I have the program below which has a dynamic array of 15 elements and the elements inside 0:4. My question is i want any elements to be not consecutive. How do i do this with const?
if(i>0 && hello[i]!=0) {hello[i-1] != hello[i];} this is working
if (i>0 && hello[i]!=0) (hello[i] != const'(hello[i])) ; this is not working
Example : 2,3,4,1,0
2,2,1,3,4 (Not allowed as 2 is repeating at first)
program tb;
class ABC;
rand int hello[];
constraint ab {
hello.size==15;
foreach (hello[i]) {
hello[i] inside {[0:4]};
// if (i>0 && hello[i]!=0) (hello[i] != const'(hello[i])) ;
if(i>0 && hello[i]!=0) {hello[i-1] != hello[i];}
}
}
endclass
ABC A1;
initial begin
A1 = new();
repeat (3) begin
if (!A1.randomize())
$display ("Error");
$display ("%p",A1.hello);
end
end
endprogram