A hypothetical processor uses a 3-stage instruction pipeline: Fetch (F),…
2025
A hypothetical processor uses a 3-stage instruction pipeline: Fetch (F), Decode (D), and Execute (E). Assume the following conditions:
The processor operates at a clock rate of 1 GHz.
Each instruction takes exactly one clock cycle per stage.
The pipeline is ideal (no stalls or hazards).
100 instructions need to be executed.
(a) Calculate the total execution time to complete all 100 instructions using the pipelined processor.
(b) Calculate the total time to complete the same 100 instructions in a non-pipelined processor, where each instruction takes 3 clock cycles (1 each for fetch, decode, and execute).
(c) Compute the speedup achieved by pipelining.
Attempted by 40 students.
Show answer & explanation
Given a processor with a 3-stage pipeline: Fetch (F), Decode (D), and Execute (E). The clock rate is 1 GHz, which means the clock cycle time is 1 ns.
(a) Execution time using pipelining
In an ideal pipeline, the first instruction requires 3 cycles to pass through all stages. After the pipeline is filled, each additional instruction completes in one cycle.
Total cycles required = pipeline stages + (number of instructions − 1)
= 3 + (100 − 1)
= 102 cycles
Since each cycle takes 1 ns,
Total execution time = 102 × 1 ns = 102 ns
Example:
Instruction 1 completes at cycle 3, instruction 2 at cycle 4, instruction 3 at cycle 5, and so on until instruction 100 finishes at cycle 102.
(b) Execution time without pipelining
In a non-pipelined processor, each instruction performs fetch, decode, and execute sequentially. Each instruction therefore takes 3 cycles.
Total cycles = 100 × 3 = 300 cycles
Total execution time = 300 × 1 ns = 300 ns
(c) Speedup due to pipelining
Speedup = Non-pipelined time / Pipelined time
= 300 ns / 102 ns
≈ 2.94
Thus, by using pipelining the processor completes 100 instructions in about 102 ns instead of 300 ns, achieving a speedup of approximately 2.94 times.