How to get config object from config db to the tb_top

I have some forces (interface to dut) in my tb_top file.

For example:

      // rx forces and assignments
   assign rx_vif.chind2 = dut.rx_fe.chind2;
      initial begin
                force dut.rx_fe.x = rx_vif.x;
      end
   end

I want to execute above only if the rx_agent is active.

For this I have to get the rx_agent_config object to the tb_top like this (in initial block):

if(!uvm_config_db #(rx_agent_config)::get(this, "", "db_rx_agent_config", m_rx_cfg)) begin `uvm_error("top", "rx_agent_config not found") end//if

What should I write instead of this (in the get function)?


I did the set in the env by:

uvm_config_db #(rx_agent_config)::set(this, "*", "db_rx_agent_config", m_cfg.m_rx_agent_cfg);

In reply to saritr:

//Set with null context and "*" visible everywhere
uvm_config_db #(rx_agent_config)::set(null, "*", "db_rx_agent_config", m_rx_cfg)


//If you have delta delay/finite amount of delay before setting
//the config obj
//Wait till configuration object is modified by agent
//use null context again for module 
uvm_config_db #(rx_agent_config)::wait_modified(null, "*", "db_rx_agent_config")

void'(uvm_config_db #(rx_agent_config)::get(null, "", "db_rx_agent_config", m_rx_cfg))


//Alternate way is to use small delay before getting the
//object in module initial block
initial
begin
  #1;
  if(!uvm_config_db #(rx_agent_config)::get(null, "", "db_rx_agent_config", m_rx_cfg))
    `uvm_error("top", "rx_agent_config not found")
end

In reply to MayurKubavat:

The get command in the initial block cannot use ‘this’. It should be ‘null’!

In reply to MayurKubavat:

I set the rx_agent_config in the env. It should be with this, not null.

Regarding
//Alternate way is to use small delay before getting the
//object in module initial block

initial
begin
  #1;
  if(!uvm_config_db #(rx_agent_config)::get(this, "", "db_rx_agent_config", m_rx_cfg))
    `uvm_error("top", "rx_agent_config not found")
end

It doesn’t recognize “this” when I try to compile

In reply to chr_sue:
I did the following:

   // tx_fe forces and assignments
   assign tx_vif.cyc_tic = dut.tx_fe.cyc_tic_internal;
   initial begin
      start_of_simulation_ph.wait_for_state(UVM_PHASE_STARTED);      
      if(!uvm_config_db #(tx_agent_config)::get(null, "uvm_test_top.env",  "db_tx_agent_config", m_tx_cfg)) begin
      `uvm_error("top", "tx_agent_config not found")
	end//if
      if (m_tx_cfg.is_active == UVM_ACTIVE) begin 	 
	 force dut.tx_fe.xi_n = tx_vif.xi;
	 force dut.tx_fe.xq_n = tx_vif.xq;
      end
   end
   
 
   // rx_fe forces and assignments
   assign rx_vif.chind2 = dut.rx_fe.chind2;
   initial begin
      start_of_simulation_ph.wait_for_state(UVM_PHASE_STARTED);      
      if(!uvm_config_db #(rx_agent_config)::get(null, "uvm_test_top.env",  "db_rx_agent_config", m_rx_cfg)) begin
      `uvm_error("top", "rx_agent_config not found")
	end//if  
      if (m_rx_cfg.is_active == UVM_ACTIVE) begin  	 
	 force dut.rx_fe.x = rx_vif.x;
      end
   end

I got error when I try to run this:
UVM_ERROR …/sv/girobo2_tb_top.sv(175) @ 0: reporter [top] rx_agent_config not found

In reply to saritr:

This is correct. You are in the top-level module of your UVM testbench. This module does not know anything about the path uvm_test_top.env.
Please try
get(null, “”, “db_rx_agent_config”, m_rx_cfg)

In reply to chr_sue:

Same error:\

In reply to saritr:
You have to wait for certain time before issuing the get:
initial
begin
#1;
if(!uvm_config_db #(rx_agent_config)::get(null, “”, “db_rx_agent_config”, m_rx_cfg))
`uvm_error(“top”, “rx_agent_config not found”)
end

In reply to chr_sue:

i wait…
start_of_simulation_ph.wait_for_state(UVM_PHASE_STARTED);

I tried also #1, and still got the error.

In reply to saritr:

For any beginners out there reading this thread, if you change code, then you need show what changes have been made. One can not debug code without seeing it. In this posting, one would have to see the current set & get lines of code and the error that they generated to determine why they are not working - this should be common sense for all UVM users. If you are unable to ‘get’, maybe the context & inst_name in ‘set’ are not correct (the poster says that they used ‘this’ as the context which would be incorrect, Mayur correctly posted how to use the ‘set’ in this case). It’s hard to tell if the user followed this suggestion without the code.

In reply to saritr:

This is interesting as you are not getting error for tx_agent_config. Check settings for rx_agent_config!

In reply to dhserfer:

I edited the question, and added how I did the set.

In reply to MayurKubavat:

When I changed the order of the get (rx, and then tx) I got error regarding the tx.

In reply to saritr:

mayur’s first reply to your post was correct:

uvm_config_db #(rx_agent_config)::set(null, "*", "db_rx_agent_config", m_rx_cfg)
uvm_config_db #(rx_agent_config)::get(null, "", "db_rx_agent_config", m_rx_cfg)

In reply to dhserfer:

Why Should it be null in the set, and not this?

In reply to saritr:

null is indicating you are using an absolute path.
this means a relative path.

In reply to chr_sue:

So the combination of this and “" means that all the objects which down in the hirerachy (down to env in my case) will “know” the config object, whereas the combination of null and "” means that all objects (up and down in the hirerachy)will “know” the config object?

In reply to saritr:

this post has a link to a verilabs paper on the uvm_config_db. I would recommend reading it. For the ‘set’ method, ‘this’ is the starting point of accessibility, not the end.

In reply to dhserfer:

Please see my response to chr_sue. Did I understand correctly?

In reply to saritr:

In reply to chr_sue:
So the combination of this and “" means that all the objects which down in the hirerachy (down to env in my case) will “know” the config object, whereas the combination of null and "” means that all objects (up and down in the hirerachy)will “know” the config object?

Yes. That’s the intention.

If error persists there might be two reasons,

  • config_db get is being called before setting is done.
  • String path to the env instance is not correct.