olo_base_rs_decode¶
Status Information¶
VHDL Source: olo_base_rs_decode
Description¶
This entity is a Reed-Solomon decoder over GF(2^m) for a stream of symbols, the counterpart of olo_base_rs_encode. It takes the same generics for the code (field polynomial, code length n, data symbols k, generator roots alpha^(b0 + i*gamma), interleaving depth I, dual basis) and corrects up to t = (n-k)/2 symbol errors in every codeword. Shortened blocks are supported. Erasures are not supported.
The entity outputs the corrected data symbols of each block (optionally also the check symbols) and, after the last output symbol of a block, one status pulse per codeword with the number of corrected symbols and an uncorrectable flag. The field arithmetic is in olo_base_pkg_gf.
The reference configuration is the Reed-Solomon code of CCSDS 131.0-B-5 (TM Synchronization and Channel Coding, section 4). The generics are the same as for the encoder:
| Generic | E = 16, RS(255,223) | E = 8, RS(255,239) | Clause |
|---|---|---|---|
| FieldPolynomial_g | x"87" | x"87" | 4.3.3 |
| CodewordSymbols_g | 255 | 255 | 4.3.2 |
| DataSymbols_g | 223 | 239 | 4.3.2 |
| FirstRoot_g | 212 | 45 | 4.3.4 |
| RootStep_g | 11 | 11 | 4.3.4 |
| InterleaveDepth_g | 1, 2, 3, 4, 5 or 8 | 1, 2, 3, 4, 5 or 8 | 4.3.5 |
| DualBasis_g | 117 | 117 | 4.3.9 |
The attached sync marker and the pseudo-randomizer are not part of this entity: the input of the decoder is the derandomized codeblock without the marker.
A Python model of the decoder is in src/base/python/olo_base_rs; the testbench compares the entity with it, including blocks with more than t errors per codeword and invalid blocks.
Generics¶
| Name | Type | Default | Description |
|---|---|---|---|
| FieldPolynomial_g | std_logic_vector | - | Field polynomial without its x^m term (as in olo_base_pkg_gf), e.g. x"87" for x^8 + x^7 + x^2 + x + 1. Its length is the symbol width m (3 ... 12). Must be primitive. |
| CodewordSymbols_g | positive | - | Codeword length n in symbols, at most 2^m-1 |
| DataSymbols_g | positive | - | Data symbols per codeword k (k < n). n-k must be even. |
| FirstRoot_g | natural | 0 | b0, exponent of the first root of the generator polynomial (see olo_base_rs_encode) |
| RootStep_g | positive | 1 | gamma, the step between the exponents of consecutive roots. Must be coprime to 2^m-1. |
| InterleaveDepth_g | positive | 1 | Interleaving depth I: number of codewords interleaved symbol by symbol in one block |
| DualBasis_g | natural | 0 | Representation of the symbols at the ports: 0: polynomial basis s > 0: dual basis of (1, alpha^s, ..., alpha^(s(m-1))) (CCSDS 131.0-B-5: 117) |
| OutputParity_g | boolean | false | false: only the data symbols are output true: the check symbols are output too (marked by Out_Parity) |
| RamStyle_g | string | "auto" | RAM style of the block buffer, see olo_base_ram_sdp |
| RamBehavior_g | string | "RBW" | RAM behavior of the block buffer, see olo_base_ram_sdp |
Interfaces¶
Control¶
| Name | In/Out | Length | Default | Description |
|---|---|---|---|---|
| Clk | in | 1 | - | Clock |
| Rst | in | 1 | - | Reset input (high-active, synchronous to Clk) |
Input Data¶
| Name | In/Out | Length | Default | Description |
|---|---|---|---|---|
| In_Valid | in | 1 | '1' | AXI4-Stream handshaking signal for In_Data |
| In_Ready | out | 1 | N/A | AXI4-Stream handshaking signal for In_Data |
| In_Data | in | m | - | Received symbol (data or check symbol) |
| In_Last | in | 1 | '0' | Last symbol of a shortened block. Not required for a block of I*n symbols. |
Output Data¶
| Name | In/Out | Length | Default | Description |
|---|---|---|---|---|
| Out_Valid | out | 1 | N/A | AXI4-Stream handshaking signal for Out_Data |
| Out_Ready | in | 1 | '1' | AXI4-Stream handshaking signal for Out_Data |
| Out_Data | out | m | N/A | Corrected symbol |
| Out_Parity | out | 1 | N/A | '1' for check symbols (only output with OutputParity_g = true) |
| Out_Last | out | 1 | N/A | Last output symbol of the block |
Status¶
| Name | In/Out | Length | Default | Description |
|---|---|---|---|---|
| Status_Valid | out | 1 | N/A | One pulse per codeword, codewords 1 ... I of the block on consecutive clock cycles |
| Status_Last | out | 1 | N/A | Status of the last codeword of the block |
| Status_Corrected | out | ceil(log2(t+1)) | N/A | Number of symbols of the codeword the decoder changed |
| Status_Uncorrectable | out | 1 | N/A | '1' if the codeword is uncorrectable |
The status has no ready signal: the user must accept a pulse in every clock cycle in which Status_Valid is high.
Architecture¶
Blocks¶
A block consists of the I*n symbols of a codeblock as olo_base_rs_encode outputs it: symbol i of the block belongs to codeword i mod I, the last I*(n-k) symbols are the check symbols. A full block ends automatically after I*n symbols; In_Last ends a shortened block (CCSDS 131.0-B-5 4.3.7) earlier.
A block is decoded if its length is a multiple of I and at least I*(n-k+1) symbols (one data symbol per codeword). Any other block is not a valid codeblock. The entity does not decode it: its symbols pass unchanged, and all I codewords are reported uncorrectable with a corrected count of zero. A block whose length is not a multiple of I also produces an assertion warning in simulation. The next block is decoded normally.
A reset discards the block that is being received and all blocks that are not yet completely output, including their status. After a reset, In_Ready is low for I clock cycles while the syndrome registers are cleared.
Decoding¶
The decoder works in three stages, each one block apart:
- Syndromes. While a block is received, the symbols are written into a buffer RAM and the 2t syndromes of all I codewords are computed in parallel (Horner's rule, constant multipliers). Two sets of syndrome registers alternate between consecutive blocks.
- Key equation. For each codeword the syndromes are scaled to the length of the (shortened) block and the key equation is solved by the reformulated inversionless Berlekamp-Massey algorithm (RiBM, Sarwate and Shanbhag), one iteration per clock cycle, 2t iterations per codeword. The resulting error locator Lambda(x) and error evaluator Omega(x) of all I codewords are stored.
- Correction. The symbols of the block are read from the buffer in their original order. For every position the Chien search evaluates Lambda(x) and the Forney formula computes the error value, which is added to the symbol on its way to the output. Search and correction run at the speed of the output, one position per clock cycle, so no second buffer is needed.
Uncorrectable Codewords¶
A codeword is reported uncorrectable if one of the following holds:
- The Berlekamp-Massey register length L is larger than t, or the degree of Lambda(x) differs from L. In this case no symbol of the codeword is changed.
- The number of positions of the (shortened) codeword at which Lambda(x) has a root differs from its degree. Roots in the virtual fill of a shortened codeword are not found and count as missing; a multiple root is found only once.
- The block is not a valid codeblock (see Blocks).
Because the correction runs together with the output, the decoder knows whether a codeword is uncorrectable only after its last position passed. The output symbols of an uncorrectable codeword may therefore contain changes that are not corrections, and Status_Corrected reports the number of symbols that were changed. A user that must not forward wrongly corrected data has to buffer the output of a block until its status arrives.
Like every Reed-Solomon decoder, the entity cannot detect all codewords with more than t errors: such a codeword can be close enough to another valid codeword to be decoded to it and reported as corrected.
Status Timing¶
The status of a block consists of I pulses on Status_Valid on consecutive clock cycles, one per codeword in the order codeword 1 ... I. Status_Last marks the pulse of the last codeword.
The first pulse comes at the earliest two clock cycles after the handshake of the block's Out_Last symbol, and only after all positions of the block (including the check symbols, which pass the correction stage even when they are not output) were processed. The status of a block is therefore never output before its last output symbol was accepted. The output of the next block can start before the status pulses of the previous block.
For a block without output symbols (a block of at most I*(n-k) symbols with OutputParity_g = false) the status pulses follow the processing of its positions.
Timing and Throughput¶
- The input accepts one symbol per clock cycle.
- The correction stage processes one position per clock cycle. With OutputParity_g = false the check symbols are not output, so the output of each block has a gap of I*(n-k) clock cycles; the data rate at the output is k/n of the clock. With 8-bit symbols at 200 MHz the input carries 1.6 Gbit/s.
- The entity handles one symbol per beat. Wider streams are converted with olo_base_wconv_n2xn and olo_base_wconv_xn2n around it.
- Latency: the first output symbol of a block appears I*(2t+2) + 2t + 8 clock cycles after the last symbol of the block was accepted (decoder idle, Out_Ready high), e.g. 74 clock cycles for CCSDS E = 16 with I = 1, 210 with I = 5, and 42 for E = 8 with I = 1.
- Status: with OutputParity_g = false the first status pulse of a block comes I*(n-k) + 1 clock cycles after its Out_Last symbol (the check symbols are processed but not output); with OutputParity_g = true it comes two clock cycles after Out_Last (Out_Ready high).
- Continuous operation: blocks of N symbols that follow each other without a gap are accepted without stalling the input (In_Ready stays high) as long as Out_Ready is high and N >= I*(2t+3) + 2t + 3. The bound comes from the key equation solver, which needs 2t+2 clock cycles per codeword. For full blocks (N = I*n) it holds for all codes with n >= 2t+3 + (2t+3)/I, which includes every CCSDS configuration. For CCSDS E = 16, shortened blocks need at least 70 (I = 1), 53 (I = 2), 42 (I = 5) or 40 (I = 8) symbols per codeword for continuous operation. Shorter blocks are decoded at a rate of one block per I*(2t+3) + 2t + 3 clock cycles; In_Ready goes low as needed.
- While Out_Ready is low, the decoder keeps receiving until its buffer of 2^ceil(log2(2In)) symbols or its queue of four blocks is full.
Resources¶
Synthesis results for the CCSDS configurations (Libero SoC 2025.2, PolarFire SoC MPFS250T, speed grade STD; the maximum frequency with registered ports after place and route):
| Configuration | LUTs | Registers | Block RAM (LSRAM) | Small RAM (uSRAM) | Fmax |
|---|---|---|---|---|---|
| E = 16, I = 5 | 14131 | 6335 | 2 | 31 | 192 MHz |
| E = 8, I = 1 | 4466 | 1717 | 1 | 4 | 207 MHz |
The buffer of the received symbols uses block RAM, the stored locator and evaluator coefficients of the codewords use small RAMs. Most of the logic is the key equation solver: the RiBM structure has 3t+1 processing elements with two general GF(2^m) multipliers each, so its size grows with t but not with I. In the configuration with E = 16 the critical path is the selection of the syndrome in the scaling stage of the key equation solver.
The solver is busy for 2t+2 of the n clock cycles of each codeword. A folded solver with fewer processing elements, which spends several clock cycles per iteration, would reduce the area while keeping the throughput for full blocks; it is a possible extension and not implemented.