Improve Verilation performance on internal strings, msg1975.
This commit is contained in:
parent
26774eb045
commit
45d7312dfc
2
Changes
2
Changes
|
|
@ -10,6 +10,8 @@ indicates the contributor was also the author of the fix; Thanks!
|
||||||
|
|
||||||
**** Fix error on wide numbers that represent small msb/lsb, msg1991. [Mandy Xu]
|
**** Fix error on wide numbers that represent small msb/lsb, msg1991. [Mandy Xu]
|
||||||
|
|
||||||
|
**** Improve Verilation performance on internal strings, msg1975. [Johan Bjork]
|
||||||
|
|
||||||
|
|
||||||
* Verilator 3.886 2016-07-30
|
* Verilator 3.886 2016-07-30
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,44 +166,53 @@ string AstNode::vcdName(const string& namein) {
|
||||||
}
|
}
|
||||||
|
|
||||||
string AstNode::prettyName(const string& namein) {
|
string AstNode::prettyName(const string& namein) {
|
||||||
|
// This function is somewhat hot, so we short-circuit some compares
|
||||||
string pretty;
|
string pretty;
|
||||||
pretty = "";
|
pretty = "";
|
||||||
|
pretty.reserve(namein.length());
|
||||||
for (const char* pos = namein.c_str(); *pos; ) {
|
for (const char* pos = namein.c_str(); *pos; ) {
|
||||||
|
if (pos[0]=='-' && pos[1]=='>') { // ->
|
||||||
|
pretty += ".";
|
||||||
|
pos += 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (pos[0]=='_' && pos[1]=='_') { // Short-circuit
|
||||||
if (0==strncmp(pos,"__BRA__",7)) {
|
if (0==strncmp(pos,"__BRA__",7)) {
|
||||||
pretty += "[";
|
pretty += "[";
|
||||||
pos += 7;
|
pos += 7;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (0==strncmp(pos,"__KET__",7)) {
|
if (0==strncmp(pos,"__KET__",7)) {
|
||||||
pretty += "]";
|
pretty += "]";
|
||||||
pos += 7;
|
pos += 7;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (0==strncmp(pos,"__DOT__",7)) {
|
if (0==strncmp(pos,"__DOT__",7)) {
|
||||||
pretty += ".";
|
pretty += ".";
|
||||||
pos += 7;
|
pos += 7;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (0==strncmp(pos,"->",2)) {
|
if (0==strncmp(pos,"__PVT__",7)) {
|
||||||
pretty += ".";
|
|
||||||
pos += 2;
|
|
||||||
}
|
|
||||||
else if (0==strncmp(pos,"__PVT__",7)) {
|
|
||||||
pretty += "";
|
pretty += "";
|
||||||
pos += 7;
|
pos += 7;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (pos[0]=='_' && pos[1]=='_' && pos[2]=='0'
|
if (pos[0]=='_' && pos[1]=='_' && pos[2]=='0'
|
||||||
&& isxdigit(pos[3]) && isxdigit(pos[4])) {
|
&& isxdigit(pos[3]) && isxdigit(pos[4])) {
|
||||||
char value = 0;
|
char value = 0;
|
||||||
value += 16*(isdigit(pos[3]) ? (pos[3]-'0') : (tolower(pos[3])-'a'+10));
|
value += 16*(isdigit(pos[3]) ? (pos[3]-'0') : (tolower(pos[3])-'a'+10));
|
||||||
value += (isdigit(pos[4]) ? (pos[4]-'0') : (tolower(pos[4])-'a'+10));
|
value += (isdigit(pos[4]) ? (pos[4]-'0') : (tolower(pos[4])-'a'+10));
|
||||||
pretty += value;
|
pretty += value;
|
||||||
pos += 5;
|
pos += 5;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
|
// Default
|
||||||
pretty += pos[0];
|
pretty += pos[0];
|
||||||
++pos;
|
++pos;
|
||||||
}
|
}
|
||||||
}
|
if (pretty[0]=='T' && pretty.substr(0,4) == "TOP.") pretty.replace(0,4,"");
|
||||||
if (pretty.substr(0,4) == "TOP.") pretty.replace(0,4,"");
|
if (pretty[0]=='T' && pretty.substr(0,5) == "TOP->") pretty.replace(0,5,"");
|
||||||
if (pretty.substr(0,5) == "TOP->") pretty.replace(0,5,"");
|
|
||||||
return pretty;
|
return pretty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue