NAND to Tetris: Why the NAND Gate is Universally Functional

Denny Denny
4 min read
NAND to Tetris: Why the NAND Gate is Universally Functional

Digital Logic 101

đź“… January 2026 â€˘ âŹ±ď¸Ź 15 min read â€˘ đźŽ“ Intermediate

What if you could build an entire computer using just one type of logic gate? It sounds impossible, but the NAND gate makes it a reality. In this tutorial, you'll discover why NAND is called "universally functional" and learn to build AND, OR, and NOT gates using only NAND gates.

The Power of Functional Completeness

A logic gate is called functionally complete (or "universal") if you can use it to implement any Boolean function. The NAND gate has this remarkable property—with nothing but NAND gates, you can build every other gate, every circuit, and ultimately, an entire computer.

This isn't just theoretical. The famous "NAND to Tetris" course demonstrates building a complete computer from nothing but NAND gates—from basic logic all the way up to a working game of Tetris!

What is a NAND Gate?

NAND stands for "NOT AND." It's an AND gate followed by a NOT gate. The output is LOW only when ALL inputs are HIGH—the exact opposite of an AND gate.

NAND Gate: The Universal Building Block

Output is 0 only when BOTH inputs are 1. Otherwise, output is 1.

Boolean Expression:

Y = NOT(A AND B) = (A · B)' = A NAND B

Input AInput BA AND BA NAND B
0001
0101
1001
1110

Building Other Gates from NAND

Here's where the magic happens. We'll build each fundamental gate using ONLY NAND gates.

NAND Gate Universal Logic showing NOT, AND, and OR built from NAND

Three circuits showing NOT, AND, and OR gates built entirely from NAND gates. This demonstrates functional completeness.

1. Building a NOT Gate from NAND

The simplest implementation: connect both inputs of a NAND gate together!

NOT from NAND

Connect both NAND inputs to the same signal:

NOT(A) = A NAND A

When A=0: 0 NAND 0 = 1 âś“

When A=1: 1 NAND 1 = 0 âś“

2. Building an AND Gate from NAND

Use two NAND gates: the first performs NAND, the second inverts it back.

AND from NAND

NAND the inputs, then NAND the result with itself (to invert):

A AND B = (A NAND B) NAND (A NAND B)

First NAND gives us NOT(A AND B), second NAND inverts it to (A AND B).

3. Building an OR Gate from NAND

This uses De Morgan's Law: NOT(A) AND NOT(B) = NOT(A OR B).

OR from NAND

Invert both inputs, then NAND them:

A OR B = (A NAND A) NAND (B NAND B)

We first create NOT(A) and NOT(B), then NAND them together.

De Morgan's Law demonstration showing equivalent circuits

De Morgan's Law in action: NOT(A OR B) = NOT(A) AND NOT(B). This equivalence is key to understanding universal gates.

Key Insight: Why NAND is Universal

Since we can build NOT, AND, and OR from NAND gates, and since ANY Boolean function can be expressed using just these three operations, NAND is sufficient to build any digital circuit whatsoever!

Why Does This Matter?

Understanding NAND universality isn't just academic—it has real practical implications:

  • Manufacturing Efficiency: Chip manufacturers can use a single gate design throughout an entire chip, simplifying production.
  • Cost Reduction: NAND gates require fewer transistors than some other gates (typically 4 transistors).
  • Standardization: The 7400-series of TTL chips is based on NAND gates, becoming an industry standard.
  • Educational Value: Building a computer from NAND gates teaches you exactly how every component works.

Complete Implementation Rules

Here's your quick reference for implementing any basic gate:

GateNAND ImplementationNAND Count
NOTA NAND A1
AND(A NAND B) NAND (A NAND B)2
OR(A NAND A) NAND (B NAND B)3
NOR[(A NAND A) NAND (B NAND B)] NAND [(A NAND A) NAND (B NAND B)]4
XOR[(A NAND (A NAND B)) NAND (B NAND (A NAND B))]4

What About NOR?

The NOR gate is also universal! You can build any circuit using just NOR gates. The NAND vs NOR choice often comes down to manufacturing preferences and circuit requirements.

NOR Gate Universal Logic

NOR gates are also universal—any logic function can be built using only NOR gates.

Try It Yourself!

Build these NAND-only circuits in DigiSim.io:

  1. NOT gate: Place a NAND gate and connect both inputs together.
  2. AND gate: Use two NAND gates in series.
  3. OR gate: Create NOT-NOT-NAND structure.
  4. XOR gate: The challenge! Build it with just 4 NAND gates.

🔬 Build NAND-Only Circuits

Open the NAND Universal Logic template and experiment with universal gate construction!

© 2026 DigiSim.io — The Interactive Digital Logic Simulator

digisim.io â€˘ Blog â€˘ Lessons