#include "Vsystem.h" #include "verilated.h" #include "stdio.h" Vsystem *system_state; VerilatedContext* contextp; /*In hz */ #define CPU_SPEED 1000 #define timeinc CPU_SPEED*1000000/2 void tick() { system_state->clock = 1; contextp->timeInc(timeinc); system_state->eval(); system_state->clock = 0; contextp->timeInc(timeinc); system_state->eval(); //printf("tick() %04x\n",system_state->address_bus); //trace->dump(timestamp); //timestamp += 500/MHz; } int main(int argc, char** argv) { contextp = new VerilatedContext; // Set debug level, 0 is off, 9 is highest presently used // May be overridden by commandArgs argument parsing contextp->debug(0); // Verilator must compute traced signals contextp->traceEverOn(true); contextp->commandArgs(argc, argv); system_state = new Vsystem{contextp}; system_state->reset=1; tick(); system_state->reset=0; tick(); system_state->reset=1; // Simulate until $finish while(!contextp->gotFinish()){ tick(); } system_state->final(); delete system_state; delete contextp; return 0; }