Support proper automatic/static initialization, and remove STATICVAR warning (#6405). (#7086)

This commit is contained in:
Wilson Snyder
2026-02-24 14:04:43 -05:00
committed by GitHub
parent 3992da6027
commit 7607f0e7fa
35 changed files with 914 additions and 282 deletions
+7 -1
View File
@@ -39,6 +39,7 @@ class LinkLValueVisitor final : public VNVisitor {
bool m_setStrengthSpecified = false; // Set that var has assignment with strength specified.
bool m_inFunc = false; // Set if inside AstNodeFTask
bool m_inInitialStatic = false; // Set if inside AstInitialStatic
bool m_inInitialStaticStmt = false; // Set if inside AstInitialStaticStmt
VAccess m_setRefLvalue; // Set VarRefs to lvalues for pin assignments
// VISITORS
@@ -113,7 +114,7 @@ class LinkLValueVisitor final : public VNVisitor {
iterateAndNextNull(nodep->rhsp());
}
if (m_inInitialStatic && m_inFunc) {
if ((m_inInitialStatic || m_inInitialStaticStmt) && m_inFunc) {
const bool rhsHasIO = nodep->rhsp()->exists([](const AstNodeVarRef* const refp) {
// Exclude module I/O referenced from a function/task.
return refp->varp() && refp->varp()->isIO()
@@ -147,6 +148,11 @@ class LinkLValueVisitor final : public VNVisitor {
m_inInitialStatic = true;
iterateChildren(nodep);
}
void visit(AstInitialStaticStmt* nodep) override {
VL_RESTORER(m_inInitialStaticStmt);
m_inInitialStaticStmt = true;
iterateChildren(nodep);
}
void visit(AstRelease* nodep) override {
VL_RESTORER(m_setRefLvalue);
VL_RESTORER(m_setContinuously);