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

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • 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
  • Interview Prep: Puzzle Rounds5
  • 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. Handle Equality vs Content Equality

VLSI DV Interview Puzzles · All levels

Handle Equality vs Content Equality

Two packets have identical field values, yet `if (a == b)` fails. What is being compared and how should scoreboards compare content?

On this page

    Puzzle

    Difficulty: Easy · Puzzle 5 of 6 · Topic: Handle and Copy Puzzles

    Two packets have identical field values, yet `if (a == b)` fails. What is being compared and how should scoreboards compare content?

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    class pkt extends uvm_object;
      `uvm_object_utils(pkt)
      rand bit [31:0] addr;
      function new(string name="pkt"); super.new(name); endfunction
    endclass
    
    initial begin
      pkt a = pkt::type_id::create("a");
      pkt b = pkt::type_id::create("b");
      a.addr = 'h100;
      b.addr = 'h100;
      $display("eq=%0d", (a == b));
    end

    Hint

    Class `==` is not like packed-struct equality.

    Step-by-step solution

    Diagram
    1) For class handles, `==` checks handle identity (same object), not field-by-field data.
    2) `a` and `b` are distinct objects, so expression is false even with matching `addr`.
    3) In UVM use `a.compare(b)` with configured comparers or explicit field checks.

    Answer

    Answer: `a == b` compares handle identity; use `compare()`/field comparisons for value equivalence.

    Why candidates get it wrong

    This trap causes false negatives in scoreboards that accidentally compare object identity.

    Interviewer follow-up

    What comparer settings would you tune to ignore volatile fields like timestamps?

    Related topics

    • Back to Handle and Copy Puzzles

    • OOP & Testbench Puzzles section

    Previous

    34 / 210

    Next: Clone Without Overridden do_copy

    Up next

    Up nextClone Without Overridden do_copy

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Shallow Copy in Nested Payload
    • Queue of Handle Cells Still Aliases
    • Analysis Port Lifetime Reuse