Tests: Add checkp macro. No test functionality change.

This commit is contained in:
Wilson Snyder 2024-07-20 06:51:50 -04:00
parent 2bd2b9324f
commit b7345eb5d5
18 changed files with 189 additions and 197 deletions

View File

@ -6,7 +6,7 @@
`define stop $stop `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 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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
module t (/*AUTOARG*/); module t (/*AUTOARG*/);
initial begin initial begin
@ -17,65 +17,65 @@ module t (/*AUTOARG*/);
string v; string v;
q = '{1, 2, 2, 4, 3}; q = '{1, 2, 2, 4, 3};
v = $sformatf("%p", q); `checks(v, "'{'h1, 'h2, 'h2, 'h4, 'h3} "); `checkp(q, "'{'h1, 'h2, 'h2, 'h4, 'h3} ");
// NOT tested: with ... selectors // NOT tested: with ... selectors
q.sort; q.sort;
v = $sformatf("%p", q); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} "); `checkp(q, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
q.sort with (item == 2); q.sort with (item == 2);
v = $sformatf("%p", q); `checks(v, "'{'h1, 'h3, 'h4, 'h2, 'h2} "); `checkp(q, "'{'h1, 'h3, 'h4, 'h2, 'h2} ");
q.sort(x) with (x == 3); q.sort(x) with (x == 3);
v = $sformatf("%p", q); `checks(v, "'{'h1, 'h4, 'h2, 'h2, 'h3} "); `checkp(q, "'{'h1, 'h4, 'h2, 'h2, 'h3} ");
q.rsort; q.rsort;
v = $sformatf("%p", q); `checks(v, "'{'h4, 'h3, 'h2, 'h2, 'h1} "); `checkp(q, "'{'h4, 'h3, 'h2, 'h2, 'h1} ");
q.rsort with (item == 2); q.rsort with (item == 2);
v = $sformatf("%p", q); `checks(v, "'{'h2, 'h2, 'h4, 'h3, 'h1} "); `checkp(q, "'{'h2, 'h2, 'h4, 'h3, 'h1} ");
qv = q.unique; qv = q.unique;
v = $sformatf("%p", qv); `checks(v, "'{'h2, 'h4, 'h3, 'h1} "); `checkp(qv, "'{'h2, 'h4, 'h3, 'h1} ");
qi = q.unique_index; qi.sort; qi = q.unique_index; qi.sort;
v = $sformatf("%p", qi); `checks(v, "'{'h0, 'h2, 'h3, 'h4} "); `checkp(qi, "'{'h0, 'h2, 'h3, 'h4} ");
q.reverse; q.reverse;
v = $sformatf("%p", q); `checks(v, "'{'h1, 'h3, 'h4, 'h2, 'h2} "); `checkp(q, "'{'h1, 'h3, 'h4, 'h2, 'h2} ");
q.shuffle(); q.sort; q.shuffle(); q.sort;
v = $sformatf("%p", q); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} "); `checkp(q, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
// 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, "'{'h2, 'h2} "); `checkp(qv, "'{'h2, 'h2} ");
qv = q.find_first with (item == 2); qv = q.find_first with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{'h2} "); `checkp(qv, "'{'h2} ");
qv = q.find_last with (item == 2); qv = q.find_last with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{'h2} "); `checkp(qv, "'{'h2} ");
qv = q.find with (item == 20); qv = q.find with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qv = q.find_first with (item == 20); qv = q.find_first with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qv = q.find_last with (item == 20); qv = q.find_last with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qi = q.find_index with (item == 2); qi.sort; qi = q.find_index with (item == 2); qi.sort;
v = $sformatf("%p", qi); `checks(v, "'{'h1, 'h2} "); `checkp(qi, "'{'h1, 'h2} ");
qi = q.find_first_index with (item == 2); qi = q.find_first_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{'h1} "); `checkp(qi, "'{'h1} ");
qi = q.find_last_index with (item == 2); qi = q.find_last_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{'h2} "); `checkp(qi, "'{'h2} ");
qi = q.find_index with (item == 20); qi.sort; qi = q.find_index with (item == 20); qi.sort;
v = $sformatf("%p", qi); `checks(v, "'{}"); `checkp(qi, "'{}");
qi = q.find_first_index with (item == 20); qi = q.find_first_index with (item == 20);
v = $sformatf("%p", qi); `checks(v, "'{}"); `checkp(qi, "'{}");
qi = q.find_last_index with (item == 20); qi = q.find_last_index with (item == 20);
v = $sformatf("%p", qi); `checks(v, "'{}"); `checkp(qi, "'{}");
qv = q.min; qv = q.min;
v = $sformatf("%p", qv); `checks(v, "'{'h1} "); `checkp(qv, "'{'h1} ");
qv = q.max; qv = q.max;
v = $sformatf("%p", qv); `checks(v, "'{'h4} "); `checkp(qv, "'{'h4} ");
// Reduction methods // Reduction methods

View File

@ -1,21 +1,21 @@
%Error: t/t_array_method_unsup.v:24:17: 'with' not legal on this method %Error: t/t_array_method_unsup.v:23:17: 'with' not legal on this method
: ... note: In instance 't' : ... note: In instance 't'
24 | 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_unsup.v",24, (i), (32'h11)); $stop; end while(0);; 23 | 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_unsup.v",23, (i), (32'h11)); $stop; end while(0);;
| ^~~~ | ^~~~
%Error: t/t_array_method_unsup.v:25:21: 'with' not legal on this method %Error: t/t_array_method_unsup.v:24:21: 'with' not legal on this method
: ... note: In instance 't' : ... note: In instance 't'
25 | 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_unsup.v",25, (i), (32'h168)); $stop; end while(0);; 24 | 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_unsup.v",24, (i), (32'h168)); $stop; end while(0);;
| ^~~~ | ^~~~
%Error: t/t_array_method_unsup.v:28:17: 'with' not legal on this method %Error: t/t_array_method_unsup.v:27:17: 'with' not legal on this method
: ... note: In instance 't' : ... note: In instance 't'
28 | 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_unsup.v",28, (i), (32'b1001)); $stop; end while(0);; 27 | 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_unsup.v",27, (i), (32'b1001)); $stop; end while(0);;
| ^~~~ | ^~~~
%Error: t/t_array_method_unsup.v:29:16: 'with' not legal on this method %Error: t/t_array_method_unsup.v:28:16: 'with' not legal on this method
: ... note: In instance 't' : ... note: In instance 't'
29 | 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_unsup.v",29, (i), (32'b1111)); $stop; end while(0);; 28 | 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_unsup.v",28, (i), (32'b1111)); $stop; end while(0);;
| ^~~~ | ^~~~
%Error: t/t_array_method_unsup.v:30:17: 'with' not legal on this method %Error: t/t_array_method_unsup.v:29:17: 'with' not legal on this method
: ... note: In instance 't' : ... note: In instance 't'
30 | 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_unsup.v",30, (i), (32'hb)); $stop; end while(0);; 29 | 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_unsup.v",29, (i), (32'hb)); $stop; end while(0);;
| ^~~~ | ^~~~
%Error: Exiting due to %Error: Exiting due to

View File

@ -6,7 +6,7 @@
`define stop $stop `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 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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
module t (/*AUTOARG*/); module t (/*AUTOARG*/);
initial begin initial begin
@ -14,10 +14,9 @@ module t (/*AUTOARG*/);
int qv[$]; // Value returns int qv[$]; // Value returns
int qi[$]; // Index returns int qi[$]; // Index returns
int i; int i;
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} "); `checkp(q, "'{1, 2, 2, 4, 3} ");
// Reduction methods // Reduction methods

View File

@ -8,6 +8,7 @@
`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 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 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); `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);
`define checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
module t (/*AUTOARG*/ module t (/*AUTOARG*/
// Inputs // Inputs
@ -44,7 +45,7 @@ module t (/*AUTOARG*/
i = a.last(k); `checkh(i, 1); `checks(k, 4'd3); i = a.last(k); `checkh(i, 1); `checks(k, 4'd3);
i = a.prev(k); `checkh(i, 1); `checks(k, 4'd2); i = a.prev(k); `checkh(i, 1); `checks(k, 4'd2);
i = a.prev(k); `checkh(i, 0); i = a.prev(k); `checkh(i, 0);
v = $sformatf("%p", a); `checks(v, "'{'h2:\"bared\", 'h3:\"fooed\"} "); `checkp(a, "'{'h2:\"bared\", 'h3:\"fooed\"} ");
a.first(k); `checks(k, 4'd2); a.first(k); `checks(k, 4'd2);
a.next(k); `checks(k, 4'd3); a.next(k); `checks(k, 4'd3);
@ -79,8 +80,8 @@ module t (/*AUTOARG*/
i = a.last(k); `checkh(i, 1); `checks(k, "foo"); i = a.last(k); `checkh(i, 1); `checks(k, "foo");
i = a.prev(k); `checkh(i, 1); `checks(k, "bar"); i = a.prev(k); `checkh(i, 1); `checks(k, "bar");
i = a.prev(k); `checkh(i, 0); i = a.prev(k); `checkh(i, 0);
v = $sformatf("%p", a["foo"]); `checks(v, "\"fooed\""); `checkp(a["foo"], "\"fooed\"");
v = $sformatf("%p", a); `checks(v, "'{\"bar\":\"bared\", \"foo\":\"fooed\"} "); `checkp(a, "'{\"bar\":\"bared\", \"foo\":\"fooed\"} ");
a.delete("bar"); a.delete("bar");
i = a.size(); `checkh(i, 1); i = a.size(); `checkh(i, 1);

View File

@ -6,7 +6,7 @@
`define stop $stop `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 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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
module t (/*AUTOARG*/); module t (/*AUTOARG*/);
typedef struct { int x, y; } point; typedef struct { int x, y; } point;
@ -18,10 +18,9 @@ module t (/*AUTOARG*/);
point points_q[int]; point points_q[int];
point points_qv[$]; point points_qv[$];
int i; int i;
string v;
q = '{10:1, 11:2, 12:2, 13:4, 14:3}; q = '{10:1, 11:2, 12:2, 13:4, 14:3};
v = $sformatf("%p", q); `checks(v, "'{'ha:'h1, 'hb:'h2, 'hc:'h2, 'hd:'h4, 'he:'h3} "); `checkp(q, "'{'ha:'h1, 'hb:'h2, 'hc:'h2, 'hd:'h4, 'he:'h3} ");
// NOT tested: with ... selectors // NOT tested: with ... selectors
@ -30,15 +29,15 @@ 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, "'{}"); `checkp(qe, "'{}");
qv = q.unique; qv = q.unique;
v = $sformatf("%p", qv); `checks(v, "'{'h1, 'h2, 'h4, 'h3} "); `checkp(qv, "'{'h1, 'h2, 'h4, 'h3} ");
qv = qe.unique; qv = qe.unique;
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qi = q.unique_index; qi.sort; qi = q.unique_index; qi.sort;
v = $sformatf("%p", qi); `checks(v, "'{'ha, 'hb, 'hd, 'he} "); `checkp(qi, "'{'ha, 'hb, 'hd, 'he} ");
qi = qe.unique_index; qi = qe.unique_index;
v = $sformatf("%p", qi); `checks(v, "'{}"); `checkp(qi, "'{}");
points_q[0] = point'{1, 2}; points_q[0] = point'{1, 2};
points_q[1] = point'{2, 4}; points_q[1] = point'{2, 4};
@ -48,61 +47,61 @@ module t (/*AUTOARG*/);
`checkh(points_qv.size, 2); `checkh(points_qv.size, 2);
qi = points_q.unique_index(p) with (p.x + p.y); qi = points_q.unique_index(p) with (p.x + p.y);
qi.sort; qi.sort;
v = $sformatf("%p", qi); `checks(v, "'{'h0, 'h1, 'h5} "); `checkp(qi, "'{'h0, 'h1, 'h5} ");
// 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, "'{'h2, 'h2} "); `checkp(qv, "'{'h2, 'h2} ");
qv = q.find_first with (item == 2); qv = q.find_first with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{'h2} "); `checkp(qv, "'{'h2} ");
qv = q.find_last with (item == 2); qv = q.find_last with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{'h2} "); `checkp(qv, "'{'h2} ");
qv = q.find with (item == 20); qv = q.find with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qv = q.find_first with (item == 20); qv = q.find_first with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qv = q.find_last with (item == 20); qv = q.find_last with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qi = q.find_index with (item == 2); qi.sort; qi = q.find_index with (item == 2); qi.sort;
v = $sformatf("%p", qi); `checks(v, "'{'hb, 'hc} "); `checkp(qi, "'{'hb, 'hc} ");
qi = q.find_first_index with (item == 2); qi = q.find_first_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{'hb} "); `checkp(qi, "'{'hb} ");
qi = q.find_last_index with (item == 2); qi = q.find_last_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{'hc} "); `checkp(qi, "'{'hc} ");
qi = q.find_index with (item == 20); qi.sort; qi = q.find_index with (item == 20); qi.sort;
v = $sformatf("%p", qi); `checks(v, "'{}"); `checkp(qi, "'{}");
qi = q.find_first_index with (item == 20); qi = q.find_first_index with (item == 20);
v = $sformatf("%p", qi); `checks(v, "'{}"); `checkp(qi, "'{}");
qi = q.find_last_index with (item == 20); qi = q.find_last_index with (item == 20);
v = $sformatf("%p", qi); `checks(v, "'{}"); `checkp(qi, "'{}");
qi = q.find_index with (item.index == 12); qi = q.find_index with (item.index == 12);
v = $sformatf("%p", qi); `checks(v, "'{'hc} "); `checkp(qi, "'{'hc} ");
qi = q.find with (item.index == 12); qi = q.find with (item.index == 12);
v = $sformatf("%p", qi); `checks(v, "'{'h2} "); `checkp(qi, "'{'h2} ");
qv = q.min; qv = q.min;
v = $sformatf("%p", qv); `checks(v, "'{'h1} "); `checkp(qv, "'{'h1} ");
points_qv = points_q.min(p) with (p.x + p.y); points_qv = points_q.min(p) with (p.x + p.y);
if (points_qv[0].x != 1 || points_qv[0].y != 2) $stop; if (points_qv[0].x != 1 || points_qv[0].y != 2) $stop;
qv = q.max; qv = q.max;
v = $sformatf("%p", qv); `checks(v, "'{'h4} "); `checkp(qv, "'{'h4} ");
points_qv = points_q.max(p) with (p.x + p.y); points_qv = points_q.max(p) with (p.x + p.y);
if (points_qv[0].x != 2 || points_qv[0].y != 4) $stop; if (points_qv[0].x != 2 || points_qv[0].y != 4) $stop;
qv = qe.min; qv = qe.min;
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qv = qe.min(x) with (x + 1); qv = qe.min(x) with (x + 1);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qv = qe.max; qv = qe.max;
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qv = qe.max(x) with (x + 1); qv = qe.max(x) with (x + 1);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
// Reduction methods // Reduction methods

View File

@ -6,7 +6,7 @@
`define stop $stop `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 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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
module t (/*AUTOARG*/); module t (/*AUTOARG*/);
initial begin initial begin
@ -18,7 +18,7 @@ module t (/*AUTOARG*/);
string v; string v;
q = '{"a":1, "b":2, "c":2, "d":4, "e":3}; q = '{"a":1, "b":2, "c":2, "d":4, "e":3};
v = $sformatf("%p", q); `checks(v, "'{\"a\":'h1, \"b\":'h2, \"c\":'h2, \"d\":'h4, \"e\":'h3} "); `checkp(q, "'{\"a\":'h1, \"b\":'h2, \"c\":'h2, \"d\":'h4, \"e\":'h3} ");
// NOT tested: with ... selectors // NOT tested: with ... selectors
@ -27,42 +27,42 @@ 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, "'{}"); `checkp(qe, "'{}");
qv = q.unique; qv = q.unique;
v = $sformatf("%p", qv); `checks(v, "'{'h1, 'h2, 'h4, 'h3} "); `checkp(qv, "'{'h1, 'h2, 'h4, 'h3} ");
qv = qe.unique; qv = qe.unique;
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
//q.unique_index; // Not legal on wildcard assoc - see t_assoc_wildcard_bad //q.unique_index; // Not legal on wildcard assoc - see t_assoc_wildcard_bad
// These require an with clause or are illegal // These require an with clause or are illegal
qv = q.find with (item == 2); qv = q.find with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{'h2, 'h2} "); `checkp(qv, "'{'h2, 'h2} ");
qv = q.find_first with (item == 2); qv = q.find_first with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{'h2} "); `checkp(qv, "'{'h2} ");
qv = q.find_last with (item == 2); qv = q.find_last with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{'h2} "); `checkp(qv, "'{'h2} ");
qv = q.find with (item == 20); qv = q.find with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qv = q.find_first with (item == 20); qv = q.find_first with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qv = q.find_last with (item == 20); qv = q.find_last with (item == 20);
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
//q.find_index; // Not legal on wildcard assoc - see t_assoc_wildcard_bad //q.find_index; // Not legal on wildcard assoc - see t_assoc_wildcard_bad
//q.find_first_index; // Not legal on wildcard assoc - see t_assoc_wildcard_bad //q.find_first_index; // Not legal on wildcard assoc - see t_assoc_wildcard_bad
//q.find_last_index; // Not legal on wildcard assoc - see t_assoc_wildcard_bad //q.find_last_index; // Not legal on wildcard assoc - see t_assoc_wildcard_bad
qv = q.min; qv = q.min;
v = $sformatf("%p", qv); `checks(v, "'{'h1} "); `checkp(qv, "'{'h1} ");
qv = q.max; qv = q.max;
v = $sformatf("%p", qv); `checks(v, "'{'h4} "); `checkp(qv, "'{'h4} ");
qv = qe.min; qv = qe.min;
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qv = qe.max; qv = qe.max;
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
// Reduction methods // Reduction methods

View File

@ -5,7 +5,7 @@
// SPDX-License-Identifier: CC0-1.0 // SPDX-License-Identifier: CC0-1.0
`define stop $stop `define stop $stop
`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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
// See also t_class_param_mod.v // See also t_class_param_mod.v
@ -199,8 +199,8 @@ module t (/*AUTOARG*/);
if (c4.member != 4'ha) $stop; if (c4.member != 4'ha) $stop;
if (c12.get_member() != 12'haaa) $stop; if (c12.get_member() != 12'haaa) $stop;
if (c4.get_member() != 4'ha) $stop; if (c4.get_member() != 4'ha) $stop;
`checks($sformatf("%p", c12), "'{member:'haaa}"); `checkp(c12, "'{member:'haaa}");
`checks($sformatf("%p", c4), "'{member:'ha}"); `checkp(c4, "'{member:'ha}");
if ($bits(src_logic.field) != 1) $stop; if ($bits(src_logic.field) != 1) $stop;
if ($bits(src_int.field) != 32) $stop; if ($bits(src_int.field) != 32) $stop;

View File

@ -5,7 +5,7 @@
// SPDX-License-Identifier: CC0-1.0 // SPDX-License-Identifier: CC0-1.0
`define stop $stop `define stop $stop
`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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
// See also t_class_param.v // See also t_class_param.v
@ -105,8 +105,8 @@ endclass
if (c4.member != 4'ha) $stop; if (c4.member != 4'ha) $stop;
if (c12.get_member() != 12'haaa) $stop; if (c12.get_member() != 12'haaa) $stop;
if (c4.get_member() != 4'ha) $stop; if (c4.get_member() != 4'ha) $stop;
`checks($sformatf("%p", c12), "'{member:'haaa}"); `checkp(c12, "'{member:'haaa}");
`checks($sformatf("%p", c4), "'{member:'ha}"); `checkp(c4, "'{member:'ha}");
if ($bits(src_logic.field) != 1) $stop; if ($bits(src_logic.field) != 1) $stop;
if ($bits(src_int.field) != 32) $stop; if ($bits(src_int.field) != 32) $stop;

View File

@ -5,7 +5,7 @@
// SPDX-License-Identifier: CC0-1.0 // SPDX-License-Identifier: CC0-1.0
`define stop $stop `define stop $stop
`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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
// See also t_class_param_mod.v // See also t_class_param_mod.v
@ -93,8 +93,8 @@ module t (/*AUTOARG*/);
if (c4.member != 4'ha) $stop; if (c4.member != 4'ha) $stop;
if (c12.get_member() != 12'haaa) $stop; if (c12.get_member() != 12'haaa) $stop;
if (c4.get_member() != 4'ha) $stop; if (c4.get_member() != 4'ha) $stop;
`checks($sformatf("%p", c12), "'{member:'haaa}"); `checkp(c12, "'{member:'haaa}");
`checks($sformatf("%p", c4), "'{member:'ha}"); `checkp(c4, "'{member:'ha}");
$write("*-* All Finished *-*\n"); $write("*-* All Finished *-*\n");
$finish; $finish;

View File

@ -7,6 +7,7 @@
`define stop $stop `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 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 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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
module t (/*AUTOARG*/ module t (/*AUTOARG*/
// Inputs // Inputs
@ -17,7 +18,6 @@ module t (/*AUTOARG*/
integer cyc = 0; integer cyc = 0;
integer i; integer i;
string v;
// verilator lint_off UNUSED // verilator lint_off UNUSED
integer unused[]; integer unused[];
@ -42,7 +42,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, "'{}"); `checkp(a, "'{}");
`checkh(s.size, 3); `checkh(s.size, 3);
`checks(s[0], "hello"); `checks(s[0], "hello");
@ -57,7 +57,7 @@ module t (/*AUTOARG*/
`checkh(a[0], 10); `checkh(a[0], 10);
`checkh(a[1], 11); `checkh(a[1], 11);
`checkh(a[2], 12); `checkh(a[2], 12);
v = $sformatf("%p", a); `checks(v, "'{'ha, 'hb, 'hc} "); `checkp(a, "'{'ha, 'hb, 'hc} ");
a.delete; a.delete;
`checkh(a.size, 0); `checkh(a.size, 0);

View File

@ -7,6 +7,7 @@
`define stop $stop `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 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 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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end 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); `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);
@ -21,56 +22,55 @@ module t (/*AUTOARG*/);
int qvunused[$]; // Value returns (unused) int qvunused[$]; // Value returns (unused)
int qi[$]; // Index returns int qi[$]; // Index returns
int i; int i;
string v;
d = '{1, 2, 2, 4, 3}; d = '{1, 2, 2, 4, 3};
v = $sformatf("%p", d); `checks(v, "'{'h1, 'h2, 'h2, 'h4, 'h3} "); `checkp(d, "'{'h1, 'h2, 'h2, 'h4, 'h3} ");
d = {1, 2, 2, 4, 3}; d = {1, 2, 2, 4, 3};
v = $sformatf("%p", d); `checks(v, "'{'h1, 'h2, 'h2, 'h4, 'h3} "); `checkp(d, "'{'h1, 'h2, 'h2, 'h4, 'h3} ");
// sort/rsort with clause is the field to use for the sorting // sort/rsort with clause is the field to use for the sorting
d.sort; d.sort;
v = $sformatf("%p", d); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} "); `checkp(d, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
d.sort with (10 - item); d.sort with (10 - item);
v = $sformatf("%p", d); `checks(v, "'{'h4, 'h3, 'h2, 'h2, 'h1} "); `checkp(d, "'{'h4, 'h3, 'h2, 'h2, 'h1} ");
d.sort(x) with (10 - x); d.sort(x) with (10 - x);
v = $sformatf("%p", d); `checks(v, "'{'h4, 'h3, 'h2, 'h2, 'h1} "); `checkp(d, "'{'h4, 'h3, 'h2, 'h2, 'h1} ");
de.sort(x) with (10 - x); de.sort(x) with (10 - x);
v = $sformatf("%p", de); `checks(v, "'{}"); `checkp(de, "'{}");
d.rsort; d.rsort;
v = $sformatf("%p", d); `checks(v, "'{'h4, 'h3, 'h2, 'h2, 'h1} "); `checkp(d, "'{'h4, 'h3, 'h2, 'h2, 'h1} ");
d.rsort with (10 - item); d.rsort with (10 - item);
v = $sformatf("%p", d); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} "); `checkp(d, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
de.rsort(x) with (10 - x); de.rsort(x) with (10 - x);
v = $sformatf("%p", d); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} "); `checkp(d, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
d = '{2, 2, 4, 1, 3}; d = '{2, 2, 4, 1, 3};
qv = d.unique; qv = d.unique;
v = $sformatf("%p", qv); `checks(v, "'{'h2, 'h4, 'h1, 'h3} "); `checkp(qv, "'{'h2, 'h4, 'h1, 'h3} ");
qv = de.unique; qv = de.unique;
`checkh(qv.size(), 0); `checkh(qv.size(), 0);
qi = d.unique_index; qv.sort; qi = d.unique_index; qv.sort;
v = $sformatf("%p", qi); `checks(v, "'{'h0, 'h2, 'h3, 'h4} "); `checkp(qi, "'{'h0, 'h2, 'h3, 'h4} ");
qi = de.unique_index; qi = de.unique_index;
`checkh(qi.size(), 0); `checkh(qi.size(), 0);
d.reverse; d.reverse;
v = $sformatf("%p", d); `checks(v, "'{'h3, 'h1, 'h4, 'h2, 'h2} "); `checkp(d, "'{'h3, 'h1, 'h4, 'h2, 'h2} ");
de.reverse; de.reverse;
`checkh(de.size(), 0); `checkh(de.size(), 0);
d.shuffle(); d.sort; d.shuffle(); d.sort;
v = $sformatf("%p", d); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} "); `checkp(d, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
de.shuffle(); de.shuffle();
`checkh(de.size(), 0); `checkh(de.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 = d.find with (item == 2); qv = d.find with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{'h2, 'h2} "); `checkp(qv, "'{'h2, 'h2} ");
qv = d.find_first with (item == 2); qv = d.find_first with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{'h2} "); `checkp(qv, "'{'h2} ");
qv = d.find_last with (item == 2); qv = d.find_last with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{'h2} "); `checkp(qv, "'{'h2} ");
qv = d.find with (item == 20); qv = d.find with (item == 20);
`checkh(qv.size, 0); `checkh(qv.size, 0);
@ -83,15 +83,15 @@ module t (/*AUTOARG*/);
qvunused = d.find with (item == 20); qvunused = d.find with (item == 20);
qi = d.find_index with (item == 2); qi = d.find_index with (item == 2);
qi.sort; v = $sformatf("%p", qi); `checks(v, "'{'h1, 'h2} "); qi.sort; `checkp(qi, "'{'h1, 'h2} ");
qi = d.find_first_index with (item == 2); qi = d.find_first_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{'h1} "); `checkp(qi, "'{'h1} ");
qi = d.find_last_index with (item == 2); qi = d.find_last_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{'h2} "); `checkp(qi, "'{'h2} ");
i = 2; i = 2;
qi = d.find_index with (item == i); qi = d.find_index with (item == i);
qi.sort; v = $sformatf("%p", qi); `checks(v, "'{'h1, 'h2} "); qi.sort; `checkp(qi, "'{'h1, 'h2} ");
qi = d.find_index with (item == 20); qi.sort; qi = d.find_index with (item == 20); qi.sort;
`checkh(qi.size, 0); `checkh(qi.size, 0);
@ -101,16 +101,16 @@ module t (/*AUTOARG*/);
`checkh(qi.size, 0); `checkh(qi.size, 0);
qi = d.find_index with (item.index == 2); qi = d.find_index with (item.index == 2);
v = $sformatf("%p", qi); `checks(v, "'{'h2} "); `checkp(qi, "'{'h2} ");
qv = d.min; qv = d.min;
v = $sformatf("%p", qv); `checks(v, "'{'h1} "); `checkp(qv, "'{'h1} ");
qv = d.max; qv = d.max;
v = $sformatf("%p", qv); `checks(v, "'{'h4} "); `checkp(qv, "'{'h4} ");
qv = de.min; qv = de.min;
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qv = de.max; qv = de.max;
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
// Reduction methods // Reduction methods
i = d.sum; i = d.sum;

View File

@ -8,6 +8,7 @@
`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 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 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); `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);
`define checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
module t (/*AUTOARG*/ module t (/*AUTOARG*/
// Inputs // Inputs
@ -134,8 +135,8 @@ module t (/*AUTOARG*/
v = q[4]; `checks(v, ""); v = q[4]; `checks(v, "");
//Unsup: `checkh(q[$], "b2"); //Unsup: `checkh(q[$], "b2");
v = $sformatf("%p", q); `checks(v, "'{\"f2\", \"f1\", \"b1\", \"b2\"} "); `checkp(q, "'{\"f2\", \"f1\", \"b1\", \"b2\"} ");
v = $sformatf("%p", p); `checks(v, "'{}"); `checkp(p, "'{}");
//Unsup: q.delete(1); //Unsup: q.delete(1);
//Unsup: v = q[1]; `checks(v, "b1"); //Unsup: v = q[1]; `checks(v, "b1");

View File

@ -7,6 +7,7 @@
`define stop $stop `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 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 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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end 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); `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);
@ -27,7 +28,6 @@ module t (/*AUTOARG*/);
int qvunused[$]; // Value returns (unused) int qvunused[$]; // Value returns (unused)
int qi[$]; // Index returns int qi[$]; // Index returns
int i; int i;
string v;
string string_q[$]; string string_q[$];
string string_qv[$]; string string_qv[$];
point_3d points_q[$]; // Same as q and qv, but complex value type point_3d points_q[$]; // Same as q and qv, but complex value type
@ -53,27 +53,27 @@ module t (/*AUTOARG*/);
string_q.push_back("b"); string_q.push_back("b");
q = '{1, 2, 2, 4, 3}; q = '{1, 2, 2, 4, 3};
v = $sformatf("%p", q); `checks(v, "'{'h1, 'h2, 'h2, 'h4, 'h3} "); `checkp(q, "'{'h1, 'h2, 'h2, 'h4, 'h3} ");
// sort/rsort with clause is the field to use for the sorting // sort/rsort with clause is the field to use for the sorting
q.sort; q.sort;
v = $sformatf("%p", q); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} "); `checkp(q, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
q.sort with (10 - item); q.sort with (10 - item);
v = $sformatf("%p", q); `checks(v, "'{'h4, 'h3, 'h2, 'h2, 'h1} "); `checkp(q, "'{'h4, 'h3, 'h2, 'h2, 'h1} ");
q.sort(x) with (10 - x); q.sort(x) with (10 - x);
v = $sformatf("%p", q); `checks(v, "'{'h4, 'h3, 'h2, 'h2, 'h1} "); `checkp(q, "'{'h4, 'h3, 'h2, 'h2, 'h1} ");
qe.sort(x) with (10 - x); qe.sort(x) with (10 - x);
v = $sformatf("%p", qe); `checks(v, "'{}"); `checkp(qe, "'{}");
q.rsort; q.rsort;
v = $sformatf("%p", q); `checks(v, "'{'h4, 'h3, 'h2, 'h2, 'h1} "); `checkp(q, "'{'h4, 'h3, 'h2, 'h2, 'h1} ");
q.rsort with (10 - item); q.rsort with (10 - item);
v = $sformatf("%p", q); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} "); `checkp(q, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
qe.rsort(x) with (10 - x); qe.rsort(x) with (10 - x);
v = $sformatf("%p", q); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} "); `checkp(q, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
q = '{2, 2, 4, 1, 3}; q = '{2, 2, 4, 1, 3};
qv = q.unique; qv = q.unique;
v = $sformatf("%p", qv); `checks(v, "'{'h2, 'h4, 'h1, 'h3} "); `checkp(qv, "'{'h2, 'h4, 'h1, 'h3} ");
qv = qe.unique; qv = qe.unique;
`checkh(qv.size(), 0); `checkh(qv.size(), 0);
qv = q.unique(x) with (x % 2); qv = q.unique(x) with (x % 2);
@ -84,7 +84,7 @@ module t (/*AUTOARG*/);
// According to IEEE 1800-2023 7.12.1, it is not specified which index of duplicated value should be returned // According to IEEE 1800-2023 7.12.1, it is not specified which index of duplicated value should be returned
`checkh(qi.size(), 4); `checkh(qi.size(), 4);
qi.delete(1); qi.delete(1);
v = $sformatf("%p", qi); `checks(v, "'{'h0, 'h3, 'h4} "); `checkp(qi, "'{'h0, 'h3, 'h4} ");
qi = qe.unique_index; qi = qe.unique_index;
`checkh(qi.size(), 0); `checkh(qi.size(), 0);
qi = q.unique_index(x) with (x % 3); qv.sort; qi = q.unique_index(x) with (x % 3); qv.sort;
@ -95,31 +95,31 @@ module t (/*AUTOARG*/);
`checkh(cls_qv.size(), 1); `checkh(cls_qv.size(), 1);
qi = cls_q.unique_index with (item.x % 2); qi = cls_q.unique_index with (item.x % 2);
qi.sort; qi.sort;
v = $sformatf("%p", qi); `checks(v, "'{'h0, 'h1} "); `checkp(qi, "'{'h0, 'h1} ");
q.reverse; q.reverse;
v = $sformatf("%p", q); `checks(v, "'{'h3, 'h1, 'h4, 'h2, 'h2} "); `checkp(q, "'{'h3, 'h1, 'h4, 'h2, 'h2} ");
qe.reverse; qe.reverse;
`checkh(qe.size(), 0); `checkh(qe.size(), 0);
q.shuffle(); q.sort; q.shuffle(); q.sort;
v = $sformatf("%p", q); `checks(v, "'{'h1, 'h2, 'h2, 'h3, 'h4} "); `checkp(q, "'{'h1, 'h2, 'h2, 'h3, 'h4} ");
qe.shuffle(); qe.shuffle();
`checkh(qe.size(), 0); `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, "'{'h2, 'h2} "); `checkp(qv, "'{'h2, 'h2} ");
qv = q.find with (item[0] == 1); qv = q.find with (item[0] == 1);
v = $sformatf("%p", qv); `checks(v, "'{'h1, 'h3} "); `checkp(qv, "'{'h1, 'h3} ");
qv = q.find_first with (item == 2); qv = q.find_first with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{'h2} "); `checkp(qv, "'{'h2} ");
points_qv = points_q.find_first with (item.z == 5); points_qv = points_q.find_first with (item.z == 5);
`checkh(points_qv[0].p.y, 3); `checkh(points_qv[0].p.y, 3);
points_qv = points_q.find_first with (item.p.x == 1); points_qv = points_q.find_first with (item.p.x == 1);
`checkh(points_qv[0].p.y, 2); `checkh(points_qv[0].p.y, 2);
qv = q.find_last with (item == 2); qv = q.find_last with (item == 2);
v = $sformatf("%p", qv); `checks(v, "'{'h2} "); `checkp(qv, "'{'h2} ");
string_qv = string_q.find_last(s) with (s.tolower() == "a"); string_qv = string_q.find_last(s) with (s.tolower() == "a");
`checks(string_qv[0], "A"); `checks(string_qv[0], "A");
@ -134,15 +134,15 @@ module t (/*AUTOARG*/);
qvunused = q.find with (item == 20); qvunused = q.find with (item == 20);
qi = q.find_index with (item == 2); qi = q.find_index with (item == 2);
qi.sort; v = $sformatf("%p", qi); `checks(v, "'{'h1, 'h2} "); qi.sort; `checkp(qi, "'{'h1, 'h2} ");
qi = q.find_first_index with (item == 2); qi = q.find_first_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{'h1} "); `checkp(qi, "'{'h1} ");
qi = q.find_last_index with (item == 2); qi = q.find_last_index with (item == 2);
v = $sformatf("%p", qi); `checks(v, "'{'h2} "); `checkp(qi, "'{'h2} ");
i = 2; i = 2;
qi = q.find_index with (item == i); qi = q.find_index with (item == i);
qi.sort; v = $sformatf("%p", qi); `checks(v, "'{'h1, 'h2} "); qi.sort; `checkp(qi, "'{'h1, 'h2} ");
qi = q.find_index with (item == 20); qi.sort; qi = q.find_index with (item == 20); qi.sort;
`checkh(qi.size, 0); `checkh(qi.size, 0);
@ -152,22 +152,22 @@ module t (/*AUTOARG*/);
`checkh(qi.size, 0); `checkh(qi.size, 0);
qi = q.find_index with (item.index == 2); qi = q.find_index with (item.index == 2);
v = $sformatf("%p", qi); `checks(v, "'{'h2} "); `checkp(qi, "'{'h2} ");
qi = q.find_index with (item.index == item); qi = q.find_index with (item.index == item);
v = $sformatf("%p", qi); `checks(v, "'{'h2, 'h3, 'h4} "); `checkp(qi, "'{'h2, 'h3, 'h4} ");
qv = q.min; qv = q.min;
v = $sformatf("%p", qv); `checks(v, "'{'h1} "); `checkp(qv, "'{'h1} ");
qv = q.min(x) with (x + 1); qv = q.min(x) with (x + 1);
v = $sformatf("%p", qv); `checks(v, "'{'h1} "); `checkp(qv, "'{'h1} ");
qv = q.max; qv = q.max;
v = $sformatf("%p", qv); `checks(v, "'{'h4} "); `checkp(qv, "'{'h4} ");
qv = q.max(x) with ((x % 4) + 100); qv = q.max(x) with ((x % 4) + 100);
v = $sformatf("%p", qv); `checks(v, "'{'h3} "); `checkp(qv, "'{'h3} ");
qv = qe.min; qv = qe.min;
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
qv = qe.max; qv = qe.max;
v = $sformatf("%p", qv); `checks(v, "'{}"); `checkp(qv, "'{}");
// Reduction methods // Reduction methods
i = q.sum; i = q.sum;

View File

@ -7,6 +7,7 @@
`define stop $stop `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 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 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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
module t (/*AUTOARG*/); module t (/*AUTOARG*/);
initial begin initial begin
@ -18,46 +19,46 @@ module t (/*AUTOARG*/);
q.push_front("non-empty"); q.push_front("non-empty");
i = q.size(); `checkh(i, 1); i = q.size(); `checkh(i, 1);
v = $sformatf("%p", q); `checks(v, "'{\"non-empty\"} "); `checkp(q, "'{\"non-empty\"} ");
q = '{}; q = '{};
i = q.size(); `checkh(i, 0); i = q.size(); `checkh(i, 0);
q = '{"q"}; q = '{"q"};
v = $sformatf("%p", q); `checks(v, "'{\"q\"} "); `checkp(q, "'{\"q\"} ");
q = {}; q = {};
i = q.size(); `checkh(i, 0); i = q.size(); `checkh(i, 0);
q = '{"q", "b", "c", "d", "e", "f"}; q = '{"q", "b", "c", "d", "e", "f"};
if (q[0] !== "q") $stop; if (q[0] !== "q") $stop;
v = $sformatf("%p", q); `checks(v, "'{\"q\", \"b\", \"c\", \"d\", \"e\", \"f\"} "); `checkp(q, "'{\"q\", \"b\", \"c\", \"d\", \"e\", \"f\"} ");
q = {"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\"} "); `checkp(q, "'{\"q\", \"b\", \"c\", \"d\", \"e\", \"f\"} ");
q.delete(1); q.delete(1);
v = q[1]; `checks(v, "c"); v = q[1]; `checks(v, "c");
v = $sformatf("%p", q); `checks(v, "'{\"q\", \"c\", \"d\", \"e\", \"f\"} "); `checkp(q, "'{\"q\", \"c\", \"d\", \"e\", \"f\"} ");
q.insert(0, "ins0"); q.insert(0, "ins0");
q.insert(2, "ins2"); q.insert(2, "ins2");
v = q[0]; `checks(v, "ins0"); v = q[0]; `checks(v, "ins0");
v = q[2]; `checks(v, "ins2"); v = q[2]; `checks(v, "ins2");
v = $sformatf("%p", q); `checks(v, "'{\"ins0\", \"q\", \"ins2\", \"c\", \"d\", \"e\", \"f\"} "); `checkp(q, "'{\"ins0\", \"q\", \"ins2\", \"c\", \"d\", \"e\", \"f\"} ");
// Slicing // Slicing
q = '{"q", "b", "c", "d", "e", "f"}; q = '{"q", "b", "c", "d", "e", "f"};
q = q[-1:0]; q = q[-1:0];
v = $sformatf("%p", q); `checks(v, "'{\"q\"} "); `checkp(q, "'{\"q\"} ");
q = '{"q", "b", "c", "d", "e", "f"}; q = '{"q", "b", "c", "d", "e", "f"};
q = q[2:3]; q = q[2:3];
v = $sformatf("%p", q); `checks(v, "'{\"c\", \"d\"} "); `checkp(q, "'{\"c\", \"d\"} ");
q = '{"q", "b", "c", "d", "e", "f"}; q = '{"q", "b", "c", "d", "e", "f"};
q = q[3:$]; q = q[3:$];
v = $sformatf("%p", q); `checks(v, "'{\"d\", \"e\", \"f\"} "); `checkp(q, "'{\"d\", \"e\", \"f\"} ");
q = q[$:$]; q = q[$:$];
v = $sformatf("%p", q); `checks(v, "'{\"f\"} "); `checkp(q, "'{\"f\"} ");
// Similar using implied notation // Similar using implied notation
q = '{"f"}; q = '{"f"};
@ -65,14 +66,14 @@ module t (/*AUTOARG*/);
q = {q, "f2"}; // push_front q = {q, "f2"}; // push_front
q = {"b1", q}; // push_back q = {"b1", q}; // push_back
q = {"b2", q}; // push_back q = {"b2", q}; // push_back
v = $sformatf("%p", q); `checks(v, "'{\"b2\", \"b1\", \"f\", \"f1\", \"f2\"} "); `checkp(q, "'{\"b2\", \"b1\", \"f\", \"f1\", \"f2\"} ");
q = {q[0], q[2:$]}; // delete element 1 q = {q[0], q[2:$]}; // delete element 1
v = $sformatf("%p", q); `checks(v, "'{\"b2\", \"f\", \"f1\", \"f2\"} "); `checkp(q, "'{\"b2\", \"f\", \"f1\", \"f2\"} ");
q = {"a", "b"}; q = {"a", "b"};
q = {q, q}; q = {q, q};
v = $sformatf("%p", q); `checks(v, "'{\"a\", \"b\", \"a\", \"b\"} "); `checkp(q, "'{\"a\", \"b\", \"a\", \"b\"} ");
begin begin
string ai[$] = '{ "Foo", "Bar" }; string ai[$] = '{ "Foo", "Bar" };

View File

@ -6,7 +6,7 @@
`define stop $stop `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 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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
typedef enum bit [5:0] { typedef enum bit [5:0] {
A = 6'b111000, A = 6'b111000,
@ -18,13 +18,12 @@ module t (/*AUTOARG*/);
bit arr[]; bit arr[];
bit [1:0] arr2[$]; bit [1:0] arr2[$];
bit [5:0] arr6[$]; bit [5:0] arr6[$];
string v;
bit [5:0] bit6 = 6'b111000; bit [5:0] bit6 = 6'b111000;
bit [5:0] ans; bit [5:0] ans;
enum_t ans_enum; enum_t ans_enum;
{ >> bit {arr}} = bit6; { >> bit {arr}} = bit6;
v = $sformatf("%p", arr); `checks(v, "'{'h0, 'h0, 'h0, 'h1, 'h1, 'h1} "); `checkp(arr, "'{'h0, 'h0, 'h0, 'h1, 'h1, 'h1} ");
ans = { >> bit {arr} }; ans = { >> bit {arr} };
`checkh(ans, bit6); `checkh(ans, bit6);
@ -33,7 +32,7 @@ module t (/*AUTOARG*/);
`checkh(ans_enum, bit6); `checkh(ans_enum, bit6);
{ << bit {arr}} = bit6; { << bit {arr}} = bit6;
v = $sformatf("%p", arr); `checks(v, "'{'h1, 'h1, 'h1, 'h0, 'h0, 'h0} "); `checkp(arr, "'{'h1, 'h1, 'h1, 'h0, 'h0, 'h0} ");
ans = { << bit {arr} }; ans = { << bit {arr} };
`checkh(ans, bit6); `checkh(ans, bit6);
@ -42,7 +41,7 @@ module t (/*AUTOARG*/);
`checkh(ans_enum, bit6); `checkh(ans_enum, bit6);
{ >> bit[1:0] {arr2}} = bit6; { >> bit[1:0] {arr2}} = bit6;
v = $sformatf("%p", arr2); `checks(v, "'{'h0, 'h2, 'h3} "); `checkp(arr2, "'{'h0, 'h2, 'h3} ");
ans = { >> bit[1:0] {arr2} }; ans = { >> bit[1:0] {arr2} };
`checkh(ans, bit6); `checkh(ans, bit6);
@ -51,7 +50,7 @@ module t (/*AUTOARG*/);
`checkh(ans_enum, bit6); `checkh(ans_enum, bit6);
{ << bit[1:0] {arr2}} = bit6; { << bit[1:0] {arr2}} = bit6;
v = $sformatf("%p", arr2); `checks(v, "'{'h3, 'h2, 'h0} "); `checkp(arr2, "'{'h3, 'h2, 'h0} ");
ans = { << bit[1:0] {arr2} }; ans = { << bit[1:0] {arr2} };
`checkh(ans, bit6); `checkh(ans, bit6);
@ -60,7 +59,7 @@ module t (/*AUTOARG*/);
`checkh(ans_enum, bit6); `checkh(ans_enum, bit6);
{ >> bit [5:0] {arr6} } = bit6; { >> bit [5:0] {arr6} } = bit6;
v = $sformatf("%p", arr6); `checks(v, "'{'h38} "); `checkp(arr6, "'{'h38} ");
ans = { >> bit[5:0] {arr6} }; ans = { >> bit[5:0] {arr6} };
`checkh(ans, bit6); `checkh(ans, bit6);
@ -69,7 +68,7 @@ module t (/*AUTOARG*/);
`checkh(ans_enum, bit6); `checkh(ans_enum, bit6);
{ << bit [5:0] {arr6} } = bit6; { << bit [5:0] {arr6} } = bit6;
v = $sformatf("%p", arr6); `checks(v, "'{'h38} "); `checkp(arr6, "'{'h38} ");
ans = { << bit[5:0] {arr6} }; ans = { << bit[5:0] {arr6} };
`checkh(ans, bit6); `checkh(ans, bit6);

View File

@ -6,7 +6,7 @@
`define stop $stop `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 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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
typedef enum bit [5:0] { typedef enum bit [5:0] {
A = 6'b111000, A = 6'b111000,
@ -18,13 +18,12 @@ module t (/*AUTOARG*/);
bit arr[6]; bit arr[6];
bit [1:0] arr2[3]; bit [1:0] arr2[3];
bit [5:0] arr6[1]; bit [5:0] arr6[1];
string v;
bit [5:0] bit6 = 6'b111000; bit [5:0] bit6 = 6'b111000;
bit [5:0] ans; bit [5:0] ans;
enum_t ans_enum; enum_t ans_enum;
{ >> bit {arr}} = bit6; { >> bit {arr}} = bit6;
v = $sformatf("%p", arr); `checks(v, "'{'h1, 'h1, 'h1, 'h0, 'h0, 'h0} "); `checkp(arr, "'{'h1, 'h1, 'h1, 'h0, 'h0, 'h0} ");
ans = { >> bit {arr} }; ans = { >> bit {arr} };
`checkh(ans, bit6); `checkh(ans, bit6);
@ -33,7 +32,7 @@ module t (/*AUTOARG*/);
`checkh(ans_enum, bit6); `checkh(ans_enum, bit6);
{ << bit {arr}} = bit6; { << bit {arr}} = bit6;
v = $sformatf("%p", arr); `checks(v, "'{'h0, 'h0, 'h0, 'h1, 'h1, 'h1} "); `checkp(arr, "'{'h0, 'h0, 'h0, 'h1, 'h1, 'h1} ");
ans = { << bit {arr} }; ans = { << bit {arr} };
`checkh(ans, bit6); `checkh(ans, bit6);
@ -42,7 +41,7 @@ module t (/*AUTOARG*/);
`checkh(ans_enum, bit6); `checkh(ans_enum, bit6);
{ >> bit[1:0] {arr2}} = bit6; { >> bit[1:0] {arr2}} = bit6;
v = $sformatf("%p", arr2); `checks(v, "'{'h3, 'h2, 'h0} "); `checkp(arr2, "'{'h3, 'h2, 'h0} ");
ans = { >> bit[1:0] {arr2} }; ans = { >> bit[1:0] {arr2} };
`checkh(ans, bit6); `checkh(ans, bit6);
@ -51,7 +50,7 @@ module t (/*AUTOARG*/);
`checkh(ans_enum, bit6); `checkh(ans_enum, bit6);
{ << bit[1:0] {arr2}} = bit6; { << bit[1:0] {arr2}} = bit6;
v = $sformatf("%p", arr2); `checks(v, "'{'h0, 'h2, 'h3} "); `checkp(arr2, "'{'h0, 'h2, 'h3} ");
ans = { << bit[1:0] {arr2} }; ans = { << bit[1:0] {arr2} };
`checkh(ans, bit6); `checkh(ans, bit6);
@ -60,7 +59,7 @@ module t (/*AUTOARG*/);
`checkh(ans_enum, bit6); `checkh(ans_enum, bit6);
{ >> bit [5:0] {arr6} } = bit6; { >> bit [5:0] {arr6} } = bit6;
v = $sformatf("%p", arr6); `checks(v, "'{'h38} "); `checkp(arr6, "'{'h38} ");
ans = { >> bit[5:0] {arr6} }; ans = { >> bit[5:0] {arr6} };
`checkh(ans, bit6); `checkh(ans, bit6);
@ -69,7 +68,7 @@ module t (/*AUTOARG*/);
`checkh(ans_enum, bit6); `checkh(ans_enum, bit6);
{ << bit [5:0] {arr6} } = bit6; { << bit [5:0] {arr6} } = bit6;
v = $sformatf("%p", arr6); `checks(v, "'{'h38} "); `checkp(arr6, "'{'h38} ");
ans = { << bit[5:0] {arr6} }; ans = { << bit[5:0] {arr6} };
`checkh(ans, bit6); `checkh(ans, bit6);

View File

@ -5,7 +5,7 @@
// SPDX-License-Identifier: CC0-1.0 // SPDX-License-Identifier: CC0-1.0
`define stop $stop `define stop $stop
`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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
typedef struct { typedef struct {
struct { struct {
@ -29,17 +29,11 @@ module t (/*AUTOARG*/);
pstr_t pstr; pstr_t pstr;
initial begin initial begin
string s;
str.el[0].val.next = 6; str.el[0].val.next = 6;
s = $sformatf("%p", str); `checkp(str, "'{el:'{'{val:'{next:'h6}}} }");
$display("%s", s);
`checks(s, "'{el:'{'{val:'{next:'h6}}} }");
pstr.el[0].val.next = 6; pstr.el[0].val.next = 6;
s = $sformatf("%p", pstr); `checkp(str, "'{el:'{'{val:'{next:'h6}}} }");
$display("%s", s);
`checks(s, "'{el:'{'{val:'{next:'h6}}} }");
$write("*-* All Finished *-*\n"); $write("*-* All Finished *-*\n");
$finish; $finish;

View File

@ -6,6 +6,7 @@
`define stop $stop `define stop $stop
`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 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 checkp(gotv,expv_s) do begin string gotv_s; gotv_s = $sformatf("%p", gotv); if ((gotv_s) !== (expv_s)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv_s), (expv_s)); `stop; end end while(0);
class Cls; class Cls;
typedef struct { typedef struct {
@ -50,12 +51,10 @@ module x;
istr.m_i = 12; istr.m_i = 12;
istr.m_s = "str1"; istr.m_s = "str1";
s = $sformatf("%p", istr); `checkp(istr, "'{m_i:'hc, m_s:\"str1\"}");
`checks(s, "'{m_i:'hc, m_s:\"str1\"}");
istr = '{m_i: '1, m_s: "str2"}; istr = '{m_i: '1, m_s: "str2"};
s = $sformatf("%p", istr); `checkp(istr, "'{m_i:'hffff, m_s:\"str2\"}");
`checks(s, "'{m_i:'hffff, m_s:\"str2\"}");
c = new; c = new;
s = c.get_cstr().m_strg; s = c.get_cstr().m_strg;