Jump to content

Packing from multiple classes


Recommended Posts

Hi All,

I'm currently trying to write a frame generator with support for multiple

protocols.

My current idea is to implement one class for each protocol which I have to

support and then one frame class which can instance the different protocols

as needed.

Currently I've some difficulties to figure out how to do the packing in such

an approach can be implemented.

In principal I do have a do_pack as described below for simple packet.

If I would like to add another level of protocol it would have been put right after

the type field and before the data.

The question is which approach I've to follow in order to change this position

from another protocol class. (Note: I have to support a lot of protocols so hard coding each

combination is not an option.)

function void do_pack(uvm_packer packer);

super.do_pack(packer);

packer.pack_field_int(dest,$bits(dest));

packer.pack_field_int(src,$bits(src));

packer.pack_field_int(type,$bits(type));

foreach(data)

packer.pack_field_int(data,8);

packer.pack_field_int(fcs,$bits(fcs);

endfunction

Thanks,

Frodus

Link to comment
Share on other sites

Hi Frodus,

One approach that I took in similar application was to flatten out all packets in singe class. Depending on class type (another field in class), I would do packing of required fields.

Pros: Simplified code for coverage / automation / generation

Cons : Debug might become a slight issue. Depending on protocols, flattening can results into the class being always huge

-Vishal

Link to comment
Share on other sites

For encapsulation protocols, you can use pack_field_object for the data. This will allow the sub-object type to determine the data and packing of its section.

For things that modify the fields themselves, you could have a virtual functions in your base class that are called from do_pack and pack certain groups of fields. Overriding those would allow you to insert, modify, delete those groups individually.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...