summaryrefslogtreecommitdiff
path: root/tb/top/conspiracion.cpp
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2022-11-16 20:26:10 -0600
committerAlejandro Soto <alejandro@34project.org>2022-11-16 23:32:25 -0600
commitf1353e81d59986dfc11e3f1a43e351f6c8117f9b (patch)
tree94caa9c254abf26552a23d22c323bfae1beebf80 /tb/top/conspiracion.cpp
parentc64dee965fa00a4b7e3c3705da5e226ea56082ed (diff)
Gracefully exit when Avalon assertions fail during simulation
Diffstat (limited to '')
-rw-r--r--tb/top/conspiracion.cpp22
1 files changed, 18 insertions, 4 deletions
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;
}