srsLTE/srslte/include/srslte/sync/sss.h

177 lines
5.7 KiB
C
Raw Normal View History

/**
2014-01-28 03:41:17 -08:00
*
* \section COPYRIGHT
2014-01-28 03:41:17 -08:00
*
* 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,
2014-01-28 03:41:17 -08:00
* 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/.
*
2014-01-28 03:41:17 -08:00
*/
2014-01-28 03:41:17 -08:00
#ifndef SSS_
#define SSS_
#include <stdint.h>
#include <stdbool.h>
#include "srslte/config.h"
#include "srslte/common/phy_common.h"
2015-03-18 11:14:24 -07:00
#include "srslte/dft/dft.h"
2014-01-28 03:41:17 -08:00
2015-03-18 11:14:24 -07:00
#define SRSLTE_SSS_N 31
#define SRSLTE_SSS_LEN 2*SRSLTE_SSS_N
2014-01-28 03:41:17 -08:00
2015-03-18 11:14:24 -07:00
typedef struct SRSLTE_API {
int z1[SRSLTE_SSS_N][SRSLTE_SSS_N];
int c[2][SRSLTE_SSS_N];
int s[SRSLTE_SSS_N][SRSLTE_SSS_N];
}srslte_sss_tables_t;
2014-01-28 03:41:17 -08:00
/* Allocate 32 complex to make it multiple of 32-byte AVX instructions alignment requirement.
2015-03-18 11:14:24 -07:00
* Should use srslte_vec_malloc() to make it platform agnostic.
2014-01-28 03:41:17 -08:00
*/
2015-03-18 11:14:24 -07:00
typedef struct SRSLTE_API {
float z1[SRSLTE_SSS_N][SRSLTE_SSS_N];
float c[2][SRSLTE_SSS_N];
float s[SRSLTE_SSS_N][SRSLTE_SSS_N];
float sd[SRSLTE_SSS_N][SRSLTE_SSS_N-1];
}srslte_sss_fc_tables_t;
2014-01-28 03:41:17 -08:00
/* Low-level API */
typedef struct SRSLTE_API {
2014-01-28 03:41:17 -08:00
2015-03-18 05:41:50 -07:00
srslte_dft_plan_t dftp_input;
uint32_t fft_size;
2014-01-28 03:41:17 -08:00
2014-06-17 02:11:41 -07:00
float corr_peak_threshold;
uint32_t symbol_sz;
uint32_t subframe_sz;
uint32_t N_id_2;
uint32_t N_id_1_table[30][30];
2015-03-18 11:14:24 -07:00
srslte_sss_fc_tables_t fc_tables[3]; // one for each N_id_2
2014-01-28 03:41:17 -08:00
2015-03-18 11:14:24 -07:00
float corr_output_m0[SRSLTE_SSS_N];
float corr_output_m1[SRSLTE_SSS_N];
2015-03-18 11:14:24 -07:00
}srslte_sss_synch_t;
2014-01-28 03:41:17 -08:00
/* Basic functionality */
2015-03-18 11:14:24 -07:00
SRSLTE_API int srslte_sss_synch_init(srslte_sss_synch_t *q,
uint32_t fft_size);
SRSLTE_API int srslte_sss_synch_realloc(srslte_sss_synch_t *q,
uint32_t fft_size);
SRSLTE_API void srslte_sss_synch_free(srslte_sss_synch_t *q);
SRSLTE_API void srslte_sss_generate(float *signal0,
float *signal5,
uint32_t cell_id);
SRSLTE_API void srslte_sss_put_slot(float *sss,
cf_t *symbol,
uint32_t nof_prb,
srslte_cp_t cp);
SRSLTE_API int srslte_sss_synch_set_N_id_2(srslte_sss_synch_t *q,
uint32_t N_id_2);
SRSLTE_API int srslte_sss_synch_m0m1_partial(srslte_sss_synch_t *q,
cf_t *input,
uint32_t M,
cf_t ce[2*SRSLTE_SSS_N],
uint32_t *m0,
float *m0_value,
uint32_t *m1,
float *m1_value);
SRSLTE_API int srslte_sss_synch_m0m1_diff_coh(srslte_sss_synch_t *q,
cf_t *input,
cf_t ce[2*SRSLTE_SSS_N],
uint32_t *m0,
float *m0_value,
uint32_t *m1,
float *m1_value);
SRSLTE_API int srslte_sss_synch_m0m1_diff(srslte_sss_synch_t *q,
cf_t *input,
uint32_t *m0,
float *m0_value,
uint32_t *m1,
float *m1_value);
SRSLTE_API uint32_t srslte_sss_synch_subframe(uint32_t m0,
uint32_t m1);
SRSLTE_API int srslte_sss_synch_N_id_1(srslte_sss_synch_t *q,
uint32_t m0,
uint32_t m1);
2015-03-18 11:14:24 -07:00
SRSLTE_API int srslte_sss_synch_frame(srslte_sss_synch_t *q,
cf_t *input,
uint32_t *subframe_idx,
uint32_t *N_id_1);
2015-03-18 11:14:24 -07:00
SRSLTE_API void srslte_sss_synch_set_threshold(srslte_sss_synch_t *q,
float threshold);
2014-01-28 03:41:17 -08:00
2015-03-18 11:14:24 -07:00
SRSLTE_API void srslte_sss_synch_set_symbol_sz(srslte_sss_synch_t *q,
uint32_t symbol_sz);
2014-01-28 03:41:17 -08:00
2015-03-18 11:14:24 -07:00
SRSLTE_API void srslte_sss_synch_set_subframe_sz(srslte_sss_synch_t *q,
uint32_t subframe_sz);
2014-01-28 03:41:17 -08:00
/* High-level API */
typedef struct SRSLTE_API {
2015-03-18 11:14:24 -07:00
srslte_sss_synch_t obj;
struct srslte_sss_synch_init {
uint32_t N_id_2;
2014-06-17 02:11:41 -07:00
} init;
cf_t *input;
uint32_t in_len;
2015-03-18 11:14:24 -07:00
struct srslte_sss_synch_ctrl_in {
uint32_t symbol_sz;
uint32_t subframe_sz;
uint32_t correlation_threshold;
2014-06-17 02:11:41 -07:00
} ctrl_in;
2015-03-18 11:14:24 -07:00
struct srslte_sss_synch_ctrl_out {
uint32_t subframe_idx;
uint32_t N_id_1;
2014-06-17 02:11:41 -07:00
} ctrl_out;
2015-03-18 11:14:24 -07:00
}srslte_sss_synch_hl;
2014-01-28 03:41:17 -08:00
2014-06-17 02:11:41 -07:00
#define DEFAULT_FRAME_SIZE 2048
2014-01-28 03:41:17 -08:00
2015-03-18 11:14:24 -07:00
SRSLTE_API int srslte_sss_synch_initialize(srslte_sss_synch_hl* h);
SRSLTE_API int srslte_sss_synch_work(srslte_sss_synch_hl* hl);
SRSLTE_API int srslte_sss_synch_stop(srslte_sss_synch_hl* hl);
2014-01-28 03:41:17 -08:00
#endif // SSS_
2014-01-28 03:41:17 -08:00