5-Stage CPU Pipeline: Hazards & Forwarding (2D)
Watch instructions flow through a classic 5-stage RISC pipeline (IF/ID/EX/MEM/WB) on a live 2D cycle diagram. Toggle data forwarding on/off and see stall bubbles and forwarding arrows appear when a load-use hazard or register dependency can't be resolved in time.
This simulator renders the classic 5-stage RISC instruction pipeline (Fetch, Decode, Execute, Memory, Write-Back) as a live 2D pipeline diagram: rows are instructions in program order, columns are clock cycles, and each cell shows which stage that instruction occupied that cycle. A randomly generated instruction stream — a mix of ALU operations, loads and stores, seeded with deliberate register dependencies — is decoded, hazard-checked and retired one cycle at a time, exactly as a real in-order core would. Toggle data forwarding to see the pipeline's hazard-detection logic in action: with forwarding off, any true register dependency stalls the pipeline (repeated ID cells, then a grey bubble cell) until the producing instruction reaches write-back; with forwarding on, an animated blue arrow bypasses the EX/MEM result straight into the dependent instruction's EX stage and most stalls vanish, except the one-cycle bubble a load-use hazard always costs. Live readouts track cycle count, retired instructions, injected stall bubbles, forwarding events, and separately-accumulated CPI for forwarding on vs. off so the performance difference is directly measurable.
Control data forwarding and watch stall bubbles appear as register dependencies cause hazards in a 5-stage CPU pipeline.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install