Skip to content
Official PYQ · 2015

GATE CS 2015 Set 2 Q44 — Instruction Pipelining

Explain with AI
Consider the sequence of machine instruction given below:
MULR5, R0, R1DIVR6, R2, R3ADDR7, R5, R6SUBR8, R7, R4\begin{array}{ll} \text{MUL} & \text{R5, R0, R1} \\ \text{DIV} & \text{R6, R2, R3} \\ \text{ADD} & \text{R7, R5, R6} \\ \text{SUB} & \text{R8, R7, R4} \\ \end{array}
In  the above sequence, R0R0 to R8R8 are general purpose registers. In the instructions shown, the first register shows the result of the operation performed on the second and the third registers. This sequence of instructions is to be executed in a pipelined instruction processor with the following 44 stages: (1)(1) Instruction Fetch and Decode (IF)(IF), (2)(2) Operand Fetch (OF)(OF), (3)(3) Perform Operation (PO)(PO) and (4)(4) Write back the result (WB)(WB). The IFIF, OFOF and WBWB stages take 11 clock cycle each for any instruction. The POPO stage takes 11 clock cycle for ADD and SUB instruction, 33 clock cycles for MUL instruction and 55 clock cycles for DIV instruction. The pipelined processor uses operand forwarding from the PO stage to the OF stage. The number of clock cycles taken for the execution of the above sequence of instruction is _________.
View worked solution

Answer: 13

To find the total number of clock cycles, we trace the execution of each instruction through the pipeline stages: IF (Instruction Fetch), OF (Operand Fetch), PO (Perform Operation), and WB (Write Back).

Since operand forwarding is available from the PO stage to the OF stage, a dependent instruction can perform its OF stage in the cycle immediately following the completion of the source instruction's PO stage.

The cycle-by-cycle execution is shown in the table below:

Instruction 1 2 3 4 5 6 7 8 9 10 11 12 13
I1: MUL R5, R0, R1 IF OF PO PO PO WB
I2: DIV R6, R2, R3 IF OF PO PO PO PO PO WB
I3: ADD R7, R5, R6 IF stall stall stall stall stall OF PO WB
I4: SUB R8, R7, R4 IF stall stall stall stall stall stall OF PO WB

Key Details:

  • I3 (ADD) depends on R5R5 (from I1) and R6R6 (from I2). R5R5 is ready at the end of cycle 5, and R6R6 is ready at the end of cycle 8. Thus, the OF of I3 must wait until cycle 9.
  • I4 (SUB) depends on R7R7 (from I3). R7R7 is ready at the end of cycle 10. Thus, the OF of I4 must wait until cycle 11.

The entire sequence completes execution at the end of 13 clock cycles.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Instruction Pipelining questions