Reusable C++ coding-related code library
Find a file
Ahmet Inan f9dad0397b replaced 8 bit CRC with 16 bit 0xA8F4
8 bit CRC is simply too weak with a large list size
2026-02-14 06:06:59 +01:00
tests replaced 8 bit CRC with 16 bit 0xA8F4 2026-02-14 06:06:59 +01:00
tools also print bit transition count 2025-06-14 10:40:29 +02:00
.gitignore moved crc and xorshift from DSP to CODE repository 2018-09-20 08:36:45 +02:00
avx2.hh added more shuffle operations for AVX2 2024-02-14 10:48:45 +01:00
avx2_double.hh make gnu compiler happy 2024-02-21 07:54:44 +01:00
bitman.hh time to embrace #pragma once 2020-08-05 10:43:49 +02:00
bitstream.hh time to embrace #pragma once 2020-08-05 10:43:49 +02:00
bose_chaudhuri_hocquenghem_decoder.hh time to embrace #pragma once 2020-08-05 10:43:49 +02:00
bose_chaudhuri_hocquenghem_encoder.hh time to embrace #pragma once 2020-08-05 10:43:49 +02:00
cauchy_prime_field_erasure_coding.hh used larger type and replaced literals with constants 2024-03-30 10:12:03 +01:00
cauchy_reed_solomon_erasure_coding.hh hopefully these names are less confusing 2023-06-09 10:06:34 +02:00
crc.hh time to embrace #pragma once 2020-08-05 10:43:49 +02:00
exclusive_reduce.hh time to embrace #pragma once 2020-08-05 10:43:49 +02:00
galois_field.hh added code that might be faster on smaller CPUs 2023-05-18 15:55:11 +02:00
hadamard_decoder.hh oops 2023-05-11 13:41:19 +02:00
hadamard_encoder.hh encoder and soft decoder for augmented Hadamard codes 2020-06-11 23:11:31 +02:00
interleave.hh added simple interleavers 2023-03-27 11:07:04 +02:00
ldpc_decoder.hh made compiler happy 2025-12-25 12:35:00 +01:00
ldpc_encoder.hh made compiler happy 2025-12-25 12:35:00 +01:00
LICENSE moved crc and xorshift from DSP to CODE repository 2018-09-20 08:36:45 +02:00
mls.hh added length() method 2025-06-13 16:22:53 +02:00
neon.hh removed negz constants for consistency 2024-02-13 11:59:44 +01:00
neon_double.hh use struct versions of vqtbl 2026-01-20 11:24:13 +01:00
neon_quadruple.hh use struct versions of vqtbl 2026-01-20 11:24:13 +01:00
neon_triple.hh use struct versions of vqtbl 2026-01-20 11:24:13 +01:00
osd.hh use merge sort 2024-03-08 14:02:17 +01:00
osd_bch.png updated ber plot 2024-02-04 08:51:56 +01:00
osd_pac_crc.png added FER curves for OSD, PAC and CRC-aided Polar 2025-12-30 08:35:30 +01:00
pac_encoder.hh limit code length to 256 2026-02-02 07:54:51 +01:00
pac_list_decoder.hh limit code length to 256 2026-02-02 07:54:51 +01:00
permute.hh removed block shuffle 2023-05-11 09:01:08 +02:00
polar_ber.png remade with improved decoders 2024-03-03 20:54:53 +01:00
polar_decoder.hh limit polar to order 20 and list decoder to 16 2023-07-25 11:48:23 +02:00
polar_encoder.hh use uint32_t for the frozen bits 2021-07-13 10:50:06 +02:00
polar_freezer.hh renamed PolarCodeConst0 to BhattacharyyaFreezer 2026-02-13 12:47:55 +01:00
polar_helper.hh added support for int16_t 2025-07-01 22:39:07 +02:00
polar_list_decoder.hh use the new sorting functions 2024-03-07 22:04:09 +01:00
polar_parity_aided.hh use the new sorting functions 2024-03-07 22:04:09 +01:00
polar_sequence.hh added Reed Muller rule construction 2025-12-29 09:36:29 +01:00
prime_field.hh removed testing code 2024-03-26 09:13:45 +01:00
README.md renamed PolarCodeConst0 to BhattacharyyaFreezer 2026-02-13 12:47:55 +01:00
reed_solomon_decoder.hh time to embrace #pragma once 2020-08-05 10:43:49 +02:00
reed_solomon_encoder.hh time to embrace #pragma once 2020-08-05 10:43:49 +02:00
reed_solomon_error_correction.hh made compiler happy 2025-12-25 12:35:00 +01:00
rotate.hh use faster vqtbl1q_u8 on ARM64 2023-05-05 08:53:56 +02:00
short_bch_code_decoder.hh don't rely on err[] being signed 2020-07-08 13:46:07 +02:00
short_bch_code_encoder.hh moved constructor generator argument to template parameter 2020-06-14 20:43:45 +02:00
simd.hh added double, triple and quadruple versions for SSE 2024-02-13 12:37:38 +01:00
simd_sort.hh use the new sorting functions 2024-03-07 22:04:09 +01:00
simplex_decoder.hh oops 2023-05-11 13:41:19 +02:00
simplex_encoder.hh added encoder and soft decoder for simplex codes 2020-05-31 17:43:29 +02:00
sort.hh added comp argument and test for stability 2024-03-08 13:00:40 +01:00
sse4_1.hh removed negz constants for consistency 2024-02-13 11:59:44 +01:00
sse4_1_double.hh added vshuf versions for SSE 2024-02-13 13:27:55 +01:00
sse4_1_quadruple.hh added vshuf versions for SSE 2024-02-13 13:27:55 +01:00
sse4_1_triple.hh added vshuf versions for SSE 2024-02-13 13:27:55 +01:00
xorshift.hh added XorShiftMask 2025-06-14 09:16:31 +02:00

