diff --git a/bin/verilator b/bin/verilator index 0ced7e0c0..fb5853c0f 100755 --- a/bin/verilator +++ b/bin/verilator @@ -1717,7 +1717,8 @@ Enable simulation runtime debugging at the provided level. =item +verilator+error+limit+I Set number of non-fatal errors (e.g. assertion failures) before exiting -simulation. Defaults to 1. +simulation runtime. Also affects number of $stop calls needed before +exit. Defaults to 1. =item +verilator+help diff --git a/include/verilated.cpp b/include/verilated.cpp index dc1528458..21dff74e5 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -111,15 +111,17 @@ void vl_fatal(const char* filename, int linenum, const char* hier, const char* m } #endif -//=========================================================================== -// Error handline - +#ifndef VL_USER_STOP_MAYBE ///< Define this to override this function void vl_stop_maybe(const char* filename, int linenum, const char* hier, bool maybe) VL_MT_UNSAFE { Verilated::errorCountInc(); - if (!maybe || Verilated::errorCount() >= Verilated::errorLimit()) { + if (maybe && Verilated::errorCount() < Verilated::errorLimit()) { + VL_PRINTF( // Not VL_PRINTF_MT, already on main thread + "-Info: %s:%d: %s\n", filename, linenum, "Verilog $stop, ignored due to +verilator+error+limit"); + } else { vl_stop(filename, linenum, hier); } } +#endif //=========================================================================== // Wrapper to call certain functions via messages when multithreaded diff --git a/include/verilated.h b/include/verilated.h index 997615f04..d28820edc 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -575,7 +575,7 @@ extern void vl_fatal(const char* filename, int linenum, const char* hier, extern void VL_FINISH_MT(const char* filename, int linenum, const char* hier) VL_MT_SAFE; /// Multithread safe wrapper for calls to $stop extern void VL_STOP_MT(const char* filename, int linenum, const char* hier, - bool maybe = false) VL_MT_SAFE; + bool maybe = true) VL_MT_SAFE; /// Multithread safe wrapper to call for a couple of fatal messages extern void VL_FATAL_MT(const char* filename, int linenum, const char* hier, const char* msg) VL_MT_SAFE; diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 4dc7150ca..a642170b5 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -3587,8 +3587,7 @@ class AstStop : public AstNodeStmt { bool m_maybe; // Maybe stop, maybe not based on error count public: explicit AstStop(FileLine* fl, bool maybe) - : AstNodeStmt(fl) - , m_maybe(maybe) {} + : AstNodeStmt(fl) {} ASTNODE_NODE_FUNCS(Stop) virtual bool isGateOptimizable() const { return false; } virtual bool isPredictOptimizable() const { return false; } @@ -3599,7 +3598,6 @@ public: virtual V3Hash sameHash() const { return V3Hash(fileline()->lineno()); } virtual bool same(const AstNode* samep) const { return fileline() == samep->fileline(); } - bool maybe() const { return m_maybe; } }; class AstFinish : public AstNodeStmt { diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 15b8cf885..d00a38e64 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -533,7 +533,6 @@ public: puts(", "); puts(cvtToStr(nodep->fileline()->lineno())); puts(", \"\""); - if (nodep->maybe()) puts(", true"); puts(");\n"); } virtual void visit(AstFinish* nodep) { diff --git a/test_regress/t/t_runflag_errlimit.out b/test_regress/t/t_runflag_errlimit.out deleted file mode 100644 index e78a6623f..000000000 --- a/test_regress/t/t_runflag_errlimit.out +++ /dev/null @@ -1,5 +0,0 @@ -[0] %Error: t_runflag_errlimit.v:8: Assertion failed in top.t: One -[0] %Error: t_runflag_errlimit.v:9: Assertion failed in top.t: Two -[0] %Error: t_runflag_errlimit.v:10: Assertion failed in top.t: Three -%Error: t/t_runflag_errlimit.v:10: Verilog $stop -Aborting... diff --git a/test_regress/t/t_runflag_errorlimit.out b/test_regress/t/t_runflag_errorlimit.out new file mode 100644 index 000000000..1a0255428 --- /dev/null +++ b/test_regress/t/t_runflag_errorlimit.out @@ -0,0 +1,7 @@ +[0] %Error: t_runflag_errorlimit.v:8: Assertion failed in top.t: One +-Info: t/t_runflag_errorlimit.v:8: Verilog $stop, ignored due to +verilator+error+limit +[0] %Error: t_runflag_errorlimit.v:9: Assertion failed in top.t: Two +-Info: t/t_runflag_errorlimit.v:9: Verilog $stop, ignored due to +verilator+error+limit +[0] %Error: t_runflag_errorlimit.v:10: Assertion failed in top.t: Three +%Error: t/t_runflag_errorlimit.v:10: Verilog $stop +Aborting... diff --git a/test_regress/t/t_runflag_errlimit.pl b/test_regress/t/t_runflag_errorlimit.pl similarity index 100% rename from test_regress/t/t_runflag_errlimit.pl rename to test_regress/t/t_runflag_errorlimit.pl diff --git a/test_regress/t/t_runflag_errlimit.v b/test_regress/t/t_runflag_errorlimit.v similarity index 100% rename from test_regress/t/t_runflag_errlimit.v rename to test_regress/t/t_runflag_errorlimit.v