forked from github/verilator
Fix genvar constant propagation from package, bug1003.
Signed-off-by: Wilson Snyder <wsnyder@wsnyder.org>
This commit is contained in:
parent
7698af5178
commit
9edd28d2ed
2
Changes
2
Changes
@ -19,6 +19,8 @@ indicates the contributor was also the author of the fix; Thanks!
|
||||
|
||||
**** Fix $signed casts under generates, bug999. [Clifford Wolf]
|
||||
|
||||
**** Fix genvar constant propagation from package, bug1003. [Johan Bjork]
|
||||
|
||||
|
||||
* Verilator 3.878 2015-11-01
|
||||
|
||||
|
@ -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);
|
||||
|
@ -3,6 +3,11 @@
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2009 by Wilson Snyder.
|
||||
|
||||
package testpackage;
|
||||
localparam PARAM = 1024 >> 3;
|
||||
endpackage
|
||||
import testpackage::*;
|
||||
|
||||
module t;
|
||||
|
||||
localparam P4 = f_add(P3,1);
|
||||
@ -12,6 +17,7 @@ module t;
|
||||
localparam P18 = f_case(P4);
|
||||
localparam P6 = f_return(P4);
|
||||
localparam P3 = 3;
|
||||
localparam P128 = f_package();
|
||||
|
||||
typedef struct packed {
|
||||
logic [7:0] data;
|
||||
@ -42,10 +48,15 @@ module t;
|
||||
if (bigparam.first != 1'b1) $stop;
|
||||
if (bigparam.second != 1'b0) $stop;
|
||||
if (bigparam.data != 32'hfff12fff) $stop;
|
||||
if (P128 != 128) $stop;
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
function integer f_package();
|
||||
return PARAM;
|
||||
endfunction
|
||||
|
||||
function integer f_add(input [31:0] a, input [31:0] b);
|
||||
f_add = a+b;
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user