Better error on inside on unpacked, queues, etc (#2566)

This commit is contained in:
Wilson Snyder 2020-12-12 21:20:42 -05:00
parent 6061744c4d
commit e2e3cc8463
8 changed files with 72 additions and 6 deletions

View File

@ -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),

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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