Merge pull request #817 from larsclausen/fix-left-right-c-array

Fix $left/$right for C-style unpacked arrays
This commit is contained in:
Stephen Williams 2022-12-17 11:09:48 -08:00 committed by GitHub
commit 70e2ff0bd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 2 deletions

View File

@ -0,0 +1,30 @@
// Check that array query functions return the correct value for C style arrays
module test;
bit failed = 1'b0;
`define check(expr, val) \
if (expr !== val) begin \
$display("FAILED: %s, expected %0d, got %0d", `"expr`", val, expr); \
failed = 1'b1; \
end
bit [1:0] a[10];
initial begin
`check($left(a), 0)
`check($right(a), 9)
`check($low(a), 0)
`check($high(a), 9)
`check($size(a), 10)
`check($increment(a), -1)
`check($dimensions(a), 2)
`check($unpacked_dimensions(a), 1)
if (!failed) begin
$display("PASSED");
end
end
endmodule

View File

@ -499,6 +499,7 @@ sv_assign_pattern_func normal,-g2005-sv ivltests
sv_assign_pattern_op normal,-g2005-sv ivltests
sv_assign_pattern_part normal,-g2005-sv ivltests
sv_array_assign_pattern2 normal,-g2009 ivltests
sv_array_query normal,-g2005-sv ivltests
sv_cast_integer normal,-g2005-sv ivltests
sv_cast_integer2 normal,-g2005-sv ivltests
sv_cast_packed_array normal,-g2005-sv ivltests

View File

@ -1099,8 +1099,8 @@ bool evaluate_range(Design*des, NetScope*scope, const LineInfo*li,
if (!dimension_ok) {
// bail out
} else if (index_l > 0) {
index_l = index_l - 1;
index_r = 0;
index_r = index_l - 1;
index_l = 0;
} else {
cerr << range.first->get_fileline() << ": error: "
"Dimension size must be greater than zero." << endl;