I have a 9x9 matrix as follows M[9][9]
Each A,B,C etc below are sub square matrices of 3x3 so that its a total of 9x9 matrix.
A B C
M = D E F
G H I
I need to write a constraint for following conditions :
Condition 1 : Any given 3x3 sub square matrices A,B etc above should have a unique max value
e g
1 1 1 5 6 6
A = 3 2 1 B = 6 9 6
3 6 8 6 6 6
Amax = 8 , Bmax = 9.
Condition 2 : Amax != Bmax
Condition 3 : Amax != Dmax
For having a max element for one sub square matrix, follo. code works but I dont know how to make it work for all the sub square matrces,
class max;
rand bit[4:0] sub_mat[3][3];
rand bit[4:0] max;
constraint c3 {
sub_mat.sum(item1) with (item1.sum(item2) with (int'(item2==max))) ==1;
foreach (mat[i,j]){
sub_mat[i][j] <= max;
}
}
endclass
Please provide inputs for how to do it for all A,B,C etc sub matrices in bigger matrix M