GATE Computer ScienceEasyGATE CS (PYQ pattern)

A classic 5-stage pipeline (IF, ID, EX, MEM, WB) has no forwarding; the register file is written in the first half of a cycle and read in the second half (a consumer may be in ID during its producer's WB). Without hazards I1 finishes WB in cycle 5. Program: I1: ADD R1, R2, R3; I2: SUB R4, R1, R5; I3: MUL R6, R4, R1; I4: ADD R7, R6, R4; I5: BEQ R7, R1, L3; I6: ADD R8, R8, R7. The branch is not taken (no flush), and MUL is a single-cycle EX operation. In which cycle does I6 finish WB?

  1. A. 22
  2. B. 18
  3. C. 10
  4. D. 17

Correct answer: B. 18

Each of I2, I3, I4, I5 depends on the instruction just before it, so each waits until its producer's WB: ID cycles I1 2, I2 5, I3 8, I4 11, I5 14, I6 15; I6 needs R7 from I4 (WB at 14) and is in ID at 15, WB at 18. Without the split register file it would be 22; 10 is the hazard-free time.

More Computer Organization and Architecture questions

Exams that ask this topic