diff --git a/Changes b/Changes index 4a59529d9..612ba975d 100644 --- a/Changes +++ b/Changes @@ -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. diff --git a/bin/verilator_profcfunc b/bin/verilator_profcfunc index f4b384b07..347d0236a 100755 --- a/bin/verilator_profcfunc +++ b/bin/verilator_profcfunc @@ -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; diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 542821a77..79c1c4206 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -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]; diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 8cbc1ea00..a0ad6fd0f 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -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, diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 774c02c84..c1f042acc 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -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(), diff --git a/src/V3Depth.cpp b/src/V3Depth.cpp index 5eedd81b5..ff16e96ab 100644 --- a/src/V3Depth.cpp +++ b/src/V3Depth.cpp @@ -58,7 +58,7 @@ private: UINFO(6," Deep "<=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. diff --git a/src/V3Error.cpp b/src/V3Error.cpp index 091c9b4c4..e77b46d19 100644 --- a/src/V3Error.cpp +++ b/src/V3Error.cpp @@ -152,7 +152,7 @@ const string FileLine::profileFuncname() const { != string::npos) { name.replace(pos, 1, "_"); } - name += "__"+cvtToStr(lineno()); + name += "__l"+cvtToStr(lineno()); return name; } diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index 668361210..5898cf087 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -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); diff --git a/src/V3Table.cpp b/src/V3Table.cpp index eaee93a95..0d632a050 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -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); diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index 2025a7211..9537a5da2 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -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,