This is a work in progress and a long overdue attempt to bring all our coding-related code together and make it reusable for our future projects.

Before using any of this you should enter the tests directory and execute "make". This will check if your compiler is able to create binaries that are able to produce correct results when executed.

What we have included so far:

crc.hh

A Cyclic redundancy check helps ensuring data integrity.

For example, if we need to integrate CRC32 checking for a few bytes, like in the following:

# echo -n 'Hello World!' | rhash -C -
(stdin) 1C291CA3

We can add it to our project as simple as that:

CODE::CRC<uint32_t> crc(0xEDB88320, 0xFFFFFFFF);
for (uint8_t c: std::string("Hello World!")) crc(c);
assert(~crc() == 0x1C291CA3);

xorshift.hh

Sometimes we need a sequence of "random enough" numbers but don't want to store them in an array to get a repeatable sequence. Here a Pseudorandom number generator can help by prodiving a deterministic and thus repeatable sequence of numbers. George Marsaglia discovered a class of simple and fast pseudorandom number generators, which he called Xorshift.

mls.hh

Maximum length sequences have useful correlation properties.

bitstream.hh

When dealing with unaligned and arbitrary-bit-sized elements in a data stream, the bitwise stream container might help avoiding some headaches.

bitman.hh

Simple bit manipulation on byte arrays.

galois_field.hh

We have to thank Évariste Galois for his contribution of the Finite field to mathematics, which laid the cornerstone for a variety of applications that we take for granted today. One of them is ReedSolomon error correction:

reed_solomon_error_correction.hh

Implemented are the following Encoders and Decoders:

short_bch_code_encoder.hh

Encoder for short BCH codes

short_bch_code_decoder.hh

Syndrome decoding based Soft-decision decoder for short BCH codes

simplex_encoder.hh

Encoder for Simplex codes.

simplex_decoder.hh

Soft-decision decoder for Simplex codes.

hadamard_encoder.hh

Encoder for augmented Hadamard codes.

hadamard_decoder.hh

Soft-decision decoder for augmented Hadamard codes.

ldpc_encoder.hh

Low-density parity-check encoder

ldpc_decoder.hh

SIMD intra-frame accelerated Low-density parity-check layered decoder.

polar_freezer.hh

Bit freezers for the construction of polar codes.

  • PolarFreezer: Constructs code for a given erasure probability without the need for storing nor sorting of erasure probabilities for the virtual channels.
  • BhattacharyyaFreezer: Constructs code by choosing the K best virtual channels computed from a given erasure probability.

polar_sequence.hh

Construction of reliability sequences for polar codes.

  • BhattacharyyaSequence: Constructs a sequence by sorting virtual channel reliabilities computed from a given erasure probability.
  • ReedMullerSequence: Constructs a sequence by sorting virtual channels by the Hamming weight of their index first and then by their magnitude to resolve ties.

polar_encoder.hh

Encoders for non-systematic and systematic polar codes.

polar_decoder.hh

Successive cancellation decoding of polar codes.

polar_list_decoder.hh

Successive cancellation list decoding of polar codes.

List size depends on used SIMD type. Decoding performance of the fixed-point implementation is better with shorter codes, as the list size is larger but a deterioration can be observed with larger codes.

polar_parity_aided.hh

Parity check aided successive cancellation list decoding of polar codes. Polar decoder comparisons

pac_list_decoder.hh

Successive cancellation list decoding of Polarization-Adjusted Convolutional codes. OSD, PAC and CRC

osd.hh

Ordered statistics decoding allows the practical soft-decision decoding of short to medium sized linear codes. Below are the BER plots of the BCH(127, 64) T=10 code, using the OSD Soft-decision decoder and the ReedSolomon error correction BCH decoder with erasures. OSD and BCH decoder comparison

exclusive_reduce.hh

Reduce N times while excluding ith input element

It computes the following, but having only O(N) complexity and using O(1) extra storage:

	output[0] = input[1];
	output[1] = input[0];
	for (int i = 2; i < N; ++i)
		output[i] = op(input[0], input[1]);
	for (int i = 0; i < N; ++i)
		for (int j = 2; j < N; ++j)
			if (i != j)
				output[i] = op(output[i], input[j]);

simd.hh

Single instruction, multiple data (SIMD) wrappers for:

rotate.hh

SIMD element wise horizontal rotation

It computes the following, but faster:

SIMD<int8_t, SIZE> rotate(SIMD<int8_t, SIZE> input, int shift, int WIDTH)
{
	SIMD<int8_t, SIZE> output;
	for (int n = 0; n < WIDTH; ++n)
		output.v[(n + shift + WIDTH) % WIDTH] = input.v[n];
	return output;
}