From 9c18c03b97575b1676f062184037892cdb285441 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Thu, 25 Aug 2016 17:05:17 -0700 Subject: [PATCH 1/9] Inreased DCI buffer because CRC is appended there --- srslte/include/srslte/phch/dci.h | 2 +- srslte/lib/phch/dci.c | 5 +- srslte/lib/phch/test/CMakeLists.txt | 3 - srslte/lib/phch/test/dci_unpacking.c | 102 --------------------------- srslte/lib/phch/test/pucch_test.c | 4 +- srslte/lib/phch/test/pusch_test.c | 4 +- 6 files changed, 8 insertions(+), 112 deletions(-) delete mode 100644 srslte/lib/phch/test/dci_unpacking.c diff --git a/srslte/include/srslte/phch/dci.h b/srslte/include/srslte/phch/dci.h index c3fe268e1..b8e590516 100644 --- a/srslte/include/srslte/phch/dci.h +++ b/srslte/include/srslte/phch/dci.h @@ -43,7 +43,7 @@ #include "srslte/common/phy_common.h" #include "srslte/phch/ra.h" -#define SRSLTE_DCI_MAX_BITS 57 +#define SRSLTE_DCI_MAX_BITS 128 #define SRSLTE_RAR_GRANT_LEN 20 diff --git a/srslte/lib/phch/dci.c b/srslte/lib/phch/dci.c index 57dc9862a..b4262f857 100644 --- a/srslte/lib/phch/dci.c +++ b/srslte/lib/phch/dci.c @@ -65,7 +65,7 @@ int srslte_dci_msg_to_dl_grant(srslte_dci_msg_t *msg, uint16_t msg_rnti, srslte_dci_format_t tmp = msg->format; ret = srslte_dci_msg_unpack_pdsch(msg, dl_dci, nof_prb, nof_ports, crc_is_crnti); if (ret) { - fprintf(stderr, "Can't unpack DCI message %s (%d)\n", srslte_dci_format_string(tmp), ret); + fprintf(stderr, "Can't unpack DCI message %s (%d)\n", srslte_dci_format_string(tmp), tmp); return ret; } @@ -386,7 +386,8 @@ uint32_t srslte_dci_format_sizeof(srslte_dci_format_t format, uint32_t nof_prb, return dci_format3A_sizeof(nof_prb); */ default: - return SRSLTE_ERROR; + printf("Error computing DCI bits: Unknown format %d\n", format); + return 0; } } diff --git a/srslte/lib/phch/test/CMakeLists.txt b/srslte/lib/phch/test/CMakeLists.txt index 9789a605d..90c658e66 100644 --- a/srslte/lib/phch/test/CMakeLists.txt +++ b/srslte/lib/phch/test/CMakeLists.txt @@ -81,9 +81,6 @@ target_link_libraries(pdcch_test srslte) add_test(pdcch_test pdcch_test) -add_executable(dci_unpacking dci_unpacking.c) -target_link_libraries(dci_unpacking srslte) - BuildMex(MEXNAME pdcch SOURCES pdcch_test_mex.c LIBRARIES srslte_static srslte_mex) ######################################################################## diff --git a/srslte/lib/phch/test/dci_unpacking.c b/srslte/lib/phch/test/dci_unpacking.c deleted file mode 100644 index 7e65b433f..000000000 --- a/srslte/lib/phch/test/dci_unpacking.c +++ /dev/null @@ -1,102 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2015 Software Radio Systems Limited - * - * \section LICENSE - * - * This file is part of the srsLTE library. - * - * srsLTE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * srsLTE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * A copy of the GNU Affero General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - -#include -#include -#include -#include -#include - -#include "srslte/srslte.h" - -void usage(char *prog) { - printf("Usage: %s nof_prb length_bits Word0 Word1 ...\n", prog); -} - -int main(int argc, char **argv) { - srslte_dci_msg_t msg; - srslte_ra_dl_dci_t ra_dl; - int len, rlen; - int nof_prb; - int nwords; - int i; - uint8_t *y; - - if (argc < 3) { - usage(argv[0]); - exit(-1); - } - - nof_prb = atoi(argv[1]); - len = atoi(argv[2]); - - nwords = (len - 1) / 32 + 1; - - if (argc < 3 + nwords) { - usage(argv[0]); - exit(-1); - } - - y = msg.data; - rlen = 0; - uint32_t x; - for (i = 0; i < nwords; i++) { - x = strtoul(argv[i + 3], NULL, 16); - if (len - rlen < 32) { - srslte_bit_unpack(x, &y, len - rlen); - } else { - srslte_bit_unpack(x, &y, 32); - } - - } - - printf("DCI message len %d:\n", len); - for (i = 0; i < len; i++) { - printf("%d, ", msg.data[i]); - } - printf("\n"); - - srslte_dci_msg_type_t dci_type; - msg.nof_bits = len; - if (srslte_dci_msg_get_type(&msg, &dci_type, nof_prb, SRSLTE_SIRNTI)) { - fprintf(stderr, "Can't obtain DCI message type\n"); - exit(-1); - } - printf("\n"); - printf("Message type:"); - srslte_dci_msg_type_fprint(stdout, dci_type); - switch (dci_type.type) { - case SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED: - bzero(&ra_dl, sizeof(srslte_ra_dl_dci_t)); - srslte_dci_msg_unpack_pdsch(&msg, &ra_dl, nof_prb, 1, false); - srslte_ra_pdsch_fprint(stdout, &ra_dl, nof_prb); - break; - default: - printf("Error expected PDSCH\n"); - exit(-1); - } - printf("\n"); -} diff --git a/srslte/lib/phch/test/pucch_test.c b/srslte/lib/phch/test/pucch_test.c index aeec68a41..77fa75e62 100644 --- a/srslte/lib/phch/test/pucch_test.c +++ b/srslte/lib/phch/test/pucch_test.c @@ -90,11 +90,11 @@ int main(int argc, char **argv) { if (srslte_pucch_init(&pucch, cell)) { fprintf(stderr, "Error creating PDSCH object\n"); - goto quit; + exit(-1); } if (srslte_refsignal_ul_init(&dmrs, cell)) { fprintf(stderr, "Error creating PDSCH object\n"); - goto quit; + exit(-1; } bzero(&pucch_cfg, sizeof(srslte_pucch_cfg_t)); diff --git a/srslte/lib/phch/test/pusch_test.c b/srslte/lib/phch/test/pusch_test.c index 8752cc734..def6b5982 100644 --- a/srslte/lib/phch/test/pusch_test.c +++ b/srslte/lib/phch/test/pusch_test.c @@ -184,13 +184,13 @@ int main(int argc, char **argv) { sf_symbols = srslte_vec_malloc(sizeof(cf_t) * nof_re); if (!sf_symbols) { perror("malloc"); - goto quit; + exit(-1); } data = srslte_vec_malloc(sizeof(uint8_t) * cfg.grant.mcs.tbs); if (!data) { perror("malloc"); - goto quit; + exit(-1); } for (uint32_t i=0;i Date: Thu, 25 Aug 2016 17:14:10 -0700 Subject: [PATCH 2/9] compilation issue in pucch_test --- srslte/lib/phch/test/pucch_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srslte/lib/phch/test/pucch_test.c b/srslte/lib/phch/test/pucch_test.c index 77fa75e62..a2a9b8958 100644 --- a/srslte/lib/phch/test/pucch_test.c +++ b/srslte/lib/phch/test/pucch_test.c @@ -94,7 +94,7 @@ int main(int argc, char **argv) { } if (srslte_refsignal_ul_init(&dmrs, cell)) { fprintf(stderr, "Error creating PDSCH object\n"); - exit(-1; + exit(-1); } bzero(&pucch_cfg, sizeof(srslte_pucch_cfg_t)); From 10cbb9ad920191f9c74e44123e059e92747e9f55 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Thu, 25 Aug 2016 19:01:47 -0700 Subject: [PATCH 3/9] ue_sync: set default offset correction interval to 0. chest_dl: added option to average estimates per subframe --- matlab/tests/equalizer_test.m | 21 +++++------- matlab/tests/pdsch_equal.m | 3 +- srslte/examples/pdsch_ue.c | 2 ++ srslte/lib/ch_estimation/chest_dl.c | 52 +++++++++++++++++++++-------- srslte/lib/ue/ue_sync.c | 22 ++++++------ 5 files changed, 62 insertions(+), 38 deletions(-) diff --git a/matlab/tests/equalizer_test.m b/matlab/tests/equalizer_test.m index 1391d5e53..5cd7e3353 100644 --- a/matlab/tests/equalizer_test.m +++ b/matlab/tests/equalizer_test.m @@ -6,13 +6,13 @@ clear plot_noise_estimation_only=false; -SNR_values_db=100;%linspace(20,35,8); -Nrealizations=1; +SNR_values_db=linspace(0,20,8); +Nrealizations=10; w1=0.1; w2=0.3; -enb.NDLRB = 6; % Number of resource blocks +enb.NDLRB = 25; % Number of resource blocks enb.CellRefP = 1; % One transmit antenna port enb.NCellID = 0; % Cell ID @@ -181,8 +181,8 @@ for i=1:10 rxGrid_sf = rxGrid(:,(i-1)*14+1:i*14); %% Channel Estimation with Matlab - [hest{1}(:,(1:14)+(i-1)*14), tmpnoise{1}(i), hls(:,(1:4*P)+(i-1)*4*P)] = ... - lteDLChannelEstimate2(enb,cec,rxGrid_sf); + [hest{1}(:,(1:14)+(i-1)*14), tmpnoise{1}(i)] = ... + lteDLChannelEstimate(enb,cec,rxGrid_sf); tmpnoise{1}(i)=tmpnoise{1}(i)*sqrt(2)*enb.CellRefP; %% LS-Linear estimation with srsLTE @@ -227,17 +227,12 @@ if (length(SNR_values_db) == 1) tmp{Ntests+1}='Real'; legend(tmp) - xlabel('SNR (dB)') + xlabel('Sample') ylabel('Channel Gain') grid on; - fprintf('Mean MMSE Robust %.2f dB\n', 10*log10(MSE(4,nreal,snr_idx))) - fprintf('Mean MMSE matlab %.2f dB\n', 10*log10(MSE(1,nreal,snr_idx))) -<<<<<<< HEAD - -======= - ->>>>>>> master +% fprintf('Mean MMSE Robust %.2f dB\n', 10*log10(MSE(4,nreal,snr_idx))) +% fprintf('Mean MMSE matlab %.2f dB\n', 10*log10(MSE(1,nreal,snr_idx))) end end diff --git a/matlab/tests/pdsch_equal.m b/matlab/tests/pdsch_equal.m index 665ff8047..08722b3bd 100644 --- a/matlab/tests/pdsch_equal.m +++ b/matlab/tests/pdsch_equal.m @@ -116,7 +116,7 @@ for snr_idx=1:length(SNR_values) rmccFgOut.TotSubframes=1; % Perform channel estimation - [hest, nest,estimates] = lteDLChannelEstimate2(rmccFgOut, cec, subframe_rx); + [hest, nest] = lteDLChannelEstimate(rmccFgOut, cec, subframe_rx); [cws,symbols] = ltePDSCHDecode(rmccFgOut,rmccFgOut.PDSCH,subframe_rx,hest,nest); [trblkout,blkcrc,dstate] = lteDLSCHDecode(rmccFgOut,rmccFgOut.PDSCH, ... @@ -156,6 +156,7 @@ if (length(SNR_values)>1) axis([min(SNR_values) max(SNR_values) 1/Npackets/(Nsf+1) 1]) else scatter(real(symbols{1}),imag(symbols{1})) + plot( fprintf('Matlab: %d OK\nsrsLTE: %d OK\n',decoded, decoded_srslte); end diff --git a/srslte/examples/pdsch_ue.c b/srslte/examples/pdsch_ue.c index b0a9c5fd6..8c986ab75 100644 --- a/srslte/examples/pdsch_ue.c +++ b/srslte/examples/pdsch_ue.c @@ -583,11 +583,13 @@ int main(int argc, char **argv) { sfn++; if (sfn == 1024) { sfn = 0; + /* printf("\n"); ue_dl.pkt_errors = 0; ue_dl.pkts_total = 0; ue_dl.nof_detected = 0; nof_trials = 0; + */ } } diff --git a/srslte/lib/ch_estimation/chest_dl.c b/srslte/lib/ch_estimation/chest_dl.c index beb7518d2..7ac4444a0 100644 --- a/srslte/lib/ch_estimation/chest_dl.c +++ b/srslte/lib/ch_estimation/chest_dl.c @@ -39,6 +39,8 @@ #include "srslte/utils/vector.h" #include "srslte/utils/convolution.h" +#define AVERAGE_SUBFRAME + //#define DEFAULT_FILTER_LEN 3 #ifdef DEFAULT_FILTER_LEN @@ -165,7 +167,18 @@ void srslte_chest_dl_free(srslte_chest_dl_t *q) /* Uses the difference between the averaged and non-averaged pilot estimates */ static float estimate_noise_pilots(srslte_chest_dl_t *q, uint32_t port_id) { + float norm = sqrt(2); +#ifdef AVERAGE_SUBFRAME + int nref=2*q->cell.nof_prb; +#else int nref=SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id); + if (q->smooth_filter_len == 3) { + float a = q->smooth_filter[0]; + float norm3 = 6.143*a*a+0.04859*a-0.002774; + norm /= norm3; + } +#endif + /* Substract noisy pilot estimates */ srslte_vec_sub_ccc(q->pilot_estimates_average, q->pilot_estimates, q->tmp_noise, nref); @@ -179,12 +192,6 @@ static float estimate_noise_pilots(srslte_chest_dl_t *q, uint32_t port_id) #endif /* Compute average power. Normalized for filter len 3 using matlab */ - float norm = 1; - if (q->smooth_filter_len == 3) { - float a = q->smooth_filter[0]; - float norm3 = 6.143*a*a+0.04859*a-0.002774; - norm /= norm3; - } float power = norm*q->cell.nof_ports*srslte_vec_avg_power_cf(q->tmp_noise, nref); return power; } @@ -225,19 +232,29 @@ static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) { static void interpolate_pilots(srslte_chest_dl_t *q, cf_t *pilot_estimates, cf_t *ce, uint32_t port_id) { - /* interpolate the symbols with references in the freq domain */ - uint32_t l; + +#ifdef AVERAGE_SUBFRAME + // Interpolate symbol 0 in the frequency domain + uint32_t fidx_offset = srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0); + srslte_interp_linear_offset(&q->srslte_interp_lin, pilot_estimates, + &ce[srslte_refsignal_cs_nsymbol(0,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], + fidx_offset, SRSLTE_NRE/2-fidx_offset); + // All channel estimates in the subframe are the same + for (int l=1;l<2*SRSLTE_CP_NSYMB(q->cell.cp);l++) { + memcpy(&ce[l*q->cell.nof_prb*SRSLTE_NRE], ce, q->cell.nof_prb*SRSLTE_NRE*sizeof(cf_t)); + } +#else + uint32_t l=0; uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); - - /* Interpolate in the frequency domain */ + + // Interpolate in the frequency domain for (l=0;lcell, l, port_id, 0); srslte_interp_linear_offset(&q->srslte_interp_lin, &pilot_estimates[2*q->cell.nof_prb*l], &ce[srslte_refsignal_cs_nsymbol(l,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], fidx_offset, SRSLTE_NRE/2-fidx_offset); } - - /* Now interpolate in the time domain between symbols */ + // Interpolate in the time domain between symbols if (SRSLTE_CP_ISNORM(q->cell.cp)) { if (nsymbols == 4) { srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(4), &cesymb(1), 4, 3); @@ -261,6 +278,7 @@ static void interpolate_pilots(srslte_chest_dl_t *q, cf_t *pilot_estimates, cf_t srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(8), 6, 4); } } +#endif } void srslte_chest_dl_set_smooth_filter(srslte_chest_dl_t *q, float *filter, uint32_t filter_len) { @@ -293,9 +311,17 @@ static void average_pilots(srslte_chest_dl_t *q, cf_t *input, cf_t *output, uint uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); uint32_t nref = 2*q->cell.nof_prb; - for (int l=0;lsmooth_filter, &output[l*nref], nref, q->smooth_filter_len); +#endif } +#ifdef AVERAGE_SUBFRAME + srslte_vec_sc_prod_cfc(output, (float) 1.0/nsymbols, output, nref); +#endif } float srslte_chest_dl_rssi(srslte_chest_dl_t *q, cf_t *input, uint32_t port_id) { diff --git a/srslte/lib/ue/ue_sync.c b/srslte/lib/ue/ue_sync.c index d04c5c303..a81004ef0 100644 --- a/srslte/lib/ue/ue_sync.c +++ b/srslte/lib/ue/ue_sync.c @@ -44,7 +44,7 @@ cf_t dummy[MAX_TIME_OFFSET]; #define TRACK_MAX_LOST 4 #define TRACK_FRAME_SIZE 32 #define FIND_NOF_AVG_FRAMES 4 -#define DEFAULT_SAMPLE_OFFSET_CORRECT_PERIOD 5 +#define DEFAULT_SAMPLE_OFFSET_CORRECT_PERIOD 0 #define DEFAULT_SFO_EMA_COEFF 0.1 cf_t dummy_offset_buffer[1024*1024]; @@ -358,7 +358,6 @@ static int track_peak_ok(srslte_ue_sync_t *q, uint32_t track_idx) { { INFO("Warning: Expected SF idx %d but got %d! (%d frames)\n", q->sf_idx, srslte_sync_get_sf_idx(&q->strack), q->frame_no_cnt); - q->sf_idx = srslte_sync_get_sf_idx(&q->strack); q->frame_no_cnt++; if (q->frame_no_cnt >= TRACK_MAX_LOST) { INFO("\n%d frames lost. Going back to FIND\n", (int) q->frame_no_cnt); @@ -382,18 +381,19 @@ static int track_peak_ok(srslte_ue_sync_t *q, uint32_t track_idx) { // Compute cumulative moving average time offset */ if (!frame_idx) { - // Adjust RF sampling time based on the mean sampling offset - q->next_rf_sample_offset = (int) round(q->mean_sample_offset); - - // Reset PSS averaging if correcting every a period longer than 1 - if (q->sample_offset_correct_period > 1) { - srslte_sync_reset(&q->strack); - } - - // Compute SFO based on mean sample offset if (q->sample_offset_correct_period) { + // Adjust RF sampling time based on the mean sampling offset + q->next_rf_sample_offset = (int) round(q->mean_sample_offset); + // Reset PSS averaging if correcting every a period longer than 1 + if (q->sample_offset_correct_period > 1) { + srslte_sync_reset(&q->strack); + } + // Compute SFO based on mean sample offset q->mean_sample_offset /= q->sample_offset_correct_period; + } else { + q->next_rf_sample_offset = q->last_sample_offset; } + q->mean_sfo = SRSLTE_VEC_EMA(q->mean_sample_offset, q->mean_sfo, q->sfo_ema); INFO("Time offset adjustment: %d samples (%.2f), mean SFO: %.2f Hz, %.5f samples/5-sf, ema=%f, length=%d\n", From 58d955ea10d67e0407cdd01def3aef65a34d2944 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Thu, 25 Aug 2016 19:04:36 -0700 Subject: [PATCH 4/9] psdch_ue: disabled agc by default. Set default gain to 70 dB --- srslte/examples/pdsch_ue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srslte/examples/pdsch_ue.c b/srslte/examples/pdsch_ue.c index 8c986ab75..e347f0e71 100644 --- a/srslte/examples/pdsch_ue.c +++ b/srslte/examples/pdsch_ue.c @@ -39,7 +39,7 @@ #include "srslte/srslte.h" -#define ENABLE_AGC_DEFAULT +//#define ENABLE_AGC_DEFAULT #ifndef DISABLE_RF #include "srslte/rf/rf.h" @@ -116,7 +116,7 @@ void args_default(prog_args_t *args) { #ifdef ENABLE_AGC_DEFAULT args->rf_gain = -1.0; #else - args->rf_gain = 50.0; + args->rf_gain = 70.0; #endif args->net_port = -1; args->net_address = "127.0.0.1"; From 82cfa014684d452e71e29936d84a7869a282bc10 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Sat, 27 Aug 2016 17:24:55 +0000 Subject: [PATCH 5/9] chest_dl: subframe averaging with previous --- .../include/srslte/ch_estimation/chest_dl.h | 10 ++ srslte/lib/ch_estimation/chest_dl.c | 162 +++++++++--------- 2 files changed, 94 insertions(+), 78 deletions(-) diff --git a/srslte/include/srslte/ch_estimation/chest_dl.h b/srslte/include/srslte/ch_estimation/chest_dl.h index a4afa1d84..3aabd2595 100644 --- a/srslte/include/srslte/ch_estimation/chest_dl.h +++ b/srslte/include/srslte/ch_estimation/chest_dl.h @@ -63,6 +63,7 @@ typedef struct { srslte_refsignal_cs_t csr_signal; cf_t *pilot_estimates; cf_t *pilot_estimates_average; + cf_t *pilot_average_last; cf_t *pilot_recv_signal; cf_t *tmp_noise; @@ -73,6 +74,9 @@ typedef struct { uint32_t smooth_filter_len; float smooth_filter[SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN]; + float time_ema_coeff; + bool average_subframe; + srslte_interp_linsrslte_vec_t srslte_interp_linvec; srslte_interp_lin_t srslte_interp_lin; @@ -102,6 +106,12 @@ SRSLTE_API void srslte_chest_dl_set_smooth_filter(srslte_chest_dl_t *q, SRSLTE_API void srslte_chest_dl_set_smooth_filter3_coeff(srslte_chest_dl_t* q, float w); +SRSLTE_API void srslte_chest_dl_set_time_ema_coeff(srslte_chest_dl_t *q, + float t); + +SRSLTE_API void srslte_chest_dl_set_average_subframe(srslte_chest_dl_t *q, + bool enable); + SRSLTE_API void srslte_chest_dl_set_noise_alg(srslte_chest_dl_t *q, srslte_chest_dl_noise_alg_t noise_estimation_alg); diff --git a/srslte/lib/ch_estimation/chest_dl.c b/srslte/lib/ch_estimation/chest_dl.c index 7ac4444a0..e550a5305 100644 --- a/srslte/lib/ch_estimation/chest_dl.c +++ b/srslte/lib/ch_estimation/chest_dl.c @@ -39,32 +39,8 @@ #include "srslte/utils/vector.h" #include "srslte/utils/convolution.h" -#define AVERAGE_SUBFRAME - -//#define DEFAULT_FILTER_LEN 3 - -#ifdef DEFAULT_FILTER_LEN -static void set_default_filter(srslte_chest_dl_t *q, int filter_len) { - - float fil[SRSLTE_CHEST_DL_MAX_SMOOTH_FIL_LEN]; - - for (int i=0;ipilot_average_last = srslte_vec_malloc(sizeof(cf_t) * 2 * cell.nof_prb); + if (!q->pilot_average_last) { + perror("malloc"); + goto clean_exit; + } q->pilot_recv_signal = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(cell.nof_prb)); if (!q->pilot_recv_signal) { perror("malloc"); @@ -127,7 +108,14 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell) q->noise_alg = SRSLTE_NOISE_ALG_REFS; - q->smooth_filter_len = 3; + q->time_ema_coeff = 1.0; +#ifdef DEFAULT_TIME_EMA_COEFF + q->time_ema_coeff = DEFAULT_TIME_EMA_COEFF; +#endif + + q->average_subframe = true; + + q->smooth_filter_len = DEFAULT_FILTER_LEN; srslte_chest_dl_set_smooth_filter3_coeff(q, 0.1); q->cell = cell; @@ -158,6 +146,9 @@ void srslte_chest_dl_free(srslte_chest_dl_t *q) if (q->pilot_estimates_average) { free(q->pilot_estimates_average); } + if (q->pilot_average_last) { + free(q->pilot_average_last); + } if (q->pilot_recv_signal) { free(q->pilot_recv_signal); } @@ -233,52 +224,52 @@ static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) { static void interpolate_pilots(srslte_chest_dl_t *q, cf_t *pilot_estimates, cf_t *ce, uint32_t port_id) { -#ifdef AVERAGE_SUBFRAME - // Interpolate symbol 0 in the frequency domain - uint32_t fidx_offset = srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0); - srslte_interp_linear_offset(&q->srslte_interp_lin, pilot_estimates, - &ce[srslte_refsignal_cs_nsymbol(0,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], - fidx_offset, SRSLTE_NRE/2-fidx_offset); - // All channel estimates in the subframe are the same - for (int l=1;l<2*SRSLTE_CP_NSYMB(q->cell.cp);l++) { - memcpy(&ce[l*q->cell.nof_prb*SRSLTE_NRE], ce, q->cell.nof_prb*SRSLTE_NRE*sizeof(cf_t)); - } -#else - uint32_t l=0; - uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); - - // Interpolate in the frequency domain - for (l=0;lcell, l, port_id, 0); - srslte_interp_linear_offset(&q->srslte_interp_lin, &pilot_estimates[2*q->cell.nof_prb*l], - &ce[srslte_refsignal_cs_nsymbol(l,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], - fidx_offset, SRSLTE_NRE/2-fidx_offset); - } - // Interpolate in the time domain between symbols - if (SRSLTE_CP_ISNORM(q->cell.cp)) { - if (nsymbols == 4) { - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(4), &cesymb(1), 4, 3); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(4), &cesymb(7), &cesymb(5), 3, 2); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(7), &cesymb(11), &cesymb(8), 4, 3); - srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(7), &cesymb(11), &cesymb(11), &cesymb(12), 4, 2); - } else { - srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(8), &cesymb(1), &cesymb(1), &cesymb(0), 7, 1); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(8), &cesymb(2), 7, 6); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(8), &cesymb(9), 7, 5); - } + if (q->average_subframe) { + // Interpolate symbol 0 in the frequency domain + uint32_t fidx_offset = srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0); + srslte_interp_linear_offset(&q->srslte_interp_lin, pilot_estimates, + &ce[srslte_refsignal_cs_nsymbol(0,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], + fidx_offset, SRSLTE_NRE/2-fidx_offset); + // All channel estimates in the subframe are the same + for (int l=1;l<2*SRSLTE_CP_NSYMB(q->cell.cp);l++) { + memcpy(&ce[l*q->cell.nof_prb*SRSLTE_NRE], ce, q->cell.nof_prb*SRSLTE_NRE*sizeof(cf_t)); + } } else { - if (nsymbols == 4) { - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(3), &cesymb(1), 3, 2); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(3), &cesymb(6), &cesymb(4), 3, 2); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(6), &cesymb(9), &cesymb(7), 3, 2); - srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(6), &cesymb(9), &cesymb(9), &cesymb(10), 3, 2); + uint32_t l=0; + uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); + + // Interpolate in the frequency domain + for (l=0;lcell, l, port_id, 0); + srslte_interp_linear_offset(&q->srslte_interp_lin, &pilot_estimates[2*q->cell.nof_prb*l], + &ce[srslte_refsignal_cs_nsymbol(l,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], + fidx_offset, SRSLTE_NRE/2-fidx_offset); + } + // Interpolate in the time domain between symbols + if (SRSLTE_CP_ISNORM(q->cell.cp)) { + if (nsymbols == 4) { + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(4), &cesymb(1), 4, 3); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(4), &cesymb(7), &cesymb(5), 3, 2); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(7), &cesymb(11), &cesymb(8), 4, 3); + srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(7), &cesymb(11), &cesymb(11), &cesymb(12), 4, 2); + } else { + srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(8), &cesymb(1), &cesymb(1), &cesymb(0), 7, 1); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(8), &cesymb(2), 7, 6); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(8), &cesymb(9), 7, 5); + } } else { - srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(7), &cesymb(1), &cesymb(1), &cesymb(0), 6, 1); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(2), 6, 5); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(8), 6, 4); - } + if (nsymbols == 4) { + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(3), &cesymb(1), 3, 2); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(3), &cesymb(6), &cesymb(4), 3, 2); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(6), &cesymb(9), &cesymb(7), 3, 2); + srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(6), &cesymb(9), &cesymb(9), &cesymb(10), 3, 2); + } else { + srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(7), &cesymb(1), &cesymb(1), &cesymb(0), 6, 1); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(2), 6, 5); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(8), 6, 4); + } + } } -#endif } void srslte_chest_dl_set_smooth_filter(srslte_chest_dl_t *q, float *filter, uint32_t filter_len) { @@ -307,21 +298,36 @@ void srslte_chest_dl_set_smooth_filter3_coeff(srslte_chest_dl_t* q, float w) q->smooth_filter[1] = 1-2*w; } +void srslte_chest_dl_set_time_ema_coeff(srslte_chest_dl_t *q, float t) { + if (t > 0.0 && t <= 1.0) { + q->time_ema_coeff = t; + } +} + +void srslte_chest_dl_set_average_subframe(srslte_chest_dl_t *q, bool enable) { + q->average_subframe = enable; +} + static void average_pilots(srslte_chest_dl_t *q, cf_t *input, cf_t *output, uint32_t port_id) { uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); uint32_t nref = 2*q->cell.nof_prb; memcpy(output, input, nref*sizeof(cf_t)); for (int l=1;lsmooth_filter, &output[l*nref], nref, q->smooth_filter_len); -#endif + if (q->average_subframe) { + srslte_vec_sum_ccc(output, &input[l*nref], output, nref); + } else { + srslte_conv_same_cf(&input[l*nref], q->smooth_filter, &output[l*nref], nref, q->smooth_filter_len); + } + } + if (q->average_subframe) { + srslte_vec_sc_prod_cfc(output, (float) q->time_ema_coeff/nsymbols, output, nref); + if (q->time_ema_coeff < 1.0) { + srslte_vec_sc_prod_cfc(q->pilot_average_last, 1-q->time_ema_coeff, q->pilot_average_last, nref); + srslte_vec_sum_ccc(q->pilot_average_last, output, output, nref); + memcpy(q->pilot_average_last, output, nref*sizeof(cf_t)); + } } -#ifdef AVERAGE_SUBFRAME - srslte_vec_sc_prod_cfc(output, (float) 1.0/nsymbols, output, nref); -#endif } float srslte_chest_dl_rssi(srslte_chest_dl_t *q, cf_t *input, uint32_t port_id) { From 9d68d0adb42f5fa71ea955b4c9b7e10343ada7b9 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Mon, 29 Aug 2016 17:42:46 +0200 Subject: [PATCH 6/9] Revert "chest_dl: subframe averaging with previous" This reverts commit 82cfa014684d452e71e29936d84a7869a282bc10. --- .../include/srslte/ch_estimation/chest_dl.h | 10 -- srslte/lib/ch_estimation/chest_dl.c | 162 +++++++++--------- 2 files changed, 78 insertions(+), 94 deletions(-) diff --git a/srslte/include/srslte/ch_estimation/chest_dl.h b/srslte/include/srslte/ch_estimation/chest_dl.h index 3aabd2595..a4afa1d84 100644 --- a/srslte/include/srslte/ch_estimation/chest_dl.h +++ b/srslte/include/srslte/ch_estimation/chest_dl.h @@ -63,7 +63,6 @@ typedef struct { srslte_refsignal_cs_t csr_signal; cf_t *pilot_estimates; cf_t *pilot_estimates_average; - cf_t *pilot_average_last; cf_t *pilot_recv_signal; cf_t *tmp_noise; @@ -74,9 +73,6 @@ typedef struct { uint32_t smooth_filter_len; float smooth_filter[SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN]; - float time_ema_coeff; - bool average_subframe; - srslte_interp_linsrslte_vec_t srslte_interp_linvec; srslte_interp_lin_t srslte_interp_lin; @@ -106,12 +102,6 @@ SRSLTE_API void srslte_chest_dl_set_smooth_filter(srslte_chest_dl_t *q, SRSLTE_API void srslte_chest_dl_set_smooth_filter3_coeff(srslte_chest_dl_t* q, float w); -SRSLTE_API void srslte_chest_dl_set_time_ema_coeff(srslte_chest_dl_t *q, - float t); - -SRSLTE_API void srslte_chest_dl_set_average_subframe(srslte_chest_dl_t *q, - bool enable); - SRSLTE_API void srslte_chest_dl_set_noise_alg(srslte_chest_dl_t *q, srslte_chest_dl_noise_alg_t noise_estimation_alg); diff --git a/srslte/lib/ch_estimation/chest_dl.c b/srslte/lib/ch_estimation/chest_dl.c index e550a5305..7ac4444a0 100644 --- a/srslte/lib/ch_estimation/chest_dl.c +++ b/srslte/lib/ch_estimation/chest_dl.c @@ -39,8 +39,32 @@ #include "srslte/utils/vector.h" #include "srslte/utils/convolution.h" -#define DEFAULT_FILTER_LEN 3 -#define DEFAULT_TIME_EMA_COEFF 0.9 +#define AVERAGE_SUBFRAME + +//#define DEFAULT_FILTER_LEN 3 + +#ifdef DEFAULT_FILTER_LEN +static void set_default_filter(srslte_chest_dl_t *q, int filter_len) { + + float fil[SRSLTE_CHEST_DL_MAX_SMOOTH_FIL_LEN]; + + for (int i=0;ipilot_average_last = srslte_vec_malloc(sizeof(cf_t) * 2 * cell.nof_prb); - if (!q->pilot_average_last) { - perror("malloc"); - goto clean_exit; - } q->pilot_recv_signal = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(cell.nof_prb)); if (!q->pilot_recv_signal) { perror("malloc"); @@ -108,14 +127,7 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell) q->noise_alg = SRSLTE_NOISE_ALG_REFS; - q->time_ema_coeff = 1.0; -#ifdef DEFAULT_TIME_EMA_COEFF - q->time_ema_coeff = DEFAULT_TIME_EMA_COEFF; -#endif - - q->average_subframe = true; - - q->smooth_filter_len = DEFAULT_FILTER_LEN; + q->smooth_filter_len = 3; srslte_chest_dl_set_smooth_filter3_coeff(q, 0.1); q->cell = cell; @@ -146,9 +158,6 @@ void srslte_chest_dl_free(srslte_chest_dl_t *q) if (q->pilot_estimates_average) { free(q->pilot_estimates_average); } - if (q->pilot_average_last) { - free(q->pilot_average_last); - } if (q->pilot_recv_signal) { free(q->pilot_recv_signal); } @@ -224,52 +233,52 @@ static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) { static void interpolate_pilots(srslte_chest_dl_t *q, cf_t *pilot_estimates, cf_t *ce, uint32_t port_id) { - if (q->average_subframe) { - // Interpolate symbol 0 in the frequency domain - uint32_t fidx_offset = srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0); - srslte_interp_linear_offset(&q->srslte_interp_lin, pilot_estimates, - &ce[srslte_refsignal_cs_nsymbol(0,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], - fidx_offset, SRSLTE_NRE/2-fidx_offset); - // All channel estimates in the subframe are the same - for (int l=1;l<2*SRSLTE_CP_NSYMB(q->cell.cp);l++) { - memcpy(&ce[l*q->cell.nof_prb*SRSLTE_NRE], ce, q->cell.nof_prb*SRSLTE_NRE*sizeof(cf_t)); - } +#ifdef AVERAGE_SUBFRAME + // Interpolate symbol 0 in the frequency domain + uint32_t fidx_offset = srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0); + srslte_interp_linear_offset(&q->srslte_interp_lin, pilot_estimates, + &ce[srslte_refsignal_cs_nsymbol(0,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], + fidx_offset, SRSLTE_NRE/2-fidx_offset); + // All channel estimates in the subframe are the same + for (int l=1;l<2*SRSLTE_CP_NSYMB(q->cell.cp);l++) { + memcpy(&ce[l*q->cell.nof_prb*SRSLTE_NRE], ce, q->cell.nof_prb*SRSLTE_NRE*sizeof(cf_t)); + } +#else + uint32_t l=0; + uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); + + // Interpolate in the frequency domain + for (l=0;lcell, l, port_id, 0); + srslte_interp_linear_offset(&q->srslte_interp_lin, &pilot_estimates[2*q->cell.nof_prb*l], + &ce[srslte_refsignal_cs_nsymbol(l,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], + fidx_offset, SRSLTE_NRE/2-fidx_offset); + } + // Interpolate in the time domain between symbols + if (SRSLTE_CP_ISNORM(q->cell.cp)) { + if (nsymbols == 4) { + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(4), &cesymb(1), 4, 3); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(4), &cesymb(7), &cesymb(5), 3, 2); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(7), &cesymb(11), &cesymb(8), 4, 3); + srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(7), &cesymb(11), &cesymb(11), &cesymb(12), 4, 2); + } else { + srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(8), &cesymb(1), &cesymb(1), &cesymb(0), 7, 1); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(8), &cesymb(2), 7, 6); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(8), &cesymb(9), 7, 5); + } } else { - uint32_t l=0; - uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); - - // Interpolate in the frequency domain - for (l=0;lcell, l, port_id, 0); - srslte_interp_linear_offset(&q->srslte_interp_lin, &pilot_estimates[2*q->cell.nof_prb*l], - &ce[srslte_refsignal_cs_nsymbol(l,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], - fidx_offset, SRSLTE_NRE/2-fidx_offset); - } - // Interpolate in the time domain between symbols - if (SRSLTE_CP_ISNORM(q->cell.cp)) { - if (nsymbols == 4) { - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(4), &cesymb(1), 4, 3); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(4), &cesymb(7), &cesymb(5), 3, 2); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(7), &cesymb(11), &cesymb(8), 4, 3); - srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(7), &cesymb(11), &cesymb(11), &cesymb(12), 4, 2); - } else { - srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(8), &cesymb(1), &cesymb(1), &cesymb(0), 7, 1); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(8), &cesymb(2), 7, 6); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(8), &cesymb(9), 7, 5); - } + if (nsymbols == 4) { + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(3), &cesymb(1), 3, 2); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(3), &cesymb(6), &cesymb(4), 3, 2); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(6), &cesymb(9), &cesymb(7), 3, 2); + srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(6), &cesymb(9), &cesymb(9), &cesymb(10), 3, 2); } else { - if (nsymbols == 4) { - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(3), &cesymb(1), 3, 2); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(3), &cesymb(6), &cesymb(4), 3, 2); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(6), &cesymb(9), &cesymb(7), 3, 2); - srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(6), &cesymb(9), &cesymb(9), &cesymb(10), 3, 2); - } else { - srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(7), &cesymb(1), &cesymb(1), &cesymb(0), 6, 1); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(2), 6, 5); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(8), 6, 4); - } - } + srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(7), &cesymb(1), &cesymb(1), &cesymb(0), 6, 1); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(2), 6, 5); + srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(8), 6, 4); + } } +#endif } void srslte_chest_dl_set_smooth_filter(srslte_chest_dl_t *q, float *filter, uint32_t filter_len) { @@ -298,36 +307,21 @@ void srslte_chest_dl_set_smooth_filter3_coeff(srslte_chest_dl_t* q, float w) q->smooth_filter[1] = 1-2*w; } -void srslte_chest_dl_set_time_ema_coeff(srslte_chest_dl_t *q, float t) { - if (t > 0.0 && t <= 1.0) { - q->time_ema_coeff = t; - } -} - -void srslte_chest_dl_set_average_subframe(srslte_chest_dl_t *q, bool enable) { - q->average_subframe = enable; -} - static void average_pilots(srslte_chest_dl_t *q, cf_t *input, cf_t *output, uint32_t port_id) { uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); uint32_t nref = 2*q->cell.nof_prb; memcpy(output, input, nref*sizeof(cf_t)); for (int l=1;laverage_subframe) { - srslte_vec_sum_ccc(output, &input[l*nref], output, nref); - } else { - srslte_conv_same_cf(&input[l*nref], q->smooth_filter, &output[l*nref], nref, q->smooth_filter_len); - } - } - if (q->average_subframe) { - srslte_vec_sc_prod_cfc(output, (float) q->time_ema_coeff/nsymbols, output, nref); - if (q->time_ema_coeff < 1.0) { - srslte_vec_sc_prod_cfc(q->pilot_average_last, 1-q->time_ema_coeff, q->pilot_average_last, nref); - srslte_vec_sum_ccc(q->pilot_average_last, output, output, nref); - memcpy(q->pilot_average_last, output, nref*sizeof(cf_t)); - } +#ifdef AVERAGE_SUBFRAME + srslte_vec_sum_ccc(output, &input[l*nref], output, nref); +#else + srslte_conv_same_cf(&input[l*nref], q->smooth_filter, &output[l*nref], nref, q->smooth_filter_len); +#endif } +#ifdef AVERAGE_SUBFRAME + srslte_vec_sc_prod_cfc(output, (float) 1.0/nsymbols, output, nref); +#endif } float srslte_chest_dl_rssi(srslte_chest_dl_t *q, cf_t *input, uint32_t port_id) { From 4f7b372711f4a31d13bb05cb553b020d9c185463 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Mon, 29 Aug 2016 17:43:04 +0200 Subject: [PATCH 7/9] Revert "psdch_ue: disabled agc by default. Set default gain to 70 dB" This reverts commit 58d955ea10d67e0407cdd01def3aef65a34d2944. --- srslte/examples/pdsch_ue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srslte/examples/pdsch_ue.c b/srslte/examples/pdsch_ue.c index e347f0e71..8c986ab75 100644 --- a/srslte/examples/pdsch_ue.c +++ b/srslte/examples/pdsch_ue.c @@ -39,7 +39,7 @@ #include "srslte/srslte.h" -//#define ENABLE_AGC_DEFAULT +#define ENABLE_AGC_DEFAULT #ifndef DISABLE_RF #include "srslte/rf/rf.h" @@ -116,7 +116,7 @@ void args_default(prog_args_t *args) { #ifdef ENABLE_AGC_DEFAULT args->rf_gain = -1.0; #else - args->rf_gain = 70.0; + args->rf_gain = 50.0; #endif args->net_port = -1; args->net_address = "127.0.0.1"; From 850259e2f704a5c9fabb801a69111a9de2409f50 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Mon, 29 Aug 2016 17:43:07 +0200 Subject: [PATCH 8/9] Revert "ue_sync: set default offset correction interval to 0. chest_dl: added option to average estimates per subframe" This reverts commit 10cbb9ad920191f9c74e44123e059e92747e9f55. --- matlab/tests/equalizer_test.m | 21 +++++++----- matlab/tests/pdsch_equal.m | 3 +- srslte/examples/pdsch_ue.c | 2 -- srslte/lib/ch_estimation/chest_dl.c | 52 ++++++++--------------------- srslte/lib/ue/ue_sync.c | 22 ++++++------ 5 files changed, 38 insertions(+), 62 deletions(-) diff --git a/matlab/tests/equalizer_test.m b/matlab/tests/equalizer_test.m index 5cd7e3353..1391d5e53 100644 --- a/matlab/tests/equalizer_test.m +++ b/matlab/tests/equalizer_test.m @@ -6,13 +6,13 @@ clear plot_noise_estimation_only=false; -SNR_values_db=linspace(0,20,8); -Nrealizations=10; +SNR_values_db=100;%linspace(20,35,8); +Nrealizations=1; w1=0.1; w2=0.3; -enb.NDLRB = 25; % Number of resource blocks +enb.NDLRB = 6; % Number of resource blocks enb.CellRefP = 1; % One transmit antenna port enb.NCellID = 0; % Cell ID @@ -181,8 +181,8 @@ for i=1:10 rxGrid_sf = rxGrid(:,(i-1)*14+1:i*14); %% Channel Estimation with Matlab - [hest{1}(:,(1:14)+(i-1)*14), tmpnoise{1}(i)] = ... - lteDLChannelEstimate(enb,cec,rxGrid_sf); + [hest{1}(:,(1:14)+(i-1)*14), tmpnoise{1}(i), hls(:,(1:4*P)+(i-1)*4*P)] = ... + lteDLChannelEstimate2(enb,cec,rxGrid_sf); tmpnoise{1}(i)=tmpnoise{1}(i)*sqrt(2)*enb.CellRefP; %% LS-Linear estimation with srsLTE @@ -227,12 +227,17 @@ if (length(SNR_values_db) == 1) tmp{Ntests+1}='Real'; legend(tmp) - xlabel('Sample') + xlabel('SNR (dB)') ylabel('Channel Gain') grid on; -% fprintf('Mean MMSE Robust %.2f dB\n', 10*log10(MSE(4,nreal,snr_idx))) -% fprintf('Mean MMSE matlab %.2f dB\n', 10*log10(MSE(1,nreal,snr_idx))) + fprintf('Mean MMSE Robust %.2f dB\n', 10*log10(MSE(4,nreal,snr_idx))) + fprintf('Mean MMSE matlab %.2f dB\n', 10*log10(MSE(1,nreal,snr_idx))) +<<<<<<< HEAD + +======= + +>>>>>>> master end end diff --git a/matlab/tests/pdsch_equal.m b/matlab/tests/pdsch_equal.m index 08722b3bd..665ff8047 100644 --- a/matlab/tests/pdsch_equal.m +++ b/matlab/tests/pdsch_equal.m @@ -116,7 +116,7 @@ for snr_idx=1:length(SNR_values) rmccFgOut.TotSubframes=1; % Perform channel estimation - [hest, nest] = lteDLChannelEstimate(rmccFgOut, cec, subframe_rx); + [hest, nest,estimates] = lteDLChannelEstimate2(rmccFgOut, cec, subframe_rx); [cws,symbols] = ltePDSCHDecode(rmccFgOut,rmccFgOut.PDSCH,subframe_rx,hest,nest); [trblkout,blkcrc,dstate] = lteDLSCHDecode(rmccFgOut,rmccFgOut.PDSCH, ... @@ -156,7 +156,6 @@ if (length(SNR_values)>1) axis([min(SNR_values) max(SNR_values) 1/Npackets/(Nsf+1) 1]) else scatter(real(symbols{1}),imag(symbols{1})) - plot( fprintf('Matlab: %d OK\nsrsLTE: %d OK\n',decoded, decoded_srslte); end diff --git a/srslte/examples/pdsch_ue.c b/srslte/examples/pdsch_ue.c index 8c986ab75..b0a9c5fd6 100644 --- a/srslte/examples/pdsch_ue.c +++ b/srslte/examples/pdsch_ue.c @@ -583,13 +583,11 @@ int main(int argc, char **argv) { sfn++; if (sfn == 1024) { sfn = 0; - /* printf("\n"); ue_dl.pkt_errors = 0; ue_dl.pkts_total = 0; ue_dl.nof_detected = 0; nof_trials = 0; - */ } } diff --git a/srslte/lib/ch_estimation/chest_dl.c b/srslte/lib/ch_estimation/chest_dl.c index 7ac4444a0..beb7518d2 100644 --- a/srslte/lib/ch_estimation/chest_dl.c +++ b/srslte/lib/ch_estimation/chest_dl.c @@ -39,8 +39,6 @@ #include "srslte/utils/vector.h" #include "srslte/utils/convolution.h" -#define AVERAGE_SUBFRAME - //#define DEFAULT_FILTER_LEN 3 #ifdef DEFAULT_FILTER_LEN @@ -167,18 +165,7 @@ void srslte_chest_dl_free(srslte_chest_dl_t *q) /* Uses the difference between the averaged and non-averaged pilot estimates */ static float estimate_noise_pilots(srslte_chest_dl_t *q, uint32_t port_id) { - float norm = sqrt(2); -#ifdef AVERAGE_SUBFRAME - int nref=2*q->cell.nof_prb; -#else int nref=SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id); - if (q->smooth_filter_len == 3) { - float a = q->smooth_filter[0]; - float norm3 = 6.143*a*a+0.04859*a-0.002774; - norm /= norm3; - } -#endif - /* Substract noisy pilot estimates */ srslte_vec_sub_ccc(q->pilot_estimates_average, q->pilot_estimates, q->tmp_noise, nref); @@ -192,6 +179,12 @@ static float estimate_noise_pilots(srslte_chest_dl_t *q, uint32_t port_id) #endif /* Compute average power. Normalized for filter len 3 using matlab */ + float norm = 1; + if (q->smooth_filter_len == 3) { + float a = q->smooth_filter[0]; + float norm3 = 6.143*a*a+0.04859*a-0.002774; + norm /= norm3; + } float power = norm*q->cell.nof_ports*srslte_vec_avg_power_cf(q->tmp_noise, nref); return power; } @@ -232,29 +225,19 @@ static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) { static void interpolate_pilots(srslte_chest_dl_t *q, cf_t *pilot_estimates, cf_t *ce, uint32_t port_id) { - -#ifdef AVERAGE_SUBFRAME - // Interpolate symbol 0 in the frequency domain - uint32_t fidx_offset = srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0); - srslte_interp_linear_offset(&q->srslte_interp_lin, pilot_estimates, - &ce[srslte_refsignal_cs_nsymbol(0,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], - fidx_offset, SRSLTE_NRE/2-fidx_offset); - // All channel estimates in the subframe are the same - for (int l=1;l<2*SRSLTE_CP_NSYMB(q->cell.cp);l++) { - memcpy(&ce[l*q->cell.nof_prb*SRSLTE_NRE], ce, q->cell.nof_prb*SRSLTE_NRE*sizeof(cf_t)); - } -#else - uint32_t l=0; + /* interpolate the symbols with references in the freq domain */ + uint32_t l; uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); - - // Interpolate in the frequency domain + + /* Interpolate in the frequency domain */ for (l=0;lcell, l, port_id, 0); srslte_interp_linear_offset(&q->srslte_interp_lin, &pilot_estimates[2*q->cell.nof_prb*l], &ce[srslte_refsignal_cs_nsymbol(l,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], fidx_offset, SRSLTE_NRE/2-fidx_offset); } - // Interpolate in the time domain between symbols + + /* Now interpolate in the time domain between symbols */ if (SRSLTE_CP_ISNORM(q->cell.cp)) { if (nsymbols == 4) { srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(4), &cesymb(1), 4, 3); @@ -278,7 +261,6 @@ static void interpolate_pilots(srslte_chest_dl_t *q, cf_t *pilot_estimates, cf_t srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(8), 6, 4); } } -#endif } void srslte_chest_dl_set_smooth_filter(srslte_chest_dl_t *q, float *filter, uint32_t filter_len) { @@ -311,17 +293,9 @@ static void average_pilots(srslte_chest_dl_t *q, cf_t *input, cf_t *output, uint uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); uint32_t nref = 2*q->cell.nof_prb; - memcpy(output, input, nref*sizeof(cf_t)); - for (int l=1;lsmooth_filter, &output[l*nref], nref, q->smooth_filter_len); -#endif } -#ifdef AVERAGE_SUBFRAME - srslte_vec_sc_prod_cfc(output, (float) 1.0/nsymbols, output, nref); -#endif } float srslte_chest_dl_rssi(srslte_chest_dl_t *q, cf_t *input, uint32_t port_id) { diff --git a/srslte/lib/ue/ue_sync.c b/srslte/lib/ue/ue_sync.c index a81004ef0..d04c5c303 100644 --- a/srslte/lib/ue/ue_sync.c +++ b/srslte/lib/ue/ue_sync.c @@ -44,7 +44,7 @@ cf_t dummy[MAX_TIME_OFFSET]; #define TRACK_MAX_LOST 4 #define TRACK_FRAME_SIZE 32 #define FIND_NOF_AVG_FRAMES 4 -#define DEFAULT_SAMPLE_OFFSET_CORRECT_PERIOD 0 +#define DEFAULT_SAMPLE_OFFSET_CORRECT_PERIOD 5 #define DEFAULT_SFO_EMA_COEFF 0.1 cf_t dummy_offset_buffer[1024*1024]; @@ -358,6 +358,7 @@ static int track_peak_ok(srslte_ue_sync_t *q, uint32_t track_idx) { { INFO("Warning: Expected SF idx %d but got %d! (%d frames)\n", q->sf_idx, srslte_sync_get_sf_idx(&q->strack), q->frame_no_cnt); + q->sf_idx = srslte_sync_get_sf_idx(&q->strack); q->frame_no_cnt++; if (q->frame_no_cnt >= TRACK_MAX_LOST) { INFO("\n%d frames lost. Going back to FIND\n", (int) q->frame_no_cnt); @@ -381,19 +382,18 @@ static int track_peak_ok(srslte_ue_sync_t *q, uint32_t track_idx) { // Compute cumulative moving average time offset */ if (!frame_idx) { - if (q->sample_offset_correct_period) { - // Adjust RF sampling time based on the mean sampling offset - q->next_rf_sample_offset = (int) round(q->mean_sample_offset); - // Reset PSS averaging if correcting every a period longer than 1 - if (q->sample_offset_correct_period > 1) { - srslte_sync_reset(&q->strack); - } + // Adjust RF sampling time based on the mean sampling offset + q->next_rf_sample_offset = (int) round(q->mean_sample_offset); + + // Reset PSS averaging if correcting every a period longer than 1 + if (q->sample_offset_correct_period > 1) { + srslte_sync_reset(&q->strack); + } + // Compute SFO based on mean sample offset + if (q->sample_offset_correct_period) { q->mean_sample_offset /= q->sample_offset_correct_period; - } else { - q->next_rf_sample_offset = q->last_sample_offset; } - q->mean_sfo = SRSLTE_VEC_EMA(q->mean_sample_offset, q->mean_sfo, q->sfo_ema); INFO("Time offset adjustment: %d samples (%.2f), mean SFO: %.2f Hz, %.5f samples/5-sf, ema=%f, length=%d\n", From ded17137b0c3d6b58c752209736ed8663f088c89 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 30 Aug 2016 00:49:31 +0200 Subject: [PATCH 9/9] fixed bugs from coverty analysis --- matlab/tests/equalizer_test.m | 17 ++---- matlab/tests/pdsch_decode_signal.m | 9 ++- matlab/tests/pdsch_equal.m | 11 +++- srslte/examples/pdsch_ue.c | 7 +-- srslte/include/srslte/dft/dft_precoding.h | 4 +- srslte/lib/ch_estimation/chest_dl.c | 1 + srslte/lib/ch_estimation/chest_ul.c | 6 +- srslte/lib/ch_estimation/refsignal_ul.c | 60 +++++++++++-------- srslte/lib/ch_estimation/test/chest_test_ul.c | 2 +- srslte/lib/fec/convcoder.c | 2 +- srslte/lib/fec/parity.c | 2 +- srslte/lib/phch/cqi.c | 17 ++++-- srslte/lib/phch/dci.c | 4 +- srslte/lib/phch/pdcch.c | 53 ++++++++-------- srslte/lib/phch/pdsch.c | 27 +++++---- srslte/lib/phch/prach.c | 28 ++++++--- srslte/lib/phch/pucch.c | 4 +- srslte/lib/phch/ra.c | 5 +- srslte/lib/phch/regs.c | 10 +++- srslte/lib/phch/sch.c | 4 +- srslte/lib/phch/test/pdsch_test_mex.c | 4 +- srslte/lib/rf/rf_blade_imp.c | 5 +- srslte/lib/rf/rf_uhd_imp.c | 2 + srslte/lib/sync/cfo.c | 2 +- srslte/lib/sync/pss.c | 2 + srslte/lib/sync/sss.c | 13 ++-- srslte/lib/sync/sync.c | 9 ++- srslte/lib/ue/ue_sync.c | 3 +- srslte/lib/ue/ue_ul.c | 4 +- 29 files changed, 189 insertions(+), 128 deletions(-) diff --git a/matlab/tests/equalizer_test.m b/matlab/tests/equalizer_test.m index 1391d5e53..816a29957 100644 --- a/matlab/tests/equalizer_test.m +++ b/matlab/tests/equalizer_test.m @@ -6,11 +6,11 @@ clear plot_noise_estimation_only=false; -SNR_values_db=100;%linspace(20,35,8); -Nrealizations=1; +SNR_values_db=linspace(0,30,8); +Nrealizations=10; w1=0.1; -w2=0.3; +w2=0.2; enb.NDLRB = 6; % Number of resource blocks @@ -55,7 +55,7 @@ L = gridsize(2); % Number of OFDM symbols in one subframe Ports = gridsize(3); % Number of transmit antenna ports %% Allocate memory -Ntests=2; +Ntests=4; hest=cell(1,Ntests); tmpnoise=cell(1,Ntests); for i=1:Ntests @@ -181,8 +181,8 @@ for i=1:10 rxGrid_sf = rxGrid(:,(i-1)*14+1:i*14); %% Channel Estimation with Matlab - [hest{1}(:,(1:14)+(i-1)*14), tmpnoise{1}(i), hls(:,(1:4*P)+(i-1)*4*P)] = ... - lteDLChannelEstimate2(enb,cec,rxGrid_sf); + [hest{1}(:,(1:14)+(i-1)*14), tmpnoise{1}(i)] = ... + lteDLChannelEstimate(enb,cec,rxGrid_sf); tmpnoise{1}(i)=tmpnoise{1}(i)*sqrt(2)*enb.CellRefP; %% LS-Linear estimation with srsLTE @@ -233,11 +233,6 @@ if (length(SNR_values_db) == 1) fprintf('Mean MMSE Robust %.2f dB\n', 10*log10(MSE(4,nreal,snr_idx))) fprintf('Mean MMSE matlab %.2f dB\n', 10*log10(MSE(1,nreal,snr_idx))) -<<<<<<< HEAD - -======= - ->>>>>>> master end end diff --git a/matlab/tests/pdsch_decode_signal.m b/matlab/tests/pdsch_decode_signal.m index d376c5c3f..72b733eb5 100644 --- a/matlab/tests/pdsch_decode_signal.m +++ b/matlab/tests/pdsch_decode_signal.m @@ -1,6 +1,6 @@ -enb=struct('NCellID',137,'NDLRB',50,'NSubframe',8,'CFI',1,'CyclicPrefix','Normal','CellRefP',2,'Ng','One','PHICHDuration','Normal','DuplexMode','FDD'); +enb=struct('NCellID',313,'NDLRB',75,'NSubframe',5,'CFI',1,'CyclicPrefix','Normal','CellRefP',2,'Ng','One','PHICHDuration','Normal','DuplexMode','FDD'); -RNTI=5; +RNTI=65535; addpath('../../build/srslte/lib/phch/test') @@ -44,12 +44,15 @@ if ~isempty(dci) [sib1, crc] = lteDLSCHDecode(enb, pdsch, trblklen, dlschBits); - [dec2, data, pdschRx2, pdschSymbols2, e_bits] = srslte_pdsch(enb, pdsch, ... + [dec2, data, pdschRx2, pdschSymbols2, e_bits, ce] = srslte_pdsch(enb, pdsch, ... trblklen, ... subframe_rx); + subplot(2,1,1) scatter(real(pdschSymbols{1}),imag(pdschSymbols{1})) + subplot(2,1,2) + scatter(real(pdschSymbols2),imag(pdschSymbols2)) if crc == 0 fprintf('PDSCH Matlab OK.\n\n'); diff --git a/matlab/tests/pdsch_equal.m b/matlab/tests/pdsch_equal.m index 665ff8047..1ad1d86dc 100644 --- a/matlab/tests/pdsch_equal.m +++ b/matlab/tests/pdsch_equal.m @@ -116,7 +116,7 @@ for snr_idx=1:length(SNR_values) rmccFgOut.TotSubframes=1; % Perform channel estimation - [hest, nest,estimates] = lteDLChannelEstimate2(rmccFgOut, cec, subframe_rx); + [hest, nest] = lteDLChannelEstimate(rmccFgOut, cec, subframe_rx); [cws,symbols] = ltePDSCHDecode(rmccFgOut,rmccFgOut.PDSCH,subframe_rx,hest,nest); [trblkout,blkcrc,dstate] = lteDLSCHDecode(rmccFgOut,rmccFgOut.PDSCH, ... @@ -127,7 +127,7 @@ for snr_idx=1:length(SNR_values) %% Same with srsLTE if (rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1) > 0) - [dec2, data, pdschRx, pdschSymbols2, cws2] = srslte_pdsch(rmccFgOut, rmccFgOut.PDSCH, ... + [dec2, data, pdschRx, pdschSymbols2, cws2, ce] = srslte_pdsch(rmccFgOut, rmccFgOut.PDSCH, ... rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1), ... subframe_rx); else @@ -155,7 +155,12 @@ if (length(SNR_values)>1) ylabel('BLER') axis([min(SNR_values) max(SNR_values) 1/Npackets/(Nsf+1) 1]) else - scatter(real(symbols{1}),imag(symbols{1})) + subplot(2,1,1) + scatter(real(pdschSymbols2),imag(pdschSymbols2)) + %plot(real(hest)) + subplot(2,1,2) + %plot(1:180,angle(ce(1:180)),1:180,angle(hest(:,1))) + plot(abs(ce-hest(:))) fprintf('Matlab: %d OK\nsrsLTE: %d OK\n',decoded, decoded_srslte); end diff --git a/srslte/examples/pdsch_ue.c b/srslte/examples/pdsch_ue.c index b0a9c5fd6..f8cf033a9 100644 --- a/srslte/examples/pdsch_ue.c +++ b/srslte/examples/pdsch_ue.c @@ -512,13 +512,12 @@ int main(int argc, char **argv) { srslte_ue_sync_get_sfidx(&ue_sync), SRSLTE_SIRNTI, rv); - /* - if (!n) { + if (n>0) { printf("Saving signal...\n"); - srslte_ue_dl_save_signal(&ue_dl, &ue_dl.softbuffer, sfn*10+srslte_ue_sync_get_sfidx(&ue_sync), rv); + srslte_ue_dl_save_signal(&ue_dl, &ue_dl.softbuffer, sfn*10+srslte_ue_sync_get_sfidx(&ue_sync), rv, prog_args.rnti); exit(-1); } - */ + } if (n < 0) { // fprintf(stderr, "Error decoding UE DL\n");fflush(stdout); diff --git a/srslte/include/srslte/dft/dft_precoding.h b/srslte/include/srslte/dft/dft_precoding.h index eac79e6c8..e860e5b7b 100644 --- a/srslte/include/srslte/dft/dft_precoding.h +++ b/srslte/include/srslte/dft/dft_precoding.h @@ -44,8 +44,8 @@ typedef struct SRSLTE_API { uint32_t max_prb; - srslte_dft_plan_t dft_plan[SRSLTE_MAX_PRB]; - srslte_dft_plan_t idft_plan[SRSLTE_MAX_PRB]; + srslte_dft_plan_t dft_plan[SRSLTE_MAX_PRB+1]; + srslte_dft_plan_t idft_plan[SRSLTE_MAX_PRB+1]; }srslte_dft_precoding_t; diff --git a/srslte/lib/ch_estimation/chest_dl.c b/srslte/lib/ch_estimation/chest_dl.c index beb7518d2..541f98646 100644 --- a/srslte/lib/ch_estimation/chest_dl.c +++ b/srslte/lib/ch_estimation/chest_dl.c @@ -293,6 +293,7 @@ static void average_pilots(srslte_chest_dl_t *q, cf_t *input, cf_t *output, uint uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); uint32_t nref = 2*q->cell.nof_prb; + // Average in the frequency domain for (int l=0;lsmooth_filter, &output[l*nref], nref, q->smooth_filter_len); } diff --git a/srslte/lib/ch_estimation/chest_ul.c b/srslte/lib/ch_estimation/chest_ul.c index 4286854c0..c61e88c7d 100644 --- a/srslte/lib/ch_estimation/chest_ul.c +++ b/srslte/lib/ch_estimation/chest_ul.c @@ -91,11 +91,11 @@ int srslte_chest_ul_init(srslte_chest_ul_t *q, srslte_cell_t cell) q->smooth_filter_len = 3; srslte_chest_ul_set_smooth_filter3_coeff(q, 0.3333); - - } - q->dmrs_signal_configured = false; + q->dmrs_signal_configured = false; + } + ret = SRSLTE_SUCCESS; clean_exit: diff --git a/srslte/lib/ch_estimation/refsignal_ul.c b/srslte/lib/ch_estimation/refsignal_ul.c index 3c7dcfb02..30aa7da08 100644 --- a/srslte/lib/ch_estimation/refsignal_ul.c +++ b/srslte/lib/ch_estimation/refsignal_ul.c @@ -177,6 +177,8 @@ int srslte_refsignal_ul_init(srslte_refsignal_ul_t * q, srslte_cell_t cell) if (q != NULL && srslte_cell_isvalid(&cell)) { + ret = SRSLTE_ERROR; + bzero(q, sizeof(srslte_refsignal_ul_t)); q->cell = cell; @@ -275,11 +277,13 @@ static uint32_t get_q(uint32_t u, uint32_t v, uint32_t N_sz) { static void arg_r_uv_mprb(float *arg, uint32_t M_sc, uint32_t u, uint32_t v) { uint32_t N_sz = largest_prime_lower_than(M_sc); - float q = get_q(u,v,N_sz); - float n_sz = (float) N_sz; - for (uint32_t i = 0; i < M_sc; i++) { - float m = (float) (i%N_sz); - arg[i] = -M_PI * q * m * (m + 1) / n_sz; + if (N_sz > 0) { + float q = get_q(u,v,N_sz); + float n_sz = (float) N_sz; + for (uint32_t i = 0; i < M_sc; i++) { + float m = (float) (i%N_sz); + arg[i] = -M_PI * q * m * (m + 1) / n_sz; + } } } @@ -478,29 +482,35 @@ static uint32_t get_pucch_dmrs_symbol(uint32_t m, srslte_pucch_format_t format, case SRSLTE_PUCCH_FORMAT_1A: case SRSLTE_PUCCH_FORMAT_1B: if (SRSLTE_CP_ISNORM(cp)) { - if (m < 4) { + if (m < 3) { return pucch_dmrs_symbol_format1_cpnorm[m]; } } else { - if (m < 3) { + if (m < 2) { return pucch_dmrs_symbol_format1_cpext[m]; } } + break; case SRSLTE_PUCCH_FORMAT_2: if (SRSLTE_CP_ISNORM(cp)) { - if (m < 3) { + if (m < 2) { return pucch_dmrs_symbol_format2_cpnorm[m]; } } else { - if (m < 2) { + if (m < 1) { return pucch_dmrs_symbol_format2_cpext[m]; } } + break; case SRSLTE_PUCCH_FORMAT_2A: case SRSLTE_PUCCH_FORMAT_2B: - if (m < 3) { + if (m < 2) { return pucch_dmrs_symbol_format2_cpnorm[m]; } + break; + default: + fprintf(stderr, "Unsupported format %d\n", format); + return 0; } return 0; } @@ -759,21 +769,23 @@ uint32_t srslte_refsignal_srs_rb_L_cs(uint32_t bw_cfg, uint32_t nof_prb) { } uint32_t srs_Fb(srslte_refsignal_srs_cfg_t *cfg, uint32_t b, uint32_t nof_prb, uint32_t tti) { - uint32_t n_srs = tti/T_srs_table(cfg->I_srs); - uint32_t N_b = Nb[srsbwtable_idx(nof_prb)][b][cfg->bw_cfg]; - - uint32_t prod_1=1; - for (uint32_t bp=cfg->b_hop+1;bpbw_cfg]; - } - uint32_t prod_2 = prod_1*Nb[srsbwtable_idx(nof_prb)][b][cfg->bw_cfg]; - uint32_t Fb; - if ((N_b%2) == 0) { - Fb = (N_b/2)*((n_srs%prod_2)/prod_1)+((n_srs%prod_2)/prod_1/2); - } else { - Fb = (N_b/2)*(n_srs/prod_1); + uint32_t Fb = 0; + uint32_t T = T_srs_table(cfg->I_srs); + if (T) { + uint32_t n_srs = tti/T; + uint32_t N_b = Nb[srsbwtable_idx(nof_prb)][b][cfg->bw_cfg]; + + uint32_t prod_1=1; + for (uint32_t bp=cfg->b_hop+1;bpbw_cfg]; + } + uint32_t prod_2 = prod_1*Nb[srsbwtable_idx(nof_prb)][b][cfg->bw_cfg]; + if ((N_b%2) == 0) { + Fb = (N_b/2)*((n_srs%prod_2)/prod_1)+((n_srs%prod_2)/prod_1/2); + } else { + Fb = (N_b/2)*(n_srs/prod_1); + } } - return Fb; } diff --git a/srslte/lib/ch_estimation/test/chest_test_ul.c b/srslte/lib/ch_estimation/test/chest_test_ul.c index 93953dcbc..b3b2331da 100644 --- a/srslte/lib/ch_estimation/test/chest_test_ul.c +++ b/srslte/lib/ch_estimation/test/chest_test_ul.c @@ -178,7 +178,7 @@ int main(int argc, char **argv) { /* Generate random input */ bzero(input, sizeof(cf_t) * num_re); for (i=0;itail_biting ? frame_length : (frame_length + q->K - 1); if (q != NULL && input != NULL && output != NULL && frame_length > q->K + 1) { + uint32_t len = q->tail_biting ? frame_length : (frame_length + q->K - 1); if (q->tail_biting) { sr = 0; for (i=frame_length - q->K + 1; i>= 1; + ti >>= 1; } Partab[i] = cnt & 1; } diff --git a/srslte/lib/phch/cqi.c b/srslte/lib/phch/cqi.c index a19060961..df46152b0 100644 --- a/srslte/lib/phch/cqi.c +++ b/srslte/lib/phch/cqi.c @@ -129,12 +129,12 @@ bool srslte_cqi_send(uint32_t I_cqi_pmi, uint32_t tti) { } else if (I_cqi_pmi <= 1023) { return false; } - - if ((tti-N_offset)%N_p == 0) { - return true; - } else { - return false; + if (N_p) { + if ((tti-N_offset)%N_p == 0) { + return true; + } } + return false; } @@ -181,5 +181,10 @@ int srslte_cqi_hl_get_subband_size(int nof_prb) */ int srslte_cqi_hl_get_no_subbands(int nof_prb) { - return (int)ceil(nof_prb/(float)srslte_cqi_hl_get_subband_size(nof_prb)); + int hl_size = srslte_cqi_hl_get_subband_size(nof_prb); + if (hl_size > 0) { + return (int)ceil((float)nof_prb/hl_size); + } else { + return 0; + } } diff --git a/srslte/lib/phch/dci.c b/srslte/lib/phch/dci.c index b4262f857..276768c67 100644 --- a/srslte/lib/phch/dci.c +++ b/srslte/lib/phch/dci.c @@ -170,7 +170,7 @@ int srslte_dci_msg_to_ul_grant(srslte_dci_msg_t *msg, uint32_t nof_prb, ret = SRSLTE_ERROR; bzero(ul_dci, sizeof(srslte_ra_ul_dci_t)); - bzero(grant, sizeof(srslte_ra_ul_dci_t)); + bzero(grant, sizeof(srslte_ra_ul_grant_t)); if (srslte_dci_msg_unpack_pusch(msg, ul_dci, nof_prb)) { return ret; @@ -392,7 +392,7 @@ uint32_t srslte_dci_format_sizeof(srslte_dci_format_t format, uint32_t nof_prb, } uint32_t srslte_dci_format_sizeof_lut(srslte_dci_format_t format, uint32_t nof_prb) { - if (nof_prb <= 100 && format < 11) { + if (nof_prb < 101 && format < 4) { return dci_sz_table[nof_prb][format]; } else { return 0; diff --git a/srslte/lib/phch/pdcch.c b/srslte/lib/phch/pdcch.c index 8a67f8d0f..d0db566eb 100644 --- a/srslte/lib/phch/pdcch.c +++ b/srslte/lib/phch/pdcch.c @@ -275,33 +275,36 @@ int srslte_pdcch_dci_decode(srslte_pdcch_t *q, float *e, uint8_t *data, uint32_t uint16_t p_bits, crc_res; uint8_t *x; - if (q != NULL && - data != NULL && - E <= q->max_bits && - nof_bits <= SRSLTE_DCI_MAX_BITS) - { - bzero(q->rm_f, sizeof(float)*3 * (SRSLTE_DCI_MAX_BITS + 16)); - - uint32_t coded_len = 3 * (nof_bits + 16); - - /* unrate matching */ - srslte_rm_conv_rx(e, E, q->rm_f, coded_len); - - /* viterbi decoder */ - srslte_viterbi_decode_f(&q->decoder, q->rm_f, data, nof_bits + 16); + if (q != NULL) { + if (data != NULL && + E <= q->max_bits && + nof_bits <= SRSLTE_DCI_MAX_BITS) + { + bzero(q->rm_f, sizeof(float)*3 * (SRSLTE_DCI_MAX_BITS + 16)); + + uint32_t coded_len = 3 * (nof_bits + 16); + + /* unrate matching */ + srslte_rm_conv_rx(e, E, q->rm_f, coded_len); + + /* viterbi decoder */ + srslte_viterbi_decode_f(&q->decoder, q->rm_f, data, nof_bits + 16); - x = &data[nof_bits]; - p_bits = (uint16_t) srslte_bit_pack(&x, 16); - crc_res = ((uint16_t) srslte_crc_checksum(&q->crc, data, nof_bits) & 0xffff); - - if (crc) { - *crc = p_bits ^ crc_res; + x = &data[nof_bits]; + p_bits = (uint16_t) srslte_bit_pack(&x, 16); + crc_res = ((uint16_t) srslte_crc_checksum(&q->crc, data, nof_bits) & 0xffff); + + if (crc) { + *crc = p_bits ^ crc_res; + } + + return SRSLTE_SUCCESS; + } else { + fprintf(stderr, "Invalid parameters: E: %d, max_bits: %d, nof_bits: %d\n", E, q->max_bits, nof_bits); + return SRSLTE_ERROR_INVALID_INPUTS; } - - return SRSLTE_SUCCESS; } else { - fprintf(stderr, "Invalid parameters: E: %d, max_bits: %d, nof_bits: %d\n", E, q->max_bits, nof_bits); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSLTE_ERROR_INVALID_INPUTS; } } @@ -525,7 +528,7 @@ int srslte_pdcch_encode(srslte_pdcch_t *q, srslte_dci_msg_t *msg, srslte_dci_loc ret = SRSLTE_ERROR; if (location.ncce + PDCCH_FORMAT_NOF_CCE(location.L) <= q->nof_cce && - msg->nof_bits < SRSLTE_DCI_MAX_BITS) + msg->nof_bits < SRSLTE_DCI_MAX_BITS - 16) { DEBUG("Encoding DCI: Nbits: %d, E: %d, nCCE: %d, L: %d, RNTI: 0x%x\n", msg->nof_bits, e_bits, location.ncce, location.L, rnti); diff --git a/srslte/lib/phch/pdsch.c b/srslte/lib/phch/pdsch.c index 10b50bf43..174b8715a 100644 --- a/srslte/lib/phch/pdsch.c +++ b/srslte/lib/phch/pdsch.c @@ -316,19 +316,22 @@ void srslte_pdsch_free(srslte_pdsch_t *q) { */ int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg, srslte_cell_t cell, srslte_ra_dl_grant_t *grant, uint32_t cfi, uint32_t sf_idx, uint32_t rvidx) { - - if (cfg && grant) { - memcpy(&cfg->grant, grant, sizeof(srslte_ra_dl_grant_t)); - } - if (srslte_cbsegm(&cfg->cb_segm, cfg->grant.mcs.tbs)) { - fprintf(stderr, "Error computing Codeblock segmentation for TBS=%d\n", cfg->grant.mcs.tbs); - return SRSLTE_ERROR; - } - srslte_ra_dl_grant_to_nbits(&cfg->grant, cfi, cell, sf_idx, &cfg->nbits); - cfg->sf_idx = sf_idx; - cfg->rv = rvidx; + if (cfg) { + if (grant) { + memcpy(&cfg->grant, grant, sizeof(srslte_ra_dl_grant_t)); + } + if (srslte_cbsegm(&cfg->cb_segm, cfg->grant.mcs.tbs)) { + fprintf(stderr, "Error computing Codeblock segmentation for TBS=%d\n", cfg->grant.mcs.tbs); + return SRSLTE_ERROR; + } + srslte_ra_dl_grant_to_nbits(&cfg->grant, cfi, cell, sf_idx, &cfg->nbits); + cfg->sf_idx = sf_idx; + cfg->rv = rvidx; - return SRSLTE_SUCCESS; + return SRSLTE_SUCCESS; + } else { + return SRSLTE_ERROR_INVALID_INPUTS; + } } diff --git a/srslte/lib/phch/prach.c b/srslte/lib/phch/prach.c index cf47babc5..39114ec8e 100644 --- a/srslte/lib/phch/prach.c +++ b/srslte/lib/phch/prach.c @@ -264,7 +264,7 @@ int srslte_prach_gen_seqs(srslte_prach_t *p) if(((p_*u) % p->N_zc) == 1) break; } - if(p_ >= 0 && p_ < p->N_zc/2){ + if(p_ < p->N_zc/2){ d_u = p_; }else{ d_u = p->N_zc - p_; @@ -342,8 +342,7 @@ int srslte_prach_init(srslte_prach_t *p, if(p != NULL && N_ifft_ul < 2049 && config_idx < 16 && - root_seq_index < MAX_ROOTS && - zero_corr_zone_config < 16) + root_seq_index < MAX_ROOTS) { uint32_t preamble_format = srslte_prach_get_preamble_format(config_idx); p->config_idx = config_idx; @@ -356,14 +355,29 @@ int srslte_prach_init(srslte_prach_t *p, // Determine N_zc and N_cs if(4 == preamble_format){ - p->N_zc = 139; - p->N_cs = prach_Ncs_format4[p->zczc]; + if (p->zczc < 7) { + p->N_zc = 139; + p->N_cs = prach_Ncs_format4[p->zczc]; + } else { + fprintf(stderr, "Invalid zeroCorrelationZoneConfig=%d for format4\n", p->zczc); + return SRSLTE_ERROR; + } }else{ p->N_zc = 839; if(p->hs){ - p->N_cs = prach_Ncs_restricted[p->zczc]; + if (p->zczc < 15) { + p->N_cs = prach_Ncs_restricted[p->zczc]; + } else { + fprintf(stderr, "Invalid zeroCorrelationZoneConfig=%d for restricted set\n", p->zczc); + return SRSLTE_ERROR; + } }else{ - p->N_cs = prach_Ncs_unrestricted[p->zczc]; + if (p->zczc < 16) { + p->N_cs = prach_Ncs_unrestricted[p->zczc]; + } else { + fprintf(stderr, "Invalid zeroCorrelationZoneConfig=%d\n", p->zczc); + return SRSLTE_ERROR; + } } } diff --git a/srslte/lib/phch/pucch.c b/srslte/lib/phch/pucch.c index 9c55768e1..fb2419be0 100644 --- a/srslte/lib/phch/pucch.c +++ b/srslte/lib/phch/pucch.c @@ -136,7 +136,7 @@ uint32_t get_pucch_symbol(uint32_t m, srslte_pucch_format_t format, srslte_cp_t case SRSLTE_PUCCH_FORMAT_1: case SRSLTE_PUCCH_FORMAT_1A: case SRSLTE_PUCCH_FORMAT_1B: - if (m < 5) { + if (m < 4) { if (SRSLTE_CP_ISNORM(cp)) { return pucch_symbol_format1_cpnorm[m]; } else { @@ -147,7 +147,7 @@ uint32_t get_pucch_symbol(uint32_t m, srslte_pucch_format_t format, srslte_cp_t case SRSLTE_PUCCH_FORMAT_2: case SRSLTE_PUCCH_FORMAT_2A: case SRSLTE_PUCCH_FORMAT_2B: - if (m < 6) { + if (m < 5) { if (SRSLTE_CP_ISNORM(cp)) { return pucch_symbol_format2_cpnorm[m]; } else { diff --git a/srslte/lib/phch/ra.c b/srslte/lib/phch/ra.c index f005cd9aa..3ea7b9c30 100644 --- a/srslte/lib/phch/ra.c +++ b/srslte/lib/phch/ra.c @@ -595,7 +595,10 @@ int srslte_ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb) { if (tbs <= tbs_table[0][n_prb-1]) { return 0; } - for (idx = 0; idx < 27; idx++) { + if (tbs >= tbs_table[26][n_prb-1]) { + return 27; + } + for (idx = 0; idx < 26; idx++) { if (tbs_table[idx][n_prb-1] <= tbs && tbs_table[idx+1][n_prb-1] >= tbs) { return idx+1; } diff --git a/srslte/lib/phch/regs.c b/srslte/lib/phch/regs.c index 9c2764866..8ada33e7f 100644 --- a/srslte/lib/phch/regs.c +++ b/srslte/lib/phch/regs.c @@ -247,6 +247,10 @@ int regs_phich_init(srslte_regs_t *h) { srslte_regs_reg_t **regs_phich[3]; int ret = SRSLTE_ERROR; + for (int i=0;i<3;i++) { + regs_phich[i] = NULL; + } + switch(h->phich_res) { case SRSLTE_PHICH_R_1_6: ng = (float) 1/6; @@ -768,8 +772,10 @@ int srslte_regs_init(srslte_regs_t *h, srslte_cell_t cell) { ret = SRSLTE_SUCCESS; } clean_and_exit: - if (ret != SRSLTE_SUCCESS) { - srslte_regs_free(h); + if (h) { + if (ret != SRSLTE_SUCCESS) { + srslte_regs_free(h); + } } return ret; } diff --git a/srslte/lib/phch/sch.c b/srslte/lib/phch/sch.c index 0550a492f..0655b5cd1 100644 --- a/srslte/lib/phch/sch.c +++ b/srslte/lib/phch/sch.c @@ -58,7 +58,7 @@ float beta_cqi_offset[16] = {-1.0, -1.0, 1.125, 1.25, 1.375, 1.625, 1.750, 2.0, float srslte_sch_beta_cqi(uint32_t I_cqi) { - if (I_cqi <= 16) { + if (I_cqi < 16) { return beta_cqi_offset[I_cqi]; } else { return 0; @@ -463,7 +463,7 @@ static int decode_tb(srslte_sch_t *q, par_tx = ((uint32_t) parity[0])<<16 | ((uint32_t) parity[1])<<8 | ((uint32_t) parity[2]); if (!par_rx) { - printf("Warning: Received all-zero transport block\n\n", 0); + printf("Warning: Received all-zero transport block\n\n"); } if (par_rx == par_tx && par_rx) { diff --git a/srslte/lib/phch/test/pdsch_test_mex.c b/srslte/lib/phch/test/pdsch_test_mex.c index 699fbb1f6..9deaef2cb 100644 --- a/srslte/lib/phch/test/pdsch_test_mex.c +++ b/srslte/lib/phch/test/pdsch_test_mex.c @@ -271,7 +271,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) if (nlhs >= 5) { mexutils_write_s(pdsch.e, &plhs[4], cfg.nbits.nof_bits, 1); } - + if (nlhs >= 6) { + mexutils_write_cf(ce[0], &plhs[5], SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp), 1); + } srslte_softbuffer_rx_free(&softbuffer); srslte_chest_dl_free(&chest); srslte_pdsch_free(&pdsch); diff --git a/srslte/lib/rf/rf_blade_imp.c b/srslte/lib/rf/rf_blade_imp.c index ee7185c88..af2916f65 100644 --- a/srslte/lib/rf/rf_blade_imp.c +++ b/srslte/lib/rf/rf_blade_imp.c @@ -478,10 +478,12 @@ int rf_blade_send_timed(void *h, if (is_end_of_burst) { meta.flags |= BLADERF_META_FLAG_TX_BURST_END; } + srslte_rf_error_t error; + bzero(&error, sizeof(srslte_rf_error_t)); + status = bladerf_sync_tx(handler->dev, handler->tx_buffer, nsamples, &meta, 2000); if (status == BLADERF_ERR_TIME_PAST) { if (blade_error_handler) { - srslte_rf_error_t error; error.type = SRSLTE_RF_ERROR_LATE; blade_error_handler(error); } else { @@ -492,7 +494,6 @@ int rf_blade_send_timed(void *h, return status; } else if (meta.status == BLADERF_META_STATUS_UNDERRUN) { if (blade_error_handler) { - srslte_rf_error_t error; error.type = SRSLTE_RF_ERROR_UNDERFLOW; blade_error_handler(error); } else { diff --git a/srslte/lib/rf/rf_uhd_imp.c b/srslte/lib/rf/rf_uhd_imp.c index 73e7af981..c0b4cc71a 100644 --- a/srslte/lib/rf/rf_uhd_imp.c +++ b/srslte/lib/rf/rf_uhd_imp.c @@ -62,6 +62,8 @@ srslte_rf_error_handler_t uhd_error_handler = NULL; void msg_handler(const char *msg) { srslte_rf_error_t error; + bzero(&error, sizeof(srslte_rf_error_t)); + if(0 == strcmp(msg, "O")) { error.type = SRSLTE_RF_ERROR_OVERFLOW; } else if(0 == strcmp(msg, "D")) { diff --git a/srslte/lib/sync/cfo.c b/srslte/lib/sync/cfo.c index 84997dc3f..f9304576a 100644 --- a/srslte/lib/sync/cfo.c +++ b/srslte/lib/sync/cfo.c @@ -62,7 +62,7 @@ void srslte_cfo_free(srslte_cfo_t *h) { if (h->cur_cexp) { free(h->cur_cexp); } - bzero(h, sizeof(cf_t)); + bzero(h, sizeof(srslte_cfo_t)); } void srslte_cfo_set_tol(srslte_cfo_t *h, float tol) { diff --git a/srslte/lib/sync/pss.c b/srslte/lib/sync/pss.c index 16efa4f1b..f7edbb353 100644 --- a/srslte/lib/sync/pss.c +++ b/srslte/lib/sync/pss.c @@ -94,6 +94,8 @@ int srslte_pss_synch_init_fft_offset(srslte_pss_synch_t *q, uint32_t frame_size, if (q != NULL) { + ret = SRSLTE_ERROR; + uint32_t N_id_2; uint32_t buffer_size; bzero(q, sizeof(srslte_pss_synch_t)); diff --git a/srslte/lib/sync/sss.c b/srslte/lib/sync/sss.c index d64c0db1d..27818866a 100644 --- a/srslte/lib/sync/sss.c +++ b/srslte/lib/sync/sss.c @@ -139,14 +139,15 @@ uint32_t srslte_sss_synch_subframe(uint32_t m0, uint32_t m1) { /** Returns the N_id_1 value based on the m0 and m1 values */ int srslte_sss_synch_N_id_1(srslte_sss_synch_t *q, uint32_t m0, uint32_t m1) { - if (m0==m1 || m0 > 30 || m1 > 30) { - return SRSLTE_ERROR; - } - int N_id_1; + int N_id_1 = -1; if (m1 > m0) { - N_id_1 = q->N_id_1_table[m0][m1 - 1]; + if (m0 < 30 && m1 - 1 < 30) { + N_id_1 = q->N_id_1_table[m0][m1 - 1]; + } } else { - N_id_1 = q->N_id_1_table[m1][m0 - 1]; + if (m1 < 30 && m0 - 1 < 30) { + N_id_1 = q->N_id_1_table[m1][m0 - 1]; + } } return N_id_1; } diff --git a/srslte/lib/sync/sync.c b/srslte/lib/sync/sync.c index 41a4c5efc..df44ed77b 100644 --- a/srslte/lib/sync/sync.c +++ b/srslte/lib/sync/sync.c @@ -79,7 +79,7 @@ int srslte_sync_init(srslte_sync_t *q, uint32_t frame_size, uint32_t max_offset, } // Set a CFO tolerance of approx 100 Hz - srslte_cfo_set_tol(&q->cfocorr, 100/(15000*q->fft_size)); + srslte_cfo_set_tol(&q->cfocorr, 100.0/(15000.0*q->fft_size)); for (int i=0;i<2;i++) { q->cfo_i_corr[i] = srslte_vec_malloc(sizeof(cf_t)*q->frame_size); @@ -398,8 +398,11 @@ srslte_sync_find_ret_t srslte_sync_find(srslte_sync_t *q, cf_t *input, uint32_t srslte_sync_find_ret_t ret = SRSLTE_SYNC_ERROR; - if (q != NULL && - input != NULL && + if (!q) { + return SRSLTE_ERROR_INVALID_INPUTS; + } + + if (input != NULL && srslte_N_id_2_isvalid(q->N_id_2) && fft_size_isvalid(q->fft_size)) { diff --git a/srslte/lib/ue/ue_sync.c b/srslte/lib/ue/ue_sync.c index d04c5c303..7a9b7cb64 100644 --- a/srslte/lib/ue/ue_sync.c +++ b/srslte/lib/ue/ue_sync.c @@ -44,7 +44,7 @@ cf_t dummy[MAX_TIME_OFFSET]; #define TRACK_MAX_LOST 4 #define TRACK_FRAME_SIZE 32 #define FIND_NOF_AVG_FRAMES 4 -#define DEFAULT_SAMPLE_OFFSET_CORRECT_PERIOD 5 +#define DEFAULT_SAMPLE_OFFSET_CORRECT_PERIOD 0 #define DEFAULT_SFO_EMA_COEFF 0.1 cf_t dummy_offset_buffer[1024*1024]; @@ -358,7 +358,6 @@ static int track_peak_ok(srslte_ue_sync_t *q, uint32_t track_idx) { { INFO("Warning: Expected SF idx %d but got %d! (%d frames)\n", q->sf_idx, srslte_sync_get_sf_idx(&q->strack), q->frame_no_cnt); - q->sf_idx = srslte_sync_get_sf_idx(&q->strack); q->frame_no_cnt++; if (q->frame_no_cnt >= TRACK_MAX_LOST) { INFO("\n%d frames lost. Going back to FIND\n", (int) q->frame_no_cnt); diff --git a/srslte/lib/ue/ue_ul.c b/srslte/lib/ue/ue_ul.c index 1e5d7a51f..1d8a371e4 100644 --- a/srslte/lib/ue/ue_ul.c +++ b/srslte/lib/ue/ue_ul.c @@ -434,12 +434,14 @@ int srslte_ue_ul_pusch_encode_rnti_softbuffer(srslte_ue_ul_t *q, { int ret = SRSLTE_ERROR_INVALID_INPUTS; - bzero(q->sf_symbols, sizeof(cf_t)*SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp)); if (q != NULL && softbuffer != NULL && output_signal != NULL) { + + bzero(q->sf_symbols, sizeof(cf_t)*SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp)); + if (srslte_pusch_uci_encode_rnti(&q->pusch, &q->pusch_cfg, softbuffer, data, uci_data, rnti, q->sf_symbols)) { fprintf(stderr, "Error encoding TB\n"); return ret;