From 1a43afe6f73998731f9d369e61739ea10eef5335 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 24 Dec 2023 11:02:52 -0500 Subject: [PATCH] Fix $finish twice to no longer exit (#4757). --- Changes | 1 + include/verilated.cpp | 9 +-------- test_regress/t/t_repeat.v | 8 ++------ 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/Changes b/Changes index 5c962a317..35c063cd4 100644 --- a/Changes +++ b/Changes @@ -50,6 +50,7 @@ Verilator 5.019 devel * Fix power operator with wide numbers and constants (#4721) (#4763). [Flavien Solt] * Fix parameter passing to ports (#4723). [Ryszard Rozak, Antmicro Ltd.] * Fix block names of nested do..while loops (#4728). [Ryszard Rozak, Antmicro Ltd.] +* Fix $finish twice to no longer exit (#4757). [Tim Hutt] Verilator 5.018 2023-10-30 diff --git a/include/verilated.cpp b/include/verilated.cpp index 420331f5e..8648ce8dc 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -107,16 +107,9 @@ thread_local Verilated::ThreadLocal Verilated::t_s; #ifndef VL_USER_FINISH ///< Define this to override the vl_finish function void vl_finish(const char* filename, int linenum, const char* hier) VL_MT_UNSAFE { - if (false && hier) {} + if (false && hier) {} // Unused argument VL_PRINTF( // Not VL_PRINTF_MT, already on main thread "- %s:%d: Verilog $finish\n", filename, linenum); - if (Verilated::threadContextp()->gotFinish()) { - VL_PRINTF( // Not VL_PRINTF_MT, already on main thread - "- %s:%d: Second verilog $finish, exiting\n", filename, linenum); - Verilated::runFlushCallbacks(); - Verilated::runExitCallbacks(); - std::exit(0); - } Verilated::threadContextp()->gotFinish(true); } #endif diff --git a/test_regress/t/t_repeat.v b/test_regress/t/t_repeat.v index b80287bad..54c20c4d9 100644 --- a/test_regress/t/t_repeat.v +++ b/test_regress/t/t_repeat.v @@ -26,12 +26,8 @@ module t (/*AUTOARG*/); end if (times != 10) $stop; // - // verilator lint_off INFINITELOOP - forever begin - // verilator lint_on INFINITELOOP - $write("*-* All Finished *-*\n"); - $finish; - end + $write("*-* All Finished *-*\n"); + $finish; end endmodule