A 5 stage pipelined CPU has the following sequence of stages:
IF – Instruction fetch from instrution memory.
RD – Instruction decode and register read.
EX – Execute: ALU operation for data and address computation.
MA – Data memory access – for write access, the register read at RD state is used.
WB – Register write back.
Consider the following sequence of instructions:
I1: L R0, loc 1 ; R0 <=M[loc1]
I2: A R0, R0 1 ; R0 <= R0 + R0
I3: S R2, R0 1 ; R2 <= R2 - R0
Let each stage take one clock cycle. What is the number of clock cycles taken to complete the above sequence of instructions starting from the fetch of I1?
So here's my solution.
1 2 3 4 5 6 7 8 9 10 11 12 13
I1: IF RD EX MA WB
I2: IF - - - RD EX MA WB
I3: IF - - - - - - RD EX MA WB
In this way I'm getting total 13 cycles. I'm assuming that since operand forwarding is not explicitly mentioned in the question. So register will be only available after WB stage. But option are following:
- A. 8
- B. 10
- C. 12
- D. 15