Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • Architecture Metrics Reference
  • Workload Taxonomy for Architects
  • Architecture Glossary
  • Computer Architecture Cheatsheet
  • Pipeline Fundamentals14
    • Pipeline Throughput
      • The Five-Stage Datapath
      • Stage Depth and Clock Period
      • CPI and Speedup Arithmetic
      • Hazard Classes: Structural, Data and Control
      • Forwarding and Stalls
    • Branch Prediction and Fetch
    • Out-of-Order Superscalar Execution
  • Memory Hierarchy15
  • NoC and Interconnect Architecture6
  • Coherency and Memory Ordering9
  • Performance Analysis9
  • Accelerator Architectures6
  • SoC Architecture Tradeoffs9
  • Architecture Interview Prep14
Loading lesson

‹Pipeline Throughput
  1. Topics
  2. Computer Architecture
  3. Pipeline Fundamentals
  4. Pipeline Throughput
  5. Forwarding and Stalls

Computer Architecture · All levels

Forwarding and Stalls

Forwarding paths that remove ALU stalls, the load-use bubble that stays, and the stall rules.

On this page

    What forwarding fixes

    Without forwarding, a consumer waits until the producer writes the register file. That costs three bubbles per ALU pair in a five-stage pipe.

    Forwarding routes the EX/MEM and MEM/WB results back to the ALU inputs. An ALU chain then runs with zero bubbles.

    Consumer needs rs

    EX/MEM (younger)

    MEM/WB (older)

    Select

    No producer matches

    No match

    No match

    Register file

    ALU result ready

    rd matches, write set

    Do not care

    EX/MEM

    Older result only

    No match

    rd matches, write set

    MEM/WB

    Both match

    rd matches, write set

    rd matches, write set

    EX/MEM, younger wins

    Match on x0 or write clear

    Ignored

    Ignored

    Register file

    Youngest producer wins

    Both bypass sources can match at once when two producers target the same register. The younger EX/MEM value is the correct one, so it takes priority.

    A match on register zero never forwards. Register zero reads zero by definition, and a cleared write enable means the producer wrote nothing.

    The load-use bubble stays

    A load value is ready only at the end of MEM, one cycle after the next instruction starts EX. No bypass fixes that, so the hazard unit freezes the PC and injects one bubble.

    Diagram
    Assume 25% of instructions are ALU consumers after an ALU producer, and 8% are load-use pairs
    no forwarding:  0.25 x 3 + 0.08 x 3 = 0.75 + 0.24 = 0.99 stalls per instruction
    with forwarding: 0.25 x 0 + 0.08 x 1 = 0.08 stalls per instruction
    saved by forwarding: 0.99 - 0.08 = 0.91 stalls per instruction

    The hazard rule is simple: stall on load-use, bypass otherwise. The next-lesson detail is the detector truth table, which this lesson states in words.

    Common pitfall

    Forwarding adds mux levels on the EX inputs, which can lengthen the critical path and force a lower frequency. A bypass that saves bubbles but costs clock rate can lose overall, so check the speedup ratio again.

    Interview

    Likely probe: why an aggressive forwarding network can still hurt. Extra mux depth and control complexity can force a lower frequency or an added stage that erases the bubble savings.

    Check yourself An ADD feeds the next ADD with full forwarding. How many bubbles?

    Zero. The EX/MEM bypass delivers the result in time for the next EX.

    Check yourself A LW feeds the next ADD with full forwarding. How many bubbles, and why?

    One. The loaded word is ready only at the end of MEM, so the consumer EX waits one cycle.

    Testbench

    A forwarding-select unit with youngest-wins priority, plus a testbench that checks 8 directed producer-consumer cases.

    fwd_sel.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    module fwd_sel (
      input  logic [4:0] rs,
      input  logic [4:0] rd_ex,
      input  logic       regwrite_ex,
      input  logic [4:0] rd_mem,
      input  logic       regwrite_mem,
      output logic [1:0] fwd
    );
      always_comb begin
        fwd = 2'd0;
        if (regwrite_mem && (rd_mem != 5'd0) && (rd_mem == rs))
          fwd = 2'd1;
        if (regwrite_ex && (rd_ex != 5'd0) && (rd_ex == rs))
          fwd = 2'd2;
      end
    endmodule
    

    Related topics

    • Stalls and bubbles

    • Retiming

    • Out-of-order and superscalar

    Previous

    9 / 86

    Next: Branch Prediction and Fetch

    Up next

    Up nextBranch Prediction and Fetch

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • The Five-Stage Datapath
    • Stage Depth and Clock Period
    • CPI and Speedup Arithmetic