in the test I have two agents instances, for both I would like to pass a specific value to “is_tx” field from the test, then pass it to driver from the agent as the following:
class test_base extends uvm_test;
`uvm_component_utils(test_base)
rngbus_agent agent_tx;
rngbus_agent agent_rx;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
uvm_config_db#(bit)::set(this,"agent_tx","is_tx",1);
uvm_config_db#(bit)::set(this,"agent_rx","is_tx",0);
agent_tx = rngbus_agent::type_id::create("agent_tx", this);
agent_rx = rngbus_agent::type_id::create("agent_rx", this);
endfunction: build_phase
enclass: test_base
class rngbus_agent extends uvm_agent;
`uvm_component_utils(rngbus_agent)
rngbus_driver drv;
bit is_tx;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
uvm_config_db#(bit)::get(this,"","is_tx",is_tx);
uvm_config_db#(bit)::set(this,"drv","is_tx",is_tx);
drv = rngbus_driver::type_id::create("drv", this);
endfunction: build_phase
endclass: rngbus_agent
class rngbus_driver extends uvm_driver #(rngbus_item);
int data_index;
bit is_tx;
`uvm_component_utils(rngbus_driver)
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
uvm_config_db#(bit)::get(this,"","is_tx", is_tx);
endfunction: build_phase
what’s the wrong with the “is_tx” configuration, in a way that I get always is_tx= 0 for both agent_tx.drv.is_tx and agent_rx.drv.is_tx ?
what’s the wrong with the “is_tx” configuration, in a way that I get always is_tx= 0 for both agent_tx.drv.is_tx and agent_rx.drv.is_tx
You are passing with same name(string) 2 different values. The 2nd one is overriding the first one. It is completely correct what you are getting. You have to use 2 different names, like is_tx, is_rx, then it is working.
BTW you do not need to perfrom another set, because you can pass this field through the hierarchy from the agent like this
thanks chr_sue, I don’t believe that I must use two different variables since there are two different instances agent_tx and agent_rx and for each I did a dedicated configuration.
In fact I don’t really know what’s happened (I fixed something in the RX/TX sequences related to objection) the above code worked without the reported problem I’m so confused I tried to reproduce the problem I didn’t succeed.
I will keep you updated once I understand the origin of the issue.
I too don’t agree with what chr_sue is saying. This is the rule when using config_db:
The important thing to remember is that each entry needs a unique field name
or label (if the global scope is being used), or the path needs to
be limited in such a way that non-unique labels do not conflict
as the scopes are now limited to specific areas of the naming
hierarchy
The above is courtesy this paper - Demystifying the UVM Configuration Database