Visualizations
078 / 500

078 · Retro

Breadboard CPU

A microcoded 8-bit breadboard computer paints cellular automata on a 16x16 LED matrix.

Ten breadboards hold a program counter, memory address register, 256 bytes of RAM, an instruction register, A and B registers, an ALU with carry and zero flags, an output display and a control board, all joined by an 8-bit bus. Instructions are never executed directly: a microcode table maps opcode, step and flags to a control word, and each clock edge only does what that word says, one module driving the bus and others latching it, starting with the fetch steps PC to MAR then RAM to IR. The program is assembled at start-up and draws rules 150 and 30 into video RAM at $E0 to $FF, shifting each 16-pixel row through the carry and combining it with XOR and OR. With no indexed addressing, its row pointers are the operand bytes of its own LDA and STA instructions, so the live disassembly shows the code rewriting itself.

Try it. Click STEP (or press N) to advance one clock edge and watch the value run from the driving module down the bus into the latch, or turn the SPEED knob (+ and - keys) from half a hertz to 30 kHz. Flip the address DIP switches to enter program mode and read RAM, set the data switches and press WRITE to change a byte, click the matrix to poke pixels into video RAM, and press RESET to reload the program. Space halts or runs the clock.

  • Microcoded control unit
  • Bus-level CPU emulation
  • Self-modifying code
  • Elementary cellular automata

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a tiny microcoded 8-bit computer that you can watch run, with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Model the machine as plain state: a program counter, memory address register, 256 bytes of RAM, an instruction register, A and B registers, carry and zero flags, an output register and an 8-bit bus.
- Define control signals as bits (PC out, RAM out, A out, ALU out, MAR in, RAM in, IR in, A in, B in, output in, PC increment, jump, flags in). Write a microcode table that maps each opcode and step to a control word. Every instruction starts with the same two steps: PC to MAR, then RAM to IR and PC + 1.
- Write one function for a rising clock edge: find which module drives the bus, then let every enabled register latch it. That function is the whole CPU.
- Add LDA, ADD, SUB, STA, LDI, JMP, JC, JZ, OUT and HLT, and hand-assemble a program that counts up on the output register.
- Draw each register as a row of eight LEDs with a label, plus the bus and the active control signals, and run the clock at a few hertz with a Step button.

Once that works, make it beautiful:
- Draw the modules as breadboards with chips, resistors and jumper wires, and light the bus wires that carry a 1 while a value moves.
- Add a speed control up to thousands of hertz, and show each LED's brightness as its duty cycle over the frame.
- Add a 16 x 16 LED matrix that shows 32 bytes of RAM, and a program that draws a pattern into it.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as a small assembler with labels, shift and XOR instructions to draw cellular automata, or DIP switches for editing RAM by hand.
PreviousRigid BodiesStacked towers of boxes knocked down by a swinging wrecking ball. NextKernel Trick LiftRings no line can split are lifted into 3D, where an SMO-trained SVM slices them flat.

Related visualizations

  • Automaton OrchestraEmergence Elementary cellular automata woven into cloth on a loom and played as music.
  • Core ArenaAlgorithms Assembly warriors battle for 8,000 cells of shared memory on a real Redcode VM.
  • Tiny CompilerAlgorithms A whole compiler, from source to running bytecode, rebuilt on every keystroke.
  • Marble ComputerPhysics A wooden pegboard computer where falling marbles count, add and multiply in binary.
  • CPU PipelineRetro A five-stage RISC pipeline as an isometric factory: bubbles, bypasses and flushes.
  • Wireworld CircuitsEmergence A four-rule cellular automaton runs a six-bit counter and logic gates on a PCB.
  • Chiptune TrackerRetro An 8-bit sound chip emulated from scratch, playing a procedurally composed song.
  • Turing MachineRetro A brass Turing machine runs busy beavers, including all 47 million steps of BB(5).
  • Mode 7 TrackRetro The per-scanline floor trick of 16-bit kart racers, with a debug view of every row.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs