Data Forwarding (Bypassing)
What You'll Learn
You'll learn how modern pipelined processors avoid waiting for data by sending computed results directly where they're needed, bypassing the usual writeback delay.
The Problem It Solves
Imagine you're cooking in an assembly line: one station chops vegetables, the next cooks them, and the final one plates the dish. What if the cooking station needs the chopped vegetables right now, but the chopping station is about to hand them over to a storage shelf first? Why waste time storing and retrieving when you can just pass them directly?
In a pipelined CPU, when one instruction computes a value in the Execute stage, a following instruction might need that value as input. Normally, the first instruction must complete the Write-Back stage (writing to the register file) before the second can read it during Decode. This creates a Read-After-Write (RAW) hazard that forces pipeline stalls.
How Data Forwarding Works
Data forwarding (also called bypassing) detects when a later instruction needs a value that an earlier instruction just computed but hasn't yet written back. Instead of stalling the pipeline, special hardware routes the result directly from the Execute stage (or Memory stage) back to the Execute stage of the dependent instruction.
Think of it as a shortcut hallway between two rooms instead of walking through the main corridor.
The forwarding unit monitors which registers instructions read and write, then adds multiplexers to the ALU inputs that can select freshly-computed values from pipeline registers instead of only from the register file.
Key Takeaway:
Data forwarding eliminates many pipeline stalls by routing computed results directly to dependent instructions, bypassing the register file and dramatically improving pipeline efficiency.