PDA

View Full Version : Difference between try_put() and can_put()



mohammed.peer
01-02-2010, 06:59 AM
Hi,
I am new to ovm methodology, I just want to know about the basic difference between try_put() and can_put() methods.

Regards
Peer Mohammed

dave_59
01-02-2010, 07:54 AM
The non-blocking try_put() function will attempt to perform a put operation and will return true if it succeeds, and false if does not. If it fails, then you have to try again, or use a blocking put() that will wait until the operation succeeds.

The can_put() function is just a test to see if a non-blocking put operation would succeed without actually performing the operation. This is typically used in arbitration schemes where you want to check the availability of a number of ports, and make a decision based on the set of ports currently availible. For example, you might want to randomly select a port amongst the availible ports instead of randomly selecting an unavailable port and blocking.

Note that the can_put() and can_get() functions are immediate tests. In a multi-process environment, there is no guarantee of success in the statements that follow. For example.

if (p_port.can_put()) void'(p_port.try_put(trans));

Unless this statement is within the only process performing puts, there is no guarentee that the try_put() has succeeded.

Dave

mohammed.peer
01-02-2010, 09:13 PM
Thanks Dave for clarification..