in CO and Architecture retagged by
2,388 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).
in CO and Architecture retagged by
2.4k views

1 comment

Part (a) will need 3 + 3 NOP instructions.

Part (b) will not require any NOP instructions.
0
0

1 Answer

1 vote
1 vote

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