Pipelining & Hazards
![Question 68, GATE 2005: Five one-cycle stages IF instruction fetch, RD decode/register read, EX ALU/address, MA data memory (stores use data read in RD), WB register write. Instructions I1:R0←M[loc1], I2:R0←R0+R0, I3:R2←R2−R0. Total cycles from first fetch through final completion? A8; B10; C12; D15. The source does not explicitly state forwarding.](../../assets/questions/CS-2005-Q68-1.webp)
Answer & solution
Answer: A, conditional on forwarding (no official key was published)
With ordinary EX forwarding, the load-use dependency requires one bubble: I1 follows IF1, RD2, EX3, MA4, WB5; I2 follows IF2, RD3 (held through cycle 4), EX5, MA6, WB7; I3 follows IF3 (held), RD5, EX6, MA7, WB8. The add result forwards to the subtract without another bubble. Total 5+2+1=8 cycles, option A. Forwarding is not explicitly stated in the paper, so 8 is conditional, not a uniquely established result from the written stage definitions alone. Without forwarding, with register write/read in opposite halves of one cycle, the two RAW dependencies instead add four bubbles, producing 11 cycles, absent from the choices.
With forwarding, the memory-loaded value appears only after I1’s MA stage, so I2 cannot consume it in EX at cycle 4; stall one cycle. Its ALU result can then forward directly to I3’s EX, adding no second bubble. An unstalled three-instruction/five-stage pipeline would take 7 cycles, so the one bubble makes 8. If forwarding is absent, register availability imposes further waits; the question’s stage list alone does not justify treating 8 as universal.