AND gate using NAND gates: two gates, live
An AND gate takes two NAND gates: the first computes NAND(A, B), and the second, with both inputs tied together, inverts it. NOT NAND(A, B) = A AND B, so Y is 1 only when A and B are both 1.
NAND means NOT AND, so AND is a NAND followed by an inverter, and a NAND gate with its inputs joined is an inverter: NAND(X, X) = NOT X. This is also how CMOS chips build AND: a 4-transistor NAND plus a 2-transistor inverter, because the NAND is the natural CMOS gate (see the CMOS AND gate). The mirror of this circuit is the OR gate from two NOR gates, and the OR gate from three NAND gates and the NAND universal gates page complete the set.
Open this circuit in the lab →
What you need
- 1× NAND: N = NAND(A, B)
- 1× NAND: Y = NAND(N, N) = A AND B
Step by step
- Place inputs
AandBand a probeY. - Feed A and B into the first NAND gate.
- Feed its output into both inputs of a second NAND gate and probe that as
Y. - Try all four rows: Y is 1 only when A and B are both 1.
AND from NAND truth table
| A | B | N = NAND(A, B) | Y = A AND B |
|---|---|---|---|
| 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
All input rows are checked on the live circuit before the page is built.
You can also read the full theory in the lesson on the NAND gate. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.
More builds: Universal gates: NAND only, NOR only
All 246 build guides, by topic
Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.
Open the AND gate from NAND gates in the lab →Frequently asked
How many NAND gates are needed to make an AND gate?
Two: one NAND gate, then a second NAND gate with its inputs tied together to invert the result. NOT NAND(A, B) = A AND B.
Why are AND gates built from NAND gates in CMOS?
Because a CMOS NAND needs only four transistors and an inverter two, while there is no direct CMOS AND. An AND gate is a NAND plus an inverter, six transistors.
How many NAND gates make an OR gate?
Three: two NANDs invert A and B, and a third NANDs the inverted inputs, NAND(NOT A, NOT B) = A OR B.