Files

44 lines
1.2 KiB
C++
Raw Permalink Normal View History

2024-04-14 16:08:20 +03:00
#include "verilated.h"
#include "verilated_vcd_c.h"
2022-12-03 18:36:50 +03:00
#include "V@TOPMODULE@.h"
#define DUMPFILE "@WORKDIR@/@TOPMODULE@.vcd"
2024-04-14 16:08:20 +03:00
int main(int argc, char** argv, char**) {
// Setup context, defaults, and parse command line
Verilated::debug(0);
const std::unique_ptr<VerilatedContext> contextp{new VerilatedContext};
contextp->traceEverOn(true);
contextp->commandArgs(argc, argv);
2022-12-03 18:36:50 +03:00
2024-04-14 16:08:20 +03:00
// Construct the Verilated model, from Vtop.h generated from Verilating
const std::unique_ptr<V@TOPMODULE@> topp{new V@TOPMODULE@{contextp.get()}};
2022-12-03 18:36:50 +03:00
VerilatedVcdC *vcd = new VerilatedVcdC;
2024-04-14 16:08:20 +03:00
topp->trace(vcd, 99);
2022-12-03 18:36:50 +03:00
vcd->open(DUMPFILE);
2024-04-14 16:08:20 +03:00
// Simulate until $finish
while (!contextp->gotFinish()) {
// Evaluate model
topp->eval();
vcd->dump(contextp->time());
// Advance time
if (!topp->eventsPending()) break;
contextp->time(topp->nextTimeSlot());
}
2022-12-03 18:36:50 +03:00
2024-04-14 16:08:20 +03:00
if (!contextp->gotFinish()) {
VL_DEBUG_IF(VL_PRINTF("+ Exiting without $finish; no events left\n"););
2022-12-03 18:36:50 +03:00
}
2024-04-14 16:08:20 +03:00
// Execute 'final' processes
topp->final();
2022-12-03 18:36:50 +03:00
2024-04-14 16:08:20 +03:00
// Print statistical summary report
contextp->statsPrintSummary();
vcd->close();
2022-12-03 18:36:50 +03:00
return 0;
}