I am dealing with a situation to randomize a large matrix with specific conditions. But I am seeing results are not coming as expected. Can anyone point me what should be the good method here.
module top();
class transaction;
rand bit[8:0] A[5][5] ;
shortint i,j;
constraint c_1 {foreach (A[i][j]) A[i][j] == i+j; }
endclass
transaction tr;
initial begin
tr = new();
tr.randomize();
$display ("Array is %p",tr.A);
end
endmodule
The constraints are illegal syntax the way they are written. You are only allowed one set of brackets 's at the end of the expression used in a foreach loop iterator. Since you already declared i, it is treating that as a non-random state variable using its initial value 0, not as a loop iterator. I would report that to your tool vendor as a bug.
You should write this with one using commas to separate the iterator variables.