Skip to content
Tactiverge

Computer architecture

Pipelining

Also called: instruction pipeline · 5-stage pipeline · IF ID EX MEM WB · throughput

Definition

Pipelining splits instruction execution into stages and overlaps them, so that while one instruction executes the next is being decoded and the one after is being fetched.

Picture it

It is a laundry line: washer, dryer, folding, each busy with a different load. Each instruction still takes five steps, but once the pipe is full one instruction finishes every cycle. Hazards, when an instruction needs something not ready yet, insert bubbles.

The maths

unpipelined: n × k cycles
pipelined (ideal): k + (n − 1) cycles
speed-up → k as n grows
SI units used in this entry
QuantityUnitSymbol
clock cyclescycle (count)1

Worked example

How many cycles do 100 independent instructions take on a 5-stage pipeline, and without pipelining? What is the speed-up?

  1. Pipelined: 5 + 99 = 104 cycles
  2. Unpipelined: 100 × 5 = 500 cycles
  3. Speed-up = 500 / 104 = 4.81

Answer104 versus 500 cycles: about 4.81 times faster.

✓ The 2 numbers in this answer are recomputed from scratch by an automated test.

laundry line

Pipeline diagram

Stage occupied by each instruction in each clock cycle
Instruction123456789101112
add r1, r2, r3IFIDEXMEMWB
sub r4, r1, r5IFID····EXMEMWB
and r6, r4, r1IF····ID····EXMEMWB
or r7, r2, r3IF····IDEXMEMWB
12 cycles for 4 instructions, with 4 stall bubbles (shown as ··).

Classic 5-stage in-order pipeline: register file written in the first half of WB and read in the second half of ID. A teaching model, not any specific processor.

Common misconceptions

  • Misconception: Pipelining does not make one instruction faster; it improves throughput.
  • Misconception: The speed-up is never quite k because of filling, draining and hazards.