commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r4607 - in gnuradio/branches/developers/jcorgan/glfsr/


From: jcorgan
Subject: [Commit-gnuradio] r4607 - in gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src: lib/general python/gnuradio/gr
Date: Fri, 23 Feb 2007 01:41:41 -0700 (MST)

Author: jcorgan
Date: 2007-02-23 01:41:40 -0700 (Fri, 23 Feb 2007)
New Revision: 4607

Added:
   
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/lib/general/gri_glfsr.h
Modified:
   
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/lib/general/gr_glfsr_source_b.cc
   
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/lib/general/gr_glfsr_source_b.h
   
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/python/gnuradio/gr/qa_glfsr_source_b.py
Log:
Work in progress.

Modified: 
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/lib/general/gr_glfsr_source_b.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/lib/general/gr_glfsr_source_b.cc
       2007-02-23 08:05:12 UTC (rev 4606)
+++ 
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/lib/general/gr_glfsr_source_b.cc
       2007-02-23 08:41:40 UTC (rev 4607)
@@ -26,6 +26,7 @@
 #endif
 
 #include <gr_glfsr_source_b.h>
+#include <gri_glfsr.h>
 #include <gr_io_signature.h>
 #include <stdexcept>
 
@@ -39,20 +40,19 @@
   : gr_sync_block ("glfsr_source_b",
                   gr_make_io_signature (0, 0, 0),
                   gr_make_io_signature (1, 1, sizeof(unsigned char))),
-    d_degree(degree),
     d_repeat(repeat),
-    d_mask(mask),
-    d_shift_register(seed),
     d_index(0)
 {
   if (degree < 1 || degree > 31)
     throw std::out_of_range("gr_glfsr_source_b: degree must be between 1 and 
31 inclusive");
   d_length = (int)(1ULL << degree)-1;
+
+  d_glfsr = new gri_glfsr(mask, seed);
 }
 
 gr_glfsr_source_b::~gr_glfsr_source_b()
 {
-  /* NOP */
+  delete d_glfsr;
 }
 
 int
@@ -66,7 +66,7 @@
 
   int i;
   for (i = 0; i < noutput_items; i++) {
-    out[i] = 0; /* (char)d_glfsr.next_bit(); */
+    out[i] = d_glfsr->next_bit();
     d_index++;
     if (d_index > d_length && d_repeat == false)
       break;

Modified: 
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/lib/general/gr_glfsr_source_b.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/lib/general/gr_glfsr_source_b.h
        2007-02-23 08:05:12 UTC (rev 4606)
+++ 
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/lib/general/gr_glfsr_source_b.h
        2007-02-23 08:41:40 UTC (rev 4607)
@@ -25,6 +25,8 @@
 
 #include <gr_sync_block.h>
 
+class gri_glfsr;
+
 class gr_glfsr_source_b;
 typedef boost::shared_ptr<gr_glfsr_source_b> gr_glfsr_source_b_sptr;
 
@@ -40,10 +42,9 @@
   friend gr_glfsr_source_b_sptr
   gr_make_glfsr_source_b(int degree, bool repeat, int mask, int seed);
   
-  int d_degree;
+  gri_glfsr *d_glfsr;
+
   bool d_repeat;
-  int d_mask;
-  int d_shift_register;
   unsigned int d_index;
   unsigned int d_length;
   

Added: 
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/lib/general/gri_glfsr.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/lib/general/gri_glfsr.h
                                (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/lib/general/gri_glfsr.h
        2007-02-23 08:41:40 UTC (rev 4607)
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GRI_GLFSR_H
+#define INCLUDED_GRI_GLFSR_H
+
+/*!
+ * \brief Galois Linear Feedback Shift Register using specified polynomial mask
+ *
+ * Generates a maximal length pseudo-random sequence of length 2^degree-1
+ */
+
+class gri_glfsr
+{
+ private:
+  int d_shift_register;
+  int d_mask;
+
+ public:
+
+  gri_glfsr(int mask, int seed) { d_shift_register = seed; d_mask = mask; }
+
+  unsigned char next_bit() {
+    unsigned char bit = d_shift_register & 1;
+    d_shift_register >>= 1;
+    if (bit)
+      d_shift_register ^= d_mask;
+    return bit;
+  }
+};
+
+#endif /* INCLUDED_GRI_GLFSR_H */


Property changes on: 
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/lib/general/gri_glfsr.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: 
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/python/gnuradio/gr/qa_glfsr_source_b.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/python/gnuradio/gr/qa_glfsr_source_b.py
        2007-02-23 08:05:12 UTC (rev 4606)
+++ 
gnuradio/branches/developers/jcorgan/glfsr/gnuradio-core/src/python/gnuradio/gr/qa_glfsr_source_b.py
        2007-02-23 08:41:40 UTC (rev 4607)
@@ -31,8 +31,11 @@
         self.fg = None
 
     def test_glfsr_source_b(self):
-        src = gr.glfsr_source_b(5, False)
-        expected_result = (0,)*31
+        src = gr.glfsr_source_b(5, False, 0x25)
+        expected_result = (1, 1, 1, 0, 1, 0, 1, 1,
+                           0, 1, 1, 1, 1, 1, 0, 0,
+                           0, 1, 0, 1, 0, 0, 1, 0,
+                           0, 0, 0, 0, 1, 1, 1)
         dst = gr.vector_sink_b()
         self.fg.connect(src, dst)
         self.fg.run()





reply via email to

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