diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 246c02cad..176f8c00e 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1139,8 +1139,12 @@ private: // The node got setup with the signed/real state of the node. // However a later operation may have changed the node->signed w/o changing // the number's sign. So we don't: nodep->dtypeChgSigned(nodep->num().isSigned()); + if (nodep->didWidthAndSet()) return; if (m_vup && m_vup->prelim()) { - if (nodep->num().isString()) { + if (VN_IS(nodep->dtypep()->skipRefToEnump(), EnumDType)) { + // Assume this constant was properly casted ealier + // (Otherwise it couldn't have an enum data type) + } else if (nodep->num().isString()) { nodep->dtypeSetString(); } else if (nodep->num().sized()) { nodep->dtypeChgWidth(nodep->num().width(), nodep->num().width()); diff --git a/test_regress/t/t_enum_value_assign.v b/test_regress/t/t_enum_value_assign.v index 28e55cf02..953245910 100644 --- a/test_regress/t/t_enum_value_assign.v +++ b/test_regress/t/t_enum_value_assign.v @@ -19,6 +19,9 @@ module t(/*AUTOARG*/); localparam enum_t PARAMVAL1 = VAL1; localparam enum_t PARAMVAL1CONST = enum_t'(2); + typedef enum {I_ZERO, I_ONE, I_TWO} inte_t; + localparam inte_t I_PARAM = inte_t'(1); + initial begin enum_t e; e = VAL01; @@ -27,6 +30,8 @@ module t(/*AUTOARG*/); if (PARAMVAL1 != VAL1) $stop; if (PARAMVAL1CONST != VAL1) $stop; + if (I_PARAM != I_ONE) $stop; + $write("*-* All Finished *-*\n"); $finish; end