summaryrefslogtreecommitdiff
path: root/gr-digital/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital/lib')
-rw-r--r--gr-digital/lib/CMakeLists.txt13
-rw-r--r--gr-digital/lib/Makefile.am16
-rw-r--r--gr-digital/lib/digital_binary_slicer_fb.cc59
-rw-r--r--gr-digital/lib/digital_binary_slicer_fb.h52
-rw-r--r--gr-digital/lib/digital_clock_recovery_mm_cc.cc217
-rw-r--r--gr-digital/lib/digital_clock_recovery_mm_cc.h113
-rw-r--r--gr-digital/lib/digital_clock_recovery_mm_ff.cc139
-rw-r--r--gr-digital/lib/digital_clock_recovery_mm_ff.h99
-rw-r--r--gr-digital/lib/digital_correlate_access_code_bb.cc134
-rw-r--r--gr-digital/lib/digital_correlate_access_code_bb.h84
-rw-r--r--gr-digital/lib/digital_crc32.cc130
-rw-r--r--gr-digital/lib/digital_crc32.h51
-rw-r--r--gr-digital/lib/digital_mpsk_receiver_cc.cc322
-rw-r--r--gr-digital/lib/digital_mpsk_receiver_cc.h317
14 files changed, 1743 insertions, 3 deletions
diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt
index 86e082b31..b7d93da6b 100644
--- a/gr-digital/lib/CMakeLists.txt
+++ b/gr-digital/lib/CMakeLists.txt
@@ -32,13 +32,19 @@ LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
# Setup library
########################################################################
LIST(APPEND gr_digital_sources
+ digital_binary_slicer_fb.cc
+ digital_clock_recovery_mm_cc.cc
+ digital_clock_recovery_mm_ff.cc
digital_constellation.cc
digital_constellation_receiver_cb.cc
digital_constellation_decoder_cb.cc
+ digital_correlate_access_code_bb.cc
digital_costas_loop_cc.cc
digital_cma_equalizer_cc.cc
+ digital_crc32.cc
digital_lms_dd_equalizer_cc.cc
digital_kurtotic_equalizer_cc.cc
+ digital_mpsk_receiver_cc.cc
)
LIST(APPEND digital_libs
@@ -61,15 +67,20 @@ INSTALL(TARGETS gnuradio-digital
# Install header files
########################################################################
INSTALL(FILES
- digital_api.h
+ digital_binary_slicer_fb.h
+ digital_clock_recovery_mm_cc.h
+ digital_clock_recovery_mm_ff.h
digital_constellation.h
digital_constellation_receiver_cb.h
digital_constellation_decoder_cb.h
+ digital_correlate_access_code_bb.h
digital_costas_loop_cc.h
digital_cma_equalizer_cc.h
+ digital_crc32.h
digital_lms_dd_equalizer_cc.h
digital_kurtotic_equalizer_cc.h
digital_metric_type.h
+ digital_mpsk_receiver_cc.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio
COMPONENT "digital_devel"
)
diff --git a/gr-digital/lib/Makefile.am b/gr-digital/lib/Makefile.am
index 1cdb27a38..6b14988ac 100644
--- a/gr-digital/lib/Makefile.am
+++ b/gr-digital/lib/Makefile.am
@@ -26,25 +26,37 @@ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES)
# These headers get installed in ${prefix}/include/gnuradio
grinclude_HEADERS = \
digital_api.h \
+ digital_binary_slicer_fb.h \
+ digital_clock_recovery_mm_cc.h \
+ digital_clock_recovery_mm_ff.h \
digital_constellation.h \
digital_constellation_receiver_cb.h \
digital_constellation_decoder_cb.h \
+ digital_correlate_access_code_bb.h \
digital_costas_loop_cc.h \
digital_cma_equalizer_cc.h \
+ digital_crc32.h \
digital_lms_dd_equalizer_cc.h \
digital_kurtotic_equalizer_cc.h \
- digital_metric_type.h
+ digital_metric_type.h \
+ digital_mpsk_receiver_cc.h
lib_LTLIBRARIES = libgnuradio-digital.la
libgnuradio_digital_la_SOURCES = \
+ digital_binary_slicer_fb.cc \
+ digital_clock_recovery_mm_cc.cc \
+ digital_clock_recovery_mm_ff.cc \
digital_constellation.cc \
digital_constellation_receiver_cb.cc \
digital_constellation_decoder_cb.cc \
+ digital_correlate_access_code_bb.cc \
digital_costas_loop_cc.cc \
digital_cma_equalizer_cc.cc \
+ digital_crc32.cc \
digital_lms_dd_equalizer_cc.cc \
- digital_kurtotic_equalizer_cc.cc
+ digital_kurtotic_equalizer_cc.cc \
+ digital_mpsk_receiver_cc.cc
libgnuradio_digital_la_LIBADD = \
$(GNURADIO_CORE_LA)
diff --git a/gr-digital/lib/digital_binary_slicer_fb.cc b/gr-digital/lib/digital_binary_slicer_fb.cc
new file mode 100644
index 000000000..fcdb4291f
--- /dev/null
+++ b/gr-digital/lib/digital_binary_slicer_fb.cc
@@ -0,0 +1,59 @@
+/* -*- 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_binary_slicer_fb.h>
+#include <gr_io_signature.h>
+#include <gr_math.h>
+#include <stdexcept>
+
+digital_binary_slicer_fb_sptr
+digital_make_binary_slicer_fb ()
+{
+ return gnuradio::get_initial_sptr(new digital_binary_slicer_fb ());
+}
+
+digital_binary_slicer_fb::digital_binary_slicer_fb ()
+ : gr_sync_block ("binary_slicer_fb",
+ gr_make_io_signature (1, 1, sizeof (float)),
+ gr_make_io_signature (1, 1, sizeof (unsigned char)))
+{
+}
+
+int
+digital_binary_slicer_fb::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const float *in = (const float *) input_items[0];
+ unsigned char *out = (unsigned char *) output_items[0];
+
+
+ for (int i = 0; i < noutput_items; i++){
+ out[i] = gr_binary_slicer(in[i]);
+ }
+
+ return noutput_items;
+}
diff --git a/gr-digital/lib/digital_binary_slicer_fb.h b/gr-digital/lib/digital_binary_slicer_fb.h
new file mode 100644
index 000000000..9da776012
--- /dev/null
+++ b/gr-digital/lib/digital_binary_slicer_fb.h
@@ -0,0 +1,52 @@
+/* -*- 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_BINARY_SLICER_FB_H
+#define INCLUDED_DIGITAL_BINARY_SLICER_FB_H
+
+#include <digital_api.h>
+#include <gr_sync_block.h>
+
+class digital_binary_slicer_fb;
+typedef boost::shared_ptr<digital_binary_slicer_fb> digital_binary_slicer_fb_sptr;
+
+DIGITAL_API digital_binary_slicer_fb_sptr digital_make_binary_slicer_fb ();
+
+/*!
+ * \brief slice float binary symbol outputting 1 bit output
+ * \ingroup converter_blk
+ *
+ * x < 0 --> 0
+ * x >= 0 --> 1
+ */
+class DIGITAL_API digital_binary_slicer_fb : public gr_sync_block
+{
+ friend DIGITAL_API digital_binary_slicer_fb_sptr digital_make_binary_slicer_fb ();
+ digital_binary_slicer_fb ();
+
+ public:
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif
diff --git a/gr-digital/lib/digital_clock_recovery_mm_cc.cc b/gr-digital/lib/digital_clock_recovery_mm_cc.cc
new file mode 100644
index 000000000..2984afd6c
--- /dev/null
+++ b/gr-digital/lib/digital_clock_recovery_mm_cc.cc
@@ -0,0 +1,217 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,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 <gr_io_signature.h>
+#include <gr_prefs.h>
+#include <digital_clock_recovery_mm_cc.h>
+#include <gri_mmse_fir_interpolator_cc.h>
+#include <stdexcept>
+#include <cstdio>
+
+
+// Public constructor
+static const int FUDGE = 16;
+
+digital_clock_recovery_mm_cc_sptr
+digital_make_clock_recovery_mm_cc(float omega, float gain_omega,
+ float mu, float gain_mu,
+ float omega_relative_limit)
+{
+ return gnuradio::get_initial_sptr(new digital_clock_recovery_mm_cc (omega,
+ gain_omega,
+ mu,
+ gain_mu,
+ omega_relative_limit));
+}
+
+digital_clock_recovery_mm_cc::digital_clock_recovery_mm_cc (float omega, float gain_omega,
+ float mu, float gain_mu,
+ float omega_relative_limit)
+ : gr_block ("clock_recovery_mm_cc",
+ gr_make_io_signature (1, 1, sizeof (gr_complex)),
+ gr_make_io_signature (1, 2, sizeof (gr_complex))),
+ d_mu (mu), d_omega(omega), d_gain_omega(gain_omega),
+ d_omega_relative_limit(omega_relative_limit),
+ d_gain_mu(gain_mu), d_last_sample(0), d_interp(new gri_mmse_fir_interpolator_cc()),
+ d_verbose(gr_prefs::singleton()->get_bool("clock_recovery_mm_cc", "verbose", false)),
+ d_p_2T(0), d_p_1T(0), d_p_0T(0), d_c_2T(0), d_c_1T(0), d_c_0T(0)
+{
+ if (omega <= 0.0)
+ throw std::out_of_range ("clock rate must be > 0");
+ if (gain_mu < 0 || gain_omega < 0)
+ throw std::out_of_range ("Gains must be non-negative");
+
+ set_omega(omega); // also sets min and max omega
+ set_relative_rate (1.0 / omega);
+ set_history(3); // ensure 2 extra input sample is available
+}
+
+digital_clock_recovery_mm_cc::~digital_clock_recovery_mm_cc ()
+{
+ delete d_interp;
+}
+
+void
+digital_clock_recovery_mm_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required)
+{
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned i=0; i < ninputs; i++)
+ ninput_items_required[i] =
+ (int) ceil((noutput_items * d_omega) + d_interp->ntaps()) + FUDGE;
+}
+
+gr_complex
+digital_clock_recovery_mm_cc::slicer_0deg (gr_complex sample)
+{
+ float real=0, imag=0;
+
+ if(sample.real() > 0)
+ real = 1;
+ if(sample.imag() > 0)
+ imag = 1;
+ return gr_complex(real,imag);
+}
+
+gr_complex
+digital_clock_recovery_mm_cc::slicer_45deg (gr_complex sample)
+{
+ float real= -1, imag = -1;
+ if(sample.real() > 0)
+ real=1;
+ if(sample.imag() > 0)
+ imag = 1;
+ return gr_complex(real,imag);
+}
+
+/*
+ Modified Mueller and Muller clock recovery circuit
+ Based:
+ G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller and Muller
+ algorithm," Electronics Letters, Vol. 31, no. 13, 22 June 1995, pp. 1032 - 1033.
+*/
+
+int
+digital_clock_recovery_mm_cc::general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const gr_complex *in = (const gr_complex *) input_items[0];
+ gr_complex *out = (gr_complex *) output_items[0];
+ gr_complex *foptr = (gr_complex *) output_items[1];
+
+ bool write_foptr = output_items.size() >= 2;
+
+ int ii = 0; // input index
+ int oo = 0; // output index
+ int ni = ninput_items[0] - d_interp->ntaps() - FUDGE; // don't use more input than this
+
+ assert(d_mu >= 0.0);
+ assert(d_mu <= 1.0);
+
+ float mm_val=0;
+ gr_complex u, x, y;
+
+ // This loop writes the error to the second output, if it exists
+ if (write_foptr) {
+ while(oo < noutput_items && ii < ni) {
+ d_p_2T = d_p_1T;
+ d_p_1T = d_p_0T;
+ d_p_0T = d_interp->interpolate (&in[ii], d_mu);
+
+ d_c_2T = d_c_1T;
+ d_c_1T = d_c_0T;
+ d_c_0T = slicer_0deg(d_p_0T);
+
+ x = (d_c_0T - d_c_2T) * conj(d_p_1T);
+ y = (d_p_0T - d_p_2T) * conj(d_c_1T);
+ u = y - x;
+ mm_val = u.real();
+ out[oo++] = d_p_0T;
+
+ // limit mm_val
+ mm_val = gr_branchless_clip(mm_val,1.0);
+ d_omega = d_omega + d_gain_omega * mm_val;
+ d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_relative_limit); // make sure we don't walk away
+
+ d_mu = d_mu + d_omega + d_gain_mu * mm_val;
+ ii += (int)floor(d_mu);
+ d_mu -= floor(d_mu);
+
+ // write the error signal to the second output
+ foptr[oo-1] = gr_complex(d_mu,0);
+
+ if (ii < 0) // clamp it. This should only happen with bogus input
+ ii = 0;
+ }
+ }
+ // This loop does not write to the second output (ugly, but faster)
+ else {
+ while(oo < noutput_items && ii < ni) {
+ d_p_2T = d_p_1T;
+ d_p_1T = d_p_0T;
+ d_p_0T = d_interp->interpolate (&in[ii], d_mu);
+
+ d_c_2T = d_c_1T;
+ d_c_1T = d_c_0T;
+ d_c_0T = slicer_0deg(d_p_0T);
+
+ x = (d_c_0T - d_c_2T) * conj(d_p_1T);
+ y = (d_p_0T - d_p_2T) * conj(d_c_1T);
+ u = y - x;
+ mm_val = u.real();
+ out[oo++] = d_p_0T;
+
+ // limit mm_val
+ mm_val = gr_branchless_clip(mm_val,1.0);
+
+ d_omega = d_omega + d_gain_omega * mm_val;
+ d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_relative_limit); // make sure we don't walk away
+
+ d_mu = d_mu + d_omega + d_gain_mu * mm_val;
+ ii += (int)floor(d_mu);
+ d_mu -= floor(d_mu);
+
+ if(d_verbose) {
+ printf("%f\t%f\n", d_omega, d_mu);
+ }
+
+ if (ii < 0) // clamp it. This should only happen with bogus input
+ ii = 0;
+ }
+ }
+
+ if (ii > 0){
+ if (ii > ninput_items[0]){
+ fprintf(stderr, "gr_clock_recovery_mm_cc: ii > ninput_items[0] (%d > %d)\n",
+ ii, ninput_items[0]);
+ assert(0);
+ }
+ consume_each (ii);
+ }
+
+ return oo;
+}
diff --git a/gr-digital/lib/digital_clock_recovery_mm_cc.h b/gr-digital/lib/digital_clock_recovery_mm_cc.h
new file mode 100644
index 000000000..e45b79229
--- /dev/null
+++ b/gr-digital/lib/digital_clock_recovery_mm_cc.h
@@ -0,0 +1,113 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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_CLOCK_RECOVERY_MM_CC_H
+#define INCLUDED_DIGITAL_CLOCK_RECOVERY_MM_CC_H
+
+#include <digital_api.h>
+#include <gr_block.h>
+#include <gr_complex.h>
+#include <gr_math.h>
+
+class gri_mmse_fir_interpolator_cc;
+
+class digital_clock_recovery_mm_cc;
+typedef boost::shared_ptr<digital_clock_recovery_mm_cc> digital_clock_recovery_mm_cc_sptr;
+
+// public constructor
+DIGITAL_API digital_clock_recovery_mm_cc_sptr
+digital_make_clock_recovery_mm_cc (float omega, float gain_omega,
+ float mu, float gain_mu,
+ float omega_relative_limit=0.001);
+
+/*!
+ * \brief Mueller and Müller (M&M) based clock recovery block with complex input, complex output.
+ * \ingroup sync_blk
+ *
+ * This implements the Mueller and Müller (M&M) discrete-time error-tracking synchronizer.
+ * The complex version here is based on:
+ * Modified Mueller and Muller clock recovery circuit
+ * Based:
+ * G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller and Muller
+ * algorithm," Electronics Letters, Vol. 31, no. 13, 22 June 1995, pp. 1032 - 1033.
+ */
+class DIGITAL_API digital_clock_recovery_mm_cc : public gr_block
+{
+ public:
+ ~digital_clock_recovery_mm_cc ();
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ float mu() const { return d_mu;}
+ float omega() const { return d_omega;}
+ float gain_mu() const { return d_gain_mu;}
+ float gain_omega() const { return d_gain_omega;}
+ void set_verbose (bool verbose) { d_verbose = verbose; }
+
+ void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; }
+ void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; }
+ void set_mu (float mu) { d_mu = mu; }
+ void set_omega (float omega) {
+ d_omega = omega;
+ d_min_omega = omega*(1.0 - d_omega_relative_limit);
+ d_max_omega = omega*(1.0 + d_omega_relative_limit);
+ d_omega_mid = 0.5*(d_min_omega+d_max_omega);
+ }
+
+protected:
+ digital_clock_recovery_mm_cc (float omega, float gain_omega,
+ float mu, float gain_mu,
+ float omega_relative_limi);
+
+ private:
+ float d_mu;
+ float d_omega;
+ float d_gain_omega;
+ float d_min_omega; // minimum allowed omega
+ float d_max_omega; // maximum allowed omeg
+ float d_omega_relative_limit; // used to compute min and max omega
+ float d_omega_mid;
+ float d_gain_mu;
+ gr_complex d_last_sample;
+ gri_mmse_fir_interpolator_cc *d_interp;
+ bool d_verbose;
+
+ gr_complex d_p_2T;
+ gr_complex d_p_1T;
+ gr_complex d_p_0T;
+
+ gr_complex d_c_2T;
+ gr_complex d_c_1T;
+ gr_complex d_c_0T;
+
+ gr_complex slicer_0deg (gr_complex sample);
+ gr_complex slicer_45deg (gr_complex sample);
+
+ friend DIGITAL_API digital_clock_recovery_mm_cc_sptr
+ digital_make_clock_recovery_mm_cc (float omega, float gain_omega,
+ float mu, float gain_mu,
+ float omega_relative_limit);
+};
+
+#endif
diff --git a/gr-digital/lib/digital_clock_recovery_mm_ff.cc b/gr-digital/lib/digital_clock_recovery_mm_ff.cc
new file mode 100644
index 000000000..04057f0e9
--- /dev/null
+++ b/gr-digital/lib/digital_clock_recovery_mm_ff.cc
@@ -0,0 +1,139 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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 <gr_io_signature.h>
+#include <digital_clock_recovery_mm_ff.h>
+#include <gri_mmse_fir_interpolator.h>
+#include <stdexcept>
+
+#define DEBUG_CR_MM_FF 0 // must be defined as 0 or 1
+
+// Public constructor
+
+digital_clock_recovery_mm_ff_sptr
+digital_make_clock_recovery_mm_ff(float omega, float gain_omega,
+ float mu, float gain_mu,
+ float omega_relative_limit)
+{
+ return gnuradio::get_initial_sptr(new digital_clock_recovery_mm_ff (omega,
+ gain_omega,
+ mu,
+ gain_mu,
+ omega_relative_limit));
+}
+
+digital_clock_recovery_mm_ff::digital_clock_recovery_mm_ff (float omega, float gain_omega,
+ float mu, float gain_mu,
+ float omega_relative_limit)
+ : gr_block ("clock_recovery_mm_ff",
+ gr_make_io_signature (1, 1, sizeof (float)),
+ gr_make_io_signature (1, 1, sizeof (float))),
+ d_mu (mu), d_gain_omega(gain_omega), d_gain_mu(gain_mu),
+ d_last_sample(0), d_interp(new gri_mmse_fir_interpolator()),
+ d_logfile(0), d_omega_relative_limit(omega_relative_limit)
+{
+ if (omega < 1)
+ throw std::out_of_range ("clock rate must be > 0");
+ if (gain_mu < 0 || gain_omega < 0)
+ throw std::out_of_range ("Gains must be non-negative");
+
+ set_omega(omega); // also sets min and max omega
+ set_relative_rate (1.0 / omega);
+
+ if (DEBUG_CR_MM_FF)
+ d_logfile = fopen("cr_mm_ff.dat", "wb");
+}
+
+digital_clock_recovery_mm_ff::~digital_clock_recovery_mm_ff ()
+{
+ delete d_interp;
+
+ if (DEBUG_CR_MM_FF && d_logfile){
+ fclose(d_logfile);
+ d_logfile = 0;
+ }
+}
+
+void
+digital_clock_recovery_mm_ff::forecast(int noutput_items, gr_vector_int &ninput_items_required)
+{
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned i=0; i < ninputs; i++)
+ ninput_items_required[i] =
+ (int) ceil((noutput_items * d_omega) + d_interp->ntaps());
+}
+
+static inline float
+slice(float x)
+{
+ return x < 0 ? -1.0F : 1.0F;
+}
+
+/*
+ * This implements the Mueller and Müller (M&M) discrete-time error-tracking synchronizer.
+ *
+ * See "Digital Communication Receivers: Synchronization, Channel
+ * Estimation and Signal Processing" by Heinrich Meyr, Marc Moeneclaey, & Stefan Fechtel.
+ * ISBN 0-471-50275-8.
+ */
+int
+digital_clock_recovery_mm_ff::general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const float *in = (const float *) input_items[0];
+ float *out = (float *) output_items[0];
+
+ int ii = 0; // input index
+ int oo = 0; // output index
+ int ni = ninput_items[0] - d_interp->ntaps(); // don't use more input than this
+ float mm_val;
+
+ while (oo < noutput_items && ii < ni ){
+
+ // produce output sample
+ out[oo] = d_interp->interpolate (&in[ii], d_mu);
+ mm_val = slice(d_last_sample) * out[oo] - slice(out[oo]) * d_last_sample;
+ d_last_sample = out[oo];
+
+ d_omega = d_omega + d_gain_omega * mm_val;
+ d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_relative_limit); // make sure we don't walk away
+ d_mu = d_mu + d_omega + d_gain_mu * mm_val;
+
+ ii += (int) floor(d_mu);
+ d_mu = d_mu - floor(d_mu);
+ oo++;
+
+ if (DEBUG_CR_MM_FF && d_logfile){
+ fwrite(&d_omega, sizeof(d_omega), 1, d_logfile);
+ }
+ }
+
+ consume_each (ii);
+
+ return oo;
+}
diff --git a/gr-digital/lib/digital_clock_recovery_mm_ff.h b/gr-digital/lib/digital_clock_recovery_mm_ff.h
new file mode 100644
index 000000000..6f88a4dcd
--- /dev/null
+++ b/gr-digital/lib/digital_clock_recovery_mm_ff.h
@@ -0,0 +1,99 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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_CLOCK_RECOVERY_MM_FF_H
+#define INCLUDED_DIGITAL_CLOCK_RECOVERY_MM_FF_H
+
+#include <digital_api.h>
+#include <gr_block.h>
+#include <gr_math.h>
+#include <stdio.h>
+
+class gri_mmse_fir_interpolator;
+
+class digital_clock_recovery_mm_ff;
+typedef boost::shared_ptr<digital_clock_recovery_mm_ff> digital_clock_recovery_mm_ff_sptr;
+
+// public constructor
+DIGITAL_API digital_clock_recovery_mm_ff_sptr
+digital_make_clock_recovery_mm_ff (float omega, float gain_omega,
+ float mu, float gain_mu,
+ float omega_relative_limit=0.001);
+
+/*!
+ * \brief Mueller and Müller (M&M) based clock recovery block with float input, float output.
+ * \ingroup sync_blk
+ *
+ * This implements the Mueller and Müller (M&M) discrete-time error-tracking synchronizer.
+ *
+ * See "Digital Communication Receivers: Synchronization, Channel
+ * Estimation and Signal Processing" by Heinrich Meyr, Marc Moeneclaey, & Stefan Fechtel.
+ * ISBN 0-471-50275-8.
+ */
+class DIGITAL_API digital_clock_recovery_mm_ff : public gr_block
+{
+ public:
+ ~digital_clock_recovery_mm_ff ();
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ float mu() const { return d_mu;}
+ float omega() const { return d_omega;}
+ float gain_mu() const { return d_gain_mu;}
+ float gain_omega() const { return d_gain_omega;}
+
+ void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; }
+ void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; }
+ void set_mu (float mu) { d_mu = mu; }
+ void set_omega (float omega){
+ d_omega = omega;
+ d_min_omega = omega*(1.0 - d_omega_relative_limit);
+ d_max_omega = omega*(1.0 + d_omega_relative_limit);
+ d_omega_mid = 0.5*(d_min_omega+d_max_omega);
+ }
+
+protected:
+ digital_clock_recovery_mm_ff (float omega, float gain_omega, float mu, float gain_mu,
+ float omega_relative_limit);
+
+ private:
+ float d_mu; // fractional sample position [0.0, 1.0]
+ float d_omega; // nominal frequency
+ float d_min_omega; // minimum allowed omega
+ float d_omega_mid; // average omega
+ float d_max_omega; // maximum allowed omega
+ float d_gain_omega; // gain for adjusting omega
+ float d_gain_mu; // gain for adjusting mu
+ float d_last_sample;
+ gri_mmse_fir_interpolator *d_interp;
+ FILE *d_logfile;
+ float d_omega_relative_limit; // used to compute min and max omega
+
+ friend DIGITAL_API digital_clock_recovery_mm_ff_sptr
+ digital_make_clock_recovery_mm_ff (float omega, float gain_omega,
+ float mu, float gain_mu,
+ float omega_relative_limit);
+};
+
+#endif
diff --git a/gr-digital/lib/digital_correlate_access_code_bb.cc b/gr-digital/lib/digital_correlate_access_code_bb.cc
new file mode 100644
index 000000000..f21b57d92
--- /dev/null
+++ b/gr-digital/lib/digital_correlate_access_code_bb.cc
@@ -0,0 +1,134 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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_correlate_access_code_bb.h>
+#include <gr_io_signature.h>
+#include <stdexcept>
+#include <gr_count_bits.h>
+#include <cstdio>
+
+
+#define VERBOSE 0
+
+
+digital_correlate_access_code_bb_sptr
+digital_make_correlate_access_code_bb (const std::string &access_code, int threshold)
+{
+ return gnuradio::get_initial_sptr(new digital_correlate_access_code_bb
+ (access_code, threshold));
+}
+
+
+digital_correlate_access_code_bb::digital_correlate_access_code_bb (
+ const std::string &access_code, int threshold)
+ : gr_sync_block ("correlate_access_code_bb",
+ gr_make_io_signature (1, 1, sizeof(char)),
+ gr_make_io_signature (1, 1, sizeof(char))),
+ d_data_reg(0), d_flag_reg(0), d_flag_bit(0), d_mask(0),
+ d_threshold(threshold)
+
+{
+ if (!set_access_code(access_code)){
+ fprintf(stderr, "digital_correlate_access_code_bb: access_code is > 64 bits\n");
+ throw std::out_of_range ("access_code is > 64 bits");
+ }
+}
+
+digital_correlate_access_code_bb::~digital_correlate_access_code_bb ()
+{
+}
+
+bool
+digital_correlate_access_code_bb::set_access_code(
+ const std::string &access_code)
+{
+ unsigned len = access_code.length(); // # of bytes in string
+ if (len > 64)
+ return false;
+
+ // set len top bits to 1.
+ d_mask = ((~0ULL) >> (64 - len)) << (64 - len);
+
+ d_flag_bit = 1LL << (64 - len); // Where we or-in new flag values.
+ // new data always goes in 0x0000000000000001
+ d_access_code = 0;
+ for (unsigned i=0; i < 64; i++){
+ d_access_code <<= 1;
+ if (i < len)
+ d_access_code |= access_code[i] & 1; // look at LSB only
+ }
+
+ return true;
+}
+
+int
+digital_correlate_access_code_bb::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const unsigned char *in = (const unsigned char *) input_items[0];
+ unsigned char *out = (unsigned char *) output_items[0];
+
+ for (int i = 0; i < noutput_items; i++){
+
+ // compute output value
+ unsigned int t = 0;
+
+ t |= ((d_data_reg >> 63) & 0x1) << 0;
+ t |= ((d_flag_reg >> 63) & 0x1) << 1; // flag bit
+ out[i] = t;
+
+ // compute hamming distance between desired access code and current data
+ unsigned long long wrong_bits = 0;
+ unsigned int nwrong = d_threshold+1;
+ int new_flag = 0;
+
+ wrong_bits = (d_data_reg ^ d_access_code) & d_mask;
+ nwrong = gr_count_bits64(wrong_bits);
+
+ // test for access code with up to threshold errors
+ new_flag = (nwrong <= d_threshold);
+
+#if VERBOSE
+ if(new_flag) {
+ fprintf(stderr, "access code found: %llx\n", d_access_code);
+ }
+ else {
+ fprintf(stderr, "%llx ==> %llx\n", d_access_code, d_data_reg);
+ }
+#endif
+
+ // shift in new data and new flag
+ d_data_reg = (d_data_reg << 1) | (in[i] & 0x1);
+ d_flag_reg = (d_flag_reg << 1);
+ if (new_flag) {
+ d_flag_reg |= d_flag_bit;
+ }
+ }
+
+ return noutput_items;
+}
+
diff --git a/gr-digital/lib/digital_correlate_access_code_bb.h b/gr-digital/lib/digital_correlate_access_code_bb.h
new file mode 100644
index 000000000..c4cb60428
--- /dev/null
+++ b/gr-digital/lib/digital_correlate_access_code_bb.h
@@ -0,0 +1,84 @@
+/* -*- 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.
+ */
+
+#ifndef INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_BB_H
+#define INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_BB_H
+
+#include <digital_api.h>
+#include <gr_sync_block.h>
+#include <string>
+
+class digital_correlate_access_code_bb;
+typedef boost::shared_ptr<digital_correlate_access_code_bb> digital_correlate_access_code_bb_sptr;
+
+/*!
+ * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100"
+ * \param threshold maximum number of bits that may be wrong
+ */
+DIGITAL_API digital_correlate_access_code_bb_sptr
+digital_make_correlate_access_code_bb (const std::string &access_code, int threshold);
+
+/*!
+ * \brief Examine input for specified access code, one bit at a time.
+ * \ingroup sync_blk
+ *
+ * input: stream of bits, 1 bit per input byte (data in LSB)
+ * output: stream of bits, 2 bits per output byte (data in LSB, flag in next higher bit)
+ *
+ * Each output byte contains two valid bits, the data bit, and the
+ * flag bit. The LSB (bit 0) is the data bit, and is the original
+ * input data, delayed 64 bits. Bit 1 is the
+ * flag bit and is 1 if the corresponding data bit is the first data
+ * bit following the access code. Otherwise the flag bit is 0.
+ */
+class DIGITAL_API digital_correlate_access_code_bb : public gr_sync_block
+{
+ friend DIGITAL_API digital_correlate_access_code_bb_sptr
+ digital_make_correlate_access_code_bb (const std::string &access_code, int threshold);
+ private:
+ unsigned long long d_access_code; // access code to locate start of packet
+ // access code is left justified in the word
+ unsigned long long d_data_reg; // used to look for access_code
+ unsigned long long d_flag_reg; // keep track of decisions
+ unsigned long long d_flag_bit; // mask containing 1 bit which is location of new flag
+ unsigned long long d_mask; // masks access_code bits (top N bits are set where
+ // N is the number of bits in the access code)
+ unsigned int d_threshold; // how many bits may be wrong in sync vector
+
+ protected:
+ digital_correlate_access_code_bb(const std::string &access_code, int threshold);
+
+ public:
+ ~digital_correlate_access_code_bb();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+
+ /*!
+ * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100"
+ */
+ bool set_access_code (const std::string &access_code);
+};
+
+#endif /* INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_BB_H */
diff --git a/gr-digital/lib/digital_crc32.cc b/gr-digital/lib/digital_crc32.cc
new file mode 100644
index 000000000..8806d6e9c
--- /dev/null
+++ b/gr-digital/lib/digital_crc32.cc
@@ -0,0 +1,130 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,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.
+ */
+
+/*
+ * See also ISO 3309 [ISO-3309] or ITU-T V.42 [ITU-V42] for a formal specification.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <digital_crc32.h>
+
+
+// Automatically generated CRC function
+// polynomial: 0x104C11DB7
+unsigned int
+digital_update_crc32(unsigned int crc, const unsigned char *data, size_t len)
+{
+ static const unsigned int table[256] = {
+ 0x00000000U,0x04C11DB7U,0x09823B6EU,0x0D4326D9U,
+ 0x130476DCU,0x17C56B6BU,0x1A864DB2U,0x1E475005U,
+ 0x2608EDB8U,0x22C9F00FU,0x2F8AD6D6U,0x2B4BCB61U,
+ 0x350C9B64U,0x31CD86D3U,0x3C8EA00AU,0x384FBDBDU,
+ 0x4C11DB70U,0x48D0C6C7U,0x4593E01EU,0x4152FDA9U,
+ 0x5F15ADACU,0x5BD4B01BU,0x569796C2U,0x52568B75U,
+ 0x6A1936C8U,0x6ED82B7FU,0x639B0DA6U,0x675A1011U,
+ 0x791D4014U,0x7DDC5DA3U,0x709F7B7AU,0x745E66CDU,
+ 0x9823B6E0U,0x9CE2AB57U,0x91A18D8EU,0x95609039U,
+ 0x8B27C03CU,0x8FE6DD8BU,0x82A5FB52U,0x8664E6E5U,
+ 0xBE2B5B58U,0xBAEA46EFU,0xB7A96036U,0xB3687D81U,
+ 0xAD2F2D84U,0xA9EE3033U,0xA4AD16EAU,0xA06C0B5DU,
+ 0xD4326D90U,0xD0F37027U,0xDDB056FEU,0xD9714B49U,
+ 0xC7361B4CU,0xC3F706FBU,0xCEB42022U,0xCA753D95U,
+ 0xF23A8028U,0xF6FB9D9FU,0xFBB8BB46U,0xFF79A6F1U,
+ 0xE13EF6F4U,0xE5FFEB43U,0xE8BCCD9AU,0xEC7DD02DU,
+ 0x34867077U,0x30476DC0U,0x3D044B19U,0x39C556AEU,
+ 0x278206ABU,0x23431B1CU,0x2E003DC5U,0x2AC12072U,
+ 0x128E9DCFU,0x164F8078U,0x1B0CA6A1U,0x1FCDBB16U,
+ 0x018AEB13U,0x054BF6A4U,0x0808D07DU,0x0CC9CDCAU,
+ 0x7897AB07U,0x7C56B6B0U,0x71159069U,0x75D48DDEU,
+ 0x6B93DDDBU,0x6F52C06CU,0x6211E6B5U,0x66D0FB02U,
+ 0x5E9F46BFU,0x5A5E5B08U,0x571D7DD1U,0x53DC6066U,
+ 0x4D9B3063U,0x495A2DD4U,0x44190B0DU,0x40D816BAU,
+ 0xACA5C697U,0xA864DB20U,0xA527FDF9U,0xA1E6E04EU,
+ 0xBFA1B04BU,0xBB60ADFCU,0xB6238B25U,0xB2E29692U,
+ 0x8AAD2B2FU,0x8E6C3698U,0x832F1041U,0x87EE0DF6U,
+ 0x99A95DF3U,0x9D684044U,0x902B669DU,0x94EA7B2AU,
+ 0xE0B41DE7U,0xE4750050U,0xE9362689U,0xEDF73B3EU,
+ 0xF3B06B3BU,0xF771768CU,0xFA325055U,0xFEF34DE2U,
+ 0xC6BCF05FU,0xC27DEDE8U,0xCF3ECB31U,0xCBFFD686U,
+ 0xD5B88683U,0xD1799B34U,0xDC3ABDEDU,0xD8FBA05AU,
+ 0x690CE0EEU,0x6DCDFD59U,0x608EDB80U,0x644FC637U,
+ 0x7A089632U,0x7EC98B85U,0x738AAD5CU,0x774BB0EBU,
+ 0x4F040D56U,0x4BC510E1U,0x46863638U,0x42472B8FU,
+ 0x5C007B8AU,0x58C1663DU,0x558240E4U,0x51435D53U,
+ 0x251D3B9EU,0x21DC2629U,0x2C9F00F0U,0x285E1D47U,
+ 0x36194D42U,0x32D850F5U,0x3F9B762CU,0x3B5A6B9BU,
+ 0x0315D626U,0x07D4CB91U,0x0A97ED48U,0x0E56F0FFU,
+ 0x1011A0FAU,0x14D0BD4DU,0x19939B94U,0x1D528623U,
+ 0xF12F560EU,0xF5EE4BB9U,0xF8AD6D60U,0xFC6C70D7U,
+ 0xE22B20D2U,0xE6EA3D65U,0xEBA91BBCU,0xEF68060BU,
+ 0xD727BBB6U,0xD3E6A601U,0xDEA580D8U,0xDA649D6FU,
+ 0xC423CD6AU,0xC0E2D0DDU,0xCDA1F604U,0xC960EBB3U,
+ 0xBD3E8D7EU,0xB9FF90C9U,0xB4BCB610U,0xB07DABA7U,
+ 0xAE3AFBA2U,0xAAFBE615U,0xA7B8C0CCU,0xA379DD7BU,
+ 0x9B3660C6U,0x9FF77D71U,0x92B45BA8U,0x9675461FU,
+ 0x8832161AU,0x8CF30BADU,0x81B02D74U,0x857130C3U,
+ 0x5D8A9099U,0x594B8D2EU,0x5408ABF7U,0x50C9B640U,
+ 0x4E8EE645U,0x4A4FFBF2U,0x470CDD2BU,0x43CDC09CU,
+ 0x7B827D21U,0x7F436096U,0x7200464FU,0x76C15BF8U,
+ 0x68860BFDU,0x6C47164AU,0x61043093U,0x65C52D24U,
+ 0x119B4BE9U,0x155A565EU,0x18197087U,0x1CD86D30U,
+ 0x029F3D35U,0x065E2082U,0x0B1D065BU,0x0FDC1BECU,
+ 0x3793A651U,0x3352BBE6U,0x3E119D3FU,0x3AD08088U,
+ 0x2497D08DU,0x2056CD3AU,0x2D15EBE3U,0x29D4F654U,
+ 0xC5A92679U,0xC1683BCEU,0xCC2B1D17U,0xC8EA00A0U,
+ 0xD6AD50A5U,0xD26C4D12U,0xDF2F6BCBU,0xDBEE767CU,
+ 0xE3A1CBC1U,0xE760D676U,0xEA23F0AFU,0xEEE2ED18U,
+ 0xF0A5BD1DU,0xF464A0AAU,0xF9278673U,0xFDE69BC4U,
+ 0x89B8FD09U,0x8D79E0BEU,0x803AC667U,0x84FBDBD0U,
+ 0x9ABC8BD5U,0x9E7D9662U,0x933EB0BBU,0x97FFAD0CU,
+ 0xAFB010B1U,0xAB710D06U,0xA6322BDFU,0xA2F33668U,
+ 0xBCB4666DU,0xB8757BDAU,0xB5365D03U,0xB1F740B4U,
+ };
+
+ while (len > 0)
+ {
+ crc = table[*data ^ ((crc >> 24) & 0xff)] ^ (crc << 8);
+ data++;
+ len--;
+ }
+ return crc;
+}
+
+unsigned int
+digital_update_crc32(unsigned int crc, const std::string s)
+{
+ return digital_update_crc32(crc, (const unsigned char *) s.data(), s.size());
+}
+
+unsigned int
+digital_crc32(const unsigned char *buf, size_t len)
+{
+ return digital_update_crc32(0xffffffff, buf, len) ^ 0xffffffff;
+}
+
+unsigned int
+digital_crc32(const std::string s)
+{
+ return digital_crc32((const unsigned char *) s.data(), s.size());
+}
diff --git a/gr-digital/lib/digital_crc32.h b/gr-digital/lib/digital_crc32.h
new file mode 100644
index 000000000..852d06f49
--- /dev/null
+++ b/gr-digital/lib/digital_crc32.h
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,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_CRC32_H
+#define INCLUDED_DIGITAL_CRC32_H
+
+#include <digital_api.h>
+#include <string>
+#include <gr_types.h>
+
+/*!
+ * \brief update running CRC-32
+ * \ingroup misc
+ *
+ * Update a running CRC with the bytes buf[0..len-1] The CRC should be
+ * initialized to all 1's, and the transmitted value is the 1's
+ * complement of the final running CRC. The resulting CRC should be
+ * transmitted in big endian order.
+ */
+DIGITAL_API unsigned int
+digital_update_crc32(unsigned int crc, const unsigned char *buf, size_t len);
+
+DIGITAL_API unsigned int
+digital_update_crc32(unsigned int crc, const std::string buf);
+
+DIGITAL_API unsigned int
+digital_crc32(const unsigned char *buf, size_t len);
+
+DIGITAL_API unsigned int
+digital_crc32(const std::string buf);
+
+#endif /* INCLUDED_CRC32_H */
diff --git a/gr-digital/lib/digital_mpsk_receiver_cc.cc b/gr-digital/lib/digital_mpsk_receiver_cc.cc
new file mode 100644
index 000000000..3b2ea9840
--- /dev/null
+++ b/gr-digital/lib/digital_mpsk_receiver_cc.cc
@@ -0,0 +1,322 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2006,2007,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 <gr_io_signature.h>
+#include <gr_prefs.h>
+#include <digital_mpsk_receiver_cc.h>
+#include <stdexcept>
+#include <gr_math.h>
+#include <gr_expj.h>
+#include <gri_mmse_fir_interpolator_cc.h>
+
+
+#define M_TWOPI (2*M_PI)
+#define VERBOSE_MM 0 // Used for debugging symbol timing loop
+#define VERBOSE_COSTAS 0 // Used for debugging phase and frequency tracking
+
+// Public constructor
+
+digital_mpsk_receiver_cc_sptr
+digital_make_mpsk_receiver_cc(unsigned int M, float theta,
+ float alpha, float beta,
+ float fmin, float fmax,
+ float mu, float gain_mu,
+ float omega, float gain_omega, float omega_rel)
+{
+ return gnuradio::get_initial_sptr(new digital_mpsk_receiver_cc (M, theta,
+ alpha, beta,
+ fmin, fmax,
+ mu, gain_mu,
+ omega, gain_omega, omega_rel));
+}
+
+digital_mpsk_receiver_cc::digital_mpsk_receiver_cc (unsigned int M, float theta,
+ float alpha, float beta,
+ float fmin, float fmax,
+ float mu, float gain_mu,
+ float omega, float gain_omega, float omega_rel)
+ : gr_block ("mpsk_receiver_cc",
+ gr_make_io_signature (1, 1, sizeof (gr_complex)),
+ gr_make_io_signature (1, 1, sizeof (gr_complex))),
+ d_M(M), d_theta(theta),
+ d_alpha(alpha), d_beta(beta), d_freq(0), d_max_freq(fmax), d_min_freq(fmin), d_phase(0),
+ d_current_const_point(0),
+ d_mu(mu), d_gain_mu(gain_mu), d_gain_omega(gain_omega),
+ d_omega_rel(omega_rel), d_max_omega(0), d_min_omega(0),
+ d_p_2T(0), d_p_1T(0), d_p_0T(0), d_c_2T(0), d_c_1T(0), d_c_0T(0)
+{
+ d_interp = new gri_mmse_fir_interpolator_cc();
+ d_dl_idx = 0;
+
+ set_omega(omega);
+
+ if (omega <= 0.0)
+ throw std::out_of_range ("clock rate must be > 0");
+ if (gain_mu < 0 || gain_omega < 0)
+ throw std::out_of_range ("Gains must be non-negative");
+
+ assert(d_interp->ntaps() <= DLLEN);
+
+ // zero double length delay line.
+ for (unsigned int i = 0; i < 2 * DLLEN; i++)
+ d_dl[i] = gr_complex(0.0,0.0);
+
+ // build the constellation vector from M
+ make_constellation();
+
+ // Select a phase detector and a decision maker for the modulation order
+ switch(d_M) {
+ case 2: // optimized algorithms for BPSK
+ d_phase_error_detector = &digital_mpsk_receiver_cc::phase_error_detector_bpsk; //bpsk;
+ d_decision = &digital_mpsk_receiver_cc::decision_bpsk;
+ break;
+
+ case 4: // optimized algorithms for QPSK
+ d_phase_error_detector = &digital_mpsk_receiver_cc::phase_error_detector_qpsk; //qpsk;
+ d_decision = &digital_mpsk_receiver_cc::decision_qpsk;
+ break;
+
+ default: // generic algorithms for any M (power of 2?) but not pretty
+ d_phase_error_detector = &digital_mpsk_receiver_cc::phase_error_detector_generic;
+ d_decision = &digital_mpsk_receiver_cc::decision_generic;
+ break;
+ }
+}
+
+digital_mpsk_receiver_cc::~digital_mpsk_receiver_cc ()
+{
+ delete d_interp;
+}
+
+void
+digital_mpsk_receiver_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required)
+{
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned i=0; i < ninputs; i++)
+ ninput_items_required[i] = (int) ceil((noutput_items * d_omega) + d_interp->ntaps());
+}
+
+// FIXME add these back in an test difference in performance
+float
+digital_mpsk_receiver_cc::phase_error_detector_qpsk(gr_complex sample) const
+{
+ float phase_error = 0;
+ if(fabsf(sample.real()) > fabsf(sample.imag())) {
+ if(sample.real() > 0)
+ phase_error = -sample.imag();
+ else
+ phase_error = sample.imag();
+ }
+ else {
+ if(sample.imag() > 0)
+ phase_error = sample.real();
+ else
+ phase_error = -sample.real();
+ }
+
+ return phase_error;
+}
+
+float
+digital_mpsk_receiver_cc::phase_error_detector_bpsk(gr_complex sample) const
+{
+ return -(sample.real()*sample.imag());
+}
+
+float digital_mpsk_receiver_cc::phase_error_detector_generic(gr_complex sample) const
+{
+ //return gr_fast_atan2f(sample*conj(d_constellation[d_current_const_point]));
+ return -arg(sample*conj(d_constellation[d_current_const_point]));
+}
+
+unsigned int
+digital_mpsk_receiver_cc::decision_bpsk(gr_complex sample) const
+{
+ return (gr_branchless_binary_slicer(sample.real()) ^ 1);
+ //return gr_binary_slicer(sample.real()) ^ 1;
+}
+
+unsigned int
+digital_mpsk_receiver_cc::decision_qpsk(gr_complex sample) const
+{
+ unsigned int index;
+
+ //index = gr_branchless_quad_0deg_slicer(sample);
+ index = gr_quad_0deg_slicer(sample);
+ return index;
+}
+
+unsigned int
+digital_mpsk_receiver_cc::decision_generic(gr_complex sample) const
+{
+ unsigned int min_m = 0;
+ float min_s = 65535;
+
+ // Develop all possible constellation points and find the one that minimizes
+ // the Euclidean distance (error) with the sample
+ for(unsigned int m=0; m < d_M; m++) {
+ gr_complex diff = norm(d_constellation[m] - sample);
+
+ if(fabs(diff.real()) < min_s) {
+ min_s = fabs(diff.real());
+ min_m = m;
+ }
+ }
+ // Return the index of the constellation point that minimizes the error
+ return min_m;
+}
+
+
+void
+digital_mpsk_receiver_cc::make_constellation()
+{
+ for(unsigned int m=0; m < d_M; m++) {
+ d_constellation.push_back(gr_expj((M_TWOPI/d_M)*m));
+ }
+}
+
+void
+digital_mpsk_receiver_cc::mm_sampler(const gr_complex symbol)
+{
+ gr_complex sample, nco;
+
+ d_mu--; // skip a number of symbols between sampling
+ d_phase += d_freq; // increment the phase based on the frequency of the rotation
+
+ // Keep phase clamped and not walk to infinity
+ while(d_phase > M_TWOPI)
+ d_phase -= M_TWOPI;
+ while(d_phase < -M_TWOPI)
+ d_phase += M_TWOPI;
+
+ nco = gr_expj(d_phase+d_theta); // get the NCO value for derotating the current sample
+ sample = nco*symbol; // get the downconverted symbol
+
+ // Fill up the delay line for the interpolator
+ d_dl[d_dl_idx] = sample;
+ d_dl[(d_dl_idx + DLLEN)] = sample; // put this in the second half of the buffer for overflows
+ d_dl_idx = (d_dl_idx+1) % DLLEN; // Keep the delay line index in bounds
+}
+
+void
+digital_mpsk_receiver_cc::mm_error_tracking(gr_complex sample)
+{
+ gr_complex u, x, y;
+ float mm_error = 0;
+
+ // Make sample timing corrections
+
+ // set the delayed samples
+ d_p_2T = d_p_1T;
+ d_p_1T = d_p_0T;
+ d_p_0T = sample;
+ d_c_2T = d_c_1T;
+ d_c_1T = d_c_0T;
+
+ d_current_const_point = (*this.*d_decision)(d_p_0T); // make a decision on the sample value
+ d_c_0T = d_constellation[d_current_const_point];
+
+ x = (d_c_0T - d_c_2T) * conj(d_p_1T);
+ y = (d_p_0T - d_p_2T) * conj(d_c_1T);
+ u = y - x;
+ mm_error = u.real(); // the error signal is in the real part
+ mm_error = gr_branchless_clip(mm_error, 1.0); // limit mm_val
+
+ d_omega = d_omega + d_gain_omega * mm_error; // update omega based on loop error
+ d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_rel); // make sure we don't walk away
+
+ d_mu += d_omega + d_gain_mu * mm_error; // update mu based on loop error
+
+#if VERBOSE_MM
+ printf("mm: mu: %f omega: %f mm_error: %f sample: %f+j%f constellation: %f+j%f\n",
+ d_mu, d_omega, mm_error, sample.real(), sample.imag(),
+ d_constellation[d_current_const_point].real(), d_constellation[d_current_const_point].imag());
+#endif
+}
+
+
+void
+digital_mpsk_receiver_cc::phase_error_tracking(gr_complex sample)
+{
+ float phase_error = 0;
+
+ // Make phase and frequency corrections based on sampled value
+ phase_error = (*this.*d_phase_error_detector)(sample);
+
+ d_freq += d_beta*phase_error; // adjust frequency based on error
+ d_phase += d_freq + d_alpha*phase_error; // adjust phase based on error
+
+ // Make sure we stay within +-2pi
+ while(d_phase > M_TWOPI)
+ d_phase -= M_TWOPI;
+ while(d_phase < -M_TWOPI)
+ d_phase += M_TWOPI;
+
+ // Limit the frequency range
+ d_freq = gr_branchless_clip(d_freq, d_max_freq);
+
+#if VERBOSE_COSTAS
+ printf("cl: phase_error: %f phase: %f freq: %f sample: %f+j%f constellation: %f+j%f\n",
+ phase_error, d_phase, d_freq, sample.real(), sample.imag(),
+ d_constellation[d_current_const_point].real(), d_constellation[d_current_const_point].imag());
+#endif
+}
+
+int
+digital_mpsk_receiver_cc::general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const gr_complex *in = (const gr_complex *) input_items[0];
+ gr_complex *out = (gr_complex *) output_items[0];
+
+ int i=0, o=0;
+
+ while((o < noutput_items) && (i < ninput_items[0])) {
+ while((d_mu > 1) && (i < ninput_items[0])) {
+ mm_sampler(in[i]); // puts symbols into a buffer and adjusts d_mu
+ i++;
+ }
+
+ if(i < ninput_items[0]) {
+ gr_complex interp_sample = d_interp->interpolate(&d_dl[d_dl_idx], d_mu);
+
+ mm_error_tracking(interp_sample); // corrects M&M sample time
+ phase_error_tracking(interp_sample); // corrects phase and frequency offsets
+
+ out[o++] = interp_sample;
+ }
+ }
+
+ #if 0
+ printf("ninput_items: %d noutput_items: %d consuming: %d returning: %d\n",
+ ninput_items[0], noutput_items, i, o);
+ #endif
+
+ consume_each(i);
+ return o;
+}
diff --git a/gr-digital/lib/digital_mpsk_receiver_cc.h b/gr-digital/lib/digital_mpsk_receiver_cc.h
new file mode 100644
index 000000000..8a6352ec7
--- /dev/null
+++ b/gr-digital/lib/digital_mpsk_receiver_cc.h
@@ -0,0 +1,317 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2007,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_MPSK_RECEIVER_CC_H
+#define INCLUDED_DIGITAL_MPSK_RECEIVER_CC_H
+
+#include <digital_api.h>
+#include <gruel/attributes.h>
+#include <gr_block.h>
+#include <gr_complex.h>
+#include <fstream>
+
+class gri_mmse_fir_interpolator_cc;
+
+class digital_mpsk_receiver_cc;
+typedef boost::shared_ptr<digital_mpsk_receiver_cc> digital_mpsk_receiver_cc_sptr;
+
+// public constructor
+DIGITAL_API digital_mpsk_receiver_cc_sptr
+digital_make_mpsk_receiver_cc (unsigned int M, float theta,
+ float alpha, float beta,
+ float fmin, float fmax,
+ float mu, float gain_mu,
+ float omega, float gain_omega, float omega_rel);
+
+/*!
+ * \brief This block takes care of receiving M-PSK modulated signals through phase, frequency, and symbol
+ * synchronization.
+ * \ingroup sync_blk
+ * \ingroup demod_blk
+ *
+ * This block takes care of receiving M-PSK modulated signals through phase, frequency, and symbol
+ * synchronization. It performs carrier frequency and phase locking as well as symbol timing recovery.
+ * It works with (D)BPSK, (D)QPSK, and (D)8PSK as tested currently. It should also work for OQPSK and
+ * PI/4 DQPSK.
+ *
+ * The phase and frequency synchronization are based on a Costas loop that finds the error of the incoming
+ * signal point compared to its nearest constellation point. The frequency and phase of the NCO are
+ * updated according to this error. There are optimized phase error detectors for BPSK and QPSK, but 8PSK
+ * is done using a brute-force computation of the constellation points to find the minimum.
+ *
+ * The symbol synchronization is done using a modified Mueller and Muller circuit from the paper:
+ *
+ * G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller and Muller
+ * algorithm," Electronics Letters, Vol. 31, no. 13, 22 June 1995, pp. 1032 - 1033.
+ *
+ * This circuit interpolates the downconverted sample (using the NCO developed by the Costas loop)
+ * every mu samples, then it finds the sampling error based on this and the past symbols and the decision
+ * made on the samples. Like the phase error detector, there are optimized decision algorithms for BPSK
+ * and QPKS, but 8PSK uses another brute force computation against all possible symbols. The modifications
+ * to the M&M used here reduce self-noise.
+ *
+ */
+
+class DIGITAL_API digital_mpsk_receiver_cc : public gr_block
+{
+ public:
+ ~digital_mpsk_receiver_cc ();
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+
+ // Member functions related to the symbol tracking portion of the receiver
+ //! (M&M) Returns current value of mu
+ float mu() const { return d_mu;}
+
+ //! (M&M) Returns current value of omega
+ float omega() const { return d_omega;}
+
+ //! (M&M) Returns mu gain factor
+ float gain_mu() const { return d_gain_mu;}
+
+ //! (M&M) Returns omega gain factor
+ float gain_omega() const { return d_gain_omega;}
+
+ //! (M&M) Sets value of mu
+ void set_mu (float mu) { d_mu = mu; }
+
+ //! (M&M) Sets value of omega and its min and max values
+ void set_omega (float omega) {
+ d_omega = omega;
+ d_min_omega = omega*(1.0 - d_omega_rel);
+ d_max_omega = omega*(1.0 + d_omega_rel);
+ d_omega_mid = 0.5*(d_min_omega+d_max_omega);
+ }
+
+ //! (M&M) Sets value for mu gain factor
+ void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; }
+
+ //! (M&M) Sets value for omega gain factor
+ void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; }
+
+
+
+ // Member function related to the phase/frequency tracking portion of the receiver
+ //! (CL) Returns the value for alpha (the phase gain term)
+ float alpha() const { return d_alpha; }
+
+ //! (CL) Returns the value of beta (the frequency gain term)
+ float beta() const { return d_beta; }
+
+ //! (CL) Returns the current value of the frequency of the NCO in the Costas loop
+ float freq() const { return d_freq; }
+
+ //! (CL) Returns the current value of the phase of the NCO in the Costal loop
+ float phase() const { return d_phase; }
+
+ //! (CL) Sets the value for alpha (the phase gain term)
+ void set_alpha(float alpha) { d_alpha = alpha; }
+
+ //! (CL) Setss the value of beta (the frequency gain term)
+ void set_beta(float beta) { d_beta = beta; }
+
+ //! (CL) Sets the current value of the frequency of the NCO in the Costas loop
+ void set_freq(float freq) { d_freq = freq; }
+
+ //! (CL) Setss the current value of the phase of the NCO in the Costal loop
+ void set_phase(float phase) { d_phase = phase; }
+
+
+protected:
+
+ /*!
+ * \brief Constructor to synchronize incoming M-PSK symbols
+ *
+ * \param M modulation order of the M-PSK modulation
+ * \param theta any constant phase rotation from the real axis of the constellation
+ * \param alpha gain parameter to adjust the phase in the Costas loop (~0.01)
+ * \param beta gain parameter to adjust the frequency in the Costas loop (~alpha^2/4)
+ * \param fmin minimum normalized frequency value the loop can achieve
+ * \param fmax maximum normalized frequency value the loop can achieve
+ * \param mu initial parameter for the interpolator [0,1]
+ * \param gain_mu gain parameter of the M&M error signal to adjust mu (~0.05)
+ * \param omega initial value for the number of symbols between samples (~number of samples/symbol)
+ * \param gain_omega gain parameter to adjust omega based on the error (~omega^2/4)
+ * \param omega_rel sets the maximum (omega*(1+omega_rel)) and minimum (omega*(1+omega_rel)) omega (~0.005)
+ *
+ * The constructor also chooses which phase detector and decision maker to use in the work loop based on the
+ * value of M.
+ */
+ digital_mpsk_receiver_cc (unsigned int M, float theta,
+ float alpha, float beta,
+ float fmin, float fmax,
+ float mu, float gain_mu,
+ float omega, float gain_omega, float omega_rel);
+
+ void make_constellation();
+ void mm_sampler(const gr_complex symbol);
+ void mm_error_tracking(gr_complex sample);
+ void phase_error_tracking(gr_complex sample);
+
+
+/*!
+ * \brief Phase error detector for MPSK modulations.
+ *
+ * \param sample the I&Q sample from which to determine the phase error
+ *
+ * This function determines the phase error for any MPSK signal by creating a set of PSK constellation points
+ * and doing a brute-force search to see which point minimizes the Euclidean distance. This point is then used
+ * to derotate the sample to the real-axis and a atan (using the fast approximation function) to determine the
+ * phase difference between the incoming sample and the real constellation point
+ *
+ * This should be cleaned up and made more efficient.
+ *
+ * \returns the approximated phase error.
+ */
+ float phase_error_detector_generic(gr_complex sample) const; // generic for M but more costly
+
+ /*!
+ * \brief Phase error detector for BPSK modulation.
+ *
+ * \param sample the I&Q sample from which to determine the phase error
+ *
+ * This function determines the phase error using a simple BPSK phase error detector by multiplying the real
+ * and imaginary (the error signal) components together. As the imaginary part goes to 0, so does this error.
+ *
+ * \returns the approximated phase error.
+ */
+ float phase_error_detector_bpsk(gr_complex sample) const; // optimized for BPSK
+
+ /*!
+ * \brief Phase error detector for QPSK modulation.
+ *
+ * \param sample the I&Q sample from which to determine the phase error
+ *
+ * This function determines the phase error using the limiter approach in a standard 4th order Costas loop
+ *
+ * \returns the approximated phase error.
+ */
+ float phase_error_detector_qpsk(gr_complex sample) const;
+
+
+
+ /*!
+ * \brief Decision maker for a generic MPSK constellation.
+ *
+ * \param sample the baseband I&Q sample from which to make the decision
+ *
+ * This decision maker is a generic implementation that does a brute-force search
+ * for the constellation point that minimizes the error between it and the incoming signal.
+ *
+ * \returns the index to d_constellation that minimizes the error/
+ */
+ unsigned int decision_generic(gr_complex sample) const;
+
+
+ /*!
+ * \brief Decision maker for BPSK constellation.
+ *
+ * \param sample the baseband I&Q sample from which to make the decision
+ *
+ * This decision maker is a simple slicer function that makes a decision on the symbol based on its
+ * placement on the real axis of greater than 0 or less than 0; the quadrature component is always 0.
+ *
+ * \returns the index to d_constellation that minimizes the error/
+ */
+ unsigned int decision_bpsk(gr_complex sample) const;
+
+
+ /*!
+ * \brief Decision maker for QPSK constellation.
+ *
+ * \param sample the baseband I&Q sample from which to make the decision
+ *
+ * This decision maker is a simple slicer function that makes a decision on the symbol based on its
+ * placement versus both axes and returns which quadrant the symbol is in.
+ *
+ * \returns the index to d_constellation that minimizes the error/
+ */
+ unsigned int decision_qpsk(gr_complex sample) const;
+
+ private:
+ unsigned int d_M;
+ float d_theta;
+
+ // Members related to carrier and phase tracking
+ float d_alpha;
+ float d_beta;
+ float d_freq, d_max_freq, d_min_freq;
+ float d_phase;
+
+/*!
+ * \brief Decision maker function pointer
+ *
+ * \param sample the baseband I&Q sample from which to make the decision
+ *
+ * This is a function pointer that is set in the constructor to point to the proper decision function
+ * for the specified constellation order.
+ *
+ * \return index into d_constellation point that is the closest to the recieved sample
+ */
+ unsigned int (digital_mpsk_receiver_cc::*d_decision)(gr_complex sample) const; // pointer to decision function
+
+
+ std::vector<gr_complex> d_constellation;
+ unsigned int d_current_const_point;
+
+ // Members related to symbol timing
+ float d_mu, d_gain_mu;
+ float d_omega, d_gain_omega, d_omega_rel, d_max_omega, d_min_omega, d_omega_mid;
+ gr_complex d_p_2T, d_p_1T, d_p_0T;
+ gr_complex d_c_2T, d_c_1T, d_c_0T;
+
+ /*!
+ * \brief Phase error detector function pointer
+ *
+ * \param sample the I&Q sample from which to determine the phase error
+ *
+ * This is a function pointer that is set in the constructor to point to the proper phase error detector
+ * function for the specified constellation order.
+ */
+ float (digital_mpsk_receiver_cc::*d_phase_error_detector)(gr_complex sample) const;
+
+
+ //! get interpolated value
+ gri_mmse_fir_interpolator_cc *d_interp;
+
+ //! delay line length.
+ static const unsigned int DLLEN = 8;
+
+ //! delay line plus some length for overflow protection
+ __GR_ATTR_ALIGNED(8) gr_complex d_dl[2*DLLEN];
+
+ //! index to delay line
+ unsigned int d_dl_idx;
+
+ friend DIGITAL_API digital_mpsk_receiver_cc_sptr
+ digital_make_mpsk_receiver_cc (unsigned int M, float theta,
+ float alpha, float beta,
+ float fmin, float fmax,
+ float mu, float gain_mu,
+ float omega, float gain_omega, float omega_rel);
+};
+
+#endif