girodias Posted June 2, 2011 Report Share Posted June 2, 2011 The following example of packing and unpacking does not work. Integral fields (length) get packed and unpacked properly but arrays do not get unpacked (unless I'm unpacking to an existing data structure that previously allocated space for the array). Is this a known issue? program test; import uvm_pkg::*; `include "uvm_macros.svh" class my_item extends uvm_sequence_item; rand int length; rand bit [7:0] payload[]; constraint data_length_cons { length inside { [1:10] }; } constraint data_payload_sizecons { payload.size() == length; } `uvm_object_utils_begin(my_item) `uvm_field_int(length, UVM_ALL_ON + UVM_DEC) `uvm_field_array_int(payload, UVM_ALL_ON) `uvm_object_utils_end endclass initial begin my_item a = new(); my_item b = new(); bit bitstream[]; int num_bits = 0; a.randomize(); `uvm_info("a", {"\n", a.sprint()}, UVM_NONE); num_bits = a.pack(bitstream); b.unpack(bitstream); `uvm_info("b", {"\n", b.sprint()}, UVM_NONE); end endprogram : test Typical output for the unpacked object will look like: UVM_INFO n.sv(32) @ 0: reporter [b] -------------------------------------------- Name Type Size Value -------------------------------------------- uvm_sequence_item my_item - @465 length integral 32 'd8 payload da(integral) 0 - -------------------------------------------- Quote Link to comment Share on other sites More sharing options...
jadec Posted June 3, 2011 Report Share Posted June 3, 2011 Make sure you set the packer to use_metadata = 1 during both the pack and unpack in order for array sizes to be stored and retrieved. Quote Link to comment Share on other sites More sharing options...
girodias Posted June 3, 2011 Author Report Share Posted June 3, 2011 Should that not be handled by the field automation macros? Quote Link to comment Share on other sites More sharing options...
jadec Posted June 3, 2011 Report Share Posted June 3, 2011 This is handled by the automation macros, but by default the packer doesn't generate the extra "metadata" needed to do this. In your case, you have a redundant length field, but there's no automated association between that length and the array size. Quote Link to comment Share on other sites More sharing options...
girodias Posted June 3, 2011 Author Report Share Posted June 3, 2011 I'm not following; the length property is redundant so why does it need to be considered for the unpacking? If I take the length property out and hard-code in the constraint the size of the array, how is the problem going to be different? The array will still be packed the same way. 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.