Verilator包将Verilog 1和SystemVerilog 2硬件描述语言(HDL)设计转换为编译后可以执行的c++或SystemC模型。Verilator不是一个传统的模拟器,而是一个编译器。
Verilator的典型用法
-
使用类似于GCC或其他模拟器(如Cadence Verilog-XL/NC-Verilog或Synopsys VCS)的参数调用verilog可执行文件。Verilator读取指定的SystemVerilog代码,对其进行检测,可选地添加覆盖和波形跟踪支持,并将设计编译成源代码级多线程c++或SystemC“模型”。结果模型的c++或SystemC代码输出为.cpp和.h文件。这被称为“验证”,过程是“验证”;输出是一个“验证”模型。
-
对于模拟,需要一个小用户编写的c++包装器文件,即“包装器”。这个包装器定义了c++标准函数" main() ",它将验证模型实例化为一个c++ /SystemC对象。
-
由Verilator提供用户c++包装器、由Verilator创建的文件、“运行时库”以及(如果适用)SystemC库,然后使用c++编译器编译以创建模拟可执行文件。
-
生成的可执行文件将在“模拟运行时”期间执行实际的模拟。
-
如果适当地启用,可执行程序还可以生成可以查看的设计的波形轨迹。它还可以为后期分析创建覆盖率分析数据。
Verilator安装
如果想要查看更多,可以进入Verilator官方网站自行查看教程。
包管理器快速安装
sudo apt-get install verilator # On Ubuntu
注意:软件包不太可能有最新的版本,所以不推荐使用这种方法进行安装。
Git快速安装
# Prerequisites:
#sudo apt-get install git help2man perl python3 make autoconf g++ flex bison ccache
#sudo apt-get install libgoogle-perftools-dev numactl perl-doc
#sudo apt-get install libfl2 # Ubuntu only (ignore if gives error)
#sudo apt-get install libfl-dev # Ubuntu only (ignore if gives error)
#sudo apt-get install zlibc zlib1g zlib1g-dev # Ubuntu only (ignore if gives error)
git clone https://github.com/verilator/verilator # Only first time
# Every time you need to build:
unsetenv VERILATOR_ROOT # For csh; ignore error if on bash
unset VERILATOR_ROOT # For bash
cd verilator
git pull # Make sure git repository is up-to-date
git tag # See what versions exist
#git checkout master # Use development branch (e.g. recent bug fixes)
#git checkout stable # Use most recent stable release
#git checkout v{version} # Switch to specified release version
autoconf # Create ./configure script
./configure # Configure and create Makefile
make -j `nproc` # Build Verilator itself (if error, try just 'make')
sudo make install
这种安装方式verilator没有安装在默认路径下,想要使用verilator,还应运行下面的命令:
# See above; don't do this if using an OS-distributed Verilator
export VERILATOR_ROOT=/path/to/where/verilator/was/installed
export PATH=$VERILATOR_ROOT/bin:$PATH
VERILATOR_ROOT=自己的安装路径