Add regression tests for queue of packed arrays

Check that queues of packed arrays are supported. These tests are identical
to the existing queue tests for other data type, just that the data type
is a packed array.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-03-12 12:55:20 +01:00
parent babfacee9a
commit 1a10abeae7
8 changed files with 335 additions and 0 deletions

View File

@ -0,0 +1,16 @@
./ivltests/sv_queue_parray.v:35: Warning: skipping delete(0) on empty queue.
./ivltests/sv_queue_parray.v:39: Warning: pop_front() on empty queue<vector[40]>.
./ivltests/sv_queue_parray.v:45: Warning: pop_back() on empty queue<vector[40]>.
./ivltests/sv_queue_parray.v:56: Warning: skipping out of range delete(3) on queue of size 3.
./ivltests/sv_queue_parray.v:57: Warning: skipping queue delete() with negative index.
./ivltests/sv_queue_parray.v:58: Warning: skipping queue delete() with undefined index.
./ivltests/sv_queue_parray.v:132: Warning: cannot assign to a negative queue<vector[40]> index (-1). 40'b0000000000000000000000000000000000001010 was not added.
./ivltests/sv_queue_parray.v:133: Warning: cannot assign to an undefined queue<vector[40]> index. 40'b0000000000000000000000000000000000001010 was not added.
./ivltests/sv_queue_parray.v:134: Warning: assigning to queue<vector>[4] is outside of size (3). 40'b0000000000000000000000000000000000001010 was not added.
./ivltests/sv_queue_parray.v:137: Warning: cannot assign to a negative queue<vector[40]> index (-1). 40'b0000000000000000000000000000000000001010 was not added.
./ivltests/sv_queue_parray.v:139: Warning: cannot assign to an undefined queue<vector[40]> index. 40'b0000000000000000000000000000000000001010 was not added.
./ivltests/sv_queue_parray.v:141: Warning: assigning to queue<vector>[4] is outside of size (3). 40'b0000000000000000000000000000000000001010 was not added.
./ivltests/sv_queue_parray.v:153: Warning: cannot insert at a negative queue<vector[40]> index (-1). 40'b0000000000000000000000000000000000001010 was not added.
./ivltests/sv_queue_parray.v:154: Warning: cannot insert at an undefined queue<vector[40]> index. 40'b0000000000000000000000000000000000001010 was not added.
./ivltests/sv_queue_parray.v:155: Warning: inserting to queue<vector[40]>[5] is outside of size (4). 40'b0000000000000000000000000000000000001010 was not added.
PASSED

View File

