-
Notifications
You must be signed in to change notification settings - Fork 0
/
sim_main.cpp
32 lines (27 loc) · 935 Bytes
/
sim_main.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
#include "Vtoptoplevel.h"
#include "verilated.h"
// for traces
#include "verilated_vcd_c.h" // for Verilator trace things
#include <sys/stat.h> // for mkdir
int main(int argc, char** argv) {
VerilatedContext* contextp = new VerilatedContext;
contextp->commandArgs(argc, argv);
Vtoptoplevel* top = new Vtoptoplevel{contextp};
Verilated::traceEverOn(true);
VL_PRINTF("Setting up to save traces to vcd/waveforms.vcd\n");
VerilatedVcdC* tfp = new VerilatedVcdC;
top->trace(tfp, 99); // Trace 99 levels of hierarchy (or see below)
// tfp->dumpvars(1, "t"); // trace 1 level under "t"
mkdir("vcd", 0777);
tfp->open("vcd/waveforms.vcd");
int sim_time = 100;
while (contextp->time() < sim_time && !contextp->gotFinish()) {
contextp->timeInc(1);
top->eval();
tfp->dump(contextp->time());
}
tfp->close();
delete top;
delete contextp;
return 0;
}