[英]SystemVerilog stringify (`") operator and line breaks
I'm using the SystemVerilog stringify operator, `"
, in a macro, as below. The case is deliberately contrived to show the bug: 如下所示,我在宏中使用SystemVerilog字符串化运算符`"
。故意设计这种情况以显示该错误:
module my_test();
`define print(x) $fwrite(log_file, `"x`")
`define println(x) $fwrite(log_file, `"x\n`")
integer log_file;
initial begin
log_file = $fopen("result.txt", "w");
`print(A);
`print(B);
`println(C);
`println(D);
`print(E);
`print(F);
end
endmodule
This gives the output (no trailing newline): 这给出了输出(没有尾随换行符):
ABC
`D
`EF
Why are there `
s in the output, but only from the println
? 为什么有`
S IN的输出,但只从println
?
Is this documented behaviour in the spec, or a bug in my simulator (Aldec Active-HDL)? 这是规范中记录的行为,还是模拟器中的错误(Aldec Active-HDL)?
This is a bug in your tool. 这是您工具中的错误。 However, the second `"
is not needed and gives you the results you are looking for. 但是,不需要第二个`"
,它会为您提供所需的结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.