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.