In reply to Juhi_Patel:
I liked your solution , how about this alternative ?
class C;
rand bit data[8][8];
constraint c_d {
foreach(data[i,j]) {
if (((i<=4) && ((j>2-i) && (j<i+5))) ||
((i==5) && ((j<i+2) && (j>i-5))) ||
((i==6) && ((j<i) && (j>i-5))) ||
((i==7) && ((j<i-2) && (j>i-5))) ) {
data[i][j] == 1;
} else {
data[i][j] == 0;
}
}
}
endclass : C
module top();
C c;
initial begin
c = new();
repeat(1) begin
if(!c.randomize()) $error("RAND FAILED --- !!!");
for(int i=0;i<8;i++)begin
for(int j=0;j<8;j++)begin
$write ("%0b\t",c.data[i][j]);
end
$display();
end
end
end
endmodule : top
I should have spent more time to sort the lower half of diamond, for more generic solution instead of directed i values, but leaving on others to sort it out :)
Thank you,
Mega