cleaned up cfo set tolerance functions

master
Ismael Gomez 7 years ago
parent 7b854476a2
commit 41188b409e

@ -585,6 +585,10 @@ int main(int argc, char **argv) {
/* If a new line is detected set verbose level to Debug */ /* If a new line is detected set verbose level to Debug */
if (fgets(input, sizeof(input), stdin)) { if (fgets(input, sizeof(input), stdin)) {
srslte_verbose = SRSLTE_VERBOSE_DEBUG; srslte_verbose = SRSLTE_VERBOSE_DEBUG;
ue_dl.pkt_errors = 0;
ue_dl.pkts_total = 0;
ue_dl.nof_detected = 0;
nof_trials = 0;
} }
} }
@ -778,10 +782,12 @@ int main(int argc, char **argv) {
if (sfn == 1024) { if (sfn == 1024) {
sfn = 0; sfn = 0;
PRINT_LINE_ADVANCE_CURSOR(); PRINT_LINE_ADVANCE_CURSOR();
/*
ue_dl.pkt_errors = 0; ue_dl.pkt_errors = 0;
ue_dl.pkts_total = 0; ue_dl.pkts_total = 0;
ue_dl.nof_detected = 0; ue_dl.nof_detected = 0;
nof_trials = 0; nof_trials = 0;
*/
} }
} }

