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.
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.
One gate, every gate
Make NOT, AND, OR and XOR out of NAND gates, and package each one.
| Lesson | Time | What 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
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".
Choosing
Build the gates that decide which signal goes where.
| Lesson | Time | What 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 |
|
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".
Adding
Add one bit, then three, then four and eight at once.
| Lesson | Time | What 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
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".
Eight bits wide
Choose, count and compute a byte at a time, up to an ALU.
| Lesson | Time | What 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
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".
Memory
Latches, flip-flops, registers, a program counter, RAM and a register file.
| Lesson | Time | What 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
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".
The Kestrel
Decode instructions, build a CPU, and run your own program on it.
| Lesson | Time | What 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 |
|
| 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 |
|
| 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 |
|
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".
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.