cshell脚本解析

注意:cshell命令从上到下顺序执行;makefile命令并发执行;
一、脚本源码
#! /bin/csh
setenv DUV_DIR …/…/duv
setenv VERDI_LIB_PATH $NOVAS/share/PLI/VCS/LINUX64
setenv LD_LIBRARY_PATH $NOVAS/share/PLI/VCS/LINUX64

set TESTCASE =
set SEED = date +%N

if ($ #argv == 3) then
unset TESTCASE
set TESTCASE = $ 2
unset SEED
set SEED = $ 3

else if ($ #argv == 2) then
unset TESTCASE
set TESTCASE = $2
endif

set VERBOSITY = UVM_MEDIUM
set COMPILE = "vcs -full64 +lint=TFIPC-L -sverilog -timescale=1ns/1ps -ntb_opts uvm-1.1
-Mupdate -debug_all
+v2k +nospecify +notimingcheck +profile
+vcs+lic+wait
+libext+.v+.vg+.sv
-o simv_$SEED
-l …/…/log/${TESTCASE}_compile_$SEED.log "

set FILELIST = "+incdir+…/…/testbench
+incdir+…/…/testcase
-f $ {DUV_DIR}/filelist.f …/…/testcase/$TESTCASE.sv "

set DUMP = "+vcsd -load ${VERDI_LIB_PATH}/libnovas.so:FSDBDumpCmd
-P ${VERDI_LIB_PATH}/novas.tab
${VERDI_LIB_PATH}/pli.a "

set USERDEFINE = "+define+UVM_REPORT_DISABLE_FILE_LINE "

set RUN = “./simv_$ SEED +UVM_VERBOSITY=$ VERBOSITY +ntb_random_seed=$ SEED +UVM_TESTNAME=$ TESTCASE -l …/…/log/$ {TESTCASE}-run- $ SEED.log +UVM_NO_RELNOTES”

if ($#argv = = 1 && $1 == clean) then
rm -rf * ~ core csrc simv* vc_hdrs.h ucli.key urg* * .log * .fsdb DVEfiles *.vpd
可以同时删除多个不同路径下多个不同文件夹和文件,一次到位。
rm -rf… /…/log/{*.log,*.fsdb,verdiLog}
exit 1
endif

if (-e simv_$ SEED) then
$ COMPILE $ FILELIST $ DUMP $ USERDEFINE
set result = $ ?
if ($ result != 0) then
echo “Compile Result has ERROR!!”
echo “See …/…/log/$ {TESTCASE}-compile-$ SEED.log For More Details.”
exit 1
endif
endif

if ($ #argv > 1) then
if ($1 = = run) then
$RUN +fsdbfile+…/…/wave/ $ {TESTCASE}_ $ SEED.fsdb +fsdb+autoflush -ucli -i …/…/scripts/vcs.cmd
else if ($1 = = nodump) then
$RUN
else if ($1 == gui) then
$RUN -gui
else if ($1 == verdi) then
verdi ${FILELIST} $USERDEFINE -sv -syntaxerrormax 9999 &
# 打开verdi 关联代码 后台运行
endif
endif

二、脚本用法
运行初始用例及初始种子
b …/…/scripts/run_vcs.csh run
运行指定用例及随机种子
b …/…/scripts/run_vcs.csh run testcase_name seed
运行初始用例及初始种子并且不dump波形
b …/…/scripts/run_vcs.csh nodump
运行初始用例及初始种子并且打开gui
b …/…/scripts/run_vcs.csh gui
清理work目录
b …/…/scripts/run_vcs.csh clean
打开verdi
b …/…/scripts/run_vcs.csh verdi

三、脚本语法
VERDI_LIB_PATH verdi的库文件
LD_LIBRARY_PATH 让系统Linux找到verdi需要的库文件
-P ${VERDI_LIB_PATH}/novas.tab 加载表格文件
${VERDI_LIB_PATH}/pli.a 加载静态库

shell语法
文件比较运算符:-e filename 如果filename存在,则为真。
date +%N 当前时间,转换为9位数,单位为ns
$ 的用法
shell中用$ 来取一个变量的值,常见用法$ VAR或$ {VAR}。
$# 代表传入参数的个数
$@ 代表传入参数的列表
$0 代表脚本本身
$1 代表传入的第一个参数
$* 以字符串方式显示所有传入的参数
$ $ 脚本运行的进程ID
$? 显示最后命令的退出情况,0表示没有错误

exit 0表示正常退出,不执行后面命令。
exit 1表示异常退出,不执行后面命令。可以在退出前设置log来方便debug。

verdi相关语法
+fsdbfile+…/…/wave/$ {TESTCASE}_$SEED.fsdb 指定定波形文件的存放目录和名称,默认路径是当前仿真work目录,默认名称为novas.fsdb
+fsdb+autoflush 在simulation stop或者ctrl c停止时自动将缓冲中的波形输出。如果没有该参数,则在仿真时不会dump波形,需在ucli命令run 100ns后键入fsdbDumpflush才会dump波形。
-ucli -i …/…/scripts/vcs.cmd ucli的输入文件

发布了38 篇原创文章 · 获赞 29 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_45270982/article/details/104041682