Mailbox

Hello Good morning.
I have a class PACKET, defined all fields in it, randomizing the fields.
But I have to pass the object of packet class to another “driver class”.
So i am simply writing my_mailbox.put(obj_packet);
But it is not working and giving me FATAL ERROR : “Illegal unpacked assignment to packed LHS.”
Please provide some solutions.
Thank you.

`include “packet_class.sv”

program program_block();
mailbox mb1;

packet p,p_recv;

initial begin
repeat(12)
begin
mb1=new();
p=new();
p.randomize();
p.disp123();
mb1.put(p);
mb1.get(p_recv);
$display(“**********OBJECT is %p”,p);
end
#100;
end
endprogram

Please provide some solutions and suggestions if there is some mistake in it.
Thank you.

The code that you provided works with Questasim 10.1 and later, so you should check your error message and code to make sure that they are related.

Some suggestions are:

  1. Don’t use program blocks. There are several threads on the Verification Academy which discuss the origin of them and why they shouldn’t be used.
  2. Your mailbox should be typed to prevent any inadvertent misuse of the mailbox by placing an object of an unexpected type into it causing problems.
  3. UVM has these TLM capabilities built into the methodology. Is there a reason you aren’t using UVM?

In reply to cgales:

Thank you sir, for your guidelines.
I am using MODELSIM 6.3f version.

The problem solved by using typed mailbox.

I just wrote,

mailbox #(packet) mb1;

and it worked, as it only pass object of packet class only.