Hi,
I am faced the error.
** Error: design.sv(4): Invalid type ‘transaction_data’. Please check the type of the variable ‘data’.
** Error: design.sv(4): near “(”: syntax error, unexpected ‘(’, expecting function or task
End time: 15:10:18 on Jul 01,2017, Elapsed time: 0:00:00
Errors: 2, Warnings: 0
class common_mailbox;
mailbox box=new();
transaction_data data;
function new();
data=new();
$display("completed");
endfunction
endclass
class transaction_data;
bit [7:0]input_axis_tdata=8’d5;
bit clk=1;
bit reset=0;
bit input_axis_tvalid=1;
bit [15:0]prescale=3;
bit input_axis_tready=1;
In order to parse your code, SystemVerilog needs to know that an identifier is a type before it can be referenced within your code. So you need to put the class declaration of transaction_data before it is referenced inside class common_mailbox. There is also something called a forward typedef that can be placed before an undeclared class. See section 6.18 in the IEEE 1800-2012 LRM.
Also, I strongly recommend that you declare your mailbox parameterized by the class type you will be putting into it.
But parameterized class only uses the same data type.But i want store a one class object and reterive from the other class. Ex. I have a common mailbox class,transaction class and driver class.The values are stimules in a transaction class then transaction class object will be stored into common mailbox class using put method.Then i want to reterive transaction class object to the driver class using get method
first transaction object will be put to the common mailbox and get to the driver class object using mailbox get method…