Tests: Add unsupported queue method/slice testing.

This commit is contained in:
Wilson Snyder 2020-10-14 21:57:53 -04:00
parent 7e5f562500
commit 3b9c8b64f7
8 changed files with 322 additions and 82 deletions

View File

@ -38,6 +38,7 @@ sub formats {
my $lineno = 0;
foreach my $line (split /\n/, $wholefile) {
++$lineno;
$line =~ s/(\$display|\$write).*\".*%(Error|Warning)//;
if ($line =~ /(Error|Warning)/) {
# These formats are documented in bin/verilator
# Error with fileline

View File

@ -0,0 +1,70 @@
%Error-UNSUPPORTED: t/t_queue_method.v:28:14: Unsupported: with statements
28 | q.sort with (item == 2);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:30:17: Unsupported: with statements
30 | q.sort(x) with (x == 3);
| ^~~~
%Error: t/t_queue_method.v:30:14: Can't find definition of variable: 'x'
30 | q.sort(x) with (x == 3);
| ^
%Error-UNSUPPORTED: t/t_queue_method.v:32:18: Unsupported: with statements
32 | qe.sort(x) with (x == 3);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:37:15: Unsupported: with statements
37 | q.rsort with (item == 2);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:39:19: Unsupported: with statements
39 | qe.rsort(x) with (x == 3);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:59:19: Unsupported: with statements
59 | qv = q.find with (item == 2);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:61:25: Unsupported: with statements
61 | qv = q.find_index with (item == 2); qv.sort;
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:63:25: Unsupported: with statements
63 | qv = q.find_first with (item == 2);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:65:31: Unsupported: with statements
65 | qv = q.find_first_index with (item == 2);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:67:24: Unsupported: with statements
67 | qv = q.find_last with (item == 2);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:69:30: Unsupported: with statements
69 | qv = q.find_last_index with (item == 2);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:72:19: Unsupported: with statements
72 | qv = q.find with (item == 20);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:74:25: Unsupported: with statements
74 | qv = q.find_index with (item == 20); qv.sort;
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:76:25: Unsupported: with statements
76 | qv = q.find_first with (item == 20);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:78:31: Unsupported: with statements
78 | qv = q.find_first_index with (item == 20);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:80:24: Unsupported: with statements
80 | qv = q.find_last with (item == 20);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:82:30: Unsupported: with statements
82 | qv = q.find_last_index with (item == 20);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:98:17: Unsupported: with statements
98 | i = q.sum with (item + 1); do if ((i) !== (32'h11)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", "t/t_queue_method.v",98, (i), (32'h11)); $stop; end while(0);;
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:100:21: Unsupported: with statements
100 | i = q.product with (item + 1); do if ((i) !== (32'h168)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", "t/t_queue_method.v",100, (i), (32'h168)); $stop; end while(0);;
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:107:17: Unsupported: with statements
107 | i = q.and with (item + 1); do if ((i) !== (32'b1001)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", "t/t_queue_method.v",107, (i), (32'b1001)); $stop; end while(0);;
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:109:16: Unsupported: with statements
109 | i = q.or with (item + 1); do if ((i) !== (32'b1111)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", "t/t_queue_method.v",109, (i), (32'b1111)); $stop; end while(0);;
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:111:17: Unsupported: with statements
111 | i = q.xor with (item + 1); do if ((i) !== (32'b0110)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", "t/t_queue_method.v",111, (i), (32'b0110)); $stop; end while(0);;
| ^~~~
%Error: Exiting due to

View File

@ -8,12 +8,16 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(vlt => 1);
scenarios(simulator => 1);
compile(
fails => 1,
fails => $Self->{vlt_all},
expect_filename => $Self->{golden_filename},
);
#execute(
# check_finished => 1,
# );
ok(1);
1;

View File

@ -0,0 +1,120 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2019 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
`define stop $stop
`define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0);
`define checks(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0);
`define checkg(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='%g' exp='%g'\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0);
module t (/*AUTOARG*/);
initial begin
int q[$];
int qe[$];
int qv[$];
int i;
string v;
q = '{1, 2, 2, 4, 3};
v = $sformatf("%p", q); `checks(v, "'{1, 2, 2, 4, 3} ");
// NOT tested: with ... selectors
q.sort;
v = $sformatf("%p", q); `checks(v, "'{1, 2, 2, 3, 4} ");
q.sort with (item == 2);
v = $sformatf("%p", q); `checks(v, "'{4, 3, 1, 2, 2} ");
q.sort(x) with (x == 3);
v = $sformatf("%p", q); `checks(v, "'{2, 1, 2, 4, 3} ");
qe.sort(x) with (x == 3);
v = $sformatf("%p", qe); `checks(v, "'{}");
q.rsort;
v = $sformatf("%p", q); `checks(v, "'{4, 3, 2, 2, 1} ");
q.rsort with (item == 2);
v = $sformatf("%p", q); `checks(v, "'{2, 2, 4, 1, 3} ");
qe.rsort(x) with (x == 3);
v = $sformatf("%p", qe); `checks(v, "'{}");
qv = q.unique;
v = $sformatf("%p", qv); `checks(v, "'{2, 4, 1, 3} ");
qv = qe.unique;
v = $sformatf("%p", qv); `checks(v, "'{}");
qv = q.unique_index; qv.sort;
v = $sformatf("%p", qv); `checks(v, "'{0, 2, 3, 4} ");
q.reverse;
v = $sformatf("%p", q); `checks(v, "'{3, 1, 4, 2, 2} ");
qe.reverse;
v = $sformatf("%p", qe); `checks(v, "'{}");
q.shuffle(); q.sort;
v = $sformatf("%p", q); `checks(v, "'{1, 2, 2, 3, 4} ");
qe.shuffle(); qe.sort;
v = $sformatf("%p", qe); `checks(v, "'{}");
// These require an with clause or are illegal
// TODO add a lint check that with clause is provided
qv = q.find with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{2, 2} ");
qv = q.find_index with (item == 2); qv.sort;
v = $sformatf("%p", qv); `checks(v, "'{1, 2} ");
qv = q.find_first with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{2} ");
qv = q.find_first_index with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{1} ");
qv = q.find_last with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{2} ");
qv = q.find_last_index with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{2} ");
qv = q.find with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}");
qv = q.find_index with (item == 20); qv.sort;
v = $sformatf("%p", qv); `checks(v, "'{}");
qv = q.find_first with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}");
qv = q.find_first_index with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}");
qv = q.find_last with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}");
qv = q.find_last_index with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}");
qv = q.min;
v = $sformatf("%p", qv); `checks(v, "'{1} ");
qv = q.max;
v = $sformatf("%p", qv); `checks(v, "'{4} ");
qv = qe.min;
v = $sformatf("%p", qv); `checks(v, "'{}");
qv = qe.max;
v = $sformatf("%p", qv); `checks(v, "'{}");
// Reduction methods
i = q.sum; `checkh(i, 32'hc);
i = q.sum with (item + 1); `checkh(i, 32'h11);
i = q.product; `checkh(i, 32'h30);
i = q.product with (item + 1); `checkh(i, 32'h168);
i = qe.sum; `checkh(i, 32'h0);
i = qe.product; `checkh(i, 32'h0);
q = '{32'b1100, 32'b1010};
i = q.and; `checkh(i, 32'b1000);
i = q.and with (item + 1); `checkh(i, 32'b1001);
i = q.or; `checkh(i, 32'b1110);
i = q.or with (item + 1); `checkh(i, 32'b1111);
i = q.xor; `checkh(i, 32'b0110);
i = q.xor with (item + 1); `checkh(i, 32'b0110);
i = qe.and; `checkh(i, 32'b0);
i = qe.or; `checkh(i, 32'b0);
i = qe.xor; `checkh(i, 32'b0);
$write("*-* All Finished *-*\n");
$finish;
end
endmodule

View File

@ -0,0 +1,85 @@
%Error-UNSUPPORTED: t/t_queue_slice.v:22:11: Unsupported: Assignment pattern applies against non struct/union data type: 'string[$]'
: ... In instance t
22 | q = '{"q", "b", "c", "d", "e", "f"};
| ^~
%Error-UNSUPPORTED: t/t_queue_slice.v:25:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
25 | q = {"q", "b", "c", "d", "e", "f"};
| ^
%Error-UNSUPPORTED: t/t_queue_slice.v:28:9: Unsupported: Queue .delete(index) method, as is O(n) complexity and slow.
: ... In instance t
28 | q.delete(1);
| ^~~~~~
%Error-UNSUPPORTED: t/t_queue_slice.v:32:9: Unsupported: Queue .insert method, as is O(n) complexity and slow.
: ... In instance t
32 | q.insert(2, "ins2");
| ^~~~~~
%Error-UNSUPPORTED: t/t_queue_slice.v:38:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
38 | q = {"q", "b", "c", "d", "e", "f"};
| ^
%Error: t/t_queue_slice.v:39:12: Illegal range select; type already selected, or bad dimension: data type is 'string[$]'
: ... In instance t
39 | q = q[2:3];
| ^
%Error-UNSUPPORTED: t/t_queue_slice.v:41:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
41 | q = {"q", "b", "c", "d", "e", "f"};
| ^
%Error-UNSUPPORTED: t/t_queue_slice.v:42:15: Unsupported/illegal unbounded ('$') in this context.
: ... In instance t
42 | q = q[3:$];
| ^
%Error: t/t_queue_slice.v:42:15: First value of [a:b] isn't a constant, maybe you want +: or -:
: ... In instance t
42 | q = q[3:$];
| ^
%Error: t/t_queue_slice.v:42:12: Illegal range select; type already selected, or bad dimension: data type is 'string[$]'
: ... In instance t
42 | q = q[3:$];
| ^
%Error-UNSUPPORTED: t/t_queue_slice.v:46:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
46 | q = {q, "f1"};
| ^
%Error-UNSUPPORTED: t/t_queue_slice.v:47:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
47 | q = {q, "f2"};
| ^
%Error-UNSUPPORTED: t/t_queue_slice.v:48:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
48 | q = {"b1", q};
| ^
%Error-UNSUPPORTED: t/t_queue_slice.v:49:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
49 | q = {"b2", q};
| ^
%Error-UNSUPPORTED: t/t_queue_slice.v:50:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
50 | q = {q[0], q[2:$]};
| ^
%Error-UNSUPPORTED: t/t_queue_slice.v:50:22: Unsupported/illegal unbounded ('$') in this context.
: ... In instance t
50 | q = {q[0], q[2:$]};
| ^
%Error: t/t_queue_slice.v:50:22: First value of [a:b] isn't a constant, maybe you want +: or -:
: ... In instance t
50 | q = {q[0], q[2:$]};
| ^
%Error: t/t_queue_slice.v:50:19: Illegal range select; type already selected, or bad dimension: data type is 'string[$]'
: ... In instance t
50 | q = {q[0], q[2:$]};
| ^
%Error-UNSUPPORTED: t/t_queue_slice.v:54:25: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
54 | string ai[$] = { "Foo", "Bar" };
| ^
%Error-UNSUPPORTED: t/t_queue_slice.v:59:14: Unsupported: Assignment pattern applies against non struct/union data type: 'string[$]'
: ... In instance t
59 | q = '{ "BB", "CC" };
| ^~
%Error-UNSUPPORTED: t/t_queue_slice.v:62:14: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
62 | q = { "BB", "CC" };
| ^
%Error: Exiting due to

23
test_regress/t/t_queue_slice.pl Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 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(simulator => 1);
compile(
fails => $Self->{vlt_all},
expect_filename => $Self->{golden_filename},
);
#execute(
# check_finished => 1,
# );
ok(1);
1;

View File

@ -16,7 +16,11 @@ module t (/*AUTOARG*/);
int i;
q.push_front("non-empty");
i = q.size(); `checkh(i, 0);
i = q.size(); `checkh(i, 1);
v = $sformatf("%p", q); `checks(v, "'{\"non-empty\"} ");
q = '{"q", "b", "c", "d", "e", "f"};
v = $sformatf("%p", q); `checks(v, "'{\"q\", \"b\", \"c\", \"d\", \"e\", \"f\"} ");
q = {"q", "b", "c", "d", "e", "f"};
v = $sformatf("%p", q); `checks(v, "'{\"q\", \"b\", \"c\", \"d\", \"e\", \"f\"} ");
@ -28,7 +32,15 @@ module t (/*AUTOARG*/);
q.insert(2, "ins2");
v = q[0]; `checks(v, "ins0");
v = q[2]; `checks(v, "ins2");
v = $sformatf("%p", q); `checks(v, "'{need_update, \"q\", \"b\", \"c\", \"d\", \"e\", \"f\"} ");
v = $sformatf("%p", q); `checks(v, "'{\"ins0\", \"q\", \"ins2\", \"c\", \"d\", \"e\", \"f\"} ");
// Slicing
q = {"q", "b", "c", "d", "e", "f"};
q = q[2:3];
v = $sformatf("%p", q); `checks(v, "'{\"c\", \"d\"} ");
q = {"q", "b", "c", "d", "e", "f"};
q = q[3:$];
v = $sformatf("%p", q); `checks(v, "'{\"d\", \"e\", \"f\"} ");
// Similar using implied notation
q = {q, "f1"}; // push_front
@ -36,7 +48,7 @@ module t (/*AUTOARG*/);
q = {"b1", q}; // push_back
q = {"b2", q}; // push_back
q = {q[0], q[2:$]}; // delete element 1
v = $sformatf("%p", q); `checks(v, "'{need_update, \"q\", \"b\", \"c\", \"d\", \"e\", \"f\"} ");
v = $sformatf("%p", q); `checks(v, "'{\"b2\", \"d\", \"e\", \"f\", \"f1\", \"f2\"} ");
begin
string ai[$] = { "Foo", "Bar" };
@ -52,25 +64,7 @@ module t (/*AUTOARG*/);
v = q.pop_front(); `checks(v, "CC");
end
// Unpacked methods also allowed. Not supported yet.
// find()
// find_index()
// find_first()
// find_first_index()
// find_last()
// find_last_index()
// min()
// max()
// unique()
// unique_index()
// reverse()
// sort()
// rsort()
// shuffle()
// sum()
// product()
// and()
// or()
// xor()
$write("*-* All Finished *-*\n");
$finish;
end
endmodule

View File

@ -1,57 +0,0 @@
%Error-UNSUPPORTED: t/t_queue_unsup_bad.v:21:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
21 | q = {"q", "b", "c", "d", "e", "f"};
| ^
%Error-UNSUPPORTED: t/t_queue_unsup_bad.v:24:9: Unsupported: Queue .delete(index) method, as is O(n) complexity and slow.
: ... In instance t
24 | q.delete(1);
| ^~~~~~
%Error-UNSUPPORTED: t/t_queue_unsup_bad.v:28:9: Unsupported: Queue .insert method, as is O(n) complexity and slow.
: ... In instance t
28 | q.insert(2, "ins2");
| ^~~~~~
%Error-UNSUPPORTED: t/t_queue_unsup_bad.v:34:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
34 | q = {q, "f1"};
| ^
%Error-UNSUPPORTED: t/t_queue_unsup_bad.v:35:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
35 | q = {q, "f2"};
| ^
%Error-UNSUPPORTED: t/t_queue_unsup_bad.v:36:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
36 | q = {"b1", q};
| ^
%Error-UNSUPPORTED: t/t_queue_unsup_bad.v:37:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
37 | q = {"b2", q};
| ^
%Error-UNSUPPORTED: t/t_queue_unsup_bad.v:38:11: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
38 | q = {q[0], q[2:$]};
| ^
%Error-UNSUPPORTED: t/t_queue_unsup_bad.v:38:22: Unsupported/illegal unbounded ('$') in this context.
: ... In instance t
38 | q = {q[0], q[2:$]};
| ^
%Error: t/t_queue_unsup_bad.v:38:22: First value of [a:b] isn't a constant, maybe you want +: or -:
: ... In instance t
38 | q = {q[0], q[2:$]};
| ^
%Error: t/t_queue_unsup_bad.v:38:19: Illegal range select; type already selected, or bad dimension: data type is 'string[$]'
: ... In instance t
38 | q = {q[0], q[2:$]};
| ^
%Error-UNSUPPORTED: t/t_queue_unsup_bad.v:42:25: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
42 | string ai[$] = { "Foo", "Bar" };
| ^
%Error-UNSUPPORTED: t/t_queue_unsup_bad.v:47:14: Unsupported: Assignment pattern applies against non struct/union data type: 'string[$]'
: ... In instance t
47 | q = '{ "BB", "CC" };
| ^~
%Error-UNSUPPORTED: t/t_queue_unsup_bad.v:50:14: Unsupported: Replication to form 'string[$]' data type
: ... In instance t
50 | q = { "BB", "CC" };
| ^
%Error: Exiting due to