Verilator生成仿真波形文件
基本步骤
代码模板
- 顶层CPP模板
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
int main(int argc, char **argv, char **env)
{
// Prevent unused variables
if (false && argc && argv && env) {}
const std::unique_ptr<VerilatedContext> contextp{new VerilatedContext};
// Module
Vtop *top = new Vtop;
Verilated::traceEverOn(true);
VerilatedVcdC* tfp = new VerilatedVcdC;
top->trace(tfp, 0);
tfp->open("simx.vcd");
while (contextp->time() < 20 && !contextp->gotFinish())
{
// simulation code
……
contextp->timeInc(1);
top->eval();
tfp->dump(contextp->time());
}
top->final();
tfp->close();
delete top;
return 0;
}
执行
command
1
2
3
4
5
6# trace generate a wave file
verilator -Wall top.v sam.cpp --cc --trace --exe --build
# compiles
make -C obj_dir -f Vtop.mk Vtop
# run
./obj_dir/Vtopfiles
wave
总结
待更新…………