mirror of
https://github.com/verilator/verilator.git
synced 2025-01-05 22:27:35 +00:00
Make V3Number::setMask to refactor some code
git-svn-id: file://localhost/svn/verilator/trunk/verilator@900 77ca24e4-aefa-0310-84f0-b9a241c72d87
This commit is contained in:
parent
78997ee13c
commit
e7280d7237
@ -104,11 +104,8 @@ private:
|
||||
nodep->unlinkFrBack(&relinkHandle);
|
||||
//
|
||||
computeCppWidth(nodep);
|
||||
V3Number zero (nodep->fileline(), nodep->widthMin(),0);
|
||||
V3Number masksmall (nodep->fileline(), nodep->widthMin());
|
||||
masksmall.opNot(zero);
|
||||
V3Number mask (nodep->fileline(), cppWidth(nodep));
|
||||
mask.opAssign(masksmall);
|
||||
mask.setMask(nodep->widthMin());
|
||||
AstNode* cleanp = new AstAnd (nodep->fileline(),
|
||||
new AstConst (nodep->fileline(), mask),
|
||||
nodep);
|
||||
|
@ -246,9 +246,8 @@ private:
|
||||
replaceNum(nodep, 0); nodep=NULL;
|
||||
}
|
||||
void replaceAllOnes (AstNode* nodep) {
|
||||
V3Number num (nodep->fileline(), nodep->width(), 0);
|
||||
V3Number ones (nodep->fileline(), nodep->width());
|
||||
ones.opNot(num);
|
||||
V3Number ones (nodep->fileline(), nodep->width(), 0);
|
||||
ones.setMask(nodep->width());
|
||||
replaceNum(nodep, ones); nodep=NULL;
|
||||
}
|
||||
void replaceConst(AstNodeUniop* nodep) {
|
||||
@ -388,7 +387,7 @@ private:
|
||||
AstNode* newp;
|
||||
V3Number mask1 (nodep->fileline(), nodep->width());
|
||||
V3Number ones (nodep->fileline(), nodep->width());
|
||||
ones.opNot(mask1);
|
||||
ones.setMask(nodep->width());
|
||||
if (shift1<0) {
|
||||
mask1.opShiftR(ones,V3Number(nodep->fileline(),VL_WORDSIZE,-shift1));
|
||||
} else {
|
||||
|
@ -65,11 +65,8 @@ private:
|
||||
if (nodep->isWide()) {
|
||||
return V3Number (nodep->fileline(), VL_WORDSIZE, VL_MASK_I(nodep->widthMin()));
|
||||
} else {
|
||||
V3Number zero (nodep->fileline(), nodep->widthMin(),0);
|
||||
V3Number masksmall (nodep->fileline(), nodep->widthMin());
|
||||
masksmall.opNot(zero);
|
||||
V3Number mask (nodep->fileline(), longOrQuadWidth(nodep));
|
||||
mask.opAssign(masksmall);
|
||||
mask.setMask(nodep->widthMin());
|
||||
return mask;
|
||||
}
|
||||
}
|
||||
|
@ -296,6 +296,11 @@ V3Number& V3Number::setAllBitsZ() {
|
||||
for (int i=0; i<words(); i++) { m_value[i]=0; m_valueX[i] = ~0; }
|
||||
return *this;
|
||||
}
|
||||
V3Number& V3Number::setMask(int nbits) {
|
||||
setZero();
|
||||
for (int bit=0; bit<nbits; bit++) { setBit(bit,1); }
|
||||
return *this;
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
// ACCESSORS
|
||||
|
@ -108,6 +108,7 @@ public:
|
||||
// SETTERS
|
||||
V3Number& setAllBitsX();
|
||||
V3Number& setAllBitsZ();
|
||||
V3Number& setMask(int nbits); // IE if nbits=1, then 0b1, if 2->0b11, if 3->0b111 etc
|
||||
|
||||
// ACCESSORS
|
||||
string ascii(bool prefixed=true, bool cleanVerilog=false) const;
|
||||
|
Loading…
Reference in New Issue
Block a user