2.3Structural hazard
The idea
A structural hazard happens when two instructions need the same hardware in the same cycle, so one has to wait.
Think of it like this: Two people arriving at a single photocopier at the same moment.
Why it exists
Real machines have limited resources, and a pipeline makes demands overlap.
How it works
- Find the cycle where two stages use the same unit (e.g. IF and MEM both use one memory).
- The younger instruction is stalled one cycle (a bubble).
- Fix by duplicating the resource, e.g. separate instruction and data memory.
Worked example: One memory port
In cycle 4, I1 is in MEM while I4 wants to fetch. I4 waits: total cycles grow from 8 to 9.
Now play with it
- →Press Play and watch I4 get a "stall" in cycle 4.
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |
|---|---|---|---|---|---|---|---|---|---|
| I1 | IF | ID | EX | MEM | WB | ||||
| I2 | IF | ID | EX | MEM | WB | ||||
| I3 | IF | ID | EX | MEM | WB | ||||
| I4 | stall | IF | ID | EX | MEM | WB |
Cycle 4: I1 needs memory for MEM while I4 needs it for IF (one memory port). I4 waits one cycle: a structural hazard. Fix: separate instruction and data memory.
Check yourself
What is the standard fix for an IF/MEM structural hazard on a single memory?
Exam notes (the dense version)
Two instructions need the same hardware in the same cycle (e.g. one memory port for IF and MEM). Fix: duplicate resource or stall.
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.