Build a CPU
First chapter free with a free account. Runs in your browser. Pricing
- levels
- 23
- chapters
- 6
- things to install
- 0
23 levels, 6 chapters.
Free
01Charge
- 01 A loop of charge Current flows only round a closed loop Experiment
- 02 Voltage is the push More volts, more current, until the filament burns Experiment
- 03 Resistance holds it back Ohm’s law: current is voltage over resistance Experiment
- 04 Two ways to draw a current Electron flow and conventional current Experiment
02Switches
- 05 Two switches in a row Switches in series make AND Experiment
- 06 Two switches side by side Switches in parallel make OR Experiment
- 07 A switch with no moving parts The transistor: a channel opened by a gate voltage Experiment
03Gates
- 08 NOT, the first gate The CMOS inverter, from one P and one N transistor Challenge
- 09 NAND from four transistors Pull-up and pull-down networks Challenge
- 10 NAND builds everything A universal gate, and building in blocks Challenge
- 11 XOR: one or the other Exclusive-OR from OR, NAND and AND Challenge
04Numbers
- 12 Counting with two symbols Binary place values, bits and bytes Experiment
- 13 Adding two bits The half adder: a sum and a carry Challenge
- 14 Carry in, carry out The full adder, from two half adders Challenge
- 15 Four bits at once A ripple-carry adder, and why it takes time Challenge
05Memory
- 16 A circuit that remembers The SR latch: feedback that holds one bit Challenge
- 17 Store on command The D latch and its enable wire Challenge
- 18 The clock and the register Flip-flops that capture on one clock edge Challenge
06The machine
- 19 Sixteen numbered cells RAM: addresses, writing and reading Experiment
- 20 One circuit, many operations The ALU and its zero and carry flags Experiment
- 21 Fetch, decode, execute The stored program and the instruction cycle Experiment
- 22 Your first program Machine code: load, subtract, add, show, halt Challenge
- 23 A loop that ends Jumps and a test: a loop that knows when to stop Challenge
A working model, not a real chip.
Modelled
- A loop of wire solved with Ohm’s law: current from voltage and resistance, a lamp that brightens with current and burns out past its rating, and current that divides between parallel branches.
- A transistor as a switch worked by voltage: no channel below about 2 V on the gate, a full one by 3.5 V.
- A switch-level circuit simulator. Wires join pins into nets, the + and − rails and the switches drive them, a conducting transistor joins its source to its drain, and a net driven both ways is reported as a short circuit.
- Gates that update one at a time, so a carry visibly ripples through an adder, and two cross-coupled NOR gates settle into a latch.
- Every wiring puzzle is checked exhaustively: each row of its truth table on a fresh circuit, or each step of a test sequence for a circuit with memory. The 4-bit adder is tested on all 256 pairs of inputs.
- An 8-bit accumulator processor with 16 bytes of RAM and ten instructions, stepped one clock beat at a time through fetch, decode and execute.
Simplified or left out
- Analogue behaviour: capacitance, rise times, noise. On the wiring boards a wire is 1, 0, unconnected or shorted.
- The LED’s own forward voltage, the way a lamp’s resistance changes as it heats, and the battery’s internal resistance.
- How the control logic, the instruction decoder and the memory’s address decoder are wired from gates. In the last chapter they are blocks.
- Interrupts, a stack, subroutines, pipelines, caches and everything else a modern processor adds.
Volts, amperes and ohms are real units and obey Ohm’s law. Electrons are drawn far larger, far fewer and far slower than they are, and the clock is slowed to a beat you can watch.