r/SVUVM

▲ 3 r/SVUVM

mailbox vs queue

A queue (q[$]) is contiguous storage. It's indexable and we can push/pop elements from the front and back in constant time. If we call pop_front() or pop_back() on an empty list, we get an error. Although it's called queue for historical reasons, it's closer to python's list.

A mailbox is a FIFO that blocks both ends. put() adds an item and get() removes an item. Mailboxes are unbounded by default, but we can make them fixed size. Mailboxes synchronize the flow of transactions between components/threads: when the source thread tries to put a value into a sized mailbox that's full, that thread blocks until the value is removed. Likewise, if a sink thread tries to remove a value from a mailbox that's empty, that thread blocks until a value is put into the mailbox. Queues don't offer this synchronization

Note: A mailbox never holds objects directly, only handles to them. By default it has no fixed type, so nothing stops you from putting a mix of unrelated data into the same mailbox, whereas queues are statically typed so int int_q[$] can hold only values of type int. Always parameterize your mailbox (mailbox #(Transaction) mb) instead, so a type mismatch is caught at compile time rather than corrupting your testbench silently at runtime.

reddit.com
u/hieg_siel — 8 days ago
▲ 5 r/SVUVM+4 crossposts

👋Welcome to r/SVUVM

What the sub is about:

SystemVerilog and UVM. RTL basics, testbenches, verification methodology, all the way up to full UVM environments.

What to Post:

- projects / resumes

- personal notes

- learning resources

- debugging help

- concept breakdown

- interview/exam questions

What not to post:

- pirated books

- pirated video

- cracked licensed software

- any discussions regarding piracy

Happy Learning.

reddit.com
u/hieg_siel — 10 days ago