From e2e3cc84633db33625039dc3f87a15ec6986114a Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 12 Dec 2020 21:20:42 -0500 Subject: [PATCH] Better error on inside on unpacked, queues, etc (#2566) --- src/V3Width.cpp | 13 ++++++++++-- test_regress/t/t_inside_queue_bad.out | 13 ++++++++++++ test_regress/t/t_inside_queue_bad.pl | 19 ++++++++++++++++++ test_regress/t/t_inside_queue_bad.v | 20 +++++++++++++++++++ test_regress/t/t_inside_unpack.out | 4 ---- test_regress/t/t_inside_unpacked.out | 9 +++++++++ ..._inside_unpack.pl => t_inside_unpacked.pl} | 0 ...{t_inside_unpack.v => t_inside_unpacked.v} | 0 8 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 test_regress/t/t_inside_queue_bad.out create mode 100755 test_regress/t/t_inside_queue_bad.pl create mode 100644 test_regress/t/t_inside_queue_bad.v delete mode 100644 test_regress/t/t_inside_unpack.out create mode 100644 test_regress/t/t_inside_unpacked.out rename test_regress/t/{t_inside_unpack.pl => t_inside_unpacked.pl} (100%) rename test_regress/t/{t_inside_unpack.v => t_inside_unpacked.v} (100%) diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 2499543b6..0c3195edc 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -2211,12 +2211,21 @@ private: for (AstNode *nextip, *itemp = nodep->itemsp(); itemp; itemp = nextip) { nextip = itemp->nextp(); // Will be unlinking AstNode* inewp; + AstNodeDType* itemDtp = itemp->dtypep()->skipRefp(); if (AstInsideRange* irangep = VN_CAST(itemp, InsideRange)) { // Similar logic in V3Case inewp = irangep->newAndFromInside(nodep->exprp(), irangep->lhsp()->unlinkFrBack(), irangep->rhsp()->unlinkFrBack()); - } else if (auto* irangep = VN_CAST(itemp->dtypep(), UnpackArrayDType)) { - irangep->v3error("Unsupported: inside on unpacked array"); + } else if (VN_IS(itemDtp, UnpackArrayDType)) { + nodep->v3error("Unsupported: inside (set membership operator) on unpacked array"); + // Need the AstInside type to persist, then + // for parameters, need V3Simulate support. + // For non-parameters, need runtime support. + continue; + } else if (VN_IS(itemDtp, AssocArrayDType) || VN_IS(itemDtp, DynArrayDType) + || VN_IS(itemDtp, QueueDType)) { + nodep->v3error( + "Inside operator not legal on non-unpacked arrays (IEEE 1800-2017 11.4.13)"); continue; } else { inewp = new AstEqWild(itemp->fileline(), nodep->exprp()->cloneTree(true), diff --git a/test_regress/t/t_inside_queue_bad.out b/test_regress/t/t_inside_queue_bad.out new file mode 100644 index 000000000..ad0b436c9 --- /dev/null +++ b/test_regress/t/t_inside_queue_bad.out @@ -0,0 +1,13 @@ +%Error: t/t_inside_queue_bad.v:15:15: Inside operator not legal on non-unpacked arrays (IEEE 1800-2017 11.4.13) + : ... In instance t + 15 | m = (10 inside {q}); + | ^~~~~~ +%Error: t/t_inside_queue_bad.v:16:15: Inside operator not legal on non-unpacked arrays (IEEE 1800-2017 11.4.13) + : ... In instance t + 16 | m = (10 inside {assoc}); + | ^~~~~~ +%Error: t/t_inside_queue_bad.v:17:15: Inside operator not legal on non-unpacked arrays (IEEE 1800-2017 11.4.13) + : ... In instance t + 17 | m = (10 inside {dyn}); + | ^~~~~~ +%Error: Exiting due to diff --git a/test_regress/t/t_inside_queue_bad.pl b/test_regress/t/t_inside_queue_bad.pl new file mode 100755 index 000000000..ffb804e48 --- /dev/null +++ b/test_regress/t/t_inside_queue_bad.pl @@ -0,0 +1,19 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2019 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(linter => 1); + +compile( + fails => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_inside_queue_bad.v b/test_regress/t/t_inside_queue_bad.v new file mode 100644 index 000000000..4e3e0c9a8 --- /dev/null +++ b/test_regress/t/t_inside_queue_bad.v @@ -0,0 +1,20 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2020 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module t(/*AUTOARG*/); + + int q[$]; + int assoc[int]; + int dyn[]; + bit m; + + initial begin + m = (10 inside {q}); + m = (10 inside {assoc}); + m = (10 inside {dyn}); + end + +endmodule diff --git a/test_regress/t/t_inside_unpack.out b/test_regress/t/t_inside_unpack.out deleted file mode 100644 index e7037fc4a..000000000 --- a/test_regress/t/t_inside_unpack.out +++ /dev/null @@ -1,4 +0,0 @@ -%Error: t/t_inside_unpack.v:13:31: Unsupported: inside on unpacked array - 13 | localparam int CHECKLIST_P [2:0] = '{0, 1, 2}; - | ^ -%Error: Exiting due to diff --git a/test_regress/t/t_inside_unpacked.out b/test_regress/t/t_inside_unpacked.out new file mode 100644 index 000000000..608d0f49b --- /dev/null +++ b/test_regress/t/t_inside_unpacked.out @@ -0,0 +1,9 @@ +%Error: t/t_inside_unpacked.v:17:35: Unsupported: inside (set membership operator) on unpacked array + : ... In instance t + 17 | localparam HIT_INSIDE = HIT_LP inside {CHECKLIST_P}; + | ^~~~~~ +%Error: t/t_inside_unpacked.v:18:37: Unsupported: inside (set membership operator) on unpacked array + : ... In instance t + 18 | localparam MISS_INSIDE = MISS_LP inside {CHECKLIST_P}; + | ^~~~~~ +%Error: Exiting due to diff --git a/test_regress/t/t_inside_unpack.pl b/test_regress/t/t_inside_unpacked.pl similarity index 100% rename from test_regress/t/t_inside_unpack.pl rename to test_regress/t/t_inside_unpacked.pl diff --git a/test_regress/t/t_inside_unpack.v b/test_regress/t/t_inside_unpacked.v similarity index 100% rename from test_regress/t/t_inside_unpack.v rename to test_regress/t/t_inside_unpacked.v