four_multi
Multi-Antenna,Multi-Node,Multi-Band,Multi-Cell
examples/SISO_AMC_OFDM_node.hpp
00001 //
00002 // Copyright 2011-2013, Per Zetterberg, KTH Royal Institute of Technology
00003 //
00004 // This program is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #ifndef SISO_LDPC_OFDM_node_HPP
00019 #define SISO_LDPC_OFDM_node_HPP
00020 
00021 #include <uhd/device.hpp>
00022 #include <uhd/utils/thread_priority.hpp>
00023 #include <uhd/utils/safe_main.hpp>
00024 #include <uhd/usrp/multi_usrp.hpp>
00025 #include <boost/program_options.hpp>
00026 #include <boost/format.hpp>
00027 #include <iostream>
00028 #include <complex>
00029 #include <uhd/types/clock_config.hpp>
00030 #include <four_multi/gps.hpp>
00031 #include <four_multi/four_multi.hpp>
00032 #include <four_multi/modem_OFDM1.hpp>
00033 #include <itpp/itbase.h>
00034 #include <itpp/itcomm.h>
00035 #include <itpp/stat/misc_stat.h>
00036 #include <four_multi/simulator.hpp>
00037 #include <four_multi/AMC.hpp>
00038 
00039 using namespace boost;
00040 using namespace itpp;
00041 
00042 
00047 class SISO_AMC_OFDM_node : public four_multi_node {
00048 
00049    public:
00050    
00051   /* \brief Constructor. 
00052      \param  start_gain_rx This is the receiver gain. As the name indicates the received gain could be updated during the run, However, this was never implemented.
00053       \param start_gain_tx This is the transmitter gain.
00054       \param use_same_antenna. If XCVR2450 is used, setting this value 
00055            to true makes the J1 antenna connector be used during TX and RX. 
00056            Setting it to false makes J1 being used for RX and J2 for TX.
00057       \param modulation_order. Possible values are 4, 16 and 256. This is the constellation size of the QAM modulation used.
00058       \param simulate. This parameter is set true in 
00059   SISO_AMC_OFDM_simulator and false in SISO_AMC_OFDM_realtime.
00060       \param codec_ix: The codec number used by the AMC modulation and coding (LDPC). There are three possibilities 0 (rate 1/4), 1 (rate 1/2) and 2, (rate 3/4).
00061       \param chase Use chase combining (true or false).
00062       \param delta_t Time in seconds between frames.
00063   */  
00064     SISO_AMC_OFDM_node(float gain_rx, 
00065       float gain_tx,uint32_t node_ix , double frequency,
00066                        bool same_antenna,
00067                        uint32_t modulation_order, bool simulate, uint32_t codec_ix,bool chase, double delta_time);
00068 
00069 
00070    uint32_t frame_ix(void ){ return d_frame_ix;};
00071 
00072  
00073    ~SISO_AMC_OFDM_node();
00074   
00075    double get_gain(void) {return d_gain_rx;};
00076    OFDM1 ai; 
00077 
00078    vec BERraw, BER;
00079    cvec symbols, symbols_chase;
00080   
00081    uint64_t seed;
00082 
00083    protected:   
00084 
00085    uint32_t d_codec_ix;
00086    uint32_t d_modulation_order;
00087 
00088 
00089   //2E. K26
00090 
00091    virtual frame_settings node_init(void) ;
00092    virtual frame_settings node_process(void) ;
00093    virtual void end_of_run(void) ;
00094 
00095    void format_tx_symbols(uint32_t codec_ix, uint32_t modulation_order); 
00096    void decode_rx_symbols(uint32_t codec_ix, uint32_t modulation_order,
00097                           bool use_chase_combining);
00098 
00099    static const uint32_t buffer_size=10000;
00100    static const uint32_t block_length=400;
00101    static const uint32_t shift_transmit_signal_samples=2000;
00102    static const uint32_t max_modulation_order=256;
00103 
00104    double base_band_tx_power_ampl;
00105    uint32_t d_frame_ix, d_no_frames;
00106    double d_delta_time;
00107    double d_gain_rx, d_gain_tx, d_frequency;
00108    bool d_chase;
00109    cvec waveform_rx;
00110    cvec waveform_tx;
00111    bvec input, transmitted, transmitted_hat, message_hat, input_hat;
00112    double noise_variance_chase;
00113    double noise_variance, noise_variance_norm;
00114    vec soft_bit;
00115    int max_message_length, word_length;
00116    double scaling_tx_signal; 
00117 
00118    AMC amc;
00119 
00120    BERC berc;
00121    bvec decoded_bits;
00122    int ber_i;
00123 
00124    int modulation_order;
00125    int codec_ix;
00126 
00127 
00128 };
00129 
00130 
00131 
00132 #endif
 All Classes Functions Variables