From 8274370d3d523539b846563776f5d29858bc99b2 Mon Sep 17 00:00:00 2001 From: ismagom Date: Sun, 5 Apr 2015 16:32:35 +0200 Subject: [PATCH 1/2] Fixed some srslte duplicate prefix --- matlab/tests/drms_pusch_test.m | 2 +- matlab/tests/pusch_test.m | 2 +- matlab/tests/rm_turbo_rx_test.m | 2 +- mex/lib/mexutils.c | 2 +- srslte/examples/CMakeLists.txt | 3 ++ srslte/examples/pdsch_enodeb.c | 12 +++---- srslte/examples/pdsch_ue.c | 8 ++--- srslte/examples/prach_ue.c | 2 +- srslte/examples/synch_file.c | 2 +- .../srslte/ch_estimation/refsignal_ul.h | 2 +- srslte/include/srslte/common/phy_common.h | 34 +++++++++---------- srslte/include/srslte/fec/tc_interl.h | 16 ++++----- srslte/include/srslte/fec/turbocoder.h | 2 +- srslte/include/srslte/fec/turbodecoder.h | 2 +- srslte/include/srslte/phch/pbch.h | 4 +-- srslte/include/srslte/phch/pucch.h | 6 ++-- srslte/lib/ch_estimation/test/chest_test_dl.c | 4 +-- .../ch_estimation/test/chest_test_dl_mex.c | 6 ++-- .../ch_estimation/test/refsignal_pusch_mex.c | 4 +-- .../ch_estimation/test/refsignal_ul_test.c | 4 +-- srslte/lib/common/src/phy_common.c | 2 +- srslte/lib/dft/src/ofdm.c | 2 +- srslte/lib/dft/test/ofdm_test.c | 4 +-- srslte/lib/fec/src/tc_interl_lte.c | 2 +- srslte/lib/fec/src/tc_interl_umts.c | 10 +++--- srslte/lib/fec/src/turbocoder.c | 6 ++-- srslte/lib/fec/src/turbodecoder.c | 6 ++-- srslte/lib/fec/test/rm_turbo_rx_mex.c | 2 +- srslte/lib/phch/src/pbch.c | 2 +- srslte/lib/phch/src/pucch.c | 4 +-- srslte/lib/phch/test/pbch_file_test.c | 4 +-- srslte/lib/phch/test/pbch_test.c | 4 +-- srslte/lib/phch/test/pcfich_file_test.c | 4 +-- srslte/lib/phch/test/pcfich_test.c | 4 +-- srslte/lib/phch/test/pdcch_file_test.c | 4 +-- srslte/lib/phch/test/pdcch_test.c | 4 +-- srslte/lib/phch/test/pdsch_file_test.c | 4 +-- srslte/lib/phch/test/pdsch_test.c | 4 +-- srslte/lib/phch/test/pdsch_test_mex.c | 2 +- srslte/lib/phch/test/phich_file_test.c | 4 +-- srslte/lib/phch/test/phich_test.c | 6 ++-- srslte/lib/phch/test/pusch_encode_test_mex.c | 4 +-- srslte/lib/phch/test/pusch_test.c | 4 +-- srslte/lib/phch/test/ulsch_encode_test_mex.c | 4 +-- srslte/lib/scrambling/test/scrambling_test.c | 4 +-- srslte/lib/sync/src/sync.c | 12 +++---- srslte/lib/sync/test/pss_file.c | 6 ++-- srslte/lib/sync/test/pss_usrp.c | 6 ++-- srslte/lib/sync/test/sync_test.c | 4 +-- srslte/lib/ue/src/ue_cell_search.c | 4 +-- srslte/tutorial_examples/pss.c | 6 ++-- srslte/tutorial_examples/simple_tx.c | 10 +++--- srslte/tutorial_examples/ue_rx.c | 8 ++--- 53 files changed, 139 insertions(+), 136 deletions(-) diff --git a/matlab/tests/drms_pusch_test.m b/matlab/tests/drms_pusch_test.m index 84848315f..271e925d8 100644 --- a/matlab/tests/drms_pusch_test.m +++ b/matlab/tests/drms_pusch_test.m @@ -28,7 +28,7 @@ for prb=4 subframe_mat = lteULResourceGrid(ueConfig); subframe_mat(ind)=mat; - subframe_lib=srslte_srslte_refsignal_pusch(ueConfig,puschConfig); + subframe_lib=srslte_refsignal_pusch(ueConfig,puschConfig); error(k)=mean(abs(subframe_mat(:)-subframe_lib(:))); disp(error(k)) diff --git a/matlab/tests/pusch_test.m b/matlab/tests/pusch_test.m index 4eb4bce5f..c743e19e9 100644 --- a/matlab/tests/pusch_test.m +++ b/matlab/tests/pusch_test.m @@ -51,7 +51,7 @@ for i=1:length(TBs) subframe_mat(idx)=cw_mat; waveform = lteSCFDMAModulate(ueConfig,subframe_mat,0); - [waveform_lib, subframe_lib, cwlib]=srslte_srslte_pusch_encode(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit); + [waveform_lib, subframe_lib, cwlib]=srslte_pusch_encode(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit); err=mean(abs(waveform-waveform_lib)); if (err > 10^-6) disp(err) diff --git a/matlab/tests/rm_turbo_rx_test.m b/matlab/tests/rm_turbo_rx_test.m index 4a014189d..4180a2130 100644 --- a/matlab/tests/rm_turbo_rx_test.m +++ b/matlab/tests/rm_turbo_rx_test.m @@ -26,7 +26,7 @@ for i=1:length(trBlkLenVec) mat2 = reshape(reshape(mat{1},[],3)',[],1); out = lteTurboDecode(mat{1}); - lib=srslte_srslte_rm_turbo_rx(double(codeword),trBlkLen,RV); + lib=srslte_rm_turbo_rx(double(codeword),trBlkLen,RV); [outLib] = srslte_turbodecoder(lib); if (length(trBlkLenVec) == 1) diff --git a/mex/lib/mexutils.c b/mex/lib/mexutils.c index 8e39d6fbf..742d30193 100644 --- a/mex/lib/mexutils.c +++ b/mex/lib/mexutils.c @@ -83,7 +83,7 @@ int mexutils_read_cell(const mxArray *ptr, srslte_cell_t *cell) { return -1; } // TODO - cell->cp = SRSLTE_SRSLTE_CP_NORM; + cell->cp = SRSLTE_CP_NORM; cell->phich_length = SRSLTE_PHICH_NORM; cell->phich_resources = SRSLTE_PHICH_SRSLTE_PHICH_R_1_6; return 0; diff --git a/srslte/examples/CMakeLists.txt b/srslte/examples/CMakeLists.txt index d381e4aad..fed7b112a 100644 --- a/srslte/examples/CMakeLists.txt +++ b/srslte/examples/CMakeLists.txt @@ -89,6 +89,9 @@ IF(${CUHD_FIND} GREATER -1) add_executable(usrp_capture usrp_capture.c cuhd_utils.c) target_link_libraries(usrp_capture cuhd srslte) + add_executable(usrp_capture_sync usrp_capture_sync.c cuhd_utils.c) + target_link_libraries(usrp_capture_sync cuhd srslte) + MESSAGE(STATUS " UHD examples will be installed.") ELSE(${CUHD_FIND} GREATER -1) diff --git a/srslte/examples/pdsch_enodeb.c b/srslte/examples/pdsch_enodeb.c index 5fd8cea9d..d65429808 100644 --- a/srslte/examples/pdsch_enodeb.c +++ b/srslte/examples/pdsch_enodeb.c @@ -52,7 +52,7 @@ srslte_cell_t cell = { 6, // nof_prb 1, // nof_ports 1, // cell_id - SRSLTE_SRSLTE_CP_NORM, // cyclic prefix + SRSLTE_CP_NORM, // cyclic prefix SRSLTE_PHICH_R_1, // PHICH resources SRSLTE_PHICH_NORM // PHICH length }; @@ -215,7 +215,7 @@ void base_init() { } /* create ifft object */ - if (srslte_ofdm_rx_init(&ifft, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb)) { + if (srslte_ofdm_rx_init(&ifft, SRSLTE_CP_NORM, cell.nof_prb)) { fprintf(stderr, "Error creating iFFT object\n"); exit(-1); } @@ -324,7 +324,7 @@ int update_radl(uint32_t sf_idx) { ra_dl.type0_alloc.rbg_bitmask = prbset_to_bitmask(); srslte_ra_dl_alloc(&prb_alloc, &ra_dl, cell.nof_prb); - srslte_ra_dl_alloc_re(&prb_alloc, cell.nof_prb, 1, cell.nof_prb<10?(cfi+1):cfi, SRSLTE_SRSLTE_CP_NORM); + srslte_ra_dl_alloc_re(&prb_alloc, cell.nof_prb, 1, cell.nof_prb<10?(cfi+1):cfi, SRSLTE_CP_NORM); srslte_ra_mcs_from_idx_dl(mcs_idx, prb_alloc.slot[0].nof_prb, &ra_dl.mcs); srslte_ra_pdsch_fprint(stdout, &ra_dl, cell.nof_prb); @@ -460,7 +460,7 @@ int main(int argc, char **argv) { parse_args(argc, argv); N_id_2 = cell.id % 3; - sf_n_re = 2 * SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE; + sf_n_re = 2 * SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE; sf_n_samples = 2 * SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb)); cell.phich_length = SRSLTE_PHICH_NORM; @@ -524,9 +524,9 @@ int main(int argc, char **argv) { bzero(sf_buffer, sizeof(cf_t) * sf_n_re); if (sf_idx == 0 || sf_idx == 5) { - srslte_pss_put_slot(pss_signal, sf_buffer, cell.nof_prb, SRSLTE_SRSLTE_CP_NORM); + srslte_pss_put_slot(pss_signal, sf_buffer, cell.nof_prb, SRSLTE_CP_NORM); srslte_sss_put_slot(sf_idx ? sss_signal5 : sss_signal0, sf_buffer, cell.nof_prb, - SRSLTE_SRSLTE_CP_NORM); + SRSLTE_CP_NORM); } srslte_refsignal_cs_put_sf(cell, 0, est.csr_signal.pilots[0][sf_idx], sf_buffer); diff --git a/srslte/examples/pdsch_ue.c b/srslte/examples/pdsch_ue.c index 83cc6e677..437abd421 100644 --- a/srslte/examples/pdsch_ue.c +++ b/srslte/examples/pdsch_ue.c @@ -304,7 +304,7 @@ int main(int argc, char **argv) { state = DECODE_PDSCH; /* preset cell configuration */ cell.id = 1; - cell.cp = SRSLTE_SRSLTE_CP_NORM; + cell.cp = SRSLTE_CP_NORM; cell.phich_length = SRSLTE_PHICH_NORM; cell.phich_resources = SRSLTE_PHICH_R_1; cell.nof_ports = 1; @@ -519,9 +519,9 @@ int main(int argc, char **argv) { plot_real_t p_sync, pce; plot_scatter_t pscatequal, pscatequal_pdcch; -float tmp_plot[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_SRSLTE_CP_NORM)]; -float tmp_plot2[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_SRSLTE_CP_NORM)]; -float tmp_plot3[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_SRSLTE_CP_NORM)]; +float tmp_plot[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM)]; +float tmp_plot2[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM)]; +float tmp_plot3[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM)]; void *plot_thread_run(void *arg) { int i; diff --git a/srslte/examples/prach_ue.c b/srslte/examples/prach_ue.c index a8e04267f..cb9401bd3 100644 --- a/srslte/examples/prach_ue.c +++ b/srslte/examples/prach_ue.c @@ -344,7 +344,7 @@ int main(int argc, char **argv) { cell.id = 1; cell.nof_ports = 1; cell.nof_prb = 25; - cell.cp = SRSLTE_SRSLTE_CP_NORM; + cell.cp = SRSLTE_CP_NORM; cell.phich_length = SRSLTE_PHICH_NORM; cell.phich_resources = SRSLTE_PHICH_R_1; #endif diff --git a/srslte/examples/synch_file.c b/srslte/examples/synch_file.c index 9cb5a97c9..f464f26c1 100644 --- a/srslte/examples/synch_file.c +++ b/srslte/examples/synch_file.c @@ -219,7 +219,7 @@ int main(int argc, char **argv) { /* If peak detected */ if (peak_value[N_id_2] > corr_peak_threshold) { - sss_idx = peak_pos[N_id_2]-2*(symbol_sz+SRSLTE_CP(symbol_sz,SRSLTE_SRSLTE_CP_NORM_LEN)); + sss_idx = peak_pos[N_id_2]-2*(symbol_sz+SRSLTE_CP(symbol_sz,SRSLTE_CP_NORM_LEN)); if (sss_idx >= 0) { srslte_sss_synch_m0m1_diff(&sss[N_id_2], &input[sss_idx], &m0, &m0_value, &m1, &m1_value); diff --git a/srslte/include/srslte/ch_estimation/refsignal_ul.h b/srslte/include/srslte/ch_estimation/refsignal_ul.h index a61262d7d..d992e2db4 100644 --- a/srslte/include/srslte/ch_estimation/refsignal_ul.h +++ b/srslte/include/srslte/ch_estimation/refsignal_ul.h @@ -63,7 +63,7 @@ typedef struct SRSLTE_API { /** Uplink DeModulation Reference Signal (DMRS) */ typedef struct SRSLTE_API { srslte_cell_t cell; - uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB]; + uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB]; float *tmp_arg; uint32_t n_prs_pusch[SRSLTE_NOF_DELTA_SS][SRSLTE_NSLOTS_X_FRAME]; // We precompute n_prs needed for cyclic shift alpha at srslte_refsignal_dl_init() uint32_t f_gh[SRSLTE_NSLOTS_X_FRAME]; diff --git a/srslte/include/srslte/common/phy_common.h b/srslte/include/srslte/common/phy_common.h index b4ae2f3db..b95d271fb 100644 --- a/srslte/include/srslte/common/phy_common.h +++ b/srslte/include/srslte/common/phy_common.h @@ -57,7 +57,7 @@ #define SRSLTE_LTE_CRC16 0x11021 #define SRSLTE_LTE_CRC8 0x19B -typedef enum {SRSLTE_SRSLTE_CP_NORM, SRSLTE_SRSLTE_CP_EXT} srslte_cp_t; +typedef enum {SRSLTE_CP_NORM, SRSLTE_CP_EXT} srslte_cp_t; #define SRSLTE_CRNTI_START 0x003D @@ -77,23 +77,23 @@ typedef enum {SRSLTE_SRSLTE_CP_NORM, SRSLTE_SRSLTE_CP_EXT} srslte_cp_t; #define SRSLTE_SYMBOL_SZ_MAX 2048 -#define SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB 7 -#define SRSLTE_SRSLTE_CP_NORM_SF_NSYMB (2*SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB) -#define SRSLTE_SRSLTE_CP_NORM_0_LEN 160 -#define SRSLTE_SRSLTE_CP_NORM_LEN 144 +#define SRSLTE_CP_NORM_NSYMB 7 +#define SRSLTE_CP_NORM_SF_NSYMB (2*SRSLTE_CP_NORM_NSYMB) +#define SRSLTE_CP_NORM_0_LEN 160 +#define SRSLTE_CP_NORM_LEN 144 -#define SRSLTE_SRSLTE_CP_EXT_NSYMB 6 -#define SRSLTE_SRSLTE_CP_EXT_SF_NSYMB (2*SRSLTE_SRSLTE_CP_EXT_NSYMB) -#define SRSLTE_SRSLTE_CP_EXT_LEN 512 -#define SRSLTE_SRSLTE_CP_EXT_7_5_LEN 1024 +#define SRSLTE_CP_EXT_NSYMB 6 +#define SRSLTE_CP_EXT_SF_NSYMB (2*SRSLTE_CP_EXT_NSYMB) +#define SRSLTE_CP_EXT_LEN 512 +#define SRSLTE_CP_EXT_7_5_LEN 1024 -#define SRSLTE_CP_ISNORM(cp) (cp==SRSLTE_SRSLTE_CP_NORM) -#define SRSLTE_CP_ISEXT(cp) (cp==SRSLTE_SRSLTE_CP_EXT) -#define SRSLTE_CP_NSYMB(cp) (SRSLTE_CP_ISNORM(cp)?SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB:SRSLTE_SRSLTE_CP_EXT_NSYMB) +#define SRSLTE_CP_ISNORM(cp) (cp==SRSLTE_CP_NORM) +#define SRSLTE_CP_ISEXT(cp) (cp==SRSLTE_CP_EXT) +#define SRSLTE_CP_NSYMB(cp) (SRSLTE_CP_ISNORM(cp)?SRSLTE_CP_NORM_NSYMB:SRSLTE_CP_EXT_NSYMB) #define SRSLTE_CP(symbol_sz, c) ((int) ceil((((float) (c)*(symbol_sz))/2048))) -#define SRSLTE_CP_NORM(symbol, symbol_sz) ((symbol==0)?SRSLTE_CP((symbol_sz),SRSLTE_SRSLTE_CP_NORM_0_LEN):SRSLTE_CP((symbol_sz),SRSLTE_SRSLTE_CP_NORM_LEN)) -#define SRSLTE_CP_EXT(symbol_sz) (SRSLTE_CP((symbol_sz),SRSLTE_SRSLTE_CP_EXT_LEN)) +#define SRSLTE_CP_NORM(symbol, symbol_sz) ((symbol==0)?SRSLTE_CP((symbol_sz),SRSLTE_CP_NORM_0_LEN):SRSLTE_CP((symbol_sz),SRSLTE_CP_NORM_LEN)) +#define SRSLTE_CP_EXT(symbol_sz) (SRSLTE_CP((symbol_sz),SRSLTE_CP_EXT_LEN)) #define SRSLTE_SLOT_LEN(symbol_sz) (480*((symbol_sz)/64)) #define SRSLTE_SF_LEN(symbol_sz) (2*SRSLTE_SLOT_LEN(symbol_sz)) @@ -109,9 +109,9 @@ typedef enum {SRSLTE_SRSLTE_CP_NORM, SRSLTE_SRSLTE_CP_EXT} srslte_cp_t; #define SRSLTE_LTE_TS 1.0/(15000.0*2048) -#define SRSLTE_SLOT_IDX_CPNORM(symbol_idx, symbol_sz) (symbol_idx==0?0:(symbol_sz + SRSLTE_CP(symbol_sz, SRSLTE_SRSLTE_CP_NORM_0_LEN) + \ - (symbol_idx-1)*(symbol_sz+SRSLTE_CP(symbol_sz, SRSLTE_SRSLTE_CP_NORM_LEN)))) -#define SRSLTE_SLOT_IDX_CPEXT(idx, symbol_sz) (idx*(symbol_sz+SRSLTE_CP(symbol_sz, SRSLTE_SRSLTE_CP_EXT_LEN))) +#define SRSLTE_SLOT_IDX_CPNORM(symbol_idx, symbol_sz) (symbol_idx==0?0:(symbol_sz + SRSLTE_CP(symbol_sz, SRSLTE_CP_NORM_0_LEN) + \ + (symbol_idx-1)*(symbol_sz+SRSLTE_CP(symbol_sz, SRSLTE_CP_NORM_LEN)))) +#define SRSLTE_SLOT_IDX_CPEXT(idx, symbol_sz) (idx*(symbol_sz+SRSLTE_CP(symbol_sz, SRSLTE_CP_EXT_LEN))) #define SRSLTE_RE_IDX(nof_prb, symbol_idx, sample_idx) ((symbol_idx)*(nof_prb)*(SRSLTE_NRE) + sample_idx) diff --git a/srslte/include/srslte/fec/tc_interl.h b/srslte/include/srslte/fec/tc_interl.h index 27300fe69..adca1be8b 100644 --- a/srslte/include/srslte/fec/tc_interl.h +++ b/srslte/include/srslte/fec/tc_interl.h @@ -42,17 +42,17 @@ typedef struct SRSLTE_API { uint32_t *forward; uint32_t *reverse; uint32_t max_long_cb; -} srs_tc_interl_t; +} srslte_tc_interl_t; -SRSLTE_API int srs_tc_interl_LTE_gen(srs_tc_interl_t *h, - uint32_t long_cb); +SRSLTE_API int srslte_tc_interl_LTE_gen(srslte_tc_interl_t *h, + uint32_t long_cb); -SRSLTE_API int srs_tc_interl_UMTS_gen(srs_tc_interl_t *h, - uint32_t long_cb); +SRSLTE_API int srslte_tc_interl_UMTS_gen(srslte_tc_interl_t *h, + uint32_t long_cb); -SRSLTE_API int srs_tc_interl_init(srs_tc_interl_t *h, - uint32_t max_long_cb); +SRSLTE_API int srslte_tc_interl_init(srslte_tc_interl_t *h, + uint32_t max_long_cb); -SRSLTE_API void srs_tc_interl_free(srs_tc_interl_t *h); +SRSLTE_API void srslte_tc_interl_free(srslte_tc_interl_t *h); #endif diff --git a/srslte/include/srslte/fec/turbocoder.h b/srslte/include/srslte/fec/turbocoder.h index 945862f25..739211c0d 100644 --- a/srslte/include/srslte/fec/turbocoder.h +++ b/srslte/include/srslte/fec/turbocoder.h @@ -49,7 +49,7 @@ typedef struct SRSLTE_API { uint32_t max_long_cb; - srs_tc_interl_t interl; + srslte_tc_interl_t interl; } srslte_tcod_t; SRSLTE_API int srslte_tcod_init(srslte_tcod_t *h, diff --git a/srslte/include/srslte/fec/turbodecoder.h b/srslte/include/srslte/fec/turbodecoder.h index afd3905ad..90fb0b4ff 100644 --- a/srslte/include/srslte/fec/turbodecoder.h +++ b/srslte/include/srslte/fec/turbodecoder.h @@ -67,7 +67,7 @@ typedef struct SRSLTE_API { srslte_llr_t *syst; srslte_llr_t *parity; - srs_tc_interl_t interleaver; + srslte_tc_interl_t interleaver; } srslte_tdec_t; SRSLTE_API int srslte_tdec_init(srslte_tdec_t * h, diff --git a/srslte/include/srslte/phch/pbch.h b/srslte/include/srslte/phch/pbch.h index aeb4bf9b1..cafeaa5e2 100644 --- a/srslte/include/srslte/phch/pbch.h +++ b/srslte/include/srslte/phch/pbch.h @@ -52,8 +52,8 @@ #define BCH_PAYLOADCRC_LEN (BCH_PAYLOAD_LEN+16) #define BCH_ENCODED_LEN 3*(BCH_PAYLOADCRC_LEN) -#define PBCH_RE_SRSLTE_SRSLTE_CP_NORM 240 -#define PBCH_RE_SRSLTE_SRSLTE_CP_EXT 216 +#define PBCH_RE_SRSLTE_CP_NORM 240 +#define PBCH_RE_SRSLTE_CP_EXT 216 /* PBCH object */ typedef struct SRSLTE_API { diff --git a/srslte/include/srslte/phch/pucch.h b/srslte/include/srslte/phch/pucch.h index e12812678..32df3a8cb 100644 --- a/srslte/include/srslte/phch/pucch.h +++ b/srslte/include/srslte/phch/pucch.h @@ -74,7 +74,7 @@ typedef struct SRSLTE_API { srslte_cell_t cell; srslte_pucch_cfg_t pucch_cfg; - uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB]; + uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB]; float tmp_arg[SRSLTE_PUCCH_N_SF_MAX*SRSLTE_PUCCH_N_SEQ]; float y[SRSLTE_PUCCH_N_SEQ]; }srslte_pucch_t; @@ -96,7 +96,7 @@ SRSLTE_API int srslte_pucch_encode(srslte_pucch_t *q, uint8_t bits[SRSLTE_PUCCH_MAX_BITS], cf_t *sf_symbols); -SRSLTE_API float srslte_pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB], +SRSLTE_API float srslte_pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB], srslte_pucch_cfg_t *cfg, srslte_cp_t cp, bool is_drms, @@ -105,7 +105,7 @@ SRSLTE_API float srslte_pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME uint32_t *n_oc); SRSLTE_API int srslte_generate_n_cs_cell(srslte_cell_t cell, - uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB]); + uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB]); SRSLTE_API bool srslte_pucch_cfg_isvalid(srslte_pucch_cfg_t *cfg); diff --git a/srslte/lib/ch_estimation/test/chest_test_dl.c b/srslte/lib/ch_estimation/test/chest_test_dl.c index 4e9974796..b59d9d10f 100644 --- a/srslte/lib/ch_estimation/test/chest_test_dl.c +++ b/srslte/lib/ch_estimation/test/chest_test_dl.c @@ -37,7 +37,7 @@ srslte_cell_t cell = { 6, // nof_prb 1, // nof_ports 1000, // cell_id - SRSLTE_SRSLTE_CP_NORM // cyclic prefix + SRSLTE_CP_NORM // cyclic prefix }; char *output_matlab = NULL; @@ -62,7 +62,7 @@ void parse_args(int argc, char **argv) { cell.nof_prb = atoi(argv[optind]); break; case 'e': - cell.cp = SRSLTE_SRSLTE_CP_EXT; + cell.cp = SRSLTE_CP_EXT; break; case 'c': cell.id = atoi(argv[optind]); diff --git a/srslte/lib/ch_estimation/test/chest_test_dl_mex.c b/srslte/lib/ch_estimation/test/chest_test_dl_mex.c index 993d9dd64..247efa513 100644 --- a/srslte/lib/ch_estimation/test/chest_test_dl_mex.c +++ b/srslte/lib/ch_estimation/test/chest_test_dl_mex.c @@ -88,9 +88,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) cell.nof_prb = mxGetM(INPUT)/SRSLTE_NRE; cell.nof_ports = (uint32_t) *((double*) mxGetPr(PORTS)); if ((mxGetN(INPUT)%14) == 0) { - cell.cp = SRSLTE_SRSLTE_CP_NORM; + cell.cp = SRSLTE_CP_NORM; } else if ((mxGetN(INPUT)%12)!=0) { - cell.cp = SRSLTE_SRSLTE_CP_EXT; + cell.cp = SRSLTE_CP_EXT; } else { mexErrMsgTxt("Invalid number of symbols\n"); help(); @@ -103,7 +103,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } int nsubframes; - if (cell.cp == SRSLTE_SRSLTE_CP_NORM) { + if (cell.cp == SRSLTE_CP_NORM) { nsubframes = mxGetN(INPUT)/14; } else { nsubframes = mxGetN(INPUT)/12; diff --git a/srslte/lib/ch_estimation/test/refsignal_pusch_mex.c b/srslte/lib/ch_estimation/test/refsignal_pusch_mex.c index 9b0afbe03..e384d3b1b 100644 --- a/srslte/lib/ch_estimation/test/refsignal_pusch_mex.c +++ b/srslte/lib/ch_estimation/test/refsignal_pusch_mex.c @@ -39,7 +39,7 @@ void help() { mexErrMsgTxt - ("[seq] = srslte_srslte_refsignal_pusch(ueConfig, puschConfig)\n\n"); + ("[seq] = srslte_refsignal_pusch(ueConfig, puschConfig)\n\n"); } extern int indices[2048]; @@ -65,7 +65,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexErrMsgTxt("Field NCellID not found in UE config\n"); return; } - cell.cp = SRSLTE_SRSLTE_CP_NORM; + cell.cp = SRSLTE_CP_NORM; cell.nof_ports = 1; if (mexutils_read_uint32_struct(UECFG, "NSubframe", &sf_idx)) { diff --git a/srslte/lib/ch_estimation/test/refsignal_ul_test.c b/srslte/lib/ch_estimation/test/refsignal_ul_test.c index c772a4571..906b45630 100644 --- a/srslte/lib/ch_estimation/test/refsignal_ul_test.c +++ b/srslte/lib/ch_estimation/test/refsignal_ul_test.c @@ -37,7 +37,7 @@ srslte_cell_t cell = { 100, // nof_prb SRSLTE_MAX_PORTS, // nof_ports 1, // cell_id - SRSLTE_SRSLTE_CP_NORM // cyclic prefix + SRSLTE_CP_NORM // cyclic prefix }; void usage(char *prog) { @@ -59,7 +59,7 @@ void parse_args(int argc, char **argv) { cell.nof_prb = atoi(argv[optind]); break; case 'e': - cell.cp = SRSLTE_SRSLTE_CP_EXT; + cell.cp = SRSLTE_CP_EXT; break; case 'c': cell.id = atoi(argv[optind]); diff --git a/srslte/lib/common/src/phy_common.c b/srslte/lib/common/src/phy_common.c index b32ed6356..2faadb5eb 100644 --- a/srslte/lib/common/src/phy_common.c +++ b/srslte/lib/common/src/phy_common.c @@ -163,7 +163,7 @@ uint32_t srslte_mod_bits_x_symbol(srslte_mod_t mod) { } char *srslte_cp_string(srslte_cp_t cp) { - if (cp == SRSLTE_SRSLTE_CP_NORM) { + if (cp == SRSLTE_CP_NORM) { return "Normal"; } else { return "Extended"; diff --git a/srslte/lib/dft/src/ofdm.c b/srslte/lib/dft/src/ofdm.c index 9613ea066..886382fd9 100644 --- a/srslte/lib/dft/src/ofdm.c +++ b/srslte/lib/dft/src/ofdm.c @@ -68,7 +68,7 @@ int srslte_ofdm_tx_init_(srslte_ofdm_t *q, srslte_cp_t cp, uint32_t nof_prb, srs DEBUG("Init %s symbol_sz=%d, nof_symbols=%d, cp=%s, nof_re=%d, nof_guards=%d\n", dir==SRSLTE_DFT_FORWARD?"FFT":"iFFT", q->symbol_sz, q->nof_symbols, - q->cp==SRSLTE_SRSLTE_CP_NORM?"Normal":"Extended", q->nof_re, q->nof_guards); + q->cp==SRSLTE_CP_NORM?"Normal":"Extended", q->nof_re, q->nof_guards); return SRSLTE_SUCCESS; } diff --git a/srslte/lib/dft/test/ofdm_test.c b/srslte/lib/dft/test/ofdm_test.c index 84476841f..44808dc38 100644 --- a/srslte/lib/dft/test/ofdm_test.c +++ b/srslte/lib/dft/test/ofdm_test.c @@ -35,7 +35,7 @@ #include "srslte/srslte.h" int nof_prb = -1; -srslte_cp_t cp = SRSLTE_SRSLTE_CP_NORM; +srslte_cp_t cp = SRSLTE_CP_NORM; void usage(char *prog) { printf("Usage: %s\n", prog); @@ -51,7 +51,7 @@ void parse_args(int argc, char **argv) { nof_prb = atoi(argv[optind]); break; case 'e': - cp = SRSLTE_SRSLTE_CP_EXT; + cp = SRSLTE_CP_EXT; break; default: usage(argv[0]); diff --git a/srslte/lib/fec/src/tc_interl_lte.c b/srslte/lib/fec/src/tc_interl_lte.c index 657ef8094..43d1ca549 100644 --- a/srslte/lib/fec/src/tc_interl_lte.c +++ b/srslte/lib/fec/src/tc_interl_lte.c @@ -66,7 +66,7 @@ const uint32_t f2_list[SRSLTE_NOF_TC_CB_SIZES] = { 10, 12, 42, 16, 18, 20, 22, 2 280, 142, 480, 146, 444, 120, 152, 462, 234, 158, 80, 96, 902, 166, 336, 170, 86, 174, 176, 178, 120, 182, 184, 186, 94, 190, 480 }; -int srs_tc_interl_LTE_gen(srs_tc_interl_t *h, uint32_t long_cb) { +int srslte_tc_interl_LTE_gen(srslte_tc_interl_t *h, uint32_t long_cb) { uint32_t cb_table_idx, f1, f2; uint64_t i, j; diff --git a/srslte/lib/fec/src/tc_interl_umts.c b/srslte/lib/fec/src/tc_interl_umts.c index d848141d2..2856d1e40 100644 --- a/srslte/lib/fec/src/tc_interl_umts.c +++ b/srslte/lib/fec/src/tc_interl_umts.c @@ -54,7 +54,7 @@ const uint8_t table_v[52] = { 3, 2, 2, 3, 2, 5, 2, 3, 2, 6, 3, 5, 2, 2, 2, 2, 7, 5, 3, 2, 3, 5, 2, 5, 2, 6, 3, 3, 2, 3, 2, 2, 6, 5, 2, 5, 2, 2, 2, 19, 5, 2, 3, 2, 3, 2, 6, 3, 7, 7, 6, 3 }; -int srs_tc_interl_init(srs_tc_interl_t *h, uint32_t max_long_cb) { +int srslte_tc_interl_init(srslte_tc_interl_t *h, uint32_t max_long_cb) { int ret = -1; h->forward = malloc(sizeof(uint32_t) * max_long_cb); if (!h->forward) { @@ -69,22 +69,22 @@ int srs_tc_interl_init(srs_tc_interl_t *h, uint32_t max_long_cb) { h->max_long_cb = max_long_cb; ret = 0; clean_exit: if (ret == -1) { - srs_tc_interl_free(h); + srslte_tc_interl_free(h); } return ret; } -void srs_tc_interl_free(srs_tc_interl_t *h) { +void srslte_tc_interl_free(srslte_tc_interl_t *h) { if (h->forward) { free(h->forward); } if (h->reverse) { free(h->reverse); } - bzero(h, sizeof(srs_tc_interl_t)); + bzero(h, sizeof(srslte_tc_interl_t)); } -int srs_tc_interl_UMTS_gen(srs_tc_interl_t *h, uint32_t long_cb) { +int srslte_tc_interl_UMTS_gen(srslte_tc_interl_t *h, uint32_t long_cb) { uint32_t i, j; uint32_t res, prim, aux; diff --git a/srslte/lib/fec/src/turbocoder.c b/srslte/lib/fec/src/turbocoder.c index aa6770582..51d8e05dd 100644 --- a/srslte/lib/fec/src/turbocoder.c +++ b/srslte/lib/fec/src/turbocoder.c @@ -39,7 +39,7 @@ int srslte_tcod_init(srslte_tcod_t *h, uint32_t max_long_cb) { - if (srs_tc_interl_init(&h->interl, max_long_cb)) { + if (srslte_tc_interl_init(&h->interl, max_long_cb)) { return -1; } h->max_long_cb = max_long_cb; @@ -47,7 +47,7 @@ int srslte_tcod_init(srslte_tcod_t *h, uint32_t max_long_cb) { } void srslte_tcod_free(srslte_tcod_t *h) { - srs_tc_interl_free(&h->interl); + srslte_tc_interl_free(&h->interl); h->max_long_cb = 0; } @@ -65,7 +65,7 @@ int srslte_tcod_encode(srslte_tcod_t *h, uint8_t *input, uint8_t *output, uint32 return -1; } - if (srs_tc_interl_LTE_gen(&h->interl, long_cb)) { + if (srslte_tc_interl_LTE_gen(&h->interl, long_cb)) { fprintf(stderr, "Error initiating TC interleaver\n"); return -1; } diff --git a/srslte/lib/fec/src/turbodecoder.c b/srslte/lib/fec/src/turbodecoder.c index 4c522698b..88c621ae2 100644 --- a/srslte/lib/fec/src/turbodecoder.c +++ b/srslte/lib/fec/src/turbodecoder.c @@ -239,7 +239,7 @@ int srslte_tdec_init(srslte_tdec_t * h, uint32_t max_long_cb) goto clean_and_exit; } - if (srs_tc_interl_init(&h->interleaver, h->max_long_cb) < 0) { + if (srslte_tc_interl_init(&h->interleaver, h->max_long_cb) < 0) { goto clean_and_exit; } @@ -270,7 +270,7 @@ void srslte_tdec_free(srslte_tdec_t * h) srslte_map_gen_free(&h->dec); - srs_tc_interl_free(&h->interleaver); + srslte_tc_interl_free(&h->interleaver); bzero(h, sizeof(srslte_tdec_t)); } @@ -323,7 +323,7 @@ int srslte_tdec_reset(srslte_tdec_t * h, uint32_t long_cb) return -1; } memset(h->w, 0, sizeof(srslte_llr_t) * long_cb); - return srs_tc_interl_LTE_gen(&h->interleaver, long_cb); + return srslte_tc_interl_LTE_gen(&h->interleaver, long_cb); } void srslte_tdec_decision(srslte_tdec_t * h, uint8_t *output, uint32_t long_cb) diff --git a/srslte/lib/fec/test/rm_turbo_rx_mex.c b/srslte/lib/fec/test/rm_turbo_rx_mex.c index 969b4b3dc..b8ab95e4a 100644 --- a/srslte/lib/fec/test/rm_turbo_rx_mex.c +++ b/srslte/lib/fec/test/rm_turbo_rx_mex.c @@ -41,7 +41,7 @@ void help() { mexErrMsgTxt - ("[out] = srslte_srslte_rm_turbo_rx(in, trblkin, rv)\n\n"); + ("[out] = srslte_rm_turbo_rx(in, trblkin, rv)\n\n"); } /* the gateway function */ diff --git a/srslte/lib/phch/src/pbch.c b/srslte/lib/phch/src/pbch.c index e164adc3c..ccfd004d3 100644 --- a/srslte/lib/phch/src/pbch.c +++ b/srslte/lib/phch/src/pbch.c @@ -138,7 +138,7 @@ int srslte_pbch_init(srslte_pbch_t *q, srslte_cell_t cell) { bzero(q, sizeof(srslte_pbch_t)); q->cell = cell; - q->nof_symbols = (SRSLTE_CP_ISNORM(q->cell.cp)) ? PBCH_RE_SRSLTE_SRSLTE_CP_NORM : PBCH_RE_SRSLTE_SRSLTE_CP_EXT; + q->nof_symbols = (SRSLTE_CP_ISNORM(q->cell.cp)) ? PBCH_RE_SRSLTE_CP_NORM : PBCH_RE_SRSLTE_CP_EXT; if (srslte_precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); diff --git a/srslte/lib/phch/src/pucch.c b/srslte/lib/phch/src/pucch.c index 1fca4aed8..b656e951c 100644 --- a/srslte/lib/phch/src/pucch.c +++ b/srslte/lib/phch/src/pucch.c @@ -50,7 +50,7 @@ bool srslte_pucch_cfg_isvalid(srslte_pucch_cfg_t *cfg) { /* Generates n_cs_cell according to Sec 5.4 of 36.211 */ -int srslte_generate_n_cs_cell(srslte_cell_t cell, uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB]) +int srslte_generate_n_cs_cell(srslte_cell_t cell, uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB]) { srslte_sequence_t seq; bzero(&seq, sizeof(srslte_sequence_t)); @@ -71,7 +71,7 @@ int srslte_generate_n_cs_cell(srslte_cell_t cell, uint32_t n_cs_cell[SRSLTE_NSLO /* Calculates alpha according to 5.5.2.2.2 of 36.211 */ -float srslte_pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB], +float srslte_pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB], srslte_pucch_cfg_t *cfg, srslte_cp_t cp, bool is_drms, uint32_t ns, uint32_t l, diff --git a/srslte/lib/phch/test/pbch_file_test.c b/srslte/lib/phch/test/pbch_file_test.c index db2e58226..09e71c946 100644 --- a/srslte/lib/phch/test/pbch_file_test.c +++ b/srslte/lib/phch/test/pbch_file_test.c @@ -40,7 +40,7 @@ srslte_cell_t cell = { 2, // nof_ports 0, // bw_idx 150, // cell_id - SRSLTE_SRSLTE_CP_NORM, // cyclic prefix + SRSLTE_CP_NORM, // cyclic prefix SRSLTE_PHICH_R_1, // PHICH resources SRSLTE_PHICH_NORM // PHICH length }; @@ -87,7 +87,7 @@ void parse_args(int argc, char **argv) { srslte_verbose++; break; case 'e': - cell.cp = SRSLTE_SRSLTE_CP_EXT; + cell.cp = SRSLTE_CP_EXT; break; default: usage(argv[0]); diff --git a/srslte/lib/phch/test/pbch_test.c b/srslte/lib/phch/test/pbch_test.c index d0887d327..ceee176ea 100644 --- a/srslte/lib/phch/test/pbch_test.c +++ b/srslte/lib/phch/test/pbch_test.c @@ -38,7 +38,7 @@ srslte_cell_t cell = { 6, // nof_prb 1, // nof_ports 1, // cell_id - SRSLTE_SRSLTE_CP_NORM, // cyclic prefix + SRSLTE_CP_NORM, // cyclic prefix SRSLTE_PHICH_R_1, // PHICH resources SRSLTE_PHICH_NORM // PHICH length }; @@ -86,7 +86,7 @@ int main(int argc, char **argv) { parse_args(argc,argv); - nof_re = SRSLTE_SLOT_LEN_RE(cell.nof_prb, SRSLTE_SRSLTE_CP_NORM); + nof_re = SRSLTE_SLOT_LEN_RE(cell.nof_prb, SRSLTE_CP_NORM); /* init memory */ for (i=0;idetect_cp = true; - q->cp = SRSLTE_SRSLTE_CP_NORM; + q->cp = SRSLTE_CP_NORM; q->mean_peak_value = 0.0; q->sss_en = true; q->correct_cfo = true; @@ -215,14 +215,14 @@ srslte_cp_t srslte_sync_detect_cp(srslte_sync_t *q, cf_t *input, uint32_t peak_p q->M_ext_avg = SRSLTE_VEC_EMA(M_ext/2, q->M_ext_avg, CP_EMA_ALPHA); if (q->M_norm_avg > q->M_ext_avg) { - return SRSLTE_SRSLTE_CP_NORM; + return SRSLTE_CP_NORM; } else if (q->M_norm_avg < q->M_ext_avg) { - return SRSLTE_SRSLTE_CP_EXT; + return SRSLTE_CP_EXT; } else { if (R_norm > R_ext) { - return SRSLTE_SRSLTE_CP_NORM; + return SRSLTE_CP_NORM; } else { - return SRSLTE_SRSLTE_CP_EXT; + return SRSLTE_CP_EXT; } } } @@ -236,7 +236,7 @@ int sync_sss(srslte_sync_t *q, cf_t *input, uint32_t peak_pos, srslte_cp_t cp) { srslte_sss_synch_set_N_id_2(&q->sss, q->N_id_2); /* Make sure we have enough room to find SSS sequence */ - sss_idx = (int) peak_pos-2*q->fft_size-SRSLTE_CP(q->fft_size, (SRSLTE_CP_ISNORM(q->cp)?SRSLTE_SRSLTE_CP_NORM_LEN:SRSLTE_SRSLTE_CP_EXT_LEN)); + sss_idx = (int) peak_pos-2*q->fft_size-SRSLTE_CP(q->fft_size, (SRSLTE_CP_ISNORM(q->cp)?SRSLTE_CP_NORM_LEN:SRSLTE_CP_EXT_LEN)); if (sss_idx < 0) { INFO("Not enough room to decode CP SSS (sss_idx=%d, peak_pos=%d)\n", sss_idx, peak_pos); return SRSLTE_ERROR; diff --git a/srslte/lib/sync/test/pss_file.c b/srslte/lib/sync/test/pss_file.c index a60a1c91c..d786fa20f 100644 --- a/srslte/lib/sync/test/pss_file.c +++ b/srslte/lib/sync/test/pss_file.c @@ -53,7 +53,7 @@ int nof_frames = -1; uint32_t fft_size=64; float threshold = 0.4; int N_id_2_sync = -1; -srslte_cp_t cp=SRSLTE_SRSLTE_CP_NORM; +srslte_cp_t cp=SRSLTE_CP_NORM; void usage(char *prog) { printf("Usage: %s [nlestdv] -i cell_id -f input_file_name\n", prog); @@ -81,7 +81,7 @@ void parse_args(int argc, char **argv) { threshold = atof(argv[optind]); break; case 'e': - cp = SRSLTE_SRSLTE_CP_EXT; + cp = SRSLTE_CP_EXT; break; case 'i': cell_id = atoi(argv[optind]); @@ -231,7 +231,7 @@ int main(int argc, char **argv) { } // Find SSS - int sss_idx = peak_idx-2*fft_size-(SRSLTE_CP_ISNORM(cp)?SRSLTE_CP(fft_size, SRSLTE_SRSLTE_CP_NORM_LEN):SRSLTE_CP(fft_size, SRSLTE_SRSLTE_CP_EXT_LEN)); + int sss_idx = peak_idx-2*fft_size-(SRSLTE_CP_ISNORM(cp)?SRSLTE_CP(fft_size, SRSLTE_CP_NORM_LEN):SRSLTE_CP(fft_size, SRSLTE_CP_EXT_LEN)); if (sss_idx >= 0 && sss_idx < flen-fft_size) { srslte_sss_synch_m0m1_partial(&sss, &buffer[sss_idx], 3, NULL, &m0, &m0_value, &m1, &m1_value); if (srslte_sss_synch_N_id_1(&sss, m0, m1) != N_id_1) { diff --git a/srslte/lib/sync/test/pss_usrp.c b/srslte/lib/sync/test/pss_usrp.c index b0671f187..b9cd60faa 100644 --- a/srslte/lib/sync/test/pss_usrp.c +++ b/srslte/lib/sync/test/pss_usrp.c @@ -54,7 +54,7 @@ int nof_frames = -1; uint32_t fft_size=64; float threshold = 0.4; int N_id_2_sync = -1; -srslte_cp_t cp=SRSLTE_SRSLTE_CP_NORM; +srslte_cp_t cp=SRSLTE_CP_NORM; void usage(char *prog) { printf("Usage: %s [aedgtvnp] -f rx_frequency_hz -i cell_id\n", prog); @@ -90,7 +90,7 @@ void parse_args(int argc, char **argv) { threshold = atof(argv[optind]); break; case 'e': - cp = SRSLTE_SRSLTE_CP_EXT; + cp = SRSLTE_CP_EXT; break; case 'i': cell_id = atoi(argv[optind]); @@ -241,7 +241,7 @@ int main(int argc, char **argv) { } // Find SSS - int sss_idx = peak_idx-2*fft_size-(SRSLTE_CP_ISNORM(cp)?SRSLTE_CP(fft_size, SRSLTE_SRSLTE_CP_NORM_LEN):SRSLTE_CP(fft_size, SRSLTE_SRSLTE_CP_EXT_LEN)); + int sss_idx = peak_idx-2*fft_size-(SRSLTE_CP_ISNORM(cp)?SRSLTE_CP(fft_size, SRSLTE_CP_NORM_LEN):SRSLTE_CP(fft_size, SRSLTE_CP_EXT_LEN)); if (sss_idx >= 0 && sss_idx < flen-fft_size) { srslte_sss_synch_m0m1_partial(&sss, &buffer[sss_idx], 3, NULL, &m0, &m0_value, &m1, &m1_value); if (srslte_sss_synch_N_id_1(&sss, m0, m1) != N_id_1) { diff --git a/srslte/lib/sync/test/sync_test.c b/srslte/lib/sync/test/sync_test.c index 491d58236..c9a79e4ab 100644 --- a/srslte/lib/sync/test/sync_test.c +++ b/srslte/lib/sync/test/sync_test.c @@ -38,7 +38,7 @@ #include "srslte/srslte.h" int cell_id = -1, offset = 0; -srslte_cp_t cp = SRSLTE_SRSLTE_CP_NORM; +srslte_cp_t cp = SRSLTE_CP_NORM; uint32_t nof_prb=6; #define FLEN SRSLTE_SF_LEN(fft_size) @@ -66,7 +66,7 @@ void parse_args(int argc, char **argv) { offset = atoi(argv[optind]); break; case 'e': - cp = SRSLTE_SRSLTE_CP_EXT; + cp = SRSLTE_CP_EXT; break; case 'v': srslte_verbose++; diff --git a/srslte/lib/ue/src/ue_cell_search.c b/srslte/lib/ue/src/ue_cell_search.c index 204f43526..4cde570cf 100644 --- a/srslte/lib/ue/src/ue_cell_search.c +++ b/srslte/lib/ue/src/ue_cell_search.c @@ -167,9 +167,9 @@ static void get_cell(srslte_ue_cellsearch_t * q, uint32_t nof_detected_frames, s found_cell->peak /= nof_detected_frames; if (nof_normal > q->mode_ntimes[mode_pos]/2) { - found_cell->cp = SRSLTE_SRSLTE_CP_NORM; + found_cell->cp = SRSLTE_CP_NORM; } else { - found_cell->cp = SRSLTE_SRSLTE_CP_EXT; + found_cell->cp = SRSLTE_CP_EXT; } found_cell->mode = (float) q->mode_ntimes[mode_pos]/nof_detected_frames; diff --git a/srslte/tutorial_examples/pss.c b/srslte/tutorial_examples/pss.c index f0406e7d1..08b58e36a 100644 --- a/srslte/tutorial_examples/pss.c +++ b/srslte/tutorial_examples/pss.c @@ -54,7 +54,7 @@ int nof_frames = -1; uint32_t fft_size=128; float threshold = 0.4; int N_id_2_sync = -1; -srslte_cp_t cp=SRSLTE_SRSLTE_CP_NORM; +srslte_cp_t cp=SRSLTE_CP_NORM; void usage(char *prog) { printf("Usage: %s [aedgtvnp] -f rx_frequency_hz -i cell_id\n", prog); @@ -90,7 +90,7 @@ void parse_args(int argc, char **argv) { threshold = atof(argv[optind]); break; case 'e': - cp = SRSLTE_SRSLTE_CP_EXT; + cp = SRSLTE_CP_EXT; break; case 'i': cell_id = atoi(argv[optind]); @@ -242,7 +242,7 @@ int main(int argc, char **argv) { } // Find SSS - int sss_idx = peak_idx-2*fft_size-(SRSLTE_CP_ISNORM(cp)?SRSLTE_CP(fft_size, SRSLTE_SRSLTE_CP_NORM_LEN):SRSLTE_CP(fft_size, SRSLTE_SRSLTE_CP_EXT_LEN)); + int sss_idx = peak_idx-2*fft_size-(SRSLTE_CP_ISNORM(cp)?SRSLTE_CP(fft_size, SRSLTE_CP_NORM_LEN):SRSLTE_CP(fft_size, SRSLTE_CP_EXT_LEN)); if (sss_idx >= 0 && sss_idx < flen-fft_size) { srslte_sss_synch_m0m1_partial(&sss, &buffer[sss_idx], 3, NULL, &m0, &m0_value, &m1, &m1_value); if (srslte_sss_synch_N_id_1(&sss, m0, m1) != N_id_1) { diff --git a/srslte/tutorial_examples/simple_tx.c b/srslte/tutorial_examples/simple_tx.c index 57bb94d5b..a0cb21f3a 100644 --- a/srslte/tutorial_examples/simple_tx.c +++ b/srslte/tutorial_examples/simple_tx.c @@ -45,7 +45,7 @@ srslte_cell_t cell = { 6, // nof_prb 1, // nof_ports 1, // cell_id - SRSLTE_SRSLTE_CP_NORM, // cyclic prefix + SRSLTE_CP_NORM, // cyclic prefix SRSLTE_PHICH_R_1, // PHICH resources SRSLTE_PHICH_NORM // PHICH length }; @@ -145,7 +145,7 @@ void base_init() { } /* create ifft object */ - if (srslte_ofdm_rx_init(&ifft, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb)) { + if (srslte_ofdm_rx_init(&ifft, SRSLTE_CP_NORM, cell.nof_prb)) { fprintf(stderr, "Error creating iFFT object\n"); exit(-1); } @@ -183,7 +183,7 @@ int main(int argc, char **argv) { parse_args(argc, argv); N_id_2 = cell.id % 3; - sf_n_re = 2 * SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE; + sf_n_re = 2 * SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE; sf_n_samples = 2 * SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb)); cell.phich_length = SRSLTE_PHICH_NORM; @@ -228,9 +228,9 @@ int main(int argc, char **argv) { #ifdef kk if (sf_idx == 0 || sf_idx == 5) { - srslte_pss_put_slot(pss_signal, sf_buffer, cell.nof_prb, SRSLTE_SRSLTE_CP_NORM); + srslte_pss_put_slot(pss_signal, sf_buffer, cell.nof_prb, SRSLTE_CP_NORM); srslte_sss_put_slot(sf_idx ? sss_signal5 : sss_signal0, sf_buffer, cell.nof_prb, - SRSLTE_SRSLTE_CP_NORM); + SRSLTE_CP_NORM); /* Transform to OFDM symbols */ srslte_ofdm_rx_sf(&ifft, sf_buffer, output_buffer); diff --git a/srslte/tutorial_examples/ue_rx.c b/srslte/tutorial_examples/ue_rx.c index 438b05374..b27c99de2 100644 --- a/srslte/tutorial_examples/ue_rx.c +++ b/srslte/tutorial_examples/ue_rx.c @@ -316,7 +316,7 @@ int main(int argc, char **argv) { state = DECODE_PDSCH; /* preset cell configuration */ cell.id = 1; - cell.cp = SRSLTE_SRSLTE_CP_NORM; + cell.cp = SRSLTE_CP_NORM; cell.phich_length = SRSLTE_PHICH_NORM; cell.phich_resources = SRSLTE_PHICH_R_1; cell.nof_ports = 1; @@ -541,9 +541,9 @@ plot_real_t poutfft; plot_real_t pce_angle, pce; plot_scatter_t pscatequal, pscatequal_pdcch; -float tmp_plot[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_SRSLTE_CP_NORM)]; -float tmp_plot2[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_SRSLTE_CP_NORM)]; -float tmp_plot3[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_SRSLTE_CP_NORM)]; +float tmp_plot[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM)]; +float tmp_plot2[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM)]; +float tmp_plot3[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM)]; void *plot_thread_run(void *arg) { int i; From f253321ebbbcb28335802f22f7ee1c99afd6250a Mon Sep 17 00:00:00 2001 From: ismagom Date: Sun, 5 Apr 2015 21:03:01 +0200 Subject: [PATCH 2/2] Added usrp_capture_sync example --- srslte/examples/pdsch_ue.c | 24 +++- srslte/examples/usrp_capture_sync.c | 208 ++++++++++++++++++++++++++++ 2 files changed, 226 insertions(+), 6 deletions(-) create mode 100644 srslte/examples/usrp_capture_sync.c diff --git a/srslte/examples/pdsch_ue.c b/srslte/examples/pdsch_ue.c index 437abd421..b9359d411 100644 --- a/srslte/examples/pdsch_ue.c +++ b/srslte/examples/pdsch_ue.c @@ -80,6 +80,8 @@ typedef struct { uint16_t rnti; char *input_file_name; uint32_t file_nof_prb; + uint32_t file_nof_ports; + uint32_t file_cell_id; char *uhd_args; float uhd_freq; float uhd_freq_offset; @@ -96,6 +98,8 @@ void args_default(prog_args_t *args) { args->force_N_id_2 = -1; // Pick the best args->input_file_name = NULL; args->file_nof_prb = 6; + args->file_nof_ports = 1; + args->file_cell_id = 0; args->uhd_args = ""; args->uhd_freq = -1.0; args->uhd_freq = 8000000.0; @@ -107,7 +111,7 @@ void args_default(prog_args_t *args) { } void usage(prog_args_t *args, char *prog) { - printf("Usage: %s [agildnruv] -f rx_frequency (in Hz) | -i input_file\n", prog); + printf("Usage: %s [agpPcildnruv] -f rx_frequency (in Hz) | -i input_file\n", prog); #ifndef DISABLE_UHD printf("\t-a UHD args [Default %s]\n", args->uhd_args); printf("\t-g UHD RX gain [Default %.2f dB]\n", args->uhd_gain); @@ -117,6 +121,8 @@ void usage(prog_args_t *args, char *prog) { #endif printf("\t-i input_file [Default USRP]\n"); printf("\t-p nof_prb for input file [Default %d]\n", args->file_nof_prb); + printf("\t-P nof_ports for input file [Default %d]\n", args->file_nof_ports); + printf("\t-c cell_id for input file [Default %d]\n", args->file_cell_id); printf("\t-r RNTI [Default 0x%x]\n",args->rnti); printf("\t-l Force N_id_2 [Default best]\n"); #ifndef DISABLE_GRAPHICS @@ -135,7 +141,7 @@ void usage(prog_args_t *args, char *prog) { void parse_args(prog_args_t *args, int argc, char **argv) { int opt; args_default(args); - while ((opt = getopt(argc, argv, "aoglipdnvrfuUsS")) != -1) { + while ((opt = getopt(argc, argv, "aoglipPcdnvrfuUsS")) != -1) { switch (opt) { case 'i': args->input_file_name = argv[optind]; @@ -143,6 +149,12 @@ void parse_args(prog_args_t *args, int argc, char **argv) { case 'p': args->file_nof_prb = atoi(argv[optind]); break; + case 'P': + args->file_nof_ports = atoi(argv[optind]); + break; + case 'c': + args->file_cell_id = atoi(argv[optind]); + break; case 'a': args->uhd_args = argv[optind]; break; @@ -303,11 +315,11 @@ int main(int argc, char **argv) { if (prog_args.input_file_name) { state = DECODE_PDSCH; /* preset cell configuration */ - cell.id = 1; + cell.id = prog_args.file_cell_id; cell.cp = SRSLTE_CP_NORM; cell.phich_length = SRSLTE_PHICH_NORM; cell.phich_resources = SRSLTE_PHICH_R_1; - cell.nof_ports = 1; + cell.nof_ports = prog_args.file_nof_ports; cell.nof_prb = prog_args.file_nof_prb; if (srslte_ue_sync_init_file(&ue_sync, prog_args.file_nof_prb, prog_args.input_file_name)) { @@ -399,8 +411,8 @@ int main(int argc, char **argv) { if (prog_args.rnti != SRSLTE_SIRNTI) { n = srslte_ue_dl_decode(&ue_dl, sf_buffer, data_packed, srslte_ue_sync_get_sfidx(&ue_sync)); } else { - n = srslte_ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data_packed, srslte_ue_sync_get_sfidx(&ue_sync), SRSLTE_SIRNTI, - ((int) ceilf((float)3*(((sfn)/2)%4)/2))%4); + n = srslte_ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data_packed, srslte_ue_sync_get_sfidx(&ue_sync), + SRSLTE_SIRNTI, ((int) ceilf((float)3*(((sfn)/2)%4)/2))%4); } if (n < 0) { // fprintf(stderr, "Error decoding UE DL\n");fflush(stdout); diff --git a/srslte/examples/usrp_capture_sync.c b/srslte/examples/usrp_capture_sync.c new file mode 100644 index 000000000..672b7f96c --- /dev/null +++ b/srslte/examples/usrp_capture_sync.c @@ -0,0 +1,208 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2014 The srsLTE Developers. See the + * COPYRIGHT file at the top-level directory of this distribution. + * + * \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 Lesser 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 Lesser General Public License for more details. + * + * A copy of the GNU Lesser 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 +#include +#include + +#include + +#include "srslte/srslte.h" +#include "srslte/cuhd/cuhd.h" + +static bool keep_running = true; +char *output_file_name = NULL; +char *uhd_args=""; +float uhd_gain=40.0, uhd_freq=-1.0; +int nof_prb = 6; +int nof_subframes = -1; +int N_id_2 = -1; + +void int_handler(int dummy) { + keep_running = false; +} + +void usage(char *prog) { + printf("Usage: %s [agrnv] -l N_id_2 -f rx_frequency_hz -o output_file\n", prog); + printf("\t-a UHD args [Default %s]\n", uhd_args); + printf("\t-g UHD Gain [Default %.2f dB]\n", uhd_gain); + printf("\t-p nof_prb [Default %d]\n", nof_prb); + printf("\t-n nof_subframes [Default %d]\n", nof_subframes); + printf("\t-v srslte_verbose\n"); +} + +void parse_args(int argc, char **argv) { + int opt; + while ((opt = getopt(argc, argv, "agpnvfol")) != -1) { + switch (opt) { + case 'o': + output_file_name = argv[optind]; + break; + case 'a': + uhd_args = argv[optind]; + break; + case 'g': + uhd_gain = atof(argv[optind]); + break; + case 'p': + nof_prb = atoi(argv[optind]); + break; + case 'f': + uhd_freq = atof(argv[optind]); + break; + case 'n': + nof_subframes = atoi(argv[optind]); + break; + case 'l': + N_id_2 = atoi(argv[optind]); + break; + case 'v': + srslte_verbose++; + break; + default: + usage(argv[0]); + exit(-1); + } + } + if (uhd_freq < 0 || N_id_2 == -1 || output_file_name == NULL) { + usage(argv[0]); + exit(-1); + } +} + +int cuhd_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) { + DEBUG(" ---- Receive %d samples ---- \n", nsamples); + return cuhd_recv(h, data, nsamples, 1); +} + +enum receiver_state { DECODE_MIB, SAVE_FILE} state; + +int main(int argc, char **argv) { + cf_t *buffer; + int subframe_count, n; + void *uhd; + srslte_filesink_t sink; + srslte_ue_mib_t ue_mib; + srslte_ue_sync_t ue_sync; + srslte_cell_t cell; + enum receiver_state state; + uint8_t bch_payload[BCH_PAYLOAD_LEN]; + + signal(SIGINT, int_handler); + + parse_args(argc, argv); + + subframe_count = 0; + + srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN); + + printf("Opening UHD device...\n"); + if (cuhd_open(uhd_args, &uhd)) { + fprintf(stderr, "Error opening uhd\n"); + exit(-1); + } + printf("Set RX freq: %.6f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000); + printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_gain)); + printf("Set RX rate: %.6f MHz\n", cuhd_set_rx_srate(uhd, srslte_sampling_freq_hz(nof_prb)) / 1000000); + cuhd_rx_wait_lo_locked(uhd); + cuhd_start_rx_stream(uhd); + + cell.cp = SRSLTE_CP_NORM; + cell.id = N_id_2; + cell.nof_prb = nof_prb; + cell.nof_ports = 1; + + if (srslte_ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper, uhd)) { + fprintf(stderr, "Error initiating ue_sync\n"); + exit(-1); + } + if (srslte_ue_mib_init(&ue_mib, cell)) { + fprintf(stderr, "Error initaiting UE MIB decoder\n"); + exit(-1); + } + state = DECODE_MIB; + bool decoded_mib = false; + uint32_t sfn, sfn_offset; + + printf("Waiting for SFN=0\n"); + while((subframe_count < nof_subframes || nof_subframes == -1) + && keep_running) + { + n = srslte_ue_sync_get_buffer(&ue_sync, &buffer); + if (n < 0) { + fprintf(stderr, "Error receiving samples\n"); + exit(-1); + } + if (n == 1) { + switch (state) { + case DECODE_MIB: + if (srslte_ue_sync_get_sfidx(&ue_sync) == 0) { + srslte_pbch_decode_reset(&ue_mib.pbch); + n = srslte_ue_mib_decode(&ue_mib, buffer, bch_payload, NULL, &sfn_offset); + if (n < 0) { + fprintf(stderr, "Error decoding UE MIB\n"); + exit(-1); + } else if (n == SRSLTE_UE_MIB_FOUND) { + srslte_pbch_mib_unpack(bch_payload, &cell, &sfn); + sfn = (sfn + sfn_offset)%1024; + decoded_mib = true; + } + } + if (decoded_mib && srslte_ue_sync_get_sfidx(&ue_sync) == 9 && sfn == 1023) { + srslte_pbch_mib_fprint(stdout, &cell, sfn, cell.id); + printf("Decoded MIB. SFN: %d\n", sfn); + state = SAVE_FILE; + } + break; + case SAVE_FILE: + printf("Writing to file %4d subframes...\r", subframe_count); + srslte_filesink_write(&sink, buffer, SRSLTE_SF_LEN_PRB(nof_prb)); + subframe_count++; + break; + } + if (srslte_ue_sync_get_sfidx(&ue_sync) == 9) { + sfn++; + if (sfn == 1024) { + sfn = 0; + } + } + + } + } + + srslte_filesink_free(&sink); + cuhd_close(uhd); + srslte_ue_sync_free(&ue_sync); + + printf("Ok - wrote %d subframes\n", subframe_count); + exit(0); +}