SystemVerilog Interprocess Synchronization and Communication


[Part 1]

Previous: More methods in Mailbox | Next: Event sequencing with wait()

Parameterized Mailboxes

We noticed that general (also called dynamic) mailboxes can hold any type of message. As long as a message matches with the expected type during retrieval, everything works seemlessly.

If it is known that a mailbox will be used with only one type of message, say string type, the mailbox definition can be parameterized. This is shown below.

   mailbox #(string) uGotMail = new(N_MSG);
   int i;
   string s;
   ...
   uGotMail.put("Hi there!");
   ...
   uGotMail.get(s); // correct 
   uGotMail.get(i); // incorrect

The usefulness of parameterized mailboxes is that in a case of a type mismatch (as in the incorrect example above), it will be a compilation error, not a runtime one.

Next time: We will probe more into SystemVerilog events and will find out how normal Verilog facilities, such as triggering an event and waiting for an event have been further enhanced in SystemVerilog.

Previous: More methods in Mailbox | Next: Event sequencing with wait()

Share/Save/Bookmark



Verification Management
Join Verification Management Group


Shop Amazon - Contract Cell Phones & Service Plans

Book of the Month