build: move to cmake

This commit is contained in:
xinyangli 2024-01-05 23:50:26 +08:00
parent 38818f6f66
commit 1702da0a0a
11 changed files with 896 additions and 78 deletions

View file

@ -3,14 +3,14 @@
#include <cstdlib>
#include <verilated.h>
#include <verilated_vcd_c.h>
#include <Vexample.h>
#include <VSwitch.h>
const int MAX_SIM_TIME=100;
int main(int argc, char **argv, char **env) {
int sim_time = 0;
Verilated::commandArgs(argc, argv);
Vexample *top = new Vexample;
VSwitch *top = new VSwitch;
Verilated::traceEverOn(true);
VerilatedVcdC *m_trace = new VerilatedVcdC;
@ -19,11 +19,11 @@ int main(int argc, char **argv, char **env) {
m_trace->open("waveform.vcd");
#endif
for (sim_time = 0; sim_time < MAX_SIM_TIME; sim_time++) {
CData sw = rand() & 0b11;
top->sw = sw;
top->io_sw_0 = rand() % 2;
top->io_sw_1 = rand() % 2;
top->eval();
printf("sw0 = %d, sw1 = %d, ledr = %d\n", sw & 0b1, sw >> 1, top->ledr);
assert(top->ledr == ((sw >> 1) ^ (sw & 0b1)) );
printf("sw0 = %d, sw1 = %d, ledr = %d\n", top->io_sw_0, top->io_sw_1, top->io_out);
assert(top->io_out == (top->io_sw_0 ^ top->io_sw_1));
#ifdef VERILATOR_TRACE
m_trace->dump(sim_time);
#endif