uvm-1.2 examples —— 1.2 makefile

1.2 makefile



前言

makefile文件是测试用例的入口文件,这里主要介绍uvm-1.2自带测试用例中,VCS工具的makefile文件。包括每个case共用的makefile文件,和每个case单独使用的makefile文件。


一、所有测试用例共用的makefile文件

共用的makefile文件如下所示。

x: all

#
# Include file for VCS Makefiles
#

UVM_VERBOSITY =	UVM_LOW

#
# Note that +acc and +vpi have an adverse impact on performance
# and should not be used unless necessary.
#
# They are used here because they are required by some examples
# (backdoor register accesses).
#


TEST = /usr/bin/test
N_ERRS = 0
N_FATALS = 0

VCS =	vcs -sverilog -timescale=1ns/1ns \
	+acc +vpi \
	+incdir+$(UVM_HOME)/src $(UVM_HOME)/src/uvm.sv \
	$(UVM_HOME)/src/dpi/uvm_dpi.cc -CFLAGS -DVCS

SIMV = 	./simv +UVM_VERBOSITY=$(UVM_VERBOSITY) -l vcs.log

URG  = urg -format text -dir simv.vdb

CHECK = \
	@$(TEST) \( `grep -c 'UVM_ERROR :    $(N_ERRS)' vcs.log` -eq 1 \) -a \
		 \( `grep -c 'UVM_FATAL :    $(N_FATALS)' vcs.log` -eq 1 \)

clean:
	rm -rf *~ core csrc simv* vc_hdrs.h ucli.key urg* *.log

其中,最开始的x和最后的clean分别定义了两个函数,x调用的all函数,是在每个case单独的makefile中实现的,clean则是删除仿真生成的临时文件。
其余都是声明一些变量。
UVM_VERBOSITY变量用于控制uvm打印的log等级;
TEST、N_ERRS、N_FATALS这三个变量在CHECK中被使用,
CHECK主要的目的是,在仿真结束后检查有没有UVM_ERROR和UVM_FATAL;
VCS变量存放的是vcs仿真的命令和添加的选项,其中,

  • -sverilog:支持SystemVerilog
  • -timescale=1ns/1ns:指定仿真的时间单位和精度,斜杠前面是时间单位,后边是时间精度
  • +acc:使能PLI中的ACC
  • +vpi:使能VPI
  • +incdir+$(UVM_HOME)/src $(UVM_HOME)/src/uvm.sv $(UVM_HOME)/src/dpi/uvm_dpi.cc :添加仿真的搜索路径
  • -CFLAGS -DVCS:编译UVM源文件时,一般使用 -CFLAGS -DVCS 选项。-DVCS代表为C源代码定义的宏。所有已-D开始的选项都被gcc、g++编译器当做宏来处理。和VCS编译时间的选项一起,应该传输-DVCS时加上选项-CFLAGS,这样-DVCS就可以传给gcc、g++编译器了。

-CFLAGS 和 -DVCS有什么用?
How to use the gcc compiler’s option “-DVCS”?
-DVCS represents a macro defined for C source code. Please note that anything followed by -D is treated as a macro by the gcc/g++ compiler. Along with VCS compile-time options one should pass -DVCS with -CFLAGS so that -DVCS gets passed to gcc/g++.Example steps:% vcs top.v test.c -CFLAGS -DVCS
What’s the compile environment that we need to use this option?
“-CFLAGS -DVCS” is usually required during UVM source compilation.
Therefore, if we are using an external UVM source then you must pass -DVCS.(If we are using -ntb_opts uvm then no need to pass this option because it is internally passed with -ntb_opts uvm). Also, if we have any macros with the name ‘VCS’ defined in any other C source then we need to pass it with -CFLAGS -D

SIMV变量存放的是执行vcs仿真的命令;
URG变量用于生成覆盖率文件。

二、每个测试用例单独的makefile文件

下面列出了hello_world这个测试用例的makefile文件。

UVM_HOME	= ../../..

include ../../Makefile.vcs


all: comp run

comp:
	$(VCS) +incdir+. \
		hello_world.sv

run:
	$(SIMV)
	$(CHECK)

首先指定UVM_HOME的相对路径;其次加入共用的makefile文件;再定义all函数,all函数分别调用了comp和run函数;接着定义comp函数,这里使用了前面公共makefile中定义的VCS变量;最后定义了run函数,分别执行仿真和检查仿真log中是否有UVM_ERROR和UVM_FATAL。


总结

makefile是测试用例的入口文件,只有了解了makefile文件后,才能知道如何启动仿真。本文以uvm-1.2/examples中的hello_world测试用例为例,分别介绍了共用的makefile文件和case单独的makefile文件。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值