mirror of
https://github.com/verilator/verilator.git
synced 2026-10-07 02:23:19 +02:00
Fix reset of automatic function variables (#5747).
Also required V3Life optimize CRESET(x) ... ASSIGN(rhs, x) to remove the extraneous CRESET to avoid creating new UNOPTFLAT situations.
This commit is contained in:
+10
-2
@@ -604,11 +604,19 @@ class TaskVisitor final : public VNVisitor {
|
||||
// Any I/O variables that fell out of above loop were already linked
|
||||
if (!portp->user2p()) {
|
||||
// Move it to a new localized variable
|
||||
portp->unlinkFrBack();
|
||||
pushDeletep(portp); // Remove it from the clone (not original)
|
||||
AstVarScope* const localVscp
|
||||
= createVarScope(portp, namePrefix + "__" + portp->shortName());
|
||||
portp->user2p(localVscp);
|
||||
if (portp->needsCReset() && portp->lifetime().isAutomatic()
|
||||
&& !portp->valuep()) {
|
||||
// Reset automatic var to its default, on each invocation of function
|
||||
AstVarRef* const vrefp
|
||||
= new AstVarRef{portp->fileline(), portp, VAccess::WRITE};
|
||||
portp->replaceWith(new AstCReset{portp->fileline(), vrefp, false});
|
||||
} else {
|
||||
portp->unlinkFrBack();
|
||||
}
|
||||
pushDeletep(portp); // Remove it from the clone (not original)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user