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
    • Virtual Method Puzzles
    • Parameterized Class Puzzles
    • Factory Override Puzzles
      • Type Override vs Instance Override Specificity
      • create() Honors Override, new() Bypasses
      • Replace Flag in Repeated set_type_override
      • Wildcard Instance Path Precedence
      • Component Override in build_phase
      • Override Timing Relative to create Calls
    • 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

‹Factory Override Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. OOP & Testbench Puzzles
  4. Factory Override Puzzles
  5. Type Override vs Instance Override Specificity

VLSI DV Interview Puzzles · All levels

Type Override vs Instance Override Specificity

Both type and instance overrides are configured. Predict concrete type for each create path.

On this page

    Puzzle

    Difficulty: Medium · Puzzle 1 of 6 · Topic: Factory Override Puzzles

    Both type and instance overrides are configured. Predict concrete type for each create path.

    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
    23
    24
    25
    26
    class base_item extends uvm_sequence_item;
      `uvm_object_utils(base_item)
      function new(string name="base_item"); super.new(name); endfunction
    endclass
    
    class ecc_item extends base_item;
      `uvm_object_utils(ecc_item)
      function new(string name="ecc_item"); super.new(name); endfunction
    endclass
    
    class poison_item extends base_item;
      `uvm_object_utils(poison_item)
      function new(string name="poison_item"); super.new(name); endfunction
    endclass
    
    initial begin
      base_item::type_id::set_type_override(ecc_item::get_type());
      base_item::type_id::set_inst_override(
        poison_item::get_type(),
        "uvm_test_top.env.agentA.seqr.main_phase"
      );
      base_item a, b;
      a = base_item::type_id::create("a", null, "uvm_test_top.env.agentA.seqr.main_phase");
      b = base_item::type_id::create("b", null, "uvm_test_top.env.agentB.seqr.main_phase");
      $display("a=%s b=%s", a.get_type_name(), b.get_type_name());
    end

    Hint

    Factory picks the most specific matching rule for each create request.

    Step-by-step solution

    Diagram
    1) Create at agentA path exactly matches instance override, so returns `poison_item`.
    2) Create at agentB has no matching instance override; type override applies.
    3) Result prints `a=poison_item b=ecc_item`.

    Answer

    Answer: Instance-path match wins for `a`, so `a=poison_item`; `b` falls back to type override, so `b=ecc_item`.

    Why candidates get it wrong

    Override call order is not enough; path specificity determines precedence at create-time.

    Interviewer follow-up

    How would wildcard instance paths affect this result?

    Related topics

    • Back to Factory Override Puzzles

    • OOP & Testbench Puzzles section

    Previous

    48 / 210

    Next: create() Honors Override, new() Bypasses

    Up next

    Up nextcreate() Honors Override, new() Bypasses

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Replace Flag in Repeated set_type_override
    • Wildcard Instance Path Precedence
    • Component Override in build_phase