uvm_config_db#(T)::set(,string inst,,) string argument context with respect to new/create name argument

uvm_config_db#(T)::set(top.env,"agent",“var”,var)*

Above line decides scope of getting var at anywhere inside agent and any sub instances of agents.

Let’s say by mistakenly we have used different string while creating agent like below in env

agent = AGENT :: type_id :: create(“myagent”,this);

So the name “agent” mentioned in the scope also has to be updated to myagent or it will take as per instance name and not the argument passed ?

I actually got this doubt mainly due to first argument is of type uvm_component context and second is of string. And I also understand it will concatenate both to decide scope.

Please clarify.

In reply to jkpatel:

This line
agent = AGENT :: type_id :: create(“myagent”,this);
is really bad coding style, because it makes the debugging totally complicated. You’ll use the object name ‘agent’ but relly it takes ‘myagent’.
With respect to the scope you are right, but it is does not follow a good coding practice.
In most of all cases you are using as the 1st argument in the set/get command null’ or ‘this’. If you are using null the path defined in the 2nd argument is considered as an absolute path. If you are using ‘this’ the path is considered a a realtive path, starting from the actual object.

In reply to chr_sue:

Thanks , I understand it is bad practice and must be avoided but this is just to understand hierarchical way of how scope will get it’s details.

so, which scope will be taken from below 2.

scope1 : top.env.agent
scope2 : top.env.myagent

Thanks

In reply to jkpatel:

It uses scope 2:

top.env.myagent