2023-12-23 10:31:48 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstdlib>
|
2023-12-23 11:57:04 +00:00
|
|
|
#include <verilated.h>
|
|
|
|
#include <verilated_vcd_c.h>
|
2023-12-23 09:27:29 +00:00
|
|
|
#include "Vexample.h"
|
|
|
|
|
2023-12-23 11:58:48 +00:00
|
|
|
#define MAX_SIM_TIME 100
|
|
|
|
|
2023-12-23 09:27:29 +00:00
|
|
|
int main(int argc, char **argv, char **env) {
|
2023-12-23 11:58:48 +00:00
|
|
|
int sim_time = 0;
|
2023-12-23 09:27:29 +00:00
|
|
|
Verilated::commandArgs(argc, argv);
|
|
|
|
Vexample *top = new Vexample;
|
2023-12-23 11:57:21 +00:00
|
|
|
|
|
|
|
Verilated::traceEverOn(true);
|
2023-12-23 11:57:04 +00:00
|
|
|
VerilatedVcdC *m_trace = new VerilatedVcdC;
|
|
|
|
top->trace(m_trace, 5);
|
|
|
|
m_trace->open("waveform.vcd");
|
2023-12-23 11:58:48 +00:00
|
|
|
for (sim_time = 0; sim_time < MAX_SIM_TIME; sim_time++) {
|
2023-12-23 10:31:48 +00:00
|
|
|
int a = rand() & 1;
|
|
|
|
int b = rand() & 1;
|
|
|
|
top->a = a;
|
|
|
|
top->b = b;
|
2023-12-23 09:27:29 +00:00
|
|
|
top->eval();
|
2023-12-23 10:31:48 +00:00
|
|
|
printf("a = %d, b = %d, f = %d\n", a, b, top->f);
|
|
|
|
assert(top->f == (a ^ b));
|
2023-12-23 11:58:48 +00:00
|
|
|
m_trace->dump(sim_time);
|
2023-12-23 09:27:29 +00:00
|
|
|
}
|
2023-12-23 11:57:04 +00:00
|
|
|
m_trace->close();
|
|
|
|
delete top;
|
|
|
|
exit(EXIT_SUCCESS);
|
2023-12-23 09:27:29 +00:00
|
|
|
}
|