Question: Consider the following code sequence that might be used to compute the product of the elements of a small, 5 element vector that has already
Consider the following code sequence that might be used to compute the product of the elements of a small, 5 element vector that has already been loaded into registers $1 through $5:
mul $1, $1, $2
mul $1, $1, $3
mul $1, $1, $4
mul $1, $1, $5
Consider the dependences induced in this code segment and the corresponding data hazards created. Carefully think about the forwarding required to correctly resolve the hazards and, using a data path diagram showing the forwarding paths needed, explain what needs to be forwarded, from where and to where. Modify the equations given in class for MEM data hazards to handle this special case. Briefly explain why your equations make sense. Referring to the text book will be helpful for this question.
Given in class:
EX Hazards:
if(EX/MEM.RegWrite and (EX/MEM.RegisterRd != 0) and
(EX/MEM.RegisterRd = ID/EX.RegisterRs))then
Forward ALU result to 1st ALU input
if(EX/MEM.RegWrite and (EX/MEM.RegisterRd != 0) and
(EX/MEM.RegisterRd = ID/EX.RegisterRt))then
Forward ALU result to 2nd ALU input
MEM hazards:
if(MEM/WB.RegWrite and (MEM/WB.RegisterRd != 0) and
(MEM/WB.RegisterRd = ID/EX.RegisterRs))then
Forward ALU result to 1st ALU input
if(MEM/WB.RegWrite and (MEM/WB.RegisterRd != 0) and
(MEM/WB.RegisterRd = ID/EX.RegisterRt))then
Forward ALU result to 2nd ALU input
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
