Allow __ in cell names by quoting them in C.
git-svn-id: file://localhost/svn/verilator/trunk/verilator@1003 77ca24e4-aefa-0310-84f0-b9a241c72d87
This commit is contained in:
parent
b1565f5b89
commit
4a1729eaab
2
Changes
2
Changes
|
|
@ -14,6 +14,8 @@ indicates the contributor was also the author of the fix; Thanks!
|
|||
|
||||
*** Add --error-limit option. [Stefan Thiede]
|
||||
|
||||
*** Allow __ in cell names by quoting them in C. [Stefan Thiede]
|
||||
|
||||
**** Fix genvar to be signed, so "< 0" works properly. [Niranjan Prabhu]
|
||||
|
||||
**** Fix assignments to inputs inside functions/tasks. [Patricio Kaplan]
|
||||
|
|
|
|||
|
|
@ -83,6 +83,20 @@ void AstNode::init() {
|
|||
m_user5Cnt = 0;
|
||||
}
|
||||
|
||||
string AstNode::encodeName(const string& namein) {
|
||||
string name2 = namein;
|
||||
string out;
|
||||
for (string::iterator pos = name2.begin(); pos != name2.end(); pos++) {
|
||||
if (pos[0]=='_' && pos[1]=='_') {
|
||||
out += "__ULUL_";
|
||||
pos++;
|
||||
} else {
|
||||
out += pos[0];
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
string AstNode::shortName() const {
|
||||
string pretty = name();
|
||||
string::size_type pos;
|
||||
|
|
@ -114,6 +128,9 @@ string AstNode::prettyName(const string& namein) {
|
|||
while ((pos=pretty.find("__PVT__")) != string::npos) {
|
||||
pretty.replace(pos, 7, "");
|
||||
}
|
||||
while ((pos=pretty.find("__ULUL_")) != string::npos) {
|
||||
pretty.replace(pos, 7, "");
|
||||
}
|
||||
return AstNode::dedotName(pretty);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -558,6 +558,7 @@ public:
|
|||
string shortName() const; // Name with __PVT__ removed for concatenating scopes
|
||||
static string dedotName(const string& namein); // Name with dots removed
|
||||
static string prettyName(const string& namein); // Name for printing out to the user
|
||||
static string encodeName(const string& namein); // Encode user name into internal C representation
|
||||
string prettyName() const { return prettyName(name()); }
|
||||
FileLine* fileline() const { return m_fileline; }
|
||||
int width() const { return m_width; }
|
||||
|
|
|
|||
|
|
@ -127,9 +127,6 @@ private:
|
|||
// Module: Pick up modnames, so we can resolve cells later
|
||||
m_modp = nodep;
|
||||
UINFO(2,"Link Module: "<<nodep<<endl);
|
||||
if (nodep->name().find("__") != string::npos) {
|
||||
nodep->v3error("Unsupported: Double underscores (__) in module names reserved for internal use: "<<nodep->prettyName());
|
||||
}
|
||||
if (nodep->inLibrary()) {
|
||||
if (!m_libVertexp) m_libVertexp = new LibraryVertex(&m_graph);
|
||||
new V3GraphEdge(&m_graph, m_libVertexp, vertex(nodep), 1, false);
|
||||
|
|
|
|||
|
|
@ -634,14 +634,18 @@ escid \\[^ \t\f\r\n]+
|
|||
if (!isalnum(yytext[i]))
|
||||
yytext[i] = '_';
|
||||
if (isalpha(yytext[1])) {
|
||||
yylval.strp = V3Read::newString(yytext+1); // +1 to skip the backslash
|
||||
yylval.strp = V3Read::newString(
|
||||
AstNode::encodeName(
|
||||
string(yytext+1))); // +1 to skip the backslash
|
||||
} else {
|
||||
yylval.strp = V3Read::newString(yytext); // Need _ as "6..." isn't legal ID
|
||||
yylval.strp = V3Read::newString(
|
||||
AstNode::encodeName(
|
||||
yytext)); // Need _ as "6..." isn't legal ID
|
||||
}
|
||||
return yaID;
|
||||
}
|
||||
|
||||
{id} { yylval.strp = V3Read::newString(yytext);
|
||||
{id} { yylval.strp = V3Read::newString(AstNode::encodeName(string(yytext)));
|
||||
return yaID;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue