From 8031ca2616805a393f9c2614110a2559ecc733ac Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 29 May 2025 21:02:00 -0400 Subject: [PATCH] Add `MODMISSING` error, in place of unnamed error (#6054). --- Changes | 1 + docs/guide/warnings.rst | 13 +++++++++++++ src/V3Error.h | 8 +++++--- src/V3Width.cpp | 13 +++++++------ test_regress/t/t_gen_missing_bad.out | 24 ++++++++++++------------ test_regress/t/t_gen_nonconst_bad.out | 20 ++++++++++---------- test_regress/t/t_inst_long_bad.out | 8 ++++---- test_regress/t/t_lint_modmissing.py | 16 ++++++++++++++++ test_regress/t/t_lint_modmissing.v | 10 ++++++++++ 9 files changed, 78 insertions(+), 35 deletions(-) create mode 100755 test_regress/t/t_lint_modmissing.py create mode 100644 test_regress/t/t_lint_modmissing.v diff --git a/Changes b/Changes index 911d8012c..f8540fb54 100644 --- a/Changes +++ b/Changes @@ -24,6 +24,7 @@ Verilator 5.037 devel * Add aggregate type error checks (#5570) (#5950). [Shou-Li Hsu] * Add `--filter-type` to verilator_coverage (#6030). [Ryszard Rozak, Antmicro Ltd.] * Add `--hierarchical-threads` (#6037). [Bartłomiej Chmiel] +* Add `MODMISSING` error, in place of unnamed error (#6054). [Paul Swirhun] * Improve hierarchical scheduling visualization in V3ExecGraph (#6009). [Bartłomiej Chmiel, Antmicro Ltd.] * Fix --x-initial and --x-assign random stability (#2662) (#5958) (#6018) (#6025). [Todd Strader] * Fix filename backslash escapes in C code (#5947). diff --git a/docs/guide/warnings.rst b/docs/guide/warnings.rst index 24f525105..d78fac0c5 100644 --- a/docs/guide/warnings.rst +++ b/docs/guide/warnings.rst @@ -1180,6 +1180,19 @@ List Of Warnings discarded. +.. option:: MODMISSING + + .. TODO better example + + Error that a module, typically referenced by a cell, was not found. + This is typically fatal, but may be suppressed in some linting + situations with missing libraries. + + Ignoring this error will cause the cell definition to be discarded. + Simulation results will likely be wrong, so typically used only with + lint-only. + + .. option:: MULTIDRIVEN Warns that the specified signal comes from multiple :code:`always` diff --git a/src/V3Error.h b/src/V3Error.h index f96e1d81a..633299f80 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -120,6 +120,7 @@ public: MINTYPMAXDLY, // Unsupported: min/typ/max delay expressions MISINDENT, // Misleading indentation MODDUP, // Duplicate module + MODMISSING, // Error: missing module MULTIDRIVEN, // Driven from multiple blocks MULTITOP, // Multiple top level modules NEWERSTD, // Newer language standard required @@ -208,7 +209,7 @@ public: "IFDEPTH", "IGNOREDRETURN", "IMPERFECTSCH", "IMPLICIT", "IMPLICITSTATIC", "IMPORTSTAR", "IMPURE", "INCABSPATH", "INFINITELOOP", "INITIALDLY", "INSECURE", - "LATCH", "LITENDIAN", "MINTYPMAXDLY", "MISINDENT", "MODDUP", + "LATCH", "LITENDIAN", "MINTYPMAXDLY", "MISINDENT", "MODDUP", "MODMISSING", "MULTIDRIVEN", "MULTITOP", "NEWERSTD", "NOLATCH", "NONSTD", "NULLPORT", "PINCONNECTEMPTY", "PINMISSING", "PINNOCONNECT", "PINNOTFOUND", "PKGNODECL", "PREPROCZERO", "PROCASSINIT", "PROCASSWIRE", "PROFOUTOFDATE", "PROTECTED", "RANDC", "REALCVT", "REDEFMACRO", "RISEFALLDLY", @@ -248,8 +249,9 @@ public: bool pretendError() const VL_MT_SAFE { return (m_e == ASSIGNIN || m_e == BADSTDPRAGMA || m_e == BADVLTPRAGMA || m_e == BLKANDNBLK || m_e == BLKLOOPINIT || m_e == CONTASSREG || m_e == ENCAPSULATED - || m_e == ENDLABEL || m_e == ENUMVALUE || m_e == IMPURE || m_e == PINNOTFOUND - || m_e == PKGNODECL || m_e == PROCASSWIRE || m_e == ZEROREPL // Says IEEE + || m_e == ENDLABEL || m_e == ENUMVALUE || m_e == IMPURE || m_e == MODMISSING + || m_e == PINNOTFOUND || m_e == PKGNODECL || m_e == PROCASSWIRE + || m_e == ZEROREPL // Says IEEE ); } // Warnings to mention manual diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 1b23f494a..88f510db1 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -5898,12 +5898,13 @@ class WidthVisitor final : public VNVisitor { // We've resolved parameters and hit a module that we couldn't resolve. It's // finally time to report it. // Note only here in V3Width as this is first visitor after V3Dead. - nodep->modNameFileline()->v3error( - "Cannot find file containing module: '" - << nodep->modName() << "'\n" - << nodep->modNameFileline()->warnContextPrimary() - << V3Error::warnAdditionalInfo() - << v3Global.opt.filePathLookedMsg(nodep->modNameFileline(), nodep->modName())); + nodep->modNameFileline()->v3warn( + MODMISSING, "Cannot find file containing module: '" + << nodep->modName() << "'\n" + << nodep->modNameFileline()->warnContextPrimary() + << V3Error::warnAdditionalInfo() + << v3Global.opt.filePathLookedMsg(nodep->modNameFileline(), + nodep->modName())); } if (nodep->rangep()) userIterateAndNext(nodep->rangep(), WidthVP{SELF, BOTH}.p()); userIterateAndNext(nodep->pinsp(), nullptr); diff --git a/test_regress/t/t_gen_missing_bad.out b/test_regress/t/t_gen_missing_bad.out index 4a16da624..cf46263f1 100644 --- a/test_regress/t/t_gen_missing_bad.out +++ b/test_regress/t/t_gen_missing_bad.out @@ -1,15 +1,15 @@ -%Error: t/t_gen_missing.v:43:20: Cannot find file containing module: 'foo_not_needed' +%Error-MODMISSING: t/t_gen_missing.v:43:20: Cannot find file containing module: 'foo_not_needed' 43 | foo_not_needed i_foo(.x(foo[j]), .y(bar[j])); | ^~~~~~~~~~~~~~ - ... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance. - ... Looked in: - t/foo_not_needed - t/foo_not_needed.v - t/foo_not_needed.sv - foo_not_needed - foo_not_needed.v - foo_not_needed.sv - obj_vlt/t_gen_missing_bad/foo_not_needed - obj_vlt/t_gen_missing_bad/foo_not_needed.v - obj_vlt/t_gen_missing_bad/foo_not_needed.sv + ... For error description see https://verilator.org/warn/MODMISSING?v=latest + ... Looked in: + t/foo_not_needed + t/foo_not_needed.v + t/foo_not_needed.sv + foo_not_needed + foo_not_needed.v + foo_not_needed.sv + obj_vlt/t_gen_missing_bad/foo_not_needed + obj_vlt/t_gen_missing_bad/foo_not_needed.v + obj_vlt/t_gen_missing_bad/foo_not_needed.sv %Error: Exiting due to diff --git a/test_regress/t/t_gen_nonconst_bad.out b/test_regress/t/t_gen_nonconst_bad.out index 9c7aa3c0c..138517066 100644 --- a/test_regress/t/t_gen_nonconst_bad.out +++ b/test_regress/t/t_gen_nonconst_bad.out @@ -1,13 +1,13 @@ -%Error: t/t_gen_nonconst_bad.v:8:4: Cannot find file containing module: 'nfound' +%Error-MODMISSING: t/t_gen_nonconst_bad.v:8:4: Cannot find file containing module: 'nfound' 8 | nfound nfound(); | ^~~~~~ - ... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance. - ... This may be because there's no search path specified with -I. - ... Looked in: - nfound - nfound.v - nfound.sv - obj_dir/nfound - obj_dir/nfound.v - obj_dir/nfound.sv + ... For error description see https://verilator.org/warn/MODMISSING?v=latest + ... This may be because there's no search path specified with -I. + ... Looked in: + nfound + nfound.v + nfound.sv + obj_dir/nfound + obj_dir/nfound.v + obj_dir/nfound.sv %Error: Exiting due to diff --git a/test_regress/t/t_inst_long_bad.out b/test_regress/t/t_inst_long_bad.out index fcf60e3cc..c903f6b35 100644 --- a/test_regress/t/t_inst_long_bad.out +++ b/test_regress/t/t_inst_long_bad.out @@ -1,7 +1,7 @@ -%Error: t/t_inst_long_bad.v:9:3: Cannot find file containing module: 'long_long_long_long_long_long___Vhsh1JZCXQVBM1QiASYlLmgTuAXYyUr7VAbJYwVHfiAD' +%Error-MODMISSING: t/t_inst_long_bad.v:9:3: Cannot find file containing module: 'long_long_long_long_long_long___Vhsh1JZCXQVBM1QiASYlLmgTuAXYyUr7VAbJYwVHfiAD' 9 | long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_ inst (); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance. - ... Note: Name is longer than 127 characters; automatic file lookup may have failed due to OS filename length limits. - ... Suggest putting filename with this module/package onto command line instead. + ... For error description see https://verilator.org/warn/MODMISSING?v=latest + ... Note: Name is longer than 127 characters; automatic file lookup may have failed due to OS filename length limits. + ... Suggest putting filename with this module/package onto command line instead. %Error: Exiting due to diff --git a/test_regress/t/t_lint_modmissing.py b/test_regress/t/t_lint_modmissing.py new file mode 100755 index 000000000..f81c3d68d --- /dev/null +++ b/test_regress/t/t_lint_modmissing.py @@ -0,0 +1,16 @@ +#!/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('vlt') + +test.lint() + +test.passes() diff --git a/test_regress/t/t_lint_modmissing.v b/test_regress/t/t_lint_modmissing.v new file mode 100644 index 000000000..6a6d7284e --- /dev/null +++ b/test_regress/t/t_lint_modmissing.v @@ -0,0 +1,10 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2011 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module t(input i); + // verilator lint_off MODMISSING + foobar sub(i); +endmodule