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 33 34 35 36 37 38 39 40 41 42
| #include <stdio.h> #include <stdlib.h> #include <assert.h>
#include "Vtop.h" #include "verilated.h"
#include "verilated_vcd_c.h"
int main(int argc, char** argv) { VerilatedContext* contextp = new VerilatedContext; VerilatedVcdC *tfp = new VerilatedVcdC; contextp->commandArgs(argc, argv); Vtop* top = new Vtop{contextp}; contextp->traceEverOn(true); top->trace(tfp, 0); tfp->open("wave.vcd"); while (!contextp->gotFinish()) { int a = rand() & 1; int b = rand() & 1; top->a = a; top->b = b; top->eval(); printf("a = %d, b = %d, f = %d\n", a, b, top->f); assert(top->f == (a ^ b)); tfp->dump(contextp->time()); contextp->timeInc(1); if (contextp->time() > 3) { contextp->gotFinish(true); } } delete top; delete contextp; tfp->close(); return 0; }
|