【问题标题】:Verilog : Module parameter, code simulates but doesn't synthesizeVerilog:模块参数,代码模拟但不综合
【发布时间】:2012-05-22 17:21:24
【问题描述】:

我在合成一些 Verilog 代码时遇到了一些问题 - 尽管模拟似乎很好。

具体来说,一个模块定义如下..

module nexys2_sevensegment(
  input clk,
  input [NUM_CHARS*4-1: 0] disp_chars,
  output [NUM_CHARS-1: 0] anodes,   // The common cathodes for each display.
  output [6: 0] cathodes // The seven segments in the form {G,F,E,D,C,B,A}
  );

  parameter NUM_CHARS = 4; // The number of characters that need to be
                           // displayed. Should be in [1, 4].

并实例化如下,

  nexys2_sevensegment #(4) seven_seg_disp(clk, disp_bus, an, seg);

模拟似乎工作正常,但是当我合成它时,我收到以下错误:

=========================================================================
*                          HDL Compilation                              *
=========================================================================
Compiling verilog file "nexys2_sevensegment.v" in library work
ERROR:HDLCompilers:28 - "nexys2_sevensegment.v" line 8 'NUM_CHARS' has not been declared
ERROR:HDLCompilers:28 - "nexys2_sevensegment.v" line 9 'NUM_CHARS' has not been declared
Compiling verilog file "tb_nexys2_seven_segment.v" in library work
Module <nexys2_sevensegment> compiled
Module <tb_nexys2_seven_segment> compiled
Analysis of file <"tb_nexys2_seven_segment.prj"> failed.

我正在使用 Spartan3e-1200 - Digilent Nexys2 开发 Xilinx。

谢谢!

【问题讨论】:

    标签: verilog


    【解决方案1】:

    如果您使用参数,则必须在使用前声明。试试:

    module nexys2_sevensegment
      #( parameter NUM_CHARS=4 )
      (
      input clk,
      input [NUM_CHARS*4-1: 0] disp_chars,
      output [NUM_CHARS-1: 0] anodes,   // The common cathodes for each display.
      output [6: 0] cathodes // The seven segments in the form {G,F,E,D,C,B,A}
      );
    
      // ( remove parameter statement here )
    

    现在编译器在端口定义中看到NUM_CHARS 之前就遇到了它。

    您可能需要在编译器上设置 Verilog-2001 开关才能使其正常工作。

    【讨论】:

      【解决方案2】:

      你也可以在端口列表之后使用端口声明:

      //non-ANSI style header
      module nexys2_sevensegment(
        clk,
        disp_chars,
        anodes,   // The common cathodes for each display.
        cathodes // The seven segments in the form {G,F,E,D,C,B,A}
        );
      
        parameter NUM_CHARS = 4; // The number of characters that need to be
                                 // displayed. Should be in [1, 4]
      
        input                     clk;
        input  [NUM_CHARS*4-1: 0] disp_chars;
        output [NUM_CHARS-1: 0]   anodes;   // The common cathodes for each display.
        output [6: 0]             cathodes; // The seven segments in the form {G,F,E,D,C,B,A}
      
      endmodule
      

      【讨论】:

        猜你喜欢
        • 2016-07-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-12-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多