From ae1ab8aaaafd829e46b2a653347952440664c9e1 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 12 Jan 2013 15:34:09 -0500 Subject: [PATCH] Fix array slice selection of msb==lsb. --- src/V3WidthSel.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index 39a78923c..601f49853 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -260,14 +260,11 @@ private: AstNodeDType* ddtypep = dtypeForExtractp(nodep, basefromp, dimension, msb!=lsb); if (AstArrayDType* adtypep = ddtypep->castArrayDType()) { if (adtypep) {} - if (msb!=lsb) { - AstArraySel* newp = new AstArraySel (nodep->fileline(), fromp, lsbp); - newp->start(lsb); - newp->length((msb - lsb) + 1); - nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL; - } else { - nodep->v3error("Illegal bit select; can't bit extract from arrayed dimension: "<prettyName()); - } + // Slice extraction + AstArraySel* newp = new AstArraySel (nodep->fileline(), fromp, lsbp); + newp->start(lsb); + newp->length((msb - lsb) + 1); + nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL; } else if (AstBasicDType* adtypep = ddtypep->castBasicDType()) { if (adtypep) {} // Unused if (bfdtypep->basicp()->littleEndian()) { @@ -367,16 +364,16 @@ private: } UINFO(6," new "<replaceWith(newp); pushDeletep(nodep); nodep=NULL; - // delete whataver we didn't use in reconstruction - if (!fromp->backp()) pushDeletep(fromp); fromp=NULL; - if (!rhsp->backp()) pushDeletep(rhsp); rhsp=NULL; - if (!widthp->backp()) pushDeletep(widthp); widthp=NULL; } else { // NULL=bad extract, or unknown node type nodep->v3error("Illegal +: or -: select; variable already selected, or bad dimension"); // How to recover? We'll strip a dimension. nodep->replaceWith(fromp); pushDeletep(nodep); nodep=NULL; } + // delete whataver we didn't use in reconstruction + if (!fromp->backp()) pushDeletep(fromp); fromp=NULL; + if (!rhsp->backp()) pushDeletep(rhsp); rhsp=NULL; + if (!widthp->backp()) pushDeletep(widthp); widthp=NULL; } virtual void visit(AstSelPlus* nodep, AstNUser*) { replaceSelPlusMinus(nodep);