文章目录
Ubuntu(22.04.2 LTS)中,使用verilator
开源verilog仿真工具,进行RTL功能仿真。现构建版本为5.008
的verilator
仿真环境。
安装流程
安装依赖
sudo apt-get install git perl python3 make autoconf g++ flex bison ccache
sudo apt-get install libgoogle-perftools-dev numactl perl-doc
sudo apt-get install libfl2
sudo apt-get install libfl-dev
sudo apt-get install zlibc zlib1g zlib1g-dev
获取源码
git clone https://github.com/verilator/verilator
选择合适的版本(5.008
)
unsetenv VERILATOR_ROOT
unset VERILATOR_ROOT
cd verilator
git pull
git tag
git checkout v5.008
编译
autoconf
./configure
make
sudo make install
简单C++测试用例
创建测试文件夹test_our
mkdir test_our
cd test_our
创建Verilog/SystemVerilog文件our.v
,内容如下
cat >our.v <<'EOF'
module our;
initial begin $display("Hello World"); $finish; end
endmodule
EOF
创建C++文件sim_main.cpp
,内容如下
cat >sim_main.cpp <<'EOF'
#include "Vour.h"
#include "verilated.h"
int main(int argc, char** argv) {
VerilatedContext* contextp = new VerilatedContext;
contextp->commandArgs(argc, argv);
Vour* top = new Vour{contextp};
while (!cont