VLSI DV Interview Puzzles · All levels

Wildcard Instance Path Precedence

An exact instance override and a wildcard instance override both match one path. Which type is created?

Puzzle

Difficulty: Hard · Puzzle 4 of 6 · Topic: Factory Override Puzzles

An exact instance override and a wildcard instance override both match one path. Which type is created?

Code

systemverilog
class base_item extends uvm_object;
  `uvm_object_utils(base_item)
  function new(string name="base_item"); super.new(name); endfunction
endclass
class dbg_item extends base_item;
  `uvm_object_utils(dbg_item)
  function new(string name="dbg_item"); super.new(name); endfunction
endclass
class perf_item extends base_item;
  `uvm_object_utils(perf_item)
  function new(string name="perf_item"); super.new(name); endfunction
endclass

initial begin
  base_item::type_id::set_inst_override(
    perf_item::get_type(),
    "uvm_test_top.env.agent*.seqr.main_phase"
  );
  base_item::type_id::set_inst_override(
    dbg_item::get_type(),
    "uvm_test_top.env.agent0.seqr.main_phase"
  );
  $display("a0=%s",
    base_item::type_id::create("a0", null, "uvm_test_top.env.agent0.seqr.main_phase").get_type_name());
  $display("a1=%s",
    base_item::type_id::create("a1", null, "uvm_test_top.env.agent1.seqr.main_phase").get_type_name());
end

Hint

Exact path match is more specific than wildcard match.

Step-by-step solution

diagram
1) agent0 path matches both wildcard and exact entries.
2) Factory selects the more specific exact instance override for agent0 -> `dbg_item`.
3) agent1 only matches wildcard -> `perf_item`.

Answer

Answer: `a0=dbg_item` and `a1=perf_item` due to exact instance-path precedence over wildcard.

Why candidates get it wrong

Assuming wildcard registration order alone determines result leads to incorrect predictions.

Interviewer follow-up

How would you debug this at runtime using factory print/debug APIs?

Related topics