SECTION 03 / 5

Universal Gates — Building Everything from NAND or NOR

3 min read
On this page 5 headings

Start here Imagine a LEGO box with only one kind of brick, yet you can still build anything. NAND gates are like that: with enough NAND gates, you can build NOT, AND, OR and every other circuit. Chip factories love this, because making one kind of gate again and again is cheap and fast.

Only NAND bricks: 1 brick makes NOT, 2 make AND, 3 make OR.
Only NAND bricks: 1 brick makes NOT, 2 make AND, 3 make OR.
Open image ↗
One brick, every circuit

What “universal” means

A gate is universal if NOT, AND and OR (and so any circuit) can be built from it alone. NAND and NOR are both universal.

Everything from NAND

NOT needs 1 NAND, AND needs 2, OR needs 3, XOR needs 4.
NOT needs 1 NAND, AND needs 2, OR needs 3, XOR needs 4.
Open image ↗
Gates made from NAND
Want How, using only 2-input NAND NAND gates
NOT A NAND(A, A) 1
A AND B NAND, then a NOT made from NAND 2
A OR B NOT A, NOT B, then NAND them (De Morgan: (A‾⋅B‾)‾=A+B\overline{\left(\overline{A} \cdot \overline{B}\right)} = A + B) 3
A XOR B G1 = NAND(A,B); G2 = NAND(A,G1); G3 = NAND(B,G1); out = NAND(G2,G3) 4
A XNOR B XOR, then NOT 5

Everything from NOR

Want How, using only 2-input NOR NOR gates
NOT A NOR(A, A) 1
A OR B NOR, then NOT 2
A AND B NOT A, NOT B, then NOR them ((A‾+B‾)‾=A⋅B)\left(\overline{\left(\overline{A} + \overline{B}\right)} = A \cdot B\right) 3
A XNOR B same 4-gate pattern as NAND-XOR, but with NORs 4
A XOR B XNOR, then NOT 5

Notice the mirror: NAND makes AND cheap (2) and OR expensive (3). NOR is the opposite. XOR is cheap with NAND (4); XNOR is cheap with NOR (4).

All these counts were checked by a computer search over every possible circuit. They really are the minimum.

Two-level circuits: AND-OR becomes NAND-NAND

Replace every gate in an AND-OR circuit with a NAND. The output stays exactly the same.
Replace every gate in an AND-OR circuit with a NAND. The output stays exactly the same.
Open image ↗
AND-OR to NAND-NAND

Rule 1: an AND–OR (SOP) circuit = a NAND–NAND circuit with the same shape. Just swap every gate for a NAND.

Why? Put two “bubbles” (NOTs) on each wire between the levels. Two NOTs cancel, so nothing changes. Then the AND⁡+\operatorname{AND} + bubble becomes NAND, and the bubbles + OR becomes NAND too (De Morgan).

Rule 2: an OR–AND (POS) circuit = a NOR–NOR circuit with the same shape.

Watch out for single letters. If a product term is just one letter (like A in A+BCA + B C), it needs a NAND used as an inverter in the NAND–NAND version.

Example: A+BC→A + B C \to G1 = NAND⁡(A,A)=A‾\operatorname{NAND} \left(A , A\right) = \overline{A}; G2 = NAND(B, C); out = NAND(G1, G2) → 3 NAND gates.

In one line: NAND and NOR can each build every circuit (NAND: NOT 1, AND 2, OR 3, XOR 4; NOR: NOT 1, OR 2, AND 3, XNOR 4), and an AND–OR circuit turns into NAND–NAND just by swapping the gates. Exam words: universal gate, NAND-only, NOR-only, NAND–NAND realisation, NOR–NOR realisation, bubble pushing, De Morgan.


Quick check

How many 2-input NAND gates make an OR gate? 3.
How many 2-input NOR gates make an XNOR (an equality checker)? 4.
An SOP circuit is AND–OR. What do you get if you replace every gate with NAND? A NAND–NAND circuit that gives the same output.
YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