mirror of
https://github.com/verilator/verilator.git
synced 2024-12-29 10:47:34 +00:00
Internals: Ast classes create declRange().
This commit is contained in:
parent
bbeb382cbb
commit
de4016dcff
@ -1559,6 +1559,7 @@ public:
|
||||
}
|
||||
int lsb() const { return 0; }
|
||||
int msb() const { return dtypep()->width()-1; } // Packed classes look like arrays
|
||||
VNumRange declRange() const { return VNumRange(msb(), lsb(), false); }
|
||||
};
|
||||
|
||||
struct AstNodeArrayDType : public AstNodeDType {
|
||||
@ -1601,6 +1602,7 @@ public:
|
||||
int msb() const;
|
||||
int lsb() const;
|
||||
int elementsConst() const;
|
||||
VNumRange declRange() const;
|
||||
};
|
||||
|
||||
struct AstNodeSel : public AstNodeBiop {
|
||||
@ -1802,5 +1804,6 @@ inline void AstNodeArrayDType::rangep(AstRange* nodep) { setOp2p(nodep); }
|
||||
inline int AstNodeArrayDType::msb() const { return rangep()->msbConst(); }
|
||||
inline int AstNodeArrayDType::lsb() const { return rangep()->lsbConst(); }
|
||||
inline int AstNodeArrayDType::elementsConst() const { return rangep()->elementsConst(); }
|
||||
inline VNumRange AstNodeArrayDType::declRange() const { return VNumRange(msb(), lsb(), rangep()->littleEndian()); }
|
||||
|
||||
#endif // Guard
|
||||
|
@ -746,11 +746,11 @@ void AstNodeDType::dumpSmall(ostream& str) {
|
||||
void AstNodeArrayDType::dumpSmall(ostream& str) {
|
||||
this->AstNodeDType::dumpSmall(str);
|
||||
if (castPackArrayDType()) str<<"p"; else str<<"u";
|
||||
str<<"["<<msb()<<":"<<lsb()<<"]";
|
||||
str<<"["<<declRange().left()<<":"<<declRange().right()<<"]";
|
||||
}
|
||||
void AstNodeArrayDType::dump(ostream& str) {
|
||||
this->AstNodeDType::dump(str);
|
||||
str<<" ["<<msb()<<":"<<lsb()<<"]";
|
||||
str<<" ["<<declRange().left()<<":"<<declRange().right()<<"]";
|
||||
}
|
||||
void AstNodeModule::dump(ostream& str) {
|
||||
this->AstNode::dump(str);
|
||||
|
@ -374,6 +374,7 @@ public:
|
||||
int right() const { return littleEndian()?msb():lsb(); }
|
||||
bool littleEndian() const { return (rangep() ? rangep()->littleEndian() : m.m_nrange.littleEndian()); }
|
||||
bool implicit() const { return keyword() == AstBasicDTypeKwd::LOGIC_IMPLICIT; }
|
||||
VNumRange declRange() const { return isRanged() ? VNumRange(msb(), lsb(), littleEndian()) : VNumRange(); }
|
||||
void cvtRangeConst() { // Convert to smaller represenation
|
||||
if (rangep() && rangep()->msbp()->castConst() && rangep()->lsbp()->castConst()) {
|
||||
m.m_nrange.init(rangep()->msbConst(), rangep()->lsbConst(),
|
||||
|
@ -94,14 +94,10 @@ private:
|
||||
AstNode* errp = ddtypep;
|
||||
UINFO(9," fromData.ddtypep = "<<ddtypep<<endl);
|
||||
if (AstNodeArrayDType* adtypep = ddtypep->castNodeArrayDType()) {
|
||||
fromRange.init(adtypep->msb(),
|
||||
adtypep->lsb(),
|
||||
adtypep->rangep()->littleEndian());
|
||||
fromRange = adtypep->declRange();
|
||||
}
|
||||
else if (AstNodeClassDType* adtypep = ddtypep->castNodeClassDType()) {
|
||||
fromRange.init(adtypep->msb(),
|
||||
adtypep->lsb(),
|
||||
false); // big endian
|
||||
fromRange = adtypep->declRange();
|
||||
}
|
||||
else if (AstBasicDType* adtypep = ddtypep->castBasicDType()) {
|
||||
if (adtypep->isRanged()) {
|
||||
@ -109,9 +105,7 @@ private:
|
||||
&& (!adtypep->rangep()->msbp()->castConst()
|
||||
|| !adtypep->rangep()->lsbp()->castConst()))
|
||||
nodep->v3fatalSrc("Non-constant variable range; errored earlier"); // in constifyParam(bfdtypep)
|
||||
fromRange.init(adtypep->msb(),
|
||||
adtypep->lsb(),
|
||||
adtypep->littleEndian());
|
||||
fromRange = adtypep->declRange();
|
||||
} else {
|
||||
nodep->v3error("Illegal bit or array select; type does not have a bit range, or bad dimension: type is "
|
||||
<<errp->prettyName());
|
||||
|
Loading…
Reference in New Issue
Block a user