VLSI DV Interview Puzzles · All levels

Wrong UVM Macro for Parameterized Object

Factory create fails for `pkt#(int)` in a parameterized sequence item. What registration mistake causes this?

Puzzle

Difficulty: Hard · Puzzle 6 of 6 · Topic: Parameterized Class Puzzles

Factory create fails for `pkt#(int)` in a parameterized sequence item. What registration mistake causes this?

Code

systemverilog
class pkt #(type T = int) extends uvm_sequence_item;
  `uvm_object_utils(pkt#(T))
  function new(string name="pkt");
    super.new(name);
  endfunction
endclass

initial begin
  uvm_object o;
  o = pkt#(int)::type_id::create("o");
end

Hint

Parameterized classes need parameter-aware registration macros.

Step-by-step solution

diagram
1) `uvm_object_utils` is for non-parameterized object types or concrete typedef specializations.
2) For parameterized class templates, use `uvm_object_param_utils(pkt#(T))`.
3) Wrong macro leads to missing/incorrect factory registration and create/override mismatches.

Answer

Answer: Use `uvm_object_param_utils` for parameterized class templates; wrong macro breaks reliable factory behavior per specialization.

Why candidates get it wrong

People remember macro names but not why specialization-aware registration is required.

Interviewer follow-up

When is it acceptable to use `uvm_object_utils` with a typedef of a concrete specialization?

Related topics