Constraint Randomization

Hi All,

I need help in writing constraint.

class foo;

rand bit [31:0] numbers [5];

//constraint requirements are that array elements are unique and the numbers should be non consecutive numbers as well. Numbers are between 0 -100
// Valid Solution can  be: 0 2 6 9 11. 
// While if the solution is 0, 2, 3 , 6, 9 May be unique, this wont be a valid solution.

endclass:foo

In reply to rre_dortmund:

That is three constraints

constraint range { foreach (numbers[i]) numbers[I] inside {[0:10]}; }
constraint uniqu { unique {numbers}; }
constraint nonco { foreach (numbers[i]) foreach (numbers[j])
                        numbers[i] - numbers[j] != 1; }

You might want to optimize this to remove redundant or unnecessary constraints. (like when i==j, and comparing [j][i] versus [i][j])