Add regression test for negative packed array bounds

Check that variable selects of a packed array with negative bounds use the
correct index width and can read back assigned elements.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2026-06-19 21:43:57 -07:00
parent 128c621e85
commit 6326c5b1ba
3 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,33 @@
// Check variable selects of packed arrays with negative bounds.
module test;
reg failed;
reg [-8:-1][3:0] a;
reg signed [2:0] i;
`define check(val, exp) \
if (val !== exp) begin \
$display("FAILED(%0d). '%s' expected %b, got %b", `__LINE__, \
`"val`", exp, val); \
failed = 1'b1; \
end
initial begin
failed = 1'b0;
a = '0;
i = -1;
a[i] = 4'ha;
i = -2;
a[i] = 4'h5;
`check(a[-1], 4'ha);
`check(a[-2], 4'h5);
if (!failed) begin
$display("PASSED");
end
end
endmodule

View File

@ -352,6 +352,7 @@ sv_net_decl_assign vvp_tests/sv_net_decl_assign.json
sv_package_lifetime vvp_tests/sv_package_lifetime.json
sv_package_lifetime_fail vvp_tests/sv_package_lifetime_fail.json
sv_parameter_type vvp_tests/sv_parameter_type.json
sv_partsel_var_negative_packed vvp_tests/sv_partsel_var_negative_packed.json
sv_queue_ap_method vvp_tests/sv_queue_ap_method.json
sv_queue_assign_op vvp_tests/sv_queue_assign_op.json
sv_queue_method_insert_too_few_arg_fail vvp_tests/sv_queue_method_insert_too_few_arg_fail.json

View File

@ -0,0 +1,8 @@
{
"type" : "normal",
"source" : "sv_partsel_var_negative_packed.v",
"iverilog-args" : [ "-g2005-sv" ],
"vlog95" : {
"iverilog-args" : [ "-pallowsigned=1" ]
}
}