Lesson plan

From gates to a computer lesson plan

Start with one NAND gate, package every circuit you build into a chip, and use your chips to build the next one: an adder, memory, a CPU of your own, and a computer that runs your program.

6 chapters, 23 lessons, about 16 hours, no board. Every lesson runs in the browser, with nothing to install.

The unit

Objectives and materials

By the end, students can

  • Make NOT, AND, OR and XOR out of NAND gates, and package each one.
  • Build the gates that decide which signal goes where.
  • Add one bit, then three, then four and eight at once.
  • Choose, count and compute a byte at a time, up to an ALU.
  • Latches, flip-flops, registers, a program counter, RAM and a register file.
  • Decode instructions, build a CPU, and run your own program on it.

Materials for the whole unit

  • Bit lamp x 8
  • Bit switch x 3
  • chip:c1 x 4
  • chip:c10
  • chip:c11 x 7
  • chip:c12
  • chip:c13
  • chip:c14
  • chip:c15 x 8
  • chip:c16
  • chip:c18 x 2
  • chip:c19
  • chip:c2 x 4
  • chip:c21 x 8
  • chip:c22
  • chip:c23
  • chip:c24
  • chip:c25
  • chip:c26
  • chip:c3 x 7
  • chip:c4 x 2
  • chip:c5 x 8
  • chip:c6 x 3
  • chip:c7 x 2
  • chip:c8 x 4
  • chip:c9 x 2
  • Constant bit x 2
  • Logic gate x 4
  • Number display x 2
  • Number switch x 3
  • Program ROM
  • Step clock
  • Terminal

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 2 h 50 min

One gate, every gate

Make NOT, AND, OR and XOR out of NAND gates, and package each one.

LessonTimeWhat students do
The one gateMeet the NAND gate, the only gate you need. Wire it between two switches and a lamp, read its truth table, and see why every other gate can be built from it.40 min
  1. One gate to build everything
  2. Finish the wiring
  3. Run it by hand
  4. Why this is enough
NOT from NAND, and your first chipBuild a NOT gate out of one NAND, test it against its table, and package it into a chip with your name on it, ready for the next lesson.40 min
  1. The NOT table
  2. Tie the inputs together
  3. Package it as NOT
  4. Open it, and put it back
AND and ORUndo the "not" in NAND to make AND, then turn a NAND inside out with two NOTs to make OR. Two chips, both from NAND gates.50 min
  1. AND is NAND, then NOT
  2. Build AND
  3. Package it as AND
  4. Build OR
  5. Package it as OR
XOR from four NANDsThe gate that says "one or the other, not both", built from exactly four NAND gates. It is the heart of every adder you will build next.40 min
  1. Different, or the same
  2. Wire the four gates
  3. Package it as XOR
  4. Count your gates

Materials

  • Bit lamp
  • Bit switch x 2
  • Logic gate x 4

Check for understanding

Each student finishes "XOR from four NANDs" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Count your gates".

Chapter 2. About 50 min

Choosing

Build the gates that decide which signal goes where.

LessonTimeWhat students do
Choosing with MUX and DEMUXA MUX picks one of two inputs with a select bit, and a DEMUX sends one input to one of two outputs. The switchboard of every processor.50 min
  1. A switch made of gates
  2. Build the MUX
  3. Package it as MUX
  4. Build the DEMUX
  5. Package it as DEMUX

Materials

  • Bit lamp
  • Bit switch x 3
  • chip:c1
  • chip:c2 x 2
  • chip:c3

Check for understanding

Each student finishes "Choosing with MUX and DEMUX" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Package it as DEMUX".

Chapter 3. About 2 h 50 min

Adding

Add one bit, then three, then four and eight at once.

LessonTimeWhat students do
Adding one bitAdd two bits and get a sum and a carry. The half adder is an XOR and an AND side by side, and it is where arithmetic starts.40 min
  1. Binary addition, one column
  2. Build it
  3. One plus one
  4. Package it as HALF ADDER
Carrying: the full adderAdd three bits, the two you are adding and the carry from the column before. Two half adders and an OR make a full adder, the building block of every adder.40 min
  1. A column with a carry in
  2. Build it
  3. One plus one plus one
  4. Package it as FULL ADDER
Four bits at onceChain four full adders, carry out to carry in, and add two 4-bit numbers. Number switches and a number display show the values in decimal and hex.40 min
  1. The ripple carry
  2. Build it
  3. Overflow
  4. Package it as ADDER4
An 8-bit adderTwo 4-bit adders make an 8-bit one: the adder a small computer uses, all 120 NAND gates of it. The end of the first milestone.50 min
  1. A byte
  2. Build it
  3. Two hundred plus one hundred
  4. Package it as ADDER8
  5. What comes next

Materials

  • Bit lamp x 2
  • Bit switch x 3
  • chip:c2
  • chip:c3
  • chip:c4
  • chip:c7 x 2
  • chip:c8 x 4
  • chip:c9 x 2
  • Number display
  • Number switch x 2

Check for understanding

Each student finishes "An 8-bit adder" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "What comes next".

Chapter 4. About 3 h 30 min

Eight bits wide

Choose, count and compute a byte at a time, up to an ALU.

LessonTimeWhat students do
Choosing a whole byteEight MUX chips side by side, one select line for all of them: a chip that picks one of two bytes. The CPU uses one at every fork in its data.40 min
  1. Eight bits, one choice
  2. One select line for all eight
  3. Pick B
  4. Package it as MUX8
