Better place to get the interface through config_db

Hi All,

I just wanted to have some ideas on the better place for the uvm_components to get the interface through config_db below are the two ways.

Method I:
//call the uvm_config_db in respective uvm_component’s like driver,monitor’s “build_phase” as below
if (!uvm_config_db#(virtual SBus)::get(this, “”, “Sbus_if_h”, Sbus_if_h)) begin
`uvm_fatal(“repective_component”, “No virtual interface specified for this driver instance”)
end

Method II:
//call the uvm_config_db for all the uvm_component’s like driver,monitor to get the interface in the agents build_phase as below
//In the agents build_phase
driver drv;
monitor mon;

mon = monitor::type_id::create(“mon”, this);
drv = driver::type_id::create(“drv”, this);

//Driver gets the interface
if (!uvm_config_db#(virtual SBus)::get(this, “”, “Sbus_if_h”, drv.Sbus_if_h))
begin
`uvm_fatal(get_type_name(), “DRIVER Could not get the SBUS interface for config”)
end

//Monitor gets the interface
if (!uvm_config_db#(virtual SBus)::get(this, “”, “Sbus_if_h”, mon.Sbus_if_h))
begin
`uvm_fatal(get_type_name(), “MONITOR Could not get the SBUS interface for config”)
end

I feel method II is better as it makes each uvm_component independent of get interfaces and just by reading the agents file others can get the better observability rather than going to each components file for observing.

So,Your suggestions on this…

Thanks…

In general, your second method is better than the first, but there’s no need to repeat the expensive uvm_config_db #(xxx)::get() call more than you have to. A better partitioning strategy is to put the virtual interface into the agents config object and only do one get() from the uvm_config_db.

See the following page for an example of how to do this:

https://verificationacademy.com/cookbook/Agent