The GATE Grind

GATE 2018 CS – Question 60

Computer Organization and Architecture · Instruction Pipelining and Pipeline Hazards · 2 marks · Numerical answer

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 instructions is ________.

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 219

Explanation

Stage times: IF = ID = OF = WB = 1 cycle, PO = 3, 2 or 1 cycles depending on the instruction.

Because PO is a single stage that cannot overlap itself, instructions go through PO one after another. Total PO time:
$$40\times3+35\times2+25\times1=120+70+25=215\text{ cycles}.$$

The first instruction must pass IF, ID and OF (3 cycles) before it enters PO. The last instruction, after finishing PO, needs 1 more cycle for WB. The other stages never delay PO because they take no longer than 1 cycle per instruction, which is not slower than PO.

$$\text{Total}=3+215+1=\mathbf{219}\text{ cycles}.$$

More Instruction Pipelining and Pipeline Hazards questions

All Instruction Pipelining and Pipeline Hazards questions →