I have following lines of Verilog code:
mySwitch simblock_out_a_inst0 (.aa(simblock_if_h[0].simblock_out_a),.bb(BLOCK_out_a_inst0),.CloseIfHi(simblock_if_h[0].enable));
mySwitch simblock_out_b_inst0 (.aa(simblock_if_h[0].simblock_out_b),.bb(BLOCK_out_b_inst0),.CloseIfHi(simblock_if_h[0].enable));
mySwitch simblock_out_c_inst0 (.aa(simblock_if_h[0].simblock_out_c),.bb(BLOCK_out_c_inst0),.CloseIfHi(simblock_if_h[0].enable));
mySwitch simblock_out_d_inst0 (.aa(simblock_if_h[0].simblock_out_d),.bb(BLOCK_out_d_inst0),.CloseIfHi(simblock_if_h[0].enable));
mySwitch simblock_out_a_inst1 (.aa(simblock_if_h[1].simblock_out_a),.bb(BLOCK_out_a_inst1),.CloseIfHi(simblock_if_h[1].enable));
mySwitch simblock_out_b_inst1 (.aa(simblock_if_h[1].simblock_out_b),.bb(BLOCK_out_b_inst1),.CloseIfHi(simblock_if_h[1].enable));
mySwitch simblock_out_c_inst1 (.aa(simblock_if_h[1].simblock_out_c),.bb(BLOCK_out_c_inst1),.CloseIfHi(simblock_if_h[1].enable));
mySwitch simblock_out_d_inst1 (.aa(simblock_if_h[1].simblock_out_d),.bb(BLOCK_out_d_inst1),.CloseIfHi(simblock_if_h[1].enable));
The above does work. But the above is for just 2 instances and the code can increase with multiple instances, which I am looking to avoid. Also, I would like to have the number of instances parameterized.
I was thinking of using generate
statement, but due to net names like BLOCK_out_d_inst1
(i.e. in non-array format), I'm unaware of how to implement that.
Any suggestions? Can I create a variable say, var_net
, and use its value as a net? E.g.:
var_net = BLOCK_out_d_inst1;
mySwitch simblock_out_d_inst1 (.aa(simblock_if_h[1].simblock_out_d),.bb(var_net),.CloseIfHi(simblock_if_h[1].enable));