wire / wire-format / cpu-pipeline
The classic 5-stage RISC pipeline: IF (Instruction Fetch), ID (Instruction Decode + Register Read), EX (Execute/ALU), MEM (Memory Access), WB (Write Back). Each stage takes one clock cycle. Hazards: structural (resource conflict), data (RAW/WAR/WAW dependencies), control (branch). Solutions: forwarding/bypassing, stalling, branch prediction, out-of-order execution.
aka: CPU pipeline stages (classic 5-stage)
spec: Computer architecture
The classic 5-stage RISC pipeline: IF (Instruction Fetch), ID (Instruction Decode + Register Read), EX (Execute/ALU), MEM (Memory Access), WB (Write Back). Each stage takes one clock cycle. Hazards: structural (resource conflict), data (RAW/WAR/WAW dependencies), control (branch). Solutions: forwarding/bypassing, stalling, branch prediction, out-of-order execution.
| field | size | meaning |
|---|---|---|
| IF (Instruction Fetch) | stage 1 | Fetch instruction from memory (I-cache). Compute next PC (PC+4 or branch target). |
| ID (Instruction Decode) | stage 2 | Decode instruction. Read source registers from register file. Sign-extend immediate. |
| EX (Execute) | stage 3 | ALU operation. Compute branch target. Evaluate branch condition. |
| MEM (Memory Access) | stage 4 | Load/store to data cache. (NOP for non-memory instructions.) |
| WB (Write Back) | stage 5 | Write result to register file. (NOP for stores and branches.) |
| RAW hazard | data hazard | Read After Write: instruction needs a result that hasn't been written yet. Solved by forwarding or stalling. |
| WAR hazard | data hazard | Write After Read: less common in in-order pipelines. Solved by register renaming in OoO. |
| WAW hazard | data hazard | Write After Write: two instructions write the same register. Solved by register renaming in OoO. |
| Control hazard | control hazard | Branch outcome unknown until EX stage. Solved by branch prediction and flushing on misprediction. |
| Structural hazard | resource hazard | Two instructions need the same resource (e.g., single-ported memory). Solved by duplicating resources or stalling. |
example:
00 00 00 00
CPU pipeline stages (placeholder)
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/cpu-pipeline
or /wire-format/cpu-pipeline.json