budisantoso Posted June 26, 2012 Report Share Posted June 26, 2012 (edited) Hi All, I am developing a UVM bench right now, but got a little problem with the use of packer when I do pack/unpack operation. Let me explain my problem below: For a scenario where there is subclass inside a class, during pack/unpack I notice that the packer of the parent class is shared with the subclass. As a result the parent class packer information will be overwritten by subclass. For example, see pseudo code below: parent.unpack_bytes begin (bytestream1, packer) subclass.unpack_bytes (bytestream2, packer) begin ……….. end ….....(continue with parent other operation which uses packer information i.e: m_packed_size) end In this case, I notice the value of m_packed_size of parent packer is overwritten by subclass m_packed_size. Is there any way not to change the value of m_packed_size? so that I can use the original value of m_packed_size (before it is edited by subclass.unpacked_bytes) at the end of parent class? Really appreciate your helps. Thanks, Budi Edited June 26, 2012 by budisantoso Quote Link to comment Share on other sites More sharing options...
janick Posted June 26, 2012 Report Share Posted June 26, 2012 Are you writing your own do_unpack? Quote Link to comment Share on other sites More sharing options...
budisantoso Posted June 27, 2012 Author Report Share Posted June 27, 2012 Yes, you are correct. I am writing my do_unpack. Quote Link to comment Share on other sites More sharing options...
janick Posted June 27, 2012 Report Share Posted June 27, 2012 Do not call obj.unpack_bytes(packer) but packer.unpack_object(obj). Quote Link to comment Share on other sites More sharing options...
budisantoso Posted July 5, 2012 Author Report Share Posted July 5, 2012 Hi Janick, Thanks for you reply. Using the method that you recommended, the packer properties will not be modified. However, if i use that method, I can not pass the bytestream to be unpack. So in my case, I am still using obj.unpack_bytes(bytestream, packer) but before i call that function, I keep the old properties of packer (ex:m_packed_size) as temp and set it back at the end. Thanks Quote Link to comment Share on other sites More sharing options...
janick Posted July 5, 2012 Report Share Posted July 5, 2012 The packed stream is a variable inside the uvm_packer instance. You need not pass it. 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.