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
    • Handle and Copy Puzzles
      • Shallow Copy in Nested Payload
      • Queue of Handle Cells Still Aliases
      • Analysis Port Lifetime Reuse
      • Null Handle During Partial Deep Copy
      • Handle Equality vs Content Equality
      • Clone Without Overridden do_copy
    • Virtual Method Puzzles
    • Parameterized Class Puzzles
    • Factory Override Puzzles
    • OOP & Testbench Puzzles: Tricky Q&A
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • UVM Testbench Puzzles25
  • Clock, Reset & CDC Puzzles25
  • Bus and Interface Protocol Puzzles25
  • Interview Prep: Puzzle Rounds7
  • DV Puzzle Cheatsheet
Loading lesson

←Handle and Copy Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. OOP & Testbench Puzzles
  4. Handle and Copy Puzzles
  5. Analysis Port Lifetime Reuse
On this page

    VLSI DV Interview PuzzlesAll levels

    Analysis Port Lifetime Reuse

    A monitor reuses one transaction object every cycle and sends it over analysis port. Why does scoreboard history show all entries with the final sample value?

    Puzzle

    Difficulty: Medium · Puzzle 3 of 6 · Topic: Handle and Copy Puzzles

    A monitor reuses one transaction object every cycle and sends it over analysis port. Why does scoreboard history show all entries with the final sample value?

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    class mon extends uvm_component;
      `uvm_component_utils(mon)
      uvm_analysis_port #(tr) ap;
      virtual bus_if vif;
      tr t;
      function new(string name, uvm_component parent);
        super.new(name, parent);
        ap = new("ap", this);
      endfunction
      task run_phase(uvm_phase phase);
        t = tr::type_id::create("t");
        forever begin
          @(posedge vif.clk);
          t.addr = vif.addr;
          ap.write(t);
        end
      endtask
    endclass
    
    function void sb::write(tr t);
      exp_q.push_back(t);
    endfunction

    Hint

    Ask whether `write()` transfers a new object or the same handle.

    Step-by-step solution

    Diagram
    1) `ap.write(t)` passes a handle, not a deep-copied object.
    2) Scoreboard stores that same handle each cycle, so queue entries alias one object.
    3) Next cycle updates `t.addr`, and all previously stored handles appear to change.
    4) Clone in monitor before write, or clone in subscriber on receipt.

    Answer

    Answer: All entries alias the same reused object handle; the scoreboard never captured immutable snapshots.

    How this was checked

    Checked by running the code in Verilator 5; the printed output supports the answer above. A hand-written model of a monitor and scoreboard (not the UVM library): write() stores a handle, so a reused object fills the queue with its last value.

    Why candidates get it wrong

    Analysis `write()` is a function call that passes a handle: the one object `t` sits in the queue N times, so the history shows the most recent `addr` N times.

    Interviewer follow-up

    Where should cloning happen for best performance and ownership clarity: monitor, analysis FIFO, or scoreboard? Model answer: in the producer. The monitor owns the object and knows when it is finished with it, so it should create a fresh `tr` per sample (cheapest, no clone) and never touch it after `write()`. Cloning in each subscriber costs one copy per subscriber and relies on every subscriber remembering to do it.

    Say it out loud

    Every queued entry ends up looking the same, because the monitor reuses one object and the write call only passes a handle. The scoreboard stores that one handle every cycle, so when the next cycle updates the address, all stored entries appear to change. The trap is thinking the analysis port makes a snapshot, and it does not. I would clone in the monitor before writing, or clone in the subscriber on receipt, and then check the queue entries are distinct objects.

    Related topics

    • Analysis Port Fanout

    • Handles vs Objects

    • Back to Handle and Copy Puzzles

    • OOP & Testbench Puzzles section

    Previous

    38 / 293

    Next: Null Handle During Partial Deep Copy

    Up next

    Up nextNull Handle During Partial Deep Copy

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • Shallow Copy in Nested Payload
    • Handle Equality vs Content Equality
    • Clone Without Overridden do_copy