The Forwarding, Hazard Detection, and Stall Unit
The following figure shows the forwarding, hazard detection, and stall unit in a pipelined datapath.
- Forwarding Part
- It controls the ALU multiplexors to replace the value from a general-purpose register with the value from the proper pipeline register.
It generates two control signals
ForwardA and ForwardB, which are used to control the two forwarding multiplexors, and it uses Rs and Rt in IF/ID and Rw in ID/EX and EX/MEM.
- Hazard Detection Part
- It checks whether a data hazard occurs after a load instruction.
If it does occur, the stall part will take action.
- Stall Part
- It controls the writing of the PC and IF/ID registers plus the multiplexor that chooses between the real control and all 0s (bubble clears control signals).
The pipeline is stalled by making
IF/IDWrite=‘0’ and PCWrite=‘0’ and introducing a bubble into the ID/EX control signals.