diff options
57 files changed, 0 insertions, 11856 deletions
diff --git a/gr-error-correcting-codes/AUTHORS b/gr-error-correcting-codes/AUTHORS deleted file mode 100644 index bb4f6a68a..000000000 --- a/gr-error-correcting-codes/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Michael Dickens <mdickens@nd.edu> diff --git a/gr-error-correcting-codes/ChangeLog b/gr-error-correcting-codes/ChangeLog deleted file mode 100644 index f176d1325..000000000 --- a/gr-error-correcting-codes/ChangeLog +++ /dev/null @@ -1,31 +0,0 @@ -2006-07-09 Eric Blossom <eb@comsec.com> - - * src/lib/gr_streams_encode_convolutional.{h,cc,i}: fixes to - access second constructor via SWIG. - - * src/lib/libecc/code_metrics.cc: added missing include. - -2006-07-03 Michael Dickens <mdickens@nd.edu> - - * In development. - -# -# 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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# diff --git a/gr-error-correcting-codes/Makefile.am b/gr-error-correcting-codes/Makefile.am deleted file mode 100644 index 1745dea9f..000000000 --- a/gr-error-correcting-codes/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -# -# 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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = src - -MOSTLYCLEANFILES = *~ diff --git a/gr-error-correcting-codes/examples/qa_test_coding_1.py b/gr-error-correcting-codes/examples/qa_test_coding_1.py deleted file mode 100755 index d78a0358a..000000000 --- a/gr-error-correcting-codes/examples/qa_test_coding_1.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python -# -# 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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, audio -from gnuradio.eng_option import eng_option -from optparse import OptionParser -# must be imported from local directory so that make check -# can run before installation -import ecc - -class my_graph(gr.flow_graph): - - def __init__(self): - gr.flow_graph.__init__(self) - - parser = OptionParser(option_class=eng_option) - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm output device name. E.g., hw:0,0 or /dev/dsp") - parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, - help="set sample rate to RATE (48000)") - (options, args) = parser.parse_args () - if len(args) != 0: - parser.print_help() - raise SystemExit, 1 - - sample_rate = int(options.sample_rate) - audio_option = options.audio_output - src = audio.source (sample_rate, audio_option) - src_out_chan = src.output_signature().max_streams() - dst = audio.sink (sample_rate, str(src_out_chan)) - dst_in_chan = dst.input_signature().max_streams() - audio_el_size = src.output_signature().sizeof_stream_item(1) - frame_size = 1000 - do_mux_outputs = 0 - enc_code_in_chan = src_out_chan - code_generators = [05, 06] #, 03, 04] # , 0, 07] - enc_code_out_chan = len (code_generators) / enc_code_in_chan - do_termination = 1 - - if do_mux_outputs == 1: - enc_dec_chan = 1 - else: - enc_dec_chan = enc_code_out_chan - - ss_enc = ecc.streams_encode_convolutional (frame_size, - enc_code_in_chan, - enc_code_out_chan, - code_generators, - do_termination) -# for now - ss2s = gr.streams_to_stream (1, enc_dec_chan); - ns = gr.null_sink (1); -# end for now - -# ss_dec = error-correcting-codes.frames_to_streams (audio_el_size, 1, 1000) - - for i in range (src_out_chan): - self.connect ((src, i), (ss_enc, i)) -# for now - for i in range (enc_dec_chan): - self.connect ((ss_enc, i), (ss2s, i)) - self.connect (ss2s, ns) -# end for now - -# for i in range (enc_dec_chan): -# self.connect ((ss_enc, i), (ss_dec, i)) - -# for i in range (dst_in_chan): -# self.connect ((ss_dec, i), (dst, i)) - -if __name__ == '__main__': - try: - my_graph().run() - except KeyboardInterrupt: - pass diff --git a/gr-error-correcting-codes/examples/qa_test_coding_2.py b/gr-error-correcting-codes/examples/qa_test_coding_2.py deleted file mode 100755 index d0019be17..000000000 --- a/gr-error-correcting-codes/examples/qa_test_coding_2.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env python -# -# 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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, audio -from gnuradio.eng_option import eng_option -from optparse import OptionParser -# must be imported from local directory so that make check -# can run before installation -import ecc - -class my_graph(gr.flow_graph): - - def __init__(self): - gr.flow_graph.__init__(self) - - parser = OptionParser(option_class=eng_option) - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm output device name. E.g., hw:0,0 or /dev/dsp") - parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, - help="set sample rate to RATE (48000)") - (options, args) = parser.parse_args () - if len(args) != 0: - parser.print_help() - raise SystemExit, 1 - - sample_rate = int(options.sample_rate) - audio_option = options.audio_output - src = audio.source (sample_rate, audio_option) - enc_chan_in = 2 - src_out_chan = src.output_signature().max_streams() - dst = audio.sink (sample_rate, str(enc_chan_in)) - dst_in_chan = dst.input_signature().max_streams() - audio_el_size = dst.input_signature().sizeof_stream_item(0) - frame_size = 10 - enc_code_in_chan = enc_chan_in - code_generators = [05, 06] #, 03, 04] #, 0, 07] - enc_code_out_chan = len (code_generators) / enc_code_in_chan - do_termination = 1 - - ss_enc = ecc.streams_encode_convolutional (frame_size, - enc_code_in_chan, - enc_code_out_chan, - code_generators, - do_termination) - - for i in range (src_out_chan): - p2up = gr.packed_to_unpacked_bb (1, 1) - self.connect ((src, i), p2up, (ss_enc, i)) - - tau_bits = 0 # 0 -> decode all first - ss_dec = error-correcting-codes.dec_blk_conv_soft_full (audio_el_size, - frame_size, - do_termination, - do_mux_outputs, - enc_code_in_chan, - enc_code_out_chan, - code_generators) - up2bf0 = gr.chunks_to_symbols_bf ([1.0, -1.0]) - self.connect ((ss_enc, 0), p2up0, up2bf0, (ss_dec, 0)) - if enc_dec_chan > 1: - p2up1 = gr.packed_to_unpacked_bb (1, 1) - up2bf1 = gr.chunks_to_symbols_bf ([1.0, -1.0]) - self.connect ((ss_enc, 1), p2up1, up2bf1, (ss_dec, 1)) - - for i in range (dst_in_chan): - self.connect ((ss_dec, i), (dst, i)) - -if __name__ == '__main__': - try: - my_graph().run() - except KeyboardInterrupt: - pass diff --git a/gr-error-correcting-codes/examples/qa_test_encoder_convolutional_1.py b/gr-error-correcting-codes/examples/qa_test_encoder_convolutional_1.py deleted file mode 100755 index 6d4bf2f6c..000000000 --- a/gr-error-correcting-codes/examples/qa_test_encoder_convolutional_1.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python -# -# 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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, audio -from gnuradio.eng_option import eng_option -from optparse import OptionParser -# must be imported from local directory so that make check -# can run before installation -import ecc - -class my_graph(gr.flow_graph): - - def __init__(self): - gr.flow_graph.__init__(self) - - parser = OptionParser(option_class=eng_option) - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm output device name. E.g., hw:0,0 or /dev/dsp") - parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, - help="set sample rate to RATE (48000)") - (options, args) = parser.parse_args () - if len(args) != 0: - parser.print_help() - raise SystemExit, 1 - - sample_rate = int(options.sample_rate) - audio_option = options.audio_output - src = audio.source (sample_rate, audio_option) - src_out_chan = src.output_signature().max_streams() - dst = audio.sink (sample_rate, str(src_out_chan)) - dst_in_chan = dst.input_signature().max_streams() - audio_el_size = src.output_signature().sizeof_stream_item(1) - frame_size = 10 - enc_code_in_chan = src_out_chan - code_generators = [05, 06] #, 03, 04] # , 0, 07] - enc_code_out_chan = len (code_generators) / enc_code_in_chan - do_termination = 1 - - ss_enc = ecc.streams_encode_convolutional (frame_size, - enc_code_in_chan, - enc_code_out_chan, - code_generators, - do_termination) - for i in range (enc_code_in_chan): - self.connect ((src, i), (ss_enc, i)) - - for i in range (enc_code_out_chan): - ns = gr.null_sink (1) - self.connect ((ss_enc, i), ns) - -if __name__ == '__main__': - try: - my_graph().run() - except KeyboardInterrupt: - pass diff --git a/gr-error-correcting-codes/examples/qa_test_encoder_convolutional_2.py b/gr-error-correcting-codes/examples/qa_test_encoder_convolutional_2.py deleted file mode 100755 index 125933e7d..000000000 --- a/gr-error-correcting-codes/examples/qa_test_encoder_convolutional_2.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python -# -# 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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr -from gnuradio.eng_option import eng_option -import ecc - -def main (): - e1 = ecc.streams_encode_convolutional (100, 3, 2, [1, 0, 5, 0, 1, 6]) - - e2 = ecc.streams_encode_convolutional (100, 2, 3, [1, 0, 0, 1, 5, 6]) - - e3 = ecc.streams_encode_convolutional_feedback (100, 2, 3, [1, 7, 0, 1, 5, 6], [1, 1, 1, 1, 017, 017]) - -if __name__ == '__main__': - main () diff --git a/gr-error-correcting-codes/src/Makefile.am b/gr-error-correcting-codes/src/Makefile.am deleted file mode 100644 index ce1b3a3b2..000000000 --- a/gr-error-correcting-codes/src/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -# -# 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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -SUBDIRS = lib python - -MOSTLYCLEANFILES = *~ - diff --git a/gr-error-correcting-codes/src/lib/Makefile.am b/gr-error-correcting-codes/src/lib/Makefile.am deleted file mode 100644 index 679d882cd..000000000 --- a/gr-error-correcting-codes/src/lib/Makefile.am +++ /dev/null @@ -1,100 +0,0 @@ -# -# 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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = libecc - -# Install this stuff so that it ends up as the gnuradio.und module -# This usually ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio - -ourpythondir = $(grpythondir) -ourlibdir = $(grpythondir) - -INCLUDES = $(PYTHON_CPPFLAGS) $(STD_DEFINES_AND_INCLUDES) - -SWIGCPPPYTHONARGS = -fvirtual -python -modern $(PYTHON_CPPFLAGS) \ - $(STD_DEFINES_AND_INCLUDES) - -NON_LOCAL_IFILES = $(GNURADIO_I) - -LOCAL_IFILES = \ - $(top_srcdir)/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.i \ - $(top_srcdir)/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.i \ - $(top_srcdir)/gr-error-correcting-codes/src/lib/ecc_streams_encode_convolutional.i \ - $(top_srcdir)/gr-error-correcting-codes/src/lib/ecc_streams_encode_turbo.i \ - $(top_srcdir)/gr-error-correcting-codes/src/lib/ecc.i - -# These files are built by SWIG. The first is the C++ glue. -# The second is the python wrapper that loads the _howto shared library -# and knows how to call our extensions. - -ALL_IFILES = $(LOCAL_IFILES) $(NON_LOCAL_IFILES) - -BUILT_SOURCES = \ - ecc.cc \ - ecc.py - -# This gets ecc.py installed in the right place -ourpython_PYTHON = \ - __init__.py \ - ecc.py - -ourlib_LTLIBRARIES = _ecc.la - -# These are the source files that go into the shared library -_ecc_la_SOURCES = \ - ecc_syms_to_metrics.cc \ - ecc_metrics_decode_viterbi_full_block.cc \ - ecc_streams_encode_convolutional.cc \ - ecc_streams_encode_turbo.cc \ - ecc.cc - -# magic flags -_ecc_la_LDFLAGS = $(NO_UNDEFINED) -module -avoid-version - -# link the library against the c++ standard library -_ecc_la_LIBADD = \ - libecc/libecc.la \ - $(PYTHON_LDFLAGS) \ - $(GNURADIO_CORE_LIBS) \ - -lstdc++ - -# These headers get installed in ${prefix}/include/gnuradio -grinclude_HEADERS = \ - ecc_syms_to_metrics.h \ - ecc_metrics_decode_viterbi_full_block.h \ - ecc_streams_encode_convolutional.h \ - ecc_streams_encode_turbo.h - -# These swig headers get installed in ${prefix}/include/gnuradio/swig -swiginclude_HEADERS = $(LOCAL_IFILES) - -ecc.cc ecc.py: $(top_srcdir)/gr-error-correcting-codes/src/lib/ecc.i $(ALL_IFILES) - $(SWIG) $(SWIGCPPPYTHONARGS) -module ecc -o ecc.cc $(top_srcdir)/gr-error-correcting-codes/src/lib/ecc.i - -# Don't distribute output of swig -dist-hook: - @for file in $(BUILT_SOURCES); do echo $(RM) $(distdir)/$$file; done - @for file in $(BUILT_SOURCES); do $(RM) $(distdir)/$$file; done - -MOSTLYCLEANFILES = $(BUILT_SOURCES) *.pyc *.loT *~ diff --git a/gr-error-correcting-codes/src/lib/__init__.py b/gr-error-correcting-codes/src/lib/__init__.py deleted file mode 100644 index bc9a14c0e..000000000 --- a/gr-error-correcting-codes/src/lib/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -# 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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# diff --git a/gr-error-correcting-codes/src/lib/ecc.i b/gr-error-correcting-codes/src/lib/ecc.i deleted file mode 100644 index 067f52875..000000000 --- a/gr-error-correcting-codes/src/lib/ecc.i +++ /dev/null @@ -1,41 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%feature("autodoc","1"); -%include "exception.i" -%import "gnuradio.i" - -%{ - -#include "gnuradio_swig_bug_workaround.h" // mandatory bug fix -#include <ecc_streams_encode_convolutional.h> -#include <ecc_streams_encode_turbo.h> -#include <ecc_metrics_decode_viterbi_full_block.h> -#include <ecc_syms_to_metrics.h> -#include <stdexcept> - -%} - -%include "ecc_streams_encode_convolutional.i" -%include "ecc_streams_encode_turbo.i" -%include "ecc_metrics_decode_viterbi_full_block.i" -%include "ecc_syms_to_metrics.i" diff --git a/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.cc b/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.cc deleted file mode 100644 index 78489a8d7..000000000 --- a/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.cc +++ /dev/null @@ -1,245 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <ecc_metrics_decode_viterbi_full_block.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <iostream> - -ecc_metrics_decode_viterbi_full_block_sptr -ecc_make_metrics_decode_viterbi_full_block -(int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generator, - bool do_termination, - int start_memory_state, - int end_memory_state) -{ - return ecc_metrics_decode_viterbi_full_block_sptr - (new ecc_metrics_decode_viterbi_full_block - (sample_precision, - frame_size_bits, - n_code_inputs, - n_code_outputs, - code_generator, - do_termination, - start_memory_state, - end_memory_state)); -} - -ecc_metrics_decode_viterbi_full_block_feedback_sptr -ecc_make_metrics_decode_viterbi_full_block_feedback -(int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generator, - const std::vector<int>& code_feedback, - bool do_termination, - int start_memory_state, - int end_memory_state) -{ - return ecc_metrics_decode_viterbi_full_block_feedback_sptr - (new ecc_metrics_decode_viterbi_full_block - (sample_precision, - frame_size_bits, - n_code_inputs, - n_code_outputs, - code_generator, - code_feedback, - do_termination, - start_memory_state, - end_memory_state)); -} - -ecc_metrics_decode_viterbi_full_block::ecc_metrics_decode_viterbi_full_block -(int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generator, - bool do_termination, - int start_memory_state, - int end_memory_state) - : gr_block ("metrics_decode_viterbi_full_block", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (0, 0, 0)) -{ - d_encoder = new encoder_convolutional (frame_size_bits, - n_code_inputs, - n_code_outputs, - code_generator, - do_termination, - start_memory_state, - end_memory_state); - - setup_io_signatures (sample_precision, n_code_inputs, n_code_outputs); -} - -ecc_metrics_decode_viterbi_full_block::ecc_metrics_decode_viterbi_full_block -(int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generator, - const std::vector<int>& code_feedback, - bool do_termination, - int start_memory_state, - int end_memory_state) - : gr_block ("metrics_decode_viterbi_full_block_feedback", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (0, 0, 0)) -{ - d_encoder = new encoder_convolutional (frame_size_bits, - n_code_inputs, - n_code_outputs, - code_generator, - code_feedback, - do_termination, - start_memory_state, - end_memory_state); - - setup_io_signatures (sample_precision, n_code_inputs, n_code_outputs); -} - -ecc_metrics_decode_viterbi_full_block::~ecc_metrics_decode_viterbi_full_block -() -{ - delete d_decoder; - d_decoder = 0; - delete d_encoder; - d_encoder = 0; - delete d_in_buf; - d_in_buf = 0; - delete d_out_buf; - d_out_buf = 0; -} - -void -ecc_metrics_decode_viterbi_full_block::setup_io_signatures -(int sample_precision, - int n_code_inputs, - int n_code_outputs) -{ - // create the decoder - // - // the input model: individual input streams; two per metric type - // (0-bit, 1-bit), single metric per input item (float, char, short, - // long) - // - // the "ic1l" output model: - // individual output streams per decoded code input stream; - // each item is a 'char' type with 1 bit aligned on the LSB. - - d_decoder = new decoder_viterbi_full_block (sample_precision, - d_encoder); - d_out_buf = new code_output_ic1l (n_code_inputs); - - // error checking is done in the encoder and decoder classes - // so just use the parameters as given; will be correct! - - d_n_code_inputs = n_code_inputs; - d_n_code_outputs = n_code_outputs; - - // output signature is always the same: - // sizeof (char) with 1 bit per char as the LSB - - set_output_signature (gr_make_io_signature (d_n_code_inputs, - d_n_code_inputs, - sizeof (char))); - - // determine the input signature element size - size_t l_input_item_size_bytes; - - if (sample_precision == 0) { - // float - l_input_item_size_bytes = sizeof (float); - d_in_buf = new code_input_if (n_code_outputs); - } else if (sample_precision <= 8) { - // use char - l_input_item_size_bytes = sizeof (char); - d_in_buf = new code_input_ic (n_code_outputs); - } else if (sample_precision <= 16) { - // use short - l_input_item_size_bytes = sizeof (short); - d_in_buf = new code_input_is (n_code_outputs); - } else { - // use long - l_input_item_size_bytes = sizeof (long); - d_in_buf = new code_input_il (n_code_outputs); - } - - set_input_signature (gr_make_io_signature (2*d_n_code_outputs, - 2*d_n_code_outputs, - l_input_item_size_bytes)); -} - -void ecc_metrics_decode_viterbi_full_block::forecast -(int noutput_items, - gr_vector_int &ninput_items_required) -{ - int ninput_items = d_decoder->compute_n_input_items (noutput_items); - size_t ninputs = ninput_items_required.size(); - for (size_t n = 0; n < ninputs; n++) - ninput_items_required[n] = ninput_items; -} - -int -ecc_metrics_decode_viterbi_full_block::general_work -(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - // compute the actual number of output items (1 bit char's) created. - - size_t t_n_input_items = d_decoder->compute_n_input_items (noutput_items); -#if 1 - size_t t_n_output_items = d_decoder->compute_n_output_bits (t_n_input_items); - assert (t_n_output_items == ((size_t)noutput_items)); -#endif - - // setup the i/o buffers - - d_in_buf->set_buffer ((void**)(&input_items[0]), t_n_input_items); - d_out_buf->set_buffer ((void**)(&output_items[0]), noutput_items); - - // "work" is handled by the decoder; which returns the actual number - // of input items (metrics) used. - - t_n_input_items = d_decoder->decode (d_in_buf, d_out_buf, - (size_t) noutput_items); - - // consume the number of used input items on all input streams - - consume_each (t_n_input_items); - - // returns number of items written to each output stream - - return (noutput_items); -} diff --git a/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.h b/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.h deleted file mode 100644 index b127bdf5f..000000000 --- a/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.h +++ /dev/null @@ -1,167 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_ECC_METRICS_DECODE_VITERBI_FULL_BLOCK_H -#define INCLUDED_ECC_METRICS_DECODE_VITERBI_FULL_BLOCK_H - -#include <gr_block.h> -#include <libecc/decoder_viterbi_full_block.h> -#include <libecc/encoder_convolutional.h> - -class ecc_metrics_decode_viterbi_full_block; - -typedef boost::shared_ptr<ecc_metrics_decode_viterbi_full_block> -ecc_metrics_decode_viterbi_full_block_sptr, -ecc_metrics_decode_viterbi_full_block_feedback_sptr; - -ecc_metrics_decode_viterbi_full_block_sptr -ecc_make_metrics_decode_viterbi_full_block -(int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generator, - bool do_termination = true, - int start_memory_state = 0, - int end_memory_state = 0); - -ecc_metrics_decode_viterbi_full_block_feedback_sptr -ecc_make_metrics_decode_viterbi_full_block_feedback -(int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generator, - const std::vector<int>& code_feedback, - bool do_termination = true, - int start_memory_state = 0, - int end_memory_state = 0); - -/*! - * \brief Decode the incoming streams using a Viterbi-style decoder, - * full trellis block decoding. - * - * input: symbol metrics data. - * - * output: stream(s) of char, single bit stored in the LSB. - */ - -class ecc_metrics_decode_viterbi_full_block : public gr_block -{ -protected: - friend ecc_metrics_decode_viterbi_full_block_sptr - ecc_make_metrics_decode_viterbi_full_block - (int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generator, - bool do_termination, - int start_memory_state, - int end_memory_state); - - friend ecc_metrics_decode_viterbi_full_block_feedback_sptr - ecc_make_metrics_decode_viterbi_full_block_feedback - (int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generator, - const std::vector<int>& code_feedback, - bool do_termination, - int start_memory_state, - int end_memory_state); -/* - * frame_size_bits: if == 0, then do streaming decoding (infinite - * trellis); otherwise this is the block size to decode before - * terminating the trellis. - * - * code_generator: vector of integers (32 bit) representing the code - * to be implemented in octal form. E.g. "04" in binary is "100", - * which would be "D^2" for code generation. "06" == 110b == "D^2 + D" - * ==> The vector is listed in order for each input stream, so if there - * are 2 input streams (I1, I2) [specified in "n_code_inputs"] - * and 2 output streams (O1, O2) [specified in "n_code_outputs"], - * then the vector would be the code generator for: - * [I1->O1, I1->O2, I2->O1, I2->O2] - * with each element being the octal representation of the code. - * - * do_termination is valid only if frame_size_bits != 0, and defines - * whether or not to to trellis termination. - * - * do_mux_input: is true, then the one input stream will be - * interpreted as the multiplexing all of the input bits. For - * example for a 3 input decoder, the input stream would be - * [I1[k], I2[k], I3[k], I1[k+1], I2[k+1], ...], where "k" is the - * input sample time, and "I1" through "I3" are the 3 input - * streams. - * - * n_code_inputs: the number of decoder-input (encoder-output) - * streams, no matter if separate or mux'ed - * - * n_code_outputs: the number of decoder-output (encoder-input) streams - */ - - ecc_metrics_decode_viterbi_full_block - (int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generator, - bool do_termination, - int start_memory_state, - int end_memory_state); - - ecc_metrics_decode_viterbi_full_block - (int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generator, - const std::vector<int>& code_feedback, - bool do_termination, - int start_memory_state, - int end_memory_state); - - void setup_io_signatures (int sample_precision, - int n_code_inputs, - int n_code_outputs); - - int d_n_code_inputs, d_n_code_outputs; - decoder_viterbi_full_block* d_decoder; - encoder_convolutional* d_encoder; - code_input_ptr d_in_buf; - code_output_ptr d_out_buf; - -public: - ~ecc_metrics_decode_viterbi_full_block (); - - virtual void forecast (int noutput_items, - gr_vector_int& ninput_items_required); - - virtual 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 /* INCLUDED_ECC_METRICS_DECODE_VITERBI_FULL_BLOCK_H */ diff --git a/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.i b/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.i deleted file mode 100644 index a609fd48d..000000000 --- a/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.i +++ /dev/null @@ -1,77 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(ecc,metrics_decode_viterbi_full_block); - -// corrected "class NAME" statement, which uses slightly different NAMEs - -typedef boost::shared_ptr<ecc_metrics_decode_viterbi_full_block> -ecc_metrics_decode_viterbi_full_block_feedback_sptr; - -LOCAL_GR_SWIG_BLOCK_MAGIC(ecc,metrics_decode_viterbi_full_block_feedback); - -ecc_metrics_decode_viterbi_full_block_sptr -ecc_make_metrics_decode_viterbi_full_block -(int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - bool do_termination, - int start_memory_state, - int end_memory_state); - -ecc_metrics_decode_viterbi_full_block_feedback_sptr -ecc_make_metrics_decode_viterbi_full_block_feedback -(int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - const std::vector<int> &code_feedback, - bool do_termination, - int start_memory_state, - int end_memory_state); - -class ecc_metrics_decode_viterbi_full_block : public gr_block -{ - ecc_metrics_decode_viterbi_full_block - (int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - bool do_termination, - int start_memory_state, - int end_memory_state); - - ecc_metrics_decode_viterbi_full_block - (int sample_precision, - int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - const std::vector<int> &code_feedback, - bool do_termination, - int start_memory_state, - int end_memory_state); -}; diff --git a/gr-error-correcting-codes/src/lib/ecc_streams_encode_convolutional.cc b/gr-error-correcting-codes/src/lib/ecc_streams_encode_convolutional.cc deleted file mode 100644 index c3d0c5606..000000000 --- a/gr-error-correcting-codes/src/lib/ecc_streams_encode_convolutional.cc +++ /dev/null @@ -1,208 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <ecc_streams_encode_convolutional.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <iostream> - -ecc_streams_encode_convolutional_sptr -ecc_make_streams_encode_convolutional -(int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - bool do_termination, - int start_memory_state, - int end_memory_state) -{ - return ecc_streams_encode_convolutional_sptr - (new ecc_streams_encode_convolutional (frame_size_bits, - n_code_inputs, - n_code_outputs, - code_generator, - do_termination, - start_memory_state, - end_memory_state)); -} - -ecc_streams_encode_convolutional_sptr -ecc_make_streams_encode_convolutional_feedback -(int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - const std::vector<int> &code_feedback, - bool do_termination, - int start_memory_state, - int end_memory_state) -{ - return ecc_streams_encode_convolutional_sptr - (new ecc_streams_encode_convolutional (frame_size_bits, - n_code_inputs, - n_code_outputs, - code_generator, - code_feedback, - do_termination, - start_memory_state, - end_memory_state)); -} - -ecc_streams_encode_convolutional::ecc_streams_encode_convolutional -(int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generators, - bool do_termination, - int start_memory_state, - int end_memory_state) - : gr_block ("streams_encode_convolutional", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (0, 0, 0)) -{ - // error checking is done by the encoder class itself; - // just pass items on here. - - d_encoder = new encoder_convolutional (frame_size_bits, - n_code_inputs, - n_code_outputs, - code_generators, - do_termination, - start_memory_state, - end_memory_state); - - setup_io_signatures (n_code_inputs, n_code_outputs); -} - -ecc_streams_encode_convolutional::ecc_streams_encode_convolutional -(int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generators, - const std::vector<int> &code_feedback, - bool do_termination, - int start_memory_state, - int end_memory_state) - : gr_block ("streams_encode_convolutional_feedback", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (0, 0, 0)) -{ - // error checking is done by the encoder class itself; - // just pass items on here. - - d_encoder = new encoder_convolutional (frame_size_bits, - n_code_inputs, - n_code_outputs, - code_generators, - code_feedback, - do_termination, - start_memory_state, - end_memory_state); - - setup_io_signatures (n_code_inputs, n_code_outputs); -} - -void -ecc_streams_encode_convolutional::setup_io_signatures -(int n_code_inputs, - int n_code_outputs) -{ - // create the correct input signature; 1 bit per input char - - d_in_buf = new code_input_ic1l (n_code_inputs); - set_input_signature (gr_make_io_signature (n_code_inputs, - n_code_inputs, - sizeof (char))); - - // create the correct output signature; 1 bit per output char - - d_out_buf = new code_output_ic1l (n_code_outputs); - set_output_signature (gr_make_io_signature (n_code_outputs, - n_code_outputs, - sizeof (char))); -} - -ecc_streams_encode_convolutional::~ecc_streams_encode_convolutional -() -{ - delete d_encoder; - d_encoder = 0; - delete d_in_buf; - d_in_buf = 0; - delete d_out_buf; - d_out_buf = 0; -} - -/* - * Compute the number of input items needed to produce 'n_output' - * bits. Handled internally by the encoder. - */ - -void ecc_streams_encode_convolutional::forecast -(int noutput_items, - gr_vector_int &ninput_items_required) -{ - int ninput_items = d_encoder->compute_n_input_bits (noutput_items); - size_t ninputs = ninput_items_required.size(); - for (size_t n = 0; n < ninputs; n++) - ninput_items_required[n] = ninput_items; -} - -int -ecc_streams_encode_convolutional::general_work -(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - // compute the actual number of output items (1 bit char's) created. - - size_t t_n_input_items = d_encoder->compute_n_input_bits (noutput_items); -#if 1 - size_t t_n_output_items = d_encoder->compute_n_output_bits (t_n_input_items); - assert (t_n_output_items == ((size_t)noutput_items)); -#endif - // setup the i/o buffers - - d_in_buf->set_buffer ((void**)(&input_items[0]), t_n_input_items); - d_out_buf->set_buffer ((void**)(&output_items[0]), noutput_items); - - // "work" is handled by the encoder; which returns the actual number - // of input items (1-bit char's) used. - - t_n_input_items = d_encoder->encode (d_in_buf, d_out_buf, - (size_t) noutput_items); - - assert (0); - - // consume the number of used input items on all input streams - - consume_each (t_n_input_items); - - // returns number of items written to each output stream - - return (noutput_items); -} diff --git a/gr-error-correcting-codes/src/lib/ecc_streams_encode_convolutional.h b/gr-error-correcting-codes/src/lib/ecc_streams_encode_convolutional.h deleted file mode 100644 index ff60a8fa9..000000000 --- a/gr-error-correcting-codes/src/lib/ecc_streams_encode_convolutional.h +++ /dev/null @@ -1,158 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_ECC_STREAMS_ENCODE_CONVOLUTIONAL_H -#define INCLUDED_ECC_STREAMS_ENCODE_CONVOLUTIONAL_H - -#include <gr_block.h> -#include <libecc/encoder_convolutional.h> - -/*! - * \brief Encode the incoming streams using a convolutional encoder - * - * input: streams of char, one stream per input as defined by the - * instantiated code, using only the right-most justified bit as - * the single input bit per input item. - * - * output: streams of char, one stream per output as defined by the - * instantiated code, using only the right-most justified bit as - * the single output bit per output item. - * - * frame_size_bits: if == 0, then do streaming encoding ("infinite" - * trellis); otherwise this is the frame size in bits to encode - * before terminating the trellis. This value -does not- include - * any termination bits. - * - * n_code_inputs: - * n_code_outputs: - * code_generator: vector of integers (32 bit) representing the code - * to be implemented. E.g. "4" in binary is "100", which would be - * "D^2" for code generation. "6" == 110b == "D^2 + D" - * ==> The vector is listed in order for each output stream, so if there - * are 2 input streams (I1, I2) [specified in "n_code_inputs"] - * and 2 output streams (O1, O2) [specified in "n_code_outputs"], - * then the vector would be the code generator for: - * [I1->O1, I2->O1, I1->O2, I2->O2] - * with each element being an integer representation of the code. - * - * do_termination: valid only if frame_size_bits != 0, and defines - * whether or not to use trellis termination. Default is to use - * termination when doing block coding. - * - * start_memory_state: when starting a new block, the starting memory - * state to begin encoding; there will be a helper function to - * assist in creating this value for a given set of inputs; - * default is the "all zero" state. - * - * end_memory_state: when terminating a block, the ending memory - * state to stop encoding; there will be a helper function to - * assist in creating this value for a given set of inputs; - * default is the "all zero" state. - */ - -class ecc_streams_encode_convolutional; -typedef boost::shared_ptr<ecc_streams_encode_convolutional> - ecc_streams_encode_convolutional_sptr; - -ecc_streams_encode_convolutional_sptr -ecc_make_streams_encode_convolutional -(int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - bool do_termination = true, - int start_memory_state = 0, - int end_memory_state = 0); - -ecc_streams_encode_convolutional_sptr -ecc_make_streams_encode_convolutional_feedback -(int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - const std::vector<int> &code_feedback, - bool do_termination = true, - int start_memory_state = 0, - int end_memory_state = 0); - -class ecc_streams_encode_convolutional : public gr_block -{ -protected: - friend ecc_streams_encode_convolutional_sptr - ecc_make_streams_encode_convolutional - (int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - bool do_termination, - int start_memory_state, - int end_memory_state); - - friend ecc_streams_encode_convolutional_sptr - ecc_make_streams_encode_convolutional_feedback - (int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - const std::vector<int> &code_feedback, - bool do_termination, - int start_memory_state, - int end_memory_state); - - ecc_streams_encode_convolutional (int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - bool do_termination, - int start_memory_state, - int end_memory_state); - - ecc_streams_encode_convolutional (int frame_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - const std::vector<int> &code_feedback, - bool do_termination, - int start_memory_state, - int end_memory_state); - - void setup_io_signatures (int n_code_inputs, int n_code_outputs); - - encoder_convolutional* d_encoder; - code_input_ptr d_in_buf; - code_output_ptr d_out_buf; - -public: - ~ecc_streams_encode_convolutional (); - - inline encoder_convolutional* encoder () {return (d_encoder);}; - - virtual void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - - virtual 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 /* INCLUDED_ECC_STREAMS_ENCODE_CONVOLUTIONAL_H */ diff --git a/gr-error-correcting-codes/src/lib/ecc_streams_encode_convolutional.i b/gr-error-correcting-codes/src/lib/ecc_streams_encode_convolutional.i deleted file mode 100644 index f7cc42116..000000000 --- a/gr-error-correcting-codes/src/lib/ecc_streams_encode_convolutional.i +++ /dev/null @@ -1,77 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(ecc,streams_encode_convolutional); - -// Rename second constructor -%rename(streams_encode_convolutional_feedback) ecc_make_streams_encode_convolutional_feedback; - -// support vectors of these ... for use in the convolutional decoder -// as well as Turbo Codes (both encoder and decoder). - -namespace std { - %template(x_vector_ecc_streams_encode_convolutional_sptr) vector<ecc_streams_encode_convolutional_sptr>; -}; - -ecc_streams_encode_convolutional_sptr -ecc_make_streams_encode_convolutional -(int block_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - bool do_termination = true, - int start_memory_state = 0, - int end_memory_state = 0); - -ecc_streams_encode_convolutional_sptr -ecc_make_streams_encode_convolutional_feedback -(int block_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - const std::vector<int> &code_feedback, - bool do_termination = true, - int start_memory_state = 0, - int end_memory_state = 0); - -class ecc_streams_encode_convolutional : public gr_block -{ -private: - ecc_streams_encode_convolutional - (int block_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - bool do_termination, - int start_memory_state, - int end_memory_state); - - ecc_streams_encode_convolutional - (int block_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generator, - const std::vector<int> &code_feedback, - bool do_termination, - int start_memory_state, - int end_memory_state); -}; diff --git a/gr-error-correcting-codes/src/lib/ecc_streams_encode_turbo.cc b/gr-error-correcting-codes/src/lib/ecc_streams_encode_turbo.cc deleted file mode 100644 index 587d8116d..000000000 --- a/gr-error-correcting-codes/src/lib/ecc_streams_encode_turbo.cc +++ /dev/null @@ -1,197 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <ecc_streams_encode_turbo.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <iostream> - -ecc_streams_encode_turbo_sptr -ecc_make_streams_encode_turbo -(int n_code_inputs, - int n_code_outputs, - const std::vector<ecc_streams_encode_convolutional_sptr> &encoders, - const std::vector<size_t> &interleavers) -{ - return ecc_streams_encode_turbo_sptr - (new ecc_streams_encode_turbo (n_code_inputs, - n_code_outputs, - encoders, - interleavers)); -} - -ecc_streams_encode_turbo::ecc_streams_encode_turbo -(int n_code_inputs, - int n_code_outputs, - const std::vector<ecc_streams_encode_convolutional_sptr> &encoders, - const std::vector<size_t> &interleavers) - : gr_block ("streams_encode_turbo", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (0, 0, 0)) -{ - // error checking is done by the encoder class itself; just pass - // items on here. But ... check out individual encoders, to make - // sure the total I/O matches those specified by the user. - - d_n_encoders = encoders.size (); - - if (d_n_encoders < 2) { - std::cerr << "ecc_streams_encode_turbo: Error: " - "too few (" << d_n_encoders << ") encoders specified; a Turbo " - "code requires at least 2 constituent encoders.\n"; - assert (0); - } - - // make sure that the block size and termination are consistent for - // all encoders; warn the user if not, since it doesn't really - // matter to the encoder (but it might to the decoder; remains to be - // seen). - - encoder_convolutional* t_ec = encoders[0]->encoder (); - d_block_size_bits = t_ec->block_size_bits (); - d_do_termination = t_ec->do_termination (); - bool t_diff_block_size, t_diff_termination; - t_diff_block_size = t_diff_termination = false; - - for (size_t m = 1; m < d_n_encoders; m++) { - t_ec = encoders[0]->encoder (); - size_t t_block_size_bits = t_ec->block_size_bits (); - if (t_block_size_bits != d_block_size_bits) - t_diff_block_size = true; - bool t_do_termination = t_ec->do_termination (); - if (t_do_termination != d_do_termination) - t_do_termination = true; - } - - if (t_diff_block_size == true) { - std::cout << "ecc_streams_encode_turbo: Warning: " - "Some constituent encoders have different block size (bits).\n"; - } - if (t_diff_termination == true) { - std::cout << "ecc_streams_encode_turbo: Warning: " - "Some constituent encoders are differently terminationed.\n"; - } - - std::cout << "ecc_streams_encode_turbo: setup:\n" - "d_n_encoders = " << d_n_encoders << "\n" - "n_code_inputs = " << n_code_inputs << "\n" - "n_code_outputs = " << n_code_outputs << "\n\n" - "Individual Encoders:\n"; - - for (size_t m = 0; m < d_n_encoders; m++) { - t_ec = encoders[m]->encoder (); - std::cout << " [" << (m+1) << "]:\n" - "n_code_inputs = " << (t_ec->n_code_inputs()) << "\n" - "n_code_outputs = " << (t_ec->n_code_outputs()) << "\n" - "block_size_bits = " << (t_ec->block_size_bits()) << "\n" - "do_termination = " << - ((t_ec->do_termination()==true)?"true":"false") << "\n"; - } - -#if 1 - assert (0); -#else - if (d_n_encoders != (interleavers.size())) {} - - d_encoder = new encoder_turbo (n_code_inputs, - n_code_outputs, - code_generators, - do_termination, - start_memory_state, - end_memory_state); -#endif - - // create the correct input signature; 1 bit per input char - - d_in_buf = new code_input_ic1l (n_code_inputs); - set_input_signature (gr_make_io_signature (n_code_inputs, - n_code_inputs, - sizeof (char))); - - // create the correct output signature; 1 bit per output char - - d_out_buf = new code_output_ic1l (n_code_outputs); - set_output_signature (gr_make_io_signature (n_code_outputs, - n_code_outputs, - sizeof (char))); -} - -ecc_streams_encode_turbo::~ecc_streams_encode_turbo -() -{ - delete d_encoder; - d_encoder = 0; - delete d_in_buf; - d_in_buf = 0; - delete d_out_buf; - d_out_buf = 0; -} - -void ecc_streams_encode_turbo::forecast -(int noutput_items, - gr_vector_int &ninput_items_required) -{ - int ninput_items = d_encoder->compute_n_input_bits (noutput_items); - size_t ninputs = ninput_items_required.size(); - for (size_t n = 0; n < ninputs; n++) - ninput_items_required[n] = ninput_items; -} - -int -ecc_streams_encode_turbo::general_work -(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - // compute the actual number of output items (1 bit char's) created. - - size_t t_n_input_items = d_encoder->compute_n_input_bits (noutput_items); -#if 1 - size_t t_n_output_items = d_encoder->compute_n_output_bits (t_n_input_items); - assert (t_n_output_items == ((size_t)noutput_items)); -#endif - // setup the i/o buffers - - d_in_buf->set_buffer ((void**)(&input_items[0]), t_n_input_items); - d_out_buf->set_buffer ((void**)(&output_items[0]), noutput_items); - - // "work" is handled by the encoder; which returns the actual number - // of input items (1-bit char's) used. - - t_n_input_items = d_encoder->encode (d_in_buf, d_out_buf, - (size_t) noutput_items); - - assert (0); - - // consume the number of used input items on all input streams - - consume_each (t_n_input_items); - - // returns number of items written to each output stream - - return (noutput_items); -} diff --git a/gr-error-correcting-codes/src/lib/ecc_streams_encode_turbo.h b/gr-error-correcting-codes/src/lib/ecc_streams_encode_turbo.h deleted file mode 100644 index 93b42174c..000000000 --- a/gr-error-correcting-codes/src/lib/ecc_streams_encode_turbo.h +++ /dev/null @@ -1,107 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_ECC_STREAMS_ENCODE_TURBO_H -#define INCLUDED_ECC_STREAMS_ENCODE_TURBO_H - -#include <gr_block.h> -#include <ecc_streams_encode_convolutional.h> - -#if 0 -#include <libecc/encoder_turbo_ic1_ic1.h> -#else -#include <libecc/encoder_turbo.h> -#endif - -/*! - * \brief Encode the incoming stream(s) using a turbo encoder - * - * input: streams of char, one stream per input as defined by the - * instantiated code, using only the right-most justified bit as - * the single input bit per input item. - * - * output: streams of char, one stream per output as defined by the - * instantiated code, using only the right-most justified bit as - * the single output bit per output item. - * - * n_code_inputs: - * n_code_outputs: the total number of code inputs and outputs for the - * overall turbo encoder (not just the constituent codes). - * - * encoders: the constituent encoders to be used; all -should- be - * configured with the same "block_size" and "termination", though - * from this encoder's perspective it doesn't really matter. - * - * interleavers: the interleavers to use before each encoder, - * respectively, except the first encoder which will not use an - * interleaver. - */ - -class ecc_streams_encode_turbo; - -typedef boost::shared_ptr<ecc_streams_encode_turbo> -ecc_streams_encode_turbo_sptr; - -ecc_streams_encode_turbo_sptr -ecc_make_streams_encode_turbo -(int n_code_inputs, - int n_code_outputs, - const std::vector<ecc_streams_encode_convolutional_sptr> &encoders, - const std::vector<size_t> &interleavers); - -class ecc_streams_encode_turbo : public gr_block -{ -protected: - friend ecc_streams_encode_turbo_sptr - ecc_make_streams_encode_turbo - (int n_code_inputs, - int n_code_outputs, - const std::vector<ecc_streams_encode_convolutional_sptr> &d_encoders, - const std::vector<size_t> &d_interleavers); - - ecc_streams_encode_turbo - (int n_code_inputs, - int n_code_outputs, - const std::vector<ecc_streams_encode_convolutional_sptr> &d_encoders, - const std::vector<size_t> &d_interleavers); - - std::vector<ecc_streams_encode_turbo_sptr> d_encoders; - std::vector<size_t> d_interleavers; - size_t d_n_encoders, d_block_size_bits; - bool d_do_termination; - encoder_turbo* d_encoder; - code_input_ptr d_in_buf; - code_output_ptr d_out_buf; - -public: - ~ecc_streams_encode_turbo (); - - virtual void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - - virtual 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 /* INCLUDED_ECC_STREAMS_ENCODE_TURBO_H */ diff --git a/gr-error-correcting-codes/src/lib/ecc_streams_encode_turbo.i b/gr-error-correcting-codes/src/lib/ecc_streams_encode_turbo.i deleted file mode 100644 index 8ee36906a..000000000 --- a/gr-error-correcting-codes/src/lib/ecc_streams_encode_turbo.i +++ /dev/null @@ -1,41 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(ecc,streams_encode_turbo); - -#include <ecc_streams_encode_convolutional.h> - -ecc_streams_encode_turbo_sptr -ecc_make_streams_encode_turbo -(int n_code_inputs, - int n_code_outputs, - const std::vector<ecc_streams_encode_convolutional_sptr> &encoders, - const std::vector<size_t> &interleavers); - -class ecc_streams_encode_turbo : public gr_block -{ - ecc_streams_encode_turbo - (int frame_size_bits, - int n_code_inputs, - const std::vector<ecc_streams_encode_convolutional_sptr> &encoders, - const std::vector<size_t> &interleavers); -}; diff --git a/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.cc b/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.cc deleted file mode 100644 index 78be73533..000000000 --- a/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.cc +++ /dev/null @@ -1,149 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <ecc_syms_to_metrics.h> -#include <gr_io_signature.h> -#include <assert.h> - -ecc_syms_to_metrics_sptr -ecc_make_syms_to_metrics (gr_feval_dd* pdf_fcn_0_bit, - gr_feval_dd* pdf_fcn_1_bit, - int n_samples, - double min_sample, - double max_sample, - int sample_precision) -{ - return ecc_syms_to_metrics_sptr - (new ecc_syms_to_metrics (pdf_fcn_0_bit, - pdf_fcn_1_bit, - n_samples, - min_sample, - max_sample, - sample_precision)); -} - -/* - * dummy functions and variables to get the double(*)(double) function - * to work properly with the gr_feval_XX stuff. - */ - -static gr_feval_dd* l_pdf_fcn_0_bit; -static gr_feval_dd* l_pdf_fcn_1_bit; - -static double pdf_fcn_0 (double x) -{ - return (l_pdf_fcn_0_bit->calleval (x)); -} - -static double pdf_fcn_1 (double x) -{ - return (l_pdf_fcn_1_bit->calleval (x)); -} - -ecc_syms_to_metrics::ecc_syms_to_metrics -(gr_feval_dd* pdf_fcn_0_bit, - gr_feval_dd* pdf_fcn_1_bit, - int n_samples, - double min_sample, - double max_sample, - int sample_precision) - : gr_block ("syms_to_metrics", - gr_make_io_signature (1, -1, sizeof (float)), - gr_make_io_signature (0, 0, 0)) -{ - // setup the dummy functions to do the conversion from the - // python-provided feval classes to that which is needed by the - // libecc's code_metrics classes. - - l_pdf_fcn_0_bit = pdf_fcn_0_bit; - l_pdf_fcn_1_bit = pdf_fcn_1_bit; - - // use the static "create" member function to create the actual - // code_metrics to use. - - d_code_metrics_table = libecc_code_metrics_create_table<double> - (&pdf_fcn_0, - &pdf_fcn_1, - n_samples, - min_sample, - max_sample, - sample_precision); - - // get the output item size in bytes from the new code_metrics. - - d_out_item_size_bytes = d_code_metrics_table->out_item_size_bytes (); - - // set the output signature to match that which the code_metrics - // will generate. - - set_output_signature (gr_make_io_signature (1, -1, d_out_item_size_bytes)); -} - -bool ecc_syms_to_metrics::check_topology (int ninputs, int noutputs) -{ - // there are 2 output streams per input stream; the first is ~to - // log(p(0|x)) = log-probability of a 0-bit given the input symbol - // 'x'; the second is ~to log(p(1|x)). - - return ((noutputs == (2*ninputs)) ? true : false); -} - -void -ecc_syms_to_metrics::forecast -(int noutput_items, - gr_vector_int &ninput_items_required) -{ - // always 1:1, for all streams - for (size_t n = 0; n < ninput_items_required.size(); n++) { - ninput_items_required[n] = noutput_items; - } -} - -int -ecc_syms_to_metrics::general_work -(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t l_n_output_items = noutput_items; - - for (size_t n = 0; n < input_items.size(); n++) { - double* t_in_buf = (double*)(&input_items[n]); - void* t_out_buf_0_bit = (void*)(&(output_items[2*n])); - void* t_out_buf_1_bit = (void*)(&(output_items[(2*n)+1])); - d_code_metrics_table->convert (l_n_output_items, t_in_buf, - t_out_buf_0_bit, t_out_buf_1_bit); - } - - // consume the number of used input items on all input streams - - consume_each (noutput_items); - - // returns number of items written to each output stream - - return (noutput_items); -} diff --git a/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.h b/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.h deleted file mode 100644 index c5f853cd3..000000000 --- a/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.h +++ /dev/null @@ -1,124 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_SYMS_TO_METRICS_H -#define INCLUDED_SYMS_TO_METRICS_H - -#include <gr_block.h> -#include <gr_feval.h> -#include <vector> -#include <libecc/code_metrics.h> - -class ecc_syms_to_metrics; -typedef boost::shared_ptr<ecc_syms_to_metrics> ecc_syms_to_metrics_sptr; - -ecc_syms_to_metrics_sptr ecc_make_syms_to_metrics -(gr_feval_dd* pdf_fcn_0_bit, - gr_feval_dd* pdf_fcn_1_bit, - int n_samples, - double min_sample, - double max_sample, - int sample_precision); - -/*! - * \brief Convert the input stream(s) of soft (float) symbols to - * log-probability metrics of user-specified precision; output is 2 - * streams per input stream, each stream consisting of the metric for - * receiving a 0-bit and 1-bit, respectively, with the lower-numbered - * stream being the 0-bit. - * - * input: stream(s) of float; output: stream(s) of metrics - */ - -class ecc_syms_to_metrics : public gr_block -{ -protected: - friend ecc_syms_to_metrics_sptr - ecc_make_syms_to_metrics (gr_feval_dd* pdf_fcn_0_bit, - gr_feval_dd* pdf_fcn_1_bit, - int n_samples, - double min_sample, - double max_sample, - int sample_precision); - -/* - * ecc_syms_to_metrics: Convert the input soft (float) symbols into - * log-probabilities (metrics) for use in the convolutional - * decoder. Samples the provided PDF function in 'n_samples' - * places from 'min_sample' to 'max_sample', takes the log of that - * value, then converts the result into a given precision and - * stores all results in a "handy dandy" lookup table for much - * faster processing. - * - * pdf_fcn_0_bit: point to a probability distribution function which - * takes a double and returns a double, for the 0-bit probabilities. - * - * pdf_fcn_1_bit: point to a probability distribution function which - * takes a double and returns a double, for the 1-bit probabilities. - * - * n_samples: the number of samples between min_sample and max_sample - * to store in the lookup table. Must be at least 2, but - * otherwise is limited only by the amount of available memory; - * generally, 65536 (1 << 16) is plenty of samples. - * - * min_sample: the minimum value below which any incoming value is - * "rounded" up. - * - * max_sample: the maximum value above which any incoming value is - * "rounded" down. - * - * sample_precision: the precision with which to sample the returned - * value of the PDF function. - * + Cannot be < 0 or > 32. - * + "soft float" == 0 - * + otherwise, convert to an integer of the given value - * - * in "work", finds the (linearly) closest sample value for the given - * input and outputs the metric for a 0-bit input on the first - * stream and a 1-bit input on the second stream. - * - */ - - ecc_syms_to_metrics (gr_feval_dd* pdf_fcn_0_bit, - gr_feval_dd* pdf_fcn_1_bit, - int n_samples, - double min_sample, - double max_sample, - int sample_precision); - - size_t d_out_item_size_bytes; - code_metrics_table<double>* d_code_metrics_table; - -public: - ~ecc_syms_to_metrics() {delete d_code_metrics_table;}; - - bool check_topology (int ninputs, int noutputs); - - 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 /* INCLUDED_SYMS_TO_METRICS_H */ diff --git a/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.i b/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.i deleted file mode 100644 index 32a830473..000000000 --- a/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.i +++ /dev/null @@ -1,41 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(ecc,syms_to_metrics); - -ecc_syms_to_metrics_sptr ecc_make_syms_to_metrics -(gr_feval_dd* pdf_fcn_0_bit, - gr_feval_dd* pdf_fcn_1_bit, - int n_samples, - double min_sample, - double max_sample, - int sample_precision); - -class ecc_syms_to_metrics : public gr_block -{ - ecc_syms_to_metrics (gr_feval_dd* pdf_fcn_0_bit, - gr_feval_dd* pdf_fcn_1_bit, - int n_samples, - double min_sample, - double max_sample, - int sample_precision); -}; diff --git a/gr-error-correcting-codes/src/lib/libecc/Makefile.am b/gr-error-correcting-codes/src/lib/libecc/Makefile.am deleted file mode 100644 index 3c44464d3..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/Makefile.am +++ /dev/null @@ -1,56 +0,0 @@ -# -# 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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = mld . tests - -INCLUDES = $(STD_DEFINES_AND_INCLUDES) \ - -I$(top_srcdir)/gr-error-correcting-codes/src/lib - -noinst_LTLIBRARIES = libecc.la - -libecc_la_SOURCES = \ - code_convolutional_trellis.cc \ - code_metrics.cc code_io.cc \ - encoder.cc \ - encoder_convolutional.cc \ - encoder_turbo.cc \ - decoder.cc \ - decoder_viterbi.cc \ - decoder_viterbi_full_block.cc - -noinst_HEADERS = \ - code_types.h code_metrics.h code_io.h \ - code_convolutional_trellis.h \ - encoder.h encoder_turbo.h \ - encoder_convolutional.h \ - decoder.h decoder_viterbi.h \ - decoder_viterbi_full_block.h - -# link the library against the c++ standard library -libecc_la_LIBADD = \ - mld/libmld.la \ - $(PYTHON_LDFLAGS) \ - $(GNURADIO_CORE_LIBS) \ - -lstdc++ - -MOSTLYCLEANFILES = *.loT *~ diff --git a/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.cc b/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.cc deleted file mode 100644 index 6d4a2f138..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.cc +++ /dev/null @@ -1,1264 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "code_convolutional_trellis.h" -#include <assert.h> -#include <iostream> - -#define DO_TIME_THOUGHPUT 0 -#define DO_PRINT_DEBUG 0 -#define DO_PRINT_DEBUG_VARS 0 -#define DO_PRINT_DEBUG_TERM 0 -#define DO_PRINT_DEBUG_TERM_END 0 -#define DO_PRINT_DEBUG_LOOKUP 0 - -#include <mld/mld_timer.h> -#include <mld/n2bs.h> - -static const int g_max_block_size_bits = 10000000; -static const int g_max_num_streams = 10; -static const int g_num_bits_per_byte = 8; - -/* - * sum_bits_mod2: - * sum the number of set bits, mod 2, for the output bit - */ - -char -code_convolutional_trellis::sum_bits_mod2 -(memory_t in_mem, - size_t max_memory) -{ - // there are faster ways to do this, but this works for now; could - // certainly do a single inline asm, which most processors provide - // to deal with summing the bits in an integer. - // this routine can be overridden by another method if desired. - - char t_out_bit = (char)(in_mem & 1); - for (size_t r = max_memory; r > 0; r--) { - in_mem >>= 1; - t_out_bit ^= ((char)(in_mem & 1)); - } - return (t_out_bit); -} - -void -code_convolutional_trellis::code_convolutional_trellis_init -(int block_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generators, - const std::vector<int>* code_feedback, - bool do_termination, - int end_memory_state) -{ - // do error checking on the input arguments - - // make sure the block length makes sense - - if ((block_size_bits < 0) | (block_size_bits > g_max_block_size_bits)) { - std::cerr << "code_convolutional_trellis: " << - "Requested block length (" << block_size_bits << - " bits) must be between 0 and " << g_max_block_size_bits << - " bits, with 0 being a streaming encoder.\n"; - assert (0); - } - - // check to make sure the number of input streams makes sense - - if ((n_code_inputs <= 0) | (n_code_inputs > g_max_num_streams)) { - std::cerr << "code_convolutional_trellis: " << - "Requested number of input streams (" << - n_code_inputs << ") must be between 1 and " << - g_max_num_streams << ".\n"; - assert (0); - } - - // check to make sure the number of output streams makes sense - - if ((n_code_outputs <= 0) | (n_code_outputs > g_max_num_streams)) { - std::cerr << "code_convolutional_trellis: " << - "Requested number of output streams (" << - n_code_outputs << ") must be between 1 and " << - g_max_num_streams << ".\n"; - assert (0); - } - - // make sure the code_generator is the correct length - - if (code_generators.size () != - ((size_t)(n_code_inputs * n_code_outputs))) { - std::cerr << "code_convolutional_trellis: " << - "Number of code generator entries (" << code_generators.size () << - ") is not equal to the product of the number of input and output" << - " streams (" << (n_code_inputs * n_code_outputs) << ").\n"; - assert (0); - } - - // check for feedback (== NULL or not) - - d_do_feedback = (code_feedback != NULL); - - // create the class block variables - - d_block_size_bits = block_size_bits; - d_n_code_inputs = n_code_inputs; - d_n_code_outputs = n_code_outputs; - d_do_streaming = (block_size_bits == 0); - d_do_termination = (d_do_streaming == true) ? false : do_termination; - - if (DO_PRINT_DEBUG_VARS) { - std::cout << - "d_block_size_bits = " << d_block_size_bits << "\n" - "d_n_code_inputs = " << d_n_code_inputs << "\n" - "d_n_code_outputs = " << d_n_code_outputs << "\n" - "d_do_streaming = " << - ((d_do_streaming == true) ? "true" : "false") << "\n" - "d_do_termination = " << - ((d_do_termination == true) ? "true" : "false") << "\n" - "d_do_feedback = " << - ((d_do_feedback == true) ? "true" : "false") << "\n"; - } - - // allocate the vectors for doing the encoding. use memory_t (an - // interger type, at least 32 bits) bits to represent memory and the - // code, as it makes the operations quite simple the state vectors. - - // d_states is a "matrix" [#input by #outputs] containing indices - // to memory_t's; this is done to make feedback function properly, - // and doesn't effect the computation time for feedforward. The - // issue is that any code with the same feedback can use the same - // memory - thus reducing the actual number of memories required. - // These overlapping encoders will use the same actual memory, but - // given that there is no way to know a-priori where they are, use - // pointers over the full I/O matrix-space to make sure each I/O - // encoder uses the correct memory. - // reference the matrix using "maoi(i,o)" ... see .h file. - - // code generators (feedforward part) are [#inputs x #outputs], - // always - one for each I/O combination. - // reference the matrix using "maoi(i,o)" ... see .h file - - d_code_generators.assign (d_n_code_inputs * d_n_code_outputs, 0); - - // check the feedback for correctness, before anything else, since - // any feedback impacts the total # of delays in the encoder: - // without feedback, this is the sum of the individual delays max'ed - // over each input (if siao) or output (if soai). - - if (d_do_feedback == true) { - memory_t t_OR_all_feedback = 0; - for (size_t n = 0; n < d_n_code_outputs; n++) { - for (size_t m = 0; m < d_n_code_inputs; m++) { - memory_t t_in_code = (*code_feedback)[maoi(m,n)]; - - // OR this feedback with the overall, - // to check for any delays used at all - - t_OR_all_feedback |= t_in_code; - } - } - - // check to see if all the feedback entries were either "0" or "1", - // which implies no feedback; warn the user in that case and reset - // the do_feedback parameter to false. - - if ((t_OR_all_feedback | 1) == 1) { - std::cout << "code_convolutional_trellis: Warning: " << - "No feedback is required, ignoring feedback.\n"; - d_do_feedback = false; - } - } - - // copy over the FF code generators - - for (size_t n = 0; n < d_n_code_outputs; n++) - for (size_t m = 0; m < d_n_code_inputs; m++) - d_code_generators[maio(m,n)] = code_generators[maio(m,n)]; - - // check the input FF (and FB) code generators for correctness, and - // find the minimum memory configuration: combining via a single - // input / all outputs (SIAO), or a single output / all inputs (SOAI). - // - // for FF only, look over both the SOAI and SIAO realizations to - // find the minimum total # of delays, and use that realization - // (SOAI is preferred if total # of delays is equal, since it's much - // simpler to implement). - // - // for FB: - // for SIAO, check each input row (all outputs for a given input) - // for unique feedback; duplicate feedback entries can be - // combined into a single computation to reduce total # of delays. - // for SOAI: check each output column (all inputs for a given - // output) for unique feedback; duplicate feedback entries can - // be combined into a simgle computation (ditto). - - // check for SOAI all '0' output - - for (size_t n = 0; n < d_n_code_outputs; n++) { - memory_t t_all_inputs_zero = 0; - for (size_t m = 0; m < d_n_code_inputs; m++) - t_all_inputs_zero |= d_code_generators[maio(m,n)]; - - // check this input to see if all encoders were '0'; this might be - // OK for some codes, but warn the user just in case - - if (t_all_inputs_zero == 0) { - std::cout << "code_convolutional_trellis: Warning:" - "Output " << n+1 << " (of " << d_n_code_outputs << - ") will always be 0.\n"; - } - } - - // check for SIAO all '0' input - - for (size_t m = 0; m < d_n_code_inputs; m++) { - memory_t t_all_outputs_zero = 0; - for (size_t n = 0; n < d_n_code_outputs; n++) - t_all_outputs_zero |= d_code_generators[maio(m,n)]; - - // check this input to see if all encoders were '0'; this might be - // OK for some codes, but warn the user just in case - - if (t_all_outputs_zero == 0) { - std::cout << "code_convolutional_trellis: Warning:" - "Input " << m+1 << " (of " << d_n_code_inputs << - ") will not be used; all encoders are '0'.\n"; - } - } - - // check and compute memory requirements in order to determine which - // realization uses the least memory; create and save findings to - // not have to re-do these computations later. - - // single output, all inputs (SOAI) realization: - // reset the global parameters - - d_code_feedback.assign (d_n_code_inputs * d_n_code_outputs, 0); - d_n_delays.assign (d_n_code_inputs * d_n_code_outputs, 0); - d_io_num.assign (d_n_code_inputs * d_n_code_outputs, 0); - d_states_ndx.assign (d_n_code_inputs * d_n_code_outputs, 0); - d_max_delay = d_total_n_delays = d_n_memories = 0; - d_do_encode_soai = true; - - for (size_t n = 0; n < d_n_code_outputs; n++) { - size_t t_max_mem = 0; - size_t t_n_unique_fb_prev_start = d_n_memories; - - for (size_t m = 0; m < d_n_code_inputs; m++) { - get_memory_requirements (m, n, t_max_mem, - t_n_unique_fb_prev_start, code_feedback); - if (d_do_feedback == false) { - d_states_ndx[maio(m,n)] = n; - } - } - if (d_do_feedback == false) { - // not feedback; just store memory requirements for this output - d_total_n_delays += t_max_mem; - d_n_delays[n] = t_max_mem; - d_io_num[n] = n; - } - } - if (d_do_feedback == false) { - d_n_memories = d_n_code_outputs; - } - - // store the parameters for SOAI - - std::vector<memory_t> t_fb_generators_soai; - std::vector<size_t> t_n_delays_soai, t_io_num_soai; - std::vector<size_t> t_states_ndx_soai; - size_t t_max_delay_soai, t_total_n_delays_soai, t_n_memories_soai; - - t_fb_generators_soai.assign (d_code_feedback.size (), 0); - t_fb_generators_soai = d_code_feedback; - t_n_delays_soai.assign (d_n_delays.size (), 0); - t_n_delays_soai = d_n_delays; - t_io_num_soai.assign (d_io_num.size (), 0); - t_io_num_soai = d_io_num; - t_states_ndx_soai.assign (d_states_ndx.size (), 0); - t_states_ndx_soai = d_states_ndx; - - t_n_memories_soai = d_n_memories; - t_total_n_delays_soai = d_total_n_delays; - t_max_delay_soai = d_max_delay; - - // single input, all outputs (SIAO) realization - // reset the global parameters - - d_code_feedback.assign (d_n_code_inputs * d_n_code_outputs, 0); - d_n_delays.assign (d_n_code_inputs * d_n_code_outputs, 0); - d_io_num.assign (d_n_code_inputs * d_n_code_outputs, 0); - d_states_ndx.assign (d_n_code_inputs * d_n_code_outputs, 0); - d_max_delay = d_total_n_delays = d_n_memories = 0; - d_do_encode_soai = false; - - for (size_t m = 0; m < d_n_code_inputs; m++) { - size_t t_max_mem = 0; - size_t t_n_unique_fb_prev_start = d_n_memories; - - for (size_t n = 0; n < d_n_code_outputs; n++) { - get_memory_requirements (m, n, t_max_mem, - t_n_unique_fb_prev_start, code_feedback); - if (d_do_feedback == false) { - d_states_ndx[maio(m,n)] = m; - } - } - if (d_do_feedback == false) { - // not feedback; just store memory requirements for this output - d_total_n_delays += t_max_mem; - d_n_delays[m] = t_max_mem; - d_io_num[m] = m; - } - } - if (d_do_feedback == false) { - d_n_memories = d_n_code_inputs; - } - - if (DO_PRINT_DEBUG_VARS) { - std::cout << - " t_total_n_delays_siao = " << d_total_n_delays << "\n" - " t_total_n_delays_soai = " << t_total_n_delays_soai << "\n"; - } - - // pick which realization to use; - // siao is preferred since it's easier to debug, and more likely - - if (d_total_n_delays <= t_total_n_delays_soai) { - // use siao - // nothing else to do, since the global variables already hold - // the correct values. - } else { - // use soai - d_do_encode_soai = true; - d_code_feedback = t_fb_generators_soai; - d_n_delays = t_n_delays_soai; - d_io_num = t_io_num_soai; - d_states_ndx = t_states_ndx_soai; - d_n_memories = t_n_memories_soai; - d_total_n_delays = t_total_n_delays_soai; - d_max_delay = t_max_delay_soai; - } - - // make sure the block length makes sense, #2 - - if ((d_do_streaming == false) & (d_block_size_bits < d_max_delay)) { - std::cerr << "code_convolutional_trellis: " << - "Requested block length (" << d_block_size_bits << - " bit" << (d_block_size_bits > 1 ? "s" : "") << - ") must be at least 1 memory length (" << d_max_delay << - " bit" << (d_max_delay > 1 ? "s" : "") << - " for this code) when doing block coding.\n"; - assert (0); - } - - // check & mask off the init states - - d_n_states = (1 << d_total_n_delays); - d_n_input_combinations = (1 << d_n_code_inputs); - - if (DO_PRINT_DEBUG_VARS) { - std::cout << - " d_n_states = " << d_n_states << "\n" - " d_n_input_combinations = " << d_n_input_combinations << "\n"; - } - - if ((d_do_feedback == true) & (d_do_encode_soai == true)) { - // create the individual output bits used in soai feedback - - d_ind_outputs.assign (d_n_memories, 0); - } - - // create the max_mem_mask to be used in encoding - - d_max_mem_masks.assign (d_n_memories, 0); - - for (size_t m = 0; m < d_n_memories; m++) { - if (d_n_delays[m] == sizeof (memory_t) * g_num_bits_per_byte) - d_max_mem_masks[m] = ((memory_t) -1); - else - d_max_mem_masks[m] = (memory_t)((2 << (d_n_delays[m])) - 1); - } - - if (DO_PRINT_DEBUG_VARS) { - std::cout << - " d_n_memories = " << d_n_memories << "\n" - " d_total_n_delays = " << d_total_n_delays << " : ["; - for (size_t m = 0; m < d_n_memories; m++) { - std::cout << d_n_delays[m]; - if (m != (d_n_memories-1)) - std::cout << ", "; - } - std::cout << "]\n" << - " d_max_delay = " << d_max_delay << "\n" - " d_do_encode_soai = " << - ((d_do_encode_soai == true) ? "true" : "false") << "\n"; - } - - // zero the memories - - d_memory.assign (d_n_memories, 0); - - // create the inputs and outputs buffers - - d_current_inputs.assign (d_n_code_inputs, 0); - d_current_outputs.assign (d_n_code_outputs, 0); - - // create the trellis for this code: - - memory_t t_mask = (memory_t)((1 << d_total_n_delays) - 1); - memory_t t_end_memory_state = (memory_t) end_memory_state; - - if (t_end_memory_state != (t_end_memory_state & t_mask)) { - std::cout << "code_convolutional_trellis: Warning: " << - "provided end memory state out (" << end_memory_state << - ") is out of the state range [0, " << - (d_n_states-1) << "]; masking off the unused bits.\n"; - - end_memory_state &= t_mask; - } - - create_trellis (); - - if (d_do_termination == true) { - - // create the termination lookup table - - create_termination_table (end_memory_state); - } -} - -void -code_convolutional_trellis::get_memory_requirements -(size_t m, // input number - size_t n, // output number - size_t& t_max_mem, - size_t& t_n_unique_fb_prev_start, - const std::vector<int>* code_feedback) -{ - size_t t_in_code = d_code_generators[maio(m,n)]; - - // find the memory requirement for this code generator - - size_t t_code_mem_ff = max_bit_position (t_in_code); - - // check to see if this is bigger than any others in this row/column - - if (t_code_mem_ff > t_max_mem) - t_max_mem = t_code_mem_ff; - - if (DO_PRINT_DEBUG) { - std::cout << "c_g[" << m << "][" << n << "]{" << - maio(m,n) << "} = " << n2bs(t_in_code, 8) << - ", code_mem = " << t_code_mem_ff; - } - - // check the feedback portion, if it exists; - // for soai, check all the inputs which generate this output for - // uniqueness; duplicate entries can be combined to reduce total - // # of memories as well as required computations. - - if (d_do_feedback == true) { - if (DO_PRINT_DEBUG) { - std::cout << "\n"; - } - - // get the FB code; AND off the LSB for correct functionality - // during internal computations. - - t_in_code = ((memory_t)((*code_feedback)[maio(m,n)])); - t_in_code &= ((memory_t)(-2)); - - // find the memory requirement - - size_t t_code_mem_fb = max_bit_position (t_in_code); - - if (DO_PRINT_DEBUG) { - std::cout << "c_f[" << m << "][" << n << "]{" << - maio(m,n) << "} = " << n2bs(t_in_code, 8) << - ", code_mem = " << t_code_mem_fb; - } - - // check to see if this feedback is unique - - size_t l_n_unique_fb = t_n_unique_fb_prev_start; - while (l_n_unique_fb < d_n_memories) { - if (d_code_feedback[l_n_unique_fb] == t_in_code) - break; - l_n_unique_fb++; - } - if (l_n_unique_fb == d_n_memories) { - - // this is a unique feedback; - - d_code_feedback[l_n_unique_fb] = t_in_code; - d_n_delays[l_n_unique_fb] = t_code_mem_fb; - - // increase the number of unique feedback codes - - d_n_memories++; - - // store memory requirements for this output - - if (t_max_mem < t_code_mem_fb) - t_max_mem = t_code_mem_fb; - d_total_n_delays += t_max_mem; - - if (DO_PRINT_DEBUG) { - std::cout << ", uq # " << l_n_unique_fb << - ", tot_mem = " << d_total_n_delays; - } - } else { - // not a unique feedback, but the FF might require more memory - - if (DO_PRINT_DEBUG) { - std::cout << ", !uq # " << l_n_unique_fb << - " = " << d_n_delays[l_n_unique_fb]; - } - - if (d_n_delays[l_n_unique_fb] < t_code_mem_ff) { - d_total_n_delays += (t_code_mem_ff - d_n_delays[l_n_unique_fb]); - d_n_delays[l_n_unique_fb] = t_code_mem_ff; - - if (DO_PRINT_DEBUG) { - std::cout << " => " << d_n_delays[l_n_unique_fb] << - ", tot_mem = " << d_total_n_delays; - } - } - } - d_io_num[l_n_unique_fb] = ((d_do_encode_soai == true) ? n : m); - d_states_ndx[maio(m,n)] = l_n_unique_fb; - } - if (DO_PRINT_DEBUG) { - std::cout << "\n"; - } - if (d_max_delay < t_max_mem) - d_max_delay = t_max_mem; -} - -void -code_convolutional_trellis::create_trellis -() -{ - // first dimension is the number of states - - d_trellis.resize (d_n_states); - - // second dimension (one per first dimension) is the number of input - // combinations - - for (size_t m = 0; m < d_n_states; m++) { - d_trellis[m].resize (d_n_input_combinations); - } - - // fill in the trellis - - for (size_t m = 0; m < d_n_states; m++) { - for (size_t n = 0; n < d_n_input_combinations; n++) { - connection_t_ptr t_connection = &(d_trellis[m][n]); - encode_single ((memory_t) m, - (memory_t) n, - t_connection->d_to_state, - t_connection->d_output_bits); - } - } -} - -void -code_convolutional_trellis::demux_state -(memory_t in_state, - std::vector<memory_t>& memories) -{ - // de-mux bits for the given memory state; - // copy them into the provided vector; - // assumes state bits start after the LSB (not at &1) - - memories.resize (d_n_memories); - for (size_t m = 0; m < d_n_memories; m++) { - memories[m] = (in_state << 1) & d_max_mem_masks[m]; - in_state >>= d_n_delays[m]; - } -} - -memory_t -code_convolutional_trellis::mux_state -(const std::vector<memory_t>& memories) -{ - // mux bits for the given memory states in d_memory - // assumes state bits start after the LSB (not at &1) - - memory_t t_state = 0; - size_t shift = 0; - for (size_t m = 0; m < d_n_memories; m++) { - t_state |= (memories[m] >> 1) << shift; - shift += d_n_delays[m]; - } - return (t_state); -} - -void -code_convolutional_trellis::demux_inputs -(memory_t inputs, - std::vector<char>& in_vec) -{ - // de-mux bits for the given inputs; - // copy them into the provided vector; - - for (size_t m = 0; m < d_n_code_inputs; m++, inputs >>= 1) { - in_vec[m] = (char)(inputs & 1); - } -} - -memory_t -code_convolutional_trellis::mux_inputs -(const std::vector<char>& in_vec) -{ - // mux bits for the given inputs - - size_t bit_shift = 0; - memory_t inputs = 0; - for (size_t m = 0; m < in_vec.size(); m++, bit_shift++) { - inputs |= (((memory_t)(in_vec[m]&1)) << bit_shift); - } - return (inputs); -} - -void -code_convolutional_trellis::demux_outputs -(memory_t outputs, - std::vector<char>& out_vec) -{ - // de-mux bits for the given outputs; - // copy them into the provided vector; - - for (size_t m = 0; m < d_n_code_outputs; m++, outputs >>= 1) { - out_vec[m] = (char)(outputs & 1); - } -} - -memory_t -code_convolutional_trellis::mux_outputs -(const std::vector<char>& out_vec) -{ - // mux bits for the given outputs - - size_t bit_shift = 0; - memory_t outputs = 0; - for (size_t m = 0; m < out_vec.size(); m++, bit_shift++) { - outputs |= (((memory_t)(out_vec[m]&1)) << bit_shift); - } - return (outputs); -} - -void -code_convolutional_trellis::encode_single -(memory_t in_state, - memory_t inputs, - memory_t& out_state, - memory_t& out_bits) -{ - // set input parameters - - demux_state (in_state, d_memory); - demux_inputs (inputs, d_current_inputs); - - // call the correct function to do the work - - if (d_do_encode_soai == true) { - if (d_do_feedback == true) { - encode_single_soai_fb (); - } else { - encode_single_soai (); - } - } else { - if (d_do_feedback == true) { - encode_single_siao_fb (); - } else { - encode_single_siao (); - } - } - - // retrieve the output parameters - - out_state = mux_state (d_memory); - out_bits = mux_outputs (d_current_outputs); -} - -void -code_convolutional_trellis::encode_lookup -(memory_t& state, - const std::vector<char>& inputs, - memory_t& out_bits) -{ - if (DO_PRINT_DEBUG_LOOKUP) { - std::cout << "e_l: in_st = " << n2bs(state,d_total_n_delays) << - ", in = " << n2bs(mux_inputs(inputs),d_n_code_inputs); - } - - connection_t_ptr t_connection = &(d_trellis[state][mux_inputs(inputs)]); - state = t_connection->d_to_state; - out_bits = t_connection->d_output_bits; - - if (DO_PRINT_DEBUG_LOOKUP) { - std::cout << " -> out_st = " << n2bs(state,d_total_n_delays) << - ", out = " << n2bs(out_bits, d_n_code_outputs) << "\n"; - } -} - -void -code_convolutional_trellis::encode_lookup -(memory_t& state, - const std::vector<char>& inputs, - std::vector<char>& out_bits) -{ - if (DO_PRINT_DEBUG_LOOKUP) { - std::cout << "e_l: in_st = " << n2bs(state,d_total_n_delays) << - ", in = " << n2bs(mux_inputs(inputs),d_n_code_inputs); - } - - connection_t_ptr t_connection = &(d_trellis[state][mux_inputs(inputs)]); - state = t_connection->d_to_state; - demux_outputs (t_connection->d_output_bits, out_bits); - - if (DO_PRINT_DEBUG_LOOKUP) { - std::cout << " -> out_st = " << n2bs(state,d_total_n_delays) << - ", out = " << n2bs(t_connection->d_output_bits, - d_n_code_outputs) << "\n"; - } -} - -void -code_convolutional_trellis::create_termination_table -(memory_t end_memory_state) -{ - // somewhat involved, but basically start with the terminating state - // and work backwards d_total_n_delays, then create a - // std::vector<memory_t> of length n_states, once per path required - // to get from the given state to the desired termination state. - // - // each entry represents the bits required to terminate that - // particular state, listed in order from LSB for the first input - // bit to the MSB for the last input bit. - - // create a reverse trellis - // it's temporary, just for doing the termination, so just do it locally - - trellis_t t_trellis; - - // first dimension is the number of states - - t_trellis.resize (d_n_states); - - // second dimension (one per first dimension) is the number of input - // combinations; reserve so that the size() can be used for adding new - - for (size_t m = 0; m < d_n_states; m++) { - t_trellis[m].reserve (d_n_input_combinations); - } - - std::vector<memory_t> tmp(d_n_memories); - demux_state (end_memory_state, tmp); - - memory_t to_state, outputs; - connection_t t_conn; - - // fill in the trellis; discard the outputs - // set the trellis node's output bits to the input - - for (size_t m = 0; m < d_n_states; m++) { - for (size_t n = 0; n < d_n_input_combinations; n++) { - to_state = outputs = 0; - - encode_single ((memory_t) m, - (memory_t) n, - to_state, - outputs); - - t_conn.d_to_state = (memory_t) m; - t_conn.d_output_bits = (memory_t) n; - t_trellis[to_state].push_back (t_conn); - - if (DO_PRINT_DEBUG_TERM) { - std::cout << "[" << n2bs(m,d_total_n_delays) << "][" << - n2bs(n,d_n_code_inputs) << "] -> " << - n2bs(to_state, d_total_n_delays) << "\n"; - } - } - } - - if (DO_PRINT_DEBUG_TERM) { - std::cout << "Trellis:\n"; - - for (size_t m = 0; m < d_n_states; m++) { - for (size_t n = 0; n < d_n_input_combinations; n++) { - std::cout << "[" << n2bs(t_trellis[m][n].d_to_state, - d_total_n_delays) << "] : [" << - n2bs(t_trellis[m][n].d_output_bits, d_n_code_inputs) << "] -> " << - n2bs(m, d_total_n_delays) << "\n"; - } - } - } - - // need 2 of most buffers: one for the current-in-use variables, and - // one for the to-be-determined variables - - // create the term input bit vectors - - term_input_t t_term_inputs[2]; - t_term_inputs[0].resize (d_n_states); - for (size_t m = 0; m < d_n_states; m++) { - t_term_inputs[0][m].assign (d_n_code_inputs, 0); - } - t_term_inputs[1].resize (d_n_states); - for (size_t m = 0; m < d_n_states; m++) { - t_term_inputs[1][m].assign (d_n_code_inputs, 0); - } - - // create the list of "in-use" states for the current t_term_inputs - - std::vector<size_t> t_used_states_ndx[2]; - t_used_states_ndx[0].assign (d_n_states, 0); - t_used_states_ndx[1].assign (d_n_states, 0); - - std::vector<bool> t_in_use_states[2]; - t_in_use_states[0].assign (d_n_states, false); - t_in_use_states[1].assign (d_n_states, false); - - // termporary 'inputs' place holder, in order to use the class's - // built-in inputs demux'er. - - std::vector<char> t_inputs; - t_inputs.assign (d_n_code_inputs, 0); - - // setup the first state - - size_t t_which_input = 0; - t_used_states_ndx[t_which_input][0] = (size_t) end_memory_state; - t_in_use_states[t_which_input][(size_t) end_memory_state] = true; - size_t n_states_used[2]; - n_states_used[t_which_input] = 1; - n_states_used[t_which_input^1] = 0; - - // loop until either the number of states has been reached, or the - // number of input term bits (per stream) is too large (in which - // case this code can't be terminated ... shouldn't happen, but it's - // here just in case. - - size_t n_input_term_bits = 0; - - while ((n_states_used[t_which_input] < d_n_states) & - (n_input_term_bits < 2*d_total_n_delays)) { - - if (DO_PRINT_DEBUG_TERM) { - std::cout << "Starting loop:\n# states in use = " << - n_states_used[t_which_input] << " (of " << d_n_states << - "), # term bits = " << n_input_term_bits << " (of between " << - d_total_n_delays << " and " << (2*d_total_n_delays) << ")\n"; - } - - // loop over all current in-use states - - for (size_t m = 0; m < n_states_used[t_which_input]; m++) { - - // get the current state to work with - - size_t t_state_ndx = t_used_states_ndx[t_which_input][m]; - - for (size_t p = 0; p < d_n_input_combinations; p++) { - memory_t t_from_state = t_trellis[t_state_ndx][p].d_to_state; - if (t_in_use_states[t_which_input^1][t_from_state] == false) { - // not currently in use; make use of it - // if it's already in use, then why duplicate the inputs? - - memory_t t_input = t_trellis[t_state_ndx][p].d_output_bits; - - if (DO_PRINT_DEBUG_TERM) { - std::cout << "doing st[" << n2bs(t_state_ndx,d_total_n_delays) << - "] <- [" << n2bs(t_from_state,d_total_n_delays) << "]: in = " << - n2bs(t_input, d_n_code_inputs) << "\n"; - } - - // copy over the current state's input bits to the 'from' - // state's input bits, in the "current" term inputs - - t_term_inputs[t_which_input^1][t_from_state] = - t_term_inputs[t_which_input][t_state_ndx]; - - // update the copied bits with the current inputs, in the - // correct bit position: LSB (&1) -> first input, LSB+1 (&2) - // -> second input, etc... - - demux_inputs (t_input, t_inputs); - - for (size_t n = 0; n < d_n_code_inputs; n++) { - memory_t t_term = t_term_inputs[t_which_input^1][t_from_state][n]; - t_term <<= 1; - t_term |= ((memory_t)(t_inputs[n] & 1)); - t_term_inputs[t_which_input^1][t_from_state][n] = t_term; - } - - // add this from state to the list of states for the next run - - t_used_states_ndx[t_which_input^1][n_states_used[t_which_input^1]] = - t_from_state; - - // and set that this state is in use - - t_in_use_states[t_which_input^1][t_from_state] = true; - - // increase the number of next used states - - n_states_used[t_which_input^1] += 1; - } - } - } - - // update / reset variables for this run-through - - // swap buffers ("^1" is always the next set of buffers) - - t_which_input ^= 1; - - // zero the next # of states used - - n_states_used[t_which_input^1] = 0; - - // reset the next 'in use' buffer - - t_in_use_states[t_which_input^1].assign (d_n_states, false); - - // increase the number of required term bits (per stream) - - n_input_term_bits++; - } - - if (n_states_used[t_which_input] != d_n_states) { - std::cerr << "code_convolutional_trellis::create_termination_table: " - "Warning: Unable to determine all required termination inputs for the " - "provided termination state. Turning termination off.\n"; - d_do_termination = false; - } else { - d_n_bits_to_term = n_input_term_bits; - - d_term_inputs.resize (d_n_states); - for (size_t m = 0; m < d_n_states; m++) { - d_term_inputs[m].assign (d_n_code_inputs, 0); - } - - d_term_inputs = t_term_inputs[t_which_input]; - - if (DO_PRINT_DEBUG_TERM_END) { - std::cout << "# Term inputs / stream = " << d_n_bits_to_term << "\n"; - - for (size_t m = 0; m < d_n_states; m++) { - for (size_t n = 0; n < d_n_code_inputs; n++) { - std::cout << " [" << n2bs(m,d_total_n_delays) << "][" << n << - "] = " << n2bs(d_term_inputs[m][n], d_n_bits_to_term) << "\n"; - } - } - } - } -} - -void -code_convolutional_trellis::encode_single_soai -() -{ - // single-output, all inputs; no feedback - - if (DO_PRINT_DEBUG) { - std::cout << "Starting encode_single_soai.\n"; - } - - // shift memories down by 1 bit to make room for feedback; no - // masking required. - - for (size_t p = 0; p < d_n_memories; p++) { - if (DO_PRINT_DEBUG) { - std::cout << "m_i[" << p << "] = " << - n2bs(d_memory[p], 1+d_n_delays[p]); - } - - d_memory[p] >>= 1; - - if (DO_PRINT_DEBUG) { - std::cout << " >>= 1 -> " << - n2bs(d_memory[p], 1+d_n_delays[p]) << "\n"; - } - } - - // for each input bit, if that bit's a '1', then XOR the code - // generators into the correct state's memory. - - for (size_t m = 0; m < d_n_code_inputs; m++) { - if (DO_PRINT_DEBUG) { - std::cout << "c_i[" << m << "] = " << - n2bs(d_current_inputs[m],1); - } - if (d_current_inputs[m] == 1) { - if (DO_PRINT_DEBUG) { - std::cout << "\n"; - } - for (size_t n = 0; n < d_n_code_outputs; n++) { - if (DO_PRINT_DEBUG) { - std::cout << "m_i[s_ndx[" << m << "][" << n << "] == " << - d_states_ndx[maio(m,n)] << "] = " << - n2bs(d_memory[d_states_ndx[maio(m,n)]], - 1+d_n_delays[d_states_ndx[maio(m,n)]]); - } - - d_memory[d_states_ndx[maio(m,n)]] ^= d_code_generators[maio(m,n)]; - - if (DO_PRINT_DEBUG) { - std::cout << " ^= c_g[][] == " << - n2bs(d_code_generators[maio(m,n)], - 1+d_n_delays[d_states_ndx[maio(m,n)]]) << - " -> " << n2bs(d_memory[d_states_ndx[maio(m,n)]], - 1+d_n_delays[d_states_ndx[maio(m,n)]]) << "\n"; - } - } - } else if (DO_PRINT_DEBUG) { - std::cout << " ... nothing to do\n"; - } - } - - for (size_t p = 0; p < d_n_code_outputs; p++) { - d_current_outputs[p] = 0; - } - - // create the output bits, by XOR'ing the individual unique - // memory(ies) into the correct output bit - - for (size_t p = 0; p < d_n_memories; p++) { - d_current_outputs[d_io_num[p]] ^= ((char)(d_memory[p] & 1)); - } - - if (DO_PRINT_DEBUG) { - std::cout << "ending encode_single_soai.\n"; - } -} - -void -code_convolutional_trellis::encode_single_soai_fb -() -{ - // single-output, all inputs; with feedback - - if (DO_PRINT_DEBUG) { - std::cout << "Starting encode_single_soai_fb.\n"; - } - - // shift memories down by 1 bit to make room for feedback; no - // masking required. - - for (size_t p = 0; p < d_n_memories; p++) { - if (DO_PRINT_DEBUG) { - std::cout << "m_i[" << p << "] = " << - n2bs(d_memory[p], 1+d_n_delays[p]); - } - - d_memory[p] >>= 1; - - if (DO_PRINT_DEBUG) { - std::cout << " >>= 1 -> " << - n2bs(d_memory[p], 1+d_n_delays[p]) << "\n"; - } - } - - // for each input bit, if that bit's a '1', then XOR the code - // generators into the correct state's memory. - - for (size_t m = 0; m < d_n_code_inputs; m++) { - if (DO_PRINT_DEBUG) { - std::cout << "in[" << m << "] = " << ((int)d_current_inputs[m]) << "\n"; - } - - if (d_current_inputs[m] == 1) { - for (size_t n = 0; n < d_n_code_outputs; n++) { - if (DO_PRINT_DEBUG) { - size_t p = d_states_ndx[maio(m,n)]; - std::cout << "d_m[" << p << "] = " << - n2bs(d_memory[p], 1+d_n_delays[p]) << - " ^= c_g[" << maio(m,n) << "] = " << - n2bs(d_code_generators[maio(m,n)],1+d_n_delays[p]); - } - - d_memory[d_states_ndx[maio(m,n)]] ^= d_code_generators[maio(m,n)]; - - if (DO_PRINT_DEBUG) { - size_t p = d_states_ndx[maio(m,n)]; - std::cout << " -> " << n2bs(d_memory[p],1+d_n_delays[p]) << "\n"; - } - } - } - } - - for (size_t p = 0; p < d_n_code_outputs; p++) { - d_current_outputs[p] = 0; - } - - // create the output bits, by XOR'ing the individual unique - // memory(ies) into the correct output bit - - for (size_t p = 0; p < d_n_memories; p++) { - if (DO_PRINT_DEBUG) { - std::cout << "c_o[" << d_io_num[p] << "] = " << - n2bs(d_current_outputs[d_io_num[p]],1) << " ^= m[" << - p << "]&1 = " << n2bs(d_memory[p],1); - } - - d_ind_outputs[p] = ((char)(d_memory[p] & 1)); - d_current_outputs[d_io_num[p]] ^= d_ind_outputs[p]; - - if (DO_PRINT_DEBUG) { - std::cout << " -> " << n2bs(d_current_outputs[d_io_num[p]],1) << "\n"; - } - } - - // now that the output bits are fully created, XOR the FB back - // into the memories; the feedback bits have the LSB (&1) masked - // off already so that it doesn't contribute. - - for (size_t p = 0; p < d_n_memories; p++) { - if (DO_PRINT_DEBUG) { - std::cout << "i_o[" << p << "] = " << - n2bs(d_ind_outputs[p],1) << ", m[" << p << "] = " << - n2bs(d_memory[p],1+d_n_delays[p]); - } - - if (d_ind_outputs[p] == 1) { - d_memory[p] ^= d_code_feedback[p]; - - if (DO_PRINT_DEBUG) { - std::cout << " ^= c_f[" << p << "] = " << - n2bs(d_code_feedback[p],1+d_n_delays[p]) << - " -> " << n2bs(d_memory[p],1+d_n_delays[p]); - } - } - if (DO_PRINT_DEBUG) { - std::cout << "\n"; - } - } - - if (DO_PRINT_DEBUG) { - std::cout << "ending encode_single_soai_fb.\n"; - } -} - -void -code_convolutional_trellis::encode_single_siao -() -{ - // single input, all outputs; no feedback - - if (DO_PRINT_DEBUG) { - std::cout << "starting encode_single_siao.\n"; - } - - // update the memories with the current input bits; - - // for each unique memory (1 per input), shift the delays and mask - // off the extra high bits; then XOR in the input bit. - - for (size_t p = 0; p < d_n_memories; p++) { - d_memory[p] |= ((memory_t)(d_current_inputs[d_io_num[p]])); - } - - // create the output bits: for each output, loop over all inputs, - // find the output bits for each encoder, and XOR each together - // then sum (would usually be sum then XOR, but they're mutable in - // base-2 and it's faster this way). - - for (size_t n = 0; n < d_n_code_outputs; n++) { - memory_t t_mem = 0; - for (size_t m = 0; m < d_n_code_inputs; m++) { - t_mem ^= ((d_memory[d_states_ndx[maio(m,n)]]) & - d_code_generators[maio(m,n)]); - } - d_current_outputs[n] = sum_bits_mod2 (t_mem, d_max_delay); - } - - // post-shift & mask the memory to guarantee that output - // state is in the correct bit positions (1 up, not the LSB) - - for (size_t p = 0; p < d_n_memories; p++) { - d_memory[p] = (d_memory[p] << 1) & d_max_mem_masks[p]; - } - - if (DO_PRINT_DEBUG) { - std::cout << "ending encode_single_siao.\n"; - } -} - -void -code_convolutional_trellis::encode_single_siao_fb -() -{ - // single input, all outputs; with feedback - - if (DO_PRINT_DEBUG) { - std::cout << "starting encode_single_siao_fb.\n"; - } - - // update the memories with the current input bits; - - // for each unique memory (1 per input), shift the delays and mask - // off the extra high bits; then XOR in the input bit. - // with FB: find the feedback bit, and OR it into the input bit's slot; - - for (size_t p = 0; p < d_n_memories; p++) { - memory_t t_mem = d_memory[p]; - memory_t t_fb = t_mem & d_code_feedback[p]; - char t_fb_bit = sum_bits_mod2 (t_fb, d_max_delay); - t_mem |= ((memory_t) t_fb_bit); - d_memory[p] = t_mem ^ ((memory_t)(d_current_inputs[d_io_num[p]])); - } - - // create the output bits: for each output, loop over all inputs, - // find the output bits for each encoder, and XOR each together - // then sum (would usually be sum then XOR, but they're mutable in - // base-2 and it's faster this way). - - for (size_t n = 0; n < d_n_code_outputs; n++) { - memory_t t_mem = 0; - for (size_t m = 0; m < d_n_code_inputs; m++) { - t_mem ^= ((d_memory[d_states_ndx[maio(m,n)]]) & - d_code_generators[maio(m,n)]); - } - d_current_outputs[n] = sum_bits_mod2 (t_mem, d_max_delay); - } - - // post-shift & mask the memory to guarantee that output - // state is in the correct bit positions (1 up, not the LSB) - - for (size_t p = 0; p < d_n_memories; p++) { - d_memory[p] = (d_memory[p] << 1) & d_max_mem_masks[p]; - } - - if (DO_PRINT_DEBUG) { - std::cout << "ending encode_loop_siao_fb.\n"; - } -} diff --git a/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.h b/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.h deleted file mode 100644 index 33f58d23c..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.h +++ /dev/null @@ -1,405 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_CODE_CONVOLUTIONAL_TRELLIS_H -#define INCLUDED_CODE_CONVOLUTIONAL_TRELLIS_H - -#include "code_types.h" -#include <vector> - -/* - * connection_t: describes an output connection from the current - * time-bit memory state to the next time-bit memory state - * - * d_to_state: memory configuration of the "to" state - * - * d_output_bits: the output bits for this connection, mux'ed - */ - -typedef struct connection_t { - memory_t d_to_state; - memory_t d_output_bits; -} connection_t, *connection_t_ptr; - -/* - * trellis_t: describes a single set of trellis connections, from a - * time-bit to the next, forward transitions only - * - * This is a 2d "matrix", where the first dimention is the starting - * memory state, and the second is the (combined) input as an - * integer: e.g. for a 2 input code, if I1 = 0 and I2 = 1, then - * the combined input is the "number" found by appending I2 and I1 - * together, in this case 10b = 3. - * - * The trellis is used to lookup information: given a starting state - * and inputs, return the output bits and next state. - */ - -typedef std::vector<std::vector<connection_t> > trellis_t, *trellis_t_ptr; - -class code_convolutional_trellis -{ -/*! - * class code_convolutional_trellis - * - * Create a convolutional code trellis structure, but encoding, - * decoding, determining termination transitions, and anything else - * which might be useful. - * - * block_size_bits: if == 0, then do streaming encoding ("infinite" - * trellis); otherwise this is the block size in bits to encode - * before terminating the trellis. This value -does not- include - * any termination bits. - * - * n_code_inputs: - * n_code_outputs: - * code_generator: vector of integers (32 bit) representing the code - * to be implemented. E.g. "4" in binary is "100", which would be - * "D^2" for code generation. "6" == 110b == "D^2 + D" - * ==> The vector is listed in order for each output stream, so if there - * are 2 input streams (I1, I2) [specified in "n_code_inputs"] - * and 2 output streams (O1, O2) [specified in "n_code_outputs"], - * then the vector would be the code generator for: - * [I1->O1, I2->O1, I1->O2, I2->O2] - * with each element being an integer representation of the code. - * The "octal" representation is used frequently in the literature - * (e.g. [015, 06] == [1101, 0110] in binary) due to its close - * relationship with binary (each number is 3 binary digits) - * ... but any integer representation will suffice. - * - * do_termination: valid only if block_size_bits != 0, and defines - * whether or not to use trellis termination. Default is to use - * termination when doing block coding. - * - * start_memory_state: when starting a new block, the starting memory - * state to begin encoding; there will be a helper function to - * assist in creating this value for a given set of inputs; - * default is the "all zero" state. - * - * end_memory_state: when terminating a block, the ending memory - * state to stop encoding; there will be a helper function to - * assist in creating this value for a given set of inputs; - * default is the "all zero" state. - */ - -public: - inline code_convolutional_trellis - (int block_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generators, - bool do_termination = true, - int end_memory_state = 0) - {code_convolutional_trellis_init (block_size_bits, - n_code_inputs, - n_code_outputs, - code_generators, - NULL, - do_termination, - end_memory_state);}; - -/*! - * Encoder with feedback. - * - * code_feedback: vector of integers (32 bit) representing the code - * feedback to be implemented (same as for the code_generator). - * For this feedback type, the LSB ("& 1") is ignored (set to "1" - * internally, since it's always 1) ... this (effectively) - * represents the input bit for the given encoder, without which - * there would be no encoding! Each successive higher-order bit - * represents the output of that delay block; for example "6" == - * 110b == "D^2 + D" means use the current input bit + the output - * of the second delay block. Listing order is the same as for - * the code_generator. - */ - - inline code_convolutional_trellis - (int block_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generators, - const std::vector<int> &code_feedback, - bool do_termination = true, - int end_memory_state = 0) - {code_convolutional_trellis_init (block_size_bits, - n_code_inputs, - n_code_outputs, - code_generators, - &code_feedback, - do_termination, - end_memory_state);}; - - virtual ~code_convolutional_trellis () {}; - -/* for remote access to internal info */ - - inline const size_t block_size_bits () {return (d_block_size_bits);}; - inline const size_t n_code_inputs () {return (d_n_code_inputs);}; - inline const size_t n_code_outputs () {return (d_n_code_outputs);}; - inline const size_t n_states () {return (d_n_states);}; - inline const size_t n_input_combinations () - {return (d_n_input_combinations);}; - inline const bool do_termination () {return (d_do_termination);}; - inline const bool do_feedback () {return (d_do_feedback);}; - inline const bool do_streaming () {return (d_do_streaming);}; - inline const bool do_encode_soai () {return (d_do_encode_soai);}; - inline const size_t total_n_delays () {return (d_total_n_delays);}; - inline const size_t n_bits_to_term () {return (d_n_bits_to_term);}; - - virtual char sum_bits_mod2 (memory_t in_mem, size_t max_memory); - void get_termination_inputs (memory_t term_start_state, - size_t bit_num, - std::vector<char>& inputs) { - // no error checking ... be careful! - for (size_t m = 0; m < d_n_code_inputs; m++) { - inputs[m] = ((d_term_inputs[term_start_state][m]) >> bit_num) & 1; - } - }; - - // encode_lookup: given the starting state and inputs, return the - // resulting state and output bits. Two versions: the first is - // better for decoding, while the second is better for encoding. - - void encode_lookup (memory_t& state, - const std::vector<char>& inputs, - memory_t& out_bits); - void encode_lookup (memory_t& state, - const std::vector<char>& inputs, - std::vector<char>& out_bits); - - // methods for setting and retrieving the state, inputs, and outputs. - - void demux_state (memory_t in_state, std::vector<memory_t>& memories); - memory_t mux_state (const std::vector<memory_t>& memories); - void demux_inputs (memory_t inputs, std::vector<char>& in_vec); - memory_t mux_inputs (const std::vector<char>& in_vec); - void demux_outputs (memory_t outputs, std::vector<char>& out_vec); - memory_t mux_outputs (const std::vector<char>& out_vec); - -protected: -#if 0 -/* - * state_get_from(v,i,k): use to retrieve a given bit-memory state, - * from the inputs: - * - * memory_t v: the value from which to retrieve the given state - * size_t i: for which input stream (0 to #I-1) - * size_t k: the number of memory slots per input (e.g. 1+D^2 -> 2) - */ - - inline memory_t state_get_from (memory_t v, - size_t i, - size_t k) - {return (((v)>>((i)*(k)))&((1<<(k))-1));}; - -/* - * state_add_to(s,v,i,k): use to create a given bit-memory state, - * from the inputs: - * - * memory_t s: the state value to modify - * memory_t v: value to set the state to for this input - * size_t i: for which input stream (0 to #I-1) - * size_t k: the number of memory slots per input (e.g. 1+D^2 -> 2) - */ - - inline void state_add_to (memory_t s, - memory_t v, - size_t i, - size_t k) - {(s)|=(((v)&((1<<(k))-1))<<((i)*(k)));}; -#endif - -/* - * maio(i,o): matrix access into a vector, knowing the # of code - * outputs (from inside the class). References into a vector with - * code inputs ordered by code output. - * - * 'i' is the 1st dimension - faster memory - the code input - * 'o' is the 2nd dimension - slower memory - the code output - * - * returns ((o*n_code_inputs) + i) - */ - - inline size_t maio(size_t i, size_t o) {return ((o*d_n_code_inputs) + i);}; - -/* - * maoi(i,o): matrix access into a vector, knowing the # of code - * inputs (from inside the class). References into a vector with - * code outputs ordered by code input. - * - * 'o' is the 1st dimension - faster memory - the code output - * 'i' is the 2nd dimension - slower memory - the code input - * - * returns ((i*n_code_outputs) + o) - */ - - inline size_t maoi(size_t i, size_t o) {return ((i*d_n_code_outputs) + o);}; - -/* - * max_bit_position (x): returns the bit-number of the highest "1" bit - * in the provided value, such that the LSB would return 0 and the MSB - * of a long would return 31. - */ - - inline size_t max_bit_position (memory_t x) - { - size_t t_code_mem = 0; - memory_t t_in_code = x >> 1; - while (t_in_code != 0) { - t_in_code >>= 1; - t_code_mem++; - } - - return (t_code_mem); - } - - // methods defined in this class - - void code_convolutional_trellis_init - (int block_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generators, - const std::vector<int>* code_generators, - bool do_termination, - int end_memory_state); - - void create_trellis (); - void create_termination_table (memory_t end_memory_state); - void encode_single (memory_t in_state, - memory_t inputs, - memory_t& out_state, - memory_t& out_bits); - virtual void encode_single_soai (); - virtual void encode_single_siao (); - virtual void encode_single_soai_fb (); - virtual void encode_single_siao_fb (); - - void get_memory_requirements (size_t m, - size_t n, - size_t& t_max_mem, - size_t& t_n_unique_fb_prev_start, - const std::vector<int>* code_feedback); - - // variables - - size_t d_block_size_bits, d_n_code_outputs; - size_t d_n_code_inputs, d_n_input_combinations; - bool d_do_streaming, d_do_termination, d_do_feedback, d_do_encode_soai; - - // "max_delay" is the max # of delays for all unique generators (ff and fb), - - size_t d_max_delay; - - // "n_memories" is the number of unique memories as determined by - // either the feedforward or feedback generators (not both). For - // FF, this number equals either the number of code inputs (for - // SIAO) or outputs (for SOAI). - - size_t d_n_memories; - - // "total_n_delays" is the total # of delays, needed to determine the - // # of states in the decoder - // "n_states" = (2^total_n_delays) - 1 .. the number of memory states - - size_t d_total_n_delays, d_n_states; - - // "code generators" are stored internally in "maXY(i,o)" order this - // allows for looping over all a single output and computing all - // input parts sequentially. - - std::vector<memory_t> d_code_generators; - - // "feedback" are found as "d_n_memories" unique entries, and stored - // in at most 1 entry per I/O combination. Listed in the same order - // as "d_io_num" entries show. - - std::vector<memory_t> d_code_feedback; - - // "n_delays" is a vector, the number of delays for the FB generator - // in the same [] location; also relates directly to the - // "max_mem_masks" in the same [] location. - - std::vector<size_t> d_n_delays; - - // "io_num" is a vector, mapping which FB in SIAO goes with which - // input, or which FB in SOAI goes with which output - - std::vector<size_t> d_io_num; - - // "max_mem_masks" are the memory masks, one per unique FB for SIAO; - // otherwise not used. - - std::vector<size_t> d_states_ndx; - - // "memory" are the actual stored delay bits, one memory for each - // unique FF or FB code generator; - // interpreted w/r.t. the actual FF and FB code generators and - // SOAI / SIAO realization; - - std::vector<memory_t> d_max_mem_masks; - - // "states_ndx" is a "matrix" whose contents are the indices into - // the "io_num" vector, telling which input goes with which - // state; uses the same "maXY(i,o)" as the code generators. - - std::vector<memory_t> d_memory; - - // "term_inputs" are the inputs required to terminate the trellis - - // interpreted w/r.t. the actual FF and FB code generators and - // SOAI / SIAO realization; - // first dimension is the memory state #; - // second dimension is the input stream #; - // bits are packed, with the first input being the LSB and the last - // input being farthest away from the LSB. - - typedef std::vector<std::vector<memory_t> > term_input_t; - term_input_t d_term_inputs; - - // "n_bits_to_term" is the number of bits to terminate the trellis - // to the desired state, as determined by the termination table. - // d_max_delay <= d_n_bits_to_term <= d_total_n_delays - // These numbers will vary depending on the realization. - - size_t d_n_bits_to_term; - - // "inputs" are the current input bits, in the LSB (&1) of each "char" - - std::vector<char> d_current_inputs; - - // "outputs" are the current output bits, in the LSB (&1) of each "char" - - std::vector<char> d_current_outputs; - - // "ind_outputs" are the current output bits, in the LSB (&1) of - // each "char", for each individual memory's computations; needed - // for soai-type feedback only - - std::vector<char> d_ind_outputs; - - // "trellis" is the single-stage memory state transition ("trellis") - // representation for this code; forward paths only - - trellis_t d_trellis; -}; - -#endif /* INCLUDED_CODE_CONVOLUTIONAL_TRELLIS_H */ diff --git a/gr-error-correcting-codes/src/lib/libecc/code_io.cc b/gr-error-correcting-codes/src/lib/libecc/code_io.cc deleted file mode 100644 index f917e7d03..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/code_io.cc +++ /dev/null @@ -1,33 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <code_io.h> - -#define DO_PRINT_DEBUG 0 - -static const int g_num_bits_per_byte = 8; - -// nothing yet ... it's all in the header file for now. diff --git a/gr-error-correcting-codes/src/lib/libecc/code_io.h b/gr-error-correcting-codes/src/lib/libecc/code_io.h deleted file mode 100644 index 815287069..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/code_io.h +++ /dev/null @@ -1,556 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_CODE_IO_H -#define INCLUDED_CODE_IO_H - -#include "code_types.h" -#include <vector> -#include <assert.h> -#include <iostream> - -/* - * code_io provides classes which do the input and output for these - * codes. One can add another class with its specific needs primarily - * by changing the way that the provided data is manipulated to read - * or write data items. - */ - -/* - * combined io classes - */ - -class code_io -{ -public: - inline code_io (size_t n_streams) { - if (n_streams < 1) { - std::cerr << "code_io::code_io: Error:" << - "Provided # of streams (" << n_streams << - ") must be at least 1.\n"; - assert (0); - } - d_n_streams = n_streams; - d_buf_ptrs.resize (d_n_streams); - }; - - virtual ~code_io () {}; - - inline void set_buffer (void** buffer, size_t n_items) { - if (buffer == 0) { - std::cerr << "code_io::set_buffer: Error:" << - "Provided buffer is NULL.\n"; - assert (0); - } - if (n_items == 0) { - std::cerr << "code_io::set_buffer: Warning:" << - "Provided # of items is 0!\n"; - } - d_buf = buffer; - d_n_items = d_n_items_left = n_items; - for (size_t m = 0; m < d_n_streams; m++) { - d_buf_ptrs[m] = d_buf[m]; - } - }; - - inline void set_buffer (std::vector<void*>* buffer, size_t n_items) { - set_buffer (&((*buffer)[0]), n_items);}; - - inline void set_buffer (std::vector<void*>& buffer, size_t n_items) { - set_buffer (&(buffer[0]), n_items);}; - - inline virtual void increment_indices () { - if (d_n_items_left == 0) { - std::cerr << "code_io::increment_indices: Warning: " - "No items left!\n"; - } else - d_n_items_left--; - }; - - // methods for getting info on class internals - - const size_t& n_items_left () {return (d_n_items_left);}; - const size_t n_items_used () {return (d_n_items - d_n_items_left);}; - const size_t n_streams () {return (d_n_streams);}; - -protected: - void** d_buf; - std::vector<void*> d_buf_ptrs; - size_t d_n_streams, d_n_items, d_n_items_left; -}; - -/* - * input classes - */ - -class code_input : public code_io -{ -public: - inline code_input (size_t n_streams) : code_io (n_streams) {}; - virtual ~code_input () {}; - virtual void read_item (void* item, size_t stream_n) = 0; - virtual void read_items (void* items) = 0; - inline virtual void increment_indices () {code_io::increment_indices ();}; -}; - -typedef code_input* code_input_ptr; - -class code_input_id : public code_input -{ -private: - typedef double input_t; - -public: -/*! - * class code_input_id : public code_input - * - * "id": - * 'i': one stream per code input as defined by the instantiated - * code ("individual", not mux'ed); - * 'f': streams of double; - */ - inline code_input_id (size_t n_streams) : code_input (n_streams) {}; - virtual ~code_input_id () {}; - - inline virtual void read_item (void* item, size_t stream_n) { - /* no error checking for better speed! */ - input_t* t_item = (input_t*) item; - (*t_item) = (*((input_t*)(d_buf_ptrs[stream_n]))); - }; - inline virtual void read_items (void* items) { - /* no error checking for better speed! */ - input_t* t_items = (input_t*) items; - for (size_t m = 0; m < d_n_streams; m++) { - t_items[m] = (*((input_t*)(d_buf_ptrs[m]))); - } - }; - inline virtual void increment_indices () { - code_input::increment_indices (); - for (size_t m = 0; m < d_n_streams; m++) { - input_t* t_buf = (input_t*) d_buf_ptrs[m]; - d_buf_ptrs[m] = (void*)(++t_buf); - } - }; -}; - -class code_input_if : public code_input -{ -private: - typedef float input_t; - -public: -/*! - * class code_input_if : public code_input - * - * "if": - * 'i': one stream per code input as defined by the instantiated - * code ("individual", not mux'ed); - * 'f': streams of float; - */ - inline code_input_if (size_t n_streams) : code_input (n_streams) {}; - virtual ~code_input_if () {}; - - inline virtual void read_item (void* item, size_t stream_n) { - /* no error checking for better speed! */ - input_t* t_item = (input_t*) item; - (*t_item) = (*((input_t*)(d_buf_ptrs[stream_n]))); - }; - inline virtual void read_items (void* items) { - /* no error checking for better speed! */ - input_t* t_items = (input_t*) items; - for (size_t m = 0; m < d_n_streams; m++) { - t_items[m] = (*((input_t*)(d_buf_ptrs[m]))); - } - }; - inline virtual void increment_indices () { - code_input::increment_indices (); - for (size_t m = 0; m < d_n_streams; m++) { - input_t* t_buf = (input_t*) d_buf_ptrs[m]; - d_buf_ptrs[m] = (void*)(++t_buf); - } - }; -}; - -class code_input_ic : public code_input -{ -private: - typedef char input_t; - -public: -/*! - * class code_input_is : public code_input - * - * "ic": - * 'i': one stream per code input as defined by the instantiated - * code ("individual", not mux'ed); - * 'c': streams of char; - */ - inline code_input_ic (size_t n_streams) : code_input (n_streams) {}; - virtual ~code_input_ic () {}; - - inline virtual void read_item (void* item, size_t stream_n) { - /* no error checking for better speed! */ - input_t* t_item = (input_t*) item; - (*t_item) = (*((input_t*)(d_buf_ptrs[stream_n]))); - }; - inline virtual void read_items (void* items) { - /* no error checking for better speed! */ - input_t* t_items = (input_t*) items; - for (size_t m = 0; m < d_n_streams; m++) { - t_items[m] = (*((input_t*)(d_buf_ptrs[m]))); - } - }; - inline virtual void increment_indices () { - code_input::increment_indices (); - for (size_t m = 0; m < d_n_streams; m++) { - input_t* t_buf = (input_t*) d_buf_ptrs[m]; - d_buf_ptrs[m] = (void*)(++t_buf); - } - }; -}; - -class code_input_is : public code_input -{ -private: - typedef short input_t; - -public: -/*! - * class code_input_is : public code_input - * - * "is": - * 'i': one stream per code input as defined by the instantiated - * code ("individual", not mux'ed); - * 's': streams of short; - */ - inline code_input_is (size_t n_streams) : code_input (n_streams) {}; - virtual ~code_input_is () {}; - - inline virtual void read_item (void* item, size_t stream_n) { - /* no error checking for better speed! */ - input_t* t_item = (input_t*) item; - (*t_item) = (*((input_t*)(d_buf_ptrs[stream_n]))); - }; - inline virtual void read_items (void* items) { - /* no error checking for better speed! */ - input_t* t_items = (input_t*) items; - for (size_t m = 0; m < d_n_streams; m++) { - t_items[m] = (*((input_t*)(d_buf_ptrs[m]))); - } - }; - inline virtual void increment_indices () { - code_input::increment_indices (); - for (size_t m = 0; m < d_n_streams; m++) { - input_t* t_buf = (input_t*) d_buf_ptrs[m]; - d_buf_ptrs[m] = (void*)(++t_buf); - } - }; -}; - -class code_input_il : public code_input -{ -private: - typedef long input_t; - -public: -/*! - * class code_input_il : public code_input - * - * "il": - * 'i': one stream per code input as defined by the instantiated - * code ("individual", not mux'ed); - * 'l': streams of long; - */ - inline code_input_il (size_t n_streams) : code_input (n_streams) {}; - virtual ~code_input_il () {}; - - inline virtual void read_item (void* item, size_t stream_n) { - /* no error checking for better speed! */ - input_t* t_item = (input_t*) item; - (*t_item) = (*((input_t*)(d_buf_ptrs[stream_n]))); - }; - inline virtual void read_items (void* items) { - /* no error checking for better speed! */ - input_t* t_items = (input_t*) items; - for (size_t m = 0; m < d_n_streams; m++) { - t_items[m] = (*((input_t*)(d_buf_ptrs[m]))); - } - }; - inline virtual void increment_indices () { - code_input::increment_indices (); - for (size_t m = 0; m < d_n_streams; m++) { - input_t* t_buf = (input_t*) d_buf_ptrs[m]; - d_buf_ptrs[m] = (void*)(++t_buf); - } - }; -}; - -class code_input_ill : public code_input -{ -private: - typedef long long input_t; - -public: -/*! - * class code_input_ill : public code_input - * - * "ill": - * 'i': one stream per code input as defined by the instantiated - * code ("individual", not mux'ed); - * 'll': streams of long long; - */ - inline code_input_ill (size_t n_streams) : code_input (n_streams) {}; - virtual ~code_input_ill () {}; - - inline virtual void read_item (void* item, size_t stream_n) { - /* no error checking for better speed! */ - input_t* t_item = (input_t*) item; - (*t_item) = (*((input_t*)(d_buf_ptrs[stream_n]))); - }; - inline virtual void read_items (void* items) { - /* no error checking for better speed! */ - input_t* t_items = (input_t*) items; - for (size_t m = 0; m < d_n_streams; m++) { - t_items[m] = (*((input_t*)(d_buf_ptrs[m]))); - } - }; - inline virtual void increment_indices () { - code_input::increment_indices (); - for (size_t m = 0; m < d_n_streams; m++) { - input_t* t_buf = (input_t*) d_buf_ptrs[m]; - d_buf_ptrs[m] = (void*)(++t_buf); - } - }; -}; - -class code_input_ic1 : public code_input -{ -public: -/*! - * class code_input_ic1 : public code_input - * - * "ic": - * 'i': one stream per code input as defined by the instantiated - * code ("individual", not mux'ed); - * 'c': streams of char; - * '1': single bit per char; - * --> which bit to choose left to an inheriting class - */ - - inline code_input_ic1 (size_t n_streams) : code_input (n_streams) {}; - virtual ~code_input_ic1 () {}; - - inline virtual void read_item (void* item, size_t stream_n) { - /* no error checking for better speed! */ - char* t_item = (char*) item; - (*t_item) = (*((char*)(d_buf_ptrs[stream_n]))) & d_which_bit; - }; - inline virtual void read_items (void* items) { - /* no error checking for better speed! */ - char* t_items = (char*) items; - for (size_t m = 0; m < d_n_streams; m++) { - t_items[m] = (*((char*)(d_buf_ptrs[m]))) & d_which_bit; - } - }; - inline virtual void increment_indices () { - code_input::increment_indices (); - for (size_t m = 0; m < d_n_streams; m++) { - char* t_buf = (char*) d_buf_ptrs[m]; - d_buf_ptrs[m] = (void*)(++t_buf); - } - }; - -protected: - char d_which_bit; -}; - -class code_input_ic1l : public code_input_ic1 -{ -public: -/*! - * class code_input_ic1l : public code_input_ic1 - * - * "ic1l": - * 'i': one stream per code input as defined by the instantiated - * code ("individual", not mux'ed); - * 'c': streams of char; - * '1': single bit per char; - * 'l': using only the LSB of the char. - */ - - inline code_input_ic1l (size_t n_streams) : - code_input_ic1 (n_streams) {d_which_bit = 1;}; - virtual ~code_input_ic1l () {}; -}; - -class code_input_ic1h : public code_input_ic1 -{ -public: -/*! - * class code_input_ic1h : public code_input_ic1 - * - * "ic1h": - * 'i': one stream per code input as defined by the instantiated - * code ("individual", not mux'ed); - * 'c': streams of char; - * '1': single bit per char; - * 'h': using only the MSB of the char. - */ - - inline code_input_ic1h (size_t n_streams) - : code_input_ic1 (n_streams) {d_which_bit = 128;}; - virtual ~code_input_ic1h () {}; -}; - -class code_input_ic8l : public code_input_ic1l -{ -protected: - size_t d_bit_shift; - const static size_t g_num_bits_per_byte = 8; - -public: -/*! - * class code_input_ic8l : public code_input_ic1l - * - * "ic8l": - * 'i': one stream per code input as defined by the instantiated - * code ("individual", not mux'ed); - * 'c': streams of char; - * '8': using all 8 bits per char; - * 'l': starting with the LSB and working up - */ - - inline code_input_ic8l (size_t n_streams) : - code_input_ic1l (n_streams) {d_bit_shift = 0;}; - - virtual ~code_input_ic8l () {}; - - inline virtual void increment_indices () { - code_input::increment_indices (); - if (++d_bit_shift % g_num_bits_per_byte == 0) { - d_bit_shift = 0; - for (size_t m = 0; m < d_n_streams; m++) { - char* t_buf = (char*) d_buf_ptrs[m]; - d_buf_ptrs[m] = (void*)(++t_buf); - } - } else { - for (size_t m = 0; m < d_n_streams; m++) { - char* t_buf = (char*) d_buf_ptrs[m]; - (*t_buf) >>= 1; - } - } - }; -}; - -class code_input_ic8h : public code_input_ic1h -{ -protected: - size_t d_bit_shift; - const static size_t g_num_bits_per_byte = 8; - -public: -/*! - * class code_input_ic8h : public code_input_ic1h - * - * "ic8h": - * 'i': one stream per code input as defined by the instantiated - * code ("individual", not mux'ed); - * 'c': streams of char; - * '8': using all 8 bits per char; - * 'h': starting with the MSB and working down - */ - - inline code_input_ic8h (size_t n_streams) : - code_input_ic1h (n_streams) {d_bit_shift = 0;}; - - virtual ~code_input_ic8h () {}; - - inline virtual void increment_indices () { - code_input::increment_indices (); - if (++d_bit_shift % g_num_bits_per_byte == 0) { - d_bit_shift = 0; - for (size_t m = 0; m < d_n_streams; m++) { - char* t_buf = (char*) d_buf_ptrs[m]; - d_buf_ptrs[m] = (void*)(++t_buf); - } - } else { - for (size_t m = 0; m < d_n_streams; m++) { - char* t_buf = (char*) d_buf_ptrs[m]; - (*t_buf) <<= 1; - } - } - }; -}; - -/* - * output classes - */ - -class code_output : public code_io -{ -public: - code_output (size_t n_streams) : code_io (n_streams) {}; - virtual ~code_output () {}; - virtual void write_item (const void* item, size_t stream_n) = 0; - virtual void write_items (const void* items) = 0; - virtual inline void increment_indices () {code_io::increment_indices ();}; -}; - -typedef code_output* code_output_ptr; - -class code_output_ic1l : public code_output -{ -public: -/*! - * class code_output_ic1l : public code_output - * - * 'i': one stream per code input as defined by the instantiated - * code ("individual", not mux'ed); - * 'c': streams of char; - * '1': single bit per char; - * 'l': using only the right-most justified (LSB). - */ - - inline code_output_ic1l (size_t n_streams) : code_output (n_streams) {}; - virtual ~code_output_ic1l () {}; - - inline virtual void write_item (const void* item, size_t stream_n) { - /* no error checking for better speed! */ - const char* t_item = (char*) item; - (*((char*)(d_buf_ptrs[stream_n]))) = (*t_item) & 1; - }; - inline virtual void write_items (const void* items) { - /* no error checking for better speed! */ - const char* t_items = (char*) items; - for (size_t m = 0; m < d_n_streams; m++) - (*((char*)(d_buf_ptrs[m]))) = (t_items[m]) & 1; - }; - inline virtual void increment_indices () { - code_output::increment_indices (); - for (size_t m = 0; m < d_n_streams; m++) { - char* t_buf = (char*) d_buf_ptrs[m]; - d_buf_ptrs[m] = (void*)(++t_buf); - } - }; -}; - -#endif /* INCLUDED_CODE_IO_H */ diff --git a/gr-error-correcting-codes/src/lib/libecc/code_metrics.cc b/gr-error-correcting-codes/src/lib/libecc/code_metrics.cc deleted file mode 100644 index db402b3eb..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/code_metrics.cc +++ /dev/null @@ -1,436 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <code_metrics.h> -#include <iostream> -#include <math.h> -#include <assert.h> - -template<typename pdf_fcn_io_t> -code_metrics_table<pdf_fcn_io_t>* -libecc_code_metrics_create_table -(pdf_fcn_io_t (*pdf_fcn_0_bit) (pdf_fcn_io_t), - pdf_fcn_io_t (*pdf_fcn_1_bit) (pdf_fcn_io_t), - size_t n_samples, - pdf_fcn_io_t min_sample, - pdf_fcn_io_t max_sample, - int sample_precision) -{ - if (! pdf_fcn_0_bit) { - std::cerr << "libecc_code_metrics_create_table: Error: " - "pdf_fcn_0_bit must be a non-null pointer to function.\n"; - assert (0); - } - if (! pdf_fcn_1_bit) { - std::cerr << "libecc_code_metrics_create_table: Error: " - "pdf_fcn_0_bit must be a non-null pointer to function.\n"; - assert (0); - } - if (n_samples < 2) { - std::cerr << "libecc_code_metrics_create_table: Error: " - "n_samples must be at least 2.\n"; - assert (0); - } - if (min_sample >= max_sample) { - std::cerr << "libecc_code_metrics_create_table: Error: " - "min_sample must be less than max_sample.\n"; - assert (0); - } - if ((sample_precision < 0) | (sample_precision > 32)) { - std::cerr << "libecc_code_metrics_create_table: Error: " - "sample_precision must be between 0 and 32.\n"; - assert (0); - } - - code_metrics_table<pdf_fcn_io_t>* t_code_metrics_table; - - if (sample_precision == 0) { - // float - t_code_metrics_table = new code_metrics_table_work - <pdf_fcn_io_t, float>(pdf_fcn_0_bit, - pdf_fcn_1_bit, - n_samples, - min_sample, - max_sample); - } else if (sample_precision <= 8) { - // use char - t_code_metrics_table = new code_metrics_table_work - <pdf_fcn_io_t, unsigned char>(pdf_fcn_0_bit, - pdf_fcn_1_bit, - n_samples, - min_sample, - max_sample, - sample_precision); - } else if (sample_precision <= 16) { - // use short - t_code_metrics_table = new code_metrics_table_work - <pdf_fcn_io_t, unsigned short>(pdf_fcn_0_bit, - pdf_fcn_1_bit, - n_samples, - min_sample, - max_sample, - sample_precision); - } else { - // use long - t_code_metrics_table = new code_metrics_table_work - <pdf_fcn_io_t, unsigned long>(pdf_fcn_0_bit, - pdf_fcn_1_bit, - n_samples, - min_sample, - max_sample, - sample_precision); - } - - return (t_code_metrics_table); -} - -template<typename pdf_fcn_io_t> -code_metrics_table<pdf_fcn_io_t>::code_metrics_table -(pdf_fcn_t pdf_fcn_0_bit, - pdf_fcn_t pdf_fcn_1_bit, - size_t n_samples, - pdf_fcn_io_t min_sample, - pdf_fcn_io_t max_sample) -{ - // internally, all samples are taken as pdf_fcn_io_t initially, and - // only converted to other values by their specific constructors. - - d_n_samples = n_samples; - d_max_sample = max_sample; - d_min_sample = min_sample; - d_delta = (max_sample - min_sample) / ((pdf_fcn_io_t) n_samples); - d_pdf_fcn_0_bit = pdf_fcn_0_bit; - d_pdf_fcn_1_bit = pdf_fcn_1_bit; - - // use a sub-sample by 100 to better determine the actual "bin" - // probability values for each actual sample. Each "bin" is 100 - // delta's less than the min_sample up to the min_sample+delta; then - // each delta; then from the max_sample-delta to 100 delta's more - // than the max sample. Once normalized, these give a reasonable - // interpretation of the PDF function. - - pdf_fcn_io_t d_sub_delta = d_delta / ((pdf_fcn_io_t) 100); - pdf_fcn_io_t d_sub_min_sample = d_min_sample - ((pdf_fcn_io_t) 100)*d_delta; - pdf_fcn_io_t d_sup_max_sample = d_max_sample + ((pdf_fcn_io_t) 100)*d_delta; - - d_pdf_fcn_0_samples.assign (d_n_samples, 0); - d_pdf_fcn_1_samples.assign (d_n_samples, 0); - - pdf_fcn_io_t t_val, t_sum_0, t_sum_1, t_max_0, t_max_1, t_min_0, t_min_1; - t_sum_0 = t_sum_1 = t_max_0 = t_max_1 = t_min_0 = t_min_1 = 0; - size_t m = 0; - t_val = d_sub_min_sample; - for (; m < (d_n_samples - 1); m++) { - pdf_fcn_io_t t_sample_0 = 1; - pdf_fcn_io_t t_sample_1 = 1; - for (; t_val < (d_min_sample+d_delta); t_val += d_sub_delta) { - t_sample_0 += ((*d_pdf_fcn_0_bit)(t_val)); - t_sample_1 += ((*d_pdf_fcn_1_bit)(t_val)); - } - d_pdf_fcn_0_samples[m] = t_sample_0; - d_pdf_fcn_0_samples[m] = t_sample_1; - t_sum_0 += t_sample_0; - t_sum_1 += t_sample_1; - if (m == 0) { - t_max_0 = t_min_0 = t_sample_0; - t_max_1 = t_min_1 = t_sample_1; - } else { - if (t_max_0 < t_sample_0) - t_max_0 = t_sample_0; - else if (t_min_0 > t_sample_0) - t_min_0 = t_sample_0; - if (t_max_1 < t_sample_1) - t_max_1 = t_sample_1; - else if (t_min_1 > t_sample_1) - t_min_1 = t_sample_1; - } - } - - pdf_fcn_io_t t_sample_0 = 1; - pdf_fcn_io_t t_sample_1 = 1; - for (; t_val < d_sup_max_sample; t_val += d_sub_delta) { - t_sample_0 += ((*d_pdf_fcn_0_bit)(t_val)); - t_sample_1 += ((*d_pdf_fcn_1_bit)(t_val)); - } - d_pdf_fcn_0_samples[m] = t_sample_0; - d_pdf_fcn_0_samples[m] = t_sample_1; - t_sum_0 += t_sample_0; - t_sum_1 += t_sample_1; - if (t_max_0 < t_sample_0) - t_max_0 = t_sample_0; - else if (t_min_0 > t_sample_0) - t_min_0 = t_sample_0; - if (t_max_1 < t_sample_1) - t_max_1 = t_sample_1; - else if (t_min_1 > t_sample_1) - t_min_1 = t_sample_1; - - // normalize to the sum, so that these are "real" probabilities. - - for (m = 0; m < d_n_samples; m++) { - d_pdf_fcn_0_samples[m] /= t_sum_0; - d_pdf_fcn_1_samples[m] /= t_sum_1; - } - t_max_0 /= t_sum_0; - t_min_0 /= t_sum_0; - t_max_1 /= t_sum_1; - t_min_1 /= t_sum_1; - - // take the logf so that metrics can add - - for (m = 0; m < d_n_samples; m++) { - d_pdf_fcn_0_samples[m] = logf (d_pdf_fcn_0_samples[m]); - d_pdf_fcn_1_samples[m] = logf (d_pdf_fcn_1_samples[m]); - } - t_max_0 = logf (t_max_0); - t_min_0 = logf (t_min_0); - t_max_1 = logf (t_max_1); - t_min_1 = logf (t_min_1); - - // higher (less negative) log-probabilities mean more likely; lower - // (more negative) mean less likely. Want metrics which are 0 when - // most likely and more positive when less likely. So subtract the - // max, then negate and normalize to the min (new max) so that the - // max value is 1 and the min value is 0. - - for (m = 0; m < d_n_samples; m++) { - d_pdf_fcn_0_samples[m] = ((d_pdf_fcn_0_samples[m] - t_max_0) / - (t_min_0 - t_max_0)); - d_pdf_fcn_1_samples[m] = ((d_pdf_fcn_1_samples[m] - t_max_1) / - (t_min_1 - t_max_1)); - } - - // correct the delta to the lookup computations - - d_delta = (max_sample - min_sample) / ((pdf_fcn_io_t)(n_samples-1)); -} - -template<typename pdf_fcn_io_t, typename metric_t> -code_metrics_table_work<pdf_fcn_io_t,metric_t>::code_metrics_table_work -(pdf_fcn_t pdf_fcn_0_bit, - pdf_fcn_t pdf_fcn_1_bit, - size_t n_samples, - pdf_fcn_io_t min_sample, - pdf_fcn_io_t max_sample, - int sample_precision) - : code_metrics_table<pdf_fcn_io_t> - (pdf_fcn_0_bit, - pdf_fcn_1_bit, - n_samples, - min_sample, - max_sample) -{ - code_metrics_table<pdf_fcn_io_t>::d_out_item_size_bytes = sizeof (metric_t); - code_metrics_table<pdf_fcn_io_t>::d_sample_precision = sample_precision; - - // get the scale factor for converting from float to - // sample_precision maps: 0 -> 0, 1 -> (2^sample_precision)-1 for - // integers; there is no need for a mapping for float types, since - // those are already in [0,1]. - - pdf_fcn_io_t t_mult = ((sample_precision == 0) ? 1 : - ((pdf_fcn_io_t)((2^sample_precision)-1))); - - // convert the 0 bit metrics from float to integer - - d_metric_table_0_bit.assign (n_samples, 0); - for (size_t m = 0; m < n_samples; m++) { - d_metric_table_0_bit[m] = - (metric_t)((code_metrics_table<pdf_fcn_io_t>::d_pdf_fcn_0_samples[m]) * - t_mult); - } - - // clear the old float sample vectors to free memory - - code_metrics_table<pdf_fcn_io_t>::d_pdf_fcn_0_samples.resize (0); - - // convert the 1 bit metrics from float to integer - - d_metric_table_1_bit.assign (n_samples, 0); - for (size_t m = 0; m < n_samples; m++) { - d_metric_table_1_bit[m] = - (metric_t)((code_metrics_table<pdf_fcn_io_t>::d_pdf_fcn_1_samples[m]) * - t_mult); - } - - // clear the old float sample vectors to free memory - - code_metrics_table<pdf_fcn_io_t>::d_pdf_fcn_1_samples.resize (0); -} - -template<typename pdf_fcn_io_t, typename metric_t> -void -code_metrics_table_work<pdf_fcn_io_t,metric_t>::lookup -(pdf_fcn_io_t sym, - void* bit_0, - void* bit_1) -{ - metric_ptr_t l_bit_0 = (metric_ptr_t) bit_0; - metric_ptr_t l_bit_1 = (metric_ptr_t) bit_1; - - if (sym <= code_metrics_table<pdf_fcn_io_t>::d_min_sample) { - *l_bit_0 = d_metric_table_0_bit[0]; - *l_bit_1 = d_metric_table_1_bit[0]; - return; - } - if (sym >= code_metrics_table<pdf_fcn_io_t>::d_max_sample) { - *l_bit_0 = d_metric_table_0_bit.back (); - *l_bit_1 = d_metric_table_1_bit.back (); - return; - } - - size_t l_ndx = (size_t) round - ((double)((sym - code_metrics_table<pdf_fcn_io_t>::d_min_sample) / - code_metrics_table<pdf_fcn_io_t>::d_delta)); - *l_bit_0 = d_metric_table_0_bit[l_ndx]; - *l_bit_1 = d_metric_table_1_bit[l_ndx]; -} - -template<typename pdf_fcn_io_t, typename metric_t> -void -code_metrics_table_work<pdf_fcn_io_t,metric_t>::convert -(size_t n_syms, - pdf_fcn_io_t* sym, - void* bit_0, - void* bit_1) -{ - metric_ptr_t l_bit_0 = (metric_ptr_t) bit_0; - metric_ptr_t l_bit_1 = (metric_ptr_t) bit_1; - - for (size_t m = n_syms; m > 0; m--) - lookup (*sym++, (void*) l_bit_0++, (void*) l_bit_1++); -} - -// force the compiler to instantiate a particular version of the -// templated super-class, for <float> PDF function precision because -// all code_metrics classes are created by this function, this is the -// only one which is required to instantaite. - -template -code_metrics_table<float>* -libecc_code_metrics_create_table<float> -(float (*pdf_fcn_0_bit) (float), - float (*pdf_fcn_1_bit) (float), - size_t n_samples, - float min_sample, - float max_sample, - int sample_precision); - -template -code_metrics_table<double>* -libecc_code_metrics_create_table<double> -(double (*pdf_fcn_0_bit) (double), - double (*pdf_fcn_1_bit) (double), - size_t n_samples, - double min_sample, - double max_sample, - int sample_precision); - -#if 0 - // for compute_all_outputs - - d_n_code_outputs = n_code_outputs; - - in_l[0].resize (d_n_code_outputs); - in_l[1].resize (d_n_code_outputs); - in_f[0].resize (d_n_code_outputs); - in_f[1].resize (d_n_code_outputs); - - - - if (n_code_outputs == 0) { - std::cerr << "code_metrics::create: Error: # of code outputs " - "must be positive.\n"; - assert (0); - } - - -template<typename pdf_fcn_io_t> -void -code_metrics<pdf_fcn_io_t>::compute_all_outputs -(pdf_fcn_io_t* syms, - std::vector<unsigned long>& out) -{ - // use the first 'n_code_output' symbols, convert them into metrics, - // then compute all possible (summation) combinations of them and - // return those in the provided vector. - - convert (d_n_code_outputs, syms, - (void*)(&(in_l[0][0])), (void*)(&in_l[1][0])); - - // assign the starting minimum metric to 0. This is safe because - // metrics are always non-negative. - - unsigned long min_metric = 0; - for (size_t m = 0; m < (((size_t)2) << d_n_code_outputs); m++) { - size_t t_out_ndx = m; - unsigned long t_metric = 0; - for (size_t n = 0; n < d_n_code_outputs; n++, t_out_ndx >>= 1) - t_metric += in_l[t_out_ndx&1][n]; - if (t_metric < min_metric) - min_metric = t_metric; - out[m] = t_metric; - } - - // normalize so that the minimum metric equals 0 - - for (size_t m = 0; m < d_n_code_outputs; m++) - out[m] -= min_metric; -} - -template<typename pdf_fcn_io_t> -void -code_metrics<pdf_fcn_io_t>::compute_all_outputs -(pdf_fcn_io_t* syms, - std::vector<float>& out) -{ - // use the first 'n_code_output' symbols, convert them into metrics, - // then compute all possible (summation) combinations of them and - // return those in the provided vector. - - convert (d_n_code_outputs, syms, - (void*)(&(in_f[0][0])), (void*)(&in_f[1][0])); - - // assign the starting minimum metric to 0. This is safe because - // metrics are always non-negative. - - float min_metric = 0; - for (size_t m = 0; m < (((size_t)2) << d_n_code_outputs); m++) { - size_t t_out_ndx = m; - float t_metric = 0; - for (size_t n = 0; n < d_n_code_outputs; n++, t_out_ndx >>= 1) - t_metric += in_f[t_out_ndx&1][n]; - if (t_metric < min_metric) - min_metric = t_metric; - out[m] = t_metric; - } - - // normalize so that the minimum metric equals 0 - - for (size_t m = 0; m < d_n_code_outputs; m++) - out[m] -= min_metric; -} -#endif diff --git a/gr-error-correcting-codes/src/lib/libecc/code_metrics.h b/gr-error-correcting-codes/src/lib/libecc/code_metrics.h deleted file mode 100644 index 34f241887..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/code_metrics.h +++ /dev/null @@ -1,172 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_CODE_METRICS_H -#define INCLUDED_CODE_METRICS_H - -#include "code_types.h" -#include <vector> - -template<typename pdf_fcn_io_t> -class code_metrics_table; - -template<typename pdf_fcn_io_t> -code_metrics_table<pdf_fcn_io_t>* -libecc_code_metrics_create_table -(pdf_fcn_io_t (*pdf_fcn_0_bit) (pdf_fcn_io_t), - pdf_fcn_io_t (*pdf_fcn_1_bit) (pdf_fcn_io_t), - size_t n_samples, - pdf_fcn_io_t min_sample, - pdf_fcn_io_t max_sample, - int sample_precision = 0); - -#if 0 -template<typename pdf_fcn_io_t> -class code_metrics_decoder; - -template<typename pdf_fcn_io_t> -libecc_code_metrics_create_decoder -(code_convolutional_trellis* trellis, - code_metrics_table<pdf_fcn_io_t>* table = 0, - int sample_precision = 0); -#endif - -template<typename pdf_fcn_io_t> -class code_metrics_table -{ -/* - * class code_metrics_table: metrics table for convolutional codes. - * Pre-compute a lookup table upon instantiation, which makes for - * quick conversion from soft-float symbol value ('sym') to metric - * value. The symbol value probability is defined by the arguments - * 'pdf_fcn_0_bit' and 'pdf_fcn_1_bit' for p(0|sym) and p(1|sym) - * respectively. Internally, the PDF's are sampled and normalized to - * always have a minimum value of 0. For float-precision, the maximum - * value is 1.0, while for integer M-bits the maximum value is - * (2^M)-1. Smaller metric values indicate that the received symbols - * are closer to the given output bits; larger values indicate greater - * differences. The only constraint on the PDF functions are that - * they are piecewise continuous; otherwise, they don't even have to - * be a true PDF in terms of the integral from -inf to +inf being - * equal to 1 due to the normalization. - * - * Storage type for the tables is determined by the "sample_precision" - * argument. When the precision equals 0, 32-bit float storage is - * used; otherwise, the next largest standard integer type is used - * unsigned (char for 1 to 8 bits, short for 9 to 16 bits, and long - * for 17 to 32 bits). For the purposes of coding gain, any - * sample_precision larger than about 9 will have minimal added - * benefit under most conditions where communications are possible. - * Trellis computations are performed in either 32-bit float (for - * float storage) or 32-bit unsigned long (for all integer storage). - * - * The number of samples to store is determined by the "n_samples" - * argument, which must be at least 2 but is otherwise not limited - * except by the memory of the host computer. - * - * Samples of the PDF functions are taken from "min_sample" to - * "max_sample", which represent the floor and ceiling on input symbol - * values below and above which symbol values are truncated. - * Internally, a sub-n_samples value is determined and used to "sum" - * the PDF functions to divide the probabilities into "bins". - */ - -public: - typedef pdf_fcn_io_t (*pdf_fcn_t) (pdf_fcn_io_t); - - virtual ~code_metrics_table () {}; - - // lookup() returns either a float, or a sign-extended - // 'sample_precision'-bit integer value. - - virtual void lookup (pdf_fcn_io_t sym, - void* bit_0, - void* bit_1) = 0; - - // convert does a lookup on 'n_syms' input symbols - - virtual void convert (size_t n_syms, - pdf_fcn_io_t* syms, - void* bit_0, - void* bit_1) = 0; - - inline const unsigned char out_item_size_bytes () - {return(d_out_item_size_bytes);}; - -protected: - code_metrics_table (pdf_fcn_t pdf_fcn_0_bit, - pdf_fcn_t pdf_fcn_1_bit, - size_t n_samples, - pdf_fcn_io_t min_sample, - pdf_fcn_io_t max_sample); - - unsigned char d_out_item_size_bytes, d_sample_precision; - size_t d_n_samples; - pdf_fcn_io_t d_max_sample, d_min_sample, d_delta; - pdf_fcn_t d_pdf_fcn_0_bit, d_pdf_fcn_1_bit; - std::vector<pdf_fcn_io_t> d_pdf_fcn_0_samples, d_pdf_fcn_1_samples; -}; - -template<typename pdf_fcn_io_t, typename metric_t> -class code_metrics_table_work : public code_metrics_table<pdf_fcn_io_t> -{ -public: - typedef metric_t *metric_ptr_t; - typedef pdf_fcn_io_t (*pdf_fcn_t) (pdf_fcn_io_t); - - ~code_metrics_table_work () {}; - - void lookup (pdf_fcn_io_t sym, void* bit_0, void* bit_1); - void convert (size_t n_syms, pdf_fcn_io_t* sym, void* bit_0, void* bit_1); - -protected: - code_metrics_table_work (pdf_fcn_t pdf_fcn_0_bit, - pdf_fcn_t pdf_fcn_1_bit, - size_t n_samples, - pdf_fcn_io_t min_sample, - pdf_fcn_io_t max_sample, - int sample_precision = 0); - - friend code_metrics_table<pdf_fcn_io_t>* - libecc_code_metrics_create_table<pdf_fcn_io_t> - (pdf_fcn_io_t (*pdf_fcn_0_bit) (pdf_fcn_io_t), - pdf_fcn_io_t (*pdf_fcn_1_bit) (pdf_fcn_io_t), - size_t n_samples, - pdf_fcn_io_t min_sample, - pdf_fcn_io_t max_sample, - int sample_precision); - - std::vector<metric_t> d_metric_table_0_bit, d_metric_table_1_bit; -}; - -#if 0 - // compute all output-bit combinations of the incoming symbols' metrics - - void compute_all_outputs (pdf_fcn_io_t* syms, std::vector<unsigned long>& out); - void compute_all_outputs (pdf_fcn_io_t* syms, std::vector<float>& out); - - size_t d_n_code_outputs; - std::vector<unsigned long> in_l[2]; - std::vector<float> in_f[2]; -#endif - -#endif /* INCLUDED_CODE_METRICS_H */ diff --git a/gr-error-correcting-codes/src/lib/libecc/code_types.h b/gr-error-correcting-codes/src/lib/libecc/code_types.h deleted file mode 100644 index 324f1bd3c..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/code_types.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_CODE_TYPES_H -#define INCLUDED_CODE_TYPES_H - -#include <sys/types.h> - -// the following is the type used for encoder memory - -typedef unsigned long memory_t, *memory_ptr_t; - -#endif /* INCLUDED_CODE_TYPES_H */ diff --git a/gr-error-correcting-codes/src/lib/libecc/decoder.cc b/gr-error-correcting-codes/src/lib/libecc/decoder.cc deleted file mode 100644 index acd319a3b..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/decoder.cc +++ /dev/null @@ -1,228 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <decoder.h> -#include <iostream> - -#define DO_PRINT_DEBUG 0 - -/* - * decode a certain number of output bits - * - * the 'in_buf' and 'out_buf' must have enough memory to handle the - * number of input items and output bits; no error checking is done! - * - * n_bits_to_output: the number of bits per output stream to decode. - * - * returns the actual number of items used per input stream. - */ - -size_t -decoder::decode -(const code_input_ptr in_buf, - code_output_ptr out_buf, - size_t n_bits_to_output) -{ - if (in_buf == 0) { - std::cerr << "decoder::decode{output}: Error: input buffer is NULL.\n"; - assert (0); - } - if (out_buf == 0) { - std::cerr << "decoder::decode{output}: Error: output buffer is NULL.\n"; - assert (0); - } - if (n_bits_to_output == 0) { - std::cerr << "decoder::decode{output}: Warning: " - "no output bits requested.\n"; - return (0); - } - - // set the class-internal number of input metrics - // and output bits left to decode - - d_in_buf = in_buf; - d_out_buf = out_buf; - - // check that there are enough output buffer items - - if (d_out_buf->n_items_left() < n_bits_to_output) { - std::cerr << "encoder::encode{output}: Warning: output buffer size (" << - d_out_buf->n_items_left() << ") is less than the desired number " - "of output items (" << n_bits_to_output << - ") ... using lower number.\n"; - n_bits_to_output = d_out_buf->n_items_left(); - } - - // check that there are enough input buffer items - - size_t n_items_to_input = compute_n_input_items (n_bits_to_output); - - if (d_in_buf->n_items_left() < n_items_to_input) { - std::cerr << "encoder::encode{output}: Warning: input buffer size (" << - d_in_buf->n_items_left() << ") is less than the computed number " - "of required input items (" << n_items_to_input << - ") ... using lower number.\n"; - n_items_to_input = d_in_buf->n_items_left(); - n_bits_to_output = compute_n_output_bits (n_items_to_input); - } - - // set the correct number of I/O bits - - d_n_items_to_input = n_items_to_input; - d_n_bits_to_output = n_bits_to_output; - - if (DO_PRINT_DEBUG) { - std::cout << - "Before Decoding{output}:\n" - " # output bits = " << d_n_bits_to_output << "\n" - " # input items = " << d_n_items_to_input << "\n" - " # output bits used = " << d_out_buf->n_items_used() << "\n" - " # input items used = " << d_in_buf->n_items_used() << "\n"; - } - - // call the private decode function - - decode_private (); - - if (DO_PRINT_DEBUG) { - std::cout << - "After Encoding{output}:\n" - " # output bits = " << d_n_bits_to_output << "\n" - " # input items = " << d_n_items_to_input << "\n" - " # output bits used = " << d_out_buf->n_items_used() << "\n" - " # input items used = " << d_in_buf->n_items_used() << "\n"; - } - - size_t n_items_used = d_in_buf->n_items_used (); - - // clear these buffers, just in case - - d_in_buf = 0; - d_out_buf = 0; - - // return the actual number of input bits used - - return (n_items_used); -} - -/* - * decode a certain number of input metrics - * - * the 'in_buf' and 'out_buf' must have enough memory to handle the - * number of input items and output bits; no error checking is done! - * - * n_items_to_input: the number of items per input stream to decode - * - * returns the actual number of bits written per output stream - */ - -size_t -decoder::decode -(const code_input_ptr in_buf, - size_t n_items_to_input, - code_output_ptr out_buf) -{ - if (in_buf == 0) { - std::cerr << "encoder::encode{input}: Error: input buffer is NULL.\n"; - assert (0); - } - if (out_buf == 0) { - std::cerr << "encoder::encode{input}: Error: output buffer is NULL.\n"; - assert (0); - } - if (n_items_to_input == 0) { - std::cerr << "encoder::encode{input}: Warning: " - "no input items requested.\n"; - return (0); - } - - // set the class-internal number of input metrics and - // output bits left to decode - - d_in_buf = in_buf; - d_out_buf = out_buf; - - // check that there are enough input buffer items - - if (d_in_buf->n_items_left() < n_items_to_input) { - std::cerr << "encoder::encode{input}: Warning: input buffer size (" << - d_in_buf->n_items_left() << ") is less than the desired number " - "of input items (" << n_items_to_input << - ") ... using lower number.\n"; - n_items_to_input = d_in_buf->n_items_left(); - } - - // check that there are enough output buffer items - - size_t n_bits_to_output = compute_n_output_bits (n_items_to_input); - - if (d_out_buf->n_items_left() < n_bits_to_output) { - std::cerr << "encoder::encode{input}: Warning: output buffer size (" << - d_out_buf->n_items_left() << ") is less than the computed number " - "of required output items (" << n_bits_to_output << - ") ... using lower number.\n"; - n_bits_to_output = d_out_buf->n_items_left(); - n_items_to_input = compute_n_input_items (n_bits_to_output); - } - - // set the correct number of I/O bits - - d_n_items_to_input = n_items_to_input; - d_n_bits_to_output = n_bits_to_output; - - if (DO_PRINT_DEBUG) { - std::cout << - "Before Decoding{output}:\n" - " # output bits = " << d_n_bits_to_output << "\n" - " # input items = " << d_n_items_to_input << "\n" - " # output bits used = " << d_out_buf->n_items_used() << "\n" - " # input items used = " << d_in_buf->n_items_used() << "\n"; - } - - // call the private decode function - - decode_private (); - - if (DO_PRINT_DEBUG) { - std::cout << - "After Encoding{output}:\n" - " # output bits = " << d_n_bits_to_output << "\n" - " # input items = " << d_n_items_to_input << "\n" - " # output bits used = " << d_out_buf->n_items_used() << "\n" - " # input items used = " << d_in_buf->n_items_used() << "\n"; - } - - size_t n_items_used = d_out_buf->n_items_used(); - - // clear these buffers, just in case - - d_in_buf = 0; - d_out_buf = 0; - - // return the actual number of output bits written - - return (n_items_used); -} diff --git a/gr-error-correcting-codes/src/lib/libecc/decoder.h b/gr-error-correcting-codes/src/lib/libecc/decoder.h deleted file mode 100644 index 1ff155810..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/decoder.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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_DECODER_H -#define INCLUDED_DECODER_H - -#include "code_io.h" - -class decoder -{ - /* - * class decoder - * A virtual class upon which all decoder types can be built. - * This class provides the basic methods and variables - * generic for all decoders. - */ -public: - decoder () {}; - virtual ~decoder () {}; - - /* - * compute_n_...: to be defined by inheriting classes, in order to - * allow for user-functions to figure out how many inputs are - * required to generate a given number of outputs, and vice versa. - * Can't define them without knowing the decoder type. - * - * Compute the number of input items (metrics, floats, whatevers) - * needed to produce 'n_output' bits, and the number of output bits - * which will be produced by 'n_input' items ... for a single stream - * only. - */ - - virtual size_t compute_n_input_items (size_t n_output_bits) = 0; - virtual size_t compute_n_output_bits (size_t n_input_items) = 0; - - /* - * decode: given the input and output buffers, either decode up to - * the number of output bits or decode the number of input items - * ... if the buffers support either decoding amounts. - */ - - virtual size_t decode (const code_input_ptr in_buf, - code_output_ptr out_buf, - size_t n_bits_to_output); - virtual size_t decode (const code_input_ptr in_buf, - size_t n_items_to_input, - code_output_ptr out_buf); - -/* for remote access to internal info */ - - inline const size_t block_size_bits () {return (d_block_size_bits);}; - inline const size_t n_code_inputs () {return (d_n_code_inputs);}; - inline const size_t n_code_outputs () {return (d_n_code_outputs);}; - inline const size_t total_n_dec_bits () {return (d_total_n_dec_bits);}; - -protected: - /* - * decode_private: decode the given in_buf and write the output bits - * to the out_buf, using internal class variables. This function is - * called from the publically available "encode()" methods, which - * first set the internal class variables before executing. - */ - - virtual void decode_private () = 0; - - size_t d_block_size_bits, d_n_code_inputs, d_n_code_outputs; - size_t d_total_n_dec_bits, d_n_items_to_input, d_n_bits_to_output; - code_input_ptr d_in_buf; - code_output_ptr d_out_buf; -}; - -#endif /* INCLUDED_DECODER_H */ diff --git a/gr-error-correcting-codes/src/lib/libecc/decoder_viterbi.cc b/gr-error-correcting-codes/src/lib/libecc/decoder_viterbi.cc deleted file mode 100644 index c2e8901e5..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/decoder_viterbi.cc +++ /dev/null @@ -1,1049 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <decoder_viterbi.h> -#include <assert.h> -#include <iostream> - -const int g_max_block_size_bits = 10000000; -const int g_max_num_streams = 10; -const int g_num_bits_per_byte = 8; - -#define DO_TIME_THOUGHPUT 0 -#define DO_PRINT_DEBUG_INST 0 -#define DO_PRINT_DEBUG_INST_0 0 -#define DO_PRINT_DEBUG_INST_1 0 -#define DO_PRINT_DEBUG_INST_2 0 -#define DO_PRINT_DEBUG_FSM 0 -#define DO_PRINT_DEBUG_INIT 0 -#define DO_PRINT_DEBUG_UP 0 -#define DO_PRINT_DEBUG_UP_0 0 -#define DO_PRINT_DEBUG_UP_1 0 -#define DO_PRINT_DEBUG_MIDDLE 0 -#define DO_PRINT_DEBUG_MIDDLE_0 0 -#define DO_PRINT_DEBUG_MIDDLE_1 0 -#define DO_PRINT_DEBUG_TERM 0 -#define DO_PRINT_DEBUG_TERM_1 0 -#define DO_PRINT_DEBUG_OUTPUT 0 -#define DO_PRINT_DEBUG_OUTPUT_0 0 -#define DO_PRINT_DEBUG_EXIT 0 -#define DO_PRINT_DEBUG 0 - -#include <mld/mld_timer.h> -#include <mld/n2bs.h> - -decoder_viterbi::decoder_viterbi -(int sample_precision, - const encoder_convolutional* l_encoder) -{ - // make sure that the encoder is "valid" - - if (! l_encoder) { - std::cerr << "decoder_viterbi: Error: Encoder is NULL.\n"; - assert (0); - } - - // make the metrics converter - - // d_code_metrics = new code_metrics ( - - if ((sample_precision < 0) | (sample_precision > 32)) { - std::cerr << "decoder_viterbi: " - "Requested sample_precision (" << sample_precision << - ") must be between 0 and 32.\n"; - assert (0); - } - - // get the trellis - - d_encoder = (encoder_convolutional*) l_encoder; - d_trellis = (code_convolutional_trellis*) d_encoder->trellis (); - - // fill the class variables - - d_block_size_bits = d_encoder->block_size_bits (); - d_n_code_inputs = d_encoder->n_code_inputs (); - d_n_code_outputs = d_encoder->n_code_outputs (); - d_do_termination = d_encoder->do_termination (); - d_total_n_delays = d_encoder->total_n_delays (); - d_n_states = d_trellis->n_states (); - d_n_input_combinations = d_trellis->n_input_combinations (); - - // really nothing else to do here, since this class doesn't "know" - // how to process streaming versus block decoding, or partial - // trellis versus full-trellis. Those will be handled by - // sub-classes which inherit from this one. - - if (DO_PRINT_DEBUG_INST_0) { - std::cout << "Init:\n" << - "d_block_size_bits = " << d_block_size_bits << "\n" << - "d_n_code_inputs = " << d_n_code_inputs << "\n" << - "d_n_code_outputs = " << d_n_code_outputs << "\n" << - "d_do_termination = " << - ((d_do_termination == true) ? "true" : "false") << "\n" << - "d_total_n_delays = " << d_total_n_delays << "\n" << - "d_n_states = " << d_n_states << "\n" << - "d_n_input_combinations = " << d_n_input_combinations << "\n"; - } - - // always start the fsm in the "init" state - - d_fsm_state = fsm_dec_viterbi_init; - - // create a vector of indexes to states when doing "up" or "termination"; - - d_up_term_states_ndx[0] = new size_t [d_n_states]; - d_up_term_states_ndx[1] = new size_t [d_n_states]; - - // get the total number of out bits per stream - - d_n_total_inputs_per_stream = d_block_size_bits; - if (d_do_termination == true) - d_n_total_inputs_per_stream += d_total_n_delays; -} - -decoder_viterbi::~decoder_viterbi -() -{ - // reverse over from allocation -#if 0 - delete [] d_up_term_states_ndx[0]; - delete [] d_up_term_states_ndx[1]; - - // delete the state's structures - - state_t_ptr t_state = d_states[0]; - for (size_t n = d_n_states; n > 0; n--, t_state++) { - connection_t_ptr t_connection = t_state->d_connections; - for (size_t m = d_n_input_combinations; m > 0; m--, t_connection++) { - delete [] t_connection->d_output_bits; - } - delete [] t_state->d_connections; - } - delete [] d_states[0]; - - t_state = d_states[1]; - for (size_t n = d_n_states; n > 0; n--, t_state++) { - connection_t_ptr t_connection = t_state->d_connections; - for (size_t m = d_n_input_combinations; m > 0; m--, t_connection++) { - delete [] t_connection->d_output_bits; - } - delete [] t_state->d_connections; - } - delete [] d_states[1]; - - // delete the save buffer - - char** t_save_buffer = d_save_buffer; - for (size_t n = 0; n < d_n_code_inputs; n++) { - delete [] (*t_save_buffer++); - } - delete [] d_save_buffer; -#endif -} - -void -decoder_viterbi::reset_metrics -(u_char which) -{ - state_t_ptr t_state = d_states[which&1]; - for (size_t n = d_n_states; n > 0; n--, t_state++) { - t_state->d_max_metric = -1e10; -#if 0 -// probably don't need to do these, try removing them later - t_state->d_max_state_ndx = 0; - t_state->d_max_input = -1; -#endif - } -} - -void -decoder_viterbi::zero_metrics -(u_char which) -{ - state_t_ptr t_state = d_states[which&1]; - for (size_t n = d_n_states; n > 0; n--, t_state++) { - t_state->d_max_metric = 0; -#if 0 -// probably don't need to do these, try removing them later - t_state->d_max_state_ndx = -1; - t_state->d_max_input = -1; -#endif - } -} - -void -decoder_viterbi::decode_private -() -{ -#if 0 - -#if DO_TIME_THOUGHPUT - struct timeval t_tp; - start_timer (&t_tp); -#endif -#if DO_PRINT_DEBUG - size_t t_state_print_bits = d_total_n_delays; - size_t t_mem_print_bits = d_total_n_delays; -#endif -// setup variables for quicker access - const char **in_buf = (const char **) &input_items[0]; - char **out_buf = (char **) &output_items[0]; - int t_in_buf_ndx = 0, t_out_buf_ndx = 0; - int t_out_bit_shift = 0; - int t_ninput_items = compute_n_input_metrics (noutput_items); - int t_noutput_bits = noutput_items; - -#if DO_PRINT_DEBUG_INST - std::cout << "# output items = " << noutput_items << " (" << - t_noutput_bytes << " Bytes, " << (t_noutput_bytes * g_num_bits_per_byte) << - " bits), # input items = " << t_ninput_items << " Symbols\n"; - for (size_t n = 0; n < ninput_items.size(); n++) { - std::cout << "# input items [" << n << "] = " << ninput_items[n] << "\n"; - } -#endif - -// put any leftover bits into the output - if (d_n_saved_bits != 0) { -// copy the leftover from the save buffer -// check to make sure it will all fit - size_t t_noutput_bits = t_noutput_bytes * g_num_bits_per_byte; - size_t t_n_copy; - if (t_noutput_bits < d_n_saved_bits) { -// asking for fewer bits than available; set to copy -// just what's being asked for - t_n_copy = t_noutput_bytes; - } else { -// asking for at least as many bits as available; set to copy all - t_out_buf_ndx = d_n_saved_bits / g_num_bits_per_byte; - t_out_bit_shift = d_n_saved_bits % g_num_bits_per_byte; - t_n_copy = t_out_buf_ndx + (t_out_bit_shift != 0 ? 1 : 0); - } -// do the copy for all output streams (code inputs) -// copy starting at save buffer index "start" - for (size_t n = 0; n < d_n_code_inputs; n++) - bcopy (&(d_save_buffer[n][d_n_saved_bits_start_ndx]), - out_buf[n], t_n_copy); -#if DO_PRINT_DEBUG_INST - std::cout << "Copied " << t_n_copy << " Byte" << - (t_n_copy != 1 ? "s" : "") << ": s_b[][" << - d_n_saved_bits_start_ndx << "] => o_b[][0]\n" << - "# saved bits = " << d_n_saved_bits << - ", o_b_ndx = " << t_out_buf_ndx << - ", bit shift = " << t_out_bit_shift << "\n"; -#endif -// update the number of saved bits and start - if (t_noutput_bits < d_n_saved_bits) { -// asking for fewer bit than available: update -// the number of saved bits and their starting index - d_n_saved_bits_start_ndx += t_noutput_bytes; - d_n_saved_bits -= (t_noutput_bytes * g_num_bits_per_byte); -#if DO_PRINT_DEBUG_INST - std::cout << "Updated # saved bits = " << d_n_saved_bits << - ", index = " << d_n_saved_bits_start_ndx << "\n"; -#endif -// nothing to consume; return the desired number of output items - return (noutput_items); - } else { - d_n_saved_bits_start_ndx = d_n_saved_bits = 0; - } - } -#if DO_PRINT_DEBUG_INST - std::cout << "Starting FSM in state: " << - (d_fsm_state == fsm_dec_viterbi_init ? "init" : - (d_fsm_state == fsm_dec_viterbi_doing_up ? "up" : - (d_fsm_state == fsm_dec_viterbi_doing_middle ? "middle" : - (d_fsm_state == fsm_dec_viterbi_doing_term ? "term" : - (d_fsm_state == fsm_dec_viterbi_output ? "output" : "unknown"))))) << "\n"; -#endif - -// while there are input items to create - while (t_out_buf_ndx < t_noutput_bytes) { -#if DO_PRINT_DEBUG_FMS - std::cout << "Starting 'while': processing " << t_in_buf_ndx << " of " << - t_ninput_items << " items.\nJumping to state '" << - (d_fsm_state == fsm_dec_viterbi_init ? "init" : - (d_fsm_state == fsm_dec_viterbi_doing_up ? "up" : - (d_fsm_state == fsm_dec_viterbi_doing_middle ? "middle" : - (d_fsm_state == fsm_dec_viterbi_doing_term ? "term" : - (d_fsm_state == fsm_dec_viterbi_output ? "output" : "unknown"))))) << "'\n"; -#endif -// jump to the correct state in the fsm - switch (d_fsm_state) { - case fsm_dec_viterbi_doing_up: -#if 0 - encode_loop_up (); -#endif - break; - case (fsm_dec_viterbi_doing_middle): -#if DO_PRINT_DEBUG_FSM - std::cout << "Entered fsm_dec_viterbi_doing_middle\n"; -#endif -// stay in this state until the correct number of input symbols is -// reached (if doing block coding), or until there are no more input -// symbols to parse - while (((d_block_size_bits != 0) & - (d_time_count < d_block_size_bits) & - (t_in_buf_ndx < t_ninput_items)) | - ((d_block_size_bits == 0) & - (t_in_buf_ndx < t_ninput_items))) { -// use all states, loop over all inputs, compute the metric for -// each; compare the current metric with all previous stored metric in the -// endpoint of the connection to find the highest one. - -// reset the "to" state's metrics - reset_metrics (d_states_ndx ^ 1); -// get the state's index for each set of new inputs - state_t_ptr t_state = d_states[d_states_ndx]; -#if DO_PRINT_DEBUG_MIDDLE - std::cout << "Time Count " << (d_time_count+1) << " of " << - d_block_size_bits << "\n" << - "d_states_ndx = " << d_states_ndx << "\n"; -#endif -// loop over all current states - for (size_t n = 0; n < d_n_states; n++, t_state++) { -// loop over all possible input values, 1 bit per input stream - connection_t_ptr t_connection = t_state->d_connections; -#if DO_PRINT_DEBUG_MIDDLE_0 - std::cout << "Looping over all 'middle' states: " << - n << " of " << d_n_states << "\n"; -#endif - for (size_t q = 0; q < d_n_input_combinations; q++, t_connection++) { -#if DO_PRINT_DEBUG_MIDDLE_0 - std::cout << "Input = " << n2bs(q, d_n_code_inputs+1) << "\n"; -#endif -// start with this state's metric - float t_metric = t_state->d_max_metric; -// get the "to" state - state_t_ptr t_to_state = t_connection->d_to; -// get that state's metric - float t_to_metric = t_to_state->d_max_metric; -// see if the computation is even needed; -// maximum change is d_n_code_outputs if all bits match exactly - if ((t_to_metric - t_metric) > ((float) 2*d_n_code_outputs)) { -#if DO_PRINT_DEBUG_MIDDLE_0 - std::cout << "!not computing metric!\n"; -#endif - continue; - } -// metrics are close enough; do the computation and the compare -// get the output bits for this connection - float* t_output_bit = t_connection->d_output_bits; - if (d_do_mux_inputs == true) { -// if using mux'ed input streams, handle differently - const float* t_in_buf = &(in_buf[0][t_in_buf_ndx]); -// loop over all encoder-output values - for (size_t r = d_n_code_outputs; r > 0; r--) { -#if DO_PRINT_DEBUG_MIDDLE_0 - std::cout << "in_sym = " << *t_in_buf << ", code_out_bit = " << - *t_output_bit << " ==> metric -> "; -#endif - t_metric += ((*t_in_buf++) * (*t_output_bit++)); -#if DO_PRINT_DEBUG_MIDDLE_0 - std::cout << t_metric << "\n"; -#endif - } - } else { -// loop over all encoder-output values - for (size_t r = 0; r < d_n_code_outputs; r++) { -#if DO_PRINT_DEBUG_MIDDLE_0 - std::cout << "in_sym = " << in_buf[r][t_in_buf_ndx] << - ", code_out_bit = " << *t_output_bit << " ==> metric -> "; -#endif - t_metric += (in_buf[r][t_in_buf_ndx] * (*t_output_bit++)); -#if DO_PRINT_DEBUG_MIDDLE_0 - std::cout << t_metric << "\n"; -#endif - } - } -// done with this input value; compare old and new metrics - if (t_metric > t_to_metric) { -#if DO_PRINT_DEBUG_MIDDLE - std::cout << "New Metric to s[" << - n2bs (t_connection->d_to_ndx,t_state_print_bits) << "]: "; - if (t_to_state->d_max_metric == -1e10) { - std::cout << "setting to "; - } else { - std::cout << "was s[" << - n2bs(t_to_state->d_max_state_ndx,t_state_print_bits) << - "]i[" << n2bs (t_to_state->d_max_input, d_n_code_inputs+1) << - "]@ " << t_to_state->d_max_metric << " now "; - } - std::cout << "s[" << n2bs(n,t_state_print_bits) << "] i[" << - n2bs (q, d_n_code_inputs+1) << "]@ " << t_metric << "\n"; -#endif -// new metric is better; copy that info into the "to" state - t_to_state->d_max_metric = t_metric; - t_to_state->d_max_state_ndx = n; - t_to_state->d_max_input = q; - } -// finished (for) this input value - } -// finished (for) this state - } -// done with all states and all inputs; now update the traceback structure -// change which d_states' index to use as starting - d_states_ndx ^= 1; -// get the state's index for the "to" set of new inputs to get the -// "max" stuff from - t_state = d_states[d_states_ndx]; -// update the traceback structure -// loop over all current states - traceback_t_ptr t_prev_out_bufs = d_out_buf[d_time_count]; - traceback_t_ptr t_out_bufs = d_out_buf[d_time_count+1]; -#if DO_PRINT_DEBUG_MIDDLE_1 - std::cout << "d_o_b[" << d_time_count+1 << "] => d_o_b prev\n"; -#endif - for (size_t n = d_n_states; n > 0; n--, t_state++) { -// simple: get the current state & output state -// and connect output to the current, set inputs on output - traceback_t_ptr t_out_buf = t_out_bufs++; - traceback_t_ptr t_prev_out_buf = - &(t_prev_out_bufs[t_state->d_max_state_ndx]); -#if DO_PRINT_DEBUG_MIDDLE_1 - std::cout << "s[" << n2bs(d_n_states-n,t_state_print_bits) << - "]: max_ndx = " << - n2bs(t_state->d_max_state_ndx,t_state_print_bits) << - ", input = " << n2bs(t_state->d_max_input, d_n_code_inputs+1) << - ": " << t_out_buf << " => " << t_prev_out_buf << "\n"; -#endif - t_out_buf->d_prev = t_prev_out_buf; - t_out_buf->d_inputs = t_state->d_max_input; -// finished doing this state - } -// increment the in_buf index, depending on mux'ing or not - t_in_buf_ndx += (d_do_mux_inputs == false) ? 1 : d_n_code_outputs; -// increment the time counter - d_time_count++; -// finished (while) staying in this fsm state or not - } - if ((d_block_size_bits != 0) & - (d_time_count == d_block_size_bits)) { -#if DO_PRINT_DEBUG_FSM - std::cout << "Setting FSM to fsm_dec_viterbi_doing_term\n"; -#endif - d_fsm_state = fsm_dec_viterbi_doing_term; - } - break; -#if DO_PRINT_DEBUG_FSM - std::cout << "Exited fsm_dec_viterbi_doing_middle\n"; -#endif - case (fsm_dec_viterbi_doing_term): -#if DO_PRINT_DEBUG_FSM - std::cout << "Entered fsm_dec_viterbi_doing_term\n"; -#endif -// set the "next" up_down index to the end of their states - size_t t_time_count = d_total_n_delays - (d_time_count - d_block_size_bits); - t_n_up_down_ndx = 1 << (d_n_code_inputs * t_time_count); -// stay in this state until the correct number of input symbols are -// reached; exit also if we run out of input symbols to process - while ((t_time_count > 0) & - (t_in_buf_ndx < t_ninput_items)) { -#if DO_PRINT_DEBUG_TERM - std::cout << "Doing time " << (d_total_n_delays - t_time_count + 1) << - " of " << d_total_n_delays << "; starting buf[" << t_in_buf_ndx << - "] of [" << t_ninput_items << "]\n"; -#endif -// use the "to" states, -// FIXME: loop over just the "0" inputs -// and compute the metric for -// each, compare & store it in the "to" state at the end of the connection. - -// reset the "to" state's metrics - reset_metrics (d_states_ndx ^ 1); -// reset the state's index for each set of new inputs - size_t* t_state_ndx_ptr = d_up_term_states_ndx[d_up_term_ndx]; - size_t* t_next_state_ndx_ptr = d_up_term_states_ndx[d_up_term_ndx ^ 1]; -// loop over all current stored "term" state indeces - for (size_t n = 0; n < t_n_up_down_ndx; n++) { - size_t t_state_ndx = *t_state_ndx_ptr++; - state_t_ptr t_state = &(d_states[d_states_ndx][t_state_ndx]); -// loop over just the all 0 input value (d_connections[0]) - connection_t_ptr t_connection = t_state->d_connections; -// get the "to" state - state_t_ptr t_to_state = t_connection->d_to; -// start with this state's metric - float t_metric = t_state->d_max_metric; -// get that state's metric - float t_to_metric = t_to_state->d_max_metric; -#if DO_PRINT_DEBUG_TERM - std::cout << "Term state " << (n+1) << " of " << t_n_up_down_ndx << - "; using d_s[" << d_states_ndx << "][" << - n2bs(t_state_ndx,t_state_print_bits) << "]\n"; -#endif -// see if the computation is even needed; -// maximum change is d_n_code_outputs if all bits match exactly - if ((t_to_metric - t_metric) > ((float) 2*d_n_code_outputs)) { -#if DO_PRINT_DEBUG_TERM - std::cout << "!not computing metric!\n"; -#endif - continue; - } -// metrics are close enough; do the computation and the compare -// get the output bits for this connection - float* t_output_bit = t_connection->d_output_bits; - if (d_do_mux_inputs == true) { -// if using mux'ed input streams, handle differently - const float* t_in_buf = &(in_buf[0][t_in_buf_ndx]); -// loop over all encoder-output values - for (size_t r = d_n_code_outputs; r > 0; r--) { - t_metric += ((*t_in_buf++) * (*t_output_bit++)); - } - } else { -// loop over all encoder-output values - for (size_t r = 0; r < d_n_code_outputs; r++) { - t_metric += (in_buf[r][t_in_buf_ndx] * (*t_output_bit++)); - } - } -// done with this input value; compare old and new metrics -// see if it's the best metric - if (t_metric > t_to_metric) { -#if DO_PRINT_DEBUG_TERM - std::cout << "New Metric to s[" << - n2bs (t_connection->d_to_ndx,t_state_print_bits) << "]: "; - if (t_to_state->d_max_metric == -1e10) { - std::cout << "setting to "; - } else { - std::cout << "was s[" << - n2bs(t_to_state->d_max_state_ndx,t_state_print_bits) << - "]i[" << n2bs (t_to_state->d_max_input, d_n_code_inputs+1) << - "]@ " << t_to_state->d_max_metric << " now "; - } - std::cout << "s[" << n2bs(t_state_ndx,t_state_print_bits) << - "] i[" << n2bs (0, d_n_code_inputs+1) << "]@ " << t_metric << "\n"; -#endif - t_to_state->d_max_metric = t_metric; - t_to_state->d_max_state_ndx = t_state_ndx; - t_to_state->d_max_input = 0; - } -// add the "to" state's index to the "next" set of state's indices list - *t_next_state_ndx_ptr++ = t_connection->d_to_ndx; -// finished (for) this state - } -// done with all states and all inputs; now update the traceback structure -// change which d_states' index to use as starting - d_states_ndx ^= 1; -// update the number of "up_term" states - d_up_term_ndx ^= 1; -// reduce the number of using states - t_n_up_down_ndx >>= d_n_code_inputs; -// reset the state's index for each set of new inputs - t_state_ndx_ptr = d_up_term_states_ndx[d_up_term_ndx]; -// update the traceback structure -// loop over all current states - traceback_t_ptr t_prev_out_bufs = d_out_buf[d_time_count]; - traceback_t_ptr t_out_bufs = d_out_buf[d_time_count+1]; -#if DO_PRINT_DEBUG_TERM_1 - std::cout << "d_o_b[" << d_time_count+1 << "] => d_o_b prev\n"; -#endif -// loop over all current stored "term" state indices - for (size_t n = 0; n < t_n_up_down_ndx; n++) { -// get the start index and then pointer to each of the "to" states, -// which hold the newest "max" stuff - size_t t_state_ndx = *t_state_ndx_ptr++; - state_t_ptr t_state = &(d_states[d_states_ndx][t_state_ndx]); -// simple: get the current state & output state -// and connect output to the current, set inputs on output - traceback_t_ptr t_out_buf = &(t_out_bufs[t_state_ndx]); - traceback_t_ptr t_prev_out_buf = - &(t_prev_out_bufs[t_state->d_max_state_ndx]); -#if DO_PRINT_DEBUG_TERM_1 - std::cout << "ndx[" << n << "] == " << t_state_ndx << - ", s[" << n2bs(t_state_ndx,t_state_print_bits) << - "]: max_ndx = " << - n2bs(t_state->d_max_state_ndx,t_state_print_bits) << - ", input = " << n2bs(t_state->d_max_input, d_n_code_inputs+1) << - ": " << t_out_buf << " => " << t_prev_out_buf << "\n"; -#endif - t_out_buf->d_prev = t_prev_out_buf; - t_out_buf->d_inputs = t_state->d_max_input; -// finished (for) this state - } -// increment the in_buf index, depending on mux'ing or not - t_in_buf_ndx += (d_do_mux_inputs == false) ? 1 : d_n_code_outputs; -// increment the time counters - t_time_count--; - d_time_count++; -// finished (while) staying in this fsm state or not - } - if (t_time_count == 0) { -// finished this trellis, now move as much of the decoded input to the -// output buffer as possible -#if DO_PRINT_DEBUG_FSM - std::cout << "Setting FSM to fsm_dec_viterbi_output\n"; -#endif - d_fsm_state = fsm_dec_viterbi_output; - } -#if DO_PRINT_DEBUG_FSM - std::cout << "Exited fsm_dec_viterbi_doing_term\n"; -#endif - break; - case (fsm_dec_viterbi_output): -#if DO_PRINT_DEBUG_FSM - std::cout << "Entered fsm_dec_viterbi_output.\n"; -#endif -// this is done in reverse bit order (last time to first time) -// using the traceback structure in d_out_buf, starting with -// the maximum valued one in the last time slot, then using -// the traceback's "d_prev" link to trace the trellis back - -// see where the output data will terminate - int t_next_out_buf_ndx = (t_out_buf_ndx + - (d_block_size_bits / g_num_bits_per_byte)); - int t_next_out_bit_shift = (t_out_bit_shift + - (d_block_size_bits % g_num_bits_per_byte)); - if (t_next_out_bit_shift >= g_num_bits_per_byte) { - t_next_out_bit_shift -= g_num_bits_per_byte; - t_next_out_buf_ndx++; - } -#if DO_PRINT_DEBUG_OUTPUT - std::cout << "First bit in at out[][" << t_out_buf_ndx << "].[" << - t_out_bit_shift << "] -> " << d_block_size_bits << " bits == " << - (d_block_size_bits / g_num_bits_per_byte) << " Byte" << - ((d_block_size_bits / g_num_bits_per_byte) != 1 ? "s" : "") << - " + " << (d_block_size_bits % g_num_bits_per_byte) << " bit" << - ((d_block_size_bits % g_num_bits_per_byte) != 1 ? "s" : "") << - "\nNext set of bits start at out[][" << t_next_out_buf_ndx << - "].[" << t_next_out_bit_shift << "]\n"; -#endif -// find the starting traceback structure - traceback_t_ptr t_out_buf; - if (d_do_termination == true) { -// FIXME: assume termination state == 0 -#if DO_PRINT_DEBUG_OUTPUT_0 - std::cout << "Using termination; going through trellis for " << - d_total_n_delays << " bit" << - ((d_total_n_delays != 1) ? "s" : "") << "\n"; -#endif - t_out_buf = &(d_out_buf[d_time_count][0]); -#if DO_PRINT_DEBUG_OUTPUT_0 - std::cout << "Starting traceback ptr " << t_out_buf << "\n"; -#endif -// skip over the termination bits - for (size_t n = d_total_n_delays; n > 0; n--) { - t_out_buf = t_out_buf->d_prev; -#if DO_PRINT_DEBUG_OUTPUT_0 - std::cout << "Next traceback ptr " << t_out_buf << "\n"; -#endif - } - } else { -// no termination but doing block coding; -// FIXME: use the state with the bext metric -// get the state's index for each set of new inputs - state_t_ptr t_state = d_states[d_states_ndx]; - float t_max_metric = t_state->d_max_metric; - size_t t_max_state_ndx = 0; - t_state++; -// loop over all current states - for (size_t n = 1; n < d_n_states; n++, t_state++) { -// start with this state's metric - float t_metric = t_state->d_max_metric; -// compare with current max - if (t_metric > t_max_metric) { - t_max_metric = t_metric; - t_max_state_ndx = n; - } - } -// get the correct out_buf reference to start with - t_out_buf = &(d_out_buf[d_time_count][t_max_state_ndx]); - } -#if DO_PRINT_DEBUG_OUTPUT - std::cout << "Found starting traceback ptr " << t_out_buf << - "; getting all " << d_block_size_bits << " bits per stream.\n"; -#endif -// now we've got the starting traceback structure address; -// check to make sure there is enough space in each output buffer - size_t t_block_bit_ndx = d_block_size_bits; - if ((t_next_out_buf_ndx > t_noutput_bytes) | - ((t_next_out_buf_ndx == t_noutput_bytes) & - (t_next_out_bit_shift != 0))) { -// not enough space for all output bits; -// find the number of extra bits to save - size_t t_save_buf_ndx = t_next_out_buf_ndx - t_noutput_bytes; - size_t t_n_extra_bits = ((t_save_buf_ndx * g_num_bits_per_byte) + - t_next_out_bit_shift); -// set the number of saved bits - d_n_saved_bits = t_n_extra_bits; -// remove the extra bits from the number to copy to the output buffer - t_block_bit_ndx -= t_n_extra_bits; -// find the actual output buf index, once we get there - t_next_out_buf_ndx -= t_save_buf_ndx; -#if DO_PRINT_DEBUG_OUTPUT - std::cout << "Not enough output buffer space:\n" << - "len (o_b) = " << t_noutput_bytes << " ==> " << - t_n_extra_bits << " extra bit" << - (t_n_extra_bits != 1 ? "s" : "") << " == " << - t_save_buf_ndx << " Byte" << - (t_save_buf_ndx != 1 ? "s" : "") << ", " << - t_next_out_bit_shift << " bit" << - (t_next_out_bit_shift != 1 ? "s" : "") << "\n"; -#endif -// zero each output buffers' bytes - size_t t_n_zero = t_save_buf_ndx + (t_next_out_bit_shift ? 1 : 0); -#if DO_PRINT_DEBUG_OUTPUT - size_t t_n_out_bytes = ((d_block_size_bits / g_num_bits_per_byte) + - ((d_block_size_bits % g_num_bits_per_byte) ? 1 : 0)); - std::cout << "Zeroing save buffer from for " << t_n_zero << - " Byte" << (t_n_zero != 1 ? "s" : "") << " (of " << - d_block_size_bits << " bit" << - (d_block_size_bits != 1 ? "s" : "") << " == " << t_n_out_bytes << - " Byte" << (t_n_out_bytes != 1 ? "s" : "") << ")\n"; -#endif - for (size_t m = 0; m < d_n_code_inputs; m++) - bzero (d_save_buffer[m], t_n_zero); -// loop over all extra bits - for (size_t n = t_n_extra_bits; n > 0; n--) { -// first decrement the output bit & byte as necessary - if (--t_next_out_bit_shift < 0) { - t_next_out_bit_shift += g_num_bits_per_byte; - t_save_buf_ndx--; - } -// get the encoder inputs to output - size_t t_inputs = t_out_buf->d_inputs; -// loop over all code inputs (decoder-outputs), 1 bit per stream - for (size_t m = 0; m < d_n_code_inputs; m++) { - d_save_buffer[m][t_save_buf_ndx] |= - ((t_inputs & 1) << t_next_out_bit_shift); - t_inputs >>= 1; - } - t_out_buf = t_out_buf->d_prev; -#if DO_PRINT_DEBUG_OUTPUT_0 - std::cout << "Next traceback ptr " << t_out_buf << "\n"; -#endif - } -// at exit, "t_out_buf_ndx" should be == t_noutput_bytes, and -// "t_out_bit_shift" should be 0; check these! -#if DO_PRINT_DEBUG_OUTPUT - std::cout << "n_o_b_ndx (" << t_next_out_buf_ndx << ") ?=? " << - "#o_B (" << t_noutput_bytes << ") & t_o_b_sh (" << - t_next_out_bit_shift << ") ?=? 0\n"; - assert (t_next_out_buf_ndx == t_noutput_bytes); - assert (t_next_out_bit_shift == 0); -#endif - } -// set the correct output buffer index and bit shift - t_out_bit_shift = t_next_out_bit_shift; - t_out_buf_ndx = t_next_out_buf_ndx; -// copy any remaining bits looping backwards in bit-time -// through the traceback trellis - for (size_t n = t_block_bit_ndx; n > 0; n--) { -// first decrement the output bit & byte as necessary - if (--t_out_bit_shift < 0) { - t_out_bit_shift += g_num_bits_per_byte; - t_out_buf_ndx--; - } -// get the encoder inputs to output - size_t t_inputs = t_out_buf->d_inputs; -// loop over all code inputs (decoder-outputs), 1 bit per stream - for (size_t m = 0; m < d_n_code_inputs; m++) { - out_buf[m][t_out_buf_ndx] |= ((t_inputs & 1) << t_out_bit_shift); - t_inputs >>= 1; - } - t_out_buf = t_out_buf->d_prev; -#if DO_PRINT_DEBUG_OUTPUT_0 - std::cout << "Next traceback ptr " << t_out_buf << "\n"; -#endif - } -// set the next output byte and bit-shift - t_out_bit_shift = t_next_out_bit_shift; - t_out_buf_ndx = t_next_out_buf_ndx; -#if DO_PRINT_DEBUG_FSM - std::cout << "Set FSM to fsm_dec_viterbi_init\n"; -#endif - d_fsm_state = fsm_dec_viterbi_init; -#if DO_PRINT_DEBUG_FSM - std::cout << "Exited fsm_dec_viterbi_output\n"; -#endif - break; - case (fsm_dec_viterbi_init): -#if DO_PRINT_DEBUG_FSM - std::cout << "Entered fsm_dec_viterbi_init\n"; -#endif -// this is called immediately (first input bit upon startup), -// or after termination of a trellis. - -// reset states to the 0'th one - d_up_term_ndx = d_states_ndx = 0; -// zero the metrics for those states - zero_metrics (0); -#if 0 -// might not need to do this; check and see after it works -// reset up_term states and number so that there is 1 item, the "0" state. - bzero (d_up_term_states_ndx[0], sizeof (size_t) * d_n_states); - bzero (d_up_term_states_ndx[1], sizeof (size_t) * d_n_states); -#else - d_up_term_states_ndx[0][0] = 0; -#endif -// reset time count back to the start - d_time_count = 0; -#if 0 -// reset the traceback structures -// might not need to do this; check and see after it works - traceback_t_hdl t_out_bufs = d_out_buf; - for (size_t n = d_n_traceback_els; n > 0; n--) { - traceback_t_ptr t_out_buf = (*t_out_bufs++); - for (size_t m = d_n_states; m > 0; m--, t_out_buf++) { - t_out_buf->d_prev = NULL; - t_out_buf->d_inputs = -1; - } - } -#endif -// set the fsm to "doing up" -#if DO_PRINT_DEBUG_FSM - std::cout << "Set FSM to fsm_dec_viterbi_doing_up\n"; -#endif - d_fsm_state = fsm_dec_viterbi_doing_up; -#if DO_PRINT_DEBUG_FSM - std::cout << "Exited fsm_dec_viterbi_init\n"; -#endif - break; -// should never get here! - default: - assert (0); -// done (switch) with FSM - } -// done (while) there are inputs - } - -// consume all of the input items on all input streams -// "ninput_items[]" doesn't seem to be reliable, -// so compute this from the actual number of blocks processed -#if DO_PRINT_DEBUG_EXIT - std::cout << "Exiting FSM in state: " << - (d_fsm_state == fsm_dec_viterbi_init ? "init" : - (d_fsm_state == fsm_dec_viterbi_doing_up ? "up" : - (d_fsm_state == fsm_dec_viterbi_doing_middle ? "middle" : - (d_fsm_state == fsm_dec_viterbi_doing_term ? "term" : - (d_fsm_state == fsm_dec_viterbi_output ? "output" : "unknown"))))) << "\n" << - "Consuming " << t_in_buf_ndx << - " input items on each input stream (of " << t_ninput_items << ").\n"; -#endif - consume_each (t_in_buf_ndx); - -// make sure the number of output items makes sense -// t_out_buf_ndx always points to the current index -// t_out_bit_shift always points to the next bit position to be written - int t_leftover_bytes = t_out_buf_ndx % d_out_stream_el_size_bytes; - int t_leftover_bits = ((t_leftover_bytes * g_num_bits_per_byte) + - t_out_bit_shift); - int t_noutput_items = noutput_items; -#if DO_PRINT_DEBUG_EXIT - std::cout << "Final o_b[" << t_out_buf_ndx << "][" << - t_out_bit_shift << "] of " << t_noutput_bytes << - ", el_size = " << d_out_stream_el_size_bytes << - ", lo_Bytes = " << t_leftover_bytes << - ", t_lo_bits = " << t_leftover_bits << "\n" << - "Desired # output items = " << noutput_items << "\n"; -#endif - if (t_leftover_bits != 0) { - // should never get here! -#if 1 - assert (0); -#else - int t_ndx = t_out_buf_ndx - t_leftover_bytes; - size_t t_n_copy = t_leftover_bytes + ((t_out_bit_shift != 0) ? 1 : 0); - assert (t_n_copy <= d_out_stream_el_size_bytes); -// copy the leftover into the save buffer - for (size_t n = 0; n < d_n_code_inputs; n++) { - bcopy (&(out_buf[n][t_ndx]), d_save_buffer[n], t_n_copy); - } - t_noutput_items = t_ndx / d_out_stream_el_size_bytes; - d_n_saved_bits = t_leftover_bits; -#if DO_PRINT_DEBUG_EXIT - std::cout << "Copied " << t_n_copy << " Byte" << - (t_n_copy != 1 ? "s" : "") << " from o_b[][" << t_ndx << - "] into each save buffer.\n" << - "Actual #output items = " << t_noutput_items << - ", # saved bit(s) = " << d_n_saved_bits << "\n"; -#endif -#endif - } - -#endif - -#if DO_TIME_THOUGHPUT - u_long d_t = end_timer (&t_tp); - - std::cout << "dec_blk_conv_soft_full: Completed " << t_ninput_items << - " bits in " << d_t << " usec => " << - 1e6*(((double)(t_ninput_items))/((double) d_t)) << - " b/s\n"; -#endif -} - -#if 0 - -void -decoder_viterbi::encode_loop_up () -{ -#if DO_PRINT_DEBUG_FSM - std::cout << "Starting fsm_dec_viterbi_doing_up\n"; -#endif - - // set the number of up_down indices - - size_t t_n_up_down_ndx = 1 << (d_n_code_inputs * - d_time_count); - -// stay in this state until the correct number of input symbols are -// reached; exit also if we run out of input symbols to process - while ((d_time_count < d_total_n_delays) & - (t_in_buf_ndx < t_ninput_items)) { -#if DO_PRINT_DEBUG_UP_0 - std::cout << "Doing 'while' loop:\n" << - "t_n_up_down_ndx = " << t_n_up_down_ndx << "\n" << - "d_time_count = " << d_time_count << "\n" << - "d_total_n_delays = " << d_total_n_delays << "\n" << - "t_in_buf_ndx = " << t_in_buf_ndx << "\n" << - "t_ninput_items = " << t_ninput_items << "\n"; -#endif -// use the "from" states, loop over all inputs and compute the metric for -// each & store it in the "to" state at the end of the connection. -// no need to compare metrics yet, since none join into any given state - -#if 0 -// reset the "to" state's metrics -// probably don't need to do this; try removing later - reset_metrics (d_states_ndx ^ 1); -#if DO_PRINT_DEBUG_UP - std::cout << "Reset Metrics\n"; -#endif -#endif - -// reset the state's index for each set of new inputs - size_t* t_state_ndx_ptr = d_up_term_states_ndx[d_up_term_ndx]; - size_t* t_next_state_ndx_ptr = d_up_term_states_ndx[d_up_term_ndx ^ 1]; -// loop over all current stored "up" states - for (size_t n = 0; n < t_n_up_down_ndx; n++) { - size_t t_state_ndx = *t_state_ndx_ptr++; -// get a pointer to this state's structure - state_t_ptr t_state = &(d_states[d_states_ndx][t_state_ndx]); -// get the connections for all inputs - connection_t_ptr t_connection = t_state->d_connections; -#if DO_PRINT_DEBUG_UP_0 - std::cout << "Looping over all 'up' states:\n" << - "n = " << n << "\n" << - "t_n_up_down_ndx = " << t_n_up_down_ndx << "\n" << - "d_states_ndx = " << d_states_ndx << "\n" << - "t_state_ndx = " << t_state_ndx << "\n" << - "d_n_input_combs = " << d_n_input_combinations << "\n" << - "t_state = " << t_state << "\n" << - "t_connection = " << t_connection << "\n"; -#endif -// loop over all possible input values, 1 bit per input stream - for (size_t q = 0; q < d_n_input_combinations; q++, t_connection++) { -// find the "to" state for this connection - state_t_ptr t_to_state = t_connection->d_to; -// get the output bits for this connection - float* t_output_bit = t_connection->d_output_bits; -// start with this state's metric - float t_metric = t_state->d_max_metric; -#if DO_PRINT_DEBUG_UP_0 - std::cout << - "to state index = " << t_connection->d_to_ndx << "\n" << - "current metric = " << t_metric << "\n"; -#endif - if (d_do_mux_inputs == true) { -// if using mux'ed input streams, handle differently - const float* t_in_buf = &(in_buf[0][t_in_buf_ndx]); -// loop over all encoder-output values - for (size_t r = d_n_code_outputs; r > 0; r--) { -#if DO_PRINT_DEBUG_UP - std::cout << "in_sym = " << *t_in_buf << ", code_out_bit = " << - *t_output_bit << " ==> metric -> "; -#endif - t_metric += ((*t_in_buf++) * (*t_output_bit++)); -#if DO_PRINT_DEBUG_UP - std::cout << t_metric << "\n"; -#endif - } - } else { -// loop over all encoder-output values - for (size_t r = 0; r < d_n_code_outputs; r++) { -#if DO_PRINT_DEBUG_UP - std::cout << "in_sym = " << in_buf[r][t_in_buf_ndx] << - ", code_out_bit = " << *t_output_bit << " ==> metric -> "; -#endif - t_metric += (in_buf[r][t_in_buf_ndx] * (*t_output_bit++)); -#if DO_PRINT_DEBUG_UP - std::cout << t_metric << "\n"; -#endif - } - } -// get the "to" state index - size_t t_to_ndx = t_connection->d_to_ndx; -// store the metric in the "to" state; should not have been used before - t_to_state->d_max_metric = t_metric; -// add the "to" state index to the "up" state list - *t_next_state_ndx_ptr++ = t_to_ndx; -// update the traceback structure, depending on which variety it is -// doing full trellis before decoding; use d_out_buf -// simple: get the current state & output state - traceback_t_ptr t_out_buf = &(d_out_buf[d_time_count] - [t_state_ndx]); - traceback_t_ptr t_next_out_buf = &(d_out_buf[d_time_count+1] - [t_to_ndx]); -#if DO_PRINT_DEBUG_UP_1 - std::cout << "d_o_b[" << d_time_count+1 << "] => d_o_b prev\n" << - "ndx[" << n << "] == " << t_state_ndx << - ", s[" << n2bs(t_state_ndx,t_state_print_bits) << - "]: max_ndx = " << - n2bs(t_state->d_max_state_ndx,t_state_print_bits) << - ", input = " << n2bs(q, d_n_code_inputs+1) << - ": " << t_next_out_buf << " => " << t_out_buf << "\n"; -#endif -// and connect output to the current, set inputs on output - t_next_out_buf->d_prev = t_out_buf; - t_next_out_buf->d_inputs = q; -// finished (for) this input value - } -// finished (for) this "up_term" state - } -// increment the in_buf index, depending on mux'ing or not - t_in_buf_ndx += (d_do_mux_inputs == false) ? 1 : d_n_code_outputs; -// increment the time counter - d_time_count++; -// update the number of "up_term" states - d_up_term_ndx ^= 1; -// increase the number of using states - t_n_up_down_ndx <<= d_n_code_inputs; -// change which d_states' index to use as starting - d_states_ndx ^= 1; -// finished (while) staying in this fsm state or not - } -// if reached the end of doing the "up" part of the trellis, -// switch states into the middle - if (d_time_count == d_total_n_delays) { -#if DO_PRINT_DEBUG_FSM - std::cout << "Setting FSM to fsm_dec_viterbi_doing_middle\n"; -#endif - d_fsm_state = fsm_dec_viterbi_doing_middle; - } -#if DO_PRINT_DEBUG_FSM - std::cout << "Exited fsm_dec_viterbi_doing_up\n"; -#endif -} -#endif diff --git a/gr-error-correcting-codes/src/lib/libecc/decoder_viterbi.h b/gr-error-correcting-codes/src/lib/libecc/decoder_viterbi.h deleted file mode 100644 index 339317187..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/decoder_viterbi.h +++ /dev/null @@ -1,185 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_DECODER_VITERBI_H -#define INCLUDED_DECODER_VITERBI_H - -#include "decoder.h" -#include "encoder_convolutional.h" - -class decoder_viterbi : public decoder -{ -public: -/*! - * \brief Decode the incoming metrics streams using the Viterbi algorithm. - * - * input: streams of metrics, 2 streams per n_code_outputs - one each for - * a 0- and 1-bit metric. - * - * output: streams of char, one stream per n_code_inputs, using only - * the right-most justified bit as the single bit per output item. - * - * sample_precision: precision of the incoming metrics - * if == 0, then use soft precision (32 bit float); - * otherwise, use an integer up to 32 bits, already sign-extended - * to the nearest power-of-2-sized type (char, short, long). - * - * l_encoder: pointer to an encoder class from which to determine the - * trellis transitions (states and i/o bits). - */ - - decoder_viterbi (int sample_precision, - const encoder_convolutional* l_encoder); - - virtual ~decoder_viterbi (); - -protected: -/* - * state_t: describes a given memory state - * - * d_connections: a pointer to an array of these structures - * will be used to describes a given time-bit's memory state; - * an entry will be referenced via "state_add_to", to find the - * connections to the next time-bit memory states. There is - * one entry per each input bit combination -> 2^#I connections in all. - * e.g. [0] means the all 0 input; - * [1] means that input #1 was 1 while all the others were 0; - * [2] means that input #2 was 1, while all the others were 0; - * [3] means that inputs #1 and #2 were 1, while the others were 0. - * - * d_max_metric: the maximum metric thus far for this state - * - * d_max_state: the state from which the maximum metric was attained - * - * d_max_input: the input bits from which the maximum metric was attained - */ - - typedef struct state_t { - struct state_t* d_connections; - float d_max_metric; - int d_max_state_ndx; - int d_max_input; - } state_t, *state_t_ptr; - -/* - * state_get_from(v,i,k): use to retrieve a given bit-memory state, - * from the inputs: - * - * memory_t v: the value from which to retrieve the given state - * size_t i: for which input stream (0 to #I-1) - * size_t k: the number of memory slots per input (e.g. 1+D^2 -> 2) - */ - - inline memory_t state_get_from (memory_t v, - size_t i, - size_t k) - {return (((v)>>((i)*(k)))&((1<<(k))-1));}; - -/* - * state_add_to(s,v,i,k): use to create a given bit-memory state, - * from the inputs: - * - * memory_t s: the state value to modify - * memory_t v: value to set the state to for this input - * size_t i: for which input stream (0 to #I-1) - * size_t k: the number of memory slots per input (e.g. 1+D^2 -> 2) - */ - - inline void state_add_to (memory_t s, - memory_t v, - size_t i, - size_t k) - {(s)|=(((v)&((1<<(k))-1))<<((i)*(k)));}; - -/* - * fsm_dec_viterbi_t: finite state machine for the Viterbi decoder - * - * fsm_dec_viterbi_init: initialize for a new block / block; this is - * already done at instantiation, so do it only at the end of a - * block. - * - * fsm_dec_viterbi_doing_up: encoding at the start of a block - * - * fsm_dec_viterbi_doing_middle: doing encoding inside the trellis - * - * fsm_dec_viterbi_doing_term: termination trellis, if requested - */ - - enum fsm_dec_viterbi_t { - fsm_dec_viterbi_init, fsm_dec_viterbi_doing_up, - fsm_dec_viterbi_doing_middle, fsm_dec_viterbi_doing_term - }; - - virtual void decode_private (); -#if 0 - virtual void decode_loop (size_t* which_counter, size_t how_many); -#endif - virtual void get_next_inputs () { - d_in_buf->read_items ((void*)(&(d_current_inputs[0]))); - d_in_buf->increment_indices (); - }; - virtual void write_output_bits () { - d_out_buf->write_items ((void*)(&(d_current_outputs[0]))); - d_out_buf->increment_indices (); - }; - - void encode_loop_up (); - - virtual void update_traceback__up (size_t from_state_ndx, - size_t to_state_ndx, - size_t l_input) = 0; - virtual void update_traceback__middle () = 0; - virtual void update_traceback__term () = 0; - - void reset_metrics (u_char which); - void zero_metrics (u_char which); - - encoder_convolutional* d_encoder; - code_convolutional_trellis* d_trellis; - fsm_dec_viterbi_t d_fsm_state; - - size_t d_time_count, d_n_total_inputs_per_stream; - size_t d_n_saved_bits, d_n_saved_bits_start_ndx, d_n_traceback_els; - size_t d_n_states, d_n_input_combinations, d_total_n_delays; - size_t d_states_ndx, d_up_term_ndx; - bool d_do_termination; -#if 1 - state_t_ptr d_states[2]; - size_t* d_up_term_states_ndx[2]; - char **d_save_buffer; -#else - std::vector<state_t> d_states[2]; - std::vector<size_t> d_up_term_states_ndx[2]; - std::vector<char **> d_save_buffer; ??? -#endif - - // "inputs" are the current input symbols as soft-floats, to be - // converted to metrics internally - - std::vector<float> d_current_inputs; - - // "outputs" are the current output bits, in the LSB (&1) of each "char" - - std::vector<char> d_current_outputs; -}; - -#endif /* INCLUDED_DECODER_VITERBI_H */ diff --git a/gr-error-correcting-codes/src/lib/libecc/decoder_viterbi_full_block.cc b/gr-error-correcting-codes/src/lib/libecc/decoder_viterbi_full_block.cc deleted file mode 100644 index f494dd4da..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/decoder_viterbi_full_block.cc +++ /dev/null @@ -1,1133 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "decoder_viterbi_full_block.h" -#include <assert.h> -#include <iostream> -#include <math.h> - -const int g_max_block_size_bits = 10000000; -const int g_max_num_streams = 10; -const int g_num_bits_per_byte = 8; - -#define DO_TIME_THOUGHPUT 0 - -#define DO_PRINT_DEBUG_INST 0 -#define DO_PRINT_DEBUG_FSM 0 -#define DO_PRINT_DEBUG_INIT 0 -#define DO_PRINT_DEBUG_UP 0 -#define DO_PRINT_DEBUG_UP_0 0 -#define DO_PRINT_DEBUG_UP_1 0 -#define DO_PRINT_DEBUG_MIDDLE 0 -#define DO_PRINT_DEBUG_MIDDLE_0 0 -#define DO_PRINT_DEBUG_MIDDLE_1 0 -#define DO_PRINT_DEBUG_TERM 0 -#define DO_PRINT_DEBUG_TERM_1 0 -#define DO_PRINT_DEBUG_OUTPUT 0 -#define DO_PRINT_DEBUG_OUTPUT_0 0 -#define DO_PRINT_DEBUG_EXIT 0 -#define DO_PRINT_DEBUG 1 - -#if DO_TIME_THOUGHPUT -#include <mld/mld_timer.h> -#endif -#if DO_PRINT_DEBUG -#include <mld/n2bs.h> -#endif - -decoder_viterbi_full_block::decoder_viterbi_full_block -(int sample_precision, - encoder_convolutional* l_encoder) - : decoder_viterbi (sample_precision, l_encoder) -{ - // verify that the block size is non-zero - - if (d_block_size_bits == 0) { - std::cerr << "decoder_viterbi_full_block: Error: " - "Block size is 0, and must be positive for block decoding.\n"; - assert (0); - } - - // the traceback buffers are specific to the type of decoding - // (full/block, partial/block, partial/stream) - - // create the traceback buffers; for full/block, use the total # of - // bits to decode + 1: each bit is represented by a transition - // between traceback elements. - - d_n_traceback_els = d_n_total_inputs_per_stream + 1; - - // create the output buffers: - // this is a 2d matrix structure, where the first dimension - // is the number of output bits; the second dimension is - // the number of states. - // When doing full blocks, each bit-time's state's traceback - // contains just the pointer to the previous bit-time's state's traceback - // as well as the inputs for that connection. - // No further work is required because each reverse-path is unique - // once a given end-bit-time's state is determined to be "the one". - - traceback_t_hdl t_out_buf = - d_out_buf = new traceback_t_ptr [d_n_traceback_els]; - for (size_t n = d_n_traceback_els; n > 0; n--) { - (*t_out_buf++) = new traceback_t [d_n_states]; - } - - if (DO_PRINT_DEBUG_INST) { - std::cout << - "total # in bits / stream = " << d_n_total_inputs_per_stream << "\n" << - "d_n_traceback_els = " << d_n_traceback_els << "\n"; - } - - if (DO_PRINT_DEBUG_INST) { - traceback_t_hdl t_out_bufs = d_out_buf; - for (size_t n = 0; n < d_n_traceback_els; n++, *t_out_bufs++) { - traceback_t_ptr t_out_buf = *t_out_bufs; - for (size_t m = 0; m < d_n_states; m++, t_out_buf++) { - std::cout << "tb[" << n << "] = " << t_out_bufs << - ", &tb[" << n << "][" << m << "] = " << (&d_out_buf[n][m]) << - ", tb[" << n << "," << m << "] = " << t_out_buf << "\n"; - } - } - } -} - -decoder_viterbi_full_block::~decoder_viterbi_full_block -() -{ - // delete the traceback buffers - - traceback_t_hdl t_out_buf = d_out_buf; - for (size_t n = d_n_traceback_els; n > 0; n--) { - delete [] (*t_out_buf++); - } - delete [] d_out_buf; -} - -size_t -decoder_viterbi_full_block::compute_n_input_items -(size_t n_output_bits) -{ - return (0); -} - -size_t -decoder_viterbi_full_block::compute_n_output_bits -(size_t n_input_items) -{ - return (0); -} - -void -decoder_viterbi_full_block::update_traceback__up -(size_t from_state_ndx, - size_t to_state_ndx, - size_t l_input) -{ -#if 0 -#if DO_PRINT_DEBUG - size_t t_state_print_bits = d_total_memory + 1; - size_t t_mem_print_bits = d_max_memory + 2; -#endif - // update the traceback structure, depending on which variety it is - // doing full trellis before decoding; use d_out_buf - - // get the current state & output state - - traceback_t_ptr t_out_buf = &(d_out_buf[d_time_count] - [from_state_ndx]); - traceback_t_ptr t_next_out_buf = &(d_out_buf[d_time_count+1] - [to_state_ndx]); - if (DO_PRINT_DEBUG_UP_1) { - std::cout << "d_o_b[" << d_time_count+1 << "] => d_o_b prev\n" << - "ndx[" << n << "] == " << from_state_ndx << - ", s[" << n2bs(from_state_ndx,t_state_print_bits) << - "]: max_ndx = " << - n2bs(t_state->d_max_state_ndx,t_state_print_bits) << - ", input = " << n2bs(l_input, d_n_code_inputs+1) << - ": " << t_next_out_buf << " => " << t_out_buf << "\n"; - } - - // and connect output to the current, set inputs on output - - t_next_out_buf->d_prev = t_out_buf; - t_next_out_buf->d_inputs = l_input; -#endif -} - -void -decoder_viterbi_full_block::update_traceback__middle -() -{ -#if 0 - -#if DO_PRINT_DEBUG - size_t t_state_print_bits = d_total_memory + 1; - size_t t_mem_print_bits = d_max_memory + 2; -#endif - // change which d_states' index to use as starting - - d_states_ndx ^= 1; - - // get the state's index for the "to" set of new inputs to get the - // "max" stuff from - - state_t_ptr t_state = d_states[d_states_ndx]; - - // update the traceback structure - // loop over all current states - - traceback_t_ptr t_prev_out_bufs = d_out_buf[d_time_count]; - traceback_t_ptr t_out_bufs = d_out_buf[d_time_count+1]; - - if (DO_PRINT_DEBUG_MIDDLE_1) { - std::cout << "d_o_b[" << d_time_count+1 << "] => d_o_b prev\n"; - } - - for (size_t n = d_n_states; n > 0; n--, t_state++) { - - // simple: get the current state & output state - // and connect output to the current, set inputs on output - - traceback_t_ptr t_out_buf = t_out_bufs++; - traceback_t_ptr t_prev_out_buf = - &(t_prev_out_bufs[t_state->d_max_state_ndx]); - - if (DO_PRINT_DEBUG_MIDDLE_1) { - std::cout << "s[" << n2bs(d_n_states-n,t_state_print_bits) << - "]: max_ndx = " << - n2bs(t_state->d_max_state_ndx,t_state_print_bits) << - ", input = " << n2bs(t_state->d_max_input, d_n_code_inputs+1) << - ": " << t_out_buf << " => " << t_prev_out_buf << "\n"; - } - - t_out_buf->d_prev = t_prev_out_buf; - t_out_buf->d_inputs = t_state->d_max_input; - } - -#endif -} - -void -decoder_viterbi_full_block::update_traceback__term -() -{ -#if 0 - -#if DO_PRINT_DEBUG - size_t t_state_print_bits = d_total_memory + 1; - size_t t_mem_print_bits = d_max_memory + 2; -#endif -// done with all states and all inputs; now update the traceback structure -// change which d_states' index to use as starting - d_states_ndx ^= 1; -// update the number of "up_term" states - d_up_term_ndx ^= 1; -// reduce the number of using states - t_n_up_down_ndx >>= d_n_code_inputs; -// reset the state's index for each set of new inputs - t_state_ndx_ptr = d_up_term_states_ndx[d_up_term_ndx]; -// update the traceback structure -// loop over all current states - traceback_t_ptr t_prev_out_bufs = d_out_buf[d_time_count]; - traceback_t_ptr t_out_bufs = d_out_buf[d_time_count+1]; -#if DO_PRINT_DEBUG_TERM_1 - std::cout << "d_o_b[" << d_time_count+1 << "] => d_o_b prev\n"; -#endif -// loop over all current stored "term" state indices - for (size_t n = 0; n < t_n_up_down_ndx; n++) { -// get the start index and then pointer to each of the "to" states, -// which hold the newest "max" stuff - size_t t_state_ndx = *t_state_ndx_ptr++; - state_t_ptr t_state = &(d_states[d_states_ndx][t_state_ndx]); -// simple: get the current state & output state -// and connect output to the current, set inputs on output - traceback_t_ptr t_out_buf = &(t_out_bufs[t_state_ndx]); - traceback_t_ptr t_prev_out_buf = - &(t_prev_out_bufs[t_state->d_max_state_ndx]); -#if DO_PRINT_DEBUG_TERM_1 - std::cout << "ndx[" << n << "] == " << t_state_ndx << - ", s[" << n2bs(t_state_ndx,t_state_print_bits) << - "]: max_ndx = " << - n2bs(t_state->d_max_state_ndx,t_state_print_bits) << - ", input = " << n2bs(t_state->d_max_input, d_n_code_inputs+1) << - ": " << t_out_buf << " => " << t_prev_out_buf << "\n"; -#endif - t_out_buf->d_prev = t_prev_out_buf; - t_out_buf->d_inputs = t_state->d_max_input; -// finished (for) this state - } - -#endif -} - -void -decoder_viterbi_full_block::decode_private -() -{ -#if 0 - -#if DO_TIME_THOUGHPUT - struct timeval t_tp; - start_timer (&t_tp); -#endif -#if DO_PRINT_DEBUG - size_t t_state_print_bits = d_total_memory + 1; - size_t t_mem_print_bits = d_max_memory + 2; -#endif -// setup variables for quicker access - int t_in_buf_ndx = 0, t_out_buf_ndx = 0; - int t_out_bit_shift = 0; - int t_ninput_items = fixed_rate_noutput_to_ninput (noutput_items); - int t_noutput_bytes = noutput_items * d_out_stream_el_size_bytes; - -#if DO_PRINT_DEBUG_INST - std::cout << "# output items = " << noutput_items << " (" << - t_noutput_bytes << " Bytes, " << (t_noutput_bytes * g_num_bits_per_byte) << - " bits), # input items = " << t_ninput_items << " Symbols\n"; - for (size_t n = 0; n < ninput_items.size(); n++) { - std::cout << "# input items [" << n << "] = " << ninput_items[n] << "\n"; - } -#endif - -// put any leftover bits into the output - if (d_n_saved_bits != 0) { -// copy the leftover from the save buffer -// check to make sure it will all fit - size_t t_noutput_bits = t_noutput_bytes * g_num_bits_per_byte; - size_t t_n_copy; - if (t_noutput_bits < d_n_saved_bits) { -// asking for fewer bits than available; set to copy -// just what's being asked for - t_n_copy = t_noutput_bytes; - } else { -// asking for at least as many bits as available; set to copy all - t_out_buf_ndx = d_n_saved_bits / g_num_bits_per_byte; - t_out_bit_shift = d_n_saved_bits % g_num_bits_per_byte; - t_n_copy = t_out_buf_ndx + (t_out_bit_shift != 0 ? 1 : 0); - } -// do the copy for all output streams (code inputs) -// copy starting at save buffer index "start" - for (size_t n = 0; n < d_n_code_inputs; n++) - bcopy (&(d_save_buffer[n][d_n_saved_bits_start_ndx]), - out_buf[n], t_n_copy); -#if DO_PRINT_DEBUG_INST - std::cout << "Copied " << t_n_copy << " Byte" << - (t_n_copy != 1 ? "s" : "") << ": s_b[][" << - d_n_saved_bits_start_ndx << "] => o_b[][0]\n" << - "# saved bits = " << d_n_saved_bits << - ", o_b_ndx = " << t_out_buf_ndx << - ", bit shift = " << t_out_bit_shift << "\n"; -#endif -// update the number of saved bits and start - if (t_noutput_bits < d_n_saved_bits) { -// asking for fewer bit than available: update -// the number of saved bits and their starting index - d_n_saved_bits_start_ndx += t_noutput_bytes; - d_n_saved_bits -= (t_noutput_bytes * g_num_bits_per_byte); -#if DO_PRINT_DEBUG_INST - std::cout << "Updated # saved bits = " << d_n_saved_bits << - ", index = " << d_n_saved_bits_start_ndx << "\n"; -#endif -// nothing to consume; return the desired number of output items - return (noutput_items); - } else { - d_n_saved_bits_start_ndx = d_n_saved_bits = 0; - } - } -#if DO_PRINT_DEBUG_INST - std::cout << "Starting FSM in state: " << - (d_fsm == fsm_dec_init ? "init" : - (d_fsm == fsm_dec_doing_up ? "up" : - (d_fsm == fsm_dec_doing_middle ? "middle" : - (d_fsm == fsm_dec_doing_term ? "term" : - (d_fsm == fsm_dec_output ? "output" : "unknown"))))) << "\n"; -#endif - -// while there are input items to create - while (t_out_buf_ndx < t_noutput_bytes) { -#if DO_PRINT_DEBUG_FMS - std::cout << "Starting 'while': processing " << t_in_buf_ndx << " of " << - t_ninput_items << " items.\nJumping to state '" << - (d_fsm == fsm_dec_init ? "init" : - (d_fsm == fsm_dec_doing_up ? "up" : - (d_fsm == fsm_dec_doing_middle ? "middle" : - (d_fsm == fsm_dec_doing_term ? "term" : - (d_fsm == fsm_dec_output ? "output" : "unknown"))))) << "'\n"; -#endif -// jump to the correct state in the fsm - switch (d_fsm) { - case fsm_dec_doing_up: -#if DO_PRINT_DEBUG_FSM - std::cout << "Starting fsm_dec_doing_up\n"; -#endif -// set the number of up_down indices - size_t t_n_up_down_ndx = 1 << (d_n_code_inputs * - d_time_count); -// stay in this state until the correct number of input symbols are -// reached; exit also if we run out of input symbols to process - while ((d_time_count < d_max_memory) & - (t_in_buf_ndx < t_ninput_items)) { -#if DO_PRINT_DEBUG_UP_0 - std::cout << "Doing 'while' loop:\n" << - "t_n_up_down_ndx = " << t_n_up_down_ndx << "\n" << - "d_time_count = " << d_time_count << "\n" << - "d_max_memory = " << d_max_memory << "\n" << - "t_in_buf_ndx = " << t_in_buf_ndx << "\n" << - "t_ninput_items = " << t_ninput_items << "\n"; -#endif -// use the "from" states, loop over all inputs and compute the metric for -// each & store it in the "to" state at the end of the connection. -// no need to compare metrics yet, since none join into any given state - -#if 0 -// reset the "to" state's metrics -// probably don't need to do this; try removing later - reset_metrics (d_states_ndx ^ 1); -#if DO_PRINT_DEBUG_UP - std::cout << "Reset Metrics\n"; -#endif -#endif - -// reset the state's index for each set of new inputs - size_t* t_state_ndx_ptr = d_up_term_states_ndx[d_up_term_ndx]; - size_t* t_next_state_ndx_ptr = d_up_term_states_ndx[d_up_term_ndx ^ 1]; -// loop over all current stored "up" states - for (size_t n = 0; n < t_n_up_down_ndx; n++) { - size_t t_state_ndx = *t_state_ndx_ptr++; -// get a pointer to this state's structure - state_t_ptr t_state = &(d_states[d_states_ndx][t_state_ndx]); -// get the connections for all inputs - connection_t_ptr t_connection = t_state->d_connections; -#if DO_PRINT_DEBUG_UP_0 - std::cout << "Looping over all 'up' states:\n" << - "n = " << n << "\n" << - "t_n_up_down_ndx = " << t_n_up_down_ndx << "\n" << - "d_states_ndx = " << d_states_ndx << "\n" << - "t_state_ndx = " << t_state_ndx << "\n" << - "d_n_input_combs = " << d_n_input_combinations << "\n" << - "t_state = " << t_state << "\n" << - "t_connection = " << t_connection << "\n"; -#endif -// loop over all possible input values, 1 bit per input stream - for (size_t q = 0; q < d_n_input_combinations; q++, t_connection++) { -// find the "to" state for this connection - state_t_ptr t_to_state = t_connection->d_to; -// get the output bits for this connection - float* t_output_bit = t_connection->d_output_bits; -// start with this state's metric - float t_metric = t_state->d_max_metric; -#if DO_PRINT_DEBUG_UP_0 - std::cout << - "to state index = " << t_connection->d_to_ndx << "\n" << - "current metric = " << t_metric << "\n"; -#endif - if (d_do_mux_inputs == true) { -// if using mux'ed input streams, handle differently - const float* t_in_buf = &(in_buf[0][t_in_buf_ndx]); -// loop over all encoder-output values - for (size_t r = d_n_code_outputs; r > 0; r--) { -#if DO_PRINT_DEBUG_UP - std::cout << "in_sym = " << *t_in_buf << ", code_out_bit = " << - *t_output_bit << " ==> metric -> "; -#endif - t_metric += ((*t_in_buf++) * (*t_output_bit++)); -#if DO_PRINT_DEBUG_UP - std::cout << t_metric << "\n"; -#endif - } - } else { -// loop over all encoder-output values - for (size_t r = 0; r < d_n_code_outputs; r++) { -#if DO_PRINT_DEBUG_UP - std::cout << "in_sym = " << in_buf[r][t_in_buf_ndx] << - ", code_out_bit = " << *t_output_bit << " ==> metric -> "; -#endif - t_metric += (in_buf[r][t_in_buf_ndx] * (*t_output_bit++)); -#if DO_PRINT_DEBUG_UP - std::cout << t_metric << "\n"; -#endif - } - } - // get the "to" state index - - size_t t_to_ndx = t_connection->d_to_ndx; - - // store the metric in the "to" state; should not have - // been used before - - t_to_state->d_max_metric = t_metric; - - // add the "to" state index to the "up" state list - - *t_next_state_ndx_ptr++ = t_to_ndx; - - // update the traceback structure - - update_traceback__up (t_state, t_to_state, q); - - // next (for) input value - } - - // next (for) "up_term" state - } - - // increment the input buffer indices - - increment_input_indices (false); - - // increment the time counter - - d_time_count++; - - // change which up-term index to use - - d_up_term_ndx ^= 1; - - // increase the number of states to be used - - t_n_up_down_ndx <<= d_n_code_inputs; - - // change which d_states' index to use as starting - - d_states_ndx ^= 1; - - // next (while) input - } - - // if reached the end of doing the "up" part of the trellis, - // switch states into the middle - - if (d_time_count == d_max_memory) { - if (DO_PRINT_DEBUG_FSM) { - std::cout << "Setting FSM to fsm_dec_doing_middle\n"; - } - d_fsm = fsm_dec_doing_middle; - } - if (DO_PRINT_DEBUG_FSM) { - std::cout << "Exited fsm_dec_doing_up\n"; - } - break; - - case (fsm_dec_doing_middle): - if (DO_PRINT_DEBUG_FSM) { - std::cout << "Entered fsm_dec_doing_middle\n"; - } - - // stay in this state until a full block (+ optional - // termination) of input metrics is reached, or until there are - // no more input metrics to parse - - while ((d_time_count < d_block_size_bits) & - (t_in_buf_ndx < t_ninput_items)) { - - // use all states, loop over all inputs, compute the metric - // for each; compare the current metric with all previous - // stored metric in the endpoint of the connection to find the - // highest one. - - // reset the "to" state's metrics - - reset_metrics (d_states_ndx ^ 1); - - // get the state's index for each set of new inputs - - state_t_ptr t_state = d_states[d_states_ndx]; - - if (DO_PRINT_DEBUG_MIDDLE) { - std::cout << "Time Count " << (d_time_count+1) << " of " << - d_block_size_bits << "\nd_states_ndx = " << d_states_ndx << "\n"; - } - - // loop over all current states - - for (size_t n = 0; n < d_n_states; n++, t_state++) { - - // loop over all possible input values, 1 bit per input stream - - connection_t_ptr t_connection = t_state->d_connections; - - if (DO_PRINT_DEBUG_MIDDLE_0) { - std::cout << "Looping over all 'middle' states: " << - n << " of " << d_n_states << "\n"; - } - - for (size_t q = 0; q < d_n_input_combinations; q++, t_connection++) { - - if (DO_PRINT_DEBUG_MIDDLE_0) { - std::cout << "Input = " << n2bs(q, d_n_code_inputs+1) << "\n"; - } - - // start with this state's metric - - float t_metric = t_state->d_max_metric; - - // get the "to" state - - state_t_ptr t_to_state = t_connection->d_to; - - // get that state's metric - - float t_to_metric = t_to_state->d_max_metric; - - // see if the computation is even needed; - // maximum change is d_n_code_outputs if all bits match exactly - - if ((t_to_metric - t_metric) > ((float) 2*d_n_code_outputs)) { - if (DO_PRINT_DEBUG_MIDDLE_0) { - std::cout << "!not computing metric!\n"; - } - continue; - } - - // metrics are close enough; do the computation and the - // compare get the output bits for this connection - - float* t_output_bit = t_connection->d_output_bits; - if (d_do_mux_inputs == true) { - - // if using mux'ed input streams, handle differently - - const float* t_in_buf = &(in_buf[0][t_in_buf_ndx]); - - // loop over all encoder-output values - - for (size_t r = d_n_code_outputs; r > 0; r--) { -#if DO_PRINT_DEBUG_MIDDLE_0 - std::cout << "in_sym = " << *t_in_buf << ", code_out_bit = " << - *t_output_bit << " ==> metric -> "; -#endif - t_metric += ((*t_in_buf++) * (*t_output_bit++)); -#if DO_PRINT_DEBUG_MIDDLE_0 - std::cout << t_metric << "\n"; -#endif - } - } else { -// loop over all encoder-output values - for (size_t r = 0; r < d_n_code_outputs; r++) { -#if DO_PRINT_DEBUG_MIDDLE_0 - std::cout << "in_sym = " << in_buf[r][t_in_buf_ndx] << - ", code_out_bit = " << *t_output_bit << " ==> metric -> "; -#endif - t_metric += (in_buf[r][t_in_buf_ndx] * (*t_output_bit++)); -#if DO_PRINT_DEBUG_MIDDLE_0 - std::cout << t_metric << "\n"; -#endif - } - } -// done with this input value; compare old and new metrics - if (t_metric > t_to_metric) { -#if DO_PRINT_DEBUG_MIDDLE - std::cout << "New Metric to s[" << - n2bs (t_connection->d_to_ndx,t_state_print_bits) << "]: "; - if (t_to_state->d_max_metric == -1e10) { - std::cout << "setting to "; - } else { - std::cout << "was s[" << - n2bs(t_to_state->d_max_state_ndx,t_state_print_bits) << - "]i[" << n2bs (t_to_state->d_max_input, d_n_code_inputs+1) << - "]@ " << t_to_state->d_max_metric << " now "; - } - std::cout << "s[" << n2bs(n,t_state_print_bits) << "] i[" << - n2bs (q, d_n_code_inputs+1) << "]@ " << t_metric << "\n"; -#endif -// new metric is better; copy that info into the "to" state - t_to_state->d_max_metric = t_metric; - t_to_state->d_max_state_ndx = n; - t_to_state->d_max_input = q; - } - // next (for) input value - } - // next (for) state - } - - // done with all states and all inputs; - // update the traceback buffers - - update_traceback__middle (); - - // increment the input buffer indices - - increment_input_indices (); - - // increment the time counter - - d_time_count++; - - // check (while) staying in this fsm state or not - } - - if ((d_block_size_bits != 0) & - (d_time_count == d_block_size_bits)) { - if (DO_PRINT_DEBUG_FSM) { - std::cout << "Setting FSM to fsm_dec_doing_term\n"; - } - d_fsm = fsm_dec_doing_term; - } - if (DO_PRINT_DEBUG_FSM) { - std::cout << "Exited fsm_dec_doing_middle\n"; - } - break; - - case (fsm_dec_doing_term): - if (DO_PRINT_DEBUG_FSM) { - std::cout << "Entered fsm_dec_doing_term\n"; - } - - // set the "next" up_down index to the end of their states - - size_t t_time_count = d_max_memory - (d_time_count - d_block_size_bits); - t_n_up_down_ndx = 1 << (d_n_code_inputs * t_time_count); - - // stay in this state until the correct number of input metrics - // are reached; exit if we run out of input metrics to process - - while ((t_time_count > 0) & - (t_in_buf_ndx < t_ninput_items)) { - - if (DO_PRINT_DEBUG_TERM) { - std::cout << "Doing time " << (d_max_memory - t_time_count + 1) << - " of " << d_max_memory << "; starting buf[" << t_in_buf_ndx << - "] of [" << t_ninput_items << "]\n"; - } - - // FIXME: loop over just the "0" inputs - - // use the "to" states, and compute the metric for each, - // compare & store it in the "to" state at the end of the - // connection. - - // reset the "to" state's metrics - - reset_metrics (d_states_ndx ^ 1); - - // reset the state's index for each set of new inputs - - size_t* t_state_ndx_ptr = d_up_term_states_ndx[d_up_term_ndx]; - size_t* t_next_state_ndx_ptr = d_up_term_states_ndx[d_up_term_ndx ^ 1]; - - // loop over all current stored "term" state indeces - - for (size_t n = 0; n < t_n_up_down_ndx; n++) { - size_t t_state_ndx = *t_state_ndx_ptr++; - state_t_ptr t_state = &(d_states[d_states_ndx][t_state_ndx]); - - // loop over just the all 0 input value (d_connections[0]) - - connection_t_ptr t_connection = t_state->d_connections; - - // get the "to" state - - state_t_ptr t_to_state = t_connection->d_to; - - // start with this state's metric - - float t_metric = t_state->d_max_metric; - - // get that state's metric - - float t_to_metric = t_to_state->d_max_metric; - - if (DO_PRINT_DEBUG_TERM) { - std::cout << "Term state " << (n+1) << " of " << - t_n_up_down_ndx << "; using d_s[" << d_states_ndx << "][" << - n2bs(t_state_ndx,t_state_print_bits) << "]\n"; - } - - // see if the computation is even needed; - // maximum change is d_n_code_outputs if all bits match exactly - - if ((t_to_metric - t_metric) > ((float) 2*d_n_code_outputs)) { - if (DO_PRINT_DEBUG_TERM) { - std::cout << "!not computing metric!\n"; - } - continue; - } - - // metrics are close enough; do the computation and the - // compare get the output bits for this connection - - float* t_output_bit = t_connection->d_output_bits; - if (d_do_mux_inputs == true) { -// if using mux'ed input streams, handle differently - const float* t_in_buf = &(in_buf[0][t_in_buf_ndx]); -// loop over all encoder-output values - for (size_t r = d_n_code_outputs; r > 0; r--) { - t_metric += ((*t_in_buf++) * (*t_output_bit++)); - } - } else { -// loop over all encoder-output values - for (size_t r = 0; r < d_n_code_outputs; r++) { - t_metric += (in_buf[r][t_in_buf_ndx] * (*t_output_bit++)); - } - } -// done with this input value; compare old and new metrics -// see if it's the best metric - if (t_metric > t_to_metric) { -#if DO_PRINT_DEBUG_TERM - std::cout << "New Metric to s[" << - n2bs (t_connection->d_to_ndx,t_state_print_bits) << "]: "; - if (t_to_state->d_max_metric == -1e10) { - std::cout << "setting to "; - } else { - std::cout << "was s[" << - n2bs(t_to_state->d_max_state_ndx,t_state_print_bits) << - "]i[" << n2bs (t_to_state->d_max_input, d_n_code_inputs+1) << - "]@ " << t_to_state->d_max_metric << " now "; - } - std::cout << "s[" << n2bs(t_state_ndx,t_state_print_bits) << - "] i[" << n2bs (0, d_n_code_inputs+1) << "]@ " << t_metric << "\n"; -#endif - t_to_state->d_max_metric = t_metric; - t_to_state->d_max_state_ndx = t_state_ndx; - t_to_state->d_max_input = 0; - } -// add the "to" state's index to the "next" set of state's indices list - *t_next_state_ndx_ptr++ = t_connection->d_to_ndx; -// finished (for) this state - } - - // update the traceback buffers - - update_traceback__term (); - increment_input_indices (false); - - // increment the time counters - - t_time_count--; - d_time_count++; - - // finished (while) staying in this fsm state or not - - } - - if (t_time_count == 0) { - // finished this trellis, now move as much of the decoded - // input to the output buffer as possible - if (DO_PRINT_DEBUG_FSM) { - std::cout << "Setting FSM to fsm_dec_output\n"; - } - d_fsm = fsm_dec_output; - } - if (DO_PRINT_DEBUG_FSM) { - std::cout << "Exited fsm_dec_doing_term\n"; - } - break; - - case (fsm_dec_output): - if (DO_PRINT_DEBUG_FSM) { - std::cout << "Entered fsm_dec_output.\n"; - } - - // this is done in reverse bit order (last time to first time) - // using the traceback structure in d_out_buf, starting with the - // maximum valued one in the last time slot, then using the - // traceback's "d_prev" link to trace the trellis back - - // see where the output data will terminate - - int t_next_out_buf_ndx = (t_out_buf_ndx + - (d_block_size_bits / g_num_bits_per_byte)); - int t_next_out_bit_shift = (t_out_bit_shift + - (d_block_size_bits % g_num_bits_per_byte)); - if (t_next_out_bit_shift >= g_num_bits_per_byte) { - t_next_out_bit_shift -= g_num_bits_per_byte; - t_next_out_buf_ndx++; - } -#if DO_PRINT_DEBUG_OUTPUT - std::cout << "First bit in at out[][" << t_out_buf_ndx << "].[" << - t_out_bit_shift << "] -> " << d_block_size_bits << " bits == " << - (d_block_size_bits / g_num_bits_per_byte) << " Byte" << - ((d_block_size_bits / g_num_bits_per_byte) != 1 ? "s" : "") << - " + " << (d_block_size_bits % g_num_bits_per_byte) << " bit" << - ((d_block_size_bits % g_num_bits_per_byte) != 1 ? "s" : "") << - "\nNext set of bits start at out[][" << t_next_out_buf_ndx << - "].[" << t_next_out_bit_shift << "]\n"; -#endif -// find the starting traceback structure - traceback_t_ptr t_out_buf; - if (d_do_termination == true) { -// FIXME: assume termination state == 0 -#if DO_PRINT_DEBUG_OUTPUT_0 - std::cout << "Using termination; going through trellis for " << - d_max_memory << " bit" << - ((d_max_memory != 1) ? "s" : "") << "\n"; -#endif - t_out_buf = &(d_out_buf[d_time_count][0]); -#if DO_PRINT_DEBUG_OUTPUT_0 - std::cout << "Starting traceback ptr " << t_out_buf << "\n"; -#endif -// skip over the termination bits - for (size_t n = d_max_memory; n > 0; n--) { - t_out_buf = t_out_buf->d_prev; -#if DO_PRINT_DEBUG_OUTPUT_0 - std::cout << "Next traceback ptr " << t_out_buf << "\n"; -#endif - } - } else { -// no termination but doing block coding; -// FIXME: use the state with the bext metric -// get the state's index for each set of new inputs - state_t_ptr t_state = d_states[d_states_ndx]; - float t_max_metric = t_state->d_max_metric; - size_t t_max_state_ndx = 0; - t_state++; -// loop over all current states - for (size_t n = 1; n < d_n_states; n++, t_state++) { -// start with this state's metric - float t_metric = t_state->d_max_metric; -// compare with current max - if (t_metric > t_max_metric) { - t_max_metric = t_metric; - t_max_state_ndx = n; - } - } -// get the correct out_buf reference to start with - t_out_buf = &(d_out_buf[d_time_count][t_max_state_ndx]); - } -#if DO_PRINT_DEBUG_OUTPUT - std::cout << "Found starting traceback ptr " << t_out_buf << - "; getting all " << d_block_size_bits << " bits per stream.\n"; -#endif -// now we've got the starting traceback structure address; -// check to make sure there is enough space in each output buffer - size_t t_block_bit_ndx = d_block_size_bits; - if ((t_next_out_buf_ndx > t_noutput_bytes) | - ((t_next_out_buf_ndx == t_noutput_bytes) & - (t_next_out_bit_shift != 0))) { -// not enough space for all output bits; -// find the number of extra bits to save - size_t t_save_buf_ndx = t_next_out_buf_ndx - t_noutput_bytes; - size_t t_n_extra_bits = ((t_save_buf_ndx * g_num_bits_per_byte) + - t_next_out_bit_shift); -// set the number of saved bits - d_n_saved_bits = t_n_extra_bits; -// remove the extra bits from the number to copy to the output buffer - t_block_bit_ndx -= t_n_extra_bits; -// find the actual output buf index, once we get there - t_next_out_buf_ndx -= t_save_buf_ndx; -#if DO_PRINT_DEBUG_OUTPUT - std::cout << "Not enough output buffer space:\n" << - "len (o_b) = " << t_noutput_bytes << " ==> " << - t_n_extra_bits << " extra bit" << - (t_n_extra_bits != 1 ? "s" : "") << " == " << - t_save_buf_ndx << " Byte" << - (t_save_buf_ndx != 1 ? "s" : "") << ", " << - t_next_out_bit_shift << " bit" << - (t_next_out_bit_shift != 1 ? "s" : "") << "\n"; -#endif -// zero each output buffers' bytes - size_t t_n_zero = t_save_buf_ndx + (t_next_out_bit_shift ? 1 : 0); -#if DO_PRINT_DEBUG_OUTPUT - size_t t_n_out_bytes = ((d_block_size_bits / g_num_bits_per_byte) + - ((d_block_size_bits % g_num_bits_per_byte) ? 1 : 0)); - std::cout << "Zeroing save buffer from for " << t_n_zero << - " Byte" << (t_n_zero != 1 ? "s" : "") << " (of " << - d_block_size_bits << " bit" << - (d_block_size_bits != 1 ? "s" : "") << " == " << t_n_out_bytes << - " Byte" << (t_n_out_bytes != 1 ? "s" : "") << ")\n"; -#endif - for (size_t m = 0; m < d_n_code_inputs; m++) - bzero (d_save_buffer[m], t_n_zero); -// loop over all extra bits - for (size_t n = t_n_extra_bits; n > 0; n--) { -// first decrement the output bit & byte as necessary - if (--t_next_out_bit_shift < 0) { - t_next_out_bit_shift += g_num_bits_per_byte; - t_save_buf_ndx--; - } -// get the encoder inputs to output - size_t t_inputs = t_out_buf->d_inputs; -// loop over all code inputs (decoder-outputs), 1 bit per stream - for (size_t m = 0; m < d_n_code_inputs; m++) { - d_save_buffer[m][t_save_buf_ndx] |= - ((t_inputs & 1) << t_next_out_bit_shift); - t_inputs >>= 1; - } - t_out_buf = t_out_buf->d_prev; -#if DO_PRINT_DEBUG_OUTPUT_0 - std::cout << "Next traceback ptr " << t_out_buf << "\n"; -#endif - } -// at exit, "t_out_buf_ndx" should be == t_noutput_bytes, and -// "t_out_bit_shift" should be 0; check these! -#if DO_PRINT_DEBUG_OUTPUT - std::cout << "n_o_b_ndx (" << t_next_out_buf_ndx << ") ?=? " << - "#o_B (" << t_noutput_bytes << ") & t_o_b_sh (" << - t_next_out_bit_shift << ") ?=? 0\n"; - assert (t_next_out_buf_ndx == t_noutput_bytes); - assert (t_next_out_bit_shift == 0); -#endif - } -// set the correct output buffer index and bit shift - t_out_bit_shift = t_next_out_bit_shift; - t_out_buf_ndx = t_next_out_buf_ndx; -// copy any remaining bits looping backwards in bit-time -// through the traceback trellis - for (size_t n = t_block_bit_ndx; n > 0; n--) { -// first decrement the output bit & byte as necessary - if (--t_out_bit_shift < 0) { - t_out_bit_shift += g_num_bits_per_byte; - t_out_buf_ndx--; - } -// get the encoder inputs to output - size_t t_inputs = t_out_buf->d_inputs; -// loop over all code inputs (decoder-outputs), 1 bit per stream - for (size_t m = 0; m < d_n_code_inputs; m++) { - out_buf[m][t_out_buf_ndx] |= ((t_inputs & 1) << t_out_bit_shift); - t_inputs >>= 1; - } - t_out_buf = t_out_buf->d_prev; -#if DO_PRINT_DEBUG_OUTPUT_0 - std::cout << "Next traceback ptr " << t_out_buf << "\n"; -#endif - } -// set the next output byte and bit-shift - t_out_bit_shift = t_next_out_bit_shift; - t_out_buf_ndx = t_next_out_buf_ndx; -#if DO_PRINT_DEBUG_FSM - std::cout << "Set FSM to fsm_dec_init\n"; -#endif - d_fsm = fsm_dec_init; -#if DO_PRINT_DEBUG_FSM - std::cout << "Exited fsm_dec_output\n"; -#endif - break; - case (fsm_dec_init): -#if DO_PRINT_DEBUG_FSM - std::cout << "Entered fsm_dec_init\n"; -#endif -// this is called immediately (first input bit upon startup), -// or after termination of a trellis. - -// reset states to the 0'th one - d_up_term_ndx = d_states_ndx = 0; -// zero the metrics for those states - zero_metrics (0); -#if 0 -// might not need to do this; check and see after it works -// reset up_term states and number so that there is 1 item, the "0" state. - bzero (d_up_term_states_ndx[0], sizeof (size_t) * d_n_states); - bzero (d_up_term_states_ndx[1], sizeof (size_t) * d_n_states); -#else - d_up_term_states_ndx[0][0] = 0; -#endif -// reset time count back to the start - d_time_count = 0; -#if 0 -// reset the traceback structures -// might not need to do this; check and see after it works - traceback_t_hdl t_out_bufs = d_out_buf; - for (size_t n = d_n_traceback_els; n > 0; n--) { - traceback_t_ptr t_out_buf = (*t_out_bufs++); - for (size_t m = d_n_states; m > 0; m--, t_out_buf++) { - t_out_buf->d_prev = NULL; - t_out_buf->d_inputs = -1; - } - } -#endif -// set the fsm to "doing up" -#if DO_PRINT_DEBUG_FSM - std::cout << "Set FSM to fsm_dec_doing_up\n"; -#endif - d_fsm = fsm_dec_doing_up; -#if DO_PRINT_DEBUG_FSM - std::cout << "Exited fsm_dec_init\n"; -#endif - break; -// should never get here! - default: - assert (0); -// done (switch) with FSM - } -// done (while) there are inputs - } - -// consume all of the input items on all input streams -// "ninput_items[]" doesn't seem to be reliable, -// so compute this from the actual number of blocks processed -#if DO_PRINT_DEBUG_EXIT - std::cout << "Exiting FSM in state: " << - (d_fsm == fsm_dec_init ? "init" : - (d_fsm == fsm_dec_doing_up ? "up" : - (d_fsm == fsm_dec_doing_middle ? "middle" : - (d_fsm == fsm_dec_doing_term ? "term" : - (d_fsm == fsm_dec_output ? "output" : "unknown"))))) << "\n" << - "Consuming " << t_in_buf_ndx << - " input items on each input stream (of " << t_ninput_items << ").\n"; -#endif - consume_each (t_in_buf_ndx); - -// make sure the number of output items makes sense -// t_out_buf_ndx always points to the current index -// t_out_bit_shift always points to the next bit position to be written - int t_leftover_bytes = t_out_buf_ndx % d_out_stream_el_size_bytes; - int t_leftover_bits = ((t_leftover_bytes * g_num_bits_per_byte) + - t_out_bit_shift); - int t_noutput_items = noutput_items; -#if DO_PRINT_DEBUG_EXIT - std::cout << "Final o_b[" << t_out_buf_ndx << "][" << - t_out_bit_shift << "] of " << t_noutput_bytes << - ", el_size = " << d_out_stream_el_size_bytes << - ", lo_Bytes = " << t_leftover_bytes << - ", t_lo_bits = " << t_leftover_bits << "\n" << - "Desired # output items = " << noutput_items << "\n"; -#endif - if (t_leftover_bits != 0) { - // should never get here! -#if 1 - assert (0); -#else - int t_ndx = t_out_buf_ndx - t_leftover_bytes; - size_t t_n_copy = t_leftover_bytes + ((t_out_bit_shift != 0) ? 1 : 0); - assert (t_n_copy <= d_out_stream_el_size_bytes); -// copy the leftover into the save buffer - for (size_t n = 0; n < d_n_code_inputs; n++) { - bcopy (&(out_buf[n][t_ndx]), d_save_buffer[n], t_n_copy); - } - t_noutput_items = t_ndx / d_out_stream_el_size_bytes; - d_n_saved_bits = t_leftover_bits; -#if DO_PRINT_DEBUG_EXIT - std::cout << "Copied " << t_n_copy << " Byte" << - (t_n_copy != 1 ? "s" : "") << " from o_b[][" << t_ndx << - "] into each save buffer.\n" << - "Actual #output items = " << t_noutput_items << - ", # saved bit(s) = " << d_n_saved_bits << "\n"; -#endif -#endif - } - -#endif - -#if DO_TIME_THOUGHPUT - u_long d_t = end_timer (&t_tp); - - std::cout << "decoder_viterbi_full_block: Completed " << t_ninput_items << - " bits in " << d_t << " usec => " << - 1e6*(((double)(t_ninput_items))/((double) d_t)) << - " b/s\n"; -#endif -} diff --git a/gr-error-correcting-codes/src/lib/libecc/decoder_viterbi_full_block.h b/gr-error-correcting-codes/src/lib/libecc/decoder_viterbi_full_block.h deleted file mode 100644 index ba12cf11c..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/decoder_viterbi_full_block.h +++ /dev/null @@ -1,81 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_DECODER_VITERBI_FULL_BLOCK_H -#define INCLUDED_DECODER_VITERBI_FULL_BLOCK_H - -#include "decoder_viterbi.h" - -class decoder_viterbi_full_block : public decoder_viterbi -{ -/*! - * \brief Decode the incoming streams using a Viterbi-style decoder, - * doing full trellis block decoding before putting out any - * decoded bits. - * - * input: streams of metrics, two per code output: one for the 0-bit - * metrics and the other for the 1-bit metric. - * - * output: stream(s) of output bits - */ - -public: - decoder_viterbi_full_block (int sample_precision, - encoder_convolutional* l_encoder); - - virtual ~decoder_viterbi_full_block (); - - virtual size_t compute_n_input_items (size_t n_output_bits); - virtual size_t compute_n_output_bits (size_t n_input_items); - -protected: - virtual void decode_private (); - virtual void update_traceback__up (size_t from_state_ndx, - size_t to_state_ndx, - size_t l_input); - virtual void update_traceback__middle (); - virtual void update_traceback__term (); - -/* - * traceback_t: used to store all encode-input bits for - * all possible paths, when computing all trellis bits before - * determining the ML decode-output sequence. - * - * d_prev: the connection to the previous bit's traceback structure - * - * d_inputs: the inputs (one per bit) for this connection - */ - - typedef struct traceback_t { - struct traceback_t *d_prev; - int d_inputs; - } traceback_t, *traceback_t_ptr, **traceback_t_hdl; - -/* - * d_n_total_inputs_per_stream: how many bits to store for each - * state to determine the best decoder-output (encoder-input) bits - */ - size_t d_n_inputs_per_stream; - traceback_t_hdl d_out_buf; -}; - -#endif /* INCLUDED_DECODER_VITERBI_FULL_BLOCK_H */ diff --git a/gr-error-correcting-codes/src/lib/libecc/encoder.cc b/gr-error-correcting-codes/src/lib/libecc/encoder.cc deleted file mode 100644 index 336698025..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/encoder.cc +++ /dev/null @@ -1,225 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <encoder.h> -#include <iostream> - -#define DO_PRINT_DEBUG 0 - -/* - * encode a certain number of output bits - * - * the 'in_buf' and 'out_buf' must have enough memory to handle the - * number of input and output bits; no error checking is done! - * - * n_bits_to_output: the number of bits per output stream to encode - * - * returns the actual number of bits used per input stream - */ - -size_t -encoder::encode -(const code_input_ptr in_buf, - code_output_ptr out_buf, - size_t n_bits_to_output) -{ - if (in_buf == 0) { - std::cerr << "encoder::encode{output}: Error: " - "input buffer is NULL.\n"; - assert (0); - } - if (out_buf == 0) { - std::cerr << "encoder::encode{output}: Error: " - "output buffer is NULL.\n"; - assert (0); - } - if (n_bits_to_output == 0) { - std::cerr << "encoder::encode{output}: Warning: " - "no output bits requested.\n"; - return (0); - } - - // set the class-internal number of input bits and - // output bits left to encode - - d_in_buf = in_buf; - d_out_buf = out_buf; - - // check that there are enough output buffer items - - if (d_out_buf->n_items_left() < n_bits_to_output) { - std::cerr << "encoder::encode{output}: Warning: " - "output buffer size (" << d_out_buf->n_items_left() << - ") is less than the desired number of output items (" << - n_bits_to_output << ") ... using lower number.\n"; - n_bits_to_output = d_out_buf->n_items_left(); - } - - // check that there are enough input buffer items - - size_t n_bits_to_input = compute_n_input_bits (n_bits_to_output); - - if (d_in_buf->n_items_left() < n_bits_to_input) { - std::cerr << "encoder::encode{output}: Warning: input buffer size (" << - d_in_buf->n_items_left() << ") is less than the computed number " - "of required input items (" << n_bits_to_input << - ") ... using lower number.\n"; - n_bits_to_input = d_in_buf->n_items_left(); - n_bits_to_output = compute_n_output_bits (n_bits_to_input); - } - - // set the correct number of I/O bits - - d_n_bits_to_input = n_bits_to_input; - d_n_bits_to_output = n_bits_to_output; - - if (DO_PRINT_DEBUG) { - std::cout << - "Before Encoding{output}:\n" - " # output bits = " << d_n_bits_to_output << "\n" - " # input bits = " << d_n_bits_to_input << "\n" - " # output bits used = " << d_out_buf->n_items_used() << "\n" - " # input bits used = " << d_in_buf->n_items_used() << "\n"; - } - - // call the private encode function - - encode_private (); - - if (DO_PRINT_DEBUG) { - std::cout << - "After Encoding{output}:\n" - " # output bits = " << d_n_bits_to_output << "\n" - " # input bits = " << d_n_bits_to_input << "\n" - " # output bits used = " << d_out_buf->n_items_used() << "\n" - " # input bits used = " << d_in_buf->n_items_used() << "\n"; - } - - // clear these buffers, just in case - - d_in_buf = 0; - d_out_buf = 0; - - // return the actual number of input bits used - - return (n_bits_to_input - d_n_bits_to_input); -} - -/* - * encode a certain number of input bits - * - * the 'in_buf' and 'out_buf' must have enough memory to handle the - * number of input and output bits; no error checking is done! - * - * n_bits_to_input: the number of bits per input stream to encode - * - * returns the actual number of bits written per output stream - */ - -size_t -encoder::encode -(const code_input_ptr in_buf, - size_t n_bits_to_input, - code_output_ptr out_buf) -{ - if (in_buf == 0) { - std::cerr << "encoder::encode{input}: Error: input buffer is NULL.\n"; - assert (0); - } - if (out_buf == 0) { - std::cerr << "encoder::encode{input}: Error: output buffer is NULL.\n"; - assert (0); - } - if (n_bits_to_input == 0) { - std::cerr << "encoder::encode{input}: Warning: no input bits requested.\n"; - return (0); - } - - // set the class-internal number of input and - // output bits left to encode - - d_in_buf = in_buf; - d_out_buf = out_buf; - - // check that there are enough input buffer items - - if (d_in_buf->n_items_left() < n_bits_to_input) { - std::cerr << "encoder::encode{input}: Warning: input buffer size (" << - d_in_buf->n_items_left() << ") is less than the desired number " - "of input items (" << n_bits_to_input << - ") ... using lower number.\n"; - n_bits_to_input = d_in_buf->n_items_left(); - } - - // check that there are enough output buffer items - - size_t n_bits_to_output = compute_n_output_bits (n_bits_to_input); - - if (d_out_buf->n_items_left() < n_bits_to_output) { - std::cerr << "encoder::encode{input}: Warning: output buffer size (" << - d_out_buf->n_items_left() << ") is less than the computed number " - "of required output items (" << n_bits_to_output << - ") ... using lower number.\n"; - n_bits_to_output = d_out_buf->n_items_left(); - n_bits_to_input = compute_n_input_bits (n_bits_to_output); - } - - // set the correct number of I/O bits - - d_n_bits_to_input = n_bits_to_input; - d_n_bits_to_output = n_bits_to_output; - - if (DO_PRINT_DEBUG) { - std::cout << - "Before Encoding{input}:\n" - " # output bits = " << d_n_bits_to_output << "\n" - " # input bits = " << d_n_bits_to_input << "\n" - " # output bits used = " << d_out_buf->n_items_used() << "\n" - " # input bits used = " << d_in_buf->n_items_used() << "\n"; - } - - // call the private encode function - - encode_private (); - - if (DO_PRINT_DEBUG) { - std::cout << - "After Encoding{input}:\n" - " # output bits = " << d_n_bits_to_output << "\n" - " # input bits = " << d_n_bits_to_input << "\n" - " # output bits used = " << d_out_buf->n_items_used() << "\n" - " # input bits used = " << d_in_buf->n_items_used() << "\n"; - } - - // clear these buffers, just in case - - d_in_buf = 0; - d_out_buf = 0; - - // return the actual number of output bits written - - return (n_bits_to_output - d_n_bits_to_output); -} diff --git a/gr-error-correcting-codes/src/lib/libecc/encoder.h b/gr-error-correcting-codes/src/lib/libecc/encoder.h deleted file mode 100644 index e02f1845f..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/encoder.h +++ /dev/null @@ -1,90 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_ENCODER_H -#define INCLUDED_ENCODER_H - -#include "code_io.h" - -class encoder -{ - /* - * class encoder - * A virtual class upon which all encoder types can be built. - * This class provides the basic methods and variables - * generic for all encoders. - */ -public: - encoder () {}; - virtual ~encoder () {}; - - /* - * compute_n_...: to be defined by inheriting classes, in order to - * allow for user-functions to figure out how many inputs are - * required to generate a given number of outputs, and vice versa. - * Can't define them without knowing the encoder type. - * - * Compute the number of input bits needed to produce 'n_output' bits, - * and the number of output bits which will be produced by 'n_input' - * bits ... for a single stream only. - */ - - virtual size_t compute_n_input_bits (size_t n_output_bits) = 0; - virtual size_t compute_n_output_bits (size_t n_input_bits) = 0; - - /* - * encode: given the input and output buffers, either encode up to - * the number of output bits or encode the number of input bits - * ... if the buffers support either encoding amounts. - */ - - virtual size_t encode (const code_input_ptr in_buf, - code_output_ptr out_buf, - size_t n_bits_to_output); - virtual size_t encode (const code_input_ptr in_buf, - size_t n_bits_to_input, - code_output_ptr out_buf); - -/* for remote access to internal info */ - - inline const size_t block_size_bits () {return (d_block_size_bits);}; - inline const size_t n_code_inputs () {return (d_n_code_inputs);}; - inline const size_t n_code_outputs () {return (d_n_code_outputs);}; - inline const size_t total_n_enc_bits () {return (d_total_n_enc_bits);}; - -protected: - /* - * encode_private: encode the given in_buf and write the output bits - * to the out_buf, using internal class variables. This function is - * called from the publically available "encode()" methods, which - * first set the internal class variables before executing. - */ - - virtual void encode_private () = 0; - - size_t d_block_size_bits, d_n_code_inputs, d_n_code_outputs; - size_t d_total_n_enc_bits, d_n_bits_to_input, d_n_bits_to_output; - code_input_ptr d_in_buf; - code_output_ptr d_out_buf; -}; - -#endif /* INCLUDED_ENCODER_H */ diff --git a/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.cc b/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.cc deleted file mode 100644 index bb93b7352..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.cc +++ /dev/null @@ -1,375 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "encoder_convolutional.h" -#include <assert.h> -#include <iostream> - -#define DO_TIME_THOUGHPUT 0 -#define DO_PRINT_DEBUG_FSM 0 - -#include <mld/mld_timer.h> - -void -encoder_convolutional::encoder_convolutional_init -(int block_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generators, - const std::vector<int>* code_feedback, - bool do_termination, - int start_memory_state, - int end_memory_state) -{ - // error checking on the input arguments is done by the trellis class - - if (code_feedback) - d_trellis = new code_convolutional_trellis - (block_size_bits, - n_code_inputs, - n_code_outputs, - code_generators, - *code_feedback, - do_termination, - end_memory_state); - else - d_trellis = new code_convolutional_trellis - (block_size_bits, - n_code_inputs, - n_code_outputs, - code_generators, - do_termination, - end_memory_state); - - // set the initial FSM state to 'init' - - d_fsm_state = fsm_enc_conv_init; - d_n_enc_bits = 0; - - // create the class block variables - - d_block_size_bits = block_size_bits; - d_n_code_inputs = n_code_inputs; - d_n_code_outputs = n_code_outputs; - d_do_streaming = d_trellis->do_streaming (); - d_do_termination = d_trellis->do_termination (); - d_total_n_delays = d_trellis->total_n_delays (); - d_n_bits_to_term = d_trellis->n_bits_to_term (); - - // parse the init state - - memory_t t_mask = (memory_t)((1 << d_total_n_delays) - 1); - size_t t_n_states = (1 << d_total_n_delays); - memory_t t_start_memory_state = (memory_t) start_memory_state; - - if (t_start_memory_state != (t_start_memory_state & t_mask)) { - std::cout << "encoder_convolutional: Warning: " << - "provided start memory state (" << start_memory_state << - ") is out of the state range [0, " << - (t_n_states-1) << "]; masking off the unused bits.\n"; - - start_memory_state &= t_mask; - } - - d_init_state = start_memory_state; - - // reset the inputs and outputs, both to get the correct size() and - // for the sake of zeroing them out. - - d_current_inputs.assign (d_n_code_inputs, 0); - d_current_outputs.assign (d_n_code_outputs, 0); -} - -void -encoder_convolutional::encode_private -() -{ - struct timeval t_tp; - if (DO_TIME_THOUGHPUT) { - start_timer (&t_tp); - } - - // reset buffer indices - - d_total_n_enc_bits = 0; - - // while there are inputs and outputs left to process ... - - while ((d_n_bits_to_input != 0) | - (d_n_bits_to_output != 0) | - (d_fsm_state == fsm_enc_conv_init)) { - - // jump to the correct state in the fsm - - switch (d_fsm_state) { - - case fsm_enc_conv_init: - - if (DO_PRINT_DEBUG_FSM) - std::cout << "Starting FSM Doing Init\n"; - - // copy the init states to the current memory - - d_memory = d_init_state; - - // if not doing streaming, things to do; else nothing more do - - if (d_do_streaming == false) { - - // reset the number of encoded bits in this block (which is - // used to compare with the number of bits in the block) - - d_n_enc_bits = 0; - } - - // move to the 'input' state - - d_fsm_state = fsm_enc_conv_doing_input; - - if (DO_PRINT_DEBUG_FSM) - std::cout << "FSM State set to Doing Input\n" - "Ending FSM Doing Init\n"; - - break; - - case fsm_enc_conv_doing_input: - - if (DO_PRINT_DEBUG_FSM) - std::cout << "Starting FSM Doing Input\n"; - - // working through the trellis section which requires input bits - // from external sources; loop up to the block size (before - // termination bits, if any), counting down the number of - // available input bits. - - encode_loop (d_n_bits_to_input, d_block_size_bits); - - // finished this loop; check for jumping to the next state - - if ((d_n_enc_bits == d_block_size_bits) & (d_do_streaming == false)) { - - // jump to another state, depending on termination requirement - - if (d_do_termination == true) { - d_n_enc_bits = 0; - d_fsm_state = fsm_enc_conv_doing_term; - - if (DO_PRINT_DEBUG_FSM) - std::cout << "FSM State set to Doing Term\n"; - - } else { - d_fsm_state = fsm_enc_conv_init; - - if (DO_PRINT_DEBUG_FSM) - std::cout << "FSM State set to Init\n"; - } - } - - if (DO_PRINT_DEBUG_FSM) - std::cout << "Ending FSM Doing Input\n"; - - break; - - case fsm_enc_conv_doing_term: - - if (DO_PRINT_DEBUG_FSM) - std::cout << "Starting FSM Doing Term\n"; - - // terminating the trellis, trying to get to a specific state; - // better get here only when do_termination is true, but check - // just in case; lop up to the max memory, counting down the - // number of output bits left - - if (d_do_termination == true) { - if (d_n_enc_bits == 0) { - // first time through this; save the starting termination state - d_term_state = d_memory; - } - - encode_loop (d_n_bits_to_output, d_n_bits_to_term); - - // finished this loop; check for jumping to the next state - - if (d_n_enc_bits == d_n_bits_to_term) { - d_fsm_state = fsm_enc_conv_init; - - if (DO_PRINT_DEBUG_FSM) - std::cout << "FSM State set to Init\n"; - } - } else { - // should never get here! - assert (0); - } - - if (DO_PRINT_DEBUG_FSM) - std::cout << "Ending FSM Doing Term\n"; - - break; - - default: - // better never get here! - assert (0); - break; - - // done (switch) with FSM - } - - // done (while) there are inputs and outputs - } - - if (DO_TIME_THOUGHPUT) { - // compute the throughput for this particular function call - u_long d_t = end_timer (&t_tp); - std::cout << "Completed " << d_total_n_enc_bits << - " bits in " << d_t << " usec => " << - 1e6*(((double) d_total_n_enc_bits)/((double) d_t)) << - " b/s\n"; - } -} - -void -encoder_convolutional::encode_loop -(size_t& which_counter, - size_t how_many) -{ - // generic encode_loop - - while ((which_counter > 0) & (d_n_enc_bits < how_many)) { - - // get the next set of input bits from all streams; - // written into d_current_inputs - - get_next_inputs (); - - // use the trellis to do the encoding; - // updates the input memory to the new memory state for the given input - // and writes the output bits to the current_outputs - - d_trellis->encode_lookup (d_memory, d_current_inputs, d_current_outputs); - - // write the bits in d_current_outputs into the output buffer - - write_output_bits (); - - // increment the number of encoded bits for the current block, and - // the total number of bits for this running of "encode()" - - d_n_enc_bits++; - d_total_n_enc_bits++; - } -} - -size_t -encoder_convolutional::compute_n_output_bits -(size_t n_input_bits) -{ - size_t t_n_output_bits, t_n_input_bits; - t_n_output_bits = t_n_input_bits = n_input_bits; - - if (d_do_termination == true) { - // not streaming, doing termination; find the number of bits - // currently available with no required inputs, if any - - size_t t_n_blocks, t_n_extra; - t_n_blocks = t_n_extra = 0; - - if (d_fsm_state == fsm_enc_conv_doing_term) { - - t_n_extra = d_n_bits_to_term - d_n_enc_bits; - t_n_blocks = t_n_input_bits / d_block_size_bits; - - } else { - // find the number of blocks which will be completed by the - // additional inputs - - t_n_blocks = (d_n_enc_bits + t_n_input_bits) / d_block_size_bits; - } - - // add the number of term_bits*blocks to the number of output bits - - t_n_output_bits += (t_n_blocks * d_n_bits_to_term); - t_n_output_bits += t_n_extra; - } - - return (t_n_output_bits); -} - -size_t -encoder_convolutional::compute_n_input_bits -(size_t n_output_bits) -{ - size_t t_n_output_bits, t_n_input_bits; - t_n_output_bits = t_n_input_bits = n_output_bits; - - if (d_do_termination == true) { - - // not streaming, doing termination; find the number of bits - // currently available with no required inputs, if any - - size_t n_extra = 0; - if (d_fsm_state == fsm_enc_conv_doing_term) { - n_extra = d_n_bits_to_term - d_n_enc_bits; - } - - // check to see if this is enough; return 0 if it is. - - if (n_extra >= t_n_output_bits) - return (0); - - // remove those which require no input - - t_n_output_bits -= n_extra; - t_n_input_bits -= n_extra; - - // add into the output bits the number of currently encoded input bits - - if (d_fsm_state == fsm_enc_conv_doing_input) - t_n_output_bits += d_n_enc_bits; - - // find the number of blocks of data which will create the - // remaining number of output bits, though possibly not the - // termination bits of a final block (done later) - - size_t t_n_output_bits_per_block = d_block_size_bits + d_n_bits_to_term; - size_t t_n_blocks = t_n_output_bits / t_n_output_bits_per_block; - - // remove the termination bits from the remaining # of input bits - - t_n_input_bits -= (t_n_blocks * d_n_bits_to_term); - - // do the remaining inputs / outputs create at least 1 - // block_size_bits (but less than a full block + termination bits) - - t_n_output_bits -= (t_n_blocks * t_n_output_bits_per_block); - - if (t_n_output_bits >= d_block_size_bits) { - n_extra = t_n_output_bits - d_block_size_bits; - t_n_input_bits -= n_extra; - } - } - - return (t_n_input_bits); -} diff --git a/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.h b/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.h deleted file mode 100644 index 76312251b..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.h +++ /dev/null @@ -1,278 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_ENCODER_CONVOLUTIONAL_H -#define INCLUDED_ENCODER_CONVOLUTIONAL_H - -#include "encoder.h" -#include "code_convolutional_trellis.h" - -class encoder_convolutional : public encoder -{ -/*! - * class encoder_convolutional : public encoder - * - * Encode the incoming streams using a convolutional encoder; This is - * a virtual class which defines the basics of a convolutional - * encoder, but not how input and output bits are handled, nor - * feedback in the encoder. These features are all defined by - * overriding methods appropriately. - * - * block_size_bits: if == 0, then do streaming encoding ("infinite" - * trellis); otherwise this is the block size in bits to encode - * before terminating the trellis. This value -does not- include - * any termination bits. - * - * n_code_inputs: - * n_code_outputs: - * code_generator: vector of integers (32 bit) representing the code - * to be implemented. E.g. "4" in binary is "100", which would be - * "D^2" for code generation. "6" == 110b == "D^2 + D" - * ==> The vector is listed in order for each output stream, so if there - * are 2 input streams (I1, I2) [specified in "n_code_inputs"] - * and 2 output streams (O1, O2) [specified in "n_code_outputs"], - * then the vector would be the code generator for: - * [I1->O1, I2->O1, I1->O2, I2->O2] - * with each element being an integer representation of the code. - * The "octal" representation is used frequently in the literature - * (e.g. [015, 06] == [1101, 0110] in binary) due to its close - * relationship with binary (each number is 3 binary digits) - * ... but any integer representation will suffice. - * - * do_termination: valid only if block_size_bits != 0, and defines - * whether or not to use trellis termination. Default is to use - * termination when doing block coding. - * - * start_memory_state: when starting a new block, the starting memory - * state to begin encoding; there will be a helper function to - * assist in creating this value for a given set of inputs; - * default is the "all zero" state. - * - * end_memory_state: when terminating a block, the ending memory - * state to stop encoding; there will be a helper function to - * assist in creating this value for a given set of inputs; - * default is the "all zero" state. - */ - -public: - inline encoder_convolutional - (int block_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int> &code_generators, - bool do_termination = true, - int start_memory_state = 0, - int end_memory_state = 0) - {encoder_convolutional_init (block_size_bits, - n_code_inputs, - n_code_outputs, - code_generators, - 0, - do_termination, - start_memory_state, - end_memory_state);}; - -/*! - * Encoder with feedback. - * - * code_feedback: vector of integers (32 bit) representing the code - * feedback to be implemented (same as for the code_generator). - * For this feedback type, the LSB ("& 1") is ignored (set to "1" - * internally, since it's always 1) ... this (effectively) - * represents the input bit for the given encoder, without which - * there would be no encoding! Each successive higher-order bit - * represents the output of that delay block; for example "6" == - * 110b == "D^2 + D" means use the current input bit + the output - * of the second delay block. Listing order is the same as for - * the code_generator. - */ - - inline encoder_convolutional - (int block_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generators, - const std::vector<int>& code_feedback, - bool do_termination = true, - int start_memory_state = 0, - int end_memory_state = 0) - {encoder_convolutional_init (block_size_bits, - n_code_inputs, - n_code_outputs, - code_generators, - &code_feedback, - do_termination, - start_memory_state, - end_memory_state);}; - - virtual ~encoder_convolutional () {delete d_trellis;}; - -/* - * Compute the number of input bits needed to produce 'n_output' bits, - * and the number of output bits which will be produced by 'n_input' - * bits ... for a single stream only. - * - * For convolutional encoders, there is 1 bit output per bit input per - * stream, with the addition of a some bits for trellis termination if - * selected. Thus the input:output bit ratio will be: - * - * if (streaming | no termination), 1:1 exactly; - * - * if (not streaming & termination), depends on the state of the FSM, - * and needs to include the number of termination bits (the total # of - * delays); ratio is roughly (1:(1+X)), where "X" is the number of - * termination bits divided by the (unterminated) block length in bits. - * - * It's up to the caller to change 'bits' to 'items' ... to know if - * bits are packed (see e.g. code_io "ic8l") or not ("ic1l"), or all - * streams are mux'ed together into one stream. -*/ - - virtual size_t compute_n_input_bits (size_t n_output_bits); - virtual size_t compute_n_output_bits (size_t n_input_bits); - -/* for remote access to internal info */ - - inline const bool do_termination () {return (d_do_termination);}; - inline const bool do_feedback () {return (d_trellis->do_feedback());}; - inline const bool do_encode_soai () {return (d_trellis->do_encode_soai());}; - inline const bool do_streaming () {return (d_do_streaming);}; - inline const size_t total_n_delays () {return (d_total_n_delays);}; - inline const size_t n_bits_to_term () {return (d_n_bits_to_term);}; - inline const code_convolutional_trellis* trellis() {return (d_trellis);}; - -protected: -/* - * fsm_enc_conv_t: finite state machine for the convolutional encoder; - * output happens all the time, so that's built-in to each state. - * - * fsm_enc_conv_init: initialize for a new block / block; this is already - * done at instantiation, so do it only at the end of a block. - * - * fsm_enc_conv_doing_input: doing encoding inside the trellis - * - * fsm_enc_conv_doing_term: termination trellis, if requested - */ - - enum fsm_enc_conv_t { - fsm_enc_conv_init, fsm_enc_conv_doing_input, fsm_enc_conv_doing_term - }; - - // methods defined in this class - - void encoder_convolutional_init (int block_size_bits, - int n_code_inputs, - int n_code_outputs, - const std::vector<int>& code_generators, - const std::vector<int>* code_generators, - bool do_termination, - int start_memory_state, - int end_memory_state); - - virtual void encode_private (); - virtual void encode_loop (size_t& which_counter, size_t how_many); - - inline void get_next_inputs () { - switch (d_fsm_state) { - case fsm_enc_conv_doing_input: - get_next_inputs__input (); - break; - case fsm_enc_conv_doing_term: - get_next_inputs__term (); - break; - default: - assert (0); - break; - } - }; - - inline virtual void get_next_inputs__input () { - d_in_buf->read_items ((void*)(&(d_current_inputs[0]))); - d_in_buf->increment_indices (); - d_n_bits_to_input--; - }; - - inline virtual void get_next_inputs__term () { - d_trellis->get_termination_inputs (d_term_state, - d_n_enc_bits, - d_current_inputs); - }; - - inline virtual void write_output_bits () { - d_out_buf->write_items ((const void*)(&(d_current_outputs[0]))); - d_out_buf->increment_indices (); - d_n_bits_to_output--; - }; - - void get_memory_requirements (size_t m, - size_t n, - size_t& t_max_mem, - size_t& t_n_unique_fb_prev_start, - const std::vector<int>* code_feedback); - - // variables - - fsm_enc_conv_t d_fsm_state; - bool d_do_streaming, d_do_termination; - - // "total_n_delays" is the total # of delays, needed to determine the - // # of states in the decoder - - size_t d_total_n_delays, d_n_enc_bits; - - // the current state of the encoder (all delays / memories) - - memory_t d_memory; - - // "inputs" are the current input bits, in the LSB (&1) of each "char" - - std::vector<char> d_current_inputs; - - // "outputs" are the current output bits, in the LSB (&1) of each "char" - - std::vector<char> d_current_outputs; - - // "n_bits_to_term" is the number of bits to terminate the trellis - // to the desired state, as determined by the termination table. - // d_max_delay <= d_n_bits_to_term <= d_total_n_delays - // These numbers will vary depending on the realization. - - size_t d_n_bits_to_term; - - // "trellis" is the code trellis for the given input parameters - - code_convolutional_trellis* d_trellis; - - // "init_states" are the user-provided init states, - // interpreted w/r.t. the actual trellis; - - memory_t d_init_state; - - // "term_state" is the ending state before termination, used by the - // trellis to determine the correct input-bit sequences needed to - // properly terminate the trellis to the desired end-state; - // used only if doing termination. - - memory_t d_term_state; -}; - -#endif /* INCLUDED_ENCODER_CONVOLUTIONAL_H */ diff --git a/gr-error-correcting-codes/src/lib/libecc/encoder_turbo.cc b/gr-error-correcting-codes/src/lib/libecc/encoder_turbo.cc deleted file mode 100644 index 111424a70..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/encoder_turbo.cc +++ /dev/null @@ -1,41 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "encoder_turbo.h" - -encoder_turbo::encoder_turbo -(int n_code_inputs, - int n_code_outputs, - const std::vector<encoder_convolutional*>& encoders, - const std::vector<interleaver_t>& interleavers) -{ - // need error checking on inputs, not yet. - -#if 0 - d_encoders = encoders; - d_interleavers = interleavers; -#endif -} diff --git a/gr-error-correcting-codes/src/lib/libecc/encoder_turbo.h b/gr-error-correcting-codes/src/lib/libecc/encoder_turbo.h deleted file mode 100644 index d780faccb..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/encoder_turbo.h +++ /dev/null @@ -1,119 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_ENCODER_TURBO_H -#define INCLUDED_ENCODER_TURBO_H - -#include "encoder_convolutional.h" - -typedef std::vector<size_t> interleaver_t; - -class encoder_turbo : public encoder -{ -public: -/*! - * class encoder_turbo : public encoder - * - * Encode the incoming streams using a turbo encoder; This is a - * virtual class which defines the basics of a turbo encoder, but - * not how input and output bits are handled. These features are - * all defined by overriding methods appropriately. - * - * n_code_inputs: - * n_code_outputs: the total number of code inputs and outputs for the - * overall turbo encoder (not just the constituent codes). - * - * encoders: the constituent encoders to be used; all -should- be - * configured with the same "block_size" and "termination", though - * from this encoder's perspective it doesn't really matter. - * - * interleavers: the interleavers to use before each encoder, - * respectively, except the first encoder which will not use an - * interleaver. - */ - - encoder_turbo - (int n_code_inputs, - int n_code_outputs, - const std::vector<encoder_convolutional*>& encoders, - const std::vector<interleaver_t>& interleavers); - - virtual ~encoder_turbo () {}; - -/* for remote access to internal info */ - - inline const bool do_termination () {return (d_do_termination);}; - -#if 1 - // dummy functions for now - virtual size_t compute_n_input_bits (size_t n_output_bits){return(0);}; - virtual size_t compute_n_output_bits (size_t n_input_bits){return(0);}; -#endif - -protected: -/* - * fsm_enc_turbo_t: finite state machine for the turbo encoder; - * output happens all the time, so that's built-in to each state. - * - * fsm_enc_turbo_init: initialize for a new frame / block; this is already - * done at instantiation, so do it only at the end of a block. - * - * fsm_enc_turbo_doing_input: doing encoding inside the trellis - * - * fsm_enc_turbo_doing_term: termination trellis, if requested - */ - - enum fsm_enc_turbo_t { - fsm_enc_turbo_init, fsm_enc_turbo_doing_input, fsm_enc_turbo_doing_term - }; - - // methods defined in this class -#if 1 - // temporary just to get full compilation - - virtual void encode_private () {}; - -#else - virtual void encode_private () = 0; - virtual void encode_loop (size_t* which_counter, size_t how_many) = 0; - virtual char get_next_bit (const char** in_buf, size_t code_input_n) = 0; - virtual char get_next_bit__term (size_t code_input_n) = 0; - - // methods which are required by classes which inherit from this - // one; primarily just the parts which deal with getting input bits - // and writing output bits, changing the indices for those buffers. - - virtual char get_next_bit__input (const char** in_buf, - size_t code_input_n) = 0; -#endif - - // variables - - fsm_enc_turbo_t d_fsm_state; - bool d_do_termination; - size_t d_max_memory, d_n_memories; - - std::vector<encoder_convolutional*> d_encoders; - std::vector<size_t> d_interleavers; -}; - -#endif /* INCLUDED_ENCODER_TURBO_H */ diff --git a/gr-error-correcting-codes/src/lib/libecc/mld/Makefile.am b/gr-error-correcting-codes/src/lib/libecc/mld/Makefile.am deleted file mode 100644 index 3420d5581..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/mld/Makefile.am +++ /dev/null @@ -1,35 +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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -INCLUDES = $(STD_DEFINES_AND_INCLUDES) - -noinst_LTLIBRARIES = libmld.la - -libmld_la_SOURCES = \ - mld_timer.cc n2bs.cc - -noinst_HEADERS = \ - mld_timer.h n2bs.h - -MOSTLYCLEANFILES = *.loT *~ - diff --git a/gr-error-correcting-codes/src/lib/libecc/mld/mld_timer.cc b/gr-error-correcting-codes/src/lib/libecc/mld/mld_timer.cc deleted file mode 100644 index cb736a98c..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/mld/mld_timer.cc +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio. - * - * Primary Author: Michael Dickens, NCIP Lab, University of Notre Dame - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <sys/types.h> -#include <mld_timer.h> - -void start_timer (struct timeval *t_tp) -{ - gettimeofday (t_tp, 0); -} - -u_long end_timer (struct timeval *g_tp) -{ - struct timeval t_tp; - gettimeofday (&t_tp, 0); - - u_long retVal = (t_tp.tv_sec - g_tp->tv_sec); - u_long df_usec; - - if (t_tp.tv_usec < g_tp->tv_usec) { - retVal -= 1; - df_usec = 1000000 - (g_tp->tv_usec - t_tp.tv_usec); - } else - df_usec = t_tp.tv_usec - g_tp->tv_usec; - - retVal *= 1000000; - retVal += df_usec; - return (retVal); -} diff --git a/gr-error-correcting-codes/src/lib/libecc/mld/mld_timer.h b/gr-error-correcting-codes/src/lib/libecc/mld/mld_timer.h deleted file mode 100644 index b24a8c33b..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/mld/mld_timer.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio. - * - * Primary Author: Michael Dickens, NCIP Lab, University of Notre Dame - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <sys/time.h> - -extern void start_timer (struct timeval *t_tp); -extern u_long end_timer (struct timeval *g_tp); diff --git a/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.cc b/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.cc deleted file mode 100644 index cbe45af99..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.cc +++ /dev/null @@ -1,37 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <n2bs.h> -#include <iostream> - -std::string _n2bs_helper(unsigned long long v, size_t nbinary_digits) -{ - std::string retVal (nbinary_digits, '0'); - if (v != 0) - for (int n = int(nbinary_digits) - 1; n >= 0; n--) { - if (v & 1) { - retVal[n] = '1'; - } - v >>= 1; - } - return (retVal); -} diff --git a/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.h b/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.h deleted file mode 100644 index 8b6e712a6..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.h +++ /dev/null @@ -1,37 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_N2BS_H -#define INCLUDED_N2BS_H - -#include <string> -#include <algorithm> - -std::string _n2bs_helper(unsigned long long v, size_t nbinary_digits); - -template<class T> -std::string n2bs(T v, size_t nbinary_digits) -{ - return _n2bs_helper((unsigned long long)v, std::min(nbinary_digits, 8 * sizeof(T))); -} - -#endif /* INCLUDED_N2BS_H */ diff --git a/gr-error-correcting-codes/src/lib/libecc/tests/Makefile.am b/gr-error-correcting-codes/src/lib/libecc/tests/Makefile.am deleted file mode 100644 index 78503d2ac..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/tests/Makefile.am +++ /dev/null @@ -1,48 +0,0 @@ -# -# Copyright 2001 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) \ - -I$(top_srcdir)/gr-error-correcting-codes/src/lib/libecc - -noinst_LTLIBRARIES = libecc-qa.la - -noinst_HEADERS = \ - qa_encoder_convolutional_ic1_ic1.h \ - qa_ecc.h - -libecc_qa_la_SOURCES = \ - qa_encoder_convolutional_ic1_ic1.cc \ - qa_ecc.cc - -# list of programs run by "make check" and "make distcheck" - -TESTS = test_all - -noinst_PROGRAMS = test_all - -LIBECC = ../libecc.la -LIBECCQA = libecc-qa.la $(LIBECC) - -test_all_SOURCES = test_all.cc -test_all_LDADD = $(LIBECCQA) \ - $(CPPUNIT_LIBS) diff --git a/gr-error-correcting-codes/src/lib/libecc/tests/qa_ecc.cc b/gr-error-correcting-codes/src/lib/libecc/tests/qa_ecc.cc deleted file mode 100644 index bb955c845..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/tests/qa_ecc.cc +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * This class gathers together all the test cases for the gr - * directory into a single test suite. As you create new test cases, - * add them here. - */ - -#include <qa_ecc.h> -#include <qa_encoder_convolutional_ic1_ic1.h> - -CppUnit::TestSuite* -qa_ecc::suite -() -{ - CppUnit::TestSuite* s = new CppUnit::TestSuite ("ecc"); - - s->addTest (qa_encoder_convolutional_ic1_ic1::suite ()); - - return (s); -} diff --git a/gr-error-correcting-codes/src/lib/libecc/tests/qa_ecc.h b/gr-error-correcting-codes/src/lib/libecc/tests/qa_ecc.h deleted file mode 100644 index 273425433..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/tests/qa_ecc.h +++ /dev/null @@ -1,36 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _QA_ECC_H_ -#define _QA_ECC_H_ - -#include <cppunit/TestSuite.h> - -//! collect all the tests for the gr directory - -class qa_ecc { -public: - //! return suite of tests for all of gr directory - static CppUnit::TestSuite *suite (); -}; - -#endif /* _QA_ECC_H_ */ diff --git a/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.cc b/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.cc deleted file mode 100644 index d7258de70..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.cc +++ /dev/null @@ -1,2298 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "encoder_convolutional.h" -#include <qa_encoder_convolutional_ic1_ic1.h> -#include <cppunit/TestAssert.h> -#include <string.h> -#include <iostream> -#include <iomanip> -#include <stdio.h> - -#define DO_PRINT_DEBUG 0 - -// test number counter - -static size_t g_t_num = 0; - -void -qa_encoder_convolutional_ic1_ic1::do_encoder_check -(bool use_encode_in_or_out, - const char** c_in, - const char** c_res, - const size_t n_io_items, - const size_t* n_input_items, - const size_t* n_output_items, - const size_t block_size_bits, - const size_t n_code_inputs, - const size_t n_code_outputs, - const int* code_generators, - const int* code_feedback, - const bool do_termination, - const size_t start_state, - const size_t term_state, - const int encode_soai) -{ - if (DO_PRINT_DEBUG) - std::cout << "Starting Test " << g_t_num << "\n"; - - std::vector<int> t_code_generators; - t_code_generators.assign (n_code_inputs * n_code_outputs, 0); - for (size_t m = 0; m < (n_code_inputs * n_code_outputs); m++) - t_code_generators[m] = code_generators[m]; - - encoder_convolutional* t_encoder; - - if (code_feedback) { - std::vector<int> t_code_feedback; - t_code_feedback.assign (n_code_inputs * n_code_outputs, 0); - for (size_t m = 0; m < (n_code_inputs * n_code_outputs); m++) - t_code_feedback[m] = code_feedback[m]; - - t_encoder = new encoder_convolutional - (block_size_bits, - n_code_inputs, - n_code_outputs, - t_code_generators, - t_code_feedback, - do_termination, - start_state, - term_state); - } else { - t_encoder = new encoder_convolutional - (block_size_bits, - n_code_inputs, - n_code_outputs, - t_code_generators, - do_termination, - start_state, - term_state); - } - - size_t t_total_n_input_items = 0; - size_t t_total_n_output_items = 0; - for (size_t m = 0; m < n_io_items; m++) { - t_total_n_input_items += n_input_items[m]; - t_total_n_output_items += n_output_items[m]; - } - - code_input_ic1l* t_c_in = new code_input_ic1l (n_code_inputs); - t_c_in->set_buffer ((void**) c_in, t_total_n_input_items); - - char** t_out = new char*[n_code_outputs]; - for (size_t m = 0; m < n_code_outputs; m++) { - t_out[m] = new char[t_total_n_output_items]; - } - - code_output_ic1l* t_c_out = new code_output_ic1l (n_code_outputs); - t_c_out->set_buffer ((void**) t_out, t_total_n_output_items); - - bool t_errors = false; - - for (size_t m = 0; m < n_io_items; m++) { - if (use_encode_in_or_out == true) { - size_t t_n_output_items_used = t_encoder->encode (t_c_in, - n_input_items[m], - t_c_out); - if (t_n_output_items_used != n_output_items[m]) { - std::cout << "Test " << g_t_num << ": Encode[" << m << - "]{input}: Warning: Number of returned output items (" << - t_n_output_items_used << ") is not as expected (" << - n_output_items[m] << ").\n"; - t_errors = true; - } - } else { - size_t t_n_input_items_used = t_encoder->encode (t_c_in, - t_c_out, - n_output_items[m]); - if (t_n_input_items_used != n_input_items[m]) { - std::cout << "Test " << g_t_num << ": Encode[" << m << - "]{output}: Warning: Number of returned output items (" << - t_n_input_items_used << ") is not as expected (" << - n_input_items[m] << ").\n"; - t_errors = true; - } - } - } - - for (size_t m = 0; m < n_code_outputs; m++) { - for (size_t n = 0; n < t_total_n_output_items; n++) { - if (c_res[m][n] != t_out[m][n]) { - std::cout << "Test " << g_t_num << ": Item [" << m << - "][" << n << "] not equal: des = " << (int)(c_res[m][n]) << - ", act = " << (int)(t_out[m][n]) << "\n"; - t_errors = true; - } - } - } - - if (encode_soai != -1) { - // verify that the internal realization is correct - if (encode_soai != t_encoder->do_encode_soai ()) { - t_errors = true; - } - } - - CPPUNIT_ASSERT_EQUAL (t_errors, false); - - delete t_c_out; - t_c_out = 0; - delete t_c_in; - t_c_in = 0; - delete t_encoder; - t_encoder = 0; - - for (size_t m = 0; m < n_code_outputs; m++) { - delete [] t_out[m]; - t_out[m] = 0; - } - delete [] t_out; - t_out = 0; - - // increment the test number - - g_t_num++; -} - -// TESTS 0 through 22 use do_encode_in_or_out as false - -static const bool g_do_encode_in_or_out_0_22 = false; - -// TEST 0 -// -// checking for: -// SIAO realization (implicitely) -// start state is 0, no feedback, no termination - -const static int t0_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static size_t t0_encode_soai = 0; - -const static char t0_in_0[] = - {0, 1, 0, 0, 1, 0, 1, 0, 0, 0}; -const static char t0_in_1[] = - {0, 1, 0, 0, 0, 1, 1, 0, 0, 0}; -const static char t0_in_2[] = - {0, 0, 1, 1, 1, 1, 1, 0, 0, 0}; -const static char* t0_in[] = - {t0_in_0, t0_in_1, t0_in_2}; - -const static size_t t0_n_input_items = sizeof (t0_in_0); -const static size_t t0_n_code_inputs = sizeof (t0_in) / sizeof (char*); - -const static char t0_res_0[] = - {0, 1, 1, 1, 1, 0, 1, 1, 1, 0}; -const static char t0_res_1[] = - {0, 1, 0, 1, 0, 1, 1, 0, 1, 0}; -const static char* t0_res[] = - {t0_res_0, t0_res_1}; - -const static size_t t0_n_output_items = sizeof (t0_res_0); -const static size_t t0_n_code_outputs = sizeof (t0_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t0 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t0_in, (const char**) t0_res, - 1, (const size_t*) &t0_n_input_items, - (const size_t*) &t0_n_output_items, 100, - t0_n_code_inputs, t0_n_code_outputs, - (const int*) t0_code_generator, - 0, true, 0, 0, t0_encode_soai); -} - -// TEST 1 -// -// checking for SIAO realization (implicitely) -// start state is 0, no feedback, no termination - -const static int t1_code_generator[] = {1, 0, 0, 1, 5, 6}; -const static size_t t1_encode_soai = 1; - -const static char t1_in_0[] = - {0, 1, 1, 1, 0, 0, 0, 1, 0}; -const static char t1_in_1[] = - {0, 0, 0, 0, 0, 1, 1, 1, 0}; -const static char* t1_in[] = - {t1_in_0, t1_in_1}; - -const static size_t t1_n_input_items = sizeof (t1_in_0); -const static size_t t1_n_code_inputs = sizeof (t1_in) / sizeof (char*); - -const static char t1_res_0[] = - {0, 1, 1, 1, 0, 0, 0, 1, 0}; -const static char t1_res_1[] = - {0, 0, 0, 0, 0, 1, 1, 1, 0}; -const static char t1_res_2[] = - {0, 1, 1, 0, 1, 1, 1, 1, 0}; -const static char* t1_res[] = - {t1_res_0, t1_res_1, t1_res_2}; - -const static size_t t1_n_output_items = sizeof (t1_res_0); -const static size_t t1_n_code_outputs = sizeof (t1_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t1 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t1_in, (const char**) t1_res, - 1, (const size_t*) &t1_n_input_items, - (const size_t*) &t1_n_output_items, 100, - t1_n_code_inputs, t1_n_code_outputs, - (const int*) t1_code_generator, - 0, true, 0, 0, t1_encode_soai); -} - -// TEST 2 -// -// checking for SOAI realization (implicitely) -// start state is 0, same feedback, no termination - -const static int t2_code_generator[] = {1, 0, 0, 1, 5, 6}; -const static int t2_code_feedback[] = {0, 0, 0, 0, 7, 7}; -const static int t2_encode_soai = 1; - -const static char t2_in_0[] = - {0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0}; -const static char t2_in_1[] = - {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0}; -const static char* t2_in[] = - {t2_in_0, t2_in_1}; - -const static size_t t2_n_input_items = sizeof (t2_in_0); -const static size_t t2_n_code_inputs = sizeof (t2_in) / sizeof (char*); - -const static char t2_res_0[] = - {0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0}; -const static char t2_res_1[] = - {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0}; -const static char t2_res_2[] = - {0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0}; -const static char* t2_res[] = - {t2_res_0, t2_res_1, t2_res_2}; - -const static size_t t2_n_output_items = sizeof (t2_res_0); -const static size_t t2_n_code_outputs = sizeof (t2_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t2 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t2_in, (const char**) t2_res, - 1, (const size_t*) &t2_n_input_items, - (const size_t*) &t2_n_output_items, 100, - t2_n_code_inputs, t2_n_code_outputs, - (const int*) t2_code_generator, - (const int*) t2_code_feedback, - true, 0, 0, t2_encode_soai); -} - -// TEST 3 -// -// checking for SIAO realization (implicitely) -// start state is 0, same feedback, no termination - -const static int t3_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t3_code_feedback[] = {0, 0, 7, 0, 0, 7}; -const static int t3_encode_soai = 0; - -const static char t3_in_0[] = - {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0}; -const static char t3_in_1[] = - {0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const static char t3_in_2[] = - {0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0}; -const static char* t3_in[] = - {t3_in_0, t3_in_1, t3_in_2}; - -const static size_t t3_n_input_items = sizeof (t3_in_0); -const static size_t t3_n_code_inputs = sizeof (t3_in) / sizeof (char*); - -const static char t3_res_0[] = - {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0}; -const static char t3_res_1[] = - {0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0}; -const static char* t3_res[] = - {t3_res_0, t3_res_1}; - -const static size_t t3_n_output_items = sizeof (t3_res_0); -const static size_t t3_n_code_outputs = sizeof (t3_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t3 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t3_in, (const char**) t3_res, - 1, (const size_t*) &t3_n_input_items, - (const size_t*) &t3_n_output_items, 100, - t3_n_code_inputs, t3_n_code_outputs, - (const int*) t3_code_generator, - (const int*) t3_code_feedback, - true, 0, 0, t3_encode_soai); -} - -// TEST 4 -// -// checking for SIAO realization (implicitely), -// start state is 0, different feedbacks, no termination - -const static int t4_code_generator[] = {1, 4, 0, 3, 1, 6}; -const static int t4_code_feedback[] = {0, 7, 0, 5, 0, 5}; -const static int t4_encode_soai = 0; - -const static char t4_in_0[] = - {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0}; -const static char t4_in_1[] = - {0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0}; -const static char* t4_in[] = - {t4_in_0, t4_in_1}; - -const static size_t t4_n_input_items = sizeof (t4_in_0); -const static size_t t4_n_code_inputs = sizeof (t4_in) / sizeof (char*); - -const static char t4_res_0[] = - {0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0}; -const static char t4_res_1[] = - {0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0}; -const static char t4_res_2[] = - {0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0}; -const static char* t4_res[] = - {t4_res_0, t4_res_1, t4_res_2}; - -const static size_t t4_n_output_items = sizeof (t4_res_0); -const static size_t t4_n_code_outputs = sizeof (t4_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t4 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t4_in, (const char**) t4_res, - 1, (const size_t*) &t4_n_input_items, - (const size_t*) &t4_n_output_items, 100, - t4_n_code_inputs, t4_n_code_outputs, - (const int*) t4_code_generator, - (const int*) t4_code_feedback, - true, 0, 0, t4_encode_soai); -} - -// TEST 5 -// -// checking for SOAI realization (implicitely), -// with different feedbacks, no termination - -const static int t5_code_generator[] = {1, 0, 1, 4, 3, 6}; -const static int t5_code_feedback[] = {0, 0, 0, 5, 7, 7}; -const static int t5_encode_soai = 1; - -const static char t5_in_0[] = - {0, 1, 0, 0, 0, 1, 0, 0, 1}; -const static char t5_in_1[] = - {0, 0, 1, 0, 1, 1, 0, 0, 1}; -const static char t5_in_2[] = - {0, 0, 0, 1, 0, 0, 0, 0, 1}; -const static char* t5_in[] = - {t5_in_0, t5_in_1, t5_in_2}; - -const static size_t t5_n_input_items = sizeof (t5_in_0); -const static size_t t5_n_code_inputs = sizeof (t5_in) / sizeof (char*); - -const static char t5_res_0[] = - {0, 1, 0, 1, 0, 1, 0, 0, 0}; -const static char t5_res_1[] = - {0, 0, 1, 1, 1, 1, 0, 0, 1}; -const static char* t5_res[] = - {t5_res_0, t5_res_1}; - -const static size_t t5_n_output_items = sizeof (t5_res_0); -const static size_t t5_n_code_outputs = sizeof (t5_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t5 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t5_in, (const char**) t5_res, - 1, (const size_t*) &t5_n_input_items, - (const size_t*) &t5_n_output_items, 100, - t5_n_code_inputs, t5_n_code_outputs, - (const int*) t5_code_generator, - (const int*) t5_code_feedback, true, - 0, 0, t5_encode_soai); -} - -// TEST 6 -// -// checking for: -// start state is 0, no feedback, termination to 0 state - -const static int t6_code_generator[] = {1, 0, 5, 0, 1, 6}; - -const static char t6_in_0[] = - {0, 1, 0, 0, 1, 0}; -const static char t6_in_1[] = - {0, 1, 0, 0, 0, 0}; -const static char t6_in_2[] = - {0, 0, 1, 1, 1, 0}; -const static char* t6_in[] = - {t6_in_0, t6_in_1, t6_in_2}; - -const static size_t t6_n_input_items = sizeof (t6_in_0); -const static size_t t6_n_code_inputs = sizeof (t6_in) / sizeof (char*); - -const static char t6_res_0[] = - {0, 1, 1, 1, 1, 1, 1, 0}; -const static char t6_res_1[] = - {0, 1, 0, 1, 0, 0, 1, 0}; -const static char* t6_res[] = - {t6_res_0, t6_res_1}; - -const static size_t t6_n_output_items = sizeof (t6_res_0); -const static size_t t6_n_code_outputs = sizeof (t6_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t6 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t6_in, (const char**) t6_res, - 1, (const size_t*) &t6_n_input_items, - (const size_t*) &t6_n_output_items, 5, t6_n_code_inputs, - t6_n_code_outputs, (const int*) t6_code_generator); -} - -// TEST 7 -// -// checking for: -// start state is 0, same feedback, termination to 0 state -// # of termination bits = 2 - -const static int t7_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t7_code_feedback[] = {0, 0, 7, 0, 0, 7}; - -const static char t7_in_0[] = - {0, 1, 1, 0, 0, 0, 0}; -const static char t7_in_1[] = - {0, 1, 0, 1, 0, 0, 0}; -const static char t7_in_2[] = - {0, 0, 0, 0, 1, 0, 1}; -const static char* t7_in[] = - {t7_in_0, t7_in_1, t7_in_2}; - -const static size_t t7_n_input_items = sizeof (t7_in_0); -const static size_t t7_n_code_inputs = sizeof (t7_in) / sizeof (char*); - -const static char t7_res_0[] = - {0, 1, 1, 0, 1, 0, 1, 0, 1}; -const static char t7_res_1[] = - {0, 1, 0, 1, 0, 1, 1, 0, 0}; -const static char* t7_res[] = - {t7_res_0, t7_res_1}; - -const static size_t t7_n_output_items = sizeof (t7_res_0); -const static size_t t7_n_code_outputs = sizeof (t7_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t7 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t7_in, (const char**) t7_res, - 1, (const size_t*) &t7_n_input_items, - (const size_t*) &t7_n_output_items, 5, t7_n_code_inputs, - t7_n_code_outputs, (const int*) t7_code_generator, - (const int*) t7_code_feedback); -} - -// TEST 8 -// -// checking for: -// state state is 0, different feedbacks, termination to 0 state -// # of term bits will be 4 - -const static int t8_code_generator[] = {1, 4, 0, 3, 1, 6}; -const static int t8_code_feedback[] = {0, 5, 0, 7, 0, 7}; - -const static char t8_in_0[] = - {0, 1, 0, 0, 0, 1, 0, 1, 1}; -const static char t8_in_1[] = - {0, 0, 0, 1, 1, 1, 0, 1, 0}; -const static char* t8_in[] = - {t8_in_0, t8_in_1}; - -const static size_t t8_n_input_items = sizeof (t8_in_0); -const static size_t t8_n_code_inputs = sizeof (t8_in) / sizeof (char*); - -const static char t8_res_0[] = - {0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1}; -const static char t8_res_1[] = - {0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0}; -const static char t8_res_2[] = - {0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; -const static char* t8_res[] = - {t8_res_0, t8_res_1, t8_res_2}; - -const static size_t t8_n_output_items = sizeof (t8_res_0); -const static size_t t8_n_code_outputs = sizeof (t8_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t8 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t8_in, (const char**) t8_res, - 1, (const size_t*) &t8_n_input_items, - (const size_t*) &t8_n_output_items, 6, t8_n_code_inputs, - t8_n_code_outputs, (const int*) t8_code_generator, - (const int*) t8_code_feedback); -} - -// TEST 9 -// -// checking for: -// start state is 0, different feedbacks, termination to non-0 state -// # of term bits will be 2 - -const static int t9_code_generator[] = {1, 0, 1, 4, 3, 6}; -const static int t9_code_feedback[] = {0, 0, 0, 5, 7, 7}; -const static size_t t9_term_state = 4; - -const static char t9_in_0[] = - {0, 1, 0, 0, 0, 0, 1}; -const static char t9_in_1[] = - {0, 0, 1, 0, 1, 0, 1}; -const static char t9_in_2[] = - {0, 0, 0, 1, 0, 0, 1}; -const static char* t9_in[] = - {t9_in_0, t9_in_1, t9_in_2}; - -const static size_t t9_n_input_items = sizeof (t9_in_0); -const static size_t t9_n_code_inputs = sizeof (t9_in) / sizeof (char*); - -const static char t9_res_0[] = - {0, 1, 0, 1, 0, 1, 1, 0, 0}; -const static char t9_res_1[] = - {0, 0, 1, 1, 1, 1, 1, 0, 1}; -const static char* t9_res[] = - {t9_res_0, t9_res_1}; - -const static size_t t9_n_output_items = sizeof (t9_res_0); -const static size_t t9_n_code_outputs = sizeof (t9_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t9 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t9_in, (const char**) t9_res, - 1, (const size_t*) &t9_n_input_items, - (const size_t*) &t9_n_output_items, 5, t9_n_code_inputs, - t9_n_code_outputs, (const int*) t9_code_generator, - (const int*) t9_code_feedback, true, 0, t9_term_state); -} - -// TEST 10 -// -// checking for termination to non-0 state, no feedback - -const static int t10_code_generator[] = {1, 0, 3, 0, 1, 6}; -const static size_t t10_term_state = 2; - -const static char t10_in_0[] = - {0, 1, 0, 1, 0, 0, 1, 1}; -const static char t10_in_1[] = - {0, 1, 0, 0, 1, 0, 1, 1}; -const static char t10_in_2[] = - {0, 1, 0, 1, 1, 0, 0, 1}; -const static char* t10_in[] = - {t10_in_0, t10_in_1, t10_in_2}; - -const static size_t t10_n_input_items = sizeof (t10_in_0); -const static size_t t10_n_code_inputs = sizeof (t10_in) / sizeof (char*); - -const static char t10_res_0[] = - {0, 0, 1, 0, 0, 0, 1, 0, 1, 0}; -const static char t10_res_1[] = - {0, 1, 1, 1, 0, 0, 0, 0, 1, 1}; -const static char* t10_res[] = - {t10_res_0, t10_res_1}; - -const static size_t t10_n_output_items = sizeof (t10_res_0); -const static size_t t10_n_code_outputs = sizeof (t10_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t10 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t10_in, (const char**) t10_res, - 1, (const size_t*) &t10_n_input_items, - (const size_t*) &t10_n_output_items, 5, - t10_n_code_inputs, t10_n_code_outputs, - (const int*) t10_code_generator, - 0, true, 0, t10_term_state); -} - -// TEST 11 -// -// checking for: -// start state is not 0, no feedback, terminating to 0 state - -const static int t11_code_generator[] = {1, 0, 3, 0, 1, 6}; -const static size_t t11_start_state = 1; - -const static char t11_in_0[] = - {0, 1, 0, 0, 0, 1, 0}; -const static char t11_in_1[] = - {0, 0, 1, 0, 0, 1, 0}; -const static char t11_in_2[] = - {0, 1, 1, 1, 0, 1, 1}; -const static char* t11_in[] = - {t11_in_0, t11_in_1, t11_in_2}; - -const static size_t t11_n_input_items = sizeof (t11_in_0); -const static size_t t11_n_code_inputs = sizeof (t11_in) / sizeof (char*); - -const static char t11_res_0[] = - {1, 0, 0, 0, 1, 0, 0, 1, 0}; -const static char t11_res_1[] = - {1, 1, 0, 0, 0, 1, 0, 0, 0}; -const static char* t11_res[] = - {t11_res_0, t11_res_1}; - -const static size_t t11_n_output_items = sizeof (t11_res_0); -const static size_t t11_n_code_outputs = sizeof (t11_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t11 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t11_in, (const char**) t11_res, - 1, (const size_t*) &t11_n_input_items, - (const size_t*) &t11_n_output_items, 5, - t11_n_code_inputs, t11_n_code_outputs, - (const int*) t11_code_generator, - 0, true, t11_start_state); -} - -// TEST 12 -// -// checking for: -// start state is not 0, no feedback, terminating to non-0 state - -const static int t12_code_generator[] = {1, 0, 3, 0, 1, 6}; -const static size_t t12_start_state = 2; -const static size_t t12_term_state = 2; - -const static char t12_in_0[] = - {0, 1, 1, 1, 0, 1, 0}; -const static char t12_in_1[] = - {0, 1, 0, 0, 0, 0, 1}; -const static char t12_in_2[] = - {0, 1, 1, 0, 1, 0, 1}; -const static char* t12_in[] = - {t12_in_0, t12_in_1, t12_in_2}; - -const static size_t t12_n_input_items = sizeof (t12_in_0); -const static size_t t12_n_code_inputs = sizeof (t12_in) / sizeof (char*); - -const static char t12_res_0[] = - {0, 0, 1, 0, 1, 0, 1, 1, 1}; -const static char t12_res_1[] = - {1, 1, 1, 0, 1, 1, 0, 1, 1}; -const static char* t12_res[] = - {t12_res_0, t12_res_1}; - -const static size_t t12_n_output_items = sizeof (t12_res_0); -const static size_t t12_n_code_outputs = sizeof (t12_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t12 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t12_in, (const char**) t12_res, - 1, (const size_t*) &t12_n_input_items, - (const size_t*) &t12_n_output_items, 5, t12_n_code_inputs, - t12_n_code_outputs, (const int*) t12_code_generator, - 0, true, t12_start_state, t12_term_state); -} - -// TEST 13 -// -// checking for: -// start state is not 0, any feedback, termination to 0 state - -const static int t13_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t13_code_feedback[] = {0, 0, 7, 0, 0, 7}; -const static size_t t13_start_state = 2; -const static size_t t13_term_state = 0; - -const static char t13_in_0[] = - {0, 1, 0, 0, 0, 1, 0}; -const static char t13_in_1[] = - {0, 0, 1, 1, 0, 1, 0}; -const static char t13_in_2[] = - {0, 0, 0, 0, 1, 0, 0}; -const static char* t13_in[] = - {t13_in_0, t13_in_1, t13_in_2}; - -const static size_t t13_n_input_items = sizeof (t13_in_0); -const static size_t t13_n_code_inputs = sizeof (t13_in) / sizeof (char*); - -const static char t13_res_0[] = - {0, 0, 1, 0, 0, 1, 0, 1, 1}; -const static char t13_res_1[] = - {1, 1, 1, 0, 1, 1, 0, 0, 1}; -const static char* t13_res[] = - {t13_res_0, t13_res_1}; - -const static size_t t13_n_output_items = sizeof (t13_res_0); -const static size_t t13_n_code_outputs = sizeof (t13_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t13 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t13_in, (const char**) t13_res, - 1, (const size_t*) &t13_n_input_items, - (const size_t*) &t13_n_output_items, 5, - t13_n_code_inputs, t13_n_code_outputs, - (const int*) t13_code_generator, - (const int*) t13_code_feedback, - true, t13_start_state, t13_term_state); -} - -// TEST 14 -// -// checking for: -// start state is not 0, any feedback, termination to non-zero state - -const static int t14_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t14_code_feedback[] = {0, 0, 7, 0, 0, 7}; -const static size_t t14_start_state = 1; -const static size_t t14_term_state = 2; - -const static char t14_in_0[] = - {0, 1, 0, 1, 0, 1, 0}; -const static char t14_in_1[] = - {0, 0, 0, 0, 1, 1, 0}; -const static char t14_in_2[] = - {0, 1, 0, 0, 0, 1, 1}; -const static char* t14_in[] = - {t14_in_0, t14_in_1, t14_in_2}; - -const static size_t t14_n_input_items = sizeof (t14_in_0); -const static size_t t14_n_code_inputs = sizeof (t14_in) / sizeof (char*); - -const static char t14_res_0[] = - {1, 1, 1, 1, 1, 0, 1, 1, 1}; -const static char t14_res_1[] = - {1, 0, 0, 1, 0, 0, 0, 0, 1}; -const static char* t14_res[] = - {t14_res_0, t14_res_1}; - -const static size_t t14_n_output_items = sizeof (t14_res_0); -const static size_t t14_n_code_outputs = sizeof (t14_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t14 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t14_in, (const char**) t14_res, - 1, (const size_t*) &t14_n_input_items, - (const size_t*) &t14_n_output_items, 5, - t14_n_code_inputs, t14_n_code_outputs, - (const int*) t14_code_generator, - (const int*) t14_code_feedback, - true, t14_start_state, t14_term_state); -} - -// TEST 15 -// -// checking for: -// no feedback, block coding but no termination - -const static int t15_code_generator[] = {1, 0, 3, 0, 1, 6}; - -const static char t15_in_0[] = - {0, 1, 0, 1, 0, 0, 1, 1}; -const static char t15_in_1[] = - {0, 1, 0, 0, 1, 0, 1, 1}; -const static char t15_in_2[] = - {0, 1, 0, 1, 1, 0, 0, 1}; -const static char* t15_in[] = - {t15_in_0, t15_in_1, t15_in_2}; - -const static size_t t15_n_input_items = sizeof (t15_in_0); -const static size_t t15_n_code_inputs = sizeof (t15_in) / sizeof (char*); - -const static char t15_res_0[] = - {0, 0, 1, 0, 0, 0, 1, 0}; -const static char t15_res_1[] = - {0, 1, 1, 1, 0, 0, 1, 1}; -const static char* t15_res[] = - {t15_res_0, t15_res_1}; - -const static size_t t15_n_output_items = sizeof (t15_res_0); -const static size_t t15_n_code_outputs = sizeof (t15_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t15 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t15_in, (const char**) t15_res, - 1, (const size_t*) &t15_n_input_items, - (const size_t*) &t15_n_output_items, 5, - t15_n_code_inputs, t15_n_code_outputs, - (const int*) t15_code_generator, 0, false); -} - -// TEST 16 -// -// checking for: -// start state is 0, same feedback, block but no termination - -const static int t16_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t16_code_feedback[] = {0, 0, 7, 0, 0, 7}; - -const static char t16_in_0[] = - {0, 1, 1, 0, 0, 0, 0}; -const static char t16_in_1[] = - {0, 1, 0, 1, 0, 0, 0}; -const static char t16_in_2[] = - {0, 0, 0, 0, 1, 0, 1}; -const static char* t16_in[] = - {t16_in_0, t16_in_1, t16_in_2}; - -const static size_t t16_n_input_items = sizeof (t16_in_0); -const static size_t t16_n_code_inputs = sizeof (t16_in) / sizeof (char*); - -const static char t16_res_0[] = - {0, 1, 1, 0, 1, 0, 1}; -const static char t16_res_1[] = - {0, 1, 0, 1, 0, 0, 0}; -const static char* t16_res[] = - {t16_res_0, t16_res_1}; - -const static size_t t16_n_output_items = sizeof (t16_res_0); -const static size_t t16_n_code_outputs = sizeof (t16_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t16 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t16_in, (const char**) t16_res, - 1, (const size_t*) &t16_n_input_items, - (const size_t*) &t16_n_output_items, 5, t16_n_code_inputs, - t16_n_code_outputs, (const int*) t16_code_generator, - (const int*) t16_code_feedback, false); -} - -// TEST 17 -// -// checking for: -// state state is 0, different feedbacks, block but no termination - -const static int t17_code_generator[] = {1, 4, 0, 3, 1, 6}; -const static int t17_code_feedback[] = {0, 5, 0, 7, 0, 7}; - -const static char t17_in_0[] = - {0, 1, 0, 0, 0, 1, 0, 1, 1}; -const static char t17_in_1[] = - {0, 0, 0, 1, 1, 1, 0, 1, 0}; -const static char* t17_in[] = - {t17_in_0, t17_in_1}; - -const static size_t t17_n_input_items = sizeof (t17_in_0); -const static size_t t17_n_code_inputs = sizeof (t17_in) / sizeof (char*); - -const static char t17_res_0[] = - {0, 1, 0, 0, 0, 0, 0, 1, 1}; -const static char t17_res_1[] = - {0, 0, 0, 1, 1, 0, 0, 1, 0}; -const static char t17_res_2[] = - {0, 1, 0, 0, 1, 0, 0, 1, 0}; -const static char* t17_res[] = - {t17_res_0, t17_res_1, t17_res_2}; - -const static size_t t17_n_output_items = sizeof (t17_res_0); -const static size_t t17_n_code_outputs = sizeof (t17_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t17 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t17_in, (const char**) t17_res, - 1, (const size_t*) &t17_n_input_items, - (const size_t*) &t17_n_output_items, 6, t17_n_code_inputs, - t17_n_code_outputs, (const int*) t17_code_generator, - (const int*) t17_code_feedback, false); -} - -// TEST 18 -// -// checking for: -// start state is not 0, no feedback, terminating to non-0 state -// multi-encode, stop output before term bits - -const static int t18_code_generator[] = {1, 0, 3, 0, 1, 6}; -const static size_t t18_start_state = 2; -const static size_t t18_term_state = 2; - -const static char t18_in_0[] = - {0, 1, 1, 1, 0, 1, 0}; -const static char t18_in_1[] = - {0, 1, 0, 0, 0, 0, 1}; -const static char t18_in_2[] = - {0, 1, 1, 0, 1, 0, 1}; -const static char* t18_in[] = - {t18_in_0, t18_in_1, t18_in_2}; - -const static size_t t18_n_input_items[] = {3, 2, 2}; -const static size_t t18_n_io_items = (sizeof (t18_n_input_items) / - sizeof (size_t)); -const static size_t t18_n_code_inputs = sizeof (t18_in) / sizeof (char*); - -const static char t18_res_0[] = - {0, 0, 1, 0, 1, 0, 1, 1, 1}; -const static char t18_res_1[] = - {1, 1, 1, 0, 1, 1, 0, 1, 1}; -const static char* t18_res[] = - {t18_res_0, t18_res_1}; - -const static size_t t18_n_output_items[] = {3, 2, 4}; -const static size_t t18_n_code_outputs = sizeof (t18_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t18 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t18_in, (const char**) t18_res, - t18_n_io_items, (const size_t*) t18_n_input_items, - (const size_t*) t18_n_output_items, 5, t18_n_code_inputs, - t18_n_code_outputs, (const int*) t18_code_generator, - 0, true, t18_start_state, t18_term_state); -} - -// TEST 19 -// -// checking for: -// start state is not 0, any feedback, termination to non-zero state -// multi-encode, stop output in the middle of term bits - -const static int t19_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t19_code_feedback[] = {0, 0, 7, 0, 0, 7}; -const static size_t t19_start_state = 1; -const static size_t t19_term_state = 2; - -const static char t19_in_0[] = - {0, 1, 0, 1, 0, 1, 0}; -const static char t19_in_1[] = - {0, 0, 0, 0, 1, 1, 0}; -const static char t19_in_2[] = - {0, 1, 0, 0, 0, 1, 1}; -const static char* t19_in[] = - {t19_in_0, t19_in_1, t19_in_2}; - -const static size_t t19_n_input_items[] = {2, 2, 1, 1, 1}; -const static size_t t19_n_io_items = (sizeof (t19_n_input_items) / - sizeof (size_t)); -const static size_t t19_n_code_inputs = sizeof (t19_in) / sizeof (char*); - -const static char t19_res_0[] = - {1, 1, 1, 1, 1, 0, 1, 1, 1}; -const static char t19_res_1[] = - {1, 0, 0, 1, 0, 0, 0, 0, 1}; -const static char* t19_res[] = - {t19_res_0, t19_res_1}; - -const static size_t t19_n_output_items[] = {2, 2, 2, 2, 1}; -const static size_t t19_n_code_outputs = sizeof (t19_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t19 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t19_in, (const char**) t19_res, - 1, (const size_t*) &t19_n_input_items, - (const size_t*) &t19_n_output_items, 5, - t19_n_code_inputs, t19_n_code_outputs, - (const int*) t19_code_generator, - (const int*) t19_code_feedback, - true, t19_start_state, t19_term_state); -} - -// TEST 20 -// -// checking for: -// no feedback, block coding but no termination -// multi-encode - -const static int t20_code_generator[] = {1, 0, 3, 0, 1, 6}; - -const static char t20_in_0[] = - {0, 1, 0, 1, 0, 0, 1, 1}; -const static char t20_in_1[] = - {0, 1, 0, 0, 1, 0, 1, 1}; -const static char t20_in_2[] = - {0, 1, 0, 1, 1, 0, 0, 1}; -const static char* t20_in[] = - {t20_in_0, t20_in_1, t20_in_2}; - -const static size_t t20_n_input_items[] = {2, 2, 2, 2}; -const static size_t t20_n_n_input_items = (sizeof (t20_n_input_items) / - sizeof (size_t)); -const static size_t t20_n_code_inputs = sizeof (t20_in) / sizeof (char*); - -const static char t20_res_0[] = - {0, 0, 1, 0, 0, 0, 1, 0}; -const static char t20_res_1[] = - {0, 1, 1, 1, 0, 0, 1, 1}; -const static char* t20_res[] = - {t20_res_0, t20_res_1}; - -const static size_t t20_n_output_items[] = {2, 2, 2, 2}; -const static size_t t20_n_code_outputs = sizeof (t20_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t20 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t20_in, (const char**) t20_res, - t20_n_n_input_items, (const size_t*) t20_n_input_items, - (const size_t*) t20_n_output_items, 5, - t20_n_code_inputs, t20_n_code_outputs, - (const int*) t20_code_generator, 0, false); -} - -// TEST 21 -// -// checking for: -// start state is 0, same feedback, block but no termination -// multi-encode - -const static int t21_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t21_code_feedback[] = {0, 0, 7, 0, 0, 7}; - -const static char t21_in_0[] = - {0, 1, 1, 0, 0, 0, 0}; -const static char t21_in_1[] = - {0, 1, 0, 1, 0, 0, 0}; -const static char t21_in_2[] = - {0, 0, 0, 0, 1, 0, 1}; -const static char* t21_in[] = - {t21_in_0, t21_in_1, t21_in_2}; - -const static size_t t21_n_input_items[] = {5, 1, 1}; -const static size_t t21_n_n_input_items = (sizeof (t21_n_input_items) / - sizeof (size_t)); -const static size_t t21_n_code_inputs = sizeof (t21_in) / sizeof (char*); - -const static char t21_res_0[] = - {0, 1, 1, 0, 1, 0, 1}; -const static char t21_res_1[] = - {0, 1, 0, 1, 0, 0, 0}; -const static char* t21_res[] = - {t21_res_0, t21_res_1}; - -const static size_t t21_n_output_items[] = {5, 1, 1}; -const static size_t t21_n_code_outputs = sizeof (t21_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t21 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t21_in, (const char**) t21_res, - t21_n_n_input_items, (const size_t*) t21_n_input_items, - (const size_t*) t21_n_output_items, 5, t21_n_code_inputs, - t21_n_code_outputs, (const int*) t21_code_generator, - (const int*) t21_code_feedback, false); -} - -// TEST 22 -// -// checking for: -// state state is 0, different feedbacks, block but no termination -// multi-encode - -const static int t22_code_generator[] = {1, 4, 0, 3, 1, 6}; -const static int t22_code_feedback[] = {0, 5, 0, 7, 0, 7}; - -const static char t22_in_0[] = - {0, 1, 0, 0, 0, 1, 0, 1, 1}; -const static char t22_in_1[] = - {0, 0, 0, 1, 1, 1, 0, 1, 0}; -const static char* t22_in[] = - {t22_in_0, t22_in_1}; - -const static size_t t22_n_input_items[] = {5, 4}; -const static size_t t22_n_n_input_items = (sizeof (t22_n_input_items) / - sizeof (size_t)); -const static size_t t22_n_code_inputs = sizeof (t22_in) / sizeof (char*); - -const static char t22_res_0[] = - {0, 1, 0, 0, 0, 0, 0, 1, 1}; -const static char t22_res_1[] = - {0, 0, 0, 1, 1, 0, 0, 1, 0}; -const static char t22_res_2[] = - {0, 1, 0, 0, 1, 0, 0, 1, 0}; -const static char* t22_res[] = - {t22_res_0, t22_res_1, t22_res_2}; - -const static size_t t22_n_output_items[] = {5, 4}; -const static size_t t22_n_code_outputs = sizeof (t22_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t22 -() -{ - do_encoder_check (g_do_encode_in_or_out_0_22, - (const char**) t22_in, (const char**) t22_res, - t22_n_n_input_items, (const size_t*) t22_n_input_items, - (const size_t*) t22_n_output_items, 6, t22_n_code_inputs, - t22_n_code_outputs, (const int*) t22_code_generator, - (const int*) t22_code_feedback, false); -} - -// TESTS 23 through 45 use do_encode_in_or_out as true - -static const bool g_do_encode_in_or_out_23_45 = true; - -// TEST 23 -// -// checking for: -// SIAO realization (implicitely) -// start state is 0, no feedback, no termination - -const static int t23_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static size_t t23_encode_soai = 0; - -const static char t23_in_0[] = - {0, 1, 0, 0, 1, 0, 1, 0, 0, 0}; -const static char t23_in_1[] = - {0, 1, 0, 0, 0, 1, 1, 0, 0, 0}; -const static char t23_in_2[] = - {0, 0, 1, 1, 1, 1, 1, 0, 0, 0}; -const static char* t23_in[] = - {t23_in_0, t23_in_1, t23_in_2}; - -const static size_t t23_n_input_items = sizeof (t23_in_0); -const static size_t t23_n_code_inputs = sizeof (t23_in) / sizeof (char*); - -const static char t23_res_0[] = - {0, 1, 1, 1, 1, 0, 1, 1, 1, 0}; -const static char t23_res_1[] = - {0, 1, 0, 1, 0, 1, 1, 0, 1, 0}; -const static char* t23_res[] = - {t23_res_0, t23_res_1}; - -const static size_t t23_n_output_items = sizeof (t23_res_0); -const static size_t t23_n_code_outputs = sizeof (t23_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t23 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t23_in, (const char**) t23_res, - 1, (const size_t*) &t23_n_input_items, - (const size_t*) &t23_n_output_items, 100, - t23_n_code_inputs, t23_n_code_outputs, - (const int*) t23_code_generator, - 0, true, 0, 0, t23_encode_soai); -} - -// TEST 24 -// -// checking for SIAO realization (implicitely) -// start state is 0, no feedback, no termination - -const static int t24_code_generator[] = {1, 0, 0, 1, 5, 6}; -const static size_t t24_encode_soai = 1; - -const static char t24_in_0[] = - {0, 1, 1, 1, 0, 0, 0, 1, 0}; -const static char t24_in_1[] = - {0, 0, 0, 0, 0, 1, 1, 1, 0}; -const static char* t24_in[] = - {t24_in_0, t24_in_1}; - -const static size_t t24_n_input_items = sizeof (t24_in_0); -const static size_t t24_n_code_inputs = sizeof (t24_in) / sizeof (char*); - -const static char t24_res_0[] = - {0, 1, 1, 1, 0, 0, 0, 1, 0}; -const static char t24_res_1[] = - {0, 0, 0, 0, 0, 1, 1, 1, 0}; -const static char t24_res_2[] = - {0, 1, 1, 0, 1, 1, 1, 1, 0}; -const static char* t24_res[] = - {t24_res_0, t24_res_1, t24_res_2}; - -const static size_t t24_n_output_items = sizeof (t24_res_0); -const static size_t t24_n_code_outputs = sizeof (t24_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t24 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t24_in, (const char**) t24_res, - 1, (const size_t*) &t24_n_input_items, - (const size_t*) &t24_n_output_items, 100, - t24_n_code_inputs, t24_n_code_outputs, - (const int*) t24_code_generator, - 0, true, 0, 0, t24_encode_soai); -} - -// TEST 25 -// -// checking for SOAI realization (implicitely) -// start state is 0, same feedback, no termination - -const static int t25_code_generator[] = {1, 0, 0, 1, 5, 6}; -const static int t25_code_feedback[] = {0, 0, 0, 0, 7, 7}; -const static int t25_encode_soai = 1; - -const static char t25_in_0[] = - {0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0}; -const static char t25_in_1[] = - {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0}; -const static char* t25_in[] = - {t25_in_0, t25_in_1}; - -const static size_t t25_n_input_items = sizeof (t25_in_0); -const static size_t t25_n_code_inputs = sizeof (t25_in) / sizeof (char*); - -const static char t25_res_0[] = - {0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0}; -const static char t25_res_1[] = - {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0}; -const static char t25_res_2[] = - {0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0}; -const static char* t25_res[] = - {t25_res_0, t25_res_1, t25_res_2}; - -const static size_t t25_n_output_items = sizeof (t25_res_0); -const static size_t t25_n_code_outputs = sizeof (t25_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t25 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t25_in, (const char**) t25_res, - 1, (const size_t*) &t25_n_input_items, - (const size_t*) &t25_n_output_items, 100, - t25_n_code_inputs, t25_n_code_outputs, - (const int*) t25_code_generator, - (const int*) t25_code_feedback, - true, 0, 0, t25_encode_soai); -} - -// TEST 26 -// -// checking for SIAO realization (implicitely) -// start state is 0, same feedback, no termination - -const static int t26_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t26_code_feedback[] = {0, 0, 7, 0, 0, 7}; -const static int t26_encode_soai = 0; - -const static char t26_in_0[] = - {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0}; -const static char t26_in_1[] = - {0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const static char t26_in_2[] = - {0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0}; -const static char* t26_in[] = - {t26_in_0, t26_in_1, t26_in_2}; - -const static size_t t26_n_input_items = sizeof (t26_in_0); -const static size_t t26_n_code_inputs = sizeof (t26_in) / sizeof (char*); - -const static char t26_res_0[] = - {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0}; -const static char t26_res_1[] = - {0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0}; -const static char* t26_res[] = - {t26_res_0, t26_res_1}; - -const static size_t t26_n_output_items = sizeof (t26_res_0); -const static size_t t26_n_code_outputs = sizeof (t26_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t26 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t26_in, (const char**) t26_res, - 1, (const size_t*) &t26_n_input_items, - (const size_t*) &t26_n_output_items, 100, - t26_n_code_inputs, t26_n_code_outputs, - (const int*) t26_code_generator, - (const int*) t26_code_feedback, - true, 0, 0, t26_encode_soai); -} - -// TEST 27 -// -// checking for SIAO realization (implicitely), -// start state is 0, different feedbacks, no termination - -const static int t27_code_generator[] = {1, 4, 0, 3, 1, 6}; -const static int t27_code_feedback[] = {0, 7, 0, 5, 0, 5}; -const static int t27_encode_soai = 0; - -const static char t27_in_0[] = - {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0}; -const static char t27_in_1[] = - {0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0}; -const static char* t27_in[] = - {t27_in_0, t27_in_1}; - -const static size_t t27_n_input_items = sizeof (t27_in_0); -const static size_t t27_n_code_inputs = sizeof (t27_in) / sizeof (char*); - -const static char t27_res_0[] = - {0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0}; -const static char t27_res_1[] = - {0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0}; -const static char t27_res_2[] = - {0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0}; -const static char* t27_res[] = - {t27_res_0, t27_res_1, t27_res_2}; - -const static size_t t27_n_output_items = sizeof (t27_res_0); -const static size_t t27_n_code_outputs = sizeof (t27_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t27 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t27_in, (const char**) t27_res, - 1, (const size_t*) &t27_n_input_items, - (const size_t*) &t27_n_output_items, 100, - t27_n_code_inputs, t27_n_code_outputs, - (const int*) t27_code_generator, - (const int*) t27_code_feedback, - true, 0, 0, t27_encode_soai); -} - -// TEST 28 -// -// checking for SOAI realization (implicitely), -// with different feedbacks, no termination - -const static int t28_code_generator[] = {1, 0, 1, 4, 3, 6}; -const static int t28_code_feedback[] = {0, 0, 0, 5, 7, 7}; -const static int t28_encode_soai = 1; - -const static char t28_in_0[] = - {0, 1, 0, 0, 0, 1, 0, 0, 1}; -const static char t28_in_1[] = - {0, 0, 1, 0, 1, 1, 0, 0, 1}; -const static char t28_in_2[] = - {0, 0, 0, 1, 0, 0, 0, 0, 1}; -const static char* t28_in[] = - {t28_in_0, t28_in_1, t28_in_2}; - -const static size_t t28_n_input_items = sizeof (t28_in_0); -const static size_t t28_n_code_inputs = sizeof (t28_in) / sizeof (char*); - -const static char t28_res_0[] = - {0, 1, 0, 1, 0, 1, 0, 0, 0}; -const static char t28_res_1[] = - {0, 0, 1, 1, 1, 1, 0, 0, 1}; -const static char* t28_res[] = - {t28_res_0, t28_res_1}; - -const static size_t t28_n_output_items = sizeof (t28_res_0); -const static size_t t28_n_code_outputs = sizeof (t28_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t28 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t28_in, (const char**) t28_res, - 1, (const size_t*) &t28_n_input_items, - (const size_t*) &t28_n_output_items, 100, - t28_n_code_inputs, t28_n_code_outputs, - (const int*) t28_code_generator, - (const int*) t28_code_feedback, true, - 0, 0, t28_encode_soai); -} - -// TEST 29 -// -// checking for: -// start state is 0, no feedback, termination to 0 state - -const static int t29_code_generator[] = {1, 0, 5, 0, 1, 6}; - -const static char t29_in_0[] = - {0, 1, 0, 0, 1, 0}; -const static char t29_in_1[] = - {0, 1, 0, 0, 0, 0}; -const static char t29_in_2[] = - {0, 0, 1, 1, 1, 0}; -const static char* t29_in[] = - {t29_in_0, t29_in_1, t29_in_2}; - -const static size_t t29_n_input_items = sizeof (t29_in_0); -const static size_t t29_n_code_inputs = sizeof (t29_in) / sizeof (char*); - -const static char t29_res_0[] = - {0, 1, 1, 1, 1, 1, 1, 0}; -const static char t29_res_1[] = - {0, 1, 0, 1, 0, 0, 1, 0}; -const static char* t29_res[] = - {t29_res_0, t29_res_1}; - -const static size_t t29_n_output_items = sizeof (t29_res_0); -const static size_t t29_n_code_outputs = sizeof (t29_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t29 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t29_in, (const char**) t29_res, - 1, (const size_t*) &t29_n_input_items, - (const size_t*) &t29_n_output_items, 5, t29_n_code_inputs, - t29_n_code_outputs, (const int*) t29_code_generator); -} - -// TEST 30 -// -// checking for: -// start state is 0, same feedback, termination to 0 state -// # of termination bits = 2 - -const static int t30_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t30_code_feedback[] = {0, 0, 7, 0, 0, 7}; - -const static char t30_in_0[] = - {0, 1, 1, 0, 0, 0, 0}; -const static char t30_in_1[] = - {0, 1, 0, 1, 0, 0, 0}; -const static char t30_in_2[] = - {0, 0, 0, 0, 1, 0, 1}; -const static char* t30_in[] = - {t30_in_0, t30_in_1, t30_in_2}; - -const static size_t t30_n_input_items = sizeof (t30_in_0); -const static size_t t30_n_code_inputs = sizeof (t30_in) / sizeof (char*); - -const static char t30_res_0[] = - {0, 1, 1, 0, 1, 0, 1, 0, 1}; -const static char t30_res_1[] = - {0, 1, 0, 1, 0, 1, 1, 0, 0}; -const static char* t30_res[] = - {t30_res_0, t30_res_1}; - -const static size_t t30_n_output_items = sizeof (t30_res_0); -const static size_t t30_n_code_outputs = sizeof (t30_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t30 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t30_in, (const char**) t30_res, - 1, (const size_t*) &t30_n_input_items, - (const size_t*) &t30_n_output_items, 5, t30_n_code_inputs, - t30_n_code_outputs, (const int*) t30_code_generator, - (const int*) t30_code_feedback); -} - -// TEST 31 -// -// checking for: -// state state is 0, different feedbacks, termination to 0 state -// # of term bits will be 4 - -const static int t31_code_generator[] = {1, 4, 0, 3, 1, 6}; -const static int t31_code_feedback[] = {0, 5, 0, 7, 0, 7}; - -const static char t31_in_0[] = - {0, 1, 0, 0, 0, 1, 0, 1, 1}; -const static char t31_in_1[] = - {0, 0, 0, 1, 1, 1, 0, 1, 0}; -const static char* t31_in[] = - {t31_in_0, t31_in_1}; - -const static size_t t31_n_input_items = sizeof (t31_in_0); -const static size_t t31_n_code_inputs = sizeof (t31_in) / sizeof (char*); - -const static char t31_res_0[] = - {0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1}; -const static char t31_res_1[] = - {0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0}; -const static char t31_res_2[] = - {0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; -const static char* t31_res[] = - {t31_res_0, t31_res_1, t31_res_2}; - -const static size_t t31_n_output_items = sizeof (t31_res_0); -const static size_t t31_n_code_outputs = sizeof (t31_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t31 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t31_in, (const char**) t31_res, - 1, (const size_t*) &t31_n_input_items, - (const size_t*) &t31_n_output_items, 6, t31_n_code_inputs, - t31_n_code_outputs, (const int*) t31_code_generator, - (const int*) t31_code_feedback); -} - -// TEST 32 -// -// checking for: -// start state is 0, different feedbacks, termination to non-0 state -// # of term bits will be 2 - -const static int t32_code_generator[] = {1, 0, 1, 4, 3, 6}; -const static int t32_code_feedback[] = {0, 0, 0, 5, 7, 7}; -const static size_t t32_term_state = 4; - -const static char t32_in_0[] = - {0, 1, 0, 0, 0, 0, 1}; -const static char t32_in_1[] = - {0, 0, 1, 0, 1, 0, 1}; -const static char t32_in_2[] = - {0, 0, 0, 1, 0, 0, 1}; -const static char* t32_in[] = - {t32_in_0, t32_in_1, t32_in_2}; - -const static size_t t32_n_input_items = sizeof (t32_in_0); -const static size_t t32_n_code_inputs = sizeof (t32_in) / sizeof (char*); - -const static char t32_res_0[] = - {0, 1, 0, 1, 0, 1, 1, 0, 0}; -const static char t32_res_1[] = - {0, 0, 1, 1, 1, 1, 1, 0, 1}; -const static char* t32_res[] = - {t32_res_0, t32_res_1}; - -const static size_t t32_n_output_items = sizeof (t32_res_0); -const static size_t t32_n_code_outputs = sizeof (t32_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t32 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t32_in, (const char**) t32_res, - 1, (const size_t*) &t32_n_input_items, - (const size_t*) &t32_n_output_items, 5, t32_n_code_inputs, - t32_n_code_outputs, (const int*) t32_code_generator, - (const int*) t32_code_feedback, true, 0, t32_term_state); -} - -// TEST 33 -// -// checking for termination to non-0 state, no feedback - -const static int t33_code_generator[] = {1, 0, 3, 0, 1, 6}; -const static size_t t33_term_state = 2; - -const static char t33_in_0[] = - {0, 1, 0, 1, 0, 0, 1, 1}; -const static char t33_in_1[] = - {0, 1, 0, 0, 1, 0, 1, 1}; -const static char t33_in_2[] = - {0, 1, 0, 1, 1, 0, 0, 1}; -const static char* t33_in[] = - {t33_in_0, t33_in_1, t33_in_2}; - -const static size_t t33_n_input_items = sizeof (t33_in_0); -const static size_t t33_n_code_inputs = sizeof (t33_in) / sizeof (char*); - -const static char t33_res_0[] = - {0, 0, 1, 0, 0, 0, 1, 0, 1, 0}; -const static char t33_res_1[] = - {0, 1, 1, 1, 0, 0, 0, 0, 1, 1}; -const static char* t33_res[] = - {t33_res_0, t33_res_1}; - -const static size_t t33_n_output_items = sizeof (t33_res_0); -const static size_t t33_n_code_outputs = sizeof (t33_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t33 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t33_in, (const char**) t33_res, - 1, (const size_t*) &t33_n_input_items, - (const size_t*) &t33_n_output_items, 5, - t33_n_code_inputs, t33_n_code_outputs, - (const int*) t33_code_generator, - 0, true, 0, t33_term_state); -} - -// TEST 34 -// -// checking for: -// start state is not 0, no feedback, terminating to 0 state - -const static int t34_code_generator[] = {1, 0, 3, 0, 1, 6}; -const static size_t t34_start_state = 1; - -const static char t34_in_0[] = - {0, 1, 0, 0, 0, 1, 0}; -const static char t34_in_1[] = - {0, 0, 1, 0, 0, 1, 0}; -const static char t34_in_2[] = - {0, 1, 1, 1, 0, 1, 1}; -const static char* t34_in[] = - {t34_in_0, t34_in_1, t34_in_2}; - -const static size_t t34_n_input_items = sizeof (t34_in_0); -const static size_t t34_n_code_inputs = sizeof (t34_in) / sizeof (char*); - -const static char t34_res_0[] = - {1, 0, 0, 0, 1, 0, 0, 1, 0}; -const static char t34_res_1[] = - {1, 1, 0, 0, 0, 1, 0, 0, 0}; -const static char* t34_res[] = - {t34_res_0, t34_res_1}; - -const static size_t t34_n_output_items = sizeof (t34_res_0); -const static size_t t34_n_code_outputs = sizeof (t34_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t34 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t34_in, (const char**) t34_res, - 1, (const size_t*) &t34_n_input_items, - (const size_t*) &t34_n_output_items, 5, - t34_n_code_inputs, t34_n_code_outputs, - (const int*) t34_code_generator, - 0, true, t34_start_state); -} - -// TEST 35 -// -// checking for: -// start state is not 0, no feedback, terminating to non-0 state - -const static int t35_code_generator[] = {1, 0, 3, 0, 1, 6}; -const static size_t t35_start_state = 2; -const static size_t t35_term_state = 2; - -const static char t35_in_0[] = - {0, 1, 1, 1, 0, 1, 0}; -const static char t35_in_1[] = - {0, 1, 0, 0, 0, 0, 1}; -const static char t35_in_2[] = - {0, 1, 1, 0, 1, 0, 1}; -const static char* t35_in[] = - {t35_in_0, t35_in_1, t35_in_2}; - -const static size_t t35_n_input_items = sizeof (t35_in_0); -const static size_t t35_n_code_inputs = sizeof (t35_in) / sizeof (char*); - -const static char t35_res_0[] = - {0, 0, 1, 0, 1, 0, 1, 1, 1}; -const static char t35_res_1[] = - {1, 1, 1, 0, 1, 1, 0, 1, 1}; -const static char* t35_res[] = - {t35_res_0, t35_res_1}; - -const static size_t t35_n_output_items = sizeof (t35_res_0); -const static size_t t35_n_code_outputs = sizeof (t35_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t35 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t35_in, (const char**) t35_res, - 1, (const size_t*) &t35_n_input_items, - (const size_t*) &t35_n_output_items, 5, t35_n_code_inputs, - t35_n_code_outputs, (const int*) t35_code_generator, - 0, true, t35_start_state, t35_term_state); -} - -// TEST 36 -// -// checking for: -// start state is not 0, any feedback, termination to 0 state - -const static int t36_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t36_code_feedback[] = {0, 0, 7, 0, 0, 7}; -const static size_t t36_start_state = 2; -const static size_t t36_term_state = 0; - -const static char t36_in_0[] = - {0, 1, 0, 0, 0, 1, 0}; -const static char t36_in_1[] = - {0, 0, 1, 1, 0, 1, 0}; -const static char t36_in_2[] = - {0, 0, 0, 0, 1, 0, 0}; -const static char* t36_in[] = - {t36_in_0, t36_in_1, t36_in_2}; - -const static size_t t36_n_input_items = sizeof (t36_in_0); -const static size_t t36_n_code_inputs = sizeof (t36_in) / sizeof (char*); - -const static char t36_res_0[] = - {0, 0, 1, 0, 0, 1, 0, 1, 1}; -const static char t36_res_1[] = - {1, 1, 1, 0, 1, 1, 0, 0, 1}; -const static char* t36_res[] = - {t36_res_0, t36_res_1}; - -const static size_t t36_n_output_items = sizeof (t36_res_0); -const static size_t t36_n_code_outputs = sizeof (t36_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t36 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t36_in, (const char**) t36_res, - 1, (const size_t*) &t36_n_input_items, - (const size_t*) &t36_n_output_items, 5, - t36_n_code_inputs, t36_n_code_outputs, - (const int*) t36_code_generator, - (const int*) t36_code_feedback, - true, t36_start_state, t36_term_state); -} - -// TEST 37 -// -// checking for: -// start state is not 0, any feedback, termination to non-zero state - -const static int t37_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t37_code_feedback[] = {0, 0, 7, 0, 0, 7}; -const static size_t t37_start_state = 1; -const static size_t t37_term_state = 2; - -const static char t37_in_0[] = - {0, 1, 0, 1, 0, 1, 0}; -const static char t37_in_1[] = - {0, 0, 0, 0, 1, 1, 0}; -const static char t37_in_2[] = - {0, 1, 0, 0, 0, 1, 1}; -const static char* t37_in[] = - {t37_in_0, t37_in_1, t37_in_2}; - -const static size_t t37_n_input_items = sizeof (t37_in_0); -const static size_t t37_n_code_inputs = sizeof (t37_in) / sizeof (char*); - -const static char t37_res_0[] = - {1, 1, 1, 1, 1, 0, 1, 1, 1}; -const static char t37_res_1[] = - {1, 0, 0, 1, 0, 0, 0, 0, 1}; -const static char* t37_res[] = - {t37_res_0, t37_res_1}; - -const static size_t t37_n_output_items = sizeof (t37_res_0); -const static size_t t37_n_code_outputs = sizeof (t37_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t37 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t37_in, (const char**) t37_res, - 1, (const size_t*) &t37_n_input_items, - (const size_t*) &t37_n_output_items, 5, - t37_n_code_inputs, t37_n_code_outputs, - (const int*) t37_code_generator, - (const int*) t37_code_feedback, - true, t37_start_state, t37_term_state); -} - -// TEST 38 -// -// checking for: -// no feedback, block coding but no termination - -const static int t38_code_generator[] = {1, 0, 3, 0, 1, 6}; - -const static char t38_in_0[] = - {0, 1, 0, 1, 0, 0, 1, 1}; -const static char t38_in_1[] = - {0, 1, 0, 0, 1, 0, 1, 1}; -const static char t38_in_2[] = - {0, 1, 0, 1, 1, 0, 0, 1}; -const static char* t38_in[] = - {t38_in_0, t38_in_1, t38_in_2}; - -const static size_t t38_n_input_items = sizeof (t38_in_0); -const static size_t t38_n_code_inputs = sizeof (t38_in) / sizeof (char*); - -const static char t38_res_0[] = - {0, 0, 1, 0, 0, 0, 1, 0}; -const static char t38_res_1[] = - {0, 1, 1, 1, 0, 0, 1, 1}; -const static char* t38_res[] = - {t38_res_0, t38_res_1}; - -const static size_t t38_n_output_items = sizeof (t38_res_0); -const static size_t t38_n_code_outputs = sizeof (t38_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t38 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t38_in, (const char**) t38_res, - 1, (const size_t*) &t38_n_input_items, - (const size_t*) &t38_n_output_items, 5, - t38_n_code_inputs, t38_n_code_outputs, - (const int*) t38_code_generator, 0, false); -} - -// TEST 39 -// -// checking for: -// start state is 0, same feedback, block but no termination - -const static int t39_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t39_code_feedback[] = {0, 0, 7, 0, 0, 7}; - -const static char t39_in_0[] = - {0, 1, 1, 0, 0, 0, 0}; -const static char t39_in_1[] = - {0, 1, 0, 1, 0, 0, 0}; -const static char t39_in_2[] = - {0, 0, 0, 0, 1, 0, 1}; -const static char* t39_in[] = - {t39_in_0, t39_in_1, t39_in_2}; - -const static size_t t39_n_input_items = sizeof (t39_in_0); -const static size_t t39_n_code_inputs = sizeof (t39_in) / sizeof (char*); - -const static char t39_res_0[] = - {0, 1, 1, 0, 1, 0, 1}; -const static char t39_res_1[] = - {0, 1, 0, 1, 0, 0, 0}; -const static char* t39_res[] = - {t39_res_0, t39_res_1}; - -const static size_t t39_n_output_items = sizeof (t39_res_0); -const static size_t t39_n_code_outputs = sizeof (t39_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t39 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t39_in, (const char**) t39_res, - 1, (const size_t*) &t39_n_input_items, - (const size_t*) &t39_n_output_items, 5, t39_n_code_inputs, - t39_n_code_outputs, (const int*) t39_code_generator, - (const int*) t39_code_feedback, false); -} - -// TEST 40 -// -// checking for: -// state state is 0, different feedbacks, block but no termination - -const static int t40_code_generator[] = {1, 4, 0, 3, 1, 6}; -const static int t40_code_feedback[] = {0, 5, 0, 7, 0, 7}; - -const static char t40_in_0[] = - {0, 1, 0, 0, 0, 1, 0, 1, 1}; -const static char t40_in_1[] = - {0, 0, 0, 1, 1, 1, 0, 1, 0}; -const static char* t40_in[] = - {t40_in_0, t40_in_1}; - -const static size_t t40_n_input_items = sizeof (t40_in_0); -const static size_t t40_n_code_inputs = sizeof (t40_in) / sizeof (char*); - -const static char t40_res_0[] = - {0, 1, 0, 0, 0, 0, 0, 1, 1}; -const static char t40_res_1[] = - {0, 0, 0, 1, 1, 0, 0, 1, 0}; -const static char t40_res_2[] = - {0, 1, 0, 0, 1, 0, 0, 1, 0}; -const static char* t40_res[] = - {t40_res_0, t40_res_1, t40_res_2}; - -const static size_t t40_n_output_items = sizeof (t40_res_0); -const static size_t t40_n_code_outputs = sizeof (t40_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t40 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t40_in, (const char**) t40_res, - 1, (const size_t*) &t40_n_input_items, - (const size_t*) &t40_n_output_items, 6, t40_n_code_inputs, - t40_n_code_outputs, (const int*) t40_code_generator, - (const int*) t40_code_feedback, false); -} - -// TEST 41 -// -// checking for: -// start state is not 0, no feedback, terminating to non-0 state -// multi-encode, forced to retrieve all term outputs - -const static int t41_code_generator[] = {1, 0, 3, 0, 1, 6}; -const static size_t t41_start_state = 2; -const static size_t t41_term_state = 2; - -const static char t41_in_0[] = - {0, 1, 1, 1, 0, 1, 0}; -const static char t41_in_1[] = - {0, 1, 0, 0, 0, 0, 1}; -const static char t41_in_2[] = - {0, 1, 1, 0, 1, 0, 1}; -const static char* t41_in[] = - {t41_in_0, t41_in_1, t41_in_2}; - -const static size_t t41_n_input_items[] = {3, 2, 2}; -const static size_t t41_n_io_items = (sizeof (t41_n_input_items) / - sizeof (size_t)); -const static size_t t41_n_code_inputs = sizeof (t41_in) / sizeof (char*); - -const static char t41_res_0[] = - {0, 0, 1, 0, 1, 0, 1, 1, 1}; -const static char t41_res_1[] = - {1, 1, 1, 0, 1, 1, 0, 1, 1}; -const static char* t41_res[] = - {t41_res_0, t41_res_1}; - -const static size_t t41_n_output_items[] = {3, 4, 2}; -const static size_t t41_n_code_outputs = sizeof (t41_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t41 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t41_in, (const char**) t41_res, - t41_n_io_items, (const size_t*) t41_n_input_items, - (const size_t*) t41_n_output_items, 5, t41_n_code_inputs, - t41_n_code_outputs, (const int*) t41_code_generator, - 0, true, t41_start_state, t41_term_state); -} - -// TEST 42 -// -// checking for: -// start state is not 0, any feedback, termination to non-zero state -// multi-encode - -const static int t42_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t42_code_feedback[] = {0, 0, 7, 0, 0, 7}; -const static size_t t42_start_state = 1; -const static size_t t42_term_state = 2; - -const static char t42_in_0[] = - {0, 1, 0, 1, 0, 1, 0}; -const static char t42_in_1[] = - {0, 0, 0, 0, 1, 1, 0}; -const static char t42_in_2[] = - {0, 1, 0, 0, 0, 1, 1}; -const static char* t42_in[] = - {t42_in_0, t42_in_1, t42_in_2}; - -const static size_t t42_n_input_items[] = {2, 2, 1, 1, 1}; -const static size_t t42_n_io_items = (sizeof (t42_n_input_items) / - sizeof (size_t)); -const static size_t t42_n_code_inputs = sizeof (t42_in) / sizeof (char*); - -const static char t42_res_0[] = - {1, 1, 1, 1, 1, 0, 1, 1, 1}; -const static char t42_res_1[] = - {1, 0, 0, 1, 0, 0, 0, 0, 1}; -const static char* t42_res[] = - {t42_res_0, t42_res_1}; - -const static size_t t42_n_output_items[] = {2, 2, 3, 1, 1}; -const static size_t t42_n_code_outputs = sizeof (t42_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t42 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t42_in, (const char**) t42_res, - 1, (const size_t*) &t42_n_input_items, - (const size_t*) &t42_n_output_items, 5, - t42_n_code_inputs, t42_n_code_outputs, - (const int*) t42_code_generator, - (const int*) t42_code_feedback, - true, t42_start_state, t42_term_state); -} - -// TEST 43 -// -// checking for: -// no feedback, block coding but no termination -// multi-encode - -const static int t43_code_generator[] = {1, 0, 3, 0, 1, 6}; - -const static char t43_in_0[] = - {0, 1, 0, 1, 0, 0, 1, 1}; -const static char t43_in_1[] = - {0, 1, 0, 0, 1, 0, 1, 1}; -const static char t43_in_2[] = - {0, 1, 0, 1, 1, 0, 0, 1}; -const static char* t43_in[] = - {t43_in_0, t43_in_1, t43_in_2}; - -const static size_t t43_n_input_items[] = {2, 2, 2, 2}; -const static size_t t43_n_n_input_items = (sizeof (t43_n_input_items) / - sizeof (size_t)); -const static size_t t43_n_code_inputs = sizeof (t43_in) / sizeof (char*); - -const static char t43_res_0[] = - {0, 0, 1, 0, 0, 0, 1, 0}; -const static char t43_res_1[] = - {0, 1, 1, 1, 0, 0, 1, 1}; -const static char* t43_res[] = - {t43_res_0, t43_res_1}; - -const static size_t t43_n_output_items[] = {2, 2, 2, 2}; -const static size_t t43_n_code_outputs = sizeof (t43_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t43 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t43_in, (const char**) t43_res, - t43_n_n_input_items, (const size_t*) t43_n_input_items, - (const size_t*) t43_n_output_items, 5, - t43_n_code_inputs, t43_n_code_outputs, - (const int*) t43_code_generator, 0, false); -} - -// TEST 44 -// -// checking for: -// start state is 0, same feedback, block but no termination -// multi-encode - -const static int t44_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static int t44_code_feedback[] = {0, 0, 7, 0, 0, 7}; - -const static char t44_in_0[] = - {0, 1, 1, 0, 0, 0, 0}; -const static char t44_in_1[] = - {0, 1, 0, 1, 0, 0, 0}; -const static char t44_in_2[] = - {0, 0, 0, 0, 1, 0, 1}; -const static char* t44_in[] = - {t44_in_0, t44_in_1, t44_in_2}; - -const static size_t t44_n_input_items[] = {5, 1, 1}; -const static size_t t44_n_n_input_items = (sizeof (t44_n_input_items) / - sizeof (size_t)); -const static size_t t44_n_code_inputs = sizeof (t44_in) / sizeof (char*); - -const static char t44_res_0[] = - {0, 1, 1, 0, 1, 0, 1}; -const static char t44_res_1[] = - {0, 1, 0, 1, 0, 0, 0}; -const static char* t44_res[] = - {t44_res_0, t44_res_1}; - -const static size_t t44_n_output_items[] = {5, 1, 1}; -const static size_t t44_n_code_outputs = sizeof (t44_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t44 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t44_in, (const char**) t44_res, - t44_n_n_input_items, (const size_t*) t44_n_input_items, - (const size_t*) t44_n_output_items, 5, t44_n_code_inputs, - t44_n_code_outputs, (const int*) t44_code_generator, - (const int*) t44_code_feedback, false); -} - -// TEST 45 -// -// checking for: -// state state is 0, different feedbacks, block but no termination -// multi-encode - -const static int t45_code_generator[] = {1, 4, 0, 3, 1, 6}; -const static int t45_code_feedback[] = {0, 5, 0, 7, 0, 7}; - -const static char t45_in_0[] = - {0, 1, 0, 0, 0, 1, 0, 1, 1}; -const static char t45_in_1[] = - {0, 0, 0, 1, 1, 1, 0, 1, 0}; -const static char* t45_in[] = - {t45_in_0, t45_in_1}; - -const static size_t t45_n_input_items[] = {5, 4}; -const static size_t t45_n_n_input_items = (sizeof (t45_n_input_items) / - sizeof (size_t)); -const static size_t t45_n_code_inputs = sizeof (t45_in) / sizeof (char*); - -const static char t45_res_0[] = - {0, 1, 0, 0, 0, 0, 0, 1, 1}; -const static char t45_res_1[] = - {0, 0, 0, 1, 1, 0, 0, 1, 0}; -const static char t45_res_2[] = - {0, 1, 0, 0, 1, 0, 0, 1, 0}; -const static char* t45_res[] = - {t45_res_0, t45_res_1, t45_res_2}; - -const static size_t t45_n_output_items[] = {5, 4}; -const static size_t t45_n_code_outputs = sizeof (t45_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t45 -() -{ - do_encoder_check (g_do_encode_in_or_out_23_45, - (const char**) t45_in, (const char**) t45_res, - t45_n_n_input_items, (const size_t*) t45_n_input_items, - (const size_t*) t45_n_output_items, 6, t45_n_code_inputs, - t45_n_code_outputs, (const int*) t45_code_generator, - (const int*) t45_code_feedback, false); -} - -// TEST 46 -// -// checking for: -// start state is not 0, no feedback, terminating to non-0 state -// multi-encode, input dictates encoding: forced to retrieve all term -// outputs; multiple encoding blocks - -const static int t46_code_generator[] = {1, 0, 3, 0, 1, 6}; -const static size_t t46_start_state = 2; -const static size_t t46_term_state = 2; - -const static char t46_in_0[] = - {0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0}; -const static char t46_in_1[] = - {0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0}; -const static char t46_in_2[] = - {0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0}; -const static char* t46_in[] = - {t46_in_0, t46_in_1, t46_in_2}; - -const static size_t t46_n_input_items[] = {5, 0, 4, 1, 1}; -const static size_t t46_n_io_items = (sizeof (t46_n_input_items) / - sizeof (size_t)); -const static size_t t46_n_code_inputs = sizeof (t46_in) / sizeof (char*); - -const static char t46_res_0[] = - {0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0}; -const static char t46_res_1[] = - {1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1}; -const static char* t46_res[] = - {t46_res_0, t46_res_1}; - -const static size_t t46_n_output_items[] = {7, 0, 4, 3, 1}; -const static size_t t46_n_code_outputs = sizeof (t46_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t46 -() -{ - do_encoder_check (true, - (const char**) t46_in, (const char**) t46_res, - t46_n_io_items, (const size_t*) t46_n_input_items, - (const size_t*) t46_n_output_items, 5, t46_n_code_inputs, - t46_n_code_outputs, (const int*) t46_code_generator, - 0, true, t46_start_state, t46_term_state); -} - -// TEST 47 -// -// checking for: -// start state is not 0, no feedback, terminating to non-0 state -// multi-encode, output dictates encoding; multiple encoding blocks - -const static int t47_code_generator[] = {1, 0, 3, 0, 1, 6}; -const static size_t t47_start_state = 2; -const static size_t t47_term_state = 2; - -const static char t47_in_0[] = - {0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0}; -const static char t47_in_1[] = - {0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0}; -const static char t47_in_2[] = - {0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0}; -const static char* t47_in[] = - {t47_in_0, t47_in_1, t47_in_2}; - -const static size_t t47_n_input_items[] = {5, 0, 0, 4, 1, 0, 0, 1}; -const static size_t t47_n_io_items = (sizeof (t47_n_input_items) / - sizeof (size_t)); -const static size_t t47_n_code_inputs = sizeof (t47_in) / sizeof (char*); - -const static char t47_res_0[] = - {0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0}; -const static char t47_res_1[] = - {1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1}; -const static char* t47_res[] = - {t47_res_0, t47_res_1}; - -const static size_t t47_n_output_items[] = {6, 0, 1, 4, 1, 1, 1, 1}; -const static size_t t47_n_code_outputs = sizeof (t47_res) / sizeof (char*); - -void -qa_encoder_convolutional_ic1_ic1::t47 -() -{ - do_encoder_check (false, - (const char**) t47_in, (const char**) t47_res, - t47_n_io_items, (const size_t*) t47_n_input_items, - (const size_t*) t47_n_output_items, 5, t47_n_code_inputs, - t47_n_code_outputs, (const int*) t47_code_generator, - 0, true, t47_start_state, t47_term_state); -} - diff --git a/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.h b/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.h deleted file mode 100644 index a3f50ace6..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.h +++ /dev/null @@ -1,150 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_ENCODER_CONVOLUTIONAL_IC1_IC1_H -#define INCLUDED_QA_ENCODER_CONVOLUTIONAL_IC1_IC1_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_encoder_convolutional_ic1_ic1 : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_encoder_convolutional_ic1_ic1); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST (t4); - CPPUNIT_TEST (t5); - CPPUNIT_TEST (t6); - CPPUNIT_TEST (t7); - CPPUNIT_TEST (t8); - CPPUNIT_TEST (t9); - CPPUNIT_TEST (t10); - CPPUNIT_TEST (t11); - CPPUNIT_TEST (t12); - CPPUNIT_TEST (t13); - CPPUNIT_TEST (t14); - CPPUNIT_TEST (t15); - CPPUNIT_TEST (t16); - CPPUNIT_TEST (t17); - CPPUNIT_TEST (t18); - CPPUNIT_TEST (t19); - CPPUNIT_TEST (t20); - CPPUNIT_TEST (t21); - CPPUNIT_TEST (t22); - CPPUNIT_TEST (t23); - CPPUNIT_TEST (t24); - CPPUNIT_TEST (t25); - CPPUNIT_TEST (t26); - CPPUNIT_TEST (t27); - CPPUNIT_TEST (t28); - CPPUNIT_TEST (t29); - CPPUNIT_TEST (t30); - CPPUNIT_TEST (t31); - CPPUNIT_TEST (t32); - CPPUNIT_TEST (t33); - CPPUNIT_TEST (t34); - CPPUNIT_TEST (t35); - CPPUNIT_TEST (t36); - CPPUNIT_TEST (t37); - CPPUNIT_TEST (t38); - CPPUNIT_TEST (t39); - CPPUNIT_TEST (t40); - CPPUNIT_TEST (t41); - CPPUNIT_TEST (t42); - CPPUNIT_TEST (t43); - CPPUNIT_TEST (t44); - CPPUNIT_TEST (t45); - CPPUNIT_TEST (t46); - CPPUNIT_TEST (t47); - CPPUNIT_TEST_SUITE_END (); - - private: - void do_encoder_check (bool use_encode_in_or_out, - const char** c_t1_in, - const char** c_t1_res, - const size_t n_io_items, - const size_t* n_input_items, - const size_t* n_output_items, - const size_t block_size_bits, - const size_t n_code_inputs, - const size_t n_code_outputs, - const int* code_generators, - const int* code_feedback = 0, - const bool do_termination = true, - const size_t start_state = 0, - const size_t term_state = 0, - const int encode_soai = -1); - - void t0 (); - void t1 (); - void t2 (); - void t3 (); - void t4 (); - void t5 (); - void t6 (); - void t7 (); - void t8 (); - void t9 (); - void t10 (); - void t11 (); - void t12 (); - void t13 (); - void t14 (); - void t15 (); - void t16 (); - void t17 (); - void t18 (); - void t19 (); - void t20 (); - void t21 (); - void t22 (); - void t23 (); - void t24 (); - void t25 (); - void t26 (); - void t27 (); - void t28 (); - void t29 (); - void t30 (); - void t31 (); - void t32 (); - void t33 (); - void t34 (); - void t35 (); - void t36 (); - void t37 (); - void t38 (); - void t39 (); - void t40 (); - void t41 (); - void t42 (); - void t43 (); - void t44 (); - void t45 (); - void t46 (); - void t47 (); -}; - -#endif /* INCLUDED_QA_ENCODER_CONVOLUTIONAL_IC1_IC1_H */ diff --git a/gr-error-correcting-codes/src/lib/libecc/tests/test_all.cc b/gr-error-correcting-codes/src/lib/libecc/tests/test_all.cc deleted file mode 100644 index 7650fe0dd..000000000 --- a/gr-error-correcting-codes/src/lib/libecc/tests/test_all.cc +++ /dev/null @@ -1,38 +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 2, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <cppunit/TextTestRunner.h> -#include <qa_ecc.h> - -int -main -(int argc, - char **argv) -{ - CppUnit::TextTestRunner runner; - - runner.addTest (qa_ecc::suite ()); - - bool was_successful = runner.run ("", false); - - return ((was_successful == true) ? 0 : 1); -} diff --git a/gr-error-correcting-codes/src/python/Makefile.am b/gr-error-correcting-codes/src/python/Makefile.am deleted file mode 100644 index e03d9eb40..000000000 --- a/gr-error-correcting-codes/src/python/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# -# 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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -EXTRA_DIST = run_tests.in - -TESTS = run_tests - -noinst_PYTHON = qa_ecc.py - -#grpython_PYTHON = - -MOSTLYCLEANFILES = *.pyc *~ run_tests diff --git a/gr-error-correcting-codes/src/python/qa_ecc.py b/gr-error-correcting-codes/src/python/qa_ecc.py deleted file mode 100755 index 350f1d829..000000000 --- a/gr-error-correcting-codes/src/python/qa_ecc.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# -# 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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import ecc - -class qa_ecc (gr_unittest.TestCase): - - def setUp (self): - self.fg = gr.flow_graph () - - def tearDown (self): - self.fg = None - - def test_000_nop (self): - """Just see if we can import the module... - They may not have drivers, etc. Don't try to run anything""" - pass - -if __name__ == '__main__': - gr_unittest.main () diff --git a/gr-error-correcting-codes/src/python/run_tests.in b/gr-error-correcting-codes/src/python/run_tests.in deleted file mode 100644 index 8598810f4..000000000 --- a/gr-error-correcting-codes/src/python/run_tests.in +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# 1st parameter is absolute path to component source directory -# 2nd parameter is absolute path to component build directory -# 3rd parameter is path to Python QA directory - -@top_builddir@/run_tests.sh \ - @abs_top_srcdir@/gr-error-correcting-codes \ - @abs_top_builddir@/gr-error-correcting-codes \ - @srcdir@ |