ITclub

العودة إلى Digital Engineering
محاضرة 7

Review: Logic Gates, DeMorgan's, and K-Maps

مراجعة سريعة على البوابات، جداول الحقيقة، (SOP/POS)، وقوانين (DeMorgan)، مع أمثلة على (K-Maps).

ملخص المحاضرة

📜 Comprehensive Summary: Digital Engineering (Lectures 1-6)

This summary covers the foundational concepts of digital engineering, from basic number systems to logic gates, Boolean algebra, and circuit simplification techniques.

Lecture 1: Introduction to Digital Engineering

This lecture introduces the core concepts of digital systems and number theory.

Key Concepts

  • Hardware vs. Software: Electronic devices consist of physical circuits (Hardware) and the programs that run on them (Software). This course focuses on Digital Logic Design, which is the design of the hardware.
  • Digital vs. Analog:
    • Analog: A continuous signal (e.g., a sound wave) that can have any value within a range.
    • Digital: A discrete signal that can only have two distinct values: 0 (Low, Off) or 1 (High, On). Digital systems are preferred for their accuracy and noise immunity.
  • Logic Levels: The binary 0 and 1 are physically represented by voltage ranges. For example, 0V-0.8V might be Logic 0, and 2V-5V might be Logic 1.
  • Building Blocks: The basic units of all digital circuits are Logic Gates (AND, OR, NOT).
  • Number Systems:
    • Binary (Base 2): Uses digits 0 and 1.
    • Octal (Base 8): Uses digits 0-7.
    • Decimal (Base 10): Uses digits 0-9.
    • Hexadecimal (Base 16): Uses digits 0-9 and letters A (10) through F (15).
  • Number Conversions:
    • Decimal to Base-N: Use repeated division by the base (e.g., divide by 2 for binary) and read the remainders from bottom to top.
    • Base-N to Decimal: Use the sum of powers (e.g., for binary 1101, calculate 1*2^3 + 1*2^2 + 0*2^1 + 1*2^0 = 13).

Lecture 2: Basic Gates

This lecture defines the fundamental logic gates, their symbols, expressions, and truth tables.

Key Concepts

  • NOT Gate (Inverter): A 1-input gate. The output is the inverse of the input.
    • Expression: X = A'
  • AND Gate: The output is 1 if and only if ALL inputs are 1.
    • Expression: X = A · B
  • OR Gate: The output is 1 if AT LEAST ONE input is 1.
    • Expression: X = A + B
  • XOR Gate (Exclusive-OR): The output is 1 if and only if the inputs are DIFFERENT. For 3+ inputs, it outputs 1 if there is an odd number of 1s.
    • Expression: X = A ⊕ B
  • NAND Gate (Not-AND): An AND gate followed by an inverter. The output is 0 only when all inputs are 1.
    • Expression: X = (A · B)'
  • NOR Gate (Not-OR): An OR gate followed by an inverter. The output is 1 only when all inputs are 0.
    • Expression: X = (A + B)'
  • XNOR Gate (Exclusive-NOR): An XOR gate followed by an inverter. The output is 1 if and only if the inputs are the SAME.
    • Expression: X = (A ⊕ B)'
  • Universal Gates: NAND and NOR are "universal" because any other gate can be built from them. For example, tying both inputs of a NAND gate together creates a NOT gate.
  • Circuit Analysis: The lecture shows how to derive the truth table for a complex circuit, proving (A NAND B) AND (A OR B) is equivalent to A XOR B.

Lecture 3: Truth Tables

This lecture details the process of constructing truth tables, which describe a circuit's output for every possible input.

