Working with Multi-dimensional uvm_queue

Hi,

I’m trying to create an object which is constructed from array of uvm_queue. The idea is that each item in the array is for itself a uvm_queue ( i.e. a list of items).
The problem is I can’t manage to iterate the items of a single ‘memory ID’ list.

When I compile I get the following Error:
*if (ml_mem_array[mem_id][ii].m_addr == a_addr)
|
xmelab: E,CUVNAA (./utils.sv,47|45): An index has been applied to an inappropriate type.

The code looks like this:

// ============================================================================

class mem_entry extends uvm_object;

   int m_addr;
   int m_data;

…
endclass

// =============================================================================

class memory extends uvm_object;

   uvm_queue#(mem_entry) ml_mem_array[2];

   function new (string name = "memory");
      super.new(name);
   endfunction

   function mem_entry get_mem_entry(int a_addr, int mem_id);

      int v_size;
      int ii;

      v_size = ml_mem_array[mem_id].size();

     if ((mem_id >= 2) || (v_size == 0))
        return null;

      for (ii=0 ; ii<=(v_size-1) ; ii=ii+1)
        begin
           if (ml_mem_array[mem_id][ii].m_addr == a_addr)
             return ml_mem_array[mem_id][ii];
        end

      return null;
   endfunction

endclass

In reply to Tamir:

Please use code tags making your code easier to read. I have added them for you.

You need to use the get() method of uvm_queue to access the internal queue elements

 for (int ii=0 ; ii<=(v_size-1) ; ii=ii+1)
    begin
       mem_entry entry = ml_mem_array[mem_id].get(ii);
       if (entry.m_addr == a_addr)
         return entry;
    end

In reply to dave_59:

Thanks Dave, this solved my issue.
BTW, is it possible to replace the for loop with foreach loop ?
What is the syntax ?

In reply to Tamir:

You cannot use a foreach loop because the queue is protected inside the uvm_queue class