Coding & Line Codes
Bit Unstuffer After 5 Ones — L2 Upgrade
Bit unstuffer with stream enable and lock detect for serial data integrity.
About this block
Simulate it in the Verilog IDE
Bit Unstuffer After 5 Ones — L2 Upgrade is a Verilog reference block in the Coding & Line Codes catalog. Line codes, serializers, and digital encoding/decoding blocks. Marked Medium: more state or a wider datapath, still one workspace in the IDE.
This IP implements a serial bit unstuffer with stream gating, lock detection, and error detection capabilities.
It monitors an input data stream to ensure synchronization integrity by detecting consecutive ones.
The module asserts a lock signal upon detecting five consecutive ones and an err signal upon detecting six consecutive ones (a stuffing violation).
- Lock Detection: Asserts the
lockoutput signal when five consecutive1bits are detected on the input stream. - Error Detection: Asserts the
erroutput signal when six consecutive1bits are detected, indicating a violation of the bit-stuffing rule. - Stream Gating: The
data_outis valid only whenstream_enis high anderris low. Otherwise,data_outis forced to0. - Reset Behavior: All internal states (counter, lock, error) are reset to zero when
rst_nis low orstream_enis disabled.
- Choose Open in IDE. RTL Studio loads the packaged workspace for Bit Unstuffer After 5 Ones — L2 Upgrade.
- Read the Verilog module in the editor. The catalog line for this block: Bit unstuffer with stream enable and lock detect for serial data integrity.
- Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
- Run Yosys in the same IDE for a generic netlist. Sky130 liberty mapping is a separate Pro library option.
RTL Studio is the Verilog simulator and IDE around this block: Slang lint, Verilator, VCD waveforms, and Yosys, in the browser. Simulation guide · Yosys guide.
Features
- Synchronous design with active-low reset.
- Configurable lock threshold (5 consecutive ones).
- Configurable error threshold (6 consecutive ones).
- Stream enable control for power management or data flow control.
- Zero output on error or when stream is disabled.
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock input |
rst_n | Input | 1 | Active-low reset |
stream_en | Input | 1 | Stream enable signal |
data_in | Input | 1 | Input data bit |
data_out | Output | 1 | Output data bit |
lock | Output | 1 | Lock detected signal (asserted on 5 consecutive ones) |
err | Output | 1 | Error detected signal (asserted on 6 consecutive ones) |
Verification
The provided testbench (tb_bit_unstuff.v) verifies the following scenarios:
- Reset Check: Ensures all outputs are zero after reset.
- Idle State: Verifies behavior when
stream_enis low. - Data Passthrough: Checks that data is passed through correctly when no lock/error conditions exist.
- Lock Detection: Confirms
lockis asserted after five consecutive ones. - Error Detection: Confirms
erris asserted after six consecutive ones. - Stream Enable Recovery: Verifies state recovery when
stream_entoggles.
To run the simulation, use your preferred HDL simulator (e.g., ModelSim, VCS, Xcelium) with the provided testbench.
More in Coding & Line Codes
- 4-Bit Hex to 7-Segment Display Decoder
- 4b/6b Run-Length Limited Encoder
- 8-Bit Differential Encoder/Decoder (NRZ-D) — L1 Upgrade — L2 Upgrade
- 8-bit Huffman Encoder (Static Table)
- 8-Bit Manchester Encoder (IEEE 802.3 Compliant)
- 8-Bit Nibble-Swap Endian Converter — L1 Upgrade — L2 Upgrade
- 8-Bit Parallel Descrambler
- 8-Bit Run-Length Decoder (RLE)
- 8b/10b Encoder and Decoder
- Additive Scrambler 8-bit — L2 Upgrade
- Golay (24,12) Encoder with Syndrome Calculator
- Hamming (7,4) Decoder
- Hamming (7,4) Encoder
- HDLC Bit Stuffing (5 Ones)
- HDLC Bit-Stuff Remover
- NRZ-to-NRZI Line Encoder — L2 Upgrade