Fix unexpected RefDType on assoc arrays (#4337)

This commit is contained in:
Aleksander Kiryk 2023-07-04 15:13:22 +02:00 committed by GitHub
parent 97feba6898
commit fcbd7c87af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -383,7 +383,8 @@ public:
void visit(AstAssocSel* nodep) override { void visit(AstAssocSel* nodep) override {
iterateAndNextConstNull(nodep->fromp()); iterateAndNextConstNull(nodep->fromp());
putbs(".at("); putbs(".at(");
AstAssocArrayDType* const adtypep = VN_AS(nodep->fromp()->dtypep(), AssocArrayDType); AstAssocArrayDType* const adtypep
= VN_AS(nodep->fromp()->dtypep()->skipRefp(), AssocArrayDType);
UASSERT_OBJ(adtypep, nodep, "Associative select on non-associative type"); UASSERT_OBJ(adtypep, nodep, "Associative select on non-associative type");
if (adtypep->keyDTypep()->isWide()) { if (adtypep->keyDTypep()->isWide()) {
emitCvtWideArray(nodep->bitp(), nodep->fromp()); emitCvtWideArray(nodep->bitp(), nodep->fromp());
@ -395,7 +396,8 @@ public:
void visit(AstWildcardSel* nodep) override { void visit(AstWildcardSel* nodep) override {
iterateAndNextConstNull(nodep->fromp()); iterateAndNextConstNull(nodep->fromp());
putbs(".at("); putbs(".at(");
AstWildcardArrayDType* const adtypep = VN_AS(nodep->fromp()->dtypep(), WildcardArrayDType); AstWildcardArrayDType* const adtypep
= VN_AS(nodep->fromp()->dtypep()->skipRefp(), WildcardArrayDType);
UASSERT_OBJ(adtypep, nodep, "Wildcard select on non-wildcard-associative type"); UASSERT_OBJ(adtypep, nodep, "Wildcard select on non-wildcard-associative type");
iterateAndNextConstNull(nodep->bitp()); iterateAndNextConstNull(nodep->bitp());
puts(")"); puts(")");

View File

@ -23,7 +23,8 @@ module t (/*AUTOARG*/
begin begin
// Type // Type
typedef bit [3:0] nibble_t; typedef bit [3:0] nibble_t;
string a [nibble_t]; typedef string dict_t [nibble_t];
dict_t a;
string b [nibble_t]; string b [nibble_t];
nibble_t k; nibble_t k;
string v; string v;