04 verilator仿真生成.vcd波形文件并利用gtkwave查看波形
编写top.v文件 module top(input a,input b,output f);assign f = a ^ b;endmodule编写ma
编写top.v文件
module top(input a,input b,output f
);assign f = a ^ b;
endmodule
编写main.c文件
#include
#include
#include #include "Vtop.h"
#include "verilated.h"#include "verilated_vcd_c.h" 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; contextp->traceEverOn(true); top->trace(tfp, 0); tfp->open("wave.vcd"); while (!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()); contextp->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
gtkwave wave.vcd
版权声明
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处。如若内容有涉嫌抄袭侵权/违法违规/事实不符,请点击 举报 进行投诉反馈!