Learning Objectives
By the end of this topic you will be able to:
Explain how clock speed, cores, cache size, and word length affect CPU performance
Describe pipelining and how it increases instruction throughput
Explain pipeline hazards: data, control and structural hazards
Discuss trade-offs between performance factors
Pipelining
What is Pipelining?
Pipelining overlaps the execution of multiple instructions by dividing the FDE cycle into distinct stages. While one instruction is being executed, the next is being decoded and the one after is being fetched.
Cycle: 1 2 3 4 5
Instr1: [F] [D] [E]
Instr2: [F] [D] [E]
Instr3: [F] [D] [E]
Without pipelining: 3 instructions = 9 cycles. With pipelining: 3 instructions ≈ 5 cycles. Theoretical throughput: 1 instruction completed per cycle (after pipeline fills).
Pipeline Hazards
Pipeline Hazards
Data hazard: an instruction needs data that hasn't been produced yet by an earlier instruction still in the pipeline. Resolved by stalling (inserting NOPs) or forwarding.
Control hazard (branch hazard): a branch instruction changes the PC, invalidating instructions already fetched into the pipeline. Resolved by branch prediction or flushing.
Structural hazard: two instructions need the same hardware resource simultaneously (e.g. single memory bus). Resolved by duplicating resources or stalling.
Pipeline hazards cause stalls (wasted cycles). Modern CPUs use out-of-order execution and branch prediction to minimise stalls.
Common Mistakes
Don’t Lose Marks
!
Saying pipelining speeds up individual instructions — it does not. It increases overall throughput by executing multiple instructions in parallel stages.
!
Forgetting that more cores only help if software is multi-threaded. A single-threaded program runs on one core, regardless of how many cores the CPU has.
!
Saying increasing clock speed always improves performance — thermal limits and the memory bottleneck mean performance gains diminish at very high frequencies.