forked from github/verilator
Internals: Rename LinkDot methods. Merge from dot. No functional change
This commit is contained in:
parent
f3f34baa73
commit
a2f49063e2
@ -80,13 +80,23 @@ public:
|
|||||||
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__);
|
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__);
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
void dump() {
|
||||||
|
if (debug()>=6) m_syms.dumpFilePrefixed("linkdot");
|
||||||
|
}
|
||||||
|
void preErrorDump() {
|
||||||
|
static bool diddump = false;
|
||||||
|
if (!diddump && v3Global.opt.dumpTree()) {
|
||||||
|
diddump = true;
|
||||||
|
m_syms.dumpFilePrefixed("linkdot-preerr");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
LinkDotState(AstNetlist* rootp, bool forPrearray, bool forScopeCreation)
|
LinkDotState(AstNetlist* rootp, VLinkDotStep step)
|
||||||
: m_syms(rootp) {
|
: m_syms(rootp) {
|
||||||
UINFO(4,__FUNCTION__<<": "<<endl);
|
UINFO(4,__FUNCTION__<<": "<<endl);
|
||||||
m_forPrearray = forPrearray;
|
m_forPrearray = (step == LDS_PARAMED || step==LDS_PRIMARY);
|
||||||
m_forScopeCreation = forScopeCreation;
|
m_forScopeCreation = (step == LDS_SCOPED);
|
||||||
}
|
}
|
||||||
~LinkDotState() {}
|
~LinkDotState() {}
|
||||||
|
|
||||||
@ -150,7 +160,7 @@ public:
|
|||||||
// A fake point in the hierarchy, corresponding to a begin block
|
// A fake point in the hierarchy, corresponding to a begin block
|
||||||
// After we remove begins these will go away
|
// After we remove begins these will go away
|
||||||
// Note we fallback to the symbol table of the parent, as we want to find variables there
|
// Note we fallback to the symbol table of the parent, as we want to find variables there
|
||||||
// However, cells walk the graph, so cells will appear under the begin itself
|
// However, cells walk the graph, so cells will appear under the begin/ftask itself
|
||||||
if (!abovep) nodep->v3fatalSrc("Null symbol table inserting node");
|
if (!abovep) nodep->v3fatalSrc("Null symbol table inserting node");
|
||||||
VSymEnt* symp = new VSymEnt(&m_syms, nodep);
|
VSymEnt* symp = new VSymEnt(&m_syms, nodep);
|
||||||
UINFO(9," INSERTblk se"<<(void*)symp<<" above=se"<<(void*)abovep<<" node="<<nodep<<endl);
|
UINFO(9," INSERTblk se"<<(void*)symp<<" above=se"<<(void*)abovep<<" node="<<nodep<<endl);
|
||||||
@ -172,9 +182,9 @@ public:
|
|||||||
static bool existsModScope(AstNodeModule* nodep) {
|
static bool existsModScope(AstNodeModule* nodep) {
|
||||||
return nodep->user1p()!=NULL;
|
return nodep->user1p()!=NULL;
|
||||||
}
|
}
|
||||||
static VSymEnt* getNodeSym(AstNodeModule* nodep) {
|
static VSymEnt* getNodeSym(AstNode* nodep) {
|
||||||
VSymEnt* symp = nodep->user1p()->castSymEnt();
|
VSymEnt* symp = nodep->user1p()->castSymEnt();
|
||||||
if (!symp) nodep->v3fatalSrc("Module never assigned a symbol entry?");
|
if (!symp) nodep->v3fatalSrc("Module/etc never assigned a symbol entry?");
|
||||||
return symp;
|
return symp;
|
||||||
}
|
}
|
||||||
VSymEnt* getScopeSym(AstScope* nodep) {
|
VSymEnt* getScopeSym(AstScope* nodep) {
|
||||||
@ -184,16 +194,6 @@ public:
|
|||||||
}
|
}
|
||||||
return iter->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
void dump() {
|
|
||||||
if (debug()>=6) m_syms.dumpFilePrefixed("linkdot");
|
|
||||||
}
|
|
||||||
void preErrorDump() {
|
|
||||||
static bool diddump = false;
|
|
||||||
if (!diddump && v3Global.opt.dumpTree()) {
|
|
||||||
diddump = true;
|
|
||||||
m_syms.dumpFilePrefixed("linkdot-preerr");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
VSymEnt* findDotted(VSymEnt* lookupSymp, const string& dotname,
|
VSymEnt* findDotted(VSymEnt* lookupSymp, const string& dotname,
|
||||||
string& baddot, VSymEnt*& okSymp) {
|
string& baddot, VSymEnt*& okSymp) {
|
||||||
// Given a dotted hierarchy name, return where in scope it is
|
// Given a dotted hierarchy name, return where in scope it is
|
||||||
@ -221,7 +221,7 @@ public:
|
|||||||
altIdent = ident.substr(0,pos);
|
altIdent = ident.substr(0,pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UINFO(8," id "<<ident<<" left "<<leftname<<" at se"<<lookupSymp<<endl);
|
UINFO(8," id "<<ident<<" alt "<<altIdent<<" left "<<leftname<<" at se"<<lookupSymp<<endl);
|
||||||
// Spec says; Look at exiting module (cellnames then modname),
|
// Spec says; Look at exiting module (cellnames then modname),
|
||||||
// then look up (inst name or modname)
|
// then look up (inst name or modname)
|
||||||
if (firstId) {
|
if (firstId) {
|
||||||
@ -352,7 +352,10 @@ private:
|
|||||||
string baddot;
|
string baddot;
|
||||||
VSymEnt* okSymp;
|
VSymEnt* okSymp;
|
||||||
aboveSymp = m_statep->findDotted(aboveSymp, scope, baddot, okSymp);
|
aboveSymp = m_statep->findDotted(aboveSymp, scope, baddot, okSymp);
|
||||||
if (!aboveSymp) nodep->v3fatalSrc("Can't find cell insertion point at '"<<baddot<<"' in: "<<nodep->prettyName());
|
if (!aboveSymp) {
|
||||||
|
m_statep->preErrorDump();
|
||||||
|
nodep->v3fatalSrc("Can't find cell insertion point at '"<<baddot<<"' in: "<<nodep->prettyName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
m_scope = m_scope+"."+nodep->name();
|
m_scope = m_scope+"."+nodep->name();
|
||||||
@ -377,7 +380,10 @@ private:
|
|||||||
string baddot;
|
string baddot;
|
||||||
VSymEnt* okSymp;
|
VSymEnt* okSymp;
|
||||||
aboveSymp = m_statep->findDotted(aboveSymp, dotted, baddot, okSymp);
|
aboveSymp = m_statep->findDotted(aboveSymp, dotted, baddot, okSymp);
|
||||||
if (!aboveSymp) nodep->v3fatalSrc("Can't find cellinline insertion point at '"<<baddot<<"' in: "<<nodep->prettyName());
|
if (!aboveSymp) {
|
||||||
|
m_statep->preErrorDump();
|
||||||
|
nodep->v3fatalSrc("Can't find cellinline insertion point at '"<<baddot<<"' in: "<<nodep->prettyName());
|
||||||
|
}
|
||||||
m_statep->insertInline(aboveSymp, m_modSymp, nodep, ident);
|
m_statep->insertInline(aboveSymp, m_modSymp, nodep, ident);
|
||||||
} else { // No __DOT__, just directly underneath
|
} else { // No __DOT__, just directly underneath
|
||||||
m_statep->insertInline(aboveSymp, m_modSymp, nodep, nodep->name());
|
m_statep->insertInline(aboveSymp, m_modSymp, nodep, nodep->name());
|
||||||
@ -386,14 +392,14 @@ private:
|
|||||||
virtual void visit(AstBegin* nodep, AstNUser*) {
|
virtual void visit(AstBegin* nodep, AstNUser*) {
|
||||||
UINFO(5," "<<nodep<<endl);
|
UINFO(5," "<<nodep<<endl);
|
||||||
AstBegin* oldbegin = m_beginp;
|
AstBegin* oldbegin = m_beginp;
|
||||||
VSymEnt* oldSymp = m_curSymp;
|
VSymEnt* oldCurSymp = m_curSymp;
|
||||||
{
|
{
|
||||||
m_beginp = nodep;
|
m_beginp = nodep;
|
||||||
// We don't pickup variables (as not supported yet), but do need to find cells
|
// We don't pickup variables (as not supported yet), but do need to find cells
|
||||||
m_curSymp = m_statep->insertBegin(m_curSymp, m_modSymp, nodep);
|
m_curSymp = m_statep->insertBegin(m_curSymp, m_modSymp, nodep);
|
||||||
nodep->stmtsp()->iterateAndNext(*this);
|
nodep->stmtsp()->iterateAndNext(*this);
|
||||||
}
|
}
|
||||||
m_curSymp = oldSymp;
|
m_curSymp = oldCurSymp;
|
||||||
m_beginp = oldbegin;
|
m_beginp = oldbegin;
|
||||||
//
|
//
|
||||||
nodep->flatsp()->iterateAndNext(*this);
|
nodep->flatsp()->iterateAndNext(*this);
|
||||||
@ -648,13 +654,15 @@ public:
|
|||||||
//######################################################################
|
//######################################################################
|
||||||
// Link class functions
|
// Link class functions
|
||||||
|
|
||||||
void V3LinkDot::linkDotGuts(AstNetlist* rootp, bool prearray, bool scoped) {
|
int V3LinkDot::debug() { return LinkDotState::debug(); }
|
||||||
|
|
||||||
|
void V3LinkDot::linkDotGuts(AstNetlist* rootp, VLinkDotStep step) {
|
||||||
UINFO(2,__FUNCTION__<<": "<<endl);
|
UINFO(2,__FUNCTION__<<": "<<endl);
|
||||||
if (LinkDotState::debug()>=5 || v3Global.opt.dumpTree()>=9) v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("prelinkdot.tree"));
|
if (LinkDotState::debug()>=5 || v3Global.opt.dumpTree()>=9) v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("prelinkdot.tree"));
|
||||||
LinkDotState state (rootp, prearray, scoped);
|
LinkDotState state (rootp, step);
|
||||||
LinkDotFindVisitor visitor(rootp,&state);
|
LinkDotFindVisitor visitor(rootp,&state);
|
||||||
if (LinkDotState::debug()>=5 || v3Global.opt.dumpTree()>=9) v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("prelinkdot-find.tree"));
|
if (LinkDotState::debug()>=5 || v3Global.opt.dumpTree()>=9) v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("prelinkdot-find.tree"));
|
||||||
if (scoped) {
|
if (step == LDS_SCOPED) {
|
||||||
// Well after the initial link when we're ready to operate on the flat design,
|
// Well after the initial link when we're ready to operate on the flat design,
|
||||||
// process AstScope's. This needs to be separate pass after whole hierarchy graph created.
|
// process AstScope's. This needs to be separate pass after whole hierarchy graph created.
|
||||||
LinkDotScopeVisitor visitors(rootp,&state);
|
LinkDotScopeVisitor visitors(rootp,&state);
|
||||||
|
@ -27,13 +27,21 @@
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
|
enum VLinkDotStep { LDS_PRIMARY, LDS_PARAMED, LDS_ARRAYED, LDS_SCOPED };
|
||||||
|
|
||||||
class V3LinkDot {
|
class V3LinkDot {
|
||||||
private:
|
private:
|
||||||
static void linkDotGuts(AstNetlist* nodep, bool preparam, bool scoped);
|
static int debug();
|
||||||
|
static void linkDotGuts(AstNetlist* nodep, VLinkDotStep step);
|
||||||
public:
|
public:
|
||||||
static void linkDotPrearrayed(AstNetlist* nodep) { linkDotGuts(nodep,true,false); }
|
static void linkDotPrimary(AstNetlist* nodep) {
|
||||||
static void linkDotArrayed(AstNetlist* nodep) { linkDotGuts(nodep,false,false); }
|
UINFO(2,__FUNCTION__<<": "<<endl); linkDotGuts(nodep,LDS_PRIMARY); }
|
||||||
static void linkDotScope(AstNetlist* nodep) { linkDotGuts(nodep,false,true); }
|
static void linkDotParamed(AstNetlist* nodep) {
|
||||||
|
UINFO(2,__FUNCTION__<<": "<<endl); linkDotGuts(nodep,LDS_PARAMED); }
|
||||||
|
static void linkDotArrayed(AstNetlist* nodep) {
|
||||||
|
UINFO(2,__FUNCTION__<<": "<<endl); linkDotGuts(nodep,LDS_ARRAYED); }
|
||||||
|
static void linkDotScope(AstNetlist* nodep) {
|
||||||
|
UINFO(2,__FUNCTION__<<": "<<endl); linkDotGuts(nodep,LDS_SCOPED); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // Guard
|
#endif // Guard
|
||||||
|
@ -53,7 +53,15 @@ private:
|
|||||||
VSymEnt* m_parentp; // Table that created this table, dot notation needed to resolve into it
|
VSymEnt* m_parentp; // Table that created this table, dot notation needed to resolve into it
|
||||||
AstPackage* m_packagep; // Package node is in (for V3LinkDot, unused here)
|
AstPackage* m_packagep; // Package node is in (for V3LinkDot, unused here)
|
||||||
string m_symPrefix; // String to prefix symbols with (for V3LinkDot, unused here)
|
string m_symPrefix; // String to prefix symbols with (for V3LinkDot, unused here)
|
||||||
|
#if 0 // debug
|
||||||
|
static int debug() {
|
||||||
|
static int level = -1;
|
||||||
|
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel("V3LinkDot.cpp");
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
#else
|
||||||
static int debug() { return 0; } // NOT runtime, too hot of a function
|
static int debug() { return 0; } // NOT runtime, too hot of a function
|
||||||
|
#endif
|
||||||
public:
|
public:
|
||||||
void dumpIterate(ostream& os, VSymMap& doneSymsr, const string& indent, int numLevels, const string& searchName) {
|
void dumpIterate(ostream& os, VSymMap& doneSymsr, const string& indent, int numLevels, const string& searchName) {
|
||||||
os<<indent<<"+ "<<left<<setw(30)<<(searchName==""?"\"\"":searchName)<<setw(0)<<right;
|
os<<indent<<"+ "<<left<<setw(30)<<(searchName==""?"\"\"":searchName)<<setw(0)<<right;
|
||||||
|
@ -816,6 +816,7 @@ private:
|
|||||||
}
|
}
|
||||||
virtual void visit(AstNodeVarRef* nodep, AstNUser* vup) {
|
virtual void visit(AstNodeVarRef* nodep, AstNUser* vup) {
|
||||||
if (nodep->didWidth()) return;
|
if (nodep->didWidth()) return;
|
||||||
|
if (!nodep->varp()) nodep->v3fatalSrc("Unlinked varref");
|
||||||
if (!nodep->varp()->didWidth()) {
|
if (!nodep->varp()->didWidth()) {
|
||||||
// Var hasn't been widthed, so make it so.
|
// Var hasn't been widthed, so make it so.
|
||||||
nodep->varp()->iterate(*this);
|
nodep->varp()->iterate(*this);
|
||||||
|
@ -161,8 +161,9 @@ void process () {
|
|||||||
V3Link::link(v3Global.rootp());
|
V3Link::link(v3Global.rootp());
|
||||||
if (dumpMore) V3Global::dumpGlobalTree("linkmain.tree");
|
if (dumpMore) V3Global::dumpGlobalTree("linkmain.tree");
|
||||||
// Cross-link dotted hierarchical references
|
// Cross-link dotted hierarchical references
|
||||||
V3LinkDot::linkDotPrearrayed(v3Global.rootp());
|
V3LinkDot::linkDotPrimary(v3Global.rootp());
|
||||||
if (dumpMore) V3Global::dumpGlobalTree("linkdot.tree");
|
if (dumpMore) V3Global::dumpGlobalTree("linkdot.tree");
|
||||||
|
v3Global.checkTree(); // Force a check, as link is most likely place for problems
|
||||||
// Correct state we couldn't know at parse time, repair SEL's
|
// Correct state we couldn't know at parse time, repair SEL's
|
||||||
V3LinkResolve::linkResolve(v3Global.rootp());
|
V3LinkResolve::linkResolve(v3Global.rootp());
|
||||||
if (dumpMore) V3Global::dumpGlobalTree("linkresolve.tree");
|
if (dumpMore) V3Global::dumpGlobalTree("linkresolve.tree");
|
||||||
@ -179,8 +180,9 @@ void process () {
|
|||||||
// Remove parameters by cloning modules to de-parameterized versions
|
// Remove parameters by cloning modules to de-parameterized versions
|
||||||
// This requires some width calculations and constant propagation
|
// This requires some width calculations and constant propagation
|
||||||
V3Param::param(v3Global.rootp());
|
V3Param::param(v3Global.rootp());
|
||||||
V3LinkDot::linkDotPrearrayed(v3Global.rootp()); // Cleanup as made new modules
|
if (dumpMore) V3Global::dumpGlobalTree("param.tree");
|
||||||
V3Global::dumpGlobalTree("param.tree");
|
V3LinkDot::linkDotParamed(v3Global.rootp()); // Cleanup as made new modules
|
||||||
|
V3Global::dumpGlobalTree("paramlink.tree");
|
||||||
V3Error::abortIfErrors();
|
V3Error::abortIfErrors();
|
||||||
|
|
||||||
// Remove any modules that were parameterized and are no longer referenced.
|
// Remove any modules that were parameterized and are no longer referenced.
|
||||||
|
Loading…
Reference in New Issue
Block a user