Fix genvar constant propagation from package, bug1003.

Signed-off-by: Wilson Snyder <[email protected]>
This commit is contained in:
Johan Bjork
2015-11-22 20:46:26 -05:00
committed by Wilson Snyder
parent 7698af5178
commit 9edd28d2ed
3 changed files with 17 additions and 3 deletions
+4 -3
View File
@@ -255,6 +255,7 @@ private:
virtual void visit(AstVarRef* nodep, AstNUser*) {
if (jumpingOver(nodep)) return;
if (!optimizable()) return; // Accelerate
nodep->varp()->iterateChildren(*this);
AstNode* vscp = varOrScope(nodep);
// We can't have non-delayed assignments with same value on LHS and RHS
@@ -282,10 +283,10 @@ private:
if (!m_params && (vscp->user1() & VU_LV)) clearOptimizable(nodep,"Var write & read");
vscp->user1( vscp->user1() | VU_RV);
bool isConst = nodep->varp()->isParam();
AstConst* constp = (isConst ? nodep->varp()->valuep()->castConst() : NULL);
if (isConst && constp) { // Propagate PARAM constants for constant function analysis
V3Number* nump = isConst ? fetchNumberNull(nodep->varp()->valuep()) : NULL;
if (isConst && nump) { // Propagate PARAM constants for constant function analysis
if (!m_checkOnly && optimizable()) {
newNumber(vscp)->opAssign(constp->num());
newNumber(vscp)->opAssign(*nump);
}
} else {
if (m_checkOnly) varRefCb (nodep);