← 🚰 Instruction Pipelining & Hazards
Subtopic 3 of 8

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

  1. Find the cycle where two stages use the same unit (e.g. IF and MEM both use one memory).
  2. The younger instruction is stalled one cycle (a bubble).
  3. 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.
123456789
I1IFIDEXMEMWB
I2IFIDEXMEMWB
I3IFIDEXMEMWB
I4stallIFIDEXMEMWB

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?

Remember: Same hardware, same cycle: stall or duplicate.
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.