From 0396ebae1773e6c4ca2f72baf31e5d4bd24d55fe Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Thu, 12 Nov 2020 12:48:00 +0100 Subject: [PATCH] Fix UE/ENB DL NR --- lib/src/phy/ch_estimation/dmrs_pdsch.c | 2 +- lib/src/phy/phch/pdsch_nr.c | 24 ++++++++++++++++++------ lib/src/phy/phch/test/CMakeLists.txt | 2 +- lib/src/phy/phch/test/dlsch_nr_test.c | 8 ++++---- lib/src/phy/ue/ue_dl_nr.c | 11 +---------- lib/test/phy/CMakeLists.txt | 2 +- 6 files changed, 26 insertions(+), 23 deletions(-) diff --git a/lib/src/phy/ch_estimation/dmrs_pdsch.c b/lib/src/phy/ch_estimation/dmrs_pdsch.c index 87c13dd3e..00c9de8eb 100644 --- a/lib/src/phy/ch_estimation/dmrs_pdsch.c +++ b/lib/src/phy/ch_estimation/dmrs_pdsch.c @@ -725,7 +725,7 @@ int srslte_dmrs_pdsch_estimate(srslte_dmrs_pdsch_t* q, // Time domain hold, extract resource elements estimates for PDSCH uint32_t symbol_idx = 0; uint32_t count = 0; - for (uint32_t l = grant->S; l < grant->L; l++) { + for (uint32_t l = grant->S; l < grant->S + grant->L; l++) { while (symbols[symbol_idx] < l && symbol_idx < nof_symbols) { symbol_idx++; } diff --git a/lib/src/phy/phch/pdsch_nr.c b/lib/src/phy/phch/pdsch_nr.c index 2a897e869..058a93dd2 100644 --- a/lib/src/phy/phch/pdsch_nr.c +++ b/lib/src/phy/phch/pdsch_nr.c @@ -119,7 +119,7 @@ int srslte_pdsch_nr_set_carrier(srslte_pdsch_nr_t* q, for (uint32_t i = 0; i < max_cw; i++) { if (q->b[i] == NULL) { - q->b[i] = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_LEN_RE_NR); + q->b[i] = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); if (q->b[i] == NULL) { ERROR("Malloc"); return SRSLTE_ERROR; @@ -210,9 +210,9 @@ static uint32_t srslte_pdsch_nr_cp_dmrs_type1(const srslte_pdsch_nr_t* q, if (grant->prb_idx[i]) { for (uint32_t j = 0; j < SRSLTE_NRE; j += 2) { if (put) { - sf_symbols[i * SRSLTE_NRE + delta + j] = symbols[count++]; + sf_symbols[i * SRSLTE_NRE + delta + j + 1] = symbols[count++]; } else { - symbols[count++] = sf_symbols[i * SRSLTE_NRE + delta + j]; + symbols[count++] = sf_symbols[i * SRSLTE_NRE + delta + j + 1]; } } } @@ -562,20 +562,32 @@ int srslte_pdsch_nr_decode(srslte_pdsch_nr_t* q, uint32_t nof_re = srslte_ra_dl_nr_slot_nof_re(cfg, grant); + if (channel->nof_re != nof_re) { + ERROR("Inconsistent number of RE (%d!=%d)\n", channel->nof_re, nof_re); + return SRSLTE_ERROR; + } + // Demapping from virtual to physical resource blocks - cf_t** x = (grant->nof_layers > 1) ? q->x : q->d; - uint32_t nof_re_get = srslte_pdsch_nr_get(q, cfg, grant, x[0], sf_symbols[0]); + uint32_t nof_re_get = srslte_pdsch_nr_get(q, cfg, grant, q->x[0], sf_symbols[0]); if (nof_re_get != nof_re) { ERROR("Inconsistent number of RE (%d!=%d)\n", nof_re_get, nof_re); return SRSLTE_ERROR; } + if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + INFO("ce="); + srslte_vec_fprint_c(stdout, channel->ce[0][0], nof_re); + INFO("x="); + srslte_vec_fprint_c(stdout, q->x[0], nof_re); + } + // Demapping to virtual resource blocks // ... Not implemented // Antenna port demapping // ... Not implemented - srslte_predecoding_single(x[0], channel->ce[0][0], x[0], NULL, nof_re, 1.0f, channel->noise_estimate); + srslte_predecoding_type( + q->x, channel->ce, q->d, NULL, 1, 1, 1, 0, nof_re, SRSLTE_TXSCHEME_PORT0, 1.0f, channel->noise_estimate); // Layer demapping if (grant->nof_layers > 1) { diff --git a/lib/src/phy/phch/test/CMakeLists.txt b/lib/src/phy/phch/test/CMakeLists.txt index 18d6c3ce0..e2e7af349 100644 --- a/lib/src/phy/phch/test/CMakeLists.txt +++ b/lib/src/phy/phch/test/CMakeLists.txt @@ -628,4 +628,4 @@ add_test(dlsch_nr_test dlsch_nr_test -m 0 -n 1) add_executable(pdsch_nr_test pdsch_nr_test.c) target_link_libraries(pdsch_nr_test srslte_phy) -add_test(pdsch_nr_test pdsch_nr_test -n 6 -m 20) +add_test(pdsch_nr_test pdsch_nr_test -p 6 -m 20) diff --git a/lib/src/phy/phch/test/dlsch_nr_test.c b/lib/src/phy/phch/test/dlsch_nr_test.c index b41b04324..a50d77609 100644 --- a/lib/src/phy/phch/test/dlsch_nr_test.c +++ b/lib/src/phy/phch/test/dlsch_nr_test.c @@ -103,14 +103,14 @@ int main(int argc, char** argv) goto clean_exit; } - if (srslte_sch_nr_init_tx(&sch_nr_tx) < SRSLTE_SUCCESS) { + srslte_sch_nr_args_t args = {}; + args.disable_simd = false; + if (srslte_sch_nr_init_tx(&sch_nr_tx, &args) < SRSLTE_SUCCESS) { ERROR("Error initiating SCH NR for Tx\n"); goto clean_exit; } - srslte_sch_nr_args_t decoder_cfg = {}; - decoder_cfg.disable_simd = false; - if (srslte_sch_nr_init_rx(&sch_nr_rx, &decoder_cfg) < SRSLTE_SUCCESS) { + if (srslte_sch_nr_init_rx(&sch_nr_rx, &args) < SRSLTE_SUCCESS) { ERROR("Error initiating SCH NR for Rx\n"); goto clean_exit; } diff --git a/lib/src/phy/ue/ue_dl_nr.c b/lib/src/phy/ue/ue_dl_nr.c index b1ec2de38..a8607ffcc 100644 --- a/lib/src/phy/ue/ue_dl_nr.c +++ b/lib/src/phy/ue/ue_dl_nr.c @@ -158,18 +158,9 @@ int srslte_ue_dl_nr_pdsch_get(srslte_ue_dl_nr_t* q, return SRSLTE_ERROR; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { - printf("ce[0][0]="); - srslte_vec_fprint_c(stdout, q->chest.ce[0][0], q->chest.nof_re); - } - - for (uint32_t i = 0; i < grant->tb->nof_re; i++) { - q->chest.ce[0][0][i] = (1536); - } - if (srslte_pdsch_nr_decode(&q->pdsch, cfg, grant, &q->chest, q->sf_symbols, res) < SRSLTE_SUCCESS) { return SRSLTE_ERROR; } return SRSLTE_SUCCESS; -} \ No newline at end of file +} diff --git a/lib/test/phy/CMakeLists.txt b/lib/test/phy/CMakeLists.txt index 2c0d725f5..d3b35554e 100644 --- a/lib/test/phy/CMakeLists.txt +++ b/lib/test/phy/CMakeLists.txt @@ -64,4 +64,4 @@ set_tests_properties(pucch_ca_test PROPERTIES LABELS "long;phy") add_executable(phy_dl_nr_test phy_dl_nr_test.c) target_link_libraries(phy_dl_nr_test srslte_phy srslte_common srslte_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) -add_test(phy_dl_nr_test phy_dl_nr_test) \ No newline at end of file +add_test(phy_dl_nr_test phy_dl_nr_test -p 100 -m 28) \ No newline at end of file