How does the actual blocking put/get happens inside the mailbox or the uvm blocking ports etc?

Hello Folks,

a. Was trying to build up a system for transporting packets similar to mailbox or uvm_blocking ports.
b. Where in have a fifo size of say 5, and can do write/read to the fifo using put/get methods.
c. Just similar to mailbox… When the fifo is full, the put should block until its empty…
d. And so does get should block until fifo is having some data.
c. I tried looking for internal code details inside the uvm libraries, but unable to find the same.

Can anyone kindly share where can I find the internal code details for the block put/get process either in uvm libraries or give a snapshot of the code ?

Thanks in Advance !!

for mailbox kind of functionality you can use following code.

class channel #(type T = int, depth = 5);
T fifo[$]

task put(T tr);
wait(fifo.size() < depth);
fifo.push_back(tr) ;
endtask

task get(output T tr);
wait(fifo.size()>0);
tr = fifo.pop_front();
endtask

endclass

In reply to desperadorocks:
put and get are always blocking. You do not need a fifo bigger than 1.

@Chandra & @Chris:

Thanks guys for your inputs. Hmm makesense, so all the blocking ports in the uvm port libraries just have a size of 1 to store just one element and except the uvm_tlm_fifo which can have variable limit.

B/w… How does the normal fifo takes care of the push_back and pop_front process ?
a. Do they internally have the wr_pointer and rd_pointer concepts ? accordingly they manipulate the data’s ? or any other functionality is used ?

Share in your comments !! Thanks !!

In reply to desperadorocks:

The internal code for the uvm_tlm_fifo is easily available https://verificationacademy.com/verification-methodology-reference/uvm/docs_1.2/html/src/tlm1/uvm_tlm_fifos.svh

@Dave: THanks for pointing out the library. But my other query was, while using the queue we use the system function like push_back or push_front, pop_back or pop_front… So how does these work ? do they internal wr/rd pointer etc ? Where can I find such system function codes which resides in the systemverilog ? Can you kindly point me to the same ? Thanks !!

Hello Folks,

Can anyone provide some comments on the same ?

a. How does the system function like push_back, push_front or pop_back, pop_front works ?
b. Do they work with some reference write pointers and read pointers ?
c. Is there any standard place where we can see the functional implementation of these codes ? i.e. for mailbox, queues, process fine grain control etc ?

Please share in your comments/thought process. Thanks !! Happy Holidays !!

In reply to desperadorocks:
The SystemVerilog standard does not impose any implementation; only the functionality. Queues are a familiar data structure in software and you can look up many examples of how they are coded. You will have to check with your synthesis vendor to see if and how they are implemented.

Mailboxes are primarily a software concept built using a combination of queues and semaphores. Again, you can look up many examples of how mailboxes are implemented in software.