edited by
2,515 views
18 votes
18 votes

A machine $\mathcal{M}$ has the following five pipeline stages; their respective time requirements in nanoseconds (ns) are given within parentheses:

  • $F$-stage — instruction fetch ($9$ ns),
  • $D$-stage — instruction decode and register fetch ($3$ ns),
  • $X$-stage — execute/address calculation ($7$ ns),
  • $M$-stage — memory access ($9$ ns),
  • $W$-stage — write back to a register ($2$ ns).

Assume that for each stage, the pipeline overhead is $1$ ns. A program $P$ having $100$ machine instructions runs on $\mathcal{M}$, where every $3$rd instruction needs a $1$ – cycle stall before the $X$-stage. Calculate the CPU time in seconds for completing $P$.

edited by

5 Answers

Best answer
22 votes
22 votes
As there are $5$ stages so $1$ instruction will take $5$ clock cycles, now all subsequent
instructions will take $1\text{-}1$ cycle each So,
Now without any stall cycle total cycles are $ 5+(100-1) =104$

Now each $3^{rd}$ instruction is taking one stall cycle So,
Total stall cycles in $100$ instructions are $\dfrac{100}{3}=33$

Total cycle to complete the $100$ instructions are $104+33=137$ cycles.

Max time taken from all the stages are $9\text{ ns}$ and $1\text{ ns}$ is overhead
then $10\text{ ns}$ can be given as clock cycle time
So, total time taken is: $137\times 10=1370 \text{ ns}$   ...:)
edited by
4 votes
4 votes
Tc=Max(among all delay of stages)+Toverhead

Tc=10ns

Time required for one instruction=(1+SF*SP)Tc

Here, SF=0.33 bcz every third out of 100 and SP=1(Stall)

T1st=(1+.033*1)Tc=13.3ns

Therefore for 100 instruction=13.3*100ns=1330ns
2 votes
2 votes
Clock cycle for pipe line is 10 ns,  we take Max time

there is 100 instruction

33 instruction are branch instruction which take CPI=2     , 2 clock cycle to execute

67 instruction are non branching instruction which take CPI=1 ,   1 clock cycle to execute

so ,Total time taken is == 67*1 + 33*2 = 133 clock cycle

and 1 clock cycle is of 10ns

Total time taken as = 1330ns
0 votes
0 votes

"Every 3rd instruction needs a 1– cycle stall before the X-stage"

therefore for 100 instructions , clock cycles will be = 100/3 = 33 clock cycles stalls

And the time taken for each cycle is = max( 9,3,7,9,2) + 1ns of overhead = 9+1 = 10ns

therefore for 33 clock cycles it take =  33 * 10 = 330 ns

 

And the time taken by CPU to execute 100 instructions is

= 1(1st instruction) * 5(CPI) * 10(each clock cycle time)  +  99(remaining 99 instruction) * 1 ( CPI ) * 10(each clock cycle time) 

= 1040 ns

 

Total time taken by CPU = 330 + 1040 = 1370 ns Ans.

 

 

Answer:

Related questions