From 1e546bb9d9ec28be49d837fcf55c4cd64445f5ab Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 9 Nov 2024 09:28:40 -0500 Subject: [PATCH] Add assertion on firing event inside class (#5597) --- src/V3Delayed.cpp | 1 + test_regress/t/t_event_class_fire.out | 5 +++++ test_regress/t/t_event_class_fire.py | 21 +++++++++++++++++++++ test_regress/t/t_event_class_fire.v | 24 ++++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 test_regress/t/t_event_class_fire.out create mode 100755 test_regress/t/t_event_class_fire.py create mode 100644 test_regress/t/t_event_class_fire.v diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 5edee1370..4d43665ec 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -891,6 +891,7 @@ class DelayedVisitor final : public VNVisitor { ifp->addThensp(newp); } + UASSERT_OBJ(m_activep, nodep, "No active to handle FireEvent"); AstActive* const activep = new AstActive{flp, "nba-event", m_activep->sensesp()}; m_activep->addNextHere(activep); activep->addStmtsp(prep); diff --git a/test_regress/t/t_event_class_fire.out b/test_regress/t/t_event_class_fire.out new file mode 100644 index 000000000..5cd5a3d51 --- /dev/null +++ b/test_regress/t/t_event_class_fire.out @@ -0,0 +1,5 @@ +%Error: Internal Error: t/t_event_class_fire.v:10:7: ../V3Delayed.cpp:#: No active to handle FireEvent + : ... note: In instance '$unit::Cls' + 10 | ->> e; + | ^~~ + ... See the manual at https://verilator.org/verilator_doc.html for more assistance. diff --git a/test_regress/t/t_event_class_fire.py b/test_regress/t/t_event_class_fire.py new file mode 100755 index 000000000..9de681711 --- /dev/null +++ b/test_regress/t/t_event_class_fire.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# 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 + +import vltest_bootstrap + +test.scenarios('simulator') + +# Issue #5597 makes this fail +test.compile(fails=test.vlt_all, + expect_filename=test.golden_filename, + verilator_flags2=['--timing']) + +#test.execute() + +test.passes() diff --git a/test_regress/t/t_event_class_fire.v b/test_regress/t/t_event_class_fire.v new file mode 100644 index 000000000..325fbafc0 --- /dev/null +++ b/test_regress/t/t_event_class_fire.v @@ -0,0 +1,24 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2024 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +class Cls; + event e; + task trig_e(); + ->> e; + endtask +endclass + +module top(); + event e; + initial begin + Cls c; + c = new; + c.trig_e(); + wait(e.triggered); + $write("*-* All Finished *-*\n"); + $finish; + end +endmodule