diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index aa364c48e..d8ebba07f 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -72,7 +72,7 @@ private: nodep->iterateChildren(*this); m_topscopep = NULL; } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { // Create required actives and add to module // We can start ordering at a module, or a scope UINFO(4," MOD "<iterateChildren(*this); diff --git a/src/V3AssertPre.cpp b/src/V3AssertPre.cpp index a98ed0ec5..fdc99546b 100644 --- a/src/V3AssertPre.cpp +++ b/src/V3AssertPre.cpp @@ -127,7 +127,7 @@ private: nodep->replaceWith(blockp); pushDeletep(nodep); nodep=NULL; } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { nodep->iterateChildren(*this); // Reset defaults m_seniDefaultp = NULL; diff --git a/src/V3Ast.h b/src/V3Ast.h index 713dbe511..19c6e133d 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1272,6 +1272,49 @@ public: void addPinsp(AstNode* nodep) { addOp2p(nodep); } }; +struct AstNodeModule : public AstNode { + // A module, package, program or interface declaration; + // something that can live directly under the TOP, + // excluding $unit package stuff +private: + string m_name; // Name of the module + string m_origName; // Name of the module, ignoring name() changes, for dot lookup + bool m_modPublic:1; // Module has public references + bool m_modTrace:1; // Tracing this module + bool m_inLibrary:1; // From a library, no error if not used, never top level + int m_level; // 1=top module, 2=cell off top module, ... + int m_varNum; // Incrementing variable number +public: + AstNodeModule(FileLine* fl, const string& name) + : AstNode (fl) + ,m_name(name), m_origName(name) + ,m_modPublic(false), m_modTrace(false), m_inLibrary(false) + ,m_level(0), m_varNum(0) { } + ASTNODE_BASE_FUNCS(NodeModule) + virtual void dump(ostream& str); + virtual bool maybePointedTo() const { return true; } + virtual string name() const { return m_name; } + AstNode* stmtsp() const { return op2p()->castNode(); } // op2 = List of statements + AstActive* activesp() const { return op3p()->castActive(); } // op3 = List of i/sblocks + // METHODS + void addInlinesp(AstNode* nodep) { addOp1p(nodep); } + void addStmtp(AstNode* nodep) { addOp2p(nodep); } + void addActivep(AstNode* nodep) { addOp3p(nodep); } + // ACCESSORS + virtual void name(const string& name) { m_name = name; } + string origName() const { return m_origName; } + bool inLibrary() const { return m_inLibrary; } + void inLibrary(bool flag) { m_inLibrary = flag; } + void level(int level) { m_level = level; } + int level() const { return m_level; } + bool isTop() const { return level()==1; } + int varNumGetInc() { return ++m_varNum; } + void modPublic(bool flag) { m_modPublic = flag; } + bool modPublic() const { return m_modPublic; } + void modTrace(bool flag) { m_modTrace = flag; } + bool modTrace() const { return m_modTrace; } +}; + //###################################################################### #include "V3AstNodes.h" diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index d5dd2ce70..a9499ed6c 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -228,7 +228,7 @@ bool AstScope::broken() const { void AstScope::cloneRelink() { if (m_aboveScopep && m_aboveScopep->clonep()) m_aboveScopep->clonep()->castScope(); if (m_aboveCellp && m_aboveCellp->clonep()) m_aboveCellp->clonep()->castCell(); - if (m_modp && ((AstNode*)m_modp)->clonep()) ((AstNode*)m_modp)->clonep()->castModule(); + if (m_modp && ((AstNode*)m_modp)->clonep()) ((AstNode*)m_modp)->clonep()->castNodeModule(); } string AstScope::nameDotless() const { @@ -397,7 +397,7 @@ void AstVarXRef::dump(ostream& str) { else if (varp()) { varp()->dump(str); } else { str<<"UNLINKED"; } } -void AstModule::dump(ostream& str) { +void AstNodeModule::dump(ostream& str) { this->AstNode::dump(str); str<<" L"<") + nameDotless()); } - AstModule* modp() const { return m_modp; } + AstNodeModule* modp() const { return m_modp; } void addVarp(AstNode* nodep) { addOp1p(nodep); } AstNode* varsp() const { return op1p()->castNode(); } // op1 = AstVarScope's void addActivep(AstNode* nodep) { addOp2p(nodep); } @@ -756,54 +756,20 @@ public: void svImplicit(bool flag) { m_svImplicit=flag; } }; -struct AstModule : public AstNode { +struct AstModule : public AstNodeModule { // A module declaration -private: - string m_name; // Name of the module - string m_origName; // Name of the module, ignoring name() changes, for dot lookup - bool m_modPublic:1; // Module has public references - bool m_modTrace:1; // Tracing this module - bool m_inLibrary:1; // From a library, no error if not used, never top level - int m_level; // 1=top module, 2=cell off top module, ... - int m_varNum; // Incrementing variable number -public: AstModule(FileLine* fl, const string& name) - : AstNode (fl) - ,m_name(name), m_origName(name) - ,m_modPublic(false), m_modTrace(false), m_inLibrary(false) - ,m_level(0), m_varNum(0) { } + : AstNodeModule (fl,name) {} ASTNODE_NODE_FUNCS(Module, MODULE) - virtual void dump(ostream& str); - virtual bool maybePointedTo() const { return true; } - virtual string name() const { return m_name; } - AstNode* stmtsp() const { return op2p()->castNode(); } // op2 = List of statements - AstActive* activesp() const { return op3p()->castActive(); } // op3 = List of i/sblocks - // METHODS - void addInlinesp(AstNode* nodep) { addOp1p(nodep); } - void addStmtp(AstNode* nodep) { addOp2p(nodep); } - void addActivep(AstNode* nodep) { addOp3p(nodep); } - // ACCESSORS - virtual void name(const string& name) { m_name = name; } - string origName() const { return m_origName; } - bool inLibrary() const { return m_inLibrary; } - void inLibrary(bool flag) { m_inLibrary = flag; } - void level(int level) { m_level = level; } - int level() const { return m_level; } - bool isTop() const { return level()==1; } - int varNumGetInc() { return ++m_varNum; } - void modPublic(bool flag) { m_modPublic = flag; } - bool modPublic() const { return m_modPublic; } - void modTrace(bool flag) { m_modTrace = flag; } - bool modTrace() const { return m_modTrace; } }; struct AstCell : public AstNode { - // A instantiation cell + // A instantiation cell or interface call (don't know which until link) private: string m_name; // Cell name string m_origName; // Original name before dot addition string m_modName; // Module the cell instances - AstModule* m_modp; // [AfterLink] Pointer to module instanced + AstNodeModule* m_modp; // [AfterLink] Pointer to module instanced public: AstCell(FileLine* fl, const string& instName, const string& modName, AstPin* pinsp, AstPin* paramsp, AstRange* rangep) @@ -826,10 +792,10 @@ public: AstPin* pinsp() const { return op1p()->castPin(); } // op1 = List of cell ports AstPin* paramsp() const { return op2p()->castPin(); } // op2 = List of parameter #(##) values AstRange* rangep() const { return op3p()->castRange(); } // op3 = Range of arrayed instants (NULL=not ranged) - AstModule* modp() const { return m_modp; } // [AfterLink] = Pointer to module instantiated + AstNodeModule* modp() const { return m_modp; } // [AfterLink] = Pointer to module instantiated void addPinsp(AstPin* nodep) { addOp1p(nodep); } void addParamsp(AstPin* nodep) { addOp2p(nodep); } - void modp(AstModule* nodep) { m_modp = nodep; } + void modp(AstNodeModule* nodep) { m_modp = nodep; } }; struct AstCellInline : public AstNode { @@ -3098,18 +3064,18 @@ struct AstCInclude : public AstNode { // Parents: MODULE // Children: None private: - AstModule* m_modp; + AstNodeModule* m_modp; public: - AstCInclude(FileLine* fl, AstModule* modp) + AstCInclude(FileLine* fl, AstNodeModule* modp) : AstNode(fl) { m_modp = modp; } ASTNODE_NODE_FUNCS(CInclude, CINCLUDE) virtual bool broken() const { return (m_modp && !m_modp->brokeExists()); } virtual void cloneRelink() { if (m_modp && m_modp->clonep()) { - m_modp = m_modp->clonep()->castModule(); + m_modp = m_modp->clonep()->castNodeModule(); }} - AstModule* modp() const { return m_modp; } + AstNodeModule* modp() const { return m_modp; } }; struct AstCMath : public AstNodeMath { @@ -3163,9 +3129,9 @@ struct AstNetlist : public AstNode { // Children: MODULEs & CFILEs AstNetlist() : AstNode(new FileLine("AstRoot",0)) {} ASTNODE_NODE_FUNCS(Netlist, NETLIST) - AstModule* modulesp() const { return op1p()->castModule();} // op1 = List of modules - AstModule* topModulep() const { return op1p()->castModule(); } // * = Top module in hierarchy (first one added, for now) - void addModulep(AstModule* modulep) { addOp1p(modulep); } + AstNodeModule* modulesp() const { return op1p()->castNodeModule();} // op1 = List of modules + AstNodeModule* topModulep() const { return op1p()->castNodeModule(); } // * = Top module in hierarchy (first one added, for now) + void addModulep(AstNodeModule* modulep) { addOp1p(modulep); } AstCFile* filesp() const { return op2p()->castCFile();} // op2 = List of files void addFilesp(AstCFile* filep) { addOp2p(filep); } }; diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index 69177e039..db84ee3e2 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -48,7 +48,7 @@ class BeginVisitor : public AstNVisitor { private: // STATE - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module 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 @@ -62,7 +62,7 @@ private: } // VISITORS - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { m_modp = nodep; m_repeatNum = 0; nodep->iterateChildren(*this); diff --git a/src/V3Changed.cpp b/src/V3Changed.cpp index e7420faf6..70431d99a 100644 --- a/src/V3Changed.cpp +++ b/src/V3Changed.cpp @@ -55,7 +55,7 @@ private: AstUser1InUse m_inuser1; // STATE - AstModule* m_topModp; // Top module + AstNodeModule* m_topModp; // Top module AstScope* m_scopetopp; // Scope under TOPSCOPE AstCFunc* m_chgFuncp; // Change function we're building @@ -99,7 +99,7 @@ private: } // VISITORS - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { UINFO(4," MOD "<isTop()) { m_topModp = nodep; diff --git a/src/V3Clean.cpp b/src/V3Clean.cpp index d00186e38..e69fdae4e 100644 --- a/src/V3Clean.cpp +++ b/src/V3Clean.cpp @@ -55,7 +55,7 @@ private: enum CleanState { UNKNOWN, CLEAN, DIRTY }; // STATE - AstModule* m_modp; + AstNodeModule* m_modp; // METHODS static int debug() { @@ -160,7 +160,7 @@ private: } // VISITORS - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { m_modp = nodep; nodep->iterateChildren(*this); m_modp = NULL; diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index 238707e8b..ec93a2c3d 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -60,7 +60,7 @@ private: enum { DOUBLE_OR_RATE = 10 }; // How many | per ||, Determined experimentally as best // STATE - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module AstTopScope* m_topScopep; // Current top scope AstScope* m_scopep; // Current scope AstActive* m_activep; // Current block @@ -258,7 +258,7 @@ private: m_topScopep=NULL; m_scopep = NULL; } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { //UINFO(4," MOD "<iterateChildrenBackwards(*this); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { UINFO(4," MOD "<iterateChildrenBackwards(*this); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { m_modp = nodep; nodep->iterateChildren(*this); m_modp = NULL; diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index f1135e74c..6a3db1eab 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -63,7 +63,7 @@ private: // STATE bool m_checkBlock; // Should this block get covered? - AstModule* m_modp; // Current module to add statement to + AstNodeModule* m_modp; // Current module to add statement to bool m_inToggleOff; // In function/task etc FileMap m_fileps; // Column counts for each fileline string m_beginHier; // AstBegin hier name for user coverage points @@ -121,7 +121,7 @@ private: } // VISITORS - BOTH - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { m_modp = nodep; m_fileps.clear(); nodep->iterateChildren(*this); diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index d01271f8e..a74181e69 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -55,7 +55,7 @@ private: } public: // CONSTRUCTORS - DeadModVisitor(AstModule* nodep) { + DeadModVisitor(AstNodeModule* nodep) { nodep->accept(*this); } virtual ~DeadModVisitor() {} @@ -68,7 +68,7 @@ class DeadVisitor : public AstNVisitor { private: // NODE STATE // Entire Netlist: - // AstModule::user() -> int. Count of number of cells referencing this module. + // AstNodeModule::user() -> int. Count of number of cells referencing this module. // AstVar::user() -> int. Count of number of references // AstVarScope::user() -> int. Count of number of references AstUser1InUse m_inuser1; @@ -145,9 +145,9 @@ private: // after we've done all the generate blocks for (bool retry=true; retry; ) { retry=false; - AstModule* nextmodp; - for (AstModule* modp = v3Global.rootp()->modulesp(); modp; modp=nextmodp) { - nextmodp = modp->nextp()->castModule(); + AstNodeModule* nextmodp; + for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; modp=nextmodp) { + nextmodp = modp->nextp()->castNodeModule(); if (modp->level()>2 && modp->user1()==0) { // > 2 because L1 is the wrapper, L2 is the top user module UINFO(4," Dead module "<,AstVar*> VarMap; + typedef std::map,AstVar*> VarMap; VarMap m_modVarMap; // Table of new var names created under module V3Double0 m_statSharedSet;// Statistic tracking @@ -121,7 +121,7 @@ private: // Because we've already scoped it, we may need to add both the AstVar and the AstVarScope if (!oldvarscp->scopep()) oldvarscp->v3fatalSrc("Var unscoped"); AstVar* varp; - AstModule* addmodp = oldvarscp->scopep()->modp(); + AstNodeModule* addmodp = oldvarscp->scopep()->modp(); // We need a new AstVar, but only one for all scopes, to match the new AstVarScope VarMap::iterator iter = m_modVarMap.find(make_pair(addmodp,name)); if (iter != m_modVarMap.end()) { diff --git a/src/V3Depth.cpp b/src/V3Depth.cpp index d13a8e83c..4b5c4f4e3 100644 --- a/src/V3Depth.cpp +++ b/src/V3Depth.cpp @@ -46,7 +46,7 @@ private: // NODE STATE // STATE - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module AstCFunc* m_funcp; // Current block AstNode* m_stmtp; // Current statement int m_depth; // How deep in an expression @@ -85,7 +85,7 @@ private: } // VISITORS - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { UINFO(4," MOD "< FuncMmap; // STATE - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module AstScope* m_scopep; // Current scope bool m_needThis; // Add thisp to function FuncMmap m_modFuncs; // Name of public functions added @@ -179,7 +179,7 @@ private: } // VISITORS - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { m_modp = nodep; m_modFuncs.clear(); nodep->iterateChildren(*this); diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 2f425d626..36a06eb99 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -551,7 +551,7 @@ public: class EmitCImp : EmitCStmts { // MEMBERS - AstModule* m_modp; + AstNodeModule* m_modp; vector m_blkChangeDetVec; // All encountered changes in block bool m_slow; // Creating __Slow file bool m_fast; // Creating non __Slow file (or both) @@ -592,7 +592,7 @@ class EmitCImp : EmitCStmts { } } - V3OutCFile* newOutCFile(AstModule* modp, bool slow, bool source, int filenum=0) { + V3OutCFile* newOutCFile(AstNodeModule* modp, bool slow, bool source, int filenum=0) { string filenameNoExt = v3Global.opt.makeDir()+"/"+ modClassName(modp); if (filenum) filenameNoExt += "__"+cvtToStr(filenum); filenameNoExt += (slow ? "__Slow":""); @@ -722,22 +722,22 @@ class EmitCImp : EmitCStmts { // METHODS // Low level - void emitVarResets(AstModule* modp); - void emitCellCtors(AstModule* modp); + void emitVarResets(AstNodeModule* modp); + void emitCellCtors(AstNodeModule* modp); void emitSensitives(); // Medium level - void emitCtorImp(AstModule* modp); - void emitConfigureImp(AstModule* modp); - void emitCoverageDecl(AstModule* modp); - void emitCoverageImp(AstModule* modp); - void emitDestructorImp(AstModule* modp); + void emitCtorImp(AstNodeModule* modp); + void emitConfigureImp(AstNodeModule* modp); + void emitCoverageDecl(AstNodeModule* modp); + void emitCoverageImp(AstNodeModule* modp); + void emitDestructorImp(AstNodeModule* modp); void emitTextSection(AstType type); - void emitIntFuncDecls(AstModule* modp); + void emitIntFuncDecls(AstNodeModule* modp); // High level - void emitImp(AstModule* modp); - void emitStaticDecl(AstModule* modp); - void emitWrapEval(AstModule* modp); - void emitInt(AstModule* modp); + void emitImp(AstNodeModule* modp); + void emitStaticDecl(AstNodeModule* modp); + void emitWrapEval(AstNodeModule* modp); + void emitInt(AstNodeModule* modp); void writeMakefile(string filename); public: @@ -745,7 +745,7 @@ public: m_modp = NULL; } virtual ~EmitCImp() {} - void main(AstModule* modp, bool slow, bool fast); + void main(AstNodeModule* modp, bool slow, bool fast); void mainDoFunc(AstCFunc* nodep) { nodep->accept(*this); } @@ -1141,7 +1141,7 @@ void EmitCStmts::displayNode(AstNode* nodep, const string& vformat, AstNode* exp //###################################################################### // Internal EmitC -void EmitCImp::emitVarResets(AstModule* modp) { +void EmitCImp::emitVarResets(AstNodeModule* modp) { puts("// Reset internal values\n"); if (modp->isTop()) { if (v3Global.opt.inhibitSim()) puts("__Vm_inhibitSim = false;\n"); @@ -1214,7 +1214,7 @@ void EmitCImp::emitVarResets(AstModule* modp) { } } -void EmitCImp::emitCoverageDecl(AstModule* modp) { +void EmitCImp::emitCoverageDecl(AstNodeModule* modp) { if (v3Global.opt.coverage()) { ofp()->putsPrivate(true); puts("// Coverage\n"); @@ -1223,7 +1223,7 @@ void EmitCImp::emitCoverageDecl(AstModule* modp) { } } -void EmitCImp::emitCtorImp(AstModule* modp) { +void EmitCImp::emitCtorImp(AstNodeModule* modp) { puts("\n"); if (optSystemPerl() && modp->isTop()) { puts("SP_CTOR_IMP("+modClassName(modp)+")"); @@ -1243,7 +1243,7 @@ void EmitCImp::emitCtorImp(AstModule* modp) { puts("}\n"); } -void EmitCImp::emitConfigureImp(AstModule* modp) { +void EmitCImp::emitConfigureImp(AstNodeModule* modp) { puts("\nvoid "+modClassName(modp)+"::__Vconfigure("+symClassName()+"* vlSymsp, bool first) {\n"); puts( "if (0 && first) {} // Prevent unused\n"); puts( "this->__VlSymsp = vlSymsp;\n"); // First, as later stuff needs it. @@ -1260,7 +1260,7 @@ void EmitCImp::emitConfigureImp(AstModule* modp) { puts("}\n"); } -void EmitCImp::emitCoverageImp(AstModule* modp) { +void EmitCImp::emitCoverageImp(AstNodeModule* modp) { if (v3Global.opt.coverage() ) { puts("\n// Coverage\n"); // Rather than putting out SP_COVER_INSERT calls directly, we do it via this function @@ -1284,7 +1284,7 @@ void EmitCImp::emitCoverageImp(AstModule* modp) { } } -void EmitCImp::emitDestructorImp(AstModule* modp) { +void EmitCImp::emitDestructorImp(AstNodeModule* modp) { puts("\n"); puts(modClassName(modp)+"::~"+modClassName(modp)+"() {\n"); emitTextSection(AstType::SCDTOR); @@ -1292,7 +1292,7 @@ void EmitCImp::emitDestructorImp(AstModule* modp) { puts("}\n"); } -void EmitCImp::emitStaticDecl(AstModule* modp) { +void EmitCImp::emitStaticDecl(AstNodeModule* modp) { // Need implementation here. Be careful of alignment code; needs to be uniquified // with module name to avoid multiple symbols. //emitVarList(modp->stmtsp(), EVL_ALL, modp->name()); @@ -1323,7 +1323,7 @@ void EmitCImp::emitTextSection(AstType type) { } } -void EmitCImp::emitCellCtors(AstModule* modp) { +void EmitCImp::emitCellCtors(AstNodeModule* modp) { if (modp->isTop()) { // Must be before other constructors, as __vlCoverInsert calls it puts(EmitCBaseVisitor::symClassVar()+" = __VlSymsp = new "+symClassName()+"(this, name());\n"); @@ -1353,7 +1353,7 @@ void EmitCImp::emitSensitives() { } } -void EmitCImp::emitWrapEval(AstModule* modp) { +void EmitCImp::emitWrapEval(AstNodeModule* modp) { puts("\nvoid "+modClassName(modp)+"::eval() {\n"); puts(EmitCBaseVisitor::symClassVar()+" = this->__VlSymsp; // Setup global symbol table\n"); puts(EmitCBaseVisitor::symTopAssign()+"\n"); @@ -1450,7 +1450,7 @@ struct CmpName { } }; -void EmitCImp::emitIntFuncDecls(AstModule* modp) { +void EmitCImp::emitIntFuncDecls(AstNodeModule* modp) { vector funcsp; for (AstNode* nodep=modp->stmtsp(); nodep; nodep = nodep->nextp()) { @@ -1472,7 +1472,7 @@ void EmitCImp::emitIntFuncDecls(AstModule* modp) { } } -void EmitCImp::emitInt(AstModule* modp) { +void EmitCImp::emitInt(AstNodeModule* modp) { // Always have this first; gcc has short circuiting if #ifdef is first in a file if (!optSystemPerl()) { // else done for us automatically puts("#ifndef _"+modClassName(modp)+"_H_\n"); @@ -1634,7 +1634,7 @@ void EmitCImp::emitInt(AstModule* modp) { //---------------------------------------------------------------------- -void EmitCImp::emitImp(AstModule* modp) { +void EmitCImp::emitImp(AstNodeModule* modp) { if (optSystemPerl()) { puts("//############################################################\n"); puts("#sp implementation\n"); @@ -1694,7 +1694,7 @@ void EmitCImp::emitImp(AstModule* modp) { //###################################################################### -void EmitCImp::main(AstModule* modp, bool slow, bool fast) { +void EmitCImp::main(AstNodeModule* modp, bool slow, bool fast) { // Output a module m_modp = modp; m_slow = slow; @@ -1922,7 +1922,7 @@ class EmitCTrace : EmitCStmts { // Top module only nodep->topModulep()->accept(*this); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { nodep->iterateChildren(*this); } virtual void visit(AstCFunc* nodep, AstNUser*) { @@ -2022,7 +2022,7 @@ public: void V3EmitC::emitc() { UINFO(2,__FUNCTION__<<": "<modulesp(); nodep; nodep=nodep->nextp()->castModule()) { + for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); nodep; nodep=nodep->nextp()->castNodeModule()) { if (v3Global.opt.outputSplit()) { { EmitCImp imp; imp.main(nodep, false, true); } { EmitCImp imp; imp.main(nodep, true, false); } diff --git a/src/V3EmitCBase.h b/src/V3EmitCBase.h index 42587c01d..33084089d 100644 --- a/src/V3EmitCBase.h +++ b/src/V3EmitCBase.h @@ -119,7 +119,7 @@ public: static string symClassName() { return v3Global.opt.prefix()+"__Syms"; } static string symClassVar() { return symClassName()+"* __restrict vlSymsp"; } static string symTopAssign() { return v3Global.opt.prefix()+"* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp;"; } - static string modClassName(AstModule* modp) { // Return name of current module being processed + static string modClassName(AstNodeModule* modp) { // Return name of current module being processed if (modp->isTop()) { return v3Global.opt.prefix(); } else { diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index 3a41e79ae..e9dfc97b6 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -41,12 +41,12 @@ class EmitCSyms : EmitCBaseVisitor { // NODE STATE // Cleared on Netlist - // AstModule::user1() -> bool. Set true __Vconfigure called + // AstNodeModule::user1() -> bool. Set true __Vconfigure called AstUser1InUse m_inuser1; // STATE - AstModule* m_modp; // Current module - typedef pair ScopeModPair; + AstNodeModule* m_modp; // Current module + typedef pair ScopeModPair; vector m_scopes; // Every scope by module V3LanguageWords m_words; // Reserved word detector int m_coverBins; // Coverage bin number @@ -84,7 +84,7 @@ class EmitCSyms : EmitCBaseVisitor { emitInt(); emitImp(); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { nameCheck(nodep); m_modp = nodep; nodep->iterateChildren(*this); @@ -131,7 +131,7 @@ void EmitCSyms::emitInt() { // for puts("\n// INCLUDE MODULE CLASSES\n"); - for (AstModule* nodep = v3Global.rootp()->modulesp(); nodep; nodep=nodep->nextp()->castModule()) { + for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); nodep; nodep=nodep->nextp()->castNodeModule()) { puts("#include \""+modClassName(nodep)+".h\"\n"); } @@ -152,7 +152,7 @@ void EmitCSyms::emitInt() { ofp()->putAlign(V3OutFile::AL_AUTO, sizeof(vluint64_t)); puts("\n// SUBCELL STATE\n"); for (vector::iterator it = m_scopes.begin(); it != m_scopes.end(); ++it) { - AstScope* scopep = it->first; AstModule* modp = it->second; + AstScope* scopep = it->first; AstNodeModule* modp = it->second; if (modp->isTop()) { ofp()->printf("%-30s ", (modClassName(modp)+"*").c_str()); puts(scopep->nameDotless()+"p;\n"); @@ -192,7 +192,7 @@ void EmitCSyms::emitImp() { // Includes puts("#include \""+symClassName()+".h\"\n"); - for (AstModule* nodep = v3Global.rootp()->modulesp(); nodep; nodep=nodep->nextp()->castModule()) { + for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); nodep; nodep=nodep->nextp()->castNodeModule()) { puts("#include \""+modClassName(nodep)+".h\"\n"); } @@ -207,7 +207,7 @@ void EmitCSyms::emitImp() { puts("\t// Setup submodule names\n"); char comma=','; for (vector::iterator it = m_scopes.begin(); it != m_scopes.end(); ++it) { - AstScope* scopep = it->first; AstModule* modp = it->second; + AstScope* scopep = it->first; AstNodeModule* modp = it->second; if (modp->isTop()) { } else { ofp()->printf("\t%c %-30s ", comma, scopep->nameDotless().c_str()); @@ -223,7 +223,7 @@ void EmitCSyms::emitImp() { puts("TOPp = topp;\n"); puts("// Setup each module's pointers to their submodules\n"); for (vector::iterator it = m_scopes.begin(); it != m_scopes.end(); ++it) { - AstScope* scopep = it->first; AstModule* modp = it->second; + AstScope* scopep = it->first; AstNodeModule* modp = it->second; if (!modp->isTop()) { string arrow = scopep->name(); string::size_type pos; @@ -239,7 +239,7 @@ void EmitCSyms::emitImp() { puts("// Setup each module's pointer back to symbol table (for public functions)\n"); puts("TOPp->__Vconfigure(this, true);\n"); for (vector::iterator it = m_scopes.begin(); it != m_scopes.end(); ++it) { - AstScope* scopep = it->first; AstModule* modp = it->second; + AstScope* scopep = it->first; AstNodeModule* modp = it->second; if (!modp->isTop()) { // first is used by AstCoverDecl's call to __vlCoverInsert bool first = !modp->user1(); diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index 0168ef42e..51fad083f 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -502,7 +502,7 @@ void V3EmitV::emitv() { EmitVFileVisitor visitor (v3Global.rootp(), &of); } else { // Process each module in turn - for (AstModule* modp = v3Global.rootp()->modulesp(); modp; modp=modp->nextp()->castModule()) { + for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; modp=modp->nextp()->castNodeModule()) { V3OutVFile of (v3Global.opt.makeDir() +"/"+EmitCBaseVisitor::modClassName(modp)+"__Vout.v"); of.putsHeader(); diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 892038f0e..bbfeb1da6 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -242,7 +242,7 @@ private: V3Graph m_graph; // Scoreboard of var usages/dependencies GateLogicVertex* m_logicVertexp; // Current statement being tracked, NULL=ignored AstScope* m_scopep; // Current scope being processed - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module AstActive* m_activep; // Current active bool m_activeReducible; // Is activation block reducible? bool m_inSenItem; // Underneath AstSenItem; any varrefs are clocks @@ -316,7 +316,7 @@ private: consumedMove(); replaceAssigns(); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { m_modp = nodep; m_activeReducible = true; nodep->iterateChildren(*this); diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp index a8906bf4e..b2faf5ea0 100644 --- a/src/V3GenClk.cpp +++ b/src/V3GenClk.cpp @@ -59,8 +59,8 @@ private: AstUser3InUse m_inuser3; // STATE - AstActive* m_activep; // Inside activate statement - AstModule* m_topModp; // Top module + AstActive* m_activep; // Inside activate statement + AstNodeModule* m_topModp; // Top module AstScope* m_scopetopp; // Scope under TOPSCOPE // METHODS @@ -130,7 +130,7 @@ private: } public: // CONSTRUCTORS - GenClkRenameVisitor(AstTopScope* nodep, AstModule* topModp) { + GenClkRenameVisitor(AstTopScope* nodep, AstNodeModule* topModp) { m_topModp = topModp; m_scopetopp = NULL; m_activep = NULL; @@ -152,7 +152,7 @@ private: // STATE AstActive* m_activep; // Inside activate statement AstNodeAssign* m_assignp; // Inside assigndly statement - AstModule* m_topModp; // Top module + AstNodeModule* m_topModp; // Top module // VISITORS virtual void visit(AstTopScope* nodep, AstNUser*) { @@ -164,7 +164,7 @@ private: GenClkRenameVisitor visitor (nodep, m_topModp); } } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { // Only track the top scopes, not lower level functions if (nodep->isTop()) { m_topModp = nodep; diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index 5911c0910..4c0d9be09 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -54,12 +54,12 @@ private: // NODE STATE // Cleared entire netlist // Input: - // AstModule::user1p() // bool. True to inline this module (from InlineMarkVisitor) + // AstNodeModule::user1p() // bool. True to inline this module (from InlineMarkVisitor) // Cleared each cell // AstVar::user2p() // AstVarRef*/AstConst* Points to signal this is a direct connect to // STATE - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module AstCell* m_cellp; // Cell being cloned V3Double0 m_statCells; // Statistic tracking @@ -74,7 +74,7 @@ private: // Iterate modules backwards, in bottom-up order. Required! nodep->iterateChildrenBackwards(*this); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { if (m_cellp) { } else { m_modp = nodep; @@ -118,7 +118,7 @@ private: // Clone original module if (debug()>=9) { nodep->dumpTree(cout,"inlcell:"); } //if (debug()>=9) { nodep->modp()->dumpTree(cout,"oldmod:"); } - AstModule* newmodp = nodep->modp()->cloneTree(false); + AstNodeModule* newmodp = nodep->modp()->cloneTree(false); if (debug()>=9) { newmodp->dumpTree(cout,"newmod:"); } // Clear var markings AstNode::user2ClearTree(); @@ -306,16 +306,16 @@ class InlineMarkVisitor : public AstNVisitor { private: // NODE STATE // Entire netlist - // AstModule::user1() // OUTPUT: bool. User request to inline this module - // AstModule::user2() // bool. Allowed to automatically inline module - // AstModule::user3() // int. Number of cells referencing this module + // AstNodeModule::user1() // OUTPUT: bool. User request to inline this module + // AstNodeModule::user2() // bool. Allowed to automatically inline module + // AstNodeModule::user3() // int. Number of cells referencing this module AstUser1InUse m_inuser1; AstUser2InUse m_inuser2; AstUser3InUse m_inuser3; // STATE - AstModule* m_modp; // Current module - int m_stmtCnt; // Statements in module + AstNodeModule* m_modp; // Current module + int m_stmtCnt; // Statements in module // METHODS void cantInline(const char* reason) { @@ -326,7 +326,7 @@ private: } // VISITORS - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { m_stmtCnt = 0; m_modp = nodep; m_modp->user2(true); // Allowed = true @@ -427,9 +427,9 @@ void V3Inline::inlineAll(AstNetlist* nodep) { // Remove all modules that were inlined // V3Dead will also clean them up, but if we have debug on, it's a good // idea to avoid dumping the hugely exploded tree. - AstModule* nextmodp; - for (AstModule* modp = v3Global.rootp()->modulesp(); modp; modp=nextmodp) { - nextmodp = modp->nextp()->castModule(); + AstNodeModule* nextmodp; + for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; modp=nextmodp) { + nextmodp = modp->nextp()->castNodeModule(); if (modp->user1p()) { // Was inlined modp->unlinkFrBack()->deleteTree(); modp=NULL; } diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 663cf253f..9821f266f 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -51,7 +51,7 @@ private: AstUser1InUse m_inuser1; // STATE - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module AstCell* m_cellp; // Current cell static int debug() { @@ -62,7 +62,7 @@ private: //int m_debug; int debug() { return m_debug; } // VISITORS - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { UINFO(4," MOD "<name() == "t_chg") m_debug = 9; else m_debug=0; m_modp = nodep; @@ -232,7 +232,7 @@ public: //###################################################################### // Inst class functions -void V3Inst::pinReconnectSimple(AstPin* pinp, AstCell* cellp, AstModule* modp) { +void V3Inst::pinReconnectSimple(AstPin* pinp, AstCell* cellp, AstNodeModule* modp) { // If a pin connection is "simple" leave it as-is // Else create a intermediate wire to perform the interconnect // Note this module calles cloneTree() via new AstVar diff --git a/src/V3Inst.h b/src/V3Inst.h index 8e21516f3..f87ef1971 100644 --- a/src/V3Inst.h +++ b/src/V3Inst.h @@ -33,7 +33,7 @@ class V3Inst { public: static void instAll(AstNetlist* nodep); static void dearrayAll(AstNetlist* nodep); - static void pinReconnectSimple(AstPin* nodep, AstCell* cellp, AstModule* modp); + static void pinReconnectSimple(AstPin* nodep, AstCell* cellp, AstNodeModule* modp); }; #endif // Guard diff --git a/src/V3LifePost.cpp b/src/V3LifePost.cpp index 2729d21d3..8483dab4f 100644 --- a/src/V3LifePost.cpp +++ b/src/V3LifePost.cpp @@ -72,7 +72,7 @@ private: nodep->deleteTree(); nodep=NULL; } } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { // Only track the top scopes, not lower level functions if (nodep->isTop()) nodep->iterateChildren(*this); } @@ -162,7 +162,7 @@ private: } } } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { // Only track the top scopes, not lower level functions if (nodep->isTop()) nodep->iterateChildren(*this); } diff --git a/src/V3Link.cpp b/src/V3Link.cpp index fa4748302..78d66e7ae 100644 --- a/src/V3Link.cpp +++ b/src/V3Link.cpp @@ -48,7 +48,7 @@ class LinkVisitor : public AstNVisitor { private: // NODE STATE // Entire netlist: - // AstModule::user1p() // V3SymTable* Module's Symbol table + // AstNodeModule::user1p() // V3SymTable* Module's Symbol table // AstNodeFTask::user1p() // V3SymTable* Local Symbol table // AstBegin::user1p() // V3SymTable* Local Symbol table // AstVar::user2p() // bool True if port set for this variable @@ -65,7 +65,7 @@ private: // STATE // Below state needs to be preserved between each module call. - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module AstNodeFTask* m_ftaskp; // Current function/task IdState m_idState; // Id linking mode (find or resolve) int m_paramNum; // Parameter number, for position based connection @@ -172,7 +172,7 @@ private: // VISITs virtual void visit(AstNetlist* nodep, AstNUser*) { // Look at all modules, and store pointers to all module names - for (AstModule* modp = v3Global.rootp()->modulesp(); modp; modp=modp->nextp()->castModule()) { + for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; modp=modp->nextp()->castNodeModule()) { symsFindNew(modp, NULL); } // And recurse... @@ -185,7 +185,7 @@ private: nodep->checkTree(); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { // Module: Create sim table for entire module and iterate UINFO(2,"Link Module: "<name(); } }; @@ -90,15 +90,15 @@ class LinkCellsVisitor : public AstNVisitor { private: // NODE STATE // Entire netlist: - // AstModule::user1p() // V3GraphVertex* Vertex describing this module + // AstNodeModule::user1p() // V3GraphVertex* Vertex describing this module // Allocated across all readFiles in V3Global::readFiles: // AstNode::user4p() // V3SymTable* Package and typedef symbol names AstUser1InUse m_inuser1; // STATE // Below state needs to be preserved between each module call. - AstModule* m_modp; // Current module - V3SymTable m_mods; // Symbol table of all module names + AstNodeModule* m_modp; // Current module + V3SymTable m_mods; // Symbol table of all module names LinkCellsGraph m_graph; // Linked graph of all cell interconnects LibraryVertex* m_libVertexp; // Vertex at root of all libraries V3GraphVertex* m_topVertexp; // Vertex of top module @@ -110,7 +110,7 @@ private: } // METHODS - V3GraphVertex* vertex(AstModule* nodep) { + V3GraphVertex* vertex(AstNodeModule* nodep) { // Return corresponding vertex for this module if (!nodep->user1p()) { nodep->user1p(new LinkCellsVertex(&m_graph, nodep)); @@ -130,7 +130,7 @@ private: for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp=itp->verticesNextp()) { if (LinkCellsVertex* vvertexp = dynamic_cast(itp)) { // +1 so we leave level 1 for the new wrapper we'll make in a moment - AstModule* modp = vvertexp->modp(); + AstNodeModule* modp = vvertexp->modp(); modp->level(vvertexp->rank()+1); if (vvertexp == m_topVertexp && modp->level() != 2) { v3error("Specified --top-module '"<modName())->castModule(); + AstNodeModule* modp = m_mods.findIdUpward(nodep->modName())->castNodeModule(); if (!modp) { // Read-subfile V3Parse parser (v3Global.rootp()); @@ -180,7 +180,7 @@ private: // We've read new modules, grab new pointers to their names readModNames(); // Check again - modp = m_mods.findIdUpward(nodep->modName())->castModule(); + modp = m_mods.findIdUpward(nodep->modName())->castNodeModule(); if (!modp) { nodep->v3error("Can't resolve module reference: "<modName()); } @@ -250,7 +250,7 @@ private: // METHODS void readModNames() { // Look at all modules, and store pointers to all module names - for (AstModule* nodep = v3Global.rootp()->modulesp(); nodep; nodep=nodep->nextp()->castModule()) { + for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); nodep; nodep=nodep->nextp()->castNodeModule()) { AstNode* foundp = m_mods.findIdUpward(nodep->name()); if (foundp && foundp != nodep) { nodep->v3error("Duplicate declaration of module: "<prettyName()); diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index c5b3e48be..a2df93419 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -106,16 +106,16 @@ public: class LinkDotCellVertex : public LinkDotBaseVertex { // A real point in the hierarchy, corresponding to a instantiated module - AstModule* m_modp; // Module + AstNodeModule* m_modp; // Module AstCell* m_cellp; // Cell creating this vertex **NULL AT TOP** V3SymTable m_syms; // Symbol table of variable/task names for global lookup public: LinkDotCellVertex(V3Graph* graphp, AstCell* nodep) : LinkDotBaseVertex(graphp, ""), m_modp(nodep->modp()), m_cellp(nodep) {} - LinkDotCellVertex(V3Graph* graphp, AstModule* nodep) + LinkDotCellVertex(V3Graph* graphp, AstNodeModule* nodep) : LinkDotBaseVertex(graphp, ""), m_modp(nodep), m_cellp(NULL) {} virtual ~LinkDotCellVertex() {} - AstModule* modp() const { return m_modp; } // May be NULL + AstNodeModule* modp() const { return m_modp; } // May be NULL AstCell* cellp() const { return m_cellp; } // Is NULL at TOP virtual V3SymTable& syms() { return m_syms; } // We need to use origName as parameters may have renamed the modname @@ -174,7 +174,7 @@ class LinkDotState { private: // NODE STATE // Cleared on Netlist - // AstModule::user1p() -> LinkDotCellVertex*. Last cell that uses this module + // AstNodeModule::user1p() -> LinkDotCellVertex*. Last cell that uses this module // AstVarScope::user2p() -> AstVarScope*. Base alias for this signal AstUser1InUse m_inuser1; AstUser2InUse m_inuser2; @@ -209,7 +209,7 @@ public: bool forScopeCreation() const { return m_forScopeCreation; } // METHODS - LinkDotCellVertex* insertTopCell(AstModule* nodep, const string& scopename) { + LinkDotCellVertex* insertTopCell(AstNodeModule* nodep, const string& scopename) { UINFO(9," INSERTcell "<user1p(vxp); @@ -254,10 +254,10 @@ public: UINFO(9," INSERTsym "<syms().insert(name, nodep); } - bool existsModScope(AstModule* nodep) { + bool existsModScope(AstNodeModule* nodep) { return nodep->user1p()!=NULL; } - LinkDotCellVertex* findModScope(AstModule* nodep) { + LinkDotCellVertex* findModScope(AstNodeModule* nodep) { LinkDotCellVertex* vxp = (LinkDotCellVertex*)(nodep->user1p()); if (!vxp) nodep->v3fatalSrc("Module never assigned a vertex"); return vxp; @@ -385,7 +385,7 @@ private: // The first module in the list is always the top module (sorted before this is called). // This may not be the module with isTop() set, as early in the steps, // wrapTop may have not been created yet. - AstModule* topmodp = nodep->modulesp(); + AstNodeModule* topmodp = nodep->modulesp(); if (!topmodp) { nodep->v3error("No top level module found"); } else { @@ -401,7 +401,7 @@ private: m_inlineVxp = m_cellVxp; } } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { UINFO(8," "<existsModScope(nodep)) { UINFO(5,"Dead module for "<level() < rhsp->level(); } }; @@ -53,9 +53,11 @@ void V3LinkLevel::modSortByLevel() { // level() was computed for us in V3LinkCells - vector vec; - AstModule* topp = NULL; - for (AstModule* nodep = v3Global.rootp()->modulesp(); nodep; nodep=nodep->nextp()->castModule()) { + typedef vector ModVec; + + ModVec vec; + AstNodeModule* topp = NULL; + for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); nodep; nodep=nodep->nextp()->castNodeModule()) { if (nodep->level()<=2) { if (topp) { nodep->v3warn(MULTITOP, "Unsupported: Multiple top level modules: " @@ -67,13 +69,13 @@ void V3LinkLevel::modSortByLevel() { vec.push_back(nodep); } sort(vec.begin(), vec.end(), CmpLevel()); // Sort the vector - for (vector::iterator it = vec.begin(); it != vec.end(); ++it) { - AstModule* nodep = *it; + for (ModVec::iterator it = vec.begin(); it != vec.end(); ++it) { + AstNodeModule* nodep = *it; nodep->unlinkFrBack(); } if (v3Global.rootp()->modulesp()) v3Global.rootp()->v3fatalSrc("Unlink didn't work"); - for (vector::iterator it = vec.begin(); it != vec.end(); ++it) { - AstModule* nodep = *it; + for (ModVec::iterator it = vec.begin(); it != vec.end(); ++it) { + AstNodeModule* nodep = *it; v3Global.rootp()->addModulep(nodep); } } @@ -84,9 +86,9 @@ void V3LinkLevel::modSortByLevel() { void V3LinkLevel::wrapTop(AstNetlist* netlistp) { UINFO(2,__FUNCTION__<<": "<modulesp(); + AstNodeModule* oldmodp = netlistp->modulesp(); if (!oldmodp) netlistp->v3fatalSrc("No module found to process"); - AstModule* newmodp = new AstModule(oldmodp->fileline(), (string)"TOP_"+oldmodp->name()); + AstNodeModule* newmodp = new AstModule(oldmodp->fileline(), (string)"TOP_"+oldmodp->name()); // Make the new module first in the list oldmodp->unlinkFrBackWithNext(); newmodp->addNext(oldmodp); diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index 7ab9c7f8f..a0edf69ef 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -54,7 +54,7 @@ private: // STATE // Below state needs to be preserved between each module call. - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module AstNodeFTask* m_ftaskp; // Function or task we're inside AstVAssert* m_assertp; // Current assertion int m_senitemCvtNum; // Temporary signal counter @@ -67,7 +67,7 @@ private: } // VISITs - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { // Module: Create sim table for entire module and iterate UINFO(8,"MODULE "<iterateChildrenBackwards(*this); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { m_modp = nodep; nodep->iterateChildren(*this); m_modp = NULL; diff --git a/src/V3Localize.cpp b/src/V3Localize.cpp index 9b4284a8c..423b07286 100644 --- a/src/V3Localize.cpp +++ b/src/V3Localize.cpp @@ -160,10 +160,6 @@ private: nodep->iterateChildren(*this); moveVars(); } - virtual void visit(AstModule* nodep, AstNUser*) { - // Consumption/generation of a variable, - nodep->iterateChildren(*this); - } virtual void visit(AstCFunc* nodep, AstNUser*) { UINFO(4," CFUNC "<iterateChildren(*this); m_modp = NULL; diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 3b7a01e96..2af1faf39 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -246,8 +246,8 @@ private: // USER4 Cleared on each Logic stmt // AstVarScope::user4() -> VarUsage(gen/con/both). Where already encountered signal // Ordering (user3/4/5 cleared between forming and ordering) - // AstScope::user1p() -> AstModule*. Module this scope is under - // AstModule::user3() -> Number of routines created + // AstScope::user1p() -> AstNodeModule*. Module this scope is under + // AstNodeModule::user3() -> Number of routines created // Each call to V3Const::constify // AstNode::user4() Used by V3Const::constify, called below AstUser1InUse m_inuser1; @@ -266,7 +266,7 @@ private: OrderLogicVertex* m_logicVxp; // Current statement being tracked, NULL=ignored AstTopScope* m_topScopep; // Current top scope being processed AstScope* m_scopetopp; // Scope under TOPSCOPE - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module AstScope* m_scopep; // Current scope being processed AstActive* m_activep; // Current activation block bool m_inSenTree; // Underneath AstSenItem; any varrefs are clocks @@ -374,7 +374,7 @@ private: void processMoveLoopStmt(AstNode* newSubnodep); OrderLoopId processMoveLoopCurrent(); - string cfuncName(AstModule* modp, AstSenTree* domainp, AstScope* scopep, AstNode* forWhatp) { + string cfuncName(AstNodeModule* modp, AstSenTree* domainp, AstScope* scopep, AstNode* forWhatp) { modp->user3(1+modp->user3()); int funcnum = modp->user3(); string name = (domainp->hasCombo() ? "_combo" @@ -473,7 +473,7 @@ private: AstNode::user3ClearTree(); AstNode::user4ClearTree(); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { m_modp = nodep; nodep->iterateChildren(*this); m_modp = NULL; @@ -1387,7 +1387,7 @@ void OrderVisitor::processMoveOne(OrderMoveVertex* vertexp, OrderMoveDomScope* d <<" s="<<(void*)(scopep)<<" "<domainp(); AstNode* nodep = lvertexp->nodep(); - AstModule* modp = scopep->user1p()->castNode()->castModule(); UASSERT(modp,"NULL"); // Stashed by visitor func + AstNodeModule* modp = scopep->user1p()->castNode()->castNodeModule(); UASSERT(modp,"NULL"); // Stashed by visitor func if (nodep->castUntilStable()) { #ifdef NEW_ORDERING // Beginning of loop. diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 0e89b2c76..056c60438 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -52,7 +52,7 @@ class ParamVisitor : public AstNVisitor { private: // NODE STATE - // AstModule::user4() // bool True if parameters numbered + // AstNodeModule::user4() // bool True if parameters numbered // AstVar::user4() // int Global parameter number (for naming new module) // // (0=not processed, 1=iterated, but no number, 65+ parameter numbered) AstUser4InUse m_inuser4; @@ -61,9 +61,9 @@ private: // STATE typedef std::map VarCloneMap; struct ModInfo { - AstModule* m_modp; // Module with specified name + AstNodeModule* m_modp; // Module with specified name VarCloneMap m_cloneMap; // Map of old-varp -> new cloned varp - ModInfo(AstModule* modp) { m_modp=modp; } + ModInfo(AstNodeModule* modp) { m_modp=modp; } }; typedef std::map ModNameMap; ModNameMap m_modNameMap; // Hash of created module flavors by name @@ -79,7 +79,7 @@ private: return level; } - void makeSmallNames(AstModule* modp) { + void makeSmallNames(AstNodeModule* modp) { vector usedLetter; usedLetter.resize(256); // Pass 1, assign first letter to each gparam's name for (AstNode* stmtp = modp->stmtsp(); stmtp; stmtp=stmtp->nextp()) { @@ -93,7 +93,7 @@ private: } } } - string paramSmallName(AstModule* modp, AstVar* varp) { + string paramSmallName(AstNodeModule* modp, AstVar* varp) { if (varp->user4()<=1) { makeSmallNames(modp); } @@ -122,7 +122,7 @@ private: // Modules must be done in top-down-order nodep->iterateChildren(*this); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { UINFO(4," MOD "<iterateChildren(*this); } @@ -314,7 +314,7 @@ void ParamVisitor::visit(AstCell* nodep, AstNUser*) { // // Already made this flavor? - AstModule* modp = NULL; + AstNodeModule* modp = NULL; ModNameMap::iterator iter = m_modNameMap.find(newname); if (iter != m_modNameMap.end()) modp = iter->second.m_modp; if (!modp) { diff --git a/src/V3ParseImp.h b/src/V3ParseImp.h index e647fa484..2bcf6b4e0 100644 --- a/src/V3ParseImp.h +++ b/src/V3ParseImp.h @@ -61,7 +61,7 @@ struct V3ParseBisonYYSType { AstCase* casep; AstCaseItem* caseitemp; AstConst* constp; - AstModule* modulep; + AstNodeModule* modulep; AstNodeDType* dtypep; AstNodeFTask* ftaskp; AstNodeSenItem* senitemp; diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index 97d1c753e..b7073c43a 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -54,7 +54,7 @@ private: AstUser2InUse m_inuser2; // STATE - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module AstCFunc* m_funcp; // Current block AstNode* m_stmtp; // Current statement AstWhile* m_inWhilep; // Inside while loop, special statement additions @@ -144,7 +144,7 @@ private: } // VISITORS - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { UINFO(4," MOD "<topModulep(); + AstNodeModule* modp = nodep->topModulep(); if (!modp) { nodep->v3error("No root module specified"); return; } // Operate starting at the top of the hierarchy AstNode::user2ClearTree(); @@ -74,7 +74,7 @@ private: m_aboveScopep = NULL; modp->accept(*this); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { // Create required blocks and add to module string scopename = (!m_aboveScopep ? "TOP" : (m_aboveScopep->name()+"."+m_aboveCellp->name())); @@ -94,9 +94,9 @@ private: { m_aboveCellp = cellp; m_aboveScopep = m_scopep; - AstModule* modp = cellp->modp(); + AstNodeModule* modp = cellp->modp(); if (!modp) cellp->v3fatalSrc("Unlinked mod"); - modp->accept(*this); // Recursive call to visit(AstModule) + modp->accept(*this); // Recursive call to visit(AstNodeModule) } // Done, restore vars m_scopep = oldScopep; diff --git a/src/V3SenTree.h b/src/V3SenTree.h index bfb9ab207..451162d8c 100644 --- a/src/V3SenTree.h +++ b/src/V3SenTree.h @@ -64,7 +64,7 @@ private: return level; } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { // Only do the top if (nodep->isTop()) { nodep->iterateChildren(*this); diff --git a/src/V3Stats.cpp b/src/V3Stats.cpp index e5bc45cfc..970c29916 100644 --- a/src/V3Stats.cpp +++ b/src/V3Stats.cpp @@ -72,7 +72,7 @@ private: } // VISITORS - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { allNodes(nodep); if (!m_fast) { nodep->iterateChildren(*this); diff --git a/src/V3Table.cpp b/src/V3Table.cpp index 205d96ba3..49fbff0d3 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -80,8 +80,8 @@ private: V3Double0 m_statTablesCre; // Statistic tracking // State cleared on each module - AstModule* m_modp; // Current MODULE - int m_modTables; // Number of tables created in this module + AstNodeModule* m_modp; // Current MODULE + int m_modTables; // Number of tables created in this module deque m_modTableVscs; // All tables created // State cleared on each scope @@ -399,7 +399,7 @@ private: virtual void visit(AstNetlist* nodep, AstNUser*) { nodep->iterateChildren(*this); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { m_modTables = 0; m_modTableVscs.clear(); m_modp = nodep; diff --git a/src/V3Task.cpp b/src/V3Task.cpp index e5ab4c7e8..e45bd8b76 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -306,7 +306,7 @@ private: // STATE TaskStateVisitor* m_statep; // Common state between visitors - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module AstScope* m_scopep; // Current scope InsertMode m_insMode; // How to insert AstNode* m_insStmtp; // Where to insert statement @@ -632,7 +632,7 @@ private: } // VISITORS - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { m_modp = nodep; m_insStmtp = NULL; m_modNCalls = 0; diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 69547ad41..8ae59b2a5 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -167,7 +167,7 @@ private: //AstUser4InUse In V3Hashed // STATE - AstModule* m_topModp; // Module to add variables to + AstNodeModule* m_topModp; // Module to add variables to AstScope* m_highScopep; // Scope to add variables to AstCFunc* m_funcp; // C function adding to graph AstTraceInc* m_tracep; // Trace function adding to graph @@ -583,7 +583,7 @@ private: assignActivity(); putTracesIntoTree(); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { if (nodep->isTop()) m_topModp = nodep; nodep->iterateChildren(*this); } diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index e798ae66c..fd6fe50ab 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -44,7 +44,7 @@ private: // NODE STATE // STATE - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module AstScope* m_scopetopp; // Current top scope AstCFunc* m_initFuncp; // Trace function being built AstCFunc* m_initSubFuncp; // Trace function being built (under m_init) diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index c79023204..64983582c 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -95,7 +95,7 @@ private: // STATE int m_unique; - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module VarMap* m_lhsmapp; // LHS driver map AstSel* m_sel; @@ -262,7 +262,7 @@ private: } public: - TristateExpander(AstModule* nodep, VarMap* lhsmapp) { + TristateExpander(AstNodeModule* nodep, VarMap* lhsmapp) { m_modp = nodep; m_lhsmapp = lhsmapp; m_unique = 0; @@ -287,7 +287,7 @@ private: AstUser2InUse m_inuser2; AstUser3InUse m_inuser3; - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module AstCell* m_cellp; // current cell int m_unique; @@ -296,7 +296,7 @@ private: nodep->iterateChildrenBackwards(*this); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { UINFO(9," MOD "<iterateChildren(*this); } - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { m_modp = nodep; nodep->iterateChildren(*this); m_modp = NULL; diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index 415625e7a..0d7441840 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -58,7 +58,7 @@ private: AstUser2InUse m_inuser2; // STATE - AstModule* m_modp; // Current module + AstNodeModule* m_modp; // Current module bool m_constXCvt; // Convert X's V3Double0 m_statUnkVars; // Statistic tracking AstAssignW* m_assignwp; // Current assignment @@ -146,7 +146,7 @@ private: } // VISITORS - virtual void visit(AstModule* nodep, AstNUser*) { + virtual void visit(AstNodeModule* nodep, AstNUser*) { UINFO(4," MOD "<iterateChildren(*this); - } - bool cantUnroll(AstNode* nodep, const char* reason) { if (m_generate) { nodep->v3error("Unsupported: Can't unroll generate for; "<