From 19bc98081a1c505679e3626f807985d023e0a33d Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Tue, 25 Jul 2017 15:35:25 +0200 Subject: [PATCH] PDSCH decoder multi has been modified for future parallel decoding of codewords. --- lib/include/srslte/phy/phch/sch.h | 9 ++++--- lib/src/phy/phch/pdsch.c | 45 ++++++++++++++++--------------- lib/src/phy/phch/sch.c | 19 +++++++------ 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/lib/include/srslte/phy/phch/sch.h b/lib/include/srslte/phy/phch/sch.h index 0e59ecbc9..128cfea6f 100644 --- a/lib/include/srslte/phy/phch/sch.h +++ b/lib/include/srslte/phy/phch/sch.h @@ -108,11 +108,12 @@ SRSLTE_API int srslte_dlsch_decode(srslte_sch_t *q, int16_t *e_bits, uint8_t *data); -SRSLTE_API int srslte_dlsch_decode_multi(srslte_sch_t *q, +SRSLTE_API int srslte_dlsch_decode2(srslte_sch_t *q, srslte_pdsch_cfg_t *cfg, - srslte_softbuffer_rx_t softbuffers[SRSLTE_MAX_CODEWORDS], - int16_t *e_bits[SRSLTE_MAX_CODEWORDS], - uint8_t *data[SRSLTE_MAX_CODEWORDS]); + srslte_softbuffer_rx_t *softbuffer, + int16_t *e_bits, + uint8_t *data, + int codeword_idx); SRSLTE_API int srslte_ulsch_encode(srslte_sch_t *q, srslte_pusch_cfg_t *cfg, diff --git a/lib/src/phy/phch/pdsch.c b/lib/src/phy/phch/pdsch.c index 3d24cf175..5d85a3ec2 100644 --- a/lib/src/phy/phch/pdsch.c +++ b/lib/src/phy/phch/pdsch.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include "prb_dl.h" #include "srslte/phy/phch/pdsch.h" @@ -488,7 +490,8 @@ int srslte_pdsch_decode_multi(srslte_pdsch_t *q, /* Set pointers for layermapping & precoding */ uint32_t i, n; cf_t *x[SRSLTE_MAX_LAYERS]; - + int ret = 0; + if (q != NULL && sf_symbols != NULL && data != NULL && @@ -564,26 +567,14 @@ int srslte_pdsch_decode_multi(srslte_pdsch_t *q, * The MAX-log-MAP algorithm used in turbo decoding is unsensitive to SNR estimation, * thus we don't need tot set it in the LLRs normalization */ - if (cfg->nbits.nof_re) { + if (cfg->nbits.nof_bits) { + INFO("Decoding CW 0 (%d bits)\n", cfg->nbits.nof_bits); srslte_demod_soft_demodulate_s(cfg->grant.mcs.mod, q->d, q->e, cfg->nbits.nof_re); - } - - if (cfg->nbits2.nof_re) { - srslte_demod_soft_demodulate_s(cfg->grant.mcs2.mod, q->d2, q->e2, cfg->nbits2.nof_re); - } - /* descramble */ - if (q->users[rnti] && q->users[rnti]->sequence_generated) { - if (cfg->nbits.nof_bits) { + if (q->users[rnti] && q->users[rnti]->sequence_generated) { srslte_scrambling_s_offset(&q->users[rnti]->seq[cfg->sf_idx], q->e, 0, cfg->nbits.nof_bits); - } - - if (cfg->nbits2.nof_bits) { - srslte_scrambling_s_offset(&q->users[rnti]->seq2[cfg->sf_idx], q->e2, 0, cfg->nbits2.nof_bits); - } - } else { - srslte_sequence_t seq; - if (cfg->nbits.nof_bits) { + } else { + srslte_sequence_t seq; if (srslte_sequence_pdsch(&seq, rnti, 0, 2 * cfg->sf_idx, q->cell.id, cfg->nbits.nof_bits)) { return SRSLTE_ERROR; } @@ -591,22 +582,34 @@ int srslte_pdsch_decode_multi(srslte_pdsch_t *q, srslte_sequence_free(&seq); } - if (cfg->nbits2.nof_bits) { + ret |= srslte_dlsch_decode2(&q->dl_sch, cfg, &softbuffers[0], q->e, data[0], 0); + } + + if (cfg->nbits2.nof_bits) { + INFO("Decoding CW 1 (%d bits)\n", cfg->nbits2.nof_bits); + srslte_demod_soft_demodulate_s(cfg->grant.mcs2.mod, q->d2, q->e2, cfg->nbits2.nof_re); + + if (q->users[rnti] && q->users[rnti]->sequence_generated) { + srslte_scrambling_s_offset(&q->users[rnti]->seq2[cfg->sf_idx], q->e2, 0, cfg->nbits2.nof_bits); + } else { + srslte_sequence_t seq; if (srslte_sequence_pdsch(&seq, rnti, 1, 2 * cfg->sf_idx, q->cell.id, cfg->nbits2.nof_bits)) { return SRSLTE_ERROR; } srslte_scrambling_s_offset(&seq, q->e2, 0, cfg->nbits2.nof_bits); srslte_sequence_free(&seq); } + + ret |= srslte_dlsch_decode2(&q->dl_sch, cfg, &softbuffers[1], q->e2, data[1], 1); } + if (SRSLTE_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE llr.dat: LLR estimates after demodulation and descrambling\n",0); srslte_vec_save_file("llr.dat", q->e, cfg->nbits.nof_bits*sizeof(int16_t)); } - return srslte_dlsch_decode_multi(&q->dl_sch, cfg, softbuffers, (int16_t *[SRSLTE_MAX_CODEWORDS]) {q->e, q->e2}, - data); + return ret; } else { return SRSLTE_ERROR_INVALID_INPUTS; diff --git a/lib/src/phy/phch/sch.c b/lib/src/phy/phch/sch.c index f0515227e..1caacacc9 100644 --- a/lib/src/phy/phch/sch.c +++ b/lib/src/phy/phch/sch.c @@ -524,29 +524,28 @@ int srslte_dlsch_decode(srslte_sch_t *q, srslte_pdsch_cfg_t *cfg, srslte_softbuf } -int srslte_dlsch_decode_multi(srslte_sch_t *q, srslte_pdsch_cfg_t *cfg, srslte_softbuffer_rx_t softbuffers[SRSLTE_MAX_CODEWORDS], - int16_t *e_bits[SRSLTE_MAX_CODEWORDS], uint8_t *data[SRSLTE_MAX_CODEWORDS]) +int srslte_dlsch_decode2(srslte_sch_t *q, srslte_pdsch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer, + int16_t *e_bits, uint8_t *data, int codeword_idx) { - int ret = SRSLTE_SUCCESS; uint32_t Nl = 1; if (cfg->nof_layers != cfg->grant.nof_tb) { Nl = 2; } - if (cfg->nbits.nof_bits) { - ret |= decode_tb(q, &softbuffers[0], &cfg->cb_segm, + if (codeword_idx == 0) { + return decode_tb(q, softbuffer, &cfg->cb_segm, cfg->grant.Qm*Nl, cfg->rv, cfg->nbits.nof_bits, - e_bits[0], data[0]); + e_bits, data); } - if (cfg->nbits2.nof_bits) { - ret |= decode_tb(q, &softbuffers[1], &cfg->cb_segm2, + if (codeword_idx == 1) { + return decode_tb(q, softbuffer, &cfg->cb_segm2, cfg->grant.Qm2*Nl, cfg->rv2, cfg->nbits2.nof_bits, - e_bits[1], data[1]); + e_bits, data); } - return ret; + return SRSLTE_ERROR; } /**