Verilator是一种开源的Verilog/SystemVerilog仿真器,可用于编译代码以及代码在线检查,Verilator能够读取Verilog或者SystemVerilog文件,并进行lint checks(基于lint工具的语法检测),并最终将其转换成C++的源文件.cpp和.h。
Verilator不直接将Verilog HDL转换为C++或者SystemC,反之Verilator将代码编译成更快的优化过的并且支持多线程的模型,该模型被依次包装在(wrapped)在C++/SystemC模型中。这样就生成一个编译的Verilog模型,其功能和Verilog是一致的,但效率由于基于C++即使是单线程模型也可以10倍快于SystemC,100倍快于基于解释Verilog的仿真器,并且通过多线程可以进一步加速。
Verilator的优点:将Verilog/SystemVerilog转换成C++/SystemC,仿真速度快很多,如果有这方面的需求,那Verilator是不错的选择。
本节将先介绍下Verilator的安装以及基本的使用方法,所有操作均在Ubuntu16系统上实现。
![图片[1]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
![图片[2]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
编译前的准备工作:
![图片[3]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
这里选择编译版本v4.210(注:最新版本会报错)
![图片[4]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
配置编译安装:
![图片[5]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
如果成功的话输入:
![图片[6]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
可以看到verilator的版本信息:
![图片[7]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
下面我们看下官方示例,最简单的hello world代码,文件位置在verilator/examples/make_hello_c/下,主要两个文件:
![图片[8]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
sim_main.cpp
![图片[9]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
MakeFile文件:
![图片[10]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
MakeFile中核心的编译语句其实就是执行:
![图片[11]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
直接执行编译:
make
![图片[12]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
安装gtkwave,gtkwave同样是开源的工具其git地址为:https://github.com/gtkwave/gtkwave.git
![图片[13]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
![图片[14]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
![图片[15]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
执行编译:
![图片[16]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
结果如下图:
![图片[17]-开源仿真工具Verilator入门1:安装和测试-Anlogic-安路社区-FPGA CPLD-ChipDebug](https://chipdebug.com/wp-content/themes/zibll/img/thumbnail-lg.svg)
没有回复内容