Getting the virtual interface in the test class or in the agent?

Hello,

I would like to ask a question which could be more philosophical or religious than technical, I am not really sure.
Here is the point:

  • we set a virtual interface in the config_db in the physical test bench
  • in the agent config class, we have a virtual interface pointer

Traditionally, I get the virtual interface in the base test class, in which I have agent configs (because I potentially configure agents from the test), and I do the assignment of the agent config VIF to that object retrieved from the config_db inside that base test class build phase, like:

if (!uvm_config_db #(virtual power_if)::get(this, "" , "m_power_vif", this.m_power_config.vif)) begin
    `uvm_fatal(get_type_name(), "Power virtual interface not set for m_power_config")
end
this.m_env_config.m_power_config = this.m_power_config;

However, it is also possible not to do that, and do the get of the VIF from the config_db inside the agent build phase.

So, is there a good reason to choose one method rather than the other? Any advantages? Caveats? I also assume that commercial VIPs would not necessarily be consistent about it.

Thanks in advance.

My approach is to specify that each agent has a configuration object which contains all functional parameters along with the vif handle. The agent will retrieve the configuration object from the config_db. There is no other mechanism to pass the vif handle to the agent, so the only option is to pass it to uvm_test_top and have the test responsible for mapping all vif’s to the appropriate agents.

Of course, this may vary with the UVC designer, but you will find that most modern UVCs follow this approach.