diff --git a/Changes b/Changes index a4f3a0248..05e9c5956 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,8 @@ indicates the contributor was also the author of the fix; Thanks! * Verilator 3.846-devel +**** Support pattern assignments to const variables, bug616. [Ed Lander] + **** Fix DETECTARRAY on packed structures, bug610. [Jeremy Bennett] **** Fix LITENDIAN on unpacked structures, bug614. [Wai Sum Mong] diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 2e1275084..d6ee9f740 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1151,6 +1151,9 @@ private: patp->unlinkFrBack(); } } + while (AstConstDType* classp = m_assDTypep->castConstDType()) { + m_assDTypep = classp->subDTypep()->skipRefp(); + } if (AstNodeClassDType* classp = m_assDTypep->castNodeClassDType()) { // Due to "default" and tagged patterns, we need to determine // which member each AstPatMember corresponds to before we can diff --git a/test_regress/t/t_struct_init.v b/test_regress/t/t_struct_init.v index 5f1fb9ddb..979b56b15 100644 --- a/test_regress/t/t_struct_init.v +++ b/test_regress/t/t_struct_init.v @@ -39,6 +39,8 @@ module t; // bit vec2d[2][3]; } pack3_t; + const b4_t b4_const_a = '{1'b1, 1'b0, 1'b0, 1'b1}; + pack2_t arr[2]; initial begin @@ -94,6 +96,8 @@ module t; if (q != 4'b1011) $stop; end + if (b4_const_a != 4'b1001) $stop; + $write("*-* All Finished *-*\n"); $finish; end