VLSI DV Interview Puzzles · All levels

Handshake Violation: item_done Called Twice

Test sometimes fatals with sequencer protocol error, and sometimes appears to hang after retries. Find the handshake bug introduced in retry handling.

Puzzle

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

Test sometimes fatals with sequencer protocol error, and sometimes appears to hang after retries. Find the handshake bug introduced in retry handling.

Code

systemverilog
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();
    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 protocol checkers/logging around sequencer handshake API calls.
2) Trigger a retry case and observe two item_done calls for one get_next_item.
3) See queue bookkeeping corruption that later manifests as stall/fatal.
4) Refactor to exactly one item_done at a single exit point.
5) Add a unit test for retry path to prevent regression.

Answer

Answer: Bug: retry path calls item_done twice for one granted item. Fix: centralize handshake completion so each request has exactly one item_done.

Why candidates get it wrong

A quick workaround that removes retry behavior can hide the protocol violation but break functionality.

Interviewer follow-up

Would you use assertions, sequencer callbacks, or counters to enforce one-to-one handshake pairing?

Related topics