Difficulty: Medium · Puzzle 5 of 6 · Topic: Factory and config_db
UVM 1.2. Two tests want the same override of `base_drv` by `err_drv` for `env.agent.drv`. Test A calls the component method `set_inst_override_by_type`; test B calls the factory directly with the same string. Which test actually gets an err_drv, and why does the other get no message at all?
class test_a extends uvm_test;
`uvm_component_utils(test_a)
function new(string name, uvm_component parent); super.new(name, parent); endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
set_inst_override_by_type("env.agent.drv", base_drv::get_type(), err_drv::get_type());
env = my_env::type_id::create("env", this);
endfunction
endclass
class test_b extends uvm_test;
`uvm_component_utils(test_b)
function new(string name, uvm_component parent); super.new(name, parent); endfunction
function void build_phase(uvm_phase phase);
uvm_factory f = uvm_factory::get();
super.build_phase(phase);
f.set_inst_override_by_type(base_drv::get_type(), err_drv::get_type(), "env.agent.drv");
env = my_env::type_id::create("env", this);
endfunction
endclassOne of the two prefixes the path with something. Which?
1) The component method `uvm_component::set_inst_override_by_type(relative_inst_path, ...)` prepends the calling component's full name, so test A applies it to `uvm_test_top.env.agent.drv`, which matches the real path of the driver.
2) The factory's own method takes the full instance path as given. Test B's string `env.agent.drv` is matched against `uvm_test_top.env.agent.drv`, does not match, and the override is simply never applied.
3) The factory does not warn about an override that never matches. Diagnose with `factory.print()` or `uvm_top.print_topology()` and fix with the full path (`uvm_test_top.env.agent.drv`) or a leading wildcard (`*.env.agent.drv`).Answer: Test A gets err_drv; test B's path is missing the `uvm_test_top.` prefix and silently never matches.
Not run here: The UVM library is not installed here, so this cannot be executed; uvm_factory path matching is library behaviour; the claim rests on uvm_component::set_inst_override_by_type prepending get_full_name() in the UVM 1.2 source.. The answer follows the language rules and the solution steps above.
Same method name, different path rules: the component method takes a path relative to the component, the factory method takes the full path, and an unmatched override is silent.
How do you find out which override fired for a given create? Model answer: call `factory.debug_create_by_type(base_drv::get_type(), "uvm_test_top.env.agent", "drv")` (or `factory.print()`), which prints the matching override chain for that type, parent path and name.