I am trying to learn foreach iterative constraints. LRM says “An empty loop variable indicates no iteration over that dimension of the array” Also gave 2 examples for reference in LRM
**“foreach( A [ i, j, k ] ) …
foreach( B [ q, r, , s ] ) …
The first foreach causes i to iterate from 0 to 1, j from 0 to 2, and k from 0 to 3. The second foreach
causes q to iterate from 5 to 1, r from 0 to 3, and s from 2 to 1.”
**
I have written simple code for same. Can someone explain what is wrong with it ? I am getting compilation error with all tools on EDA playground.
class array;
rand int unsigned two_dim[5][5];
constraint my_ct {
foreach(two_dim[,j]){
two_dim[j] > 0;
two_dim[j] < 20;
}
}
function new();
endfunction
function print();
$display("Array :%p",two_dim);
endfunction
endclass
module multi_array();
array u_array;
initial begin
u_array = new();
assert(u_array.randomize());
u_array.print();
end
endmodule