commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8304 - grc/trunk/src/grc_gnuradio/blks2


From: jblum
Subject: [Commit-gnuradio] r8304 - grc/trunk/src/grc_gnuradio/blks2
Date: Fri, 2 May 2008 18:29:49 -0600 (MDT)

Author: jblum
Date: 2008-05-02 18:29:48 -0600 (Fri, 02 May 2008)
New Revision: 8304

Modified:
   grc/trunk/src/grc_gnuradio/blks2/error_rate.py
Log:
faster BER calculation

Modified: grc/trunk/src/grc_gnuradio/blks2/error_rate.py
===================================================================
--- grc/trunk/src/grc_gnuradio/blks2/error_rate.py      2008-05-02 22:03:00 UTC 
(rev 8303)
+++ grc/trunk/src/grc_gnuradio/blks2/error_rate.py      2008-05-03 00:29:48 UTC 
(rev 8304)
@@ -26,6 +26,9 @@
 import gnuradio.gr.gr_threading as _threading
 import numpy
 
+#generate 1s counts array
+_1s_counts = [sum([1&(i>>j) for j in range(8)]) for i in range(2**8)]
+
 class input_watcher(_threading.Thread):
        """
        Read samples from the message queue and hand them to the callback.
@@ -101,13 +104,7 @@
                for i in range(num):
                        old_err = self._err_array[self._err_index]              
                                                        
                        #record error
-                       ref = samples[i*2] ^ samples[i*2 + 1]
-                       self._err_array[self._err_index] = 0
-                       for j in range(self._bits_per_symbol):
-                               if (ref & 1) != 0: 
-                                       self._err_array[self._err_index] = 
self._err_array[self._err_index] + 1
-                               ref >> 1
-                       #update number of errors
+                       self._err_array[self._err_index] = 
_1s_counts[samples[i*2] ^ samples[i*2 + 1]]
                        self._num_errs = self._num_errs + 
self._err_array[self._err_index] - old_err
                        #increment index
                        self._err_index = (self._err_index + 
1)%self._max_samples





reply via email to

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