文章目录
- 0.引言
- 1.知识要求
- 2.VCS simulation basics (基础操作)
- 3、Compile-time option exambles(VCS可选项的介绍)
- 4、VCS Simulation Command Format(simv的可选项)
- 5. Using DesignWare Library with VCS(使用新思科技的库)
- 5.实际操作
0.引言
在安装好VCS后,现在开始开启VCS的使用熟悉。在逐步熟练使用VCS中,将FPGA中掌握的知识转行到IC设计中来。
参考资料:启芯
1.知识要求
you should hae experience in the following areas:
understanding of digital IC design
Familiarity with a Linux or Unix OS
Familiarity with a Linux - based text editor(VI)
综上所述:需要掌握数字电路基础、Verilog、Linux系统、编辑器VI
measurable Ohectives:(任务目标)
by the end of this workshop you should be able to:
- Simulate Verilog/SV designs using VCS
- Debug Verilog/SV designs using VCS
- Run fast RTL-lvel regession tests for your design
- run fast Gate-level regression tests for your design
- Acquire the skills and knowledge to successfully implement coverage driven vertification methodology using VCS
2.VCS simulation basics (基础操作)
this unit when you complated, you should be able to :
- Compile a Verilog/sSV design using VCS
- Simulate a Verilog/SV design
介绍:VCS
(Verilog Compiled Simulator)
Digital function simulator
支持多种抽象层次的仿真
1、行为级描述
2、RTL(寄存器传输级)
3、Gate-level(门级),与具体工艺库相关(TSMC(台积电)、SMIC(中芯国际)、CSMC(华润微电子有限公司))
VCS compilation command Format (VCS的编译命令格式)
$ VCS source_file [compile_time_options]
-
source file(源代码)
All Verilog/SV source file of the DUT
Sepatated multiple source files by spaces
Top module should contain testbench for DUT -
compile_time_options(可选项)
control how VCS compiles the soyrce files
Critical for optimizaition for visibility and performace
each unit of this workshop will describle how best to these compile_tiom_option -
Generate simulation binary excutable simv(bnary executable file)(最后生成一个二进制文件simv)
3、Compile-time option exambles(VCS可选项的介绍)
- VCS -help
list compile option, run-time options, environment variables
- Command line option(commonly used):
-Mupdate 增量编译
Incremental compilation(only changed files are compiled)
当代码量非常大,而只修改了很少的一部分时,如果全部重新编译,非常浪费时间,为了节约时间,可以做增量编译,从而与原来的代码做链接。
-R自动执行simv
自动执行编译后的可执行文件.simv
-gui启动DVE界面
starts the DVE GUI at runrime
**-I < filename > **
set log filename
编译的时候会产生一些信息文件,可以写到filename中
-sverilog
enable SystemVerilog language support
支持SV语言
+v2k
compile with support for Verilog 2001 extensions
编译支持verilog2001的标准
-v lib_file
search for unresolved module reference in file lib_file
如果用到了某些厂商的工艺库,请到该工艺库文件中去找
-y lib_dir
serch for unresolved module reference in files residing indirectry lib_dir
去找工艺库文件中去找,指定这个工艺库的目录中去找
+libext+lib_ext
use file extension lib_ext when searching for files inlibrary directory lib_dir
如果用到了很多工艺库,通过制定的文件后缀lib_ext(指定后缀),来找在指定目录下的指定后缀的文件。
+incdir+inc_dir
search inc_dir directory for ‘include files’
Access Verilog files and options via a file
-f file
file containing a list of absolute pathnames for the source_file and a subset of VCS options
User selected simulation binary name
-o foo
Creates executable foo instead of simv
Define a macro
+define+<macro_name> = < value >
4、VCS Simulation Command Format(simv的可选项)
在生成simv可执行文件后,仍然有一些可选项。
simv [run_time_options]
- run_time_options(optional)
controls how VCS executes the simulation binary - Simulaton results reported via
Verilog system task calls
User defined PLI routines
Run-time options example
- s
stop simulation at time 0 - userswitch
User defined run-time switch - E
echo displays compile-time option used for the creation of the current simv executable - I
logfile write output to logfile
5. Using DesignWare Library with VCS(使用新思科技的库)
Instantiating DesignWare Components in verilog
- Formate:
Dwpart # (parameters) u1(.porta(a),.port(b));
-DesignWare multiplier example:
Dw02_mult #(inst A_width,inst B_width);
Accessing DesignWare Simulation library
- y $SYNOPSYSS/dw/sim_ver+libext+.v+
5.实际操作
通过上面介绍,有很多命令还是记不住,没关系,上面只是作为一个查询,了解,有这个意识,知道VCS会执行编译,然后生成一个simv的文件,再执行这个simv的文件即可。在编译VCS和执行simv,都有其命令选项参数。
5.1 case1-加法器
下面通过在建立一个VCS-lab1的文件夹,进行一个最最简单的加法器实验。
//add.v
`timescale 1 ns/ 1 ps
module add(
input [3:0] a,
input [3:0] b,
output [4:0] sum
);
fa fa_inst(
.a(a),
.b(b),
.sum(sum)
);
endmodule
//fa.v
`timescale 1 ns/1 ps
module fa
(
input [3:0] a,
input [3:0] b,
output [4:0] sum
);
assign sum=a+b;
endmodule
//测试激励文件
`timescale 1 ns/1 ps
module add_tb();
reg [3:0] a;
reg [3:0] b;
wire [4:0] sum;
initial
begin
#0 a=4'd1;
#0 b=4'd2;
#100;
$stop;
end
always # 10
begin
a=a+1;
b=b+1;
end
add add_inst(
.a(a),
.b(b),
.sum(sum)
);
endmodule
注意:时间格式 `timescale 1 ns/1 ps 每一个文件中都应该有,否则会报错。
执行命令如下:必须要加上-full64,另外需要以gcc4.4来执行,+v2k代表遵循verilog的2001的标准,再加上一个调试-debug-all
就会生成simv文件和csrc文件夹
vcs -full64 add.v fa.v add_tb.v +v2k -debug_all
注意可以在环境变量里面将vcs的别名更改为vcs -full64
就每次只需要输入vcs即可
启动GUI界面即DVE,这个&代表后台执行,这样可以让你继续操作teminal不会被锁死,14092代表打开的端口号
由上图可见在后台执行时,命令行是可以继续操作的。
下面,我们采用增量编译的方式重新编译试试
5.111 增量编译 -Mupdate
-Mupdate 增量编译
Incremental compilation(only changed files are compiled)
当代码量非常大,而只修改了很少的一部分时,如果全部重新编译,非常浪费时间,为了节约时间,可以做增量编译,从而与原来的代码做链接。
vcs add.v add_tb.v fa.v +v2k -debug_all -Mupdate
- 1
因为终端的缓存十分有限,如果代码量很大,我们需要把终端中的信息记录下来。
5.112 日志文件输出-l +文件名.log
vcs add.v add_tb.v fa.v +v2k -debug_all -l compile.log
- 1
此时就会发现编译后多了一个文件compile.log文件
注意 -l是起作用的参数 而compile.log这个日志文件可以随便取名。
从图片中,可以看到日志文件记录了命令,以及编译的过程信息
5.113 -o取缔simv
默认输出的可执行文件是simv ,如果我们想要输出指定的文件名,可以用-o参数 +文件名
liruifeng@liruifeng:~/project_data/VCS_lab/lab1$ vcs add.v add_tb.v fa.v +v2k -debug_all -o Rhys
- 1
如图所示,生成的Rhys文件,而且这个文件是能够执行的。
tips:个人觉得这个-o参数也没啥实用价值。
5.114 +incdir+inc_dir头文件编译
有时候,我们需要用到头文件,特别是在ifdef语法中。
如图所示,我在添加了一句rhys.h的头文件另外touch一个rhys.h的文件,然后按照如下编译,否则会提示找不到rhys.h的文件
5.115 +define+宏的名字
直接在命令里面定义宏
+define+宏的名字