class base_config extends uvm_object;
//
endclass
class top_config extends uvm_object;
base_config b_cfg[];
integer c_size;
//In which phase can i do b_cfg =new(c_size);
//for(int i=0; i < c_size; i++) begin
//b_cfg[i]= base_config::type_id::create($sformatf("base_cfg_%0d",b_cfg));
//end
endclass
class test extends base_test;
top_config top_cfg;
//if i want to pass c_size from the test like top_cfg.c_size = 4
//in which part of the top_configuration class should i initialize the array. Array
//components are built and initialized in the build_phase if i'm not wrong but the c_size
//component cannot be initialized then. My best bet is to initialize this array before the
//simulation hits the run phase? how can i achieve this?
endclass
In reply to markiv:
Classes not derived from uvm_component do not have phases. You just need to construct objects before using them. You can do it as part of setting the size:
class top_config extends uvm_object;
base_config b_cfg[];
int c_size;
function void set_c_size(int size);
b_cfg= new[(c_size = size)];
foreach (b_cfg[i]) b_cfg[i]= base_config::type_id::create($sformatf("base_cfg_%0d",b_cfg));
endfunction
endclass
You can so this in your test in any base before the run_phase: build_, end_of_elaboration_, start_of_simulation_ phase.
In reply to dave_59:
Thanks for the response dave!
Okay, that is what i figured when i was looking at the uvm_object function definitions in uvm1.1.
Just wanted to clarify, to be able to construct the b_cfg i need to add the top_config class to my base test and call the set_c_size() function in any one of the phases before run_phase in my derived tests?