frodus Posted April 13, 2011 Report Share Posted April 13, 2011 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 Quote Link to comment Share on other sites More sharing options...
vishal.jain Posted April 14, 2011 Report Share Posted April 14, 2011 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 Quote Link to comment Share on other sites More sharing options...
frodus Posted April 14, 2011 Author Report Share Posted April 14, 2011 Hi Vishal, thanks for the reply. Unfortionatly I'm looking into a lot of protocols, including IEEE802, MPLS, OAM etc. So I guess putting everything in one class is not an option. Bye, Frodus Quote Link to comment Share on other sites More sharing options...
jadec Posted April 18, 2011 Report Share Posted April 18, 2011 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.