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

AboutRoadmapCareersInternshipsFAQContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • Study Route: One Week Before the Interview
  • Study Route: Two Weeks
  • Study Route: Four Weeks (Full Course)4
  • OOP & Testbench Puzzles25
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • UVM Testbench Puzzles25
  • Clock, Reset & CDC Puzzles25
  • Bus and Interface Protocol Puzzles25
    • Valid/Ready Handshake Puzzles
      • Counting Transfers in a Valid/Ready Trace
      • Which Cycle Drops VALID Illegally?
      • Payload Changes While Stalled
      • Both Sides Wait: The Handshake Deadlock
      • Registered READY Overflows a FIFO
      • Register Slice: 50% Throughput Without Data Errors
    • APB Protocol Puzzles
    • AXI Protocol Puzzles
    • FIFO, Arbitration and Credit Puzzles
    • Bus and Interface Protocol Puzzles: Tricky Q&A
  • Interview Prep: Puzzle Rounds7
  • DV Puzzle Cheatsheet
Loading lesson

←Valid/Ready Handshake Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. Bus and Interface Protocol Puzzles
  4. Valid/Ready Handshake Puzzles
  5. Both Sides Wait: The Handshake Deadlock
On this page

    VLSI DV Interview PuzzlesAll levels

    Both Sides Wait: The Handshake Deadlock

    A source has 4 beats to send. The sink raises READY only after it has seen VALID. In design 'bad' the source raises VALID only after it has seen READY; in design 'good' the source drives VALID whenever it has data. After 12 cycles from reset, how many beats does each design transfer, and which rule of the protocol did 'bad' break?

    Puzzle

    Difficulty: Medium · Puzzle 4 of 6 · Topic: Valid/Ready Handshake Puzzles

    A source has 4 beats to send. The sink raises READY only after it has seen VALID. In design 'bad' the source raises VALID only after it has seen READY; in design 'good' the source drives VALID whenever it has data. After 12 cycles from reset, how many beats does each design transfer, and which rule of the protocol did 'bad' break?

    Code

    link.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    `timescale 1ns/1ns
    module link(input bit clk, input bit fix);
      bit valid = 0, ready = 0;
      int left = 4, xfers = 0;
      always @(posedge clk) begin
        if (valid && ready) begin xfers++; left--; end
        ready <= valid;                              // sink: raise ready only after it has seen valid
        valid <= (left > 0) && (fix || ready);       // source: fix=0 waits for ready first
      end
    endmodule
    
    module tb;
      bit clk = 0;
      always #5 clk = ~clk;
      link bad (.clk(clk), .fix(1'b0));
      link good(.clk(clk), .fix(1'b1));
      initial begin
        #(10*12);
        $display("source waits for ready : transfers in 12 cycles = %0d", bad.xfers);
        $display("source drives valid    : transfers in 12 cycles = %0d", good.xfers);
        $finish;
      end
    endmodule

    Hint

    Reset leaves both flags low. Who is allowed to go first?

    Step-by-step solution

    Diagram
    1) After reset valid=0 and ready=0.
    2) 'bad': the sink waits for valid=1, the source waits for ready=1. Neither condition can ever become true, so nothing moves: 0 transfers in 12 cycles.
    3) 'good': the source drives valid at the first edge, the sink sees it and raises ready one edge later; beats then flow on four consecutive cycles. 4 transfers.
    4) The rule broken by 'bad' is that a source must not wait for READY before asserting VALID. The sink waiting for VALID is legal.

    Answer

    Answer: 'bad' transfers 0 beats (deadlock from reset), 'good' transfers 4. The protocol lets READY depend on VALID but forbids VALID depending on READY.

    How this was checked

    Checked by running the code in Verilator 5; the printed output supports the answer above. Both flags start low; when each side waits for the other, nothing ever moves.

    Why candidates get it wrong

    The tempting diagnosis is 'the sink must not wait for VALID'. That is allowed (and common: a slave may wait for AWVALID before asserting AWREADY). The illegal dependency is the source-side one. Also, simulation only shows silence, so a testbench with an overall timeout and no 'beats sent' watchdog reports a hang with no hint of the cause.

    Interviewer follow-up

    Which direction of combinational dependency between VALID and READY is allowed? Model answer: READY may be a combinational function of VALID (and of other state), but VALID must never be a function of READY. The asymmetry guarantees there is no combinational loop and no mutual-wait state.

    Related topics

    • Back to Valid/Ready Handshake Puzzles

    • Bus and Interface Protocol Puzzles section

    Previous

    264 / 293

    Next: Registered READY Overflows a FIFO

    Up next

    Up nextRegistered READY Overflows a FIFO

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • Counting Transfers in a Valid/Ready Trace
    • Which Cycle Drops VALID Illegally?
    • Register Slice: 50% Throughput Without Data Errors