diff options
637 files changed, 9240 insertions, 23337 deletions
diff --git a/cmake/Modules/GrBoost.cmake b/cmake/Modules/GrBoost.cmake index 7c0d42134a..23bea41add 100644 --- a/cmake/Modules/GrBoost.cmake +++ b/cmake/Modules/GrBoost.cmake @@ -50,11 +50,12 @@ if(MSVC) endif(BOOST_ALL_DYN_LINK) endif(MSVC) +# Boost 1.52 disabled, see https://svn.boost.org/trac/boost/ticket/7669 set(Boost_ADDITIONAL_VERSIONS "1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39" "1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44" "1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49" - "1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54" + "1.50.0" "1.50" "1.51.0" "1.51" "1.53.0" "1.53" "1.54.0" "1.54" "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59" "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" diff --git a/docs/doxygen/other/main_page.dox b/docs/doxygen/other/main_page.dox index 681dea41c8..59ee96d7f9 100644 --- a/docs/doxygen/other/main_page.dox +++ b/docs/doxygen/other/main_page.dox @@ -201,7 +201,7 @@ buffer, which may be different than what was initially specified. It is possible to reconfigure the flowgraph at runtime. The reconfiguration is meant for changes in the flowgraph structure, not individual parameter settings of the blocks. For example, changing the -constant in a gr_add_const_cc block can be done while the flowgraph is +constant in a gr::blocks::add_const_cc block can be done while the flowgraph is running using the 'set_k(k)' method. Reconfiguration is done by locking the flowgraph, which stops it from @@ -209,21 +209,22 @@ running and processing data, performing the reconfiguration, and then restarting the graph by unlocking it. The following example code shows a graph that first adds two -analog::noise_source_c blocks and then replaces the gr_add_cc block with a -gr_sub_cc block to then subtract the sources. +gr::analog::noise_source_c blocks and then replaces the +gr::blocks::add_cc block with a gr::blocks::sub_cc block to then +subtract the sources. \code -from gnuradio import gr, analog +from gnuradio import gr, analog, blocks import time class mytb(gr.top_block): def __init__(self): gr.top_block.__init__(self) - self.src0 = analog.noise_source_c(gr.GR_GAUSSIAN, 1) - self.src1 = analog.noise_source_c(gr.GR_GAUSSIAN, 1) - self.add = gr.add_cc() - self.sub = gr.sub_cc() + self.src0 = analog.noise_source_c(analog.GR_GAUSSIAN, 1) + self.src1 = analog.noise_source_c(analog.GR_GAUSSIAN, 1) + self.add = blocks.add_cc() + self.sub = blocks.sub_cc() self.head = gr.head(gr.sizeof_gr_complex, 1000000) self.snk = gr.file_sink(gr.sizeof_gr_complex, "output.32fc") @@ -268,17 +269,17 @@ The following example expands the previous example but sets and resets the max noutput_items both locally and globally. \code -from gnuradio import gr, analog +from gnuradio import gr, analog, blocks import time class mytb(gr.top_block): def __init__(self): gr.top_block.__init__(self) - self.src0 = analog.noise_source_c(gr.GR_GAUSSIAN, 1) - self.src1 = analog.noise_source_c(gr.GR_GAUSSIAN, 1) - self.add = gr.add_cc() - self.sub = gr.sub_cc() + self.src0 = analog.noise_source_c(analog.GR_GAUSSIAN, 1) + self.src1 = analog.noise_source_c(analog.GR_GAUSSIAN, 1) + self.add = blocks.add_cc() + self.sub = blocks.sub_cc() self.head = gr.head(gr.sizeof_gr_complex, 1000000) self.snk = gr.file_sink(gr.sizeof_gr_complex, "output.32fc") diff --git a/docs/sphinx/source/blks2/blks.rst b/docs/sphinx/source/blks2/blks.rst deleted file mode 100644 index 6510169710..0000000000 --- a/docs/sphinx/source/blks2/blks.rst +++ /dev/null @@ -1,9 +0,0 @@ -gnuradio.blks2: Signal Processing Blocks -======================================== - -.. autopyblock:: gnuradio.blks2.rational_resampler_ccc -.. autopyblock:: gnuradio.blks2.rational_resampler_ccf -.. autopyblock:: gnuradio.blks2.rational_resampler_fff -.. autopyblock:: gnuradio.blks2.analysis_filterbank -.. autopyblock:: gnuradio.blks2.stream_to_vector_decimator -.. autopyblock:: gnuradio.blks2.synthesis_filterbank diff --git a/docs/sphinx/source/blks2/index.rst b/docs/sphinx/source/blks2/index.rst deleted file mode 100644 index 7a911d001b..0000000000 --- a/docs/sphinx/source/blks2/index.rst +++ /dev/null @@ -1,25 +0,0 @@ -gnuradio.blks2 -============== - -.. automodule:: gnuradio.blks2 - -Signal Processing Blocks ------------------------- - -.. autosummary:: - :nosignatures: - - gnuradio.blks2.rational_resampler_ccc - gnuradio.blks2.rational_resampler_ccf - gnuradio.blks2.rational_resampler_fff - gnuradio.blks2.analysis_filterbank - gnuradio.blks2.stream_to_vector_decimator - gnuradio.blks2.synthesis_filterbank - -Utility Functions ------------------ - -.. autosummary:: - :nosignatures: - - gnuradio.blks2.design_filter diff --git a/docs/sphinx/source/blks2/utilities.rst b/docs/sphinx/source/blks2/utilities.rst deleted file mode 100644 index 3ce068fb41..0000000000 --- a/docs/sphinx/source/blks2/utilities.rst +++ /dev/null @@ -1,4 +0,0 @@ -gnuradio.blks2: Utility Functions -================================= - -.. autoclass:: gnuradio.blks2.design_filter diff --git a/docs/sphinx/source/gr/converter_blk.rst b/docs/sphinx/source/gr/converter_blk.rst index 4ae469c2ac..98cfcfee9f 100644 --- a/docs/sphinx/source/gr/converter_blk.rst +++ b/docs/sphinx/source/gr/converter_blk.rst @@ -1,7 +1,6 @@ gnuradio.gr: Type Conversions ============================= -.. autooldblock:: gnuradio.gr.char_to_float .. autooldblock:: gnuradio.gr.complex_to_interleaved_short .. autooldblock:: gnuradio.gr.complex_to_float .. autooldblock:: gnuradio.gr.complex_to_real @@ -9,13 +8,6 @@ gnuradio.gr: Type Conversions .. autooldblock:: gnuradio.gr.complex_to_mag .. autooldblock:: gnuradio.gr.complex_to_mag_squared .. autooldblock:: gnuradio.gr.complex_to_arg -.. autooldblock:: gnuradio.gr.float_to_char -.. autooldblock:: gnuradio.gr.float_to_complex -.. autooldblock:: gnuradio.gr.float_to_short -.. autooldblock:: gnuradio.gr.float_to_uchar -.. autooldblock:: gnuradio.gr.interleaved_short_to_complex -.. autooldblock:: gnuradio.gr.short_to_float -.. autooldblock:: gnuradio.gr.uchar_to_float .. autooldblock:: gnuradio.gr.unpack_k_bits_bb .. autooldblock:: gnuradio.gr.packed_to_unpacked_bb .. autooldblock:: gnuradio.gr.packed_to_unpacked_ii diff --git a/docs/sphinx/source/gr/filter_design.rst b/docs/sphinx/source/gr/filter_design.rst deleted file mode 100644 index 6ab23c50bf..0000000000 --- a/docs/sphinx/source/gr/filter_design.rst +++ /dev/null @@ -1,7 +0,0 @@ -gnuradio.gr: Digital Filter Design -================================== - -.. autoclass:: gnuradio.gr.firdes - :members: - -.. autofunction:: gnuradio.gr.remez diff --git a/docs/sphinx/source/gr/index.rst b/docs/sphinx/source/gr/index.rst index ec4671d545..6d09b861ef 100644 --- a/docs/sphinx/source/gr/index.rst +++ b/docs/sphinx/source/gr/index.rst @@ -114,62 +114,9 @@ Mathematics .. autosummary:: :nosignatures: - gnuradio.gr.conjugate_cc - gnuradio.gr.nlog10_ff gnuradio.gr.rms_cf gnuradio.gr.rms_ff - gnuradio.gr.add_cc - gnuradio.gr.add_const_cc - gnuradio.gr.add_const_ff - gnuradio.gr.add_const_ii - gnuradio.gr.add_const_sf - gnuradio.gr.add_const_ss - gnuradio.gr.add_const_vcc - gnuradio.gr.add_const_vff - gnuradio.gr.add_const_vii - gnuradio.gr.add_const_vss - gnuradio.gr.add_ff - gnuradio.gr.add_ii - gnuradio.gr.add_ss - gnuradio.gr.and_bb - gnuradio.gr.and_const_bb - gnuradio.gr.and_const_ii - gnuradio.gr.and_const_ss - gnuradio.gr.and_ii - gnuradio.gr.and_ss - gnuradio.gr.divide_cc - gnuradio.gr.divide_ff - gnuradio.gr.divide_ii - gnuradio.gr.divide_ss - gnuradio.gr.integrate_cc - gnuradio.gr.integrate_ff - gnuradio.gr.integrate_ii - gnuradio.gr.integrate_ss - gnuradio.gr.multiply_cc - gnuradio.gr.multiply_const_cc - gnuradio.gr.multiply_const_ff - gnuradio.gr.multiply_const_ii - gnuradio.gr.multiply_const_ss - gnuradio.gr.multiply_const_vcc - gnuradio.gr.multiply_const_vff - gnuradio.gr.multiply_const_vii - gnuradio.gr.multiply_const_vss - gnuradio.gr.multiply_ff - gnuradio.gr.multiply_ii - gnuradio.gr.multiply_ss - gnuradio.gr.not_bb - gnuradio.gr.not_ii - gnuradio.gr.not_ss - gnuradio.gr.or_bb - gnuradio.gr.or_ii - gnuradio.gr.or_ss - gnuradio.gr.sub_cc - gnuradio.gr.sub_ff - gnuradio.gr.sub_ii - gnuradio.gr.sub_ss - gnuradio.gr.xor_bb - gnuradio.gr.xor_ii - gnuradio.gr.xor_ss + Information Coding and Decoding ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -194,7 +141,6 @@ Type Conversions .. autosummary:: :nosignatures: - gnuradio.gr.char_to_float gnuradio.gr.complex_to_interleaved_short gnuradio.gr.complex_to_float gnuradio.gr.complex_to_real @@ -202,13 +148,6 @@ Type Conversions gnuradio.gr.complex_to_mag gnuradio.gr.complex_to_mag_squared gnuradio.gr.complex_to_arg - gnuradio.gr.float_to_char - gnuradio.gr.float_to_complex - gnuradio.gr.float_to_short - gnuradio.gr.float_to_uchar - gnuradio.gr.interleaved_short_to_complex - gnuradio.gr.short_to_float - gnuradio.gr.uchar_to_float gnuradio.gr.unpack_k_bits_bb gnuradio.gr.packed_to_unpacked_bb gnuradio.gr.packed_to_unpacked_ii @@ -258,7 +197,6 @@ Miscellaneous Blocks gnuradio.gr.kludge_copy gnuradio.gr.nop gnuradio.gr.pa_2x2_phase_combiner - gnuradio.gr.repeat gnuradio.gr.threshold_ff gnuradio.gr.throttle gnuradio.gr.channel_model @@ -269,17 +207,8 @@ Slicing and Dicing Streams .. autosummary:: :nosignatures: - gnuradio.gr.deinterleave gnuradio.gr.head - gnuradio.gr.interleave - gnuradio.gr.keep_one_in_n gnuradio.gr.skiphead - gnuradio.gr.stream_to_streams - gnuradio.gr.stream_to_vector - gnuradio.gr.streams_to_stream - gnuradio.gr.streams_to_vector - gnuradio.gr.vector_to_stream - gnuradio.gr.vector_to_streams Digital Filter Design --------------------- diff --git a/docs/sphinx/source/gr/math_blk.rst b/docs/sphinx/source/gr/math_blk.rst index 7b9437f995..208318def2 100644 --- a/docs/sphinx/source/gr/math_blk.rst +++ b/docs/sphinx/source/gr/math_blk.rst @@ -1,59 +1,5 @@ gnuradio.gr: Mathematics ======================== -.. autooldblock:: gnuradio.gr.conjugate_cc -.. autooldblock:: gnuradio.gr.nlog10_ff .. autooldblock:: gnuradio.gr.rms_cf .. autooldblock:: gnuradio.gr.rms_ff -.. autooldblock:: gnuradio.gr.add_cc -.. autooldblock:: gnuradio.gr.add_const_cc -.. autooldblock:: gnuradio.gr.add_const_ff -.. autooldblock:: gnuradio.gr.add_const_ii -.. autooldblock:: gnuradio.gr.add_const_sf -.. autooldblock:: gnuradio.gr.add_const_ss -.. autooldblock:: gnuradio.gr.add_const_vcc -.. autooldblock:: gnuradio.gr.add_const_vff -.. autooldblock:: gnuradio.gr.add_const_vii -.. autooldblock:: gnuradio.gr.add_const_vss -.. autooldblock:: gnuradio.gr.add_ff -.. autooldblock:: gnuradio.gr.add_ii -.. autooldblock:: gnuradio.gr.add_ss -.. autooldblock:: gnuradio.gr.and_bb -.. autooldblock:: gnuradio.gr.and_const_bb -.. autooldblock:: gnuradio.gr.and_const_ii -.. autooldblock:: gnuradio.gr.and_const_ss -.. autooldblock:: gnuradio.gr.and_ii -.. autooldblock:: gnuradio.gr.and_ss -.. autooldblock:: gnuradio.gr.divide_cc -.. autooldblock:: gnuradio.gr.divide_ff -.. autooldblock:: gnuradio.gr.divide_ii -.. autooldblock:: gnuradio.gr.divide_ss -.. autooldblock:: gnuradio.gr.integrate_cc -.. autooldblock:: gnuradio.gr.integrate_ff -.. autooldblock:: gnuradio.gr.integrate_ii -.. autooldblock:: gnuradio.gr.integrate_ss -.. autooldblock:: gnuradio.gr.multiply_cc -.. autooldblock:: gnuradio.gr.multiply_const_cc -.. autooldblock:: gnuradio.gr.multiply_const_ff -.. autooldblock:: gnuradio.gr.multiply_const_ii -.. autooldblock:: gnuradio.gr.multiply_const_ss -.. autooldblock:: gnuradio.gr.multiply_const_vcc -.. autooldblock:: gnuradio.gr.multiply_const_vff -.. autooldblock:: gnuradio.gr.multiply_const_vii -.. autooldblock:: gnuradio.gr.multiply_const_vss -.. autooldblock:: gnuradio.gr.multiply_ff -.. autooldblock:: gnuradio.gr.multiply_ii -.. autooldblock:: gnuradio.gr.multiply_ss -.. autooldblock:: gnuradio.gr.not_bb -.. autooldblock:: gnuradio.gr.not_ii -.. autooldblock:: gnuradio.gr.not_ss -.. autooldblock:: gnuradio.gr.or_bb -.. autooldblock:: gnuradio.gr.or_ii -.. autooldblock:: gnuradio.gr.or_ss -.. autooldblock:: gnuradio.gr.sub_cc -.. autooldblock:: gnuradio.gr.sub_ff -.. autooldblock:: gnuradio.gr.sub_ii -.. autooldblock:: gnuradio.gr.sub_ss -.. autooldblock:: gnuradio.gr.xor_bb -.. autooldblock:: gnuradio.gr.xor_ii -.. autooldblock:: gnuradio.gr.xor_ss diff --git a/docs/sphinx/source/gr/misc_blk.rst b/docs/sphinx/source/gr/misc_blk.rst index c69293056c..56bcb7fbde 100644 --- a/docs/sphinx/source/gr/misc_blk.rst +++ b/docs/sphinx/source/gr/misc_blk.rst @@ -6,7 +6,6 @@ gnuradio.gr: Miscellaneous Blocks .. autooldblock:: gnuradio.gr.kludge_copy .. autooldblock:: gnuradio.gr.nop .. autooldblock:: gnuradio.gr.pa_2x2_phase_combiner -.. autooldblock:: gnuradio.gr.repeat .. autooldblock:: gnuradio.gr.threshold_ff .. autooldblock:: gnuradio.gr.throttle .. autooldblock:: gnuradio.gr.channel_model diff --git a/docs/sphinx/source/gr/slicedice_blk.rst b/docs/sphinx/source/gr/slicedice_blk.rst index e845627aad..9ade1667d5 100644 --- a/docs/sphinx/source/gr/slicedice_blk.rst +++ b/docs/sphinx/source/gr/slicedice_blk.rst @@ -1,14 +1,5 @@ gnuradio.gr: Slicing and Dicing Streams ======================================= -.. autooldblock:: gnuradio.gr.deinterleave .. autooldblock:: gnuradio.gr.head -.. autooldblock:: gnuradio.gr.interleave -.. autooldblock:: gnuradio.gr.keep_one_in_n .. autooldblock:: gnuradio.gr.skiphead -.. autooldblock:: gnuradio.gr.stream_to_streams -.. autooldblock:: gnuradio.gr.stream_to_vector -.. autooldblock:: gnuradio.gr.streams_to_stream -.. autooldblock:: gnuradio.gr.streams_to_vector -.. autooldblock:: gnuradio.gr.vector_to_stream -.. autooldblock:: gnuradio.gr.vector_to_streams diff --git a/docs/sphinx/source/index.rst b/docs/sphinx/source/index.rst index 38d859aafd..988b6554c5 100644 --- a/docs/sphinx/source/index.rst +++ b/docs/sphinx/source/index.rst @@ -11,13 +11,10 @@ Core Framework gnuradio.gr gnuradio.digital - gnuradio.blks2 gnuradio.audio gnuradio.trellis gnuradio.wavelet gnuradio.fft - gnuradio.window - gnuradio.optfir gnuradio.gr_unittest gnuradio.qtgui gnuradio.wxgui @@ -27,14 +24,11 @@ Core Framework gnuradio.gr <gr/index> gnuradio.digital <digital/index> - gnuradio.blks2 <blks2/index> gnuradio.audio <audio/index> gnuradio.gr_unittest <gr_unittest/index> - gnuradio.optfir <optfir/index> gnuradio.trellis <trellis/index> gnuradio.wavelet <wavelet> gnuradio.fft <fft> - gnuradio.window <window/index> gnuradio.qtgui <qtgui/index> gnuradio.wxgui <wxgui/index> diff --git a/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py b/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py index 81613922b8..ac060c0cce 100755 --- a/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py +++ b/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py @@ -22,7 +22,8 @@ from gnuradio import gr, gru, eng_notation, optfir from gnuradio import audio -from gnuradio import blks2 +from gnuradio import analog +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import sys @@ -70,12 +71,12 @@ class wfm_rx_block (gr.top_block): chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) - #self.guts = blks2.wfm_rcv (demod_rate, audio_decimation) - self.guts = blks2.wfm_rcv_pll (demod_rate, audio_decimation) + #self.guts = analog.wfm_rcv (demod_rate, audio_decimation) + self.guts = analog.wfm_rcv_pll (demod_rate, audio_decimation) # FIXME rework {add,multiply}_const_* to handle multiple streams - self.volume_control_l = gr.multiply_const_ff(self.vol) - self.volume_control_r = gr.multiply_const_ff(self.vol) + self.volume_control_l = blocks.multiply_const_ff(self.vol) + self.volume_control_r = blocks.multiply_const_ff(self.vol) # wave file as final sink if 1: diff --git a/gnuradio-core/src/examples/network/dial_tone_source.py b/gnuradio-core/src/examples/network/dial_tone_source.py index 8c826e2ad4..a8d85c4c57 100755 --- a/gnuradio-core/src/examples/network/dial_tone_source.py +++ b/gnuradio-core/src/examples/network/dial_tone_source.py @@ -28,7 +28,12 @@ import sys try: from gnuradio import analog except ImportError: - sys.stderr.write("This example required gr-analog.\n") + sys.stderr.write("This example requires gr-analog.\n") + +try: + from gnuradio import blocks +except ImportError: + sys.stderr.write("This example requires gr-blocks.\n") class dial_tone_source(gr.top_block): def __init__(self, host, port, pkt_size, sample_rate, eof): @@ -37,7 +42,7 @@ class dial_tone_source(gr.top_block): amplitude = 0.3 src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, amplitude) src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, amplitude) - add = gr.add_ff() + add = blocks.add_ff() # Throttle needed here to account for the other side's audio card sampling rate thr = gr.throttle(gr.sizeof_float, sample_rate) diff --git a/gnuradio-core/src/examples/volk_benchmark/volk_math.py b/gnuradio-core/src/examples/volk_benchmark/volk_math.py index 1d8bf04cc0..753257c237 100755 --- a/gnuradio-core/src/examples/volk_benchmark/volk_math.py +++ b/gnuradio-core/src/examples/volk_benchmark/volk_math.py @@ -1,12 +1,18 @@ #!/usr/bin/env python from gnuradio import gr +from gnuradio import blocks import argparse from volk_test_funcs import * +try: + from gnuradio import blocks +except ImportError: + sys.stderr.write("This example requires gr-blocks.\n") + def multiply_const_cc(N): k = 3.3 - op = gr.multiply_const_cc(k) + op = blocks.multiply_const_cc(k) tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_gr_complex, 1, 1) return tb @@ -14,35 +20,35 @@ def multiply_const_cc(N): def multiply_const_ff(N): k = 3.3 - op = gr.multiply_const_ff(k) + op = blocks.multiply_const_ff(k) tb = helper(N, op, gr.sizeof_float, gr.sizeof_float, 1, 1) return tb ###################################################################### def multiply_cc(N): - op = gr.multiply_cc(1) + op = blocks.multiply_cc(1) tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_gr_complex, 2, 1) return tb ###################################################################### def multiply_ff(N): - op = gr.multiply_ff() + op = blocks.multiply_ff() tb = helper(N, op, gr.sizeof_float, gr.sizeof_float, 2, 1) return tb ###################################################################### def add_ff(N): - op = gr.add_ff() + op = blocks.add_ff() tb = helper(N, op, gr.sizeof_float, gr.sizeof_float, 2, 1) return tb ###################################################################### def conjugate_cc(N): - op = gr.conjugate_cc() + op = blocks.conjugate_cc() tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_gr_complex, 1, 1) return tb @@ -50,7 +56,7 @@ def conjugate_cc(N): def multiply_conjugate_cc(N): try: - op = gr.multiply_conjugate_cc() + op = blocks.multiply_conjugate_cc() tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_gr_complex, 2, 1) return tb @@ -60,8 +66,8 @@ def multiply_conjugate_cc(N): gr.hier_block2.__init__(self, "s", gr.io_signature(2, 2, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex)) - conj = gr.conjugate_cc() - mult = gr.multiply_cc() + conj = blocks.conjugate_cc() + mult = blocks.multiply_cc() self.connect((self,0), (mult,0)) self.connect((self,1), conj, (mult,1)) self.connect(mult, self) diff --git a/gnuradio-core/src/examples/volk_benchmark/volk_types.py b/gnuradio-core/src/examples/volk_benchmark/volk_types.py index 5dac23c535..134a3db781 100755 --- a/gnuradio-core/src/examples/volk_benchmark/volk_types.py +++ b/gnuradio-core/src/examples/volk_benchmark/volk_types.py @@ -1,62 +1,49 @@ #!/usr/bin/env python from gnuradio import gr +from gnuradio import blocks import argparse from volk_test_funcs import * ###################################################################### def float_to_char(N): - op = gr.float_to_char() + op = blocks.float_to_char() tb = helper(N, op, gr.sizeof_float, gr.sizeof_char, 1, 1) return tb ###################################################################### def float_to_int(N): - op = gr.float_to_int() + op = blocks.float_to_int() tb = helper(N, op, gr.sizeof_float, gr.sizeof_int, 1, 1) return tb ###################################################################### def float_to_short(N): - op = gr.float_to_short() + op = blocks.float_to_short() tb = helper(N, op, gr.sizeof_float, gr.sizeof_short, 1, 1) return tb ###################################################################### def short_to_float(N): - op = gr.short_to_float() + op = blocks.short_to_float() tb = helper(N, op, gr.sizeof_short, gr.sizeof_float, 1, 1) return tb ###################################################################### def short_to_char(N): - op = gr.short_to_char() + op = blocks.short_to_char() tb = helper(N, op, gr.sizeof_short, gr.sizeof_char, 1, 1) return tb ###################################################################### -def char_to_short(N): - op = gr.char_to_short() - tb = helper(N, op, gr.sizeof_char, gr.sizeof_short, 1, 1) - return tb - -###################################################################### - -def char_to_float(N): - op = gr.char_to_float() - tb = helper(N, op, gr.sizeof_char, gr.sizeof_float, 1, 1) - return tb - -###################################################################### - def int_to_float(N): - op = gr.int_to_float() + op = blocks.int_to_float() tb = helper(N, op, gr.sizeof_int, gr.sizeof_float, 1, 1) return tb diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index 5978a035c7..6d67b333b9 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -76,18 +76,9 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/gr_random.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_reverse.cc ${CMAKE_CURRENT_SOURCE_DIR}/gri_add_const_ss_generic.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_char_to_float.cc ${CMAKE_CURRENT_SOURCE_DIR}/gri_control_loop.cc ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.cc ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_char.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_int.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_short.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_uchar.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_interleaved_short_to_complex.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_int_to_float.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_short_to_float.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_uchar_to_float.cc ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.c ) @@ -126,20 +117,11 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_test_types.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_vco.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_add_const_ss.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_char_to_float.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_control_loop.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_char.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_int.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_short.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_uchar.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_interleaved_short_to_complex.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_15_1_0.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_32k.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_int_to_float.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_short_to_float.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_uchar_to_float.h ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.h ${CMAKE_CURRENT_SOURCE_DIR}/random.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio @@ -164,44 +146,23 @@ endif(ENABLE_PYTHON) ######################################################################## set(gr_core_general_triple_threats complex_vec_test - gr_add_ff gr_align_on_samplenumbers_ss gr_bin_statistics_f gr_block_gateway - gr_char_to_float - gr_char_to_short gr_check_counting_s gr_check_lfsr_32k_s gr_complex_to_interleaved_short gr_complex_to_xxx - gr_conjugate_cc gr_copy - gr_deinterleave gr_delay gr_endian_swap gr_fake_channel_coder_pp gr_feval gr_firdes - gr_float_to_char - gr_float_to_complex - gr_float_to_int - gr_float_to_short - gr_float_to_uchar gr_head - gr_int_to_float - gr_interleave - gr_interleaved_short_to_complex gr_iqcomp_cc - gr_keep_one_in_n - gr_keep_m_in_n gr_kludge_copy gr_lfsr_32k_source_s - gr_multiply_cc - gr_multiply_ff - gr_multiply_const_cc - gr_multiply_const_ff - gr_multiply_conjugate_cc - gr_nlog10_ff gr_nop gr_null_sink gr_null_source @@ -212,26 +173,15 @@ set(gr_core_general_triple_threats gr_remez gr_rms_cf gr_rms_ff - gr_repeat - gr_short_to_float - gr_short_to_char gr_simple_correlator gr_skiphead - gr_stream_mux - gr_stream_to_streams - gr_stream_to_vector - gr_streams_to_stream - gr_streams_to_vector gr_stretch_ff gr_test gr_threshold_ff gr_throttle gr_transcendental - gr_uchar_to_float gr_vco_f gr_vector_map - gr_vector_to_stream - gr_vector_to_streams gr_unpack_k_bits_bb gr_pack_k_bits_bb gr_annotator_alltoall diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 9af804afed..4e483500ee 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -29,47 +29,22 @@ #include <gr_head.h> #include <gr_skiphead.h> #include <gr_remez.h> -#include <gr_float_to_complex.h> #include <gr_check_counting_s.h> #include <gr_lfsr_32k_source_s.h> #include <gr_check_lfsr_32k_s.h> -#include <gr_stream_to_vector.h> -#include <gr_vector_to_stream.h> -#include <gr_keep_one_in_n.h> -#include <gr_keep_m_in_n.h> -#include <gr_float_to_int.h> -#include <gr_float_to_short.h> -#include <gr_float_to_char.h> -#include <gr_float_to_uchar.h> -#include <gr_short_to_float.h> -#include <gr_short_to_char.h> -#include <gr_int_to_float.h> -#include <gr_char_to_float.h> -#include <gr_char_to_short.h> -#include <gr_uchar_to_float.h> #include <gr_simple_correlator.h> #include <gr_align_on_samplenumbers_ss.h> #include <gr_complex_to_xxx.h> #include <gr_complex_to_interleaved_short.h> -#include <gr_interleaved_short_to_complex.h> //#include <gr_endianness.h> #include <gr_endian_swap.h> #include <gr_firdes.h> -#include <gr_interleave.h> -#include <gr_deinterleave.h> #include <gr_delay.h> #include <gr_rms_cf.h> #include <gr_rms_ff.h> -#include <gr_nlog10_ff.h> #include <gr_fake_channel_coder_pp.h> #include <gr_throttle.h> #include <gr_transcendental.h> -#include <gr_stream_mux.h> -#include <gr_stream_to_streams.h> -#include <gr_streams_to_stream.h> -#include <gr_streams_to_vector.h> -#include <gr_vector_to_streams.h> -#include <gr_conjugate_cc.h> #include <gr_vco_f.h> #include <gr_threshold_ff.h> #include <gr_regenerate_bb.h> @@ -81,15 +56,9 @@ #include <gr_test.h> #include <gr_unpack_k_bits_bb.h> #include <gr_pack_k_bits_bb.h> -#include <gr_multiply_cc.h> -#include <gr_multiply_ff.h> -#include <gr_multiply_const_cc.h> -#include <gr_multiply_const_ff.h> -#include <gr_multiply_conjugate_cc.h> #include <gr_feval.h> #include <gr_bin_statistics_f.h> #include <gr_peak_detector2_fb.h> -#include <gr_repeat.h> #include <gr_stretch_ff.h> #include <gr_copy.h> #include <complex_vec_test.h> @@ -98,7 +67,6 @@ #include <gr_annotator_raw.h> #include <gr_burst_tagger.h> #include <gr_vector_map.h> -#include <gr_add_ff.h> #include <gr_tag_debug.h> #include <gr_message_strobe.h> %} @@ -110,47 +78,22 @@ %include "gr_head.i" %include "gr_skiphead.i" %include "gr_remez.i" -%include "gr_float_to_complex.i" %include "gr_check_counting_s.i" %include "gr_lfsr_32k_source_s.i" %include "gr_check_lfsr_32k_s.i" -%include "gr_stream_to_vector.i" -%include "gr_vector_to_stream.i" -%include "gr_keep_one_in_n.i" -%include "gr_keep_m_in_n.i" -%include "gr_float_to_int.i" -%include "gr_float_to_short.i" -%include "gr_float_to_char.i" -%include "gr_float_to_uchar.i" -%include "gr_short_to_float.i" -%include "gr_short_to_char.i" -%include "gr_int_to_float.i" -%include "gr_char_to_float.i" -%include "gr_char_to_short.i" -%include "gr_uchar_to_float.i" %include "gr_simple_correlator.i" %include "gr_align_on_samplenumbers_ss.i" %include "gr_complex_to_xxx.i" %include "gr_complex_to_interleaved_short.i" //%include "gr_endianness.i" %include "gr_endian_swap.i" -%include "gr_interleaved_short_to_complex.i" %include "gr_firdes.i" -%include "gr_interleave.i" -%include "gr_deinterleave.i" %include "gr_delay.i" %include "gr_rms_cf.i" %include "gr_rms_ff.i" -%include "gr_nlog10_ff.i" %include "gr_fake_channel_coder_pp.i" %include "gr_throttle.i" %include "gr_transcendental.i" -%include "gr_stream_mux.i" -%include "gr_stream_to_streams.i" -%include "gr_streams_to_stream.i" -%include "gr_streams_to_vector.i" -%include "gr_vector_to_streams.i" -%include "gr_conjugate_cc.i" %include "gr_vco_f.i" %include "gr_threshold_ff.i" %include "gr_regenerate_bb.i" @@ -162,15 +105,9 @@ %include "gr_test.i" %include "gr_unpack_k_bits_bb.i" %include "gr_pack_k_bits_bb.i" -%include "gr_multiply_cc.i" -%include "gr_multiply_ff.i" -%include "gr_multiply_const_cc.i" -%include "gr_multiply_const_ff.i" -%include "gr_multiply_conjugate_cc.i" %include "gr_feval.i" %include "gr_bin_statistics_f.i" %include "gr_peak_detector2_fb.i" -%include "gr_repeat.i" %include "gr_stretch_ff.i" %include "gr_copy.i" %include "complex_vec_test.i" @@ -179,7 +116,6 @@ %include "gr_annotator_raw.i" %include "gr_burst_tagger.i" %include "gr_vector_map.i" -%include "gr_add_ff.i" %include "gr_tag_debug.i" %include "gr_block_gateway.i" %include "gr_message_strobe.i" diff --git a/gnuradio-core/src/lib/general/general_generated.i b/gnuradio-core/src/lib/general/general_generated.i index 5671570a6f..251406c99e 100644 --- a/gnuradio-core/src/lib/general/general_generated.i +++ b/gnuradio-core/src/lib/general/general_generated.i @@ -2,38 +2,6 @@ // This file is machine generated. All edits will be overwritten // %{ -#include <gr_add_cc.h> -#include <gr_add_const_cc.h> -#include <gr_add_const_ff.h> -#include <gr_add_const_ii.h> -#include <gr_add_const_sf.h> -#include <gr_add_const_ss.h> -#include <gr_add_const_vcc.h> -#include <gr_add_const_vff.h> -#include <gr_add_const_vii.h> -#include <gr_add_const_vss.h> -#include <gr_add_ii.h> -#include <gr_add_ss.h> -#include <gr_add_vcc.h> -#include <gr_add_vff.h> -#include <gr_add_vii.h> -#include <gr_add_vss.h> -#include <gr_divide_cc.h> -#include <gr_divide_ff.h> -#include <gr_divide_ii.h> -#include <gr_divide_ss.h> -#include <gr_multiply_const_ii.h> -#include <gr_multiply_const_ss.h> -#include <gr_multiply_const_vcc.h> -#include <gr_multiply_const_vff.h> -#include <gr_multiply_const_vii.h> -#include <gr_multiply_const_vss.h> -#include <gr_multiply_ii.h> -#include <gr_multiply_ss.h> -#include <gr_multiply_vcc.h> -#include <gr_multiply_vff.h> -#include <gr_multiply_vii.h> -#include <gr_multiply_vss.h> #include <gr_mute_cc.h> #include <gr_mute_ff.h> #include <gr_mute_ii.h> @@ -51,10 +19,6 @@ #include <gr_probe_signal_vi.h> #include <gr_probe_signal_vf.h> #include <gr_probe_signal_vc.h> -#include <gr_sub_cc.h> -#include <gr_sub_ff.h> -#include <gr_sub_ii.h> -#include <gr_sub_ss.h> #include <gr_unpacked_to_packed_bb.h> #include <gr_unpacked_to_packed_ii.h> #include <gr_unpacked_to_packed_ss.h> @@ -70,38 +34,6 @@ #include <gr_vector_source_s.h> %} -%include <gr_add_cc.i> -%include <gr_add_const_cc.i> -%include <gr_add_const_ff.i> -%include <gr_add_const_ii.i> -%include <gr_add_const_sf.i> -%include <gr_add_const_ss.i> -%include <gr_add_const_vcc.i> -%include <gr_add_const_vff.i> -%include <gr_add_const_vii.i> -%include <gr_add_const_vss.i> -%include <gr_add_ii.i> -%include <gr_add_ss.i> -%include <gr_add_vcc.i> -%include <gr_add_vff.i> -%include <gr_add_vii.i> -%include <gr_add_vss.i> -%include <gr_divide_cc.i> -%include <gr_divide_ff.i> -%include <gr_divide_ii.i> -%include <gr_divide_ss.i> -%include <gr_multiply_const_ii.i> -%include <gr_multiply_const_ss.i> -%include <gr_multiply_const_vcc.i> -%include <gr_multiply_const_vff.i> -%include <gr_multiply_const_vii.i> -%include <gr_multiply_const_vss.i> -%include <gr_multiply_ii.i> -%include <gr_multiply_ss.i> -%include <gr_multiply_vcc.i> -%include <gr_multiply_vff.i> -%include <gr_multiply_vii.i> -%include <gr_multiply_vss.i> %include <gr_mute_cc.i> %include <gr_mute_ff.i> %include <gr_mute_ii.i> @@ -119,10 +51,6 @@ %include <gr_probe_signal_vi.i> %include <gr_probe_signal_vf.i> %include <gr_probe_signal_vc.i> -%include <gr_sub_cc.i> -%include <gr_sub_ff.i> -%include <gr_sub_ii.i> -%include <gr_sub_ss.i> %include <gr_unpacked_to_packed_bb.i> %include <gr_unpacked_to_packed_ii.i> %include <gr_unpacked_to_packed_ss.i> diff --git a/gnuradio-core/src/lib/general/gr_add_ff.cc b/gnuradio-core/src/lib/general/gr_add_ff.cc deleted file mode 100644 index 5f6676bb7b..0000000000 --- a/gnuradio-core/src/lib/general/gr_add_ff.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_add_ff.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_add_ff_sptr -gr_make_add_ff(size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_add_ff(vlen)); -} - -gr_add_ff::gr_add_ff (size_t vlen) - : gr_sync_block("add_ff", - gr_make_io_signature (1, -1, sizeof(float)*vlen), - gr_make_io_signature (1, 1, sizeof(float)*vlen)), - d_vlen (vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_add_ff::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *out = (float *) output_items[0]; - int noi = d_vlen*noutput_items; - - memcpy(out, input_items[0], noi*sizeof(float)); - if(is_unaligned()) { - for(size_t i = 1; i < input_items.size(); i++) - volk_32f_x2_add_32f_u(out, out, (const float*)input_items[i], noi); - } - else { - for(size_t i = 1; i < input_items.size(); i++) - volk_32f_x2_add_32f_a(out, out, (const float*)input_items[i], noi); - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_add_ff.h b/gnuradio-core/src/lib/general/gr_add_ff.h deleted file mode 100644 index ff5604c97d..0000000000 --- a/gnuradio-core/src/lib/general/gr_add_ff.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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_ADD_FF_H -#define INCLUDED_GR_ADD_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_add_ff; -typedef boost::shared_ptr<gr_add_ff> gr_add_ff_sptr; - -GR_CORE_API gr_add_ff_sptr -gr_make_add_ff (size_t vlen=1); - -/*! - * \brief Add streams of complex values - * \ingroup math_blk - */ - -class GR_CORE_API gr_add_ff : public gr_sync_block -{ - private: - friend GR_CORE_API gr_add_ff_sptr - gr_make_add_ff (size_t vlen); - gr_add_ff (size_t vlen); - - size_t d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_ADD_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_add_ff.i b/gnuradio-core/src/lib/general/gr_add_ff.i deleted file mode 100644 index 75a87651fa..0000000000 --- a/gnuradio-core/src/lib/general/gr_add_ff.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,add_ff) - -gr_add_ff_sptr -gr_make_add_ff (size_t vlen=1); - -class gr_add_ff : public gr_sync_block -{ -public: - -}; diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.cc b/gnuradio-core/src/lib/general/gr_char_to_float.cc deleted file mode 100644 index f63aa5b169..0000000000 --- a/gnuradio-core/src/lib/general/gr_char_to_float.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_char_to_float.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_char_to_float_sptr -gr_make_char_to_float (size_t vlen, float scale) -{ - return gnuradio::get_initial_sptr(new gr_char_to_float (vlen, scale)); -} - -gr_char_to_float::gr_char_to_float (size_t vlen, float scale) - : gr_sync_block ("gr_char_to_float", - gr_make_io_signature (1, 1, sizeof (char)*vlen), - gr_make_io_signature (1, 1, sizeof (float)*vlen)), - d_vlen(vlen), d_scale(scale) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -float -gr_char_to_float::scale() const -{ - return d_scale; -} - -void -gr_char_to_float::set_scale(float scale) -{ - d_scale = scale; -} - -int -gr_char_to_float::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const int8_t *in = (const int8_t *) input_items[0]; - float *out = (float *) output_items[0]; - - // Note: the unaligned benchmarked much faster than the aligned - volk_8i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.h b/gnuradio-core/src/lib/general/gr_char_to_float.h deleted file mode 100644 index 5170c618c9..0000000000 --- a/gnuradio-core/src/lib/general/gr_char_to_float.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_CHAR_TO_FLOAT_H -#define INCLUDED_GR_CHAR_TO_FLOAT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_char_to_float; -typedef boost::shared_ptr<gr_char_to_float> gr_char_to_float_sptr; - -GR_CORE_API gr_char_to_float_sptr -gr_make_char_to_float (size_t vlen=1, float scale=1); - -/*! - * \brief Convert stream of chars to a stream of float - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar divider to change the output signal scale. - */ - -class GR_CORE_API gr_char_to_float : public gr_sync_block -{ - private: - friend GR_CORE_API gr_char_to_float_sptr - gr_make_char_to_float (size_t vlen, float scale); - gr_char_to_float (size_t vlen, float scale); - - size_t d_vlen; - float d_scale; - - public: - /*! - * Get the scalar divider value. - */ - float scale() const; - - /*! - * Set the scalar divider value. - */ - void set_scale(float scale); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_CHAR_TO_FLOAT_H */ diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.i b/gnuradio-core/src/lib/general/gr_char_to_float.i deleted file mode 100644 index c0b3d75fef..0000000000 --- a/gnuradio-core/src/lib/general/gr_char_to_float.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,char_to_float) - -gr_char_to_float_sptr -gr_make_char_to_float (size_t vlen=1, float scale=1); - -class gr_char_to_float : public gr_sync_block -{ -public: - float scale() const; - void set_scale(float scale); -}; diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.cc b/gnuradio-core/src/lib/general/gr_char_to_short.cc deleted file mode 100644 index bb9bd8909e..0000000000 --- a/gnuradio-core/src/lib/general/gr_char_to_short.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_char_to_short.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_char_to_short_sptr -gr_make_char_to_short (size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_char_to_short (vlen)); -} - -gr_char_to_short::gr_char_to_short (size_t vlen) - : gr_sync_block ("gr_char_to_short", - gr_make_io_signature (1, 1, sizeof (char)*vlen), - gr_make_io_signature (1, 1, sizeof (short)*vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(char); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_char_to_short::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const int8_t *in = (const int8_t *) input_items[0]; - int16_t *out = (int16_t *) output_items[0]; - - if(is_unaligned()) { - volk_8i_convert_16i_u(out, in, d_vlen*noutput_items); - } - else { - volk_8i_convert_16i_a(out, in, d_vlen*noutput_items); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.h b/gnuradio-core/src/lib/general/gr_char_to_short.h deleted file mode 100644 index 7ac5e97b93..0000000000 --- a/gnuradio-core/src/lib/general/gr_char_to_short.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 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_CHAR_TO_SHORT_H -#define INCLUDED_GR_CHAR_TO_SHORT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_char_to_short; -typedef boost::shared_ptr<gr_char_to_short> gr_char_to_short_sptr; - -GR_CORE_API gr_char_to_short_sptr -gr_make_char_to_short (size_t vlen=1); - -/*! - * \brief Convert stream of chars to a stream of float - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - */ - -class GR_CORE_API gr_char_to_short : public gr_sync_block -{ - private: - friend GR_CORE_API gr_char_to_short_sptr - gr_make_char_to_short (size_t vlen); - gr_char_to_short (size_t vlen); - - size_t d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_CHAR_TO_SHORT_H */ diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.i b/gnuradio-core/src/lib/general/gr_char_to_short.i deleted file mode 100644 index a53a0990e3..0000000000 --- a/gnuradio-core/src/lib/general/gr_char_to_short.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,char_to_short) - -gr_char_to_short_sptr gr_make_char_to_short (size_t vlen=1); - -class gr_char_to_short : public gr_sync_block -{ - -}; diff --git a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc b/gnuradio-core/src/lib/general/gr_conjugate_cc.cc deleted file mode 100644 index 94ac3e162b..0000000000 --- a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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: this file is machine generated. Edits will be over written - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_conjugate_cc.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_conjugate_cc_sptr -gr_make_conjugate_cc () -{ - return gnuradio::get_initial_sptr(new gr_conjugate_cc ()); -} - -gr_conjugate_cc::gr_conjugate_cc () - : gr_sync_block ("conjugate_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(gr_complex); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_conjugate_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *iptr = (gr_complex *) input_items[0]; - gr_complex *optr = (gr_complex *) output_items[0]; - - if(is_unaligned()) { - volk_32fc_conjugate_32fc_u(optr, iptr, noutput_items); - } - else { - volk_32fc_conjugate_32fc_a(optr, iptr, noutput_items); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_conjugate_cc.h b/gnuradio-core/src/lib/general/gr_conjugate_cc.h deleted file mode 100644 index e0a2af7164..0000000000 --- a/gnuradio-core/src/lib/general/gr_conjugate_cc.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- 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. - */ - -// WARNING: this file is machine generated. Edits will be over written - -#ifndef INCLUDED_GR_CONJUGATE_CC_H -#define INCLUDED_GR_CONJUGATE_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_conjugate_cc; -typedef boost::shared_ptr<gr_conjugate_cc> gr_conjugate_cc_sptr; - -GR_CORE_API gr_conjugate_cc_sptr gr_make_conjugate_cc (); - -/*! - * \brief output = complex conjugate of input - * \ingroup math_blk - */ -class GR_CORE_API gr_conjugate_cc : public gr_sync_block -{ - friend GR_CORE_API gr_conjugate_cc_sptr gr_make_conjugate_cc (); - - gr_conjugate_cc (); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_conjugate_cc.i b/gnuradio-core/src/lib/general/gr_conjugate_cc.i deleted file mode 100644 index 444ebb1b8b..0000000000 --- a/gnuradio-core/src/lib/general/gr_conjugate_cc.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- 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. - */ - -// WARNING: this file is machine generated. Edits will be over written - -GR_SWIG_BLOCK_MAGIC(gr,conjugate_cc) - -gr_conjugate_cc_sptr gr_make_conjugate_cc (); - -class gr_conjugate_cc : public gr_sync_block -{ - private: - gr_conjugate_cc (); -}; diff --git a/gnuradio-core/src/lib/general/gr_deinterleave.cc b/gnuradio-core/src/lib/general/gr_deinterleave.cc deleted file mode 100644 index e22db60c1a..0000000000 --- a/gnuradio-core/src/lib/general/gr_deinterleave.cc +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_deinterleave.h> -#include <gr_io_signature.h> -#include <string.h> - - -gr_deinterleave_sptr -gr_make_deinterleave (size_t itemsize) -{ - return gnuradio::get_initial_sptr(new gr_deinterleave (itemsize)); -} - -gr_deinterleave::gr_deinterleave (size_t itemsize) - : gr_sync_decimator ("deinterleave", - gr_make_io_signature (1, 1, itemsize), - gr_make_io_signature (1, gr_io_signature::IO_INFINITE, itemsize), - 1), - d_itemsize (itemsize) -{ -} - -gr_deinterleave::~gr_deinterleave () -{ - // NOP -} - -bool -gr_deinterleave::check_topology (int ninputs, int noutputs) -{ - set_decimation (noutputs); - return true; -} - -int -gr_deinterleave::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t nchan = output_items.size (); - size_t itemsize = d_itemsize; - const char *in = (const char *) input_items[0]; - char **out = (char **) &output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - for (unsigned int n = 0; n < nchan; n++){ - memcpy (out[n], in, itemsize); - out[n] += itemsize; - in += itemsize; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_deinterleave.h b/gnuradio-core/src/lib/general/gr_deinterleave.h deleted file mode 100644 index 0eecc44d13..0000000000 --- a/gnuradio-core/src/lib/general/gr_deinterleave.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- 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_GR_DEINTERLEAVE_H -#define INCLUDED_GR_DEINTERLEAVE_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_deinterleave; -typedef boost::shared_ptr<gr_deinterleave> gr_deinterleave_sptr; - -GR_CORE_API gr_deinterleave_sptr gr_make_deinterleave (size_t itemsize); - -/*! - * \brief deinterleave a single input into N outputs - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_deinterleave : public gr_sync_decimator -{ - friend GR_CORE_API gr_deinterleave_sptr gr_make_deinterleave (size_t itemsize); - - size_t d_itemsize; - - gr_deinterleave (size_t itemsize); - -public: - ~gr_deinterleave (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool check_topology (int ninputs, int noutputs); - -}; - -#endif /* INCLUDED_GR_DEINTERLEAVE_H */ diff --git a/gnuradio-core/src/lib/general/gr_deinterleave.i b/gnuradio-core/src/lib/general/gr_deinterleave.i deleted file mode 100644 index a70ce6c527..0000000000 --- a/gnuradio-core/src/lib/general/gr_deinterleave.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,deinterleave) - -gr_deinterleave_sptr gr_make_deinterleave (size_t itemsize); - -class gr_deinterleave : public gr_sync_decimator -{ - gr_deinterleave (size_t itemsize); -}; diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.cc b/gnuradio-core/src/lib/general/gr_float_to_char.cc deleted file mode 100644 index d67ded3ea6..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_char.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_float_to_char.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_float_to_char_sptr -gr_make_float_to_char (size_t vlen, float scale) -{ - return gnuradio::get_initial_sptr(new gr_float_to_char (vlen, scale)); -} - -gr_float_to_char::gr_float_to_char (size_t vlen, float scale) - : gr_sync_block ("gr_float_to_char", - gr_make_io_signature (1, 1, sizeof (float)*vlen), - gr_make_io_signature (1, 1, sizeof (char)*vlen)), - d_vlen(vlen), d_scale(scale) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(char); - set_alignment(std::max(1,alignment_multiple)); -} - -float -gr_float_to_char::scale() const -{ - return d_scale; -} - -void -gr_float_to_char::set_scale(float scale) -{ - d_scale = scale; -} - -int -gr_float_to_char::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - int8_t *out = (int8_t *) output_items[0]; - - if(is_unaligned()) { - volk_32f_s32f_convert_8i_u(out, in, d_scale, d_vlen*noutput_items); - } - else { - volk_32f_s32f_convert_8i_a(out, in, d_scale, d_vlen*noutput_items); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.h b/gnuradio-core/src/lib/general/gr_float_to_char.h deleted file mode 100644 index 2df50f18d5..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_char.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 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_FLOAT_TO_CHAR_H -#define INCLUDED_GR_FLOAT_TO_CHAR_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_float_to_char; -typedef boost::shared_ptr<gr_float_to_char> gr_float_to_char_sptr; - -GR_CORE_API gr_float_to_char_sptr -gr_make_float_to_char (size_t vlen=1, float scale=1); - -/*! - * \brief Convert stream of float to a stream of char - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar multiplier to change the output signal scale. - */ - -class GR_CORE_API gr_float_to_char : public gr_sync_block -{ - private: - friend GR_CORE_API gr_float_to_char_sptr gr_make_float_to_char - (size_t vlen, float scale); - gr_float_to_char (size_t vlen, float scale); - - size_t d_vlen; - float d_scale; - - public: - /*! - * Get the scalar multiplier value. - */ - float scale() const; - - /*! - * Set the scalar multiplier value. - */ - void set_scale(float scale); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_FLOAT_TO_CHAR_H */ diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.i b/gnuradio-core/src/lib/general/gr_float_to_char.i deleted file mode 100644 index b40389ede5..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_char.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,float_to_char) - -gr_float_to_char_sptr -gr_make_float_to_char (size_t vlen=1, float scale=1); - -class gr_float_to_char : public gr_sync_block -{ -public: - float scale() const; - void set_scale(float scale); -}; diff --git a/gnuradio-core/src/lib/general/gr_float_to_complex.cc b/gnuradio-core/src/lib/general/gr_float_to_complex.cc deleted file mode 100644 index c68eac8c7c..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_complex.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_float_to_complex.h> -#include <gr_io_signature.h> - -gr_float_to_complex_sptr -gr_make_float_to_complex (size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_float_to_complex (vlen)); -} - -gr_float_to_complex::gr_float_to_complex (size_t vlen) - : gr_sync_block ("gr_float_to_complex", - gr_make_io_signature (1, 2, sizeof (float) * vlen), - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen)), - d_vlen (vlen) -{ -} - -int -gr_float_to_complex::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *r = (float *)input_items[0]; - float *i = (float *)input_items[1]; - gr_complex *out = (gr_complex *) output_items[0]; - - switch (input_items.size ()){ - case 1: - for (size_t j = 0; j < noutput_items*d_vlen; j++) - out[j] = gr_complex (r[j], 0); - break; - - case 2: - for (size_t j = 0; j < noutput_items*d_vlen; j++) - out[j] = gr_complex (r[j], i[j]); - break; - - default: - assert (0); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_float_to_complex.h b/gnuradio-core/src/lib/general/gr_float_to_complex.h deleted file mode 100644 index 628b4a954e..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_complex.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 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_FLOAT_TO_COMPLEX_H -#define INCLUDED_GR_FLOAT_TO_COMPLEX_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_complex.h> - -class gr_float_to_complex; -typedef boost::shared_ptr<gr_float_to_complex> gr_float_to_complex_sptr; - -GR_CORE_API gr_float_to_complex_sptr -gr_make_float_to_complex (size_t vlen = 1); - -/*! - * \brief Convert 1 or 2 streams of float to a stream of gr_complex - * \ingroup converter_blk - */ - -class GR_CORE_API gr_float_to_complex : public gr_sync_block -{ - friend GR_CORE_API gr_float_to_complex_sptr gr_make_float_to_complex (size_t vlen); - gr_float_to_complex (size_t vlen); - - size_t d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_FLOAT_TO_COMPLEX_H */ diff --git a/gnuradio-core/src/lib/general/gr_float_to_complex.i b/gnuradio-core/src/lib/general/gr_float_to_complex.i deleted file mode 100644 index ed5ad128b0..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_complex.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,float_to_complex) - -gr_float_to_complex_sptr gr_make_float_to_complex (size_t vlen = 1); - -class gr_float_to_complex : public gr_sync_block -{ - gr_float_to_complex (size_t vlen); -}; diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.cc b/gnuradio-core/src/lib/general/gr_float_to_int.cc deleted file mode 100644 index 43b8518956..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_int.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_float_to_int.h> -#include <gr_io_signature.h> -#include <gri_float_to_int.h> -#include <volk/volk.h> - -gr_float_to_int_sptr -gr_make_float_to_int (size_t vlen, float scale) -{ - return gnuradio::get_initial_sptr(new gr_float_to_int (vlen, scale)); -} - -gr_float_to_int::gr_float_to_int (size_t vlen, float scale) - : gr_sync_block ("gr_float_to_int", - gr_make_io_signature (1, 1, sizeof (float)*vlen), - gr_make_io_signature (1, 1, sizeof (int)*vlen)), - d_vlen(vlen), d_scale(scale) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(int); - set_alignment(std::max(1,alignment_multiple)); -} - -float -gr_float_to_int::scale() const -{ - return d_scale; -} - -void -gr_float_to_int::set_scale(float scale) -{ - d_scale = scale; -} -int -gr_float_to_int::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - // Disable the Volk for now. There is a problem for large 32-bit ints that - // are not properly represented by the precisions of a single float, which - // can cause wrapping from large, positive numbers to negative. - // In gri_float_to_int, the value is first promoted to a 64-bit - // value, clipped, then converted to a float. -#if 0 - const float *in = (const float *) input_items[0]; - int32_t *out = (int32_t *) output_items[0]; - - if(is_unaligned()) { - volk_32f_s32f_convert_32i_u(out, in, d_scale, d_vlen*noutput_items); - } - else { - volk_32f_s32f_convert_32i_a(out, in, d_scale, d_vlen*noutput_items); - } -#else - const float *in = (const float *) input_items[0]; - int *out = (int *) output_items[0]; - - gri_float_to_int (in, out, d_scale, d_vlen*noutput_items); - -#endif - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.h b/gnuradio-core/src/lib/general/gr_float_to_int.h deleted file mode 100644 index c10ea739d2..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_int.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 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_FLOAT_TO_INT_H -#define INCLUDED_GR_FLOAT_TO_INT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_float_to_int; -typedef boost::shared_ptr<gr_float_to_int> gr_float_to_int_sptr; - -GR_CORE_API gr_float_to_int_sptr -gr_make_float_to_int (size_t vlen=1, float scale=1); - -/*! - * \brief Convert stream of float to a stream of short - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar multiplier to change the output signal scale. - */ - -class GR_CORE_API gr_float_to_int : public gr_sync_block -{ - private: - friend GR_CORE_API - gr_float_to_int_sptr gr_make_float_to_int (size_t vlen, float scale); - gr_float_to_int (size_t vlen, float scale); - - size_t d_vlen; - float d_scale; - - public: - /*! - * Get the scalar multiplier value. - */ - float scale() const; - - /*! - * Set the scalar multiplier value. - */ - void set_scale(float scale); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_FLOAT_TO_INT_H */ diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.i b/gnuradio-core/src/lib/general/gr_float_to_int.i deleted file mode 100644 index e2a2c53ceb..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_int.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,float_to_int) - -gr_float_to_int_sptr -gr_make_float_to_int (size_t vlen=1, float scale=1); - -class gr_float_to_int : public gr_sync_block -{ -public: - float scale() const; - void set_scale(float scale); -}; diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.cc b/gnuradio-core/src/lib/general/gr_float_to_short.cc deleted file mode 100644 index ab720168bf..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_short.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_float_to_short.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_float_to_short_sptr -gr_make_float_to_short (size_t vlen, float scale) -{ - return gnuradio::get_initial_sptr(new gr_float_to_short (vlen, scale)); -} - -gr_float_to_short::gr_float_to_short (size_t vlen, float scale) - : gr_sync_block ("gr_float_to_short", - gr_make_io_signature (1, 1, sizeof (float)*vlen), - gr_make_io_signature (1, 1, sizeof (short)*vlen)), - d_vlen(vlen), d_scale(scale) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(short); - set_alignment(std::max(1,alignment_multiple)); -} - -float -gr_float_to_short::scale() const -{ - return d_scale; -} - -void -gr_float_to_short::set_scale(float scale) -{ - d_scale = scale; -} - -int -gr_float_to_short::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - short *out = (short *) output_items[0]; - - if(is_unaligned()) { - volk_32f_s32f_convert_16i_u(out, in, d_scale, d_vlen*noutput_items); - } - else { - volk_32f_s32f_convert_16i_a(out, in, d_scale, d_vlen*noutput_items); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.h b/gnuradio-core/src/lib/general/gr_float_to_short.h deleted file mode 100644 index 9e43804f54..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_short.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 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_FLOAT_TO_SHORT_H -#define INCLUDED_GR_FLOAT_TO_SHORT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_float_to_short; -typedef boost::shared_ptr<gr_float_to_short> gr_float_to_short_sptr; - -GR_CORE_API gr_float_to_short_sptr -gr_make_float_to_short (size_t vlen=1, float scale=1); - -/*! - * \brief Convert stream of float to a stream of short - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar multiplier to change the output signal scale. - */ - -class GR_CORE_API gr_float_to_short : public gr_sync_block -{ - friend GR_CORE_API - gr_float_to_short_sptr gr_make_float_to_short (size_t vlen, float scale); - gr_float_to_short (size_t vlen, float scale); - - size_t d_vlen; - float d_scale; - - public: - /*! - * Get the scalar multiplier value. - */ - float scale() const; - - /*! - * Set the scalar multiplier value. - */ - void set_scale(float scale); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_FLOAT_TO_SHORT_H */ diff --git a/gnuradio-core/src/lib/general/gr_float_to_uchar.cc b/gnuradio-core/src/lib/general/gr_float_to_uchar.cc deleted file mode 100644 index 5aec73b71f..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_uchar.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_float_to_uchar.h> -#include <gr_io_signature.h> -#include <gri_float_to_uchar.h> - -gr_float_to_uchar_sptr -gr_make_float_to_uchar () -{ - return gnuradio::get_initial_sptr(new gr_float_to_uchar ()); -} - -gr_float_to_uchar::gr_float_to_uchar () - : gr_sync_block ("gr_float_to_uchar", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (unsigned char))) -{ -} - -int -gr_float_to_uchar::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - gri_float_to_uchar (in, out, noutput_items); - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_float_to_uchar.h b/gnuradio-core/src/lib/general/gr_float_to_uchar.h deleted file mode 100644 index 7fd947048a..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_uchar.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_FLOAT_TO_UCHAR_H -#define INCLUDED_GR_FLOAT_TO_UCHAR_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_float_to_uchar; -typedef boost::shared_ptr<gr_float_to_uchar> gr_float_to_uchar_sptr; - -GR_CORE_API gr_float_to_uchar_sptr -gr_make_float_to_uchar (); - -/*! - * \brief Convert stream of float to a stream of unsigned char - * \ingroup converter_blk - */ - -class GR_CORE_API gr_float_to_uchar : public gr_sync_block -{ - friend GR_CORE_API gr_float_to_uchar_sptr gr_make_float_to_uchar (); - gr_float_to_uchar (); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_FLOAT_TO_UCHAR_H */ diff --git a/gnuradio-core/src/lib/general/gr_float_to_uchar.i b/gnuradio-core/src/lib/general/gr_float_to_uchar.i deleted file mode 100644 index b35979213c..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_uchar.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,float_to_uchar) - -gr_float_to_uchar_sptr gr_make_float_to_uchar (); - -class gr_float_to_uchar : public gr_sync_block -{ - gr_float_to_uchar (); -}; diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.cc b/gnuradio-core/src/lib/general/gr_int_to_float.cc deleted file mode 100644 index a7fb24dc69..0000000000 --- a/gnuradio-core/src/lib/general/gr_int_to_float.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_int_to_float.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_int_to_float_sptr -gr_make_int_to_float (size_t vlen, float scale) -{ - return gnuradio::get_initial_sptr(new gr_int_to_float (vlen, scale)); -} - -gr_int_to_float::gr_int_to_float (size_t vlen, float scale) - : gr_sync_block ("gr_int_to_float", - gr_make_io_signature (1, 1, sizeof (int32_t)*vlen), - gr_make_io_signature (1, 1, sizeof (float)*vlen)), - d_vlen(vlen), d_scale(scale) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_int_to_float::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const int32_t *in = (const int32_t *) input_items[0]; - float *out = (float *) output_items[0]; - - if(is_unaligned()) { - volk_32i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items); - } - else { - volk_32i_s32f_convert_32f_a(out, in, d_scale, d_vlen*noutput_items); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.h b/gnuradio-core/src/lib/general/gr_int_to_float.h deleted file mode 100644 index 6200c5be75..0000000000 --- a/gnuradio-core/src/lib/general/gr_int_to_float.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 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_INT_TO_FLOAT_H -#define INCLUDED_GR_INT_TO_FLOAT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_int_to_float; -typedef boost::shared_ptr<gr_int_to_float> gr_int_to_float_sptr; - -GR_CORE_API gr_int_to_float_sptr -gr_make_int_to_float (size_t vlen=1, float scale=1); - -/*! - * \brief Convert stream of int to a stream of float - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar divider to change the output signal scale. - */ - -class GR_CORE_API gr_int_to_float : public gr_sync_block -{ - private: - friend GR_CORE_API gr_int_to_float_sptr - gr_make_int_to_float (size_t vlen, float scale); - gr_int_to_float (size_t vlen, float scale); - - size_t d_vlen; - float d_scale; - - public: - /*! - * Get the scalar divider value. - */ - float scale() const; - - /*! - * Set the scalar divider value. - */ - void set_scale(float scale); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_INT_TO_FLOAT_H */ diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.i b/gnuradio-core/src/lib/general/gr_int_to_float.i deleted file mode 100644 index f3781ac8ab..0000000000 --- a/gnuradio-core/src/lib/general/gr_int_to_float.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,int_to_float) - -gr_int_to_float_sptr -gr_make_int_to_float (size_t vlen=1, float scale=1); - -class gr_int_to_float : public gr_sync_block -{ - float scale() const; - void set_scale(float scale); -}; diff --git a/gnuradio-core/src/lib/general/gr_interleave.cc b/gnuradio-core/src/lib/general/gr_interleave.cc deleted file mode 100644 index 5d572871eb..0000000000 --- a/gnuradio-core/src/lib/general/gr_interleave.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_interleave.h> -#include <gr_io_signature.h> -#include <string.h> - - -gr_interleave_sptr -gr_make_interleave (size_t itemsize) -{ - return gnuradio::get_initial_sptr(new gr_interleave (itemsize)); -} - -gr_interleave::gr_interleave (size_t itemsize) - : gr_sync_interpolator ("interleave", - gr_make_io_signature (1, gr_io_signature::IO_INFINITE, itemsize), - gr_make_io_signature (1, 1, itemsize), - 1), - d_itemsize (itemsize) -{ -} - -gr_interleave::~gr_interleave () -{ - // NOP -} - -bool -gr_interleave::check_topology (int ninputs, int noutputs) -{ - set_interpolation (ninputs); - return true; -} - -int -gr_interleave::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t nchan = input_items.size (); - size_t itemsize = d_itemsize; - const char **in = (const char **) &input_items[0]; - char *out = (char *) output_items[0]; - - for (int i = 0; i < noutput_items; i += nchan){ - for (unsigned int n = 0; n < nchan; n++){ - memcpy (out, in[n], itemsize); - out += itemsize; - in[n] += itemsize; - } - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_interleave.h b/gnuradio-core/src/lib/general/gr_interleave.h deleted file mode 100644 index 3b0202d008..0000000000 --- a/gnuradio-core/src/lib/general/gr_interleave.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- 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_GR_INTERLEAVE_H -#define INCLUDED_GR_INTERLEAVE_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_interleave; -typedef boost::shared_ptr<gr_interleave> gr_interleave_sptr; - -GR_CORE_API gr_interleave_sptr gr_make_interleave (size_t itemsize); - -/*! - * \brief interleave N inputs to a single output - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_interleave : public gr_sync_interpolator -{ - friend GR_CORE_API gr_interleave_sptr gr_make_interleave (size_t itemsize); - - size_t d_itemsize; - - gr_interleave (size_t itemsize); - -public: - ~gr_interleave (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool check_topology (int ninputs, int noutputs); - -}; - -#endif /* INCLUDED_GR_INTERLEAVE_H */ diff --git a/gnuradio-core/src/lib/general/gr_interleave.i b/gnuradio-core/src/lib/general/gr_interleave.i deleted file mode 100644 index 09a57c886c..0000000000 --- a/gnuradio-core/src/lib/general/gr_interleave.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,interleave) - -gr_interleave_sptr gr_make_interleave (size_t itemsize); - -class gr_interleave : public gr_sync_interpolator -{ - gr_interleave (size_t itemsize); -}; diff --git a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.cc b/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.cc deleted file mode 100644 index e7d375a355..0000000000 --- a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_interleaved_short_to_complex.h> -#include <gr_io_signature.h> -#include <gri_interleaved_short_to_complex.h> - -gr_interleaved_short_to_complex_sptr -gr_make_interleaved_short_to_complex () -{ - return gnuradio::get_initial_sptr(new gr_interleaved_short_to_complex ()); -} - -gr_interleaved_short_to_complex::gr_interleaved_short_to_complex () - : gr_sync_decimator ("gr_interleaved_short_to_complex", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (1, 1, sizeof (gr_complex)), - 2) -{ -} - -int -gr_interleaved_short_to_complex::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const short *in = (const short *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - gri_interleaved_short_to_complex (in, out, 2 * noutput_items); - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h b/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h deleted file mode 100644 index 159d107b33..0000000000 --- a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- 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_GR_INTERLEAVED_SHORT_TO_COMPLEX_H -#define INCLUDED_GR_INTERLEAVED_SHORT_TO_COMPLEX_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_interleaved_short_to_complex; -typedef boost::shared_ptr<gr_interleaved_short_to_complex> - gr_interleaved_short_to_complex_sptr; - -GR_CORE_API gr_interleaved_short_to_complex_sptr -gr_make_interleaved_short_to_complex (); - -/*! - * \brief Convert stream of interleaved shorts to a stream of complex - * \ingroup converter_blk - */ - -class GR_CORE_API gr_interleaved_short_to_complex : public gr_sync_decimator -{ - friend GR_CORE_API gr_interleaved_short_to_complex_sptr gr_make_interleaved_short_to_complex (); - gr_interleaved_short_to_complex (); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_INTERLEAVED_SHORT_TO_COMPLEX_H */ diff --git a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.i b/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.i deleted file mode 100644 index 7977105506..0000000000 --- a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,interleaved_short_to_complex) - -gr_interleaved_short_to_complex_sptr gr_make_interleaved_short_to_complex (); - -class gr_interleaved_short_to_complex : public gr_sync_decimator -{ - gr_interleaved_short_to_complex (); -}; diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc b/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc deleted file mode 100644 index 1becbfa116..0000000000 --- a/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_keep_m_in_n.h> -#include <gr_io_signature.h> -#include <string.h> -#include <stdio.h> - -gr_keep_m_in_n_sptr -gr_make_keep_m_in_n(size_t item_size, int m, int n, int offset) -{ - return gnuradio::get_initial_sptr(new gr_keep_m_in_n(item_size, m, n, offset)); -} - - -/* -* -* offset = 0, starts with 0th item -* offset = 1, starts with 1st item, etc... -* -* we take m items out of each n -*/ -gr_keep_m_in_n::gr_keep_m_in_n(size_t item_size, int m, int n, int offset) - : gr_block("keep_m_in_n", - gr_make_io_signature(1, 1, item_size), - gr_make_io_signature(1, 1, item_size)), - d_n(n), - d_m(m), - d_offset(offset), - d_itemsize(item_size) -{ - // sanity checking - assert(d_m > 0); - assert(d_n > 0); - assert(d_m <= d_n); - assert(d_offset <= (d_n-d_m)); - - set_output_multiple(m); -} - - -void -gr_keep_m_in_n::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - ninput_items_required[0] = d_n*(noutput_items/d_m); -} - -void -gr_keep_m_in_n::set_offset(int offset) -{ - d_offset = offset; -} - -int -gr_keep_m_in_n::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - uint8_t* out = (uint8_t*)output_items[0]; - const uint8_t* in = (const uint8_t*)input_items[0]; - - // iterate over data blocks of size {n, input : m, output} - int blks = std::min(noutput_items/d_m, ninput_items[0]/d_n); - for(int i=0; i<blks; i++) { - // set up copy pointers - const uint8_t* iptr = &in[(i*d_n + d_offset)*d_itemsize]; - uint8_t* optr = &out[i*d_m*d_itemsize]; - // perform copy - memcpy( optr, iptr, d_m*d_itemsize ); - } - - consume_each(d_n); - return d_m; -} diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.h b/gnuradio-core/src/lib/general/gr_keep_m_in_n.h deleted file mode 100644 index c6bf40ecf2..0000000000 --- a/gnuradio-core/src/lib/general/gr_keep_m_in_n.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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_KEEP_M_IN_N_H -#define INCLUDED_GR_KEEP_M_IN_N_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_keep_m_in_n; -typedef boost::shared_ptr<gr_keep_m_in_n> gr_keep_m_in_n_sptr; - -GR_CORE_API gr_keep_m_in_n_sptr -gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset); - - -/*! - * \brief decimate a stream, keeping one item out of every n. - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_keep_m_in_n : public gr_block -{ - friend GR_CORE_API gr_keep_m_in_n_sptr - gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset); - - int d_n; - int d_m; - int d_count; - int d_offset; - int d_itemsize; - - protected: - gr_keep_m_in_n (size_t item_size, int m, int n, int offset); - void forecast (int noutput_items, gr_vector_int &ninput_items_required); - - public: - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void set_offset(int offset); - void set_n(int n){ d_n = n; } - void set_m(int m){ d_m = m; } - -}; - -#endif /* INCLUDED_GR_KEEP_M_IN_N_H */ diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.i b/gnuradio-core/src/lib/general/gr_keep_m_in_n.i deleted file mode 100644 index f280c0248a..0000000000 --- a/gnuradio-core/src/lib/general/gr_keep_m_in_n.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,keep_m_in_n) - -gr_keep_m_in_n_sptr -gr_make_keep_m_in_n (size_t itemsize, int m, int n, int offset); - -class gr_keep_m_in_n : public gr_sync_block -{ - protected: - gr_keep_m_in_n (size_t itemsize, int m, int n, int offset); - public: - void set_offset(int offset); - -}; diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc deleted file mode 100644 index fbba9e91c0..0000000000 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_keep_one_in_n.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_keep_one_in_n_sptr -gr_make_keep_one_in_n (size_t item_size, int n) -{ - return gnuradio::get_initial_sptr(new gr_keep_one_in_n (item_size, n)); -} - -gr_keep_one_in_n::gr_keep_one_in_n (size_t item_size, int n) - : gr_block ("keep_one_in_n", - gr_make_io_signature (1, 1, item_size), - gr_make_io_signature (1, 1, item_size)), - d_count(n) -{ - // To avoid bad behavior with using set_relative_rate in this block with - // VERY large values of n, we will keep track of things ourselves. Using - // this to turn off automatic tag propagation, which will be handled - // locally in general_work(). - set_tag_propagation_policy(TPP_DONT); - - set_n(n); -} - -void -gr_keep_one_in_n::set_n(int n) -{ - if (n < 1) - n = 1; - - d_n = n; - d_count = n; - - // keep our internal understanding of the relative rate of this block - // don't set the relative rate, though, and we will handle our own - // tag propagation. - d_decim_rate = 1.0/(float)d_n; -} - -int -gr_keep_one_in_n::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *in = (const char *) input_items[0]; - char *out = (char *) output_items[0]; - - size_t item_size = input_signature ()->sizeof_stream_item (0); - int ni = 0; - int no = 0; - - while (ni < ninput_items[0] && no < noutput_items){ - d_count--; - if (d_count <= 0){ - memcpy (out, in, item_size); // copy 1 item - out += item_size; - no++; - d_count = d_n; - } - in += item_size; - ni++; - } - - // Because we have set TPP_DONT, we have to propagate the tags here manually. - // Adjustment of the tag sample value is done using the float d_decim_rate. - std::vector<gr_tag_t> tags; - std::vector<gr_tag_t>::iterator t; - get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+ni); - for(t = tags.begin(); t != tags.end(); t++) { - gr_tag_t new_tag = *t; - new_tag.offset *= d_decim_rate; - add_item_tag(0, new_tag); - } - - consume_each (ni); - return no; -} diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.h b/gnuradio-core/src/lib/general/gr_keep_one_in_n.h deleted file mode 100644 index f37475204b..0000000000 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- 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_GR_KEEP_ONE_IN_N_H -#define INCLUDED_GR_KEEP_ONE_IN_N_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_keep_one_in_n; -typedef boost::shared_ptr<gr_keep_one_in_n> gr_keep_one_in_n_sptr; - -GR_CORE_API gr_keep_one_in_n_sptr -gr_make_keep_one_in_n (size_t item_size, int n); - - -/*! - * \brief decimate a stream, keeping one item out of every n. - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_keep_one_in_n : public gr_block -{ - friend GR_CORE_API gr_keep_one_in_n_sptr - gr_make_keep_one_in_n (size_t item_size, int n); - - int d_n; - int d_count; - float d_decim_rate; - - protected: - gr_keep_one_in_n (size_t item_size, int n); - - public: - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void set_n(int n); - -}; - -#endif /* INCLUDED_GR_KEEP_ONE_IN_N_H */ diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.i b/gnuradio-core/src/lib/general/gr_keep_one_in_n.i deleted file mode 100644 index 534098cded..0000000000 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,keep_one_in_n) - -gr_keep_one_in_n_sptr -gr_make_keep_one_in_n (size_t itemsize, int n); - -class gr_keep_one_in_n : public gr_block -{ - protected: - gr_keep_one_in_n (size_t itemsize, int n); - - public: - void set_n(int n); -}; diff --git a/gnuradio-core/src/lib/general/gr_multiply_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_cc.cc deleted file mode 100644 index 4a3751419f..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_cc.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_multiply_cc.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_multiply_cc_sptr -gr_make_multiply_cc (size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_multiply_cc (vlen)); -} - -gr_multiply_cc::gr_multiply_cc (size_t vlen) - : gr_sync_block ("gr_multiply_cc", - gr_make_io_signature (1, -1, sizeof (gr_complex)*vlen), - gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(gr_complex); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_multiply_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *out = (gr_complex *) output_items[0]; - int noi = d_vlen*noutput_items; - - memcpy(out, input_items[0], noi*sizeof(gr_complex)); - if(is_unaligned()) { - for(size_t i = 1; i < input_items.size(); i++) - volk_32fc_x2_multiply_32fc_u(out, out, (gr_complex*)input_items[i], noi); - } - else { - for(size_t i = 1; i < input_items.size(); i++) - volk_32fc_x2_multiply_32fc_a(out, out, (gr_complex*)input_items[i], noi); - } - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_multiply_cc.h b/gnuradio-core/src/lib/general/gr_multiply_cc.h deleted file mode 100644 index d25935b4ca..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_cc.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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_MULTIPLY_CC_H -#define INCLUDED_GR_MULTIPLY_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_multiply_cc; -typedef boost::shared_ptr<gr_multiply_cc> gr_multiply_cc_sptr; - -GR_CORE_API gr_multiply_cc_sptr -gr_make_multiply_cc (size_t vlen=1); - -/*! - * \brief Multiply streams of complex values - * \ingroup math_blk - */ - -class GR_CORE_API gr_multiply_cc : public gr_sync_block -{ - private: - friend GR_CORE_API gr_multiply_cc_sptr - gr_make_multiply_cc (size_t vlen); - gr_multiply_cc (size_t vlen); - - size_t d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_MULTIPLY_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_multiply_cc.i b/gnuradio-core/src/lib/general/gr_multiply_cc.i deleted file mode 100644 index f0faa3594c..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_cc.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,multiply_cc) - -gr_multiply_cc_sptr -gr_make_multiply_cc (size_t vlen=1); - -class gr_multiply_cc : public gr_sync_block -{ -public: - -}; diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc deleted file mode 100644 index 0c5fb4a926..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_multiply_conjugate_cc.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_multiply_conjugate_cc_sptr -gr_make_multiply_conjugate_cc (size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_multiply_conjugate_cc (vlen)); -} - -gr_multiply_conjugate_cc::gr_multiply_conjugate_cc (size_t vlen) - : gr_sync_block ("gr_multiply_conjugate_cc", - gr_make_io_signature (2, 2, sizeof (gr_complex)*vlen), - gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(gr_complex); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_multiply_conjugate_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in0 = (gr_complex *) input_items[0]; - gr_complex *in1 = (gr_complex *) input_items[1]; - gr_complex *out = (gr_complex *) output_items[0]; - int noi = d_vlen*noutput_items; - - if(is_unaligned()) { - volk_32fc_x2_multiply_conjugate_32fc_u(out, in0, in1, noi); - } - else { - volk_32fc_x2_multiply_conjugate_32fc_a(out, in0, in1, noi); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h deleted file mode 100644 index 826e287714..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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_MULTIPLY_CONJUGATE_CC_H -#define INCLUDED_GR_MULTIPLY_CONJUGATE_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_multiply_conjugate_cc; -typedef boost::shared_ptr<gr_multiply_conjugate_cc> -gr_multiply_conjugate_cc_sptr; - -GR_CORE_API gr_multiply_conjugate_cc_sptr -gr_make_multiply_conjugate_cc (size_t vlen=1); - -/*! - * \brief Multiplies a stream by the conjugate of the second stream - * \ingroup math_blk - */ - -class GR_CORE_API gr_multiply_conjugate_cc : public gr_sync_block -{ - private: - friend GR_CORE_API gr_multiply_conjugate_cc_sptr - gr_make_multiply_conjugate_cc (size_t vlen); - gr_multiply_conjugate_cc (size_t vlen); - - size_t d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_MULTIPLY_CONJUGATE_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i deleted file mode 100644 index e7979dbcdf..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,multiply_conjugate_cc) - -gr_multiply_conjugate_cc_sptr -gr_make_multiply_conjugate_cc (size_t vlen=1); - -class gr_multiply_conjugate_cc : public gr_sync_block -{ -public: - -}; diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc deleted file mode 100644 index bd4511937f..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_multiply_const_cc.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_multiply_const_cc_sptr -gr_make_multiply_const_cc (gr_complex k, size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_multiply_const_cc (k, vlen)); -} - -gr_multiply_const_cc::gr_multiply_const_cc (gr_complex k, size_t vlen) - : gr_sync_block ("gr_multiply_const_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen), - gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)), - d_k(k), d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(gr_complex); - set_alignment(std::max(1,alignment_multiple)); -} - -gr_complex -gr_multiply_const_cc::k() const -{ - return d_k; -} - -void -gr_multiply_const_cc::set_k(gr_complex k) -{ - d_k = k; -} - -int -gr_multiply_const_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - int noi = d_vlen*noutput_items; - - if(is_unaligned()) { - volk_32fc_s32fc_multiply_32fc_u(out, in, d_k, noi); - } - else { - volk_32fc_s32fc_multiply_32fc_a(out, in, d_k, noi); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.h b/gnuradio-core/src/lib/general/gr_multiply_const_cc.h deleted file mode 100644 index 97962abc70..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_const_cc.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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_MULTIPLY_CONST_CC_H -#define INCLUDED_GR_MULTIPLY_CONST_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_multiply_const_cc; -typedef boost::shared_ptr<gr_multiply_const_cc> gr_multiply_const_cc_sptr; - -GR_CORE_API gr_multiply_const_cc_sptr -gr_make_multiply_const_cc (gr_complex k, size_t vlen=1); - -/*! - * \brief Multiply stream of complex values with a constant \p k - * \ingroup math_blk - */ - -class GR_CORE_API gr_multiply_const_cc : public gr_sync_block -{ - private: - friend GR_CORE_API gr_multiply_const_cc_sptr - gr_make_multiply_const_cc (gr_complex k, size_t vlen); - gr_multiply_const_cc (gr_complex k, size_t vlen); - - gr_complex d_k; - size_t d_vlen; - - public: - gr_complex k() const; - void set_k(gr_complex k); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_MULTIPLY_CONST_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.i b/gnuradio-core/src/lib/general/gr_multiply_const_cc.i deleted file mode 100644 index c2f3cbed31..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_const_cc.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,multiply_const_cc) - -gr_multiply_const_cc_sptr -gr_make_multiply_const_cc (gr_complex k, size_t vlen=1); - -class gr_multiply_const_cc : public gr_sync_block -{ -public: - gr_complex k() const; - void set_k(gr_complex k); -}; diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc b/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc deleted file mode 100644 index 16ba39df93..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_multiply_const_ff.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_multiply_const_ff_sptr -gr_make_multiply_const_ff (float k, size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_multiply_const_ff (k, vlen)); -} - -gr_multiply_const_ff::gr_multiply_const_ff (float k, size_t vlen) - : gr_sync_block ("gr_multiply_const_ff", - gr_make_io_signature (1, 1, sizeof (float)*vlen), - gr_make_io_signature (1, 1, sizeof (float)*vlen)), - d_k(k), d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -float -gr_multiply_const_ff::k() const -{ - return d_k; -} - -void -gr_multiply_const_ff::set_k(float k) -{ - d_k = k; -} - -int -gr_multiply_const_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = d_vlen*noutput_items; - - if(is_unaligned()) { - volk_32f_s32f_multiply_32f_u(out, in, d_k, noi); - } - else { - volk_32f_s32f_multiply_32f_a(out, in, d_k, noi); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.h b/gnuradio-core/src/lib/general/gr_multiply_const_ff.h deleted file mode 100644 index fac73f88a2..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_const_ff.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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_MULTIPLY_CONST_FF_H -#define INCLUDED_GR_MULTIPLY_CONST_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_multiply_const_ff; -typedef boost::shared_ptr<gr_multiply_const_ff> gr_multiply_const_ff_sptr; - -GR_CORE_API gr_multiply_const_ff_sptr -gr_make_multiply_const_ff (float k, size_t vlen=1); - -/*! - * \brief Multiply stream of float values with a constant \p k - * \ingroup math_blk - */ - -class GR_CORE_API gr_multiply_const_ff : public gr_sync_block -{ - private: - friend GR_CORE_API gr_multiply_const_ff_sptr - gr_make_multiply_const_ff (float k, size_t vlen); - gr_multiply_const_ff (float k, size_t vlen); - - float d_k; - size_t d_vlen; - - public: - float k() const; - void set_k(float k); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_MULTIPLY_CONST_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.i b/gnuradio-core/src/lib/general/gr_multiply_const_ff.i deleted file mode 100644 index 343f67cd25..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_const_ff.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,multiply_const_ff) - -gr_multiply_const_ff_sptr -gr_make_multiply_const_ff (float k, size_t vlen=1); - -class gr_multiply_const_ff : public gr_sync_block -{ -public: - float k() const; - void set_k(float k); -}; diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.cc b/gnuradio-core/src/lib/general/gr_multiply_ff.cc deleted file mode 100644 index bb7bd07550..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_ff.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_multiply_ff.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_multiply_ff_sptr -gr_make_multiply_ff (size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_multiply_ff (vlen)); -} - -gr_multiply_ff::gr_multiply_ff (size_t vlen) - : gr_sync_block ("gr_multiply_ff", - gr_make_io_signature (1, -1, sizeof (float)*vlen), - gr_make_io_signature (1, 1, sizeof (float)*vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_multiply_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *out = (float *) output_items[0]; - int noi = d_vlen*noutput_items; - - memcpy(out, input_items[0], noi*sizeof(float)); - if(is_unaligned()) { - for(size_t i = 1; i < input_items.size(); i++) - volk_32f_x2_multiply_32f_u(out, out, (const float*)input_items[i], noi); - } - else { - for(size_t i = 1; i < input_items.size(); i++) - volk_32f_x2_multiply_32f_a(out, out, (const float*)input_items[i], noi); - } - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.h b/gnuradio-core/src/lib/general/gr_multiply_ff.h deleted file mode 100644 index ed628385ce..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_ff.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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_MULTIPLY_FF_H -#define INCLUDED_GR_MULTIPLY_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_multiply_ff; -typedef boost::shared_ptr<gr_multiply_ff> gr_multiply_ff_sptr; - -GR_CORE_API gr_multiply_ff_sptr -gr_make_multiply_ff (size_t vlen=1); - -/*! - * \brief Multiply streams of complex values - * \ingroup math_blk - */ - -class GR_CORE_API gr_multiply_ff : public gr_sync_block -{ - private: - friend GR_CORE_API gr_multiply_ff_sptr - gr_make_multiply_ff (size_t vlen); - gr_multiply_ff (size_t vlen); - - size_t d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_MULTIPLY_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_nlog10_ff.cc b/gnuradio-core/src/lib/general/gr_nlog10_ff.cc deleted file mode 100644 index 24cfe25fb5..0000000000 --- a/gnuradio-core/src/lib/general/gr_nlog10_ff.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_nlog10_ff.h> -#include <gr_io_signature.h> -#include <algorithm> - -gr_nlog10_ff_sptr -gr_make_nlog10_ff (float n, unsigned vlen, float k) -{ - return gnuradio::get_initial_sptr(new gr_nlog10_ff(n, vlen, k)); -} - -gr_nlog10_ff::gr_nlog10_ff(float n, unsigned vlen, float k) - : gr_sync_block("nlog10_ff", - gr_make_io_signature(1, 1, sizeof(float) * vlen), - gr_make_io_signature(1, 1, sizeof(float) * vlen)), - d_vlen(vlen), d_n(n), d_k(k) -{ -} - -gr_nlog10_ff::~gr_nlog10_ff() -{ -} - -int -gr_nlog10_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = noutput_items * d_vlen; - float n = d_n; - float k = d_k; - - for (int i = 0; i < noi; i++) - out[i] = n * log10(std::max(in[i], (float) 1e-18)) + k; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_nlog10_ff.h b/gnuradio-core/src/lib/general/gr_nlog10_ff.h deleted file mode 100644 index cfeba3feeb..0000000000 --- a/gnuradio-core/src/lib/general/gr_nlog10_ff.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_NLOG10_FF_H -#define INCLUDED_GR_NLOG10_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_nlog10_ff; -typedef boost::shared_ptr<gr_nlog10_ff> gr_nlog10_ff_sptr; - -GR_CORE_API gr_nlog10_ff_sptr gr_make_nlog10_ff (float n=1.0, unsigned vlen=1, float k=0); - -/*! - * \brief output = n*log10(input) + k - * \ingroup math_blk - */ -class GR_CORE_API gr_nlog10_ff : public gr_sync_block -{ - friend GR_CORE_API gr_nlog10_ff_sptr gr_make_nlog10_ff (float n, unsigned vlen, float k); - - unsigned int d_vlen; - float d_n; - float d_k; - - gr_nlog10_ff (float n, unsigned vlen, float k); - -public: - ~gr_nlog10_ff(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_NLOG10_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_nlog10_ff.i b/gnuradio-core/src/lib/general/gr_nlog10_ff.i deleted file mode 100644 index 73da597938..0000000000 --- a/gnuradio-core/src/lib/general/gr_nlog10_ff.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,nlog10_ff); - -gr_nlog10_ff_sptr gr_make_nlog10_ff (float n=1.0, unsigned vlen=1, float k=0); - -class gr_nlog10_ff : public gr_sync_block -{ - gr_nlog10_ff (float n, unsigned vlen, float k); - -public: - ~gr_nlog10_ff(); -}; diff --git a/gnuradio-core/src/lib/general/gr_repeat.cc b/gnuradio-core/src/lib/general/gr_repeat.cc deleted file mode 100644 index 2fa82cd94d..0000000000 --- a/gnuradio-core/src/lib/general/gr_repeat.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_repeat.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_repeat_sptr -gr_make_repeat(size_t itemsize, int interp) -{ - return gnuradio::get_initial_sptr(new gr_repeat(itemsize, interp)); -} - -gr_repeat::gr_repeat(size_t itemsize, int interp) - : gr_sync_interpolator("extend", - gr_make_io_signature(1, 1, itemsize), - gr_make_io_signature(1, 1, itemsize), - interp), - d_interp(interp), - d_itemsize(itemsize) -{ -} - -gr_repeat::~gr_repeat() -{ -} - -int -gr_repeat::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *in = (const char *) input_items[0]; - char *out = (char *)output_items[0]; - - for (int i = 0; i < noutput_items/d_interp; i++) { - for (int j = 0; j < d_interp; j++) { - memcpy(out, in, d_itemsize); - out += d_itemsize; - } - - in += d_itemsize; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_repeat.h b/gnuradio-core/src/lib/general/gr_repeat.h deleted file mode 100644 index 548ca79f4d..0000000000 --- a/gnuradio-core/src/lib/general/gr_repeat.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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_REPEAT_H -#define INCLUDED_GR_REPEAT_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_repeat; - -typedef boost::shared_ptr<gr_repeat> gr_repeat_sptr; - -GR_CORE_API gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp); - -/*! - * \brief Repeat a sample 'interp' times in output stream - * \ingroup misc_blk - */ - -class GR_CORE_API gr_repeat : public gr_sync_interpolator -{ -private: - friend GR_CORE_API gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp); - - gr_repeat(size_t itemsize, int interp); - - int d_interp; - int d_itemsize; - - public: - ~gr_repeat(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_REPEAT_H */ diff --git a/gnuradio-core/src/lib/general/gr_repeat.i b/gnuradio-core/src/lib/general/gr_repeat.i deleted file mode 100644 index c657a4906f..0000000000 --- a/gnuradio-core/src/lib/general/gr_repeat.i +++ /dev/null @@ -1,11 +0,0 @@ -/* -*- c++ -*- */ - -GR_SWIG_BLOCK_MAGIC(gr,repeat); - -gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp); - -class gr_repeat : public gr_sync_interpolator -{ -private: - gr_repeat(); -}; diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.cc b/gnuradio-core/src/lib/general/gr_short_to_char.cc deleted file mode 100644 index 8c146a351d..0000000000 --- a/gnuradio-core/src/lib/general/gr_short_to_char.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_short_to_char.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_short_to_char_sptr -gr_make_short_to_char (size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_short_to_char (vlen)); -} - -gr_short_to_char::gr_short_to_char (size_t vlen) - : gr_sync_block ("gr_short_to_char", - gr_make_io_signature (1, 1, sizeof (short)*vlen), - gr_make_io_signature (1, 1, sizeof (char)*vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(char); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_short_to_char::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const int16_t *in = (const int16_t *) input_items[0]; - int8_t *out = (int8_t *) output_items[0]; - - if(is_unaligned()) { - volk_16i_convert_8i_u(out, in, d_vlen*noutput_items); - } - else { - volk_16i_convert_8i_a(out, in, d_vlen*noutput_items); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.h b/gnuradio-core/src/lib/general/gr_short_to_char.h deleted file mode 100644 index bf96211c7c..0000000000 --- a/gnuradio-core/src/lib/general/gr_short_to_char.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 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_SHORT_TO_CHAR_H -#define INCLUDED_GR_SHORT_TO_CHAR_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_short_to_char; -typedef boost::shared_ptr<gr_short_to_char> gr_short_to_char_sptr; - -GR_CORE_API gr_short_to_char_sptr -gr_make_short_to_char (size_t vlen=1); - -/*! - * \brief Convert stream of short to a stream of float - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - */ - -class GR_CORE_API gr_short_to_char : public gr_sync_block -{ - private: - friend GR_CORE_API gr_short_to_char_sptr - gr_make_short_to_char (size_t vlen); - gr_short_to_char (size_t vlen); - - size_t d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_SHORT_TO_CHAR_H */ diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.i b/gnuradio-core/src/lib/general/gr_short_to_char.i deleted file mode 100644 index 7389ed10ba..0000000000 --- a/gnuradio-core/src/lib/general/gr_short_to_char.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,short_to_char) - -gr_short_to_char_sptr -gr_make_short_to_char (size_t vlen=1); - -class gr_short_to_char : public gr_sync_block -{ - -}; diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.cc b/gnuradio-core/src/lib/general/gr_short_to_float.cc deleted file mode 100644 index 093d6024fa..0000000000 --- a/gnuradio-core/src/lib/general/gr_short_to_float.cc +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_short_to_float.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_short_to_float_sptr -gr_make_short_to_float (size_t vlen, float scale) -{ - return gnuradio::get_initial_sptr(new gr_short_to_float (vlen, scale)); -} - -gr_short_to_float::gr_short_to_float (size_t vlen, float scale) - : gr_sync_block ("gr_short_to_float", - gr_make_io_signature (1, 1, sizeof (short)*vlen), - gr_make_io_signature (1, 1, sizeof (float)*vlen)), - d_vlen(vlen), d_scale(scale) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -float -gr_short_to_float::scale() const -{ - return d_scale; -} - -void -gr_short_to_float::set_scale(float scale) -{ - d_scale = scale; -} - -int -gr_short_to_float::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const short *in = (const short *) input_items[0]; - float *out = (float *) output_items[0]; - - if(is_unaligned()) { - volk_16i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items); - } - else { - volk_16i_s32f_convert_32f_a(out, in, d_scale, d_vlen*noutput_items); - } - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.h b/gnuradio-core/src/lib/general/gr_short_to_float.h deleted file mode 100644 index 362549e70a..0000000000 --- a/gnuradio-core/src/lib/general/gr_short_to_float.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 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_SHORT_TO_FLOAT_H -#define INCLUDED_GR_SHORT_TO_FLOAT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_short_to_float; -typedef boost::shared_ptr<gr_short_to_float> gr_short_to_float_sptr; - -GR_CORE_API gr_short_to_float_sptr -gr_make_short_to_float (size_t vlen=1, float scale=1); - -/*! - * \brief Convert stream of short to a stream of float - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar divider to change the output signal scale. - */ - -class GR_CORE_API gr_short_to_float : public gr_sync_block -{ - private: - friend GR_CORE_API gr_short_to_float_sptr - gr_make_short_to_float (size_t vlen, float scale); - gr_short_to_float (size_t vlen, float scale); - - size_t d_vlen; - float d_scale; - - public: - /*! - * Get the scalar divider value. - */ - float scale() const; - - /*! - * Set the scalar divider value. - */ - void set_scale(float scale); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_SHORT_TO_FLOAT_H */ diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.i b/gnuradio-core/src/lib/general/gr_short_to_float.i deleted file mode 100644 index e781e292c9..0000000000 --- a/gnuradio-core/src/lib/general/gr_short_to_float.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,short_to_float) - -gr_short_to_float_sptr -gr_make_short_to_float (size_t vlen=1, float scale=1); - -class gr_short_to_float : public gr_sync_block -{ -public: - float scale() const; - void set_scale(float scale); -}; diff --git a/gnuradio-core/src/lib/general/gr_stream_mux.cc b/gnuradio-core/src/lib/general/gr_stream_mux.cc deleted file mode 100644 index 978d960b20..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_mux.cc +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_stream_mux.h> -#include <gr_io_signature.h> -#include <string.h> -#include <cstdio> - -#define VERBOSE 0 - -gr_stream_mux_sptr -gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths) -{ - return gnuradio::get_initial_sptr(new gr_stream_mux (itemsize, lengths)); -} - -gr_stream_mux::gr_stream_mux (size_t itemsize, const std::vector<int> &lengths) - : gr_block ("stream_mux", - gr_make_io_signature (1, -1, itemsize), - gr_make_io_signature (1, 1, itemsize)), - d_itemsize(itemsize), - d_stream(0), - d_residual(0), - d_lengths(lengths) -{ - if(d_lengths[d_stream] == 0) { - increment_stream(); - } - d_residual = d_lengths[d_stream]; -} - -gr_stream_mux::~gr_stream_mux(void) -{ -} - -void -gr_stream_mux::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size (); - for (unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = (d_lengths[i] == 0 ? 0 : 1); -} - -void gr_stream_mux::increment_stream() -{ - do { - d_stream = (d_stream+1) % d_lengths.size(); - } while(d_lengths[d_stream] == 0); - - d_residual = d_lengths[d_stream]; -} - -int -gr_stream_mux::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - char *out = (char *) output_items[0]; - const char *in; - int out_index = 0; - std::vector<int> input_index(d_lengths.size(), 0); - - if(VERBOSE) { - printf("mux: nouput_items: %d d_stream: %d\n", noutput_items, d_stream); - for(size_t i = 0; i < d_lengths.size(); i++) - printf("\tninput_items[%zu]: %d\n", i, ninput_items[i]); - } - - while (1) { - int r = std::min(noutput_items - out_index, - std::min(d_residual, - ninput_items[d_stream] - input_index[d_stream])); - if(VERBOSE) { - printf("mux: r=%d\n", r); - printf("\tnoutput_items - out_index: %d\n", - noutput_items - out_index); - printf("\td_residual: %d\n", - d_residual); - printf("\tninput_items[d_stream] - input_index[d_stream]: %d\n", - ninput_items[d_stream] - input_index[d_stream]); - } - - if(r <= 0) { - return out_index; - } - - in = (const char *) input_items[d_stream] + input_index[d_stream]*d_itemsize; - - memcpy(&out[out_index*d_itemsize], in, r*d_itemsize); - out_index += r; - input_index[d_stream] += r; - d_residual -= r; - - consume(d_stream, r); - - if(d_residual == 0) { - increment_stream(); - } - } -} diff --git a/gnuradio-core/src/lib/general/gr_stream_mux.h b/gnuradio-core/src/lib/general/gr_stream_mux.h deleted file mode 100644 index 742bf082d1..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_mux.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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_STREAM_MUX_H -#define INCLUDED_GR_STREAM_MUX_H - - -#include <gr_core_api.h> -#include <gr_block.h> -#include <vector> - -/*! - * \brief Creates a stream muxing block to multiplex many streams into - * one with a specified format. - * \ingroup converter_blk - * - * \param itemsize the item size of the stream - * \param length a vector (list/tuple) specifying the number of - * items from each stream the mux together. - * Warning: this requires that at least as many items - * per stream are available or the system will wait - * indefinitely for the items. - * - */ -class gr_stream_mux; -typedef boost::shared_ptr<gr_stream_mux> gr_stream_mux_sptr; - - - -GR_CORE_API gr_stream_mux_sptr -gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths); - - -/*! - * \brief Stream muxing block to multiplex many streams into - * one with a specified format. - * - * Muxes N streams together producing an output stream that - * contains N0 items from the first stream, N1 items from the second, - * etc. and repeats: - * - * [N0, N1, N2, ..., Nm, N0, N1, ...] - */ - -class GR_CORE_API gr_stream_mux : public gr_block -{ - friend GR_CORE_API gr_stream_mux_sptr - gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths); - - protected: - gr_stream_mux (size_t itemsize, const std::vector<int> &lengths); - - private: - size_t d_itemsize; - unsigned int d_stream; // index of currently selected stream - int d_residual; // number if items left to put into current stream - gr_vector_int d_lengths; // number if items to pack per stream - - void increment_stream(); - - public: - ~gr_stream_mux(void); - - void forecast (int noutput_items, gr_vector_int &ninput_items_required); - - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - - -#endif diff --git a/gnuradio-core/src/lib/general/gr_stream_mux.i b/gnuradio-core/src/lib/general/gr_stream_mux.i deleted file mode 100644 index 7cc116a23b..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_mux.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 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. - */ - -#include <vector> - -GR_SWIG_BLOCK_MAGIC(gr,stream_mux) - -gr_stream_mux_sptr -gr_make_stream_mux (size_t itemsize, - const std::vector<int> &lengths); - -class gr_stream_mux : public gr_block -{ - protected: - gr_make_stream_mux (size_t itemsize, - const std::vector<int> &lengths); - - public: - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; diff --git a/gnuradio-core/src/lib/general/gr_stream_to_streams.cc b/gnuradio-core/src/lib/general/gr_stream_to_streams.cc deleted file mode 100644 index de72adb1dd..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_to_streams.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_stream_to_streams.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_stream_to_streams_sptr -gr_make_stream_to_streams (size_t item_size, size_t nstreams) -{ - return gnuradio::get_initial_sptr(new gr_stream_to_streams (item_size, nstreams)); -} - -gr_stream_to_streams::gr_stream_to_streams (size_t item_size, size_t nstreams) - : gr_sync_decimator ("stream_to_streams", - gr_make_io_signature (1, 1, item_size), - gr_make_io_signature (nstreams, - nstreams, item_size), - nstreams) -{ -} - -int -gr_stream_to_streams::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t item_size = output_signature()->sizeof_stream_item (0); - - const char *in = (const char *) input_items[0]; - char **outv = (char **) &output_items[0]; - int nstreams = output_items.size(); - - for (int i = 0; i < noutput_items; i++){ - for (int j = 0; j < nstreams; j++){ - memcpy(outv[j], in, item_size); - outv[j] += item_size; - in += item_size; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_stream_to_streams.h b/gnuradio-core/src/lib/general/gr_stream_to_streams.h deleted file mode 100644 index 117f57bf5e..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_to_streams.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_STREAM_TO_STREAMS_H -#define INCLUDED_GR_STREAM_TO_STREAMS_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_stream_to_streams; -typedef boost::shared_ptr<gr_stream_to_streams> gr_stream_to_streams_sptr; - -GR_CORE_API gr_stream_to_streams_sptr -gr_make_stream_to_streams (size_t item_size, size_t nstreams); - - -/*! - * \brief convert a stream of items into a N streams of items - * \ingroup slicedice_blk - * - * Converts a stream of N items into N streams of 1 item. - * Repeat ad infinitum. - */ -class GR_CORE_API gr_stream_to_streams : public gr_sync_decimator -{ - friend GR_CORE_API gr_stream_to_streams_sptr - gr_make_stream_to_streams (size_t item_size, size_t nstreams); - - protected: - gr_stream_to_streams (size_t item_size, size_t nstreams); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_STREAM_TO_STREAMS_H */ diff --git a/gnuradio-core/src/lib/general/gr_stream_to_streams.i b/gnuradio-core/src/lib/general/gr_stream_to_streams.i deleted file mode 100644 index 4d324372ee..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_to_streams.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,stream_to_streams) - -gr_stream_to_streams_sptr -gr_make_stream_to_streams (size_t itemsize, size_t nstreams); - -class gr_stream_to_streams : public gr_sync_decimator -{ - protected: - gr_stream_to_streams (size_t itemsize, size_t nstreams); - - public: -}; diff --git a/gnuradio-core/src/lib/general/gr_stream_to_vector.cc b/gnuradio-core/src/lib/general/gr_stream_to_vector.cc deleted file mode 100644 index d38cdd4348..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_to_vector.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_stream_to_vector.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_stream_to_vector_sptr -gr_make_stream_to_vector (size_t item_size, size_t nitems_per_block) -{ - return gnuradio::get_initial_sptr(new gr_stream_to_vector (item_size, nitems_per_block)); -} - -gr_stream_to_vector::gr_stream_to_vector (size_t item_size, size_t nitems_per_block) - : gr_sync_decimator ("stream_to_vector", - gr_make_io_signature (1, 1, item_size), - gr_make_io_signature (1, 1, item_size * nitems_per_block), - nitems_per_block) -{ -} - -int -gr_stream_to_vector::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t block_size = output_signature()->sizeof_stream_item (0); - - const char *in = (const char *) input_items[0]; - char *out = (char *) output_items[0]; - - memcpy (out, in, noutput_items * block_size); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_stream_to_vector.h b/gnuradio-core/src/lib/general/gr_stream_to_vector.h deleted file mode 100644 index 362349965f..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_to_vector.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 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_STREAM_TO_VECTOR_H -#define INCLUDED_GR_STREAM_TO_VECTOR_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_stream_to_vector; -typedef boost::shared_ptr<gr_stream_to_vector> gr_stream_to_vector_sptr; - -GR_CORE_API gr_stream_to_vector_sptr -gr_make_stream_to_vector (size_t item_size, size_t nitems_per_block); - - -/*! - * \brief convert a stream of items into a stream of blocks containing nitems_per_block - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_stream_to_vector : public gr_sync_decimator -{ - friend GR_CORE_API gr_stream_to_vector_sptr - gr_make_stream_to_vector (size_t item_size, size_t nitems_per_block); - - protected: - gr_stream_to_vector (size_t item_size, size_t nitems_per_block); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_STREAM_TO_VECTOR_H */ diff --git a/gnuradio-core/src/lib/general/gr_stream_to_vector.i b/gnuradio-core/src/lib/general/gr_stream_to_vector.i deleted file mode 100644 index ef867012ad..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_to_vector.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,stream_to_vector) - -gr_stream_to_vector_sptr -gr_make_stream_to_vector (size_t itemsize, size_t nitems_per_block); - -class gr_stream_to_vector : public gr_sync_decimator -{ - protected: - gr_stream_to_vector (size_t itemsize, size_t nitems_per_block); - - public: -}; diff --git a/gnuradio-core/src/lib/general/gr_streams_to_stream.cc b/gnuradio-core/src/lib/general/gr_streams_to_stream.cc deleted file mode 100644 index 8bce747227..0000000000 --- a/gnuradio-core/src/lib/general/gr_streams_to_stream.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_streams_to_stream.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_streams_to_stream_sptr -gr_make_streams_to_stream (size_t item_size, size_t nstreams) -{ - return gnuradio::get_initial_sptr(new gr_streams_to_stream (item_size, nstreams)); -} - -gr_streams_to_stream::gr_streams_to_stream (size_t item_size, size_t nstreams) - : gr_sync_interpolator ("streams_to_stream", - gr_make_io_signature (nstreams, nstreams, item_size), - gr_make_io_signature (1, 1, item_size), - nstreams) -{ -} - -int -gr_streams_to_stream::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t item_size = output_signature()->sizeof_stream_item (0); - - const char **inv = (const char **) &input_items[0]; - char *out = (char *) output_items[0]; - int nstreams = input_items.size(); - - assert (noutput_items % nstreams == 0); - int ni = noutput_items / nstreams; - - for (int i = 0; i < ni; i++){ - for (int j = 0; j < nstreams; j++){ - memcpy(out, inv[j], item_size); - out += item_size; - inv[j] += item_size; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_streams_to_stream.h b/gnuradio-core/src/lib/general/gr_streams_to_stream.h deleted file mode 100644 index f636837675..0000000000 --- a/gnuradio-core/src/lib/general/gr_streams_to_stream.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_STREAMS_TO_STREAM_H -#define INCLUDED_GR_STREAMS_TO_STREAM_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_streams_to_stream; -typedef boost::shared_ptr<gr_streams_to_stream> gr_streams_to_stream_sptr; - -GR_CORE_API gr_streams_to_stream_sptr -gr_make_streams_to_stream (size_t item_size, size_t nstreams); - - -/*! - * \brief Convert N streams of 1 item into a 1 stream of N items - * \ingroup slicedice_blk - * - * Convert N streams of 1 item into 1 stream of N items. - * Repeat ad infinitum. - */ -class GR_CORE_API gr_streams_to_stream : public gr_sync_interpolator -{ - friend GR_CORE_API gr_streams_to_stream_sptr - gr_make_streams_to_stream (size_t item_size, size_t nstreams); - - protected: - gr_streams_to_stream (size_t item_size, size_t nstreams); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_STREAMS_TO_STREAM_H */ diff --git a/gnuradio-core/src/lib/general/gr_streams_to_stream.i b/gnuradio-core/src/lib/general/gr_streams_to_stream.i deleted file mode 100644 index a09ded0710..0000000000 --- a/gnuradio-core/src/lib/general/gr_streams_to_stream.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,streams_to_stream) - -gr_streams_to_stream_sptr -gr_make_streams_to_stream (size_t itemsize, size_t nstreams); - -class gr_streams_to_stream : public gr_sync_interpolator -{ - protected: - gr_streams_to_stream (size_t itemsize, size_t nstreams); - - public: -}; diff --git a/gnuradio-core/src/lib/general/gr_streams_to_vector.cc b/gnuradio-core/src/lib/general/gr_streams_to_vector.cc deleted file mode 100644 index cf862ca954..0000000000 --- a/gnuradio-core/src/lib/general/gr_streams_to_vector.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_streams_to_vector.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_streams_to_vector_sptr -gr_make_streams_to_vector (size_t item_size, size_t nstreams) -{ - return gnuradio::get_initial_sptr(new gr_streams_to_vector (item_size, nstreams)); -} - -gr_streams_to_vector::gr_streams_to_vector (size_t item_size, size_t nstreams) - : gr_sync_block ("streams_to_vector", - gr_make_io_signature (nstreams, nstreams, item_size), - gr_make_io_signature (1, 1, nstreams * item_size)) -{ -} - -int -gr_streams_to_vector::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t item_size = input_signature()->sizeof_stream_item(0); - int nstreams = input_items.size(); - - const char **inv = (const char **) &input_items[0]; - char *out = (char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - for (int j = 0; j < nstreams; j++){ - memcpy(out, inv[j], item_size); - inv[j] += item_size; - out += item_size; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_streams_to_vector.h b/gnuradio-core/src/lib/general/gr_streams_to_vector.h deleted file mode 100644 index 1df2890999..0000000000 --- a/gnuradio-core/src/lib/general/gr_streams_to_vector.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 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_STREAMS_TO_VECTOR_H -#define INCLUDED_GR_STREAMS_TO_VECTOR_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_streams_to_vector; -typedef boost::shared_ptr<gr_streams_to_vector> gr_streams_to_vector_sptr; - -GR_CORE_API gr_streams_to_vector_sptr -gr_make_streams_to_vector (size_t item_size, size_t nstreams); - - -/*! - * \brief convert N streams of items to 1 stream of vector length N - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_streams_to_vector : public gr_sync_block -{ - friend GR_CORE_API gr_streams_to_vector_sptr - gr_make_streams_to_vector (size_t item_size, size_t nstreams); - - protected: - gr_streams_to_vector (size_t item_size, size_t nstreams); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_STREAMS_TO_VECTOR_H */ diff --git a/gnuradio-core/src/lib/general/gr_streams_to_vector.i b/gnuradio-core/src/lib/general/gr_streams_to_vector.i deleted file mode 100644 index 4d5eca45ef..0000000000 --- a/gnuradio-core/src/lib/general/gr_streams_to_vector.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,streams_to_vector) - -gr_streams_to_vector_sptr -gr_make_streams_to_vector (size_t itemsize, size_t nstreams); - -class gr_streams_to_vector : public gr_sync_block -{ - protected: - gr_streams_to_vector (size_t itemsize, size_t nstreams); - - public: -}; diff --git a/gnuradio-core/src/lib/general/gr_uchar_to_float.cc b/gnuradio-core/src/lib/general/gr_uchar_to_float.cc deleted file mode 100644 index 981a934400..0000000000 --- a/gnuradio-core/src/lib/general/gr_uchar_to_float.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_uchar_to_float.h> -#include <gr_io_signature.h> -#include <gri_uchar_to_float.h> - -gr_uchar_to_float_sptr -gr_make_uchar_to_float () -{ - return gnuradio::get_initial_sptr(new gr_uchar_to_float ()); -} - -gr_uchar_to_float::gr_uchar_to_float () - : gr_sync_block ("gr_uchar_to_float", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (float))) -{ -} - -int -gr_uchar_to_float::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - float *out = (float *) output_items[0]; - - gri_uchar_to_float (in, out, noutput_items); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_uchar_to_float.h b/gnuradio-core/src/lib/general/gr_uchar_to_float.h deleted file mode 100644 index c02601cca6..0000000000 --- a/gnuradio-core/src/lib/general/gr_uchar_to_float.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_UCHAR_TO_FLOAT_H -#define INCLUDED_GR_UCHAR_TO_FLOAT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_uchar_to_float; -typedef boost::shared_ptr<gr_uchar_to_float> gr_uchar_to_float_sptr; - -GR_CORE_API gr_uchar_to_float_sptr -gr_make_uchar_to_float (); - -/*! - * \brief Convert stream of unsigned chars to a stream of float - * \ingroup converter_blk - */ - -class GR_CORE_API gr_uchar_to_float : public gr_sync_block -{ - friend GR_CORE_API gr_uchar_to_float_sptr gr_make_uchar_to_float (); - gr_uchar_to_float (); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_UCHAR_TO_FLOAT_H */ diff --git a/gnuradio-core/src/lib/general/gr_uchar_to_float.i b/gnuradio-core/src/lib/general/gr_uchar_to_float.i deleted file mode 100644 index b6cc353296..0000000000 --- a/gnuradio-core/src/lib/general/gr_uchar_to_float.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,uchar_to_float) - -gr_uchar_to_float_sptr gr_make_uchar_to_float (); - -class gr_uchar_to_float : public gr_sync_block -{ - gr_uchar_to_float (); -}; diff --git a/gnuradio-core/src/lib/general/gr_vector_to_stream.cc b/gnuradio-core/src/lib/general/gr_vector_to_stream.cc deleted file mode 100644 index 621b7ec581..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_to_stream.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_vector_to_stream.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_vector_to_stream_sptr -gr_make_vector_to_stream (size_t item_size, size_t nitems_per_block) -{ - return gnuradio::get_initial_sptr(new gr_vector_to_stream (item_size, nitems_per_block)); -} - -gr_vector_to_stream::gr_vector_to_stream (size_t item_size, size_t nitems_per_block) - : gr_sync_interpolator ("vector_to_stream", - gr_make_io_signature (1, 1, item_size * nitems_per_block), - gr_make_io_signature (1, 1, item_size), - nitems_per_block) -{ -} - -int -gr_vector_to_stream::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t block_size = output_signature()->sizeof_stream_item (0); - - const char *in = (const char *) input_items[0]; - char *out = (char *) output_items[0]; - - memcpy (out, in, noutput_items * block_size); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_vector_to_stream.h b/gnuradio-core/src/lib/general/gr_vector_to_stream.h deleted file mode 100644 index 9fc8030f5b..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_to_stream.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2006 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_VECTOR_TO_STREAM_H -#define INCLUDED_GR_VECTOR_TO_STREAM_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_vector_to_stream; -typedef boost::shared_ptr<gr_vector_to_stream> gr_vector_to_stream_sptr; - -GR_CORE_API gr_vector_to_stream_sptr -gr_make_vector_to_stream (size_t item_size, size_t nitems_per_block); - - -/*! - * \brief convert a stream of blocks of nitems_per_block items into a stream of items - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_vector_to_stream : public gr_sync_interpolator -{ - friend GR_CORE_API gr_vector_to_stream_sptr - gr_make_vector_to_stream (size_t item_size, size_t nitems_per_block); - - protected: - gr_vector_to_stream (size_t item_size, size_t nitems_per_block); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_VECTOR_TO_STREAM_H */ diff --git a/gnuradio-core/src/lib/general/gr_vector_to_stream.i b/gnuradio-core/src/lib/general/gr_vector_to_stream.i deleted file mode 100644 index 99776eeb86..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_to_stream.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,vector_to_stream) - -gr_vector_to_stream_sptr -gr_make_vector_to_stream (size_t itemsize, size_t nitems_per_block); - -class gr_vector_to_stream : public gr_sync_decimator -{ - protected: - gr_vector_to_stream (size_t itemsize, size_t nitems_per_block); - - public: -}; diff --git a/gnuradio-core/src/lib/general/gr_vector_to_streams.cc b/gnuradio-core/src/lib/general/gr_vector_to_streams.cc deleted file mode 100644 index 7ab352a4fb..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_to_streams.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_vector_to_streams.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_vector_to_streams_sptr -gr_make_vector_to_streams (size_t item_size, size_t nstreams) -{ - return gnuradio::get_initial_sptr(new gr_vector_to_streams (item_size, nstreams)); -} - -gr_vector_to_streams::gr_vector_to_streams (size_t item_size, size_t nstreams) - : gr_sync_block ("vector_to_streams", - gr_make_io_signature (1, 1, nstreams * item_size), - gr_make_io_signature (nstreams, nstreams, item_size)) -{ -} - -int -gr_vector_to_streams::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t item_size = output_signature()->sizeof_stream_item(0); - int nstreams = output_items.size(); - - const char *in = (const char *) input_items[0]; - char **outv = (char **) &output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - for (int j = 0; j < nstreams; j++){ - memcpy(outv[j], in, item_size); - outv[j] += item_size; - in += item_size; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_vector_to_streams.h b/gnuradio-core/src/lib/general/gr_vector_to_streams.h deleted file mode 100644 index 8db4230536..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_to_streams.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 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_VECTOR_TO_STREAMS_H -#define INCLUDED_GR_VECTOR_TO_STREAMS_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_vector_to_streams; -typedef boost::shared_ptr<gr_vector_to_streams> gr_vector_to_streams_sptr; - -GR_CORE_API gr_vector_to_streams_sptr -gr_make_vector_to_streams (size_t item_size, size_t nstreams); - - -/*! - * \brief Convert 1 stream of vectors of length N to N streams of items - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_vector_to_streams : public gr_sync_block -{ - friend GR_CORE_API gr_vector_to_streams_sptr - gr_make_vector_to_streams (size_t item_size, size_t nstreams); - - protected: - gr_vector_to_streams (size_t item_size, size_t nstreams); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_VECTOR_TO_STREAMS_H */ diff --git a/gnuradio-core/src/lib/general/gr_vector_to_streams.i b/gnuradio-core/src/lib/general/gr_vector_to_streams.i deleted file mode 100644 index d4123135bc..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_to_streams.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,vector_to_streams) - -gr_vector_to_streams_sptr -gr_make_vector_to_streams (size_t itemsize, size_t nstreams); - -class gr_vector_to_streams : public gr_sync_block -{ - protected: - gr_vector_to_streams (size_t itemsize, size_t nstreams); - - public: -}; diff --git a/gnuradio-core/src/lib/general/gri_char_to_float.cc b/gnuradio-core/src/lib/general/gri_char_to_float.cc deleted file mode 100644 index fd9a6636a1..0000000000 --- a/gnuradio-core/src/lib/general/gri_char_to_float.cc +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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. - */ - -#include <gri_char_to_float.h> - -void -gri_char_to_float (const char *in, float *out, int nsamples) -{ - while (nsamples >= 4){ - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; - out[3] = in[3]; - out += 4; - in += 4; - nsamples -= 4; - } - - while (nsamples-- > 0) - *out++ = *in++; -} diff --git a/gnuradio-core/src/lib/general/gri_char_to_float.h b/gnuradio-core/src/lib/general/gri_char_to_float.h deleted file mode 100644 index 8bd3bfde7d..0000000000 --- a/gnuradio-core/src/lib/general/gri_char_to_float.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_CHAR_TO_FLOAT_H -#define INCLUDED_GRI_CHAR_TO_FLOAT_H - -#include <gr_core_api.h> - -/* - * convert array of chars to floats - */ -GR_CORE_API void gri_char_to_float (const char *in, float *out, int nsamples); - - -#endif /* INCLUDED_GRI_CHAR_TO_FLOAT_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/gri_float_to_char.cc b/gnuradio-core/src/lib/general/gri_float_to_char.cc deleted file mode 100644 index 3e779b0e70..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_char.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#define _ISOC9X_SOURCE -#include <gri_float_to_char.h> -#include <math.h> - -static const int MIN_CHAR = -128; -static const int MAX_CHAR = 127; - - -void -gri_float_to_char (const float *in, char *out, int nsamples) -{ - for (int i = 0; i < nsamples; i++){ - long int r = (long int) rint (in[i]); - if (r < MIN_CHAR) - r = MIN_CHAR; - else if (r > MAX_CHAR) - r = MAX_CHAR; - out[i] = r; - } -} diff --git a/gnuradio-core/src/lib/general/gri_float_to_char.h b/gnuradio-core/src/lib/general/gri_float_to_char.h deleted file mode 100644 index 172a7da651..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_char.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_FLOAT_TO_CHAR_H -#define INCLUDED_GRI_FLOAT_TO_CHAR_H - -#include <gr_core_api.h> - -/*! - * convert array of floats to chars with rounding and saturation. - */ -GR_CORE_API void gri_float_to_char (const float *in, char *out, int nsamples); - -#endif /* INCLUDED_GRI_FLOAT_TO_CHAR_H */ diff --git a/gnuradio-core/src/lib/general/gri_float_to_int.cc b/gnuradio-core/src/lib/general/gri_float_to_int.cc deleted file mode 100644 index 525ea675d2..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_int.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#define _ISOC9X_SOURCE -#include <gri_float_to_int.h> -#include <math.h> -#include <stdint.h> - -static const int64_t MAX_INT = 2147483647; // (2^31)-1 -static const int64_t MIN_INT = -2147483647; // -(2^31)-1 - - -void -gri_float_to_int (const float *in, int *out, float scale, int nsamples) -{ - for (int i = 0; i < nsamples; i++){ - int64_t r = llrintf(scale * in[i]); - if (r < MIN_INT) - r = MIN_INT; - else if (r > MAX_INT) - r = MAX_INT; - out[i] = static_cast<int>(r); - } -} diff --git a/gnuradio-core/src/lib/general/gri_float_to_int.h b/gnuradio-core/src/lib/general/gri_float_to_int.h deleted file mode 100644 index 84f72a420d..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_int.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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_FLOAT_TO_INT_H -#define INCLUDED_GRI_FLOAT_TO_INT_H - -#include <gr_core_api.h> - -/*! - * convert array of floats to int with rounding and saturation. - */ -GR_CORE_API void gri_float_to_int (const float *in, int *out, float scale, int nsamples); - -#endif /* INCLUDED_GRI_FLOAT_TO_INT_H */ diff --git a/gnuradio-core/src/lib/general/gri_float_to_short.cc b/gnuradio-core/src/lib/general/gri_float_to_short.cc deleted file mode 100644 index 4508e37a7d..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_short.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#define _ISOC9X_SOURCE -#include <gri_float_to_short.h> -#include <math.h> - -static const int MIN_SHORT = -32768; -static const int MAX_SHORT = 32767; - - -void -gri_float_to_short (const float *in, short *out, int nsamples) -{ - for (int i = 0; i < nsamples; i++){ - long int r = (long int) rint (in[i]); - if (r < MIN_SHORT) - r = MIN_SHORT; - else if (r > MAX_SHORT) - r = MAX_SHORT; - out[i] = r; - } -} diff --git a/gnuradio-core/src/lib/general/gri_float_to_short.h b/gnuradio-core/src/lib/general/gri_float_to_short.h deleted file mode 100644 index b9cdf685be..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_short.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_FLOAT_TO_SHORT_H -#define INCLUDED_GRI_FLOAT_TO_SHORT_H - -#include <gr_core_api.h> - -/*! - * convert array of floats to shorts with rounding and saturation. - */ -GR_CORE_API void gri_float_to_short (const float *in, short *out, int nsamples); - -#endif /* INCLUDED_GRI_FLOAT_TO_SHORT_H */ diff --git a/gnuradio-core/src/lib/general/gri_float_to_uchar.cc b/gnuradio-core/src/lib/general/gri_float_to_uchar.cc deleted file mode 100644 index 9ea42a31b5..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_uchar.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#define _ISOC9X_SOURCE -#include <gri_float_to_uchar.h> -#include <math.h> - -static const int MIN_UCHAR = 0; -static const int MAX_UCHAR = 255; - - -void -gri_float_to_uchar (const float *in, unsigned char *out, int nsamples) -{ - for (int i = 0; i < nsamples; i++){ - long int r = (long int) rint (in[i]); - if (r < MIN_UCHAR) - r = MIN_UCHAR; - else if (r > MAX_UCHAR) - r = MAX_UCHAR; - out[i] = r; - } -} diff --git a/gnuradio-core/src/lib/general/gri_float_to_uchar.h b/gnuradio-core/src/lib/general/gri_float_to_uchar.h deleted file mode 100644 index e24b1973fd..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_uchar.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_FLOAT_TO_UCHAR_H -#define INCLUDED_GRI_FLOAT_TO_UCHAR_H - -#include <gr_core_api.h> - -/*! - * convert array of floats to unsigned chars with rounding and saturation. - */ -GR_CORE_API void gri_float_to_uchar (const float *in, unsigned char *out, int nsamples); - -#endif /* INCLUDED_GRI_FLOAT_TO_UCHAR_H */ diff --git a/gnuradio-core/src/lib/general/gri_int_to_float.cc b/gnuradio-core/src/lib/general/gri_int_to_float.cc deleted file mode 100644 index 91da08897f..0000000000 --- a/gnuradio-core/src/lib/general/gri_int_to_float.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#define _ISOC9X_SOURCE -#include <gri_int_to_float.h> -#include <math.h> - -void -gri_int_to_float (const int *in, float *out, int nsamples) -{ - for (int i = 0; i < nsamples; i++){ - out[i] = static_cast<float>(in[i]); - } -} diff --git a/gnuradio-core/src/lib/general/gri_int_to_float.h b/gnuradio-core/src/lib/general/gri_int_to_float.h deleted file mode 100644 index 4b08b7c6be..0000000000 --- a/gnuradio-core/src/lib/general/gri_int_to_float.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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_INT_TO_FLOAT_H -#define INCLUDED_GRI_INT_TO_FLOAT_H - -#include <gr_core_api.h> - -/* - * convert array of ints to floats - */ -GR_CORE_API void gri_int_to_float (const int *in, float *out, int nsamples); - - -#endif /* INCLUDED_GRI_INT_TO_FLOAT_H */ diff --git a/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.cc b/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.cc deleted file mode 100644 index 7d0af0fc75..0000000000 --- a/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gri_interleaved_short_to_complex.h> -#include <assert.h> - -void -gri_interleaved_short_to_complex (const short *in, - gr_complex *out, int nsamples) -{ - assert (nsamples % 2 == 0); - - for (int i = 0; i < nsamples/2; i++){ - out[i] = gr_complex (in[i*2 + 0], in[i*2 + 1]); - } -} diff --git a/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.h b/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.h deleted file mode 100644 index 8d8a0d16ef..0000000000 --- a/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_INTERLEAVED_SHORT_TO_COMPLEX_H -#define INCLUDED_GRI_INTERLEAVED_SHORT_TO_COMPLEX_H - -#include <gr_core_api.h> -#include <gr_complex.h> - -/* - * convert array of interleaved shorts to complex. - * the shorts contains real, imaginary, real, imaginary... - * nsamples is the number of shorts; it must be even. - */ -GR_CORE_API void gri_interleaved_short_to_complex (const short *in, gr_complex *out, int nsamples); - -#endif /* INCLUDED_GRI_INTERLEAVED_SHORT_TO_COMPLEX_H */ - - diff --git a/gnuradio-core/src/lib/general/gri_short_to_float.cc b/gnuradio-core/src/lib/general/gri_short_to_float.cc deleted file mode 100644 index d5d0e786e3..0000000000 --- a/gnuradio-core/src/lib/general/gri_short_to_float.cc +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -#include <gri_short_to_float.h> - -void -gri_short_to_float (const short *in, float *out, int nsamples) -{ - while (nsamples >= 4){ - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; - out[3] = in[3]; - out += 4; - in += 4; - nsamples -= 4; - } - - while (nsamples-- > 0) - *out++ = *in++; -} diff --git a/gnuradio-core/src/lib/general/gri_short_to_float.h b/gnuradio-core/src/lib/general/gri_short_to_float.h deleted file mode 100644 index 2ffdbb45b8..0000000000 --- a/gnuradio-core/src/lib/general/gri_short_to_float.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_SHORT_TO_FLOAT_H -#define INCLUDED_GRI_SHORT_TO_FLOAT_H - -#include <gr_core_api.h> - -/* - * convert array of shorts to floats - */ -GR_CORE_API void gri_short_to_float (const short *in, float *out, int nsamples); - - -#endif /* INCLUDED_GRI_SHORT_TO_FLOAT_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/gri_uchar_to_float.cc b/gnuradio-core/src/lib/general/gri_uchar_to_float.cc deleted file mode 100644 index 91f3e7336a..0000000000 --- a/gnuradio-core/src/lib/general/gri_uchar_to_float.cc +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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. - */ - -#include <gri_uchar_to_float.h> - -void -gri_uchar_to_float (const unsigned char *in, float *out, int nsamples) -{ - while (nsamples >= 4){ - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; - out[3] = in[3]; - out += 4; - in += 4; - nsamples -= 4; - } - - while (nsamples-- > 0) - *out++ = *in++; -} diff --git a/gnuradio-core/src/lib/general/gri_uchar_to_float.h b/gnuradio-core/src/lib/general/gri_uchar_to_float.h deleted file mode 100644 index 633c5d4ce7..0000000000 --- a/gnuradio-core/src/lib/general/gri_uchar_to_float.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_UCHAR_TO_FLOAT_H -#define INCLUDED_GRI_UCHAR_TO_FLOAT_H - -#include <gr_core_api.h> - -/* - * convert array of unsigned chars to floats - */ -GR_CORE_API void gri_uchar_to_float (const unsigned char *in, float *out, int nsamples); - - -#endif /* INCLUDED_GRI_UCHAR_TO_FLOAT_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/gengen/CMakeLists.txt b/gnuradio-core/src/lib/gengen/CMakeLists.txt index 03f39d358d..404a258873 100644 --- a/gnuradio-core/src/lib/gengen/CMakeLists.txt +++ b/gnuradio-core/src/lib/gengen/CMakeLists.txt @@ -87,25 +87,11 @@ expand_h_cc_i(gr_vector_sink_X b s i f c) expand_h_cc_i(gr_probe_signal_X b s i f c) expand_h_cc_i(gr_probe_signal_vX b s i f c) -expand_h_cc_i(gr_add_const_XX bb ss ii ff cc sf) -expand_h_cc_i(gr_multiply_const_XX ss ii) -expand_h_cc_i(gr_add_XX ss ii cc) -expand_h_cc_i(gr_sub_XX ss ii ff cc) -expand_h_cc_i(gr_multiply_XX ss ii) -expand_h_cc_i(gr_divide_XX ss ii ff cc) expand_h_cc_i(gr_mute_XX ss ii ff cc) -expand_h_cc_i(gr_add_const_vXX ss ii ff cc) -expand_h_cc_i(gr_multiply_const_vXX ss ii ff cc) -expand_h_cc_i(gr_integrate_XX ss ii ff cc) expand_h_cc_i(gr_moving_average_XX ss ii ff cc) expand_h_cc_i(gr_unpacked_to_packed_XX bb ss ii) expand_h_cc_i(gr_packed_to_unpacked_XX bb ss ii) -expand_h_cc_i(gr_xor_XX bb ss ii) -expand_h_cc_i(gr_and_XX bb ss ii) -expand_h_cc_i(gr_and_const_XX bb ss ii) -expand_h_cc_i(gr_or_XX bb ss ii) -expand_h_cc_i(gr_not_XX bb ss ii) expand_h_cc_i(gr_sample_and_hold_XX bb ss ii ff) expand_h_cc_i(gr_argmax_XX fs is ss) expand_h_cc_i(gr_max_XX ff ii ss) diff --git a/gnuradio-core/src/lib/gengen/generate_common.py b/gnuradio-core/src/lib/gengen/generate_common.py index d04df6bda5..6a04a75d72 100755 --- a/gnuradio-core/src/lib/gengen/generate_common.py +++ b/gnuradio-core/src/lib/gengen/generate_common.py @@ -40,13 +40,7 @@ ss_roots = [ reg_signatures = ['ss', 'ii', 'ff', 'cc'] reg_roots = [ - 'gr_add_const_XX', - 'gr_sub_XX', - 'gr_divide_XX', 'gr_mute_XX', - 'gr_add_const_vXX', - 'gr_multiply_const_vXX', - 'gr_integrate_XX', 'gr_moving_average_XX', ] @@ -54,18 +48,10 @@ reg_roots = [ others = ( ('gr_unpacked_to_packed_XX', ('bb','ss','ii')), ('gr_packed_to_unpacked_XX', ('bb','ss','ii')), - ('gr_xor_XX', ('bb','ss','ii')), - ('gr_and_XX', ('bb','ss','ii')), - ('gr_and_const_XX', ('bb','ss','ii')), - ('gr_or_XX', ('bb','ss','ii')), - ('gr_not_XX', ('bb','ss','ii')), ('gr_sample_and_hold_XX', ('bb','ss','ii','ff')), ('gr_argmax_XX', ('fs','is','ss')), ('gr_max_XX', ('ff','ii','ss')), ('gr_peak_detector_XX', ('fb','ib','sb')), - ('gr_multiply_XX', ('ss','ii')), - ('gr_multiply_const_XX', ('ss','ii')), - ('gr_add_XX', ('ss','cc','ii')) ) @@ -79,7 +65,6 @@ def expand_h_cc_i (root, sig): def generate (): - expand_h_cc_i ('gr_add_const_XX', 'sf') # for MC4020 expand_h_cc_i ('gr_vector_sink_X', 'b') expand_h_cc_i ('gr_vector_source_X', 'b') expand_h_cc_i ('gr_probe_signal_X', 'b') diff --git a/gnuradio-core/src/lib/gengen/gr_add_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_add_XX.cc.t deleted file mode 100644 index 5a888125bf..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_XX.cc.t +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (size_t vlen) -{ - return gnuradio::get_initial_sptr (new @NAME@ (vlen)); -} - -@NAME@::@NAME@ (size_t vlen) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)*vlen), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)*vlen)), - d_vlen (vlen) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - for (size_t i = 0; i < noutput_items*d_vlen; i++){ - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc += ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_add_XX.h.t b/gnuradio-core/src/lib/gengen/gr_add_XX.h.t deleted file mode 100644 index cd6d80cd9a..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_XX.h.t +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 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 <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -/*! - * \brief output = sum (input_0, input_1, ...) - * \ingroup math_blk - * - * Add across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - @NAME@ (size_t vlen); - - size_t d_vlen; - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_add_XX.i.t b/gnuradio-core/src/lib/gengen/gr_add_XX.i.t deleted file mode 100644 index b2c5106106..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 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@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (size_t vlen); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_add_const_XX.cc.t deleted file mode 100644 index 3dccc86b80..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_const_XX.cc.t +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (@O_TYPE@ k) -{ - return gnuradio::get_initial_sptr (new @NAME@ (k)); -} - -@NAME@::@NAME@ (@O_TYPE@ k) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_k (k) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0]; - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int size = noutput_items; - - while (size >= 8){ - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - size -= 8; - } - - while (size-- > 0) - *optr++ = *iptr++ + d_k; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_XX.h.t b/gnuradio-core/src/lib/gengen/gr_add_const_XX.h.t deleted file mode 100644 index 00d2c9b587..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_const_XX.h.t +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - -/*! - * \brief output = input + constant - * \ingroup math_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - - @O_TYPE@ d_k; // the constant - @NAME@ (@O_TYPE@ k); - - public: - @O_TYPE@ k () const { return d_k; } - void set_k (@O_TYPE@ k) { d_k = k; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_XX.i.t b/gnuradio-core/src/lib/gengen/gr_add_const_XX.i.t deleted file mode 100644 index b7921554e5..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_const_XX.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (@TYPE@ k); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (@TYPE@ k); - - public: - @TYPE@ k () const { return d_k; } - void set_k (@TYPE@ k) { d_k = k; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t deleted file mode 100755 index b29f3014d8..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k) -{ - return gnuradio::get_initial_sptr (new @NAME@ (k)); -} - -@NAME@::@NAME@ (const std::vector<@I_TYPE@> &k) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof(@I_TYPE@)*k.size()), - gr_make_io_signature (1, 1, sizeof(@O_TYPE@)*k.size())) -{ - d_k = k; -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *iptr = (@O_TYPE@ *)input_items[0]; - @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; - - int nitems_per_block = output_signature()->sizeof_stream_item(0)/sizeof(@I_TYPE@); - - for (int i = 0; i < noutput_items; i++) - for (int j = 0; j < nitems_per_block; j++) - *optr++ = *iptr++ + d_k[j]; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t deleted file mode 100644 index 438a84bfdd..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 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 <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); - -/*! - * \brief output vector = input vector + constant vector - * \ingroup math_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); - - std::vector<@I_TYPE@> d_k; // the constant - @NAME@ (const std::vector<@I_TYPE@> &k); - - public: - const std::vector<@I_TYPE@> k () const { return d_k; } - void set_k (const std::vector<@I_TYPE@> &k) { d_k = k; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.i.t b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.i.t deleted file mode 100755 index e0e6ae9051..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 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@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (const std::vector<@I_TYPE@> &k); - - public: - std::vector<@I_TYPE@> k () const { return d_k; } - void set_k (const std::vector<@I_TYPE@> &k) { d_k = k; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_and_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_and_XX.cc.t deleted file mode 100644 index 9d60e092af..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_and_XX.cc.t +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ () -{ - return gnuradio::get_initial_sptr (new @NAME@ ()); -} - -@NAME@::@NAME@ () - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - for (int i = 0; i < noutput_items; i++) { - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc = acc & ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_and_XX.h.t b/gnuradio-core/src/lib/gengen/gr_and_XX.h.t deleted file mode 100644 index 2247780968..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_and_XX.h.t +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 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 <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - -/*! - * \brief output = input_0 & input_1 & , ... & input_N) - * \ingroup math_blk - * - * bitwise boolean and across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - - @NAME@ (); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_and_XX.i.t b/gnuradio-core/src/lib/gengen/gr_and_XX.i.t deleted file mode 100644 index 06db5ca59d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_and_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 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@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_and_const_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_and_const_XX.cc.t deleted file mode 100644 index d4f9a4b613..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_and_const_XX.cc.t +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (@I_TYPE@ k) -{ - return gnuradio::get_initial_sptr (new @NAME@ (k)); -}; - -@NAME@::@NAME@ (@I_TYPE@ k) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_k (k) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0]; - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int size = noutput_items; - - while (size >= 8) { - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - size -= 8; - } - - while (size-- > 0) - *optr++ = *iptr++ & d_k; - - return (noutput_items); -} diff --git a/gnuradio-core/src/lib/gengen/gr_and_const_XX.h.t b/gnuradio-core/src/lib/gengen/gr_and_const_XX.h.t deleted file mode 100644 index b331f33ccd..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_and_const_XX.h.t +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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 <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - -/*! - * \brief output_N = input_N & value - * \ingroup math_blk - * - * bitwise boolean and of const to the data stream. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - - @O_TYPE@ d_k; // the constant - @NAME@ (@O_TYPE@ k); - - public: - @O_TYPE@ k () const { return d_k; } - void set_k (@O_TYPE@ k) { d_k = k; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_and_const_XX.i.t b/gnuradio-core/src/lib/gengen/gr_and_const_XX.i.t deleted file mode 100644 index c797c45eb7..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_and_const_XX.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (@O_TYPE@ k); - - public: - @O_TYPE@ k () const { return d_k; } - void set_k (@O_TYPE@ k) { d_k = k; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_divide_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_divide_XX.cc.t deleted file mode 100644 index 63450cb3df..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_divide_XX.cc.t +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (size_t vlen) -{ - return gnuradio::get_initial_sptr (new @NAME@ (vlen)); -} - -@NAME@::@NAME@ (size_t vlen) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)*vlen), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)*vlen)), - d_vlen (vlen) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - if (ninputs == 1){ // compute reciprocal - for (size_t i = 0; i < noutput_items*d_vlen; i++) - *optr++ = (@O_TYPE@) ((@O_TYPE@) 1 / - ((@I_TYPE@ *) input_items[0])[i]); - } - - else { - for (size_t i = 0; i < noutput_items*d_vlen; i++){ - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc /= ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_divide_XX.h.t b/gnuradio-core/src/lib/gengen/gr_divide_XX.h.t deleted file mode 100644 index 40ee27a51d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_divide_XX.h.t +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 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 <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -/*! - * \brief output = input_0 / input_1 / input_x ...) - * \ingroup math_blk - * - * Divide across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - @NAME@ (size_t vlen); - - size_t d_vlen; - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_divide_XX.i.t b/gnuradio-core/src/lib/gengen/gr_divide_XX.i.t deleted file mode 100644 index b2c5106106..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_divide_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 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@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (size_t vlen); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t deleted file mode 100644 index 1dbee49db9..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (int decim) -{ - return gnuradio::get_initial_sptr (new @NAME@ (decim)); -} - -@NAME@::@NAME@ (int decim) - : gr_sync_decimator ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)), - decim), - d_decim(decim), - d_count(0) -{ -} - -@NAME@::~@NAME@ () -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - - for (int i = 0; i < noutput_items; i++) { - out[i] = (@O_TYPE@)0; - for (int j = 0; j < d_decim; j++) - out[i] += in[i*d_decim+j]; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t b/gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t deleted file mode 100644 index a96e5fd29d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@SPTR_NAME@ gr_make_@BASE_NAME@ (int decim); - -class @NAME@ : public gr_sync_decimator -{ -private: - @NAME@ (); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_multiply_XX.cc.t deleted file mode 100644 index a60118e14c..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_XX.cc.t +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (size_t vlen) -{ - return gnuradio::get_initial_sptr (new @NAME@ (vlen)); -} - -@NAME@::@NAME@ (size_t vlen) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)*vlen), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)*vlen)), - d_vlen (vlen) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - for (size_t i = 0; i < noutput_items*d_vlen; i++){ - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc *= ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_XX.h.t b/gnuradio-core/src/lib/gengen/gr_multiply_XX.h.t deleted file mode 100644 index 18ec6d0beb..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_XX.h.t +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 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 <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -/*! - * \brief output = prod (input_0, input_1, ...) - * \ingroup math_blk - * - * Multiply across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - @NAME@ (size_t vlen); - - size_t d_vlen; - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_XX.i.t b/gnuradio-core/src/lib/gengen/gr_multiply_XX.i.t deleted file mode 100644 index b2c5106106..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 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@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (size_t vlen); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.cc.t deleted file mode 100644 index 424b62412c..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.cc.t +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (@O_TYPE@ k) -{ - return gnuradio::get_initial_sptr (new @NAME@ (k)); -} - -@NAME@::@NAME@ (@O_TYPE@ k) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_k (k) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0]; - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int size = noutput_items; - - while (size >= 8){ - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - size -= 8; - } - - while (size-- > 0) - *optr++ = *iptr++ * d_k; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.h.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.h.t deleted file mode 100644 index 274fc3b998..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.h.t +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - -/*! - * \brief output = input * constant - * \ingroup math_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - - @O_TYPE@ d_k; // the constant - @NAME@ (@O_TYPE@ k); - - public: - @O_TYPE@ k () const { return d_k; } - void set_k (@O_TYPE@ k) { d_k = k; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.i.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.i.t deleted file mode 100644 index b7921554e5..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (@TYPE@ k); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (@TYPE@ k); - - public: - @TYPE@ k () const { return d_k; } - void set_k (@TYPE@ k) { d_k = k; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t deleted file mode 100755 index eb896dee53..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k) -{ - return gnuradio::get_initial_sptr (new @NAME@ (k)); -} - -@NAME@::@NAME@ (const std::vector<@I_TYPE@> &k) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof(@I_TYPE@)*k.size()), - gr_make_io_signature (1, 1, sizeof(@O_TYPE@)*k.size())) -{ - d_k = k; -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *iptr = (@O_TYPE@ *)input_items[0]; - @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; - - int nitems_per_block = output_signature()->sizeof_stream_item(0)/sizeof(@I_TYPE@); - - for (int i = 0; i < noutput_items; i++) - for (int j = 0; j < nitems_per_block; j++) - *optr++ = *iptr++ * d_k[j]; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t deleted file mode 100644 index 2c6edd3642..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 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 <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); - -/*! - * \brief output vector = input vector * constant vector (element-wise) - * \ingroup math_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); - - std::vector<@I_TYPE@> d_k; // the constant - @NAME@ (const std::vector<@I_TYPE@> &k); - - public: - const std::vector<@I_TYPE@> k () const { return d_k; } - void set_k (const std::vector<@I_TYPE@> &k) { d_k = k; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.i.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.i.t deleted file mode 100755 index e0e6ae9051..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 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@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (const std::vector<@I_TYPE@> &k); - - public: - std::vector<@I_TYPE@> k () const { return d_k; } - void set_k (const std::vector<@I_TYPE@> &k) { d_k = k; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_not_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_not_XX.cc.t deleted file mode 100644 index 4806b142f2..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_not_XX.cc.t +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ () -{ - return gnuradio::get_initial_sptr (new @NAME@ ()); -} - -@NAME@::@NAME@ () - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - const @I_TYPE@ *inptr = (const @I_TYPE@ *) input_items[0]; - - - for (int i = 0; i < noutput_items; i++) { - *optr++ = ~(inptr[i]); - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_not_XX.i.t b/gnuradio-core/src/lib/gengen/gr_not_XX.i.t deleted file mode 100644 index 06db5ca59d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_not_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 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@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_or_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_or_XX.cc.t deleted file mode 100644 index ee55eedda4..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_or_XX.cc.t +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ () -{ - return gnuradio::get_initial_sptr (new @NAME@ ()); -} - -@NAME@::@NAME@ () - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - for (int i = 0; i < noutput_items; i++) { - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc = acc | ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_or_XX.i.t b/gnuradio-core/src/lib/gengen/gr_or_XX.i.t deleted file mode 100644 index 06db5ca59d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_or_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 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@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_sub_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_sub_XX.cc.t deleted file mode 100644 index 11eb7440e0..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_sub_XX.cc.t +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (size_t vlen) -{ - return gnuradio::get_initial_sptr (new @NAME@ (vlen)); -} - -@NAME@::@NAME@ (size_t vlen) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)*vlen), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)*vlen)), - d_vlen (vlen) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - if (ninputs == 1){ // negate - for (size_t i = 0; i < noutput_items*d_vlen; i++) - *optr++ = (@O_TYPE@) -((@I_TYPE@ *) input_items[0])[i]; - } - - else { - for (size_t i = 0; i < noutput_items*d_vlen; i++){ - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc -= ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_sub_XX.h.t b/gnuradio-core/src/lib/gengen/gr_sub_XX.h.t deleted file mode 100644 index f96c934845..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_sub_XX.h.t +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 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 <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -/*! - * \brief output = input_0 - input_1 - ...) - * \ingroup math_blk - * - * Subtract across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - @NAME@ (size_t vlen); - - size_t d_vlen; - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_sub_XX.i.t b/gnuradio-core/src/lib/gengen/gr_sub_XX.i.t deleted file mode 100644 index b2c5106106..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_sub_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 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@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (size_t vlen); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_xor_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_xor_XX.cc.t deleted file mode 100644 index d6990aa4f5..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_xor_XX.cc.t +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 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 <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ () -{ - return gnuradio::get_initial_sptr (new @NAME@ ()); -} - -@NAME@::@NAME@ () - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - for (int i = 0; i < noutput_items; i++) { - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc = acc ^ ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_xor_XX.h.t b/gnuradio-core/src/lib/gengen/gr_xor_XX.h.t deleted file mode 100644 index 8fe47d9e00..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_xor_XX.h.t +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 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 <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - -/*! - * \brief output = input_0 ^ input_1 ^ , ... ^ input_N) - * \ingroup math_blk - * - * bitwise boolean xor across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - - @NAME@ (); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_xor_XX.i.t b/gnuradio-core/src/lib/gengen/gr_xor_XX.i.t deleted file mode 100644 index 06db5ca59d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_xor_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 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@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (); -}; diff --git a/gnuradio-core/src/lib/io/gr_pdu.cc b/gnuradio-core/src/lib/io/gr_pdu.cc index c9202647d0..ab0e79e5ec 100644 --- a/gnuradio-core/src/lib/io/gr_pdu.cc +++ b/gnuradio-core/src/lib/io/gr_pdu.cc @@ -29,11 +29,11 @@ size_t gr_pdu_itemsize(gr_pdu_vector_type type){ switch(type){ - case BYTE: + case pdu_byte: return 1; - case FLOAT: + case pdu_float: return sizeof(float); - case COMPLEX: + case pdu_complex: return sizeof(gr_complex); default: throw std::runtime_error("bad type!"); diff --git a/gnuradio-core/src/lib/io/gr_pdu.h b/gnuradio-core/src/lib/io/gr_pdu.h index 5ed9cdded8..a5ae87db7f 100644 --- a/gnuradio-core/src/lib/io/gr_pdu.h +++ b/gnuradio-core/src/lib/io/gr_pdu.h @@ -29,7 +29,7 @@ #define pdu_port_id pmt::mp("pdus") #define pdu_length_tag pmt::mp("pdu_length") -enum gr_pdu_vector_type { BYTE, FLOAT, COMPLEX }; +enum gr_pdu_vector_type { pdu_byte, pdu_float, pdu_complex }; size_t gr_pdu_itemsize(gr_pdu_vector_type type); bool gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v); diff --git a/gnuradio-core/src/lib/io/gr_pdu.i b/gnuradio-core/src/lib/io/gr_pdu.i index 7cb3c62c78..ada3a63a73 100644 --- a/gnuradio-core/src/lib/io/gr_pdu.i +++ b/gnuradio-core/src/lib/io/gr_pdu.i @@ -24,7 +24,7 @@ #include <gr_pdu.h>
%}
-enum gr_pdu_vector_type { BYTE, FLOAT, COMPLEX };
+enum gr_pdu_vector_type { pdu_byte, pdu_float, pdu_complex };
diff --git a/gnuradio-core/src/lib/io/gr_socket_pdu.h b/gnuradio-core/src/lib/io/gr_socket_pdu.h index 4e58006028..c2b4dd248c 100644 --- a/gnuradio-core/src/lib/io/gr_socket_pdu.h +++ b/gnuradio-core/src/lib/io/gr_socket_pdu.h @@ -28,6 +28,7 @@ #include <gr_message.h> #include <gr_msg_queue.h> #include <gr_stream_pdu_base.h> +#include <boost/array.hpp> #include <boost/asio.hpp> class gr_socket_pdu; diff --git a/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc b/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc index 108424d393..0a0038ea25 100644 --- a/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc +++ b/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc @@ -24,6 +24,7 @@ #include "config.h" #endif +#include <ciso646> #include <gr_stream_pdu_base.h> #include <gr_io_signature.h> #include <cstdio> @@ -35,8 +36,13 @@ #include <string.h> #include <iostream> #include <gr_pdu.h> +#include <boost/asio.hpp> #include <boost/format.hpp> +#ifdef HAVE_IO_H +#include <io.h> +#endif + static const long timeout_us = 100*1000; //100ms gr_stream_pdu_base::gr_stream_pdu_base (int MTU) diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.h b/gnuradio-core/src/lib/runtime/gr_basic_block.h index 5e00a4f22a..55940e3c7f 100644 --- a/gnuradio-core/src/lib/runtime/gr_basic_block.h +++ b/gnuradio-core/src/lib/runtime/gr_basic_block.h @@ -148,9 +148,9 @@ class GR_CORE_API gr_basic_block : public gr_msg_accepter, public boost::enable_ void message_port_sub(pmt::pmt_t port_id, pmt::pmt_t target); void message_port_unsub(pmt::pmt_t port_id, pmt::pmt_t target); - virtual bool message_port_is_hier(pmt::pmt_t port_id) { std::cout << "is_hier\n"; return false; } - virtual bool message_port_is_hier_in(pmt::pmt_t port_id) { std::cout << "is_hier_in\n"; return false; } - virtual bool message_port_is_hier_out(pmt::pmt_t port_id) { std::cout << "is_hier_out\n"; return false; } + virtual bool message_port_is_hier(pmt::pmt_t port_id) { (void) port_id; std::cout << "is_hier\n"; return false; } + virtual bool message_port_is_hier_in(pmt::pmt_t port_id) { (void) port_id; std::cout << "is_hier_in\n"; return false; } + virtual bool message_port_is_hier_out(pmt::pmt_t port_id) { (void) port_id; std::cout << "is_hier_out\n"; return false; } /*! * \brief Get input message port names. @@ -258,7 +258,7 @@ class GR_CORE_API gr_basic_block : public gr_msg_accepter, public boost::enable_ * This check is in addition to the constraints specified by the input * and output gr_io_signatures. */ - virtual bool check_topology(int ninputs, int noutputs) { return true; } + virtual bool check_topology(int ninputs, int noutputs) { (void) ninputs; (void) noutputs; return true; } /*! * \brief Set the callback that is fired when messages are available. diff --git a/gnuradio-core/src/lib/runtime/gr_complex.h b/gnuradio-core/src/lib/runtime/gr_complex.h index 7580021064..58d1525b4d 100644 --- a/gnuradio-core/src/lib/runtime/gr_complex.h +++ b/gnuradio-core/src/lib/runtime/gr_complex.h @@ -27,13 +27,13 @@ typedef std::complex<float> gr_complex; typedef std::complex<double> gr_complexd; -inline bool is_complex (gr_complex x) { return true;} -inline bool is_complex (gr_complexd x) { return true;} -inline bool is_complex (float x) { return false;} -inline bool is_complex (double x) { return false;} -inline bool is_complex (int x) { return false;} -inline bool is_complex (char x) { return false;} -inline bool is_complex (short x) { return false;} +inline bool is_complex (gr_complex x) { (void) x; return true;} +inline bool is_complex (gr_complexd x) { (void) x; return true;} +inline bool is_complex (float x) { (void) x; return false;} +inline bool is_complex (double x) { (void) x; return false;} +inline bool is_complex (int x) { (void) x; return false;} +inline bool is_complex (char x) { (void) x; return false;} +inline bool is_complex (short x) { (void) x; return false;} // this doesn't really belong here, but there are worse places for it... diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.cc b/gnuradio-core/src/lib/runtime/qa_block_tags.cc index d6b1065e32..8cc1b49b3c 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.cc +++ b/gnuradio-core/src/lib/runtime/qa_block_tags.cc @@ -31,7 +31,7 @@ #include <gr_head.h> #include <gr_annotator_alltoall.h> #include <gr_annotator_1to1.h> -#include <gr_keep_one_in_n.h> +//#include <gr_keep_one_in_n.h> #include <gr_firdes.h> #include <gr_tags.h> @@ -370,6 +370,7 @@ qa_block_tags::t4 () } +/* void qa_block_tags::t5 () { @@ -447,4 +448,4 @@ qa_block_tags::t5 () } #endif } - +*/ diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.h b/gnuradio-core/src/lib/runtime/qa_block_tags.h index 6b7e5975d1..039d345cdf 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.h +++ b/gnuradio-core/src/lib/runtime/qa_block_tags.h @@ -35,7 +35,7 @@ class qa_block_tags : public CppUnit::TestCase { CPPUNIT_TEST (t2); CPPUNIT_TEST (t3); CPPUNIT_TEST (t4); - CPPUNIT_TEST (t5); + //CPPUNIT_TEST (t5); CPPUNIT_TEST_SUITE_END (); private: @@ -44,7 +44,7 @@ class qa_block_tags : public CppUnit::TestCase { void t2 (); void t3 (); void t4 (); - void t5 (); + //void t5 (); }; diff --git a/gnuradio-core/src/python/gnuradio/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/CMakeLists.txt index 0acb893538..9b75f20f33 100644 --- a/gnuradio-core/src/python/gnuradio/CMakeLists.txt +++ b/gnuradio-core/src/python/gnuradio/CMakeLists.txt @@ -22,8 +22,6 @@ include(GrPython) add_subdirectory(gr) add_subdirectory(gru) add_subdirectory(gruimpl) -add_subdirectory(blks2) -add_subdirectory(blks2impl) if(ENABLE_GR_CTRLPORT) add_subdirectory(ctrlport) @@ -35,8 +33,6 @@ GR_PYTHON_INSTALL(FILES eng_option.py gr_unittest.py gr_xmlrunner.py - optfir.py - window.py DESTINATION ${GR_PYTHON_DIR}/gnuradio COMPONENT "core_python" ) diff --git a/gnuradio-core/src/python/gnuradio/blks2/__init__.py b/gnuradio-core/src/python/gnuradio/blks2/__init__.py deleted file mode 100644 index 1d3203ec79..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2/__init__.py +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright 2005 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. -# -""" -Miscellaneous contents implemented in python. -""" - -import glob -import os.path - -# Semi-hideous kludge to import everything in the blksimpl2 directory -# into the gnuradio.blks2 namespace. This keeps us from having to remember -# to manually update this file. - -for p in __path__: - filenames = glob.glob (os.path.join (p, "..", "blks2impl", "*.py")) - for f in filenames: - f = os.path.basename(f).lower() - f = f[:-3] - if f == '__init__': - continue - # print f - exec "from gnuradio.blks2impl.%s import *" % (f,) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt deleted file mode 100644 index dae287ca3a..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2010-2012 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. - -include(GrPython) - -GR_PYTHON_INSTALL(FILES - __init__.py - filterbank.py - rational_resampler.py - stream_to_vector_decimator.py - DESTINATION ${GR_PYTHON_DIR}/gnuradio/blks2impl - COMPONENT "core_python" -) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/__init__.py b/gnuradio-core/src/python/gnuradio/blks2impl/__init__.py deleted file mode 100644 index a4917cf64c..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# make this a package diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/rational_resampler.py b/gnuradio-core/src/python/gnuradio/blks2impl/rational_resampler.py deleted file mode 100644 index 33b5b0b1f3..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/rational_resampler.py +++ /dev/null @@ -1,127 +0,0 @@ -# -# Copyright 2005,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 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, gru, filter - -_plot = None - -def design_filter(interpolation, decimation, fractional_bw): - """ - Given the interpolation rate, decimation rate and a fractional bandwidth, - design a set of taps. - - Args: - interpolation: interpolation factor (integer > 0) - decimation: decimation factor (integer > 0) - fractional_bw: fractional bandwidth in (0, 0.5) 0.4 works well. (float) - Returns: - : sequence of numbers - """ - - if fractional_bw >= 0.5 or fractional_bw <= 0: - raise ValueError, "Invalid fractional_bandwidth, must be in (0, 0.5)" - - beta = 5.0 - trans_width = 0.5 - fractional_bw - mid_transition_band = 0.5 - trans_width/2 - - taps = gr.firdes.low_pass(interpolation, # gain - 1, # Fs - mid_transition_band/interpolation, # trans mid point - trans_width/interpolation, # transition width - gr.firdes.WIN_KAISER, - beta # beta - ) - - return taps - - - -class _rational_resampler_base(gr.hier_block2): - """ - base class for all rational resampler variants. - """ - def __init__(self, resampler_base, - interpolation, decimation, taps=None, fractional_bw=None): - """ - Rational resampling polyphase FIR filter. - - Either taps or fractional_bw may be specified, but not both. - If neither is specified, a reasonable default, 0.4, is used as - the fractional_bw. - - Args: - interpolation: interpolation factor (integer > 0) - decimation: decimation factor (integer > 0) - taps: optional filter coefficients (sequence) - fractional_bw: fractional bandwidth in (0, 0.5), measured at final freq (use 0.4) (float) - """ - - if not isinstance(interpolation, int) or interpolation < 1: - raise ValueError, "interpolation must be an integer >= 1" - - if not isinstance(decimation, int) or decimation < 1: - raise ValueError, "decimation must be an integer >= 1" - - if taps is None and fractional_bw is None: - fractional_bw = 0.4 - - d = gru.gcd(interpolation, decimation) - interpolation = interpolation // d - decimation = decimation // d - - if taps is None: - taps = design_filter(interpolation, decimation, fractional_bw) - - resampler = resampler_base(interpolation, decimation, taps) - gr.hier_block2.__init__(self, "rational_resampler", - gr.io_signature(1, 1, resampler.input_signature().sizeof_stream_item(0)), - gr.io_signature(1, 1, resampler.output_signature().sizeof_stream_item(0))) - - self.connect(self, resampler, self) - - -class rational_resampler_fff(_rational_resampler_base): - def __init__(self, interpolation, decimation, taps=None, fractional_bw=None): - """ - Rational resampling polyphase FIR filter with - float input, float output and float taps. - """ - _rational_resampler_base.__init__(self, filter.rational_resampler_base_fff, - interpolation, decimation, taps, fractional_bw) - -class rational_resampler_ccf(_rational_resampler_base): - def __init__(self, interpolation, decimation, taps=None, fractional_bw=None): - """ - Rational resampling polyphase FIR filter with - complex input, complex output and float taps. - """ - _rational_resampler_base.__init__(self, filter.rational_resampler_base_ccf, - interpolation, decimation, taps, fractional_bw) - -class rational_resampler_ccc(_rational_resampler_base): - def __init__(self, interpolation, decimation, taps=None, fractional_bw=None): - """ - Rational resampling polyphase FIR filter with - complex input, complex output and complex taps. - """ - _rational_resampler_base.__init__(self, filter.rational_resampler_base_ccc, - interpolation, decimation, taps, fractional_bw) diff --git a/gnuradio-core/src/python/gnuradio/gr/__init__.py b/gnuradio-core/src/python/gnuradio/gr/__init__.py index 3ece4b2676..2735f500fb 100644 --- a/gnuradio-core/src/python/gnuradio/gr/__init__.py +++ b/gnuradio-core/src/python/gnuradio/gr/__init__.py @@ -34,19 +34,5 @@ from hier_block2 import * from top_block import * from gateway import basic_block, sync_block, decim_block, interp_block -# create a couple of aliases -serial_to_parallel = stream_to_vector -parallel_to_serial = vector_to_stream - # Force the preference database to be initialized from prefs import prefs - -#alias old gr_add_vXX and gr_multiply_vXX -add_vcc = add_cc -add_vff = add_ff -add_vii = add_ii -add_vss = add_ss -multiply_vcc = multiply_cc -multiply_vff = multiply_ff -multiply_vii = multiply_ii -multiply_vss = multiply_ss diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_add_and_friends.py b/gnuradio-core/src/python/gnuradio/gr/qa_add_and_friends.py deleted file mode 100755 index 7ccbbe8ad4..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_add_and_friends.py +++ /dev/null @@ -1,163 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 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 - -class test_add_and_friends (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def help_ii (self, src_data, exp_data, op): - for s in zip (range (len (src_data)), src_data): - src = gr.vector_source_i (s[1]) - self.tb.connect (src, (op, s[0])) - dst = gr.vector_sink_i () - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (exp_data, result_data) - - def help_ff (self, src_data, exp_data, op): - for s in zip (range (len (src_data)), src_data): - src = gr.vector_source_f (s[1]) - self.tb.connect (src, (op, s[0])) - dst = gr.vector_sink_f () - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (exp_data, result_data) - - def help_cc (self, src_data, exp_data, op): - for s in zip (range (len (src_data)), src_data): - src = gr.vector_source_c (s[1]) - self.tb.connect (src, (op, s[0])) - dst = gr.vector_sink_c () - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (exp_data, result_data) - - def test_add_const_ii (self): - src_data = (1, 2, 3, 4, 5) - expected_result = (6, 7, 8, 9, 10) - op = gr.add_const_ii (5) - self.help_ii ((src_data,), expected_result, op) - - def test_add_const_cc (self): - src_data = (1, 2, 3, 4, 5) - expected_result = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j) - op = gr.add_const_cc (5j) - self.help_cc ((src_data,), expected_result, op) - - def test_mult_const_ii (self): - src_data = (-1, 0, 1, 2, 3) - expected_result = (-5, 0, 5, 10, 15) - op = gr.multiply_const_ii (5) - self.help_ii ((src_data,), expected_result, op) - - def test_mult_const_ff (self): - src_data = (-1, 0, 1, 2, 3) - expected_result = (-5, 0, 5, 10, 15) - op = gr.multiply_const_cc (5) - self.help_cc ((src_data,), expected_result, op) - - def test_mult_const_cc (self): - src_data = (-1-1j, 0+0j, 1+1j, 2+2j, 3+3j) - expected_result = (-5-5j, 0+0j, 5+5j, 10+10j, 15+15j) - op = gr.multiply_const_cc (5) - self.help_cc ((src_data,), expected_result, op) - - def test_mult_const_cc2 (self): - src_data = (-1-1j, 0+0j, 1+1j, 2+2j, 3+3j) - expected_result = (-3-7j, 0+0j, 3+7j, 6+14j, 9+21j) - op = gr.multiply_const_cc (5+2j) - self.help_cc ((src_data,), expected_result, op) - - def test_add_ii (self): - src1_data = (1, 2, 3, 4, 5) - src2_data = (8, -3, 4, 8, 2) - expected_result = (9, -1, 7, 12, 7) - op = gr.add_ii () - self.help_ii ((src1_data, src2_data), - expected_result, op) - - def test_mult_ii (self): - src1_data = (1, 2, 3, 4, 5) - src2_data = (8, -3, 4, 8, 2) - expected_result = (8, -6, 12, 32, 10) - op = gr.multiply_ii () - self.help_ii ((src1_data, src2_data), - expected_result, op) - - def test_mult_ff (self): - src1_data = (1, 2, 3, 4, 5) - src2_data = (8, -3, 4, 8, 2) - expected_result = (8, -6, 12, 32, 10) - op = gr.multiply_ff () - self.help_ff ((src1_data, src2_data), - expected_result, op) - - def test_mult_cc (self): - src1_data = (1+1j, 2+2j, 3+3j, 4+4j, 5+5j) - src2_data = (8, -3, 4, 8, 2) - expected_result = (8+8j, -6-6j, 12+12j, 32+32j, 10+10j) - op = gr.multiply_cc () - self.help_cc ((src1_data, src2_data), - expected_result, op) - - def test_sub_ii_1 (self): - src1_data = (1, 2, 3, 4, 5) - expected_result = (-1, -2, -3, -4, -5) - op = gr.sub_ii () - self.help_ii ((src1_data,), - expected_result, op) - - def test_sub_ii_2 (self): - src1_data = (1, 2, 3, 4, 5) - src2_data = (8, -3, 4, 8, 2) - expected_result = (-7, 5, -1, -4, 3) - op = gr.sub_ii () - self.help_ii ((src1_data, src2_data), - expected_result, op) - - def test_div_ff_1 (self): - src1_data = (1, 2, 4, -8) - expected_result = (1, 0.5, 0.25, -.125) - op = gr.divide_ff () - self.help_ff ((src1_data,), - expected_result, op) - - def test_div_ff_2 (self): - src1_data = ( 5, 9, -15, 1024) - src2_data = (10, 3, -5, 64) - expected_result = (0.5, 3, 3, 16) - op = gr.divide_ff () - self.help_ff ((src1_data, src2_data), - expected_result, op) - - -if __name__ == '__main__': - gr_unittest.run(test_add_and_friends, "test_add_and_friends.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_add_v_and_friends.py b/gnuradio-core/src/python/gnuradio/gr/qa_add_v_and_friends.py deleted file mode 100755 index c8df47b392..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_add_v_and_friends.py +++ /dev/null @@ -1,353 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 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 - -class test_add_v_and_friends(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def help_ss(self, size, src_data, exp_data, op): - for s in zip(range (len (src_data)), src_data): - src = gr.vector_source_s(s[1]) - srcv = gr.stream_to_vector(gr.sizeof_short, size) - self.tb.connect(src, srcv) - self.tb.connect(srcv, (op, s[0])) - rhs = gr.vector_to_stream(gr.sizeof_short, size) - dst = gr.vector_sink_s() - self.tb.connect(op, rhs, dst) - self.tb.run() - result_data = dst.data() - self.assertEqual(exp_data, result_data) - - def help_ii(self, size, src_data, exp_data, op): - for s in zip(range (len (src_data)), src_data): - src = gr.vector_source_i(s[1]) - srcv = gr.stream_to_vector(gr.sizeof_int, size) - self.tb.connect(src, srcv) - self.tb.connect(srcv, (op, s[0])) - rhs = gr.vector_to_stream(gr.sizeof_int, size) - dst = gr.vector_sink_i() - self.tb.connect(op, rhs, dst) - self.tb.run() - result_data = dst.data() - self.assertEqual(exp_data, result_data) - - def help_ff(self, size, src_data, exp_data, op): - for s in zip(range (len (src_data)), src_data): - src = gr.vector_source_f(s[1]) - srcv = gr.stream_to_vector(gr.sizeof_float, size) - self.tb.connect(src, srcv) - self.tb.connect(srcv, (op, s[0])) - rhs = gr.vector_to_stream(gr.sizeof_float, size) - dst = gr.vector_sink_f() - self.tb.connect(op, rhs, dst) - self.tb.run() - result_data = dst.data() - self.assertEqual(exp_data, result_data) - - def help_cc(self, size, src_data, exp_data, op): - for s in zip(range (len (src_data)), src_data): - src = gr.vector_source_c(s[1]) - srcv = gr.stream_to_vector(gr.sizeof_gr_complex, size) - self.tb.connect(src, srcv) - self.tb.connect(srcv, (op, s[0])) - rhs = gr.vector_to_stream(gr.sizeof_gr_complex, size) - dst = gr.vector_sink_c() - self.tb.connect(op, rhs, dst) - self.tb.run() - result_data = dst.data() - self.assertEqual(exp_data, result_data) - - def help_const_ss(self, src_data, exp_data, op): - src = gr.vector_source_s(src_data) - srcv = gr.stream_to_vector(gr.sizeof_short, len(src_data)) - rhs = gr.vector_to_stream(gr.sizeof_short, len(src_data)) - dst = gr.vector_sink_s() - self.tb.connect(src, srcv, op, rhs, dst) - self.tb.run() - result_data = dst.data() - self.assertEqual(exp_data, result_data) - - def help_const_ii(self, src_data, exp_data, op): - src = gr.vector_source_i(src_data) - srcv = gr.stream_to_vector(gr.sizeof_int, len(src_data)) - rhs = gr.vector_to_stream(gr.sizeof_int, len(src_data)) - dst = gr.vector_sink_i() - self.tb.connect(src, srcv, op, rhs, dst) - self.tb.run() - result_data = dst.data() - self.assertEqual(exp_data, result_data) - - def help_const_ff(self, src_data, exp_data, op): - src = gr.vector_source_f(src_data) - srcv = gr.stream_to_vector(gr.sizeof_float, len(src_data)) - rhs = gr.vector_to_stream(gr.sizeof_float, len(src_data)) - dst = gr.vector_sink_f() - self.tb.connect(src, srcv, op, rhs, dst) - self.tb.run() - result_data = dst.data() - self.assertEqual(exp_data, result_data) - - def help_const_cc(self, src_data, exp_data, op): - src = gr.vector_source_c(src_data) - srcv = gr.stream_to_vector(gr.sizeof_gr_complex, len(src_data)) - rhs = gr.vector_to_stream(gr.sizeof_gr_complex, len(src_data)) - dst = gr.vector_sink_c() - self.tb.connect(src, srcv, op, rhs, dst) - self.tb.run() - result_data = dst.data() - self.assertEqual(exp_data, result_data) - - - def test_add_vss_one(self): - src1_data = (1,) - src2_data = (2,) - src3_data = (3,) - expected_result = (6,) - op = gr.add_vss(1) - self.help_ss(1, (src1_data, src2_data, src3_data), expected_result, op) - - def test_add_vss_five(self): - src1_data = (1, 2, 3, 4, 5) - src2_data = (6, 7, 8, 9, 10) - src3_data = (11, 12, 13, 14, 15) - expected_result = (18, 21, 24, 27, 30) - op = gr.add_vss(5) - self.help_ss(5, (src1_data, src2_data, src3_data), expected_result, op) - - def test_add_vii_one(self): - src1_data = (1,) - src2_data = (2,) - src3_data = (3,) - expected_result = (6,) - op = gr.add_vii(1) - self.help_ii(1, (src1_data, src2_data, src3_data), expected_result, op) - - def test_add_vii_five(self): - src1_data = (1, 2, 3, 4, 5) - src2_data = (6, 7, 8, 9, 10) - src3_data = (11, 12, 13, 14, 15) - expected_result = (18, 21, 24, 27, 30) - op = gr.add_vii(5) - self.help_ii(5, (src1_data, src2_data, src3_data), expected_result, op) - - def test_add_vff_one(self): - src1_data = (1.0,) - src2_data = (2.0,) - src3_data = (3.0,) - expected_result = (6.0,) - op = gr.add_vff(1) - self.help_ff(1, (src1_data, src2_data, src3_data), expected_result, op) - - def test_add_vff_five(self): - src1_data = (1.0, 2.0, 3.0, 4.0, 5.0) - src2_data = (6.0, 7.0, 8.0, 9.0, 10.0) - src3_data = (11.0, 12.0, 13.0, 14.0, 15.0) - expected_result = (18.0, 21.0, 24.0, 27.0, 30.0) - op = gr.add_vff(5) - self.help_ff(5, (src1_data, src2_data, src3_data), expected_result, op) - - def test_add_vcc_one(self): - src1_data = (1.0+2.0j,) - src2_data = (3.0+4.0j,) - src3_data = (5.0+6.0j,) - expected_result = (9.0+12j,) - op = gr.add_vcc(1) - self.help_cc(1, (src1_data, src2_data, src3_data), expected_result, op) - - def test_add_vcc_five(self): - src1_data = (1.0+2.0j, 3.0+4.0j, 5.0+6.0j, 7.0+8.0j, 9.0+10.0j) - src2_data = (11.0+12.0j, 13.0+14.0j, 15.0+16.0j, 17.0+18.0j, 19.0+20.0j) - src3_data = (21.0+22.0j, 23.0+24.0j, 25.0+26.0j, 27.0+28.0j, 29.0+30.0j) - expected_result = (33.0+36.0j, 39.0+42.0j, 45.0+48.0j, 51.0+54.0j, 57.0+60.0j) - op = gr.add_vcc(5) - self.help_cc(5, (src1_data, src2_data, src3_data), expected_result, op) - - def test_add_const_vss_one(self): - src_data = (1,) - op = gr.add_const_vss((2,)) - exp_data = (3,) - self.help_const_ss(src_data, exp_data, op) - - def test_add_const_vss_five(self): - src_data = (1, 2, 3, 4, 5) - op = gr.add_const_vss((6, 7, 8, 9, 10)) - exp_data = (7, 9, 11, 13, 15) - self.help_const_ss(src_data, exp_data, op) - - def test_add_const_vii_one(self): - src_data = (1,) - op = gr.add_const_vii((2,)) - exp_data = (3,) - self.help_const_ii(src_data, exp_data, op) - - def test_add_const_vii_five(self): - src_data = (1, 2, 3, 4, 5) - op = gr.add_const_vii((6, 7, 8, 9, 10)) - exp_data = (7, 9, 11, 13, 15) - self.help_const_ii(src_data, exp_data, op) - - def test_add_const_vff_one(self): - src_data = (1.0,) - op = gr.add_const_vff((2.0,)) - exp_data = (3.0,) - self.help_const_ff(src_data, exp_data, op) - - def test_add_const_vff_five(self): - src_data = (1.0, 2.0, 3.0, 4.0, 5.0) - op = gr.add_const_vff((6.0, 7.0, 8.0, 9.0, 10.0)) - exp_data = (7.0, 9.0, 11.0, 13.0, 15.0) - self.help_const_ff(src_data, exp_data, op) - - def test_add_const_vcc_one(self): - src_data = (1.0+2.0j,) - op = gr.add_const_vcc((2.0+3.0j,)) - exp_data = (3.0+5.0j,) - self.help_const_cc(src_data, exp_data, op) - - def test_add_const_vcc_five(self): - src_data = (1.0+2.0j, 3.0+4.0j, 5.0+6.0j, 7.0+8.0j, 9.0+10.0j) - op = gr.add_const_vcc((11.0+12.0j, 13.0+14.0j, 15.0+16.0j, 17.0+18.0j, 19.0+20.0j)) - exp_data = (12.0+14.0j, 16.0+18.0j, 20.0+22.0j, 24.0+26.0j, 28.0+30.0j) - self.help_const_cc(src_data, exp_data, op) - - - def test_multiply_vss_one(self): - src1_data = (1,) - src2_data = (2,) - src3_data = (3,) - expected_result = (6,) - op = gr.multiply_vss(1) - self.help_ss(1, (src1_data, src2_data, src3_data), expected_result, op) - - def test_multiply_vss_five(self): - src1_data = (1, 2, 3, 4, 5) - src2_data = (6, 7, 8, 9, 10) - src3_data = (11, 12, 13, 14, 15) - expected_result = (66, 168, 312, 504, 750) - op = gr.multiply_vss(5) - self.help_ss(5, (src1_data, src2_data, src3_data), expected_result, op) - - def test_multiply_vii_one(self): - src1_data = (1,) - src2_data = (2,) - src3_data = (3,) - expected_result = (6,) - op = gr.multiply_vii(1) - self.help_ii(1, (src1_data, src2_data, src3_data), expected_result, op) - - def test_multiply_vii_five(self): - src1_data = (1, 2, 3, 4, 5) - src2_data = (6, 7, 8, 9, 10) - src3_data = (11, 12, 13, 14, 15) - expected_result = (66, 168, 312, 504, 750) - op = gr.multiply_vii(5) - self.help_ii(5, (src1_data, src2_data, src3_data), expected_result, op) - - def test_multiply_vff_one(self): - src1_data = (1.0,) - src2_data = (2.0,) - src3_data = (3.0,) - expected_result = (6.0,) - op = gr.multiply_vff(1) - self.help_ff(1, (src1_data, src2_data, src3_data), expected_result, op) - - def test_multiply_vff_five(self): - src1_data = (1.0, 2.0, 3.0, 4.0, 5.0) - src2_data = (6.0, 7.0, 8.0, 9.0, 10.0) - src3_data = (11.0, 12.0, 13.0, 14.0, 15.0) - expected_result = (66.0, 168.0, 312.0, 504.0, 750.0) - op = gr.multiply_vff(5) - self.help_ff(5, (src1_data, src2_data, src3_data), expected_result, op) - - def test_multiply_vcc_one(self): - src1_data = (1.0+2.0j,) - src2_data = (3.0+4.0j,) - src3_data = (5.0+6.0j,) - expected_result = (-85+20j,) - op = gr.multiply_vcc(1) - self.help_cc(1, (src1_data, src2_data, src3_data), expected_result, op) - - def test_multiply_vcc_five(self): - src1_data = (1.0+2.0j, 3.0+4.0j, 5.0+6.0j, 7.0+8.0j, 9.0+10.0j) - src2_data = (11.0+12.0j, 13.0+14.0j, 15.0+16.0j, 17.0+18.0j, 19.0+20.0j) - src3_data = (21.0+22.0j, 23.0+24.0j, 25.0+26.0j, 27.0+28.0j, 29.0+30.0j) - expected_result = (-1021.0+428.0j, -2647.0+1754.0j, -4945.0+3704.0j, -8011.0+6374.0j, -11941.0+9860.0j) - op = gr.multiply_vcc(5) - self.help_cc(5, (src1_data, src2_data, src3_data), expected_result, op) - - def test_multiply_const_vss_one(self): - src_data = (2,) - op = gr.multiply_const_vss((3,)) - exp_data = (6,) - self.help_const_ss(src_data, exp_data, op) - - def test_multiply_const_vss_five(self): - src_data = (1, 2, 3, 4, 5) - op = gr.multiply_const_vss((6, 7, 8, 9, 10)) - exp_data = (6, 14, 24, 36, 50) - self.help_const_ss(src_data, exp_data, op) - - def test_multiply_const_vii_one(self): - src_data = (2,) - op = gr.multiply_const_vii((3,)) - exp_data = (6,) - self.help_const_ii(src_data, exp_data, op) - - def test_multiply_const_vii_five(self): - src_data = (1, 2, 3, 4, 5) - op = gr.multiply_const_vii((6, 7, 8, 9, 10)) - exp_data = (6, 14, 24, 36, 50) - self.help_const_ii(src_data, exp_data, op) - - def test_multiply_const_vff_one(self): - src_data = (2.0,) - op = gr.multiply_const_vff((3.0,)) - exp_data = (6.0,) - self.help_const_ff(src_data, exp_data, op) - - def test_multiply_const_vff_five(self): - src_data = (1.0, 2.0, 3.0, 4.0, 5.0) - op = gr.multiply_const_vff((6.0, 7.0, 8.0, 9.0, 10.0)) - exp_data = (6.0, 14.0, 24.0, 36.0, 50.0) - self.help_const_ff(src_data, exp_data, op) - - def test_multiply_const_vcc_one(self): - src_data = (1.0+2.0j,) - op = gr.multiply_const_vcc((2.0+3.0j,)) - exp_data = (-4.0+7.0j,) - self.help_const_cc(src_data, exp_data, op) - - def test_multiply_const_vcc_five(self): - src_data = (1.0+2.0j, 3.0+4.0j, 5.0+6.0j, 7.0+8.0j, 9.0+10.0j) - op = gr.multiply_const_vcc((11.0+12.0j, 13.0+14.0j, 15.0+16.0j, 17.0+18.0j, 19.0+20.0j)) - exp_data = (-13.0+34.0j, -17.0+94.0j, -21.0+170.0j, -25.0+262.0j, -29.0+370.0j) - self.help_const_cc(src_data, exp_data, op) - - -if __name__ == '__main__': - gr_unittest.run(test_add_v_and_friends, "test_add_v_and_friends.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_block_gateway.py b/gnuradio-core/src/python/gnuradio/gr/qa_block_gateway.py index 5018e1e0db..2c8cba5439 100644 --- a/gnuradio-core/src/python/gnuradio/gr/qa_block_gateway.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_block_gateway.py @@ -158,6 +158,26 @@ class fc32_to_f32_2(gr.sync_block): output_items[0][::,1] = numpy.imag(input_items[0]) return len(output_items[0]) +class vector_to_stream(gr.interp_block): + def __init__(self, itemsize, nitems_per_block): + gr.interp_block.__init__( + self, + name = "vector_to_stream", + in_sig = [(itemsize, nitems_per_block)], + out_sig = [itemsize], + interp = nitems_per_block + ) + self.block_size = nitems_per_block + + def work(self, input_items, output_items): + n = 0 + for i in xrange(len(input_items[0])): + for j in xrange(self.block_size): + output_items[0][n] = input_items[0][i][j] + n += 1 + + return len(output_items[0]) + class test_block_gateway(gr_unittest.TestCase): def test_add_f32(self): @@ -224,7 +244,7 @@ class test_block_gateway(gr_unittest.TestCase): tb = gr.top_block() src = gr.vector_source_c([1+2j, 3+4j, 5+6j, 7+8j, 9+10j], False) convert = fc32_to_f32_2() - v2s = gr.vector_to_stream(gr.sizeof_float, 2) + v2s = vector_to_stream(numpy.float32, 2) sink = gr.vector_sink_f() tb.connect(src, convert, v2s, sink) tb.run() diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_boolean_operators.py b/gnuradio-core/src/python/gnuradio/gr/qa_boolean_operators.py deleted file mode 100755 index d7d134dcbe..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_boolean_operators.py +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2008,2010 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 - -class test_boolean_operators (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def help_ss (self, src_data, exp_data, op): - for s in zip (range (len (src_data)), src_data): - src = gr.vector_source_s (s[1]) - self.tb.connect (src, (op, s[0])) - dst = gr.vector_sink_s () - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (exp_data, result_data) - - def help_bb (self, src_data, exp_data, op): - for s in zip (range (len (src_data)), src_data): - src = gr.vector_source_b (s[1]) - self.tb.connect (src, (op, s[0])) - dst = gr.vector_sink_b () - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (exp_data, result_data) - - def help_ii (self, src_data, exp_data, op): - for s in zip (range (len (src_data)), src_data): - src = gr.vector_source_i (s[1]) - self.tb.connect (src, (op, s[0])) - dst = gr.vector_sink_i () - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (exp_data, result_data) - - def test_xor_ss (self): - src1_data = (1, 2, 3, 0x5004, 0x1150) - src2_data = (8, 2, 1 , 0x0508, 0x1105) - expected_result = (9, 0, 2, 0x550C, 0x0055) - op = gr.xor_ss () - self.help_ss ((src1_data, src2_data), - expected_result, op) - - def test_xor_bb (self): - src1_data = (1, 2, 3, 4, 0x50) - src2_data = (8, 2, 1 , 8, 0x05) - expected_result = (9, 0, 2, 0xC, 0x55) - op = gr.xor_bb () - self.help_bb ((src1_data, src2_data), - expected_result, op) - - - def test_xor_ii (self): - src1_data = (1, 2, 3, 0x5000004, 0x11000050) - src2_data = (8, 2, 1 , 0x0500008, 0x11000005) - expected_result = (9, 0, 2, 0x550000C, 0x00000055) - op = gr.xor_ii () - self.help_ii ((src1_data, src2_data), - expected_result, op) - - def test_and_ss (self): - src1_data = (1, 2, 3, 0x5004, 0x1150) - src2_data = (8, 2, 1 , 0x0508, 0x1105) - expected_result = (0, 2, 1, 0x0000, 0x1100) - op = gr.and_ss () - self.help_ss ((src1_data, src2_data), - expected_result, op) - - def test_and_bb (self): - src1_data = (1, 2, 2, 3, 0x04, 0x50) - src2_data = (8, 2, 2, 1, 0x08, 0x05) - src3_data = (8, 2, 1, 1, 0x08, 0x05) - expected_result = (0, 2, 0, 1, 0x00, 0x00) - op = gr.and_bb () - self.help_bb ((src1_data, src2_data, src3_data), - expected_result, op) - - def test_and_ii (self): - src1_data = (1, 2, 3, 0x50005004, 0x11001150) - src2_data = (8, 2, 1 , 0x05000508, 0x11001105) - expected_result = (0, 2, 1, 0x00000000, 0x11001100) - op = gr.and_ii () - self.help_ii ((src1_data, src2_data), - expected_result, op) - - def test_or_ss (self): - src1_data = (1, 2, 3, 0x5004, 0x1150) - src2_data = (8, 2, 1 , 0x0508, 0x1105) - expected_result = (9, 2, 3, 0x550C, 0x1155) - op = gr.or_ss () - self.help_ss ((src1_data, src2_data), - expected_result, op) - - def test_or_bb (self): - src1_data = (1, 2, 2, 3, 0x04, 0x50) - src2_data = (8, 2, 2, 1 , 0x08, 0x05) - src3_data = (8, 2, 1, 1 , 0x08, 0x05) - expected_result = (9, 2, 3, 3, 0x0C, 0x55) - op = gr.or_bb () - self.help_bb ((src1_data, src2_data, src3_data), - expected_result, op) - - def test_or_ii (self): - src1_data = (1, 2, 3, 0x50005004, 0x11001150) - src2_data = (8, 2, 1 , 0x05000508, 0x11001105) - expected_result = (9, 2, 3, 0x5500550C, 0x11001155) - op = gr.or_ii () - self.help_ii ((src1_data, src2_data), - expected_result, op) - - def test_not_ss (self): - src1_data = (1, 2, 3, 0x5004, 0x1150) - expected_result = (~1, ~2, ~3, ~0x5004, ~0x1150) - op = gr.not_ss () - self.help_ss ((((src1_data),)), - expected_result, op) - - def test_not_bb (self): - src1_data = (1, 2, 2, 3, 0x04, 0x50) - expected_result = (0xFE, 0xFD, 0xFD, 0xFC, 0xFB, 0xAF) - op = gr.not_bb () - self.help_bb (((src1_data), ), - expected_result, op) - - def test_not_ii (self): - src1_data = (1, 2, 3, 0x50005004, 0x11001150) - expected_result = (~1 , ~2, ~3, ~0x50005004, ~0x11001150) - op = gr.not_ii () - self.help_ii (((src1_data),), - expected_result, op) - - - -if __name__ == '__main__': - gr_unittest.run(test_boolean_operators, "test_boolean_operators.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_conjugate.py b/gnuradio-core/src/python/gnuradio/gr/qa_conjugate.py deleted file mode 100644 index 17fa891e21..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_conjugate.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2012 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 - -class test_conjugate (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_000 (self): - src_data = (-2-2j, -1-1j, -2+2j, -1+1j, - 2-2j, 1-1j, 2+2j, 1+1j, - 0+0j) - - exp_data = (-2+2j, -1+1j, -2-2j, -1-1j, - 2+2j, 1+1j, 2-2j, 1-1j, - 0-0j) - - src = gr.vector_source_c(src_data) - op = gr.conjugate_cc () - dst = gr.vector_sink_c () - - self.tb.connect(src, op) - self.tb.connect(op, dst) - self.tb.run() - result_data = dst.data () - self.assertEqual (exp_data, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_conjugate, "test_conjugate.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_char.py b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_char.py deleted file mode 100755 index 057e297f91..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_char.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2011,2012 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 -class test_float_to_char (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - - src_data = (0.0, 1.1, 2.2, 3.3, 4.4, 5.5, -1.1, -2.2, -3.3) - expected_result = [0, 1, 2, 3, 4, 5, 255, 254, 253] - src = gr.vector_source_f(src_data) - op = gr.float_to_char() - dst = gr.vector_sink_b() - - self.tb.connect(src, op, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - - def test_002(self): - - src_data = ( 126.0, 127.0, 128.0) - expected_result = [ 126, 127, 127 ] - - src = gr.vector_source_f(src_data) - op = gr.float_to_char() - # Note: vector_sink_b returns uchar - dst = gr.vector_sink_b() - - self.tb.connect(src, op, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - - def test_003(self): - - scale = 2 - vlen = 3 - src_data = (0.0, 1.1, 2.2, 3.3, 4.4, 5.5, -1.1, -2.2, -3.3) - expected_result = [0, 2, 4, 6, 8, 11, 254, 252, 250] - src = gr.vector_source_f(src_data) - s2v = gr.stream_to_vector(gr.sizeof_float, vlen) - op = gr.float_to_char(vlen, scale) - v2s = gr.vector_to_stream(gr.sizeof_char, vlen) - dst = gr.vector_sink_b() - - self.tb.connect(src, s2v, op, v2s, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_float_to_char, "test_float_to_char.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py deleted file mode 100755 index 5c7a412d2c..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2011 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 - -class test_float_to_int (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - - src_data = (0.0, 1.1, 2.2, 3.3, 4.4, 5.5, -1.1, -2.2, -3.3, -4.4, -5.5) - expected_result = [0, 1, 2, 3, 4, 6, -1, -2, -3, -4, -6] - - src = gr.vector_source_f(src_data) - op = gr.float_to_int() - dst = gr.vector_sink_i() - - self.tb.connect(src, op, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - - def test_002(self): - - src_data = ( 2147483647, 2147483648, 2200000000, - -2147483648, -2147483649, -2200000000) - expected_result = [ 2147483647, 2147483647, 2147483647, - -2147483647, -2147483647, -2147483647] - src = gr.vector_source_f(src_data) - op = gr.float_to_int() - dst = gr.vector_sink_i() - - self.tb.connect(src, op, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - - - def test_003(self): - - scale = 2 - vlen = 3 - src_data = (0.0, 1.1, 2.2, 3.3, 4.4, 5.5, -1.1, -2.2, -3.3) - expected_result = [0, 2, 4, 7, 9, 11, -2, -4, -7,] - src = gr.vector_source_f(src_data) - s2v = gr.stream_to_vector(gr.sizeof_float, vlen) - op = gr.float_to_int(vlen, scale) - v2s = gr.vector_to_stream(gr.sizeof_int, vlen) - dst = gr.vector_sink_i() - - self.tb.connect(src, s2v, op, v2s, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_float_to_int, "test_float_to_int.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_short.py b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_short.py deleted file mode 100755 index 3f8b66975f..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_short.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2011,2012 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 -import ctypes - -class test_float_to_short (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - - src_data = (0.0, 1.1, 2.2, 3.3, 4.4, 5.5, -1.1, -2.2, -3.3, -4.4, -5.5) - expected_result = [0, 1, 2, 3, 4, 6, -1, -2, -3, -4, -6] - - src = gr.vector_source_f(src_data) - op = gr.float_to_short() - dst = gr.vector_sink_s() - - self.tb.connect(src, op, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - - def test_002(self): - - src_data = ( 32766, 32767, 32768, - -32767, -32768, -32769) - expected_result = [ 32766, 32767, 32767, - -32767, -32768, -32768 ] - - src = gr.vector_source_f(src_data) - op = gr.float_to_short() - dst = gr.vector_sink_s() - - self.tb.connect(src, op, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - - def test_003(self): - - scale = 2 - vlen = 3 - src_data = (0.0, 1.1, 2.2, 3.3, 4.4, 5.5, -1.1, -2.2, -3.3) - expected_result = [0, 2, 4, 7, 9, 11, -2, -4, -7] - src = gr.vector_source_f(src_data) - s2v = gr.stream_to_vector(gr.sizeof_float, vlen) - op = gr.float_to_short(vlen, scale) - v2s = gr.vector_to_stream(gr.sizeof_short, vlen) - dst = gr.vector_sink_s() - - self.tb.connect(src, s2v, op, v2s, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_float_to_short, "test_float_to_short.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_uchar.py b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_uchar.py deleted file mode 100755 index 831bed93ef..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_uchar.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2011 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 -import ctypes - -class test_float_to_uchar (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - - src_data = (0.0, 1.1, 2.2, 3.3, 4.4, 5.5, -1.1, -2.2, -3.3, -4.4, -5.5) - expected_result = [0, 1, 2, 3, 4, 6, 0, 0, 0, 0, 0] - src = gr.vector_source_f(src_data) - op = gr.float_to_uchar() - dst = gr.vector_sink_b() - - self.tb.connect(src, op, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - - def test_002(self): - - src_data = ( 254.0, 255.0, 256.0) - expected_result = [ 254, 255, 255 ] - src = gr.vector_source_f(src_data) - op = gr.float_to_uchar() - dst = gr.vector_sink_b() - - self.tb.connect(src, op, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_float_to_uchar, "test_float_to_uchar.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py b/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py index 3132d91b05..9ba48599af 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py @@ -1,6 +1,34 @@ #!/usr/bin/env python from gnuradio import gr, gr_unittest +import numpy + +class add_ff(gr.sync_block): + def __init__(self): + gr.sync_block.__init__( + self, + name = "add_ff", + in_sig = [numpy.float32, numpy.float32], + out_sig = [numpy.float32], + ) + + def work(self, input_items, output_items): + output_items[0][:] = input_items[0] + input_items[1] + return len(output_items[0]) + +class multiply_const_ff(gr.sync_block): + def __init__(self, k): + gr.sync_block.__init__( + self, + name = "multiply_ff", + in_sig = [numpy.float32], + out_sig = [numpy.float32], + ) + self.k = k + + def work(self, input_items, output_items): + output_items[0][:] = map(lambda x: self.k*x, input_items[0]) + return len(output_items[0]) class test_hier_block2(gr_unittest.TestCase): @@ -327,9 +355,9 @@ class test_hier_block2(gr_unittest.TestCase): hb = gr.hier_block2("hb", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float)) - m1 = gr.multiply_const_ff(1.0) - m2 = gr.multiply_const_ff(2.0) - add = gr.add_ff() + m1 = multiply_const_ff(1.0) + m2 = multiply_const_ff(2.0) + add = add_ff() hb.connect(hb, m1) # m1 is connected to hb external input #0 hb.connect(hb, m2) # m2 is also connected to hb external input #0 hb.connect(m1, (add, 0)) @@ -350,9 +378,9 @@ class test_hier_block2(gr_unittest.TestCase): gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float)) - m1 = gr.multiply_const_ff(1.0) - m2 = gr.multiply_const_ff(2.0) - add = gr.add_ff() + m1 = multiply_const_ff(1.0) + m2 = multiply_const_ff(2.0) + add = add_ff() hb2.connect(hb2, m1) # m1 is connected to hb2 external input #0 hb2.connect(hb2, m2) # m2 is also connected to hb2 external input #0 hb2.connect(m1, (add, 0)) diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_int_to_float.py b/gnuradio-core/src/python/gnuradio/gr/qa_int_to_float.py deleted file mode 100755 index 7536b3820a..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_int_to_float.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2011 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 - -class test_int_to_float (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - - src_data = (0, 1, 2, 3, 4, 5, -1, -2, -3, -4, -5) - expected_result = [float(s) for s in src_data] - src = gr.vector_source_i(src_data) - op = gr.int_to_float() - dst = gr.vector_sink_f() - - self.tb.connect(src, op, dst) - self.tb.run() - result_data = dst.data() - - self.assertFloatTuplesAlmostEqual(expected_result, result_data) - - def test_002(self): - - vlen = 3 - src_data = ( 65000, 65001, 65002, 65003, 65004, 65005, - -65001, -65002, -65003) - expected_result = [ 65000.0, 65001.0, 65002.0, - 65003.0, 65004.0, 65005.0, - -65001.0, -65002.0, -65003.0] - src = gr.vector_source_i(src_data) - s2v = gr.stream_to_vector(gr.sizeof_int, vlen) - op = gr.int_to_float(vlen) - v2s = gr.vector_to_stream(gr.sizeof_float, vlen) - dst = gr.vector_sink_f() - - self.tb.connect(src, s2v, op, v2s, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_int_to_float, "test_int_to_float.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_integrate.py b/gnuradio-core/src/python/gnuradio/gr/qa_integrate.py deleted file mode 100755 index ddb1310b69..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_integrate.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2008,2010 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 -import math - -class test_integrate (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_000_ss(self): - src_data = (1, 2, 3, 4, 5, 6) - dst_data = (6, 15) - src = gr.vector_source_s(src_data) - itg = gr.integrate_ss(3) - dst = gr.vector_sink_s() - self.tb.connect(src, itg, dst) - self.tb.run() - self.assertEqual(dst_data, dst.data()) - - def test_001_ii(self): - src_data = (1, 2, 3, 4, 5, 6) - dst_data = (6, 15) - src = gr.vector_source_i(src_data) - itg = gr.integrate_ii(3) - dst = gr.vector_sink_i() - self.tb.connect(src, itg, dst) - self.tb.run() - self.assertEqual(dst_data, dst.data()) - - def test_002_ff(self): - src_data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] - dst_data = [6.0, 15.0] - src = gr.vector_source_f(src_data) - itg = gr.integrate_ff(3) - dst = gr.vector_sink_f() - self.tb.connect(src, itg, dst) - self.tb.run() - self.assertFloatTuplesAlmostEqual(dst_data, dst.data(), 6) - - def test_003_cc(self): - src_data = [1.0+1.0j, 2.0+2.0j, 3.0+3.0j, 4.0+4.0j, 5.0+5.0j, 6.0+6.0j] - dst_data = [6.0+6.0j, 15.0+15.0j] - src = gr.vector_source_c(src_data) - itg = gr.integrate_cc(3) - dst = gr.vector_sink_c() - self.tb.connect(src, itg, dst) - self.tb.run() - self.assertComplexTuplesAlmostEqual(dst_data, dst.data(), 6) - -if __name__ == '__main__': - gr_unittest.run(test_integrate, "test_integrate.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_interleave.py b/gnuradio-core/src/python/gnuradio/gr/qa_interleave.py deleted file mode 100755 index 1ff1782519..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_interleave.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 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 -import math - -class test_interleave (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_int_001 (self): - lenx = 64 - src0 = gr.vector_source_f (range (0, lenx, 4)) - src1 = gr.vector_source_f (range (1, lenx, 4)) - src2 = gr.vector_source_f (range (2, lenx, 4)) - src3 = gr.vector_source_f (range (3, lenx, 4)) - op = gr.interleave (gr.sizeof_float) - dst = gr.vector_sink_f () - - self.tb.connect (src0, (op, 0)) - self.tb.connect (src1, (op, 1)) - self.tb.connect (src2, (op, 2)) - self.tb.connect (src3, (op, 3)) - self.tb.connect (op, dst) - self.tb.run () - expected_result = tuple (range (lenx)) - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_deint_001 (self): - lenx = 64 - src = gr.vector_source_f (range (lenx)) - op = gr.deinterleave (gr.sizeof_float) - dst0 = gr.vector_sink_f () - dst1 = gr.vector_sink_f () - dst2 = gr.vector_sink_f () - dst3 = gr.vector_sink_f () - - self.tb.connect (src, op) - self.tb.connect ((op, 0), dst0) - self.tb.connect ((op, 1), dst1) - self.tb.connect ((op, 2), dst2) - self.tb.connect ((op, 3), dst3) - self.tb.run () - - expected_result0 = tuple (range (0, lenx, 4)) - expected_result1 = tuple (range (1, lenx, 4)) - expected_result2 = tuple (range (2, lenx, 4)) - expected_result3 = tuple (range (3, lenx, 4)) - - self.assertFloatTuplesAlmostEqual (expected_result0, dst0.data ()) - self.assertFloatTuplesAlmostEqual (expected_result1, dst1.data ()) - self.assertFloatTuplesAlmostEqual (expected_result2, dst2.data ()) - self.assertFloatTuplesAlmostEqual (expected_result3, dst3.data ()) - -if __name__ == '__main__': - gr_unittest.run(test_interleave, "test_interleave.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_keep_m_in_n.py b/gnuradio-core/src/python/gnuradio/gr/qa_keep_m_in_n.py deleted file mode 100755 index 922671d024..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_keep_m_in_n.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2008,2010 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 this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -from gnuradio import gr, gr_unittest -import sys -import random - -class test_keep_m_in_n(gr_unittest.TestCase): - - def setUp(self): - pass - - def tearDown(self): - pass - - def test_001(self): - self.maxDiff = None; - tb = gr.top_block() - src = gr.vector_source_b( range(0,100) ) - - # itemsize, M, N, offset - km2 = gr.keep_m_in_n( 1, 1, 2, 0 ); - km3 = gr.keep_m_in_n( 1, 1, 3, 1 ); - km7 = gr.keep_m_in_n( 1, 1, 7, 2 ); - snk2 = gr.vector_sink_b(); - snk3 = gr.vector_sink_b(); - snk7 = gr.vector_sink_b(); - tb.connect(src,km2,snk2); - tb.connect(src,km3,snk3); - tb.connect(src,km7,snk7); - tb.run(); - - self.assertEqual(range(0,100,2), list(snk2.data())); - self.assertEqual(range(1,100,3), list(snk3.data())); - self.assertEqual(range(2,100,7), list(snk7.data())); - - -if __name__ == '__main__': - gr_unittest.run(test_keep_m_in_n, "test_keep_m_in_n.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_kludged_imports.py b/gnuradio-core/src/python/gnuradio/gr/qa_kludged_imports.py index 39b5d781e2..f80188c9fc 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_kludged_imports.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_kludged_imports.py @@ -30,10 +30,6 @@ class test_kludged_imports (gr_unittest.TestCase): def tearDown(self): pass - def test_blks_import(self): - # make sure that this somewhat magic import works - from gnuradio import blks2 - def test_gru_import(self): # make sure that this somewhat magic import works from gnuradio import gru diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_multiply_conjugate.py b/gnuradio-core/src/python/gnuradio/gr/qa_multiply_conjugate.py deleted file mode 100644 index 1601a109e4..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_multiply_conjugate.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2012 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 - -class test_multiply_conjugate (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_000 (self): - src_data0 = (-2-2j, -1-1j, -2+2j, -1+1j, - 2-2j, 1-1j, 2+2j, 1+1j, - 0+0j) - src_data1 = (-3-3j, -4-4j, -3+3j, -4+4j, - 3-3j, 4-4j, 3+3j, 4+4j, - 0+0j) - - exp_data = (12+0j, 8+0j, 12+0j, 8+0j, - 12+0j, 8+0j, 12+0j, 8+0j, - 0+0j) - src0 = gr.vector_source_c(src_data0) - src1 = gr.vector_source_c(src_data1) - op = gr.multiply_conjugate_cc () - dst = gr.vector_sink_c () - - self.tb.connect(src0, (op,0)) - self.tb.connect(src1, (op,1)) - self.tb.connect(op, dst) - self.tb.run() - result_data = dst.data () - self.assertEqual (exp_data, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_multiply_conjugate, "test_multiply_conjugate.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_nlog10.py b/gnuradio-core/src/python/gnuradio/gr/qa_nlog10.py deleted file mode 100755 index 239911851c..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_nlog10.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2007,2010 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. -# - -import sys, time, random, numpy -from gnuradio import gr, gr_unittest - -class test_nlog10(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - src_data = (-10, 0, 10, 100, 1000, 10000, 100000) - expected_result = (-180, -180, 10, 20, 30, 40, 50) - src = gr.vector_source_f(src_data) - op = gr.nlog10_ff(10) - dst = gr.vector_sink_f() - self.tb.connect (src, op, dst) - self.tb.run() - result_data = dst.data() - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - -if __name__ == '__main__': - gr_unittest.run(test_nlog10, "test_nlog10.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pdu.py b/gnuradio-core/src/python/gnuradio/gr/qa_pdu.py index ff7eb722cd..59f927fa19 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_pdu.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_pdu.py @@ -36,8 +36,8 @@ class test_pdu(gr_unittest.TestCase): # Just run some data through and make sure it doesn't puke. src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - src = gr.pdu_to_tagged_stream(gr.BYTE) - snk3 = gr.tagged_stream_to_pdu(gr.BYTE) + src = gr.pdu_to_tagged_stream(gr.pdu_byte) + snk3 = gr.tagged_stream_to_pdu(gr.pdu_byte) snk2 = gr.vector_sink_b() snk = gr.tag_debug(1, "test") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pipe_fittings.py b/gnuradio-core/src/python/gnuradio/gr/qa_pipe_fittings.py deleted file mode 100755 index 1f24062b14..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_pipe_fittings.py +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2007,2010 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 - -if 0: - import os - print "pid =", os.getpid() - raw_input("Attach, then press Enter to continue") - - -def calc_expected_result(src_data, n): - assert (len(src_data) % n) == 0 - result = [list() for x in range(n)] - #print "len(result) =", len(result) - for i in xrange(len(src_data)): - (result[i % n]).append(src_data[i]) - return [tuple(x) for x in result] - - -class test_pipe_fittings(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block () - - def tearDown(self): - self.tb = None - - def test_001(self): - """ - Test stream_to_streams. - """ - n = 8 - src_len = n * 8 - src_data = range(src_len) - - expected_results = calc_expected_result(src_data, n) - #print "expected results: ", expected_results - src = gr.vector_source_i(src_data) - op = gr.stream_to_streams(gr.sizeof_int, n) - self.tb.connect(src, op) - - dsts = [] - for i in range(n): - dst = gr.vector_sink_i() - self.tb.connect((op, i), (dst, 0)) - dsts.append(dst) - - self.tb.run() - - for d in range(n): - self.assertEqual(expected_results[d], dsts[d].data()) - - def test_002(self): - """ - Test streams_to_stream (using stream_to_streams). - """ - n = 8 - src_len = n * 8 - src_data = tuple(range(src_len)) - expected_results = src_data - - src = gr.vector_source_i(src_data) - op1 = gr.stream_to_streams(gr.sizeof_int, n) - op2 = gr.streams_to_stream(gr.sizeof_int, n) - dst = gr.vector_sink_i() - - self.tb.connect(src, op1) - for i in range(n): - self.tb.connect((op1, i), (op2, i)) - self.tb.connect(op2, dst) - - self.tb.run() - self.assertEqual(expected_results, dst.data()) - - def test_003(self): - """ - Test streams_to_vector (using stream_to_streams & vector_to_stream). - """ - n = 8 - src_len = n * 8 - src_data = tuple(range(src_len)) - expected_results = src_data - - src = gr.vector_source_i(src_data) - op1 = gr.stream_to_streams(gr.sizeof_int, n) - op2 = gr.streams_to_vector(gr.sizeof_int, n) - op3 = gr.vector_to_stream(gr.sizeof_int, n) - dst = gr.vector_sink_i() - - self.tb.connect(src, op1) - for i in range(n): - self.tb.connect((op1, i), (op2, i)) - self.tb.connect(op2, op3, dst) - - self.tb.run() - self.assertEqual(expected_results, dst.data()) - - def test_004(self): - """ - Test vector_to_streams. - """ - n = 8 - src_len = n * 8 - src_data = tuple(range(src_len)) - expected_results = src_data - - src = gr.vector_source_i(src_data) - op1 = gr.stream_to_vector(gr.sizeof_int, n) - op2 = gr.vector_to_streams(gr.sizeof_int, n) - op3 = gr.streams_to_stream(gr.sizeof_int, n) - dst = gr.vector_sink_i() - - self.tb.connect(src, op1, op2) - for i in range(n): - self.tb.connect((op2, i), (op3, i)) - self.tb.connect(op3, dst) - - self.tb.run() - self.assertEqual(expected_results, dst.data()) - -if __name__ == '__main__': - gr_unittest.run(test_pipe_fittings, "test_pipe_fittings.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_rational_resampler.py b/gnuradio-core/src/python/gnuradio/gr/qa_rational_resampler.py deleted file mode 100755 index cc963d7572..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_rational_resampler.py +++ /dev/null @@ -1,298 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2006,2007,2010 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 blks2 -import math -import random -import sys - -#import os -#print os.getpid() -#raw_input('Attach with gdb, then press Enter: ') - - -def random_floats(n): - r = [] - for x in xrange(n): - r.append(float(random.randint(-32768, 32768))) - return tuple(r) - - -def reference_dec_filter(src_data, decim, taps): - tb = gr.top_block() - src = gr.vector_source_f(src_data) - op = gr.fir_filter_fff(decim, taps) - dst = gr.vector_sink_f() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - tb = None - return result_data - -def reference_interp_filter(src_data, interp, taps): - tb = gr.top_block() - src = gr.vector_source_f(src_data) - op = gr.interp_fir_filter_fff(interp, taps) - dst = gr.vector_sink_f() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - tb = None - return result_data - -def reference_interp_dec_filter(src_data, interp, decim, taps): - tb = gr.top_block() - src = gr.vector_source_f(src_data) - up = gr.interp_fir_filter_fff(interp, (1,)) - dn = gr.fir_filter_fff(decim, taps) - dst = gr.vector_sink_f() - tb.connect(src, up, dn, dst) - tb.run() - result_data = dst.data() - tb = None - return result_data - - -class test_rational_resampler (gr_unittest.TestCase): - - def setUp(self): - pass - - def tearDown(self): - pass - - # - # test the gr.rational_resampler_base primitives... - # - - def test_000_1_to_1(self): - taps = (-4, 5) - src_data = (234, -4, 23, -56, 45, 98, -23, -7) - xr = (-936, 1186, -112, 339, -460, -167, 582) - expected_result = tuple([float(x) for x in xr]) - - tb = gr.top_block() - src = gr.vector_source_f(src_data) - op = gr.rational_resampler_base_fff(1, 1, taps) - dst = gr.vector_sink_f() - tb.connect(src, op) - tb.connect(op, dst) - tb.run() - result_data = dst.data() - self.assertEqual(expected_result, result_data) - - def test_001_interp(self): - taps = [1, 10, 100, 1000, 10000] - src_data = (0, 2, 3, 5, 7, 11, 13, 17) - interpolation = 3 - xr = (0,0,0,0,2,20,200,2003,20030,300,3005,30050,500,5007,50070,700,7011,70110,1100,11013,110130,1300,13017,130170,1700.0,17000.0,170000.0) - expected_result = tuple([float(x) for x in xr]) - - tb = gr.top_block() - src = gr.vector_source_f(src_data) - op = gr.rational_resampler_base_fff(interpolation, 1, taps) - dst = gr.vector_sink_f() - tb.connect(src, op) - tb.connect(op, dst) - tb.run() - result_data = dst.data() - self.assertEqual(expected_result, result_data) - - def test_002_interp(self): - taps = random_floats(31) - #src_data = random_floats(10000) # FIXME the 10k case fails! - src_data = random_floats(1000) - interpolation = 3 - - expected_result = reference_interp_filter(src_data, interpolation, taps) - - tb = gr.top_block() - src = gr.vector_source_f(src_data) - op = gr.rational_resampler_base_fff(interpolation, 1, taps) - dst = gr.vector_sink_f() - tb.connect(src, op) - tb.connect(op, dst) - tb.run() - result_data = dst.data() - - L1 = len(result_data) - L2 = len(expected_result) - L = min(L1, L2) - if False: - sys.stderr.write('delta = %2d: ntaps = %d interp = %d ilen = %d\n' % - (L2 - L1, len(taps), interpolation, len(src_data))) - sys.stderr.write(' len(result_data) = %d len(expected_result) = %d\n' % - (len(result_data), len(expected_result))) - #self.assertEqual(expected_result[0:L], result_data[0:L]) - # FIXME check first 3 answers - self.assertEqual(expected_result[3:L], result_data[3:L]) - - def test_003_interp(self): - taps = random_floats(31) - src_data = random_floats(10000) - decimation = 3 - - expected_result = reference_dec_filter(src_data, decimation, taps) - - tb = gr.top_block() - src = gr.vector_source_f(src_data) - op = gr.rational_resampler_base_fff(1, decimation, taps) - dst = gr.vector_sink_f() - tb.connect(src, op) - tb.connect(op, dst) - tb.run() - result_data = dst.data() - - L1 = len(result_data) - L2 = len(expected_result) - L = min(L1, L2) - if False: - sys.stderr.write('delta = %2d: ntaps = %d decim = %d ilen = %d\n' % - (L2 - L1, len(taps), decimation, len(src_data))) - sys.stderr.write(' len(result_data) = %d len(expected_result) = %d\n' % - (len(result_data), len(expected_result))) - self.assertEqual(expected_result[0:L], result_data[0:L]) - - # FIXME disabled. Triggers hang on SuSE 10.0 - def xtest_004_decim_random_vals(self): - MAX_TAPS = 9 - MAX_DECIM = 7 - OUTPUT_LEN = 9 - - random.seed(0) # we want reproducibility - - for ntaps in xrange(1, MAX_TAPS + 1): - for decim in xrange(1, MAX_DECIM+1): - for ilen in xrange(ntaps + decim, ntaps + OUTPUT_LEN*decim): - src_data = random_floats(ilen) - taps = random_floats(ntaps) - expected_result = reference_dec_filter(src_data, decim, taps) - - tb = gr.top_block() - src = gr.vector_source_f(src_data) - op = gr.rational_resampler_base_fff(1, decim, taps) - dst = gr.vector_sink_f() - tb.connect(src, op, dst) - tb.run() - tb = None - result_data = dst.data() - L1 = len(result_data) - L2 = len(expected_result) - L = min(L1, L2) - if False: - sys.stderr.write('delta = %2d: ntaps = %d decim = %d ilen = %d\n' % (L2 - L1, ntaps, decim, ilen)) - sys.stderr.write(' len(result_data) = %d len(expected_result) = %d\n' % - (len(result_data), len(expected_result))) - self.assertEqual(expected_result[0:L], result_data[0:L]) - - - # FIXME disabled. Triggers hang on SuSE 10.0 - def xtest_005_interp_random_vals(self): - MAX_TAPS = 9 - MAX_INTERP = 7 - INPUT_LEN = 9 - - random.seed(0) # we want reproducibility - - for ntaps in xrange(1, MAX_TAPS + 1): - for interp in xrange(1, MAX_INTERP+1): - for ilen in xrange(ntaps, ntaps + INPUT_LEN): - src_data = random_floats(ilen) - taps = random_floats(ntaps) - expected_result = reference_interp_filter(src_data, interp, taps) - - tb = gr.top_block() - src = gr.vector_source_f(src_data) - op = gr.rational_resampler_base_fff(interp, 1, taps) - dst = gr.vector_sink_f() - tb.connect(src, op, dst) - tb.run() - tb = None - result_data = dst.data() - L1 = len(result_data) - L2 = len(expected_result) - L = min(L1, L2) - #if True or abs(L1-L2) > 1: - if False: - sys.stderr.write('delta = %2d: ntaps = %d interp = %d ilen = %d\n' % (L2 - L1, ntaps, interp, ilen)) - #sys.stderr.write(' len(result_data) = %d len(expected_result) = %d\n' % - # (len(result_data), len(expected_result))) - #self.assertEqual(expected_result[0:L], result_data[0:L]) - # FIXME check first ntaps+1 answers - self.assertEqual(expected_result[ntaps+1:L], result_data[ntaps+1:L]) - - - def test_006_interp_decim(self): - taps = (0,1,0,0) - src_data = range(10000) - interp = 3 - decimation = 2 - - expected_result = reference_interp_dec_filter(src_data, interp, decimation, taps) - - tb = gr.top_block() - src = gr.vector_source_f(src_data) - op = gr.rational_resampler_base_fff(interp, decimation, taps) - dst = gr.vector_sink_f() - tb.connect(src, op) - tb.connect(op, dst) - tb.run() - result_data = dst.data() - - L1 = len(result_data) - L2 = len(expected_result) - L = min(L1, L2) - if False: - sys.stderr.write('delta = %2d: ntaps = %d decim = %d ilen = %d\n' % - (L2 - L1, len(taps), decimation, len(src_data))) - sys.stderr.write(' len(result_data) = %d len(expected_result) = %d\n' % - (len(result_data), len(expected_result))) - self.assertEqual(expected_result[1:L], result_data[1:L]) - - # - # test the blks2.rational_resampler_??? primitives... - # - - def test_101_interp(self): - taps = [1, 10, 100, 1000, 10000] - src_data = (0, 2, 3, 5, 7, 11, 13, 17) - interpolation = 3 - xr = (0,0,0,0,2,20,200,2003,20030,300,3005,30050,500,5007,50070,700,7011,70110,1100,11013,110130,1300,13017,130170,1700.0,17000.0,170000.0) - expected_result = tuple([float(x) for x in xr]) - - tb = gr.top_block() - src = gr.vector_source_f(src_data) - op = blks2.rational_resampler_fff(interpolation, 1, taps=taps) - dst = gr.vector_sink_f() - tb.connect(src, op) - tb.connect(op, dst) - tb.run() - result_data = dst.data() - self.assertEqual(expected_result, result_data) - - -if __name__ == '__main__': - pass - # FIXME: Disabled, see ticket:210 - # gr_unittest.run(test_rational_resampler, "test_rational_resampler.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_repeat.py b/gnuradio-core/src/python/gnuradio/gr/qa_repeat.py deleted file mode 100755 index 116f37115a..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_repeat.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2008,2010 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 -import math - -class test_repeat (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001_float(self): - src_data = [n*1.0 for n in range(100)]; - dst_data = [] - for n in range(100): - dst_data += [1.0*n, 1.0*n, 1.0*n] - - src = gr.vector_source_f(src_data) - rpt = gr.repeat(gr.sizeof_float, 3) - dst = gr.vector_sink_f() - self.tb.connect(src, rpt, dst) - self.tb.run() - self.assertFloatTuplesAlmostEqual(dst_data, dst.data(), 6) - -if __name__ == '__main__': - gr_unittest.run(test_repeat, "test_repeat.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_short_to_char.py b/gnuradio-core/src/python/gnuradio/gr/qa_short_to_char.py deleted file mode 100755 index 490b149c7c..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_short_to_char.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2011,2012 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 -import ctypes - -class test_short_to_char (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - - src_data = range(0, 32767, 32767/127) - src_data = [int(s) for s in src_data] - expected_result = range(0, 128) - src = gr.vector_source_s(src_data) - op = gr.short_to_char() - dst = gr.vector_sink_b() - - self.tb.connect(src, op, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - - def test_002(self): - - vlen = 3 - src_data = range(0, 32400, 32767/127) - src_data = [int(s) for s in src_data] - expected_result = range(0, 126) - src = gr.vector_source_s(src_data) - s2v = gr.stream_to_vector(gr.sizeof_short, vlen) - op = gr.short_to_char(vlen) - v2s = gr.vector_to_stream(gr.sizeof_char, vlen) - dst = gr.vector_sink_b() - - self.tb.connect(src, s2v, op, v2s, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_short_to_char, "test_short_to_char.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_short_to_float.py b/gnuradio-core/src/python/gnuradio/gr/qa_short_to_float.py deleted file mode 100755 index 130f034ec3..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_short_to_float.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2011,2012 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 -import ctypes - -class test_short_to_float (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - - src_data = (0, 1, 2, 3, 4, 5, -1, -2, -3, -4, -5) - expected_result = [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, - -1.0, -2.0, -3.0, -4.0, -5.0] - - src = gr.vector_source_s(src_data) - op = gr.short_to_float() - dst = gr.vector_sink_f() - - self.tb.connect(src, op, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - - def test_002(self): - - vlen = 3 - src_data = (0, 1, 2, 3, 4, 5, -1, -2, -3) - expected_result = [0.0, 1.0, 2.0, 3.0, 4.0, - 5.0, -1.0, -2.0, -3.0] - src = gr.vector_source_s(src_data) - s2v = gr.stream_to_vector(gr.sizeof_short, vlen) - op = gr.short_to_float(vlen) - v2s = gr.vector_to_stream(gr.sizeof_float, vlen) - dst = gr.vector_sink_f() - - self.tb.connect(src, s2v, op, v2s, dst) - self.tb.run() - result_data = list(dst.data()) - - self.assertEqual(expected_result, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_short_to_float, "test_short_to_float.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_stream_mux.py b/gnuradio-core/src/python/gnuradio/gr/qa_stream_mux.py deleted file mode 100755 index 779d0b25e3..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_stream_mux.py +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2005,2007,2010 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 - -class test_stream_mux (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def help_stream_2ff(self, N, stream_sizes): - v0 = gr.vector_source_f(N*[1,], False) - v1 = gr.vector_source_f(N*[2,], False) - - mux = gr.stream_mux(gr.sizeof_float, stream_sizes) - - dst = gr.vector_sink_f () - - self.tb.connect (v0, (mux,0)) - self.tb.connect (v1, (mux,1)) - self.tb.connect (mux, dst) - self.tb.run () - - return dst.data () - - def help_stream_ramp_2ff(self, N, stream_sizes): - r1 = range(N) - r2 = range(N) - r2.reverse() - - v0 = gr.vector_source_f(r1, False) - v1 = gr.vector_source_f(r2, False) - - mux = gr.stream_mux(gr.sizeof_float, stream_sizes) - - dst = gr.vector_sink_f () - - self.tb.connect (v0, (mux,0)) - self.tb.connect (v1, (mux,1)) - self.tb.connect (mux, dst) - self.tb.run () - - return dst.data () - - def test_stream_2NN_ff(self): - N = 40 - stream_sizes = [10, 10] - result_data = self.help_stream_2ff(N, stream_sizes) - - exp_data = (1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0) - self.assertEqual (exp_data, result_data) - - def test_stream_ramp_2NN_ff(self): - N = 40 - stream_sizes = [10, 10] - result_data = self.help_stream_ramp_2ff(N, stream_sizes) - - exp_data = ( 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, - 39.0, 38.0, 37.0, 36.0, 35.0, 34.0, 33.0, 32.0, 31.0, 30.0, - 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, - 29.0, 28.0, 27.0, 26.0, 25.0, 24.0, 23.0, 22.0, 21.0, 20.0, - 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, - 19.0, 18.0, 17.0, 16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, - 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, - 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0) - self.assertEqual (exp_data, result_data) - - def test_stream_2NM_ff(self): - N = 40 - stream_sizes = [7, 9] - self.help_stream_2ff(N, stream_sizes) - - result_data = self.help_stream_2ff(N, stream_sizes) - - exp_data = (1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0) - - self.assertEqual (exp_data, result_data) - - - def test_stream_2MN_ff(self): - N = 37 - stream_sizes = [7, 9] - self.help_stream_2ff(N, stream_sizes) - - result_data = self.help_stream_2ff(N, stream_sizes) - - exp_data = (1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 2.0) - - self.assertEqual (exp_data, result_data) - - def test_stream_2N0_ff(self): - N = 30 - stream_sizes = [7, 0] - self.help_stream_2ff(N, stream_sizes) - - result_data = self.help_stream_2ff(N, stream_sizes) - - exp_data = (1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0) - - self.assertEqual (exp_data, result_data) - - def test_stream_20N_ff(self): - N = 30 - stream_sizes = [0, 9] - self.help_stream_2ff(N, stream_sizes) - - result_data = self.help_stream_2ff(N, stream_sizes) - - exp_data = (2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, - 2.0, 2.0, 2.0) - - self.assertEqual (exp_data, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_stream_mux, "test_stream_mux.xml") diff --git a/gnuradio-core/src/python/gnuradio/optfir.py b/gnuradio-core/src/python/gnuradio/optfir.py deleted file mode 100644 index bbd48dae75..0000000000 --- a/gnuradio-core/src/python/gnuradio/optfir.py +++ /dev/null @@ -1,359 +0,0 @@ -# -# Copyright 2004,2005,2009 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. -# - -''' -Routines for designing optimal FIR filters. - -For a great intro to how all this stuff works, see section 6.6 of -"Digital Signal Processing: A Practical Approach", Emmanuael C. Ifeachor -and Barrie W. Jervis, Adison-Wesley, 1993. ISBN 0-201-54413-X. -''' - -import math, cmath -from gnuradio import gr - -remez = gr.remez - -def low_pass (gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db, - nextra_taps=2): - """ - Builds a low pass filter. - - Args: - gain: Filter gain in the passband (linear) - Fs: Sampling rate (sps) - freq1: End of pass band (in Hz) - freq2: Start of stop band (in Hz) - passband_ripple_db: Pass band ripple in dB (should be small, < 1) - stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) - nextra_taps: Extra taps to use in the filter (default=2) - """ - passband_dev = passband_ripple_to_dev (passband_ripple_db) - stopband_dev = stopband_atten_to_dev (stopband_atten_db) - desired_ampls = (gain, 0) - (n, fo, ao, w) = remezord ([freq1, freq2], desired_ampls, - [passband_dev, stopband_dev], Fs) - # The remezord typically under-estimates the filter order, so add 2 taps by default - taps = gr.remez (n + nextra_taps, fo, ao, w, "bandpass") - return taps - -def band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, - passband_ripple_db, stopband_atten_db, - nextra_taps=2): - """ - Builds a band pass filter. - - Args: - gain: Filter gain in the passband (linear) - Fs: Sampling rate (sps) - freq_sb1: End of stop band (in Hz) - freq_pb1: Start of pass band (in Hz) - freq_pb2: End of pass band (in Hz) - freq_sb2: Start of stop band (in Hz) - passband_ripple_db: Pass band ripple in dB (should be small, < 1) - stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) - nextra_taps: Extra taps to use in the filter (default=2) - """ - passband_dev = passband_ripple_to_dev (passband_ripple_db) - stopband_dev = stopband_atten_to_dev (stopband_atten_db) - desired_ampls = (0, gain, 0) - desired_freqs = [freq_sb1, freq_pb1, freq_pb2, freq_sb2] - desired_ripple = [stopband_dev, passband_dev, stopband_dev] - (n, fo, ao, w) = remezord (desired_freqs, desired_ampls, - desired_ripple, Fs) - # The remezord typically under-estimates the filter order, so add 2 taps by default - taps = gr.remez (n + nextra_taps, fo, ao, w, "bandpass") - return taps - - -def complex_band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, - passband_ripple_db, stopband_atten_db, - nextra_taps=2): - """ - Builds a band pass filter with complex taps by making an LPF and - spinning it up to the right center frequency - - Args: - gain: Filter gain in the passband (linear) - Fs: Sampling rate (sps) - freq_sb1: End of stop band (in Hz) - freq_pb1: Start of pass band (in Hz) - freq_pb2: End of pass band (in Hz) - freq_sb2: Start of stop band (in Hz) - passband_ripple_db: Pass band ripple in dB (should be small, < 1) - stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) - nextra_taps: Extra taps to use in the filter (default=2) - """ - center_freq = (freq_pb2 + freq_pb1) / 2.0 - lp_pb = (freq_pb2 - center_freq)/1.0 - lp_sb = freq_sb2 - center_freq - lptaps = low_pass(gain, Fs, lp_pb, lp_sb, passband_ripple_db, - stopband_atten_db, nextra_taps) - spinner = [cmath.exp(2j*cmath.pi*center_freq/Fs*i) for i in xrange(len(lptaps))] - taps = [s*t for s,t in zip(spinner, lptaps)] - return taps - - -def band_reject (gain, Fs, freq_pb1, freq_sb1, freq_sb2, freq_pb2, - passband_ripple_db, stopband_atten_db, - nextra_taps=2): - """ - Builds a band reject filter - spinning it up to the right center frequency - - Args: - gain: Filter gain in the passband (linear) - Fs: Sampling rate (sps) - freq_pb1: End of pass band (in Hz) - freq_sb1: Start of stop band (in Hz) - freq_sb2: End of stop band (in Hz) - freq_pb2: Start of pass band (in Hz) - passband_ripple_db: Pass band ripple in dB (should be small, < 1) - stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) - nextra_taps: Extra taps to use in the filter (default=2) - """ - passband_dev = passband_ripple_to_dev (passband_ripple_db) - stopband_dev = stopband_atten_to_dev (stopband_atten_db) - desired_ampls = (gain, 0, gain) - desired_freqs = [freq_pb1, freq_sb1, freq_sb2, freq_pb2] - desired_ripple = [passband_dev, stopband_dev, passband_dev] - (n, fo, ao, w) = remezord (desired_freqs, desired_ampls, - desired_ripple, Fs) - # Make sure we use an odd number of taps - if((n+nextra_taps)%2 == 1): - n += 1 - # The remezord typically under-estimates the filter order, so add 2 taps by default - taps = gr.remez (n + nextra_taps, fo, ao, w, "bandpass") - return taps - - -def high_pass (gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db, - nextra_taps=2): - """ - Builds a high pass filter. - - Args: - gain: Filter gain in the passband (linear) - Fs: Sampling rate (sps) - freq1: End of stop band (in Hz) - freq2: Start of pass band (in Hz) - passband_ripple_db: Pass band ripple in dB (should be small, < 1) - stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) - nextra_taps: Extra taps to use in the filter (default=2) - """ - passband_dev = passband_ripple_to_dev (passband_ripple_db) - stopband_dev = stopband_atten_to_dev (stopband_atten_db) - desired_ampls = (0, 1) - (n, fo, ao, w) = remezord ([freq1, freq2], desired_ampls, - [stopband_dev, passband_dev], Fs) - # For a HPF, we need to use an odd number of taps - # In gr.remez, ntaps = n+1, so n must be even - if((n+nextra_taps)%2 == 1): - n += 1 - - # The remezord typically under-estimates the filter order, so add 2 taps by default - taps = gr.remez (n + nextra_taps, fo, ao, w, "bandpass") - return taps - -# ---------------------------------------------------------------- - -def stopband_atten_to_dev (atten_db): - """Convert a stopband attenuation in dB to an absolute value""" - return 10**(-atten_db/20) - -def passband_ripple_to_dev (ripple_db): - """Convert passband ripple spec expressed in dB to an absolute value""" - return (10**(ripple_db/20)-1)/(10**(ripple_db/20)+1) - -# ---------------------------------------------------------------- - -def remezord (fcuts, mags, devs, fsamp = 2): - ''' - FIR order estimator (lowpass, highpass, bandpass, mulitiband). - - (n, fo, ao, w) = remezord (f, a, dev) - (n, fo, ao, w) = remezord (f, a, dev, fs) - - (n, fo, ao, w) = remezord (f, a, dev) finds the approximate order, - normalized frequency band edges, frequency band amplitudes, and - weights that meet input specifications f, a, and dev, to use with - the remez command. - - * f is a sequence of frequency band edges (between 0 and Fs/2, where - Fs is the sampling frequency), and a is a sequence specifying the - desired amplitude on the bands defined by f. The length of f is - twice the length of a, minus 2. The desired function is - piecewise constant. - - * dev is a sequence the same size as a that specifies the maximum - allowable deviation or ripples between the frequency response - and the desired amplitude of the output filter, for each band. - - Use remez with the resulting order n, frequency sequence fo, - amplitude response sequence ao, and weights w to design the filter b - which approximately meets the specifications given by remezord - input parameters f, a, and dev: - - b = remez (n, fo, ao, w) - - (n, fo, ao, w) = remezord (f, a, dev, Fs) specifies a sampling frequency Fs. - - Fs defaults to 2 Hz, implying a Nyquist frequency of 1 Hz. You can - therefore specify band edges scaled to a particular applications - sampling frequency. - - In some cases remezord underestimates the order n. If the filter - does not meet the specifications, try a higher order such as n+1 - or n+2. - ''' - # get local copies - fcuts = fcuts[:] - mags = mags[:] - devs = devs[:] - - for i in range (len (fcuts)): - fcuts[i] = float (fcuts[i]) / fsamp - - nf = len (fcuts) - nm = len (mags) - nd = len (devs) - nbands = nm - - if nm != nd: - raise ValueError, "Length of mags and devs must be equal" - - if nf != 2 * (nbands - 1): - raise ValueError, "Length of f must be 2 * len (mags) - 2" - - for i in range (len (mags)): - if mags[i] != 0: # if not stopband, get relative deviation - devs[i] = devs[i] / mags[i] - - # separate the passband and stopband edges - f1 = fcuts[0::2] - f2 = fcuts[1::2] - - n = 0 - min_delta = 2 - for i in range (len (f1)): - if f2[i] - f1[i] < min_delta: - n = i - min_delta = f2[i] - f1[i] - - if nbands == 2: - # lowpass or highpass case (use formula) - l = lporder (f1[n], f2[n], devs[0], devs[1]) - else: - # bandpass or multipass case - # try different lowpasses and take the worst one that - # goes through the BP specs - l = 0 - for i in range (1, nbands-1): - l1 = lporder (f1[i-1], f2[i-1], devs[i], devs[i-1]) - l2 = lporder (f1[i], f2[i], devs[i], devs[i+1]) - l = max (l, l1, l2) - - n = int (math.ceil (l)) - 1 # need order, not length for remez - - # cook up remez compatible result - ff = [0] + fcuts + [1] - for i in range (1, len (ff) - 1): - ff[i] *= 2 - - aa = [] - for a in mags: - aa = aa + [a, a] - - max_dev = max (devs) - wts = [1] * len(devs) - for i in range (len (wts)): - wts[i] = max_dev / devs[i] - - return (n, ff, aa, wts) - -# ---------------------------------------------------------------- - -def lporder (freq1, freq2, delta_p, delta_s): - ''' - FIR lowpass filter length estimator. freq1 and freq2 are - normalized to the sampling frequency. delta_p is the passband - deviation (ripple), delta_s is the stopband deviation (ripple). - - Note, this works for high pass filters too (freq1 > freq2), but - doesnt work well if the transition is near f == 0 or f == fs/2 - - From Herrmann et al (1973), Practical design rules for optimum - finite impulse response filters. Bell System Technical J., 52, 769-99 - ''' - df = abs (freq2 - freq1) - ddp = math.log10 (delta_p) - dds = math.log10 (delta_s) - - a1 = 5.309e-3 - a2 = 7.114e-2 - a3 = -4.761e-1 - a4 = -2.66e-3 - a5 = -5.941e-1 - a6 = -4.278e-1 - - b1 = 11.01217 - b2 = 0.5124401 - - t1 = a1 * ddp * ddp - t2 = a2 * ddp - t3 = a4 * ddp * ddp - t4 = a5 * ddp - - dinf=((t1 + t2 + a3) * dds) + (t3 + t4 + a6) - ff = b1 + b2 * (ddp - dds) - n = dinf / df - ff * df + 1 - return n - - -def bporder (freq1, freq2, delta_p, delta_s): - ''' - FIR bandpass filter length estimator. freq1 and freq2 are - normalized to the sampling frequency. delta_p is the passband - deviation (ripple), delta_s is the stopband deviation (ripple). - - From Mintzer and Liu (1979) - ''' - df = abs (freq2 - freq1) - ddp = math.log10 (delta_p) - dds = math.log10 (delta_s) - - a1 = 0.01201 - a2 = 0.09664 - a3 = -0.51325 - a4 = 0.00203 - a5 = -0.57054 - a6 = -0.44314 - - t1 = a1 * ddp * ddp - t2 = a2 * ddp - t3 = a4 * ddp * ddp - t4 = a5 * ddp - - cinf = dds * (t1 + t2 + a3) + t3 + t4 + a6 - ginf = -14.6 * math.log10 (delta_p / delta_s) - 16.9 - n = cinf / df + ginf * df + 1 - return n - diff --git a/gr-analog/examples/fmtest.py b/gr-analog/examples/fmtest.py index ca02ee5729..294fa0d425 100755 --- a/gr-analog/examples/fmtest.py +++ b/gr-analog/examples/fmtest.py @@ -20,7 +20,9 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, filter +from gnuradio import gr +from gnuradio import blocks +from gnuradio import filter from gnuradio import analog import sys, math, time @@ -53,7 +55,7 @@ class fmtx(gr.hier_block2): lo_freq, # frequency 1.0, # amplitude 0) # DC Offset - mixer = gr.multiply_cc() + mixer = blocks.multiply_cc() self.connect(self, fmtx, (mixer, 0)) self.connect(lo, (mixer, 1)) @@ -75,7 +77,7 @@ class fmtest(gr.top_block): self._if_rate = 4*self._N*self._audio_rate # Create a signal source and frequency modulate it - self.sum = gr.add_cc() + self.sum = blocks.add_cc() for n in xrange(self._N): sig = analog.sig_source_f(self._audio_rate, analog.GR_SIN_WAVE, freq[n], 0.5) fm = fmtx(f_lo[n], self._audio_rate, self._if_rate) diff --git a/gr-analog/examples/tags/uhd_burst_detector.py b/gr-analog/examples/tags/uhd_burst_detector.py index 3be0fb8c2e..8d846bbae8 100755 --- a/gr-analog/examples/tags/uhd_burst_detector.py +++ b/gr-analog/examples/tags/uhd_burst_detector.py @@ -22,9 +22,9 @@ from gnuradio import eng_notation from gnuradio import gr -from gnuradio import filter, analog +from gnuradio import filter, analog, blocks from gnuradio import uhd -from gnuradio import window +from gnuradio.fft import window from gnuradio.eng_option import eng_option from gnuradio.gr import firdes from optparse import OptionParser @@ -65,9 +65,9 @@ class uhd_burst_detector(gr.top_block): ## average to debounce self.avg = filter.single_pole_iir_filter_ff(0.01) ## rescale signal for conversion to short - self.scale = gr.multiply_const_ff(2**16) + self.scale = blocks.multiply_const_ff(2**16) ## signal input uses shorts - self.f2s = gr.float_to_short() + self.f2s = blocks.float_to_short() # Use file sink burst tagger to capture bursts self.fsnk = gr.tagged_file_sink(gr.sizeof_gr_complex, self.samp_rate) diff --git a/gr-analog/python/am_demod.py b/gr-analog/python/am_demod.py index 2730aa2622..64a3909f51 100644 --- a/gr-analog/python/am_demod.py +++ b/gr-analog/python/am_demod.py @@ -20,6 +20,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio import filter class am_demod_cf(gr.hier_block2): @@ -43,7 +44,7 @@ class am_demod_cf(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_float)) # Input signature MAG = gr.complex_to_mag() - DCR = gr.add_const_ff(-1.0) + DCR = blocks.add_const_ff(-1.0) audio_taps = filter.optfir.low_pass(0.5, # Filter gain channel_rate, # Sample rate diff --git a/gr-analog/python/standard_squelch.py b/gr-analog/python/standard_squelch.py index 986397a48e..c1fa406b48 100644 --- a/gr-analog/python/standard_squelch.py +++ b/gr-analog/python/standard_squelch.py @@ -21,6 +21,7 @@ import math from gnuradio import gr +from gnuradio import blocks from gnuradio import filter class standard_squelch(gr.hier_block2): @@ -29,23 +30,23 @@ class standard_squelch(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_float), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature - self.input_node = gr.add_const_ff(0) # FIXME kludge + self.input_node = blocks.add_const_ff(0) # FIXME kludge self.low_iir = filter.iir_filter_ffd((0.0193,0,-0.0193),(1,1.9524,-0.9615)) - self.low_square = gr.multiply_ff() + self.low_square = blocks.multiply_ff() self.low_smooth = filter.single_pole_iir_filter_ff(1/(0.01*audio_rate)) # 100ms time constant self.hi_iir = filter.iir_filter_ffd((0.0193,0,-0.0193),(1,1.3597,-0.9615)) - self.hi_square = gr.multiply_ff() + self.hi_square = blocks.multiply_ff() self.hi_smooth = filter.single_pole_iir_filter_ff(1/(0.01*audio_rate)) - self.sub = gr.sub_ff(); - self.add = gr.add_ff(); + self.sub = blocks.sub_ff(); + self.add = blocks.add_ff(); self.gate = gr.threshold_ff(0.3,0.43,0) self.squelch_lpf = filter.single_pole_iir_filter_ff(1/(0.01*audio_rate)) - self.div = gr.divide_ff() - self.squelch_mult = gr.multiply_ff() + self.div = blocks.divide_ff() + self.squelch_mult = blocks.multiply_ff() self.connect(self, self.input_node) self.connect(self.input_node, (self.squelch_mult, 0)) diff --git a/gr-analog/python/wfm_rcv_fmdet.py b/gr-analog/python/wfm_rcv_fmdet.py index 0fc9de1b88..735b39912f 100644 --- a/gr-analog/python/wfm_rcv_fmdet.py +++ b/gr-analog/python/wfm_rcv_fmdet.py @@ -19,7 +19,9 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, filter +from gnuradio import gr +from gnuradio import blocks +from gnuradio import filter from fm_emph import fm_deemph import math @@ -111,7 +113,7 @@ class wfm_rcv_fmdet(gr.hier_block2): # carrier is twice the picked off carrier so arrange to do # a commplex multiply - self.stereo_carrier_generator = gr.multiply_cc(); + self.stereo_carrier_generator = blocks.multiply_cc(); # Pick off the rds signal stereo_rds_filter_coeffs = \ @@ -128,8 +130,8 @@ class wfm_rcv_fmdet(gr.hier_block2): self.rds_signal_filter = \ filter.fir_filter_fcc(audio_decimation, stereo_rds_filter_coeffs) - self.rds_carrier_generator = gr.multiply_cc(); - self.rds_signal_generator = gr.multiply_cc(); + self.rds_carrier_generator = blocks.multiply_cc(); + self.rds_signal_generator = blocks.multiply_cc(); self_rds_signal_processor = gr.null_sink(gr.sizeof_gr_complex); loop_bw = 2*math.pi/100.0 @@ -146,14 +148,14 @@ class wfm_rcv_fmdet(gr.hier_block2): # set up mixer (multiplier) to get the L-R signal at # baseband - self.stereo_basebander = gr.multiply_cc(); + self.stereo_basebander = blocks.multiply_cc(); # pick off the real component of the basebanded L-R # signal. The imaginary SHOULD be zero self.LmR_real = gr.complex_to_real(); - self.Make_Left = gr.add_ff(); - self.Make_Right = gr.sub_ff(); + self.Make_Left = blocks.add_ff(); + self.Make_Right = blocks.sub_ff(); self.stereo_dsbsc_filter = \ filter.fir_filter_fcc(audio_decimation, diff --git a/gr-analog/python/wfm_rcv_pll.py b/gr-analog/python/wfm_rcv_pll.py index c26dfb4928..0c5c83db21 100644 --- a/gr-analog/python/wfm_rcv_pll.py +++ b/gr-analog/python/wfm_rcv_pll.py @@ -19,7 +19,9 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, filter +from gnuradio import gr +from gnuradio import blocks +from gnuradio import filter from fm_emph import fm_deemph import math @@ -103,7 +105,7 @@ class wfm_rcv_pll(gr.hier_block2): # carrier is twice the picked off carrier so arrange to do a commplex multiply - self.stereo_carrier_generator = gr.multiply_cc(); + self.stereo_carrier_generator = blocks.multiply_cc(); # Pick off the rds signal @@ -121,8 +123,8 @@ class wfm_rcv_pll(gr.hier_block2): self.rds_signal_filter = \ filter.fir_filter_fcc(audio_decimation, stereo_rds_filter_coeffs) - self.rds_carrier_generator = gr.multiply_cc(); - self.rds_signal_generator = gr.multiply_cc(); + self.rds_carrier_generator = blocks.multiply_cc(); + self.rds_signal_generator = blocks.multiply_cc(); self_rds_signal_processor = gr.null_sink(gr.sizeof_gr_complex); loop_bw = 2*math.pi/100.0 @@ -135,13 +137,13 @@ class wfm_rcv_pll(gr.hier_block2): # set up mixer (multiplier) to get the L-R signal at baseband - self.stereo_basebander = gr.multiply_cc(); + self.stereo_basebander = blocks.multiply_cc(); # pick off the real component of the basebanded L-R signal. The imaginary SHOULD be zero self.LmR_real = gr.complex_to_real(); - self.Make_Left = gr.add_ff(); - self.Make_Right = gr.sub_ff(); + self.Make_Left = blocks.add_ff(); + self.Make_Right = blocks.sub_ff(); self.stereo_dsbsc_filter = \ filter.fir_filter_fcc(audio_decimation, stereo_dsbsc_filter_coeffs) diff --git a/gr-atsc/CMakeLists.txt b/gr-atsc/CMakeLists.txt index c9a033fc1a..10a7904b20 100644 --- a/gr-atsc/CMakeLists.txt +++ b/gr-atsc/CMakeLists.txt @@ -30,6 +30,7 @@ GR_REGISTER_COMPONENT("gr-atsc" ENABLE_GR_ATSC Boost_FOUND ENABLE_GR_CORE ENABLE_GR_FFT + ENABLE_GR_BLOCKS ENABLE_GR_FILTER ENABLE_GR_ANALOG ) diff --git a/gr-atsc/src/python/CMakeLists.txt b/gr-atsc/src/python/CMakeLists.txt index b80ab2b181..aaa5bd93c4 100644 --- a/gr-atsc/src/python/CMakeLists.txt +++ b/gr-atsc/src/python/CMakeLists.txt @@ -46,6 +46,8 @@ if(ENABLE_TESTING) list(APPEND GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/gr-atsc/src/lib + ${CMAKE_BINARY_DIR}/gr-blocks/python + ${CMAKE_BINARY_DIR}/gr-blocks/swig ) list(APPEND GR_TEST_TARGET_DEPS gnuradio-atsc gnuradio-fec gnuradio-filter gnuradio-analog gnuradio-fft) diff --git a/gr-atsc/src/python/fpll.py b/gr-atsc/src/python/fpll.py index aed975557a..69749420b4 100755 --- a/gr-atsc/src/python/fpll.py +++ b/gr-atsc/src/python/fpll.py @@ -21,6 +21,8 @@ # from gnuradio import gr, atsc +from gnuradio import blocks +from gnuradio import filter import math, os def main(): @@ -38,7 +40,7 @@ def main(): # 1/2 as wide because we're designing lp filter symbol_rate = atsc.ATSC_SYMBOL_RATE/2. NTAPS = 279 - tt = gr.firdes.root_raised_cosine (1.0, input_rate, symbol_rate, .115, NTAPS) + tt = filter.firdes.root_raised_cosine (1.0, input_rate, symbol_rate, .115, NTAPS) # heterodyne the low pass coefficients up to the specified bandpass # center frequency. Note that when we do this, the filter bandwidth # is effectively twice the low pass (2.69 * 2 = 5.38) and hence @@ -47,7 +49,7 @@ def main(): t=[] for i in range(len(tt)): t += [tt[i] * 2. * math.cos(arg * i)] - rrc = gr.fir_filter_fff(1, t) + rrc = filter.fir_filter_fff(1, t) fpll = atsc.fpll() @@ -55,17 +57,17 @@ def main(): lower_edge = 6e6 - 0.31e6 upper_edge = IF_freq - 3e6 + pilot_freq transition_width = upper_edge - lower_edge - lp_coeffs = gr.firdes.low_pass (1.0, + lp_coeffs = filter.firdes.low_pass (1.0, input_rate, (lower_edge + upper_edge) * 0.5, transition_width, - gr.firdes.WIN_HAMMING); + filter.firdes.WIN_HAMMING); - lp_filter = gr.fir_filter_fff (1,lp_coeffs) + lp_filter = filter.fir_filter_fff (1,lp_coeffs) alpha = 1e-5 - iir = gr.single_pole_iir_filter_ff(alpha) - remove_dc = gr.sub_ff() + iir = filter.single_pole_iir_filter_ff(alpha) + remove_dc = blocks.sub_ff() out = gr.file_sink(gr.sizeof_float,"/tmp/atsc_pipe_3") # out = gr.file_sink(gr.sizeof_float,"/mnt/sata/atsc_data_float") diff --git a/gr-atsc/src/python/interp_short.py b/gr-atsc/src/python/interp_short.py index c5ea337f9a..749d15d0a7 100755 --- a/gr-atsc/src/python/interp_short.py +++ b/gr-atsc/src/python/interp_short.py @@ -33,6 +33,8 @@ # then at 0 with edges at -3.2MHz and 3.2MHz. from gnuradio import gr +from gnuradio import blocks +from gnuradio import filter import sys, os def graph (args): @@ -46,17 +48,18 @@ def graph (args): sys.stderr.write('usage: interp.py input_file\n') sys.exit (1) - tb = gr.top_block () + tb = gr.top_block() - srcf = gr.file_source (gr.sizeof_short,infile) - s2ss = gr.stream_to_streams(gr.sizeof_short,2) - s2f1 = gr.short_to_float() - s2f2 = gr.short_to_float() - src0 = gr.float_to_complex() + srcf = gr.file_source(gr.sizeof_short,infile) + s2ss = blocks.stream_to_streams(gr.sizeof_short,2) + s2f1 = blocks.short_to_float() + s2f2 = blocks.short_to_float() + src0 = blocks.float_to_complex() - lp_coeffs = gr.firdes.low_pass ( 3, 19.2e6, 3.2e6, .5e6, gr.firdes.WIN_HAMMING ) - lp = gr.interp_fir_filter_ccf ( 3, lp_coeffs ) + lp_coeffs = filter.firdes.low_pass(3, 19.2e6, 3.2e6, .5e6, + filter.firdes.WIN_HAMMING) + lp = filter.interp_fir_filter_ccf(3, lp_coeffs) file = gr.file_sink(gr.sizeof_gr_complex,"/tmp/atsc_pipe_1") diff --git a/gr-atsc/src/python/qa_atsc.py b/gr-atsc/src/python/qa_atsc.py index ab3eb96d40..507bc8aa47 100755 --- a/gr-atsc/src/python/qa_atsc.py +++ b/gr-atsc/src/python/qa_atsc.py @@ -25,7 +25,7 @@ import atsc # qa code needs to run without being installed #from gnuradio import atsc from atsc_utils import * import sys - +import blocks_swig as blocks class memoize(object): def __init__(self, thunk): @@ -81,7 +81,7 @@ class vector_source_ts(gr.hier_block2): """ src = gr.vector_source_b(pad_transport_stream(ts)) - s2v = gr.stream_to_vector(gr.sizeof_char, atsc.sizeof_atsc_mpeg_packet) + s2v = blocks.stream_to_vector(gr.sizeof_char, atsc.sizeof_atsc_mpeg_packet) gr.hier_block2.__init__(self, "vector_source_ts", gr.io_signature(0, 0, 0), @@ -97,7 +97,7 @@ class vector_sink_ts(gr.hier_block2): """ """ - v2s = gr.vector_to_stream(gr.sizeof_char, atsc.sizeof_atsc_mpeg_packet) + v2s = blocks.vector_to_stream(gr.sizeof_char, atsc.sizeof_atsc_mpeg_packet) self.sink = gr.vector_sink_b() gr.hier_block2.__init__(self, "vector_sink_ts", v2s.input_signature(), diff --git a/gr-audio/examples/grc/cvsd_sweep.grc b/gr-audio/examples/grc/cvsd_sweep.grc index b5735ddf0f..88629f15c2 100644 --- a/gr-audio/examples/grc/cvsd_sweep.grc +++ b/gr-audio/examples/grc/cvsd_sweep.grc @@ -204,7 +204,7 @@ </param> </block> <block> - <key>gr_char_to_float</key> + <key>blocks_char_to_float</key> <param> <key>id</key> <value>c2f</value> diff --git a/gr-audio/examples/grc/dial_tone.grc b/gr-audio/examples/grc/dial_tone.grc index 557edbd441..2503fed640 100644 --- a/gr-audio/examples/grc/dial_tone.grc +++ b/gr-audio/examples/grc/dial_tone.grc @@ -229,10 +229,10 @@ </param> </block> <block> - <key>gr_add_xx</key> + <key>blocks_add_xx</key> <param> <key>id</key> - <value>gr_add_xx</value> + <value>blocks_add_xx</value> </param> <param> <key>_enabled</key> @@ -381,26 +381,26 @@ </param> </block> <connection> - <source_block_id>gr_add_xx</source_block_id> + <source_block_id>blocks_add_xx</source_block_id> <sink_block_id>audio_sink</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>analog_sig_source_x_0</source_block_id> - <sink_block_id>gr_add_xx</sink_block_id> + <sink_block_id>blocks_add_xx</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>analog_sig_source_x_1</source_block_id> - <sink_block_id>gr_add_xx</sink_block_id> + <sink_block_id>blocks_add_xx</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> <source_block_id>analog_noise_source_x_0</source_block_id> - <sink_block_id>gr_add_xx</sink_block_id> + <sink_block_id>blocks_add_xx</sink_block_id> <source_key>0</source_key> <sink_key>2</sink_key> </connection> diff --git a/gr-audio/examples/python/spectrum_inversion.py b/gr-audio/examples/python/spectrum_inversion.py index e152430cdb..63d0c8cc8d 100755 --- a/gr-audio/examples/python/spectrum_inversion.py +++ b/gr-audio/examples/python/spectrum_inversion.py @@ -28,6 +28,7 @@ from gnuradio import gr from gnuradio import audio +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -54,7 +55,7 @@ class my_top_block(gr.top_block): vec1 = [1, -1] vsource = gr.vector_source_f(vec1, True) - multiply = gr.multiply_ff() + multiply = blocks.multiply_ff() self.connect(src, (multiply, 0)) self.connect(vsource, (multiply, 1)) diff --git a/gr-audio/examples/python/test_resampler.py b/gr-audio/examples/python/test_resampler.py index 93be86086b..0f5544cfa9 100755 --- a/gr-audio/examples/python/test_resampler.py +++ b/gr-audio/examples/python/test_resampler.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, blks2 +from gnuradio import gr, gru from gnuradio import audio from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -31,6 +31,12 @@ except ImportError: sys.stderr.write("Error: Program requires gr-analog.\n") sys.exit(1) +try: + from gnuradio import blocks +except ImportError: + sys.stderr.write("Error: Program requires gr-blocks.\n") + sys.exit(1) + class my_top_block(gr.top_block): def __init__(self): @@ -59,7 +65,7 @@ class my_top_block(gr.top_block): ampl = 0.1 src0 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 650, ampl) - rr = blks2.rational_resampler_fff(interp, decim) + rr = blocks.rational_resampler_fff(interp, decim) dst = audio.sink(output_rate, options.audio_output) self.connect(src0, rr, (dst, 0)) diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml index 797b3dbc5a..509547cbff 100644 --- a/gr-blocks/grc/blocks_block_tree.xml +++ b/gr-blocks/grc/blocks_block_tree.xml @@ -94,5 +94,6 @@ <block>blocks_streams_to_vector</block> <block>blocks_vector_to_stream</block> <block>blocks_vector_to_streams</block> + <block>blocks_stream_to_vector_decimator</block> </cat> </cat> diff --git a/grc/blocks/blks2_stream_to_vector_decimator.xml b/gr-blocks/grc/blocks_stream_to_vector_decimator.xml index 25f8f7a62f..ca71cf17ff 100644 --- a/grc/blocks/blks2_stream_to_vector_decimator.xml +++ b/gr-blocks/grc/blocks_stream_to_vector_decimator.xml @@ -6,9 +6,9 @@ --> <block> <name>Stream to Vec Decim</name> - <key>blks2_stream_to_vector_decimator</key> - <import>from gnuradio import blks2</import> - <make>blks2.stream_to_vector_decimator( + <key>blocks_stream_to_vector_decimator</key> + <import>from gnuradio import blocks</import> + <make>blocks.stream_to_vector_decimator( item_size=$type.size, sample_rate=$sample_rate, vec_rate=$vec_rate, diff --git a/gr-blocks/python/CMakeLists.txt b/gr-blocks/python/CMakeLists.txt index cab0b956f7..841588799b 100644 --- a/gr-blocks/python/CMakeLists.txt +++ b/gr-blocks/python/CMakeLists.txt @@ -24,6 +24,7 @@ GR_PYTHON_INSTALL( FILES __init__.py parse_file_metadata.py + stream_to_vector_decimator.py DESTINATION ${GR_PYTHON_DIR}/gnuradio/blocks COMPONENT "blocks_python" ) diff --git a/gr-blocks/python/__init__.py b/gr-blocks/python/__init__.py index 6577d933e0..56d274918c 100644 --- a/gr-blocks/python/__init__.py +++ b/gr-blocks/python/__init__.py @@ -25,8 +25,9 @@ processing blocks common to many flowgraphs. ''' from blocks_swig import * +from stream_to_vector_decimator import * -#alias old gr_add_vXX and gr_multiply_vXX +#alias old add_vXX and multiply_vXX add_vcc = add_cc add_vff = add_ff add_vii = add_ii diff --git a/gr-blocks/python/qa_add_mult_v.py b/gr-blocks/python/qa_add_mult_v.py index d362cb8859..13cb71df2c 100755 --- a/gr-blocks/python/qa_add_mult_v.py +++ b/gr-blocks/python/qa_add_mult_v.py @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks class test_add_mult_v(gr_unittest.TestCase): @@ -34,10 +34,10 @@ class test_add_mult_v(gr_unittest.TestCase): def help_ss(self, size, src_data, exp_data, op): for s in zip(range (len (src_data)), src_data): src = gr.vector_source_s(s[1]) - srcv = gr.stream_to_vector(gr.sizeof_short, size) + srcv = blocks.stream_to_vector(gr.sizeof_short, size) self.tb.connect(src, srcv) self.tb.connect(srcv, (op, s[0])) - rhs = gr.vector_to_stream(gr.sizeof_short, size) + rhs = blocks.vector_to_stream(gr.sizeof_short, size) dst = gr.vector_sink_s() self.tb.connect(op, rhs, dst) self.tb.run() @@ -47,10 +47,10 @@ class test_add_mult_v(gr_unittest.TestCase): def help_ii(self, size, src_data, exp_data, op): for s in zip(range (len (src_data)), src_data): src = gr.vector_source_i(s[1]) - srcv = gr.stream_to_vector(gr.sizeof_int, size) + srcv = blocks.stream_to_vector(gr.sizeof_int, size) self.tb.connect(src, srcv) self.tb.connect(srcv, (op, s[0])) - rhs = gr.vector_to_stream(gr.sizeof_int, size) + rhs = blocks.vector_to_stream(gr.sizeof_int, size) dst = gr.vector_sink_i() self.tb.connect(op, rhs, dst) self.tb.run() @@ -60,10 +60,10 @@ class test_add_mult_v(gr_unittest.TestCase): def help_ff(self, size, src_data, exp_data, op): for s in zip(range (len (src_data)), src_data): src = gr.vector_source_f(s[1]) - srcv = gr.stream_to_vector(gr.sizeof_float, size) + srcv = blocks.stream_to_vector(gr.sizeof_float, size) self.tb.connect(src, srcv) self.tb.connect(srcv, (op, s[0])) - rhs = gr.vector_to_stream(gr.sizeof_float, size) + rhs = blocks.vector_to_stream(gr.sizeof_float, size) dst = gr.vector_sink_f() self.tb.connect(op, rhs, dst) self.tb.run() @@ -73,10 +73,10 @@ class test_add_mult_v(gr_unittest.TestCase): def help_cc(self, size, src_data, exp_data, op): for s in zip(range (len (src_data)), src_data): src = gr.vector_source_c(s[1]) - srcv = gr.stream_to_vector(gr.sizeof_gr_complex, size) + srcv = blocks.stream_to_vector(gr.sizeof_gr_complex, size) self.tb.connect(src, srcv) self.tb.connect(srcv, (op, s[0])) - rhs = gr.vector_to_stream(gr.sizeof_gr_complex, size) + rhs = blocks.vector_to_stream(gr.sizeof_gr_complex, size) dst = gr.vector_sink_c() self.tb.connect(op, rhs, dst) self.tb.run() @@ -85,8 +85,8 @@ class test_add_mult_v(gr_unittest.TestCase): def help_const_ss(self, src_data, exp_data, op): src = gr.vector_source_s(src_data) - srcv = gr.stream_to_vector(gr.sizeof_short, len(src_data)) - rhs = gr.vector_to_stream(gr.sizeof_short, len(src_data)) + srcv = blocks.stream_to_vector(gr.sizeof_short, len(src_data)) + rhs = blocks.vector_to_stream(gr.sizeof_short, len(src_data)) dst = gr.vector_sink_s() self.tb.connect(src, srcv, op, rhs, dst) self.tb.run() @@ -95,8 +95,8 @@ class test_add_mult_v(gr_unittest.TestCase): def help_const_ii(self, src_data, exp_data, op): src = gr.vector_source_i(src_data) - srcv = gr.stream_to_vector(gr.sizeof_int, len(src_data)) - rhs = gr.vector_to_stream(gr.sizeof_int, len(src_data)) + srcv = blocks.stream_to_vector(gr.sizeof_int, len(src_data)) + rhs = blocks.vector_to_stream(gr.sizeof_int, len(src_data)) dst = gr.vector_sink_i() self.tb.connect(src, srcv, op, rhs, dst) self.tb.run() @@ -105,8 +105,8 @@ class test_add_mult_v(gr_unittest.TestCase): def help_const_ff(self, src_data, exp_data, op): src = gr.vector_source_f(src_data) - srcv = gr.stream_to_vector(gr.sizeof_float, len(src_data)) - rhs = gr.vector_to_stream(gr.sizeof_float, len(src_data)) + srcv = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) + rhs = blocks.vector_to_stream(gr.sizeof_float, len(src_data)) dst = gr.vector_sink_f() self.tb.connect(src, srcv, op, rhs, dst) self.tb.run() @@ -115,8 +115,8 @@ class test_add_mult_v(gr_unittest.TestCase): def help_const_cc(self, src_data, exp_data, op): src = gr.vector_source_c(src_data) - srcv = gr.stream_to_vector(gr.sizeof_gr_complex, len(src_data)) - rhs = gr.vector_to_stream(gr.sizeof_gr_complex, len(src_data)) + srcv = blocks.stream_to_vector(gr.sizeof_gr_complex, len(src_data)) + rhs = blocks.vector_to_stream(gr.sizeof_gr_complex, len(src_data)) dst = gr.vector_sink_c() self.tb.connect(src, srcv, op, rhs, dst) self.tb.run() @@ -130,7 +130,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (2,) src3_data = (3,) expected_result = (6,) - op = blocks_swig.add_ss(1) + op = blocks.add_ss(1) self.help_ss(1, (src1_data, src2_data, src3_data), expected_result, op) def test_add_vss_five(self): @@ -138,7 +138,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (6, 7, 8, 9, 10) src3_data = (11, 12, 13, 14, 15) expected_result = (18, 21, 24, 27, 30) - op = blocks_swig.add_ss(5) + op = blocks.add_ss(5) self.help_ss(5, (src1_data, src2_data, src3_data), expected_result, op) def test_add_vii_one(self): @@ -146,7 +146,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (2,) src3_data = (3,) expected_result = (6,) - op = blocks_swig.add_ii(1) + op = blocks.add_ii(1) self.help_ii(1, (src1_data, src2_data, src3_data), expected_result, op) def test_add_vii_five(self): @@ -154,7 +154,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (6, 7, 8, 9, 10) src3_data = (11, 12, 13, 14, 15) expected_result = (18, 21, 24, 27, 30) - op = blocks_swig.add_ii(5) + op = blocks.add_ii(5) self.help_ii(5, (src1_data, src2_data, src3_data), expected_result, op) def test_add_vff_one(self): @@ -162,7 +162,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (2.0,) src3_data = (3.0,) expected_result = (6.0,) - op = blocks_swig.add_ff(1) + op = blocks.add_ff(1) self.help_ff(1, (src1_data, src2_data, src3_data), expected_result, op) def test_add_vff_five(self): @@ -170,7 +170,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (6.0, 7.0, 8.0, 9.0, 10.0) src3_data = (11.0, 12.0, 13.0, 14.0, 15.0) expected_result = (18.0, 21.0, 24.0, 27.0, 30.0) - op = blocks_swig.add_ff(5) + op = blocks.add_ff(5) self.help_ff(5, (src1_data, src2_data, src3_data), expected_result, op) def test_add_vcc_one(self): @@ -178,7 +178,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (3.0+4.0j,) src3_data = (5.0+6.0j,) expected_result = (9.0+12j,) - op = blocks_swig.add_cc(1) + op = blocks.add_cc(1) self.help_cc(1, (src1_data, src2_data, src3_data), expected_result, op) def test_add_vcc_five(self): @@ -186,56 +186,56 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (11.0+12.0j, 13.0+14.0j, 15.0+16.0j, 17.0+18.0j, 19.0+20.0j) src3_data = (21.0+22.0j, 23.0+24.0j, 25.0+26.0j, 27.0+28.0j, 29.0+30.0j) expected_result = (33.0+36.0j, 39.0+42.0j, 45.0+48.0j, 51.0+54.0j, 57.0+60.0j) - op = blocks_swig.add_cc(5) + op = blocks.add_cc(5) self.help_cc(5, (src1_data, src2_data, src3_data), expected_result, op) # add_const_vXX def test_add_const_vss_one(self): src_data = (1,) - op = blocks_swig.add_const_vss((2,)) + op = blocks.add_const_vss((2,)) exp_data = (3,) self.help_const_ss(src_data, exp_data, op) def test_add_const_vss_five(self): src_data = (1, 2, 3, 4, 5) - op = blocks_swig.add_const_vss((6, 7, 8, 9, 10)) + op = blocks.add_const_vss((6, 7, 8, 9, 10)) exp_data = (7, 9, 11, 13, 15) self.help_const_ss(src_data, exp_data, op) def test_add_const_vii_one(self): src_data = (1,) - op = blocks_swig.add_const_vii((2,)) + op = blocks.add_const_vii((2,)) exp_data = (3,) self.help_const_ii(src_data, exp_data, op) def test_add_const_vii_five(self): src_data = (1, 2, 3, 4, 5) - op = blocks_swig.add_const_vii((6, 7, 8, 9, 10)) + op = blocks.add_const_vii((6, 7, 8, 9, 10)) exp_data = (7, 9, 11, 13, 15) self.help_const_ii(src_data, exp_data, op) def test_add_const_vff_one(self): src_data = (1.0,) - op = blocks_swig.add_const_vff((2.0,)) + op = blocks.add_const_vff((2.0,)) exp_data = (3.0,) self.help_const_ff(src_data, exp_data, op) def test_add_const_vff_five(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) - op = blocks_swig.add_const_vff((6.0, 7.0, 8.0, 9.0, 10.0)) + op = blocks.add_const_vff((6.0, 7.0, 8.0, 9.0, 10.0)) exp_data = (7.0, 9.0, 11.0, 13.0, 15.0) self.help_const_ff(src_data, exp_data, op) def test_add_const_vcc_one(self): src_data = (1.0+2.0j,) - op = blocks_swig.add_const_vcc((2.0+3.0j,)) + op = blocks.add_const_vcc((2.0+3.0j,)) exp_data = (3.0+5.0j,) self.help_const_cc(src_data, exp_data, op) def test_add_const_vcc_five(self): src_data = (1.0+2.0j, 3.0+4.0j, 5.0+6.0j, 7.0+8.0j, 9.0+10.0j) - op = blocks_swig.add_const_vcc((11.0+12.0j, 13.0+14.0j, 15.0+16.0j, 17.0+18.0j, 19.0+20.0j)) + op = blocks.add_const_vcc((11.0+12.0j, 13.0+14.0j, 15.0+16.0j, 17.0+18.0j, 19.0+20.0j)) exp_data = (12.0+14.0j, 16.0+18.0j, 20.0+22.0j, 24.0+26.0j, 28.0+30.0j) self.help_const_cc(src_data, exp_data, op) @@ -246,7 +246,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (2,) src3_data = (3,) expected_result = (6,) - op = gr.multiply_vss(1) + op = blocks.multiply_ss(1) self.help_ss(1, (src1_data, src2_data, src3_data), expected_result, op) def test_multiply_vss_five(self): @@ -254,7 +254,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (6, 7, 8, 9, 10) src3_data = (11, 12, 13, 14, 15) expected_result = (66, 168, 312, 504, 750) - op = gr.multiply_vss(5) + op = blocks.multiply_ss(5) self.help_ss(5, (src1_data, src2_data, src3_data), expected_result, op) def test_multiply_vii_one(self): @@ -262,7 +262,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (2,) src3_data = (3,) expected_result = (6,) - op = gr.multiply_vii(1) + op = blocks.multiply_ii(1) self.help_ii(1, (src1_data, src2_data, src3_data), expected_result, op) def test_multiply_vii_five(self): @@ -270,7 +270,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (6, 7, 8, 9, 10) src3_data = (11, 12, 13, 14, 15) expected_result = (66, 168, 312, 504, 750) - op = gr.multiply_vii(5) + op = blocks.multiply_ii(5) self.help_ii(5, (src1_data, src2_data, src3_data), expected_result, op) def test_multiply_vff_one(self): @@ -278,7 +278,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (2.0,) src3_data = (3.0,) expected_result = (6.0,) - op = gr.multiply_vff(1) + op = blocks.multiply_ff(1) self.help_ff(1, (src1_data, src2_data, src3_data), expected_result, op) def test_multiply_vff_five(self): @@ -286,7 +286,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (6.0, 7.0, 8.0, 9.0, 10.0) src3_data = (11.0, 12.0, 13.0, 14.0, 15.0) expected_result = (66.0, 168.0, 312.0, 504.0, 750.0) - op = gr.multiply_vff(5) + op = blocks.multiply_ff(5) self.help_ff(5, (src1_data, src2_data, src3_data), expected_result, op) def test_multiply_vcc_one(self): @@ -294,7 +294,7 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (3.0+4.0j,) src3_data = (5.0+6.0j,) expected_result = (-85+20j,) - op = gr.multiply_vcc(1) + op = blocks.multiply_cc(1) self.help_cc(1, (src1_data, src2_data, src3_data), expected_result, op) def test_multiply_vcc_five(self): @@ -302,56 +302,56 @@ class test_add_mult_v(gr_unittest.TestCase): src2_data = (11.0+12.0j, 13.0+14.0j, 15.0+16.0j, 17.0+18.0j, 19.0+20.0j) src3_data = (21.0+22.0j, 23.0+24.0j, 25.0+26.0j, 27.0+28.0j, 29.0+30.0j) expected_result = (-1021.0+428.0j, -2647.0+1754.0j, -4945.0+3704.0j, -8011.0+6374.0j, -11941.0+9860.0j) - op = gr.multiply_vcc(5) + op = blocks.multiply_cc(5) self.help_cc(5, (src1_data, src2_data, src3_data), expected_result, op) # multiply_const_vXX def test_multiply_const_vss_one(self): src_data = (2,) - op = gr.multiply_const_vss((3,)) + op = blocks.multiply_const_vss((3,)) exp_data = (6,) self.help_const_ss(src_data, exp_data, op) def test_multiply_const_vss_five(self): src_data = (1, 2, 3, 4, 5) - op = gr.multiply_const_vss((6, 7, 8, 9, 10)) + op = blocks.multiply_const_vss((6, 7, 8, 9, 10)) exp_data = (6, 14, 24, 36, 50) self.help_const_ss(src_data, exp_data, op) def test_multiply_const_vii_one(self): src_data = (2,) - op = gr.multiply_const_vii((3,)) + op = blocks.multiply_const_vii((3,)) exp_data = (6,) self.help_const_ii(src_data, exp_data, op) def test_multiply_const_vii_five(self): src_data = (1, 2, 3, 4, 5) - op = gr.multiply_const_vii((6, 7, 8, 9, 10)) + op = blocks.multiply_const_vii((6, 7, 8, 9, 10)) exp_data = (6, 14, 24, 36, 50) self.help_const_ii(src_data, exp_data, op) def test_multiply_const_vff_one(self): src_data = (2.0,) - op = gr.multiply_const_vff((3.0,)) + op = blocks.multiply_const_vff((3.0,)) exp_data = (6.0,) self.help_const_ff(src_data, exp_data, op) def test_multiply_const_vff_five(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) - op = gr.multiply_const_vff((6.0, 7.0, 8.0, 9.0, 10.0)) + op = blocks.multiply_const_vff((6.0, 7.0, 8.0, 9.0, 10.0)) exp_data = (6.0, 14.0, 24.0, 36.0, 50.0) self.help_const_ff(src_data, exp_data, op) def test_multiply_const_vcc_one(self): src_data = (1.0+2.0j,) - op = gr.multiply_const_vcc((2.0+3.0j,)) + op = blocks.multiply_const_vcc((2.0+3.0j,)) exp_data = (-4.0+7.0j,) self.help_const_cc(src_data, exp_data, op) def test_multiply_const_vcc_five(self): src_data = (1.0+2.0j, 3.0+4.0j, 5.0+6.0j, 7.0+8.0j, 9.0+10.0j) - op = gr.multiply_const_vcc((11.0+12.0j, 13.0+14.0j, 15.0+16.0j, 17.0+18.0j, 19.0+20.0j)) + op = blocks.multiply_const_vcc((11.0+12.0j, 13.0+14.0j, 15.0+16.0j, 17.0+18.0j, 19.0+20.0j)) exp_data = (-13.0+34.0j, -17.0+94.0j, -21.0+170.0j, -25.0+262.0j, -29.0+370.0j) self.help_const_cc(src_data, exp_data, op) diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_argmax.py b/gr-blocks/python/qa_argmax.py index 564eb620b0..1fbda7a1f9 100644 --- a/gnuradio-core/src/python/gnuradio/gr/qa_argmax.py +++ b/gr-blocks/python/qa_argmax.py @@ -21,6 +21,7 @@ # from gnuradio import gr, gr_unittest +import blocks_swig as blocks import math @@ -42,15 +43,15 @@ class test_arg_max (gr_unittest.TestCase): src3_data = (0,0.0,3.0,0,1,0) src1 = gr.vector_source_f (src1_data) - s2v1 = gr.stream_to_vector(gr.sizeof_float, len(src1_data)) + s2v1 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) tb.connect( src1, s2v1 ) src2 = gr.vector_source_f (src2_data) - s2v2 = gr.stream_to_vector(gr.sizeof_float, len(src1_data)) + s2v2 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) tb.connect( src2, s2v2 ) src3 = gr.vector_source_f (src3_data) - s2v3 = gr.stream_to_vector(gr.sizeof_float, len(src1_data)) + s2v3 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) tb.connect( src3, s2v3 ) dst1 = gr.vector_sink_s () diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_bin_statistics.py b/gr-blocks/python/qa_bin_statistics.py index 8a6dd9056f..00fd58b600 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_bin_statistics.py +++ b/gr-blocks/python/qa_bin_statistics.py @@ -21,6 +21,7 @@ # from gnuradio import gr, gr_unittest +import blocks_swig as blocks import random import struct @@ -124,7 +125,7 @@ class xtest_bin_statistics(gr_unittest.TestCase): )]) src = gr.vector_source_f(src_data, False) - s2v = gr.stream_to_vector(gr.sizeof_float, vlen) + s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) stats = gr.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) self.tb.connect(src, s2v, stats) self.tb.run() @@ -152,7 +153,7 @@ class xtest_bin_statistics(gr_unittest.TestCase): ( 9, 10, 11, 12)]) src = gr.vector_source_f(src_data, False) - s2v = gr.stream_to_vector(gr.sizeof_float, vlen) + s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) stats = gr.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) self.tb.connect(src, s2v, stats) self.tb.run() @@ -182,7 +183,7 @@ class xtest_bin_statistics(gr_unittest.TestCase): ( 9, 10, 11, 12)]) src = gr.vector_source_f(src_data, False) - s2v = gr.stream_to_vector(gr.sizeof_float, vlen) + s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) stats = gr.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) self.tb.connect(src, s2v, stats) self.tb.run() @@ -215,7 +216,7 @@ class xtest_bin_statistics(gr_unittest.TestCase): ( 9, 10, 11, 12)]) src = gr.vector_source_f(src_data, False) - s2v = gr.stream_to_vector(gr.sizeof_float, vlen) + s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) stats = gr.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) self.tb.connect(src, s2v, stats) self.tb.run() diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_max.py b/gr-blocks/python/qa_max.py index f962df457d..00c7e60110 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_max.py +++ b/gr-blocks/python/qa_max.py @@ -21,6 +21,7 @@ # from gnuradio import gr, gr_unittest +import blocks_swig as blocks import math @@ -40,7 +41,7 @@ class test_max (gr_unittest.TestCase): expected_result = (float(max(src_data)), ) src = gr.vector_source_f(src_data) - s2v = gr.stream_to_vector(gr.sizeof_float, len(src_data)) + s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) op = gr.max_ff( len(src_data) ) dst = gr.vector_sink_f() @@ -56,7 +57,7 @@ class test_max (gr_unittest.TestCase): expected_result = (float(max(src_data)), ) src = gr.vector_source_f(src_data) - s2v = gr.stream_to_vector(gr.sizeof_float, len(src_data)) + s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) op = gr.max_ff( len(src_data) ) dst = gr.vector_sink_f() diff --git a/gr-blocks/python/qa_pipe_fittings.py b/gr-blocks/python/qa_pipe_fittings.py index 321660d5ee..9894a5c211 100755 --- a/gr-blocks/python/qa_pipe_fittings.py +++ b/gr-blocks/python/qa_pipe_fittings.py @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks def calc_expected_result(src_data, n): assert (len(src_data) % n) == 0 @@ -51,7 +51,7 @@ class test_pipe_fittings(gr_unittest.TestCase): expected_results = calc_expected_result(src_data, n) #print "expected results: ", expected_results src = gr.vector_source_i(src_data) - op = gr.stream_to_streams(gr.sizeof_int, n) + op = blocks.stream_to_streams(gr.sizeof_int, n) self.tb.connect(src, op) dsts = [] @@ -75,8 +75,8 @@ class test_pipe_fittings(gr_unittest.TestCase): expected_results = src_data src = gr.vector_source_i(src_data) - op1 = gr.stream_to_streams(gr.sizeof_int, n) - op2 = gr.streams_to_stream(gr.sizeof_int, n) + op1 = blocks.stream_to_streams(gr.sizeof_int, n) + op2 = blocks.streams_to_stream(gr.sizeof_int, n) dst = gr.vector_sink_i() self.tb.connect(src, op1) @@ -97,9 +97,9 @@ class test_pipe_fittings(gr_unittest.TestCase): expected_results = src_data src = gr.vector_source_i(src_data) - op1 = gr.stream_to_streams(gr.sizeof_int, n) - op2 = gr.streams_to_vector(gr.sizeof_int, n) - op3 = gr.vector_to_stream(gr.sizeof_int, n) + op1 = blocks.stream_to_streams(gr.sizeof_int, n) + op2 = blocks.streams_to_vector(gr.sizeof_int, n) + op3 = blocks.vector_to_stream(gr.sizeof_int, n) dst = gr.vector_sink_i() self.tb.connect(src, op1) @@ -120,9 +120,9 @@ class test_pipe_fittings(gr_unittest.TestCase): expected_results = src_data src = gr.vector_source_i(src_data) - op1 = gr.stream_to_vector(gr.sizeof_int, n) - op2 = gr.vector_to_streams(gr.sizeof_int, n) - op3 = gr.streams_to_stream(gr.sizeof_int, n) + op1 = blocks.stream_to_vector(gr.sizeof_int, n) + op2 = blocks.vector_to_streams(gr.sizeof_int, n) + op3 = blocks.streams_to_stream(gr.sizeof_int, n) dst = gr.vector_sink_i() self.tb.connect(src, op1, op2) diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_probe_signal.py b/gr-blocks/python/qa_probe_signal.py index 4e10afdb64..ce526e8a53 100644 --- a/gnuradio-core/src/python/gnuradio/gr/qa_probe_signal.py +++ b/gr-blocks/python/qa_probe_signal.py @@ -23,6 +23,7 @@ import time from gnuradio import gr, gr_unittest +import blocks_swig as blocks class test_probe_signal (gr_unittest.TestCase): @@ -54,7 +55,7 @@ class test_probe_signal (gr_unittest.TestCase): src_data = value * repeats src = gr.vector_source_f(src_data) - s2v = gr.stream_to_vector(gr.sizeof_float, vector_length) + s2v = blocks.stream_to_vector(gr.sizeof_float, vector_length) dst = gr.probe_signal_vf(vector_length) self.tb.connect(src, s2v, dst) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/stream_to_vector_decimator.py b/gr-blocks/python/stream_to_vector_decimator.py index d6808b722f..c32ae6fce2 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/stream_to_vector_decimator.py +++ b/gr-blocks/python/stream_to_vector_decimator.py @@ -21,6 +21,11 @@ from gnuradio import gr +try: + from gnuradio import blocks +except ImportError: + import blocks_swig as blocks + class stream_to_vector_decimator(gr.hier_block2): """ Convert the stream to a vector, decimate the vector stream to achieve the vector rate. @@ -44,8 +49,8 @@ class stream_to_vector_decimator(gr.hier_block2): gr.io_signature(1, 1, item_size), # Input signature gr.io_signature(1, 1, item_size*vec_len)) # Output signature - s2v = gr.stream_to_vector(item_size, vec_len) - self.one_in_n = gr.keep_one_in_n(item_size*vec_len, 1) + s2v = blocks.stream_to_vector(item_size, vec_len) + self.one_in_n = blocks.keep_one_in_n(item_size*vec_len, 1) self._update_decimator() self.connect(self, s2v, self.one_in_n, self) diff --git a/gr-digital/CMakeLists.txt b/gr-digital/CMakeLists.txt index c2d7524505..ac0dbb737d 100644 --- a/gr-digital/CMakeLists.txt +++ b/gr-digital/CMakeLists.txt @@ -32,6 +32,7 @@ GR_REGISTER_COMPONENT("gr-digital" ENABLE_GR_DIGITAL ENABLE_GR_CORE ENABLE_GR_FFT ENABLE_GR_FILTER + ENABLE_GR_BLOCKS ENABLE_GR_ANALOG ) diff --git a/gr-digital/examples/berawgn.py b/gr-digital/examples/berawgn.py index 8ff43b7b92..b20b17fd39 100755 --- a/gr-digital/examples/berawgn.py +++ b/gr-digital/examples/berawgn.py @@ -37,6 +37,7 @@ import math import numpy from gnuradio import gr, digital from gnuradio import analog +from gnuradio import blocks try: from scipy.special import erfc @@ -70,16 +71,16 @@ class BitErrors(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_int)) # Bit comparison - comp = gr.xor_bb() + comp = blocks.xor_bb() intdump_decim = 100000 if N_BITS < intdump_decim: intdump_decim = int(N_BITS) self.connect(self, comp, gr.unpack_k_bits_bb(bits_per_byte), - gr.uchar_to_float(), - gr.integrate_ff(intdump_decim), - gr.multiply_const_ff(1.0/N_BITS), + blocks.uchar_to_float(), + blocks.integrate_ff(intdump_decim), + blocks.multiply_const_ff(1.0/N_BITS), self) self.connect((self, 1), (comp, 1)) @@ -92,7 +93,7 @@ class BERAWGNSimu(gr.top_block): data = map(int, numpy.random.randint(0, self.const.arity(), N_BITS/self.const.bits_per_symbol())) src = gr.vector_source_b(data, False) mod = digital.chunks_to_symbols_bc((self.const.points()), 1) - add = gr.add_vcc() + add = blocks.add_vcc() noise = analog.noise_source_c(analog.GR_GAUSSIAN, self.EbN0_to_noise_voltage(EbN0), RAND_SEED) diff --git a/gr-digital/examples/demod/ber_simulation.grc b/gr-digital/examples/demod/ber_simulation.grc index 2a3e27a496..9f67504b5a 100644 --- a/gr-digital/examples/demod/ber_simulation.grc +++ b/gr-digital/examples/demod/ber_simulation.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Sat Nov 10 15:31:44 2012</timestamp> + <timestamp>Thu Dec 27 13:06:26 2012</timestamp> <block> <key>options</key> <param> @@ -510,10 +510,10 @@ </param> </block> <block> - <key>gr_add_xx</key> + <key>blocks_add_xx</key> <param> <key>id</key> - <value>gr_add_xx</value> + <value>blocks_add_xx</value> </param> <param> <key>_enabled</key> @@ -594,7 +594,7 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_add_xx</source_block_id> + <source_block_id>blocks_add_xx</source_block_id> <sink_block_id>wxgui_scopesink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -606,7 +606,7 @@ <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_add_xx</source_block_id> + <source_block_id>blocks_add_xx</source_block_id> <sink_block_id>digital_constellation_decoder_cb_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -619,13 +619,13 @@ </connection> <connection> <source_block_id>digital_chunks_to_symbols_xx_0</source_block_id> - <sink_block_id>gr_add_xx</sink_block_id> + <sink_block_id>blocks_add_xx</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>analog_noise_source_x_0</source_block_id> - <sink_block_id>gr_add_xx</sink_block_id> + <sink_block_id>blocks_add_xx</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> diff --git a/gr-digital/examples/demod/pam_sync.grc b/gr-digital/examples/demod/pam_sync.grc index 11c625467b..d9afb3100c 100644 --- a/gr-digital/examples/demod/pam_sync.grc +++ b/gr-digital/examples/demod/pam_sync.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Mon Jul 16 21:25:28 2012</timestamp> + <timestamp>Thu Dec 27 13:26:17 2012</timestamp> <block> <key>options</key> <param> @@ -311,61 +311,6 @@ </param> </block> <block> - <key>digital_pfb_clock_sync_xxx</key> - <param> - <key>id</key> - <value>digital_pfb_clock_sync_xxx_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>ccf</value> - </param> - <param> - <key>sps</key> - <value>spb</value> - </param> - <param> - <key>alpha</key> - <value>time_alpha</value> - </param> - <param> - <key>beta</key> - <value>time_beta</value> - </param> - <param> - <key>taps</key> - <value>rrctaps</value> - </param> - <param> - <key>filter_size</key> - <value>nfilts</value> - </param> - <param> - <key>init_phase</key> - <value>nfilts/2</value> - </param> - <param> - <key>max_dev</key> - <value>1.5</value> - </param> - <param> - <key>osps</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(601, 254)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>wxgui_scopesink2</key> <param> <key>id</key> @@ -452,7 +397,7 @@ </param> <param> <key>label</key> - <value>Channel Noise</value> + <value>Channels_Channel Noise</value> </param> <param> <key>value</key> @@ -703,10 +648,10 @@ </param> </block> <block> - <key>channel_model</key> + <key>channels_channel_model</key> <param> <key>id</key> - <value>channel_model_0</value> + <value>channels_channel_model_0</value> </param> <param> <key>_enabled</key> @@ -966,116 +911,6 @@ <key>variable_slider</key> <param> <key>id</key> - <value>time_alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>Timing Alpha</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>min</key> - <value>0</value> - </param> - <param> - <key>max</key> - <value>1</value> - </param> - <param> - <key>num_steps</key> - <value>1000</value> - </param> - <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> - </param> - <param> - <key>converver</key> - <value>float_converter</value> - </param> - <param> - <key>grid_pos</key> - <value>(5,2,1,1)</value> - </param> - <param> - <key>notebook</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(557, 431)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_slider</key> - <param> - <key>id</key> - <value>time_beta</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>Timing Beta</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>min</key> - <value>0.0</value> - </param> - <param> - <key>max</key> - <value>0.1</value> - </param> - <param> - <key>num_steps</key> - <value>1000</value> - </param> - <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> - </param> - <param> - <key>converver</key> - <value>float_converter</value> - </param> - <param> - <key>grid_pos</key> - <value>(6,2,1,1)</value> - </param> - <param> - <key>notebook</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(694, 430)</value> - </param> - <param> - <key>_rotation</key> - <value>180</value> - </param> - </block> - <block> - <key>variable_slider</key> - <param> - <key>id</key> <value>freq_bw</value> </param> <param> @@ -1219,10 +1054,10 @@ </param> </block> <block> - <key>gr_multiply_const_vxx</key> + <key>blocks_multiply_const_vxx</key> <param> <key>id</key> - <value>gr_multiply_const_vxx_0</value> + <value>blocks_multiply_const_vxx_0</value> </param> <param> <key>_enabled</key> @@ -1307,6 +1142,10 @@ <value>32</value> </param> <param> + <key>atten</key> + <value>100</value> + </param> + <param> <key>_coordinate</key> <value>(468, 72)</value> </param> @@ -1355,58 +1194,105 @@ </param> </block> <block> - <key>options</key> + <key>digital_pfb_clock_sync_xxx</key> <param> <key>id</key> - <value>pam_sync</value> + <value>digital_pfb_clock_sync_xxx_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>title</key> - <value></value> + <key>type</key> + <value>ccf</value> </param> <param> - <key>author</key> - <value></value> + <key>sps</key> + <value>spb</value> </param> <param> - <key>description</key> - <value></value> + <key>loop_bw</key> + <value>timing_loop_bw</value> </param> <param> - <key>window_size</key> - <value>1280, 1024</value> + <key>taps</key> + <value>rrctaps</value> </param> <param> - <key>generate_options</key> - <value>wx_gui</value> + <key>filter_size</key> + <value>nfilts</value> </param> <param> - <key>category</key> - <value>Custom</value> + <key>init_phase</key> + <value>nfilts/2</value> </param> <param> - <key>run_options</key> - <value>prompt</value> + <key>max_dev</key> + <value>1.5</value> </param> <param> - <key>run</key> + <key>osps</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(601, 254)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> + <value>timing_loop_bw</value> + </param> + <param> + <key>_enabled</key> <value>True</value> </param> <param> - <key>max_nouts</key> + <key>label</key> + <value>Timing Loop Bandwidth</value> + </param> + <param> + <key>value</key> + <value>6.28/100.0</value> + </param> + <param> + <key>min</key> <value>0</value> </param> <param> - <key>realtime_scheduling</key> + <key>max</key> + <value>0.2</value> + </param> + <param> + <key>num_steps</key> + <value>1000</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value>(5,2,1,1)</value> + </param> + <param> + <key>notebook</key> <value></value> </param> <param> <key>_coordinate</key> - <value>(-1, 0)</value> + <value>(557, 431)</value> </param> <param> <key>_rotation</key> @@ -1438,7 +1324,7 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_const_vxx_0</source_block_id> + <source_block_id>blocks_multiply_const_vxx_0</source_block_id> <sink_block_id>gr_throttle_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -1462,20 +1348,20 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>channel_model_0</source_block_id> + <source_block_id>channels_channel_model_0</source_block_id> <sink_block_id>virtual_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>channel_model_0</source_block_id> + <source_block_id>channels_channel_model_0</source_block_id> <sink_block_id>digital_fll_band_edge_cc_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>gr_throttle_0</source_block_id> - <sink_block_id>channel_model_0</sink_block_id> + <sink_block_id>channels_channel_model_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> @@ -1487,7 +1373,7 @@ </connection> <connection> <source_block_id>pfb_arb_resampler_xxx_0</source_block_id> - <sink_block_id>gr_multiply_const_vxx_0</sink_block_id> + <sink_block_id>blocks_multiply_const_vxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-digital/examples/demod/pam_timing.grc b/gr-digital/examples/demod/pam_timing.grc index 6465d25fd0..b5e8d8822e 100644 --- a/gr-digital/examples/demod/pam_timing.grc +++ b/gr-digital/examples/demod/pam_timing.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Thu Jul 5 17:55:51 2012</timestamp> + <timestamp>Thu Dec 27 13:05:12 2012</timestamp> <block> <key>options</key> <param> @@ -61,10 +61,10 @@ </param> </block> <block> - <key>gr_uchar_to_float</key> + <key>blocks_uchar_to_float</key> <param> <key>id</key> - <value>gr_uchar_to_float_0</value> + <value>blocks_uchar_to_float_0</value> </param> <param> <key>_enabled</key> @@ -80,10 +80,10 @@ </param> </block> <block> - <key>gr_uchar_to_float</key> + <key>blocks_uchar_to_float</key> <param> <key>id</key> - <value>gr_uchar_to_float_0_0</value> + <value>blocks_uchar_to_float_0_0</value> </param> <param> <key>_enabled</key> @@ -232,10 +232,10 @@ </param> </block> <block> - <key>const_source_x</key> + <key>analog_const_source_x</key> <param> <key>id</key> - <value>const_source_x_0</value> + <value>analog_const_source_x_0</value> </param> <param> <key>_enabled</key> @@ -259,10 +259,10 @@ </param> </block> <block> - <key>const_source_x</key> + <key>analog_const_source_x</key> <param> <key>id</key> - <value>const_source_x_0_0</value> + <value>analog_const_source_x_0_0</value> </param> <param> <key>_enabled</key> @@ -321,10 +321,10 @@ </param> </block> <block> - <key>gr_add_xx</key> + <key>blocks_add_xx</key> <param> <key>id</key> - <value>gr_add_xx_0</value> + <value>blocks_add_xx_0</value> </param> <param> <key>_enabled</key> @@ -352,10 +352,10 @@ </param> </block> <block> - <key>gr_add_xx</key> + <key>blocks_add_xx</key> <param> <key>id</key> - <value>gr_add_xx_0_1</value> + <value>blocks_add_xx_0_1</value> </param> <param> <key>_enabled</key> @@ -516,61 +516,6 @@ </param> </block> <block> - <key>variable_slider</key> - <param> - <key>id</key> - <value>alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>Timing Alpha</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>min</key> - <value>0</value> - </param> - <param> - <key>max</key> - <value>1</value> - </param> - <param> - <key>num_steps</key> - <value>1000</value> - </param> - <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> - </param> - <param> - <key>converver</key> - <value>float_converter</value> - </param> - <param> - <key>grid_pos</key> - <value></value> - </param> - <param> - <key>notebook</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(552, 4)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>variable</key> <param> <key>id</key> @@ -692,61 +637,6 @@ </param> </block> <block> - <key>digital_pfb_clock_sync_xxx</key> - <param> - <key>id</key> - <value>digital_pfb_clock_sync_xxx_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>ccf</value> - </param> - <param> - <key>sps</key> - <value>spb</value> - </param> - <param> - <key>alpha</key> - <value>alpha</value> - </param> - <param> - <key>beta</key> - <value>beta</value> - </param> - <param> - <key>taps</key> - <value>rrctaps</value> - </param> - <param> - <key>filter_size</key> - <value>nfilts</value> - </param> - <param> - <key>init_phase</key> - <value>nfilts/2</value> - </param> - <param> - <key>max_dev</key> - <value>1.5</value> - </param> - <param> - <key>osps</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(492, 519)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>gr_throttle</key> <param> <key>id</key> @@ -778,10 +668,10 @@ </param> </block> <block> - <key>channel_model</key> + <key>channels_channel_model</key> <param> <key>id</key> - <value>channel_model_0</value> + <value>channels_channel_model_0</value> </param> <param> <key>_enabled</key> @@ -817,10 +707,10 @@ </param> </block> <block> - <key>gr_float_to_complex</key> + <key>blocks_float_to_complex</key> <param> <key>id</key> - <value>gr_float_to_complex_0</value> + <value>blocks_float_to_complex_0</value> </param> <param> <key>_enabled</key> @@ -866,6 +756,10 @@ <value>32</value> </param> <param> + <key>atten</key> + <value>100</value> + </param> + <param> <key>_coordinate</key> <value>(788, 173)</value> </param> @@ -875,10 +769,10 @@ </param> </block> <block> - <key>gr_multiply_const_vxx</key> + <key>blocks_multiply_const_vxx</key> <param> <key>id</key> - <value>gr_multiply_const_vxx_0</value> + <value>blocks_multiply_const_vxx_0</value> </param> <param> <key>_enabled</key> @@ -1206,113 +1100,119 @@ </param> </block> <block> - <key>variable_slider</key> + <key>variable</key> <param> <key>id</key> - <value>beta</value> + <value>pam_amp</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Timing Beta</value> + <key>value</key> + <value>2</value> </param> <param> - <key>value</key> + <key>_coordinate</key> + <value>(277, 12)</value> + </param> + <param> + <key>_rotation</key> <value>0</value> </param> + </block> + <block> + <key>variable</key> <param> - <key>min</key> - <value>0.0</value> + <key>id</key> + <value>samp_rate</value> </param> <param> - <key>max</key> - <value>0.1</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>num_steps</key> - <value>1000</value> + <key>value</key> + <value>32000</value> </param> <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> + <key>_coordinate</key> + <value>(182, 12)</value> </param> <param> - <key>converver</key> - <value>float_converter</value> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sig_amp</value> </param> <param> - <key>grid_pos</key> - <value></value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>notebook</key> - <value></value> + <key>value</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(673, 5)</value> + <value>(369, 12)</value> </param> <param> <key>_rotation</key> - <value>180</value> + <value>0</value> </param> </block> <block> - <key>options</key> + <key>digital_pfb_clock_sync_xxx</key> <param> <key>id</key> - <value>pam_timing</value> + <value>digital_pfb_clock_sync_xxx_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>title</key> - <value></value> - </param> - <param> - <key>author</key> - <value></value> - </param> - <param> - <key>description</key> - <value></value> + <key>type</key> + <value>ccf</value> </param> <param> - <key>window_size</key> - <value>1280, 1024</value> + <key>sps</key> + <value>spb</value> </param> <param> - <key>generate_options</key> - <value>wx_gui</value> + <key>loop_bw</key> + <value>loop_bw</value> </param> <param> - <key>category</key> - <value>Custom</value> + <key>taps</key> + <value>rrctaps</value> </param> <param> - <key>run_options</key> - <value>prompt</value> + <key>filter_size</key> + <value>nfilts</value> </param> <param> - <key>run</key> - <value>True</value> + <key>init_phase</key> + <value>nfilts/2</value> </param> <param> - <key>max_nouts</key> - <value>0</value> + <key>max_dev</key> + <value>1.5</value> </param> <param> - <key>realtime_scheduling</key> - <value></value> + <key>osps</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(10, 10)</value> + <value>(492, 519)</value> </param> <param> <key>_rotation</key> @@ -1320,68 +1220,54 @@ </param> </block> <block> - <key>variable</key> + <key>variable_slider</key> <param> <key>id</key> - <value>pam_amp</value> + <value>loop_bw</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>2</value> + <key>label</key> + <value>Loop Bandwidth</value> </param> <param> - <key>_coordinate</key> - <value>(277, 12)</value> + <key>value</key> + <value>6.28/100.0</value> </param> <param> - <key>_rotation</key> + <key>min</key> <value>0</value> </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>samp_rate</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> <param> - <key>value</key> - <value>32000</value> + <key>max</key> + <value>0.2</value> </param> <param> - <key>_coordinate</key> - <value>(182, 12)</value> + <key>num_steps</key> + <value>1000</value> </param> <param> - <key>_rotation</key> - <value>0</value> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> </param> - </block> - <block> - <key>variable</key> <param> - <key>id</key> - <value>sig_amp</value> + <key>converver</key> + <value>float_converter</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>grid_pos</key> + <value></value> </param> <param> - <key>value</key> - <value>1</value> + <key>notebook</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(369, 12)</value> + <value>(552, 4)</value> </param> <param> <key>_rotation</key> @@ -1390,54 +1276,54 @@ </block> <connection> <source_block_id>random_source_x_0</source_block_id> - <sink_block_id>gr_uchar_to_float_0</sink_block_id> + <sink_block_id>blocks_uchar_to_float_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_uchar_to_float_0</source_block_id> - <sink_block_id>gr_add_xx_0</sink_block_id> + <source_block_id>blocks_uchar_to_float_0</source_block_id> + <sink_block_id>blocks_add_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>const_source_x_0</source_block_id> - <sink_block_id>gr_add_xx_0</sink_block_id> + <source_block_id>analog_const_source_x_0</source_block_id> + <sink_block_id>blocks_add_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_uchar_to_float_0_0</source_block_id> - <sink_block_id>gr_add_xx_0_1</sink_block_id> + <source_block_id>blocks_uchar_to_float_0_0</source_block_id> + <sink_block_id>blocks_add_xx_0_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>const_source_x_0_0</source_block_id> - <sink_block_id>gr_add_xx_0_1</sink_block_id> + <source_block_id>analog_const_source_x_0_0</source_block_id> + <sink_block_id>blocks_add_xx_0_1</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> <source_block_id>random_source_x_0_0</source_block_id> - <sink_block_id>gr_uchar_to_float_0_0</sink_block_id> + <sink_block_id>blocks_uchar_to_float_0_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_0</source_block_id> - <sink_block_id>gr_float_to_complex_0</sink_block_id> + <source_block_id>blocks_add_xx_0</source_block_id> + <sink_block_id>blocks_float_to_complex_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_0_1</source_block_id> - <sink_block_id>gr_float_to_complex_0</sink_block_id> + <source_block_id>blocks_add_xx_0_1</source_block_id> + <sink_block_id>blocks_float_to_complex_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_multiply_const_vxx_0</source_block_id> + <source_block_id>blocks_multiply_const_vxx_0</source_block_id> <sink_block_id>wxgui_scopesink2_0_0_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -1473,26 +1359,26 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>channel_model_0</source_block_id> + <source_block_id>channels_channel_model_0</source_block_id> <sink_block_id>gr_throttle_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_const_vxx_0</source_block_id> - <sink_block_id>channel_model_0</sink_block_id> + <source_block_id>blocks_multiply_const_vxx_0</source_block_id> + <sink_block_id>channels_channel_model_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_float_to_complex_0</source_block_id> + <source_block_id>blocks_float_to_complex_0</source_block_id> <sink_block_id>pfb_arb_resampler_xxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>pfb_arb_resampler_xxx_0</source_block_id> - <sink_block_id>gr_multiply_const_vxx_0</sink_block_id> + <sink_block_id>blocks_multiply_const_vxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-digital/examples/narrowband/benchmark_add_channel.py b/gr-digital/examples/narrowband/benchmark_add_channel.py index 0ee0058059..05b55e3755 100755 --- a/gr-digital/examples/narrowband/benchmark_add_channel.py +++ b/gr-digital/examples/narrowband/benchmark_add_channel.py @@ -21,6 +21,7 @@ # from gnuradio import gr, filter +from gnuradio import blocks from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -46,7 +47,7 @@ class my_top_block(gr.top_block): self.channel = filter.channel_model(noise_voltage, frequency_offset, time_offset, noise_seed=-random.randint(0,100000)) - self.phase = gr.multiply_const_cc(complex(math.cos(phase_offset), + self.phase = blocks.multiply_const_cc(complex(math.cos(phase_offset), math.sin(phase_offset))) self.snk = gr.file_sink(gr.sizeof_gr_complex, ofile) diff --git a/gr-digital/examples/narrowband/digital_bert_tx.py b/gr-digital/examples/narrowband/digital_bert_tx.py index ff8bf9f104..5559f8698e 100755 --- a/gr-digital/examples/narrowband/digital_bert_tx.py +++ b/gr-digital/examples/narrowband/digital_bert_tx.py @@ -25,6 +25,7 @@ from gnuradio.eng_option import eng_option from optparse import OptionParser import sys +from gnuradio import blocks from gnuradio import digital # from current dir @@ -90,7 +91,7 @@ class tx_psk_block(gr.top_block): verbose=options.verbose, log=options.log) - self.amp = gr.multiply_const_cc(options.amplitude) + self.amp = blocks.multiply_const_cc(options.amplitude) self.connect(self._transmitter, self.amp, self._sink) diff --git a/gr-digital/examples/narrowband/rx_voice.py b/gr-digital/examples/narrowband/rx_voice.py index 079f8cb9b9..b1a1b0782e 100755 --- a/gr-digital/examples/narrowband/rx_voice.py +++ b/gr-digital/examples/narrowband/rx_voice.py @@ -26,6 +26,7 @@ from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser +from gnuradio import blocks from gnuradio import digital from gnuradio import vocoder @@ -51,8 +52,8 @@ class audio_tx(gr.hier_block2): self.sample_rate = sample_rate = 8000 self.packet_src = gr.message_source(33) voice_decoder = vocoder.gsm_fr_decode_ps() - s2f = gr.short_to_float () - sink_scale = gr.multiply_const_ff(1.0/32767.) + s2f = blocks.short_to_float() + sink_scale = blocks.multiply_const_ff(1.0/32767.) audio_sink = audio.sink(sample_rate, audio_output_dev) self.connect(self.packet_src, voice_decoder, s2f, sink_scale, audio_sink) diff --git a/gr-digital/examples/narrowband/transmit_path.py b/gr-digital/examples/narrowband/transmit_path.py index ec87ecd825..43a96050e9 100644 --- a/gr-digital/examples/narrowband/transmit_path.py +++ b/gr-digital/examples/narrowband/transmit_path.py @@ -21,6 +21,7 @@ from gnuradio import gr from gnuradio import eng_notation +from gnuradio import blocks from gnuradio import digital import copy @@ -58,7 +59,7 @@ class transmit_path(gr.hier_block2): msgq_limit=4, pad_for_usrp=True) - self.amp = gr.multiply_const_cc(1) + self.amp = blocks.multiply_const_cc(1) self.set_tx_amplitude(self._tx_amplitude) # Display some information about the setup diff --git a/gr-digital/examples/narrowband/tx_voice.py b/gr-digital/examples/narrowband/tx_voice.py index 1f968fa8a3..d3c81694ab 100755 --- a/gr-digital/examples/narrowband/tx_voice.py +++ b/gr-digital/examples/narrowband/tx_voice.py @@ -25,6 +25,7 @@ from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser +from gnuradio import blocks from gnuradio import filter from gnuradio import digital from gnuradio import vocoder @@ -50,8 +51,8 @@ class audio_rx(gr.hier_block2): gr.io_signature(0, 0, 0)) # Output signature self.sample_rate = sample_rate = 8000 src = audio.source(sample_rate, audio_input_dev) - src_scale = gr.multiply_const_ff(32767) - f2s = gr.float_to_short() + src_scale = blocks.multiply_const_ff(32767) + f2s = blocks.float_to_short() voice_coder = vocoder.gsm_fr_encode_sp() self.packets_from_encoder = gr.msg_queue() packet_sink = gr.message_sink(33, self.packets_from_encoder, False) diff --git a/gr-digital/examples/ofdm/benchmark_add_channel.py b/gr-digital/examples/ofdm/benchmark_add_channel.py index 5c7a3ae501..369087b4c1 100755 --- a/gr-digital/examples/ofdm/benchmark_add_channel.py +++ b/gr-digital/examples/ofdm/benchmark_add_channel.py @@ -21,6 +21,7 @@ # from gnuradio import gr, filter +from gnuradio import blocks from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -48,7 +49,7 @@ class my_top_block(gr.top_block): self.channel = filter.channel_model(noise_voltage, frequency_offset, time_offset, noise_seed=-random.randint(0,100000)) - self.phase = gr.multiply_const_cc(complex(math.cos(phase_offset), + self.phase = blocks.multiply_const_cc(complex(math.cos(phase_offset), math.sin(phase_offset))) self.snk = gr.file_sink(gr.sizeof_gr_complex, ofile) diff --git a/gr-digital/examples/ofdm/transmit_path.py b/gr-digital/examples/ofdm/transmit_path.py index 6fb66e4076..aa146cea96 100644 --- a/gr-digital/examples/ofdm/transmit_path.py +++ b/gr-digital/examples/ofdm/transmit_path.py @@ -21,6 +21,7 @@ from gnuradio import gr from gnuradio import eng_notation +from gnuradio import blocks from gnuradio import digital import copy @@ -49,7 +50,7 @@ class transmit_path(gr.hier_block2): msgq_limit=4, pad_for_usrp=False) - self.amp = gr.multiply_const_cc(1) + self.amp = blocks.multiply_const_cc(1) self.set_tx_amplitude(self._tx_amplitude) # Display some information about the setup diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt index c5d9a63189..398285a228 100644 --- a/gr-digital/lib/CMakeLists.txt +++ b/gr-digital/lib/CMakeLists.txt @@ -23,6 +23,7 @@ include_directories( ${VOLK_INCLUDE_DIRS} ${GNURADIO_CORE_INCLUDE_DIRS} + ${GR_BLOCKS_INCLUDE_DIRS} ${GR_ANALOG_INCLUDE_DIRS} ${GR_DIGITAL_INCLUDE_DIRS} ${GR_FFT_INCLUDE_DIRS} @@ -156,6 +157,7 @@ list(APPEND digital_libs volk gnuradio-core gnuradio-filter + gnuradio-blocks gnuradio-analog ${Boost_LIBRARIES} ) diff --git a/gr-digital/lib/cpmmod_bc_impl.cc b/gr-digital/lib/cpmmod_bc_impl.cc index d6c3a29a29..763a4cc1e2 100644 --- a/gr-digital/lib/cpmmod_bc_impl.cc +++ b/gr-digital/lib/cpmmod_bc_impl.cc @@ -60,7 +60,7 @@ namespace gr { gr_make_io_signature2(1, 1, sizeof(gr_complex), sizeof(float))), d_type(type), d_index(h), d_sps(samples_per_sym), d_length(L), d_beta(beta), d_taps(analog::cpm::phase_response(type, samples_per_sym, L, beta)), - d_char_to_float(gr_make_char_to_float()), + d_char_to_float(blocks::char_to_float::make()), d_pulse_shaper(filter::interp_fir_filter_fff::make(samples_per_sym, d_taps)), d_fm(analog::frequency_modulator_fc::make(M_PI * h)) { diff --git a/gr-digital/lib/cpmmod_bc_impl.h b/gr-digital/lib/cpmmod_bc_impl.h index 3051e49df9..9cfec4959e 100644 --- a/gr-digital/lib/cpmmod_bc_impl.h +++ b/gr-digital/lib/cpmmod_bc_impl.h @@ -24,7 +24,7 @@ #define INCLUDED_DIGITAL_CPMMOD_BC_IMPL_H #include <digital/cpmmod_bc.h> -#include <gr_char_to_float.h> +#include <blocks/char_to_float.h> #include <analog/frequency_modulator_fc.h> #include <filter/interp_fir_filter_fff.h> @@ -42,7 +42,7 @@ namespace gr { protected: std::vector<float> d_taps; - gr_char_to_float_sptr d_char_to_float; + gr::blocks::char_to_float::sptr d_char_to_float; gr::filter::interp_fir_filter_fff::sptr d_pulse_shaper; analog::frequency_modulator_fc::sptr d_fm; diff --git a/gr-digital/python/CMakeLists.txt b/gr-digital/python/CMakeLists.txt index 2b12799b56..c44248d54c 100644 --- a/gr-digital/python/CMakeLists.txt +++ b/gr-digital/python/CMakeLists.txt @@ -70,6 +70,8 @@ list(APPEND GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/gr-filter/swig ${CMAKE_BINARY_DIR}/gr-analog/python ${CMAKE_BINARY_DIR}/gr-analog/swig + ${CMAKE_BINARY_DIR}/gr-blocks/python + ${CMAKE_BINARY_DIR}/gr-blocks/swig ) list(APPEND GR_TEST_TARGET_DEPS gnuradio-digital gnuradio-filter gnuradio-fft gnuradio-analog) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/digital_voice.py.real b/gr-digital/python/digital_voice.py.real index 6ec66825c1..4a2ef7721f 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/digital_voice.py.real +++ b/gr-digital/python/digital_voice.py.real @@ -28,6 +28,7 @@ but there's room for a rate 1/2 coder. """ from gnuradio import gr, gru +from gnuradio import blocks from gnuradio.blksimpl.gmsk import gmsk_mod, gmsk_demod from gnuradio.vocoder import gsm_full_rate @@ -61,8 +62,8 @@ class digital_voice_tx(gr.hier_block): symbol_rate = 32000 bt = 0.3 # Gaussian filter bandwidth * symbol time - src_scale = gr.multiply_const_ff(32767) - f2s = gr.float_to_short() + src_scale = blocks.multiply_const_ff(32767) + f2s = blocks.float_to_short() voice_coder = gsm_full_rate.encode_sp() channel_coder = gr.fake_channel_encoder_pp(GSM_FRAME_SIZE, AIR_FRAME_SIZE) @@ -95,8 +96,8 @@ class digital_voice_rx(gr.hier_block): channel_decoder = gr.fake_channel_decoder_pp(AIR_FRAME_SIZE, GSM_FRAME_SIZE) voice_decoder = gsm_full_rate.decode_ps() - s2f = gr.short_to_float () - sink_scale = gr.multiply_const_ff(1.0/32767.) + s2f = blocks.short_to_float () + sink_scale = blocks.multiply_const_ff(1.0/32767.) fg.connect(demod, s2p, channel_decoder, voice_decoder, s2f, sink_scale) gr.hier_block.__init__(self, fg, demod, sink_scale) diff --git a/gr-digital/python/gfsk.py b/gr-digital/python/gfsk.py index c69dd4d7d8..42d65d36ce 100644 --- a/gr-digital/python/gfsk.py +++ b/gr-digital/python/gfsk.py @@ -26,6 +26,7 @@ from gnuradio import gr from gnuradio import analog +from gnuradio import blocks import modulation_utils import digital_swig as digital from math import pi @@ -118,7 +119,7 @@ class gfsk_mod(gr.hier_block2): self.fmmod = frequency.frequency_modulator_fc(sensitivity) # small amount of output attenuation to prevent clipping USRP sink - self.amp = gr.multiply_const_cc(0.999) + self.amp = blocks.multiply_const_cc(0.999) if verbose: self._print_verbage() diff --git a/gr-digital/python/ofdm.py b/gr-digital/python/ofdm.py index 4113a552eb..5bbe111f31 100644 --- a/gr-digital/python/ofdm.py +++ b/gr-digital/python/ofdm.py @@ -22,6 +22,7 @@ import math from gnuradio import gr, fft +from gnuradio import blocks import digital_swig as digital import ofdm_packet_utils from ofdm_receiver import ofdm_receiver @@ -107,7 +108,7 @@ class ofdm_mod(gr.hier_block2): self.ifft = fft.fft_vcc(self._fft_length, False, win, True) self.cp_adder = digital.ofdm_cyclic_prefixer(self._fft_length, symbol_length) - self.scale = gr.multiply_const_cc(1.0 / math.sqrt(self._fft_length)) + self.scale = blocks.multiply_const_cc(1.0 / math.sqrt(self._fft_length)) self.connect((self._pkt_input, 0), (self.preambles, 0)) self.connect((self._pkt_input, 1), (self.preambles, 1)) diff --git a/gr-digital/python/ofdm_receiver.py b/gr-digital/python/ofdm_receiver.py index ace64a8089..c5725bab28 100644 --- a/gr-digital/python/ofdm_receiver.py +++ b/gr-digital/python/ofdm_receiver.py @@ -24,6 +24,7 @@ import math from numpy import fft from gnuradio import gr from gnuradio import analog +from gnuradio import blocks import digital_swig as digital from ofdm_sync_pn import ofdm_sync_pn @@ -108,7 +109,7 @@ class ofdm_receiver(gr.hier_block2): # for testing only; do not user over the air # remove filter and filter delay for this elif SYNC == "fixed": - self.chan_filt = gr.multiply_const_cc(1.0) + self.chan_filt = blocks.multiply_const_cc(1.0) nsymbols = 18 # enter the number of symbols per packet freq_offset = 0.0 # if you use a frequency offset, enter it here nco_sensitivity = -2.0/fft_length # correct for fine frequency @@ -121,7 +122,7 @@ class ofdm_receiver(gr.hier_block2): # Set up blocks self.nco = analog.frequency_modulator_fc(nco_sensitivity) # generate a signal proportional to frequency error of sync block - self.sigmix = gr.multiply_cc() + self.sigmix = blocks.multiply_cc() self.sampler = digital.ofdm_sampler(fft_length, fft_length+cp_length) self.fft_demod = gr.fft_vcc(fft_length, True, win, True) self.ofdm_frame_acq = digital.ofdm_frame_acquisition(occupied_tones, diff --git a/gr-digital/python/ofdm_sync_ml.py b/gr-digital/python/ofdm_sync_ml.py index f732fdf29a..885531f66a 100644 --- a/gr-digital/python/ofdm_sync_ml.py +++ b/gr-digital/python/ofdm_sync_ml.py @@ -28,6 +28,11 @@ try: except ImportError: import filter_swig as filter +try: + from gnuradio import blocks +except ImportError: + import blocks_swig as blocks + class ofdm_sync_ml(gr.hier_block2): def __init__(self, fft_length, cp_length, snr, kstime, logging): ''' Maximum Likelihood OFDM synchronizer: @@ -40,7 +45,7 @@ class ofdm_sync_ml(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature - self.input = gr.add_const_cc(0) + self.input = blocks.add_const_cc(0) SNR = 10.0**(snr/10.0) rho = SNR / (SNR + 1.0) @@ -59,7 +64,7 @@ class ofdm_sync_ml(gr.hier_block2): # magnitude squared blocks self.magsqrd1 = gr.complex_to_mag_squared() self.magsqrd2 = gr.complex_to_mag_squared() - self.adder = gr.add_ff() + self.adder = blocks.add_ff() moving_sum_taps = [rho/2 for i in range(cp_length)] self.moving_sum_filter = filter.fir_filter_fff(1,moving_sum_taps) @@ -72,8 +77,8 @@ class ofdm_sync_ml(gr.hier_block2): # Correlation from ML Sync - self.conjg = gr.conjugate_cc(); - self.mixer = gr.multiply_cc(); + self.conjg = blocks.conjugate_cc(); + self.mixer = blocks.multiply_cc(); movingsum2_taps = [1.0 for i in range(cp_length)] self.movingsum2 = filter.fir_filter_ccf(1,movingsum2_taps) @@ -87,12 +92,12 @@ class ofdm_sync_ml(gr.hier_block2): self.connect(self.movingsum2,self.angle) # ML Sync output arg, need to find maximum point of this - self.diff = gr.sub_ff() + self.diff = blocks.sub_ff() self.connect(self.c2mag,(self.diff,0)) self.connect(self.moving_sum_filter,(self.diff,1)) #ML measurements input to sampler block and detect - self.f2c = gr.float_to_complex() + self.f2c = blocks.float_to_complex() self.pk_detect = gr.peak_detector_fb(0.2, 0.25, 30, 0.0005) self.sample_and_hold = gr.sample_and_hold_ff() @@ -122,7 +127,7 @@ class ofdm_sync_ml(gr.hier_block2): kstime.reverse() self.kscorr = filter.fir_filter_ccc(1, kstime) self.corrmag = gr.complex_to_mag_squared() - self.div = gr.divide_ff() + self.div = blocks.divide_ff() # The output signature of the correlation has a few spikes because the rest of the # system uses the repeated preamble symbol. It needs to work that generically if @@ -131,9 +136,9 @@ class ofdm_sync_ml(gr.hier_block2): # identify the proper peak and remove other products in this cross-correlation self.threshold_factor = 0.1 self.slice = gr.threshold_ff(self.threshold_factor, self.threshold_factor, 0) - self.f2b = gr.float_to_char() - self.b2f = gr.char_to_float() - self.mul = gr.multiply_ff() + self.f2b = blocks.float_to_char() + self.b2f = blocks.char_to_float() + self.mul = blocks.multiply_ff() # Normalize the power of the corr output by the energy. This is not really needed # and could be removed for performance, but it makes for a cleaner signal. diff --git a/gr-digital/python/ofdm_sync_pn.py b/gr-digital/python/ofdm_sync_pn.py index 8307a8ee14..fb011bf252 100644 --- a/gr-digital/python/ofdm_sync_pn.py +++ b/gr-digital/python/ofdm_sync_pn.py @@ -29,6 +29,11 @@ try: except ImportError: import filter_swig as filter +try: + from gnuradio import blocks +except ImportError: + import blocks_swig as blocks + class ofdm_sync_pn(gr.hier_block2): def __init__(self, fft_length, cp_length, logging=False): """ @@ -42,7 +47,7 @@ class ofdm_sync_pn(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature - self.input = gr.add_const_cc(0) + self.input = blocks.add_const_cc(0) # PN Sync @@ -50,8 +55,8 @@ class ofdm_sync_pn(gr.hier_block2): self.delay = gr.delay(gr.sizeof_gr_complex, fft_length/2) # Correlation from ML Sync - self.conjg = gr.conjugate_cc(); - self.corr = gr.multiply_cc(); + self.conjg = blocks.conjugate_cc(); + self.corr = blocks.multiply_cc(); # Create a moving sum filter for the corr output if 1: @@ -70,8 +75,8 @@ class ofdm_sync_pn(gr.hier_block2): else: self.inputmovingsum = filter.fft_filter_fff(1,movingsum2_taps) - self.square = gr.multiply_ff() - self.normalize = gr.divide_ff() + self.square = blocks.multiply_ff() + self.normalize = blocks.divide_ff() # Get magnitude (peaks) and angle (phase/freq error) self.c2mag = gr.complex_to_mag_squared() @@ -80,7 +85,7 @@ class ofdm_sync_pn(gr.hier_block2): self.sample_and_hold = gr.sample_and_hold_ff() #ML measurements input to sampler block and detect - self.sub1 = gr.add_const_ff(-1) + self.sub1 = blocks.add_const_ff(-1) self.pk_detect = gr.peak_detector_fb(0.20, 0.20, 30, 0.001) #self.pk_detect = gr.peak_detector2_fb(9) diff --git a/gr-digital/python/ofdm_sync_pnac.py b/gr-digital/python/ofdm_sync_pnac.py index a5edc272a8..9b0302ffbb 100644 --- a/gr-digital/python/ofdm_sync_pnac.py +++ b/gr-digital/python/ofdm_sync_pnac.py @@ -29,6 +29,11 @@ try: except ImportError: import filter_swig as filter +try: + from gnuradio import blocks +except ImportError: + import blocks_swig as blocks + class ofdm_sync_pnac(gr.hier_block2): def __init__(self, fft_length, cp_length, kstime, logging=False): """ @@ -55,7 +60,7 @@ class ofdm_sync_pnac(gr.hier_block2): gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature - self.input = gr.add_const_cc(0) + self.input = blocks.add_const_cc(0) symbol_length = fft_length + cp_length @@ -70,8 +75,8 @@ class ofdm_sync_pnac(gr.hier_block2): self.delay = gr.delay(gr.sizeof_gr_complex, fft_length/2) # Correlation from ML Sync - self.conjg = gr.conjugate_cc(); - self.corr = gr.multiply_cc(); + self.conjg = blocks.conjugate_cc(); + self.corr = blocks.multiply_cc(); # Create a moving sum filter for the input self.mag = gr.complex_to_mag_squared() @@ -81,13 +86,13 @@ class ofdm_sync_pnac(gr.hier_block2): # Get magnitude (peaks) and angle (phase/freq error) self.c2mag = gr.complex_to_mag_squared() self.angle = gr.complex_to_arg() - self.compare = gr.sub_ff() + self.compare = blocks.sub_ff() self.sample_and_hold = gr.sample_and_hold_ff() #ML measurements input to sampler block and detect self.threshold = gr.threshold_ff(0,0,0) # threshold detection might need to be tweaked - self.peaks = gr.float_to_char() + self.peaks = blocksx.float_to_char() self.connect(self, self.input) diff --git a/gr-digital/python/qa_constellation.py b/gr-digital/python/qa_constellation.py index 9d6f4c6427..3c109cfe82 100755 --- a/gr-digital/python/qa_constellation.py +++ b/gr-digital/python/qa_constellation.py @@ -26,6 +26,7 @@ from cmath import exp, pi, log from gnuradio import gr, gr_unittest from utils import mod_codes import digital_swig as digital +import blocks_swig as blocks # import from local folder import psk @@ -192,7 +193,7 @@ class mod_demod(gr.hier_block2): # CHANNEL # Channel just consists of a rotation to check differential coding. if rotation is not None: - self.blocks.append(gr.multiply_const_cc(rotation)) + self.blocks.append(blocks.multiply_const_cc(rotation)) # RX # Convert the constellation symbols back to binary values. diff --git a/gr-digital/python/qa_constellation_receiver.py b/gr-digital/python/qa_constellation_receiver.py index 6da3fc1066..254a8240d4 100755 --- a/gr-digital/python/qa_constellation_receiver.py +++ b/gr-digital/python/qa_constellation_receiver.py @@ -27,6 +27,7 @@ from utils import mod_codes, alignment import packet_utils import filter_swig as filter import analog_swig as analog +import blocks_swig as blocks from generic_mod_demod import generic_mod, generic_demod from qa_constellation import tested_constellations, twod_constell @@ -60,12 +61,12 @@ class channel_model(gr.hier_block2): timing_offset = filter.fractional_interpolator_cc(0, timing) - noise_adder = gr.add_cc() + noise_adder = blocks.add_cc() noise = analog.noise_source_c(analog.GR_GAUSSIAN, noise_voltage, 0) freq_offset = analog.sig_source_c(1, analog.GR_SIN_WAVE, freq, 1.0, 0.0) - mixer_offset = gr.multiply_cc(); + mixer_offset = blocks.multiply_cc(); self.connect(self, timing_offset) self.connect(timing_offset, (mixer_offset,0)) diff --git a/gr-digital/python/qa_fll_band_edge.py b/gr-digital/python/qa_fll_band_edge.py index 1e699bbdd4..0f6bad984e 100755 --- a/gr-digital/python/qa_fll_band_edge.py +++ b/gr-digital/python/qa_fll_band_edge.py @@ -23,6 +23,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital import filter_swig as filter +import blocks_swig as blocks import analog_swig as analog import random, math @@ -55,7 +56,7 @@ class test_fll_band_edge_cc(gr_unittest.TestCase): # Mix symbols with a complex sinusoid to spin them self.nco = analog.sig_source_c(1, analog.GR_SIN_WAVE, foffset, 1) - self.mix = gr.multiply_cc() + self.mix = blocks.multiply_cc() # FLL will despin the symbols to an arbitrary phase self.fll = digital.fll_band_edge_cc(sps, rolloff, ntaps, bw) diff --git a/gr-digital/python/qa_ofdm_insert_preamble.py b/gr-digital/python/qa_ofdm_insert_preamble.py index d084796644..60902edc14 100755 --- a/gr-digital/python/qa_ofdm_insert_preamble.py +++ b/gr-digital/python/qa_ofdm_insert_preamble.py @@ -23,6 +23,7 @@ from gnuradio import gr, gr_unittest from pprint import pprint import digital_swig as digital +import blocks_swig as blocks class test_ofdm_insert_preamble(gr_unittest.TestCase): @@ -37,13 +38,13 @@ class test_ofdm_insert_preamble(gr_unittest.TestCase): src0 = gr.vector_source_c(v0) src1 = gr.vector_source_b(v1) - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_length) + s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, fft_length) # print "len(v) = %d" % (len(v)) op = digital.ofdm_insert_preamble(fft_length, preamble) - v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_length) + v2s = blocks.vector_to_stream(gr.sizeof_gr_complex, fft_length) dst0 = gr.vector_sink_c() dst1 = gr.vector_sink_b() diff --git a/gr-digital/python/qa_pn_correlator_cc.py b/gr-digital/python/qa_pn_correlator_cc.py index 4e81bf6662..53633d04fa 100755 --- a/gr-digital/python/qa_pn_correlator_cc.py +++ b/gr-digital/python/qa_pn_correlator_cc.py @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks class test_pn_correlator_cc(gr_unittest.TestCase): @@ -39,7 +40,7 @@ class test_pn_correlator_cc(gr_unittest.TestCase): length = 2**degree-1 src = digital.glfsr_source_f(degree) head = gr.head(gr.sizeof_float, length*length) - f2c = gr.float_to_complex() + f2c = blocks.float_to_complex() corr = digital.pn_correlator_cc(degree) dst = gr.vector_sink_c() self.tb.connect(src, head, f2c, corr, dst) diff --git a/gr-fcd/CMakeLists.txt b/gr-fcd/CMakeLists.txt index ff61ce28c6..810e79e6eb 100644 --- a/gr-fcd/CMakeLists.txt +++ b/gr-fcd/CMakeLists.txt @@ -35,6 +35,7 @@ if (LINUX) GR_REGISTER_COMPONENT("gr-fcd" ENABLE_GR_FCD Boost_FOUND ENABLE_GR_CORE + ENABLE_GR_BLOCKS ENABLE_GR_AUDIO LIBUSB_FOUND ) diff --git a/gr-fcd/examples/grc/fcd_nfm_rx.grc b/gr-fcd/examples/grc/fcd_nfm_rx.grc index 98d06d9ef1..96d6f55e2e 100644 --- a/gr-fcd/examples/grc/fcd_nfm_rx.grc +++ b/gr-fcd/examples/grc/fcd_nfm_rx.grc @@ -379,10 +379,10 @@ </param> </block> <block> - <key>gr_multiply_const_vxx</key> + <key>blocks_multiply_const_vxx</key> <param> <key>id</key> - <value>gr_multiply_const_vxx_1</value> + <value>blocks_multiply_const_vxx_1</value> </param> <param> <key>_enabled</key> @@ -997,20 +997,20 @@ </param> </block> <connection> - <source_block_id>gr_multiply_const_vxx_1</source_block_id> + <source_block_id>blocks_multiply_const_vxx_1</source_block_id> <sink_block_id>audio_sink</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_multiply_const_vxx_1</source_block_id> + <source_block_id>blocks_multiply_const_vxx_1</source_block_id> <sink_block_id>audio_sink</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>nbfm_normal</source_block_id> - <sink_block_id>gr_multiply_const_vxx_1</sink_block_id> + <sink_block_id>blocks_multiply_const_vxx_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-fcd/lib/CMakeLists.txt b/gr-fcd/lib/CMakeLists.txt index 9a5605d99c..dd0778deef 100644 --- a/gr-fcd/lib/CMakeLists.txt +++ b/gr-fcd/lib/CMakeLists.txt @@ -26,6 +26,7 @@ GR_INCLUDE_SUBDIRECTORY(fcd) include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} ${GR_FCD_INCLUDE_DIRS} + ${GR_BLOCKS_INCLUDE_DIRS} ${GR_AUDIO_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/hid ${CMAKE_CURRENT_SOURCE_DIR}/fcd @@ -44,6 +45,7 @@ list(APPEND gr_fcd_sources list(APPEND fcd_libs gnuradio-core + gnuradio-blocks gnuradio-audio ${Boost_LIBRARIES} ) diff --git a/gr-fcd/lib/fcd_source_c_impl.cc b/gr-fcd/lib/fcd_source_c_impl.cc index 81ccee092d..9d66e8bb4f 100644 --- a/gr-fcd/lib/fcd_source_c_impl.cc +++ b/gr-fcd/lib/fcd_source_c_impl.cc @@ -26,7 +26,7 @@ #include <fcd.h> #include <fcdhidcmd.h> // needed for extended API #include <gr_io_signature.h> -#include <gr_float_to_complex.h> +#include <blocks/float_to_complex.h> #include <gruel/attributes.h> //#include <iostream> @@ -53,13 +53,13 @@ fcd_source_c_impl::fcd_source_c_impl(const std::string device_name) d_freq_corr(-120), d_freq_req(0) { - gr_float_to_complex_sptr f2c; + gr::blocks::float_to_complex::sptr f2c; /* Audio source; sample rate fixed at 96kHz */ fcd = audio_make_source(96000, device_name, true); /* block to convert stereo audio to a complex stream */ - f2c = gr_make_float_to_complex(1); + f2c = gr::blocks::float_to_complex::make(1); connect(fcd, 0, f2c, 0); connect(fcd, 1, f2c, 1); diff --git a/gr-fec/CMakeLists.txt b/gr-fec/CMakeLists.txt index e072ce337e..256f419c87 100644 --- a/gr-fec/CMakeLists.txt +++ b/gr-fec/CMakeLists.txt @@ -31,6 +31,7 @@ GR_REGISTER_COMPONENT("gr-fec" ENABLE_GR_FEC Boost_FOUND ENABLE_GRUEL ENABLE_GR_CORE + ENABLE_GR_BLOCKS ) GR_SET_GLOBAL(GR_FEC_INCLUDE_DIRS diff --git a/gr-fec/python/CMakeLists.txt b/gr-fec/python/CMakeLists.txt index 6af4df2aec..a05981c8e6 100644 --- a/gr-fec/python/CMakeLists.txt +++ b/gr-fec/python/CMakeLists.txt @@ -35,6 +35,8 @@ if(ENABLE_TESTING) list(APPEND GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/gr-fec/python ${CMAKE_BINARY_DIR}/gr-fec/swig + ${CMAKE_BINARY_DIR}/gr-blocks/python + ${CMAKE_BINARY_DIR}/gr-blocks/swig ) list(APPEND GR_TEST_TARGET_DEPS gnuradio-fec) diff --git a/gr-fec/python/qa_ecc_ccsds_27.py b/gr-fec/python/qa_ecc_ccsds_27.py index cded055b4a..52615abe23 100755 --- a/gr-fec/python/qa_ecc_ccsds_27.py +++ b/gr-fec/python/qa_ecc_ccsds_27.py @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import fec_swig as fec +import blocks_swig as blocks class test_ccsds_27 (gr_unittest.TestCase): @@ -36,9 +37,9 @@ class test_ccsds_27 (gr_unittest.TestCase): expected = (0, 0, 0, 0, 1, 2, 3, 4, 5, 6) src = gr.vector_source_b(src_data) enc = fec.encode_ccsds_27_bb() - b2f = gr.char_to_float() - add = gr.add_const_ff(-0.5) - mul = gr.multiply_const_ff(2.0) + b2f = blocks.char_to_float() + add = blocks.add_const_ff(-0.5) + mul = blocks.multiply_const_ff(2.0) dec = fec.decode_ccsds_27_fb() dst = gr.vector_sink_b() self.tb.connect(src, enc, b2f, add, mul, dec, dst) diff --git a/gr-fft/CMakeLists.txt b/gr-fft/CMakeLists.txt index 7d76dc7f93..6b37bd3caa 100644 --- a/gr-fft/CMakeLists.txt +++ b/gr-fft/CMakeLists.txt @@ -34,6 +34,7 @@ GR_REGISTER_COMPONENT("gr-fft" ENABLE_GR_FFT ENABLE_VOLK Boost_FOUND ENABLE_GR_CORE + ENABLE_GR_BLOCKS FFTW3F_FOUND ) diff --git a/gr-fft/grc/fft_fft_vxx.xml b/gr-fft/grc/fft_fft_vxx.xml index 69f12ace77..028721fe25 100644 --- a/gr-fft/grc/fft_fft_vxx.xml +++ b/gr-fft/grc/fft_fft_vxx.xml @@ -8,7 +8,7 @@ <name>FFT</name> <key>fft_vxx</key> <import>from gnuradio import fft</import> - <import>from gnuradio import window</import> + <import>from gnuradio.fft import window</import> <make>#if $type() == "complex" fft.fft_vcc($fft_size, $forward, $window, $shift, $nthreads) #else diff --git a/gr-fft/python/CMakeLists.txt b/gr-fft/python/CMakeLists.txt index c259035c33..415d87e2e8 100644 --- a/gr-fft/python/CMakeLists.txt +++ b/gr-fft/python/CMakeLists.txt @@ -24,6 +24,7 @@ GR_PYTHON_INSTALL( FILES __init__.py logpwrfft.py + window.py DESTINATION ${GR_PYTHON_DIR}/gnuradio/fft COMPONENT "fft_python" ) @@ -36,6 +37,8 @@ if(ENABLE_TESTING) list(APPEND GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/gr-fft/python ${CMAKE_BINARY_DIR}/gr-fft/swig + ${CMAKE_BINARY_DIR}/gr-blocks/python + ${CMAKE_BINARY_DIR}/gr-blocks/swig ) list(APPEND GR_TEST_TARGET_DEPS gnuradio-fft) diff --git a/gr-fft/python/__init__.py b/gr-fft/python/__init__.py index a532109b70..093cc3c696 100644 --- a/gr-fft/python/__init__.py +++ b/gr-fft/python/__init__.py @@ -25,4 +25,4 @@ processing blocks for FFT and related functions. ''' from fft_swig import * -from logpwrfft import * +from window import * diff --git a/gr-fft/python/logpwrfft.py b/gr-fft/python/logpwrfft.py index f48b60518f..0513169275 100644 --- a/gr-fft/python/logpwrfft.py +++ b/gr-fft/python/logpwrfft.py @@ -19,11 +19,12 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, window -from gnuradio.blks2 import stream_to_vector_decimator +from gnuradio import gr +from gnuradio import blocks import sys, math import fft_swig as fft +import window try: from gnuradio import filter @@ -54,10 +55,10 @@ class _logpwrfft_base(gr.hier_block2): gr.io_signature(1, 1, self._item_size), # Input signature gr.io_signature(1, 1, gr.sizeof_float*fft_size)) # Output signature - self._sd = stream_to_vector_decimator(item_size=self._item_size, - sample_rate=sample_rate, - vec_rate=frame_rate, - vec_len=fft_size) + self._sd = blocks.stream_to_vector_decimator(item_size=self._item_size, + sample_rate=sample_rate, + vec_rate=frame_rate, + vec_len=fft_size) if win is None: win = window.blackmanharris fft_window = win(fft_size) @@ -66,10 +67,10 @@ class _logpwrfft_base(gr.hier_block2): c2magsq = gr.complex_to_mag_squared(fft_size) self._avg = filter.single_pole_iir_filter_ff(1.0, fft_size) - self._log = gr.nlog10_ff(10, fft_size, - -20*math.log10(fft_size) # Adjust for number of bins - -10*math.log10(window_power/fft_size) # Adjust for windowing loss - -20*math.log10(ref_scale/2)) # Adjust for reference scale + self._log = blocks.nlog10_ff(10, fft_size, + -20*math.log10(fft_size) # Adjust for number of bins + -10*math.log10(window_power/fft_size) # Adjust for windowing loss + -20*math.log10(ref_scale/2)) # Adjust for reference scale self.connect(self, self._sd, fft, c2magsq, self._avg, self._log, self) self._average = average diff --git a/gr-fft/python/qa_fft.py b/gr-fft/python/qa_fft.py index 1c45ac1484..0a66a2c1fc 100755 --- a/gr-fft/python/qa_fft.py +++ b/gr-fft/python/qa_fft.py @@ -21,6 +21,7 @@ from gnuradio import gr, gr_unittest import fft_swig as fft +import blocks_swig as blocks import sys import random @@ -87,9 +88,9 @@ class test_fft(gr_unittest.TestCase): (1646.539306640625-1694.1956787109375j)) src = gr.vector_source_c(src_data) - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_size) + s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, fft_size) op = fft.fft_vcc(fft_size, True, [], False) - v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size) + v2s = blocks.vector_to_stream(gr.sizeof_gr_complex, fft_size) dst = gr.vector_sink_c() tb.connect(src, s2v, op, v2s, dst) tb.run() @@ -141,9 +142,9 @@ class test_fft(gr_unittest.TestCase): expected_result = tuple([complex(primes[2*i], primes[2*i+1]) for i in range(fft_size)]) src = gr.vector_source_c(src_data) - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_size) + s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, fft_size) op = fft.fft_vcc(fft_size, False, [], False) - v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size) + v2s = blocks.vector_to_stream(gr.sizeof_gr_complex, fft_size) dst = gr.vector_sink_c() tb.connect(src, s2v, op, v2s, dst) tb.run() @@ -199,9 +200,9 @@ class test_fft(gr_unittest.TestCase): nthreads = 2 src = gr.vector_source_c(src_data) - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_size) + s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, fft_size) op = fft.fft_vcc(fft_size, False, [], False, nthreads) - v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size) + v2s = blocks.vector_to_stream(gr.sizeof_gr_complex, fft_size) dst = gr.vector_sink_c() tb.connect(src, s2v, op, v2s, dst) tb.run() diff --git a/gnuradio-core/src/python/gnuradio/window.py b/gr-fft/python/window.py index 4a1d0c5161..0065a08a61 100644 --- a/gnuradio-core/src/python/gnuradio/window.py +++ b/gr-fft/python/window.py @@ -24,7 +24,6 @@ Routines for designing window functions. ''' import math -from gnuradio import gr def izero(x): izeroepsilon = 1e-21 diff --git a/gr-filter/CMakeLists.txt b/gr-filter/CMakeLists.txt index 38e26c8c2c..affa74b726 100644 --- a/gr-filter/CMakeLists.txt +++ b/gr-filter/CMakeLists.txt @@ -33,6 +33,7 @@ GR_REGISTER_COMPONENT("gr-filter" ENABLE_GR_FILTER Boost_FOUND ENABLE_GR_CORE ENABLE_GR_FFT + ENABLE_GR_BLOCKS ) GR_SET_GLOBAL(GR_FILTER_INCLUDE_DIRS diff --git a/gr-filter/examples/channelize.py b/gr-filter/examples/channelize.py index 1745b3f7af..77d3c21968 100755 --- a/gr-filter/examples/channelize.py +++ b/gr-filter/examples/channelize.py @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio import filter import sys, time @@ -68,7 +69,7 @@ class pfb_top_block(gr.top_block): # freqs lists the frequencies of the signals that get stored # in the list "signals", which then get summed together self.signals = list() - self.add = gr.add_cc() + self.add = blocks.add_cc() freqs = [-70, -50, -30, -10, 10, 20, 40, 60, 80] for i in xrange(len(freqs)): f = freqs[i] + (M/2-M+i+1)*self._fs diff --git a/gr-filter/examples/chirp_channelize.py b/gr-filter/examples/chirp_channelize.py index e52a44dde4..ca97a5551c 100755 --- a/gr-filter/examples/chirp_channelize.py +++ b/gr-filter/examples/chirp_channelize.py @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio import filter import sys, time @@ -74,7 +75,7 @@ class pfb_top_block(gr.top_block): # Build a VCO controlled by either the sinusoid or single chirp tone # Then convert this to a complex signal self.vco = gr.vco_f(self._fs, 225, 1) - self.f2c = gr.float_to_complex() + self.f2c = blocks.float_to_complex() self.head = gr.head(gr.sizeof_gr_complex, self._N) diff --git a/gr-filter/examples/decimate.py b/gr-filter/examples/decimate.py index 4a7a5eb155..56ed7edff1 100755 --- a/gr-filter/examples/decimate.py +++ b/gr-filter/examples/decimate.py @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio import filter import sys, time @@ -68,7 +69,7 @@ class pfb_top_block(gr.top_block): # We create a list of freqs, and a sine wave is generated and added to the source # for each one of these frequencies. self.signals = list() - self.add = gr.add_cc() + self.add = blocks.add_cc() freqs = [10, 20, 2040] for i in xrange(len(freqs)): self.signals.append(analog.sig_source_c(self._fs, analog.GR_SIN_WAVE, freqs[i], 1)) diff --git a/gr-filter/examples/gr_filtdes_live_upd.py b/gr-filter/examples/gr_filtdes_live_upd.py index db19db2b39..b21e381a46 100755 --- a/gr-filter/examples/gr_filtdes_live_upd.py +++ b/gr-filter/examples/gr_filtdes_live_upd.py @@ -88,10 +88,8 @@ class my_top_block(gr.top_block): pyWin.show() def update_filter(self, filtobj): - print "Filter Count:", filtobj.get_filtercount() print "Filter type:", filtobj.get_restype() print "Filter params", filtobj.get_params() - print "Filter Coefficients", filtobj.get_taps() self.filt.set_taps(filtobj.get_taps()) if __name__ == "__main__": diff --git a/gr-filter/examples/interpolate.py b/gr-filter/examples/interpolate.py index 45f4b3f801..e0d4cc14b1 100755 --- a/gr-filter/examples/interpolate.py +++ b/gr-filter/examples/interpolate.py @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio import filter import sys, time @@ -86,7 +87,7 @@ class pfb_top_block(gr.top_block): # Create a couple of signals at different frequencies self.signal1 = analog.sig_source_c(self._fs, analog.GR_SIN_WAVE, freq1, 0.5) self.signal2 = analog.sig_source_c(self._fs, analog.GR_SIN_WAVE, freq2, 0.5) - self.signal = gr.add_cc() + self.signal = blocks.add_cc() self.head = gr.head(gr.sizeof_gr_complex, self._N) diff --git a/gr-filter/examples/resampler_demo.grc b/gr-filter/examples/resampler_demo.grc index 7616d0bccd..9c19cd7dcc 100644 --- a/gr-filter/examples/resampler_demo.grc +++ b/gr-filter/examples/resampler_demo.grc @@ -511,7 +511,7 @@ </param> </block> <block> - <key>gr_add_const_vxx</key> + <key>blocks_add_const_vxx</key> <param> <key>id</key> <value>adder</value> diff --git a/gr-filter/examples/synth_to_chan.py b/gr-filter/examples/synth_to_chan.py index bd39a17e59..d1d2406458 100755 --- a/gr-filter/examples/synth_to_chan.py +++ b/gr-filter/examples/synth_to_chan.py @@ -20,7 +20,8 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, blks2 +from gnuradio import gr +from gnuradio import blocks from gnuradio import filter import sys @@ -69,7 +70,7 @@ def main(): noise_level = 0.01 head = gr.head(gr.sizeof_gr_complex, N) noise = analog.noise_source_c(gr.GR_GAUSSIAN, noise_level) - addnoise = gr.add_cc() + addnoise = blocks.add_cc() snk_synth = gr.vector_sink_c() tb = gr.top_block() diff --git a/gr-filter/include/filter/pfb_channelizer_ccf.h b/gr-filter/include/filter/pfb_channelizer_ccf.h index 2ff83b5e7e..07e0c96387 100644 --- a/gr-filter/include/filter/pfb_channelizer_ccf.h +++ b/gr-filter/include/filter/pfb_channelizer_ccf.h @@ -59,13 +59,13 @@ namespace gr { * structure, each filter input must come from its own input * stream. So the channelizer must be provided with <EM>M</EM> streams * where the input stream has been deinterleaved. This is most easily - * done using the gr_stream_to_streams block. + * done using the gr::blocks::stream_to_streams block. * - * The output is then produced as a vector, where index <EM>i</EM> in - * the vector is the next sample from the <EM>i</EM>th channel. This - * is most easily handled by sending the output to a - * gr_vector_to_streams block to handle the conversion and passing - * <EM>M</EM> streams out. + * The output is then produced as a vector, where index <EM>i</EM> + * in the vector is the next sample from the <EM>i</EM>th + * channel. This is most easily handled by sending the output to a + * gr::blocks::vector_to_streams block to handle the conversion + * and passing <EM>M</EM> streams out. * * The input and output formatting is done using a hier_block2 called * pfb_channelizer_ccf. This can take in a single stream and outputs diff --git a/gr-filter/include/filter/polyphase_filterbank.h b/gr-filter/include/filter/polyphase_filterbank.h index 33e9522e17..cd4ee4db99 100644 --- a/gr-filter/include/filter/polyphase_filterbank.h +++ b/gr-filter/include/filter/polyphase_filterbank.h @@ -63,13 +63,13 @@ namespace gr { * must come from its own input stream. So the channelizer must * be provided with <EM>M</EM> streams where the input stream * has been deinterleaved. This is most easily done using the - * gr_stream_to_streams block. + * gr::blocks::stream_to_streams block. * * The output is then produced as a vector, where index * <EM>i</EM> in the vector is the next sample from the * <EM>i</EM>th channel. This is most easily handled by sending - * the output to a gr_vector_to_streams block to handle the - * conversion and passing <EM>M</EM> streams out. + * the output to a gr::blocks::vector_to_streams block to handle + * the conversion and passing <EM>M</EM> streams out. * * The input and output formatting is done using a hier_block2 * called pfb_channelizer_ccf. This can take in a single stream diff --git a/gr-filter/python/CMakeLists.txt b/gr-filter/python/CMakeLists.txt index bcb55cf460..1ef5b35641 100644 --- a/gr-filter/python/CMakeLists.txt +++ b/gr-filter/python/CMakeLists.txt @@ -23,6 +23,7 @@ include(GrPython) GR_PYTHON_INSTALL( FILES __init__.py + filterbank.py optfir.py pfb.py rational_resampler.py @@ -38,6 +39,8 @@ if(ENABLE_TESTING) list(APPEND GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/gr-filter/python ${CMAKE_BINARY_DIR}/gr-filter/swig + ${CMAKE_BINARY_DIR}/gr-blocks/python + ${CMAKE_BINARY_DIR}/gr-blocks/swig ) list(APPEND GR_TEST_TARGET_DEPS gnuradio-filter gnuradio-fft) diff --git a/gr-filter/python/__init__.py b/gr-filter/python/__init__.py index 65a62d828d..ad2f116d72 100644 --- a/gr-filter/python/__init__.py +++ b/gr-filter/python/__init__.py @@ -25,6 +25,10 @@ processing blocks for FILTER and related functions. ''' from filter_swig import * +from filterbank import * from rational_resampler import * import pfb import optfir + +# Pull this into the filter module +from gnuradio.fft import window diff --git a/gr-filter/python/design/filter_design.py b/gr-filter/python/design/filter_design.py index 556ac8edf7..748a435c63 100644 --- a/gr-filter/python/design/filter_design.py +++ b/gr-filter/python/design/filter_design.py @@ -1077,7 +1077,13 @@ class gr_plot_filter(QtGui.QMainWindow): Ts = 1.0/fs fftpts = fftpack.fft(taps, Npts) self.freq = scipy.arange(0, fs, 1.0/(Npts*Ts)) - self.fftdB = 20.0*scipy.log10(abs(fftpts)) + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + self.fftdB = 20.0*scipy.log10(abs(fftpts)) + if any(self.fftdB == float('-inf')): + sys.stderr.write('Filter design failed (taking log10 of 0).\n') + self.fftdB = scipy.zeros([len(fftpts)]) + self.fftDeg = scipy.unwrap(scipy.angle(fftpts)) self.groupDelay = -scipy.diff(self.fftDeg) self.phaseDelay = -self.fftDeg[1:]/self.freq[1:] diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/filterbank.py b/gr-filter/python/filterbank.py index 29e50bc2a3..a8ee27ce97 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/filterbank.py +++ b/gr-filter/python/filterbank.py @@ -20,7 +20,9 @@ # import sys -from gnuradio import gr, gru +from gnuradio import gr +from gnuradio import fft +from gnuradio import blocks def _generate_synthesis_taps(mpoints): return [] # FIXME @@ -99,11 +101,11 @@ class synthesis_filterbank(gr.hier_block2): # split in mpoints separate set of taps sub_taps = _split_taps(taps, mpoints) - self.ss2v = gr.streams_to_vector(item_size, mpoints) - self.ifft = gr.fft_vcc(mpoints, False, []) - self.v2ss = gr.vector_to_streams(item_size, mpoints) + self.ss2v = blocks.streams_to_vector(item_size, mpoints) + self.ifft = fft.fft_vcc(mpoints, False, []) + self.v2ss = blocks.vector_to_streams(item_size, mpoints) # mpoints filters go in here... - self.ss2s = gr.streams_to_stream(item_size, mpoints) + self.ss2s = blocks.streams_to_stream(item_size, mpoints) for i in range(mpoints): self.connect((self, i), (self.ss2v, i)) @@ -112,7 +114,7 @@ class synthesis_filterbank(gr.hier_block2): # build mpoints fir filters... for i in range(mpoints): - f = gr.fft_filter_ccc(1, sub_taps[i]) + f = fft.fft_filter_ccc(1, sub_taps[i]) self.connect((self.v2ss, i), f) self.connect(f, (self.ss2s, i)) @@ -153,17 +155,17 @@ class analysis_filterbank(gr.hier_block2): # print >> sys.stderr, "mpoints =", mpoints, "len(sub_taps) =", len(sub_taps) - self.s2ss = gr.stream_to_streams(item_size, mpoints) + self.s2ss = blocks.stream_to_streams(item_size, mpoints) # filters here - self.ss2v = gr.streams_to_vector(item_size, mpoints) - self.fft = gr.fft_vcc(mpoints, True, []) - self.v2ss = gr.vector_to_streams(item_size, mpoints) + self.ss2v = blocks.streams_to_vector(item_size, mpoints) + self.fft = fft.fft_vcc(mpoints, True, []) + self.v2ss = blocks.vector_to_streams(item_size, mpoints) self.connect(self, self.s2ss) # build mpoints fir filters... for i in range(mpoints): - f = gr.fft_filter_ccc(1, sub_taps[mpoints-i-1]) + f = fft.fft_filter_ccc(1, sub_taps[mpoints-i-1]) self.connect((self.s2ss, i), f) self.connect(f, (self.ss2v, i)) self.connect((self.v2ss, i), (self, i)) diff --git a/gr-filter/python/pfb.py b/gr-filter/python/pfb.py index b9608362c3..52f598cc40 100644 --- a/gr-filter/python/pfb.py +++ b/gr-filter/python/pfb.py @@ -24,6 +24,11 @@ from gnuradio import gr import filter_swig as filter import optfir +try: + from gnuradio import blocks +except ImportError: + import blocks_swig as blocks + class channelizer_ccf(gr.hier_block2): ''' Make a Polyphase Filter channelizer (complex in, complex out, floating-point taps) @@ -60,7 +65,7 @@ class channelizer_ccf(gr.hier_block2): if(ripple >= 1.0): raise RuntimeError("optfir could not generate an appropriate filter.") - self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._nchans) + self.s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, self._nchans) self.pfb = filter.pfb_channelizer_ccf(self._nchans, self._taps, self._oversample_rate) self.connect(self, self.s2ss) @@ -154,7 +159,7 @@ class decimator_ccf(gr.hier_block2): if(ripple >= 1.0): raise RuntimeError("optfir could not generate an appropriate filter.") - self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._decim) + self.s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, self._decim) self.pfb = filter.pfb_decimator_ccf(self._decim, self._taps, self._channel) self.connect(self, self.s2ss) diff --git a/gr-filter/python/qa_pfb_channelizer.py b/gr-filter/python/qa_pfb_channelizer.py index e9a4d446e7..519afa0458 100755 --- a/gr-filter/python/qa_pfb_channelizer.py +++ b/gr-filter/python/qa_pfb_channelizer.py @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks import math def sig_source_c(samp_rate, freq, amp, N): @@ -49,7 +50,7 @@ class test_pfb_channelizer(gr_unittest.TestCase): window=filter.firdes.WIN_BLACKMAN_hARRIS) signals = list() - add = gr.add_cc() + add = blocks.add_cc() freqs = [-200, -100, 0, 100, 200] for i in xrange(len(freqs)): f = freqs[i] + (M/2-M+i+1)*fs @@ -57,7 +58,7 @@ class test_pfb_channelizer(gr_unittest.TestCase): signals.append(gr.vector_source_c(data)) self.tb.connect(signals[i], (add,i)) - s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, M) + s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M) pfb = filter.pfb_channelizer_ccf(M, taps, 1) self.tb.connect(add, s2ss) diff --git a/gr-filter/python/qa_pfb_decimator.py b/gr-filter/python/qa_pfb_decimator.py index c4448de4b5..d20b2fa856 100755 --- a/gr-filter/python/qa_pfb_decimator.py +++ b/gr-filter/python/qa_pfb_decimator.py @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks import math def sig_source_c(samp_rate, freq, amp, N): @@ -50,7 +51,7 @@ class test_pfb_decimator(gr_unittest.TestCase): window=filter.firdes.WIN_BLACKMAN_hARRIS) signals = list() - add = gr.add_cc() + add = blocks.add_cc() freqs = [-200, -100, 0, 100, 200] for i in xrange(len(freqs)): f = freqs[i] + (M/2-M+i+1)*fs @@ -59,7 +60,7 @@ class test_pfb_decimator(gr_unittest.TestCase): self.tb.connect(signals[i], (add,i)) head = gr.head(gr.sizeof_gr_complex, N) - s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, M) + s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M) pfb = filter.pfb_decimator_ccf(M, taps, channel) snk = gr.vector_sink_c() @@ -96,7 +97,7 @@ class test_pfb_decimator(gr_unittest.TestCase): window=filter.firdes.WIN_BLACKMAN_hARRIS) signals = list() - add = gr.add_cc() + add = blocks.add_cc() freqs = [-200, -100, 0, 100, 200] for i in xrange(len(freqs)): f = freqs[i] + (M/2-M+i+1)*fs @@ -104,7 +105,7 @@ class test_pfb_decimator(gr_unittest.TestCase): signals.append(gr.vector_source_c(data)) self.tb.connect(signals[i], (add,i)) - s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, M) + s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M) pfb = filter.pfb_decimator_ccf(M, taps, channel) snk = gr.vector_sink_c() diff --git a/gr-filter/python/qa_single_pole_iir.py b/gr-filter/python/qa_single_pole_iir.py index 3608c77f95..d28ab643fd 100755 --- a/gr-filter/python/qa_single_pole_iir.py +++ b/gr-filter/python/qa_single_pole_iir.py @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks class test_single_pole_iir_filter(gr_unittest.TestCase): @@ -58,9 +59,9 @@ class test_single_pole_iir_filter(gr_unittest.TestCase): src_data = (0, 1000, 2000, 3000, 4000, 5000) expected_result = (0, 125, 250, 484.375, 718.75, 1048.828125) src = gr.vector_source_f(src_data) - s2p = gr.serial_to_parallel(gr.sizeof_float, block_size) + s2p = blocks.stream_to_vector(gr.sizeof_float, block_size) op = filter.single_pole_iir_filter_ff (0.125, block_size) - p2s = gr.parallel_to_serial(gr.sizeof_float, block_size) + p2s = blocks.vector_to_stream(gr.sizeof_float, block_size) dst = gr.vector_sink_f() self.tb.connect(src, s2p, op, p2s, dst) self.tb.run() @@ -100,9 +101,9 @@ class test_single_pole_iir_filter(gr_unittest.TestCase): complex(484.375,-484.375), complex(718.75,-718.75), complex(1048.828125,-1048.828125)) src = gr.vector_source_c(src_data) - s2p = gr.serial_to_parallel(gr.sizeof_gr_complex, block_size) + s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, block_size) op = filter.single_pole_iir_filter_cc(0.125, block_size) - p2s = gr.parallel_to_serial(gr.sizeof_gr_complex, block_size) + p2s = blocks.vector_to_stream(gr.sizeof_gr_complex, block_size) dst = gr.vector_sink_c() self.tb.connect(src, s2p, op, p2s, dst) self.tb.run() diff --git a/gr-noaa/CMakeLists.txt b/gr-noaa/CMakeLists.txt index 09ce2a3293..ac8aac5a93 100644 --- a/gr-noaa/CMakeLists.txt +++ b/gr-noaa/CMakeLists.txt @@ -29,6 +29,7 @@ include(GrComponent) GR_REGISTER_COMPONENT("gr-noaa" ENABLE_GR_NOAA Boost_FOUND ENABLE_GR_CORE + ENABLE_GR_BLOCKS ) GR_SET_GLOBAL(GR_NOAA_INCLUDE_DIRS diff --git a/gr-noaa/examples/file_rx_hrpt.grc b/gr-noaa/examples/file_rx_hrpt.grc index 4097e83d36..664b200a5f 100644 --- a/gr-noaa/examples/file_rx_hrpt.grc +++ b/gr-noaa/examples/file_rx_hrpt.grc @@ -419,10 +419,10 @@ </param> </block> <block> - <key>gr_interleaved_short_to_complex</key> + <key>blocks_interleaved_short_to_complex</key> <param> <key>id</key> - <value>gr_interleaved_short_to_complex_0</value> + <value>blocks_interleaved_short_to_complex_0</value> </param> <param> <key>_enabled</key> @@ -871,14 +871,14 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_interleaved_short_to_complex_0</source_block_id> + <source_block_id>blocks_interleaved_short_to_complex_0</source_block_id> <sink_block_id>agc</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>throttle</source_block_id> - <sink_block_id>gr_interleaved_short_to_complex_0</sink_block_id> + <sink_block_id>blocks_interleaved_short_to_complex_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-noaa/examples/hrpt_demod.grc b/gr-noaa/examples/hrpt_demod.grc index f5833b864c..54dbf73ce7 100644 --- a/gr-noaa/examples/hrpt_demod.grc +++ b/gr-noaa/examples/hrpt_demod.grc @@ -231,7 +231,7 @@ </param> </block> <block> - <key>gr_interleaved_short_to_complex</key> + <key>blocks_interleaved_short_to_complex</key> <param> <key>id</key> <value>cs2cf</value> diff --git a/gr-pager/CMakeLists.txt b/gr-pager/CMakeLists.txt index b11c2f4a28..3feae16e02 100644 --- a/gr-pager/CMakeLists.txt +++ b/gr-pager/CMakeLists.txt @@ -29,6 +29,7 @@ include(GrComponent) GR_REGISTER_COMPONENT("gr-pager" ENABLE_GR_PAGER Boost_FOUND ENABLE_GR_CORE + ENABLE_GR_FILTER ENABLE_GR_ANALOG ) diff --git a/gr-pager/apps/usrp_flex_all b/gr-pager/apps/usrp_flex_all index 8ecf5a41ff..2110d91561 100755 --- a/gr-pager/apps/usrp_flex_all +++ b/gr-pager/apps/usrp_flex_all @@ -20,7 +20,8 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, uhd, optfir, eng_notation, blks2, pager +from gnuradio import gr, uhd, eng_notation, pager +from gnuradio import filter from gnuradio.eng_option import eng_option from optparse import OptionParser from string import split, join, printable @@ -88,7 +89,7 @@ class app_top_block(gr.top_block): if options.verbose: print "Channel filter has", len(taps), "taps" - self.bank = blks2.analysis_filterbank(self.nchan, taps) + self.bank = filter.analysis_filterbank(self.nchan, taps) self.connect(self.u, self.bank) if options.log and options.from_file == None: diff --git a/gr-pager/apps/usrp_flex_band b/gr-pager/apps/usrp_flex_band index 5ec0065d61..a792a753be 100755 --- a/gr-pager/apps/usrp_flex_band +++ b/gr-pager/apps/usrp_flex_band @@ -20,7 +20,8 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, uhd, optfir, eng_notation, blks2, pager +from gnuradio import gr, uhd, eng_notation, pager +from gnuradio import filter from gnuradio.eng_option import eng_option from optparse import OptionParser import sys @@ -73,7 +74,7 @@ class app_top_block(gr.top_block): if options.verbose: print "Channel filter has", len(taps), "taps" - bank = blks2.analysis_filterbank(40, taps) + bank = filter.analysis_filterbank(40, taps) self.connect(self.u, bank) if options.log and options.from_file == None: diff --git a/gr-pager/apps/usrp_rx_flex.grc b/gr-pager/apps/usrp_rx_flex.grc index b9461a57f8..79312a4148 100644 --- a/gr-pager/apps/usrp_rx_flex.grc +++ b/gr-pager/apps/usrp_rx_flex.grc @@ -330,10 +330,10 @@ </param> </block> <block> - <key>gr_freq_xlating_fir_filter_xxx</key> + <key>filter_freq_xlating_fir_filter_xxx</key> <param> <key>id</key> - <value>gr_freq_xlating_fir_filter_xxx_0</value> + <value>filter_freq_xlating_fir_filter_xxx_0</value> </param> <param> <key>_enabled</key> @@ -1086,7 +1086,7 @@ </param> </block> <block> - <key>gr_quadrature_demod_cf</key> + <key>analog_quadrature_demod_cf</key> <param> <key>id</key> <value>fm_demod</value> @@ -1466,10 +1466,10 @@ </param> </block> <block> - <key>gr_char_to_float</key> + <key>blocks_char_to_float</key> <param> <key>id</key> - <value>gr_char_to_float_0</value> + <value>blocks_char_to_float_0</value> </param> <param> <key>_enabled</key> @@ -1688,14 +1688,14 @@ </param> </block> <connection> - <source_block_id>gr_freq_xlating_fir_filter_xxx_0</source_block_id> + <source_block_id>filter_freq_xlating_fir_filter_xxx_0</source_block_id> <sink_block_id>wxgui_fftsink2_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>usrp_source</source_block_id> - <sink_block_id>gr_freq_xlating_fir_filter_xxx_0</sink_block_id> + <sink_block_id>filter_freq_xlating_fir_filter_xxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> @@ -1706,7 +1706,7 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_freq_xlating_fir_filter_xxx_0</source_block_id> + <source_block_id>filter_freq_xlating_fir_filter_xxx_0</source_block_id> <sink_block_id>fm_demod</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -1743,12 +1743,12 @@ </connection> <connection> <source_block_id>pager_slicer_fb_0</source_block_id> - <sink_block_id>gr_char_to_float_0</sink_block_id> + <sink_block_id>blocks_char_to_float_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_char_to_float_0</source_block_id> + <source_block_id>blocks_char_to_float_0</source_block_id> <sink_block_id>wxgui_scopesink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> diff --git a/gr-pager/apps/usrp_rx_flex.py b/gr-pager/apps/usrp_rx_flex.py index 47bf5a3df6..6bb93ee756 100755 --- a/gr-pager/apps/usrp_rx_flex.py +++ b/gr-pager/apps/usrp_rx_flex.py @@ -5,13 +5,13 @@ # Generated: Thu Oct 29 11:03:16 2009 ################################################## -from gnuradio import blks2 from gnuradio import eng_notation from gnuradio import gr +from gnuradio import filter from gnuradio import pager -from gnuradio import window from gnuradio.eng_option import eng_option -from gnuradio.gr import firdes +from gnuradio.filter import window +from gnuradio.filter import firdes from gnuradio.wxgui import fftsink2 from gnuradio.wxgui import forms from gnuradio.wxgui import scopesink2 @@ -185,7 +185,7 @@ class usrp_rx_flex(grc_wxgui.top_block_gui): self.pager_flex_deinterleave_0_1_0 = pager.flex_deinterleave() self.pager_flex_sync_0 = pager.flex_sync() self.pager_slicer_fb_0 = pager.slicer_fb(1e-6) - self.resampler = blks2.rational_resampler_fff( + self.resampler = filter.rational_resampler_fff( interpolation=bb_interp, decimation=bb_decim, taps=([1.0/ma_ntaps,]*ma_ntaps*bb_interp), diff --git a/gr-pager/python/flex_demod.py b/gr-pager/python/flex_demod.py index 853348e4b0..85797f3701 100644 --- a/gr-pager/python/flex_demod.py +++ b/gr-pager/python/flex_demod.py @@ -19,8 +19,9 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, blks2 +from gnuradio import gr from gnuradio import analog +from gnuradio import filter from math import pi import pager_swig @@ -42,7 +43,7 @@ class flex_demod(gr.hier_block2): quad = analog.quadrature_demod_cf(k) self.connect(self, quad) - rsamp = blks2.rational_resampler_fff(16, 25) + rsamp = filter.rational_resampler_fff(16, 25) self.slicer = pager_swig.slicer_fb(5e-6) # DC removal averaging filter constant self.sync = pager_swig.flex_sync() diff --git a/gr-qtgui/apps/gr_psd_plot_b b/gr-qtgui/apps/gr_psd_plot_b index 283bf2950c..b5d2104da2 100755 --- a/gr-qtgui/apps/gr_psd_plot_b +++ b/gr-qtgui/apps/gr_psd_plot_b @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import os, sys @@ -91,7 +92,7 @@ class my_top_block(gr.top_block): data = read_samples_and_pad(f, self._start, self._nsamps, self._psd_size) self.srcs.append(gr.vector_source_b(data)) - self.cnvrt.append(gr.char_to_float(1, self._scale)) + self.cnvrt.append(blocks.char_to_float(1, self._scale)) # Set default labels based on file names fname = f.split("/")[-1] diff --git a/gr-qtgui/apps/gr_psd_plot_i b/gr-qtgui/apps/gr_psd_plot_i index 022f4ee755..f27011be22 100755 --- a/gr-qtgui/apps/gr_psd_plot_i +++ b/gr-qtgui/apps/gr_psd_plot_i @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import os, sys @@ -91,7 +92,7 @@ class my_top_block(gr.top_block): data = read_samples_and_pad(f, self._start, self._nsamps, self._psd_size) self.srcs.append(gr.vector_source_i(data)) - self.cnvrt.append(gr.int_to_float(1, self._scale)) + self.cnvrt.append(blocks.int_to_float(1, self._scale)) # Set default labels based on file names fname = f.split("/")[-1] diff --git a/gr-qtgui/apps/gr_psd_plot_s b/gr-qtgui/apps/gr_psd_plot_s index 905d8fde60..cd2d4a516e 100755 --- a/gr-qtgui/apps/gr_psd_plot_s +++ b/gr-qtgui/apps/gr_psd_plot_s @@ -91,7 +91,7 @@ class my_top_block(gr.top_block): data = read_samples_and_pad(f, self._start, self._nsamps, self._psd_size) self.srcs.append(gr.vector_source_s(data)) - self.cnvrt.append(gr.short_to_float(1, self._scale)) + self.cnvrt.append(blocks.short_to_float(1, self._scale)) # Set default labels based on file names fname = f.split("/")[-1] diff --git a/gr-qtgui/apps/gr_spectrogram_plot_b b/gr-qtgui/apps/gr_spectrogram_plot_b index 41c1af521a..649c2834d6 100755 --- a/gr-qtgui/apps/gr_spectrogram_plot_b +++ b/gr-qtgui/apps/gr_spectrogram_plot_b @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import os, sys @@ -81,7 +82,7 @@ class my_top_block(gr.top_block): self.qapp = QtGui.QApplication(sys.argv) self.skip = gr.skiphead(gr.sizeof_float, self._start) - self.add = gr.add_ff() + self.add = blocks.add_ff() self.gui_snk = qtgui.waterfall_sink_f(self._psd_size, gr.firdes.WIN_BLACKMAN_hARRIS, self._center_freq, self._samp_rate, "GNU Radio Spectrogram Plot") @@ -92,7 +93,7 @@ class my_top_block(gr.top_block): data = read_samples_and_pad(f, self._start, self._nsamps, self._psd_size) self.srcs.append(gr.vector_source_b(data)) - self.cnvrt.append(gr.char_to_float(1, self._scale)) + self.cnvrt.append(blocks.char_to_float(1, self._scale)) n += 1 self.connect(self.add, self.skip) diff --git a/gr-qtgui/apps/gr_spectrogram_plot_c b/gr-qtgui/apps/gr_spectrogram_plot_c index 28fa82f298..160072f27c 100755 --- a/gr-qtgui/apps/gr_spectrogram_plot_c +++ b/gr-qtgui/apps/gr_spectrogram_plot_c @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import os, sys @@ -80,7 +81,7 @@ class my_top_block(gr.top_block): self.qapp = QtGui.QApplication(sys.argv) self.skip = gr.skiphead(gr.sizeof_gr_complex, self._start) - self.add = gr.add_cc() + self.add = blocks.add_cc() self.gui_snk = qtgui.waterfall_sink_c(self._psd_size, gr.firdes.WIN_BLACKMAN_hARRIS, self._center_freq, self._samp_rate, "GNU Radio Spectrogram Plot") diff --git a/gr-qtgui/apps/gr_spectrogram_plot_f b/gr-qtgui/apps/gr_spectrogram_plot_f index d1bb73212a..3e799395b3 100755 --- a/gr-qtgui/apps/gr_spectrogram_plot_f +++ b/gr-qtgui/apps/gr_spectrogram_plot_f @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import os, sys @@ -80,7 +81,7 @@ class my_top_block(gr.top_block): self.qapp = QtGui.QApplication(sys.argv) self.skip = gr.skiphead(gr.sizeof_float, self._start) - self.add = gr.add_ff() + self.add = blocks.add_ff() self.gui_snk = qtgui.waterfall_sink_f(self._psd_size, gr.firdes.WIN_BLACKMAN_hARRIS, self._center_freq, self._samp_rate, "GNU Radio Spectrogram Plot") diff --git a/gr-qtgui/apps/gr_spectrogram_plot_i b/gr-qtgui/apps/gr_spectrogram_plot_i index a617f9087d..444f4115ad 100755 --- a/gr-qtgui/apps/gr_spectrogram_plot_i +++ b/gr-qtgui/apps/gr_spectrogram_plot_i @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import os, sys @@ -81,7 +82,7 @@ class my_top_block(gr.top_block): self.qapp = QtGui.QApplication(sys.argv) self.skip = gr.skiphead(gr.sizeof_float, self._start) - self.add = gr.add_ff() + self.add = blocks.add_ff() self.gui_snk = qtgui.waterfall_sink_f(self._psd_size, gr.firdes.WIN_BLACKMAN_hARRIS, self._center_freq, self._samp_rate, "GNU Radio Spectrogram Plot") @@ -92,7 +93,7 @@ class my_top_block(gr.top_block): data = read_samples_and_pad(f, self._start, self._nsamps, self._psd_size) self.srcs.append(gr.vector_source_i(data)) - self.cnvrt.append(gr.int_to_float(1, self._scale)) + self.cnvrt.append(blocks.int_to_float(1, self._scale)) n += 1 self.connect(self.add, self.skip) diff --git a/gr-qtgui/apps/gr_spectrogram_plot_s b/gr-qtgui/apps/gr_spectrogram_plot_s index 29f3d3df77..bb3573ba2c 100755 --- a/gr-qtgui/apps/gr_spectrogram_plot_s +++ b/gr-qtgui/apps/gr_spectrogram_plot_s @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import os, sys @@ -81,7 +82,7 @@ class my_top_block(gr.top_block): self.qapp = QtGui.QApplication(sys.argv) self.skip = gr.skiphead(gr.sizeof_float, self._start) - self.add = gr.add_ff() + self.add = blocks.add_ff() self.gui_snk = qtgui.waterfall_sink_f(self._psd_size, gr.firdes.WIN_BLACKMAN_hARRIS, self._center_freq, self._samp_rate, "GNU Radio Spectrogram Plot") @@ -92,7 +93,7 @@ class my_top_block(gr.top_block): data = read_samples_and_pad(f, self._start, self._nsamps, self._psd_size) self.srcs.append(gr.vector_source_s(data)) - self.cnvrt.append(gr.short_to_float(1, self._scale)) + self.cnvrt.append(blocks.short_to_float(1, self._scale)) n += 1 self.connect(self.add, self.skip) diff --git a/gr-qtgui/apps/gr_time_plot_b b/gr-qtgui/apps/gr_time_plot_b index 3ac583eef3..4b63c3fd11 100755 --- a/gr-qtgui/apps/gr_time_plot_b +++ b/gr-qtgui/apps/gr_time_plot_b @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import os, sys @@ -85,7 +86,7 @@ class gr_time_plot_f(gr.top_block): for f in filelist: data = read_samples(f, self._start, self._nsamps) self.srcs.append(gr.vector_source_b(data)) - self.cnvrt.append(gr.char_to_float(1, self._scale)) + self.cnvrt.append(blocks.char_to_float(1, self._scale)) # Set default labels based on file names fname = f.split("/")[-1] diff --git a/gr-qtgui/apps/gr_time_plot_i b/gr-qtgui/apps/gr_time_plot_i index f9765db672..4895090a10 100755 --- a/gr-qtgui/apps/gr_time_plot_i +++ b/gr-qtgui/apps/gr_time_plot_i @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import os, sys @@ -85,7 +86,7 @@ class gr_time_plot_f(gr.top_block): for f in filelist: data = read_samples(f, self._start, self._nsamps) self.srcs.append(gr.vector_source_i(data)) - self.cnvrt.append(gr.int_to_float(1, self._scale)) + self.cnvrt.append(blocks.int_to_float(1, self._scale)) # Set default labels based on file names fname = f.split("/")[-1] diff --git a/gr-qtgui/apps/gr_time_plot_s b/gr-qtgui/apps/gr_time_plot_s index 43b098dbdb..581190e6df 100755 --- a/gr-qtgui/apps/gr_time_plot_s +++ b/gr-qtgui/apps/gr_time_plot_s @@ -85,7 +85,7 @@ class gr_time_plot_f(gr.top_block): for f in filelist: data = read_samples(f, self._start, self._nsamps) self.srcs.append(gr.vector_source_s(data)) - self.cnvrt.append(gr.short_to_float(1, self._scale)) + self.cnvrt.append(blocks.short_to_float(1, self._scale)) # Set default labels based on file names fname = f.split("/")[-1] diff --git a/gr-qtgui/apps/uhd_display.py b/gr-qtgui/apps/uhd_display.py index 250d757b6c..bca3126ce7 100755 --- a/gr-qtgui/apps/uhd_display.py +++ b/gr-qtgui/apps/uhd_display.py @@ -21,6 +21,8 @@ # from gnuradio import gr +from gnuradio import filter +from gnuradio import blocks from gnuradio import uhd from gnuradio import eng_notation from gnuradio.eng_option import eng_option @@ -198,14 +200,14 @@ class my_top_block(gr.top_block): True, True, True, False) # Set up internal amplifier - self.amp = gr.multiply_const_cc(0.0) + self.amp = blocks.multiply_const_cc(0.0) self.set_amplifier_gain(100) # Create a single-pole IIR filter to remove DC # but don't connect it yet self.dc_gain = 0.001 - self.dc = gr.single_pole_iir_filter_cc(self.dc_gain) - self.dc_sub = gr.sub_cc() + self.dc = filter.single_pole_iir_filter_cc(self.dc_gain) + self.dc_sub = blocks.sub_cc() self.connect(self.u, self.amp, self.snk) diff --git a/gr-qtgui/examples/pyqt_const_c.py b/gr-qtgui/examples/pyqt_const_c.py index 382fbdabee..e26ce0bd90 100755 --- a/gr-qtgui/examples/pyqt_const_c.py +++ b/gr-qtgui/examples/pyqt_const_c.py @@ -21,6 +21,7 @@ # from gnuradio import gr, filter +from gnuradio import blocks import sys try: @@ -153,7 +154,7 @@ class my_top_block(gr.top_block): src1 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f1, 0.5, 0) src2 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f2, 0.5, 0) - src = gr.add_cc() + src = blocks.add_cc() channel = channels.channel_model(0.001) thr = gr.throttle(gr.sizeof_gr_complex, 100*npts) self.snk1 = qtgui.const_sink_c(npts, "Constellation Example", 1) diff --git a/gr-qtgui/examples/pyqt_example_c.py b/gr-qtgui/examples/pyqt_example_c.py index 3ed64b7003..ccacc246bf 100755 --- a/gr-qtgui/examples/pyqt_example_c.py +++ b/gr-qtgui/examples/pyqt_example_c.py @@ -21,6 +21,7 @@ # from gnuradio import gr, filter +from gnuradio import blocks import sys try: @@ -157,7 +158,7 @@ class my_top_block(gr.top_block): src1 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f1, 0.1, 0) src2 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_cc() + src = blocks.add_cc() channel = channels.channel_model(0.001) thr = gr.throttle(gr.sizeof_gr_complex, 100*fftsize) self.snk1 = qtgui.sink_c(fftsize, filter.firdes.WIN_BLACKMAN_hARRIS, diff --git a/gr-qtgui/examples/pyqt_example_f.py b/gr-qtgui/examples/pyqt_example_f.py index 4e59d78001..f975bf0d1a 100755 --- a/gr-qtgui/examples/pyqt_example_f.py +++ b/gr-qtgui/examples/pyqt_example_f.py @@ -21,6 +21,7 @@ # from gnuradio import gr, filter +from gnuradio import blocks import sys try: @@ -147,10 +148,10 @@ class my_top_block(gr.top_block): src1 = analog.sig_source_f(Rs, analog.GR_SIN_WAVE, f1, 0.1, 0) src2 = analog.sig_source_f(Rs, analog.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_ff() + src = blocks.add_ff() thr = gr.throttle(gr.sizeof_float, 100*fftsize) noise = analog.noise_source_f(analog.GR_GAUSSIAN, 0.001) - add = gr.add_ff() + add = blocks.add_ff() self.snk1 = qtgui.sink_f(fftsize, filter.firdes.WIN_BLACKMAN_hARRIS, 0, Rs, "Float Signal Example", diff --git a/gr-qtgui/examples/pyqt_freq_c.py b/gr-qtgui/examples/pyqt_freq_c.py index a02ded898d..5941622130 100755 --- a/gr-qtgui/examples/pyqt_freq_c.py +++ b/gr-qtgui/examples/pyqt_freq_c.py @@ -21,6 +21,7 @@ # from gnuradio import gr, filter +from gnuradio import blocks import sys try: @@ -157,7 +158,7 @@ class my_top_block(gr.top_block): src1 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f1, 0.1, 0) src2 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_cc() + src = blocks.add_cc() channel = channels.channel_model(0.01) thr = gr.throttle(gr.sizeof_gr_complex, 100*npts) self.snk1 = qtgui.freq_sink_c(npts, filter.firdes.WIN_BLACKMAN_hARRIS, diff --git a/gr-qtgui/examples/pyqt_freq_f.py b/gr-qtgui/examples/pyqt_freq_f.py index 79c1399a73..44d81314a4 100755 --- a/gr-qtgui/examples/pyqt_freq_f.py +++ b/gr-qtgui/examples/pyqt_freq_f.py @@ -21,6 +21,7 @@ # from gnuradio import gr, filter +from gnuradio import blocks import sys try: @@ -148,7 +149,7 @@ class my_top_block(gr.top_block): src1 = analog.sig_source_f(Rs, analog.GR_SIN_WAVE, f1, 0.1, 0) src2 = analog.sig_source_f(Rs, analog.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_ff() + src = blocks.add_ff() thr = gr.throttle(gr.sizeof_float, 100*npts) self.snk1 = qtgui.freq_sink_f(npts, filter.firdes.WIN_BLACKMAN_hARRIS, 0, Rs, diff --git a/gr-qtgui/examples/pyqt_time_c.py b/gr-qtgui/examples/pyqt_time_c.py index 6eb97fa9eb..65d62c4167 100755 --- a/gr-qtgui/examples/pyqt_time_c.py +++ b/gr-qtgui/examples/pyqt_time_c.py @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks import sys try: @@ -157,7 +158,7 @@ class my_top_block(gr.top_block): src1 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f1, 0.1, 0) src2 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_cc() + src = blocks.add_cc() channel = channels.channel_model(0.01) thr = gr.throttle(gr.sizeof_gr_complex, 100*npts) self.snk1 = qtgui.time_sink_c(npts, Rs, diff --git a/gr-qtgui/examples/pyqt_time_f.py b/gr-qtgui/examples/pyqt_time_f.py index d7119dcb93..e64d6fcfde 100755 --- a/gr-qtgui/examples/pyqt_time_f.py +++ b/gr-qtgui/examples/pyqt_time_f.py @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks import sys try: @@ -147,10 +148,10 @@ class my_top_block(gr.top_block): src1 = analog.sig_source_f(Rs, analog.GR_SIN_WAVE, f1, 0.1, 0) src2 = analog.sig_source_f(Rs, analog.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_ff() + src = blocks.add_ff() thr = gr.throttle(gr.sizeof_float, 100*npts) noise = analog.noise_source_f(analog.GR_GAUSSIAN, 0.001) - add = gr.add_ff() + add = blocks.add_ff() self.snk1 = qtgui.time_sink_f(npts, Rs, "Complex Time Example", 3) diff --git a/gr-qtgui/examples/pyqt_waterfall_c.py b/gr-qtgui/examples/pyqt_waterfall_c.py index 30931227b3..3fce9b9a5a 100755 --- a/gr-qtgui/examples/pyqt_waterfall_c.py +++ b/gr-qtgui/examples/pyqt_waterfall_c.py @@ -21,6 +21,7 @@ # from gnuradio import gr, filter +from gnuradio import blocks import sys try: @@ -157,7 +158,7 @@ class my_top_block(gr.top_block): src1 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f1, 0.1, 0) src2 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_cc() + src = blocks.add_cc() channel = channels.channel_model(0.01) thr = gr.throttle(gr.sizeof_gr_complex, 100*npts) self.snk1 = qtgui.waterfall_sink_c(npts, filter.firdes.WIN_BLACKMAN_hARRIS, diff --git a/gr-qtgui/examples/pyqt_waterfall_f.py b/gr-qtgui/examples/pyqt_waterfall_f.py index 725117d06b..1c4063e31b 100755 --- a/gr-qtgui/examples/pyqt_waterfall_f.py +++ b/gr-qtgui/examples/pyqt_waterfall_f.py @@ -21,6 +21,7 @@ # from gnuradio import gr, filter +from gnuradio import blocks import sys try: @@ -147,7 +148,7 @@ class my_top_block(gr.top_block): src1 = analog.sig_source_f(Rs, analog.GR_SIN_WAVE, f1, 0.1, 0) src2 = analog.sig_source_f(Rs, analog.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_ff() + src = blocks.add_ff() thr = gr.throttle(gr.sizeof_float, 100*npts) self.snk1 = qtgui.waterfall_sink_f(npts, filter.firdes.WIN_BLACKMAN_hARRIS, 0, Rs, diff --git a/gr-trellis/CMakeLists.txt b/gr-trellis/CMakeLists.txt index 2685be2950..b764998e8c 100644 --- a/gr-trellis/CMakeLists.txt +++ b/gr-trellis/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -29,12 +29,18 @@ include(GrComponent) GR_REGISTER_COMPONENT("gr-trellis" ENABLE_GR_TRELLIS Boost_FOUND ENABLE_GR_CORE + ENABLE_GR_ANALOG + ENABLE_GR_BLOCKS ENABLE_GR_DIGITAL ) GR_SET_GLOBAL(GR_TRELLIS_INCLUDE_DIRS - ${CMAKE_CURRENT_BINARY_DIR}/src/lib - ${CMAKE_CURRENT_SOURCE_DIR}/src/lib + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_BINARY_DIR}/include +) + +GR_SET_GLOBAL(GR_TRELLIS_SWIG_INCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/swig ) SET(GR_PKG_TRELLIS_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/trellis) @@ -94,9 +100,14 @@ CPACK_COMPONENT("trellis_swig" ######################################################################## # Add subdirectories ######################################################################## -add_subdirectory(src) +add_subdirectory(include/trellis) +add_subdirectory(lib) add_subdirectory(doc) if(ENABLE_PYTHON) + add_subdirectory(swig) + add_subdirectory(python) + add_subdirectory(examples/python) + add_subdirectory(examples/grc) add_subdirectory(grc) endif(ENABLE_PYTHON) diff --git a/gr-trellis/doc/gr-trellis.xml b/gr-trellis/doc/gr-trellis.xml index 314fb2e05f..083c2f1637 100644 --- a/gr-trellis/doc/gr-trellis.xml +++ b/gr-trellis/doc/gr-trellis.xml @@ -597,7 +597,7 @@ r_k=(rk1,rk2,...,rkD). </para> <programlisting> 22 # CHANNEL - 23 add = gr.add_ff() + 23 add = blocks.add_ff() 24 noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) </programlisting> @@ -814,7 +814,7 @@ The modulated symbols are filtered by the ISI channel and AWGN with appropriate <programlisting> 28 # CHANNEL 29 isi = gr.fir_filter_fff(1,channel) - 30 add = gr.add_ff() + 30 add = blocks.add_ff() 31 noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) </programlisting> diff --git a/gr-trellis/doc/test_tcm.py b/gr-trellis/doc/test_tcm.py index 181ba643d6..641e7dd6db 100644 --- a/gr-trellis/doc/test_tcm.py +++ b/gr-trellis/doc/test_tcm.py @@ -2,7 +2,7 @@ from gnuradio import gr from gnuradio import audio -from gnuradio import trellis, digital +from gnuradio import trellis, digital, blocks from gnuradio import eng_notation import math import sys @@ -26,7 +26,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): mod = digital.chunks_to_symbols_sf(constellation,dimensionality) # CHANNEL - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX diff --git a/gr-trellis/doc/test_tcm.py.xml b/gr-trellis/doc/test_tcm.py.xml index 4122fafff8..29052faebc 100644 --- a/gr-trellis/doc/test_tcm.py.xml +++ b/gr-trellis/doc/test_tcm.py.xml @@ -4,7 +4,7 @@ 2 3 from gnuradio import gr 4 from gnuradio import audio - 5 from gnuradio import trellis, digital, analog + 5 from gnuradio import trellis, digital, analog, blocks 6 from gnuradio import eng_notation 7 import math 8 import sys @@ -22,7 +22,7 @@ 20 mod = digital.chunks_to_symbols_sf(constellation,dimensionality) 21 22 # CHANNEL - 23 add = gr.add_ff() + 23 add = blocks.add_ff() 24 noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) 25 26 # RX diff --git a/gr-trellis/doc/test_viterbi_equalization1.py b/gr-trellis/doc/test_viterbi_equalization1.py index cac96df117..d53e2b3304 100755 --- a/gr-trellis/doc/test_viterbi_equalization1.py +++ b/gr-trellis/doc/test_viterbi_equalization1.py @@ -2,7 +2,7 @@ from gnuradio import gr from gnuradio import audio -from gnuradio import trellis, digital +from gnuradio import trellis, digital, filter, blocks from gnuradio import eng_notation import math import sys @@ -32,8 +32,8 @@ def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constel mod = digital.chunks_to_symbols_sf(modulation[1],modulation[0]) # CHANNEL - isi = gr.fir_filter_fff(1,channel) - add = gr.add_ff() + isi = filter.fir_filter_fff(1,channel) + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX diff --git a/gr-trellis/doc/test_viterbi_equalization1.py.xml b/gr-trellis/doc/test_viterbi_equalization1.py.xml index e1f2aeefcb..5aca46ab35 100644 --- a/gr-trellis/doc/test_viterbi_equalization1.py.xml +++ b/gr-trellis/doc/test_viterbi_equalization1.py.xml @@ -4,7 +4,7 @@ 2 3 from gnuradio import gr 4 from gnuradio import audio - 5 from gnuradio import trellis, digital, analog + 5 from gnuradio import trellis, digital, analog, filter, blocks 6 from gnuradio import eng_notation 7 import math 8 import sys @@ -28,8 +28,8 @@ 26 mod = digital.chunks_to_symbols_sf(modulation[1],modulation[0]) 27 28 # CHANNEL - 29 isi = gr.fir_filter_fff(1,channel) - 30 add = gr.add_ff() + 29 isi = filter.fir_filter_fff(1,channel) + 30 add = blocs.add_ff() 31 noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) 32 33 # RX diff --git a/gr-trellis/src/examples/grc/CMakeLists.txt b/gr-trellis/examples/grc/CMakeLists.txt index 46b825d888..46b825d888 100644 --- a/gr-trellis/src/examples/grc/CMakeLists.txt +++ b/gr-trellis/examples/grc/CMakeLists.txt diff --git a/gr-trellis/src/examples/grc/interference_cancellation.grc b/gr-trellis/examples/grc/interference_cancellation.grc index 129ee87905..891426660a 100644 --- a/gr-trellis/src/examples/grc/interference_cancellation.grc +++ b/gr-trellis/examples/grc/interference_cancellation.grc @@ -272,10 +272,10 @@ </param> </block> <block> - <key>gr_sub_xx</key> + <key>blocks_sub_xx</key> <param> <key>id</key> - <value>gr_sub_xx_0</value> + <value>blocks_sub_xx_0</value> </param> <param> <key>_enabled</key> @@ -303,10 +303,10 @@ </param> </block> <block> - <key>gr_multiply_xx</key> + <key>blocks_multiply_xx</key> <param> <key>id</key> - <value>gr_multiply_xx_0</value> + <value>blocks_multiply_xx_0</value> </param> <param> <key>_enabled</key> @@ -334,10 +334,10 @@ </param> </block> <block> - <key>gr_short_to_float</key> + <key>blocks_short_to_float</key> <param> <key>id</key> - <value>gr_short_to_float_0</value> + <value>blocks_short_to_float_0</value> </param> <param> <key>_enabled</key> @@ -361,10 +361,10 @@ </param> </block> <block> - <key>gr_sub_xx</key> + <key>blocks_sub_xx</key> <param> <key>id</key> - <value>gr_sub_xx_3</value> + <value>blocks_sub_xx_3</value> </param> <param> <key>_enabled</key> @@ -392,10 +392,10 @@ </param> </block> <block> - <key>gr_multiply_xx</key> + <key>blocks_multiply_xx</key> <param> <key>id</key> - <value>gr_multiply_xx_1</value> + <value>blocks_multiply_xx_1</value> </param> <param> <key>_enabled</key> @@ -423,10 +423,10 @@ </param> </block> <block> - <key>gr_short_to_float</key> + <key>blocks_short_to_float</key> <param> <key>id</key> - <value>gr_short_to_float_2</value> + <value>blocks_short_to_float_2</value> </param> <param> <key>_enabled</key> @@ -450,10 +450,10 @@ </param> </block> <block> - <key>gr_sub_xx</key> + <key>blocks_sub_xx</key> <param> <key>id</key> - <value>gr_sub_xx_2</value> + <value>blocks_sub_xx_2</value> </param> <param> <key>_enabled</key> @@ -481,10 +481,10 @@ </param> </block> <block> - <key>gr_sub_xx</key> + <key>blocks_sub_xx</key> <param> <key>id</key> - <value>gr_sub_xx_1</value> + <value>blocks_sub_xx_1</value> </param> <param> <key>_enabled</key> @@ -512,10 +512,10 @@ </param> </block> <block> - <key>gr_multiply_xx</key> + <key>blocks_multiply_xx</key> <param> <key>id</key> - <value>gr_multiply_xx_2</value> + <value>blocks_multiply_xx_2</value> </param> <param> <key>_enabled</key> @@ -543,10 +543,10 @@ </param> </block> <block> - <key>gr_short_to_float</key> + <key>blocks_short_to_float</key> <param> <key>id</key> - <value>gr_short_to_float_1</value> + <value>blocks_short_to_float_1</value> </param> <param> <key>_enabled</key> @@ -570,10 +570,10 @@ </param> </block> <block> - <key>gr_sub_xx</key> + <key>blocks_sub_xx</key> <param> <key>id</key> - <value>gr_sub_xx_2_0</value> + <value>blocks_sub_xx_2_0</value> </param> <param> <key>_enabled</key> @@ -601,10 +601,10 @@ </param> </block> <block> - <key>gr_sub_xx</key> + <key>blocks_sub_xx</key> <param> <key>id</key> - <value>gr_sub_xx_1_0</value> + <value>blocks_sub_xx_1_0</value> </param> <param> <key>_enabled</key> @@ -632,10 +632,10 @@ </param> </block> <block> - <key>gr_multiply_xx</key> + <key>blocks_multiply_xx</key> <param> <key>id</key> - <value>gr_multiply_xx_2_0</value> + <value>blocks_multiply_xx_2_0</value> </param> <param> <key>_enabled</key> @@ -663,10 +663,10 @@ </param> </block> <block> - <key>gr_short_to_float</key> + <key>blocks_short_to_float</key> <param> <key>id</key> - <value>gr_short_to_float_1_0</value> + <value>blocks_short_to_float_1_0</value> </param> <param> <key>_enabled</key> @@ -1410,10 +1410,10 @@ </param> </block> <block> - <key>gr_add_xx</key> + <key>blocks_add_xx</key> <param> <key>id</key> - <value>gr_add_xx_1</value> + <value>blocks_add_xx_1</value> </param> <param> <key>_enabled</key> @@ -1441,10 +1441,10 @@ </param> </block> <block> - <key>gr_add_xx</key> + <key>blocks_add_xx</key> <param> <key>id</key> - <value>gr_add_xx_0</value> + <value>blocks_add_xx_0</value> </param> <param> <key>_enabled</key> @@ -1538,10 +1538,10 @@ </param> </block> <block> - <key>gr_multiply_const_vxx</key> + <key>blocks_multiply_const_vxx</key> <param> <key>id</key> - <value>gr_multiply_const_vxx_0</value> + <value>blocks_multiply_const_vxx_0</value> </param> <param> <key>_enabled</key> @@ -1608,10 +1608,10 @@ </param> </block> <block> - <key>gr_multiply_const_vxx</key> + <key>blocks_multiply_const_vxx</key> <param> <key>id</key> - <value>gr_multiply_const_vxx_1</value> + <value>blocks_multiply_const_vxx_1</value> </param> <param> <key>_enabled</key> @@ -1748,10 +1748,10 @@ </param> </block> <block> - <key>gr_multiply_const_vxx</key> + <key>blocks_multiply_const_vxx</key> <param> <key>id</key> - <value>gr_multiply_const_vxx_2</value> + <value>blocks_multiply_const_vxx_2</value> </param> <param> <key>_enabled</key> @@ -1810,10 +1810,10 @@ </param> </block> <block> - <key>gr_multiply_const_vxx</key> + <key>blocks_multiply_const_vxx</key> <param> <key>id</key> - <value>gr_multiply_const_vxx_2_0</value> + <value>blocks_multiply_const_vxx_2_0</value> </param> <param> <key>_enabled</key> @@ -1917,50 +1917,50 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_const_vxx_0</source_block_id> - <sink_block_id>gr_add_xx_0</sink_block_id> + <source_block_id>blocks_multiply_const_vxx_0</source_block_id> + <sink_block_id>blocks_add_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_0</source_block_id> - <sink_block_id>gr_add_xx_1</sink_block_id> + <source_block_id>blocks_add_xx_0</source_block_id> + <sink_block_id>blocks_add_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_const_vxx_1</source_block_id> - <sink_block_id>gr_add_xx_0</sink_block_id> + <source_block_id>blocks_multiply_const_vxx_1</source_block_id> + <sink_block_id>blocks_add_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_0</source_block_id> - <sink_block_id>gr_multiply_xx_0</sink_block_id> + <source_block_id>blocks_sub_xx_0</source_block_id> + <sink_block_id>blocks_multiply_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_0</source_block_id> - <sink_block_id>gr_multiply_xx_0</sink_block_id> + <source_block_id>blocks_sub_xx_0</source_block_id> + <sink_block_id>blocks_multiply_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_multiply_xx_0</source_block_id> - <sink_block_id>gr_short_to_float_0</sink_block_id> + <source_block_id>blocks_multiply_xx_0</source_block_id> + <sink_block_id>blocks_short_to_float_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_short_to_float_0</source_block_id> + <source_block_id>blocks_short_to_float_0</source_block_id> <sink_block_id>wxgui_numbersink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_xx_2</source_block_id> - <sink_block_id>gr_short_to_float_1</sink_block_id> + <source_block_id>blocks_multiply_xx_2</source_block_id> + <sink_block_id>blocks_short_to_float_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> @@ -1971,62 +1971,62 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_1</source_block_id> + <source_block_id>blocks_add_xx_1</source_block_id> <sink_block_id>trellis_viterbi_combined_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>random_source_x_0</source_block_id> - <sink_block_id>gr_sub_xx_0</sink_block_id> + <sink_block_id>blocks_sub_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>trellis_viterbi_combined_xx_1</source_block_id> - <sink_block_id>gr_sub_xx_0</sink_block_id> + <sink_block_id>blocks_sub_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> <source_block_id>trellis_viterbi_combined_xx_0</source_block_id> - <sink_block_id>gr_sub_xx_1</sink_block_id> + <sink_block_id>blocks_sub_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> <source_block_id>random_source_x_1</source_block_id> - <sink_block_id>gr_sub_xx_1</sink_block_id> + <sink_block_id>blocks_sub_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_1</source_block_id> - <sink_block_id>gr_multiply_xx_2</sink_block_id> + <source_block_id>blocks_sub_xx_1</source_block_id> + <sink_block_id>blocks_multiply_xx_2</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_1</source_block_id> - <sink_block_id>gr_multiply_xx_2</sink_block_id> + <source_block_id>blocks_sub_xx_1</source_block_id> + <sink_block_id>blocks_multiply_xx_2</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_2</source_block_id> + <source_block_id>blocks_sub_xx_2</source_block_id> <sink_block_id>trellis_viterbi_combined_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_1</source_block_id> - <sink_block_id>gr_sub_xx_2</sink_block_id> + <source_block_id>blocks_add_xx_1</source_block_id> + <sink_block_id>blocks_sub_xx_2</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_const_vxx_2</source_block_id> - <sink_block_id>gr_sub_xx_2</sink_block_id> + <source_block_id>blocks_multiply_const_vxx_2</source_block_id> + <sink_block_id>blocks_sub_xx_2</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> @@ -2037,49 +2037,49 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_xx_1</source_block_id> - <sink_block_id>gr_short_to_float_2</sink_block_id> + <source_block_id>blocks_multiply_xx_1</source_block_id> + <sink_block_id>blocks_short_to_float_2</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_short_to_float_2</source_block_id> + <source_block_id>blocks_short_to_float_2</source_block_id> <sink_block_id>wxgui_numbersink2_2</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>trellis_viterbi_combined_xx_2</source_block_id> - <sink_block_id>gr_sub_xx_3</sink_block_id> + <sink_block_id>blocks_sub_xx_3</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_3</source_block_id> - <sink_block_id>gr_multiply_xx_1</sink_block_id> + <source_block_id>blocks_sub_xx_3</source_block_id> + <sink_block_id>blocks_multiply_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_3</source_block_id> - <sink_block_id>gr_multiply_xx_1</sink_block_id> + <source_block_id>blocks_sub_xx_3</source_block_id> + <sink_block_id>blocks_multiply_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_1</source_block_id> + <source_block_id>blocks_add_xx_1</source_block_id> <sink_block_id>trellis_viterbi_combined_xx_2</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>random_source_x_1</source_block_id> - <sink_block_id>gr_sub_xx_3</sink_block_id> + <sink_block_id>blocks_sub_xx_3</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_short_to_float_1</source_block_id> + <source_block_id>blocks_short_to_float_1</source_block_id> <sink_block_id>wxgui_numbersink2_3</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -2091,61 +2091,61 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_xx_2_0</source_block_id> - <sink_block_id>gr_short_to_float_1_0</sink_block_id> + <source_block_id>blocks_multiply_xx_2_0</source_block_id> + <sink_block_id>blocks_short_to_float_1_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>trellis_viterbi_combined_xx_0_0</source_block_id> - <sink_block_id>gr_sub_xx_1_0</sink_block_id> + <sink_block_id>blocks_sub_xx_1_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_1_0</source_block_id> - <sink_block_id>gr_multiply_xx_2_0</sink_block_id> + <source_block_id>blocks_sub_xx_1_0</source_block_id> + <sink_block_id>blocks_multiply_xx_2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_1_0</source_block_id> - <sink_block_id>gr_multiply_xx_2_0</sink_block_id> + <source_block_id>blocks_sub_xx_1_0</source_block_id> + <sink_block_id>blocks_multiply_xx_2_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_2_0</source_block_id> + <source_block_id>blocks_sub_xx_2_0</source_block_id> <sink_block_id>trellis_viterbi_combined_xx_0_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_short_to_float_1_0</source_block_id> + <source_block_id>blocks_short_to_float_1_0</source_block_id> <sink_block_id>wxgui_numbersink2_3_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_1</source_block_id> - <sink_block_id>gr_sub_xx_2_0</sink_block_id> + <source_block_id>blocks_add_xx_1</source_block_id> + <sink_block_id>blocks_sub_xx_2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>random_source_x_0</source_block_id> - <sink_block_id>gr_sub_xx_1_0</sink_block_id> + <sink_block_id>blocks_sub_xx_1_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_const_vxx_2_0</source_block_id> - <sink_block_id>gr_sub_xx_2_0</sink_block_id> + <source_block_id>blocks_multiply_const_vxx_2_0</source_block_id> + <sink_block_id>blocks_sub_xx_2_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_1</source_block_id> + <source_block_id>blocks_add_xx_1</source_block_id> <sink_block_id>wxgui_scopesink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -2158,7 +2158,7 @@ </connection> <connection> <source_block_id>analog_noise_source_x_0</source_block_id> - <sink_block_id>gr_add_xx_1</sink_block_id> + <sink_block_id>blocks_add_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> @@ -2170,13 +2170,13 @@ </connection> <connection> <source_block_id>digital_chunks_to_symbols_xx_0</source_block_id> - <sink_block_id>gr_multiply_const_vxx_0</sink_block_id> + <sink_block_id>blocks_multiply_const_vxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>digital_chunks_to_symbols_xx_0_0</source_block_id> - <sink_block_id>gr_multiply_const_vxx_1</sink_block_id> + <sink_block_id>blocks_multiply_const_vxx_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> @@ -2194,7 +2194,7 @@ </connection> <connection> <source_block_id>digital_chunks_to_symbols_xx_0_0_0</source_block_id> - <sink_block_id>gr_multiply_const_vxx_2</sink_block_id> + <sink_block_id>blocks_multiply_const_vxx_2</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> @@ -2206,7 +2206,7 @@ </connection> <connection> <source_block_id>digital_chunks_to_symbols_xx_0_0_1</source_block_id> - <sink_block_id>gr_multiply_const_vxx_2_0</sink_block_id> + <sink_block_id>blocks_multiply_const_vxx_2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-trellis/src/examples/grc/pccc.grc b/gr-trellis/examples/grc/pccc.grc index 06fa9cd69f..a9f65cf856 100644 --- a/gr-trellis/src/examples/grc/pccc.grc +++ b/gr-trellis/examples/grc/pccc.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Sat Nov 10 15:37:00 2012</timestamp> + <timestamp>Thu Dec 27 13:49:53 2012</timestamp> <block> <key>options</key> <param> @@ -185,10 +185,10 @@ </param> </block> <block> - <key>gr_multiply_xx</key> + <key>blocks_multiply_xx</key> <param> <key>id</key> - <value>gr_multiply_xx_2_0</value> + <value>blocks_multiply_xx_2_0</value> </param> <param> <key>_enabled</key> @@ -216,10 +216,10 @@ </param> </block> <block> - <key>gr_short_to_float</key> + <key>blocks_short_to_float</key> <param> <key>id</key> - <value>gr_short_to_float_1_0</value> + <value>blocks_short_to_float_1_0</value> </param> <param> <key>_enabled</key> @@ -597,10 +597,10 @@ </param> </block> <block> - <key>gr_sub_xx</key> + <key>blocks_sub_xx</key> <param> <key>id</key> - <value>gr_sub_xx_0</value> + <value>blocks_sub_xx_0</value> </param> <param> <key>_enabled</key> @@ -733,10 +733,10 @@ </param> </block> <block> - <key>gr_add_xx</key> + <key>blocks_add_xx</key> <param> <key>id</key> - <value>gr_add_xx_1</value> + <value>blocks_add_xx_1</value> </param> <param> <key>_enabled</key> @@ -765,37 +765,37 @@ </block> <connection> <source_block_id>random_source_x_0</source_block_id> - <sink_block_id>gr_sub_xx_0</sink_block_id> + <sink_block_id>blocks_sub_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_1</source_block_id> + <source_block_id>blocks_add_xx_1</source_block_id> <sink_block_id>wxgui_scopesink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_xx_2_0</source_block_id> - <sink_block_id>gr_short_to_float_1_0</sink_block_id> + <source_block_id>blocks_multiply_xx_2_0</source_block_id> + <sink_block_id>blocks_short_to_float_1_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_short_to_float_1_0</source_block_id> + <source_block_id>blocks_short_to_float_1_0</source_block_id> <sink_block_id>wxgui_numbersink2_3_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_0</source_block_id> - <sink_block_id>gr_multiply_xx_2_0</sink_block_id> + <source_block_id>blocks_sub_xx_0</source_block_id> + <sink_block_id>blocks_multiply_xx_2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_0</source_block_id> - <sink_block_id>gr_multiply_xx_2_0</sink_block_id> + <source_block_id>blocks_sub_xx_0</source_block_id> + <sink_block_id>blocks_multiply_xx_2_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> @@ -812,20 +812,20 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_1</source_block_id> + <source_block_id>blocks_add_xx_1</source_block_id> <sink_block_id>trellis_pccc_decoder_combined_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>trellis_pccc_decoder_combined_xx_0</source_block_id> - <sink_block_id>gr_sub_xx_0</sink_block_id> + <sink_block_id>blocks_sub_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> <source_block_id>analog_noise_source_x_0</source_block_id> - <sink_block_id>gr_add_xx_1</sink_block_id> + <sink_block_id>blocks_add_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> @@ -837,7 +837,7 @@ </connection> <connection> <source_block_id>digital_chunks_to_symbols_xx_0</source_block_id> - <sink_block_id>gr_add_xx_1</sink_block_id> + <sink_block_id>blocks_add_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-trellis/src/examples/grc/pccc1.grc b/gr-trellis/examples/grc/pccc1.grc index c111ebd3ec..1bc0e189d0 100644 --- a/gr-trellis/src/examples/grc/pccc1.grc +++ b/gr-trellis/examples/grc/pccc1.grc @@ -185,10 +185,10 @@ </param> </block> <block> - <key>gr_multiply_xx</key> + <key>blocks_multiply_xx</key> <param> <key>id</key> - <value>gr_multiply_xx_2_0</value> + <value>blocks_multiply_xx_2_0</value> </param> <param> <key>_enabled</key> @@ -216,10 +216,10 @@ </param> </block> <block> - <key>gr_short_to_float</key> + <key>blocks_short_to_float</key> <param> <key>id</key> - <value>gr_short_to_float_1_0</value> + <value>blocks_short_to_float_1_0</value> </param> <param> <key>_enabled</key> @@ -444,10 +444,10 @@ </param> </block> <block> - <key>gr_sub_xx</key> + <key>blocks_sub_xx</key> <param> <key>id</key> - <value>gr_sub_xx_0</value> + <value>blocks_sub_xx_0</value> </param> <param> <key>_enabled</key> @@ -678,10 +678,10 @@ </param> </block> <block> - <key>gr_add_xx</key> + <key>blocks_add_xx</key> <param> <key>id</key> - <value>gr_add_xx_1</value> + <value>blocks_add_xx_1</value> </param> <param> <key>_enabled</key> @@ -784,42 +784,42 @@ </block> <connection> <source_block_id>random_source_x_0</source_block_id> - <sink_block_id>gr_sub_xx_0</sink_block_id> + <sink_block_id>blocks_sub_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_1</source_block_id> + <source_block_id>blocks_add_xx_1</source_block_id> <sink_block_id>wxgui_scopesink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_xx_2_0</source_block_id> - <sink_block_id>gr_short_to_float_1_0</sink_block_id> + <source_block_id>blocks_multiply_xx_2_0</source_block_id> + <sink_block_id>blocks_short_to_float_1_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_short_to_float_1_0</source_block_id> + <source_block_id>blocks_short_to_float_1_0</source_block_id> <sink_block_id>wxgui_numbersink2_3_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_0</source_block_id> - <sink_block_id>gr_multiply_xx_2_0</sink_block_id> + <source_block_id>blocks_sub_xx_0</source_block_id> + <sink_block_id>blocks_multiply_xx_2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_0</source_block_id> - <sink_block_id>gr_multiply_xx_2_0</sink_block_id> + <source_block_id>blocks_sub_xx_0</source_block_id> + <sink_block_id>blocks_multiply_xx_2_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_1</source_block_id> + <source_block_id>blocks_add_xx_1</source_block_id> <sink_block_id>trellis_metrics_x_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -844,7 +844,7 @@ </connection> <connection> <source_block_id>trellis_pccc_decoder_x_0</source_block_id> - <sink_block_id>gr_sub_xx_0</sink_block_id> + <sink_block_id>blocks_sub_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> @@ -856,13 +856,13 @@ </connection> <connection> <source_block_id>digital_chunks_to_symbols_xx_0</source_block_id> - <sink_block_id>gr_add_xx_1</sink_block_id> + <sink_block_id>blocks_add_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>analog_noise_source_x_0</source_block_id> - <sink_block_id>gr_add_xx_1</sink_block_id> + <sink_block_id>blocks_add_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> diff --git a/gr-trellis/src/examples/grc/readme.txt b/gr-trellis/examples/grc/readme.txt index a5261ac0b2..a5261ac0b2 100644 --- a/gr-trellis/src/examples/grc/readme.txt +++ b/gr-trellis/examples/grc/readme.txt diff --git a/gr-trellis/src/examples/grc/sccc.grc b/gr-trellis/examples/grc/sccc.grc index 36657f5441..abfbeb8b81 100644 --- a/gr-trellis/src/examples/grc/sccc.grc +++ b/gr-trellis/examples/grc/sccc.grc @@ -169,10 +169,10 @@ </param> </block> <block> - <key>gr_sub_xx</key> + <key>blocks_sub_xx</key> <param> <key>id</key> - <value>gr_sub_xx_0</value> + <value>blocks_sub_xx_0</value> </param> <param> <key>_enabled</key> @@ -200,10 +200,10 @@ </param> </block> <block> - <key>gr_multiply_xx</key> + <key>blocks_multiply_xx</key> <param> <key>id</key> - <value>gr_multiply_xx_2_0</value> + <value>blocks_multiply_xx_2_0</value> </param> <param> <key>_enabled</key> @@ -231,10 +231,10 @@ </param> </block> <block> - <key>gr_short_to_float</key> + <key>blocks_short_to_float</key> <param> <key>id</key> - <value>gr_short_to_float_1_0</value> + <value>blocks_short_to_float_1_0</value> </param> <param> <key>_enabled</key> @@ -659,10 +659,10 @@ </param> </block> <block> - <key>gr_add_xx</key> + <key>blocks_add_xx</key> <param> <key>id</key> - <value>gr_add_xx_1</value> + <value>blocks_add_xx_1</value> </param> <param> <key>_enabled</key> @@ -765,12 +765,12 @@ </block> <connection> <source_block_id>random_source_x_0</source_block_id> - <sink_block_id>gr_sub_xx_0</sink_block_id> + <sink_block_id>blocks_sub_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_1</source_block_id> + <source_block_id>blocks_add_xx_1</source_block_id> <sink_block_id>wxgui_scopesink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -788,38 +788,38 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_1</source_block_id> + <source_block_id>blocks_add_xx_1</source_block_id> <sink_block_id>trellis_sccc_decoder_combined_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>trellis_sccc_decoder_combined_xx_0</source_block_id> - <sink_block_id>gr_sub_xx_0</sink_block_id> + <sink_block_id>blocks_sub_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_multiply_xx_2_0</source_block_id> - <sink_block_id>gr_short_to_float_1_0</sink_block_id> + <source_block_id>blocks_multiply_xx_2_0</source_block_id> + <sink_block_id>blocks_short_to_float_1_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_short_to_float_1_0</source_block_id> + <source_block_id>blocks_short_to_float_1_0</source_block_id> <sink_block_id>wxgui_numbersink2_3_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_0</source_block_id> - <sink_block_id>gr_multiply_xx_2_0</sink_block_id> + <source_block_id>blocks_sub_xx_0</source_block_id> + <sink_block_id>blocks_multiply_xx_2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_0</source_block_id> - <sink_block_id>gr_multiply_xx_2_0</sink_block_id> + <source_block_id>blocks_sub_xx_0</source_block_id> + <sink_block_id>blocks_multiply_xx_2_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> @@ -831,13 +831,13 @@ </connection> <connection> <source_block_id>analog_noise_source_x_0</source_block_id> - <sink_block_id>gr_add_xx_1</sink_block_id> + <sink_block_id>blocks_add_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> <source_block_id>digital_chunks_to_symbols_xx_0</source_block_id> - <sink_block_id>gr_add_xx_1</sink_block_id> + <sink_block_id>blocks_add_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-trellis/src/examples/grc/sccc1.grc b/gr-trellis/examples/grc/sccc1.grc index 17626e3dce..906ca25389 100644 --- a/gr-trellis/src/examples/grc/sccc1.grc +++ b/gr-trellis/examples/grc/sccc1.grc @@ -357,10 +357,10 @@ </param> </block> <block> - <key>gr_sub_xx</key> + <key>blocks_sub_xx</key> <param> <key>id</key> - <value>gr_sub_xx_0</value> + <value>blocks_sub_xx_0</value> </param> <param> <key>_enabled</key> @@ -388,10 +388,10 @@ </param> </block> <block> - <key>gr_multiply_xx</key> + <key>blocks_multiply_xx</key> <param> <key>id</key> - <value>gr_multiply_xx_2_0</value> + <value>blocks_multiply_xx_2_0</value> </param> <param> <key>_enabled</key> @@ -419,10 +419,10 @@ </param> </block> <block> - <key>gr_short_to_float</key> + <key>blocks_short_to_float</key> <param> <key>id</key> - <value>gr_short_to_float_1_0</value> + <value>blocks_short_to_float_1_0</value> </param> <param> <key>_enabled</key> @@ -717,10 +717,10 @@ </param> </block> <block> - <key>gr_add_xx</key> + <key>blocks_add_xx</key> <param> <key>id</key> - <value>gr_add_xx_1</value> + <value>blocks_add_xx_1</value> </param> <param> <key>_enabled</key> @@ -784,12 +784,12 @@ </block> <connection> <source_block_id>random_source_x_0</source_block_id> - <sink_block_id>gr_sub_xx_0</sink_block_id> + <sink_block_id>blocks_sub_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_1</source_block_id> + <source_block_id>blocks_add_xx_1</source_block_id> <sink_block_id>wxgui_scopesink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -807,31 +807,31 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_xx_2_0</source_block_id> - <sink_block_id>gr_short_to_float_1_0</sink_block_id> + <source_block_id>blocks_multiply_xx_2_0</source_block_id> + <sink_block_id>blocks_short_to_float_1_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_short_to_float_1_0</source_block_id> + <source_block_id>blocks_short_to_float_1_0</source_block_id> <sink_block_id>wxgui_numbersink2_3_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_0</source_block_id> - <sink_block_id>gr_multiply_xx_2_0</sink_block_id> + <source_block_id>blocks_sub_xx_0</source_block_id> + <sink_block_id>blocks_multiply_xx_2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sub_xx_0</source_block_id> - <sink_block_id>gr_multiply_xx_2_0</sink_block_id> + <source_block_id>blocks_sub_xx_0</source_block_id> + <sink_block_id>blocks_multiply_xx_2_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_add_xx_1</source_block_id> + <source_block_id>blocks_add_xx_1</source_block_id> <sink_block_id>trellis_metrics_x_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -844,7 +844,7 @@ </connection> <connection> <source_block_id>trellis_sccc_decoder_x_0</source_block_id> - <sink_block_id>gr_sub_xx_0</sink_block_id> + <sink_block_id>blocks_sub_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> @@ -856,13 +856,13 @@ </connection> <connection> <source_block_id>digital_chunks_to_symbols_xx_0</source_block_id> - <sink_block_id>gr_add_xx_1</sink_block_id> + <sink_block_id>blocks_add_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>analog_noise_source_x_0</source_block_id> - <sink_block_id>gr_add_xx_1</sink_block_id> + <sink_block_id>blocks_add_xx_1</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> diff --git a/gr-trellis/src/examples/python/CMakeLists.txt b/gr-trellis/examples/python/CMakeLists.txt index e2c7e70ff7..e2c7e70ff7 100644 --- a/gr-trellis/src/examples/python/CMakeLists.txt +++ b/gr-trellis/examples/python/CMakeLists.txt diff --git a/gr-trellis/src/examples/python/README b/gr-trellis/examples/python/README index d51f231ac3..d51f231ac3 100644 --- a/gr-trellis/src/examples/python/README +++ b/gr-trellis/examples/python/README diff --git a/gr-trellis/src/examples/python/fsm_files/awgn1o2_128.fsm b/gr-trellis/examples/python/fsm_files/awgn1o2_128.fsm index 4b47007c50..4b47007c50 100644 --- a/gr-trellis/src/examples/python/fsm_files/awgn1o2_128.fsm +++ b/gr-trellis/examples/python/fsm_files/awgn1o2_128.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/awgn1o2_16.fsm b/gr-trellis/examples/python/fsm_files/awgn1o2_16.fsm index cdab41359e..cdab41359e 100644 --- a/gr-trellis/src/examples/python/fsm_files/awgn1o2_16.fsm +++ b/gr-trellis/examples/python/fsm_files/awgn1o2_16.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/awgn1o2_4.fsm b/gr-trellis/examples/python/fsm_files/awgn1o2_4.fsm index fb316b5ef8..fb316b5ef8 100644 --- a/gr-trellis/src/examples/python/fsm_files/awgn1o2_4.fsm +++ b/gr-trellis/examples/python/fsm_files/awgn1o2_4.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/awgn1o2_8.fsm b/gr-trellis/examples/python/fsm_files/awgn1o2_8.fsm index 604bac6c2c..604bac6c2c 100644 --- a/gr-trellis/src/examples/python/fsm_files/awgn1o2_8.fsm +++ b/gr-trellis/examples/python/fsm_files/awgn1o2_8.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/awgn2o3_16.fsm b/gr-trellis/examples/python/fsm_files/awgn2o3_16.fsm index 9630cd9afb..9630cd9afb 100644 --- a/gr-trellis/src/examples/python/fsm_files/awgn2o3_16.fsm +++ b/gr-trellis/examples/python/fsm_files/awgn2o3_16.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/awgn2o3_4.fsm b/gr-trellis/examples/python/fsm_files/awgn2o3_4.fsm index 3ac57be18d..3ac57be18d 100644 --- a/gr-trellis/src/examples/python/fsm_files/awgn2o3_4.fsm +++ b/gr-trellis/examples/python/fsm_files/awgn2o3_4.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/awgn2o3_4_msb.fsm b/gr-trellis/examples/python/fsm_files/awgn2o3_4_msb.fsm index d834c52718..d834c52718 100644 --- a/gr-trellis/src/examples/python/fsm_files/awgn2o3_4_msb.fsm +++ b/gr-trellis/examples/python/fsm_files/awgn2o3_4_msb.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/awgn2o3_4_msbG.fsm b/gr-trellis/examples/python/fsm_files/awgn2o3_4_msbG.fsm index 8956c53da2..8956c53da2 100644 --- a/gr-trellis/src/examples/python/fsm_files/awgn2o3_4_msbG.fsm +++ b/gr-trellis/examples/python/fsm_files/awgn2o3_4_msbG.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/awgn2o3_8.fsm b/gr-trellis/examples/python/fsm_files/awgn2o3_8.fsm index 34deeb68cb..34deeb68cb 100644 --- a/gr-trellis/src/examples/python/fsm_files/awgn2o3_8.fsm +++ b/gr-trellis/examples/python/fsm_files/awgn2o3_8.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/awgn2o4_4.fsm b/gr-trellis/examples/python/fsm_files/awgn2o4_4.fsm index a895be8965..a895be8965 100644 --- a/gr-trellis/src/examples/python/fsm_files/awgn2o4_4.fsm +++ b/gr-trellis/examples/python/fsm_files/awgn2o4_4.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/disconnected.fsm b/gr-trellis/examples/python/fsm_files/disconnected.fsm index 847963e7b2..847963e7b2 100644 --- a/gr-trellis/src/examples/python/fsm_files/disconnected.fsm +++ b/gr-trellis/examples/python/fsm_files/disconnected.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/irregular.fsm b/gr-trellis/examples/python/fsm_files/irregular.fsm index 80b82b889d..80b82b889d 100644 --- a/gr-trellis/src/examples/python/fsm_files/irregular.fsm +++ b/gr-trellis/examples/python/fsm_files/irregular.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/joint_16_16.fsm b/gr-trellis/examples/python/fsm_files/joint_16_16.fsm index 293ff4e7c6..293ff4e7c6 100644 --- a/gr-trellis/src/examples/python/fsm_files/joint_16_16.fsm +++ b/gr-trellis/examples/python/fsm_files/joint_16_16.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/joint_4_16.fsm b/gr-trellis/examples/python/fsm_files/joint_4_16.fsm index 427a182071..427a182071 100644 --- a/gr-trellis/src/examples/python/fsm_files/joint_4_16.fsm +++ b/gr-trellis/examples/python/fsm_files/joint_4_16.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/rep3.fsm b/gr-trellis/examples/python/fsm_files/rep3.fsm index ef1bd1f025..ef1bd1f025 100644 --- a/gr-trellis/src/examples/python/fsm_files/rep3.fsm +++ b/gr-trellis/examples/python/fsm_files/rep3.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/rep5.fsm b/gr-trellis/examples/python/fsm_files/rep5.fsm index 2aa5d77cfb..2aa5d77cfb 100644 --- a/gr-trellis/src/examples/python/fsm_files/rep5.fsm +++ b/gr-trellis/examples/python/fsm_files/rep5.fsm diff --git a/gr-trellis/src/examples/python/fsm_files/simple.fsm b/gr-trellis/examples/python/fsm_files/simple.fsm index f27f6b4b05..f27f6b4b05 100644 --- a/gr-trellis/src/examples/python/fsm_files/simple.fsm +++ b/gr-trellis/examples/python/fsm_files/simple.fsm diff --git a/gr-trellis/src/examples/python/fsm_utils.py b/gr-trellis/examples/python/fsm_utils.py index 06855ea775..06855ea775 100755 --- a/gr-trellis/src/examples/python/fsm_utils.py +++ b/gr-trellis/examples/python/fsm_utils.py diff --git a/gr-trellis/src/examples/python/test_cpm.py b/gr-trellis/examples/python/test_cpm.py index 6b9b9a4f52..8d1e2024c1 100755 --- a/gr-trellis/src/examples/python/test_cpm.py +++ b/gr-trellis/examples/python/test_cpm.py @@ -8,7 +8,7 @@ ################################################## from gnuradio import gr -from gnuradio import trellis, digital, filter +from gnuradio import trellis, digital, filter, blocks from grc_gnuradio import blks2 as grc_blks2 import math import numpy @@ -95,18 +95,18 @@ def run_test(seed,blocksize): ################################################## random_source_x_0 = gr.vector_source_b(data.tolist(), False) digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf((-1, 1), 1) - gr_interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(Q, p) - gr_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2*math.pi*h*(1.0/Q)) + filter_interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(Q, p) + analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2*math.pi*h*(1.0/Q)) - gr_add_vxx_0 = gr.add_vcc(1) - gr_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, (N0/2.0)**0.5, -long(seed)) + blocks_add_vxx_0 = blocks.add_vcc(1) + analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, (N0/2.0)**0.5, -long(seed)) - gr_multiply_vxx_0 = gr.multiply_vcc(1) - gr_sig_source_x_0 = analog.sig_source_c(Q, analog.GR_COS_WAVE, -f0T, 1, 0) + blokcs_multiply_vxx_0 = blocks.multiply_vcc(1) + analog_sig_source_x_0 = analog.sig_source_c(Q, analog.GR_COS_WAVE, -f0T, 1, 0) # only works for N=2, do it manually for N>2... - gr_fir_filter_xxx_0_0 = filter.fir_filter_ccc(Q, MF[0].conjugate()) - gr_fir_filter_xxx_0_0_0 = filter.fir_filter_ccc(Q, MF[1].conjugate()) - gr_streams_to_stream_0 = gr.streams_to_stream(gr.sizeof_gr_complex*1, int(N)) + filter_fir_filter_xxx_0_0 = filter.fir_filter_ccc(Q, MF[0].conjugate()) + filter_fir_filter_xxx_0_0_0 = filter.fir_filter_ccc(Q, MF[1].conjugate()) + blocks_streams_to_stream_0 = blocks.streams_to_stream(gr.sizeof_gr_complex*1, int(N)) gr_skiphead_0 = gr.skiphead(gr.sizeof_gr_complex*1, int(N*(1+0))) viterbi = trellis.viterbi_combined_cb(f, head+blocksize+tail, 0, -1, int(N), constellation, digital.TRELLIS_EUCLIDEAN) @@ -117,17 +117,17 @@ def run_test(seed,blocksize): # Connections ################################################## tb.connect((random_source_x_0, 0), (digital_chunks_to_symbols_xx_0, 0)) - tb.connect((digital_chunks_to_symbols_xx_0, 0), (gr_interp_fir_filter_xxx_0, 0)) - tb.connect((gr_interp_fir_filter_xxx_0, 0), (gr_frequency_modulator_fc_0, 0)) - tb.connect((gr_frequency_modulator_fc_0, 0), (gr_add_vxx_0, 0)) - tb.connect((gr_noise_source_x_0, 0), (gr_add_vxx_0, 1)) - tb.connect((gr_add_vxx_0, 0), (gr_multiply_vxx_0, 0)) - tb.connect((gr_sig_source_x_0, 0), (gr_multiply_vxx_0, 1)) - tb.connect((gr_multiply_vxx_0, 0), (gr_fir_filter_xxx_0_0, 0)) - tb.connect((gr_multiply_vxx_0, 0), (gr_fir_filter_xxx_0_0_0, 0)) - tb.connect((gr_fir_filter_xxx_0_0, 0), (gr_streams_to_stream_0, 0)) - tb.connect((gr_fir_filter_xxx_0_0_0, 0), (gr_streams_to_stream_0, 1)) - tb.connect((gr_streams_to_stream_0, 0), (gr_skiphead_0, 0)) + tb.connect((digital_chunks_to_symbols_xx_0, 0), (filter_interp_fir_filter_xxx_0, 0)) + tb.connect((filter_interp_fir_filter_xxx_0, 0), (analog_frequency_modulator_fc_0, 0)) + tb.connect((analog_frequency_modulator_fc_0, 0), (blocks_add_vxx_0, 0)) + tb.connect((analog_noise_source_x_0, 0), (blocks_add_vxx_0, 1)) + tb.connect((blocks_add_vxx_0, 0), (blocks_multiply_vxx_0, 0)) + tb.connect((analog_sig_source_x_0, 0), (blocks_multiply_vxx_0, 1)) + tb.connect((blocks_multiply_vxx_0, 0), (filter_fir_filter_xxx_0_0, 0)) + tb.connect((blocks_multiply_vxx_0, 0), (filter_fir_filter_xxx_0_0_0, 0)) + tb.connect((filter_fir_filter_xxx_0_0, 0), (blocks_streams_to_stream_0, 0)) + tb.connect((filter_fir_filter_xxx_0_0_0, 0), (blocks_streams_to_stream_0, 1)) + tb.connect((blocks_streams_to_stream_0, 0), (gr_skiphead_0, 0)) tb.connect((gr_skiphead_0, 0), (viterbi, 0)) tb.connect((viterbi, 0), (gr_vector_sink_x_0, 0)) diff --git a/gr-trellis/src/examples/python/test_pccc_turbo1.py b/gr-trellis/examples/python/test_pccc_turbo1.py index bbcce106fb..121659ccf5 100755 --- a/gr-trellis/src/examples/python/test_pccc_turbo1.py +++ b/gr-trellis/examples/python/test_pccc_turbo1.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, blocks from gnuradio import eng_notation import math import sys @@ -28,12 +28,12 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, mod = digital.chunks_to_symbols_sf(constellation,dimensionality) # CHANNEL - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX metrics_in = trellis.metrics_f(fi.O()*fo.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO - scale = gr.multiply_const_ff(1.0/N0) + scale = blocks.multiply_const_ff(1.0/N0) dec = trellis.pccc_decoder_s(fo,0,-1,fi,0,-1,interleaver,K,IT,trellis.TRELLIS_MIN_SUM) fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts diff --git a/gr-trellis/src/examples/python/test_sccc_hard.py b/gr-trellis/examples/python/test_sccc_hard.py index b75a07b8b0..8676a6064d 100755 --- a/gr-trellis/src/examples/python/test_sccc_hard.py +++ b/gr-trellis/examples/python/test_sccc_hard.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, blocks from gnuradio import eng_notation import math import sys @@ -28,7 +28,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, mod = digital.chunks_to_symbols_sf(constellation,dimensionality) # CHANNEL - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX diff --git a/gr-trellis/src/examples/python/test_sccc_soft.py b/gr-trellis/examples/python/test_sccc_soft.py index 0b10c07bbc..1885934a46 100755 --- a/gr-trellis/src/examples/python/test_sccc_soft.py +++ b/gr-trellis/examples/python/test_sccc_soft.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, blocks from gnuradio import eng_notation import math import sys @@ -28,7 +28,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, mod = digital.chunks_to_symbols_sf(constellation,dimensionality) # CHANNEL - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX diff --git a/gr-trellis/src/examples/python/test_sccc_turbo.py b/gr-trellis/examples/python/test_sccc_turbo.py index 979dfeca59..677c07a05c 100755 --- a/gr-trellis/src/examples/python/test_sccc_turbo.py +++ b/gr-trellis/examples/python/test_sccc_turbo.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, blocks from gnuradio import eng_notation import math import sys @@ -16,7 +16,7 @@ except ImportError: def make_rx(tb,fo,fi,dimensionality,constellation,K,interleaver,IT,Es,N0,type): metrics_in = trellis.metrics_f(fi.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner Viterbi - scale = gr.multiply_const_ff(1.0/N0) + scale = blocks.multiply_const_ff(1.0/N0) gnd = gr.vector_source_f([0],True); inter=[] @@ -68,7 +68,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, mod = digital.chunks_to_symbols_sf(constellation,dimensionality) # CHANNEL - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX diff --git a/gr-trellis/src/examples/python/test_sccc_turbo1.py b/gr-trellis/examples/python/test_sccc_turbo1.py index 60188e4d3b..62a0b6e318 100755 --- a/gr-trellis/src/examples/python/test_sccc_turbo1.py +++ b/gr-trellis/examples/python/test_sccc_turbo1.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, blocks from gnuradio import eng_notation import math import sys @@ -25,7 +25,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, mod = digital.chunks_to_symbols_sf(constellation,dimensionality) # CHANNEL - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX diff --git a/gr-trellis/src/examples/python/test_sccc_turbo2.py b/gr-trellis/examples/python/test_sccc_turbo2.py index e9f4841e3e..510748a68a 100755 --- a/gr-trellis/src/examples/python/test_sccc_turbo2.py +++ b/gr-trellis/examples/python/test_sccc_turbo2.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, blocks from gnuradio import eng_notation import math import sys @@ -25,12 +25,12 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, mod = digital.chunks_to_symbols_sf(constellation,dimensionality) # CHANNEL - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX metrics_in = trellis.metrics_f(fi.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO - scale = gr.multiply_const_ff(1.0/N0) + scale = blocks.multiply_const_ff(1.0/N0) dec = trellis.sccc_decoder_s(fo,0,-1,fi,0,-1,interleaver,K,IT,trellis.TRELLIS_MIN_SUM) fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts dst = gr.check_lfsr_32k_s() diff --git a/gr-trellis/src/examples/python/test_tcm.py b/gr-trellis/examples/python/test_tcm.py index fced315260..aca06f783e 100755 --- a/gr-trellis/src/examples/python/test_tcm.py +++ b/gr-trellis/examples/python/test_tcm.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, blocks from gnuradio import eng_notation import math import sys @@ -33,7 +33,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): mod = digital.chunks_to_symbols_sf(constellation,dimensionality) # CHANNEL - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX diff --git a/gr-trellis/src/examples/python/test_tcm_bit.py b/gr-trellis/examples/python/test_tcm_bit.py index 873d58684b..4438db91ac 100755 --- a/gr-trellis/src/examples/python/test_tcm_bit.py +++ b/gr-trellis/examples/python/test_tcm_bit.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, blocks from gnuradio import eng_notation import math import sys @@ -34,7 +34,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): # CHANNEL - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) diff --git a/gr-trellis/src/examples/python/test_tcm_combined.py b/gr-trellis/examples/python/test_tcm_combined.py index 8bea1ac86a..a0cd58c6df 100755 --- a/gr-trellis/src/examples/python/test_tcm_combined.py +++ b/gr-trellis/examples/python/test_tcm_combined.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, blocks from gnuradio import eng_notation import math import sys @@ -27,7 +27,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): # CHANNEL - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) diff --git a/gr-trellis/src/examples/python/test_tcm_parallel.py b/gr-trellis/examples/python/test_tcm_parallel.py index 1767cc730f..0bd6f739c1 100755 --- a/gr-trellis/src/examples/python/test_tcm_parallel.py +++ b/gr-trellis/examples/python/test_tcm_parallel.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, blocks from gnuradio import eng_notation import math import sys @@ -22,7 +22,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed,P): src = gr.lfsr_32k_source_s() src_head = gr.head (gr.sizeof_short,Kb/16*P) # packet size in shorts s2fsmi=gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality - s2p = gr.stream_to_streams(gr.sizeof_short,P) # serial to parallel + s2p = blocks.stream_to_streams(gr.sizeof_short,P) # serial to parallel enc = trellis.encoder_ss(f,0) # initiali state = 0 mod = digital.chunks_to_symbols_sf(constellation,dimensionality) @@ -30,13 +30,13 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed,P): add=[] noise=[] for i in range(P): - add.append(gr.add_ff()) + add.append(blocks.add_ff()) noise.append(analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed)) # RX metrics = trellis.metrics_f(f.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. - p2s = gr.streams_to_stream(gr.sizeof_short,P) # parallel to serial + p2s = block.streams_to_stream(gr.sizeof_short,P) # parallel to serial fsmi2s=gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts dst = gr.check_lfsr_32k_s() diff --git a/gr-trellis/src/examples/python/test_turbo_equalization.py b/gr-trellis/examples/python/test_turbo_equalization.py index baddd7cb50..b0889bdcef 100755 --- a/gr-trellis/src/examples/python/test_turbo_equalization.py +++ b/gr-trellis/examples/python/test_turbo_equalization.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, blocks from gnuradio import eng_notation import math import sys @@ -15,7 +15,7 @@ except ImportError: def make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,type): metrics_in = trellis.metrics_f(fi.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO - scale = gr.multiply_const_ff(1.0/N0) + scale = blocks.multiply_const_ff(1.0/N0) gnd = gr.vector_source_f([0],True); inter=[] @@ -67,7 +67,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,tot_constellat mod = digital.chunks_to_symbols_sf(tot_constellation,dimensionality) # CHANNEL - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX diff --git a/gr-trellis/src/examples/python/test_turbo_equalization1.py b/gr-trellis/examples/python/test_turbo_equalization1.py index dfe1a2d82e..ae7e3e374b 100755 --- a/gr-trellis/src/examples/python/test_turbo_equalization1.py +++ b/gr-trellis/examples/python/test_turbo_equalization1.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital, filter +from gnuradio import trellis, digital, filter, blocks from gnuradio import eng_notation import math import sys @@ -16,7 +16,7 @@ except ImportError: def make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,type): metrics_in = trellis.metrics_f(fi.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO - scale = gr.multiply_const_ff(1.0/N0) + scale = blocks.multiply_const_ff(1.0/N0) gnd = gr.vector_source_f([0],True); inter=[] @@ -71,7 +71,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensiona # CHANNEL isi = filter.fir_filter_fff(1,channel) - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX diff --git a/gr-trellis/src/examples/python/test_turbo_equalization2.py b/gr-trellis/examples/python/test_turbo_equalization2.py index fb0a899eba..eed5675fe5 100755 --- a/gr-trellis/src/examples/python/test_turbo_equalization2.py +++ b/gr-trellis/examples/python/test_turbo_equalization2.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital, filter +from gnuradio import trellis, digital, filter, blocks from gnuradio import eng_notation import math import sys @@ -15,7 +15,7 @@ except ImportError: sys.exit(1) def make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,type): - scale = gr.multiply_const_ff(math.sqrt(1.0/N0)) + scale = blocks.multiply_const_ff(math.sqrt(1.0/N0)) gnd = gr.vector_source_f([0],True); inter=[] @@ -69,7 +69,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensiona # CHANNEL isi = filter.fir_filter_fff(1,channel) - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX diff --git a/gr-trellis/src/examples/python/test_viterbi_equalization.py b/gr-trellis/examples/python/test_viterbi_equalization.py index 91dc7e36da..21236d2870 100755 --- a/gr-trellis/src/examples/python/test_viterbi_equalization.py +++ b/gr-trellis/examples/python/test_viterbi_equalization.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, blocks from gnuradio import eng_notation import math import sys @@ -25,7 +25,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,tot_constellation,N0,seed): mod = digital.chunks_to_symbols_sf(tot_constellation,dimensionality) # CHANNEL - add = gr.add_ff() + add = blocks.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX diff --git a/gr-trellis/src/examples/python/test_viterbi_equalization1.py b/gr-trellis/examples/python/test_viterbi_equalization1.py index 4421e370a4..df46046ae3 100755 --- a/gr-trellis/src/examples/python/test_viterbi_equalization1.py +++ b/gr-trellis/examples/python/test_viterbi_equalization1.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital, filter +from gnuradio import trellis, digital, filter, blocks from gnuradio import eng_notation import math import sys @@ -32,7 +32,7 @@ def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constel # CHANNEL isi = filter.fir_filter_fff(1,channel) - add = gr.add_ff() + add = blockss.add_ff() noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX diff --git a/gr-trellis/include/trellis/CMakeLists.txt b/gr-trellis/include/trellis/CMakeLists.txt new file mode 100644 index 0000000000..294481368a --- /dev/null +++ b/gr-trellis/include/trellis/CMakeLists.txt @@ -0,0 +1,103 @@ +# Copyright 2012 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. + +######################################################################## +# generate helper scripts to expand templated files +######################################################################## +include(GrPython) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py " +#!${PYTHON_EXECUTABLE} + +import sys, os, re +sys.path.append('${GR_CORE_PYTHONPATH}') +os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' +os.chdir('${CMAKE_CURRENT_BINARY_DIR}') + +if __name__ == '__main__': + import build_utils + root, inp = sys.argv[1:3] + for sig in sys.argv[3:]: + name = re.sub ('X+', sig, root) + d = build_utils.standard_dict2(name, sig, 'trellis') + build_utils.expand_template(d, inp) + +") + +macro(expand_h root) + #make a list of all the generated files + unset(expanded_files_h) + foreach(sig ${ARGN}) + string(REGEX REPLACE "X+" ${sig} name ${root}) + list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/${name}.h) + endforeach(sig) + + #create a command to generate the files + add_custom_command( + OUTPUT ${expanded_files_h} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.h.t + COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py + ${root} ${root}.h.t ${ARGN} + ) + + #install rules for the generated h files + list(APPEND generated_includes ${expanded_files_h}) +endmacro(expand_h) + +######################################################################## +# Invoke macro to generate various sources +####################################################################### +expand_h(encoder_XX bb bs bi ss si ii) +expand_h(sccc_encoder_XX bb bs bi ss si ii) +expand_h(pccc_encoder_XX bb bs bi ss si ii) +expand_h(metrics_X s i f c) +expand_h(viterbi_X b s i) +expand_h(viterbi_combined_XX sb ss si ib is ii fb fs fi cb cs ci) +expand_h(sccc_decoder_X b s i) +expand_h(sccc_decoder_combined_XX fb fs fi cb cs ci) +expand_h(pccc_decoder_X b s i) +expand_h(pccc_decoder_combined_XX fb fs fi cb cs ci) + +add_custom_target(trellis_generated_includes DEPENDS + ${generated_includes} +) +MESSAGE(STATUS "GENERATED INCLUDES: ${trellis_generated_includes}") + +######################################################################## +# Install header files +######################################################################## +install(FILES + ${trellis_generated_includes} + api.h + base.h + calc_metric.h + constellation_metrics_cf.h + core_algorithms.h + fsm.h + interleaver.h + permutation.h + quicksort_index.h + siso_type.h + siso_combined_f.h + siso_f.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/trellis + COMPONENT "trellis_devel" +) + diff --git a/gr-trellis/src/lib/trellis_api.h b/gr-trellis/include/trellis/api.h index c09b340d6d..c09b340d6d 100644 --- a/gr-trellis/src/lib/trellis_api.h +++ b/gr-trellis/include/trellis/api.h diff --git a/gr-trellis/src/lib/base.h b/gr-trellis/include/trellis/base.h index aa407cbec1..c69500d0df 100644 --- a/gr-trellis/src/lib/base.h +++ b/gr-trellis/include/trellis/base.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,14 +25,19 @@ #include <vector> -/*! - * \brief change base - */ +namespace gr { + namespace trellis { + + /*! + * \brief change base + */ + bool dec2base(unsigned int num, int base, std::vector<int> &s); + bool dec2bases(unsigned int num, const std::vector<int> &bases, std::vector<int> &s); + unsigned int base2dec(const std::vector<int> &s, int base); + unsigned int bases2dec(const std::vector<int> &s, const std::vector<int> &bases); -bool dec2base(unsigned int num, int base, std::vector<int> &s); -bool dec2bases(unsigned int num, const std::vector<int> &bases, std::vector<int> &s); -unsigned int base2dec(const std::vector<int> &s, int base); -unsigned int bases2dec(const std::vector<int> &s, const std::vector<int> &bases); + } /* namespace trellis */ +} /* namespace gr */ -#endif +#endif /* INCLUDED_TRELLIS_BASE_H */ diff --git a/gr-trellis/include/trellis/calc_metric.h b/gr-trellis/include/trellis/calc_metric.h new file mode 100644 index 0000000000..b39267dc84 --- /dev/null +++ b/gr-trellis/include/trellis/calc_metric.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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_CALC_METRIC_H +#define INCLUDED_CALC_METRIC_H + +#include <vector> +#include <gr_complex.h> +#include <digital/metric_type.h> + +namespace gr { + namespace trellis { + + template <class T> + void calc_metric(int O, int D, const std::vector<T> &TABLE, const T *input, + float *metric, digital::trellis_metric_type_t type); + + /* + void calc_metric(int O, int D, const std::vector<short> &TABLE, const short *input, + float *metric, digital::trellis_metric_type_t type); + + void calc_metric(int O, int D, const std::vector<int> &TABLE, const int *input, + float *metric, digital::trellis_metric_type_t type); + + void calc_metric(int O, int D, const std::vector<float> &TABLE, const float *input, + float *metric, digital::trellis_metric_type_t type); + */ + + void calc_metric(int O, int D, const std::vector<gr_complex> &TABLE, const gr_complex *input, + float *metric, digital::trellis_metric_type_t type); + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* INCLUDED_CALC_METRIC_H */ diff --git a/gr-trellis/include/trellis/constellation_metrics_cf.h b/gr-trellis/include/trellis/constellation_metrics_cf.h new file mode 100644 index 0000000000..2dca6f7b5b --- /dev/null +++ b/gr-trellis/include/trellis/constellation_metrics_cf.h @@ -0,0 +1,51 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010-2012 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_TRELLIS_CONSTELLATION_METRICS_CF_H +#define INCLUDED_TRELLIS_CONSTELLATION_METRICS_CF_H + +#include <trellis/api.h> +#include <gr_block.h> +#include <digital/constellation.h> +#include <digital/metric_type.h> + +namespace gr { + namespace trellis { + + /*! + * \brief Evaluate metrics for use by the Viterbi algorithm. + * \ingroup coding_blk + */ + class TRELLIS_API constellation_metrics_cf : virtual public gr_block + { + public: + // gr::trellis::constellation_metrics_cf::sptr + typedef boost::shared_ptr<constellation_metrics_cf> sptr; + + static sptr make(digital::constellation_sptr constellation, + digital::trellis_metric_type_t TYPE); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* INCLUDED_TRELLIS_CONSTELLATION_METRICS_CF_H */ diff --git a/gr-trellis/include/trellis/core_algorithms.h b/gr-trellis/include/trellis/core_algorithms.h new file mode 100644 index 0000000000..2292845629 --- /dev/null +++ b/gr-trellis/include/trellis/core_algorithms.h @@ -0,0 +1,124 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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_CORE_ALGORITHMS_H +#define INCLUDED_CORE_ALGORITHMS_H + +#include <cmath> +#include <vector> +#include <digital/metric_type.h> +#include <trellis/fsm.h> +#include <trellis/interleaver.h> + +namespace gr { + namespace trellis { + + float min(float a, float b); + float min_star(float a, float b); + + template <class T> + void viterbi_algorithm(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + const float *in, T *out); + + template <class Ti, class To> + void viterbi_algorithm_combined(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<Ti> &TABLE, + digital::trellis_metric_type_t TYPE, + const Ti *in, To *out); + + void siso_algorithm(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + bool POSTI, bool POSTO, + float (*p2mymin)(float,float), + const float *priori, const float *prioro, float *post); + + template <class T> + void siso_algorithm_combined(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + bool POSTI, bool POSTO, + float (*p2mymin)(float,float), + int D, + const std::vector<T> &TABLE, + digital::trellis_metric_type_t TYPE, + const float *priori, const T *observations, float *post); + + template<class T> + void sccc_decoder(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, int iterations, + float (*p2mymin)(float,float), + const float *iprioro, T *data); + + template<class Ti, class To> + void sccc_decoder_combined(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<Ti> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const Ti *observations, To *data); + + template<class T> + void pccc_decoder(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, int blocklength, int iterations, + float (*p2mymin)(float,float), + const float *cprioro, T *data); + + template<class Ti, class To> + void pccc_decoder_combined(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, int blocklength, int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<Ti> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const Ti *observations, To *data); + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* INCLUDED_CORE_ALGORITHMS_H */ diff --git a/gnuradio-core/src/lib/gengen/gr_or_XX.h.t b/gr-trellis/include/trellis/encoder_XX.h.t index 8860eedd50..c10b283f87 100644 --- a/gnuradio-core/src/lib/gengen/gr_or_XX.h.t +++ b/gr-trellis/include/trellis/encoder_XX.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008 Free Software Foundation, Inc. + * Copyright 2004,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,31 +25,30 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ -#include <gr_core_api.h> +#include <trellis/api.h> +#include <trellis/fsm.h> #include <gr_sync_block.h> -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; +namespace gr { + namespace trellis { -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); + /*! + * \brief Convolutional encoder. + * \ingroup coding_blk + */ + class TRELLIS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::trellis::@BASE_NAME@::sptr + typedef boost::shared_ptr<@BASE_NAME@> sptr; -/*! - * \brief output = input_0 | input_1 | , ... | input_N) - * \ingroup math_blk - * - * bitwise boolean or across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - - @NAME@ (); + static sptr make(const fsm &FSM, int ST); - public: + virtual fsm FSM() const = 0; + virtual int ST() const = 0; + }; - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; + } /* namespace trellis */ +} /* namespace gr */ -#endif +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/include/trellis/fsm.h b/gr-trellis/include/trellis/fsm.h new file mode 100644 index 0000000000..a69925c1c7 --- /dev/null +++ b/gr-trellis/include/trellis/fsm.h @@ -0,0 +1,191 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2011-2012 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_TRELLIS_FSM_H +#define INCLUDED_TRELLIS_FSM_H + +#include <trellis/api.h> +#include <vector> +#include <iosfwd> + +namespace gr { + namespace trellis { + + /*! + * \brief Finite State Machine Specification class. + * + * An instance of this class represents a finite state machine + * specification (FSMS) rather than the FSM itself. It particular + * the state of the FSM is not stored within an instance of this + * class. + */ + class TRELLIS_API fsm + { + private: + // Input alphabet cardinality. + int d_I; + + // Number of states. + int d_S; + + // Output alphabet cardinality. + int d_O; + + // NS means Next State. + // next_state = d_NS[current_state * d_I + input_symbol] + std::vector<int> d_NS; + + // OS means Output Symbol. + // output_symbol = d_OS[current_state * d_I + input_symbol] + std::vector<int> d_OS; + + // PS means Previous State. + std::vector< std::vector<int> > d_PS; + + // PI means Previous Input Symbol. + // d_PS[current_state][k] and d_PI[current_state][k], is a pair of the form + // (previous_state, previous_input_symbol) that could have produced the + // current state. + std::vector< std::vector<int> > d_PI; + + // TM means Termination matrix. + // d_TMl[s*d_S+es] is the shortest number of steps to get from state s to + // state es. + std::vector<int> d_TMl; + + // d_TMi[s*d_S+es] is the input symbol required to set off on the shortest + // path from state s to es. + std::vector<int> d_TMi; + void generate_PS_PI (); + void generate_TM (); + bool find_es(int es); + + public: + /*! + * \brief Constructor to create an uninitialized FSMS. + */ + fsm(); + + /*! + * \brief Constructor to copy an FSMS. + */ + fsm(const fsm &FSM); + + /*! + * \brief Constructor to to create an FSMS. + * + * \param I The number of possible input symbols. + * \param S The number of possible FSM states. + * \param O The number of possible output symbols. + * \param NS A mapping from (current state, input symbol) to next state. + * next_state = NS[current_state * I + input_symbol] + * \param OS A mapping from (current state, input symbol) to output symbol. + * output_symbol = OS[current_state * I + input_symbol] + * + */ + fsm(int I, int S, int O, const std::vector<int> &NS, const std::vector<int> &OS); + + /*! + * \brief Constructor to create an FSMS from file contents. + * + * \param name filename + * + */ + fsm(const char *name); + + /*! + * \brief Creates an FSMS from the generator matrix of a (n, k) binary convolutional code. + * + * \param k ??? + * \param n ??? + * \param G ??? + * + */ + fsm(int k, int n, const std::vector<int> &G); + + /*! + * \brief Creates an FSMS describing ISI. + * + * \param mod_size modulation size + * \param ch_length channel length + * + */ + fsm(int mod_size, int ch_length); + + /*! + * \brief Creates an FSMS describing the trellis for a CPM. + * + * \param P ???? h=K/P (relatively prime) + * \param M alphabet size + * \param L pulse duration + * + * This FSM is based on the paper by B. Rimoldi + * "A decomposition approach to CPM", IEEE Trans. Info Theory, March 1988 + * See also my own notes at http://www.eecs.umich.edu/~anastas/docs/cpm.pdf + */ + fsm(int P, int M, int L); + + /*! + * \brief Creates an FSMS describing the joint trellis of two FSMs. + * + * \param FSM1 first FSMS + * \param FSM2 second FSMS + */ + fsm(const fsm &FSM1, const fsm &FSM2); + + /*! + * \brief Creates an FSMS representing n stages through the originial FSM (AKA radix-n FSM). + * + * \param FSM Original FSMs + * \param n Number of stages. + */ + fsm(const fsm &FSM, int n); + int I() const { return d_I; } + int S() const { return d_S; } + int O() const { return d_O; } + const std::vector<int> & NS() const { return d_NS; } + const std::vector<int> & OS() const { return d_OS; } + const std::vector< std::vector<int> > & PS() const { return d_PS; } + const std::vector< std::vector<int> > & PI() const { return d_PI; } + const std::vector<int> & TMi() const { return d_TMi; } + const std::vector<int> & TMl() const { return d_TMl; } + + /*! + * \brief Creates an svg image of the trellis representation. + * + * \param filename filename + * \param number_stages ???? + */ + void write_trellis_svg(std::string filename ,int number_stages); + + /*! + * \brief Write the FSMS to a file. + * + * \param filename filename + */ + void write_fsm_txt(std::string filename); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* INCLUDED_TRELLIS_FSM_H */ diff --git a/gr-trellis/src/lib/interleaver.h b/gr-trellis/include/trellis/interleaver.h index fbd378d621..7465f17986 100644 --- a/gr-trellis/src/lib/interleaver.h +++ b/gr-trellis/include/trellis/interleaver.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,27 +23,35 @@ #ifndef INCLUDED_TRELLIS_INTERLEAVER_H #define INCLUDED_TRELLIS_INTERLEAVER_H -#include <trellis_api.h> +#include <trellis/api.h> #include <vector> -/*! - * \brief INTERLEAVER class - */ -class TRELLIS_API interleaver { -private: - int d_K; - std::vector<int> d_INTER; - std::vector<int> d_DEINTER; -public: - interleaver(); - interleaver(const interleaver & INTERLEAVER); - interleaver(int K, const std::vector<int> & INTER); - interleaver(const char *name); - interleaver(int K, int seed); - int K () const { return d_K; } - const std::vector<int> & INTER () const { return d_INTER; } - const std::vector<int> & DEINTER () const { return d_DEINTER; } - void write_interleaver_txt(std::string filename); -}; +namespace gr { + namespace trellis { + + /*! + * \brief INTERLEAVER class + */ + class TRELLIS_API interleaver + { + private: + int d_K; + std::vector<int> d_INTER; + std::vector<int> d_DEINTER; + + public: + interleaver(); + interleaver(const interleaver & INTERLEAVER); + interleaver(int K, const std::vector<int> & INTER); + interleaver(const char *name); + interleaver(int K, int seed); + int K () const { return d_K; } + const std::vector<int> & INTER() const { return d_INTER; } + const std::vector<int> & DEINTER() const { return d_DEINTER; } + void write_interleaver_txt(std::string filename); + }; + + } /* namespace trellis */ +} /* namespace gr */ -#endif +#endif /* INCLUDED_TRELLIS_INTERLEAVER_H */ diff --git a/gr-trellis/include/trellis/metrics_X.h.t b/gr-trellis/include/trellis/metrics_X.h.t new file mode 100644 index 0000000000..5605130c24 --- /dev/null +++ b/gr-trellis/include/trellis/metrics_X.h.t @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/api.h> +#include <trellis/calc_metric.h> +#include <gr_block.h> + +namespace gr { + namespace trellis { + + /*! + * \brief Evaluate metrics for use by the Viterbi algorithm. + * \ingroup coding_blk + */ + class TRELLIS_API @NAME@ : virtual public gr_block + { + public: + // gr::trellis::@BASE_NAME@::sptr + typedef boost::shared_ptr<@BASE_NAME@> sptr; + + static sptr make(int O, int D, const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t TYPE); + + virtual int O() const = 0; + virtual int D() const = 0; + virtual digital::trellis_metric_type_t TYPE() const = 0; + virtual std::vector<@I_TYPE@> TABLE() const = 0; + virtual void set_TABLE(const std::vector<@I_TYPE@> &table) = 0; + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/include/trellis/pccc_decoder_X.h.t b/gr-trellis/include/trellis/pccc_decoder_X.h.t new file mode 100644 index 0000000000..4ab1c088a5 --- /dev/null +++ b/gr-trellis/include/trellis/pccc_decoder_X.h.t @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/api.h> +#include <trellis/fsm.h> +#include <trellis/interleaver.h> +#include <trellis/siso_type.h> +#include <gr_block.h> +#include <vector> + +namespace gr { + namespace trellis { + + /*! + * \ingroup coding_blk + */ + class TRELLIS_API @NAME@ : virtual public gr_block + { + public: + // gr::trellis::@BASE_NAME@::sptr + typedef boost::shared_ptr<@BASE_NAME@> sptr; + + static sptr make(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE); + + virtual fsm FSM1() const = 0; + virtual fsm FSM2() const = 0; + virtual int ST10() const = 0; + virtual int ST1K() const = 0; + virtual int ST20() const = 0; + virtual int ST2K() const = 0; + virtual interleaver INTERLEAVER() const = 0; + virtual int blocklength() const = 0; + virtual int repetitions() const = 0; + virtual siso_type_t SISO_TYPE() const = 0; + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/include/trellis/pccc_decoder_combined_XX.h.t b/gr-trellis/include/trellis/pccc_decoder_combined_XX.h.t new file mode 100644 index 0000000000..1ea53329c4 --- /dev/null +++ b/gr-trellis/include/trellis/pccc_decoder_combined_XX.h.t @@ -0,0 +1,79 @@ +/* -*- 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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <trellis/api.h> +#include <trellis/fsm.h> +#include <trellis/interleaver.h> +#include <trellis/calc_metric.h> +#include <trellis/siso_type.h> +#include <gr_block.h> +#include <vector> + +namespace gr { + namespace trellis { + + /*! + * \ingroup coding_blk + */ + class TRELLIS_API @NAME@ : virtual public gr_block + { + public: + // gr::trellis::@BASE_NAME@::sptr + typedef boost::shared_ptr<@BASE_NAME@> sptr; + + static sptr make(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE, + int D, + const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling); + + virtual fsm FSM1() const = 0; + virtual fsm FSM2() const = 0; + virtual int ST10() const = 0; + virtual int ST1K() const = 0; + virtual int ST20() const = 0; + virtual int ST2K() const = 0; + virtual interleaver INTERLEAVER() const = 0; + virtual int blocklength() const = 0; + virtual int repetitions() const = 0; + virtual int D() const = 0; + virtual std::vector<@I_TYPE@> TABLE() const = 0; + virtual digital::trellis_metric_type_t METRIC_TYPE() const = 0; + virtual siso_type_t SISO_TYPE() const = 0; + virtual float scaling() const = 0; + virtual void set_scaling(float scaling) = 0; + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/include/trellis/pccc_encoder_XX.h.t b/gr-trellis/include/trellis/pccc_encoder_XX.h.t new file mode 100644 index 0000000000..103301eecd --- /dev/null +++ b/gr-trellis/include/trellis/pccc_encoder_XX.h.t @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/api.h> +#include <trellis/fsm.h> +#include <trellis/interleaver.h> +#include <gr_sync_block.h> +#include <vector> + +namespace gr { + namespace trellis { + + /*! + * \brief SCCC encoder. + * \ingroup coding_blk + */ + class TRELLIS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::trellis::@BASE_NAME@::sptr + typedef boost::shared_ptr<@BASE_NAME@> sptr; + + static sptr make(const fsm &FSM1, int ST1, + const fsm &FSM2, int ST2, + const interleaver &INTERLEAVER, + int blocklength); + + virtual fsm FSM1 () const = 0; + virtual int ST1 () const = 0; + virtual fsm FSM2 () const = 0; + virtual int ST2 () const = 0; + virtual interleaver INTERLEAVER () const = 0; + virtual int blocklength () const = 0; + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.i b/gr-trellis/include/trellis/permutation.h index ea59a388e2..adfe44a576 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_short.i +++ b/gr-trellis/include/trellis/permutation.h @@ -20,14 +20,36 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,float_to_short) +#ifndef INCLUDED_TRELLIS_PERMUTATION_H +#define INCLUDED_TRELLIS_PERMUTATION_H -gr_float_to_short_sptr -gr_make_float_to_short (size_t vlen=1, float scale=1); +#include <trellis/api.h> +#include <vector> +#include <gr_sync_block.h> -class gr_float_to_short : public gr_sync_block -{ -public: - float scale() const; - void set_scale(float scale); -}; +namespace gr { + namespace trellis { + + /*! + * \brief Permutation. + * \ingroup coding_blk + */ + class TRELLIS_API permutation : virtual public gr_sync_block + { + public: + // gr::trellis::permutation::sptr + typedef boost::shared_ptr<permutation> sptr; + + static sptr make(int K, const std::vector<int> &TABLE, + int SYMS_PER_BLOCK, size_t NBYTES); + + virtual int K() const = 0; + virtual const std::vector<int> & TABLE() const = 0; + virtual int SYMS_PER_BLOCK() const = 0; + virtual size_t BYTES_PER_SYMBOL() const = 0; + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* INCLUDED_TRELLIS_PERMUTATION_H */ diff --git a/gr-trellis/src/lib/quicksort_index.h b/gr-trellis/include/trellis/quicksort_index.h index 9583955db9..402962172a 100644 --- a/gr-trellis/src/lib/quicksort_index.h +++ b/gr-trellis/include/trellis/quicksort_index.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2007 Free Software Foundation, Inc. + * Copyright 2004,2007,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,10 +25,17 @@ #include <vector> -template <class T> -void SWAP (T & a, T & b); +namespace gr { + namespace trellis { -template <class T> -void quicksort_index (std::vector<T> & p, std::vector<int> & index, int left, int right); + template <class T> + void SWAP(T &a, T &b); -#endif + template <class T> + void quicksort_index(std::vector<T> &p, std::vector<int> &index, + int left, int right); + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* INCLUDED_QUICKSORT_INDEX_H */ diff --git a/gr-trellis/include/trellis/sccc_decoder_X.h.t b/gr-trellis/include/trellis/sccc_decoder_X.h.t new file mode 100644 index 0000000000..f2faa97e26 --- /dev/null +++ b/gr-trellis/include/trellis/sccc_decoder_X.h.t @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/api.h> +#include <trellis/fsm.h> +#include <trellis/interleaver.h> +#include <trellis/siso_type.h> +#include <gr_block.h> +#include <vector> + +namespace gr { + namespace trellis { + + /*! + * \ingroup coding_blk + */ + class TRELLIS_API @NAME@ : virtual public gr_block + { + public: + // gr::trellis::@BASE_NAME@::sptr + typedef boost::shared_ptr<@BASE_NAME@> sptr; + + static sptr make(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE); + + virtual fsm FSMo() const = 0; + virtual fsm FSMi() const = 0; + virtual int STo0() const = 0; + virtual int SToK() const = 0; + virtual int STi0() const = 0; + virtual int STiK() const = 0; + virtual interleaver INTERLEAVER() const = 0; + virtual int blocklength() const = 0; + virtual int repetitions() const = 0; + virtual siso_type_t SISO_TYPE() const = 0; + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/include/trellis/sccc_decoder_combined_XX.h.t b/gr-trellis/include/trellis/sccc_decoder_combined_XX.h.t new file mode 100644 index 0000000000..fbc3d8d668 --- /dev/null +++ b/gr-trellis/include/trellis/sccc_decoder_combined_XX.h.t @@ -0,0 +1,79 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/api.h> +#include <trellis/fsm.h> +#include <trellis/interleaver.h> +#include <trellis/calc_metric.h> +#include <trellis/siso_type.h> +#include <gr_block.h> +#include <vector> + +namespace gr { + namespace trellis { + + /*! + * \ingroup coding_blk + */ + class TRELLIS_API @NAME@ : virtual public gr_block + { + public: + // gr::trellis::@BASE_NAME@::sptr + typedef boost::shared_ptr<@BASE_NAME@> sptr; + + static sptr make(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE, + int D, + const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling); + + virtual fsm FSMo() const = 0; + virtual fsm FSMi() const = 0; + virtual int STo0() const = 0; + virtual int SToK() const = 0; + virtual int STi0() const = 0; + virtual int STiK() const = 0; + virtual interleaver INTERLEAVER() const = 0; + virtual int blocklength() const = 0; + virtual int repetitions() const = 0; + virtual int D() const = 0; + virtual std::vector<@I_TYPE@> TABLE() const = 0; + virtual digital::trellis_metric_type_t METRIC_TYPE() const = 0; + virtual siso_type_t SISO_TYPE() const = 0; + virtual float scaling() const = 0; + virtual void set_scaling(float scaling) = 0; + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/include/trellis/sccc_encoder_XX.h.t b/gr-trellis/include/trellis/sccc_encoder_XX.h.t new file mode 100644 index 0000000000..7702d06faf --- /dev/null +++ b/gr-trellis/include/trellis/sccc_encoder_XX.h.t @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/api.h> +#include <trellis/fsm.h> +#include <trellis/interleaver.h> +#include <gr_sync_block.h> +#include <vector> + +namespace gr { + namespace trellis { + + /*! + * \brief SCCC encoder. + * \ingroup coding_blk + */ + class TRELLIS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::trellis::@BASE_NAME@::sptr + typedef boost::shared_ptr<@BASE_NAME@> sptr; + + static sptr make(const fsm &FSMo, int STo, + const fsm &FSMi, int STi, + const interleaver &INTERLEAVER, + int blocklength); + + virtual fsm FSMo() const = 0; + virtual int STo() const = 0; + virtual fsm FSMi() const = 0; + virtual int STi() const = 0; + virtual interleaver INTERLEAVER() const = 0; + virtual int blocklength() const = 0; + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/include/trellis/siso_combined_f.h b/gr-trellis/include/trellis/siso_combined_f.h new file mode 100644 index 0000000000..c67a296885 --- /dev/null +++ b/gr-trellis/include/trellis/siso_combined_f.h @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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_TRELLIS_SISO_COMBINED_F_H +#define INCLUDED_TRELLIS_SISO_COMBINED_F_H + +#include <trellis/api.h> +#include <trellis/fsm.h> +#include <trellis/siso_type.h> +#include <trellis/calc_metric.h> +#include <trellis/core_algorithms.h> +#include <gr_block.h> + +namespace gr { + namespace trellis { + + /*! + * \ingroup coding_blk + */ + class TRELLIS_API siso_combined_f : virtual public gr_block + { + public: + // gr::trellis::siso_combined_f::sptr + typedef boost::shared_ptr<siso_combined_f> sptr; + + static sptr make(const fsm &FSM, int K, + int S0, int SK, + bool POSTI, bool POSTO, + siso_type_t d_SISO_TYPE, + int D, + const std::vector<float> &TABLE, + digital::trellis_metric_type_t TYPE); + + virtual fsm FSM() const = 0; + virtual int K() const = 0; + virtual int S0() const = 0; + virtual int SK() const = 0; + virtual bool POSTI() const = 0; + virtual bool POSTO() const = 0; + virtual siso_type_t SISO_TYPE() const = 0; + virtual int D() const = 0; + virtual std::vector<float> TABLE() const = 0; + virtual digital::trellis_metric_type_t TYPE() const = 0; + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* INCLUDED_TRELLIS_SISO_COMBINED_F_H */ diff --git a/gr-trellis/include/trellis/siso_f.h b/gr-trellis/include/trellis/siso_f.h new file mode 100644 index 0000000000..da35e14a0b --- /dev/null +++ b/gr-trellis/include/trellis/siso_f.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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_TRELLIS_SISO_F_H +#define INCLUDED_TRELLIS_SISO_F_H + +#include <trellis/api.h> +#include <trellis/fsm.h> +#include <trellis/siso_type.h> +#include <trellis/core_algorithms.h> +#include <gr_block.h> + +namespace gr { + namespace trellis { + + /*! + * \ingroup coding_blk + */ + class TRELLIS_API siso_f : virtual public gr_block + { + public: + // gr::trellis::siso_f::sptr + typedef boost::shared_ptr<siso_f> sptr; + + static sptr make(const fsm &FSM, int K, + int S0, int SK, + bool POSTI, bool POSTO, + siso_type_t d_SISO_TYPE); + + virtual fsm FSM() const = 0; + virtual int K() const = 0; + virtual int S0() const = 0; + virtual int SK() const = 0; + virtual bool POSTI() const = 0; + virtual bool POSTO() const = 0; + virtual siso_type_t SISO_TYPE() const = 0; + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* INCLUDED_TRELLIS_SISO_F_H */ diff --git a/gr-trellis/src/lib/siso_type.h b/gr-trellis/include/trellis/siso_type.h index 3a7163d02a..9167381164 100644 --- a/gr-trellis/src/lib/siso_type.h +++ b/gr-trellis/include/trellis/siso_type.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,9 +23,15 @@ #ifndef INCLUDED_TRELLIS_SISO_TYPE_H #define INCLUDED_TRELLIS_SISO_TYPE_H -typedef enum { - TRELLIS_MIN_SUM = 200, TRELLIS_SUM_PRODUCT -} trellis_siso_type_t; +namespace gr { + namespace trellis { -#endif + typedef enum { + TRELLIS_MIN_SUM = 200, + TRELLIS_SUM_PRODUCT + } siso_type_t; + + } /* namespace trellis */ +} /* namespace gr */ +#endif /* INCLUDED_TRELLIS_SISO_TYPE_H */ diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t b/gr-trellis/include/trellis/viterbi_X.h.t index abb13ea904..6931eb37e5 100644 --- a/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t +++ b/gr-trellis/include/trellis/viterbi_X.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2004,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,37 +25,33 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class @NAME@; - -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int decim); - -/*! - * \brief output = sum(input[0]...input[n]) - * \ingroup math_blk - * - * Integrate successive samples in input stream and decimate - */ -class GR_CORE_API @NAME@ : public gr_sync_decimator -{ -private: - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@(int decim); - - @NAME@ (int decim); - - int d_decim; - int d_count; - -public: - ~@NAME@ (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; +#include <trellis/api.h> +#include <trellis/fsm.h> +#include <trellis/core_algorithms.h> +#include <gr_block.h> + +namespace gr { + namespace trellis { + + /*! + * \ingroup coding_blk + */ + class TRELLIS_API @NAME@ : virtual public gr_block + { + public: + // gr::trellis::@BASE_NAME@::sptr + typedef boost::shared_ptr<@BASE_NAME@> sptr; + + static sptr make(const fsm &FSM, int K, + int S0, int SK); + + virtual fsm FSM() const = 0; + virtual int K() const = 0; + virtual int S0() const = 0; + virtual int SK() const = 0; + }; + + } /* namespace trellis */ +} /* namespace gr */ #endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/include/trellis/viterbi_combined_XX.h.t b/gr-trellis/include/trellis/viterbi_combined_XX.h.t new file mode 100644 index 0000000000..77fc5a5a60 --- /dev/null +++ b/gr-trellis/include/trellis/viterbi_combined_XX.h.t @@ -0,0 +1,64 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/api.h> +#include <trellis/fsm.h> +#include <trellis/calc_metric.h> +#include <trellis/core_algorithms.h> +#include <gr_block.h> + +namespace gr { + namespace trellis { + + /*! + * \ingroup coding_blk + */ + class TRELLIS_API @NAME@ : virtual public gr_block + { + public: + // gr::trellis::@BASE_NAME@::sptr + typedef boost::shared_ptr<@BASE_NAME@> sptr; + + static sptr make(const fsm &FSM, int K, + int S0, int SK, int D, + const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t TYPE); + + virtual fsm FSM() const = 0; + virtual int K() const = 0; + virtual int S0() const = 0; + virtual int SK() const = 0; + virtual int D() const = 0; + virtual std::vector<@I_TYPE@> TABLE() const = 0; + virtual digital::trellis_metric_type_t TYPE() const = 0; + virtual void set_TABLE (const std::vector<@I_TYPE@> &table) = 0; + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/lib/CMakeLists.txt b/gr-trellis/lib/CMakeLists.txt new file mode 100644 index 0000000000..5bd0227de6 --- /dev/null +++ b/gr-trellis/lib/CMakeLists.txt @@ -0,0 +1,139 @@ +# Copyright 2012 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. + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories( + ${GNURADIO_CORE_INCLUDE_DIRS} + ${GR_TRELLIS_INCLUDE_DIRS} + ${GR_DIGITAL_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR}/../include +) + +include_directories(${Boost_INCLUDE_DIRS}) +link_directories(${Boost_LIBRARY_DIRS}) + +if(ENABLE_GR_CTRLPORT) + ADD_DEFINITIONS(-DGR_CTRLPORT) +endif(ENABLE_GR_CTRLPORT) + +####################################################################### +# generate the python helper script which calls into the build utils +######################################################################## +include(GrPython) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py " +#!${PYTHON_EXECUTABLE} + +import sys, os, re +sys.path.append('${GR_CORE_PYTHONPATH}') +os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' +os.chdir('${CMAKE_CURRENT_BINARY_DIR}') + +if __name__ == '__main__': + import build_utils + root, inp = sys.argv[1:3] + for sig in sys.argv[3:]: + name = re.sub ('X+', sig, root) + d = build_utils.standard_impl_dict2(name, sig, 'trellis') + build_utils.expand_template(d, inp) +") + +macro(expand_cc root) + #make a list of all the generated files + unset(expanded_files_cc) + unset(expanded_files_h) + foreach(sig ${ARGN}) + string(REGEX REPLACE "X+" ${sig} name ${root}) + list(APPEND expanded_files_cc ${CMAKE_CURRENT_BINARY_DIR}/${name}.cc) + list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/${name}.h) + endforeach(sig) + + #create a command to generate the source files + add_custom_command( + OUTPUT ${expanded_files_cc} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.cc.t + COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py + ${root} ${root}.cc.t ${ARGN} + ) + + #create a command to generate the header file + add_custom_command( + OUTPUT ${expanded_files_h} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.h.t + COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py + ${root} ${root}.h.t ${ARGN} + ) + + #make source files depends on headers to force generation + set_source_files_properties(${expanded_files_cc} + PROPERTIES OBJECT_DEPENDS "${expanded_files_h}" + ) + + #install rules for the generated cc files + list(APPEND generated_sources ${expanded_files_cc}) + list(APPEND generated_headers ${expanded_files_h}) +endmacro(expand_cc) + +######################################################################## +# Invoke macro to generate various sources +######################################################################## +expand_cc(encoder_XX_impl bb bs bi ss si ii) +expand_cc(sccc_encoder_XX_impl bb bs bi ss si ii) +expand_cc(pccc_encoder_XX_impl bb bs bi ss si ii) +expand_cc(metrics_X_impl s i f c) +expand_cc(viterbi_X_impl b s i) +expand_cc(viterbi_combined_XX_impl sb ss si ib is ii fb fs fi cb cs ci) +expand_cc(sccc_decoder_X_impl b s i) +expand_cc(sccc_decoder_combined_XX_impl fb fs fi cb cs ci) +expand_cc(pccc_decoder_X_impl b s i) +expand_cc(pccc_decoder_combined_XX_impl fb fs fi cb cs ci) + +######################################################################## +# Setup library +######################################################################## +list(APPEND trellis_sources + ${generated_sources} + base.cc + calc_metric.cc + core_algorithms.cc + fsm.cc + interleaver.cc + quicksort_index.cc + constellation_metrics_cf_impl.cc + permutation_impl.cc + siso_f_impl.cc + siso_combined_f_impl.cc +) + +list(APPEND trellis_libs + gnuradio-core + gnuradio-digital + ${Boost_LIBRARIES} +) + +add_library(gnuradio-trellis SHARED ${trellis_sources}) +target_link_libraries(gnuradio-trellis ${trellis_libs}) +GR_LIBRARY_FOO(gnuradio-trellis RUNTIME_COMPONENT "trellis_runtime" DEVEL_COMPONENT "trellis_devel") +add_dependencies(gnuradio-trellis + trellis_generated_includes trellis_generated_swigs + gnuradio-core gnuradio-digital) diff --git a/gr-trellis/lib/base.cc b/gr-trellis/lib/base.cc new file mode 100644 index 0000000000..e9d0141e70 --- /dev/null +++ b/gr-trellis/lib/base.cc @@ -0,0 +1,86 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2012 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. + */ + +#include <cstdio> +#include <stdexcept> +#include <cmath> +#include <trellis/base.h> + +namespace gr { + namespace trellis { + + bool + dec2base(unsigned int num, int base, std::vector<int> &s) + { + int l = s.size(); + unsigned int n=num; + for(int i=0;i<l;i++) { + s[l-i-1] = n % base; //MSB first + n /= base; + } + if(n!=0) { + printf("Number %d requires more than %d digits.",num,l); + return false; + } + else + return true; + } + + unsigned int + base2dec(const std::vector<int> &s, int base) + { + int l = s.size(); + unsigned int num=0; + for(int i=0;i<l;i++) + num=num*base+s[i]; + return num; + } + + bool + dec2bases(unsigned int num, const std::vector<int> &bases, std::vector<int> &s) + { + int l = s.size(); + unsigned int n=num; + for(int i=0;i<l;i++) { + s[l-i-1] = n % bases[l-i-1]; + n /= bases[l-i-1]; + } + if(n!=0) { + printf("Number %d requires more than %d digits.",num,l); + return false; + } + else + return true; + } + + unsigned int + bases2dec(const std::vector<int> &s, const std::vector<int> &bases) + { + int l = s.size(); + unsigned int num=0; + for(int i=0;i<l;i++) + num = num * bases[i] + s[i]; + return num; + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/calc_metric.cc b/gr-trellis/lib/calc_metric.cc new file mode 100644 index 0000000000..3c474e30fe --- /dev/null +++ b/gr-trellis/lib/calc_metric.cc @@ -0,0 +1,251 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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. + */ + +#include <float.h> +#include <stdexcept> +#include <trellis/calc_metric.h> + +namespace gr { + namespace trellis { + + template <class T> + void calc_metric(int O, int D, const std::vector<T> &TABLE, const T *input, + float *metric, digital::trellis_metric_type_t type) + { + float minm = FLT_MAX; + int minmi = 0; + + switch(type) { + case digital::TRELLIS_EUCLIDEAN: + for(int o = 0; o < O; o++) { + metric[o] = 0.0; + for(int m = 0; m < D; m++) { + T s = input[m]-TABLE[o*D+m]; + //gr_complex sc(1.0*s,0); + //metric[o] += (sc*conj(sc)).real(); + metric[o] += s * s; + } + } + break; + case digital::TRELLIS_HARD_SYMBOL: + for(int o = 0; o < O; o++) { + metric[o] = 0.0; + for(int m = 0; m < D; m++) { + T s = input[m]-TABLE[o*D+m]; + //gr_complex sc(1.0*s,0); + //metric[o] + =(sc*conj(sc)).real(); + metric[o] += s * s; + } + if(metric[o] < minm) { + minm = metric[o]; + minmi = o; + } + } + for(int o = 0; o < O; o++) { + metric[o] = (o == minmi ? 0.0 : 1.0); + } + break; + case digital::TRELLIS_HARD_BIT: + throw std::runtime_error("calc_metric: Invalid metric type (not yet implemented)."); + break; + default: + throw std::runtime_error("calc_metric: Invalid metric type."); + } + } + + template + void calc_metric<short>(int O, int D, const std::vector<short> &TABLE, const short *input, + float *metric, digital::trellis_metric_type_t type); + + template + void calc_metric<int>(int O, int D, const std::vector<int> &TABLE, const int *input, + float *metric, digital::trellis_metric_type_t type); + + template + void calc_metric<float>(int O, int D, const std::vector<float> &TABLE, const float *input, + float *metric, digital::trellis_metric_type_t type); + + void calc_metric(int O, int D, const std::vector<short> &TABLE, const short *input, + float *metric, digital::trellis_metric_type_t type) + { + float minm = FLT_MAX; + int minmi = 0; + + switch(type) { + case digital::TRELLIS_EUCLIDEAN: + for(int o = 0; o < O; o++) { + metric[o] = 0.0; + for(int m = 0; m < D; m++) { + float s = input[m]-TABLE[o*D+m]; + metric[o] += s*s; + } + } + break; + case digital::TRELLIS_HARD_SYMBOL: + for(int o = 0; o < O; o++) { + metric[o] = 0.0; + for(int m = 0; m < D; m++) { + float s = input[m]-TABLE[o*D+m]; + metric[o] += s*s; + } + if(metric[o] < minm) { + minm = metric[o]; + minmi = o; + } + } + for(int o = 0; o < O; o++) { + metric[o] = (o == minmi ? 0.0 : 1.0); + } + break; + case digital::TRELLIS_HARD_BIT: + throw std::runtime_error("calc_metric: Invalid metric type (not yet implemented)."); + break; + default: + throw std::runtime_error("calc_metric: Invalid metric type."); + } + } + + /* + void calc_metric(int O, int D, const std::vector<int> &TABLE, const int *input, + float *metric, digital::trellis_metric_type_t type) + { + float minm = FLT_MAX; + int minmi = 0; + + switch(type){ + case digital::TRELLIS_EUCLIDEAN: + for(int o=0;o<O;o++) { + metric[o]=0.0; + for(int m=0;m<D;m++) { + float s=input[m]-TABLE[o*D+m]; + metric[o]+=s*s; + } + } + break; + case digital::TRELLIS_HARD_SYMBOL: + for(int o=0;o<O;o++) { + metric[o]=0.0; + for(int m=0;m<D;m++) { + float s=input[m]-TABLE[o*D+m]; + metric[o]+=s*s; + } + if(metric[o]<minm) { + minm=metric[o]; + minmi=o; + } + } + for(int o=0;o<O;o++) { + metric[o] = (o==minmi?0.0:1.0); + } + break; + case digital::TRELLIS_HARD_BIT: + throw std::runtime_error("calc_metric: Invalid metric type (not yet implemented)."); + break; + default: + throw std::runtime_error("calc_metric: Invalid metric type."); + } + } + + void calc_metric(int O, int D, const std::vector<float> &TABLE, const float *input, + float *metric, digital::trellis_metric_type_t type) + { + float minm = FLT_MAX; + int minmi = 0; + + switch(type) { + case digital::TRELLIS_EUCLIDEAN: + for(int o=0;o<O;o++) { + metric[o]=0.0; + for(int m=0;m<D;m++) { + float s=input[m]-TABLE[o*D+m]; + metric[o]+=s*s; + } + } + break; + case digital::TRELLIS_HARD_SYMBOL: + for(int o=0;o<O;o++) { + metric[o]=0.0; + for(int m=0;m<D;m++) { + float s=input[m]-TABLE[o*D+m]; + metric[o]+=s*s; + } + if(metric[o]<minm) { + minm=metric[o]; + minmi=o; + } + } + for(int o=0;o<O;o++) { + metric[o] = (o==minmi?0.0:1.0); + } + break; + case digital::TRELLIS_HARD_BIT: + throw std::runtime_error("calc_metric: Invalid metric type (not yet implemented)."); + break; + default: + throw std::runtime_error("calc_metric: Invalid metric type."); + } + } +*/ + + void calc_metric(int O, int D, const std::vector<gr_complex> &TABLE, const gr_complex *input, + float *metric, digital::trellis_metric_type_t type) + { + float minm = FLT_MAX; + int minmi = 0; + + switch(type) { + case digital::TRELLIS_EUCLIDEAN: + for(int o = 0; o < O; o++) { + metric[o] = 0.0; + for(int m = 0; m < D; m++) { + gr_complex s = input[m]-TABLE[o*D+m]; + metric[o] += s.real()*s.real()+s.imag()*s.imag(); + } + } + break; + case digital::TRELLIS_HARD_SYMBOL: + for(int o = 0; o < O; o++) { + metric[o] = 0.0; + for(int m = 0; m < D; m++) { + gr_complex s = input[m]-TABLE[o*D+m]; + metric[o] += s.real()*s.real()+s.imag()*s.imag(); + } + if(metric[o] < minm) { + minm = metric[o]; + minmi = o; + } + } + for(int o = 0; o < O; o++) { + metric[o] = (o == minmi ? 0.0 : 1.0); + } + break; + case digital::TRELLIS_HARD_BIT: + throw std::runtime_error("calc_metric: Invalid metric type (not yet implemented)."); + break; + default: + throw std::runtime_error("calc_metric: Invalid metric type."); + } + } + + } /* namespace trellis */ +} /* namespace gr */ + diff --git a/gr-trellis/lib/constellation_metrics_cf_impl.cc b/gr-trellis/lib/constellation_metrics_cf_impl.cc new file mode 100644 index 0000000000..18d3095802 --- /dev/null +++ b/gr-trellis/lib/constellation_metrics_cf_impl.cc @@ -0,0 +1,96 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010-2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "constellation_metrics_cf_impl.h" +#include <gr_io_signature.h> +#include <assert.h> +#include <stdexcept> +#include <iostream> + +namespace gr { + namespace trellis { + + constellation_metrics_cf::sptr + constellation_metrics_cf::make(digital::constellation_sptr constellation, + digital::trellis_metric_type_t TYPE) + { + return gnuradio::get_initial_sptr + (new constellation_metrics_cf_impl(constellation, TYPE)); + } + + constellation_metrics_cf_impl::constellation_metrics_cf_impl(digital::constellation_sptr constellation, + digital::trellis_metric_type_t TYPE) + : gr_block("constellation_metrics_cf", + gr_make_io_signature(1, -1, sizeof(gr_complex)), + gr_make_io_signature(1, -1, sizeof(float))), + d_constellation(constellation), + d_TYPE(TYPE), + d_O(constellation->arity()), + d_D(constellation->dimensionality()) + { + set_relative_rate(1.0 * d_O / ((double) d_D)); + set_output_multiple((int)d_O); + } + + constellation_metrics_cf_impl::~constellation_metrics_cf_impl() + { + } + + void + constellation_metrics_cf_impl::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + assert(noutput_items % d_O == 0); + + unsigned int input_required = d_D * noutput_items / d_O; + unsigned int ninputs = ninput_items_required.size(); + for(unsigned int i = 0; i < ninputs; i++) + ninput_items_required[i] = input_required; + } + + int + constellation_metrics_cf_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + unsigned int nstreams = input_items.size(); + + for(unsigned int m=0;m<nstreams;m++) { + const gr_complex *in = (gr_complex*)input_items[m]; + float *out = (float*)output_items[m]; + + for(unsigned int i = 0; i < noutput_items / d_O ; i++) { + d_constellation->calc_metric(&(in[i*d_D]), &(out[i*d_O]), d_TYPE); + } + } + + consume_each(d_D * noutput_items / d_O); + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/constellation_metrics_cf_impl.h b/gr-trellis/lib/constellation_metrics_cf_impl.h new file mode 100644 index 0000000000..52018c4baa --- /dev/null +++ b/gr-trellis/lib/constellation_metrics_cf_impl.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010-2012 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_TRELLIS_CONSTELLATION_METRICS_CF_IMPL_H +#define INCLUDED_TRELLIS_CONSTELLATION_METRICS_CF_IMPL_H + +#include <trellis/api.h> +#include <trellis/constellation_metrics_cf.h> + +namespace gr { + namespace trellis { + + class constellation_metrics_cf_impl : public constellation_metrics_cf + { + private: + digital::constellation_sptr d_constellation; + digital::trellis_metric_type_t d_TYPE; + unsigned int d_O; + unsigned int d_D; + + public: + constellation_metrics_cf_impl(digital::constellation_sptr constellation, + digital::trellis_metric_type_t TYPE); + ~constellation_metrics_cf_impl(); + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* INCLUDED_TRELLIS_CONSTELLATION_METRICS_CF_IMPL_H */ diff --git a/gr-trellis/lib/core_algorithms.cc b/gr-trellis/lib/core_algorithms.cc new file mode 100644 index 0000000000..a704e5f9a6 --- /dev/null +++ b/gr-trellis/lib/core_algorithms.cc @@ -0,0 +1,1324 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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. + */ + +#include <cstring> +#include <stdexcept> +#include <iostream> +#include <trellis/core_algorithms.h> +#include <trellis/calc_metric.h> + +namespace gr { + namespace trellis { + + static const float INF = 1.0e9; + + float + min(float a, float b) + { + return a <= b ? a : b; + } + + float + min_star(float a, float b) + { + return (a <= b ? a : b)-log(1+exp(a <= b ? a-b : b-a)); + } + + template <class T> void + viterbi_algorithm(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + const float *in, T *out)//, + //std::vector<int> &trace) + { + std::vector<int> trace(S*K); + std::vector<float> alpha(S*2); + int alphai; + float norm,mm,minm; + int minmi; + int st; + + if(S0<0) { // initial state not specified + for(int i=0;i<S;i++) alpha[0*S+i]=0; + } + else { + for(int i=0;i<S;i++) alpha[0*S+i]=INF; + alpha[0*S+S0]=0.0; + } + + alphai=0; + for(int k=0;k<K;k++) { + norm=INF; + for(int j=0;j<S;j++) { // for each next state do ACS + minm=INF; + minmi=0; + for(unsigned int i=0;i<PS[j].size();i++) { + //int i0 = j*I+i; + if((mm=alpha[alphai*S+PS[j][i]]+in[k*O+OS[PS[j][i]*I+PI[j][i]]])<minm) + minm=mm,minmi=i; + } + trace[k*S+j]=minmi; + alpha[((alphai+1)%2)*S+j]=minm; + if(minm<norm) norm=minm; + } + for(int j=0;j<S;j++) + alpha[((alphai+1)%2)*S+j]-=norm; // normalize total metrics so they do not explode + alphai=(alphai+1)%2; + } + + if(SK<0) { // final state not specified + minm=INF; + minmi=0; + for(int i=0;i<S;i++) + if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i; + st=minmi; + } + else { + st=SK; + } + + for(int k=K-1;k>=0;k--) { // traceback + int i0=trace[k*S+st]; + out[k]= (T) PI[st][i0]; + st=PS[st][i0]; + } + } + + template void + viterbi_algorithm<unsigned char>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + const float *in, unsigned char *out); + + template void + viterbi_algorithm<short>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + const float *in, short *out); + + template void + viterbi_algorithm<int>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + const float *in, int *out); + + //============================================== + + template <class Ti, class To> void + viterbi_algorithm_combined(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<Ti> &TABLE, + digital::trellis_metric_type_t TYPE, + const Ti *in, To *out) + { + std::vector<int> trace(S*K); + std::vector<float> alpha(S*2); + float *metric = new float[O]; + int alphai; + float norm,mm,minm; + int minmi; + int st; + + if(S0<0) { // initial state not specified + for(int i=0;i<S;i++) alpha[0*S+i]=0; + } + else { + for(int i=0;i<S;i++) alpha[0*S+i]=INF; + alpha[0*S+S0]=0.0; + } + + alphai=0; + for(int k=0;k<K;k++) { + calc_metric(O, D, TABLE, &(in[k*D]), metric,TYPE); // calc metrics + norm=INF; + for(int j=0;j<S;j++) { // for each next state do ACS + minm=INF; + minmi=0; + for(unsigned int i=0;i<PS[j].size();i++) { + //int i0 = j*I+i; + if((mm=alpha[alphai*S+PS[j][i]]+metric[OS[PS[j][i]*I+PI[j][i]]])<minm) + minm=mm,minmi=i; + } + trace[k*S+j]=minmi; + alpha[((alphai+1)%2)*S+j]=minm; + if(minm<norm) norm=minm; + } + for(int j=0;j<S;j++) + alpha[((alphai+1)%2)*S+j]-=norm; // normalize total metrics so they do not explode + alphai=(alphai+1)%2; + } + + if(SK<0) { // final state not specified + minm=INF; + minmi=0; + for(int i=0;i<S;i++) + if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i; + st=minmi; + } + else { + st=SK; + } + + for(int k=K-1;k>=0;k--) { // traceback + int i0=trace[k*S+st]; + out[k]= (To) PI[st][i0]; + st=PS[st][i0]; + } + + delete [] metric; + } + + // Ti = s i f c + // To = b s i + + //--------------- + + template void + viterbi_algorithm_combined<short,unsigned char>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<short> &TABLE, + digital::trellis_metric_type_t TYPE, + const short *in, unsigned char *out); + + template void + viterbi_algorithm_combined<int,unsigned char>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<int> &TABLE, + digital::trellis_metric_type_t TYPE, + const int *in, unsigned char *out); + + template void + viterbi_algorithm_combined<float,unsigned char>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<float> &TABLE, + digital::trellis_metric_type_t TYPE, + const float *in, unsigned char *out); + + template void + viterbi_algorithm_combined<gr_complex,unsigned char>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<gr_complex> &TABLE, + digital::trellis_metric_type_t TYPE, + const gr_complex *in, unsigned char *out); + + //--------------- + + template void + viterbi_algorithm_combined<short,short>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<short> &TABLE, + digital::trellis_metric_type_t TYPE, + const short *in, short *out); + + template void + viterbi_algorithm_combined<int,short>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<int> &TABLE, + digital::trellis_metric_type_t TYPE, + const int *in, short *out); + + template void + viterbi_algorithm_combined<float,short>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<float> &TABLE, + digital::trellis_metric_type_t TYPE, + const float *in, short *out); + + template void + viterbi_algorithm_combined<gr_complex,short>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<gr_complex> &TABLE, + digital::trellis_metric_type_t TYPE, + const gr_complex *in, short *out); + + //-------------- + + template void + viterbi_algorithm_combined<short,int>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<short> &TABLE, + digital::trellis_metric_type_t TYPE, + const short *in, int *out); + + template void + viterbi_algorithm_combined<int,int>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<int> &TABLE, + digital::trellis_metric_type_t TYPE, + const int *in, int *out); + + template void + viterbi_algorithm_combined<float,int>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<float> &TABLE, + digital::trellis_metric_type_t TYPE, + const float *in, int *out); + + template void + viterbi_algorithm_combined<gr_complex,int>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + int D, + const std::vector<gr_complex> &TABLE, + digital::trellis_metric_type_t TYPE, + const gr_complex *in, int *out); + + //=============================================== + + void + siso_algorithm(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + bool POSTI, bool POSTO, + float (*p2mymin)(float,float), + const float *priori, const float *prioro, float *post//, + //std::vector<float> &alpha, + //std::vector<float> &beta + ) + { + float norm,mm,minm; + std::vector<float> alpha(S*(K+1)); + std::vector<float> beta(S*(K+1)); + + if(S0<0) { // initial state not specified + for(int i=0;i<S;i++) alpha[0*S+i]=0; + } + else { + for(int i=0;i<S;i++) alpha[0*S+i]=INF; + alpha[0*S+S0]=0.0; + } + + for(int k=0;k<K;k++) { // forward recursion + norm=INF; + for(int j=0;j<S;j++) { + minm=INF; + for(unsigned int i=0;i<PS[j].size();i++) { + //int i0 = j*I+i; + mm=alpha[k*S+PS[j][i]]+priori[k*I+PI[j][i]]+prioro[k*O+OS[PS[j][i]*I+PI[j][i]]]; + minm=(*p2mymin)(minm,mm); + } + alpha[(k+1)*S+j]=minm; + if(minm<norm) norm=minm; + } + for(int j=0;j<S;j++) + alpha[(k+1)*S+j]-=norm; // normalize total metrics so they do not explode + } + + if(SK<0) { // final state not specified + for(int i=0;i<S;i++) beta[K*S+i]=0; + } + else { + for(int i=0;i<S;i++) beta[K*S+i]=INF; + beta[K*S+SK]=0.0; + } + + for(int k=K-1;k>=0;k--) { // backward recursion + norm=INF; + for(int j=0;j<S;j++) { + minm=INF; + for(int i=0;i<I;i++) { + int i0 = j*I+i; + mm=beta[(k+1)*S+NS[i0]]+priori[k*I+i]+prioro[k*O+OS[i0]]; + minm=(*p2mymin)(minm,mm); + } + beta[k*S+j]=minm; + if(minm<norm) norm=minm; + } + for(int j=0;j<S;j++) + beta[k*S+j]-=norm; // normalize total metrics so they do not explode + } + + if(POSTI && POSTO) + { + for(int k=0;k<K;k++) { // input combining + norm=INF; + for(int i=0;i<I;i++) { + minm=INF; + for(int j=0;j<S;j++) { + mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; + minm=(*p2mymin)(minm,mm); + } + post[k*(I+O)+i]=minm; + if(minm<norm) norm=minm; + } + for(int i=0;i<I;i++) + post[k*(I+O)+i]-=norm; // normalize metrics + } + + for(int k=0;k<K;k++) { // output combining + norm=INF; + for(int n=0;n<O;n++) { + minm=INF; + for(int j=0;j<S;j++) { + for(int i=0;i<I;i++) { + mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); + minm=(*p2mymin)(minm,mm); + } + } + post[k*(I+O)+I+n]=minm; + if(minm<norm) norm=minm; + } + for(int n=0;n<O;n++) + post[k*(I+O)+I+n]-=norm; // normalize metrics + } + } + else if(POSTI) + { + for(int k=0;k<K;k++) { // input combining + norm=INF; + for(int i=0;i<I;i++) { + minm=INF; + for(int j=0;j<S;j++) { + mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; + minm=(*p2mymin)(minm,mm); + } + post[k*I+i]=minm; + if(minm<norm) norm=minm; + } + for(int i=0;i<I;i++) + post[k*I+i]-=norm; // normalize metrics + } + } + else if(POSTO) + { + for(int k=0;k<K;k++) { // output combining + norm=INF; + for(int n=0;n<O;n++) { + minm=INF; + for(int j=0;j<S;j++) { + for(int i=0;i<I;i++) { + mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); + minm=(*p2mymin)(minm,mm); + } + } + post[k*O+n]=minm; + if(minm<norm) norm=minm; + } + for(int n=0;n<O;n++) + post[k*O+n]-=norm; // normalize metrics + } + } + else + throw std::runtime_error("Not both POSTI and POSTO can be false."); + } + + //=========================================================== + + template <class T> void + siso_algorithm_combined(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + bool POSTI, bool POSTO, + float (*p2mymin)(float,float), + int D, + const std::vector<T> &TABLE, + digital::trellis_metric_type_t TYPE, + const float *priori, const T *observations, float *post) + { + float norm,mm,minm; + std::vector<float> alpha(S*(K+1)); + std::vector<float> beta(S*(K+1)); + float *prioro = new float[O*K]; + + if(S0<0) { // initial state not specified + for(int i=0;i<S;i++) alpha[0*S+i]=0; + } + else { + for(int i=0;i<S;i++) alpha[0*S+i]=INF; + alpha[0*S+S0]=0.0; + } + + for(int k=0;k<K;k++) { // forward recursion + calc_metric(O, D, TABLE, &(observations[k*D]), &(prioro[k*O]),TYPE); // calc metrics + norm=INF; + for(int j=0;j<S;j++) { + minm=INF; + for(unsigned int i=0;i<PS[j].size();i++) { + //int i0 = j*I+i; + mm=alpha[k*S+PS[j][i]]+priori[k*I+PI[j][i]]+prioro[k*O+OS[PS[j][i]*I+PI[j][i]]]; + minm=(*p2mymin)(minm,mm); + } + alpha[(k+1)*S+j]=minm; + if(minm<norm) norm=minm; + } + for(int j=0;j<S;j++) + alpha[(k+1)*S+j]-=norm; // normalize total metrics so they do not explode + } + + if(SK<0) { // final state not specified + for(int i=0;i<S;i++) beta[K*S+i]=0; + } + else { + for(int i=0;i<S;i++) beta[K*S+i]=INF; + beta[K*S+SK]=0.0; + } + + for(int k=K-1;k>=0;k--) { // backward recursion + norm=INF; + for(int j=0;j<S;j++) { + minm=INF; + for(int i=0;i<I;i++) { + int i0 = j*I+i; + mm=beta[(k+1)*S+NS[i0]]+priori[k*I+i]+prioro[k*O+OS[i0]]; + minm=(*p2mymin)(minm,mm); + } + beta[k*S+j]=minm; + if(minm<norm) norm=minm; + } + for(int j=0;j<S;j++) + beta[k*S+j]-=norm; // normalize total metrics so they do not explode + } + + if(POSTI && POSTO) + { + for(int k=0;k<K;k++) { // input combining + norm=INF; + for(int i=0;i<I;i++) { + minm=INF; + for(int j=0;j<S;j++) { + mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; + minm=(*p2mymin)(minm,mm); + } + post[k*(I+O)+i]=minm; + if(minm<norm) norm=minm; + } + for(int i=0;i<I;i++) + post[k*(I+O)+i]-=norm; // normalize metrics + } + + for(int k=0;k<K;k++) { // output combining + norm=INF; + for(int n=0;n<O;n++) { + minm=INF; + for(int j=0;j<S;j++) { + for(int i=0;i<I;i++) { + mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); + minm=(*p2mymin)(minm,mm); + } + } + post[k*(I+O)+I+n]=minm; + if(minm<norm) norm=minm; + } + for(int n=0;n<O;n++) + post[k*(I+O)+I+n]-=norm; // normalize metrics + } + } + else if(POSTI) + { + for(int k=0;k<K;k++) { // input combining + norm=INF; + for(int i=0;i<I;i++) { + minm=INF; + for(int j=0;j<S;j++) { + mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; + minm=(*p2mymin)(minm,mm); + } + post[k*I+i]=minm; + if(minm<norm) norm=minm; + } + for(int i=0;i<I;i++) + post[k*I+i]-=norm; // normalize metrics + } + } + else if(POSTO) { + for(int k=0;k<K;k++) { // output combining + norm=INF; + for(int n=0;n<O;n++) { + minm=INF; + for(int j=0;j<S;j++) { + for(int i=0;i<I;i++) { + mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); + minm=(*p2mymin)(minm,mm); + } + } + post[k*O+n]=minm; + if(minm<norm) norm=minm; + } + for(int n=0;n<O;n++) + post[k*O+n]-=norm; // normalize metrics + } + } + else + throw std::runtime_error ("Not both POSTI and POSTO can be false."); + + delete [] prioro; + } + + //--------- + + template void + siso_algorithm_combined<short>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + bool POSTI, bool POSTO, + float (*p2mymin)(float,float), + int D, + const std::vector<short> &TABLE, + digital::trellis_metric_type_t TYPE, + const float *priori, const short *observations, float *post); + + template void + siso_algorithm_combined<int>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + bool POSTI, bool POSTO, + float (*p2mymin)(float,float), + int D, + const std::vector<int> &TABLE, + digital::trellis_metric_type_t TYPE, + const float *priori, const int *observations, float *post); + + template void + siso_algorithm_combined<float>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + bool POSTI, bool POSTO, + float (*p2mymin)(float,float), + int D, + const std::vector<float> &TABLE, + digital::trellis_metric_type_t TYPE, + const float *priori, const float *observations, float *post); + + template void + siso_algorithm_combined<gr_complex>(int I, int S, int O, + const std::vector<int> &NS, + const std::vector<int> &OS, + const std::vector< std::vector<int> > &PS, + const std::vector< std::vector<int> > &PI, + int K, + int S0,int SK, + bool POSTI, bool POSTO, + float (*p2mymin)(float,float), + int D, + const std::vector<gr_complex> &TABLE, + digital::trellis_metric_type_t TYPE, + const float *priori, const gr_complex *observations, float *post); + + //========================================================= + + template<class Ti, class To> void + sccc_decoder_combined(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<Ti> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const Ti *observations, To *data) + { + //allocate space for priori, prioro and posti of inner FSM + std::vector<float> ipriori(blocklength*FSMi.I(),0.0); + std::vector<float> iprioro(blocklength*FSMi.O()); + std::vector<float> iposti(blocklength*FSMi.I()); + + //allocate space for priori, prioro and posto of outer FSM + std::vector<float> opriori(blocklength*FSMo.I(),0.0); + std::vector<float> oprioro(blocklength*FSMo.O()); + std::vector<float> oposti(blocklength*FSMo.I()); + std::vector<float> oposto(blocklength*FSMo.O()); + + // turn observations to neg-log-priors + for(int k=0;k<blocklength;k++) { + calc_metric(FSMi.O(), D, TABLE, &(observations[k*D]), &(iprioro[k*FSMi.O()]),METRIC_TYPE); + iprioro[k*FSMi.O()] *= scaling; + } + + for(int rep=0;rep<iterations;rep++) { + // run inner SISO + siso_algorithm(FSMi.I(),FSMi.S(),FSMi.O(), + FSMi.NS(), FSMi.OS(), FSMi.PS(), FSMi.PI(), + blocklength, + STi0,STiK, + true, false, + p2mymin, + &(ipriori[0]), &(iprioro[0]), &(iposti[0])); + + //interleave soft info inner -> outer + for(int k=0;k<blocklength;k++) { + int ki = INTERLEAVER.DEINTER()[k]; + //for(int i=0;i<FSMi.I();i++) { + //oprioro[k*FSMi.I()+i]=iposti[ki*FSMi.I()+i]; + //} + memcpy(&(oprioro[k*FSMi.I()]),&(iposti[ki*FSMi.I()]),FSMi.I()*sizeof(float)); + } + + // run outer SISO + + if(rep<iterations-1) { // do not produce posti + siso_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), + FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), + blocklength, + STo0,SToK, + false, true, + p2mymin, + &(opriori[0]), &(oprioro[0]), &(oposto[0])); + + //interleave soft info outer --> inner + for(int k=0;k<blocklength;k++) { + int ki = INTERLEAVER.DEINTER()[k]; + //for(int i=0;i<FSMi.I();i++) { + //ipriori[ki*FSMi.I()+i]=oposto[k*FSMi.I()+i]; + //} + memcpy(&(ipriori[ki*FSMi.I()]),&(oposto[k*FSMi.I()]),FSMi.I()*sizeof(float)); + } + } + else // produce posti but not posto + + siso_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), + FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), + blocklength, + STo0,SToK, + true, false, + p2mymin, + &(opriori[0]), &(oprioro[0]), &(oposti[0])); + + /* + viterbi_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), + FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), + blocklength, + STo0,SToK, + &(oprioro[0]), data + ); + */ + } + + // generate hard decisions + for(int k=0;k<blocklength;k++) { + float min=INF; + int mini=0; + for(int i=0;i<FSMo.I();i++) { + if(oposti[k*FSMo.I()+i]<min) { + min=oposti[k*FSMo.I()+i]; + mini=i; + } + } + data[k]=(To)mini; + } + } + + //------- + + template void + sccc_decoder_combined<float,unsigned char>(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<float> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const float *observations, unsigned char *data); + + template void + sccc_decoder_combined<float,short>(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<float> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const float *observations, short *data); + + template void + sccc_decoder_combined<float,int>(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<float> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const float *observations, int *data); + + template void + sccc_decoder_combined<gr_complex,unsigned char>(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<gr_complex> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const gr_complex *observations, unsigned char *data + ); + + template void + sccc_decoder_combined<gr_complex,short>(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<gr_complex> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const gr_complex *observations, short *data); + + template void + sccc_decoder_combined<gr_complex,int>(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<gr_complex> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const gr_complex *observations, int *data); + + //========================================================= + + template<class T> void + sccc_decoder(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, int iterations, + float (*p2mymin)(float,float), + const float *iprioro, T *data) + { + //allocate space for priori, and posti of inner FSM + std::vector<float> ipriori(blocklength*FSMi.I(),0.0); + std::vector<float> iposti(blocklength*FSMi.I()); + + //allocate space for priori, prioro and posto of outer FSM + std::vector<float> opriori(blocklength*FSMo.I(),0.0); + std::vector<float> oprioro(blocklength*FSMo.O()); + std::vector<float> oposti(blocklength*FSMo.I()); + std::vector<float> oposto(blocklength*FSMo.O()); + + for(int rep=0;rep<iterations;rep++) { + // run inner SISO + siso_algorithm(FSMi.I(),FSMi.S(),FSMi.O(), + FSMi.NS(), FSMi.OS(), FSMi.PS(), FSMi.PI(), + blocklength, + STi0,STiK, + true, false, + p2mymin, + &(ipriori[0]), &(iprioro[0]), &(iposti[0])); + + //interleave soft info inner -> outer + for(int k=0;k<blocklength;k++) { + int ki = INTERLEAVER.DEINTER()[k]; + //for(int i=0;i<FSMi.I();i++) { + //oprioro[k*FSMi.I()+i]=iposti[ki*FSMi.I()+i]; + //} + memcpy(&(oprioro[k*FSMi.I()]),&(iposti[ki*FSMi.I()]),FSMi.I()*sizeof(float)); + } + + // run outer SISO + + if(rep<iterations-1) { // do not produce posti + siso_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), + FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), + blocklength, + STo0,SToK, + false, true, + p2mymin, + &(opriori[0]), &(oprioro[0]), &(oposto[0])); + + //interleave soft info outer --> inner + for(int k=0;k<blocklength;k++) { + int ki = INTERLEAVER.DEINTER()[k]; + //for(int i=0;i<FSMi.I();i++) { + //ipriori[ki*FSMi.I()+i]=oposto[k*FSMi.I()+i]; + //} + memcpy(&(ipriori[ki*FSMi.I()]),&(oposto[k*FSMi.I()]),FSMi.I()*sizeof(float)); + } + } + else {// produce posti but not posto + siso_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), + FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), + blocklength, + STo0,SToK, + true, false, + p2mymin, + &(opriori[0]), &(oprioro[0]), &(oposti[0])); + + /* + viterbi_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), + FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), + blocklength, + STo0,SToK, + &(oprioro[0]), data); + */ + } + } // end iterations + + // generate hard decisions + for(int k=0;k<blocklength;k++) { + float min=INF; + int mini=0; + for(int i=0;i<FSMo.I();i++) { + if(oposti[k*FSMo.I()+i]<min) { + min=oposti[k*FSMo.I()+i]; + mini=i; + } + } + data[k]=(T)mini; + } + } + + //------- + + template void + sccc_decoder<unsigned char>(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + const float *iprioro, unsigned char *data); + + template void + sccc_decoder<short>(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + const float *iprioro, short *data); + + template void + sccc_decoder<int>(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + const float *iprioro, int *data); + + //==================================================== + + template<class T> void + pccc_decoder(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + const float *cprioro, T *data) + { + //allocate space for priori, prioro and posti of FSM1 + std::vector<float> priori1(blocklength*FSM1.I(),0.0); + std::vector<float> prioro1(blocklength*FSM1.O()); + std::vector<float> posti1(blocklength*FSM1.I()); + + //allocate space for priori, prioro and posti of FSM2 + std::vector<float> priori2(blocklength*FSM2.I(),0.0); + std::vector<float> prioro2(blocklength*FSM2.O()); + std::vector<float> posti2(blocklength*FSM2.I()); + + //generate prioro1,2 (metrics are not updated per iteration: this is not the best you can do...) + for(int k=0;k<blocklength;k++) { + //std::cout << k << std::endl; + for(int i=0;i<FSM1.O();i++) { + float x=cprioro[k*FSM1.O()*FSM2.O()+i*FSM1.O()+0]; + for(int j=1;j<FSM2.O();j++) + x = (*p2mymin)(x,cprioro[k*FSM1.O()*FSM2.O()+i*FSM1.O()+j]); + prioro1[k*FSM1.O()+i]=x; + //std::cout << prioro1[k*FSM1.O()+i] << ", "; + } + //std::cout << std::endl; + for(int i=0;i<FSM2.O();i++) { + float x=cprioro[k*FSM1.O()*FSM2.O()+0*FSM1.O()+i]; + for(int j=1;j<FSM1.O();j++) + x = (*p2mymin)(x,cprioro[k*FSM1.O()*FSM2.O()+j*FSM1.O()+i]); + prioro2[k*FSM2.O()+i]=x; + } + } + + for(int rep=0;rep<iterations;rep++) { + // run SISO 1 + siso_algorithm(FSM1.I(),FSM1.S(),FSM1.O(), + FSM1.NS(), FSM1.OS(), FSM1.PS(), FSM1.PI(), + blocklength, + ST10,ST1K, + true, false, + p2mymin, + &(priori1[0]), &(prioro1[0]), &(posti1[0])); + + //for(int k=0;k<blocklength;k++){ + //for(int i=0;i<FSM1.I();i++) + //std::cout << posti1[k*FSM1.I()+i] << ", "; + //std::cout << std::endl; + //} + + //interleave soft info 1 -> 2 + for(int k=0;k<blocklength;k++) { + int ki = INTERLEAVER.INTER()[k]; + //for(int i=0;i<FSMi.I();i++) { + //oprioro[k*FSMi.I()+i]=iposti[ki*FSMi.I()+i]; + //} + memcpy(&(priori2[k*FSM2.I()]),&(posti1[ki*FSM1.I()]),FSM1.I()*sizeof(float)); + } + + // run SISO 2 + siso_algorithm(FSM2.I(),FSM2.S(),FSM2.O(), + FSM2.NS(), FSM2.OS(), FSM2.PS(), FSM2.PI(), + blocklength, + ST20,ST2K, + true, false, + p2mymin, + &(priori2[0]), &(prioro2[0]), &(posti2[0])); + + //interleave soft info 2 --> 1 + for(int k=0;k<blocklength;k++) { + int ki = INTERLEAVER.INTER()[k]; + //for(int i=0;i<FSMi.I();i++) { + //ipriori[ki*FSMi.I()+i]=oposto[k*FSMi.I()+i]; + //} + memcpy(&(priori1[ki*FSM1.I()]),&(posti2[k*FSM2.I()]),FSM1.I()*sizeof(float)); + } + } // end iterations + + // generate hard decisions + for(int k=0;k<blocklength;k++) { + for(int i=0;i<FSM1.I();i++) + posti1[k*FSM1.I()+i] = (*p2mymin)(priori1[k*FSM1.I()+i],posti1[k*FSM1.I()+i]); + float min=INF; + int mini=0; + for(int i=0;i<FSM1.I();i++) { + if(posti1[k*FSM1.I()+i]<min) { + min=posti1[k*FSM1.I()+i]; + mini=i; + } + } + data[k]=(T)mini; + //std::cout << data[k] << ", "<< std::endl; + } + //std::cout << std::endl; + } + + //---------------- + + template void + pccc_decoder<unsigned char>(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + const float *cprioro, unsigned char *data); + + template void + pccc_decoder<short>(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + const float *cprioro, short *data); + + template void + pccc_decoder<int>(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + const float *cprioro, int *data); + + //---------------- + + template<class Ti, class To> void + pccc_decoder_combined(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<Ti> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const Ti *observations, To *data) + { + //allocate space for cprioro + std::vector<float> cprioro(blocklength*FSM1.O()*FSM2.O(),0.0); + + //allocate space for priori, prioro and posti of FSM1 + std::vector<float> priori1(blocklength*FSM1.I(),0.0); + std::vector<float> prioro1(blocklength*FSM1.O()); + std::vector<float> posti1(blocklength*FSM1.I()); + + //allocate space for priori, prioro and posti of FSM2 + std::vector<float> priori2(blocklength*FSM2.I(),0.0); + std::vector<float> prioro2(blocklength*FSM2.O()); + std::vector<float> posti2(blocklength*FSM2.I()); + + // turn observations to neg-log-priors for cprioiro + int O=FSM1.O()*FSM2.O(); + for(int k=0;k<blocklength;k++) { + calc_metric(O, D, TABLE, &(observations[k*D]), &(cprioro[k*O]),METRIC_TYPE); + cprioro[k*O] *= scaling; + } + + //generate prioro1,2 (metrics are not updated per iteration: this is not the best you can do...) + for(int k=0;k<blocklength;k++) { + //std::cout << k << std::endl; + for(int i=0;i<FSM1.O();i++) { + float x=cprioro[k*FSM1.O()*FSM2.O()+i*FSM1.O()+0]; + for(int j=1;j<FSM2.O();j++) + x = (*p2mymin)(x,cprioro[k*FSM1.O()*FSM2.O()+i*FSM1.O()+j]); + prioro1[k*FSM1.O()+i]=x; + //std::cout << prioro1[k*FSM1.O()+i] << ", "; + } + //std::cout << std::endl; + for(int i=0;i<FSM2.O();i++) { + float x=cprioro[k*FSM1.O()*FSM2.O()+0*FSM1.O()+i]; + for(int j=1;j<FSM1.O();j++) + x = (*p2mymin)(x,cprioro[k*FSM1.O()*FSM2.O()+j*FSM1.O()+i]); + prioro2[k*FSM2.O()+i]=x; + } + } + + for(int rep=0;rep<iterations;rep++) { + // run SISO 1 + siso_algorithm(FSM1.I(),FSM1.S(),FSM1.O(), + FSM1.NS(), FSM1.OS(), FSM1.PS(), FSM1.PI(), + blocklength, + ST10,ST1K, + true, false, + p2mymin, + &(priori1[0]), &(prioro1[0]), &(posti1[0])); + + //for(int k=0;k<blocklength;k++){ + //for(int i=0;i<FSM1.I();i++) + //std::cout << posti1[k*FSM1.I()+i] << ", "; + //std::cout << std::endl; + //} + + //interleave soft info 1 -> 2 + for(int k=0;k<blocklength;k++) { + int ki = INTERLEAVER.INTER()[k]; + //for(int i=0;i<FSMi.I();i++) { + //oprioro[k*FSMi.I()+i]=iposti[ki*FSMi.I()+i]; + //} + memcpy(&(priori2[k*FSM2.I()]),&(posti1[ki*FSM1.I()]),FSM1.I()*sizeof(float)); + } + + // run SISO 2 + siso_algorithm(FSM2.I(),FSM2.S(),FSM2.O(), + FSM2.NS(), FSM2.OS(), FSM2.PS(), FSM2.PI(), + blocklength, + ST20,ST2K, + true, false, + p2mymin, + &(priori2[0]), &(prioro2[0]), &(posti2[0])); + + //interleave soft info 2 --> 1 + for(int k=0;k<blocklength;k++) { + int ki = INTERLEAVER.INTER()[k]; + //for(int i=0;i<FSMi.I();i++) { + //ipriori[ki*FSMi.I()+i]=oposto[k*FSMi.I()+i]; + //} + memcpy(&(priori1[ki*FSM1.I()]),&(posti2[k*FSM2.I()]),FSM1.I()*sizeof(float)); + } + } // end iterations + + // generate hard decisions + for(int k=0;k<blocklength;k++) { + for(int i=0;i<FSM1.I();i++) + posti1[k*FSM1.I()+i] = (*p2mymin)(priori1[k*FSM1.I()+i],posti1[k*FSM1.I()+i]); + float min=INF; + int mini=0; + for(int i=0;i<FSM1.I();i++) { + if(posti1[k*FSM1.I()+i]<min) { + min=posti1[k*FSM1.I()+i]; + mini=i; + } + } + data[k]=(To)mini; + //std::cout << data[k] << ", "<< std::endl; + } + //std::cout << std::endl; + } + + template void + pccc_decoder_combined(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<float> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const float *observations, unsigned char *data); + + template void + pccc_decoder_combined(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<float> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const float *observations, short *data); + + template void + pccc_decoder_combined(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<float> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const float *observations, int *data); + + template void + pccc_decoder_combined(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<gr_complex> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const gr_complex *observations, unsigned char *data); + + template void + pccc_decoder_combined(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<gr_complex> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const gr_complex *observations, short *data); + + template void + pccc_decoder_combined(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, int blocklength, + int iterations, + float (*p2mymin)(float,float), + int D, const std::vector<gr_complex> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling, + const gr_complex *observations, int *data); + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/encoder_XX_impl.cc.t b/gr-trellis/lib/encoder_XX_impl.cc.t new file mode 100644 index 0000000000..fdda593d45 --- /dev/null +++ b/gr-trellis/lib/encoder_XX_impl.cc.t @@ -0,0 +1,82 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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 "@NAME@.h" +#include <gr_io_signature.h> +#include <iostream> + +namespace gr { + namespace trellis { + + @BASE_NAME@::sptr + @BASE_NAME@::make(const fsm &FSM, int ST) + { + return gnuradio::get_initial_sptr + (new @IMPL_NAME@(FSM,ST)); + } + + @IMPL_NAME@::@IMPL_NAME@(const fsm &FSM, int ST) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, -1, sizeof(@I_TYPE@)), + gr_make_io_signature(1, -1, sizeof(@O_TYPE@))), + d_FSM(FSM), + d_ST(ST) + { + } + + @IMPL_NAME@::~@IMPL_NAME@() + { + } + + int + @IMPL_NAME@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int ST_tmp = 0; + int nstreams = input_items.size(); + + for(int m=0;m<nstreams;m++) { + const @I_TYPE@ *in = (const @I_TYPE@*)input_items[m]; + @O_TYPE@ *out = (@O_TYPE@ *) output_items[m]; + ST_tmp = d_ST; + + // per stream processing + for(int i = 0; i < noutput_items; i++) { + out[i] = (@O_TYPE@)d_FSM.OS()[ST_tmp*d_FSM.I()+in[i]]; // direction of time? + ST_tmp = (int)d_FSM.NS()[ST_tmp*d_FSM.I()+in[i]]; + } + // end per stream processing + } + d_ST = ST_tmp; + + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gnuradio-core/src/lib/gengen/gr_not_XX.h.t b/gr-trellis/lib/encoder_XX_impl.h.t index aff4211099..949f1182de 100644 --- a/gnuradio-core/src/lib/gengen/gr_not_XX.h.t +++ b/gr-trellis/lib/encoder_XX_impl.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008 Free Software Foundation, Inc. + * Copyright 2004,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,31 +25,30 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ -#include <gr_core_api.h> -#include <gr_sync_block.h> +#include <trellis/@BASE_NAME@.h> -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; +namespace gr { + namespace trellis { -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); + class @IMPL_NAME@ : public @BASE_NAME@ + { + private: + fsm d_FSM; + int d_ST; -/*! - * \brief output = ~input_0 - * \ingroup math_blk - * - * bitwise boolean not across input stream. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); + public: + @IMPL_NAME@(const fsm &FSM, int ST); + ~@IMPL_NAME@(); - @NAME@ (); + fsm FSM() const { return d_FSM; } + int ST() const { return d_ST; } - public: + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; + } /* namespace trellis */ +} /* namespace gr */ -#endif +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/lib/fsm.cc b/gr-trellis/lib/fsm.cc new file mode 100644 index 0000000000..16efcd10f2 --- /dev/null +++ b/gr-trellis/lib/fsm.cc @@ -0,0 +1,521 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2012 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. + */ + +#include <cstdio> +#include <string> +#include <iostream> +#include <fstream> +#include <stdexcept> +#include <cmath> +#include <stdlib.h> +#include <trellis/base.h> +#include <trellis/fsm.h> + +namespace gr { + namespace trellis { + + fsm::fsm() + { + d_I=0; + d_S=0; + d_O=0; + d_NS.resize(0); + d_OS.resize(0); + d_PS.resize(0); + d_PI.resize(0); + d_TMi.resize(0); + d_TMl.resize(0); + } + + fsm::fsm(const fsm &FSM) + { + d_I=FSM.I(); + d_S=FSM.S(); + d_O=FSM.O(); + d_NS=FSM.NS(); + d_OS=FSM.OS(); + d_PS=FSM.PS(); // is this going to make a deep copy? + d_PI=FSM.PI(); + d_TMi=FSM.TMi(); + d_TMl=FSM.TMl(); + } + + fsm::fsm(int I, int S, int O, const std::vector<int> &NS, const std::vector<int> &OS) + { + d_I=I; + d_S=S; + d_O=O; + d_NS=NS; + d_OS=OS; + + generate_PS_PI(); + generate_TM(); + } + + //###################################################################### + //# Read an FSM specification from a file. + //# Format (hopefully will become more flexible in the future...): + //# I S O (in the first line) + //# blank line + //# Next state matrix (S lines, each with I integers separated by spaces) + //# blank line + //# output symbol matrix (S lines, each with I integers separated by spaces) + //# optional comments + //###################################################################### + fsm::fsm(const char *name) + { + FILE *fsmfile; + + if((fsmfile=fopen(name,"r"))==NULL) + throw std::runtime_error ("fsm::fsm(const char *name): file open error\n"); + //printf("file open error in fsm()\n"); + + if(fscanf(fsmfile,"%d %d %d\n",&d_I,&d_S,&d_O) == EOF) { + if(ferror(fsmfile) != 0) + throw std::runtime_error ("fsm::fsm(const char *name): file read error\n"); + } + + d_NS.resize(d_I*d_S); + d_OS.resize(d_I*d_S); + + for(int i=0;i<d_S;i++) { + for(int j=0;j<d_I;j++) { + if(fscanf(fsmfile,"%d",&(d_NS[i*d_I+j])) == EOF) { + if(ferror(fsmfile) != 0) + throw std::runtime_error ("fsm::fsm(const char *name): file read error\n"); + } + } + } + for(int i=0;i<d_S;i++) { + for(int j=0;j<d_I;j++) { + if(fscanf(fsmfile,"%d",&(d_OS[i*d_I+j])) == EOF) { + if(ferror(fsmfile) != 0) + throw std::runtime_error ("fsm::fsm(const char *name): file read error\n"); + } + } + } + + fclose(fsmfile); + + generate_PS_PI(); + generate_TM(); + } + + //###################################################################### + //# Automatically generate the FSM from the generator matrix + //# of a (n,k) binary convolutional code + //###################################################################### + fsm::fsm(int k, int n, const std::vector<int> &G) + { + // calculate maximum memory requirements for each input stream + std::vector<int> max_mem_x(k,-1); + int max_mem = -1; + for(int i=0;i<k;i++) { + for(int j=0;j<n;j++) { + int mem = -1; + if(G[i*n+j]!=0) + mem=(int)(log(double(G[i*n+j]))/log(2.0)); + if(mem>max_mem_x[i]) + max_mem_x[i]=mem; + if(mem>max_mem) + max_mem=mem; + } + } + + //printf("max_mem_x\n"); + //for(int j=0;j<max_mem_x.size();j++) printf("%d ",max_mem_x[j]); printf("\n"); + + // calculate total memory requirements to set S + int sum_max_mem = 0; + for(int i=0;i<k;i++) + sum_max_mem += max_mem_x[i]; + + //printf("sum_max_mem = %d\n",sum_max_mem); + + d_I=1<<k; + d_S=1<<sum_max_mem; + d_O=1<<n; + + // binary representation of the G matrix + std::vector<std::vector<int> > Gb(k*n); + for(int j=0;j<k*n;j++) { + Gb[j].resize(max_mem+1); + dec2base(G[j],2,Gb[j]); + //printf("Gb\n"); + //for(int m=0;m<Gb[j].size();m++) printf("%d ",Gb[j][m]); printf("\n"); + } + + // alphabet size of each shift register + std::vector<int> bases_x(k); + for(int j=0;j<k ;j++) + bases_x[j] = 1 << max_mem_x[j]; + //printf("bases_x\n"); + //for(int j=0;j<max_mem_x.size();j++) printf("%d ",max_mem_x[j]); printf("\n"); + + d_NS.resize(d_I*d_S); + d_OS.resize(d_I*d_S); + + std::vector<int> sx(k); + std::vector<int> nsx(k); + std::vector<int> tx(k); + std::vector<std::vector<int> > tb(k); + for(int j=0;j<k;j++) + tb[j].resize(max_mem+1); + std::vector<int> inb(k); + std::vector<int> outb(n); + + for(int s=0;s<d_S;s++) { + dec2bases(s,bases_x,sx); // split s into k values, each representing one of the k shift registers + //printf("state = %d \nstates = ",s); + //for(int j=0;j<sx.size();j++) printf("%d ",sx[j]); printf("\n"); + for(int i=0;i<d_I;i++) { + dec2base(i,2,inb); // input in binary + //printf("input = %d \ninputs = ",i); + //for(int j=0;j<inb.size();j++) printf("%d ",inb[j]); printf("\n"); + + // evaluate next state + for(int j=0;j<k;j++) + nsx[j] = (inb[j]*bases_x[j]+sx[j])/2; // next state (for each shift register) MSB first + d_NS[s*d_I+i]=bases2dec(nsx,bases_x); // collect all values into the new state + + // evaluate transitions + for(int j=0;j<k;j++) + tx[j] = inb[j]*bases_x[j]+sx[j]; // transition (for each shift register)MSB first + for(int j=0;j<k;j++) { + dec2base(tx[j],2,tb[j]); // transition in binary + //printf("transition = %d \ntransitions = ",tx[j]); + //for(int m=0;m<tb[j].size();m++) printf("%d ",tb[j][m]); printf("\n"); + } + + // evaluate outputs + for(int nn=0;nn<n;nn++) { + outb[nn] = 0; + for(int j=0;j<k;j++) { + for(int m=0;m<max_mem+1;m++) + outb[nn] = (outb[nn] + Gb[j*n+nn][m]*tb[j][m]) % 2; // careful: polynomial 1+D ir represented as 110, not as 011 + //printf("output %d equals %d\n",nn,outb[nn]); + } + } + d_OS[s*d_I+i] = base2dec(outb,2); + } + } + + generate_PS_PI(); + generate_TM(); + } + + //###################################################################### + //# Automatically generate an FSM specification describing the + //# ISI for a channel + //# of length ch_length and a modulation of size mod_size + //###################################################################### + fsm::fsm(int mod_size, int ch_length) + { + d_I=mod_size; + d_S=(int) (pow(1.0*d_I,1.0*ch_length-1)+0.5); + d_O=d_S*d_I; + + d_NS.resize(d_I*d_S); + d_OS.resize(d_I*d_S); + + for(int s=0;s<d_S;s++) { + for(int i=0;i<d_I;i++) { + int t=i*d_S+s; + d_NS[s*d_I+i] = t/d_I; + d_OS[s*d_I+i] = t; + } + } + + generate_PS_PI(); + generate_TM(); + } + + //###################################################################### + //# Automatically generate an FSM specification describing the + //# the trellis for a CPM with h=K/P (relatively prime), + //# alphabet size M, and frequency pulse duration L symbols + //# + //# This FSM is based on the paper by B. Rimoldi + //# "A decomposition approach to CPM", IEEE Trans. Info Theory, March 1988 + //# See also my own notes at http://www.eecs.umich.edu/~anastas/docs/cpm.pdf + //###################################################################### + fsm::fsm(int P, int M, int L) + { + d_I=M; + d_S=(int)(pow(1.0*M,1.0*L-1)+0.5)*P; + d_O=(int)(pow(1.0*M,1.0*L)+0.5)*P; + + d_NS.resize(d_I*d_S); + d_OS.resize(d_I*d_S); + int nv; + for(int s=0;s<d_S;s++) { + for(int i=0;i<d_I;i++) { + int s1=s/P; + int v=s%P; + int ns1= (i*(int)(pow(1.0*M,1.0*(L-1))+0.5)+s1)/M; + if (L==1) + nv=(i+v)%P; + else + nv=(s1%M+v)%P; + d_NS[s*d_I+i] = ns1*P+nv; + d_OS[s*d_I+i] = i*d_S+s; + } + } + + generate_PS_PI(); + generate_TM(); + } + + //###################################################################### + //# Automatically generate an FSM specification describing the + //# the joint trellis of fsm1 and fsm2 + //###################################################################### + fsm::fsm(const fsm &FSM1, const fsm &FSM2) + { + d_I=FSM1.I()*FSM2.I(); + d_S=FSM1.S()*FSM2.S(); + d_O=FSM1.O()*FSM2.O(); + + d_NS.resize(d_I*d_S); + d_OS.resize(d_I*d_S); + + for(int s=0;s<d_S;s++) { + for(int i=0;i<d_I;i++) { + int s1=s/FSM2.S(); + int s2=s%FSM2.S(); + int i1=i/FSM2.I(); + int i2=i%FSM2.I(); + d_NS[s*d_I+i] = FSM1.NS()[s1 * FSM1.I() + i1] * FSM2.S() + FSM2.NS()[s2 * FSM2.I() + i2]; + d_OS[s*d_I+i] = FSM1.OS()[s1 * FSM1.I() + i1] * FSM2.O() + FSM2.OS()[s2 * FSM2.I() + i2]; + } + } + + generate_PS_PI(); + generate_TM(); + } + + //###################################################################### + //# Generate a new FSM representing n stages through the original FSM + //# AKA radix-n FSM + //###################################################################### + fsm::fsm(const fsm &FSM, int n) + { + d_I=(int) (pow(1.0*FSM.I(),1.0*n)+0.5); + d_S=FSM.S(); + d_O=(int) (pow(1.0*FSM.O(),1.0*n)+0.5); + + d_NS.resize(d_I*d_S); + d_OS.resize(d_I*d_S); + + for(int s=0;s<d_S;s++ ) { + for(int i=0;i<d_I;i++ ) { + std::vector<int> ii(n); + dec2base(i,FSM.I(),ii); + std::vector<int> oo(n); + int ns=s; + for(int k=0;k<n;k++) { + oo[k]=FSM.OS()[ns*FSM.I()+ii[k]]; + ns=FSM.NS()[ns*FSM.I()+ii[k]]; + } + d_NS[s*d_I+i]=ns; + d_OS[s*d_I+i]=base2dec(oo,FSM.O()); + } + } + + generate_PS_PI(); + generate_TM(); + } + + //###################################################################### + //# generate the PS and PI tables for later use + //###################################################################### + void + fsm::generate_PS_PI() + { + d_PS.resize(d_S); + d_PI.resize(d_S); + + for(int i=0;i<d_S;i++) { + d_PS[i].resize(d_I*d_S); // max possible size + d_PI[i].resize(d_I*d_S); + int j=0; + for(int ii=0;ii<d_S;ii++) for(int jj=0;jj<d_I;jj++) { + if(d_NS[ii*d_I+jj]!=i) continue; + d_PS[i][j]=ii; + d_PI[i][j]=jj; + j++; + } + d_PS[i].resize(j); + d_PI[i].resize(j); + } + } + + //###################################################################### + //# generate the termination matrices TMl and TMi for later use + //###################################################################### + void + fsm::generate_TM() + { + d_TMi.resize(d_S*d_S); + d_TMl.resize(d_S*d_S); + + for(int i=0;i<d_S*d_S;i++) { + d_TMi[i] = -1; // no meaning + d_TMl[i] = d_S; //infinity: you need at most S-1 steps + if (i/d_S == i%d_S) + d_TMl[i] = 0; + } + + for(int s=0;s<d_S;s++) { + bool done = false; + int attempts = 0; + while (done == false && attempts < d_S-1) { + done = find_es(s); + attempts ++; + } + if (done == false && d_S > 1) { + //throw std::runtime_error ("fsm::generate_TM(): FSM appears to be disconnected\n"); + printf("fsm::generate_TM(): FSM appears to be disconnected\n"); + printf("state %d cannot be reached from all other states\n",s); + } + } + } + + // find a path from any state to the ending state "es" + bool + fsm::find_es(int es) + { + bool done = true; + for(int s=0;s<d_S;s++) { + if(d_TMl[s*d_S+es] < d_S) + continue; + int minl=d_S; + int mini=-1; + for(int i=0;i<d_I;i++) { + if( 1 + d_TMl[d_NS[s*d_I+i]*d_S+es] < minl) { + minl = 1 + d_TMl[d_NS[s*d_I+i]*d_S+es]; + mini = i; + } + } + if (mini != -1) { + d_TMl[s*d_S+es]=minl; + d_TMi[s*d_S+es]=mini; + } + else + done = false; + } + return done; + } + + //###################################################################### + //# generate trellis representation of FSM as an SVG file + //###################################################################### + void + fsm::write_trellis_svg(std::string filename, int number_stages) + { + std::ofstream trellis_fname (filename.c_str()); + if(!trellis_fname) { + std::cout << "file not found " << std::endl ; exit(-1); + } + const int TRELLIS_Y_OFFSET = 30; + const int TRELLIS_X_OFFSET = 20; + const int STAGE_LABEL_Y_OFFSET = 25; + const int STAGE_LABEL_X_OFFSET = 20; + const int STATE_LABEL_Y_OFFSET = 30; + const int STATE_LABEL_X_OFFSET = 5; + const int STAGE_STATE_OFFSETS = 10; + // std::cout << "################## BEGIN SVG TRELLIS PIC #####################" << std::endl; + trellis_fname << "<svg viewBox = \"0 0 200 200\" version = \"1.1\">" << std::endl; + + for(int stage_num = 0;stage_num < number_stages;stage_num ++) { + // draw states + for(int state_num = 0;state_num < d_S ; state_num ++ ) { + trellis_fname << "<circle cx = \"" << stage_num * STAGE_STATE_OFFSETS + TRELLIS_X_OFFSET << + "\" cy = \"" << state_num * STAGE_STATE_OFFSETS + TRELLIS_Y_OFFSET << "\" r = \"1\"/>" << std::endl; + //draw branches + if(stage_num != number_stages-1) { + for(int branch_num = 0;branch_num < d_I; branch_num++) { + trellis_fname << "<line x1 =\"" << STAGE_STATE_OFFSETS * stage_num+ TRELLIS_X_OFFSET << "\" "; + trellis_fname << "y1 =\"" << state_num * STAGE_STATE_OFFSETS + TRELLIS_Y_OFFSET<< "\" "; + trellis_fname << "x2 =\"" << STAGE_STATE_OFFSETS *stage_num + STAGE_STATE_OFFSETS+ TRELLIS_X_OFFSET << "\" "; + trellis_fname << "y2 =\"" << d_NS[d_I * state_num + branch_num] * STAGE_STATE_OFFSETS + TRELLIS_Y_OFFSET << "\" "; + trellis_fname << " stroke-dasharray = \"3," << branch_num << "\" "; + trellis_fname << " stroke = \"black\" stroke-width = \"0.3\"/>" << std::endl; + } + } + } + } + // label the stages + trellis_fname << "<g font-size = \"4\" font= \"times\" fill = \"black\">" << std::endl; + for(int stage_num = 0;stage_num < number_stages ;stage_num ++) { + trellis_fname << "<text x = \"" << stage_num * STAGE_STATE_OFFSETS + STAGE_LABEL_X_OFFSET << + "\" y = \"" << STAGE_LABEL_Y_OFFSET << "\" >" << std::endl; + trellis_fname << stage_num << std::endl; + trellis_fname << "</text>" << std::endl; + } + trellis_fname << "</g>" << std::endl; + + // label the states + trellis_fname << "<g font-size = \"4\" font= \"times\" fill = \"black\">" << std::endl; + for(int state_num = 0;state_num < d_S ; state_num ++) { + trellis_fname << "<text y = \"" << state_num * STAGE_STATE_OFFSETS + STATE_LABEL_Y_OFFSET << + "\" x = \"" << STATE_LABEL_X_OFFSET << "\" >" << std::endl; + trellis_fname << state_num << std::endl; + trellis_fname << "</text>" << std::endl; + } + trellis_fname << "</g>" << std::endl; + + trellis_fname << "</svg>" << std::endl; + // std::cout << "################## END SVG TRELLIS PIC ##################### " << std::endl; + trellis_fname.close(); + } + + //###################################################################### + //# Write trellis specification to a text file, + //# in the same format used when reading FSM files + //###################################################################### + void + fsm::write_fsm_txt(std::string filename) + { + std::ofstream trellis_fname (filename.c_str()); + if(!trellis_fname) { + std::cout << "file not found " << std::endl ; exit(-1); + } + trellis_fname << d_I << ' ' << d_S << ' ' << d_O << std::endl; + trellis_fname << std::endl; + for(int i=0;i<d_S;i++) { + for(int j=0;j<d_I;j++) + trellis_fname << d_NS[i*d_I+j] << ' '; + trellis_fname << std::endl; + } + trellis_fname << std::endl; + for(int i=0;i<d_S;i++) { + for(int j=0;j<d_I;j++) + trellis_fname << d_OS[i*d_I+j] << ' '; + trellis_fname << std::endl; + } + trellis_fname << std::endl; + trellis_fname.close(); + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/interleaver.cc b/gr-trellis/lib/interleaver.cc new file mode 100644 index 0000000000..27248a6d43 --- /dev/null +++ b/gr-trellis/lib/interleaver.cc @@ -0,0 +1,147 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2012 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. + */ + +#include <cstdlib> +#include <cstdio> +#include <iostream> +#include <string> +#include <fstream> +#include <stdexcept> +#include <cmath> +#include <trellis/quicksort_index.h> +#include <trellis/interleaver.h> + +namespace gr { + namespace trellis { + + interleaver::interleaver() + { + d_K=0; + d_INTER.resize(0); + d_DEINTER.resize(0); + } + + interleaver::interleaver(const interleaver &INTERLEAVER) + { + d_K=INTERLEAVER.K(); + d_INTER=INTERLEAVER.INTER(); + d_DEINTER=INTERLEAVER.DEINTER(); + } + + interleaver::interleaver(int K, const std::vector<int> &INTER) + { + d_K=K; + d_INTER=INTER; + d_DEINTER.resize(d_K); + + // generate DEINTER table + for(int i=0;i<d_K;i++) { + d_DEINTER[d_INTER[i]]=i; + } + } + + //###################################################################### + //# Read an INTERLEAVER specification from a file. + //# Format (hopefully will become more flexible in the future...): + //# K + //# blank line + //# list of space separated K integers from 0 to K-1 in appropriate order + //# optional comments + //###################################################################### + interleaver::interleaver(const char *name) + { + FILE *interleaverfile; + + if((interleaverfile=fopen(name,"r")) == NULL) + throw std::runtime_error ("file open error in interleaver()"); + //printf("file open error in interleaver()\n"); + + if(fscanf(interleaverfile,"%d\n",&d_K) == EOF) { + if(ferror(interleaverfile) != 0) + throw std::runtime_error ("interleaver::interleaver(const char *name): file read error\n"); + } + + d_INTER.resize(d_K); + d_DEINTER.resize(d_K); + + for(int i=0;i<d_K;i++) { + if(fscanf(interleaverfile,"%d",&(d_INTER[i])) == EOF) { + if(ferror(interleaverfile) != 0) + throw std::runtime_error("interleaver::interleaver(const char *name): file read error\n"); + } + } + + // generate DEINTER table + for(int i=0;i<d_K;i++) { + d_DEINTER[d_INTER[i]]=i; + } + } + + //###################################################################### + //# Generate a random interleaver + //###################################################################### + interleaver::interleaver(int K, int seed) + { + d_K=K; + d_INTER.resize(d_K); + d_DEINTER.resize(d_K); + + if(seed>=0) + srand((unsigned int)seed); + std::vector<int> tmp(d_K); + for(int i=0;i<d_K;i++) { + d_INTER[i]=i; + tmp[i] = rand(); + } + quicksort_index <int> (tmp,d_INTER,0,d_K-1); + + // generate DEINTER table + for(int i=0;i<d_K;i++) { + d_DEINTER[d_INTER[i]]=i; + } + } + + //###################################################################### + //# Write an INTERLEAVER specification to a file. + //# Format + //# K + //# blank line + //# list of space separated K integers from 0 to K-1 in appropriate order + //# optional comments + //###################################################################### + void + interleaver::write_interleaver_txt(std::string filename) + { + std::ofstream interleaver_fname (filename.c_str()); + if(!interleaver_fname) { + std::cout << "file not found " << std::endl ; exit(-1); + } + interleaver_fname << d_K << std::endl; + interleaver_fname << std::endl; + for(int i=0;i<d_K;i++) + interleaver_fname << d_INTER[i] << ' '; + interleaver_fname << std::endl; + interleaver_fname.close(); + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/metrics_X_impl.cc.t b/gr-trellis/lib/metrics_X_impl.cc.t new file mode 100644 index 0000000000..c74051c53e --- /dev/null +++ b/gr-trellis/lib/metrics_X_impl.cc.t @@ -0,0 +1,98 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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 "@NAME@.h" +#include <gr_io_signature.h> +#include <assert.h> +#include <stdexcept> +#include <iostream> + +namespace gr { + namespace trellis { + + @BASE_NAME@::sptr + @BASE_NAME@::make(int O, int D, const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t TYPE) + { + return gnuradio::get_initial_sptr + (new @IMPL_NAME@(O,D,TABLE,TYPE)); + } + + @IMPL_NAME@::@IMPL_NAME@(int O, int D, const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t TYPE) + : gr_block("@BASE_NAME@", + gr_make_io_signature(1, -1, sizeof (@I_TYPE@)), + gr_make_io_signature(1, -1, sizeof (float))), + d_O(O), d_D(D), d_TYPE(TYPE), d_TABLE(TABLE) + { + set_relative_rate (1.0 * d_O / ((double) d_D)); + set_output_multiple ((int)d_O); + } + + @IMPL_NAME@::~@IMPL_NAME@() + { + } + + void + @IMPL_NAME@::set_TABLE(const std::vector<@I_TYPE@> &table) + { + d_TABLE = table; + } + + void + @IMPL_NAME@::forecast(int noutput_items, gr_vector_int &ninput_items_required) + { + int input_required = d_D * noutput_items / d_O; + unsigned ninputs = ninput_items_required.size(); + for(unsigned int i = 0; i < ninputs; i++) + ninput_items_required[i] = input_required; + } + + int + @IMPL_NAME@::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int nstreams = input_items.size(); + + for(int m = 0; m < nstreams; m++) { + const @I_TYPE@ *in = (@I_TYPE@*)input_items[m]; + float *out = (float*)output_items[m]; + + for(int i = 0; i < noutput_items / d_O ; i++) { + calc_metric(d_O, d_D, d_TABLE,&(in[i*d_D]), &(out[i*d_O]), d_TYPE); + } + } + + consume_each(d_D * noutput_items / d_O); + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/metrics_X_impl.h.t b/gr-trellis/lib/metrics_X_impl.h.t new file mode 100644 index 0000000000..0f52a8bc40 --- /dev/null +++ b/gr-trellis/lib/metrics_X_impl.h.t @@ -0,0 +1,64 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/@BASE_NAME@.h> + +namespace gr { + namespace trellis { + + class @IMPL_NAME@ : public @BASE_NAME@ + { + private: + int d_O; + int d_D; + digital::trellis_metric_type_t d_TYPE; + std::vector<@I_TYPE@> d_TABLE; + + public: + @IMPL_NAME@(int O, int D, const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t TYPE); + ~@IMPL_NAME@(); + + int O() const { return d_O; } + int D() const { return d_D; } + digital::trellis_metric_type_t TYPE() const { return d_TYPE; } + std::vector<@I_TYPE@> TABLE() const { return d_TABLE; } + void set_TABLE(const std::vector<@I_TYPE@> &table); + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/lib/pccc_decoder_X_impl.cc.t b/gr-trellis/lib/pccc_decoder_X_impl.cc.t new file mode 100644 index 0000000000..9bf85bc614 --- /dev/null +++ b/gr-trellis/lib/pccc_decoder_X_impl.cc.t @@ -0,0 +1,120 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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 "@NAME@.h" +#include <gr_io_signature.h> +#include <iostream> +#include <trellis/core_algorithms.h> + +namespace gr { + namespace trellis { + + static const float INF = 1.0e9; + + @BASE_NAME@::sptr + @BASE_NAME@::make(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE) + { + return gnuradio::get_initial_sptr + (new @IMPL_NAME@(FSM1, ST10, ST1K, + FSM2, ST20, ST2K, + INTERLEAVER, + blocklength, + repetitions, + SISO_TYPE)); + } + + @IMPL_NAME@::@IMPL_NAME@(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE) + : gr_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(float)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_FSM1(FSM1), d_ST10(ST10), d_ST1K(ST1K), + d_FSM2(FSM2), d_ST20(ST20), d_ST2K(ST2K), + d_INTERLEAVER(INTERLEAVER), + d_blocklength(blocklength), + d_repetitions(repetitions), + d_SISO_TYPE(SISO_TYPE) + { + set_relative_rate (1.0 / ((double) d_FSM1.O() * d_FSM2.O())); + set_output_multiple (d_blocklength); + } + + @IMPL_NAME@::~@IMPL_NAME@() + { + } + + void + @IMPL_NAME@::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + int input_required = d_FSM1.O() * d_FSM2.O() * noutput_items; + ninput_items_required[0] = input_required; + } + + //=========================================================== + + int + @IMPL_NAME@::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int nblocks = noutput_items / d_blocklength; + + float (*p2min)(float, float) = NULL; + if(d_SISO_TYPE == TRELLIS_MIN_SUM) + p2min = &min; + else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) + p2min = &min_star; + + const float *in = (const float *) input_items[0]; + @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; + for(int n=0;n<nblocks;n++) { + pccc_decoder(d_FSM1, d_ST10, d_ST1K, + d_FSM2, d_ST20, d_ST2K, + d_INTERLEAVER, d_blocklength, d_repetitions, + p2min, + &(in[n*d_blocklength*d_FSM1.O()*d_FSM2.O()]), + &(out[n*d_blocklength])); + } + + consume_each(d_FSM1.O() * d_FSM2.O() * noutput_items); + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/pccc_decoder_X_impl.h.t b/gr-trellis/lib/pccc_decoder_X_impl.h.t new file mode 100644 index 0000000000..9b61e34fde --- /dev/null +++ b/gr-trellis/lib/pccc_decoder_X_impl.h.t @@ -0,0 +1,80 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/@BASE_NAME@.h> + +namespace gr { + namespace trellis { + + class @IMPL_NAME@ : public @BASE_NAME@ + { + private: + fsm d_FSM1; + int d_ST10; + int d_ST1K; + fsm d_FSM2; + int d_ST20; + int d_ST2K; + interleaver d_INTERLEAVER; + int d_blocklength; + int d_repetitions; + siso_type_t d_SISO_TYPE; + std::vector<float> d_buffer; + + public: + @IMPL_NAME@(const fsm &FSM1, int ST10, int ST1K, + const fsm &FSM2, int ST20, int ST2K, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE); + ~@IMPL_NAME@(); + + fsm FSM1() const { return d_FSM1; } + fsm FSM2() const { return d_FSM2; } + int ST10() const { return d_ST10; } + int ST1K() const { return d_ST1K; } + int ST20() const { return d_ST20; } + int ST2K() const { return d_ST2K; } + interleaver INTERLEAVER() const { return d_INTERLEAVER; } + int blocklength() const { return d_blocklength; } + int repetitions() const { return d_repetitions; } + siso_type_t SISO_TYPE() const { return d_SISO_TYPE; } + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/lib/pccc_decoder_combined_XX_impl.cc.t b/gr-trellis/lib/pccc_decoder_combined_XX_impl.cc.t new file mode 100644 index 0000000000..21a5c0b3ae --- /dev/null +++ b/gr-trellis/lib/pccc_decoder_combined_XX_impl.cc.t @@ -0,0 +1,139 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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 "@NAME@.h" +#include <gr_io_signature.h> +#include <iostream> +#include <trellis/core_algorithms.h> + +namespace gr { + namespace trellis { + + static const float INF = 1.0e9; + + @BASE_NAME@::sptr + @BASE_NAME@::make(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE, + int D, + const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling) + { + return gnuradio::get_initial_sptr + (new @NAME@(FSMo, STo0, SToK, FSMi, STi0, STiK, + INTERLEAVER, blocklength, repetitions, + SISO_TYPE, D, TABLE,METRIC_TYPE, scaling)); + } + + @IMPL_NAME@::@IMPL_NAME@(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE, + int D, + const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling) + : gr_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(@I_TYPE@)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_FSMo(FSMo), d_STo0(STo0), d_SToK(SToK), + d_FSMi(FSMi), d_STi0(STi0), d_STiK(STiK), + d_INTERLEAVER(INTERLEAVER), + d_blocklength(blocklength), + d_repetitions(repetitions), + d_SISO_TYPE(SISO_TYPE), + d_D(D), + d_TABLE(TABLE), + d_METRIC_TYPE(METRIC_TYPE), + d_scaling(scaling) + { + assert(d_FSMo.I() == d_FSMi.I()); + set_relative_rate (1.0 / ((double) d_D)); + set_output_multiple (d_blocklength); + } + + @IMPL_NAME@::~@IMPL_NAME@() + { + } + + void + @IMPL_NAME@::set_scaling(float scaling) + { + d_scaling = scaling; + } + + void + @IMPL_NAME@::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + int input_required = d_D * noutput_items; + ninput_items_required[0] = input_required; + } + + //=========================================================== + + int + @IMPL_NAME@::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int nblocks = noutput_items / d_blocklength; + + float (*p2min)(float, float) = NULL; + if(d_SISO_TYPE == TRELLIS_MIN_SUM) + p2min = &min; + else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) + p2min = &min_star; + + const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0]; + @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; + for (int n=0;n<nblocks;n++) { + pccc_decoder_combined(d_FSMo, d_STo0, d_SToK, + d_FSMi, d_STi0, d_STiK, + d_INTERLEAVER, d_blocklength, d_repetitions, + p2min, + d_D,d_TABLE, + d_METRIC_TYPE, + d_scaling, + &(in[n*d_blocklength*d_D]), + &(out[n*d_blocklength])); + } + + consume_each(d_D * noutput_items); + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/pccc_decoder_combined_XX_impl.h.t b/gr-trellis/lib/pccc_decoder_combined_XX_impl.h.t new file mode 100644 index 0000000000..4c3655f40d --- /dev/null +++ b/gr-trellis/lib/pccc_decoder_combined_XX_impl.h.t @@ -0,0 +1,93 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/@BASE_NAME@.h> + +namespace gr { + namespace trellis { + + class @IMPL_NAME@ : public @BASE_NAME@ + { + private: + fsm d_FSMo; + int d_STo0; + int d_SToK; + fsm d_FSMi; + int d_STi0; + int d_STiK; + interleaver d_INTERLEAVER; + int d_blocklength; + int d_repetitions; + siso_type_t d_SISO_TYPE; + int d_D; + std::vector<@I_TYPE@> d_TABLE; + digital::trellis_metric_type_t d_METRIC_TYPE; + float d_scaling; + std::vector<float> d_buffer; + + public: + @IMPL_NAME@(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE, + int D, + const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling); + ~@IMPL_NAME@(); + + fsm FSM1() const { return d_FSMo; } + fsm FSM2() const { return d_FSMi; } + int ST10() const { return d_STo0; } + int ST1K() const { return d_SToK; } + int ST20() const { return d_STi0; } + int ST2K() const { return d_STiK; } + interleaver INTERLEAVER() const { return d_INTERLEAVER; } + int blocklength() const { return d_blocklength; } + int repetitions() const { return d_repetitions; } + int D() const { return d_D; } + std::vector<@I_TYPE@> TABLE() const { return d_TABLE; } + digital::trellis_metric_type_t METRIC_TYPE() const { return d_METRIC_TYPE; } + siso_type_t SISO_TYPE() const { return d_SISO_TYPE; } + float scaling() const { return d_scaling; } + void set_scaling(float scaling); + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/lib/pccc_encoder_XX_impl.cc.t b/gr-trellis/lib/pccc_encoder_XX_impl.cc.t new file mode 100644 index 0000000000..4e804729a2 --- /dev/null +++ b/gr-trellis/lib/pccc_encoder_XX_impl.cc.t @@ -0,0 +1,91 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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 "@NAME@.h" +#include <gr_io_signature.h> +#include <iostream> + +namespace gr { + namespace trellis { + + @BASE_NAME@::sptr + @BASE_NAME@::make(const fsm &FSM1, int ST1, + const fsm &FSM2, int ST2, + const interleaver &INTERLEAVER, + int blocklength) + { + return gnuradio::get_initial_sptr + (new @IMPL_NAME@(FSM1, ST1, FSM2, ST2, INTERLEAVER, blocklength)); + } + + @IMPL_NAME@::@IMPL_NAME@(const fsm &FSM1, int ST1, + const fsm &FSM2, int ST2, + const interleaver &INTERLEAVER, + int blocklength) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(@I_TYPE@)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_FSM1(FSM1), d_ST1(ST1), + d_FSM2(FSM2), d_ST2(ST2), + d_INTERLEAVER(INTERLEAVER), + d_blocklength(blocklength) + { + assert(d_FSM1.I() == d_FSM2.I()); + set_output_multiple(d_blocklength); + d_buffer.resize(d_blocklength); + } + + @IMPL_NAME@::~@IMPL_NAME@() + { + } + + int + @NAME@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + for(int b = 0 ; b<noutput_items/d_blocklength; b++) { + const @I_TYPE@ *in = (const @I_TYPE@*)input_items[0]+b*d_blocklength; + @O_TYPE@ *out = (@O_TYPE@*)output_items[0]+b*d_blocklength; + + int ST1_tmp = d_ST1; + int ST2_tmp = d_ST2; + for(int i = 0; i < d_blocklength; i++) { + int k = d_INTERLEAVER.INTER()[i]; + int o1 = d_FSM1.OS()[ST1_tmp*d_FSM1.I()+in[i]]; + ST1_tmp = (int) d_FSM1.NS()[ST1_tmp*d_FSM1.I()+in[i]]; + int o2 = d_FSM2.OS()[ST2_tmp*d_FSM2.I()+in[k]]; + ST2_tmp = (int) d_FSM2.NS()[ST2_tmp*d_FSM2.I()+in[k]]; + out[i] = (@O_TYPE@) (o1*d_FSM1.O() + o2); + } + } + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/pccc_encoder_XX_impl.h.t b/gr-trellis/lib/pccc_encoder_XX_impl.h.t new file mode 100644 index 0000000000..1eed3702be --- /dev/null +++ b/gr-trellis/lib/pccc_encoder_XX_impl.h.t @@ -0,0 +1,66 @@ +/* -*- 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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <trellis/@BASE_NAME@.h> + +namespace gr { + namespace trellis { + + class @IMPL_NAME@ : public @BASE_NAME@ + { + private: + fsm d_FSM1; + int d_ST1; + fsm d_FSM2; + int d_ST2; + interleaver d_INTERLEAVER; + int d_blocklength; + std::vector<int> d_buffer; + + public: + @IMPL_NAME@(const fsm &FSM1, int ST1, + const fsm &FSM2, int ST2, + const interleaver &INTERLEAVER, + int blocklength); + ~@IMPL_NAME@(); + + fsm FSM1() const { return d_FSM1; } + int ST1() const { return d_ST1; } + fsm FSM2() const { return d_FSM2; } + int ST2() const { return d_ST2; } + interleaver INTERLEAVER() const { return d_INTERLEAVER; } + int blocklength() const { return d_blocklength; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/lib/permutation_impl.cc b/gr-trellis/lib/permutation_impl.cc new file mode 100644 index 0000000000..da82e46832 --- /dev/null +++ b/gr-trellis/lib/permutation_impl.cc @@ -0,0 +1,90 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "permutation_impl.h" +#include <gr_io_signature.h> +#include <iostream> +#include <string.h> + +namespace gr { + namespace trellis { + + permutation::sptr + permutation::make(int K, const std::vector<int> &TABLE, + int SYMS_PER_BLOCK, size_t BYTES_PER_SYMBOL) + { + return gnuradio::get_initial_sptr + (new permutation_impl(K,TABLE,SYMS_PER_BLOCK,BYTES_PER_SYMBOL)); + } + + permutation_impl::permutation_impl(int K, const std::vector<int> &TABLE, + int SYMS_PER_BLOCK, size_t BYTES_PER_SYMBOL) + : gr_sync_block("permutation", + gr_make_io_signature(1, -1, BYTES_PER_SYMBOL), + gr_make_io_signature(1, -1, BYTES_PER_SYMBOL)), + d_K(K), d_TABLE(TABLE), + d_SYMS_PER_BLOCK(SYMS_PER_BLOCK), + d_BYTES_PER_SYMBOL(BYTES_PER_SYMBOL) + { + set_output_multiple(d_K*SYMS_PER_BLOCK); + //std::cout << d_K << "\n"; + } + + permutation_impl::~permutation_impl() + { + } + + int + permutation_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int nstreams = input_items.size(); + + for(int m=0;m<nstreams;m++) { + const char *in = (const char *) input_items[m]; + char *out = (char *) output_items[m]; + + // per stream processing + for(int i = 0; i < noutput_items/d_SYMS_PER_BLOCK; i++) { + // Index i refers to blocks. + // Begining of packet (in blocks) + int i0 = d_K*(i/d_K); + // position of block within packet (in blocks) + int j0 = i%d_K; + // new position of block within packet (in blocks) + int k0 = d_TABLE[j0]; + memcpy(&(out[i*d_SYMS_PER_BLOCK*d_BYTES_PER_SYMBOL]), + &(in[(i0+k0)*d_SYMS_PER_BLOCK*d_BYTES_PER_SYMBOL]), + d_BYTES_PER_SYMBOL*d_SYMS_PER_BLOCK); + } + // end per stream processing + } + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/permutation_impl.h b/gr-trellis/lib/permutation_impl.h new file mode 100644 index 0000000000..6e3ca2b2d7 --- /dev/null +++ b/gr-trellis/lib/permutation_impl.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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_TRELLIS_PERMUTATION_IMPL_H +#define INCLUDED_TRELLIS_PERMUTATION_IMPL_H + +#include <trellis/api.h> +#include <trellis/permutation.h> + +namespace gr { + namespace trellis { + + class permutation_impl : public permutation + { + private: + int d_K; + std::vector<int> d_TABLE; + int d_SYMS_PER_BLOCK; + size_t d_BYTES_PER_SYMBOL; + + public: + permutation_impl(int K, const std::vector<int> &TABLE, + int SYMS_PER_BLOCK, size_t NBYTES); + ~permutation_impl(); + + int K() const { return d_K; } + const std::vector<int> & TABLE() const { return d_TABLE; } + int SYMS_PER_BLOCK() const { return d_SYMS_PER_BLOCK; } + size_t BYTES_PER_SYMBOL() const { return d_BYTES_PER_SYMBOL; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* INCLUDED_TRELLIS_PERMUTATION_IMPL_H */ diff --git a/gr-trellis/lib/quicksort_index.cc b/gr-trellis/lib/quicksort_index.cc new file mode 100644 index 0000000000..02cd8a9134 --- /dev/null +++ b/gr-trellis/lib/quicksort_index.cc @@ -0,0 +1,70 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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. + */ + +#include <trellis/quicksort_index.h> + +namespace gr { + namespace trellis { + + template <class T> void + SWAP(T & a, T & b) + { + T temp = a; + a = b; + b = temp; + } + + template <class T> void + quicksort_index (std::vector<T> & p, std::vector<int> & index, + int left, int right) + { + if(left < right) { + int i = left; + int j = right + 1; + T pivot = p[left]; + do { + do + i++; + while ((p[i] < pivot) && (i < right)); + do + j--; + while ((p[j] > pivot) && (j > left)); + if (i < j) { + SWAP <T> (p[i],p[j]); + SWAP <int> (index[i],index[j]); + } + } while (i < j); + SWAP <T> (p[left], p[j]); + SWAP <int> (index[left], index[j]); + quicksort_index <T> (p,index, left, j-1); + quicksort_index <T> (p,index, j+1, right); + } + } + + // instantiate an <int> version of the quicksort_index + //template <int> void SWAP (int & a, int & b); + template void + quicksort_index<int>(std::vector<int> & p, std::vector<int> & index, + int left, int right); + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/sccc_decoder_X_impl.cc.t b/gr-trellis/lib/sccc_decoder_X_impl.cc.t new file mode 100644 index 0000000000..6eef46518d --- /dev/null +++ b/gr-trellis/lib/sccc_decoder_X_impl.cc.t @@ -0,0 +1,118 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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 "@NAME@.h" +#include <gr_io_signature.h> +#include <iostream> +#include <trellis/core_algorithms.h> + +namespace gr { + namespace trellis { + + static const float INF = 1.0e9; + + @BASE_NAME@::sptr + @BASE_NAME@::make(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE) + { + return gnuradio::get_initial_sptr + (new @IMPL_NAME@(FSMo, STo0, SToK, FSMi, STi0, STiK, + INTERLEAVER, blocklength, repetitions, + SISO_TYPE)); + } + + @IMPL_NAME@::@IMPL_NAME@(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE) + : gr_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(float)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_FSMo(FSMo), d_STo0(STo0), d_SToK(SToK), + d_FSMi(FSMi), d_STi0(STi0), d_STiK(STiK), + d_INTERLEAVER(INTERLEAVER), + d_blocklength(blocklength), + d_repetitions(repetitions), + d_SISO_TYPE(SISO_TYPE) + { + set_relative_rate(1.0 / ((double) d_FSMi.O())); + set_output_multiple(d_blocklength); + } + + @IMPL_NAME@::~@IMPL_NAME@() + { + } + + void + @IMPL_NAME@::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + int input_required = d_FSMi.O() * noutput_items ; + ninput_items_required[0] = input_required; + } + + //=========================================================== + + int + @IMPL_NAME@::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int nblocks = noutput_items / d_blocklength; + float (*p2min)(float, float) = NULL; + + if(d_SISO_TYPE == TRELLIS_MIN_SUM) + p2min = &min; + else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) + p2min = &min_star; + + const float *in = (const float*)input_items[0]; + @O_TYPE@ *out = (@O_TYPE@*)output_items[0]; + + for(int n = 0; n < nblocks; n++) { + sccc_decoder(d_FSMo, d_STo0, d_SToK, + d_FSMi, d_STi0, d_STiK, + d_INTERLEAVER, d_blocklength, d_repetitions, + p2min, + &(in[n*d_blocklength*d_FSMi.O()]), + &(out[n*d_blocklength])); + } + + consume_each(d_FSMi.O() * noutput_items ); + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/sccc_decoder_X_impl.h.t b/gr-trellis/lib/sccc_decoder_X_impl.h.t new file mode 100644 index 0000000000..31f4edc4b8 --- /dev/null +++ b/gr-trellis/lib/sccc_decoder_X_impl.h.t @@ -0,0 +1,80 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/@BASE_NAME@.h> + +namespace gr { + namespace trellis { + + class @IMPL_NAME@ : public @BASE_NAME@ + { + private: + fsm d_FSMo; + int d_STo0; + int d_SToK; + fsm d_FSMi; + int d_STi0; + int d_STiK; + interleaver d_INTERLEAVER; + int d_blocklength; + int d_repetitions; + siso_type_t d_SISO_TYPE; + std::vector<float> d_buffer; + + public: + @IMPL_NAME@(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE); + ~@IMPL_NAME@(); + + fsm FSMo() const { return d_FSMo; } + fsm FSMi() const { return d_FSMi; } + int STo0() const { return d_STo0; } + int SToK() const { return d_SToK; } + int STi0() const { return d_STi0; } + int STiK() const { return d_STiK; } + interleaver INTERLEAVER() const { return d_INTERLEAVER; } + int blocklength() const { return d_blocklength; } + int repetitions() const { return d_repetitions; } + siso_type_t SISO_TYPE() const { return d_SISO_TYPE; } + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/lib/sccc_decoder_combined_XX_impl.cc.t b/gr-trellis/lib/sccc_decoder_combined_XX_impl.cc.t new file mode 100644 index 0000000000..717f2c8e49 --- /dev/null +++ b/gr-trellis/lib/sccc_decoder_combined_XX_impl.cc.t @@ -0,0 +1,139 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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 "@NAME@.h" +#include <gr_io_signature.h> +#include <iostream> +#include <trellis/core_algorithms.h> + +namespace gr { + namespace trellis { + + static const float INF = 1.0e9; + + @BASE_NAME@::sptr + @BASE_NAME@::make(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE, + int D, + const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling) + { + return gnuradio::get_initial_sptr + (new @IMPL_NAME@(FSMo, STo0, SToK, FSMi, STi0, STiK, + INTERLEAVER, blocklength, repetitions, + SISO_TYPE, D, TABLE,METRIC_TYPE, scaling)); + } + + @IMPL_NAME@::@IMPL_NAME@(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE, + int D, + const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling) + : gr_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(@I_TYPE@)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_FSMo(FSMo), d_STo0(STo0), d_SToK(SToK), + d_FSMi(FSMi), d_STi0(STi0), d_STiK(STiK), + d_INTERLEAVER(INTERLEAVER), + d_blocklength(blocklength), + d_repetitions(repetitions), + d_SISO_TYPE(SISO_TYPE), + d_D(D), + d_TABLE(TABLE), + d_METRIC_TYPE(METRIC_TYPE), + d_scaling(scaling) + { + set_relative_rate(1.0 / ((double) d_D)); + set_output_multiple(d_blocklength); + } + + @IMPL_NAME@::~@IMPL_NAME@() + { + } + + void + @IMPL_NAME@::set_scaling(float scaling) + { + d_scaling = scaling; + } + + void + @IMPL_NAME@::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + int input_required = d_D * noutput_items ; + ninput_items_required[0] = input_required; + } + + //=========================================================== + + int + @IMPL_NAME@::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int nblocks = noutput_items / d_blocklength; + float (*p2min)(float, float) = NULL; + + if(d_SISO_TYPE == TRELLIS_MIN_SUM) + p2min = &min; + else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) + p2min = &min_star; + + const @I_TYPE@ *in = (const @I_TYPE@*)input_items[0]; + @O_TYPE@ *out = (@O_TYPE@*)output_items[0]; + + for(int n = 0; n < nblocks; n++) { + sccc_decoder_combined(d_FSMo, d_STo0, d_SToK, + d_FSMi, d_STi0, d_STiK, + d_INTERLEAVER, d_blocklength, d_repetitions, + p2min, + d_D,d_TABLE, + d_METRIC_TYPE, + d_scaling, + &(in[n*d_blocklength*d_D]), + &(out[n*d_blocklength])); + } + + consume_each(d_D * noutput_items); + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/sccc_decoder_combined_XX_impl.h.t b/gr-trellis/lib/sccc_decoder_combined_XX_impl.h.t new file mode 100644 index 0000000000..f3dbd1b4bb --- /dev/null +++ b/gr-trellis/lib/sccc_decoder_combined_XX_impl.h.t @@ -0,0 +1,93 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/@BASE_NAME@.h> + +namespace gr { + namespace trellis { + + class @IMPL_NAME@ : public @BASE_NAME@ + { + private: + fsm d_FSMo; + int d_STo0; + int d_SToK; + fsm d_FSMi; + int d_STi0; + int d_STiK; + interleaver d_INTERLEAVER; + int d_blocklength; + int d_repetitions; + siso_type_t d_SISO_TYPE; + int d_D; + std::vector<@I_TYPE@> d_TABLE; + digital::trellis_metric_type_t d_METRIC_TYPE; + float d_scaling; + std::vector<float> d_buffer; + + public: + @IMPL_NAME@(const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + siso_type_t SISO_TYPE, + int D, + const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t METRIC_TYPE, + float scaling); + ~@IMPL_NAME@(); + + fsm FSMo() const { return d_FSMo; } + fsm FSMi() const { return d_FSMi; } + int STo0() const { return d_STo0; } + int SToK() const { return d_SToK; } + int STi0() const { return d_STi0; } + int STiK() const { return d_STiK; } + interleaver INTERLEAVER() const { return d_INTERLEAVER; } + int blocklength() const { return d_blocklength; } + int repetitions() const { return d_repetitions; } + int D() const { return d_D; } + std::vector<@I_TYPE@> TABLE() const { return d_TABLE; } + digital::trellis_metric_type_t METRIC_TYPE() const { return d_METRIC_TYPE; } + siso_type_t SISO_TYPE() const { return d_SISO_TYPE; } + float scaling() const { return d_scaling; } + void set_scaling(float scaling); + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/lib/sccc_encoder_XX_impl.cc.t b/gr-trellis/lib/sccc_encoder_XX_impl.cc.t new file mode 100644 index 0000000000..390e65c4f3 --- /dev/null +++ b/gr-trellis/lib/sccc_encoder_XX_impl.cc.t @@ -0,0 +1,93 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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 "@NAME@.h" +#include <gr_io_signature.h> +#include <iostream> + +namespace gr { + namespace trellis { + + @BASE_NAME@::sptr + @BASE_NAME@::make(const fsm &FSMo, int STo, + const fsm &FSMi, int STi, + const interleaver &INTERLEAVER, + int blocklength) + { + return gnuradio::get_initial_sptr + (new @IMPL_NAME@(FSMo, STo, FSMi, STi, INTERLEAVER, blocklength)); + } + + @IMPL_NAME@::@IMPL_NAME@(const fsm &FSMo, int STo, + const fsm &FSMi, int STi, + const interleaver &INTERLEAVER, + int blocklength) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(@I_TYPE@)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_FSMo(FSMo), d_STo(STo), + d_FSMi(FSMi), d_STi(STi), + d_INTERLEAVER(INTERLEAVER), + d_blocklength(blocklength) + { + set_output_multiple(d_blocklength); + d_buffer.resize(d_blocklength); + } + + @IMPL_NAME@::~@IMPL_NAME@() + { + } + + int + @IMPL_NAME@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + for(int b = 0; b < noutput_items/d_blocklength; b++) { + const @I_TYPE@ *in = (const @I_TYPE@*)input_items[0]+b*d_blocklength; + @O_TYPE@ *out = (@O_TYPE@*)output_items[0]+b*d_blocklength; + + int STo_tmp = d_STo; + for(int i = 0; i < d_blocklength; i++) { + d_buffer[i] = d_FSMo.OS()[STo_tmp*d_FSMo.I()+in[i]]; + STo_tmp = (int) d_FSMo.NS()[STo_tmp*d_FSMo.I()+in[i]]; + } + + int STi_tmp = d_STi; + for(int i = 0; i < d_blocklength; i++) { + int k = d_INTERLEAVER.INTER()[i]; + out[i] = (@O_TYPE@) d_FSMi.OS()[STi_tmp*d_FSMi.I()+d_buffer[k]]; + STi_tmp = (int) d_FSMi.NS()[STi_tmp*d_FSMi.I()+d_buffer[k]]; + } + } + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ + diff --git a/gr-trellis/lib/sccc_encoder_XX_impl.h.t b/gr-trellis/lib/sccc_encoder_XX_impl.h.t new file mode 100644 index 0000000000..a3e582b5a0 --- /dev/null +++ b/gr-trellis/lib/sccc_encoder_XX_impl.h.t @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/@BASE_NAME@.h> + +namespace gr { + namespace trellis { + + class @IMPL_NAME@ : public @BASE_NAME@ + { + private: + fsm d_FSMo; + int d_STo; + fsm d_FSMi; + int d_STi; + interleaver d_INTERLEAVER; + int d_blocklength; + std::vector<int> d_buffer; + + public: + @IMPL_NAME@(const fsm &FSMo, int STo, + const fsm &FSMi, int STi, + const interleaver &INTERLEAVER, + int blocklength); + ~@IMPL_NAME@(); + + fsm FSMo() const { return d_FSMo; } + int STo() const { return d_STo; } + fsm FSMi() const { return d_FSMi; } + int STi() const { return d_STi; } + interleaver INTERLEAVER() const { return d_INTERLEAVER; } + int blocklength() const { return d_blocklength; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/lib/siso_combined_f_impl.cc b/gr-trellis/lib/siso_combined_f_impl.cc new file mode 100644 index 0000000000..7514d46747 --- /dev/null +++ b/gr-trellis/lib/siso_combined_f_impl.cc @@ -0,0 +1,180 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "siso_combined_f_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> +#include <assert.h> +#include <iostream> + +namespace gr { + namespace trellis { + + static const float INF = 1.0e9; + + siso_combined_f::sptr + siso_combined_f::make(const fsm &FSM, int K, + int S0, int SK, + bool POSTI, bool POSTO, + siso_type_t SISO_TYPE, + int D, const std::vector<float> &TABLE, + digital::trellis_metric_type_t TYPE) + { + return gnuradio::get_initial_sptr + (new siso_combined_f_impl(FSM, K, S0, SK, POSTI, POSTO, + SISO_TYPE, D, TABLE, TYPE)); + } + + siso_combined_f_impl::siso_combined_f_impl(const fsm &FSM, int K, + int S0, int SK, + bool POSTI, bool POSTO, + siso_type_t SISO_TYPE, + int D, const std::vector<float> &TABLE, + digital::trellis_metric_type_t TYPE) + : gr_block("siso_combined_f", + gr_make_io_signature(1, -1, sizeof(float)), + gr_make_io_signature(1, -1, sizeof(float))), + d_FSM(FSM), d_K(K), d_S0(S0), d_SK(SK), + d_POSTI(POSTI), d_POSTO(POSTO), + d_SISO_TYPE(SISO_TYPE), + d_D(D), d_TABLE(TABLE), d_TYPE(TYPE)//, + //d_alpha(FSM.S()*(K+1)), + //d_beta(FSM.S()*(K+1)) + { + int multiple; + if(d_POSTI && d_POSTO) + multiple = d_FSM.I()+d_FSM.O(); + else if(d_POSTI) + multiple = d_FSM.I(); + else if(d_POSTO) + multiple = d_FSM.O(); + else + throw std::runtime_error ("Not both POSTI and POSTO can be false."); + + //printf("constructor: Multiple = %d\n",multiple); + set_output_multiple(d_K*multiple); + + //what is the meaning of relative rate for a block with 2 inputs? + //set_relative_rate ( multiple / ((double) d_FSM.I()) ); + // it turns out that the above gives problems in the scheduler, so + // let's try (assumption O>I) + //set_relative_rate ( multiple / ((double) d_FSM.O()) ); + // I am tempted to automate like this + if(d_FSM.I() <= d_D) + set_relative_rate(multiple / ((double)d_D)); + else + set_relative_rate(multiple / ((double)d_FSM.I())); + } + + siso_combined_f_impl::~siso_combined_f_impl() + { + } + + void + siso_combined_f_impl::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + int multiple; + if(d_POSTI && d_POSTO) + multiple = d_FSM.I()+d_FSM.O(); + else if(d_POSTI) + multiple = d_FSM.I(); + else if(d_POSTO) + multiple = d_FSM.O(); + else + throw std::runtime_error ("Not both POSTI and POSTO can be false."); + + //printf("forecast: Multiple = %d\n",multiple); + int input_required1 = d_FSM.I() * (noutput_items/multiple) ; + int input_required2 = d_D * (noutput_items/multiple) ; + //printf("forecast: Output requirements: %d\n",noutput_items); + //printf("forecast: Input requirements: %d %d\n",input_required1,input_required2); + unsigned ninputs = ninput_items_required.size(); + + for(unsigned int i = 0; i < ninputs/2; i++) { + ninput_items_required[2*i] = input_required1; + ninput_items_required[2*i+1] = input_required2; + } + } + + int + siso_combined_f_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int nstreams = output_items.size(); + //printf("general_work:Streams: %d\n",nstreams); + + int multiple; + if(d_POSTI && d_POSTO) + multiple = d_FSM.I()+d_FSM.O(); + else if(d_POSTI) + multiple = d_FSM.I(); + else if(d_POSTO) + multiple = d_FSM.O(); + else + throw std::runtime_error("siso_combined_f_impl:: Not both POSTI and POSTO can be false."); + + int nblocks = noutput_items / (d_K*multiple); + //printf("general_work:Blocks: %d\n",nblocks); + //for(int i=0;i<ninput_items.size();i++) + //printf("general_work:Input items available: %d\n",ninput_items[i]); + + float (*p2min)(float, float) = NULL; + if(d_SISO_TYPE == TRELLIS_MIN_SUM) + p2min = &min; + else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) + p2min = &min_star; + + for(int m=0;m<nstreams;m++) { + const float *in1 = (const float*)input_items[2*m]; + const float *in2 = (const float*)input_items[2*m+1]; + float *out = (float *) output_items[m]; + for(int n=0;n<nblocks;n++) { + siso_algorithm_combined(d_FSM.I(),d_FSM.S(),d_FSM.O(), + d_FSM.NS(),d_FSM.OS(),d_FSM.PS(),d_FSM.PI(), + d_K,d_S0,d_SK, + d_POSTI,d_POSTO, + p2min, + d_D,d_TABLE,d_TYPE, + &(in1[n*d_K*d_FSM.I()]),&(in2[n*d_K*d_D]), + &(out[n*d_K*multiple])//, + //d_alpha,d_beta + ); + } + } + + for(unsigned int i = 0; i < input_items.size()/2; i++) { + consume(2*i,d_FSM.I() * noutput_items / multiple ); + consume(2*i+1,d_D * noutput_items / multiple ); + } + + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/siso_combined_f_impl.h b/gr-trellis/lib/siso_combined_f_impl.h new file mode 100644 index 0000000000..27cef5e334 --- /dev/null +++ b/gr-trellis/lib/siso_combined_f_impl.h @@ -0,0 +1,79 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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_TRELLIS_SISO_COMBINED_F_IMPL_H +#define INCLUDED_TRELLIS_SISO_COMBINED_F_IMPL_H + +#include <trellis/siso_combined_f.h> + +namespace gr { + namespace trellis { + + class siso_combined_f_impl : public siso_combined_f + { + private: + fsm d_FSM; + int d_K; + int d_S0; + int d_SK; + bool d_POSTI; + bool d_POSTO; + siso_type_t d_SISO_TYPE; + int d_D; + std::vector<float> d_TABLE; + digital::trellis_metric_type_t d_TYPE; + //std::vector<float> d_alpha; + //std::vector<float> d_beta; + + public: + siso_combined_f_impl(const fsm &FSM, int K, + int S0, int SK, + bool POSTI, bool POSTO, + siso_type_t d_SISO_TYPE, + int D, const std::vector<float> &TABLE, + digital::trellis_metric_type_t TYPE); + ~siso_combined_f_impl(); + + fsm FSM() const { return d_FSM; } + int K() const { return d_K; } + int S0() const { return d_S0; } + int SK() const { return d_SK; } + bool POSTI() const { return d_POSTI; } + bool POSTO() const { return d_POSTO; } + siso_type_t SISO_TYPE() const { return d_SISO_TYPE; } + int D() const { return d_D; } + std::vector<float> TABLE() const { return d_TABLE; } + digital::trellis_metric_type_t TYPE() const { return d_TYPE; } + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* INCLUDED_TRELLIS_SISO_COMBINED_F_IMPL_H */ diff --git a/gr-trellis/lib/siso_f_impl.cc b/gr-trellis/lib/siso_f_impl.cc new file mode 100644 index 0000000000..b0484f6f37 --- /dev/null +++ b/gr-trellis/lib/siso_f_impl.cc @@ -0,0 +1,171 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "siso_f_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> +#include <assert.h> +#include <iostream> + +namespace gr { + namespace trellis { + + static const float INF = 1.0e9; + + siso_f::sptr + siso_f::make(const fsm &FSM, int K, + int S0, int SK, + bool POSTI, bool POSTO, + siso_type_t SISO_TYPE) + { + return gnuradio::get_initial_sptr + (new siso_f_impl(FSM, K, S0, SK, POSTI, POSTO, SISO_TYPE)); + } + + siso_f_impl::siso_f_impl(const fsm &FSM, int K, + int S0, int SK, + bool POSTI, bool POSTO, + siso_type_t SISO_TYPE) + : gr_block("siso_f", + gr_make_io_signature(1, -1, sizeof(float)), + gr_make_io_signature(1, -1, sizeof(float))), + d_FSM(FSM), d_K(K), + d_S0(S0),d_SK(SK), + d_POSTI(POSTI), d_POSTO(POSTO), + d_SISO_TYPE(SISO_TYPE)//, + //d_alpha(FSM.S()*(K+1)), + //d_beta(FSM.S()*(K+1)) + { + int multiple; + if(d_POSTI && d_POSTO) + multiple = d_FSM.I()+d_FSM.O(); + else if(d_POSTI) + multiple = d_FSM.I(); + else if(d_POSTO) + multiple = d_FSM.O(); + else + throw std::runtime_error ("Not both POSTI and POSTO can be false."); + + //printf("constructor: Multiple = %d\n",multiple); + set_output_multiple (d_K*multiple); + + //what is the meaning of relative rate for a block with 2 inputs? + //set_relative_rate ( multiple / ((double) d_FSM.I()) ); + // it turns out that the above gives problems in the scheduler, so + // let's try (assumption O>I) + //set_relative_rate ( multiple / ((double) d_FSM.O()) ); + // I am tempted to automate like this + if(d_FSM.I() <= d_FSM.O()) + set_relative_rate(multiple / ((double) d_FSM.O())); + else + set_relative_rate(multiple / ((double) d_FSM.I())); + } + + siso_f_impl::~siso_f_impl() + { + } + + void + siso_f_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required) + { + int multiple; + if(d_POSTI && d_POSTO) + multiple = d_FSM.I()+d_FSM.O(); + else if(d_POSTI) + multiple = d_FSM.I(); + else if(d_POSTO) + multiple = d_FSM.O(); + else + throw std::runtime_error ("Not both POSTI and POSTO can be false."); + + //printf("forecast: Multiple = %d\n",multiple); + int input_required1 = d_FSM.I() * (noutput_items/multiple) ; + int input_required2 = d_FSM.O() * (noutput_items/multiple) ; + //printf("forecast: Output requirements: %d\n",noutput_items); + //printf("forecast: Input requirements: %d %d\n",input_required1,input_required2); + unsigned ninputs = ninput_items_required.size(); + for(unsigned int i = 0; i < ninputs/2; i++) { + ninput_items_required[2*i] = input_required1; + ninput_items_required[2*i+1] = input_required2; + } + } + + int + siso_f_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int nstreams = output_items.size(); + //printf("general_work:Streams: %d\n",nstreams); + int multiple; + if(d_POSTI && d_POSTO) + multiple = d_FSM.I()+d_FSM.O(); + else if(d_POSTI) + multiple = d_FSM.I(); + else if(d_POSTO) + multiple = d_FSM.O(); + else + throw std::runtime_error("siso_f_impl: Not both POSTI and POSTO can be false.\n"); + + int nblocks = noutput_items / (d_K*multiple); + //printf("general_work:Blocks: %d\n",nblocks); + //for(int i=0;i<ninput_items.size();i++) + //printf("general_work:Input items available: %d\n",ninput_items[i]); + + float (*p2min)(float, float) = NULL; + if(d_SISO_TYPE == TRELLIS_MIN_SUM) + p2min = &min; + else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) + p2min = &min_star; + + for(int m = 0; m < nstreams; m++) { + const float *in1 = (const float*)input_items[2*m]; + const float *in2 = (const float*)input_items[2*m+1]; + float *out = (float*)output_items[m]; + for(int n = 0;n < nblocks; n++) { + siso_algorithm(d_FSM.I(),d_FSM.S(),d_FSM.O(), + d_FSM.NS(),d_FSM.OS(),d_FSM.PS(),d_FSM.PI(), + d_K,d_S0,d_SK, + d_POSTI,d_POSTO, + p2min, + &(in1[n*d_K*d_FSM.I()]),&(in2[n*d_K*d_FSM.O()]), + &(out[n*d_K*multiple])//, + //d_alpha,d_beta + ); + } + } + + for(unsigned int i = 0; i < input_items.size()/2; i++) { + consume(2*i,d_FSM.I() * noutput_items / multiple ); + consume(2*i+1,d_FSM.O() * noutput_items / multiple ); + } + + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/siso_f_impl.h b/gr-trellis/lib/siso_f_impl.h new file mode 100644 index 0000000000..40766b97fa --- /dev/null +++ b/gr-trellis/lib/siso_f_impl.h @@ -0,0 +1,75 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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_TRELLIS_SISO_F_IMPL_H +#define INCLUDED_TRELLIS_SISO_F_IMPL_H + +#include <trellis/api.h> +#include <trellis/fsm.h> +#include <trellis/siso_type.h> +#include <trellis/core_algorithms.h> +#include <trellis/siso_f.h> + +namespace gr { + namespace trellis { + + class siso_f_impl : public siso_f + { + private: + fsm d_FSM; + int d_K; + int d_S0; + int d_SK; + bool d_POSTI; + bool d_POSTO; + siso_type_t d_SISO_TYPE; + //std::vector<float> d_alpha; + //std::vector<float> d_beta; + + public: + siso_f_impl(const fsm &FSM, int K, + int S0, int SK, + bool POSTI, bool POSTO, + siso_type_t d_SISO_TYPE); + ~siso_f_impl(); + + fsm FSM() const { return d_FSM; } + int K() const { return d_K; } + int S0() const { return d_S0; } + int SK() const { return d_SK; } + bool POSTI() const { return d_POSTI; } + bool POSTO() const { return d_POSTO; } + siso_type_t SISO_TYPE() const { return d_SISO_TYPE; } + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* INCLUDED_TRELLIS_SISO_F_IMPL_H */ diff --git a/gr-trellis/lib/viterbi_X_impl.cc.t b/gr-trellis/lib/viterbi_X_impl.cc.t new file mode 100644 index 0000000000..5097cc2053 --- /dev/null +++ b/gr-trellis/lib/viterbi_X_impl.cc.t @@ -0,0 +1,99 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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 "@NAME@.h" +#include <gr_io_signature.h> +#include <iostream> + +namespace gr { + namespace trellis { + + static const float INF = 1.0e9; + + @BASE_NAME@::sptr + @BASE_NAME@::make(const fsm &FSM, int K, + int S0, int SK) + { + return gnuradio::get_initial_sptr + (new @IMPL_NAME@(FSM, K, S0, SK)); + } + + @IMPL_NAME@::@IMPL_NAME@(const fsm &FSM, int K, + int S0, int SK) + : gr_block("@BASE_NAME@", + gr_make_io_signature(1, -1, sizeof(float)), + gr_make_io_signature(1, -1, sizeof(@TYPE@))), + d_FSM(FSM), d_K(K), d_S0(S0), d_SK(SK)//, + //d_trace(FSM.S()*K) + { + set_relative_rate(1.0 / ((double)d_FSM.O())); + set_output_multiple(d_K); + } + + @IMPL_NAME@::~@IMPL_NAME@() + { + } + + void + @IMPL_NAME@::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + int input_required = d_FSM.O() * noutput_items; + unsigned ninputs = ninput_items_required.size(); + for(unsigned int i = 0; i < ninputs; i++) { + ninput_items_required[i] = input_required; + } + } + + int + @IMPL_NAME@::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int nstreams = input_items.size(); + int nblocks = noutput_items / d_K; + + for(int m = 0; m < nstreams; m++) { + const float *in = (const float*)input_items[m]; + @TYPE@ *out = (@TYPE@*)output_items[m]; + + for(int n = 0; n < nblocks; n++) { + viterbi_algorithm(d_FSM.I(), d_FSM.S(), d_FSM.O(), + d_FSM.NS(), d_FSM.OS(), d_FSM.PS(), + d_FSM.PI(), d_K,d_S0, d_SK, + &(in[n*d_K*d_FSM.O()]), &(out[n*d_K])); + } + } + + consume_each(d_FSM.O() * noutput_items); + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/viterbi_X_impl.h.t b/gr-trellis/lib/viterbi_X_impl.h.t new file mode 100644 index 0000000000..accaacc158 --- /dev/null +++ b/gr-trellis/lib/viterbi_X_impl.h.t @@ -0,0 +1,65 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/@BASE_NAME@.h> + +namespace gr { + namespace trellis { + + class @IMPL_NAME@ : public @BASE_NAME@ + { + private: + fsm d_FSM; + int d_K; + int d_S0; + int d_SK; + //std::vector<int> d_trace; + + public: + @IMPL_NAME@(const fsm &FSM, int K, + int S0, int SK); + ~@IMPL_NAME@(); + + fsm FSM() const { return d_FSM; } + int K() const { return d_K; } + int S0() const { return d_S0; } + int SK() const { return d_SK; } + + //std::vector<int> trace () const { return d_trace; } + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/lib/viterbi_combined_XX_impl.cc.t b/gr-trellis/lib/viterbi_combined_XX_impl.cc.t new file mode 100644 index 0000000000..95175bef95 --- /dev/null +++ b/gr-trellis/lib/viterbi_combined_XX_impl.cc.t @@ -0,0 +1,112 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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 "@NAME@.h" +#include <gr_io_signature.h> +#include <iostream> + +namespace gr { + namespace trellis { + + static const float INF = 1.0e9; + + @BASE_NAME@::sptr + @BASE_NAME@::make(const fsm &FSM, int K, + int S0, int SK, int D, + const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t TYPE) + { + return gnuradio::get_initial_sptr + (new @NAME@(FSM, K, S0, SK, D, TABLE,TYPE)); + } + + @IMPL_NAME@::@IMPL_NAME@(const fsm &FSM, int K, + int S0, int SK, int D, + const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t TYPE) + : gr_block("@BASE_NAME@", + gr_make_io_signature(1, -1, sizeof(@I_TYPE@)), + gr_make_io_signature(1, -1, sizeof(@O_TYPE@))), + d_FSM(FSM), d_K(K), d_S0(S0), d_SK(SK), d_D(D), + d_TABLE(TABLE), d_TYPE(TYPE)//, + //d_trace(FSM.S()*K) + { + set_relative_rate(1.0 / ((double)d_D)); + set_output_multiple(d_K); + } + + @IMPL_NAME@::~@IMPL_NAME@() + { + } + + void + @IMPL_NAME@::set_TABLE(const std::vector<@I_TYPE@> &table) + { + d_TABLE = table; + } + + void + @IMPL_NAME@::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + int input_required = d_D * noutput_items; + unsigned ninputs = ninput_items_required.size(); + for(unsigned int i = 0; i < ninputs; i++) { + ninput_items_required[i] = input_required; + } + } + + int + @IMPL_NAME@::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int nstreams = input_items.size(); + int nblocks = noutput_items / d_K; + + for(int m=0;m<nstreams;m++) { + const @I_TYPE@ *in = (const @I_TYPE@*)input_items[m]; + @O_TYPE@ *out = (@O_TYPE@*)output_items[m]; + + for(int n=0;n<nblocks;n++) { + viterbi_algorithm_combined(d_FSM.I(), d_FSM.S(), d_FSM.O(), + d_FSM.NS(), d_FSM.OS(), d_FSM.PS(), + d_FSM.PI(), d_K,d_S0, d_SK, d_D, + d_TABLE, d_TYPE, + &(in[n*d_K*d_D]), &(out[n*d_K])); + } + } + + consume_each(d_D * noutput_items); + return noutput_items; + } + + } /* namespace trellis */ +} /* namespace gr */ + diff --git a/gr-trellis/lib/viterbi_combined_XX_impl.h.t b/gr-trellis/lib/viterbi_combined_XX_impl.h.t new file mode 100644 index 0000000000..df62001110 --- /dev/null +++ b/gr-trellis/lib/viterbi_combined_XX_impl.h.t @@ -0,0 +1,74 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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 <trellis/@BASE_NAME@.h> + +namespace gr { + namespace trellis { + + class @IMPL_NAME@ : public @BASE_NAME@ + { + private: + fsm d_FSM; + int d_K; + int d_S0; + int d_SK; + int d_D; + std::vector<@I_TYPE@> d_TABLE; + digital::trellis_metric_type_t d_TYPE; + //std::vector<int> d_trace; + + public: + @IMPL_NAME@(const fsm &FSM, int K, + int S0, int SK, int D, + const std::vector<@I_TYPE@> &TABLE, + digital::trellis_metric_type_t TYPE); + ~@IMPL_NAME@(); + + fsm FSM() const { return d_FSM; } + int K() const { return d_K; } + int S0() const { return d_S0; } + int SK() const { return d_SK; } + int D() const { return d_D; } + std::vector<@I_TYPE@> TABLE() const { return d_TABLE; } + digital::trellis_metric_type_t TYPE() const { return d_TYPE; } + //std::vector<int> trace() const { return d_trace; } + void set_TABLE(const std::vector<@I_TYPE@> &table); + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace trellis */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-trellis/python/CMakeLists.txt b/gr-trellis/python/CMakeLists.txt new file mode 100644 index 0000000000..a166764fbe --- /dev/null +++ b/gr-trellis/python/CMakeLists.txt @@ -0,0 +1,57 @@ +# Copyright 2011-2012 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. + +######################################################################## +# Setup python install +######################################################################## +include(GrPython) + +GR_PYTHON_INSTALL( + FILES + __init__.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio/trellis + COMPONENT "trellis_python" +) + +######################################################################## +# Handle the unit tests +######################################################################## +if(ENABLE_TESTING) + +list(APPEND GR_TEST_PYTHON_DIRS + ${CMAKE_BINARY_DIR}/gr-trellis/python + ${CMAKE_BINARY_DIR}/gr-trellis/swig + ${CMAKE_BINARY_DIR}/gr-blocks/python + ${CMAKE_BINARY_DIR}/gr-blocks/swig + ${CMAKE_BINARY_DIR}/gr-filter/python + ${CMAKE_BINARY_DIR}/gr-filter/swig + ${CMAKE_BINARY_DIR}/gr-analog/python + ${CMAKE_BINARY_DIR}/gr-analog/swig + ${CMAKE_BINARY_DIR}/gr-digital/python + ${CMAKE_BINARY_DIR}/gr-digital/swig +) +list(APPEND GR_TEST_TARGET_DEPS gnuradio-trellis gnuradio-digital gnuradio-analog gnuradio-filter) + +include(GrTest) +file(GLOB py_qa_test_files "qa_*.py") +foreach(py_qa_test_file ${py_qa_test_files}) + get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE) + GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file}) +endforeach(py_qa_test_file) +endif(ENABLE_TESTING) diff --git a/gr-trellis/src/lib/generate_all.py b/gr-trellis/python/__init__.py index 78e36270cc..a1792bc9b4 100644 --- a/gr-trellis/src/lib/generate_all.py +++ b/gr-trellis/python/__init__.py @@ -1,32 +1,27 @@ -#!/usr/bin/env python -# -# Copyright 2006,2007 Free Software Foundation, Inc. -# +# Copyright 2012 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 build_utils import output_glue +''' +Blocks and utilities for trellis coding and related. +''' -import generate_trellis +# The presence of this file turns this directory into a Python package -def generate_all (): - generate_trellis.generate () - output_glue ('trellis') - -if __name__ == '__main__': - generate_all () +from trellis_swig import * diff --git a/gr-trellis/src/python/awgn1o2_4.fsm b/gr-trellis/python/awgn1o2_4.fsm index 9245c69ac1..9245c69ac1 100644 --- a/gr-trellis/src/python/awgn1o2_4.fsm +++ b/gr-trellis/python/awgn1o2_4.fsm diff --git a/gr-trellis/src/python/qa_trellis.py b/gr-trellis/python/qa_trellis.py index 53dcf0d8f6..0e1ddc61b2 100755 --- a/gr-trellis/src/python/qa_trellis.py +++ b/gr-trellis/python/qa_trellis.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2010 Free Software Foundation, Inc. +# Copyright 2004,2010,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,16 +21,14 @@ # import math +import os +from gnuradio import gr, gr_unittest -from gnuradio import gr, gr_unittest, blks2 -# It's pretty ugly that we can't import trellis from gnuradio in this test -# but because it runs on the non-installed python code it's all a mess. -import trellis - -import os +import trellis_swig as trellis import digital_swig as digital import analog_swig as analog +import blocks_swig as blocks fsm_args = {"awgn1o2_4": (2, 4, 4, (0, 2, 0, 2, 1, 3, 1, 3), @@ -118,7 +116,7 @@ class trellis_tb(gr.top_block): mod = digital.chunks_to_symbols_sc(constellation.points(), 1) # CHANNEL - add = gr.add_cc() + add = blocks.add_cc() noise = analog.noise_source_c(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX diff --git a/gr-trellis/src/lib/CMakeLists.txt b/gr-trellis/src/lib/CMakeLists.txt deleted file mode 100644 index 3463ba8037..0000000000 --- a/gr-trellis/src/lib/CMakeLists.txt +++ /dev/null @@ -1,224 +0,0 @@ -# Copyright 2011 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. - -include(GrPython) - -######################################################################## -# Setup the include and linker paths -######################################################################## -include_directories( - ${GNURADIO_CORE_INCLUDE_DIRS} - ${GR_TRELLIS_INCLUDE_DIRS} - ${GR_DIGITAL_INCLUDE_DIRS} -) - -include_directories(${Boost_INCLUDE_DIRS}) -link_directories(${Boost_LIBRARY_DIRS}) - -######################################################################## -# generate the python helper script which calls into the build utils -######################################################################## -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py " -#!${PYTHON_EXECUTABLE} - -import sys, os, re -sys.path.append('${GR_CORE_PYTHONPATH}') -sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}') -os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' -os.chdir('${CMAKE_CURRENT_BINARY_DIR}') - -if __name__ == '__main__': - import build_utils, generate_trellis - root, inp = sys.argv[1:3] - for sig in sys.argv[3:]: - name = re.sub ('X+', sig, root) - d = generate_trellis.standard_dict(name, sig) - build_utils.expand_template(d, inp) - -") - -######################################################################## -# generation helper macro to generate various files from template -######################################################################## -macro(expand_h_cc_i root) - - foreach(ext h cc i) - #make a list of all the generated files - unset(expanded_files_${ext}) - foreach(sig ${ARGN}) - string(REGEX REPLACE "X+" ${sig} name ${root}) - list(APPEND expanded_files_${ext} ${CMAKE_CURRENT_BINARY_DIR}/${name}.${ext}) - endforeach(sig) - - #create a command to generate the files - add_custom_command( - OUTPUT ${expanded_files_${ext}} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.${ext}.t - COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} - ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py - ${root} ${root}.${ext}.t ${ARGN} - ) - endforeach(ext) - - #make source files depends on headers to force generation - set_source_files_properties(${expanded_files_cc} - PROPERTIES OBJECT_DEPENDS "${expanded_files_h}" - ) - - #install rules for the generated cc, h, and i files - list(APPEND generated_trellis_sources ${expanded_files_cc}) - list(APPEND generated_trellis_includes ${expanded_files_h}) - list(APPEND generated_trellis_swigs ${expanded_files_i}) - -endmacro(expand_h_cc_i) - -######################################################################## -# Invoke macro to generate various sources -######################################################################## -expand_h_cc_i(trellis_encoder_XX bb bs bi ss si ii) -expand_h_cc_i(trellis_sccc_encoder_XX bb bs bi ss si ii) -expand_h_cc_i(trellis_pccc_encoder_XX bb bs bi ss si ii) -expand_h_cc_i(trellis_metrics_X s i f c) -expand_h_cc_i(trellis_viterbi_X b s i) -expand_h_cc_i(trellis_viterbi_combined_XX sb ss si ib is ii fb fs fi cb cs ci) -expand_h_cc_i(trellis_sccc_decoder_X b s i) -expand_h_cc_i(trellis_sccc_decoder_combined_XX fb fs fi cb cs ci) -expand_h_cc_i(trellis_pccc_decoder_X b s i) -expand_h_cc_i(trellis_pccc_decoder_combined_XX fb fs fi cb cs ci) - -######################################################################## -# Create the master trellis swig include files -######################################################################## -set(generated_index ${CMAKE_CURRENT_BINARY_DIR}/trellis_generated.i.in) -file(WRITE ${generated_index} " -// -// This file is machine generated. All edits will be overwritten -// -") - -file(APPEND ${generated_index} "%{\n") -foreach(swig_file ${generated_trellis_swigs}) - get_filename_component(name ${swig_file} NAME_WE) - file(APPEND ${generated_index} "#include<${name}.h>\n") -endforeach(swig_file) -file(APPEND ${generated_index} "%}\n") - -foreach(swig_file ${generated_trellis_swigs}) - get_filename_component(name ${swig_file} NAME) - file(APPEND ${generated_index} "%include<${name}>\n") -endforeach(swig_file) - -execute_process( - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${generated_index} ${CMAKE_CURRENT_BINARY_DIR}/trellis_generated.i -) - -######################################################################## -# Setup library -######################################################################## -list(APPEND gr_trellis_sources - fsm.cc - quicksort_index.cc - base.cc - interleaver.cc - calc_metric.cc - core_algorithms.cc - trellis_permutation.cc - trellis_siso_f.cc - trellis_siso_combined_f.cc - trellis_constellation_metrics_cf.cc - ${generated_trellis_sources} -) - -list(APPEND trellis_libs - gnuradio-core - gnuradio-digital - ${Boost_LIBRARIES} -) - -add_library(gnuradio-trellis SHARED ${gr_trellis_sources}) -target_link_libraries(gnuradio-trellis ${trellis_libs}) -GR_LIBRARY_FOO(gnuradio-trellis RUNTIME_COMPONENT "trellis_runtime" DEVEL_COMPONENT "trellis_devel") - -######################################################################## -# Handle the generated sources + a few non-generated ones -######################################################################## -install(FILES - ${generated_trellis_includes} - trellis_api.h - fsm.h - quicksort_index.h - base.h - interleaver.h - calc_metric.h - core_algorithms.h - trellis_permutation.h - siso_type.h - trellis_siso_f.h - trellis_siso_combined_f.h - trellis_constellation_metrics_cf.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "trellis_devel" -) - -if(ENABLE_PYTHON) - install(FILES - trellis.i - ${generated_trellis_swigs} - fsm.i - interleaver.i - trellis_permutation.i - trellis_siso_f.i - trellis_siso_combined_f.i - trellis_constellation_metrics_cf.i - ${CMAKE_CURRENT_BINARY_DIR}/trellis_generated.i - ${CMAKE_CURRENT_BINARY_DIR}/trellis_swig_doc.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "trellis_swig" - ) - -######################################################################## -# Setup swig generation -######################################################################## -include(GrPython) -include(GrSwig) - -set(GR_SWIG_SOURCE_DEPS - ${generated_trellis_includes} - ${generated_trellis_swigs} -) -set(GR_SWIG_INCLUDE_DIRS - ${GR_TRELLIS_INCLUDE_DIRS} - ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} - ${GR_DIGITAL_SWIG_INCLUDE_DIRS} -) - -set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/trellis_swig_doc.i) -set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -set(GR_SWIG_LIBRARIES gnuradio-trellis gnuradio-digital gnuradio-analog gnuradio-fft) -GR_SWIG_MAKE(trellis trellis.i) - -GR_SWIG_INSTALL( - TARGETS trellis - DESTINATION ${GR_PYTHON_DIR}/gnuradio - COMPONENT "trellis_python" -) - -endif(ENABLE_PYTHON) diff --git a/gr-trellis/src/lib/Makefile.gen b/gr-trellis/src/lib/Makefile.gen deleted file mode 100644 index b9b9afb1f7..0000000000 --- a/gr-trellis/src/lib/Makefile.gen +++ /dev/null @@ -1,174 +0,0 @@ -# -# This file is machine generated. All edits will be overwritten -# -GENERATED_H = \ - trellis_encoder_bb.h \ - trellis_encoder_bi.h \ - trellis_encoder_bs.h \ - trellis_encoder_ii.h \ - trellis_encoder_si.h \ - trellis_encoder_ss.h \ - trellis_metrics_c.h \ - trellis_metrics_f.h \ - trellis_metrics_i.h \ - trellis_metrics_s.h \ - trellis_pccc_decoder_b.h \ - trellis_pccc_decoder_combined_cb.h \ - trellis_pccc_decoder_combined_ci.h \ - trellis_pccc_decoder_combined_cs.h \ - trellis_pccc_decoder_combined_fb.h \ - trellis_pccc_decoder_combined_fi.h \ - trellis_pccc_decoder_combined_fs.h \ - trellis_pccc_decoder_i.h \ - trellis_pccc_decoder_s.h \ - trellis_pccc_encoder_bb.h \ - trellis_pccc_encoder_bi.h \ - trellis_pccc_encoder_bs.h \ - trellis_pccc_encoder_ii.h \ - trellis_pccc_encoder_si.h \ - trellis_pccc_encoder_ss.h \ - trellis_sccc_decoder_b.h \ - trellis_sccc_decoder_combined_cb.h \ - trellis_sccc_decoder_combined_ci.h \ - trellis_sccc_decoder_combined_cs.h \ - trellis_sccc_decoder_combined_fb.h \ - trellis_sccc_decoder_combined_fi.h \ - trellis_sccc_decoder_combined_fs.h \ - trellis_sccc_decoder_i.h \ - trellis_sccc_decoder_s.h \ - trellis_sccc_encoder_bb.h \ - trellis_sccc_encoder_bi.h \ - trellis_sccc_encoder_bs.h \ - trellis_sccc_encoder_ii.h \ - trellis_sccc_encoder_si.h \ - trellis_sccc_encoder_ss.h \ - trellis_viterbi_b.h \ - trellis_viterbi_combined_cb.h \ - trellis_viterbi_combined_ci.h \ - trellis_viterbi_combined_cs.h \ - trellis_viterbi_combined_fb.h \ - trellis_viterbi_combined_fi.h \ - trellis_viterbi_combined_fs.h \ - trellis_viterbi_combined_ib.h \ - trellis_viterbi_combined_ii.h \ - trellis_viterbi_combined_is.h \ - trellis_viterbi_combined_sb.h \ - trellis_viterbi_combined_si.h \ - trellis_viterbi_combined_ss.h \ - trellis_viterbi_i.h \ - trellis_viterbi_s.h - -GENERATED_I = \ - trellis_encoder_bb.i \ - trellis_encoder_bi.i \ - trellis_encoder_bs.i \ - trellis_encoder_ii.i \ - trellis_encoder_si.i \ - trellis_encoder_ss.i \ - trellis_metrics_c.i \ - trellis_metrics_f.i \ - trellis_metrics_i.i \ - trellis_metrics_s.i \ - trellis_pccc_decoder_b.i \ - trellis_pccc_decoder_combined_cb.i \ - trellis_pccc_decoder_combined_ci.i \ - trellis_pccc_decoder_combined_cs.i \ - trellis_pccc_decoder_combined_fb.i \ - trellis_pccc_decoder_combined_fi.i \ - trellis_pccc_decoder_combined_fs.i \ - trellis_pccc_decoder_i.i \ - trellis_pccc_decoder_s.i \ - trellis_pccc_encoder_bb.i \ - trellis_pccc_encoder_bi.i \ - trellis_pccc_encoder_bs.i \ - trellis_pccc_encoder_ii.i \ - trellis_pccc_encoder_si.i \ - trellis_pccc_encoder_ss.i \ - trellis_sccc_decoder_b.i \ - trellis_sccc_decoder_combined_cb.i \ - trellis_sccc_decoder_combined_ci.i \ - trellis_sccc_decoder_combined_cs.i \ - trellis_sccc_decoder_combined_fb.i \ - trellis_sccc_decoder_combined_fi.i \ - trellis_sccc_decoder_combined_fs.i \ - trellis_sccc_decoder_i.i \ - trellis_sccc_decoder_s.i \ - trellis_sccc_encoder_bb.i \ - trellis_sccc_encoder_bi.i \ - trellis_sccc_encoder_bs.i \ - trellis_sccc_encoder_ii.i \ - trellis_sccc_encoder_si.i \ - trellis_sccc_encoder_ss.i \ - trellis_viterbi_b.i \ - trellis_viterbi_combined_cb.i \ - trellis_viterbi_combined_ci.i \ - trellis_viterbi_combined_cs.i \ - trellis_viterbi_combined_fb.i \ - trellis_viterbi_combined_fi.i \ - trellis_viterbi_combined_fs.i \ - trellis_viterbi_combined_ib.i \ - trellis_viterbi_combined_ii.i \ - trellis_viterbi_combined_is.i \ - trellis_viterbi_combined_sb.i \ - trellis_viterbi_combined_si.i \ - trellis_viterbi_combined_ss.i \ - trellis_viterbi_i.i \ - trellis_viterbi_s.i - -GENERATED_CC = \ - trellis_encoder_bb.cc \ - trellis_encoder_bi.cc \ - trellis_encoder_bs.cc \ - trellis_encoder_ii.cc \ - trellis_encoder_si.cc \ - trellis_encoder_ss.cc \ - trellis_metrics_c.cc \ - trellis_metrics_f.cc \ - trellis_metrics_i.cc \ - trellis_metrics_s.cc \ - trellis_pccc_decoder_b.cc \ - trellis_pccc_decoder_combined_cb.cc \ - trellis_pccc_decoder_combined_ci.cc \ - trellis_pccc_decoder_combined_cs.cc \ - trellis_pccc_decoder_combined_fb.cc \ - trellis_pccc_decoder_combined_fi.cc \ - trellis_pccc_decoder_combined_fs.cc \ - trellis_pccc_decoder_i.cc \ - trellis_pccc_decoder_s.cc \ - trellis_pccc_encoder_bb.cc \ - trellis_pccc_encoder_bi.cc \ - trellis_pccc_encoder_bs.cc \ - trellis_pccc_encoder_ii.cc \ - trellis_pccc_encoder_si.cc \ - trellis_pccc_encoder_ss.cc \ - trellis_sccc_decoder_b.cc \ - trellis_sccc_decoder_combined_cb.cc \ - trellis_sccc_decoder_combined_ci.cc \ - trellis_sccc_decoder_combined_cs.cc \ - trellis_sccc_decoder_combined_fb.cc \ - trellis_sccc_decoder_combined_fi.cc \ - trellis_sccc_decoder_combined_fs.cc \ - trellis_sccc_decoder_i.cc \ - trellis_sccc_decoder_s.cc \ - trellis_sccc_encoder_bb.cc \ - trellis_sccc_encoder_bi.cc \ - trellis_sccc_encoder_bs.cc \ - trellis_sccc_encoder_ii.cc \ - trellis_sccc_encoder_si.cc \ - trellis_sccc_encoder_ss.cc \ - trellis_viterbi_b.cc \ - trellis_viterbi_combined_cb.cc \ - trellis_viterbi_combined_ci.cc \ - trellis_viterbi_combined_cs.cc \ - trellis_viterbi_combined_fb.cc \ - trellis_viterbi_combined_fi.cc \ - trellis_viterbi_combined_fs.cc \ - trellis_viterbi_combined_ib.cc \ - trellis_viterbi_combined_ii.cc \ - trellis_viterbi_combined_is.cc \ - trellis_viterbi_combined_sb.cc \ - trellis_viterbi_combined_si.cc \ - trellis_viterbi_combined_ss.cc \ - trellis_viterbi_i.cc \ - trellis_viterbi_s.cc - diff --git a/gr-trellis/src/lib/base.cc b/gr-trellis/src/lib/base.cc deleted file mode 100644 index 002c964cd5..0000000000 --- a/gr-trellis/src/lib/base.cc +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -#include <cstdio> -#include <stdexcept> -#include <cmath> -#include "base.h" - - -bool dec2base(unsigned int num, int base, std::vector<int> &s) -{ - int l = s.size(); - unsigned int n=num; - for(int i=0;i<l;i++) { - s[l-i-1] = n % base; //MSB first - n /= base; - } - if(n!=0) { - printf("Number %d requires more than %d digits.",num,l); - return false; - } - else - return true; -} - - -unsigned int base2dec(const std::vector<int> &s, int base) -{ - int l = s.size(); - unsigned int num=0; - for(int i=0;i<l;i++) - num=num*base+s[i]; - return num; -} - - -bool dec2bases(unsigned int num, const std::vector<int> &bases, std::vector<int> &s) -{ - int l = s.size(); - unsigned int n=num; - for(int i=0;i<l;i++) { - s[l-i-1] = n % bases[l-i-1]; - n /= bases[l-i-1]; - } - if(n!=0) { - printf("Number %d requires more than %d digits.",num,l); - return false; - } - else - return true; -} - - - -unsigned int bases2dec(const std::vector<int> &s, const std::vector<int> &bases) -{ - int l = s.size(); - unsigned int num=0; - for(int i=0;i<l;i++) - num = num * bases[i] + s[i]; - return num; -} - - - - - - - - - - - diff --git a/gr-trellis/src/lib/calc_metric.cc b/gr-trellis/src/lib/calc_metric.cc deleted file mode 100644 index 4d58a05482..0000000000 --- a/gr-trellis/src/lib/calc_metric.cc +++ /dev/null @@ -1,258 +0,0 @@ -/* -*- 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. - */ - -#include <float.h> -#include <stdexcept> -#include "calc_metric.h" - - - -template <class T> -void calc_metric(int O, int D, const std::vector<T> &TABLE, const T *in, - float *metric, gr::digital::trellis_metric_type_t type) -{ - float minm = FLT_MAX; - int minmi = 0; - - - switch (type){ - case gr::digital::TRELLIS_EUCLIDEAN: - for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - T s=in[m]-TABLE[o*D+m]; - //gr_complex sc(1.0*s,0); - //metric[o]+=(sc*conj(sc)).real(); - metric[o]+= s * s; - } - } - break; - case gr::digital::TRELLIS_HARD_SYMBOL: - for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - T s=in[m]-TABLE[o*D+m]; - //gr_complex sc(1.0*s,0); - //metric[o]+=(sc*conj(sc)).real(); - metric[o]+= s * s; - } - if(metric[o]<minm) { - minm=metric[o]; - minmi=o; - } - } - for(int o=0;o<O;o++) { - metric[o] = (o==minmi?0.0:1.0); - } - break; - case gr::digital::TRELLIS_HARD_BIT: - throw std::runtime_error ("Invalid metric type (not yet implemented)."); - break; - default: - throw std::runtime_error ("Invalid metric type."); - } -} - - - -template -void calc_metric<short>(int O, int D, const std::vector<short> &TABLE, const short *in, - float *metric, gr::digital::trellis_metric_type_t type); - -template -void calc_metric<int>(int O, int D, const std::vector<int> &TABLE, const int *in, - float *metric, gr::digital::trellis_metric_type_t type); - -template -void calc_metric<float>(int O, int D, const std::vector<float> &TABLE, const float *in, - float *metric, gr::digital::trellis_metric_type_t type); - - -/* -void calc_metric(int O, int D, const std::vector<short> &TABLE, const short *in, - float *metric, gr::digital::trellis_metric_type_t type) -{ - float minm = FLT_MAX; - int minmi = 0; - - switch (type){ - case gr::digital::TRELLIS_EUCLIDEAN: - for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - float s=in[m]-TABLE[o*D+m]; - metric[o]+=s*s; - } - } - break; - case gr::digital::TRELLIS_HARD_SYMBOL: - for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - float s=in[m]-TABLE[o*D+m]; - metric[o]+=s*s; - } - if(metric[o]<minm) { - minm=metric[o]; - minmi=o; - } - } - for(int o=0;o<O;o++) { - metric[o] = (o==minmi?0.0:1.0); - } - break; - case gr::digital::TRELLIS_HARD_BIT: - throw std::runtime_error ("Invalid metric type (not yet implemented)."); - break; - default: - throw std::runtime_error ("Invalid metric type."); - } -} - - -void calc_metric(int O, int D, const std::vector<int> &TABLE, const int *in, - float *metric, gr::digital::trellis_metric_type_t type) -{ - float minm = FLT_MAX; - int minmi = 0; - - switch (type){ - case gr::digital::TRELLIS_EUCLIDEAN: - for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - float s=in[m]-TABLE[o*D+m]; - metric[o]+=s*s; - } - } - break; - case gr::digital::TRELLIS_HARD_SYMBOL: - for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - float s=in[m]-TABLE[o*D+m]; - metric[o]+=s*s; - } - if(metric[o]<minm) { - minm=metric[o]; - minmi=o; - } - } - for(int o=0;o<O;o++) { - metric[o] = (o==minmi?0.0:1.0); - } - break; - case gr::digital::TRELLIS_HARD_BIT: - throw std::runtime_error ("Invalid metric type (not yet implemented)."); - break; - default: - throw std::runtime_error ("Invalid metric type."); - } -} - - - -void calc_metric(int O, int D, const std::vector<float> &TABLE, const float *in, - float *metric, gr::digital::trellis_metric_type_t type) -{ - float minm = FLT_MAX; - int minmi = 0; - - switch (type){ - case gr::digital::TRELLIS_EUCLIDEAN: - for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - float s=in[m]-TABLE[o*D+m]; - metric[o]+=s*s; - } - } - break; - case gr::digital::TRELLIS_HARD_SYMBOL: - for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - float s=in[m]-TABLE[o*D+m]; - metric[o]+=s*s; - } - if(metric[o]<minm) { - minm=metric[o]; - minmi=o; - } - } - for(int o=0;o<O;o++) { - metric[o] = (o==minmi?0.0:1.0); - } - break; - case gr::digital::TRELLIS_HARD_BIT: - throw std::runtime_error ("Invalid metric type (not yet implemented)."); - break; - default: - throw std::runtime_error ("Invalid metric type."); - } -} -*/ - - - - - -void calc_metric(int O, int D, const std::vector<gr_complex> &TABLE, const gr_complex *in, - float *metric, gr::digital::trellis_metric_type_t type) -{ - float minm = FLT_MAX; - int minmi = 0; - - - switch (type){ - case gr::digital::TRELLIS_EUCLIDEAN: - for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - gr_complex s=in[m]-TABLE[o*D+m]; - metric[o]+=s.real()*s.real()+s.imag()*s.imag(); - } - } - break; - case gr::digital::TRELLIS_HARD_SYMBOL: - for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - gr_complex s=in[m]-TABLE[o*D+m]; - metric[o]+=s.real()*s.real()+s.imag()*s.imag(); - } - if(metric[o]<minm) { - minm=metric[o]; - minmi=o; - } - } - for(int o=0;o<O;o++) { - metric[o] = (o==minmi?0.0:1.0); - } - break; - case gr::digital::TRELLIS_HARD_BIT: - throw std::runtime_error ("Invalid metric type (not yet implemented)."); - break; - default: - throw std::runtime_error ("Invalid metric type."); - } -} diff --git a/gr-trellis/src/lib/calc_metric.h b/gr-trellis/src/lib/calc_metric.h deleted file mode 100644 index cc0a12878d..0000000000 --- a/gr-trellis/src/lib/calc_metric.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- 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_CALC_METRIC_H -#define INCLUDED_CALC_METRIC_H - -#include <vector> -#include <gr_complex.h> -#include <digital/metric_type.h> - - -template <class T> -void calc_metric(int O, int D, const std::vector<T> &TABLE, const T *in, - float *metric, gr::digital::trellis_metric_type_t type); - -/* -void calc_metric(int O, int D, const std::vector<short> &TABLE, const short *in, float *metric, gr::digital::trellis_metric_type_t type); - -void calc_metric(int O, int D, const std::vector<int> &TABLE, const int *in, float *metric, gr::digital::trellis_metric_type_t type); - -void calc_metric(int O, int D, const std::vector<float> &TABLE, const float *in, float *metric, gr::digital::trellis_metric_type_t type); -*/ - -void calc_metric(int O, int D, const std::vector<gr_complex> &TABLE, const gr_complex *in, - float *metric, gr::digital::trellis_metric_type_t type); - - - -#endif diff --git a/gr-trellis/src/lib/core_algorithms.cc b/gr-trellis/src/lib/core_algorithms.cc deleted file mode 100644 index 442565054a..0000000000 --- a/gr-trellis/src/lib/core_algorithms.cc +++ /dev/null @@ -1,1437 +0,0 @@ -/* -*- 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. - */ - -#include <cstring> -#include <stdexcept> -//#include <cstdio> -#include <iostream> -#include "core_algorithms.h" -#include "calc_metric.h" - -static const float INF = 1.0e9; - -float min(float a, float b) -{ - return a <= b ? a : b; -} - -float min_star(float a, float b) -{ - return (a <= b ? a : b)-log(1+exp(a <= b ? a-b : b-a)); -} - - - - -template <class T> -void viterbi_algorithm(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - const float *in, T *out)//, - //std::vector<int> &trace) -{ - std::vector<int> trace(S*K); - std::vector<float> alpha(S*2); - int alphai; - float norm,mm,minm; - int minmi; - int st; - - - if(S0<0) { // initial state not specified - for(int i=0;i<S;i++) alpha[0*S+i]=0; - } - else { - for(int i=0;i<S;i++) alpha[0*S+i]=INF; - alpha[0*S+S0]=0.0; - } - - alphai=0; - for(int k=0;k<K;k++) { - norm=INF; - for(int j=0;j<S;j++) { // for each next state do ACS - minm=INF; - minmi=0; - for(unsigned int i=0;i<PS[j].size();i++) { - //int i0 = j*I+i; - if((mm=alpha[alphai*S+PS[j][i]]+in[k*O+OS[PS[j][i]*I+PI[j][i]]])<minm) - minm=mm,minmi=i; - } - trace[k*S+j]=minmi; - alpha[((alphai+1)%2)*S+j]=minm; - if(minm<norm) norm=minm; - } - for(int j=0;j<S;j++) - alpha[((alphai+1)%2)*S+j]-=norm; // normalize total metrics so they do not explode - alphai=(alphai+1)%2; - } - - if(SK<0) { // final state not specified - minm=INF; - minmi=0; - for(int i=0;i<S;i++) - if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i; - st=minmi; - } - else { - st=SK; - } - - for(int k=K-1;k>=0;k--) { // traceback - int i0=trace[k*S+st]; - out[k]= (T) PI[st][i0]; - st=PS[st][i0]; - } - -} - - -template -void viterbi_algorithm<unsigned char>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - const float *in, unsigned char *out); - - -template -void viterbi_algorithm<short>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - const float *in, short *out); - -template -void viterbi_algorithm<int>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - const float *in, int *out); - - - -//============================================== - -template <class Ti, class To> -void viterbi_algorithm_combined(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<Ti> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const Ti *in, To *out -) -{ - std::vector<int> trace(S*K); - std::vector<float> alpha(S*2); - float *metric = new float[O]; - int alphai; - float norm,mm,minm; - int minmi; - int st; - - if(S0<0) { // initial state not specified - for(int i=0;i<S;i++) alpha[0*S+i]=0; - } - else { - for(int i=0;i<S;i++) alpha[0*S+i]=INF; - alpha[0*S+S0]=0.0; - } - - alphai=0; - for(int k=0;k<K;k++) { - calc_metric(O, D, TABLE, &(in[k*D]), metric,TYPE); // calc metrics - norm=INF; - for(int j=0;j<S;j++) { // for each next state do ACS - minm=INF; - minmi=0; - for(unsigned int i=0;i<PS[j].size();i++) { - //int i0 = j*I+i; - if((mm=alpha[alphai*S+PS[j][i]]+metric[OS[PS[j][i]*I+PI[j][i]]])<minm) - minm=mm,minmi=i; - } - trace[k*S+j]=minmi; - alpha[((alphai+1)%2)*S+j]=minm; - if(minm<norm) norm=minm; - } - for(int j=0;j<S;j++) - alpha[((alphai+1)%2)*S+j]-=norm; // normalize total metrics so they do not explode - alphai=(alphai+1)%2; - } - - if(SK<0) { // final state not specified - minm=INF; - minmi=0; - for(int i=0;i<S;i++) - if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i; - st=minmi; - } - else { - st=SK; - } - - for(int k=K-1;k>=0;k--) { // traceback - int i0=trace[k*S+st]; - out[k]= (To) PI[st][i0]; - st=PS[st][i0]; - } - - delete [] metric; - -} - -// Ti = s i f c -// To = b s i - -//--------------- - -template -void viterbi_algorithm_combined<short,unsigned char>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<short> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const short *in, unsigned char *out -); - -template -void viterbi_algorithm_combined<int,unsigned char>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<int> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const int *in, unsigned char *out -); - -template -void viterbi_algorithm_combined<float,unsigned char>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const float *in, unsigned char *out -); - -template -void viterbi_algorithm_combined<gr_complex,unsigned char>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<gr_complex> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const gr_complex *in, unsigned char *out -); - -//--------------- - -template -void viterbi_algorithm_combined<short,short>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<short> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const short *in, short *out -); - -template -void viterbi_algorithm_combined<int,short>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<int> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const int *in, short *out -); - -template -void viterbi_algorithm_combined<float,short>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const float *in, short *out -); - -template -void viterbi_algorithm_combined<gr_complex,short>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<gr_complex> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const gr_complex *in, short *out -); - -//-------------- - -template -void viterbi_algorithm_combined<short,int>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<short> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const short *in, int *out -); - -template -void viterbi_algorithm_combined<int,int>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<int> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const int *in, int *out -); - -template -void viterbi_algorithm_combined<float,int>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const float *in, int *out -); - -template -void viterbi_algorithm_combined<gr_complex,int>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<gr_complex> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const gr_complex *in, int *out -); - - - - - - - - - - - - - - - - - - - - -//=============================================== - - -void siso_algorithm(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - bool POSTI, bool POSTO, - float (*p2mymin)(float,float), - const float *priori, const float *prioro, float *post//, - //std::vector<float> &alpha, - //std::vector<float> &beta - ) -{ - float norm,mm,minm; - std::vector<float> alpha(S*(K+1)); - std::vector<float> beta(S*(K+1)); - - - if(S0<0) { // initial state not specified - for(int i=0;i<S;i++) alpha[0*S+i]=0; - } - else { - for(int i=0;i<S;i++) alpha[0*S+i]=INF; - alpha[0*S+S0]=0.0; - } - - for(int k=0;k<K;k++) { // forward recursion - norm=INF; - for(int j=0;j<S;j++) { - minm=INF; - for(unsigned int i=0;i<PS[j].size();i++) { - //int i0 = j*I+i; - mm=alpha[k*S+PS[j][i]]+priori[k*I+PI[j][i]]+prioro[k*O+OS[PS[j][i]*I+PI[j][i]]]; - minm=(*p2mymin)(minm,mm); - } - alpha[(k+1)*S+j]=minm; - if(minm<norm) norm=minm; - } - for(int j=0;j<S;j++) - alpha[(k+1)*S+j]-=norm; // normalize total metrics so they do not explode - } - - if(SK<0) { // final state not specified - for(int i=0;i<S;i++) beta[K*S+i]=0; - } - else { - for(int i=0;i<S;i++) beta[K*S+i]=INF; - beta[K*S+SK]=0.0; - } - - for(int k=K-1;k>=0;k--) { // backward recursion - norm=INF; - for(int j=0;j<S;j++) { - minm=INF; - for(int i=0;i<I;i++) { - int i0 = j*I+i; - mm=beta[(k+1)*S+NS[i0]]+priori[k*I+i]+prioro[k*O+OS[i0]]; - minm=(*p2mymin)(minm,mm); - } - beta[k*S+j]=minm; - if(minm<norm) norm=minm; - } - for(int j=0;j<S;j++) - beta[k*S+j]-=norm; // normalize total metrics so they do not explode - } - - -if (POSTI && POSTO) -{ - for(int k=0;k<K;k++) { // input combining - norm=INF; - for(int i=0;i<I;i++) { - minm=INF; - for(int j=0;j<S;j++) { - mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; - minm=(*p2mymin)(minm,mm); - } - post[k*(I+O)+i]=minm; - if(minm<norm) norm=minm; - } - for(int i=0;i<I;i++) - post[k*(I+O)+i]-=norm; // normalize metrics - } - - - for(int k=0;k<K;k++) { // output combining - norm=INF; - for(int n=0;n<O;n++) { - minm=INF; - for(int j=0;j<S;j++) { - for(int i=0;i<I;i++) { - mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); - minm=(*p2mymin)(minm,mm); - } - } - post[k*(I+O)+I+n]=minm; - if(minm<norm) norm=minm; - } - for(int n=0;n<O;n++) - post[k*(I+O)+I+n]-=norm; // normalize metrics - } -} -else if(POSTI) -{ - for(int k=0;k<K;k++) { // input combining - norm=INF; - for(int i=0;i<I;i++) { - minm=INF; - for(int j=0;j<S;j++) { - mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; - minm=(*p2mymin)(minm,mm); - } - post[k*I+i]=minm; - if(minm<norm) norm=minm; - } - for(int i=0;i<I;i++) - post[k*I+i]-=norm; // normalize metrics - } -} -else if(POSTO) -{ - for(int k=0;k<K;k++) { // output combining - norm=INF; - for(int n=0;n<O;n++) { - minm=INF; - for(int j=0;j<S;j++) { - for(int i=0;i<I;i++) { - mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); - minm=(*p2mymin)(minm,mm); - } - } - post[k*O+n]=minm; - if(minm<norm) norm=minm; - } - for(int n=0;n<O;n++) - post[k*O+n]-=norm; // normalize metrics - } -} -else - throw std::runtime_error ("Not both POSTI and POSTO can be false."); - -} - - -//=========================================================== - -template <class T> -void siso_algorithm_combined(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - bool POSTI, bool POSTO, - float (*p2mymin)(float,float), - int D, - const std::vector<T> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const float *priori, const T *observations, float *post -) -{ - float norm,mm,minm; - std::vector<float> alpha(S*(K+1)); - std::vector<float> beta(S*(K+1)); - float *prioro = new float[O*K]; - - - if(S0<0) { // initial state not specified - for(int i=0;i<S;i++) alpha[0*S+i]=0; - } - else { - for(int i=0;i<S;i++) alpha[0*S+i]=INF; - alpha[0*S+S0]=0.0; - } - - for(int k=0;k<K;k++) { // forward recursion - calc_metric(O, D, TABLE, &(observations[k*D]), &(prioro[k*O]),TYPE); // calc metrics - norm=INF; - for(int j=0;j<S;j++) { - minm=INF; - for(unsigned int i=0;i<PS[j].size();i++) { - //int i0 = j*I+i; - mm=alpha[k*S+PS[j][i]]+priori[k*I+PI[j][i]]+prioro[k*O+OS[PS[j][i]*I+PI[j][i]]]; - minm=(*p2mymin)(minm,mm); - } - alpha[(k+1)*S+j]=minm; - if(minm<norm) norm=minm; - } - for(int j=0;j<S;j++) - alpha[(k+1)*S+j]-=norm; // normalize total metrics so they do not explode - } - - if(SK<0) { // final state not specified - for(int i=0;i<S;i++) beta[K*S+i]=0; - } - else { - for(int i=0;i<S;i++) beta[K*S+i]=INF; - beta[K*S+SK]=0.0; - } - - for(int k=K-1;k>=0;k--) { // backward recursion - norm=INF; - for(int j=0;j<S;j++) { - minm=INF; - for(int i=0;i<I;i++) { - int i0 = j*I+i; - mm=beta[(k+1)*S+NS[i0]]+priori[k*I+i]+prioro[k*O+OS[i0]]; - minm=(*p2mymin)(minm,mm); - } - beta[k*S+j]=minm; - if(minm<norm) norm=minm; - } - for(int j=0;j<S;j++) - beta[k*S+j]-=norm; // normalize total metrics so they do not explode - } - - - if (POSTI && POSTO) - { - for(int k=0;k<K;k++) { // input combining - norm=INF; - for(int i=0;i<I;i++) { - minm=INF; - for(int j=0;j<S;j++) { - mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; - minm=(*p2mymin)(minm,mm); - } - post[k*(I+O)+i]=minm; - if(minm<norm) norm=minm; - } - for(int i=0;i<I;i++) - post[k*(I+O)+i]-=norm; // normalize metrics - } - - - for(int k=0;k<K;k++) { // output combining - norm=INF; - for(int n=0;n<O;n++) { - minm=INF; - for(int j=0;j<S;j++) { - for(int i=0;i<I;i++) { - mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); - minm=(*p2mymin)(minm,mm); - } - } - post[k*(I+O)+I+n]=minm; - if(minm<norm) norm=minm; - } - for(int n=0;n<O;n++) - post[k*(I+O)+I+n]-=norm; // normalize metrics - } - } - else if(POSTI) - { - for(int k=0;k<K;k++) { // input combining - norm=INF; - for(int i=0;i<I;i++) { - minm=INF; - for(int j=0;j<S;j++) { - mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; - minm=(*p2mymin)(minm,mm); - } - post[k*I+i]=minm; - if(minm<norm) norm=minm; - } - for(int i=0;i<I;i++) - post[k*I+i]-=norm; // normalize metrics - } - } - else if(POSTO) - { - for(int k=0;k<K;k++) { // output combining - norm=INF; - for(int n=0;n<O;n++) { - minm=INF; - for(int j=0;j<S;j++) { - for(int i=0;i<I;i++) { - mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); - minm=(*p2mymin)(minm,mm); - } - } - post[k*O+n]=minm; - if(minm<norm) norm=minm; - } - for(int n=0;n<O;n++) - post[k*O+n]-=norm; // normalize metrics - } - } - else - throw std::runtime_error ("Not both POSTI and POSTO can be false."); - - delete [] prioro; - -} - -//--------- - -template -void siso_algorithm_combined<short>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - bool POSTI, bool POSTO, - float (*p2mymin)(float,float), - int D, - const std::vector<short> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const float *priori, const short *observations, float *post -); - -template -void siso_algorithm_combined<int>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - bool POSTI, bool POSTO, - float (*p2mymin)(float,float), - int D, - const std::vector<int> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const float *priori, const int *observations, float *post -); - -template -void siso_algorithm_combined<float>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - bool POSTI, bool POSTO, - float (*p2mymin)(float,float), - int D, - const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const float *priori, const float *observations, float *post -); - -template -void siso_algorithm_combined<gr_complex>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - bool POSTI, bool POSTO, - float (*p2mymin)(float,float), - int D, - const std::vector<gr_complex> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const float *priori, const gr_complex *observations, float *post -); - -//========================================================= - -template<class Ti, class To> -void sccc_decoder_combined( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<Ti> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const Ti *observations, To *data -) -{ - -//allocate space for priori, prioro and posti of inner FSM -std::vector<float> ipriori(blocklength*FSMi.I(),0.0); -std::vector<float> iprioro(blocklength*FSMi.O()); -std::vector<float> iposti(blocklength*FSMi.I()); - -//allocate space for priori, prioro and posto of outer FSM -std::vector<float> opriori(blocklength*FSMo.I(),0.0); -std::vector<float> oprioro(blocklength*FSMo.O()); -std::vector<float> oposti(blocklength*FSMo.I()); -std::vector<float> oposto(blocklength*FSMo.O()); - -// turn observations to neg-log-priors -for(int k=0;k<blocklength;k++) { - calc_metric(FSMi.O(), D, TABLE, &(observations[k*D]), &(iprioro[k*FSMi.O()]),METRIC_TYPE); - iprioro[k*FSMi.O()] *= scaling; -} - -for(int rep=0;rep<iterations;rep++) { - // run inner SISO - siso_algorithm(FSMi.I(),FSMi.S(),FSMi.O(), - FSMi.NS(), FSMi.OS(), FSMi.PS(), FSMi.PI(), - blocklength, - STi0,STiK, - true, false, - p2mymin, - &(ipriori[0]), &(iprioro[0]), &(iposti[0]) - ); - - //interleave soft info inner -> outer - for(int k=0;k<blocklength;k++) { - int ki = INTERLEAVER.DEINTER()[k]; - //for(int i=0;i<FSMi.I();i++) { - //oprioro[k*FSMi.I()+i]=iposti[ki*FSMi.I()+i]; - //} - memcpy(&(oprioro[k*FSMi.I()]),&(iposti[ki*FSMi.I()]),FSMi.I()*sizeof(float)); - } - - // run outer SISO - - if(rep<iterations-1) { // do not produce posti - siso_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), - FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), - blocklength, - STo0,SToK, - false, true, - p2mymin, - &(opriori[0]), &(oprioro[0]), &(oposto[0]) - ); - - //interleave soft info outer --> inner - for(int k=0;k<blocklength;k++) { - int ki = INTERLEAVER.DEINTER()[k]; - //for(int i=0;i<FSMi.I();i++) { - //ipriori[ki*FSMi.I()+i]=oposto[k*FSMi.I()+i]; - //} - memcpy(&(ipriori[ki*FSMi.I()]),&(oposto[k*FSMi.I()]),FSMi.I()*sizeof(float)); - } - } - else // produce posti but not posto - - siso_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), - FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), - blocklength, - STo0,SToK, - true, false, - p2mymin, - &(opriori[0]), &(oprioro[0]), &(oposti[0]) - ); - - /* - viterbi_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), - FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), - blocklength, - STo0,SToK, - &(oprioro[0]), data - ); - */ - -} - - -// generate hard decisions -for(int k=0;k<blocklength;k++) { - float min=INF; - int mini=0; - for(int i=0;i<FSMo.I();i++) { - if(oposti[k*FSMo.I()+i]<min) { - min=oposti[k*FSMo.I()+i]; - mini=i; - } - } - data[k]=(To)mini; -} - - - -} - -//------- - -template -void sccc_decoder_combined<float,unsigned char>( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const float *observations, unsigned char *data -); - -template -void sccc_decoder_combined<float,short>( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const float *observations, short *data -); - -template -void sccc_decoder_combined<float,int>( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const float *observations, int *data -); - -template -void sccc_decoder_combined<gr_complex,unsigned char>( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<gr_complex> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const gr_complex *observations, unsigned char *data -); - -template -void sccc_decoder_combined<gr_complex,short>( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<gr_complex> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const gr_complex *observations, short *data -); - -template -void sccc_decoder_combined<gr_complex,int>( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<gr_complex> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const gr_complex *observations, int *data -); - - - -//========================================================= - -template<class T> -void sccc_decoder( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - const float *iprioro, T *data -) -{ - //allocate space for priori, and posti of inner FSM - std::vector<float> ipriori(blocklength*FSMi.I(),0.0); - std::vector<float> iposti(blocklength*FSMi.I()); - - //allocate space for priori, prioro and posto of outer FSM - std::vector<float> opriori(blocklength*FSMo.I(),0.0); - std::vector<float> oprioro(blocklength*FSMo.O()); - std::vector<float> oposti(blocklength*FSMo.I()); - std::vector<float> oposto(blocklength*FSMo.O()); - - for(int rep=0;rep<iterations;rep++) { - // run inner SISO - siso_algorithm(FSMi.I(),FSMi.S(),FSMi.O(), - FSMi.NS(), FSMi.OS(), FSMi.PS(), FSMi.PI(), - blocklength, - STi0,STiK, - true, false, - p2mymin, - &(ipriori[0]), &(iprioro[0]), &(iposti[0]) - ); - - //interleave soft info inner -> outer - for(int k=0;k<blocklength;k++) { - int ki = INTERLEAVER.DEINTER()[k]; - //for(int i=0;i<FSMi.I();i++) { - //oprioro[k*FSMi.I()+i]=iposti[ki*FSMi.I()+i]; - //} - memcpy(&(oprioro[k*FSMi.I()]),&(iposti[ki*FSMi.I()]),FSMi.I()*sizeof(float)); - } - - // run outer SISO - - if(rep<iterations-1) { // do not produce posti - siso_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), - FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), - blocklength, - STo0,SToK, - false, true, - p2mymin, - &(opriori[0]), &(oprioro[0]), &(oposto[0]) - ); - - //interleave soft info outer --> inner - for(int k=0;k<blocklength;k++) { - int ki = INTERLEAVER.DEINTER()[k]; - //for(int i=0;i<FSMi.I();i++) { - //ipriori[ki*FSMi.I()+i]=oposto[k*FSMi.I()+i]; - //} - memcpy(&(ipriori[ki*FSMi.I()]),&(oposto[k*FSMi.I()]),FSMi.I()*sizeof(float)); - } - } - else {// produce posti but not posto - - siso_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), - FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), - blocklength, - STo0,SToK, - true, false, - p2mymin, - &(opriori[0]), &(oprioro[0]), &(oposti[0]) - ); - - /* - viterbi_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), - FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), - blocklength, - STo0,SToK, - &(oprioro[0]), data - ); - */ - } - - } // end iterations - - // generate hard decisions - for(int k=0;k<blocklength;k++) { - float min=INF; - int mini=0; - for(int i=0;i<FSMo.I();i++) { - if(oposti[k*FSMo.I()+i]<min) { - min=oposti[k*FSMo.I()+i]; - mini=i; - } - } - data[k]=(T)mini; - } - - - -} - -//------- - -template -void sccc_decoder<unsigned char>( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - const float *iprioro, unsigned char *data -); - -template -void sccc_decoder<short>( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - const float *iprioro, short *data -); - -template -void sccc_decoder<int>( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - const float *iprioro, int *data -); - - -//==================================================== - -template<class T> -void pccc_decoder( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - const float *cprioro, T *data -) -{ - - //allocate space for priori, prioro and posti of FSM1 - std::vector<float> priori1(blocklength*FSM1.I(),0.0); - std::vector<float> prioro1(blocklength*FSM1.O()); - std::vector<float> posti1(blocklength*FSM1.I()); - - //allocate space for priori, prioro and posti of FSM2 - std::vector<float> priori2(blocklength*FSM2.I(),0.0); - std::vector<float> prioro2(blocklength*FSM2.O()); - std::vector<float> posti2(blocklength*FSM2.I()); - - //generate prioro1,2 (metrics are not updated per iteration: this is not the best you can do...) - for (int k=0;k<blocklength;k++) { - //std::cout << k << std::endl; - for(int i=0;i<FSM1.O();i++) { - float x=cprioro[k*FSM1.O()*FSM2.O()+i*FSM1.O()+0]; - for(int j=1;j<FSM2.O();j++) - x = (*p2mymin)(x,cprioro[k*FSM1.O()*FSM2.O()+i*FSM1.O()+j]); - prioro1[k*FSM1.O()+i]=x; - //std::cout << prioro1[k*FSM1.O()+i] << ", "; - } - //std::cout << std::endl; - for(int i=0;i<FSM2.O();i++) { - float x=cprioro[k*FSM1.O()*FSM2.O()+0*FSM1.O()+i]; - for(int j=1;j<FSM1.O();j++) - x = (*p2mymin)(x,cprioro[k*FSM1.O()*FSM2.O()+j*FSM1.O()+i]); - prioro2[k*FSM2.O()+i]=x; - } - } - - for(int rep=0;rep<iterations;rep++) { - // run SISO 1 - siso_algorithm(FSM1.I(),FSM1.S(),FSM1.O(), - FSM1.NS(), FSM1.OS(), FSM1.PS(), FSM1.PI(), - blocklength, - ST10,ST1K, - true, false, - p2mymin, - &(priori1[0]), &(prioro1[0]), &(posti1[0]) - ); - - //for(int k=0;k<blocklength;k++){ - //for(int i=0;i<FSM1.I();i++) - //std::cout << posti1[k*FSM1.I()+i] << ", "; - //std::cout << std::endl; - //} - - //interleave soft info 1 -> 2 - for(int k=0;k<blocklength;k++) { - int ki = INTERLEAVER.INTER()[k]; - //for(int i=0;i<FSMi.I();i++) { - //oprioro[k*FSMi.I()+i]=iposti[ki*FSMi.I()+i]; - //} - memcpy(&(priori2[k*FSM2.I()]),&(posti1[ki*FSM1.I()]),FSM1.I()*sizeof(float)); - } - - // run SISO 2 - siso_algorithm(FSM2.I(),FSM2.S(),FSM2.O(), - FSM2.NS(), FSM2.OS(), FSM2.PS(), FSM2.PI(), - blocklength, - ST20,ST2K, - true, false, - p2mymin, - &(priori2[0]), &(prioro2[0]), &(posti2[0]) - ); - - //interleave soft info 2 --> 1 - for(int k=0;k<blocklength;k++) { - int ki = INTERLEAVER.INTER()[k]; - //for(int i=0;i<FSMi.I();i++) { - //ipriori[ki*FSMi.I()+i]=oposto[k*FSMi.I()+i]; - //} - memcpy(&(priori1[ki*FSM1.I()]),&(posti2[k*FSM2.I()]),FSM1.I()*sizeof(float)); - } - - } // end iterations - - // generate hard decisions - for(int k=0;k<blocklength;k++) { - for(int i=0;i<FSM1.I();i++) - posti1[k*FSM1.I()+i] = (*p2mymin)(priori1[k*FSM1.I()+i],posti1[k*FSM1.I()+i]); - float min=INF; - int mini=0; - for(int i=0;i<FSM1.I();i++) { - if(posti1[k*FSM1.I()+i]<min) { - min=posti1[k*FSM1.I()+i]; - mini=i; - } - } - data[k]=(T)mini; - //std::cout << data[k] << ", "<< std::endl; - } - //std::cout << std::endl; - -} - -//---------------- - -template -void pccc_decoder<unsigned char>( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - const float *cprioro, unsigned char *data -); - -template -void pccc_decoder<short>( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - const float *cprioro, short *data -); - -template -void pccc_decoder<int>( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - const float *cprioro, int *data -); - - - -//---------------- - - -template<class Ti, class To> -void pccc_decoder_combined( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<Ti> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const Ti *observations, To *data -) -{ - - //allocate space for cprioro - std::vector<float> cprioro(blocklength*FSM1.O()*FSM2.O(),0.0); - - //allocate space for priori, prioro and posti of FSM1 - std::vector<float> priori1(blocklength*FSM1.I(),0.0); - std::vector<float> prioro1(blocklength*FSM1.O()); - std::vector<float> posti1(blocklength*FSM1.I()); - - //allocate space for priori, prioro and posti of FSM2 - std::vector<float> priori2(blocklength*FSM2.I(),0.0); - std::vector<float> prioro2(blocklength*FSM2.O()); - std::vector<float> posti2(blocklength*FSM2.I()); - - // turn observations to neg-log-priors for cprioiro - int O=FSM1.O()*FSM2.O(); - for(int k=0;k<blocklength;k++) { - calc_metric(O, D, TABLE, &(observations[k*D]), &(cprioro[k*O]),METRIC_TYPE); - cprioro[k*O] *= scaling; - } - - //generate prioro1,2 (metrics are not updated per iteration: this is not the best you can do...) - for (int k=0;k<blocklength;k++) { - //std::cout << k << std::endl; - for(int i=0;i<FSM1.O();i++) { - float x=cprioro[k*FSM1.O()*FSM2.O()+i*FSM1.O()+0]; - for(int j=1;j<FSM2.O();j++) - x = (*p2mymin)(x,cprioro[k*FSM1.O()*FSM2.O()+i*FSM1.O()+j]); - prioro1[k*FSM1.O()+i]=x; - //std::cout << prioro1[k*FSM1.O()+i] << ", "; - } - //std::cout << std::endl; - for(int i=0;i<FSM2.O();i++) { - float x=cprioro[k*FSM1.O()*FSM2.O()+0*FSM1.O()+i]; - for(int j=1;j<FSM1.O();j++) - x = (*p2mymin)(x,cprioro[k*FSM1.O()*FSM2.O()+j*FSM1.O()+i]); - prioro2[k*FSM2.O()+i]=x; - } - } - - for(int rep=0;rep<iterations;rep++) { - // run SISO 1 - siso_algorithm(FSM1.I(),FSM1.S(),FSM1.O(), - FSM1.NS(), FSM1.OS(), FSM1.PS(), FSM1.PI(), - blocklength, - ST10,ST1K, - true, false, - p2mymin, - &(priori1[0]), &(prioro1[0]), &(posti1[0]) - ); - - //for(int k=0;k<blocklength;k++){ - //for(int i=0;i<FSM1.I();i++) - //std::cout << posti1[k*FSM1.I()+i] << ", "; - //std::cout << std::endl; - //} - - //interleave soft info 1 -> 2 - for(int k=0;k<blocklength;k++) { - int ki = INTERLEAVER.INTER()[k]; - //for(int i=0;i<FSMi.I();i++) { - //oprioro[k*FSMi.I()+i]=iposti[ki*FSMi.I()+i]; - //} - memcpy(&(priori2[k*FSM2.I()]),&(posti1[ki*FSM1.I()]),FSM1.I()*sizeof(float)); - } - - // run SISO 2 - siso_algorithm(FSM2.I(),FSM2.S(),FSM2.O(), - FSM2.NS(), FSM2.OS(), FSM2.PS(), FSM2.PI(), - blocklength, - ST20,ST2K, - true, false, - p2mymin, - &(priori2[0]), &(prioro2[0]), &(posti2[0]) - ); - - //interleave soft info 2 --> 1 - for(int k=0;k<blocklength;k++) { - int ki = INTERLEAVER.INTER()[k]; - //for(int i=0;i<FSMi.I();i++) { - //ipriori[ki*FSMi.I()+i]=oposto[k*FSMi.I()+i]; - //} - memcpy(&(priori1[ki*FSM1.I()]),&(posti2[k*FSM2.I()]),FSM1.I()*sizeof(float)); - } - - } // end iterations - - // generate hard decisions - for(int k=0;k<blocklength;k++) { - for(int i=0;i<FSM1.I();i++) - posti1[k*FSM1.I()+i] = (*p2mymin)(priori1[k*FSM1.I()+i],posti1[k*FSM1.I()+i]); - float min=INF; - int mini=0; - for(int i=0;i<FSM1.I();i++) { - if(posti1[k*FSM1.I()+i]<min) { - min=posti1[k*FSM1.I()+i]; - mini=i; - } - } - data[k]=(To)mini; - //std::cout << data[k] << ", "<< std::endl; - } - //std::cout << std::endl; - -} - - -template -void pccc_decoder_combined( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const float *observations, unsigned char *data -); - - -template -void pccc_decoder_combined( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const float *observations, short *data -); - - -template -void pccc_decoder_combined( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const float *observations, int *data -); - - -template -void pccc_decoder_combined( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<gr_complex> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const gr_complex *observations, unsigned char *data -); - - -template -void pccc_decoder_combined( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<gr_complex> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const gr_complex *observations, short *data -); - - -template -void pccc_decoder_combined( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<gr_complex> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const gr_complex *observations, int *data -); diff --git a/gr-trellis/src/lib/core_algorithms.h b/gr-trellis/src/lib/core_algorithms.h deleted file mode 100644 index 4efcc91235..0000000000 --- a/gr-trellis/src/lib/core_algorithms.h +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- 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_CORE_ALGORITHMS_H -#define INCLUDED_CORE_ALGORITHMS_H - -#include <cmath> -#include <vector> -//#include <gr_complex.h> -#include "digital/metric_type.h" -#include "fsm.h" -#include "interleaver.h" - - -float min(float a, float b); -float min_star(float a, float b); - -template <class T> -void viterbi_algorithm(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - const float *in, T *out -); - -template <class Ti, class To> -void viterbi_algorithm_combined(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<Ti> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const Ti *in, To *out -); - - - -void siso_algorithm(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - bool POSTI, bool POSTO, - float (*p2mymin)(float,float), - const float *priori, const float *prioro, float *post -); - - -template <class T> -void siso_algorithm_combined(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - bool POSTI, bool POSTO, - float (*p2mymin)(float,float), - int D, - const std::vector<T> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const float *priori, const T *observations, float *post -); - - -template<class T> -void sccc_decoder( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - const float *iprioro, T *data -); - - -template<class Ti, class To> -void sccc_decoder_combined( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<Ti> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const Ti *observations, To *data -); - -template<class T> -void pccc_decoder( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - const float *cprioro, T *data -); - -template<class Ti, class To> -void pccc_decoder_combined( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, int blocklength, int iterations, - float (*p2mymin)(float,float), - int D, const std::vector<Ti> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling, - const Ti *observations, To *data -); - - - - -#endif diff --git a/gr-trellis/src/lib/fsm.cc b/gr-trellis/src/lib/fsm.cc deleted file mode 100644 index fb2b4d2c9f..0000000000 --- a/gr-trellis/src/lib/fsm.cc +++ /dev/null @@ -1,548 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -#include <cstdio> -#include <string> -#include <iostream> -#include <fstream> -#include <stdexcept> -#include <cmath> -#include <stdlib.h> -#include "base.h" -#include "fsm.h" - - -fsm::fsm() -{ - d_I=0; - d_S=0; - d_O=0; - d_NS.resize(0); - d_OS.resize(0); - d_PS.resize(0); - d_PI.resize(0); - d_TMi.resize(0); - d_TMl.resize(0); -} - -fsm::fsm(const fsm &FSM) -{ - d_I=FSM.I(); - d_S=FSM.S(); - d_O=FSM.O(); - d_NS=FSM.NS(); - d_OS=FSM.OS(); - d_PS=FSM.PS(); // is this going to make a deep copy? - d_PI=FSM.PI(); - d_TMi=FSM.TMi(); - d_TMl=FSM.TMl(); -} - -fsm::fsm(int I, int S, int O, const std::vector<int> &NS, const std::vector<int> &OS) -{ - d_I=I; - d_S=S; - d_O=O; - d_NS=NS; - d_OS=OS; - - generate_PS_PI(); - generate_TM(); -} - -//###################################################################### -//# Read an FSM specification from a file. -//# Format (hopefully will become more flexible in the future...): -//# I S O (in the first line) -//# blank line -//# Next state matrix (S lines, each with I integers separated by spaces) -//# blank line -//# output symbol matrix (S lines, each with I integers separated by spaces) -//# optional comments -//###################################################################### -fsm::fsm(const char *name) -{ - FILE *fsmfile; - - if((fsmfile=fopen(name,"r"))==NULL) - throw std::runtime_error ("fsm::fsm(const char *name): file open error\n"); - //printf("file open error in fsm()\n"); - - if(fscanf(fsmfile,"%d %d %d\n",&d_I,&d_S,&d_O) == EOF) { - if(ferror(fsmfile) != 0) - throw std::runtime_error ("fsm::fsm(const char *name): file read error\n"); - } - - d_NS.resize(d_I*d_S); - d_OS.resize(d_I*d_S); - - for(int i=0;i<d_S;i++) { - for(int j=0;j<d_I;j++) { - if(fscanf(fsmfile,"%d",&(d_NS[i*d_I+j])) == EOF) { - if(ferror(fsmfile) != 0) - throw std::runtime_error ("fsm::fsm(const char *name): file read error\n"); - } - } - } - for(int i=0;i<d_S;i++) { - for(int j=0;j<d_I;j++) { - if(fscanf(fsmfile,"%d",&(d_OS[i*d_I+j])) == EOF) { - if(ferror(fsmfile) != 0) - throw std::runtime_error ("fsm::fsm(const char *name): file read error\n"); - } - } - } - - fclose(fsmfile); - - generate_PS_PI(); - generate_TM(); -} - - - -//###################################################################### -//# Automatically generate the FSM from the generator matrix -//# of a (n,k) binary convolutional code -//###################################################################### -fsm::fsm(int k, int n, const std::vector<int> &G) -{ - - // calculate maximum memory requirements for each input stream - std::vector<int> max_mem_x(k,-1); - int max_mem = -1; - for(int i=0;i<k;i++) { - for(int j=0;j<n;j++) { - int mem = -1; - if(G[i*n+j]!=0) - mem=(int)(log(double(G[i*n+j]))/log(2.0)); - if(mem>max_mem_x[i]) - max_mem_x[i]=mem; - if(mem>max_mem) - max_mem=mem; - } - } - -//printf("max_mem_x\n"); -//for(int j=0;j<max_mem_x.size();j++) printf("%d ",max_mem_x[j]); printf("\n"); - - // calculate total memory requirements to set S - int sum_max_mem = 0; - for(int i=0;i<k;i++) - sum_max_mem += max_mem_x[i]; - -//printf("sum_max_mem = %d\n",sum_max_mem); - - d_I=1<<k; - d_S=1<<sum_max_mem; - d_O=1<<n; - - // binary representation of the G matrix - std::vector<std::vector<int> > Gb(k*n); - for(int j=0;j<k*n;j++) { - Gb[j].resize(max_mem+1); - dec2base(G[j],2,Gb[j]); -//printf("Gb\n"); -//for(int m=0;m<Gb[j].size();m++) printf("%d ",Gb[j][m]); printf("\n"); - } - - // alphabet size of each shift register - std::vector<int> bases_x(k); - for(int j=0;j<k ;j++) - bases_x[j] = 1 << max_mem_x[j]; -//printf("bases_x\n"); -//for(int j=0;j<max_mem_x.size();j++) printf("%d ",max_mem_x[j]); printf("\n"); - - d_NS.resize(d_I*d_S); - d_OS.resize(d_I*d_S); - - std::vector<int> sx(k); - std::vector<int> nsx(k); - std::vector<int> tx(k); - std::vector<std::vector<int> > tb(k); - for(int j=0;j<k;j++) - tb[j].resize(max_mem+1); - std::vector<int> inb(k); - std::vector<int> outb(n); - - - for(int s=0;s<d_S;s++) { - dec2bases(s,bases_x,sx); // split s into k values, each representing one of the k shift registers -//printf("state = %d \nstates = ",s); -//for(int j=0;j<sx.size();j++) printf("%d ",sx[j]); printf("\n"); - for(int i=0;i<d_I;i++) { - dec2base(i,2,inb); // input in binary -//printf("input = %d \ninputs = ",i); -//for(int j=0;j<inb.size();j++) printf("%d ",inb[j]); printf("\n"); - - // evaluate next state - for(int j=0;j<k;j++) - nsx[j] = (inb[j]*bases_x[j]+sx[j])/2; // next state (for each shift register) MSB first - d_NS[s*d_I+i]=bases2dec(nsx,bases_x); // collect all values into the new state - - // evaluate transitions - for(int j=0;j<k;j++) - tx[j] = inb[j]*bases_x[j]+sx[j]; // transition (for each shift register)MSB first - for(int j=0;j<k;j++) { - dec2base(tx[j],2,tb[j]); // transition in binary -//printf("transition = %d \ntransitions = ",tx[j]); -//for(int m=0;m<tb[j].size();m++) printf("%d ",tb[j][m]); printf("\n"); - } - - // evaluate outputs - for(int nn=0;nn<n;nn++) { - outb[nn] = 0; - for(int j=0;j<k;j++) { - for(int m=0;m<max_mem+1;m++) - outb[nn] = (outb[nn] + Gb[j*n+nn][m]*tb[j][m]) % 2; // careful: polynomial 1+D ir represented as 110, not as 011 -//printf("output %d equals %d\n",nn,outb[nn]); - } - } - d_OS[s*d_I+i] = base2dec(outb,2); - } - } - - generate_PS_PI(); - generate_TM(); -} - - - - -//###################################################################### -//# Automatically generate an FSM specification describing the -//# ISI for a channel -//# of length ch_length and a modulation of size mod_size -//###################################################################### -fsm::fsm(int mod_size, int ch_length) -{ - d_I=mod_size; - d_S=(int) (pow(1.0*d_I,1.0*ch_length-1)+0.5); - d_O=d_S*d_I; - - d_NS.resize(d_I*d_S); - d_OS.resize(d_I*d_S); - - for(int s=0;s<d_S;s++) { - for(int i=0;i<d_I;i++) { - int t=i*d_S+s; - d_NS[s*d_I+i] = t/d_I; - d_OS[s*d_I+i] = t; - } - } - - generate_PS_PI(); - generate_TM(); -} - - - - -//###################################################################### -//# Automatically generate an FSM specification describing the -//# the trellis for a CPM with h=K/P (relatively prime), -//# alphabet size M, and frequency pulse duration L symbols -//# -//# This FSM is based on the paper by B. Rimoldi -//# "A decomposition approach to CPM", IEEE Trans. Info Theory, March 1988 -//# See also my own notes at http://www.eecs.umich.edu/~anastas/docs/cpm.pdf -//###################################################################### -fsm::fsm(int P, int M, int L) -{ - d_I=M; - d_S=(int)(pow(1.0*M,1.0*L-1)+0.5)*P; - d_O=(int)(pow(1.0*M,1.0*L)+0.5)*P; - - d_NS.resize(d_I*d_S); - d_OS.resize(d_I*d_S); - int nv; - for(int s=0;s<d_S;s++) { - for(int i=0;i<d_I;i++) { - int s1=s/P; - int v=s%P; - int ns1= (i*(int)(pow(1.0*M,1.0*(L-1))+0.5)+s1)/M; - if (L==1) - nv=(i+v)%P; - else - nv=(s1%M+v)%P; - d_NS[s*d_I+i] = ns1*P+nv; - d_OS[s*d_I+i] = i*d_S+s; - } - } - - generate_PS_PI(); - generate_TM(); -} - - - - - - - - - - -//###################################################################### -//# Automatically generate an FSM specification describing the -//# the joint trellis of fsm1 and fsm2 -//###################################################################### -fsm::fsm(const fsm &FSM1, const fsm &FSM2) -{ - d_I=FSM1.I()*FSM2.I(); - d_S=FSM1.S()*FSM2.S(); - d_O=FSM1.O()*FSM2.O(); - - d_NS.resize(d_I*d_S); - d_OS.resize(d_I*d_S); - - for(int s=0;s<d_S;s++) { - for(int i=0;i<d_I;i++) { - int s1=s/FSM2.S(); - int s2=s%FSM2.S(); - int i1=i/FSM2.I(); - int i2=i%FSM2.I(); - d_NS[s*d_I+i] = FSM1.NS()[s1 * FSM1.I() + i1] * FSM2.S() + FSM2.NS()[s2 * FSM2.I() + i2]; - d_OS[s*d_I+i] = FSM1.OS()[s1 * FSM1.I() + i1] * FSM2.O() + FSM2.OS()[s2 * FSM2.I() + i2]; - } - } - - generate_PS_PI(); - generate_TM(); -} - - - - -//###################################################################### -//# Generate a new FSM representing n stages through the original FSM -//# AKA radix-n FSM -//###################################################################### -fsm::fsm(const fsm &FSM, int n) -{ - d_I=(int) (pow(1.0*FSM.I(),1.0*n)+0.5); - d_S=FSM.S(); - d_O=(int) (pow(1.0*FSM.O(),1.0*n)+0.5); - - d_NS.resize(d_I*d_S); - d_OS.resize(d_I*d_S); - - for(int s=0;s<d_S;s++ ) { - for(int i=0;i<d_I;i++ ) { - std::vector<int> ii(n); - dec2base(i,FSM.I(),ii); - std::vector<int> oo(n); - int ns=s; - for(int k=0;k<n;k++) { - oo[k]=FSM.OS()[ns*FSM.I()+ii[k]]; - ns=FSM.NS()[ns*FSM.I()+ii[k]]; - } - d_NS[s*d_I+i]=ns; - d_OS[s*d_I+i]=base2dec(oo,FSM.O()); - } - } - - generate_PS_PI(); - generate_TM(); -} - - - - - - - - - -//###################################################################### -//# generate the PS and PI tables for later use -//###################################################################### -void fsm::generate_PS_PI() -{ - d_PS.resize(d_S); - d_PI.resize(d_S); - - for(int i=0;i<d_S;i++) { - d_PS[i].resize(d_I*d_S); // max possible size - d_PI[i].resize(d_I*d_S); - int j=0; - for(int ii=0;ii<d_S;ii++) for(int jj=0;jj<d_I;jj++) { - if(d_NS[ii*d_I+jj]!=i) continue; - d_PS[i][j]=ii; - d_PI[i][j]=jj; - j++; - } - d_PS[i].resize(j); - d_PI[i].resize(j); - } -} - - -//###################################################################### -//# generate the termination matrices TMl and TMi for later use -//###################################################################### -void fsm::generate_TM() -{ - d_TMi.resize(d_S*d_S); - d_TMl.resize(d_S*d_S); - - for(int i=0;i<d_S*d_S;i++) { - d_TMi[i] = -1; // no meaning - d_TMl[i] = d_S; //infinity: you need at most S-1 steps - if (i/d_S == i%d_S) - d_TMl[i] = 0; - } - - for(int s=0;s<d_S;s++) { - bool done = false; - int attempts = 0; - while (done == false && attempts < d_S-1) { - done = find_es(s); - attempts ++; - } - if (done == false && d_S > 1) { - //throw std::runtime_error ("fsm::generate_TM(): FSM appears to be disconnected\n"); - printf("fsm::generate_TM(): FSM appears to be disconnected\n"); - printf("state %d cannot be reached from all other states\n",s); - } - } -} - - -// find a path from any state to the ending state "es" -bool fsm::find_es(int es) -{ - bool done = true; - for(int s=0;s<d_S;s++) { - if(d_TMl[s*d_S+es] < d_S) - continue; - int minl=d_S; - int mini=-1; - for(int i=0;i<d_I;i++) { - if( 1 + d_TMl[d_NS[s*d_I+i]*d_S+es] < minl) { - minl = 1 + d_TMl[d_NS[s*d_I+i]*d_S+es]; - mini = i; - } - } - if (mini != -1) { - d_TMl[s*d_S+es]=minl; - d_TMi[s*d_S+es]=mini; - } - else - done = false; - } - return done; -} - - - - - -//###################################################################### -//# generate trellis representation of FSM as an SVG file -//###################################################################### -void fsm::write_trellis_svg( std::string filename ,int number_stages) -{ - std::ofstream trellis_fname (filename.c_str()); - if (!trellis_fname) {std::cout << "file not found " << std::endl ; exit(-1);} - const int TRELLIS_Y_OFFSET = 30; - const int TRELLIS_X_OFFSET = 20; - const int STAGE_LABEL_Y_OFFSET = 25; - const int STAGE_LABEL_X_OFFSET = 20; - const int STATE_LABEL_Y_OFFSET = 30; - const int STATE_LABEL_X_OFFSET = 5; - const int STAGE_STATE_OFFSETS = 10; -// std::cout << "################## BEGIN SVG TRELLIS PIC #####################" << std::endl; - trellis_fname << "<svg viewBox = \"0 0 200 200\" version = \"1.1\">" << std::endl; - - for( int stage_num = 0;stage_num < number_stages;stage_num ++){ - // draw states - for ( int state_num = 0;state_num < d_S ; state_num ++ ) { - trellis_fname << "<circle cx = \"" << stage_num * STAGE_STATE_OFFSETS + TRELLIS_X_OFFSET << - "\" cy = \"" << state_num * STAGE_STATE_OFFSETS + TRELLIS_Y_OFFSET << "\" r = \"1\"/>" << std::endl; - //draw branches - if(stage_num != number_stages-1){ - for( int branch_num = 0;branch_num < d_I; branch_num++){ - trellis_fname << "<line x1 =\"" << STAGE_STATE_OFFSETS * stage_num+ TRELLIS_X_OFFSET << "\" "; - trellis_fname << "y1 =\"" << state_num * STAGE_STATE_OFFSETS + TRELLIS_Y_OFFSET<< "\" "; - trellis_fname << "x2 =\"" << STAGE_STATE_OFFSETS *stage_num + STAGE_STATE_OFFSETS+ TRELLIS_X_OFFSET << "\" "; - trellis_fname << "y2 =\"" << d_NS[d_I * state_num + branch_num] * STAGE_STATE_OFFSETS + TRELLIS_Y_OFFSET << "\" "; - trellis_fname << " stroke-dasharray = \"3," << branch_num << "\" "; - trellis_fname << " stroke = \"black\" stroke-width = \"0.3\"/>" << std::endl; - } - } - } - } - // label the stages - trellis_fname << "<g font-size = \"4\" font= \"times\" fill = \"black\">" << std::endl; - for( int stage_num = 0;stage_num < number_stages ;stage_num ++){ - trellis_fname << "<text x = \"" << stage_num * STAGE_STATE_OFFSETS + STAGE_LABEL_X_OFFSET << - "\" y = \"" << STAGE_LABEL_Y_OFFSET << "\" >" << std::endl; - trellis_fname << stage_num << std::endl; - trellis_fname << "</text>" << std::endl; - } - trellis_fname << "</g>" << std::endl; - - // label the states - trellis_fname << "<g font-size = \"4\" font= \"times\" fill = \"black\">" << std::endl; - for( int state_num = 0;state_num < d_S ; state_num ++){ - trellis_fname << "<text y = \"" << state_num * STAGE_STATE_OFFSETS + STATE_LABEL_Y_OFFSET << - "\" x = \"" << STATE_LABEL_X_OFFSET << "\" >" << std::endl; - trellis_fname << state_num << std::endl; - trellis_fname << "</text>" << std::endl; - } - trellis_fname << "</g>" << std::endl; - - - trellis_fname << "</svg>" << std::endl; -// std::cout << "################## END SVG TRELLIS PIC ##################### " << std::endl; - trellis_fname.close(); -} - - - - - - -//###################################################################### -//# Write trellis specification to a text file, -//# in the same format used when reading FSM files -//###################################################################### -void fsm::write_fsm_txt(std::string filename) -{ - std::ofstream trellis_fname (filename.c_str()); - if (!trellis_fname) {std::cout << "file not found " << std::endl ; exit(-1);} - trellis_fname << d_I << ' ' << d_S << ' ' << d_O << std::endl; - trellis_fname << std::endl; - for(int i=0;i<d_S;i++) { - for(int j=0;j<d_I;j++) trellis_fname << d_NS[i*d_I+j] << ' '; - trellis_fname << std::endl; - } - trellis_fname << std::endl; - for(int i=0;i<d_S;i++) { - for(int j=0;j<d_I;j++) trellis_fname << d_OS[i*d_I+j] << ' '; - trellis_fname << std::endl; - } - trellis_fname << std::endl; - trellis_fname.close(); -} - diff --git a/gr-trellis/src/lib/fsm.h b/gr-trellis/src/lib/fsm.h deleted file mode 100644 index 47e467898a..0000000000 --- a/gr-trellis/src/lib/fsm.h +++ /dev/null @@ -1,166 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2011 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_TRELLIS_FSM_H -#define INCLUDED_TRELLIS_FSM_H - -#include <trellis_api.h> -#include <vector> -#include <iosfwd> - -/*! - * \brief Finite State Machine Specification class. - * - * An instance of this class represents a finite state machine specification (FSMS) - * rather than the FSM itself. It particular the state of the FSM - * is not stored within an instance of this class. - */ -class TRELLIS_API fsm { -private: - // Input alphabet cardinality. - int d_I; - // Number of states. - int d_S; - // Output alphabet cardinality. - int d_O; - // NS means Next State. - // next_state = d_NS[current_state * d_I + input_symbol] - std::vector<int> d_NS; - // OS means Output Symbol. - // output_symbol = d_OS[current_state * d_I + input_symbol] - std::vector<int> d_OS; - // PS means Previous State. - std::vector< std::vector<int> > d_PS; - // PI means Previous Input Symbol. - // d_PS[current_state][k] and d_PI[current_state][k], is a pair of the form - // (previous_state, previous_input_symbol) that could have produced the - // current state. - std::vector< std::vector<int> > d_PI; - // TM means Termination matrix. - // d_TMl[s*d_S+es] is the shortest number of steps to get from state s to - // state es. - std::vector<int> d_TMl; - // d_TMi[s*d_S+es] is the input symbol required to set off on the shortest - // path from state s to es. - std::vector<int> d_TMi; - void generate_PS_PI (); - void generate_TM (); - bool find_es(int es); -public: - /*! - * \brief Constructor to create an uninitialized FSMS. - */ - fsm(); - /*! - * \brief Constructor to copy an FSMS. - */ - fsm(const fsm &FSM); - /*! - * \brief Constructor to to create an FSMS. - * - * \param I The number of possible input symbols. - * \param S The number of possible FSM states. - * \param O The number of possible output symbols. - * \param NS A mapping from (current state, input symbol) to next state. - * next_state = NS[current_state * I + input_symbol] - * \param OS A mapping from (current state, input symbol) to output symbol. - * output_symbol = OS[current_state * I + input_symbol] - * - */ - fsm(int I, int S, int O, const std::vector<int> &NS, const std::vector<int> &OS); - /*! - * \brief Constructor to create an FSMS from file contents. - * - * \param name filename - * - */ - fsm(const char *name); - /*! - * \brief Creates an FSMS from the generator matrix of a (n, k) binary convolutional code. - * - * \param k ??? - * \param n ??? - * \param G ??? - * - */ - fsm(int k, int n, const std::vector<int> &G); - /*! - * \brief Creates an FSMS describing ISI. - * - * \param mod_size modulation size - * \param ch_length channel length - * - */ - fsm(int mod_size, int ch_length); - /*! - * \brief Creates an FSMS describing the trellis for a CPM. - * - * \param P ???? h=K/P (relatively prime) - * \param M alphabet size - * \param L pulse duration - * - * This FSM is based on the paper by B. Rimoldi - * "A decomposition approach to CPM", IEEE Trans. Info Theory, March 1988 - * See also my own notes at http://www.eecs.umich.edu/~anastas/docs/cpm.pdf - */ - fsm(int P, int M, int L); - /*! - * \brief Creates an FSMS describing the joint trellis of two FSMs. - * - * \param FSM1 first FSMS - * \param FSM2 second FSMS - */ - fsm(const fsm &FSM1, const fsm &FSM2); - /*! - * \brief Creates an FSMS representing n stages through the originial FSM (AKA radix-n FSM). - * - * \param FSM Original FSMs - * \param n Number of stages. - */ - fsm(const fsm &FSM, int n); - int I () const { return d_I; } - int S () const { return d_S; } - int O () const { return d_O; } - const std::vector<int> & NS () const { return d_NS; } - const std::vector<int> & OS () const { return d_OS; } - const std::vector< std::vector<int> > & PS () const { return d_PS; } - const std::vector< std::vector<int> > & PI () const { return d_PI; } - const std::vector<int> & TMi () const { return d_TMi; } - const std::vector<int> & TMl () const { return d_TMl; } - /*! - * \brief Creates an svg image of the trellis representation. - * - * \param filename filename - * \param number_stages ???? - * - */ - void write_trellis_svg(std::string filename ,int number_stages); - /*! - * \brief Write the FSMS to a file. - * - * \param filename filename - * - */ - void write_fsm_txt(std::string filename); -}; - -#endif diff --git a/gr-trellis/src/lib/fsm.i b/gr-trellis/src/lib/fsm.i deleted file mode 100644 index 1e9c7ad8f5..0000000000 --- a/gr-trellis/src/lib/fsm.i +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -class fsm { -private: - int d_I; - int d_S; - int d_O; - std::vector<int> d_NS; - std::vector<int> d_OS; - std::vector< std::vector<int> > d_PS; - std::vector< std::vector<int> > d_PI; - std::vector<int> d_TMi; - std::vector<int> d_TMl; - void generate_PS_PI (); - void generate_TM (); -public: - fsm(); - fsm(const fsm &FSM); - fsm(int I, int S, int O, const std::vector<int> &NS, const std::vector<int> &OS); - fsm(const char *name); - fsm(int k, int n, const std::vector<int> &G); - fsm(int mod_size, int ch_length); - fsm(int P, int M, int L); - fsm(const fsm &FSM1, const fsm &FSM2); - fsm(const fsm &FSM, int n); - int I () const { return d_I; } - int S () const { return d_S; } - int O () const { return d_O; } - const std::vector<int> & NS () const { return d_NS; } - const std::vector<int> & OS () const { return d_OS; } - // disable these accessors until we find out how to swig them - //const std::vector< std::vector<int> > & PS () const { return d_PS; } - //const std::vector< std::vector<int> > & PI () const { return d_PI; } - const std::vector<int> & TMi () const { return d_TMi; } - const std::vector<int> & TMl () const { return d_TMl; } - void fsm::write_trellis_svg(std::string filename ,int number_stages); - void fsm::write_fsm_txt(std::string filename); -}; - diff --git a/gr-trellis/src/lib/generate_trellis.py b/gr-trellis/src/lib/generate_trellis.py deleted file mode 100644 index 60a81f77a8..0000000000 --- a/gr-trellis/src/lib/generate_trellis.py +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,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 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 build_utils import expand_template, copyright, open_and_log_name -from build_utils_codes import * -import re - -# regular blocks - -other_roots = [ - 'trellis_encoder_XX', - 'trellis_sccc_encoder_XX', - 'trellis_pccc_encoder_XX', - 'trellis_metrics_X', - 'trellis_viterbi_X', - 'trellis_viterbi_combined_XX', - 'trellis_sccc_decoder_X', - 'trellis_sccc_decoder_combined_XX', - 'trellis_pccc_decoder_X', - 'trellis_pccc_decoder_combined_XX', - ] - -other_signatures = ( - ['bb','bs','bi','ss','si','ii'], - ['bb','bs','bi','ss','si','ii'], - ['bb','bs','bi','ss','si','ii'], - ['s','i','f','c'], - ['b','s','i'], - ['sb','ss','si','ib','is','ii','fb','fs','fi','cb','cs','ci'], - ['b','s','i'], - ['fb','fs','fi','cb','cs','ci'], - ['b','s','i'], - ['fb','fs','fi','cb','cs','ci'], - ) - - -def is_byte (code3): - if i_code (code3) == 'b' or o_code (code3) == 'b': - return '1' - else: - return '0' - - -def is_short (code3): - if i_code (code3) == 's' or o_code (code3) == 's': - return '1' - else: - return '0' - - -def is_int (code3): - if i_code (code3) == 'i' or o_code (code3) == 'i': - return '1' - else: - return '0' - - -def is_float (code3): - if i_code (code3) == 'f' or o_code (code3) == 'f': - return '1' - else: - return '0' - - -def is_complex (code3): - if i_code (code3) == 'c' or o_code (code3) == 'c': - return '1' - else: - return '0' - - -def standard_dict (name, code3): - d = {} - d['NAME'] = name - d['GUARD_NAME'] = 'INCLUDED_%s_H' % name.upper () - d['BASE_NAME'] = re.sub ('^trellis_', '', name) - d['SPTR_NAME'] = '%s_sptr' % name - d['WARNING'] = 'WARNING: this file is machine generated. Edits will be over written' - d['COPYRIGHT'] = copyright - d['TYPE'] = i_type (code3) - d['I_TYPE'] = i_type (code3) - d['O_TYPE'] = o_type (code3) - d['TAP_TYPE'] = tap_type (code3) - d['IS_BYTE'] = is_byte (code3) - d['IS_SHORT'] = is_short (code3) - d['IS_INT'] = is_int (code3) - d['IS_FLOAT'] = is_float (code3) - d['IS_COMPLEX'] = is_complex (code3) - return d - - -def expand_h_cc_i (root, sig): - # root looks like 'gr_vector_sink_X' - name = re.sub ('X+', sig, root) - d = standard_dict (name, sig) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - expand_template (d, root + '.i.t') - - -def generate (): - i=0 - for r in other_roots : - for s in other_signatures[i]: - expand_h_cc_i (r, s) - i=i+1 - - -if __name__ == '__main__': - generate () diff --git a/gr-trellis/src/lib/interleaver.cc b/gr-trellis/src/lib/interleaver.cc deleted file mode 100644 index 740f33ab39..0000000000 --- a/gr-trellis/src/lib/interleaver.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -#include <cstdlib> -#include <cstdio> -#include <iostream> -#include <string> -#include <fstream> -#include <stdexcept> -#include <cmath> -#include "quicksort_index.h" -#include "interleaver.h" - - - - -interleaver::interleaver() -{ - d_K=0; - d_INTER.resize(0); - d_DEINTER.resize(0); -} - -interleaver::interleaver(const interleaver &INTERLEAVER) -{ - d_K=INTERLEAVER.K(); - d_INTER=INTERLEAVER.INTER(); - d_DEINTER=INTERLEAVER.DEINTER(); -} - -interleaver::interleaver(int K, const std::vector<int> &INTER) -{ - d_K=K; - d_INTER=INTER; - d_DEINTER.resize(d_K); - - // generate DEINTER table - for(int i=0;i<d_K;i++) { - d_DEINTER[d_INTER[i]]=i; - } -} - -//###################################################################### -//# Read an INTERLEAVER specification from a file. -//# Format (hopefully will become more flexible in the future...): -//# K -//# blank line -//# list of space separated K integers from 0 to K-1 in appropriate order -//# optional comments -//###################################################################### -interleaver::interleaver(const char *name) -{ - FILE *interleaverfile; - - if((interleaverfile=fopen(name,"r"))==NULL) - throw std::runtime_error ("file open error in interleaver()"); - //printf("file open error in interleaver()\n"); - - if(fscanf(interleaverfile,"%d\n",&d_K) == EOF) { - if(ferror(interleaverfile) != 0) - throw std::runtime_error ("interleaver::interleaver(const char *name): file read error\n"); - } - - d_INTER.resize(d_K); - d_DEINTER.resize(d_K); - - for(int i=0;i<d_K;i++) { - if(fscanf(interleaverfile,"%d",&(d_INTER[i])) == EOF) { - if(ferror(interleaverfile) != 0) - throw std::runtime_error ("interleaver::interleaver(const char *name): file read error\n"); - } - } - - // generate DEINTER table - for(int i=0;i<d_K;i++) { - d_DEINTER[d_INTER[i]]=i; - } -} - -//###################################################################### -//# Generate a random interleaver -//###################################################################### -interleaver::interleaver(int K, int seed) -{ - d_K=K; - d_INTER.resize(d_K); - d_DEINTER.resize(d_K); - - if(seed>=0) srand((unsigned int)seed); - std::vector<int> tmp(d_K); - for(int i=0;i<d_K;i++) { - d_INTER[i]=i; - tmp[i] = rand(); - } - quicksort_index <int> (tmp,d_INTER,0,d_K-1); - - // generate DEINTER table - for(int i=0;i<d_K;i++) { - d_DEINTER[d_INTER[i]]=i; - } -} - - - - - -//###################################################################### -//# Write an INTERLEAVER specification to a file. -//# Format -//# K -//# blank line -//# list of space separated K integers from 0 to K-1 in appropriate order -//# optional comments -//###################################################################### -void interleaver::write_interleaver_txt(std::string filename) -{ - std::ofstream interleaver_fname (filename.c_str()); - if (!interleaver_fname) {std::cout << "file not found " << std::endl ; exit(-1);} - interleaver_fname << d_K << std::endl; - interleaver_fname << std::endl; - for(int i=0;i<d_K;i++) - interleaver_fname << d_INTER[i] << ' '; - interleaver_fname << std::endl; - interleaver_fname.close(); -} diff --git a/gr-trellis/src/lib/interleaver.i b/gr-trellis/src/lib/interleaver.i deleted file mode 100644 index bb9078b1bd..0000000000 --- a/gr-trellis/src/lib/interleaver.i +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -class interleaver { -private: - int d_K; - std::vector<int> d_INTER; - std::vector<int> d_DEINTER; -public: - interleaver(); - interleaver(const interleaver & INTERLEAVER); - interleaver(int K, const std::vector<int> & INTER); - interleaver(const char *name); - interleaver(int K, int seed); - int K () const { return d_K; } - const std::vector<int> & INTER () const { return d_INTER; } - const std::vector<int> & DEINTER () const { return d_DEINTER; } - void write_interleaver_txt(std::string filename); -}; diff --git a/gr-trellis/src/lib/quicksort_index.cc b/gr-trellis/src/lib/quicksort_index.cc deleted file mode 100644 index cf37e862e2..0000000000 --- a/gr-trellis/src/lib/quicksort_index.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- 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. - */ - -#include "quicksort_index.h" - -template <class T> -void -SWAP -(T & a, T & b) -{ - T temp = a; - a = b; - b = temp; -} - -template <class T> -void -quicksort_index -(std::vector<T> & p, std::vector<int> & index, int left, int right) -{ - if (left < right) { - int i = left; - int j = right + 1; - T pivot = p[left]; - do { - do - i++; - while ((p[i] < pivot) && (i < right)); - do - j--; - while ((p[j] > pivot) && (j > left)); - if (i < j) { - SWAP <T> (p[i],p[j]); - SWAP <int> (index[i],index[j]); - } - } while (i < j); - SWAP <T> (p[left], p[j]); - SWAP <int> (index[left], index[j]); - quicksort_index <T> (p,index, left, j-1); - quicksort_index <T> (p,index, j+1, right); - } -} - -// instantiate an <int> version of the quicksort_index -//template <int> void SWAP (int & a, int & b); -template -void -quicksort_index<int> -(std::vector<int> & p, std::vector<int> & index, int left, int right); diff --git a/gr-trellis/src/lib/trellis.i b/gr-trellis/src/lib/trellis.i deleted file mode 100644 index d0b3707d05..0000000000 --- a/gr-trellis/src/lib/trellis.i +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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. - */ -%module(docstring="Generic coding/decoding.") trellis - -#define DIGITAL_API - -%include "gnuradio.i" // the common stuff - -//load generated python docstrings -%include "trellis_swig_doc.i" - -%{ -#include "digital/constellation.h" -#include "digital/metric_type.h" -#include "fsm.h" -#include "interleaver.h" -#include "trellis_permutation.h" -#include "trellis_siso_f.h" -#include "trellis_siso_combined_f.h" -#include "trellis_constellation_metrics_cf.h" -%} - -%include "digital/constellation.h" -%include "digital/metric_type.h" -%include "constellation.i" - -// ---------------------------------------------------------------- - -%include "fsm.i" -%include "interleaver.i" -%include "trellis_permutation.i" -%include "trellis_siso_f.i" -%include "trellis_siso_combined_f.i" - -%include "siso_type.h" - -%include "trellis_constellation_metrics_cf.i" - -%include "trellis_generated.i" diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc b/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc deleted file mode 100644 index d7a7aba1d4..0000000000 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2011 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <trellis_constellation_metrics_cf.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <stdexcept> -#include <iostream> - -trellis_constellation_metrics_cf_sptr -trellis_make_constellation_metrics_cf(constellation_sptr constellation, - trellis_metric_type_t TYPE) -{ - return gnuradio::get_initial_sptr - (new trellis_constellation_metrics_cf(constellation, TYPE)); -} - - -trellis_constellation_metrics_cf::trellis_constellation_metrics_cf(constellation_sptr constellation, - trellis_metric_type_t TYPE) - : gr_block ("constellation_metrics_cf", - gr_make_io_signature (1, -1, sizeof (gr_complex)), - gr_make_io_signature (1, -1, sizeof (float))), - d_constellation (constellation), - d_TYPE (TYPE), - d_O (constellation->arity()), - d_D (constellation->dimensionality()) -{ - set_relative_rate (1.0 * d_O / ((double) d_D)); - set_output_multiple ((int)d_O); -} - -void -trellis_constellation_metrics_cf::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - assert (noutput_items % d_O == 0); - unsigned int input_required = d_D * noutput_items / d_O; - unsigned int ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) - ninput_items_required[i] = input_required; -} - - - -int -trellis_constellation_metrics_cf::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - - assert (noutput_items % d_O == 0); - assert (input_items.size() == output_items.size()); - unsigned int nstreams = input_items.size(); - -for (unsigned int m=0;m<nstreams;m++) { - const gr_complex *in = (gr_complex *) input_items[m]; - float *out = (float *) output_items[m]; - - for (unsigned int i = 0; i < noutput_items / d_O ; i++){ - d_constellation->calc_metric(&(in[i*d_D]), &(out[i*d_O]), d_TYPE); - } -} - - consume_each (d_D * noutput_items / d_O); - return noutput_items; -} diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h deleted file mode 100644 index 91ab30986b..0000000000 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2011 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_TRELLIS_CONSTELLATION_METRICS_CF_H -#define INCLUDED_TRELLIS_CONSTELLATION_METRICS_CF_H - -#include <trellis_api.h> -#include <gr_block.h> -#include <digital/constellation.h> -#include <digital/metric_type.h> - -using namespace gr::digital; - -class trellis_constellation_metrics_cf; -typedef boost::shared_ptr<trellis_constellation_metrics_cf> trellis_constellation_metrics_cf_sptr; - -TRELLIS_API trellis_constellation_metrics_cf_sptr - trellis_make_constellation_metrics_cf(constellation_sptr constellation, - trellis_metric_type_t TYPE); - -/*! - * \brief Evaluate metrics for use by the Viterbi algorithm. - * \ingroup coding_blk - */ -class TRELLIS_API trellis_constellation_metrics_cf : public gr_block -{ - public: - void forecast(int noutput_items, - gr_vector_int &ninput_items_required); - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - protected: - trellis_constellation_metrics_cf(constellation_sptr constellation, - trellis_metric_type_t TYPE); - - private: - constellation_sptr d_constellation; - trellis_metric_type_t d_TYPE; - unsigned int d_O; - unsigned int d_D; - friend TRELLIS_API trellis_constellation_metrics_cf_sptr - trellis_make_constellation_metrics_cf(constellation_sptr constellation, - trellis_metric_type_t TYPE); - -}; - - -#endif diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.i b/gr-trellis/src/lib/trellis_constellation_metrics_cf.i deleted file mode 100644 index 13b11c0b06..0000000000 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(trellis,constellation_metrics_cf); - -trellis_constellation_metrics_cf_sptr -trellis_make_constellation_metrics_cf(gr::digital::constellation_sptr constellation, - gr::digital::trellis_metric_type_t TYPE); - -class trellis_constellation_metrics_cf : public gr_block -{ -}; diff --git a/gr-trellis/src/lib/trellis_encoder_XX.cc.t b/gr-trellis/src/lib/trellis_encoder_XX.cc.t deleted file mode 100644 index dca92b08f3..0000000000 --- a/gr-trellis/src/lib/trellis_encoder_XX.cc.t +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <@NAME@.h> -#include <gr_io_signature.h> -#include <iostream> - -@SPTR_NAME@ -trellis_make_@BASE_NAME@ (const fsm &FSM, int ST) -{ - return gnuradio::get_initial_sptr (new @NAME@ (FSM,ST)); -} - -@NAME@::@NAME@ (const fsm &FSM, int ST) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, -1, sizeof (@O_TYPE@))), - d_FSM (FSM), - d_ST (ST) -{ -} - - - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - int ST_tmp=0; - - assert (input_items.size() == output_items.size()); - int nstreams = input_items.size(); - - for (int m=0;m<nstreams;m++) { - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[m]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[m]; - ST_tmp = d_ST; - - // per stream processing - for (int i = 0; i < noutput_items; i++){ - out[i] = (@O_TYPE@) d_FSM.OS()[ST_tmp*d_FSM.I()+in[i]]; // direction of time? - ST_tmp = (int) d_FSM.NS()[ST_tmp*d_FSM.I()+in[i]]; - } - // end per stream processing - } - d_ST = ST_tmp; - - return noutput_items; -} - diff --git a/gr-trellis/src/lib/trellis_encoder_XX.h.t b/gr-trellis/src/lib/trellis_encoder_XX.h.t deleted file mode 100644 index 7c4250a929..0000000000 --- a/gr-trellis/src/lib/trellis_encoder_XX.h.t +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <trellis_api.h> -#include "fsm.h" -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, int ST); - -/*! - * \brief Convolutional encoder. - * \ingroup coding_blk - */ -class TRELLIS_API @NAME@ : public gr_sync_block -{ -private: - friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, int ST); - fsm d_FSM; - int d_ST; - @NAME@ (const fsm &FSM, int ST); - -public: - fsm FSM () const { return d_FSM; } - int ST () const { return d_ST; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-trellis/src/lib/trellis_encoder_XX.i.t b/gr-trellis/src/lib/trellis_encoder_XX.i.t deleted file mode 100644 index 29c9c4db33..0000000000 --- a/gr-trellis/src/lib/trellis_encoder_XX.i.t +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); - -@SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, int ST); - -class @NAME@ : public gr_sync_block -{ -private: - @NAME@ (const fsm &FSM, int ST); -public: - fsm FSM () const { return d_FSM; } - int ST () const { return d_ST; } -}; diff --git a/gr-trellis/src/lib/trellis_metrics_X.cc.t b/gr-trellis/src/lib/trellis_metrics_X.cc.t deleted file mode 100644 index 756ac92a31..0000000000 --- a/gr-trellis/src/lib/trellis_metrics_X.cc.t +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <@NAME@.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <stdexcept> -#include <iostream> - - -@SPTR_NAME@ -trellis_make_@BASE_NAME@(int O, int D, const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE) -{ - return gnuradio::get_initial_sptr(new @NAME@(O,D,TABLE,TYPE)); -} - - - -@NAME@::@NAME@(int O, int D, const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE) - : gr_block("@BASE_NAME@", - gr_make_io_signature(1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature(1, -1, sizeof (float))), - d_O (O), - d_D (D), - d_TYPE (TYPE), - d_TABLE (TABLE) -{ - set_relative_rate (1.0 * d_O / ((double) d_D)); - set_output_multiple ((int)d_O); -} - -void @NAME@::set_TABLE(const std::vector<@I_TYPE@> &table) -{ - d_TABLE = table; -} - - -void -@NAME@::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - assert (noutput_items % d_O == 0); - int input_required = d_D * noutput_items / d_O; - unsigned ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) - ninput_items_required[i] = input_required; -} - - - -int -@NAME@::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert (noutput_items % d_O == 0); - assert (input_items.size() == output_items.size()); - int nstreams = input_items.size(); - - for (int m=0;m<nstreams;m++) { - const @I_TYPE@ *in = (@I_TYPE@ *) input_items[m]; - float *out = (float *) output_items[m]; - - for(int i = 0; i < noutput_items / d_O ; i++) { - calc_metric(d_O, d_D, d_TABLE,&(in[i*d_D]),&(out[i*d_O]), d_TYPE); - } - } - - consume_each(d_D * noutput_items / d_O); - return noutput_items; -} diff --git a/gr-trellis/src/lib/trellis_metrics_X.h.t b/gr-trellis/src/lib/trellis_metrics_X.h.t deleted file mode 100644 index 9a671bc121..0000000000 --- a/gr-trellis/src/lib/trellis_metrics_X.h.t +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <trellis_api.h> -#include <gr_block.h> -#include "calc_metric.h" - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@(int O, int D, const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - -/*! - * \brief Evaluate metrics for use by the Viterbi algorithm. - * \ingroup coding_blk - */ -class TRELLIS_API @NAME@ : public gr_block -{ - int d_O; - int d_D; - gr::digital::trellis_metric_type_t d_TYPE; - std::vector<@I_TYPE@> d_TABLE; - - friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@(int O, int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - @NAME@(int O, int D, const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - -public: - int O() const { return d_O; } - int D() const { return d_D; } - gr::digital::trellis_metric_type_t TYPE() const { return d_TYPE; } - std::vector<@I_TYPE@> TABLE() const { return d_TABLE; } - void set_TABLE(const std::vector<@I_TYPE@> &table); - void forecast(int noutput_items, - gr_vector_int &ninput_items_required); - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gr-trellis/src/lib/trellis_metrics_X.i.t b/gr-trellis/src/lib/trellis_metrics_X.i.t deleted file mode 100644 index b53594f3a6..0000000000 --- a/gr-trellis/src/lib/trellis_metrics_X.i.t +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); - -@SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - -class @NAME@ : public gr_block -{ -private: - @NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - -public: - int O () const { return d_O; } - int D () const { return d_D; } - gr::digital::trellis_metric_type_t TYPE () const { return d_TYPE; } - void set_TABLE (const std::vector<@I_TYPE@> &table); - std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } -}; diff --git a/gr-trellis/src/lib/trellis_pccc_decoder_X.cc.t b/gr-trellis/src/lib/trellis_pccc_decoder_X.cc.t deleted file mode 100644 index d79192491e..0000000000 --- a/gr-trellis/src/lib/trellis_pccc_decoder_X.cc.t +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <@NAME@.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <iostream> -#include "core_algorithms.h" - - -static const float INF = 1.0e9; - -@SPTR_NAME@ -trellis_make_@BASE_NAME@ ( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE -) -{ - return gnuradio::get_initial_sptr (new @NAME@ ( - FSM1, ST10, ST1K, - FSM2, ST20, ST2K, - INTERLEAVER, - blocklength, - repetitions, - SISO_TYPE - )); -} - -@NAME@::@NAME@ ( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE -) - : gr_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_FSM1 (FSM1), d_ST10 (ST10), d_ST1K (ST1K), - d_FSM2 (FSM2), d_ST20 (ST20), d_ST2K (ST2K), - d_INTERLEAVER (INTERLEAVER), - d_blocklength (blocklength), - d_repetitions (repetitions), - d_SISO_TYPE (SISO_TYPE) -{ - assert(d_FSM1.I() == d_FSM2.I()); - set_relative_rate (1.0 / ((double) d_FSM1.O() * d_FSM2.O())); - set_output_multiple (d_blocklength); -} - - -void -@NAME@::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - assert (noutput_items % d_blocklength == 0); - int input_required = d_FSM1.O() * d_FSM2.O() * noutput_items ; - ninput_items_required[0] = input_required; -} - - - -//=========================================================== - -int -@NAME@::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert (noutput_items % d_blocklength == 0); - int nblocks = noutput_items / d_blocklength; - - float (*p2min)(float, float) = NULL; - if(d_SISO_TYPE == TRELLIS_MIN_SUM) - p2min = &min; - else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) - p2min = &min_star; - - - const float *in = (const float *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - for (int n=0;n<nblocks;n++) { - pccc_decoder( - d_FSM1, d_ST10, d_ST1K, - d_FSM2, d_ST20, d_ST2K, - d_INTERLEAVER, d_blocklength, d_repetitions, - p2min, - &(in[n*d_blocklength*d_FSM1.O()*d_FSM2.O()]),&(out[n*d_blocklength]) - ); - } - - consume_each (d_FSM1.O() * d_FSM2.O() * noutput_items ); - return noutput_items; -} diff --git a/gr-trellis/src/lib/trellis_pccc_decoder_X.h.t b/gr-trellis/src/lib/trellis_pccc_decoder_X.h.t deleted file mode 100644 index e9bc946818..0000000000 --- a/gr-trellis/src/lib/trellis_pccc_decoder_X.h.t +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <trellis_api.h> -#include "fsm.h" -#include "interleaver.h" -#include <gr_block.h> -#include <vector> -#include "siso_type.h" - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE // perform "min-sum" or "sum-product" combining -); - - -/*! - * \ingroup coding_blk - */ -class TRELLIS_API @NAME@ : public gr_block -{ - fsm d_FSM1; - int d_ST10; - int d_ST1K; - fsm d_FSM2; - int d_ST20; - int d_ST2K; - interleaver d_INTERLEAVER; - int d_blocklength; - int d_repetitions; - trellis_siso_type_t d_SISO_TYPE; - std::vector<float> d_buffer; - - friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE - ); - - @NAME@ ( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE - ); - -public: - fsm FSM1 () const { return d_FSM1; } - fsm FSM2 () const { return d_FSM2; } - int ST10 () const { return d_ST10; } - int ST1K () const { return d_ST1K; } - int ST20 () const { return d_ST20; } - int ST2K () const { return d_ST2K; } - interleaver INTERLEAVER () const { return d_INTERLEAVER; } - int blocklength () const { return d_blocklength; } - int repetitions () const { return d_repetitions; } - trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } - - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-trellis/src/lib/trellis_pccc_decoder_X.i.t b/gr-trellis/src/lib/trellis_pccc_decoder_X.i.t deleted file mode 100644 index 83d7fe969d..0000000000 --- a/gr-trellis/src/lib/trellis_pccc_decoder_X.i.t +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); - -@SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE -); - - -class @NAME@ : public gr_block -{ -private: - @NAME@ ( - const fsm &FSM1, int ST10, int ST1K, - const fsm &FSM2, int ST20, int ST2K, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE - ); - -public: - fsm FSM1 () const { return d_FSM1; } - fsm FSM2 () const { return d_FSM2; } - int ST10 () const { return d_ST10; } - int ST1K () const { return d_ST1K; } - int ST20 () const { return d_ST20; } - int ST2K () const { return d_ST2K; } - interleaver INTERLEAVER () const { return d_INTERLEAVER; } - int blocklength () const { return d_blocklength; } - int repetitions () const { return d_repetitions; } - trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } -}; diff --git a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.cc.t b/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.cc.t deleted file mode 100644 index e8f9f7296e..0000000000 --- a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.cc.t +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <@NAME@.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <iostream> -#include "core_algorithms.h" - - -static const float INF = 1.0e9; - -@SPTR_NAME@ -trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling -) -{ - return gnuradio::get_initial_sptr (new @NAME@ ( - FSMo, STo0, SToK, - FSMi, STi0, STiK, - INTERLEAVER, - blocklength, - repetitions, - SISO_TYPE, - D, - TABLE,METRIC_TYPE, - scaling - )); -} - -@NAME@::@NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling -) - : gr_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_FSMo (FSMo), d_STo0 (STo0), d_SToK (SToK), - d_FSMi (FSMi), d_STi0 (STi0), d_STiK (STiK), - d_INTERLEAVER (INTERLEAVER), - d_blocklength (blocklength), - d_repetitions (repetitions), - d_SISO_TYPE (SISO_TYPE), - d_D (D), - d_TABLE (TABLE), - d_METRIC_TYPE (METRIC_TYPE), - d_scaling (scaling) -{ - assert(d_FSMo.I() == d_FSMi.I()); - set_relative_rate (1.0 / ((double) d_D)); - set_output_multiple (d_blocklength); -} - -void @NAME@::set_scaling(float scaling) -{ - d_scaling = scaling; -} - - -void -@NAME@::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - assert (noutput_items % d_blocklength == 0); - int input_required = d_D * noutput_items ; - ninput_items_required[0] = input_required; -} - - - -//=========================================================== - -int -@NAME@::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert (noutput_items % d_blocklength == 0); - int nblocks = noutput_items / d_blocklength; - - float (*p2min)(float, float) = NULL; - if(d_SISO_TYPE == TRELLIS_MIN_SUM) - p2min = &min; - else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) - p2min = &min_star; - - - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - for (int n=0;n<nblocks;n++) { - pccc_decoder_combined( - d_FSMo, d_STo0, d_SToK, - d_FSMi, d_STi0, d_STiK, - d_INTERLEAVER, d_blocklength, d_repetitions, - p2min, - d_D,d_TABLE, - d_METRIC_TYPE, - d_scaling, - &(in[n*d_blocklength*d_D]),&(out[n*d_blocklength]) - ); - } - - consume_each (d_D * noutput_items ); - return noutput_items; -} diff --git a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t b/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t deleted file mode 100644 index 81d9abbc1f..0000000000 --- a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <trellis_api.h> -#include "fsm.h" -#include "interleaver.h" -#include <gr_block.h> -#include <vector> -#include "calc_metric.h" -#include "siso_type.h" - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, // perform "min-sum" or "sum-product" combining - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling -); - - -/*! - * \ingroup coding_blk - */ -class TRELLIS_API @NAME@ : public gr_block -{ - fsm d_FSMo; - int d_STo0; - int d_SToK; - fsm d_FSMi; - int d_STi0; - int d_STiK; - interleaver d_INTERLEAVER; - int d_blocklength; - int d_repetitions; - trellis_siso_type_t d_SISO_TYPE; - int d_D; - std::vector<@I_TYPE@> d_TABLE; - gr::digital::trellis_metric_type_t d_METRIC_TYPE; - float d_scaling; - std::vector<float> d_buffer; - - friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling - ); - - @NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling - ); - -public: - fsm FSM1 () const { return d_FSMo; } - fsm FSM2 () const { return d_FSMi; } - int ST10 () const { return d_STo0; } - int ST1K () const { return d_SToK; } - int ST20 () const { return d_STi0; } - int ST2K () const { return d_STiK; } - interleaver INTERLEAVER () const { return d_INTERLEAVER; } - int blocklength () const { return d_blocklength; } - int repetitions () const { return d_repetitions; } - int D () const { return d_D; } - std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } - gr::digital::trellis_metric_type_t METRIC_TYPE () const { return d_METRIC_TYPE; } - trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } - float scaling () const { return d_scaling; } - void set_scaling (float scaling); - - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.i.t b/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.i.t deleted file mode 100644 index 8684ff650c..0000000000 --- a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.i.t +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); - -@SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling -); - - -class @NAME@ : public gr_block -{ -private: - @NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling - ); - -public: - fsm FSM1 () const { return d_FSMo; } - fsm FSM2 () const { return d_FSMi; } - int ST10 () const { return d_STo0; } - int ST1K () const { return d_SToK; } - int ST20 () const { return d_STi0; } - int ST2K () const { return d_STiK; } - interleaver INTERLEAVER () const { return d_INTERLEAVER; } - int blocklength () const { return d_blocklength; } - int repetitions () const { return d_repetitions; } - int D () const { return d_D; } - std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } - gr::digital::trellis_metric_type_t METRIC_TYPE () const { return d_METRIC_TYPE; } - trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } - float scaling() const { return d_scaling; } - void set_scaling (float scaling); -}; diff --git a/gr-trellis/src/lib/trellis_pccc_encoder_XX.cc.t b/gr-trellis/src/lib/trellis_pccc_encoder_XX.cc.t deleted file mode 100644 index 6cab858cd5..0000000000 --- a/gr-trellis/src/lib/trellis_pccc_encoder_XX.cc.t +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <@NAME@.h> -#include <gr_io_signature.h> -#include <iostream> - -@SPTR_NAME@ -trellis_make_@BASE_NAME@ ( - const fsm &FSM1, int ST1, - const fsm &FSM2, int ST2, - const interleaver &INTERLEAVER, - int blocklength -) -{ - return gnuradio::get_initial_sptr (new @NAME@ (FSM1,ST1,FSM2,ST2,INTERLEAVER,blocklength)); -} - -@NAME@::@NAME@ ( - const fsm &FSM1, int ST1, - const fsm &FSM2, int ST2, - const interleaver &INTERLEAVER, - int blocklength -) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_FSM1 (FSM1), - d_ST1 (ST1), - d_FSM2 (FSM2), - d_ST2 (ST2), - d_INTERLEAVER (INTERLEAVER), - d_blocklength (blocklength) -{ - assert(d_FSM1.I() == d_FSM2.I()); - set_output_multiple(d_blocklength); - d_buffer.resize(d_blocklength); -} - - - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert(noutput_items%d_blocklength ==0); - for (int b = 0 ; b<noutput_items/d_blocklength; b++) { - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0]+b*d_blocklength; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]+b*d_blocklength; - - int ST1_tmp = d_ST1; - int ST2_tmp = d_ST2; - for (int i = 0; i < d_blocklength; i++){ - int k = d_INTERLEAVER.INTER()[i]; - int o1 = d_FSM1.OS()[ST1_tmp*d_FSM1.I()+in[i]]; - ST1_tmp = (int) d_FSM1.NS()[ST1_tmp*d_FSM1.I()+in[i]]; - int o2 = d_FSM2.OS()[ST2_tmp*d_FSM2.I()+in[k]]; - ST2_tmp = (int) d_FSM2.NS()[ST2_tmp*d_FSM2.I()+in[k]]; - out[i] = (@O_TYPE@) (o1*d_FSM1.O() + o2); - } - } - return noutput_items; -} - diff --git a/gr-trellis/src/lib/trellis_pccc_encoder_XX.h.t b/gr-trellis/src/lib/trellis_pccc_encoder_XX.h.t deleted file mode 100644 index 75a22b829c..0000000000 --- a/gr-trellis/src/lib/trellis_pccc_encoder_XX.h.t +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <trellis_api.h> -#include <vector> -#include "fsm.h" -#include "interleaver.h" -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSM1, int ST1, - const fsm &FSM2, int ST2, - const interleaver &INTERLEAVER, - int blocklength -); - -/*! - * \brief SCCC encoder. - * \ingroup coding_blk - */ -class TRELLIS_API @NAME@ : public gr_sync_block -{ -private: - friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSM1, int ST1, - const fsm &FSM2, int ST2, - const interleaver &INTERLEAVER, - int blocklength - ); - fsm d_FSM1; - int d_ST1; - fsm d_FSM2; - int d_ST2; - interleaver d_INTERLEAVER; - int d_blocklength; - std::vector<int> d_buffer; - @NAME@ ( - const fsm &FSM1, int ST1, - const fsm &FSM2, int ST2, - const interleaver &INTERLEAVER, - int blocklength - ); - -public: - fsm FSM1 () const { return d_FSM1; } - int ST1 () const { return d_ST1; } - fsm FSM2 () const { return d_FSM2; } - int ST2 () const { return d_ST2; } - interleaver INTERLEAVER () const { return d_INTERLEAVER; } - int blocklength () const { return d_blocklength; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-trellis/src/lib/trellis_pccc_encoder_XX.i.t b/gr-trellis/src/lib/trellis_pccc_encoder_XX.i.t deleted file mode 100644 index c02ee428a3..0000000000 --- a/gr-trellis/src/lib/trellis_pccc_encoder_XX.i.t +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); - -@SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSM1, int ST1, - const fsm &FSM2, int ST2, - const interleaver &INTERLEAVER, - int blocklength -); - -class @NAME@ : public gr_sync_block -{ -private: - @NAME@ ( - const fsm &FSM1, int ST1, - const fsm &FSM2, int ST2, - const interleaver &INTERLEAVER, - int blocklength - ); -public: - fsm FSM1 () const { return d_FSM1; } - int ST1 () const { return d_ST1; } - fsm FSM2 () const { return d_FSM2; } - int ST2 () const { return d_ST2; } - interleaver INTERLEAVER () const { return d_INTERLEAVER; } - int blocklength () const { return d_blocklength; } -}; diff --git a/gr-trellis/src/lib/trellis_permutation.cc b/gr-trellis/src/lib/trellis_permutation.cc deleted file mode 100644 index 57c6d26938..0000000000 --- a/gr-trellis/src/lib/trellis_permutation.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <trellis_permutation.h> -#include <gr_io_signature.h> -#include <iostream> -#include <string.h> - -trellis_permutation_sptr -trellis_make_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t BYTES_PER_SYMBOL) -{ - return gnuradio::get_initial_sptr(new trellis_permutation (K,TABLE,SYMS_PER_BLOCK,BYTES_PER_SYMBOL)); -} - -trellis_permutation::trellis_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t BYTES_PER_SYMBOL) - : gr_sync_block ("permutation", - gr_make_io_signature (1, -1, BYTES_PER_SYMBOL), - gr_make_io_signature (1, -1, BYTES_PER_SYMBOL)), - d_K (K), - d_TABLE (TABLE), - d_SYMS_PER_BLOCK (SYMS_PER_BLOCK), - d_BYTES_PER_SYMBOL (BYTES_PER_SYMBOL) -{ - set_output_multiple (d_K*SYMS_PER_BLOCK); - //std::cout << d_K << "\n"; -} - - - -int -trellis_permutation::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - int nstreams = input_items.size(); - assert (input_items.size() == output_items.size()); - assert (noutput_items % d_K ==0); - - for (int m=0;m<nstreams;m++) { - const char *in = (const char *) input_items[m]; - char *out = (char *) output_items[m]; - - // per stream processing - for (int i = 0; i < noutput_items/d_SYMS_PER_BLOCK; i++){ - // Index i refers to blocks. - // Begining of packet (in blocks) - int i0 = d_K*(i/d_K); - // position of block within packet (in blocks) - int j0 = i%d_K; - // new position of block within packet (in blocks) - int k0 = d_TABLE[j0]; - memcpy(&(out[i*d_SYMS_PER_BLOCK*d_BYTES_PER_SYMBOL]), - &(in[(i0+k0)*d_SYMS_PER_BLOCK*d_BYTES_PER_SYMBOL]), - d_BYTES_PER_SYMBOL*d_SYMS_PER_BLOCK); - } - // end per stream processing - } - return noutput_items; -} diff --git a/gr-trellis/src/lib/trellis_permutation.h b/gr-trellis/src/lib/trellis_permutation.h deleted file mode 100644 index cc40518c2c..0000000000 --- a/gr-trellis/src/lib/trellis_permutation.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- 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_TRELLIS_PERMUTATION_H -#define INCLUDED_TRELLIS_PERMUTATION_H - -#include <trellis_api.h> -#include <vector> -#include <gr_sync_block.h> - -class trellis_permutation; -typedef boost::shared_ptr<trellis_permutation> trellis_permutation_sptr; - -TRELLIS_API trellis_permutation_sptr trellis_make_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t BYTES_PER_SYMBOL); - -/*! - * \brief Permutation. - * \ingroup coding_blk - */ -class TRELLIS_API trellis_permutation : public gr_sync_block -{ -private: - friend TRELLIS_API trellis_permutation_sptr trellis_make_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t BYTES_PER_SYMBOL); - int d_K; - std::vector<int> d_TABLE; - int d_SYMS_PER_BLOCK; - size_t d_BYTES_PER_SYMBOL; - trellis_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t NBYTES); - -public: - int K () const { return d_K; } - const std::vector<int> & TABLE () const { return d_TABLE; } - int SYMS_PER_BLOCK () const { return d_SYMS_PER_BLOCK; } - size_t BYTES_PER_SYMBOL () const { return d_BYTES_PER_SYMBOL; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-trellis/src/lib/trellis_permutation.i b/gr-trellis/src/lib/trellis_permutation.i deleted file mode 100644 index fdfaa44d33..0000000000 --- a/gr-trellis/src/lib/trellis_permutation.i +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- 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. - */ - -GR_SWIG_BLOCK_MAGIC(trellis,permutation); - -trellis_permutation_sptr trellis_make_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t BYTES_PER_SYMBOL); - -class trellis_permutation : public gr_sync_block -{ -private: - int d_K; - std::vector<int> d_TABLE; - int d_SYMS_PER_BLOCK; - size_t d_BYTES_PER_SYMBOL; - trellis_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t BYTES_PER_SYMBOL); - -public: - int K () const { return d_K; } - const std::vector<int> & TABLE () const { return d_TABLE; } - int SYMS_PER_BLOCK () const { return d_SYMS_PER_BLOCK; } - size_t BYTES_PER_SYMBOL () const { return d_BYTES_PER_SYMBOL; } -}; diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_X.cc.t b/gr-trellis/src/lib/trellis_sccc_decoder_X.cc.t deleted file mode 100644 index c9b78aa8f6..0000000000 --- a/gr-trellis/src/lib/trellis_sccc_decoder_X.cc.t +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <@NAME@.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <iostream> -#include "core_algorithms.h" - - -static const float INF = 1.0e9; - -@SPTR_NAME@ -trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE -) -{ - return gnuradio::get_initial_sptr (new @NAME@ ( - FSMo, STo0, SToK, - FSMi, STi0, STiK, - INTERLEAVER, - blocklength, - repetitions, - SISO_TYPE - )); -} - -@NAME@::@NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE -) - : gr_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_FSMo (FSMo), d_STo0 (STo0), d_SToK (SToK), - d_FSMi (FSMi), d_STi0 (STi0), d_STiK (STiK), - d_INTERLEAVER (INTERLEAVER), - d_blocklength (blocklength), - d_repetitions (repetitions), - d_SISO_TYPE (SISO_TYPE) -{ - assert(d_FSMo.O() == d_FSMi.I()); - set_relative_rate (1.0 / ((double) d_FSMi.O())); - set_output_multiple (d_blocklength); -} - - -void -@NAME@::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - assert (noutput_items % d_blocklength == 0); - int input_required = d_FSMi.O() * noutput_items ; - ninput_items_required[0] = input_required; -} - - - -//=========================================================== - -int -@NAME@::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert (noutput_items % d_blocklength == 0); - int nblocks = noutput_items / d_blocklength; - - float (*p2min)(float, float) = NULL; - if(d_SISO_TYPE == TRELLIS_MIN_SUM) - p2min = &min; - else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) - p2min = &min_star; - - - const float *in = (const float *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - for (int n=0;n<nblocks;n++) { - sccc_decoder( - d_FSMo, d_STo0, d_SToK, - d_FSMi, d_STi0, d_STiK, - d_INTERLEAVER, d_blocklength, d_repetitions, - p2min, - &(in[n*d_blocklength*d_FSMi.O()]),&(out[n*d_blocklength]) - ); - } - - consume_each (d_FSMi.O() * noutput_items ); - return noutput_items; -} diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t b/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t deleted file mode 100644 index d6fb72f682..0000000000 --- a/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <trellis_api.h> -#include "fsm.h" -#include "interleaver.h" -#include <gr_block.h> -#include <vector> -#include "siso_type.h" - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE // perform "min-sum" or "sum-product" combining -); - - -/*! - * \ingroup coding_blk - */ -class TRELLIS_API @NAME@ : public gr_block -{ - fsm d_FSMo; - int d_STo0; - int d_SToK; - fsm d_FSMi; - int d_STi0; - int d_STiK; - interleaver d_INTERLEAVER; - int d_blocklength; - int d_repetitions; - trellis_siso_type_t d_SISO_TYPE; - std::vector<float> d_buffer; - - friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE - ); - - @NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE - ); - -public: - fsm FSMo () const { return d_FSMo; } - fsm FSMi () const { return d_FSMi; } - int STo0 () const { return d_STo0; } - int SToK () const { return d_SToK; } - int STi0 () const { return d_STi0; } - int STiK () const { return d_STiK; } - interleaver INTERLEAVER () const { return d_INTERLEAVER; } - int blocklength () const { return d_blocklength; } - int repetitions () const { return d_repetitions; } - trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } - - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_X.i.t b/gr-trellis/src/lib/trellis_sccc_decoder_X.i.t deleted file mode 100644 index a4392ee6fa..0000000000 --- a/gr-trellis/src/lib/trellis_sccc_decoder_X.i.t +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); - -@SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE -); - - -class @NAME@ : public gr_block -{ -private: - @NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE - ); - -public: - fsm FSMo () const { return d_FSMo; } - fsm FSMi () const { return d_FSMi; } - int STo0 () const { return d_STo0; } - int SToK () const { return d_SToK; } - int STi0 () const { return d_STi0; } - int STiK () const { return d_STiK; } - interleaver INTERLEAVER () const { return d_INTERLEAVER; } - int blocklength () const { return d_blocklength; } - int repetitions () const { return d_repetitions; } - trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } -}; diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t deleted file mode 100644 index 0fcfc70a68..0000000000 --- a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <@NAME@.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <iostream> -#include "core_algorithms.h" - - -static const float INF = 1.0e9; - -@SPTR_NAME@ -trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling -) -{ - return gnuradio::get_initial_sptr (new @NAME@ ( - FSMo, STo0, SToK, - FSMi, STi0, STiK, - INTERLEAVER, - blocklength, - repetitions, - SISO_TYPE, - D, - TABLE,METRIC_TYPE, - scaling - )); -} - -@NAME@::@NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling -) - : gr_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_FSMo (FSMo), d_STo0 (STo0), d_SToK (SToK), - d_FSMi (FSMi), d_STi0 (STi0), d_STiK (STiK), - d_INTERLEAVER (INTERLEAVER), - d_blocklength (blocklength), - d_repetitions (repetitions), - d_SISO_TYPE (SISO_TYPE), - d_D (D), - d_TABLE (TABLE), - d_METRIC_TYPE (METRIC_TYPE), - d_scaling (scaling) -{ - assert(d_FSMo.O() == d_FSMi.I()); - set_relative_rate (1.0 / ((double) d_D)); - set_output_multiple (d_blocklength); -} - -void @NAME@::set_scaling(float scaling) -{ - d_scaling = scaling; -} - - -void -@NAME@::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - assert (noutput_items % d_blocklength == 0); - int input_required = d_D * noutput_items ; - ninput_items_required[0] = input_required; -} - - - -//=========================================================== - -int -@NAME@::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert (noutput_items % d_blocklength == 0); - int nblocks = noutput_items / d_blocklength; - - float (*p2min)(float, float) = NULL; - if(d_SISO_TYPE == TRELLIS_MIN_SUM) - p2min = &min; - else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) - p2min = &min_star; - - - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - for (int n=0;n<nblocks;n++) { - sccc_decoder_combined( - d_FSMo, d_STo0, d_SToK, - d_FSMi, d_STi0, d_STiK, - d_INTERLEAVER, d_blocklength, d_repetitions, - p2min, - d_D,d_TABLE, - d_METRIC_TYPE, - d_scaling, - &(in[n*d_blocklength*d_D]),&(out[n*d_blocklength]) - ); - } - - consume_each (d_D * noutput_items ); - return noutput_items; -} diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t deleted file mode 100644 index 2cf03eaa55..0000000000 --- a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <trellis_api.h> -#include "fsm.h" -#include "interleaver.h" -#include <gr_block.h> -#include <vector> -#include "calc_metric.h" -#include "siso_type.h" - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, // perform "min-sum" or "sum-product" combining - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling -); - - -/*! - * \ingroup coding_blk - */ -class TRELLIS_API @NAME@ : public gr_block -{ - fsm d_FSMo; - int d_STo0; - int d_SToK; - fsm d_FSMi; - int d_STi0; - int d_STiK; - interleaver d_INTERLEAVER; - int d_blocklength; - int d_repetitions; - trellis_siso_type_t d_SISO_TYPE; - int d_D; - std::vector<@I_TYPE@> d_TABLE; - gr::digital::trellis_metric_type_t d_METRIC_TYPE; - float d_scaling; - std::vector<float> d_buffer; - - friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling - ); - - @NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling - ); - -public: - fsm FSMo () const { return d_FSMo; } - fsm FSMi () const { return d_FSMi; } - int STo0 () const { return d_STo0; } - int SToK () const { return d_SToK; } - int STi0 () const { return d_STi0; } - int STiK () const { return d_STiK; } - interleaver INTERLEAVER () const { return d_INTERLEAVER; } - int blocklength () const { return d_blocklength; } - int repetitions () const { return d_repetitions; } - int D () const { return d_D; } - std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } - gr::digital::trellis_metric_type_t METRIC_TYPE () const { return d_METRIC_TYPE; } - trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } - float scaling () const { return d_scaling; } - void set_scaling (float scaling); - - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.i.t b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.i.t deleted file mode 100644 index 872afcad09..0000000000 --- a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.i.t +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); - -@SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling -); - - -class @NAME@ : public gr_block -{ -private: - @NAME@ ( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, - int blocklength, - int repetitions, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t METRIC_TYPE, - float scaling - ); - -public: - fsm FSMo () const { return d_FSMo; } - fsm FSMi () const { return d_FSMi; } - int STo0 () const { return d_STo0; } - int SToK () const { return d_SToK; } - int STi0 () const { return d_STi0; } - int STiK () const { return d_STiK; } - interleaver INTERLEAVER () const { return d_INTERLEAVER; } - int blocklength () const { return d_blocklength; } - int repetitions () const { return d_repetitions; } - int D () const { return d_D; } - std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } - gr::digital::trellis_metric_type_t METRIC_TYPE () const { return d_METRIC_TYPE; } - trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } - float scaling() const { return d_scaling; } - void set_scaling (float scaling); -}; diff --git a/gr-trellis/src/lib/trellis_sccc_encoder_XX.cc.t b/gr-trellis/src/lib/trellis_sccc_encoder_XX.cc.t deleted file mode 100644 index 8054909db8..0000000000 --- a/gr-trellis/src/lib/trellis_sccc_encoder_XX.cc.t +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <@NAME@.h> -#include <gr_io_signature.h> -#include <iostream> - -@SPTR_NAME@ -trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo, - const fsm &FSMi, int STi, - const interleaver &INTERLEAVER, - int blocklength -) -{ - return gnuradio::get_initial_sptr (new @NAME@ (FSMo,STo,FSMi,STi,INTERLEAVER,blocklength)); -} - -@NAME@::@NAME@ ( - const fsm &FSMo, int STo, - const fsm &FSMi, int STi, - const interleaver &INTERLEAVER, - int blocklength -) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_FSMo (FSMo), - d_STo (STo), - d_FSMi (FSMi), - d_STi (STi), - d_INTERLEAVER (INTERLEAVER), - d_blocklength (blocklength) -{ - assert(d_FSMo.O() == d_FSMi.I()); - set_output_multiple(d_blocklength); - d_buffer.resize(d_blocklength); -} - - - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert(noutput_items%d_blocklength ==0); - for (int b = 0 ; b<noutput_items/d_blocklength; b++) { - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0]+b*d_blocklength; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]+b*d_blocklength; - - int STo_tmp = d_STo; - for (int i = 0; i < d_blocklength; i++){ - d_buffer[i] = d_FSMo.OS()[STo_tmp*d_FSMo.I()+in[i]]; - STo_tmp = (int) d_FSMo.NS()[STo_tmp*d_FSMo.I()+in[i]]; - } - int STi_tmp = d_STi; - for (int i = 0; i < d_blocklength; i++){ - int k = d_INTERLEAVER.INTER()[i]; - out[i] = (@O_TYPE@) d_FSMi.OS()[STi_tmp*d_FSMi.I()+d_buffer[k]]; - STi_tmp = (int) d_FSMi.NS()[STi_tmp*d_FSMi.I()+d_buffer[k]]; - } - } - return noutput_items; -} - diff --git a/gr-trellis/src/lib/trellis_sccc_encoder_XX.h.t b/gr-trellis/src/lib/trellis_sccc_encoder_XX.h.t deleted file mode 100644 index b16d7ffca9..0000000000 --- a/gr-trellis/src/lib/trellis_sccc_encoder_XX.h.t +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <trellis_api.h> -#include <vector> -#include "fsm.h" -#include "interleaver.h" -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo, - const fsm &FSMi, int STi, - const interleaver &INTERLEAVER, - int blocklength -); - -/*! - * \brief SCCC encoder. - * \ingroup coding_blk - */ -class TRELLIS_API @NAME@ : public gr_sync_block -{ -private: - friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo, - const fsm &FSMi, int STi, - const interleaver &INTERLEAVER, - int blocklength - ); - fsm d_FSMo; - int d_STo; - fsm d_FSMi; - int d_STi; - interleaver d_INTERLEAVER; - int d_blocklength; - std::vector<int> d_buffer; - @NAME@ ( - const fsm &FSMo, int STo, - const fsm &FSMi, int STi, - const interleaver &INTERLEAVER, - int blocklength - ); - -public: - fsm FSMo () const { return d_FSMo; } - int STo () const { return d_STo; } - fsm FSMi () const { return d_FSMi; } - int STi () const { return d_STi; } - interleaver INTERLEAVER () const { return d_INTERLEAVER; } - int blocklength () const { return d_blocklength; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-trellis/src/lib/trellis_sccc_encoder_XX.i.t b/gr-trellis/src/lib/trellis_sccc_encoder_XX.i.t deleted file mode 100644 index ca6b561992..0000000000 --- a/gr-trellis/src/lib/trellis_sccc_encoder_XX.i.t +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); - -@SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSMo, int STo, - const fsm &FSMi, int STi, - const interleaver &INTERLEAVER, - int blocklength -); - -class @NAME@ : public gr_sync_block -{ -private: - @NAME@ ( - const fsm &FSMo, int STo, - const fsm &FSMi, int STi, - const interleaver &INTERLEAVER, - int blocklength - ); -public: - fsm FSMo () const { return d_FSMo; } - int STo () const { return d_STo; } - fsm FSMi () const { return d_FSMi; } - int STi () const { return d_STi; } - interleaver INTERLEAVER () const { return d_INTERLEAVER; } - int blocklength () const { return d_blocklength; } -}; diff --git a/gr-trellis/src/lib/trellis_siso_combined_f.cc b/gr-trellis/src/lib/trellis_siso_combined_f.cc deleted file mode 100644 index d956c47854..0000000000 --- a/gr-trellis/src/lib/trellis_siso_combined_f.cc +++ /dev/null @@ -1,357 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <trellis_siso_combined_f.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <assert.h> -#include <iostream> - -static const float INF = 1.0e9; - -trellis_siso_combined_f_sptr -trellis_make_siso_combined_f ( - const fsm &FSM, - int K, - int S0, - int SK, - bool POSTI, - bool POSTO, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t TYPE) -{ - return gnuradio::get_initial_sptr(new trellis_siso_combined_f (FSM,K,S0,SK,POSTI,POSTO,SISO_TYPE,D,TABLE,TYPE)); -} - -trellis_siso_combined_f::trellis_siso_combined_f ( - const fsm &FSM, - int K, - int S0, - int SK, - bool POSTI, - bool POSTO, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t TYPE) - : gr_block ("siso_combined_f", - gr_make_io_signature (1, -1, sizeof (float)), - gr_make_io_signature (1, -1, sizeof (float))), - d_FSM (FSM), - d_K (K), - d_S0 (S0), - d_SK (SK), - d_POSTI (POSTI), - d_POSTO (POSTO), - d_SISO_TYPE (SISO_TYPE), - d_D (D), - d_TABLE (TABLE), - d_TYPE (TYPE)//, - //d_alpha(FSM.S()*(K+1)), - //d_beta(FSM.S()*(K+1)) -{ - int multiple; - if (d_POSTI && d_POSTO) - multiple = d_FSM.I()+d_FSM.O(); - else if(d_POSTI) - multiple = d_FSM.I(); - else if(d_POSTO) - multiple = d_FSM.O(); - else - throw std::runtime_error ("Not both POSTI and POSTO can be false."); - //printf("constructor: Multiple = %d\n",multiple); - set_output_multiple (d_K*multiple); - //what is the meaning of relative rate for a block with 2 inputs? - //set_relative_rate ( multiple / ((double) d_FSM.I()) ); - // it turns out that the above gives problems in the scheduler, so - // let's try (assumption O>I) - //set_relative_rate ( multiple / ((double) d_FSM.O()) ); - // I am tempted to automate like this - if(d_FSM.I() <= d_D) - set_relative_rate ( multiple / ((double) d_D) ); - else - set_relative_rate ( multiple / ((double) d_FSM.I()) ); -} - - -void -trellis_siso_combined_f::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - int multiple; - if (d_POSTI && d_POSTO) - multiple = d_FSM.I()+d_FSM.O(); - else if(d_POSTI) - multiple = d_FSM.I(); - else if(d_POSTO) - multiple = d_FSM.O(); - else - throw std::runtime_error ("Not both POSTI and POSTO can be false."); - //printf("forecast: Multiple = %d\n",multiple); - assert (noutput_items % (d_K*multiple) == 0); - int input_required1 = d_FSM.I() * (noutput_items/multiple) ; - int input_required2 = d_D * (noutput_items/multiple) ; - //printf("forecast: Output requirements: %d\n",noutput_items); - //printf("forecast: Input requirements: %d %d\n",input_required1,input_required2); - unsigned ninputs = ninput_items_required.size(); - assert(ninputs % 2 == 0); - for (unsigned int i = 0; i < ninputs/2; i++) { - ninput_items_required[2*i] = input_required1; - ninput_items_required[2*i+1] = input_required2; - } -} - - - - - -/* - - -inline float min(float a, float b) -{ - return a <= b ? a : b; -} - -inline float min_star(float a, float b) -{ - return (a <= b ? a : b)-log(1+exp(a <= b ? a-b : b-a)); -} - -void siso_algorithm_combined(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - bool POSTI, bool POSTO, - float (*p2mymin)(float,float), - int D, - const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const float *priori, const float *observations, float *post//, - //std::vector<float> &alpha, - //std::vector<float> &beta - ) -{ - float norm,mm,minm; - std::vector<float> alpha(S*(K+1)); - std::vector<float> beta(S*(K+1)); - float *prioro = new float[O*K]; - - - if(S0<0) { // initial state not specified - for(int i=0;i<S;i++) alpha[0*S+i]=0; - } - else { - for(int i=0;i<S;i++) alpha[0*S+i]=INF; - alpha[0*S+S0]=0.0; - } - - for(int k=0;k<K;k++) { // forward recursion - calc_metric(O, D, TABLE, &(observations[k*D]), &(prioro[k*O]),TYPE); // calc metrics - norm=INF; - for(int j=0;j<S;j++) { - minm=INF; - for(unsigned int i=0;i<PS[j].size();i++) { - //int i0 = j*I+i; - mm=alpha[k*S+PS[j][i]]+priori[k*I+PI[j][i]]+prioro[k*O+OS[PS[j][i]*I+PI[j][i]]]; - minm=(*p2mymin)(minm,mm); - } - alpha[(k+1)*S+j]=minm; - if(minm<norm) norm=minm; - } - for(int j=0;j<S;j++) - alpha[(k+1)*S+j]-=norm; // normalize total metrics so they do not explode - } - - if(SK<0) { // final state not specified - for(int i=0;i<S;i++) beta[K*S+i]=0; - } - else { - for(int i=0;i<S;i++) beta[K*S+i]=INF; - beta[K*S+SK]=0.0; - } - - for(int k=K-1;k>=0;k--) { // backward recursion - norm=INF; - for(int j=0;j<S;j++) { - minm=INF; - for(int i=0;i<I;i++) { - int i0 = j*I+i; - mm=beta[(k+1)*S+NS[i0]]+priori[k*I+i]+prioro[k*O+OS[i0]]; - minm=(*p2mymin)(minm,mm); - } - beta[k*S+j]=minm; - if(minm<norm) norm=minm; - } - for(int j=0;j<S;j++) - beta[k*S+j]-=norm; // normalize total metrics so they do not explode - } - - - if (POSTI && POSTO) - { - for(int k=0;k<K;k++) { // input combining - norm=INF; - for(int i=0;i<I;i++) { - minm=INF; - for(int j=0;j<S;j++) { - mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; - minm=(*p2mymin)(minm,mm); - } - post[k*(I+O)+i]=minm; - if(minm<norm) norm=minm; - } - for(int i=0;i<I;i++) - post[k*(I+O)+i]-=norm; // normalize metrics - } - - - for(int k=0;k<K;k++) { // output combining - norm=INF; - for(int n=0;n<O;n++) { - minm=INF; - for(int j=0;j<S;j++) { - for(int i=0;i<I;i++) { - mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); - minm=(*p2mymin)(minm,mm); - } - } - post[k*(I+O)+I+n]=minm; - if(minm<norm) norm=minm; - } - for(int n=0;n<O;n++) - post[k*(I+O)+I+n]-=norm; // normalize metrics - } - } - else if(POSTI) - { - for(int k=0;k<K;k++) { // input combining - norm=INF; - for(int i=0;i<I;i++) { - minm=INF; - for(int j=0;j<S;j++) { - mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; - minm=(*p2mymin)(minm,mm); - } - post[k*I+i]=minm; - if(minm<norm) norm=minm; - } - for(int i=0;i<I;i++) - post[k*I+i]-=norm; // normalize metrics - } - } - else if(POSTO) - { - for(int k=0;k<K;k++) { // output combining - norm=INF; - for(int n=0;n<O;n++) { - minm=INF; - for(int j=0;j<S;j++) { - for(int i=0;i<I;i++) { - mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); - minm=(*p2mymin)(minm,mm); - } - } - post[k*O+n]=minm; - if(minm<norm) norm=minm; - } - for(int n=0;n<O;n++) - post[k*O+n]-=norm; // normalize metrics - } - } - else - throw std::runtime_error ("Not both POSTI and POSTO can be false."); - - delete [] prioro; - -} - -*/ - - - - -int -trellis_siso_combined_f::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert (input_items.size() == 2*output_items.size()); - int nstreams = output_items.size(); - //printf("general_work:Streams: %d\n",nstreams); - int multiple; - if (d_POSTI && d_POSTO) - multiple = d_FSM.I()+d_FSM.O(); - else if(d_POSTI) - multiple = d_FSM.I(); - else if(d_POSTO) - multiple = d_FSM.O(); - else - throw std::runtime_error ("Not both POSTI and POSTO can be false."); - - assert (noutput_items % (d_K*multiple) == 0); - int nblocks = noutput_items / (d_K*multiple); - //printf("general_work:Blocks: %d\n",nblocks); - //for(int i=0;i<ninput_items.size();i++) - //printf("general_work:Input items available: %d\n",ninput_items[i]); - - float (*p2min)(float, float) = NULL; - if(d_SISO_TYPE == TRELLIS_MIN_SUM) - p2min = &min; - else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) - p2min = &min_star; - - - for (int m=0;m<nstreams;m++) { - const float *in1 = (const float *) input_items[2*m]; - const float *in2 = (const float *) input_items[2*m+1]; - float *out = (float *) output_items[m]; - for (int n=0;n<nblocks;n++) { - siso_algorithm_combined(d_FSM.I(),d_FSM.S(),d_FSM.O(), - d_FSM.NS(),d_FSM.OS(),d_FSM.PS(),d_FSM.PI(), - d_K,d_S0,d_SK, - d_POSTI,d_POSTO, - p2min, - d_D,d_TABLE,d_TYPE, - &(in1[n*d_K*d_FSM.I()]),&(in2[n*d_K*d_D]), - &(out[n*d_K*multiple])//, - //d_alpha,d_beta - ); - } - } - - for (unsigned int i = 0; i < input_items.size()/2; i++) { - consume(2*i,d_FSM.I() * noutput_items / multiple ); - consume(2*i+1,d_D * noutput_items / multiple ); - } - - return noutput_items; -} diff --git a/gr-trellis/src/lib/trellis_siso_combined_f.h b/gr-trellis/src/lib/trellis_siso_combined_f.h deleted file mode 100644 index 47fa20fb65..0000000000 --- a/gr-trellis/src/lib/trellis_siso_combined_f.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- 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_TRELLIS_SISO_COMBINED_F_H -#define INCLUDED_TRELLIS_SISO_COMBINED_F_H - -#include <trellis_api.h> -#include "fsm.h" -#include "siso_type.h" -#include "calc_metric.h" -#include "core_algorithms.h" -#include <gr_block.h> - -class trellis_siso_combined_f; -typedef boost::shared_ptr<trellis_siso_combined_f> trellis_siso_combined_f_sptr; - -TRELLIS_API trellis_siso_combined_f_sptr trellis_make_siso_combined_f ( - const fsm &FSM, // underlying FSM - int K, // block size in trellis steps - int S0, // initial state (put -1 if not specified) - int SK, // final state (put -1 if not specified) - bool POSTI, // true if you want a-posteriori info about the input symbols to be mux-ed in the output - bool POSTO, // true if you want a-posteriori info about the output symbols to be mux-ed in the output - trellis_siso_type_t d_SISO_TYPE, // perform "min-sum" or "sum-product" combining - int D, - const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t TYPE -); - -/*! - * \ingroup coding_blk - */ -class TRELLIS_API trellis_siso_combined_f : public gr_block -{ - fsm d_FSM; - int d_K; - int d_S0; - int d_SK; - bool d_POSTI; - bool d_POSTO; - trellis_siso_type_t d_SISO_TYPE; - int d_D; - std::vector<float> d_TABLE; - gr::digital::trellis_metric_type_t d_TYPE; - //std::vector<float> d_alpha; - //std::vector<float> d_beta; - - friend TRELLIS_API trellis_siso_combined_f_sptr trellis_make_siso_combined_f ( - const fsm &FSM, - int K, - int S0, - int SK, - bool POSTI, - bool POSTO, - trellis_siso_type_t d_SISO_TYPE, - int D, - const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - - - trellis_siso_combined_f ( - const fsm &FSM, - int K, - int S0, - int SK, - bool POSTI, - bool POSTO, - trellis_siso_type_t d_SISO_TYPE, - int D, - const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - - -public: - fsm FSM () const { return d_FSM; } - int K () const { return d_K; } - int S0 () const { return d_S0; } - int SK () const { return d_SK; } - bool POSTI () const { return d_POSTI; } - bool POSTO () const { return d_POSTO; } - trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } - int D () const { return d_D; } - std::vector<float> TABLE () const { return d_TABLE; } - gr::digital::trellis_metric_type_t TYPE () const { return d_TYPE; } - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-trellis/src/lib/trellis_siso_combined_f.i b/gr-trellis/src/lib/trellis_siso_combined_f.i deleted file mode 100644 index 228cdd1218..0000000000 --- a/gr-trellis/src/lib/trellis_siso_combined_f.i +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- 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. - */ - -GR_SWIG_BLOCK_MAGIC(trellis,siso_combined_f); - -trellis_siso_combined_f_sptr trellis_make_siso_combined_f ( - const fsm &FSM, - int K, - int S0, - int SK, - bool POSTI, - bool POSTO, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - - -class trellis_siso_combined_f : public gr_block -{ -private: - trellis_siso_combined_f ( - const fsm &FSM, - int K, - int S0, - int SK, - bool POSTI, - bool POSTO, - trellis_siso_type_t SISO_TYPE, - int D, - const std::vector<float> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - -public: - fsm FSM () const { return d_FSM; } - int K () const { return d_K; } - int S0 () const { return d_S0; } - int SK () const { return d_SK; } - bool POSTI () const { return d_POSTI; } - bool POSTO () const { return d_POSTO; } - trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } - int D () const { return d_D; } - std::vector<float> TABLE () const { return d_TABLE; } - gr::digital::trellis_metric_type_t TYPE () const { return d_TYPE; } -}; diff --git a/gr-trellis/src/lib/trellis_siso_f.cc b/gr-trellis/src/lib/trellis_siso_f.cc deleted file mode 100644 index ffebf1928a..0000000000 --- a/gr-trellis/src/lib/trellis_siso_f.cc +++ /dev/null @@ -1,338 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <trellis_siso_f.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <assert.h> -#include <iostream> - -static const float INF = 1.0e9; - -trellis_siso_f_sptr -trellis_make_siso_f ( - const fsm &FSM, - int K, - int S0, - int SK, - bool POSTI, - bool POSTO, - trellis_siso_type_t SISO_TYPE) -{ - return gnuradio::get_initial_sptr(new trellis_siso_f (FSM,K,S0,SK,POSTI,POSTO,SISO_TYPE)); -} - -trellis_siso_f::trellis_siso_f ( - const fsm &FSM, - int K, - int S0, - int SK, - bool POSTI, - bool POSTO, - trellis_siso_type_t SISO_TYPE) - : gr_block ("siso_f", - gr_make_io_signature (1, -1, sizeof (float)), - gr_make_io_signature (1, -1, sizeof (float))), - d_FSM (FSM), - d_K (K), - d_S0 (S0), - d_SK (SK), - d_POSTI (POSTI), - d_POSTO (POSTO), - d_SISO_TYPE (SISO_TYPE)//, - //d_alpha(FSM.S()*(K+1)), - //d_beta(FSM.S()*(K+1)) -{ - int multiple; - if (d_POSTI && d_POSTO) - multiple = d_FSM.I()+d_FSM.O(); - else if(d_POSTI) - multiple = d_FSM.I(); - else if(d_POSTO) - multiple = d_FSM.O(); - else - throw std::runtime_error ("Not both POSTI and POSTO can be false."); - //printf("constructor: Multiple = %d\n",multiple); - set_output_multiple (d_K*multiple); - //what is the meaning of relative rate for a block with 2 inputs? - //set_relative_rate ( multiple / ((double) d_FSM.I()) ); - // it turns out that the above gives problems in the scheduler, so - // let's try (assumption O>I) - //set_relative_rate ( multiple / ((double) d_FSM.O()) ); - // I am tempted to automate like this - if(d_FSM.I() <= d_FSM.O()) - set_relative_rate ( multiple / ((double) d_FSM.O()) ); - else - set_relative_rate ( multiple / ((double) d_FSM.I()) ); -} - - -void -trellis_siso_f::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - int multiple; - if (d_POSTI && d_POSTO) - multiple = d_FSM.I()+d_FSM.O(); - else if(d_POSTI) - multiple = d_FSM.I(); - else if(d_POSTO) - multiple = d_FSM.O(); - else - throw std::runtime_error ("Not both POSTI and POSTO can be false."); - //printf("forecast: Multiple = %d\n",multiple); - assert (noutput_items % (d_K*multiple) == 0); - int input_required1 = d_FSM.I() * (noutput_items/multiple) ; - int input_required2 = d_FSM.O() * (noutput_items/multiple) ; - //printf("forecast: Output requirements: %d\n",noutput_items); - //printf("forecast: Input requirements: %d %d\n",input_required1,input_required2); - unsigned ninputs = ninput_items_required.size(); - assert(ninputs % 2 == 0); - for (unsigned int i = 0; i < ninputs/2; i++) { - ninput_items_required[2*i] = input_required1; - ninput_items_required[2*i+1] = input_required2; - } -} - - - - -/* Moved it to "core_algorithms.cc" */ -/* -inline float min(float a, float b) -{ - return a <= b ? a : b; -} - -inline float min_star(float a, float b) -{ - return (a <= b ? a : b)-log(1+exp(a <= b ? a-b : b-a)); -} - -void siso_algorithm(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - bool POSTI, bool POSTO, - float (*p2mymin)(float,float), - const float *priori, const float *prioro, float *post//, - //std::vector<float> &alpha, - //std::vector<float> &beta - ) -{ - float norm,mm,minm; - std::vector<float> alpha(S*(K+1)); - std::vector<float> beta(S*(K+1)); - - - if(S0<0) { // initial state not specified - for(int i=0;i<S;i++) alpha[0*S+i]=0; - } - else { - for(int i=0;i<S;i++) alpha[0*S+i]=INF; - alpha[0*S+S0]=0.0; - } - - for(int k=0;k<K;k++) { // forward recursion - norm=INF; - for(int j=0;j<S;j++) { - minm=INF; - for(unsigned int i=0;i<PS[j].size();i++) { - //int i0 = j*I+i; - mm=alpha[k*S+PS[j][i]]+priori[k*I+PI[j][i]]+prioro[k*O+OS[PS[j][i]*I+PI[j][i]]]; - minm=(*p2mymin)(minm,mm); - } - alpha[(k+1)*S+j]=minm; - if(minm<norm) norm=minm; - } - for(int j=0;j<S;j++) - alpha[(k+1)*S+j]-=norm; // normalize total metrics so they do not explode - } - - if(SK<0) { // final state not specified - for(int i=0;i<S;i++) beta[K*S+i]=0; - } - else { - for(int i=0;i<S;i++) beta[K*S+i]=INF; - beta[K*S+SK]=0.0; - } - - for(int k=K-1;k>=0;k--) { // backward recursion - norm=INF; - for(int j=0;j<S;j++) { - minm=INF; - for(int i=0;i<I;i++) { - int i0 = j*I+i; - mm=beta[(k+1)*S+NS[i0]]+priori[k*I+i]+prioro[k*O+OS[i0]]; - minm=(*p2mymin)(minm,mm); - } - beta[k*S+j]=minm; - if(minm<norm) norm=minm; - } - for(int j=0;j<S;j++) - beta[k*S+j]-=norm; // normalize total metrics so they do not explode - } - - -if (POSTI && POSTO) -{ - for(int k=0;k<K;k++) { // input combining - norm=INF; - for(int i=0;i<I;i++) { - minm=INF; - for(int j=0;j<S;j++) { - mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; - minm=(*p2mymin)(minm,mm); - } - post[k*(I+O)+i]=minm; - if(minm<norm) norm=minm; - } - for(int i=0;i<I;i++) - post[k*(I+O)+i]-=norm; // normalize metrics - } - - - for(int k=0;k<K;k++) { // output combining - norm=INF; - for(int n=0;n<O;n++) { - minm=INF; - for(int j=0;j<S;j++) { - for(int i=0;i<I;i++) { - mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); - minm=(*p2mymin)(minm,mm); - } - } - post[k*(I+O)+I+n]=minm; - if(minm<norm) norm=minm; - } - for(int n=0;n<O;n++) - post[k*(I+O)+I+n]-=norm; // normalize metrics - } -} -else if(POSTI) -{ - for(int k=0;k<K;k++) { // input combining - norm=INF; - for(int i=0;i<I;i++) { - minm=INF; - for(int j=0;j<S;j++) { - mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; - minm=(*p2mymin)(minm,mm); - } - post[k*I+i]=minm; - if(minm<norm) norm=minm; - } - for(int i=0;i<I;i++) - post[k*I+i]-=norm; // normalize metrics - } -} -else if(POSTO) -{ - for(int k=0;k<K;k++) { // output combining - norm=INF; - for(int n=0;n<O;n++) { - minm=INF; - for(int j=0;j<S;j++) { - for(int i=0;i<I;i++) { - mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); - minm=(*p2mymin)(minm,mm); - } - } - post[k*O+n]=minm; - if(minm<norm) norm=minm; - } - for(int n=0;n<O;n++) - post[k*O+n]-=norm; // normalize metrics - } -} -else - throw std::runtime_error ("Not both POSTI and POSTO can be false."); - -} - -*/ - - - - -int -trellis_siso_f::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert (input_items.size() == 2*output_items.size()); - int nstreams = output_items.size(); - //printf("general_work:Streams: %d\n",nstreams); - int multiple; - if (d_POSTI && d_POSTO) - multiple = d_FSM.I()+d_FSM.O(); - else if(d_POSTI) - multiple = d_FSM.I(); - else if(d_POSTO) - multiple = d_FSM.O(); - else - throw std::runtime_error ("Not both POSTI and POSTO can be false."); - - assert (noutput_items % (d_K*multiple) == 0); - int nblocks = noutput_items / (d_K*multiple); - //printf("general_work:Blocks: %d\n",nblocks); - //for(int i=0;i<ninput_items.size();i++) - //printf("general_work:Input items available: %d\n",ninput_items[i]); - - float (*p2min)(float, float) = NULL; - if(d_SISO_TYPE == TRELLIS_MIN_SUM) - p2min = &min; - else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) - p2min = &min_star; - - - for (int m=0;m<nstreams;m++) { - const float *in1 = (const float *) input_items[2*m]; - const float *in2 = (const float *) input_items[2*m+1]; - float *out = (float *) output_items[m]; - for (int n=0;n<nblocks;n++) { - siso_algorithm(d_FSM.I(),d_FSM.S(),d_FSM.O(), - d_FSM.NS(),d_FSM.OS(),d_FSM.PS(),d_FSM.PI(), - d_K,d_S0,d_SK, - d_POSTI,d_POSTO, - p2min, - &(in1[n*d_K*d_FSM.I()]),&(in2[n*d_K*d_FSM.O()]), - &(out[n*d_K*multiple])//, - //d_alpha,d_beta - ); - } - } - - for (unsigned int i = 0; i < input_items.size()/2; i++) { - consume(2*i,d_FSM.I() * noutput_items / multiple ); - consume(2*i+1,d_FSM.O() * noutput_items / multiple ); - } - - return noutput_items; -} diff --git a/gr-trellis/src/lib/trellis_siso_f.h b/gr-trellis/src/lib/trellis_siso_f.h deleted file mode 100644 index 9341f24683..0000000000 --- a/gr-trellis/src/lib/trellis_siso_f.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- 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_TRELLIS_SISO_F_H -#define INCLUDED_TRELLIS_SISO_F_H - -#include <trellis_api.h> -#include "fsm.h" -#include "siso_type.h" -#include "core_algorithms.h" -#include <gr_block.h> - -class trellis_siso_f; -typedef boost::shared_ptr<trellis_siso_f> trellis_siso_f_sptr; - -TRELLIS_API trellis_siso_f_sptr trellis_make_siso_f ( - const fsm &FSM, // underlying FSM - int K, // block size in trellis steps - int S0, // initial state (put -1 if not specified) - int SK, // final state (put -1 if not specified) - bool POSTI, // true if you want a-posteriori info about the input symbols to be mux-ed in the output - bool POSTO, // true if you want a-posteriori info about the output symbols to be mux-ed in the output - trellis_siso_type_t d_SISO_TYPE // perform "min-sum" or "sum-product" combining -); - - -/*! - * \ingroup coding_blk - */ -class TRELLIS_API trellis_siso_f : public gr_block -{ - fsm d_FSM; - int d_K; - int d_S0; - int d_SK; - bool d_POSTI; - bool d_POSTO; - trellis_siso_type_t d_SISO_TYPE; - //std::vector<float> d_alpha; - //std::vector<float> d_beta; - - friend TRELLIS_API trellis_siso_f_sptr trellis_make_siso_f ( - const fsm &FSM, - int K, - int S0, - int SK, - bool POSTI, - bool POSTO, - trellis_siso_type_t d_SISO_TYPE); - - - trellis_siso_f ( - const fsm &FSM, - int K, - int S0, - int SK, - bool POSTI, - bool POSTO, - trellis_siso_type_t d_SISO_TYPE); - - -public: - fsm FSM () const { return d_FSM; } - int K () const { return d_K; } - int S0 () const { return d_S0; } - int SK () const { return d_SK; } - bool POSTI () const { return d_POSTI; } - bool POSTO () const { return d_POSTO; } - trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-trellis/src/lib/trellis_siso_f.i b/gr-trellis/src/lib/trellis_siso_f.i deleted file mode 100644 index 63bfb48c8f..0000000000 --- a/gr-trellis/src/lib/trellis_siso_f.i +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- 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. - */ - -GR_SWIG_BLOCK_MAGIC(trellis,siso_f); - -trellis_siso_f_sptr trellis_make_siso_f ( - const fsm &FSM, - int K, - int S0, - int SK, - bool POSTI, - bool POSTO, - trellis_siso_type_t SISO_TYPE); - - -class trellis_siso_f : public gr_block -{ -private: - trellis_siso_f ( - const fsm &FSM, - int K, - int S0, - int SK, - bool POSTI, - bool POSTO, - trellis_siso_type_t SISO_TYPE); - -public: - fsm FSM () const { return d_FSM; } - int K () const { return d_K; } - int S0 () const { return d_S0; } - int SK () const { return d_SK; } - bool POSTI () const { return d_POSTI; } - bool POSTO () const { return d_POSTO; } - trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } -}; diff --git a/gr-trellis/src/lib/trellis_viterbi_X.cc.t b/gr-trellis/src/lib/trellis_viterbi_X.cc.t deleted file mode 100644 index cadb89d574..0000000000 --- a/gr-trellis/src/lib/trellis_viterbi_X.cc.t +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <@NAME@.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <iostream> - -static const float INF = 1.0e9; - -@SPTR_NAME@ -trellis_make_@BASE_NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK) -{ - return gnuradio::get_initial_sptr (new @NAME@ (FSM,K,S0,SK)); -} - -@NAME@::@NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK) - : gr_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (float)), - gr_make_io_signature (1, -1, sizeof (@TYPE@))), - d_FSM (FSM), - d_K (K), - d_S0 (S0), - d_SK (SK)//, - //d_trace(FSM.S()*K) -{ - set_relative_rate (1.0 / ((double) d_FSM.O())); - set_output_multiple (d_K); -} - - -void -@NAME@::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - assert (noutput_items % d_K == 0); - int input_required = d_FSM.O() * noutput_items ; - unsigned ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) { - ninput_items_required[i] = input_required; - } -} - -/* -template -void viterbi_algorithm<@O_TYPE@>(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - const float *in, @O_TYPE@ *out); -*/ - - - -/* Moved it to "core_algorithms.cc" */ -/* -void viterbi_algorithm(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - const float *in, @TYPE@ *out)//, - //std::vector<int> &trace) -{ - std::vector<int> trace(S*K); - std::vector<float> alpha(S*2); - int alphai; - float norm,mm,minm; - int minmi; - int st; - - - if(S0<0) { // initial state not specified - for(int i=0;i<S;i++) alpha[0*S+i]=0; - } - else { - for(int i=0;i<S;i++) alpha[0*S+i]=INF; - alpha[0*S+S0]=0.0; - } - - alphai=0; - for(int k=0;k<K;k++) { - norm=INF; - for(int j=0;j<S;j++) { // for each next state do ACS - minm=INF; - minmi=0; - for(unsigned int i=0;i<PS[j].size();i++) { - //int i0 = j*I+i; - if((mm=alpha[alphai*S+PS[j][i]]+in[k*O+OS[PS[j][i]*I+PI[j][i]]])<minm) - minm=mm,minmi=i; - } - trace[k*S+j]=minmi; - alpha[((alphai+1)%2)*S+j]=minm; - if(minm<norm) norm=minm; - } - for(int j=0;j<S;j++) - alpha[((alphai+1)%2)*S+j]-=norm; // normalize total metrics so they do not explode - alphai=(alphai+1)%2; - } - - if(SK<0) { // final state not specified - minm=INF; - minmi=0; - for(int i=0;i<S;i++) - if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i; - st=minmi; - } - else { - st=SK; - } - - for(int k=K-1;k>=0;k--) { // traceback - int i0=trace[k*S+st]; - out[k]= (@TYPE@) PI[st][i0]; - st=PS[st][i0]; - } - -} - -*/ - - - - -int -@NAME@::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert (input_items.size() == output_items.size()); - int nstreams = input_items.size(); - assert (noutput_items % d_K == 0); - int nblocks = noutput_items / d_K; - - for (int m=0;m<nstreams;m++) { - const float *in = (const float *) input_items[m]; - @TYPE@ *out = (@TYPE@ *) output_items[m]; - for (int n=0;n<nblocks;n++) { - viterbi_algorithm(d_FSM.I(),d_FSM.S(),d_FSM.O(),d_FSM.NS(),d_FSM.OS(),d_FSM.PS(),d_FSM.PI(),d_K,d_S0,d_SK,&(in[n*d_K*d_FSM.O()]),&(out[n*d_K]));//,d_trace); - } - } - - consume_each (d_FSM.O() * noutput_items ); - return noutput_items; -} diff --git a/gr-trellis/src/lib/trellis_viterbi_X.h.t b/gr-trellis/src/lib/trellis_viterbi_X.h.t deleted file mode 100644 index c0400d3410..0000000000 --- a/gr-trellis/src/lib/trellis_viterbi_X.h.t +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <trellis_api.h> -#include "fsm.h" -#include <gr_block.h> -#include "core_algorithms.h" - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK); - - - -/*! - * \ingroup coding_blk - */ -class TRELLIS_API @NAME@ : public gr_block -{ - fsm d_FSM; - int d_K; - int d_S0; - int d_SK; - //std::vector<int> d_trace; - - friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK); - - - @NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK); - - -public: - fsm FSM () const { return d_FSM; } - int K () const { return d_K; } - int S0 () const { return d_S0; } - int SK () const { return d_SK; } - //std::vector<int> trace () const { return d_trace; } - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - - - - - - - - -#endif diff --git a/gr-trellis/src/lib/trellis_viterbi_X.i.t b/gr-trellis/src/lib/trellis_viterbi_X.i.t deleted file mode 100644 index 063f4a1b39..0000000000 --- a/gr-trellis/src/lib/trellis_viterbi_X.i.t +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); - -@SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK); - - -class @NAME@ : public gr_block -{ -private: - @NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK); - -public: - fsm FSM () const { return d_FSM; } - int K () const { return d_K; } - int S0 () const { return d_S0; } - int SK () const { return d_SK; } - //std::vector<short> trace () const { return d_trace; } -}; diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t b/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t deleted file mode 100644 index b337b6f16c..0000000000 --- a/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t +++ /dev/null @@ -1,191 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <@NAME@.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <iostream> - -static const float INF = 1.0e9; - -@SPTR_NAME@ -trellis_make_@BASE_NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE) -{ - return gnuradio::get_initial_sptr (new @NAME@ (FSM,K,S0,SK,D,TABLE,TYPE)); -} - -@NAME@::@NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE) - : gr_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, -1, sizeof (@O_TYPE@))), - d_FSM (FSM), - d_K (K), - d_S0 (S0), - d_SK (SK), - d_D (D), - d_TABLE (TABLE), - d_TYPE (TYPE)//, - //d_trace(FSM.S()*K) -{ - set_relative_rate (1.0 / ((double) d_D)); - set_output_multiple (d_K); -} - - -void @NAME@::set_TABLE(const std::vector<@I_TYPE@> &table) -{ - d_TABLE = table; -} - -void -@NAME@::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - assert (noutput_items % d_K == 0); - int input_required = d_D * noutput_items ; - unsigned ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) { - ninput_items_required[i] = input_required; - } -} - - - - -/* -void viterbi_algorithm_combined(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE, - const @I_TYPE@ *in, @O_TYPE@ *out)//, - //std::vector<int> &trace) -{ - std::vector<int> trace(S*K); - std::vector<float> alpha(S*2); - float *metric = new float[O]; - int alphai; - float norm,mm,minm; - int minmi; - int st; - - if(S0<0) { // initial state not specified - for(int i=0;i<S;i++) alpha[0*S+i]=0; - } - else { - for(int i=0;i<S;i++) alpha[0*S+i]=INF; - alpha[0*S+S0]=0.0; - } - - alphai=0; - for(int k=0;k<K;k++) { - calc_metric(O, D, TABLE, &(in[k*D]), metric,TYPE); // calc metrics - norm=INF; - for(int j=0;j<S;j++) { // for each next state do ACS - minm=INF; - minmi=0; - for(unsigned int i=0;i<PS[j].size();i++) { - //int i0 = j*I+i; - if((mm=alpha[alphai*S+PS[j][i]]+metric[OS[PS[j][i]*I+PI[j][i]]])<minm) - minm=mm,minmi=i; - } - trace[k*S+j]=minmi; - alpha[((alphai+1)%2)*S+j]=minm; - if(minm<norm) norm=minm; - } - for(int j=0;j<S;j++) - alpha[((alphai+1)%2)*S+j]-=norm; // normalize total metrics so they do not explode - alphai=(alphai+1)%2; - } - - if(SK<0) { // final state not specified - minm=INF; - minmi=0; - for(int i=0;i<S;i++) - if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i; - st=minmi; - } - else { - st=SK; - } - - for(int k=K-1;k>=0;k--) { // traceback - int i0=trace[k*S+st]; - out[k]= (@O_TYPE@) PI[st][i0]; - st=PS[st][i0]; - } - - delete [] metric; - -} - - -*/ - - - -int -@NAME@::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert (input_items.size() == output_items.size()); - int nstreams = input_items.size(); - assert (noutput_items % d_K == 0); - int nblocks = noutput_items / d_K; - - for (int m=0;m<nstreams;m++) { - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[m]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[m]; - for (int n=0;n<nblocks;n++) { - viterbi_algorithm_combined(d_FSM.I(),d_FSM.S(),d_FSM.O(),d_FSM.NS(),d_FSM.OS(),d_FSM.PS(),d_FSM.PI(),d_K,d_S0,d_SK,d_D,d_TABLE,d_TYPE,&(in[n*d_K*d_D]),&(out[n*d_K]));//,d_trace); - } - } - - consume_each (d_D * noutput_items ); - return noutput_items; -} diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t b/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t deleted file mode 100644 index f0a64c3317..0000000000 --- a/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <trellis_api.h> -#include "fsm.h" -#include <gr_block.h> -#include "calc_metric.h" -#include "core_algorithms.h" - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - - -/*! - * \ingroup coding_blk - */ -class TRELLIS_API @NAME@ : public gr_block -{ - fsm d_FSM; - int d_K; - int d_S0; - int d_SK; - int d_D; - std::vector<@I_TYPE@> d_TABLE; - gr::digital::trellis_metric_type_t d_TYPE; - //std::vector<int> d_trace; - - friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - - - @NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - - -public: - fsm FSM () const { return d_FSM; } - int K () const { return d_K; } - int S0 () const { return d_S0; } - int SK () const { return d_SK; } - int D () const { return d_D; } - std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } - gr::digital::trellis_metric_type_t TYPE () const { return d_TYPE; } - //std::vector<int> trace () const { return d_trace; } - void set_TABLE (const std::vector<@I_TYPE@> &table); - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_XX.i.t b/gr-trellis/src/lib/trellis_viterbi_combined_XX.i.t deleted file mode 100644 index 2687a2056d..0000000000 --- a/gr-trellis/src/lib/trellis_viterbi_combined_XX.i.t +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); - -@SPTR_NAME@ trellis_make_@BASE_NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - - -class @NAME@ : public gr_block -{ -private: - @NAME@ ( - const fsm &FSM, - int K, - int S0, - int SK, - int D, - const std::vector<@I_TYPE@> &TABLE, - gr::digital::trellis_metric_type_t TYPE); - -public: - fsm FSM () const { return d_FSM; } - int K () const { return d_K; } - int S0 () const { return d_S0; } - int SK () const { return d_SK; } - int D () const { return d_D; } - std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } - gr::digital::trellis_metric_type_t TYPE () const { return d_TYPE; } - //std::vector<short> trace () const { return d_trace; } - void set_TABLE (const std::vector<@I_TYPE@> &table); -}; diff --git a/gr-trellis/swig/CMakeLists.txt b/gr-trellis/swig/CMakeLists.txt new file mode 100644 index 0000000000..36a5f850ad --- /dev/null +++ b/gr-trellis/swig/CMakeLists.txt @@ -0,0 +1,57 @@ +# Copyright 2012 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. + +######################################################################## +# Setup swig generation +######################################################################## +include(GrPython) +include(GrSwig) + +set(GR_SWIG_INCLUDE_DIRS + ${GR_TRELLIS_INCLUDE_DIRS} + ${GR_DIGITAL_INCLUDE_DIRS} + ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} +) + +set(GR_SWIG_LIBRARIES gnuradio-trellis gnuradio-digital) + +if(ENABLE_GR_CTRLPORT) + ADD_DEFINITIONS(-DGR_CTRLPORT) +endif(ENABLE_GR_CTRLPORT) + +# Setup swig docs to depend on includes and pull in from build directory +set(GR_SWIG_TARGET_DEPS trellis_generated_includes) +set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/trellis_swig_doc.i) +set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../lib) + +GR_SWIG_MAKE(trellis_swig trellis_swig.i) + +GR_SWIG_INSTALL( + TARGETS trellis_swig + DESTINATION ${GR_PYTHON_DIR}/gnuradio/trellis + COMPONENT "trellis_python" +) + +install( + FILES + trellis_swig.i + ${CMAKE_CURRENT_BINARY_DIR}/trellis_swig_doc.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "trellis_swig" +) diff --git a/gr-trellis/swig/trellis_swig.i b/gr-trellis/swig/trellis_swig.i new file mode 100644 index 0000000000..5732aca1fb --- /dev/null +++ b/gr-trellis/swig/trellis_swig.i @@ -0,0 +1,216 @@ +/* + * Copyright 2012 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. + */ + +#define TRELLIS_API +#define DIGITAL_API + +%include "gnuradio.i" + +//load generated python docstrings +%include "trellis_swig_doc.i" + +%include "digital/metric_type.h" +%include "digital/constellation.h" +%include "trellis/siso_type.h" +%include "trellis/fsm.h" +%include "trellis/interleaver.h" + +%{ +#include "trellis/constellation_metrics_cf.h" +#include "trellis/permutation.h" +#include "trellis/siso_combined_f.h" +#include "trellis/siso_f.h" +#include "trellis/encoder_bb.h" +#include "trellis/encoder_bs.h" +#include "trellis/encoder_bi.h" +#include "trellis/encoder_ss.h" +#include "trellis/encoder_si.h" +#include "trellis/encoder_ii.h" +#include "trellis/sccc_encoder_bb.h" +#include "trellis/sccc_encoder_bs.h" +#include "trellis/sccc_encoder_bi.h" +#include "trellis/sccc_encoder_ss.h" +#include "trellis/sccc_encoder_si.h" +#include "trellis/sccc_encoder_ii.h" +#include "trellis/pccc_encoder_bb.h" +#include "trellis/pccc_encoder_bs.h" +#include "trellis/pccc_encoder_bi.h" +#include "trellis/pccc_encoder_ss.h" +#include "trellis/pccc_encoder_si.h" +#include "trellis/pccc_encoder_ii.h" +#include "trellis/metrics_s.h" +#include "trellis/metrics_i.h" +#include "trellis/metrics_f.h" +#include "trellis/metrics_c.h" +#include "trellis/pccc_decoder_b.h" +#include "trellis/pccc_decoder_s.h" +#include "trellis/pccc_decoder_i.h" +#include "trellis/pccc_decoder_combined_fb.h" +#include "trellis/pccc_decoder_combined_fs.h" +#include "trellis/pccc_decoder_combined_fi.h" +#include "trellis/pccc_decoder_combined_cb.h" +#include "trellis/pccc_decoder_combined_cs.h" +#include "trellis/pccc_decoder_combined_ci.h" +#include "trellis/viterbi_b.h" +#include "trellis/viterbi_s.h" +#include "trellis/viterbi_i.h" +#include "trellis/viterbi_combined_sb.h" +#include "trellis/viterbi_combined_ss.h" +#include "trellis/viterbi_combined_si.h" +#include "trellis/viterbi_combined_ib.h" +#include "trellis/viterbi_combined_is.h" +#include "trellis/viterbi_combined_ii.h" +#include "trellis/viterbi_combined_fb.h" +#include "trellis/viterbi_combined_fs.h" +#include "trellis/viterbi_combined_fi.h" +#include "trellis/viterbi_combined_cb.h" +#include "trellis/viterbi_combined_cs.h" +#include "trellis/viterbi_combined_ci.h" +#include "trellis/sccc_decoder_b.h" +#include "trellis/sccc_decoder_s.h" +#include "trellis/sccc_decoder_i.h" +#include "trellis/sccc_decoder_combined_fb.h" +#include "trellis/sccc_decoder_combined_fs.h" +#include "trellis/sccc_decoder_combined_fi.h" +#include "trellis/sccc_decoder_combined_cb.h" +#include "trellis/sccc_decoder_combined_cs.h" +#include "trellis/sccc_decoder_combined_ci.h" +%} + +%include "trellis/constellation_metrics_cf.h" +%include "trellis/permutation.h" +%include "trellis/siso_combined_f.h" +%include "trellis/siso_f.h" +%include "trellis/encoder_bb.h" +%include "trellis/encoder_bs.h" +%include "trellis/encoder_bi.h" +%include "trellis/encoder_ss.h" +%include "trellis/encoder_si.h" +%include "trellis/encoder_ii.h" +%include "trellis/sccc_encoder_bb.h" +%include "trellis/sccc_encoder_bs.h" +%include "trellis/sccc_encoder_bi.h" +%include "trellis/sccc_encoder_ss.h" +%include "trellis/sccc_encoder_si.h" +%include "trellis/sccc_encoder_ii.h" +%include "trellis/pccc_encoder_bb.h" +%include "trellis/pccc_encoder_bs.h" +%include "trellis/pccc_encoder_bi.h" +%include "trellis/pccc_encoder_ss.h" +%include "trellis/pccc_encoder_si.h" +%include "trellis/pccc_encoder_ii.h" +%include "trellis/metrics_s.h" +%include "trellis/metrics_i.h" +%include "trellis/metrics_f.h" +%include "trellis/metrics_c.h" +%include "trellis/pccc_decoder_b.h" +%include "trellis/pccc_decoder_s.h" +%include "trellis/pccc_decoder_i.h" +%include "trellis/pccc_decoder_combined_fb.h" +%include "trellis/pccc_decoder_combined_fs.h" +%include "trellis/pccc_decoder_combined_fi.h" +%include "trellis/pccc_decoder_combined_cb.h" +%include "trellis/pccc_decoder_combined_cs.h" +%include "trellis/pccc_decoder_combined_ci.h" +%include "trellis/viterbi_b.h" +%include "trellis/viterbi_s.h" +%include "trellis/viterbi_i.h" +%include "trellis/viterbi_combined_sb.h" +%include "trellis/viterbi_combined_ss.h" +%include "trellis/viterbi_combined_si.h" +%include "trellis/viterbi_combined_ib.h" +%include "trellis/viterbi_combined_is.h" +%include "trellis/viterbi_combined_ii.h" +%include "trellis/viterbi_combined_fb.h" +%include "trellis/viterbi_combined_fs.h" +%include "trellis/viterbi_combined_fi.h" +%include "trellis/viterbi_combined_cb.h" +%include "trellis/viterbi_combined_cs.h" +%include "trellis/viterbi_combined_ci.h" +%include "trellis/sccc_decoder_b.h" +%include "trellis/sccc_decoder_s.h" +%include "trellis/sccc_decoder_i.h" +%include "trellis/sccc_decoder_combined_fb.h" +%include "trellis/sccc_decoder_combined_fs.h" +%include "trellis/sccc_decoder_combined_fi.h" +%include "trellis/sccc_decoder_combined_cb.h" +%include "trellis/sccc_decoder_combined_cs.h" +%include "trellis/sccc_decoder_combined_ci.h" + +GR_SWIG_BLOCK_MAGIC2(trellis, constellation_metrics_cf); +GR_SWIG_BLOCK_MAGIC2(trellis, permutation); +GR_SWIG_BLOCK_MAGIC2(trellis, siso_combined_f); +GR_SWIG_BLOCK_MAGIC2(trellis, siso_f); +GR_SWIG_BLOCK_MAGIC2(trellis, encoder_bb); +GR_SWIG_BLOCK_MAGIC2(trellis, encoder_bs); +GR_SWIG_BLOCK_MAGIC2(trellis, encoder_bi); +GR_SWIG_BLOCK_MAGIC2(trellis, encoder_ss); +GR_SWIG_BLOCK_MAGIC2(trellis, encoder_si); +GR_SWIG_BLOCK_MAGIC2(trellis, encoder_ii); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_encoder_bb); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_encoder_bs); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_encoder_bi); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_encoder_ss); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_encoder_si); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_encoder_ii); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_encoder_bb); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_encoder_bs); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_encoder_bi); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_encoder_ss); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_encoder_si); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_encoder_ii); +GR_SWIG_BLOCK_MAGIC2(trellis, metrics_s); +GR_SWIG_BLOCK_MAGIC2(trellis, metrics_i); +GR_SWIG_BLOCK_MAGIC2(trellis, metrics_f); +GR_SWIG_BLOCK_MAGIC2(trellis, metrics_c); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_b); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_s); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_i); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_combined_fb); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_combined_fs); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_combined_fi); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_combined_cb); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_combined_cs); +GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_combined_ci); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_b); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_s); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_i); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_sb); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_ss); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_si); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_ib); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_is); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_ii); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_fb); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_fs); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_fi); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_cb); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_cs); +GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_ci); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_b); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_s); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_i); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_combined_fb); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_combined_fs); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_combined_fi); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_combined_cb); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_combined_cs); +GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_combined_ci); diff --git a/gr-uhd/CMakeLists.txt b/gr-uhd/CMakeLists.txt index 23fef3a485..05094032a7 100644 --- a/gr-uhd/CMakeLists.txt +++ b/gr-uhd/CMakeLists.txt @@ -33,6 +33,7 @@ GR_REGISTER_COMPONENT("gr-uhd" ENABLE_GR_UHD UHD_FOUND ENABLE_GR_CORE ENABLE_GR_FILTER + ENABLE_GR_BLOCKS ENABLE_GR_ANALOG ) diff --git a/gr-uhd/apps/hf_explorer/hfx.py b/gr-uhd/apps/hf_explorer/hfx.py index 8033273d06..15962f9e4d 100755 --- a/gr-uhd/apps/hf_explorer/hfx.py +++ b/gr-uhd/apps/hf_explorer/hfx.py @@ -83,6 +83,7 @@ from gnuradio.wxgui import powermate, fftsink2 from gnuradio import gr, audio, eng_notation from gnuradio import analog from gnuradio import filter +from gnuradio import blocks from gnuradio.eng_option import eng_option from gnuradio import uhd from optparse import OptionParser @@ -258,10 +259,10 @@ class MyFrame(wx.Frame): self.tune_offset = 2200 # 2200 works for 3.5-4Mhz band # convert rf data in interleaved short int form to complex - s2ss = gr.stream_to_streams(gr.sizeof_short,2) - s2f1 = gr.short_to_float() - s2f2 = gr.short_to_float() - src_f2c = gr.float_to_complex() + s2ss = blocks.stream_to_streams(gr.sizeof_short,2) + s2f1 = blocks.short_to_float() + s2f2 = blocks.short_to_float() + src_f2c = blocks.float_to_complex() self.tb.connect(self.src,s2ss) self.tb.connect((s2ss,0),s2f1) self.tb.connect((s2ss,1),s2f2) @@ -307,21 +308,21 @@ class MyFrame(wx.Frame): c2f = gr.complex_to_float() # AM branch - self.sel_am = gr.multiply_const_cc(0) + self.sel_am = blocks.multiply_const_cc(0) # the following frequencies turn out to be in radians/sample # analog.pll_refout_cc(alpha,beta,min_freq,max_freq) # suggested alpha = X, beta = .25 * X * X pll = analog.pll_refout_cc(.5,.0625,(2.*math.pi*7.5e3/self.af_sample_rate), (2.*math.pi*6.5e3/self.af_sample_rate)) - self.pll_carrier_scale = gr.multiply_const_cc(complex(10,0)) - am_det = gr.multiply_cc() + self.pll_carrier_scale = blocks.multiply_const_cc(complex(10,0)) + am_det = blocks.multiply_cc() # these are for converting +7.5kHz to -7.5kHz - # for some reason gr.conjugate_cc() adds noise ?? + # for some reason blocks.conjugate_cc() adds noise ?? c2f2 = gr.complex_to_float() c2f3 = gr.complex_to_float() - f2c = gr.float_to_complex() - phaser1 = gr.multiply_const_ff(1) - phaser2 = gr.multiply_const_ff(-1) + f2c = blocks.float_to_complex() + phaser1 = blocks.multiply_const_ff(1) + phaser2 = blocks.multiply_const_ff(-1) # filter for pll generated carrier pll_carrier_coeffs = filter.firdes.complex_band_pass ( @@ -334,16 +335,16 @@ class MyFrame(wx.Frame): self.pll_carrier_filter = filter.fir_filter_ccc (1, pll_carrier_coeffs) - self.sel_sb = gr.multiply_const_ff(1) - combine = gr.add_ff() + self.sel_sb = blocks.multiply_const_ff(1) + combine = blocks.add_ff() #AGC - sqr1 = gr.multiply_ff() - intr = gr.iir_filter_ffd ( [.004, 0], [0, .999] ) - offset = gr.add_const_ff(1) - agc = gr.divide_ff() + sqr1 = blocks.multiply_ff() + intr = filter.iir_filter_ffd( [.004, 0], [0, .999] ) + offset = blocks.add_const_ff(1) + agc = blocks.divide_ff() - self.scale = gr.multiply_const_ff(0.00001) + self.scale = blocks.multiply_const_ff(0.00001) dst = audio.sink(long(self.af_sample_rate), options.audio_output) @@ -375,8 +376,8 @@ class MyFrame(wx.Frame): if SAVE_AUDIO_TO_FILE: f_out = gr.file_sink(gr.sizeof_short,options.audio_file) - sc1 = gr.multiply_const_ff(64000) - f2s1 = gr.float_to_short() + sc1 = blocks.multiply_const_ff(64000) + f2s1 = blocks.float_to_short() self.tb.connect(agc,sc1,f2s1,f_out) self.tb.start() diff --git a/gr-uhd/apps/hf_radio/output.py b/gr-uhd/apps/hf_radio/output.py index 70add5b84a..3e80c8d315 100644 --- a/gr-uhd/apps/hf_radio/output.py +++ b/gr-uhd/apps/hf_radio/output.py @@ -24,6 +24,7 @@ # M. Revnell 2005-Dec from gnuradio import gr, gru +from gnuradio import blocks from gnuradio import audio class output( gr.hier_block2 ): @@ -32,7 +33,7 @@ class output( gr.hier_block2 ): gr.io_signature(1,1,gr.sizeof_float), gr.io_signature(0,0,0)) - self.vol = gr.multiply_const_ff( 0.1 ) + self.vol = blocks.multiply_const_ff( 0.1 ) self.out = audio.sink( int(rate), device ) self.connect( self, self.vol, self.out ) diff --git a/gr-uhd/apps/hf_radio/ssbagc.py b/gr-uhd/apps/hf_radio/ssbagc.py index 6a2e0a7cd4..48cc009101 100644 --- a/gr-uhd/apps/hf_radio/ssbagc.py +++ b/gr-uhd/apps/hf_radio/ssbagc.py @@ -43,6 +43,8 @@ # M. Revnell 2006-Jan from gnuradio import gr +from gnuradio import blocks +from gnuradio import filter class agc( gr.hier_block2 ): def __init__( self ): @@ -50,13 +52,13 @@ class agc( gr.hier_block2 ): gr.io_signature(1,1,gr.sizeof_float), gr.io_signature(1,1,gr.sizeof_float)) - self.split = gr.multiply_const_ff( 1 ) - self.sqr = gr.multiply_ff( ) - self.int0 = gr.iir_filter_ffd( [.004, 0], [0, .999] ) - self.offs = gr.add_const_ff( -30 ) - self.gain = gr.multiply_const_ff( 70 ) - self.log = gr.nlog10_ff( 10, 1 ) - self.agc = gr.divide_ff( ) + self.split = blocks.multiply_const_ff( 1 ) + self.sqr = blocks.multiply_ff( ) + self.int0 = filter.iir_filter_ffd( [.004, 0], [0, .999] ) + self.offs = blocks.add_const_ff( -30 ) + self.gain = blocks.multiply_const_ff( 70 ) + self.log = blocks.nlog10_ff( 10, 1 ) + self.agc = blocks.divide_ff( ) self.connect(self, self.split) self.connect(self.split, (self.agc, 0)) diff --git a/gr-uhd/apps/hf_radio/ssbdemod.py b/gr-uhd/apps/hf_radio/ssbdemod.py index 3c533f617f..a77fb6cfcb 100644 --- a/gr-uhd/apps/hf_radio/ssbdemod.py +++ b/gr-uhd/apps/hf_radio/ssbdemod.py @@ -32,6 +32,7 @@ # M. Revnell Jan 06 from gnuradio import gr +from gnuradio import blocks class ssb_demod( gr.hier_block2 ): def __init__( self, if_rate, af_rate ): @@ -64,10 +65,10 @@ class ssb_demod( gr.hier_block2 ): self.lpf = gr.fir_filter_fff( 1, self.audio_taps ) - self.sum = gr.add_ff( ) - self.am_sel = gr.multiply_const_ff( 0 ) - self.sb_sel = gr.multiply_const_ff( 1 ) - self.mixer = gr.add_ff() + self.sum = blocks.add_ff( ) + self.am_sel = blocks.multiply_const_ff( 0 ) + self.sb_sel = blocks.multiply_const_ff( 1 ) + self.mixer = blocks.add_ff() self.am_det = gr.complex_to_mag() self.connect(self, self.xlate) diff --git a/gr-uhd/apps/uhd_rx_nogui b/gr-uhd/apps/uhd_rx_nogui index c348ba23f5..a17ab7459f 100755 --- a/gr-uhd/apps/uhd_rx_nogui +++ b/gr-uhd/apps/uhd_rx_nogui @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, uhd, audio, blks2 +from gnuradio import gr, gru, uhd, audio from gnuradio import filter from gnuradio import analog from gnuradio import eng_notation @@ -184,7 +184,7 @@ class app_top_block(gr.top_block): out_lcm = gru.lcm(audio_rate, options.output_rate) out_interp = int(out_lcm // audio_rate) out_decim = int(out_lcm // options.output_rate) - RSAMP = blks2.rational_resampler_fff(out_interp, out_decim) + RSAMP = filter.rational_resampler_fff(out_interp, out_decim) self.connect(tail, RSAMP) tail = RSAMP diff --git a/gr-uhd/apps/uhd_siggen_base.py b/gr-uhd/apps/uhd_siggen_base.py index 3dcebab29c..6b51bfcb50 100644 --- a/gr-uhd/apps/uhd_siggen_base.py +++ b/gr-uhd/apps/uhd_siggen_base.py @@ -40,6 +40,7 @@ def setter(ps, key, val): ps[key] = val from gnuradio import gr, gru, uhd, eng_notation from gnuradio import analog +from gnuradio import blocks from gnuradio.gr.pubsub import pubsub from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -48,10 +49,10 @@ import math n2s = eng_notation.num_to_str -waveforms = { gr.GR_SIN_WAVE : "Complex Sinusoid", - gr.GR_CONST_WAVE : "Constant", - gr.GR_GAUSSIAN : "Gaussian Noise", - gr.GR_UNIFORM : "Uniform Noise", +waveforms = { analog.GR_SIN_WAVE : "Complex Sinusoid", + analog.GR_CONST_WAVE : "Constant", + analog.GR_GAUSSIAN : "Gaussian Noise", + analog.GR_UNIFORM : "Uniform Noise", "2tone" : "Two Tone", "sweep" : "Sweep" } @@ -165,7 +166,7 @@ class top_block(gr.top_block, pubsub): self._u.set_samp_rate(sr) sr = self._u.get_samp_rate() - if self[TYPE_KEY] in (gr.GR_SIN_WAVE, gr.GR_CONST_WAVE): + if self[TYPE_KEY] in (analog.GR_SIN_WAVE, analog.GR_CONST_WAVE): self._src.set_sampling_freq(self[SAMP_RATE_KEY]) elif self[TYPE_KEY] == "2tone": self._src1.set_sampling_freq(self[SAMP_RATE_KEY]) @@ -218,7 +219,7 @@ class top_block(gr.top_block, pubsub): return tr def set_waveform_freq(self, freq): - if self[TYPE_KEY] == gr.GR_SIN_WAVE: + if self[TYPE_KEY] == analog.GR_SIN_WAVE: self._src.set_frequency(freq) elif self[TYPE_KEY] == "2tone": self._src1.set_frequency(freq) @@ -262,7 +263,7 @@ class top_block(gr.top_block, pubsub): self[WAVEFORM2_FREQ_KEY], self[AMPLITUDE_KEY]/2.0, 0) - self._src = gr.add_cc() + self._src = blocks.add_cc() self.connect(self._src1,(self._src,0)) self.connect(self._src2,(self._src,1)) elif type == "sweep": @@ -279,7 +280,7 @@ class top_block(gr.top_block, pubsub): 1.0, -0.5) self._src2 = analog.frequency_modulator_fc(self[WAVEFORM_FREQ_KEY]*2*math.pi/self[SAMP_RATE_KEY]) - self._src = gr.multiply_const_cc(self[AMPLITUDE_KEY]) + self._src = blocks.multiply_const_cc(self[AMPLITUDE_KEY]) self.connect(self._src1,self._src2,self._src) else: raise RuntimeError("Unknown waveform type") diff --git a/gr-uhd/apps/uhd_siggen_gui b/gr-uhd/apps/uhd_siggen_gui index 70929b1825..80fcf8e673 100755 --- a/gr-uhd/apps/uhd_siggen_gui +++ b/gr-uhd/apps/uhd_siggen_gui @@ -22,6 +22,7 @@ import wx from gnuradio import gr, uhd +from gnuradio import analog from gnuradio.gr.pubsub import pubsub from gnuradio.wxgui import gui, forms from gnuradio.uhd import uhd_siggen_base as uhd_siggen @@ -58,7 +59,7 @@ class app_gui(pubsub): self.vbox.AddStretchSpacer() #callback to show/hide forms def set_type(type): - sine_bb_hbox.ShowItems(type == gr.GR_SIN_WAVE) + sine_bb_hbox.ShowItems(type == analog.GR_SIN_WAVE) sweep_bb_hbox.ShowItems(type == 'sweep') tone_bb_hbox.ShowItems(type == '2tone') self.vbox.Layout() diff --git a/gr-uhd/examples/grc/uhd_dpsk_mod.grc b/gr-uhd/examples/grc/uhd_dpsk_mod.grc index 18ae9c3db7..9caafbb6ac 100644 --- a/gr-uhd/examples/grc/uhd_dpsk_mod.grc +++ b/gr-uhd/examples/grc/uhd_dpsk_mod.grc @@ -281,10 +281,10 @@ </param> </block> <block> - <key>gr_multiply_const_vxx</key> + <key>blocks_multiply_const_vxx</key> <param> <key>id</key> - <value>gr_multiply_const_vxx_0</value> + <value>blocks_multiply_const_vxx_0</value> </param> <param> <key>_enabled</key> @@ -2218,7 +2218,7 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_const_vxx_0</source_block_id> + <source_block_id>blocks_multiply_const_vxx_0</source_block_id> <sink_block_id>uhd_usrp_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -2231,7 +2231,7 @@ </connection> <connection> <source_block_id>digital_dxpsk_mod_0</source_block_id> - <sink_block_id>gr_multiply_const_vxx_0</sink_block_id> + <sink_block_id>blocks_multiply_const_vxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-uhd/examples/grc/uhd_two_tone_loopback.grc b/gr-uhd/examples/grc/uhd_two_tone_loopback.grc index b186c2f2bc..1884dd3ebf 100644 --- a/gr-uhd/examples/grc/uhd_two_tone_loopback.grc +++ b/gr-uhd/examples/grc/uhd_two_tone_loopback.grc @@ -2194,10 +2194,10 @@ </param> </block> <block> - <key>gr_add_xx</key> + <key>blocks_add_xx</key> <param> <key>id</key> - <value>gr_add_xx</value> + <value>blocks_add_xx</value> </param> <param> <key>_enabled</key> @@ -2260,7 +2260,7 @@ </param> </block> <connection> - <source_block_id>gr_add_xx</source_block_id> + <source_block_id>blocks_add_xx</source_block_id> <sink_block_id>uhd_usrp_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -2273,19 +2273,19 @@ </connection> <connection> <source_block_id>analog_sig_source_x_0</source_block_id> - <sink_block_id>gr_add_xx</sink_block_id> + <sink_block_id>blocks_add_xx</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>analog_sig_source_x_1</source_block_id> - <sink_block_id>gr_add_xx</sink_block_id> + <sink_block_id>blocks_add_xx</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> <source_block_id>analog_noise_source_x_0</source_block_id> - <sink_block_id>gr_add_xx</sink_block_id> + <sink_block_id>blocks_add_xx</sink_block_id> <source_key>0</source_key> <sink_key>2</sink_key> </connection> diff --git a/gr-uhd/examples/grc/uhd_tx_dpsk.grc b/gr-uhd/examples/grc/uhd_tx_dpsk.grc index 281ba84295..38318bef4b 100644 --- a/gr-uhd/examples/grc/uhd_tx_dpsk.grc +++ b/gr-uhd/examples/grc/uhd_tx_dpsk.grc @@ -1035,10 +1035,10 @@ </param> </block> <block> - <key>gr_multiply_const_vxx</key> + <key>blocks_multiply_const_vxx</key> <param> <key>id</key> - <value>gr_multiply_const_vxx_0</value> + <value>blocks_multiply_const_vxx_0</value> </param> <param> <key>_enabled</key> @@ -1214,20 +1214,20 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_const_vxx_0</source_block_id> + <source_block_id>blocks_multiply_const_vxx_0</source_block_id> <sink_block_id>wxgui_fftsink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_const_vxx_0</source_block_id> + <source_block_id>blocks_multiply_const_vxx_0</source_block_id> <sink_block_id>uhd_usrp_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>digital_dxpsk_mod_0</source_block_id> - <sink_block_id>gr_multiply_const_vxx_0</sink_block_id> + <sink_block_id>blocks_multiply_const_vxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-uhd/examples/grc/uhd_wbfm_receive.grc b/gr-uhd/examples/grc/uhd_wbfm_receive.grc index 7f14123f2e..943e82cf31 100644 --- a/gr-uhd/examples/grc/uhd_wbfm_receive.grc +++ b/gr-uhd/examples/grc/uhd_wbfm_receive.grc @@ -347,10 +347,10 @@ </param> </block> <block> - <key>gr_multiply_const_vxx</key> + <key>blocks_multiply_const_vxx</key> <param> <key>id</key> - <value>gr_multiply_const_vxx</value> + <value>blocks_multiply_const_vxx</value> </param> <param> <key>_enabled</key> @@ -1373,14 +1373,14 @@ </param> </block> <connection> - <source_block_id>gr_multiply_const_vxx</source_block_id> + <source_block_id>blocks_multiply_const_vxx</source_block_id> <sink_block_id>audio_sink</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>blks2_wfm_rcv</source_block_id> - <sink_block_id>gr_multiply_const_vxx</sink_block_id> + <sink_block_id>blocks_multiply_const_vxx</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-uhd/examples/python/fm_tx4.py b/gr-uhd/examples/python/fm_tx4.py index ae3e1b94f3..e4cf3ded24 100755 --- a/gr-uhd/examples/python/fm_tx4.py +++ b/gr-uhd/examples/python/fm_tx4.py @@ -35,6 +35,7 @@ audio_to_file.py from gnuradio import gr, eng_notation from gnuradio import uhd from gnuradio import analog +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import math @@ -70,7 +71,7 @@ class pipeline(gr.hier_block2): lo_freq, # frequency 1.0, # amplitude 0) # DC Offset - mixer = gr.multiply_cc() + mixer = blocks.multiply_cc() self.connect(src, fmtx, (mixer, 0)) self.connect(lo, (mixer, 1)) @@ -141,7 +142,7 @@ class fm_tx_block(stdgui2.std_top_block): self.set_gain(options.gain) self.set_freq(options.freq) - self.sum = gr.add_cc () + self.sum = blocks.add_cc () # Instantiate N NBFM channels step = 25e3 @@ -153,7 +154,7 @@ class fm_tx_block(stdgui2.std_top_block): self.audio_rate, self.usrp_rate) self.connect(t, (self.sum, i)) - self.gain = gr.multiply_const_cc (1.0 / options.nchannels) + self.gain = blocks.multiply_const_cc (1.0 / options.nchannels) # connect it all self.connect (self.sum, self.gain) diff --git a/gr-uhd/examples/python/fm_tx_2_daughterboards.py b/gr-uhd/examples/python/fm_tx_2_daughterboards.py index f896be6d04..b4958b8596 100755 --- a/gr-uhd/examples/python/fm_tx_2_daughterboards.py +++ b/gr-uhd/examples/python/fm_tx_2_daughterboards.py @@ -33,6 +33,7 @@ Side B is 350 + 440 Hz tones. from gnuradio import gr, uhd from gnuradio import filter from gnuradio import analog +from gnuradio import blocks from gnuradio.eng_notation import num_to_str, str_to_num from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -78,7 +79,7 @@ class example_signal_1(gr.hier_block2): 440, # frequency 1.0, # amplitude 0) # DC Offset - sum = gr.add_cc() + sum = blocks.add_cc() self.connect(src0, (sum, 0)) self.connect(src1, (sum, 1)) self.connect(sum, self) @@ -154,7 +155,7 @@ class my_top_block(gr.top_block): sig0 = example_signal_0(self.usrp_rate) sig1 = example_signal_1(self.usrp_rate) - intl = gr.interleave(gr.sizeof_gr_complex) + intl = blocks.interleave(gr.sizeof_gr_complex) self.connect(sig0, (intl, 0)) self.connect(sig1, (intl, 1)) diff --git a/gr-uhd/examples/python/usrp_am_mw_rcv.py b/gr-uhd/examples/python/usrp_am_mw_rcv.py index a389e173f8..5cd9d3f7ec 100755 --- a/gr-uhd/examples/python/usrp_am_mw_rcv.py +++ b/gr-uhd/examples/python/usrp_am_mw_rcv.py @@ -116,7 +116,7 @@ class wfm_rx_block (stdgui2.std_top_block): self.agc = analog.agc_cc(0.1, 1, 1, 100000) self.am_demod = gr.complex_to_mag() - self.volume_control = gr.multiply_const_ff(self.vol) + self.volume_control = blocks.multiply_const_ff(self.vol) audio_filt_coeffs = filter.firdes.low_pass_2(1, # gain demod_rate, # sampling rate diff --git a/gr-uhd/examples/python/usrp_nbfm_ptt.py b/gr-uhd/examples/python/usrp_nbfm_ptt.py index d377e3a0a2..471a4e8090 100755 --- a/gr-uhd/examples/python/usrp_nbfm_ptt.py +++ b/gr-uhd/examples/python/usrp_nbfm_ptt.py @@ -27,6 +27,7 @@ from optparse import OptionParser from gnuradio import gr, audio, uhd from gnuradio import analog +from gnuradio import blocks from gnuradio.eng_option import eng_option from gnuradio.wxgui import stdgui2, fftsink2, scopesink2, slider, form @@ -301,7 +302,7 @@ class transmit_path(gr.hier_block2): self.normal_gain = 32000 self.audio = audio.source(int(self.audio_rate), audio_input) - self.audio_amp = gr.multiply_const_ff(self.audio_gain) + self.audio_amp = blocks.multiply_const_ff(self.audio_gain) lpf = gr.firdes.low_pass (1, # gain self.audio_rate, # sampling rate @@ -319,11 +320,11 @@ class transmit_path(gr.hier_block2): self.audio_filt = gr.fir_filter_fff(1,audio_taps) self.pl = analog.ctcss_gen_f(self.audio_rate,123.0) - self.add_pl = gr.add_ff() + self.add_pl = blocks.add_ff() self.connect(self.pl,(self.add_pl,1)) self.fmtx = analog.nbfm_tx(self.audio_rate, self.if_rate) - self.amp = gr.multiply_const_cc (self.normal_gain) + self.amp = blocks.multiply_const_cc (self.normal_gain) rrate = dev_rate / self.if_rate self.resamp = filter.pfb.arb_resampler_ccf(rrate) @@ -405,7 +406,7 @@ class receive_path(gr.hier_block2): self.squelch = analog.standard_squelch(self.audio_rate) # audio gain / mute block - self._audio_gain = gr.multiply_const_ff(1.0) + self._audio_gain = blocks.multiply_const_ff(1.0) # sound card as final sink audio_sink = audio.sink(int(self.audio_rate), audio_output) diff --git a/gr-uhd/examples/python/usrp_nbfm_rcv.py b/gr-uhd/examples/python/usrp_nbfm_rcv.py index 1a06e7d06d..0652556cd1 100755 --- a/gr-uhd/examples/python/usrp_nbfm_rcv.py +++ b/gr-uhd/examples/python/usrp_nbfm_rcv.py @@ -21,6 +21,7 @@ # from gnuradio import gr, audio, uhd +from gnuradio import blocks from gnuradio import filter from gnuradio import analog from gnuradio.eng_option import eng_option @@ -304,7 +305,7 @@ class receive_path(gr.hier_block2): self.fmrx = analog.nbfm_rx(self.audio_rate, self.quad_rate) # audio gain / mute block - self._audio_gain = gr.multiply_const_ff(1.0) + self._audio_gain = blocks.multiply_const_ff(1.0) # sound card as final sink audio_sink = audio.sink (int(self.audio_rate), audio_output) diff --git a/gr-uhd/examples/python/usrp_spectrum_sense.py b/gr-uhd/examples/python/usrp_spectrum_sense.py index ce60241deb..62349da941 100755 --- a/gr-uhd/examples/python/usrp_spectrum_sense.py +++ b/gr-uhd/examples/python/usrp_spectrum_sense.py @@ -21,6 +21,7 @@ # from gnuradio import gr, eng_notation, window +from gnuradio import blocks from gnuradio import audio from gnuradio import uhd from gnuradio.eng_option import eng_option @@ -151,7 +152,7 @@ class my_top_block(gr.top_block): self.u.set_samp_rate(usrp_rate) dev_rate = self.u.get_samp_rate() - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) + s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) mywindow = window.blackmanharris(self.fft_size) fft = gr.fft_vcc(self.fft_size, True, mywindow) @@ -162,8 +163,8 @@ class my_top_block(gr.top_block): c2mag = gr.complex_to_mag_squared(self.fft_size) # FIXME the log10 primitive is dog slow - log = gr.nlog10_ff(10, self.fft_size, - -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)) + log = blocks.nlog10_ff(10, self.fft_size, + -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)) # Set the freq_step to 75% of the actual data throughput. # This allows us to discard the bins on both ends of the spectrum. diff --git a/gr-uhd/examples/python/usrp_tv_rcv.py b/gr-uhd/examples/python/usrp_tv_rcv.py index 0d0ddf531f..cd54fad3ae 100755 --- a/gr-uhd/examples/python/usrp_tv_rcv.py +++ b/gr-uhd/examples/python/usrp_tv_rcv.py @@ -48,6 +48,7 @@ except: print "realtime SDL video output window will not be available" from gnuradio import uhd from gnuradio import analog +from gnuradio import blocks from gnuradio.eng_option import eng_option from gnuradio.wxgui import slider, powermate from gnuradio.wxgui import stdgui2, fftsink2, form @@ -124,7 +125,7 @@ class tv_rx_block (stdgui2.std_top_block): if not ((filename is None) or (filename=="usrp")): # file is data source self.filesource = gr.file_source(gr.sizeof_short,filename,options.repeat) - self.istoc = gr.interleaved_short_to_complex() + self.istoc = blocks.interleaved_short_to_complex() self.connect(self.filesource,self.istoc) self.src=self.istoc @@ -154,7 +155,7 @@ class tv_rx_block (stdgui2.std_top_block): self.gain = options.gain - f2uc=gr.float_to_uchar() + f2uc = blocks.float_to_uchar() # sdl window as final sink if not (options.pal or options.ntsc): @@ -197,8 +198,8 @@ class tv_rx_block (stdgui2.std_top_block): self.agc = analog.agc_cc(1e-7,1.0,1.0) #1e-7 self.am_demod = gr.complex_to_mag () - self.set_blacklevel=gr.add_const_ff(0.0) - self.invert_and_scale = gr.multiply_const_ff (0.0) #-self.contrast *128.0*255.0/(200.0) + self.set_blacklevel = blocks.add_const_ff(0.0) + self.invert_and_scale = blocks.multiply_const_ff (0.0) #-self.contrast *128.0*255.0/(200.0) # now wire it all together #sample_rate=options.width*options.height*options.framerate @@ -238,7 +239,7 @@ class tv_rx_block (stdgui2.std_top_block): #Note: this block is not yet in cvs tv_corr=gr.tv_correlator_ff(frame_size,nframes, search_window, video_alpha, corr_alpha,debug) - shift=gr.add_const_ff(-0.7) + shift = blocks.add_const_ff(-0.7) self.connect (self.src, self.agc, self.am_demod, tv_corr, self.invert_and_scale, self.set_blacklevel, diff --git a/gr-uhd/examples/python/usrp_tv_rcv_nogui.py b/gr-uhd/examples/python/usrp_tv_rcv_nogui.py index 54275bb037..dfa6ceec1f 100755 --- a/gr-uhd/examples/python/usrp_tv_rcv_nogui.py +++ b/gr-uhd/examples/python/usrp_tv_rcv_nogui.py @@ -36,6 +36,7 @@ development but not yet in cvs. from gnuradio import gr, eng_notation from gnuradio import analog +from gnuradio import blocks from gnuradio import audio from gnuradio import uhd from gnuradio.eng_option import eng_option @@ -122,7 +123,7 @@ class my_top_block(gr.top_block): self.filesource = gr.file_source(gr.sizeof_short, options.in_filename, options.repeat) - self.istoc = gr.interleaved_short_to_complex() + self.istoc = blocks.interleaved_short_to_complex() self.connect(self.filesource,self.istoc) self.src=self.istoc else: @@ -161,9 +162,9 @@ class my_top_block(gr.top_block): self.agc = analog.agc_cc(1e-7,1.0,1.0) #1e-7 self.am_demod = gr.complex_to_mag () - self.set_blacklevel = gr.add_const_ff(options.brightness +255.0) - self.invert_and_scale = gr.multiply_const_ff (-options.contrast *128.0*255.0/(200.0)) - self.f2uc = gr.float_to_uchar() + self.set_blacklevel = blocks.add_const_ff(options.brightness +255.0) + self.invert_and_scale = blocks.multiply_const_ff(-options.contrast *128.0*255.0/(200.0)) + self.f2uc = blocks.float_to_uchar() # sdl window as final sink if not (options.pal or options.ntsc): @@ -181,8 +182,7 @@ class my_top_block(gr.top_block): if filename=="sdl": #Here comes the tv screen, you have to build and install - #gr-video-sdl for this (subproject of gnuradio, only in cvs - #for now) + #gr-video-sdl for this (subproject of gnuradio) try: video_sink = video_sdl.sink_uc(frames_per_sec, width, height, 0, show_width,height) diff --git a/gr-uhd/examples/python/usrp_wfm_rcv.py b/gr-uhd/examples/python/usrp_wfm_rcv.py index 824af8975c..351f2c7be4 100755 --- a/gr-uhd/examples/python/usrp_wfm_rcv.py +++ b/gr-uhd/examples/python/usrp_wfm_rcv.py @@ -21,6 +21,7 @@ # from gnuradio import gr, optfir, audio, uhd +from gnuradio import blocks from gnuradio import filter from gnuradio import analog from gnuradio.eng_option import eng_option @@ -101,7 +102,7 @@ class wfm_rx_block (stdgui2.std_top_block): self.guts = analog.wfm_rcv(demod_rate, audio_decim) - self.volume_control = gr.multiply_const_ff(self.vol) + self.volume_control = blocks.multiply_const_ff(self.vol) # sound card as final sink self.audio_sink = audio.sink(int (audio_rate), diff --git a/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py b/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py index e76c78e017..42cea79e73 100755 --- a/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py +++ b/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py @@ -21,6 +21,7 @@ # from gnuradio import gr, audio, uhd +from gnuradio import blocks from gnuradio import filter from gnuradio import analog from gnuradio.eng_option import eng_option @@ -115,7 +116,7 @@ class wfm_rx_block (gr.top_block): for n in range(2): chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts) guts = analog.wfm_rcv(demod_rate, audio_decim) - volume_control = gr.multiply_const_ff(self.vol) + volume_control = blocks.multiply_const_ff(self.vol) #self.connect((self.di, n), chan_filt) self.connect((self.u, n), chan_filt) diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py b/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py index 97bd2b2d32..e03b86025f 100755 --- a/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py +++ b/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py @@ -20,7 +20,8 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, audio, uhd +from gnuradio import gr, audio, uhdf +from gnuradio import blocks from gnuradio import filter from gnuradio import analog from gnuradio.eng_option import eng_option @@ -107,8 +108,8 @@ class wfm_rx_block (stdgui2.std_top_block): self.lchan_filt = filter.pfb.arb_resampler_fff(chan_rate) # FIXME rework {add,multiply}_const_* to handle multiple streams - self.volume_control_l = gr.multiply_const_ff(self.vol) - self.volume_control_r = gr.multiply_const_ff(self.vol) + self.volume_control_l = blocks.multiply_const_ff(self.vol) + self.volume_control_r = blocks.multiply_const_ff(self.vol) # sound card as final sink self.audio_sink = audio.sink(int (audio_rate), diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py b/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py index f2271fb6db..2116eb96b6 100755 --- a/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py +++ b/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py @@ -21,6 +21,7 @@ # from gnuradio import gr, optfir, audio, uhd +from gnuradio import blocks from gnuradio import filter from gnuradio import analog from gnuradio import eng_notation @@ -95,7 +96,7 @@ class wfm_rx_block (gr.top_block): self.guts = analog.wfm_rcv(demod_rate, audio_decim) - self.volume_control = gr.multiply_const_ff(1) + self.volume_control = blocks.multiply_const_ff(1) # sound card as final sink self.audio_sink = audio.sink(int(audio_rate), diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_pll.py b/gr-uhd/examples/python/usrp_wfm_rcv_pll.py index 8cd3d5ab13..5d3045589c 100755 --- a/gr-uhd/examples/python/usrp_wfm_rcv_pll.py +++ b/gr-uhd/examples/python/usrp_wfm_rcv_pll.py @@ -21,6 +21,7 @@ # from gnuradio import gr, audio, uhd +from gnuradio import blocks from gnuradio import filter from gnuradio import analog from gnuradio import eng_notation @@ -108,8 +109,8 @@ class wfm_rx_block (stdgui2.std_top_block): self.lchan_filt = filter.pfb.arb_resampler_fff(chan_rate) # FIXME rework {add,multiply}_const_* to handle multiple streams - self.volume_control_l = gr.multiply_const_ff(self.vol) - self.volume_control_r = gr.multiply_const_ff(self.vol) + self.volume_control_l = blocks.multiply_const_ff(self.vol) + self.volume_control_r = blocks.multiply_const_ff(self.vol) # sound card as final sink self.audio_sink = audio.sink (int (audio_rate), diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_sca.py b/gr-uhd/examples/python/usrp_wfm_rcv_sca.py index 68ff27ff30..6d38efa3da 100755 --- a/gr-uhd/examples/python/usrp_wfm_rcv_sca.py +++ b/gr-uhd/examples/python/usrp_wfm_rcv_sca.py @@ -51,6 +51,7 @@ OFDM. from gnuradio import gr, audio, uhd +from gnuradio import blocks from gnuradio import filter from gnuradio import analog from gnuradio.eng_option import eng_option @@ -180,7 +181,7 @@ class wfm_rx_sca_block (stdgui2.std_top_block): # Create deemphasis block that is applied after SCA demodulation self.deemph = analog.fm_deemph(audio_rate, sca_tau) - self.volume_control = gr.multiply_const_ff(self.vol) + self.volume_control = blocks.multiply_const_ff(self.vol) # sound card as final sink self.audio_sink = audio.sink(int (audio_rate), diff --git a/gr-uhd/examples/python/usrp_wxapt_rcv.py b/gr-uhd/examples/python/usrp_wxapt_rcv.py index ef774e2a07..446e4bf2c8 100755 --- a/gr-uhd/examples/python/usrp_wxapt_rcv.py +++ b/gr-uhd/examples/python/usrp_wxapt_rcv.py @@ -21,6 +21,7 @@ # from gnuradio import gr, audio, uhd +from gnuradio import blocks from gnuradio import filter from gnuradio import analog from gnuradio.eng_option import eng_option @@ -100,7 +101,7 @@ class wxapt_rx_block (stdgui2.std_top_block): self.guts = analog.wfm_rcv(demod_rate, audio_decim) - self.volume_control = gr.multiply_const_ff(self.vol) + self.volume_control = blocks.multiply_const_ff(self.vol) # sound card as final sink self.audio_sink = audio.sink(int (audio_rate), options.audio_output) diff --git a/gr-utils/CMakeLists.txt b/gr-utils/CMakeLists.txt index 38bb245c61..e7b43f4c82 100644 --- a/gr-utils/CMakeLists.txt +++ b/gr-utils/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -48,6 +48,6 @@ CPACK_COMPONENT("utils" ######################################################################## # Add subdirectories ######################################################################## -add_subdirectory(src/python) +add_subdirectory(python) endif(ENABLE_GR_UTILS) diff --git a/gr-utils/src/python/CMakeLists.txt b/gr-utils/python/CMakeLists.txt index 4b956904f3..4b956904f3 100644 --- a/gr-utils/src/python/CMakeLists.txt +++ b/gr-utils/python/CMakeLists.txt diff --git a/gr-utils/src/python/README.plot b/gr-utils/python/README.plot index 60f14c669c..60f14c669c 100644 --- a/gr-utils/src/python/README.plot +++ b/gr-utils/python/README.plot diff --git a/gr-utils/src/python/create-gnuradio-out-of-tree-project b/gr-utils/python/create-gnuradio-out-of-tree-project index d5e32c92b8..d5e32c92b8 100755 --- a/gr-utils/src/python/create-gnuradio-out-of-tree-project +++ b/gr-utils/python/create-gnuradio-out-of-tree-project diff --git a/gr-utils/src/python/gr_plot_char b/gr-utils/python/gr_plot_char index a2b93a63c6..a2b93a63c6 100755 --- a/gr-utils/src/python/gr_plot_char +++ b/gr-utils/python/gr_plot_char diff --git a/gr-utils/src/python/gr_plot_const b/gr-utils/python/gr_plot_const index 749ad035b5..749ad035b5 100755 --- a/gr-utils/src/python/gr_plot_const +++ b/gr-utils/python/gr_plot_const diff --git a/gr-utils/src/python/gr_plot_fft b/gr-utils/python/gr_plot_fft index 4343481645..4343481645 100644 --- a/gr-utils/src/python/gr_plot_fft +++ b/gr-utils/python/gr_plot_fft diff --git a/gr-utils/src/python/gr_plot_fft_c b/gr-utils/python/gr_plot_fft_c index 43e808d95a..43e808d95a 100755 --- a/gr-utils/src/python/gr_plot_fft_c +++ b/gr-utils/python/gr_plot_fft_c diff --git a/gr-utils/src/python/gr_plot_fft_f b/gr-utils/python/gr_plot_fft_f index dee9b17dea..dee9b17dea 100755 --- a/gr-utils/src/python/gr_plot_fft_f +++ b/gr-utils/python/gr_plot_fft_f diff --git a/gr-utils/src/python/gr_plot_float b/gr-utils/python/gr_plot_float index 22806e48ae..22806e48ae 100755 --- a/gr-utils/src/python/gr_plot_float +++ b/gr-utils/python/gr_plot_float diff --git a/gr-utils/src/python/gr_plot_int b/gr-utils/python/gr_plot_int index 355ddf0189..355ddf0189 100755 --- a/gr-utils/src/python/gr_plot_int +++ b/gr-utils/python/gr_plot_int diff --git a/gr-utils/src/python/gr_plot_iq b/gr-utils/python/gr_plot_iq index bf8077b6b4..bf8077b6b4 100755 --- a/gr-utils/src/python/gr_plot_iq +++ b/gr-utils/python/gr_plot_iq diff --git a/gr-utils/src/python/gr_plot_psd b/gr-utils/python/gr_plot_psd index 059ca6b645..059ca6b645 100644 --- a/gr-utils/src/python/gr_plot_psd +++ b/gr-utils/python/gr_plot_psd diff --git a/gr-utils/src/python/gr_plot_psd_c b/gr-utils/python/gr_plot_psd_c index fff2bff0f2..fff2bff0f2 100755 --- a/gr-utils/src/python/gr_plot_psd_c +++ b/gr-utils/python/gr_plot_psd_c diff --git a/gr-utils/src/python/gr_plot_psd_f b/gr-utils/python/gr_plot_psd_f index ec67994797..ec67994797 100755 --- a/gr-utils/src/python/gr_plot_psd_f +++ b/gr-utils/python/gr_plot_psd_f diff --git a/gr-utils/src/python/gr_plot_qt b/gr-utils/python/gr_plot_qt index 153359f0c6..153359f0c6 100755 --- a/gr-utils/src/python/gr_plot_qt +++ b/gr-utils/python/gr_plot_qt diff --git a/gr-utils/src/python/gr_plot_short b/gr-utils/python/gr_plot_short index 702a2a94a6..702a2a94a6 100755 --- a/gr-utils/src/python/gr_plot_short +++ b/gr-utils/python/gr_plot_short diff --git a/gr-utils/src/python/gr_read_file_metadata b/gr-utils/python/gr_read_file_metadata index 3bc448b04e..3bc448b04e 100644 --- a/gr-utils/src/python/gr_read_file_metadata +++ b/gr-utils/python/gr_read_file_metadata diff --git a/gr-utils/src/python/grcc b/gr-utils/python/grcc index 7e5665dc05..7e5665dc05 100755 --- a/gr-utils/src/python/grcc +++ b/gr-utils/python/grcc diff --git a/gr-utils/src/python/plot_data.py b/gr-utils/python/plot_data.py index 2ae3b1d5b3..2ae3b1d5b3 100644 --- a/gr-utils/src/python/plot_data.py +++ b/gr-utils/python/plot_data.py diff --git a/gr-utils/src/python/plot_fft_base.py b/gr-utils/python/plot_fft_base.py index 4afdc3a360..4afdc3a360 100755 --- a/gr-utils/src/python/plot_fft_base.py +++ b/gr-utils/python/plot_fft_base.py diff --git a/gr-utils/src/python/plot_psd_base.py b/gr-utils/python/plot_psd_base.py index fe3c9e12b7..fe3c9e12b7 100755 --- a/gr-utils/src/python/plot_psd_base.py +++ b/gr-utils/python/plot_psd_base.py diff --git a/gr-utils/src/python/pyqt_filter.py b/gr-utils/python/pyqt_filter.py index 0c781f2347..0c781f2347 100644 --- a/gr-utils/src/python/pyqt_filter.py +++ b/gr-utils/python/pyqt_filter.py diff --git a/gr-utils/src/python/pyqt_filter.ui b/gr-utils/python/pyqt_filter.ui index 9853352e2e..9853352e2e 100644 --- a/gr-utils/src/python/pyqt_filter.ui +++ b/gr-utils/python/pyqt_filter.ui diff --git a/gr-utils/src/python/pyqt_plot.py b/gr-utils/python/pyqt_plot.py index 5650135abf..5650135abf 100644 --- a/gr-utils/src/python/pyqt_plot.py +++ b/gr-utils/python/pyqt_plot.py diff --git a/gr-utils/src/python/pyqt_plot.ui b/gr-utils/python/pyqt_plot.ui index 55c72fda26..55c72fda26 100644 --- a/gr-utils/src/python/pyqt_plot.ui +++ b/gr-utils/python/pyqt_plot.ui diff --git a/gr-video-sdl/CMakeLists.txt b/gr-video-sdl/CMakeLists.txt index 57ffde8945..6dfec7d671 100644 --- a/gr-video-sdl/CMakeLists.txt +++ b/gr-video-sdl/CMakeLists.txt @@ -35,7 +35,8 @@ GR_REGISTER_COMPONENT("gr-video-sdl" ENABLE_GR_VIDEO_SDL ) GR_SET_GLOBAL(GR_VIDEO_SDL_INCLUDE_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_BINARY_DIR}/include ) ######################################################################## @@ -80,7 +81,12 @@ CPACK_COMPONENT("video_sdl_swig" ######################################################################## # Add subdirectories ######################################################################## -add_subdirectory(src) +add_subdirectory(include/video_sdl) +add_subdirectory(lib) +if(ENABLE_PYTHON) + add_subdirectory(swig) + add_subdirectory(python) +endif(ENABLE_PYTHON) ######################################################################## # Create Pkg Config File diff --git a/gr-trellis/src/CMakeLists.txt b/gr-video-sdl/include/video_sdl/CMakeLists.txt index 56db84a3e4..8831fd8172 100644 --- a/gr-trellis/src/CMakeLists.txt +++ b/gr-video-sdl/include/video_sdl/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2011,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -18,11 +18,13 @@ # Boston, MA 02110-1301, USA. ######################################################################## -# Add subdirectories +# Install header files ######################################################################## -add_subdirectory(lib) -if(ENABLE_PYTHON) - add_subdirectory(python) - add_subdirectory(examples/python) - add_subdirectory(examples/grc) -endif(ENABLE_PYTHON) +install(FILES + api.h + sink_s.h + sink_uc.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/video_sdl + COMPONENT "video_sdl_devel" +) + diff --git a/gr-video-sdl/src/video_sdl_api.h b/gr-video-sdl/include/video_sdl/api.h index 5418f86f03..5418f86f03 100644 --- a/gr-video-sdl/src/video_sdl_api.h +++ b/gr-video-sdl/include/video_sdl/api.h diff --git a/gr-video-sdl/include/video_sdl/sink_s.h b/gr-video-sdl/include/video_sdl/sink_s.h new file mode 100644 index 0000000000..2e2a9085e4 --- /dev/null +++ b/gr-video-sdl/include/video_sdl/sink_s.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 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_VIDEO_SDL_SINK_S_H +#define INCLUDED_VIDEO_SDL_SINK_S_H + +#include <video_sdl/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace video_sdl { + + /*! + * \brief video sink using SDL + * + * input signature is one, two or three streams of signed short. + * One stream: stream is grey (Y) + * two streems: first is grey (Y), second is alternating U and V + * Three streams: first is grey (Y), second is U, third is V + * Input samples must be in the range [0,255]. + */ + class VIDEO_SDL_API sink_s : virtual public gr_sync_block + { + public: + // gr::video_sdl::sink_s::sptr + typedef boost::shared_ptr<sink_s> sptr; + + static sptr make(double framerate, + int width, int height, + unsigned int format, + int dst_width, int dst_height); + }; + + } /* namespace video_sdl */ +} /* namespace gr */ + +#endif /* INCLUDED_VIDEO_SDL_SINK_S_H */ diff --git a/gr-video-sdl/include/video_sdl/sink_uc.h b/gr-video-sdl/include/video_sdl/sink_uc.h new file mode 100644 index 0000000000..215847fc0b --- /dev/null +++ b/gr-video-sdl/include/video_sdl/sink_uc.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 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_VIDEO_SDL_SINK_UC_H +#define INCLUDED_VIDEO_SDL_SINK_UC_H + +#include <video_sdl/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace video_sdl { + + /*! + * \brief video sink using SDL + * + * input signature is one, two or three streams of uchar. + * One stream: stream is grey (Y) + * two streems: first is grey (Y), second is alternating U and V + * Three streams: first is grey (Y), second is U, third is V + * Input samples must be in the range [0,255]. + */ + class VIDEO_SDL_API sink_uc : virtual public gr_sync_block + { + public: + // gr::video_sdl::sink_uc::sptr + typedef boost::shared_ptr<sink_uc> sptr; + + static sptr make(double framerate, + int width, int height, + unsigned int format, + int dst_width, int dst_height); + }; + + } /* namespace video_sdl */ +} /* namespace gr */ + +#endif /* INCLUDED_VIDEO_SDL_SINK_UC_H */ diff --git a/gr-video-sdl/lib/CMakeLists.txt b/gr-video-sdl/lib/CMakeLists.txt new file mode 100644 index 0000000000..5175412ad8 --- /dev/null +++ b/gr-video-sdl/lib/CMakeLists.txt @@ -0,0 +1,56 @@ +# Copyright 2011,2012 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. + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories( + ${GR_VIDEO_SDL_INCLUDE_DIRS} + ${GNURADIO_CORE_INCLUDE_DIRS} +) + +include_directories(${Boost_INCLUDE_DIRS}) +link_directories(${Boost_LIBRARY_DIRS}) + +include_directories(${SDL_INCLUDE_DIR}) + +if(ENABLE_GR_CTRLPORT) + ADD_DEFINITIONS(-DGR_CTRLPORT) +endif(ENABLE_GR_CTRLPORT) + +######################################################################## +# Setup library +######################################################################## +list(APPEND video_sdl_sources + sink_s_impl.cc + sink_uc_impl.cc +) + +list(APPEND video_sdl_libs + gnuradio-core + ${Boost_LIBRARIES} + ${SDL_LIBRARY} +) + + +add_library(gnuradio-video-sdl SHARED ${video_sdl_sources}) +target_link_libraries(gnuradio-video-sdl ${video_sdl_libs}) +GR_LIBRARY_FOO(gnuradio-video-sdl RUNTIME_COMPONENT "video_sdl_runtime" DEVEL_COMPONENT "video_sdl_devel") +add_dependencies(gnuradio-video-sdl + gnuradio-core) diff --git a/gr-video-sdl/lib/sink_s_impl.cc b/gr-video-sdl/lib/sink_s_impl.cc new file mode 100644 index 0000000000..2da9442d63 --- /dev/null +++ b/gr-video-sdl/lib/sink_s_impl.cc @@ -0,0 +1,322 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2010,2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "sink_s_impl.h" +#include <gr_io_signature.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdio.h> +#include <iostream> +#include <stdexcept> +#include <string.h> + + +namespace gr { + namespace video_sdl { + + + sink_s::sptr + sink_s::make(double framerate, int width, int height, + unsigned int format, int dst_width, int dst_height) + { + return gnuradio::get_initial_sptr + (new sink_s_impl(framerate, width, height,format, dst_width, dst_height)); + } + + sink_s_impl::sink_s_impl(double framerate, int width, int height, + unsigned int format, int dst_width, int dst_height) + : gr_sync_block("video_sdl_sink_s", + gr_make_io_signature(1, 3, sizeof(short)), + gr_make_io_signature(0, 0, 0)), + d_chunk_size(width*height), d_framerate(framerate), + d_wanted_frametime_ms(0), d_width(width), d_height(height), + d_dst_width(dst_width), d_dst_height(dst_height), + d_format(format), + d_current_line(0), d_screen(NULL), d_image(NULL), + d_avg_delay(0.0), d_wanted_ticks(0) + { + if(framerate <= 0.0) + d_wanted_frametime_ms = 0; //Go as fast as possible + else + d_wanted_frametime_ms = (int)(1000.0/framerate); + + if(dst_width < 0) + d_dst_width = d_width; + if(dst_height < 0) + d_dst_height = d_height; + if(0 == format) + d_format = IMGFMT_YV12; + + atexit(SDL_Quit); //check if this is the way to do this + if(SDL_Init(SDL_INIT_VIDEO) < 0) { + std::cerr << "video_sdl::sink_s: Couldn't initialize SDL:" << SDL_GetError() + << " \n SDL_Init(SDL_INIT_VIDEO) failed\n"; + throw std::runtime_error("video_sdl::sink_s"); + }; + + /* accept any depth */ + d_screen = SDL_SetVideoMode(dst_width, dst_height, 0, + SDL_SWSURFACE|SDL_RESIZABLE|SDL_ANYFORMAT);//SDL_DOUBLEBUF |SDL_SWSURFACE| SDL_HWSURFACE||SDL_FULLSCREEN + + if(d_screen == NULL) { + std::cerr << "Unable to set SDL video mode: " << SDL_GetError() + << "\n SDL_SetVideoMode() Failed \n"; + exit(1); + } + if(d_image) { + SDL_FreeYUVOverlay(d_image); + } + + /* Initialize and create the YUV Overlay used for video out */ + if(!(d_image = SDL_CreateYUVOverlay(d_width, d_height, SDL_YV12_OVERLAY, d_screen))) { + std::cerr << "SDL: Couldn't create a YUV overlay: \n"<< SDL_GetError() << "\n"; + throw std::runtime_error("video_sdl::sink_s"); + } + + printf("SDL screen_mode %d bits-per-pixel\n", + d_screen->format->BitsPerPixel); + printf("SDL overlay_mode %i \n", + d_image->format); + + d_chunk_size = std::min(1, 16384/width); //width*16; + d_chunk_size = d_chunk_size*width; + //d_chunk_size = (int) (width); + set_output_multiple(d_chunk_size); + + /* Set the default playback area */ + d_dst_rect.x = 0; + d_dst_rect.y = 0; + d_dst_rect.w = d_dst_width; + d_dst_rect.h = d_dst_height; + //clear the surface to grey + + if(SDL_LockYUVOverlay(d_image)) { + std::cerr << "SDL: Couldn't lock YUV overlay: \n" << SDL_GetError() << "\n"; + throw std::runtime_error("video_sdl::sink_s"); + } + + memset(d_image->pixels[0], 128, d_image->pitches[0]*d_height); + memset(d_image->pixels[1], 128, d_image->pitches[1]*d_height/2); + memset(d_image->pixels[2], 128, d_image->pitches[2]*d_height/2); + SDL_UnlockYUVOverlay( d_image ); + } + + sink_s_impl::~sink_s_impl() + { + SDL_Quit(); + } + + void + sink_s_impl::copy_line_pixel_interleaved(unsigned char *dst_pixels_u, + unsigned char *dst_pixels_v, + const short * src_pixels, + int src_width) + { + for(int i = 0; i < src_width; i++) { + dst_pixels_u[i]=(unsigned char)src_pixels[i*2]; + dst_pixels_v[i]=(unsigned char)src_pixels[i*2+1]; + } + } + + void + sink_s_impl::copy_line_line_interleaved(unsigned char *dst_pixels_u, + unsigned char *dst_pixels_v, + const short * src_pixels, + int src_width) + { + for(int i = 0; i < src_width; i++) { + dst_pixels_u[i] = (unsigned char)src_pixels[i]; + dst_pixels_v[i] = (unsigned char)src_pixels[i+src_width]; + } + + for(int i = src_width; i < src_width*2; i++) { + dst_pixels_v[i] = (unsigned char)src_pixels[i]; + } + } + + void + sink_s_impl::copy_line_single_plane(unsigned char *dst_pixels, + const short * src_pixels, + int src_width) + { + for(int i = 0; i < src_width; i++) { + dst_pixels[i] = (unsigned char)src_pixels[i]; + } + } + + void + sink_s_impl::copy_line_single_plane_dec2(unsigned char *dst_pixels, + const short * src_pixels, + int src_width) + { + for(int i = 0, j = 0; i < src_width; i += 2, j++) { + dst_pixels[j] = (unsigned char)src_pixels[i]; + } + } + + int + sink_s_impl::copy_plane_to_surface(int plane,int noutput_items, + const short * src_pixels) + { + const int first_dst_plane = (12 == plane || 1122 == plane) ? 1 : plane; + const int second_dst_plane = (12 == plane || 1122 == plane) ? 2 : plane; + int current_line = (0 == plane) ? d_current_line : d_current_line/2; + + unsigned char * dst_pixels = (unsigned char *)d_image->pixels[first_dst_plane]; + dst_pixels =& dst_pixels[current_line*d_image->pitches[first_dst_plane]]; + + unsigned char * dst_pixels_2 = (unsigned char *)d_image->pixels[second_dst_plane]; + dst_pixels_2 =& dst_pixels_2[current_line*d_image->pitches[second_dst_plane]]; + + int src_width = (0 == plane || 12 == plane || 1122 == plane) ? d_width:d_width/2; + int noutput_items_produced = 0; + int max_height = (0 == plane) ? d_height-1 : d_height/2-1; + + for(int i = 0; i < noutput_items; i += src_width) { + //output one line at a time + if(12==plane) { + copy_line_pixel_interleaved(dst_pixels, dst_pixels_2, src_pixels, src_width); + dst_pixels_2 += d_image->pitches[second_dst_plane]; + } + else if(1122 == plane) { + copy_line_line_interleaved(dst_pixels, dst_pixels_2, src_pixels, src_width); + dst_pixels_2 += d_image->pitches[second_dst_plane]; + src_pixels += src_width; + } + else if(0==plane) + copy_line_single_plane(dst_pixels, src_pixels, src_width); + else /* 1==plane || 2==plane*/ + copy_line_single_plane_dec2(dst_pixels, src_pixels, src_width); //decimate by two horizontally + + src_pixels += src_width; + dst_pixels += d_image->pitches[first_dst_plane]; + noutput_items_produced += src_width; + current_line++; + if(current_line > max_height) { + //Start new frame + //TODO, do this all in a seperate thread + current_line=0; + dst_pixels=d_image->pixels[first_dst_plane]; + dst_pixels_2=d_image->pixels[second_dst_plane]; + if(0 == plane) { + SDL_DisplayYUVOverlay(d_image, &d_dst_rect); + //SDL_Flip(d_screen); + unsigned int ticks = SDL_GetTicks();//milliseconds + d_wanted_ticks += d_wanted_frametime_ms; + float avg_alpha = 0.1; + int time_diff = d_wanted_ticks-ticks; + d_avg_delay = time_diff*avg_alpha +d_avg_delay*(1.0-avg_alpha); + } + } + } + + if(0==plane) + d_current_line=current_line; + + return noutput_items_produced; + } + + int + sink_s_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + short *src_pixels_0,*src_pixels_1,*src_pixels_2; + int noutput_items_produced = 0; + int plane; + int delay = (int)d_avg_delay; + + if(0 == d_wanted_ticks) + d_wanted_ticks = SDL_GetTicks(); + if(delay > 0) + SDL_Delay((unsigned int)delay); //compensate if running too fast + + if(SDL_LockYUVOverlay(d_image)) { + return 0; + } + + switch(input_items.size ()) { + case 3: // first channel=Y, second channel is U , third channel is V + src_pixels_0 = (short *)input_items[0]; + src_pixels_1 = (short *)input_items[1]; + src_pixels_2 = (short *)input_items[2]; + for(int i = 0; i < noutput_items; i += d_chunk_size) { + copy_plane_to_surface(1,d_chunk_size, src_pixels_1); + copy_plane_to_surface(2,d_chunk_size, src_pixels_2); + noutput_items_produced += copy_plane_to_surface(0,d_chunk_size, src_pixels_0); + src_pixels_0 += d_chunk_size; + src_pixels_1 += d_chunk_size; + src_pixels_2 += d_chunk_size; + } + break; + case 2: + if(1) { //if(pixel_interleaved_uv) + // first channel=Y, second channel is alternating pixels U and V + src_pixels_0 = (short *)input_items[0]; + src_pixels_1 = (short *)input_items[1]; + for(int i = 0; i < noutput_items; i += d_chunk_size) { + copy_plane_to_surface(12, d_chunk_size/2, src_pixels_1); + noutput_items_produced += copy_plane_to_surface(0, d_chunk_size, src_pixels_0); + src_pixels_0 += d_chunk_size; + src_pixels_1 += d_chunk_size; + } + } + else { + // first channel=Y, second channel is alternating lines U and V + src_pixels_0 = (short *)input_items[0]; + src_pixels_1 = (short *)input_items[1]; + for(int i = 0; i < noutput_items; i += d_chunk_size) { + copy_plane_to_surface(1222, d_chunk_size/2, src_pixels_1); + noutput_items_produced += copy_plane_to_surface(0, d_chunk_size, src_pixels_0); + src_pixels_0 += d_chunk_size; + src_pixels_1 += d_chunk_size; + } + } + break; + case 1: // grey (Y) input + /* Y component */ + plane=0; + src_pixels_0 = (short *)input_items[plane]; + for(int i = 0; i < noutput_items; i += d_chunk_size) { + noutput_items_produced += copy_plane_to_surface(plane, d_chunk_size, src_pixels_0); + src_pixels_0 += d_chunk_size; + } + break; + default: //0 or more then 3 channels + std::cerr << "video_sdl::sink_s: Wrong number of channels: "; + std::cerr << "1, 2 or 3 channels are supported.\n Requested number of channels is " + << input_items.size () << "\n"; + throw std::runtime_error("video_sdl::sink_s"); + } + + SDL_UnlockYUVOverlay(d_image); + return noutput_items_produced; + } + + } /* namespace video_sdl */ +} /* namespace gr */ diff --git a/gr-video-sdl/lib/sink_s_impl.h b/gr-video-sdl/lib/sink_s_impl.h new file mode 100644 index 0000000000..8d20cb6596 --- /dev/null +++ b/gr-video-sdl/lib/sink_s_impl.h @@ -0,0 +1,80 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 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_VIDEO_SDL_SINK_S_IMPL_H +#define INCLUDED_VIDEO_SDL_SINK_S_IMPL_H + +#include <video_sdl/sink_s.h> +#include <SDL.h> + +namespace gr { + namespace video_sdl { + +/* fourcc (four character code) */ +#define vid_fourcc(a,b,c,d) (((unsigned)(a)<<0) | ((unsigned)(b)<<8) | ((unsigned)(c)<<16) | ((unsigned)(d)<<24)) +#define IMGFMT_YV12 vid_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */ + + class sink_s_impl : public sink_s + { + private: + int d_chunk_size; + + protected: + void copy_line_pixel_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v, + const short * src_pixels,int src_width); + void copy_line_line_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v, + const short * src_pixels,int src_width); + void copy_line_single_plane(unsigned char *dst_pixels,const short * src_pixels,int src_width); + void copy_line_single_plane_dec2(unsigned char *dst_pixels,const short * src_pixels,int src_width); + int copy_plane_to_surface(int plane,int noutput_items, + const short * src_pixels); + + float d_framerate; + int d_wanted_frametime_ms; + int d_width; + int d_height; + int d_dst_width; + int d_dst_height; + int d_format; + int d_current_line; + SDL_Surface *d_screen; + SDL_Overlay *d_image; + SDL_Rect d_dst_rect; + float d_avg_delay; + unsigned int d_wanted_ticks; + + public: + sink_s_impl(double framerate, + int width, int height, + unsigned int format, + int dst_width, int dst_height); + ~sink_s_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace video_sdl */ +} /* namespace gr */ + +#endif /* INCLUDED_VIDEO_SDL_SINK_S_IMPL_H */ diff --git a/gr-video-sdl/lib/sink_uc_impl.cc b/gr-video-sdl/lib/sink_uc_impl.cc new file mode 100644 index 0000000000..28333e2413 --- /dev/null +++ b/gr-video-sdl/lib/sink_uc_impl.cc @@ -0,0 +1,318 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2010,2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "sink_uc_impl.h" +#include <gr_io_signature.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdio.h> +#include <iostream> +#include <stdexcept> +#include <string.h> + + +namespace gr { + namespace video_sdl { + + sink_uc::sptr + sink_uc::make(double framerate, int width, int height, + unsigned int format, int dst_width, int dst_height) + { + return gnuradio::get_initial_sptr + (new sink_uc_impl(framerate, width, height, format, dst_width, dst_height)); + } + + sink_uc_impl::sink_uc_impl(double framerate, int width, int height, + unsigned int format, int dst_width, int dst_height) + : gr_sync_block("video_sdl_sink_uc", + gr_make_io_signature(1, 3, sizeof(unsigned char)), + gr_make_io_signature(0, 0, 0)), + d_chunk_size(width*height), d_framerate(framerate), + d_wanted_frametime_ms(0), d_width(width), d_height(height), + d_dst_width(dst_width), d_dst_height(dst_height), + d_format(format), + d_current_line(0), d_screen(NULL), d_image(NULL), + d_avg_delay(0.0), d_wanted_ticks(0) + { + if(framerate <= 0.0) + d_wanted_frametime_ms = 0; //Go as fast as possible + else + d_wanted_frametime_ms = (int)(1000.0/framerate); + + if(dst_width < 0) + d_dst_width = d_width; + + if(dst_height < 0) + d_dst_height = d_height; + + if(0==format) + d_format= IMGFMT_YV12; + + atexit(SDL_Quit); //check if this is the way to do this + if(SDL_Init(SDL_INIT_VIDEO) < 0) { + std::cerr << "video_sdl::sink_uc: Couldn't initialize SDL:" + << SDL_GetError() << " \n SDL_Init(SDL_INIT_VIDEO) failed\n"; + throw std::runtime_error ("video_sdl::sink_uc"); + } + + /* accept any depth */ + d_screen = SDL_SetVideoMode(dst_width, dst_height, 0, + SDL_SWSURFACE|SDL_RESIZABLE|SDL_ANYFORMAT);//SDL_DOUBLEBUF |SDL_SWSURFACE| SDL_HWSURFACE||SDL_FULLSCREEN + + if(d_screen == NULL) { + std::cerr << "Unable to set SDL video mode: " << SDL_GetError() + <<"\n SDL_SetVideoMode() Failed \n"; + exit(1); + } + + if(d_image) { + SDL_FreeYUVOverlay(d_image); + } + + /* Initialize and create the YUV Overlay used for video out */ + if(!(d_image = SDL_CreateYUVOverlay(d_width, d_height, SDL_YV12_OVERLAY, d_screen))) { + std::cerr << "SDL: Couldn't create a YUV overlay: \n"<< SDL_GetError() <<"\n"; + throw std::runtime_error("video_sdl::sink_uc"); + } + + printf("SDL screen_mode %d bits-per-pixel\n", + d_screen->format->BitsPerPixel); + printf("SDL overlay_mode %i \n", + d_image->format); + + d_chunk_size = std::min(1,16384/width); //width*16; + d_chunk_size = d_chunk_size*width; + //d_chunk_size = (int)(width); + set_output_multiple(d_chunk_size); + + /* Set the default playback area */ + d_dst_rect.x = 0; + d_dst_rect.y = 0; + d_dst_rect.w = d_dst_width; + d_dst_rect.h = d_dst_height; + //clear the surface to grey + + if(SDL_LockYUVOverlay(d_image)) { + std::cerr << "SDL: Couldn't lock YUV overlay: \n" << SDL_GetError() << "\n"; + throw std::runtime_error ("video_sdl::sink_uc"); + } + + memset(d_image->pixels[0], 128, d_image->pitches[0]*d_height); + memset(d_image->pixels[1], 128, d_image->pitches[1]*d_height/2); + memset(d_image->pixels[2], 128, d_image->pitches[2]*d_height/2); + SDL_UnlockYUVOverlay(d_image); + } + + sink_uc_impl::~sink_uc_impl() + { + SDL_Quit(); + } + + void + sink_uc_impl::copy_line_pixel_interleaved(unsigned char *dst_pixels_u, + unsigned char *dst_pixels_v, + const unsigned char *src_pixels, + int src_width) + { + for(int i=0;i<src_width;i++) { + dst_pixels_u[i]=src_pixels[i*2]; + dst_pixels_v[i]=src_pixels[i*2+1]; + } + } + + void + sink_uc_impl::copy_line_line_interleaved(unsigned char *dst_pixels_u, + unsigned char *dst_pixels_v, + const unsigned char *src_pixels, + int src_width) + { + memcpy(dst_pixels_u, src_pixels, src_width); + memcpy(dst_pixels_v, src_pixels+src_width, src_width); + } + + void + sink_uc_impl::copy_line_single_plane(unsigned char *dst_pixels, + const unsigned char *src_pixels, + int src_width) + { + memcpy(dst_pixels, src_pixels, src_width); + } + + void + sink_uc_impl::copy_line_single_plane_dec2(unsigned char *dst_pixels, + const unsigned char *src_pixels, + int src_width) + { + for(int i = 0,j = 0; i < src_width; i += 2, j++) { + dst_pixels[j] = (unsigned char)src_pixels[i]; + } + } + + int + sink_uc_impl::copy_plane_to_surface(int plane,int noutput_items, + const unsigned char * src_pixels) + { + const int first_dst_plane = (12==plane || 1122 == plane) ? 1 : plane; + const int second_dst_plane = (12==plane || 1122 == plane) ? 2 : plane; + int current_line = (0 == plane) ? d_current_line : d_current_line/2; + + unsigned char *dst_pixels = (unsigned char*)d_image->pixels[first_dst_plane]; + dst_pixels =& dst_pixels[current_line*d_image->pitches[first_dst_plane]]; + + unsigned char * dst_pixels_2 = (unsigned char *)d_image->pixels[second_dst_plane]; + dst_pixels_2 =& dst_pixels_2[current_line*d_image->pitches[second_dst_plane]]; + + int src_width = (0 == plane || 12 == plane || 1122 == plane) ? d_width : d_width/2; + int noutput_items_produced = 0; + int max_height = (0 == plane)? d_height-1 : d_height/2-1; + + for(int i = 0; i < noutput_items; i += src_width) { + //output one line at a time + if(12 == plane) { + copy_line_pixel_interleaved(dst_pixels, dst_pixels_2, src_pixels, src_width); + dst_pixels_2 += d_image->pitches[second_dst_plane]; + } + else if(1122 == plane) { + copy_line_line_interleaved(dst_pixels, dst_pixels_2, src_pixels, src_width); + dst_pixels_2 += d_image->pitches[second_dst_plane]; + src_pixels += src_width; + } + else if(0 == plane) + copy_line_single_plane(dst_pixels, src_pixels, src_width); + else /* 1==plane || 2==plane*/ + copy_line_single_plane_dec2(dst_pixels, src_pixels, src_width); //decimate by two horizontally + + src_pixels += src_width; + dst_pixels += d_image->pitches[first_dst_plane]; + noutput_items_produced+=src_width; + current_line++; + + if(current_line > max_height) { + //Start new frame + //TODO, do this all in a seperate thread + current_line = 0; + dst_pixels = d_image->pixels[first_dst_plane]; + dst_pixels_2 = d_image->pixels[second_dst_plane]; + if(0 == plane) { + SDL_DisplayYUVOverlay(d_image, &d_dst_rect); + //SDL_Flip(d_screen); + unsigned int ticks = SDL_GetTicks();//milliseconds + d_wanted_ticks += d_wanted_frametime_ms; + float avg_alpha = 0.1; + int time_diff = d_wanted_ticks-ticks; + d_avg_delay = time_diff*avg_alpha + d_avg_delay*(1.0-avg_alpha); + } + } + } + + if(0==plane) + d_current_line=current_line; + + return noutput_items_produced; + } + + int + sink_uc_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + unsigned char *src_pixels_0,*src_pixels_1,*src_pixels_2; + int noutput_items_produced = 0; + int plane; + int delay = (int)d_avg_delay; + + if(0 == d_wanted_ticks) + d_wanted_ticks=SDL_GetTicks(); + + if(delay > 0) + SDL_Delay((unsigned int)delay);//compensate if running too fast + + if(SDL_LockYUVOverlay(d_image)) { + return 0; + } + + switch(input_items.size ()) { + case 3: // first channel=Y, second channel is U , third channel is V + src_pixels_0 = (unsigned char *) input_items[0]; + src_pixels_1 = (unsigned char *) input_items[1]; + src_pixels_2 = (unsigned char *) input_items[2]; + for(int i = 0; i < noutput_items; i += d_chunk_size) { + copy_plane_to_surface (1,d_chunk_size, src_pixels_1); + copy_plane_to_surface (2,d_chunk_size, src_pixels_2); + noutput_items_produced+=copy_plane_to_surface(0,d_chunk_size, src_pixels_0); + src_pixels_0 += d_chunk_size; + src_pixels_1 += d_chunk_size; + src_pixels_2 += d_chunk_size; + } + break; + case 2: + if(1) {//if(pixel_interleaved_uv) + // first channel=Y, second channel is alternating pixels U and V + src_pixels_0 = (unsigned char *) input_items[0]; + src_pixels_1 = (unsigned char *) input_items[1]; + for(int i = 0; i < noutput_items; i += d_chunk_size) { + copy_plane_to_surface(12, d_chunk_size/2, src_pixels_1); + noutput_items_produced += copy_plane_to_surface(0, d_chunk_size, src_pixels_0); + src_pixels_0 += d_chunk_size; + src_pixels_1 += d_chunk_size; + } + } + else { + // first channel=Y, second channel is alternating lines U and V + src_pixels_0 = (unsigned char*)input_items[0]; + src_pixels_1 = (unsigned char*)input_items[1]; + for(int i = 0; i < noutput_items; i += d_chunk_size) { + copy_plane_to_surface (1222,d_chunk_size/2, src_pixels_1); + noutput_items_produced += copy_plane_to_surface(0, d_chunk_size, src_pixels_0); + src_pixels_0 += d_chunk_size; + src_pixels_1 += d_chunk_size; + } + } + break; + case 1: // grey (Y) input + /* Y component */ + plane=0; + src_pixels_0 = (unsigned char*)input_items[plane]; + for(int i = 0; i < noutput_items; i += d_chunk_size) { + noutput_items_produced += copy_plane_to_surface(plane, d_chunk_size, src_pixels_0); + src_pixels_0 += d_chunk_size; + } + break; + default: //0 or more then 3 channels + std::cerr << "video_sdl::sink_uc: Wrong number of channels: "; + std::cerr <<"1, 2 or 3 channels are supported.\n Requested number of channels is " + << input_items.size () <<"\n"; + throw std::runtime_error("video_sdl::sink_uc"); + } + + SDL_UnlockYUVOverlay(d_image); + return noutput_items_produced; + } + + } /* namespace video_sdl */ +} /* namespace gr */ diff --git a/gr-video-sdl/lib/sink_uc_impl.h b/gr-video-sdl/lib/sink_uc_impl.h new file mode 100644 index 0000000000..927510745f --- /dev/null +++ b/gr-video-sdl/lib/sink_uc_impl.h @@ -0,0 +1,80 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 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_VIDEO_SDL_SINK_UC_IMPL_H +#define INCLUDED_VIDEO_SDL_SINK_UC_IMPL_H + +#include <video_sdl/sink_uc.h> +#include <SDL.h> + +namespace gr { + namespace video_sdl { + +/* fourcc (four character code) */ +#define vid_fourcc(a,b,c,d) (((unsigned)(a)<<0) | ((unsigned)(b)<<8) | ((unsigned)(c)<<16) | ((unsigned)(d)<<24)) +#define IMGFMT_YV12 vid_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */ + + class sink_uc_impl : public sink_uc + { + private: + int d_chunk_size; + + protected: + void copy_line_pixel_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v, + const unsigned char * src_pixels,int src_width); + void copy_line_line_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v, + const unsigned char * src_pixels,int src_width); + void copy_line_single_plane(unsigned char *dst_pixels,const unsigned char * src_pixels,int src_width); + void copy_line_single_plane_dec2(unsigned char *dst_pixels,const unsigned char * src_pixels,int src_width); + int copy_plane_to_surface(int plane,int noutput_items, + const unsigned char * src_pixels); + + float d_framerate; + int d_wanted_frametime_ms; + int d_width; + int d_height; + int d_dst_width; + int d_dst_height; + int d_format; + int d_current_line; + SDL_Surface *d_screen; + SDL_Overlay *d_image; + SDL_Rect d_dst_rect; + float d_avg_delay; + unsigned int d_wanted_ticks; + + public: + sink_uc_impl(double framerate, + int width, int height, + unsigned int format, + int dst_width, int dst_height); + ~sink_uc_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace video_sdl */ +} /* namespace gr */ + +#endif /* INCLUDED_VIDEO_SDL_SINK_UC_IMPL_H */ diff --git a/gr-trellis/src/python/CMakeLists.txt b/gr-video-sdl/python/CMakeLists.txt index adc6b3a239..0ce0ea3d78 100644 --- a/gr-trellis/src/python/CMakeLists.txt +++ b/gr-video-sdl/python/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011-2012 Free Software Foundation, Inc. +# Copyright 2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -18,18 +18,28 @@ # Boston, MA 02110-1301, USA. ######################################################################## +# Setup python install +######################################################################## +include(GrPython) + +GR_PYTHON_INSTALL( + FILES + __init__.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio/video-sdl + COMPONENT "video_sdl_python" +) + +######################################################################## # Handle the unit tests ######################################################################## if(ENABLE_TESTING) list(APPEND GR_TEST_PYTHON_DIRS - ${CMAKE_BINARY_DIR}/gr-analog/swig - ${CMAKE_BINARY_DIR}/gr-digital/swig - ${CMAKE_BINARY_DIR}/gr-trellis/src/lib + ${CMAKE_BINARY_DIR}/gr-video-sdl/python + ${CMAKE_BINARY_DIR}/gr-video-sdl/swig ) -list(APPEND GR_TEST_TARGET_DEPS gnuradio-analog gnuradio-digital gnuradio-trellis gnuradio-filter) +list(APPEND GR_TEST_TARGET_DEPS gnuradio-video-sdl) -include(GrPython) include(GrTest) file(GLOB py_qa_test_files "qa_*.py") foreach(py_qa_test_file ${py_qa_test_files}) diff --git a/gnuradio-core/src/python/gnuradio/blks2/CMakeLists.txt b/gr-video-sdl/python/__init__.py index 83d11dd831..c029a82c2d 100644 --- a/gnuradio-core/src/python/gnuradio/blks2/CMakeLists.txt +++ b/gr-video-sdl/python/__init__.py @@ -1,26 +1,27 @@ -# Copyright 2010-2011 Free Software Foundation, Inc. -# +# Copyright 2012 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. +# -include(GrPython) +''' +Blocks and utilities for Video SDL module +''' -GR_PYTHON_INSTALL( - FILES __init__.py - DESTINATION ${GR_PYTHON_DIR}/gnuradio/blks2 - COMPONENT "core_python" -) +# The presence of this file turns this directory into a Python package + +from video_sdl_swig import * diff --git a/gr-video-sdl/src/qa_video_sdl.py b/gr-video-sdl/python/qa_video_sdl.py index 9008d15131..68c3185ef5 100755 --- a/gr-video-sdl/src/qa_video_sdl.py +++ b/gr-video-sdl/python/qa_video_sdl.py @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import video_sdl +import video_sdl_swig as video_sdl class test_video_sdl (gr_unittest.TestCase): diff --git a/gr-video-sdl/src/CMakeLists.txt b/gr-video-sdl/src/CMakeLists.txt deleted file mode 100644 index 27fb4115f6..0000000000 --- a/gr-video-sdl/src/CMakeLists.txt +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright 2011-2012 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. - -######################################################################## -# Setup the include and linker paths -######################################################################## -include_directories( - ${GNURADIO_CORE_INCLUDE_DIRS} - ${GR_VIDEO_SDL_INCLUDE_DIRS} -) - -include_directories(${Boost_INCLUDE_DIRS}) -link_directories(${Boost_LIBRARY_DIRS}) - -include_directories(${SDL_INCLUDE_DIR}) - -######################################################################## -# Setup library -######################################################################## -list(APPEND gr_video_sdl_sources - video_sdl_sink_uc.cc - video_sdl_sink_s.cc -) - -list(APPEND video_sdl_libs - gnuradio-core - ${Boost_LIBRARIES} - ${SDL_LIBRARY} -) - -add_library(gnuradio-video-sdl SHARED ${gr_video_sdl_sources}) -target_link_libraries(gnuradio-video-sdl ${video_sdl_libs}) -GR_LIBRARY_FOO(gnuradio-video-sdl RUNTIME_COMPONENT "video_sdl_runtime" DEVEL_COMPONENT "video_sdl_devel") - -######################################################################## -# Install public header files -######################################################################## -install(FILES - video_sdl_api.h - video_sdl_sink_uc.h - video_sdl_sink_s.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "video_sdl_devel" -) - -######################################################################## -# Setup swig generation -######################################################################## -if(ENABLE_PYTHON) -include(GrPython) -include(GrSwig) - -set(GR_SWIG_INCLUDE_DIRS - ${GR_COMEDI_INCLUDE_DIRS} - ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} -) - -set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/video_sdl_swig_doc.i) -set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) - -set(GR_SWIG_LIBRARIES gnuradio-video-sdl) - -GR_SWIG_MAKE(video_sdl video_sdl.i) - -GR_SWIG_INSTALL( - TARGETS video_sdl - DESTINATION ${GR_PYTHON_DIR}/gnuradio - COMPONENT "video_sdl_python" -) - -install( - FILES video_sdl.i - ${CMAKE_CURRENT_BINARY_DIR}/video_sdl_swig_doc.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "video_sdl_swig" -) - -endif(ENABLE_PYTHON) - -######################################################################## -# Handle the unit tests -######################################################################## -if(ENABLE_TESTING AND ENABLE_PYTHON) - -list(APPEND GR_TEST_PYTHON_DIRS - ${CMAKE_BINARY_DIR}/gr-video-sdl/src -) -list(APPEND GR_TEST_TARGET_DEPS gnuradio-video-sdl) - -include(GrTest) -file(GLOB py_qa_test_files "qa_*.py") -foreach(py_qa_test_file ${py_qa_test_files}) - get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE) - GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file}) -endforeach(py_qa_test_file) -endif(ENABLE_TESTING AND ENABLE_PYTHON) diff --git a/gr-video-sdl/src/video_sdl.i b/gr-video-sdl/src/video_sdl.i deleted file mode 100644 index c06ad6c2e3..0000000000 --- a/gr-video-sdl/src/video_sdl.i +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 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. - */ - -%include "gnuradio.i" // the common stuff - -//load generated python docstrings -%include "video_sdl_swig_doc.i" - -%{ -#include "video_sdl_sink_uc.h" -#include "video_sdl_sink_s.h" -%} - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(video_sdl,sink_uc) - -video_sdl_sink_uc_sptr -video_sdl_make_sink_uc ( double framerate,int width=640, int height=480,unsigned int format=0,int dst_width=-1,int dst_height=-1 - ) throw (std::runtime_error); - - -class video_sdl_sink_uc : public gr_sync_block { - protected: - video_sdl_sink_uc (double framerate,int width, int height,gr_uint32 format,int dst_width,int dst_height); - - public: - ~video_sdl_sink_uc (); -}; - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(video_sdl,sink_s) - -video_sdl_sink_s_sptr -video_sdl_make_sink_s ( double framerate,int width=640, int height=480,unsigned int format=0,int dst_width=-1,int dst_height=-1 - ) throw (std::runtime_error); - - -class video_sdl_sink_s : public gr_sync_block { - protected: - video_sdl_sink_s (double framerate,int width, int height,gr_uint32 format,int dst_width,int dst_height); - - public: - ~video_sdl_sink_s (); -}; diff --git a/gr-video-sdl/src/video_sdl_sink_s.cc b/gr-video-sdl/src/video_sdl_sink_s.cc deleted file mode 100644 index d9232043ab..0000000000 --- a/gr-video-sdl/src/video_sdl_sink_s.cc +++ /dev/null @@ -1,301 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <SDL.h> - -#include <video_sdl_sink_s.h> -#include <gr_io_signature.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <stdio.h> -#include <iostream> -#include <stdexcept> -#include <string.h> - - - -video_sdl_sink_s::video_sdl_sink_s (double framerate,int width, int height,unsigned int format,int dst_width,int dst_height) - : gr_sync_block ("video_sdl_sink_s", - gr_make_io_signature (1, 3, sizeof (short)), - gr_make_io_signature (0, 0, 0)), - d_chunk_size (width*height), - d_framerate(framerate), - d_wanted_frametime_ms(0), - d_width(width), - d_height (height), - d_dst_width(dst_width), - d_dst_height(dst_height), - d_format(format), - d_current_line(0), - d_screen(NULL), - d_image(NULL), - d_avg_delay(0.0), - d_wanted_ticks(0) -{ - if(framerate<=0.0) - d_wanted_frametime_ms=0;//Go as fast as possible - else - d_wanted_frametime_ms=(int)(1000.0/framerate); - if(dst_width<0) d_dst_width=d_width; - if(dst_height<0) d_dst_height=d_height; - if(0==format) d_format=IMGFMT_YV12; - - atexit(SDL_Quit);//check if this is the way to do this - if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { - std::cerr << "video_sdl_sink_s: Couldn't initialize SDL:" << SDL_GetError() << " \n SDL_Init(SDL_INIT_VIDEO) failed\n"; - throw std::runtime_error ("video_sdl_sink_s"); - }; - - /* accept any depth */ - d_screen = SDL_SetVideoMode(dst_width, dst_height, 0, SDL_SWSURFACE|SDL_RESIZABLE|SDL_ANYFORMAT);//SDL_DOUBLEBUF |SDL_SWSURFACE| SDL_HWSURFACE||SDL_FULLSCREEN - if ( d_screen == NULL ) { - std::cerr << "Unable to set SDL video mode: " << SDL_GetError() <<"\n SDL_SetVideoMode() Failed \n"; - exit(1); - } - if ( d_image ) { - SDL_FreeYUVOverlay(d_image); - } - /* Initialize and create the YUV Overlay used for video out */ - if (!(d_image = SDL_CreateYUVOverlay (d_width, d_height, SDL_YV12_OVERLAY, d_screen))) { - std::cerr << "SDL: Couldn't create a YUV overlay: \n"<< SDL_GetError() <<"\n"; - throw std::runtime_error ("video_sdl_sink_s"); - } - - printf("SDL screen_mode %d bits-per-pixel\n", - d_screen->format->BitsPerPixel); - printf("SDL overlay_mode %i \n", - d_image->format); - d_chunk_size = std::min(1,16384/width); //width*16; - d_chunk_size = d_chunk_size*width; - //d_chunk_size = (int) (width); - set_output_multiple (d_chunk_size); - /* Set the default playback area */ - d_dst_rect.x = 0; - d_dst_rect.y = 0; - d_dst_rect.w = d_dst_width; - d_dst_rect.h = d_dst_height; - //clear the surface to grey - if ( SDL_LockYUVOverlay( d_image ) ) { - std::cerr << "SDL: Couldn't lock YUV overlay: \n"<< SDL_GetError() <<"\n"; - throw std::runtime_error ("video_sdl_sink_s"); - } - memset(d_image->pixels[0], 128, d_image->pitches[0]*d_height); - memset(d_image->pixels[1], 128, d_image->pitches[1]*d_height/2); - memset(d_image->pixels[2], 128, d_image->pitches[2]*d_height/2); - SDL_UnlockYUVOverlay( d_image ); -} - -video_sdl_sink_s::~video_sdl_sink_s () -{ - SDL_Quit(); -} - -video_sdl_sink_s_sptr -video_sdl_make_sink_s (double framerate,int width, int height,unsigned int format,int dst_width,int dst_height) -{ - return gnuradio::get_initial_sptr(new video_sdl_sink_s (framerate, width, height,format,dst_width,dst_height)); -} - -void -video_sdl_sink_s::copy_line_pixel_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v,const short * src_pixels,int src_width) -{ - for(int i=0;i<src_width;i++) - { - dst_pixels_u[i]=(unsigned char)src_pixels[i*2]; - dst_pixels_v[i]=(unsigned char)src_pixels[i*2+1]; - } - return; -} - -void -video_sdl_sink_s::copy_line_line_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v,const short * src_pixels,int src_width) -{ - for(int i=0;i<src_width;i++) - { - dst_pixels_u[i]=(unsigned char)src_pixels[i]; - dst_pixels_v[i]=(unsigned char)src_pixels[i+src_width]; - } - for(int i=src_width;i<src_width*2;i++) - { - dst_pixels_v[i]=(unsigned char)src_pixels[i]; - } - return; -} -void -video_sdl_sink_s::copy_line_single_plane(unsigned char *dst_pixels,const short * src_pixels,int src_width) -{ - for(int i=0;i<src_width;i++) - { - dst_pixels[i]=(unsigned char)src_pixels[i]; - } - return; -} - -void -video_sdl_sink_s::copy_line_single_plane_dec2(unsigned char *dst_pixels,const short * src_pixels,int src_width) -{ - for(int i=0,j=0;i<src_width;i+=2,j++) - { - dst_pixels[j]=(unsigned char)src_pixels[i]; - } - return; -} - -int -video_sdl_sink_s::copy_plane_to_surface (int plane,int noutput_items, - const short * src_pixels) -{ - const int first_dst_plane=(12==plane ||1122==plane)?1:plane; - const int second_dst_plane=(12==plane ||1122==plane)?2:plane; - int current_line=(0==plane)?d_current_line:d_current_line/2; - unsigned char * dst_pixels = (unsigned char *)d_image->pixels[first_dst_plane]; - dst_pixels=&dst_pixels[current_line*d_image->pitches[first_dst_plane]]; - unsigned char * dst_pixels_2 = (unsigned char *)d_image->pixels[second_dst_plane]; - dst_pixels_2=&dst_pixels_2[current_line*d_image->pitches[second_dst_plane]]; - int src_width=(0==plane || 12==plane || 1122==plane)?d_width:d_width/2; - int noutput_items_produced=0; - int max_height=(0==plane)?d_height-1:d_height/2-1; - for (int i = 0; i < noutput_items; i += src_width){ - //output one line at a time - if(12==plane) - { - copy_line_pixel_interleaved(dst_pixels,dst_pixels_2,src_pixels,src_width); - dst_pixels_2 += d_image->pitches[second_dst_plane]; - } - else if (1122==plane) - { - copy_line_line_interleaved(dst_pixels,dst_pixels_2,src_pixels,src_width); - dst_pixels_2 += d_image->pitches[second_dst_plane]; - src_pixels += src_width; - } - else if (0==plane) - copy_line_single_plane(dst_pixels,src_pixels,src_width); - else /* 1==plane || 2==plane*/ - copy_line_single_plane_dec2(dst_pixels,src_pixels,src_width);//decimate by two horizontally - - src_pixels += src_width; - dst_pixels += d_image->pitches[first_dst_plane]; - noutput_items_produced+=src_width; - current_line++; - if (current_line>max_height) - { - //Start new frame - //TODO, do this all in a seperate thread - current_line=0; - dst_pixels=d_image->pixels[first_dst_plane]; - dst_pixels_2=d_image->pixels[second_dst_plane]; - if(0==plane) - { - SDL_DisplayYUVOverlay(d_image, &d_dst_rect); - //SDL_Flip(d_screen); - unsigned int ticks=SDL_GetTicks();//milliseconds - d_wanted_ticks+=d_wanted_frametime_ms; - float avg_alpha=0.1; - int time_diff=d_wanted_ticks-ticks; - d_avg_delay=time_diff*avg_alpha +d_avg_delay*(1.0-avg_alpha); - } - } - } - if(0==plane) d_current_line=current_line; - return noutput_items_produced; -} - -int -video_sdl_sink_s::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - short *src_pixels_0,*src_pixels_1,*src_pixels_2; - int noutput_items_produced=0; - int plane; - int delay=(int)d_avg_delay; - if(0==d_wanted_ticks) - d_wanted_ticks=SDL_GetTicks(); - if(delay>0) - SDL_Delay((unsigned int)delay);//compensate if running too fast - - if ( SDL_LockYUVOverlay( d_image ) ) { - return 0; - } - switch (input_items.size ()){ - case 3: // first channel=Y, second channel is U , third channel is V - src_pixels_0 = (short *) input_items[0]; - src_pixels_1 = (short *) input_items[1]; - src_pixels_2 = (short *) input_items[2]; - for (int i = 0; i < noutput_items; i += d_chunk_size){ - copy_plane_to_surface (1,d_chunk_size, src_pixels_1); - copy_plane_to_surface (2,d_chunk_size, src_pixels_2); - noutput_items_produced+=copy_plane_to_surface (0,d_chunk_size, src_pixels_0); - src_pixels_0 += d_chunk_size; - src_pixels_1 += d_chunk_size; - src_pixels_2 += d_chunk_size; - } - break; - case 2: - if(1) //if(pixel_interleaved_uv) - { - // first channel=Y, second channel is alternating pixels U and V - src_pixels_0 = (short *) input_items[0]; - src_pixels_1 = (short *) input_items[1]; - for (int i = 0; i < noutput_items; i += d_chunk_size){ - copy_plane_to_surface (12,d_chunk_size/2, src_pixels_1); - noutput_items_produced+=copy_plane_to_surface (0,d_chunk_size, src_pixels_0); - src_pixels_0 += d_chunk_size; - src_pixels_1 += d_chunk_size; - } - } else - { - // first channel=Y, second channel is alternating lines U and V - src_pixels_0 = (short *) input_items[0]; - src_pixels_1 = (short *) input_items[1]; - for (int i = 0; i < noutput_items; i += d_chunk_size){ - copy_plane_to_surface (1222,d_chunk_size/2, src_pixels_1); - noutput_items_produced+=copy_plane_to_surface (0,d_chunk_size, src_pixels_0); - src_pixels_0 += d_chunk_size; - src_pixels_1 += d_chunk_size; - } - } - break; - case 1: // grey (Y) input - /* Y component */ - plane=0; - src_pixels_0 = (short *) input_items[plane]; - for (int i = 0; i < noutput_items; i += d_chunk_size){ - noutput_items_produced+=copy_plane_to_surface (plane,d_chunk_size, src_pixels_0); - src_pixels_0 += d_chunk_size; - } - break; - default: //0 or more then 3 channels - std::cerr << "video_sdl_sink_s: Wrong number of channels: "; - std::cerr <<"1, 2 or 3 channels are supported.\n Requested number of channels is "<< input_items.size () <<"\n"; - throw std::runtime_error ("video_sdl_sink_s"); - } - - SDL_UnlockYUVOverlay( d_image ); - return noutput_items_produced; -} diff --git a/gr-video-sdl/src/video_sdl_sink_s.h b/gr-video-sdl/src/video_sdl_sink_s.h deleted file mode 100644 index 64f5b5a6c2..0000000000 --- a/gr-video-sdl/src/video_sdl_sink_s.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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_VIDEO_SDL_SINK_S_H -#define INCLUDED_VIDEO_SDL_SINK_S_H - -#include <video_sdl_api.h> -#include <gr_sync_block.h> -#include <string> -#include <SDL.h> - -/* fourcc (four character code) */ -#define vid_fourcc(a,b,c,d) (((unsigned)(a)<<0) | ((unsigned)(b)<<8) | ((unsigned)(c)<<16) | ((unsigned)(d)<<24)) -#define IMGFMT_YV12 vid_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */ - -class video_sdl_sink_s; -typedef boost::shared_ptr<video_sdl_sink_s> video_sdl_sink_s_sptr; - -VIDEO_SDL_API video_sdl_sink_s_sptr -video_sdl_make_sink_s (double framerate,int width=640, int height=480,unsigned int format=IMGFMT_YV12,int dst_width=-1,int dst_height=-1); - -/*! - * \brief video sink using SDL - * - * input signature is one, two or three streams of signed short. - * One stream: stream is grey (Y) - * two streems: first is grey (Y), second is alternating U and V - * Three streams: first is grey (Y), second is U, third is V - * Input samples must be in the range [0,255]. - */ - -class VIDEO_SDL_API video_sdl_sink_s : public gr_sync_block { - friend VIDEO_SDL_API video_sdl_sink_s_sptr - video_sdl_make_sink_s (double framerate,int width, int height,unsigned int format,int dst_width,int dst_height); - - int d_chunk_size; - - protected: - video_sdl_sink_s (double framerate,int width, int height,unsigned int format, - int dst_width,int dst_height); - void copy_line_pixel_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v, - const short * src_pixels,int src_width); - void copy_line_line_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v, - const short * src_pixels,int src_width); - void copy_line_single_plane(unsigned char *dst_pixels,const short * src_pixels,int src_width); - void copy_line_single_plane_dec2(unsigned char *dst_pixels,const short * src_pixels,int src_width); - int copy_plane_to_surface (int plane,int noutput_items, - const short * src_pixels); - float d_framerate; - int d_wanted_frametime_ms; - int d_width; - int d_height; - int d_dst_width; - int d_dst_height; - int d_format; - int d_current_line; - SDL_Surface *d_screen; - SDL_Overlay *d_image; - SDL_Rect d_dst_rect; - float d_avg_delay; - unsigned int d_wanted_ticks; - - - public: - ~video_sdl_sink_s (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_VIDEO_SDL_SINK_S_H */ diff --git a/gr-video-sdl/src/video_sdl_sink_uc.cc b/gr-video-sdl/src/video_sdl_sink_uc.cc deleted file mode 100644 index 360df1109f..0000000000 --- a/gr-video-sdl/src/video_sdl_sink_uc.cc +++ /dev/null @@ -1,291 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <SDL.h> - -#include <video_sdl_sink_uc.h> -#include <gr_io_signature.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <stdio.h> -#include <iostream> -#include <stdexcept> -#include <string.h> - - - -video_sdl_sink_uc::video_sdl_sink_uc (double framerate,int width, int height,unsigned int format,int dst_width,int dst_height) - : gr_sync_block ("video_sdl_sink_uc", - gr_make_io_signature (1, 3, sizeof (unsigned char)), - gr_make_io_signature (0, 0, 0)), - d_chunk_size (width*height), - d_framerate(framerate), - d_wanted_frametime_ms(0), - d_width(width), - d_height (height), - d_dst_width(dst_width), - d_dst_height(dst_height), - d_format(format), - d_current_line(0), - d_screen(NULL), - d_image(NULL), - d_avg_delay(0.0), - d_wanted_ticks(0) -{ - if(framerate<=0.0) - d_wanted_frametime_ms=0;//Go as fast as possible - else - d_wanted_frametime_ms=(int)(1000.0/framerate); - if(dst_width<0) d_dst_width=d_width; - if(dst_height<0) d_dst_height=d_height; - if(0==format) d_format=IMGFMT_YV12; - - atexit(SDL_Quit);//check if this is the way to do this - if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { - std::cerr << "video_sdl_sink_uc: Couldn't initialize SDL:" << SDL_GetError() << " \n SDL_Init(SDL_INIT_VIDEO) failed\n"; - throw std::runtime_error ("video_sdl_sink_uc"); - }; - - /* accept any depth */ - d_screen = SDL_SetVideoMode(dst_width, dst_height, 0, SDL_SWSURFACE|SDL_RESIZABLE|SDL_ANYFORMAT);//SDL_DOUBLEBUF |SDL_SWSURFACE| SDL_HWSURFACE||SDL_FULLSCREEN - if ( d_screen == NULL ) { - std::cerr << "Unable to set SDL video mode: " << SDL_GetError() <<"\n SDL_SetVideoMode() Failed \n"; - exit(1); - } - if ( d_image ) { - SDL_FreeYUVOverlay(d_image); - } - /* Initialize and create the YUV Overlay used for video out */ - if (!(d_image = SDL_CreateYUVOverlay (d_width, d_height, SDL_YV12_OVERLAY, d_screen))) { - std::cerr << "SDL: Couldn't create a YUV overlay: \n"<< SDL_GetError() <<"\n"; - throw std::runtime_error ("video_sdl_sink_uc"); - } - - printf("SDL screen_mode %d bits-per-pixel\n", - d_screen->format->BitsPerPixel); - printf("SDL overlay_mode %i \n", - d_image->format); - d_chunk_size = std::min(1,16384/width); //width*16; - d_chunk_size = d_chunk_size*width; - //d_chunk_size = (int) (width); - set_output_multiple (d_chunk_size); - /* Set the default playback area */ - d_dst_rect.x = 0; - d_dst_rect.y = 0; - d_dst_rect.w = d_dst_width; - d_dst_rect.h = d_dst_height; - //clear the surface to grey - if ( SDL_LockYUVOverlay( d_image ) ) { - std::cerr << "SDL: Couldn't lock YUV overlay: \n"<< SDL_GetError() <<"\n"; - throw std::runtime_error ("video_sdl_sink_uc"); - } - memset(d_image->pixels[0], 128, d_image->pitches[0]*d_height); - memset(d_image->pixels[1], 128, d_image->pitches[1]*d_height/2); - memset(d_image->pixels[2], 128, d_image->pitches[2]*d_height/2); - SDL_UnlockYUVOverlay( d_image ); -} - -video_sdl_sink_uc::~video_sdl_sink_uc () -{ - SDL_Quit(); -} - -video_sdl_sink_uc_sptr -video_sdl_make_sink_uc (double framerate,int width, int height,unsigned int format,int dst_width,int dst_height) -{ - return gnuradio::get_initial_sptr(new video_sdl_sink_uc (framerate, width, height,format,dst_width,dst_height)); -} - -void -video_sdl_sink_uc::copy_line_pixel_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v,const unsigned char * src_pixels,int src_width) -{ - for(int i=0;i<src_width;i++) - { - dst_pixels_u[i]=src_pixels[i*2]; - dst_pixels_v[i]=src_pixels[i*2+1]; - } - return; -} - -void -video_sdl_sink_uc::copy_line_line_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v,const unsigned char * src_pixels,int src_width) -{ - memcpy(dst_pixels_u, src_pixels, src_width); - memcpy(dst_pixels_v, src_pixels+src_width, src_width); - return; -} - -void -video_sdl_sink_uc::copy_line_single_plane(unsigned char *dst_pixels,const unsigned char * src_pixels,int src_width) -{ - memcpy(dst_pixels, src_pixels, src_width); - return; -} - -void -video_sdl_sink_uc::copy_line_single_plane_dec2(unsigned char *dst_pixels,const unsigned char * src_pixels,int src_width) -{ - for(int i=0,j=0;i<src_width;i+=2,j++) - { - dst_pixels[j]=(unsigned char)src_pixels[i]; - } - return; -} - -int -video_sdl_sink_uc::copy_plane_to_surface (int plane,int noutput_items, - const unsigned char * src_pixels) -{ - const int first_dst_plane=(12==plane ||1122==plane)?1:plane; - const int second_dst_plane=(12==plane ||1122==plane)?2:plane; - int current_line=(0==plane)?d_current_line:d_current_line/2; - unsigned char * dst_pixels = (unsigned char *)d_image->pixels[first_dst_plane]; - dst_pixels=&dst_pixels[current_line*d_image->pitches[first_dst_plane]]; - unsigned char * dst_pixels_2 = (unsigned char *)d_image->pixels[second_dst_plane]; - dst_pixels_2=&dst_pixels_2[current_line*d_image->pitches[second_dst_plane]]; - int src_width=(0==plane || 12==plane || 1122==plane)?d_width:d_width/2; - int noutput_items_produced=0; - int max_height=(0==plane)?d_height-1:d_height/2-1; - for (int i = 0; i < noutput_items; i += src_width){ - //output one line at a time - if(12==plane) - { - copy_line_pixel_interleaved(dst_pixels,dst_pixels_2,src_pixels,src_width); - dst_pixels_2 += d_image->pitches[second_dst_plane]; - } - else if (1122==plane) - { - copy_line_line_interleaved(dst_pixels,dst_pixels_2,src_pixels,src_width); - dst_pixels_2 += d_image->pitches[second_dst_plane]; - src_pixels += src_width; - } - else if (0==plane) - copy_line_single_plane(dst_pixels,src_pixels,src_width); - else /* 1==plane || 2==plane*/ - copy_line_single_plane_dec2(dst_pixels,src_pixels,src_width);//decimate by two horizontally - src_pixels += src_width; - dst_pixels += d_image->pitches[first_dst_plane]; - noutput_items_produced+=src_width; - current_line++; - if (current_line>max_height) - { - //Start new frame - //TODO, do this all in a seperate thread - current_line=0; - dst_pixels=d_image->pixels[first_dst_plane]; - dst_pixels_2=d_image->pixels[second_dst_plane]; - if(0==plane) - { - SDL_DisplayYUVOverlay(d_image, &d_dst_rect); - //SDL_Flip(d_screen); - unsigned int ticks=SDL_GetTicks();//milliseconds - d_wanted_ticks+=d_wanted_frametime_ms; - float avg_alpha=0.1; - int time_diff=d_wanted_ticks-ticks; - d_avg_delay=time_diff*avg_alpha +d_avg_delay*(1.0-avg_alpha); - } - } - } - if(0==plane) d_current_line=current_line; - return noutput_items_produced; -} - -int -video_sdl_sink_uc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - unsigned char *src_pixels_0,*src_pixels_1,*src_pixels_2; - int noutput_items_produced=0; - int plane; - int delay=(int)d_avg_delay; - if(0==d_wanted_ticks) - d_wanted_ticks=SDL_GetTicks(); - if(delay>0) - SDL_Delay((unsigned int)delay);//compensate if running too fast - - if ( SDL_LockYUVOverlay( d_image ) ) { - return 0; - } - switch (input_items.size ()){ - case 3: // first channel=Y, second channel is U , third channel is V - src_pixels_0 = (unsigned char *) input_items[0]; - src_pixels_1 = (unsigned char *) input_items[1]; - src_pixels_2 = (unsigned char *) input_items[2]; - for (int i = 0; i < noutput_items; i += d_chunk_size){ - copy_plane_to_surface (1,d_chunk_size, src_pixels_1); - copy_plane_to_surface (2,d_chunk_size, src_pixels_2); - noutput_items_produced+=copy_plane_to_surface (0,d_chunk_size, src_pixels_0); - src_pixels_0 += d_chunk_size; - src_pixels_1 += d_chunk_size; - src_pixels_2 += d_chunk_size; - } - break; - case 2: - if(1) //if(pixel_interleaved_uv) - { - // first channel=Y, second channel is alternating pixels U and V - src_pixels_0 = (unsigned char *) input_items[0]; - src_pixels_1 = (unsigned char *) input_items[1]; - for (int i = 0; i < noutput_items; i += d_chunk_size){ - copy_plane_to_surface (12,d_chunk_size/2, src_pixels_1); - noutput_items_produced+=copy_plane_to_surface (0,d_chunk_size, src_pixels_0); - src_pixels_0 += d_chunk_size; - src_pixels_1 += d_chunk_size; - } - } else - { - // first channel=Y, second channel is alternating lines U and V - src_pixels_0 = (unsigned char *) input_items[0]; - src_pixels_1 = (unsigned char *) input_items[1]; - for (int i = 0; i < noutput_items; i += d_chunk_size){ - copy_plane_to_surface (1222,d_chunk_size/2, src_pixels_1); - noutput_items_produced+=copy_plane_to_surface (0,d_chunk_size, src_pixels_0); - src_pixels_0 += d_chunk_size; - src_pixels_1 += d_chunk_size; - } - } - break; - case 1: // grey (Y) input - /* Y component */ - plane=0; - src_pixels_0 = (unsigned char *) input_items[plane]; - for (int i = 0; i < noutput_items; i += d_chunk_size){ - noutput_items_produced+=copy_plane_to_surface (plane,d_chunk_size, src_pixels_0); - src_pixels_0 += d_chunk_size; - } - break; - default: //0 or more then 3 channels - std::cerr << "video_sdl_sink_uc: Wrong number of channels: "; - std::cerr <<"1, 2 or 3 channels are supported.\n Requested number of channels is "<< input_items.size () <<"\n"; - throw std::runtime_error ("video_sdl_sink_uc"); - } - - SDL_UnlockYUVOverlay( d_image ); - return noutput_items_produced; -} diff --git a/gr-video-sdl/src/video_sdl_sink_uc.h b/gr-video-sdl/src/video_sdl_sink_uc.h deleted file mode 100644 index 6c071cf9db..0000000000 --- a/gr-video-sdl/src/video_sdl_sink_uc.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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_VIDEO_SDL_SINK_UC_H -#define INCLUDED_VIDEO_SDL_SINK_UC_H - -#include <video_sdl_api.h> -#include <gr_sync_block.h> -#include <string> -#include <SDL.h> - -/* fourcc (four character code) */ -#define vid_fourcc(a,b,c,d) (((unsigned)(a)<<0) | ((unsigned)(b)<<8) | ((unsigned)(c)<<16) | ((unsigned)(d)<<24)) -#define IMGFMT_YV12 vid_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */ - -class video_sdl_sink_uc; -typedef boost::shared_ptr<video_sdl_sink_uc> video_sdl_sink_uc_sptr; - -VIDEO_SDL_API video_sdl_sink_uc_sptr -video_sdl_make_sink_uc (double framerate,int width=640, int height=480,unsigned int format=IMGFMT_YV12,int dst_width=-1,int dst_height=-1); - -/*! - * \brief video sink using SDL - * - * input signature is one, two or three streams of uchar. - * One stream: stream is grey (Y) - * two streems: first is grey (Y), second is alternating U and V - * Three streams: first is grey (Y), second is U, third is V - * Input samples must be in the range [0,255]. - */ - -class VIDEO_SDL_API video_sdl_sink_uc : public gr_sync_block { - friend VIDEO_SDL_API video_sdl_sink_uc_sptr - video_sdl_make_sink_uc (double framerate,int width, int height,unsigned int format,int dst_width,int dst_height); - - int d_chunk_size; - - protected: - video_sdl_sink_uc (double framerate,int width, int height,unsigned int format, - int dst_width,int dst_height); - void copy_line_pixel_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v, - const unsigned char * src_pixels,int src_width); - void copy_line_line_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v, - const unsigned char * src_pixels,int src_width); - void copy_line_single_plane(unsigned char *dst_pixels,const unsigned char * src_pixels,int src_width); - void copy_line_single_plane_dec2(unsigned char *dst_pixels,const unsigned char * src_pixels,int src_width); - int copy_plane_to_surface (int plane,int noutput_items, - const unsigned char * src_pixels); - float d_framerate; - int d_wanted_frametime_ms; - int d_width; - int d_height; - int d_dst_width; - int d_dst_height; - int d_format; - int d_current_line; - SDL_Surface *d_screen; - SDL_Overlay *d_image; - SDL_Rect d_dst_rect; - float d_avg_delay; - unsigned int d_wanted_ticks; - - - public: - ~video_sdl_sink_uc (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_VIDEO_SDL_SINK_UC_H */ diff --git a/gr-video-sdl/swig/CMakeLists.txt b/gr-video-sdl/swig/CMakeLists.txt new file mode 100644 index 0000000000..665e398d43 --- /dev/null +++ b/gr-video-sdl/swig/CMakeLists.txt @@ -0,0 +1,58 @@ +# Copyright 2012 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. + +######################################################################## +# Setup swig generation +######################################################################## +include(GrPython) +include(GrSwig) + +set(GR_SWIG_INCLUDE_DIRS + ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} + ${GR_VIDEO_SDL_INCLUDE_DIRS} +) + +set(GR_SWIG_LIBRARIES gnuradio-video-sdl) + +if(ENABLE_GR_CTRLPORT) + ADD_DEFINITIONS(-DGR_CTRLPORT) +endif(ENABLE_GR_CTRLPORT) + +# Setup swig docs to depend on includes and pull in from build directory +set(GR_SWIG_TARGET_DEPS video_sdl_generated_includes) +set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/video_sdl_swig_doc.i) +set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../lib) + +set(GR_SWIG_LIBRARIES gnuradio-video-sdl) + +GR_SWIG_MAKE(video_sdl_swig video_sdl_swig.i) + +GR_SWIG_INSTALL( + TARGETS video_sdl_swig + DESTINATION ${GR_PYTHON_DIR}/gnuradio/video_sdl + COMPONENT "video_sdl_python" +) + +install( + FILES + video_sdl_swig.i + ${CMAKE_CURRENT_BINARY_DIR}/video_sdl_swig_doc.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "video_sdl_swig" +) diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.i b/gr-video-sdl/swig/video_sdl_swig.i index e5fdea3488..8561565901 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_ff.i +++ b/gr-video-sdl/swig/video_sdl_swig.i @@ -20,13 +20,20 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,multiply_ff) +#define VIDEO_SDL_API -gr_multiply_ff_sptr -gr_make_multiply_ff (size_t vlen=1); +%include "gnuradio.i" // the common stuff -class gr_multiply_ff : public gr_sync_block -{ -public: +//load generated python docstrings +%include "video_sdl_swig_doc.i" -}; +%{ +#include "video_sdl/sink_uc.h" +#include "video_sdl/sink_s.h" +%} + +%include "video_sdl/sink_uc.h" +%include "video_sdl/sink_s.h" + +GR_SWIG_BLOCK_MAGIC2(video_sdl, sink_uc); +GR_SWIG_BLOCK_MAGIC2(video_sdl, sink_s); diff --git a/gr-vocoder/CMakeLists.txt b/gr-vocoder/CMakeLists.txt index 6f9962d5a0..95c7ae3c19 100644 --- a/gr-vocoder/CMakeLists.txt +++ b/gr-vocoder/CMakeLists.txt @@ -30,6 +30,7 @@ GR_REGISTER_COMPONENT("gr-vocoder" ENABLE_GR_VOCODER Boost_FOUND ENABLE_GR_CORE ENABLE_GR_FFT + ENABLE_GR_BLOCKS ENABLE_GR_FILTER ) diff --git a/gr-vocoder/examples/alaw_audio_loopback.py b/gr-vocoder/examples/alaw_audio_loopback.py index ad686244b3..5b800b5bfb 100755 --- a/gr-vocoder/examples/alaw_audio_loopback.py +++ b/gr-vocoder/examples/alaw_audio_loopback.py @@ -22,17 +22,18 @@ from gnuradio import gr from gnuradio import audio +from gnuradio import blocks from gnuradio import vocoder def build_graph(): tb = gr.top_block() src = audio.source(8000) - src_scale = gr.multiply_const_ff(32767) - f2s = gr.float_to_short () + src_scale = blocks.multiply_const_ff(32767) + f2s = blocks.float_to_short() enc = vocoder.alaw_encode_sb() dec = vocoder.alaw_decode_bs() - s2f = gr.short_to_float () - sink_scale = gr.multiply_const_ff(1.0/32767.) + s2f = blocks.short_to_float() + sink_scale = blocks.multiply_const_ff(1.0/32767.) sink = audio.sink(8000) tb.connect(src, src_scale, f2s, enc, dec, s2f, sink_scale, sink) return tb diff --git a/gr-vocoder/examples/codec2_audio_loopback.py b/gr-vocoder/examples/codec2_audio_loopback.py index f5da9c217b..bf95f39ce9 100755 --- a/gr-vocoder/examples/codec2_audio_loopback.py +++ b/gr-vocoder/examples/codec2_audio_loopback.py @@ -22,17 +22,18 @@ from gnuradio import gr from gnuradio import audio +from gnuradio import blocks from gnuradio import vocoder def build_graph(): tb = gr.top_block() src = audio.source(8000) - src_scale = gr.multiply_const_ff(32767) - f2s = gr.float_to_short () + src_scale = blocks.multiply_const_ff(32767) + f2s = blocks.float_to_short() enc = vocoder.codec2_encode_sp() dec = vocoder.codec2_decode_ps() - s2f = gr.short_to_float () - sink_scale = gr.multiply_const_ff(1.0/32767.) + s2f = blocks.short_to_float() + sink_scale = blocks.multiply_const_ff(1.0/32767.) sink = audio.sink(8000) tb.connect(src, src_scale, f2s, enc, dec, s2f, sink_scale, sink) return tb diff --git a/gr-vocoder/examples/cvsd_audio_loopback.py b/gr-vocoder/examples/cvsd_audio_loopback.py index f101fecb4e..ef4c6ded21 100755 --- a/gr-vocoder/examples/cvsd_audio_loopback.py +++ b/gr-vocoder/examples/cvsd_audio_loopback.py @@ -20,8 +20,10 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, blks2 +from gnuradio import gr from gnuradio import audio +from gnuradio import blocks +from gnuradio import filter from gnuradio import vocoder def build_graph(): @@ -30,18 +32,18 @@ def build_graph(): tb = gr.top_block() src = audio.source(sample_rate, "plughw:0,0") - src_scale = gr.multiply_const_ff(scale_factor) + src_scale = blocks.multiply_const_ff(scale_factor) - interp = blks2.rational_resampler_fff(8, 1) - f2s = gr.float_to_short () + interp = filter.rational_resampler_fff(8, 1) + f2s = blocks.float_to_short() enc = vocoder.cvsd_encode_sb() dec = vocoder.cvsd_decode_bs() - s2f = gr.short_to_float () - decim = blks2.rational_resampler_fff(1, 8) + s2f = blocks.short_to_float() + decim = filter.rational_resampler_fff(1, 8) - sink_scale = gr.multiply_const_ff(1.0/scale_factor) + sink_scale = blocks.multiply_const_ff(1.0/scale_factor) sink = audio.sink(sample_rate, "plughw:0,0") tb.connect(src, src_scale, interp, f2s, enc) diff --git a/gr-vocoder/examples/g721_audio_loopback.py b/gr-vocoder/examples/g721_audio_loopback.py index 339ea79ad1..42abbabf64 100755 --- a/gr-vocoder/examples/g721_audio_loopback.py +++ b/gr-vocoder/examples/g721_audio_loopback.py @@ -22,17 +22,18 @@ from gnuradio import gr from gnuradio import audio +from gnuradio import blocks from gnuradio import vocoder def build_graph(): tb = gr.top_block() src = audio.source(8000) - src_scale = gr.multiply_const_ff(32767) - f2s = gr.float_to_short () + src_scale = blocks.multiply_const_ff(32767) + f2s = blocks.float_to_short() enc = vocoder.g721_encode_sb() dec = vocoder.g721_decode_bs() - s2f = gr.short_to_float () - sink_scale = gr.multiply_const_ff(1.0/32767.) + s2f = blocks.short_to_float() + sink_scale = blocks.multiply_const_ff(1.0/32767.) sink = audio.sink(8000) tb.connect(src, src_scale, f2s, enc, dec, s2f, sink_scale, sink) return tb diff --git a/gr-vocoder/examples/g723_24_audio_loopback.py b/gr-vocoder/examples/g723_24_audio_loopback.py index 34d9ddd5dd..cade33f295 100755 --- a/gr-vocoder/examples/g723_24_audio_loopback.py +++ b/gr-vocoder/examples/g723_24_audio_loopback.py @@ -22,17 +22,18 @@ from gnuradio import gr from gnuradio import audio +from gnuradio import blocks from gnuradio import vocoder def build_graph(): tb = gr.top_block() src = audio.source(8000) - src_scale = gr.multiply_const_ff(32767) - f2s = gr.float_to_short () + src_scale = blocks.multiply_const_ff(32767) + f2s = blocks.float_to_short() enc = vocoder.g723_24_encode_sb() dec = vocoder.g723_24_decode_bs() - s2f = gr.short_to_float () - sink_scale = gr.multiply_const_ff(1.0/32767.) + s2f = blocks.short_to_float() + sink_scale = blocks.multiply_const_ff(1.0/32767.) sink = audio.sink(8000) tb.connect(src, src_scale, f2s, enc, dec, s2f, sink_scale, sink) return tb diff --git a/gr-vocoder/examples/g723_40_audio_loopback.py b/gr-vocoder/examples/g723_40_audio_loopback.py index c636d82d1e..77e40884cf 100755 --- a/gr-vocoder/examples/g723_40_audio_loopback.py +++ b/gr-vocoder/examples/g723_40_audio_loopback.py @@ -22,17 +22,18 @@ from gnuradio import gr from gnuradio import audio +from gnuradio import blocks from gnuradio import vocoder def build_graph(): tb = gr.top_block() src = audio.source(8000) - src_scale = gr.multiply_const_ff(32767) - f2s = gr.float_to_short () + src_scale = blocks.multiply_const_ff(32767) + f2s = blocks.float_to_short() enc = vocoder.g723_40_encode_sb() dec = vocoder.g723_40_decode_bs() - s2f = gr.short_to_float () - sink_scale = gr.multiply_const_ff(1.0/32767.) + s2f = blocks.short_to_float() + sink_scale = blocks.multiply_const_ff(1.0/32767.) sink = audio.sink(8000) tb.connect(src, src_scale, f2s, enc, dec, s2f, sink_scale, sink) return tb diff --git a/gr-vocoder/examples/gsm_audio_loopback.py b/gr-vocoder/examples/gsm_audio_loopback.py index ba0fcb847b..5d5bf9dd72 100755 --- a/gr-vocoder/examples/gsm_audio_loopback.py +++ b/gr-vocoder/examples/gsm_audio_loopback.py @@ -22,17 +22,18 @@ from gnuradio import gr from gnuradio import audio +from gnuradio import blocks from gnuradio import vocoder def build_graph(): tb = gr.top_block() src = audio.source(8000) - src_scale = gr.multiply_const_ff(32767) - f2s = gr.float_to_short () + src_scale = blocks.multiply_const_ff(32767) + f2s = blocks.float_to_short() enc = vocoder.gsm_fr_encode_sp() dec = vocoder.gsm_fr_decode_ps() - s2f = gr.short_to_float () - sink_scale = gr.multiply_const_ff(1.0/32767.) + s2f = blocks.short_to_float() + sink_scale = blocks.multiply_const_ff(1.0/32767.) sink = audio.sink(8000) tb.connect(src, src_scale, f2s, enc, dec, s2f, sink_scale, sink) return tb diff --git a/gr-vocoder/examples/ulaw_audio_loopback.py b/gr-vocoder/examples/ulaw_audio_loopback.py index e7a96d3673..9f0617622e 100755 --- a/gr-vocoder/examples/ulaw_audio_loopback.py +++ b/gr-vocoder/examples/ulaw_audio_loopback.py @@ -22,17 +22,18 @@ from gnuradio import gr from gnuradio import audio +from gnuradio import blocks from gnuradio import vocoder def build_graph(): tb = gr.top_block() src = audio.source(8000) - src_scale = gr.multiply_const_ff(32767) - f2s = gr.float_to_short () + src_scale = blocks.multiply_const_ff(32767) + f2s = blocks.float_to_short() enc = vocoder.ulaw_encode_sb() dec = vocoder.ulaw_decode_bs() - s2f = gr.short_to_float () - sink_scale = gr.multiply_const_ff(1.0/32767.) + s2f = blocks.short_to_float() + sink_scale = blocks.multiply_const_ff(1.0/32767.) sink = audio.sink(8000) tb.connect(src, src_scale, f2s, enc, dec, s2f, sink_scale, sink) return tb diff --git a/gr-vocoder/python/CMakeLists.txt b/gr-vocoder/python/CMakeLists.txt index 372dcec051..9fdc625280 100644 --- a/gr-vocoder/python/CMakeLists.txt +++ b/gr-vocoder/python/CMakeLists.txt @@ -36,6 +36,8 @@ GR_PYTHON_INSTALL( if(ENABLE_TESTING) list(APPEND GR_TEST_PYTHON_DIRS + ${CMAKE_BINARY_DIR}/gr-blocks/python + ${CMAKE_BINARY_DIR}/gr-blocks/swig ${CMAKE_BINARY_DIR}/gr-filter/python ${CMAKE_BINARY_DIR}/gr-filter/swig ${CMAKE_BINARY_DIR}/gr-analog/python diff --git a/gr-vocoder/python/cvsd.py b/gr-vocoder/python/cvsd.py index 0b38615f41..1c58c33076 100644 --- a/gr-vocoder/python/cvsd.py +++ b/gr-vocoder/python/cvsd.py @@ -28,6 +28,11 @@ try: except ImportError: import filter_swig as filter +try: + from gnuradio import blocks +except ImportError: + import blocks_swig as blocks + class cvsd_encode_fb(gr.hier_block2): ''' This is a wrapper for the CVSD encoder that performs interpolation and filtering @@ -51,10 +56,10 @@ class cvsd_encode_fb(gr.hier_block2): scale_factor = 32000.0 self.interp = resample - src_scale = gr.multiply_const_ff(scale_factor) + src_scale = blocks.multiply_const_ff(scale_factor) taps = filter.firdes.low_pass(self.interp, self.interp, bw, 2*bw) interp = filter.interp_fir_filter_fff(self.interp, taps) - f2s = gr.float_to_short() + f2s = blocks.float_to_short() enc = vocoder_swig.cvsd_encode_sb() self.connect(self, src_scale, interp, f2s, enc, self) @@ -83,9 +88,9 @@ class cvsd_decode_bf(gr.hier_block2): self.decim = resample dec = vocoder_swig.cvsd_decode_bs() - s2f = gr.short_to_float() + s2f = blocks.short_to_float() taps = filter.firdes.low_pass(1, 1, bw, 2*bw) decim = filter.fir_filter_fff(self.decim, taps) - sink_scale = gr.multiply_const_ff(1.0/scale_factor) + sink_scale = blocks.multiply_const_ff(1.0/scale_factor) self.connect(self, dec, s2f, decim, sink_scale, self) diff --git a/gr-vocoder/python/qa_cvsd_vocoder.py b/gr-vocoder/python/qa_cvsd_vocoder.py index fc7ba35249..579b019cc9 100755 --- a/gr-vocoder/python/qa_cvsd_vocoder.py +++ b/gr-vocoder/python/qa_cvsd_vocoder.py @@ -23,6 +23,8 @@ from gnuradio import gr, gr_unittest from vocoder_swig import * from cvsd import * +import blocks_swig as blocks +import filter_swig as filter class test_cvsd_vocoder (gr_unittest.TestCase): @@ -99,18 +101,18 @@ class test_cvsd_vocoder (gr_unittest.TestCase): # If we enable this, we can probably just create a sin with numpy. src = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 200, 1, 0) head = gr.head(gr.sizeof_float, 100) - src_scale = gr.multiply_const_ff(scale_factor) + src_scale = blocks.multiply_const_ff(scale_factor) - interp = blks2.rational_resampler_fff(8, 1) - f2s = gr.float_to_short () + interp = filter.rational_resampler_fff(8, 1) + f2s = blocks.float_to_short() enc = cvsd_vocoder.encode_sb() dec = cvsd_vocoder.decode_bs() - s2f = gr.short_to_float () - decim = blks2.rational_resampler_fff(1, 8) + s2f = blocks.short_to_float() + decim = filter.rational_resampler_fff(1, 8) - sink_scale = gr.multiply_const_ff(1.0/scale_factor) + sink_scale = blocks.multiply_const_ff(1.0/scale_factor) sink = gr.vector_sink_f() self.tb.connect(src, src_scale, interp, f2s, enc) diff --git a/gr-wxgui/grc/wxgui_fftsink2.xml b/gr-wxgui/grc/wxgui_fftsink2.xml index 74ee5b173e..ff5c47b85c 100644 --- a/gr-wxgui/grc/wxgui_fftsink2.xml +++ b/gr-wxgui/grc/wxgui_fftsink2.xml @@ -8,7 +8,7 @@ <name>WX GUI FFT Sink</name> <key>wxgui_fftsink2</key> <category>WX GUI Widgets</category> - <import>from gnuradio import window</import> + <import>from gnuradio.fft import window</import> <import>from gnuradio.wxgui import fftsink2</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' fftsink2.$(type.fcn)( diff --git a/gr-wxgui/grc/wxgui_waterfallsink2.xml b/gr-wxgui/grc/wxgui_waterfallsink2.xml index 8921e87f9a..c02901d336 100644 --- a/gr-wxgui/grc/wxgui_waterfallsink2.xml +++ b/gr-wxgui/grc/wxgui_waterfallsink2.xml @@ -8,7 +8,7 @@ <name>WX GUI Waterfall Sink</name> <key>wxgui_waterfallsink2</key> <category>WX GUI Widgets</category> - <import>from gnuradio import window</import> + <import>from gnuradio.fft import window</import> <import>from gnuradio.wxgui import waterfallsink2</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' waterfallsink2.$(type.fcn)( diff --git a/gr-wxgui/src/python/constsink_gl.py b/gr-wxgui/src/python/constsink_gl.py index 51434df68f..4765e7a6eb 100644 --- a/gr-wxgui/src/python/constsink_gl.py +++ b/gr-wxgui/src/python/constsink_gl.py @@ -24,7 +24,8 @@ ################################################## import const_window import common -from gnuradio import gr, blks2 +from gnuradio import gr +from gnuradio import blocks from pubsub import pubsub from constants import * import sys @@ -68,7 +69,7 @@ class const_sink_c(gr.hier_block2, common.wxgui_hb): gr.io_signature(0, 0, 0), ) #blocks - sd = blks2.stream_to_vector_decimator( + sd = blocks.stream_to_vector_decimator( item_size=gr.sizeof_gr_complex, sample_rate=sample_rate, vec_rate=frame_rate, diff --git a/gr-wxgui/src/python/fftsink_gl.py b/gr-wxgui/src/python/fftsink_gl.py index 931cf5c725..e87b86ec2a 100644 --- a/gr-wxgui/src/python/fftsink_gl.py +++ b/gr-wxgui/src/python/fftsink_gl.py @@ -28,6 +28,8 @@ import fft_window import common from gnuradio import gr, fft from gnuradio import analog +from gnuradio import blocks +from gnuradio.fft import logpwrfft from pubsub import pubsub from constants import * import math @@ -133,12 +135,12 @@ class _fft_sink_base(gr.hier_block2, common.wxgui_hb): self.win.set_callback(callb) class fft_sink_f(_fft_sink_base): - _fft_chain = fft.logpwrfft_f + _fft_chain = logpwrfft.logpwrfft_f _item_size = gr.sizeof_float _real = True class fft_sink_c(_fft_sink_base): - _fft_chain = fft.logpwrfft_c + _fft_chain = logpwrfft.logpwrfft_c _item_size = gr.sizeof_gr_complex _real = False @@ -174,7 +176,7 @@ class test_app_block (stdgui2.std_top_block): ref_level=0, y_per_div=20, y_divs=10) vbox.Add(sink1.win, 1, wx.EXPAND) - combine1 = gr.add_cc() + combine1 = blocks.add_cc() self.connect(src1, (combine1,0)) self.connect(noise,(combine1,1)) self.connect(combine1,thr1, sink1) @@ -187,7 +189,7 @@ class test_app_block (stdgui2.std_top_block): ref_level=0, y_per_div=20, y_divs=10) vbox.Add(sink2.win, 1, wx.EXPAND) - combine2 = gr.add_ff() + combine2 = blocks.add_ff() c2f2 = gr.complex_to_float() self.connect(src2, (combine2,0)) diff --git a/gr-wxgui/src/python/fftsink_nongl.py b/gr-wxgui/src/python/fftsink_nongl.py index bc634b5cc7..e9308fd354 100644 --- a/gr-wxgui/src/python/fftsink_nongl.py +++ b/gr-wxgui/src/python/fftsink_nongl.py @@ -20,9 +20,11 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, window, fft, filter +from gnuradio import gr, gru, fft, filter +from gnuradio import blocks from gnuradio import analog from gnuradio.wxgui import stdgui2 +from gnuradio.filter import window import wx import plot import numpy @@ -118,9 +120,9 @@ class fft_sink_f(gr.hier_block2, fft_sink_base): average=average, avg_alpha=avg_alpha, title=title, peak_hold=peak_hold,use_persistence=use_persistence,persist_alpha=persist_alpha) - self.s2p = gr.stream_to_vector(gr.sizeof_float, self.fft_size) - self.one_in_n = gr.keep_one_in_n(gr.sizeof_float * self.fft_size, - max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) + self.s2p = blocks.stream_to_vector(gr.sizeof_float, self.fft_size) + self.one_in_n = blocks.keep_one_in_n(gr.sizeof_float * self.fft_size, + max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) self.fft = fft.fft_vfc(self.fft_size, True, mywindow) @@ -132,10 +134,10 @@ class fft_sink_f(gr.hier_block2, fft_sink_base): self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) # FIXME We need to add 3dB to all bins but the DC bin - self.log = gr.nlog10_ff(20, self.fft_size, - -10*math.log10(self.fft_size) # Adjust for number of bins - -10*math.log10(power/self.fft_size) # Adjust for windowing loss - -20*math.log10(ref_scale/2)) # Adjust for reference scale + self.log = blocks.nlog10_ff(20, self.fft_size, + -10*math.log10(self.fft_size) # Adjust for number of bins + -10*math.log10(power/self.fft_size) # Adjust for windowing loss + -20*math.log10(ref_scale/2)) # Adjust for reference scale self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink) @@ -150,7 +152,8 @@ class fft_sink_c(gr.hier_block2, fft_sink_base): def __init__(self, parent, baseband_freq=0, ref_scale=2.0, y_per_div=10, y_divs=8, ref_level=50, sample_rate=1, fft_size=512, fft_rate=default_fft_rate, average=False, avg_alpha=None, - title='', size=default_fftsink_size, peak_hold=False, use_persistence=False,persist_alpha=0.2, **kwargs): + title='', size=default_fftsink_size, peak_hold=False, + use_persistence=False, persist_alpha=0.2, **kwargs): gr.hier_block2.__init__(self, "fft_sink_c", gr.io_signature(1, 1, gr.sizeof_gr_complex), @@ -163,9 +166,9 @@ class fft_sink_c(gr.hier_block2, fft_sink_base): average=average, avg_alpha=avg_alpha, title=title, peak_hold=peak_hold, use_persistence=use_persistence,persist_alpha=persist_alpha) - self.s2p = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) - self.one_in_n = gr.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size, - max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) + self.s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) + self.one_in_n = blocks.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size, + max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) self.fft = fft.fft_vcc(self.fft_size, True, mywindow) @@ -177,10 +180,10 @@ class fft_sink_c(gr.hier_block2, fft_sink_base): self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) # FIXME We need to add 3dB to all bins but the DC bin - self.log = gr.nlog10_ff(20, self.fft_size, - -10*math.log10(self.fft_size) # Adjust for number of bins - -10*math.log10(power/self.fft_size) # Adjust for windowing loss - -20*math.log10(ref_scale/2)) # Adjust for reference scale + self.log = blocks.nlog10_ff(20, self.fft_size, + -10*math.log10(self.fft_size) # Adjust for number of bins + -10*math.log10(power/self.fft_size) # Adjust for windowing loss + -20*math.log10(ref_scale/2)) # Adjust for reference scale self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink) diff --git a/gr-wxgui/src/python/numbersink2.py b/gr-wxgui/src/python/numbersink2.py index f85d9c3ee1..1619b09eb6 100644 --- a/gr-wxgui/src/python/numbersink2.py +++ b/gr-wxgui/src/python/numbersink2.py @@ -24,8 +24,9 @@ ################################################## import number_window import common -from gnuradio import gr, blks2, filter +from gnuradio import gr, filter from gnuradio import analog +from gnuradio import blocks from pubsub import pubsub from constants import * @@ -66,19 +67,19 @@ class _number_sink_base(gr.hier_block2, common.wxgui_hb): gr.io_signature(0, 0, 0), ) #blocks - sd = blks2.stream_to_vector_decimator( + sd = blocks.stream_to_vector_decimator( item_size=self._item_size, sample_rate=sample_rate, vec_rate=number_rate, vec_len=1, ) if self._real: - mult = gr.multiply_const_ff(factor) - add = gr.add_const_ff(ref_level) + mult = blocks.multiply_const_ff(factor) + add = blocks.add_const_ff(ref_level) avg = filter.single_pole_iir_filter_ff(1.0) else: - mult = gr.multiply_const_cc(factor) - add = gr.add_const_cc(ref_level) + mult = blocks.multiply_const_cc(factor) + add = blocks.add_const_cc(ref_level) avg = filter.single_pole_iir_filter_cc(1.0) msgq = gr.msg_queue(2) sink = gr.message_sink(self._item_size, msgq, True) diff --git a/gr-wxgui/src/python/scopesink_gl.py b/gr-wxgui/src/python/scopesink_gl.py index 51bc454f09..647ea60983 100644 --- a/gr-wxgui/src/python/scopesink_gl.py +++ b/gr-wxgui/src/python/scopesink_gl.py @@ -25,6 +25,7 @@ import scope_window import common from gnuradio import gr, filter +from gnuradio import blocks from pubsub import pubsub from constants import * import math @@ -44,7 +45,7 @@ class ac_couple_block(gr.hier_block2): ) #blocks lpf = filter.single_pole_iir_filter_ff(0.0) - sub = gr.sub_ff() + sub = blocks.sub_ff() mute = gr.mute_ff() #connect self.connect(self, sub, self) diff --git a/gr-wxgui/src/python/waterfallsink_gl.py b/gr-wxgui/src/python/waterfallsink_gl.py index 050bbb5924..17900a6e4f 100644 --- a/gr-wxgui/src/python/waterfallsink_gl.py +++ b/gr-wxgui/src/python/waterfallsink_gl.py @@ -26,6 +26,7 @@ import waterfall_window import common from gnuradio import gr, fft from gnuradio import analog +from gnuradio.fft import logpwrfft from pubsub import pubsub from constants import * @@ -118,12 +119,12 @@ class _waterfall_sink_base(gr.hier_block2, common.wxgui_hb): self.win.set_callback(callb) class waterfall_sink_f(_waterfall_sink_base): - _fft_chain = fft.logpwrfft_f + _fft_chain = logpwrfft.logpwrfft_f _item_size = gr.sizeof_float _real = True class waterfall_sink_c(_waterfall_sink_base): - _fft_chain = fft.logpwrfft_c + _fft_chain = logpwrfft.logpwrfft_c _item_size = gr.sizeof_gr_complex _real = False diff --git a/gr-wxgui/src/python/waterfallsink_nongl.py b/gr-wxgui/src/python/waterfallsink_nongl.py index 0e9b706708..1ff44a88c6 100644 --- a/gr-wxgui/src/python/waterfallsink_nongl.py +++ b/gr-wxgui/src/python/waterfallsink_nongl.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2003-2007,2008,2012 Free Software Foundation, Inc. +# Copyright 2003-2008,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,9 +20,11 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, window, fft, filter +from gnuradio import gr, gru, fft, filter +from gnuradio import blocks from gnuradio import analog from gnuradio.wxgui import stdgui2 +from gnuradio.filter import window import wx import gnuradio.wxgui.plot as plot import numpy @@ -88,14 +90,14 @@ class waterfall_sink_f(gr.hier_block2, waterfall_sink_base): average=average, avg_alpha=avg_alpha, title=title) self.s2p = gr.serial_to_parallel(gr.sizeof_float, self.fft_size) - self.one_in_n = gr.keep_one_in_n(gr.sizeof_float * self.fft_size, - max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) + self.one_in_n = blocks.keep_one_in_n(gr.sizeof_float * self.fft_size, + max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) self.fft = fft.fft_vfc(self.fft_size, True, mywindow) self.c2mag = gr.complex_to_mag(self.fft_size) self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) - self.log = gr.nlog10_ff(20, self.fft_size, -20*math.log10(self.fft_size)) + self.log = blocks.nlog10_ff(20, self.fft_size, -20*math.log10(self.fft_size)) self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink) @@ -119,14 +121,14 @@ class waterfall_sink_c(gr.hier_block2, waterfall_sink_base): average=average, avg_alpha=avg_alpha, title=title) self.s2p = gr.serial_to_parallel(gr.sizeof_gr_complex, self.fft_size) - self.one_in_n = gr.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size, - max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) + self.one_in_n = blocks.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size, + max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) self.fft = fft.fft_vcc(self.fft_size, True, mywindow) self.c2mag = gr.complex_to_mag(self.fft_size) self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) - self.log = gr.nlog10_ff(20, self.fft_size, -20*math.log10(self.fft_size)) + self.log = blocks.nlog10_ff(20, self.fft_size, -20*math.log10(self.fft_size)) self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink) diff --git a/grc/blocks/blks2_rational_resampler_xxx.xml b/grc/blocks/blks2_rational_resampler_xxx.xml deleted file mode 100644 index b92ec8ec20..0000000000 --- a/grc/blocks/blks2_rational_resampler_xxx.xml +++ /dev/null @@ -1,88 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Rational Resampler -################################################### - --> -<block> - <name>Rational Resampler</name> - <key>blks2_rational_resampler_xxx</key> - <import>from gnuradio import blks2</import> - <import>from gnuradio.gr import firdes</import> - <make>blks2.rational_resampler_$(type)( - interpolation=$interp, - decimation=$decim, -#if $taps() - taps=$taps, -#else - taps=None, -#end if -#if $fractional_bw() != 0 - fractional_bw=$fractional_bw, -#else - fractional_bw=None, -#end if -)</make> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex->Complex (Complex Taps)</name> - <key>ccc</key> - <opt>input:complex</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - <option> - <name>Complex->Complex (Real Taps)</name> - <key>ccf</key> - <opt>input:complex</opt> - <opt>output:complex</opt> - <opt>taps:real_vector</opt> - </option> - <option> - <name>Float->Float (Real Taps)</name> - <key>fff</key> - <opt>input:float</opt> - <opt>output:float</opt> - <opt>taps:real_vector</opt> - </option> - </param> - <param> - <name>Decimation</name> - <key>decim</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Interpolation</name> - <key>interp</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Taps</name> - <key>taps</key> - <value>[]</value> - <type>$type.taps</type> - </param> - <param> - <name>Fractional BW</name> - <key>fractional_bw</key> - <value>0</value> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>$type.input</type> - </sink> - <source> - <name>out</name> - <type>$type.output</type> - </source> - <doc> -Leave taps empty for automatic value. -Leave fractional bandwidth 0 for automatic value. - </doc> -</block> diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index bec06b2edb..9f1e62b41d 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -44,27 +44,11 @@ </cat> <cat> <name>Operators</name> - <block>gr_add_xx</block> - <block>gr_sub_xx</block> - <block>gr_multiply_xx</block> - <block>gr_divide_xx</block> - <block>gr_nlog10_ff</block> <block>gr_transcendental</block> - <block>gr_add_const_vxx</block> - <block>gr_multiply_const_vxx</block> - <block>gr_and_const_xx</block> - - <block>gr_not_xx</block> - <block>gr_and_xx</block> - <block>gr_or_xx</block> - <block>gr_xor_xx</block> <block>gr_max_xx</block> <block>gr_argmax_xx</block> <block>gr_rms_xx</block> - <block>gr_integrate_xx</block> - - <block>gr_conjugate_cc</block> <block>gr_vector_insert_x</block> @@ -79,42 +63,11 @@ <block>gr_complex_to_imag</block> <block>gr_complex_to_float</block> - <block>gr_float_to_complex</block> - - <block>gr_float_to_int</block> - <block>gr_float_to_short</block> - <block>gr_short_to_float</block> - <block>gr_short_to_char</block> - - <block>gr_int_to_float</block> - - <block>gr_float_to_char</block> - <block>gr_char_to_float</block> - <block>gr_char_to_short</block> - - <block>gr_float_to_uchar</block> - <block>gr_uchar_to_float</block> <block>gr_complex_to_interleaved_short</block> - <block>gr_interleaved_short_to_complex</block> </cat> <cat> <name>Stream Conversions</name> - <block>gr_interleave</block> - <block>gr_deinterleave</block> - - <block>gr_streams_to_stream</block> - <block>gr_stream_to_streams</block> - - <block>gr_streams_to_vector</block> - <block>gr_vector_to_streams</block> - - <block>gr_stream_to_vector</block> - <block>gr_vector_to_stream</block> - - <block>blks2_stream_to_vector_decimator</block> - - <block>gr_stream_mux</block> <block>gr_burst_tagger</block> </cat> <cat> @@ -146,9 +99,6 @@ <cat> <name>Filters</name> <!-- Other filters --> - <block>blks2_rational_resampler_xxx</block> - <block>gr_keep_one_in_n</block> - <block>gr_keep_m_in_n</block> <block>gr_moving_average_xx</block> </cat> <cat> @@ -179,7 +129,6 @@ <block>gr_throttle</block> <block>gr_delay</block> - <block>gr_repeat</block> <block>blks2_selector</block> <block>blks2_valve</block> diff --git a/grc/blocks/gr_add_const_vxx.xml b/grc/blocks/gr_add_const_vxx.xml deleted file mode 100644 index 9f1c545ab8..0000000000 --- a/grc/blocks/gr_add_const_vxx.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Add Const Block: -## all types, 1 output, 1 input & const -################################################### - --> -<block> - <name>Add Const</name> - <key>gr_add_const_vxx</key> - <import>from gnuradio import gr</import> - <make>gr.add_const_v$(type.fcn)($const)</make> - <callback>set_k($const)</callback> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>const_type:complex_vector</opt> - <opt>fcn:cc</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>const_type:real_vector</opt> - <opt>fcn:ff</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>const_type:int_vector</opt> - <opt>fcn:ii</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>const_type:int_vector</opt> - <opt>fcn:ss</opt> - </option> - </param> - <param> - <name>Constant</name> - <key>const</key> - <value>0</value> - <type>$type.const_type</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>len($const) == $vlen</check> - <check>$vlen > 0</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_add_xx.xml b/grc/blocks/gr_add_xx.xml deleted file mode 100644 index 97ed9283c2..0000000000 --- a/grc/blocks/gr_add_xx.xml +++ /dev/null @@ -1,63 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Add Block: -## all types, 1 output, 2 to inf inputs -################################################### - --> -<block> - <name>Add</name> - <key>gr_add_xx</key> - <import>from gnuradio import gr</import> - <make>gr.add_v$(type.fcn)($vlen)</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>fcn:cc</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>fcn:ff</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>fcn:ii</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>fcn:ss</opt> - </option> - </param> - <param> - <name>Num Inputs</name> - <key>num_inputs</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$num_inputs > 1</check> - <check>$vlen > 0</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_inputs</nports> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_and_const_xx.xml b/grc/blocks/gr_and_const_xx.xml deleted file mode 100644 index dc96493111..0000000000 --- a/grc/blocks/gr_and_const_xx.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -## And Const Block: -## all types, 1 output, 1 input & const -################################################### - --> -<block> - <name>And Const</name> - <key>gr_and_const_xx</key> - <import>from gnuradio import gr</import> - <make>gr.and_const_$(type.fcn)($const)</make> - <callback>set_k($const)</callback> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Int</name> - <key>int</key> - <opt>fcn:ii</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>fcn:ss</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>fcn:bb</opt> - </option> - </param> - <param> - <name>Constant</name> - <key>const</key> - <value>0</value> - <type>int</type> - </param> - <sink> - <name>in</name> - <type>$type</type> - </sink> - <source> - <name>out</name> - <type>$type</type> - </source> -</block> diff --git a/grc/blocks/gr_and_xx.xml b/grc/blocks/gr_and_xx.xml deleted file mode 100644 index 9ed0060906..0000000000 --- a/grc/blocks/gr_and_xx.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Logical And Block -################################################### - --> -<block> - <name>And</name> - <key>gr_and_xx</key> - <import>from gnuradio import gr</import> - <make>gr.and_$(type.fcn)()</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Int</name> - <key>int</key> - <opt>fcn:ii</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>fcn:ss</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>fcn:bb</opt> - </option> - </param> - <param> - <name>Num Inputs</name> - <key>num_inputs</key> - <value>2</value> - <type>int</type> - </param> - <check>$num_inputs >= 2</check> - <sink> - <name>in</name> - <type>$type</type> - <nports>$num_inputs</nports> - </sink> - <source> - <name>out</name> - <type>$type</type> - </source> -</block> diff --git a/grc/blocks/gr_char_to_float.xml b/grc/blocks/gr_char_to_float.xml deleted file mode 100644 index 838b6a203d..0000000000 --- a/grc/blocks/gr_char_to_float.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Char to Float: -################################################### - --> -<block> - <name>Char To Float</name> - <key>gr_char_to_float</key> - <import>from gnuradio import gr</import> - <make>gr.char_to_float($vlen, $scale)</make> - <callback>set_scale($scale)</callback> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Scale</name> - <key>scale</key> - <value>1</value> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>byte</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>float</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_char_to_short.xml b/grc/blocks/gr_char_to_short.xml deleted file mode 100644 index 57261e0845..0000000000 --- a/grc/blocks/gr_char_to_short.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Char to Short: -################################################### - --> -<block> - <name>Char To Short</name> - <key>gr_char_to_short</key> - <import>from gnuradio import gr</import> - <make>gr.char_to_short($vlen)</make> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <sink> - <name>in</name> - <type>byte</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>short</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_conjugate_cc.xml b/grc/blocks/gr_conjugate_cc.xml deleted file mode 100644 index 0b4deb3472..0000000000 --- a/grc/blocks/gr_conjugate_cc.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Complex Conjugate -################################################### - --> -<block> - <name>Complex Conjugate</name> - <key>gr_conjugate_cc</key> - <import>from gnuradio import gr</import> - <make>gr.conjugate_cc()</make> - <sink> - <name>in</name> - <type>complex</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/gr_deinterleave.xml b/grc/blocks/gr_deinterleave.xml deleted file mode 100644 index a7482978c0..0000000000 --- a/grc/blocks/gr_deinterleave.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Deinterleave -################################################### - --> -<block> - <name>Deinterleave</name> - <key>gr_deinterleave</key> - <import>from gnuradio import gr</import> - <make>gr.deinterleave($type.size*$vlen)</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>Num Streams</name> - <key>num_streams</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$num_streams > 0</check> - <check>$vlen >= 1</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_streams</nports> - </source> -</block> diff --git a/grc/blocks/gr_divide_xx.xml b/grc/blocks/gr_divide_xx.xml deleted file mode 100644 index 04667bc2ac..0000000000 --- a/grc/blocks/gr_divide_xx.xml +++ /dev/null @@ -1,63 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Divide Block: -## all types, 1 output, 2 to inf inputs -################################################### - --> -<block> - <name>Divide</name> - <key>gr_divide_xx</key> - <import>from gnuradio import gr</import> - <make>gr.divide_$(type.fcn)($vlen)</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>fcn:cc</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>fcn:ff</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>fcn:ii</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>fcn:ss</opt> - </option> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Num Inputs</name> - <key>num_inputs</key> - <value>2</value> - <type>int</type> - </param> - <check>$vlen > 0</check> - <check>$num_inputs >= 2</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_inputs</nports> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_float_to_char.xml b/grc/blocks/gr_float_to_char.xml deleted file mode 100644 index 1fa500e3cf..0000000000 --- a/grc/blocks/gr_float_to_char.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Float to Char: -################################################### - --> -<block> - <name>Float To Char</name> - <key>gr_float_to_char</key> - <import>from gnuradio import gr</import> - <make>gr.float_to_char($vlen, $scale)</make> - <callback>set_scale($scale)</callback> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Scale</name> - <key>scale</key> - <value>1</value> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>float</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>byte</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_float_to_complex.xml b/grc/blocks/gr_float_to_complex.xml deleted file mode 100644 index a42cff3589..0000000000 --- a/grc/blocks/gr_float_to_complex.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Float to Complex: -## one or two input streams -################################################### - --> -<block> - <name>Float To Complex</name> - <key>gr_float_to_complex</key> - <import>from gnuradio import gr</import> - <make>gr.float_to_complex($vlen)</make> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$vlen > 0</check> - <sink> - <name>re</name> - <type>float</type> - <vlen>$vlen</vlen> - </sink> - <sink> - <name>im</name> - <type>float</type> - <vlen>$vlen</vlen> - <optional>1</optional> - </sink> - <source> - <name>out</name> - <type>complex</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_float_to_int.xml b/grc/blocks/gr_float_to_int.xml deleted file mode 100644 index b43c208a5a..0000000000 --- a/grc/blocks/gr_float_to_int.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Float to Int: -################################################### - --> -<block> - <name>Float To Int</name> - <key>gr_float_to_int</key> - <import>from gnuradio import gr</import> - <make>gr.float_to_int($vlen, $scale)</make> - <callback>set_scale($scale)</callback> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Scale</name> - <key>scale</key> - <value>1</value> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>float</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>int</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_float_to_short.xml b/grc/blocks/gr_float_to_short.xml deleted file mode 100644 index 4f76b8f580..0000000000 --- a/grc/blocks/gr_float_to_short.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Float to Short: -################################################### - --> -<block> - <name>Float To Short</name> - <key>gr_float_to_short</key> - <import>from gnuradio import gr</import> - <make>gr.float_to_short($vlen, $scale)</make> - <callback>set_scale($scale)</callback> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Scale</name> - <key>scale</key> - <value>1</value> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>float</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>short</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_float_to_uchar.xml b/grc/blocks/gr_float_to_uchar.xml deleted file mode 100644 index aa804d7d93..0000000000 --- a/grc/blocks/gr_float_to_uchar.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Float to Unsigned Char: -################################################### - --> -<block> - <name>Float To UChar</name> - <key>gr_float_to_uchar</key> - <import>from gnuradio import gr</import> - <make>gr.float_to_uchar()</make> - <sink> - <name>in</name> - <type>float</type> - </sink> - <source> - <name>out</name> - <type>byte</type> - </source> -</block> diff --git a/grc/blocks/gr_int_to_float.xml b/grc/blocks/gr_int_to_float.xml deleted file mode 100644 index 7430fec728..0000000000 --- a/grc/blocks/gr_int_to_float.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Int to Float: -################################################### - --> -<block> - <name>Int To Float</name> - <key>gr_int_to_float</key> - <import>from gnuradio import gr</import> - <make>gr.int_to_float($vlen, $scale)</make> - <callback>set_scale($scale)</callback> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Scale</name> - <key>scale</key> - <value>1</value> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>int</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>float</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_integrate_xx.xml b/grc/blocks/gr_integrate_xx.xml deleted file mode 100644 index d0ebd42e2d..0000000000 --- a/grc/blocks/gr_integrate_xx.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Integrate -################################################### - --> -<block> - <name>Integrate</name> - <key>gr_integrate_xx</key> - <import>from gnuradio import gr</import> - <make>gr.integrate_$(type.fcn)($decim)</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>fcn:cc</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>fcn:ff</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>fcn:ii</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>fcn:ss</opt> - </option> - </param> - <param> - <name>Decimation</name> - <key>decim</key> - <type>int</type> - </param> - <sink> - <name>in</name> - <type>$type</type> - </sink> - <source> - <name>out</name> - <type>$type</type> - </source> -</block> diff --git a/grc/blocks/gr_interleave.xml b/grc/blocks/gr_interleave.xml deleted file mode 100644 index 3db16ab552..0000000000 --- a/grc/blocks/gr_interleave.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Interleave -################################################### - --> -<block> - <name>Interleave</name> - <key>gr_interleave</key> - <import>from gnuradio import gr</import> - <make>gr.interleave($type.size*$vlen)</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>Num Streams</name> - <key>num_streams</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$num_streams > 0</check> - <check>$vlen >= 1</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_streams</nports> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_interleaved_short_to_complex.xml b/grc/blocks/gr_interleaved_short_to_complex.xml deleted file mode 100644 index e3023e499d..0000000000 --- a/grc/blocks/gr_interleaved_short_to_complex.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Interleaved Short to Complex: -################################################### - --> -<block> - <name>IShort To Complex</name> - <key>gr_interleaved_short_to_complex</key> - <import>from gnuradio import gr</import> - <make>gr.interleaved_short_to_complex()</make> - <sink> - <name>in</name> - <type>short</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/gr_keep_m_in_n.xml b/grc/blocks/gr_keep_m_in_n.xml deleted file mode 100644 index 35a1561764..0000000000 --- a/grc/blocks/gr_keep_m_in_n.xml +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Keep M in N -################################################### - --> -<block> - <name>Keep M in N</name> - <key>gr_keep_m_in_n</key> - <import>from gnuradio import gr</import> - <make>gr.keep_m_in_n($type.size, $m, $n, $offset)</make> - <callback>set_offset($offset)</callback> - <callback>set_m($m)</callback> - <callback>set_n($n)</callback> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>M</name> - <key>m</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>N</name> - <key>n</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>initial offset</name> - <key>offset</key> - <value>0</value> - <type>int</type> - </param> - <check>$n > 0</check> - <check>$m > 0</check> - <check>$m < $n</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>1</vlen> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>1</vlen> - </source> -</block> diff --git a/grc/blocks/gr_keep_one_in_n.xml b/grc/blocks/gr_keep_one_in_n.xml deleted file mode 100644 index 21595b7559..0000000000 --- a/grc/blocks/gr_keep_one_in_n.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Keep 1 in N -################################################### - --> -<block> - <name>Keep 1 in N</name> - <key>gr_keep_one_in_n</key> - <import>from gnuradio import gr</import> - <make>gr.keep_one_in_n($type.size*$vlen, $n)</make> - <callback>set_n($n)</callback> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>N</name> - <key>n</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$n > 0</check> - <check>$vlen > 0</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_multiply_const_vxx.xml b/grc/blocks/gr_multiply_const_vxx.xml deleted file mode 100644 index 1309d75cde..0000000000 --- a/grc/blocks/gr_multiply_const_vxx.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Multiply Const Block: -## all types, 1 output, 1 input & const -################################################### - --> -<block> - <name>Multiply Const</name> - <key>gr_multiply_const_vxx</key> - <import>from gnuradio import gr</import> - <make>gr.multiply_const_v$(type.fcn)($const)</make> - <callback>set_k($const)</callback> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>const_type:complex_vector</opt> - <opt>fcn:cc</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>const_type:real_vector</opt> - <opt>fcn:ff</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>const_type:int_vector</opt> - <opt>fcn:ii</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>const_type:int_vector</opt> - <opt>fcn:ss</opt> - </option> - </param> - <param> - <name>Constant</name> - <key>const</key> - <value>0</value> - <type>$type.const_type</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>len($const) == $vlen</check> - <check>$vlen > 0</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_multiply_xx.xml b/grc/blocks/gr_multiply_xx.xml deleted file mode 100644 index 60f65c2745..0000000000 --- a/grc/blocks/gr_multiply_xx.xml +++ /dev/null @@ -1,63 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Multiply Block: -## all types, 1 output, 2 to inf inputs -################################################### - --> -<block> - <name>Multiply</name> - <key>gr_multiply_xx</key> - <import>from gnuradio import gr</import> - <make>gr.multiply_v$(type.fcn)($vlen)</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>fcn:cc</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>fcn:ff</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>fcn:ii</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>fcn:ss</opt> - </option> - </param> - <param> - <name>Num Inputs</name> - <key>num_inputs</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$num_inputs > 1</check> - <check>$vlen > 0</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_inputs</nports> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_nlog10_ff.xml b/grc/blocks/gr_nlog10_ff.xml deleted file mode 100644 index 9350782368..0000000000 --- a/grc/blocks/gr_nlog10_ff.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Log10 Block: -## float in/ float out -################################################### - --> -<block> - <name>Log10</name> - <key>gr_nlog10_ff</key> - <import>from gnuradio import gr</import> - <make>gr.nlog10_ff($n, $vlen, $k)</make> - <param> - <name>n</name> - <key>n</key> - <value>1</value> - <type>real</type> - </param> - <param> - <name>k</name> - <key>k</key> - <value>0</value> - <type>real</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$vlen >= 1</check> - <sink> - <name>in</name> - <type>float</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>float</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_not_xx.xml b/grc/blocks/gr_not_xx.xml deleted file mode 100644 index 1c2bb87096..0000000000 --- a/grc/blocks/gr_not_xx.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Logical Not Block -################################################### - --> -<block> - <name>Not</name> - <key>gr_not_xx</key> - <import>from gnuradio import gr</import> - <make>gr.not_$(type.fcn)()</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Int</name> - <key>int</key> - <opt>fcn:ii</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>fcn:ss</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>fcn:bb</opt> - </option> - </param> - <sink> - <name>in</name> - <type>$type</type> - </sink> - <source> - <name>out</name> - <type>$type</type> - </source> -</block> diff --git a/grc/blocks/gr_or_xx.xml b/grc/blocks/gr_or_xx.xml deleted file mode 100644 index b374aa22ab..0000000000 --- a/grc/blocks/gr_or_xx.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Logical Or Block -################################################### - --> -<block> - <name>Or</name> - <key>gr_or_xx</key> - <import>from gnuradio import gr</import> - <make>gr.or_$(type.fcn)()</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Int</name> - <key>int</key> - <opt>fcn:ii</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>fcn:ss</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>fcn:bb</opt> - </option> - </param> - <param> - <name>Num Inputs</name> - <key>num_inputs</key> - <value>2</value> - <type>int</type> - </param> - <check>$num_inputs >= 2</check> - <sink> - <name>in</name> - <type>$type</type> - <nports>$num_inputs</nports> - </sink> - <source> - <name>out</name> - <type>$type</type> - </source> -</block> diff --git a/grc/blocks/gr_repeat.xml b/grc/blocks/gr_repeat.xml deleted file mode 100644 index ba652a4d79..0000000000 --- a/grc/blocks/gr_repeat.xml +++ /dev/null @@ -1,64 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Repeat -################################################### - --> -<block> - <name>Repeat</name> - <key>gr_repeat</key> - <import>from gnuradio import gr</import> - <make>gr.repeat($type.size*$vlen, $interp)</make> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>Interpolation</name> - <key>interp</key> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$vlen > 0</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_short_to_char.xml b/grc/blocks/gr_short_to_char.xml deleted file mode 100644 index 9c41da84ef..0000000000 --- a/grc/blocks/gr_short_to_char.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Short to char: -################################################### - --> -<block> - <name>Short To Char</name> - <key>gr_short_to_char</key> - <import>from gnuradio import gr</import> - <make>gr.short_to_char($vlen)</make> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <sink> - <name>in</name> - <type>short</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>byte</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_short_to_float.xml b/grc/blocks/gr_short_to_float.xml deleted file mode 100644 index 529f8c78cb..0000000000 --- a/grc/blocks/gr_short_to_float.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Short to Float: -################################################### - --> -<block> - <name>Short To Float</name> - <key>gr_short_to_float</key> - <import>from gnuradio import gr</import> - <make>gr.short_to_float($vlen, $scale)</make> - <callback>set_scale($scale)</callback> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Scale</name> - <key>scale</key> - <value>1</value> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>short</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>float</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_stream_mux.xml b/grc/blocks/gr_stream_mux.xml deleted file mode 100644 index 8efe7b6555..0000000000 --- a/grc/blocks/gr_stream_mux.xml +++ /dev/null @@ -1,75 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Stream Mux: -## all types, many inputs, only one output -################################################### - --> -<block> - <name>Stream Mux</name> - <key>gr_stream_mux</key> - <import>from gnuradio import gr</import> - <make>gr.stream_mux($type.size*$vlen, $lengths)</make> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>Lengths</name> - <key>lengths</key> - <value>1, 1</value> - <type>int_vector</type> - </param> - <param> - <name>Num Inputs</name> - <key>num_inputs</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$num_inputs > 0</check> - <check>$num_inputs == len($lengths)</check> - <check>$vlen > 0</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_inputs</nports> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_stream_to_streams.xml b/grc/blocks/gr_stream_to_streams.xml deleted file mode 100644 index 82542b8d44..0000000000 --- a/grc/blocks/gr_stream_to_streams.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Stream to Streams -################################################### - --> -<block> - <name>Stream to Streams</name> - <key>gr_stream_to_streams</key> - <import>from gnuradio import gr</import> - <make>gr.stream_to_streams($type.size*$vlen, $num_streams)</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>Num Streams</name> - <key>num_streams</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$num_streams > 0</check> - <check>$vlen >= 1</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_streams</nports> - </source> -</block> diff --git a/grc/blocks/gr_stream_to_vector.xml b/grc/blocks/gr_stream_to_vector.xml deleted file mode 100644 index 296d786f8c..0000000000 --- a/grc/blocks/gr_stream_to_vector.xml +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Stream to Vector -################################################### - --> -<block> - <name>Stream to Vector</name> - <key>gr_stream_to_vector</key> - <import>from gnuradio import gr</import> - <make>gr.stream_to_vector($type.size*$vlen, $num_items)</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>Num Items</name> - <key>num_items</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$num_items > 0</check> - <check>$vlen >= 1</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen*$num_items</vlen> - </source> -</block> diff --git a/grc/blocks/gr_streams_to_stream.xml b/grc/blocks/gr_streams_to_stream.xml deleted file mode 100644 index 7aadd7eef2..0000000000 --- a/grc/blocks/gr_streams_to_stream.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Streams to Stream -################################################### - --> -<block> - <name>Streams to Stream</name> - <key>gr_streams_to_stream</key> - <import>from gnuradio import gr</import> - <make>gr.streams_to_stream($type.size*$vlen, $num_streams)</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>Num Streams</name> - <key>num_streams</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$num_streams > 0</check> - <check>$vlen >= 1</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_streams</nports> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_streams_to_vector.xml b/grc/blocks/gr_streams_to_vector.xml deleted file mode 100644 index 4ecdcb2d41..0000000000 --- a/grc/blocks/gr_streams_to_vector.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Streams to Vector -################################################### - --> -<block> - <name>Streams to Vector</name> - <key>gr_streams_to_vector</key> - <import>from gnuradio import gr</import> - <make>gr.streams_to_vector($type.size*$vlen, $num_streams)</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>Num Streams</name> - <key>num_streams</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$num_streams > 0</check> - <check>$vlen >= 1</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_streams</nports> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen*$num_streams</vlen> - </source> -</block> diff --git a/grc/blocks/gr_sub_xx.xml b/grc/blocks/gr_sub_xx.xml deleted file mode 100644 index c677747da9..0000000000 --- a/grc/blocks/gr_sub_xx.xml +++ /dev/null @@ -1,63 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Subtract Block: -## all types, 1 output, 2 to inf inputs -################################################### - --> -<block> - <name>Subtract</name> - <key>gr_sub_xx</key> - <import>from gnuradio import gr</import> - <make>gr.sub_$(type.fcn)($vlen)</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>fcn:cc</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>fcn:ff</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>fcn:ii</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>fcn:ss</opt> - </option> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Num Inputs</name> - <key>num_inputs</key> - <value>2</value> - <type>int</type> - </param> - <check>$vlen > 0</check> - <check>$num_inputs >= 1</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_inputs</nports> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_uchar_to_float.xml b/grc/blocks/gr_uchar_to_float.xml deleted file mode 100644 index 0a5f7f96a5..0000000000 --- a/grc/blocks/gr_uchar_to_float.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Unsigned Char to Float: -################################################### - --> -<block> - <name>UChar To Float</name> - <key>gr_uchar_to_float</key> - <import>from gnuradio import gr</import> - <make>gr.uchar_to_float()</make> - <sink> - <name>in</name> - <type>byte</type> - </sink> - <source> - <name>out</name> - <type>float</type> - </source> -</block> diff --git a/grc/blocks/gr_vector_to_stream.xml b/grc/blocks/gr_vector_to_stream.xml deleted file mode 100644 index d56d340677..0000000000 --- a/grc/blocks/gr_vector_to_stream.xml +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Vector to Stream -################################################### - --> -<block> - <name>Vector to Stream</name> - <key>gr_vector_to_stream</key> - <import>from gnuradio import gr</import> - <make>gr.vector_to_stream($type.size*$vlen, $num_items)</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>Num Items</name> - <key>num_items</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$num_items > 0</check> - <check>$vlen >= 1</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen*$num_items</vlen> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/blocks/gr_vector_to_streams.xml b/grc/blocks/gr_vector_to_streams.xml deleted file mode 100644 index 86cb56813c..0000000000 --- a/grc/blocks/gr_vector_to_streams.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Vector to Streams -################################################### - --> -<block> - <name>Vector to Streams</name> - <key>gr_vector_to_streams</key> - <import>from gnuradio import gr</import> - <make>gr.vector_to_streams($type.size*$vlen, $num_streams)</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>Num Streams</name> - <key>num_streams</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$num_streams > 0</check> - <check>$vlen >= 1</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen*$num_streams</vlen> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_streams</nports> - </source> -</block> diff --git a/grc/blocks/gr_xor_xx.xml b/grc/blocks/gr_xor_xx.xml deleted file mode 100644 index c014cbe577..0000000000 --- a/grc/blocks/gr_xor_xx.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Logical Xor Block -################################################### - --> -<block> - <name>Xor</name> - <key>gr_xor_xx</key> - <import>from gnuradio import gr</import> - <make>gr.xor_$(type.fcn)()</make> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Int</name> - <key>int</key> - <opt>fcn:ii</opt> - </option> - <option> - <name>Shxort</name> - <key>short</key> - <opt>fcn:ss</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>fcn:bb</opt> - </option> - </param> - <param> - <name>Num Inputs</name> - <key>num_inputs</key> - <value>2</value> - <type>int</type> - </param> - <check>$num_inputs >= 2</check> - <sink> - <name>in</name> - <type>$type</type> - <nports>$num_inputs</nports> - </sink> - <source> - <name>out</name> - <type>$type</type> - </source> -</block> diff --git a/grc/grc_gnuradio/blks2/error_rate.py b/grc/grc_gnuradio/blks2/error_rate.py index eb8d12d4e3..7f53f7af65 100644 --- a/grc/grc_gnuradio/blks2/error_rate.py +++ b/grc/grc_gnuradio/blks2/error_rate.py @@ -21,6 +21,7 @@ default_win_size = 1000 from gnuradio import gr +from gnuradio import blocks import gnuradio.gr.gr_threading as _threading import numpy @@ -82,7 +83,7 @@ class error_rate(gr.hier_block2): self._msgq_source = msg_source.msgq() msgq_sink = gr.msg_queue(2) msg_sink = gr.message_sink(gr.sizeof_char, msgq_sink, False) #False -> blocking - inter = gr.interleave(gr.sizeof_char) + inter = blocks.interleave(gr.sizeof_char) #start thread self._num_errs = 0 self._err_index = 0 diff --git a/gruel/CMakeLists.txt b/gruel/CMakeLists.txt index 627135abe9..3e8c5166e5 100644 --- a/gruel/CMakeLists.txt +++ b/gruel/CMakeLists.txt @@ -37,6 +37,7 @@ include(GrMiscUtils) GR_SET_GLOBAL(GRUEL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/include ${CMAKE_CURRENT_BINARY_DIR}/src/include + ${Boost_INCLUDE_DIRS} ) ######################################################################## diff --git a/gruel/src/include/gruel/pmt.h b/gruel/src/include/gruel/pmt.h index 1a6cd0ec50..b4c51ab927 100644 --- a/gruel/src/include/gruel/pmt.h +++ b/gruel/src/include/gruel/pmt.h @@ -229,6 +229,12 @@ GRUEL_API pmt_t from_complex(double re, double im); //! Return a complex number constructed of the given a complex number. GRUEL_API pmt_t from_complex(const std::complex<double> &z); +//! Return a complex number constructed of the given real and imaginary parts. +GRUEL_API pmt_t pmt_from_complex(double re, double im); + +//! Return a complex number constructed of the given a complex number. +GRUEL_API pmt_t pmt_from_complex(const std::complex<double> &z); + /*! * If \p z is complex, real or integer, return the closest complex<double>. * Otherwise, raise the wrong_type exception. @@ -500,6 +506,20 @@ GRUEL_API const std::vector<double> f64vector_elements(pmt_t v); GRUEL_API const std::vector<std::complex<float> > c32vector_elements(pmt_t v); GRUEL_API const std::vector<std::complex<double> > c64vector_elements(pmt_t v); +// len is in elements +GRUEL_API const std::vector<uint8_t> pmt_u8vector_elements(pmt_t v); +GRUEL_API const std::vector<int8_t> pmt_s8vector_elements(pmt_t v); +GRUEL_API const std::vector<uint16_t> pmt_u16vector_elements(pmt_t v); +GRUEL_API const std::vector<int16_t> pmt_s16vector_elements(pmt_t v); +GRUEL_API const std::vector<uint32_t> pmt_u32vector_elements(pmt_t v); +GRUEL_API const std::vector<int32_t> pmt_s32vector_elements(pmt_t v); +GRUEL_API const std::vector<uint64_t> pmt_u64vector_elements(pmt_t v); +GRUEL_API const std::vector<int64_t> pmt_s64vector_elements(pmt_t v); +GRUEL_API const std::vector<float> pmt_f32vector_elements(pmt_t v); +GRUEL_API const std::vector<double> pmt_f64vector_elements(pmt_t v); +GRUEL_API const std::vector<std::complex<float> > pmt_c32vector_elements(pmt_t v); +GRUEL_API const std::vector<std::complex<double> > pmt_c64vector_elements(pmt_t v); + // Return non-const pointers to the elements GRUEL_API void *uniform_vector_writable_elements(pmt_t v, size_t &len); //< works with any; len is in bytes diff --git a/gruel/src/lib/pmt/pmt.cc b/gruel/src/lib/pmt/pmt.cc index bb1866d562..8ea0e76143 100644 --- a/gruel/src/lib/pmt/pmt.cc +++ b/gruel/src/lib/pmt/pmt.cc @@ -394,6 +394,11 @@ make_rectangular(double re, double im) pmt_t from_complex(double re, double im) { + return pmt_from_complex(re, im); +} + +pmt_t pmt_from_complex(double re, double im) +{ return pmt_t(new pmt_complex(std::complex<double>(re, im))); } |