diff --git a/lte/phy/lib/modem/src/soft_algs.c b/lte/phy/lib/modem/src/soft_algs.c index cb8d4e40b..589c24824 100644 --- a/lte/phy/lib/modem/src/soft_algs.c +++ b/lte/phy/lib/modem/src/soft_algs.c @@ -34,6 +34,54 @@ #include "soft_algs.h" +#define LLR_APPROX_USE_VOLK + + +#ifdef LLR_APPROX_USE_VOLK +void +llr_approx(const _Complex float *in, float *out, int N, int M, int B, + _Complex float *symbols, uint32_t(*S)[6][32], float sigma2) +{ + int i, s, b; + float num, den; + int change_sign = -1; + float x, y, d[64]; + + for (s = 0; s < N; s++) { /* recevied symbols */ + /* Compute the distances squared d[i] between the received symbol and all constellation points */ + for (i = 0; i < M; i++) { + x = __real__ in[s] - __real__ symbols[i]; + y = __imag__ in[s] - __imag__ symbols[i]; + d[i] = x * x + y * y; + } + + for (b = 0; b < B; b++) { /* bits per symbol */ + /* initiate num[b] and den[b] */ + num = d[S[0][b][0]]; + den = d[S[1][b][0]]; + + /* Minimum distance squared search between recevied symbol and a constellation point with a + '1' and a '0' for each bit position */ + for (i = 1; i < M / 2; i++) { /* half the constellation points have '1'|'0' at any given bit position */ + if (d[S[0][b][i]] < num) { + num = d[S[0][b][i]]; + } + if (d[S[1][b][i]] < den) { + den = d[S[1][b][i]]; + } + } + /* Theoretical LLR and approximate LLR values are positive if + * symbol(s) with '0' is/are closer and negative if symbol(s) + * with '1' are closer. + * Change sign if mapping negative to '0' and positive to '1' */ + out[s * B + b] = change_sign * (den - num) / sigma2; + } + } + +} + +#else + /** * @ingroup Soft Modulation Demapping based on the approximate * log-likelihood algorithm @@ -92,6 +140,8 @@ llr_approx(const _Complex float *in, float *out, int N, int M, int B, } +#endif + /** * @ingroup Soft Modulation Demapping based on the approximate * log-likelihood ratio algorithm @@ -108,8 +158,7 @@ llr_approx(const _Complex float *in, float *out, int N, int M, int B, * \param S Soft demapping auxiliary matrix * \param sigma2 Noise vatiance */ -void -llr_exact(const _Complex float *in, float *out, int N, int M, int B, +void llr_exact(const _Complex float *in, float *out, int N, int M, int B, _Complex float *symbols, uint32_t(*S)[6][32], float sigma2) { int i, s, b;