Key Concepts

  • Purpose: A truth table is the first step in logic design. It lists all possible input combinations (2^n rows for n inputs) and the corresponding desired output.
  • Filling Inputs: A systematic method is used to list all combinations:
    • The right-most input (e.g., C) alternates: 0, 1, 0, 1...
    • The next input (e.g., B) alternates: 0, 0, 1, 1...
    • The left-most input (e.g., A) alternates: 0, 0, 0, 0, 1, 1, 1, 1...
  • Creating a Truth Table From...
    1. A Word Description: (e.g., "3-bit prime number detector"). You analyze the problem (primes are 2, 3, 5, 7) and place a 1 in the output column for those input rows (010, 011, 101, 111) and 0 for all others.
    2. A Boolean Equation: (e.g., F = A·B' + C). You substitute the A, B, and C values from each row into the equation to find the resulting F.
    3. An Unknown Circuit: (Reverse Engineering). You empirically test the circuit by applying every input combination (e.g., 000 to 111) and measuring the output (Low=0, High=1) to fill the table.

Lecture 4: Minterms and Maxterms

This lecture explains how to convert a truth table into a formal Boolean equation using two standard (canonical) forms.

Key Concepts

  • Minterms (m) & Sum of Products (SOP)

    • Minterm: A product (AND) term that corresponds to a single row where the function F=1.
    • Rule: If the input variable is 0, it is complemented (A'). If it is 1, it is uncomplemented (A).
    • Example: Input A=0, B=1, C=0 (Decimal 2) is Minterm m2 = A'BC'.
    • SOP (Sum of Products): The final function is the sum (OR) of all minterms where F=1.
    • On-Set: The list of minterms where F=1. (e.g., F = Σm(2, 3, 5, 7)).
    • Circuit: Implemented as an AND-OR circuit.
  • Maxterms (M) & Product of Sums (POS)

    • Maxterm: A sum (OR) term that corresponds to a single row where the function F=0.
    • Rule (Opposite of Minterms): If the input variable is 0, it is uncomplemented (A). If it is 1, it is complemented (A').
    • Example: Input A=0, B=0, C=1 (Decimal 1) is Maxterm M1 = A + B + C'.
    • POS (Product of Sums): The final function is the product (AND) of all maxterms where F=0.
    • Off-Set: The list of maxterms where F=0. (e.g., F = ΠM(0, 1, 4, 6)).
    • Circuit: Implemented as an OR-AND circuit.
  • Implementation: Both SOP and POS forms create circuits for the same function. SOP (AND-OR) circuits can be converted to NAND-NAND circuits, and POS (OR-AND) can be converted to NOR-NOR.


Lecture 5: Boolean Algebra & Simplification

This lecture introduces the mathematical rules of Boolean Algebra, which are used to simplify complex expressions into smaller, cheaper, and faster circuits.

Key Concepts

  • DeMorgan's Laws:
    • (X + Y)' = X' · Y' (Break the bar, change the OR to AND)
    • (X · Y)' = X' + Y' (Break the bar, change the AND to OR)
  • Basic Boolean Laws:
    • Identity: X + 0 = X and X · 1 = X
    • Annihilator: X + 1 = 1 and X · 0 = 0
    • Idempotent: X + X = X and X · X = X
    • Complementarity: X + X' = 1 and X · X' = 0
    • Distributive: X(Y + Z) = XY + XZ and X + YZ = (X + Y)(X + Z)
  • Duality (F^D):
    • To find the Dual, swap all + and · and swap all 0 and 1.
    • Variables and complements (like A' or B') are left unchanged.
    • Example: The Dual of F = A·B' + C is F^D = (A + B') · C.
  • Key Simplification Theorems:
    1. Absorption: X + XY = X (and its dual X(X + Y) = X)
    2. Adjacency: XY + XY' = X (and its dual (X+Y)(X+Y') = X)
    3. Redundancy: XY + X'Z + YZ = XY + X'Z (The YZ term is redundant).
  • Minimization Example: The prime detector function f = A'BC' + A'BC + AB'C + ABC is simplified using these laws.
    1. (A'BC' + A'BC) simplifies to A'B (Adjacency).
    2. (A'BC + ABC) simplifies to BC (Adjacency).
    3. (AB'C + ABC) simplifies to AC (Adjacency).
    4. The expression becomes f = A'B + BC + AC.
    5. Using the Redundancy theorem (XY + X'Z + YZ), the BC term is redundant.
    6. Final Simplified Function: f = A'B + AC.

Lecture 6: Karnaugh Maps (K-Maps)

This lecture introduces the Karnaugh Map (K-map), a graphical and systematic method for simplifying Boolean expressions, serving as a visual alternative to Boolean algebra.

Key Concepts

  • Purpose: K-maps provide a simple, visual, and systematic way to perform Boolean simplification.
  • K-Map Structure (3-Variable):
    • An 8-cell grid (2^3 = 8).
    • The rows are labeled for one variable (e.g., A as 0 or 1).
    • The columns are labeled for the other variables (e.g., BC).
  • Gray Code: The column/row labels must be in Gray code order (00, 01, 11, 10). This is not a standard binary count. This ordering is critical because it ensures any two adjacent cells differ by only one bit.
  • Adjacency: The map "wraps around," meaning the first column (00) is adjacent to the last column (10).
  • SOP Simplification Steps:
    1. Draw & Fill Map: Draw the 3-variable map. Place a 1 in each cell corresponding to a minterm in the function's On-Set (e.g., for f = Σm(2, 3, 5, 7)).
    2. Group the 1s: Draw loops around adjacent 1s.
      • Groups must contain a power of 2 (1, 2, 4, 8) cells.
      • Groups must be as large as possible.
      • You must use the minimum number of groups to cover all the 1s.
      • Groups can overlap and wrap around.
    3. Read the Groups: For each group, find the variable(s) that do not change value.
      • If a variable is 0 in the whole group, it's complemented (e.g., A').
      • If a variable is 1 in the whole group, it's uncomplemented (e.g., A).
      • If a variable changes (is both 0 and 1) within the group, it is eliminated.
    4. Sum the Terms: The final simplified expression is the sum (OR) of all the group terms.
  • Example (Prime Detector): f = Σm(2, 3, 5, 7)
    • Group 1: A loop around m2 (010) and m3 (011).
      • A is 0 (A'). B is 1 (B). C changes (0->1) (eliminated).
      • Term = A'B
    • Group 2: A loop around m5 (101) and m7 (111).
      • A is 1 (A). B changes (0->1) (eliminated). C is 1 (C).
      • Term = AC
    • (Note: A group of (m3, m7) for BC is redundant, as its 1s are already covered).
    • Final Result: f = A'B + AC.