Skip to content
Tech News
← Back to articles

Show HN: SIMD Viterbi Decoder in Rust

read original more articles
Why This Matters

This article introduces a Rust-based SIMD-accelerated Viterbi decoder and error correction codes crucial for software-defined radio and satellite communications. Its implementation enhances decoding efficiency and supports a wide range of code rates and orders, benefiting both industry professionals and consumers relying on robust data transmission. The integration of SIMD features on nightly Rust further accelerates processing, making it a significant advancement in error correction technology.

Key Takeaways

fec

Forward error correction for SDR, space, and satellite applications.

fec implements two error-correcting codes that show up throughout software-defined radio and spacecraft links:

Convolutional codes with a Viterbi decoder (hard and soft decision), including the common rate-1/2 k=7, rate-1/2 k=9, rate-1/3 k=9, and rate-1/6 k=15 codes. Supports any rate from 1/2 to 1/8 and any order from k=4 to k=16. On nightly Rust, the simd feature enables a Viterbi decoder with acceleration on SSE/AVX2/AVX512.

with a Viterbi decoder (hard and soft decision), including the common rate-1/2 k=7, rate-1/2 k=9, rate-1/3 k=9, and rate-1/6 k=15 codes. Supports any rate from 1/2 to 1/8 and any order from k=4 to k=16. On nightly Rust, the feature enables a Viterbi decoder with acceleration on SSE/AVX2/AVX512. Reed–Solomon codes over GF(2⁸) with error and erasure decoding, including the standard CCSDS (255,223) code in both the conventional and the on-the-wire dual-basis (Berlekamp) representations.

fec started as and draws heavy inspiration from the author's own libcorrect, a C library for forward error correction. This crate also credits Phil Karn's libfec C library for offering an original implementation of these codes, although this crate does not borrow any source or have any relationship with that library, and the name is purely coincidental.

Standard parameters (primitive polynomials, the CCSDS dual-basis transform) are derived from the published CCSDS standard (CCSDS 131.0-B, Annex D for the dual basis).

Quick start

Convolutional (Viterbi)

use fec :: { ConvEncoder , ConvDecoder } ; // Rate-1/2, order-7 NASA code. let polys = [ 0o161 , 0o127 ] ; let mut enc = ConvEncoder :: new ( 2 , 7 , & polys ) ; let mut dec = ConvDecoder :: new ( 2 , 7 , & polys ) ; let msg = b"hello, error correction" ; let mut encoded = vec ! [ 0u8 ; enc . encode_len ( msg . len ( ) ) ] ; let num_bits = enc . encode ( msg , & mut encoded ) . unwrap ( ) ; // ... encoded is corrupted in transit ... let mut recovered = vec ! [ 0u8 ; msg . len ( ) ] ; dec . decode_hard ( & encoded , num_bits , & mut recovered ) . unwrap ( ) ;

... continue reading