Computer Architecture
How software actually executes on real hardware — and why moving data usually costs more than computing with it. Not a hardware course: a way of reading your own code that explains why two O(n) loops can differ tenfold.
Your path through Computer Architecture
Start with these 5 lessons
- What Actually Happens When You Add Two NumbersFoundation≈ 15 min
- Binary, and Why Everything Is Eventually BitsFoundation≈ 10 min
- Bits, Bytes and Words — and Why "Word" Is Not a Fixed SizeFoundation≈ 10 min
- Two's Complement: One Circuit for Addition and SubtractionFoundation≈ 10 min
- Integer Overflow: The Hardware Wraps, the Language DecidesFoundation≈ 10 min
Then follow the stages in order
Each stage builds on the ones before it. Labs and simulators sit right after the lessons they exercise. Open a stage to see its lessons. Full roadmap with goals →
Level 1 · How arithmetic becomes hardware0 of 11 lessons done
- What Actually Happens When You Add Two NumbersFoundation≈ 15 min
- Binary, and Why Everything Is Eventually BitsFoundation≈ 10 min
- Bits, Bytes and Words — and Why "Word" Is Not a Fixed SizeFoundation≈ 10 min
- Two's Complement: One Circuit for Addition and SubtractionFoundation≈ 10 min
- Integer Overflow: The Hardware Wraps, the Language DecidesFoundation≈ 10 min
- Floating Point: Trading Precision for RangeFoundation≈ 10 min
- Why 0.1 + 0.2 Is Not 0.2 + 0.1's ProblemFoundation≈ 10 min
- Boolean Logic: The Four Operations Hardware Actually HasFoundation≈ 10 min
- Logic Gates: Where Software Stops and Physics StartsFoundation≈ 10 min
- Building an Adder: Where Arithmetic Comes FromFoundation≈ 5 min
- Adding Memory: Combinational, Sequential and the ClockFoundation≈ 5 min
Level 2 · What a CPU is made of0 of 7 lessons done
- What Is Actually Inside a CPUFoundation≈ 10 min
- Registers: The Fastest Storage, and There Is Almost None of ItFoundation≈ 10 min
- The ALU: Where Arithmetic Actually HappensFoundation≈ 10 min
- The Control Unit: Turning Instructions Into ActionsFoundation≈ 10 min
- The Datapath: How Values Move Through the MachineFoundation≈ 10 min
- The Program Counter: Deciding What Happens NextFoundation≈ 5 min
- The Clock: Why GHz Is Not PerformanceFoundation≈ 10 min
Level 3 · The contract, and executing against it0 of 14 lessons done
- The ISA: The Contract Between Software and HardwareFoundation≈ 10 min
- ISA vs Microarchitecture: The Distinction Everything Depends OnFoundation≈ 10 min
- x86-64, ARM and RISC-V: Three Families, Three HistoriesFoundation≈ 10 min
- RISC vs CISC: A Real Argument That Stopped Predicting AnythingFoundation≈ 5 min
- Reading Assembly Without Writing ItFoundation≈ 10 min
- Addressing Modes: How an Index Becomes an AddressFoundation≈ 5 min
- Fetch, Decode, Execute — and Why That Story Is IncompleteFoundation≈ 10 min
- Instruction Fetch: Code Is Data TooFoundation≈ 10 min
- Decode: Turning Bytes Into IntentFoundation≈ 10 min
- Execute: Not All Operations Cost the SameFoundation≈ 10 min
- Load and Store: Why Arithmetic Happens in RegistersFoundation≈ 10 min
- Pipelining: Throughput Without Making Anything FasterFoundation≈ 10 min
- Pipeline Hazards: The Three Ways Overlap FailsFoundation≈ 5 min
- Forwarding and Stalls: Paying for DependenciesFoundation≈ 10 min
Level 4 · Guessing, reordering and doing several things at once0 of 16 lessons done
- Control Hazards: The CPU Does Not Know Where You Are GoingIntermediate≈ 5 min
- Branch Prediction: Guessing Well Enough to MatterIntermediate≈ 10 min
- Misprediction: What a Wrong Guess CostsIntermediate≈ 10 min
- Speculative Execution: Doing Work Before You Know You Need ItIntermediate≈ 5 min
- Branchless Code: A Trade, Not an UpgradeIntermediate≈ 5 min
- Out-of-Order ExecutionIntermediate≈ 15 min
- Dependency Graphs: The Real Shape of Your CodeIntermediate≈ 10 min
- Instruction-Level ParallelismIntermediate≈ 10 min
- Superscalar ExecutionIntermediate≈ 10 min
- Register RenamingIntermediate≈ 10 min
- The Reorder Buffer and Precise StateIntermediate≈ 10 min
- IPC: Instructions Per CycleIntermediate≈ 10 min
- Four Kinds of ParallelismIntermediate≈ 5 min
- SIMD: One Instruction, Many ElementsIntermediate≈ 10 min
- Vectorization: Turning a Loop Into Vector WorkIntermediate≈ 10 min
- Auto-Vectorization: Verify, Do Not AssumeIntermediate≈ 10 min
Level 5 · The memory hierarchy0 of 14 lessons done
- The Memory HierarchyIntermediate≈ 15 min
- What a Cache Actually IsIntermediate≈ 10 min
- Memory Moves in Lines, Not VariablesIntermediate≈ 10 min
- Spatial LocalityIntermediate≈ 10 min
- Temporal LocalityIntermediate≈ 10 min
- Hits, Misses and What a Miss Actually CostsIntermediate≈ 10 min
- Three Kinds of Miss, Three Different FixesIntermediate≈ 10 min
- Direct-Mapped Caches: One Address, One HomeIntermediate≈ 10 min
- Set-Associative Caches: The Compromise That WonIntermediate≈ 10 min
- Tag, Index and Offset: How an Address Finds Its LineIntermediate≈ 10 min
- Cache Replacement: LRU Is the Idea, Not the ImplementationIntermediate≈ 10 min
- Cache Thrashing: Load, Evict, Reload, RepeatIntermediate≈ 10 min
- Working Set: Why Performance Falls Off a CliffIntermediate≈ 10 min
- Prefetching: The Hardware Guesses What You Will Read NextIntermediate≈ 15 min
Level 6 · Past the cache, and where the bytes sit0 of 13 lessons done
- Past the Last-Level CacheIntermediate≈ 10 min
- How DRAM Is OrganisedIntermediate≈ 10 min
- Latency and Bandwidth Are Different ResourcesIntermediate≈ 10 min
- When the Memory Bus Is the BottleneckIntermediate≈ 5 min
- When You Cannot Ask the Next Question YetIntermediate≈ 10 min
- Alignment: Why Addresses Are Not ArbitraryIntermediate≈ 10 min
- Padding: Why Your Struct Is Bigger Than Its FieldsIntermediate≈ 10 min
- Endianness: Which Byte Comes FirstIntermediate≈ 5 min
- What `arr[i]` Actually Compiles ToIntermediate≈ 5 min
- Both Are O(n). One Is Far Slower.Intermediate≈ 10 min
- Pointer Chasing: The Address You Do Not Have YetIntermediate≈ 10 min
- Array of Structs, or Struct of Arrays?Intermediate≈ 10 min
- Data-Oriented Design, Without the DogmaIntermediate≈ 10 min
Level 7 · Address translation and protection0 of 9 lessons done
- Every Address Your Program Uses Is FakeAdvanced≈ 10 min
- The MMU: Translation and Protection in One CheckAdvanced≈ 10 min
- The Page-Table Walk: Dependent Loads All the Way DownAdvanced≈ 10 min
- The TLB: A Cache for Addresses, Not DataAdvanced≈ 15 min
- When Translation Itself Is the BottleneckAdvanced≈ 10 min
- Huge Pages: More Coverage per Entry, and What It CostsAdvanced≈ 10 min
- What Actually Stops One Process Reading Another's MemoryAdvanced≈ 10 min
- Why Kernel Mode Is Actually PrivilegedAdvanced≈ 10 min
- Why a System Call Costs More Than a Function CallAdvanced≈ 10 min
Level 8 · More than one core0 of 18 lessons done
- What a Second Core Actually AddsAdvanced≈ 10 min
- Core, Hardware Thread, Software ThreadAdvanced≈ 5 min
- SMT: Two Contexts, One CoreAdvanced≈ 10 min
- Hardware Threads Are Not OS ThreadsAdvanced≈ 5 min
- Cache Coherence: Why Shared Memory Works At AllAdvanced≈ 10 min
- MESI and Its RelativesAdvanced≈ 10 min
- False Sharing: Independent Data, Shared LineAdvanced≈ 15 min
- NUMA: Not All Memory Is Equally FarAdvanced≈ 10 min
- Thread Affinity: Pinning and Its PriceAdvanced≈ 10 min
- Cache Warmth and the Real Cost of MigrationAdvanced≈ 10 min
- Sequential Consistency: The Model You Already HaveAdvanced≈ 10 min
- Why Your Loads and Stores Happen Out of OrderAdvanced≈ 10 min
- Store Buffers: Where Your Writes WaitAdvanced≈ 10 min
- Memory Barriers: Ordering, Not FlushingAdvanced≈ 10 min
- Hardware Memory Models Are Not Language Memory ModelsAdvanced≈ 10 min
- Atomic Instructions: What the Hardware Actually GuaranteesAdvanced≈ 10 min
- Compare-and-Swap: The Primitive Everything Is Built OnAdvanced≈ 10 min
- What a Mutex Actually DoesAdvanced≈ 10 min
Level 9 · The rest of the machine, and reading it0 of 36 lessons done
- Interrupts: How Hardware Gets the CPU's AttentionAdvanced≈ 10 min
- Polling versus InterruptsAdvanced≈ 10 min
- DMA: Moving Bytes Without the CPUAdvanced≈ 10 min
- I/O Architecture: The Interconnect Is a Shared ResourceAdvanced≈ 5 min
- Memory-Mapped I/O: When a Store Is Not a StoreAdvanced≈ 10 min
- PCIe: Lanes, Generations and the Transfer BudgetAdvanced≈ 10 min
- The Storage Path: Why One Small Read Is the Worst CaseAdvanced≈ 10 min
- CPU Cache Is Not the Page CacheAdvanced≈ 10 min
- CPU or GPU: Two Bets About What Work Looks LikeAdvanced≈ 15 min
- What Is Actually Inside a GPUAdvanced≈ 10 min
- Lanes, Divergence and CoalescingAdvanced≈ 10 min
- The Transfer You Forgot to CountAdvanced≈ 10 min
- What GPU-Friendly Work Has in CommonAdvanced≈ 10 min
- Accelerators: The Specialization SpectrumAdvanced≈ 10 min
- The Specialization Trade-offAdvanced≈ 5 min
- LLM Inference Is a Memory Bandwidth ProblemAdvanced≈ 10 min
- Model Memory, and Why the Naive Number Is Always Too LowAdvanced≈ 10 min
- The CPU Counts ItselfAdvanced≈ 15 min
- CPI and IPC: The Number Everyone MisreadsAdvanced≈ 10 min
- Busy Is Not the Same as WorkingAdvanced≈ 10 min
- Misses That Overlap Are Nearly FreeAdvanced≈ 10 min
- Your Code Is Data TooAdvanced≈ 10 min
- Every Way a CPU Microbenchmark LiesAdvanced≈ 10 min
- The Clock Is a VariableAdvanced≈ 10 min
- The First Ten Seconds LieAdvanced≈ 10 min
- Performance Per WattAdvanced≈ 10 min
- Throughput Improved, Latency Did NotAdvanced≈ 10 min
- Cache-Aware AlgorithmsAdvanced≈ 15 min
- Matrix Tiling: Same Arithmetic, Ten Times FasterAdvanced≈ 15 min
- The Compiler Reordered It Before the CPU DidAdvanced≈ 10 min
- Why Reading the Source Cannot Tell You the CostAdvanced≈ 10 min
- Side Channels: When Performance Optimisations LeakAdvanced≈ 10 min
- Spectre and Meltdown: When Speculation Crossed a BoundaryAdvanced≈ 10 min
- The Hardware That Makes Virtual Machines PossibleAdvanced≈ 10 min
- What a vCPU Actually IsAdvanced≈ 10 min
- From malloc to Cache LinesAdvanced≈ 10 min
What do you want to understand?
What actually happens between sum += arr[i] and a number changing in a register — and which part of it is expensive?
Source code to silicon
Every lesson sits somewhere on this chain, and names which end of it your intuition came from.
Flagship experiences
Learn → visualize → execute → inspect → measure → break → optimize.
One arr[i] from address arithmetic through the TLB, three cache levels and the memory controller — with the cost accumulating as you open each level.
One ADD through fetch, decode, rename, schedule, execute, writeback and retire — and why no single stage is the story.
Set size, line size, associativity and access pattern. Find the stride that thrashes, the working set that fits, and the difference between a conflict and a capacity miss.
A decision tree from counters to cause: stalling or working, waiting on memory or on a dependency, bandwidth or latency.
Twelve sets of counters with the cause unlabelled. Read the evidence and name what the hardware is doing.
Sixteen questions with progressive answers, and the red flags that separate a memorised fact from a mental model.
Learning modules
How arithmetic emerges from logic: binary and two's complement, why floating point approximates, gates, adders, and the step from combinational logic to stored state.
The parts that execute an instruction: registers as the fastest storage you have, the ALU, the datapath they sit on, the control unit that steers it, and why clock speed is not performance.
The contract between software and hardware — and the distinction that most performance arguments get wrong: the same ISA is implemented by wildly different microarchitectures.
Fetch, decode, execute, write back — then the pipeline that overlaps them, the hazards that break the overlap, and the forwarding and stalls that patch it up.
A CPU cannot afford to wait to find out where a branch goes, so it guesses. What that buys, what a misprediction costs, and why unpredictable data hurts more than extra work.
Modern CPUs are throughput machines: many instructions in flight, executed as their inputs become ready, retired in program order. Renaming, superscalar issue, ILP and what IPC actually tells you.
One instruction, many elements. What makes a loop vectorizable, what stops the compiler from doing it, and where data-level parallelism sits among the other kinds.
The deepest module, because this is where most real programs spend their time. Lines, locality, associativity, replacement, thrashing and prefetching — the machinery behind "why is this loop slow".
Past the last-level cache: how DRAM is organized, why latency and bandwidth are different resources, and how to tell a bandwidth-bound workload from a latency-bound one.
Where the bytes actually sit: alignment and padding, endianness, address arithmetic, why an array beats a linked list at equal complexity, and array-of-structs versus struct-of-arrays.
The hardware half of a mechanism the OS owns: the MMU that translates, the page tables it walks, the TLB that caches translations, and the protection bits that make isolation possible.
What changes when there is more than one core: hardware threads versus OS threads, the coherence protocol keeping caches consistent, false sharing, NUMA and why moving a thread costs cache.
Why the order you wrote is not the order the machine performs, what a barrier actually constrains, and the hardware primitives — compare-and-swap and friends — every lock is built from.
How the world outside the CPU gets in: interrupts against polling, DMA moving bytes without the CPU copying them, the path to storage, and why a CPU cache is not the OS page cache.
Throughput hardware and its price: why GPUs win on wide regular work, why transfers and divergence undo it, and what specialized accelerators trade away to be fast at one thing.
Reading the machine: performance counters, CPI, telling compute-bound from memory-bound, and every way a microbenchmark will lie to you about frequency, caches and dead code.
Cache-aware algorithms and tiling, what the compiler did before the CPU saw your code, side channels as a consequence of speculation, and the hardware under virtual machines and containers.
Nothing here is universal
§224 — cache sizes, latencies, policies and ordering rules all vary. Every claim says what it is specific to.
True of this instruction set; another may not have the concept.
True of one implementation; the next generation may differ.
A deliberately reduced model, with the omissions named.
Produced by a model here — faithful shape, invented magnitudes.
You will not find an exact latency table here. Publishing "L1 is 1.2 ns" would be wrong on every machine except the one it was measured on, and numbers outlive their caveats. What transfers is the ratio — a register is one unit, a cache level is a few, memory is hundreds — and that is what the cost scales show.