【发布时间】:2019-11-01 08:54:31
【问题描述】:
我无法从 systenverilog 中的另一个库访问包和宏。我不明白的是,包或宏应该在编译单元中可见,因此在该单元中的任何库中都可见,但在本例中似乎并非如此
定义.sv
`define POUTMAX
mtp_pkg.sv
package mtp;
function automatic void set_mtp(string name, int val);
$display("set_mtp");
endfunction
endpackage
tb.sv
module tb;
initial begin
mtp::set_mtp("l",7);
// $display(`POUTMAX);
end
endmodule
如果我将测试台编译到它自己的库中,mtp_pkg 或宏将无法访问。例如
xrun mtp_pkg.sv 定义.sv -makelib tb_lib tb.sv -endlib -top tb
file: tb.sv
mtp::set_mtp("l",7);
| xmvlog: *E,NOPBIND (tb.sv,6|8): Package mtp could not be bound.
module tb_lib.tb:sv
errors: 1, warnings: 0 xrun: *E,VLGERR: An error occurred during parsing. Review the log file for errors with the code
*E and fix those identified problems to proceed. Exiting with code (status 1).
我在这里缺少什么?似乎 mtp_pkg 没有在 tb.sv 之前编译。 添加 include 和或 import mtp::* 到 tb.sv 并不能解决问题,然后我得到一个错误,即 mtp 包存在于 2 个位置和一个绑定错误。
如果我删除 tb_lib 就可以了。
【问题讨论】:
-
究竟是什么错误?您可以按照消息的建议检查日志文件吗?
-
编译命令后的错误如上所示:"Package mtp could not be bound" 来自 tb.sv 第 3 行 => mtp::set_mtp(...)
-
我的猜测是您需要将 -makelib 放在您编译的所有文件周围。
标签: scope macros package system-verilog