commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] gnuradio-core/src lib/filter/Makefile.am lib/fi...


From: Johnathan Corgan
Subject: [Commit-gnuradio] gnuradio-core/src lib/filter/Makefile.am lib/fi...
Date: Tue, 04 Jul 2006 07:20:53 +0000

CVSROOT:        /sources/gnuradio
Module name:    gnuradio-core
Changes by:     Johnathan Corgan <jcorgan>      06/07/04 07:20:53

Modified files:
        src/lib/filter : Makefile.am filter.i 
        src/python/gnuradio/blksimpl: fm_demod.py 
Added files:
        src/lib/filter : gr_adaptive_fir_ccf.cc gr_adaptive_fir_ccf.h 
                         gr_adaptive_fir_ccf.i gr_cma_equalizer_cc.cc 
                         gr_cma_equalizer_cc.h gr_cma_equalizer_cc.i 
        src/python/gnuradio/gr: qa_cma_equalizer.py 

Log message:
        Work in progress adaptive FIR class and constant modulus filter.
        
        The CMA is a skeleton--still need to fill in the error, update_tap
        methods.  They currently indicate no error and the taps are never
        changed. The default taps start with 1.0 and the remainder are zeros
        so the output is identical to the input.
        
        The adaptive FIR class is complete but unoptimized.  It implements a
        generic dot product for the FIR output calculation.  It presently is 
only
        implemented for _ccf signature but it would be possibly to make it into
        a template.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/filter/Makefile.am?cvsroot=gnuradio&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/filter/filter.i?cvsroot=gnuradio&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.cc?cvsroot=gnuradio&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h?cvsroot=gnuradio&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.i?cvsroot=gnuradio&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.cc?cvsroot=gnuradio&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.h?cvsroot=gnuradio&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.i?cvsroot=gnuradio&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/python/gnuradio/blksimpl/fm_demod.py?cvsroot=gnuradio&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/python/gnuradio/gr/qa_cma_equalizer.py?cvsroot=gnuradio&rev=1.1

Patches:
Index: lib/filter/Makefile.am
===================================================================
RCS file: /sources/gnuradio/gnuradio-core/src/lib/filter/Makefile.am,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- lib/filter/Makefile.am      23 Jun 2006 21:11:33 -0000      1.33
+++ lib/filter/Makefile.am      4 Jul 2006 07:20:52 -0000       1.34
@@ -166,6 +166,8 @@
 # work around automake deficiency
 libfilter_la_common_SOURCES =          \
        $(GENERATED_CC)                 \
+       gr_adaptive_fir_ccf.cc          \
+       gr_cma_equalizer_cc.cc          \
        gr_fft_filter_ccc.cc            \
        gr_fft_filter_fff.cc            \
        gr_goertzel_fc.cc               \
@@ -222,6 +224,8 @@
        ccomplex_dotprod_x86.h          \
        float_dotprod_generic.h         \
        float_dotprod_x86.h             \
+       gr_adaptive_fir_ccf.h           \
+       gr_cma_equalizer_cc.h           \
        gr_cpu.h                        \
        gr_fft_filter_ccc.h             \
        gr_fft_filter_fff.h             \
@@ -284,6 +288,8 @@
 swiginclude_HEADERS =                  \
        filter.i                        \
        filter_generated.i              \
+       gr_adaptive_fir_ccf.i           \
+       gr_cma_equalizer_cc.i           \
        gr_fft_filter_ccc.i             \
        gr_fft_filter_fff.i             \
        gr_filter_delay_fc.i            \

Index: lib/filter/filter.i
===================================================================
RCS file: /sources/gnuradio/gnuradio-core/src/lib/filter/filter.i,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- lib/filter/filter.i 23 Jun 2006 21:11:33 -0000      1.9
+++ lib/filter/filter.i 4 Jul 2006 07:20:52 -0000       1.10
@@ -29,6 +29,7 @@
 #include <gr_fft_filter_ccc.h>
 #include <gr_fft_filter_fff.h>
 #include <gr_goertzel_fc.h>
+#include <gr_cma_equalizer_cc.h>
 %}
 
 %include "gr_iir_filter_ffd.i"
@@ -39,5 +40,6 @@
 %include "gr_fft_filter_ccc.i"
 %include "gr_fft_filter_fff.i"
 %include "gr_goertzel_fc.i"
+%include "gr_cma_equalizer_cc.i"
 
 %include "filter_generated.i"

Index: python/gnuradio/blksimpl/fm_demod.py
===================================================================
RCS file: 
/sources/gnuradio/gnuradio-core/src/python/gnuradio/blksimpl/fm_demod.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- python/gnuradio/blksimpl/fm_demod.py        2 Jul 2006 20:17:19 -0000       
1.3
+++ python/gnuradio/blksimpl/fm_demod.py        4 Jul 2006 07:20:52 -0000       
1.4
@@ -52,6 +52,9 @@
     def __init__(self, fg, channel_rate, audio_decim, deviation, 
                  audio_pass, audio_stop, gain=1.0, tau=75e-6):
        
