0

我希望能够编写这样的代码:

`ifdef SYSTEMVERILOG_ENABLED
  .. systemverilog code here.
`else
 .. verilog-2001 equivalent code here.
`endif

但是 SystemVerilog 参考手册似乎没有引用任何此类标准预定义常量。这似乎是一个疏忽——有没有一种简单的方法来做我打算在这里做的事情?

4

1 回答 1

4

是的,有编译器指令begin_keywords "version_specifier"end_keywords,其中:

version_specifier ::=
    1800-2009
  | 1800-2005
  | 1364-2005
  | 1364-2001
  | 1364-2001-noconfig
  | 1364-1995

来自 LRM 的示例:

`begin_keywords "1364-2001" // use IEEE Std 1364-2001 Verilog keywords
module m2 (...);
reg [63:0] logic; // OK: "logic" is not a keyword in 1364-2001
...
endmodule
`end_keywords

IEEE 1800-2009 第 22.14 章对此进行了介绍。

就个人而言,我从未使用过这些,所以我不知道这些工具对它们的支持程度。

于 2013-03-05T21:54:12.660 回答