• edited by
75,595 views
144 144 votes

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 $\text{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\ \text{ns}.$ A program consisting of $12$ instructions $\text{I1, I2, I3,}\ldots,\text{ I12}$ is executed in this pipelined processor. Instruction $\text{I4}$ is the only branch instruction and its branch target is $\text{I9}.$ If the branch is taken during the execution of this program, the time (in ns) needed to complete the program is

  1.  $132$   
  2.  $165$ 
  3.  $176$
  4.  $328$

20 Answers

Best answer
186 186 votes
After pipelining we have to adjust the stage delays such that no stage will be waiting for another to ensure smooth pipelining (continuous flow). Since we can not easily decrease the stage delay, we can increase all the stage delays to the maximum delay possible. So, here maximum delay is $10$ ns. Buffer delay given is $1$ ns. So, each stage takes $11$ ns in total.

FI of $\text{I9}$ can start only after the EI of $\text{I4}.$ So, the total execution time will be
$$15 \times 11 = 165$$
$$\small \begin{array}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \hline
&\bf{t_1}&\bf{t_2}&\bf{t_3}&\bf{t_4}&\bf{t_5}&\bf{t_6}&\bf{t_7}&\bf{t_8}&\bf{t_9}&\bf{t_{10}}&\bf{t_{11}}&\bf{t_{12}}&\bf{t_{13}}&\bf{t_{14}}&\bf{t_{15}}\\
\hline
\textbf{I1}&\text{FI}&\text{DI}&\text{FO}&\text{EI}&\text{WO}\\
\textbf{I2}&&\text{FI}&\text{DI}&\text{FO}&\text{EI}&\text{WO}\\
\textbf{I3}&&&\text{FI}&\text{DI}&\text{FO}
&\text{EI}&\text{WO}\\
\textbf{I4}&&&&\text{FI}&\text{DI}&\text{FO}&\text{EI}&\text{WO}\\
&&&&&\color{red}{\text{stall}}\\
&&&&&&\color{red}{\text{stall}}\\
&&&&&&&\color{red}{\text{stall}}\\
\textbf{I9}&&&&&&&&\text{FI}&\text{DI}&\text{FO}&\text{EI}&\text{WO}\\
\textbf{I10}&&&&&&&&&\text{FI}&\text{DI}&\text{FO}&\text{EI}&\text{WO}\\
\textbf{I11}&&&&&&&&&&\text{FI}&\text{DI}&\text{FO}&\text{EI}&\text{WO}\\
\textbf{I12}&&&&&&&&&&&\text{FI}&\text{DI}&\text{FO}&\text{EI}&\text{WO}\\
\hline\end{array}$$

Correct Answer: $B$
• edited by
43 43 votes

answer = option B

cycles in pink are stall cycles, at EI-4 it was notified to the system that instruction 9 has to be loaded next. 
We have completed execution in a total of 15 cycles where each cycle was (10+1)ns long,

Hence, answer = $15 \times 11 = 165$ns

20 20 votes
Clock Time = max stage delay + Buffer Delay

 = 10+1= 11ns

I1 - Finish at 5th clock

I2 - Finish at 6th clock

I3 - Finish at 7th clock

I4- Finish at 8th clock

Due to branching at I4 pipelining halts and starts after  EI stage of I4 and performs FI of I9 at 8th clock.

I9 - Finish at 12th clock

I10 - Finish at 13th clock

I11- Finish at 14th clock

I12 - Finish at 15 clock

Total time to complete program = 11*15= 165 ns
7 7 votes

.......

 

2 flags:
✌ Edit necessary (js__)
✌ Edit necessary (vxi lin “total instructions are 12 not 11”)
6 6 votes
We can determine  if the branch is taken or not after the execution stage  of the instruction I4.So number of stall cycles will be (4-1)=3.

Before the branch is taken total number of instructions is  4 and after branch is taken total number of instructions is 4 .So total number of instructions to be executed is 8.So we can assume the situation as we have total 8 instructions to be executed in pipelined manner without any stall cycles.

There are  5 stages in the pipeline.So the number of cycles needed to execute first instruction is 5.After that in each clock cycle one instruction will be completed.So total number of clock cycles needed is

5+(8-1)=5+7=12.

Due to branching number of stall cycles overhead is 3.

So total number of clock cycles needed=12+3=15.

time required to complete one clock cycle is =max stage delay+buffer overhead=10+1=11

So total time required will be = 15*11=165.
2 2 votes

1) Total Cycles if there were no stalls or branching = k + (n-1) = 5 + ( 12-1) = 16 cycles

where k = number of stages in pipeline and n = total number of instructions

2) Due to branching, we jump over/skip I5, I6, I7, I8; four instructions are skipped; updated number of cycles = 12 cycles

3) Branch is resolved at 4th stage (EI) Therefore,

number of stalls = 4-1 = 3 cycles 

Final number of cycles = 12 + 3(stalls) = 15 cycles

Cycle time = 10 + 1= 11ns

Execution time = cycle time * number of cycles = 11 ns * 15 = 165 ns

 

Answer:
Position:
Show:

Related questions

79 79 votes
11 answers 11 answers
33.8k
33.8k views
go_editor asked Sep 28, 2014
33,801 views
Consider a $6$-stage instruction pipeline, where all stages are perfectly balanced. Assume that there is no cycle-time overhead of pipelining. When an application is exec...
197 197 votes
9 answers 9 answers
78.5k
78.5k views
Kathleen asked Sep 22, 2014
78,490 views
A $5$ stage pipelined CPU has the following sequence of stages:IF – instruction fetch from instruction memoryRD – Instruction decode and register readEX – Execute: ALU op...
74 74 votes
4 answers 4 answers
35.7k
35.7k views
Kathleen asked Sep 12, 2014
35,733 views
Which of the following are NOT true in a pipelined processor?Bypassing can handle all RAW hazardsRegister renaming can eliminate all register carried WAR hazardsControl h...
55 55 votes
5 answers 5 answers
23.5k
23.5k views
Arjun asked Sep 24, 2014
23,467 views
Consider the following sequence of micro-operations.MBR ← PC MAR ← X PC ← Y Memory ← MBRWhich one of the following is a possible operation performed by this sequence?Inst...