QUEUE

I have queue which is having elements multiple of 16. Ex 256. But I have to take 16 element from queue and process that. After processing first 16 elements , I need to take next 16 elements from queue and process until all elements are finished processing from queue.
Please help me for this.

In reply to poonamnlwd:

You have not mentioned, required 16 element is available in consecutive location or available at different location.
if it is in consecutive location , Then i think queue empty checking + retrieving 16 entry in each round will work for you. ( like below ).



module m;
  bit [31:0] data_queue[$:255] = '{256{$urandom}};

  initial begin
    while(data_queue.size > 0)begin
      automatic bit [31:0] temp_data [16];
      for(bit[4:0] i = 0; i <= 15; i++) temp_data[i] = data_queue.pop_front();
      // Now process temp_data;
    end
  end
  
endmodule : m

Thanks!

In reply to harsh pandya:

modified the code to pop 16 elements from queue and create a single vector.


module m;
  bit [31:0] data_queue[$:255];

  initial begin

    for(int i=0; i<256; i++) data_queue[i]=i+1;

    while(data_queue.size > 0)begin
      automatic bit [16] [31:0] temp_data;
      foreach(temp_data[i]) temp_data[i] = data_queue.pop_front();
      $display("temp_data=0x%x",temp_data);
      // Now process temp_data;
    end
  end

endmodule : m

In reply to harsh pandya:
I tried with this solution. Its working. Thanks
.

In reply to Alokpati:

Thanks for reply.