一、官网介绍

1.官网:

Veripool

2.介绍:

  • Verilator:最快的 Verilog/SystemVerilog 模拟器
  • 执行 lint 代码质量检查
  • 接受可合成的 Verilog 或 SystemVerilog
  • 编译成多线程 C + + 或 SystemC
  • 创建 XML 用于自己的工具的前端

3.What Verilator Does

  • 使用类似于 GCC 或 Synopsys 的 VCS 的参数调用 Verilator。它通过读取指定的 Verilog 或 SystemVerilog 代码,执行 lint 检查,并有选择地插入断言检查和覆盖率分析点来“ Verilog”指定的 Verilog 或 SystemVerilog 代码。它输出单线程或多线程.cpp 和.h 文件,“ Verilated”代码。
  • 用户写一个小小的 c + +/SystemC 包装文件,它实例化用户顶级模块的“ Verilated”模型。这些 c + +/SystemC 文件然后由 c + + 编译器(gcc/clang/MSVC + +)编译。生成的可执行文件执行设计仿真。Verilator 还支持将其生成的库链接到其他模拟器(可选加密)。
  • 如果你期待 NC-Verilog、 VCS 或另一个商业 Verilog 模拟器的全功能替代品,或者如果你正在寻找一个行为 Verilog 模拟器,比如一个快速类项目(我们推荐 Icarus Verilog) ,那么 veriator 可能不是最佳选择然而,如果您正在寻找将 SystemVerilog 迁移到 c + + 或 SystemC 的路径,或者您的团队仅仅编写一点 c + + 代码就已经很舒服了,Verilator 就是您的工具。

4.查阅资料

在线手册:Verilator User’s Guide — Verilator 4.223 documentation

5.工作流程

通常情况下,Verilator的工作流程如下所示:

  • 首先Verilator将读取特定的HDL文件并检查其代码,同时还可以选择支持检查覆盖率和debug波形的生成。然后将源文件编译成源代码级的多线程(source level multithreaded) C++或SystemC模型。其输出的模型会以.cpp和.h文件存在。这个阶段的过程叫做"to Varilate",输出的文件叫做"Verilated Model"。
  • 为了能够完成仿真,Verilator需要一个用户自行编写的C++ wrapper,这个wrapper与传统的Verilog Testbench 功能类似,主要是为了连接顶层模块,并给予相应的激励。
  • 在C++ 编译器的工作下,所有的之前生成的文件(C++ wrapper以及Verilated Model)以及库文件(Verilator提供的runtime library或者SystemC库文件)会被一同合并成一个可执行文件。
  • 执行生成的可执行文件,就可以开始实际的仿真,此时成为"simulation runtime"
  • 最后如果在编译阶段将特定的编译选项打开,可执行文件也会生成波形和覆盖率等信息。

二、安装verilator

安装步骤在官网链接

操作系统:Ubuntu 21.04

# Prerequisites:
#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  # 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 versionautoconf         # Create ./configure script
./configure      # Configure and create Makefile
make -j `nproc`  # Build Verilator itself (if error, try just 'make')
sudo make install
最后键入:verilator --version 

出现下图,说明搭建成功。

三、运行官方demo

demo链接:C++ example

按照手册做就好。改动一个地方

cd verilator
git pull        # Make sure we're up-to-date
git tag         # See what versions exist
#git checkout master      # Use development branch (e.g. recent bug fix)
#git checkout stable      # Use most recent release
git checkout v4.210  # Switch to specified release version

这里有一个:cat和<<的配合使用

官方给的demo:

our.v

module our;
initial begin $display("Hello World"); $finish;
end
endmodule

sim_main.cpp---------testbench

#include "Vour.h"
#include "verilated.h"
int main(int argc, char** argv, char** env)
{VerilatedContext* contextp = new VerilatedContext;contextp->commandArgs(argc, argv);Vour* top = new Vour{contextp};while (!contextp->gotFinish()) { top->eval(); }delete top;delete contextp;return 0;
}

执行:

verilator -Wall --cc --exe --build sim_main.cpp our.v

当出现这个,说明官方demo跑通了。

四、gtkwave使用

1.安装gtkwave

sudo apt-get install gtkwave
#gtkwave --version

如果出现下面报错:缺少canberra-gtk-module,apt安装即可

2.示例

以双控开关为例:

top.v 

