Finding the index of the minimum value of an array

In reply to uvm_va_1:

The return type of min function is unpacked, we can not compare packed data type(here item) with unpacked data type. We can do as below



module test();
  
  int x [] = {13,41,89,31,2,67,2};
  
  int q[$];
  int y[$];
  
  
  initial
    begin
      y = x.min;
      foreach(y[i])
             q = x.find_index with(item == y[i]);
      $display("%p",q);
    end
endmodule

Regards,
Shanthi V A
www.maven-silicon.com