4.1.18 · D1Computer Architecture (Deep)

Foundations — Pipelining — 5-stage pipeline, each stage

2,080 words9 min readBack to topic

This page is the ground floor for the pipelining topic. Before we can talk about speedup, stages, and clocks, we have to earn every symbol the parent note quietly used. We go one brick at a time — nothing appears before it is drawn and named.


0. The picture we keep coming back to

Everything below is a variation on one image: a row of workers, each doing one small task, passing work along. Hold this in your head.

Figure — Pipelining — 5-stage pipeline, each stage

1. Instruction — the "job"

The picture: one tray of laundry, one sandwich, one car body moving down the line. In this topic an instruction is the unit of work that flows through the pipeline.

Why the topic needs it: pipelining is about overlapping the steps of consecutive instructions. If you don't have a clear notion of "one job", you can't talk about overlapping many jobs.


2. Stage — one step of the job

The picture: one workstation in the assembly line — the washer, or the "add cheese" friend. Each station does only its one job, then passes the work on.

Why the topic needs it: the whole trick is that different stages use different hardware, so they can all run at the same time on different instructions. No stages → nothing to overlap.


3. The letter — how many stages

The picture: count the workstations in the row. Five stations → .

Why a letter and not just "5"? Because we want formulas that work for any pipeline — a 3-stage one, a 14-stage one. Writing lets one formula describe them all. The moment we plug in a real machine, we replace with a number.


4. The letter — how long one stage takes

The picture: the length of one tick of a metronome. Every station finishes its piece in one , then everything shifts right together.

Why the topic needs : every timing formula — sequential time, pipelined time, speedup — is measured in units of . It's the ruler we measure everything with.


5. The letter — how many instructions

The picture: the number of trays waiting to enter the line. Four trays → .

Why the topic needs it: pipelining barely helps for tiny but almost triples/quadruples throughput for huge . To see when pipelining wins, we must keep as an adjustable knob.


6. Reading the space-time diagram (fill and drain)

Now that we have jobs, stages, , , and , we can read the diagram that is the derivation of speedup. Time runs left→right in units of .

Figure — Pipelining — 5-stage pipeline, each stage

This picture is where comes from — count the columns: columns to push the first instruction out, then one extra column for each of the remaining instructions.


7. The fraction bar — what "speedup" means

The picture: two stopwatches side by side. If the slow one reads 20 seconds and the fast one reads 5, then → "four times faster".

Why a division? Dividing the old time by the new time cancels the units (the 's and the seconds), leaving a pure "times faster" number that means the same on any machine.


8. The arrow and "limit" — what happens for huge

The picture: the drain and fill triangles in the space-time diagram stay the same tiny size, but the steady-state middle stretches out forever. The two little triangles become a rounding error.

Why we care: it tells us the best possible speedup. In the fraction , when is gigantic the "" is negligible next to , so the fraction settles at .

Let's see the fraction climb toward this ceiling as grows.

Figure — Pipelining — 5-stage pipeline, each stage

9. Throughput vs Latency — two different questions

The picture: latency is how long a single car spends on the assembly line; throughput is how many cars roll off the end per hour. A pipeline improves the second without shortening the first.


10. Pipeline register — the tray between stations

The picture: the little tray each sandwich-friend drops the half-made sandwich onto before the next friend picks it up. Without the tray, the next sandwich would smear over the last one.

Why the topic needs it: stages share buses. Stage 2 needs what stage 1 produced, but stage 1 is already producing something new next cycle. The register freezes the value in transit. There are four of them, named for the stages they bridge: IF/ID, ID/EX, EX/MEM, MEM/WB.


The prerequisite map

Instruction = one job

Stage = one step

k = number of stages

t = time per stage

n = number of instructions

T seq = n k t

T pipe = k plus n minus 1 times t

Speedup S = T seq over T pipe

Limit as n grows gives max speedup k

Pipeline register holds state

Throughput vs Latency

Pipelining topic


Equipment checklist

Cover the right side and test yourself before moving on.

An instruction is...
one small command the CPU obeys (add, load, jump); the "job" that flows through the pipe.
A stage is...
one step of processing, done by its own dedicated hardware (IF, ID, EX, MEM, WB).
The symbol means...
the number of stages in the pipeline (5 in the classic RISC pipeline).
The symbol means...
the time one stage takes; the ruler all timings are measured in.
The symbol means...
the number of instructions being pushed through.
because...
one lone instruction must visit all stages, each costing .
because...
without overlap, all jobs run one after another, each taking .
because...
cycles to fill/push the first instruction out, then one extra cycle for each of the remaining .
Speedup is...
the ratio , a pure "times faster" number.
The cancels in because...
it appears on top and bottom of the fraction; a value over itself is 1.
means...
imagine an endless stream of instructions; used to find the best-possible speedup.
Maximum speedup is...
— one factor per stage, reached as grows huge.
Latency vs throughput...
latency = time for one job (unchanged, cycles); throughput = jobs finished per unit time (improved to ).
A pipeline register is...
a latch between two stages holding a job's in-transit state so the next job doesn't overwrite it.

Connections