summaryrefslogtreecommitdiff
path: root/gr-blocks/include
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-03-18 12:28:18 -0400
committerTom Rondeau <trondeau@vt.edu>2013-03-18 12:28:18 -0400
commit19e39553188395a4ee057fa8c5e0f92cbeda4f28 (patch)
treee5e1b8bcaee26ae85a7e998f08504867878f21ed /gr-blocks/include
parent65d88f0b28e233c82bc4f0c07072085a3d18c163 (diff)
blocks: moved lfsr and friends to gr-blocks.
Diffstat (limited to 'gr-blocks/include')
-rw-r--r--gr-blocks/include/blocks/CMakeLists.txt3
-rw-r--r--gr-blocks/include/blocks/check_lfsr_32k_s.h56
-rw-r--r--gr-blocks/include/blocks/lfsr_15_1_0.h69
-rw-r--r--gr-blocks/include/blocks/lfsr_32k.h90
-rw-r--r--gr-blocks/include/blocks/lfsr_32k_source_s.h55
5 files changed, 273 insertions, 0 deletions
diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt
index b34809ae59..fcd31e31a8 100644
--- a/gr-blocks/include/blocks/CMakeLists.txt
+++ b/gr-blocks/include/blocks/CMakeLists.txt
@@ -108,6 +108,8 @@ install(FILES
fxpt.h
fxpt_nco.h
fxpt_vco.h
+ lfsr_15_1_0.h
+ lfsr_32k.h
log2_const.h
rotator.h
nco.h
@@ -121,6 +123,7 @@ install(FILES
burst_tagger.h
char_to_float.h
char_to_short.h
+ check_lfsr_32k_s.h
complex_to_interleaved_short.h
complex_to_float.h
complex_to_imag.h
diff --git a/gr-blocks/include/blocks/check_lfsr_32k_s.h b/gr-blocks/include/blocks/check_lfsr_32k_s.h
new file mode 100644
index 0000000000..4eba436e80
--- /dev/null
+++ b/gr-blocks/include/blocks/check_lfsr_32k_s.h
@@ -0,0 +1,56 @@
+/* -*- 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_CHECK_LFSR_32K_S_H
+#define INCLUDED_GR_CHECK_LFSR_32K_S_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief sink that checks if its input stream consists of a lfsr_32k sequence.
+ * \ingroup sink_blk
+ *
+ * This sink is typically used along with
+ * gr::blocks::lfsr_32k_source_s to test the USRP using its
+ * digital loopback mode.
+ */
+ class BLOCKS_API check_lfsr_32k_s : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::check_lfsr_32k_s::sptr
+ typedef boost::shared_ptr<check_lfsr_32k_s> sptr;
+
+ static sptr make();
+
+ virtual long ntotal () const = 0;
+ virtual long nright () const = 0;
+ virtual long runlength () const = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_CHECK_LFSR_32K_S_H */
diff --git a/gr-blocks/include/blocks/lfsr_15_1_0.h b/gr-blocks/include/blocks/lfsr_15_1_0.h
new file mode 100644
index 0000000000..a79ed62eb8
--- /dev/null
+++ b/gr-blocks/include/blocks/lfsr_15_1_0.h
@@ -0,0 +1,69 @@
+/* -*- 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_GRI_LFSR_15_1_0_H
+#define INCLUDED_GRI_LFSR_15_1_0_H
+
+#include <blocks/api.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Linear Feedback Shift Register using primitive polynomial x^15 + x + 1
+ * \ingroup misc
+ *
+ * Generates a maximal length pseudo-random sequence of length
+ * 2^15 - 1 bits.
+ */
+ class BLOCKS_API lfsr_15_1_0
+ {
+ private:
+ unsigned long d_sr; // shift register
+
+ public:
+ lfsr_15_1_0() { reset(); }
+
+ void reset() { d_sr = 0x7fff; }
+
+ int next_bit()
+ {
+ d_sr = ((((d_sr >> 1) ^ d_sr) & 0x1) << 14) | (d_sr >> 1);
+ return d_sr & 0x1;
+ }
+
+ int next_byte ()
+ {
+ int v = 0;
+ for(int i = 0; i < 8; i++) {
+ v >>= 1;
+ if(next_bit ())
+ v |= 0x80;
+ }
+ return v;
+ }
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GRI_LFSR_15_1_0_H */
diff --git a/gr-blocks/include/blocks/lfsr_32k.h b/gr-blocks/include/blocks/lfsr_32k.h
new file mode 100644
index 0000000000..7e70f6512b
--- /dev/null
+++ b/gr-blocks/include/blocks/lfsr_32k.h
@@ -0,0 +1,90 @@
+/* -*- 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_GRI_LFSR_32k_H
+#define INCLUDED_GRI_LFSR_32k_H
+
+#include <blocks/api.h>
+#include <blocks/lfsr_15_1_0.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief generate pseudo-random sequence of length 32768 bits.
+ * \ingroup misc
+ *
+ * This is based on gri_lfsr_15_1_0 with an extra 0 added at the
+ * end of the sequence.
+ */
+ class BLOCKS_API lfsr_32k
+ {
+ private:
+ lfsr_15_1_0 d_lfsr;
+ unsigned int d_count;
+
+ public:
+ lfsr_32k() { reset (); }
+
+ void reset()
+ {
+ d_lfsr.reset();
+ d_count = 0;
+ }
+
+ int next_bit()
+ {
+ if(d_count == 32767) {
+ d_count = 0;
+ return 0;
+ }
+ d_count++;
+ return d_lfsr.next_bit();
+ }
+
+ int next_byte()
+ {
+ int v = 0;
+ for(int i = 0; i < 8; i++) {
+ v >>= 1;
+ if(next_bit ())
+ v |= 0x80;
+ }
+ return v;
+ }
+
+ int next_short()
+ {
+ int v = 0;
+ for(int i = 0; i < 16; i++) {
+ v >>= 1;
+ if(next_bit ())
+ v |= 0x8000;
+ }
+ return v;
+ }
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GRI_LFSR_32k_H */
diff --git a/gr-blocks/include/blocks/lfsr_32k_source_s.h b/gr-blocks/include/blocks/lfsr_32k_source_s.h
new file mode 100644
index 0000000000..c24cc31b29
--- /dev/null
+++ b/gr-blocks/include/blocks/lfsr_32k_source_s.h
@@ -0,0 +1,55 @@
+/* -*- 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_LFSR_32K_SOURCE_S_H
+#define INCLUDED_GR_LFSR_32K_SOURCE_S_H
+
+#include <blocks/api.h>
+#include <blocks/lfsr_32k.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief LFSR pseudo-random source with period of 2^15 bits (2^11 shorts)
+ * \ingroup source_blk
+ *
+ * This source is typically used along with gr::blocks::check_lfsr_32k_s to
+ * test the USRP using its digital loopback mode.
+ */
+ class BLOCKS_API lfsr_32k_source_s : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::lfsr_32k_source_s::sptr
+ typedef boost::shared_ptr<lfsr_32k_source_s> sptr;
+
+ /*!
+ * \brief Make a LFSR 32k source block.
+ */
+ static sptr make();
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_LFSR_32K_SOURCE_S_H */