UVM top-down configuration

Hi All,

I have the following UVM env:

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 ?

thanks in advance,

In reply to dbaram:

You should always check the return value of the get() call. This will give you the first indication that something is wrong:


if(!uvm_config_db#(bit)::get(this,"","is_tx",is_tx)) begin
  uvm_error(...)
end 

In reply to dbaram:

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

drv.is_tx = is_tx;

In reply to cgales:

thanks cgales, it’s a simple configuration easy to detect the wrong set/get issues even the compiler can detect this.

In reply to chr_sue:

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.

In reply to dbaram:

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