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

VLSI DV Interview Puzzles · All levels

Component Override in build_phase

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

On this page

    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`.

    Why candidates get it wrong

    Direct component `new` in build_phase is a frequent reason overrides 'mysteriously' do nothing.

    Interviewer follow-up

    Would this differ for objects created in `run_phase` versus components in `build_phase`?

    Related topics

    • Back to Factory Override Puzzles

    • OOP & Testbench Puzzles section

    Previous

    52 / 210

    Next: Override Timing Relative to create Calls

    Up next

    Up nextOverride Timing Relative to create Calls

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Type Override vs Instance Override Specificity
    • create() Honors Override, new() Bypasses
    • Replace Flag in Repeated set_type_override