Systemverilog Mailbox is communication mechanism to allows packets(object of sequence item/transaction) to be exchanged between two blocks/components/processes of Testbench.
Systemverilog Mailbox can efficiently use to exchange information between two independent components.
LIMITATION OF SEMAPHORE
Systemverilog Semaphore could not exchange information between to process. It can useful only for locking mechanism between to processes. Which means Semaphore could not able to send packet(object of sequence item) from one process to another process.Mailbox is automatic class of semaphore.
REQUIREMENT
It is the most required process to send a packet from one process to another process. Consider the scenario to send entire packet information like address, data, packet_no, message_no to another process.
APPLICATION
To send data from generator to driver.
ANALOGY
It is like pipe line connection between to process/components for data exchange.
USER WANTS CODE
program mailbox;
mailbox m1;
int i,j;
initial
begin
m1 = new; // allocate memory to mailbox
repeat(5)
begin
m1.put(i); //put value in mailbox
i++;
m1.get(j); // get value in mailbox
$display("value of j = %d",j);
end
end
endprogram
program mailbox;
mailbox m1;
int i,j;
initial
begin
m1 = new; // allocate memory to mailbox
repeat(5)
begin
m1.put(i); //put value in mailbox
i++;
m1.get(j); // get value in mailbox
$display("value of j = %d",j);
end
end
endprogram