XNOR from five NAND gates — XNOR gate
exam standardone gate more than XOR
Answer
5 NAND gates realising A′ · B′ + A · B
Why this example is worth doing
Building XNOR from NANDs costs one more gate than XOR, since the cheapest route is the four-NAND XOR followed by a NAND inverter. The page uses this to make a point about universal-gate costs generally: they are not symmetric, and the count depends on which primitive you start from, so a design decision to standardise on one gate type has a real and asymmetric price that shows up function by function.
Try your own input in the XNOR gate. Truth table, symbol and algebraic form for A ⊙ B, the equality detector.
How the answer is reached
Gate list
| Node | Gate | Inputs |
|---|---|---|
| g1 | nand | A, B |
| g2 | nand | A, g1 |
| g3 | nand | g1, B |
| g4 | nand | g2, g3 |
| g5 | nand | g4, g4 |
NAND-only realisation
A ↑ (A ↑ B) ↑ (A ↑ B ↑ B) ↑ (A ↑ (A ↑ B) ↑ (A ↑ B ↑ B))A′ · B′ + A · B— 5 NAND gates, verified by reading the network back out.
Truth table
| # | A | B | A ↑ (A ↑ B) ↑ (A ↑ B ↑ B) ↑ (A ↑ (A ↑ B) ↑ (A ↑ B ↑ B)) |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 |
| 2 | 1 | 0 | 0 |
| 3 | 1 | 1 | 1 |