diff --git a/lib/include/srslte/phy/phch/pucch.h b/lib/include/srslte/phy/phch/pucch.h index 2134bb19b..0e5d08ab5 100644 --- a/lib/include/srslte/phy/phch/pucch.h +++ b/lib/include/srslte/phy/phch/pucch.h @@ -91,6 +91,7 @@ typedef struct SRSLTE_API { typedef struct SRSLTE_API { srslte_uci_value_t uci_data; + float dmrs_correlation; float correlation; bool detected; } srslte_pucch_res_t; @@ -184,7 +185,7 @@ SRSLTE_API void srslte_pucch_tx_info(srslte_pucch_cfg_t* cfg, srslte_uci_value_t* uci_data, char* str, uint32_t str_len); SRSLTE_API void -srslte_pucch_rx_info(srslte_pucch_cfg_t* cfg, srslte_uci_value_t* uci_data, char* str, uint32_t str_len); +srslte_pucch_rx_info(srslte_pucch_cfg_t* cfg, srslte_pucch_res_t* pucch_res, char* str, uint32_t str_len); SRSLTE_API bool srslte_pucch_cfg_isvalid(srslte_pucch_cfg_t* cfg, uint32_t nof_prb); diff --git a/lib/src/phy/enb/enb_ul.c b/lib/src/phy/enb/enb_ul.c index 10a93c50e..fb3d29511 100644 --- a/lib/src/phy/enb/enb_ul.c +++ b/lib/src/phy/enb/enb_ul.c @@ -185,8 +185,8 @@ static int get_pucch(srslte_enb_ul_t* q, srslte_ul_sf_cfg_t* ul_sf, srslte_pucch // Get possible resources int nof_resources = srslte_pucch_proc_get_resources(&q->cell, cfg, &cfg->uci_cfg, NULL, n_pucch_i); - if (nof_resources < SRSLTE_SUCCESS || nof_resources > SRSLTE_PUCCH_CS_MAX_ACK) { - ERROR("No PUCCH resource could be calculated\n"); + if (nof_resources < 1 || nof_resources > SRSLTE_PUCCH_CS_MAX_ACK) { + ERROR("No PUCCH resource could be calculated (%d)\n", nof_resources); return SRSLTE_ERROR; } @@ -216,12 +216,8 @@ static int get_pucch(srslte_enb_ul_t* q, srslte_ul_sf_cfg_t* ul_sf, srslte_pucch srslte_pucch_cs_get_ack(cfg, &cfg->uci_cfg, i, b, &pucch_res.uci_data); } - char txt[256]; - srslte_pucch_rx_info(cfg, &pucch_res.uci_data, txt, sizeof(txt)); - INFO("[ENB_UL/PUCCH] Decoded %s, corr=%.3f\n", txt, pucch_res.correlation); - // Check correlation value, keep maximum - if (pucch_res.correlation > res->correlation) { + if (i == 0 || pucch_res.correlation > res->correlation) { *res = pucch_res; } } diff --git a/lib/src/phy/phch/pucch.c b/lib/src/phy/phch/pucch.c index 2860f4506..b148ce556 100644 --- a/lib/src/phy/phch/pucch.c +++ b/lib/src/phy/phch/pucch.c @@ -912,17 +912,19 @@ int srslte_pucch_decode(srslte_pucch_t* q, // Equalization srslte_predecoding_single(q->z_tmp, q->ce, q->z, NULL, nof_re, 1.0f, channel->noise_estimate); - // DMRS Detection - cf_t _dmrs_corr = srslte_vec_acc_cc(q->ce, nof_re) / nof_re; - float _rms = __real__(conjf(_dmrs_corr) * _dmrs_corr); - float _pow = srslte_vec_avg_power_cf(q->ce, nof_re); - float _r = _rms / _pow; - - // Return not detected if the ratio is 0, NAN, +/- Infinity or below threshold - if (!isnormal(_r) || _r < cfg->threshold_dmrs_detection) { - data->detected = false; - data->correlation = NAN; - return SRSLTE_SUCCESS; + // Perform DMRS Detection, if enabled + if (isnormal(cfg->threshold_dmrs_detection)) { + cf_t _dmrs_corr = srslte_vec_acc_cc(q->ce, SRSLTE_NRE) / SRSLTE_NRE; + float rms = __real__(conjf(_dmrs_corr) * _dmrs_corr); + float power = srslte_vec_avg_power_cf(q->ce, SRSLTE_NRE); + data->dmrs_correlation = rms / power; + + // Return not detected if the ratio is 0, NAN, +/- Infinity or below threshold + if (!isnormal(data->dmrs_correlation) || data->dmrs_correlation < cfg->threshold_dmrs_detection) { + data->correlation = 0.0f; + data->detected = false; + return SRSLTE_SUCCESS; + } } // Perform ML-decoding @@ -1368,7 +1370,7 @@ void srslte_pucch_tx_info(srslte_pucch_cfg_t* cfg, srslte_uci_value_t* uci_data, } } -void srslte_pucch_rx_info(srslte_pucch_cfg_t* cfg, srslte_uci_value_t* uci_data, char* str, uint32_t str_len) +void srslte_pucch_rx_info(srslte_pucch_cfg_t* cfg, srslte_pucch_res_t* pucch_res, char* str, uint32_t str_len) { uint32_t n = srslte_print_check(str, str_len, @@ -1378,7 +1380,13 @@ void srslte_pucch_rx_info(srslte_pucch_cfg_t* cfg, srslte_uci_value_t* uci_data, srslte_pucch_format_text_short(cfg->format), cfg->n_pucch); - if (uci_data) { - srslte_uci_data_info(&cfg->uci_cfg, uci_data, &str[n], str_len - n); + if (pucch_res) { + if (isnormal(cfg->threshold_dmrs_detection)) { + n = srslte_print_check(str, str_len, n, ", dmrs_corr=%.3f", pucch_res->dmrs_correlation); + } + + n = srslte_print_check(str, str_len, n, ", corr=%.3f", pucch_res->correlation); + + srslte_uci_data_info(&cfg->uci_cfg, &pucch_res->uci_data, &str[n], str_len - n); } } diff --git a/srsenb/src/phy/cc_worker.cc b/srsenb/src/phy/cc_worker.cc index 1bbe96f3a..24abf8089 100644 --- a/srsenb/src/phy/cc_worker.cc +++ b/srsenb/src/phy/cc_worker.cc @@ -422,8 +422,8 @@ int cc_worker::decode_pucch() // Logging char str[512]; - srslte_pucch_rx_info(&ul_cfg.pucch, &pucch_res.uci_data, str, 512); - Info("PUCCH: cc=%d; %s, corr=%.1f\n", cc_idx, str, pucch_res.correlation); + srslte_pucch_rx_info(&ul_cfg.pucch, &pucch_res, str, 512); + Info("PUCCH: cc=%d; %s\n", cc_idx, str); } } }