Verilog 网络示例的语法错误,是否有多种 Verilog 语法变体?

Syntax error with Verilog web examples, are there multiple variants of Verilog syntax?

我正在尝试编译一些非常基本的 Verilog 文件,其中模块 inputs/outputs 是由讲师提供的,并且我编写了一个数据流分配,但我在讲师方面遇到了语法错误。这是源文件的精简版:

module syntax1 (
  input A, B,
  output C
  );

  assign C = A && B; // Only line that I can modify

endmodule

我用 verilog syntax1.v 编译它并得到这个输出:

Host command: [path removed for Whosebug]/verilog.exe
Command arguments:
    syntax1.v

Tool:   VERILOG-XL  08.20.001-d log file created Jan  9, 2016  17:56:34
Tool:   VERILOG-XL  08.20.001-d   Jan  9, 2016  17:56:34

[license is here]

Compiling source file "syntax1.v"

Error!    syntax error                                      [Verilog]          
          "syntax1.v", 2: input<-

Error!    Input, output or inout (C) not defined in port                       
          list                                              [Verilog-INOPL]    
          "syntax1.v", 3: 

Error!    syntax error                                      [Verilog]          
          "syntax1.v", 4: )<-

Error!    Identifier (A) not declared                       [Verilog-IDSND]    
          "syntax1.v", 6: 

Error!    Identifier (B) not declared                       [Verilog-IDSND]    
          "syntax1.v", 6: 
5 errors
End of Tool:    VERILOG-XL  08.20.001-d   Jan  9, 2016  17:56:34

如果我更改前三行(我希望这不是我必须做的)并重新编译,它会起作用:

module syntax2 (A, B, C);
  input A, B;
  output C;

  assign C = A && B;

endmodule

Verilog 输出:

Host command: [path removed for Whosebug]/verilog.exe
Command arguments:
    syntax2.v

Tool:   VERILOG-XL  08.20.001-d log file created Jan  9, 2016  17:49:02
Tool:   VERILOG-XL  08.20.001-d   Jan  9, 2016  17:49:02

[license is here]

Compiling source file "syntax2.v"
Highest level modules:
syntax2

0 simulation events (use +profile or +listcounts option to count)
CPU time: 0.0 secs to compile + 0.0 secs to link + 0.0 secs in simulation
End of Tool:    VERILOG-XL  08.20.001-d   Jan  9, 2016  17:49:03

所以 Verilog 不喜欢在参数列表中声明的输入和输出,或者我做错了什么。我看到像 syntax1.v 中那样做的网络示例,所以我认为这是我这边的配置问题。我是否可能针对不同版本的 Verilog 进行编译?

您使用的示例代码使用 ANSI 样式 header,IEEE 标准 1364-2001(又名 Verilog-2001)及更高版本支持该样式。根据维基百科的 List of HDL sinulators,Verilog-XL 仅支持 IEEE Std 1364-1995(又名 Verilog-1995)。也许 Cadence 添加了 Verilog-2001 支持并且它没有记录在维基百科上,查找或尝试 -2001-v2k 或类似的命令行选项。

你掩盖了你的路径,所以我无法判断你是 Verilog-XL 作为独立安装还是通过 Cadence Incisive 安装。如果您有 Incisive,请尝试 运行 ncverilogirun 而不是 verilog

你应该考虑换个模拟器。现代模拟器不限于 Verilog-1995。

如果您想继续使用Verilog-XL,您需要将header样式更改为Non-ANSI样式;下面的例子。注意:Verilog-1995 不支持 @*,因此 FSM 会比较难写,除非你使用脚本为你声明敏感度列表。

module syntax1 ( A, B, C );
  input A;
  input B;
  output C;

  assign C = A && B; // Only line that I can modify

endmodule