hi sir,
i would like to generate the randomize array value with constraint method in sv.
for example
0_th location store the array value is 0…;
1_th location store the array value is 5,10,15…;
2_th location store the array value is 6,12,18…;
3_th location stote the array value is 7,14,21…;
4_th location stote the array value is 8,16,24…;
5_th location stote the array value is 9,18,27…;
code but not this working.
class A;
rand bit[31:0] data[6];
//constraint data_values { foreach(data[i]) data[i] > data [i-1] ;}
constraint data_0_1 {data[0] == 0; data[1] == 1;data[2]==2;data[3]==3;data[4]==4;data[5]==5;}
constraint data_values { foreach(data[i])
data[i] == data[i*0];data[i*5];data[i*6];data[i*7];data[i*8];data[i*9];}
//constraint data_values { foreach(data[i])
// data[i] == data[00];data[15];data[26];data[37];data[48];data[59];}
//constraint data_values { foreach(data[i])
// foreach(data[j])
// if(i != j) data[i] != data [j] ;}
endclass
program main;
A a;
initial begin
bit k;
a=new();
k=a.randomize();
$display(“k=0%d”,k);
foreach(a.data[i])
$display(“data[%0d]=0%d”,i,a.data[i]);
end
endprogram