spi/test_spi_write_read_mode0.cpp

46 lines
770 B
C++

#include <stdio.h>
#include <verilated.h>
#include "Vtest_spi_write_read_mode0.h"
using TopModule = Vtest_spi_write_read_mode0;
VerilatedContext *ctx;
TopModule *sim;
static void progress() {
sim->eval();
ctx->timeInc(1);
sim->clk = !sim->clk;
}
static void progress_n(int f) {
for (int i = 0; i < f; i++)
progress();
}
int main(int argc, char **argv) {
ctx = new VerilatedContext;
ctx->traceEverOn(true);
ctx->commandArgs(argc, argv);
sim = new TopModule(ctx);
sim->ss = 0;
sim->clk = 0;
sim->activate = 0;
progress_n(8);
sim->ss = 1;
progress();
sim->data_ctrl = 0b110011011111001100011111;
sim->activate = 1;
while (!sim->master_finished)
progress();
progress_n(5);
sim->ss = 0;
progress_n(5);
sim->final();
delete sim;
return 0;
}