Boolean Logic & Gates
At the hardware level, every computation is about true/false (1/0) decisions. Logic gates are the physical building blocks that perform these Boolean operations inside every CPU.
Learning Objectives
- 11.3.3.3 Build truth tables for AND, OR, NOT, NAND, NOR, XOR
Conceptual Anchor
The Light Switch Analogy
AND gate = two switches in series (BOTH must be ON for the light to turn on). OR gate = two switches in parallel (EITHER one turns the light on). NOT gate = an inverter (if switch is ON, light is OFF and vice versa).
Rules & Theory
Logic Gate Summary
| Gate | Symbol | Rule | Expression |
|---|---|---|---|
| AND | A · B | Output 1 only if BOTH inputs are 1 | Q = A AND B |
| OR | A + B | Output 1 if ANY input is 1 | Q = A OR B |
| NOT | Ā or ¬A | Output is the OPPOSITE of input | Q = NOT A |
| NAND | A · B̄ | Opposite of AND (NOT AND) | Q = NOT (A AND B) |
| NOR | A + B̄ | Opposite of OR (NOT OR) | Q = NOT (A OR B) |
| XOR | A ⊕ B | Output 1 if inputs are DIFFERENT | Q = A XOR B |
Truth Tables
NOT (1 input): AND (2 inputs): OR (2 inputs):
A │ Q A B │ Q A B │ Q
───┼─── ─────┼─── ─────┼───
0 │ 1 0 0 │ 0 0 0 │ 0
1 │ 0 0 1 │ 0 0 1 │ 1
1 0 │ 0 1 0 │ 1
1 1 │ 1 1 1 │ 1
NAND: NOR: XOR:
A B │ Q A B │ Q A B │ Q
─────┼─── ─────┼─── ─────┼───
0 0 │ 1 0 0 │ 1 0 0 │ 0
0 1 │ 1 0 1 │ 0 0 1 │ 1
1 0 │ 1 1 0 │ 0 1 0 │ 1
1 1 │ 0 1 1 │ 0 1 1 │ 0Memory Tricks
| Gate | Memory Aid |
|---|---|
| AND | "Both must agree" — 1 AND 1 = 1 |
| OR | "At least one" — any 1 makes output 1 |
| NOT | "Flip it" — 0→1, 1→0 |
| NAND | "Not AND" — flip the AND output |
| NOR | "Not OR" — flip the OR output |
| XOR | "eXclusive" — different inputs = 1, same = 0 |
NAND: The Universal Gate
Any logic circuit can be built using only NAND gates. This is why NAND is called a "universal gate". In practice, NAND-based chips are cheaper to manufacture, so most integrated circuits use NAND gates internally.
Worked Examples
1 Build a Truth Table for (A AND B) OR C
A B C │ A AND B │ (A AND B) OR C
────────┼────────┼───────────────
0 0 0 │ 0 │ 0
0 0 1 │ 0 │ 1
0 1 0 │ 0 │ 0
0 1 1 │ 0 │ 1
1 0 0 │ 0 │ 0
1 0 1 │ 0 │ 1
1 1 0 │ 1 │ 1
1 1 1 │ 1 │ 1Common Pitfalls
XOR = OR
OR outputs 1 when A=1, B=1. XOR outputs 0 when both are 1 (it means "exclusively one or the other, not both").
Tasks
Draw the truth tables for all 6 gates: AND, OR, NOT, NAND, NOR, XOR.
Build a truth table for: (A OR B) AND (NOT C)
Explain why NAND is called a "universal gate". Show how to create NOT using only NAND.
Self-Check Quiz
Q1: What is the output of 1 AND 0?
Q2: What is the output of 1 XOR 1?
Q3: What gate gives the opposite output of OR?