Hi SV forum,
I have a class which contain getter method which return addr value of type int.
class reg extends uvm_object;
int addr;
int val;
...
function int get_addr();
return addr;
endfunction
endclass
In other class I have queue of objects of reg type.
I need to write a method which create a sorted queue,
meaning that the first item in the queue will be reg with lowest addr value
and the last item will be reg with highest addr value.
I did it but it took me allot of code, is there a way maybe using array reduction technique to do it with less code?
// q[0]={addr=1,val=12}, q[1]={addr=10,val=9}, q[2]={addr=8,val=4}
// sq[0]={addr=1,val=12}, sq[1]={addr=8,val=4}, sq[2]={addr=10,val=9}
class algo extends uvm_object;
reg q[$];
reg sq[$]; //sorted queue
...
function void sort_q_by_addr();
endfunction
endclass