Difficulty: Easy · Puzzle 1 of 6 · Topic: Factory and config_db
UVM 1.2. The top module publishes the virtual interface with a null context and the path `env.agent.*`; the test class is my_test, run with `run_test("my_test")`. The driver's build_phase get() fails with NOVIF. Why?
module top;
bus_if vif(clk);
initial begin
uvm_config_db#(virtual bus_if)::set(null, "env.agent.*", "vif", vif);
run_test("my_test");
end
endmodule
// in my_driver.build_phase (full name is uvm_test_top.env.agent.drv)
if (!uvm_config_db#(virtual bus_if)::get(this, "", "vif", vif))
`uvm_fatal("NOVIF", "virtual interface not set")With a null context the path is taken from the very top of the hierarchy. What is the full name of the test component?
1) With cntxt == null the inst_name is an absolute pattern, matched against the full names of components, which all start with the test's instance name.
2) The test is always instantiated as `uvm_test_top`, whatever the test class is called. The driver's full name is `uvm_test_top.env.agent.drv`.
3) `env.agent.*` does not match it (missing the `uvm_test_top.` prefix), so get() returns 0 and the fatal fires.
4) Fix: `uvm_config_db#(virtual bus_if)::set(null, "uvm_test_top.env.agent.*", "vif", vif)`, or a leading wildcard such as `*.agent.*`.Answer: The pattern lacks the `uvm_test_top.` prefix; with a null context the path is absolute, so it never matches the driver.
Not run here: The UVM library is not installed here, so this cannot be executed; uvm_config_db path globbing and uvm_test_top naming are library behaviour; a stand-in would only restate the claim.. The answer follows the language rules and the solution steps above.
The instance name `uvm_test_top` is fixed by run_test and has nothing to do with the test class name (`my_test`), so a path written from the class name is just as wrong.
Would `"uvm_test_top.env.agent"` (no `.*`) match the driver? Model answer: no; a pattern without a wildcard matches only the component with exactly that full name (the agent). To reach the agent and every child use `uvm_test_top.env.agent*` or set per child; the driver's get uses `(this, "", ...)` so its own full name is what is matched.