More renames of asInt/toUInt where deemed correct

This commit is contained in:
Wilson Snyder 2008-09-04 11:03:46 -04:00
parent 99cf981c2f
commit ef69f36403
9 changed files with 17 additions and 16 deletions

View File

@ -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; }
};

View File

@ -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<<m_caseWidth); i++) {
if ((i & mask) == val) {
if (!m_valueItem[i]) {

View File

@ -180,7 +180,7 @@ private:
return (nodep->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 "<<nodep<<endl);
UINFO(4," && "<<nextp<<endl);
//nodep->dumpTree(cout, "comb1: ");

View File

@ -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:

View File

@ -688,7 +688,7 @@ private:
UINFO(8," REPLICATE "<<nodep<<endl);
AstConst* constp = nodep->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; repnum<times; repnum++) {
@ -713,7 +713,7 @@ private:
int lhswidth = lhsp->widthMin();
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; w<rhsp->widthWords(); w++) {
AstNode* newp;
if (lhswidth==1) {

View File

@ -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");
}
}

View File

@ -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"<<word<<" "<<varrefp<<endl);
SubstVarEntry* entryp = getEntryp(varrefp);
if (AstNode* substp = entryp->substWord (nodep, word)) {

View File

@ -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;

View File

@ -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));