The document discusses the conditions used to detect forwarding from the writeback stage to the execution stage in a CPU pipeline. The four conditions check if 1) the writeback stage will write a register, 2) the register to write is not zero, 3) the register read by the execution stage does not match the register read two stages earlier in the decode stage, and 4) the register to write matches the register read two stages earlier in the decode stage. Together these conditions detect if there is a data hazard where the execution stage needs to read a value that will be written in the writeback stage.
Below is the statement that detects forwarding from WB to EX- What is.docx
1. Below is the statement that detects forwarding from WB to EX. What is the meaning of each of
the four conditions? If ( MEM/WB.RegWrite==l and MEM/WB.RegisterRd != 0 and
EX/MEM.RegisterRd != ID/EX.RegisterRs and MEM/WB.RegisterRd == ID/EX.RegisterRs)
Solution
Here given that
if ( MEM/WB.RegWrite==1 and
MEM/WB.RegisterRd != 0 and
EX/MEM.RegisterRd != ID/EX.RegisterRs and
MEM/WB.RegisterRd == ID/EX.RegisterRs )
It is the statement used to detect forwarding from WB to EX. And in this condition ForwardA
=01.
The above conditions are MEM/Wb hazard equations used for detecting and handling MEM/WB
hazards for the ALU source. A MEM/WB hazard occur between an instruction in EX stage and
one from two cycles ago.
The above given conditions contains both EX hazards and MEM hazards.The above condition is
obtained when data hazard matches both conditions in EX hazard and MEM hazard, and here
data hazard is treated as EX hazard rather than MEM hazard.
The input control signals of the given forwarding unit are: ID/EX.RegisterRs,
MEM/WB.RegWrite,
MEM/WB.RegisterRd,  EX/MEM.RegisterRd. The output is Forward A
The data hazard EX/MEM.RegisterRd != ID/EX.RegisterRs forwards from EX/MEM pipeline
register to data memory
2. The data hazard MEM/WB.RegisterRd == ID/EX.RegisterRs forwards from MEM/WB pipeline
register to data memory.
ID/EX.RegisterRs is the ALU operand register numbers in EX stage.
MEM/WB.RegWrite==1 means the RegWrite is set. It enters the WB stage and it is ready to
write. a value to register. MEM means memory and Reg means register.
We forward MEM/WB.RegisterRd != 0 if MEM/WB.RegWrite==1 and Rd != 0