2D array constraint randomization

In reply to prasadaddagarla:

Hey,

Have you tried this on multidimensional dynamic array?

I have tried and it give me below error,

class matrix_cons;
  
  rand bit [2:0] a [][];
  
  constraint c1 { a.size() == 2;
                  foreach (a[i])
                 a[i].size() == 2;}
  
  
  constraint c2 {
      
      foreach (a[i,j]) {
        a.sum() with (item.index(1) == i ? int'(item) : 0) == 10;
        a.sum() with (item.index(2) == j ? int'(item) : 0) == 10;
    }
      unique{a};
  }  
  
endclass

Error-[IAMC] Invalid array manipulation method call
testbench.sv, 18
Wrong usage of array manipulation method ‘sum’ as this method is not
supported on variable-size multidimensional arrays.

Error-[IAMC] Invalid array manipulation method call
testbench.sv, 19
Wrong usage of array manipulation method ‘sum’ as this method is not
supported on variable-size multidimensional arrays.

Can you please try and let me know if you are facing same issue.

Thanks,