From ba8e0a1437a5f1ea73d22b595b31b2b5c7fc5463 Mon Sep 17 00:00:00 2001 From: Ryszard Rozak Date: Fri, 25 Sep 2026 15:26:22 +0200 Subject: [PATCH] Set status of finished process immediately (#8503) Signed-off-by: Ryszard Rozak --- src/V3SchedTiming.cpp | 5 +--- src/V3Timing.cpp | 4 ++++ test_regress/t/t_process_join_any_finished.py | 18 ++++++++++++++ test_regress/t/t_process_join_any_finished.v | 24 +++++++++++++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100755 test_regress/t/t_process_join_any_finished.py create mode 100644 test_regress/t/t_process_join_any_finished.v diff --git a/src/V3SchedTiming.cpp b/src/V3SchedTiming.cpp index f432a9a5c..e5078ad77 100644 --- a/src/V3SchedTiming.cpp +++ b/src/V3SchedTiming.cpp @@ -545,10 +545,7 @@ class TransformForksVisitor final : public VNVisitor { // Replace the body of the begin with a call to the newly created function nodep->addStmtsp(callp->makeStmt()); // Propagate if needs process - if (nodep->needProcess()) { - newfuncp->setNeedProcess(); - newfuncp->addStmtsp(new AstCStmt{flp, "vlProcess->state(VlProcess::FINISHED);"}); - } + if (nodep->needProcess()) newfuncp->setNeedProcess(); remapLocals(newfuncp, callp); } void visit(AstCAwait* nodep) override { diff --git a/src/V3Timing.cpp b/src/V3Timing.cpp index 733e9fd64..a346dff7e 100644 --- a/src/V3Timing.cpp +++ b/src/V3Timing.cpp @@ -1463,6 +1463,10 @@ class TimingControlVisitor final : public VNVisitor { // Name the begin (later the name will be used for a new function) itemp->name(nodep->name() + "__" + std::to_string(idx++)); + if (itemp->needProcess()) { + itemp->addStmtsp( + new AstCStmt{itemp->fileline(), "vlProcess->state(VlProcess::FINISHED);"}); + } } if (!nodep->joinType().joinNone()) makeForkJoin(nodep); } diff --git a/test_regress/t/t_process_join_any_finished.py b/test_regress/t/t_process_join_any_finished.py new file mode 100755 index 000000000..46d1fe4c0 --- /dev/null +++ b/test_regress/t/t_process_join_any_finished.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# 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-FileCopyrightText: 2026 Wilson Snyder +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +import vltest_bootstrap + +test.scenarios('simulator') + +test.compile(verilator_flags2=['--binary']) + +test.execute() + +test.passes() diff --git a/test_regress/t/t_process_join_any_finished.v b/test_regress/t/t_process_join_any_finished.v new file mode 100644 index 000000000..f33b56b8c --- /dev/null +++ b/test_regress/t/t_process_join_any_finished.v @@ -0,0 +1,24 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain. +// SPDX-FileCopyrightText: 2026 Antmicro +// SPDX-License-Identifier: CC0-1.0 + +module t; + process proc; + + initial begin + fork + begin + proc = process::self(); + #1; + end + #10; + join_any + + if (proc.status() != process::FINISHED) $stop; + + $write("*-* All Finished *-*\n"); + $finish; + end +endmodule