forked from github/verilator
Fix enum constant propagation, bug970.
This commit is contained in:
parent
dc57282168
commit
c60ffd7fd9
2
Changes
2
Changes
@ -15,6 +15,8 @@ indicates the contributor was also the author of the fix; Thanks!
|
||||
|
||||
**** Fix structure parameter constant propagation, bug968. [Todd Strader]
|
||||
|
||||
**** Fix enum constant propagation, bug970. [Todd Strader]
|
||||
|
||||
**** Fix mis-optimizing public DPI functions, bug963. [Wei Song]
|
||||
|
||||
|
||||
|
@ -345,6 +345,19 @@ private:
|
||||
setNumber(nodep, &(nodep->num()));
|
||||
}
|
||||
}
|
||||
virtual void visit(AstEnumItemRef* nodep, AstNUser*) {
|
||||
checkNodeInfo(nodep);
|
||||
if (!nodep->itemp()) nodep->v3fatalSrc("Not linked");
|
||||
if (!m_checkOnly && optimizable()) {
|
||||
AstNode* valuep = nodep->itemp()->valuep();
|
||||
if (valuep) {
|
||||
valuep->iterateAndNext(*this);
|
||||
newNumber(nodep)->opAssign(*fetchNumber(valuep));
|
||||
} else {
|
||||
clearOptimizable(nodep, "No value found for enum item");
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void visit(AstNodeUniop* nodep, AstNUser*) {
|
||||
if (!optimizable()) return; // Accelerate
|
||||
checkNodeInfo(nodep);
|
||||
|
@ -9,6 +9,11 @@ module t (/*AUTOARG*/);
|
||||
logic [ 31 : 0 ] _five;
|
||||
} five_t;
|
||||
|
||||
typedef enum {
|
||||
LOW_FIVE = 32'hdeadbeef,
|
||||
HIGH_FIVE
|
||||
} five_style_t;
|
||||
|
||||
function five_t gimme_five ();
|
||||
automatic five_t result;
|
||||
|
||||
@ -17,7 +22,16 @@ module t (/*AUTOARG*/);
|
||||
return result;
|
||||
endfunction
|
||||
|
||||
function five_style_t gimme_high_five ();
|
||||
automatic five_style_t result;
|
||||
|
||||
result = HIGH_FIVE;
|
||||
|
||||
return result;
|
||||
endfunction
|
||||
|
||||
localparam five_t FIVE = gimme_five();
|
||||
localparam five_style_t THE_HIGH_FIVE = gimme_high_five();
|
||||
|
||||
initial begin
|
||||
if (FIVE._five != 5) begin
|
||||
@ -25,6 +39,11 @@ module t (/*AUTOARG*/);
|
||||
$stop;
|
||||
end
|
||||
|
||||
if (THE_HIGH_FIVE != HIGH_FIVE) begin
|
||||
$display("%%Error: Got 0b%b instead of HIGH_FIVE", THE_HIGH_FIVE);
|
||||
$stop;
|
||||
end
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
Loading…
Reference in New Issue
Block a user