4.1.18 · D5Computer Architecture (Deep)

Question bank — Pipelining — 5-stage pipeline, each stage

1,925 words9 min readBack to topic

The symbols this page uses (define before you argue)

Before any trap, pin down every letter so no reveal ever surprises you.

Below, the figure turns these letters into a picture so you can see fill, steady state, and drain.

Figure — Pipelining — 5-stage pipeline, each stage

True or false — justify

A stage is one of the steps (IF, ID, EX, MEM, WB) an instruction passes through; latency is the time from an instruction entering the pipe to it finishing; throughput is how many instructions complete per unit time. Keep those three apart and most traps disappear.

Pipelining makes each individual instruction run faster.
False. A single instruction still visits all stages, so its latency is unchanged (often slightly worse from register overhead). Only throughput — completions per second — improves.
A 5-stage pipeline always delivers exactly 5× speedup.
False. only approaches as , and only with balanced stages and zero stalls. Real speedup is lower — see Pipeline Hazards (Data, Control, Structural).
If all stages are perfectly balanced and there are no hazards, throughput is one instruction per cycle.
True. After the pipe fills, a completed instruction exits every cycle, giving throughput where is the clock period — the ideal steady state.
Adding more pipeline stages always increases performance.
False. Deeper pipelines shrink the clock period but add more register overhead per stage and worsen hazard penalties (branch misprediction flushes cost more stages). There is a sweet spot beyond which it hurts.
Pipeline registers are wasted hardware you could remove to save area.
False. Without latches the result of stage would be clobbered when the next instruction enters stage next cycle. They hold each instruction's per-stage state as it moves down the pipe.
The clock period of a pipeline equals the total instruction time divided by the number of stages.
False. It equals the slowest single stage delay plus register overhead, — the max, not the average.
Doubling the number of instructions doubles the speedup.
False. Speedup is bounded above by ; as grows, climbs toward but flattens. Doubling from huge to huger barely moves it.
In steady state, all stages are busy on different instructions at once.
True. That overlap is the entire point — instructions are "in flight," each in a different stage, so no hardware sits idle.

Spot the error

Each item states a piece of reasoning with a hidden flaw. Find it before revealing.

"Latency improves because the program finishes sooner, so each instruction is quicker."
The program finishes sooner because instructions overlap, not because any one sped up. Program time ↓ while per-instruction latency stays cycles — those are different quantities.
"Speedup for , is 5 because there are 5 stages."
Only instructions can't hide the 4 fill cycles. Actual . Max speedup is a limit reached only for large .
"We set the clock to the average stage delay so faster stages compensate for slower ones."
A fast stage cannot "finish early and help." Every stage must complete within one period, so the clock is governed by the slowest stage; the fast ones just wait.
"Since IF and WB both touch memory-like structures, one register file port is enough — no structural conflict."
IF fetches from instruction memory while WB writes the register file, and ID reads the register file simultaneously. Sharing a single port causes a structural hazard (see Pipeline Hazards (Data, Control, Structural)). Split ports / caches exist precisely to avoid this.
"With forwarding installed, we get the full 5× speedup on any program."
Forwarding and Bypassing removes most data-hazard stalls, but load-use hazards still cost a bubble and control hazards from branches still cause flushes. Speedup improves but stays below .
"Non-pipelined CPI is 5 and pipelined CPI is 1, so the speedup is exactly 5 always."
Ideal pipelined CPI is 1 only in steady state with no stalls. Fill cycles, hazards, and branch penalties push effective CPI above 1 — see Clock Frequency and CPI.
"A single-cycle CPU has no pipeline registers, so it must have lower latency per instruction."
A single-cycle instruction's latency is one long clock () with no register overhead, so its latency can be comparable or lower — but its throughput is far worse. Compare via Single-cycle vs Multi-cycle Datapath.

Why questions

Why is the maximum speedup equal to the number of stages, not something larger?
In the best case the pipe completes exactly one instruction per cycle (throughput ) versus non-pipelined — a ratio. You can't finish faster than one-per-cycle without going superscalar (Superscalar and Out-of-Order Execution).
Why do we bother balancing stage delays if the whole instruction time is fixed?
Because the clock period is set by the slowest stage. One bloated stage stretches every cycle for every instruction, so balancing minimizes the max stage delay and thus the period.
Why does a small give disappointing speedup even with a perfect pipeline?
The first instruction still needs cycles to fill the pipe. Those warm-up cycles are a fixed cost amortized over ; when is small they dominate .
Why can pipelining make per-instruction latency slightly worse than non-pipelined?
Each stage boundary inserts a pipeline register with setup/propagation delay . Summed across boundaries, that overhead adds to the instruction's total journey time.
Why does branch prediction matter for keeping the pipeline full?
A branch's outcome isn't known until a later stage, but IF must keep fetching now. Guessing wrong means discarding wrongly-fetched instructions (a flush). Good Branch Prediction keeps the fetch stream correct and the pipe fed.
Why doesn't Amdahl's Law contradict the speedup claim?
Amdahl's Law limits overall program speedup when only part of the work is accelerated; the figure is the ideal speedup of the pipelineable instruction stream itself, assuming no unpipelinable serial bottleneck.
Why is throughput the right metric to advertise a pipeline, not latency?
Pipelines are designed to overlap work, which raises completions-per-second without shortening any single job — exactly what throughput measures. Advertising latency would hide the real benefit.

Edge cases

: what is the speedup?
. One lone instruction gets no overlap partner — pipelining gives zero benefit, and with register overhead it's marginally slower.
(a "one-stage pipeline"): speedup?
. With a single stage there is nothing to overlap; it's just the non-pipelined machine.
One stage is far slower than the rest (e.g. MEM = , others ): what happens to the clock?
The clock period stretches to that slowest stage (). Throughput collapses toward one instruction per — the bottleneck stage sets the pace regardless of how fast the others are.
Every instruction stalls one cycle (a bubble each): effect on steady-state throughput?
Effective CPI rises from 1 to 2, halving throughput. Stalls insert idle "bubble" cycles where no instruction completes even though the pipe is running.
with balanced stages and no hazards: throughput and speedup?
Throughput (one per cycle) and speedup . The fill cycles become negligible and the ideal limit is reached.
A program is one huge unbreakable instruction (can't be split into stages): can pipelining help it?
No. Pipelining exploits overlap between the stages of consecutive instructions; a single indivisible unit offers no stages to overlap and no successor to feed in behind it.
Two consecutive instructions where the second needs the first's result immediately: does the pipe still complete one-per-cycle?
Not without help — that's a data hazard. Either a stall bubble is inserted (throughput dips) or Forwarding and Bypassing routes the result early to preserve the one-per-cycle rate.

Connections