i just read this article posted in Patterns Library and have a try. However, it seems doesn’t work.
after check UVM source code, the test is instantiated with factory.create_component_by_name().
for parameterized component, type name is not registered into regedit even if explicitly implement get_type_name(),just following the example code of the article. i don’t know why get_type_name is not works when registry. is there anyone explain it? the result is when search for the registered component with given type name, it fail and return null. i’m really curious how does it works as author said. actually i find parameterized test registry is not success.
this is my code.
parameter NUM = 3;
class mytest#(int NUM) extends uvm_test;
typedef uvm_component_registry#(mytest#(NUM),$sformatf(“mytest#(%1d)”,NUM)) type_id;
static function type_id get_type();
return type_id::get();
endfunction
virtual function uvm_object_wrapper get_object_type();
return type_id::get();
endfunction
const static string type_name = $sformatf(“mytest#(%1d)”,NUM);
virtual function string get_type_name();
return type_name;
endfunction
//function new
//function build_phase
endclass
initial begin
run_test($sformatf(“mytest#(%1d)”,NUM));
end
In reply to cgales:
thanks, it’s really works. why add a typedef can make registry successful for the parameterized class? could you explain more to me ? typedef can be used as alias name or pre-declare, but seems it has no relationship with uvm_factory registry. That’s why i ignored it when read article.