summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/sphinx/source/analog_blocks.rst1
-rw-r--r--docs/sphinx/source/index.rst1
-rw-r--r--gnuradio-runtime/include/gnuradio/fxpt_nco.h18
-rw-r--r--gr-analog/grc/analog_const_source_x.block.yml6
-rw-r--r--gr-analog/grc/analog_sig_source_x.block.yml6
-rw-r--r--gr-analog/include/gnuradio/analog/sig_source.h1
-rw-r--r--gr-analog/lib/sig_source_impl.cc2
-rw-r--r--gr-analog/python/analog/qa_sig_source.py28
-rw-r--r--gr-analog/swig/analog_swig.i1
9 files changed, 57 insertions, 7 deletions
diff --git a/docs/sphinx/source/analog_blocks.rst b/docs/sphinx/source/analog_blocks.rst
index bbf1a2275e..5c5adfd43c 100644
--- a/docs/sphinx/source/analog_blocks.rst
+++ b/docs/sphinx/source/analog_blocks.rst
@@ -37,4 +37,5 @@ gnuradio.analog
.. autoblock:: gnuradio.analog.sig_source_f
.. autoblock:: gnuradio.analog.sig_source_i
.. autoblock:: gnuradio.analog.sig_source_s
+.. autoblock:: gnuradio.analog.sig_source_b
.. autoblock:: gnuradio.analog.simple_squelch_cc
diff --git a/docs/sphinx/source/index.rst b/docs/sphinx/source/index.rst
index fbce329e4d..c5521550c1 100644
--- a/docs/sphinx/source/index.rst
+++ b/docs/sphinx/source/index.rst
@@ -1135,6 +1135,7 @@ Waveform Generator Blocks
gnuradio.analog.sig_source_f
gnuradio.analog.sig_source_i
gnuradio.analog.sig_source_s
+ gnuradio.analog.sig_source_b
ZeroMQ Interface Blocks
diff --git a/gnuradio-runtime/include/gnuradio/fxpt_nco.h b/gnuradio-runtime/include/gnuradio/fxpt_nco.h
index 33a176d9b4..b3eafadecf 100644
--- a/gnuradio-runtime/include/gnuradio/fxpt_nco.h
+++ b/gnuradio-runtime/include/gnuradio/fxpt_nco.h
@@ -113,6 +113,24 @@ namespace gr {
step ();
}
}
+
+ // compute sin for a block of phase angles
+ void sin(std::int8_t *output, int noutput_items, double ampl=1.0)
+ {
+ for(int i = 0; i < noutput_items; i++) {
+ output[i] = (std::int8_t)(gr::fxpt::sin(d_phase) * ampl);
+ step();
+ }
+ }
+
+ // compute cos for a block of phase angles
+ void cos(std::int8_t *output, int noutput_items, double ampl=1.0)
+ {
+ for(int i = 0; i < noutput_items; i++) {
+ output[i] = (std::int8_t)(gr::fxpt::cos(d_phase) * ampl);
+ step();
+ }
+ }
// compute sin for a block of phase angles
void sin(short *output, int noutput_items, double ampl=1.0)
diff --git a/gr-analog/grc/analog_const_source_x.block.yml b/gr-analog/grc/analog_const_source_x.block.yml
index ccabfdabc8..348bd8377c 100644
--- a/gr-analog/grc/analog_const_source_x.block.yml
+++ b/gr-analog/grc/analog_const_source_x.block.yml
@@ -6,10 +6,10 @@ parameters:
- id: type
label: Output Type
dtype: enum
- options: [complex, float, int, short]
+ options: [complex, float, int, short, byte]
option_attributes:
- const_type: [complex, real, int, int]
- fcn: [c, f, i, s]
+ const_type: [complex, real, int, short, gr.sizeof_char]
+ fcn: [c, f, i, s, b]
hide: part
- id: const
label: Constant
diff --git a/gr-analog/grc/analog_sig_source_x.block.yml b/gr-analog/grc/analog_sig_source_x.block.yml
index 47160f722a..02bb791b56 100644
--- a/gr-analog/grc/analog_sig_source_x.block.yml
+++ b/gr-analog/grc/analog_sig_source_x.block.yml
@@ -6,10 +6,10 @@ parameters:
- id: type
label: Output Type
dtype: enum
- options: [complex, float, int, short]
+ options: [complex, float, int, short, byte]
option_attributes:
- fcn: [c, f, i, s]
- offset_type: [complex, real, int, int]
+ fcn: [c, f, i, s, b]
+ offset_type: [complex, real, int, short, byte]
hide: part
- id: samp_rate
label: Sample Rate
diff --git a/gr-analog/include/gnuradio/analog/sig_source.h b/gr-analog/include/gnuradio/analog/sig_source.h
index 5d8ee05614..ec8e4eee43 100644
--- a/gr-analog/include/gnuradio/analog/sig_source.h
+++ b/gr-analog/include/gnuradio/analog/sig_source.h
@@ -101,6 +101,7 @@ template<class T>
virtual void set_phase(float phase) = 0;
};
+ typedef sig_source<std::int8_t> sig_source_b;
typedef sig_source<std::int16_t> sig_source_s;
typedef sig_source<std::int32_t> sig_source_i;
typedef sig_source<float> sig_source_f;
diff --git a/gr-analog/lib/sig_source_impl.cc b/gr-analog/lib/sig_source_impl.cc
index 1b3aa82e44..fa18a25bba 100644
--- a/gr-analog/lib/sig_source_impl.cc
+++ b/gr-analog/lib/sig_source_impl.cc
@@ -287,7 +287,7 @@ void sig_source_impl<T>::set_phase(float phase) {
d_nco.set_phase(phase);
}
-
+template class sig_source<std::int8_t>;
template class sig_source<std::int16_t>;
template class sig_source<std::int32_t>;
template class sig_source<float>;
diff --git a/gr-analog/python/analog/qa_sig_source.py b/gr-analog/python/analog/qa_sig_source.py
index 8b239fc070..0f14ae46c8 100644
--- a/gr-analog/python/analog/qa_sig_source.py
+++ b/gr-analog/python/analog/qa_sig_source.py
@@ -58,6 +58,18 @@ class test_sig_source(gr_unittest.TestCase):
dst_data = dst1.data()
self.assertEqual(expected_result, dst_data)
+ def test_const_b(self):
+ tb = self.tb
+ expected_result = (1, 1, 1, 1)
+ src1 = analog.sig_source_b(1e6, analog.GR_CONST_WAVE, 0, 1)
+ op = blocks.head(gr.sizeof_char, 4)
+ dst1 = blocks.vector_sink_b()
+ tb.connect(src1, op)
+ tb.connect(op, dst1)
+ tb.run()
+ dst_data = dst1.data()
+ self.assertEqual(expected_result, dst_data)
+
def test_sine_f(self):
tb = self.tb
sqrt2 = math.sqrt(2) / 2
@@ -71,6 +83,22 @@ class test_sig_source(gr_unittest.TestCase):
dst_data = dst1.data()
self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 5)
+
+ def test_sine_b(self):
+ tb = self.tb
+ sqrt2 = math.sqrt(2) / 2
+ temp_result = (0, sqrt2, 1, sqrt2, 0, -sqrt2, -1, -sqrt2, 0)
+ amp = 8
+ expected_result = tuple([int(z * amp) for z in temp_result])
+ src1 = analog.sig_source_b(8, analog.GR_SIN_WAVE, 1.0, amp)
+ op = blocks.head(gr.sizeof_char, 9)
+ dst1 = blocks.vector_sink_b()
+ tb.connect(src1, op)
+ tb.connect(op, dst1)
+ tb.run()
+ dst_data = dst1.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, dst_data)
+
def test_cosine_f(self):
tb = self.tb
sqrt2 = math.sqrt(2) / 2
diff --git a/gr-analog/swig/analog_swig.i b/gr-analog/swig/analog_swig.i
index 8f4b90b71c..23ab1c5cbe 100644
--- a/gr-analog/swig/analog_swig.i
+++ b/gr-analog/swig/analog_swig.i
@@ -131,6 +131,7 @@ GR_SWIG_BLOCK_MAGIC2(analog, pwr_squelch_cc);
GR_SWIG_BLOCK_MAGIC2(analog, pwr_squelch_ff);
GR_SWIG_BLOCK_MAGIC2(analog, quadrature_demod_cf);
GR_SWIG_BLOCK_MAGIC2(analog, rail_ff);
+GR_SWIG_BLOCK_MAGIC2_TMPL(analog, sig_source_b, sig_source<std::int8_t>);
GR_SWIG_BLOCK_MAGIC2_TMPL(analog, sig_source_s, sig_source<std::int16_t>);
GR_SWIG_BLOCK_MAGIC2_TMPL(analog, sig_source_i, sig_source<std::int32_t>);
GR_SWIG_BLOCK_MAGIC2_TMPL(analog, sig_source_f, sig_source<float>);