First(),last(),next(),num() on a associative array

Hi,
when we want to modify associative array contents we use the following methods like first(),next(),last(),delete()

but when we take a mail box we use get,try_get,peek,put,try_put kind of functions

can some one explain me why we cannot use the methods like first,last,next on a mail box?
we tent to use get,put,peek,try_get,try_put etc…

Thanks in advance,
Rami.

Can some one help me address this please?
Thanks in advance,
Rami.

The API for associative arrays and Mailboxes is defined in the SystemVerilog LRM and therefore they are what they are. To my mind, the APIs seem reasonable for the functionality encapsulated.

If you want to add extra API calls to the mailbox, there is nothing to stop you building a wrapper around a mailbox that adds the calls.

An associative array is a kind of array (sometimes called a hash table) with indexes that may be in no particular order, nor contiguous. The associative array methods are designed to be able to interrogate what is stored in the array.

A mailbox is a built-in class that mixes semaphores with a set of queues. There is a single line waiting to put data into the mailbox and a single line waiting to get data out of the mailbox. The SV mailbox adheres to strict FIFO rules and there is no way to access data in the middle of the FIFO.

As Mark said, you are free to build your own class out of semaphores and whatever data types you want, but I would check with the various communication classes already provided by the OVM to see if they can fill your needs.