From a951446f9bb085549c093ed5890f78f98a886f51 Mon Sep 17 00:00:00 2001 From: Yutetsu TAKATSUKASA Date: Mon, 19 Feb 2024 21:26:58 +0900 Subject: [PATCH] Add --[no]-stop-fail option (#4904) Co-authored-by: Wilson Snyder --- bin/verilator | 1 + docs/guide/exe_verilator.rst | 4 ++++ src/V3Assert.cpp | 2 +- src/V3Options.cpp | 1 + src/V3Options.h | 2 ++ test_regress/t/t_assert_unique_case.out | 12 ++++++++++++ test_regress/t/t_assert_unique_case.pl | 24 ++++++++++++++++++++++++ 7 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 test_regress/t/t_assert_unique_case.out create mode 100755 test_regress/t/t_assert_unique_case.pl diff --git a/bin/verilator b/bin/verilator index a542724a2..4f3ef3d89 100755 --- a/bin/verilator +++ b/bin/verilator @@ -437,6 +437,7 @@ detailed descriptions of these arguments. --stats Create statistics file --stats-vars Provide statistics on variables --no-std Prevent parsing standard library + --no-stop-fail Do not call $stop when assertion fails --structs-packed Convert all unpacked structures to packed structures -sv Enable SystemVerilog parsing +systemverilogext+ Synonym for +1800-2017ext+ diff --git a/docs/guide/exe_verilator.rst b/docs/guide/exe_verilator.rst index 70099b8d3..ea564449a 100644 --- a/docs/guide/exe_verilator.rst +++ b/docs/guide/exe_verilator.rst @@ -1280,6 +1280,10 @@ Summary: Prevents parsing standard library. +.. option:: --no-stop-fail + + Don't call $stop when assertion fails. Simulation will continue. + .. option:: --structs-packed Converts all unpacked structures to packed structures, and issues an diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 8da4e113a..b85a13e6b 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -127,7 +127,7 @@ class AssertVisitor final : public VNVisitor { AstNode* const bodysp = dispp; replaceDisplay(dispp, "%%Error"); // Convert to standard DISPLAY format if (exprsp) dispp->fmtp()->exprsp()->addNext(exprsp); - bodysp->addNext(new AstStop{nodep->fileline(), true}); + if (v3Global.opt.stopFail()) bodysp->addNext(new AstStop{nodep->fileline(), true}); return bodysp; } diff --git a/src/V3Options.cpp b/src/V3Options.cpp index cc54663a8..50f05f5e6 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -1442,6 +1442,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, m_stats |= flag; }); DECL_OPTION("-std", OnOff, &m_std); + DECL_OPTION("-stop-fail", OnOff, &m_stopFail); DECL_OPTION("-structs-packed", OnOff, &m_structsPacked); DECL_OPTION("-sv", CbCall, [this]() { m_defaultLanguage = V3LangCode::L1800_2017; }); diff --git a/src/V3Options.h b/src/V3Options.h index 846025a4a..e520826ec 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -315,6 +315,7 @@ private: int m_publicDepth = 0; // main switch: --public-depth int m_reloopLimit = 40; // main switch: --reloop-limit VOptionBool m_skipIdentical; // main switch: --skip-identical + bool m_stopFail = true; // main switch: --stop-fail int m_threads = 1; // main switch: --threads int m_threadsMaxMTasks = 0; // main switch: --threads-max-mtasks VTimescale m_timeDefaultPrec; // main switch: --timescale @@ -549,6 +550,7 @@ public: int publicDepth() const { return m_publicDepth; } int reloopLimit() const { return m_reloopLimit; } VOptionBool skipIdentical() const { return m_skipIdentical; } + bool stopFail() const { return m_stopFail; } int threads() const VL_MT_SAFE { return m_threads; } int threadsMaxMTasks() const { return m_threadsMaxMTasks; } bool mtasks() const { return (m_threads > 1); } diff --git a/test_regress/t/t_assert_unique_case.out b/test_regress/t/t_assert_unique_case.out new file mode 100644 index 000000000..46c287188 --- /dev/null +++ b/test_regress/t/t_assert_unique_case.out @@ -0,0 +1,12 @@ +match_item0 +match_item0 +match_item0 +match_item0 +match_item0 +match_item0 +match_item0 +match_item0 +match_item0 +[90] %Error: t_assert_unique_case_bad.v:36: Assertion failed in top.t: unique case, but multiple matches found for '12'h388' +*-* All Finished *-* +match_item0 diff --git a/test_regress/t/t_assert_unique_case.pl b/test_regress/t/t_assert_unique_case.pl new file mode 100755 index 000000000..a9f22933c --- /dev/null +++ b/test_regress/t/t_assert_unique_case.pl @@ -0,0 +1,24 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2024 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(simulator => 1); +top_filename("t/t_assert_unique_case_bad.v"); + +compile( + verilator_flags2 => ["-x-assign 0 --assert --no-stop-fail"], + ); + +execute( + check_finished => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1;