From 070bcddf5a979252c6f0e913ceea13740aa03aef Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 10 May 2020 12:48:33 -0400 Subject: [PATCH] Support unpacked array .sum and .product. --- Changes | 2 ++ src/V3Width.cpp | 9 ++++++++- test_regress/t/t_array_type_methods.v | 14 ++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Changes b/Changes index 4d64d89cc..24ac0fe9f 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Support $isunbounded and parameter $. (#2104) +**** Support unpacked array .sum and .product. + **** Fix FST tracing of little bit endian signals. [Geza Lore] **** Fix +: and -: on unpacked arrays. (#2304) [engr248] diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 9da46282b..a47743257 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1944,6 +1944,7 @@ private: } } else if (VN_IS(fromDtp, EnumDType) // || VN_IS(fromDtp, AssocArrayDType) // + || VN_IS(fromDtp, UnpackArrayDType) // || VN_IS(fromDtp, DynArrayDType) // || VN_IS(fromDtp, QueueDType) // || VN_IS(fromDtp, BasicDType)) { @@ -2420,7 +2421,7 @@ private: nodep->dtypeSetSigned32(); // Guess on error } void methodCallUnpack(AstMethodCall* nodep, AstUnpackArrayDType* adtypep) { - enum { UNKNOWN = 0, ARRAY_OR, ARRAY_AND, ARRAY_XOR } methodId; + enum { UNKNOWN = 0, ARRAY_OR, ARRAY_AND, ARRAY_XOR, ARRAY_SUM, ARRAY_PRODUCT } methodId; methodId = UNKNOWN; if (nodep->name() == "or") { @@ -2429,6 +2430,10 @@ private: methodId = ARRAY_AND; } else if (nodep->name() == "xor") { methodId = ARRAY_XOR; + } else if (nodep->name() == "sum") { + methodId = ARRAY_SUM; + } else if (nodep->name() == "product") { + methodId = ARRAY_PRODUCT; } if (methodId) { @@ -2445,6 +2450,8 @@ private: case ARRAY_OR: newp = new AstOr(fl, newp, selector); break; case ARRAY_AND: newp = new AstAnd(fl, newp, selector); break; case ARRAY_XOR: newp = new AstXor(fl, newp, selector); break; + case ARRAY_SUM: newp = new AstAdd(fl, newp, selector); break; + case ARRAY_PRODUCT: newp = new AstMul(fl, newp, selector); break; default: nodep->v3fatalSrc("bad case"); } } diff --git a/test_regress/t/t_array_type_methods.v b/test_regress/t/t_array_type_methods.v index 48429bdd9..1ee503146 100644 --- a/test_regress/t/t_array_type_methods.v +++ b/test_regress/t/t_array_type_methods.v @@ -13,14 +13,16 @@ module t (/*AUTOARG*/ ); input clk; - logic [2:0] foo [1:0]; + logic [3:0] foo [1:0]; initial begin - foo[0] = 3'b101; - foo[1] = 3'b011; + foo[0] = 4'b0101; + foo[1] = 4'b0011; - `checkh(foo.or, 3'b111); - `checkh(foo.and, 3'b001); - `checkh(foo.xor, 3'b110); + `checkh(foo.or, 4'b0111); + `checkh(foo.and, 4'b0001); + `checkh(foo.xor, 4'b0110); + `checkh(foo.sum, 4'b1000); + `checkh(foo.product, 4'b1111); $write("*-* All Finished *-*\n"); $finish;