Fix packed array select internal error, bug652.

This commit is contained in:
Wilson Snyder 2013-05-24 21:14:42 -04:00
parent 3b3a7f7354
commit 48d177a9d0
3 changed files with 10 additions and 6 deletions

View File

@ -9,6 +9,8 @@ indicates the contributor was also the author of the fix; Thanks!
**** Fix GCC version runtime changes, bug651. [Jeremy Bennett] **** Fix GCC version runtime changes, bug651. [Jeremy Bennett]
**** Fix packed array select internal error, bug652. [Krzysztof Jankowski]
* Verilator 3.847 2013-05-11 * Verilator 3.847 2013-05-11

View File

@ -244,16 +244,16 @@ public:
refDTypep(NULL); refDTypep(NULL);
setOp2p(rangep); setOp2p(rangep);
dtypep(NULL); // V3Width will resolve dtypep(NULL); // V3Width will resolve
// For backward compatibility AstNodeArrayDType and others inherit width and signing from the subDType/base type int width = subDTypep()->width() * rangep->elementsConst();
widthFromSub(subDTypep()); widthForce(width,width);
} }
AstPackArrayDType(FileLine* fl, AstNodeDType* dtp, AstRange* rangep) AstPackArrayDType(FileLine* fl, AstNodeDType* dtp, AstRange* rangep)
: AstNodeArrayDType(fl) { : AstNodeArrayDType(fl) {
refDTypep(dtp); refDTypep(dtp);
setOp2p(rangep); setOp2p(rangep);
dtypep(this); dtypep(this);
// For backward compatibility AstNodeArrayDType and others inherit width and signing from the subDType/base type int width = subDTypep()->width() * rangep->elementsConst();
widthFromSub(subDTypep()); widthForce(width,width);
} }
ASTNODE_NODE_FUNCS(PackArrayDType, PACKARRAYDTYPE) ASTNODE_NODE_FUNCS(PackArrayDType, PACKARRAYDTYPE)
}; };

View File

@ -307,13 +307,15 @@ private:
newp->dtypeFrom(adtypep); newp->dtypeFrom(adtypep);
} else { } else {
// Need a slice data type, which is an array of the extracted type, but with (presumably) different size // 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(), AstNodeDType* vardtypep = new AstPackArrayDType(nodep->fileline(),
adtypep->subDTypep(), // Need to strip off array reference adtypep->subDTypep(), // Need to strip off array reference
new AstRange(nodep->fileline(), fromRange)); new AstRange(nodep->fileline(), newRange));
v3Global.rootp()->typeTablep()->addTypesp(vardtypep); v3Global.rootp()->typeTablep()->addTypesp(vardtypep);
newp->dtypeFrom(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; nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL;
} }
else if (ddtypep->castBasicDType()) { else if (ddtypep->castBasicDType()) {