Why use uvm_config_db to pass vif or configuration object is recommended?

In reply to cgales:

Hi cgales,

I have some modifications with the idea of seabeam.

Instead of declare of automatic config object inside agent, I use static config object.

So config object of agent can be easily assign at test class before the agent component actually built.

→ Hence I see that when we used assignment config object directly is more effectively as we use uvm_config_db ( as seabeam pointout

I’v tried to set-get 10,000 integer from parent to child, which uvm_config_db() methord takes 2.1s CPU time & nearly 87M Mem while direct assignment 0.3s CPU time & 3.7M Mem.

Can you explain other reason to use uvm_config_db(), cgales?

Hi cgales:
Here is an example,
configuration object:
class x_agent_config extends uvm_object;
virtual x_if x_port;
uvm_active_passive_enum active = UVM_ACTIVE;
bit coverage_enable = 1’b1;

endclass : x_agent_config
agent
class x_agent extends uvm_agent;
x_agent_config cfg;

endclass : x_agent
perhaps an env level:
class simple_env extends uvm_env;
simple_env_config cfg;
x_agent x_agt;
y_agent y_agt;

function void build_phase (uvm_phase phase);
x_agt.cfg = cfg.x_agt_cfg;
y_agt.cfg = cfg.y_agt_cfg;
if (cfg.has_scoreboard)

endfunction : build_phase
endclass : simple_env
Then make a base class of cases:
class simple_case_base extends uvm_test;
simple_env env;
simple_env_config env_cfg;
x_agent_config x_agt_cfg;
y_agent_config y_agt_cfg;

function void build_phase (uvm_phase phase);
env_cfg = simple_env_config::type_id::create(“env_cfg”);
config_env(env_cfg);
x_agent_cfg = x_agent_config::type_id::create(“x_agent_cfg”);
config_x_agent(x_agent_cfg);
env_cfg.x_agent_cfg = x_agent_cfg;

env.cfg = env_cfg;
endfunction : build_phase
endclass : simple_case_base
In this situation, there is not many call. Instead, we use uvm_config_db(), we also need to call config_env() then use uvm_config_db’s set() methord. I’m confused that why don’t use direct assignment like above?
Thanks!