From 003c2ebeed882c83ac06a0cd1f7449677ca31d14 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 13 Nov 2021 23:00:12 +0000 Subject: Rename the verilator script --- scripts/verilator_main.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 scripts/verilator_main.cpp (limited to 'scripts') diff --git a/scripts/verilator_main.cpp b/scripts/verilator_main.cpp new file mode 100644 index 0000000..4561158 --- /dev/null +++ b/scripts/verilator_main.cpp @@ -0,0 +1,35 @@ +#include +#include +#include "Vmain.h" +#include "verilated.h" + +int main(int argc, char **argv) { + // Initialize Verilators variables + Verilated::commandArgs(argc, argv); + + // Create an instance of our module under test + Vmain *tb = new Vmain; + + tb->clk = 0; + tb->start = 0; + tb->reset = 0; + tb->eval(); tb->clk = 1; tb->eval(); tb->clk = 0; tb->eval(); + tb->reset = 1; + tb->eval(); tb->clk = 1; tb->eval(); tb->clk = 0; tb->eval(); + tb->reset = 0; + tb->eval(); tb->clk = 1; tb->eval(); tb->clk = 0; tb->eval(); + + int cycles = 1; + + // Tick the clock until we are done + while(!tb->finish) { + tb->clk = 1; + tb->eval(); + tb->clk = 0; + tb->eval(); + cycles++; + } + + printf("cycles: %d\nfinished: %d\n", cycles, (unsigned)tb->return_val); + exit(EXIT_SUCCESS); +} -- cgit