周末也学习了下,主要做了个测试环境搭建,为了前几天的driver,倒腾了蛮久。但为了陪娃,也没有花很多时间来整理发布。还有40分钟上班,赶紧。

首先是建立了test方面的目录树,与RTL分开。在根目录用tree 命令很容易看到目录树。这种结构比较清晰,适用于中大型平台。因为是跟着书中的例子走,所以目前只有driver。

uvm启动顺序(UVM入坑笔记day)(1)

`timescale 1ns/1ps `include "uvm_macros.svh" import uvm_pkg::*; import driver_pkg::*; module top_tb; parameter simulation_cycle = 100 ; bit SystemClock; reset_io reset_if(SystemClock); router_io router_if(SystemClock); router dut(.clk(SystemClock), .reset_n(reset_if.reset_n), .io(router_if)); initial begin $fsdbDumpvars; forever #(simulation_cycle/2) SystemClock = ~SystemClock ; end initial begin uvm_config_db#(virtual router_io)::set(null,"uvm_test_top","router_if",router_if); uvm_config_db#(virtual reset_io)::set(null,"uvm_test_top","reset_if",reset_if); end initial begin run_test(); end endmodule

上图中就是top_tb.sv的代码,其中import driver_pkg::*;是个大坑,我没有在结尾加“;”号,导致我花了蛮多时间debug。第21行和22行是将顶层的if配置到driver中去。有人会问为什么是“uvm_test_top" 而不是"my_driver"?引用书中描述:无论传递给run_test的参数是什么,创建的实例的名字都是"uvm_test_top"。 26行中run_test()也没有指定是run哪个test,不急,在Makefile中我们有指定,” UVM_TESTNAME=“ 可以传递参数给仿真工具,下面Makefile中传了"my_driver"。

# Makefile for UVM Lab2 LD_LIBRARY_PATH = ${NOVAS_HOME}/share/PLI/VCS/LINUX CES64 = TRUE test = my_driver tb_path = ../src rtl_path = ../../../rtl DUT = ${rtl_path}/router.sv DUT = ${rtl_path}/router_io.sv DUT = ${rtl_path}/reset_io.sv TOP = ${tb_path}/drv/driver_pkg.sv TOP = ${tb_path}/top/top_tb.sv log = simv.log verbosity = UVM_MEDIUM uvm_ver = uvm-1.2 seed = 1 defines = uvm_defines = UVM_NO_DEPRECATED UVM_OBJECT_MUST_HAVE_CONSTRUCTOR plus = option = UVM_TR_RECORD UVM_LOG_RECORD trace = #trace = UVM_OBJECTION_TRACE compile_switches = -sverilog -lca -debug_access all -kdb vcs vcdpluson -timescale="1ns/100ps" -l comp.log -ntb_opts ${uvm_ver} ${DUT} ${TOP} define ${uvm_defines} ${defines} runtime_switches = -l ${log} UVM_TESTNAME=${test} UVM_VERBOSITY=${verbosity} ${plus} ${trace} ${option}

uvm启动顺序(UVM入坑笔记day)(2)

打开vcs,在DUT内看到有波形数据了,只是还不对,下一步再调整下:

uvm启动顺序(UVM入坑笔记day)(3)

,