Coding & Line Codes
Golay (24,12) Encoder with Syndrome Calculator
Fully synthesizable Golay (24,12) block encoder with streaming interface and syndrome calculation.
About this block
Simulate it in the Verilog IDE
Golay (24,12) Encoder with Syndrome Calculator 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.
This IP provides a fully synthesizable, streaming Golay (24,12) block encoder. It maps 12-bit input data to a 24-bit codeword and simultaneously computes a 12-bit syndrome for error detection. The design supports configurable pipeline depths (0-2 stages) to balance throughput and timing closure. It includes optional parity inversion and is designed for latch-free, high-frequency operation using standard SystemVerilog.
- Choose Open in IDE. RTL Studio loads the packaged workspace for Golay (24,12) Encoder with Syndrome Calculator.
- Read the SystemVerilog module in the editor. The catalog line for this block: Fully synthesizable Golay (24,12) block encoder with streaming interface and syndrome calculation.
- 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
- Streaming Interface: Valid/ready handshake protocol.
- Configurable Pipeline: Supports 0, 1, or 2 pipeline stages via the
PIPELINE_DEPTHparameter. - Parity Inversion: Optional bitwise inversion of parity bits via the
INVERT_PARITYparameter. - Syndrome Output: Computes a 12-bit syndrome for immediate error detection.
- Synthesizable: Latch-free RTL compatible with major synthesis tools (Vivado, Quartus, etc.).
Interface
The module uses a simple valid/ready handshake protocol.
Note on ready_in: This signal is an output from the encoder indicating it is ready to accept data. It is hardwired to 1'b1, meaning the encoder never stalls the upstream producer. The upstream producer should drive valid_in based on its own data availability.
| Signal Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock input |
rst_n | Input | 1 | Active-low asynchronous reset |
valid_in | Input | 1 | Valid input data flag |
ready_in | Output | 1 | Ready for input (Always 1) |
data_in | Input | 12 | 12-bit data payload |
valid_out | Output | 1 | Valid output codeword flag |
ready_out | Input | 1 | Ready to accept output from downstream |
codeword_out | Output | 24 | 24-bit encoded codeword |
syndrome_out | Output | 12 | 12-bit syndrome/parity bits |
Parameters
| Parameter | Default | Description |
|---|---|---|
PIPELINE_DEPTH | 1 | Number of pipeline stages (0, 1, or 2). |
Higher depth improves Fmax but adds latency. |
Architecture
The encoder generates parity bits using XOR logic derived from the Golay generator matrix. The codeword is formed by concatenating the original 12-bit data and the 12-bit syndrome bits.
- Combinational Logic: Computes the 12-bit syndrome from the 12-bit input data.
- Codeword Formation: Concatenates
data_inandsyndrome(optionally inverted). - Pipeline Register: Registers the codeword and valid signal based on the
PIPELINE_DEPTHsetting.
Verification
The included testbench validates the following scenarios:
- TC1: Generation of 1024 random codewords and structural verification.
- TC2: Uniqueness of syndromes for single-bit errors.
- TC3: Minimum Hamming distance verification via syndrome checks.
All test cases pass successfully.
Integration
- Timing: Ensure timing constraints are set for the chosen
PIPELINE_DEPTH.
Typical Fmax ranges from 200MHz (0 stages) to 400MHz+ (2 stages) depending on target technology.
- Reset: The module uses an active-low asynchronous reset (
rst_n). - Backpressure: Since
ready_inis always 1, the encoder will always accept input whenvalid_inis high.
Ensure upstream logic handles backpressure if the producer cannot sustain the rate.
- Throughput: Ensure downstream logic can handle the throughput or implement backpressure on
valid_inif necessary.
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
- Bit Unstuffer After 5 Ones — L2 Upgrade
- Hamming (7,4) Decoder
- Hamming (7,4) Encoder
- HDLC Bit Stuffing (5 Ones)
- HDLC Bit-Stuff Remover
- NRZ-to-NRZI Line Encoder — L2 Upgrade