RTL Studio Open IDE

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

Mediumsystemverilogsimsyn

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.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Golay (24,12) Encoder with Syndrome Calculator.
  2. 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.
  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

  • Streaming Interface: Valid/ready handshake protocol.
  • Configurable Pipeline: Supports 0, 1, or 2 pipeline stages via the PIPELINE_DEPTH parameter.
  • Parity Inversion: Optional bitwise inversion of parity bits via the INVERT_PARITY parameter.
  • 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 NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low asynchronous reset
valid_inInput1Valid input data flag
ready_inOutput1Ready for input (Always 1)
data_inInput1212-bit data payload
valid_outOutput1Valid output codeword flag
ready_outInput1Ready to accept output from downstream
codeword_outOutput2424-bit encoded codeword
syndrome_outOutput1212-bit syndrome/parity bits

Parameters

ParameterDefaultDescription
PIPELINE_DEPTH1Number 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.

  1. Combinational Logic: Computes the 12-bit syndrome from the 12-bit input data.
  2. Codeword Formation: Concatenates data_in and syndrome (optionally inverted).
  3. Pipeline Register: Registers the codeword and valid signal based on the PIPELINE_DEPTH setting.

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_in is always 1, the encoder will always accept input when valid_in is 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_in if necessary.

More in Coding & Line Codes

All Coding & Line Codes blocks