有人能解释一下系统中`line编译器指令的工作原理吗?verilog试图从LRM读取指令,但无法理解
`line指令的工作原理与C等其他语言中的相同(#line是什么意思?(。
主要用途是用于从另一种语言生成SystemVerilog代码的工具,这样由生成的SystemVerilog码生成的任何消息都可以指向原始代码,而不是翻译后的代码。这甚至适用于扩展SystemVerilog宏的工具,是一个很好的例子。假设我有这个5行文件top.sv
module top;
`include "defines.h"
`M(A)
`M(B)
initial x.x=0; // elaboration error
endmodule
这个5行文件定义了.h
int i1;
`define M(arg)
int L1_``arg;
int L2_``arg;
int i2;
SystemVerilog宏预处理器的输出是这个26行文件out.sv
`begin_keywords "1800-2017"
`line 1 "top.sv" 0
module top;
`line 1 "defines.h" 1
int i1;
`line 4 "defines.h" 0
int i2;
`line 6 "defines.h" 0
`line 2 "top.sv" 2
int L1_A; int L2_A;
int L1_B; int L2_B;
initial x.x=0;
endmodule
`end_keywords
如果我试图编译并运行这个out.sv文件,错误会在top.v的第5行报告,而不是out.sv.的第22行