Sum query on a Multi D array

In reply to dave_59:

Was trying this at my end in Edaplayground and have been hitting errors. Wanted to know if my logic is wrong.

To start with I want to constraint a 2-D array which has its column values sum up to 30. Here’s my code inside a class -


  rand bit [7:0] array[5][5];
  
  constraint c_col_val {
    foreach(array[col,row])
      array[col].sum() == 30;
  };