Hi,
i am trying to find the two dimensional index of array whose value matches to 1.
i am looking for array method like find_index can be used for the same. i can easily accomplish the same with foreach loop but would like to avoid it.
Below is the code where ind is a queue which has index of row if there is a column in the row has value = 1. if i need to get both row and column pair, how can it be done in below code?
initial begin
bit[3:0] arr1[3][3];
int ind[$];
foreach(arr1[i,j]) begin
arr1[i][j] = i+j;
end
ind = arr1.find_index(n) with (n.find_index(m) with (m==1)); //it return all row which has at least one column corresponding to value =1
$display("array1 is = %p", arr1);
$display("index queue is = %p",ind);
$finish();
end
Thanks,
Amit