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.
118 lines
4.9 KiB
C
118 lines
4.9 KiB
C
4 years ago
|
/**
|
||
6 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
6 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
6 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.
|
||
6 years ago
|
*
|
||
|
*/
|
||
|
|
||
|
/******************************************************************************
|
||
|
* File: npss.h
|
||
|
*
|
||
|
* Description: Narrowband Primary synchronization signal (NPSS) generation and detection.
|
||
|
*
|
||
4 years ago
|
* The srsran_npss_synch_t object provides functions for fast
|
||
6 years ago
|
* computation of the crosscorrelation between the NPSS and received
|
||
4 years ago
|
* signal and CFO estimation. Also, the function srsran_npss_synch_tperiodic()
|
||
6 years ago
|
* is designed to be called periodically every subframe, taking
|
||
|
* care of the correct data alignment with respect to the NPSS sequence.
|
||
|
*
|
||
|
* The object is designed to work with signals sampled at ?.? Mhz
|
||
|
* centered at the carrier frequency. Thus, downsampling is required
|
||
|
* if the signal is sampled at higher frequencies.
|
||
|
*
|
||
|
* Reference: 3GPP TS 36.211 version 13.2.0 Release 13 Sec. 10.x.x
|
||
|
*****************************************************************************/
|
||
|
|
||
4 years ago
|
#ifndef SRSRAN_NPSS_H
|
||
|
#define SRSRAN_NPSS_H
|
||
6 years ago
|
|
||
|
#include <stdbool.h>
|
||
|
#include <stdint.h>
|
||
|
|
||
4 years ago
|
#include "srsran/config.h"
|
||
|
#include "srsran/phy/common/phy_common.h"
|
||
|
#include "srsran/phy/utils/convolution.h"
|
||
6 years ago
|
|
||
|
#define CONVOLUTION_FFT
|
||
|
|
||
4 years ago
|
#define SRSRAN_NPSS_RETURN_PSR
|
||
6 years ago
|
|
||
4 years ago
|
#define SRSRAN_NPSS_LEN 11
|
||
|
#define SRSRAN_NPSS_NUM_OFDM_SYMS 11
|
||
|
#define SRSRAN_NPSS_TOT_LEN (SRSRAN_NPSS_LEN * SRSRAN_NPSS_NUM_OFDM_SYMS)
|
||
6 years ago
|
|
||
4 years ago
|
#define SRSRAN_NPSS_CORR_FILTER_LEN \
|
||
|
((SRSRAN_NPSS_NUM_OFDM_SYMS * SRSRAN_NBIOT_FFT_SIZE) + \
|
||
|
(SRSRAN_NPSS_NUM_OFDM_SYMS - 1) * SRSRAN_CP_LEN_NORM(1, SRSRAN_NBIOT_FFT_SIZE) + \
|
||
|
SRSRAN_CP_LEN_NORM(0, SRSRAN_NBIOT_FFT_SIZE))
|
||
6 years ago
|
|
||
|
// The below value corresponds to the time-domain representation of the first
|
||
|
// three OFDM-symbols plus cyclic prefix that are not transmitted in the sub-frame
|
||
|
// carrying the NPSS
|
||
4 years ago
|
#define SRSRAN_NPSS_CORR_OFFSET (SRSRAN_SF_LEN(SRSRAN_NBIOT_FFT_SIZE) - SRSRAN_NPSS_CORR_FILTER_LEN)
|
||
6 years ago
|
|
||
|
// CFO estimation based on the NPSS is done using the second slot of the sub-frame
|
||
4 years ago
|
#define SRSRAN_NPSS_CFO_OFFSET (SRSRAN_SF_LEN(SRSRAN_NBIOT_FFT_SIZE) / 2 - SRSRAN_NPSS_CORR_OFFSET)
|
||
|
#define SRSRAN_NPSS_CFO_NUM_SYMS 6 // number of symbols for CFO estimation
|
||
|
#define SRSRAN_NPSS_CFO_NUM_SAMPS \
|
||
|
((SRSRAN_NPSS_CFO_NUM_SYMS * SRSRAN_NBIOT_FFT_SIZE) + \
|
||
|
(SRSRAN_NPSS_CFO_NUM_SYMS - 1) * SRSRAN_CP_LEN_NORM(1, SRSRAN_NBIOT_FFT_SIZE) + \
|
||
|
SRSRAN_CP_LEN_NORM(0, SRSRAN_NBIOT_FFT_SIZE)) // resulting number of samples
|
||
6 years ago
|
|
||
|
// NPSS processing options
|
||
4 years ago
|
#define SRSRAN_NPSS_ACCUMULATE_ABS // If enabled, accumulates the correlation absolute value on consecutive calls to
|
||
|
// srsran_pss_synch_find_pss
|
||
6 years ago
|
|
||
4 years ago
|
#define SRSRAN_NPSS_ABS_SQUARE // If enabled, compute abs square, otherwise computes absolute value only
|
||
6 years ago
|
|
||
4 years ago
|
#define SRSRAN_NPSS_RETURN_PSR // If enabled returns peak to side-lobe ratio, otherwise returns absolute peak value
|
||
6 years ago
|
|
||
|
/* Low-level API */
|
||
4 years ago
|
typedef struct SRSRAN_API {
|
||
6 years ago
|
#ifdef CONVOLUTION_FFT
|
||
4 years ago
|
srsran_conv_fft_cc_t conv_fft;
|
||
6 years ago
|
#endif
|
||
|
|
||
|
uint32_t frame_size, max_frame_size;
|
||
|
uint32_t fft_size, max_fft_size;
|
||
|
|
||
|
cf_t* npss_signal_time;
|
||
|
cf_t* tmp_input;
|
||
|
cf_t* conv_output;
|
||
|
float* conv_output_abs;
|
||
|
float ema_alpha;
|
||
|
float* conv_output_avg;
|
||
|
float peak_value;
|
||
4 years ago
|
} srsran_npss_synch_t;
|
||
6 years ago
|
|
||
|
// Basic functionality
|
||
4 years ago
|
SRSRAN_API int srsran_npss_synch_init(srsran_npss_synch_t* q, uint32_t frame_size, uint32_t fft_size);
|
||
6 years ago
|
|
||
4 years ago
|
SRSRAN_API void srsran_npss_synch_reset(srsran_npss_synch_t* q);
|
||
6 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_npss_synch_resize(srsran_npss_synch_t* q, uint32_t frame_size, uint32_t fft_size);
|
||
6 years ago
|
|
||
4 years ago
|
SRSRAN_API void srsran_npss_synch_set_ema_alpha(srsran_npss_synch_t* q, float alpha);
|
||
6 years ago
|
|
||
4 years ago
|
SRSRAN_API void srsran_npss_synch_free(srsran_npss_synch_t* q);
|
||
6 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_npss_sync_find(srsran_npss_synch_t* q, cf_t* input, float* corr_peak_value);
|
||
6 years ago
|
|
||
|
// Internal functions
|
||
4 years ago
|
SRSRAN_API int srsran_npss_corr_init(cf_t* npss_signal_time, uint32_t fft_size, uint32_t frame_size);
|
||
6 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_npss_generate(cf_t* signal);
|
||
6 years ago
|
|
||
4 years ago
|
SRSRAN_API void srsran_npss_put_subframe(srsran_npss_synch_t* q,
|
||
5 years ago
|
cf_t* npss_signal,
|
||
|
cf_t* sf,
|
||
|
const uint32_t nof_prb,
|
||
|
const uint32_t nbiot_prb_offset);
|
||
6 years ago
|
|
||
4 years ago
|
#endif // SRSRAN_NPSS_H
|