@ -0,0 +1,9 @@
./ivltests/sv_queue_parray_bounded.v:61: Warning: Array pattern assignment has more elements (4) than bounded queue 'q_tst' supports (3).
Only using first 3 elements.
./ivltests/sv_queue_parray_bounded.v:38: Warning: push_back(40'b0000000000000000000000000000000001100100) skipped for already full bounded queue<vector[40]> [3].
./ivltests/sv_queue_parray_bounded.v:45: Warning: push_front(40'b0000000000000000000000000000000000000101) removed 40'b0000000000000000000000000000000000000011 from already full bounded queue<vector[40]> [3].
./ivltests/sv_queue_parray_bounded.v:46: Warning: assigning to queue<vector>[3] is outside bound (3). 40'b0000000000000000000000000000000000000011 was not added.
./ivltests/sv_queue_parray_bounded.v:53: Warning: inserting to queue<vector[40]>[3] is outside bound (3). 40'b0000000000000000000000000000000000001010 was not added.
./ivltests/sv_queue_parray_bounded.v:54: Warning: insert(1, 40'b0000000000000000000000000000000000000010) removed 40'b0000000000000000000000000000000000000010 from already full bounded queue<vector[40]> [3].
./ivltests/sv_queue_parray_bounded.v:69: Warning: queue<vector> is bounded to have at most 3 elements, source has 4 elements.
PASSED

View File

@ -0,0 +1,10 @@
./ivltests/sv_queue_parray_fail.v:7: error: queue 'q_vec1' bound must be positive (-1)!
./ivltests/sv_queue_parray_fail.v:8: error: queue 'q_vec2' bound is undefined!
./ivltests/sv_queue_parray_fail.v:9: error: A reference to a wire or reg (`bound') is not allowed in a constant expression.
./ivltests/sv_queue_parray_fail.v:9: error: queue 'q_vec3' bound must be a constant!
./ivltests/sv_queue_parray_fail.v:12: error: size() method takes no arguments
./ivltests/sv_queue_parray_fail.v:13: error: pop_front() method takes no arguments
./ivltests/sv_queue_parray_fail.v:14: error: pop_back() method takes no arguments
./ivltests/sv_queue_parray_fail.v:15: error: push_front() method requires a single argument.
./ivltests/sv_queue_parray_fail.v:16: error: push_back() method requires a single argument.
9 error(s) during elaboration.

View File

@ -0,0 +1,195 @@
module top;
typedef reg [4:0] T1;
typedef T1 [7:0] T2;
T2 q_tst [$];
T2 q_tmp [$];
T2 elem;
integer idx;
bit passed;
task automatic check_size(integer size,
string fname,
integer lineno);
if (q_tst.size !== size) begin
$display("%s:%0d: Failed: queue size != %0d (%0d)",
fname, lineno, size, q_tst.size);
passed = 1'b0;
end
endtask
task automatic check_idx_value(integer idx,
T2 expected,
string fname,
integer lineno);
if (q_tst[idx] != expected) begin
$display("%s:%0d: Failed: element [%0d] != %0d (%0d)",
fname, lineno, idx, expected, q_tst[idx]);
passed = 1'b0;
end
endtask
initial begin
passed = 1'b1;
q_tst.delete(0); // Warning: skip delete on an empty queue
check_size(0, `__FILE__, `__LINE__);
check_idx_value(0, 0, `__FILE__, `__LINE__);
elem = q_tst.pop_front(); // Warning: cannot pop_front() an empty queue
if (elem !== 'X) begin
$display("Failed: pop_front() != 'X (%0d)", elem);
passed = 1'b0;
end
elem = q_tst.pop_back(); // Warning: cannot pop_back() an empty queue
if (elem !== 'X) begin
$display("Failed: pop_back() != 'X (%0d)", elem);
passed = 1'b0;
end
q_tst.push_back(2);
q_tst.push_front(1);
q_tst.push_back(3);
q_tst.push_back(100);
q_tst.delete(3); // Should $ work here?
q_tst.delete(3); // Warning: skip an out of range delete()
q_tst.delete(-1); // Warning: skip delete with negative index
q_tst.delete('X); // Warning: skip delete with undefined index
check_size(3, `__FILE__, `__LINE__);
if (q_tst[0] !== 1) begin
$display("Failed: element [0] != 1 (%0d)", q_tst[0]);
passed = 1'b0;
end
if (q_tst[1] !== 2) begin
$display("Failed: element [1] != 2 (%0d)", q_tst[1]);
passed = 1'b0;
end
if (q_tst[2] !== 3) begin
$display("Failed: element [2] != 3 (%0d)", q_tst[2]);
passed = 1'b0;
end
if (q_tst[3] !== 'X) begin
$display("Failed: element [3] != 'X (%0d)", q_tst[3]);
passed = 1'b0;
end
if (q_tst[-1] !== 'X) begin
$display("Failed: element [-1] != 'X (%0d)", q_tst[-1]);
passed = 1'b0;
end
if (q_tst['X] !== 'X) begin
$display("Failed: element ['X] != 'X (%0d)", q_tst['X]);
passed = 1'b0;
end
check_idx_value(-1, 0.0, `__FILE__, `__LINE__);
check_idx_value('X, 0.0, `__FILE__, `__LINE__);
elem = q_tst.pop_front();
if (elem !== 1) begin
$display("Failed: element pop_front() != 1 (%0d)", elem);
passed = 1'b0;
end
elem = q_tst.pop_back();
if (elem !== 3) begin
$display("Failed: element pop_back() != 3 (%0d)", elem);
passed = 1'b0;
end
check_size(1, `__FILE__, `__LINE__);
if ((q_tst[0] !== q_tst[$]) || (q_tst[0] !== 2)) begin
$display("Failed: q_tst[0](%0d) != q_tst[$](%0d) != 2",
q_tst[0], q_tst[$]);
passed = 1'b0;
end
q_tst.delete();
check_size(0, `__FILE__, `__LINE__);
q_tst.push_front(5);
q_tst.push_front(100);
q_tst.push_back(100);
elem = q_tst.pop_back;
elem = q_tst.pop_front;
check_size(1, `__FILE__, `__LINE__);
check_idx_value(0, 5, `__FILE__, `__LINE__);
q_tst[0] = 1;
q_tst[1] = 3;
q_tst[1] = 2;
q_tst[2] = 3;
q_tst[-1] = 10; // Warning: will not be added (negative index)
q_tst['X] = 10; // Warning: will not be added (undefined index)
q_tst[4] = 10; // Warning: will not be added (out of range index)
idx = -1;
q_tst[idx] = 10; // Warning: will not be added (negative index)
idx = 3'b0x1;
q_tst[idx] = 10; // Warning: will not be added (undefined index)
idx = 4;
q_tst[idx] = 10; // Warning: will not be added (out of range index)
check_size(3, `__FILE__, `__LINE__);
check_idx_value(0, 1, `__FILE__, `__LINE__);
check_idx_value(1, 2, `__FILE__, `__LINE__);
check_idx_value(2, 3, `__FILE__, `__LINE__);
q_tst.delete();
q_tst[0] = 2;
q_tst.insert(1, 4);
q_tst.insert(0, 1);
q_tst.insert(2, 3);
q_tst.insert(-1, 10); // Warning: will not be added (negative index)
q_tst.insert('X, 10); // Warning: will not be added (undefined index)
q_tst.insert(5, 10); // Warning: will not be added (out of range index)
check_size(4, `__FILE__, `__LINE__);
check_idx_value(0, 1, `__FILE__, `__LINE__);
check_idx_value(1, 2, `__FILE__, `__LINE__);
check_idx_value(2, 3, `__FILE__, `__LINE__);
check_idx_value(3, 4, `__FILE__, `__LINE__);
q_tst = '{3, 2, 1};
check_size(3, `__FILE__, `__LINE__);
check_idx_value(0, 3, `__FILE__, `__LINE__);
check_idx_value(1, 2, `__FILE__, `__LINE__);
check_idx_value(2, 1, `__FILE__, `__LINE__);
q_tmp = '{1, 2};
q_tst = q_tmp;
q_tmp[0] = 3;
q_tmp[2] = 1;
check_size(2, `__FILE__, `__LINE__);
check_idx_value(0, 1.0, `__FILE__, `__LINE__);
check_idx_value(1, 2.0, `__FILE__, `__LINE__);
q_tst[2] = 3;
check_size(3, `__FILE__, `__LINE__);
check_idx_value(2, 3, `__FILE__, `__LINE__);
q_tst = {1, 2};
check_size(2, `__FILE__, `__LINE__);
check_idx_value(0, 1, `__FILE__, `__LINE__);
check_idx_value(1, 2, `__FILE__, `__LINE__);
q_tst = '{};
check_size(0, `__FILE__, `__LINE__);
if (passed) $display("PASSED");
end
endmodule : top

View File

@ -0,0 +1,80 @@
module top;
typedef reg [4:0] T1;
typedef T1 [7:0] T2;
T2 q_tst [$:2];
T2 q_tmp [$];
bit passed;
task automatic check_size(integer size,
string fname,
integer lineno);
if (q_tst.size !== size) begin
$display("%s:%0d: Failed: queue size != %0d (%0d)",
fname, lineno, size, q_tst.size);
passed = 1'b0;
end
endtask
task automatic check_idx_value(integer idx,
T2 expected,
string fname,
integer lineno);
if (q_tst[idx] != expected) begin
$display("%s:%0d: Failed: element [%0d] != %0d (%0d)",
fname, lineno, idx, expected, q_tst[idx]);
passed = 1'b0;
end
endtask
initial begin
passed = 1'b1;
check_size(0, `__FILE__, `__LINE__);
q_tst.push_back(2);
q_tst.push_front(1);
q_tst.push_back(3);
q_tst.push_back(100); // Warning: item not added.
check_size(3, `__FILE__, `__LINE__);
check_idx_value(0, 1, `__FILE__, `__LINE__);
check_idx_value(1, 2, `__FILE__, `__LINE__);
check_idx_value(2, 3, `__FILE__, `__LINE__);
q_tst.push_front(5); // Warning: back item removed.
q_tst[3] = 3; // Warning: item not added.
check_size(3, `__FILE__, `__LINE__);
check_idx_value(0, 5, `__FILE__, `__LINE__);
check_idx_value(1, 1, `__FILE__, `__LINE__);
check_idx_value(2, 2, `__FILE__, `__LINE__);
q_tst.insert(3, 10); // Warning: item not added.
q_tst.insert(1, 2); // Warning: back item removed.
check_size(3, `__FILE__, `__LINE__);
check_idx_value(0, 5, `__FILE__, `__LINE__);
check_idx_value(1, 2, `__FILE__, `__LINE__);
check_idx_value(2, 1, `__FILE__, `__LINE__);
q_tst = '{1, 2, 3, 4}; // Warning: items not added.
check_size(3, `__FILE__, `__LINE__);
check_idx_value(0, 1, `__FILE__, `__LINE__);
check_idx_value(1, 2, `__FILE__, `__LINE__);
check_idx_value(2, 3, `__FILE__, `__LINE__);
q_tmp = '{4, 3, 2, 1};
q_tst = q_tmp; // Warning not all items copied
q_tmp[0] = 5;
check_size(3, `__FILE__, `__LINE__);
check_idx_value(0, 4, `__FILE__, `__LINE__);
check_idx_value(1, 3, `__FILE__, `__LINE__);
check_idx_value(2, 2, `__FILE__, `__LINE__);
if (passed) $display("PASSED");
end
endmodule : top

View File

@ -0,0 +1,19 @@
module top;
typedef reg [4:0] T1;
typedef T1 [7:0] T2;
int bound = 2;
T2 q_vec [$];
T2 q_vec1 [$:-1];
T2 q_vec2 [$:'X];
T2 q_vec3 [$:bound];
initial begin
$display(q_vec.size(1));
$display(q_vec.pop_front(1));
$display(q_vec.pop_back(1));
q_vec.push_front(1, 2);
q_vec.push_back(1, 2);
$display("FAILED");
end
endmodule : top

View File

@ -514,6 +514,9 @@ sv_port_default14 CE,-g2009 ivltests
sv_queue1 normal,-g2009 ivltests
sv_queue2 normal,-g2009 ivltests
sv_queue3 normal,-g2009 ivltests
sv_queue_parray normal,-g2009,-pfileline=1 ivltests gold=sv_queue_parray.gold
sv_queue_parray_bounded normal,-g2009,-pfileline=1 ivltests gold=sv_queue_parray_bounded.gold
sv_queue_parray_fail CE,-g2009 ivltests gold=sv_queue_parray_fail.gold
sv_queue_real normal,-g2009,-pfileline=1 ivltests gold=sv_queue_real.gold
sv_queue_real_bounded normal,-g2009,-pfileline=1 ivltests gold=sv_queue_real_bounded.gold
sv_queue_real_fail CE,-g2009 ivltests gold=sv_queue_real_fail.gold

View File

@ -588,6 +588,9 @@ sv_queue_string_fail CE,-g2009 ivltests
sv_queue_vec CE,-g2009,-pallowsigned=1 ivltests
sv_queue_vec_bounded CE,-g2009,-pallowsigned=1 ivltests
sv_queue_vec_fail CE,-g2009,-pallowsigned=1 ivltests
sv_queue_parray CE,-g2009, ivltests
sv_queue_parray_bounded CE,-g2009, ivltests
sv_queue_parray_fail CE,-g2009, ivltests
test_forgen CE,-g2009,ivltests/forgen.vhd ivltests
test_gxor CE,-g2009,-pallowsigned=1,ivltests/gxor.vhd ivltests
test_varray1 CE,-g2009,-pallowsigned=1,ivltests/varray1.vhd ivltests