Skip to content
Tactiverge

School/△ Builder/Week 16

Everything from NAND

If you could only manufacture one kind of gate, could you still build a whole computer? Engineers found the answer is yes, twice.

About 35 min · 3 goals · Checked by automated tests

1.Why should I care?

NAND gates are simple to make with transistors, so whole chips (and early computers) have been built almost entirely from them. Showing that everything can be made from one gate is also your first real piece of computer architecture: building bigger blocks from smaller ones.

  • ◇ Build NOT, AND and OR from NAND gates only, using De Morgan's law.
  • ◇ Build XOR from four NAND gates and verify it on every row.
  • ◇ Explain why a single universal gate type is useful in manufacturing.

2.Discover

Do Level 2 of the virtual computer: wire NOT from one NAND, XOR from at most four NANDs, and a half adder from at most two gates. Read the live truth table after every wire you add, and keep notes on which NAND does which job.

Can't use the interactive? Read a description instead

In the virtual computer's circuit builder, a NAND with both inputs joined acts as NOT. Four NANDs make XOR: the first NAND feeds two more, each also fed by one input, and a last NAND combines them. A half adder uses XOR for the sum and AND for the carry. The live truth table confirms each row.

3.Checkpoint: guided practice

Check what you just discovered before going on. Hints appear after a wrong answer.

Practice 1

How do you make NOT from a single NAND?

Practice 2

How many NAND gates does the standard De Morgan construction of a two-input OR use?

gates

4.Apply it

In BUILD 008 Level 2, complete all three circuits within the gate limits. Then, on paper, design AND from NOR gates only and check it with a truth table.

Open BUILD 008: Create a Virtual Computer →

5.Understand

NOT and AND

NOT A = NAND(A, A). A AND B = NOT(NAND(A, B)), which is two NANDs: one NAND, then a NAND with its inputs tied as a NOT.

OR via De Morgan

De Morgan says A + B = ¬(¬A · ¬B), which is NAND(¬A, ¬B). So OR takes three NANDs: two as NOTs on the inputs, and one to combine them.

XOR in four

Let g1 = NAND(A, B). Then g2 = NAND(A, g1), g3 = NAND(B, g1), and Y = NAND(g2, g3) = A ⊕ B. Check row 11: g1 = 0, g2 = 1, g3 = 1, Y = 0. Row 10: g1 = 1, g2 = 0, g3 = 1, Y = 1.

Why one gate type helps

A factory that makes one well-tested cell can tile it millions of times. Designers still use many gate types today, but the fact that NAND (or NOR) is universal shows how little you need to compute anything.

Explain it another way

It is like having only one Lego brick shape and discovering you can still build every model, just with more bricks.

Worked example 1

Show that NAND(NAND(A, A), NAND(B, B)) is A OR B.

NAND(A, A) = ¬A and NAND(B, B) = ¬B. NAND(¬A, ¬B) = ¬(¬A · ¬B) = A + B by De Morgan. Three NANDs make OR.

Common mix-ups

  • Using only NAND gates always gives the smallest circuit.
    ✓ It is always possible, not always smallest. Real designs mix gate types for size and speed.

6.Watch

→ Watch for how a transistor acts as a voltage-controlled switch. That switch is all a NAND gate needs.

Follows doped silicon into a transistor, the switch that every logic gate is built from.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

The video is optional: everything you need is also in the lesson text and the interactive.

7.Practice on your own

Practice, not a test. Wrong answers get a hint and another try.

Practice 3

How many NAND gates does the classic XOR construction use?

gates

Practice 4

In the four-NAND XOR, with A = 1 and B = 1, what is g1 = NAND(A, B)?

Practice 5 · a fresh version every time

With A = 0, B = 0 and C = 0, what is Y = ¬(A + (B + ¬A))? Answer 0 or 1.

Practice 6

Why can't AND and OR gates alone build every logic function?

8.Predict

What does a NAND gate do if you connect both of its inputs to the same signal A?

Guess first. Being wrong here is how the surprise works.

9.Reflect

Concepts: Logic gates and Boolean algebra