diff options
author | Tom Rondeau <trondeau@vt.edu> | 2012-08-14 21:00:26 -0400 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2012-08-14 21:00:26 -0400 |
commit | c537cf7d85f59db21c98ac859bc08fbe55031314 (patch) | |
tree | fd260f991eeb7fe1e2b7e2c2f781bfa50f6b2704 /gr-digital/include | |
parent | e45449570984c0a709a21ea5ab078f9747e4b9c5 (diff) |
digital: converted equalizers and fixed cma equalizer.
Diffstat (limited to 'gr-digital/include')
-rw-r--r-- | gr-digital/include/digital/CMakeLists.txt | 4 | ||||
-rw-r--r-- | gr-digital/include/digital/cma_equalizer_cc.h | 6 | ||||
-rw-r--r-- | gr-digital/include/digital/kurtotic_equalizer_cc.h | 63 | ||||
-rw-r--r-- | gr-digital/include/digital/lms_dd_equalizer_cc.h | 89 | ||||
-rw-r--r-- | gr-digital/include/digital_kurtotic_equalizer_cc.h | 121 | ||||
-rw-r--r-- | gr-digital/include/digital_lms_dd_equalizer_cc.h | 125 |
6 files changed, 157 insertions, 251 deletions
diff --git a/gr-digital/include/digital/CMakeLists.txt b/gr-digital/include/digital/CMakeLists.txt index 5a6bd563fc..eb2dedc334 100644 --- a/gr-digital/include/digital/CMakeLists.txt +++ b/gr-digital/include/digital/CMakeLists.txt @@ -101,8 +101,8 @@ install(FILES glfsr_source_b.h glfsr_source_f.h # gmskmod_bc.h -# lms_dd_equalizer_cc.h -# kurtotic_equalizer_cc.h + kurtotic_equalizer_cc.h + lms_dd_equalizer_cc.h map_bb.h metric_type.h mpsk_receiver_cc.h diff --git a/gr-digital/include/digital/cma_equalizer_cc.h b/gr-digital/include/digital/cma_equalizer_cc.h index 6d6be0f2aa..659437694e 100644 --- a/gr-digital/include/digital/cma_equalizer_cc.h +++ b/gr-digital/include/digital/cma_equalizer_cc.h @@ -53,13 +53,13 @@ namespace gr { static sptr make(int num_taps, float modulus, float mu, int sps); - virtual float gain() = 0; + virtual float gain() const = 0; virtual void set_gain(float mu) = 0; - virtual float modulus() = 0; + virtual float modulus() const = 0; virtual void set_modulus(float mod) = 0; }; } /* namespace digital */ } /* namespace gr */ -#endif +#endif /* INCLUDED_DIGITAL_CMA_EQUALIZER_CC_H */ diff --git a/gr-digital/include/digital/kurtotic_equalizer_cc.h b/gr-digital/include/digital/kurtotic_equalizer_cc.h new file mode 100644 index 0000000000..2753cb3cce --- /dev/null +++ b/gr-digital/include/digital/kurtotic_equalizer_cc.h @@ -0,0 +1,63 @@ +/* -*- 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_H +#define INCLUDED_DIGITAL_KURTOTIC_EQUALIZER_CC_H + +#include <digital/api.h> +#include <gr_sync_decimator.h> + +namespace gr { + namespace digital { + + /*! + * \brief Implements a kurtosis-based adaptive equalizer on complex stream + * \ingroup eq_blk + * \ingroup digital + * + * WARNING: This block does not yet work. + * + * "Y. Guo, J. Zhao, Y. Sun, "Sign kurtosis maximization based blind + * equalization algorithm," IEEE Conf. on Control, Automation, + * Robotics and Vision, Vol. 3, Dec. 2004, pp. 2052 - 2057." + */ + class DIGITAL_API kurtotic_equalizer_cc : + virtual public gr_sync_decimator + { + protected: + virtual gr_complex error(const gr_complex &out) = 0; + virtual void update_tap(gr_complex &tap, const gr_complex &in) = 0; + + public: + // gr::digital::kurtotic_equalizer_cc::sptr + typedef boost::shared_ptr<kurtotic_equalizer_cc> sptr; + + static sptr make(int num_taps, float mu); + + virtual float gain() const = 0; + virtual void set_gain(float mu) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_KURTOTIC_EQUALIZER_CC_H */ diff --git a/gr-digital/include/digital/lms_dd_equalizer_cc.h b/gr-digital/include/digital/lms_dd_equalizer_cc.h new file mode 100644 index 0000000000..b4cde28545 --- /dev/null +++ b/gr-digital/include/digital/lms_dd_equalizer_cc.h @@ -0,0 +1,89 @@ +/* -*- 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_H +#define INCLUDED_DIGITAL_LMS_DD_EQUALIZER_CC_H + +#include <digital/api.h> +#include <gr_sync_decimator.h> +#include <digital/constellation.h> + +namespace gr { + namespace digital { + + /*! + * \brief Least-Mean-Square Decision Directed Equalizer (complex in/out) + * \ingroup eq_blk + * \ingroup digital + * + * This block implements an LMS-based decision-directed equalizer. + * It uses a set of weights, w, to correlate against the inputs, + * u, and a decisions is then made from this output. The error in + * the decision is used to update teh weight vector. + * + * y[n] = conj(w[n]) u[n] + * d[n] = decision(y[n]) + * e[n] = d[n] - y[n] + * w[n+1] = w[n] + mu u[n] conj(e[n]) + * + * Where mu is a gain value (between 0 and 1 and usualy small, + * around 0.001 - 0.01. + * + * This block uses the digital_constellation object for making the + * decision from y[n]. Create the constellation object for + * whatever constellation is to be used and pass in the object. + * In Python, you can use something like: + * + * self.constellation = digital.constellation_qpsk() + * + * To create a QPSK constellation (see the digital_constellation + * block for more details as to what constellations are available + * or how to create your own). You then pass the object to this + * block as an sptr, or using "self.constellation.base()". + * + * The theory for this algorithm can be found in Chapter 9 of: + * S. Haykin, Adaptive Filter Theory, Upper Saddle River, NJ: + * Prentice Hall, 1996. + */ + class DIGITAL_API lms_dd_equalizer_cc : + virtual public gr_sync_decimator + { + protected: + virtual gr_complex error(const gr_complex &out) = 0; + virtual void update_tap(gr_complex &tap, const gr_complex &in) = 0; + + public: + // gr::digital::lms_dd_equalizer_cc::sptr + typedef boost::shared_ptr<lms_dd_equalizer_cc> sptr; + + static sptr make(int num_taps, + float mu, int sps, + constellation_sptr cnst); + + virtual float gain() const = 0; + virtual void set_gain(float mu) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_LMS_DD_EQUALIZER_CC_H */ diff --git a/gr-digital/include/digital_kurtotic_equalizer_cc.h b/gr-digital/include/digital_kurtotic_equalizer_cc.h deleted file mode 100644 index c18d91560c..0000000000 --- a/gr-digital/include/digital_kurtotic_equalizer_cc.h +++ /dev/null @@ -1,121 +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. - */ - -#ifndef INCLUDED_DIGITAL_KURTOTIC_EQUALIZER_CC_H -#define INCLUDED_DIGITAL_KURTOTIC_EQUALIZER_CC_H - -#include <digital_api.h> -#include <gr_sync_decimator.h> -#include <filter/adaptive_fir.h> -#include <gr_math.h> -#include <iostream> -#include <stdexcept> - -class digital_kurtotic_equalizer_cc; -typedef boost::shared_ptr<digital_kurtotic_equalizer_cc> digital_kurtotic_equalizer_cc_sptr; - -DIGITAL_API digital_kurtotic_equalizer_cc_sptr -digital_make_kurtotic_equalizer_cc(int num_taps, float mu); - -/*! - * \brief Implements a kurtosis-based adaptive equalizer on complex stream - * \ingroup eq_blk - * \ingroup digital - * - * WARNING: This block does not yet work. - * - * "Y. Guo, J. Zhao, Y. Sun, "Sign kurtosis maximization based blind - * equalization algorithm," IEEE Conf. on Control, Automation, - * Robotics and Vision, Vol. 3, Dec. 2004, pp. 2052 - 2057." - */ -class DIGITAL_API digital_kurtotic_equalizer_cc : - public gr_sync_decimator, public gr::filter::kernel::adaptive_fir_ccc -{ -private: - float d_mu; - float d_p, d_m; - gr_complex d_q, d_u; - float d_alpha_p, d_alpha_q, d_alpha_m; - - friend DIGITAL_API digital_kurtotic_equalizer_cc_sptr - digital_make_kurtotic_equalizer_cc(int num_taps, float mu); - - digital_kurtotic_equalizer_cc(int num_taps, float mu); - - 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: - void set_gain(float mu) - { - if(mu < 0) - throw std::out_of_range("digital_kurtotic_equalizer::set_gain: Gain value must be >= 0"); - d_mu = mu; - } - - float gain() const { return d_mu; } - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-digital/include/digital_lms_dd_equalizer_cc.h b/gr-digital/include/digital_lms_dd_equalizer_cc.h deleted file mode 100644 index 3bb9e935ad..0000000000 --- a/gr-digital/include/digital_lms_dd_equalizer_cc.h +++ /dev/null @@ -1,125 +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. - */ - -#ifndef INCLUDED_DIGITAL_LMS_DD_EQUALIZER_CC_H -#define INCLUDED_DIGITAL_LMS_DD_EQUALIZER_CC_H - -#include <digital_api.h> -#include <gr_sync_decimator.h> -#include <filter/adaptive_fir.h> -#include <digital_constellation.h> -#include <stdexcept> - -class digital_lms_dd_equalizer_cc; -typedef boost::shared_ptr<digital_lms_dd_equalizer_cc> digital_lms_dd_equalizer_cc_sptr; - -DIGITAL_API digital_lms_dd_equalizer_cc_sptr -digital_make_lms_dd_equalizer_cc(int num_taps, - float mu, int sps, - digital_constellation_sptr cnst); - -/*! - * \brief Least-Mean-Square Decision Directed Equalizer (complex in/out) - * \ingroup eq_blk - * \ingroup digital - * - * This block implements an LMS-based decision-directed equalizer. - * It uses a set of weights, w, to correlate against the inputs, u, - * and a decisions is then made from this output. The error - * in the decision is used to update teh weight vector. - * - * y[n] = conj(w[n]) u[n] - * d[n] = decision(y[n]) - * e[n] = d[n] - y[n] - * w[n+1] = w[n] + mu u[n] conj(e[n]) - * - * Where mu is a gain value (between 0 and 1 and usualy small, - * around 0.001 - 0.01. - * - * This block uses the digital_constellation object for making - * the decision from y[n]. Create the constellation object for - * whatever constellation is to be used and pass in the object. - * In Python, you can use something like: - * self.constellation = digital.constellation_qpsk() - * To create a QPSK constellation (see the digital_constellation - * block for more details as to what constellations are available - * or how to create your own). You then pass the object to this - * block as an sptr, or using "self.constellation.base()". - * - * The theory for this algorithm can be found in Chapter 9 of: - * S. Haykin, Adaptive Filter Theory, Upper Saddle River, NJ: - * Prentice Hall, 1996. - * - */ -class DIGITAL_API digital_lms_dd_equalizer_cc : - public gr_sync_decimator, public gr::filter::kernel::adaptive_fir_ccc -{ -private: - friend DIGITAL_API digital_lms_dd_equalizer_cc_sptr - digital_make_lms_dd_equalizer_cc(int num_taps, - float mu, int sps, - digital_constellation_sptr cnst); - - float d_mu; - digital_constellation_sptr d_cnst; - - digital_lms_dd_equalizer_cc(int num_taps, - float mu, int sps, - digital_constellation_sptr 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: - float get_gain() - { - return d_mu; - } - - void set_gain(float mu) - { - if(mu < 0.0f || mu > 1.0f) { - throw std::out_of_range("digital_lms_dd_equalizer::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); -}; - -#endif |