I've got a parametrized interface with clock input. For example :
interface itf # (PARAM1 = 16, PARAM2 = 8)(input logic clk);
This interface has a modport called "slave".
My module takes an array of this interface as an input (modport "slave").
module MyModule #(NB_ITFS = 4)(... itf.slave itfs[NB_ITFS]...);
In a testbench module for MyModule, I would like a generic code that is able to test different values of NB_ITFS.
Question : how to create my array of interfaces for MyModule instanciation (taking into account the fact that elements have different parameters) ?
For example, I tried to use a generate statement :
module testbench()
...
generate
genvar i;
for (i = 0; i < NB_ITFS; i++)
begin : interfaces
itf #(.PARAM1(PARAM1_TABLE[i]),
.PARAM2(PARAM2_TABLE[i])) itf_inst (.clk(clk));
end
endgenerate
...
endmodule
But in this case, the interface array is interfaces[xxx].itf_inst (and .slave if I want to select the "slave" modport) and the instanciation of MyModule using interfaces[NB_ITFS].itf_inst.slave raises an error.
I also tried without success:
- a generic definition itf itf_inst[NB_ITFS] (.clk(clk)); and tried to modify the parameters using defparam inside a generate block
- "virtual interface" feature
Any suggestion ?