diff --git a/src/V3Simulate.h b/src/V3Simulate.h index 8ab23fb52..4b3572fe6 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -51,16 +51,16 @@ //###################################################################### // Simulate class functions -class SimulateStackNode { +class SimStackNode { public: // MEMBERS AstFuncRef* m_funcp; V3TaskConnects* m_tconnects; // CONSTRUCTORS - SimulateStackNode(AstFuncRef* funcp, V3TaskConnects* tconnects): + SimStackNode(AstFuncRef* funcp, V3TaskConnects* tconnects): m_funcp(funcp), m_tconnects(tconnects) {} - ~SimulateStackNode() {} + ~SimStackNode() {} }; class SimulateVisitor : public AstNVisitor { @@ -103,7 +103,7 @@ private: // Simulating: std::deque m_numFreeps; ///< List of all numbers free and not in use std::deque m_numAllps; ///< List of all numbers free and in use - std::deque m_callStack; ///< Call stack for verbose error messages + std::deque m_callStack; ///< Call stack for verbose error messages // Cleanup // V3Numbers that represents strings are a bit special and the API for V3Number does not allow changing them. @@ -178,7 +178,7 @@ public: } m_whyNotOptimizable = why; std::ostringstream stack; - for (std::deque::iterator it=m_callStack.begin(); it !=m_callStack.end(); ++it) { + for (std::deque::iterator it=m_callStack.begin(); it !=m_callStack.end(); ++it) { AstFuncRef* funcp = (*it)->m_funcp; stack<<"\nCalled from:\n"<fileline()<<" "<prettyName()<<"() with parameters:"; V3TaskConnects* tconnects = (*it)->m_tconnects; @@ -242,6 +242,9 @@ public: return (fetchOutNumber(nodep)); } } + void newNumber(AstNode* nodep, const V3Number& numr) { + newNumber(nodep)->opAssign(numr); + } V3Number* fetchNumberNull(AstNode* nodep) { return ((V3Number*)nodep->user3p()); } @@ -390,7 +393,7 @@ private: } virtual void visit(AstVarXRef* nodep) { if (jumpingOver(nodep)) return; - if (m_scoped) { badNodeType(nodep); return; } + if (m_scoped) { badNodeType(nodep); return; } else { clearOptimizable(nodep,"Language violation: Dotted hierarchical references not allowed in constant functions"); } } virtual void visit(AstNodeFTask* nodep) { @@ -793,7 +796,7 @@ private: } } } - SimulateStackNode stackNode(nodep, &tconnects); + SimStackNode stackNode(nodep, &tconnects); m_callStack.push_front(&stackNode); // Evaluate the function iterate(funcp); @@ -922,6 +925,7 @@ private: public: // CONSTRUCTORS SimulateVisitor() { + // Note AstUser#InUse ensures only one invocation exists at once setMode(false,false,false); clear(); // We reuse this structure in the main loop, so put initializers inside clear() } diff --git a/src/V3Table.cpp b/src/V3Table.cpp index 422d1ae9e..b54eb37a0 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -292,7 +292,9 @@ private: for (std::deque::iterator it = m_inVarps.begin(); it!=m_inVarps.end(); ++it) { AstVarScope* invscp = *it; // LSB is first variable, so extract it that way - simvis.newNumber(invscp, VL_MASK_I(invscp->width()) & (inValue>>shift)); + simvis.newNumber(invscp, + V3Number(invscp->fileline(), invscp->width(), + VL_MASK_I(invscp->width()) & (inValue>>shift))); shift += invscp->width(); // We're just using32 bit arithmetic, because there's no way the input table can be 2^32 bytes! if (shift>31) nodep->v3fatalSrc("shift overflow");