All episodes · From One Switch to a CPU · Episode 18

One Key Press Through the Whole Computer (Season Finale)

Pressing play loads the video from YouTube.

This season we built a computer, starting from a single switch. In the finale, we watch every part work together.
We follow one press of the A key: an interrupt, instructions in memory, the TLB and the cache, the pipeline and the control unit, 65 = A in a register, the ALU down to its gates and switches, pixels on the screen, and flash cells in an SSD. Then how to measure speed: instructions × ticks per instruction × time per tick.

Every animation in this video is drawn by code, and the narration is an AI voice.

Transcript

This season, we built a computer, starting from a single switch. Today, let's watch all of it work together, by following one key press all the way through. Press A. Here's what happens in the next small fraction of a second.

The keyboard's chip raises an interrupt. The processor saves where it was, and jumps to the handler. The handler is just numbers: instructions stored in memory, each one an opcode and some fields. To fetch them, the CPU turns virtual addresses into real ones through the TLB, and finds most instructions already waiting in the cache. In the pipeline, instructions are fetched, decoded and executed, out of order when they can be, with jumps guessed ahead, while the control unit flips the right switches on every tick. The key arrives as the number sixty-five, the letter A, and lands in a register made of flip-flops. The ALU compares and adds, with negative numbers in two's complement, using adders built from gates, and gates built from switches. Then the letter is drawn: thousands of pixels, each three numbers for red, green and blue, worked out with multiplications and floating-point math. And when you save your work, it's written to flash cells on an SSD, where it stays even with the power off. All of that happens in a small fraction of a second.

So how do we measure how fast all this is? The time a program takes is three numbers multiplied together. How many instructions it runs, how many ticks each instruction takes on average, and how long one tick lasts. A billion instructions, half a tick each, at four billion ticks a second: one eighth of a second. And that gives three ways to go faster: fewer instructions, fewer ticks per instruction, or shorter ticks. Every trick this season was one of those.

Billions of steps every second, and every single one comes down to switches, turning on and off. That's the end of season one. Thanks for building a computer with us.

That's the end of season one. Thanks for building a computer with us.

Buy the Developer a Coffee

Entirely up to you: it works the same either way.

Every cup turns into the next update.

WeChat Pay QR code
WeChat Pay
Alipay QR code
Alipay
PayPal QR code
PayPal