How to Build Logic from NAND
Nine simulator elements, from an inverter to a D flip-flop, are built from NAND gates alone. Each card has a circuit, a price in gates and transistors, and a real 74-series chip. If you have not passed levels 3–5 yet, try building NOT, AND, and OR yourself first: that is the task there.
NOT (Inverter)
Both inputs of one NAND are tied together. With a 0 at the input the NAND sees two zeros and outputs 1; with a 1 it outputs 0.
In silicon an inverter takes 2 transistors — one p-channel and one n-channel. Four NAND gates are not needed.
AND
NAND answers "not both", so its output is inverted by a second NAND with tied inputs. The result is "both".
AND in silicon is a NAND plus an inverter, about 6 transistors.
OR
Two NANDs act as inverters for A and B, and a third combines them by De Morgan: ¬(¬A · ¬B) = A + B.
OR is built as NOR plus an inverter: about 6 transistors.
XOR (Exclusive OR)
The first NAND computes ¬(A·B), the next two mix it with A and B, and the last one assembles the difference: 1 only when the inputs differ.
Silicon XOR is not built from four NANDs: an optimised circuit takes about 12 transistors.
NOR
Two NANDs invert A and B, a third computes their AND, and a fourth inverts the result. The output is 1 only when both inputs are 0.
CMOS NOR takes 4 transistors: two p-channel in series and two n-channel in parallel.
MUX (Multiplexer 2→1)
A NAND with tied inputs makes ¬Sel; two NANDs prepare ¬(A·¬Sel) and ¬(B·Sel); the last NAND combines them by De Morgan and selects the input with Sel.
A 2-to-1 multiplexer in silicon uses transmission gates: about 12 transistors.
Half Adder
Five NANDs: four build the XOR for the sum, and the fifth inverts the shared NAND(A,B) to produce the carry. One gate serves two formulas.
A half adder in silicon takes about 18 transistors; it has no separate chip and exists inside the 74HC283 adder.
Full Adder
Two XORs in a row add A, B, and Cin. The carry is "at least two of three": a ninth gate combines the shared NAND(A,B) with NAND(X,Cin).
A full adder is optimised to about 28 transistors. In the 74 series this is the four-bit 74HC283 — four such blocks in one package.
DFF (D Flip-Flop)
Six NANDs: two turn D into the pair D and ¬D, two pass them to the latch only while the clock is high, and two hold the result. While Clock=0 the data is locked; on the rising edge the value of D reaches Q.
A D flip-flop in silicon takes about 24 transistors. In the 74 series this is the 7474: two flip-flops in one package.
NAND
NAND is the primitive the course starts from. Every other element on this page is built from it, and in CMOS it costs four transistors.
In the 74 series it is the 7400: four two-input NAND gates in one package. Building NAND out of NAND makes no sense — it is the brick itself.
Why one NAND is enough
NAND is functionally complete: NOT, AND, and OR can all be expressed through it, and any digital circuit, including a processor, can be built from those. That is why the course starts with NAND and only then unlocks the other elements.