Creating unique values in array within a range of values

In reply to aashishs2603:

You can use a foreach iterative constraint and the inside operator to constrain each element in a range. You should also use inside constrain the size of the array.

rand logic [4:0] d_arr[$];
  constraint uniq {d_arr.size inside {[1:7]};
                   unique {d_arr}};
                   foreach (d_arr[i]) d_arr[i] inside {[7:30]};
  }