Structural Hazard - mbits-mirafra/computerArchitectureCourse GitHub Wiki
Structural hazard
As the name itself says "structure", which means something that deals with the "hardware"
- At a given time, only one can use the physical structure
Resource conflict: Happens when two instruction requires same resource in the same cycle
- Resource conflicts when the hardware cannot support all possible combination of instructions simultaneously
Some pipeline processors have shared a single memory pipeline for data and instructions
Simple example to understand Structural hazard:
There are 2 persons
- Person A
- Person B
Let's say there is only one room.
It's 10pm in the night
Now, person A wants to study with the lights on. But person B wants to sleep.
As there is only one room both cannot do this at the same time, Now there is a conflict
- Let's think in single cycle design perspective : Person A finishes his studies and then comes out of the room, then person B goes to sleep
But in multi-cycle design this is not the case, both wants to access the room at the same time. Which creates a conflict
To avoid this conflict they have to buy or build a new room.
Technical Example:
Can't read same memory twice in the same clock cycle
To solve this hazard,
- We "stall" the pipeline until the resource is freed
- "Stall" is commonly called as a "bubble"
- Bubble (NOP - NO OPERATION) floats through the pipeline taking place, but carry no useful work
- Adding more hardware
- There are separate Data memory and Instruction memory
- Adders to increment PC or to add offset to PC are separate from the main ALU