SystemVerilog Mailbox: put, get, peek, bounded vs unbounded, and the reused-handle bug. Tested on VCS. The Art of Verification

SystemVerilog Mailbox: put, get, Bounded and Parameterized (Tested)

In short: A mailbox is a built-in SystemVerilog FIFO for passing messages between processes. put() adds an item and get() removes the oldest one, and both can block: get() waits while the mailbox is empty, and put() waits while a bounded mailbox is full. Use mailbox #(T) so the compiler checks the type, and remember that for class items the mailbox holds handles, not copies.

A mailbox is how a generator hands transactions to a driver in a class-based testbench. It is also behind one of the most common bugs new verification engineers write.

In this lesson we test every mailbox method in one UVM bench, measure exactly when put() and get() block, and plant that classic bug. I ran it on Synopsys VCS.

Start here: the simplest example

One producer, one consumer, one mailbox. The producer is fast and the consumer is slow.

// tav_mbox_simple.sv : the smallest mailbox example (UVM 1.2 reporting only)
// The Art of Verification | theartofverification.com
// Run on Synopsys VCS X-2025.06-SP1 with UVM 1.2 (EDA Playground), 30 Nov 2026.
// EDA Playground: Synopsys VCS, UVM 1.2, top module "tav_top".

`timescale 1ns/1ns
`include "uvm_macros.svh"

module tav_top;
  import uvm_pkg::*;
  mailbox #(int) tav_mb = new();            // unbounded

  initial begin
    fork
      begin                                 // producer: puts 3 values at time 0
        for (int i = 1; i <= 3; i++) begin
          tav_mb.put(i * 10);
          `uvm_info("TAV_SIMPLE", $sformatf("put %0d at %0t ns, holds %0d", i * 10, $time, tav_mb.num()), UVM_NONE)
        end
      end
      begin                                 // consumer: takes one every 5 ns
        int v;
        repeat (3) begin
          #5;
          tav_mb.get(v);
          `uvm_info("TAV_SIMPLE", $sformatf("got %0d at %0t ns", v, $time), UVM_NONE)
        end
      end
    join
  end
endmodule

Here is what VCS printed:

UVM_INFO testbench.sv(18) @ 0: reporter [TAV_SIMPLE] put 10 at 0 ns, holds 1
UVM_INFO testbench.sv(18) @ 0: reporter [TAV_SIMPLE] put 20 at 0 ns, holds 2
UVM_INFO testbench.sv(18) @ 0: reporter [TAV_SIMPLE] put 30 at 0 ns, holds 3
UVM_INFO testbench.sv(26) @ 5: reporter [TAV_SIMPLE] got 10 at 5 ns
UVM_INFO testbench.sv(26) @ 10: reporter [TAV_SIMPLE] got 20 at 10 ns
UVM_INFO testbench.sv(26) @ 15: reporter [TAV_SIMPLE] got 30 at 15 ns
  • The puts: all three happen at 0 ns, because an unbounded mailbox never makes put() wait.
  • The gets: the values come out in the same order, one every 5 ns. The mailbox held them in between.

The rest of this lesson builds on this. The full bench further down tests the same idea from more angles, with a planted bug.

What you will learn

  • The six mailbox methods and which ones block.
  • Bounded vs unbounded, with real timing from the simulator.
  • Why mailbox #(T) beats a plain mailbox.
  • Why reusing one object for every put() breaks your driver.
  • When to pick a mailbox over a queue, an event or a semaphore.

Cheat sheet: mailbox methods

MethodBlocks?ReturnsRemoves the item?
put(x)Yes, if bounded and fullNothing (task)n/a
try_put(x)No0 if fulln/a
get(x)Yes, if emptyNothing (task)Yes
try_get(x)No0 if emptyYes
peek(x)Yes, if emptyNothing (task)No
try_peek(x)No0 if emptyNo
num()NoItems insideNo

Analogy: a mailbox is a real letterbox with a slot. Letters come out in the order they went in, a full box makes the postman wait, and an empty box makes you wait at the door.

Bounded vs unbounded

UnboundedBounded
Declaremailbox #(int) mb = new();mailbox #(int) mb2 = new(2);
Size limitNoneThe number you pass to new()
put() when “full”Never blocksWaits until a get() makes room
Typical useGenerator to driver when speed does not matterBack pressure: keep a fast producer in step with a slow consumer

