Building a Computer from Scratch — Part 1: Wires and Logic Gates
Every computer is built from wires and gates. This post starts from scratch — what is a wire, what is a gate, and why one small design decision here is...
An 18-part series building a complete 16-bit computer from first principles in Go, based on the book But How Do It Know? by J. Clark Scott. Starting from a single wire and NAND gate, we build upward through storage primitives, the bus, arithmetic, registers, the ALU, 64K RAM, I/O, a CPU, and finally an assembler that runs real programs.
Every computer is built from wires and gates. This post starts from scratch — what is a wire, what is a gate, and why one small design decision here is...
Extending the gate layer to handle three, four, five, and eight inputs at once — and why the struct fields matter more than the truth table.
Building the first component that can remember — a 4-NAND feedback loop that locks a bit in place, and why Go's zero values make it tricky.
Storage cells can hold values, but they can't talk to each other. This phase builds the shared channel that every component in the computer will use to pass data.
Building the gate that silences a component on the shared bus, and discovering that a left shift is just rewiring — no logic required.
Building the comparator that chains 16 bit-stages MSB-first, and BusOne — the gate that injects the constant 1 without an if-statement.
One NOT per input, not one per gate — and how cascading two 4×16 decoders selects any one of 256 outputs without 8-input AND gates.
Building a 16-bit ripple-carry adder from five gates per bit column.
Combining storage and bus access into a single unit with two independent control wires.
Building a six-position shift register that gives the machine a shared sense of time.
Assembling eight parallel operation units behind a decoder-controlled gate, so a 3-bit opcode routes exactly one result onto the bus — with no branching in sight.
Building 65,536 cells in a 256×256 grid, selected by two 8-bit decoders, with a Memory Address Register that makes the two-phase read/write protocol possible.
Adding a 4-wire I/O control bus to keep RAM silent during peripheral cycles, and a keyboard that detects its own address in pure gate logic and delivers keycodes across a...
Adding a 4,800-cell frame buffer with two independent address registers, a two-phase write protocol, and a 30fps scanner goroutine that never touches the CPU's bus.
Wiring nine registers, a stepper, an ALU, and a control unit into a fetch-decode-execute machine that runs one instruction every six clock steps.
Connecting CPU, RAM, keyboard, and display into a single runnable machine — with a memory map, a sentinel jump, and a clock loop.
After 16 phases of hardware, the computer can run programs — but only if you write them in raw binary. This final part adds an assembler that translates human-readable instructions...
The three pieces that turn Go packages into a running simulator: a program generator that writes assembly from code, a bug that only appeared end-to-end, and a three-goroutine simulator that...