Hi all,
How to write a constraint for two consecutive numbers are same.
Example pattern: array[15] ----> {3,3,7,5,5,9,6,6,1,4,4,–}
I tried below code but its not working
module conditional_con;
class frame_t;
rand int length[10];
int k;
constraint frame_sizes {
foreach (length[i]){
if(i!=0)
i==i+2;
else
i==i;
foreach(length[j]){
if(j==i || j==i+1){
if(j!=0)
length[j]==length[j-1];
else
length[j]==length[j];}
else{
length[j]!=length[j-1];}}
}
}
endclass
initial begin
frame_t frame = new();
integer i,j;
for (j=0;j < 4; j++) begin
$write("-------------------------------\n");
$write("Randomize Value\n");
i = frame.randomize();
$display("length : %p",frame.length);
end
$write("-------------------------------\n");
end
endmodule
Thanks,