The pop_front function does not seem to decrease the size of the queue. As a result the following while loop never breaks(here ‘sequence_item_base’ is a class and ‘list’ is its static queue member):
while(sequence_item_base::list.size() != 0)
begin
popped_addr = sequence_item_base::list.pop_front();
$display("popped addr : 0x%h", popped_addr );
$display("Size of list:%d",sequence_item_base::list.size());
end
The output just cycles again and again through the queue:
It works for me - at least with the following test case:
class qic;
static bit[31:0] addr_q[$];
function new();
addr_q.push_back(32’h0);
addr_q.push_back(32’h1);
addr_q.push_back(32’h2);
addr_q.push_back(32’h3);
addr_q.push_back(32’h4);
endfunction
endclass: qic
module qic_tb;
qic q;
bit[31:0] addr;
initial begin
q = new();
while(q.addr_q.size() != 0) begin
addr = q.addr_q.pop_front();
$display(“addr: %h size:%0d”, addr, q.addr_q.size());
end
q = new;
while(qic::addr_q.size() != 0) begin
addr = qic::addr_q.pop_front();
$display(“addr: %h size:%0d”, addr, qic::addr_q.size());
end
end
endmodule: qic_tb
You may need to share more of your code in order to understand the source of the problem. What is the purpose of the sequence_item_base class? What is its content?
I had implemented the push_back functionality in the post_randomize phase of uvm. When I used to generated write sequences using randomize function, it used to push the address in the queue. But when I generated read sequences, the same used to happen inspite of popping the data out of the queue. That was undesired. Now it works. Thank you.