User guide

24-181
SystemVerilog Testbench Constructs
end
i = mbx.num();
repeat (3)
begin
#5 $display("No. of msgs in mbx = %0d j = %0d at
%0t",i,j,$time);
mbx.get(j);
i = mbx.num();
end
end
endprogram
This program declares a mailbox named mbx with the mailbox
keyword and the new() method.
The initial block does the following:
1. Executes a repeat loop three times which does the following:
a. Puts the value of k in the mailbox.
b. Assigns the number of messages in the mailbox to i.
c. Increments the value of k.
2. Execute another repeat loop three times that does the following:
a. Displays the number of messages in the mailbox, the value of
j, and the simulation time.
b. Assigns the first expression in the mailbox to j.
c. Assigns the number of messages to i.
The $display system tasks display the following:
No. of msgs in mbx = 1 at 5
No. of msgs in mbx = 2 at 10
No. of msgs in mbx = 3 at 15
No. of msgs in mbx = 3 j = 0 at 20
No. of msgs in mbx = 2 j = 10 at 25
No. of msgs in mbx = 1 j = 11 at 30