In the above sequence, to 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 stages: Instruction Fetch and Decode , Operand Fetch , Perform Operation and Write back the result . The , and stages take clock cycle each for any instruction. The stage takes clock cycle for ADD and SUB instruction, clock cycles for MUL instruction and 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 (from I1) and (from I2). is ready at the end of cycle 5, and is ready at the end of cycle 8. Thus, the OF of I3 must wait until cycle 9.
- I4 (SUB) depends on (from I3). 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.
