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
    • Testbench Debug Puzzles: Why Did the Test Hang?
      • Handshake Hang: Missing item_done on One Branch
      • Missing run_phase Objection in Test
      • Wrong Phase: Starting Traffic in shutdown_phase
      • Handshake Violation: item_done Called Twice
      • Sequence get_response Stall
      • Virtual Sequence Waits on an Event That Already Fired
    • Deadlock Scenario Puzzles: Objection and Phase Stalls
    • Scoreboard Puzzles: Mismatch or Ordering Bug?
    • Real Interview Rounds: End-to-End Debug Walkthrough
    • Scenario & Debug Puzzles: Tricky Q&A
  • UVM Testbench Puzzles25
  • Clock, Reset & CDC Puzzles25
  • Bus and Interface Protocol Puzzles25
  • Interview Prep: Puzzle Rounds7
  • DV Puzzle Cheatsheet
Loading lesson

←Testbench Debug Puzzles: Why Did the Test Hang?
  1. Topics
  2. DV Interview Puzzles
  3. Scenario & Debug Puzzles
  4. Testbench Debug Puzzles: Why Did the Test Hang?
  5. Handshake Violation: item_done Called Twice
On this page

    VLSI DV Interview PuzzlesAll levels

    Handshake Violation: item_done Called Twice

    Seeds that hit the retry path die with a sequencer fatal complaining about item_done with no outstanding get_next_item. Intent of the retry path: complete the first attempt, then re-drive the same item. Find the handshake bug.

    Puzzle

    Difficulty: Medium · Puzzle 4 of 6 · Topic: Testbench Debug Puzzles: Why Did the Test Hang?

    Seeds that hit the retry path die with a sequencer fatal complaining about item_done with no outstanding get_next_item. Intent of the retry path: complete the first attempt, then re-drive the same item. Find the handshake bug.

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    virtual task run_phase(uvm_phase phase);
      my_item req;
      forever begin
        seq_item_port.get_next_item(req);
        drive_req(req);
        if (req.retry) begin
          seq_item_port.item_done();  // release first attempt
          drive_req(req);             // re-drive the same item
        end
        seq_item_port.item_done();    // second done on retry path
      end
    endtask

    Hint

    Count handshakes by transaction id: grant, get, done.

    Step-by-step solution

    Diagram
    1) Enable handshake logging around get_next_item/item_done with the item id, or count calls.
    2) A retry item shows one get_next_item and two item_done calls.
    3) The first item_done closes the handshake; the second has no outstanding get_next_item, which UVM 1.2 reports as a UVM_FATAL (SQRBADITMDN); older versions may differ. It is a fatal, not a hang.
    4) Fix: exactly one item_done at a single exit point, and do the re-drive before it: drive_req(req); if (req.retry) drive_req(req); seq_item_port.item_done();
    5) Add a directed retry test and a pairing counter (get_next_item count equals item_done count).

    Answer

    Answer: Bug: the retry branch calls item_done and the common exit calls it again, so one get_next_item is closed twice and UVM 1.2 reports a protocol fatal. Fix: re-drive inside the branch and keep a single item_done after it.

    How this was checked

    Checked by running the code in Verilator 5; the printed output supports the answer above. Plain-SV model of the get_next_item/item_done pairing counters, not the UVM library: the retry path closes one handshake twice.

    Why candidates get it wrong

    Dropping the retry behaviour makes the fatal vanish but silently changes the DUT stimulus; also do not expect a hang here, the symptom is the sequencer protocol fatal on the second item_done.

    Interviewer follow-up

    Would you use assertions, sequencer callbacks, or counters to enforce one-to-one handshake pairing? Model answer: A simple counter pair in the driver (opened on get_next_item, closed on item_done) with an end-of-test check and an immediate error if item_done is called at zero is the cheapest and works in every simulator; a sequencer/driver callback gives a reusable hook for all agents; SVA is a poor fit because the handshake is software-level, not signal-level.

    Say it out loud

    I start with the sequencer protocol fatal, because the symptom here is an error on the second item_done, not a hang. The root cause is that the retry branch calls item_done and the common exit calls it again, so one get_next_item is closed twice. I confirm it by counting get_next_item against item_done in the driver log for the failing item. The fix is to re-drive inside the retry branch and keep a single item_done after it, without dropping the retry behaviour.

    Related topics

    • The Driver Handshake: start_item, finish_item, get_next_item, item_done

    • Stalled Sequences: Hang Triage

    • Back to Testbench Debug Puzzles: Why Did the Test Hang?

    • Scenario & Debug Puzzles section

    Previous

    189 / 293

    Next: Sequence get_response Stall

    Up next

    Up nextSequence get_response Stall

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • Handshake Hang: Missing item_done on One Branch
    • Missing run_phase Objection in Test
    • Virtual Sequence Waits on an Event That Already Fired