Internals: Add isNonPackedArray(). No functional change. (#7334 prep)
This commit is contained in:
parent
adb48046c2
commit
3b454a6f60
|
|
@ -125,6 +125,8 @@ public:
|
|||
virtual AstNodeDType* subDTypep() const VL_MT_STABLE { return nullptr; }
|
||||
virtual AstNodeDType* subDType2p() const VL_MT_STABLE { return nullptr; }
|
||||
virtual bool isAggregateType() const { return false; }
|
||||
// True for unpacked, dynamic, queue, and associative arrays (not packed arrays)
|
||||
bool isNonPackedArray() const;
|
||||
virtual bool isFourstate() const;
|
||||
// Ideally an IEEE $typename
|
||||
virtual string prettyDTypeName(bool) const { return prettyTypeName(); }
|
||||
|
|
|
|||
|
|
@ -1013,6 +1013,11 @@ bool AstNodeDType::similarDType(const AstNodeDType* samep) const {
|
|||
|
||||
bool AstNodeDType::isFourstate() const { return basicp() && basicp()->isFourstate(); }
|
||||
|
||||
bool AstNodeDType::isNonPackedArray() const {
|
||||
return VN_IS(this, UnpackArrayDType) || VN_IS(this, DynArrayDType)
|
||||
|| VN_IS(this, QueueDType) || VN_IS(this, AssocArrayDType);
|
||||
}
|
||||
|
||||
class AstNodeDType::CTypeRecursed final {
|
||||
public:
|
||||
string m_type; // The base type, e.g.: "Foo_t"s
|
||||
|
|
|
|||
|
|
@ -280,9 +280,7 @@ class EmitCHeader final : public EmitCConstInit {
|
|||
enum class AttributeType { Width, Dimension };
|
||||
// Get member attribute based on type
|
||||
int getNodeAttribute(const AstMemberDType* itemp, AttributeType type) {
|
||||
const bool isArrayType
|
||||
= VN_IS(itemp->dtypep(), UnpackArrayDType) || VN_IS(itemp->dtypep(), DynArrayDType)
|
||||
|| VN_IS(itemp->dtypep(), QueueDType) || VN_IS(itemp->dtypep(), AssocArrayDType);
|
||||
const bool isArrayType = itemp->dtypep()->isNonPackedArray();
|
||||
switch (type) {
|
||||
case AttributeType::Width: {
|
||||
if (isArrayType) {
|
||||
|
|
|
|||
|
|
@ -1136,8 +1136,7 @@ class ConstraintExprVisitor final : public VNVisitor {
|
|||
AstClassRefDType* elemClassRefDtp = nullptr;
|
||||
{
|
||||
AstNodeDType* varDtp = varp->dtypep()->skipRefp();
|
||||
if (VN_IS(varDtp, DynArrayDType) || VN_IS(varDtp, QueueDType)
|
||||
|| VN_IS(varDtp, UnpackArrayDType) || VN_IS(varDtp, AssocArrayDType)) {
|
||||
if (varDtp->isNonPackedArray()) {
|
||||
AstNodeDType* const elemDtp = varDtp->subDTypep()->skipRefp();
|
||||
elemClassRefDtp = VN_CAST(elemDtp, ClassRefDType);
|
||||
if (elemClassRefDtp) {
|
||||
|
|
@ -1209,9 +1208,7 @@ class ConstraintExprVisitor final : public VNVisitor {
|
|||
AstVar* const memberVarp = VN_CAST(mnodep, Var);
|
||||
if (!memberVarp || !memberVarp->rand().isRandomizable()) continue;
|
||||
AstNodeDType* const memberDtp = memberVarp->dtypep()->skipRefp();
|
||||
if (VN_IS(memberDtp, ClassRefDType) || VN_IS(memberDtp, DynArrayDType)
|
||||
|| VN_IS(memberDtp, QueueDType) || VN_IS(memberDtp, UnpackArrayDType)
|
||||
|| VN_IS(memberDtp, AssocArrayDType))
|
||||
if (VN_IS(memberDtp, ClassRefDType) || memberDtp->isNonPackedArray())
|
||||
continue;
|
||||
const int memberWidth = memberDtp->width();
|
||||
|
||||
|
|
@ -1281,9 +1278,7 @@ class ConstraintExprVisitor final : public VNVisitor {
|
|||
VAccess::READWRITE},
|
||||
VCMethod::RANDOMIZER_WRITE_VAR};
|
||||
uint32_t dimension = 0;
|
||||
if (VN_IS(varp->dtypep(), UnpackArrayDType) || VN_IS(varp->dtypep(), DynArrayDType)
|
||||
|| VN_IS(varp->dtypep(), QueueDType)
|
||||
|| VN_IS(varp->dtypep(), AssocArrayDType)) {
|
||||
if (varp->dtypep()->isNonPackedArray()) {
|
||||
const std::pair<uint32_t, uint32_t> dims
|
||||
= varp->dtypep()->dimensions(/*includeBasic=*/true);
|
||||
const uint32_t unpackedDimensions = dims.second;
|
||||
|
|
@ -1316,8 +1311,7 @@ class ConstraintExprVisitor final : public VNVisitor {
|
|||
methodp->addPinsp(varRefp);
|
||||
}
|
||||
AstNodeDType* tmpDtypep = varp->dtypep();
|
||||
while (VN_IS(tmpDtypep, UnpackArrayDType) || VN_IS(tmpDtypep, DynArrayDType)
|
||||
|| VN_IS(tmpDtypep, QueueDType) || VN_IS(tmpDtypep, AssocArrayDType))
|
||||
while (tmpDtypep->isNonPackedArray())
|
||||
tmpDtypep = tmpDtypep->subDTypep();
|
||||
const size_t width = tmpDtypep->width();
|
||||
methodp->addPinsp(
|
||||
|
|
@ -3370,8 +3364,7 @@ class RandomizeVisitor final : public VNVisitor {
|
|||
dtypep->findBasicDType(VBasicDTypeKwd::UINT32)};
|
||||
};
|
||||
AstNodeExpr* tempElementp = nullptr;
|
||||
while (VN_IS(tempDTypep, DynArrayDType) || VN_IS(tempDTypep, UnpackArrayDType)
|
||||
|| VN_IS(tempDTypep, AssocArrayDType) || VN_IS(tempDTypep, QueueDType)) {
|
||||
while (tempDTypep->isNonPackedArray()) {
|
||||
AstVar* const newRandLoopIndxp = createLoopIndex(tempDTypep);
|
||||
randLoopIndxp = AstNode::addNext(randLoopIndxp, newRandLoopIndxp);
|
||||
AstNodeExpr* const tempExprp = tempElementp ? tempElementp : exprp;
|
||||
|
|
@ -4397,8 +4390,7 @@ class RandomizeVisitor final : public VNVisitor {
|
|||
}
|
||||
|
||||
AstNodeDType* tmpDtypep = arrVarp->dtypep();
|
||||
while (VN_IS(tmpDtypep, UnpackArrayDType) || VN_IS(tmpDtypep, DynArrayDType)
|
||||
|| VN_IS(tmpDtypep, QueueDType) || VN_IS(tmpDtypep, AssocArrayDType))
|
||||
while (tmpDtypep->isNonPackedArray())
|
||||
tmpDtypep = tmpDtypep->subDTypep();
|
||||
const size_t width = tmpDtypep->width();
|
||||
|
||||
|
|
|
|||
|
|
@ -6043,12 +6043,8 @@ class WidthVisitor final : public VNVisitor {
|
|||
const AstNodeDType* const rhsDtp = nodep->rhsp()->dtypep()->skipRefp();
|
||||
// Only check if number of states match for unpacked array to unpacked array
|
||||
// assignments
|
||||
const bool lhsIsUnpackArray
|
||||
= VN_IS(lhsDtp, UnpackArrayDType) || VN_IS(lhsDtp, DynArrayDType)
|
||||
|| VN_IS(lhsDtp, QueueDType) || VN_IS(lhsDtp, AssocArrayDType);
|
||||
const bool rhsIsUnpackArray
|
||||
= VN_IS(rhsDtp, UnpackArrayDType) || VN_IS(rhsDtp, DynArrayDType)
|
||||
|| VN_IS(rhsDtp, QueueDType) || VN_IS(rhsDtp, AssocArrayDType);
|
||||
const bool lhsIsUnpackArray = lhsDtp->isNonPackedArray();
|
||||
const bool rhsIsUnpackArray = rhsDtp->isNonPackedArray();
|
||||
if (lhsIsUnpackArray && rhsIsUnpackArray) {
|
||||
if (lhsDtp->isFourstate() != rhsDtp->isFourstate()) {
|
||||
nodep->v3error("Assignment between 2-state and 4-state types requires "
|
||||
|
|
|
|||
Loading…
Reference in New Issue