diff --git a/Changes b/Changes index 905e2b488..beda0e6c8 100644 --- a/Changes +++ b/Changes @@ -9,6 +9,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix GCC version runtime changes, bug651. [Jeremy Bennett] +**** Fix packed array select internal error, bug652. [Krzysztof Jankowski] + * Verilator 3.847 2013-05-11 diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 7cd2e4086..3f794bd0a 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -244,16 +244,16 @@ public: refDTypep(NULL); setOp2p(rangep); dtypep(NULL); // V3Width will resolve - // For backward compatibility AstNodeArrayDType and others inherit width and signing from the subDType/base type - widthFromSub(subDTypep()); + int width = subDTypep()->width() * rangep->elementsConst(); + widthForce(width,width); } AstPackArrayDType(FileLine* fl, AstNodeDType* dtp, AstRange* rangep) : AstNodeArrayDType(fl) { refDTypep(dtp); setOp2p(rangep); dtypep(this); - // For backward compatibility AstNodeArrayDType and others inherit width and signing from the subDType/base type - widthFromSub(subDTypep()); + int width = subDTypep()->width() * rangep->elementsConst(); + widthForce(width,width); } ASTNODE_NODE_FUNCS(PackArrayDType, PACKARRAYDTYPE) }; diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index 5b7019b58..3626aa464 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -307,13 +307,15 @@ private: newp->dtypeFrom(adtypep); } else { // Need a slice data type, which is an array of the extracted type, but with (presumably) different size + VNumRange newRange (msb, lsb, fromRange.littleEndian()); AstNodeDType* vardtypep = new AstPackArrayDType(nodep->fileline(), adtypep->subDTypep(), // Need to strip off array reference - new AstRange(nodep->fileline(), fromRange)); + new AstRange(nodep->fileline(), newRange)); v3Global.rootp()->typeTablep()->addTypesp(vardtypep); newp->dtypeFrom(vardtypep); } - if (debug()>=9) newp->dumpTree(cout,"--EXTBTn: "); + //if (debug()>=9) newp->dumpTree(cout,"--EXTBTn: "); + if (newp->widthMin()!=(int)newp->widthConst()) nodep->v3fatalSrc("Width mismatch"); nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL; } else if (ddtypep->castBasicDType()) {