V
vijay
Guest
I have a requirement to design a module with a customizable number of
submodules. I was thinking of using an array of interfaces at the
toplevel and for-generate to connect them to the submodules; with the
number of submodules passed as a parameter, while checking the
validity of the code I am getting compilation error from dc.
e.g. The code below compiles fine. but if we uncomment the first line
we get an error of " The name 'enc' is not a modport of the interface
instance actually provided on port 'ekIfc[0]'."
Is there some way of achieving the intended result?
//****************** Start Code ********************************
//`define array
`ifndef array
`define index
`define parindex
`define forloopbegin
`define forloopend
`else
`define index
`define parindex [numInstance]
`define forloopbegin for(i=0;i<numInstance;i=i+1) begin
`define forloopend end
`endif
interface ioIfc;
logic encryptedData;
logic decryptedData;
modport enc(input decryptedData,output encryptedData);
modport dec(output decryptedData,input encryptedData);
endinterface
module ek(ioIfc.enc enc);
endmodule
module dk(ioIfc.dec dec);
endmodule
module top#(numInstance=5)(
ioIfc.enc ekIfc `parindex,
ioIfc.dec dkIfc `parindex
);
genvar i;
generate
`forloopbegin
ek ek(.enc(ekIfc`index));
dk dk(.dec(dkIfc`index));
`forloopend
endgenerate
endmodule
//****************** End Code ********************************
submodules. I was thinking of using an array of interfaces at the
toplevel and for-generate to connect them to the submodules; with the
number of submodules passed as a parameter, while checking the
validity of the code I am getting compilation error from dc.
e.g. The code below compiles fine. but if we uncomment the first line
we get an error of " The name 'enc' is not a modport of the interface
instance actually provided on port 'ekIfc[0]'."
Is there some way of achieving the intended result?
//****************** Start Code ********************************
//`define array
`ifndef array
`define index
`define parindex
`define forloopbegin
`define forloopend
`else
`define index
`define parindex [numInstance]
`define forloopbegin for(i=0;i<numInstance;i=i+1) begin
`define forloopend end
`endif
interface ioIfc;
logic encryptedData;
logic decryptedData;
modport enc(input decryptedData,output encryptedData);
modport dec(output decryptedData,input encryptedData);
endinterface
module ek(ioIfc.enc enc);
endmodule
module dk(ioIfc.dec dec);
endmodule
module top#(numInstance=5)(
ioIfc.enc ekIfc `parindex,
ioIfc.dec dkIfc `parindex
);
genvar i;
generate
`forloopbegin
ek ek(.enc(ekIfc`index));
dk dk(.dec(dkIfc`index));
`forloopend
endgenerate
endmodule
//****************** End Code ********************************