Files
iverilog/ivtest/ivltests/partsel_outside_expr.v
T
Dag Lem ba7da9d5a5 Guard against overflow / wrap around of internal part-select bit address
Internally, the maximum address space of a vector is 31 bits + a sign bit
to signal invalid addresses (out of bounds or has one or more x or z bits).

This commit ensures that unsigned part-select bit addresses which would
otherwise overflow and wrap around within this address space are correctly
handled as out of bounds.
2024-09-16 23:50:24 +02:00

26 lines
645 B
Verilog

/*
* partsel_outside_expr
* Check that base_expr ± bit_number in a part-select does not wrap around
* within the internal 32 bit (signed) vector address space.
* This could incorrectly select bits from a vector when unsigned integers
* are used in the part-select index expression.
*/
module main;
reg [1:0] arr = 1;
integer unsigned uoffset = -'d1;
wire [1:0] outside_expr = arr[uoffset +: 2];
initial begin
if (outside_expr !== 'x) begin
$display("FAILED -- non-const base_expr out of bounds value %b != xx", outside_expr);
$finish;
end
$display("PASSED");
$finish;
end
endmodule // main