Multiple agent with multiple interface

Hi,
I need to have multiple instantiation of an object and array of interface.
During build_phase multiple agent will be created according to configuration and each agent will be assigned an interface according to configuration from array of interface.

How to set array of interface in uvm_config_db in top module and how to get an interface from array of interface from the config_db assign to agent.

Please recommend a way.

It is recommended that the agent’s configuration object should contain the virtual interface handle for that agent. This precludes you from having to determine the where the agent exists in the hierarchy and allows your environment to pass the agent configuration object to the correct agent.

The flow will be:

  • The HDL module will instantiate interfaces and connect appropriately
  • The interfaces will be passed to the top level test via the uvm_config_db with unique names.
  • The test will create the environment config object, which will in turn contain the agent configuration object for each agent.
  • The test will get the interface for each agent from the uvm_config_db and store it in each agent’s configuration object.
  • The environment will pass the agent’s configuration object to the agent using the uvm_config_db
  • The agent will get it’s unique configuration object and get it’s virtual interface handle from the configuration object.

In reply to cgales:

Hi Cgales,
Thanks for replying .If you can give some coding example then it will be much clear.
Another thing is that agent_0 can be assigned interface_3 or agent_1 can be assigned interface_0 i,e the interface assignment depends on configuration.
Can we do that ?

Hello Sidharth,
Number of interface can’t be random.Number of interfaces must be constant.
But it is possible that,out of those interfaces DUT could use few if not all.

Probably you can set all possible interfaces in config db.Depending on number of agents you can get interfaces randomly from config db .But you have to make sure “never get same interface multiple times”.

Otherwise you can set a single interface but that interface must contain array of interface signal(array size must be same as max number of interfaces).Depending on agent you can select a array member(then this array member will get fixed for other interface signal for an agent) and can be driven from your driver.

Kiran

I’ve found it best to use a generate block and use $psprintf or $sformat for an iterator.

interface abc #(int WIDTH=1);
endinterface

psuedo code (please check my syntax)

–in top.sv—
genvar ii
generate
for (ii=0; ii<`NUM; ii++) begin GEN_IFS
abc_if #(8) m_abc_if();
initial // YES! This will run before run_test because run_test has a #0 somewhere
uvm_config_db(#virtual abc_if#(8))::set(uvm_root::get(), $sformat(“GEN_DUT[%0d].*”, ii, GEN_IFS[ii].abc_if
endgenerate

—in scoreboard/agent-----
virtual abc#(NUM_param) abc_vif;
int phase; // set in the cfg by the env as part of env::build()

function build();
uvm_config_db #(virtual abc_if#(NUM_param))::get(uvm_root::get(), $sformat(“*GEN_DUT[%0d].”, phase, abc_vif);