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
    • Virtual Method Puzzles
    • Parameterized Class Puzzles
    • Factory Override Puzzles
      • Type Override vs Instance Override Precedence
      • Chained Type Overrides
      • Replace Flag in Repeated set_type_override
      • Overlapping Instance Overrides: First Match Wins
      • 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
  • UVM Testbench Puzzles25
  • Clock, Reset & CDC Puzzles25
  • Bus and Interface Protocol Puzzles25
  • Interview Prep: Puzzle Rounds7
  • DV Puzzle Cheatsheet
Loading lesson

←Factory Override Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. OOP & Testbench Puzzles
  4. Factory Override Puzzles
  5. Chained Type Overrides
On this page

    VLSI DV Interview PuzzlesAll levels

    Chained Type Overrides

    Two type overrides are installed on different original types so that A maps to B and B maps to C. Predict the type of each created object.

    Puzzle

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

    Two type overrides are installed on different original types so that A maps to B and B maps to C. Predict the type of each created object.

    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 item_a extends uvm_object;
      `uvm_object_utils(item_a)
      function new(string name="item_a"); super.new(name); endfunction
    endclass
    class item_b extends item_a;
      `uvm_object_utils(item_b)
      function new(string name="item_b"); super.new(name); endfunction
    endclass
    class item_c extends item_b;
      `uvm_object_utils(item_c)
      function new(string name="item_c"); super.new(name); endfunction
    endclass
    
    initial begin
      item_a x;
      item_b y;
      item_a::type_id::set_type_override(item_b::get_type());
      item_b::type_id::set_type_override(item_c::get_type());
      x = item_a::type_id::create("x");
      y = item_b::type_id::create("y");
      $display("x=%s y=%s", x.get_type_name(), y.get_type_name());
    end

    Hint

    After the factory applies one override, it looks the result up again.

    Step-by-step solution

    Diagram
    1) `y` asks for `item_b`; the override B->C applies, so `y` is an `item_c`.
    2) `x` asks for `item_a`; override A->B applies, and the factory then checks the override table again for `item_b`, finds B->C, and ends at `item_c`.
    3) Both objects are `item_c`: `x=item_c y=item_c`. The handle types still work because `item_c` extends `item_b` extends `item_a`.

    Answer

    Answer: Prints `x=item_c y=item_c`: the factory resolves override chains, so A->B->C yields `item_c` for both requests.

    How this was checked

    Checked by running the code in Verilator 5; the printed output supports the answer above. A hand-written model of the documented UVM 1.2 factory rule (not the UVM library): the factory re-resolves the replacement, so A to B to C ends at C.

    Why candidates get it wrong

    Overrides are not one-hop lookups: an override installed for the replacement type applies to requests for the original type too, so adding an unrelated override for B in another file silently changes what A produces.

    Interviewer follow-up

    What breaks if the chain is closed into a loop, A->B and B->A? Model answer: nothing legal can be resolved; the factory has to stop the recursion, and UVM reports an error rather than looping. Treat a cycle as a testbench bug and use `factory.print()` to inspect the table. (UVM 1.2 documented chaining; the cycle handling rests on the source, not a run.)

    Say it out loud

    Both x and y are item_c. The factory resolves override chains, so A goes to B and then B goes to C. The trap is stopping after the first hop. The handle types still work because item_c extends item_b, which extends item_a, and I would confirm with a factory print.

    Related topics

    • Override Resolution: Who Wins

    • Override Timing, Safety and Debug

    • Back to Factory Override Puzzles

    • OOP & Testbench Puzzles section

    Previous

    55 / 293

    Next: Replace Flag in Repeated set_type_override

    Up next

    Up nextReplace Flag in Repeated set_type_override

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • Overlapping Instance Overrides: First Match Wins
    • Component Override in build_phase
    • Override Timing Relative to create Calls