VLSI DV Interview Puzzles · All levels
UVM Analysis Port Handle Reuse
Scoreboard queue entries appear to change after insertion. Locate the monitor bug.
Puzzle
Difficulty: Hard · Puzzle 4 of 6 · Topic: Debugging Riddles
Scoreboard queue entries appear to change after insertion. Locate the monitor bug.
Code
systemverilog
task run_phase(uvm_phase phase);
tr t = tr::type_id::create("t");
forever begin
collect_fields(t);
ap.write(t);
end
endtaskHint
Analysis ports pass object handles, not deep copies.
Step-by-step solution
diagram
1) Same object t is reused every iteration.
2) Subscribers store handle to t; later collect_fields overwrites same object.
3) Scoreboard then sees previously queued entries mutate, appearing as random corruption.
4) Fix: create new object each transaction or clone before write (ap.write(t.clone())).
5) Also ensure do_copy/do_clone perform deep copy for dynamic fields.Answer
Answer: The monitor reuses one transaction handle; clone/new per sample before ap.write.
Why candidates get it wrong
Assuming `write()` implies by-value transfer.
Interviewer follow-up
Which fields require explicit deep-copy logic in `do_copy`?