Hi all,
I am trying to create a generic method which could be utilized in the creation of any amount of any agent. Basically, my approach is to implement virtual parameterized class with static method targeted to create process. The problem is that it seems I can’t pass parent component handle to that implemented create method.
Here is an example case. Inside example_env, I am trying to create six instances of example_agent. m_example_agent is an dynamic array holding handles for those six occurrences of example_agent. Parent uvm_component handle is tried to pass to support_class via this since uvm_component’s create() method requires it.
class example_env extends uvm_env;
...
example_agent m_example_agent[];
...
function virtual void build_phase(uvm_phase phase);
...
m_example_agent = support_class#(example_agent, this)::create_child(6);
...
endfunction: build_phase
...
endclass: example_env
support_class is declared as a virtual class and it has a static method called create_child as follows:
virtual class support_class #(type T = int, uvm_component parent);
typedef T return_type_array[];
static function return_type_array create_child(int number);
string str;
create_child = new[number];
for (int i = 0; i < number; i++) begin
create_child[i] = T::type_id::create({"agent_x", str.itoa(i)}, parent);
end
endfunction: create_child
endclass: support_class
Simulator doesn’t accept that but instead it says “Class specialization parameter must be constant…” once ::create_child(6) is called. If I give a default value of null for parent parameter, it seems working.
Do I have any possibility to pass parent uvm_component handle to my create_child() method? Or do you have any other implementations in your mind? I wouldn’t like to throw this to the waste bin.
Sorry for the typos in the example code already in advance. Thanks for your help!
-Vaino