Shorter stringify of empty queues, and better queue tests

This commit is contained in:
Wilson Snyder 2020-10-24 18:00:40 -04:00
parent 2f21b3385a
commit 51d1235cda
8 changed files with 243 additions and 243 deletions

View File

@ -202,6 +202,7 @@ public:
// Dumping. Verilog: str = $sformatf("%p", assoc) // Dumping. Verilog: str = $sformatf("%p", assoc)
std::string to_string() const { std::string to_string() const {
if (m_map.empty()) return "'{}"; // No trailing space
std::string out = "'{"; std::string out = "'{";
std::string comma; std::string comma;
for (const auto& i : m_map) { for (const auto& i : m_map) {
@ -393,6 +394,7 @@ public:
// Dumping. Verilog: str = $sformatf("%p", assoc) // Dumping. Verilog: str = $sformatf("%p", assoc)
std::string to_string() const { std::string to_string() const {
if (m_deque.empty()) return "'{}"; // No trailing space
std::string out = "'{"; std::string out = "'{";
std::string comma; std::string comma;
for (const auto& i : m_deque) { for (const auto& i : m_deque) {

View File

@ -7,64 +7,58 @@
%Error: t/t_array_method.v:28:14: Can't find definition of variable: 'x' %Error: t/t_array_method.v:28:14: Can't find definition of variable: 'x'
28 | q.sort(x) with (x == 3); 28 | q.sort(x) with (x == 3);
| ^ | ^
%Error-UNSUPPORTED: t/t_array_method.v:30:18: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:33:15: Unsupported: with statements
30 | qe.sort(x) with (x == 3); 33 | q.rsort with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:35:15: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:47:19: Unsupported: with statements
35 | q.rsort with (item == 2); 47 | qv = q.find with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:37:19: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:49:25: Unsupported: with statements
37 | qe.rsort(x) with (x == 3); 49 | qv = q.find_first with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:57:19: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:51:24: Unsupported: with statements
57 | qv = q.find with (item == 2); 51 | qv = q.find_last with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:59:25: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:54:19: Unsupported: with statements
59 | qv = q.find_index with (item == 2); qv.sort; 54 | qv = q.find with (item == 20);
| ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:56:25: Unsupported: with statements
56 | qv = q.find_first with (item == 20);
| ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:58:24: Unsupported: with statements
58 | qv = q.find_last with (item == 20);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:61:25: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:61:25: Unsupported: with statements
61 | qv = q.find_first with (item == 2); 61 | qi = q.find_index with (item == 2); qi.sort;
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:63:31: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:63:31: Unsupported: with statements
63 | qv = q.find_first_index with (item == 2); 63 | qi = q.find_first_index with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:65:24: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:65:30: Unsupported: with statements
65 | qv = q.find_last with (item == 2); 65 | qi = q.find_last_index with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:67:30: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:68:25: Unsupported: with statements
67 | qv = q.find_last_index with (item == 2); 68 | qi = q.find_index with (item == 20); qi.sort;
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:70:19: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:70:31: Unsupported: with statements
70 | qv = q.find with (item == 20); 70 | qi = q.find_first_index with (item == 20);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:72:25: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:72:30: Unsupported: with statements
72 | qv = q.find_index with (item == 20); qv.sort; 72 | qi = q.find_last_index with (item == 20);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:74:25: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:83:17: Unsupported: with statements
74 | qv = q.find_first with (item == 20); 83 | 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_array_method.v",83, (i), (32'h11)); $stop; end while(0);;
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:76:31: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:85:21: Unsupported: with statements
76 | qv = q.find_first_index with (item == 20); 85 | 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_array_method.v",85, (i), (32'h168)); $stop; end while(0);;
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:78:24: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:89:17: Unsupported: with statements
78 | qv = q.find_last with (item == 20); 89 | 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_array_method.v",89, (i), (32'b1001)); $stop; end while(0);;
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:80:30: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:91:16: Unsupported: with statements
80 | qv = q.find_last_index with (item == 20); 91 | 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_array_method.v",91, (i), (32'b1111)); $stop; end while(0);;
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:96:17: Unsupported: with statements %Error-UNSUPPORTED: t/t_array_method.v:93:17: Unsupported: with statements
96 | 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_array_method.v",96, (i), (32'h11)); $stop; end while(0);; 93 | i = q.xor with (item + 1); do if ((i) !== (32'hb)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", "t/t_array_method.v",93, (i), (32'hb)); $stop; end while(0);;
| ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:98:21: Unsupported: with statements
98 | 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_array_method.v",98, (i), (32'h168)); $stop; end while(0);;
| ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:105:17: Unsupported: with statements
105 | 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_array_method.v",105, (i), (32'b1001)); $stop; end while(0);;
| ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:107:16: Unsupported: with statements
107 | 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_array_method.v",107, (i), (32'b1111)); $stop; end while(0);;
| ^~~~
%Error-UNSUPPORTED: t/t_array_method.v:109:17: Unsupported: with statements
109 | i = q.xor with (item + 1); do if ((i) !== (32'hb)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", "t/t_array_method.v",109, (i), (32'hb)); $stop; end while(0);;
| ^~~~ | ^~~~
%Error: Exiting due to %Error: Exiting due to

View File

@ -11,8 +11,8 @@
module t (/*AUTOARG*/); module t (/*AUTOARG*/);
initial begin initial begin
int q[5]; int q[5];
int qe[$]; int qv[$]; // Value returns
int qv[$]; int qi[$]; // Index returns
int i; int i;
string v; string v;
@ -27,69 +27,56 @@ module t (/*AUTOARG*/);
v = $sformatf("%p", q); `checks(v, "'{4, 3, 1, 2, 2} "); v = $sformatf("%p", q); `checks(v, "'{4, 3, 1, 2, 2} ");
q.sort(x) with (x == 3); q.sort(x) with (x == 3);
v = $sformatf("%p", q); `checks(v, "'{2, 1, 2, 4, 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; q.rsort;
v = $sformatf("%p", q); `checks(v, "'{4, 3, 2, 2, 1} "); v = $sformatf("%p", q); `checks(v, "'{4, 3, 2, 2, 1} ");
q.rsort with (item == 2); q.rsort with (item == 2);
v = $sformatf("%p", q); `checks(v, "'{2, 2, 4, 1, 3} "); 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; qv = q.unique;
v = $sformatf("%p", qv); `checks(v, "'{2, 4, 1, 3} "); v = $sformatf("%p", qv); `checks(v, "'{2, 4, 1, 3} ");
qv = qe.unique; qi = q.unique_index; qi.sort;
v = $sformatf("%p", qv); `checks(v, "'{}"); v = $sformatf("%p", qi); `checks(v, "'{0, 2, 3, 4} ");
qv = q.unique_index; qv.sort;
v = $sformatf("%p", qv); `checks(v, "'{0, 2, 3, 4} ");
q.reverse; q.reverse;
v = $sformatf("%p", q); `checks(v, "'{3, 1, 4, 2, 2} "); v = $sformatf("%p", q); `checks(v, "'{3, 1, 4, 2, 2} ");
qe.reverse;
v = $sformatf("%p", qe); `checks(v, "'{}");
q.shuffle(); q.sort; q.shuffle(); q.sort;
v = $sformatf("%p", q); `checks(v, "'{1, 2, 2, 3, 4} "); 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 // These require an with clause or are illegal
// TODO add a lint check that with clause is provided // TODO add a lint check that with clause is provided
qv = q.find with (item == 2); qv = q.find with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{2, 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); qv = q.find_first with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{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); qv = q.find_last with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{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); qv = q.find with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); 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); qv = q.find_first with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); 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); qv = q.find_last with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); v = $sformatf("%p", qv); `checks(v, "'{}");
qv = q.find_last_index with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); qi = q.find_index with (item == 2); qi.sort;
v = $sformatf("%p", qi); `checks(v, "'{1, 2} ");
qi = q.find_first_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{1} ");
qi = q.find_last_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{2} ");
qi = q.find_index with (item == 20); qi.sort;
v = $sformatf("%p", qi); `checks(v, "'{}");
qi = q.find_first_index with (item == 20);
v = $sformatf("%p", qi); `checks(v, "'{}");
qi = q.find_last_index with (item == 20);
v = $sformatf("%p", qi); `checks(v, "'{}");
qv = q.min; qv = q.min;
v = $sformatf("%p", qv); `checks(v, "'{1} "); v = $sformatf("%p", qv); `checks(v, "'{1} ");
qv = q.max; qv = q.max;
v = $sformatf("%p", qv); `checks(v, "'{4} "); 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 // Reduction methods
i = q.sum; `checkh(i, 32'hc); i = q.sum; `checkh(i, 32'hc);
@ -97,9 +84,6 @@ module t (/*AUTOARG*/);
i = q.product; `checkh(i, 32'h30); i = q.product; `checkh(i, 32'h30);
i = q.product with (item + 1); `checkh(i, 32'h168); 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, 32'b1100, 32'b1010, 32'b1010}; q = '{32'b1100, 32'b1010, 32'b1100, 32'b1010, 32'b1010};
i = q.and; `checkh(i, 32'b1000); i = q.and; `checkh(i, 32'b1000);
i = q.and with (item + 1); `checkh(i, 32'b1001); i = q.and with (item + 1); `checkh(i, 32'b1001);
@ -108,10 +92,6 @@ module t (/*AUTOARG*/);
i = q.xor; `checkh(i, 32'ha); i = q.xor; `checkh(i, 32'ha);
i = q.xor with (item + 1); `checkh(i, 32'hb); i = q.xor with (item + 1); `checkh(i, 32'hb);
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"); $write("*-* All Finished *-*\n");
$finish; $finish;
end end

View File

@ -1,52 +1,52 @@
%Error-UNSUPPORTED: t/t_assoc_method.v:38:19: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:42:19: Unsupported: with statements
38 | qv = q.find with (item == 2); 42 | qv = q.find with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:40:25: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:44:25: Unsupported: with statements
40 | qv = q.find_index with (item == 2); qv.sort; 44 | qv = q.find_first with (item == 2);
| ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:42:25: Unsupported: with statements
42 | qv = q.find_first with (item == 2);
| ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:44:31: Unsupported: with statements
44 | qv = q.find_first_index with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:46:24: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:46:24: Unsupported: with statements
46 | qv = q.find_last with (item == 2); 46 | qv = q.find_last with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:48:30: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:49:19: Unsupported: with statements
48 | qv = q.find_last_index with (item == 2); 49 | qv = q.find with (item == 20);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:51:19: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:51:25: Unsupported: with statements
51 | qv = q.find with (item == 20); 51 | qv = q.find_first with (item == 20);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:53:25: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:53:24: Unsupported: with statements
53 | qv = q.find_index with (item == 20); qv.sort; 53 | qv = q.find_last with (item == 20);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:55:25: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:56:25: Unsupported: with statements
55 | qv = q.find_first with (item == 20); 56 | qi = q.find_index with (item == 2); qi.sort;
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:57:31: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:58:31: Unsupported: with statements
57 | qv = q.find_first_index with (item == 20); 58 | qi = q.find_first_index with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:59:24: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:60:30: Unsupported: with statements
59 | qv = q.find_last with (item == 20); 60 | qi = q.find_last_index with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:61:30: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:63:25: Unsupported: with statements
61 | qv = q.find_last_index with (item == 20); 63 | qi = q.find_index with (item == 20); qi.sort;
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:77:17: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:65:31: Unsupported: with statements
77 | 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_assoc_method.v",77, (i), (32'h11)); $stop; end while(0);; 65 | qi = q.find_first_index with (item == 20);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:79:21: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:67:30: Unsupported: with statements
79 | 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_assoc_method.v",79, (i), (32'h168)); $stop; end while(0);; 67 | qi = q.find_last_index with (item == 20);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:86:17: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:83:17: Unsupported: with statements
86 | 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_assoc_method.v",86, (i), (32'b1001)); $stop; end while(0);; 83 | 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_assoc_method.v",83, (i), (32'h11)); $stop; end while(0);;
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:88:16: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:85:21: Unsupported: with statements
88 | 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_assoc_method.v",88, (i), (32'b1111)); $stop; end while(0);; 85 | 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_assoc_method.v",85, (i), (32'h168)); $stop; end while(0);;
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:90:17: Unsupported: with statements %Error-UNSUPPORTED: t/t_assoc_method.v:92:17: Unsupported: with statements
90 | 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_assoc_method.v",90, (i), (32'b0110)); $stop; end while(0);; 92 | 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_assoc_method.v",92, (i), (32'b1001)); $stop; end while(0);;
| ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:94:16: Unsupported: with statements
94 | 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_assoc_method.v",94, (i), (32'b1111)); $stop; end while(0);;
| ^~~~
%Error-UNSUPPORTED: t/t_assoc_method.v:96:17: Unsupported: with statements
96 | 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_assoc_method.v",96, (i), (32'b0110)); $stop; end while(0);;
| ^~~~ | ^~~~
%Error: Exiting due to %Error: Exiting due to

View File

@ -11,8 +11,9 @@
module t (/*AUTOARG*/); module t (/*AUTOARG*/);
initial begin initial begin
int q[int]; int q[int];
int qe[$]; int qe[int]; // Empty
int qv[$]; int qv[$]; // Value returns
int qi[$]; // Index returns
int i; int i;
string v; string v;
@ -26,40 +27,45 @@ module t (/*AUTOARG*/);
//q.reverse; // Not legal on assoc - see t_assoc_meth_bad //q.reverse; // Not legal on assoc - see t_assoc_meth_bad
//q.shuffle; // Not legal on assoc - see t_assoc_meth_bad //q.shuffle; // Not legal on assoc - see t_assoc_meth_bad
v = $sformatf("%p", qe); `checks(v, "'{}");
qv = q.unique; qv = q.unique;
v = $sformatf("%p", qv); `checks(v, "'{1, 2, 4, 3} "); v = $sformatf("%p", qv); `checks(v, "'{1, 2, 4, 3} ");
qv = qe.unique; qv = qe.unique;
v = $sformatf("%p", qv); `checks(v, "'{}"); v = $sformatf("%p", qv); `checks(v, "'{}");
qv = q.unique_index; qv.sort; qi = q.unique_index; qi.sort;
v = $sformatf("%p", qv); `checks(v, "'{10, 11, 13, 14} "); v = $sformatf("%p", qi); `checks(v, "'{10, 11, 13, 14} ");
qv = qe.unique_index;
v = $sformatf("%p", qv); `checks(v, "'{}");
// These require an with clause or are illegal // These require an with clause or are illegal
// TODO add a lint check that with clause is provided // TODO add a lint check that with clause is provided
qv = q.find with (item == 2); qv = q.find with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{2, 2} "); v = $sformatf("%p", qv); `checks(v, "'{2, 2} ");
qv = q.find_index with (item == 2); qv.sort;
v = $sformatf("%p", qv); `checks(v, "'{11, 12} ");
qv = q.find_first with (item == 2); qv = q.find_first with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{2} "); v = $sformatf("%p", qv); `checks(v, "'{2} ");
qv = q.find_first_index with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{11} ");
qv = q.find_last with (item == 2); qv = q.find_last with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{2} "); v = $sformatf("%p", qv); `checks(v, "'{2} ");
qv = q.find_last_index with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{12} ");
qv = q.find with (item == 20); qv = q.find with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); 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); qv = q.find_first with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); 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); qv = q.find_last with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); v = $sformatf("%p", qv); `checks(v, "'{}");
qv = q.find_last_index with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); qi = q.find_index with (item == 2); qi.sort;
v = $sformatf("%p", qi); `checks(v, "'{11, 12} ");
qi = q.find_first_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{11} ");
qi = q.find_last_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{12} ");
qi = q.find_index with (item == 20); qi.sort;
v = $sformatf("%p", qi); `checks(v, "'{}");
qi = q.find_first_index with (item == 20);
v = $sformatf("%p", qi); `checks(v, "'{}");
qi = q.find_last_index with (item == 20);
v = $sformatf("%p", qi); `checks(v, "'{}");
qv = q.min; qv = q.min;
v = $sformatf("%p", qv); `checks(v, "'{1} "); v = $sformatf("%p", qv); `checks(v, "'{1} ");

View File

@ -40,7 +40,7 @@ module t (/*AUTOARG*/
cyc <= cyc + 1; cyc <= cyc + 1;
begin begin
`checkh(a.size, 0); `checkh(a.size, 0);
v = $sformatf("%p", a); `checks(v, "'{} "); v = $sformatf("%p", a); `checks(v, "'{}");
a = new [3]; a = new [3];
`checkh(a.size, 3); `checkh(a.size, 3);

View File

@ -1,70 +1,70 @@
%Error-UNSUPPORTED: t/t_queue_method.v:28:14: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:28:14: Unsupported: with statements
28 | q.sort with (item == 2); 28 | q.sort with (10 - item);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:30:17: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:30:17: Unsupported: with statements
30 | q.sort(x) with (x == 3); 30 | q.sort(x) with (10 - x);
| ^~~~ | ^~~~
%Error: t/t_queue_method.v:30:14: Can't find definition of variable: 'x' %Error: t/t_queue_method.v:30:14: Can't find definition of variable: 'x'
30 | q.sort(x) with (x == 3); 30 | q.sort(x) with (10 - x);
| ^ | ^
%Error-UNSUPPORTED: t/t_queue_method.v:32:18: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:32:18: Unsupported: with statements
32 | qe.sort(x) with (x == 3); 32 | qe.sort(x) with (10 - x);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:37:15: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:36:15: Unsupported: with statements
37 | q.rsort with (item == 2); 36 | q.rsort with (10 - item);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:39:19: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:38:19: Unsupported: with statements
39 | qe.rsort(x) with (x == 3); 38 | qe.rsort(x) with (10 - x);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:59:19: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:62:19: Unsupported: with statements
59 | qv = q.find with (item == 2); 62 | qv = q.find with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:61:25: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:64:25: Unsupported: with statements
61 | qv = q.find_index with (item == 2); qv.sort; 64 | qv = q.find_first with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:63:25: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:66:24: Unsupported: with statements
63 | qv = q.find_first with (item == 2); 66 | qv = q.find_last with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:65:31: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:69:19: Unsupported: with statements
65 | qv = q.find_first_index with (item == 2); 69 | qv = q.find with (item == 20);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:67:24: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:71:25: Unsupported: with statements
67 | qv = q.find_last with (item == 2); 71 | qv = q.find_first with (item == 20);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:69:30: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:73:24: Unsupported: with statements
69 | qv = q.find_last_index with (item == 2); 73 | qv = q.find_last with (item == 20);
| ^~~~
%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 %Error-UNSUPPORTED: t/t_queue_method.v:76:25: Unsupported: with statements
76 | qv = q.find_first with (item == 20); 76 | qi = q.find_index with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:78:31: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:78:31: Unsupported: with statements
78 | qv = q.find_first_index with (item == 20); 78 | qi = q.find_first_index with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:80:24: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:80:30: Unsupported: with statements
80 | qv = q.find_last with (item == 20); 80 | qi = q.find_last_index with (item == 2);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:82:30: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:83:25: Unsupported: with statements
82 | qv = q.find_last_index with (item == 20); 83 | qi = q.find_index with (item == 20); qi.sort;
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:98:17: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:85:31: 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);; 85 | qi = q.find_first_index with (item == 20);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:100:21: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:87:30: 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);; 87 | qi = q.find_last_index with (item == 20);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:107:17: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:102: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);; 102 | i = q.sum with (item + 1);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:109:16: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:106:21: 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);; 106 | i = q.product with (item + 1);
| ^~~~ | ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:111:17: Unsupported: with statements %Error-UNSUPPORTED: t/t_queue_method.v:117: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);; 117 | i = q.and with (item + 1);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:121:16: Unsupported: with statements
121 | i = q.or with (item + 1);
| ^~~~
%Error-UNSUPPORTED: t/t_queue_method.v:125:17: Unsupported: with statements
125 | i = q.xor with (item + 1);
| ^~~~ | ^~~~
%Error: Exiting due to %Error: Exiting due to

View File

@ -13,106 +13,124 @@
module t (/*AUTOARG*/); module t (/*AUTOARG*/);
initial begin initial begin
int q[$]; int q[$];
int qe[$]; int qe[$]; // Empty
int qv[$]; int qv[$]; // Value returns
int qi[$]; // Index returns
int i; int i;
string v; string v;
q = '{1, 2, 2, 4, 3}; q = '{1, 2, 2, 4, 3};
v = $sformatf("%p", q); `checks(v, "'{1, 2, 2, 4, 3} "); v = $sformatf("%p", q); `checks(v, "'{'h1, 'h2, 'h2, 'h4, 'h3} ");
// NOT tested: with ... selectors
// sort/rsort with clause is the field to use for the sorting
q.sort; q.sort;
v = $sformatf("%p", q); `checks(v, "'{1, 2, 2, 3, 4} "); v = $sformatf("%p", q); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
q.sort with (item == 2); q.sort with (10 - item);
v = $sformatf("%p", q); `checks(v, "'{4, 3, 1, 2, 2} "); v = $sformatf("%p", q); `checks(v, "'{'h4, 'h3, 'h2, 'h2, 'h1} ");
q.sort(x) with (x == 3); q.sort(x) with (10 - x);
v = $sformatf("%p", q); `checks(v, "'{2, 1, 2, 4, 3} "); v = $sformatf("%p", q); `checks(v, "'{'h4, 'h3, 'h2, 'h2, 'h1} ");
qe.sort(x) with (x == 3); qe.sort(x) with (10 - x);
v = $sformatf("%p", qe); `checks(v, "'{}"); v = $sformatf("%p", qe); `checks(v, "'{}");
q.rsort; q.rsort;
v = $sformatf("%p", q); `checks(v, "'{4, 3, 2, 2, 1} "); v = $sformatf("%p", q); `checks(v, "'{'h4, 'h3, 'h2, 'h2, 'h1} ");
q.rsort with (item == 2); q.rsort with (10 - item);
v = $sformatf("%p", q); `checks(v, "'{2, 2, 4, 1, 3} "); v = $sformatf("%p", q); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
qe.rsort(x) with (x == 3); qe.rsort(x) with (10 - x);
v = $sformatf("%p", qe); `checks(v, "'{}"); v = $sformatf("%p", q); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
q = '{2, 2, 4, 1, 3};
qv = q.unique; qv = q.unique;
v = $sformatf("%p", qv); `checks(v, "'{2, 4, 1, 3} "); v = $sformatf("%p", qv); `checks(v, "'{'h2, 'h4, 'h1, 'h3} ");
qv = qe.unique; qv = qe.unique;
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkh(qv.size(), 0);
qv = q.unique_index; qv.sort; qi = q.unique_index; qv.sort;
v = $sformatf("%p", qv); `checks(v, "'{0, 2, 3, 4} "); v = $sformatf("%p", qi); `checks(v, "'{'h0, 'h2, 'h3, 'h4} ");
qi = qe.unique_index;
`checkh(qi.size(), 0);
q.reverse; q.reverse;
v = $sformatf("%p", q); `checks(v, "'{3, 1, 4, 2, 2} "); v = $sformatf("%p", q); `checks(v, "'{'h3, 'h1, 'h4, 'h2, 'h2} ");
qe.reverse; qe.reverse;
v = $sformatf("%p", qe); `checks(v, "'{}"); `checkh(qe.size(), 0);
q.shuffle(); q.sort; q.shuffle(); q.sort;
v = $sformatf("%p", q); `checks(v, "'{1, 2, 2, 3, 4} "); v = $sformatf("%p", q); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
qe.shuffle(); qe.sort; qe.shuffle();
v = $sformatf("%p", qe); `checks(v, "'{}"); `checkh(qe.size(), 0);
// These require an with clause or are illegal // These require an with clause or are illegal
// TODO add a lint check that with clause is provided // TODO add a lint check that with clause is provided
qv = q.find with (item == 2); qv = q.find with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{2, 2} "); v = $sformatf("%p", qv); `checks(v, "'{'h2, 'h2} ");
qv = q.find_index with (item == 2); qv.sort;
v = $sformatf("%p", qv); `checks(v, "'{1, 2} ");
qv = q.find_first with (item == 2); qv = q.find_first with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{2} "); v = $sformatf("%p", qv); `checks(v, "'{'h2} ");
qv = q.find_first_index with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{1} ");
qv = q.find_last with (item == 2); qv = q.find_last with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{2} "); v = $sformatf("%p", qv); `checks(v, "'{'h2} ");
qv = q.find_last_index with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{2} ");
qv = q.find with (item == 20); qv = q.find with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkh(qv.size, 0);
qv = q.find_index with (item == 20); qv.sort;
v = $sformatf("%p", qv); `checks(v, "'{}");
qv = q.find_first with (item == 20); qv = q.find_first with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkh(qv.size, 0);
qv = q.find_first_index with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}");
qv = q.find_last with (item == 20); qv = q.find_last with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkh(qv.size, 0);
qv = q.find_last_index with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); qi = q.find_index with (item == 2);
qi.sort; v = $sformatf("%p", qi); `checks(v, "'{'h1, 'h2} ");
qi = q.find_first_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{'h1} ");
qi = q.find_last_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{'h2} ");
qi = q.find_index with (item == 20); qi.sort;
`checkh(qi.size, 0);
qi = q.find_first_index with (item == 20);
`checkh(qi.size, 0);
qi = q.find_last_index with (item == 20);
`checkh(qi.size, 0);
qv = q.min; qv = q.min;
v = $sformatf("%p", qv); `checks(v, "'{1} "); v = $sformatf("%p", qv); `checks(v, "'{'h1} ");
qv = q.max; qv = q.max;
v = $sformatf("%p", qv); `checks(v, "'{4} "); v = $sformatf("%p", qv); `checks(v, "'{'h4} ");
qv = qe.min; qv = qe.min;
v = $sformatf("%p", qv); `checks(v, "'{}"); v = $sformatf("%p", qv); `checks(v, "'{}");
qv = qe.max; qv = qe.max;
v = $sformatf("%p", qv); `checks(v, "'{}"); v = $sformatf("%p", qv); `checks(v, "'{}");
// Reduction methods // 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 = q.sum; `checkh(i, 32'hc); i = qe.sum;
i = q.sum with (item + 1); `checkh(i, 32'h11); `checkh(i, 32'h0);
i = q.product; `checkh(i, 32'h30); i = qe.product;
i = q.product with (item + 1); `checkh(i, 32'h168); `checkh(i, 32'h0);
i = qe.sum; `checkh(i, 32'h0);
i = qe.product; `checkh(i, 32'h0);
q = '{32'b1100, 32'b1010}; q = '{32'b1100, 32'b1010};
i = q.and; `checkh(i, 32'b1000); i = q.and;
i = q.and with (item + 1); `checkh(i, 32'b1001); `checkh(i, 32'b1000);
i = q.or; `checkh(i, 32'b1110); i = q.and with (item + 1);
i = q.or with (item + 1); `checkh(i, 32'b1111); `checkh(i, 32'b1001);
i = q.xor; `checkh(i, 32'b0110); i = q.or;
i = q.xor with (item + 1); `checkh(i, 32'b0110); `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.and;
i = qe.or; `checkh(i, 32'b0); `checkh(i, 32'b0);
i = qe.xor; `checkh(i, 32'b0); i = qe.or;
`checkh(i, 32'b0);
i = qe.xor;
`checkh(i, 32'b0);
$write("*-* All Finished *-*\n"); $write("*-* All Finished *-*\n");
$finish; $finish;