From 1f27d200401eb0497c23054ebbe04c488c6974b9 Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Sun, 18 Sep 2022 00:40:22 -0600 Subject: Update testbench --- tb/top/conspiracion.cpp | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'tb/top') diff --git a/tb/top/conspiracion.cpp b/tb/top/conspiracion.cpp index d4bdbcb..b8f803c 100644 --- a/tb/top/conspiracion.cpp +++ b/tb/top/conspiracion.cpp @@ -2,18 +2,48 @@ #include #include "Vconspiracion.h" +#include "Vconspiracion_conspiracion.h" +#include "Vconspiracion_platform.h" + +#include "../avalon.hpp" int main(int argc, char **argv) { - Verilated::commandArgs(argc, argv); // Remember args - Verilated::traceEverOn(true); + using namespace taller::avalon; + + Verilated::commandArgs(argc, argv); Vconspiracion top; - // Do not instead make Vtop as a file-scope static - // variable, as the "C++ static initialization order fiasco" - // may cause a crash + interconnect avl(*top.conspiracion->plat); + + int time = 0; + auto tick = [&]() + { + top.clk_clk = 0; + top.eval(); + top.clk_clk = 1; + top.eval(); + avl.tick(); + + std::printf("[%02d] out=0x%02x, done=%d\n", ++time, top.out, top.done); + }; + + top.dir = 1; + top.io = 1; + top.mov = 1; + top.clr = 1; + + for(int i = 0; i < 5; ++i) + { + top.add = 0; + tick(); + top.add = 1; + tick(); + } - top.eval(); + top.io = 0; + tick(); + tick(); top.final(); } -- cgit v1.2.3