mirror of
https://github.com/verilator/verilator.git
synced 2025-05-01 13:06:56 +00:00
Internals: Misc cleanups related to V3LinkDot. No functional change intended.
This commit is contained in:
parent
e897c862f2
commit
7922a1de28
@ -1966,7 +1966,7 @@ class AstNodeFTaskRef : public AstNode {
|
|||||||
private:
|
private:
|
||||||
AstNodeFTask* m_taskp; // [AfterLink] Pointer to task referenced
|
AstNodeFTask* m_taskp; // [AfterLink] Pointer to task referenced
|
||||||
string m_name; // Name of variable
|
string m_name; // Name of variable
|
||||||
string m_dotted; // Dotted part of scope to task or ""
|
string m_dotted; // Dotted part of scope the name()ed task/func is under or ""
|
||||||
string m_inlinedDots; // Dotted hierarchy flattened out
|
string m_inlinedDots; // Dotted hierarchy flattened out
|
||||||
AstPackage* m_packagep; // Package hierarchy
|
AstPackage* m_packagep; // Package hierarchy
|
||||||
public:
|
public:
|
||||||
|
@ -1024,7 +1024,7 @@ void AstVarXRef::dump(ostream& str) {
|
|||||||
if (packagep()) { str<<" pkg="<<(void*)packagep(); }
|
if (packagep()) { str<<" pkg="<<(void*)packagep(); }
|
||||||
if (lvalue()) str<<" [LV] => ";
|
if (lvalue()) str<<" [LV] => ";
|
||||||
else str<<" [RV] <- ";
|
else str<<" [RV] <- ";
|
||||||
str<<dotted()<<". - ";
|
str<<".="<<dotted()<<" ";
|
||||||
if (inlinedDots()!="") str<<" inline.="<<inlinedDots()<<" - ";
|
if (inlinedDots()!="") str<<" inline.="<<inlinedDots()<<" - ";
|
||||||
if (varScopep()) { varScopep()->dump(str); }
|
if (varScopep()) { varScopep()->dump(str); }
|
||||||
else if (varp()) { varp()->dump(str); }
|
else if (varp()) { varp()->dump(str); }
|
||||||
@ -1095,7 +1095,7 @@ void AstNodeFTaskRef::dump(ostream& str) {
|
|||||||
this->AstNode::dump(str);
|
this->AstNode::dump(str);
|
||||||
if (packagep()) { str<<" pkg="<<(void*)packagep(); }
|
if (packagep()) { str<<" pkg="<<(void*)packagep(); }
|
||||||
str<<" -> ";
|
str<<" -> ";
|
||||||
if (dotted()!="") { str<<dotted()<<". - "; }
|
if (dotted()!="") { str<<".="<<dotted()<<" "; }
|
||||||
if (taskp()) { taskp()->dump(str); }
|
if (taskp()) { taskp()->dump(str); }
|
||||||
else { str<<"UNLINKED"; }
|
else { str<<"UNLINKED"; }
|
||||||
}
|
}
|
||||||
|
@ -1484,7 +1484,7 @@ class AstVarXRef : public AstNodeVarRef {
|
|||||||
// A VarRef to something in another module before AstScope.
|
// A VarRef to something in another module before AstScope.
|
||||||
// Includes pin on a cell, as part of a ASSIGN statement to connect I/Os until AstScope
|
// Includes pin on a cell, as part of a ASSIGN statement to connect I/Os until AstScope
|
||||||
private:
|
private:
|
||||||
string m_dotted; // Scope name to connected to
|
string m_dotted; // Dotted part of scope the name()'ed reference is under or ""
|
||||||
string m_inlinedDots; // Dotted hierarchy flattened out
|
string m_inlinedDots; // Dotted hierarchy flattened out
|
||||||
public:
|
public:
|
||||||
AstVarXRef(FileLine* fl, const string& name, const string& dotted, bool lvalue)
|
AstVarXRef(FileLine* fl, const string& name, const string& dotted, bool lvalue)
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "V3Inst.h"
|
#include "V3Inst.h"
|
||||||
#include "V3Stats.h"
|
#include "V3Stats.h"
|
||||||
#include "V3Ast.h"
|
#include "V3Ast.h"
|
||||||
|
#include "V3String.h"
|
||||||
|
|
||||||
// CONFIG
|
// CONFIG
|
||||||
static const int INLINE_MODS_SMALLER = 100; // If a mod is < this # nodes, can always inline it
|
static const int INLINE_MODS_SMALLER = 100; // If a mod is < this # nodes, can always inline it
|
||||||
@ -270,14 +271,14 @@ public:
|
|||||||
|
|
||||||
class InlineRelinkVisitor : public AstNVisitor {
|
class InlineRelinkVisitor : public AstNVisitor {
|
||||||
private:
|
private:
|
||||||
typedef vl_unordered_set<string> RenamedInterfacesSet;
|
typedef vl_unordered_set<string> StringSet;
|
||||||
|
|
||||||
// NODE STATE
|
// NODE STATE
|
||||||
// Input:
|
// Input:
|
||||||
// See InlineVisitor
|
// See InlineVisitor
|
||||||
|
|
||||||
// STATE
|
// STATE
|
||||||
RenamedInterfacesSet m_renamedInterfaces; // Name of renamed interface variables
|
StringSet m_renamedInterfaces; // Name of renamed interface variables
|
||||||
AstNodeModule* m_modp; // Current module
|
AstNodeModule* m_modp; // Current module
|
||||||
AstCell* m_cellp; // Cell being cloned
|
AstCell* m_cellp; // Cell being cloned
|
||||||
|
|
||||||
@ -410,9 +411,8 @@ private:
|
|||||||
}
|
}
|
||||||
virtual void visit(AstVarXRef* nodep) {
|
virtual void visit(AstVarXRef* nodep) {
|
||||||
// Track what scope it was originally under so V3LinkDot can resolve it
|
// Track what scope it was originally under so V3LinkDot can resolve it
|
||||||
string newname = m_cellp->name();
|
string newdots = VString::dot(m_cellp->name(), ".", nodep->inlinedDots());
|
||||||
if (nodep->inlinedDots() != "") { newname += "." + nodep->inlinedDots(); }
|
nodep->inlinedDots(newdots);
|
||||||
nodep->inlinedDots(newname);
|
|
||||||
for (string tryname = nodep->dotted(); 1;) {
|
for (string tryname = nodep->dotted(); 1;) {
|
||||||
if (m_renamedInterfaces.count(tryname)) {
|
if (m_renamedInterfaces.count(tryname)) {
|
||||||
nodep->dotted(m_cellp->name() + "__DOT__" + nodep->dotted());
|
nodep->dotted(m_cellp->name() + "__DOT__" + nodep->dotted());
|
||||||
@ -430,9 +430,8 @@ private:
|
|||||||
}
|
}
|
||||||
virtual void visit(AstNodeFTaskRef* nodep) {
|
virtual void visit(AstNodeFTaskRef* nodep) {
|
||||||
// Track what scope it was originally under so V3LinkDot can resolve it
|
// Track what scope it was originally under so V3LinkDot can resolve it
|
||||||
string newname = m_cellp->name();
|
string newdots = VString::dot(m_cellp->name(), ".", nodep->inlinedDots());
|
||||||
if (nodep->inlinedDots() != "") { newname += "." + nodep->inlinedDots(); }
|
nodep->inlinedDots(newdots);
|
||||||
nodep->inlinedDots(newname);
|
|
||||||
if (m_renamedInterfaces.count(nodep->dotted())) {
|
if (m_renamedInterfaces.count(nodep->dotted())) {
|
||||||
nodep->dotted(m_cellp->name() + "__DOT__" + nodep->dotted());
|
nodep->dotted(m_cellp->name() + "__DOT__" + nodep->dotted());
|
||||||
}
|
}
|
||||||
@ -459,9 +458,7 @@ private:
|
|||||||
}
|
}
|
||||||
virtual void visit(AstCoverDecl* nodep) {
|
virtual void visit(AstCoverDecl* nodep) {
|
||||||
// Fix path in coverage statements
|
// Fix path in coverage statements
|
||||||
nodep->hier(m_cellp->prettyName()
|
nodep->hier(VString::dot(m_cellp->prettyName(), ".", nodep->hier()));
|
||||||
+ (nodep->hier()!="" ? ".":"")
|
|
||||||
+ nodep->hier());
|
|
||||||
nodep->iterateChildren(*this);
|
nodep->iterateChildren(*this);
|
||||||
}
|
}
|
||||||
virtual void visit(AstNode* nodep) {
|
virtual void visit(AstNode* nodep) {
|
||||||
|
@ -78,6 +78,7 @@
|
|||||||
#include "V3Graph.h"
|
#include "V3Graph.h"
|
||||||
#include "V3Ast.h"
|
#include "V3Ast.h"
|
||||||
#include "V3ParseImp.h"
|
#include "V3ParseImp.h"
|
||||||
|
#include "V3String.h"
|
||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
// LinkDot state, as a visitor of each AstNode
|
// LinkDot state, as a visitor of each AstNode
|
||||||
@ -1807,8 +1808,7 @@ private:
|
|||||||
|| foundp->nodep()->castModule()) { // if top
|
|| foundp->nodep()->castModule()) { // if top
|
||||||
if (allowScope) {
|
if (allowScope) {
|
||||||
ok = true;
|
ok = true;
|
||||||
if (m_ds.m_dotText!="") m_ds.m_dotText += ".";
|
m_ds.m_dotText = VString::dot(m_ds.m_dotText, ".", nodep->name());
|
||||||
m_ds.m_dotText += nodep->name();
|
|
||||||
m_ds.m_dotSymp = foundp;
|
m_ds.m_dotSymp = foundp;
|
||||||
m_ds.m_dotPos = DP_SCOPE;
|
m_ds.m_dotPos = DP_SCOPE;
|
||||||
// Upper AstDot visitor will handle it from here
|
// Upper AstDot visitor will handle it from here
|
||||||
@ -1827,8 +1827,7 @@ private:
|
|||||||
if (!ifaceRefVarp) nodep->v3fatalSrc("Can't find interface var ref: "<<findName);
|
if (!ifaceRefVarp) nodep->v3fatalSrc("Can't find interface var ref: "<<findName);
|
||||||
//
|
//
|
||||||
ok = true;
|
ok = true;
|
||||||
if (m_ds.m_dotText!="") m_ds.m_dotText += ".";
|
m_ds.m_dotText = VString::dot(m_ds.m_dotText, ".", nodep->name());
|
||||||
m_ds.m_dotText += nodep->name();
|
|
||||||
m_ds.m_dotSymp = foundp;
|
m_ds.m_dotSymp = foundp;
|
||||||
m_ds.m_dotPos = DP_SCOPE;
|
m_ds.m_dotPos = DP_SCOPE;
|
||||||
UINFO(9," cell -> iface varref "<<foundp->nodep()<<endl);
|
UINFO(9," cell -> iface varref "<<foundp->nodep()<<endl);
|
||||||
@ -1845,8 +1844,7 @@ private:
|
|||||||
if (!ifacerefp->ifaceViaCellp()) ifacerefp->v3fatalSrc("Unlinked interface");
|
if (!ifacerefp->ifaceViaCellp()) ifacerefp->v3fatalSrc("Unlinked interface");
|
||||||
// Really this is a scope reference into an interface
|
// Really this is a scope reference into an interface
|
||||||
UINFO(9,"varref-ifaceref "<<m_ds.m_dotText<<" "<<nodep<<endl);
|
UINFO(9,"varref-ifaceref "<<m_ds.m_dotText<<" "<<nodep<<endl);
|
||||||
if (m_ds.m_dotText!="") m_ds.m_dotText += ".";
|
m_ds.m_dotText = VString::dot(m_ds.m_dotText, ".", nodep->name());
|
||||||
m_ds.m_dotText += nodep->name();
|
|
||||||
m_ds.m_dotSymp = m_statep->getNodeSym(ifacerefp->ifaceViaCellp());
|
m_ds.m_dotSymp = m_statep->getNodeSym(ifacerefp->ifaceViaCellp());
|
||||||
m_ds.m_dotPos = DP_SCOPE;
|
m_ds.m_dotPos = DP_SCOPE;
|
||||||
ok = true;
|
ok = true;
|
||||||
@ -1897,8 +1895,7 @@ private:
|
|||||||
if (!cellp) nodep->v3fatalSrc("Modport not referenced from a cell");
|
if (!cellp) nodep->v3fatalSrc("Modport not referenced from a cell");
|
||||||
AstIface* ifacep = cellp->modp()->castIface();
|
AstIface* ifacep = cellp->modp()->castIface();
|
||||||
//string cellName = m_ds.m_dotText; // Use cellp->name
|
//string cellName = m_ds.m_dotText; // Use cellp->name
|
||||||
if (m_ds.m_dotText!="") m_ds.m_dotText += ".";
|
m_ds.m_dotText = VString::dot(m_ds.m_dotText, ".", nodep->name());
|
||||||
m_ds.m_dotText += nodep->name();
|
|
||||||
m_ds.m_dotSymp = m_statep->getNodeSym(modportp);
|
m_ds.m_dotSymp = m_statep->getNodeSym(modportp);
|
||||||
m_ds.m_dotPos = DP_SCOPE;
|
m_ds.m_dotPos = DP_SCOPE;
|
||||||
ok = true;
|
ok = true;
|
||||||
|
@ -69,6 +69,12 @@ bool VString::wildmatch(const char* s, const char* p) {
|
|||||||
return (*s == '\0');
|
return (*s == '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string VString::dot(const string& a, const string& dot, const string& b) {
|
||||||
|
if (b=="") return a;
|
||||||
|
if (a=="") return b;
|
||||||
|
return a+dot+b;
|
||||||
|
}
|
||||||
|
|
||||||
string VString::downcase(const string& str) {
|
string VString::downcase(const string& str) {
|
||||||
string out = str;
|
string out = str;
|
||||||
for (string::iterator pos = out.begin(); pos != out.end(); ++pos) {
|
for (string::iterator pos = out.begin(); pos != out.end(); ++pos) {
|
||||||
|
@ -33,8 +33,13 @@ class VString {
|
|||||||
static bool wildmatchi(const char* s, const char* p);
|
static bool wildmatchi(const char* s, const char* p);
|
||||||
public:
|
public:
|
||||||
// METHODS (generic string utilities)
|
// METHODS (generic string utilities)
|
||||||
|
// Return true if p with ? or *'s matches s
|
||||||
static bool wildmatch(const char* s, const char* p);
|
static bool wildmatch(const char* s, const char* p);
|
||||||
|
// Return {a}{dot}{b}, omitting dot if a or b are empty
|
||||||
|
static string dot(const string& a, const string& dot, const string& b);
|
||||||
|
// Convert string to lowercase
|
||||||
static string downcase(const string& str);
|
static string downcase(const string& str);
|
||||||
|
// Replace any %'s with %%
|
||||||
static string quotePercent(const string& str);
|
static string quotePercent(const string& str);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ public:
|
|||||||
os<<indent<<"+ "<<left<<setw(30)<<(searchName==""?"\"\"":searchName)<<setw(0)<<right;
|
os<<indent<<"+ "<<left<<setw(30)<<(searchName==""?"\"\"":searchName)<<setw(0)<<right;
|
||||||
os<<" se"<<(void*)(this)<<setw(0);
|
os<<" se"<<(void*)(this)<<setw(0);
|
||||||
os<<" fallb=se"<<(void*)(m_fallbackp);
|
os<<" fallb=se"<<(void*)(m_fallbackp);
|
||||||
|
if (m_symPrefix!="") os<<" symPrefix="<<m_symPrefix;
|
||||||
os<<" n="<<nodep();
|
os<<" n="<<nodep();
|
||||||
os<<endl;
|
os<<endl;
|
||||||
if (doneSymsr.find(this) != doneSymsr.end()) {
|
if (doneSymsr.find(this) != doneSymsr.end()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user