# Set parameterized virtual interface for an array of agents

**URL:** <https://verificationacademy.com/forums/t/set-parameterized-virtual-interface-for-an-array-of-agents/39212>\
**Category:** UVM\
**Tags:** UVM, UVM-Parameter-virtual\_interface\
**Created:** [June 21, 2021, 9:34am UTC](https://verificationacademy.com/forums/t/set-parameterized-virtual-interface-for-an-array-of-agents/39212 "2021-06-21T09:34:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HariniMadheswaran](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/87869e/32.png) [@HariniMadheswaran](https://verificationacademy.com/forums/u/HariniMadheswaran)\
**Post date:** [June 21, 2021, 9:34am UTC](https://verificationacademy.com/forums/t/set-parameterized-virtual-interface-for-an-array-of-agents/39212/1 "2021-06-21T09:34:05Z")

</div>

I am trying to create virtual interface with parameterized value for an array of agents.

```auto
interface trig_if #(parameter width=16) (input clk, input reset);
    logic [width-1 :0] en;
    logic [width-1 :0] trig_out;
endinterface

```

```auto
module tb_top; 
..
..
trig_if #(.width(16)) trig1;
trig_if #(.width(8)) trig2;
trig_if #(.width(9)) trig3;
...

uvm_config_db#(virtual trig_if#(16))::set(null, "uvm_test_top.env.tagent[0].*", "trig_vif", trig1);
uvm_config_db#(virtual trig_if#(8))::set(null, "uvm_test_top.env.tagent[1].*", "trig_vif", trig2);
uvm_config_db#(virtual trig_if#(9))::set(null, "uvm_test_top.env.tagent[2].*", "trig_vif", trig3);
..
endmodule

```

```auto
//Env
class env extends uvm_env;
..
agent tagent[];//dynamic array
..
tagent = new[3];
..
for (int i=0; i < 3; i++) begin
  tagent[i] = agent::type_id::create($sformatf("tagent[%0d]",i), this);
end
..
endclass

```

```auto
//driver
class driver extends uvm_driver;
virtual trig_if vif;
config cfg;
..
..
//cfg get
...
//vif get
if(!uvm_config_db#(virtual trig_if)::get(this, "", "trig_vif", vif))
  `uvm_fatal("NOVIF", {"Virtual interface must be set for: ", get_full_name(), ".vif"})
..

task run_phase()
....
vif.en=1;
foreach(vif.en[i])
begin
 if(vif.en[i] == 1)
  vif.out[i] = cfg.force_value ;
 else
  vif.out[i] = cfg.default_value;
end
....
endtask
endclass

```

Error msg: Virtual interface must be set for:uvm\_test\_top.env.tagent[1].driver

From this error, my understanding is the virtual interface created inside the driver getting 16 as width instead of the exact parameterized width which is 8.

How to pass the parameter value to agent/driver without parameterizing the agent/driver class as driver is generic?

Can anyone have idea on this please let me know.

---

<div class="post-metadata">

**Author:** ![Desam](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@Desam](https://verificationacademy.com/forums/u/Desam)\
**Post date:** [June 21, 2021, 9:57am UTC](https://verificationacademy.com/forums/t/set-parameterized-virtual-interface-for-an-array-of-agents/39212/2 "2021-06-21T09:57:36Z")

</div>

_In reply to [Harini Madheswaran](https://verificationacademy.com/forums/t/set-parameterized-virtual-interface-for-an-array-of-agents/39212):_

i think you pushing interface handle to config db only for agent[0]

uvm\_config\_db#(virtual trig\_if#(16))::set(null, “uvm\_test\_top.env.tagent[0]._", “trig\_vif”, trig1);  
uvm\_config\_db#(virtual trig\_if#(8))::set(null, "uvm\_test\_top.env.tagent[0]._”, “trig\_vif”, trig2);  
uvm\_config\_db#(virtual trig\_if#(9))::set(null, “uvm\_test\_top.env.tagent[0].\*”, “trig\_vif”, trig3);

---

<div class="post-metadata">

**Author:** ![HariniMadheswaran](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/87869e/32.png) [@HariniMadheswaran](https://verificationacademy.com/forums/u/HariniMadheswaran)\
**Post date:** [June 21, 2021, 10:40am UTC](https://verificationacademy.com/forums/t/set-parameterized-virtual-interface-for-an-array-of-agents/39212/3 "2021-06-21T10:40:43Z")

</div>

It is typo. I have updated the code and getting same error.

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [June 21, 2021, 11:48am UTC](https://verificationacademy.com/forums/t/set-parameterized-virtual-interface-for-an-array-of-agents/39212/4 "2021-06-21T11:48:28Z")

</div>

_In reply to [Harini Madheswaran](https://verificationacademy.com/forums/t/set-parameterized-virtual-interface-for-an-array-of-agents/39212/3):_

You need to parameterize your interface in the agent to match the interface being passed via the config\_db. Typically, you will parameterize your agent and use the agent parameter for your interface.

If for some reason you don’t want to parameterize your agent, the best option is to remove the parameter from the interface and make the signal widths the maximum your interface can support, and only connect the required bits.
