GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A 5-stage pipeline resolves conditional branches in ID, with forwarding into ID for ALU results but the branch needs its operand at the start of ID. For LW R1,0(R2) followed immediately by BEQ R1,R3,L, how many stall cycles does the branch suffer (before any branch-penalty from fetching the next instruction)?

  1. A. 2
  2. B. 1
  3. C. 0
  4. D. 3

Correct answer: A. 2

The loaded value is only available at the end of MEM; the branch compares it in ID, so it must wait until the load has passed MEM and the value is forwarded: 2 stall cycles (1 if the branch were resolved in EX).

More Computer Organization and Architecture questions

Exams that ask this topic