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
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
  • Advanced RTL28
  • Senior & Interview76
    • Low-Power RTL Hub
    • DFT and Scan Hub
    • Physical Awareness Hub
    • Waveform Debug Hub
    • STA and ECO Hub
    • RTL-to-Implementation Closure
    • DFT-Ready RTL
    • Capstone: Resilient Streaming Peripheral
    • Principal Design Review
    • Senior RTL Interview Questions & Model Answers
      • Interview: Combinational and Arithmetic
      • Interview: Sequential and Pipelines
        • Blocking vs non-blocking: the race demo
        • Pipeline latency vs throughput
        • Stalling without deadlock
        • Enables, resets and counters
      • Interview: FSM and Control
      • Interview: Timing and STA
      • Interview: CDC and Reset
      • Interview: Memories and Buses
      • Interview: Low-Power Design
      • Interview: Debug and ECO
      • Interview: Coding and Whiteboard
  • Glossary and Notation
Loading lesson

‹Interview: Sequential and Pipelines
  1. Topics
  2. RTL Design
  3. Senior & Interview
  4. Senior RTL Interview Questions & Model Answers
  5. Interview: Sequential and Pipelines
  6. Stalling without deadlock

Part 9 · Senior · Senior

Stalling without deadlock

A valid and ready stage that absorbs backpressure without loss, duplication, or deadlock.

On this page

    Why this matters

    When the consumer drops ready for five cycles, the stage must hold its item, not overwrite it, and still resume alone. Tying ready high to keep the numbers up loses data under real backpressure.

    After this lesson you can: draw a one-deep stage with in_ready = !full || out_ready, and argue why it holds every item and cannot deadlock.

    The question

    The interviewer slows the consumer mid-stream: downstream deasserts ready for several cycles. The design must hold every item, deliver each exactly once, and resume on its own.

    What is really under test is the valid/ready contract under backpressure. The candidate must show where the item waits, what ready means while it waits, and why the pipe cannot wedge.

    Model answer

    A stalled item waits in its stage register: valid stays high, data holds, and ready is low, so no transfer occurs. A bubble is different: valid is low because the slot is empty. Backpressure can fill earlier empty slots; it must not turn an unaccepted valid item into a bubble.

    The acceptance rule is in_ready = !full || out_ready. An empty stage always accepts. A full stage accepts only while the consumer takes the held item in the same cycle, so nothing is ever overwritten.

    Signal

    Role

    Rule during a stall

    valid

    This cycle carries an item

    Stays high with stable data until the handshake.

    ready

    The receiver can take it

    Falls while full and blocked; never drops an item.

    Data

    The item itself

    Held unchanged until valid && ready in the same cycle.

    Deadlock freedom follows from two facts. The stage accepts whenever it is empty, independent of downstream, and it empties whenever downstream is ready, independent of upstream.

    A source must never wait for ready before asserting valid. If the peer's ready also waits for valid, the handshake deadlocks (or forms a combinational loop).

    Each slot shows the handshake just after a clock edge. A transfer happens only on an edge where valid and ready are both high.

    • Slots 2 to 6: out_ready stays low for five cycles. The held data stays flat, in_ready stays low, and valid never drops.

    • Slot 7: ready returns, so the held item leaves while the waiting item is captured in the same cycle. Two items move at once.

    • Progress: the stage accepts whenever it is empty and empties whenever downstream is ready, so the link resumes on its own once ready returns.

    Follow-ups

    May ready depend on valid? Within one stage, ready routinely reflects state that valid also affects. The forbidden direction is valid gated combinationally by ready, which stalls the very signal needed to advance.

    Does this stage scale to a long chain? It passes ready through combinationally, so in a chain of N stages ready ripples through N gates in one cycle. Long chains need a registered-ready skid buffer (two entries) to cut that path.

    How does a stall differ from a flush? A stall holds items in place and resumes the same stream. A flush discards in-flight items and restarts, which needs an explicit kill and re-issue policy.

    What if the consumer never asserts ready again? The pipe fills and parks with all valids high. That is correct backpressure, not a logic deadlock; recovery belongs to a timeout or watchdog above the link.

    Common wrong answers

    A weaker candidate drops the item and relies on a retry. Links without retry buffers lose data permanently, and the re-ask logic costs more than the holding register.

    Another gates the clock to freeze the pipe. Gated clocks complicate timing closure and scan, and they freeze neighbours that should keep running; a register hold via ready is the standard answer.

    A third ties ready high to keep the numbers up. Under real backpressure the held item is overwritten, which the scoreboard below would catch as a skipped sequence number.

    Common pitfall

    Overwriting a full stage is silent in waveforms that only watch data. Watch the handshake pair: every accepted item (valid and ready together) must later emerge as exactly one delivered item.

    Interview

    Draw the one-deep stage: full flag plus data, in_ready = !full || out_ready, and valid never gated by ready. Then state the progress argument.

    Check yourself The stage is full, downstream ready is low, and upstream valid is high. What are in_ready and the held data on the next edge?

    in_ready is low and the data is unchanged. The item waits; the producer holds its outputs for another cycle.

    Check yourself Downstream ready returns high with the stage full and upstream valid high. How many items move in that cycle?

    Two: the held item leaves while the new item is captured. The rule accepts exactly because the consumer takes in the same cycle.

    Solution and testbench

    The finite bench pushes sixteen items through a five-cycle stall, checks sampled valid/data stability through the accepting edge, accounts accepted = delivered + cancelled + pending (cancelled is zero here), and drains for eight cycles rejecting extra deliveries. Progress assumes the scripted consumer eventually restores ready. A watchdog cannot cancel or reclaim an accepted item; timeout recovery needs an owner and explicit cancellation/replay protocol.

    stall_stage.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    module stall_stage #(parameter int W = 8) (
      input  logic         clk, rst_n,
      input  logic         in_valid,
      input  logic [W-1:0] in_data,
      output logic         in_ready,
      output logic         out_valid,
      output logic [W-1:0] out_data,
      input  logic         out_ready
    );
      logic         full;
      logic [W-1:0] held;
      assign out_valid = full;
      assign out_data  = held;
      assign in_ready  = !full || out_ready;        // empty always accepts; full only on pass-through
      always_ff @(posedge clk or negedge rst_n)
        if (!rst_n) begin full <= 1'b0; held <= '0; end
        else if (in_valid && in_ready) begin held <= in_data; full <= 1'b1; end
        else if (out_valid && out_ready) full <= 1'b0;
    endmodule
    

    Remember

    • A stalled item keeps valid high and its data flat; a bubble is an empty slot with valid low.

    • The stage accepts whenever it is empty and empties whenever downstream is ready.

    • Valid must never wait for ready, and a long chain needs a registered-ready skid buffer.

    Rule of thumb: every accepted item must leave as exactly one delivered item.

    Keep going

    • Practice: Three-stage pipeline with stall, bubble and flush control

    • Code lab: Pipeline stall logic

    • Interview: run a mock interview on this topic

    Related topics

    • Valid/ready flow control

    • Structural hazard and stall logic

    Previous

    319 / 350

    Next: Enables, resets and counters

    Up next

    Up nextEnables, resets and counters

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Blocking vs non-blocking: the race demo
    clkin_validin_readyout_validout_readyout_data1234
    A valid-ready stage through a five-cycle stall: the held item waits unchanged, then leaves as the next item is captured