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
    • Classic Brain Teasers
    • Probability Puzzles
    • Digital Logic Puzzles
    • Debugging Riddles
      • Race-Region Printout: What Does Each Monitor Print?
      • Reset Release Leaves the FSM in an Illegal State
      • always_comb with NBA and Missing Else
      • UVM Analysis Port Handle Reuse
      • join_any Timeout Ghost Thread
      • Randomization Always Fails: Hidden Unsat
    • Logic & Aptitude Puzzles: Tricky Q&A
  • Scenario & Debug Puzzles25
  • UVM Testbench Puzzles25
  • Clock, Reset & CDC Puzzles25
  • Bus and Interface Protocol Puzzles25
  • Interview Prep: Puzzle Rounds7
  • DV Puzzle Cheatsheet
Loading lesson

←Debugging Riddles
  1. Topics
  2. DV Interview Puzzles
  3. Logic & Aptitude Puzzles
  4. Debugging Riddles
  5. UVM Analysis Port Handle Reuse
On this page

    VLSI DV Interview PuzzlesAll levels

    UVM Analysis Port Handle Reuse

    Scoreboard queue entries appear to change after insertion. Locate the monitor bug.

    Puzzle

    Difficulty: Medium · Puzzle 4 of 6 · Topic: Debugging Riddles

    Scoreboard queue entries appear to change after insertion. Locate the monitor bug.

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    task run_phase(uvm_phase phase);
      tr t = tr::type_id::create("t");
      forever begin
        collect_fields(t);
        ap.write(t);
      end
    endtask

    Hint

    Analysis ports pass object handles, not deep copies.

    Step-by-step solution

    Diagram
    1) The same object t is created once and reused every iteration, and no new transaction is created per sample.
    2) Subscribers store the handle; the next collect_fields overwrites the same object.
    3) Scoreboard then sees previously queued entries mutate (in a simulation of the same pattern every queued entry showed the latest value), appearing as random corruption.
    4) Best fix: create a new object inside the loop: forever begin tr t = tr::type_id::create("t"); collect_fields(t); ap.write(t); end.
    5) Cloning also works, but clone() returns uvm_object, so ap.write(t.clone()) does not compile. Cast it: tr c; collect_fields(t); if (!$cast(c, t.clone())) `uvm_fatal("CAST", "clone type"); ap.write(c);
    6) Make sure do_copy deep-copies nested objects (class handles) so a clone is independent; dynamic arrays and queues of plain values are copied by value.

    Answer

    Answer: The monitor reuses one transaction handle; create a new tr per sample (or $cast the result of clone()) before ap.write.

    How this was checked

    Checked by running the code in Verilator 5; the printed output supports the answer above. A plain-SV model of the mechanism (no UVM library): a reused handle leaves every queue entry equal to the last value; a new object or a deep clone per sample keeps 10 20 30; a shallow copy still shares nested objects.

    Why candidates get it wrong

    Assuming write() copies the object (it passes a handle) and then 'fixing' it with ap.write(t.clone()), which fails to compile because clone() returns uvm_object and needs $cast.

    Interviewer follow-up

    Which fields require explicit deep-copy logic in `do_copy`? Model answer: only fields that hold class handles. Dynamic arrays, queues, associative arrays and strings are value types, so a plain copy is independent, but an array or queue OF handles still shares the objects. Nested uvm_objects must be created and copied (or cloned), otherwise the copy shares the member with the original.

    Say it out loud

    Entries in the scoreboard queue change after insertion, which tells me they share one object. The monitor creates the transaction once outside the loop and reuses it, and write passes a handle, not a copy, so every queued entry points at the latest data. The fix is to create a new transaction inside the loop on every sample before the write. Cloning also works, but clone returns a uvm_object, so you need a cast. The trap is assuming write copies the object, or writing write of t dot clone, which does not compile.

    Related topics

    • Monitor Implementation Detail: Sampling, Races and X

    • Analysis Port Fanout

    • Handles vs Objects

    • Back to Debugging Riddles

    • Logic & Aptitude Puzzles section

    Previous

    182 / 293

    Next: join_any Timeout Ghost Thread

    Up next

    Up nextjoin_any Timeout Ghost Thread

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • Race-Region Printout: What Does Each Monitor Print?
    • Reset Release Leaves the FSM in an Illegal State
    • Randomization Always Fails: Hidden Unsat