GNU Radio's GFDM Package
improved_sync_algorithm_kernel_cc.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2016 Johannes Demel.
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3, or (at your option)
8 * any later version.
9 *
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street,
18 * Boston, MA 02110-1301, USA.
19 */
20
21
22#ifndef INCLUDED_GFDM_IMPROVED_SYNC_ALGORITHM_KERNEL_CC_H
23#define INCLUDED_GFDM_IMPROVED_SYNC_ALGORITHM_KERNEL_CC_H
24
25#include <gfdm/api.h>
26#include <deque>
27
28namespace gr {
29 namespace gfdm {
30
31 /*!
32 * \brief Perform STO/CFO synchronization for multicarrier systems
33 * Compare: Awoseyila et. al. "Improved Preamble-Aided Timing Estimation for OFDM Systems"
34 *
35 * \param n_subcarriers: number of subcarriers of the multicarrier system.
36 * \param cp_len: Cyclic Prefix Length of the system
37 * \param preamble: actual used preamble. preamble.size MUST be equal to 2*n_subcarriers.
38 *
39 */
41 {
42 public:
43 improved_sync_algorithm_kernel_cc(int n_subcarriers, int cp_len, std::vector<gr_complex> preamble, int max_ninput_size);
45
46 int detect_frame_start(const gr_complex *p_in, int ninput_size);
47 int max_ninput_size() const { return d_max_ninput_size;};
48
49 // The following public functions are mainly a debugging interface to Python!
50 int find_preamble(std::vector<gr_complex> in_vec);
51 std::vector<gr_complex> auto_correlate_preamble(std::vector<gr_complex> in_vec);
52 std::vector<float> abs_integrate_preamble(std::vector<gr_complex> in_vec);
53 int find_peak_preamble(std::vector<float> in_vec);
54 float calculate_normalized_cfo_preamble(const gr_complex val){ return calculate_normalized_cfo(val);};
55 std::vector<gr_complex> remove_cfo_preamble(std::vector<gr_complex> in_vec, const float cfo);
56 std::vector<gr_complex> cross_correlate_preamble(std::vector<gr_complex> in_vec);
57 std::vector<gr_complex> preamble();
58 void set_false_alarm_probability(float false_alarm_prob, int ninput_size);
59 std::vector<gr_complex> input_buffer();
60 std::vector<gr_complex> auto_corr_buffer();
61 std::vector<float> integration_buffer();
62 std::vector<float> auto_corr_integrate(std::vector<gr_complex> in_vec);
63
64 private:
65 int d_max_ninput_size;
66 int d_buffer_len;
67 float d_false_alarm_prob_factor;
68 int d_n_subcarriers;
69 int d_cp_len;
70 gr_complex* d_preamble;
71 gr_complex* d_p_in_buffer;
72 gr_complex* d_auto_corr_vals;
73 float* d_abs_auto_corr_vals;
74
75 void auto_correlate(gr_complex* corr_vals, const gr_complex* p_in, const int ninput_size);
76
77 // following functions take care of absolute value integration over CP length.
78 std::deque<float> d_fifo;
79 float integrate_fifo(float next_val);
80 void abs_integrate(float* vals, const gr_complex* p_in, const int ninput_size);
81
82 // calculate results from auto correlation.
83 int find_peak(float* vals, const int ninput_size);
84
85 // perform the auto correlation stage and write all results to the provided buffers!
86 void perform_auto_correlation_stage(float *abs_corr_vals, gr_complex *corr_vals,
87 const gr_complex *p_in, const int window_size);
88
89 // derive subcarrier CFO from correlation value peak.
90 float calculate_normalized_cfo(const gr_complex corr_val);
91
92 // function assumes enough samples are available. Just like xcorr stage does!
93 void prepare_xcorr_input_array(gr_complex *xcorr_in, const gr_complex *p_in,
94 const int offset);
95
96 // following lines hold arrays and functions for xcorr fine STO peak detection.
97 gr_complex* d_xcorr_vals;
98 float* d_abs_xcorr_vals;
99 int find_cross_correlation_peak(const gr_complex* p_in, const float* abs_int_vals, const float cfo);
100 void remove_cfo(gr_complex* p_out, const gr_complex* p_in, const float cfo, const int ninput_size);
101 void cross_correlate(gr_complex* p_out, const gr_complex* p_in, const int ninput_size);
102 void combine_abs_auto_and_cross_correlation(float* p_out, const float* p_auto, const float* p_cross, const int ninput_size);
103 float threshold(const float *abs_xcorr_vals);
104
105
106 };
107
108 } // namespace gfdm
109} // namespace gr
110
111#endif /* INCLUDED_GFDM_IMPROVED_SYNC_ALGORITHM_KERNEL_CC_H */
112
#define GFDM_API
Definition api.h:30
Perform STO/CFO synchronization for multicarrier systems Compare: Awoseyila et. al....
Definition improved_sync_algorithm_kernel_cc.h:41
std::vector< gr_complex > input_buffer()
int find_peak_preamble(std::vector< float > in_vec)
std::vector< gr_complex > auto_corr_buffer()
std::vector< gr_complex > auto_correlate_preamble(std::vector< gr_complex > in_vec)
std::vector< float > abs_integrate_preamble(std::vector< gr_complex > in_vec)
std::vector< gr_complex > remove_cfo_preamble(std::vector< gr_complex > in_vec, const float cfo)
float calculate_normalized_cfo_preamble(const gr_complex val)
Definition improved_sync_algorithm_kernel_cc.h:54
std::vector< gr_complex > preamble()
std::vector< float > auto_corr_integrate(std::vector< gr_complex > in_vec)
void set_false_alarm_probability(float false_alarm_prob, int ninput_size)
improved_sync_algorithm_kernel_cc(int n_subcarriers, int cp_len, std::vector< gr_complex > preamble, int max_ninput_size)
int max_ninput_size() const
Definition improved_sync_algorithm_kernel_cc.h:47
std::vector< gr_complex > cross_correlate_preamble(std::vector< gr_complex > in_vec)
int find_preamble(std::vector< gr_complex > in_vec)
int detect_frame_start(const gr_complex *p_in, int ninput_size)
Definition add_cyclic_prefix_cc.h:30