DUT文件hello_world.sv打印
class hello_world extends uvm_test;//定义
`uvm_component_utils(hello_world);//将类注册到工厂factory,才能用uvm框架
function new (string name, uvm_component parent);//规定用new()函数分配空间
super.new(name, parent);
endfunction
virtual task run_phase(uvm_phase phase);
//phase.raise_objection(this);
`uvm_info("TEST", "****************************", UVM_MEDIUM);
`uvm_info("TEST", "* my first uvm hello_world *", UVM_MEDIUM);
`uvm_info("TEST", "****************************", UVM_MEDIUM);
//phase.drop_objection(this);
endtask
endclass:hello_world
TB文件test.sv
program automatic test;
import uvm_pkg::*;//进入所有uvm的feature,如factory,config机制
`include "../hello_world.sv"
initial begin
$timeformat(-9, 1, "ns", 10);
run_test();//启动uvm_root的架构,激活component的phase函数,从test开始执行。从+UVM_TESTNAME获取一个测试激励,并创建测试组件uvm_test_top
end
endprogram
run_test()的整个启动及执行流程参考张强的《UVM 实战》白皮书第55页,大致为run_test----启动验证平台—根据UVM_TESTNAME产生实例依次执行build_phase,形成为完整的UVM树,再按照顺序执行UVM树,各结点的connect_phase、main_phase等,最后所有phase执行完,仿真结束。
UVM的Makefile文件
UVM_VERBOSITY = UVM_MEDIUM
DEFINE=
##TB filelist
TB_FILES = ../test.sv
#compile option
VCS = vcs -full64\
+v2k\
-sverilog\
-sim_res=1ps\
-l compile.log\
-debug_acc+all -debug_region+cell+encrypt\
-fsdb\
+vcd+vcdpluson\
-lca -cm line+fsm+cond+path+branch+tgl\
+vpi \
+define+UVM_OBJECT_MUST_HAVE_CONSTRUCTOR \
+incdir+$(UVM_HOME)/src \
$(UVM_HOME)/src/uvm.sv \
$(UVM_HOME)/src/dpi/uvm_dpi.cc -CFLAGS -DVCS
##simv option
SIMV = ./simv +UVM_VERBOSITY=$(UVM_VERBOSITY) -l vcs.log\
-sml +ntb_random_seed=$(SEED)\
-lca -cm line+fsm+cond+path+branch+tgl
##for testbench compile command
comp:
$(VCS) $(TB_FILES)
##for simv command
run:
$(SIMV) +UVM_TESTNAME=hello_world
##clean compile and simv generate files
clean:
rm -rf AN.DB DVEfiles csrc *.simv *.simv.daidir simv* ucli.key 64
rm -rf *.log* *.vpd *.fsdb *.vdb novas* *verdi*
rm -rf vc_hdrs.h via.rc
make comp编译之后会报错,原因是环境构建有问题
配置UVM_HOME环境变量
export UVM_HOME=/usr/synopsys/vcs/O-2018.09-SP2/etc/uvm-1.1
echo $UVM_HOME
enter键之后显示结果
/usr/synopsys/vcs/O-2018.09-SP2/etc/uvm-1.1
重新编译,make run之后结束,打开vcs.log文件结果如下
vcs.log文件
UVM_INFO @ 0.0ns: reporter [RNTST] Running test hello_world...
UVM_INFO ../hello_world.sv(10) @ 0.0ns: uvm_test_top [TEST] ****************************
UVM_INFO ../hello_world.sv(11) @ 0.0ns: uvm_test_top [TEST] * my first uvm hello_world *
UVM_INFO ../hello_world.sv(12) @ 0.0ns: uvm_test_top [TEST] ****************************
****************************