@ -87,6 +87,7 @@ typedef struct SRSLTE_API {
uint32_t cp_len; uint32_t cp_len;
srslte_cfo_t cfocorr; srslte_cfo_t cfocorr;
srslte_cfo_t cfocorr2; srslte_cfo_t cfocorr2;
float current_cfo_tol;
sss_alg_t sss_alg; sss_alg_t sss_alg;
bool detect_cp; bool detect_cp;
bool sss_en; bool sss_en;
@ -147,6 +148,9 @@ SRSLTE_API srslte_cp_t srslte_sync_detect_cp(srslte_sync_t *q,
SRSLTE_API void srslte_sync_set_threshold(srslte_sync_t *q, SRSLTE_API void srslte_sync_set_threshold(srslte_sync_t *q,
float threshold); float threshold);
SRSLTE_API void srslte_sync_set_cfo_tol(srslte_sync_t *q,
float tol);
/* Gets the subframe idx (0 or 5) */ /* Gets the subframe idx (0 or 5) */
SRSLTE_API uint32_t srslte_sync_get_sf_idx(srslte_sync_t *q); SRSLTE_API uint32_t srslte_sync_get_sf_idx(srslte_sync_t *q);

@ -181,6 +181,9 @@ SRSLTE_API int srslte_ue_sync_zerocopy(srslte_ue_sync_t *q,
SRSLTE_API int srslte_ue_sync_zerocopy_multi(srslte_ue_sync_t *q, SRSLTE_API int srslte_ue_sync_zerocopy_multi(srslte_ue_sync_t *q,
cf_t *input_buffer[SRSLTE_MAX_PORTS]); cf_t *input_buffer[SRSLTE_MAX_PORTS]);
SRSLTE_API void srslte_ue_sync_set_cfo_tol(srslte_ue_sync_t *q,
float tol);
SRSLTE_API void srslte_ue_sync_set_cfo(srslte_ue_sync_t *q, SRSLTE_API void srslte_ue_sync_set_cfo(srslte_ue_sync_t *q,
float cfo); float cfo);

@ -76,6 +76,7 @@ typedef struct SRSLTE_API {
bool normalize_en; bool normalize_en;
bool cfo_en; bool cfo_en;
float current_cfo_tol;
float current_cfo; float current_cfo;
srslte_pucch_format_t last_pucch_format; srslte_pucch_format_t last_pucch_format;
@ -114,6 +115,9 @@ SRSLTE_API void srslte_ue_ul_free(srslte_ue_ul_t *q);
SRSLTE_API int srslte_ue_ul_set_cell(srslte_ue_ul_t *q, SRSLTE_API int srslte_ue_ul_set_cell(srslte_ue_ul_t *q,
srslte_cell_t cell); srslte_cell_t cell);
SRSLTE_API void srslte_ue_ul_set_cfo_tol(srslte_ue_ul_t *q,
float tol);
SRSLTE_API void srslte_ue_ul_set_cfo(srslte_ue_ul_t *q, SRSLTE_API void srslte_ue_ul_set_cfo(srslte_ue_ul_t *q,
float cur_cfo); float cur_cfo);

@ -30,6 +30,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <complex.h> #include <complex.h>
#include <math.h> #include <math.h>
#include <srslte/phy/sync/pss.h>
#include "srslte/phy/sync/pss.h" #include "srslte/phy/sync/pss.h"
#include "srslte/phy/dft/dft.h" #include "srslte/phy/dft/dft.h"
@ -95,8 +96,8 @@ int srslte_pss_synch_init_fft_offset(srslte_pss_synch_t *q, uint32_t frame_size,
*/ */
int srslte_pss_synch_init_fft_offset_decim(srslte_pss_synch_t *q, int srslte_pss_synch_init_fft_offset_decim(srslte_pss_synch_t *q,
uint32_t max_frame_size, uint32_t max_fft_size, uint32_t max_frame_size, uint32_t max_fft_size,
int offset, int decimate) { int offset, int decimate)
{
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL) { if (q != NULL) {
@ -183,16 +184,15 @@ int srslte_pss_synch_init_fft_offset_decim(srslte_pss_synch_t *q,
#ifdef CONVOLUTION_FFT #ifdef CONVOLUTION_FFT
for(N_id_2 = 0; N_id_2<3; N_id_2++) for(N_id_2=0; N_id_2<3; N_id_2++)
q->pss_signal_freq_full[N_id_2] = srslte_vec_malloc(buffer_size * sizeof(cf_t)); q->pss_signal_freq_full[N_id_2] = srslte_vec_malloc(buffer_size * sizeof(cf_t));
if (srslte_conv_fft_cc_init(&q->conv_fft, frame_size, fft_size)) { if (srslte_conv_fft_cc_init(&q->conv_fft, frame_size, fft_size)) {
fprintf(stderr, "Error initiating convolution FFT\n"); fprintf(stderr, "Error initiating convolution FFT\n");
goto clean_and_exit; goto clean_and_exit;
} }
for(int i =0; i< 3; i++) for(int i=0; i<3; i++) {
{ srslte_dft_run_c(&q->conv_fft.filter_plan, q->pss_signal_time[i], q->pss_signal_freq_full[i]);
srslte_dft_run_c(&q->conv_fft.filter_plan, q->pss_signal_time[i], q->pss_signal_freq_full[i]);
} }
#endif #endif

@ -38,9 +38,11 @@
#include "srslte/phy/sync/cfo.h" #include "srslte/phy/sync/cfo.h"
#define MEANPEAK_EMA_ALPHA 0.1 #define MEANPEAK_EMA_ALPHA 0.1
#define CFO_EMA_ALPHA 0.2 #define CFO_EMA_ALPHA 0.1
#define CP_EMA_ALPHA 0.1 #define CP_EMA_ALPHA 0.1
#define DEFAULT_CFO_TOL 50.0 // Hz
static bool fft_size_isvalid(uint32_t fft_size) { static bool fft_size_isvalid(uint32_t fft_size) {
if (fft_size >= SRSLTE_SYNC_FFT_SZ_MIN && fft_size <= SRSLTE_SYNC_FFT_SZ_MAX && (fft_size%64) == 0) { if (fft_size >= SRSLTE_SYNC_FFT_SZ_MIN && fft_size <= SRSLTE_SYNC_FFT_SZ_MAX && (fft_size%64) == 0) {
return true; return true;
@ -94,9 +96,8 @@ int srslte_sync_init_decim(srslte_sync_t *q, uint32_t frame_size, uint32_t max_o
goto clean_exit; goto clean_exit;
} }
// Set a CFO tolerance of approx 50 Hz // Set default CFO tolerance
srslte_cfo_set_tol(&q->cfocorr, 50.0/(15000.0*q->fft_size)); srslte_sync_set_cfo_tol(q, DEFAULT_CFO_TOL);
srslte_cfo_set_tol(&q->cfocorr2, 50.0/(15000.0*q->fft_size));
for (int i=0;i<2;i++) { for (int i=0;i<2;i++) {
q->cfo_i_corr[i] = srslte_vec_malloc(sizeof(cf_t)*q->frame_size); q->cfo_i_corr[i] = srslte_vec_malloc(sizeof(cf_t)*q->frame_size);
@ -114,10 +115,11 @@ int srslte_sync_init_decim(srslte_sync_t *q, uint32_t frame_size, uint32_t max_o
srslte_sync_set_cp(q, SRSLTE_CP_NORM); srslte_sync_set_cp(q, SRSLTE_CP_NORM);
q->decimate = decimate; q->decimate = decimate;
if(!decimate) if(!decimate) {
decimate = 1; decimate = 1;
}
if (srslte_pss_synch_init_fft_offset_decim(&q->pss, max_offset, fft_size,0,decimate)) { if (srslte_pss_synch_init_fft_offset_decim(&q->pss, max_offset, fft_size, 0, decimate)) {
fprintf(stderr, "Error initializing PSS object\n"); fprintf(stderr, "Error initializing PSS object\n");
goto clean_exit; goto clean_exit;
} }
@ -220,9 +222,7 @@ int srslte_sync_resize(srslte_sync_t *q, uint32_t frame_size, uint32_t max_offse
} }
// Update CFO tolerance // Update CFO tolerance
srslte_cfo_set_tol(&q->cfocorr, 50.0/(15000.0*q->fft_size)); srslte_sync_set_cfo_tol(q, q->current_cfo_tol);
srslte_cfo_set_tol(&q->cfocorr2, 50.0/(15000.0*q->fft_size));
DEBUG("SYNC init with frame_size=%d, max_offset=%d and fft_size=%d\n", frame_size, max_offset, fft_size); DEBUG("SYNC init with frame_size=%d, max_offset=%d and fft_size=%d\n", frame_size, max_offset, fft_size);
@ -234,6 +234,11 @@ int srslte_sync_resize(srslte_sync_t *q, uint32_t frame_size, uint32_t max_offse
return ret; return ret;
} }
void srslte_sync_set_cfo_tol(srslte_sync_t *q, float tol) {
q->current_cfo_tol = tol;
srslte_cfo_set_tol(&q->cfocorr, tol/(15000.0*q->fft_size));
srslte_cfo_set_tol(&q->cfocorr2, tol/(15000.0*q->fft_size));
}
void srslte_sync_set_threshold(srslte_sync_t *q, float threshold) { void srslte_sync_set_threshold(srslte_sync_t *q, float threshold) {
q->threshold = threshold; q->threshold = threshold;

@ -380,6 +380,8 @@ void srslte_ue_sync_set_cfo(srslte_ue_sync_t *q, float cfo) {
srslte_sync_set_cfo(&q->strack, cfo/15000); srslte_sync_set_cfo(&q->strack, cfo/15000);
} }
void srslte_ue_sync_set_cfo_tol(srslte_ue_sync_t *q, float cfo_tol) {}
float srslte_ue_sync_get_sfo(srslte_ue_sync_t *q) { float srslte_ue_sync_get_sfo(srslte_ue_sync_t *q) {
return q->mean_sfo/5e-3; return q->mean_sfo/5e-3;
} }

@ -38,6 +38,8 @@
#define MAX_SFLEN SRSLTE_SF_LEN(srslte_symbol_sz(max_prb)) #define MAX_SFLEN SRSLTE_SF_LEN(srslte_symbol_sz(max_prb))
#define DEFAULT_CFO_TOL 50.0 // Hz
int srslte_ue_ul_init(srslte_ue_ul_t *q, int srslte_ue_ul_init(srslte_ue_ul_t *q,
uint32_t max_prb) uint32_t max_prb)
{ {
@ -63,7 +65,7 @@ int srslte_ue_ul_init(srslte_ue_ul_t *q,
goto clean_exit; goto clean_exit;
} }
srslte_cfo_set_tol(&q->cfo, 0); srslte_ue_ul_set_cfo_tol(q, DEFAULT_CFO_TOL);
if (srslte_pusch_init_ue(&q->pusch, max_prb)) { if (srslte_pusch_init_ue(&q->pusch, max_prb)) {
fprintf(stderr, "Error creating PUSCH object\n"); fprintf(stderr, "Error creating PUSCH object\n");
@ -155,7 +157,9 @@ int srslte_ue_ul_set_cell(srslte_ue_ul_t *q,
fprintf(stderr, "Error resizing CFO object\n"); fprintf(stderr, "Error resizing CFO object\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_cfo_set_tol(&q->cfo, 50.0/(15000.0*srslte_symbol_sz(q->cell.nof_prb)));
srslte_ue_ul_set_cfo_tol(q, q->current_cfo_tol);
if (srslte_pusch_set_cell(&q->pusch, q->cell)) { if (srslte_pusch_set_cell(&q->pusch, q->cell)) {
fprintf(stderr, "Error resizing PUSCH object\n"); fprintf(stderr, "Error resizing PUSCH object\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
@ -178,6 +182,10 @@ int srslte_ue_ul_set_cell(srslte_ue_ul_t *q,
return ret; return ret;
} }
void srslte_ue_ul_set_cfo_tol(srslte_ue_ul_t *q, float tol) {
q->current_cfo_tol = tol;
srslte_cfo_set_tol(&q->cfo, tol/(15000.0*srslte_symbol_sz(q->cell.nof_prb)));
}
void srslte_ue_ul_set_cfo(srslte_ue_ul_t *q, float cur_cfo) { void srslte_ue_ul_set_cfo(srslte_ue_ul_t *q, float cur_cfo) {
q->current_cfo = cur_cfo; q->current_cfo = cur_cfo;

@ -545,11 +545,12 @@ int phch_worker::decode_pdsch(srslte_ra_dl_grant_t *grant, uint8_t *payload[SRSL
snprintf(timestr, 64, ", dec_time=%4d us", (int) t[0].tv_usec); snprintf(timestr, 64, ", dec_time=%4d us", (int) t[0].tv_usec);
#endif #endif
Info("PDSCH: l_crb=%2d, harq=%d, nof_tb=%d, tbs={%d, %d}, mcs={%d, %d}, rv={%d, %d}, crc={%s, %s}, snr=%.1f dB, n_iter=%d%s\n", Info("PDSCH: l_crb=%2d, harq=%d, nof_tb=%d, tbs={%d, %d}, mcs={%d, %d}, rv={%d, %d}, crc={%s, %s}, snr=%.1f dB, cfo=%.1f Hzn_iter=%d%s\n",
grant->nof_prb, harq_pid, grant->nof_prb, harq_pid,
grant->nof_tb, grant->mcs[0].tbs / 8, grant->mcs[1].tbs / 8, grant->mcs[0].idx, grant->mcs[1].idx, grant->nof_tb, grant->mcs[0].tbs / 8, grant->mcs[1].tbs / 8, grant->mcs[0].idx, grant->mcs[1].idx,
rv[0], rv[1], acks[0] ? "OK" : "KO", acks[1] ? "OK" : "KO", rv[0], rv[1], acks[0] ? "OK" : "KO", acks[1] ? "OK" : "KO",
10 * log10(srslte_chest_dl_get_snr(&ue_dl.chest)), 10 * log10(srslte_chest_dl_get_snr(&ue_dl.chest)),
cfo*15000,
srslte_pdsch_last_noi(&ue_dl.pdsch), srslte_pdsch_last_noi(&ue_dl.pdsch),
timestr); timestr);

Loading…
Cancel
Save