2023-12-23 12:23:18 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <verilated.h>
|
|
|
|
#include <verilated_vcd_c.h>
|
2024-01-01 06:41:31 +00:00
|
|
|
#include <Vexample.h>
|
2022-02-21 04:22:27 +00:00
|
|
|
|
2024-01-01 06:41:31 +00:00
|
|
|
const int MAX_SIM_TIME=100;
|
2023-12-23 12:23:18 +00:00
|
|
|
|
|
|
|
int main(int argc, char **argv, char **env) {
|
|
|
|
int sim_time = 0;
|
|
|
|
Verilated::commandArgs(argc, argv);
|
|
|
|
Vexample *top = new Vexample;
|
|
|
|
|
|
|
|
Verilated::traceEverOn(true);
|
|
|
|
VerilatedVcdC *m_trace = new VerilatedVcdC;
|
2024-01-01 06:41:31 +00:00
|
|
|
#ifdef VERILATOR_TRACE
|
2023-12-23 12:23:18 +00:00
|
|
|
top->trace(m_trace, 5);
|
|
|
|
m_trace->open("waveform.vcd");
|
2024-01-01 06:41:31 +00:00
|
|
|
#endif
|
2023-12-23 12:23:18 +00:00
|
|
|
for (sim_time = 0; sim_time < MAX_SIM_TIME; sim_time++) {
|
2024-01-01 06:41:31 +00:00
|
|
|
CData sw = rand() & 0b11;
|
|
|
|
top->sw = sw;
|
2023-12-23 12:23:18 +00:00
|
|
|
top->eval();
|
2024-01-01 06:41:31 +00:00
|
|
|
printf("sw0 = %d, sw1 = %d, ledr = %d\n", sw & 0b1, sw >> 1, top->ledr);
|
|
|
|
assert(top->ledr == ((sw >> 1) ^ (sw & 0b1)) );
|
|
|
|
#ifdef VERILATOR_TRACE
|
2023-12-23 12:23:18 +00:00
|
|
|
m_trace->dump(sim_time);
|
2024-01-01 06:41:31 +00:00
|
|
|
#endif
|
2023-12-23 12:23:18 +00:00
|
|
|
}
|
2024-01-01 06:41:31 +00:00
|
|
|
#ifdef VERILATOR_TRACE
|
2023-12-23 12:23:18 +00:00
|
|
|
m_trace->close();
|
2024-01-01 06:41:31 +00:00
|
|
|
#endif
|
2023-12-23 12:23:18 +00:00
|
|
|
delete top;
|
|
|
|
exit(EXIT_SUCCESS);
|
2022-02-21 04:22:27 +00:00
|
|
|
}
|