The uvm_packer class provides a policy object for packing and unpacking uvm_objects. The policies determine how packing and unpacking should be done. Packing an object causes the object to be placed into a bit (byte or int) array. If the `uvm_field_* macro are used to implement pack and unpack, by default no metadata information is stored for the packing of dynamic objects (strings, arrays, class objects).
uvm_packer | The uvm_packer class provides a policy object for packing and unpacking uvm_objects. |
uvm_packer | Implementation of uvm_packer, as defined in section 16.5.1 of 1800.2-2020 |
Implementation of uvm_packer, as defined in section 16.5.1 of 1800.2-2020
uvm_packer | |||||
Implementation of uvm_packer, as defined in section 16.5.1 of 1800.2-2020 | |||||
Class Hierarchy | |||||
| |||||
Class Declaration | |||||
| |||||
set_packed_* | Implementation of P1800.2 16.5.3.1 | ||||
get_packed_* | Implementation of P1800.2 16.5.3.2 | ||||
Packing | |||||
pack_field | Packs an integral value (less than or equal to 4096 bits) into the packed array. | ||||
pack_field_int | Packs the integral value (less than or equal to 64 bits) into the pack array. | ||||
pack_string | Packs a string value into the pack array. | ||||
pack_time | Packs a time value as 64 bits into the pack array. | ||||
pack_real | Packs a real value as 64 bits into the pack array. | ||||
pack_object | Packs an object value into the pack array. | ||||
Unpacking | |||||
is_null | This method is used during unpack operations to peek at the next 4-bit chunk of the pack data and determine if it is 0. | ||||
unpack_field | Unpacks bits from the pack array and returns the bit-stream that was unpacked. | ||||
unpack_field_int | Unpacks bits from the pack array and returns the bit-stream that was unpacked. | ||||
unpack_string | Unpacks a string. | ||||
unpack_time | Unpacks the next 64 bits of the pack array and places them into a time variable. | ||||
unpack_real | Unpacks the next 64 bits of the pack array and places them into a real variable. | ||||
unpack_object | Unpacks an object and stores the result into value. | ||||
get_packed_size | Returns the number of bits that were packed. | ||||
Variables | |||||
pack_object_with_meta | Packs obj into the packer data stream, such that it can be unpacked via an associated unpack_object_with_meta call. | ||||
pack_object_with_meta is not compatible with <unpack_object> | and is_null. | ||||
unpack_object_with_meta | Unpacks an object which was packed into the packer data stream using pack_object_with_meta. | ||||
unpack_object_with_meta is not compatible with <pack_object> | or is_null. |
Implementation of P1800.2 16.5.3.1
The LRM specifies the set_packed_* methods as being signed, whereas the uvm_object::unpack methods are specified as unsigned. This is being tracked in Mantis 6423.
The reference implementation has implemented these methods as unsigned so as to remain consistent.
virtual function void set_packed_bits( ref bit unsigned stream[] ); virtual function void set_packed_bytes( ref byte unsigned stream[] ); virtual function void set_packed_ints( ref int unsigned stream[] ); virtual function void set_packed_longints( ref longint unsigned stream[] );
Implementation of P1800.2 16.5.3.2
The LRM specifies the get_packed_* methods as being signed, whereas the uvm_object::pack methods are specified as unsigned. This is being tracked in Mantis 6423.
The reference implementation has implemented these methods as unsigned so as to remain consistent.
virtual function void get_packed_bits( ref bit unsigned stream[] ); virtual function void get_packed_bytes( ref byte unsigned stream[] ); virtual function void get_packed_ints( ref int unsigned stream[] ); virtual function void get_packed_longints( ref longint unsigned stream[] );
virtual function void pack_field ( uvm_bitstream_t value, int size )
Packs an integral value (less than or equal to 4096 bits) into the packed array. size is the number of bits of value to pack.
Packs the integral value (less than or equal to 64 bits) into the pack array. The size is the number of bits to pack, usually obtained by $bits. This optimized version of pack_field is useful for sizes up to 64 bits.
virtual function void pack_string ( string value )
Packs a string value into the pack array.
When the metadata flag is set, the packed string is terminated by a null character to mark the end of the string.
This is useful for mixed language communication where unpacking may occur outside of SystemVerilog UVM.
virtual function void pack_time ( time value )
Packs a time value as 64 bits into the pack array.
virtual function void pack_real ( real value )
Packs a real value as 64 bits into the pack array.
The real value is converted to a 6-bit scalar value using the function $real2bits before it is packed into the array.
virtual function void pack_object ( uvm_object value )
Packs an object value into the pack array.
A 4-bit header is inserted ahead of the string to indicate the number of bits that was packed. If a null object was packed, then this header will be 0.
This is useful for mixed-language communication where unpacking may occur outside of SystemVerilog UVM.
virtual function bit is_null ()
This method is used during unpack operations to peek at the next 4-bit chunk of the pack data and determine if it is 0.
If the next four bits are all 0, then the return value is a 1; otherwise it is 0.
This is useful when unpacking objects, to decide whether a new object needs to be allocated or not.
virtual function uvm_bitstream_t unpack_field ( int size )
Unpacks bits from the pack array and returns the bit-stream that was unpacked. size is the number of bits to unpack; the maximum is 4096 bits.
virtual function uvm_integral_t unpack_field_int ( int size )
Unpacks bits from the pack array and returns the bit-stream that was unpacked.
size is the number of bits to unpack; the maximum is 64 bits. This is a more efficient variant than unpack_field when unpacking into smaller vectors.
virtual function string unpack_string ()
Unpacks a string.
num_chars bytes are unpacked into a string. If num_chars is -1 then unpacking stops on at the first null character that is encountered.
virtual function time unpack_time ()
Unpacks the next 64 bits of the pack array and places them into a time variable.
virtual function real unpack_real ()
Unpacks the next 64 bits of the pack array and places them into a real variable.
The 64 bits of packed data are converted to a real using the $bits2real system function.
virtual function void unpack_object ( uvm_object value )
Unpacks an object and stores the result into value.
value must be an allocated object that has enough space for the data being unpacked. The first four bits of packed data are used to determine if a null object was packed into the array.
The is_null function can be used to peek at the next four bits in the pack array before calling this method.
Packs obj into the packer data stream, such that it can be unpacked via an associated unpack_object_with_meta call.
Unlike pack_object, the pack_object_with_meta method keeps track of what objects have already been packed in this call chain. The first time an object is passed to pack_object_with_meta after a call to <flush>, the object is assigned a unique id. Subsequent calls to pack_object_with_meta will only add the unique id to the stream. This allows structural information to be maintained through pack/unpack operations.
and is_null. The object can only be unpacked via unpack_object_with_meta.
@uvm-contrib This API is being considered for potential contribution to 1800.2
Unpacks an object which was packed into the packer data stream using pack_object_with_meta.
Unlike unpack_object, the unpack_object_with_meta method keeps track of what objects have already been unpacked in this call chain. If the packed object was null, then value is set to null. Otherwise, if this is the first time the object’s unique id has been encountered since a call to <flush>, then unpack_object_with_meta checks value to determine if it is the correct type. If it is not the correct type, or if value is null, then the packer shall create a new object instance for the unpack operation, using the data provided by pack_object_with_meta. If value is of the correct type, then it is used as the object instance for the unpack operation. Subsequent calls to unpack_object_with_meta for this unique id shall simply set value to this object instance.
or is_null. The object must have been packed via pack_object_with_meta.
@uvm-contrib This API is being considered for potential contribution to 1800.2
The uvm_void class is the base class for all UVM classes.
virtual class uvm_void
The uvm_object class is the base class for all UVM data and hierarchical classes.
virtual class uvm_object extends uvm_void
The abstract uvm_policy class provides a common base from which all UVM policy classes derive Implementation as per Section 16.1 UVM Policy
virtual class uvm_policy extends uvm_object
Implementation of uvm_packer, as defined in section 16.5.1 of 1800.2-2020
class uvm_packer extends uvm_policy
Packs an integral value (less than or equal to 4096 bits) into the packed array.
virtual function void pack_field ( uvm_bitstream_t value, int size )
Packs a string value into the pack array.
virtual function void pack_string ( string value )
Packs a time value as 64 bits into the pack array.
virtual function void pack_time ( time value )
Packs a real value as 64 bits into the pack array.
virtual function void pack_real ( real value )
Packs an object value into the pack array.
virtual function void pack_object ( uvm_object value )
This method is used during unpack operations to peek at the next 4-bit chunk of the pack data and determine if it is 0.
virtual function bit is_null ()
Unpacks bits from the pack array and returns the bit-stream that was unpacked.
virtual function uvm_bitstream_t unpack_field ( int size )
Unpacks bits from the pack array and returns the bit-stream that was unpacked.
virtual function uvm_integral_t unpack_field_int ( int size )
Unpacks a string.
virtual function string unpack_string ()
Unpacks the next 64 bits of the pack array and places them into a time variable.
virtual function time unpack_time ()
Unpacks the next 64 bits of the pack array and places them into a real variable.
virtual function real unpack_real ()
Unpacks an object and stores the result into value.
virtual function void unpack_object ( uvm_object value )
Returns the number of bits that were packed.
virtual function int get_packed_size()
function int unpack ( ref bit bitstream[], input uvm_packer packer = null )
function int pack ( ref bit bitstream[], input uvm_packer packer = null )