diff --git a/CMakeLists.txt b/CMakeLists.txt index 203b0cf5c..20fbed044 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index b22f0870f..d1042d1b8 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/cuhd/CMakeLists.txt b/cuhd/CMakeLists.txt index 92d85b032..c0ab96c17 100644 --- a/cuhd/CMakeLists.txt +++ b/cuhd/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/cuhd/lib/CMakeLists.txt b/cuhd/lib/CMakeLists.txt index 4973a89ed..bd2877d32 100644 --- a/cuhd/lib/CMakeLists.txt +++ b/cuhd/lib/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/mex/CMakeLists.txt b/mex/CMakeLists.txt index 478ec78d9..fbaa0c8a5 100644 --- a/mex/CMakeLists.txt +++ b/mex/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/mex/lib/CMakeLists.txt b/mex/lib/CMakeLists.txt index 896b51709..6f7eb09f4 100644 --- a/mex/lib/CMakeLists.txt +++ b/mex/lib/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/CMakeLists.txt b/srslte/CMakeLists.txt index 60ca1bbd2..89a55022d 100644 --- a/srslte/CMakeLists.txt +++ b/srslte/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. @@ -48,4 +48,5 @@ ADD_SUBDIRECTORY(lib) ADD_SUBDIRECTORY(examples) -add_subdirectory(tutorial_examples) \ No newline at end of file +add_subdirectory(tutorial_examples) +add_subdirectory(itf) \ No newline at end of file diff --git a/srslte/examples/CMakeLists.txt b/srslte/examples/CMakeLists.txt index 1bfe11fac..abd851d7d 100644 --- a/srslte/examples/CMakeLists.txt +++ b/srslte/examples/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/examples/cell_measurement.c b/srslte/examples/cell_measurement.c index 132c46854..3f0edb044 100644 --- a/srslte/examples/cell_measurement.c +++ b/srslte/examples/cell_measurement.c @@ -145,7 +145,7 @@ int main(int argc, char **argv) { uint32_t nof_trials = 0; uint32_t sfn = 0; // system frame number int n; - uint8_t bch_payload[BCH_PAYLOAD_LEN]; + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; uint32_t sfn_offset; float rssi_utra=0,rssi=0, rsrp=0, rsrq=0, snr=0; cf_t *ce[SRSLTE_MAX_PORTS]; diff --git a/srslte/examples/cuhd_utils.c b/srslte/examples/cuhd_utils.c index 2a3f27ccb..ab709593f 100644 --- a/srslte/examples/cuhd_utils.c +++ b/srslte/examples/cuhd_utils.c @@ -53,7 +53,7 @@ int cuhd_recv_wrapper_cs(void *h, void *data, uint32_t nsamples, srslte_timestam int cuhd_mib_decoder(void *uhd, uint32_t max_nof_frames, srslte_cell_t *cell) { int ret = SRSLTE_ERROR; srslte_ue_mib_sync_t ue_mib; - uint8_t bch_payload[BCH_PAYLOAD_LEN]; + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; if (srslte_ue_mib_sync_init(&ue_mib, cell->id, cell->cp, cuhd_recv_wrapper_cs, uhd)) { fprintf(stderr, "Error initiating srslte_ue_mib_sync\n"); diff --git a/srslte/examples/pdsch_enodeb.c b/srslte/examples/pdsch_enodeb.c index 5fd8cea9d..8f5ebcce5 100644 --- a/srslte/examples/pdsch_enodeb.c +++ b/srslte/examples/pdsch_enodeb.c @@ -441,7 +441,7 @@ int main(int argc, char **argv) { cf_t pss_signal[SRSLTE_PSS_LEN]; float sss_signal0[SRSLTE_SSS_LEN]; // for subframe 0 float sss_signal5[SRSLTE_SSS_LEN]; // for subframe 5 - uint8_t bch_payload[BCH_PAYLOAD_LEN]; + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; int i; cf_t *sf_symbols[SRSLTE_MAX_PORTS]; cf_t *slot1_symbols[SRSLTE_MAX_PORTS]; diff --git a/srslte/examples/pdsch_ue.c b/srslte/examples/pdsch_ue.c index 0abc87860..31688638e 100644 --- a/srslte/examples/pdsch_ue.c +++ b/srslte/examples/pdsch_ue.c @@ -235,7 +235,7 @@ int main(int argc, char **argv) { #endif uint32_t nof_trials = 0; int n; - uint8_t bch_payload[BCH_PAYLOAD_LEN]; + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; uint32_t sfn_offset; parse_args(&prog_args, argc, argv); diff --git a/srslte/examples/prach_ue.c b/srslte/examples/prach_ue.c index a8e04267f..4e5fc9e8e 100644 --- a/srslte/examples/prach_ue.c +++ b/srslte/examples/prach_ue.c @@ -295,7 +295,7 @@ int main(int argc, char **argv) { srslte_ue_mib_t ue_mib; void *uhd; int n; - uint8_t bch_payload[BCH_PAYLOAD_LEN]; + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; uint32_t sfn_offset; rar_msg_t rar_msg; srslte_ra_pusch_t ra_pusch; @@ -382,7 +382,7 @@ int main(int argc, char **argv) { perror("maloc"); exit(-1); } - if(srslte_prach_gen(&prach, prog_args.preamble_idx, 0, prog_args.beta_prach, prach_buffer)){ + if(srslte_prach_gen(&prach, prog_args.preamble_idx, 0, prach_buffer)){ fprintf(stderr, "Error generating prach sequence\n"); return -1; } @@ -398,7 +398,7 @@ int main(int argc, char **argv) { bzero(&drms_cfg, sizeof(srslte_refsignal_drms_pusch_cfg_t)); drms_cfg.beta_pusch = 1.0; drms_cfg.group_hopping_en = false; - drms_cfg.srslte_sequence_hopping_en = false; + drms_cfg.sequence_hopping_en = false; drms_cfg.delta_ss = 0; drms_cfg.cyclic_shift = 0; drms_cfg.cyclic_shift_for_drms = 0; @@ -555,7 +555,7 @@ int main(int argc, char **argv) { ra_pusch.rv_idx = rv[i]; ul_sf_idx = (srslte_ue_sync_get_sfidx(&ue_sync)+6+i*8)%10; - n = srslte_ue_ul_srslte_pusch_encode_rnti(&ue_ul, &ra_pusch, data, ul_sf_idx, rar_msg.temp_c_rnti, ul_signal); + n = srslte_ue_ul_pusch_encode_rnti(&ue_ul, &ra_pusch, data, ul_sf_idx, rar_msg.temp_c_rnti, ul_signal); if (n < 0) { fprintf(stderr, "Error encoding PUSCH\n"); exit(-1); @@ -604,7 +604,7 @@ int main(int argc, char **argv) { printf("L: %d\n", ra_pusch.prb_alloc.L_prb); // srslte_ue_ul_set_cfo(&ue_ul, srslte_sync_get_cfo(&ue_sync.strack)); srslte_bit_pack_vector((uint8_t*) conn_request_msg, data, ra_pusch.mcs.tbs); - n = srslte_ue_ul_srslte_pusch_encode_rnti(&ue_ul, &ra_pusch, data, ul_sf_idx, 111, ul_signal); + n = srslte_ue_ul_pusch_encode_rnti(&ue_ul, &ra_pusch, data, ul_sf_idx, 111, ul_signal); if (n < 0) { fprintf(stderr, "Error encoding PUSCH\n"); exit(-1); diff --git a/srslte/include/srslte/ch_estimation/refsignal_ul.h b/srslte/include/srslte/ch_estimation/refsignal_ul.h index 79d487946..59765f8ec 100644 --- a/srslte/include/srslte/ch_estimation/refsignal_ul.h +++ b/srslte/include/srslte/ch_estimation/refsignal_ul.h @@ -48,7 +48,7 @@ typedef struct SRSLTE_API { bool en_drms_2; float beta_pusch; bool group_hopping_en; - bool srslte_sequence_hopping_en; + bool sequence_hopping_en; }srslte_refsignal_drms_pusch_cfg_t; typedef struct SRSLTE_API { diff --git a/srslte/include/srslte/phch/pbch.h b/srslte/include/srslte/phch/pbch.h index 73601da89..5c7101c46 100644 --- a/srslte/include/srslte/phch/pbch.h +++ b/srslte/include/srslte/phch/pbch.h @@ -41,12 +41,9 @@ #include "srslte/fec/viterbi.h" #include "srslte/fec/crc.h" -#define BCH_PAYLOAD_LEN 24 -#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 SRSLTE_BCH_PAYLOAD_LEN 24 +#define SRSLTE_BCH_PAYLOADCRC_LEN (SRSLTE_BCH_PAYLOAD_LEN+16) +#define SRSLTE_BCH_ENCODED_LEN 3*(SRSLTE_BCH_PAYLOADCRC_LEN) /* PBCH object */ typedef struct SRSLTE_API { @@ -61,10 +58,10 @@ typedef struct SRSLTE_API { cf_t *d; float *llr; float *temp; - float rm_f[BCH_ENCODED_LEN]; + float rm_f[SRSLTE_BCH_ENCODED_LEN]; uint8_t *rm_b; - uint8_t data[BCH_PAYLOADCRC_LEN]; - uint8_t data_enc[BCH_ENCODED_LEN]; + uint8_t data[SRSLTE_BCH_PAYLOADCRC_LEN]; + uint8_t data_enc[SRSLTE_BCH_ENCODED_LEN]; uint32_t frame_idx; @@ -87,12 +84,12 @@ SRSLTE_API int srslte_pbch_decode(srslte_pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS], float noise_estimate, - uint8_t bch_payload[BCH_PAYLOAD_LEN], + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], uint32_t *nof_tx_ports, uint32_t *sfn_offset); SRSLTE_API int srslte_pbch_encode(srslte_pbch_t *q, - uint8_t bch_payload[BCH_PAYLOAD_LEN], + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], cf_t *slot1_symbols[SRSLTE_MAX_PORTS]); SRSLTE_API void srslte_pbch_decode_reset(srslte_pbch_t *q); diff --git a/srslte/include/srslte/phch/prach.h b/srslte/include/srslte/phch/prach.h index 6b001b600..31cfbd8e8 100644 --- a/srslte/include/srslte/phch/prach.h +++ b/srslte/include/srslte/phch/prach.h @@ -79,9 +79,25 @@ typedef struct SRSLTE_API { srslte_dft_plan_t *zc_fft; srslte_dft_plan_t *zc_ifft; - } srslte_prach_t; +typedef struct SRSLTE_API { + int nof_sf; + uint32_t sf[5]; +} srslte_prach_sf_config_t; + +typedef enum SRSLTE_API { + SRSLTE_PRACH_SFN_EVEN = 0, + SRSLTE_PRACH_SFN_ANY, +} srslte_prach_sfn_t; + +SRSLTE_API uint32_t srslte_prach_get_preamble_format(uint32_t config_idx); + +SRSLTE_API srslte_prach_sfn_t srslte_prach_get_sfn(uint32_t config_idx); + +SRSLTE_API void srslte_prach_sf_config(uint32_t config_idx, + srslte_prach_sf_config_t *sf_config); + SRSLTE_API int srslte_prach_init(srslte_prach_t *p, uint32_t N_ifft_ul, uint32_t preamble_format, @@ -92,7 +108,6 @@ SRSLTE_API int srslte_prach_init(srslte_prach_t *p, SRSLTE_API int srslte_prach_gen(srslte_prach_t *p, uint32_t seq_index, uint32_t freq_offset, - float beta_prach, cf_t *signal); SRSLTE_API int srslte_prach_detect(srslte_prach_t *p, diff --git a/srslte/include/srslte/phch/ra.h b/srslte/include/srslte/phch/ra.h index 956734e90..98819913e 100644 --- a/srslte/include/srslte/phch/ra.h +++ b/srslte/include/srslte/phch/ra.h @@ -93,7 +93,6 @@ typedef struct SRSLTE_API { } srslte_ra_ul_alloc_t; typedef struct SRSLTE_API { - uint16_t rnti; srslte_ra_type_t alloc_type; union { srslte_ra_type0_t type0_alloc; diff --git a/srslte/include/srslte/phch/uci.h b/srslte/include/srslte/phch/uci.h index 5eb0e77e2..cf6bb770f 100644 --- a/srslte/include/srslte/phch/uci.h +++ b/srslte/include/srslte/phch/uci.h @@ -48,13 +48,13 @@ typedef struct SRSLTE_API { typedef struct SRSLTE_API { uint8_t *uci_cqi; uint32_t uci_cqi_len; - float beta_cqi; - uint8_t uci_ri; // Only 1-bit supported for RI + uint32_t I_offset_cqi; + uint8_t uci_ri; // Only 1-bit supported for RI uint32_t uci_ri_len; - float beta_ri; - uint8_t uci_ack; // Only 1-bit supported for HARQ + uint32_t I_offset_ri; + uint8_t uci_ack; // Only 1-bit supported for HARQ uint32_t uci_ack_len; - float beta_ack; + uint32_t I_offset_ack; } srslte_uci_data_t; SRSLTE_API int srslte_uci_cqi_init(srslte_uci_cqi_pusch_t *q); diff --git a/srslte/include/srslte/ue/ue_dl.h b/srslte/include/srslte/ue/ue_dl.h index 2f958fab3..450ccc93e 100644 --- a/srslte/include/srslte/ue/ue_dl.h +++ b/srslte/include/srslte/ue/ue_dl.h @@ -105,6 +105,12 @@ SRSLTE_API int srslte_ue_dl_find_ul_dci(srslte_ue_dl_t *q, uint32_t sf_idx, uint16_t rnti); +SRSLTE_API int srslte_ue_dl_find_dl_dci(srslte_ue_dl_t *q, + srslte_dci_msg_t *dci_msg, + uint32_t cfi, + uint32_t sf_idx, + uint16_t rnti); + SRSLTE_API int srslte_ue_dl_decode(srslte_ue_dl_t * q, cf_t *input, uint8_t *data, diff --git a/srslte/include/srslte/ue/ue_mib.h b/srslte/include/srslte/ue/ue_mib.h index dea6031ee..8befca969 100644 --- a/srslte/include/srslte/ue/ue_mib.h +++ b/srslte/include/srslte/ue/ue_mib.h @@ -72,7 +72,7 @@ typedef struct SRSLTE_API { srslte_chest_dl_t chest; srslte_pbch_t pbch; - uint8_t bch_payload[BCH_PAYLOAD_LEN]; + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; uint32_t nof_tx_ports; uint32_t sfn_offset; @@ -88,7 +88,7 @@ SRSLTE_API void srslte_ue_mib_reset(srslte_ue_mib_t * q); SRSLTE_API int srslte_ue_mib_decode(srslte_ue_mib_t * q, cf_t *input, - uint8_t bch_payload[BCH_PAYLOAD_LEN], + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], uint32_t *nof_tx_ports, uint32_t *sfn_offset); @@ -113,7 +113,7 @@ SRSLTE_API void srslte_ue_mib_sync_reset(srslte_ue_mib_sync_t * q); SRSLTE_API int srslte_ue_mib_sync_decode(srslte_ue_mib_sync_t * q, uint32_t max_frames_timeout, - uint8_t bch_payload[BCH_PAYLOAD_LEN], + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], uint32_t *nof_tx_ports, uint32_t *sfn_offset); diff --git a/srslte/include/srslte/ue/ue_phy.h b/srslte/include/srslte/ue/ue_phy.h deleted file mode 100644 index d7a56acae..000000000 --- a/srslte/include/srslte/ue/ue_phy.h +++ /dev/null @@ -1,161 +0,0 @@ -/** - * - * \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 "srslte/srslte.h" -#include "srslte/utils/queue.h" - -#ifndef UEPHY_H -#define UEPHY_H - -#define SYNC_MODE_CV 0 -#define SYNC_MODE_CALLBACK 1 -#define SYNC_MODE SYNC_MODE_CV - -namespace srslte { - -typedef _Complex float cf_t; - -class ue_phy -{ -public: - - typedef enum {DOWNLINK, UPLINK} direction_t; - - typedef enum { - PDCCH_UL_SEARCH_CRNTI = 0, - PDCCH_UL_SEARCH_RA_PROC, - PDCCH_UL_SEARCH_SPS, - PDCCH_UL_SEARCH_TEMPORAL, - PDCCH_UL_SEARCH_TPC_PUSCH, - PDCCH_UL_SEARCH_TPC_PUCCH - } pdcch_ul_search_t; - - typedef enum { - PDCCH_DL_SEARCH_CRNTI = 0, - PDCCH_DL_SEARCH_SIRNTI, - PDCCH_DL_SEARCH_PRNTI, - PDCCH_DL_SEARCH_RARNTI, - PDCCH_DL_SEARCH_TEMPORAL, - PDCCH_DL_SEARCH_SPS - } pdcch_dl_search_t; - - /* Uplink/Downlink scheduling grant generated by a successfully decoded PDCCH */ - class sched_grant { - public: - uint16_t get_rnti(); - uint32_t get_rv(); - void set_rv(uint32_t rv); - bool get_ndi(); - bool get_cqi_request(); - uint32_t get_harq_process(); - private: - union { - srslte_ra_pusch_t ul_grant; - srslte_ra_pdsch_t dl_grant; - }; - direction_t dir; - }; - - - /* Uplink scheduling assignment. The MAC instructs the PHY to prepare an UL packet (PUSCH or PUCCH) - * for transmission. The MAC must call generate_pusch() to set the packet ready for transmission - */ - class ul_buffer : public queue::element { - public: - ul_buffer(srslte_cell_t cell); - void generate_pusch(sched_grant pusch_grant, uint8_t *payload, srslte_uci_data_t uci_data); - void generate_pucch(srslte_uci_data_t uci_data); - private: - srslte_ue_ul_t ue_ul; - bool signal_generated = false; - cf_t* signal_buffer = NULL; - uint32_t tti = 0; - }; - - /* Class for the processing of Downlink buffers. The MAC obtains a buffer for a given TTI and then - * gets ul/dl scheduling grants and/or processes phich/pdsch channels - */ - class dl_buffer : public queue::element { - public: - dl_buffer(srslte_cell_t cell); - sched_grant get_ul_grant(pdcch_ul_search_t mode, uint32_t rnti); - sched_grant get_dl_grant(pdcch_dl_search_t mode, uint32_t rnti); - bool decode_phich(srslte_phich_alloc_t assignment); - bool decode_pdsch(sched_grant pdsch_grant, uint8_t *payload); // returns true or false for CRC OK/KO - private: - srslte_ue_dl_t ue_dl; - srslte_phich_t phich; - cf_t *signal_buffer = NULL; - bool sf_symbols_and_ce_done = false; - bool pdcch_llr_extracted = false; - uint32_t tti = 0; - }; - - -#if SYNC_MODE==SYNC_MODE_CALLBACK - typedef (*ue_phy_tti_clock_fcn_t) (void); - ue_phy(ue_phy_tti_clock_fcn_t tti_clock_callback); -#else - ue_phy(); -#endif - ~ue_phy(); - - void measure(); // TBD - void dl_bch(); - void start_rxtx(); - void stop_rxtx(); - void init_prach(); - void send_prach(/* prach_cfg_t in prach.h with power, seq idx, etc */); - void set_param(); - - uint32_t get_tti(); -#if SYNC_MODE==SYNC_MODE_CV - std::condition_variable tti_cv; - std::mutex tti_mutex; -#endif - - ul_buffer get_ul_buffer(uint32_t tti); - dl_buffer get_dl_buffer(uint32_t tti); - -private: - enum { - IDLE, MEASURE, RX_BCH, RXTX - } phy_state; - - bool prach_initiated = false; - bool prach_ready_to_send = false; - srslte_prach_t prach; - - queue ul_buffer_queue; - queue dl_buffer_queue; - - pthread_t radio_thread; - void *radio_handler; -}; - -} -#endif \ No newline at end of file diff --git a/srslte/include/srslte/ue/ue_ul.h b/srslte/include/srslte/ue/ue_ul.h index d1865a067..14574f926 100644 --- a/srslte/include/srslte/ue/ue_ul.h +++ b/srslte/include/srslte/ue/ue_ul.h @@ -86,33 +86,33 @@ SRSLTE_API void srslte_ue_ul_set_pusch_cfg(srslte_ue_ul_t *q, srslte_refsignal_drms_pusch_cfg_t *drms_cfg, srslte_pusch_hopping_cfg_t *pusch_hopping_cfg); -SRSLTE_API int srslte_ue_ul_srslte_pusch_encode(srslte_ue_ul_t *q, - srslte_ra_pusch_t *ra_ul, - uint8_t *data, - uint32_t sf_idx, - cf_t *output_signal); - -SRSLTE_API int srslte_ue_ul_srslte_pusch_encode_rnti(srslte_ue_ul_t *q, - srslte_ra_pusch_t *ra_ul, - uint8_t *data, - uint32_t sf_idx, - uint16_t rnti, - cf_t *output_signal); - -SRSLTE_API int srslte_ue_ul_srslte_pusch_uci_encode(srslte_ue_ul_t *q, - srslte_ra_pusch_t *ra_ul, - uint8_t *data, - srslte_uci_data_t uci_data, - uint32_t sf_idx, - cf_t *output_signal); - -SRSLTE_API int srslte_ue_ul_srslte_pusch_uci_encode_rnti(srslte_ue_ul_t *q, - srslte_ra_pusch_t *ra_ul, - uint8_t *data, - srslte_uci_data_t uci_data, - uint32_t sf_idx, - uint16_t rnti, - cf_t *output_signal); +SRSLTE_API int srslte_ue_ul_pusch_encode(srslte_ue_ul_t *q, + srslte_ra_pusch_t *ra_ul, + uint8_t *data, + uint32_t sf_idx, + cf_t *output_signal); + +SRSLTE_API int srslte_ue_ul_pusch_encode_rnti(srslte_ue_ul_t *q, + srslte_ra_pusch_t *ra_ul, + uint8_t *data, + uint32_t sf_idx, + uint16_t rnti, + cf_t *output_signal); + +SRSLTE_API int srslte_ue_ul_pusch_uci_encode(srslte_ue_ul_t *q, + srslte_ra_pusch_t *ra_ul, + uint8_t *data, + srslte_uci_data_t uci_data, + uint32_t sf_idx, + cf_t *output_signal); + +SRSLTE_API int srslte_ue_ul_pusch_uci_encode_rnti(srslte_ue_ul_t *q, + srslte_ra_pusch_t *ra_ul, + uint8_t *data, + srslte_uci_data_t uci_data, + uint32_t sf_idx, + uint16_t rnti, + cf_t *output_signal); SRSLTE_API void srslte_ue_ul_reset(srslte_ue_ul_t *q); diff --git a/srslte/itf/CMakeLists.txt b/srslte/itf/CMakeLists.txt new file mode 100644 index 000000000..6bf1e39e6 --- /dev/null +++ b/srslte/itf/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright 2012-2013 The srsLTE Developers. See the +# COPYRIGHT file at the top-level directory of this distribution. +# +# 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/. +# + + +ADD_LIBRARY(srslte++ SHARED ue_phy.cc) +TARGET_LINK_LIBRARIES(srslte++ srslte m ${FFTW3F_LIBRARIES}) +INSTALL(TARGETS srslte++ DESTINATION ${LIBRARY_DIR}) +LIBLTE_SET_PIC(srslte++) diff --git a/srslte/itf/queue.cc b/srslte/itf/queue.cc new file mode 100644 index 000000000..2fc95b585 --- /dev/null +++ b/srslte/itf/queue.cc @@ -0,0 +1,49 @@ +/** + * + * \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 "queue.h" + +srslte::queue::queue(uint32_t nof_elements, uint32_t element_size) +{ + buffer_of_elements = (queue::element**) malloc(sizeof(queue::element*) * nof_elements); + for (int i=0;i +#include +#include +#include "srslte/srslte.h" +#include "ue_phy.h" + + +/* + * CLASS SCHED_GRANT + * + */ + +/* Returns the RNTI associated with the UL/DL scheduling grant */ +uint16_t srslte::ue_phy::sched_grant::get_rnti() { + return rnti; +} + +uint32_t srslte::ue_phy::sched_grant::get_rv() { + if (dir == UPLINK) { + return ul_grant.rv_idx; + } else { + return dl_grant.rv_idx; + } +} + +void srslte::ue_phy::sched_grant::set_rv(uint32_t rv) { + if (dir == UPLINK) { + ul_grant.rv_idx = rv; + } else { + dl_grant.rv_idx = rv; + } +} + +bool srslte::ue_phy::sched_grant::get_ndi() { + if (dir == UPLINK) { + return ul_grant.ndi; + } else { + return dl_grant.ndi; + } +} + +bool srslte::ue_phy::sched_grant::get_cqi_request() { + if (dir == UPLINK) { + return ul_grant.ndi; + } else { + return dl_grant.ndi; + } +} + +uint32_t srslte::ue_phy::sched_grant::get_current_tti() { + return current_tti; +} + +int srslte::ue_phy::sched_grant::get_harq_process() { + if (dir == UPLINK) { + return -1; + } else { + return dl_grant.harq_process; + } +} + +bool srslte::ue_phy::sched_grant::is_uplink() { + return dir == UPLINK; +} + +bool srslte::ue_phy::sched_grant::is_downlink() { + return dir == DOWNLINK; +} +void* srslte::ue_phy::sched_grant::get_grant_ptr() { + if (is_uplink()) { + return (void*) &ul_grant; + } else { + return (void*) &dl_grant; + } +} + + +/* + * CLASS UL_BUFFER + * + */ +bool srslte::ue_phy::ul_buffer::init_cell(srslte_cell_t cell_, int64_t *params_db_) { + cell = cell_; + params_db = params_db_; + signal_generated = false; + current_tx_nb = 0; + if (!srslte_ue_ul_init(&ue_ul, cell)) { + signal_buffer = (cf_t*) srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb)); + return signal_buffer?true:false; + } else { + return false; + } +} + +void srslte::ue_phy::ul_buffer::free_cell() { + if (signal_buffer) { + free(signal_buffer); + } + srslte_ue_ul_free(&ue_ul); +} + +bool srslte::ue_phy::ul_buffer::generate_pusch(sched_grant pusch_grant, + uint8_t *payload, + srslte_uci_data_t uci_data) +{ + if (pusch_grant.is_uplink()) { + fprintf(stderr, "Invalid scheduling grant. Grant is for Downlink\n"); + return false; + } + + srslte_refsignal_drms_pusch_cfg_t drms_cfg; + bzero(&drms_cfg, sizeof(srslte_refsignal_drms_pusch_cfg_t)); + + drms_cfg.beta_pusch = params_db[PARAM_PUSCH_BETA]; + drms_cfg.group_hopping_en = params_db[PARAM_PUSCH_RS_GROUP_HOPPING_EN]; + drms_cfg.sequence_hopping_en = params_db[PARAM_PUSCH_RS_SEQUENCE_HOPPING_EN]; + drms_cfg.cyclic_shift = params_db[PARAM_PUSCH_RS_CYCLIC_SHIFT]; + drms_cfg.delta_ss = params_db[PARAM_PUSCH_RS_GROUP_ASSIGNMENT]; + + srslte_pusch_hopping_cfg_t pusch_hopping; + pusch_hopping.n_sb = params_db[PARAM_PUSCH_HOPPING_N_SB]; + pusch_hopping.hop_mode = params_db[PARAM_PUSCH_HOPPING_INTRA_SF] ? + pusch_hopping.SRSLTE_PUSCH_HOP_MODE_INTRA_SF : + pusch_hopping.SRSLTE_PUSCH_HOP_MODE_INTER_SF; + pusch_hopping.hopping_offset = params_db[PARAM_PUSCH_HOPPING_OFFSET]; + pusch_hopping.current_tx_nb = current_tx_nb; + + srslte_ue_ul_set_pusch_cfg(&ue_ul, &drms_cfg, &pusch_hopping); + + int n = srslte_ue_ul_pusch_uci_encode_rnti(&ue_ul, (srslte_ra_pusch_t*) pusch_grant.get_grant_ptr(), + payload, uci_data, + tti%10, pusch_grant.get_rnti(), + signal_buffer); + if (n < 0) { + fprintf(stderr, "Error encoding PUSCH\n"); + return false; + } + + signal_generated = true; + + /* This is done by the transmission thread + srslte_vec_sc_prod_cfc(signal_buffer, beta_pusch, signal_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb)); + float time_adv_sec = TA_OFFSET + ((float) n_ta)*LTE_TS; + srslte_timestamp_t next_tx_time; + srslte_timestamp_copy(&next_tx_time, &last_rx_time); + srslte_timestamp_add(&next_tx_time, 0, 0.003 - time_adv_sec); + */ + // Send through radio + + return true; +} + +bool srslte::ue_phy::ul_buffer::generate_pucch(srslte_uci_data_t uci_data) +{ + return false; +} + +/* + * CLASS DL_BUFFER + * + */ +bool srslte::ue_phy::dl_buffer::init_cell(srslte_cell_t cell_, int64_t *params_db_) +{ + params_db = params_db_; + cell = cell_; + sf_symbols_and_ce_done = false; + pdcch_llr_extracted = false; + tti = 0; + if (srslte_ue_dl_init(&ue_dl, cell)) { + signal_buffer = (cf_t*) srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb)); + return signal_buffer?true:false; + } else { + return false; + } +} + +void srslte::ue_phy::dl_buffer::free_cell() +{ + if (signal_buffer) { + free(signal_buffer); + } + srslte_ue_dl_free(&ue_dl); +} + +bool srslte::ue_phy::dl_buffer::get_ul_grant(pdcch_ul_search_t mode, uint32_t rnti, ue_phy::sched_grant *grant) +{ + if (!sf_symbols_and_ce_done) { + if (srslte_ue_dl_decode_fft_estimate(&ue_dl, signal_buffer, tti%10, &cfi) < 0) { + return false; + } + sf_symbols_and_ce_done = true; + } + if (!pdcch_llr_extracted) { + if (srslte_pdcch_extract_llr(&ue_dl.pdcch, ue_dl.sf_symbols, ue_dl.ce, 0, tti%10, cfi)) { + return false; + } + pdcch_llr_extracted = true; + } + + srslte_dci_msg_t dci_msg; + if (srslte_ue_dl_find_ul_dci(&ue_dl, &dci_msg, cfi, tti%10, rnti)) { + return false; + } + + if (srslte_dci_msg_to_ra_ul(&dci_msg, cell.nof_prb, + params_db[PARAM_PUSCH_HOPPING_OFFSET], + (srslte_ra_pusch_t*) grant->get_grant_ptr())) + { + return false; + } + + return true; +} + +bool srslte::ue_phy::dl_buffer::get_dl_grant(pdcch_dl_search_t mode, uint32_t rnti, ue_phy::sched_grant *grant) +{ + if (!sf_symbols_and_ce_done) { + if (srslte_ue_dl_decode_fft_estimate(&ue_dl, signal_buffer, tti%10, &cfi) < 0) { + return false; + } + sf_symbols_and_ce_done = true; + } + if (!pdcch_llr_extracted) { + if (srslte_pdcch_extract_llr(&ue_dl.pdcch, ue_dl.sf_symbols, ue_dl.ce, 0, tti%10, cfi)) { + return false; + } + pdcch_llr_extracted = true; + } + + srslte_dci_msg_t dci_msg; + if (srslte_ue_dl_find_dl_dci(&ue_dl, &dci_msg, cfi, tti%10, rnti)) { + return false; + } + + if (srslte_dci_msg_to_ra_dl(&dci_msg, rnti, cell, cfi, + (srslte_ra_pdsch_t*) grant->get_grant_ptr())) + { + return false; + } + + return true; +} + +bool srslte::ue_phy::dl_buffer::decode_phich(srslte_phich_alloc_t assignment) +{ + if (!sf_symbols_and_ce_done) { + if (srslte_ue_dl_decode_fft_estimate(&ue_dl, signal_buffer, tti%10, &cfi) < 0) { + return false; + } + sf_symbols_and_ce_done = true; + } + return false; +} + +bool srslte::ue_phy::dl_buffer::decode_pdsch(sched_grant pdsch_grant, uint8_t *payload) +{ + if (!sf_symbols_and_ce_done) { + if (srslte_ue_dl_decode_fft_estimate(&ue_dl, signal_buffer, tti%10, &cfi) < 0) { + return false; + } + sf_symbols_and_ce_done = true; + } + srslte_ra_pdsch_t *ra_dl = (srslte_ra_pdsch_t*) pdsch_grant.get_grant_ptr(); + if (srslte_harq_setup_dl(&ue_dl.harq_process[0], ra_dl->mcs, + pdsch_grant.get_rv(), tti%10, &ra_dl->prb_alloc)) { + fprintf(stderr, "Error configuring HARQ process\n"); + return SRSLTE_ERROR; + } + if (ue_dl.harq_process[0].mcs.mod > 0 && ue_dl.harq_process[0].mcs.tbs >= 0) { + int ret = srslte_pdsch_decode_rnti(&ue_dl.pdsch, &ue_dl.harq_process[0], ue_dl.sf_symbols, + ue_dl.ce, 0, pdsch_grant.get_rnti(), payload); + if (ret == SRSLTE_SUCCESS) { + return true; + } + } + return false; +} + + + + + + + +/* + * CLASS UE_PHY + * + */ +#if SYNC_MODE==SYNC_MODE_CALLBACK +srslte::ue_phy::ue_phy(ue_phy_callback_t tti_clock_callback_, ue_phy_callback_t status_change_) +{ + tti_clock_callback = tti_clock_callback_; + status_change = status_change_; + ul_buffer_queue = new queue(6, sizeof(ul_buffer)); + dl_buffer_queue = new queue(6, sizeof(dl_buffer)); + + started = true; + + pthread_create(&radio_thread, NULL, radio_thread_fnc, this); +} + +#else +srslte::ue_phy::ue_phy() +{ + +} + +#endif + +srslte::ue_phy::~ue_phy() +{ + started = false; + + pthread_join(radio_thread, NULL); + + delete ul_buffer_queue; + delete dl_buffer_queue; + + if (prach_initiated) { + for (uint32_t i=0;i<64;i++) { + if (prach_buffer[i]) { + free(prach_buffer[i]); + } + } + srslte_prach_free(&prach); + } +} + +bool srslte::ue_phy::init_prach() +{ + + if (srslte_prach_init(&prach, srslte_symbol_sz(cell.nof_prb), + srslte_prach_get_preamble_format(params_db[PARAMS_PRACH_CONFIG_INDEX]), + params_db[PARAMS_PRACH_ROOT_SEQ_IDX], + params_db[PARAMS_PRACH_HIGH_SPEED_FLAG]?true:false, + params_db[PARAMS_PRACH_ZC_CONFIG])) { + return false; + } + + prach_len = prach.N_seq + prach.N_cp; + for (uint32_t i=0;i<64;i++) { + prach_buffer[i] = (cf_t*) srslte_vec_malloc(prach_len*sizeof(cf_t)); + if(!prach_buffer[i]) { + return false; + } + if(srslte_prach_gen(&prach, i, params_db[PARAMS_PRACH_FREQ_OFFSET], prach_buffer[i])){ + return false; + } + } + prach_initiated = true; + return true; +} + +// FIXME: Add PRACH power control +void srslte::ue_phy::send_prach(uint32_t preamble_idx) +{ + if (prach_initiated && phy_state == RXTX) { + prach_ready_to_send = true; + } +} + +// Do fast measurement on RSSI and/or PSS autocorrelation energy or PSR +void srslte::ue_phy::measure() +{ + if (phy_state == IDLE) { + // capture and do measurement + status_change(); + } +} + +void srslte::ue_phy::dl_bch() +{ + if (phy_state == IDLE) { + phy_state = RX_BCH; + status_change(); + } +} + +void srslte::ue_phy::start_rxtx() +{ + if (phy_state == MIB_DECODED) { + // Set sampling freq to MIB PRB + // start radio streaming + phy_state = RXTX; + status_change(); + } +} + +void srslte::ue_phy::stop_rxtx() +{ + // stop radio + phy_state = IDLE; + status_change(); + } + +bool srslte::ue_phy::status_is_idle() { + return phy_state == IDLE; +} + +bool srslte::ue_phy::status_is_rxtx() { + return phy_state == RXTX; +} + +bool srslte::ue_phy::status_bch_decoded(uint8_t payload[SRSLTE_BCH_PAYLOAD_LEN]) +{ + if (phy_state == MIB_DECODED) { + memcpy(payload, bch_payload, SRSLTE_BCH_PAYLOAD_LEN*sizeof(uint8_t)); + } +} + + +static void* radio_thread_fnc(void *arg) { + srslte::ue_phy* ue_phy = (srslte::ue_phy*) arg; + ue_phy->main_radio_loop(); + return NULL; +} + +int radio_recv_wrapper_cs(void*,void*,uint32_t,srslte_timestamp_t*); + +bool srslte::ue_phy::rx_bch() +{ + srslte_ue_cellsearch_result_t found_cells[3]; + srslte_ue_cellsearch_t cs; + + bzero(found_cells, 3*sizeof(srslte_ue_cellsearch_result_t)); + + if (srslte_ue_cellsearch_init(&cs, radio_recv_wrapper_cs, radio_handler)) { + return false; + } + + srslte_ue_cellsearch_set_nof_frames_to_scan(&cs, params_db[PARAM_CELLSEARCH_TIMEOUT_PSS_NFRAMES]); + srslte_ue_cellsearch_set_threshold(&cs, (float) params_db[PARAM_CELLSEARCH_CORRELATION_THRESHOLD]/10); + + // set sampling freq 1.92 MHz + // set frequency, gain etc + // start radio streaming + + /* Find a cell in the given N_id_2 or go through the 3 of them to find the strongest */ + uint32_t max_peak_cell = 0; + int ret = SRSLTE_ERROR; + uint32_t force_N_id_2 = params_db[PARAM_CELLSEARCH_FORCE_N_ID_2]; + if (force_N_id_2 >= 0 && force_N_id_2 < 3) { + ret = srslte_ue_cellsearch_scan_N_id_2(&cs, force_N_id_2, &found_cells[force_N_id_2]); + max_peak_cell = force_N_id_2; + } else { + ret = srslte_ue_cellsearch_scan(&cs, found_cells, &max_peak_cell); + } + // Stop radio + + srslte_ue_cellsearch_free(&cs); + + if (ret < 0) { + fprintf(stderr, "Error searching cell"); + return false; + } else if (ret == 0) { + fprintf(stderr, "Could not find any cell in this frequency"); + return false; + } + + // Save result + cell.id = found_cells[max_peak_cell].cell_id; + cell.cp = found_cells[max_peak_cell].cp; + + printf("Found CELL PHY_ID: %d, CP: %s PSR: %.1f AbsPower: %.1f dBm", + cell.id, srslte_cp_string(cell.cp), + found_cells[max_peak_cell].psr, 30+10*log10(found_cells[max_peak_cell].peak)); + + srslte_ue_mib_sync_t ue_mib; + + if (srslte_ue_mib_sync_init(&ue_mib, cell.id, cell.cp, radio_recv_wrapper_cs, radio_handler)) { + return false; + } + + uint32_t sfn, sfn_offset; + + /* Find and decode MIB */ + + // Start RX stream again + + ret = srslte_ue_mib_sync_decode(&ue_mib, params_db[PARAM_CELLSEARCH_TIMEOUT_MIB_NFRAMES], + bch_payload, &cell.nof_ports, &sfn_offset); + // Stop RX stream again + srslte_ue_mib_sync_free(&ue_mib); + + if (ret == 1) { + srslte_pbch_mib_unpack(bch_payload, &cell, &sfn); + sfn = (sfn + sfn_offset)%1024; + current_tti = sfn*10+1; + printf("MIB decoded: %d ports, SFN: %d, TTI: %d", cell.nof_ports, sfn, current_tti); + return true; + } else { + printf("Error decoding MIB"); + return false; + } +} + +void srslte::ue_phy::run_rx_bch_state() { + if (rx_bch()) { + for(uint32_t i=0;i<6;i++) { + get_ul_buffer(i)->init_cell(cell, params_db); + get_dl_buffer(i)->init_cell(cell, params_db); + } + // init also ue_mib for sfn synch + phy_state = MIB_DECODED; + status_change(); + } else { + phy_state = IDLE; + } +} + +void srslte::ue_phy::run_rx_tx_state() +{ + // if not synched -> go through mib + // else receive sync frame on dl_frame + // if have to send prach, send it + // if ul ready to send send +} + +void srslte::ue_phy::main_radio_loop() { + while(started) { + switch(phy_state) { + case IDLE: + case MIB_DECODED: + break; + case RX_BCH: + run_rx_bch_state(); + break; + case RXTX: + run_rx_tx_state(); + break; + } + } +} + +void srslte::ue_phy::set_param(param_t param, int64_t value) +{ + params_db[param] = value; +} + +srslte::ue_phy::ul_buffer* srslte::ue_phy::get_ul_buffer(uint32_t tti) +{ + return (srslte::ue_phy::ul_buffer*) ul_buffer_queue->get(tti); +} + +srslte::ue_phy::dl_buffer* srslte::ue_phy::get_dl_buffer(uint32_t tti) +{ + return (srslte::ue_phy::dl_buffer*) dl_buffer_queue->get(tti); +} + + diff --git a/srslte/itf/ue_phy.h b/srslte/itf/ue_phy.h new file mode 100644 index 000000000..78aab3dc2 --- /dev/null +++ b/srslte/itf/ue_phy.h @@ -0,0 +1,233 @@ +/** + * + * \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 "srslte/srslte.h" +#include "queue.h" + +#ifndef UEPHY_H +#define UEPHY_H + +#define SYNC_MODE_CV 0 +#define SYNC_MODE_CALLBACK 1 +#define SYNC_MODE SYNC_MODE_CALLBACK + +namespace srslte { + +typedef _Complex float cf_t; + +class ue_phy +{ +public: + + typedef enum {DOWNLINK=0, UPLINK=1} direction_t; + + typedef enum { + PDCCH_UL_SEARCH_CRNTI = 0, + PDCCH_UL_SEARCH_RA_PROC, + PDCCH_UL_SEARCH_SPS, + PDCCH_UL_SEARCH_TEMPORAL, + PDCCH_UL_SEARCH_TPC_PUSCH, + PDCCH_UL_SEARCH_TPC_PUCCH + } pdcch_ul_search_t; + + typedef enum { + PDCCH_DL_SEARCH_CRNTI = 0, + PDCCH_DL_SEARCH_SIRNTI, + PDCCH_DL_SEARCH_PRNTI, + PDCCH_DL_SEARCH_RARNTI, + PDCCH_DL_SEARCH_TEMPORAL, + PDCCH_DL_SEARCH_SPS + } pdcch_dl_search_t; + + /* Uplink/Downlink scheduling grant generated by a successfully decoded PDCCH */ + class sched_grant { + public: + uint16_t get_rnti(); + uint32_t get_rv(); + void set_rv(uint32_t rv); + bool get_ndi(); + uint32_t get_current_tti(); + bool get_cqi_request(); + int get_harq_process(); + bool is_uplink(); + bool is_downlink(); + void* get_grant_ptr(); + protected: + union { + srslte_ra_pusch_t ul_grant; + srslte_ra_pdsch_t dl_grant; + }; + direction_t dir; + uint16_t rnti; + uint32_t current_tti; + }; + + /* Uplink scheduling assignment. The MAC instructs the PHY to prepare an UL packet (PUSCH or PUCCH) + * for transmission. The MAC must call generate_pusch() to set the packet ready for transmission + */ + class ul_buffer : public queue::element { + public: + bool init_cell(srslte_cell_t cell, int64_t *params_db); + void free_cell(); + void set_tti(uint32_t tti); + void set_current_tx_nb(uint32_t current_tx_nb); + bool generate_pusch(sched_grant pusch_grant, uint8_t *payload, srslte_uci_data_t uci_data); + bool generate_pucch(srslte_uci_data_t uci_data); + private: + int64_t *params_db; + srslte_cell_t cell; + srslte_ue_ul_t ue_ul; + bool signal_generated; + cf_t* signal_buffer; + uint32_t tti; + uint32_t current_tx_nb; + }; + + /* Class for the processing of Downlink buffers. The MAC obtains a buffer for a given TTI and then + * gets ul/dl scheduling grants and/or processes phich/pdsch channels + */ + class dl_buffer : public queue::element { + public: + bool init_cell(srslte_cell_t cell, int64_t *params_db); + void free_cell(); + bool get_ul_grant(pdcch_ul_search_t mode, uint32_t rnti, ue_phy::sched_grant *grant); + bool get_dl_grant(pdcch_dl_search_t mode, uint32_t rnti, ue_phy::sched_grant *grant); + bool decode_phich(srslte_phich_alloc_t assignment); + bool decode_pdsch(sched_grant pdsch_grant, uint8_t *payload); // returns true or false for CRC OK/KO + private: + int64_t *params_db; + srslte_cell_t cell; + srslte_ue_dl_t ue_dl; + srslte_phich_t phich; + cf_t *signal_buffer; + uint32_t cfi; + bool sf_symbols_and_ce_done; + bool pdcch_llr_extracted; + uint32_t tti; + }; + +#if SYNC_MODE==SYNC_MODE_CALLBACK + typedef void (*ue_phy_callback_t) (void); + ue_phy_callback_t tti_clock_callback; + ue_phy_callback_t status_change; + ue_phy(ue_phy_callback_t tti_clock_callback, ue_phy_callback_t status_change); +#else + ue_phy(); +#endif + ~ue_phy(); + + void measure(); // TBD + void dl_bch(); + void start_rxtx(); + void stop_rxtx(); + bool init_prach(); + void send_prach(uint32_t preamble_idx); + + bool status_is_idle(); + bool status_is_rxtx(); + bool status_bch_decoded(uint8_t payload[SRSLTE_BCH_PAYLOAD_LEN]); + + typedef enum { + + PARAM_DL_FREQ = 0, + PARAM_UL_FREQ, + + PARAM_CELLSEARCH_TIMEOUT_PSS_NFRAMES, + PARAM_CELLSEARCH_TIMEOUT_MIB_NFRAMES, + PARAM_CELLSEARCH_FORCE_N_ID_2, + PARAM_CELLSEARCH_CORRELATION_THRESHOLD, // integer that will be divided by 10 + + PARAM_PUSCH_BETA, + + PARAM_PUSCH_RS_GROUP_HOPPING_EN, + PARAM_PUSCH_RS_SEQUENCE_HOPPING_EN, + PARAM_PUSCH_RS_CYCLIC_SHIFT, + PARAM_PUSCH_RS_GROUP_ASSIGNMENT, + + PARAM_PUSCH_HOPPING_N_SB, + PARAM_PUSCH_HOPPING_INTRA_SF, + PARAM_PUSCH_HOPPING_OFFSET, + + PARAMS_UCI_I_OFFSET_ACK, + PARAMS_UCI_I_OFFSET_RI, + PARAMS_UCI_I_OFFSET_CQI, + + PARAMS_PRACH_CONFIG_INDEX, + PARAMS_PRACH_ROOT_SEQ_IDX, + PARAMS_PRACH_HIGH_SPEED_FLAG, + PARAMS_PRACH_ZC_CONFIG, + PARAMS_PRACH_FREQ_OFFSET, + + PARAM_NOF_PARAMS, + } param_t; + + + void set_param(param_t param, int64_t value); + + uint32_t get_tti(); +#if SYNC_MODE==SYNC_MODE_CV + std::condition_variable tti_cv; + std::mutex tti_mutex; +#endif + + ul_buffer* get_ul_buffer(uint32_t tti); + dl_buffer* get_dl_buffer(uint32_t tti); + + void main_radio_loop(); + +private: + enum { + IDLE, MEASURE, RX_BCH, MIB_DECODED, RXTX + } phy_state; + + int64_t *params_db; + + srslte_cell_t cell; + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; + bool is_sfn_synched = false; + bool started = false; + uint32_t current_tti; + + bool prach_initiated = false; + bool prach_ready_to_send = false; + uint32_t prach_len; + cf_t *prach_buffer[64]; + srslte_prach_t prach; + + queue *ul_buffer_queue; + queue *dl_buffer_queue; + + pthread_t radio_thread; + void *radio_handler; + static void* radio_thread_fnc(void *arg); + void run_rx_bch_state(); + bool rx_bch(); + void run_rx_tx_state(); +}; + +} +#endif \ No newline at end of file diff --git a/srslte/lib/CMakeLists.txt b/srslte/lib/CMakeLists.txt index fb8b4c5e3..b887feeb3 100644 --- a/srslte/lib/CMakeLists.txt +++ b/srslte/lib/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/lib/ch_estimation/src/refsignal_ul.c b/srslte/lib/ch_estimation/src/refsignal_ul.c index 5283a4b89..64077d168 100644 --- a/srslte/lib/ch_estimation/src/refsignal_ul.c +++ b/srslte/lib/ch_estimation/src/refsignal_ul.c @@ -297,7 +297,7 @@ int srslte_refsignal_dmrs_gen(srslte_refsignal_ul_t *q, srslte_refsignal_drms_pu // Get sequence hopping number v uint32_t v = 0; - if (nof_prb >= 6 && cfg->srslte_sequence_hopping_en) { + if (nof_prb >= 6 && cfg->sequence_hopping_en) { v = q->v_pusch[ns][cfg->delta_ss]; } diff --git a/srslte/lib/ch_estimation/test/CMakeLists.txt b/srslte/lib/ch_estimation/test/CMakeLists.txt index 2ded0a94f..3d832283b 100644 --- a/srslte/lib/ch_estimation/test/CMakeLists.txt +++ b/srslte/lib/ch_estimation/test/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/lib/ch_estimation/test/refsignal_pusch_mex.c b/srslte/lib/ch_estimation/test/refsignal_pusch_mex.c index 9b0afbe03..783527b99 100644 --- a/srslte/lib/ch_estimation/test/refsignal_pusch_mex.c +++ b/srslte/lib/ch_estimation/test/refsignal_pusch_mex.c @@ -77,13 +77,13 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) pusch_cfg.group_hopping_en = false; - pusch_cfg.srslte_sequence_hopping_en = false; + pusch_cfg.sequence_hopping_en = false; char *tmp = mexutils_get_char_struct(UECFG, "Hopping"); if (tmp) { if (!strcmp(tmp, "Group")) { pusch_cfg.group_hopping_en = true; } else if (!strcmp(tmp, "Sequence")) { - pusch_cfg.srslte_sequence_hopping_en = true; + pusch_cfg.sequence_hopping_en = true; } mxFree(tmp); } diff --git a/srslte/lib/ch_estimation/test/refsignal_ul_test.c b/srslte/lib/ch_estimation/test/refsignal_ul_test.c index c772a4571..2a7391631 100644 --- a/srslte/lib/ch_estimation/test/refsignal_ul_test.c +++ b/srslte/lib/ch_estimation/test/refsignal_ul_test.c @@ -108,13 +108,13 @@ int main(int argc, char **argv) { pusch_cfg.delta_ss = delta_ss; if (!h) { pusch_cfg.group_hopping_en = false; - pusch_cfg.srslte_sequence_hopping_en = false; + pusch_cfg.sequence_hopping_en = false; } else if (h == 1) { pusch_cfg.group_hopping_en = false; - pusch_cfg.srslte_sequence_hopping_en = true; + pusch_cfg.sequence_hopping_en = true; } else if (h == 2) { pusch_cfg.group_hopping_en = true; - pusch_cfg.srslte_sequence_hopping_en = false; + pusch_cfg.sequence_hopping_en = false; } pusch_cfg.en_drms_2 = true; printf("Beta: %f, ",pusch_cfg.beta_pusch); diff --git a/srslte/lib/dft/test/CMakeLists.txt b/srslte/lib/dft/test/CMakeLists.txt index f01278d66..b092327c1 100644 --- a/srslte/lib/dft/test/CMakeLists.txt +++ b/srslte/lib/dft/test/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/lib/fec/test/CMakeLists.txt b/srslte/lib/fec/test/CMakeLists.txt index 696283de0..596dca9ee 100644 --- a/srslte/lib/fec/test/CMakeLists.txt +++ b/srslte/lib/fec/test/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/lib/mimo/test/CMakeLists.txt b/srslte/lib/mimo/test/CMakeLists.txt index 9f3ff616b..c67dae8db 100644 --- a/srslte/lib/mimo/test/CMakeLists.txt +++ b/srslte/lib/mimo/test/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/lib/modem/test/CMakeLists.txt b/srslte/lib/modem/test/CMakeLists.txt index fa8dd1726..6bbdd1c6e 100644 --- a/srslte/lib/modem/test/CMakeLists.txt +++ b/srslte/lib/modem/test/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/lib/phch/src/pbch.c b/srslte/lib/phch/src/pbch.c index 97f22b86f..cab90c678 100644 --- a/srslte/lib/phch/src/pbch.c +++ b/srslte/lib/phch/src/pbch.c @@ -41,6 +41,9 @@ #include "srslte/utils/vector.h" #include "srslte/utils/debug.h" +#define PBCH_RE_SRSLTE_SRSLTE_CP_NORM 240 +#define PBCH_RE_SRSLTE_SRSLTE_CP_EXT 216 + const uint8_t srslte_crc_mask[4][16] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, @@ -359,7 +362,7 @@ void srslte_pbch_decode_reset(srslte_pbch_t *q) { void srslte_crc_set_mask(uint8_t *data, int nof_ports) { int i; for (i = 0; i < 16; i++) { - data[BCH_PAYLOAD_LEN + i] = (data[BCH_PAYLOAD_LEN + i] + srslte_crc_mask[nof_ports - 1][i]) % 2; + data[SRSLTE_BCH_PAYLOAD_LEN + i] = (data[SRSLTE_BCH_PAYLOAD_LEN + i] + srslte_crc_mask[nof_ports - 1][i]) % 2; } } @@ -371,13 +374,13 @@ void srslte_crc_set_mask(uint8_t *data, int nof_ports) { * Returns 0 if the data is correct, -1 otherwise */ uint32_t srslte_pbch_crc_check(srslte_pbch_t *q, uint8_t *bits, uint32_t nof_ports) { - uint8_t data[BCH_PAYLOADCRC_LEN]; - memcpy(data, bits, BCH_PAYLOADCRC_LEN * sizeof(uint8_t)); + uint8_t data[SRSLTE_BCH_PAYLOADCRC_LEN]; + memcpy(data, bits, SRSLTE_BCH_PAYLOADCRC_LEN * sizeof(uint8_t)); srslte_crc_set_mask(data, nof_ports); - int ret = srslte_crc_checksum(&q->crc, data, BCH_PAYLOADCRC_LEN); + int ret = srslte_crc_checksum(&q->crc, data, SRSLTE_BCH_PAYLOADCRC_LEN); if (ret == 0) { uint32_t chkzeros=0; - for (int i=0;itemp, 4 * nof_bits, q->rm_f, BCH_ENCODED_LEN); + srslte_rm_conv_rx(q->temp, 4 * nof_bits, q->rm_f, SRSLTE_BCH_ENCODED_LEN); /* decode */ - srslte_viterbi_decode_f(&q->decoder, q->rm_f, q->data, BCH_PAYLOADCRC_LEN); + srslte_viterbi_decode_f(&q->decoder, q->rm_f, q->data, SRSLTE_BCH_PAYLOADCRC_LEN); if (!srslte_pbch_crc_check(q, q->data, nof_ports)) { return 1; @@ -432,7 +435,7 @@ int decode_frame(srslte_pbch_t *q, uint32_t src, uint32_t dst, uint32_t n, * Returns 1 if successfully decoded MIB, 0 if not and -1 on error */ int srslte_pbch_decode(srslte_pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS], float noise_estimate, - uint8_t bch_payload[BCH_PAYLOAD_LEN], uint32_t *nof_tx_ports, uint32_t *sfn_offset) + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], uint32_t *nof_tx_ports, uint32_t *sfn_offset) { uint32_t src, dst, nb; uint32_t nant; @@ -517,7 +520,7 @@ int srslte_pbch_decode(srslte_pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRS *nof_tx_ports = nant; } if (bch_payload) { - memcpy(bch_payload, q->data, sizeof(uint8_t) * BCH_PAYLOAD_LEN); + memcpy(bch_payload, q->data, sizeof(uint8_t) * SRSLTE_BCH_PAYLOAD_LEN); } } } @@ -537,7 +540,7 @@ int srslte_pbch_decode(srslte_pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRS /** Converts the MIB message to symbols mapped to SLOT #1 ready for transmission */ -int srslte_pbch_encode(srslte_pbch_t *q, uint8_t bch_payload[BCH_PAYLOAD_LEN], cf_t *slot1_symbols[SRSLTE_MAX_PORTS]) { +int srslte_pbch_encode(srslte_pbch_t *q, uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], cf_t *slot1_symbols[SRSLTE_MAX_PORTS]) { int i; int nof_bits; cf_t *x[SRSLTE_MAX_LAYERS]; @@ -560,15 +563,15 @@ int srslte_pbch_encode(srslte_pbch_t *q, uint8_t bch_payload[BCH_PAYLOAD_LEN], c memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); if (q->frame_idx == 0) { - memcpy(q->data, bch_payload, sizeof(uint8_t) * BCH_PAYLOAD_LEN); + memcpy(q->data, bch_payload, sizeof(uint8_t) * SRSLTE_BCH_PAYLOAD_LEN); /* encode & modulate */ - srslte_crc_attach(&q->crc, q->data, BCH_PAYLOAD_LEN); + srslte_crc_attach(&q->crc, q->data, SRSLTE_BCH_PAYLOAD_LEN); srslte_crc_set_mask(q->data, q->cell.nof_ports); - srslte_convcoder_encode(&q->encoder, q->data, q->data_enc, BCH_PAYLOADCRC_LEN); + srslte_convcoder_encode(&q->encoder, q->data, q->data_enc, SRSLTE_BCH_PAYLOADCRC_LEN); - srslte_rm_conv_tx(q->data_enc, BCH_ENCODED_LEN, q->rm_b, 4 * nof_bits); + srslte_rm_conv_tx(q->data_enc, SRSLTE_BCH_ENCODED_LEN, q->rm_b, 4 * nof_bits); } diff --git a/srslte/lib/phch/src/prach.c b/srslte/lib/phch/src/prach.c index c32305dbd..9426c39ed 100644 --- a/srslte/lib/phch/src/prach.c +++ b/srslte/lib/phch/src/prach.c @@ -152,6 +152,42 @@ uint32_t prach_zc_roots_format4[138] = { 61, 78, 62, 77, 63, 76, 64, 75, 65, 74, 66, 73, 67, 72, 68, 71, 69, 70}; + +srslte_prach_sf_config_t prach_sf_config[16] = { + {1, {1, 0, 0, 0, 0}}, + {1, {4, 0, 0, 0, 0}}, + {1, {7, 0, 0, 0, 0}}, + {1, {1, 0, 0, 0, 0}}, + {1, {4, 0, 0, 0, 0}}, + {1, {7, 0, 0, 0, 0}}, + {2, {1, 6, 0, 0, 0}}, + {2, {2, 7, 0, 0, 0}}, + {2, {3, 8, 0, 0, 0}}, + {3, {1, 4, 7, 0, 0}}, + {3, {2, 5, 8, 0, 0}}, + {3, {3, 6, 9, 0, 0}}, + {5, {0, 2, 4, 6, 8}}, + {5, {1, 3, 5, 7, 9}}, + {-1, {0, 0, 0, 0, 0}}, // this means all subframes + {1, {9, 0, 0, 0, 0}}}; + +uint32_t srslte_prach_get_preamble_format(uint32_t config_idx) { + return config_idx/16; +} + +srslte_prach_sfn_t srslte_prach_get_sfn(uint32_t config_idx) { + if ((config_idx%16)<3 || (config_idx%16)==15) { + return SRSLTE_PRACH_SFN_EVEN; + } else { + return SRSLTE_PRACH_SFN_ANY; + } +} + +void srslte_prach_sf_config(uint32_t config_idx, srslte_prach_sf_config_t *sf_config) { + memcpy(sf_config, &prach_sf_config[config_idx%16], sizeof(srslte_prach_sf_config_t)); +} + + // For debug use only void print(void *d, uint32_t size, uint32_t len, char* file_str) { @@ -375,7 +411,6 @@ int srslte_prach_init(srslte_prach_t *p, int srslte_prach_gen(srslte_prach_t *p, uint32_t seq_index, uint32_t freq_offset, - float beta_prach, cf_t *signal) { int ret = SRSLTE_ERROR; @@ -405,9 +440,6 @@ int srslte_prach_gen(srslte_prach_t *p, signal[p->N_cp+i] = p->ifft_out[i%p->N_ifft_prach]; } - // Normalize - srslte_vec_sc_prod_cfc(signal, beta_prach, signal, (p->N_cp + p->N_seq)); - ret = SRSLTE_SUCCESS; } diff --git a/srslte/lib/phch/src/sch.c b/srslte/lib/phch/src/sch.c index 0945ae65c..3878530fe 100644 --- a/srslte/lib/phch/src/sch.c +++ b/srslte/lib/phch/src/sch.c @@ -42,6 +42,18 @@ #include "srslte/utils/debug.h" #include "srslte/utils/vector.h" +/* 36.213 Table 8.6.3-1: Mapping of HARQ-ACK offset values and the index signalled by higher layers */ +float beta_harq_offset[16] = {2.0, 2.5, 3.125, 4.0, 5.0, 6.250, 8.0, 10.0, + 12.625, 15.875, 20.0, 31.0, 50.0, 80.0, 126.0, -1.0}; + +/* 36.213 Table 8.6.3-2: Mapping of RI offset values and the index signalled by higher layers */ +float beta_ri_offset[16] = {1.25, 1.625, 2.0, 2.5, 3.125, 4.0, 5.0, 6.25, 8.0, 10.0, + 12.625, 15.875, 20.0, -1.0, -1.0, -1.0}; + +/* 36.213 Table 8.6.3-3: Mapping of CQI offset values and the index signalled by higher layers */ +float beta_cqi_offset[16] = {-1.0, -1.0, 1.125, 1.25, 1.375, 1.625, 1.750, 2.0, 2.25, 2.5, 2.875, + 3.125, 3.5, 4.0, 5.0, 6.25}; + int srslte_sch_init(srslte_sch_t *q) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -459,9 +471,9 @@ int srslte_ulsch_uci_encode(srslte_sch_t *q, srslte_harq_t *harq, uint8_t *data, // Encode RI if (uci_data.uci_ri_len > 0) { - float beta = uci_data.beta_ri; + float beta = beta_ri_offset[uci_data.I_offset_ri]; if (harq->mcs.tbs == 0) { - beta /= uci_data.beta_cqi; + beta /= beta_cqi_offset[uci_data.I_offset_cqi]; } ret = srslte_uci_encode_ri(uci_data.uci_ri, uci_data.uci_cqi_len, beta, harq, nb_q/Q_m, q_bits); if (ret < 0) { @@ -473,8 +485,9 @@ int srslte_ulsch_uci_encode(srslte_sch_t *q, srslte_harq_t *harq, uint8_t *data, // Encode CQI if (uci_data.uci_cqi_len > 0) { - ret = srslte_uci_encode_cqi_pusch(&q->uci_cqi, uci_data.uci_cqi, uci_data.uci_cqi_len, uci_data.beta_cqi, - Q_prime_ri, harq, g_bits); + ret = srslte_uci_encode_cqi_pusch(&q->uci_cqi, uci_data.uci_cqi, uci_data.uci_cqi_len, + beta_cqi_offset[uci_data.I_offset_cqi], + Q_prime_ri, harq, g_bits); if (ret < 0) { return ret; } @@ -497,9 +510,9 @@ int srslte_ulsch_uci_encode(srslte_sch_t *q, srslte_harq_t *harq, uint8_t *data, // Encode (and interleave) ACK if (uci_data.uci_ack_len > 0) { - float beta = uci_data.beta_ack; + float beta = beta_harq_offset[uci_data.I_offset_ack]; if (harq->mcs.tbs == 0) { - beta /= uci_data.beta_cqi; + beta /= beta_cqi_offset[uci_data.I_offset_cqi]; } ret = srslte_uci_encode_ack(uci_data.uci_ack, uci_data.uci_cqi_len, beta, harq, nb_q/Q_m, q_bits); if (ret < 0) { diff --git a/srslte/lib/phch/src/uci.c b/srslte/lib/phch/src/uci.c index 01e45f697..15dcac8b0 100644 --- a/srslte/lib/phch/src/uci.c +++ b/srslte/lib/phch/src/uci.c @@ -102,7 +102,7 @@ static uint8_t M_basis_seq_pucch[20][13]={ {1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0}, }; - + int srslte_uci_cqi_init(srslte_uci_cqi_pusch_t *q) { if (srslte_crc_init(&q->crc, SRSLTE_LTE_CRC8, 8)) { return SRSLTE_ERROR; @@ -220,7 +220,10 @@ int srslte_uci_encode_cqi_pucch(uint8_t *cqi_data, uint32_t cqi_len, uint8_t b_b int srslte_uci_encode_cqi_pusch(srslte_uci_cqi_pusch_t *q, uint8_t *cqi_data, uint32_t cqi_len, float beta, uint32_t Q_prime_ri, srslte_harq_t *harq, uint8_t *q_bits) { - + if (beta < 0) { + fprintf(stderr, "Error beta is reserved\n"); + return -1; + } uint32_t Q_prime = Q_prime_cqi(cqi_len, beta, Q_prime_ri, harq); uint32_t Q_m = srslte_mod_bits_x_symbol(harq->mcs.mod); @@ -244,6 +247,7 @@ static int uci_ulsch_interleave_ack(uint8_t ack_coded_bits[6], uint32_t ack_q_bi const uint32_t ack_column_set_norm[4] = {2, 3, 8, 9}; const uint32_t ack_column_set_ext[4] = {1, 2, 6, 7}; + if (H_prime_total/N_pusch_symbs >= 1+ack_q_bit_idx/4) { uint32_t row = H_prime_total/N_pusch_symbs-1-ack_q_bit_idx/4; @@ -287,6 +291,12 @@ static int uci_ulsch_interleave_ri(uint8_t ri_coded_bits[6], uint32_t ri_q_bit_i } static uint32_t Q_prime_ri_ack(uint32_t O, uint32_t O_cqi, float beta, srslte_harq_t *harq) { + + if (beta < 0) { + fprintf(stderr, "Error beta is reserved\n"); + return -1; + } + uint32_t M_sc = harq->ul_alloc.L_prb * SRSLTE_NRE; uint32_t K = harq->cb_segm.C1*harq->cb_segm.K1 + @@ -321,8 +331,15 @@ static void encode_ri_ack(uint8_t data, uint8_t q_encoded_bits[6], uint8_t Q_m) /* Encode UCI HARQ/ACK bits as described in 5.2.2.6 of 36.212 * Currently only supporting 1-bit HARQ */ -int srslte_uci_encode_ack(uint8_t data, uint32_t O_cqi, float beta, srslte_harq_t *harq, uint32_t H_prime_total, uint8_t *q_bits) +int srslte_uci_encode_ack(uint8_t data, uint32_t O_cqi, + float beta, srslte_harq_t *harq, + uint32_t H_prime_total, uint8_t *q_bits) { + if (beta < 0) { + fprintf(stderr, "Error beta is reserved\n"); + return -1; + } + uint32_t Q_m = srslte_mod_bits_x_symbol(harq->mcs.mod); uint32_t Qprime = Q_prime_ri_ack(1, O_cqi, beta, harq); uint8_t q_encoded_bits[6]; @@ -340,8 +357,15 @@ int srslte_uci_encode_ack(uint8_t data, uint32_t O_cqi, float beta, srslte_harq_ /* Encode UCI RI bits as described in 5.2.2.6 of 36.212 * Currently only supporting 1-bit RI */ -int srslte_uci_encode_ri(uint8_t data, uint32_t O_cqi, float beta, srslte_harq_t *harq, uint32_t H_prime_total, uint8_t *q_bits) +int srslte_uci_encode_ri(uint8_t data, uint32_t O_cqi, float beta, + srslte_harq_t *harq, uint32_t H_prime_total, + uint8_t *q_bits) { + if (beta < 0) { + fprintf(stderr, "Error beta is reserved\n"); + return -1; + } + uint32_t Q_m = srslte_mod_bits_x_symbol(harq->mcs.mod); uint32_t Qprime = Q_prime_ri_ack(1, O_cqi, beta, harq); uint8_t q_encoded_bits[6]; diff --git a/srslte/lib/phch/test/CMakeLists.txt b/srslte/lib/phch/test/CMakeLists.txt index 533c932ac..5a8c5ec72 100644 --- a/srslte/lib/phch/test/CMakeLists.txt +++ b/srslte/lib/phch/test/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/lib/phch/test/pbch_file_test.c b/srslte/lib/phch/test/pbch_file_test.c index a929efd31..3e510c586 100644 --- a/srslte/lib/phch/test/pbch_file_test.c +++ b/srslte/lib/phch/test/pbch_file_test.c @@ -47,7 +47,7 @@ srslte_cell_t cell = { int nof_frames = 1; -uint8_t bch_payload_file[BCH_PAYLOAD_LEN] = {0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +uint8_t bch_payload_file[SRSLTE_BCH_PAYLOAD_LEN] = {0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; #define FLEN (10*SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb))) @@ -171,7 +171,7 @@ void base_free() { } int main(int argc, char **argv) { - uint8_t bch_payload[BCH_PAYLOAD_LEN]; + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; int n; uint32_t nof_tx_ports, sfn_offset; cf_t *ce_slot1[SRSLTE_MAX_PORTS]; @@ -231,8 +231,8 @@ int main(int argc, char **argv) { exit(-1); } else { printf("MIB decoded OK. Nof ports: %d. SFN offset: %d Payload: ", nof_tx_ports, sfn_offset); - srslte_vec_fprint_hex(stdout, bch_payload, BCH_PAYLOAD_LEN); - if (nof_tx_ports == 2 && sfn_offset == 0 && !memcmp(bch_payload, bch_payload_file, BCH_PAYLOAD_LEN)) { + srslte_vec_fprint_hex(stdout, bch_payload, SRSLTE_BCH_PAYLOAD_LEN); + if (nof_tx_ports == 2 && sfn_offset == 0 && !memcmp(bch_payload, bch_payload_file, SRSLTE_BCH_PAYLOAD_LEN)) { printf("This is the signal.1.92M.dat file\n"); exit(0); } else { diff --git a/srslte/lib/phch/test/pbch_test.c b/srslte/lib/phch/test/pbch_test.c index b5a3b783c..6546b87e1 100644 --- a/srslte/lib/phch/test/pbch_test.c +++ b/srslte/lib/phch/test/pbch_test.c @@ -77,7 +77,7 @@ void parse_args(int argc, char **argv) { int main(int argc, char **argv) { srslte_pbch_t pbch; - uint8_t bch_payload_tx[BCH_PAYLOAD_LEN], bch_payload_rx[BCH_PAYLOAD_LEN]; + uint8_t bch_payload_tx[SRSLTE_BCH_PAYLOAD_LEN], bch_payload_rx[SRSLTE_BCH_PAYLOAD_LEN]; int i, j; cf_t *ce[SRSLTE_MAX_PORTS]; int nof_re; @@ -111,7 +111,7 @@ int main(int argc, char **argv) { } srand(time(NULL)); - for (i=0;iN_seq; diff --git a/srslte/lib/phch/test/prach_test_mex.c b/srslte/lib/phch/test/prach_test_mex.c index 5c279d6c2..fbb986a02 100644 --- a/srslte/lib/phch/test/prach_test_mex.c +++ b/srslte/lib/phch/test/prach_test_mex.c @@ -97,7 +97,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } bzero(signal, sizeof(cf_t) * nof_samples); - if (srslte_prach_gen(&prach, seq_idx, frequency_offset, 0.2, signal)) { + if (srslte_prach_gen(&prach, seq_idx, frequency_offset, signal)) { mexErrMsgTxt("Error generating PRACH\n"); return; } diff --git a/srslte/lib/phch/test/prach_test_multi.c b/srslte/lib/phch/test/prach_test_multi.c index 83f65dacb..417514238 100644 --- a/srslte/lib/phch/test/prach_test_multi.c +++ b/srslte/lib/phch/test/prach_test_multi.c @@ -84,7 +84,6 @@ int main(int argc, char **argv) { srslte_prach_gen(p, seq_index, frequency_offset, - 0.2, preamble); for(int i=0;iN_cp+p->N_seq;i++) diff --git a/srslte/lib/phch/test/pusch_encode_test_mex.c b/srslte/lib/phch/test/pusch_encode_test_mex.c index 75602f51e..b3eda2769 100644 --- a/srslte/lib/phch/test/pusch_encode_test_mex.c +++ b/srslte/lib/phch/test/pusch_encode_test_mex.c @@ -156,17 +156,15 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) free(tmp); - if (mexutils_read_float_struct(PUSCHCFG, "BetaCQI", &uci_data.beta_cqi)) { - uci_data.beta_cqi = 2.0; + if (mexutils_read_uint32_struct(PUSCHCFG, "OffsetCQI", &uci_data.I_offset_cqi)) { + uci_data.I_offset_cqi = 7; } - if (mexutils_read_float_struct(PUSCHCFG, "BetaRI", &uci_data.beta_ri)) { - uci_data.beta_ri = 2.0; + if (mexutils_read_uint32_struct(PUSCHCFG, "OffsetRI", &uci_data.I_offset_ri)) { + uci_data.I_offset_ri = 2; } - if (mexutils_read_float_struct(PUSCHCFG, "BetaACK", &uci_data.beta_ack)) { - uci_data.beta_ack = 2.0; + if (mexutils_read_uint32_struct(PUSCHCFG, "OffsetACK", &uci_data.I_offset_ack)) { + uci_data.I_offset_ack = 0; } - mexPrintf("Beta_CQI: %.1f, Beta_ACK: %.1f, Beta_RI: %.1f\n", - uci_data.beta_cqi, uci_data.beta_ack, uci_data.beta_ri); mexPrintf("TRBL_len: %d, CQI_len: %d, ACK_len: %d (%d), RI_len: %d (%d)\n", mcs.tbs, uci_data.uci_cqi_len, uci_data.uci_ack_len, uci_data.uci_ack, uci_data.uci_ri_len, uci_data.uci_ri); diff --git a/srslte/lib/phch/test/pusch_test.c b/srslte/lib/phch/test/pusch_test.c index 6de2a7a6e..883c0aaf9 100644 --- a/srslte/lib/phch/test/pusch_test.c +++ b/srslte/lib/phch/test/pusch_test.c @@ -165,9 +165,9 @@ int main(int argc, char **argv) { } srslte_uci_data_t uci_data; bzero(&uci_data, sizeof(srslte_uci_data_t)); - uci_data.beta_cqi = 2.0; - uci_data.beta_ri = 2.0; - uci_data.beta_ack = 2.0; + uci_data.I_offset_cqi = 7; + uci_data.I_offset_ri = 2; + uci_data.I_offset_ack = 0; uci_data.uci_cqi_len = 0; uci_data.uci_ri_len = 0; diff --git a/srslte/lib/phch/test/ulsch_encode_test_mex.c b/srslte/lib/phch/test/ulsch_encode_test_mex.c index 9a5831ad3..cdad1ad38 100644 --- a/srslte/lib/phch/test/ulsch_encode_test_mex.c +++ b/srslte/lib/phch/test/ulsch_encode_test_mex.c @@ -95,17 +95,15 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } - if (mexutils_read_float_struct(PUSCHCFG, "BetaCQI", &uci_data.beta_cqi)) { - uci_data.beta_cqi = 2.0; + if (mexutils_read_uint32_struct(PUSCHCFG, "OffsetCQI", &uci_data.I_offset_cqi)) { + uci_data.I_offset_cqi = 7; } - if (mexutils_read_float_struct(PUSCHCFG, "BetaRI", &uci_data.beta_ri)) { - uci_data.beta_ri = 2.0; + if (mexutils_read_uint32_struct(PUSCHCFG, "OffsetRI", &uci_data.I_offset_ri)) { + uci_data.I_offset_ri = 2; } - if (mexutils_read_float_struct(PUSCHCFG, "BetaACK", &uci_data.beta_ack)) { - uci_data.beta_ack = 2.0; + if (mexutils_read_uint32_struct(PUSCHCFG, "OffsetACK", &uci_data.I_offset_ack)) { + uci_data.I_offset_ack = 0; } - mexPrintf("Beta_CQI: %.1f, Beta_ACK: %.1f, Beta_RI: %.1f\n", - uci_data.beta_cqi, uci_data.beta_ack, uci_data.beta_ri); char *mod_str = mexutils_get_char_struct(PUSCHCFG, "Modulation"); diff --git a/srslte/lib/resampling/test/CMakeLists.txt b/srslte/lib/resampling/test/CMakeLists.txt index cb6bac623..99e7a64ae 100644 --- a/srslte/lib/resampling/test/CMakeLists.txt +++ b/srslte/lib/resampling/test/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/lib/scrambling/test/CMakeLists.txt b/srslte/lib/scrambling/test/CMakeLists.txt index f95f0eafa..8c55cfb6b 100644 --- a/srslte/lib/scrambling/test/CMakeLists.txt +++ b/srslte/lib/scrambling/test/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/lib/sync/test/CMakeLists.txt b/srslte/lib/sync/test/CMakeLists.txt index 6a0b5d187..05e3e12f0 100644 --- a/srslte/lib/sync/test/CMakeLists.txt +++ b/srslte/lib/sync/test/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/lib/ue/src/ue_dl.c b/srslte/lib/ue/src/ue_dl.c index 10ca16fbf..1b9a65097 100644 --- a/srslte/lib/ue/src/ue_dl.c +++ b/srslte/lib/ue/src/ue_dl.c @@ -194,13 +194,6 @@ int srslte_ue_dl_decode_fft_estimate(srslte_ue_dl_t *q, cf_t *input, uint32_t sf fprintf(stderr, "Error setting CFI\n"); return SRSLTE_ERROR; } - - /* Extract all PDCCH symbols and get LLRs */ - if (srslte_pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, 0, sf_idx, *cfi)) { - fprintf(stderr, "Error extracting LLRs\n"); - return SRSLTE_ERROR; - } - return SRSLTE_SUCCESS; } else { @@ -249,32 +242,24 @@ int srslte_ue_dl_find_ul_dci(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint3 { srslte_dci_location_t locations[MAX_CANDIDATES]; uint32_t nof_locations = srslte_pdcch_ue_locations(&q->pdcch, locations, MAX_CANDIDATES, sf_idx, cfi, rnti); - uint16_t srslte_crc_rem = 0; - for (uint32_t i=0;ipdcch, dci_msg, &locations[i], SRSLTE_DCI_FORMAT0, &srslte_crc_rem)) { + uint16_t crc_rem = 0; + for (uint32_t i=0;ipdcch, dci_msg, &locations[i], SRSLTE_DCI_FORMAT0, &crc_rem)) { fprintf(stderr, "Error decoding DCI msg\n"); return SRSLTE_ERROR; } - INFO("Decoded DCI message RNTI: 0x%x\n", srslte_crc_rem); + INFO("Decoded DCI message RNTI: 0x%x\n", crc_rem); } - return srslte_crc_rem == rnti; + return crc_rem == rnti; } -int srslte_ue_dl_decode_rnti_rv(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx, uint16_t rnti, uint32_t rvidx) +int srslte_ue_dl_find_dl_dci(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint32_t cfi, uint32_t sf_idx, uint16_t rnti) { - uint32_t i; - srslte_dci_msg_t dci_msg; srslte_dci_location_t locations[MAX_CANDIDATES]; uint32_t nof_locations; - uint16_t srslte_crc_rem; - int ret = SRSLTE_ERROR; uint32_t nof_formats; srslte_dci_format_t *formats = NULL; - if ((ret = srslte_ue_dl_decode_fft_estimate(q, input, sf_idx, &q->cfi)) < 0) { - return ret; - } - /* Generate PDCCH candidates */ if (rnti == SRSLTE_SIRNTI) { nof_locations = srslte_pdcch_common_locations(&q->pdcch, locations, MAX_CANDIDATES, q->cfi); @@ -285,28 +270,42 @@ int srslte_ue_dl_decode_rnti_rv(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, u formats = ue_formats; nof_formats = nof_ue_formats; } - - /* For all possible locations, try to decode a DCI message */ - srslte_crc_rem = 0; - uint32_t found_dci = 0; - for (int f=0;fpdcch, &dci_msg, &locations[i], formats[f], &srslte_crc_rem)) { + for (int i=0;ipdcch, dci_msg, &locations[i], formats[f], &crc_rem)) { fprintf(stderr, "Error decoding DCI msg\n"); return SRSLTE_ERROR; } - INFO("Decoded DCI message RNTI: 0x%x\n", srslte_crc_rem); - - if (srslte_crc_rem == rnti) { - q->dci_format = formats[f]; - found_dci++; - ret = srslte_ue_dl_decode_rnti_rv_packet(q, &dci_msg, data, q->cfi, sf_idx, rnti, rvidx); - } + INFO("Decoded DCI message RNTI: 0x%x\n", crc_rem); } + } + return crc_rem == rnti; +} + + +int srslte_ue_dl_decode_rnti_rv(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx, uint16_t rnti, uint32_t rvidx) +{ + srslte_dci_msg_t dci_msg; + int ret = SRSLTE_ERROR; + + if ((ret = srslte_ue_dl_decode_fft_estimate(q, input, sf_idx, &q->cfi)) < 0) { + return ret; + } + + if (srslte_pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, 0, sf_idx, q->cfi)) { + fprintf(stderr, "Error extracting LLRs\n"); + return SRSLTE_ERROR; + } + + int found_dci = srslte_ue_dl_find_dl_dci(q, &dci_msg, q->cfi, sf_idx, rnti); + if (found_dci == 1) { + ret = srslte_ue_dl_decode_rnti_rv_packet(q, &dci_msg, data, q->cfi, sf_idx, rnti, rvidx); } - if (found_dci > 0 && ret == SRSLTE_SUCCESS) { + if (found_dci == 1 && ret == SRSLTE_SUCCESS) { return q->ra_dl.mcs.tbs; } else { return 0; diff --git a/srslte/lib/ue/src/ue_mib.c b/srslte/lib/ue/src/ue_mib.c index cd44a600b..0e31b1816 100644 --- a/srslte/lib/ue/src/ue_mib.c +++ b/srslte/lib/ue/src/ue_mib.c @@ -113,7 +113,7 @@ void srslte_ue_mib_reset(srslte_ue_mib_t * q) } int srslte_ue_mib_decode(srslte_ue_mib_t * q, cf_t *input, - uint8_t bch_payload[BCH_PAYLOAD_LEN], uint32_t *nof_tx_ports, uint32_t *sfn_offset) + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], uint32_t *nof_tx_ports, uint32_t *sfn_offset) { int ret = SRSLTE_SUCCESS; cf_t *ce_slot1[SRSLTE_MAX_PORTS]; @@ -193,7 +193,7 @@ void srslte_ue_mib_sync_reset(srslte_ue_mib_sync_t * q) { int srslte_ue_mib_sync_decode(srslte_ue_mib_sync_t * q, uint32_t max_frames_timeout, - uint8_t bch_payload[BCH_PAYLOAD_LEN], + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], uint32_t *nof_tx_ports, uint32_t *sfn_offset) { diff --git a/srslte/lib/ue/src/ue_phy.cc b/srslte/lib/ue/src/ue_phy.cc deleted file mode 100644 index e69de29bb..000000000 diff --git a/srslte/lib/ue/src/ue_ul.c b/srslte/lib/ue/src/ue_ul.c index ed166c2f7..7890f0087 100644 --- a/srslte/lib/ue/src/ue_ul.c +++ b/srslte/lib/ue/src/ue_ul.c @@ -152,26 +152,26 @@ void srslte_ue_ul_set_pusch_cfg(srslte_ue_ul_t *q, srslte_refsignal_drms_pusch_c srslte_pusch_set_hopping_cfg(&q->pusch, pusch_hopping_cfg); } -int srslte_ue_ul_srslte_pusch_encode(srslte_ue_ul_t *q, srslte_ra_pusch_t *ra_ul, uint8_t *data, uint32_t sf_idx, cf_t *output_signal) +int srslte_ue_ul_pusch_encode(srslte_ue_ul_t *q, srslte_ra_pusch_t *ra_ul, uint8_t *data, uint32_t sf_idx, cf_t *output_signal) { srslte_uci_data_t uci_data; bzero(&uci_data, sizeof(srslte_uci_data_t)); - return srslte_ue_ul_srslte_pusch_uci_encode_rnti(q, ra_ul, data, uci_data, sf_idx, q->current_rnti, output_signal); + return srslte_ue_ul_pusch_uci_encode_rnti(q, ra_ul, data, uci_data, sf_idx, q->current_rnti, output_signal); } -int srslte_ue_ul_srslte_pusch_encode_rnti(srslte_ue_ul_t *q, srslte_ra_pusch_t *ra_ul, uint8_t *data, uint32_t sf_idx, uint16_t rnti, cf_t *output_signal) +int srslte_ue_ul_pusch_encode_rnti(srslte_ue_ul_t *q, srslte_ra_pusch_t *ra_ul, uint8_t *data, uint32_t sf_idx, uint16_t rnti, cf_t *output_signal) { srslte_uci_data_t uci_data; bzero(&uci_data, sizeof(srslte_uci_data_t)); - return srslte_ue_ul_srslte_pusch_uci_encode_rnti(q, ra_ul, data, uci_data, sf_idx, rnti, output_signal); + return srslte_ue_ul_pusch_uci_encode_rnti(q, ra_ul, data, uci_data, sf_idx, rnti, output_signal); } -int srslte_ue_ul_srslte_pusch_uci_encode(srslte_ue_ul_t *q, srslte_ra_pusch_t *ra_ul, uint8_t *data, srslte_uci_data_t uci_data, uint32_t sf_idx, cf_t *output_signal) +int srslte_ue_ul_pusch_uci_encode(srslte_ue_ul_t *q, srslte_ra_pusch_t *ra_ul, uint8_t *data, srslte_uci_data_t uci_data, uint32_t sf_idx, cf_t *output_signal) { - return srslte_ue_ul_srslte_pusch_uci_encode_rnti(q, ra_ul, data, uci_data, sf_idx, q->current_rnti, output_signal); + return srslte_ue_ul_pusch_uci_encode_rnti(q, ra_ul, data, uci_data, sf_idx, q->current_rnti, output_signal); } -int srslte_ue_ul_srslte_pusch_uci_encode_rnti(srslte_ue_ul_t *q, srslte_ra_pusch_t *ra_ul, uint8_t *data, srslte_uci_data_t uci_data, +int srslte_ue_ul_pusch_uci_encode_rnti(srslte_ue_ul_t *q, srslte_ra_pusch_t *ra_ul, uint8_t *data, srslte_uci_data_t uci_data, uint32_t sf_idx, uint16_t rnti, cf_t *output_signal) { diff --git a/srslte/lib/utils/test/CMakeLists.txt b/srslte/lib/utils/test/CMakeLists.txt index 31d3a8d90..e72465623 100644 --- a/srslte/lib/utils/test/CMakeLists.txt +++ b/srslte/lib/utils/test/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/tutorial_examples/CMakeLists.txt b/srslte/tutorial_examples/CMakeLists.txt index 927fbbeaa..29dde663f 100644 --- a/srslte/tutorial_examples/CMakeLists.txt +++ b/srslte/tutorial_examples/CMakeLists.txt @@ -1,15 +1,15 @@ # -# Copyright 2012-2013 The libLTE Developers. See the +# Copyright 2012-2013 The srsLTE Developers. See the # COPYRIGHT file at the top-level directory of this distribution. # -# This file is part of the libLTE library. +# This file is part of the srsLTE library. # -# libLTE is free software: you can redistribute it and/or modify +# 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. # -# libLTE is distributed in the hope that it will be useful, +# 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. diff --git a/srslte/tutorial_examples/ue_rx.c b/srslte/tutorial_examples/ue_rx.c index 438b05374..bf109fc4d 100644 --- a/srslte/tutorial_examples/ue_rx.c +++ b/srslte/tutorial_examples/ue_rx.c @@ -247,7 +247,7 @@ int main(int argc, char **argv) { #endif uint32_t nof_trials = 0; int n; - uint8_t bch_payload[BCH_PAYLOAD_LEN]; + uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; uint32_t sfn_offset; parse_args(&prog_args, argc, argv);