Internals: Rename left/right to match IEEE. No functional change.

This commit is contained in:
Wilson Snyder 2012-03-19 20:25:35 -04:00
parent b4e908d04d
commit 0a832e90bd
3 changed files with 19 additions and 19 deletions

View File

@ -139,8 +139,8 @@ public:
ASTNODE_NODE_FUNCS(Range, RANGE) ASTNODE_NODE_FUNCS(Range, RANGE)
AstNode* msbp() const { return op2p()->castNode(); } // op2 = Msb expression AstNode* msbp() const { return op2p()->castNode(); } // op2 = Msb expression
AstNode* lsbp() const { return op3p()->castNode(); } // op3 = Lsb expression AstNode* lsbp() const { return op3p()->castNode(); } // op3 = Lsb expression
AstNode* msbEndianedp() const { return littleEndian()?lsbp():msbp(); } // How to show a declaration AstNode* leftp() const { return littleEndian()?lsbp():msbp(); } // How to show a declaration
AstNode* lsbEndianedp() const { return littleEndian()?msbp():lsbp(); } AstNode* rightp() const { return littleEndian()?msbp():lsbp(); }
int msbConst() const { AstConst* constp=msbp()->castConst(); return (constp?constp->toSInt():0); } int msbConst() const { AstConst* constp=msbp()->castConst(); return (constp?constp->toSInt():0); }
int lsbConst() const { AstConst* constp=lsbp()->castConst(); return (constp?constp->toSInt():0); } int lsbConst() const { AstConst* constp=lsbp()->castConst(); return (constp?constp->toSInt():0); }
int elementsConst() const { return (msbConst()>lsbConst()) ? msbConst()-lsbConst()+1 : lsbConst()-msbConst()+1; } int elementsConst() const { return (msbConst()>lsbConst()) ? msbConst()-lsbConst()+1 : lsbConst()-msbConst()+1; }
@ -320,8 +320,8 @@ public:
bool isRanged() const { return rangep() || m_msb; } bool isRanged() const { return rangep() || m_msb; }
int msb() const { if (!rangep()) return m_msb; return rangep()->msbConst(); } int msb() const { if (!rangep()) return m_msb; return rangep()->msbConst(); }
int lsb() const { if (!rangep()) return 0; return rangep()->lsbConst(); } int lsb() const { if (!rangep()) return 0; return rangep()->lsbConst(); }
int msbEndianed() const { if (!rangep()) return m_msb; return littleEndian()?rangep()->lsbConst():rangep()->msbConst(); } int left() const { if (!rangep()) return m_msb; return littleEndian()?rangep()->lsbConst():rangep()->msbConst(); }
int lsbEndianed() const { if (!rangep()) return 0; return littleEndian()?rangep()->msbConst():rangep()->lsbConst(); } int right() const { if (!rangep()) return 0; return littleEndian()?rangep()->msbConst():rangep()->lsbConst(); }
int msbMaxSelect() const { return (lsb()<0 ? msb()-lsb() : msb()); } // Maximum value a [] select may index int msbMaxSelect() const { return (lsb()<0 ? msb()-lsb() : msb()); } // Maximum value a [] select may index
bool littleEndian() const { return (rangep() && rangep()->littleEndian()); } bool littleEndian() const { return (rangep() && rangep()->littleEndian()); }
bool implicit() const { return m_implicit; } bool implicit() const { return m_implicit; }
@ -2339,8 +2339,8 @@ struct AstTraceDecl : public AstNodeStmt {
private: private:
string m_showname; // Name of variable string m_showname; // Name of variable
uint32_t m_code; // Trace identifier code; converted to ASCII by trace routines uint32_t m_code; // Trace identifier code; converted to ASCII by trace routines
int m_lsb; // Property of var the trace details int m_right; // Property of var the trace details
int m_msb; // Property of var the trace details int m_left; // Property of var the trace details
uint32_t m_arrayLsb; // Property of var the trace details uint32_t m_arrayLsb; // Property of var the trace details
uint32_t m_arrayMsb; // Property of var the trace details uint32_t m_arrayMsb; // Property of var the trace details
uint32_t m_codeInc; // Code increment uint32_t m_codeInc; // Code increment
@ -2352,8 +2352,8 @@ public:
m_code = 0; m_code = 0;
m_codeInc = varp->dtypep()->arrayElements() * varp->widthWords(); m_codeInc = varp->dtypep()->arrayElements() * varp->widthWords();
AstBasicDType* bdtypep = varp->basicp(); AstBasicDType* bdtypep = varp->basicp();
m_msb = bdtypep ? bdtypep->msbEndianed() : 0; m_left = bdtypep ? bdtypep->left() : 0;
m_lsb = bdtypep ? bdtypep->lsbEndianed() : 0; m_right = bdtypep ? bdtypep->right() : 0;
if (AstArrayDType* adtypep = varp->dtypeSkipRefp()->castArrayDType()) { if (AstArrayDType* adtypep = varp->dtypeSkipRefp()->castArrayDType()) {
m_arrayLsb = adtypep->arrayp()->lsbConst(); m_arrayLsb = adtypep->arrayp()->lsbConst();
m_arrayMsb = adtypep->arrayp()->msbConst(); m_arrayMsb = adtypep->arrayp()->msbConst();
@ -2372,8 +2372,8 @@ public:
uint32_t code() const { return m_code; } uint32_t code() const { return m_code; }
void code(uint32_t code) { m_code=code; } void code(uint32_t code) { m_code=code; }
uint32_t codeInc() const { return m_codeInc; } uint32_t codeInc() const { return m_codeInc; }
int msbEndianed() const { return m_msb; } // Note msb maybe < lsb if little endian int left() const { return m_left; } // Note msb maybe < lsb if little endian
int lsbEndianed() const { return m_lsb; } int right() const { return m_right; }
uint32_t arrayMsb() const { return m_arrayMsb; } uint32_t arrayMsb() const { return m_arrayMsb; }
uint32_t arrayLsb() const { return m_arrayLsb; } uint32_t arrayLsb() const { return m_arrayLsb; }
uint32_t arrayWidth() const { if (!arrayMsb()) return 0; return arrayMsb()-arrayLsb()+1; } uint32_t arrayWidth() const { if (!arrayMsb()) return 0; return arrayMsb()-arrayLsb()+1; }

View File

@ -2076,7 +2076,7 @@ class EmitCTrace : EmitCStmts {
puts("vcdp->declArray"); puts("vcdp->declArray");
} else if (nodep->isQuad()) { } else if (nodep->isQuad()) {
puts("vcdp->declQuad "); puts("vcdp->declQuad ");
} else if (nodep->msbEndianed() || nodep->lsbEndianed()) { } else if (nodep->left() || nodep->right()) {
puts("vcdp->declBus "); puts("vcdp->declBus ");
} else { } else {
puts("vcdp->declBit "); puts("vcdp->declBit ");
@ -2091,8 +2091,8 @@ class EmitCTrace : EmitCStmts {
puts(",-1"); puts(",-1");
} }
if (!nodep->isDouble() // When float/double no longer have widths this can go if (!nodep->isDouble() // When float/double no longer have widths this can go
&& (nodep->msbEndianed() || nodep->lsbEndianed())) { && (nodep->left() || nodep->right())) {
puts(","+cvtToStr(nodep->msbEndianed())+","+cvtToStr(nodep->lsbEndianed())); puts(","+cvtToStr(nodep->left())+","+cvtToStr(nodep->right()));
} }
puts(");"); puts(");");
} }
@ -2108,7 +2108,7 @@ class EmitCTrace : EmitCStmts {
puts("vcdp->"+full+"Array"); puts("vcdp->"+full+"Array");
} else if (nodep->isQuad()) { } else if (nodep->isQuad()) {
puts("vcdp->"+full+"Quad "); puts("vcdp->"+full+"Quad ");
} else if (nodep->declp()->msbEndianed() || nodep->declp()->lsbEndianed()) { } else if (nodep->declp()->left() || nodep->declp()->right()) {
puts("vcdp->"+full+"Bus "); puts("vcdp->"+full+"Bus ");
} else { } else {
puts("vcdp->"+full+"Bit "); puts("vcdp->"+full+"Bit ");
@ -2118,7 +2118,7 @@ class EmitCTrace : EmitCStmts {
puts(","); puts(",");
emitTraceValue(nodep, arrayindex); emitTraceValue(nodep, arrayindex);
if (!nodep->isDouble() // When float/double no longer have widths this can go if (!nodep->isDouble() // When float/double no longer have widths this can go
&& (nodep->declp()->msbEndianed() || nodep->declp()->lsbEndianed() || emitTraceIsScBv(nodep))) { && (nodep->declp()->left() || nodep->declp()->right() || emitTraceIsScBv(nodep))) {
puts(","+cvtToStr(nodep->declp()->widthMin())); puts(","+cvtToStr(nodep->declp()->widthMin()));
} }
puts(");\n"); puts(");\n");

View File

@ -447,11 +447,11 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
puts("["); puts("[");
if (nodep->msbp()->castConst() && nodep->lsbp()->castConst()) { if (nodep->msbp()->castConst() && nodep->lsbp()->castConst()) {
// Looks nicer if we print [1:0] rather than [32'sh1:32sh0] // Looks nicer if we print [1:0] rather than [32'sh1:32sh0]
puts(cvtToStr(nodep->msbEndianedp()->castConst()->toSInt())); puts(":"); puts(cvtToStr(nodep->leftp()->castConst()->toSInt())); puts(":");
puts(cvtToStr(nodep->lsbEndianedp()->castConst()->toSInt())); puts("]"); puts(cvtToStr(nodep->rightp()->castConst()->toSInt())); puts("]");
} else { } else {
nodep->msbEndianedp()->iterateAndNext(*this); puts(":"); nodep->leftp()->iterateAndNext(*this); puts(":");
nodep->lsbEndianedp()->iterateAndNext(*this); puts("]"); nodep->rightp()->iterateAndNext(*this); puts("]");
} }
} }
virtual void visit(AstSel* nodep, AstNUser*) { virtual void visit(AstSel* nodep, AstNUser*) {