HDLC Deframer (hdlc_deframer_b_uc)
Outputs HDLC frames by identifying opening/closing flags, unstuffing bits and verifying the CRC.
Design
Upon receiving sample data, the HDLC deframer begins processing by scanning for the start and end flags, both represented by 0x7E. Once both flags are located, the deframer examines the data between them. The first step is zero-removal unstuffing to reverse the stuffing that occurred during framing. The deframer does this by identifying any sequence where the bit 1 appears five times consecutively, which indicates that the next bit was stuffed and should be removed.
After bit unstuffing, the deframer extracts the CRC from the final N bits of the message, where N is the CRC size set by polynomial_taps. The deframer then calculates the expected CRC from the remaining data and compares it to the received CRC. If the two match, the data is packed into unsigned characters and output; otherwise, it is discarded.
The max_payload_size property defines the largest expected amount of payload data in a single frame in bytes.
Interface
<?xml version="1.0"?>
<componentspec>
<property name="polynomial_taps" type="uchar" arraylength="32" parameter="true" default="16,12,5"
description="CRC polynomial taps."/>
<property name="max_payload_size" type="ushort" parameter="true" default="32"
description="Maximum number of payload bytes per frame."/>
<property name="input_reflect" type="bool" parameter="true" default="false"
description="False is input data most significant bit first and true is least significant bit first."/>
<property name="output_reflect" type="bool" parameter="true" default="false"
description="False is CRC most significant bit first and true is least significant bit first."/>
<property name="seed" type="ulong" writable="true" default="0" description="Initial seed for the CRC."/>
<property name="final_xor" type="ulong" writable="true" default="0" description="Value to XOR the CRC result with."/>
<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-protOptional:
False
Outputs:
output: Primary output samples port.Protocol:
uchar_timed_sample-protOptional:
False
Opcode Handling
When a flush or discontinuity is received, any held data or pending timestamp is cleared, and the opcode then passes through.
If a time opcode arrives after a sample interval opcode, the time value updates until the closing flag of a valid frame is received. The time value then advances ahead of the payload data.
All other opcode messages pass through this component without any effect.
Properties
polynomial_taps: CRC polynomial taps. An array of up to 32 unsigned characters, meaning a maximum of 32 taps can be specified. If the polynomial is \(x^16+x^12+x^5+1\) thenpolynomial_tapsshould be set to “16,12,5”. There is no need to specify the \(x^0\) term, this is implied.Type:
ucharArray dimensions:
['32']
Access:
Parameter:
TrueWritable:
FalseInitial:
FalseVolatile:
False
Default value:
16,12,5
max_payload_size: Maximum number of payload bytes per frame.Type:
ushortAccess:
Parameter:
TrueWritable:
FalseInitial:
FalseVolatile:
False
Default value:
32
input_reflect: False is input data most significant bit first and true is least significant bit first.Type:
boolAccess:
Parameter:
TrueWritable:
FalseInitial:
FalseVolatile:
False
Default value:
false
output_reflect: False is CRC most significant bit first and true is least significant bit first.Type:
boolAccess:
Parameter:
TrueWritable:
FalseInitial:
FalseVolatile:
False
Default value:
false
seed: Initial seed for the CRC.Type:
ulongAccess:
Parameter:
FalseWritable:
TrueInitial:
FalseVolatile:
False
Default value:
0
final_xor: Value to XOR the CRC result with.Type:
ulongAccess:
Parameter:
FalseWritable:
TrueInitial:
FalseVolatile:
False
Default value:
0
Implementations
Example Application
<?xml version="1.0"?>
<application done="file_write">
<instance component="ocpi.core.file_read" connect="hdlc_deframer_b_uc">
<property name="filename" value="input.bin"/>
</instance>
<instance component="ocpi.comp.sdr.communication.hdlc_deframer_b_uc" connect="file_write">
<property name="polynomial_taps" value="16,12,5"/>
<property name="max_payload_size" value="32"/>
<property name="input_reflect" value="true"/>
<property name="output_reflect" value="false"/>
<property name="seed" value="0xffff"/>
<property name="final_xor" value="0xffff"/>
</instance>
<instance component="ocpi.core.file_write">
<property name="filename" value="output.bin"/>
</instance>
</application>
Dependencies
The dependencies to other elements in OpenCPI are:
There is also a dependency on:
ieee.std_logic_1164
ieee.numeric_std
ieee.math_real
Limitations
Limitations of hdlc_deframer_b_uc are:
CRC sizes above 32 are not supported.
Sample interval opcodes pass through unmodified.
Testing
Tested platforms: None
Component testing not completed.