Pipelining and Pipelining Hazards
Pipelining and Pipelining Hazards
Lecture # 07
Pipelining and Pipelining Hazards
Muhammad Imran
[email protected]
Acknowledgement
2
▪ Simple Solution
▪ Stall the pipeline!
▪ Wait until the data has been written
Pipeline Stall or Bubble –
A pipeline stall (wait)
initiated to resolve a
hazard
▪ Forwarding or Bypassing
▪ Forward the data to the next instruction when it is available
▪ Do not wait for the write back stage to complete!
▪ Forwarding is harder if
▪ More than one results are to be forwarded per instruction!
Control Hazards
23
▪ Prediction
▪ A better solution to control hazards
▪ Predict the outcome of branch and fetch the next instruction!
▪ If prediction is wrong, fetch the right instruction again!
▪ In general,
Avg. Time per instruction unpipelined
Speedup =
Avg. Time per instruction pipelined
▪ In general,
Avg. Time per instruction unpipelined
Speedup =
Avg. Time per instruction pipelined
Pipeline depth
Speedup =
1 + Pipeline stall cycles per instruction
Flush pipeline 2 3 3
Predicted taken 2 3 2
Predicted untaken 2 0 3