In reply to vk7715:
Try this
module array;
class array;
rand bit [7:0] array [3][4];
int i,j;
constraint abc{
foreach(array[i,j]){
array[i][j] < 80;
}
}
//constraint def{
// foreach(array[i]){
// array[i].sum(item) with (int'(item))==100;
// }
//}
constraint ghi{
foreach(array[,i]){
array.sum(item) with (int'(array[item.index][i]))==100;
}
}
function void display();
foreach (array[i]) begin
foreach (array[i][j]) begin
$write(" %d ",array[i][j]);
end
$display("\n");
end
endfunction
endclass