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.
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
endtaskCount handshakes by transaction id: grant, get, done.
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: Bug: retry path calls item_done twice for one granted item. Fix: centralize handshake completion so each request has exactly one item_done.
A quick workaround that removes retry behavior can hide the protocol violation but break functionality.
Would you use assertions, sequencer callbacks, or counters to enforce one-to-one handshake pairing?