GATE Computer ScienceHardGATE CS (PYQ pattern)

A 5-stage pipeline has forwarding from EX/MEM and MEM/WB to the ALU inputs and also from MEM/WB to the data input of a store in MEM. The program is: LW R1,0(R2); SW R1,4(R2); LW R3,8(R2); ADD R4,R3,R1; SW R4,0(R5). Including pipeline fill, how many cycles does it take to complete all 5 instructions?

  1. A. 9
  2. B. 12
  3. C. 11
  4. D. 10

Correct answer: D. 10

Ideal is 5 + 4 = 9. The SW after the first LW needs no stall (load data reaches the store data input via MEM-to-MEM forwarding), the ADD after the second LW needs one load-use stall, and the last SW gets R4 forwarded from the ALU: 9 + 1 = 10.

More Computer Organization and Architecture questions

Exams that ask this topic