Parameterized vs generic

  • mailbox #(tav_item) only accepts tav_item handles. A wrong type is a compile error.
  • Plain mailbox accepts anything. A type mismatch shows up only at run time, when get() pulls the item out.
  • Use the parameterized form unless you have a real reason not to.

The handle trap

When the item is a class, put() stores the handle, not a copy of the object. If the generator creates one object and changes it before each put(), every slot in the mailbox points to that same object.

Diagram: tav_gen puts 5 handles into a mailbox #(tav_item) and tav_drv gets them every 10 ns. When a new item is created before every put, the 5 handles point to 5 objects with id 1 to 5 and the driver sees 1 2 3 4 5. With +BUG=1 one item is reused, all 5 handles point to one object with id 5 and the driver sees 5 5 5 5 5
A new object per put() vs one object reused, as in the bench.

Going further: one bench, 8 checks

  • tav_gen puts 5 tav_items into an unbounded mailbox #(tav_item), all at time 0.
  • tav_drv takes one item out every 10 ns and records its tav_id.
  • tav_env builds both and gives them the same mailbox in connect_phase.
  • tav_mbox_test runs checks 1 to 7 on two mailbox #(int), one unbounded and one bounded to 2, then check 8 on what the driver received.
  • Planted bug: +BUG=1 makes the generator create one item and reuse it.

Run it yourself: the same file is on GitHub, with the expected output from both runs.

// tav_mbox_uvm.sv : the SystemVerilog mailbox, a complete working example (UVM 1.2)
// The Art of Verification | theartofverification.com
// Run on Synopsys VCS X-2025.06-SP1 with UVM 1.2 (EDA Playground), 30 Nov 2026.
// EDA Playground: Synopsys VCS, UVM 1.2, top module "tav_top".
// Paste this whole file into testbench.sv and leave design.sv empty.
//
// What is in here:
//   tav_item          a UVM transaction with a tav_id field
//   tav_gen           puts 5 items into a mailbox #(tav_item), all at time 0
//   tav_drv           takes one item out every 10 ns and records its tav_id
//   tav_env           builds gen and drv and gives them the same mailbox
//   tav_mbox_test     8 self-checks, each printed with `uvm_info and checked with `uvm_error:
//                     1 FIFO order   2 num()   3 peek() keeps the item   4 try_get() on empty
//                     5 try_put() on full   6 put() blocks on a full bounded mailbox
//                     7 get() waits for an item   8 generator to driver through the mailbox
//
// Run options:
//   (none)   all 8 checks pass, 0 errors
//   +BUG=1   tav_gen creates one item and reuses it, so the driver sees the same handle 5 times

`timescale 1ns/1ps
`include "uvm_macros.svh"

