Digital LogicUnit 18 min read

Digital Logic Basics: Binary Systems, Boolean Algebra & Number Systems

Unit 1 of Digital Logic covers the foundational concepts of digital systems, including binary numbers, Boolean algebra, logic operations, and their real-world applications in computing and electronics. This note explains how digital systems represent data, perform logical operations, and solve problems using Boolean al


1. Digital Systems: Why Binary?

Digital systems use binary (base-2) because:

  • Reliability: Binary signals (0/1, off/on) are easier to transmit and store without noise interference.
  • Simplicity: Electronic components (transistors, switches) naturally represent two states.
  • Scalability: Complex operations break down into simple binary logic.

Binary vs. Decimal vs. Hexadecimal

System Base Digits Used Example (Value 15) Use Case
Binary 2 0, 1 1111 Computer hardware, logic gates
Decimal 10 0–9 15 Human-readable numbers
Hexadecimal 16 0–9, A–F 0xF Memory addressing, shorthand
Binary0000Octal000Decimal0-9Hexadecimal0-F
Comparison of number systems: Binary (base-2), Octal (base-8), Decimal (base-10), and Hexadecimal (base-16)

How Binary Works: Weighted Positions

Each binary digit (bit) represents a power of 2, starting from the right (LSB = Least Significant Bit):

Bit Position: 7 6 5 4 3 2 1 0
Binary:       1 0 1 1 0 1 0 1
Decimal:      2^7 + 0 + 2^5 + 2^4 + 0 + 2^2 + 0 + 2^0 = 128 + 0 + 32 + 16 + 0 + 4 + 0 + 1 = **181**

Worked Example (Real-World Tie-In):

  • Ncell’s Network Signal Strength Ncell’s 4G/5G modems display signal strength in dBm (decibels-milliwatts), but internally, the router’s processor uses binary to represent signal levels (e.g., 0001 = weak, 1111 = strong). Convert 1010 to decimal:
    1×2³ + 0×2² + 1×2¹ + 0×2⁰ = 8 + 0 + 2 + 0 = **10 (strong signal)**
    

2. Boolean Algebra: The Math of Logic

