Hi, all
I want to use the factory mechanism to write one reusable test, this is the codes
class my_test #(parameter TSID=0) extends uvm_test;
typedef my_test #(TSID) this_typ;
typedef uvm_component_registry #(my_test #(TSID), $sformatf("my_test%0d", TSID)) type_id;
static function type_id get_type();
return type_id::get();
endfunction : get_type
function new(string name = "my_test", uvm_component parent=null);
super.new(name,parent);
endfunction : new
...
endclass
But I met such a compile error:
Error-[NCE] Non-constant expression
The following expression should be a constant.
Expression: $sformatf("my_test%0d", TSID)
Source info: typedef uvm_component_registry #(my_test #(TSID),
$sformatf("my_test%0d", TSID)) type_id;
...
If the second parameter should be a constant or constant expression in
typedef uvm_component_registry #(my_test #(TSID), $sformatf("my_test%0d", TSID)) type_id;
then how can i distinguish the specialized test using TSID which is from run option (my original idea is that using parameter TSID to distinguish the different specialized test)?
Second problem, my_test is a generic class now, where should the specialized test define and how to define if my original idea is feasible?
Regards