Fix casting to arrays of enums (#6044)
This commit is contained in:
parent
76aced4d40
commit
5fcd0e52e7
|
@ -1583,7 +1583,7 @@ static VCastable computeCastableImp(const AstNodeDType* toDtp, const AstNodeDTyp
|
||||||
return VCastable::COMPATIBLE;
|
return VCastable::COMPATIBLE;
|
||||||
} else if (toNumericable) {
|
} else if (toNumericable) {
|
||||||
if (fromNumericable) return VCastable::COMPATIBLE;
|
if (fromNumericable) return VCastable::COMPATIBLE;
|
||||||
} else if (VN_IS(toDtp, EnumDType)) {
|
} else if (VN_IS(toBaseDtp, EnumDType)) {
|
||||||
if (VN_IS(fromBaseDtp, EnumDType) && toDtp->sameTree(fromDtp))
|
if (VN_IS(fromBaseDtp, EnumDType) && toDtp->sameTree(fromDtp))
|
||||||
return VCastable::ENUM_IMPLICIT;
|
return VCastable::ENUM_IMPLICIT;
|
||||||
if (fromNumericable) return VCastable::ENUM_EXPLICIT;
|
if (fromNumericable) return VCastable::ENUM_EXPLICIT;
|
||||||
|
|
|
@ -28,6 +28,8 @@ module t;
|
||||||
ONE = 1
|
ONE = 1
|
||||||
} enum_t;
|
} enum_t;
|
||||||
|
|
||||||
|
typedef enum_t [3:0] enums_t;
|
||||||
|
|
||||||
packed_t pdata;
|
packed_t pdata;
|
||||||
packed_t pdata_reg;
|
packed_t pdata_reg;
|
||||||
packed2_t pdata2_reg;
|
packed2_t pdata2_reg;
|
||||||
|
@ -37,6 +39,7 @@ module t;
|
||||||
|
|
||||||
mc_t o;
|
mc_t o;
|
||||||
enum_t e;
|
enum_t e;
|
||||||
|
enums_t es;
|
||||||
|
|
||||||
intf the_intf();
|
intf the_intf();
|
||||||
|
|
||||||
|
@ -69,6 +72,7 @@ module t;
|
||||||
logic [31:0] thirty_two_bits;
|
logic [31:0] thirty_two_bits;
|
||||||
two_dee_t two_dee_sig;
|
two_dee_t two_dee_sig;
|
||||||
|
|
||||||
|
int i;
|
||||||
initial begin
|
initial begin
|
||||||
if (logic8bit != 8'h12) $stop;
|
if (logic8bit != 8'h12) $stop;
|
||||||
if (4'shf > 4'sh0) $stop;
|
if (4'shf > 4'sh0) $stop;
|
||||||
|
@ -95,6 +99,11 @@ module t;
|
||||||
e = enum_t'(pdata_reg);
|
e = enum_t'(pdata_reg);
|
||||||
if (e != ONE) $stop;
|
if (e != ONE) $stop;
|
||||||
|
|
||||||
|
es = {ONE, ONE, ONE, ONE};
|
||||||
|
for (i = 0; i < 4; i++) if (es[i] != ONE) $stop;
|
||||||
|
es = enums_t'(64'h0001_0001_0001_0001);
|
||||||
|
for (i = 0; i < 4; i++) if (es[i] != ONE) $stop;
|
||||||
|
|
||||||
o = tocast_t'(4'b1);
|
o = tocast_t'(4'b1);
|
||||||
if (o != 4'b1) $stop;
|
if (o != 4'b1) $stop;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue