TestBencher Pro and Reactive Test Bench Help

6.6 Data Packing and Bit Streams

6.6 Data Packing and Bit Streams

Previous topic Next topic  

6.6 Data Packing and Bit Streams

Previous topic Next topic  

Data packing is the method used to convert data structures to bit streams or byte streams. Data packing is used when you want to work with data at a higher level of abstraction. Instead of passing data around the test bench using byte arrays or bit streams, you can create a structure definition which defines the data in a way that is easier more human readable way. Then, when you want to actually use this data to drive values onto a bus, the data structure can be packed into a bit stream or array of bytes. Basically, when you pack a data structure, all of the fields will be concatenated in the way that you specify through the packing options.

When creating structure definitions, packing properties can be individually specified for each field of the structure. Packing can be enabled individually for each field and when enabled there are several different ways the field can be packed. These options, which are listed below, control the order in which bits, bytes, and words are packed. Note: the order in which fields are packed is determined by the order in which they are shown in the structure definition. The first field (that has packing enabled) is the first field to be packed.

Set the Packing Properties for a Class

Right click on the Class Library List folder and choose Classes and Variables to open the Classes and Variables dialog.

Cv_dlg_opening_just_class

Select a Class Library and a Class so that the fields of the class are displayed in the Class Fields region.

In the Classes section, the Network Packing control, if enabled for the class definition, will reverse the order of the bytes in the resulting packed byte array.

packing_class_network

In the Class Fields section, double click on the Packing cell of the field to open the Select Packing Options dialog.

cv_dlg_new_fields

Check Enable Packing to activate the controls in the dialog.

Byte Order controls how the bytes are packed in to the structure. Little Endian (default) or Big Endian. If Big Endian is used, then for each field:

each pair of bytes is swapped (if the size of the field is not a multiple of 16, then this step will not be performed).

each pair of 16 bit words are swapped (if the size of the field is not a multiple of 32, then this step will not be performed).

select_packing_options_dlg

For Example if you have a 32 bit word 01 02 03 04 in hex, then little Endian would write it out as 01 02 03 04, and Big Endian would write it out as 04 03 02 01.

Bit Order determines the order of the bits in the stream. Normal order arranges the data so that the most significant bit of each byte is first in the vector. Bit Reverse arranges the data so that the least significant bit of the vector to be packed first and the most significant bit to be packed last.

Chapter 11: Language Specific Details discusses the language specific features of data packing that TestBencher supports.