问题描述
我正在尝试以下 SystemVerilog:
`define DEBUG (ARG) \
`ifdef DEBUG_ON \
$display ARG;
`endif
module my_mod;
logic a;
logic [1:0] b;
assign a = 1'b0;
assign b = 2'b01;
`DEBUG(("a=%x,b=%b",a,b))
endmodule
VCS 给了我以下编译错误:
Error-[SE] Syntax error
Following verilog source has Syntax error :
"/media/psf/Home/projects/dep2/hw/rtl/dep_dc/dep_dc_cs.sv",254 (expanding
macro): token is '('
`DEBUG(("a=%x,b))
^
#0,DEBUG : "<my_file>":21
full expansion of macro (DEBUG),error at line 1
=>(ARG)
`ifdef DEP_DEBUG_ON
...
根据这个答案:How to emulate $display using Verilog Macros?
这对我来说似乎是正确的语法。有人能发现什么问题吗?
解决方法
所以我显然发现,编译器不喜欢宏定义和参数之间的空格:
`define DEBUG(ARG) \
`ifdef DEBUG_ON \
$display ARG;
`endif
作品。