accessing interfaces created using "generate" statement

N

noob

Guest
Hi,
I have used generate to create interface for my module. There are 3 instances of this module so I need 3 different interfaces. The code snippet is following:

parameter NUM_MOD=3;

genvar i;
generate
for (i=0 ; i<(NUM_MOD-1) ; i++)
begin: MOD_IF

module_if mod_if(clk);
module_bfm_wrapper mod_bfm(mod_if);

tran ip1 (tb_input1, mod_if.input1);
tran ip2 (tb_input2, mod_if.input2);
tran op (tb_output, mod_if.output);

end
endgenerate

Now in env file i'm accessing the interfaces as shown below:

virtual module_if vif [0:NUM_MOD-1];

for (i=0;i<NUM_MOD;i++)
begin
vif = testbench.(hierarchy).MOD_IF.mod_if;
end

Here, the i in MOD_IF is not getting replaced by numbers, instead it is taken as string and causing error MOD_IF can't be found.

Can someone suggest any other way to do it? I'm stuck here.
Currently, I'm hardcoding it but I have to make it generic, so if in future the number of module change it should automatically generate that many interfaces.
 

Welcome to EDABoard.com

Sponsor

Back
Top