From 9cf1fee2e9f625ca6787e3b14c759be43ea663e6 Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 28 Feb 2020 12:59:25 +0100 Subject: ldpc decoder: wip --- controller/fw/ldpc_decoder.c | 152 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 controller/fw/ldpc_decoder.c (limited to 'controller') diff --git a/controller/fw/ldpc_decoder.c b/controller/fw/ldpc_decoder.c new file mode 100644 index 0000000..5200e8f --- /dev/null +++ b/controller/fw/ldpc_decoder.c @@ -0,0 +1,152 @@ +"""Decoding module.""" + +/* H: decoding matrix as shape (m, n) array + * m: number of equations represented by H + * n: number of code words + * y: received message in codeword space, length n + * + * out: output array of length n where the solutions in codeword space will be written + * + * maxiter: Maximum iteration number + */ +int decode(uint8_t H[], const int m, n, uint8_t y[], uint8_t out[], int maxiter) { + + /* fixme: preprocess the following. +def bitsandnodes(H): + """Return bits and nodes of a parity-check matrix H.""" + bits_indices, bits = scipy.sparse.find(H)[:2] + nodes_indices, nodes = scipy.sparse.find(H.T)[:2] + bits_histogram = np.bincount(bits_indices) + nodes_histogram = np.bincount(nodes_indices) + return bits_histogram, bits, nodes_histogram, nodes + bits_hist, bits_values, nodes_hist, nodes_values = utils.bitsandnodes(H) + */ + + float Lq[m*n]; + float Lr[m*n]; + float L_posteriori[n]; + + for (int n_iter=0; n_iter