Explain instruction pipelining. A pipeline has 5 stages and each stage takes 20 ns. i. Calculate the time required to execute 10 instructions without pipelining. ii. Calculate the execution time with pipelining. iii. Find the speedup.
Explain instruction pipelining. A pipeline has 5 stages and each stage takes 20 ns. i. Calculate the time required to execute 10 instructions without pipelining. ii. Calculate the execution time with pipelining. iii. Find the speedup.
Instruction pipelining
Instruction pipelining splits the execution of an instruction into stages, such as fetch, decode, execute, memory access and write back. Each stage has its own hardware. While one instruction is in a later stage, the next instruction is already in an earlier stage. So many instructions are in progress at the same time, and one instruction can finish in every clock cycle once the pipeline is full.
For $k$ stages, $n$ instructions and a stage time $t_p$, the times are:
$$T_{non\text{-}pipelined} = n,k,t_p$$
$$T_{pipelined} = (k + n - 1),t_p$$
$$\text{Speedup} = \frac{T_{non\text{-}pipelined}}{T_{pipelined}}$$
Numerical
Here the number of stages is $k = 5$, the stage time is $t_p = 20$ ns, and the number of instructions is $n = 10$.
(i) Without pipelining. Each instruction passes through all 5 stages one after the other, and the next one starts only after it ends. So one instruction takes $5 \times 20 = 100$ ns.
$$T_{non\text{-}pipelined} = 10 \times 5 \times 20 = 1000 \text{ ns}$$
(ii) With pipelining. The first instruction needs 5 cycles to come out. After that, each of the remaining 9 instructions finishes in one more cycle. So the total is $5 + 9 = 14$ cycles.
$$T_{pipelined} = (5 + 10 - 1) \times 20 = 14 \times 20 = 280 \text{ ns}$$
(iii) Speedup.
$$\text{Speedup} = \frac{1000}{280} \approx 3.57$$
Therefore the pipeline needs 280 ns for 10 instructions instead of 1000 ns, and the speedup is about 3.57. It is less than the ideal value 5, because the pipeline takes time to fill. If more instructions are run, the speedup comes closer to 5. For 1000 instructions, it would be $5000/1004 \approx 4.98$.
Remark. The result shows why pipelining is used. The total time falls from 1000 ns to 280 ns, though one instruction still takes 100 ns from start to end. The gain is in the throughput, which is the number of instructions finished per unit time. Hazards such as data dependencies would add stall cycles and lower the speedup further.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.
Up nextExplain the design and working of a hardwired control unit. Discuss about its advantages a