当前位置:网站首页>ICer技能02makefile脚本自跑vcs仿真
ICer技能02makefile脚本自跑vcs仿真
2022-06-23 03:52:00 【捌肆幺幺】
0.前言
在win上跑过modelesim仿真的都知道,我们需要准备好两个.v文件,然后一顿界面的操作点来点去,最后才生成波形,这对于开发者来说是相当低效的,所以今天记录一下linux下使用makefile脚本自跑vcs仿真。
1.常用选项
| 对象 | 指令 | 表示作用 |
|---|---|---|
| vcs | -full64 | 支持64位 |
| vcs | -l 空格 文件名 | 创建日志文件,一般为.log文件 |
| vcs | -f 空格 文件名 | 在某文件中索引要编译的文件路径,可以是file.list文件 |
| vcs | -debug_all | 支持调试 |
| vcs | -timescale=1ns/1ns | 时间精度 |
| vcs | +v2k | Verilog2001架构 |
| vcs | -sverilog | sv架构 |
| simv | -l | 仿真日志 |
| simv | -gui | 开启界面 |
| dve | -vpd 空格 文件名 | 打开波形文件,一般在最后加个&表示后台运行 |
2.准备工作
下面直接开始从零写一个简单的makefile脚本来自动化操作vcs仿真,当然要有一定的linux基础操作的知识,这个看个半小时基本命令的使用都能直接上手了,小case
①首先我们进入终端,用ls命令看看有什么文件
ls
②我们看到只有一个add_vcs的文件夹
③忽略这个文件夹,重新建立一个add_test的文件夹
mkdir add_test
④可以看到桌面上多了一个文件夹(当然我是在桌面这个路径下敲的代码)

⑤进入add_test文件夹下的路径
cd ./add_test/

⑥创建两个文件:add.v add_tb.v
touch add.v
touch add_tb.v


⑦使用gvim编辑器编写两个.v文件,代码如下
add.v
module add ( input a,b,c_in, output sum,c_out ); assign sum = a ^ b ^ c_in; assign c_out = (c_in & b)|(a & b)|(a & c_in); endmoduleadd_tb.v 注意一定要保证仿真能结束,不然跑vcs会一直卡进程,还有就是$vcdpluson生成波形文件
`timescale 1 ns/1 ns module add_tb(); //输入用reg reg a; reg b; reg c_in; reg clk; //输出用wire wire sum; wire c_out; //时钟周期,单位为ns parameter CYCLE = 20; //生成本地时钟 initial begin clk = 0; forever #(CYCLE/2) clk=~clk; end //信号初始化 initial begin #1 a = 0; b = 0; c_in = 0; end //待测试的模块例化 add u1 ( .a (a), .b (b), .c_in (c_in), .c_out (c_out), .sum (sum) ); //其他输入信号赋值 always @(posedge clk)begin a = {$random}%2; b = {$random}%2; c_in = {$random}%2; end initial begin $vcdpluson; end initial begin # 200 $finish; end endmodule

⑧生成file.list文件,再用ls查看是否真正生成了相应文件
find -name "*.v"> file.list

⑨使用gvim查看flie.list文件(按下gf可以跳转,ctrl+o返回),发现是一个相对路径集合
gvim file.list

3.makefile编写
- vcs的仿真首先要进行编译(com),然后是仿真(sim),再接着就是看波形(用dve看)
- 首先定义all: com sim run_dve
- 接着编写com sim run_dve 的各个指令
- 最后加上一个clean来清除仿真生成的文件
先在add_test路径下创建一个makefile文件进而编写
代码如下:
all: com sim run_dve
com:
vcs -sverilog -debug_all -timescale=1ns/1ns -f file.list -l com.log
sim:
./simv -l sim.log
run_dve:
dve -vpd vcdplus.vpd &
clean:
rm -rf *.vpd csrc *.log *.key *.vdb simv* DVE*
根据开头的表格可以了解各个指令的功能
4.一键仿真及文件清理
①回到终端,在add_test路径下运行
make all
即可
②仿真如下图:
③自动运行dve ,我们添加查看波形即可


④最后关闭dve界面,在终端上运行
make clean
将生成的文件全部删除,ls查看一下只剩下原本的4个文件
边栏推荐
- Gson typeadapter adapter
- 聊聊 C# 中的 Composite 模式
- [pytoch] calculate the derivative of sin (x) by automatic differentiation
- cadence中的焊盘和flash symbol
- 自举驱动、top开关电源、光耦拾遗
- 1183. 电力
- 距离度量 —— 余弦距离(Cosine Distance)
- 2020:VL-BERT: Pre-training of generic visual-linguistic representation
- 独立站聊天机器人有哪些类型?如何快速创建属于自己的免费聊天机器人?只需3秒钟就能搞定!
- PaddlePaddle模型服务化部署,重新启动pipeline后出现报错,trt报错
猜你喜欢

Abnova blood total nucleic acid purification kit protocol

Abnova LiquidCell-负富集细胞分离和回收系统

Reinstallation of cadence16.3, failure and success

Cocos learning diary 1 - node

Abnova PSMA磁珠解决方案

Abnova abcb10 (human) recombinant protein specification

gson TypeAdapter 适配器

Static two position relay xjls-84/440/dc220v

美团好文:从预编译的角度理解Swift与Objective-C及混编机制

在Pycharm中对字典的键值作更新时提示“This dictionary creation could be rewritten as a dictionary literal ”的解决方法
随机推荐
VGG 中草药识别
一款MVC5+EasyUI企业快速开发框架源码 BS框架源码
Reinstallation of cadence16.3, failure and success
mysql json
PCB placing components at any angle and distance
聊聊 C# 中的 Composite 模式
Abnova acid phosphatase (wheat germ) instructions
PCB任意角度和距离放置元器件
第二次作业笔记
Abnova actn4 purified rabbit polyclonal antibody instructions
mysql json
const理解之一
Using editor How to handle MD uploading pictures?
PTA: price of 7-65 beverage
win10下安装、运行MongoDB
在PCB板边走高频高速信号线的注意事项–高频高速信号设计基本原则
notepad++ 查找替换之分组替换保留
PCB----理论与现实的桥梁
Common concepts and terms in offline warehouse modeling
Banner 标语 旗帜