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