retagged by
23,581 views
59 votes
59 votes
The instruction pipeline of a RISC processor has the following stages: Instruction Fetch $(IF)$, Instruction Decode $(ID)$, Operand Fetch $(OF)$, Perform Operation $(PO)$ and Writeback $(WB)$, The $IF$, $ID$, $OF$ and $WB$ stages take $1$ clock cycle each for every instruction. Consider a sequence of $100$ instructions. In the $PO$ stage, $40$ instructions take $3$ clock cycles each, $35$ instructions take $2$ clock cycles each, and the remaining $25$ instructions take $1$ clock cycle each. Assume that there are no data hazards and no control hazards.

The number of clock cycles required for completion of execution of the sequence of instruction is _____.
retagged by

8 Answers

7 votes
7 votes
Consider it like a counting problem :

There are total (40*3 + 35*2 + 25*1 ) 'individual' PO stages and each 'individual' PO stage will take one clock cycle. Also, the initial filling of the pipeline will require 3 'extra' clock cycles of IF, ID and OF and the last clock cycle of the pipeline will always be a WB stage.

Also, since there is NO data hazard or control hazard, the IF, ID, OF and WB stages will fit in the pipeline without causing any stalls. So, the only hazard possible is due to PO stage - so, one clock cycle for each PO stage.

So, total clock cycles required = No. of clock cycles for PO stage + Initial filling of Pipeline + one last cycle for WB stage = 215 + 3 + 1 = 219 clock cycles.
1 votes
1 votes
the number of clock cycles required = Total number of cycles required in general case + Extra cycles required
= (5 + 99) + Extra cycles
= (104) + 40*(3-1)+35*(2-1)+20*(1-1)
= 104+ 40*2+35*1
= 104 + 115
= 219 cycles
0 votes
0 votes
So, in normal case total cycles = 100 + 5 - 1 = 104 cycles

But in this question it is given that PO stage of 40 instructions takes 3 cycles, 35 instructions takes 2 cycles and 25 instructions takes 1 cycle.

PO Stage of 40 instruction takes 3 cycles means 2 stalls

PO Stage of 35 instruction takes 3 cycles means 1 stalls

PO Stage of 25 instruction takes 3 cycles means 0 stalls

 

So, extra stall cycles = 40*2 + 35*1 = 80+35 = 115 cycles. So, total clock cycles = 104 + 115 = 219
Answer:

Related questions