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

0 of 32 Foundation lessons done
0 of 138 lessons done overall
Start: What Actually Happens When You Add Two Numbers →

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 →

  1. Level 1 · How arithmetic becomes hardware0 of 11 lessons done
    1. What Actually Happens When You Add Two NumbersFoundation≈ 15 min
    2. Binary, and Why Everything Is Eventually BitsFoundation≈ 10 min
    3. Bits, Bytes and Words — and Why "Word" Is Not a Fixed SizeFoundation≈ 10 min
    4. Two's Complement: One Circuit for Addition and SubtractionFoundation≈ 10 min
    5. Integer Overflow: The Hardware Wraps, the Language DecidesFoundation≈ 10 min
    6. Floating Point: Trading Precision for RangeFoundation≈ 10 min
    7. Why 0.1 + 0.2 Is Not 0.2 + 0.1's ProblemFoundation≈ 10 min
    8. Boolean Logic: The Four Operations Hardware Actually HasFoundation≈ 10 min
    9. Logic Gates: Where Software Stops and Physics StartsFoundation≈ 10 min
    10. Building an Adder: Where Arithmetic Comes FromFoundation≈ 5 min
    11. Adding Memory: Combinational, Sequential and the ClockFoundation≈ 5 min
  2. Level 2 · What a CPU is made of0 of 7 lessons done
    1. What Is Actually Inside a CPUFoundation≈ 10 min
    2. Registers: The Fastest Storage, and There Is Almost None of ItFoundation≈ 10 min
    3. The ALU: Where Arithmetic Actually HappensFoundation≈ 10 min
    4. The Control Unit: Turning Instructions Into ActionsFoundation≈ 10 min
    5. The Datapath: How Values Move Through the MachineFoundation≈ 10 min
    6. The Program Counter: Deciding What Happens NextFoundation≈ 5 min
    7. The Clock: Why GHz Is Not PerformanceFoundation≈ 10 min
  3. Level 3 · The contract, and executing against it0 of 14 lessons done
    1. The ISA: The Contract Between Software and HardwareFoundation≈ 10 min
    2. ISA vs Microarchitecture: The Distinction Everything Depends OnFoundation≈ 10 min
    3. x86-64, ARM and RISC-V: Three Families, Three HistoriesFoundation≈ 10 min
    4. RISC vs CISC: A Real Argument That Stopped Predicting AnythingFoundation≈ 5 min
    5. Reading Assembly Without Writing ItFoundation≈ 10 min
    6. Addressing Modes: How an Index Becomes an AddressFoundation≈ 5 min
    7. Fetch, Decode, Execute — and Why That Story Is IncompleteFoundation≈ 10 min
    8. Instruction Fetch: Code Is Data TooFoundation≈ 10 min
    9. Decode: Turning Bytes Into IntentFoundation≈ 10 min
    10. Execute: Not All Operations Cost the SameFoundation≈ 10 min
    11. Load and Store: Why Arithmetic Happens in RegistersFoundation≈ 10 min
    12. Pipelining: Throughput Without Making Anything FasterFoundation≈ 10 min
    13. Pipeline Hazards: The Three Ways Overlap FailsFoundation≈ 5 min
    14. Forwarding and Stalls: Paying for DependenciesFoundation≈ 10 min
  4. Level 4 · Guessing, reordering and doing several things at once0 of 16 lessons done
    1. Control Hazards: The CPU Does Not Know Where You Are GoingIntermediate≈ 5 min
    2. Branch Prediction: Guessing Well Enough to MatterIntermediate≈ 10 min
    3. Misprediction: What a Wrong Guess CostsIntermediate≈ 10 min
    4. Speculative Execution: Doing Work Before You Know You Need ItIntermediate≈ 5 min
    5. Branchless Code: A Trade, Not an UpgradeIntermediate≈ 5 min
    6. Out-of-Order ExecutionIntermediate≈ 15 min
    7. Dependency Graphs: The Real Shape of Your CodeIntermediate≈ 10 min
    8. Instruction-Level ParallelismIntermediate≈ 10 min
    9. Superscalar ExecutionIntermediate≈ 10 min
    10. Register RenamingIntermediate≈ 10 min
    11. The Reorder Buffer and Precise StateIntermediate≈ 10 min
    12. IPC: Instructions Per CycleIntermediate≈ 10 min
    13. Four Kinds of ParallelismIntermediate≈ 5 min
    14. SIMD: One Instruction, Many ElementsIntermediate≈ 10 min
    15. Vectorization: Turning a Loop Into Vector WorkIntermediate≈ 10 min
    16. Auto-Vectorization: Verify, Do Not AssumeIntermediate≈ 10 min
  5. Level 5 · The memory hierarchy0 of 14 lessons done
    1. The Memory HierarchyIntermediate≈ 15 min
    2. What a Cache Actually IsIntermediate≈ 10 min
    3. Memory Moves in Lines, Not VariablesIntermediate≈ 10 min
    4. Spatial LocalityIntermediate≈ 10 min
    5. Temporal LocalityIntermediate≈ 10 min
    6. Hits, Misses and What a Miss Actually CostsIntermediate≈ 10 min
    7. Three Kinds of Miss, Three Different FixesIntermediate≈ 10 min
    8. Direct-Mapped Caches: One Address, One HomeIntermediate≈ 10 min
    9. Set-Associative Caches: The Compromise That WonIntermediate≈ 10 min
    10. Tag, Index and Offset: How an Address Finds Its LineIntermediate≈ 10 min
    11. Cache Replacement: LRU Is the Idea, Not the ImplementationIntermediate≈ 10 min
    12. Cache Thrashing: Load, Evict, Reload, RepeatIntermediate≈ 10 min
    13. Working Set: Why Performance Falls Off a CliffIntermediate≈ 10 min
    14. Prefetching: The Hardware Guesses What You Will Read NextIntermediate≈ 15 min
  6. Level 6 · Past the cache, and where the bytes sit0 of 13 lessons done
    1. Past the Last-Level CacheIntermediate≈ 10 min
    2. How DRAM Is OrganisedIntermediate≈ 10 min
    3. Latency and Bandwidth Are Different ResourcesIntermediate≈ 10 min
    4. When the Memory Bus Is the BottleneckIntermediate≈ 5 min
    5. When You Cannot Ask the Next Question YetIntermediate≈ 10 min
    6. Alignment: Why Addresses Are Not ArbitraryIntermediate≈ 10 min
    7. Padding: Why Your Struct Is Bigger Than Its FieldsIntermediate≈ 10 min
    8. Endianness: Which Byte Comes FirstIntermediate≈ 5 min
    9. What `arr[i]` Actually Compiles ToIntermediate≈ 5 min
    10. Both Are O(n). One Is Far Slower.Intermediate≈ 10 min
    11. Pointer Chasing: The Address You Do Not Have YetIntermediate≈ 10 min
    12. Array of Structs, or Struct of Arrays?Intermediate≈ 10 min
    13. Data-Oriented Design, Without the DogmaIntermediate≈ 10 min
  7. Level 7 · Address translation and protection0 of 9 lessons done
    1. Every Address Your Program Uses Is FakeAdvanced≈ 10 min
    2. The MMU: Translation and Protection in One CheckAdvanced≈ 10 min
    3. The Page-Table Walk: Dependent Loads All the Way DownAdvanced≈ 10 min
    4. The TLB: A Cache for Addresses, Not DataAdvanced≈ 15 min
    5. When Translation Itself Is the BottleneckAdvanced≈ 10 min
    6. Huge Pages: More Coverage per Entry, and What It CostsAdvanced≈ 10 min
    7. What Actually Stops One Process Reading Another's MemoryAdvanced≈ 10 min
    8. Why Kernel Mode Is Actually PrivilegedAdvanced≈ 10 min
    9. Why a System Call Costs More Than a Function CallAdvanced≈ 10 min
  8. Level 8 · More than one core0 of 18 lessons done
    1. What a Second Core Actually AddsAdvanced≈ 10 min
    2. Core, Hardware Thread, Software ThreadAdvanced≈ 5 min
    3. SMT: Two Contexts, One CoreAdvanced≈ 10 min
    4. Hardware Threads Are Not OS ThreadsAdvanced≈ 5 min
    5. Cache Coherence: Why Shared Memory Works At AllAdvanced≈ 10 min
    6. MESI and Its RelativesAdvanced≈ 10 min
    7. False Sharing: Independent Data, Shared LineAdvanced≈ 15 min
    8. NUMA: Not All Memory Is Equally FarAdvanced≈ 10 min
    9. Thread Affinity: Pinning and Its PriceAdvanced≈ 10 min
    10. Cache Warmth and the Real Cost of MigrationAdvanced≈ 10 min
    11. Sequential Consistency: The Model You Already HaveAdvanced≈ 10 min
    12. Why Your Loads and Stores Happen Out of OrderAdvanced≈ 10 min
    13. Store Buffers: Where Your Writes WaitAdvanced≈ 10 min
    14. Memory Barriers: Ordering, Not FlushingAdvanced≈ 10 min
    15. Hardware Memory Models Are Not Language Memory ModelsAdvanced≈ 10 min
    16. Atomic Instructions: What the Hardware Actually GuaranteesAdvanced≈ 10 min
    17. Compare-and-Swap: The Primitive Everything Is Built OnAdvanced≈ 10 min
    18. What a Mutex Actually DoesAdvanced≈ 10 min
  9. Level 9 · The rest of the machine, and reading it0 of 36 lessons done
    1. Interrupts: How Hardware Gets the CPU's AttentionAdvanced≈ 10 min
    2. Polling versus InterruptsAdvanced≈ 10 min
    3. DMA: Moving Bytes Without the CPUAdvanced≈ 10 min
    4. I/O Architecture: The Interconnect Is a Shared ResourceAdvanced≈ 5 min
    5. Memory-Mapped I/O: When a Store Is Not a StoreAdvanced≈ 10 min
    6. PCIe: Lanes, Generations and the Transfer BudgetAdvanced≈ 10 min
    7. The Storage Path: Why One Small Read Is the Worst CaseAdvanced≈ 10 min
    8. CPU Cache Is Not the Page CacheAdvanced≈ 10 min
    9. CPU or GPU: Two Bets About What Work Looks LikeAdvanced≈ 15 min
    10. What Is Actually Inside a GPUAdvanced≈ 10 min
    11. Lanes, Divergence and CoalescingAdvanced≈ 10 min
    12. The Transfer You Forgot to CountAdvanced≈ 10 min
    13. What GPU-Friendly Work Has in CommonAdvanced≈ 10 min
    14. Accelerators: The Specialization SpectrumAdvanced≈ 10 min
    15. The Specialization Trade-offAdvanced≈ 5 min
    16. LLM Inference Is a Memory Bandwidth ProblemAdvanced≈ 10 min
    17. Model Memory, and Why the Naive Number Is Always Too LowAdvanced≈ 10 min
    18. The CPU Counts ItselfAdvanced≈ 15 min
    19. CPI and IPC: The Number Everyone MisreadsAdvanced≈ 10 min
    20. Busy Is Not the Same as WorkingAdvanced≈ 10 min
    21. Misses That Overlap Are Nearly FreeAdvanced≈ 10 min
    22. Your Code Is Data TooAdvanced≈ 10 min
    23. Every Way a CPU Microbenchmark LiesAdvanced≈ 10 min
    24. The Clock Is a VariableAdvanced≈ 10 min
    25. The First Ten Seconds LieAdvanced≈ 10 min
    26. Performance Per WattAdvanced≈ 10 min
    27. Throughput Improved, Latency Did NotAdvanced≈ 10 min
    28. Cache-Aware AlgorithmsAdvanced≈ 15 min
    29. Matrix Tiling: Same Arithmetic, Ten Times FasterAdvanced≈ 15 min
    30. The Compiler Reordered It Before the CPU DidAdvanced≈ 10 min
    31. Why Reading the Source Cannot Tell You the CostAdvanced≈ 10 min
    32. Side Channels: When Performance Optimisations LeakAdvanced≈ 10 min
    33. Spectre and Meltdown: When Speculation Crossed a BoundaryAdvanced≈ 10 min
    34. The Hardware That Makes Virtual Machines PossibleAdvanced≈ 10 min
    35. What a vCPU Actually IsAdvanced≈ 10 min
    36. From malloc to Cache LinesAdvanced≈ 10 min
