summaryrefslogtreecommitdiff
path: root/gr-trellis
diff options
context:
space:
mode:
Diffstat (limited to 'gr-trellis')
-rw-r--r--gr-trellis/CMakeLists.txt117
-rw-r--r--gr-trellis/doc/CMakeLists.txt73
-rw-r--r--gr-trellis/grc/CMakeLists.txt36
-rw-r--r--gr-trellis/src/examples/CMakeLists.txt64
-rw-r--r--gr-trellis/src/lib/CMakeLists.txt236
-rw-r--r--gr-trellis/src/lib/Makefile.am13
-rw-r--r--gr-trellis/src/lib/Makefile.swig.gen2
-rw-r--r--gr-trellis/src/lib/calc_metric.h2
-rw-r--r--gr-trellis/src/lib/core_algorithms.h2
-rw-r--r--gr-trellis/src/lib/fsm.cc4
-rw-r--r--gr-trellis/src/lib/fsm.h105
-rw-r--r--gr-trellis/src/lib/interleaver.h3
-rw-r--r--gr-trellis/src/lib/trellis.i12
-rw-r--r--gr-trellis/src/lib/trellis_api.h (renamed from gr-trellis/src/lib/metric_type.h)16
-rw-r--r--gr-trellis/src/lib/trellis_constellation_metrics_cf.cc90
-rw-r--r--gr-trellis/src/lib/trellis_constellation_metrics_cf.h62
-rw-r--r--gr-trellis/src/lib/trellis_constellation_metrics_cf.i33
-rw-r--r--gr-trellis/src/lib/trellis_encoder_XX.h.t7
-rw-r--r--gr-trellis/src/lib/trellis_metrics_X.h.t7
-rw-r--r--gr-trellis/src/lib/trellis_pccc_decoder_X.h.t7
-rw-r--r--gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t7
-rw-r--r--gr-trellis/src/lib/trellis_pccc_encoder_XX.h.t7
-rw-r--r--gr-trellis/src/lib/trellis_permutation.h7
-rw-r--r--gr-trellis/src/lib/trellis_sccc_decoder_X.h.t7
-rw-r--r--gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t7
-rw-r--r--gr-trellis/src/lib/trellis_sccc_encoder_XX.h.t7
-rw-r--r--gr-trellis/src/lib/trellis_siso_combined_f.h7
-rw-r--r--gr-trellis/src/lib/trellis_siso_f.h7
-rw-r--r--gr-trellis/src/lib/trellis_viterbi_X.h.t7
-rw-r--r--gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t7
-rw-r--r--gr-trellis/src/python/CMakeLists.txt37
-rwxr-xr-xgr-trellis/src/python/qa_trellis.py122
-rw-r--r--gr-trellis/src/python/run_tests.in2
33 files changed, 1036 insertions, 86 deletions
diff --git a/gr-trellis/CMakeLists.txt b/gr-trellis/CMakeLists.txt
new file mode 100644
index 000000000..dc077571c
--- /dev/null
+++ b/gr-trellis/CMakeLists.txt
@@ -0,0 +1,117 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+########################################################################
+# Setup dependencies
+########################################################################
+include(GrBoost)
+
+########################################################################
+# Register component
+########################################################################
+include(GrComponent)
+GR_REGISTER_COMPONENT("gr-trellis" ENABLE_GR_TRELLIS
+ Boost_FOUND
+ ENABLE_GR_CORE
+ ENABLE_GR_DIGITAL
+)
+
+GR_SET_GLOBAL(GR_TRELLIS_INCLUDE_DIRS
+ ${CMAKE_CURRENT_BINARY_DIR}/src/lib
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/lib
+)
+
+########################################################################
+# Begin conditional configuration
+########################################################################
+if(ENABLE_GR_TRELLIS)
+
+########################################################################
+# Setup CPack components
+########################################################################
+include(GrPackage)
+CPACK_SET(CPACK_COMPONENT_GROUP_TRELLIS_DESCRIPTION "GNU Radio Trellis Blocks")
+
+CPACK_COMPONENT("trellis_docs"
+ GROUP "Trellis"
+ DISPLAY_NAME "Documentation"
+ DESCRIPTION "Doxygen HTML and XML"
+)
+
+CPACK_COMPONENT("trellis_runtime"
+ GROUP "Trellis"
+ DISPLAY_NAME "Runtime"
+ DESCRIPTION "Dynamic link libraries"
+ DEPENDS "core_runtime"
+)
+
+CPACK_COMPONENT("trellis_devel"
+ GROUP "Trellis"
+ DISPLAY_NAME "Development"
+ DESCRIPTION "C++ headers, package config, import libraries"
+ DEPENDS "core_devel"
+)
+
+CPACK_COMPONENT("trellis_python"
+ GROUP "Trellis"
+ DISPLAY_NAME "Python"
+ DESCRIPTION "Python modules for runtime"
+ DEPENDS "core_python;trellis_runtime"
+)
+
+CPACK_COMPONENT("trellis_examples"
+ GROUP "Trellis"
+ DISPLAY_NAME "Examples"
+ DESCRIPTION "Python examples for trellis"
+ DEPENDS "trellis_python"
+)
+
+CPACK_COMPONENT("trellis_swig"
+ GROUP "Trellis"
+ DISPLAY_NAME "SWIG"
+ DESCRIPTION "SWIG development .i files"
+ DEPENDS "core_swig;trellis_python;trellis_devel"
+)
+
+########################################################################
+# Add subdirectories
+########################################################################
+add_subdirectory(src/lib)
+add_subdirectory(doc)
+if(ENABLE_PYTHON)
+ add_subdirectory(grc)
+ add_subdirectory(src/python)
+ add_subdirectory(src/examples)
+endif(ENABLE_PYTHON)
+
+########################################################################
+# Create Pkg Config File
+########################################################################
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-trellis.pc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-trellis.pc
+@ONLY)
+
+install(
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-trellis.pc
+ DESTINATION ${GR_LIBRARY_DIR}/pkgconfig
+ COMPONENT "trellis_devel"
+)
+
+endif(ENABLE_GR_TRELLIS)
diff --git a/gr-trellis/doc/CMakeLists.txt b/gr-trellis/doc/CMakeLists.txt
new file mode 100644
index 000000000..a45202861
--- /dev/null
+++ b/gr-trellis/doc/CMakeLists.txt
@@ -0,0 +1,73 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+include(GrPython)
+
+########################################################################
+# Generate HTML doc with xmlto
+########################################################################
+find_program(XMLTO_EXECUTABLE xmlto)
+
+if(XMLTO_EXECUTABLE)
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gr-trellis.html
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gr-trellis.xml
+ COMMAND ${XMLTO_EXECUTABLE} html-nochunks
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr-trellis.xml
+)
+add_custom_target(gr_trellis_html ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gr-trellis.html)
+install(
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/gr-trellis.html
+ DESTINATION ${GR_PKG_DOC_DIR}/html
+ COMPONENT "trellis_docs"
+
+)
+endif(XMLTO_EXECUTABLE)
+
+########################################################################
+# Generate xml doc
+########################################################################
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_tcm.py.xml
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test_tcm.py
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/make_numbered_listing.py
+ COMMAND ${PYTHON_EXECUTABLE}
+ ${CMAKE_CURRENT_SOURCE_DIR}/make_numbered_listing.py
+ ${CMAKE_CURRENT_SOURCE_DIR}/test_tcm.py
+)
+
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_viterbi_equalization1.py.xml
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test_viterbi_equalization1.py
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/make_numbered_listing.py
+ COMMAND ${PYTHON_EXECUTABLE}
+ ${CMAKE_CURRENT_SOURCE_DIR}/make_numbered_listing.py
+ ${CMAKE_CURRENT_SOURCE_DIR}/test_viterbi_equalization1.py
+)
+
+add_custom_target(gr_trellis_xml ALL DEPENDS
+ ${CMAKE_CURRENT_BINARY_DIR}/test_tcm.py.xml
+ ${CMAKE_CURRENT_BINARY_DIR}/test_viterbi_equalization1.py.xml
+)
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/test_tcm.py.xml
+ ${CMAKE_CURRENT_BINARY_DIR}/test_viterbi_equalization1.py.xml
+ DESTINATION ${GR_PKG_DOC_DIR}/xml
+ COMPONENT "trellis_docs"
+)
diff --git a/gr-trellis/grc/CMakeLists.txt b/gr-trellis/grc/CMakeLists.txt
new file mode 100644
index 000000000..d60d64872
--- /dev/null
+++ b/gr-trellis/grc/CMakeLists.txt
@@ -0,0 +1,36 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+install(FILES
+ trellis_encoder_xx.xml
+ trellis_siso_combined_f.xml
+ trellis_viterbi_x.xml
+ trellis_metrics_x.xml
+ trellis_siso_f.xml
+ trellis_permutation.xml
+ trellis_viterbi_combined_xx.xml
+ trellis_sccc_encoder_xx.xml
+ trellis_sccc_decoder_x.xml
+ trellis_sccc_decoder_combined_xx.xml
+ trellis_pccc_encoder_xx.xml
+ trellis_pccc_decoder_x.xml
+ trellis_pccc_decoder_combined_xx.xml
+ DESTINATION ${GRC_BLOCKS_DIR}
+ COMPONENT "trellis_python"
+)
diff --git a/gr-trellis/src/examples/CMakeLists.txt b/gr-trellis/src/examples/CMakeLists.txt
new file mode 100644
index 000000000..0d9589908
--- /dev/null
+++ b/gr-trellis/src/examples/CMakeLists.txt
@@ -0,0 +1,64 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+include(GrPython)
+
+GR_PYTHON_INSTALL(
+ PROGRAMS
+ fsm_utils.py
+ test_tcm.py
+ test_tcm_parallel.py
+ test_tcm_combined.py
+ test_sccc_hard.py
+ test_sccc_soft.py
+ test_sccc_turbo.py
+ test_viterbi_equalization1.py
+ test_viterbi_equalization.py
+ test_turbo_equalization.py
+ test_turbo_equalization1.py
+ test_turbo_equalization2.py
+ DESTINATION ${GR_PKG_DATA_DIR}/examples/trellis
+ COMPONENT "trellis_examples"
+)
+
+install(
+ FILES README
+ DESTINATION ${GR_PKG_DATA_DIR}/examples/trellis
+ COMPONENT "trellis_examples"
+)
+
+install(
+ FILES
+ fsm_files/awgn1o2_128.fsm
+ fsm_files/awgn1o2_16.fsm
+ fsm_files/awgn1o2_4.fsm
+ fsm_files/awgn1o2_8.fsm
+ fsm_files/awgn2o3_16.fsm
+ fsm_files/awgn2o3_4.fsm
+ fsm_files/awgn2o3_4_msb.fsm
+ fsm_files/awgn2o3_4_msbG.fsm
+ fsm_files/awgn2o3_8.fsm
+ fsm_files/awgn2o4_4.fsm
+ fsm_files/disconnected.fsm
+ fsm_files/rep3.fsm
+ fsm_files/rep5.fsm
+ fsm_files/simple.fsm
+ DESTINATION ${GR_PKG_DATA_DIR}/examples/trellis/fsm_files
+ COMPONENT "trellis_examples"
+)
diff --git a/gr-trellis/src/lib/CMakeLists.txt b/gr-trellis/src/lib/CMakeLists.txt
new file mode 100644
index 000000000..673032638
--- /dev/null
+++ b/gr-trellis/src/lib/CMakeLists.txt
@@ -0,0 +1,236 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+########################################################################
+# Setup the include and linker paths
+########################################################################
+include_directories(
+ ${GNURADIO_CORE_INCLUDE_DIRS}
+ ${GR_TRELLIS_INCLUDE_DIRS}
+ ${GR_DIGITAL_INCLUDE_DIRS}
+)
+
+include_directories(${Boost_INCLUDE_DIRS})
+link_directories(${Boost_LIBRARY_DIRS})
+
+########################################################################
+# generate the python helper script which calls into the build utils
+########################################################################
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py "
+#!${PYTHON_EXECUTABLE}
+
+import sys, os, re
+sys.path.append('${GR_CORE_PYTHONPATH}')
+sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}')
+os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}'
+os.chdir('${CMAKE_CURRENT_BINARY_DIR}')
+
+if __name__ == '__main__':
+ import build_utils, generate_trellis
+ root, inp = sys.argv[1:3]
+ for sig in sys.argv[3:]:
+ name = re.sub ('X+', sig, root)
+ d = generate_trellis.standard_dict(name, sig)
+ build_utils.expand_template(d, inp)
+
+")
+
+########################################################################
+# generation helper macro to generate various files from template
+########################################################################
+macro(expand_h_cc_i root)
+
+ foreach(ext h cc i)
+ #make a list of all the generated files
+ unset(expanded_files_${ext})
+ foreach(sig ${ARGN})
+ string(REGEX REPLACE "X+" ${sig} name ${root})
+ list(APPEND expanded_files_${ext} ${CMAKE_CURRENT_BINARY_DIR}/${name}.${ext})
+ endforeach(sig)
+
+ #create a command to generate the files
+ add_custom_command(
+ OUTPUT ${expanded_files_${ext}}
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.${ext}.t
+ COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
+ ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
+ ${root} ${root}.${ext}.t ${ARGN}
+ )
+ endforeach(ext)
+
+ #make source files depends on headers to force generation
+ set_source_files_properties(${expanded_files_cc}
+ PROPERTIES OBJECT_DEPENDS "${expanded_files_h}"
+ )
+
+ #install rules for the generated cc, h, and i files
+ list(APPEND generated_trellis_sources ${expanded_files_cc})
+ list(APPEND generated_trellis_includes ${expanded_files_h})
+ list(APPEND generated_trellis_swigs ${expanded_files_i})
+
+endmacro(expand_h_cc_i)
+
+########################################################################
+# Invoke macro to generate various sources
+########################################################################
+expand_h_cc_i(trellis_encoder_XX bb bs bi ss si ii)
+expand_h_cc_i(trellis_sccc_encoder_XX bb bs bi ss si ii)
+expand_h_cc_i(trellis_pccc_encoder_XX bb bs bi ss si ii)
+expand_h_cc_i(trellis_metrics_X s i f c)
+expand_h_cc_i(trellis_viterbi_X b s i)
+expand_h_cc_i(trellis_viterbi_combined_XX sb ss si ib is ii fb fs fi cb cs ci)
+expand_h_cc_i(trellis_sccc_decoder_X b s i)
+expand_h_cc_i(trellis_sccc_decoder_combined_XX fb fs fi cb cs ci)
+expand_h_cc_i(trellis_pccc_decoder_X b s i)
+expand_h_cc_i(trellis_pccc_decoder_combined_XX fb fs fi cb cs ci)
+
+add_custom_target(trellis_generated DEPENDS
+ ${generated_trellis_includes}
+ ${generated_trellis_swigs}
+)
+
+########################################################################
+# Create the master trellis swig include files
+########################################################################
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/trellis_generated.py "
+import os, sys
+if __name__ == '__main__':
+ incs = sys.argv[2:]
+ h_incs = '\\n'.join(['#include<%s.h>'%(os.path.splitext(os.path.basename(inc))[0]) for inc in incs])
+ i_incs = '\\n'.join(['%%include<%s>'%(os.path.basename(inc)) for inc in incs])
+ open(sys.argv[1], 'w').write('''
+//
+// This file is machine generated. All edits will be overwritten
+//
+
+%%{
+%s
+%%}
+
+%s
+
+'''%(h_incs, i_incs))
+")
+
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/trellis_generated.i
+ DEPENDS ${generated_trellis_swigs}
+ COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
+ ${CMAKE_CURRENT_BINARY_DIR}/trellis_generated.py
+ ${CMAKE_CURRENT_BINARY_DIR}/trellis_generated.i
+ ${generated_trellis_swigs}
+)
+
+########################################################################
+# Setup library
+########################################################################
+list(APPEND gr_trellis_sources
+ fsm.cc
+ quicksort_index.cc
+ base.cc
+ interleaver.cc
+ calc_metric.cc
+ core_algorithms.cc
+ trellis_permutation.cc
+ trellis_siso_f.cc
+ trellis_siso_combined_f.cc
+ trellis_constellation_metrics_cf.cc
+ ${generated_trellis_sources}
+)
+
+list(APPEND trellis_libs
+ gnuradio-core
+ ${Boost_LIBRARIES}
+)
+
+add_library(gnuradio-trellis SHARED ${gr_trellis_sources})
+target_link_libraries(gnuradio-trellis ${trellis_libs})
+set_target_properties(gnuradio-trellis PROPERTIES DEFINE_SYMBOL "gnuradio_trellis_EXPORTS")
+set_target_properties(gnuradio-trellis PROPERTIES SOVERSION ${LIBVER})
+
+install(TARGETS gnuradio-trellis
+ LIBRARY DESTINATION ${GR_LIBRARY_DIR} COMPONENT "trellis_runtime" # .so/.dylib file
+ ARCHIVE DESTINATION ${GR_LIBRARY_DIR} COMPONENT "trellis_devel" # .lib file
+ RUNTIME DESTINATION ${GR_RUNTIME_DIR} COMPONENT "trellis_runtime" # .dll file
+)
+
+########################################################################
+# Handle the generated sources + a few non-generated ones
+########################################################################
+install(FILES
+ ${generated_trellis_includes}
+ trellis_api.h
+ fsm.h
+ quicksort_index.h
+ base.h
+ interleaver.h
+ calc_metric.h
+ core_algorithms.h
+ trellis_permutation.h
+ siso_type.h
+ trellis_siso_f.h
+ trellis_siso_combined_f.h
+ trellis_constellation_metrics_cf.h
+ DESTINATION ${GR_INCLUDE_DIR}/gnuradio
+ COMPONENT "trellis_devel"
+)
+
+if(ENABLE_PYTHON)
+ install(FILES
+ ${generated_trellis_swigs}
+ fsm.i
+ interleaver.i
+ trellis_permutation.i
+ trellis_siso_f.i
+ trellis_siso_combined_f.i
+ trellis_constellation_metrics_cf.i
+ ${CMAKE_CURRENT_BINARY_DIR}/trellis_generated.i
+ DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig
+ COMPONENT "trellis_swig"
+ )
+
+########################################################################
+# Setup swig generation
+########################################################################
+include(GrPython)
+include(GrSwig)
+
+set(GR_SWIG_SOURCE_DEPS ${CMAKE_CURRENT_BINARY_DIR}/trellis_generated.i)
+set(GR_SWIG_TARGET_DEPS trellis_generated trellis_generated_index)
+set(GR_SWIG_INCLUDE_DIRS
+ ${GR_TRELLIS_INCLUDE_DIRS}
+ ${GNURADIO_CORE_SWIG_INCLUDE_DIRS}
+ ${GR_DIGITAL_SWIG_INCLUDE_DIRS}
+)
+set(GR_SWIG_LIBRARIES gnuradio-trellis)
+GR_SWIG_MAKE(trellis trellis.i)
+
+GR_SWIG_INSTALL(
+ TARGETS trellis
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio
+ COMPONENT "trellis_python"
+)
+
+install(
+ FILES trellis.i
+ DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig
+ COMPONENT "trellis_swig"
+)
+
+endif(ENABLE_PYTHON)
diff --git a/gr-trellis/src/lib/Makefile.am b/gr-trellis/src/lib/Makefile.am
index 8f703c92a..435a093d6 100644
--- a/gr-trellis/src/lib/Makefile.am
+++ b/gr-trellis/src/lib/Makefile.am
@@ -29,7 +29,9 @@ EXTRA_DIST += \
trellis.test
-AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES)
+AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \
+ $(GR_DIGITAL_INCLUDES) \
+ $(WITH_INCLUDES)
# ----------------------------------------------------------------
# these scripts generate trellis codes from template files
@@ -80,17 +82,18 @@ EXTRA_DIST += \
# These headers get installed in ${prefix}/include/gnuradio
grinclude_HEADERS = \
+ trellis_api.h \
fsm.h \
quicksort_index.h \
base.h \
interleaver.h \
- metric_type.h \
calc_metric.h \
core_algorithms.h \
trellis_permutation.h \
siso_type.h \
trellis_siso_f.h \
trellis_siso_combined_f.h \
+ trellis_constellation_metrics_cf.h \
$(GENERATED_H)
lib_LTLIBRARIES = libgnuradio-trellis.la
@@ -105,6 +108,7 @@ libgnuradio_trellis_la_SOURCES = \
trellis_permutation.cc \
trellis_siso_f.cc \
trellis_siso_combined_f.cc \
+ trellis_constellation_metrics_cf.cc \
$(GENERATED_CC)
libgnuradio_trellis_la_LIBADD = \
@@ -139,6 +143,7 @@ trellis_swiginclude_headers = \
trellis_permutation.i \
trellis_siso_f.i \
trellis_siso_combined_f.i \
+ trellis_constellation_metrics_cf.i \
trellis_generated.i
# Do creation and inclusion of other Makefiles last
@@ -160,6 +165,10 @@ include $(top_srcdir)/Makefile.par.gen
BUILT_SOURCES += $(python_built_sources)
+# Location of non-standard SWIG interface files
+trellis_swig_args = \
+ $(GR_DIGITAL_INCLUDES)
+
if GUILE
TESTS += run_guile_tests
endif
diff --git a/gr-trellis/src/lib/Makefile.swig.gen b/gr-trellis/src/lib/Makefile.swig.gen
index 784c146cf..2d014b946 100644
--- a/gr-trellis/src/lib/Makefile.swig.gen
+++ b/gr-trellis/src/lib/Makefile.swig.gen
@@ -105,7 +105,7 @@ _trellis_la_CXXFLAGS = \
$(trellis_la_swig_cxxflags)
python/trellis.cc: trellis.py
-trellis.py: trellis.i
+trellis.py: trellis.i
# Include the python dependencies for this file
-include python/trellis.d
diff --git a/gr-trellis/src/lib/calc_metric.h b/gr-trellis/src/lib/calc_metric.h
index d628f44e0..fd20f8d36 100644
--- a/gr-trellis/src/lib/calc_metric.h
+++ b/gr-trellis/src/lib/calc_metric.h
@@ -25,7 +25,7 @@
#include <vector>
#include <gr_complex.h>
-#include <metric_type.h>
+#include <digital_metric_type.h>
template <class T>
diff --git a/gr-trellis/src/lib/core_algorithms.h b/gr-trellis/src/lib/core_algorithms.h
index 0ce4f3f4e..cab7086ba 100644
--- a/gr-trellis/src/lib/core_algorithms.h
+++ b/gr-trellis/src/lib/core_algorithms.h
@@ -26,7 +26,7 @@
#include <cmath>
#include <vector>
//#include <gr_complex.h>
-#include "metric_type.h"
+#include "digital_metric_type.h"
#include "fsm.h"
#include "interleaver.h"
diff --git a/gr-trellis/src/lib/fsm.cc b/gr-trellis/src/lib/fsm.cc
index 5950b56b9..71e54b05a 100644
--- a/gr-trellis/src/lib/fsm.cc
+++ b/gr-trellis/src/lib/fsm.cc
@@ -132,7 +132,7 @@ fsm::fsm(int k, int n, const std::vector<int> &G)
for(int j=0;j<n;j++) {
int mem = -1;
if(G[i*n+j]!=0)
- mem=(int)(log(G[i*n+j])/log(2.0));
+ mem=(int)(log(double(G[i*n+j]))/log(2.0));
if(mem>max_mem_x[i])
max_mem_x[i]=mem;
if(mem>max_mem)
@@ -417,7 +417,7 @@ void fsm::generate_TM()
done = find_es(s);
attempts ++;
}
- if (done == false) {
+ if (done == false && d_S > 1) {
//throw std::runtime_error ("fsm::generate_TM(): FSM appears to be disconnected\n");
printf("fsm::generate_TM(): FSM appears to be disconnected\n");
printf("state %d cannot be reached from all other states\n",s);
diff --git a/gr-trellis/src/lib/fsm.h b/gr-trellis/src/lib/fsm.h
index 0a90b2cd3..7dc7e0d9d 100644
--- a/gr-trellis/src/lib/fsm.h
+++ b/gr-trellis/src/lib/fsm.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2002 Free Software Foundation, Inc.
+ * Copyright 2002,2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -23,35 +23,119 @@
#ifndef INCLUDED_TRELLIS_FSM_H
#define INCLUDED_TRELLIS_FSM_H
+#include <trellis_api.h>
#include <vector>
#include <iosfwd>
/*!
- * \brief FSM class
+ * \brief Finite State Machine Specification class.
+ *
+ * An instance of this class represents a finite state machine specification (FSMS)
+ * rather than the FSM itself. It particular the state of the FSM
+ * is not stored within an instance of this class.
*/
-class fsm {
+class TRELLIS_API fsm {
private:
+ // Input alphabet cardinality.
int d_I;
+ // Number of states.
int d_S;
+ // Output alphabet cardinality.
int d_O;
+ // NS means Next State.
+ // next_state = d_NS[current_state * d_I + input_symbol]
std::vector<int> d_NS;
+ // OS means Output Symbol.
+ // output_symbol = d_OS[current_state * d_I + input_symbol]
std::vector<int> d_OS;
+ // PS means Previous State.
std::vector< std::vector<int> > d_PS;
+ // PI means Previous Input Symbol.
+ // d_PS[current_state][k] and d_PI[current_state][k], is a pair of the form
+ // (previous_state, previous_input_symbol) that could have produced the
+ // current state.
std::vector< std::vector<int> > d_PI;
- std::vector<int> d_TMi;
+ // TM means Termination matrix.
+ // d_TMl[s*d_S+es] is the shortest number of steps to get from state s to
+ // state es.
std::vector<int> d_TMl;
+ // d_TMi[s*d_S+es] is the input symbol required to set off on the shortest
+ // path from state s to es.
+ std::vector<int> d_TMi;
void generate_PS_PI ();
void generate_TM ();
bool find_es(int es);
public:
+ /*!
+ * \brief Constructor to create an uninitialized FSMS.
+ */
fsm();
+ /*!
+ * \brief Constructor to copy an FSMS.
+ */
fsm(const fsm &FSM);
+ /*!
+ * \brief Constructor to to create an FSMS.
+ *
+ * \param I The number of possible input symbols.
+ * \param S The number of possible FSM states.
+ * \param O The number of possible output symbols.
+ * \param NS A mapping from (current state, input symbol) to next state.
+ * next_state = NS[current_state * I + input_symbol]
+ * \param OS A mapping from (current state, input symbol) to output symbol.
+ * output_symbol = OS[current_state * I + input_symbol]
+ *
+ */
fsm(int I, int S, int O, const std::vector<int> &NS, const std::vector<int> &OS);
+ /*!
+ * \brief Constructor to create an FSMS from file contents.
+ *
+ * \param name filename
+ *
+ */
fsm(const char *name);
+ /*!
+ * \brief Creates an FSMS from the generator matrix of a (n, k) binary convolutional code.
+ *
+ * \param k ???
+ * \param n ???
+ * \param G ???
+ *
+ */
fsm(int k, int n, const std::vector<int> &G);
+ /*!
+ * \brief Creates an FSMS describing ISI.
+ *
+ * \param mod_size modulation size
+ * \param ch_length channel length
+ *
+ */
fsm(int mod_size, int ch_length);
+ /*!
+ * \brief Creates an FSMS describing the trellis for a CPM.
+ *
+ * \param P ???? h=K/P (relatively prime)
+ * \param M alphabet size
+ * \param L pulse duration
+ *
+ * This FSM is based on the paper by B. Rimoldi
+ * "A decomposition approach to CPM", IEEE Trans. Info Theory, March 1988
+ * See also my own notes at http://www.eecs.umich.edu/~anastas/docs/cpm.pdf
+ */
fsm(int P, int M, int L);
+ /*!
+ * \brief Creates an FSMS describing the joint trellis of two FSMs.
+ *
+ * \param FSM1 first FSMS
+ * \param FSM2 second FSMS
+ */
fsm(const fsm &FSM1, const fsm &FSM2);
+ /*!
+ * \brief Creates an FSMS representing n stages through the originial FSM (AKA radix-n FSM).
+ *
+ * \param FSM Original FSMs
+ * \param n Number of stages.
+ */
fsm(const fsm &FSM, int n);
int I () const { return d_I; }
int S () const { return d_S; }
@@ -62,7 +146,20 @@ public:
const std::vector< std::vector<int> > & PI () const { return d_PI; }
const std::vector<int> & TMi () const { return d_TMi; }
const std::vector<int> & TMl () const { return d_TMl; }
+ /*!
+ * \brief Creates an svg image of the trellis representation.
+ *
+ * \param filename filename
+ * \param number_stages ????
+ *
+ */
void write_trellis_svg(std::string filename ,int number_stages);
+ /*!
+ * \brief Write the FSMS to a file.
+ *
+ * \param filename filename
+ *
+ */
void write_fsm_txt(std::string filename);
};
diff --git a/gr-trellis/src/lib/interleaver.h b/gr-trellis/src/lib/interleaver.h
index f6a289c52..fbd378d62 100644
--- a/gr-trellis/src/lib/interleaver.h
+++ b/gr-trellis/src/lib/interleaver.h
@@ -23,12 +23,13 @@
#ifndef INCLUDED_TRELLIS_INTERLEAVER_H
#define INCLUDED_TRELLIS_INTERLEAVER_H
+#include <trellis_api.h>
#include <vector>
/*!
* \brief INTERLEAVER class
*/
-class interleaver {
+class TRELLIS_API interleaver {
private:
int d_K;
std::vector<int> d_INTER;
diff --git a/gr-trellis/src/lib/trellis.i b/gr-trellis/src/lib/trellis.i
index 8d1118436..d01ab529a 100644
--- a/gr-trellis/src/lib/trellis.i
+++ b/gr-trellis/src/lib/trellis.i
@@ -28,8 +28,11 @@
#include "trellis_permutation.h"
#include "trellis_siso_f.h"
#include "trellis_siso_combined_f.h"
+#include "trellis_constellation_metrics_cf.h"
+#include "digital_constellation.h"
%}
+
// ----------------------------------------------------------------
%include "fsm.i"
@@ -38,12 +41,19 @@
%include "trellis_siso_f.i"
%include "trellis_siso_combined_f.i"
-%include "metric_type.h"
%include "siso_type.h"
+%include "trellis_constellation_metrics_cf.i"
%include "trellis_generated.i"
+%import "digital_metric_type.h"
+%import "digital_constellation.i"
+
+ //%pythoncode %{
+ // from gnuradio.gr import TRELLIS_EUCLIDEAN, TRELLIS_HARD_SYMBOL, TRELLIS_HARD_BIT
+ // %}
+
#if SWIGGUILE
%scheme %{
(load-extension-global "libguile-gnuradio-trellis" "scm_init_gnuradio_trellis_module")
diff --git a/gr-trellis/src/lib/metric_type.h b/gr-trellis/src/lib/trellis_api.h
index a1040f108..c09b340d6 100644
--- a/gr-trellis/src/lib/metric_type.h
+++ b/gr-trellis/src/lib/trellis_api.h
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,12 +19,15 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef INCLUDED_TRELLIS_METRIC_TYPE_H
-#define INCLUDED_TRELLIS_METRIC_TYPE_H
+#ifndef INCLUDED_TRELLIS_API_H
+#define INCLUDED_TRELLIS_API_H
-typedef enum {
- TRELLIS_EUCLIDEAN = 200, TRELLIS_HARD_SYMBOL, TRELLIS_HARD_BIT
-} trellis_metric_type_t;
+#include <gruel/attributes.h>
+#ifdef gnuradio_trellis_EXPORTS
+# define TRELLIS_API __GR_ATTR_EXPORT
+#else
+# define TRELLIS_API __GR_ATTR_IMPORT
#endif
+#endif /* INCLUDED_TRELLIS_API_H */
diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc b/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc
new file mode 100644
index 000000000..91520e4ce
--- /dev/null
+++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc
@@ -0,0 +1,90 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2011 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <trellis_constellation_metrics_cf.h>
+#include <gr_io_signature.h>
+#include <assert.h>
+#include <stdexcept>
+#include <iostream>
+
+
+
+trellis_constellation_metrics_cf_sptr
+trellis_make_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE)
+{
+ return gnuradio::get_initial_sptr (new trellis_constellation_metrics_cf (constellation, TYPE));
+}
+
+
+
+trellis_constellation_metrics_cf::trellis_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE)
+ : gr_block ("constellation_metrics_cf",
+ gr_make_io_signature (1, -1, sizeof (gr_complex)),
+ gr_make_io_signature (1, -1, sizeof (float))),
+ d_constellation (constellation),
+ d_TYPE (TYPE),
+ d_O (constellation->arity()),
+ d_D (constellation->dimensionality())
+{
+ set_relative_rate (1.0 * d_O / ((double) d_D));
+ set_output_multiple ((int)d_O);
+}
+
+void
+trellis_constellation_metrics_cf::forecast (int noutput_items, gr_vector_int &ninput_items_required)
+{
+ assert (noutput_items % d_O == 0);
+ unsigned int input_required = d_D * noutput_items / d_O;
+ unsigned int ninputs = ninput_items_required.size();
+ for (unsigned int i = 0; i < ninputs; i++)
+ ninput_items_required[i] = input_required;
+}
+
+
+
+int
+trellis_constellation_metrics_cf::general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+
+ assert (noutput_items % d_O == 0);
+ assert (input_items.size() == output_items.size());
+ unsigned int nstreams = input_items.size();
+
+for (unsigned int m=0;m<nstreams;m++) {
+ const gr_complex *in = (gr_complex *) input_items[m];
+ float *out = (float *) output_items[m];
+
+ for (unsigned int i = 0; i < noutput_items / d_O ; i++){
+ d_constellation->calc_metric(&(in[i*d_D]), &(out[i*d_O]), d_TYPE);
+ }
+}
+
+ consume_each (d_D * noutput_items / d_O);
+ return noutput_items;
+}
diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h
new file mode 100644
index 000000000..1851bb89c
--- /dev/null
+++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h
@@ -0,0 +1,62 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2011 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_TRELLIS_CONSTELLATION_METRICS_CF_H
+#define INCLUDED_TRELLIS_CONSTELLATION_METRICS_CF_H
+
+#include <trellis_api.h>
+#include <gr_block.h>
+#include <digital_constellation.h>
+#include <digital_metric_type.h>
+
+class trellis_constellation_metrics_cf;
+typedef boost::shared_ptr<trellis_constellation_metrics_cf> trellis_constellation_metrics_cf_sptr;
+
+TRELLIS_API trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE);
+
+/*!
+ * \brief Evaluate metrics for use by the Viterbi algorithm.
+ * \ingroup coding_blk
+ */
+class TRELLIS_API trellis_constellation_metrics_cf : public gr_block
+{
+ public:
+ void forecast (int noutput_items,
+ gr_vector_int &ninput_items_required);
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ protected:
+ trellis_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE);
+
+ private:
+ digital_constellation_sptr d_constellation;
+ trellis_metric_type_t d_TYPE;
+ unsigned int d_O;
+ unsigned int d_D;
+ friend TRELLIS_API trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE);
+
+};
+
+
+#endif
diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.i b/gr-trellis/src/lib/trellis_constellation_metrics_cf.i
new file mode 100644
index 000000000..c17522b11
--- /dev/null
+++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.i
@@ -0,0 +1,33 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2011 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// WARNING: this file is machine generated. Edits will be over written
+
+GR_SWIG_BLOCK_MAGIC(trellis,constellation_metrics_cf);
+
+trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE);
+
+class trellis_constellation_metrics_cf : public gr_block
+{
+private:
+ trellis_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE);
+};
diff --git a/gr-trellis/src/lib/trellis_encoder_XX.h.t b/gr-trellis/src/lib/trellis_encoder_XX.h.t
index b56fde0bf..4038caac9 100644
--- a/gr-trellis/src/lib/trellis_encoder_XX.h.t
+++ b/gr-trellis/src/lib/trellis_encoder_XX.h.t
@@ -25,22 +25,23 @@
#ifndef @GUARD_NAME@
#define @GUARD_NAME@
+#include <trellis_api.h>
#include "fsm.h"
#include <gr_sync_block.h>
class @NAME@;
typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
-@SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, int ST);
+TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, int ST);
/*!
* \brief Convolutional encoder.
* \ingroup coding_blk
*/
-class @NAME@ : public gr_sync_block
+class TRELLIS_API @NAME@ : public gr_sync_block
{
private:
- friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, int ST);
+ friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, int ST);
fsm d_FSM;
int d_ST;
@NAME@ (const fsm &FSM, int ST);
diff --git a/gr-trellis/src/lib/trellis_metrics_X.h.t b/gr-trellis/src/lib/trellis_metrics_X.h.t
index 45d4ace10..809c27e65 100644
--- a/gr-trellis/src/lib/trellis_metrics_X.h.t
+++ b/gr-trellis/src/lib/trellis_metrics_X.h.t
@@ -25,26 +25,27 @@
#ifndef @GUARD_NAME@
#define @GUARD_NAME@
+#include <trellis_api.h>
#include <gr_block.h>
#include "calc_metric.h"
class @NAME@;
typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
-@SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE);
+TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE);
/*!
* \brief Evaluate metrics for use by the Viterbi algorithm.
* \ingroup coding_blk
*/
-class @NAME@ : public gr_block
+class TRELLIS_API @NAME@ : public gr_block
{
int d_O;
int d_D;
trellis_metric_type_t d_TYPE;
std::vector<@I_TYPE@> d_TABLE;
- friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE);
+ friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE);
@NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE);
public:
diff --git a/gr-trellis/src/lib/trellis_pccc_decoder_X.h.t b/gr-trellis/src/lib/trellis_pccc_decoder_X.h.t
index 2a5b43df6..a58a03264 100644
--- a/gr-trellis/src/lib/trellis_pccc_decoder_X.h.t
+++ b/gr-trellis/src/lib/trellis_pccc_decoder_X.h.t
@@ -25,6 +25,7 @@
#ifndef @GUARD_NAME@
#define @GUARD_NAME@
+#include <trellis_api.h>
#include "fsm.h"
#include "interleaver.h"
#include <gr_block.h>
@@ -34,7 +35,7 @@
class @NAME@;
typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
-@SPTR_NAME@ trellis_make_@BASE_NAME@ (
+TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSM1, int ST10, int ST1K,
const fsm &FSM2, int ST20, int ST2K,
const interleaver &INTERLEAVER,
@@ -47,7 +48,7 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
/*!
* \ingroup coding_blk
*/
-class @NAME@ : public gr_block
+class TRELLIS_API @NAME@ : public gr_block
{
fsm d_FSM1;
int d_ST10;
@@ -61,7 +62,7 @@ class @NAME@ : public gr_block
trellis_siso_type_t d_SISO_TYPE;
std::vector<float> d_buffer;
- friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (
+ friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSM1, int ST10, int ST1K,
const fsm &FSM2, int ST20, int ST2K,
const interleaver &INTERLEAVER,
diff --git a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t b/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t
index dd9979af9..6d177cca2 100644
--- a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t
+++ b/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t
@@ -25,6 +25,7 @@
#ifndef @GUARD_NAME@
#define @GUARD_NAME@
+#include <trellis_api.h>
#include "fsm.h"
#include "interleaver.h"
#include <gr_block.h>
@@ -35,7 +36,7 @@
class @NAME@;
typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
-@SPTR_NAME@ trellis_make_@BASE_NAME@ (
+TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSMo, int STo0, int SToK,
const fsm &FSMi, int STi0, int STiK,
const interleaver &INTERLEAVER,
@@ -52,7 +53,7 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
/*!
* \ingroup coding_blk
*/
-class @NAME@ : public gr_block
+class TRELLIS_API @NAME@ : public gr_block
{
fsm d_FSMo;
fsm d_FSMi;
@@ -70,7 +71,7 @@ class @NAME@ : public gr_block
float d_scaling;
std::vector<float> d_buffer;
- friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (
+ friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSMo, int STo0, int SToK,
const fsm &FSMi, int STi0, int STiK,
const interleaver &INTERLEAVER,
diff --git a/gr-trellis/src/lib/trellis_pccc_encoder_XX.h.t b/gr-trellis/src/lib/trellis_pccc_encoder_XX.h.t
index 68ccf75db..2b6110e37 100644
--- a/gr-trellis/src/lib/trellis_pccc_encoder_XX.h.t
+++ b/gr-trellis/src/lib/trellis_pccc_encoder_XX.h.t
@@ -25,6 +25,7 @@
#ifndef @GUARD_NAME@
#define @GUARD_NAME@
+#include <trellis_api.h>
#include <vector>
#include "fsm.h"
#include "interleaver.h"
@@ -33,7 +34,7 @@
class @NAME@;
typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
-@SPTR_NAME@ trellis_make_@BASE_NAME@ (
+TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSM1, int ST1,
const fsm &FSM2, int ST2,
const interleaver &INTERLEAVER,
@@ -44,10 +45,10 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
* \brief SCCC encoder.
* \ingroup coding_blk
*/
-class @NAME@ : public gr_sync_block
+class TRELLIS_API @NAME@ : public gr_sync_block
{
private:
- friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (
+ friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSM1, int ST1,
const fsm &FSM2, int ST2,
const interleaver &INTERLEAVER,
diff --git a/gr-trellis/src/lib/trellis_permutation.h b/gr-trellis/src/lib/trellis_permutation.h
index a5c858a8b..2786de29a 100644
--- a/gr-trellis/src/lib/trellis_permutation.h
+++ b/gr-trellis/src/lib/trellis_permutation.h
@@ -24,22 +24,23 @@
#ifndef INCLUDED_TRELLIS_PERMUTATION_H
#define INCLUDED_TRELLIS_PERMUTATION_H
+#include <trellis_api.h>
#include <vector>
#include <gr_sync_block.h>
class trellis_permutation;
typedef boost::shared_ptr<trellis_permutation> trellis_permutation_sptr;
-trellis_permutation_sptr trellis_make_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t BYTES_PER_SYMBOL);
+TRELLIS_API trellis_permutation_sptr trellis_make_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t BYTES_PER_SYMBOL);
/*!
* \brief Permutation.
* \ingroup coding_blk
*/
-class trellis_permutation : public gr_sync_block
+class TRELLIS_API trellis_permutation : public gr_sync_block
{
private:
- friend trellis_permutation_sptr trellis_make_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t BYTES_PER_SYMBOL);
+ friend TRELLIS_API trellis_permutation_sptr trellis_make_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t BYTES_PER_SYMBOL);
int d_K;
std::vector<int> d_TABLE;
int d_SYMS_PER_BLOCK;
diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t b/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t
index 93c9ac9b8..9857c6a34 100644
--- a/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t
+++ b/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t
@@ -25,6 +25,7 @@
#ifndef @GUARD_NAME@
#define @GUARD_NAME@
+#include <trellis_api.h>
#include "fsm.h"
#include "interleaver.h"
#include <gr_block.h>
@@ -34,7 +35,7 @@
class @NAME@;
typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
-@SPTR_NAME@ trellis_make_@BASE_NAME@ (
+TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSMo, int STo0, int SToK,
const fsm &FSMi, int STi0, int STiK,
const interleaver &INTERLEAVER,
@@ -47,7 +48,7 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
/*!
* \ingroup coding_blk
*/
-class @NAME@ : public gr_block
+class TRELLIS_API @NAME@ : public gr_block
{
fsm d_FSMo;
int d_STo0;
@@ -61,7 +62,7 @@ class @NAME@ : public gr_block
trellis_siso_type_t d_SISO_TYPE;
std::vector<float> d_buffer;
- friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (
+ friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSMo, int STo0, int SToK,
const fsm &FSMi, int STi0, int STiK,
const interleaver &INTERLEAVER,
diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t
index 225a07ffe..5d2c2b85c 100644
--- a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t
+++ b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t
@@ -25,6 +25,7 @@
#ifndef @GUARD_NAME@
#define @GUARD_NAME@
+#include <trellis_api.h>
#include "fsm.h"
#include "interleaver.h"
#include <gr_block.h>
@@ -35,7 +36,7 @@
class @NAME@;
typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
-@SPTR_NAME@ trellis_make_@BASE_NAME@ (
+TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSMo, int STo0, int SToK,
const fsm &FSMi, int STi0, int STiK,
const interleaver &INTERLEAVER,
@@ -52,7 +53,7 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
/*!
* \ingroup coding_blk
*/
-class @NAME@ : public gr_block
+class TRELLIS_API @NAME@ : public gr_block
{
fsm d_FSMo;
int d_STo0;
@@ -70,7 +71,7 @@ class @NAME@ : public gr_block
float d_scaling;
std::vector<float> d_buffer;
- friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (
+ friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSMo, int STo0, int SToK,
const fsm &FSMi, int STi0, int STiK,
const interleaver &INTERLEAVER,
diff --git a/gr-trellis/src/lib/trellis_sccc_encoder_XX.h.t b/gr-trellis/src/lib/trellis_sccc_encoder_XX.h.t
index a9e4dc454..0e8ff45a4 100644
--- a/gr-trellis/src/lib/trellis_sccc_encoder_XX.h.t
+++ b/gr-trellis/src/lib/trellis_sccc_encoder_XX.h.t
@@ -25,6 +25,7 @@
#ifndef @GUARD_NAME@
#define @GUARD_NAME@
+#include <trellis_api.h>
#include <vector>
#include "fsm.h"
#include "interleaver.h"
@@ -33,7 +34,7 @@
class @NAME@;
typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
-@SPTR_NAME@ trellis_make_@BASE_NAME@ (
+TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSMo, int STo,
const fsm &FSMi, int STi,
const interleaver &INTERLEAVER,
@@ -44,10 +45,10 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
* \brief SCCC encoder.
* \ingroup coding_blk
*/
-class @NAME@ : public gr_sync_block
+class TRELLIS_API @NAME@ : public gr_sync_block
{
private:
- friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (
+ friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSMo, int STo,
const fsm &FSMi, int STi,
const interleaver &INTERLEAVER,
diff --git a/gr-trellis/src/lib/trellis_siso_combined_f.h b/gr-trellis/src/lib/trellis_siso_combined_f.h
index 786e79386..2d043df62 100644
--- a/gr-trellis/src/lib/trellis_siso_combined_f.h
+++ b/gr-trellis/src/lib/trellis_siso_combined_f.h
@@ -23,6 +23,7 @@
#ifndef INCLUDED_TRELLIS_SISO_COMBINED_F_H
#define INCLUDED_TRELLIS_SISO_COMBINED_F_H
+#include <trellis_api.h>
#include "fsm.h"
#include "siso_type.h"
#include "calc_metric.h"
@@ -32,7 +33,7 @@
class trellis_siso_combined_f;
typedef boost::shared_ptr<trellis_siso_combined_f> trellis_siso_combined_f_sptr;
-trellis_siso_combined_f_sptr trellis_make_siso_combined_f (
+TRELLIS_API trellis_siso_combined_f_sptr trellis_make_siso_combined_f (
const fsm &FSM, // underlying FSM
int K, // block size in trellis steps
int S0, // initial state (put -1 if not specified)
@@ -48,7 +49,7 @@ trellis_siso_combined_f_sptr trellis_make_siso_combined_f (
/*!
* \ingroup coding_blk
*/
-class trellis_siso_combined_f : public gr_block
+class TRELLIS_API trellis_siso_combined_f : public gr_block
{
fsm d_FSM;
int d_K;
@@ -63,7 +64,7 @@ class trellis_siso_combined_f : public gr_block
//std::vector<float> d_alpha;
//std::vector<float> d_beta;
- friend trellis_siso_combined_f_sptr trellis_make_siso_combined_f (
+ friend TRELLIS_API trellis_siso_combined_f_sptr trellis_make_siso_combined_f (
const fsm &FSM,
int K,
int S0,
diff --git a/gr-trellis/src/lib/trellis_siso_f.h b/gr-trellis/src/lib/trellis_siso_f.h
index 0e2cba67a..b3d02ad05 100644
--- a/gr-trellis/src/lib/trellis_siso_f.h
+++ b/gr-trellis/src/lib/trellis_siso_f.h
@@ -23,6 +23,7 @@
#ifndef INCLUDED_TRELLIS_SISO_F_H
#define INCLUDED_TRELLIS_SISO_F_H
+#include <trellis_api.h>
#include "fsm.h"
#include "siso_type.h"
#include "core_algorithms.h"
@@ -31,7 +32,7 @@
class trellis_siso_f;
typedef boost::shared_ptr<trellis_siso_f> trellis_siso_f_sptr;
-trellis_siso_f_sptr trellis_make_siso_f (
+TRELLIS_API trellis_siso_f_sptr trellis_make_siso_f (
const fsm &FSM, // underlying FSM
int K, // block size in trellis steps
int S0, // initial state (put -1 if not specified)
@@ -45,7 +46,7 @@ trellis_siso_f_sptr trellis_make_siso_f (
/*!
* \ingroup coding_blk
*/
-class trellis_siso_f : public gr_block
+class TRELLIS_API trellis_siso_f : public gr_block
{
fsm d_FSM;
int d_K;
@@ -57,7 +58,7 @@ class trellis_siso_f : public gr_block
//std::vector<float> d_alpha;
//std::vector<float> d_beta;
- friend trellis_siso_f_sptr trellis_make_siso_f (
+ friend TRELLIS_API trellis_siso_f_sptr trellis_make_siso_f (
const fsm &FSM,
int K,
int S0,
diff --git a/gr-trellis/src/lib/trellis_viterbi_X.h.t b/gr-trellis/src/lib/trellis_viterbi_X.h.t
index 362d3f57e..c679649bb 100644
--- a/gr-trellis/src/lib/trellis_viterbi_X.h.t
+++ b/gr-trellis/src/lib/trellis_viterbi_X.h.t
@@ -25,6 +25,7 @@
#ifndef @GUARD_NAME@
#define @GUARD_NAME@
+#include <trellis_api.h>
#include "fsm.h"
#include <gr_block.h>
#include "core_algorithms.h"
@@ -32,7 +33,7 @@
class @NAME@;
typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
-@SPTR_NAME@ trellis_make_@BASE_NAME@ (
+TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSM,
int K,
int S0,
@@ -43,7 +44,7 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
/*!
* \ingroup coding_blk
*/
-class @NAME@ : public gr_block
+class TRELLIS_API @NAME@ : public gr_block
{
fsm d_FSM;
int d_K;
@@ -51,7 +52,7 @@ class @NAME@ : public gr_block
int d_SK;
//std::vector<int> d_trace;
- friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (
+ friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSM,
int K,
int S0,
diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t b/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t
index 35e6c4ce0..072f66158 100644
--- a/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t
+++ b/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t
@@ -25,6 +25,7 @@
#ifndef @GUARD_NAME@
#define @GUARD_NAME@
+#include <trellis_api.h>
#include "fsm.h"
#include <gr_block.h>
#include "calc_metric.h"
@@ -33,7 +34,7 @@
class @NAME@;
typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
-@SPTR_NAME@ trellis_make_@BASE_NAME@ (
+TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSM,
int K,
int S0,
@@ -46,7 +47,7 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
/*!
* \ingroup coding_blk
*/
-class @NAME@ : public gr_block
+class TRELLIS_API @NAME@ : public gr_block
{
fsm d_FSM;
int d_K;
@@ -57,7 +58,7 @@ class @NAME@ : public gr_block
trellis_metric_type_t d_TYPE;
//std::vector<int> d_trace;
- friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (
+ friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (
const fsm &FSM,
int K,
int S0,
diff --git a/gr-trellis/src/python/CMakeLists.txt b/gr-trellis/src/python/CMakeLists.txt
new file mode 100644
index 000000000..9a9cc6aed
--- /dev/null
+++ b/gr-trellis/src/python/CMakeLists.txt
@@ -0,0 +1,37 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+########################################################################
+# Handle the unit tests
+########################################################################
+if(ENABLE_TESTING)
+include(GrTest)
+file(GLOB py_qa_test_files "qa_*.py")
+foreach(py_qa_test_file ${py_qa_test_files})
+ get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
+ set(GR_TEST_PYTHON_DIRS
+ ${CMAKE_BINARY_DIR}/gnuradio-core/src/python
+ ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/swig
+ ${CMAKE_BINARY_DIR}/gr-digital/swig
+ ${CMAKE_BINARY_DIR}/gr-trellis/src/lib
+ )
+ set(GR_TEST_TARGET_DEPS gruel gnuradio-core gnuradio-digital gnuradio-trellis)
+ GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${py_qa_test_file})
+endforeach(py_qa_test_file)
+endif(ENABLE_TESTING)
diff --git a/gr-trellis/src/python/qa_trellis.py b/gr-trellis/src/python/qa_trellis.py
index cfeefea06..b50679f27 100755
--- a/gr-trellis/src/python/qa_trellis.py
+++ b/gr-trellis/src/python/qa_trellis.py
@@ -20,46 +20,50 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, gr_unittest
+import math
+
+
+from gnuradio import gr, gr_unittest, blks2
+# It's pretty ugly that we can't import trellis from gnuradio in this test
+# but because it runs on the non-installed python code it's all a mess.
import trellis
-class test_trellis (gr_unittest.TestCase):
+import os
+import digital_swig
- def setUp (self):
- self.tb = gr.top_block ()
+fsm_args = {"awgn1o2_4": (2, 4, 4,
+ (0, 2, 0, 2, 1, 3, 1, 3),
+ (0, 3, 3, 0, 1, 2, 2, 1),
+ ),
+ "rep2": (2, 1, 4, (0, 0), (0, 3)),
+ "nothing": (2, 1, 2, (0, 0), (0, 1)),
+ }
- def tearDown (self):
- self.tb = None
+constells = {2: digital_swig.constellation_bpsk(),
+ 4: digital_swig.constellation_qpsk(),
+ }
+
+class test_trellis (gr_unittest.TestCase):
def test_001_fsm (self):
- I = 2
- S = 4
- O = 4
- NS = (0, 2, 0, 2, 1, 3, 1, 3)
- OS = (0, 3, 3, 0, 1, 2, 2, 1)
- f = trellis.fsm(I,S,O,NS,OS)
- self.assertEqual((I,S,O,NS,OS),(f.I(),f.S(),f.O(),f.NS(),f.OS()))
+ f = trellis.fsm(*fsm_args["awgn1o2_4"])
+ self.assertEqual(fsm_args["awgn1o2_4"],(f.I(),f.S(),f.O(),f.NS(),f.OS()))
def test_002_fsm (self):
- I = 2
- S = 4
- O = 4
- NS = (0, 2, 0, 2, 1, 3, 1, 3)
- OS = (0, 3, 3, 0, 1, 2, 2, 1)
- f = trellis.fsm(I,S,O,NS,OS)
+ f = trellis.fsm(*fsm_args["awgn1o2_4"])
g = trellis.fsm(f)
self.assertEqual((g.I(),g.S(),g.O(),g.NS(),g.OS()),(f.I(),f.S(),f.O(),f.NS(),f.OS()))
def test_003_fsm (self):
- I = 2
- S = 4
- O = 4
- NS = (0, 2, 0, 2, 1, 3, 1, 3)
- OS = (0, 3, 3, 0, 1, 2, 2, 1)
+ # FIXME: no file "awgn1o2_4.fsm"
#f = trellis.fsm("awgn1o2_4.fsm")
- #self.assertEqual((I,S,O,NS,OS),(f.I(),f.S(),f.O(),f.NS(),f.OS()))
- # temporary fix so that make distcheck does not fail on this
- self.assertEqual(0,0)
+ #self.assertEqual(fsm_args["awgn1o2_4"],(f.I(),f.S(),f.O(),f.NS(),f.OS()))
+ pass
+
+ def test_004_fsm(self):
+ """ Test to make sure fsm works with a single state fsm."""
+ # Just checking that it initializes properly.
+ f = trellis.fsm(*fsm_args["rep2"])
def test_001_interleaver (self):
K = 5
@@ -68,5 +72,69 @@ class test_trellis (gr_unittest.TestCase):
i = trellis.interleaver(K,IN)
self.assertEqual((K,IN,DIN),(i.K(),i.INTER(),i.DEINTER()))
+ def test_001_viterbi(self):
+ """
+ Runs some coding/decoding tests with a few different FSM
+ specs.
+ """
+ for name, args in fsm_args.items():
+ constellation = constells[args[2]]
+ fsms = trellis.fsm(*args)
+ noise = 0.1
+ tb = trellis_tb(constellation, fsms, noise)
+ tb.run()
+ # Make sure all packets succesfully transmitted.
+ self.assertEqual(tb.dst.ntotal(), tb.dst.nright())
+
+
+class trellis_tb(gr.top_block):
+ """
+ A simple top block for use testing gr-trellis.
+ """
+ def __init__(self, constellation, f, N0=0.25, seed=-666L):
+ """
+ constellation - a constellation object used for modulation.
+ f - a finite state machine specification used for coding.
+ N0 - noise level
+ seed - random seed
+ """
+ super(trellis_tb, self).__init__()
+ # packet size in bits (make it multiple of 16 so it can be packed in a short)
+ packet_size = 1024*16
+ # bits per FSM input symbol
+ bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol
+ # packet size in trellis steps
+ K = packet_size/bitspersymbol
+
+ # TX
+ src = gr.lfsr_32k_source_s()
+ # packet size in shorts
+ src_head = gr.head (gr.sizeof_short, packet_size/16)
+ # unpack shorts to symbols compatible with the FSM input cardinality
+ s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol, gr.GR_MSB_FIRST)
+ # initial FSM state = 0
+ enc = trellis.encoder_ss(f, 0)
+ mod = gr.chunks_to_symbols_sc(constellation.points(), 1)
+
+ # CHANNEL
+ add = gr.add_cc()
+ noise = gr.noise_source_c(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed)
+
+ # RX
+ # data preprocessing to generate metrics for Viterbi
+ metrics = trellis.constellation_metrics_cf(constellation.base(), digital_swig.TRELLIS_EUCLIDEAN)
+ # Put -1 if the Initial/Final states are not set.
+ va = trellis.viterbi_s(f, K, 0, -1)
+ # pack FSM input symbols to shorts
+ fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol, gr.GR_MSB_FIRST)
+ # check the output
+ self.dst = gr.check_lfsr_32k_s()
+
+ self.connect (src, src_head, s2fsmi, enc, mod)
+ self.connect (mod, (add, 0))
+ self.connect (noise, (add, 1))
+ self.connect (add, metrics, va, fsmi2s, self.dst)
+
+
if __name__ == '__main__':
gr_unittest.run(test_trellis, "test_trellis.xml")
diff --git a/gr-trellis/src/python/run_tests.in b/gr-trellis/src/python/run_tests.in
index 0da3fc1f1..fcb078663 100644
--- a/gr-trellis/src/python/run_tests.in
+++ b/gr-trellis/src/python/run_tests.in
@@ -4,6 +4,8 @@
# 2nd parameter is absolute path to component build directory
# 3rd parameter is path to Python QA directory
+PYTHONPATH=@top_builddir@/gr-digital/swig:@top_builddir@/gr-digital/swig/.libs:@top_srcdir@/gr-digital/swig:$PYTHONPATH
+
@top_builddir@/run_tests.sh \
@abs_top_srcdir@/gr-trellis \
@abs_top_builddir@/gr-trellis \