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

  • RTL Foundations36
  • Combinational Design25
  • Sequential Design27
    • Flip-Flops and Registers
    • Counters and Timers
    • Shift Registers and LFSRs
    • Pipelining
      • Throughput and Latency
      • A Three-Stage Arithmetic Pipeline
      • Valid/Ready Flow Control
      • Pipelined MAC
      • Precision Verification
    • Stalls, Bubbles and Hazards
    • Retiming
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
  • Advanced RTL28
  • Senior & Interview76
  • Glossary and Notation
Loading lesson

‹Pipelining
  1. Topics
  2. RTL Design
  3. Sequential Design
  4. Pipelining
  5. Valid/Ready Flow Control

Part 3 · Sequential · Intermediate

Valid/Ready Flow Control

Valid/ready flow control that stalls a pipeline without losing, duplicating, or reordering data.

On this page

    Why this matters

    When a consumer stalls, a pipeline stage that keeps accepting drops or duplicates an item. Valid and ready decide exactly which clock edge moves data, and the rules around them keep it lossless.

    After this lesson you can: state the four valid/ready rules, build a stage that holds data through a stall, and explain what its combinational ready path costs.

    When the consumer stalls

    A plain pipeline assumes the output is always ready. When a downstream block can stall, waiting data must not be overwritten.

    • valid from the sender: the data on this link is real.

    • ready from the receiver: it can accept data this cycle.

    • A transfer happens on a clock edge where both are high.

    Rule

    Why

    Once valid is asserted, it stays asserted until the transfer completes

    Otherwise the receiver may see an offer that vanishes.

    Data and control stay stable while valid && !ready

    The receiver must be able to take the same item later.

    The sender must not wait for ready before asserting valid

    Two blocks each waiting for the other would deadlock.

    ready may depend on valid, but not the reverse

    Avoids combinational loops.

    One stage rides through a two-cycle stall: a1 waits while a2 is held, then each item moves on.

    • Cycle 0: a1 is accepted; the stage starts empty.

    • Cycle 1: the consumer stalls, so a1 waits and in_ready falls; a2 is offered and held stable.

    • Cycle 2: the stall continues; a2 stays stable.

    • Cycle 3: ready returns; a1 leaves and a2 enters in the same cycle.

    • Cycle 4: a2 leaves and a3 enters in the same cycle.

    • Cycle 5: a3 leaves; the source is quiet, so nothing enters.

    • Cycle 6: the stage is empty and valid is low.

    • Cycles 7–8: idle.

    How the stage works

    • in_ready = !out_valid || out_ready: a new item enters when the stage is empty or its item leaves this cycle.

    • Emptying while accepting keeps one item per cycle with no bubbles.

    • out_valid follows in_valid whenever the stage is ready, so it also clears with nothing to offer.

    • The data register changes only on a real transfer, so it holds steady through a stall.

    Warning

    in_ready depends combinationally on out_ready. Through a chain of stages, a stall at the end ripples back combinationally through every stage: a long path that limits the clock. Break it by inserting a register slice (skid buffer) every few stages; see the handshake-aware retiming lesson.

    Common mistakes

    Common pitfall

    Never drop an item because ready was low, and never generate a second copy because the consumer stalled. The scoreboard below checks both: every accepted item must come out once, in order.

    Interview

    Be ready to draw this waveform, state the four rules, and explain why a stage may combine ready with the next stage's ready (and what that costs in timing).

    Check yourself In the waveform, a2 is offered in cycles 1 and 2 but only transferred in cycle 3. What guarantees the receiver sees the same data each time?

    The protocol rule that data and valid stay stable while valid && !ready, plus the stage's data register that changes only on a transfer. The sender keeps driving a2 until ready arrives.

    Testbench

    Three stages in a chain under random stalls, scored for loss, duplication, or reorder. Stability monitors check all four links. A directed shutdown fills the pipeline, stops the source while an offer is blocked, checks that the offer remains stable, then drains with the sink continuously ready.

    pipe_stage.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    module pipe_stage #(parameter int W = 8) (
      input  logic         clk, rst_n,
      input  logic         in_valid,  output logic in_ready,  input  logic [W-1:0] in_data,
      output logic         out_valid, input  logic out_ready, output logic [W-1:0] out_data
    );
      // Accept a new item whenever the stage is empty OR is being emptied this very cycle.
      assign in_ready = !out_valid || out_ready;
    
      always_ff @(posedge clk or negedge rst_n)
        if (!rst_n)          out_valid <= 1'b0;
        else if (in_ready)   out_valid <= in_valid;        // take the offer, or become empty
    
      always_ff @(posedge clk)
        if (in_ready && in_valid) out_data <= in_data;     // capture data only on a real transfer
    endmodule
    

    Remember

    • A transfer happens on an edge where both valid and ready are high.

    • Once valid is asserted it stays asserted, with data stable, until the transfer.

    • in_ready = !out_valid || out_ready keeps one item per cycle, but a stall ripples back combinationally through a chain.

    Rule of thumb: never drop an item because ready was low, and never copy it because the consumer stalled.

    Keep going

    • Practice: Two-stage valid/ready pipeline: throughput, latency and backpressure

    • Interview: run a mock interview on this topic

    Related topics

    • Valid/ready buses

    • Stalls and bubbles

    Previous

    78 / 350

    Next: Pipelined MAC

    Up next

    Up nextPipelined MAC

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Throughput and Latency
    • Precision Verification
    One pipeline stage with the consumer stalling for two cycles (values in hex)clkin_validin_dataa1a2a3in_readyout_validout_dataxa1a2a3out_ready
    a1 is accepted in cycle 0. The consumer then stalls (out_ready = 0), so the stage is full and in_ready drops: a2 is offered but not accepted, and stays stable. When out_ready returns, a1 leaves and a2 enters in the same cycle.