Fixed number of iterations calculation

master
Ismael Gomez 7 years ago
parent f15dbcdd7f
commit 680ba2761c

@ -335,9 +335,8 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error decoding UE DL\n");fflush(stdout); fprintf(stderr, "Error decoding UE DL\n");fflush(stdout);
return -1; return -1;
} else if (n == 0) { } else if (n == 0) {
printf("CFO: %+6.4f kHz, SFO: %+6.4f kHz, NOI: %.2f, PDCCH-Det: %.3f\r", printf("CFO: %+6.4f kHz, SFO: %+6.4f kHz, PDCCH-Det: %.3f\r",
srslte_ue_sync_get_cfo(&ue_sync)/1000, srslte_ue_sync_get_sfo(&ue_sync)/1000, srslte_ue_sync_get_cfo(&ue_sync)/1000, srslte_ue_sync_get_sfo(&ue_sync)/1000,
srslte_pdsch_average_noi(&ue_dl.pdsch),
(float) ue_dl.nof_detected/nof_trials); (float) ue_dl.nof_detected/nof_trials);
nof_trials++; nof_trials++;
} else { } else {

@ -58,6 +58,7 @@ typedef struct SRSLTE_API {
srslte_cell_t cell; srslte_cell_t cell;
uint32_t nof_rx_antennas; uint32_t nof_rx_antennas;
uint32_t last_nof_iterations[SRSLTE_MAX_CODEWORDS];
uint32_t max_re; uint32_t max_re;
@ -149,10 +150,12 @@ SRSLTE_API int srslte_pdsch_cn_compute(srslte_pdsch_t *q,
uint32_t nof_ce, uint32_t nof_ce,
float *cn); float *cn);
SRSLTE_API void srslte_pdsch_set_max_noi(srslte_pdsch_t *q, uint32_t max_iter); SRSLTE_API void srslte_pdsch_set_max_noi(srslte_pdsch_t *q,
uint32_t max_iter);
SRSLTE_API float srslte_pdsch_average_noi(srslte_pdsch_t *q); SRSLTE_API float srslte_pdsch_last_noi(srslte_pdsch_t *q);
SRSLTE_API uint32_t srslte_pdsch_last_noi(srslte_pdsch_t *q); SRSLTE_API uint32_t srslte_pdsch_last_noi_cw(srslte_pdsch_t *q,
uint32_t cw_idx);
#endif #endif

@ -58,7 +58,6 @@ typedef struct SRSLTE_API {
uint32_t max_iterations; uint32_t max_iterations;
uint32_t nof_iterations; uint32_t nof_iterations;
float average_nof_iterations;
/* buffers */ /* buffers */
uint8_t *cb_in; uint8_t *cb_in;
@ -87,8 +86,6 @@ SRSLTE_API void srslte_sch_free(srslte_sch_t *q);
SRSLTE_API void srslte_sch_set_max_noi(srslte_sch_t *q, SRSLTE_API void srslte_sch_set_max_noi(srslte_sch_t *q,
uint32_t max_iterations); uint32_t max_iterations);
SRSLTE_API float srslte_sch_average_noi(srslte_sch_t *q);
SRSLTE_API uint32_t srslte_sch_last_noi(srslte_sch_t *q); SRSLTE_API uint32_t srslte_sch_last_noi(srslte_sch_t *q);
SRSLTE_API int srslte_dlsch_encode(srslte_sch_t *q, SRSLTE_API int srslte_dlsch_encode(srslte_sch_t *q,

@ -29,15 +29,11 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <srslte/phy/phch/pdsch_cfg.h>
#include <srslte/phy/common/sequence.h>
#include <srslte/phy/phch/pdsch.h>
#include "prb_dl.h" #include "prb_dl.h"
#include "srslte/phy/phch/pdsch.h" #include "srslte/phy/phch/pdsch.h"
#include "srslte/phy/utils/debug.h" #include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/vector.h" #include "srslte/phy/utils/vector.h"
#include "srslte/phy/utils/bit.h"
#define MAX_PDSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12) #define MAX_PDSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12)
@ -606,6 +602,9 @@ static int srslte_pdsch_codeword_decode(srslte_pdsch_t *q, srslte_pdsch_cfg_t *c
/* Return */ /* Return */
ret = srslte_dlsch_decode2(&q->dl_sch, cfg, softbuffer, q->e[codeword_idx], data, codeword_idx); ret = srslte_dlsch_decode2(&q->dl_sch, cfg, softbuffer, q->e[codeword_idx], data, codeword_idx);
q->last_nof_iterations[codeword_idx] = srslte_sch_last_noi(&q->dl_sch);
if (ret == SRSLTE_SUCCESS) { if (ret == SRSLTE_SUCCESS) {
*ack = true; *ack = true;
} else if (ret == SRSLTE_ERROR) { } else if (ret == SRSLTE_ERROR) {
@ -828,14 +827,13 @@ void srslte_pdsch_set_max_noi(srslte_pdsch_t *q, uint32_t max_iter) {
srslte_sch_set_max_noi(&q->dl_sch, max_iter); srslte_sch_set_max_noi(&q->dl_sch, max_iter);
} }
float srslte_pdsch_average_noi(srslte_pdsch_t *q) { float srslte_pdsch_last_noi(srslte_pdsch_t *q) {
return q->dl_sch.average_nof_iterations; return srslte_pdsch_last_noi_cw(q, 0);
} }
uint32_t srslte_pdsch_last_noi(srslte_pdsch_t *q) { uint32_t srslte_pdsch_last_noi_cw(srslte_pdsch_t *q, uint32_t cw_idx) {
return q->dl_sch.nof_iterations; return q->last_nof_iterations[cw_idx];
} }

@ -472,11 +472,6 @@ int srslte_pmch_encode(srslte_pmch_t *q,
return ret; return ret;
} }
float srslte_pmch_average_noi(srslte_pmch_t *q)
{
return q->dl_sch.average_nof_iterations;
}
uint32_t srslte_pmch_last_noi(srslte_pmch_t *q) { uint32_t srslte_pmch_last_noi(srslte_pmch_t *q) {
return q->dl_sch.nof_iterations; return q->dl_sch.nof_iterations;
} }

@ -33,11 +33,6 @@
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>
#include "srslte/phy/phch/pdsch.h" #include "srslte/phy/phch/pdsch.h"
#include "srslte/phy/phch/pusch.h"
#include "srslte/phy/phch/sch.h"
#include "srslte/phy/phch/pmch.h"
#include "srslte/phy/phch/uci.h"
#include "srslte/phy/common/phy_common.h"
#include "srslte/phy/utils/bit.h" #include "srslte/phy/utils/bit.h"
#include "srslte/phy/utils/debug.h" #include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/vector.h" #include "srslte/phy/utils/vector.h"
@ -174,15 +169,10 @@ void srslte_sch_set_max_noi(srslte_sch_t *q, uint32_t max_iterations) {
q->max_iterations = max_iterations; q->max_iterations = max_iterations;
} }
float srslte_sch_average_noi(srslte_sch_t *q) {
return q->average_nof_iterations;
}
uint32_t srslte_sch_last_noi(srslte_sch_t *q) { uint32_t srslte_sch_last_noi(srslte_sch_t *q) {
return q->nof_iterations; return q->nof_iterations;
} }
/* Encode a transport block according to 36.212 5.3.2 /* Encode a transport block according to 36.212 5.3.2
* *
*/ */
@ -340,7 +330,7 @@ bool decode_tb_cb(srslte_sch_t *q,
for (int i=0;i<SRSLTE_TDEC_NPAR;i++) { for (int i=0;i<SRSLTE_TDEC_NPAR;i++) {
cb_idx[i] = i+first_cb; cb_idx[i] = i+first_cb;
decoder_input[i] = false; decoder_input[i] = NULL;
} }
for (int i=0;i<nof_cb;i++) { for (int i=0;i<nof_cb;i++) {
@ -351,6 +341,8 @@ bool decode_tb_cb(srslte_sch_t *q,
uint32_t remaining_cb = nof_cb; uint32_t remaining_cb = nof_cb;
q->nof_iterations = 0;
while(remaining_cb>0) { while(remaining_cb>0) {
// Unratematch the codeblocks left to decode // Unratematch the codeblocks left to decode
@ -384,11 +376,9 @@ bool decode_tb_cb(srslte_sch_t *q,
} }
} }
// Run 1 iteration for up to TDEC_NPAR codeblocks // Run 1 iteration for the codeblocks in queue
srslte_tdec_iteration_par(&q->decoder, decoder_input, cb_len); srslte_tdec_iteration_par(&q->decoder, decoder_input, cb_len);
q->nof_iterations = srslte_tdec_get_nof_iterations_cb(&q->decoder, 0);
// Decide output bits and compute CRC // Decide output bits and compute CRC
for (int i=0;i<SRSLTE_TDEC_NPAR;i++) { for (int i=0;i<SRSLTE_TDEC_NPAR;i++) {
if (decoder_input[i]) { if (decoder_input[i]) {
@ -410,6 +400,8 @@ bool decode_tb_cb(srslte_sch_t *q,
memcpy(&data[(cb_idx[i]*rlen)/8], q->cb_in, rlen/8 * sizeof(uint8_t)); memcpy(&data[(cb_idx[i]*rlen)/8], q->cb_in, rlen/8 * sizeof(uint8_t));
q->nof_iterations += srslte_tdec_get_nof_iterations_cb(&q->decoder, i);
// Reset number of iterations for that CB in the decoder // Reset number of iterations for that CB in the decoder
srslte_tdec_reset_cb(&q->decoder, i); srslte_tdec_reset_cb(&q->decoder, i);
remaining_cb--; remaining_cb--;
@ -421,12 +413,16 @@ bool decode_tb_cb(srslte_sch_t *q,
} else if (srslte_tdec_get_nof_iterations_cb(&q->decoder, i) >= q->max_iterations) { } else if (srslte_tdec_get_nof_iterations_cb(&q->decoder, i) >= q->max_iterations) {
INFO("CB %d: Error. CB is erroneous. remaining_cb=%d, i=%d, first_cb=%d, nof_cb=%d\n", INFO("CB %d: Error. CB is erroneous. remaining_cb=%d, i=%d, first_cb=%d, nof_cb=%d\n",
cb_idx[i], remaining_cb, i, first_cb, nof_cb); cb_idx[i], remaining_cb, i, first_cb, nof_cb);
q->nof_iterations += q->max_iterations;
q->nof_iterations /= (nof_cb-remaining_cb+1);
return false; return false;
} }
} }
} }
} }
q->nof_iterations /= nof_cb;
return true; return true;
} }

Loading…
Cancel
Save