找回密码
 立即注册
首页 业界区 安全 Verilator手册:USER'S GUIDE (一)

Verilator手册:USER'S GUIDE (一)

黎瑞芝 10 小时前
本博客用于记录我在一生一芯学习中所在手册中使用的比较有用的tips,可以方便后人学习,后续可能会根据新找的慢慢更新。
我全部都看一遍并且翻译出比较有用且常用的内容列出来,方便大伙使用和学习。
1.Verilating

  • With the --binary option, Verilator will translate the design into an executable, via generating C++ and compiling it.
  • With the --cc or --sc options, Verilator will translate the design into C++ or SystemC code, respectively.
  • With the --lint-only option, Verilator will lint the design to check for warnings but will not typically create any output files.
  • 使用--binary 选项,Verilator可以生成C++代码并进行编译,并生成可执行文件。
  • 使用--cc 或者 --sc选项,Verilator可以将设计转换为C++或者systemc代码。
  • 使用--lint-only选项,可以只用Verilator进行语法检查。我经常用这个检查RTL代码是否正确,但是逻辑检查还是用GDB和看波形比较合规。
2.Binary, C++ and SystemC Generation
可以使用--top-module来指定顶层模块。
3.Connecting to Verilated Models
Vysyx_25060170_top___024root.h 这个文件可以在gdb时候访问你RTL编译出来的变量,可以实时查看变量的值,方便你debug。
1.png

可以把他们的值p出来。
4.DPI Example
这个非常常用,用于Verilog调用C函数或者是C调用Verilog任务,常用于NPC获取指令、difftest、npc收到ebreak后正常退出等等。
如果要接收指令和当前指令的PC,可以使用下列的DPI-C,首先在仿真环境(c语言)中定义:
点击查看代码
  1. #include <verilated.h>
  2. #include "Vysyx_25060170_top.h"   //包含top模块的顶层类
  3. extern "C" void pc_inst_end(int thepc_data, int the_inst){
  4.   cpu.pc = thepc_data;
  5.   s.val = the_inst;
  6. }
复制代码
然后要在Verilog那边使用这边的代码
点击查看代码
  1. import "DPI-C" function void pc_inst_end(input int thepc_data, input int the_inst);//引进来函数
  2. always @(*) begin
  3.     pmem_read(pc_i,inst_o,rlen);
  4.     pc_inst_end(pc_i, inst_o);
  5. end
复制代码
使用组合逻辑实时将当前的PC和指令传递给仿真环境。
DPI-C基本用法就这样,还有在C语言这边引用Verilog任务,这里大伙可以去查别的博客,也有写。
大概就是:先写一个task,然后extern出去,在C语言仿真环境那边需要定义一个作用域,然后就可以调用Verilog的task了。

来源:豆瓜网用户自行投稿发布,如果侵权,请联系站长删除

相关推荐

您需要登录后才可以回帖 登录 | 立即注册