Systemverilog mailbox passing parameter

Hi, I have defined the follow

typedef mailbox #(transaction) stream_pkt_mbox;

class transaction #(parameter data_bus_width = 8, address_bus_width = 32);
  rand bit [data_bus_width-1:0]     data;
  rand bit [address_bus_width-1:0]  addr;
endclass : transaction

class stream_packet_driver #(parameter data_bus_width = 8, address_bus_width = 32);
 stream_pkt_mbox  mbox_pkt_dvr;
 transaction      pkt_transaction;
endclass

Question is, in different places of my testbench, I wanted to call this stream_packet_driver with different data/address_bus_width. How do I pass the new data/address_bus_width down to the mailbox level?

For example,

class bus1_driver #(parameter data_bus_width = 16, address_bus_width = 16);
 stream_packet_driver  #(data_bus_width,address_bus_width) bus1_dvr; 
 stream_pkt_mbox                                           bus1_dvr_mbox; //HOW TO PASS NEW PARAMETER VALUES????
endclass

class bus2_driver #(parameter data_bus_width = 8, address_bus_width = 24);
 stream_packet_driver  #(data_bus_width,address_bus_width) bus2_dvr;
 stream_pkt_mbox                                           bus2_dvr_mbox; //HOW TO PASS NEW PARAMETER VALUES????
endclass

In reply to okc177:

Two options

  1. Don’t use
    stream_pkt_mbox
    and pass the parameters to the mailbox declaration inside your drivers. You are going to need a parameterized transaction to receive when you do a get() from your mailbox anyways
class bus1_driver #(parameter data_bus_width = 16, address_bus_width = 16);
typedef transaction#(data_bus_width,address_bus_width)    bus1_transaction_t;
stream_packet_driver  #(data_bus_width,address_bus_width) bus1_dvr;
mailbox#(bus1_transaction_t)                              bus1_dvr_mbox;
endclass
  1. Use an unparameterized common transaction base class with your mailbox. You will need $cast() the item you get() from the mailbox to the correct parameterized transaction.

One other recommendation is that you do not specify default parameter values. That would make
mailbox#(transaction)
illegal, or any use of
transaction
without the width overrides.