Think of a laundromat. You have four loads to wash, dry, fold and put away. The slow way is to carry one load all the way through — wash, dry, fold, store — before you even start the next. The clever way is a pipeline: the moment the first load leaves the washer, the second load goes in, while the first moves to the dryer. All four machines run at once, each on a different load. You finish in a fraction of the time even though no single load got any faster.
A pipelined processor does exactly this with instructions. You already met
Every instruction marches through the same five stages, in order, one stage per clock cycle:
| Stage | Name | What happens |
|---|---|---|
| IF | Instruction Fetch | read the instruction word from memory; bump the program counter |
| ID | Instruction Decode | decode the opcode; read source registers from the register file |
| EX | Execute | the ALU computes — an arithmetic result, or a memory address |
| MEM | Memory access | load reads data memory / store writes it (other instructions idle here) |
| WB | Write-Back | write the result into the destination register |
Between each pair of stages sits a pipeline register — a bank of flip-flops (IF/ID, ID/EX, EX/MEM, MEM/WB) that latches everything a stage produces at the tick of the clock, so the next stage can pick it up next cycle. These registers are the guardrails that keep five instructions from crashing into one another; without them the pipeline is just a tangle of wires.
Here is the picture. Each row is one instruction; each column is one clock cycle; each coloured cell shows which stage that instruction is in during that cycle. Press play (or step forward) and watch the diagonal staircase form: the pipeline fills for the first four cycles, runs full at cycle 5, then drains over the last four.
Two numbers to read off this figure. The latency of any single instruction is still
Run
The unpipelined machine, doing one whole instruction at a time, takes
For a long stream of instructions the fill and drain become a rounding error and the speedup approaches
Push
People tried. The Pentium 4's "Prescott" core ran a 31-stage pipeline chasing raw clock
speed. It backfired. Deeper pipes mean each stage does less real work but still pays a fixed
latch-and-clock overhead, so the useful fraction of every cycle shrinks. Worse, a mispredicted
The seductive mistake is to think "five stages, so each instruction is five times faster." Exactly backwards. Look at the diagram again: I1 still occupies cycles 1 through 5 — its latency is unchanged, and each stage's clock period may even be a touch longer because of the pipeline-register overhead. What improves is throughput: the rate at which finished instructions stream out the far end. Pipelining is about keeping every unit busy, not about rushing any one instruction through. Latency and throughput are different axes — never conflate them.
The five-stage split is not sacred — it is a balance. RISC instruction sets were deliberately designed so that fetch, decode, a single ALU op, one memory access, and a register write are each about the same amount of work, so the stages take roughly equal time and the clock can tick as fast as the slowest stage allows. Almost everything later in this module — data hazards, control hazards, structural hazards, precise exceptions — is about the messy reality that instructions are not truly independent, and the pipeline occasionally has to stall, forward, or flush to keep giving correct answers. This clean picture is the baseline we will now start to complicate.