Build every logic gate from NAND gates
NAND is a universal gate: with enough of them you can build any logic circuit, all the way up to a computer. These guides start from a single NAND and build up, one gate at a time, to a working 4-bit adder.
Each guide shows the circuit, explains why it works, and gives the truth table and the number of NAND gates it takes. Click the inputs on any diagram to watch the signals change, or open the circuit in NAND Bricks to rebuild it yourself.
- NOT gate1 NAND
One NAND with both inputs tied together. The first brick everything else is built on.
- AND gate2 NAND
A NAND, then a NOT. Two gates.
- OR gate3 NAND
Flip both inputs, then NAND them. De Morgan's law in three gates.
- NOR gate4 NAND
An OR followed by a NOT. Four gates.
- XOR gate4 NAND
The classic four-NAND circuit. 1 when the inputs differ.
- XNOR gate5 NAND
XOR, then flip it. 1 when the inputs match.
- Multiplexer (MUX)4 NAND
A switch made of four gates: S picks whether A or B gets through.
- Half adder5 NAND
Adds two bits. XOR for the sum, AND for the carry, sharing a gate: five total.
- Full adder9 NAND
Adds two bits plus a carry. The classic nine-NAND design.
- 4-bit adder32 NAND
A half adder and three full adders, chained. Adds two numbers from 0 to 15.
Why NAND?
A NAND gate outputs 0 only when both of its inputs are 1. Feed it the same signal twice and it becomes NOT. Follow it with NOT and it becomes AND. Put NOTs in front and, by De Morgan's law, it becomes OR. Once you have NOT, AND and OR, you can write any truth table as a circuit. That makes NAND a natural place to start, and it is why courses like Nand to Tetris begin with it.
How to use these guides
Work through them in order. Each one reuses the ones before it, which is exactly how NAND Bricks works: build a circuit, save it as a brick, and place that brick inside the next one. By the 4-bit adder you will have 32 NAND gates working together, and you can still see every one of them.