class matrix#(parameter size=3);
rand int arr[size][size];
//helper variable to fix daigonal element
rand int x;
constraint c0 {x inside {[1:100]};}
//if diagonal element then it should be x
constraint c1 {foreach(arr[i,j]) if(i+j==size-1) arr[i][j]==x;}
//if not a diagonal element
constraint c2 {foreach(arr[i,j]) if(i+j!=size-1) arr[i][j]==x+((i+j)-size+1);}
endclass
module top();
matrix#(5) m1;
initial begin
m1=new();
repeat(5) begin
m1.randomize();
foreach(m1.arr[i])
$display("%p",m1.arr[i]);
$display("///////////////////");
end
end
endmodule