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

Hi

I am trying to find the answer for the following question.

Is it advisable to use uvm_config_db::get() functions inside constructor of a uvm_object ?

I need to set the variables of a uvm object from command line and I would prefer to no use the component to get the variables and call
obj.randomize() with {obj_var == var_from_cmd_line;};

Thanks
Venkatesh

In reply to Venkatesh Maddibande Sheshadrivasan:

It’s not recommended to get the configuration inside uvm_object constructor because to get the configuration inside the sequence we call the get method as shown below

uvm_config_db#(int)::get(null, get_full_name(),"int", var)

As in components, in objects to get the configuration we should not provide empty quotes as a second argument because objects don’t have a hierarchy. Instead, we use get_full_name as the second argument that returns the path of the sequencer on which the sequence is started.

If the get method is called in the constructor, get full_name() can not return the path & get fails as the sequence is not yet started.

Once the sequence is started then the get method should be called, so the get method should be called from the task body before the sequence item is randomized as the task body is called by start.

In reply to shanthi:

Hi Shanthi

I was using the uvm_object as a config object to hold the configurations of an agent and not as a sequence item

Thanks
Venkatesh

In reply to Venkatesh Maddibande Sheshadrivasan:

In this case you are doing the get in the build_phase of the corresponding component before you need the config data.

In reply to chr_sue:

Then I would have to replicate the variables in the component which is what I was planning to avoid.

In reply to Venkatesh Maddibande Sheshadrivasan:

I don’t understand what you mean with replicate.

In reply to Venkatesh Maddibande Sheshadrivasan:

You can use the uvm_config_db from where ever you want. You can even use it outside of a UVM testbench. You just need to make sure that set() comes before get(), and understand how the path matching strings work. Just remember that the settings from the command line don’t get applied until you call run_test().

We do recommend that you limit the number of config variables you have and the frequency of calling get() since there is a lot of overhead in searching for values.

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

In reply to Venkatesh Maddibande Sheshadrivasan:

In a uvm_component you do not randomize anything. Therefore I do not understand why you want to switch-off the randomization of a config_object variable.
And the build process for an object like aseq_item/sequence or config_object does not happen in the build_phase, because it does not exist there.

In reply to chr_sue:

Hi Chr_sue

We are using the uvm_object to hold values which will be eventually consumed to program registers as well as checkers (ex: feature enable/disable)

w.r.t rand_mode
If we override via cmd line then the randomization must not affect the variable which we set via cmd line. Hence we turn off the rand_mode for that particular variable.

Thanks
Venkatesh

In reply to Venkatesh Maddibande Sheshadrivasan:

I believe it is not a good idea to employ the command line processor for running the standard verification like regressions. This adds additional effort to maintain and archive simulator command lines. I consider the options from the command line as very useful during the testbench/sequence development to try out/modify something.

In reply to Venkatesh Maddibande Sheshadrivasan:

HI Venkatsh,
Can you enlightem me on how to get something into an object using uvmconfigdb set and get methods? What can be the first and set arguments for the set and get methods? Thanks

In reply to Srinadh:

Easy uvm_config_db use: A simplified and reusable uvm_config_db methodology for environment developers and test writers: Paper-link Poster-link