3 * Copyright 2006, 2007 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
23 #ifndef INCLUDED_GR_OFDM_FRAME_ACQUISITION_H
24 #define INCLUDED_GR_OFDM_FRAME_ACQUISITION_H
30 class gr_ofdm_frame_acquisition;
31 typedef boost::shared_ptr<gr_ofdm_frame_acquisition> gr_ofdm_frame_acquisition_sptr;
33 gr_ofdm_frame_acquisition_sptr
34 gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length,
36 const std::vector<gr_complex> &known_symbol,
37 unsigned int max_fft_shift_len=10);
40 * \brief take a vector of complex constellation points in from an FFT
41 * and performs a correlation and equalization.
42 * \ingroup demodulation_blk
44 * This block takes the output of an FFT of a received OFDM symbol and finds the
45 * start of a frame based on two known symbols. It also looks at the surrounding
46 * bins in the FFT output for the correlation in case there is a large frequency
47 * shift in the data. This block assumes that the fine frequency shift has already
48 * been corrected and that the samples fall in the middle of one FFT bin.
50 * It then uses one of those known
51 * symbols to estimate the channel response over all subcarriers and does a simple
52 * 1-tap equalization on all subcarriers. This corrects for the phase and amplitude
53 * distortion caused by the channel.
56 class gr_ofdm_frame_acquisition : public gr_block
59 * \brief Build an OFDM correlator and equalizer.
60 * \param occupied_carriers The number of subcarriers with data in the received symbol
61 * \param fft_length The size of the FFT vector (occupied_carriers + unused carriers)
62 * \param known_symbol1 A vector of complex numbers representing a known symbol at the
63 * start of a frame (usually a BPSK PN sequence)
64 * \param known_symbol2 A vector of complex numbers representing a known symbol at the
65 * start of a frame after known_symbol1 (usually a BPSK PN sequence).
66 * Both of these start symbols are differentially correlated to compensate
67 * for phase changes between symbols.
68 * \param max_fft_shift_len Set's the maximum distance you can look between bins for correlation
70 friend gr_ofdm_frame_acquisition_sptr
71 gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length,
73 const std::vector<gr_complex> &known_symbol,
74 unsigned int max_fft_shift_len);
77 gr_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length,
79 const std::vector<gr_complex> &known_symbol,
80 unsigned int max_fft_shift_len);
83 unsigned char slicer(gr_complex x);
84 void correlate(const gr_complex *symbol, int zeros_on_left);
85 void calculate_equalizer(const gr_complex *symbol, int zeros_on_left);
86 gr_complex coarse_freq_comp(int freq_delta, int count);
88 unsigned int d_occupied_carriers; // !< \brief number of subcarriers with data
89 unsigned int d_fft_length; // !< \brief length of FFT vector
90 unsigned int d_cplen; // !< \brief length of cyclic prefix in samples
91 unsigned int d_freq_shift_len; // !< \brief number of surrounding bins to look at for correlation
92 std::vector<gr_complex> d_known_symbol; // !< \brief known symbols at start of frame
93 std::vector<float> d_known_phase_diff; // !< \brief factor used in correlation from known symbol
94 std::vector<float> d_symbol_phase_diff; // !< \brief factor used in correlation from received symbol
95 std::vector<gr_complex> d_hestimate; // !< channel estimate
96 int d_coarse_freq; // !< \brief search distance in number of bins
97 unsigned int d_phase_count; // !< \brief accumulator for coarse freq correction
98 float d_snr_est; // !< an estimation of the signal to noise ratio
100 gr_complex *d_phase_lut; // !< look-up table for coarse frequency compensation
102 void forecast(int noutput_items, gr_vector_int &ninput_items_required);
106 * \brief Return an estimate of the SNR of the channel
108 float snr() { return d_snr_est; }
110 ~gr_ofdm_frame_acquisition(void);
111 int general_work(int noutput_items,
112 gr_vector_int &ninput_items,
113 gr_vector_const_void_star &input_items,
114 gr_vector_void_star &output_items);