User guide
24-180
SystemVerilog Testbench Constructs
get(number_of_keys)
Decrements the number of keys in the semaphore. If there aren’t
the specified number of keys in the semaphore, VCS halts
simulation of the process (initial block, task, etc.) until there the
put method in another process increments the number of keys
to the sufficient number.
try_get (number_of_keys)
Decrements the number of keys in the semaphore. If there aren’t
the specified number of keys in the semaphore, this method
returns a 0. If the semaphore has the specified number of keys,
this method returns 1. After returning the value, VCS executes
the next statement.
Mailboxes
Mailboxes are FIFO containers for messages that are expressions.
Note:The SystemVerilog 3.1a LRM specifies that you can specify a
maximum number of messages that a mailbox can hold, but this
feature isn’t implemented yet.
program prog;
mailbox mbx = new ();
int i,j;
int k = 10;
initial
begin
repeat(3)
begin
#5 mbx.put(k);
i = mbx.num();
$display("No. of msgs in mbx = %0d at %0t",i,$time);
k = k + 1;