Fix initial statements with gate optimizaion (#8250) (#8253)

This commit is contained in:
Wilson Snyder
2026-08-29 14:29:03 -04:00
committed by GitHub
parent 0f96460042
commit 3c121c0a2e
4 changed files with 8 additions and 1 deletions
+5 -1
View File
@@ -201,6 +201,7 @@ class GateBuildVisitor final : public VNVisitorConst {
bool m_inClockedActive = false; // Underneath clocked active
bool m_inEdgeActive = false; // Underneath edge active
bool m_inStaticActive = false; // Underneath static active
bool m_inInitialActive = false; // Underneath initial active
bool m_inSenItem = false; // Underneath AstSenItem; any varrefs are clocks
// METHODS
@@ -224,7 +225,8 @@ class GateBuildVisitor final : public VNVisitorConst {
m_logicVertexp->clearReducibleAndDedupable(nonReducibleReason);
} else if (m_inClockedActive) {
m_logicVertexp->clearReducible("Clocked logic"); // but dedupable
} else if (m_inStaticActive) {
} else if (m_inStaticActive || m_inInitialActive) {
// Runs only once, so its output must not be treated as live combinational logic
m_logicVertexp->setStaticInit();
}
if (consumeReason) m_logicVertexp->setConsumed(consumeReason);
@@ -251,10 +253,12 @@ class GateBuildVisitor final : public VNVisitorConst {
VL_RESTORER(m_inClockedActive);
VL_RESTORER(m_inEdgeActive);
VL_RESTORER(m_inStaticActive);
VL_RESTORER(m_inInitialActive);
m_activep = nodep;
m_inClockedActive = nodep->hasClocked();
m_inEdgeActive = nodep->sentreep() && nodep->sentreep()->hasEdge();
m_inStaticActive = nodep->hasStatic();
m_inInitialActive = nodep->hasInitial();
// AstVarScope::user2 -> bool: Signal used in SenItem in *this* active block
const VNUser2InUse user2InUse;