Data Packer (data_pack_b_uc)

Packs eight boolean values into a byte.

Design

This component takes in a stream of boolean inputs, packs the data into bytes, and outputs a stream of unsigned char values. The component can pack data into a byte starting with either the most significant bit (MSB) or the least significant bit (LSB).

Interface

<?xml version="1.0"?>
<componentspec>
  <property name="msb_first" type="bool" writable="true" default="true"
    description="When true the output byte is packed starting with the most significant bit first. When false the output byte is
      packed starting with the least significant bit first."/>
  <property name="flush_on_non_sample_opcode" type="bool" writable="true" default="true"
    description="When true any non-sample opcode (except time) will cause any unsent data to be output as an incomplete data word
      before outputting the non-sample opcode. When false any non-sample opcode (except time or flush) will cause any unsent data
      to be discarded before outputting the non-sample opcode."/>
  <port name="input" producer="false" protocol="bool_timed_sample-prot"/>
  <port name="output" producer="true" protocol="uchar_timed_sample-prot"/>
</componentspec>

Ports

Inputs:

  • input: Primary input samples port.

    • Protocol: bool_timed_sample-prot

    • Optional: False

Outputs:

  • output: Primary output samples port.

    • Protocol: uchar_timed_sample-prot

    • Optional: False

Opcode Handling

Messages with a sample opcode are packed into bytes and output as sample opcode messages with a fixed length of one.

If a time opcode arrives message is received after a multiple of eight sample messages data values have been received it is passed directly through the component. If the time opcode message arrives after a non-multiple of eight sample message data values have been received, then the time value received will relate to a sample value in the middle of an output byte. As such, the timestamp is advanced by the sample interval for each new sample value received until the number of input sample values is a multiple of eight, the advanced timestamp is then output. If another non-sample message is received before a multiple of eight sample values have been received, the time opcode message is discarded and not sent.

If a flush opcode messages is received after a multiple of eight sample values have been received it is passed directly through the component. If a flush opcode message arrives after a non-multiple of eight sample values have been received, then the required number of zeros are input into the data packer so that a full byte can be output. The flush opcode message is then passed on to the output of the component.

If a discontinuity opcode message is received after a multiple of eight sample values have been received it is passed directly through the component. If a discontinuity opcode message is received after a non-multiple of eight sample values have been received, the data bits that have been received but not output yet (because the all bits to make a full byte have not yet been received) are discarded and the discontinuity opcode message is passed onto the output of the component.

For all other opcodes messages, if they are received after a multiple of eight input sample values have been received, they are passed directly through the component. If a non-multiple of eight input values have been received the component either flushes the residual data or discards it depending on the value of the flush_on_non_sample_opcode property. The opcode message is then passed on to the output of the component.

Properties

  • msb_first: When true the output byte is packed starting with the most significant bit first. When false the output byte is packed starting with the least significant bit first.

    • Type: bool

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: true

  • flush_on_non_sample_opcode: When true any non-sample opcode (except time) will cause any unsent data to be output as an incomplete data word before outputting the non-sample opcode. When false any non-sample opcode (except time or flush) will cause any unsent data to be discarded before outputting the non-sample opcode.

    • Type: bool

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: true

Implementations

Example Application

<?xml version="1.0"?>
<application done="file_write">
  <instance component="ocpi.core.file_read" connect="data_pack_b_uc">
    <property name="filename" value="input.bin"/>
  </instance>
  <instance component="ocpi.comp.sdr.communication.data_pack_b_uc" connect="file_write">
    <property name="msb_first" value="true"/>
    <property name="flush_on_non_sample_opcode" value="true"/>
  </instance>
  <instance component="ocpi.core.file_write">
    <property name="filename" value="output.bin"/>
  </instance>
</application>

Dependencies

The dependencies to other elements in OpenCPI are:

  • None.

There is also a dependency on:

  • ieee.std_logic_1164

  • ieee.numeric_std

Limitations

Limitations of data_pack_b_uc are:

  • Input stream message boundaries are not preserved. All output stream messages are of length one.

Testing

Tested platforms: None

Component testing not completed.