diff --git a/Changes b/Changes index a60e8b4f0..93be6a8bd 100644 --- a/Changes +++ b/Changes @@ -13,7 +13,8 @@ Verilator 5.033 devel **Minor:** -* Add COVERIGN warning, as a more specific UNSUPPORTED error. +* Add `COVERIGN` warning, as a more specific UNSUPPORTED error. +* Add `--public-ignore` to ignore public metacomments (#7819). [Andrew Nolte] * Support generated classes (#5665). [Shou-Li Hsu] * Support `+incdir` with multiple directories. * Support side effects of form 'variable[index_function()]++'. diff --git a/bin/verilator b/bin/verilator index 769f3fb03..756344a25 100755 --- a/bin/verilator +++ b/bin/verilator @@ -431,8 +431,9 @@ detailed descriptions of these arguments. --protect-lib Create a DPI protected library --public Mark signals as public; see docs --public-depth Mark public to specified module depth - --public-params Mark all parameters as public_flat --public-flat-rw Mark all variables, etc as public_flat_rw + --public-ignore Ignore all public comment markings + --public-params Mark all parameters as public_flat -pvalue+= Overwrite toplevel parameter --quiet Minimize additional printing --quiet-exit Don't print the command on failure diff --git a/docs/guide/exe_verilator.rst b/docs/guide/exe_verilator.rst index 1f653d652..d9b4075ab 100644 --- a/docs/guide/exe_verilator.rst +++ b/docs/guide/exe_verilator.rst @@ -1211,6 +1211,13 @@ Summary: module specifically enabled it with :option:`/*verilator&32;inline_module*/`. + +.. option:: --public-depth + + Enables public as with :vlopt:`--public-flat-rw`, but only to the specified depth of modules. + It operates at the module maximum level, so if a module's cells are A.B.X and A.X, the + a --public-depth 3 must be used to make module X public, and both A.B.X and A.X will be public. + .. option:: --public-flat-rw Declares all variables, ports, and wires public as if they had @@ -1222,11 +1229,12 @@ Summary: marking only those signals that need public_flat_rw is typically significantly better performing. -.. option:: --public-depth +.. option:: --public-ignore - Enables public as with :vlopt:`--public-flat-rw`, but only to the specified depth of modules. - It operates at the module maximum level, so if a module's cells are A.B.X and A.X, the - a --public-depth 3 must be used to make module X public, and both A.B.X and A.X will be public. + Ignore all :code:`/*verilator public* */` metacomments. This is useful + for speed-optimizing VPI builds where VPI is not being used. This only + affects metacomments; options such as :vlopt:`--public`, + :vlopt:`--public-depth`, etc. work normally. .. option:: --public-params @@ -1234,6 +1242,7 @@ Summary: :code:`/*verilator public_flat_rd*/` metacomments. + .. option:: -pvalue+= Overwrites the given parameter(s) of the top-level module. See diff --git a/src/V3Options.cpp b/src/V3Options.cpp index aad0856b9..f4dc0f573 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -1510,8 +1510,9 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, m_publicFlatRW = flag; v3Global.dpi(true); }); + DECL_OPTION("-public-ignore", CbOnOff, [this](bool flag) { m_publicIgnore = flag; }); DECL_OPTION("-public-params", CbOnOff, [this](bool flag) { - m_public_params = flag; + m_publicParams = flag; v3Global.dpi(true); }); DECL_OPTION("-quiet", CbOnOff, [this](bool flag) { diff --git a/src/V3Options.h b/src/V3Options.h index c1ed66ec9..b19c6dfad 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -273,7 +273,8 @@ private: bool m_protectIds = false; // main switch: --protect-ids bool m_public = false; // main switch: --public bool m_publicFlatRW = false; // main switch: --public-flat-rw - bool m_public_params = false; // main switch: --public-params + bool m_publicIgnore = false; // main switch: --public-ignore + bool m_publicParams = false; // main switch: --public-params bool m_quietExit = false; // main switch: --quiet-exit bool m_quietStats = false; // main switch: --quiet-stats bool m_relativeIncludes = false; // main switch: --relative-includes @@ -541,10 +542,11 @@ public: bool usesProfiler() const { return profExec() || profPgo(); } bool protectIds() const VL_MT_SAFE { return m_protectIds; } bool allPublic() const { return m_public; } - bool publicParams() const { return m_public_params; } + bool publicParams() const { return m_publicParams; } + bool publicOff() const { return m_publicIgnore; } bool publicFlatRW() const { return m_publicFlatRW; } int publicDepth() const { return m_publicDepth; } - bool anyPublicFlat() const { return m_public_params || m_publicFlatRW || m_publicDepth; } + bool anyPublicFlat() const { return m_publicParams || m_publicFlatRW || m_publicDepth; } bool lintOnly() const VL_MT_SAFE { return m_lintOnly; } bool ignc() const { return m_ignc; } bool quietExit() const VL_MT_SAFE { return m_quietExit; } diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index 63894e72a..203faf5bf 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -486,7 +486,7 @@ void V3PreProcImp::comment(const string& text) { //} // else ignore the comment we don't recognize } // else no assertions - } else if (vlcomment) { + } else if (vlcomment && !(v3Global.opt.publicOff() && VString::startsWith(cmd, "public"))) { if (VString::startsWith(cmd, "public_flat_rw")) { // "/*verilator public_flat_rw @(foo) */" -> "/*verilator public_flat_rw*/ @(foo)" string::size_type endOfCmd = std::strlen("public_flat_rw"); diff --git a/test_regress/t/t_vpi_public_depth.cpp b/test_regress/t/t_vpi_public_depth.cpp index cb4da699c..e1bf6e2a6 100644 --- a/test_regress/t/t_vpi_public_depth.cpp +++ b/test_regress/t/t_vpi_public_depth.cpp @@ -26,6 +26,8 @@ #include "Vt_vpi_public_depth__Dpi.h" #elif defined(T_VPI_PUBLIC_DEPTH_OFF) #include "Vt_vpi_public_depth_off__Dpi.h" +#elif defined(T_VPI_PUBLIC_OFF) +#include "Vt_vpi_public_off__Dpi.h" #else #error "Bad test" #endif @@ -87,6 +89,15 @@ int mon_check() { it.freed(); // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle CHECK_RESULT_Z(topmod_done_should_be_0); + TestVpiHandle mod_a = vpi_handle_by_name(const_cast("\\mod.a "), topmod); +#if defined(T_VPI_PUBLIC_OFF) + // metacomment from module A should be ignored + CHECK_RESULT_Z(mod_a); + return 0; +#endif + + CHECK_RESULT_NZ(mod_a); + TestVpiHandle it2 = vpi_iterate(vpiModule, topmod); CHECK_RESULT_NZ(it2); diff --git a/test_regress/t/t_vpi_public_depth.v b/test_regress/t/t_vpi_public_depth.v index eeaedae9a..3766dfec3 100644 --- a/test_regress/t/t_vpi_public_depth.v +++ b/test_regress/t/t_vpi_public_depth.v @@ -65,7 +65,8 @@ module A(/*AUTOARG*/ clk, a, b ); - input clk; + // this comment should get ignored for public-ignore + input clk /* verilator public_flat_rw */; input a, b; output x; diff --git a/test_regress/t/t_vpi_public_off.py b/test_regress/t/t_vpi_public_off.py new file mode 100755 index 000000000..34b624b8e --- /dev/null +++ b/test_regress/t/t_vpi_public_off.py @@ -0,0 +1,29 @@ +#!/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') +test.pli_filename = "t/t_vpi_public_depth.cpp" +test.top_filename = "t/t_vpi_public_depth.v" + +test.compile(make_top_shell=False, + make_main=False, + make_pli=True, + iv_flags2=["-g2005-sv"], + verilator_flags2=[ + "+define+USE_DOLLAR_C32 --exe --vpi --no-l2name", + test.pli_filename, + "--public-depth 1 --public-ignore", + ], + make_flags=['CPPFLAGS_ADD=-DTEST_VPI_PUBLIC_OFF']) + +test.execute(use_libvpi=True) + +test.passes()