Sub topic 7
Universal Gates: NAND-Only and NOR-Only Designs
Prerequisites and the main idea
Assume you know binary values, basic logic gates, Boolean notation, and De Morgan’s laws. A NAND gate produces 0 only when all its inputs are 1:
A NAND B = ¬(A · B)
A NOR gate produces 1 only when all its inputs are 0:
A NOR B = ¬(A + B)
A gate is universal when any Boolean function can be built using only that gate type. NAND and NOR are universal because each can create NOT, AND, and OR.
Building basic gates
NAND-only designs
Use the same signal as both NAND inputs to invert it:
- NOT:
¬A = A NAND A - AND:
A · B = (A NAND B) NAND (A NAND B) - OR:
A + B = (A NAND A) NAND (B NAND B)
The OR construction follows from De Morgan’s law:
A + B = ¬(¬A · ¬B)
Thus, a NAND-only circuit naturally uses inverted intermediate signals.
NOR-only designs
The corresponding NOR constructions are:
- NOT:
¬A = A NOR A - OR:
A + B = (A NOR B) NOR (A NOR B) - AND:
A · B = (A NOR A) NOR (B NOR B)
The AND construction follows from:
A · B = ¬(¬A + ¬B)
| Required operation | NAND-only form | NOR-only form |
|---|---|---|
| NOT A | `A NAND A` | `A NOR A` |
| A AND B | `(A NAND B) NAND (A NAND B)` | `(A NOR A) NOR (B NOR B)` |
| A OR B | `(A NAND A) NAND (B NAND B)` | `(A NOR B) NOR (A NOR B)` |
Choosing the better universal gate
The expression’s structure usually suggests the better choice.
- A sum of products (SOP) expression, such as
AB + CD, maps well to NAND-NAND logic. The first level forms complemented products, and the final NAND performs the required OR through De Morgan’s law. - A product of sums (POS) expression, such as
(A + B)(C + D), maps well to NOR-NOR logic. The first level forms complemented sums, and the final NOR performs the required AND. - NAND designs often suit circuits with many AND terms.
- NOR designs often suit circuits with many OR terms.
Gate count is not the only concern. Input fan-in, propagation delay, available hardware, and the number of complemented signals also affect the design.
Worked verification
The following program checks the three NAND-only constructions and the three NOR-only constructions for every input pair.
from itertools import product
def nand(a, b):
return int(not (a and b))
def nor(a, b):
return int(not (a or b))
for a, b in product([0, 1], repeat=2):
nand_not_a = nand(a, a)
nand_and = nand(nand(a, b), nand(a, b))
nand_or = nand(nand(a, a), nand(b, b))
nor_not_a = nor(a, a)
nor_or = nor(nor(a, b), nor(a, b))
nor_and = nor(nor(a, a), nor(b, b))
assert nand_not_a == (not a)
assert nand_and == (a and b)
assert nand_or == (a or b)
assert nor_not_a == (not a)
assert nor_or == (a or b)
assert nor_and == (a and b)
print("All NAND-only and NOR-only identities are correct.")Circuit structure
Exercise
Implement F = AB + C using only NAND gates. How many two-input NAND gates are needed if each product term and the final sum use the direct NAND-NAND pattern?
Show answer
First form X = A NAND B and Y = C NAND C. Then form F = X NAND Y. Three two-input NAND gates are needed.