Pipelining Fundamentals
Day 1 of 5 — the questions every interview opens with
Before an interviewer lets you anywhere near hazards or forwarding, they'll check you actually understand why pipelining exists. These are the six questions that come up almost every time.
In This Post
- Q1. What is pipelining, and why does it improve performance?
- Q2. Why 5 stages specifically? Why not 3, or 10?
- Q3. What is a pipeline register, and why is it needed?
- Q4. What is pipeline throughput vs. latency?
- Q5. What is a hazard, and what are the three types?
- Q6. Does a typical RV32I 5-stage design have structural hazards? Why or why not?
Q1What is pipelining, and why does it improve performance?
Pipelining splits instruction execution into smaller sequential stages so multiple instructions can be in different stages of execution at the same time — like an assembly line. It doesn't make any single instruction faster; it increases throughput (instructions completed per cycle), because once the pipeline is full, one instruction retires every clock cycle instead of every 5.
Q2Why 5 stages specifically? Why not 3, or 10?
5 stages is the classic RISC design point: IF, ID, EX, MEM, WB each map cleanly onto one datapath action (fetch, decode + register read, ALU, memory, writeback). Fewer stages means longer, slower cycles; more stages (20+, like some x86 CPUs) increase clock speed but make hazards and branch mispredictions far more expensive.
Q3What is a pipeline register, and why is it needed?
It's a bank of flip-flops between two stages that latches every signal the next stage needs, once per cycle. Without it, stage boundaries would be purely combinational and the whole pipeline would collapse into a single-cycle design. In a 5-stage RV32I pipeline these are IF/ID, ID/EX, EX/MEM, and MEM/WB.
Q4What is pipeline throughput vs. latency?
Latency is how long one instruction takes start to finish (still 5 cycles). Throughput is how many instructions complete per unit time (ideally 1 per cycle once the pipeline is full). Pipelining improves throughput, not latency — a single isolated instruction running alone is not any faster.
Q5What is a hazard, and what are the three types?
A hazard is any situation where the next instruction can't execute in its designated cycle without producing a wrong result. The three types: structural (two instructions need the same hardware resource at once), data (an instruction needs a result that hasn't been produced yet), and control (the next fetch depends on a branch/jump outcome that isn't known yet).
Q6Does a typical RV32I 5-stage design have structural hazards? Why or why not?
Usually no — separate instruction and data memories avoid the classic "fetch vs. memory access in the same cycle" conflict, and each stage has its own dedicated register-file port pairing, so no stage ever contends for a resource another stage needs at the same time.
Quick Recap
- Pipelining boosts throughput, not the speed of any one instruction
- 5 stages = the standard RISC teaching/architecture balance point
- Pipeline registers are what physically make the overlap possible
- Structural, data, and control are the three hazard categories — know them cold
RISC-V Interview Q&A — 5-Day Series
- Day 1
Fundamentals - Day 2
Data Hazards - Day 3
Control Hazards - Day 4
Decode & Verify - Day 5
Trade-offs
Note: links for days not yet published will go live as each post is released —
swap the href="#" placeholders for the real post URLs once published.

Comments
Post a Comment