首先呢,请根据官网指南安装好verilator+systemc环境
一、搭建环境
安装官网的包就可以了,然后教程走一遍文档里的3个案例
二、Verilator仿真器入门 | Hu's Blog(梯子)
帖子很有用,建议跟着编译命令一步一步走一遍,
Vtop *top; // 模块的实例 vluint64_t main_time = 0; // 当前的仿真时间 // This is a 64-bit integer to reduce wrap over issues and // allow modulus. This is in units of the timeprecision // used in Verilog (or from --timescale-override) double sc_time_stamp() { // Called by $time in Verilog return main_time; // 需要被Verilog中的$time调用 } int main(int argc, char **argv) { Verilated::commandArgs(argc, argv); // Remember args top = new Vtop; // 创建一个新的实例 top->reset_l = 0; // 把reset拉低 while (!Verilated::gotFinish()) { if (main_time > 10) { top->reset_l = 1; // Deassert reset // 拉高Reset,结束复位 } if ((main_time % 10) == 1) { top->clk = 1; // 时钟翻转 } if ((main_time % 10) == 6) { top->clk = 0; // 时钟翻转 } top->eval(); // 计算输出 cout << top->out << endl; // Read a output main_time++; // 时间戳自增 } top->final(); // 仿真结束的时候,需要运行final()来执行所有的final块 // // (Though this example doesn't get here) delete top; }
部分展示