Bit Stuffer (bit_stuffer)
Zero insertion bit stuffer.
Design
Bit stuffing is the insertion of non-information bits into binary data. It has various purposes, such as to alter the bit rate of a bit stream, or to fill up a frame, or to aid receiver synchronisation. Typically it is used to limit the number of consecutive bits of the same value in the data to be transmitted. This allows for certain sequences of ones and zeros to be reserved for frame delimiting by ensuring the data itself can never be the same as the beginning or end flags.
Implementation
The number of consecutively received ones to insert a zero after is set by consecutive_ones_g at build time. When an internal counter reaches consecutive_ones_g - 1 and a one is on the input, the following clock cycle, ready switches low to pause the input source whilst a zero is inserted.
The reset signal, rst, resets the count of previously received ones on the next rising clock edge when high.
This implementation can generate a new output every clock cycle without any clock cycle latency.
Interface
Generics
consecutive_ones_g(integer): Number of consecutive ones to insert a zero after.
Ports
clk(std_logic), in: Clock. Inputs and outputs registered on rising edge.
rst(std_logic), in: Reset. Active high, synchronous with rising edge of clock.
enable(std_logic), in: Clock Enable. Enables all processes on a rising clock edge.
ready(std_logic), out: Input Ready. High when input is ready for data.
data_valid_in(std_logic), in: Valid Input. High when data ondata_inport is available.
data_in(std_logic), in: Data input. Binary input data.
data_valid_out(std_logic), in: Valid Output. High when data ondata_outport is available.
data_out(std_logic), in: Data Output. Binary bit stuffed output data.
Dependencies
The dependencies to other elements in OpenCPI are:
None.
There is also a dependency on:
ieee.std_logic_1164
Limitations
Limitations of bit_stuffer are:
consecutive_ones_gcannot be set to zero