In the Patterson & Hennessy Book:

But can’t this be handled as a EX hazard:


Why is forwarding done in the MEM stage? And how? With 1 stall (for the 2nd add, I will need result from EX in next EX)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Document used http://www.cs.cornell.edu/courses/cs3410/2011sp/faq/faq_pa1.html
I’ll rewrite EX and MEM hazard condition (dropping !=0 part for simplicity), before we will take in account “double data hazard” (original rules):
EX Hazard
I’ll call conditions EX_h_Rs and EX_h_Rt to keep formulas shorter
MEM Hazard (original condition)
====
And our example with two types of hazard at once, between (1st and 3rd) & (2nd and 3rd) at same time:
or (promlem cycle is marked with
**on top and bottom)According to my link, after taking into account double EX + MEM hazard: (without !=0 and reordered boolean terms), Updated rules of MEM Hazard:
Or the same using short record of EX_h_*
which means:
Try to forward from MEM/WB to EX; if there is no forward into same input operand from EX/MEM pipeline registers.
Or the same
Don’t even try to forward from MEM/WB to EX; if there is already forwarding of more recent result from EX/MEM.
I’ll try to illustrate:
so, for third instruction original rules will say that Both
A'from first instruction andA''from second instruction should be forwarded (but mux can’t be fed from two sources at single moment of time). And modifying of MEM hazard condition says thatA'should not be tryed to forward if there is active forwarding ofA''which is more recent.So; your drawing is right, there will be 2 EX Hazards forwarding; But MEM hazard forwarding should not be tried if there is already active EX Hazard forwarding.