Part 3 · Factory & Configuration · Intermediate
Type Overrides Scope: Global Replacement by Requested Type
set_type_override semantics, factory API equivalents, when broad replacement is appropriate, and multi-agent risk patterns.
What a type override covers
A type override replaces all future create() calls that request the original type, regardless of instance path — unless an instance override wins on a specific path.
[FACTORY][UVM] type override blast radius
policy:
base_driver -> err_driver (type)
creates affected:
env.agt0.drv -> err_driver
env.agt1.drv -> err_driver
env.agt2.drv -> err_driver
creates not affected:
base_monitor (different requested type)
already-built base_driver objects (too late)// Preferred typed API
base_driver::type_id::set_type_override(err_driver::get_type());
// Factory singleton equivalent
uvm_factory::get().set_type_override_by_type(
base_driver::get_type(),
err_driver::get_type()
);
// Legacy original-type form (still common in older code)
set_type_override_by_type(
base_driver::get_type(),
err_driver::get_type()
);Key takeaways
Type overrides are the default knob for whole-testbench behavior swaps.
Env must still request base_driver — override supplies derivative at create.
Use type override when every agent should share the same derivative.
Common pitfalls
Type override when only one agent needs different behavior.
Replacing unrelated types due to copy/paste override lines.
Expecting type override to rewrite objects created earlier in build.
When type override is the right tool
Choose type scope for uniform policy: debug verbosity, error injection everywhere, or swapped monitor implementation across all interfaces.
Appropriate use cases
All drivers should run error-injection derivative for stress scenario.
Global monitor swap to verbose_monitor for one regression mode.
Single-agent env where path-specific control adds no value.
[FACTORY] type override decision tree
Need same derivative in every agent?
yes -> type override
no -> instance override per path
Need temporary global swap for debug?
yes -> type override in debug_test onlyMulti-agent risk example
class multi_agent_env extends uvm_env;
`uvm_component_utils(multi_agent_env)
my_agent agt_tx;
my_agent agt_rx;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
agt_tx = my_agent::type_id::create("agt_tx", this);
agt_rx = my_agent::type_id::create("agt_rx", this);
endfunction
endclass[UVM][FACTORY] risk scenario
type override base_driver -> err_driver
intent: only agt_tx should inject errors
actual: both agt_tx.drv and agt_rx.drv become err_driver
fix: instance override on "env.agt_tx.drv"Common pitfalls
Using type override as shortcut without reading multi-agent impact.
Chaining multiple type overrides without replace flag awareness.
Assuming type override affects objects not created via factory.