From f1353e81d59986dfc11e3f1a43e351f6c8117f9b Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Wed, 16 Nov 2022 20:26:10 -0600 Subject: Gracefully exit when Avalon assertions fail during simulation --- tb/top/conspiracion.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'tb/top') diff --git a/tb/top/conspiracion.cpp b/tb/top/conspiracion.cpp index 789a0df..8e81c84 100644 --- a/tb/top/conspiracion.cpp +++ b/tb/top/conspiracion.cpp @@ -242,15 +242,25 @@ int main(int argc, char **argv) int time = 0; top.clk_clk = 1; + bool failed = false; + auto tick = [&]() { top.clk_clk = !top.clk_clk; top.eval(); - avl.tick(top.clk_clk); + if(!avl.tick(top.clk_clk)) + { + failed = true; + } + if(enable_video) { - avl_vga.tick(top.clk_clk); + if(!avl_vga.tick(top.clk_clk)) + { + failed = true; + } + vga.tick(top.clk_clk); } @@ -274,6 +284,10 @@ int main(int argc, char **argv) for(unsigned i = 0; i < *cycles; ++i) { cycle(); + if(failed) + { + break; + } } if(enable_trace) @@ -281,7 +295,7 @@ int main(int argc, char **argv) trace.close(); } - if(dump_regs) + if(dump_regs || failed) { std::puts("=== dump-regs ==="); @@ -327,5 +341,5 @@ int main(int argc, char **argv) } top.final(); - return EXIT_SUCCESS; + return failed ? EXIT_FAILURE : EXIT_SUCCESS; } -- cgit v1.2.3