Question

Consider an instruction pipeline with five stages without any branch prediction: Fetch Instruction (FI), Decode Instruction (DI), Fetch Operand (FO), Execute Instruction (EI) and Write Operand (WO). The stage delays for FI, DI, FO, EI and WO are 5 ns, 7 ns, 10 ns, 8 ns and 6 ns, respectively. There are intermediate storage buffers after each stage and the delay of each buffer is 1 ns. A program consisting of 12 instructions I1, I2, I3, ..., I12 is executed in this pipelined processor. Instruction I4 is the only branch instruction and its branch target is I9. If the branch is taken during the execution of this program, the time (in ns) needed to complete the program is

Choose one option
Official answer and solution
Official answer
B
From
Official GATE 2013 answer key

Solution

Calculate the clock cycle time from the stage and buffer delays, determine the cycle in which the branch penalty resolves, and sum the execution time.

  1. Determine the clock cycle time:
    Each stage delay must be added to the buffer delay of 1 ns:

    • FI: 5+1=6 ns5 + 1 = 6\text{ ns}
    • DI: 7+1=8 ns7 + 1 = 8\text{ ns}
    • FO: 10+1=11 ns10 + 1 = 11\text{ ns}
    • EI: 8+1=9 ns8 + 1 = 9\text{ ns}
    • WO: 6+1=7 ns6 + 1 = 7\text{ ns}
      The clock cycle duration is the maximum stage latency:
    Tcycle=max⁡(6,8,11,9,7)=11 nsT_{\text{cycle}} = \max(6, 8, 11, 9, 7) = 11\text{ ns}
  2. Analyze the pipeline execution with branch:

    • There are 12 instructions I1,I2,…,I12I_1, I_2, \dots, I_{12}.
    • I4I_4 is a branch instruction to target I9I_9.
    • Without branch prediction, the branch outcome is determined during the Execute Instruction (EI) stage of I4I_4.
    • Cycle trace for I4I_4:
      • Cycle 4: I4I_4 is fetched (FI).
      • Cycle 5: I4I_4 is decoded (DI).
      • Cycle 6: I4I_4 operand fetch (FO).
      • Cycle 7: I4I_4 execution (EI). The branch target I9I_9 is resolved at the end of cycle 7.
    • Meanwhile, instructions I1,I2,I3I_1, I_2, I_3 complete normally:
      • I1I_1 finishes WO at cycle 5.
      • I2I_2 finishes WO at cycle 6.
      • I3I_3 finishes WO at cycle 7.
      • I4I_4 finishes WO at cycle 8.
    • Because the branch is taken, the target instruction I9I_9 can only be fetched starting at cycle 8.
    • The instructions executed following the branch are I9,I10,I11,I12I_9, I_{10}, I_{11}, I_{12} (a sequence of 4 instructions).
    • In an empty 5-stage pipeline, executing 4 instructions requires:
      5+(4−1)=8 cycles5 + (4 - 1) = 8\text{ cycles}
    • These 8 cycles take place from cycle 8 through cycle 7+8=157 + 8 = 15.
    • Thus, instruction I12I_{12} finishes at the end of cycle 15.
  3. Compute total time:

    Total time=15×11 ns=165 ns\text{Total time} = 15 \times 11\text{ ns} = 165\text{ ns}

This matches option (B).

Final answer

B

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2013 Computer Science and Information Technology (CS)
Question
45 of 65, printed as CS Q.45
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.