diff options
Diffstat (limited to 'gr-digital')
36 files changed, 1640 insertions, 0 deletions
diff --git a/gr-digital/.gitignore b/gr-digital/.gitignore new file mode 100644 index 000000000..37c287f40 --- /dev/null +++ b/gr-digital/.gitignore @@ -0,0 +1,3 @@ +/Makefile +/Makefile.in +gnuradio-digital.pc diff --git a/gr-digital/Makefile.am b/gr-digital/Makefile.am new file mode 100644 index 000000000..62c40f2df --- /dev/null +++ b/gr-digital/Makefile.am @@ -0,0 +1,31 @@ +# +# Copyright 2011 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. +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = lib + +if PYTHON +SUBDIRS += swig python apps grc +endif + +pkgconfigdir = $(libdir)/pkgconfig +dist_pkgconfig_DATA = gnuradio-digital.pc diff --git a/gr-digital/README b/gr-digital/README new file mode 100644 index 000000000..af2005c97 --- /dev/null +++ b/gr-digital/README @@ -0,0 +1,4 @@ +This GNU Radio component for implementing digitial modulators and demodulators. + + +FIXME: just fixme.
\ No newline at end of file diff --git a/gr-digital/apps/.gitignore b/gr-digital/apps/.gitignore new file mode 100644 index 000000000..282522db0 --- /dev/null +++ b/gr-digital/apps/.gitignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/gr-digital/apps/Makefile.am b/gr-digital/apps/Makefile.am new file mode 100644 index 000000000..7373a0719 --- /dev/null +++ b/gr-digital/apps/Makefile.am @@ -0,0 +1,33 @@ +# +# Copyright 2011 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. +# + +include $(top_srcdir)/Makefile.common + +if PYTHON + +dist_bin_SCRIPTS = + +noinst_PYTHON = + +endif + +EXTRA_DIST += + diff --git a/gr-digital/gnuradio-digital.pc.in b/gr-digital/gnuradio-digital.pc.in new file mode 100644 index 000000000..6c0a7ccf8 --- /dev/null +++ b/gr-digital/gnuradio-digital.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: gnuradio-digital +Description: GNU Radio blocks for digital communications +Requires: gnuradio-core +Version: @LIBVER@ +Libs: -L${libdir} -lgnuradio-digital +Cflags: -I${includedir} diff --git a/gr-digital/grc/.gitignore b/gr-digital/grc/.gitignore new file mode 100644 index 000000000..3dda72986 --- /dev/null +++ b/gr-digital/grc/.gitignore @@ -0,0 +1,2 @@ +Makefile.in +Makefile diff --git a/gr-digital/grc/Makefile.am b/gr-digital/grc/Makefile.am new file mode 100644 index 000000000..4cc2e8d9d --- /dev/null +++ b/gr-digital/grc/Makefile.am @@ -0,0 +1,30 @@ +# +# Copyright 2011 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. +# + +include $(top_srcdir)/Makefile.common + +grcblocksdir = $(grc_blocksdir) + +dist_grcblocks_DATA = \ + digital_block_tree.xml \ + digital_costas_loop_cc.xml \ + digital_cma_equalizer_cc.xml \ + digital_kurtotic_equalizer_cc.xml
\ No newline at end of file diff --git a/gr-digital/grc/digital_block_tree.xml b/gr-digital/grc/digital_block_tree.xml new file mode 100644 index 000000000..ee2a0377f --- /dev/null +++ b/gr-digital/grc/digital_block_tree.xml @@ -0,0 +1,15 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Block Tree for GR Digital blocks. +################################################### + --> +<cat> + <name></name> <!-- Blank for Root Name --> + <cat> + <name>Digital</name> + <block>digital_costas_loop_cc</block> + <block>digital_cma_equalizer_cc</block> + <block>digital_kurtotic_equalizer_cc</block> + </cat> +</cat> diff --git a/gr-digital/grc/digital_cma_equalizer_cc.xml b/gr-digital/grc/digital_cma_equalizer_cc.xml new file mode 100644 index 000000000..a21d700db --- /dev/null +++ b/gr-digital/grc/digital_cma_equalizer_cc.xml @@ -0,0 +1,37 @@ +<?xml version="1.0"?> +<!-- +################################################### +## CMA Equalizer +################################################### + --> +<block> + <name>CMA Equalizer</name> + <key>digital_cma_equalizer_cc</key> + <import>from gnuradio import digital</import> + <make>digital.cma_equalizer_cc($num_taps, $modulus, $mu)</make> + <callback>set_gain($mu)</callback> + <callback>set_modulus($modulus)</callback> + <param> + <name>Num. Taps</name> + <key>num_taps</key> + <type>int</type> + </param> + <param> + <name>Modulus</name> + <key>modulus</key> + <type>real</type> + </param> + <param> + <name>Mu</name> + <key>mu</key> + <type>real</type> + </param> + <sink> + <name>in</name> + <type>complex</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + </source> +</block> diff --git a/gr-digital/grc/digital_costas_loop_cc.xml b/gr-digital/grc/digital_costas_loop_cc.xml new file mode 100644 index 000000000..087535b87 --- /dev/null +++ b/gr-digital/grc/digital_costas_loop_cc.xml @@ -0,0 +1,44 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Costas Loop +################################################### + --> +<block> + <name>Costas Loop</name> + <key>digital_costas_loop_cc</key> + <import>from gnuradio import digital</import> + <make>digital.costas_loop_cc($eta, $w, $order)</make> + <callback>set_damping_factor($eta)</callback> + <callback>set_natural_freq($w)</callback> + <param> + <name>Damping Factor</name> + <key>eta</key> + <type>real</type> + </param> + <param> + <name>Natural Frequency</name> + <key>w</key> + <type>real</type> + </param> + <param> + <name>Order</name> + <key>order</key> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>complex</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + </source> + + <!-- Optional Outputs --> + <source> + <name>frequency</name> + <type>float</type> + <optional>1</optional> + </source> +</block> diff --git a/gr-digital/grc/digital_kurtotic_equalizer_cc.xml b/gr-digital/grc/digital_kurtotic_equalizer_cc.xml new file mode 100644 index 000000000..8c4a2012d --- /dev/null +++ b/gr-digital/grc/digital_kurtotic_equalizer_cc.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Kurtotic Equalizer +################################################### + --> +<block> + <name>Kurtotic Equalizer</name> + <key>digital_kurtotic_equalizer_cc</key> + <import>from gnuradio import digital</import> + <make>digital.kurtotic_equalizer_cc($num_taps, $mu)</make> + <callback>set_gain($mu)</callback> + <param> + <name>Num. Taps</name> + <key>num_taps</key> + <type>int</type> + </param> + <param> + <name>Mu</name> + <key>mu</key> + <type>real</type> + </param> + <sink> + <name>in</name> + <type>complex</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + </source> +</block> diff --git a/gr-digital/lib/.gitignore b/gr-digital/lib/.gitignore new file mode 100644 index 000000000..1b6114c39 --- /dev/null +++ b/gr-digital/lib/.gitignore @@ -0,0 +1,4 @@ +/.libs +/.deps +/Makefile +/Makefile.in diff --git a/gr-digital/lib/Makefile.am b/gr-digital/lib/Makefile.am new file mode 100644 index 000000000..7113f94d2 --- /dev/null +++ b/gr-digital/lib/Makefile.am @@ -0,0 +1,42 @@ +# +# Copyright 2011 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. +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES) + +# These headers get installed in ${prefix}/include/gnuradio +grinclude_HEADERS = \ + digital_costas_loop_cc.h \ + digital_cma_equalizer_cc.h \ + digital_kurtotic_equalizer_cc.h + +lib_LTLIBRARIES = libgnuradio-digital.la + +libgnuradio_digital_la_SOURCES = \ + digital_costas_loop_cc.cc \ + digital_cma_equalizer_cc.cc \ + digital_kurtotic_equalizer_cc.cc + +libgnuradio_digital_la_LIBADD = \ + $(GNURADIO_CORE_LA) + +libgnuradio_digital_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) diff --git a/gr-digital/lib/digital_cma_equalizer_cc.cc b/gr-digital/lib/digital_cma_equalizer_cc.cc new file mode 100644 index 000000000..89f56c16f --- /dev/null +++ b/gr-digital/lib/digital_cma_equalizer_cc.cc @@ -0,0 +1,43 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 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_cma_equalizer_cc.h> + +digital_cma_equalizer_cc_sptr +digital_make_cma_equalizer_cc(int num_taps, float modulus, float mu) +{ + return gnuradio::get_initial_sptr(new digital_cma_equalizer_cc(num_taps, modulus, mu)); +} + +digital_cma_equalizer_cc::digital_cma_equalizer_cc(int num_taps, float modulus, float mu) + : gr_adaptive_fir_ccc("cma_equalizer_cc", 1, std::vector<gr_complex>(num_taps)) +{ + set_modulus(modulus); + set_gain(mu); + if (num_taps > 0) + d_taps[0] = 1.0; +} + diff --git a/gr-digital/lib/digital_cma_equalizer_cc.h b/gr-digital/lib/digital_cma_equalizer_cc.h new file mode 100644 index 000000000..54cba319c --- /dev/null +++ b/gr-digital/lib/digital_cma_equalizer_cc.h @@ -0,0 +1,89 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 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_CMA_EQUALIZER_CC_H +#define INCLUDED_DIGITAL_CMA_EQUALIZER_CC_H + +#include <gr_adaptive_fir_ccc.h> +#include <gr_math.h> +#include <iostream> + +class digital_cma_equalizer_cc; +typedef boost::shared_ptr<digital_cma_equalizer_cc> digital_cma_equalizer_cc_sptr; + +digital_cma_equalizer_cc_sptr +digital_make_cma_equalizer_cc(int num_taps, float modulus, float mu); + +/*! + * \brief Implements constant modulus adaptive filter on complex stream + * \ingroup eq_blk + * + * The error value and tap update equations (for p=2) can be found in: + * + * D. Godard, "Self-Recovering Equalization and Carrier Tracking in + * Two-Dimensional Data Communication Systems," IEEE Transactions on + * Communications, Vol. 28, No. 11, pp. 1867 - 1875, 1980, + */ +class digital_cma_equalizer_cc : public gr_adaptive_fir_ccc +{ +private: + float d_modulus; + float d_mu; + + friend digital_cma_equalizer_cc_sptr digital_make_cma_equalizer_cc(int num_taps, + float modulus, + float mu); + digital_cma_equalizer_cc(int num_taps, float modulus, float mu); + +protected: + + virtual gr_complex error(const gr_complex &out) + { + gr_complex error = out*(norm(out) - d_modulus); + float re = gr_clip(error.real(), 1.0); + float im = gr_clip(error.imag(), 1.0); + return gr_complex(re, im); + } + + virtual void update_tap(gr_complex &tap, const gr_complex &in) + { + // Hn+1 = Hn - mu*conj(Xn)*zn*(|zn|^2 - 1) + tap -= d_mu*conj(in)*d_error; + } + +public: + void set_gain(float mu) + { + if(mu < 0) + throw std::out_of_range("digital_cma_equalizer::set_gain: Gain value must be >= 0"); + d_mu = mu; + } + + void set_modulus(float mod) + { + if(mod < 0) + throw std::out_of_range("digital_cma_equalizer::set_modulus: Modulus value must be >= 0"); + d_modulus = mod; + } +}; + +#endif diff --git a/gr-digital/lib/digital_costas_loop_cc.cc b/gr-digital/lib/digital_costas_loop_cc.cc new file mode 100644 index 000000000..b41b08cba --- /dev/null +++ b/gr-digital/lib/digital_costas_loop_cc.cc @@ -0,0 +1,195 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2010,2011 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_costas_loop_cc.h> +#include <gr_io_signature.h> +#include <gr_expj.h> +#include <gr_sincos.h> +#include <math.h> + +#define M_TWOPI (2*M_PI) + +digital_costas_loop_cc_sptr +digital_make_costas_loop_cc (float damping, float nat_freq, + int order + ) throw (std::invalid_argument) +{ + return gnuradio::get_initial_sptr(new digital_costas_loop_cc (damping, + nat_freq, + order)); +} + +digital_costas_loop_cc::digital_costas_loop_cc (float damping, float nat_freq, + int order + ) throw (std::invalid_argument) + : gr_sync_block ("costas_loop_cc", + gr_make_io_signature (1, 1, sizeof (gr_complex)), + gr_make_io_signature2 (1, 2, sizeof (gr_complex), sizeof(float))), + + d_max_freq(1.0), d_min_freq(-1.0), d_phase(0), d_freq(0.0), + d_nat_freq(nat_freq), d_damping(damping), + d_order(order), d_phase_detector(NULL) +{ + // initialize gains from the natural freq and damping factors + update_gains(); + + switch(d_order) { + case 2: + d_phase_detector = &digital_costas_loop_cc::phase_detector_2; + break; + + case 4: + d_phase_detector = &digital_costas_loop_cc::phase_detector_4; + break; + + case 8: + d_phase_detector = &digital_costas_loop_cc::phase_detector_8; + break; + + default: + throw std::invalid_argument("order must be 2, 4, or 8"); + break; + } +} + +float +digital_costas_loop_cc::phase_detector_8(gr_complex sample) const +{ + float K = sqrt(2.0) - 1; + if(abs(sample.real()) >= abs(sample.imag())) { + return ((sample.real()>0 ? 1.0 : -1.0) * sample.imag() - + (sample.imag()>0 ? 1.0 : -1.0) * sample.real() * K); + } + else { + return ((sample.real()>0 ? 1.0 : -1.0) * sample.imag() * K - + (sample.imag()>0 ? 1.0 : -1.0) * sample.real()); + } +} + +float +digital_costas_loop_cc::phase_detector_4(gr_complex sample) const +{ + + return ((sample.real()>0 ? 1.0 : -1.0) * sample.imag() - + (sample.imag()>0 ? 1.0 : -1.0) * sample.real()); +} + +float +digital_costas_loop_cc::phase_detector_2(gr_complex sample) const +{ + return (sample.real()*sample.imag()); +} + +void +digital_costas_loop_cc::set_natural_freq(float w) +{ + d_nat_freq = w; + update_gains(); +} + +void +digital_costas_loop_cc::set_damping_factor(float eta) +{ + d_damping = eta; + update_gains(); +} + +void +digital_costas_loop_cc::update_gains() +{ + d_beta = d_nat_freq*d_nat_freq; + d_alpha = 2*d_damping*d_nat_freq; +} + +int +digital_costas_loop_cc::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const gr_complex *iptr = (gr_complex *) input_items[0]; + gr_complex *optr = (gr_complex *) output_items[0]; + float *foptr = (float *) output_items[1]; + + bool write_foptr = output_items.size() >= 2; + + float error; + gr_complex nco_out; + + if (write_foptr) { + + for (int i = 0; i < noutput_items; i++){ + nco_out = gr_expj(-d_phase); + optr[i] = iptr[i] * nco_out; + + error = (*this.*d_phase_detector)(optr[i]); + if (error > 1) + error = 1; + else if (error < -1) + error = -1; + + d_freq = d_freq + d_beta * error; + d_phase = d_phase + d_freq + d_alpha * error; + + while(d_phase>M_TWOPI) + d_phase -= M_TWOPI; + while(d_phase<-M_TWOPI) + d_phase += M_TWOPI; + + if (d_freq > d_max_freq) + d_freq = d_min_freq; + else if (d_freq < d_min_freq) + d_freq = d_max_freq; + + foptr[i] = d_freq; + } + } else { + for (int i = 0; i < noutput_items; i++){ + nco_out = gr_expj(-d_phase); + optr[i] = iptr[i] * nco_out; + + error = (*this.*d_phase_detector)(optr[i]); + if (error > 1) + error = 1; + else if (error < -1) + error = -1; + + d_freq = d_freq + d_beta * error; + d_phase = d_phase + d_freq + d_alpha * error; + + while(d_phase>M_TWOPI) + d_phase -= M_TWOPI; + while(d_phase<-M_TWOPI) + d_phase += M_TWOPI; + + if (d_freq > d_max_freq) + d_freq = d_max_freq; + else if (d_freq < d_min_freq) + d_freq = d_min_freq; + + } + } + return noutput_items; +} diff --git a/gr-digital/lib/digital_costas_loop_cc.h b/gr-digital/lib/digital_costas_loop_cc.h new file mode 100644 index 000000000..9c112d328 --- /dev/null +++ b/gr-digital/lib/digital_costas_loop_cc.h @@ -0,0 +1,150 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2011 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_COSTAS_LOOP_CC_H +#define INCLUDED_DIGITAL_COSTAS_LOOP_CC_H + +#include <gr_sync_block.h> +#include <stdexcept> +#include <fstream> + + +/*! \brief A Costas loop carrier recovery module. + * \ingroup sync_blk + * + * The Costas loop locks to the center frequency of a signal and + * downconverts it to baseband. The second (order=2) order loop is + * used for BPSK where the real part of the output signal is the + * baseband BPSK signal and the imaginary part is the error + * signal. When order=4, it can be used for quadrature modulations + * where both I and Q (real and imaginary) are outputted. + * + * More details can be found online: + * + * J. Feigin, "Practical Costas loop design: Designing a simple and inexpensive + * BPSK Costas loop carrier recovery circuit," RF signal processing, pp. 20-36, + * 2002. + * + * http://rfdesign.com/images/archive/0102Feigin20.pdf + * + * \param alpha the loop gain used for phase adjustment + * \param beta the loop gain for frequency adjustments + * \param max_freq the maximum frequency deviation (radians/sample) the loop can handle + * \param min_freq the minimum frequency deviation (radians/sample) the loop can handle + * \param order the loop order, either 2 or 4 + */ +class digital_costas_loop_cc; +typedef boost::shared_ptr<digital_costas_loop_cc> digital_costas_loop_cc_sptr; + + +digital_costas_loop_cc_sptr +digital_make_costas_loop_cc (float damping, float nat_freq, + int order + ) throw (std::invalid_argument); + + +/*! + * \brief Carrier tracking PLL for QPSK + * \ingroup sync_blk + * input: complex; output: complex + * <br>The Costas loop can have two output streams: + * stream 1 is the baseband I and Q; + * stream 2 is the normalized frequency of the loop + * + * \p order must be 2 or 4. + */ +class digital_costas_loop_cc : public gr_sync_block +{ + friend digital_costas_loop_cc_sptr + digital_make_costas_loop_cc (float damping, float nat_freq, + int order + ) throw (std::invalid_argument); + + float d_alpha, d_beta, d_max_freq, d_min_freq, d_phase, d_freq; + float d_nat_freq, d_damping; + int d_order; + + digital_costas_loop_cc (float damping, float nat_freq, + int order + ) throw (std::invalid_argument); + + + /*! \brief update the system gains from omega and eta + * + * This function updates the system gains based on the natural + * frequency (omega) and damping factor (eta) of the system. + * These two factors can be set separately through their own + * set functions. + * + * These equations are summarized nicely in this paper from Berkeley: + * http://www.complextoreal.com/chapters/pll.pdf + */ + void update_gains(); + + /*! \brief the phase detector circuit for 8th-order PSK loops + * \param sample complex sample + * \return the phase error + */ + float phase_detector_8(gr_complex sample) const; // for 8PSK + + /*! \brief the phase detector circuit for fourth-order loops + * \param sample complex sample + * \return the phase error + */ + float phase_detector_4(gr_complex sample) const; // for QPSK + + /*! \brief the phase detector circuit for second-order loops + * \param sample a complex sample + * \return the phase error + */ + float phase_detector_2(gr_complex sample) const; // for BPSK + + + float (digital_costas_loop_cc::*d_phase_detector)(gr_complex sample) const; + +public: + + void set_natural_freq(float w); + void set_damping_factor(float eta); + + /*! \brief get the first order gain + * + */ + float alpha() const { return d_alpha; } + + /*! \brief get the second order gain + * + */ + float beta() const { return d_beta; } + + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + /*! \brief returns the current NCO frequency in radians/sample + * + */ + float freq() const { return d_freq; } +}; + +#endif diff --git a/gr-digital/lib/digital_kurtotic_equalizer_cc.cc b/gr-digital/lib/digital_kurtotic_equalizer_cc.cc new file mode 100644 index 000000000..c95b56021 --- /dev/null +++ b/gr-digital/lib/digital_kurtotic_equalizer_cc.cc @@ -0,0 +1,51 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 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> + +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_adaptive_fir_ccc("kurtotic_equalizer_cc", 1, std::vector<gr_complex>(num_taps)) +{ + set_gain(mu); + if (num_taps > 0) + d_taps[0] = 1.0; + + 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); +} + diff --git a/gr-digital/lib/digital_kurtotic_equalizer_cc.h b/gr-digital/lib/digital_kurtotic_equalizer_cc.h new file mode 100644 index 000000000..e01cbd6e6 --- /dev/null +++ b/gr-digital/lib/digital_kurtotic_equalizer_cc.h @@ -0,0 +1,111 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 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 <gr_adaptive_fir_ccc.h> +#include <gr_math.h> +#include <iostream> + +class digital_kurtotic_equalizer_cc; +typedef boost::shared_ptr<digital_kurtotic_equalizer_cc> digital_kurtotic_equalizer_cc_sptr; + +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 + * + * 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_kurtotic_equalizer_cc : public gr_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_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); + + //std::cout << "out: " << out << " p: " << d_p << " q: " << d_q; + //std::cout << " m: " << d_m << " u: " << d_u << std::endl; + //std::cout << "error: " << F << std::endl; + + 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; + } +}; + +#endif diff --git a/gr-digital/python/.gitignore b/gr-digital/python/.gitignore new file mode 100644 index 000000000..604b402c5 --- /dev/null +++ b/gr-digital/python/.gitignore @@ -0,0 +1,3 @@ +/Makefile +/Makefile.in +/run_tests diff --git a/gr-digital/python/Makefile.am b/gr-digital/python/Makefile.am new file mode 100644 index 000000000..9db82b608 --- /dev/null +++ b/gr-digital/python/Makefile.am @@ -0,0 +1,39 @@ +# +# Copyright 2011 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. +# + +include $(top_srcdir)/Makefile.common + +TESTS = +EXTRA_DIST += run_tests.in + +if PYTHON +TESTS += run_tests + +digitaldir = $(grpythondir)/digital + +noinst_PYTHON = \ + qa_digital.py \ + qa_costas_loop_cc.py + +digital_PYTHON = \ + __init__.py + +endif diff --git a/gr-digital/python/__init__.py b/gr-digital/python/__init__.py new file mode 100644 index 000000000..c1aed10f9 --- /dev/null +++ b/gr-digital/python/__init__.py @@ -0,0 +1,24 @@ +# +# Copyright 2006 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. +# + +# The presence of this file turns this directory into a Python package + +from digital_swig import * diff --git a/gr-digital/python/qa_costas_loop_cc.py b/gr-digital/python/qa_costas_loop_cc.py new file mode 100644 index 000000000..464534723 --- /dev/null +++ b/gr-digital/python/qa_costas_loop_cc.py @@ -0,0 +1,169 @@ +#!/usr/bin/env python +# +# Copyright 2011 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. +# + +from gnuradio import gr, blks2, gr_unittest +import digital_swig +import random, cmath + +class test_digital(gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test01 (self): + # test basic functionality by setting all gains to 0 + alpha = beta = max_freq = min_freq = 0.0 + order = 2 + self.test = digital_swig.costas_loop_cc(alpha, beta, + max_freq, min_freq, + order) + data = 100*[complex(1,0),] + self.src = gr.vector_source_c(data, False) + self.snk = gr.vector_sink_c() + + self.tb.connect(self.src, self.test, self.snk) + self.tb.run() + + expected_result = data + dst_data = self.snk.data() + self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5) + + def test02 (self): + # Make sure it doesn't diverge given perfect data + alpha = 0.1 + beta = 0.25*alpha*alpha + max_freq = 0.25 + min_freq = -0.25 + order = 2 + self.test = digital_swig.costas_loop_cc(alpha, beta, + max_freq, min_freq, + order) + data = [complex(2*random.randint(0,1)-1, 0) for i in xrange(100)] + self.src = gr.vector_source_c(data, False) + self.snk = gr.vector_sink_c() + + self.tb.connect(self.src, self.test, self.snk) + self.tb.run() + + expected_result = data + dst_data = self.snk.data() + + self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5) + + def test03 (self): + # BPSK Convergence test with static rotation + alpha = 0.25 + beta = 0.25*alpha*alpha + max_freq = 0.25 + min_freq = -0.25 + order = 2 + self.test = digital_swig.costas_loop_cc(alpha, beta, + max_freq, min_freq, + order) + rot = cmath.exp(0.2j) # some small rotation + data = [complex(2*random.randint(0,1)-1, 0) for i in xrange(100)] + + N = 40 # settling time + expected_result = data[N:] + data = [rot*d for d in data] + + self.src = gr.vector_source_c(data, False) + self.snk = gr.vector_sink_c() + + self.tb.connect(self.src, self.test, self.snk) + self.tb.run() + + dst_data = self.snk.data()[N:] + + # generously compare results; the loop will converge near to, but + # not exactly on, the target data + self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 2) + + def test04 (self): + # QPSK Convergence test with static rotation + alpha = 0.25 + beta = 0.25*alpha*alpha + max_freq = 0.25 + min_freq = -0.25 + order = 4 + self.test = digital_swig.costas_loop_cc(alpha, beta, + max_freq, min_freq, + order) + rot = cmath.exp(0.2j) # some small rotation + data = [complex(2*random.randint(0,1)-1, 2*random.randint(0,1)-1) + for i in xrange(100)] + + N = 40 # settling time + expected_result = data[N:] + data = [rot*d for d in data] + + self.src = gr.vector_source_c(data, False) + self.snk = gr.vector_sink_c() + + self.tb.connect(self.src, self.test, self.snk) + self.tb.run() + + dst_data = self.snk.data()[N:] + + # generously compare results; the loop will converge near to, but + # not exactly on, the target data + self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 2) + + def test05 (self): + # 8PSK Convergence test with static rotation + alpha = 0.25 + beta = 0.25*alpha*alpha + max_freq = 0.25 + min_freq = -0.25 + order = 8 + self.test = digital_swig.costas_loop_cc(alpha, beta, + max_freq, min_freq, + order) + rot = cmath.exp(cmath.pi/16.0j) # some small rotation + const = blks2.psk.make_constellation(order) + data = [random.randint(0,7) for i in xrange(100)] + data = [rot*const[d] for d in data] + + N = 40 # settling time + expected_result = data[N:] + data = [rot*d for d in data] + + self.src = gr.vector_source_c(data, False) + self.snk = gr.vector_sink_c() + + self.tb.connect(self.src, self.test, self.snk) + self.tb.run() + + dst_data = self.snk.data()[N:] + + print expected_result + print dst_data + + # generously compare results; the loop will converge near to, but + # not exactly on, the target data + self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 2) + +if __name__ == '__main__': + gr_unittest.run(test_digital, "test_digital.xml") diff --git a/gr-digital/python/qa_digital.py b/gr-digital/python/qa_digital.py new file mode 100755 index 000000000..97e35da56 --- /dev/null +++ b/gr-digital/python/qa_digital.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# +# Copyright 2011 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. +# + +from gnuradio import gr, gr_unittest +import digital_swig + +class test_digital(gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + +if __name__ == '__main__': + gr_unittest.run(test_digital, "test_digital.xml") diff --git a/gr-digital/python/run_tests.in b/gr-digital/python/run_tests.in new file mode 100644 index 000000000..b39e7e847 --- /dev/null +++ b/gr-digital/python/run_tests.in @@ -0,0 +1,10 @@ +#!/bin/sh + +# 1st parameter is absolute path to component source directory +# 2nd parameter is absolute path to component build directory +# 3rd parameter is path to Python QA directory + +@top_builddir@/run_tests.sh \ + @abs_top_srcdir@/gr-digital \ + @abs_top_builddir@/gr-digital \ + @srcdir@ diff --git a/gr-digital/swig/.gitignore b/gr-digital/swig/.gitignore new file mode 100644 index 000000000..7e864f43f --- /dev/null +++ b/gr-digital/swig/.gitignore @@ -0,0 +1,9 @@ +/Makefile +/Makefile.in +/pager_swig.py +/pager_swig.cc +/*.pyc +/run_tests +/run_guile_tests +/guile +/python diff --git a/gr-digital/swig/Makefile.am b/gr-digital/swig/Makefile.am new file mode 100644 index 000000000..d06da3a26 --- /dev/null +++ b/gr-digital/swig/Makefile.am @@ -0,0 +1,66 @@ +# +# Copyright 2011 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. +# + +include $(top_srcdir)/Makefile.common +include $(top_srcdir)/Makefile.swig + +TESTS = +EXTRA_DIST += $(nobase_guile_DATA) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/gr-digital/lib \ + $(STD_DEFINES_AND_INCLUDES) \ + $(PYTHON_CPPFLAGS) \ + $(WITH_INCLUDES) + +if GUILE +nobase_guile_DATA = \ + gnuradio/digital.scm +endif + +noinst_GUILE = digital.test + + +############################## +# SWIG interface and library +TOP_SWIG_IFILES = \ + digital_swig.i + +# Install so that they end up available as: +# import gnuradio.digital +# This ends up at: +# ${prefix}/lib/python${python_version}/site-packages/gnuradio/digital +digital_swig_pythondir_category = \ + gnuradio/digital + +# additional libraries for linking with the SWIG-generated library +digital_swig_la_swig_libadd = \ + $(abs_top_builddir)/gr-digital/lib/libgnuradio-digital.la + +# additional SWIG files to be installed +digital_swig_swiginclude_headers = \ + digital_costas_loop_cc.i \ + digital_cma_equalizer_cc.i \ + digital_kurtotic_equalizer_cc.i + +if GUILE +TESTS += run_guile_tests +endif
\ No newline at end of file diff --git a/gr-digital/swig/Makefile.swig.gen b/gr-digital/swig/Makefile.swig.gen new file mode 100644 index 000000000..bd9aabcea --- /dev/null +++ b/gr-digital/swig/Makefile.swig.gen @@ -0,0 +1,145 @@ +# -*- Makefile -*- +# +# Copyright 2009 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. +# + +# Makefile.swig.gen for digital_swig.i + +## Default install locations for these files: +## +## Default location for the Python directory is: +## ${prefix}/lib/python${python_version}/site-packages/[category]/digital_swig +## Default location for the Python exec directory is: +## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/digital_swig +## +## The following can be overloaded to change the install location, but +## this has to be done in the including Makefile.am -before- +## Makefile.swig is included. + +digital_swig_pythondir_category ?= gnuradio/digital_swig +digital_swig_pylibdir_category ?= $(digital_swig_pythondir_category) +digital_swig_pythondir = $(pythondir)/$(digital_swig_pythondir_category) +digital_swig_pylibdir = $(pyexecdir)/$(digital_swig_pylibdir_category) + +# The .so libraries for the guile modules get installed whereever guile +# is installed, usually /usr/lib/guile/gnuradio/ +# FIXME: determince whether these should be installed with gnuradio. +digital_swig_scmlibdir = $(libdir) + +# The scm files for the guile modules get installed where ever guile +# is installed, usually /usr/share/guile/site/digital_swig +# FIXME: determince whether these should be installed with gnuradio. +digital_swig_scmdir = $(guiledir) + +## SWIG headers are always installed into the same directory. + +digital_swig_swigincludedir = $(swigincludedir) + +## This is a template file for a "generated" Makefile addition (in +## this case, "Makefile.swig.gen"). By including the top-level +## Makefile.swig, this file will be used to generate the SWIG +## dependencies. Assign the variable TOP_SWIG_FILES to be the list of +## SWIG .i files to generated wrappings for; there can be more than 1 +## so long as the names are unique (no sorting is done on the +## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i +## file will generate .cc, .py, and possibly .h files -- meaning that +## all of these files will have the same base name (that provided for +## the SWIG .i file). +## +## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the +## right thing. For more info, see < +## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > + +## Other cleaned files: dependency files generated by SWIG or this Makefile + +MOSTLYCLEANFILES += $(DEPDIR)/*.S* + +## Various SWIG variables. These can be overloaded in the including +## Makefile.am by setting the variable value there, then including +## Makefile.swig . + +digital_swig_swiginclude_HEADERS = \ + digital_swig.i \ + $(digital_swig_swiginclude_headers) + +if PYTHON +digital_swig_pylib_LTLIBRARIES = \ + _digital_swig.la + +_digital_swig_la_SOURCES = \ + python/digital_swig.cc \ + $(digital_swig_la_swig_sources) + +digital_swig_python_PYTHON = \ + digital_swig.py \ + $(digital_swig_python) + +_digital_swig_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(digital_swig_la_swig_libadd) + +_digital_swig_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(digital_swig_la_swig_ldflags) + +_digital_swig_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(digital_swig_la_swig_cxxflags) + +python/digital_swig.cc: digital_swig.py +digital_swig.py: digital_swig.i + +# Include the python dependencies for this file +-include python/digital_swig.d + +endif # end of if python + +if GUILE + +digital_swig_scmlib_LTLIBRARIES = \ + libguile-gnuradio-digital_swig.la +libguile_gnuradio_digital_swig_la_SOURCES = \ + guile/digital_swig.cc \ + $(digital_swig_la_swig_sources) +nobase_digital_swig_scm_DATA = \ + gnuradio/digital_swig.scm \ + gnuradio/digital_swig-primitive.scm +libguile_gnuradio_digital_swig_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(digital_swig_la_swig_libadd) +libguile_gnuradio_digital_swig_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(digital_swig_la_swig_ldflags) +libguile_gnuradio_digital_swig_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(digital_swig_la_swig_cxxflags) + +guile/digital_swig.cc: gnuradio/digital_swig.scm +gnuradio/digital_swig.scm: digital_swig.i +gnuradio/digital_swig-primitive.scm: gnuradio/digital_swig.scm + +# Include the guile dependencies for this file +-include guile/digital_swig.d + +endif # end of GUILE + + diff --git a/gr-digital/swig/digital_cma_equalizer_cc.i b/gr-digital/swig/digital_cma_equalizer_cc.i new file mode 100644 index 000000000..346b744db --- /dev/null +++ b/gr-digital/swig/digital_cma_equalizer_cc.i @@ -0,0 +1,42 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 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. + */ + +GR_SWIG_BLOCK_MAGIC(digital,cma_equalizer_cc) + +// retrieve info on the base class, without generating wrappers since +// the base class has a pure virual method. +%import "gr_adaptive_fir_ccc.i" + +digital_cma_equalizer_cc_sptr +digital_make_cma_equalizer_cc(int num_taps, + float modulus, + float mu); + +class digital_cma_equalizer_cc : public gr_adaptive_fir_ccc +{ +private: + digital_cma_equalizer_cc(int num_taps, float modulus, float mu); + +public: + void set_gain(float mu); + void set_modulus(float mod); +}; diff --git a/gr-digital/swig/digital_costas_loop_cc.i b/gr-digital/swig/digital_costas_loop_cc.i new file mode 100644 index 000000000..6d3d009f8 --- /dev/null +++ b/gr-digital/swig/digital_costas_loop_cc.i @@ -0,0 +1,44 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,2011 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. + */ + +GR_SWIG_BLOCK_MAGIC(digital,costas_loop_cc); + +digital_costas_loop_cc_sptr +digital_make_costas_loop_cc (float damping, float nat_freq, + int order + ) throw (std::invalid_argument); + + +class digital_costas_loop_cc : public gr_sync_block +{ + private: + digital_costas_loop_cc (float damping, float nat_freq, + int order); + + public: + float alpha(); + float beta(); + float freq(); + + void set_natural_freq(float w); + void set_damping_factor(float eta); +}; diff --git a/gr-digital/swig/digital_kurtotic_equalizer_cc.i b/gr-digital/swig/digital_kurtotic_equalizer_cc.i new file mode 100644 index 000000000..67a9dc6fd --- /dev/null +++ b/gr-digital/swig/digital_kurtotic_equalizer_cc.i @@ -0,0 +1,40 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 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. + */ + +GR_SWIG_BLOCK_MAGIC(digital,kurtotic_equalizer_cc) + +// retrieve info on the base class, without generating wrappers since +// the base class has a pure virual method. +%import "gr_adaptive_fir_ccc.i" + +digital_kurtotic_equalizer_cc_sptr +digital_make_kurtotic_equalizer_cc(int num_taps, + float mu); + +class digital_kurtotic_equalizer_cc : public gr_adaptive_fir_ccc +{ +private: + digital_kurtotic_equalizer_cc(int num_taps, float mu); + +public: + void set_gain(float mu); +}; diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i new file mode 100644 index 000000000..c2416c6c2 --- /dev/null +++ b/gr-digital/swig/digital_swig.i @@ -0,0 +1,42 @@ +/* + * Copyright 2011 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. + */ + +%include "gnuradio.i" + +%{ +#include "digital_costas_loop_cc.h" +#include "digital_cma_equalizer_cc.h" +#include "digital_kurtotic_equalizer_cc.h" +%} + +%include "digital_costas_loop_cc.i" +%include "digital_cma_equalizer_cc.i" +%include "digital_kurtotic_equalizer_cc.i" + +#if SWIGGUILE +%scheme %{ +(load-extension-global "libguile-gnuradio-digital_swig" "scm_init_gnuradio_digital_swig_module") +%} + +%goops %{ +(use-modules (gnuradio gnuradio_core_runtime)) +%} +#endif diff --git a/gr-digital/swig/gnuradio/.gitignore b/gr-digital/swig/gnuradio/.gitignore new file mode 100644 index 000000000..c264c571a --- /dev/null +++ b/gr-digital/swig/gnuradio/.gitignore @@ -0,0 +1,2 @@ +digital_swig-primitive.scm +digital_swig.scm diff --git a/gr-digital/swig/gnuradio/digital.scm b/gr-digital/swig/gnuradio/digital.scm new file mode 100644 index 000000000..834bc8d6d --- /dev/null +++ b/gr-digital/swig/gnuradio/digital.scm @@ -0,0 +1,28 @@ +;;; +;;; Copyright 2011 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 this program. If not, see <http://www.gnu.org/licenses/>. +;;; + +;;; Module that just re-exports the digital_swig module + +(define-module (gnuradio digital) + #:use-module (gnuradio export-safely) + #:use-module (gnuradio digital_swig) + #:duplicates (merge-generics replace check)) + +(re-export-all '(gnuradio digital_swig)) + diff --git a/gr-digital/swig/run_guile_tests.in b/gr-digital/swig/run_guile_tests.in new file mode 100644 index 000000000..5d08b0dd5 --- /dev/null +++ b/gr-digital/swig/run_guile_tests.in @@ -0,0 +1,14 @@ +#!/bin/sh + +. @top_builddir@/setup_guile_test_env + +# 1st argument is absolute path to hand coded guile source directory +# 2nd argument is absolute path to component C++ shared library build directory +# 3nd argument is absolute path to component SWIG build directory + +add_local_paths \ + @srcdir@ \ + @abs_builddir@ \ + @abs_builddir@ + +@GUILE@ -e main -c '(use-modules (gnuradio test-suite guile-test))' -t @srcdir@ |