GATE Computer ScienceVery hardGATE 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, so a consumer can be in ID in the same cycle as its producer's WB. Branches are resolved in EX; when a branch is taken, the two instructions fetched after it are flushed and the target is fetched in the next cycle. Without hazards I1 is in ID in cycle 2 and finishes WB in cycle 5. Program: I1: LW R1, 0(R2); I2: ADD R3, R1, R4; I3: SUB R5, R3, R1; I4: SW R5, 0(R2); I5: BEQ R5, R6, L1; I6: ADD R7, R7, R1; I7 (label L1): OR R8, R5, R3. The BEQ is taken. In which cycle does the last instruction complete WB?
- A. 17
- B. 21
- C. 13
- D. 18
Correct answer: D. 18
A consumer's ID may coincide with its producer's WB (= producer ID + 3). ID cycles: I1 2, I2 5, I3 8, I4 11, I5 12, I7 15. I6 is flushed, and the target I7 reaches ID 3 cycles after the BEQ's ID; its sources R5 and R3 were written long before. WB = ID + 3 = 18. Not taken (I6 then I7) gives 17; without the split-cycle register file 21; with full forwarding 13.
Practise more Computer Organization and Architecture questionsComputer Organization and Architecture: notes and key points
More Computer Organization and Architecture questions
- A pipeline has a two-slot delayed branch: the two instructions after every branch always execute. The compiler fills the first slot with a…
- A cache miss fetches an 8-word block. Sending the address takes 1 cycle, a memory access takes 15 cycles and putting one word on the…
- A 1 GHz machine has instruction classes A, B, C with CPI 1, 2 and 3. For the same program, compiler X produces 5×10⁹ class-A, 1×10⁹…
- A non-pipelined datapath takes 100 + 120 + 90 + 150 + 110 ps per instruction. It is cut into those 5 stages with a 10 ps latch after each…
- A device streams 2 MB/s (1 MB = 10⁶ B) into memory on a 1.5 GHz CPU. With interrupt-driven I/O every 4-byte word costs 600 CPU cycles…
- A loop reads 128 words at addresses 0, 64, 128, …, 8128 and repeats this whole sweep three times. The cache is 4 KB, 2-way set-associative…