Connecting one among the many virtual interfaces to the driver

Hi

I m creating an agent of which i would require four instances to connect via four instances of the virtual interface to the dut.
How can i chose which interface to connect to the driver?
Can anyone provide me an example on how to do it?

Regards
Meenakshy

I assume that you mean you will have four instances of the driver, driving four instances of the same interface on the DUT.

The basic recipe is as follows:

  1. In the top level testbench module, connect the four interfaces to the DUT, each one will have a different instance name
  2. In the top level testbench module, put the virtual interface handle for each interface instance in the uvm_config_db, with a unique lookup string for each virtual interface.
  3. In the test, get each virtual interface handle and put it into the config object for the agent that you want to drive it with, then set the config object so that the path matches the agent’s position in the testbench hierarchy.

You can find further details here:
https://verificationacademy.com/cookbook/Connect/Virtual_Interface

And here:
https://verificationacademy.com/cookbook/Testbench/Build

In reply to mperyer:

Hi
What you interpreted is correct.

  1. I did the connections of the four interfaces of type signals_interface
    signals_interface m1_intf;
    signals_interface m2_intf;
    signals_interface m3_intf;
    signals_interface m4_intf;

2)I have put them into the config_db
uvm_config_db #(virtual signals_interface)::set(null,“uvm_test_top”,“m1_intf”,m1_intf);
uvm_config_db #(virtual signals_interface)::set(null,“uvm_test_top”,“m2_intf”,m2_intf);
uvm_config_db #(virtual signals_interface)::set(null,“uvm_test_top”,“m3_intf”,m3_intf);
uvm_config_db #(virtual signals_interface)::set(null,“uvm_test_top”,“m4_intf”,m4_intf);

3)In the environment, I get the virtual interface handles
if(!(uvm_config_db #(virtual signals_interface)::get(null,“uvm_test_top”,“m1_intf”,m1_intf))
`uvm_fatal(“cfg not found”)
uvm_config_db #(virtual signals_interface)::set(null,“m1_env.agent_h.config_h”,“m1_intf”,this.m1_intf);
//putting into config of each agent

I have repeated the above for the other three interfaces
Is point 3 the right way of doing it?

Step 3 doesn’t look right to me.

Inside the config object for each of your agents you should have a virtual interface handle, you assign that via the uvm_config_db and then pass the config object to your agent.

class my_agent_config extends uvm_object; // .... virtual my_if VIF; // .... endclass

// Somewhere, usually in the test:
my_agent_config agent_1_cfg;
if(!(uvm_config_db #(virtual my_if)::get(null,“uvm_test_top”,“m1_intf”,agent_1_cfg.VIF))
`uvm_fatal()
uvm_config_db #(my_agent_config)::set(this, “<path_to_agent_1>”, “my_agent_config”, agent_1_cfg);

Where my_agent_config is common to all my_agents.

If you look through the example pages previously quoted you should see this approach described.