From 71265a8ec9d82f861b3824fe77f8f8e5345a3b83 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 4 Aug 2019 12:39:35 -0400 Subject: [PATCH] Internals: Rename unsized functions. No functional change. --- src/V3Ast.cpp | 4 ++-- src/V3Ast.h | 8 +++++--- src/V3AstNodes.h | 33 +++++++++++++++------------------ src/V3Const.cpp | 7 +++---- src/V3Expand.cpp | 9 ++++++--- src/V3Width.cpp | 42 ++++++++++++++++++++---------------------- 6 files changed, 51 insertions(+), 52 deletions(-) diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 61d45b7e8..d9fd182de 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -1150,7 +1150,7 @@ void AstNode::dtypeChgWidth(int width, int widthMin) { void AstNode::dtypeChgWidthSigned(int width, int widthMin, AstNumeric numeric) { if (!dtypep()) { // We allow dtypep() to be null, as before/during widthing dtypes are not resolved - dtypeSetLogicSized(width, widthMin, numeric); + dtypeSetLogicUnsized(width, widthMin, numeric); } else { if (width==dtypep()->width() && widthMin==dtypep()->widthMin() @@ -1160,7 +1160,7 @@ void AstNode::dtypeChgWidthSigned(int width, int widthMin, AstNumeric numeric) { // work OK but this assumption may break in the future. // Note we can't just clone and do a widthForce, as if it's a BasicDType // the msb() indications etc will be incorrect. - dtypeSetLogicSized(width, widthMin, numeric); + dtypeSetLogicUnsized(width, widthMin, numeric); } } diff --git a/src/V3Ast.h b/src/V3Ast.h index caf7107bc..b2820535f 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1396,10 +1396,12 @@ public: void dtypeChgSigned(bool flag=true); void dtypeChgWidth(int width, int widthMin); void dtypeChgWidthSigned(int width, int widthMin, AstNumeric numeric); - void dtypeSetBitSized(int width, int widthMin, AstNumeric numeric) { + void dtypeSetBitUnsized(int width, int widthMin, AstNumeric numeric) { dtypep(findBitDType(width, widthMin, numeric)); } - void dtypeSetLogicSized(int width, int widthMin, AstNumeric numeric) { + void dtypeSetLogicUnsized(int width, int widthMin, AstNumeric numeric) { dtypep(findLogicDType(width, widthMin, numeric)); } + void dtypeSetLogicSized(int width, AstNumeric numeric) { + dtypep(findLogicDType(width, width, numeric)); } // Since sized, widthMin is width void dtypeSetLogicBool() { dtypep(findLogicBoolDType()); } void dtypeSetDouble() { dtypep(findDoubleDType()); } void dtypeSetString() { dtypep(findStringDType()); } @@ -2055,7 +2057,7 @@ class AstNodeStream : public AstNodeBiop { public: AstNodeStream(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) { if (lhsp->dtypep()) { - dtypeSetLogicSized(lhsp->dtypep()->width(), lhsp->dtypep()->width(), AstNumeric::UNSIGNED); + dtypeSetLogicSized(lhsp->dtypep()->width(), AstNumeric::UNSIGNED); } } ASTNODE_BASE_FUNCS(NodeStream) diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 7128a467f..24c86e195 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -55,8 +55,8 @@ private: } else if (m_num.isString()) { dtypeSetString(); } else { - dtypeSetLogicSized(m_num.width(), (m_num.sized() ? 0 : m_num.widthMin()), - AstNumeric::fromBool(m_num.isSigned())); + dtypeSetLogicUnsized(m_num.width(), (m_num.sized() ? 0 : m_num.widthMin()), + AstNumeric::fromBool(m_num.isSigned())); } } public: @@ -86,21 +86,21 @@ public: AstConst(FileLine* fl, uint32_t num) : AstNodeMath(fl) , m_num(this, 32, num) { - dtypeSetLogicSized(m_num.width(), 0, AstNumeric::UNSIGNED); + dtypeSetLogicUnsized(m_num.width(), 0, AstNumeric::UNSIGNED); } class Unsized32 {}; // for creator type-overload selection AstConst(FileLine* fl, Unsized32, uint32_t num) // Unsized 32-bit integer of specified value : AstNodeMath(fl) , m_num(this, 32, num) { m_num.width(32, false); - dtypeSetLogicSized(32, m_num.widthMin(), AstNumeric::UNSIGNED); + dtypeSetLogicUnsized(32, m_num.widthMin(), AstNumeric::UNSIGNED); } class Signed32 {}; // for creator type-overload selection AstConst(FileLine* fl, Signed32, int32_t num) // Signed 32-bit integer of specified value : AstNodeMath(fl) , m_num(this, 32, num) { m_num.width(32, 32); - dtypeSetLogicSized(32, m_num.widthMin(), AstNumeric::SIGNED); + dtypeSetLogicUnsized(32, m_num.widthMin(), AstNumeric::SIGNED); } class RealDouble {}; // for creator type-overload selection AstConst(FileLine* fl, RealDouble, double num) @@ -1000,7 +1000,6 @@ public: m_declElWidth = 1; if (VN_IS(widthp, Const)) { dtypeSetLogicSized(VN_CAST(widthp, Const)->toUInt(), - VN_CAST(widthp, Const)->toUInt(), AstNumeric::UNSIGNED); } } @@ -1008,7 +1007,7 @@ public: : AstNodeTriop(fl, fromp, new AstConst(fl, lsb), new AstConst(fl, bitwidth)) { m_declElWidth = 1; - dtypeSetLogicSized(bitwidth, bitwidth, AstNumeric::UNSIGNED); + dtypeSetLogicSized(bitwidth, AstNumeric::UNSIGNED); } ASTNODE_NODE_FUNCS(Sel) virtual void dump(std::ostream& str); @@ -1218,7 +1217,7 @@ public: , m_name(name), m_origName(name) { init(); combineType(type); - dtypeSetLogicSized(wantwidth, wantwidth, AstNumeric::UNSIGNED); + dtypeSetLogicSized(wantwidth, AstNumeric::UNSIGNED); m_declKwd = AstBasicDTypeKwd::LOGIC; } AstVar(FileLine* fl, AstVarType type, const string& name, VFlagBitPacked, int wantwidth) @@ -1226,7 +1225,7 @@ public: , m_name(name), m_origName(name) { init(); combineType(type); - dtypeSetLogicSized(wantwidth, wantwidth, AstNumeric::UNSIGNED); + dtypeSetLogicSized(wantwidth, AstNumeric::UNSIGNED); m_declKwd = AstBasicDTypeKwd::BIT; } AstVar(FileLine* fl, AstVarType type, const string& name, AstVar* examplep) @@ -3837,7 +3836,7 @@ class AstExtend : public AstNodeUniop { public: AstExtend(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {} AstExtend(FileLine* fl, AstNode* lhsp, int width) : AstNodeUniop(fl, lhsp) { - dtypeSetLogicSized(width, width, AstNumeric::UNSIGNED); } + dtypeSetLogicSized(width, AstNumeric::UNSIGNED); } ASTNODE_NODE_FUNCS(Extend) virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opAssign(lhs); } virtual string emitVerilog() { return "%l"; } @@ -3853,7 +3852,7 @@ public: AstExtendS(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {} AstExtendS(FileLine* fl, AstNode* lhsp, int width) : AstNodeUniop(fl, lhsp) { // Important that widthMin be correct, as opExtend requires it after V3Expand - dtypeSetLogicSized(width, width, AstNumeric::UNSIGNED); } + dtypeSetLogicSized(width, AstNumeric::UNSIGNED); } ASTNODE_NODE_FUNCS(ExtendS) virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opExtendS(lhs, lhsp()->widthMinV()); @@ -4091,7 +4090,7 @@ public: m_size = setwidth; if (setwidth) { if (minwidth==-1) minwidth = setwidth; - dtypeSetLogicSized(setwidth, minwidth, AstNumeric::UNSIGNED); + dtypeSetLogicUnsized(setwidth, minwidth, AstNumeric::UNSIGNED); } } AstCCast(FileLine* fl, AstNode* lhsp, AstNode* typeFromp) : AstNodeUniop(fl, lhsp) { @@ -4859,7 +4858,7 @@ class AstShiftL : public AstNodeBiop { public: AstShiftL(FileLine* fl, AstNode* lhsp, AstNode* rhsp, int setwidth=0) : AstNodeBiop(fl, lhsp, rhsp) { - if (setwidth) { dtypeSetLogicSized(setwidth, setwidth, AstNumeric::UNSIGNED); } + if (setwidth) { dtypeSetLogicSized(setwidth, AstNumeric::UNSIGNED); } } ASTNODE_NODE_FUNCS(ShiftL) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) { return new AstShiftL(this->fileline(), lhsp, rhsp); } @@ -4877,7 +4876,7 @@ class AstShiftR : public AstNodeBiop { public: AstShiftR(FileLine* fl, AstNode* lhsp, AstNode* rhsp, int setwidth=0) : AstNodeBiop(fl, lhsp, rhsp) { - if (setwidth) { dtypeSetLogicSized(setwidth, setwidth, AstNumeric::UNSIGNED); } + if (setwidth) { dtypeSetLogicSized(setwidth, AstNumeric::UNSIGNED); } } ASTNODE_NODE_FUNCS(ShiftR) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) { return new AstShiftR(this->fileline(), lhsp, rhsp); } @@ -4899,7 +4898,7 @@ public: AstShiftRS(FileLine* fl, AstNode* lhsp, AstNode* rhsp, int setwidth=0) : AstNodeBiop(fl, lhsp, rhsp) { // Important that widthMin be correct, as opExtend requires it after V3Expand - if (setwidth) { dtypeSetLogicSized(setwidth, setwidth, AstNumeric::SIGNED); } + if (setwidth) { dtypeSetLogicSized(setwidth, AstNumeric::SIGNED); } } ASTNODE_NODE_FUNCS(ShiftRS) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) { return new AstShiftRS(this->fileline(), lhsp, rhsp); } @@ -5276,7 +5275,6 @@ public: AstConcat(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) { if (lhsp->dtypep() && rhsp->dtypep()) { dtypeSetLogicSized(lhsp->dtypep()->width()+rhsp->dtypep()->width(), - lhsp->dtypep()->width()+rhsp->dtypep()->width(), AstNumeric::UNSIGNED); } } @@ -5319,7 +5317,6 @@ private: if (lhsp()) { if (const AstConst* constp = VN_CAST(rhsp(), Const)) { dtypeSetLogicSized(lhsp()->width()*constp->toUInt(), - lhsp()->width()*constp->toUInt(), AstNumeric::UNSIGNED); } } @@ -5963,7 +5960,7 @@ public: AstCMath(FileLine* fl, const string& textStmt, int setwidth, bool cleanOut=true) : AstNodeMath(fl), m_cleanOut(cleanOut) { addNOp1p(new AstText(fl, textStmt, true)); - if (setwidth) { dtypeSetLogicSized(setwidth, setwidth, AstNumeric::UNSIGNED); } + if (setwidth) { dtypeSetLogicSized(setwidth, AstNumeric::UNSIGNED); } } ASTNODE_NODE_FUNCS(CMath) virtual bool isGateOptimizable() const { return false; } diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 31176c822..d65e02996 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -1150,9 +1150,8 @@ private: AstNode* srcp = nodep->rhsp()->unlinkFrBack(); // Connect the rhs to the stream operator and update its width VN_CAST(streamp, StreamL)->lhsp(srcp); - streamp->dtypeSetLogicSized((srcp->width()), - (srcp->widthMin()), - AstNumeric::UNSIGNED); + streamp->dtypeSetLogicUnsized(srcp->width(), srcp->widthMin(), + AstNumeric::UNSIGNED); // Shrink the RHS if necessary if (sWidth > dWidth) { streamp = new AstSel(streamp->fileline(), streamp, sWidth-dWidth, dWidth); @@ -1214,7 +1213,7 @@ private: new AstConst(nodep->fileline(), val), fromp); // widthMin no longer applicable if different C-expanded width - newp->dtypeSetLogicSized(nodep->width(), nodep->width(), AstNumeric::UNSIGNED); + newp->dtypeSetLogicSized(nodep->width(), AstNumeric::UNSIGNED); nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep); if (debug()>=9) newp->dumpTree(cout, " _new: "); diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index 0206c3b72..300abb673 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -120,13 +120,15 @@ private: new AstConst(nodep->fileline(), word)); } else if (nodep->isQuad() && word==0) { AstNode* quadfromp = nodep->cloneTree(true); - quadfromp->dtypeSetBitSized(VL_QUADSIZE, quadfromp->widthMin(), AstNumeric::UNSIGNED); + quadfromp->dtypeSetBitUnsized(VL_QUADSIZE, quadfromp->widthMin(), + AstNumeric::UNSIGNED); return new AstCCast(nodep->fileline(), quadfromp, VL_WORDSIZE); } else if (nodep->isQuad() && word==1) { AstNode* quadfromp = nodep->cloneTree(true); - quadfromp->dtypeSetBitSized(VL_QUADSIZE, quadfromp->widthMin(), AstNumeric::UNSIGNED); + quadfromp->dtypeSetBitUnsized(VL_QUADSIZE, quadfromp->widthMin(), + AstNumeric::UNSIGNED); return new AstCCast(nodep->fileline(), new AstShiftR(nodep->fileline(), quadfromp, @@ -760,7 +762,8 @@ private: AstNode* newp; if (lhswidth==1) { newp = new AstNegate(nodep->fileline(), lhsp->cloneTree(true)); - newp->dtypeSetLogicSized(VL_WORDSIZE, VL_WORDSIZE, AstNumeric::UNSIGNED); // Replicate always unsigned + newp->dtypeSetLogicSized(VL_WORDSIZE, + AstNumeric::UNSIGNED); // Replicate always unsigned } else { newp = newAstWordSelClone(lhsp, w); for (unsigned repnum=1; repnumexpr1p()->width(), nodep->expr2p()->width()); int mwidth = std::max(nodep->expr1p()->widthMin(), nodep->expr2p()->widthMin()); bool issigned = nodep->expr1p()->isSigned() && nodep->expr2p()->isSigned(); - nodep->dtypeSetLogicSized(width, mwidth, AstNumeric::fromBool(issigned)); + nodep->dtypeSetLogicUnsized(width, mwidth, AstNumeric::fromBool(issigned)); } } if (m_vup->final()) { @@ -390,9 +390,9 @@ private: if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH); iterateCheckSizedSelf(nodep, "RHS", nodep->rhsp(), SELF, BOTH); - nodep->dtypeSetLogicSized(nodep->lhsp()->width() + nodep->rhsp()->width(), - nodep->lhsp()->widthMin() + nodep->rhsp()->widthMin(), - AstNumeric::UNSIGNED); + nodep->dtypeSetLogicUnsized(nodep->lhsp()->width() + nodep->rhsp()->width(), + nodep->lhsp()->widthMin() + nodep->rhsp()->widthMin(), + AstNumeric::UNSIGNED); // Cleanup zero width Verilog2001 {x,{0{foo}}} now, // otherwise having width(0) will cause later assertions to fire if (AstReplicate* repp = VN_CAST(nodep->lhsp(), Replicate)) { @@ -464,9 +464,9 @@ private: pushDeletep(nodep); VL_DANGLING(nodep); return; } else { - nodep->dtypeSetLogicSized((nodep->lhsp()->width() * times), - (nodep->lhsp()->widthMin() * times), - AstNumeric::UNSIGNED); + nodep->dtypeSetLogicUnsized((nodep->lhsp()->width() * times), + (nodep->lhsp()->widthMin() * times), + AstNumeric::UNSIGNED); } } if (m_vup->final()) { @@ -515,9 +515,9 @@ private: uint32_t sliceSize = constp->toUInt(); if (!sliceSize) { nodep->v3error("Slice size cannot be zero."); return; } } - nodep->dtypeSetLogicSized((nodep->lhsp()->width()), - (nodep->lhsp()->widthMin()), - AstNumeric::UNSIGNED); + nodep->dtypeSetLogicUnsized(nodep->lhsp()->width(), + nodep->lhsp()->widthMin(), + AstNumeric::UNSIGNED); } if (m_vup->final()) { if (!nodep->dtypep()->widthSized()) { @@ -587,7 +587,7 @@ private: nodep->v3error("Unsupported: MSB < LSB of bit extract: " <msbConst()<<"<"<lsbConst()); width = (nodep->lsbConst() - nodep->msbConst() + 1); - nodep->dtypeSetLogicSized(width, width, AstNumeric::UNSIGNED); + nodep->dtypeSetLogicSized(width, AstNumeric::UNSIGNED); nodep->widthp()->replaceWith(new AstConst(nodep->widthp()->fileline(), width)); nodep->lsbp()->replaceWith(new AstConst(nodep->lsbp()->fileline(), 0)); @@ -856,7 +856,7 @@ private: virtual void visit(AstUCFunc* nodep) { // Give it the size the user wants. if (m_vup && m_vup->prelim()) { - nodep->dtypeSetLogicSized(32, 1, AstNumeric::UNSIGNED); // We don't care + nodep->dtypeSetLogicUnsized(32, 1, AstNumeric::UNSIGNED); // We don't care // All arguments seek their natural sizes userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); } @@ -939,7 +939,7 @@ private: iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH); // If it's a 32 bit number, we need a 6 bit number as we need to return '32'. int selwidth = V3Number::log2b(nodep->lhsp()->width())+1; - nodep->dtypeSetLogicSized(selwidth, selwidth, AstNumeric::UNSIGNED); // Spec doesn't indicate if an integer + nodep->dtypeSetLogicSized(selwidth, AstNumeric::UNSIGNED); // Spec doesn't indicate if an integer } } virtual void visit(AstCvtPackString* nodep) { @@ -1000,7 +1000,7 @@ private: } default: { // Everything else resolved earlier - nodep->dtypeSetLogicSized(32, 1, AstNumeric::UNSIGNED); // Approximation, unsized 32 + nodep->dtypeSetLogicUnsized(32, 1, AstNumeric::UNSIGNED); // Approximation, unsized 32 UINFO(1,"Missing ATTR type case node: "<v3fatalSrc("Missing ATTR type case"); break; @@ -1308,7 +1308,7 @@ private: } } else if (bdtypep && bdtypep->implicit()) { // Implicits get converted to size 1 - nodep->dtypeSetLogicSized(1, 1, bdtypep->numeric()); VL_DANGLING(bdtypep); + nodep->dtypeSetLogicSized(1, bdtypep->numeric()); VL_DANGLING(bdtypep); } if (nodep->valuep() && !didchk) { //if (debug()) nodep->dumpTree(cout, " final: "); @@ -1915,9 +1915,9 @@ private: else { AstConcat* concatp = new AstConcat(patp->fileline(), newp, valuep); newp = concatp; - newp->dtypeSetLogicSized(concatp->lhsp()->width()+concatp->rhsp()->width(), - concatp->lhsp()->width()+concatp->rhsp()->width(), - nodep->dtypep()->numeric()); + newp->dtypeSetLogicSized( + concatp->lhsp()->width() + concatp->rhsp()->width(), + nodep->dtypep()->numeric()); } } if (newpatp) { pushDeletep(newpatp); VL_DANGLING(newpatp); } @@ -1984,7 +1984,6 @@ private: AstConcat* concatp = new AstConcat(patp->fileline(), newp, valuep); newp = concatp; newp->dtypeSetLogicSized( - concatp->lhsp()->width()+concatp->rhsp()->width(), concatp->lhsp()->width()+concatp->rhsp()->width(), nodep->dtypep()->numeric()); } @@ -2045,7 +2044,6 @@ private: AstConcat* concatp = new AstConcat(patp->fileline(), newp, valuep); newp = concatp; newp->dtypeSetLogicSized( - concatp->lhsp()->width()+concatp->rhsp()->width(), concatp->lhsp()->width()+concatp->rhsp()->width(), nodep->dtypep()->numeric()); } @@ -2311,7 +2309,7 @@ private: virtual void visit(AstFEof* nodep) { if (m_vup->prelim()) { iterateCheckFileDesc(nodep, nodep->filep(), BOTH); - nodep->dtypeSetLogicSized(32, 1, AstNumeric::SIGNED); // Spec says integer return + nodep->dtypeSetLogicUnsized(32, 1, AstNumeric::SIGNED); // Spec says integer return } } virtual void visit(AstFFlush* nodep) { @@ -2323,7 +2321,7 @@ private: virtual void visit(AstFGetC* nodep) { if (m_vup->prelim()) { iterateCheckFileDesc(nodep, nodep->filep(), BOTH); - nodep->dtypeSetLogicSized(32, 8, AstNumeric::SIGNED); // Spec says integer return + nodep->dtypeSetLogicUnsized(32, 8, AstNumeric::SIGNED); // Spec says integer return } } virtual void visit(AstFGetS* nodep) {