S3 · Lesson 23 · Pipelining and retiming
Trading latency for throughput, balancing stages, and the limit loops impose
If a block of logic is too slow for the clock, cut it in pieces with registers between them. Each piece now has a whole clock period, so the clock can run faster, and a new input can enter every cycle while earlier ones are still in flight. That's pipelining, the reason processors, DSP chains and network switches reach gigahertz rates. It isn't free: every register adds its clock-to-Q and setup time, so the gains shrink as stages get thinner, each result takes more cycles to come out, and a loop that feeds a result back into its own input can't be pipelined at all without changing the algorithm.
- A block with total logic delay T split into k equal pipeline stages, each adding a register overhead r. The solid curve is throughput (results per nanosecond, so GHz); the dashed one is latency in nanoseconds.
- Throughput rises nearly in proportion to k at first, then flattens toward 1/r as the register overhead dominates.
- Latency, T + kr, only grows. Increase r and the useful number of stages drops.
Predict
A 4 ns block with 0.1 ns of register overhead per stage is pipelined into 4 stages. What happens to its throughput and its latency?
The period drops from 4.1 ns to 4/4 + 0.1 = 1.1 ns, so throughput rises 4.1/1.1 = 3.7 times, a little short of 4 because of the extra registers. Each result now takes 4 × 1.1 = 4.4 ns to come out, 7% longer than before. So the pipeline delivers results 3.7 times as often, and each one takes slightly longer to arrive.
Name it
Throughput and latency
Splitting logic of delay T into k balanced stages, each with register overhead (plus skew and jitter margin):
Throughput approaches 1/r as k grows, and power and area grow with every register. Unbalanced stages are worse: the period is set by the slowest stage, .
Retiming
Registers can be moved backward or forward across logic without changing what the circuit computes (as long as every path's register count between input and output is kept), to balance stage delays or shorten the critical path. Synthesis tools do it automatically when allowed.
Loops limit pipelining
A result that feeds back into the next computation (an accumulator, an IIR filter, a processor's branch decision) can't use a result that's still in the pipeline. For a loop with total logic delay and R registers around it, the period can't be less than
(the iteration bound). Adding registers to the loop changes the algorithm, so loops are fixed by transforming the algorithm (look-ahead, interleaving several independent streams) or by forwarding, as in processors (lesson 42).
Pipelining for power
At a fixed throughput, a deeper pipeline gives each stage more slack, so the supply can drop: with , that often saves more than the extra registers cost.
Worked example
A 4 ns block with 0.1 ns of register overhead: compare 1, 4 and 10 stages.
Show the solution
- One stage. The period is ns, 244 MHz, and the latency is 4.1 ns.
- Four stages. Each holds 1 ns of logic: the period is 1.1 ns, 909 MHz, and the latency is
- Ten stages. Each holds 0.4 ns: the period is 0.5 ns, 2.0 GHz, and the latency is
- Compare four and ten. Going from 4 to 10 stages buys times the throughput for 2.5 times the registers. Beyond that the 0.1 ns overhead dominates and the returns fade.
Answer 244 MHz with one stage, 909 MHz with four and 2.0 GHz with ten, at latencies of 4.1, 4.4 and 5.0 ns.
Worked example
A four-stage pipeline has stage delays of 1.2, 0.8, 1.0 and 1.0 ns with 0.1 ns of overhead. What's its clock, and what does retiming to balance the stages give?
Show the solution
- Unbalanced. The slowest stage sets the clock: which is 769 MHz.
- Retimed. Moving a register so 0.2 ns of logic shifts from the first stage to the second gives four 1.0 ns stages: which is 909 MHz.
- Compare. , so 18% faster, with the same logic and the same register count.
Answer 769 MHz as it stands, and 909 MHz (18% faster) after retiming.
Worked example
An accumulator's loop has 1.6 ns of adder and multiplexer logic and one register, with 0.1 ns of register overhead. What clock can it run at, and what does interleaving four independent streams with four registers in the loop give?
Show the solution
- One register.
- Four registers in the loop. Retimed around the loop, the iteration bound is so the clock is ns.
- Throughput. times as much, provided four independent accumulations take turns (each one still gets a new input only every fourth cycle).
Answer a 1.7 ns clock with one register; interleaving four streams allows a 0.5 ns clock, 3.4 times the throughput.
Check
A 5 ns block is split into 2 balanced stages with 0.15 ns of register overhead each. What's the clock period?
Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.
Check
The same kind of pipeline: 5 ns of logic in 3 stages with 0.15 ns overhead. What's its latency?
Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.
Check
How many times higher is the throughput of a 4-stage pipeline than the unpipelined block (3 ns of logic, 0.2 ns overhead per register)?
Check
A pipeline's stages take 1, 0.6 and 1.3 ns, with 0.1 ns of register overhead. What's its maximum clock?
Write units the way you normally would: 1.5 MHz, 1500 kHz and 0.0015 GHz are the same answer.
Check
A feedback loop has 3 ns of logic and 2 register(s) around it. What's the shortest possible clock period?
Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.
Check
What throughput does a 4 ns block approach as it's pipelined ever deeper, with 0.1 ns of register overhead?
Write units the way you normally would: 1.5 GHz, 1500 MHz and 0.0015 THz are the same answer.
Check
A block of 4 ns of logic is split into 2 balanced stages, each with 0.2 ns of register overhead.
(a)
What is the clock period?
Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.
(b)
What throughput does it reach?
(c)
What is the latency?
Check
A feedback loop has total logic delay L and R registers around it, each with overhead r.
Step 1
What is the iteration bound?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What is the shortest clock period?
Step 3
By what factor does throughput rise over a single register (with R interleaved streams)?
Explain why
Why does pipelining increase throughput but never reduce latency?
Pipelining doesn't make any piece of logic faster: a result still has to pass through all of the original logic, and now it also passes through extra registers, each adding a little delay and holding the result until its stage's clock edge. So the time for one result, from input to output, gets slightly longer. What changes is that each stage now holds a different result, so the block works on several at once. A new input can enter every clock, and the clock can be much faster because each stage contains only a fraction of the logic. The block produces results more often, even though each one takes as long or longer.
Practice
Keep practicing
10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.