Module 5 & 6 β Pipelining
Why pipelining speeds up a processor, the 5 MIPS stages, pipeline registers, the three hazard types and their fixes, and the speedup / latency / throughput arithmetic β with a live pipeline diagram (Final Q2, slide f).
Sections
π‘
What & Why
Pipelining as an assembly line, the 5 MIPS stages, and the latency vs throughput idea.
ποΈ
Stages & Datapath
Each stage in detail, pipeline registers, and the single-cycle vs pipelined datapath.
β οΈ
Hazards & Fixes
Structural, data and control hazards β each with an example and its solution (forwarding, stalls, prediction).
π
Speedup & Timing
Speedup, latency and throughput formulas with the exact final-exam calculation worked out β plus a live calculator.
π―
Practice
Pipeline exam problems with reveal-able solutions.
Quick summary
PIPELINING = overlap instruction execution like a laundry assembly line.
Same LATENCY per instruction, much higher THROUGHPUT.
MIPS 5 STAGES: IF β ID β EX β MEM β WB
IF Instruction Fetch β read instr from memory, PC += 4
ID Instruction Decode β decode + read registers from register file
EX Execute β ALU operation / address calculation
MEM Memory access β load/store data memory
WB Write Back β write result into the register file
PIPELINE REGISTERS (IF/ID, ID/EX, EX/MEM, MEM/WB) hold each stage's results
so the next stage can use them one cycle later.
CLOCK: pipelined clock = SLOWEST stage. Single-cycle clock = whole instruction.
k stages, n instructions, tc = cycle time:
Pipelined time = (k + n β 1) Γ tc [kβ1 fill + n]
Non-pipelined = n Γ (k Γ tc) (single-cycle: kΒ·tc per instr)
Speedup = non-pipelined / pipelined β approaches k for large n
Latency (1 instr)= k Γ tc Throughput = n / total time
HAZARDS (stop the next instruction entering the pipe):
STRUCTURAL β two instrs need the SAME hardware at once (e.g. one memory).
Fix: duplicate the resource (separate instr/data memory).
DATA β an instr needs a result not yet written by an earlier instr.
Fix: FORWARDING (bypass from a pipeline register); else STALL.
CONTROL β a branch's outcome isn't known when the next fetch happens.
Fix: stall, branch prediction, or delayed branch.