Verilog: параметр модуля, код моделирует, но не синтезирует

Я столкнулся с несколькими проблемами при синтезе некоторого кода 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.

Я работаю над Xilinx с Spartan3e-1200 - Digilent Nexys2.

Спасибо !


person tetradeca7tope    schedule 22.05.2012    source источник


Ответы (2)


Если вы используете параметр, вам нужно объявить его перед использованием. Пытаться:

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 на вашем компиляторе, чтобы это работало.

person Marty    schedule 22.05.2012

Вы также можете использовать объявления портов после списка портов:

//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
person Community    schedule 23.05.2012