Hi,
I want to put an unpacked array to generic mailbox, but got the following compilation error. I wonder is it possible to put unpacked array to a systemverilog mailbox?
class my_class;
mailbox mb_matrix_a;
function new;
mb_matrix_a=new();
endfunction
task my_task;
bit[255:0] matrix_a[32];
for(int i=0;i<32;i++)
matrix_a[i]=256'b0;
mb_matrix_a.put(matrix_a);
endtask
Error message (VCS)
Error-[SV-INA] Illegal non-singular argument
“matrix_a”
Illegal unpacked array, unpacked struct or aggregate argument type for
mailbox data.
Thanks in advance for the help!
Hao
In reply to peterjin:
The IEEE 1800-2017 SystemVerilog LRM
in section 15.4 Mailboxes says you can only put singular data types into a mailbox. Some tools allow any type if the mailbox is parameterized. I strongly suggest you always use parameterized mailboxes instead of a generic mailbox for type safety— you will thank me later.
The LRM complaint way of doing this is wrapping the array in a class.
typedef bit[255:0] matrix_t[32];
class array_wrapper;
matrix_t a;
endclass
class my_class;
mailbox #(array_wrapper) mb_matrix_a;
function new;
mb_matrix_a=new();
endfunction
task my_task;
array_wrapper aw;
aw = new;
for(int i=0;i<32;i++)
aw.matrix_a[i]=256'b0;
mb_matrix_a.put(aw);
endtask
In reply to dave_59:
Can we parameterize mailbox with dynamic queue type, such as below
typedef bit[255:0] matrix_t[$];
mailbox #(matrix_t) mb_matrix_a;
In reply to htt80:
No, only singular types are allowed.