Can we have an array of custom modules?

后端 未结 2 1457
情书的邮戳
情书的邮戳 2020-12-14 22:54

Can we have an array of instances for a custom module?

For example: we can have input [15:0] a; - this creates a bus. Can we do same thing for custom mo

2条回答
  •  粉色の甜心
    2020-12-14 23:38

    it is not possible to do this directly (update: now after mark4o's answer I know that there is a way), but what you can do is using the generate statement to create multiple instances of your custom module and hook them up to your signals. Should look something like this:

    wire DFF_i[15:0];
    wire DFF_o[15:0];
    
    generate
      genvar i;
      for (i=0; i<15; i=i+1) begin : dff
        custom i_custom(
           .clk(clk)
          ,.input(DFF_i[i])
          ,.output(DFF_o[i])
          );
      end
    endgenerate
    

    Otherwise there are probably some possibility during synthesis to use the correct custom modules, but I'm not an expert there.

    Cheers, Daniel

提交回复
热议问题