ysyx-workbench/npc/csrc/main.cpp
tracer-ysyx 8b71fb7db5 > sim RTL
ysyx_22040000 李心杨
Linux calcite 6.1.65 #1-NixOS SMP PREEMPT_DYNAMIC Sun Dec  3 06:32:13 UTC 2023 x86_64 GNU/Linux
 19:57:04  up  22:55,  2 users,  load average: 0.71, 0.62, 0.53
2023-12-23 19:57:04 +08:00

27 lines
687 B
C++

#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <verilated.h>
#include <verilated_vcd_c.h>
#include "Vexample.h"
int main(int argc, char **argv, char **env) {
int round = 100;
Verilated::commandArgs(argc, argv);
Vexample *top = new Vexample;
VerilatedVcdC *m_trace = new VerilatedVcdC;
top->trace(m_trace, 5);
m_trace->open("waveform.vcd");
while (round--) {
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));
}
m_trace->close();
delete top;
exit(EXIT_SUCCESS);
}