CSC116 Digital Logic

Digital LogicUnit 210 min read

Boolean Algebra & Logic Gates: Laws, Simplification & Gate Design

Unit 2 of Digital Logic covers Boolean algebra fundamentals (laws, theorems, simplification), standard logic gates (AND, OR, NOT, NAND, NOR, XOR, XNOR), their universal equivalence, and practical circuit design using De Morgan’s laws and Karnaugh Maps (K-maps).

TAKEAWAYS:

  • Boolean algebra is the math of binary logic, with laws like idempotent, complement, and distributive that simplify digital circuits.
  • Logic gates (AND, OR, NOT, etc.) are physical implementations of Boolean operations, and NAND/NOR are universal—any function can be built using just one type.
  • De Morgan’s laws convert AND/OR expressions to NAND/NOR forms, critical for gate-level design.
  • Karnaugh Maps (K-maps) visually simplify Boolean functions by grouping adjacent 1s/0s, reducing hardware complexity.
  • Real-world applications include eSewa’s payment validation (AND logic for multi-factor checks), Khalti’s fraud detection (XOR for anomaly flags), and Ncell’s call routing (MUX/DEMUX for dynamic path selection).

1. Boolean Algebra: The Math Behind Digital Logic

Boolean algebra is a branch of algebra that deals with binary variables (0 and 1) and logical operations (AND, OR, NOT). It forms the foundation for designing digital circuits.

Key Definitions

  • Binary Variables: Variables that take only two values: 0 (false/low) or 1 (true/high).
  • Boolean 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 (0 → 1, 1 → 0).

Boolean Algebra Laws

These laws are used to simplify and manipulate Boolean expressions.

Law Expression Explanation
Identity A + 0 = A, A · 1 = A Adding 0 or multiplying by 1 leaves the variable unchanged.
Complement A + A' = 1, A · A' = 0 A variable OR its complement is always 1; AND is always 0.
Idempotent A + A = A, A · A = A Repeating a variable in AND/OR doesn’t change the result.
Commutative A + B = B + A, A · B = B · A Order of variables doesn’t matter.
Associative (A + B) + C = A + (B + C) Grouping doesn’t affect the result.
Distributive A · (B + C) = (A · B) + (A · C) Like multiplication over addition in regular algebra.
Absorption A + (A · B) = A, A · (A + B) = A Reduces redundant terms.
De Morgan’s (A + B)' = A' · B', (A · B)' = A' + B' Converts AND/OR to OR/AND with complements.

Worked Example: Simplifying a Boolean Expression

