一生一芯预学习阶段记录
十月 18, 2023
2121
环境
- 虚拟机:VMware Workstation Pro 16
- 系统:Debian 12.2
6 - 搭建verilator仿真环境
安装verilator
下载源代码
github网页:verilator/verilator: Verilator open-source SystemVerilog simulator and lint system (github.com)
官方下载指南:Installation — Verilator 5.016 documentation
需要下载、安装的包:
1 | sudo apt-get install git help2man perl python3 make autoconf g++ flex bison ccache |
通过git tag查看版本之后结果是一长串,通过git checkout v5.008切换版本之后构造加编译。
make时间很长,建议-j多内核开跑(经历了全部拉满卡死的情况)
运行示例
官方简单示例
官网示例内容:Example C++ Execution — Verilator 5.016 documentation
我一开始没注意到,但是左侧分栏的GETTING STARTED内的Examples还是比较显眼的。
过程:
image-20231019102045209
运行结果:
image-20231019101929730
ysyx示例
代码:
1 |
|
过程总结:
Vtop.h是Module top生成的头文件,因此名字要对应,下面的“结构体/对象”也要相应地用V+模块名调用。obj_dir/Vtop___024root__DepSet_heccd7ead__0.cpp关键内容:1
2
3
4
5
6
7VL_INLINE_OPT void Vtop___024root___ico_sequent__TOP__0(Vtop___024root* vlSelf) {
if (false && vlSelf) {} // Prevent unused
Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___ico_sequent__TOP__0\n"); );
// Body
vlSelf->f = ((IData)(vlSelf->a) ^ (IData)(vlSelf->b));
}
仿真输出:
image-20231019214957331
打印并查看波形
tracing配置
verilator手册中已经介绍了波形生成的方法:
image-20231023185702001
其中,A方法两个变量设置指的是:
1 | initial |
GTKwave
使用直接命令行中敲入gtkwave +vcd文件名即可解析开启波形显示。
Makefile
- 本文作者:Ivor Lin
- 本文链接:http://ivorlin.cn/uncategorized/2023/10-82dfb24fdbfc/index.html
- 版权声明:本博客所有文章均采用 BY-NC-SA 许可协议,转载请注明出处!