summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-runtime/include/gnuradio/random.h16
-rw-r--r--gnuradio-runtime/lib/math/random.cc37
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/qa_random.py44
-rw-r--r--gr-analog/grc/CMakeLists.txt1
-rw-r--r--gr-analog/grc/analog_random_uniform_source_x.xml56
-rw-r--r--gr-analog/include/gnuradio/analog/CMakeLists.txt1
-rw-r--r--gr-analog/include/gnuradio/analog/random_uniform_source_X.h.t61
-rw-r--r--gr-analog/lib/CMakeLists.txt1
-rw-r--r--gr-analog/lib/random_uniform_source_X_impl.cc.t83
-rw-r--r--gr-analog/lib/random_uniform_source_X_impl.h.t54
-rwxr-xr-xgr-analog/python/analog/qa_random_uniform_source.py89
-rw-r--r--gr-analog/swig/analog_swig.i9
-rw-r--r--gr-fec/grc/fec_extended_decoder.xml2
-rw-r--r--gr-fec/include/gnuradio/fec/ber_bf.h5
-rw-r--r--gr-fec/lib/ber_bf_impl.cc3
-rw-r--r--gr-fec/lib/ber_bf_impl.h6
16 files changed, 443 insertions, 25 deletions
diff --git a/gnuradio-runtime/include/gnuradio/random.h b/gnuradio-runtime/include/gnuradio/random.h
index e95f36d1c2..2167247526 100644
--- a/gnuradio-runtime/include/gnuradio/random.h
+++ b/gnuradio-runtime/include/gnuradio/random.h
@@ -45,10 +45,12 @@ namespace gr {
boost::mt19937 *d_rng; // mersenne twister as random number generator
boost::uniform_real<float> *d_uniform; // choose uniform distribution, default is [0,1)
+ boost::random::uniform_int_distribution<> *d_integer_dis;
boost::variate_generator<boost::mt19937&, boost::uniform_real<float> > *d_generator;
+ boost::variate_generator<boost::mt19937&, boost::random::uniform_int_distribution<> > *d_integer_generator;
public:
- random(unsigned int seed=0);
+ random(unsigned int seed=0, int min_integer = 0, int max_integer = 2);
~random();
/*!
@@ -57,6 +59,18 @@ namespace gr {
void reseed(unsigned int seed);
/*!
+ * set minimum and maximum for integer random number generator.
+ * Limits are [minimum, maximum)
+ * Default: [0, std::numeric_limits< IntType >::max)]
+ */
+ void set_integer_limits(const int minimum, const int maximum);
+
+ /*!
+ * Uniform random integers in the range set by 'set_integer_limits' [min, max).
+ */
+ int ran_int();
+
+ /*!
* \brief Uniform random numbers in the range [0.0, 1.0)
*/
float ran1();
diff --git a/gnuradio-runtime/lib/math/random.cc b/gnuradio-runtime/lib/math/random.cc
index a2b2621307..5e16c96ea4 100644
--- a/gnuradio-runtime/lib/math/random.cc
+++ b/gnuradio-runtime/lib/math/random.cc
@@ -44,22 +44,27 @@
namespace gr {
- random::random(unsigned int seed)
+ random::random(unsigned int seed, int min_integer, int max_integer)
{
d_gauss_stored = false; // set gasdev (gauss distributed numbers) on calculation state
- // Setup random number generator
- d_rng = new boost::mt19937;
+ // Setup random number generators
+ d_rng = new boost::mt19937; // random numbers are generated here.
+ d_uniform = new boost::uniform_real<float>; // map random number to distribution
+ d_integer_dis = new boost::random::uniform_int_distribution<>(0, 1); // another "mapper"
+ d_generator = NULL; // MUST be reinstantiated on every call to reseed.
+ d_integer_generator = NULL; // MUST be reinstantiated on everytime d_rng or d_integer_dis is changed.
reseed(seed); // set seed for random number generator
- d_uniform = new boost::uniform_real<float>;
- d_generator = new boost::variate_generator<boost::mt19937&, boost::uniform_real<float> > (*d_rng,*d_uniform); // create number generator in [0,1) from boost.random
+ set_integer_limits(min_integer, max_integer);
}
random::~random()
{
delete d_rng;
delete d_uniform;
+ delete d_integer_dis;
delete d_generator;
+ delete d_integer_generator;
}
/*
@@ -71,6 +76,28 @@ namespace gr {
if(seed==0) d_seed = static_cast<unsigned int>(std::time(0));
else d_seed = seed;
d_rng->seed(d_seed);
+ // reinstantiate generators. Otherwise reseed doesn't take effect.
+ delete d_generator;
+ d_generator = new boost::variate_generator<boost::mt19937&, boost::uniform_real<float> > (*d_rng,*d_uniform); // create number generator in [0,1) from boost.random
+ delete d_integer_generator;
+ d_integer_generator = new boost::variate_generator<boost::mt19937&, boost::random::uniform_int_distribution<> >(*d_rng, *d_integer_dis);
+ }
+
+ void
+ random::set_integer_limits(const int minimum, const int maximum){
+ // boost expects integer limits defined as [minimum, maximum] which is unintuitive.
+ boost::random::uniform_int_distribution<>::param_type dis_params(minimum, maximum - 1);
+ d_integer_dis->param(dis_params);
+ delete d_integer_generator;
+ d_integer_generator = new boost::variate_generator<boost::mt19937&, boost::random::uniform_int_distribution<> >(*d_rng, *d_integer_dis);
+ }
+
+ /*!
+ * Uniform random integers in the range set by 'set_integer_limits' [min, max).
+ */
+ int
+ random::ran_int(){
+ return (*d_integer_generator)();
}
/*
diff --git a/gnuradio-runtime/python/gnuradio/gr/qa_random.py b/gnuradio-runtime/python/gnuradio/gr/qa_random.py
index 83fee56181..d3e5410454 100644
--- a/gnuradio-runtime/python/gnuradio/gr/qa_random.py
+++ b/gnuradio-runtime/python/gnuradio/gr/qa_random.py
@@ -23,8 +23,8 @@
from gnuradio import gr, gr_unittest
import numpy as np
-class test_random(gr_unittest.TestCase):
+class test_random(gr_unittest.TestCase):
# NOTE: For tests on the output distribution of the random numbers, see gnuradio-runtime/apps/evaluation_random_numbers.py.
# Check for range [0,1) of uniform distributed random numbers
@@ -38,27 +38,41 @@ class test_random(gr_unittest.TestCase):
self.assertLess(value, 1)
self.assertGreaterEqual(value, 0)
- # Check reseed method (init with time and seed as fix number)
- def test_2(self):
+ # Same seed should yield same random values.
+ def test_2_same_seed(self):
num = 5
-
- rndm0 = gr.random(42); # init with time
- rndm1 = gr.random(42); # init with fix seed
+ # Init with fixed seed.
+ rndm0 = gr.random(42)
+ rndm1 = gr.random(42)
for k in range(num):
- x = rndm0.ran1();
- y = rndm1.ran1();
- self.assertEqual(x,y)
+ x = rndm0.ran1()
+ y = rndm1.ran1()
+ self.assertEqual(x, y)
+ # reseed should yield same numbers.
+ def test_003_reseed(self):
+ num = 5
x = np.zeros(num)
y = np.zeros(num)
- rndm0 = gr.random(42); # init with fix seed 1
+ rndm = gr.random(43) # init with fix seed 1
for k in range(num):
- x[k] = rndm0.ran1();
- rndm1.reseed(43); # init with fix seed 2
+ x[k] = rndm.ran1()
+ rndm.reseed(43) # init with fix seed 2
for k in range(num):
- y[k] = rndm0.ran1();
- for k in range(num):
- self.assertNotEqual(x[k],y[k])
+ y[k] = rndm.ran1()
+ self.assertFloatTuplesAlmostEqual(x, y)
+
+ def test_004_integer(self):
+ nitems = 100000
+ minimum = 2
+ maximum = 42
+ rng = gr.random(1, minimum, maximum)
+ rnd_vals = np.zeros(nitems, dtype=int)
+ for i in range(nitems):
+ rnd_vals[i] = rng.ran_int()
+ self.assertGreaterEqual(minimum, np.min(rnd_vals))
+ self.assertLess(np.max(rnd_vals), maximum)
+
if __name__ == '__main__':
gr_unittest.run(test_random, "test_random.xml")
diff --git a/gr-analog/grc/CMakeLists.txt b/gr-analog/grc/CMakeLists.txt
index 908ef0ed33..a699d7c2fa 100644
--- a/gr-analog/grc/CMakeLists.txt
+++ b/gr-analog/grc/CMakeLists.txt
@@ -19,3 +19,4 @@
file(GLOB xml_files "*.xml")
install(FILES ${xml_files} DESTINATION ${GRC_BLOCKS_DIR} COMPONENT "analog_python")
+
diff --git a/gr-analog/grc/analog_random_uniform_source_x.xml b/gr-analog/grc/analog_random_uniform_source_x.xml
new file mode 100644
index 0000000000..614b800953
--- /dev/null
+++ b/gr-analog/grc/analog_random_uniform_source_x.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<block>
+ <name>Random Uniform Source</name>
+ <key>analog_random_uniform_source_x</key>
+ <category>analog</category>
+ <import>from gnuradio import analog</import>
+ <make>analog.random_uniform_source_$(type.fcn)($minimum, $maximum, $seed)</make>
+
+ <param>
+ <name>Output Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:i</opt>
+ <opt>offset_type:int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:s</opt>
+ <opt>offset_type:int</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>fcn:b</opt>
+ <opt>offset_type:int</opt>
+ </option>
+ </param>
+
+ <param>
+ <name>Minimum</name>
+ <key>minimum</key>
+ <type>int</type>
+ </param>
+
+ <param>
+ <name>Maximum</name>
+ <key>maximum</key>
+ <type>int</type>
+ </param>
+
+ <param>
+ <name>Seed</name>
+ <key>seed</key>
+ <value>0</value>
+ <type>int</type>
+ </param>
+
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ </source>
+</block>
diff --git a/gr-analog/include/gnuradio/analog/CMakeLists.txt b/gr-analog/include/gnuradio/analog/CMakeLists.txt
index 430e6432a1..b5333639d6 100644
--- a/gr-analog/include/gnuradio/analog/CMakeLists.txt
+++ b/gr-analog/include/gnuradio/analog/CMakeLists.txt
@@ -24,6 +24,7 @@ include(GrMiscUtils)
GR_EXPAND_X_H(analog noise_source_X s i f c)
GR_EXPAND_X_H(analog fastnoise_source_X s i f c)
GR_EXPAND_X_H(analog sig_source_X s i f c)
+GR_EXPAND_X_H(analog random_uniform_source_X b s i)
add_custom_target(analog_generated_includes DEPENDS
${generated_includes}
diff --git a/gr-analog/include/gnuradio/analog/random_uniform_source_X.h.t b/gr-analog/include/gnuradio/analog/random_uniform_source_X.h.t
new file mode 100644
index 0000000000..d2f7cbdc44
--- /dev/null
+++ b/gr-analog/include/gnuradio/analog/random_uniform_source_X.h.t
@@ -0,0 +1,61 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2015 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.
+ */
+
+/* @WARNING@ */
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <gnuradio/analog/api.h>
+#include <gnuradio/sync_block.h>
+
+namespace gr {
+ namespace analog {
+
+ /*!
+ * \brief Uniform Random Number Generator with @TYPE@ output.
+ * \ingroup waveform_generators_blk
+ */
+ class ANALOG_API @BASE_NAME@ : virtual public sync_block
+ {
+ public:
+ // gr::analog::@BASE_NAME@::sptr
+ typedef boost::shared_ptr<@BASE_NAME@> sptr;
+
+ /*!
+ * \brief Return a shared_ptr to a new instance of analog::random_uniform_source_X.
+ *
+ * To avoid accidental use of raw pointers, analog::random_uniform_source_b's
+ * constructor is in a private implementation
+ * class. analog::random_uniform_source_b::make is the public interface for
+ * creating new instances.
+ * \param minimum defines minimal integer value output.
+ * \param maximum output values are below this value
+ * \param seed for Pseudo Random Number Generator. Defaults to 0. In this case current time is used.
+ */
+ static sptr make(int minimum, int maximum, int seed);
+ };
+
+ } /* namespace analog */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-analog/lib/CMakeLists.txt b/gr-analog/lib/CMakeLists.txt
index 054fa13fce..918f894abe 100644
--- a/gr-analog/lib/CMakeLists.txt
+++ b/gr-analog/lib/CMakeLists.txt
@@ -46,6 +46,7 @@ include(GrMiscUtils)
GR_EXPAND_X_CC_H(analog noise_source_X_impl s i f c)
GR_EXPAND_X_CC_H(analog fastnoise_source_X_impl s i f c)
GR_EXPAND_X_CC_H(analog sig_source_X_impl s i f c)
+GR_EXPAND_X_CC_H(analog random_uniform_source_X_impl b s i)
########################################################################
# Setup library
diff --git a/gr-analog/lib/random_uniform_source_X_impl.cc.t b/gr-analog/lib/random_uniform_source_X_impl.cc.t
new file mode 100644
index 0000000000..98af5d02fa
--- /dev/null
+++ b/gr-analog/lib/random_uniform_source_X_impl.cc.t
@@ -0,0 +1,83 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2015 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.
+ */
+
+/* @WARNING@ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "@IMPL_NAME@.h"
+#include <gnuradio/io_signature.h>
+
+namespace gr {
+ namespace analog {
+
+ @BASE_NAME@::sptr
+ @BASE_NAME@::make(int minimum, int maximum, int seed)
+ {
+ return gnuradio::get_initial_sptr(new @IMPL_NAME@(minimum, maximum, seed));
+ }
+
+ @IMPL_NAME@::@IMPL_NAME@(int minimum, int maximum, int seed)
+ : sync_block("@BASE_NAME@",
+ io_signature::make(0, 0, 0),
+ io_signature::make(1, 1, sizeof(@TYPE@)))
+ {
+ d_rng = new gr::random(seed, minimum, maximum);
+ }
+
+ @IMPL_NAME@::~@IMPL_NAME@()
+ {
+ delete d_rng;
+ }
+
+ int
+ @IMPL_NAME@::random_value()
+ {
+ return d_rng->ran_int();
+ }
+
+ int
+ @IMPL_NAME@::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ @TYPE@ *out = (@TYPE@*)output_items[0];
+
+ for(int i = 0; i < noutput_items; i++){
+ *out++ = (@TYPE@) random_value();
+ }
+
+ // Tell runtime system how many output items we produced.
+ return noutput_items;
+ }
+
+
+
+
+
+
+
+
+ } /* namespace analog */
+} /* namespace gr */
diff --git a/gr-analog/lib/random_uniform_source_X_impl.h.t b/gr-analog/lib/random_uniform_source_X_impl.h.t
new file mode 100644
index 0000000000..67fcfc9893
--- /dev/null
+++ b/gr-analog/lib/random_uniform_source_X_impl.h.t
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2015 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <gnuradio/analog/@BASE_NAME@.h>
+#include <gnuradio/random.h>
+
+namespace gr {
+ namespace analog {
+
+ class @IMPL_NAME@ : public @BASE_NAME@
+ {
+ private:
+ gr::random *d_rng;
+
+ public:
+ @IMPL_NAME@(int minimum, int maximum, int seed);
+ ~@IMPL_NAME@();
+
+ // Where all the action really happens
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ int random_value();
+ };
+
+ } /* namespace filter */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */ \ No newline at end of file
diff --git a/gr-analog/python/analog/qa_random_uniform_source.py b/gr-analog/python/analog/qa_random_uniform_source.py
new file mode 100755
index 0000000000..474c5716c7
--- /dev/null
+++ b/gr-analog/python/analog/qa_random_uniform_source.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright 2015 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
+from gnuradio import blocks, analog
+import numpy as np
+
+
+class qa_random_uniform_source(gr_unittest.TestCase):
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001_byte(self):
+ minimum = 0
+ maximum = 5
+ seed = 3
+ n_items = 10000
+ rnd_src = analog.random_uniform_source_b(minimum, maximum, seed)
+ head = blocks.head(1, n_items)
+ snk = blocks.vector_sink_b(1)
+ self.tb.connect(rnd_src, head, snk)
+ # set up fg
+ self.tb.run()
+ # check data
+ res = snk.data()
+ self.assertGreaterEqual(minimum, np.min(res))
+ self.assertLess(np.max(res), maximum)
+
+ def test_002_short(self):
+ minimum = 42
+ maximum = 1025
+ seed = 3
+ n_items = 10000
+ rnd_src = analog.random_uniform_source_s(minimum, maximum, seed)
+ head = blocks.head(2, n_items)
+ snk = blocks.vector_sink_s(1)
+ self.tb.connect(rnd_src, head, snk)
+ # set up fg
+ self.tb.run()
+ # check data
+ res = snk.data()
+ self.assertGreaterEqual(minimum, np.min(res))
+ self.assertLess(np.max(res), maximum)
+
+ def test_003_int(self):
+ minimum = 2 ** 12 - 2
+ maximum = 2 ** 17 + 5
+ seed = 3
+ n_items = 10000
+ rnd_src = analog.random_uniform_source_i(minimum, maximum, seed)
+ head = blocks.head(4, n_items)
+ snk = blocks.vector_sink_i(1)
+ self.tb.connect(rnd_src, head, snk)
+ # set up fg
+ self.tb.run()
+ # check data
+ res = snk.data()
+ # plt.hist(res)
+ # plt.show()
+
+ self.assertGreaterEqual(np.min(res), minimum)
+ self.assertLess(np.max(res), maximum)
+
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_random_uniform_source, "qa_random_uniform_source.xml")
diff --git a/gr-analog/swig/analog_swig.i b/gr-analog/swig/analog_swig.i
index 84ac1486d9..7f064f545f 100644
--- a/gr-analog/swig/analog_swig.i
+++ b/gr-analog/swig/analog_swig.i
@@ -74,6 +74,9 @@
#include "gnuradio/analog/simple_squelch_cc.h"
#include "gnuradio/analog/squelch_base_cc.h"
#include "gnuradio/analog/squelch_base_ff.h"
+#include "gnuradio/analog/random_uniform_source_b.h"
+#include "gnuradio/analog/random_uniform_source_s.h"
+#include "gnuradio/analog/random_uniform_source_i.h"
%}
%include "gnuradio/analog/cpm.h"
@@ -116,6 +119,9 @@
%include "gnuradio/analog/simple_squelch_cc.h"
%include "gnuradio/analog/squelch_base_cc.h"
%include "gnuradio/analog/squelch_base_ff.h"
+%include "gnuradio/analog/random_uniform_source_b.h"
+%include "gnuradio/analog/random_uniform_source_s.h"
+%include "gnuradio/analog/random_uniform_source_i.h"
GR_SWIG_BLOCK_MAGIC2(analog, agc_cc);
GR_SWIG_BLOCK_MAGIC2(analog, agc_ff);
@@ -152,3 +158,6 @@ GR_SWIG_BLOCK_MAGIC2(analog, sig_source_i);
GR_SWIG_BLOCK_MAGIC2(analog, sig_source_f);
GR_SWIG_BLOCK_MAGIC2(analog, sig_source_c);
GR_SWIG_BLOCK_MAGIC2(analog, simple_squelch_cc);
+GR_SWIG_BLOCK_MAGIC2(analog, random_uniform_source_b);
+GR_SWIG_BLOCK_MAGIC2(analog, random_uniform_source_s);
+GR_SWIG_BLOCK_MAGIC2(analog, random_uniform_source_i);
diff --git a/gr-fec/grc/fec_extended_decoder.xml b/gr-fec/grc/fec_extended_decoder.xml
index 4262a395ae..9ed2f06bd0 100644
--- a/gr-fec/grc/fec_extended_decoder.xml
+++ b/gr-fec/grc/fec_extended_decoder.xml
@@ -3,7 +3,7 @@
<name>FEC Extended Decoder</name>
<key>fec_extended_decoder</key>
<import>from gnuradio import fec</import>
- <make>self.$(id) = $(id) = fec.extended_decoder(decoder_obj_list=$decoder_list, threading=$threadtype.arg, ann=$ann, puncpat=$puncpat, integration_period=10000)</make>
+ <make>fec.extended_decoder(decoder_obj_list=$decoder_list, threading=$threadtype.arg, ann=$ann, puncpat=$puncpat, integration_period=10000)</make>
<param>
<name>fake val</name>
diff --git a/gr-fec/include/gnuradio/fec/ber_bf.h b/gr-fec/include/gnuradio/fec/ber_bf.h
index 2aa01c98b0..5128d98d3e 100644
--- a/gr-fec/include/gnuradio/fec/ber_bf.h
+++ b/gr-fec/include/gnuradio/fec/ber_bf.h
@@ -67,6 +67,11 @@ namespace gr {
typedef boost::shared_ptr<ber_bf> sptr;
/*!
+ * Get total number of errors counter value.
+ */
+ virtual long total_errors() = 0;
+
+ /*!
* Calculate the BER between two streams of data.
*
* \param test_mode false for normal streaming mode (default);
diff --git a/gr-fec/lib/ber_bf_impl.cc b/gr-fec/lib/ber_bf_impl.cc
index 6e3dc85cab..5fd3ef049c 100644
--- a/gr-fec/lib/ber_bf_impl.cc
+++ b/gr-fec/lib/ber_bf_impl.cc
@@ -96,7 +96,8 @@ namespace gr {
% d_total_errors % (d_total * 8) % outbuffer[0]);
return 1;
}
- else if(calculate_log_ber() < d_ber_limit){
+ // check for total_errors to prevent early shutdown at high SNR simulations
+ else if(calculate_log_ber() < d_ber_limit && d_total_errors > 0){
GR_LOG_INFO(d_logger, " Min. BER limit reached");
outbuffer[0] = d_ber_limit;
d_total_errors = d_berminerrors + 1;
diff --git a/gr-fec/lib/ber_bf_impl.h b/gr-fec/lib/ber_bf_impl.h
index 15c747f659..75724a4281 100644
--- a/gr-fec/lib/ber_bf_impl.h
+++ b/gr-fec/lib/ber_bf_impl.h
@@ -31,8 +31,8 @@ namespace gr {
class FEC_API ber_bf_impl : public ber_bf
{
private:
- int d_total_errors;
- int d_total;
+ long d_total_errors;
+ long d_total;
bool d_test_mode;
int d_berminerrors;
float d_ber_limit;
@@ -48,6 +48,8 @@ namespace gr {
gr_vector_int& ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
+
+ long total_errors() {return d_total_errors;};
};
} /* namespace fec */