diff options
Diffstat (limited to 'tb')
| -rw-r--r-- | tb/avalon.hpp | 2 | ||||
| -rw-r--r-- | tb/avalon.impl.hpp | 14 | ||||
| -rw-r--r-- | tb/top/conspiracion.cpp | 22 |
3 files changed, 27 insertions, 11 deletions
diff --git a/tb/avalon.hpp b/tb/avalon.hpp index 8134677..4e33ab5 100644 --- a/tb/avalon.hpp +++ b/tb/avalon.hpp @@ -70,7 +70,7 @@ namespace taller::avalon public: interconnect(Platform &plat) noexcept; - void tick(bool clk); + bool tick(bool clk); void attach(slave &dev); std::uint32_t dump(std::uint32_t addr); diff --git a/tb/avalon.impl.hpp b/tb/avalon.impl.hpp index 03685d0..3173af8 100644 --- a/tb/avalon.impl.hpp +++ b/tb/avalon.impl.hpp @@ -22,7 +22,7 @@ namespace taller::avalon } template<class Platform> - void interconnect<Platform>::tick(bool clk) + bool interconnect<Platform>::tick(bool clk) { if(!plat.reset_reset_n) [[unlikely]] { @@ -32,7 +32,7 @@ namespace taller::avalon avl_address = 0; avl_writedata = 0; avl_byteenable = 0; - return; + return true; } if(active) @@ -51,7 +51,7 @@ namespace taller::avalon active = nullptr; } - return; + return true; } else if(!active) { avl_address = plat.avl_address; @@ -63,7 +63,7 @@ namespace taller::avalon assert(!avl_read || !avl_write); if(!avl_read && !avl_write) { - return; + return true; } for(auto &binding : devices) @@ -79,13 +79,13 @@ namespace taller::avalon { const char *op = avl_read ? "read" : "write"; fprintf(stderr, "[avl] attempt to %s memory hole at 0x%08x\n", op, avl_address); - assert(false); + return false; } if(avl_address & active->word_mask()) { fprintf(stderr, "[avl] unaligned address: 0x%08x\n", avl_address); - assert(false); + return false; } } @@ -100,6 +100,8 @@ namespace taller::avalon { plat.avl_waitrequest = !active->write(pos, avl_writedata, avl_byteenable); } + + return true; } template<class Platform> 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; } |
