summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-02-20 14:12:26 -0500
committerTom Rondeau <trondeau@vt.edu>2013-02-20 14:12:26 -0500
commit11746e7de98462a6d6a9917e0500077ed063a1d7 (patch)
treeb6b8525ae40b3e2218f70fc7e33d38b276e9895e
parente09420595c730062b17630293eaafc8f37480b18 (diff)
parent68fbb9eb29d23dd1a177a1205152635d564f992a (diff)
Merge branch 'next' of gnuradio.org:gnuradio into next
-rw-r--r--docs/sphinx/source/gr/index.rst7
-rw-r--r--docs/sphinx/source/gr/sync_blk.rst4
-rw-r--r--gnuradio-core/src/lib/general/CMakeLists.txt3
-rw-r--r--gnuradio-core/src/lib/general/general.i2
-rw-r--r--gnuradio-core/src/lib/general/gr_count_bits.cc93
-rw-r--r--gnuradio-core/src/lib/general/gr_simple_correlator.cc237
-rw-r--r--gnuradio-core/src/lib/general/gr_simple_correlator.h111
-rw-r--r--gr-blocks/include/blocks/CMakeLists.txt1
-rw-r--r--gr-blocks/include/blocks/count_bits.h (renamed from gnuradio-core/src/lib/general/gr_count_bits.h)25
-rw-r--r--gr-blocks/lib/CMakeLists.txt1
-rw-r--r--gr-blocks/lib/count_bits.cc78
-rw-r--r--gr-digital/grc/digital_block_tree.xml1
-rw-r--r--gr-digital/grc/digital_simple_correlator.xml (renamed from grc/blocks/gr_simple_correlator.xml)6
-rw-r--r--gr-digital/include/digital/CMakeLists.txt1
-rw-r--r--gr-digital/include/digital/simple_correlator.h (renamed from gnuradio-core/src/lib/general/gr_simple_correlator.i)33
-rw-r--r--gr-digital/lib/CMakeLists.txt1
-rw-r--r--gr-digital/lib/correlate_access_code_bb_impl.cc4
-rw-r--r--gr-digital/lib/correlate_access_code_tag_bb_impl.cc4
-rw-r--r--gr-digital/lib/packet_sink_impl.cc4
-rw-r--r--gr-digital/lib/simple_correlator_impl.cc237
-rw-r--r--gr-digital/lib/simple_correlator_impl.h102
-rwxr-xr-xgr-digital/python/qa_simple_correlator.py64
-rw-r--r--gr-digital/swig/digital_swig.i3
-rw-r--r--gr-pager/lib/CMakeLists.txt2
-rw-r--r--gr-pager/lib/flex_sync_impl.cc6
-rwxr-xr-xgr-qtgui/apps/gr_time_plot_b2
-rw-r--r--gr-qtgui/apps/plot_form.py16
-rw-r--r--grc/blocks/block_tree.xml2
28 files changed, 559 insertions, 491 deletions
diff --git a/docs/sphinx/source/gr/index.rst b/docs/sphinx/source/gr/index.rst
index 6d09b861ef..d946d46879 100644
--- a/docs/sphinx/source/gr/index.rst
+++ b/docs/sphinx/source/gr/index.rst
@@ -127,13 +127,6 @@ Information Coding and Decoding
gnuradio.gr.fake_channel_encoder_pp
gnuradio.gr.fake_channel_decoder_pp
-Synchronization
-^^^^^^^^^^^^^^^
-
-.. autosummary::
- :nosignatures:
-
- gnuradio.gr.simple_correlator
Type Conversions
^^^^^^^^^^^^^^^^
diff --git a/docs/sphinx/source/gr/sync_blk.rst b/docs/sphinx/source/gr/sync_blk.rst
deleted file mode 100644
index d5e3c3d7c5..0000000000
--- a/docs/sphinx/source/gr/sync_blk.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-gnuradio.gr: Synchronization
-============================
-
-.. autooldblock:: gnuradio.gr.simple_correlator
diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt
index 26dab910c9..c562224009 100644
--- a/gnuradio-core/src/lib/general/CMakeLists.txt
+++ b/gnuradio-core/src/lib/general/CMakeLists.txt
@@ -69,7 +69,6 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_BINARY_DIR}/gr_constants.cc)
########################################################################
list(APPEND gnuradio_core_sources
${CMAKE_CURRENT_SOURCE_DIR}/gr_circular_file.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/gr_count_bits.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_fast_atan2f.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_misc.cc
@@ -102,7 +101,6 @@ install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/gr_core_api.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_circular_file.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_constants.h
- ${CMAKE_CURRENT_SOURCE_DIR}/gr_count_bits.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_expj.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt_nco.h
@@ -174,7 +172,6 @@ set(gr_core_general_triple_threats
gr_remez
gr_rms_cf
gr_rms_ff
- gr_simple_correlator
gr_skiphead
gr_stretch_ff
gr_test
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index e379c40867..53dcac6fb6 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -32,7 +32,6 @@
#include <gr_check_counting_s.h>
#include <gr_lfsr_32k_source_s.h>
#include <gr_check_lfsr_32k_s.h>
-#include <gr_simple_correlator.h>
#include <gr_align_on_samplenumbers_ss.h>
#include <gr_complex_to_xxx.h>
#include <gr_complex_to_interleaved_short.h>
@@ -82,7 +81,6 @@
%include "gr_check_counting_s.i"
%include "gr_lfsr_32k_source_s.i"
%include "gr_check_lfsr_32k_s.i"
-%include "gr_simple_correlator.i"
%include "gr_align_on_samplenumbers_ss.i"
%include "gr_complex_to_xxx.i"
%include "gr_complex_to_interleaved_short.i"
diff --git a/gnuradio-core/src/lib/general/gr_count_bits.cc b/gnuradio-core/src/lib/general/gr_count_bits.cc
deleted file mode 100644
index 4776fe61a9..0000000000
--- a/gnuradio-core/src/lib/general/gr_count_bits.cc
+++ /dev/null
@@ -1,93 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003 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 <gr_count_bits.h>
-
-/*
- * these are slow and obvious. If you need something faster, fix these
- */
-
-// return number of set bits in the low 8 bits of x
-unsigned int
-gr_count_bits8 (unsigned int x)
-{
- int count = 0;
-
- for (int i = 0; i < 8; i++)
- if (x & (1 << i))
- count++;
-
- return count;
-}
-
-// return number of set bits in the low 16 bits of x
-unsigned int
-gr_count_bits16 (unsigned int x)
-{
- int count = 0;
-
- for (int i = 0; i < 16; i++)
- if (x & (1 << i))
- count++;
-
- return count;
-
-}
-
-
-#if 0 // slow and obvious
-
-// return number of set bits in the low 32 bits of x
-unsigned int
-gr_count_bits32 (unsigned int x)
-{
- int count = 0;
-
- for (int i = 0; i < 32; i++)
- if (x & (1 << i))
- count++;
-
- return count;
-}
-
-#else // fast and not so obvious
-
-// return number of set bits in the low 32 bits of x
-unsigned int
-gr_count_bits32 (unsigned int x)
-{
- unsigned res = (x & 0x55555555) + ((x >> 1) & 0x55555555);
- res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
- res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
- res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
- return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
-}
-
-#endif
-
-
-// return number of set bits in the low 64 bits of x
-unsigned int
-gr_count_bits64 (unsigned long long x)
-{
- return gr_count_bits32((x >> 32) & 0xffffffff) + gr_count_bits32(x & 0xffffffff);
-}
diff --git a/gnuradio-core/src/lib/general/gr_simple_correlator.cc b/gnuradio-core/src/lib/general/gr_simple_correlator.cc
deleted file mode 100644
index b9209e74f0..0000000000
--- a/gnuradio-core/src/lib/general/gr_simple_correlator.cc
+++ /dev/null
@@ -1,237 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2010 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_simple_correlator.h>
-#include <gr_simple_framer_sync.h>
-#include <gr_io_signature.h>
-#include <assert.h>
-#include <stdexcept>
-#include <gr_count_bits.h>
-#include <string.h>
-#include <cstdio>
-
-
-static const int THRESHOLD = 3;
-
-gr_simple_correlator_sptr
-gr_make_simple_correlator (int payload_bytesize)
-{
- return gnuradio::get_initial_sptr(new gr_simple_correlator (payload_bytesize));
-}
-
-gr_simple_correlator::gr_simple_correlator (int payload_bytesize)
- : gr_block ("simple_correlator",
- gr_make_io_signature (1, 1, sizeof (float)),
- gr_make_io_signature (1, 1, sizeof (unsigned char))),
- d_payload_bytesize (payload_bytesize),
- d_state (ST_LOOKING), d_osi (0),
- d_bblen ((payload_bytesize + GRSF_PAYLOAD_OVERHEAD) * GRSF_BITS_PER_BYTE),
- d_bitbuf (new unsigned char [d_bblen]),
- d_pktbuf (new unsigned char [d_bblen/GRSF_BITS_PER_BYTE]),
- d_bbi (0)
-{
- d_avbi = 0;
- d_accum = 0.0;
- d_avg = 0.0;
- for (int i = 0; i < AVG_PERIOD; i++)
- d_avgbuf[i] = 0.0;
-
-#ifdef DEBUG_SIMPLE_CORRELATOR
- d_debug_fp = fopen("corr.log", "w");
-#endif
- enter_looking ();
-
-}
-
-gr_simple_correlator::~gr_simple_correlator ()
-{
-#ifdef DEBUG_SIMPLE_CORRELATOR
- fclose(d_debug_fp);
-#endif
- delete [] d_bitbuf;
- delete [] d_pktbuf;
-}
-
-
-void
-gr_simple_correlator::enter_looking ()
-{
- fflush (stdout);
- // fprintf (stderr, ">>> enter_looking\n");
- d_state = ST_LOOKING;
- for (int i = 0; i < OVERSAMPLE; i++)
- d_shift_reg[i] = 0;
- d_osi = 0;
-
- d_avbi = 0;
- d_avg = d_avg * 0.5;
- d_accum = 0;
- for (int i = 0; i < AVG_PERIOD; i++)
- d_avgbuf[i] = 0.0;
-}
-
-void
-gr_simple_correlator::enter_under_threshold ()
-{
- fflush (stdout);
- // fprintf (stderr, ">>> enter_under_threshold\n");
- d_state = ST_UNDER_THRESHOLD;
- d_transition_osi = d_osi;
-}
-
-void
-gr_simple_correlator::enter_locked ()
-{
- d_state = ST_LOCKED;
- int delta = sub_index (d_osi, d_transition_osi);
- d_center_osi = add_index (d_transition_osi, delta/2);
- d_center_osi = add_index (d_center_osi, 3); // FIXME
- d_bbi = 0;
- fflush (stdout);
- // fprintf (stderr, ">>> enter_locked d_center_osi = %d\n", d_center_osi);
-
- d_avg = std::max(-1.0, std::min(1.0, d_accum * (1.0/AVG_PERIOD)));
- // fprintf(stderr, ">>> enter_locked d_avg = %g\n", d_avg);
-}
-
-static void
-packit (unsigned char *pktbuf, const unsigned char *bitbuf, int bitcount)
-{
- for (int i = 0; i < bitcount; i += 8){
- int t = bitbuf[i+0] & 0x1;
- t = (t << 1) | (bitbuf[i+1] & 0x1);
- t = (t << 1) | (bitbuf[i+2] & 0x1);
- t = (t << 1) | (bitbuf[i+3] & 0x1);
- t = (t << 1) | (bitbuf[i+4] & 0x1);
- t = (t << 1) | (bitbuf[i+5] & 0x1);
- t = (t << 1) | (bitbuf[i+6] & 0x1);
- t = (t << 1) | (bitbuf[i+7] & 0x1);
- *pktbuf++ = t;
- }
-}
-
-void
-gr_simple_correlator::update_avg(float x)
-{
- d_accum -= d_avgbuf[d_avbi];
- d_avgbuf[d_avbi] = x;
- d_accum += x;
- d_avbi = (d_avbi + 1) & (AVG_PERIOD-1);
-}
-
-
-int
-gr_simple_correlator::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];
- unsigned char *out = (unsigned char *) output_items[0];
-
-
- int n = 0;
- int nin = ninput_items[0];
- int decision;
- int hamming_dist;
-
-#ifdef DEBUG_SIMPLE_CORRELATOR
- struct debug_data {
- float raw_data;
- float sampled;
- float enter_locked;
- } debug_data;
-#endif
-
- while (n < nin){
-
-#ifdef DEBUG_SIMPLE_CORRELATOR
- debug_data.raw_data = in[n];
- debug_data.sampled = 0.0;
- debug_data.enter_locked = 0.0;
-#endif
-
- switch (d_state){
-
- case ST_LOCKED:
- if (d_osi == d_center_osi){
-
-#ifdef DEBUG_SIMPLE_CORRELATOR
- debug_data.sampled = 1.0;
-#endif
- decision = slice (in[n]);
-
- d_bitbuf[d_bbi] = decision;
- d_bbi++;
- if (d_bbi >= d_bblen){
- // printf ("got whole packet\n");
- packit (d_pktbuf, d_bitbuf, d_bbi);
- printf ("seqno %3d\n", d_pktbuf[0]);
- memcpy (out, &d_pktbuf[GRSF_PAYLOAD_OVERHEAD], d_payload_bytesize);
- enter_looking ();
- consume_each (n + 1);
- return d_payload_bytesize;
- }
- }
- break;
-
- case ST_LOOKING:
- case ST_UNDER_THRESHOLD:
- update_avg(in[n]);
- decision = slice (in[n]);
- d_shift_reg[d_osi] = (d_shift_reg[d_osi] << 1) | decision;
-
- hamming_dist = gr_count_bits64 (d_shift_reg[d_osi] ^ GRSF_SYNC);
- // printf ("%2d %d\n", hamming_dist, d_osi);
-
- if (d_state == ST_LOOKING && hamming_dist <= THRESHOLD){
- // We're seeing a good PN code, remember location
- enter_under_threshold ();
- }
- else if (d_state == ST_UNDER_THRESHOLD && hamming_dist > THRESHOLD){
- // no longer seeing good PN code, compute center of goodness
- enter_locked ();
-#ifdef DEBUG_SIMPLE_CORRELATOR
- debug_data.enter_locked = 1.0;
-#endif
- }
- break;
-
- default:
- assert (0);
- }
-
-#ifdef DEBUG_SIMPLE_CORRELATOR
- fwrite(&debug_data, sizeof (debug_data), 1, d_debug_fp);
-#endif
-
- d_osi = add_index (d_osi, 1);
- n++;
- }
-
- consume_each (n);
- return 0;
-}
diff --git a/gnuradio-core/src/lib/general/gr_simple_correlator.h b/gnuradio-core/src/lib/general/gr_simple_correlator.h
deleted file mode 100644
index 37d00c125e..0000000000
--- a/gnuradio-core/src/lib/general/gr_simple_correlator.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004 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_SIMPLE_CORRELATOR_H
-#define INCLUDED_GR_SIMPLE_CORRELATOR_H
-
-#include <gr_core_api.h>
-#include <gr_block.h>
-#include <assert.h>
-
-//#define DEBUG_SIMPLE_CORRELATOR
-
-class gr_simple_correlator;
-typedef boost::shared_ptr<gr_simple_correlator> gr_simple_correlator_sptr;
-
-GR_CORE_API gr_simple_correlator_sptr gr_make_simple_correlator (int payload_bytesize);
-
-/*!
- * \brief inverse of gr_simple_framer (more or less)
- * \ingroup sync_blk
- */
-class GR_CORE_API gr_simple_correlator : public gr_block
-{
- static const int OVERSAMPLE = 8;
- enum state_t { ST_LOOKING, ST_UNDER_THRESHOLD, ST_LOCKED };
-
- int d_payload_bytesize;
- state_t d_state;
- unsigned int d_osi; // over sample index [0,OVERSAMPLE-1]
- unsigned int d_transition_osi; // first index where Hamming dist < thresh
- unsigned int d_center_osi; // center of bit
- unsigned long long int d_shift_reg[OVERSAMPLE];
- int d_bblen; // length of bitbuf
- unsigned char *d_bitbuf; // demodulated bits
- unsigned char *d_pktbuf; // temp packet buf
- int d_bbi; // bitbuf index
-
- static const int AVG_PERIOD = 512; // must be power of 2 (for freq offset correction)
- int d_avbi;
- float d_avgbuf[AVG_PERIOD];
- float d_avg;
- float d_accum;
-
-#ifdef DEBUG_SIMPLE_CORRELATOR
- FILE *d_debug_fp; // binary log file
-#endif
-
- friend GR_CORE_API gr_simple_correlator_sptr gr_make_simple_correlator (int payload_bytesize);
- gr_simple_correlator (int payload_bytesize);
-
-
- inline int slice (float x)
- {
- return x >= d_avg ? 1 : 0;
- }
-
- void update_avg(float x);
-
- void enter_locked ();
- void enter_under_threshold ();
- void enter_looking ();
-
- static int add_index (int a, int b)
- {
- int t = a + b;
- if (t >= OVERSAMPLE)
- t -= OVERSAMPLE;
- assert (t >= 0 && t < OVERSAMPLE);
- return t;
- }
-
- static int sub_index (int a, int b)
- {
- int t = a - b;
- if (t < 0)
- t += OVERSAMPLE;
- assert (t >= 0 && t < OVERSAMPLE);
- return t;
- }
-
-
- public:
- ~gr_simple_correlator ();
-
- int general_work (int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-
-#endif /* INCLUDED_GR_SIMPLE_CORRELATOR_H */
diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt
index 0459097b0d..37790b7cfa 100644
--- a/gr-blocks/include/blocks/CMakeLists.txt
+++ b/gr-blocks/include/blocks/CMakeLists.txt
@@ -89,6 +89,7 @@ add_custom_target(blocks_generated_includes DEPENDS
install(FILES
${generated_includes}
api.h
+ count_bits.h
add_ff.h
char_to_float.h
char_to_short.h
diff --git a/gnuradio-core/src/lib/general/gr_count_bits.h b/gr-blocks/include/blocks/count_bits.h
index 76d0173eb5..ceb882f67b 100644
--- a/gnuradio-core/src/lib/general/gr_count_bits.h
+++ b/gr-blocks/include/blocks/count_bits.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2003 Free Software Foundation, Inc.
+ * Copyright 2003,2013 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -23,11 +23,24 @@
#ifndef _GR_COUNT_BITS_H_
#define _GR_COUNT_BITS_H_
-#include <gr_core_api.h>
+#include <blocks/api.h>
-GR_CORE_API unsigned int gr_count_bits8(unsigned int x); // return number of set bits in the low 8 bits of x
-GR_CORE_API unsigned int gr_count_bits16(unsigned int x); // return number of set bits in the low 16 bits of x
-GR_CORE_API unsigned int gr_count_bits32(unsigned int x); // return number of set bits in the low 32 bits of x
-GR_CORE_API unsigned int gr_count_bits64(unsigned long long int x);
+namespace gr {
+ namespace blocks {
+
+ //! return number of set bits in the low 8 bits of x
+ BLOCKS_API unsigned int count_bits8(unsigned int x);
+
+ //! return number of set bits in the low 16 bits of x
+ BLOCKS_API unsigned int count_bits16(unsigned int x);
+
+ //! return number of set bits in the low 32 bits of x
+ BLOCKS_API unsigned int count_bits32(unsigned int x);
+
+ //! return number of set bits in a 64-bit word
+ BLOCKS_API unsigned int count_bits64(unsigned long long int x);
+
+ } /* namespace blocks */
+} /* namespace gr */
#endif /* _GR_COUNT_BITS_H_ */
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index 30eab7b751..560a55d573 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -126,6 +126,7 @@ link_directories(${Boost_LIBRARY_DIRS})
########################################################################
list(APPEND gr_blocks_sources
${generated_sources}
+ count_bits.cc
add_ff_impl.cc
char_to_float_impl.cc
char_to_short_impl.cc
diff --git a/gr-blocks/lib/count_bits.cc b/gr-blocks/lib/count_bits.cc
new file mode 100644
index 0000000000..167396b575
--- /dev/null
+++ b/gr-blocks/lib/count_bits.cc
@@ -0,0 +1,78 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2003,2013 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 <blocks/count_bits.h>
+
+/*
+ * these are slow and obvious. If you need something faster, fix these
+ *
+ * Can probably replace with VOLK's popcount
+ */
+
+namespace gr {
+ namespace blocks {
+
+ unsigned int
+ count_bits8(unsigned int x)
+ {
+ int count = 0;
+
+ for(int i = 0; i < 8; i++) {
+ if(x & (1 << i))
+ count++;
+ }
+
+ return count;
+ }
+
+ unsigned int
+ count_bits16(unsigned int x)
+ {
+ int count = 0;
+
+ for(int i = 0; i < 16; i++) {
+ if(x & (1 << i))
+ count++;
+ }
+
+ return count;
+ }
+
+ unsigned int
+ count_bits32(unsigned int x)
+ {
+ unsigned res = (x & 0x55555555) + ((x >> 1) & 0x55555555);
+ res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+ res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
+ res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
+ return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
+ }
+
+ unsigned int
+ count_bits64(unsigned long long x)
+ {
+ return count_bits32((x >> 32) & 0xffffffff) + \
+ count_bits32(x & 0xffffffff);
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-digital/grc/digital_block_tree.xml b/gr-digital/grc/digital_block_tree.xml
index f8bb3871d6..04c679d355 100644
--- a/gr-digital/grc/digital_block_tree.xml
+++ b/gr-digital/grc/digital_block_tree.xml
@@ -55,6 +55,7 @@
<block>digital_packet_sink</block>
<block>digital_pn_correlator_cc</block>
<block>digital_simple_framer</block>
+ <block>digital_simple_correlator</block>
</cat>
<cat>
<name>Probes</name>
diff --git a/grc/blocks/gr_simple_correlator.xml b/gr-digital/grc/digital_simple_correlator.xml
index 820523a644..3b70e59b12 100644
--- a/grc/blocks/gr_simple_correlator.xml
+++ b/gr-digital/grc/digital_simple_correlator.xml
@@ -6,9 +6,9 @@
-->
<block>
<name>Simple Correlator</name>
- <key>gr_simple_correlator</key>
- <import>from gnuradio import gr</import>
- <make>gr.simple_correlator($payload_bytesize)</make>
+ <key>digital_simple_correlator</key>
+ <import>from gnuradio import digital</import>
+ <make>digital.simple_correlator($payload_bytesize)</make>
<param>
<name>Payload Byte Size</name>
<key>payload_bytesize</key>
diff --git a/gr-digital/include/digital/CMakeLists.txt b/gr-digital/include/digital/CMakeLists.txt
index 0cc043ed17..11cab88337 100644
--- a/gr-digital/include/digital/CMakeLists.txt
+++ b/gr-digital/include/digital/CMakeLists.txt
@@ -121,6 +121,7 @@ install(FILES
probe_mpsk_snr_est_c.h
scrambler_bb.h
simple_framer.h
+ simple_correlator.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/digital
COMPONENT "digital_devel"
)
diff --git a/gnuradio-core/src/lib/general/gr_simple_correlator.i b/gr-digital/include/digital/simple_correlator.h
index 24d133072f..b75dc24765 100644
--- a/gnuradio-core/src/lib/general/gr_simple_correlator.i
+++ b/gr-digital/include/digital/simple_correlator.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2013 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,12 +20,29 @@
* Boston, MA 02110-1301, USA.
*/
-GR_SWIG_BLOCK_MAGIC(gr,simple_correlator);
+#ifndef INCLUDED_GR_SIMPLE_CORRELATOR_H
+#define INCLUDED_GR_SIMPLE_CORRELATOR_H
-gr_simple_correlator_sptr gr_make_simple_correlator (int payload_bytesize);
+#include <digital/api.h>
+#include <gr_block.h>
-class gr_simple_correlator : public gr_block
-{
- private:
- gr_simple_correlator (int payload_bytesize);
-};
+namespace gr {
+ namespace digital {
+
+ /*!
+ * \brief inverse of simple_framer (more or less)
+ * \ingroup sync_blk
+ */
+ class DIGITAL_API simple_correlator : virtual public gr_block
+ {
+ public:
+ // gr::digital::simple_correlator::sptr
+ typedef boost::shared_ptr<simple_correlator> sptr;
+
+ static sptr make(int payload_bytesize);
+ };
+
+ } /* namespace digital */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_SIMPLE_CORRELATOR_H */
diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt
index de99ae8c0b..b4c267e8c3 100644
--- a/gr-digital/lib/CMakeLists.txt
+++ b/gr-digital/lib/CMakeLists.txt
@@ -152,6 +152,7 @@ list(APPEND digital_sources
probe_mpsk_snr_est_c_impl.cc
scrambler_bb_impl.cc
simple_framer_impl.cc
+ simple_correlator_impl.cc
)
list(APPEND digital_libs
diff --git a/gr-digital/lib/correlate_access_code_bb_impl.cc b/gr-digital/lib/correlate_access_code_bb_impl.cc
index 4e1131afda..0ada203c65 100644
--- a/gr-digital/lib/correlate_access_code_bb_impl.cc
+++ b/gr-digital/lib/correlate_access_code_bb_impl.cc
@@ -26,7 +26,7 @@
#include "correlate_access_code_bb_impl.h"
#include <gr_io_signature.h>
-#include <gr_count_bits.h>
+#include <blocks/count_bits.h>
#include <stdexcept>
#include <cstdio>
@@ -104,7 +104,7 @@ namespace gr {
int new_flag = 0;
wrong_bits = (d_data_reg ^ d_access_code) & d_mask;
- nwrong = gr_count_bits64(wrong_bits);
+ nwrong = gr::blocks::count_bits64(wrong_bits);
// test for access code with up to threshold errors
new_flag = (nwrong <= d_threshold);
diff --git a/gr-digital/lib/correlate_access_code_tag_bb_impl.cc b/gr-digital/lib/correlate_access_code_tag_bb_impl.cc
index 1ff27f02a5..8ac601bb9d 100644
--- a/gr-digital/lib/correlate_access_code_tag_bb_impl.cc
+++ b/gr-digital/lib/correlate_access_code_tag_bb_impl.cc
@@ -27,7 +27,7 @@
#include "correlate_access_code_tag_bb_impl.h"
#include <gr_io_signature.h>
#include <stdexcept>
-#include <gr_count_bits.h>
+#include <blocks/count_bits.h>
#include <cstdio>
#include <iostream>
@@ -109,7 +109,7 @@ namespace gr {
int new_flag = 0;
wrong_bits = (d_data_reg ^ d_access_code) & d_mask;
- nwrong = gr_count_bits64(wrong_bits);
+ nwrong = gr::blocks::count_bits64(wrong_bits);
// test for access code with up to threshold errors
new_flag = (nwrong <= d_threshold);
diff --git a/gr-digital/lib/packet_sink_impl.cc b/gr-digital/lib/packet_sink_impl.cc
index 0d1281b03b..1d79b3d717 100644
--- a/gr-digital/lib/packet_sink_impl.cc
+++ b/gr-digital/lib/packet_sink_impl.cc
@@ -32,7 +32,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <stdexcept>
-#include <gr_count_bits.h>
+#include <blocks/count_bits.h>
#include <string.h>
namespace gr {
@@ -130,7 +130,7 @@ static const int DEFAULT_THRESHOLD = 12;
d_shift_reg = d_shift_reg << 1;
// Compute popcnt of putative sync vector
- if(gr_count_bits64(d_shift_reg ^ d_sync_vector) <= d_threshold) {
+ if(gr::blocks::count_bits64(d_shift_reg ^ d_sync_vector) <= d_threshold) {
// Found it, set up for header decode
enter_have_sync();
break;
diff --git a/gr-digital/lib/simple_correlator_impl.cc b/gr-digital/lib/simple_correlator_impl.cc
new file mode 100644
index 0000000000..6b35b4cf0d
--- /dev/null
+++ b/gr-digital/lib/simple_correlator_impl.cc
@@ -0,0 +1,237 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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 "simple_correlator_impl.h"
+#include <digital/simple_framer_sync.h>
+#include <gr_io_signature.h>
+#include <blocks/count_bits.h>
+#include <assert.h>
+#include <stdexcept>
+#include <string.h>
+#include <cstdio>
+
+namespace gr {
+ namespace digital {
+
+ static const int THRESHOLD = 3;
+
+ simple_correlator::sptr
+ simple_correlator::make(int payload_bytesize)
+ {
+ return gnuradio::get_initial_sptr
+ (new simple_correlator_impl(payload_bytesize));
+ }
+
+ simple_correlator_impl::simple_correlator_impl(int payload_bytesize)
+ : gr_block("simple_correlator",
+ gr_make_io_signature(1, 1, sizeof(float)),
+ gr_make_io_signature(1, 1, sizeof(unsigned char))),
+ d_payload_bytesize(payload_bytesize),
+ d_state(ST_LOOKING), d_osi(0),
+ d_bblen((payload_bytesize + GRSF_PAYLOAD_OVERHEAD) * GRSF_BITS_PER_BYTE),
+ d_bitbuf(new unsigned char[d_bblen]),
+ d_pktbuf(new unsigned char[d_bblen/GRSF_BITS_PER_BYTE]),
+ d_bbi(0)
+ {
+ d_avbi = 0;
+ d_accum = 0.0;
+ d_avg = 0.0;
+ for(int i = 0; i < AVG_PERIOD; i++)
+ d_avgbuf[i] = 0.0;
+
+#ifdef DEBUG_SIMPLE_CORRELATOR
+ d_debug_fp = fopen("corr.log", "w");
+#endif
+ enter_looking();
+ }
+
+ simple_correlator_impl::~simple_correlator_impl()
+ {
+#ifdef DEBUG_SIMPLE_CORRELATOR
+ fclose(d_debug_fp);
+#endif
+ delete [] d_bitbuf;
+ delete [] d_pktbuf;
+ }
+
+ void
+ simple_correlator_impl::enter_looking()
+ {
+ fflush(stdout);
+ // fprintf(stderr, ">>> enter_looking\n");
+ d_state = ST_LOOKING;
+ for(int i = 0; i < OVERSAMPLE; i++)
+ d_shift_reg[i] = 0;
+ d_osi = 0;
+
+ d_avbi = 0;
+ d_avg = d_avg * 0.5;
+ d_accum = 0;
+ for(int i = 0; i < AVG_PERIOD; i++)
+ d_avgbuf[i] = 0.0;
+ }
+
+ void
+ simple_correlator_impl::enter_under_threshold()
+ {
+ fflush(stdout);
+ // fprintf(stderr, ">>> enter_under_threshold\n");
+ d_state = ST_UNDER_THRESHOLD;
+ d_transition_osi = d_osi;
+ }
+
+ void
+ simple_correlator_impl::enter_locked()
+ {
+ d_state = ST_LOCKED;
+ int delta = sub_index(d_osi, d_transition_osi);
+ d_center_osi = add_index(d_transition_osi, delta/2);
+ //d_center_osi = add_index(d_center_osi, 3); // FIXME
+ d_bbi = 0;
+ fflush(stdout);
+ // fprintf(stderr, ">>> enter_locked d_center_osi = %d\n", d_center_osi);
+
+ d_avg = std::max(-1.0, std::min(1.0, d_accum * (1.0/AVG_PERIOD)));
+ // fprintf(stderr, ">>> enter_locked d_avg = %g\n", d_avg);
+ }
+
+ static void
+ packit(unsigned char *pktbuf, const unsigned char *bitbuf, int bitcount)
+ {
+ for(int i = 0; i < bitcount; i += 8) {
+ int t = bitbuf[i+0] & 0x1;
+ t = (t << 1) | (bitbuf[i+1] & 0x1);
+ t = (t << 1) | (bitbuf[i+2] & 0x1);
+ t = (t << 1) | (bitbuf[i+3] & 0x1);
+ t = (t << 1) | (bitbuf[i+4] & 0x1);
+ t = (t << 1) | (bitbuf[i+5] & 0x1);
+ t = (t << 1) | (bitbuf[i+6] & 0x1);
+ t = (t << 1) | (bitbuf[i+7] & 0x1);
+ *pktbuf++ = t;
+ }
+ }
+
+ void
+ simple_correlator_impl::update_avg(float x)
+ {
+ d_accum -= d_avgbuf[d_avbi];
+ d_avgbuf[d_avbi] = x;
+ d_accum += x;
+ d_avbi = (d_avbi + 1) & (AVG_PERIOD-1);
+ }
+
+ int
+ simple_correlator_impl::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];
+ unsigned char *out = (unsigned char*)output_items[0];
+
+ int n = 0;
+ int nin = ninput_items[0];
+ int decision;
+ int hamming_dist;
+
+#ifdef DEBUG_SIMPLE_CORRELATOR
+ struct debug_data {
+ float raw_data;
+ float sampled;
+ float enter_locked;
+ } debug_data;
+#endif
+
+ while(n < nin) {
+
+#ifdef DEBUG_SIMPLE_CORRELATOR
+ debug_data.raw_data = in[n];
+ debug_data.sampled = 0.0;
+ debug_data.enter_locked = 0.0;
+#endif
+
+ switch(d_state) {
+ case ST_LOCKED:
+ if(d_osi == d_center_osi) {
+
+#ifdef DEBUG_SIMPLE_CORRELATOR
+ debug_data.sampled = 1.0;
+#endif
+ decision = slice(in[n]);
+
+ d_bitbuf[d_bbi] = decision;
+ d_bbi++;
+ if(d_bbi >= d_bblen) {
+ // printf("got whole packet\n");
+ packit(d_pktbuf, d_bitbuf, d_bbi);
+ //printf("seqno %3d\n", d_pktbuf[0]);
+ memcpy(out, &d_pktbuf[GRSF_PAYLOAD_OVERHEAD], d_payload_bytesize);
+ enter_looking();
+ consume_each(n + 1);
+ return d_payload_bytesize;
+ }
+ }
+ break;
+
+ case ST_LOOKING:
+ case ST_UNDER_THRESHOLD:
+ update_avg(in[n]);
+ decision = slice(in[n]);
+ d_shift_reg[d_osi] = (d_shift_reg[d_osi] << 1) | decision;
+
+ hamming_dist = gr::blocks::count_bits64(d_shift_reg[d_osi] ^ GRSF_SYNC);
+ // printf("%2d %d\n", hamming_dist, d_osi);
+
+ if(d_state == ST_LOOKING && hamming_dist <= THRESHOLD) {
+ // We're seeing a good PN code, remember location
+ enter_under_threshold();
+ }
+ else if(d_state == ST_UNDER_THRESHOLD && hamming_dist > THRESHOLD) {
+ // no longer seeing good PN code, compute center of goodness
+ enter_locked();
+#ifdef DEBUG_SIMPLE_CORRELATOR
+ debug_data.enter_locked = 1.0;
+#endif
+ }
+ break;
+ default:
+ assert(0);
+ }
+
+#ifdef DEBUG_SIMPLE_CORRELATOR
+ fwrite(&debug_data, sizeof(debug_data), 1, d_debug_fp);
+#endif
+
+ d_osi = add_index(d_osi, 1);
+ n++;
+ }
+
+ consume_each(n);
+ return 0;
+ }
+
+ } /* namespace digital */
+} /* namespace gr */
diff --git a/gr-digital/lib/simple_correlator_impl.h b/gr-digital/lib/simple_correlator_impl.h
new file mode 100644
index 0000000000..fe324131fd
--- /dev/null
+++ b/gr-digital/lib/simple_correlator_impl.h
@@ -0,0 +1,102 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2013 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_SIMPLE_CORRELATOR_IMPL_H
+#define INCLUDED_GR_SIMPLE_CORRELATOR_IMPL_H
+
+#include <digital/simple_correlator.h>
+
+//#define DEBUG_SIMPLE_CORRELATOR
+
+namespace gr {
+ namespace digital {
+
+ class simple_correlator_impl : public simple_correlator
+ {
+ private:
+ static const int OVERSAMPLE = 8;
+ enum state_t { ST_LOOKING, ST_UNDER_THRESHOLD, ST_LOCKED };
+
+ int d_payload_bytesize;
+ state_t d_state;
+ unsigned int d_osi; // over sample index [0,OVERSAMPLE-1]
+ unsigned int d_transition_osi; // first index where Hamming dist < thresh
+ unsigned int d_center_osi; // center of bit
+ unsigned long long int d_shift_reg[OVERSAMPLE];
+ int d_bblen; // length of bitbuf
+ unsigned char *d_bitbuf; // demodulated bits
+ unsigned char *d_pktbuf; // temp packet buf
+ int d_bbi; // bitbuf index
+
+ static const int AVG_PERIOD = 512; // must be power of 2 (for freq offset correction)
+ int d_avbi;
+ float d_avgbuf[AVG_PERIOD];
+ float d_avg;
+ float d_accum;
+
+#ifdef DEBUG_SIMPLE_CORRELATOR
+ FILE *d_debug_fp; // binary log file
+#endif
+
+ inline int slice (float x)
+ {
+ return x >= d_avg ? 1 : 0;
+ }
+
+ void update_avg(float x);
+
+ void enter_locked ();
+ void enter_under_threshold ();
+ void enter_looking ();
+
+ static int add_index (int a, int b)
+ {
+ int t = a + b;
+ if(t >= OVERSAMPLE)
+ t -= OVERSAMPLE;
+ assert(t >= 0 && t < OVERSAMPLE);
+ return t;
+ }
+
+ static int sub_index (int a, int b)
+ {
+ int t = a - b;
+ if(t < 0)
+ t += OVERSAMPLE;
+ assert(t >= 0 && t < OVERSAMPLE);
+ return t;
+ }
+
+ public:
+ simple_correlator_impl(int payload_bytesize);
+ ~simple_correlator_impl();
+
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace digital */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_SIMPLE_CORRELATOR_IMPL_H */
diff --git a/gr-digital/python/qa_simple_correlator.py b/gr-digital/python/qa_simple_correlator.py
new file mode 100755
index 0000000000..292dfd69fc
--- /dev/null
+++ b/gr-digital/python/qa_simple_correlator.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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 blocks_swig as blocks
+import filter_swig as filter
+import digital_swig as digital
+
+class test_simple_correlator(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_00(self):
+ expected_result = (
+ 0x00, 0x11, 0x22, 0x33,
+ 0x44, 0x55, 0x66, 0x77,
+ 0x88, 0x99, 0xaa, 0xbb,
+ 0xcc, 0xdd, 0xee, 0xff)
+
+ # Filter taps to expand the data to oversample by 8
+ # Just using a RRC for some basic filter shape
+ taps = filter.firdes.root_raised_cosine(8, 8, 1.0, 0.5, 21)
+
+ src = gr.vector_source_b(expected_result)
+ frame = digital.simple_framer(4)
+ unpack = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
+ expand = filter.interp_fir_filter_fff(8, taps)
+ b2f = blocks.char_to_float()
+ mult2 = blocks.multiply_const_ff(2)
+ sub1 = blocks.add_const_ff(-1)
+ op = digital.simple_correlator(4)
+ dst = gr.vector_sink_b()
+ self.tb.connect(src, frame, unpack, b2f, mult2, sub1, expand)
+ self.tb.connect(expand, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+
+ self.assertEqual(expected_result, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_simple_correlator, "test_simple_correlator.xml")
diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i
index 9cb78dd0dc..155efddf75 100644
--- a/gr-digital/swig/digital_swig.i
+++ b/gr-digital/swig/digital_swig.i
@@ -85,6 +85,7 @@
#include "digital/probe_mpsk_snr_est_c.h"
#include "digital/scrambler_bb.h"
#include "digital/simple_framer.h"
+#include "digital/simple_correlator.h"
%}
%include "digital/metric_type.h"
@@ -136,6 +137,7 @@
%include "digital/probe_mpsk_snr_est_c.h"
%include "digital/scrambler_bb.h"
%include "digital/simple_framer.h"
+%include "digital/simple_correlator.h"
GR_SWIG_BLOCK_MAGIC2(digital, additive_scrambler_bb);
GR_SWIG_BLOCK_MAGIC2(digital, binary_slicer_fb);
@@ -181,6 +183,7 @@ GR_SWIG_BLOCK_MAGIC2(digital, probe_density_b);
GR_SWIG_BLOCK_MAGIC2(digital, probe_mpsk_snr_est_c);
GR_SWIG_BLOCK_MAGIC2(digital, scrambler_bb);
GR_SWIG_BLOCK_MAGIC2(digital, simple_framer);
+GR_SWIG_BLOCK_MAGIC2(digital, simple_correlator);
GR_SWIG_BLOCK_MAGIC_FACTORY(digital, cpmmod_bc, gmskmod_bc);
diff --git a/gr-pager/lib/CMakeLists.txt b/gr-pager/lib/CMakeLists.txt
index b35553a696..bdf7445af9 100644
--- a/gr-pager/lib/CMakeLists.txt
+++ b/gr-pager/lib/CMakeLists.txt
@@ -22,6 +22,7 @@
########################################################################
include_directories(
${GR_PAGER_INCLUDE_DIRS}
+ ${GR_BLOCKS_INCLUDE_DIRS}
${GNURADIO_CORE_INCLUDE_DIRS}
${GRUEL_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
@@ -45,6 +46,7 @@ list(APPEND pager_sources
list(APPEND pager_libs
gnuradio-core
+ gnuradio-blocks
${Boost_LIBRARIES}
)
diff --git a/gr-pager/lib/flex_sync_impl.cc b/gr-pager/lib/flex_sync_impl.cc
index cdf68f0381..7701f56f7a 100644
--- a/gr-pager/lib/flex_sync_impl.cc
+++ b/gr-pager/lib/flex_sync_impl.cc
@@ -29,7 +29,7 @@
#include "bch3221.h"
#include "util.h"
#include <gr_io_signature.h>
-#include <gr_count_bits.h>
+#include <blocks/count_bits.h>
#include <cstdio>
namespace gr {
@@ -100,12 +100,12 @@ namespace gr {
int64_t val = d_sync[d_index];
int32_t marker = ((val & 0x0000FFFFFFFF0000ULL)) >> 16;
- if(gr_count_bits32(marker^FLEX_SYNC_MARKER) < 4) {
+ if(gr::blocks::count_bits32(marker^FLEX_SYNC_MARKER) < 4) {
int32_t code = ((val & 0xFFFF000000000000ULL) >> 32) |
(val & 0x000000000000FFFFULL);
for(int i = 0; i < num_flex_modes; i++) {
- if(gr_count_bits32(code^flex_modes[i].sync) < 4) {
+ if(gr::blocks::count_bits32(code^flex_modes[i].sync) < 4) {
d_mode = i;
return true;
}
diff --git a/gr-qtgui/apps/gr_time_plot_b b/gr-qtgui/apps/gr_time_plot_b
index 0d5ce5e501..20522095de 100755
--- a/gr-qtgui/apps/gr_time_plot_b
+++ b/gr-qtgui/apps/gr_time_plot_b
@@ -24,7 +24,7 @@ from gnuradio import gr
import scipy
try:
- import gnuradio.qtgui.plot_tiome_base as plot_base
+ import gnuradio.qtgui.plot_time_base as plot_base
except ImportError:
import plot_time_base as plot_base
diff --git a/gr-qtgui/apps/plot_form.py b/gr-qtgui/apps/plot_form.py
index 3b477d516f..87c3da416f 100644
--- a/gr-qtgui/apps/plot_form.py
+++ b/gr-qtgui/apps/plot_form.py
@@ -27,6 +27,8 @@ except ImportError:
print "Error: Program requires PyQt4."
sys.exit(1)
+import numpy
+
class plot_form(QtGui.QWidget):
def __init__(self, top_block, title=''):
QtGui.QWidget.__init__(self, None)
@@ -127,12 +129,16 @@ class plot_form(QtGui.QWidget):
self.gui_y_axis(top_block._y_value-top_block._y_range, top_block._y_value)
# Create a slider to move the plot's y-axis offset
+ _ymax = numpy.int32(min(numpy.iinfo(numpy.int32).max, self.top_block._y_max))
+ _ymin = numpy.int32(max(numpy.iinfo(numpy.int32).min, self.top_block._y_min))
+ _yrng = numpy.int32(min(numpy.iinfo(numpy.int32).max, self.top_block._y_range))
+ _yval = numpy.int32(min(numpy.iinfo(numpy.int32).max, self.top_block._y_value))
self.ybar = QtGui.QSlider(QtCore.Qt.Vertical, self)
- self.ybar.setMinimum(1000*self.top_block._y_min)
- self.ybar.setMaximum(1000*self.top_block._y_max)
- self.ybar.setSingleStep(1000*(self.top_block._y_range/10))
- self.ybar.setPageStep(1000*(self.top_block._y_range/2))
- self.ybar.setValue(1000*self.top_block._y_value)
+ self.ybar.setMinimum(1000*_ymin)
+ self.ybar.setMaximum(1000*_ymax)
+ self.ybar.setSingleStep(1000*(_yrng/10))
+ self.ybar.setPageStep(1000*(_yrng/2))
+ self.ybar.setValue(1000*_yval)
self.connect(self.ybar, QtCore.SIGNAL("valueChanged(int)"),
self.update_yaxis_slider)
self.layout.addWidget(self.ybar, 1,1,1,1)
diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml
index ce5acdb123..e51b1f72b0 100644
--- a/grc/blocks/block_tree.xml
+++ b/grc/blocks/block_tree.xml
@@ -83,8 +83,6 @@
<block>gr_mpsk_sync_cc</block>
- <block>gr_simple_correlator</block>
-
<block>blks2_packet_decoder</block>
<block>blks2_packet_encoder</block>
</cat>