Constraint question

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

In reply to rag123:

You need to clarify what you mean by “not consecutive”. The constraint
hello[i-1] != hello[ i];
prevents consecutive elements in the array from having the same value. You would not use const for that.

If you wanted to prevent the same element from having the same value between consecutive randomizations, you would use
hello[ i] != const’(hello[ i]);

.

In reply to dave_59:

Thanks Dave :) Now i remember :)