summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/filter/Makefile.am3
-rw-r--r--gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.cc84
-rw-r--r--gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h59
-rw-r--r--gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.i31
-rw-r--r--gnuradio-core/src/lib/general/gr_costas_loop_cc.cc22
-rw-r--r--gnuradio-core/src/lib/general/gr_costas_loop_cc.h6
6 files changed, 203 insertions, 2 deletions
diff --git a/gnuradio-core/src/lib/filter/Makefile.am b/gnuradio-core/src/lib/filter/Makefile.am
index dee13e239b..777e1158a1 100644
--- a/gnuradio-core/src/lib/filter/Makefile.am
+++ b/gnuradio-core/src/lib/filter/Makefile.am
@@ -188,6 +188,7 @@ EXTRA_DIST += \
# work around automake deficiency
libfilter_la_common_SOURCES = \
$(GENERATED_CC) \
+ gr_adaptive_fir_ccc.cc \
gr_adaptive_fir_ccf.cc \
gr_cma_equalizer_cc.cc \
gri_fft_filter_fff_generic.cc \
@@ -270,6 +271,7 @@ grinclude_HEADERS = \
ccomplex_dotprod_x86.h \
float_dotprod_generic.h \
float_dotprod_x86.h \
+ gr_adaptive_fir_ccc.h \
gr_adaptive_fir_ccf.h \
gr_altivec.h \
gr_cma_equalizer_cc.h \
@@ -353,6 +355,7 @@ noinst_HEADERS = \
swiginclude_HEADERS = \
filter.i \
filter_generated.i \
+ gr_adaptive_fir_ccc.i \
gr_adaptive_fir_ccf.i \
gr_cma_equalizer_cc.i \
gr_fft_filter_ccc.i \
diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.cc b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.cc
new file mode 100644
index 0000000000..1793918393
--- /dev/null
+++ b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.cc
@@ -0,0 +1,84 @@
+/* -*- 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 <gr_adaptive_fir_ccc.h>
+#include <gr_io_signature.h>
+
+gr_adaptive_fir_ccc::gr_adaptive_fir_ccc(const char *name, int decimation,
+ const std::vector<gr_complex> &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_ccc::set_taps(const std::vector<gr_complex> &taps)
+{
+ d_new_taps = taps;
+ d_updated = true;
+}
+
+int
+gr_adaptive_fir_ccc::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++) {
+ //printf("%f ", d_taps[k]);
+ update_tap(d_taps[l-k-1], in[j+k]);
+ }
+ //printf("\n");
+
+ j += decimation();
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h
new file mode 100644
index 0000000000..88b5f92814
--- /dev/null
+++ b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h
@@ -0,0 +1,59 @@
+/* -*- 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_GR_ADAPTIVE_FIR_CCC_H
+#define INCLUDED_GR_ADAPTIVE_FIR_CCC_H
+
+#include <gr_sync_decimator.h>
+
+/*!
+ * \brief Adaptive FIR filter with gr_complex input, gr_complex output and float taps
+ * \ingroup filter_blk
+ */
+class gr_adaptive_fir_ccc : public gr_sync_decimator
+{
+private:
+ std::vector<gr_complex> d_new_taps;
+ bool d_updated;
+
+protected:
+ gr_complex d_error;
+ std::vector<gr_complex> d_taps;
+
+ // Override to calculate error signal per output
+ virtual gr_complex error(const gr_complex &out) = 0;
+
+ // Override to calculate new weight from old, corresponding input
+ virtual void update_tap(gr_complex &tap, const gr_complex &in) = 0;
+
+ gr_adaptive_fir_ccc(const char *name, int decimation,
+ const std::vector<gr_complex> &taps);
+
+public:
+ void set_taps(const std::vector<gr_complex> &taps);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif
diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.i b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.i
new file mode 100644
index 0000000000..7e9a3fac31
--- /dev/null
+++ b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.i
@@ -0,0 +1,31 @@
+/* -*- 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.
+ */
+
+class gr_adaptive_fir_ccc : public gr_sync_decimator
+{
+protected:
+ gr_adaptive_fir_ccc(char *name, int decimation,
+ const std::vector<gr_complex> &taps);
+
+public:
+ void set_taps(const std::vector<gr_complex> &taps);
+};
diff --git a/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc b/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc
index f3bfd09518..b77b19745b 100644
--- a/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc
+++ b/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006,2010 Free Software Foundation, Inc.
+ * Copyright 2006,2010,2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -64,12 +64,30 @@ gr_costas_loop_cc::gr_costas_loop_cc (float alpha, float beta,
d_phase_detector = &gr_costas_loop_cc::phase_detector_4;
break;
+ case 8:
+ d_phase_detector = &gr_costas_loop_cc::phase_detector_8;
+ break;
+
default:
- throw std::invalid_argument("order must be 2 or 4");
+ throw std::invalid_argument("order must be 2, 4, or 8");
break;
}
}
+float
+gr_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
gr_costas_loop_cc::phase_detector_4(gr_complex sample) const
diff --git a/gnuradio-core/src/lib/general/gr_costas_loop_cc.h b/gnuradio-core/src/lib/general/gr_costas_loop_cc.h
index 3b4aab86c0..181880f1c5 100644
--- a/gnuradio-core/src/lib/general/gr_costas_loop_cc.h
+++ b/gnuradio-core/src/lib/general/gr_costas_loop_cc.h
@@ -89,6 +89,12 @@ class gr_costas_loop_cc : public gr_sync_block
int order
) throw (std::invalid_argument);
+ /*! \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