VCS仿真与调试

VCS common

-cc指定C编译器,默认使用/usr/bin下的C编译器
synopsys_sim.setup 用于配置VCS,默认使用$VCS_HOME/bin目录下的synopsys_sim.setup文件。可以放在$VCS_HOME/bin目录,home目录,vcs run目录,优先级依次增加。
一般用于指定 logical library 到 physical library 的mapping关系
logical library :可以通过 -work指定,默认为WORK
physical library:实际存放位置,默认为当前文件夹 ‘.’ ,建议指定为**./worklib**,如下:

WORK  >  DEFAULT
DEFAULT : ./worklib

llib -h查看库相关命令
库 library : 由 modules, interfaces, programs, checkers(用于formal verification), primitives(原语,门级描述), packages, and other configurations(若存在相同模块名,指定模块实例使用哪一个库的源代码)组成。 这些组成库的element也称为cell
是vcs analyzed的对象,对不同语言进行Syntax语法Parse解析,如果代码不符合规范,vcs会报Syntax ErrorToken符号标记错误位置;vcs也并不是每次都可以根据Context上下文准确的指出错误位置,因为工具对于代码的Semantic语义分析和人的理解还是有差别的。(仅个人理解

VCS 三步法

三步法用于仿真混合语言,比如VHDL和Verilog。

Analysis

Analysis阶段vcs会Parse代码,检测是否有Syntax Error,然后将中间文件保存到指定库worklib目录下,供elaboration使用。(这里的存放的是中间文件,上面提及的库是source code源代码,含义略有不同,但是内容一样。
vhdlan用于VHDL files,vlogan用于Verilog files。-work指定库,一般不需要指定,除非有需求。
注意文件的摆放顺序,被例化的模块应放在例化它的模块之前Parse。也可以显式的声明模块名extern module

Elaboration

Elaboration依据例化结构link链接各个模块,最后生成可执行文件simv
vcs WORK.tb_top指定elaboration从我们的默认库WORK的最顶层module tb_top开始。也可以写成vcs -top tb_top。不指定时,若存在多个top-level module没有被显式例化的moduel,会被隐式例化当作 top-level module, 实例名和 module name一样。$root.[top-level module name] $root下的 module就是 top-level module), 每个module都会被仿真执行,建议显式指出top-level module。
对于重复cells name的例化需要指明cells和库,例化和库的关系,保证你的例化和cells对应,避免出错。详细可参考🔗VCS仿真中的configuration和libmap 在VCS ug *Verilog Configurations and Libmaps* 中有更详细的介绍。
cells是Verilog 2001 引入的名词,VHDL的degin unit,Verilog的module,SV中的interface和program都属于cell的类型。

对于Verilog modules,加上-v -y +libext+ext被当作 library cells,否则被当作design cells处理。区别在于对于重名module的实例,优先在design cells中查找。

Elaboration产生的中间文件csrc(C的source)可以通过 -Mdir指定,可执行文件simv/可以通过-o指定,

Simulation

simv执行需要当前目录下存在simv.daidir,csrc则不需要。
在回归测试中,可以通过建立超链接或者-daidir指定simv.daidir,实现在不同目录下的仿真。

三步法中,如果使用 -ntb_opts uvm指定UVM库,需要先 vlogan -ntb_opts uvm对 UVM库编译,再执行剩余步骤。

VCS 两步法

如果设计只是Verilog代码,使用两步法。第一步Compliation相当于三步法Analysis和Elaboration(占绝大部分时间)的组合,然后再Simulation

传入命令参数时,一般 -为供工具直接解析的命令,+为供代码使用的命令,如 +define +indir +plusars

debug_access

-debug_access-debug_acc

VCS 2014 后加入了debug_access, 之前的-debug_pp, -debug, -debug_all不在建议使用。
为了更好的平衡仿真速度和debug功能,建议 配合-debug_region 使用,提供更精准的仿真控制。
vcs -debug_access 时,不需要再手动配置PLI的tab file verdi.tab 和静态库 pli.a,只需设置 $VERDI_HOME,vcs会自动查找所需文件,$fsdbDumpfile可以直接使用。
更多使用示例,可以参考sovlent🔗Purpose and Benefits of Using the -debug_access and -debug_region Options或直接在solvnet中搜索。
需要注意的是:-debug_access+all 并不包含library(-v -y指定)和cell`celldefine编译原语标记的module,是cell module),无法PLI访问(如uvm_hdl_write)和波形dump。加上-debug_region=cell+lib才可以正常访问。而-debug_all则是默认包含library和cell。(一般library和cell为标准单元,特别是在后仿,RTL综合成stdcell,被celldefine标记,而且PR也加入很多buf和inv, 降低仿真速度,增加波形文件size,如果不需要可以加上+nocelldefinepli+2,只dump module instance上的port波形)。

Options for Cell Definition
+nolibcell
Does not define as a cell modules defined in libraries unless they are under the `celldefine compiler directive.
+nocelldefinepli+0
Enables recording in VPD files, the transition times and values of nets and registers in all modules defined under the ‘celldefine compiler directive or defined in a library that you specify with the -v or -y options. This option also enables full PLI access to these modules.
+nocelldefinepli+1
Disables recording in VPD files, the transition times and values of nets and registers in all modules defined under the ‘celldefine compiler directive. This option also disables full PLI access to these modules. Modules in a library file or directory are not affected by this option unless they are defined under the ‘celldefine compiler directive.
+nocelldefinepli+2
In VPD files, disables recording the transition times and values of nets and registers in all modules defined under the ‘celldefine compiler directive or defined in a library that you specify with the -v or -y options, whether the modules in these libraries are defined under the ‘celldefine compiler directive or not. This option also disables PLI access to these modules.
Disabling recording of transition times and values of the nets and registers in library cells can significantly increase simulation performance.
Note:
Disabling recording transitions in library cells is intended for batch simulation only and not for interactive debugging with GUI.
+nocelldefinepli+1+ports
Removes the PLI capabilities from `celldefine modules but allows PLI access to port nodes and parameters.
+nocelldefinepli+2+ports
Removes the PLI capabilities from library and ‘celldefine modules and allows PLI access to port nodes and parameters

use Verdi

verdi加载的是Knowledge Database (KDB),这是一个 Elaboration Database elabDB。建议通过 vcs -kdb -lca 生成kdb.elab++,位于simv.daidir目录下。

-lca Limited Customer Availability features are features available with the select functionality. These features will be ready for a general release, based on customer feedback and meeting the required feature completion criteria. LCA features do not need any additional license keys.

VCS two-step flow
% vcs -kdb -lca <vcs options> -verdi_opts "<verdi_options>"

VCS three-step flow
% vlogan -kdb -lca <vlogan options> <source files>
% vhdlan -kdb -lca <vhdlan options> <source files>
% vcs -kdb <top_name>

verdi -elab ./simv.daidir/kdb 加载KDB。

如果是使用vcs -kdb -lca产生的KDB,建议使用如下三种方式加载:

verdi -dbdir simv.daidir
verdi -simBin simv
verdi -ssf novas.fsdb
这三种方式都以加载KDB,第三种同时加载波形。

如果没有vcs, 也可以直接使用verdi加载design。
verdi内置了compiler,vericom analyze verilog vhdlcom analyze VHDL。
vericom -sv -ntb_opts uvm -f xxx.list 生成库work.lib++
veridi -q -nologo -lib work.lib++加载设计, -lib指定加载的库,verdi打开GUI界面,会自动elab。
也可以手动elab, verdi提供了elabcom命令进行elabration:elabcom -lib work.lib++ -elab kdb生成kdb.elab++ elabDB。
verdi -q -nolog -elab kdb加载design。

也可以直接通过verdi -sv -ntb_opts uvm -f xxx.list打开GUI界面,通过source的方式直接load design,这种方式不会产生中间文件,只会生成verdiLog。有语法报错也可以打开,错误在compiler.log中显示。可以直接Edit Source File或者设置gvim编辑,再Shift + L reload design。
提前通过vcs或者vericom编译成precompiled library,直接加载无法调用Edit Source File,需要设置setenv NOVAS_EDIT_SOURCE 1。但是reload design仍需要重新编译后,才会生效。
通过设置环境变量NOVAS_RC NOVAS_GUICONF保存个人喜好verid的配置;

对于VCS用户,建议使用vcs -kdb -lca的方式结合verdi进行debug,这种方式保证了一致性。使用verdi的vericom elabcom和vcs略有差异。

加速仿真速度

  1. 合理使用debug_access对simulation database的访问权限。并配合debug_region使用。

  2. 波形的dump对仿真速度影响很大,根据需求做一些限制:
    2.1 Limit the scope (例如:$fsdbDumpvars("+IO_Only")只dump端口信号)
    2.2 Limit the Time
    2.3 Limit Dumping of Memories
    2.4 Limit Library Dumping

  3. RF/PHY的calibration增加了run-time,寻求FASTMODE的配置。VIP中各类timer的scale down。

  4. vcs的Incremental Compilation增量编译(相对于第一次编译 fresh compile而言),貌似只对analysis阶段提升,对于compile的提升作用不大。增量编译是vcs默认打开的功能。

  5. 一次编译多个tc,分别仿真。利用$plusargs减少重复编译。

  6. vcs -j<num_of_processes>多核并行编译

  7. 通过PLI大量调用ACC lib的例程,影响run-time速度。采用+vcs+learn+pli配置 +applylearn+[tabfile]使用。

  8. 大量调用VPI访问simulation database,建议改成interface的方式。比如uvm中的uvm_hdl_xxx和寄存器模型后门访问。

  9. VCS Fine-Grained Parallelism,调用多核进行仿真,有限制,仅适用于较少的 “testbench code and on the PLI/ DPI content”的testcase。
    🔗 Realizing Faster Simulations/Diagnosis with VCS’ New Parallel Simulation and UFE Technology

  10. save restore TODO

  11. 分布编译Partition Compile 见下一节

这些加速方式都有一些限制,实际使用可能达不到预期效果,分清主次,在刀刃上下功夫即可。

查看资源消耗

vcs –reportstats simv -reportstats : show the summary time and mem of compile and runtime.
vcs -simprofile simv -simprofile [time|mem]: 查看详细的各个模块(module,package,pli等)占用时间和内存。(html txt格式报告)
vcs -simprofile=uvm 查看UVM相关的资源消耗。(html txt格式报告)

Partition Complie

Improvements to simulation turnaround time for SoC Design Verification
功能:将DUT和TB分成若干partition,调用多核分别编译。对于二次编译,只编译修改的partition。
命令

vcs -lca -partcomp=autopartdbg -fastpartcomp=j4 -partcomp_dir=pc_dir -pcmakeprof [other options]

-partcomp:自动分割成若干partition。
-partcomp=autopart_low: 分割粒度更小
-partcomp=autopart_high:分割粒度更大
-partcomp=autopartdbg:debug,生成vcs_partition_config.file包含partitioning information。
-fastpartcomp:调用多核并行编译。
配置了4个CPU core:
在这里插入图片描述

-partcomp_dir:指定中间数据存放目录。
-pcmakeprof:生成时间消耗的log 如下图:
在这里插入图片描述
Note:
首先使用auto-partition,查看每个partition的时间消耗,对于较大的partition, 再人为分割。每个partition不宜过大过小。
对于Cross-Module References (XMRs) 跨模块的引用,一个partition改动都会引起另一个partition从新编译。
Partition Complie 还是lca功能,debug时可以禁用,排除EDA工具的影响。
在这里插入图片描述

VCS Diagnositics

vcs -diag timescale
vcs -diag macro_values
TODO

VCS仿真事件调度

🔗interface clocking block使用 及 verdi capture delta cycle
🔗dump glitch 毛刺分析 及 异步复位同步释放

VCS solver对constraint的求解

🔗仿真器VCS solver 对包含 function 约束的求解
🔗VCS solver对slove… before的支持

VCS对X-Propagation仿真的支持

🔗X态详解 与 X态传播 VCS X-Propagation

VCS对UPF仿真的支持

🔗低功耗验证 (二)UPF,低功耗流程,VCS NLP

VCS对SDF仿真的支持

TODO

VCS加载动态库 .so

对于DPI/PLI的调用,vcs实现了IEEE Standard for SystemVerilog (Inclusion of foreign language code章节)中规定方法:
在这里插入图片描述
先生成动态库文件,然后选择 -sv_lib -sv_root -sv_liblist中的一种方式加载 .so文件。

#生成 routine.o
gcc -fPIC -Wall -I{SRC_PATH} -I{VCS_HOME}/include -O -c xxx/routine.c 

#生成 routine.so
gcc -fPIC -shared -o routine.so routine.o

# 加载 routine.so (routine的.so扩展名不需要写)
simv -svlib ${PATH}/routine

多个文件时,可以

#makefile
CC = gcc -m64 -fPIC -std=c99
OBJS = routine1.o routine2.o routine3.o
libpli: ${OBJS}
	ld -G -o routine.so ${OBJS} -lm

加载pli时,需要额外的vcs -P xxx.tab

VCS ICO

VCS ICO - Intelligent Coverage Optimization

VCS training vedio

在这里插入图片描述
链接:https://pan.baidu.com/s/1Go5NME3uuna_IrxNPQ_R_A
提取码:csdn

  • 59
    点赞
  • 489
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Holden_Liu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值