diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 6b642cfe5..5fb4bcb06 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -50,7 +50,8 @@ public: virtual void accept(AstNVisitor& v, AstNUser* vup=NULL) { v.visit(this,vup); } virtual string name() const { return num().ascii(); } // * = Value virtual const V3Number& num() const { return m_num; } // * = Value - uint32_t asInt() const { return num().asInt(); } + uint32_t asInt() const { return num().asInt(); } // Old, should be removed + uint32_t toUInt() const { return num().toUInt(); } vluint64_t toUQuad() const { return num().toUQuad(); } virtual string emitVerilog() { V3ERROR_NA; return ""; } // Implemented specially virtual string emitC() { V3ERROR_NA; return ""; } @@ -222,7 +223,7 @@ struct AstSel : public AstNodeTriop { AstNode* lsbp() const { return op2p()->castNode(); } // op2 = Msb selection expression AstNode* widthp() const { return op3p()->castNode(); } // op3 = Width uint32_t lsbConst() const { return lsbp()->castConst()->asInt(); } - uint32_t widthConst() const { return widthp()->castConst()->asInt(); } + uint32_t widthConst() const { return widthp()->castConst()->toUInt(); } uint32_t msbConst() const { return lsbConst()+widthConst()-1; } }; diff --git a/src/V3Case.cpp b/src/V3Case.cpp index d288e3de2..e8b9c2413 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -164,10 +164,10 @@ private: } else { V3Number nummask (itemp->fileline(), iconstp->width()); nummask.opBitsNonX(iconstp->num()); - uint32_t mask = nummask.asInt(); + uint32_t mask = nummask.toUInt(); V3Number numval (itemp->fileline(), iconstp->width()); numval.opBitsOne(iconstp->num()); - uint32_t val = numval.asInt(); + uint32_t val = numval.toUInt(); for (uint32_t i=0; i<(1UL<rhsp()->castConst() && nodep->fromp()->castNodeVarRef() && !nodep->fromp()->castNodeVarRef()->lvalue() - && ((int)(nodep->rhsp()->castConst()->asInt()) + && ((int)(nodep->rhsp()->castConst()->toUInt()) >= nodep->fromp()->castNodeVarRef()->varp()->widthWords())); } bool operandSelFull(AstSel* nodep) { @@ -494,7 +494,7 @@ private: &&(con2p->asInt() != con1p->asInt() + sel1p->width())) return false; bool lsbFirstAssign = (con1p->asInt() < con2p->asInt()); // If the user already has nice 32-bit divisions, keep them to aid later subdivision - //if (VL_BITBIT_I(con1p->asInt()) == 0) return false; + //if (VL_BITBIT_I(con1p->toUInt()) == 0) return false; UINFO(4,"replaceAssignMultiSel "<dumpTree(cout, "comb1: "); diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 657365e1e..91e4eb85b 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -440,7 +440,7 @@ public: } virtual void visit(AstReplicate* nodep, AstNUser*) { if (nodep->lhsp()->widthMin() == 1 && !nodep->isWide()) { - if (((int)nodep->rhsp()->castConst()->asInt() + if (((int)nodep->rhsp()->castConst()->toUInt() * nodep->lhsp()->widthMin()) != nodep->widthMin()) nodep->v3fatalSrc("Replicate non-constant or width miscomputed"); puts("VL_REPLICATE_"); @@ -488,7 +488,7 @@ public: if (num<10) ofp()->printf("VL_ULL(%lld)", (long long)num); else ofp()->printf("VL_ULL(0x%llx)", (long long)num); } else { - uint32_t num = nodep->asInt(); + uint32_t num = nodep->toUInt(); if (num<10) puts(cvtToStr(num)); else ofp()->printf("0x%x", num); //Unneeded-Causes %lx format warnings: diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index 0c8441018..0e945c5c1 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -688,7 +688,7 @@ private: UINFO(8," REPLICATE "<rhsp()->castConst(); if (!constp) nodep->v3fatalSrc("Replication value isn't a constant. Checked earlier!"); - uint32_t times = constp->asInt(); + uint32_t times = constp->toUInt(); if (nodep->isQuad() && !lhsp->isQuad()) lhsp = new AstCast(nodep->fileline(), lhsp, nodep); newp = lhsp->cloneTree(true); for (unsigned repnum=1; repnumwidthMin(); AstConst* constp = rhsp->rhsp()->castConst(); if (!constp) rhsp->v3fatalSrc("Replication value isn't a constant. Checked earlier!"); - uint32_t times = constp->asInt(); + uint32_t times = constp->toUInt(); for (int w=0; wwidthWords(); w++) { AstNode* newp; if (lhswidth==1) { diff --git a/src/V3Number_test.cpp b/src/V3Number_test.cpp index 643418c38..32f0c8cc8 100644 --- a/src/V3Number_test.cpp +++ b/src/V3Number_test.cpp @@ -82,7 +82,7 @@ void test(string lhss, string op, string rhss, string exps) { V3Number ok (new FileLine("ck",__LINE__), 1); ok.opCaseEq(expnum,gotnum); - if (ok.asInt()!=1) { + if (ok.toUInt()!=1) { v3fatalSrc("%Error:Test FAILED\n"); } } diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index f72813ad0..1c35d589c 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -276,7 +276,7 @@ private: if (AstVarRef* varrefp = wordp->lhsp()->castVarRef()) { if (wordp->rhsp()->castConst() && varrefp->varp()->isStatementTemp()) { - int word = wordp->rhsp()->castConst()->asInt(); + int word = wordp->rhsp()->castConst()->toUInt(); SubstVarEntry* entryp = getEntryp(varrefp); hit = true; if (m_ops > SUBST_MAX_OPS_SUBST) { @@ -313,7 +313,7 @@ private: && constp) { // Nicely formed lvalues handled in NodeAssign // Other lvalues handled as unknown mess in AstVarRef - int word = constp->asInt(); + int word = constp->toUInt(); UINFO(8," USEword"<substWord (nodep, word)) { diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index d979ad92a..1da01c14e 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -158,8 +158,8 @@ private: || constStopp->width()>32 || constStopp->num().isFourState() || constIncp->width()>32 || constIncp->num().isFourState()) return cantUnroll(nodep, "init/final/increment too large or four state"); - vlsint32_t valInit = constInitp->num().asInt(); // Extract as unsigned, then make signed - vlsint32_t valStop = constStopp->num().asInt(); // Extract as unsigned, then make signed + vlsint32_t valInit = constInitp->num().toUInt(); // Extract as unsigned, then make signed + vlsint32_t valStop = constStopp->num().toUInt(); // Extract as unsigned, then make signed if (lte) valStop++; if (gte) valStop--; vlsint32_t valInc = constIncp->num().toSInt(); if (subtract) valInc = -valInc; diff --git a/src/V3Width.cpp b/src/V3Width.cpp index fb4209b9b..0c8bfb989 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -213,7 +213,7 @@ private: V3Const::constifyParam(nodep->rhsp()); AstConst* constp = nodep->rhsp()->castConst(); if (!constp) { nodep->v3error("Replication value isn't a constant."); return; } - uint32_t times = constp->asInt(); + uint32_t times = constp->toUInt(); if (times==0) { nodep->v3error("Replication value is 0."); times=1; } nodep->width((nodep->lhsp()->width() * times), (nodep->lhsp()->widthMin() * times));