From da13ba6c6729698728b209d5d3a098475d823f4c Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 30 Nov 2011 07:51:05 -0500 Subject: [PATCH] Internals: Use elementsConst for AstRange width. --- src/V3AstNodes.h | 3 +-- src/V3Inst.cpp | 2 +- src/V3Width.cpp | 7 +++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 05045d971..6f698ac62 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -130,7 +130,6 @@ public: :AstNode(fl) { m_littleEndian = false; setOp2p(new AstConst(fl,msb)); setOp3p(new AstConst(fl,lsb)); - width(msb-lsb+1,msb-lsb+1); } ASTNODE_NODE_FUNCS(Range, RANGE) AstNode* msbp() const { return op2p()->castNode(); } // op2 = Msb expression @@ -271,7 +270,7 @@ private: if (keyword().width() > 1 && !isOpaque()) rangep = new AstRange(fileline(), keyword().width()-1, 0); width(keyword().width(), keyword().width()); } else { - widthFrom(rangep); // Maybe unknown if parameters underneath it + width(rangep->elementsConst(), rangep->elementsConst()); // Maybe unknown if parameters underneath it } setNOp1p(rangep); } diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index c40f442cb..e3702b5ea 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -199,7 +199,7 @@ private: int expwidth = nodep->exprp()->width(); if (expwidth == pinwidth) { // NOP: Arrayed instants: widths match so connect to each instance - } else if (expwidth == pinwidth*m_cellRangep->width()) { + } else if (expwidth == pinwidth*m_cellRangep->elementsConst()) { // Arrayed instants: one bit for each of the instants (each assign is 1 pinwidth wide) AstNode* exprp = nodep->exprp()->unlinkFrBack(); bool inputPin = nodep->modVarp()->isInput(); diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 2bd7e06e5..3a10feea8 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -356,8 +356,7 @@ private: checkCvtUS(nodep->lsbp()); int width = nodep->elementsConst(); if (width > (1<<28)) nodep->v3error("Width of bit range is huge; vector of over 1billion bits: 0x"<numeric(AstNumeric::UNSIGNED); - nodep->width(width,width); + // Note width() not set on range; use elementsConst() if (nodep->littleEndian()) { nodep->v3warn(LITENDIAN,"Little bit endian vector: MSB < LSB of bit range: "<lsbConst()<<":"<msbConst()); } @@ -620,7 +619,7 @@ private: virtual void visit(AstBasicDType* nodep, AstNUser* vup) { if (nodep->rangep()) { nodep->rangep()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p()); - nodep->widthFrom(nodep->rangep()); + nodep->width(nodep->rangep()->elementsConst(), nodep->rangep()->elementsConst()); } // else width in node is correct; it was set based on keyword().width() // at construction time. Ditto signed, so "unsigned byte" etc works right. @@ -1102,7 +1101,7 @@ private: bool inputPin = nodep->modVarp()->isInput(); int awidth; if (m_cellRangep) { - int numInsts = m_cellRangep->width(); + int numInsts = m_cellRangep->elementsConst(); if (expwidth == pinwidth) { awidth = pinwidth; // Arrayed instants: widths match so connect to each instance } else if (expwidth == pinwidth*numInsts) {