+       # Equalizer for 250 us delay
+       CMA = gr.cma_equalizer_cc(int(channel_rate/4000), 0.5, 0.0001);
+       
        k = channel_rate/(2*pi*deviation)
        QUAD = gr.quadrature_demod_cf(k)
 
@@ -65,11 +68,11 @@
 
        if tau is not None:
            DEEMPH = fm_deemph(fg, channel_rate, tau)
-           fg.connect(QUAD, DEEMPH, LPF)
+           fg.connect(CMA, QUAD, DEEMPH, LPF)
         else:
-            fg.connect(QUAD, LPF)
+            fg.connect(CMA, QUAD, LPF)
 
-        gr.hier_block.__init__(self, fg, QUAD, LPF)
+        gr.hier_block.__init__(self, fg, CMA, LPF)
 
 class demod_20k0f3e_cf(fm_demod_cf):
     """

Index: lib/filter/gr_adaptive_fir_ccf.cc
===================================================================
RCS file: lib/filter/gr_adaptive_fir_ccf.cc
diff -N lib/filter/gr_adaptive_fir_ccf.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/filter/gr_adaptive_fir_ccf.cc   4 Jul 2006 07:20:52 -0000       1.1
@@ -0,0 +1,78 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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 2, 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_adaptive_fir_ccf.h>
+#include <gr_io_signature.h>
+
+gr_adaptive_fir_ccf::gr_adaptive_fir_ccf(char *name, int decimation, const 
std::vector<float> &taps)
+  : gr_sync_decimator (name,
+                      gr_make_io_signature (1, 1, sizeof(gr_complex)),
+                      gr_make_io_signature (1, 1, sizeof(gr_complex)),
+                      decimation),
+    d_updated(false)
+{
+  d_taps = taps;
+  set_history(d_taps.size());
+}
+
+void gr_adaptive_fir_ccf::set_taps(const std::vector<float> &taps)
+{
+  d_new_taps = taps;
+  d_updated = true;
+}
+
+int gr_adaptive_fir_ccf::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];
+
+  if (d_updated) {
+    d_taps = d_new_taps;
+    set_history(d_taps.size());
+    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++) {
+    // Generic dot product of d_taps[] and in[]
+    gr_complex sum(0.0, 0.0);
+    for (k = 0; k < l; k++)
+      sum += d_taps[l-k-1]*in[j+k];
+    out[i] = sum;
+        
+    // Adjust taps
+    d_error = error(sum);
+    for (k = 0; k < l; k++)
+        update_tap(d_taps[l-k-1], in[j+k]);
+
+    j += decimation();
+  }
+
+  return noutput_items;
+}

Index: lib/filter/gr_adaptive_fir_ccf.h
===================================================================
RCS file: lib/filter/gr_adaptive_fir_ccf.h
diff -N lib/filter/gr_adaptive_fir_ccf.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/filter/gr_adaptive_fir_ccf.h    4 Jul 2006 07:20:52 -0000       1.1
@@ -0,0 +1,57 @@
+/* -*- c++ -*- */
+/*
+ * 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 2, 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef INCLUDED_GR_ADAPTIVE_FIR_CCF_H
+#define        INCLUDED_GR_ADAPTIVE_FIR_CCF_H
+
+#include <gr_sync_decimator.h>
+
+/*!
+ * \brief Adaptive FIR filter with gr_complex input, gr_complex output and 
float taps
+ * \ingroup filter
+ */
+class gr_adaptive_fir_ccf : public gr_sync_decimator
+{
+private:
+  std::vector<float>  d_new_taps;
+  bool                d_updated;
+
+protected:
+  float                      d_error;
+  std::vector<float>  d_taps;
+
+  // Override to calculate error signal per output
+  virtual float error(const gr_complex &out) = 0; 
+
+  // Override to calculate new weight from old, corresponding input
+  virtual void update_tap(float &tap, const gr_complex &in) = 0;
+  
+public:
+  gr_adaptive_fir_ccf(char *name, int decimation, const std::vector<float> 
&taps);
+  void set_taps(const std::vector<float> &taps);
+
+  int work(int noutput_items,
+           gr_vector_const_void_star &input_items,
+           gr_vector_void_star &output_items);
+};
+
+#endif

Index: lib/filter/gr_adaptive_fir_ccf.i
===================================================================
RCS file: lib/filter/gr_adaptive_fir_ccf.i
diff -N lib/filter/gr_adaptive_fir_ccf.i
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/filter/gr_adaptive_fir_ccf.i    4 Jul 2006 07:20:52 -0000       1.1
@@ -0,0 +1,30 @@
+/* -*- c++ -*- */
+/*
+ * 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 2, 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+class gr_adaptive_fir_ccf : public gr_sync_decimator
+{
+private:
+  gr_adaptive_fir_ccf(char *name, int decimation, const std::vector<float> 
&taps);
+
+public:
+  void set_taps(const std::vector<float> &taps);
+};

Index: lib/filter/gr_cma_equalizer_cc.cc
===================================================================
RCS file: lib/filter/gr_cma_equalizer_cc.cc
diff -N lib/filter/gr_cma_equalizer_cc.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/filter/gr_cma_equalizer_cc.cc   4 Jul 2006 07:20:52 -0000       1.1
@@ -0,0 +1,40 @@
+/* -*- c++ -*- */
+/*
+ * 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 2, 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_cma_equalizer_cc.h>
+
+gr_cma_equalizer_cc_sptr
+gr_make_cma_equalizer_cc(int num_taps, float modulus, float mu)
+{
+  return gr_cma_equalizer_cc_sptr(new gr_cma_equalizer_cc(num_taps, modulus, 
mu));
+}
+
+gr_cma_equalizer_cc::gr_cma_equalizer_cc(int num_taps, float modulus, float mu)
+  : gr_adaptive_fir_ccf("cma_equalizer_cc", 1, std::vector<float>(num_taps)),
+    d_modulus(modulus), d_mu(mu)
+{
+  d_taps[0] = 1.0; // Initial tap causes identity mapping
+}

Index: lib/filter/gr_cma_equalizer_cc.h
===================================================================
RCS file: lib/filter/gr_cma_equalizer_cc.h
diff -N lib/filter/gr_cma_equalizer_cc.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/filter/gr_cma_equalizer_cc.h    4 Jul 2006 07:20:52 -0000       1.1
@@ -0,0 +1,64 @@
+/* -*- c++ -*- */
+/*
+ * 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 2, 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef INCLUDED_GR_CMA_EQUALIZER_CC_H
+#define        INCLUDED_GR_CMA_EQUALIZER_CC_H
+
+#include <gr_adaptive_fir_ccf.h>
+
+class gr_cma_equalizer_cc;
+typedef boost::shared_ptr<gr_cma_equalizer_cc> gr_cma_equalizer_cc_sptr;
+
+gr_cma_equalizer_cc_sptr 
+gr_make_cma_equalizer_cc(int num_taps, float modulus, float mu);
+
+/*!
+ * \brief Implements constant modulus adaptive filter on complex stream
+ * \ingroup filter
+ */
+class gr_cma_equalizer_cc : public gr_adaptive_fir_ccf
+{
+private:
+  float d_modulus;
+  float d_mu;
+    
+  friend gr_cma_equalizer_cc_sptr gr_make_cma_equalizer_cc(int num_taps, float 
modulus, float mu);
+  gr_cma_equalizer_cc(int num_taps, float modulus, float mu);
+
+protected:
+  virtual float error(const gr_complex &out); 
+  virtual void update_tap(float &tap, const gr_complex &in);
+  
+public:
+};
+
+inline float gr_cma_equalizer_cc::error(const gr_complex &out)
+{
+    return 0.0; // Not implemented
+}
+
+inline void gr_cma_equalizer_cc::update_tap(float &tap, const gr_complex &in)
+{
+    tap += 0.0; // Not implemented
+}
+
+#endif

Index: lib/filter/gr_cma_equalizer_cc.i
===================================================================
RCS file: lib/filter/gr_cma_equalizer_cc.i
diff -N lib/filter/gr_cma_equalizer_cc.i
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/filter/gr_cma_equalizer_cc.i    4 Jul 2006 07:20:52 -0000       1.1
@@ -0,0 +1,35 @@
+/* -*- c++ -*- */
+/*
+ * 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 2, 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,cma_equalizer_cc)
+
+%include <gr_adaptive_fir_ccf.i>
+
+gr_cma_equalizer_cc_sptr gr_make_cma_equalizer_cc(int num_taps, float modulus, 
float mu);
+
+class gr_cma_equalizer_cc : public gr_adaptive_fir_ccf
+{
+private:
+  gr_cma_equalizer_cc(int num_taps, float modulus, float mu);
+
+public:
+};

Index: python/gnuradio/gr/qa_cma_equalizer.py
===================================================================
RCS file: python/gnuradio/gr/qa_cma_equalizer.py
diff -N python/gnuradio/gr/qa_cma_equalizer.py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ python/gnuradio/gr/qa_cma_equalizer.py      4 Jul 2006 07:20:53 -0000       
1.1
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, gr_unittest
+
+class test_cma_equalizer_fir(gr_unittest.TestCase):
+
+    def setUp(self):
+       self.fg = gr.flow_graph()
+
+    def tearDown(self):
+       self.fg = None
+       
+    def transform(self, src_data):
+       SRC = gr.vector_source_c(src_data, False)
+       EQU = gr.cma_equalizer_cc(4, 1.0, .001)
+       DST = gr.vector_sink_c()
+       self.fg.connect(SRC, EQU, DST)
+       self.fg.run()
+       return DST.data()
+
+    def test_001_identity(self):
+       # Constant modulus signal so no adjustments
+       src_data      = (1+0j, 0+1j, -1+0j, 0-1j)*1000
+       expected_data = src_data
+       result = self.transform(src_data)
+       self.assertComplexTuplesAlmostEqual(expected_data, result)
+
+if __name__ == "__main__":
+    gr_unittest.main()
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]