Start from a question you already have

What do you want to understand?

Source code to silicon

Every lesson sits somewhere on this chain, and names which end of it your intuition came from.

Source→Compiler→Instructions→Front End→Execution→Registers→Caches→Memory→I/O→Behavior
The CPU does not run your source line by line. The compiler reordered it, then the machine renamed, reordered and speculated. What survives is the result, not the sequence.
Data movement usually costs more than arithmetic. An add is one unit; a trip to memory is hundreds. Most loops are waiting, not working.

Flagship experiences

Learn → visualize → execute → inspect → measure → break → optimize.

Learning modules

138 lessons
Digital Foundations11

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.

Inside a CPU7

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.

Instruction Set Architecture6

The contract between software and hardware — and the distinction that most performance arguments get wrong: the same ISA is implemented by wildly different microarchitectures.

Executing Instructions8

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.

Branches & Speculation5

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.

Out-of-Order & Parallelism7

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.

SIMD & Vectorization4

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.

Caches & Memory Hierarchy14

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".

Main Memory & DRAM5

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.

Data Layout in Memory8

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.

Virtual Memory Hardware9

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.

Multicore & Coherence10

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.

Memory Ordering & Atomics8

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.

Interrupts, DMA & I/O8

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.

GPUs & Accelerators9

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.

Hardware Performance Analysis10

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.

Where This Shows Up9

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.

ISA-SPECIFIC

True of this instruction set; another may not have the concept.

MICROARCH-SPECIFIC

True of one implementation; the next generation may differ.

SIMPLIFIED

A deliberately reduced model, with the omissions named.

SIMULATED

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.