Fix public parameters in unused packages, bug804.

This commit is contained in:
Wilson Snyder 2014-11-06 17:53:01 -05:00
parent 3234fa15ef
commit e9c46afcf7
5 changed files with 50 additions and 2 deletions

View File

@ -9,6 +9,8 @@ indicates the contributor was also the author of the fix; Thanks!
*** Add optimization of operators between concats, msg1447. [Jie Xu] *** 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 generate unrolling with function call, bug830. [Steven Slatter]
**** Fix cast-to-size context-determined sizing, bug828. [Geoff Barrett] **** Fix cast-to-size context-determined sizing, bug828. [Geoff Barrett]

View File

@ -81,6 +81,7 @@ private:
typedef multimap<AstVarScope*,AstNodeAssign*> AssignMap; typedef multimap<AstVarScope*,AstNodeAssign*> AssignMap;
// STATE // STATE
AstNodeModule* m_modp; // Current module
vector<AstNode*> m_varEtcsp; // List of all encountered to avoid another loop through tree vector<AstNode*> m_varEtcsp; // List of all encountered to avoid another loop through tree
vector<AstVarScope*> m_vscsp; // List of all encountered to avoid another loop through tree vector<AstVarScope*> m_vscsp; // List of all encountered to avoid another loop through tree
AssignMap m_assignMap; // List of all simple assignments for each variable AssignMap m_assignMap; // List of all simple assignments for each variable
@ -112,6 +113,12 @@ private:
} }
// VISITORS // VISITORS
virtual void visit(AstNodeModule* nodep, AstNUser*) {
m_modp = nodep;
nodep->iterateChildren(*this);
checkAll(nodep);
m_modp = NULL;
}
virtual void visit(AstCell* nodep, AstNUser*) { virtual void visit(AstCell* nodep, AstNUser*) {
nodep->iterateChildren(*this); nodep->iterateChildren(*this);
checkAll(nodep); checkAll(nodep);
@ -168,6 +175,7 @@ private:
virtual void visit(AstVar* nodep, AstNUser*) { virtual void visit(AstVar* nodep, AstNUser*) {
nodep->iterateChildren(*this); nodep->iterateChildren(*this);
checkAll(nodep); checkAll(nodep);
if (nodep->isSigPublic() && m_modp && m_modp->castPackage()) m_modp->user1Inc();
if (mightElim(nodep)) { if (mightElim(nodep)) {
m_varEtcsp.push_back(nodep); m_varEtcsp.push_back(nodep);
} }
@ -253,6 +261,7 @@ private:
public: public:
// CONSTRUCTORS // CONSTRUCTORS
DeadVisitor(AstNetlist* nodep, bool elimUserVars, bool elimDTypes) { DeadVisitor(AstNetlist* nodep, bool elimUserVars, bool elimDTypes) {
m_modp = NULL;
m_elimUserVars = elimUserVars; m_elimUserVars = elimUserVars;
m_elimDTypes = elimDTypes; m_elimDTypes = elimDTypes;
m_sideEffect = false; m_sideEffect = false;

View File

@ -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 <verilated.h>
#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();
}
}

View File

@ -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 # Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0. # 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 ( execute (
check_finished=>1, check_finished=>1,

View File

@ -36,3 +36,8 @@ module b #(
initial if ($c32("TWO") != 2) $stop; initial if ($c32("TWO") != 2) $stop;
`endif `endif
endmodule endmodule
//bug804
package p;
localparam INPACK /*verilator public*/ = 6;
endpackage