MIPS/sim/sim_main.cpp

45 lines
956 B
C++
Raw Normal View History

#include <verilated.h>
#include "Vtestbench_top.h"
vluint64_t main_time = 0;
double sc_time_stamp() {
return main_time;
}
int main(int argc, char **argv, char **env) {
Verilated::commandArgs(argc, argv);
Verilated::randReset(2);
Verilated::traceEverOn(true);
Verilated::mkdir("logs");
const int reset_time = 10;
2022-07-29 18:26:27 +08:00
const int time_limit = 2000000;
Vtestbench_top *top = new Vtestbench_top;
top->clk = 0;
while (!Verilated::gotFinish() && main_time < time_limit) {
++main_time;
top->clk = !top->clk;
top->resetn = (main_time < reset_time) ? 0 : 1;
if (main_time < reset_time) VerilatedCov::zero();
top->eval();
}
if (main_time == time_limit)
std::cout << "Time Limit Reached" << std::endl;
top->final();
#if VM_COVERAGE
Verilated::mkdir("logs");
VerilatedCov::write("logs/coverage.dat");
#endif
delete top;
top = NULL;
exit(0);
}