• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. usage of pack & unpack in URM

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 65
  • Views 5555
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

usage of pack & unpack in URM

archive
archive over 17 years ago

Hello friends,
                       can anyone let me know the usage of pack & unpack (urm_object ) with specific example.

Regards
Raghavendra


Originally posted in cdnusers.org by raghavendrap
  • Cancel
  • archive
    archive over 17 years ago

    I am not sure I would advocate using URM pack/unpack because you have to know a lot about what is going on. In OVM the packer has functions to pack various object types and the automation is there. You will see from this example that it is pretty ugly to do this in URM. Of course you can make your own convenience functions to simplify this greatly. module test; `include "urm.svh" class mydata extends urm_object; int sz; byte payload[]; function void resize(int size); sz = size; payload = new[sz](payload); endfunction function void do_pack (ref bit bitstream[], input urm_packer packer); //Used to size the bitstream array if(packer.nopack) begin packer.count+= (payload.size()*8) + $bits(sz); return; end for(int i=$bits(sz)-1; i>=0; --i) begin bitstream[packer.count] = sz>>i; packer.count++; end for(int j=0; j=0; --i) begin bitstream[packer.count] = payload[j]>>i; packer.count++; end endfunction function void do_unpack (ref bit bitstream[], input urm_packer packer); sz = 0; for(int i=0; i<$bits(sz); ++i) begin sz = (sz<<1) + bitstream[packer.count]; packer.count++; end resize(sz); for(int j=0; j=0; --i) begin payload[j] = (payload[j]<<1) + bitstream[packer.count]; packer.count++; end end endfunction `urm_object_utils_begin(mydata) `urm_field_int(sz, DEFAULT) `urm_field_array_int(payload, DEFAULT) `urm_object_utils_end endclass mydata md = new; mydata md2 = new; bit bits[]; initial begin md.set_name("md"); md2.set_name("md2"); md.resize(10); for(int i=0; i<10; ++i) md.payload[i] = i*i; void'(md.pack(bits)); void'(md2.unpack(bits)); md.print(); md2.print(); end endmodule Tim


    Originally posted in cdnusers.org by tpylant
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information