Pipeline Hazards
What can go wrong in pipelining?
- Data Hazards: Wrong data read before data is written.
- Control Hazards: Wrong instruction fetched before a taken branch.
- Exceptions
Data Hazards
read-after-write (RAW) dependences
add 1 2 3 //writes reg 3
nor 3 4 5 //reads reg 3
Two possible solutions.
Detect and Stall
If hazards exist, stall the processor until they go away.
-
Detect: Compare regA & regB with previous DestRegs
-
Stall:
- Keep current instructions in fetch and decode (IF/ID reg & pc unchanged)
- Pass a noop to execute
Time table for