diff --git a/Changes b/Changes index f02b98f78..466afe302 100644 --- a/Changes +++ b/Changes @@ -9,6 +9,8 @@ indicates the contributor was also the author of the fix; Thanks! *** Add optimization of operators between concats, msg1447. [Jie Xu] +**** Fix public parameters in unused packages, bug804. [Jonathon Donaldson] + **** Fix generate unrolling with function call, bug830. [Steven Slatter] **** Fix cast-to-size context-determined sizing, bug828. [Geoff Barrett] diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index 6c6c14320..9cb4cab68 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -81,6 +81,7 @@ private: typedef multimap AssignMap; // STATE + AstNodeModule* m_modp; // Current module vector m_varEtcsp; // List of all encountered to avoid another loop through tree vector m_vscsp; // List of all encountered to avoid another loop through tree AssignMap m_assignMap; // List of all simple assignments for each variable @@ -112,6 +113,12 @@ private: } // VISITORS + virtual void visit(AstNodeModule* nodep, AstNUser*) { + m_modp = nodep; + nodep->iterateChildren(*this); + checkAll(nodep); + m_modp = NULL; + } virtual void visit(AstCell* nodep, AstNUser*) { nodep->iterateChildren(*this); checkAll(nodep); @@ -168,6 +175,7 @@ private: virtual void visit(AstVar* nodep, AstNUser*) { nodep->iterateChildren(*this); checkAll(nodep); + if (nodep->isSigPublic() && m_modp && m_modp->castPackage()) m_modp->user1Inc(); if (mightElim(nodep)) { m_varEtcsp.push_back(nodep); } @@ -253,6 +261,7 @@ private: public: // CONSTRUCTORS DeadVisitor(AstNetlist* nodep, bool elimUserVars, bool elimDTypes) { + m_modp = NULL; m_elimUserVars = elimUserVars; m_elimDTypes = elimDTypes; m_sideEffect = false; diff --git a/test_regress/t/t_param_public.cpp b/test_regress/t/t_param_public.cpp new file mode 100644 index 000000000..59c33382f --- /dev/null +++ b/test_regress/t/t_param_public.cpp @@ -0,0 +1,24 @@ +// -*- mode: C++; c-file-style: "cc-mode" -*- +// +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2006 by Wilson Snyder. + +#include +#include "Vt_param_public.h" + +#include "Vt_param_public_p.h" + +int main (int argc, char *argv[]) { + Vt_param_public *topp = new Vt_param_public; + + Verilated::debug(0); + + // Make sure public tag worked + if (Vt_param_public_p::INPACK) {} + + for (int i = 0; i < 10; i++) { + topp->eval(); + } +} diff --git a/test_regress/t/t_param_public.pl b/test_regress/t/t_param_public.pl index f91289753..4408cbf72 100755 --- a/test_regress/t/t_param_public.pl +++ b/test_regress/t/t_param_public.pl @@ -7,8 +7,16 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di # Lesser General Public License Version 3 or the Perl Artistic License # Version 2.0. -compile ( - ); +if ($Self->{vlt}) { + compile ( + verilator_flags2 => ["--exe $Self->{t_dir}/$Self->{name}.cpp"], + make_top_shell => 0, + make_main => 0, + ); +} else { + compile ( + ); +} execute ( check_finished=>1, diff --git a/test_regress/t/t_param_public.v b/test_regress/t/t_param_public.v index 045c95287..e8b815ffb 100644 --- a/test_regress/t/t_param_public.v +++ b/test_regress/t/t_param_public.v @@ -36,3 +36,8 @@ module b #( initial if ($c32("TWO") != 2) $stop; `endif endmodule + +//bug804 +package p; + localparam INPACK /*verilator public*/ = 6; +endpackage