import package in SystemVerilog compilation
import and compile order
project
yapp_pkg.sv
1 | package yapp_pkg; |
yapp_tx_monitor.sv
1 | class yapp_tx_monitor extends uvm_monitor; |
yapp_tx_driver.sv
1 | class yapp_tx_driver extends uvm_driver #(yapp_packet); |
yapp_if.sv
1 | interface yapp_if (input clock, input reset ); |
virtual interface is in package;
yapp_pkg
is imported into interface
!!!
typedef uvm_config_db#(virtual yapp_if) yapp_vif_config;
is forward declarationA forward
typedef
declares an identifier as a type in advance of the full definition of that type
VCS compile
1 | vcs -full64 -R -sverilog -ntb_opts uvm-1.2 +UVM_TESTNAME=short_yapp_012_test -f vcs.f |
vcs.f
1 | -timescale=1ns/1ns |
output ERROR
1 | Error-[SV-LCM-PND] Package not defined |
xrun compile
1 | xrun -f xrun.f |
xrun.f
1 | -64 |
output Error
1 | file: ../sv/yapp_if.sv |
solution
place ../sv/yapp_pkg.sv
before
../sv/yapp_if.sv
.
In this particular example,
yapp_pkg
is NOT needed in interface. just deleteimport yapp_pkg::*
is enough in../sv/yapp_if.sv
plain example
The order of compilation unit DON'T matter
project
hw_top.sv
1 | module hw_top; |
yapp_router.sv
1 | module yapp_router (input clock, |
compile
place hw_top.sv before or after yapp_router.sv doesn't matter, the compiler (xrun, vcs) can compile them successfully.
Conclusion
Always place package before DUT is preferred choice during compiling.