Buid phase and config db set/get

Hi,

class user_env extends uvm_env;

axi_slave_env         m_slave_env;
axi_slave_env_cfg     m_slave_env_cfg;
..
..
// Inside Build phase of user_env  //
m_slave_env = axi_slave_env::type_id::create("slave_env");
m_slave_env_cfg = axi_slave_env_cfg::type_id::create("slave_env_cfg");

if (!uvm_config_db#(axi_slave_env_cfg)::get(this, "*", "uvc_cfg", m_slave_env_cfg))   
$display("ERROR");

endclass

class axi_slave_env extends uvm_env;

axi_slave             slave_uvc;
axi_slave_env_cfg     m_slave_cfg;

// Inside Build phase of axi_slave_env //
axi_slave_env_cfg.is_MASTER == MASTER;
..
..
slave_uvc = axi_slave::type_id::create("slave_uvc");

uvm_config_db#(axi_slave_env_cfg)::set(this, "*.slave_uvc", "uvc_cfg", slave_uvc_cfg);

endclass

I have few questions is it like buid_phase of user_env is triggered first → it completes and then axi_slave_env is build is triggered ?
per my understanding uvm_config we can get/set from anywhere in UVM hier may i know what is the issue ?

uvm_config_db#(axi_slave_env_cfg)::set(this, "*.slave_uvc", "uvc_cfg", slave_uvc_cfg);

—> is this correct way of restricting uvm_config db acess till m_user_env.m_slave_env.slave_uvc ?

In reply to xfinity:

Your set makes only child components of axi_slave_env with hierarchy as { axi_slave_env.get_full_name(),“*.slave_uvc” } having access to the slave_uvc_cfg.

As per your component hierarchy , user_env is parent component of axi_slave_env .
So essentially you are setting from a child component ( whose build_phase() is called later ) and getting in a parent component ( whose build_phase() is called earlier )

You are doing the get before the set is done ( also the hierarchy for the config via set is incorrect ) which is opposite to what is typically done ( i.e set from Top component and get in lower component )

In reply to xfinity:

You should re-work your configuration process. The intention is you are configuring your UVM environment from actual test and not from component deep in the hierarchy.