Fix internal signal names containing control characters (broke in 3.680).

Internally this means for signal names use __0{xdigit}{xdigit} and avoid
__0 in other cases.
This commit is contained in:
Wilson Snyder 2008-11-17 21:02:10 -05:00
parent 13f6c5a934
commit b75ff3652c
10 changed files with 26 additions and 21 deletions

View File

@ -11,6 +11,8 @@ indicates the contributor was also the author of the fix; Thanks!
**** Fix 'bad select range' warning missing some cases, bug43. [Lane Brooks]
**** Fix internal signal names containing control characters (broke in 3.680).
* Verilator 3.681 2008/11/12
*** Add SystemVerilog unique and priority case.

View File

@ -107,7 +107,7 @@ sub profcfunc {
}
}
if ($vfunc =~ /__PROF__([a-zA-Z_0-9]+)__([0-9]+)\(/) {
if ($vfunc =~ /__PROF__([a-zA-Z_0-9]+)__l?([0-9]+)\(/) {
$vfunc = sprintf("VBlock %s:%d", $1, $2);
$groups{type}{"Verilog Blocks under $design"} += $pct;
$groups{design}{$design} += $pct;

View File

@ -92,7 +92,7 @@ string AstNode::encodeName(const string& namein) {
out += pos[0];
} else if (pos[0]=='_') {
if (pos[1]=='_') {
out += "_"; out += "__5F"; // hex(_) = 0x5F
out += "_"; out += "__05F"; // hex(_) = 0x5F
pos++;
} else {
out += pos[0];
@ -104,8 +104,10 @@ string AstNode::encodeName(const string& namein) {
} else if (pos[0]==']') {
out += "__KET__";
} else {
// Need the leading 0 so this will never collide with
// a user identifier nor a temp we create in Verilator.
char hex[10]; sprintf(hex,"%02X",pos[0]);
out += "__"; out += hex;
out += "__0"; out += hex;
}
}
return out;
@ -113,7 +115,7 @@ string AstNode::encodeName(const string& namein) {
string AstNode::encodeNumber(vlsint64_t num) {
if (num < 0) {
return "__2D"+cvtToStr(-num); // 2D=-
return "__02D"+cvtToStr(-num); // 2D=-
} else {
return cvtToStr(num);
}
@ -159,12 +161,13 @@ string AstNode::prettyName(const string& namein) {
pretty += "";
pos += 7;
}
else if (pos[0]=='_' && pos[1]=='_' && isxdigit(pos[2]) && isxdigit(pos[3])) {
else if (pos[0]=='_' && pos[1]=='_' && pos[2]=='0'
&& isxdigit(pos[3]) && isxdigit(pos[4])) {
char value = 0;
value += 16*(isdigit(pos[2]) ? (pos[2]-'0') : (tolower(pos[2])-'a'+10));
value += (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));
pretty += value;
pos += 4;
pos += 5;
}
else {
pretty += pos[0];

View File

@ -720,8 +720,8 @@ private:
if (!m_modp) nodep->v3fatalSrc("Not under module");
// We could create just one temp variable, but we'll get better optimization
// if we make one per term.
string name1 = ((string)"__Vconcswap__"+cvtToStr(m_modp->varNumGetInc()));
string name2 = ((string)"__Vconcswap__"+cvtToStr(m_modp->varNumGetInc()));
string name1 = ((string)"__Vconcswap"+cvtToStr(m_modp->varNumGetInc()));
string name2 = ((string)"__Vconcswap"+cvtToStr(m_modp->varNumGetInc()));
AstVar* temp1p = new AstVar(sel1p->fileline(), AstVarType::BLOCKTEMP, name1,
new AstRange(sel1p->fileline(), msb1-lsb1, 0));
AstVar* temp2p = new AstVar(sel2p->fileline(), AstVarType::BLOCKTEMP, name2,

View File

@ -179,7 +179,7 @@ private:
dimreadps.push_front(dimp);
} else {
string bitvarname = (string("__Vdlyvdim")+cvtToStr(dimension)
+"__"+oldvarp->shortName()+"__"+cvtToStr(modVecNum));
+"__"+oldvarp->shortName()+"__v"+cvtToStr(modVecNum));
AstVarScope* bitvscp = createVarSc(varrefp->varScopep(), bitvarname, dimp->width());
AstAssign* bitassignp
= new AstAssign (nodep->fileline(),
@ -197,7 +197,7 @@ private:
if (bitselp->fromp()->castConst()) {// vlsb = constant, can just push constant into where we use it
bitreadp = lsbvaluep;
} else {
string bitvarname = (string("__Vdlyvlsb__")+oldvarp->shortName()+"__"+cvtToStr(modVecNum));
string bitvarname = (string("__Vdlyvlsb__")+oldvarp->shortName()+"__v"+cvtToStr(modVecNum));
AstVarScope* bitvscp = createVarSc(varrefp->varScopep(), bitvarname, lsbvaluep->width());
AstAssign* bitassignp = new AstAssign (nodep->fileline(),
new AstVarRef(nodep->fileline(), bitvscp, true),
@ -212,7 +212,7 @@ private:
if (nodep->rhsp()->castConst()) { // vval = constant, can just push constant into where we use it
valreadp = nodep->rhsp()->unlinkFrBack();
} else {
string valvarname = (string("__Vdlyvval__")+oldvarp->shortName()+"__"+cvtToStr(modVecNum));
string valvarname = (string("__Vdlyvval__")+oldvarp->shortName()+"__v"+cvtToStr(modVecNum));
AstVarScope* valvscp = createVarSc(varrefp->varScopep(), valvarname, nodep->rhsp()->width());
newlhsp = new AstVarRef(nodep->fileline(), valvscp, true);
valreadp = new AstVarRef(nodep->fileline(), valvscp, false);
@ -231,7 +231,7 @@ private:
setvscp = nodep->user5p()->castNode()->castVarScope();
m_statSharedSet++;
} else { // Create new one
string setvarname = (string("__Vdlyvset__")+oldvarp->shortName()+"__"+cvtToStr(modVecNum));
string setvarname = (string("__Vdlyvset__")+oldvarp->shortName()+"__v"+cvtToStr(modVecNum));
setvscp = createVarSc(varrefp->varScopep(), setvarname, 1);
AstAssignPre* setinitp
= new AstAssignPre (nodep->fileline(),

View File

@ -58,7 +58,7 @@ private:
UINFO(6," Deep "<<nodep<<endl);
//if (debug()>=9) nodep->dumpTree(cout,"deep:");
string newvarname = ((string)"__Vdeeptemp__"+cvtToStr(m_modp->varNumGetInc()));
string newvarname = ((string)"__Vdeeptemp"+cvtToStr(m_modp->varNumGetInc()));
AstVar* varp = new AstVar (nodep->fileline(), AstVarType::STMTTEMP, newvarname,
// Width, not widthMin, as we may be in middle of BITSEL expression which
// though it's one bit wide, needs the mask in the upper bits.

View File

@ -152,7 +152,7 @@ const string FileLine::profileFuncname() const {
!= string::npos) {
name.replace(pos, 1, "_");
}
name += "__"+cvtToStr(lineno());
name += "__l"+cvtToStr(lineno());
return name;
}

View File

@ -94,7 +94,7 @@ private:
}
AstVar* getBlockTemp(AstNode* nodep) {
string newvarname = ((string)"__Vtemp__"+cvtToStr(m_modp->varNumGetInc()));
string newvarname = ((string)"__Vtemp"+cvtToStr(m_modp->varNumGetInc()));
AstVar* varp = new AstVar (nodep->fileline(), AstVarType::STMTTEMP, newvarname,
new AstRange(nodep->fileline(), nodep->widthMin()-1, 0));
m_funcp->addInitsp(varp);

View File

@ -469,7 +469,7 @@ private:
// Index into our table
AstVar* indexVarp = new AstVar (nodep->fileline(), AstVarType::BLOCKTEMP,
"__Vtableidx_" + cvtToStr(m_modTables),
"__Vtableidx" + cvtToStr(m_modTables),
new AstRange (nodep->fileline(), m_inWidth-1, 0));
m_modp->addStmtp(indexVarp);
AstVarScope* indexVscp = new AstVarScope (indexVarp->fileline(), m_scopep, indexVarp);
@ -477,7 +477,7 @@ private:
// Change it variable
AstVar* chgVarp = new AstVar (nodep->fileline(), AstVarType::MODULETEMP,
"__Vtablechg_" + cvtToStr(m_modTables),
"__Vtablechg" + cvtToStr(m_modTables),
new AstRange (nodep->fileline(), m_outVarps.size()-1, 0),
new AstRange (nodep->fileline(), VL_MASK_I(m_inWidth), 0));
chgVarp->isConst(true);
@ -519,7 +519,7 @@ private:
AstVar* outvarp = outvscp->varp();
AstVar* tablevarp
= new AstVar (nodep->fileline(), AstVarType::MODULETEMP,
"__Vtable_" + cvtToStr(m_modTables) +"_"+outvarp->name(),
"__Vtable" + cvtToStr(m_modTables) +"_"+outvarp->name(),
new AstRange (nodep->fileline(), outvarp->widthMin()-1, 0),
new AstRange (nodep->fileline(), VL_MASK_I(m_inWidth), 0));
tablevarp->isConst(true);

View File

@ -193,7 +193,7 @@ private:
} else {
// Make a Vxrand variable
// We use the special XTEMP type so it doesn't break pure functions
string newvarname = ((string)"__Vxrand__"
string newvarname = ((string)"__Vxrand"
+cvtToStr(m_modp->varNumGetInc()));
AstVar* newvarp
= new AstVar (nodep->fileline(), AstVarType::XTEMP, newvarname,