summaryrefslogtreecommitdiff
path: root/gr-digital/lib/ofdm_chanest_vcvc_impl.h
blob: def8734e644a8fda574f89968d00aa49d05efdb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* -*- c++ -*- */
/* 
 * Copyright 2013 Free Software Foundation, Inc.
 * 
 * This file is part of GNU Radio
 * 
 * GNU Radio is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 * 
 * GNU Radio is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with GNU Radio; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street,
 * Boston, MA 02110-1301, USA.
 */

#ifndef INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_IMPL_H
#define INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_IMPL_H

#include <digital/ofdm_chanest_vcvc.h>

namespace gr {
  namespace digital {

    class ofdm_chanest_vcvc_impl : public ofdm_chanest_vcvc
    {
     private:
      int d_fft_len; //! FFT length
      int d_n_data_syms; //! Number of data symbols following the sync symbol(s)
      int d_n_sync_syms; //! Number of sync symbols (1 or 2)
      //! 0 if no noise reduction is done for the initial channel state estimation. Otherwise, the maximum length of the channel delay in samples.
      int d_eq_noise_red_len;
      //! Is sync_symbol1 if d_n_sync_syms == 1, otherwise sync_symbol2. Used as a reference symbol to estimate the channel.
      std::vector<gr_complex> d_ref_sym;
      //! If d_n_sync_syms == 2 this is used as a differential correlation vector (called 'v' in [1]).
      std::vector<gr_complex> d_corr_v;
      //! If d_n_sync_syms == 1 we use this instead of d_corr_v to estimate the coarse freq. offset
      std::vector<float> d_known_symbol_diffs;
      //! If d_n_sync_syms == 1 we use this instead of d_corr_v to estimate the coarse freq. offset (temp. variable)
      std::vector<float> d_new_symbol_diffs;
      //! The index of the first carrier with data (index 0 is not DC here, but the lowest frequency)
      int d_first_active_carrier;
      //! The index of the last carrier with data
      int d_last_active_carrier;
      //! If true, the channel estimation must be interpolated
      bool d_interpolate;
      //! Maximum carrier offset (negative value!)
      int d_max_neg_carr_offset;
      //! Maximum carrier offset (positive value!)
      int d_max_pos_carr_offset;

      //! Calculate the coarse frequency offset in number of carriers
      int get_carr_offset(const gr_complex *sync_sym1, const gr_complex *sync_sym2);
      //! Estimate the channel (phase and amplitude offset per carrier)
      void get_chan_taps(const gr_complex *sync_sym1, const gr_complex *sync_sym2, int carr_offset, std::vector<gr_complex> &taps);

     public:
      ofdm_chanest_vcvc_impl(const std::vector<gr_complex> &sync_symbol1, const std::vector<gr_complex> &sync_symbol2, int n_data_symbols, int eq_noise_red_len, int max_carr_offset, bool force_one_sync_symbol);
      ~ofdm_chanest_vcvc_impl();

      void forecast (int noutput_items, gr_vector_int &ninput_items_required);
      int general_work(int noutput_items,
		       gr_vector_int &ninput_items,
		       gr_vector_const_void_star &input_items,
		       gr_vector_void_star &output_items);
    };

  } // namespace digital
} // namespace gr

#endif /* INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_IMPL_H */