Difference between try_put and can_put method in tlm

,

Hi Dave,
Can you explain difference between try_put and can_put method in uvm_nonblocking_put_port with an example ?

Hi Rohan,

You don’t need to ask me specifically, there are plenty of other people around answering questions, and I would certainly like to see more.

If a put_port is implemented as a FIFO, the easiest way to think of can_put() would be the return value !(fifo.is_full()).

try_put() is the combination of can_put() followed immediately by a nonblocking put() as single atomic operation. If the port can, the put is guaranteed to happen. If you call can_put() followed by try_put() as two individual statements, there is no guarantee that try_put() will succeed even if can_put() returned true. This happens rarely, but is possible when there are multiple threads puting and getting from the same channel.

I don’t have time to write an example, but the most common place you would use can_put() is when you have one process sending transactions to multiple put_ports. An arbitration scheme might look to see which ports are available using can_put() before deciding which port to do the put. Another possibility is you might want to split the transaction up into pieces based on the available number of put_ports.

In reply to dave_59:

Thanks DAVE