Boolean algebra defines operations on binary variables (true/false, 1/0). Key operations:

  • AND (· or ∧): Output is 1 only if all inputs are 1.
  • OR (+ or ∨): Output is 1 if any input is 1.
  • NOT (' or ¬): Inverts the input (1 → 0, 0 → 1).

Truth Tables: Visualizing Logic

A B A AND B A OR B NOT A
0 0 0 0 1
0 1 0 1 1
1 0 0 1 0
1 1 1 1 0
A \ B010110111213F = A' + B
Karnaugh map for AND gate (A AND B) showing all possible input combinations

Boolean Algebra Laws (Simplify Like Algebra!)

Law Expression Example
Commutative A + B = B + A X + Y = Y + X
Associative (A + B) + C = A + (B + C) (P + Q) + R = P + (Q + R)
Distributive A · (B + C) = A·B + A·C X·(Y + Z) = XY + XZ
Identity A + 0 = A P + 0 = P
Complement A + A' = 1 X + X' = 1 (always true)

Worked Example: Simplifying a Real Circuit Problem: Simplify F = A·B + A·C + A·D (used in a Khalti payment gateway to validate multiple transaction flags). Solution:

  1. Factor out A: F = A·(B + C + D)
  2. Application: This simplified logic reduces the number of gates in Khalti’s fraud-detection module, saving power and cost.

3. Number System Conversions

Binary to Decimal (and Vice Versa)

Method:

  1. Multiply each bit by 2ⁿ (where n = position from right, starting at 0).
  2. Sum the results.

Example: Convert 101101 (binary) to decimal.

1×2⁵ + 0×2⁴ + 1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 32 + 0 + 8 + 4 + 0 + 1 = **45**

Decimal to Binary (Division by 2)

Example: Convert 29 to binary.

29 ÷ 2 = 14 (remainder 1)
14 ÷ 2 = 7  (remainder 0)
7 ÷ 2 = 3   (remainder 1)
3 ÷ 2 = 1   (remainder 1)
1 ÷ 2 = 0   (remainder 1)
Read remainders upward: **11101**

Hexadecimal (Hex) Shortcut

  • Group binary into 4 bits (nibbles).
  • Each nibble maps to a hex digit (0–F).

Example: Convert 1101 1010 to hex.

1101 = D, 1010 = A → **DA**

Real-World Use:

  • Daraz’s Order IDs: Internally, Daraz uses hex to represent order numbers (e.g., A7F2) for compact storage in databases. Convert 1010 0111 1111 0010 to hex:
    1010 = A, 0111 = 7, 1111 = F, 0010 = 2 → **A7F2**
    

4. Logic Gates: Building Blocks of Digital Circuits

Logic gates implement Boolean operations. Here are the 7 basic gates with symbols and truth tables:

1. AND Gate

FAB
AND gate symbol with inputs A, B and output F
A B F (A AND B)
0 0 0
0 1 0
1 0 0
1 1 1

Application: Used in NTC’s electricity billing to check if both power_used > threshold AND payment_received = 1 before disconnecting supply.


2. OR Gate

FAB
OR gate symbol with inputs A, B and output F
A B F (A OR B)
0 0 0
0 1 1
1 0 1
1 1 1

Application: In Pathao’s ride-booking, an OR gate triggers if either driver_available = 1 OR auto_rental_active = 1.


3. NOT Gate (Inverter)

FA
NOT gate (inverter) symbol with input A and output F
A F (NOT A)
0 1
1 0

Application: Used in bank ATMs to invert card_swiped signal if card_rejected = 1.


4. NAND and NOR Gates (Universal Gates)

  • NAND: NOT + AND
  • NOR: NOT + OR Why Universal? Any logic circuit can be built using only NAND or only NOR gates.

5. Combining Gates: Real-World Circuits

Example: Traffic Light Controller (Kathmandu’s Signals)

Problem: Design a circuit where the light turns green only if:

  • car_sensor = 1 AND pedestrian_button = 0.

Solution:

  1. Use an AND gate for car_sensor and NOT pedestrian_button.
  2. Connect to a relay to trigger the green light.
green_lightcar_sensorpedestrian_button
Traffic light logic: Green light activates when car_sensor=1 AND pedestrian_button=0 (using NOT gate for pedestrian_button)

Exam Tip: Always draw the circuit diagram for such problems!


## In the Real World

  1. eSewa’s Payment Validation

    • Uses Boolean logic to check if user_verified = 1 AND amount ≤ balance before processing a transaction.
    • AND gate ensures both conditions are met simultaneously.
  2. NEPSE Stock Market Tickers

    • Stock prices are stored in binary/hex for fast processing. For example, a price like ₹125 is converted to binary (1111101) for internal calculations in trading algorithms.
  3. WhatsApp’s End-to-End Encryption

    • Messages are split into binary packets, encrypted using Boolean-based algorithms (e.g., XOR gates), and reassembled only for the intended recipient.

## Exam Tip

  1. Memorize Truth Tables: For AND, OR, NOT, NAND, NOR. Examiners often ask to complete partial tables.
  2. Practice Conversions: Binary ↔ Decimal ↔ Hex. Use the division-by-2 method for decimal to binary.
  3. Draw Circuits: Always sketch gate diagrams for problems involving logic combinations.
  4. Simplify Before Building: Use Boolean laws to reduce gates in circuits (saves marks in design questions).
  5. Real-World Links: Relate problems to Ncell signals, Khalti payments, or NTC billing to score application-based questions.
  6. Common Pitfalls:
    • Forgetting to invert inputs in NOR/NAND.
    • Misplacing bit positions in binary (start counting from 0).
    • Overcomplicating simplifications—stick to laws!

Based on the TU BIM syllabus for Digital Logic (IT233), unit 1.

Discussion

Loading…