Hello,
Before I had a virtual uvm_component class that had a create_child function that created a child of itself, like this:
virtual class my_class extends uvm_component;
my_class m_children[$];
function new(string name = "my_class", uvm_component parent);
super.new(name, parent);
endfunction : new
function my_class create_child();
automatic my_class child;
if ( !$cast(child, create_component(get_type_name(), $sformatf("m_child_class%0d", m_children.size() ) ) ) )
`uvm_error("TEST", "failed to create child")
m_children.push_back(child);
return child;
endfunction
endclass
which worked without uvm_component_utils since it is an abstract class. Recently I had to switch from using uvm_component to uvm_object; so I tried:
virtual class my_class extends uvm_object;
my_class m_children[$];
function new(string name = "my_class");
super.new(name);
endfunction : new
function my_class create_child();
automatic my_class child;
if ( !$cast(child, create_object(get_type_name(), $sformatf("m_child_class%0d", m_children.size() ) ) ) )
`uvm_error("TEST", "failed to create child")
m_children.push_back(child);
return child;
endfunction
endclass
but this fails and gives me the error:
Error-[IND] Identifier not declared
./my_class.sv, 30
Identifier ‘create_object’ has not been declared yet. If this error is not
expected, please check if you have set `default_nettype to none.
I’ve tried temporarily including the `uvm_object_utils and making the class non-virtual for testing (I still want it to be abstract class in the end) and receive the same error but I’m not sure why. It seems like I can call create_object and create_component from a uvm_component and not a uvm_object. Where am I going wrong?
I tried to play around with adding uvm_object_registry#(my_class, “my_class”) to no avail. It seems like I just cant find the create_object function.