【问题标题】:Verilog - Getting a mismatch error trying to replicate output of another moduleVerilog - 尝试复制另一个模块的输出时出现不匹配错误
【发布时间】:2020-01-04 19:52:56
【问题描述】:

我正在尝试设计一个最多接受 N=4 个字并且每个字的位宽为 M=2 的 fifo。 我首先设计了一个 1 位宽的字 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): 实例数组中端口连接表达式 (32) 的向量长度与实例数 (2) 和端口长度 (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 的新手。将获得帮助!

【问题讨论】:

  • {M*{clk} 表示 M 乘以 clk 和 32 位宽的结果。您可能指的是{M{clk}},它是具有 2 位结果的复制运算符。
  • 你今天第二次帮助我,你是救命稻草!谢谢!

标签: verilog


【解决方案1】:

虽然您可能打算使用 replication {M{clk}} 而不是 multiplication {M*{clk}},但对于实例数组,不需要任何这些。 Verilog 会自动复制您连接到实例数组的信号,这样您就可以编写

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

附:我应该知道,因为早在 1990 年我就负责将此功能添加到 Verilog。 请参阅 IEEE 1800-2017 LRM 中的 23.3.3.5 未打包的阵列端口和实例阵列部分

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-20
    • 1970-01-01
    • 2021-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多