diff options
Diffstat (limited to 'gr-digital/lib')
-rw-r--r-- | gr-digital/lib/CMakeLists.txt | 4 | ||||
-rw-r--r-- | gr-digital/lib/cma_equalizer_cc_impl.cc | 13 | ||||
-rw-r--r-- | gr-digital/lib/cma_equalizer_cc_impl.h | 4 | ||||
-rw-r--r-- | gr-digital/lib/digital_kurtotic_equalizer_cc.cc | 87 | ||||
-rw-r--r-- | gr-digital/lib/digital_lms_dd_equalizer_cc.cc | 83 | ||||
-rw-r--r-- | gr-digital/lib/kurtotic_equalizer_cc_impl.cc | 97 | ||||
-rw-r--r-- | gr-digital/lib/kurtotic_equalizer_cc_impl.h | 108 | ||||
-rw-r--r-- | gr-digital/lib/lms_dd_equalizer_cc_impl.cc | 94 | ||||
-rw-r--r-- | gr-digital/lib/lms_dd_equalizer_cc_impl.h | 87 |
9 files changed, 393 insertions, 184 deletions
diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt index b075e980d5..cdbe4b83b4 100644 --- a/gr-digital/lib/CMakeLists.txt +++ b/gr-digital/lib/CMakeLists.txt @@ -127,8 +127,8 @@ list(APPEND digital_sources glfsr_source_b_impl.cc glfsr_source_f_impl.cc #gmskmod_bc_impl.cc - #lms_dd_equalizer_cc_impl.cc - #kurtotic_equalizer_cc_impl.cc + kurtotic_equalizer_cc_impl.cc + lms_dd_equalizer_cc_impl.cc map_bb_impl.cc mpsk_receiver_cc_impl.cc mpsk_snr_est_cc_impl.cc diff --git a/gr-digital/lib/cma_equalizer_cc_impl.cc b/gr-digital/lib/cma_equalizer_cc_impl.cc index 6d32e1a64f..fca7c0c6e5 100644 --- a/gr-digital/lib/cma_equalizer_cc_impl.cc +++ b/gr-digital/lib/cma_equalizer_cc_impl.cc @@ -49,10 +49,10 @@ namespace gr { set_modulus(modulus); set_gain(mu); if(num_taps > 0) - d_new_taps[0] = 1.0; - filter::kernel::fir_filter_ccc::set_taps(d_new_taps); + d_taps[0] = 1.0; + set_taps(d_taps); - set_history(ntaps()); + set_history(num_taps+1); } cma_equalizer_cc_impl::~cma_equalizer_cc_impl() @@ -67,13 +67,6 @@ namespace gr { gr_complex *in = (gr_complex *)input_items[0]; gr_complex *out = (gr_complex *)output_items[0]; - if (d_updated) { - filter::kernel::fir_filter_ccc::set_taps(d_new_taps); - set_history(ntaps()); - d_updated = false; - return 0; // history requirements may have changed. - } - int j = 0, k, l = d_taps.size(); for(int i = 0; i < noutput_items; i++) { out[i] = filter(&in[j]); diff --git a/gr-digital/lib/cma_equalizer_cc_impl.h b/gr-digital/lib/cma_equalizer_cc_impl.h index 9ca4214961..9e95d46f02 100644 --- a/gr-digital/lib/cma_equalizer_cc_impl.h +++ b/gr-digital/lib/cma_equalizer_cc_impl.h @@ -61,7 +61,7 @@ namespace gr { cma_equalizer_cc_impl(int num_taps, float modulus, float mu, int sps); ~cma_equalizer_cc_impl(); - float gain() + float gain() const { return d_mu; } @@ -74,7 +74,7 @@ namespace gr { d_mu = mu; } - float modulus() + float modulus() const { return d_modulus; } diff --git a/gr-digital/lib/digital_kurtotic_equalizer_cc.cc b/gr-digital/lib/digital_kurtotic_equalizer_cc.cc deleted file mode 100644 index f10ec83482..0000000000 --- a/gr-digital/lib/digital_kurtotic_equalizer_cc.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <digital_kurtotic_equalizer_cc.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -digital_kurtotic_equalizer_cc_sptr -digital_make_kurtotic_equalizer_cc(int num_taps, float mu) -{ - return gnuradio::get_initial_sptr - (new digital_kurtotic_equalizer_cc(num_taps, mu)); -} - -digital_kurtotic_equalizer_cc::digital_kurtotic_equalizer_cc(int num_taps, float mu) - : gr_sync_decimator("kurtotic_equalizer_cc", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(1, 1, sizeof(gr_complex)), - 1), - gr::filter::kernel::adaptive_fir_ccc(1, std::vector<gr_complex>(num_taps, gr_complex(0,0))) -{ - set_gain(mu); - if (num_taps > 0) - d_taps[0] = 1.0; - set_taps(d_taps); - - d_alpha_p = 0.01; - d_alpha_q = 0.01; - d_alpha_m = 0.01; - - d_p = 0.0f; - d_m = 0.0f; - d_q = gr_complex(0,0); - d_u = gr_complex(0,0); - - const int alignment_multiple = - volk_get_alignment() / sizeof(gr_complex); - set_alignment(std::max(1,alignment_multiple)); - set_history(num_taps+1); -} - -int -digital_kurtotic_equalizer_cc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *)input_items[0]; - gr_complex *out = (gr_complex *)output_items[0]; - - int j = 0, k, l = d_taps.size(); - for(int i = 0; i < noutput_items; i++) { - out[i] = filter(&in[j]); - - // Adjust taps - d_error = error(out[i]); - for(k = 0; k < l; k++) { - update_tap(d_taps[l-k-1], in[j+k]); - } - - j += decimation(); - } - - return noutput_items; -} diff --git a/gr-digital/lib/digital_lms_dd_equalizer_cc.cc b/gr-digital/lib/digital_lms_dd_equalizer_cc.cc deleted file mode 100644 index 5238063fa7..0000000000 --- a/gr-digital/lib/digital_lms_dd_equalizer_cc.cc +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <digital_lms_dd_equalizer_cc.h> -#include <gr_io_signature.h> -#include <gr_misc.h> -#include <volk/volk.h> - -digital_lms_dd_equalizer_cc_sptr -digital_make_lms_dd_equalizer_cc(int num_taps, float mu, int sps, - digital_constellation_sptr cnst) -{ - return gnuradio::get_initial_sptr - (new digital_lms_dd_equalizer_cc(num_taps, mu, sps, cnst)); -} - -digital_lms_dd_equalizer_cc::digital_lms_dd_equalizer_cc(int num_taps, float mu, - int sps, - digital_constellation_sptr cnst) - : gr_sync_decimator("lms_dd_equalizer_cc", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(1, 1, sizeof(gr_complex)), - sps), - gr::filter::kernel::adaptive_fir_ccc(sps, std::vector<gr_complex>(num_taps, gr_complex(0,0))), - d_cnst(cnst) -{ - set_gain(mu); - if(num_taps > 0) - d_taps[0] = 1.0; - set_taps(d_taps); - - const int alignment_multiple = - volk_get_alignment() / sizeof(gr_complex); - set_alignment(std::max(1,alignment_multiple)); - set_history(num_taps+1); -} - -int -digital_lms_dd_equalizer_cc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *)input_items[0]; - gr_complex *out = (gr_complex *)output_items[0]; - - int j = 0; - size_t l = d_taps.size(); - for(int i = 0; i < noutput_items; i++) { - out[i] = filter(&in[j]); - - d_error = error(out[i]); - for(size_t k=0; k < l; k++) { - update_tap(d_taps[k], in[i+k]); - } - - j += decimation(); - } - - return noutput_items; -} diff --git a/gr-digital/lib/kurtotic_equalizer_cc_impl.cc b/gr-digital/lib/kurtotic_equalizer_cc_impl.cc new file mode 100644 index 0000000000..c3be3b5d06 --- /dev/null +++ b/gr-digital/lib/kurtotic_equalizer_cc_impl.cc @@ -0,0 +1,97 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "kurtotic_equalizer_cc_impl.h" +#include <gr_io_signature.h> +#include <volk/volk.h> + +namespace gr { + namespace digital { + + kurtotic_equalizer_cc::sptr + kurtotic_equalizer_cc::make(int num_taps, float mu) + { + return gnuradio::get_initial_sptr + (new kurtotic_equalizer_cc_impl(num_taps, mu)); + } + + kurtotic_equalizer_cc_impl::kurtotic_equalizer_cc_impl(int num_taps, float mu) + : gr_sync_decimator("kurtotic_equalizer_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(gr_complex)), + 1), + filter::kernel::fir_filter_ccc(1, std::vector<gr_complex>(num_taps, gr_complex(0,0))) + { + set_gain(mu); + if(num_taps > 0) + d_taps[0] = 1.0; + set_taps(d_taps); + + d_alpha_p = 0.01; + d_alpha_q = 0.01; + d_alpha_m = 0.01; + + d_p = 0.0f; + d_m = 0.0f; + d_q = gr_complex(0,0); + d_u = gr_complex(0,0); + + const int alignment_multiple = + volk_get_alignment() / sizeof(gr_complex); + set_alignment(std::max(1,alignment_multiple)); + set_history(num_taps+1); + } + + kurtotic_equalizer_cc_impl::~kurtotic_equalizer_cc_impl() + { + } + + int + kurtotic_equalizer_cc_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr_complex *in = (gr_complex *)input_items[0]; + gr_complex *out = (gr_complex *)output_items[0]; + + int j = 0, k, l = d_taps.size(); + for(int i = 0; i < noutput_items; i++) { + out[i] = filter(&in[j]); + + // Adjust taps + d_error = error(out[i]); + for(k = 0; k < l; k++) { + update_tap(d_taps[l-k-1], in[j+k]); + } + + j += decimation(); + } + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/kurtotic_equalizer_cc_impl.h b/gr-digital/lib/kurtotic_equalizer_cc_impl.h new file mode 100644 index 0000000000..0f2ff23808 --- /dev/null +++ b/gr-digital/lib/kurtotic_equalizer_cc_impl.h @@ -0,0 +1,108 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_KURTOTIC_EQUALIZER_CC_IMPL_H +#define INCLUDED_DIGITAL_KURTOTIC_EQUALIZER_CC_IMPL_H + +#include <digital/kurtotic_equalizer_cc.h> +#include <filter/fir_filter.h> +#include <gr_math.h> +#include <stdexcept> + +namespace gr { + namespace digital { + + class kurtotic_equalizer_cc_impl + : public kurtotic_equalizer_cc, filter::kernel::fir_filter_ccc + { + private: + std::vector<gr_complex> d_new_taps; + bool d_updated; + gr_complex d_error; + + float d_mu; + float d_p, d_m; + gr_complex d_q, d_u; + float d_alpha_p, d_alpha_q, d_alpha_m; + + gr_complex sign(gr_complex x) + { + float re = (float)(x.real() >= 0.0f); + float im = (float)(x.imag() >= 0.0f); + return gr_complex(re, im); + } + + protected: + virtual gr_complex error(const gr_complex &out) + { + // p = E[|z|^2] + // q = E[z^2] + // m = E[|z|^4] + // u = E[kurtosis(z)] + + float nrm = norm(out); + gr_complex cnj = conj(out); + float epsilon_f = 1e-12; + gr_complex epsilon_c = gr_complex(1e-12, 1e-12); + + d_p = (1-d_alpha_p)*d_p + (d_alpha_p)*nrm + epsilon_f; + d_q = (1-d_alpha_q)*d_q + (d_alpha_q)*out*out + epsilon_c; + d_m = (1-d_alpha_m)*d_m + (d_alpha_m)*nrm*nrm + epsilon_f; + d_u = d_m - 2.0f*(d_p*d_p) - d_q*d_q; + + gr_complex F = (1.0f / (d_p*d_p*d_p)) * + (sign(d_u) * (nrm*cnj - 2.0f*d_p*cnj - conj(d_q)*out) - + abs(d_u)*cnj); + + float re = gr_clip(F.real(), 1.0); + float im = gr_clip(F.imag(), 1.0); + return gr_complex(re, im); + } + + virtual void update_tap(gr_complex &tap, const gr_complex &in) + { + tap += d_mu*in*d_error; + } + + public: + kurtotic_equalizer_cc_impl(int num_taps, float mu); + ~kurtotic_equalizer_cc_impl(); + + float gain() const { return d_mu; } + + void set_gain(float mu) + { + if(mu < 0) + throw std::out_of_range("kurtotic_equalizer_cc_impl::set_gain: Gain value must be >= 0"); + d_mu = mu; + } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_KURTOTIC_EQUALIZER_CC_IMPL_H */ + diff --git a/gr-digital/lib/lms_dd_equalizer_cc_impl.cc b/gr-digital/lib/lms_dd_equalizer_cc_impl.cc new file mode 100644 index 0000000000..6c217896c3 --- /dev/null +++ b/gr-digital/lib/lms_dd_equalizer_cc_impl.cc @@ -0,0 +1,94 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "lms_dd_equalizer_cc_impl.h" +#include <gr_io_signature.h> +#include <gr_misc.h> +#include <volk/volk.h> + +namespace gr { + namespace digital { + + lms_dd_equalizer_cc::sptr + lms_dd_equalizer_cc::make(int num_taps, float mu, int sps, + constellation_sptr cnst) + { + return gnuradio::get_initial_sptr + (new lms_dd_equalizer_cc_impl(num_taps, mu, sps, cnst)); + } + + lms_dd_equalizer_cc_impl::lms_dd_equalizer_cc_impl(int num_taps, float mu, + int sps, + constellation_sptr cnst) + : gr_sync_decimator("lms_dd_equalizer_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(gr_complex)), + sps), + filter::kernel::fir_filter_ccc(sps, std::vector<gr_complex>(num_taps, gr_complex(0,0))), + d_cnst(cnst) + { + set_gain(mu); + if(num_taps > 0) + d_taps[0] = 1.0; + set_taps(d_taps); + + const int alignment_multiple = + volk_get_alignment() / sizeof(gr_complex); + set_alignment(std::max(1,alignment_multiple)); + + set_history(num_taps+1); + } + + lms_dd_equalizer_cc_impl::~lms_dd_equalizer_cc_impl() + { + } + + int + lms_dd_equalizer_cc_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex *)input_items[0]; + gr_complex *out = (gr_complex *)output_items[0]; + + int j = 0; + size_t l = d_taps.size(); + for(int i = 0; i < noutput_items; i++) { + out[i] = filter(&in[j]); + + d_error = error(out[i]); + for(size_t k=0; k < l; k++) { + update_tap(d_taps[k], in[i+k]); + } + + j += decimation(); + } + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/lms_dd_equalizer_cc_impl.h b/gr-digital/lib/lms_dd_equalizer_cc_impl.h new file mode 100644 index 0000000000..aa84a71b4a --- /dev/null +++ b/gr-digital/lib/lms_dd_equalizer_cc_impl.h @@ -0,0 +1,87 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_LMS_DD_EQUALIZER_CC_IMPL_H +#define INCLUDED_DIGITAL_LMS_DD_EQUALIZER_CC_IMPL_H + +#include <digital/lms_dd_equalizer_cc.h> +#include <filter/fir_filter.h> +#include <stdexcept> + +namespace gr { + namespace digital { + + class lms_dd_equalizer_cc_impl + : public lms_dd_equalizer_cc, filter::kernel::fir_filter_ccc + { + private: + std::vector<gr_complex> d_new_taps; + bool d_updated; + gr_complex d_error; + + float d_mu; + constellation_sptr d_cnst; + + protected: + gr_complex error(const gr_complex &out) + { + gr_complex decision, error; + d_cnst->map_to_points(d_cnst->decision_maker(&out), &decision); + error = decision - out; + return error; + } + + void update_tap(gr_complex &tap, const gr_complex &in) + { + tap += d_mu*conj(in)*d_error; + } + + public: + lms_dd_equalizer_cc_impl(int num_taps, + float mu, int sps, + constellation_sptr cnst); + ~lms_dd_equalizer_cc_impl(); + + float gain() const + { + return d_mu; + } + + void set_gain(float mu) + { + if(mu < 0.0f || mu > 1.0f) { + throw std::out_of_range("lms_dd_equalizer_impl::set_mu: Gain value must in [0, 1]"); + } + else { + d_mu = mu; + } + } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_LMS_DD_EQUALIZER_CC_IMPL_H */ |