Adding oneAn 8-bit adder with one input tied to 0 and its carry in tied to 1 adds one to anything. Meet the constant bit, and build the chip a program counter counts with.40 min
  1. A number that never changes
  2. Tie the inputs
  3. Around the clock
  4. Package it as INC8
Decoders: one line out of manyTurn a 2-bit number into one of four lines, then a 3-bit number into one of eight, from DEMUX chips. A decoder is how memory finds the one byte a write is for.50 min
  1. A number picks a line
  2. Build the 2-to-4 decoder
  3. Package it as DEC2
  4. Build the 3-to-8 decoder
  5. Package it as DEC3
One bit of an ALUAn arithmetic logic unit does one of eight jobs, chosen by a 3-bit code. Build one bit of it: an adder that can subtract, four logic gates, and a MUX tree that picks the answer.40 min
  1. Eight jobs, one code
  2. Finish the slice
  3. Package it as ALU SLICE
  4. Read the table
The 8-bit ALUEight ALU slices in a carry chain, a zero detector and a carry flag: the ALU the Kestrel CPU computes with.40 min
  1. Slices in a chain
  2. Chain the carries
  3. Five minus seven
  4. Package it as ALU8

Materials

  • Bit lamp x 2
  • Bit switch x 3
  • chip:c1 x 3
  • chip:c10
  • chip:c15 x 8
  • chip:c2 x 3
  • chip:c3 x 7
  • chip:c4 x 2
  • chip:c5 x 8
  • chip:c6 x 3
  • chip:c8
  • Number display
  • Number switch x 3

Check for understanding

Each student finishes "The 8-bit ALU" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Package it as ALU8".

Chapter 5. About 4 h 10 min

Memory

Latches, flip-flops, registers, a program counter, RAM and a register file.

LessonTimeWhat students do
Remembering a bitTwo NAND gates wired into each other remember which one was pushed last. Build the set-reset latch, then the D latch that copies a bit and holds it.40 min
  1. A loop that remembers
  2. Close the loop
  3. Build the D latch
  4. Package it as DLATCH
The flip-flop and the clockTwo D latches, one open while the other is shut, make a flip-flop: it takes its input at the instant the clock rises and at no other time. Everything in a computer moves on that edge.40 min
  1. Only on the edge
  2. Wire the clock
  3. Package it as DFF
  4. Why the edge matters
RegistersA flip-flop and a MUX make a bit that loads only when told to. Eight of them make a register, the byte-sized memory every CPU is full of.50 min
  1. Load, or keep
  2. Feed it back
  3. Package it as BIT
  4. Build an 8-bit register
  5. Package it as REG8
The program counterA register that adds one to itself on every tick, loads a new value to jump, and clears to 0 on reset. It is how a CPU knows which instruction comes next.40 min
  1. Count, jump, reset
  2. Close the counting loop
  3. Count by hand
  4. Package it as PC
RAM: memory with addressesEight registers, a decoder that sends a write to one of them, and a MUX tree that reads one back: eight bytes of memory you can address.40 min
  1. An address for every byte
  2. Wire the write lines
  3. Package it as RAM8
  4. Where the gates go
The register fileFour registers with one write port and two read ports: the CPU reads two registers and writes one back, all in the same tick.40 min
  1. Two reads, one write
  2. Finish the source port and the write enable
  3. Package it as REGS4
  4. Registers and RAM

Materials

  • Bit lamp
  • Bit switch x 3
  • chip:c1
  • chip:c11 x 7
  • chip:c12
  • chip:c13
  • chip:c14
  • chip:c18 x 2
  • chip:c19
  • chip:c21 x 8
  • chip:c5
  • Constant bit x 2
  • Logic gate x 2
  • Number display x 2
  • Number switch x 3

Check for understanding

Each student finishes "The register file" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Registers and RAM".

Chapter 6. About 2 h 10 min

The Kestrel

Decode instructions, build a CPU, and run your own program on it.

LessonTimeWhat students do
Decoding instructionsThe Kestrel has sixteen instructions. The control unit turns each 4-bit opcode into the signals that steer the ALU, the registers, the memory and the jumps.40 min
  1. The Kestrel instruction set
  2. The control signals
  3. Wire ALUOP in
  4. Package it as CONTROL
The Kestrel CPUThe control unit, the register file, the ALU, the RAM and the program counter on one canvas, one instruction a tick. Package it and the tester runs a program on it.40 min
  1. One instruction a tick
  2. Wire the jumps, and run an instruction by hand
  3. Package it as KESTREL
  4. Count your gates
Your first computerA step clock, a program ROM, your Kestrel and a terminal on one canvas: a computer built from NAND gates, running a program you can change.50 min
  1. The parts of a computer
  2. Wire the terminal and run it
  3. Step through it
  4. Write your own program
  5. What you built

Materials

  • Bit lamp x 8
  • Bit switch x 2
  • chip:c1 x 4
  • chip:c11 x 2
  • chip:c14
  • chip:c16
  • chip:c2 x 4
  • chip:c22
  • chip:c23
  • chip:c24
  • chip:c25
  • chip:c26
  • chip:c3 x 3
  • chip:c5 x 3
  • Number display x 2
  • Number switch x 2
  • Program ROM
  • Step clock
  • Terminal

Check for understanding

Each student finishes "Your first computer" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "What you built".

Your class

Teach this unit as a class

Start a class from this course and its 23 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.