From e8ff191a17e6af6510699c197ce2e05941339746 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 20 Jan 2020 13:27:27 -0500 Subject: [PATCH] Internals: Prepare for hierarchical NodeModule's. No functional change intended. --- src/V3Assert.cpp | 15 ++++++++------ src/V3Ast.h | 2 +- src/V3Begin.cpp | 12 +++++------ src/V3Cdc.cpp | 9 +++++--- src/V3Clean.cpp | 9 +++++--- src/V3Clock.cpp | 9 +++++--- src/V3Const.cpp | 9 +++++--- src/V3Coverage.cpp | 16 +++++++++------ src/V3Dead.cpp | 13 +++++++----- src/V3Depth.cpp | 11 ++++++---- src/V3DepthBlock.cpp | 11 ++++++---- src/V3Descope.cpp | 15 ++++++++------ src/V3EmitCSyms.cpp | 9 +++++--- src/V3Gate.cpp | 11 ++++++---- src/V3Inline.cpp | 9 ++++++-- src/V3LinkJump.cpp | 19 ++++++++++------- src/V3LinkParse.cpp | 17 ++++++++------- src/V3LinkResolve.cpp | 22 +++++++++++++------- src/V3Name.cpp | 9 +++++--- src/V3Order.cpp | 9 +++++--- src/V3Premit.cpp | 11 ++++++---- src/V3Table.cpp | 20 ++++++++++++------ src/V3Task.cpp | 15 +++++++++----- src/V3Tristate.cpp | 48 ++++++++++++++++++++++++++----------------- src/V3Unknown.cpp | 11 ++++++---- 25 files changed, 217 insertions(+), 124 deletions(-) diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 953367966..5b158295e 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -356,12 +356,15 @@ private: } virtual void visit(AstNodeModule* nodep) { - m_modp = nodep; - m_modPastNum = 0; - // - iterateChildren(nodep); - // Reset defaults - m_modp = NULL; + AstNodeModule* origModp = m_modp; + unsigned origPastNum = m_modPastNum; + { + m_modp = nodep; + m_modPastNum = 0; + iterateChildren(nodep); + } + m_modp = origModp; + m_modPastNum = origPastNum; } virtual void visit(AstBegin* nodep) { // This code is needed rather than a visitor in V3Begin, diff --git a/src/V3Ast.h b/src/V3Ast.h index 8145a5213..ddd86aee2 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -2244,7 +2244,7 @@ public: AstActive* activesp() const { return VN_CAST(op3p(), Active); } // op3 = List of i/sblocks // METHODS void addInlinesp(AstNode* nodep) { addOp1p(nodep); } - void addStmtp(AstNode* nodep) { addOp2p(nodep); } + void addStmtp(AstNode* nodep) { addNOp2p(nodep); } void addActivep(AstNode* nodep) { addOp3p(nodep); } // ACCESSORS virtual void name(const string& name) { m_name = name; } diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index ae4c4ef3f..44b8f12e6 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -72,7 +72,6 @@ private: AstNodeFTask* m_ftaskp; // Current function/task string m_namedScope; // Name of begin blocks above us string m_unnamedScope; // Name of begin blocks, including unnamed blocks - int m_repeatNum; // Repeat counter int m_ifDepth; // Current if depth // METHODS @@ -80,10 +79,12 @@ private: // VISITORS virtual void visit(AstNodeModule* nodep) { - m_modp = nodep; - m_repeatNum = 0; - iterateChildren(nodep); - m_modp = NULL; + AstNodeModule* origModp = m_modp; + { + m_modp = nodep; + iterateChildren(nodep); + } + m_modp = origModp; } virtual void visit(AstNodeFTask* nodep) { UINFO(8," "<isTop(); // Ignore coverage on top module; it's a shell we created - m_fileps.clear(); - iterateChildren(nodep); - m_modp = NULL; - m_inModOff = true; + AstNodeModule* origModp = m_modp; + bool origInModOff = m_inModOff; + { + m_modp = nodep; + m_inModOff = nodep->isTop(); // Ignore coverage on top module; it's a shell we created + m_fileps.clear(); + iterateChildren(nodep); + } + m_modp = origModp; + m_inModOff = origInModOff; } // VISITORS - TOGGLE COVERAGE diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index 921d18261..461b8a56d 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -134,12 +134,15 @@ private: // VISITORS virtual void visit(AstNodeModule* nodep) { - m_modp = nodep; - if (!nodep->dead()) { - iterateChildren(nodep); - checkAll(nodep); + AstNodeModule* origModp = m_modp; + { + m_modp = nodep; + if (!nodep->dead()) { + iterateChildren(nodep); + checkAll(nodep); + } } - m_modp = NULL; + m_modp = origModp; } virtual void visit(AstCFunc* nodep) { iterateChildren(nodep); diff --git a/src/V3Depth.cpp b/src/V3Depth.cpp index 51e1f07a0..9be333f81 100644 --- a/src/V3Depth.cpp +++ b/src/V3Depth.cpp @@ -84,10 +84,13 @@ private: // VISITORS virtual void visit(AstNodeModule* nodep) { UINFO(4," MOD "<user2(CIL_MAYBE); @@ -525,8 +526,12 @@ private: } } virtual void visit(AstNodeModule* nodep) { - m_modp = nodep; - iterateChildren(nodep); + AstNodeModule* origModp = m_modp; + { + m_modp = nodep; + iterateChildren(nodep); + } + m_modp = origModp; } virtual void visit(AstCell* nodep) { if (nodep->modp()->user1()) { // Marked with inline request diff --git a/src/V3LinkJump.cpp b/src/V3LinkJump.cpp index ed97bb984..779e78b8d 100644 --- a/src/V3LinkJump.cpp +++ b/src/V3LinkJump.cpp @@ -49,7 +49,7 @@ private: AstNodeFTask* m_ftaskp; // Current function/task AstWhile* m_loopp; // Current loop bool m_loopInc; // In loop increment - int m_repeatNum; // Repeat counter + int m_modRepeatNum; // Repeat counter BeginStack m_beginStack; // All begin blocks above current node // METHODS @@ -109,10 +109,15 @@ private: // VISITORS virtual void visit(AstNodeModule* nodep) { if (nodep->dead()) return; - m_modp = nodep; - m_repeatNum = 0; - iterateChildren(nodep); - m_modp = NULL; + AstNodeModule* origModp = m_modp; + int origRepeatNum = m_modRepeatNum; + { + m_modp = nodep; + m_modRepeatNum = 0; + iterateChildren(nodep); + } + m_modp = origModp; + m_modRepeatNum = origRepeatNum; } virtual void visit(AstNodeFTask* nodep) { m_ftaskp = nodep; @@ -130,7 +135,7 @@ private: // REPEAT(count,body) -> loop=count,WHILE(loop>0) { body, loop-- } // Note var can be signed or unsigned based on original number. AstNode* countp = nodep->countp()->unlinkFrBackWithNext(); - string name = string("__Vrepeat")+cvtToStr(m_repeatNum++); + string name = string("__Vrepeat")+cvtToStr(m_modRepeatNum++); // Spec says value is integral, if negative is ignored AstVar* varp = new AstVar(nodep->fileline(), AstVarType::BLOCKTEMP, name, nodep->findSigned32DType()); @@ -254,7 +259,7 @@ public: m_ftaskp = NULL; m_loopp = NULL; m_loopInc = false; - m_repeatNum = 0; + m_modRepeatNum = 0; iterate(nodep); } virtual ~LinkJumpVisitor() {} diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index ce049fa8f..9ad4b66a1 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -446,14 +446,17 @@ private: virtual void visit(AstNodeModule* nodep) { V3Config::applyModule(nodep); - // Module: Create sim table for entire module and iterate - cleanFileline(nodep); - // - m_modp = nodep; + AstNodeModule* origModp = m_modp; + { + // Module: Create sim table for entire module and iterate + cleanFileline(nodep); + // + m_modp = nodep; + m_valueModp = nodep; + iterateChildren(nodep); + } + m_modp = origModp; m_valueModp = nodep; - iterateChildren(nodep); - m_modp = NULL; - m_valueModp = NULL; } void visitIterateNoValueMod(AstNode* nodep) { // Iterate a node which shouldn't have any local variables moved to an Initial diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index 122acc27a..30abedbb8 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -69,10 +69,15 @@ private: // Module: Create sim table for entire module and iterate UINFO(8,"MODULE "<dead()) return; - m_modp = nodep; - m_senitemCvtNum = 0; - iterateChildren(nodep); - m_modp = NULL; + AstNodeModule* origModp = m_modp; + int origSenitemCvtNum = m_senitemCvtNum; + { + m_modp = nodep; + m_senitemCvtNum = 0; + iterateChildren(nodep); + } + m_modp = origModp; + m_senitemCvtNum = origSenitemCvtNum; } virtual void visit(AstInitial* nodep) { iterateChildren(nodep); @@ -489,9 +494,12 @@ private: iterateChildrenBackwards(nodep); } virtual void visit(AstNodeModule* nodep) { - m_modp = nodep; - iterateChildren(nodep); - m_modp = NULL; + AstNodeModule* origModp = m_modp; + { + m_modp = nodep; + iterateChildren(nodep); + } + m_modp = origModp; } virtual void visit(AstCell* nodep) { // Parent module inherits child's publicity diff --git a/src/V3Name.cpp b/src/V3Name.cpp index fc4694d82..aba43f7c2 100644 --- a/src/V3Name.cpp +++ b/src/V3Name.cpp @@ -74,9 +74,12 @@ private: // VISITORS virtual void visit(AstNodeModule* nodep) { - m_modp = nodep; - iterateChildren(nodep); - m_modp = NULL; + AstNodeModule* origModp = m_modp; + { + m_modp = nodep; + iterateChildren(nodep); + } + m_modp = origModp; } // Add __PVT__ to names of local signals virtual void visit(AstVar* nodep) { diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 90356ddf1..6d4f3835c 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -1001,9 +1001,12 @@ private: AstNode::user4ClearTree(); } virtual void visit(AstNodeModule* nodep) { - m_modp = nodep; - iterateChildren(nodep); - m_modp = NULL; + AstNodeModule* origModp = m_modp; + { + m_modp = nodep; + iterateChildren(nodep); + } + m_modp = origModp; } virtual void visit(AstScope* nodep) { UINFO(4," SCOPE "< m_modTableVscs; // All tables created + typedef std::deque ModTableVector; + ModTableVector m_modTableVscs; // All tables created // State cleared on each scope AstScope* m_scopep; // Current SCOPE @@ -427,11 +428,18 @@ private: iterateChildren(nodep); } virtual void visit(AstNodeModule* nodep) { - m_modTables = 0; - m_modTableVscs.clear(); - m_modp = nodep; - iterateChildren(nodep); - m_modp = NULL; + AstNodeModule* origModp = m_modp; + int origModTables = m_modTables; + ModTableVector origModTableVscs = m_modTableVscs; + { + m_modp = nodep; + m_modTables = 0; + m_modTableVscs.clear(); + iterateChildren(nodep); + } + m_modp = origModp; + m_modTables = origModTables; + m_modTableVscs = origModTableVscs; } virtual void visit(AstScope* nodep) { UINFO(4," SCOPE "<