Skip to content

Commit e183838

Browse files
committed
Add regression test for invalid array query signedness
Check arithmetic right shifts of invalid `$left`, `$right`, `$low`, `$high`, `$increment` and `$size` results. Cover dimensions below and above the valid range and include valid signed results as controls. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
1 parent 80dcaa3 commit e183838

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Check that invalid array-query results keep their signed integer type.
2+
3+
module test;
4+
5+
reg [7:0] values [0:1];
6+
reg failed;
7+
8+
`define check(val, exp) \
9+
if (val !== exp) begin \
10+
$display("FAILED(%0d): '%s' expected %b, got %b", `__LINE__, \
11+
`"val`", exp, val); \
12+
failed = 1'b1; \
13+
end
14+
15+
initial begin
16+
failed = 1'b0;
17+
18+
// Dimension 0 does not exist.
19+
`check($left(values, 0) >>> 8, 32'bx);
20+
`check($right(values, 0) >>> 8, 32'bx);
21+
`check($low(values, 0) >>> 8, 32'bx);
22+
`check($high(values, 0) >>> 8, 32'bx);
23+
`check($increment(values, 0) >>> 8, 32'bx);
24+
`check($size(values, 0) >>> 8, 32'bx);
25+
26+
// Dimension 3 does not exist.
27+
`check($left(values, 3) >>> 8, 32'bx);
28+
`check($right(values, 3) >>> 8, 32'bx);
29+
`check($low(values, 3) >>> 8, 32'bx);
30+
`check($high(values, 3) >>> 8, 32'bx);
31+
`check($increment(values, 3) >>> 8, 32'bx);
32+
`check($size(values, 3) >>> 8, 32'bx);
33+
34+
`check($increment(values, 1) >>> 8, -1);
35+
`check($increment(values, 2) >>> 8, 0);
36+
if (!failed) begin
37+
$display("PASSED");
38+
end
39+
end
40+
41+
endmodule

‎ivtest/regress-vvp.list‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ array_index_real_fail vvp_tests/array_index_real_fail.json
1010
array_packed_sysfunct vvp_tests/array_packed_sysfunct.json
1111
array_packed_value_list vvp_tests/array_packed_value_list.json
1212
array_packed_write_read vvp_tests/array_packed_write_read.json
13+
array_query_invalid_signedness vvp_tests/array_query_invalid_signedness.json
1314
array_slice_concat vvp_tests/array_slice_concat.json
1415
assign_op_return_select vvp_tests/assign_op_return_select.json
1516
assign_op_signed1 vvp_tests/assign_op_signed1.json
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type" : "normal",
3+
"source" : "array_query_invalid_signedness.v",
4+
"iverilog-args" : [ "-g2005-sv" ]
5+
}

0 commit comments

Comments
 (0)