Set parameterized virtual interface for an array of agents

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

interface trig_if #(parameter width=16) (input clk, input reset);
    logic [width-1 :0] en;
    logic [width-1 :0] trig_out;
endinterface
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
//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
//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.

In reply to Harini Madheswaran:

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);

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

In reply to Harini Madheswaran:

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.