# uvm_packer

Implementation of uvm_packer, as defined in section 16.5.1 of 1800.2-2017

Summary

uvm_packer
Implementation of uvm_packer, as defined in section 16.5.1 of 1800.2-2017
Methods |
set_packed_* | Implementation of P1800.2 16.5.3.1
get_packed_* | Implementation of P1800.2 16.5.3.2
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.
unpack_object_with_meta | Unpacks an object which was packed into the packer data stream using pack_object_with_meta.

### Methods

### set_packed_*

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[] );

@uvm-contrib This API is being considered for potential contribution to 1800.2

### get_packed_*

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[] );

@uvm-contrib This API is being considered for potential contribution to 1800.2

### pack_object_with_meta

> function void uvm_packer::pack_object_with_meta(
> | uvm_object | value
> )

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.

Note: pack_object_with_meta is not compatible with <unpack_object> 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

### unpack_object_with_meta

> function void uvm_packer::unpack_object_with_meta(
> | inout | uvm_object | value
> )

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.

Note: unpack_object_with_meta is not compatible with <pack_object> 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

> function void uvm_packer::pack_object_with_meta(
> | uvm_object | value
> )

Packs obj into the packer data stream, such that it can be unpacked via an associated unpack_object_with_meta call.

> function void uvm_packer::unpack_object_with_meta(
> | inout | uvm_object | value
> )

Unpacks an object which was packed into the packer data stream using pack_object_with_meta.