Fixed number of iterations calculation

master
Ismael Gomez 7 years ago
parent f15dbcdd7f
commit 680ba2761c

@ -335,10 +335,9 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error decoding UE DL\n");fflush(stdout);
return -1;
} 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_pdsch_average_noi(&ue_dl.pdsch),
(float) ue_dl.nof_detected/nof_trials);
(float) ue_dl.nof_detected/nof_trials);
nof_trials++;
} else {
printf("Decoded SIB1. Payload: ");

@ -58,7 +58,8 @@ typedef struct SRSLTE_API {
srslte_cell_t cell;
uint32_t nof_rx_antennas;
uint32_t last_nof_iterations[SRSLTE_MAX_CODEWORDS];
uint32_t max_re;
uint16_t ue_rnti;
@ -149,10 +150,12 @@ SRSLTE_API int srslte_pdsch_cn_compute(srslte_pdsch_t *q,
uint32_t nof_ce,
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

@ -56,10 +56,9 @@
/* DL-SCH AND UL-SCH common functions */
typedef struct SRSLTE_API {
uint32_t max_iterations;
uint32_t nof_iterations;
float average_nof_iterations;
uint32_t max_iterations;
uint32_t nof_iterations;
/* buffers */
uint8_t *cb_in;
uint8_t *parity_bits;
@ -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,
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 int srslte_dlsch_encode(srslte_sch_t *q,

@ -29,15 +29,11 @@
#include <string.h>
#include <stdlib.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 "srslte/phy/phch/pdsch.h"
#include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/vector.h"
#include "srslte/phy/utils/bit.h"
#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 */
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) {
*ack = true;
} 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);
}
float srslte_pdsch_average_noi(srslte_pdsch_t *q) {
return q->dl_sch.average_nof_iterations;
float srslte_pdsch_last_noi(srslte_pdsch_t *q) {
return srslte_pdsch_last_noi_cw(q, 0);
}
uint32_t srslte_pdsch_last_noi(srslte_pdsch_t *q) {
return q->dl_sch.nof_iterations;
uint32_t srslte_pdsch_last_noi_cw(srslte_pdsch_t *q, uint32_t cw_idx) {
return q->last_nof_iterations[cw_idx];
}

@ -472,11 +472,6 @@ int srslte_pmch_encode(srslte_pmch_t *q,
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) {
return q->dl_sch.nof_iterations;
}

@ -33,11 +33,6 @@
#include <assert.h>
#include <math.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/debug.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;
}
float srslte_sch_average_noi(srslte_sch_t *q) {
return q->average_nof_iterations;
}
uint32_t srslte_sch_last_noi(srslte_sch_t *q) {
return q->nof_iterations;
}
/* 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++) {
cb_idx[i] = i+first_cb;
decoder_input[i] = false;
decoder_input[i] = NULL;
}
for (int i=0;i<nof_cb;i++) {
@ -349,8 +339,10 @@ bool decode_tb_cb(srslte_sch_t *q,
srslte_tdec_reset(&q->decoder, cb_len);
uint32_t remaining_cb = nof_cb;
uint32_t remaining_cb = nof_cb;
q->nof_iterations = 0;
while(remaining_cb>0) {
// 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);
q->nof_iterations = srslte_tdec_get_nof_iterations_cb(&q->decoder, 0);
// Decide output bits and compute CRC
for (int i=0;i<SRSLTE_TDEC_NPAR;i++) {
if (decoder_input[i]) {
@ -409,24 +399,30 @@ bool decode_tb_cb(srslte_sch_t *q,
if (!srslte_crc_checksum_byte(crc_ptr, q->cb_in, len_crc)) {
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
srslte_tdec_reset_cb(&q->decoder, i);
remaining_cb--;
decoder_input[i] = NULL;
cb_idx[i] = 0;
// CRC is error and exceeded maximum iterations for this CB.
// CRC is error and exceeded maximum iterations for this CB.
// Early stop the whole transport block.
} 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",
cb_idx[i], remaining_cb, i, first_cb, nof_cb);
return false;
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;
}
}
}
}
q->nof_iterations /= nof_cb;
return true;
}

Loading…
Cancel
Save