Part 3 · Factory & Configuration · Intermediate

Instance Overrides Scope: Surgical Path Targeting

set_inst_override path rules, context/full-name matching, factory API forms, and patterns for multi-agent selective substitution.

Instance path semantics

Instance overrides match a full hierarchical path suffix from the test root. Path strings must align with eventual get_full_name() of the created component.

diagram
[FACTORY][UVM] instance override targeting

register:
  base_driver -> stress_driver at "env.agt_tx.drv"

create chain:
  uvm_test_top
    env
      agt_tx
        drv  full name = uvm_test_top.env.agt_tx.drv

match:
  instance override applies to this create only
systemverilog
base_driver::type_id::set_inst_override(
  stress_driver::get_type(),
  "env.agt_tx.drv"
);

// Factory API with explicit context
uvm_factory::get().set_inst_override_by_type(
  base_driver::get_type(),
  stress_driver::get_type(),
  1,              // replace existing override if present
  this,           // context component (usually test)
  "env.agt_tx.drv"
);

Key takeaways

  • Instance overrides enable per-agent policy in shared environments.

  • Path accuracy is everything — one dot off and override applies nowhere.

  • Log get_full_name() early when defining new override paths.

Common pitfalls

  • Using local child name only (drv) instead of full path suffix.

  • Hardcoding paths that change when env hierarchy is renamed.

  • Instance override on wrong requested type proxy.


Path discovery and validation workflow

Never guess override paths. Derive them from a known-good hierarchy print or staged build logs.

Path discovery checklist

  1. Run smoke test with BUILD logs printing parent full names.

  2. Record exact suffix from uvm_test_top for each target child.

  3. Register instance override using that suffix string.

  4. At end_of_elaboration, confirm child get_type_name().

systemverilog
function void build_phase(uvm_phase phase);
  super.build_phase(phase);
  `uvm_info("PATH_DBG", $sformatf("agt_tx.drv path=%s",
    agt_tx.drv.get_full_name()), UVM_LOW)
endfunction

Multi-target pattern

diagram
[FACTORY] selective multi-agent map

env.agt_tx.drv -> stress_driver
env.agt_rx.drv -> low_power_driver
all other base_driver creates -> base_driver (default)

type override absent; two instance overrides only
systemverilog
virtual function void apply_factory_overrides();
  base_driver::type_id::set_inst_override(
    stress_driver::get_type(), "env.agt_tx.drv");
  base_driver::type_id::set_inst_override(
    low_power_driver::get_type(), "env.agt_rx.drv");
endfunction

Common pitfalls

  • Wildcards in instance path strings — not supported like config_db.

  • Assuming array/generate indices without verifying actual names.

  • Applying instance override from child component with wrong context.