The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+16 votes

An instruction pipeline consists of 4 stages – Fetch (F), Decode field (D), Execute (E) and Result Write (W). The 5 instructions in a certain instruction sequence need these stages for the different number of clock cycles as shown by the table below

No. of cycles needed for
Instruction F D E W
1 $1$ $2$ $1$ $1$
2 $1$ $2$ $2$ $1$
3 $2$ $1$ $3$ $2$
4 $1$ $3$ $2$ $1$
5 1 2 1 2


\begin{array}{|c|c|c|c|c|} \hline \textbf{Instruction} & \textbf {F} &\textbf {D} & \textbf {E} &  \textbf{W } \\\hline \textbf{1}& \text{$1$} & \text{$2$}  & \text{$1$} & \text{$1$} \\\hline \textbf{2} & \text{$1$} & \text{$2$} & \text{$2$}  & \text{$1$}\\\hline  \textbf{3}& \text{$2$} & \text{$1$}  & \text{$3$} & \text{$2$} \\\hline \textbf{4} & \text{$1$} & \text{$3$} & \text{$2$}  & \text{$1$} \\\hline \textbf{5} & \text{$1$} & \text{$2$} & \text{$1$}  & \text{$2$} \\\hline \end{array}

Find the number of clock cycles needed to perform the $5$ instructions.

asked in CO & Architecture by Veteran (52k points)
edited by | 1.6k views

3 Answers

+20 votes
Best answer

Answer: 15 cycles are required.

I_1&\text{F}&\text{D}&\text{D}&\text{E}&\text{W} \\ 

answered by Boss (30.6k points)
edited by
I think this is the correct sequence of fetch , unless the previous instruction goes into the next stage (here it is D stage)the current instruction can not enter into F stage.
@Arjun Sir then here we have assumed there is no data dependencies in instruction...I am just confused with the Execute of 1st instruction and decode of second instruction executing in the same column please clarify sir
yes, no dependency is assumed..
@Arjun sir, I have a doubt ,  I think F(fetch) operation of 2nd instruction should have started at 3rd clock cycle, otherwise it will overlap intermediate register's value and D(decode) operation of first instruction will not be executed correctly.

Similarly D(decode) operation of 3rd instruction should have started at 7th clock cycle, instead of 6th otherwise it will effect execution of 2nd instruction.

Please correct me if my understanding is wrong.

Thank you
what will be the answer ...if FETCH of instruction 3 ..takes 3 cycle instead of 2 ? plz help  if you can..?

Shreya Roy any references????

@Bikram  @Arjun

why the fetch operation of 3rd instruction is not starting at 3rd clock cycle?

sameway why fetch of 5th instruction is not starting at 7th clock?
thanks sir
why the F(fetch) operation of 3rd instruction cannot start with 3rd cycle.....if it would then total 14 cycles will be there...
+8 votes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
F D D E W                    
  F - D D E E W              
      F - D - E E E W W      
          F - D - - E E W    
            F - - - D - E W W

therefore 15 clock cycles needed.

answered by Active (4k points)
D of 3rd instruction is missing..
oops ... I have edited the answer Please check it again ...
please check IF(fetch) of I5. I think, it should be in clock 8 not in 7 as IF is not yet released by I4 .. And if we use the concept of the buffer then I2 and I3 should also use buffer concept  ??
yes @vijaycs I5  should be in clock 8
In 3rd instruction 1 F is missing
This answer has changed the question
0 votes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
F D D E W                    
  F - D D E E W              
    F F - D - E E E W W      
        F - D D D - E E W    
          F - - - D D - E W W

I think this should be correct answer


answered by Active (4.4k points)

@mehul vaidya 

​​​​​​instruction 3 -> clock 3 

check again.


@mehul vaidya, are you using concept of buffer? Because in question nothing is mentioned like that.


@Shubhgupta we can't start decode 7th clock, 4th instruction untill 3rd instruction enters in new phase?



Sorry For Too Late Reply.

But from your comment can I conclude that 

If there are two instruction Inst1 & Inst2 such that inst2 is next to inst1

then inst2 can not enter in particular state , until inst1 has done with that state in last cycle?

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,530 questions
54,139 answers
71,068 users