diff --git a/firmware/rtl/autoapproach/bram_interface_sim.cpp b/firmware/rtl/autoapproach/bram_interface_sim.cpp index 97270f7..068b29e 100644 --- a/firmware/rtl/autoapproach/bram_interface_sim.cpp +++ b/firmware/rtl/autoapproach/bram_interface_sim.cpp @@ -1,10 +1,5 @@ -#include -#include #include -#include -#include #include -#include #include #include #include @@ -118,9 +113,8 @@ static void refresh_data() { } int main(int argc, char *argv[]) { - Verilated::commandArgs(argc, argv); Verilated::traceEverOn(true); - tb = new TB(); + tb = new TB(argc, argv); printf("test basic read/write\n"); refresh_data(); diff --git a/firmware/rtl/testbench.hpp b/firmware/rtl/testbench.hpp index 17b2ed9..7976390 100644 --- a/firmware/rtl/testbench.hpp +++ b/firmware/rtl/testbench.hpp @@ -1,13 +1,19 @@ #pragma once #include +#include /* https://zipcpu.com/blog/2017/06/21/looking-at-verilator.html */ template class TB { int tick_count; int bailout; - public: TOP mod; - TB(int _bailout = 0) : mod(), bailout(_bailout) { + public: + TOP mod; + VerilatedContext vc; + + TB(int argc, char *argv[], int _bailout = 0) : mod(), bailout(_bailout), vc() { + vc.commandArgs(argc, argv); + vc.traceEverOn(true); mod.clk = 0; tick_count = 0; } @@ -19,10 +25,10 @@ template class TB { virtual void run_clock() { mod.clk = !mod.clk; mod.eval(); - Verilated::timeInc(1); + vc.timeInc(1); mod.clk = !mod.clk; mod.eval(); - Verilated::timeInc(1); + vc.timeInc(1); tick_count++; if (bailout > 0 && tick_count >= bailout)