Fix delayed initial assignment (#6929)

This commit is contained in:
Todd Strader
2026-01-23 12:53:40 -05:00
committed by GitHub
parent a7db9ee32f
commit bc3c5b32dd
22 changed files with 1367 additions and 1251 deletions
+10 -4
View File
@@ -1202,10 +1202,16 @@ class TimingControlVisitor final : public VNVisitor {
new AstAssign{flp, new AstVarRef{flp, tmpVarp, VAccess::WRITE}, tmpAssignRhsp});
// If the RHS is different from the currently scheduled value, schedule the new assignment
// The generation will increase, effectively 'descheduling' the previous assignment.
alwaysp->addStmtsp(new AstIf{flp,
new AstNeq{flp, preAssignp->rhsp()->cloneTree(false),
new AstVarRef{flp, tmpVarp, VAccess::READ}},
forkp->unlinkFrBack()});
AstNodeExpr* const didNotInitp
= new AstLogNot{flp, new AstCExpr{flp, "vlSymsp->__Vm_didInit", 1}};
AstVarRef* const firstIterp
= new AstVarRef{flp, m_netlistp->stlFirstIterationp(), VAccess::READ};
AstNodeExpr* const schedCondp
= new AstLogOr{flp,
new AstNeq{flp, preAssignp->rhsp()->cloneTree(false),
new AstVarRef{flp, tmpVarp, VAccess::READ}},
new AstLogAnd{flp, didNotInitp, firstIterp}};
alwaysp->addStmtsp(new AstIf{flp, schedCondp, forkp->unlinkFrBack()});
}
void visit(AstDisableFork* nodep) override {
if (m_hasProcess) return;