diff --git a/Changes b/Changes index e6d60ea1a..89af2fa73 100644 --- a/Changes +++ b/Changes @@ -11,6 +11,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix evaluation of chained parameter functions, bug684. [Ted Campbell] +**** Fix enum value extension of '1. + **** Fix multiple VPI variable callbacks, bug679. [Rich Porter] **** Fix vpi_get of vpiSize, bug680. [Rich Porter] diff --git a/src/V3Width.cpp b/src/V3Width.cpp index a91df6186..dccf2ecf7 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -2251,12 +2251,16 @@ private: void widthCheck (AstNode* nodep, const char* side, AstNode* underp, AstNodeDType* expDTypep, bool ignoreWarn=false) { - //UINFO(9,"wchk "<width(); int expWidthMin = expDTypep->widthMin(); if (expWidthMin==0) expWidthMin = expWidth; bool bad = widthBad(underp,expWidth,expWidthMin); - if (bad && fixAutoExtend(underp/*ref*/,expWidth)) bad=false; // Changes underp + if ((bad || underp->width() !=expWidth) + && fixAutoExtend(underp/*ref*/,expWidth)) { + underp=NULL; // Changes underp + return; + } if (underp->castConst() && underp->castConst()->num().isFromString() && expWidth > underp->width() && (((expWidth - underp->width()) % 8) == 0)) { // At least it's character sized diff --git a/test_regress/t/t_enum.v b/test_regress/t/t_enum.v index 9548fc9a3..1681cb603 100644 --- a/test_regress/t/t_enum.v +++ b/test_regress/t/t_enum.v @@ -34,6 +34,9 @@ module t (/*AUTOARG*/); var logic [ONES:0] sized_based_on_enum; + var enum logic [3:0] { QINVALID='1, QSEND={2'b0,2'h0}, QOP={2'b0,2'h1}, QCL={2'b0,2'h2}, + QPR={2'b0,2'h3 }, QACK, QRSP } inv; + initial begin if (e0 !== 0) $stop; if (e1 !== 1) $stop; @@ -61,6 +64,14 @@ module t (/*AUTOARG*/); if (FIVE[BIT1] != 1'b0) $stop; if (FIVE[BIT2] != 1'b1) $stop; + if (QINVALID != 15) $stop; + if (QSEND != 0) $stop; + if (QOP != 1) $stop; + if (QCL != 2) $stop; + if (QPR != 3) $stop; + if (QACK != 4) $stop; + if (QRSP != 5) $stop; + $write("*-* All Finished *-*\n"); $finish; end