From 5effadcbaf66f476c8fffefa2c349676f41c3f52 Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 28 Feb 2020 19:30:27 +0100 Subject: LDPC decoder fully working --- controller/fw/ldpc_decoder.c | 94 +++++++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 27 deletions(-) (limited to 'controller/fw/ldpc_decoder.c') diff --git a/controller/fw/ldpc_decoder.c b/controller/fw/ldpc_decoder.c index 10b5a08..fe59d77 100644 --- a/controller/fw/ldpc_decoder.c +++ b/controller/fw/ldpc_decoder.c @@ -5,6 +5,9 @@ #include #include + +void gausselimination(size_t n, size_t k, int8_t *A, int8_t *b); + void inner_logbp( size_t m, size_t n, size_t bits_count, size_t nodes_count, const uint32_t bits_values[], const uint32_t nodes_values[], @@ -60,6 +63,7 @@ int decode(size_t n, size_t nodes_count, size_t bits_count, uint32_t bits[], int for (unsigned int n_iter=0; n_iter 0 ? "\033[92m" : "\033[94m"); - printf("nij=%04u Lc=%s%3d\033[38;5;240m ", bits_values[q], s, lcv); + //int lcv = Lc[bits_values[q]]; + //char *s = lcv < 0 ? "\033[91m" : (lcv > 0 ? "\033[92m" : "\033[94m"); + //printf("nij=%04u Lc=%s%3d\033[38;5;240m ", bits_values[q], s, lcv); x *= tanhf(0.5f * Lc[bits_values[q]]); } } @@ -153,7 +158,7 @@ void inner_logbp( } } - printf("\n==== i=%03zd p=%01zd x=%08f\n", i, p-bits_counter, x); + //printf("\n==== i=%03zd p=%01zd x=%08f\n", i, p-bits_counter, x); float num = 1 + x; float denom = 1 - x; @@ -197,31 +202,66 @@ void inner_logbp( } } -/* TODO -def get_message(tG, x): - """Compute the original `n_bits` message from a `n_code` codeword `x`. +/* Compute the original (k) bit message from a (n) bit codeword x. + * + * tG: (n, k)-matrix + * x: (n)-vector + * out: (k)-vector + */ +void get_message(size_t n, size_t k, int8_t *tG, int8_t *x, int8_t *out) { - Parameters - ---------- - tG: array (n_code, n_bits) coding matrix tG. - x: array (n_code,) decoded codeword of length `n_code`. + gausselimination(n, k, tG, x); - Returns - ------- - message: array (n_bits,). Original binary message. + out[k - 1] = x[k - 1]; + for (ssize_t i=k-2; i>=0; i--) { + out[i] = x[i]; - """ - n, k = tG.shape + uint8_t sum = 0; + for (size_t j=i+1; j