1.4k views
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 _____
edited | 1.4k views

Total Instruction $= 100$
Number of stages $= 5$
In normal case total cycles $= 100 +5 -1 = 104$ cycles

Now, For PO stage $40$ instruction takes $3$ cycles, $35$ takes $2$ cycles and rest of the $25$ takes $1$ cycle.
That means all other stages are perfectly fine and working with $CPI$ (Clock Cycle Per Instruction)$= 1$

PO stage:
$40$ instruction takes $3$ cycles i.e. these instructions suffering from $2$ stall cycle,
$35$ instruction takes $2$ cycles i.e. these instructions suffering from $1$ stall cycle,
$25$ instruction takes $1$ cycles i.e. these instructions suffering from $0$ stall cycle,

So, extra cycle would be $40*2 + 35*1 + 20*0 = 80+35 = 115$ cycle.

Total cycles = $104 + 115 = 219$
answered by Veteran (54.1k points)
edited
+1

25 instruction takes 3 cycles,  i.e. these instructions suffering from 0 stall cycle,

Sir, small typo. It should be 25 instructions take 1 cycle,  i.e. these instructions suffering from 0 stall cycle,

+1
Corrected :-)
Total Instruction =100
Instruction Fetch (IF). Instruction Decode (ID). Operand Fetch (OF), and Write back (WB) performed in 1 cycle.
PO stage:
40 instructions takes 3 cycle
35 instructions take 2 cycles
25 instructions take 1 cycle
Average number of cycles required is = (40 x 3+35 x 2+25 x 1)/100 = 2.15 cycles.
On an average first instruction completed in 1+1+1+1+2.15 cycles = 6.15;
Remaining 99 instruction will takes 99 × 2.15 = 212.85 cycles
Total number of cycles is 6.15+212.85 = 219 cycles.
answered by Loyal (3.6k points)