short-ldpc#
Pure OCaml implementation of CCSDS 131.4-B Short Block-Length LDPC Codes.
Overview#
Short block-length LDPC codes for telemetry frames where turbo codes and regular LDPC codes have insufficient block length. Uses pseudo-random regular LDPC matrices with sum-product (belief propagation) decoding.
Three code sizes are provided: k=128, k=256, and k=512 bits, all at rate 1/2.
Installation#
Install with opam:
$ opam install short-ldpc
If opam cannot find the package, it may not yet be released in the public
opam-repository. Add the overlay repository, then install it:
$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install short-ldpc
Usage#
(* Pick a code: 256-bit information block, rate 1/2 *)
let code = Short_ldpc.ccsds_256
(* Encode 32 bytes: codeword is 64 bytes (32 data + 32 parity) *)
let data = Bytes.make 32 '\xAB'
let codeword = Short_ldpc.encode code data
let () =
Printf.printf "Code rate: %.2f\n" (Short_ldpc.rate code);
(* Decode with up to 50 BP iterations *)
match Short_ldpc.decode ~max_iter:50 code codeword with
| Ok recovered -> assert (recovered = data)
| Error msg -> Printf.eprintf "decode failed: %s\n" msg
API Overview#
ccsds_128,ccsds_256,ccsds_512-- Pre-built rate-1/2 LDPC codesencode-- Systematic LDPC encoding (data to codeword)decode-- Belief propagation decoding with configurable max iterationsrate-- Query the code rate (k/n)
References#
- CCSDS 131.4-B-1 -- Short Block Length LDPC Codes for TC Synchronization and Channel Coding
Licence#
ISC License. See LICENSE.md for details.