How does one find the min/max element in a multi-dimensional SV array?


int some_array [2][15];

In reply to new_to_uvm:

Remember to think of arrays of arrays instead of multidimensional arrays.

min_element = some_array.min() with (item.min());

In reply to dave_59:

Hi Dave:
How do I replace my code (shown below) with your 1 line solution?
Thank You!


module test;
  int foo_array [2][2] = '{ '{2,1},'{6,7}};
  int my_min[$];
  initial begin
    foreach (foo_array[i]) begin
          my_min = {my_min, foo_array[i].min()};
    end
    my_min = my_min.min();
    $display("my_min[0] = ", my_min[0]);
  end
endmodule

Hi Dave,

What does the “with (item.min()” → “item” in this mean? Does it refer to 1D array

Thanks

In reply to curious_verifier:

Yes, in this case item refers to the second dimension of each element of the first dimension.