How Computers Work
Bits, logic gates, and how code becomes electrons flipping switches.
Binary
Counting with Switches
intro · ~15 minBuild any number out of on/off switches, then flip one weight negative and unlock negative numbers.
Hamming Codes: Fixing a Flipped Bitin progress
core · ~20 minThree parity bits guard four data bits, each over a different group of positions. Any single flip fails exactly the groups that spell its position, so the receiver can put it back without asking.
Floating Point: IEEE 754in review
core · ~25 minA sign, a biased exponent, and a fraction with a hidden leading 1: how 6.3 becomes 6.5 in eight bits, why the error is relative, and where zero, the subnormals, and infinity live.
Logic
From Logic Gates to an Adderin review
intro · ~20 minSix truth tables, wired together: XOR is the sum bit, AND is the carry, and one full adder per column adds two bytes while the carry ripples from the lowest column to the top.
Flip-Flops: How Memory Remembersin review
core · ~25 minTwo NOR gates feeding each other hold a bit for as long as the power is on. Gate it with an enable for a latch; clock two latches and Q changes only on the edge.
CPU
A Tiny CPU, Instruction by Instructionin review
core · ~30 minSixteen bytes, four registers, nine instructions: fetch the byte at the program counter, decode its two halves, execute. The adder does the arithmetic, and data runs as code if you let it.
CPU Caches & Localityin review
core · ~25 minA few lines of fast memory in front of the slow one: an address splits into offset, set, and tag, a hit costs nothing, a miss fetches a block, and whether a program hits is a question of locality.
Instruction Pipeliningin review
core · ~25 minFive stages, five instructions in flight, one finished per cycle: the assembly line inside a processor, and the data and control hazards that stall it, forward around it, or squash what it fetched.
Branch Predictionin review
core · ~20 minA pipeline must guess which way a branch goes before it knows: one bit remembers the last outcome, two bits forgive a single surprise, and a history table learns the pattern a loop makes.
Memory
The Stack & The Heapin review
core · ~25 minA call pushes a frame and a return pops it, free of charge; a block asked for by size comes from a heap of holes that split, merge, and fragment. The two grow toward each other until they meet.
Virtual Memory & Page Tablesin review
core · ~25 minEvery address a program uses is a lie the hardware keeps: a page table maps it to a frame, a tiny buffer remembers the last few answers, and a page not in memory is a fault that reads the disk.
Garbage Collection: Mark & Sweepin review
core · ~25 minLive means reachable from a root. Mark everything the program can still reach, sweep the heap and free the rest, cycles included, then compact if the holes matter.
Networking
Error Correction
Parity: One Bit That Noticesin review
core · ~20 minOne extra bit makes a line of bits count even, so a single flip is noticed. Lay the bits out as a grid with a parity bit per row and per column, and the failing lines cross at the flip.
Codes and Distancein review
core · ~20 minA code is a set of words, and what it can do is one number: the fewest positions two of its words differ in. That distance fixes what is noticed, what is undone, and what is perfect.
SECDED: ECC Memoryin review
core · ~20 minAn eighth parity bit over the whole Hamming word tells one flip from two: a single flip is fixed as before and a double is reported, not mended wrong. ECC memory does this on every read.
CRC: Division That Catches Burstsin review
core · ~25 minThe message as a polynomial over GF(2), divided by a generator with shift-and-XOR steps, its remainder sent along: any burst up to the generator's degree leaves a nonzero remainder at the far end.
Reed-Solomon: Rebuilding a Scratched Discin review
core · ~25 minTreat four-bit symbols as a polynomial over GF(16), append a remainder so the generator's four roots all give zero, and solve four equations to find and undo any two changed symbols.
Interleaving: Spreading a Burstin review
core · ~20 minA burst of noise wrecks the one word it lands on. Write the words into a block by row, send the block by column, and the same burst leaves one flip in every word, which each word can fix.