From 3ab5f3a7e8b31fa1f2e6f2e46bca80997aa2a476 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Tue, 10 Sep 2019 09:37:46 +0200 Subject: [PATCH] Initial wiener filter integradion in DL channel estimator --- .../srslte/phy/ch_estimation/chest_dl.h | 3 ++ lib/src/phy/ch_estimation/chest_dl.c | 38 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/lib/include/srslte/phy/ch_estimation/chest_dl.h b/lib/include/srslte/phy/ch_estimation/chest_dl.h index 0a62354ac..34aaadf08 100644 --- a/lib/include/srslte/phy/ch_estimation/chest_dl.h +++ b/lib/include/srslte/phy/ch_estimation/chest_dl.h @@ -45,6 +45,7 @@ #include "srslte/phy/common/phy_common.h" #include "srslte/phy/resampling/interp.h" #include "srslte/phy/sync/pss.h" +#include "wiener_dl.h" typedef struct SRSLTE_API { cf_t* ce[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; @@ -79,6 +80,8 @@ typedef struct SRSLTE_API { srslte_refsignal_t csr_refs; srslte_refsignal_t** mbsfn_refs; + srslte_wiener_dl_t* wiener_dl; + cf_t* pilot_estimates; cf_t* pilot_estimates_average; cf_t* pilot_recv_signal; diff --git a/lib/src/phy/ch_estimation/chest_dl.c b/lib/src/phy/ch_estimation/chest_dl.c index 75dc9d90c..ace4af1f9 100644 --- a/lib/src/phy/ch_estimation/chest_dl.c +++ b/lib/src/phy/ch_estimation/chest_dl.c @@ -142,6 +142,14 @@ int srslte_chest_dl_init(srslte_chest_dl_t* q, uint32_t max_prb, uint32_t nof_rx goto clean_exit; } + q->wiener_dl = calloc(sizeof(srslte_wiener_dl_t), 1); + if (q->wiener_dl) { + srslte_wiener_dl_init(q->wiener_dl, max_prb, 2, nof_rx_antennas); + } else { + ERROR("Error allocating wiener filter\n"); + goto clean_exit; + } + q->nof_rx_antennas = nof_rx_antennas; } @@ -191,6 +199,10 @@ void srslte_chest_dl_free(srslte_chest_dl_t* q) if (q->pilot_recv_signal) { free(q->pilot_recv_signal); } + if (q->wiener_dl) { + srslte_wiener_dl_free(q->wiener_dl); + free(q->wiener_dl); + } bzero(q, sizeof(srslte_chest_dl_t)); } @@ -294,6 +306,11 @@ int srslte_chest_dl_set_cell(srslte_chest_dl_t* q, srslte_cell_t cell) fprintf(stderr, "Error initializing interpolator\n"); return SRSLTE_ERROR; } + + if (srslte_wiener_dl_set_cell(q->wiener_dl, cell)) { + fprintf(stderr, "Error initializing interpolator\n"); + return SRSLTE_ERROR; + } } ret = SRSLTE_SUCCESS; } @@ -628,6 +645,27 @@ static void chest_interpolate_noise_est(srslte_chest_dl_t* q, q->noise_estimate[rxant_id][port_id] = estimate_noise_pilots(q, sf, port_id); } + if (q->wiener_dl && ch_mode == SRSLTE_SF_NORM) { + uint32_t nre = q->cell.nof_prb * SRSLTE_NRE; + uint32_t nref = q->cell.nof_prb * 2; + uint32_t shift = srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0); + for (uint32_t m = 0, l = 0; m < 2 * SRSLTE_CP_NORM_NSYMB; m++) { + uint32_t k = srslte_refsignal_cs_nsymbol(l, q->cell.cp, 0); + srslte_wiener_dl_run(q->wiener_dl, + port_id, + rxant_id, + m, + shift, + &input[nref * l], + &ce[nre * m], + q->noise_estimate[rxant_id][port_id]); + + if (l == k) { + l++; + } + } + } + if (ce != NULL) { switch (cfg->filter_type) {