Problem: Simplify F = A + A'B + AB'C using Boolean laws. Solution:

  1. Factor A from the first and third terms: F = A(1 + B'C) + A'B
  2. Since 1 + B'C = 1, simplify to: F = A + A'B
  3. This is the simplified SOP (Sum of Products) form.

2. Logic Gates: The Building Blocks of Digital Circuits

Logic gates are physical implementations of Boolean operations. They are the basic elements of digital circuits.

Standard Logic Gates

graph LR
    AND["AND Gate\nA·B"] -->|"Output"| ANDout
    OR["OR Gate\nA+B"] -->|"Output"| ORout
    NOT["NOT Gate\nA'"] -->|"Output"| NOTout
    NAND["NAND Gate\n(A·B)'"] -->|"Output"| NANDout
    NOR["NOR Gate\n(A+B)'"] -->|"Output"| NORout
    XOR["XOR Gate\nA⊕B"] -->|"Output"| XORout
    XNOR["XNOR Gate\nA⊙B"] -->|"Output"| XNORout
Gate Symbol Truth Table Boolean Expression Key Use Case
AND `--- > ---` `A B
OR `--- > ---` `A B
NOT `--- > ---` `A
NAND `--- > ---` `A B
NOR `--- > ---` `A B
XOR `--- > ---` `A B
XNOR `--- > ---` `A B

Universal Gates: NAND and NOR

  • NAND and NOR gates are universal—any Boolean function can be implemented using only NAND or only NOR gates.
  • Example: Implement A + B using NAND gates.
    1. A + B = (A' · B')' (De Morgan’s law).
    2. Use NAND gates to compute A', B', then (A' · B')'.

NAND gate IC 7400A real 7400 NAND gate IC (quad 2-input NAND). (Image: Tosaka, CC BY 3.0, via Wikimedia Commons)


3. De Morgan’s Laws: The Bridge Between AND/OR and NAND/NOR

De Morgan’s laws allow conversion between AND/OR and NAND/NOR expressions, critical for gate-level design.

De Morgan’s Laws

  1. (A + B)' = A' · B'
  2. (A · B)' = A' + B'

Worked Example: Converting to NAND/NOR

Problem: Convert F = (A + B)' · C to NAND-only form. Solution:

  1. Apply De Morgan’s to (A + B)': F = (A' · B') · C
  2. Replace · with NAND (since X · Y = (X' + Y')'): F = ((A' NAND B') NAND C')'
  3. Use NAND gates to implement.

4. Karnaugh Maps (K-Maps): Simplifying Boolean Functions Visually

K-maps are graphical tools to simplify Boolean expressions by grouping adjacent 1s (for SOP) or 0s (for POS).

Steps to Simplify Using K-Map

  1. List all minterms (for SOP) or maxterms (for POS).
  2. Draw the K-map (2^n cells for n variables).
  3. Group adjacent 1s in powers of 2 (1, 2, 4, 8, ...).
  4. Write the simplified expression from each group.

Example: Simplifying F(A,B,C,D) = Σ(0,1,3,5,7,8,9,11,13,15)

  1. K-map for 4 variables (A,B,C,D):
   CD\AB | 00 | 01 | 11 | 10
   -------------------------
     00  |  1 |  1 |  0 |  1
     01  |  1 |  1 |  1 |  0
     11  |  1 |  1 |  1 |  1
     10  |  1 |  0 |  1 |  1
  1. Grouping:
    • Group of 8: A'C'D (top-left 8 cells).
    • Group of 4: A'BD (middle-left 4 cells).
    • Group of 2: AB'C (bottom-right 2 cells).
  2. Simplified SOP: F = A'C'D + A'BD + AB'C

5. Real-World Applications of Boolean Logic

1. eSewa’s Payment Validation (AND Logic)

  • Scenario: eSewa requires both a PIN and a fingerprint for high-value transactions.
  • Boolean Logic Used:
    • Payment_Approved = PIN_Valid AND Fingerprint_Match
    • If either fails, the transaction is blocked (0).

2. Khalti’s Fraud Detection (XOR Logic)

  • Scenario: Khalti flags transactions where the amount or time is inconsistent with user behavior.
  • Boolean Logic Used:
    • Fraud_Alert = (Amount_Expected ⊕ Actual_Amount) OR (Time_Expected ⊕ Actual_Time)
    • XOR detects exclusive mismatches.

3. Ncell’s Call Routing (MUX/DEMUX)

  • Scenario: Ncell routes calls dynamically based on network congestion.
  • Boolean Logic Used:
    • Multiplexer (MUX): Selects the best tower for a call using Select lines.
    • Demultiplexer (DEMUX): Distributes calls to multiple towers based on Data and Select.

4. Daraz’s Order Queue (Priority Encoder)

  • Scenario: Daraz prioritizes orders based on payment status, urgency, and stock availability.
  • Boolean Logic Used:
    • Priority Encoder: Assigns a binary priority code to each order type (e.g., Paid_High = 11, Paid_Low = 01).

6. Exam Tip: How to Score Full Marks

  1. For Boolean Simplification:

    • Always show intermediate steps (e.g., applying laws one by one).
    • For K-maps, circle groups clearly and label them with the simplified term.
    • Example: If asked to simplify F = A'BC + AB'C + ABC', show:
      • Group A'BC + AB'C = C(B + AB') → C(B + A) → C(B + A) (no further simplification).
  2. For Gate Circuits:

    • Draw standard gate symbols (no stick figures).
    • Label inputs/outputs clearly (e.g., A, B → F = A + B).
    • For NAND/NOR-only implementations, explicitly state De Morgan’s steps.
  3. For Truth Tables:

    • List all possible inputs (2^n rows for n variables).

    • Highlight outputs in bold or color.

    • Example: For F = A XOR B, show:

      A B F = A⊕B
      0 0 0
      0 1 1
      1 0 1
      1 1 0
  4. For Real-World Questions:

    • Relate to known systems (e.g., "Like eSewa’s AND gate for multi-factor auth").
    • Draw a simple block diagram (e.g., a MUX for call routing).

Summary Table: Key Concepts at a Glance

Topic Key Idea Exam Focus
Boolean Laws Simplify expressions using identities. Apply laws step-by-step.
Logic Gates Physical implementation of Boolean ops. Draw circuits, identify universal gates.
De Morgan’s Laws Convert AND/OR ↔ NAND/NOR. Convert expressions to NAND/NOR only.
K-Maps Simplify functions visually. Group correctly, write simplified SOP/POS.
Real-World Applications Boolean logic in apps (eSewa, Khalti). Explain how logic gates are used.

Final Note: Practice simplifying expressions and drawing gate circuits daily. Use K-maps for 3-4 variable functions to master grouping. For exams, always justify your steps—examiners reward clarity!

Based on the TU BSc CSIT syllabus for Digital Logic (CSC116), unit 2.

Discussion

Loading…