Part IV: Digital Electronics | Chapter 10

Boolean Algebra & Logic Gates

AND, OR, NOT, NAND, NOR, XOR gates, De Morgan's theorems, truth tables, canonical forms, Karnaugh maps, and gate-level implementation

1. Boolean Algebra

Boolean algebra, introduced by George Boole in 1854, is a mathematical system operating on variables that take only two values: 0 (False) and 1 (True). Three fundamental operations are sufficient to express any digital function:

AND (·)
\( F = A \cdot B \)
F=1 only if both inputs are 1
OR (+)
\( F = A + B \)
F=1 if at least one input is 1
NOT ()
\( F = \overline{A} \)
Inversion: F=1 iff A=0

Key identities: \( A \cdot 0 = 0 \), \( A + 1 = 1 \),\( A \cdot A = A \), \( A + A = A \),\( A \cdot \overline{A} = 0 \), \( A + \overline{A} = 1 \). Absorption: \( A + AB = A \).

2. Logic Gate Symbols

ANDA·BABFORA+BABFNOT¬AAFNAND¬(A·B)ABFNOR¬(A+B)ABFXORA⊕BABF
Standard logic gate symbols and their Boolean expressions

NAND and NOR are universal gates — any Boolean function can be implemented using only NAND gates (or only NOR gates). This is exploited in integrated circuit fabrication where a single gate cell is used for all logic.

3. De Morgan's Theorems

De Morgan's theorems provide the key equivalences between AND/OR and complemented functions:

First Theorem
\[ \overline{A \cdot B} = \overline{A} + \overline{B} \]
NAND = negative-OR
Second Theorem
\[ \overline{A + B} = \overline{A} \cdot \overline{B} \]
NOR = negative-AND

These theorems are used to convert between SOP (sum of products) and POS (product of sums) forms, and to simplify Boolean expressions by pushing inversions through logic gates.

4. Canonical Forms & Karnaugh Maps

Any Boolean function can be written as a Sum of Products (SOP) — OR of AND terms, one per minterm — or Product of Sums (POS). The minimal SOP is found by grouping 1s in a Karnaugh map (K-map) into rectangles of size \( 2^k \).

K-Map Rules
  • • Group cells filled with 1 in powers of 2: 1, 2, 4, 8
  • • Groups may wrap around edges (toroidal)
  • • Larger groups give simpler (fewer literal) terms
  • • Every 1 must be covered; 1s may belong to multiple groups
SOP vs POS

SOP: group the 1s → simpler for active-high outputs. POS: group the 0s, complement → simpler for active-low outputs.\( F = \sum m(1,3,5,7) = C \) is the simplest possible.

5. Python: Truth Tables, K-Map & Expression Solver

Generate truth tables for all 2-input gates, display a 3-variable Karnaugh map, and evaluate five Boolean expressions over all 8 combinations of three variables (A, B, C).

Python
script.py140 lines

Click Run to execute the Python code

Code will be executed with Python 3 on the server