MIPS/sim/sim_main.cpp

47 lines
1.1 KiB
C++
Raw Normal View History

2021-09-24 16:37:47 +08:00
#include <verilated.h>
#include "Vmycpu_top.h"
vluint64_t main_time = 0;
double sc_time_stamp() {
return main_time; // Note does conversion to real, to match SystemC
}
int main(int argc, char** argv, char** env) {
if (0 && argc && argv && env) {}
Verilated::debug(0);
Verilated::randReset(2);
Verilated::traceEverOn(true);
Verilated::commandArgs(argc, argv);
Verilated::mkdir("logs");
Vmycpu_top* top = new Vmycpu_top; // Or use a const unique_ptr, or the VL_UNIQUE_PTR wrapper
top->aclk = 0;
while (!Verilated::gotFinish()) {
++main_time;
top->aclk = !top->aclk;
top->aresetn = (main_time < 10) ? 1 : 0;
if (main_time < 5) {
// Zero coverage if still early in reset, otherwise toggles there may
// falsely indicate a signal is covered
VerilatedCov::zero();
}
top->eval();
// TODO: fake AXI
}
top->final();
// Coverage analysis (since test passed)
#if VM_COVERAGE
Verilated::mkdir("logs");
VerilatedCov::write("logs/coverage.dat");
#endif
delete top;
top = NULL;
exit(0);
}