From 1a5e064bbf79d027595e973913d4e40281da79d5 Mon Sep 17 00:00:00 2001 From: ismagom Date: Mon, 23 Mar 2015 11:03:06 -0400 Subject: [PATCH] changed names. Added tutorial examples. MMSE not working correctly due to erroneous noise estimation under time misalignment --- matlab/tests/equalizer_test.m | 10 ++++----- srslte/CMakeLists.txt | 2 ++ srslte/include/srslte/modem/demod_soft.h | 6 ++--- srslte/include/srslte/modem/mod.h | 4 ++-- srslte/include/srslte/modem/modem_table.h | 12 +++++----- srslte/include/srslte/phch/pbch.h | 2 +- srslte/include/srslte/phch/pcfich.h | 2 +- srslte/include/srslte/phch/pdcch.h | 2 +- srslte/include/srslte/phch/pdsch.h | 2 +- srslte/include/srslte/phch/phich.h | 2 +- srslte/include/srslte/phch/pusch.h | 2 +- srslte/include/srslte/ue/ue_dl.h | 2 ++ srslte/include/srslte/ue/ue_sync.h | 1 + srslte/lib/ch_estimation/src/chest_dl.c | 27 +++++++++++++---------- srslte/lib/modem/src/demod_soft.c | 2 +- srslte/lib/modem/src/mod.c | 2 +- srslte/lib/modem/src/modem_table.c | 16 +++++++------- srslte/lib/modem/test/modem_test.c | 2 +- srslte/lib/modem/test/soft_demod_test.c | 2 +- srslte/lib/phch/src/dci.c | 16 +++++++------- srslte/lib/sync/src/sync.c | 2 +- srslte/lib/ue/src/ue_dl.c | 15 +++++++------ srslte/lib/ue/src/ue_sync.c | 5 +++-- 23 files changed, 74 insertions(+), 64 deletions(-) diff --git a/matlab/tests/equalizer_test.m b/matlab/tests/equalizer_test.m index 2c82cdd16..80bd16960 100644 --- a/matlab/tests/equalizer_test.m +++ b/matlab/tests/equalizer_test.m @@ -4,9 +4,9 @@ clear -plot_noise_estimation_only=true; +plot_noise_estimation_only=false; -SNR_values_db=linspace(0,30,8); +SNR_values_db=20;%linspace(0,30,8); Nrealizations=1 ; preEVM = zeros(length(SNR_values_db),Nrealizations); @@ -80,7 +80,7 @@ for sf = 0:10 subframe = lteDLResourceGrid(enb); % Map input symbols to grid - %subframe(:) = inputSym; + subframe(:) = inputSym; % Generate synchronizing signals pssSym = ltePSS(enb); @@ -141,13 +141,13 @@ rxWaveform = rxWaveform + noise; %% Synchronization offset = lteDLFrameOffset(enb,rxWaveform); -rxWaveform = rxWaveform(1+offset:end,:); +rxWaveform = rxWaveform(1+offset+2:end,:); %% OFDM Demodulation rxGrid = lteOFDMDemodulate(enb,rxWaveform); rxGrid = rxGrid(:,1:140); -addpath('../../debug/lte/phy/lib/ch_estimation/test') +addpath('../../debug/srslte/lib/ch_estimation/test') %% Channel Estimation [estChannel, noiseEst(snr_idx)] = lteDLChannelEstimate(enb,cec,rxGrid); diff --git a/srslte/CMakeLists.txt b/srslte/CMakeLists.txt index e6f7456f1..60ca1bbd2 100644 --- a/srslte/CMakeLists.txt +++ b/srslte/CMakeLists.txt @@ -47,3 +47,5 @@ ADD_CUSTOM_TARGET (add_srslte_headers SOURCES ${HEADERS_ALL}) ADD_SUBDIRECTORY(lib) ADD_SUBDIRECTORY(examples) + +add_subdirectory(tutorial_examples) \ No newline at end of file diff --git a/srslte/include/srslte/modem/demod_soft.h b/srslte/include/srslte/modem/demod_soft.h index 5c0f53dd9..e6fa2545d 100644 --- a/srslte/include/srslte/modem/demod_soft.h +++ b/srslte/include/srslte/modem/demod_soft.h @@ -43,7 +43,7 @@ typedef enum SRSLTE_API { typedef struct SRSLTE_API { float sigma; // noise power srslte_demod_soft_alg_t alg_type; // soft demapping algorithm (SRSLTE_DEMOD_SOFT_ALG_EXACT or SRSLTE_DEMOD_SOFT_ALG_APPROX) - srslte_srslte_modem_table_t *table; // symbol mapping table (see modem_table.h) + srslte_modem_table_t *table; // symbol mapping table (see modem_table.h) uint32_t *zones; float *dd; uint32_t max_symbols; @@ -55,7 +55,7 @@ SRSLTE_API int srslte_demod_soft_init(srslte_demod_soft_t *q, SRSLTE_API void srslte_demod_soft_free(srslte_demod_soft_t *q); SRSLTE_API void srslte_demod_soft_table_set(srslte_demod_soft_t *q, - srslte_srslte_modem_table_t *table); + srslte_modem_table_t *table); SRSLTE_API void srslte_demod_soft_alg_set(srslte_demod_soft_t *q, srslte_demod_soft_alg_t alg_type); @@ -72,7 +72,7 @@ SRSLTE_API int srslte_demod_soft_demodulate(srslte_demod_soft_t *q, /* High-level API */ typedef struct SRSLTE_API { srslte_demod_soft_t obj; - srslte_srslte_modem_table_t table; + srslte_modem_table_t table; struct srslte_demod_soft_init{ srslte_mod_t std; // symbol mapping standard (see modem_table.h) diff --git a/srslte/include/srslte/modem/mod.h b/srslte/include/srslte/modem/mod.h index 627b47de1..b31e2fe7e 100644 --- a/srslte/include/srslte/modem/mod.h +++ b/srslte/include/srslte/modem/mod.h @@ -35,14 +35,14 @@ #include "srslte/config.h" #include "modem_table.h" -SRSLTE_API int srslte_mod_modulate(srslte_srslte_modem_table_t* table, +SRSLTE_API int srslte_mod_modulate(srslte_modem_table_t* table, uint8_t *bits, cf_t* symbols, uint32_t nbits); /* High-level API */ typedef struct SRSLTE_API { - srslte_srslte_modem_table_t obj; + srslte_modem_table_t obj; struct mod_init { srslte_mod_t std; // symbol mapping standard (see modem_table.h) } init; diff --git a/srslte/include/srslte/modem/modem_table.h b/srslte/include/srslte/modem/modem_table.h index 42b14a8f9..c14ea5bbf 100644 --- a/srslte/include/srslte/modem/modem_table.h +++ b/srslte/include/srslte/modem/modem_table.h @@ -49,22 +49,22 @@ typedef struct SRSLTE_API { srslte_soft_table_t soft_table; // symbol-to-bit mapping (used in soft demodulating) uint32_t nsymbols; // number of modulation symbols uint32_t nbits_x_symbol; // number of bits per symbol -}srslte_srslte_modem_table_t; +}srslte_modem_table_t; -SRSLTE_API void srslte_modem_table_init(srslte_srslte_modem_table_t* q); +SRSLTE_API void srslte_modem_table_init(srslte_modem_table_t* q); -SRSLTE_API void srslte_modem_table_free(srslte_srslte_modem_table_t* q); +SRSLTE_API void srslte_modem_table_free(srslte_modem_table_t* q); -SRSLTE_API void srslte_modem_table_reset(srslte_srslte_modem_table_t* q); +SRSLTE_API void srslte_modem_table_reset(srslte_modem_table_t* q); -SRSLTE_API int srslte_modem_table_set(srslte_srslte_modem_table_t* q, +SRSLTE_API int srslte_modem_table_set(srslte_modem_table_t* q, cf_t* table, srslte_soft_table_t *soft_table, uint32_t nsymbols, uint32_t nbits_x_symbol); -SRSLTE_API int srslte_modem_table_lte(srslte_srslte_modem_table_t* q, +SRSLTE_API int srslte_modem_table_lte(srslte_modem_table_t* q, srslte_mod_t modulation, bool compute_soft_demod); diff --git a/srslte/include/srslte/phch/pbch.h b/srslte/include/srslte/phch/pbch.h index 9bcf92c14..73601da89 100644 --- a/srslte/include/srslte/phch/pbch.h +++ b/srslte/include/srslte/phch/pbch.h @@ -69,7 +69,7 @@ typedef struct SRSLTE_API { uint32_t frame_idx; /* tx & rx objects */ - srslte_srslte_modem_table_t mod; + srslte_modem_table_t mod; srslte_demod_soft_t demod; srslte_sequence_t seq; srslte_viterbi_t decoder; diff --git a/srslte/include/srslte/phch/pcfich.h b/srslte/include/srslte/phch/pcfich.h index 1cd97c274..cdd58b0db 100644 --- a/srslte/include/srslte/phch/pcfich.h +++ b/srslte/include/srslte/phch/pcfich.h @@ -64,7 +64,7 @@ typedef struct SRSLTE_API { float data_f[PCFICH_CFI_LEN]; /* tx & rx objects */ - srslte_srslte_modem_table_t mod; + srslte_modem_table_t mod; srslte_demod_soft_t demod; srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; srslte_precoding_t precoding; diff --git a/srslte/include/srslte/phch/pdcch.h b/srslte/include/srslte/phch/pdcch.h index 4a9694585..47953b571 100644 --- a/srslte/include/srslte/phch/pdcch.h +++ b/srslte/include/srslte/phch/pdcch.h @@ -69,7 +69,7 @@ typedef struct SRSLTE_API { float *llr; /* tx & rx objects */ - srslte_srslte_modem_table_t mod; + srslte_modem_table_t mod; srslte_demod_soft_t demod; srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; srslte_viterbi_t decoder; diff --git a/srslte/include/srslte/phch/pdsch.h b/srslte/include/srslte/phch/pdsch.h index a3a923b13..50c2e248b 100644 --- a/srslte/include/srslte/phch/pdsch.h +++ b/srslte/include/srslte/phch/pdsch.h @@ -62,7 +62,7 @@ typedef struct SRSLTE_API { void *e; /* tx & rx objects */ - srslte_srslte_modem_table_t mod[4]; + srslte_modem_table_t mod[4]; srslte_demod_soft_t demod; srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; srslte_precoding_t precoding; diff --git a/srslte/include/srslte/phch/phich.h b/srslte/include/srslte/phch/phich.h index 20e9da050..c7c22afff 100644 --- a/srslte/include/srslte/phch/phich.h +++ b/srslte/include/srslte/phch/phich.h @@ -76,7 +76,7 @@ typedef struct SRSLTE_API { uint8_t data[SRSLTE_PHICH_NBITS]; /* tx & rx objects */ - srslte_srslte_modem_table_t mod; + srslte_modem_table_t mod; srslte_demod_hard_t demod; srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; srslte_precoding_t precoding; diff --git a/srslte/include/srslte/phch/pusch.h b/srslte/include/srslte/phch/pusch.h index e8d559162..d3a59124b 100644 --- a/srslte/include/srslte/phch/pusch.h +++ b/srslte/include/srslte/phch/pusch.h @@ -81,7 +81,7 @@ typedef struct SRSLTE_API { void *g; /* tx & rx objects */ - srslte_srslte_modem_table_t mod[4]; + srslte_modem_table_t mod[4]; srslte_demod_soft_t demod; srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; srslte_sequence_t seq_type2_fo; diff --git a/srslte/include/srslte/ue/ue_dl.h b/srslte/include/srslte/ue/ue_dl.h index f078d712c..2f958fab3 100644 --- a/srslte/include/srslte/ue/ue_dl.h +++ b/srslte/include/srslte/ue/ue_dl.h @@ -71,6 +71,8 @@ typedef struct SRSLTE_API { cf_t *sf_symbols; cf_t *ce[SRSLTE_MAX_PORTS]; + srslte_dci_format_t dci_format; + uint32_t cfi; uint64_t pkt_errors; uint64_t pkts_total; uint64_t nof_detected; diff --git a/srslte/include/srslte/ue/ue_sync.h b/srslte/include/srslte/ue/ue_sync.h index 45667a461..e97fa54f9 100644 --- a/srslte/include/srslte/ue/ue_sync.h +++ b/srslte/include/srslte/ue/ue_sync.h @@ -94,6 +94,7 @@ typedef struct SRSLTE_API { uint32_t sf_idx; bool decode_sss_on_track; + bool correct_cfo; uint32_t peak_idx; int time_offset; diff --git a/srslte/lib/ch_estimation/src/chest_dl.c b/srslte/lib/ch_estimation/src/chest_dl.c index a72ae29c0..b61793753 100644 --- a/srslte/lib/ch_estimation/src/chest_dl.c +++ b/srslte/lib/ch_estimation/src/chest_dl.c @@ -92,7 +92,6 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell) perror("malloc"); goto clean_exit; } - bzero(q->tmp_timeavg_mult, sizeof(cf_t) * 2*cell.nof_prb); for (int i=0;ipilot_estimates[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i)); @@ -123,13 +122,13 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell) } /* Set default time/freq filters */ - //float f[3]={0.1, 0.8, 0.1}; + //float f[3]={0.2, 0.6, 0.2}; //srslte_chest_dl_set_filter_freq(q, f, 3); - float f[5]={0.05, 0.2, 0.5, 0.2, 0.05}; + float f[5]={0.1, 0.2, 0.4, 0.2, 0.1}; srslte_chest_dl_set_filter_freq(q, f, 5); - - float t[2]={0.1, 0.9}; + + float t[2]={0.5, 0.5}; srslte_chest_dl_set_filter_time(q, t, 0); q->cell = cell; @@ -269,14 +268,18 @@ static void average_pilots(srslte_chest_dl_t *q, uint32_t port_id) for (i=0;ifilter_time_len-1;i++) { memcpy(q->tmp_timeavg[i], q->tmp_timeavg[i+1], nref*sizeof(cf_t)); } - /* Put last symbol to buffer */ - memcpy(q->tmp_timeavg[i], &pilot_tmp(0), nref*sizeof(cf_t)); - + /* Save last symbol to buffer */ + memcpy(q->tmp_timeavg[q->filter_time_len-1], &pilot_tmp(0), nref*sizeof(cf_t)); + /* Multiply all symbols by filter and add them */ - bzero(&pilot_avg(0), nref * sizeof(cf_t)); - for (i=0;ifilter_time_len;i++) { - srslte_vec_sc_prod_cfc(q->tmp_timeavg[i], q->filter_time[i], q->tmp_timeavg[i], nref); - srslte_vec_sum_ccc(q->tmp_timeavg[i], &pilot_avg(0), &pilot_avg(0), nref); + if (l > 0) { + bzero(&pilot_avg(0), nref * sizeof(cf_t)); + for (i=0;ifilter_time_len;i++) { + srslte_vec_sc_prod_cfc(q->tmp_timeavg[i], q->filter_time[i], q->tmp_timeavg_mult, nref); + srslte_vec_sum_ccc(q->tmp_timeavg_mult, &pilot_avg(0), &pilot_avg(0), nref); + } + } else { + memcpy(&pilot_avg(0), &pilot_tmp(0), nref * sizeof(cf_t)); } } else { memcpy(&pilot_avg(0), &pilot_tmp(0), nref * sizeof(cf_t)); diff --git a/srslte/lib/modem/src/demod_soft.c b/srslte/lib/modem/src/demod_soft.c index ae837154c..39fcf5e71 100644 --- a/srslte/lib/modem/src/demod_soft.c +++ b/srslte/lib/modem/src/demod_soft.c @@ -71,7 +71,7 @@ void srslte_demod_soft_free(srslte_demod_soft_t *q) { bzero((void*)q,sizeof(srslte_demod_soft_t)); } -void srslte_demod_soft_table_set(srslte_demod_soft_t *q, srslte_srslte_modem_table_t *table) { +void srslte_demod_soft_table_set(srslte_demod_soft_t *q, srslte_modem_table_t *table) { q->table = table; } diff --git a/srslte/lib/modem/src/mod.c b/srslte/lib/modem/src/mod.c index ed0b6afaf..ceb3390d1 100644 --- a/srslte/lib/modem/src/mod.c +++ b/srslte/lib/modem/src/mod.c @@ -35,7 +35,7 @@ /** Low-level API */ -int srslte_mod_modulate(srslte_srslte_modem_table_t* q, uint8_t *bits, cf_t* symbols, uint32_t nbits) { +int srslte_mod_modulate(srslte_modem_table_t* q, uint8_t *bits, cf_t* symbols, uint32_t nbits) { uint32_t i,j,idx; uint8_t *b_ptr=(uint8_t*) bits; j=0; diff --git a/srslte/lib/modem/src/modem_table.c b/srslte/lib/modem/src/modem_table.c index 1fb671172..0428fdd15 100644 --- a/srslte/lib/modem/src/modem_table.c +++ b/srslte/lib/modem/src/modem_table.c @@ -38,26 +38,26 @@ #include "lte_tables.h" /** Internal functions */ -static int table_create(srslte_srslte_modem_table_t* q) { +static int table_create(srslte_modem_table_t* q) { q->symbol_table = malloc(q->nsymbols*sizeof(cf_t)); return q->symbol_table==NULL; } -void srslte_modem_table_init(srslte_srslte_modem_table_t* q) { - bzero((void*)q,sizeof(srslte_srslte_modem_table_t)); +void srslte_modem_table_init(srslte_modem_table_t* q) { + bzero((void*)q,sizeof(srslte_modem_table_t)); } -void srslte_modem_table_free(srslte_srslte_modem_table_t* q) { +void srslte_modem_table_free(srslte_modem_table_t* q) { if (q->symbol_table) { free(q->symbol_table); } - bzero(q, sizeof(srslte_srslte_modem_table_t)); + bzero(q, sizeof(srslte_modem_table_t)); } -void srslte_modem_table_reset(srslte_srslte_modem_table_t* q) { +void srslte_modem_table_reset(srslte_modem_table_t* q) { srslte_modem_table_free(q); srslte_modem_table_init(q); } -int srslte_modem_table_set(srslte_srslte_modem_table_t* q, cf_t* table, srslte_soft_table_t *soft_table, uint32_t nsymbols, uint32_t nbits_x_symbol) { +int srslte_modem_table_set(srslte_modem_table_t* q, cf_t* table, srslte_soft_table_t *soft_table, uint32_t nsymbols, uint32_t nbits_x_symbol) { if (q->nsymbols) { return SRSLTE_ERROR; } @@ -71,7 +71,7 @@ int srslte_modem_table_set(srslte_srslte_modem_table_t* q, cf_t* table, srslte_s return SRSLTE_SUCCESS; } -int srslte_modem_table_lte(srslte_srslte_modem_table_t* q, srslte_mod_t modulation, bool compute_soft_demod) { +int srslte_modem_table_lte(srslte_modem_table_t* q, srslte_mod_t modulation, bool compute_soft_demod) { switch(modulation) { case SRSLTE_MOD_BPSK: q->nbits_x_symbol = 1; diff --git a/srslte/lib/modem/test/modem_test.c b/srslte/lib/modem/test/modem_test.c index d2cdd5662..bcbcca151 100644 --- a/srslte/lib/modem/test/modem_test.c +++ b/srslte/lib/modem/test/modem_test.c @@ -94,7 +94,7 @@ void parse_args(int argc, char **argv) { int main(int argc, char **argv) { int i; - srslte_srslte_modem_table_t mod; + srslte_modem_table_t mod; srslte_demod_hard_t demod_hard; srslte_demod_soft_t demod_soft; uint8_t *input, *output; diff --git a/srslte/lib/modem/test/soft_demod_test.c b/srslte/lib/modem/test/soft_demod_test.c index 398fd9262..7a25456f0 100644 --- a/srslte/lib/modem/test/soft_demod_test.c +++ b/srslte/lib/modem/test/soft_demod_test.c @@ -108,7 +108,7 @@ float mse_threshold() { int main(int argc, char **argv) { int i; - srslte_srslte_modem_table_t mod; + srslte_modem_table_t mod; srslte_demod_soft_t demod_soft; uint8_t *input, *output; cf_t *symbols; diff --git a/srslte/lib/phch/src/dci.c b/srslte/lib/phch/src/dci.c index 0e59b1f09..e4ec6ba8f 100644 --- a/srslte/lib/phch/src/dci.c +++ b/srslte/lib/phch/src/dci.c @@ -802,13 +802,13 @@ int srslte_dci_msg_unpack_pusch(srslte_dci_msg_t *msg, srslte_ra_pusch_t *data, } srslte_dci_format_t srslte_dci_format_from_string(char *str) { - if (!strcmp(str, "SRSLTE_DCI_FORMAT0")) { + if (!strcmp(str, "Format0")) { return SRSLTE_DCI_FORMAT0; - } else if (!strcmp(str, "SRSLTE_DCI_FORMAT1")) { + } else if (!strcmp(str, "Format1")) { return SRSLTE_DCI_FORMAT1; - } else if (!strcmp(str, "SRSLTE_DCI_FORMAT1A")) { + } else if (!strcmp(str, "Format1A")) { return SRSLTE_DCI_FORMAT1A; - } else if (!strcmp(str, "SRSLTE_DCI_FORMAT1C")) { + } else if (!strcmp(str, "Format1C")) { return SRSLTE_DCI_FORMAT1C; } else { return SRSLTE_DCI_FORMAT_ERROR; @@ -818,13 +818,13 @@ srslte_dci_format_t srslte_dci_format_from_string(char *str) { char* srslte_dci_format_string(srslte_dci_format_t format) { switch (format) { case SRSLTE_DCI_FORMAT0: - return "SRSLTE_DCI_FORMAT0"; + return "Format0"; case SRSLTE_DCI_FORMAT1: - return "SRSLTE_DCI_FORMAT1"; + return "Format1"; case SRSLTE_DCI_FORMAT1A: - return "SRSLTE_DCI_FORMAT1A"; + return "Format1A"; case SRSLTE_DCI_FORMAT1C: - return "SRSLTE_DCI_FORMAT1C"; + return "Format1C"; default: return "N/A"; // fatal error } diff --git a/srslte/lib/sync/src/sync.c b/srslte/lib/sync/src/sync.c index af298feb0..43cdd9b9b 100644 --- a/srslte/lib/sync/src/sync.c +++ b/srslte/lib/sync/src/sync.c @@ -36,7 +36,7 @@ #include "srslte/sync/cfo.h" #define MEANPEAK_EMA_ALPHA 0.2 -#define CFO_EMA_ALPHA 0.01 +#define CFO_EMA_ALPHA 0.1 #define CP_EMA_ALPHA 0.2 static bool fft_size_isvalid(uint32_t fft_size) { diff --git a/srslte/lib/ue/src/ue_dl.c b/srslte/lib/ue/src/ue_dl.c index e5e3348a4..10ca16fbf 100644 --- a/srslte/lib/ue/src/ue_dl.c +++ b/srslte/lib/ue/src/ue_dl.c @@ -196,7 +196,7 @@ int srslte_ue_dl_decode_fft_estimate(srslte_ue_dl_t *q, cf_t *input, uint32_t sf } /* Extract all PDCCH symbols and get LLRs */ - if (srslte_pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, srslte_chest_dl_get_noise_estimate(&q->chest), sf_idx, *cfi)) { + if (srslte_pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, 0, sf_idx, *cfi)) { fprintf(stderr, "Error extracting LLRs\n"); return SRSLTE_ERROR; } @@ -228,7 +228,7 @@ int srslte_ue_dl_decode_rnti_rv_packet(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_ } if (q->harq_process[0].mcs.mod > 0 && q->harq_process[0].mcs.tbs >= 0) { ret = srslte_pdsch_decode_rnti(&q->pdsch, &q->harq_process[0], q->sf_symbols, - q->ce, srslte_chest_dl_get_noise_estimate(&q->chest), + q->ce, 0, rnti, data); if (ret == SRSLTE_ERROR) { q->pkt_errors++; @@ -262,7 +262,7 @@ int srslte_ue_dl_find_ul_dci(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint3 int srslte_ue_dl_decode_rnti_rv(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx, uint16_t rnti, uint32_t rvidx) { - uint32_t cfi, i; + uint32_t i; srslte_dci_msg_t dci_msg; srslte_dci_location_t locations[MAX_CANDIDATES]; uint32_t nof_locations; @@ -271,17 +271,17 @@ int srslte_ue_dl_decode_rnti_rv(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, u uint32_t nof_formats; srslte_dci_format_t *formats = NULL; - if ((ret = srslte_ue_dl_decode_fft_estimate(q, input, sf_idx, &cfi)) < 0) { + if ((ret = srslte_ue_dl_decode_fft_estimate(q, input, sf_idx, &q->cfi)) < 0) { return ret; } /* Generate PDCCH candidates */ if (rnti == SRSLTE_SIRNTI) { - nof_locations = srslte_pdcch_common_locations(&q->pdcch, locations, MAX_CANDIDATES, cfi); + nof_locations = srslte_pdcch_common_locations(&q->pdcch, locations, MAX_CANDIDATES, q->cfi); formats = common_formats; nof_formats = nof_common_formats; } else { - nof_locations = srslte_pdcch_ue_locations(&q->pdcch, locations, MAX_CANDIDATES, sf_idx, cfi, rnti); + nof_locations = srslte_pdcch_ue_locations(&q->pdcch, locations, MAX_CANDIDATES, sf_idx, q->cfi, rnti); formats = ue_formats; nof_formats = nof_ue_formats; } @@ -299,8 +299,9 @@ int srslte_ue_dl_decode_rnti_rv(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, u INFO("Decoded DCI message RNTI: 0x%x\n", srslte_crc_rem); if (srslte_crc_rem == rnti) { + q->dci_format = formats[f]; found_dci++; - ret = srslte_ue_dl_decode_rnti_rv_packet(q, &dci_msg, data, cfi, sf_idx, rnti, rvidx); + ret = srslte_ue_dl_decode_rnti_rv_packet(q, &dci_msg, data, q->cfi, sf_idx, rnti, rvidx); } } } diff --git a/srslte/lib/ue/src/ue_sync.c b/srslte/lib/ue/src/ue_sync.c index 31fcfb956..ba087948e 100644 --- a/srslte/lib/ue/src/ue_sync.c +++ b/srslte/lib/ue/src/ue_sync.c @@ -63,7 +63,7 @@ int srslte_ue_sync_init_file(srslte_ue_sync_t *q, uint32_t nof_prb, char *file_n goto clean_exit; } - q->input_buffer = srslte_vec_malloc(q->sf_len * sizeof(cf_t)); + q->input_buffer = srslte_vec_malloc(2 * q->sf_len * sizeof(cf_t)); if (!q->input_buffer) { perror("malloc"); goto clean_exit; @@ -102,6 +102,7 @@ int srslte_ue_sync_init(srslte_ue_sync_t *q, q->fft_size = srslte_symbol_sz(q->cell.nof_prb); q->sf_len = SRSLTE_SF_LEN(q->fft_size); q->file_mode = false; + q->correct_cfo = true; if (cell.id == 1000) { /* If the cell is unkown, decode SSS on track state */ @@ -449,7 +450,7 @@ int srslte_ue_sync_get_buffer(srslte_ue_sync_t *q, cf_t **sf_symbols) { } /* Do CFO Correction if not done in track and deliver the frame */ - if (!q->strack.correct_cfo) { + if (!q->strack.correct_cfo && q->correct_cfo) { srslte_cfo_correct(&q->sfind.cfocorr, q->input_buffer, q->input_buffer,