liguydp
November 29, 2018, 8:57pm
1
I am new to using SV mailboxes.
I declare a mailbox in a testbench module - driver.sv
mailbox evt_mbx = new ();
Then I add data to it:
evt_mbx.put (mailbox_data);
This seems to work fine.
In another Testbench module elg_bfm.sv I now want to read the mailbox.
How do I reference the evt_mbx mailbox created in the other module?
My simulator is giving me this error
Unresolved reference to ‘evt_mbx’
initial
begin
forever begin
int idx;
#2 evt_mbx.get (idx);
end
end
Thanks
Len
javatea
November 29, 2018, 11:23pm
2
In reply to liguydp :
module is mainly for RTL design, if you want to pass stuff… just input output …
mailbox is for testbench, most case is declare under class.
dave_59
November 30, 2018, 12:03am
3
In reply to liguydp :
You declared evt_mbx as a class variable inside a module, and initialized it with a handle to a mailbox object. You can access that handle value from another module the same as you would access another int variable from another module: either by hierarchical reference, or through port connections. You just need to make sure you construct the mailbox in one place, and pass the handle to where it being used.
module driver;
mailbox #(int) evt_mbx;
...
evt_mbx.put(...)
endmodule
module elg_bfm;
mailbox #i(nt) evt_mbx;
...
evt_mbx.get(...);
endmodule
module top;
mailbox #(int) evt_mbx = new ();
driver d1();
bfm b1();
initial begin
d1.evt_mbx = evt_mbx;
b1.evt_mbx = evt_mbx;
end
endmodule
module driver(input mailbox #(int) mbx);
...
mbx.put(..._;
endmodule
module elg_bfm(mailbox #(int) mbx);
...
mbx.get(...);
endmodule
module top;
mailbox #(int) evt_mbx = new ();
driver d1(et_mbx);
bfm b1(evt_mbx);
endmodule