From 537f1654823b92e7054fa701c15833908851692b Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Fri, 15 Oct 2021 10:48:20 +0200 Subject: [PATCH] Added comments --- lib/src/phy/phch/pucch_nr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/src/phy/phch/pucch_nr.c b/lib/src/phy/phch/pucch_nr.c index 931fbf27a..b8c2005b2 100644 --- a/lib/src/phy/phch/pucch_nr.c +++ b/lib/src/phy/phch/pucch_nr.c @@ -528,14 +528,18 @@ int srsran_pucch_nr_format1_decode(srsran_pucch_nr_t* q, float llr[SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS]; srsran_demod_soft_demodulate((nof_bits == 1) ? SRSRAN_MOD_BPSK : SRSRAN_MOD_QPSK, &d, llr, 1); - // Hard decision + // Hard decision based on the LLRs sign for (uint32_t i = 0; i < nof_bits; i++) { b[i] = llr[i] > 0.0f ? 1 : 0; } // Calculate normalised correlation, it uses the absolute value of d and accumulated average power if (norm_corr != NULL) { - float nsymb = (float)SRSRAN_CEIL(resource->nof_symbols, 2); + // Get the number of payload symbols. As the one of every 2 symbols carry DMRS, the payload symbols is half of the + // total symbols rounding down + float nsymb = (float)SRSRAN_FLOOR(resource->nof_symbols, 2); + + // Avoid zero, INF or NAN division, set correlation to 0 in this case if (isnormal(pwr_acc) && isnormal(nsymb)) { *norm_corr = cabsf(d) / sqrtf(pwr_acc * nsymb); } else {