package tav_mbox_pkg;
  import uvm_pkg::*;
  `include "uvm_macros.svh"

  // ---------------------------------------------------------------
  // Transaction
  // ---------------------------------------------------------------
  class tav_item extends uvm_sequence_item;
    `uvm_object_utils(tav_item)
    int tav_id;
    function new(string name = "tav_item");
      super.new(name);
    endfunction
  endclass

  // ---------------------------------------------------------------
  // Generator: puts 5 items into the mailbox at time 0
  // ---------------------------------------------------------------
  class tav_gen extends uvm_component;
    `uvm_component_utils(tav_gen)
    mailbox #(tav_item) tav_mb;
    int tav_bug;

    function new(string name, uvm_component parent);
      super.new(name, parent);
    endfunction

    task run_phase(uvm_phase phase);
      tav_item it;
      void'($value$plusargs("BUG=%d", tav_bug));
      if (tav_bug == 1) it = tav_item::type_id::create("it");    // BUG: one object for all 5
      for (int i = 1; i <= 5; i++) begin
        if (tav_bug != 1) it = tav_item::type_id::create($sformatf("it%0d", i));  // a new object each time
        it.tav_id = i;
        tav_mb.put(it);
        `uvm_info("TAV_GEN", $sformatf("put tav_id=%0d, mailbox now holds %0d", i, tav_mb.num()), UVM_LOW)
      end
    endtask
  endclass

  // ---------------------------------------------------------------
  // Driver: takes one item every 10 ns
  // ---------------------------------------------------------------
  class tav_drv extends uvm_component;
    `uvm_component_utils(tav_drv)
    mailbox #(tav_item) tav_mb;
    int tav_ids[$];

    function new(string name, uvm_component parent);
      super.new(name, parent);
    endfunction

    task run_phase(uvm_phase phase);
      tav_item it;
      forever begin
        #10;
        tav_mb.get(it);
        tav_ids.push_back(it.tav_id);
        `uvm_info("TAV_DRV", $sformatf("got tav_id=%0d at %0t", it.tav_id, $time), UVM_LOW)
      end
    endtask
  endclass

  // ---------------------------------------------------------------
  // Env: one mailbox, shared by gen and drv
  // ---------------------------------------------------------------
  class tav_env extends uvm_env;
    `uvm_component_utils(tav_env)
    tav_gen gen;
    tav_drv drv;
    mailbox #(tav_item) tav_mb;

    function new(string name, uvm_component parent);
      super.new(name, parent);
    endfunction

    function void build_phase(uvm_phase phase);
      super.build_phase(phase);
      gen = tav_gen::type_id::create("gen", this);
      drv = tav_drv::type_id::create("drv", this);
      tav_mb = new();                 // unbounded
    endfunction

    function void connect_phase(uvm_phase phase);
      gen.tav_mb = tav_mb;            // both handles point to the SAME mailbox
      drv.tav_mb = tav_mb;
    endfunction
  endclass

  // ---------------------------------------------------------------
  // The test
  // ---------------------------------------------------------------
  class tav_mbox_test extends uvm_test;
    `uvm_component_utils(tav_mbox_test)

    tav_env env;
    int     tav_pass, tav_fail;

    function new(string name, uvm_component parent);
      super.new(name, parent);
    endfunction

    function void build_phase(uvm_phase phase);
      super.build_phase(phase);
      env = tav_env::type_id::create("env", this);
    endfunction

    function void tav_check(string what, string got, string exp);
      if (got == exp) begin
        tav_pass++;
        `uvm_info("TAV_MBOX", $sformatf("PASS %s: %s", what, got), UVM_LOW)
      end
      else begin
        tav_fail++;
        `uvm_error("TAV_MBOX", $sformatf("FAIL %s: got %s, expected %s", what, got, exp))
      end
    endfunction

    task run_phase(uvm_phase phase);
      mailbox #(int) mb  = new();    // unbounded
      mailbox #(int) mb2 = new(2);   // bounded: holds at most 2
      int v, a, b, c, t3, t4, t0;
      string s;
      phase.raise_objection(this);

      // 1-2. FIFO order and num()
      mb.put(11); mb.put(22); mb.put(33);
      tav_check("2 num() after 3 puts", $sformatf("%0d", mb.num()), "3");
      mb.get(a); mb.get(b); mb.get(c);
      tav_check("1 get() order", $sformatf("%0d %0d %0d", a, b, c), "11 22 33");

      // 3. peek() copies the item but leaves it in the mailbox
      mb.put(7);
      mb.peek(v);
      tav_check("3 peek() value / num() after peek", $sformatf("%0d/%0d", v, mb.num()), "7/1");
      mb.get(v);

      // 4. try_get() on an empty mailbox returns 0 and does not block
      tav_check("4 try_get() on empty", $sformatf("%0d at %0t", mb.try_get(v), $time), "0 at 0");

      // 5. try_put() on a full bounded mailbox returns 0
      mb2.put(1); mb2.put(2);
      tav_check("5 try_put() on full (bound 2)", $sformatf("%0d, num=%0d", mb2.try_put(3), mb2.num()), "0, num=2");
      mb2.get(v); mb2.get(v);

      // 6. put() blocks on a full bounded mailbox until the consumer makes room
      t0 = $time;
      fork
        for (int i = 1; i <= 4; i++) begin
          mb2.put(i);
          if (i == 3) t3 = $time - t0;
          if (i == 4) t4 = $time - t0;
        end
        repeat (4) begin
          #10;
          mb2.get(v);
        end
      join
      tav_check("6 put() 3 and 4 finished at (ns)", $sformatf("%0d and %0d", t3, t4), "10 and 20");

      // 7. get() waits until an item arrives
      t0 = $time;
      fork
        begin #15; mb.put(42); end
        begin mb.get(v); t3 = $time - t0; end
      join
      tav_check("7 get() value / waited (ns)", $sformatf("%0d / %0d", v, t3), "42 / 15");

      // 8. Generator to driver: 5 items, in order, each its own object
      wait (env.drv.tav_ids.size() == 5);
      foreach (env.drv.tav_ids[i]) s = {s, $sformatf("%0d ", env.drv.tav_ids[i])};
      tav_check("8 tav_id order at the driver", s, "1 2 3 4 5 ");

      `uvm_info("TAV_MBOX", $sformatf("Checks: %0d pass, %0d fail", tav_pass, tav_fail), UVM_NONE)
      phase.drop_objection(this);
    endtask
  endclass

endpackage

module tav_top;
  import uvm_pkg::*;
  import tav_mbox_pkg::*;
  initial run_test("tav_mbox_test");
endmodule

How to run it

  1. Open EDA Playground and pick Synopsys VCS with UVM 1.2.
  2. Paste the file into testbench.sv and leave design.sv empty.
  3. Run it once as is, then add +BUG=1 to the run options and run again.

What VCS returned

#CheckResultWhat it proves
1get() order after 3 puts11 22 33Oldest item comes out first
2num() after 3 puts3num() counts what is inside
3peek() value / num() after7/1peek() copies, it does not remove
4try_get() on empty0 at 0Returns 0 at once, no wait
5try_put() on a full bound-2 mailbox0, num=2The item was not added
6When blocked put() 3 and 4 finished10 and 20 nsEach waited for the consumer’s next get()
7get() value / wait42 / 15 nsget() slept until the put() 15 ns later
8tav_id order at the driver1 2 3 4 5Each put() carried its own object

Result: 8 pass, 0 fail. Here is the log from the clean run.

UVM_INFO @ 0: reporter [RNTST] Running test tav_mbox_test...
UVM_INFO testbench.sv(59) @ 0: uvm_test_top.env.gen [TAV_GEN] put tav_id=1, mailbox now holds 1
UVM_INFO testbench.sv(59) @ 0: uvm_test_top.env.gen [TAV_GEN] put tav_id=2, mailbox now holds 2
UVM_INFO testbench.sv(59) @ 0: uvm_test_top.env.gen [TAV_GEN] put tav_id=3, mailbox now holds 3
UVM_INFO testbench.sv(59) @ 0: uvm_test_top.env.gen [TAV_GEN] put tav_id=4, mailbox now holds 4
UVM_INFO testbench.sv(59) @ 0: uvm_test_top.env.gen [TAV_GEN] put tav_id=5, mailbox now holds 5
UVM_INFO testbench.sv(134) @ 0: uvm_test_top [TAV_MBOX] PASS 2 num() after 3 puts: 3
UVM_INFO testbench.sv(134) @ 0: uvm_test_top [TAV_MBOX] PASS 1 get() order: 11 22 33
UVM_INFO testbench.sv(134) @ 0: uvm_test_top [TAV_MBOX] PASS 3 peek() value / num() after peek: 7/1
UVM_INFO testbench.sv(134) @ 0: uvm_test_top [TAV_MBOX] PASS 4 try_get() on empty: 0 at 0
UVM_INFO testbench.sv(134) @ 0: uvm_test_top [TAV_MBOX] PASS 5 try_put() on full (bound 2): 0, num=2
UVM_INFO testbench.sv(82) @ 10000: uvm_test_top.env.drv [TAV_DRV] got tav_id=1 at 10000
UVM_INFO testbench.sv(82) @ 20000: uvm_test_top.env.drv [TAV_DRV] got tav_id=2 at 20000
UVM_INFO testbench.sv(82) @ 30000: uvm_test_top.env.drv [TAV_DRV] got tav_id=3 at 30000
UVM_INFO testbench.sv(82) @ 40000: uvm_test_top.env.drv [TAV_DRV] got tav_id=4 at 40000
UVM_INFO testbench.sv(134) @ 40000: uvm_test_top [TAV_MBOX] PASS 6 put() 3 and 4 finished at (ns): 10 and 20
UVM_INFO testbench.sv(82) @ 50000: uvm_test_top.env.drv [TAV_DRV] got tav_id=5 at 50000
UVM_INFO testbench.sv(134) @ 55000: uvm_test_top [TAV_MBOX] PASS 7 get() value / waited (ns): 42 / 15
UVM_INFO testbench.sv(134) @ 55000: uvm_test_top [TAV_MBOX] PASS 8 tav_id order at the driver: 1 2 3 4 5 
UVM_INFO testbench.sv(197) @ 55000: uvm_test_top [TAV_MBOX] Checks: 8 pass, 0 fail
UVM_INFO /apps/vcsmx/vcs/X-2025.06-SP1//etc/uvm-1.2/src/base/uvm_objection.svh(1276) @ 55000: reporter [TEST_DONE] 'run' phase is ready to proceed to the 'extract' phase
UVM_INFO /apps/vcsmx/vcs/X-2025.06-SP1//etc/uvm-1.2/src/base/uvm_report_server.svh(904) @ 55000: reporter [UVM/REPORT/SERVER] 
--- UVM Report Summary ---

** Report counts by severity
UVM_INFO :   22
UVM_WARNING :    0
UVM_ERROR :    0
UVM_FATAL :    0
** Report counts by id
[RNTST]     1
[TAV_DRV]     5
[TAV_GEN]     5
[TAV_MBOX]     9
[TEST_DONE]     1
[UVM/RELNOTES]     1

Two things are worth noticing in the log. The generator put all 5 items at time 0, because an unbounded put() never waits. The driver then took one every 10 ns, so the mailbox acted as a buffer between a fast producer and a slow consumer.

Reading the times: %0t prints in the simulation precision, which is 1 ps here, so 10 ns shows as 10000. Checks 6 and 7 subtract $time values instead, so they read in ns.

The planted bug: five handles, one object

With +BUG=1, the generator calls create() once, before the loop. Each pass changes tav_id and puts the same handle again.

UVM_INFO @ 0: reporter [RNTST] Running test tav_mbox_test...
UVM_INFO testbench.sv(59) @ 0: uvm_test_top.env.gen [TAV_GEN] put tav_id=1, mailbox now holds 1
UVM_INFO testbench.sv(59) @ 0: uvm_test_top.env.gen [TAV_GEN] put tav_id=2, mailbox now holds 2
UVM_INFO testbench.sv(59) @ 0: uvm_test_top.env.gen [TAV_GEN] put tav_id=3, mailbox now holds 3
UVM_INFO testbench.sv(59) @ 0: uvm_test_top.env.gen [TAV_GEN] put tav_id=4, mailbox now holds 4
UVM_INFO testbench.sv(59) @ 0: uvm_test_top.env.gen [TAV_GEN] put tav_id=5, mailbox now holds 5
UVM_INFO testbench.sv(134) @ 0: uvm_test_top [TAV_MBOX] PASS 2 num() after 3 puts: 3
UVM_INFO testbench.sv(134) @ 0: uvm_test_top [TAV_MBOX] PASS 1 get() order: 11 22 33
UVM_INFO testbench.sv(134) @ 0: uvm_test_top [TAV_MBOX] PASS 3 peek() value / num() after peek: 7/1
UVM_INFO testbench.sv(134) @ 0: uvm_test_top [TAV_MBOX] PASS 4 try_get() on empty: 0 at 0
UVM_INFO testbench.sv(134) @ 0: uvm_test_top [TAV_MBOX] PASS 5 try_put() on full (bound 2): 0, num=2
UVM_INFO testbench.sv(82) @ 10000: uvm_test_top.env.drv [TAV_DRV] got tav_id=5 at 10000
UVM_INFO testbench.sv(82) @ 20000: uvm_test_top.env.drv [TAV_DRV] got tav_id=5 at 20000
UVM_INFO testbench.sv(82) @ 30000: uvm_test_top.env.drv [TAV_DRV] got tav_id=5 at 30000
UVM_INFO testbench.sv(82) @ 40000: uvm_test_top.env.drv [TAV_DRV] got tav_id=5 at 40000
UVM_INFO testbench.sv(134) @ 40000: uvm_test_top [TAV_MBOX] PASS 6 put() 3 and 4 finished at (ns): 10 and 20
UVM_INFO testbench.sv(82) @ 50000: uvm_test_top.env.drv [TAV_DRV] got tav_id=5 at 50000
UVM_INFO testbench.sv(134) @ 55000: uvm_test_top [TAV_MBOX] PASS 7 get() value / waited (ns): 42 / 15
UVM_ERROR testbench.sv(138) @ 55000: uvm_test_top [TAV_MBOX] FAIL 8 tav_id order at the driver: got 5 5 5 5 5 , expected 1 2 3 4 5 
UVM_INFO testbench.sv(197) @ 55000: uvm_test_top [TAV_MBOX] Checks: 7 pass, 1 fail
UVM_INFO /apps/vcsmx/vcs/X-2025.06-SP1//etc/uvm-1.2/src/base/uvm_objection.svh(1276) @ 55000: reporter [TEST_DONE] 'run' phase is ready to proceed to the 'extract' phase
UVM_INFO /apps/vcsmx/vcs/X-2025.06-SP1//etc/uvm-1.2/src/base/uvm_report_server.svh(904) @ 55000: reporter [UVM/REPORT/SERVER] 
--- UVM Report Summary ---

** Report counts by severity
UVM_INFO :   21
UVM_WARNING :    0
UVM_ERROR :    1
UVM_FATAL :    0
** Report counts by id
[RNTST]     1
[TAV_DRV]     5
[TAV_GEN]     5
[TAV_MBOX]     9
[TEST_DONE]     1
[UVM/RELNOTES]     1

Look at the TAV_GEN lines first: they print tav_id=1 to 5, so the generator looks correct. Yet every TAV_DRV line says tav_id=5, and check 8 fails with got 5 5 5 5 5.

The mailbox did its job and delivered 5 items. All 5 were the same object, and by the time the driver looked, its tav_id was 5.

The lesson: create a new object for every put(), or put a copy with clone(). The same trap applies to UVM analysis ports, which also pass handles.

Mailbox vs queue vs event vs semaphore

NeedUseWhy
Pass data from one process to anotherMailboxBuilt-in FIFO with blocking get()
Store data inside one processQueue [$]No blocking, full random access
Signal “something happened”, no dataEventLightweight trigger and wait
Share one resource between processesSemaphoreKeys control access

Common mistakes to avoid

MistakeWhat you seeFix
One object reused for every put()Every received item has the last values (+BUG=1)Create a new item each time, or put() a clone
Forgot new() on the mailboxNull object access at the first put()Construct it once, then share the handle
Each side calls new() on its own handleProducer and consumer use two different mailboxes, and get() waits foreverCreate one mailbox and pass the same handle to both
get() on a mailbox nobody fillsThe test hangsUse try_get() or a timeout in a fork
Ignoring the return of try_put() or try_get()Lost items or stale dataAlways check the return value
Plain mailbox with mixed typesRun-time error on get()Use mailbox #(T)

How AI helps you master this

  • Find the reused handle: paste your generator and ask whether every put() carries a new object.
  • Predict the timing: describe a producer and consumer with a bounded mailbox and ask when each put() finishes. Then check it on the simulator, as in check 6.
  • Debug a hang: paste the code around a stuck get() and ask who is supposed to fill that mailbox.

Warning: a convincing AI answer is not the same as a correct engineering result. AI tools often say a mailbox “copies” the item, but for class items it does not. Run the code.

Interview questions on mailboxes

  • What is the difference between get() and peek()? Both wait for an item and copy it out. get() removes it, peek() leaves it in.
  • What does try_get() return on an empty mailbox? 0, and it returns at once.
  • When does put() block? Only on a bounded mailbox that is full.
  • Does a mailbox copy a class object? No. It stores the handle.
  • Mailbox or queue for generator to driver? Mailbox, because get() blocks until data is there.

More practice: SystemVerilog interview questions.

Practice challenge

  1. Run the bench and confirm 8 pass, 0 fail.
  2. Run with +BUG=1 and explain why every tav_id is the same.
  3. Change the env mailbox to new(1). Predict the time of each TAV_GEN line, then run.
  4. Bonus: fix the bug a second way, by keeping one object and putting it.clone() instead. What cast do you need?

FAQ

What is a mailbox in SystemVerilog? A built-in class that works as a FIFO between processes, with blocking and non-blocking methods to put and get items.

What is the difference between put() and try_put()? put() waits if a bounded mailbox is full. try_put() never waits and returns 0 if it could not add the item.

What is the difference between a bounded and an unbounded mailbox? A bounded mailbox has a size limit set in new(n), and put() waits when it is full. An unbounded mailbox, new(), never fills.

What is the difference between a mailbox and a queue? A mailbox is built to pass data between processes and blocks on empty. A queue is a data structure with no blocking.

Why use a parameterized mailbox? The compiler checks the item type, so a wrong type is caught at compile time instead of at run time.

Is the mailbox order always FIFO? Yes. Items come out in the order they went in.

References

  • IEEE 1800-2017, SystemVerilog standard: section 15.4 (mailboxes), including bounded mailboxes, the put, get, peek and try methods, and parameterized mailboxes.

Keep learning