CE2704 · Digital Logic Design
Theme 2 · Boolean algebra & logic gates
The derived gates: NAND, NOR, XOR, XNOR
Four more gates built from the first three. Two of them can build everything; the other two are the heart of arithmetic and comparison.
Built from first principles.
Before you start
What you need first
- Basic gates (AND/OR/NOT + the bubble = invert).
- Truth tables — to read each gate's behaviour.
What you'll be able to do
- Recognise and use NAND, NOR, XOR, XNOR.
- Explain why NAND and NOR are universal.
- Know what XOR ("different") and XNOR ("same") are for.
NAND — "NOT AND"
AND with an output bubble.
F = (A·B)′| A | B | F |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Universal: AND, OR and NOT can all be built from NANDs
alone — so any circuit can. Foundries love NAND: it's the smallest, fastest
gate to make in CMOS.
NOR — "NOT OR"
OR with an output bubble.
F = (A+B)′| A | B | F |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
Also universal. The Apollo Guidance Computer (1965) was
built from ~5600 NOR gates — and nothing else.
XOR — exclusive OR ("different")
OR shape + extra back curve.
F = A⊕B| A | B | F |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Output is 1 when the inputs differ. XOR is the heart of
binary addition, parity, error-detection codes, and cryptography.
XNOR — "same"
XOR with an output bubble.
F = (A⊕B)′| A | B | F |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Output is 1 when the inputs are equal. The equality
detector — used in comparators (you'll build one in Theme 4).
All seven gates at a glance
| Gate | Expression | Output 1 when… | Use |
|---|---|---|---|
| AND | A·B | both inputs 1 | "all conditions" |
| OR | A+B | at least one 1 | "any condition" |
| NOT | A′ | input is 0 | inversion |
| NAND | (A·B)′ | not both 1 | universal, cheap CMOS |
| NOR | (A+B)′ | both 0 | universal |
| XOR | A⊕B | inputs differ | adders, parity |
| XNOR | (A⊕B)′ | inputs equal | equality |
Only three (AND/OR/NOT) are truly independent — the rest are convenient
shorthand. But NAND or NOR alone is enough to build them all.
✏️ Try it yourself
(a) NAND(1,1)? (b) NOR(0,0)? (c) XOR(1,1)?
(d) Which gate outputs 1 only when its inputs are equal?
(a) AND(1,1)=1, NOT 1 = 0.
(b) OR(0,0)=0, NOT 0 = 1.
(c) inputs are the same → 0 (XOR fires only when they differ).
(d) XNOR.
Recap — the whole topic on one screen
| Gate | Memory hook |
|---|---|
| NAND / NOR | AND/OR + bubble; each is universal |
| XOR | "different" → 1; the adder/parity gate |
| XNOR | "same" → 1; the equality gate |