Array Method .sum() for multiple dimension array

In reply to Etrx91:

  1. The correct result is randomize should fail. There are no elements to sum, so how could it ever equal 27?
  2. You are bitstream casting the 2nd dimension to an int. So if there were any elements in that dimension, they get concatenated to a single int
  3. The ()'s after sum is where you can change item. You can write
box.sum(item1d) with (item1d.sum(item2d) with (item2d));
  1. SystemVerilog does not really have multidimensional array, it has arrays of arrays. So there is no simpler way to size the dimensions.
  2. No.
  3. You can flatten your array to a single dimension.