2019-04-26 12:27:38 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2013-2019 Software Radio Systems Limited
|
2014-06-24 09:41:08 -07:00
|
|
|
*
|
2019-04-26 12:27:38 -07:00
|
|
|
* This file is part of srsLTE.
|
2014-06-24 09:41:08 -07:00
|
|
|
*
|
2015-03-18 05:31:13 -07:00
|
|
|
* srsLTE is free software: you can redistribute it and/or modify
|
2015-05-08 08:05:40 -07:00
|
|
|
* it under the terms of the GNU Affero General Public License as
|
2014-06-24 09:41:08 -07:00
|
|
|
* published by the Free Software Foundation, either version 3 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
2015-03-18 05:31:13 -07:00
|
|
|
* srsLTE is distributed in the hope that it will be useful,
|
2014-06-24 09:41:08 -07:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-05-08 08:05:40 -07:00
|
|
|
* GNU Affero General Public License for more details.
|
2014-06-24 09:41:08 -07:00
|
|
|
*
|
2015-05-08 08:05:40 -07:00
|
|
|
* A copy of the GNU Affero General Public License can be found in
|
2014-06-24 09:41:08 -07:00
|
|
|
* the LICENSE file in the top-level directory of this distribution
|
|
|
|
* and at http://www.gnu.org/licenses/.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-04-03 05:49:12 -07:00
|
|
|
/******************************************************************************
|
|
|
|
* File: prach.h
|
|
|
|
*
|
|
|
|
* Description: Physical random access channel.
|
|
|
|
*
|
|
|
|
* Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 5.7
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#ifndef SRSLTE_PRACH_H
|
|
|
|
#define SRSLTE_PRACH_H
|
2014-06-24 09:41:08 -07:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <complex.h>
|
|
|
|
#include <stdbool.h>
|
2015-03-18 05:16:28 -07:00
|
|
|
#include "srslte/config.h"
|
2017-05-18 00:48:24 -07:00
|
|
|
#include "srslte/phy/dft/dft.h"
|
|
|
|
#include "srslte/phy/common/phy_common.h"
|
2015-03-19 07:47:28 -07:00
|
|
|
|
2014-06-25 01:43:06 -07:00
|
|
|
|
2017-09-01 04:29:11 -07:00
|
|
|
#define SRSLTE_PRACH_MAX_LEN (2*24576+21024) // Maximum Tcp + Tseq
|
|
|
|
|
2014-06-24 09:41:08 -07:00
|
|
|
/** Generation and detection of RACH signals for uplink.
|
|
|
|
* Currently only supports preamble formats 0-3.
|
|
|
|
* Does not currently support high speed flag.
|
|
|
|
* Based on 3GPP TS 36.211 version 10.7.0 Release 10.
|
|
|
|
*/
|
|
|
|
|
2015-03-18 05:31:13 -07:00
|
|
|
typedef struct SRSLTE_API {
|
2014-06-24 09:41:08 -07:00
|
|
|
// Parameters from higher layers (extracted from SIB2)
|
2016-05-09 03:38:39 -07:00
|
|
|
uint32_t config_idx;
|
2014-06-24 09:41:08 -07:00
|
|
|
uint32_t f; // preamble format
|
|
|
|
uint32_t rsi; // rootSequenceIndex
|
|
|
|
bool hs; // highSpeedFlag
|
|
|
|
uint32_t zczc; // zeroCorrelationZoneConfig
|
|
|
|
uint32_t N_ifft_ul; // IFFT size for uplink
|
|
|
|
uint32_t N_ifft_prach; // IFFT size for PRACH generation
|
|
|
|
|
2017-09-01 04:29:11 -07:00
|
|
|
uint32_t max_N_ifft_ul;
|
|
|
|
|
2014-06-24 09:41:08 -07:00
|
|
|
// Working parameters
|
|
|
|
uint32_t N_zc; // PRACH sequence length
|
|
|
|
uint32_t N_cs; // Cyclic shift size
|
|
|
|
uint32_t N_seq; // Preamble length
|
2016-07-27 07:44:14 -07:00
|
|
|
float T_seq; // Preamble length in seconds
|
2017-03-14 03:00:33 -07:00
|
|
|
float T_tot; // Total sequence length in seconds
|
2014-06-24 09:41:08 -07:00
|
|
|
uint32_t N_cp; // Cyclic prefix length
|
|
|
|
|
|
|
|
// Generated tables
|
|
|
|
cf_t seqs[64][839]; // Our set of 64 preamble sequences
|
|
|
|
cf_t dft_seqs[64][839]; // DFT-precoded seqs
|
|
|
|
uint32_t root_seqs_idx[64]; // Indices of root seqs in seqs table
|
|
|
|
uint32_t N_roots; // Number of root sequences used in this configuration
|
2016-05-03 01:24:45 -07:00
|
|
|
|
2014-06-24 09:41:08 -07:00
|
|
|
// Containers
|
|
|
|
cf_t *ifft_in;
|
|
|
|
cf_t *ifft_out;
|
|
|
|
cf_t *prach_bins;
|
|
|
|
cf_t *corr_spec;
|
|
|
|
float *corr;
|
|
|
|
|
|
|
|
// PRACH IFFT
|
2017-09-01 04:29:11 -07:00
|
|
|
srslte_dft_plan_t fft;
|
|
|
|
srslte_dft_plan_t ifft;
|
2014-06-24 09:41:08 -07:00
|
|
|
|
|
|
|
// ZC-sequence FFT and IFFT
|
2017-09-01 04:29:11 -07:00
|
|
|
srslte_dft_plan_t zc_fft;
|
|
|
|
srslte_dft_plan_t zc_ifft;
|
2016-04-28 13:14:33 -07:00
|
|
|
|
|
|
|
cf_t *signal_fft;
|
|
|
|
float detect_factor;
|
2016-05-03 01:24:45 -07:00
|
|
|
|
|
|
|
uint32_t deadzone;
|
|
|
|
float peak_values[65];
|
|
|
|
uint32_t peak_offsets[65];
|
2019-04-23 01:53:11 -07:00
|
|
|
|
|
|
|
srslte_tdd_config_t tdd_config;
|
|
|
|
uint32_t current_prach_idx;
|
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
} srslte_prach_t;
|
2014-06-24 09:41:08 -07:00
|
|
|
|
2015-03-24 07:58:33 -07:00
|
|
|
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;
|
|
|
|
|
2016-05-09 03:38:39 -07:00
|
|
|
typedef struct {
|
|
|
|
uint32_t config_idx;
|
|
|
|
uint32_t root_seq_idx;
|
2016-10-18 01:39:49 -07:00
|
|
|
uint32_t zero_corr_zone;
|
|
|
|
uint32_t freq_offset;
|
2019-04-23 01:53:11 -07:00
|
|
|
bool hs_flag;
|
|
|
|
srslte_tdd_config_t tdd_config;
|
|
|
|
} srslte_prach_cfg_t;
|
2016-05-09 03:38:39 -07:00
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
typedef struct SRSLTE_API {
|
|
|
|
uint32_t f;
|
|
|
|
uint32_t t0;
|
|
|
|
uint32_t t1;
|
|
|
|
uint32_t t2;
|
|
|
|
} srslte_prach_tdd_loc_t;
|
|
|
|
|
|
|
|
typedef struct SRSLTE_API {
|
|
|
|
uint32_t nof_elems;
|
|
|
|
srslte_prach_tdd_loc_t elems[6];
|
|
|
|
} srslte_prach_tdd_loc_table_t;
|
2016-05-09 03:38:39 -07:00
|
|
|
|
2015-03-24 07:58:33 -07:00
|
|
|
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);
|
|
|
|
|
2016-05-09 03:38:39 -07:00
|
|
|
SRSLTE_API bool srslte_prach_tti_opportunity(srslte_prach_t *p,
|
|
|
|
uint32_t current_tti,
|
2018-06-29 02:25:22 -07:00
|
|
|
int allowed_subframe);
|
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
SRSLTE_API bool srslte_prach_tti_opportunity_config_fdd(uint32_t config_idx,
|
|
|
|
uint32_t current_tti,
|
|
|
|
int allowed_subframe);
|
|
|
|
|
|
|
|
SRSLTE_API bool srslte_prach_tti_opportunity_config_tdd(uint32_t config_idx,
|
|
|
|
uint32_t tdd_ul_dl_config,
|
|
|
|
uint32_t current_tti,
|
|
|
|
uint32_t* prach_idx);
|
|
|
|
|
|
|
|
SRSLTE_API uint32_t srslte_prach_f_ra_tdd(uint32_t config_idx,
|
|
|
|
uint32_t tdd_ul_dl_config,
|
|
|
|
uint32_t current_tti,
|
|
|
|
uint32_t prach_idx,
|
|
|
|
uint32_t prach_offset,
|
|
|
|
uint32_t n_rb_ul);
|
|
|
|
|
|
|
|
SRSLTE_API uint32_t srslte_prach_f_id_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config, uint32_t prach_idx);
|
|
|
|
|
|
|
|
SRSLTE_API uint32_t srslte_prach_nof_f_idx_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config);
|
|
|
|
|
|
|
|
SRSLTE_API void srslte_prach_sf_config(uint32_t config_idx, srslte_prach_sf_config_t* sf_config);
|
2015-06-05 13:40:17 -07:00
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
SRSLTE_API int srslte_prach_init(srslte_prach_t* p, uint32_t max_N_ifft_ul);
|
2015-03-24 07:58:33 -07:00
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
SRSLTE_API int srslte_prach_set_cell_fdd(srslte_prach_t* p,
|
|
|
|
uint32_t N_ifft_ul,
|
|
|
|
uint32_t config_idx,
|
|
|
|
uint32_t root_seq_index,
|
|
|
|
bool high_speed_flag,
|
|
|
|
uint32_t zero_corr_zone_config);
|
2017-09-01 04:29:11 -07:00
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
SRSLTE_API int srslte_prach_set_cell_tdd(srslte_prach_t* p,
|
|
|
|
uint32_t N_ifft_ul,
|
|
|
|
uint32_t config_idx,
|
|
|
|
uint32_t root_seq_index,
|
|
|
|
bool high_speed_flag,
|
|
|
|
uint32_t zero_corr_zone_config,
|
|
|
|
srslte_tdd_config_t* tdd_config);
|
2014-06-24 09:41:08 -07:00
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
SRSLTE_API int srslte_prach_set_cfg(srslte_prach_t* p, srslte_prach_cfg_t* cfg, uint32_t nof_prb);
|
2016-05-09 03:38:39 -07:00
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
SRSLTE_API int srslte_prach_gen(srslte_prach_t* p, uint32_t seq_index, uint32_t freq_offset, cf_t* signal);
|
2014-06-24 09:41:08 -07:00
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
SRSLTE_API int srslte_prach_detect(srslte_prach_t* p,
|
2015-03-18 11:14:24 -07:00
|
|
|
uint32_t freq_offset,
|
2019-04-23 01:53:11 -07:00
|
|
|
cf_t* signal,
|
2015-03-18 11:14:24 -07:00
|
|
|
uint32_t sig_len,
|
2019-04-23 01:53:11 -07:00
|
|
|
uint32_t* indices,
|
|
|
|
uint32_t* ind_len);
|
2014-06-24 09:41:08 -07:00
|
|
|
|
2016-05-03 01:24:45 -07:00
|
|
|
SRSLTE_API int srslte_prach_detect_offset(srslte_prach_t *p,
|
|
|
|
uint32_t freq_offset,
|
|
|
|
cf_t *signal,
|
|
|
|
uint32_t sig_len,
|
|
|
|
uint32_t *indices,
|
2016-07-27 07:44:14 -07:00
|
|
|
float *t_offsets,
|
2016-09-21 09:26:35 -07:00
|
|
|
float *peak_to_avg,
|
2016-05-03 01:24:45 -07:00
|
|
|
uint32_t *ind_len);
|
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
SRSLTE_API void srslte_prach_set_detect_factor(srslte_prach_t *p, float factor);
|
2016-04-28 13:14:33 -07:00
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
SRSLTE_API int srslte_prach_free(srslte_prach_t *p);
|
2014-06-24 09:41:08 -07:00
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
SRSLTE_API int srslte_prach_print_seqs(srslte_prach_t *p);
|
2014-06-24 09:41:08 -07:00
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#endif // SRSLTE_PRACH_H
|