2.1Idea
The idea
Pipelining overlaps instructions: while one is executing, the next is already being decoded and the one after is being fetched.
Think of it like this: Laundry with a washer, dryer and folder: start the second load in the washer as soon as the first moves to the dryer.
Why it exists
Without it, most of the CPU sits idle waiting for a single instruction to finish all its stages. Pipelining uses every stage every cycle.
How it works
- Split an instruction into k stages (IF, ID, EX, MEM, WB).
- Each stage works on a different instruction in the same cycle.
- The first instruction needs k cycles; after that one instruction finishes every cycle.
- One instruction still takes k cycles (latency unchanged), but throughput rises.
Worked example: 5 stages, 3 instructions
Without a pipeline: 3 × 5 = 15 cycles. With a pipeline: k + n − 1 = 5 + 3 − 1 = 7 cycles.
Now play with it
- →Press Play on both tabs and compare the finish times.
- →In the graph drag "stages k" and see why speedup never exceeds k.
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| I1 | IF | ID | EX | MEM | WB | ||||||||||
| I2 | IF | ID | EX | MEM | WB | ||||||||||
| I3 | IF | ID | EX | MEM | WB |
3 instructions × 5 cycles = 15 cycles. Hardware sits idle most of the time.
instructions n = 10 → speedup = 3.571
Speedup nk/(k+n−1) climbs toward k but never reaches it.
Check yourself
A 5-stage pipeline runs 100 instructions with no stalls. How many cycles?
Exam notes (the dense version)
Overlap execution of instructions by splitting into stages (e.g. IF, ID, EX, MEM, WB). Improves throughput, not the latency of a single instruction.
Previous year questions: Instruction Pipelining & Hazards (15)
PYQs are grouped by topic, so this is the full set for Instruction Pipelining & Hazards; try the ones that match this subtopic. Open all 15 on the topic page.