GATE / CS ARCHIVE

GATE CSE 2013 / QUESTION 45

Taken branch in a five-stage pipeline

Computer Organization & Architecture · Pipelining & Hazards · Full GATE CSE 2013 paper

GATE 2013, Q45 2 marks · MCQ
Report issue

Pipelining & Hazards

Question 45, GATE 2013: Five pipeline stages FI, DI, FO, EI, WO take 5, 7, 10, 8, 6 ns, with 1 ns buffer delay. Program I1… I12 has only branch I4, taken to I9. Without branch prediction, under end-of-EI resolution, time to complete is A132, B165, C176, D328 ns.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

The pipeline clock period is max(5, 7, 10, 8, 6)+1=11 ns. Because I4 branches to I9, the useful executed instructions are I1, I2, I3, I4, I9, I10, I11, I12: eight instructions. Using the standard model in which the branch is resolved at the end of EI, I4 occupies FI in cycle 4, DI in cycle 5, FO in cycle 6 and EI in cycle 7. Without prediction, target fetch starts in cycle 8. Then I9 finishes WO in cycle 12 and I12 finishes WO in cycle 15. Equivalently, eight useful instructions need 8+5−1=12 cycles without a control hazard, plus three branch-wait cycles. The total is 15×11=165 ns, option B. The answer relies on branch resolution in EI and target fetch in the following cycle; the prompt does not separately specify an earlier branch-resolution mechanism.

A common clock must accommodate the slowest stage plus its buffer:10+1=11 ns. Branch I4 enters EI in cycle 7, after FI4, DI5, FO6. Its target can enter FI in cycle 8, then DI9, FO10, EI11, WO12. The next target-path instructions finish in cycles 13, 14, 15. Thus the total is 165 ns. Counting all 12 source instructions would incorrectly include the skipped I5–I8. The branch resolution convention is stated because a different resolution stage would change the stall count.

Original paper, page 10 · Answer key