Pack in UVM

Hi,

I have a query on usage of pack in UVM. I have a driver(l1) sending packet to other driver(l2). l2 driver should know the size of the whole packet received from l1 driver. l1 driver packet has different fields. Please someone help me how to use pack/do_pack in this situation. How to pack them and also how to collect it as data in the current driver? Please provide me some example.

In reply to Anudeep J:

Could you please elaborate a little bit mor on your question. Waht is a layer l1 and what is l2?
What are the differences in the data packets?

In reply to chr_sue:

Hi,

Layer is nothing but a driver here. Each driver has their own packet. But one driver uses other driver’s packet. In this kind of situation, i want to find the size of a packet coming from the other driver. I think Iam clear now.

In reply to Anudeep J:

To be honest, it is stillnot clear to me. I try to explain what I understood:
(1) you have a data packet.
(2) This packet is executes by 2 different drivers.
Correct?
The size of the packet depends on the structure of your data packet. Could you please explain how it is defined?

In reply to chr_sue:

To be very simple, I am getting a packet from a driver to my driver and I want to find the size of that packet using pack or do_pack methods

In reply to Anudeep J:

This depends on the definition/structure of your data packet. Could you please show this.

In reply to chr_sue:

I have different fields in that packet with int,bit type dynamic arrays.

In reply to Anudeep J:

If both drivers are following some protocol then only they can find data packet size of each others.

In reply to electron:

We can calculate the size of the packet in different places not only in the driver. But if I do not know the structure I cannot help and important is what do you mean with size. Is it the number of bits, byte, halfwords, words …

In reply to Anudeep J:

I1 could have a do_pack method that I2 can call. When I1 is packed into an array, you can calculate the size with I1_packed.size. I2 payload can then be set to I1_packed and I2 payload size can be set to I1_packed.size. Just guessing at your implementation.