From 93e5ca3f6d1ee49db3385552b273289cf286a17b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 18 Mar 2024 20:44:18 -0400 Subject: [PATCH] Fix class type as an associative array parameter (#4997). --- Changes | 1 + src/V3AstNodeDType.h | 2 +- test_regress/t/t_assoc_ref_type.v | 31 ++++++++++++++++++++----------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Changes b/Changes index 186a9a474..852f47469 100644 --- a/Changes +++ b/Changes @@ -33,6 +33,7 @@ Verilator 5.023 devel * Fix assignment of null into struct member (#4952). * Fix object assignment from conditionals (#4968). * Fix unpacked structure upper bit cleaning (#4978). +* Fix class type as an associative array parameter (#4997). Verilator 5.022 2024-02-24 diff --git a/src/V3AstNodeDType.h b/src/V3AstNodeDType.h index 89a41aeff..4e781995e 100644 --- a/src/V3AstNodeDType.h +++ b/src/V3AstNodeDType.h @@ -469,7 +469,7 @@ public: this->elementsp(elementsp); } ASTGEN_MEMBERS_AstBracketArrayDType; - bool similarDType(const AstNodeDType* samep) const override { V3ERROR_NA_RETURN(false); } + bool similarDType(const AstNodeDType* samep) const override { return same(samep); } AstNodeDType* subDTypep() const override VL_MT_STABLE { return childDTypep(); } // METHODS // Will be removed in V3Width, which relies on this diff --git a/test_regress/t/t_assoc_ref_type.v b/test_regress/t/t_assoc_ref_type.v index b7dbc854f..fe9b110e5 100644 --- a/test_regress/t/t_assoc_ref_type.v +++ b/test_regress/t/t_assoc_ref_type.v @@ -43,26 +43,35 @@ class Baz #(type T=Foo1); endfunction endclass -module t (/*AUTOARG*/ - ); +class WBase; +endclass + +class Wrapper#(type VAL_T=int); + VAL_T value; +endclass + +module t (/*AUTOARG*/); + + typedef WBase wrap_map_t[string]; + typedef WBase wrap_queue_t[$]; initial begin Bar bar_i = new; Baz baz_1_i = new; Baz #(Foo2) baz_2_i = new; + Wrapper#(wrap_map_t) wrap_map = new(); + Wrapper#(wrap_queue_t) wrap_queue = new(); + bar_i.set(1); baz_1_i.set(2); baz_2_i.set(3); - if (bar_i.get(1).get_x() == 1 && - baz_1_i.get(2).get_x() == 1 && - baz_2_i.get(3).get_x() == 2) begin - $write("*-* All Finished *-*\n"); - $finish; - end - else begin - $stop; - end + if (bar_i.get(1).get_x() != 1) $stop; + if (baz_1_i.get(2).get_x() != 1) $stop; + if (baz_2_i.get(3).get_x() != 2) $stop; + + $write("*-* All Finished *-*\n"); + $finish; end endmodule