5.2.4Processor Datapath & Pipelining

Pipeline registers and control signals

1,961 words9 min readdifficulty · medium2 backlinks

WHY do pipeline registers even exist?

WHAT they are: edge-triggered registers placed between the 5 classic stages. Named after the two stages they sit between:

Register Between stages Carries (data)
IF/ID Fetch → Decode instruction word, PC+4
ID/EX Decode → Execute reg values, sign-ext imm, PC+4, dest reg #
EX/MEM Execute → Memory ALU result, branch target, store data, dest reg #
MEM/WB Memory → Write-back memory data, ALU result, dest reg #

Note: there is no register after WB — the result is written into the register file, which is the storage.

Figure — Pipeline registers and control signals

WHY do control signals ride inside the registers?


HOW a signal moves: the life of RegWrite


Steel-manned mistakes


Recall Feynman: explain to a 12-year-old

Imagine a sandwich shop with 5 workers in a line: one gets the bread, one adds cheese, one grills, one wraps, one hands it over. Between each worker there's a little tray. When a worker finishes, they put the half-made sandwich and a sticky note saying what to do next on the tray. The next worker grabs the tray, reads the note, and does their job. The trays are the pipeline registers, and the sticky notes are the control signals. This way 5 sandwiches are being made at the same time, and nobody forgets what to do — because the instructions travel with the sandwich!


Flashcards

How many pipeline registers are in a classic 5-stage MIPS pipeline, and why not 5?
Four (IF/ID, ID/EX, EX/MEM, MEM/WB). No register after WB because WB writes into the register file, which is already stateful storage.
In which stage are ALL control signals generated?
In ID (Decode), because that's the only stage that sees the opcode.
Why must control signals travel inside pipeline registers?
Because signals like RegWrite are used stages later (WB), but can only be decoded from the opcode in ID; they must be transported forward.
Which three bundles are control signals grouped into?
EX bundle (ALUSrc, ALUOp, RegDst), MEM bundle (MemRead, MemWrite, Branch), WB bundle (RegWrite, MemtoReg).
Why does the destination register number ride through the pipeline registers?
Because the instruction word is gone by WB; without carrying the 5-bit dest #, WB would write to the wrong register.
What does ID/EX carry that EX/MEM no longer needs?
The EX control bundle (ALUSrc, ALUOp, RegDst) — it's consumed in EX and dropped afterward.
Which pipeline register carries the ALU result and store data?
EX/MEM.
Why is PC+4 carried past IF/ID?
Because the branch target (PC+4 + imm<<2) is computed later in EX, so PC+4 must survive to that stage.
What happens to a control bundle after its stage consumes it?
It is dropped and not latched into the next pipeline register (each register is narrower for control than the one before).

Connections

  • Single-cycle datapath — the starting point before we insert registers
  • Pipeline hazards — data/control hazards arise because signals and results are staggered across these registers
  • Forwarding and stalling — reads values directly out of EX/MEM and MEM/WB registers
  • Control unit design — the source that generates all bundles in ID
  • Clocking and edge-triggered flip-flops — the mechanism that lets registers latch cleanly

Concept Map

wants parallelism

combinational logic collides

solved by

edge-triggered latch

IF/ID

ID/EX

EX/MEM

MEM/WB

generates once

ride inside registers

split into 3 bundles

each stage drops consumed bundle

Single-cycle datapath

5 instructions in flight

No memory between stages

Pipeline registers

Freeze stage output each cycle

Instruction word, PC+4

Reg values, imm, dest reg

ALU result, branch target, store data

Memory data, ALU result

Control unit in Decode

Control signals

EX, MEM, WB bundles

Signal used then discarded

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, pipeline ek assembly line jaisa hai — 5 workers (IF, ID, EX, MEM, WB) ek line mein kaam kar rahe hain. Har do workers ke beech ek pipeline register (tray) hota hai. Jab ek stage apna kaam khatam karta hai, wo apna result us tray mein rakh deta hai, aur agla stage clock edge par use utha leta hai. Isliye ek saath 5 instructions "in flight" reh sakti hain bina aapas mein takraaye.

Ab sabse important baat: control signals (jaise RegWrite, MemRead, ALUOp) sirf ID stage mein bante hain, kyunki opcode wahi visible hota hai. Lekin kuch signals baad mein chahiye hote hain — jaise RegWrite to WB stage mein 3 cycle baad use hota hai. To hum saare signals ID mein bana ke unhe pipeline register mein daal dete hain, aur wo instruction ke saath-saath travel karte hain. Har stage jo signal use kar leta hai, use aage nahi bhejta — isko "bundle drop karna" bolte hain (EX, MEM, WB bundles).

Ek badi galti jo students karte hain: wo sochte hain ki har stage apne signals khud bana leta hai. Nahi bhai! Sirf ID banata hai, baaki stages sirf latched signals padhte hain. Doosri galti — destination register number (jaise $s0 ka number) ko bhi carry karna zaroori hai, warna WB galat register mein likh dega, kyunki tab tak instruction word gayab ho chuka hota hai.

Yaad rakho: 4 hi registers hote hain (WB ke baad koi nahi, kyunki register file khud storage hai). Jab tumhe hazards aur forwarding padhna ho, tab yahi EX/MEM aur MEM/WB registers se hi values directly forward hoti hain — isliye yeh concept ki neev hai.

Go deeper — visual, from zero

Test yourself — Processor Datapath & Pipelining

Connections