module top(input a,input b,output f
);assign f = a ^ b;
endmodule

 top_main.cpp

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>#include "Vtop.h"  // create `top.v`,so use `Vtop.h`
#include "verilated.h"#include "verilated_vcd_c.h" //可选,如果要导出vcd则需要加上int main(int argc, char** argv, char** env) {VerilatedContext* contextp = new VerilatedContext;contextp->commandArgs(argc, argv);Vtop* top = new Vtop{contextp};VerilatedVcdC* tfp = new VerilatedVcdC; //初始化VCD对象指针contextp->traceEverOn(true); //打开追踪功能top->trace(tfp, 0); //tfp->open("wave.vcd"); //设置输出的文件wave.vcdwhile (!contextp->gotFinish()) {int a = rand() & 1;int b = rand() & 1;top->a = a;top->b = b;top->eval();printf("a = %d, b = %d, f = %d\n", a, b, top->f);tfp->dump(contextp->time()); //dump wavecontextp->timeInc(1); //推动仿真时间assert(top->f == a ^ b);}delete top;tfp->close();delete contextp;return 0;
}
verilator -Wall top.v top_main.cpp --cc --trace --exe --build
#增加了--trace 是为了显示波形的
./obj_dir/Vtop   //必须执行这个,才会出现.vcd文件
gtkwave wave.vcd //如果报错缺少canberra-gtk-module,apt安装即可

Verilator+gtkwave相关推荐

  1. 平头哥Wujian100_open仿真

    平头哥Wujian100_open仿真 Wujian100_open 仿真环境搭建 xming linux下仿真工具安装 仿真步骤 install the tool chain 首先创建 riscv_ ...

  2. 一生一芯 预学习阶段 搭建verilator仿真环境 之 示例:双控开关

    一生一芯 预学习阶段 搭建verilator仿真环境 之 示例:双控开关 1.前言 一生一芯预学习 中需要安装4.210版本Verilator,通过git方式下载所需要版本. 2.步骤 1.官网链接: ...

  3. Verilator简介与使用

    Welcome to Verilator, the fastest Verilog/System Verilog simulator. Accepts Verilog or System Verilo ...

  4. EDA开源仿真工具verilator入门1:安装和测试

    Verilator介绍 Verilator是一种开源的Verilog/SystemVerilog仿真器,可用于编译代码以及代码在线检查,Verilator能够读取Verilog或者SystemVeri ...

  5. verilator的第一个程序,注意流程和命令

    1. 已有文件 已知our_OnOff.v和main.cpp文件,编写Makefile文件,在verilator软件仿真 our_OnOff.v module our_OnOff(a,b,f);inp ...

  6. Verilator 仿真环境搭建和查看波形图

    1.工具安装 通过git安装Verilator参照官方文档Installation - Verilator 5.003 documentation git clone https://github.c ...

  7. 为verilator程序编写makefile

    1. 文件来源 以our_OnOff.v和main.cpp文件为例,编写Makefile文件,并在ysyx架构中用verilator软件仿真 verilator的第一个程序,注意流程和命令_狮子座硅农 ...

  8. cygwin编译verilator_Windows 安装 verilator

    windows bubun(cygwin) 下载verilator tar xvzf verilator*.t*gz cd verilator* ./configure 报错 ./configure ...

  9. cygwin编译verilator_Sublime text3 + Verilator 实现自动语法检错

    参考链接: Sublime+Verilator建立强大的verilog编写环境首先肯定此文给了自己很大帮助,但基于此流程还是遇到了很多问题,所以决定把自己安装的具体流程写下来,和大家分享.避免大家走弯 ...

最新文章

  1. 全球及中国养老护理行业十四五趋势前景与投资动向建议报告2022版
  2. oracle先删后建,oracle 建表之前先删除语句
  3. ashx 跨域_ASP.NET通用HTTP处理程序(ashx的),支持JSONP
  4. 大数高精运算-----乘法
  5. 找不到android的sdk,CircleCI – 找不到Android Studio项目的SDK位置
  6. 计算任意两个圆的交点
  7. python3 tkinter 桌面软件教程
  8. 十天学会php之第二天
  9. 4x4矩阵键盘工作原理及扫描程序_4*4 矩阵键盘工作原理
  10. unity3d通过粒子系统制作火焰效果
  11. 台式计算机把光驱改成硬盘,笔记本电脑光驱怎么改成硬盘|笔记本光驱位换成硬盘方法...
  12. excel数据导入mysql
  13. 进不去jetbrain官网怎么办
  14. 基于N-gram的双向最大匹配中文分词
  15. Sequencer框架
  16. “互联网+可视农业”模式有哪些?
  17. fcpx字幕功能详细使用教程
  18. python winform开发框架_winform引用网络上的图
  19. Python入门(一) —— 编程基础
  20. 梦江湖获取服务器信息,《一梦江湖》6月5日更新公告

热门文章

  1. 植物大战僵尸无尽版游泳池优秀阵容推荐(一)
  2. 【STM32 x ESP8266】连接阿里云 MQTT 服务器(报文连接)
  3. 视频编码基础:I帧、P帧 和 B 帧
  4. 【Windows】电脑蓝牙突然无法使用,解决办法来了
  5. 商业智能下,金融行业如何利用起来?
  6. 同一个网址电脑手机访问显示不同内容思路
  7. java遗传算法编程_遗传算法示例程序
  8. 计算机机箱架硬盘托架是什么,机械硬盘托架 笔记本光驱位硬盘托架到底靠不靠谱?有人说会烧主板,我都害怕了,......
  9. 软件智能:aaas系统中AI的任务能力和工作
  10. HTML-简单表格制作