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. Component Override in build_phase
On this page

    VLSI DV Interview PuzzlesAll levels

    Component Override in build_phase

    Two env variants construct `agent` differently in `build_phase`. Which one honors test-level component override?

    Puzzle

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

    Two env variants construct `agent` differently in `build_phase`. Which one honors test-level component override?

    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
    27
    28
    class agent extends uvm_component;
      `uvm_component_utils(agent)
      function new(string name, uvm_component parent); super.new(name, parent); endfunction
    endclass
    class agent_ext extends agent;
      `uvm_component_utils(agent_ext)
      function new(string name, uvm_component parent); super.new(name, parent); endfunction
    endclass
    
    class env_a extends uvm_env;
      `uvm_component_utils(env_a)
      agent agt;
      function new(string name, uvm_component parent); super.new(name, parent); endfunction
      function void build_phase(uvm_phase phase);
        super.build_phase(phase);
        agt = agent::type_id::create("agt", this);
      endfunction
    endclass
    
    class env_b extends uvm_env;
      `uvm_component_utils(env_b)
      agent agt;
      function new(string name, uvm_component parent); super.new(name, parent); endfunction
      function void build_phase(uvm_phase phase);
        super.build_phase(phase);
        agt = new("agt", this);
      endfunction
    endclass

    Hint

    Component overrides require factory path; direct constructor call skips factory.

    Step-by-step solution

    Diagram
    1) `env_a` uses `type_id::create`, so override `agent -> agent_ext` is honored.
    2) `env_b` uses direct `new`, so override is bypassed.
    3) Result: env_a gets `agent_ext`, env_b gets `agent`.

    Answer

    Answer: Only `env_a` honors component override because it constructs through factory `create`.

    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): create applies the override, a direct new never does.

    Why candidates get it wrong

    Direct component `new` in build_phase is a frequent reason overrides 'mysteriously' do nothing; `env_b` also compiles and runs fine, so nothing flags it.

    Interviewer follow-up

    Would this differ for objects created in `run_phase` versus components in `build_phase`? Model answer: the override rule is the same for objects: `type_id::create` honours it at any time and `new` never does. The difference is timing: components must be created in `build_phase` (before the hierarchy is fixed) and overrides must already be registered then, whereas objects such as sequence items can be created and overridden any time during `run_phase`.

    Say it out loud

    Only env_a honors the component override. It constructs the agent through the factory create call, so the override to agent_ext applies. The env_b component uses direct new, which bypasses the factory entirely, so it gets the plain agent. The trap is thinking an override affects every construction, so I would search for direct new calls on components.

    Related topics

    • The type_id::create Pattern

    • Override Resolution: Who Wins

    • Back to Factory Override Puzzles

    • OOP & Testbench Puzzles section

    Previous

    58 / 293

    Next: Override Timing Relative to create Calls

    Up next

    Up nextOverride Timing Relative to create Calls

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • Type Override vs Instance Override Precedence
    • Chained Type Overrides
    • Replace Flag in Repeated set_type_override