如何在Verilog中用一个模块实例化两个模块?

如何在Verilog中用一个模块实例化两个模块?,verilog,Verilog,如何通过第三个模块实例化两个不同模块的副本 module instantiate (modx, mody); // ? endmodule 只需实例化它们添加实例化两次,块名为add\u 0add\u 1。对于不同的模块,只需实例化它们,就像在testharness中实例化主块一样 module add( input [31:0] i, //32 bit unsigned input [31:0] j, //32 bit unsigned output

如何通过第三个模块实例化两个不同模块的副本

module instantiate (modx, mody);
  // ?  
endmodule

只需实例化它们<代码>添加实例化两次,块名为
add\u 0
add\u 1
。对于不同的模块,只需实例化它们,就像在testharness中实例化主块一样

module add(
  input      [31:0] i, //32 bit unsigned
  input      [31:0] j, //32 bit unsigned 
  output reg [31:0] y  //32 bit unsigned
); 

  always @* begin
    y = i + j;
  end

endmodule

module instantiate (modx, mody);
  reg [31:0] a; //reg or wire depending on how it is driven
  reg [31:0] b;
  reg [31:0] c;
  reg [31:0] d;

  wire [31:0] sum1; //wire or logic as driven from an output port
  wire [31:0] sum2;

  add add_0(
    .i( a    ),
    .j( b    ),
    .y( sum1 )
  );

  add add_1(
    .i( c    ),
    .j( d    ),
    .y( sum2 )
  );

endmodule

你可以在这里找到有用的答案。