mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
215 lines
7.6 KiB
C
215 lines
7.6 KiB
C
4 years ago
|
/**
|
||
11 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
11 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
11 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
11 years ago
|
*
|
||
|
*/
|
||
|
|
||
10 years ago
|
/******************************************************************************
|
||
|
* File: prach.h
|
||
|
*
|
||
|
* Description: Physical random access channel.
|
||
|
*
|
||
|
* Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 5.7
|
||
|
*****************************************************************************/
|
||
|
|
||
4 years ago
|
#ifndef SRSRAN_PRACH_H
|
||
|
#define SRSRAN_PRACH_H
|
||
11 years ago
|
|
||
4 years ago
|
#include "srsran/config.h"
|
||
|
#include "srsran/phy/common/phy_common.h"
|
||
|
#include "srsran/phy/dft/dft.h"
|
||
5 years ago
|
#include <complex.h>
|
||
|
#include <stdbool.h>
|
||
|
#include <stdint.h>
|
||
|
#include <stdlib.h>
|
||
10 years ago
|
|
||
4 years ago
|
#define SRSRAN_PRACH_MAX_LEN (2 * 24576 + 21024) // Maximum Tcp + Tseq
|
||
7 years ago
|
|
||
4 years ago
|
// Long PRACH ZC sequence sequence length
|
||
4 years ago
|
#define SRSRAN_PRACH_N_ZC_LONG 839
|
||
4 years ago
|
|
||
|
// Short PRACH ZC sequence sequence length
|
||
4 years ago
|
#define SRSRAN_PRACH_N_ZC_SHORT 139
|
||
4 years ago
|
|
||
11 years ago
|
/** 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.
|
||
|
*/
|
||
|
|
||
4 years ago
|
typedef struct {
|
||
|
int idx;
|
||
|
float factor;
|
||
4 years ago
|
cf_t phase_array[2 * SRSRAN_PRACH_N_ZC_LONG];
|
||
|
} srsran_prach_cancellation_t;
|
||
4 years ago
|
|
||
4 years ago
|
typedef struct SRSRAN_API {
|
||
11 years ago
|
// Parameters from higher layers (extracted from SIB2)
|
||
4 years ago
|
bool is_nr;
|
||
5 years ago
|
uint32_t config_idx;
|
||
|
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
|
||
11 years ago
|
|
||
7 years ago
|
uint32_t max_N_ifft_ul;
|
||
|
|
||
11 years ago
|
// Working parameters
|
||
|
uint32_t N_zc; // PRACH sequence length
|
||
|
uint32_t N_cs; // Cyclic shift size
|
||
|
uint32_t N_seq; // Preamble length
|
||
9 years ago
|
float T_seq; // Preamble length in seconds
|
||
8 years ago
|
float T_tot; // Total sequence length in seconds
|
||
11 years ago
|
uint32_t N_cp; // Cyclic prefix length
|
||
|
|
||
|
// Generated tables
|
||
4 years ago
|
cf_t seqs[64][SRSRAN_PRACH_N_ZC_LONG]; // Our set of 64 preamble sequences
|
||
|
cf_t dft_seqs[64][SRSRAN_PRACH_N_ZC_LONG]; // DFT-precoded seqs
|
||
4 years ago
|
uint64_t dft_gen_bitmap; // Bitmap where each bit Indicates if the dft has been generated for sequence i.
|
||
11 years ago
|
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
|
||
5 years ago
|
cf_t* td_signals[64];
|
||
11 years ago
|
// Containers
|
||
5 years ago
|
cf_t* ifft_in;
|
||
|
cf_t* ifft_out;
|
||
|
cf_t* prach_bins;
|
||
|
cf_t* corr_spec;
|
||
|
float* corr;
|
||
11 years ago
|
|
||
|
// PRACH IFFT
|
||
4 years ago
|
srsran_dft_plan_t fft;
|
||
|
srsran_dft_plan_t ifft;
|
||
11 years ago
|
|
||
|
// ZC-sequence FFT and IFFT
|
||
4 years ago
|
srsran_dft_plan_t zc_fft;
|
||
|
srsran_dft_plan_t zc_ifft;
|
||
5 years ago
|
|
||
|
cf_t* signal_fft;
|
||
|
float detect_factor;
|
||
|
|
||
4 years ago
|
uint32_t deadzone;
|
||
|
float peak_values[65];
|
||
|
uint32_t peak_offsets[65];
|
||
|
uint32_t num_ra_preambles;
|
||
|
bool successive_cancellation;
|
||
|
bool freq_domain_offset_calc;
|
||
4 years ago
|
srsran_tdd_config_t tdd_config;
|
||
4 years ago
|
uint32_t current_prach_idx;
|
||
|
cf_t* cross;
|
||
|
cf_t* corr_freq;
|
||
4 years ago
|
srsran_prach_cancellation_t prach_cancel;
|
||
4 years ago
|
cf_t sub[839 * 2];
|
||
|
float phase[839];
|
||
6 years ago
|
|
||
4 years ago
|
} srsran_prach_t;
|
||
11 years ago
|
|
||
4 years ago
|
typedef struct SRSRAN_API {
|
||
5 years ago
|
int nof_sf;
|
||
10 years ago
|
uint32_t sf[5];
|
||
4 years ago
|
} srsran_prach_sf_config_t;
|
||
10 years ago
|
|
||
4 years ago
|
typedef enum SRSRAN_API {
|
||
|
SRSRAN_PRACH_SFN_EVEN = 0,
|
||
|
SRSRAN_PRACH_SFN_ANY,
|
||
|
} srsran_prach_sfn_t;
|
||
10 years ago
|
|
||
9 years ago
|
typedef struct {
|
||
4 years ago
|
bool is_nr; // Set to true if NR
|
||
5 years ago
|
uint32_t config_idx;
|
||
|
uint32_t root_seq_idx;
|
||
|
uint32_t zero_corr_zone;
|
||
|
uint32_t freq_offset;
|
||
5 years ago
|
uint32_t num_ra_preambles;
|
||
6 years ago
|
bool hs_flag;
|
||
4 years ago
|
srsran_tdd_config_t tdd_config;
|
||
5 years ago
|
bool enable_successive_cancellation;
|
||
4 years ago
|
bool enable_freq_domain_offset_calc;
|
||
4 years ago
|
} srsran_prach_cfg_t;
|
||
9 years ago
|
|
||
4 years ago
|
typedef struct SRSRAN_API {
|
||
6 years ago
|
uint32_t f;
|
||
|
uint32_t t0;
|
||
|
uint32_t t1;
|
||
|
uint32_t t2;
|
||
4 years ago
|
} srsran_prach_tdd_loc_t;
|
||
6 years ago
|
|
||
4 years ago
|
typedef struct SRSRAN_API {
|
||
6 years ago
|
uint32_t nof_elems;
|
||
4 years ago
|
srsran_prach_tdd_loc_t elems[6];
|
||
|
} srsran_prach_tdd_loc_table_t;
|
||
9 years ago
|
|
||
4 years ago
|
SRSRAN_API uint32_t srsran_prach_get_preamble_format(uint32_t config_idx);
|
||
10 years ago
|
|
||
4 years ago
|
SRSRAN_API srsran_prach_sfn_t srsran_prach_get_sfn(uint32_t config_idx);
|
||
10 years ago
|
|
||
4 years ago
|
SRSRAN_API bool srsran_prach_tti_opportunity(srsran_prach_t* p, uint32_t current_tti, int allowed_subframe);
|
||
7 years ago
|
|
||
4 years ago
|
SRSRAN_API bool
|
||
|
srsran_prach_tti_opportunity_config_fdd(uint32_t config_idx, uint32_t current_tti, int allowed_subframe);
|
||
6 years ago
|
|
||
4 years ago
|
SRSRAN_API bool srsran_prach_tti_opportunity_config_tdd(uint32_t config_idx,
|
||
6 years ago
|
uint32_t tdd_ul_dl_config,
|
||
|
uint32_t current_tti,
|
||
|
uint32_t* prach_idx);
|
||
|
|
||
4 years ago
|
SRSRAN_API uint32_t srsran_prach_f_ra_tdd(uint32_t config_idx,
|
||
6 years ago
|
uint32_t tdd_ul_dl_config,
|
||
|
uint32_t current_tti,
|
||
|
uint32_t prach_idx,
|
||
|
uint32_t prach_offset,
|
||
|
uint32_t n_rb_ul);
|
||
|
|
||
4 years ago
|
SRSRAN_API uint32_t srsran_prach_f_id_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config, uint32_t prach_idx);
|
||
6 years ago
|
|
||
4 years ago
|
SRSRAN_API uint32_t srsran_prach_nof_f_idx_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config);
|
||
6 years ago
|
|
||
4 years ago
|
SRSRAN_API void srsran_prach_sf_config(uint32_t config_idx, srsran_prach_sf_config_t* sf_config);
|
||
10 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_prach_init(srsran_prach_t* p, uint32_t max_N_ifft_ul);
|
||
10 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_prach_set_cfg(srsran_prach_t* p, srsran_prach_cfg_t* cfg, uint32_t nof_prb);
|
||
9 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_prach_gen(srsran_prach_t* p, uint32_t seq_index, uint32_t freq_offset, cf_t* signal);
|
||
11 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_prach_detect(srsran_prach_t* p,
|
||
5 years ago
|
uint32_t freq_offset,
|
||
|
cf_t* signal,
|
||
|
uint32_t sig_len,
|
||
|
uint32_t* indices,
|
||
|
uint32_t* ind_len);
|
||
|
|
||
4 years ago
|
SRSRAN_API int srsran_prach_detect_offset(srsran_prach_t* p,
|
||
5 years ago
|
uint32_t freq_offset,
|
||
|
cf_t* signal,
|
||
|
uint32_t sig_len,
|
||
|
uint32_t* indices,
|
||
|
float* t_offsets,
|
||
|
float* peak_to_avg,
|
||
|
uint32_t* ind_len);
|
||
|
|
||
4 years ago
|
SRSRAN_API void srsran_prach_set_detect_factor(srsran_prach_t* p, float factor);
|
||
5 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_prach_free(srsran_prach_t* p);
|
||
5 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_prach_print_seqs(srsran_prach_t* p);
|
||
11 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_prach_process(srsran_prach_t* p,
|
||
4 years ago
|
cf_t* signal,
|
||
|
uint32_t* indices,
|
||
|
float* t_offsets,
|
||
|
float* peak_to_avg,
|
||
|
uint32_t* n_indices,
|
||
|
int cancellation_idx,
|
||
|
uint32_t begin,
|
||
|
uint32_t sig_len);
|
||
5 years ago
|
|
||
4 years ago
|
#endif // SRSRAN_PRACH_H
|