retagged by
2,385 views
2 votes
2 votes
Consider two instruction sequences:

a. SW R16,-100(R6)
    LW R4, 8(R16)
    ADD R5,R4,R4
b. OR R1,R2,R3
    OR R2,R1,R3
    OR R1,R1,R2

Add NOP instructions to this code to eliminate hazards if there is ALU-ALU forwarding only (no forwarding from the MEM to the EX stage).
retagged by

1 Answer

1 votes
1 votes

a)

Instruction $I_{1}$ $I_{2}$ $I_{3}$ $I_{4}$ $I_{5}$ $I_{6}$ $I_{7}$ $I_{8}$ $I_{9}$
SW R16,-100(R6) IF ID EX MEM WB        
LW R4, 8(R16)   IF ID EX MEM WB      
ADD R5,R4,R4     IF _NOP _NOP ID EX MEM WB

 

Here $2$ NOP, for $2$ stalls. These stall are created due to no forwarding from the MEM to the EX stage.


b)

Instruction $I_{1}$ $I_{2}$ $I_{3}$ $I_{4}$ $I_{5}$ $I_{6}$ $I_{7}$ $I_{8}$ $I_{9}$
  IF ID EX MEM WB        
    IF ID EX MEM WB      
      IF ID EX MEM WB    

 Due to ALU-ALU forwarding, no stall has been created

Related questions

0 votes
0 votes
1 answer
1
Deepak9000 asked Nov 5, 2023
242 views
I have a Self doubt question on Operand Forwarding . The data forwarded should be done in EX-EX stage or Mem-EX ? Which one to follow and when ?Using EX-EX we require les...
0 votes
0 votes
2 answers
3