From 2488b5a97f85673e0a3a3a4bfd36ec5f7d15c53f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 14 Mar 2023 21:14:27 -0400 Subject: [PATCH] Fix pullup/pulldown to create implicit wires. --- src/V3LinkDot.cpp | 7 +++++++ test_regress/t/t_tri_pull_implicit.pl | 21 +++++++++++++++++++++ test_regress/t/t_tri_pull_implicit.v | 20 ++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100755 test_regress/t/t_tri_pull_implicit.pl create mode 100644 test_regress/t/t_tri_pull_implicit.v diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 94ac413fb..113be442d 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -1709,6 +1709,13 @@ private: } iterateChildren(nodep); } + void visit(AstPull* nodep) override { + // Deal with implicit definitions + // We used to nodep->allowImplicit() here, but it turns out + // normal "assigns" can also make implicit wires. Yuk. + pinImplicitExprRecurse(nodep->lhsp()); + iterateChildren(nodep); + } void visit(AstTypedefFwd* nodep) override { VSymEnt* const foundp = m_statep->getNodeSym(nodep)->findIdFallback(nodep->name()); if (!foundp && v3Global.opt.pedantic() diff --git a/test_regress/t/t_tri_pull_implicit.pl b/test_regress/t/t_tri_pull_implicit.pl new file mode 100755 index 000000000..b46d46042 --- /dev/null +++ b/test_regress/t/t_tri_pull_implicit.pl @@ -0,0 +1,21 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 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); + +compile( + ); + +execute( + check_finished => 1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_tri_pull_implicit.v b/test_regress/t/t_tri_pull_implicit.v new file mode 100644 index 000000000..c0c45e4d6 --- /dev/null +++ b/test_regress/t/t_tri_pull_implicit.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, 2023 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module t (/*AUTOARG*/); + + // verilator lint_off IMPLICIT + pulldown (pd); + pullup (pu); + + initial begin + if (pd != 0) $stop; + if (pu != 1) $stop; + $write("*-* All Finished *-*\n"); + $finish; + end + +endmodule