HDLC Bytestuffing



Overview

The flag sequence must never occur within the content of a frame otherwise it could be confused with an intentionally sent flag. A technique known byte insertion is used to prevent random data synthesizing a flag. The technique is said to make HDLC transparent, since any stream of bits may be present between the open and closing flag of a frame. The transparency is achieved by using an octet stuffing procedure.



HDLC Bytestuffing Functionality

HDLC flag sequences are transmitted between each frame and whenever there is no data to be transmitted The flag sequence is a unique 8-bit sequence of the form 0111 1110.

Normally a HDLC receiver starts in the idle state, waiting for the start of a frame. This is called "Hunt" mode, since the receiver is said to be hunting for a non-flag sequence. This may be achieved through a shift register and combinational logic - a Finite State Machine (FSM) is usually for implementation. Receiving implementations MUST correctly process all Control Escape sequences.

On reception, prior to FCS computation, each octet with value less than hexadecimal 0x20 is checked. Each Control Escape octet is removed, and the following octet is exclusive-or'd with hexadecimal 0x20, unless it is the Flag Sequence (which aborts a frame).

0x7e is encoded as 0x7d, 0x5e. (Flag Sequence)

0x7d is encoded as 0x7d, 0x5d. (Control Escape)

The HDLC Bytestuffer is a decision tree that can be written to with bytes of data from the HDLC Compare module. If compareStuff is asserted then the hdlcDataByte is byte stuffed. The type of data being stuffed is determined by the typeStuff signal. Data leaving the byte stuffer is passed to the packer where it is used in the VCP for Signal Digital Hierarchy (SDH) Processing.