Verilog - 尝试复制另一个模块的输出时出现不匹配错误

Verilog - Getting a mismatch error trying to replicate output of another module

我正在尝试设计一个 fifo,它最多接受 N=4 个字并且每个字的位宽为 M=2。 我首先设计了一个 1 位宽的字 fifo,我正试图将它用于更宽的字 fifo。我在调试行

时遇到问题
single_fifo fArr[M-1:0]({M*{clk}},{M*{reset}},in,{M*{push}},{M*{pop}},out,full_string);

同时出现以下错误:

ncelab: *E,PCAVDM (./fifo.v,85|27): Vector length of port connection expression (32) in array of instances does not match product of number of instances (2) and port length (1). single_fifo fArrM-1:0;

我的代码没有任何 32 位长的东西,所以我对这个错误很困惑。

我的代码:

 module fifo(clk, reset, in, push, pop, out, full);
   parameter N=4; // determines the maximum number of words in queue.
   parameter M=2; // determines the bit-width of each word, stored in the queue.

   input clk, reset, push, pop;
   input [M-1:0] in;
   output [M-1:0] out;

   wire [M-1:0] full_string;
   output full;
   wire full;

   single_fifo fArr[M-1:0]({M*{clk}},{M*{reset}},in,{M*{push}},{M*{pop}},out,full_string);

   assign full=|full_string;

endmodule

如果需要,我还会添加 single_fifo 的端口列表:

module single_fifo(clk,reset,in_bit,push,pop,out_bit,full);
   parameter N=4; // determines the maximum number of words in queue.
   input clk, reset, push, pop;
   input in_bit;
   output out_bit;

   reg [N-1:0] bit_list;
   reg [N-1:0] n; 
   reg out_bit;
   output full;
   reg full;

抱歉,如果我的问题看起来很幼稚,我对 verilog 还是个新手。将收到帮助!

尽管您可能打算使用 replication {M{clk}} 而不是 multiplication {M*{clk}},但没有必要对于任何一个实例数组。 Verilog 会自动复制您连接到实例数组的信号,因此您只需编写

single_fifo fArr[M-1:0](clk,reset,in,push,pop,out,full_string);

P.S。我应该知道,因为早在 1990 年我就负责将此功能添加到 Verilog。 请参阅 IEEE 1800-2017 LRM

中的 23.3.3.5 解包阵列端口和实例阵列