D109 of 13
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

D10 · Lesson 9 · Pipelining

Cutting a long combinational path into stages separated by registers, the higher clock rate and throughput that buys, the latency it costs, the register overhead that limits how far it helps, filling and draining the pipeline, and retiming registers to balance the stages

A laundry with a washer and a dryer finishes the first load no sooner when you pipeline it, but once the washer passes a load to the dryer and starts the next, a load comes out every hour instead of every two. Digital pipelines work the same way: break a long chain of logic into stages with registers between them, and each stage can start on new data every cycle. The clock gets faster in proportion to the number of stages, until the registers' own delay starts to dominate, and every result takes a few cycles longer to emerge.

  • A block of logic taking 10 ns, split into N equal stages, each followed by a register with 0.5 ns of overhead (clock-to-output plus setup).
  • The clock rate (solid) climbs almost in proportion to N at first, then levels off as the fixed overhead dominates. The latency (dashed, in ns) grows.
  • Throughput is one result per clock, so it follows the clock rate.

Predict

The 10 ns block is split into 4 stages, each with 0.5 ns of register overhead. How much faster does data flow through?

Name it

The gain

Splitting logic of delay TL into N balanced stages with register overhead tr each gives a clock period

T=TLN+tr

so the throughput (one result per cycle) rises until the overhead dominates: it can never exceed 1/tr.

The costs

  • Latency grows to NT=TL+Ntr: the first result appears N cycles after its input.
  • Processing M independent items takes N+M−1 cycles: N − 1 to fill the pipeline, then one per cycle.
  • Registers cost area and power, and dependencies, when one result is needed to compute the next, force stalls or forwarding (C8, S4).

Balancing

The clock must accommodate the slowest stage, so unbalanced stages waste the others' time. Retiming moves registers across logic to even out the stages without changing the function, and synthesis tools can do it automatically.

Worked example

With 10 stages instead of 4, what are the clock rate and latency? How long do 1000 items take with 4 stages?

Show the solution
  1. Clock period with 10 stages. Each stage holds 1 ns of logic plus 0.5 ns of overhead: T=1+0.5=1.5ns
  2. Clock rate. 11.5ns=667MHz
  3. Latency and speedup. Ten stages of 1.5 ns make a latency of 15 ns, and against the 10.5 ns unpipelined path the speedup is 10.51.5=7
  4. 1000 items with 4 stages. At 3 ns per cycle, the first item takes 4 cycles and each of the other 999 one more: t=(4+999)×3ns=1003×3ns=3.01μs
  5. Without the pipeline. 1000×10.5ns=10.5μs

Answer with 10 stages, 667 MHz and a latency of 15 ns; with 4 stages, 1000 items take 3.01 µs, against 10.5 µs unpipelined.

Worked example

Stages of 2, 3 and 5 ns plus 0.4 ns of overhead each. What's the clock period, and what would balancing achieve?

Show the solution
  1. The slowest stage sets the period. 5+0.4=5.4ns
  2. Balance the stages. Rebalanced to 10/3 ns each: T=3.33+0.4=3.73ns
  3. Compare. 5.43.73=1.45 so balancing makes it 45% faster.

Answer a 5.4 ns period, and 3.73 ns once balanced, 45% faster.

Worked example

In a pipelined processor, 20% of instructions are loads whose result the next instruction needs, costing one stall each. What is the CPI?

Show the solution
  1. Add the stalls. Each of the 20% of instructions that stall costs one extra cycle: CPI=1+0.2×1=1.2
  2. Throughput. 11.2=83% of the ideal.
  3. Recovering it. Compilers reorder instructions to fill those slots and bring the CPI back toward 1.

Answer a CPI of 1.2, so the pipeline runs at 83% of its ideal throughput.

Check

Logic taking 10 ns is split into 2 balanced stages with 0.6 ns of register overhead each. What clock rate does it allow?

Write units the way you normally would: 1.5 MHz, 1500 kHz and 0.0015 GHz are the same answer.

Check

For that pipeline (10 ns of logic, 2 stages, 0.6 ns overhead each), how long does one result take from input to output?

Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.

Check

How many cycles does a 5-stage pipeline take to process 10 independent items?

Check

A pipeline's three stages take 2, 4 and 5 ns of logic, each plus 0.5 ns of overhead. What clock period does it need?

Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.

Check

A combinational job of 10 ns is split into 4 equal pipeline stages, each adding 0.5 ns of register overhead.

(a)

What clock rate results?

Write units the way you normally would: 1.5 MHz, 1500 kHz and 0.0015 GHz are the same answer.

(b)

What is the latency?

Check

In a pipelined processor, 20% of instructions stall for 1 cycle(s) each.

(a)

What is the CPI?

(b)

What share of the ideal throughput does it get?

Explain why

Why does pipelining raise throughput but not reduce latency?

Practice

Keep practicing

8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.