RTL Studio Open IDE

Coding & Line Codes

4b/6b Run-Length Limited Encoder

A 4b/6b Run-Length Limited encoder and decoder with disparity control for DC balance.

About this block

Simulate it in the Verilog IDE

Mediumsystemverilogsimsyn

4b/6b Run-Length Limited Encoder is a SystemVerilog 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.

An OpenIP implementation of a 4b/6b Run-Length Limited (RLL) encoder and decoder. This IP ensures DC balance and limits consecutive identical bits in serial data streams. The design is suitable for high-speed serial communication links.

This IP provides a robust 4b/6b RLL coding solution for serial communication links. It features a simple architecture using pre-initialized lookup tables for encoding and decoding. Sequential running disparity state tracking ensures DC balance. The IP includes a comprehensive testbench for verification.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for 4b/6b Run-Length Limited Encoder.
  2. Read the SystemVerilog module in the editor. The catalog line for this block: A 4b/6b Run-Length Limited encoder and decoder with disparity control for DC balance.
  3. Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
  4. 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

  • Bidirectional Data Flow: Supports separate host and decoder interfaces with valid/ready handshaking.
  • DC Balance: Maintains running disparity state to ensure zero DC component.
  • Error Detection: Decoder flags invalid codewords via dec_err.
  • High Performance: Uses combinational logic with LUTs for fast encoding/decoding.
  • Verification: Includes a built-in testbench with passing test cases.

Interface

Signal NameDirectionWidthDescription
clkInput1Clock signal
rst_nInput1Active-low reset
host_validInput1Host input data valid
host_readyOutput1Host input data ready
host_dataInput4Host input data
enc_outOutput6Encoded output data
enc_validOutput1Encoded output valid
enc_readyInput1Encoder output ready
dec_validInput1Decoder input valid
dec_readyOutput1Decoder input ready
dec_inInput6Decoder input data
dec_outOutput4Decoded output data

Architecture

The module consists of an encoder block and a decoder block.

  1. Encoder: Selects codewords based on current running disparity using lookup tables.
  2. Decoder: Maps valid 6-bit codewords back to 4-bit data.
  3. Disparity State: A sequential state machine tracks the running disparity to ensure DC balance.

Verification

The testbench verifies encoding and decoding functions. It checks specific codeword mappings for correctness. It validates error detection for invalid codewords.

### Expected Results

After running the simulation, the Log panel should show:

  • TC1 PASS
  • TC2 PASS
  • TC3 PASS
  • TC4 PASS
  • TC5 PASS
  • Simulation ends with INFO: PASS.

### Test Cases

Test CaseDescriptionResult
TC1Encode input 0PASS
TC2Encode input 1PASS
TC3Decode valid RD-1 codePASS
TC4Decode invalid codePASS
TC5Decode valid RD+1 codePASS

More in Coding & Line Codes

All Coding & Line Codes blocks