Hi, I have been struggling in solving N queen problem in SV constraint. I know how to constraint the elements for each column and row(credit to the forum). However, diagonals are really a nightmare to me. Can anyone help me out, a detailed explain will be appreciated!!!
class queen_board;
rand bit queen_b[8][8];
constraint row_c {
foreach(queen_b[row]) queen_b[row].sum() with (int'(item)) <= 1;
}
constraint col_c {
foreach(queen_b[,col]) queen_b.sum() with (int'(queen_b[item.index(1)][col])) <= 1;
}
constraint diag_c{
//??????????????????????????
}
endclass