Study smarter with Fiveable
Get study guides, practice questions, and cheatsheets for all your subjects. Join 500,000+ students with a 96% pass rate.
Understanding CPU pipeline stages is fundamental to grasping how modern processors achieve high performance. You're being tested on concepts like instruction-level parallelism, pipeline hazards, throughput vs. latency tradeoffs, and the fetch-decode-execute cycle. These stages don't exist in isolation. They work together to allow multiple instructions to be "in flight" simultaneously, which is why a 5-stage pipeline can theoretically improve throughput by up to 5x compared to single-cycle execution.
When exam questions ask about pipeline stalls, data hazards, or control hazards, they're really testing whether you understand what each stage does and what resources it needs. Don't just memorize the stage names. Know what hardware components are active at each stage, what data flows between stages, and what happens when dependencies force the pipeline to wait. That conceptual understanding will help you tackle scenarios involving hazard detection, forwarding, and branch prediction.
These first two stages focus on getting the instruction ready for execution: fetching it from memory and figuring out what it actually means. Both stages interact heavily with memory and control logic before any real computation happens.
Compare: IF vs. ID. Both happen before any computation, but IF interacts with instruction memory while ID interacts with the register file. If a question asks where a data hazard is detected, ID is your answer, since that's where register values are read and the dependency becomes visible.
These middle stages perform the actual work: calculating results and accessing data memory. This is where the ALU does its job and where load/store instructions interact with the memory hierarchy.
Compare: EX vs. MEM. EX uses the ALU for computation, while MEM uses data memory for storage access. R-type instructions only need EX; load/store instructions need both. This distinction matters for understanding which hazards affect which instruction types. A load-use hazard is particularly nasty because the data isn't available until the end of MEM, one stage later than an R-type result would be.
The final stage ensures computed results become visible to future instructions. Without this stage, no instruction would ever produce a lasting change to the register file.
Compare: MEM vs. WB. Both can provide a "final result," but MEM provides data read from memory (loads) while WB writes any result into the register file. Understanding this split is essential for implementing data forwarding paths, because you need to know when each type of result is actually available.
| Concept | Details |
|---|---|
| Memory interaction | IF (instruction memory), MEM (data memory) |
| Register file access | ID (read), WB (write) |
| ALU usage | EX stage exclusively |
| Control signal generation | ID stage |
| Address calculation | EX (for branches and memory operations) |
| Pipeline register boundaries | IF/ID, ID/EX, EX/MEM, MEM/WB |
| Stages skipped by some instructions | MEM (by R-type), WB (by stores) |
Which two stages interact with memory, and what type of memory does each access?
If a load instruction is followed immediately by an add instruction that uses the loaded value, at which stage is the data hazard detected, and why can't forwarding alone fix it without a one-cycle stall?
Compare what happens during the EX stage for an R-type arithmetic instruction versus a load word () instruction. What's different about the ALU inputs and what the ALU result represents?
A store instruction () uses the MEM stage but not the WB stage. Explain why this makes sense given what each stage does.
If you were implementing data forwarding to reduce stalls, which stage boundaries would need forwarding paths, and what values would be forwarded? Think about where results first become available (end of EX, end of MEM) and where they're needed (start of EX).