From db9bd3a7928ca90552d0f6f1097fbdeb21cbf87f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 18 Jan 2026 16:28:48 -0500 Subject: [PATCH] Fix clocking unsupported tristate assign error (#6942). Fixes #6942. --- src/V3Tristate.cpp | 15 ++++++++------- test_regress/t/t_tri_clocking.py | 18 ++++++++++++++++++ test_regress/t/t_tri_clocking.v | 20 ++++++++++++++++++++ 3 files changed, 46 insertions(+), 7 deletions(-) create mode 100755 test_regress/t/t_tri_clocking.py create mode 100644 test_regress/t/t_tri_clocking.v diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index 33d64df4d..2b993ba3f 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -316,17 +316,16 @@ public: const TristateVertex* const vertexp = reinterpret_cast(nodep->user4p()); return vertexp && vertexp->feedsTri(); } - void didProcess(AstNode* nodep) { - TristateVertex* const vertexp = reinterpret_cast(nodep->user4p()); - if (!vertexp) { + void didProcess(AstNode* nodep, bool quiet = false) { + if (TristateVertex* const vertexp = reinterpret_cast(nodep->user4p())) { + // We don't warn if no vertexp->isTristate() as the creation + // process makes midling nodes that don't have it set + vertexp->processed(true); + } else if (!quiet) { // Not v3errorSrc as no reason to stop the world nodep->v3warn(E_UNSUPPORTED, "Unsupported tristate construct (not in propagation graph): " << nodep->prettyTypeName()); - } else { - // We don't warn if no vertexp->isTristate() as the creation - // process makes midling nodes that don't have it set - vertexp->processed(true); } } // ITERATOR METHODS @@ -1340,6 +1339,8 @@ class TristateVisitor final : public TristateBaseVisitor { nodep->rhsp()->user1p(nullptr); UINFO(9, " enp<-rhs " << nodep->lhsp()->user1p()); m_tgraph.didProcess(nodep); + } else { + m_tgraph.didProcess(nodep, true); } m_alhs = true; // And user1p() will indicate tristate equation, if any if (AstAssignW* const assignWp = VN_CAST(nodep, AssignW)) { diff --git a/test_regress/t/t_tri_clocking.py b/test_regress/t/t_tri_clocking.py new file mode 100755 index 000000000..f989a35fb --- /dev/null +++ b/test_regress/t/t_tri_clocking.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2025 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') + +test.compile() + +test.execute() + +test.passes() diff --git a/test_regress/t/t_tri_clocking.v b/test_regress/t/t_tri_clocking.v new file mode 100644 index 000000000..10542e59e --- /dev/null +++ b/test_regress/t/t_tri_clocking.v @@ -0,0 +1,20 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2026 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +interface wb_ifc; + logic clk; + wire rst; + tri0 cyc; + clocking mck @(posedge clk); + input rst; + output cyc; + endclocking +endinterface + +module t; + wb_ifc wb_ma (); + initial $finish; +endmodule