GNU Radio 3.6.5.1 C++ API
digital_ofdm_carrier_allocator_cvc.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /* Copyright 2012 Free Software Foundation, Inc.
3  *
4  * This file is part of GNU Radio
5  *
6  * GNU Radio is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3, or (at your option)
9  * any later version.
10  *
11  * GNU Radio is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GNU Radio; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 
23 #ifndef INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H
24 #define INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H
25 
26 #include <digital_api.h>
27 #include <gr_tagged_stream_block.h>
28 
31 
32 /*
33  * \param occupied_carriers A vector of vectors of indexes. Example: if
34  * occupied_carriers = ((1, 2, 3), (1, 2, 4)), the first
35  * three input symbols will be mapped to carriers 1, 2
36  * and 3. After that, a new OFDM symbol is started. The next
37  * three input symbols will be placed onto carriers 1, 2
38  * and 4 of the second OFDM symbol. The allocation then
39  * starts from the beginning.
40  * Order matters! The first input symbol is always mapped
41  * onto occupied_carriers[0][0].
42  * \param pilot_carriers The position of the pilot symbols. Same as occupied_carriers,
43  * but the actual symbols are taken from pilot_symbols instead
44  * of the input stream.
45  * \param pilot_symbols The pilot symbols which are placed onto the pilot carriers.
46  * pilot_symbols[0][0] is placed onto the first OFDM symbol, on
47  * carrier index pilot_carriers[0][0] etc.
48  * \param len_tag_key The key of the tag identifying the length of the input packet.
49  */
52  int fft_len,
53  const std::vector<std::vector<int> > &occupied_carriers,
54  const std::vector<std::vector<int> > &pilot_carriers,
55  const std::vector<std::vector<gr_complex> > &pilot_symbols,
56  const std::string &len_tag_key = "packet_len");
57 
58 /*!
59  * \brief Create frequency domain OFDM symbols from complex values, add pilots.
60  * \ingroup ofdm_blk
61  *
62  * This block turns a stream of complex, scalar modulation symbols into vectors
63  * which are the input for an IFFT in an OFDM transmitter. It also supports the
64  * possibility of placing pilot symbols onto the carriers.
65  *
66  * The carriers can be allocated freely, if a carrier is not allocated, it is set
67  * to zero. This allows doing OFDMA-style carrier allocations.
68  *
69  * Input: A tagged stream of complex scalars. The first item must have a tag
70  * containing the number of complex symbols in this frame.
71  * Output: A tagged stream of complex vectors of length fft_len. This can directly
72  * be connected to an FFT block. Make sure to set this block to 'reverse'
73  * for the IFFT and to deactivate FFT shifting.
74  *
75  * Carrier indexes are always such that index 0 is the DC carrier (note: you should
76  * not allocate this carrier). The carriers below the DC carrier are either indexed
77  * with negative numbers, or with indexes larger than fft_len/2. Index -1 and index
78  * fft_len-1 both identify the carrier below the DC carrier.
79  *
80  */
82 {
83  private:
84  friend DIGITAL_API digital_ofdm_carrier_allocator_cvc_sptr digital_make_ofdm_carrier_allocator_cvc (int fft_len, const std::vector<std::vector<int> > &occupied_carriers, const std::vector<std::vector<int> > &pilot_carriers, const std::vector<std::vector<gr_complex> > &pilot_symbols, const std::string &len_tag_key);
85 
86  digital_ofdm_carrier_allocator_cvc(int fft_len, const std::vector<std::vector<int> > &occupied_carriers, const std::vector<std::vector<int> > &pilot_carriers, const std::vector<std::vector<gr_complex> > &pilot_symbols, const std::string &len_tag_key);
87 
88  //! FFT length
89  const int d_fft_len;
90  //! Which carriers/symbols carry data
91  std::vector<std::vector<int> > d_occupied_carriers;
92  //! Which carriers/symbols carry pilots symbols
93  std::vector<std::vector<int> > d_pilot_carriers;
94  //! Value of said pilot symbols
95  const std::vector<std::vector<gr_complex> > d_pilot_symbols;
96  int d_symbols_per_set;
97 
98  protected:
99  int calculate_output_stream_length(const gr_vector_int &ninput_items);
100 
101  public:
103 
104  std::string len_tag_key() { return d_length_tag_key_str; };
105 
106  const int fft_len() { return d_fft_len; };
107  std::vector<std::vector<int> > occupied_carriers() { return d_occupied_carriers; };
108 
109  int work (int noutput_items,
110  gr_vector_int &ninput_items,
111  gr_vector_const_void_star &input_items,
112  gr_vector_void_star &output_items);
113 };
114 
115 #endif /* INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H */
116