1
votes

I have a mailbox of type ethernet packet. I have randomly put data into the mailbox. Now I want to print each element of mailbox without removing the element. I tried doing try_peek but it always points to the first element, so it always prints the first element. the get() method removes the element, so at the end of for loop the mailbox is empty. Is there a way that I can iterate over a mailbox in SystemVerilog without removing its elements?

for (int i=0; i<=9; i++)
                begin
                    mbox_pkt.try_peek(pkt1);
                    $display("mbox_pkt=%p", pkt1);
                end

mbox_pkt is a mailbox of type ethernet packet.

1

1 Answers

1
votes

There is no way to access elements of a mailbox without removing the next element with a get or try_get.