diff --git a/Changes b/Changes index 9dd89e277..dea587c08 100644 --- a/Changes +++ b/Changes @@ -15,6 +15,7 @@ Verilator 4.219 devel * Removed the deprecated lint_off flag -msg; use -rule instead. * Removed the deprecated "fl" attribute in XML output; use "loc" attribute instead. +* Fix skipping public enum values with four-state values (#3303). Verilator 4.218 2022-01-17 diff --git a/src/V3EmitCHeaders.cpp b/src/V3EmitCHeaders.cpp index 18436adb9..bb26512f2 100644 --- a/src/V3EmitCHeaders.cpp +++ b/src/V3EmitCHeaders.cpp @@ -192,6 +192,12 @@ class EmitCHeader final : public EmitCConstInit { puts("enum " + tdefp->name() + " {\n"); for (const AstEnumItem* itemp = edtypep->itemsp(); itemp; itemp = VN_AS(itemp->nextp(), EnumItem)) { + if (const AstConst* const constp = VN_CAST(itemp->valuep(), Const)) { + if (constp->num().isFourState()) { + puts("// " + itemp->nameProtect() + " is four-state\n"); + continue; + } + } puts(itemp->nameProtect()); puts(" = "); iterate(itemp->valuep()); diff --git a/test_regress/t/t_enum_public.v b/test_regress/t/t_enum_public.v index dfae146c5..60ed94800 100644 --- a/test_regress/t/t_enum_public.v +++ b/test_regress/t/t_enum_public.v @@ -8,6 +8,9 @@ package p3; typedef enum logic [2:0] { ZERO = 3'b0, ONE = 3'b1 } e3_t /*verilator public*/; + typedef enum logic [2:0] { + TWO = 3'd2, + XES = 3'b?1? } has_x_t /*verilator public*/; endpackage package p62;