What are the guidelines on using uvm_config_db::get() calls inside a uvm_object

In reply to dave_59:

Thanks Dave!

Hi Chr_sue
The following is the illustration of what I meant my replicate . And one which I wanted to avoid …

//Cfgobject code
class cfgObj extends uvm_object;
`uvm_object_utils(cfgObj)

rand int x;
rand int y;

function new(string name = “cfgObj”);
super.new(name);
//This is the place I want to read the vaue of x from cmd line and set rand_mode(0) for x
endfunction : new

endclass : cfgObj

//component code
class myComp extends uvm_component;
uvm_component_utils_begin(myComp) uvm_component_utils_end

cfgObj myObj;

function void build_phase(uvm_phase phase);
int x_comp; // This is what I meant by replication … if cfgObj has 20 var, I need to have those here…

super.build_phase(phase);
myObj = cfgObj::type_id::create(“myObj”);

uvm_config_db#(int)::get(null, get_full_name(),“xfgObj_x”, x_comp);
myObj.randmoze() with {x == x_comp;};

endfunction : build_phase

endclass : myComp