1. Chen Yong
  2. UVM
  3. Tuesday, 25 June 2019
In the example uvm-401, I added some code to try accessing component fields through uvm_config_db. I added these pieces of code:


class my_env extends uvm_env;
....
my_cfg dbg_m_cfg0;

virtual function void build_phase (uvm_phase phase);
....
if (!uvm_config_db#(my_cfg)::get(this,"","dbg_m_cfg0",dbg_m_cfg0))
`uvm_fatal(get_type_name(),"Can't get CFG object!!!")
endfunction : build_phase
......
endclass

class my_cfg extends uvm_object;
.....
rand int chk_pt;
....
endclass

class base_test extends uvm_test;
......
my_cfg my_test_cfg1;
int rd_back;
....
virtual function void build_phase (uvm_phase phase);
....
my_test_cfg1 = my_cfg::type_id::create ("my_test_cfg1", this);

// Make the cfg object available to all components in agent
uvm_config_db #(my_cfg) :: set (this, "m_top_env.my_agent", "m_cfg0", m_cfg0);
uvm_config_db #(my_cfg) :: set (this, "m_top_env", "dbg_m_cfg0", m_cfg0);

endfunction : build_phase
...

virtual function void end_of_elaboration_phase (uvm_phase phase);
// By now, the environment is all set up, just print the topology for debug
uvm_top.print_topology ();

// debug purpose, these uvm_config_db are put here
if (!uvm_config_db#(my_cfg)::get(this,"m_top_env","dbg_m_cfg0",my_test_cfg1))
`uvm_info(get_type_name(), $sformatf("can't open my_tst_cfg1"), UVM_LOW)
else
`uvm_info(get_type_name(), $sformatf("my_test_cfg1.chk_pt is %d",my_test_cfg1.chk_pt), UVM_LOW)

if (!uvm_config_db#(int)::get(this,"m_top_env.dbg_m_cfg0","chk_pt",rd_back))
`uvm_info(get_type_name(), $sformatf("can't chk_pt"), UVM_LOW)
else
`uvm_info(get_type_name(), $sformatf("chk_pt is %d",rd_back), UVM_LOW)
endfunction

......
endclass


My purpose is to set chk_pk in m_top_env.dbg_m_cfg0 through uvm_config_db. But it seems I could only access m_top_env.dbg_m_cfg0, not m_top_env.dbg_m_cfg0.chk_pt, as simulator shows:


UVM_INFO ./tb/test_pkg.sv(74) @ 0: uvm_test_top [base_test] my_test_cfg1.chk_pt is 0
UVM_INFO ./tb/test_pkg.sv(77) @ 0: uvm_test_top [base_test] can't chk_pt


Does this mean only field in component could be accessed through uvm_config_db, those fields in object can't be accessed? Can anybody help me to understand this? thanks
Accepted Answer
Accepted Answer Pending Moderation
You would need to set() the variable in the config_db with a given tag and a scope before you can get() it from config_db.

Think of config_db as a central area where you want to share a few items with some other members. You have put these items into a box and labeled it with a tag so that other members know which box to get based on the tag name. And assume the central area is divided into cubicles with certain members having access to certain cubicles. If you place the box into a given cubicle, all those members who have access to that cubicle will get the box. But members who come to the same cubicle looking for some other box with a different tag will not find what they came for.
  1. more than a month ago
  2. UVM
  3. # Permalink
Responses (4)
Accepted Answer Pending Moderation
It seems that you are trying to access a variable chk_pt of the class object dbg_m_cfg0 using a uvm_db_config::get() method. However you have not set anything in uvm_config_db under the tag "chk_pt" prior to calling the get().

Basically the uvm_config_db allows you to set an object using a tag that are accessible by members defined in the given hierarchical path. In your case, it does not find a tag called "chk_pt" in the database.

You can use +UVM_CONFIG_DB_TRACE as a command line tool option which is very helpful in debugging uvm_config_db pattern errors.
References
  1. https://www.chipverify.com/uvm/uvm-config-db-examples
  2. https://www.chipverify.com/uvm/uvm-config-db-examples-2
  1. more than a month ago
  2. UVM
  3. # 1
Accepted Answer Pending Moderation
Hi Admin,
thanks for your kind reply. My understanding is that if there is a variable defined in some place, you can use uvm_config_db to set/get it. Do you mean that my understanding is wrong, you could uvm_config_db::get() variable only after you uvm_config_db::set() it first? thanks.
  1. more than a month ago
  2. UVM
  3. # 2
Accepted Answer Pending Moderation
got it. Thank you very much
  1. more than a month ago
  2. UVM
  3. # 3
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

You consent to our cookies if you continue to use our website. To know more about cookies, see our privacy policy. I accept cookies from this site.

Agree