diff options
Diffstat (limited to 'gnuradio-core/src/lib')
865 files changed, 4477 insertions, 66602 deletions
diff --git a/gnuradio-core/src/lib/CMakeLists.txt b/gnuradio-core/src/lib/CMakeLists.txt index da6de8ed1b..72b9f9bdeb 100644 --- a/gnuradio-core/src/lib/CMakeLists.txt +++ b/gnuradio-core/src/lib/CMakeLists.txt @@ -28,12 +28,9 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/ConfigChecks.cmake) GR_INCLUDE_SUBDIRECTORY(missing) GR_INCLUDE_SUBDIRECTORY(runtime) GR_INCLUDE_SUBDIRECTORY(filter) -GR_INCLUDE_SUBDIRECTORY(viterbi) GR_INCLUDE_SUBDIRECTORY(general) GR_INCLUDE_SUBDIRECTORY(gengen) -GR_INCLUDE_SUBDIRECTORY(reed-solomon) GR_INCLUDE_SUBDIRECTORY(io) -GR_INCLUDE_SUBDIRECTORY(hier) list(APPEND gnuradio_core_sources bug_work_around_6.cc) list(APPEND test_gnuradio_core_sources bug_work_around_6.cc) @@ -103,10 +100,46 @@ endif() # Link against libvolk list(APPEND gnuradio_core_libs volk) -add_library(gnuradio-core SHARED ${gnuradio_core_sources}) +if(ENABLE_GR_CTRLPORT) + +######################################################################## +# Run ICE To compile Slice files +######################################################################## +EXECUTE_PROCESS( + COMMAND "${ICE_SLICE2CPP}" "-I${CMAKE_CURRENT_SOURCE_DIR}/runtime" + "--output-dir=${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/runtime/gnuradio.ice" + ) + +# Append generated file in build directory +list(APPEND gnuradio_core_generated_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio.cpp +) + +list(APPEND gnuradio_core_generated_includes + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio.h +) + +######################################################################## +# Add controlport stuff to gnuradio-core +######################################################################## + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +list(APPEND gnuradio_core_libs + ${ICE_LIBRARIES} +) + +endif(ENABLE_GR_CTRLPORT) + +add_library(gnuradio-core SHARED ${gnuradio_core_sources} ${gnuradio_core_generated_sources}) target_link_libraries(gnuradio-core ${gnuradio_core_libs}) GR_LIBRARY_FOO(gnuradio-core RUNTIME_COMPONENT "core_runtime" DEVEL_COMPONENT "core_devel") set_target_properties(gnuradio-core PROPERTIES LINK_INTERFACE_LIBRARIES "gruel") +ADD_DEPENDENCIES(gnuradio-core + gnuradio_core_generated_sources + gnuradio_core_generated_includes + gnuradio_core_generated_swigs) ######################################################################## # Setup executables diff --git a/gnuradio-core/src/lib/filter/3dnow_float_dotprod_really_simple.S b/gnuradio-core/src/lib/filter/3dnow_float_dotprod_really_simple.S deleted file mode 100644 index 546a4a6f3f..0000000000 --- a/gnuradio-core/src/lib/filter/3dnow_float_dotprod_really_simple.S +++ /dev/null @@ -1,99 +0,0 @@ -# -# Copyright 2002 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_4_float_blocks is != 0 -# -# -# float -# sse_float_dotprod (const float *input, -# const float *taps, unsigned n_4_float_blocks) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[1] * taps[1]; -# sum2 += input[2] * taps[2]; -# sum3 += input[3] * taps[3]; -# -# input += 4; -# taps += 4; -# -# } while (--n_4_float_blocks != 0); -# -# -# return sum0 + sum1 + sum2 + sum3; -# } -# - - - .file "3dnow_float_dotprod_really_simple.s" -// .version "01.01" -.text - .p2align 4 -.globl sse_float_dotprod - .type sse_float_dotprod,@function -sse_float_dotprod: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %edx - movl 12(%ebp), %eax - movl 16(%ebp), %ecx - - - # The plan is to get it computing the correct answer, and - # then to unroll and schedule the inner loop. - - pxor %mm4, %mm4 # mm4 = 0 0 - shll $1, %ecx # count * 2 - - .p2align 4 -.Loop1: - movq (%eax), %mm0 - pfmul (%edx), %mm0 - pfadd %mm0, %mm4 - addl $8, %edx - addl $8, %eax - decl %ecx - jne .Loop1 - - # at this point mm4 contains partial sums - - pfacc %mm4, %mm4 - movd %mm4, 16(%ebp) - femms - flds 16(%ebp) - - popl %ebp - ret -.Lfe1: - .size sse_float_dotprod,.Lfe1-sse_float_dotprod - .ident "Hand coded x86 3DNow! assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/3dnow_float_dotprod_simple.S b/gnuradio-core/src/lib/filter/3dnow_float_dotprod_simple.S deleted file mode 100644 index c721c36014..0000000000 --- a/gnuradio-core/src/lib/filter/3dnow_float_dotprod_simple.S +++ /dev/null @@ -1,106 +0,0 @@ -# -# Copyright 2002 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_4_float_blocks is != 0 -# -# -# float -# sse_float_dotprod (const float *input, -# const float *taps, unsigned n_4_float_blocks) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[1] * taps[1]; -# sum2 += input[2] * taps[2]; -# sum3 += input[3] * taps[3]; -# -# input += 4; -# taps += 4; -# -# } while (--n_4_float_blocks != 0); -# -# -# return sum0 + sum1 + sum2 + sum3; -# } -# - - - .file "3dnow_float_dotprod_simple.s" -// .version "01.01" -.text - .p2align 4 -.globl sse_float_dotprod - .type sse_float_dotprod,@function -sse_float_dotprod: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %edx - movl 12(%ebp), %eax - movl 16(%ebp), %ecx - - - # The plan is to get it computing the correct answer, and - # then to unroll and schedule the inner loop. - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - - .p2align 4 -.Loop1: - movq 0(%eax), %mm0 - movq 8(%eax), %mm1 - - pfmul 0(%edx), %mm0 - pfadd %mm0, %mm4 - - pfmul 8(%edx), %mm1 - pfadd %mm1, %mm5 - - addl $16, %edx - addl $16, %eax - decl %ecx - jne .Loop1 - - # at this point mm4 and mm5 contain partial sums - - pfadd %mm5, %mm4 - pfacc %mm4, %mm4 - movd %mm4, 16(%ebp) - femms - flds 16(%ebp) - - popl %ebp - ret -.Lfe1: - .size sse_float_dotprod,.Lfe1-sse_float_dotprod - .ident "Hand coded x86 3DNow! assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/CMakeLists.txt b/gnuradio-core/src/lib/filter/CMakeLists.txt index 088d3376d1..a185b06bd5 100644 --- a/gnuradio-core/src/lib/filter/CMakeLists.txt +++ b/gnuradio-core/src/lib/filter/CMakeLists.txt @@ -21,337 +21,19 @@ # This file included, use CMake directory variables ######################################################################## -#set the C language property on the assembly files so the compiler will pick them up -file(GLOB gr_core_filter_asms ${CMAKE_CURRENT_SOURCE_DIR}/*.S) -foreach(gr_core_filter_asm ${gr_core_filter_asms}) - set_property(SOURCE ${gr_core_filter_asm} PROPERTY LANGUAGE C) -endforeach(gr_core_filter_asm) - -#detect 32 or 64 bit compiler -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|x86_64|amd64)$") - include(CheckTypeSize) - check_type_size("void*" SIZEOF_VOID_P BUILTIN_TYPES_ONLY) - if (${SIZEOF_VOID_P} EQUAL 8) - set(CMAKE_SYSTEM_PROCESSOR_x86 64) - else() - set(CMAKE_SYSTEM_PROCESSOR_x86 32) - endif() -endif() - -######################################################################## -# Generate the makefile.gen, then extract its sources: -# This is a round-about way to extract the sources, -# but it requires minimum changed to the python utils. -# -# The recommended way to do this: -# - Make a generation macro that registers the sources command. -# - List the generation macro with each templated source file. -# - Create a python script (very generic) to perform generation. -# - This way the targets would depend only on their sources. -######################################################################## -execute_process( - COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} -c " -import os, sys -sys.path.append('${GR_CORE_PYTHONPATH}') -sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}') -os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' -os.environ['gendir'] = '${CMAKE_CURRENT_BINARY_DIR}' -os.environ['do_makefile'] = '1' -os.environ['do_sources'] = '0' -from generate_all import generate_all -generate_all() - " WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} -) - -macro(FILTER_GEN_EXTRACT outvar ext) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import os; print ';'.join( - map(lambda x: os.path.join('${CMAKE_CURRENT_BINARY_DIR}', x.replace('\\\\', '').strip()), - filter(lambda f: '${ext}' in f, open('${CMAKE_CURRENT_BINARY_DIR}/Makefile.gen').readlines() - )))" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE ${outvar}) - file(TO_CMAKE_PATH "${${outvar}}" ${outvar}) -endmacro(FILTER_GEN_EXTRACT) - -FILTER_GEN_EXTRACT(generated_filter_sources ".cc") -FILTER_GEN_EXTRACT(generated_filter_includes ".h") -FILTER_GEN_EXTRACT(generated_filter_swigs ".i") - -#TODO simplify this list with a triple-threat for loop -set(generated_filter_deps - ${CMAKE_CURRENT_SOURCE_DIR}/generate_all.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_XXX.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_filter_XXX.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_interp_fir_filter_XXX.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_rational_resampler_base_XXX.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_sysconfig.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_sysconfig_generic.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_util.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_freq_xlating_fir_filter_XXX.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gri_fir_filter_with_buffer_XXX.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_utils.py - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_XXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_XXX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_XXX_generic.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_XXX_generic.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_filter_XXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_filter_XXX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_filter_XXX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_interp_fir_filter_XXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_interp_fir_filter_XXX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_interp_fir_filter_XXX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_rational_resampler_base_XXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_rational_resampler_base_XXX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_rational_resampler_base_XXX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_freq_xlating_fir_filter_XXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_freq_xlating_fir_filter_XXX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_freq_xlating_fir_filter_XXX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fir_filter_with_buffer_XXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fir_filter_with_buffer_XXX.h.t -) - -add_custom_command( - OUTPUT - ${generated_filter_sources} - ${generated_filter_includes} - ${generated_filter_swigs} - DEPENDS ${generated_filter_deps} - COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} -c - "import os, sys;sys.path.append('${GR_CORE_PYTHONPATH}');sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}');os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}';from generate_all import generate_all;generate_all()" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "generating filter files" - VERBATIM -) - -add_custom_target(filter_generated DEPENDS - ${generated_filter_sources} - ${generated_filter_includes} - ${generated_filter_swigs} -) - -######################################################################## -# Add target specific files -# May VOLK put a rest to all the insanity below. -######################################################################## -if(MSVC) - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_generic.cc - ) - list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_generic.cc - ) -else(MSVC) -if(CMAKE_SYSTEM_PROCESSOR_x86) - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_cpu_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccc_simd.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccc_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fff_simd.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fff_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fsf_simd.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fsf_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_scc_simd.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_scc_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fcc_simd.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fcc_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccf_simd.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccf_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/sse_debug.c - ) - list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_float_dotprod_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_complex_dotprod_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_ccomplex_dotprod_x86.cc - ) -endif() - -if(CMAKE_SYSTEM_PROCESSOR_x86 AND "${CMAKE_SYSTEM_PROCESSOR_x86}" STREQUAL "64") - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_sse64.S - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_3dnow64.S - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_3dnowext64.S - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_3dnow64.S - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_sse64.S - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_3dnowext64.S - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_3dnow64.S - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_sse64.S - ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_3dnow64.S - ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_sse64.S - ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_mmx64.S - ) -elseif(CMAKE_SYSTEM_PROCESSOR_x86 AND "${CMAKE_SYSTEM_PROCESSOR_x86}" STREQUAL "32") - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_sse.S - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_3dnow.S - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_3dnowext.S - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_3dnow.S - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_sse.S - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_3dnowext.S - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_3dnow.S - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_sse.S - ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_3dnow.S - ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_sse.S - ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_mmx.S - ) -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)") - if(CMAKE_COMPILER_IS_GNUCXX) - add_definitions(-maltivec) - endif() - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_powerpc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_powerpc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_cpu_powerpc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fff_altivec.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_altivec.c - ${CMAKE_CURRENT_SOURCE_DIR}/dotprod_fff_altivec.c - ) - list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_powerpc.cc - ) -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") - if(have_mfpu_neon) - add_definitions(-DHAVE_MFPU_NEON) - endif() - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_armv7_a.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_armv7_a.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_cpu_armv7_a.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fff_armv7_a.cc - ${CMAKE_CURRENT_SOURCE_DIR}/dotprod_fff_armv7_a.c - ${CMAKE_CURRENT_SOURCE_DIR}/dotprod_ccf_armv7_a.c - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccf_armv7_a.cc - ) - list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_armv7_a.cc - ) -else() - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_generic.cc - ) - list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_generic.cc - ) -endif() -endif(MSVC) - ######################################################################## # Append gnuradio-core library sources ######################################################################## list(APPEND gnuradio_core_sources - ${generated_filter_sources} - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft_filter_fff_generic.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft_filter_ccc_generic.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.c - ${CMAKE_CURRENT_SOURCE_DIR}/gri_goertzel.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_mmse_fir_interpolator.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_mmse_fir_interpolator_cc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_generic.cc - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_generic.cc - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_generic.c - ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_generic.c -) - -######################################################################## -# Append gnuradio-core test sources -######################################################################## -list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_filter.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_ccf.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_fcc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_fff.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_ccc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_scc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_rotator.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_mmse_fir_interpolator.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_mmse_fir_interpolator_cc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_ccf.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_ccc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_fcc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_fff.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_fsf.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_scc.cc ) ######################################################################## # Install runtime headers ######################################################################## install(FILES - ${generated_filter_includes} - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_generic.h - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_x86.h - ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_x86.h - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_generic.h - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_x86.h - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_generic.h - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_x86.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_altivec.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_cpu.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft_filter_fff_generic.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft_filter_ccc_generic.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_x86.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_powerpc.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_rotator.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_single_pole_iir.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_vec_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_goertzel.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_iir.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_mmse_fir_interpolator.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_mmse_fir_interpolator_cc.h - ${CMAKE_CURRENT_SOURCE_DIR}/qa_filter.h - ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_generic.h - ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_x86.h - ${CMAKE_CURRENT_SOURCE_DIR}/sse_debug.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel" ) - -######################################################################## -# Install swig headers -######################################################################## -if(ENABLE_PYTHON) -install(FILES - ${generated_filter_swigs} - ${CMAKE_CURRENT_SOURCE_DIR}/filter.i - ${CMAKE_CURRENT_BINARY_DIR}/filter_generated.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "core_swig" -) -endif(ENABLE_PYTHON) - -######################################################################## -# Handle triple-threat files that have cc, h, and i -######################################################################## -set(gr_core_filter_triple_threats - gr_adaptive_fir_ccc - gr_adaptive_fir_ccf - gr_dc_blocker_cc - gr_dc_blocker_ff - gr_fft_filter_ccc - gr_fft_filter_fff - gr_filter_delay_fc - gr_fractional_interpolator_ff - gr_fractional_interpolator_cc - gr_goertzel_fc - gr_hilbert_fc - gr_iir_filter_ffd - gr_single_pole_iir_filter_ff - gr_single_pole_iir_filter_cc - gr_pfb_channelizer_ccf - gr_pfb_synthesizer_ccf - gr_pfb_decimator_ccf - gr_pfb_interpolator_ccf - gr_pfb_arb_resampler_ccf - gr_pfb_arb_resampler_fff - gr_pfb_clock_sync_ccf - gr_pfb_clock_sync_fff -) - -foreach(file_tt ${gr_core_filter_triple_threats}) - list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.cc) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel") - if(ENABLE_PYTHON) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig") - endif(ENABLE_PYTHON) -endforeach(file_tt ${gr_core_filter_triple_threats}) diff --git a/gnuradio-core/src/lib/filter/Makefile.gen b/gnuradio-core/src/lib/filter/Makefile.gen deleted file mode 100644 index 909899c054..0000000000 --- a/gnuradio-core/src/lib/filter/Makefile.gen +++ /dev/null @@ -1,124 +0,0 @@ -# -# This file is machine generated. All edits will be overwritten -# -GENERATED_H = \ - gr_fir_ccc.h \ - gr_fir_ccc_generic.h \ - gr_fir_ccf.h \ - gr_fir_ccf_generic.h \ - gr_fir_fcc.h \ - gr_fir_fcc_generic.h \ - gr_fir_fff.h \ - gr_fir_fff_generic.h \ - gr_fir_filter_ccc.h \ - gr_fir_filter_ccf.h \ - gr_fir_filter_fcc.h \ - gr_fir_filter_fff.h \ - gr_fir_filter_fsf.h \ - gr_fir_filter_scc.h \ - gr_fir_fsf.h \ - gr_fir_fsf_generic.h \ - gr_fir_scc.h \ - gr_fir_scc_generic.h \ - gr_fir_sysconfig.h \ - gr_fir_sysconfig_generic.h \ - gr_fir_util.h \ - gr_freq_xlating_fir_filter_ccc.h \ - gr_freq_xlating_fir_filter_ccf.h \ - gr_freq_xlating_fir_filter_fcc.h \ - gr_freq_xlating_fir_filter_fcf.h \ - gr_freq_xlating_fir_filter_scc.h \ - gr_freq_xlating_fir_filter_scf.h \ - gr_interp_fir_filter_ccc.h \ - gr_interp_fir_filter_ccf.h \ - gr_interp_fir_filter_fcc.h \ - gr_interp_fir_filter_fff.h \ - gr_interp_fir_filter_fsf.h \ - gr_interp_fir_filter_scc.h \ - gr_rational_resampler_base_ccc.h \ - gr_rational_resampler_base_ccf.h \ - gr_rational_resampler_base_fcc.h \ - gr_rational_resampler_base_fff.h \ - gr_rational_resampler_base_fsf.h \ - gr_rational_resampler_base_scc.h \ - gri_fir_filter_with_buffer_ccc.h \ - gri_fir_filter_with_buffer_ccf.h \ - gri_fir_filter_with_buffer_fcc.h \ - gri_fir_filter_with_buffer_fff.h \ - gri_fir_filter_with_buffer_fsf.h \ - gri_fir_filter_with_buffer_scc.h - - -GENERATED_I = \ - gr_fir_filter_ccc.i \ - gr_fir_filter_ccf.i \ - gr_fir_filter_fcc.i \ - gr_fir_filter_fff.i \ - gr_fir_filter_fsf.i \ - gr_fir_filter_scc.i \ - gr_freq_xlating_fir_filter_ccc.i \ - gr_freq_xlating_fir_filter_ccf.i \ - gr_freq_xlating_fir_filter_fcc.i \ - gr_freq_xlating_fir_filter_fcf.i \ - gr_freq_xlating_fir_filter_scc.i \ - gr_freq_xlating_fir_filter_scf.i \ - gr_interp_fir_filter_ccc.i \ - gr_interp_fir_filter_ccf.i \ - gr_interp_fir_filter_fcc.i \ - gr_interp_fir_filter_fff.i \ - gr_interp_fir_filter_fsf.i \ - gr_interp_fir_filter_scc.i \ - gr_rational_resampler_base_ccc.i \ - gr_rational_resampler_base_ccf.i \ - gr_rational_resampler_base_fcc.i \ - gr_rational_resampler_base_fff.i \ - gr_rational_resampler_base_fsf.i \ - gr_rational_resampler_base_scc.i - -GENERATED_CC = \ - gr_fir_ccc.cc \ - gr_fir_ccc_generic.cc \ - gr_fir_ccf.cc \ - gr_fir_ccf_generic.cc \ - gr_fir_fcc.cc \ - gr_fir_fcc_generic.cc \ - gr_fir_fff.cc \ - gr_fir_fff_generic.cc \ - gr_fir_filter_ccc.cc \ - gr_fir_filter_ccf.cc \ - gr_fir_filter_fcc.cc \ - gr_fir_filter_fff.cc \ - gr_fir_filter_fsf.cc \ - gr_fir_filter_scc.cc \ - gr_fir_fsf.cc \ - gr_fir_fsf_generic.cc \ - gr_fir_scc.cc \ - gr_fir_scc_generic.cc \ - gr_fir_sysconfig.cc \ - gr_fir_sysconfig_generic.cc \ - gr_fir_util.cc \ - gr_freq_xlating_fir_filter_ccc.cc \ - gr_freq_xlating_fir_filter_ccf.cc \ - gr_freq_xlating_fir_filter_fcc.cc \ - gr_freq_xlating_fir_filter_fcf.cc \ - gr_freq_xlating_fir_filter_scc.cc \ - gr_freq_xlating_fir_filter_scf.cc \ - gr_interp_fir_filter_ccc.cc \ - gr_interp_fir_filter_ccf.cc \ - gr_interp_fir_filter_fcc.cc \ - gr_interp_fir_filter_fff.cc \ - gr_interp_fir_filter_fsf.cc \ - gr_interp_fir_filter_scc.cc \ - gr_rational_resampler_base_ccc.cc \ - gr_rational_resampler_base_ccf.cc \ - gr_rational_resampler_base_fcc.cc \ - gr_rational_resampler_base_fff.cc \ - gr_rational_resampler_base_fsf.cc \ - gr_rational_resampler_base_scc.cc \ - gri_fir_filter_with_buffer_ccc.cc \ - gri_fir_filter_with_buffer_ccf.cc \ - gri_fir_filter_with_buffer_fcc.cc \ - gri_fir_filter_with_buffer_fff.cc \ - gri_fir_filter_with_buffer_fsf.cc \ - gri_fir_filter_with_buffer_scc.cc - diff --git a/gnuradio-core/src/lib/filter/README b/gnuradio-core/src/lib/filter/README deleted file mode 100644 index 90c1584fcb..0000000000 --- a/gnuradio-core/src/lib/filter/README +++ /dev/null @@ -1,28 +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 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along 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 directory holds filtering code, some of which is machine -generated. Which variations are generated is controlled by two -variables. For most everything, the global "signatures" -in generate_utils.py controls. - -For GrFreqXlatingFIRfilter<foo>, the global "fx_signatures" in -generate_GrFreqXlatingFIRfilterXXX.py controls. diff --git a/gnuradio-core/src/lib/filter/assembly.h b/gnuradio-core/src/lib/filter/assembly.h deleted file mode 100644 index 32477dfd7b..0000000000 --- a/gnuradio-core/src/lib/filter/assembly.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _ASSEMBLY_H_ -#define _ASSEMBLY_H_ - -#if defined (__APPLE__) && defined (__APPLE_CC__) - -// XCode ignores the .scl and .type functions in XCode 2.2.1 and 2.3, -// but creates an error in XCode 2.4. Just ignore them. - -#define GLOB_SYMB(f) _ ## f - -#define DEF_FUNC_HEAD(f) /* none */ - -#define FUNC_TAIL(f) /* none*/ - -#elif !defined (__ELF__) - -/* - * Too bad, the following define does not work as expected --SF - * #define GLOB_SYMB(f) __USER_LABEL_PREFIX__ ## f - */ -#define GLOB_SYMB(f) _ ## f - -#define DEF_FUNC_HEAD(f) \ - .def GLOB_SYMB(f); .scl 2; .type 32; .endef - -#define FUNC_TAIL(f) /* none */ - - -#else /* !__ELF__ */ - - -#define GLOB_SYMB(f) f - -#define DEF_FUNC_HEAD(f) \ - .type GLOB_SYMB(f),@function \ - -#define FUNC_TAIL(f) \ - .Lfe1: \ - .size GLOB_SYMB(f),.Lfe1-GLOB_SYMB(f) - - -#endif /* !__ELF__ */ - - -#endif /* _ASSEMBLY_H_ */ diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnow.S b/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnow.S deleted file mode 100644 index f663563375..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnow.S +++ /dev/null @@ -1,220 +0,0 @@ -# -# Copyright 2002 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_ccomplex_blocks is != 0 -# -# -# ccomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_ccomplex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0] - input[1] * taps[1]; -# sum1 += input[0] * taps[1] + input[1] * taps[0]; -# sum2 += input[2] * taps[2] - input[3] * taps[3]; -# sum3 += input[2] * taps[3] + input[3] * taps[2]; -# -# input += 4; -# taps += 4; -# -# } while (--n_2_ccomplex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - .file "ccomplex_dotprod_3dnow.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(ccomplex_dotprod_3dnow) - DEF_FUNC_HEAD(ccomplex_dotprod_3dnow) -GLOB_SYMB(ccomplex_dotprod_3dnow): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx # n_2_ccomplex_blocks - - # zero accumulators - - pxor %mm6, %mm6 # mm6 = 0 0 - - movq 0(%eax), %mm0 - - pxor %mm7, %mm7 # mm7 = 0 0 - - movq 0(%edx), %mm2 - - movq 8(%eax), %mm1 - - shrl $1, %ecx # ecx = n_2_ccomplex_blocks / 2 - - movq 8(%edx), %mm3 - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - -# complex prod: C += A * B, w/ temp Z, mmPN=$80000000 -# -# movq (%eax), %mmA -# movq (%edx), %mmB -# -# # 3DNow! replacement for: pswapd %mmA, %mmZ -# # TODO: optimize the punpckhdq -# movq %mmA, %mmZ -# punpckhdq %mmZ, %mmZ -# punpckldq %mmA, %mmZ -# -# pfmul %mmB, %mmA -# pfmul %mmZ, %mmB -# -# # 3DNow! replacement for: pfpnacc %mmB, %mmA -# pxor %mmPN, %mmA -# pfacc %mmB, %mmA -# -# pfadd %mmA, %mmC - - -# A=mm0, B=mm2, Z=mm4 -# A'=mm1, B'=mm3, Z'=mm5 - - movq %mm0, %mm4 - movq %mm1, %mm5 - punpckhdq %mm4, %mm4 - punpckhdq %mm5, %mm5 - punpckldq %mm0, %mm4 - pfmul %mm2, %mm0 - punpckldq %mm1, %mm5 - pfmul %mm4, %mm2 - pfadd %mm0, %mm6 - movq 16(%edx), %mm0 - pfmul %mm3, %mm1 - pfadd %mm2, %mm7 - movq 16(%eax), %mm2 - pfadd %mm1, %mm6 - pfmul %mm5, %mm3 - movq 24(%edx), %mm1 - - movq %mm0, %mm4 - movq %mm1, %mm5 - - pfadd %mm3, %mm7 - movq 24(%eax), %mm3 - -# unroll - - punpckhdq %mm4, %mm4 - punpckhdq %mm5, %mm5 - punpckldq %mm0, %mm4 - pfmul %mm2, %mm0 - punpckldq %mm1, %mm5 - pfmul %mm4, %mm2 - pfadd %mm0, %mm6 - movq 32(%edx), %mm0 - pfmul %mm3, %mm1 - pfadd %mm2, %mm7 - movq 32(%eax), %mm2 - pfadd %mm1, %mm6 - pfmul %mm5, %mm3 - movq 40(%edx), %mm1 - - addl $32, %eax - addl $32, %edx - - pfadd %mm3, %mm7 - movq 8(%eax), %mm3 - -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Let's see if original n_2_ccomplex_blocks was odd. - # If so, we've got 2 more taps to do. - - movl 16(%ebp), %ecx # n_2_ccomplex_blocks - andl $1, %ecx - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0/mm2 & mm1/mm3 preloaded - # from the main loop. - - movq %mm0, %mm4 - movq %mm1, %mm5 - punpckhdq %mm4, %mm4 - punpckhdq %mm5, %mm5 - punpckldq %mm0, %mm4 - pfmul %mm2, %mm0 - punpckldq %mm1, %mm5 - pfmul %mm4, %mm2 - pfadd %mm0, %mm6 - pfmul %mm3, %mm1 - pfadd %mm2, %mm7 - pfmul %mm5, %mm3 - pfadd %mm1, %mm6 - pfadd %mm3, %mm7 - -.Leven: - # mmNP: negative inversor - - pcmpeqd %mm0, %mm0 # set all bits to 1 - psllq $63, %mm0 # keep only hsb - - pxor %mm0, %mm6 - pfacc %mm7, %mm6 - - movl 20(%ebp), %eax # result - movq %mm6, (%eax) - - femms - - popl %ebp - ret - -FUNC_TAIL(ccomplex_dotprod_3dnow) - .ident "Hand coded x86 3DNow! assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnow64.S b/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnow64.S deleted file mode 100644 index e81d219935..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnow64.S +++ /dev/null @@ -1,217 +0,0 @@ -# -# Copyright 2002,2005 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_ccomplex_blocks is != 0 -# -# -# ccomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_ccomplex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0] - input[1] * taps[1]; -# sum1 += input[0] * taps[1] + input[1] * taps[0]; -# sum2 += input[2] * taps[2] - input[3] * taps[3]; -# sum3 += input[2] * taps[3] + input[3] * taps[2]; -# -# input += 4; -# taps += 4; -# -# } while (--n_2_ccomplex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - - .file "ccomplex_dotprod_3dnow64.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(ccomplex_dotprod_3dnow) - DEF_FUNC_HEAD(ccomplex_dotprod_3dnow) -GLOB_SYMB(ccomplex_dotprod_3dnow): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - # zero accumulators - - pxor %mm6, %mm6 # mm6 = 0 0 - - movq 0(%rdi), %mm0 - - pxor %mm7, %mm7 # mm7 = 0 0 - - movq 0(%rsi), %mm2 - - movq 8(%rdi), %mm1 - - shr $1, %rax # rax = n_2_ccomplex_blocks / 2 - - movq 8(%rsi), %mm3 - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - -# complex prod: C += A * B, w/ temp Z, mmPN=$80000000 -# -# movq (%rdx), %mmA -# movq (%rsi), %mmB -# -# # 3DNow! replacement for: pswapd %mmA, %mmZ -# # TODO: optimize the punpckhdq -# movq %mmA, %mmZ -# punpckhdq %mmZ, %mmZ -# punpckldq %mmA, %mmZ -# -# pfmul %mmB, %mmA -# pfmul %mmZ, %mmB -# -# # 3DNow! replacement for: pfpnacc %mmB, %mmA -# pxor %mmPN, %mmA -# pfacc %mmB, %mmA -# -# pfadd %mmA, %mmC - - -# A=mm0, B=mm2, Z=mm4 -# A'=mm1, B'=mm3, Z'=mm5 - - movq %mm0, %mm4 - movq %mm1, %mm5 - punpckhdq %mm4, %mm4 - punpckhdq %mm5, %mm5 - punpckldq %mm0, %mm4 - pfmul %mm2, %mm0 - punpckldq %mm1, %mm5 - pfmul %mm4, %mm2 - pfadd %mm0, %mm6 - movq 16(%rsi), %mm0 - pfmul %mm3, %mm1 - pfadd %mm2, %mm7 - movq 16(%rdi), %mm2 - pfadd %mm1, %mm6 - pfmul %mm5, %mm3 - movq 24(%rsi), %mm1 - - movq %mm0, %mm4 - movq %mm1, %mm5 - - pfadd %mm3, %mm7 - movq 24(%rdi), %mm3 - -# unroll - - punpckhdq %mm4, %mm4 - punpckhdq %mm5, %mm5 - punpckldq %mm0, %mm4 - pfmul %mm2, %mm0 - punpckldq %mm1, %mm5 - pfmul %mm4, %mm2 - pfadd %mm0, %mm6 - movq 32(%rsi), %mm0 - pfmul %mm3, %mm1 - pfadd %mm2, %mm7 - movq 32(%rdi), %mm2 - pfadd %mm1, %mm6 - pfmul %mm5, %mm3 - movq 40(%rsi), %mm1 - - add $32, %rdi - add $32, %rsi - - pfadd %mm3, %mm7 - movq 8(%rdi), %mm3 - -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Let's see if original n_2_ccomplex_blocks was odd. - # If so, we've got 2 more taps to do. - - and $1, %rdx - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0/mm2 & mm1/mm3 preloaded - # from the main loop. - - movq %mm0, %mm4 - movq %mm1, %mm5 - punpckhdq %mm4, %mm4 - punpckhdq %mm5, %mm5 - punpckldq %mm0, %mm4 - pfmul %mm2, %mm0 - punpckldq %mm1, %mm5 - pfmul %mm4, %mm2 - pfadd %mm0, %mm6 - pfmul %mm3, %mm1 - pfadd %mm2, %mm7 - pfmul %mm5, %mm3 - pfadd %mm1, %mm6 - pfadd %mm3, %mm7 - -.Leven: - # mmNP: negative inversor - - pcmpeqd %mm0, %mm0 # set all bits to 1 - psllq $63, %mm0 # keep only hsb - - pxor %mm0, %mm6 - pfacc %mm7, %mm6 - - movq %mm6, (%rcx) - - femms - - retq - -FUNC_TAIL(ccomplex_dotprod_3dnow) - .ident "Hand coded x86_64 3DNow! assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnowext.S b/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnowext.S deleted file mode 100644 index 22c390bddd..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnowext.S +++ /dev/null @@ -1,195 +0,0 @@ -# -# Copyright 2002 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_ccomplex_blocks is != 0 -# -# -# ccomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_ccomplex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0] - input[1] * taps[1]; -# sum1 += input[0] * taps[1] + input[1] * taps[0]; -# sum2 += input[2] * taps[2] - input[3] * taps[3]; -# sum3 += input[2] * taps[3] + input[3] * taps[2]; -# -# input += 4; -# taps += 4; -# -# } while (--n_2_ccomplex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - .file "ccomplex_dotprod_3dnowext.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(ccomplex_dotprod_3dnowext) - DEF_FUNC_HEAD(ccomplex_dotprod_3dnowext) -GLOB_SYMB(ccomplex_dotprod_3dnowext): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx # n_2_ccomplex_blocks - - # zero accumulators - - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - movq 0(%eax), %mm0 - movq 0(%edx), %mm2 - - shrl $1, %ecx # ecx = n_2_ccomplex_blocks / 2 - - movq 8(%eax), %mm1 - movq 8(%edx), %mm3 - - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - -# complex prod: C += A * B, w/ temp Z -# -# movq 0(%eax), %mmA -# movq 0(%edx), %mmB -# pswapd %mmA, %mmZ -# pfmul %mmB, %mmA -# pfmul %mmZ, %mmB -# pfpnacc %mmB, %mmA -# pfadd %mmA, %mmC - - -# A=mm0, B=mm2, Z=mm4 -# A'=mm1, B'=mm3, Z'=mm5 - - pswapd %mm0, %mm4 - pfmul %mm2, %mm0 - pswapd %mm1, %mm5 - pfmul %mm4, %mm2 - pfmul %mm3, %mm1 - pfpnacc %mm2, %mm0 - pfmul %mm5, %mm3 - movq 16(%edx), %mm2 - pfpnacc %mm3, %mm1 - movq 24(%edx), %mm3 - - pfadd %mm0, %mm6 - movq 16(%eax), %mm0 - pfadd %mm1, %mm7 - movq 24(%eax), %mm1 - -# unroll - - pswapd %mm0, %mm4 - pfmul %mm2, %mm0 - pswapd %mm1, %mm5 - pfmul %mm4, %mm2 - pfmul %mm3, %mm1 - pfpnacc %mm2, %mm0 - pfmul %mm5, %mm3 - movq 32(%edx), %mm2 - pfpnacc %mm3, %mm1 - movq 40(%edx), %mm3 - - pfadd %mm0, %mm6 - movq 32(%eax), %mm0 - pfadd %mm1, %mm7 - movq 40(%eax), %mm1 - - addl $32, %edx - addl $32, %eax - -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Let's see if original n_2_ccomplex_blocks was odd. - # If so, we've got 2 more taps to do. - - movl 16(%ebp), %ecx # n_2_ccomplex_blocks - andl $1, %ecx - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0/mm2 & mm1/mm3 preloaded - # from the main loop. - -# A=mm0, B=mm2, Z=mm4 -# A'=mm1, B'=mm3, Z'=mm5 - - pswapd %mm0, %mm4 - pfmul %mm2, %mm0 - pswapd %mm1, %mm5 - pfmul %mm4, %mm2 - pfmul %mm3, %mm1 - pfpnacc %mm2, %mm0 - pfmul %mm5, %mm3 - pfpnacc %mm3, %mm1 - - pfadd %mm0, %mm6 - pfadd %mm1, %mm7 - -.Leven: - # at this point mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - - movl 20(%ebp), %eax # result - movq %mm6, (%eax) - - femms - - popl %ebp - ret - -FUNC_TAIL(ccomplex_dotprod_3dnowext) - .ident "Hand coded x86 3DNow!Ext assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnowext64.S b/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnowext64.S deleted file mode 100644 index 75608914b0..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnowext64.S +++ /dev/null @@ -1,192 +0,0 @@ -# -# Copyright 2002,2005 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_ccomplex_blocks is != 0 -# -# -# ccomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_ccomplex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0] - input[1] * taps[1]; -# sum1 += input[0] * taps[1] + input[1] * taps[0]; -# sum2 += input[2] * taps[2] - input[3] * taps[3]; -# sum3 += input[2] * taps[3] + input[3] * taps[2]; -# -# input += 4; -# taps += 4; -# -# } while (--n_2_ccomplex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - .file "ccomplex_dotprod_3dnowext64.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(ccomplex_dotprod_3dnowext) - DEF_FUNC_HEAD(ccomplex_dotprod_3dnowext) -GLOB_SYMB(ccomplex_dotprod_3dnowext): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - - # zero accumulators - - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - movq 0(%rdi), %mm0 - movq 0(%rsi), %mm2 - - shr $1, %rax # rax = n_2_ccomplex_blocks / 2 - - movq 8(%rdi), %mm1 - movq 8(%rsi), %mm3 - - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - -# complex prod: C += A * B, w/ temp Z -# -# movq 0(%rdi), %mmA -# movq 0(%rsi), %mmB -# pswapd %mmA, %mmZ -# pfmul %mmB, %mmA -# pfmul %mmZ, %mmB -# pfpnacc %mmB, %mmA -# pfadd %mmA, %mmC - - -# A=mm0, B=mm2, Z=mm4 -# A'=mm1, B'=mm3, Z'=mm5 - - pswapd %mm0, %mm4 - pfmul %mm2, %mm0 - pswapd %mm1, %mm5 - pfmul %mm4, %mm2 - pfmul %mm3, %mm1 - pfpnacc %mm2, %mm0 - pfmul %mm5, %mm3 - movq 16(%rsi), %mm2 - pfpnacc %mm3, %mm1 - movq 24(%rsi), %mm3 - - pfadd %mm0, %mm6 - movq 16(%rdi), %mm0 - pfadd %mm1, %mm7 - movq 24(%rdi), %mm1 - -# unroll - - pswapd %mm0, %mm4 - pfmul %mm2, %mm0 - pswapd %mm1, %mm5 - pfmul %mm4, %mm2 - pfmul %mm3, %mm1 - pfpnacc %mm2, %mm0 - pfmul %mm5, %mm3 - movq 32(%rsi), %mm2 - pfpnacc %mm3, %mm1 - movq 40(%rsi), %mm3 - - pfadd %mm0, %mm6 - movq 32(%rdi), %mm0 - pfadd %mm1, %mm7 - movq 40(%rdi), %mm1 - - add $32, %rsi - add $32, %rdi - -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Let's see if original n_2_ccomplex_blocks was odd. - # If so, we've got 2 more taps to do. - - and $1, %rdx - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0/mm2 & mm1/mm3 preloaded - # from the main loop. - -# A=mm0, B=mm2, Z=mm4 -# A'=mm1, B'=mm3, Z'=mm5 - - pswapd %mm0, %mm4 - pfmul %mm2, %mm0 - pswapd %mm1, %mm5 - pfmul %mm4, %mm2 - pfmul %mm3, %mm1 - pfpnacc %mm2, %mm0 - pfmul %mm5, %mm3 - pfpnacc %mm3, %mm1 - - pfadd %mm0, %mm6 - pfadd %mm1, %mm7 - -.Leven: - # at this point mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - - movq %mm6, (%rcx) # result - - femms - - retq - -FUNC_TAIL(ccomplex_dotprod_3dnowext) - .ident "Hand coded x86_64 3DNow!Ext assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.cc b/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.cc deleted file mode 100644 index a6f3922117..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_complex.h> -#include "ccomplex_dotprod_generic.h" - -#include <iostream> - -void -ccomplex_dotprod_generic (const float *input, - const float *taps, unsigned n_2_ccomplex_blocks, - float *result) -{ - gr_complex sum0(0,0); - gr_complex sum1(0,0); - - std::cerr << "Blah!!!\n"; - do { - const gr_complex tap0(taps[0], taps[1]); - const gr_complex tap1(taps[2], taps[3]); - const gr_complex input0(input[0], input[1]); - const gr_complex input1(input[2], input[3]); - - sum0 += input0 * tap0; - sum1 += input1 * tap1; - - input += 8; - taps += 8; - - } while (--n_2_ccomplex_blocks != 0); - - - sum0 += sum1; - result[0] = sum0.real(); - result[1] = sum0.imag(); -} diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.h b/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.h deleted file mode 100644 index c7d761c079..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _CCOMPLEX_DOTPROD_GENERIC_H_ -#define _CCOMPLEX_DOTPROD_GENERIC_H_ - -#include <gr_core_api.h> - -GR_CORE_API void -ccomplex_dotprod_generic (const float *input, - const float *taps, unsigned n_2_ccomplex_blocks, - float *result); - - -#endif /* _CCOMPLEX_DOTPROD_GENERIC_H_ */ diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_sse.S b/gnuradio-core/src/lib/filter/ccomplex_dotprod_sse.S deleted file mode 100644 index 3d16c352ec..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_sse.S +++ /dev/null @@ -1,198 +0,0 @@ -# -# Copyright 2002 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_ccomplex_blocks is != 0 -# -# -# ccomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_ccomplex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0] - input[1] * taps[1]; -# sum1 += input[0] * taps[1] + input[1] * taps[0]; -# sum2 += input[2] * taps[2] - input[3] * taps[3]; -# sum3 += input[2] * taps[3] + input[3] * taps[2]; -# -# input += 4; -# taps += 4; -# -# } while (--n_2_ccomplex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - .file "ccomplex_dotprod_sse.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(ccomplex_dotprod_sse) - DEF_FUNC_HEAD(ccomplex_dotprod_sse) -GLOB_SYMB(ccomplex_dotprod_sse): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx # n_2_ccomplex_blocks - - xorps %xmm6, %xmm6 # zero accumulators - - movaps 0(%eax), %xmm0 - - xorps %xmm7, %xmm7 # zero accumulators - - movaps 0(%edx), %xmm2 - - shrl $1, %ecx # ecx = n_2_ccomplex_blocks / 2 - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - -# complex prod: C += A * B, w/ temp Z & Y (or B), xmmPN=$0x8000000080000000 -# -# movaps (%eax), %xmmA -# movaps (%edx), %xmmB -# -# movaps %xmmA, %xmmZ -# shufps $0xb1, %xmmZ, %xmmZ # swap internals -# -# mulps %xmmB, %xmmA -# mulps %xmmZ, %xmmB -# -# # SSE replacement for: pfpnacc %xmmB, %xmmA -# xorps %xmmPN, %xmmA -# movaps %xmmA, %xmmZ -# unpcklps %xmmB, %xmmA -# unpckhps %xmmB, %xmmZ -# movaps %xmmZ, %xmmY -# shufps $0x44, %xmmA, %xmmZ # b01000100 -# shufps $0xee, %xmmY, %xmmA # b11101110 -# addps %xmmZ, %xmmA -# -# addps %xmmA, %xmmC - -# A=xmm0, B=xmm2, Z=xmm4 -# A'=xmm1, B'=xmm3, Z'=xmm5 - - movaps 16(%eax), %xmm1 - - movaps %xmm0, %xmm4 - mulps %xmm2, %xmm0 - - shufps $0xb1, %xmm4, %xmm4 # swap internals - movaps 16(%edx), %xmm3 - movaps %xmm1, %xmm5 - addps %xmm0, %xmm6 - mulps %xmm3, %xmm1 - shufps $0xb1, %xmm5, %xmm5 # swap internals - addps %xmm1, %xmm6 - mulps %xmm4, %xmm2 - movaps 32(%eax), %xmm0 - addps %xmm2, %xmm7 - mulps %xmm5, %xmm3 - - addl $32, %eax - - movaps 32(%edx), %xmm2 - addps %xmm3, %xmm7 - - addl $32, %edx - - - -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Let's sse if original n_2_ccomplex_blocks was odd. - # If so, we've got 2 more taps to do. - - movl 16(%ebp), %ecx # n_2_ccomplex_blocks - andl $1, %ecx - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0/mm2 preloaded - # from the main loop. - - movaps %xmm0, %xmm4 - mulps %xmm2, %xmm0 - shufps $0xb1, %xmm4, %xmm4 # swap internals - addps %xmm0, %xmm6 - mulps %xmm4, %xmm2 - addps %xmm2, %xmm7 - - -.Leven: - # neg inversor - xorps %xmm1, %xmm1 - movl $0x80000000, 16(%ebp) - movss 16(%ebp), %xmm1 - shufps $0x11, %xmm1, %xmm1 # b00010001 # 0 -0 0 -0 - - # pfpnacc - xorps %xmm1, %xmm6 - - movaps %xmm6, %xmm2 - unpcklps %xmm7, %xmm6 - unpckhps %xmm7, %xmm2 - movaps %xmm2, %xmm3 - shufps $0x44, %xmm6, %xmm2 # b01000100 - shufps $0xee, %xmm3, %xmm6 # b11101110 - addps %xmm2, %xmm6 - - # xmm6 = r1 i2 r3 i4 - movl 20(%ebp), %eax # @result - movhlps %xmm6, %xmm4 # xmm4 = r3 i4 ?? ?? - addps %xmm4, %xmm6 # xmm6 = r1+r3 i2+i4 ?? ?? - movlps %xmm6, (%eax) # store low 2x32 bits (complex) to memory - - popl %ebp - ret - -FUNC_TAIL(ccomplex_dotprod_sse) - .ident "Hand coded x86 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_sse64.S b/gnuradio-core/src/lib/filter/ccomplex_dotprod_sse64.S deleted file mode 100644 index 95ac3dac34..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_sse64.S +++ /dev/null @@ -1,195 +0,0 @@ -# -# Copyright 2002,2005 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_ccomplex_blocks is != 0 -# -# -# ccomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_ccomplex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0] - input[1] * taps[1]; -# sum1 += input[0] * taps[1] + input[1] * taps[0]; -# sum2 += input[2] * taps[2] - input[3] * taps[3]; -# sum3 += input[2] * taps[3] + input[3] * taps[2]; -# -# input += 4; -# taps += 4; -# -# } while (--n_2_ccomplex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - - .file "ccomplex_dotprod_sse64.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(ccomplex_dotprod_sse) - DEF_FUNC_HEAD(ccomplex_dotprod_sse) -GLOB_SYMB(ccomplex_dotprod_sse): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - xorps %xmm6, %xmm6 # zero accumulators - - movaps 0(%rdi), %xmm0 - - xorps %xmm7, %xmm7 # zero accumulators - - movaps 0(%rsi), %xmm2 - - shr $1, %rax # rax = n_2_ccomplex_blocks / 2 - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - -# complex prod: C += A * B, w/ temp Z & Y (or B), xmmPN=$0x8000000080000000 -# -# movaps (%rdi), %xmmA -# movaps (%rsi), %xmmB -# -# movaps %xmmA, %xmmZ -# shufps $0xb1, %xmmZ, %xmmZ # swap internals -# -# mulps %xmmB, %xmmA -# mulps %xmmZ, %xmmB -# -# # SSE replacement for: pfpnacc %xmmB, %xmmA -# xorps %xmmPN, %xmmA -# movaps %xmmA, %xmmZ -# unpcklps %xmmB, %xmmA -# unpckhps %xmmB, %xmmZ -# movaps %xmmZ, %xmmY -# shufps $0x44, %xmmA, %xmmZ # b01000100 -# shufps $0xee, %xmmY, %xmmA # b11101110 -# addps %xmmZ, %xmmA -# -# addps %xmmA, %xmmC - -# A=xmm0, B=xmm2, Z=xmm4 -# A'=xmm1, B'=xmm3, Z'=xmm5 - - movaps 16(%rdi), %xmm1 - - movaps %xmm0, %xmm4 - mulps %xmm2, %xmm0 - - shufps $0xb1, %xmm4, %xmm4 # swap internals - movaps 16(%rsi), %xmm3 - movaps %xmm1, %xmm5 - addps %xmm0, %xmm6 - mulps %xmm3, %xmm1 - shufps $0xb1, %xmm5, %xmm5 # swap internals - addps %xmm1, %xmm6 - mulps %xmm4, %xmm2 - movaps 32(%rdi), %xmm0 - addps %xmm2, %xmm7 - mulps %xmm5, %xmm3 - - add $32, %rdi - - movaps 32(%rsi), %xmm2 - addps %xmm3, %xmm7 - - add $32, %rsi - - - -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Let's sse if original n_2_ccomplex_blocks was odd. - # If so, we've got 2 more taps to do. - - and $1, %rdx - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0/mm2 preloaded - # from the main loop. - - movaps %xmm0, %xmm4 - mulps %xmm2, %xmm0 - shufps $0xb1, %xmm4, %xmm4 # swap internals - addps %xmm0, %xmm6 - mulps %xmm4, %xmm2 - addps %xmm2, %xmm7 - - -.Leven: - # neg inversor - xorps %xmm1, %xmm1 - movl $0x80000000, -8(%rsp) - movss -8(%rsp), %xmm1 - shufps $0x11, %xmm1, %xmm1 # b00010001 # 0 -0 0 -0 - - # pfpnacc - xorps %xmm1, %xmm6 - - movaps %xmm6, %xmm2 - unpcklps %xmm7, %xmm6 - unpckhps %xmm7, %xmm2 - movaps %xmm2, %xmm3 - shufps $0x44, %xmm6, %xmm2 # b01000100 - shufps $0xee, %xmm3, %xmm6 # b11101110 - addps %xmm2, %xmm6 - - # xmm6 = r1 i2 r3 i4 - movhlps %xmm6, %xmm4 # xmm4 = r3 i4 ?? ?? - addps %xmm4, %xmm6 # xmm6 = r1+r3 i2+i4 ?? ?? - movlps %xmm6, (%rcx) # store low 2x32 bits (complex) to memory - - retq - -FUNC_TAIL(ccomplex_dotprod_sse) - .ident "Hand coded x86_64 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_x86.h b/gnuradio-core/src/lib/filter/ccomplex_dotprod_x86.h deleted file mode 100644 index ebb63c2587..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_x86.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _CCOMPLEX_DOTPROD_X86_H_ -#define _CCOMPLEX_DOTPROD_X86_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -void -ccomplex_dotprod_3dnow (const float *input, - const float *taps, unsigned n_2_ccomplex_blocks, float *result); - -void -ccomplex_dotprod_3dnowext (const float *input, - const float *taps, unsigned n_2_ccomplex_blocks, float *result); - -void -ccomplex_dotprod_sse (const float *input, - const float *taps, unsigned n_2_ccomplex_blocks, float *result); - -#ifdef __cplusplus -} -#endif - -#endif /* _CCOMPLEX_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_3dnow.S b/gnuradio-core/src/lib/filter/complex_dotprod_3dnow.S deleted file mode 100644 index be49bb863f..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_3dnow.S +++ /dev/null @@ -1,192 +0,0 @@ -# -# Copyright 2002 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# complex_dotprod_generic (const short *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -#include "assembly.h" - - .file "complex_dotprod_3dnow.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(complex_dotprod_3dnow) - DEF_FUNC_HEAD(complex_dotprod_3dnow) -GLOB_SYMB(complex_dotprod_3dnow): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - - shrl $1, %ecx # ecx = n_2_complex_blocks / 2 - - # pshufw & pi2fw - pxor %mm0, %mm0 - punpcklwd 0(%eax), %mm0 - psrad $16, %mm0 - punpckldq %mm0, %mm0 - pi2fd %mm0, %mm0 - - pxor %mm1, %mm1 - punpcklwd 0(%eax), %mm1 - psrad $16, %mm1 - punpckhdq %mm1, %mm1 - pi2fd %mm1, %mm1 - - pxor %mm2, %mm2 - pxor %mm3, %mm3 - - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%edx), %mm0 - pfadd %mm2, %mm6 - - pxor %mm2, %mm2 - punpcklwd 4(%eax), %mm2 - psrad $16, %mm2 - punpckldq %mm2, %mm2 - - pfmul 8(%edx), %mm1 - pfadd %mm3, %mm7 - pi2fd %mm2, %mm2 - - pxor %mm3, %mm3 - punpcklwd 4(%eax), %mm3 - psrad $16, %mm3 - punpckhdq %mm3, %mm3 - - pfmul 16(%edx), %mm2 - pfadd %mm0, %mm4 - pi2fd %mm3, %mm3 - - pxor %mm0, %mm0 - punpcklwd 8(%eax), %mm0 - psrad $16, %mm0 - punpckldq %mm0, %mm0 - - pfmul 24(%edx), %mm3 - pfadd %mm1, %mm5 - - pxor %mm1, %mm1 - punpcklwd 8(%eax), %mm1 - psrad $16, %mm1 - punpckhdq %mm1, %mm1 - - pi2fd %mm0, %mm0 - pi2fd %mm1, %mm1 - -#TODO: add prefetch - - addl $32, %edx - addl $8, %eax - -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_2_complex_blocks was odd. If so, we've got 2 more - # taps to do. - - movl 16(%ebp), %ecx - pfadd %mm2, %mm6 - andl $1, %ecx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%edx), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%edx), %mm1 - pfadd %mm1, %mm5 - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - - movl 20(%ebp), %eax # result - - pfadd %mm6, %mm4 - - movq %mm4, (%eax) - femms - - popl %ebp - ret - -FUNC_TAIL(complex_dotprod_3dnow) - .ident "Hand coded x86 3DNow! assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_3dnow64.S b/gnuradio-core/src/lib/filter/complex_dotprod_3dnow64.S deleted file mode 100644 index f1c8130786..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_3dnow64.S +++ /dev/null @@ -1,187 +0,0 @@ -# -# Copyright 2002,2005 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# complex_dotprod_generic (const short *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -#include "assembly.h" - - - .file "complex_dotprod_3dnow64.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(complex_dotprod_3dnow) - DEF_FUNC_HEAD(complex_dotprod_3dnow) -GLOB_SYMB(complex_dotprod_3dnow): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - - shr $1, %rax # rax = n_2_complex_blocks / 2 - - # pshufw & pi2fw - pxor %mm0, %mm0 - punpcklwd 0(%rdi), %mm0 - psrad $16, %mm0 - punpckldq %mm0, %mm0 - pi2fd %mm0, %mm0 - - pxor %mm1, %mm1 - punpcklwd 0(%rdi), %mm1 - psrad $16, %mm1 - punpckhdq %mm1, %mm1 - pi2fd %mm1, %mm1 - - pxor %mm2, %mm2 - pxor %mm3, %mm3 - - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%rsi), %mm0 - pfadd %mm2, %mm6 - - pxor %mm2, %mm2 - punpcklwd 4(%rdi), %mm2 - psrad $16, %mm2 - punpckldq %mm2, %mm2 - - pfmul 8(%rsi), %mm1 - pfadd %mm3, %mm7 - pi2fd %mm2, %mm2 - - pxor %mm3, %mm3 - punpcklwd 4(%rdi), %mm3 - psrad $16, %mm3 - punpckhdq %mm3, %mm3 - - pfmul 16(%rsi), %mm2 - pfadd %mm0, %mm4 - pi2fd %mm3, %mm3 - - pxor %mm0, %mm0 - punpcklwd 8(%rdi), %mm0 - psrad $16, %mm0 - punpckldq %mm0, %mm0 - - pfmul 24(%rsi), %mm3 - pfadd %mm1, %mm5 - - pxor %mm1, %mm1 - punpcklwd 8(%rdi), %mm1 - psrad $16, %mm1 - punpckhdq %mm1, %mm1 - - pi2fd %mm0, %mm0 - pi2fd %mm1, %mm1 - -#TODO: add prefetch - - add $32, %rsi - add $8, %rdi - -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_2_complex_blocks was odd. If so, we've got 2 more - # taps to do. - - pfadd %mm2, %mm6 - and $1, %rdx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%rsi), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%rsi), %mm1 - pfadd %mm1, %mm5 - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - pfadd %mm6, %mm4 - - movq %mm4, (%rcx) - femms - - retq - -FUNC_TAIL(complex_dotprod_3dnow) - .ident "Hand coded x86_64 3DNow! assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_3dnowext.S b/gnuradio-core/src/lib/filter/complex_dotprod_3dnowext.S deleted file mode 100644 index 52f04f10cb..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_3dnowext.S +++ /dev/null @@ -1,171 +0,0 @@ -# -# Copyright 2002 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# complex_dotprod_generic (const short *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -#include "assembly.h" - - .file "complex_dotprod_3dnowext.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(complex_dotprod_3dnowext) - DEF_FUNC_HEAD(complex_dotprod_3dnowext) -GLOB_SYMB(complex_dotprod_3dnowext): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - - shrl $1, %ecx # ecx = n_2_complex_blocks / 2 - - movd 0(%eax), %mm0 - pshufw $0x55, %mm0, %mm1 # b01010101 - pshufw $0, %mm0, %mm0 - - pxor %mm2, %mm2 - pxor %mm3, %mm3 - - pi2fw %mm1, %mm1 - pi2fw %mm0, %mm0 - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%edx), %mm0 - pfadd %mm2, %mm6 - - pshufw $0, 4(%eax), %mm2 - - pfmul 8(%edx), %mm1 - pfadd %mm3, %mm7 - pi2fw %mm2, %mm2 - - pshufw $0x55, 4(%eax), %mm3 # b01010101 - - pfmul 16(%edx), %mm2 - pi2fw %mm3, %mm3 - pfadd %mm0, %mm4 - - pshufw $0, 8(%eax), %mm0 - - pfmul 24(%edx), %mm3 - pfadd %mm1, %mm5 - - pshufw $0x55, 8(%eax), %mm1 # b01010101 - pi2fw %mm0, %mm0 - -#TODO: add prefetch - - addl $32, %edx - addl $8, %eax - pi2fw %mm1, %mm1 - -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_2_complex_blocks was odd. If so, we've got 2 more - # taps to do. - - movl 16(%ebp), %ecx - pfadd %mm2, %mm6 - andl $1, %ecx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%edx), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%edx), %mm1 - pfadd %mm1, %mm5 - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - - movl 20(%ebp), %eax # result - pfadd %mm6, %mm4 - movq %mm4, (%eax) - - femms - - popl %ebp - ret - -FUNC_TAIL(complex_dotprod_3dnowext) - .ident "Hand coded x86 3DNow!Ext assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_3dnowext64.S b/gnuradio-core/src/lib/filter/complex_dotprod_3dnowext64.S deleted file mode 100644 index 6d7ad5ad4e..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_3dnowext64.S +++ /dev/null @@ -1,168 +0,0 @@ -# -# Copyright 2002,2005 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# complex_dotprod_generic (const short *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -#include "assembly.h" - - - .file "complex_dotprod_3dnowext64.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(complex_dotprod_3dnowext) - DEF_FUNC_HEAD(complex_dotprod_3dnowext) -GLOB_SYMB(complex_dotprod_3dnowext): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - - shr $1, %rax # rax = n_2_complex_blocks / 2 - - movd 0(%rdi), %mm0 - pshufw $0x55, %mm0, %mm1 # b01010101 - pshufw $0, %mm0, %mm0 - - pxor %mm2, %mm2 - pxor %mm3, %mm3 - - pi2fw %mm1, %mm1 - pi2fw %mm0, %mm0 - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%rsi), %mm0 - pfadd %mm2, %mm6 - - pshufw $0, 4(%rdi), %mm2 - - pfmul 8(%rsi), %mm1 - pfadd %mm3, %mm7 - pi2fw %mm2, %mm2 - - pshufw $0x55, 4(%rdi), %mm3 # b01010101 - - pfmul 16(%rsi), %mm2 - pi2fw %mm3, %mm3 - pfadd %mm0, %mm4 - - pshufw $0, 8(%rdi), %mm0 - - pfmul 24(%rsi), %mm3 - pfadd %mm1, %mm5 - - pshufw $0x55, 8(%rdi), %mm1 # b01010101 - pi2fw %mm0, %mm0 - -#TODO: add prefetch - - add $32, %rsi - add $8, %rdi - pi2fw %mm1, %mm1 - -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_2_complex_blocks was odd. If so, we've got 2 more - # taps to do. - - pfadd %mm2, %mm6 - and $1, %rdx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%rsi), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%rsi), %mm1 - pfadd %mm1, %mm5 - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - - pfadd %mm6, %mm4 - movq %mm4, (%rcx) - - femms - - retq - -FUNC_TAIL(complex_dotprod_3dnowext) - .ident "Hand coded x86_64 3DNow!Ext assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_generic.cc b/gnuradio-core/src/lib/filter/complex_dotprod_generic.cc deleted file mode 100644 index 229cbe9785..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_generic.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_complex.h> -#include "complex_dotprod_generic.h" - - -void -complex_dotprod_generic (const short *input, - const float *taps, unsigned n_2_complex_blocks, - float *result) -{ - gr_complex sum0(0,0); - gr_complex sum1(0,0); - - do { - const gr_complex tap0(taps[0], taps[1]); - const gr_complex tap1(taps[2], taps[3]); - - sum0 += (float)input[0] * tap0; - sum1 += (float)input[1] * tap1; - - input += 4; - taps += 8; - - } while (--n_2_complex_blocks != 0); - - - sum0 += sum1; - result[0] = sum0.real(); - result[1] = sum0.imag(); -} diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_generic.h b/gnuradio-core/src/lib/filter/complex_dotprod_generic.h deleted file mode 100644 index 152f6e4592..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_generic.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _COMPLEX_DOTPROD_GENERIC_H_ -#define _COMPLEX_DOTPROD_GENERIC_H_ - -#include <gr_core_api.h> - -GR_CORE_API void -complex_dotprod_generic (const short *input, - const float *taps, unsigned n_2_complex_blocks, - float *result); - - -#endif /* _COMPLEX_DOTPROD_GENERIC_H_ */ diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_sse.S b/gnuradio-core/src/lib/filter/complex_dotprod_sse.S deleted file mode 100644 index fb998cc454..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_sse.S +++ /dev/null @@ -1,206 +0,0 @@ -# -# Copyright 2002 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# complex_dotprod_generic (const short *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - - .file "complex_dotprod_sse.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(complex_dotprod_sse) - DEF_FUNC_HEAD(complex_dotprod_sse) -GLOB_SYMB(complex_dotprod_sse): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx - - - # xmm0 xmm1 xmm2 xmm3 are used to hold taps and the result of mults - # xmm4 xmm5 xmm6 xmm7 are used to hold the accumulated results - - xorps %xmm4, %xmm4 # zero two accumulators - xorps %xmm5, %xmm5 # xmm5 holds zero for use below - - # first handle any non-zero remainder of (n_2_complex_blocks % 4) - - andl $0x3, %ecx - jmp .L1_test - - .p2align 4 -.Loop1: - - pxor %mm0, %mm0 - punpcklwd 0(%eax), %mm0 - psrad $16, %mm0 - cvtpi2ps %mm0, %xmm0 - shufps $0x50, %xmm0, %xmm0 - - mulps (%edx), %xmm0 - addl $0x10, %edx - addl $4, %eax - addps %xmm0, %xmm4 -.L1_test: - decl %ecx - jge .Loop1 - - - # set up for primary loop which is unrolled 4 times - - movl 16(%ebp), %ecx - movaps %xmm5, %xmm6 # zero remaining accumulators - movaps %xmm5, %xmm7 - - shrl $2, %ecx # n_2_complex_blocks / 4 - je .Lcleanup # if zero, take short path - - # finish setup and loop priming - - pxor %mm0, %mm0 - punpcklwd 0(%eax), %mm0 - psrad $16, %mm0 - cvtpi2ps %mm0, %xmm0 - shufps $0x50, %xmm0, %xmm0 - - movaps %xmm5, %xmm2 - - pxor %mm1, %mm1 - punpcklwd 4(%eax), %mm1 - psrad $16, %mm1 - cvtpi2ps %mm1, %xmm1 - shufps $0x50, %xmm1, %xmm1 - - movaps %xmm5, %xmm3 - - # we know ecx is not zero, we checked above, - # hence enter loop at top - - .p2align 4 -.Loop2: - mulps (%edx), %xmm0 - addps %xmm2, %xmm6 - - pxor %mm2, %mm2 - punpcklwd 8(%eax), %mm2 - psrad $16, %mm2 - cvtpi2ps %mm2, %xmm2 - shufps $0x50, %xmm2, %xmm2 - - mulps 0x10(%edx), %xmm1 - addps %xmm3, %xmm7 - - pxor %mm3, %mm3 - punpcklwd 12(%eax), %mm3 - psrad $16, %mm3 - cvtpi2ps %mm3, %xmm3 - shufps $0x50, %xmm3, %xmm3 - - mulps 0x20(%edx), %xmm2 - addps %xmm0, %xmm4 - - pxor %mm0, %mm0 - punpcklwd 16(%eax), %mm0 - psrad $16, %mm0 - cvtpi2ps %mm0, %xmm0 - shufps $0x50, %xmm0, %xmm0 - - mulps 0x30(%edx), %xmm3 - addps %xmm1, %xmm5 - - pxor %mm1, %mm1 - punpcklwd 20(%eax), %mm1 - psrad $16, %mm1 - cvtpi2ps %mm1, %xmm1 - shufps $0x50, %xmm1, %xmm1 - - addl $0x40, %edx - addl $0x10, %eax - decl %ecx - jne .Loop2 - - # OK, now we've done with all the multiplies, but - # we still need to handle the unaccumulated - # products in xmm2 and xmm3 - - addps %xmm2, %xmm6 - addps %xmm3, %xmm7 - - # now we want to add all accumulators into xmm4 - - addps %xmm5, %xmm4 - addps %xmm6, %xmm7 - addps %xmm7, %xmm4 - - - # At this point, xmm4 contains 2x2 partial sums. We need - # to compute a "horizontal complex add" across xmm4. - -.Lcleanup: # xmm4 = r1 i2 r3 i4 - movl 20(%ebp), %eax # @result - movhlps %xmm4, %xmm0 # xmm0 = ?? ?? r1 r2 - addps %xmm4, %xmm0 # xmm0 = ?? ?? r1+r3 i2+i4 - movlps %xmm0, (%eax) # store low 2x32 bits (complex) to memory - - emms - popl %ebp - ret - -FUNC_TAIL(complex_dotprod_sse) - .ident "Hand coded x86 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_sse64.S b/gnuradio-core/src/lib/filter/complex_dotprod_sse64.S deleted file mode 100644 index 67d3519e45..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_sse64.S +++ /dev/null @@ -1,202 +0,0 @@ -# -# Copyright 2002,2005 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# complex_dotprod_generic (const short *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - - .file "complex_dotprod_sse64.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(complex_dotprod_sse) - DEF_FUNC_HEAD(complex_dotprod_sse) -GLOB_SYMB(complex_dotprod_sse): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - - # xmm0 xmm1 xmm2 xmm3 are used to hold taps and the result of mults - # xmm4 xmm5 xmm6 xmm7 are used to hold the accumulated results - - xorps %xmm4, %xmm4 # zero two accumulators - xorps %xmm5, %xmm5 # xmm5 holds zero for use below - - # first handle any non-zero remainder of (n_2_complex_blocks % 4) - - and $0x3, %rax - jmp .L1_test - - .p2align 4 -.Loop1: - - pxor %mm0, %mm0 - punpcklwd 0(%rdi), %mm0 - psrad $16, %mm0 - cvtpi2ps %mm0, %xmm0 - shufps $0x50, %xmm0, %xmm0 - - mulps (%rsi), %xmm0 - add $0x10, %rsi - add $4, %rdi - addps %xmm0, %xmm4 -.L1_test: - dec %rax - jge .Loop1 - - - # set up for primary loop which is unrolled 4 times - - movaps %xmm5, %xmm6 # zero remaining accumulators - shr $2, %rdx # n_2_complex_blocks / 4 - movaps %xmm5, %xmm7 - - je .Lcleanup # if zero, take short path - - # finish setup and loop priming - - pxor %mm0, %mm0 - punpcklwd 0(%rdi), %mm0 - psrad $16, %mm0 - cvtpi2ps %mm0, %xmm0 - shufps $0x50, %xmm0, %xmm0 - - movaps %xmm5, %xmm2 - - pxor %mm1, %mm1 - punpcklwd 4(%rdi), %mm1 - psrad $16, %mm1 - cvtpi2ps %mm1, %xmm1 - shufps $0x50, %xmm1, %xmm1 - - movaps %xmm5, %xmm3 - - # we know rax is not zero, we checked above, - # hence enter loop at top - - .p2align 4 -.Loop2: - mulps (%rsi), %xmm0 - addps %xmm2, %xmm6 - - pxor %mm2, %mm2 - punpcklwd 8(%rdi), %mm2 - psrad $16, %mm2 - cvtpi2ps %mm2, %xmm2 - shufps $0x50, %xmm2, %xmm2 - - mulps 0x10(%rsi), %xmm1 - addps %xmm3, %xmm7 - - pxor %mm3, %mm3 - punpcklwd 12(%rdi), %mm3 - psrad $16, %mm3 - cvtpi2ps %mm3, %xmm3 - shufps $0x50, %xmm3, %xmm3 - - mulps 0x20(%rsi), %xmm2 - addps %xmm0, %xmm4 - - pxor %mm0, %mm0 - punpcklwd 16(%rdi), %mm0 - psrad $16, %mm0 - cvtpi2ps %mm0, %xmm0 - shufps $0x50, %xmm0, %xmm0 - - mulps 0x30(%rsi), %xmm3 - addps %xmm1, %xmm5 - - pxor %mm1, %mm1 - punpcklwd 20(%rdi), %mm1 - psrad $16, %mm1 - cvtpi2ps %mm1, %xmm1 - shufps $0x50, %xmm1, %xmm1 - - add $0x40, %rsi - add $0x10, %rdi - dec %rdx - jne .Loop2 - - # OK, now we've done with all the multiplies, but - # we still need to handle the unaccumulated - # products in xmm2 and xmm3 - - addps %xmm2, %xmm6 - addps %xmm3, %xmm7 - - # now we want to add all accumulators into xmm4 - - addps %xmm5, %xmm4 - addps %xmm6, %xmm7 - addps %xmm7, %xmm4 - - - # At this point, xmm4 contains 2x2 partial sums. We need - # to compute a "horizontal complex add" across xmm4. - -.Lcleanup: # xmm4 = r1 i2 r3 i4 - movhlps %xmm4, %xmm0 # xmm0 = ?? ?? r1 r2 - addps %xmm4, %xmm0 # xmm0 = ?? ?? r1+r3 i2+i4 - movlps %xmm0, (%rcx) # store low 2x32 bits (complex) to memory - - emms - retq - -FUNC_TAIL(complex_dotprod_sse) - .ident "Hand coded x86_64 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_x86.h b/gnuradio-core/src/lib/filter/complex_dotprod_x86.h deleted file mode 100644 index aad9fb5e9d..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_x86.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _COMPLEX_DOTPROD_X86_H_ -#define _COMPLEX_DOTPROD_X86_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -void -complex_dotprod_3dnow (const short *input, - const float *taps, unsigned n_2_complex_blocks, float *result); - -void -complex_dotprod_3dnowext (const short *input, - const float *taps, unsigned n_2_complex_blocks, float *result); - -void -complex_dotprod_sse (const short *input, - const float *taps, unsigned n_2_complex_blocks, float *result); - -#ifdef __cplusplus -} -#endif - -#endif /* _COMPLEX_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c b/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c deleted file mode 100644 index c125b49b3c..0000000000 --- a/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009,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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dotprod_ccf_armv7_a.h> - -/*! - * \param x any value - * \param pow2 must be a power of 2 - * \returns \p x rounded down to a multiple of \p pow2. - */ -static inline size_t -gr_p2_round_down(size_t x, size_t pow2) -{ - return x & -pow2; -} - - -#ifndef HAVE_MFPU_NEON - -void -dotprod_ccf_armv7_a(const float *a, const float *b, float *res, size_t n) -{ - size_t i; - res[0] = 0; - res[1] = 0; - - for (i = 0; i < n; i++){ - res[0] += a[2*i] * b[i]; - res[1] += a[2*i+1] * b[i]; - } -} - -#else - -/* - * preconditions: - * - * n > 0 and a multiple of 4 - * a 4-byte aligned - * b 16-byte aligned - */ -void -dotprod_ccf_armv7_a(const float *a, const float *b, float *res, size_t n) -{ - - asm volatile( - "vmov.f32 q14, #0.0 \n\t" - "vmov.f32 q15, #0.0 \n\t" - "1: \n\t" - "subs %2, %2, #4 \n\t" - "vld2.f32 {q0-q1}, [%0]! \n\t" - "vld1.f32 {q2}, [%1]! \n\t" - "vmla.f32 q14, q0, q2 \n\t" - "vmla.f32 q15, q1, q2 \n\t" - "bgt 1b \n\t" - "vpadd.f32 d0, d28, d29 \n\t" - "vpadd.f32 d1, d30, d31 \n\t" - "vpadd.f32 d0, d0, d1 \n\t" - "vst1.f32 {d0}, [%3] \n\t" - - : "+&r"(a), "+&r"(b), "+&r"(n) - : "r"(res) - : "memory", "d0", "d1", "d2", "d3", "d4", "d5", - "d28", "d29", "d30", "d31" ); -} - - -#endif diff --git a/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.h b/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.h deleted file mode 100644 index e42d6d10be..0000000000 --- a/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009,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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_DOTPROD_CCF_ARMV7_A_H -#define INCLUDED_DOTPROD_CCF_ARMV7_A_H - -#include <stddef.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/*! - * <pre> - * - * preconditions: - * - * n > 0 and a multiple of 4 - * a 4-byte aligned - * b 16-byte aligned - * - * </pre> - */ -void dotprod_ccf_armv7_a(const float *a, const float *b, float *res, size_t n); - -#ifdef __cplusplus -} -#endif - -#endif /* INCLUDED_DOTPROD_CCF_ARMV7_A_H */ diff --git a/gnuradio-core/src/lib/filter/dotprod_fff_altivec.c b/gnuradio-core/src/lib/filter/dotprod_fff_altivec.c deleted file mode 100644 index 53d6df714f..0000000000 --- a/gnuradio-core/src/lib/filter/dotprod_fff_altivec.c +++ /dev/null @@ -1,162 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <dotprod_fff_altivec.h> -#include <gr_altivec.h> - -/*! - * \param x any value - * \param pow2 must be a power of 2 - * \returns \p x rounded down to a multiple of \p pow2. - */ -static inline size_t -gr_p2_round_down(size_t x, size_t pow2) -{ - return x & -pow2; -} - - -#if 0 - -float -dotprod_fff_altivec(const float *a, const float *b, size_t n) -{ - float sum = 0; - for (size_t i = 0; i < n; i++){ - sum += a[i] * b[i]; - } - return sum; -} - -#else - -/* - * preconditions: - * - * n > 0 and a multiple of 4 - * a 4-byte aligned - * b 16-byte aligned - */ -float -dotprod_fff_altivec(const float *_a, const float *_b, size_t n) -{ - const vec_float4 *a = (const vec_float4 *) _a; - const vec_float4 *b = (const vec_float4 *) _b; - - static const size_t UNROLL_CNT = 4; - - n = gr_p2_round_down(n, 4); - size_t loop_cnt = n / (UNROLL_CNT * FLOATS_PER_VEC); - size_t nleft = n % (UNROLL_CNT * FLOATS_PER_VEC); - - // printf("n = %zd, loop_cnt = %zd, nleft = %zd\n", n, loop_cnt, nleft); - - // Used with vperm to build a* from p* - vec_uchar16 lvsl_a = vec_lvsl(0, _a); - - vec_float4 p0, p1, p2, p3; - vec_float4 a0, a1, a2, a3; - vec_float4 b0, b1, b2, b3; - vec_float4 acc0 = {0, 0, 0, 0}; - vec_float4 acc1 = {0, 0, 0, 0}; - vec_float4 acc2 = {0, 0, 0, 0}; - vec_float4 acc3 = {0, 0, 0, 0}; - - // wind in - - p0 = vec_ld(0*VS, a); - p1 = vec_ld(1*VS, a); - p2 = vec_ld(2*VS, a); - p3 = vec_ld(3*VS, a); - a += UNROLL_CNT; - - a0 = vec_perm(p0, p1, lvsl_a); - b0 = vec_ld(0*VS, b); - p0 = vec_ld(0*VS, a); - - size_t i; - for (i = 0; i < loop_cnt; i++){ - - a1 = vec_perm(p1, p2, lvsl_a); - b1 = vec_ld(1*VS, b); - p1 = vec_ld(1*VS, a); - acc0 = vec_madd(a0, b0, acc0); - - a2 = vec_perm(p2, p3, lvsl_a); - b2 = vec_ld(2*VS, b); - p2 = vec_ld(2*VS, a); - acc1 = vec_madd(a1, b1, acc1); - - a3 = vec_perm(p3, p0, lvsl_a); - b3 = vec_ld(3*VS, b); - p3 = vec_ld(3*VS, a); - acc2 = vec_madd(a2, b2, acc2); - - a += UNROLL_CNT; - b += UNROLL_CNT; - - a0 = vec_perm(p0, p1, lvsl_a); - b0 = vec_ld(0*VS, b); - p0 = vec_ld(0*VS, a); - acc3 = vec_madd(a3, b3, acc3); - } - - /* - * The compiler ought to be able to figure out that 0, 4, 8 and 12 - * are the only possible values for nleft. - */ - switch (nleft){ - case 0: - break; - - case 4: - acc0 = vec_madd(a0, b0, acc0); - break; - - case 8: - a1 = vec_perm(p1, p2, lvsl_a); - b1 = vec_ld(1*VS, b); - acc0 = vec_madd(a0, b0, acc0); - acc1 = vec_madd(a1, b1, acc1); - break; - - case 12: - a1 = vec_perm(p1, p2, lvsl_a); - b1 = vec_ld(1*VS, b); - acc0 = vec_madd(a0, b0, acc0); - a2 = vec_perm(p2, p3, lvsl_a); - b2 = vec_ld(2*VS, b); - acc1 = vec_madd(a1, b1, acc1); - acc2 = vec_madd(a2, b2, acc2); - break; - } - - acc0 = acc0 + acc1; - acc2 = acc2 + acc3; - acc0 = acc0 + acc2; - - return horizontal_add_f(acc0); -} - -#endif diff --git a/gnuradio-core/src/lib/filter/dotprod_fff_altivec.h b/gnuradio-core/src/lib/filter/dotprod_fff_altivec.h deleted file mode 100644 index a52370d56f..0000000000 --- a/gnuradio-core/src/lib/filter/dotprod_fff_altivec.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_DOTPROD_FFF_ALTIVEC_H -#define INCLUDED_DOTPROD_FFF_ALTIVEC_H - -#include <gr_core_api.h> -#include <stddef.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/*! - * <pre> - * - * preconditions: - * - * n > 0 and a multiple of 4 - * a 4-byte aligned - * b 16-byte aligned - * - * </pre> - */ -float -dotprod_fff_altivec(const float *a, const float *b, size_t n); - -#ifdef __cplusplus -} -#endif - - -#endif /* INCLUDED_DOTPROD_FFF_ALTIVEC_H */ diff --git a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c b/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c deleted file mode 100644 index 23bbef0338..0000000000 --- a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dotprod_fff_armv7_a.h> - -/*! - * \param x any value - * \param pow2 must be a power of 2 - * \returns \p x rounded down to a multiple of \p pow2. - */ -static inline size_t -gr_p2_round_down(size_t x, size_t pow2) -{ - return x & -pow2; -} - - -#ifndef HAVE_MFPU_NEON - -float -dotprod_fff_armv7_a(const float *a, const float *b, size_t n) -{ - float sum = 0; - size_t i; - for (i = 0; i < n; i++){ - sum += a[i] * b[i]; - } - return sum; -} - -#else - -/* - * preconditions: - * - * n > 0 and a multiple of 4 - * a 4-byte aligned - * b 16-byte aligned - */ -float -dotprod_fff_armv7_a(const float *a, const float *b, size_t n) -{ - float s = 0; - - asm ("vmov.f32 q8, #0.0 \n\t" - "vmov.f32 q9, #0.0 \n\t" - "1: \n\t" - "subs %3, %3, #8 \n\t" - "vld1.32 {d0,d1,d2,d3}, [%1]! \n\t" - "vld1.32 {d4,d5,d6,d7}, [%2]! \n\t" - "vmla.f32 q8, q0, q2 \n\t" - "vmla.f32 q9, q1, q3 \n\t" - "bgt 1b \n\t" - "vadd.f32 q8, q8, q9 \n\t" - "vpadd.f32 d0, d16, d17 \n\t" - "vadd.f32 %0, s0, s1 \n\t" - : "=w"(s), "+r"(a), "+r"(b), "+r"(n) - :: "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", - "d16", "d17", "d18", "d19"); - - return s; - -} - -#endif diff --git a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.h b/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.h deleted file mode 100644 index 6cea45cea3..0000000000 --- a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_DOTPROD_FFF_ARMV7_A_H -#define INCLUDED_DOTPROD_FFF_ARMV7_A_H - -#include <gr_core_api.h> -#include <stddef.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/*! - * <pre> - * - * preconditions: - * - * n > 0 and a multiple of 4 - * a 4-byte aligned - * b 16-byte aligned - * - * </pre> - */ -float -dotprod_fff_armv7_a(const float *a, const float *b, size_t n); - -#ifdef __cplusplus -} -#endif - - -#endif /* INCLUDED_DOTPROD_FFF_ARMV7_A_H */ diff --git a/gnuradio-core/src/lib/filter/fcomplex_dotprod_3dnow.S b/gnuradio-core/src/lib/filter/fcomplex_dotprod_3dnow.S deleted file mode 100644 index 536e46dc16..0000000000 --- a/gnuradio-core/src/lib/filter/fcomplex_dotprod_3dnow.S +++ /dev/null @@ -1,176 +0,0 @@ -# -# Copyright 2002 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# fcomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -#include "assembly.h" - - - .file "fcomplex_dotprod_3dnow.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(fcomplex_dotprod_3dnow) - DEF_FUNC_HEAD(fcomplex_dotprod_3dnow) -GLOB_SYMB(fcomplex_dotprod_3dnow): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - shrl $1, %ecx # ecx = n_2_complex_blocks / 2 - - movq 0(%eax), %mm0 - - pxor %mm2, %mm2 - pxor %mm3, %mm3 - - movq %mm0, %mm1 - punpckldq %mm0, %mm0 - punpckhdq %mm1, %mm1 - - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%edx), %mm0 - pfadd %mm2, %mm6 - - movq 8(%eax), %mm2 - - pfadd %mm3, %mm7 - - pfmul 8(%edx), %mm1 - - movq %mm2, %mm3 - punpckldq %mm2, %mm2 - punpckhdq %mm3, %mm3 - - - pfmul 16(%edx), %mm2 - pfadd %mm0, %mm4 - - movq 16(%eax), %mm0 - - pfadd %mm1, %mm5 - - movq %mm0, %mm1 - punpckldq %mm0, %mm0 - - pfmul 24(%edx), %mm3 - - punpckhdq %mm1, %mm1 - - -#TODO: add prefetch? - - addl $32, %edx - addl $16, %eax - -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_2_complex_blocks was odd. If so, we've got 2 more - # taps to do. - - movl 16(%ebp), %ecx - pfadd %mm2, %mm6 - andl $1, %ecx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%edx), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%edx), %mm1 - pfadd %mm1, %mm5 - - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - - movl 20(%ebp), %eax # result - - pfadd %mm6, %mm4 - - movq %mm4, (%eax) - femms - - popl %ebp - ret - -FUNC_TAIL(fcomplex_dotprod_3dnow) - .ident "Hand coded x86 3DNow! assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/fcomplex_dotprod_3dnow64.S b/gnuradio-core/src/lib/filter/fcomplex_dotprod_3dnow64.S deleted file mode 100644 index d9a695949b..0000000000 --- a/gnuradio-core/src/lib/filter/fcomplex_dotprod_3dnow64.S +++ /dev/null @@ -1,170 +0,0 @@ -# -# Copyright 2002,2005 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# fcomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -#include "assembly.h" - - - .file "fcomplex_dotprod_3dnow64.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(fcomplex_dotprod_3dnow) - DEF_FUNC_HEAD(fcomplex_dotprod_3dnow) -GLOB_SYMB(fcomplex_dotprod_3dnow): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - shr $1, %rax # rax = n_2_complex_blocks / 2 - - movq 0(%rdi), %mm0 - - pxor %mm2, %mm2 - pxor %mm3, %mm3 - - movq %mm0, %mm1 - punpckldq %mm0, %mm0 - punpckhdq %mm1, %mm1 - - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%rsi), %mm0 - pfadd %mm2, %mm6 - - movq 8(%rdi), %mm2 - - pfadd %mm3, %mm7 - - pfmul 8(%rsi), %mm1 - - movq %mm2, %mm3 - punpckldq %mm2, %mm2 - punpckhdq %mm3, %mm3 - - - pfmul 16(%rsi), %mm2 - pfadd %mm0, %mm4 - - movq 16(%rdi), %mm0 - - pfadd %mm1, %mm5 - - movq %mm0, %mm1 - punpckldq %mm0, %mm0 - - pfmul 24(%rsi), %mm3 - - punpckhdq %mm1, %mm1 - - -#TODO: add prefetch? - - add $32, %rsi - add $16, %rdi - -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_2_complex_blocks was odd. If so, we've got 2 more - # taps to do. - - pfadd %mm2, %mm6 - and $1, %rdx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%rsi), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%rsi), %mm1 - pfadd %mm1, %mm5 - - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - pfadd %mm6, %mm4 - - movq %mm4, (%rcx) # result - femms - - retq - -FUNC_TAIL(fcomplex_dotprod_3dnow) - .ident "Hand coded x86_64 3DNow! assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/fcomplex_dotprod_sse.S b/gnuradio-core/src/lib/filter/fcomplex_dotprod_sse.S deleted file mode 100644 index 4c5e956f27..0000000000 --- a/gnuradio-core/src/lib/filter/fcomplex_dotprod_sse.S +++ /dev/null @@ -1,188 +0,0 @@ -# -# Copyright 2002 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# fcomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - - .file "fcomplex_dotprod_sse.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(fcomplex_dotprod_sse) - DEF_FUNC_HEAD(fcomplex_dotprod_sse) -GLOB_SYMB(fcomplex_dotprod_sse): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx - - - # xmm0 xmm1 xmm2 xmm3 are used to hold taps and the result of mults - # xmm4 xmm5 xmm6 xmm7 are used to hold the accumulated results - - xorps %xmm4, %xmm4 # zero two accumulators - xorps %xmm5, %xmm5 # xmm5 holds zero for use below - - # first handle any non-zero remainder of (n_2_complex_blocks % 4) - - andl $0x3, %ecx - jmp .L1_test - - .p2align 4 -.Loop1: - - movlps 0(%eax), %xmm0 - shufps $0x50, %xmm0, %xmm0 # b01010000 - - mulps (%edx), %xmm0 - addl $0x10, %edx - addl $8, %eax - addps %xmm0, %xmm4 -.L1_test: - decl %ecx - jge .Loop1 - - - # set up for primary loop which is unrolled 4 times - - movl 16(%ebp), %ecx - movaps %xmm5, %xmm6 # zero remaining accumulators - movaps %xmm5, %xmm7 - - shrl $2, %ecx # n_2_complex_blocks / 4 - je .Lcleanup # if zero, take short path - - # finish setup and loop priming - - movlps 0(%eax), %xmm0 - - movaps %xmm5, %xmm2 - movaps %xmm5, %xmm3 - - movlps 8(%eax), %xmm1 - shufps $0x50, %xmm0, %xmm0 - - shufps $0x50, %xmm1, %xmm1 - - # we know ecx is not zero, we checked above, - # hence enter loop at top - - .p2align 4 -.Loop2: - addps %xmm2, %xmm6 - movlps 0x10(%eax), %xmm2 - - addps %xmm3, %xmm7 - - mulps (%edx), %xmm0 - - movlps 0x18(%eax), %xmm3 - shufps $0x50, %xmm2, %xmm2 - - mulps 0x10(%edx), %xmm1 - - shufps $0x50, %xmm3, %xmm3 - - addps %xmm0, %xmm4 - movlps 0x20(%eax), %xmm0 - - addps %xmm1, %xmm5 - - mulps 0x20(%edx), %xmm2 - - movlps 0x28(%eax), %xmm1 - shufps $0x50, %xmm0, %xmm0 - - mulps 0x30(%edx), %xmm3 - - shufps $0x50, %xmm1, %xmm1 - - addl $0x40, %edx - addl $0x20, %eax - decl %ecx - jne .Loop2 - - # OK, now we've done with all the multiplies, but - # we still need to handle the unaccumulated - # products in xmm2 and xmm3 - - addps %xmm2, %xmm6 - addps %xmm3, %xmm7 - - # now we want to add all accumulators into xmm4 - - addps %xmm5, %xmm4 - addps %xmm6, %xmm7 - addps %xmm7, %xmm4 - - - # At this point, xmm4 contains 2x2 partial sums. We need - # to compute a "horizontal complex add" across xmm4. - -.Lcleanup: # xmm4 = r1 i2 r3 i4 - movl 20(%ebp), %eax # @result - movhlps %xmm4, %xmm0 # xmm0 = ?? ?? r1 r2 - addps %xmm4, %xmm0 # xmm0 = ?? ?? r1+r3 i2+i4 - movlps %xmm0, (%eax) # store low 2x32 bits (complex) to memory - - popl %ebp - ret - -FUNC_TAIL(fcomplex_dotprod_sse) - .ident "Hand coded x86 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/fcomplex_dotprod_sse64.S b/gnuradio-core/src/lib/filter/fcomplex_dotprod_sse64.S deleted file mode 100644 index 53a4f25e0f..0000000000 --- a/gnuradio-core/src/lib/filter/fcomplex_dotprod_sse64.S +++ /dev/null @@ -1,183 +0,0 @@ -# -# Copyright 2002,2005 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# fcomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - - .file "fcomplex_dotprod_sse64.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(fcomplex_dotprod_sse) - DEF_FUNC_HEAD(fcomplex_dotprod_sse) -GLOB_SYMB(fcomplex_dotprod_sse): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - # xmm0 xmm1 xmm2 xmm3 are used to hold taps and the result of mults - # xmm4 xmm5 xmm6 xmm7 are used to hold the accumulated results - - xorps %xmm4, %xmm4 # zero two accumulators - xorps %xmm5, %xmm5 # xmm5 holds zero for use below - - # first handle any non-zero remainder of (n_2_complex_blocks % 4) - - and $0x3, %rax - jmp .L1_test - - .p2align 4 -.Loop1: - - movlps 0(%rdi), %xmm0 - shufps $0x50, %xmm0, %xmm0 # b01010000 - - mulps (%rsi), %xmm0 - add $0x10, %rsi - add $8, %rdi - addps %xmm0, %xmm4 -.L1_test: - dec %rax - jge .Loop1 - - - # set up for primary loop which is unrolled 4 times - - movaps %xmm5, %xmm6 # zero remaining accumulators - movaps %xmm5, %xmm7 - - shr $2, %rdx # n_2_complex_blocks / 4 - je .Lcleanup # if zero, take short path - - # finish setup and loop priming - - movlps 0(%rdi), %xmm0 - - movaps %xmm5, %xmm2 - movaps %xmm5, %xmm3 - - movlps 8(%rdi), %xmm1 - shufps $0x50, %xmm0, %xmm0 - - shufps $0x50, %xmm1, %xmm1 - - # we know rdx is not zero, we checked above, - # hence enter loop at top - - .p2align 4 -.Loop2: - addps %xmm2, %xmm6 - movlps 0x10(%rdi), %xmm2 - - addps %xmm3, %xmm7 - - mulps (%rsi), %xmm0 - - movlps 0x18(%rdi), %xmm3 - shufps $0x50, %xmm2, %xmm2 - - mulps 0x10(%rsi), %xmm1 - - shufps $0x50, %xmm3, %xmm3 - - addps %xmm0, %xmm4 - movlps 0x20(%rdi), %xmm0 - - addps %xmm1, %xmm5 - - mulps 0x20(%rsi), %xmm2 - - movlps 0x28(%rdi), %xmm1 - shufps $0x50, %xmm0, %xmm0 - - mulps 0x30(%rsi), %xmm3 - - shufps $0x50, %xmm1, %xmm1 - - add $0x40, %rsi - add $0x20, %rdi - dec %rdx - jne .Loop2 - - # OK, now we've done with all the multiplies, but - # we still need to handle the unaccumulated - # products in xmm2 and xmm3 - - addps %xmm2, %xmm6 - addps %xmm3, %xmm7 - - # now we want to add all accumulators into xmm4 - - addps %xmm5, %xmm4 - addps %xmm6, %xmm7 - addps %xmm7, %xmm4 - - - # At this point, xmm4 contains 2x2 partial sums. We need - # to compute a "horizontal complex add" across xmm4. - -.Lcleanup: # xmm4 = r1 i2 r3 i4 - movhlps %xmm4, %xmm0 # xmm0 = ?? ?? r1 r2 - addps %xmm4, %xmm0 # xmm0 = ?? ?? r1+r3 i2+i4 - movlps %xmm0, (%rcx) # store low 2x32 bits (complex) to memory - - retq - -FUNC_TAIL(fcomplex_dotprod_sse) - .ident "Hand coded x86_64 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/fcomplex_dotprod_x86.h b/gnuradio-core/src/lib/filter/fcomplex_dotprod_x86.h deleted file mode 100644 index b7eddf936b..0000000000 --- a/gnuradio-core/src/lib/filter/fcomplex_dotprod_x86.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _FCOMPLEX_DOTPROD_X86_H_ -#define _FCOMPLEX_DOTPROD_X86_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -void -fcomplex_dotprod_3dnow (const float *input, - const float *taps, unsigned n_2_complex_blocks, float *result); - -void -fcomplex_dotprod_sse (const float *input, - const float *taps, unsigned n_2_complex_blocks, float *result); - -#ifdef __cplusplus -} -#endif - -#endif /* _FCOMPLEX_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/filter.i b/gnuradio-core/src/lib/filter/filter.i deleted file mode 100644 index 12580aa101..0000000000 --- a/gnuradio-core/src/lib/filter/filter.i +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2006,2007,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%{ -#include <gr_iir_filter_ffd.h> -#include <gr_single_pole_iir_filter_ff.h> -#include <gr_single_pole_iir_filter_cc.h> -#include <gr_hilbert_fc.h> -#include <gr_filter_delay_fc.h> -#include <gr_fft_filter_ccc.h> -#include <gr_fft_filter_fff.h> -#include <gr_fractional_interpolator_ff.h> -#include <gr_fractional_interpolator_cc.h> -#include <gr_goertzel_fc.h> -#include <gr_pfb_channelizer_ccf.h> -#include <gr_pfb_synthesizer_ccf.h> -#include <gr_pfb_decimator_ccf.h> -#include <gr_pfb_interpolator_ccf.h> -#include <gr_pfb_arb_resampler_ccf.h> -#include <gr_pfb_arb_resampler_fff.h> -#include <gr_pfb_clock_sync_ccf.h> -#include <gr_pfb_clock_sync_fff.h> -#include <gr_dc_blocker_cc.h> -#include <gr_dc_blocker_ff.h> -%} - -%include "gr_iir_filter_ffd.i" -%include "gr_single_pole_iir_filter_ff.i" -%include "gr_single_pole_iir_filter_cc.i" -%include "gr_hilbert_fc.i" -%include "gr_filter_delay_fc.i" -%include "gr_fft_filter_ccc.i" -%include "gr_fft_filter_fff.i" -%include "gr_fractional_interpolator_ff.i" -%include "gr_fractional_interpolator_cc.i" -%include "gr_goertzel_fc.i" -%include "gr_pfb_channelizer_ccf.i" -%include "gr_pfb_synthesizer_ccf.i" -%include "gr_pfb_decimator_ccf.i" -%include "gr_pfb_interpolator_ccf.i" -%include "gr_pfb_arb_resampler_ccf.i" -%include "gr_pfb_arb_resampler_fff.i" -%include "gr_pfb_decimator_ccf.i" -%include "gr_pfb_interpolator_ccf.i" -%include "gr_pfb_arb_resampler_ccf.i" -%include "gr_pfb_clock_sync_ccf.i" -%include "gr_pfb_clock_sync_fff.i" -%include "gr_dc_blocker_cc.i" -%include "gr_dc_blocker_ff.i" - -%include "filter_generated.i" diff --git a/gnuradio-core/src/lib/filter/float_dotprod_3dnow.S b/gnuradio-core/src/lib/filter/float_dotprod_3dnow.S deleted file mode 100644 index cdebe9bc31..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_3dnow.S +++ /dev/null @@ -1,152 +0,0 @@ -# -# Copyright 2002 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_4_float_blocks is != 0 -# -# -# float -# float_dotprod_generic (const float *input, -# const float *taps, unsigned n_4_float_blocks) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[1] * taps[1]; -# sum2 += input[2] * taps[2]; -# sum3 += input[3] * taps[3]; -# -# input += 4; -# taps += 4; -# -# } while (--n_4_float_blocks != 0); -# -# -# return sum0 + sum1 + sum2 + sum3; -# } -# - -#include "assembly.h" - - - .file "float_dotprod_3dnow.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(float_dotprod_3dnow) - DEF_FUNC_HEAD(float_dotprod_3dnow) -GLOB_SYMB(float_dotprod_3dnow): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %edx - movl 12(%ebp), %eax - movl 16(%ebp), %ecx - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - shrl $1, %ecx # ecx = n_4_float_blocks / 2 - movq 0(%eax), %mm0 - movq 8(%eax), %mm1 - pxor %mm2, %mm2 - pxor %mm3, %mm3 - jmp .L1_test - - # - # 8 taps / loop - # something like 6 cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%edx), %mm0 - pfadd %mm2, %mm6 - movq 16(%eax), %mm2 - - pfmul 8(%edx), %mm1 - pfadd %mm3, %mm7 - movq 24(%eax), %mm3 - - pfmul 16(%edx), %mm2 - pfadd %mm0, %mm4 - movq 32(%eax), %mm0 - - pfmul 24(%edx), %mm3 - pfadd %mm1, %mm5 - movq 40(%eax), %mm1 - - addl $32, %edx - addl $32, %eax -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_4_float_blocks was odd. If so, we've got 4 more - # taps to do. - - movl 16(%ebp), %ecx - pfadd %mm2, %mm6 - andl $1, %ecx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 4 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%edx), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%edx), %mm1 - pfadd %mm1, %mm5 - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - pfadd %mm6, %mm4 - pfacc %mm4, %mm4 - - movd %mm4, 16(%ebp) - femms - flds 16(%ebp) - - popl %ebp - ret - -FUNC_TAIL(float_dotprod_3dnow) - .ident "Hand coded x86 3DNow! assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/float_dotprod_3dnow64.S b/gnuradio-core/src/lib/filter/float_dotprod_3dnow64.S deleted file mode 100644 index 1e859d75a8..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_3dnow64.S +++ /dev/null @@ -1,149 +0,0 @@ -# -# Copyright 2002,2005 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_4_float_blocks is != 0 -# -# -# float -# float_dotprod_generic (const float *input, -# const float *taps, unsigned n_4_float_blocks) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[1] * taps[1]; -# sum2 += input[2] * taps[2]; -# sum3 += input[3] * taps[3]; -# -# input += 4; -# taps += 4; -# -# } while (--n_4_float_blocks != 0); -# -# -# return sum0 + sum1 + sum2 + sum3; -# } -# - -#include "assembly.h" - - - .file "float_dotprod_3dnow64.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(float_dotprod_3dnow) - DEF_FUNC_HEAD(float_dotprod_3dnow) -GLOB_SYMB(float_dotprod_3dnow): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx - - mov %rdx, %rax - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - shr $1, %rax # rax = n_4_float_blocks / 2 - movq 0(%rsi), %mm0 - movq 8(%rsi), %mm1 - pxor %mm2, %mm2 - pxor %mm3, %mm3 - jmp .L1_test - - # - # 8 taps / loop - # something like 6 cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%rdi), %mm0 - pfadd %mm2, %mm6 - movq 16(%rsi), %mm2 - - pfmul 8(%rdi), %mm1 - pfadd %mm3, %mm7 - movq 24(%rsi), %mm3 - - pfmul 16(%rdi), %mm2 - pfadd %mm0, %mm4 - movq 32(%rsi), %mm0 - - pfmul 24(%rdi), %mm3 - pfadd %mm1, %mm5 - movq 40(%rsi), %mm1 - - add $32, %rdi - add $32, %rsi -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_4_float_blocks was odd. If so, we've got 4 more - # taps to do. - - pfadd %mm2, %mm6 - and $1, %rdx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 4 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%rdi), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%rdi), %mm1 - pfadd %mm1, %mm5 - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - pfadd %mm6, %mm4 - pfacc %mm4, %mm4 - - movd %mm4, -8(%rsp) - movss -8(%rsp), %xmm0 - femms - - retq - -FUNC_TAIL(float_dotprod_3dnow) - .ident "Hand coded x86_64 3DNow! assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/float_dotprod_generic.c b/gnuradio-core/src/lib/filter/float_dotprod_generic.c deleted file mode 100644 index fb91390362..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_generic.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "float_dotprod_generic.h" - - -float -float_dotprod_generic (const float *input, - const float *taps, unsigned n_4_float_blocks) -{ - float sum0 = 0; - float sum1 = 0; - float sum2 = 0; - float sum3 = 0; - - do { - - sum0 += input[0] * taps[0]; - sum1 += input[1] * taps[1]; - sum2 += input[2] * taps[2]; - sum3 += input[3] * taps[3]; - - input += 4; - taps += 4; - - } while (--n_4_float_blocks != 0); - - - return sum0 + sum1 + sum2 + sum3; -} diff --git a/gnuradio-core/src/lib/filter/float_dotprod_generic.h b/gnuradio-core/src/lib/filter/float_dotprod_generic.h deleted file mode 100644 index dee967642a..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_generic.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _FLOAT_DOTPROD_GENERIC_H_ -#define _FLOAT_DOTPROD_GENERIC_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -float -float_dotprod_generic (const float *input, - const float *taps, unsigned n_4_float_blocks); - - -#ifdef __cplusplus -} -#endif - - - -#endif /* _FLOAT_DOTPROD_GENERIC_H_ */ diff --git a/gnuradio-core/src/lib/filter/float_dotprod_sse.S b/gnuradio-core/src/lib/filter/float_dotprod_sse.S deleted file mode 100644 index 66604526d0..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_sse.S +++ /dev/null @@ -1,171 +0,0 @@ -# -# Copyright 2002 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_4_float_blocks is != 0 -# -# -# float -# float_dotprod_generic (const float *input, -# const float *taps, unsigned n_4_float_blocks) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[1] * taps[1]; -# sum2 += input[2] * taps[2]; -# sum3 += input[3] * taps[3]; -# -# input += 4; -# taps += 4; -# -# } while (--n_4_float_blocks != 0); -# -# -# return sum0 + sum1 + sum2 + sum3; -# } -# - -#include "assembly.h" - - - .file "float_dotprod_sse.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(float_dotprod_sse) - DEF_FUNC_HEAD(float_dotprod_sse) -GLOB_SYMB(float_dotprod_sse): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %edx - movl 12(%ebp), %eax - movl 16(%ebp), %ecx - - - # xmm0 xmm1 xmm2 xmm3 are used to hold taps and the result of mults - # xmm4 xmm5 xmm6 xmm7 are used to hold the accumulated results - - xorps %xmm4, %xmm4 # zero two accumulators - xorps %xmm5, %xmm5 # xmm5 holds zero for use below - - # first handle any non-zero remainder of (n_4_float_blocks % 4) - - andl $0x3, %ecx - jmp .L1_test - - .p2align 4 -.Loop1: - movaps (%eax), %xmm0 - mulps (%edx), %xmm0 - addl $0x10, %edx - addl $0x10, %eax - addps %xmm0, %xmm4 -.L1_test: - decl %ecx - jge .Loop1 - - - # set up for primary loop which is unrolled 4 times - - movl 16(%ebp), %ecx - movaps %xmm5, %xmm6 # zero remaining accumulators - movaps %xmm5, %xmm7 - - shrl $2, %ecx # n_4_float_blocks / 4 - je .Lcleanup # if zero, take short path - - # finish setup and loop priming - - movaps 0x00(%eax), %xmm0 - movaps %xmm5, %xmm2 - movaps 0x10(%eax), %xmm1 - movaps %xmm5, %xmm3 - - # we know ecx is not zero, we checked above, - # hence enter loop at top - - .p2align 4 -.Loop2: - mulps (%edx), %xmm0 - addps %xmm2, %xmm6 - movaps 0x20(%eax), %xmm2 - - mulps 0x10(%edx), %xmm1 - addps %xmm3, %xmm7 - movaps 0x30(%eax), %xmm3 - - mulps 0x20(%edx), %xmm2 - addps %xmm0, %xmm4 - movaps 0x40(%eax), %xmm0 - - mulps 0x30(%edx), %xmm3 - addps %xmm1, %xmm5 - movaps 0x50(%eax), %xmm1 - - addl $0x40, %edx - addl $0x40, %eax - decl %ecx - jne .Loop2 - - # OK, now we've done with all the multiplies, but - # we still need to handle the unaccumulated - # products in xmm2 and xmm3 - - addps %xmm2, %xmm6 - addps %xmm3, %xmm7 - - # now we want to add all accumulators into xmm4 - - addps %xmm5, %xmm4 - addps %xmm6, %xmm7 - addps %xmm7, %xmm4 - - - # At this point, xmm4 contains 4 partial sums. We need - # to compute a "horizontal add" across xmm4. - # This is a fairly nasty operation... - -.Lcleanup: # xmm4 = d1 d2 d3 d4 - xorps %xmm0, %xmm0 # xmm0 = 0 0 0 0 (may be unnecessary) - movhlps %xmm4, %xmm0 # xmm0 = 0 0 d1 d2 - addps %xmm4, %xmm0 # xmm0 = d1 d2 d1+d3 d2+d4 - movaps %xmm0, %xmm1 # xmm1 = d1 d2 d1+d3 d2+d4 - shufps $0xE1, %xmm4, %xmm1 # xmm1 = d1 d2 d2+d4 d1+d3 - addss %xmm1, %xmm0 # xmm1 = d1 d2 d1+d3 d1+d2+d3+d4 - movss %xmm0, 16(%ebp) # store low 32 bits (sum) to memory - flds 16(%ebp) # and load onto FPU stack for return - - popl %ebp - ret - -FUNC_TAIL(float_dotprod_sse) - .ident "Hand coded x86 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/float_dotprod_sse64.S b/gnuradio-core/src/lib/filter/float_dotprod_sse64.S deleted file mode 100644 index 0dd0764c5e..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_sse64.S +++ /dev/null @@ -1,165 +0,0 @@ -# -# Copyright 2002,2005 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_4_float_blocks is != 0 -# -# -# float -# float_dotprod_generic (const float *input, -# const float *taps, unsigned n_4_float_blocks) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[1] * taps[1]; -# sum2 += input[2] * taps[2]; -# sum3 += input[3] * taps[3]; -# -# input += 4; -# taps += 4; -# -# } while (--n_4_float_blocks != 0); -# -# -# return sum0 + sum1 + sum2 + sum3; -# } -# - -#include "assembly.h" - - - .file "float_dotprod_sse64.S" -// .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(float_dotprod_sse) - DEF_FUNC_HEAD(float_dotprod_sse) -GLOB_SYMB(float_dotprod_sse): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx - - mov %rdx, %rax - - # xmm0 xmm1 xmm2 xmm3 are used to hold taps and the result of mults - # xmm4 xmm5 xmm6 xmm7 are used to hold the accumulated results - - xorps %xmm4, %xmm4 # zero two accumulators - xorps %xmm5, %xmm5 # xmm5 holds zero for use below - - # first handle any non-zero remainder of (n_4_float_blocks % 4) - - and $0x3, %rax - jmp .L1_test - - .p2align 4 -.Loop1: - movaps (%rsi), %xmm0 - mulps (%rdi), %xmm0 - add $0x10, %rdi - add $0x10, %rsi - addps %xmm0, %xmm4 -.L1_test: - dec %rax - jge .Loop1 - - - # set up for primary loop which is unrolled 4 times - - movaps %xmm5, %xmm6 # zero remaining accumulators - movaps %xmm5, %xmm7 - - shr $2, %rdx # n_4_float_blocks / 4 - je .Lcleanup # if zero, take short path - - # finish setup and loop priming - - movaps 0x00(%rsi), %xmm0 - movaps %xmm5, %xmm2 - movaps 0x10(%rsi), %xmm1 - movaps %xmm5, %xmm3 - - # we know rdx is not zero, we checked above, - # hence enter loop at top - - .p2align 4 -.Loop2: - mulps (%rdi), %xmm0 - addps %xmm2, %xmm6 - movaps 0x20(%rsi), %xmm2 - - mulps 0x10(%rdi), %xmm1 - addps %xmm3, %xmm7 - movaps 0x30(%rsi), %xmm3 - - mulps 0x20(%rdi), %xmm2 - addps %xmm0, %xmm4 - movaps 0x40(%rsi), %xmm0 - - mulps 0x30(%rdi), %xmm3 - addps %xmm1, %xmm5 - movaps 0x50(%rsi), %xmm1 - - add $0x40, %rdi - add $0x40, %rsi - dec %rdx - jne .Loop2 - - # OK, now we've done with all the multiplies, but - # we still need to handle the unaccumulated - # products in xmm2 and xmm3 - - addps %xmm2, %xmm6 - addps %xmm3, %xmm7 - - # now we want to add all accumulators into xmm4 - - addps %xmm5, %xmm4 - addps %xmm6, %xmm7 - addps %xmm7, %xmm4 - - - # At this point, xmm4 contains 4 partial sums. We need - # to compute a "horizontal add" across xmm4. - # This is a fairly nasty operation... - -.Lcleanup: # xmm4 = d1 d2 d3 d4 - xorps %xmm0, %xmm0 # xmm0 = 0 0 0 0 (may be unnecessary) - movhlps %xmm4, %xmm0 # xmm0 = 0 0 d1 d2 - addps %xmm4, %xmm0 # xmm0 = d1 d2 d1+d3 d2+d4 - movaps %xmm0, %xmm1 # xmm1 = d1 d2 d1+d3 d2+d4 - shufps $0xE1, %xmm4, %xmm1 # xmm1 = d1 d2 d2+d4 d1+d3 - addss %xmm1, %xmm0 # xmm1 = d1 d2 d1+d3 d1+d2+d3+d4 - - retq - -FUNC_TAIL(float_dotprod_sse) - .ident "Hand coded x86_64 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/float_dotprod_x86.h b/gnuradio-core/src/lib/filter/float_dotprod_x86.h deleted file mode 100644 index fd1a2cc937..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_x86.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _FLOAT_DOTPROD_X86_H_ -#define _FLOAT_DOTPROD_X86_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -float -float_dotprod_3dnow (const float *input, - const float *taps, unsigned n_4_float_blocks); - -float -float_dotprod_sse (const float *input, - const float *taps, unsigned n_4_float_blocks); - -#ifdef __cplusplus -} -#endif - - - -#endif /* _FLOAT_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/gcc_x86_cpuid.h b/gnuradio-core/src/lib/filter/gcc_x86_cpuid.h deleted file mode 100644 index 98eeb33a31..0000000000 --- a/gnuradio-core/src/lib/filter/gcc_x86_cpuid.h +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. - * - * This file is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 3, or (at your option) any - * later version. - * - * This file is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * Under Section 7 of GPL version 3, you are granted additional - * permissions described in the GCC Runtime Library Exception, version - * 3.1, as published by the Free Software Foundation. - * - * You should have received a copy of the GNU General Public License and - * a copy of the GCC Runtime Library Exception along with this program; - * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see - * <http://www.gnu.org/licenses/>. - */ - -/* %ecx */ -#define bit_SSE3 (1 << 0) -#define bit_PCLMUL (1 << 1) -#define bit_SSSE3 (1 << 9) -#define bit_FMA (1 << 12) -#define bit_CMPXCHG16B (1 << 13) -#define bit_SSE4_1 (1 << 19) -#define bit_SSE4_2 (1 << 20) -#define bit_MOVBE (1 << 22) -#define bit_POPCNT (1 << 23) -#define bit_AES (1 << 25) -#define bit_XSAVE (1 << 26) -#define bit_OSXSAVE (1 << 27) -#define bit_AVX (1 << 28) - -/* %edx */ -#define bit_CMPXCHG8B (1 << 8) -#define bit_CMOV (1 << 15) -#define bit_MMX (1 << 23) -#define bit_FXSAVE (1 << 24) -#define bit_SSE (1 << 25) -#define bit_SSE2 (1 << 26) - -/* Extended Features */ -/* %ecx */ -#define bit_LAHF_LM (1 << 0) -#define bit_SSE4a (1 << 6) -#define bit_SSE5 (1 << 11) - -/* %edx */ -#define bit_LM (1 << 29) -#define bit_3DNOWP (1 << 30) -#define bit_3DNOW (1 << 31) - - -#if defined(__i386__) && defined(__PIC__) -/* %ebx may be the PIC register. */ -#if __GNUC__ >= 3 -#define __cpuid(level, a, b, c, d) \ - __asm__ ("xchg{l}\t{%%}ebx, %1\n\t" \ - "cpuid\n\t" \ - "xchg{l}\t{%%}ebx, %1\n\t" \ - : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ - : "0" (level)) - -#define __cpuid_count(level, count, a, b, c, d) \ - __asm__ ("xchg{l}\t{%%}ebx, %1\n\t" \ - "cpuid\n\t" \ - "xchg{l}\t{%%}ebx, %1\n\t" \ - : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ - : "0" (level), "2" (count)) -#else -/* Host GCCs older than 3.0 weren't supporting Intel asm syntax - nor alternatives in i386 code. */ -#define __cpuid(level, a, b, c, d) \ - __asm__ ("xchgl\t%%ebx, %1\n\t" \ - "cpuid\n\t" \ - "xchgl\t%%ebx, %1\n\t" \ - : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ - : "0" (level)) - -#define __cpuid_count(level, count, a, b, c, d) \ - __asm__ ("xchgl\t%%ebx, %1\n\t" \ - "cpuid\n\t" \ - "xchgl\t%%ebx, %1\n\t" \ - : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ - : "0" (level), "2" (count)) -#endif -#else -#define __cpuid(level, a, b, c, d) \ - __asm__ ("cpuid\n\t" \ - : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ - : "0" (level)) - -#define __cpuid_count(level, count, a, b, c, d) \ - __asm__ ("cpuid\n\t" \ - : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ - : "0" (level), "2" (count)) -#endif - -/* Return highest supported input value for cpuid instruction. ext can - be either 0x0 or 0x8000000 to return highest supported value for - basic or extended cpuid information. Function returns 0 if cpuid - is not supported or whatever cpuid returns in eax register. If sig - pointer is non-null, then first four bytes of the signature - (as found in ebx register) are returned in location pointed by sig. */ - -static __inline unsigned int -__get_cpuid_max (unsigned int __ext, unsigned int *__sig) -{ - unsigned int __eax, __ebx, __ecx, __edx; - -#ifndef __x86_64__ -#if __GNUC__ >= 3 - /* See if we can use cpuid. On AMD64 we always can. */ - __asm__ ("pushf{l|d}\n\t" - "pushf{l|d}\n\t" - "pop{l}\t%0\n\t" - "mov{l}\t{%0, %1|%1, %0}\n\t" - "xor{l}\t{%2, %0|%0, %2}\n\t" - "push{l}\t%0\n\t" - "popf{l|d}\n\t" - "pushf{l|d}\n\t" - "pop{l}\t%0\n\t" - "popf{l|d}\n\t" - : "=&r" (__eax), "=&r" (__ebx) - : "i" (0x00200000)); -#else -/* Host GCCs older than 3.0 weren't supporting Intel asm syntax - nor alternatives in i386 code. */ - __asm__ ("pushfl\n\t" - "pushfl\n\t" - "popl\t%0\n\t" - "movl\t%0, %1\n\t" - "xorl\t%2, %0\n\t" - "pushl\t%0\n\t" - "popfl\n\t" - "pushfl\n\t" - "popl\t%0\n\t" - "popfl\n\t" - : "=&r" (__eax), "=&r" (__ebx) - : "i" (0x00200000)); -#endif - - if (!((__eax ^ __ebx) & 0x00200000)) - return 0; -#endif - - /* Host supports cpuid. Return highest supported cpuid input value. */ - __cpuid (__ext, __eax, __ebx, __ecx, __edx); - - if (__sig) - *__sig = __ebx; - - return __eax; -} - -/* Return cpuid data for requested cpuid level, as found in returned - eax, ebx, ecx and edx registers. The function checks if cpuid is - supported and returns 1 for valid cpuid information or 0 for - unsupported cpuid level. All pointers are required to be non-null. */ - -static __inline int -__get_cpuid (unsigned int __level, - unsigned int *__eax, unsigned int *__ebx, - unsigned int *__ecx, unsigned int *__edx) -{ - unsigned int __ext = __level & 0x80000000; - - if (__get_cpuid_max (__ext, 0) < __level) - return 0; - - __cpuid (__level, *__eax, *__ebx, *__ecx, *__edx); - return 1; -} diff --git a/gnuradio-core/src/lib/filter/generate_all.py b/gnuradio-core/src/lib/filter/generate_all.py deleted file mode 100755 index 1da9f7209a..0000000000 --- a/gnuradio-core/src/lib/filter/generate_all.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2003 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from build_utils import output_glue - -import generate_gr_fir_filter_XXX -import generate_gr_interp_fir_filter_XXX -import generate_gr_rational_resampler_base_XXX -import generate_gr_freq_xlating_fir_filter_XXX -import generate_gr_fir_sysconfig_generic -import generate_gr_fir_sysconfig -import generate_gr_fir_util -import generate_gr_fir_XXX -import generate_gri_fir_filter_with_buffer_XXX - -def generate_all(): - generate_gr_fir_XXX.generate() - generate_gr_fir_filter_XXX.generate() - generate_gr_interp_fir_filter_XXX.generate() - generate_gr_rational_resampler_base_XXX.generate() - generate_gr_freq_xlating_fir_filter_XXX.generate() - generate_gr_fir_sysconfig_generic.generate() - generate_gr_fir_sysconfig.generate() - generate_gr_fir_util.generate() - generate_gri_fir_filter_with_buffer_XXX.generate() - output_glue('filter') - -if __name__ == '__main__': - generate_all() diff --git a/gnuradio-core/src/lib/filter/generate_gr_fir_XXX.py b/gnuradio-core/src/lib/filter/generate_gr_fir_XXX.py deleted file mode 100755 index cf37fbb24d..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_fir_XXX.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -import re -from generate_utils import * - -roots = ['gr_fir_XXX', 'gr_fir_XXX_generic'] - - -# figure out accumulator type. Use biggest of input, output and tap type - -def code3_to_acc_code (code3): - if i_code (code3) == 'c' or o_code (code3) == 'c' or tap_code (code3) == 'c': - return 'c' - if i_code (code3) == 'f' or o_code (code3) == 'f' or tap_code (code3) == 'f': - return 'f' - if i_code (code3) == 'i' or o_code (code3) == 'i' or tap_code (code3) == 'i': - return 'i' - return 'i' # even short short short needs int accumulator - - -def code3_to_input_cast (code3): - if i_code (code3) == 's' and o_code (code3) == 'c': - return '(float)' - return '' - -def expand_h_cc (root, code3): - d = init_dict (root, code3) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - -def init_dict (root, code3): - name = re.sub ('X+', code3, root) - d = standard_dict (name, code3) - d['FIR_TYPE'] = 'gr_fir_' + code3 - d['INPUT_CAST'] = code3_to_input_cast (code3) - acc_code = code3_to_acc_code (code3) - d['ACC_TYPE'] = char_to_type[acc_code] - if acc_code == 'c': - d['N_UNROLL'] = '2' - d['VRCOMPLEX_INCLUDE'] = '#include <gr_types.h>' - else: - d['N_UNROLL'] = '4' - d['VRCOMPLEX_INCLUDE'] = '' - return d - - -def generate (): - for r in roots: - for s in fir_signatures: - expand_h_cc (r, s) - - -if __name__ == '__main__': - generate () diff --git a/gnuradio-core/src/lib/filter/generate_gr_fir_filter_XXX.py b/gnuradio-core/src/lib/filter/generate_gr_fir_filter_XXX.py deleted file mode 100755 index 50cc586e59..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_fir_filter_XXX.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003,2004 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -import re -from generate_utils import * - -roots = ['gr_fir_filter_XXX'] - - -def expand_h_cc_i (root, code3): - d = init_dict (root, code3) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - expand_template (d, root + '.i.t') - -def init_dict (root, code3): - name = re.sub ('X+', code3, root) - d = standard_dict (name, code3) - d['FIR_TYPE'] = 'gr_fir_' + code3 - return d - -def generate (): - for r in roots: - for s in fir_signatures: - expand_h_cc_i (r, s) - -if __name__ == '__main__': - generate () - diff --git a/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig.py b/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig.py deleted file mode 100755 index 50d819fd18..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig.py +++ /dev/null @@ -1,133 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from generate_utils import * - - -# ---------------------------------------------------------------- - -def make_gr_fir_sysconfig_h (): - out = open_and_log_name ('gr_fir_sysconfig.h', 'w') - if not out: - return - - out.write (copyright) - - out.write ( -''' -/* - * WARNING: This file is automatically generated by generate_gr_fir_sysconfig.py - * Any changes made to this file will be overwritten. - */ - -#ifndef INCLUDED_GR_FIR_SYSCONFIG_H -#define INCLUDED_GR_FIR_SYSCONFIG_H - -#include <gr_types.h> - -''') - - # for sig in fir_signatures: - # out.write ('class gr_fir_' + sig + ';\n') - - out.write ('#include <gr_fir_util.h>\n') - - out.write ( -''' -/*! - * \\brief abstract base class for configuring the automatic selection of the - * fastest gr_fir for your platform. - * - * This is used internally by gr_fir_util. - */ - -class gr_fir_sysconfig { -public: - virtual ~gr_fir_sysconfig (); - -''') - - for sig in fir_signatures: - out.write ((' virtual gr_fir_%s *create_gr_fir_%s (const std::vector<%s> &taps) = 0;\n' % - (sig, sig, tap_type (sig)))) - - out.write ('\n') - - for sig in fir_signatures: - out.write ((' virtual void get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info) = 0;\n' % - (sig, sig))) - - out.write ( -''' -}; - -/* - * This returns the single instance of the appropriate derived class. - * This function must be defined only once in the system, and should be defined - * in the platform specific code. - */ - -gr_fir_sysconfig *gr_fir_sysconfig_singleton (); - - -#endif /* INCLUDED_GR_FIR_SYSCONFIG_H */ -''') - out.close () - - -# ---------------------------------------------------------------- - -def make_gr_fir_sysconfig_cc (): - out = open_and_log_name ('gr_fir_sysconfig.cc', 'w') - if not out: - return - - out.write (copyright) - - out.write ( -''' -/* - * WARNING: This file is automatically generated by generate_gr_fir_sysconfig.py - * Any changes made to this file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_sysconfig.h> - -gr_fir_sysconfig::~gr_fir_sysconfig () -{ -} -''') - out.close () - - -# ---------------------------------------------------------------- - -def generate (): - make_gr_fir_sysconfig_h () - make_gr_fir_sysconfig_cc () - -if __name__ == '__main__': - generate () diff --git a/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig_generic.py b/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig_generic.py deleted file mode 100755 index dcbadd30f7..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig_generic.py +++ /dev/null @@ -1,186 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from generate_utils import * - - -# ---------------------------------------------------------------- - -def make_gr_fir_sysconfig_generic_h (): - out = open_and_log_name ('gr_fir_sysconfig_generic.h', 'w') - if not out: - return - out.write (copyright) - - out.write ( -''' -/* - * WARNING: This file is automatically generated by - * generate_gr_fir_sysconfig_generic.py. - * - * Any changes made to this file will be overwritten. - */ - -#ifndef _GR_FIR_SYSCONFIG_GENERIC_H_ -#define _GR_FIR_SYSCONFIG_GENERIC_H_ - -#include <gr_fir_sysconfig.h> - -''') - - out.write ( -''' -class gr_fir_sysconfig_generic : public gr_fir_sysconfig { -public: -''') - - for sig in fir_signatures: - out.write ((' virtual gr_fir_%s *create_gr_fir_%s (const std::vector<%s> &taps);\n' % - (sig, sig, tap_type (sig)))) - - out.write ('\n') - - for sig in fir_signatures: - out.write ((' virtual void get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info);\n' % - (sig, sig))) - - out.write ( -''' -}; - - -#endif /* _GR_FIR_SYSCONFIG_GENERIC_H_ */ -''') - out.close () - - -# ---------------------------------------------------------------- - -def make_constructor (sig, out): - out.write (''' -static gr_fir_%s * -make_gr_fir_%s (const std::vector<%s> &taps) -{ - return new gr_fir_%s_generic (taps); -} -''' % (sig, sig, tap_type (sig), sig)) - - -def make_creator (sig, out): - out.write (''' -gr_fir_%s * -gr_fir_sysconfig_generic::create_gr_fir_%s (const std::vector<%s> &taps) -{ - return make_gr_fir_%s (taps); -} -''' % (sig, sig, tap_type (sig), sig)) - - -def make_info (sig, out): - out.write (''' -void -gr_fir_sysconfig_generic::get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info) -{ - info->resize (1); - (*info)[0].name = "generic"; - (*info)[0].create = make_gr_fir_%s; -} -''' % (sig, sig, sig)) - - -# ---------------------------------------------------------------- - -def make_gr_fir_sysconfig_generic_cc (): - out = open_and_log_name ('gr_fir_sysconfig_generic.cc', 'w') - if not out: - return - out.write (copyright) - - out.write ( -''' -/* - * WARNING: This file is automatically generated by - * generate_gr_fir_sysconfig_generic.py. - * - * Any changes made to this file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_sysconfig_generic.h> - -''') - - for sig in fir_signatures: - out.write ('#include <gr_fir_%s_generic.h>\n' % (sig)) - - out.write ( -''' -/* - * ---------------------------------------------------------------- - * static functions that serve as constructors returned by info - * ---------------------------------------------------------------- - */ -''') - - for sig in fir_signatures: - make_constructor (sig, out) - - out.write ( -''' -/* - * ---------------------------------------------------------------- - * return instances of the generic C++ versions of these classes. - * ---------------------------------------------------------------- - */ -''') - - for sig in fir_signatures: - make_creator (sig, out) - - out.write ( -''' -/* - * Return info about available implementations. - * - * This is the bottom of the concrete hierarchy, so we set the - * size of the vector to 1, and install our info. Classes derived - * from us invoke us first, then append their own info. - */ -''') - - for sig in fir_signatures: - make_info (sig, out) - - - out.close () - -# ---------------------------------------------------------------- - -def generate (): - make_gr_fir_sysconfig_generic_h () - make_gr_fir_sysconfig_generic_cc () - -if __name__ == '__main__': - generate () diff --git a/gnuradio-core/src/lib/filter/generate_gr_fir_util.py b/gnuradio-core/src/lib/filter/generate_gr_fir_util.py deleted file mode 100755 index 79fa51c278..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_fir_util.py +++ /dev/null @@ -1,190 +0,0 @@ -#!/bin/env python -# -# Copyright 2003,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from generate_utils import * - -def make_info_struct (out, sig): - out.write ( -''' -struct GR_CORE_API gr_fir_%s_info { - const char *name; // implementation name, e.g., "generic", "SSE", "3DNow!" - gr_fir_%s *(*create)(const std::vector<%s> &taps); -}; -''' % (sig, sig, tap_type(sig))) - -def make_create (out, sig): - out.write (''' static gr_fir_%s *create_gr_fir_%s (const std::vector<%s> &taps); -''' % (sig, sig, tap_type (sig))) - -def make_info (out, sig): - out.write (''' static void get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info); -''' % (sig, sig)) - - -# ---------------------------------------------------------------- - -def make_gr_fir_util_h (): - out = open_and_log_name ('gr_fir_util.h', 'w') - if not out: - return - out.write (copyright) - - out.write ( -''' -/* - * WARNING: This file is automatically generated by - * generate_gr_fir_util.py. - * - * Any changes made to this file will be overwritten. - */ - -#ifndef INCLUDED_GR_FIR_UTIL_H -#define INCLUDED_GR_FIR_UTIL_H - -/*! - * \\brief routines to create gr_fir_XXX's - * - * This class handles selecting the fastest version of the finite - * implulse response filter available for your platform. This - * interface should be used by the rest of the system for creating - * gr_fir_XXX's. - * - * The trailing suffix has the form _IOT where I codes the input type, - * O codes the output type, and T codes the tap type. - * I,O,T are elements of the set 's' (short), 'f' (float), 'c' (gr_complex), - * 'i' (short) - */ - -#include <gr_core_api.h> -#include <gr_types.h> - -''') - - for sig in fir_signatures: - out.write ('class gr_fir_%s;\n' % sig); - - out.write ('\n// structures returned by get_gr_fir_XXX_info methods\n\n') - - for sig in fir_signatures: - make_info_struct (out, sig) - - out.write (''' -struct GR_CORE_API gr_fir_util { - - // create a fast version of gr_fir_XXX. - -''') - - for sig in fir_signatures: - make_create (out, sig) - - out.write (''' - // Get information about all gr_fir_XXX implementations. - // This is useful for benchmarking, testing, etc without having to - // know a priori what's linked into this image - // - // The caller must pass in a valid pointer to a vector. - // The vector will be filled with structs describing the - // available implementations. - -''') - - for sig in fir_signatures: - make_info (out, sig) - - out.write (''' -}; - -#endif /* INCLUDED_GR_FIR_UTIL_H */ -''') - out.close () - - -# ---------------------------------------------------------------- - -def make_constructor_cc (out, sig): - out.write ( -''' -gr_fir_%s * -gr_fir_util::create_gr_fir_%s (const std::vector<%s> &taps) -{ - return gr_fir_sysconfig_singleton()->create_gr_fir_%s (taps); -} -''' % (sig, sig, tap_type (sig), sig)) - - -def make_info_cc (out, sig): - out.write ( -''' -void -gr_fir_util::get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info) -{ - gr_fir_sysconfig_singleton()->get_gr_fir_%s_info (info); -} -''' % (sig, sig, sig)) - - -def make_gr_fir_util_cc (): - out = open_and_log_name ('gr_fir_util.cc', 'w') - if not out: - return - out.write (copyright) - out.write (''' - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_util.h> -#include <gr_fir_sysconfig.h> - -// -// There's no problem that can't be solved by the addition of -// another layer of indirection... -// - -// --- constructors --- - -''') - - for sig in fir_signatures: - make_constructor_cc (out, sig) - - out.write (''' -// --- info gatherers --- - -''') - - for sig in fir_signatures: - make_info_cc (out, sig) - - out.close () - - -# ---------------------------------------------------------------- - -def generate (): - make_gr_fir_util_h () - make_gr_fir_util_cc () - -if __name__ == '__main__': - generate () - diff --git a/gnuradio-core/src/lib/filter/generate_gr_freq_xlating_fir_filter_XXX.py b/gnuradio-core/src/lib/filter/generate_gr_freq_xlating_fir_filter_XXX.py deleted file mode 100755 index 41c0b2b70c..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_freq_xlating_fir_filter_XXX.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003,2004 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -import re -from generate_utils import * - -# files to generate - -fx_signatures = [ 'scf', 'scc', 'fcf', 'fcc', 'ccf', 'ccc' ] - -roots = ['gr_freq_xlating_fir_filter_XXX'] - -def expand_h_cc_i (root, code3): - d = init_dict (root, code3) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - expand_template (d, root + '.i.t') - -def init_dict (root, code3): - name = re.sub ('X+', code3, root) - d = standard_dict (name, code3) - d['FIR_TYPE'] = 'gr_fir_' + i_code (code3) + 'cc' - return d - - -def generate (): - for r in roots: - for s in fx_signatures: - expand_h_cc_i (r, s) - - -if __name__ == '__main__': - generate () diff --git a/gnuradio-core/src/lib/filter/generate_gr_interp_fir_filter_XXX.py b/gnuradio-core/src/lib/filter/generate_gr_interp_fir_filter_XXX.py deleted file mode 100644 index 1dcfdadede..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_interp_fir_filter_XXX.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003,2004 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -import re -from generate_utils import * - -roots = ['gr_interp_fir_filter_XXX'] - -def expand_h_cc_i (root, code3): - d = init_dict (root, code3) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - expand_template (d, root + '.i.t') - -def init_dict (root, code3): - name = re.sub ('X+', code3, root) - d = standard_dict (name, code3) - d['FIR_TYPE'] = 'gr_fir_' + code3 - return d - -def generate (): - for r in roots: - for s in fir_signatures: - expand_h_cc_i (r, s) - -if __name__ == '__main__': - generate () - diff --git a/gnuradio-core/src/lib/filter/generate_gr_rational_resampler_base_XXX.py b/gnuradio-core/src/lib/filter/generate_gr_rational_resampler_base_XXX.py deleted file mode 100644 index 1dafec3fbe..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_rational_resampler_base_XXX.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003,2004 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -import re -from generate_utils import * - -roots = ['gr_rational_resampler_base_XXX'] - -def expand_h_cc_i (root, code3): - d = init_dict (root, code3) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - expand_template (d, root + '.i.t') - -def init_dict (root, code3): - name = re.sub ('X+', code3, root) - d = standard_dict (name, code3) - d['FIR_TYPE'] = 'gr_fir_' + code3 - return d - -def generate (): - for r in roots: - for s in fir_signatures: - expand_h_cc_i (r, s) - -if __name__ == '__main__': - generate () - diff --git a/gnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py b/gnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py deleted file mode 100755 index 6442fb3dc2..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -*- python -*- -# -# Copyright 2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -import re -from generate_utils import * - -roots = ['gri_fir_filter_with_buffer_XXX',] - -def code3_to_acc_code (code3): - if i_code (code3) == 'c' or o_code (code3) == 'c' or tap_code (code3) == 'c': - return 'c' - if i_code (code3) == 'f' or o_code (code3) == 'f' or tap_code (code3) == 'f': - return 'f' - if i_code (code3) == 'i' or o_code (code3) == 'i' or tap_code (code3) == 'i': - return 'i' - return 'i' # even short short short needs int accumulator - -def code3_to_input_cast (code3): - if i_code (code3) == 's' and o_code (code3) == 'c': - return '(float)' - return '' - -def expand_h_cc (root, code3): - d = init_dict (root, code3) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - -def init_dict (root, code3): - name = re.sub ('X+', code3, root) - d = standard_dict (name, code3) - d['INPUT_CAST'] = code3_to_input_cast (code3) - acc_code = code3_to_acc_code (code3) - d['ACC_TYPE'] = char_to_type[acc_code] - return d - - -def generate (): - for r in roots: - for s in fir_signatures: - expand_h_cc (r, s) - - -if __name__ == '__main__': - generate () diff --git a/gnuradio-core/src/lib/filter/generate_utils.py b/gnuradio-core/src/lib/filter/generate_utils.py deleted file mode 100644 index 212ea95f9c..0000000000 --- a/gnuradio-core/src/lib/filter/generate_utils.py +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright 2003,2005 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -## ----------------------------------------------------------------------- -## signatures defines which variations to generate (input, output, taps) - -fir_signatures = [ 'ccf', 'fcc', 'ccc', 'fff', 'scc', 'fsf' ] - - -## ----------------------------------------------------------------------- - -from build_utils import expand_template, copyright, open_and_log_name, standard_dict -from build_utils_codes import * diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.cc b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.cc deleted file mode 100644 index da407caa0c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_adaptive_fir_ccc.h> -#include <gr_io_signature.h> - -gr_adaptive_fir_ccc::gr_adaptive_fir_ccc(const char *name, int decimation, - const std::vector<gr_complex> &taps) - : gr_sync_decimator (name, - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - decimation), - d_updated(false), d_taps(taps) -{ - set_history(d_taps.size()); -} - -void -gr_adaptive_fir_ccc::set_taps(const std::vector<gr_complex> &taps) -{ - d_new_taps = taps; - d_updated = true; -} - -gr_complex -gr_adaptive_fir_ccc::filter(gr_complex *x) -{ - // Generic dot product of d_taps[] and in[] - gr_complex acc(0.0, 0.0); - int l = d_taps.size(); - for (int k = 0; k < l; k++) - acc += d_taps[l-k-1] * x[k]; - return acc; -} - -int -gr_adaptive_fir_ccc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *)input_items[0]; - gr_complex *out = (gr_complex *)output_items[0]; - - if (d_updated) { - d_taps = d_new_taps; - set_history(d_taps.size()); - d_updated = false; - return 0; // history requirements may have changed. - } - - int j = 0, k, l = d_taps.size(); - for (int i = 0; i < noutput_items; i++) { - out[i] = filter(&in[j]); - - // Adjust taps - d_error = error(out[i]); - for (k = 0; k < l; k++) { - update_tap(d_taps[l-k-1], in[j+k]); - } - - j += decimation(); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h deleted file mode 100644 index d144c3eb46..0000000000 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_ADAPTIVE_FIR_CCC_H -#define INCLUDED_GR_ADAPTIVE_FIR_CCC_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -/*! - * \brief Adaptive FIR filter with gr_complex input, gr_complex output and float taps - * \ingroup filter_blk - */ -class GR_CORE_API gr_adaptive_fir_ccc : public gr_sync_decimator -{ -private: - std::vector<gr_complex> d_new_taps; - bool d_updated; - -protected: - gr_complex d_error; - std::vector<gr_complex> d_taps; - - // Override to calculate error signal per output - virtual gr_complex error(const gr_complex &out) = 0; - - // Override to calculate new weight from old, corresponding input - virtual void update_tap(gr_complex &tap, const gr_complex &in) = 0; - - gr_complex filter(gr_complex *x); - - gr_adaptive_fir_ccc(const char *name, int decimation, - const std::vector<gr_complex> &taps); - -public: - void set_taps(const std::vector<gr_complex> &taps); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.i b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.i deleted file mode 100644 index a3c875a3dc..0000000000 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -class gr_adaptive_fir_ccc : public gr_sync_decimator -{ -protected: - gr_adaptive_fir_ccc(char *name, int decimation, - const std::vector<gr_complex> &taps); - -public: - void set_taps(const std::vector<gr_complex> &taps); -}; diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.cc b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.cc deleted file mode 100644 index 045d9faf92..0000000000 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_adaptive_fir_ccf.h> -#include <gr_io_signature.h> - -gr_adaptive_fir_ccf::gr_adaptive_fir_ccf(const char *name, int decimation, const std::vector<float> &taps) - : gr_sync_decimator (name, - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - decimation), - d_updated(false) -{ - d_taps = taps; - set_history(d_taps.size()); -} - -void gr_adaptive_fir_ccf::set_taps(const std::vector<float> &taps) -{ - d_new_taps = taps; - d_updated = true; -} - -int gr_adaptive_fir_ccf::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *)input_items[0]; - gr_complex *out = (gr_complex *)output_items[0]; - - if (d_updated) { - d_taps = d_new_taps; - set_history(d_taps.size()); - d_updated = false; - return 0; // history requirements may have changed. - } - - int j = 0, k, l = d_taps.size(); - for (int i = 0; i < noutput_items; i++) { - // Generic dot product of d_taps[] and in[] - gr_complex sum(0.0, 0.0); - for (k = 0; k < l; k++) - sum += d_taps[l-k-1]*in[j+k]; - out[i] = sum; - - // Adjust taps - d_error = error(sum); - for (k = 0; k < l; k++) { - //printf("%f ", d_taps[k]); - update_tap(d_taps[l-k-1], in[j+k]); - } - //printf("\n"); - - j += decimation(); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h deleted file mode 100644 index 7ec78099f8..0000000000 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_ADAPTIVE_FIR_CCF_H -#define INCLUDED_GR_ADAPTIVE_FIR_CCF_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -/*! - * \brief Adaptive FIR filter with gr_complex input, gr_complex output and float taps - * \ingroup filter_blk - */ -class GR_CORE_API gr_adaptive_fir_ccf : public gr_sync_decimator -{ -private: - std::vector<float> d_new_taps; - bool d_updated; - -protected: - float d_error; - std::vector<float> d_taps; - - // Override to calculate error signal per output - virtual float error(const gr_complex &out) = 0; - - // Override to calculate new weight from old, corresponding input - virtual void update_tap(float &tap, const gr_complex &in) = 0; - - gr_adaptive_fir_ccf(const char *name, int decimation, const std::vector<float> &taps); - -public: - void set_taps(const std::vector<float> &taps); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.i b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.i deleted file mode 100644 index 346defd4d1..0000000000 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -class gr_adaptive_fir_ccf : public gr_sync_decimator -{ -protected: - gr_adaptive_fir_ccf(char *name, int decimation, const std::vector<float> &taps); - -public: - void set_taps(const std::vector<float> &taps); -}; diff --git a/gnuradio-core/src/lib/filter/gr_altivec.c b/gnuradio-core/src/lib/filter/gr_altivec.c deleted file mode 100644 index 22a67291d4..0000000000 --- a/gnuradio-core/src/lib/filter/gr_altivec.c +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <gr_altivec.h> - -void -gr_print_vector_float(FILE *fp, vec_float4 v) -{ - union v_float_u u; - u.v = v; - fprintf(fp, "{ %f, %f, %f, %f }", u.f[0], u.f[1], u.f[2], u.f[3]); -} - -void -gr_pvf(FILE *fp, const char *label, vec_float4 v) -{ - fprintf(fp, "%s = ", label); - gr_print_vector_float(fp, v); - putc('\n', fp); -} diff --git a/gnuradio-core/src/lib/filter/gr_altivec.h b/gnuradio-core/src/lib/filter/gr_altivec.h deleted file mode 100644 index ed11490f58..0000000000 --- a/gnuradio-core/src/lib/filter/gr_altivec.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_GR_ALTIVEC_H -#define INCLUDED_GR_ALTIVEC_H - -/* - * N.B., always use "vec_float4" et al. instead of "vector float" to - * ensure portability across the various powerpc compilers. Some of - * them treat "vector" as a context specific keyword, some don't. - * Avoid the problem by always using the defines in vec_types.h - * (included below) - */ - -#include <gr_core_api.h> -#include <altivec.h> -#undef bool // repair namespace pollution -#undef vector // repair namespace pollution - -#ifdef HAVE_VEC_TYPES_H -#include <vec_types.h> // use system version if we've got it -#else -#include <gr_vec_types.h> // fall back to our local copy -#endif -#undef qword // repair namespace pollution - -#include <stddef.h> -#include <stdio.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define VS sizeof(vec_float4) -#define FLOATS_PER_VEC (sizeof(vec_float4)/sizeof(float)) - -union v_float_u { - vec_float4 v; - float f[FLOATS_PER_VEC]; -}; - -GR_CORE_API void gr_print_vector_float(FILE *fp, vec_float4 v); -GR_CORE_API void gr_pvf(FILE *fp, const char *label, vec_float4 v); - -static inline float -horizontal_add_f(vec_float4 v) -{ - union v_float_u u; - vec_float4 t0 = vec_add(v, vec_sld(v, v, 8)); - vec_float4 t1 = vec_add(t0, vec_sld(t0, t0, 4)); - u.v = t1; - return u.f[0]; -} - -#ifdef __cplusplus -} -#endif - -#endif /* INCLUDED_GR_ALTIVEC_H */ diff --git a/gnuradio-core/src/lib/filter/gr_cpu.h b/gnuradio-core/src/lib/filter/gr_cpu.h deleted file mode 100644 index 35824ac1ee..0000000000 --- a/gnuradio-core/src/lib/filter/gr_cpu.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _GR_CPU_H_ -#define _GR_CPU_H_ - -#include <gr_core_api.h> - -struct GR_CORE_API gr_cpu { - static bool has_mmx (); - static bool has_sse (); - static bool has_sse2 (); - static bool has_sse3 (); - static bool has_ssse3 (); - static bool has_sse4_1 (); - static bool has_sse4_2 (); - static bool has_3dnow (); - static bool has_3dnowext (); - static bool has_altivec (); - static bool has_armv7_a (); -}; - -#endif /* _GR_CPU_H_ */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/filter/gr_cpu_armv7_a.cc b/gnuradio-core/src/lib/filter/gr_cpu_armv7_a.cc deleted file mode 100644 index 2450492066..0000000000 --- a/gnuradio-core/src/lib/filter/gr_cpu_armv7_a.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gr_cpu.h> - -bool -gr_cpu::has_mmx () -{ - return false; -} - -bool -gr_cpu::has_sse () -{ - return false; -} - -bool -gr_cpu::has_sse2 () -{ - return false; -} - -bool -gr_cpu::has_3dnow () -{ - return false; -} - -bool -gr_cpu::has_3dnowext () -{ - return false; -} - -bool -gr_cpu::has_altivec () -{ - return false; -} - -bool -gr_cpu::has_armv7_a () -{ - return true; -} diff --git a/gnuradio-core/src/lib/filter/gr_cpu_powerpc.cc b/gnuradio-core/src/lib/filter/gr_cpu_powerpc.cc deleted file mode 100644 index d613f0ae45..0000000000 --- a/gnuradio-core/src/lib/filter/gr_cpu_powerpc.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gr_cpu.h> - -bool -gr_cpu::has_mmx () -{ - return false; -} - -bool -gr_cpu::has_sse () -{ - return false; -} - -bool -gr_cpu::has_sse2 () -{ - return false; -} - -bool -gr_cpu::has_3dnow () -{ - return false; -} - -bool -gr_cpu::has_3dnowext () -{ - return false; -} - -bool -gr_cpu::has_altivec () -{ - return true; // FIXME assume we've always got it -} - -bool -gr_cpu::has_armv7_a () -{ - return false; -} diff --git a/gnuradio-core/src/lib/filter/gr_cpu_x86.cc b/gnuradio-core/src/lib/filter/gr_cpu_x86.cc deleted file mode 100644 index 3acd694d55..0000000000 --- a/gnuradio-core/src/lib/filter/gr_cpu_x86.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gr_cpu.h> -#include "gcc_x86_cpuid.h" - -/* - * execute CPUID instruction, return EAX, EBX, ECX and EDX values in result - */ -#define cpuid_x86(op, r) __get_cpuid(op, r+0, r+1, r+2, r+3) - -/* - * CPUID functions returning a single datum - */ - -static inline unsigned int cpuid_eax(unsigned int op) -{ - unsigned int regs[4] = {0,0,0,0}; - cpuid_x86 (op, regs); - return regs[0]; -} - -static inline unsigned int cpuid_ebx(unsigned int op) -{ - unsigned int regs[4] = {0,0,0,0}; - cpuid_x86 (op, regs); - return regs[1]; -} - -static inline unsigned int cpuid_ecx(unsigned int op) -{ - unsigned int regs[4] = {0,0,0,0}; - cpuid_x86 (op, regs); - return regs[2]; -} - -static inline unsigned int cpuid_edx(unsigned int op) -{ - unsigned int regs[4] = {0,0,0,0}; - cpuid_x86 (op, regs); - return regs[3]; -} - -// ---------------------------------------------------------------- - -bool -gr_cpu::has_mmx () -{ - unsigned int edx = cpuid_edx (1); // standard features - return (edx & (1 << 23)) != 0; -} - -bool -gr_cpu::has_sse () -{ - unsigned int edx = cpuid_edx (1); // standard features - return (edx & (1 << 25)) != 0; -} - -bool -gr_cpu::has_sse2 () -{ - unsigned int edx = cpuid_edx (1); // standard features - return (edx & (1 << 26)) != 0; -} - -bool -gr_cpu::has_3dnow () -{ - unsigned int extended_fct_count = cpuid_eax (0x80000000); - if (extended_fct_count < 0x80000001) - return false; - - unsigned int extended_features = cpuid_edx (0x80000001); - return (extended_features & (1 << 31)) != 0; -} - -bool -gr_cpu::has_3dnowext () -{ - unsigned int extended_fct_count = cpuid_eax (0x80000000); - if (extended_fct_count < 0x80000001) - return false; - - unsigned int extended_features = cpuid_edx (0x80000001); - return (extended_features & (1 << 30)) != 0; -} - -bool -gr_cpu::has_altivec () -{ - return false; -} - -bool -gr_cpu::has_armv7_a () -{ - return false; -} - diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.cc b/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.cc deleted file mode 100644 index 0438a193fa..0000000000 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_dc_blocker_cc.h> -#include <gr_io_signature.h> -#include <cstdio> - -moving_averager_c::moving_averager_c(int D) - : d_length(D), d_out(0), d_out_d1(0), d_out_d2(0) -{ - d_delay_line = std::deque<gr_complex>(d_length-1, gr_complex(0,0)); -} - -moving_averager_c::~moving_averager_c() -{ -} - -gr_complex -moving_averager_c::filter(gr_complex x) -{ - d_out_d1 = d_out; - d_delay_line.push_back(x); - d_out = d_delay_line[0]; - d_delay_line.pop_front(); - - gr_complex y = x - d_out_d1 + d_out_d2; - d_out_d2 = y; - - return (y / (float)(d_length)); -} - - - -gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D, bool long_form) -{ - return gnuradio::get_initial_sptr(new gr_dc_blocker_cc(D, long_form)); -} - - -gr_dc_blocker_cc::gr_dc_blocker_cc (int D, bool long_form) - : gr_sync_block ("dc_blocker_cc", - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex))), - d_length(D), d_long_form(long_form) -{ - if(d_long_form) { - d_ma_0 = new moving_averager_c(D); - d_ma_1 = new moving_averager_c(D); - d_ma_2 = new moving_averager_c(D); - d_ma_3 = new moving_averager_c(D); - d_delay_line = std::deque<gr_complex>(d_length-1, gr_complex(0,0)); - } - else { - d_ma_0 = new moving_averager_c(D); - d_ma_1 = new moving_averager_c(D); - } -} - -gr_dc_blocker_cc::~gr_dc_blocker_cc() -{ - if(d_long_form) { - delete d_ma_0; - delete d_ma_1; - delete d_ma_2; - delete d_ma_3; - } - else { - delete d_ma_0; - delete d_ma_1; - } -} - -int -gr_dc_blocker_cc::get_group_delay() -{ - if(d_long_form) - return (2*d_length-2); - else - return d_length - 1; -} - -int -gr_dc_blocker_cc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex*)input_items[0]; - gr_complex *out = (gr_complex*)output_items[0]; - - if(d_long_form) { - gr_complex y1, y2, y3, y4, d; - for(int i = 0; i < noutput_items; i++) { - y1 = d_ma_0->filter(in[i]); - y2 = d_ma_1->filter(y1); - y3 = d_ma_2->filter(y2); - y4 = d_ma_3->filter(y3); - - d_delay_line.push_back(d_ma_0->delayed_sig()); - d = d_delay_line[0]; - d_delay_line.pop_front(); - - out[i] = d - y4; - } - } - else { - gr_complex y1, y2; - for(int i = 0; i < noutput_items; i++) { - y1 = d_ma_0->filter(in[i]); - y2 = d_ma_1->filter(y1); - out[i] = d_ma_0->delayed_sig() - y2; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h b/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h deleted file mode 100644 index e4d89a775c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef INCLUDED_GR_DC_BLOCKER_CC_H -#define INCLUDED_GR_DC_BLOCKER_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <deque> - -class GR_CORE_API moving_averager_c -{ -public: - moving_averager_c(int D); - ~moving_averager_c(); - - gr_complex filter(gr_complex x); - gr_complex delayed_sig() { return d_out; } - -private: - int d_length; - gr_complex d_out, d_out_d1, d_out_d2; - std::deque<gr_complex> d_delay_line; -}; - -class gr_dc_blocker_cc; -typedef boost::shared_ptr<gr_dc_blocker_cc> gr_dc_blocker_cc_sptr; -GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D=32, bool long_form=true); - -/*! - * \class gr_dc_blocker_cc - * \brief a computationally efficient controllable DC blocker - * - * \ingroup filter_blk - * - * This block implements a computationally efficient DC blocker that produces - * a tighter notch filter around DC for a smaller group delay than an - * equivalent FIR filter or using a single pole IIR filter (though the IIR - * filter is computationally cheaper). - * - * The block defaults to using a delay line of length 32 and the long form - * of the filter. Optionally, the delay line length can be changed to alter - * the width of the DC notch (longer lines will decrease the width). - * - * The long form of the filter produces a nearly flat response outside of - * the notch but at the cost of a group delay of 2D-2. - * - * The short form of the filter does not have as flat a response in the - * passband but has a group delay of only D-1 and is cheaper to compute. - * - * The theory behind this block can be found in the paper: - * - * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine, - * Mar. 2008, pp 132-134.</EM></B> - */ -class GR_CORE_API gr_dc_blocker_cc : public gr_sync_block -{ - private: - /*! - * Build the DC blocker. - * \param D (int) the length of the delay line - * \param long_form (bool) whether to use long (true, default) or short form - */ - friend GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D, bool long_form); - - int d_length; - bool d_long_form; - moving_averager_c *d_ma_0; - moving_averager_c *d_ma_1; - moving_averager_c *d_ma_2; - moving_averager_c *d_ma_3; - std::deque<gr_complex> d_delay_line; - - gr_dc_blocker_cc (int D, bool long_form); - -public: - ~gr_dc_blocker_cc (); - - /*! - * Get the blocker's group delay that is based on length of delay lines - */ - int get_group_delay(); - - //int set_length(int D); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.i b/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.i deleted file mode 100644 index 83d05044b8..0000000000 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,dc_blocker_cc); - -gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D=32, bool long_form=true); - -class gr_dc_blocker_cc : public gr_sync_block -{ - private: - gr_dc_blocker_cc (int D, bool long_form); - - public: - ~gr_dc_blocker_cc (); -}; diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.cc b/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.cc deleted file mode 100644 index 04ee648797..0000000000 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_dc_blocker_ff.h> -#include <gr_io_signature.h> -#include <cstdio> - -moving_averager_f::moving_averager_f(int D) - : d_length(D), d_out(0), d_out_d1(0), d_out_d2(0) -{ - d_delay_line = std::deque<float>(d_length-1, 0); -} - -moving_averager_f::~moving_averager_f() -{ -} - -float -moving_averager_f::filter(float x) -{ - d_out_d1 = d_out; - d_delay_line.push_back(x); - d_out = d_delay_line[0]; - d_delay_line.pop_front(); - - float y = x - d_out_d1 + d_out_d2; - d_out_d2 = y; - - return (y / (float)(d_length)); -} - - - -gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D, bool long_form) -{ - return gnuradio::get_initial_sptr(new gr_dc_blocker_ff(D, long_form)); -} - - -gr_dc_blocker_ff::gr_dc_blocker_ff (int D, bool long_form) - : gr_sync_block ("dc_blocker_ff", - gr_make_io_signature (1, 1, sizeof(float)), - gr_make_io_signature (1, 1, sizeof(float))), - d_length(D), d_long_form(long_form) -{ - if(d_long_form) { - d_ma_0 = new moving_averager_f(D); - d_ma_1 = new moving_averager_f(D); - d_ma_2 = new moving_averager_f(D); - d_ma_3 = new moving_averager_f(D); - d_delay_line = std::deque<float>(d_length-1, 0); - } - else { - d_ma_0 = new moving_averager_f(D); - d_ma_1 = new moving_averager_f(D); - } -} - -gr_dc_blocker_ff::~gr_dc_blocker_ff() -{ - if(d_long_form) { - delete d_ma_0; - delete d_ma_1; - delete d_ma_2; - delete d_ma_3; - } - else { - delete d_ma_0; - delete d_ma_1; - } -} - -int -gr_dc_blocker_ff::get_group_delay() -{ - if(d_long_form) - return (2*d_length-2); - else - return d_length - 1; -} - -int -gr_dc_blocker_ff::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float*)input_items[0]; - float *out = (float*)output_items[0]; - - if(d_long_form) { - float y1, y2, y3, y4, d; - for(int i = 0; i < noutput_items; i++) { - y1 = d_ma_0->filter(in[i]); - y2 = d_ma_1->filter(y1); - y3 = d_ma_2->filter(y2); - y4 = d_ma_3->filter(y3); - - d_delay_line.push_back(d_ma_0->delayed_sig()); - d = d_delay_line[0]; - d_delay_line.pop_front(); - - out[i] = d - y4; - } - } - else { - float y1, y2; - for(int i = 0; i < noutput_items; i++) { - y1 = d_ma_0->filter(in[i]); - y2 = d_ma_1->filter(y1); - out[i] = d_ma_0->delayed_sig() - y2; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h b/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h deleted file mode 100644 index d69f24835b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef INCLUDED_GR_DC_BLOCKER_FF_H -#define INCLUDED_GR_DC_BLOCKER_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <deque> - -class GR_CORE_API moving_averager_f -{ -public: - moving_averager_f(int D); - ~moving_averager_f(); - - float filter(float x); - float delayed_sig() { return d_out; } - -private: - int d_length; - float d_out, d_out_d1, d_out_d2; - std::deque<float> d_delay_line; -}; - - -class gr_dc_blocker_ff; -typedef boost::shared_ptr<gr_dc_blocker_ff> gr_dc_blocker_ff_sptr; -GR_CORE_API gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D=32, bool long_form=true); - -/*! - * \class gr_dc_blocker_ff - * \brief a computationally efficient controllable DC blocker - * - * \ingroup filter_blk - * - * This block implements a computationally efficient DC blocker that produces - * a tighter notch filter around DC for a smaller group delay than an - * equivalent FIR filter or using a single pole IIR filter (though the IIR - * filter is computationally cheaper). - * - * The block defaults to using a delay line of length 32 and the long form - * of the filter. Optionally, the delay line length can be changed to alter - * the width of the DC notch (longer lines will decrease the width). - * - * The long form of the filter produces a nearly flat response outside of - * the notch but at the cost of a group delay of 2D-2. - * - * The short form of the filter does not have as flat a response in the - * passband but has a group delay of only D-1 and is cheaper to compute. - * - * The theory behind this block can be found in the paper: - * - * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine, - * Mar. 2008, pp 132-134.</EM></B> - */ -class GR_CORE_API gr_dc_blocker_ff : public gr_sync_block -{ - private: - /*! - * Build the DC blocker. - * \param D (int) the length of the delay line - * \param long_form (bool) whether to use long (true, default) or short form - */ - friend GR_CORE_API gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D, bool long_form); - - int d_length; - bool d_long_form; - moving_averager_f *d_ma_0; - moving_averager_f *d_ma_1; - moving_averager_f *d_ma_2; - moving_averager_f *d_ma_3; - std::deque<float> d_delay_line; - - gr_dc_blocker_ff (int D, bool long_form); - -public: - ~gr_dc_blocker_ff (); - - /*! - * Get the blocker's group delay that is based on length of delay lines - */ - int get_group_delay(); - - //int set_length(int D); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.i b/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.i deleted file mode 100644 index 065eb441d6..0000000000 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,dc_blocker_ff); - -gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D=32, bool long_form=true); - -class gr_dc_blocker_ff : public gr_sync_block -{ - private: - gr_dc_blocker_ff (int D, bool long_form); - - public: - ~gr_dc_blocker_ff (); -}; diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.cc b/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.cc deleted file mode 100644 index 08e231a442..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by generate_gr_fft_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_fft_filter_ccc.h> -#include <gri_fft_filter_ccc_generic.h> -#include <gr_io_signature.h> -#include <gri_fft.h> -#include <math.h> -#include <assert.h> -#include <stdexcept> -#include <gr_firdes.h> - -#include <cstdio> -#include <iostream> -#include <string.h> - -gr_fft_filter_ccc_sptr gr_make_fft_filter_ccc (int decimation, - const std::vector<gr_complex> &taps, - int nthreads) -{ - return gnuradio::get_initial_sptr(new gr_fft_filter_ccc (decimation, taps, nthreads)); -} - - -gr_fft_filter_ccc::gr_fft_filter_ccc (int decimation, - const std::vector<gr_complex> &taps, - int nthreads) - : gr_sync_decimator ("fft_filter_ccc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex)), - decimation), - d_updated(false) -{ - set_history(1); - -#if 1 // don't enable the sse version until handling it is worked out - d_filter = new gri_fft_filter_ccc_generic(decimation, taps, nthreads); -#else - d_filter = new gri_fft_filter_ccc_sse(decimation, taps); -#endif - - d_new_taps = taps; - d_nsamples = d_filter->set_taps(taps); - set_output_multiple(d_nsamples); -} - -gr_fft_filter_ccc::~gr_fft_filter_ccc () -{ - delete d_filter; -} - -void -gr_fft_filter_ccc::set_taps (const std::vector<gr_complex> &taps) -{ - d_new_taps = taps; - d_updated = true; -} - -std::vector<gr_complex> -gr_fft_filter_ccc::taps () const -{ - return d_new_taps; -} - -void -gr_fft_filter_ccc::set_nthreads(int n) -{ - if(d_filter) - d_filter->set_nthreads(n); -} - -int -gr_fft_filter_ccc::nthreads() const -{ - if(d_filter) - return d_filter->nthreads(); - else - return 0; -} - - -int -gr_fft_filter_ccc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - if (d_updated){ - d_nsamples = d_filter->set_taps(d_new_taps); - d_updated = false; - set_output_multiple(d_nsamples); - return 0; // output multiple may have changed - } - - assert(noutput_items % d_nsamples == 0); - - d_filter->filter(noutput_items, in, out); - - //assert((out - (gr_complex *) output_items[0]) == noutput_items); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h b/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h deleted file mode 100644 index 4b478b65f7..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FFT_FILTER_CCC_H -#define INCLUDED_GR_FFT_FILTER_CCC_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_fft_filter_ccc; -typedef boost::shared_ptr<gr_fft_filter_ccc> gr_fft_filter_ccc_sptr; -GR_CORE_API gr_fft_filter_ccc_sptr -gr_make_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps, - int nthreads=1); - -//class gri_fft_filter_ccc_sse; -class gri_fft_filter_ccc_generic; - -/*! - * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps - * \ingroup filter_blk - */ -class GR_CORE_API gr_fft_filter_ccc : public gr_sync_decimator -{ - private: - friend GR_CORE_API gr_fft_filter_ccc_sptr - gr_make_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps, - int nthreads); - - int d_nsamples; - bool d_updated; -#if 1 // don't enable the sse version until handling it is worked out - gri_fft_filter_ccc_generic *d_filter; -#else - gri_fft_filter_ccc_sse *d_filter; -#endif - std::vector<gr_complex> d_new_taps; - - /*! - * Construct a FFT filter with the given taps - * - * \param decimation >= 1 - * \param taps complex filter taps - * \param nthreads number of threads for the FFT to use - */ - gr_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps, - int nthreads=1); - - public: - ~gr_fft_filter_ccc (); - - void set_taps (const std::vector<gr_complex> &taps); - std::vector<gr_complex> taps () const; - - /*! - * \brief Set number of threads to use. - */ - void set_nthreads(int n); - - /*! - * \brief Get number of threads being used. - */ - int nthreads() const; - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - - -#endif /* INCLUDED_GR_FFT_FILTER_CCC_H */ diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.i b/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.i deleted file mode 100644 index 76837b582b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.i +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,fft_filter_ccc) - -gr_fft_filter_ccc_sptr -gr_make_fft_filter_ccc (int decimation, - const std::vector<gr_complex> &taps, - int nthreads=1 - ) throw (std::invalid_argument); - -class gr_fft_filter_ccc : public gr_sync_decimator -{ - private: - gr_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps, - int nthreads=1); - - public: - ~gr_fft_filter_ccc (); - - void set_taps (const std::vector<gr_complex> &taps); - std::vector<gr_complex> taps () const; - - void set_nthreads(int n); - int nthreads() const; - -}; diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.cc b/gnuradio-core/src/lib/filter/gr_fft_filter_fff.cc deleted file mode 100644 index a09feb7f1f..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.cc +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_fft_filter_fff.h> -#include <gri_fft_filter_fff_generic.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <stdexcept> - -#include <cstdio> -#include <iostream> -#include <string.h> - -gr_fft_filter_fff_sptr gr_make_fft_filter_fff (int decimation, - const std::vector<float> &taps, - int nthreads) -{ - return gnuradio::get_initial_sptr(new gr_fft_filter_fff (decimation, taps, nthreads)); -} - - -gr_fft_filter_fff::gr_fft_filter_fff (int decimation, - const std::vector<float> &taps, - int nthreads) - : gr_sync_decimator ("fft_filter_fff", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (float)), - decimation), - d_updated(false) -{ - set_history(1); - -#if 1 // don't enable the sse version until handling it is worked out - d_filter = new gri_fft_filter_fff_generic(decimation, taps, nthreads); -#else - d_filter = new gri_fft_filter_fff_sse(decimation, taps); -#endif - - d_new_taps = taps; - d_nsamples = d_filter->set_taps(taps); - set_output_multiple(d_nsamples); -} - -gr_fft_filter_fff::~gr_fft_filter_fff () -{ - delete d_filter; -} - -void -gr_fft_filter_fff::set_taps (const std::vector<float> &taps) -{ - d_new_taps = taps; - d_updated = true; -} - -std::vector<float> -gr_fft_filter_fff::taps () const -{ - return d_new_taps; -} - -void -gr_fft_filter_fff::set_nthreads(int n) -{ - if(d_filter) - d_filter->set_nthreads(n); -} - -int -gr_fft_filter_fff::nthreads() const -{ - if(d_filter) - return d_filter->nthreads(); - else - return 0; -} - -int -gr_fft_filter_fff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - if (d_updated){ - d_nsamples = d_filter->set_taps(d_new_taps); - d_updated = false; - set_output_multiple(d_nsamples); - return 0; // output multiple may have changed - } - - assert(noutput_items % d_nsamples == 0); - - d_filter->filter(noutput_items, in, out); - - //assert((out - (float *) output_items[0]) == noutput_items); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h b/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h deleted file mode 100644 index 309a551352..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FFT_FILTER_FFF_H -#define INCLUDED_GR_FFT_FILTER_FFF_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_fft_filter_fff; -typedef boost::shared_ptr<gr_fft_filter_fff> gr_fft_filter_fff_sptr; -GR_CORE_API gr_fft_filter_fff_sptr -gr_make_fft_filter_fff (int decimation, const std::vector<float> &taps, - int nthreads=1); - -class gri_fft_filter_fff_generic; -//class gri_fft_filter_fff_sse; - -/*! - * \brief Fast FFT filter with float input, float output and float taps - * \ingroup filter_blk - */ -class GR_CORE_API gr_fft_filter_fff : public gr_sync_decimator -{ - private: - friend GR_CORE_API gr_fft_filter_fff_sptr - gr_make_fft_filter_fff (int decimation, const std::vector<float> &taps, - int nthreads); - - int d_nsamples; - bool d_updated; -#if 1 // don't enable the sse version until handling it is worked out - gri_fft_filter_fff_generic *d_filter; -#else - gri_fft_filter_fff_sse *d_filter; -#endif - std::vector<float> d_new_taps; - - /*! - * Construct a FFT filter with the given taps - * - * \param decimation >= 1 - * \param taps float filter taps - * \param nthreads number of threads for the FFT to use - */ - gr_fft_filter_fff (int decimation, const std::vector<float> &taps, - int nthreads=1); - - public: - ~gr_fft_filter_fff (); - - void set_taps (const std::vector<float> &taps); - std::vector<float> taps () const; - - /*! - * \brief Set number of threads to use. - */ - void set_nthreads(int n); - - /*! - * \brief Get number of threads being used. - */ - int nthreads() const; - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FFT_FILTER_FFF_H */ diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.i b/gnuradio-core/src/lib/filter/gr_fft_filter_fff.i deleted file mode 100644 index 86c554893e..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.i +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,fft_filter_fff) - -gr_fft_filter_fff_sptr -gr_make_fft_filter_fff (int decimation, - const std::vector<float> &taps, - int nthreads=1 - ) throw (std::invalid_argument); - -class gr_fft_filter_fff : public gr_sync_decimator -{ - private: - gr_fft_filter_fff (int decimation, const std::vector<float> &taps, - int nthreads=1); - - public: - ~gr_fft_filter_fff (); - - void set_taps (const std::vector<float> &taps); - std::vector<float> taps () const; - void set_nthreads(int n); - int nthreads() const; - -}; diff --git a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.cc b/gnuradio-core/src/lib/filter/gr_filter_delay_fc.cc deleted file mode 100644 index af8a8e9e7d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_filter_delay_fc.h> -#include <gr_fir_fff.h> -#include <gr_fir_util.h> - -// public constructor -gr_filter_delay_fc_sptr -gr_make_filter_delay_fc (const std::vector<float> &taps) -{ - return gnuradio::get_initial_sptr(new gr_filter_delay_fc (taps)); -} - -gr_filter_delay_fc::gr_filter_delay_fc (const std::vector<float> &taps) - : gr_sync_block ("filter_delay_fc", - gr_make_io_signature (1, 2, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (gr_complex))) -{ - d_fir = gr_fir_util::create_gr_fir_fff (taps); - d_delay = d_fir->ntaps () / 2; - set_history (d_fir->ntaps ()); -} - -gr_filter_delay_fc::~gr_filter_delay_fc () -{ - delete d_fir; -} - -int -gr_filter_delay_fc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *in0 = (float *) input_items[0]; - float *in1 = (float *) input_items[1]; - gr_complex *out = (gr_complex *) output_items[0]; - - switch (input_items.size ()){ - case 1: - for (int i = 0; i < noutput_items; i++) - out[i] = gr_complex (in0[i + d_delay], - d_fir->filter (&in0[i])); - break; - - case 2: - for (int j = 0; j < noutput_items; j++) - out[j] = gr_complex (in0[j + d_delay], - d_fir->filter (&in1[j])); - break; - - default: - assert (0); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h b/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h deleted file mode 100644 index fee11243a5..0000000000 --- a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FILTER_DELAY_FC_H -#define INCLUDED_GR_FILTER_DELAY_FC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_io_signature.h> -#include <gr_types.h> - -class gr_filter_delay_fc; -typedef boost::shared_ptr<gr_filter_delay_fc> gr_filter_delay_fc_sptr; - -// public constructor -GR_CORE_API gr_filter_delay_fc_sptr gr_make_filter_delay_fc (const std::vector<float> &taps); - -class gr_fir_fff; - -/*! - * \brief Filter-Delay Combination Block. - * \ingroup filter_blk - * - * The block takes one or two float stream and outputs a complex - * stream. If only one float stream is input, the real output is - * a delayed version of this input and the imaginary output is the - * filtered output. If two floats are connected to the input, then - * the real output is the delayed version of the first input, and - * the imaginary output is the filtered output. The delay in the - * real path accounts for the group delay introduced by the filter - * in the imaginary path. The filter taps needs to be calculated - * before initializing this block. - * - */ -class GR_CORE_API gr_filter_delay_fc : public gr_sync_block -{ - public: - ~gr_filter_delay_fc (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - protected: - gr_filter_delay_fc (const std::vector<float> &taps); - - private: - unsigned int d_delay; - gr_fir_fff *d_fir; - - friend GR_CORE_API gr_filter_delay_fc_sptr gr_make_filter_delay_fc (const std::vector<float> &taps); -}; - -#endif /* INCLUDED_GR_FILTER_DELAY_FC_H */ diff --git a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.i b/gnuradio-core/src/lib/filter/gr_filter_delay_fc.i deleted file mode 100644 index 54b721cee7..0000000000 --- a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,filter_delay_fc); - -gr_filter_delay_fc_sptr gr_make_filter_delay_fc (const std::vector<float> &taps); - -class gr_filter_delay_fc : public gr_sync_block -{ -private: - gr_filter_delay_fc (); -}; - -// ---------------------------------------------------------------- - diff --git a/gnuradio-core/src/lib/filter/gr_fir_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_fir_XXX.cc.t deleted file mode 100644 index 2396f0fe66..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_XXX.cc.t +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <@FIR_TYPE@.h> - -@FIR_TYPE@::~@FIR_TYPE@ () -{ -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_XXX.h.t b/gnuradio-core/src/lib/filter/gr_fir_XXX.h.t deleted file mode 100644 index 197bb3cd2c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_XXX.h.t +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2003 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 automatically generated by generate_gr_fir_XXX.py - * Any changes made to this file will be overwritten. - */ - - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <vector> -@VRCOMPLEX_INCLUDE@ -#include <gr_reverse.h> - -/*! - * \brief Abstract class for FIR with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_primitive - * - * This is the abstract class for a Finite Impulse Response filter. - * - * The trailing suffix has the form _IOT where I codes the input type, - * O codes the output type, and T codes the tap type. - * I,O,T are elements of the set 's' (short), 'f' (float), 'c' (gr_complex), 'i' (int) - */ - -class GR_CORE_API @FIR_TYPE@ { - -protected: - std::vector<@TAP_TYPE@> d_taps; // reversed taps - -public: - - // CONSTRUCTORS - - /*! - * \brief construct new FIR with given taps. - * - * Note that taps must be in forward order, e.g., coefficient 0 is - * stored in new_taps[0], coefficient 1 is stored in - * new_taps[1], etc. - */ - @FIR_TYPE@ () {} - @FIR_TYPE@ (const std::vector<@TAP_TYPE@> &taps) : d_taps (gr_reverse(taps)) {} - - virtual ~@FIR_TYPE@ (); - - // MANIPULATORS - - /*! - * \brief compute a single output value. - * - * \p input must have ntaps() valid entries. - * input[0] .. input[ntaps() - 1] are referenced to compute the output value. - * - * \returns the filtered input value. - */ - virtual @O_TYPE@ filter (const @I_TYPE@ input[]) = 0; - - /*! - * \brief compute an array of N output values. - * - * \p input must have (n - 1 + ntaps()) valid entries. - * input[0] .. input[n - 1 + ntaps() - 1] are referenced to compute the output values. - */ - virtual void filterN (@O_TYPE@ output[], const @I_TYPE@ input[], - unsigned long n) = 0; - - /*! - * \brief compute an array of N output values, decimating the input - * - * \p input must have (decimate * (n - 1) + ntaps()) valid entries. - * input[0] .. input[decimate * (n - 1) + ntaps() - 1] are referenced to - * compute the output values. - */ - virtual void filterNdec (@O_TYPE@ output[], const @I_TYPE@ input[], - unsigned long n, unsigned decimate) = 0; - - /*! - * \brief install \p new_taps as the current taps. - */ - virtual void set_taps (const std::vector<@TAP_TYPE@> &taps) - { - d_taps = gr_reverse(taps); - } - - // ACCESSORS - - /*! - * \return number of taps in filter. - */ - unsigned ntaps () const { return d_taps.size (); } - - /*! - * \return current taps - */ - virtual const std::vector<@TAP_TYPE@> get_taps () const - { - return gr_reverse(d_taps); - } -}; - -#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.cc.t b/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.cc.t deleted file mode 100644 index 11b4fd50fb..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.cc.t +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <@FIR_TYPE@_generic.h> - -#if (@N_UNROLL@ == 4) - -@O_TYPE@ -@FIR_TYPE@_generic::filter (const @I_TYPE@ input[]) -{ - static const int N_UNROLL = 4; - - @ACC_TYPE@ acc0 = 0; - @ACC_TYPE@ acc1 = 0; - @ACC_TYPE@ acc2 = 0; - @ACC_TYPE@ acc3 = 0; - - - unsigned i = 0; - unsigned n = (ntaps () / N_UNROLL) * N_UNROLL; - - for (i = 0; i < n; i += N_UNROLL){ - acc0 += d_taps[i + 0] * @INPUT_CAST@ input[i + 0]; - acc1 += d_taps[i + 1] * @INPUT_CAST@ input[i + 1]; - acc2 += d_taps[i + 2] * @INPUT_CAST@ input[i + 2]; - acc3 += d_taps[i + 3] * @INPUT_CAST@ input[i + 3]; - } - - for (; i < ntaps (); i++) - acc0 += d_taps[i] * @INPUT_CAST@ input[i]; - - return (@O_TYPE@) (acc0 + acc1 + acc2 + acc3); -} - -#else - -@O_TYPE@ -@FIR_TYPE@_generic::filter (const @I_TYPE@ input[]) -{ - static const int N_UNROLL = 2; - - @ACC_TYPE@ acc0 = 0; - @ACC_TYPE@ acc1 = 0; - - unsigned i = 0; - unsigned n = (ntaps () / N_UNROLL) * N_UNROLL; - - for (i = 0; i < n; i += N_UNROLL){ - acc0 += d_taps[i + 0] * @INPUT_CAST@ input[i + 0]; - acc1 += d_taps[i + 1] * @INPUT_CAST@ input[i + 1]; - } - - for (; i < ntaps (); i++) - acc0 += d_taps[i] * @INPUT_CAST@ input[i]; - - return (@O_TYPE@) (acc0 + acc1); -} - -#endif // N_UNROLL - -void -@FIR_TYPE@_generic::filterN (@O_TYPE@ output[], - const @I_TYPE@ input[], - unsigned long n) -{ - for (unsigned i = 0; i < n; i++) - output[i] = filter (&input[i]); -} - -void -@FIR_TYPE@_generic::filterNdec (@O_TYPE@ output[], - const @I_TYPE@ input[], - unsigned long n, - unsigned decimate) -{ - unsigned j = 0; - for (unsigned i = 0; i < n; i++){ - output[i] = filter (&input[j]); - j += decimate; - } -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.h.t b/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.h.t deleted file mode 100644 index f7382d7393..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.h.t +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <@FIR_TYPE@.h> - -/*! - * \brief Concrete class for generic implementation of FIR with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * - * The trailing suffix has the form _IOT where I codes the input type, - * O codes the output type, and T codes the tap type. - * I,O,T are elements of the set 's' (short), 'f' (float), 'c' (gr_complex), 'i' (int) - */ - -class GR_CORE_API @FIR_TYPE@_generic : public @FIR_TYPE@ { - -public: - - // CREATORS - - @FIR_TYPE@_generic () {} - @FIR_TYPE@_generic (const std::vector<@TAP_TYPE@> &taps) : @FIR_TYPE@ (taps) {} - - // MANIPULATORS - - /*! - * \brief compute a single output value. - * - * \p input must have ntaps() valid entries. - * input[0] .. input[ntaps() - 1] are referenced to compute the output value. - * - * \returns the filtered input value. - */ - virtual @O_TYPE@ filter (const @I_TYPE@ input[]); - - /*! - * \brief compute an array of N output values. - * - * \p input must have (n - 1 + ntaps()) valid entries. - * input[0] .. input[n - 1 + ntaps() - 1] are referenced to compute the output values. - */ - virtual void filterN (@O_TYPE@ output[], const @I_TYPE@ input[], - unsigned long n); - - /*! - * \brief compute an array of N output values, decimating the input - * - * \p input must have (decimate * (n - 1) + ntaps()) valid entries. - * input[0] .. input[decimate * (n - 1) + ntaps() - 1] are referenced to - * compute the output values. - */ - virtual void filterNdec (@O_TYPE@ output[], const @I_TYPE@ input[], - unsigned long n, unsigned decimate); - -}; - -#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.cc b/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.cc deleted file mode 100644 index d88b696c9a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.cc +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_ccc_simd.h> - -#include <assert.h> -#include <malloc16.h> -#include <iostream> -#include <stdexcept> - -using std::cerr; -using std::endl; - -gr_fir_ccc_simd::gr_fir_ccc_simd () - : gr_fir_ccc_generic () -{ - // cerr << "@@@ gr_fir_ccc_simd\n"; - - d_ccomplex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; -} - -gr_fir_ccc_simd::gr_fir_ccc_simd (const std::vector<gr_complex> &new_taps) - : gr_fir_ccc_generic (new_taps) -{ - // cerr << "@@@ gr_fir_ccc_simd\n"; - - d_ccomplex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; - set_taps (new_taps); -} - -gr_fir_ccc_simd::~gr_fir_ccc_simd () -{ - free16Align (d_aligned_taps[0]); - free16Align (d_aligned_taps[1]); - free16Align (d_aligned_taps[2]); - free16Align (d_aligned_taps[3]); -} - -void -gr_fir_ccc_simd::set_taps (const std::vector<gr_complex> &inew_taps) -{ - gr_fir_ccc::set_taps (inew_taps); // call superclass - - const std::vector<gr_complex> new_taps = gr_reverse(inew_taps); - unsigned len = new_taps.size (); - - // Make 4 copies of the coefficients, one for each data alignment - // Note use of special 16-byte-aligned version of calloc() - - for (unsigned i = 0; i < 4; i++){ - free16Align (d_aligned_taps[i]); // free old value - - // this works because the bit representation of a IEEE floating point - // +zero is all zeros. If you're using a different representation, - // you'll need to explictly set the result to the appropriate 0.0 value. - - d_aligned_taps[i] = (float *) calloc16Align (1 + (len + i - 1) / 2, - 2 * 4 * sizeof (float)); - if (d_aligned_taps[i] == 0){ - // throw something... - cerr << "@@@ gr_fir_ccc_simd d_aligned_taps[" << i << "] == 0\n"; - } - - for (unsigned j = 0; j < len; j++) { - d_aligned_taps[i][2*(j+i)] = new_taps[j].real(); - d_aligned_taps[i][2*(j+i)+1] = new_taps[j].imag(); - } - } -} - -gr_complex -gr_fir_ccc_simd::filter (const gr_complex input[]) -{ - if (ntaps () == 0) - return 0.0; - - if (((intptr_t) input & 0x7) != 0) - throw std::invalid_argument("gr_complex must be 8-byte aligned"); - - // Round input data address down to 16 byte boundary - // NB: depending on the alignment of input[], memory - // before input[] will be accessed. The contents don't matter since - // they'll be multiplied by zero coefficients. I can't conceive of any - // situation where this could cause a segfault since memory protection - // in the x86 machines is done on much larger boundaries. - - const gr_complex *ar = (gr_complex *)((unsigned long) input & ~15); - - // Choose one of 4 sets of pre-shifted coefficients. al is both the - // index into d_aligned_taps[] and the number of 0 words padded onto - // that coefficients array for alignment purposes. - - unsigned al = input - ar; - - // call assembler routine to do the work, passing number of 2x4-float blocks. - - // assert (((unsigned long) ar & 15) == 0); - // assert (((unsigned long) d_aligned_taps[al] & 15) == 0); - - // cerr << "ar: " << ar << " d_aligned_taps[ar]: " << d_aligned_taps[al] - // << " (ntaps() + al - 1)/2 + 1: " << (ntaps() + al -1) / 2 + 1 << endl; - - float result[2]; - - d_ccomplex_dotprod ((float*)ar, d_aligned_taps[al], (ntaps() + al - 1) / 2 + 1, result); - - // cerr << "result = " << result[0] << " " << result[1] << endl; - - return gr_complex(result[0], result[1]); -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.h b/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.h deleted file mode 100644 index ed7249c91d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FIR_CCC_SIMD_H -#define INCLUDED_GR_FIR_CCC_SIMD_H - -#include <gr_core_api.h> -#include <gr_fir_ccc_generic.h> - -/*! - * \brief common base class for SIMD versions of gr_fir_ccc - * \ingroup filter_primitive - * - * This base class handles alignment issues common to SSE and 3DNOW - * subclasses. - */ - -class GR_CORE_API gr_fir_ccc_simd : public gr_fir_ccc_generic -{ -protected: - typedef void (*ccomplex_dotprod_t)(const float *input, - const float *taps, - unsigned n_2_ccomplex_blocks, - float *result); - - /*! - * \p aligned_taps holds 4 copies of the coefficients preshifted - * by 0, 1, 2, or 3 floats to meet all possible input data alignments. - * This allows us to always fetch data and taps that are 128-bit aligned. - */ - float *d_aligned_taps[4]; - - ccomplex_dotprod_t d_ccomplex_dotprod; // fast dot product primitive - -public: - - // CREATORS - gr_fir_ccc_simd (); - gr_fir_ccc_simd (const std::vector<gr_complex> &taps); - ~gr_fir_ccc_simd (); - - // MANIPULATORS - virtual void set_taps (const std::vector<gr_complex> &taps); - virtual gr_complex filter (const gr_complex input[]); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.cc deleted file mode 100644 index 28bc008e8a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_ccc_x86.h> -#include <ccomplex_dotprod_x86.h> - -/* - * --- 3DNow! version --- - */ - -gr_fir_ccc_3dnow::gr_fir_ccc_3dnow () - : gr_fir_ccc_simd () -{ - d_ccomplex_dotprod = ccomplex_dotprod_3dnow; -} - -gr_fir_ccc_3dnow::gr_fir_ccc_3dnow (const std::vector<gr_complex> &new_taps) - : gr_fir_ccc_simd (new_taps) -{ - d_ccomplex_dotprod = ccomplex_dotprod_3dnow; -} - - -/* - * --- 3DNow!Ext version --- - */ - -gr_fir_ccc_3dnowext::gr_fir_ccc_3dnowext () - : gr_fir_ccc_simd () -{ - d_ccomplex_dotprod = ccomplex_dotprod_3dnowext; -} - -gr_fir_ccc_3dnowext::gr_fir_ccc_3dnowext (const std::vector<gr_complex> &new_taps) - : gr_fir_ccc_simd (new_taps) -{ - d_ccomplex_dotprod = ccomplex_dotprod_3dnowext; -} - - -/* - * --- SSE version --- - */ - -gr_fir_ccc_sse::gr_fir_ccc_sse () - : gr_fir_ccc_simd () -{ - d_ccomplex_dotprod = ccomplex_dotprod_sse; -} - -gr_fir_ccc_sse::gr_fir_ccc_sse (const std::vector<gr_complex> &new_taps) - : gr_fir_ccc_simd (new_taps) -{ - d_ccomplex_dotprod = ccomplex_dotprod_sse; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.h b/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.h deleted file mode 100644 index 0a9d2c83c3..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FIR_CCC_X86_H -#define INCLUDED_GR_FIR_CCC_X86_H - -#include <gr_core_api.h> -#include <gr_fir_ccc_simd.h> - -/*! - * \brief 3DNow! version of gr_fir_ccc - */ -class GR_CORE_API gr_fir_ccc_3dnow : public gr_fir_ccc_simd -{ -public: - gr_fir_ccc_3dnow (); - gr_fir_ccc_3dnow (const std::vector<gr_complex> &taps); -}; - -class GR_CORE_API gr_fir_ccc_3dnowext : public gr_fir_ccc_simd -{ -public: - gr_fir_ccc_3dnowext (); - gr_fir_ccc_3dnowext (const std::vector<gr_complex> &taps); -}; - -/*! - * \brief SSE version of gr_fir_ccc - */ -class GR_CORE_API gr_fir_ccc_sse : public gr_fir_ccc_simd -{ -public: - gr_fir_ccc_sse (); - gr_fir_ccc_sse (const std::vector<gr_complex> &taps); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_armv7_a.cc b/gnuradio-core/src/lib/filter/gr_fir_ccf_armv7_a.cc deleted file mode 100644 index d849c3dd57..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_armv7_a.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009,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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_fir_ccf_armv7_a.h> -#include <stdlib.h> -#include <string.h> -#include <stdexcept> -#include <assert.h> -#include <gr_math.h> -#include <dotprod_ccf_armv7_a.h> - -#define FLOATS_PER_VEC 4 - -gr_fir_ccf_armv7_a::gr_fir_ccf_armv7_a() - : gr_fir_ccf_generic(), - d_naligned_taps(0), d_aligned_taps(0) -{ -} - -gr_fir_ccf_armv7_a::gr_fir_ccf_armv7_a (const std::vector<float> &new_taps) - : gr_fir_ccf_generic(new_taps), - d_naligned_taps(0), d_aligned_taps(0) -{ - set_taps(new_taps); -} - -gr_fir_ccf_armv7_a::~gr_fir_ccf_armv7_a() -{ - if (d_aligned_taps){ - free(d_aligned_taps); - d_aligned_taps = 0; - } -} - -void -gr_fir_ccf_armv7_a::set_taps(const std::vector<float> &inew_taps) -{ - gr_fir_ccf_generic::set_taps(inew_taps); // call superclass - d_naligned_taps = gr_p2_round_up(ntaps(), FLOATS_PER_VEC); - - if (d_aligned_taps){ - free(d_aligned_taps); - d_aligned_taps = 0; - } - void *p; - int r = posix_memalign(&p, sizeof(float), d_naligned_taps * sizeof(d_aligned_taps[0])); - if (r != 0){ - throw std::bad_alloc(); - } - d_aligned_taps = (float *) p; - memcpy(d_aligned_taps, &d_taps[0], ntaps() * sizeof(d_aligned_taps[0])); - for (size_t i = ntaps(); i < d_naligned_taps; i++) - d_aligned_taps[i] = 0.0; -} - - -gr_complex -gr_fir_ccf_armv7_a::filter (const gr_complex input[]) -{ - if (d_naligned_taps == 0) - return 0.0; - - gr_complex result; - float *presult = reinterpret_cast<float *>(&result); - const float *pinput = reinterpret_cast<const float *>(input); - - dotprod_ccf_armv7_a(pinput, d_aligned_taps, presult, d_naligned_taps); - return result; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_armv7_a.h b/gnuradio-core/src/lib/filter/gr_fir_ccf_armv7_a.h deleted file mode 100644 index e4844bae1a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_armv7_a.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009,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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_GR_FIR_CCF_ARMV7_A_H -#define INCLUDED_GR_FIR_CCF_ARMV7_A_H - -#include <gr_fir_ccf_generic.h> - -/*! - * \brief armv7_a using NEON coprocessor version of gr_fir_ccf - */ -class gr_fir_ccf_armv7_a : public gr_fir_ccf_generic -{ -protected: - - size_t d_naligned_taps; // number of taps (multiple of 4) - float *d_aligned_taps; // 16-byte aligned, and zero padded to multiple of 4 - -public: - gr_fir_ccf_armv7_a(); - gr_fir_ccf_armv7_a(const std::vector<float> &taps); - ~gr_fir_ccf_armv7_a(); - - virtual void set_taps (const std::vector<float> &taps); - virtual gr_complex filter (const gr_complex input[]); -}; - -#endif /* INCLUDED_GR_FIR_CCF_ARMV7_A*_H */ diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.cc b/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.cc deleted file mode 100644 index 872415e8eb..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.cc +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_ccf_simd.h> - -#include <assert.h> -#include <malloc16.h> -#include <iostream> -#include <stdexcept> - -using std::cerr; -using std::endl; - -gr_fir_ccf_simd::gr_fir_ccf_simd () - : gr_fir_ccf_generic () -{ - // cerr << "@@@ gr_fir_ccf_simd\n"; - - d_fcomplex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; -} - -gr_fir_ccf_simd::gr_fir_ccf_simd (const std::vector<float> &new_taps) - : gr_fir_ccf_generic (new_taps) -{ - // cerr << "@@@ gr_fir_ccf_simd\n"; - - d_fcomplex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; - set_taps (new_taps); -} - -gr_fir_ccf_simd::~gr_fir_ccf_simd () -{ - free16Align (d_aligned_taps[0]); - free16Align (d_aligned_taps[1]); - free16Align (d_aligned_taps[2]); - free16Align (d_aligned_taps[3]); -} - -void -gr_fir_ccf_simd::set_taps (const std::vector<float> &inew_taps) -{ - gr_fir_ccf::set_taps (inew_taps); // call superclass - const std::vector<float> new_taps = gr_reverse(inew_taps); - - unsigned len = new_taps.size (); - - // Make 4 copies of the coefficients, one for each data alignment - // Note use of special 16-byte-aligned version of calloc() - - for (unsigned i = 0; i < 4; i++){ - free16Align (d_aligned_taps[i]); // free old value - - // this works because the bit representation of a IEEE floating point - // +zero is all zeros. If you're using a different representation, - // you'll need to explictly set the result to the appropriate 0.0 value. - - d_aligned_taps[i] = (float *) calloc16Align (1 + (len + i - 1) / 4, - 4 * sizeof (float)); - if (d_aligned_taps[i] == 0){ - // throw something... - cerr << "@@@ gr_fir_ccf_simd d_aligned_taps[" << i << "] == 0\n"; - } - - for (unsigned j = 0; j < len; j++) - d_aligned_taps[i][j+i] = new_taps[j]; - } -} - -gr_complex -gr_fir_ccf_simd::filter (const gr_complex input[]) -{ - if (ntaps () == 0) - return 0.0; - - if (((intptr_t) input & 0x7) != 0) - throw std::invalid_argument("gr_complex must be 8-byte aligned"); - - // Round input data address down to 16 byte boundary - // NB: depending on the alignment of input[], memory - // before input[] will be accessed. The contents don't matter since - // they'll be multiplied by zero coefficients. I can't conceive of any - // situation where this could cause a segfault since memory protection - // in the x86 machines is done on much larger boundaries. - - const gr_complex *ar = (gr_complex *)((unsigned long) input & ~15); - - // Choose one of 4 sets of pre-shifted coefficients. al is both the - // index into d_aligned_taps[] and the number of 0 words padded onto - // that coefficients array for alignment purposes. - - unsigned al = input - ar; - - // call assembler routine to do the work, passing number of 2x4-float blocks. - - // assert (((unsigned long) ar & 15) == 0); - // assert (((unsigned long) d_aligned_taps[al] & 15) == 0); - - // cerr << "ar: " << ar << " d_aligned_taps[ar]: " << d_aligned_taps[al] - // << " (ntaps() + al - 1)/2 + 1: " << (ntaps() + al -1) / 2 + 1 << endl; - - float result[2]; - - // the trick here is to invert input and taps, and reuse FCC speedup - d_fcomplex_dotprod (d_aligned_taps[al], (float*)ar, (ntaps() + al - 1) / 2 + 1, result); - - // cerr << "result = " << result[0] << " " << result[1] << endl; - - return gr_complex(result[0], result[1]); -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.h b/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.h deleted file mode 100644 index 3c3e7e4f5b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FIR_CCF_SIMD_H -#define INCLUDED_GR_FIR_CCF_SIMD_H - -#include <gr_core_api.h> -#include <gr_fir_ccf_generic.h> - - -/*! - * \brief common base class for SIMD versions of gr_fir_ccf - * \ingroup filter_primitive - * - * This base class handles alignment issues common to SSE and 3DNOW - * subclasses. - */ - -class GR_CORE_API gr_fir_ccf_simd : public gr_fir_ccf_generic -{ -protected: - typedef void (*fcomplex_dotprod_t)(const float *taps, - const float *input, - unsigned n_2_complex_blocks, - float *result); - - /*! - * \p aligned_taps holds 4 copies of the coefficients preshifted - * by 0, 1, 2, or 3 float pairs to meet all possible input data alignments. - * This allows us to always fetch data and taps that are 128-bit aligned. - */ - float *d_aligned_taps[4]; - - fcomplex_dotprod_t d_fcomplex_dotprod; // fast dot product primitive - -public: - - // CREATORS - gr_fir_ccf_simd (); - gr_fir_ccf_simd (const std::vector<float> &taps); - ~gr_fir_ccf_simd (); - - // MANIPULATORS - virtual void set_taps (const std::vector<float> &taps); - virtual gr_complex filter (const gr_complex input[]); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.cc deleted file mode 100644 index f26d4ecc2c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_ccf_x86.h> -#include <fcomplex_dotprod_x86.h> - -/* - * --- 3DNow! version --- - */ - -gr_fir_ccf_3dnow::gr_fir_ccf_3dnow () - : gr_fir_ccf_simd () -{ - d_fcomplex_dotprod = fcomplex_dotprod_3dnow; -} - -gr_fir_ccf_3dnow::gr_fir_ccf_3dnow (const std::vector<float> &new_taps) - : gr_fir_ccf_simd (new_taps) -{ - d_fcomplex_dotprod = fcomplex_dotprod_3dnow; -} - - -/* - * --- SSE version --- - */ - -gr_fir_ccf_sse::gr_fir_ccf_sse () - : gr_fir_ccf_simd () -{ - d_fcomplex_dotprod = fcomplex_dotprod_sse; -} - -gr_fir_ccf_sse::gr_fir_ccf_sse (const std::vector<float> &new_taps) - : gr_fir_ccf_simd (new_taps) -{ - d_fcomplex_dotprod = fcomplex_dotprod_sse; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.h b/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.h deleted file mode 100644 index 6b260c3dbb..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FIR_CCF_X86_H -#define INCLUDED_GR_FIR_CCF_X86_H - -#include <gr_core_api.h> -#include <gr_fir_ccf_simd.h> - -/*! - * \brief 3DNow! version of gr_fir_ccf - * \ingroup filter_primitive - */ -class GR_CORE_API gr_fir_ccf_3dnow : public gr_fir_ccf_simd -{ -public: - gr_fir_ccf_3dnow (); - gr_fir_ccf_3dnow (const std::vector<float> &taps); -}; - -/*! - * \brief SSE version of gr_fir_ccf - * \ingroup filter_primitive - */ -class GR_CORE_API gr_fir_ccf_sse : public gr_fir_ccf_simd -{ -public: - gr_fir_ccf_sse (); - gr_fir_ccf_sse (const std::vector<float> &taps); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.cc b/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.cc deleted file mode 100644 index 5b75a43fd2..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.cc +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_fcc_simd.h> - -#include <assert.h> -#include <malloc16.h> -#include <iostream> - -using std::cerr; -using std::endl; - -gr_fir_fcc_simd::gr_fir_fcc_simd () - : gr_fir_fcc_generic () -{ - // cerr << "@@@ gr_fir_fcc_simd\n"; - - d_fcomplex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; -} - -gr_fir_fcc_simd::gr_fir_fcc_simd (const std::vector<gr_complex> &new_taps) - : gr_fir_fcc_generic (new_taps) -{ - // cerr << "@@@ gr_fir_fcc_simd\n"; - - d_fcomplex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; - set_taps (new_taps); -} - -gr_fir_fcc_simd::~gr_fir_fcc_simd () -{ - free16Align (d_aligned_taps[0]); - free16Align (d_aligned_taps[1]); - free16Align (d_aligned_taps[2]); - free16Align (d_aligned_taps[3]); -} - -void -gr_fir_fcc_simd::set_taps (const std::vector<gr_complex> &inew_taps) -{ - gr_fir_fcc::set_taps (inew_taps); // call superclass - const std::vector<gr_complex> new_taps = gr_reverse(inew_taps); - - unsigned len = new_taps.size (); - - // Make 4 copies of the coefficients, one for each data alignment - // Note use of special 16-byte-aligned version of calloc() - - for (unsigned i = 0; i < 4; i++){ - free16Align (d_aligned_taps[i]); // free old value - - // this works because the bit representation of a IEEE floating point - // +zero is all zeros. If you're using a different representation, - // you'll need to explictly set the result to the appropriate 0.0 value. - - d_aligned_taps[i] = (float *) calloc16Align (1 + (len + i - 1) / 2, - 2 * 4 * sizeof (float)); - if (d_aligned_taps[i] == 0){ - // throw something... - cerr << "@@@ gr_fir_fcc_simd d_aligned_taps[" << i << "] == 0\n"; - } - - for (unsigned j = 0; j < len; j++) { - d_aligned_taps[i][2*(j+i)] = new_taps[j].real(); - d_aligned_taps[i][2*(j+i)+1] = new_taps[j].imag(); - } - } -} - -gr_complex -gr_fir_fcc_simd::filter (const float input[]) -{ - if (ntaps () == 0) - return 0.0; - - - // Round input data address down to 16 byte boundary - // NB: depending on the alignment of input[], memory - // before input[] will be accessed. The contents don't matter since - // they'll be multiplied by zero coefficients. I can't conceive of any - // situation where this could cause a segfault since memory protection - // in the x86 machines is done on much larger boundaries. - - const float *ar = (float *)((unsigned long) input & ~15); - - // Choose one of 4 sets of pre-shifted coefficients. al is both the - // index into d_aligned_taps[] and the number of 0 words padded onto - // that coefficients array for alignment purposes. - - unsigned al = input - ar; - - // call assembler routine to do the work, passing number of 2x4-float blocks. - - // assert (((unsigned long) ar & 15) == 0); - // assert (((unsigned long) d_aligned_taps[al] & 15) == 0); - - // cerr << "ar: " << ar << " d_aligned_taps[ar]: " << d_aligned_taps[al] - // << " (ntaps() + al - 1)/2 + 1: " << (ntaps() + al -1) / 2 + 1 << endl; - - float result[2]; - - d_fcomplex_dotprod (ar, d_aligned_taps[al], (ntaps() + al - 1) / 2 + 1, result); - - // cerr << "result = " << result[0] << " " << result[1] << endl; - - return gr_complex(result[0], result[1]); -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.h b/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.h deleted file mode 100644 index b7463070bc..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FIR_FCC_SIMD_H -#define INCLUDED_GR_FIR_FCC_SIMD_H - -#include <gr_core_api.h> -#include <gr_fir_fcc_generic.h> - - -/*! - * \brief common base class for SIMD versions of gr_fir_fcc - * \ingroup filter_primitive - * - * This base class handles alignment issues common to SSE and 3DNOW - * subclasses. - */ - -class GR_CORE_API gr_fir_fcc_simd : public gr_fir_fcc_generic -{ -protected: - typedef void (*fcomplex_dotprod_t)(const float *input, - const float *taps, - unsigned n_2_complex_blocks, - float *result); - - /*! - * \p aligned_taps holds 4 copies of the coefficients preshifted - * by 0, 1, 2, or 3 float pairs to meet all possible input data alignments. - * This allows us to always fetch data and taps that are 128-bit aligned. - */ - float *d_aligned_taps[4]; - - fcomplex_dotprod_t d_fcomplex_dotprod; // fast dot product primitive - -public: - - // CREATORS - gr_fir_fcc_simd (); - gr_fir_fcc_simd (const std::vector<gr_complex> &taps); - ~gr_fir_fcc_simd (); - - // MANIPULATORS - virtual void set_taps (const std::vector<gr_complex> &taps); - virtual gr_complex filter (const float input[]); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.cc deleted file mode 100644 index d9904133c4..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_fcc_x86.h> -#include <fcomplex_dotprod_x86.h> - -/* - * --- 3DNow! version --- - */ - -gr_fir_fcc_3dnow::gr_fir_fcc_3dnow () - : gr_fir_fcc_simd () -{ - d_fcomplex_dotprod = fcomplex_dotprod_3dnow; -} - -gr_fir_fcc_3dnow::gr_fir_fcc_3dnow (const std::vector<gr_complex> &new_taps) - : gr_fir_fcc_simd (new_taps) -{ - d_fcomplex_dotprod = fcomplex_dotprod_3dnow; -} - - -/* - * --- SSE version --- - */ - -gr_fir_fcc_sse::gr_fir_fcc_sse () - : gr_fir_fcc_simd () -{ - d_fcomplex_dotprod = fcomplex_dotprod_sse; -} - -gr_fir_fcc_sse::gr_fir_fcc_sse (const std::vector<gr_complex> &new_taps) - : gr_fir_fcc_simd (new_taps) -{ - d_fcomplex_dotprod = fcomplex_dotprod_sse; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h b/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h deleted file mode 100644 index 3fc6c4855b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FIR_FCC_X86_H -#define INCLUDED_GR_FIR_FCC_X86_H - -#include <gr_core_api.h> -#include <gr_fir_fcc_simd.h> - -/*! - * \brief 3DNow! version of gr_fir_fcc - * \ingroup filter_primitive - */ -class GR_CORE_API gr_fir_fcc_3dnow : public gr_fir_fcc_simd -{ -public: - gr_fir_fcc_3dnow (); - gr_fir_fcc_3dnow (const std::vector<gr_complex> &taps); -}; - -/*! - * \brief SSE version of gr_fir_fcc - * \ingroup filter_blk - */ -class GR_CORE_API gr_fir_fcc_sse : public gr_fir_fcc_simd -{ -public: - gr_fir_fcc_sse (); - gr_fir_fcc_sse (const std::vector<gr_complex> &taps); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc b/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc deleted file mode 100644 index b81283ce56..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_fff_altivec.h> -#include <stdexcept> -#include <assert.h> -#include <gr_math.h> -#include <gr_altivec.h> -#include <dotprod_fff_altivec.h> -#include <string.h> -#include "posix_memalign.h" - -gr_fir_fff_altivec::gr_fir_fff_altivec() - : gr_fir_fff_generic(), - d_naligned_taps(0), d_aligned_taps(0) -{ -} - -gr_fir_fff_altivec::gr_fir_fff_altivec (const std::vector<float> &new_taps) - : gr_fir_fff_generic(new_taps), - d_naligned_taps(0), d_aligned_taps(0) -{ - set_taps(new_taps); -} - -gr_fir_fff_altivec::~gr_fir_fff_altivec() -{ - if (d_aligned_taps){ - free(d_aligned_taps); - d_aligned_taps = 0; - } -} - -void -gr_fir_fff_altivec::set_taps(const std::vector<float> &inew_taps) -{ - gr_fir_fff_generic::set_taps(inew_taps); // call superclass - d_naligned_taps = gr_p2_round_up(ntaps(), FLOATS_PER_VEC); - - if (d_aligned_taps){ - free(d_aligned_taps); - d_aligned_taps = 0; - } - void *p; - int r = posix_memalign(&p, sizeof(vec_float4), d_naligned_taps * sizeof(d_aligned_taps[0])); - if (r != 0){ - throw std::bad_alloc(); - } - d_aligned_taps = (float *) p; - memcpy(d_aligned_taps, &d_taps[0], ntaps() * sizeof(d_aligned_taps[0])); - for (size_t i = ntaps(); i < d_naligned_taps; i++) - d_aligned_taps[i] = 0.0; -} - - -float -gr_fir_fff_altivec::filter (const float input[]) -{ - if (d_naligned_taps == 0) - return 0.0; - - return dotprod_fff_altivec(input, d_aligned_taps, d_naligned_taps); -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h b/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h deleted file mode 100644 index a3d4a2aae9..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_GR_FIR_FFF_ALTIVEC_H -#define INCLUDED_GR_FIR_FFF_ALTIVEC_H - -#include <gr_core_api.h> -#include <gr_fir_fff_generic.h> - -/*! - * \brief altivec version of gr_fir_fff - */ -class GR_CORE_API gr_fir_fff_altivec : public gr_fir_fff_generic -{ -protected: - - size_t d_naligned_taps; // number of taps (multiple of 4) - float *d_aligned_taps; // 16-byte aligned, and zero padded to multiple of 4 - -public: - gr_fir_fff_altivec(); - gr_fir_fff_altivec(const std::vector<float> &taps); - ~gr_fir_fff_altivec(); - - virtual void set_taps (const std::vector<float> &taps); - virtual float filter (const float input[]); -}; - -#endif /* INCLUDED_GR_FIR_FFF_ALTIVEC_H */ diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.cc b/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.cc deleted file mode 100644 index b437254202..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_fir_fff_armv7_a.h> -#include <stdlib.h> -#include <string.h> -#include <stdexcept> -#include <assert.h> -#include <gr_math.h> -#include <dotprod_fff_armv7_a.h> - -#define FLOATS_PER_VEC 8 - -gr_fir_fff_armv7_a::gr_fir_fff_armv7_a() - : gr_fir_fff_generic(), - d_naligned_taps(0), d_aligned_taps(0) -{ -} - -gr_fir_fff_armv7_a::gr_fir_fff_armv7_a (const std::vector<float> &new_taps) - : gr_fir_fff_generic(new_taps), - d_naligned_taps(0), d_aligned_taps(0) -{ - set_taps(new_taps); -} - -gr_fir_fff_armv7_a::~gr_fir_fff_armv7_a() -{ - if (d_aligned_taps){ - free(d_aligned_taps); - d_aligned_taps = 0; - } -} - -void -gr_fir_fff_armv7_a::set_taps(const std::vector<float> &inew_taps) -{ - gr_fir_fff_generic::set_taps(inew_taps); // call superclass - d_naligned_taps = gr_p2_round_up(ntaps(), FLOATS_PER_VEC); - - if (d_aligned_taps){ - free(d_aligned_taps); - d_aligned_taps = 0; - } - void *p; - int r = posix_memalign(&p, sizeof(float), d_naligned_taps * sizeof(d_aligned_taps[0])); - if (r != 0){ - throw std::bad_alloc(); - } - d_aligned_taps = (float *) p; - memcpy(d_aligned_taps, &d_taps[0], ntaps() * sizeof(d_aligned_taps[0])); - for (size_t i = ntaps(); i < d_naligned_taps; i++) - d_aligned_taps[i] = 0.0; -} - - -float -gr_fir_fff_armv7_a::filter (const float input[]) -{ - if (d_naligned_taps == 0) - return 0.0; - - return dotprod_fff_armv7_a(input, d_aligned_taps, d_naligned_taps); -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.h b/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.h deleted file mode 100644 index 78863d2866..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_GR_FIR_FFF_ARMV7_A_H -#define INCLUDED_GR_FIR_FFF_ARMV7_A_H - -#include <gr_core_api.h> -#include <gr_fir_fff_generic.h> - -/*! - * \brief armv7_a using NEON coprocessor version of gr_fir_fff - */ -class GR_CORE_API gr_fir_fff_armv7_a : public gr_fir_fff_generic -{ -protected: - - size_t d_naligned_taps; // number of taps (multiple of 4) - float *d_aligned_taps; // 16-byte aligned, and zero padded to multiple of 4 - -public: - gr_fir_fff_armv7_a(); - gr_fir_fff_armv7_a(const std::vector<float> &taps); - ~gr_fir_fff_armv7_a(); - - virtual void set_taps (const std::vector<float> &taps); - virtual float filter (const float input[]); -}; - -#endif /* INCLUDED_GR_FIR_FFF_ARMV7_A*_H */ diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_simd.cc b/gnuradio-core/src/lib/filter/gr_fir_fff_simd.cc deleted file mode 100644 index d6c28ed45b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_simd.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_fff_simd.h> - -#include <assert.h> -#include <malloc16.h> -#include <iostream> - -using std::cerr; - -gr_fir_fff_simd::gr_fir_fff_simd () - : gr_fir_fff_generic () -{ - // cerr << "@@@ gr_fir_fff_simd\n"; - - d_float_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; -} - -gr_fir_fff_simd::gr_fir_fff_simd (const std::vector<float> &new_taps) - : gr_fir_fff_generic (new_taps) -{ - // cerr << "@@@ gr_fir_fff_simd\n"; - - d_float_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; - set_taps (new_taps); -} - -gr_fir_fff_simd::~gr_fir_fff_simd () -{ - free16Align (d_aligned_taps[0]); - free16Align (d_aligned_taps[1]); - free16Align (d_aligned_taps[2]); - free16Align (d_aligned_taps[3]); -} - -void -gr_fir_fff_simd::set_taps (const std::vector<float> &inew_taps) -{ - gr_fir_fff::set_taps (inew_taps); // call superclass - const std::vector<float> new_taps = gr_reverse(inew_taps); - - unsigned len = new_taps.size (); - - // Make 4 copies of the coefficients, one for each data alignment - // Note use of special 16-byte-aligned version of calloc() - - for (unsigned i = 0; i < 4; i++){ - free16Align (d_aligned_taps[i]); // free old value - - // this works because the bit representation of a IEEE floating point - // +zero is all zeros. If you're using a different representation, - // you'll need to explictly set the result to the appropriate 0.0 value. - - d_aligned_taps[i] = (float *) calloc16Align (1 + (len + i - 1) / 4, - 4 * sizeof (float)); - if (d_aligned_taps[i] == 0){ - // throw something... - cerr << "@@@ gr_fir_fff_simd d_aligned_taps[" << i << "] == 0\n"; - } - - for (unsigned j = 0; j < len; j++) - d_aligned_taps[i][j+i] = new_taps[j]; - } -} - -float -gr_fir_fff_simd::filter (const float input[]) -{ - if (ntaps () == 0) - return 0.0; - - - // Round input data address down to 16 byte boundary - // NB: depending on the alignment of input[], memory - // before input[] will be accessed. The contents don't matter since - // they'll be multiplied by zero coefficients. I can't conceive of any - // situation where this could cause a segfault since memory protection - // in the x86 machines is done on much larger boundaries. - - const float *ar = (float *)((unsigned long) input & ~15); - - // Choose one of 4 sets of pre-shifted coefficients. al is both the - // index into d_aligned_taps[] and the number of 0 words padded onto - // that coefficients array for alignment purposes. - - unsigned al = input - ar; - - // call assembler routine to do the work, passing number of 4-float blocks. - - // assert (((unsigned long) ar & 15) == 0); - // assert (((unsigned long) d_aligned_taps[al] & 15) == 0); - - // cerr << "ar: " << ar << " d_aligned_taps[ar]: " << d_aligned_taps[al] - // << " (ntaps() + al - 1)/4 + 1: " << (ntaps() + al -1) / 4 + 1 << endl; - - float r = d_float_dotprod (ar, d_aligned_taps[al], (ntaps() + al - 1) / 4 + 1); - - // cerr << "result = " << r << endl; - - return r; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_simd.h b/gnuradio-core/src/lib/filter/gr_fir_fff_simd.h deleted file mode 100644 index 9d61062664..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_simd.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FIR_FFF_SIMD_H -#define INCLUDED_GR_FIR_FFF_SIMD_H - -#include <gr_core_api.h> -#include <gr_fir_fff_generic.h> - -/*! - * \brief common base class for SIMD versions of gr_fir_fff - * \ingroup filter_primitive - * - * This base class handles alignment issues common to SSE and 3DNOW - * subclasses. - */ - -class GR_CORE_API gr_fir_fff_simd : public gr_fir_fff_generic -{ -protected: - typedef float (*float_dotprod_t)(const float *input, - const float *taps, - unsigned n_4_float_blocks); - - /*! - * \p aligned_taps holds 4 copies of the coefficients preshifted - * by 0, 1, 2, or 3 floats to meet all possible input data alignments. - * This allows us to always fetch data and taps that are 128-bit aligned. - */ - float *d_aligned_taps[4]; - - float_dotprod_t d_float_dotprod; // fast dot product primitive - -public: - - // CREATORS - gr_fir_fff_simd (); - gr_fir_fff_simd (const std::vector<float> &taps); - ~gr_fir_fff_simd (); - - // MANIPULATORS - virtual void set_taps (const std::vector<float> &taps); - virtual float filter (const float input[]); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_fff_x86.cc deleted file mode 100644 index 40ac266be6..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_x86.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_fff_x86.h> -#include <float_dotprod_x86.h> - -/* - * --- 3DNow! version --- - */ - -gr_fir_fff_3dnow::gr_fir_fff_3dnow () - : gr_fir_fff_simd () -{ - d_float_dotprod = float_dotprod_3dnow; -} - -gr_fir_fff_3dnow::gr_fir_fff_3dnow (const std::vector<float> &new_taps) - : gr_fir_fff_simd (new_taps) -{ - d_float_dotprod = float_dotprod_3dnow; -} - - -/* - * --- SSE version --- - */ - -gr_fir_fff_sse::gr_fir_fff_sse () - : gr_fir_fff_simd () -{ - d_float_dotprod = float_dotprod_sse; -} - -gr_fir_fff_sse::gr_fir_fff_sse (const std::vector<float> &new_taps) - : gr_fir_fff_simd (new_taps) -{ - d_float_dotprod = float_dotprod_sse; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_x86.h b/gnuradio-core/src/lib/filter/gr_fir_fff_x86.h deleted file mode 100644 index 8d451f0c95..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_x86.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FIR_FFF_X86_H -#define INCLUDED_GR_FIR_FFF_X86_H - -#include <gr_core_api.h> -#include <gr_fir_fff_simd.h> - -/*! - * \brief 3DNow! version of gr_fir_fff - */ -class GR_CORE_API gr_fir_fff_3dnow : public gr_fir_fff_simd -{ -public: - gr_fir_fff_3dnow (); - gr_fir_fff_3dnow (const std::vector<float> &taps); -}; - -/*! - * \brief SSE version of gr_fir_fff - */ -class GR_CORE_API gr_fir_fff_sse : public gr_fir_fff_simd -{ -public: - gr_fir_fff_sse (); - gr_fir_fff_sse (const std::vector<float> &taps); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.cc.t deleted file mode 100644 index 39bc756301..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.cc.t +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by generate_gr_fir_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <@FIR_TYPE@.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps) -{ - return gnuradio::get_initial_sptr (new @NAME@ (decimation, taps)); -} - - -@NAME@::@NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps) - : gr_sync_decimator ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)), - decimation), - d_updated (false) -{ - d_fir = gr_fir_util::create_@FIR_TYPE@ (taps); - set_history (d_fir->ntaps ()); -} - -@NAME@::~@NAME@ () -{ - delete d_fir; -} - -void -@NAME@::set_taps (const std::vector<@TAP_TYPE@> &taps) -{ - d_new_taps = taps; - d_updated = true; -} - -std::vector<@TAP_TYPE@> -@NAME@::taps () const -{ - return d_new_taps; -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *in = (@I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - - if (d_updated) { - d_fir->set_taps (d_new_taps); - set_history (d_fir->ntaps ()); - d_updated = false; - return 0; // history requirements may have changed. - } - - if (decimation() == 1) - d_fir->filterN (out, in, noutput_items); - - else - d_fir->filterNdec (out, in, noutput_items, decimation()); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t b/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t deleted file mode 100644 index b32e04bd35..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by generate_gr_fir_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); - -class @FIR_TYPE@; - -/*! - * \brief FIR filter with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_decimator -{ - private: - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); - - @FIR_TYPE@ *d_fir; - std::vector<@TAP_TYPE@> d_new_taps; - bool d_updated; - - /*! - * Construct a FIR filter with the given taps - */ - @NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); - - public: - ~@NAME@ (); - - void set_taps (const std::vector<@TAP_TYPE@> &taps); - std::vector<@TAP_TYPE@> taps () const; - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.i.t b/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.i.t deleted file mode 100644 index d9dc86180e..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.i.t +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by generate_GrFIRfilterXXX.py - * Any changes made to this file will be overwritten. - */ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); - -class @NAME@ : public gr_sync_decimator -{ - private: - @NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); - - public: - ~@NAME@ (); - - void set_taps (const std::vector<@TAP_TYPE@> &taps); - std::vector<@TAP_TYPE@> taps () const; -}; diff --git a/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.cc b/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.cc deleted file mode 100644 index a49503e6ab..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_fsf_simd.h> - -#include <assert.h> -#include <malloc16.h> -#include <iostream> - -using std::cerr; - -gr_fir_fsf_simd::gr_fir_fsf_simd () - : gr_fir_fsf_generic () -{ - // cerr << "@@@ gr_fir_fsf_simd\n"; - - d_float_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; -} - -gr_fir_fsf_simd::gr_fir_fsf_simd (const std::vector<float> &new_taps) - : gr_fir_fsf_generic (new_taps) -{ - // cerr << "@@@ gr_fir_fsf_simd\n"; - - d_float_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; - set_taps (new_taps); -} - -gr_fir_fsf_simd::~gr_fir_fsf_simd () -{ - free16Align (d_aligned_taps[0]); - free16Align (d_aligned_taps[1]); - free16Align (d_aligned_taps[2]); - free16Align (d_aligned_taps[3]); -} - -void -gr_fir_fsf_simd::set_taps (const std::vector<float> &inew_taps) -{ - gr_fir_fsf::set_taps (inew_taps); // call superclass - const std::vector<float> new_taps = gr_reverse(inew_taps); - unsigned len = new_taps.size (); - - // Make 4 copies of the coefficients, one for each data alignment - // Note use of special 16-byte-aligned version of calloc() - - for (unsigned i = 0; i < 4; i++){ - free16Align (d_aligned_taps[i]); // free old value - - // this works because the bit representation of a IEEE floating point - // +zero is all zeros. If you're using a different representation, - // you'll need to explictly set the result to the appropriate 0.0 value. - - d_aligned_taps[i] = (float *) calloc16Align (1 + (len + i - 1) / 4, - 4 * sizeof (float)); - if (d_aligned_taps[i] == 0){ - // throw something... - cerr << "@@@ gr_fir_fsf_simd d_aligned_taps[" << i << "] == 0\n"; - } - - for (unsigned j = 0; j < len; j++) - d_aligned_taps[i][j+i] = new_taps[j]; - } -} - -short -gr_fir_fsf_simd::filter (const float input[]) -{ - if (ntaps () == 0) - return 0; - - - // Round input data address down to 16 byte boundary - // NB: depending on the alignment of input[], memory - // before input[] will be accessed. The contents don't matter since - // they'll be multiplied by zero coefficients. I can't conceive of any - // situation where this could cause a segfault since memory protection - // in the x86 machines is done on much larger boundaries. - - const float *ar = (float *)((unsigned long) input & ~15); - - // Choose one of 4 sets of pre-shifted coefficients. al is both the - // index into d_aligned_taps[] and the number of 0 words padded onto - // that coefficients array for alignment purposes. - - unsigned al = input - ar; - - // call assembler routine to do the work, passing number of 4-float blocks. - - // assert (((unsigned long) ar & 15) == 0); - // assert (((unsigned long) d_aligned_taps[al] & 15) == 0); - - // cerr << "ar: " << ar << " d_aligned_taps[ar]: " << d_aligned_taps[al] - // << " (ntaps() + al - 1)/4 + 1: " << (ntaps() + al -1) / 4 + 1 << endl; - - float r = d_float_dotprod (ar, d_aligned_taps[al], (ntaps() + al - 1) / 4 + 1); - - // cerr << "result = " << r << endl; - - return (short) r; // FIXME? may want to saturate here -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.h b/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.h deleted file mode 100644 index d63e9dd17d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GR_FIR_FSF_SIMD_H_ -#define _GR_FIR_FSF_SIMD_H_ - -#include <gr_core_api.h> -#include <gr_fir_fsf_generic.h> - -/*! - * \brief common base class for SIMD versions of gr_fir_fsf - * \ingroup filter_primitive - * - * This base class handles alignment issues common to SSE and 3DNOW - * subclasses. - */ - -class GR_CORE_API gr_fir_fsf_simd : public gr_fir_fsf_generic -{ -protected: - typedef float (*float_dotprod_t)(const float *input, - const float *taps, - unsigned n_4_float_blocks); - - /*! - * \p aligned_taps holds 4 copies of the coefficients preshifted - * by 0, 1, 2, or 3 floats to meet all possible input data alignments. - * This allows us to always fetch data and taps that are 128-bit aligned. - */ - float *d_aligned_taps[4]; - - float_dotprod_t d_float_dotprod; // fast dot product primitive - -public: - - // CREATORS - gr_fir_fsf_simd (); - gr_fir_fsf_simd (const std::vector<float> &taps); - ~gr_fir_fsf_simd (); - - // MANIPULATORS - virtual void set_taps (const std::vector<float> &taps); - virtual short filter (const float input[]); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.cc deleted file mode 100644 index 40ba17d3a7..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_fsf_x86.h> -#include <float_dotprod_x86.h> - -/* - * --- 3DNow! version --- - */ - -gr_fir_fsf_3dnow::gr_fir_fsf_3dnow () - : gr_fir_fsf_simd () -{ - d_float_dotprod = float_dotprod_3dnow; -} - -gr_fir_fsf_3dnow::gr_fir_fsf_3dnow (const std::vector<float> &new_taps) - : gr_fir_fsf_simd (new_taps) -{ - d_float_dotprod = float_dotprod_3dnow; -} - - -/* - * --- SSE version --- - */ - -gr_fir_fsf_sse::gr_fir_fsf_sse () - : gr_fir_fsf_simd () -{ - d_float_dotprod = float_dotprod_sse; -} - -gr_fir_fsf_sse::gr_fir_fsf_sse (const std::vector<float> &new_taps) - : gr_fir_fsf_simd (new_taps) -{ - d_float_dotprod = float_dotprod_sse; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.h b/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.h deleted file mode 100644 index df664d5e27..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FIR_FSF_X86_H -#define INCLUDED_GR_FIR_FSF_X86_H - -#include <gr_core_api.h> -#include <gr_fir_fsf_simd.h> - -/*! - * \brief 3DNow! version of gr_fir_fsf - * \ingroup filter_primitive - */ -class GR_CORE_API gr_fir_fsf_3dnow : public gr_fir_fsf_simd -{ -public: - gr_fir_fsf_3dnow (); - gr_fir_fsf_3dnow (const std::vector<float> &taps); -}; - -/*! - * \brief SSE version of gr_fir_fsf - * \ingroup filter_primitive - */ -class GR_CORE_API gr_fir_fsf_sse : public gr_fir_fsf_simd -{ -public: - gr_fir_fsf_sse (); - gr_fir_fsf_sse (const std::vector<float> &taps); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_scc_simd.cc b/gnuradio-core/src/lib/filter/gr_fir_scc_simd.cc deleted file mode 100644 index 0b2dd7e613..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_scc_simd.cc +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_scc_simd.h> - -#include <assert.h> -#include <malloc16.h> -#include <iostream> - -using std::cerr; -using std::endl; - -gr_fir_scc_simd::gr_fir_scc_simd () - : gr_fir_scc_generic () -{ - // cerr << "@@@ gr_fir_scc_simd\n"; - - d_complex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; -} - -gr_fir_scc_simd::gr_fir_scc_simd (const std::vector<gr_complex> &new_taps) - : gr_fir_scc_generic (new_taps) -{ - // cerr << "@@@ gr_fir_scc_simd\n"; - - d_complex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; - set_taps (new_taps); -} - -gr_fir_scc_simd::~gr_fir_scc_simd () -{ - free16Align (d_aligned_taps[0]); - free16Align (d_aligned_taps[1]); - free16Align (d_aligned_taps[2]); - free16Align (d_aligned_taps[3]); -} - -void -gr_fir_scc_simd::set_taps (const std::vector<gr_complex> &inew_taps) -{ - gr_fir_scc::set_taps (inew_taps); // call superclass - - const std::vector<gr_complex> new_taps = gr_reverse(inew_taps); - - unsigned len = new_taps.size (); - - // Make 4 copies of the coefficients, one for each data alignment - // Note use of special 16-byte-aligned version of calloc() - - for (unsigned i = 0; i < 4; i++){ - free16Align (d_aligned_taps[i]); // free old value - - // this works because the bit representation of a IEEE floating point - // +zero is all zeros. If you're using a different representation, - // you'll need to explictly set the result to the appropriate 0.0 value. - - d_aligned_taps[i] = (float *) calloc16Align (1 + (len + i - 1) / 2, - 2 * 4 * sizeof (float)); - if (d_aligned_taps[i] == 0){ - // throw something... - cerr << "@@@ gr_fir_scc_simd d_aligned_taps[" << i << "] == 0\n"; - } - - for (unsigned j = 0; j < len; j++) { - d_aligned_taps[i][2*(j+i)] = new_taps[j].real(); - d_aligned_taps[i][2*(j+i)+1] = new_taps[j].imag(); - } - } -} - -gr_complex -gr_fir_scc_simd::filter (const short input[]) -{ - if (ntaps () == 0) - return 0.0; - - - // Round input data address down to 8 byte boundary - // NB: depending on the alignment of input[], memory - // before input[] will be accessed. The contents don't matter since - // they'll be multiplied by zero coefficients. I can't conceive of any - // situation where this could cause a segfault since memory protection - // in the x86 machines is done on much larger boundaries. - - const short *ar = (short *)((unsigned long) input & ~7); - - // Choose one of 4 sets of pre-shifted coefficients. al is both the - // index into d_aligned_taps[] and the number of 0 words padded onto - // that coefficients array for alignment purposes. - - unsigned al = input - ar; - - // call assembler routine to do the work, passing number of 2x4-float blocks. - - // assert (((unsigned long) ar & 7) == 0); - // assert (((unsigned long) d_aligned_taps[al] & 15) == 0); - - // cerr << "ar: " << ar << " d_aligned_taps[ar]: " << d_aligned_taps[al] - // << " (ntaps() + al - 1)/2 + 1: " << (ntaps() + al -1) / 2 + 1 << endl; - - float result[2]; - - d_complex_dotprod (ar, d_aligned_taps[al], (ntaps() + al - 1) / 2 + 1, result); - - // cerr << "result = " << result[0] << " " << result[1] << endl; - - return gr_complex(result[0], result[1]); -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_scc_simd.h b/gnuradio-core/src/lib/filter/gr_fir_scc_simd.h deleted file mode 100644 index 72c15f93b3..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_scc_simd.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FIR_SCC_SIMD_H -#define INCLUDED_GR_FIR_SCC_SIMD_H - -#include <gr_core_api.h> -#include <gr_fir_scc_generic.h> - - -/*! - * \brief common base class for SIMD versions of gr_fir_scc - * \ingroup filter_primitive - * - * This base class handles alignment issues common to SSE and 3DNOW - * subclasses. - */ -class GR_CORE_API gr_fir_scc_simd : public gr_fir_scc_generic -{ -protected: - typedef void (*complex_dotprod_t)(const short *input, - const float *taps, - unsigned n_2_complex_blocks, - float *result); - - /*! - * \p aligned_taps holds 4 copies of the coefficients preshifted - * by 0, 1, 2, or 3 float pairs to meet all possible input data alignments. - * This allows us to always fetch data and taps that are 128-bit aligned. - */ - float *d_aligned_taps[4]; - - complex_dotprod_t d_complex_dotprod; // fast dot product primitive - -public: - - // CREATORS - gr_fir_scc_simd (); - gr_fir_scc_simd (const std::vector<gr_complex> &taps); - ~gr_fir_scc_simd (); - - // MANIPULATORS - virtual void set_taps (const std::vector<gr_complex> &taps); - virtual gr_complex filter (const short input[]); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_scc_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_scc_x86.cc deleted file mode 100644 index ab0668c63a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_scc_x86.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_scc_x86.h> -#include <complex_dotprod_x86.h> - -/* - * --- 3DNow! version --- - */ - -gr_fir_scc_3dnow::gr_fir_scc_3dnow () - : gr_fir_scc_simd () -{ - d_complex_dotprod = complex_dotprod_3dnow; -} - -gr_fir_scc_3dnow::gr_fir_scc_3dnow (const std::vector<gr_complex> &new_taps) - : gr_fir_scc_simd (new_taps) -{ - d_complex_dotprod = complex_dotprod_3dnow; -} - - -/* - * --- 3DNow! Ext version --- - */ - -gr_fir_scc_3dnowext::gr_fir_scc_3dnowext () - : gr_fir_scc_simd () -{ - d_complex_dotprod = complex_dotprod_3dnowext; -} - -gr_fir_scc_3dnowext::gr_fir_scc_3dnowext (const std::vector<gr_complex> &new_taps) - : gr_fir_scc_simd (new_taps) -{ - d_complex_dotprod = complex_dotprod_3dnowext; -} - - -/* - * --- SSE version --- - */ - -gr_fir_scc_sse::gr_fir_scc_sse () - : gr_fir_scc_simd () -{ - d_complex_dotprod = complex_dotprod_sse; -} - -gr_fir_scc_sse::gr_fir_scc_sse (const std::vector<gr_complex> &new_taps) - : gr_fir_scc_simd (new_taps) -{ - d_complex_dotprod = complex_dotprod_sse; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_scc_x86.h b/gnuradio-core/src/lib/filter/gr_fir_scc_x86.h deleted file mode 100644 index 85a63251b2..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_scc_x86.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FIR_SCC_X86_H -#define INCLUDED_GR_FIR_SCC_X86_H - -#include <gr_core_api.h> -#include <gr_fir_scc_simd.h> - -/*! - * \brief 3DNow! version of gr_fir_scc - */ -class GR_CORE_API gr_fir_scc_3dnow : public gr_fir_scc_simd -{ -public: - gr_fir_scc_3dnow (); - gr_fir_scc_3dnow (const std::vector<gr_complex> &taps); -}; - -/*! - * \brief 3DNow! Ext version of gr_fir_scc - */ -class GR_CORE_API gr_fir_scc_3dnowext : public gr_fir_scc_simd -{ -public: - gr_fir_scc_3dnowext (); - gr_fir_scc_3dnowext (const std::vector<gr_complex> &taps); -}; - -/*! - * \brief SSE version of gr_fir_scc - */ -class GR_CORE_API gr_fir_scc_sse : public gr_fir_scc_simd -{ -public: - gr_fir_scc_sse (); - gr_fir_scc_sse (const std::vector<gr_complex> &taps); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.cc b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.cc deleted file mode 100644 index 70adbc0920..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.cc +++ /dev/null @@ -1,337 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008,2009,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 <gr_fir_sysconfig_armv7_a.h> -#include <gr_cpu.h> - -#include <gr_fir_ccf.h> -#include <gr_fir_ccf_generic.h> -#include <gr_fir_ccf_armv7_a.h> -#include <gr_fir_fcc.h> -#include <gr_fir_fcc_generic.h> -#include <gr_fir_fff.h> -#include <gr_fir_fff_generic.h> -#include <gr_fir_fff_armv7_a.h> -#include <gr_fir_fsf.h> -#include <gr_fir_fsf_generic.h> -#include <gr_fir_ccc.h> -#include <gr_fir_ccc_generic.h> -#include <gr_fir_scc.h> -#include <gr_fir_scc_generic.h> - -#include <iostream> -using std::cerr; - -///\todo Remove commented out code for altivec and replace with NEON versions. - -/* - * ---------------------------------------------------------------- - * static functions that serve as constructors... - * ---------------------------------------------------------------- - */ - -static gr_fir_ccf * -make_gr_fir_ccf_armv7_a (const std::vector<float> &taps) -{ - return new gr_fir_ccf_armv7_a(taps); -} - -#if 0 -static gr_fir_fcc * -make_gr_fir_fcc_altivec(const std::vector<gr_complex> &taps) -{ - return new gr_fir_fcc_altivec(taps); -} - -static gr_fir_ccc * -make_gr_fir_ccc_altivec (const std::vector<gr_complex> &taps) -{ - return new gr_fir_ccc_altivec (taps); -} -#endif - -static gr_fir_fff * -make_gr_fir_fff_armv7_a (const std::vector<float> &taps) -{ - return new gr_fir_fff_armv7_a (taps); -} - -#if 0 -static gr_fir_fsf * -make_gr_fir_fsf_altivec (const std::vector<float> &taps) -{ - return new gr_fir_fsf_altivec (taps); -} - -static gr_fir_scc * -make_gr_fir_scc_altivec(const std::vector<gr_complex> &taps) -{ - return new gr_fir_scc_altivec(taps); -} -#endif - -/* - * ---------------------------------------------------------------- - * Return instances of the fastest arm versions of these classes. - * - * check CPUID, if has armv7-a, return armv7-a version, - * else return generic version. This will break - * when someone makes an armv7-a without a NEON - * coprocessor. - * ---------------------------------------------------------------- - */ - -gr_fir_ccf * -gr_fir_sysconfig_armv7_a::create_gr_fir_ccf (const std::vector<float> &taps) -{ - static bool first = true; - - if (gr_cpu::has_armv7_a ()){ - if (first){ - cerr << ">>> gr_fir_ccf: using armv7_a\n"; - first = false; - } - return make_gr_fir_ccf_armv7_a (taps); - } - - if (0 && first){ - cerr << ">>> gr_fir_ccf: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_ccf (taps); -} - -gr_fir_fcc * -gr_fir_sysconfig_armv7_a::create_gr_fir_fcc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_fcc: using altivec\n"; - first = false; - } - return make_gr_fir_fcc_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_fcc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fcc (taps); -} - -gr_fir_ccc * -gr_fir_sysconfig_armv7_a::create_gr_fir_ccc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_ccc: using altivec\n"; - first = false; - } - return make_gr_fir_ccc_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_ccc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_ccc (taps); -} - -gr_fir_fff * -gr_fir_sysconfig_armv7_a::create_gr_fir_fff (const std::vector<float> &taps) -{ - static bool first = true; - - if (gr_cpu::has_armv7_a ()){ - if (first){ - cerr << ">>> gr_fir_fff: using armv7_a\n"; - first = false; - } - return make_gr_fir_fff_armv7_a (taps); - } - - if (0 && first){ - cerr << ">>> gr_fir_fff: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fff (taps); -} - -gr_fir_fsf * -gr_fir_sysconfig_armv7_a::create_gr_fir_fsf (const std::vector<float> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_fsf: using altivec\n"; - first = false; - } - return make_gr_fir_fsf_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_fsf: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fsf (taps); -} - - -gr_fir_scc * -gr_fir_sysconfig_armv7_a::create_gr_fir_scc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_scc: using altivec\n"; - first = false; - } - return make_gr_fir_scc_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_scc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_scc (taps); -} - -/* - * ---------------------------------------------------------------- - * Return info about available implementations - * ---------------------------------------------------------------- - */ - -void -gr_fir_sysconfig_armv7_a::get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_ccf_info (info); - - // add our stuff... - gr_fir_ccf_info t; - if (gr_cpu::has_armv7_a ()){ - t.name = "armv7_a"; - t.create = make_gr_fir_ccf_armv7_a; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_armv7_a::get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fcc_info (info); - -#if 0 - // add our stuff... - gr_fir_fcc_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_fcc_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_armv7_a::get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_ccc_info (info); - -#if 0 - // add our stuff... - gr_fir_ccc_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_ccc_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_armv7_a::get_gr_fir_fff_info (std::vector<gr_fir_fff_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fff_info (info); - - // add our stuff... - gr_fir_fff_info t; - if (gr_cpu::has_armv7_a ()){ - t.name = "armv7_a"; - t.create = make_gr_fir_fff_armv7_a; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_armv7_a::get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fsf_info (info); - -#if 0 - // add our stuff... - gr_fir_fsf_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_fsf_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_armv7_a::get_gr_fir_scc_info (std::vector<gr_fir_scc_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_scc_info (info); - -#if 0 - // add our stuff... - gr_fir_scc_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_scc_altivec; - (*info).push_back (t); - } -#endif -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.h b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.h deleted file mode 100644 index 7295475f64..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FIR_SYSCONFIG_ARMV7_A_H -#define INCLUDED_GR_FIR_SYSCONFIG_ARMV7_A_H - -#include <gr_core_api.h> -#include <gr_fir_sysconfig_generic.h> - -class GR_CORE_API gr_fir_sysconfig_armv7_a : public gr_fir_sysconfig_generic { -public: - virtual gr_fir_ccf *create_gr_fir_ccf (const std::vector<float> &taps); - virtual gr_fir_fcc *create_gr_fir_fcc (const std::vector<gr_complex> &taps); - virtual gr_fir_fff *create_gr_fir_fff (const std::vector<float> &taps); - virtual gr_fir_fsf *create_gr_fir_fsf (const std::vector<float> &taps); - virtual gr_fir_scc *create_gr_fir_scc (const std::vector<gr_complex> &taps); - virtual gr_fir_ccc *create_gr_fir_ccc (const std::vector<gr_complex> &taps); -//virtual gr_fir_sss *create_gr_fir_sss (const std::vector<short> &taps); - - virtual void get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info> *info); - virtual void get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info> *info); - virtual void get_gr_fir_fff_info (std::vector<gr_fir_fff_info> *info); - virtual void get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info> *info); - virtual void get_gr_fir_scc_info (std::vector<gr_fir_scc_info> *info); - virtual void get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info> *info); -//virtual void get_gr_fir_sss_info (std::vector<gr_fir_sss_info> *info); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.cc b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.cc deleted file mode 100644 index f706bd5bf2..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.cc +++ /dev/null @@ -1,340 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_sysconfig_powerpc.h> -#include <gr_cpu.h> - -#include <gr_fir_ccf.h> -#include <gr_fir_ccf_generic.h> -//#include <gr_fir_ccf_altivec.h> -#include <gr_fir_fcc.h> -#include <gr_fir_fcc_generic.h> -//#include <gr_fir_fcc_altivec.h> -#include <gr_fir_fff.h> -#include <gr_fir_fff_generic.h> -#include <gr_fir_fff_altivec.h> -#include <gr_fir_fsf.h> -#include <gr_fir_fsf_generic.h> -//#include <gr_fir_fsf_powerpc.h> -#include <gr_fir_ccc.h> -#include <gr_fir_ccc_generic.h> -//#include <gr_fir_ccc_altivec.h> -#include <gr_fir_scc.h> -#include <gr_fir_scc_generic.h> -//#include <gr_fir_scc_altivec.h> - -#include <iostream> -using std::cerr; - -/* - * ---------------------------------------------------------------- - * static functions that serve as constructors... - * ---------------------------------------------------------------- - */ - -#if 0 -static gr_fir_ccf * -make_gr_fir_ccf_altivec(const std::vector<float> &taps) -{ - return new gr_fir_ccf_altivec(taps); -} - -static gr_fir_fcc * -make_gr_fir_fcc_altivec(const std::vector<gr_complex> &taps) -{ - return new gr_fir_fcc_altivec(taps); -} - -static gr_fir_ccc * -make_gr_fir_ccc_altivec (const std::vector<gr_complex> &taps) -{ - return new gr_fir_ccc_altivec (taps); -} -#endif - -static gr_fir_fff * -make_gr_fir_fff_altivec (const std::vector<float> &taps) -{ - return new gr_fir_fff_altivec (taps); -} - -#if 0 -static gr_fir_fsf * -make_gr_fir_fsf_altivec (const std::vector<float> &taps) -{ - return new gr_fir_fsf_altivec (taps); -} - -static gr_fir_scc * -make_gr_fir_scc_altivec(const std::vector<gr_complex> &taps) -{ - return new gr_fir_scc_altivec(taps); -} -#endif - -/* - * ---------------------------------------------------------------- - * Return instances of the fastest powerpc versions of these classes. - * - * check CPUID, if has altivec, return altivec version, - * else return generic version. - * ---------------------------------------------------------------- - */ - -gr_fir_ccf * -gr_fir_sysconfig_powerpc::create_gr_fir_ccf (const std::vector<float> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_ccf: using altivec\n"; - first = false; - } - return make_gr_fir_ccf_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_ccf: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_ccf (taps); -} - -gr_fir_fcc * -gr_fir_sysconfig_powerpc::create_gr_fir_fcc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_fcc: using altivec\n"; - first = false; - } - return make_gr_fir_fcc_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_fcc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fcc (taps); -} - -gr_fir_ccc * -gr_fir_sysconfig_powerpc::create_gr_fir_ccc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_ccc: using altivec\n"; - first = false; - } - return make_gr_fir_ccc_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_ccc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_ccc (taps); -} - -gr_fir_fff * -gr_fir_sysconfig_powerpc::create_gr_fir_fff (const std::vector<float> &taps) -{ - static bool first = true; - - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_fff: using altivec\n"; - first = false; - } - return make_gr_fir_fff_altivec (taps); - } - - if (0 && first){ - cerr << ">>> gr_fir_fff: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fff (taps); -} - -gr_fir_fsf * -gr_fir_sysconfig_powerpc::create_gr_fir_fsf (const std::vector<float> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_fsf: using altivec\n"; - first = false; - } - return make_gr_fir_fsf_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_fsf: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fsf (taps); -} - - -gr_fir_scc * -gr_fir_sysconfig_powerpc::create_gr_fir_scc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_scc: using altivec\n"; - first = false; - } - return make_gr_fir_scc_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_scc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_scc (taps); -} - -/* - * ---------------------------------------------------------------- - * Return info about available implementations - * ---------------------------------------------------------------- - */ - -void -gr_fir_sysconfig_powerpc::get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_ccf_info (info); - -#if 0 - // add our stuff... - gr_fir_ccf_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_ccf_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_powerpc::get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fcc_info (info); - -#if 0 - // add our stuff... - gr_fir_fcc_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_fcc_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_powerpc::get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_ccc_info (info); - -#if 0 - // add our stuff... - gr_fir_ccc_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_ccc_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_powerpc::get_gr_fir_fff_info (std::vector<gr_fir_fff_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fff_info (info); - - // add our stuff... - gr_fir_fff_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_fff_altivec; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_powerpc::get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fsf_info (info); - -#if 0 - // add our stuff... - gr_fir_fsf_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_fsf_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_powerpc::get_gr_fir_scc_info (std::vector<gr_fir_scc_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_scc_info (info); - -#if 0 - // add our stuff... - gr_fir_scc_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_scc_altivec; - (*info).push_back (t); - } -#endif -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.h b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.h deleted file mode 100644 index 09a7a0ba04..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FIR_SYSCONFIG_POWERPC_H -#define INCLUDED_GR_FIR_SYSCONFIG_POWERPC_H - -#include <gr_core_api.h> -#include <gr_fir_sysconfig_generic.h> - -class GR_CORE_API gr_fir_sysconfig_powerpc : public gr_fir_sysconfig_generic { -public: - virtual gr_fir_ccf *create_gr_fir_ccf (const std::vector<float> &taps); - virtual gr_fir_fcc *create_gr_fir_fcc (const std::vector<gr_complex> &taps); - virtual gr_fir_fff *create_gr_fir_fff (const std::vector<float> &taps); - virtual gr_fir_fsf *create_gr_fir_fsf (const std::vector<float> &taps); - virtual gr_fir_scc *create_gr_fir_scc (const std::vector<gr_complex> &taps); - virtual gr_fir_ccc *create_gr_fir_ccc (const std::vector<gr_complex> &taps); -//virtual gr_fir_sss *create_gr_fir_sss (const std::vector<short> &taps); - - virtual void get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info> *info); - virtual void get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info> *info); - virtual void get_gr_fir_fff_info (std::vector<gr_fir_fff_info> *info); - virtual void get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info> *info); - virtual void get_gr_fir_scc_info (std::vector<gr_fir_scc_info> *info); - virtual void get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info> *info); -//virtual void get_gr_fir_sss_info (std::vector<gr_fir_sss_info> *info); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc deleted file mode 100644 index 95e17123c8..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc +++ /dev/null @@ -1,561 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_sysconfig_x86.h> -#include <gr_cpu.h> - -#include <gr_fir_ccf.h> -#include <gr_fir_ccf_generic.h> -#include <gr_fir_ccf_x86.h> -#include <gr_fir_fcc.h> -#include <gr_fir_fcc_generic.h> -#include <gr_fir_fcc_x86.h> -#include <gr_fir_fff.h> -#include <gr_fir_fff_generic.h> -#include <gr_fir_fff_x86.h> -#include <gr_fir_fsf.h> -#include <gr_fir_fsf_generic.h> -#include <gr_fir_fsf_x86.h> -#include <gr_fir_ccc.h> -#include <gr_fir_ccc_generic.h> -#include <gr_fir_ccc_x86.h> -#include <gr_fir_scc.h> -#include <gr_fir_scc_generic.h> -#include <gr_fir_scc_x86.h> -// #include <gr_fir_sss.h> -// #include <gr_fir_sss_generic.h> -// #include <gr_fir_sss_mmx.h> -// #include <gr_fir_sss_sse2.h> - - -#include <iostream> -using std::cerr; - -/* - * ---------------------------------------------------------------- - * static functions that serve as constructors... - * Is it possible to take the address of a normal constructor? - * ---------------------------------------------------------------- - */ - -static gr_fir_ccf * -make_gr_fir_ccf_3dnow(const std::vector<float> &taps) -{ - return new gr_fir_ccf_3dnow(taps); -} - -static gr_fir_ccf * -make_gr_fir_ccf_sse(const std::vector<float> &taps) -{ - return new gr_fir_ccf_sse(taps); -} - -static gr_fir_fcc * -make_gr_fir_fcc_3dnow(const std::vector<gr_complex> &taps) -{ - return new gr_fir_fcc_3dnow(taps); -} - -static gr_fir_fcc * -make_gr_fir_fcc_sse(const std::vector<gr_complex> &taps) -{ - return new gr_fir_fcc_sse(taps); -} - -static gr_fir_ccc * -make_gr_fir_ccc_3dnow (const std::vector<gr_complex> &taps) -{ - return new gr_fir_ccc_3dnow (taps); -} - -static gr_fir_ccc * -make_gr_fir_ccc_3dnowext (const std::vector<gr_complex> &taps) -{ - return new gr_fir_ccc_3dnowext (taps); -} - -static gr_fir_ccc * -make_gr_fir_ccc_sse (const std::vector<gr_complex> &taps) -{ - return new gr_fir_ccc_sse (taps); -} - -static gr_fir_fff * -make_gr_fir_fff_3dnow (const std::vector<float> &taps) -{ - return new gr_fir_fff_3dnow (taps); -} - -static gr_fir_fff * -make_gr_fir_fff_sse (const std::vector<float> &taps) -{ - return new gr_fir_fff_sse (taps); -} - -static gr_fir_fsf * -make_gr_fir_fsf_3dnow (const std::vector<float> &taps) -{ - return new gr_fir_fsf_3dnow (taps); -} - -static gr_fir_fsf * -make_gr_fir_fsf_sse (const std::vector<float> &taps) -{ - return new gr_fir_fsf_sse (taps); -} - -#if 0 -static gr_fir_sss * -make_gr_fir_sss_mmx (const std::vector<short> &taps) -{ - return new gr_fir_sss_mmx (taps); -} - -static gr_fir_sss * -make_gr_fir_sss_sse2 (const std::vector<short> &taps) -{ - return new gr_fir_sss_sse2 (taps); -} -#endif - -static gr_fir_scc * -make_gr_fir_scc_3dnow(const std::vector<gr_complex> &taps) -{ - return new gr_fir_scc_3dnow(taps); -} - -static gr_fir_scc * -make_gr_fir_scc_3dnowext(const std::vector<gr_complex> &taps) -{ - return new gr_fir_scc_3dnowext(taps); -} - -static gr_fir_scc * -make_gr_fir_scc_sse(const std::vector<gr_complex> &taps) -{ - return new gr_fir_scc_sse(taps); -} - -/* - * ---------------------------------------------------------------- - * Return instances of the fastest x86 versions of these classes. - * - * check CPUID, if has 3DNowExt, return 3DNow!Ext version, - * else if 3DNow, return 3DNow! version, - * else if SSE2, return SSE2 version, - * else if SSE, return SSE version, - * else if MMX, return MMX version, - * else return generic version. - * - * FIXME: benchmark, store result, use stored result to - * select the fastest version. - * ---------------------------------------------------------------- - */ - -gr_fir_ccf * -gr_fir_sysconfig_x86::create_gr_fir_ccf (const std::vector<float> &taps) -{ - static bool first = true; - - if (gr_cpu::has_3dnow ()){ - if (first){ - cerr << ">>> gr_fir_ccf: using 3DNow!\n"; - first = false; - } - return make_gr_fir_ccf_3dnow (taps); - } - - if (gr_cpu::has_sse ()){ - if (first){ - cerr << ">>> gr_fir_ccf: using SSE\n"; - first = false; - } - return make_gr_fir_ccf_sse (taps); - } - - if (first){ - cerr << ">>> gr_fir_ccf: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_ccf (taps); -} - -gr_fir_fcc * -gr_fir_sysconfig_x86::create_gr_fir_fcc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - - if (gr_cpu::has_3dnow ()){ - if (first){ - cerr << ">>> gr_fir_fcc: gr_fir_fcc: using 3DNow!\n"; - first = false; - } - return make_gr_fir_fcc_3dnow (taps); - } - - if (gr_cpu::has_sse ()){ - if (first){ - cerr << ">>> gr_fir_fcc: gr_fir_fcc: using SSE\n"; - first = false; - } - return make_gr_fir_fcc_sse (taps); - } - - if (first){ - cerr << ">>> gr_fir_fcc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fcc (taps); -} - -gr_fir_ccc * -gr_fir_sysconfig_x86::create_gr_fir_ccc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - - if (gr_cpu::has_3dnowext ()){ - if (first) { - cerr << ">>> gr_fir_ccc: using 3DNow!Ext\n"; - first = false; - } - return make_gr_fir_ccc_3dnowext (taps); - } - - if (gr_cpu::has_3dnow ()){ - if (first) { - cerr << ">>> gr_fir_ccc: using 3DNow!\n"; - first = false; - } - return make_gr_fir_ccc_3dnow (taps); - } - - if (gr_cpu::has_sse ()){ - if (first){ - cerr << ">>> gr_fir_ccc: using SSE\n"; - first = false; - } - return make_gr_fir_ccc_sse (taps); - } - - if (first){ - cerr << ">>> gr_fir_ccc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_ccc (taps); -} - -gr_fir_fff * -gr_fir_sysconfig_x86::create_gr_fir_fff (const std::vector<float> &taps) -{ - static bool first = true; - - if (gr_cpu::has_3dnow ()){ - if (first) { - cerr << ">>> gr_fir_fff: using 3DNow!\n"; - first = false; - } - return make_gr_fir_fff_3dnow (taps); - } - - if (gr_cpu::has_sse ()){ - if (first){ - cerr << ">>> gr_fir_fff: using SSE\n"; - first = false; - } - return make_gr_fir_fff_sse (taps); - } - - if (first){ - cerr << ">>> gr_fir_fff: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fff (taps); -} - -gr_fir_fsf * -gr_fir_sysconfig_x86::create_gr_fir_fsf (const std::vector<float> &taps) -{ - static bool first = true; - - if (gr_cpu::has_3dnow ()){ - if (first) { - cerr << ">>> gr_fir_fsf: using 3DNow!\n"; - first = false; - } - return make_gr_fir_fsf_3dnow (taps); - } - - if (gr_cpu::has_sse ()){ - if (first){ - cerr << ">>> gr_fir_fsf: using SSE\n"; - first = false; - } - return make_gr_fir_fsf_sse (taps); - } - - if (first){ - cerr << ">>> gr_fir_fsf: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fsf (taps); -} - -#if 0 -gr_fir_sss * -gr_fir_sysconfig_x86::create_gr_fir_sss (const std::vector<short> &taps) -{ - // FIXME -- probably want to figure out best answer for Athlon and code - // add code to select it here... - static bool first = true; - - if (gr_cpu::has_sse2 ()){ - if(first) { - cerr << ">>> gr_fir_sss: using SSE2\n"; - return make_gr_fir_sss_sse2 (taps); - } - } - - if (gr_cpu::has_mmx ()){ - if(first) { - cerr << ">>> gr_fir_sss: using MMX\n"; - return make_gr_fir_sss_mmx (taps); - } - } - - if(first) { - cerr << ">>> gr_fir_sss: handing off to parent class\n"; - return gr_fir_sysconfig_generic::create_gr_fir_sss (taps); - } -} -#endif - -gr_fir_scc * -gr_fir_sysconfig_x86::create_gr_fir_scc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - - if (gr_cpu::has_3dnowext ()){ - if (first){ - cerr << ">>> gr_fir_scc: using 3DNow!Ext\n"; - first = false; - } - return make_gr_fir_scc_3dnowext (taps); - } - - if (gr_cpu::has_3dnow ()){ - if (first){ - cerr << ">>> gr_fir_scc: using 3DNow!\n"; - first = false; - } - return make_gr_fir_scc_3dnow (taps); - } - - if (gr_cpu::has_sse ()){ - if (first){ - cerr << ">>> gr_fir_scc: using SSE\n"; - first = false; - } - return make_gr_fir_scc_sse (taps); - } - - if (first){ - cerr << ">>> gr_fir_scc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_scc (taps); -} - -/* - * ---------------------------------------------------------------- - * Return info about available implementations - * ---------------------------------------------------------------- - */ - -void -gr_fir_sysconfig_x86::get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info> *info) -{ - gr_fir_ccf_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_ccf_info (info); - - // add our stuff... - if (gr_cpu::has_3dnow ()){ - t.name = "3DNow!"; - t.create = make_gr_fir_ccf_3dnow; - (*info).push_back (t); - } - - if (gr_cpu::has_sse ()){ - t.name = "SSE"; - t.create = make_gr_fir_ccf_sse; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_x86::get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info> *info) -{ - gr_fir_fcc_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fcc_info (info); - - // add our stuff... - if (gr_cpu::has_3dnow ()){ - t.name = "3DNow!"; - t.create = make_gr_fir_fcc_3dnow; - (*info).push_back (t); - } - - if (gr_cpu::has_sse ()){ - t.name = "SSE"; - t.create = make_gr_fir_fcc_sse; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_x86::get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info> *info) -{ - gr_fir_ccc_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_ccc_info (info); - - // add our stuff... - if (gr_cpu::has_3dnowext ()){ - t.name = "3DNow!Ext"; - t.create = make_gr_fir_ccc_3dnowext; - (*info).push_back (t); - } - - if (gr_cpu::has_3dnow ()){ - t.name = "3DNow!"; - t.create = make_gr_fir_ccc_3dnow; - (*info).push_back (t); - } - - if (gr_cpu::has_sse ()){ - t.name = "SSE"; - t.create = make_gr_fir_ccc_sse; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_x86::get_gr_fir_fff_info (std::vector<gr_fir_fff_info> *info) -{ - gr_fir_fff_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fff_info (info); - - // add our stuff... - if (gr_cpu::has_3dnow ()){ - t.name = "3DNow!"; - t.create = make_gr_fir_fff_3dnow; - (*info).push_back (t); - } - - if (gr_cpu::has_sse ()){ - t.name = "SSE"; - t.create = make_gr_fir_fff_sse; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_x86::get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info> *info) -{ - gr_fir_fsf_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fsf_info (info); - - // add our stuff... - if (gr_cpu::has_3dnow ()){ - t.name = "3DNow!"; - t.create = make_gr_fir_fsf_3dnow; - (*info).push_back (t); - } - - if (gr_cpu::has_sse ()){ - t.name = "SSE"; - t.create = make_gr_fir_fsf_sse; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_x86::get_gr_fir_scc_info (std::vector<gr_fir_scc_info> *info) -{ - gr_fir_scc_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_scc_info (info); - - // add our stuff... - if (gr_cpu::has_3dnowext ()){ - t.name = "3DNow!Ext"; - t.create = make_gr_fir_scc_3dnowext; - (*info).push_back (t); - } - - if (gr_cpu::has_3dnow ()){ - t.name = "3DNow!"; - t.create = make_gr_fir_scc_3dnow; - (*info).push_back (t); - } - - if (gr_cpu::has_sse ()){ - t.name = "SSE"; - t.create = make_gr_fir_scc_sse; - (*info).push_back (t); - } -} - -#if 0 -void -gr_fir_sysconfig_x86::get_gr_fir_sss_info (std::vector<gr_fir_sss_info> *info) -{ - gr_fir_sss_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_sss_info (info); - - // add our stuff... - if (gr_cpu::has_mmx ()){ - t.name = "MMX"; - t.create = make_gr_fir_sss_mmx; - (*info).push_back (t); - } - - if (gr_cpu::has_sse2 ()){ - t.name = "SSE2"; - t.create = make_gr_fir_sss_sse2; - (*info).push_back (t); - } -} -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.h b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.h deleted file mode 100644 index ebb399c8ba..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FIR_SYSCONFIG_X86_H -#define INCLUDED_GR_FIR_SYSCONFIG_X86_H - -#include <gr_core_api.h> -#include <gr_fir_sysconfig_generic.h> - -class GR_CORE_API gr_fir_sysconfig_x86 : public gr_fir_sysconfig_generic { -public: - virtual gr_fir_ccf *create_gr_fir_ccf (const std::vector<float> &taps); - virtual gr_fir_fcc *create_gr_fir_fcc (const std::vector<gr_complex> &taps); - virtual gr_fir_fff *create_gr_fir_fff (const std::vector<float> &taps); - virtual gr_fir_fsf *create_gr_fir_fsf (const std::vector<float> &taps); - virtual gr_fir_scc *create_gr_fir_scc (const std::vector<gr_complex> &taps); - virtual gr_fir_ccc *create_gr_fir_ccc (const std::vector<gr_complex> &taps); -//virtual gr_fir_sss *create_gr_fir_sss (const std::vector<short> &taps); - - virtual void get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info> *info); - virtual void get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info> *info); - virtual void get_gr_fir_fff_info (std::vector<gr_fir_fff_info> *info); - virtual void get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info> *info); - virtual void get_gr_fir_scc_info (std::vector<gr_fir_scc_info> *info); - virtual void get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info> *info); -//virtual void get_gr_fir_sss_info (std::vector<gr_fir_sss_info> *info); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.cc b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.cc deleted file mode 100644 index 500958e3da..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_io_signature.h> -#include <gr_fractional_interpolator_cc.h> -#include <gri_mmse_fir_interpolator_cc.h> -#include <stdexcept> - -// Public constructor -gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_cc(float phase_shift, float interp_ratio) -{ - return gnuradio::get_initial_sptr(new gr_fractional_interpolator_cc(phase_shift, interp_ratio)); -} - -gr_fractional_interpolator_cc::gr_fractional_interpolator_cc(float phase_shift, float interp_ratio) - : gr_block ("fractional_interpolator_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_mu (phase_shift), d_mu_inc (interp_ratio), d_interp(new gri_mmse_fir_interpolator_cc()) -{ - if (interp_ratio <= 0) - throw std::out_of_range ("interpolation ratio must be > 0"); - if (phase_shift < 0 || phase_shift > 1) - throw std::out_of_range ("phase shift ratio must be > 0 and < 1"); - - set_relative_rate (1.0 / interp_ratio); -} - -gr_fractional_interpolator_cc::~gr_fractional_interpolator_cc() -{ - delete d_interp; -} - -void -gr_fractional_interpolator_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size(); - for (unsigned i=0; i < ninputs; i++) - - ninput_items_required[i] = - (int) ceil((noutput_items * d_mu_inc) + d_interp->ntaps()); -} - -int -gr_fractional_interpolator_cc::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - int ii = 0; // input index - int oo = 0; // output index - - while (oo < noutput_items) { - - out[oo++] = d_interp->interpolate(&in[ii], d_mu); - - double s = d_mu + d_mu_inc; - double f = floor (s); - int incr = (int) f; - d_mu = s - f; - ii += incr; - } - - consume_each (ii); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h deleted file mode 100644 index 29c67895a4..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FRACTIONAL_INTERPOLATOR_CC_H -#define INCLUDED_GR_FRACTIONAL_INTERPOLATOR_CC_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gri_mmse_fir_interpolator_cc; - -class gr_fractional_interpolator_cc; -typedef boost::shared_ptr<gr_fractional_interpolator_cc> gr_fractional_interpolator_cc_sptr; - -// public constructor -GR_CORE_API gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_cc (float phase_shift, float interp_ratio); - -/*! - * \brief Interpolating mmse filter with gr_complex input, gr_complex output - * \ingroup filter_blk - */ -class GR_CORE_API gr_fractional_interpolator_cc : public gr_block -{ -public: - ~gr_fractional_interpolator_cc (); - 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); - - float mu() const { return d_mu;} - float interp_ratio() const { return d_mu_inc;} - void set_mu (float mu) { d_mu = mu; } - void set_interp_ratio (float interp_ratio) { d_mu_inc = interp_ratio; } - -protected: - gr_fractional_interpolator_cc (float phase_shift, float interp_ratio); - -private: - float d_mu; - float d_mu_inc; - gri_mmse_fir_interpolator_cc *d_interp; - - friend GR_CORE_API gr_fractional_interpolator_cc_sptr - gr_make_fractional_interpolator_cc (float phase_shift, float interp_ratio); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.i b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.i deleted file mode 100644 index d7341176a7..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,fractional_interpolator_cc); - -gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_cc (float phase_shift, float interp_ratio); - -class gr_fractional_interpolator_cc : public gr_block -{ -private: - gr_fractional_interpolator_cc (float phase_shift, float interp_ratio); - -public: - float mu() const; - float interp_ratio() const; - void set_mu (float mu); - void set_interp_ratio (float interp_ratio); -}; diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.cc b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.cc deleted file mode 100644 index 9cbe31635d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_io_signature.h> -#include <gr_fractional_interpolator_ff.h> -#include <gri_mmse_fir_interpolator.h> -#include <stdexcept> - -// Public constructor -gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_ff(float phase_shift, float interp_ratio) -{ - return gnuradio::get_initial_sptr(new gr_fractional_interpolator_ff(phase_shift, interp_ratio)); -} - -gr_fractional_interpolator_ff::gr_fractional_interpolator_ff(float phase_shift, float interp_ratio) - : gr_block ("fractional_interpolator_ff", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (float))), - d_mu (phase_shift), d_mu_inc (interp_ratio), d_interp(new gri_mmse_fir_interpolator()) -{ - if (interp_ratio <= 0) - throw std::out_of_range ("interpolation ratio must be > 0"); - if (phase_shift < 0 || phase_shift > 1) - throw std::out_of_range ("phase shift ratio must be > 0 and < 1"); - - set_relative_rate (1.0 / interp_ratio); -} - -gr_fractional_interpolator_ff::~gr_fractional_interpolator_ff() -{ - delete d_interp; -} - -void -gr_fractional_interpolator_ff::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size(); - for (unsigned i=0; i < ninputs; i++) - - ninput_items_required[i] = - (int) ceil((noutput_items * d_mu_inc) + d_interp->ntaps()); -} - -int -gr_fractional_interpolator_ff::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - int ii = 0; // input index - int oo = 0; // output index - - while (oo < noutput_items) { - - out[oo++] = d_interp->interpolate(&in[ii], d_mu); - - double s = d_mu + d_mu_inc; - double f = floor (s); - int incr = (int) f; - d_mu = s - f; - ii += incr; - } - - consume_each (ii); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h deleted file mode 100644 index 7e000a6d1c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FRACTIONAL_INTERPOLATOR_FF_H -#define INCLUDED_GR_FRACTIONAL_INTERPOLATOR_FF_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gri_mmse_fir_interpolator; - -class gr_fractional_interpolator_ff; -typedef boost::shared_ptr<gr_fractional_interpolator_ff> gr_fractional_interpolator_ff_sptr; - -// public constructor -GR_CORE_API gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_ff (float phase_shift, float interp_ratio); - -/*! - * \brief Interpolating mmse filter with float input, float output - * \ingroup filter_blk - */ -class GR_CORE_API gr_fractional_interpolator_ff : public gr_block -{ -public: - ~gr_fractional_interpolator_ff (); - 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); - - float mu() const { return d_mu;} - float interp_ratio() const { return d_mu_inc;} - void set_mu (float mu) { d_mu = mu; } - void set_interp_ratio (float interp_ratio) { d_mu_inc = interp_ratio; } - -protected: - gr_fractional_interpolator_ff (float phase_shift, float interp_ratio); - -private: - float d_mu; - float d_mu_inc; - gri_mmse_fir_interpolator *d_interp; - - friend GR_CORE_API gr_fractional_interpolator_ff_sptr - gr_make_fractional_interpolator_ff (float phase_shift, float interp_ratio); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.i b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.i deleted file mode 100644 index 4ec7c85cfc..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,fractional_interpolator_ff); - -gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_ff (float phase_shift, float interp_ratio); - -class gr_fractional_interpolator_ff : public gr_block -{ -private: - gr_fractional_interpolator_ff (float phase_shift, float interp_ratio); - -public: - float mu() const; - float interp_ratio() const; - void set_mu (float mu); - void set_interp_ratio (float interp_ratio); -}; diff --git a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.cc.t deleted file mode 100644 index 3d65f872e6..0000000000 --- a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.cc.t +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by - * generate_gr_freq_xlating_fir_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <@FIR_TYPE@.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps, - double center_freq, double sampling_freq) -{ - return gnuradio::get_initial_sptr (new @NAME@ (decimation, taps, center_freq, sampling_freq)); -} - - -@NAME@::@NAME@ ( - - int decimation, - const std::vector<@TAP_TYPE@> &taps, - double center_freq, - double sampling_freq) - - : gr_sync_decimator ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)), - decimation), - d_proto_taps (taps), d_center_freq (center_freq), d_sampling_freq (sampling_freq), - d_updated (false) -{ - std::vector<gr_complex> dummy_taps; - d_composite_fir = gr_fir_util::create_@FIR_TYPE@ (dummy_taps); - - set_history (d_proto_taps.size ()); - build_composite_fir (); -} - -@NAME@::~@NAME@ () -{ - delete d_composite_fir; -} - -void -@NAME@::build_composite_fir () -{ - std::vector<gr_complex> ctaps (d_proto_taps.size ()); - - float fwT0 = 2 * M_PI * d_center_freq / d_sampling_freq; - for (unsigned int i = 0; i < d_proto_taps.size (); i++) - ctaps[i] = d_proto_taps[i] * exp (gr_complex (0, i * fwT0)); - - d_composite_fir->set_taps (gr_reverse(ctaps)); - d_r.set_phase_incr (exp (gr_complex (0, fwT0 * decimation ()))); -} - -void -@NAME@::set_center_freq (double center_freq) -{ - d_center_freq = center_freq; - d_updated = true; -} - -void -@NAME@::set_taps (const std::vector<@TAP_TYPE@> &taps) -{ - d_proto_taps = taps; - d_updated = true; -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *in = (@I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - - // rebuild composite FIR if the center freq has changed - - if (d_updated){ - set_history (d_proto_taps.size ()); - build_composite_fir (); - d_updated = false; - return 0; // history requirements may have changed. - } - - unsigned j = 0; - for (int i = 0; i < noutput_items; i++){ - out[i] = d_r.rotate (d_composite_fir->filter (&in[j])); - j += decimation (); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t b/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t deleted file mode 100644 index 97d20e04f5..0000000000 --- a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by - * generate_gr_freq_xlating_fir_filter_XXX.py Any changes made to this file - * will be overwritten. - */ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> -#include <gr_rotator.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -/*! - * Construct a FIR filter with the given taps and a composite frequency - * translation that shifts center_freq down to zero Hz. The frequency - * translation logically comes before the filtering operation. - */ -GR_CORE_API @SPTR_NAME@ -gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps, - double center_freq, double sampling_freq); - - -class @FIR_TYPE@; - -/*! - * \brief FIR filter combined with frequency translation with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_blk - * - * This class efficiently combines a frequency translation - * (typically "down conversion") with a FIR filter (typically low-pass) - * and decimation. It is ideally suited for a "channel selection filter" - * and can be efficiently used to select and decimate a narrow band signal - * out of wide bandwidth input. - * - * Uses a single input array to produce a single output array. - * Additional inputs and/or outputs are ignored. - */ -class GR_CORE_API @NAME@ : public gr_sync_decimator -{ - public: - virtual ~@NAME@ (); - - void set_center_freq (double center_freq); - void set_taps (const std::vector<@TAP_TYPE@> &taps); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - private: - friend GR_CORE_API @SPTR_NAME@ - gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps, - double center_freq, double sampling_freq); - - protected: - std::vector<@TAP_TYPE@> d_proto_taps; - @FIR_TYPE@ *d_composite_fir; - gr_rotator d_r; - double d_center_freq; - double d_sampling_freq; - bool d_updated; - - virtual void build_composite_fir (); - - /*! - * Construct a FIR filter with the given taps and a composite frequency - * translation that shifts center_freq down to zero Hz. The frequency - * translation logically comes before the filtering operation. - */ - @NAME@ (int decimation, - const std::vector<@TAP_TYPE@> &taps, - double center_freq, double sampling_freq); -}; - -#endif /* _@NAME@_H_ */ diff --git a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.i.t b/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.i.t deleted file mode 100644 index ac6c8c9e1e..0000000000 --- a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.i.t +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by - * generate_gr_freq_xlating_fir_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps, - double center_freq, double sampling_freq); - - -class @NAME@ : public gr_sync_decimator -{ - protected: - @NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps, - double center_freq, double sampling_freq); - - public: - ~@NAME@ (); - - void set_center_freq (double center_freq); - void set_taps (const std::vector<@TAP_TYPE@> &taps); -}; diff --git a/gnuradio-core/src/lib/filter/gr_goertzel_fc.cc b/gnuradio-core/src/lib/filter/gr_goertzel_fc.cc deleted file mode 100644 index 07bed8157b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_goertzel_fc.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,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 <gr_goertzel_fc.h> -#include <gr_io_signature.h> - -// public constructor -gr_goertzel_fc_sptr -gr_make_goertzel_fc(int rate, int len, float freq) -{ - return gnuradio::get_initial_sptr(new gr_goertzel_fc(rate, len, freq)); -} - -gr_goertzel_fc::gr_goertzel_fc(int rate, int len, float freq) - : gr_sync_decimator("goertzel_fc", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (gr_complex)), - len), - d_goertzel(rate, len, freq) -{ - d_len = len; - d_rate = rate; - d_freq = freq; -} - -int gr_goertzel_fc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *in = (float *)input_items[0]; - gr_complex *out = (gr_complex *)output_items[0]; - - for (int i = 0; i < noutput_items; i++) { - *out++ = d_goertzel.batch(in); - in += d_len; - } - - return noutput_items; -} - -void -gr_goertzel_fc::set_freq(float freq) -{ - d_freq = freq; - d_goertzel.gri_setparms(d_rate, d_len, d_freq); -} - -void -gr_goertzel_fc::set_rate(int rate) -{ - d_rate = rate; - d_goertzel.gri_setparms(d_rate, d_len, d_freq); -} diff --git a/gnuradio-core/src/lib/filter/gr_goertzel_fc.h b/gnuradio-core/src/lib/filter/gr_goertzel_fc.h deleted file mode 100644 index 5fb6e0ee05..0000000000 --- a/gnuradio-core/src/lib/filter/gr_goertzel_fc.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,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_GR_GOERTZEL_FC_H -#define INCLUDED_GR_GOERTZEL_FC_H - -#include <gr_core_api.h> -#include <gri_goertzel.h> -#include <gr_sync_decimator.h> - -class gr_goertzel_fc; -typedef boost::shared_ptr<gr_goertzel_fc> gr_goertzel_fc_sptr; - -// public constructor -GR_CORE_API gr_goertzel_fc_sptr gr_make_goertzel_fc(int rate, int len, float freq); - -/*! - * \brief Goertzel single-bin DFT calculation. - * \ingroup dft_blk - */ -class GR_CORE_API gr_goertzel_fc : public gr_sync_decimator -{ -private: - friend GR_CORE_API gr_goertzel_fc_sptr gr_make_goertzel_fc (int rate, int len, float freq); - - gr_goertzel_fc(int rate, int len, float freq); - gri_goertzel d_goertzel; - int d_len; - float d_freq; - int d_rate; - -public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void set_freq (float freq); - void set_rate (int rate); -}; - -#endif /* INCLUDED_GR_GOERTZEL_FC_H */ - diff --git a/gnuradio-core/src/lib/filter/gr_goertzel_fc.i b/gnuradio-core/src/lib/filter/gr_goertzel_fc.i deleted file mode 100644 index 775c78cc8e..0000000000 --- a/gnuradio-core/src/lib/filter/gr_goertzel_fc.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,goertzel_fc); - -gr_goertzel_fc_sptr gr_make_goertzel_fc(int rate, int len, float freq); - -class gr_goertzel_fc : public gr_sync_decimator -{ -private: - gr_goertzel_fc(); - -public: - void set_freq (float freq); - void set_rate (int rate); -}; diff --git a/gnuradio-core/src/lib/filter/gr_hilbert_fc.cc b/gnuradio-core/src/lib/filter/gr_hilbert_fc.cc deleted file mode 100644 index 385e24ad2b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_hilbert_fc.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_hilbert_fc.h> -#include <gr_firdes.h> -#include <gr_fir_fff.h> -#include <gr_fir_util.h> - -// public constructor -gr_hilbert_fc_sptr -gr_make_hilbert_fc (unsigned int ntaps) -{ - return gnuradio::get_initial_sptr(new gr_hilbert_fc (ntaps)); -} - -gr_hilbert_fc::gr_hilbert_fc (unsigned int ntaps) - : gr_sync_block ("hilbert_fc", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_ntaps (ntaps | 0x1), // ensure ntaps is odd - d_hilb (gr_fir_util::create_gr_fir_fff (gr_firdes::hilbert (d_ntaps))) -{ - set_history (d_ntaps); -} - -gr_hilbert_fc::~gr_hilbert_fc () -{ - delete d_hilb; -} - -int -gr_hilbert_fc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *in = (float *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - for (int i = 0; i < noutput_items; i++) - out[i] = gr_complex (in[i + d_ntaps/2], - d_hilb->filter (&in[i])); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_hilbert_fc.h b/gnuradio-core/src/lib/filter/gr_hilbert_fc.h deleted file mode 100644 index 2bb5ff9e37..0000000000 --- a/gnuradio-core/src/lib/filter/gr_hilbert_fc.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_HILBERT_FC_H -#define INCLUDED_GR_HILBERT_FC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_io_signature.h> -#include <gr_types.h> - -class gr_hilbert_fc; -typedef boost::shared_ptr<gr_hilbert_fc> gr_hilbert_fc_sptr; - -// public constructor -GR_CORE_API gr_hilbert_fc_sptr gr_make_hilbert_fc (unsigned int ntaps); - - -class gr_fir_fff; - -/*! - * \brief Hilbert transformer. - * \ingroup filter_blk - * - * real output is input appropriately delayed. - * imaginary output is hilbert filtered (90 degree phase shift) - * version of input. - */ -class GR_CORE_API gr_hilbert_fc : public gr_sync_block -{ - public: - ~gr_hilbert_fc (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - protected: - gr_hilbert_fc (unsigned int ntaps); - - private: - unsigned int d_ntaps; - gr_fir_fff *d_hilb; - - friend GR_CORE_API gr_hilbert_fc_sptr gr_make_hilbert_fc (unsigned int ntaps); -}; - - - -#endif /* INCLUDED_GR_HILBERT_FC_H */ diff --git a/gnuradio-core/src/lib/filter/gr_hilbert_fc.i b/gnuradio-core/src/lib/filter/gr_hilbert_fc.i deleted file mode 100644 index 91d4e23eb7..0000000000 --- a/gnuradio-core/src/lib/filter/gr_hilbert_fc.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,hilbert_fc); - -gr_hilbert_fc_sptr gr_make_hilbert_fc (unsigned int ntaps); - -class gr_hilbert_fc : public gr_sync_block -{ -protected: - gr_hilbert_fc (unsigned int ntaps); - -public: - ~gr_hilbert_fc (); -}; diff --git a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.cc b/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.cc deleted file mode 100644 index 4da2aa310b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_iir_filter_ffd.h> -#include <gr_io_signature.h> -#include <stdio.h> - - -gr_iir_filter_ffd_sptr -gr_make_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument) -{ - return gnuradio::get_initial_sptr(new gr_iir_filter_ffd (fftaps, fbtaps)); -} - -gr_iir_filter_ffd::gr_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument) - - : gr_sync_block ("iir_filter_ffd", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (float))), - d_iir (fftaps, fbtaps), - d_updated (false) -{ - // fprintf (stderr, "gr_iir_filter_ffd::ctor\n"); -} - -gr_iir_filter_ffd::~gr_iir_filter_ffd () -{ - // nop -} - -void -gr_iir_filter_ffd::set_taps (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument) -{ - - d_new_fftaps = fftaps; - d_new_fbtaps = fbtaps; - d_updated = true; -} - -int -gr_iir_filter_ffd::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - - if (d_updated){ - d_iir.set_taps (d_new_fftaps, d_new_fbtaps); - d_updated = false; - } - - d_iir.filter_n (out, in, noutput_items); - return noutput_items; -}; diff --git a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h b/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h deleted file mode 100644 index ab7065e921..0000000000 --- a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_IIR_FILTER_FFD_H -#define INCLUDED_GR_IIR_FILTER_FFD_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_iir.h> -#include <stdexcept> - -class gr_iir_filter_ffd; -typedef boost::shared_ptr<gr_iir_filter_ffd> gr_iir_filter_ffd_sptr; -GR_CORE_API gr_iir_filter_ffd_sptr -gr_make_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); - -/*! - * \brief IIR filter with float input, float output and double taps - * \ingroup filter_blk - * - * This filter uses the Direct Form I implementation, where - * \p fftaps contains the feed-forward taps, and \p fbtaps the feedback ones. - * - * - * The input and output satisfy a difference equation of the form - \htmlonly - \f{ - y[n] - \sum_{k=1}^{M} a_k y[n-k] = \sum_{k=0}^{N} b_k x[n-k] - \f} - \endhtmlonly - - \xmlonly - y[n] - \sum_{k=1}^{M} a_k y[n-k] = \sum_{k=0}^{N} b_k x[n-k] - \endxmlonly - - * with the corresponding rational system function - \htmlonly - \f{ - H(z) = \ frac{\sum_{k=0}^{M} b_k z^{-k}}{1 - \sum_{k=1}^{N} a_k z^{-k}} - \f} - \endhtmlonly - - \xmlonly - H(z) = \ frac{\sum_{k=0}^{M} b_k z^{-k}}{1 - \sum_{k=1}^{N} a_k z^{-k}} - \endxmlonly - - * Note that some texts define the system function with a + in the denominator. - * If you're using that convention, you'll need to negate the feedback taps. - */ -class GR_CORE_API gr_iir_filter_ffd : public gr_sync_block -{ - private: - friend GR_CORE_API gr_iir_filter_ffd_sptr - gr_make_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); - - gri_iir<float,float,double> d_iir; - std::vector<double> d_new_fftaps; - std::vector<double> d_new_fbtaps; - bool d_updated; - - /*! - * Construct an IIR filter with the given taps - */ - gr_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); - - public: - ~gr_iir_filter_ffd (); - - void set_taps (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.i b/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.i deleted file mode 100644 index 0a35ad89e1..0000000000 --- a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.i +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,iir_filter_ffd); - -gr_iir_filter_ffd_sptr -gr_make_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); - -class gr_iir_filter_ffd : public gr_sync_block -{ - private: - gr_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); - - public: - ~gr_iir_filter_ffd (); - - void set_taps (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); -}; diff --git a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.cc.t deleted file mode 100644 index 55297d1eb9..0000000000 --- a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.cc.t +++ /dev/null @@ -1,146 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by generate_gr_fir_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <@FIR_TYPE@.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <iostream> - -@SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps) -{ - return gnuradio::get_initial_sptr (new @NAME@ (interpolation, taps)); -} - - -@NAME@::@NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps) - : gr_sync_interpolator ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)), - interpolation), - d_updated (false), d_firs (interpolation) -{ - if (interpolation == 0) - throw std::out_of_range ("interpolation must be > 0"); - - std::vector<@TAP_TYPE@> dummy_taps; - - for (unsigned i = 0; i < interpolation; i++) - d_firs[i] = gr_fir_util::create_@FIR_TYPE@ (dummy_taps); - - set_taps (taps); - install_taps(d_new_taps); -} - -@NAME@::~@NAME@ () -{ - int interp = interpolation (); - for (int i = 0; i < interp; i++) - delete d_firs[i]; -} - -void -@NAME@::set_taps (const std::vector<@TAP_TYPE@> &taps) -{ - d_new_taps = taps; - d_updated = true; - - // round up length to a multiple of the interpolation factor - int n = taps.size () % interpolation (); - if (n > 0){ - n = interpolation () - n; - while (n-- > 0) - d_new_taps.insert(d_new_taps.begin(), 0); - } - - assert (d_new_taps.size () % interpolation () == 0); -} - - -void -@NAME@::install_taps (const std::vector<@TAP_TYPE@> &taps) -{ - int nfilters = interpolation (); - int nt = taps.size () / nfilters; - - assert (nt * nfilters == (int) taps.size ()); - - std::vector< std::vector <@TAP_TYPE@> > xtaps (nfilters); - - for (int n = 0; n < nfilters; n++) - xtaps[n].resize (nt); - - for (int i = 0; i < (int) taps.size(); i++) - xtaps[i % nfilters][i / nfilters] = taps[i]; - - for (int n = 0; n < nfilters; n++) - d_firs[n]->set_taps (xtaps[n]); - - set_history (nt); - d_updated = false; - -#if 0 - for (int i = 0; i < nfilters; i++){ - std::cout << "filter[" << i << "] = "; - for (int j = 0; j < nt; j++) - std::cout << xtaps[i][j] << " "; - - std::cout << "\n"; - } -#endif - -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - - if (d_updated) { - install_taps (d_new_taps); - return 0; // history requirements may have changed. - } - - int nfilters = interpolation (); - int ni = noutput_items / interpolation (); - - for (int i = 0; i < ni; i++){ - for (int nf = 0; nf < nfilters; nf++) - out[nf] = d_firs[nf]->filter (&in[i]); - out += nfilters; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t b/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t deleted file mode 100644 index 83904dce21..0000000000 --- a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by generate_gr_fir_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps); - -class @FIR_TYPE@; - -/*! - * \brief Interpolating FIR filter with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_interpolator -{ - private: - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps); - - std::vector<@TAP_TYPE@> d_new_taps; - bool d_updated; - std::vector<@FIR_TYPE@ *> d_firs; - - /*! - * Construct a FIR filter with the given taps - */ - @NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps); - - void install_taps (const std::vector<@TAP_TYPE@> &taps); - - public: - ~@NAME@ (); - - void set_taps (const std::vector<@TAP_TYPE@> &taps); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.i.t b/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.i.t deleted file mode 100644 index 2747530016..0000000000 --- a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.i.t +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by generate_GrFIRfilterXXX.py - * Any changes made to this file will be overwritten. - */ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (int interpolation, const std::vector<@TAP_TYPE@> &taps); - -class @NAME@ : public gr_sync_interpolator -{ - private: - @NAME@ (int interpolation, const std::vector<@TAP_TYPE@> &taps); - - public: - ~@NAME@ (); - - void set_taps (const std::vector<@TAP_TYPE@> &taps); -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc deleted file mode 100644 index ee09fef44e..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc +++ /dev/null @@ -1,210 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pfb_arb_resampler_ccf.h> -#include <gr_fir_ccf.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <cstdio> - -gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size) -{ - return gnuradio::get_initial_sptr(new gr_pfb_arb_resampler_ccf (rate, taps, - filter_size)); -} - - -gr_pfb_arb_resampler_ccf::gr_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size) - : gr_block ("pfb_arb_resampler_ccf", - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex))), - d_updated (false) -{ - d_acc = 0; // start accumulator at 0 - - /* The number of filters is specified by the user as the filter size; - this is also the interpolation rate of the filter. We use it and the - rate provided to determine the decimation rate. This acts as a - rational resampler. The flt_rate is calculated as the residual - between the integer decimation rate and the real decimation rate and - will be used to determine to interpolation point of the resampling - process. - */ - d_int_rate = filter_size; - set_rate(rate); - - // Store the last filter between calls to work - d_last_filter = 0; - - d_start_index = 0; - - d_filters = std::vector<gr_fir_ccf*>(d_int_rate); - d_diff_filters = std::vector<gr_fir_ccf*>(d_int_rate); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_int_rate); - for(unsigned int i = 0; i < d_int_rate; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - d_diff_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - } - - // Now, actually set the filters' taps - std::vector<float> dtaps; - create_diff_taps(taps, dtaps); - create_taps(taps, d_taps, d_filters); - create_taps(dtaps, d_dtaps, d_diff_filters); -} - -gr_pfb_arb_resampler_ccf::~gr_pfb_arb_resampler_ccf () -{ - for(unsigned int i = 0; i < d_int_rate; i++) { - delete d_filters[i]; - delete d_diff_filters[i]; - } -} - -void -gr_pfb_arb_resampler_ccf::create_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_ccf*> &ourfilter) -{ - unsigned int ntaps = newtaps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_int_rate); - - // Create d_numchan vectors to store each channel's taps - ourtaps.resize(d_int_rate); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = newtaps; - while((float)(tmp_taps.size()) < d_int_rate*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(unsigned int i = 0; i < d_int_rate; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - ourtaps[d_int_rate-1-i] = std::vector<float>(d_taps_per_filter, 0); - for(unsigned int j = 0; j < d_taps_per_filter; j++) { - ourtaps[d_int_rate - 1 - i][j] = tmp_taps[i + j*d_int_rate]; - } - - // Build a filter for each channel and add it's taps to it - ourfilter[i]->set_taps(ourtaps[d_int_rate-1-i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter + 1); - - d_updated = true; -} - -void -gr_pfb_arb_resampler_ccf::create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps) -{ - // Calculate the differential taps (derivative filter) by taking the difference - // between two taps. Duplicate the last one to make both filters the same length. - float tap; - difftaps.clear(); - for(unsigned int i = 0; i < newtaps.size()-1; i++) { - tap = newtaps[i+1] - newtaps[i]; - difftaps.push_back(tap); - } - difftaps.push_back(tap); -} - -void -gr_pfb_arb_resampler_ccf::print_taps() -{ - unsigned int i, j; - for(i = 0; i < d_int_rate; i++) { - printf("filter[%d]: [", i); - for(j = 0; j < d_taps_per_filter; j++) { - printf(" %.4e", d_taps[i][j]); - } - printf("]\n"); - } -} - -int -gr_pfb_arb_resampler_ccf::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - int i = 0, count = d_start_index; - unsigned int j; - gr_complex o0, o1; - - // Restore the last filter position - j = d_last_filter; - - // produce output as long as we can and there are enough input samples - int max_input = ninput_items[0]-(int)d_taps_per_filter; - while((i < noutput_items) && (count < max_input)) { - // start j by wrapping around mod the number of channels - while((j < d_int_rate) && (i < noutput_items)) { - // Take the current filter and derivative filter output - o0 = d_filters[j]->filter(&in[count]); - o1 = d_diff_filters[j]->filter(&in[count]); - - out[i] = o0 + o1*d_acc; // linearly interpolate between samples - i++; - - // Adjust accumulator and index into filterbank - d_acc += d_flt_rate; - j += d_dec_rate + (int)floor(d_acc); - d_acc = fmodf(d_acc, 1.0); - } - if(i < noutput_items) { // keep state for next entry - float ss = (int)(j / d_int_rate); // number of items to skip ahead by - count += ss; // we have fully consumed another input - j = j % d_int_rate; // roll filter around - } - } - - // Store the current filter position and start of next sample - d_last_filter = j; - d_start_index = std::max(0, count - ninput_items[0]); - - // consume all we've processed but no more than we can - consume_each(std::min(count, ninput_items[0])); - return i; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h deleted file mode 100644 index d92898a23e..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef INCLUDED_GR_PFB_ARB_RESAMPLER_CCF_H -#define INCLUDED_GR_PFB_ARB_RESAMPLER_CCF_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_pfb_arb_resampler_ccf; -typedef boost::shared_ptr<gr_pfb_arb_resampler_ccf> gr_pfb_arb_resampler_ccf_sptr; -GR_CORE_API gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size=32); - -class gr_fir_ccf; - -/*! - * \class gr_pfb_arb_resampler_ccf - * - * \brief Polyphase filterbank arbitrary resampler with - * gr_complex input, gr_complex output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block takes in a signal stream and performs arbitrary - * resampling. The resampling rate can be any real - * number <EM>r</EM>. The resampling is done by constructing - * <EM>N</EM> filters where <EM>N</EM> is the interpolation rate. We - * then calculate <EM>D</EM> where <EM>D = floor(N/r)</EM>. - * - * Using <EM>N</EM> and <EM>D</EM>, we can perform rational resampling - * where <EM>N/D</EM> is a rational number close to the input rate - * <EM>r</EM> where we have <EM>N</EM> filters and we cycle through - * them as a polyphase filterbank with a stride of <EM>D</EM> so that - * <EM>i+1 = (i + D) % N</EM>. - * - * To get the arbitrary rate, we want to interpolate between two - * points. For each value out, we take an output from the current - * filter, <EM>i</EM>, and the next filter <EM>i+1</EM> and then - * linearly interpolate between the two based on the real resampling - * rate we want. - * - * The linear interpolation only provides us with an approximation to - * the real sampling rate specified. The error is a quantization error - * between the two filters we used as our interpolation points. To - * this end, the number of filters, <EM>N</EM>, used determines the - * quantization error; the larger <EM>N</EM>, the smaller the - * noise. You can design for a specified noise floor by setting the - * filter size (parameters <EM>filter_size</EM>). The size defaults to - * 32 filters, which is about as good as most implementations need. - * - * The trick with designing this filter is in how to specify the taps - * of the prototype filter. Like the PFB interpolator, the taps are - * specified using the interpolated filter rate. In this case, that - * rate is the input sample rate multiplied by the number of filters - * in the filterbank, which is also the interpolation rate. All other - * values should be relative to this rate. - * - * For example, for a 32-filter arbitrary resampler and using the - * GNU Radio's firdes utility to build the filter, we build a low-pass - * filter with a sampling rate of <EM>fs</EM>, a 3-dB bandwidth of - * <EM>BW</EM> and a transition bandwidth of <EM>TB</EM>. We can also - * specify the out-of-band attenuation to use, <EM>ATT</EM>, and the - * filter window function (a Blackman-harris window in this case). The - * first input is the gain of the filter, which we specify here as the - * interpolation rate (<EM>32</EM>). - * - * <B><EM>self._taps = gr.firdes.low_pass_2(32, 32*fs, BW, TB, - * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B> - * - * The theory behind this block can be found in Chapter 7.5 of - * the following book. - * - * <B><EM>f. harris, "Multirate Signal Processing for Communication - * Systems", Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B> - */ - -class GR_CORE_API gr_pfb_arb_resampler_ccf : public gr_block -{ - private: - /*! - * Build the polyphase filterbank arbitray resampler. - * \param rate (float) Specifies the resampling rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the filter_size sampling rate. - * \param filter_size (unsigned int) The number of filters in the filter bank. This is directly - related to quantization noise introduced during the resampling. - Defaults to 32 filters. - */ - friend GR_CORE_API gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size); - - std::vector<gr_fir_ccf*> d_filters; - std::vector<gr_fir_ccf*> d_diff_filters; - std::vector< std::vector<float> > d_taps; - std::vector< std::vector<float> > d_dtaps; - unsigned int d_int_rate; // the number of filters (interpolation rate) - unsigned int d_dec_rate; // the stride through the filters (decimation rate) - float d_flt_rate; // residual rate for the linear interpolation - float d_acc; - unsigned int d_last_filter; - int d_start_index; - unsigned int d_taps_per_filter; - bool d_updated; - - /*! - * Build the polyphase filterbank arbitray resampler. - * \param rate (float) Specifies the resampling rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the filter_size sampling rate. - * \param filter_size (unsigned int) The number of filters in the filter bank. This is directly - related to quantization noise introduced during the resampling. - Defaults to 32 filters. - */ - gr_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size); - - void create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - * \param newtaps (vector of floats) The prototype filter to populate the filterbank. - * The taps should be generated at the interpolated sampling rate. - * \param ourtaps (vector of floats) Reference to our internal member of holding the taps. - * \param ourfilter (vector of filters) Reference to our internal filter to set the taps for. - */ - void create_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_ccf*> &ourfilter); - - -public: - ~gr_pfb_arb_resampler_ccf (); - - // FIXME: See about a set_taps function during runtime. - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - void set_rate (float rate) { - d_dec_rate = (unsigned int)floor(d_int_rate/rate); - d_flt_rate = (d_int_rate/rate) - d_dec_rate; - set_relative_rate(rate); - } - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.i deleted file mode 100644 index da58947e92..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_arb_resampler_ccf); - -gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size=32); - -class gr_pfb_arb_resampler_ccf : public gr_block -{ - private: - gr_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size); - - public: - ~gr_pfb_arb_resampler_ccf (); - - //void set_taps (const std::vector<float> &taps); - void print_taps(); - void set_rate (float rate); -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.cc b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.cc deleted file mode 100644 index f01af2e6f4..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.cc +++ /dev/null @@ -1,210 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009-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 <gr_pfb_arb_resampler_fff.h> -#include <gr_fir_fff.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <cstdio> - -gr_pfb_arb_resampler_fff_sptr gr_make_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size) -{ - return gnuradio::get_initial_sptr(new gr_pfb_arb_resampler_fff (rate, taps, - filter_size)); -} - - -gr_pfb_arb_resampler_fff::gr_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size) - : gr_block ("pfb_arb_resampler_fff", - gr_make_io_signature (1, 1, sizeof(float)), - gr_make_io_signature (1, 1, sizeof(float))), - d_updated (false) -{ - d_acc = 0; // start accumulator at 0 - - /* The number of filters is specified by the user as the filter size; - this is also the interpolation rate of the filter. We use it and the - rate provided to determine the decimation rate. This acts as a - rational resampler. The flt_rate is calculated as the residual - between the integer decimation rate and the real decimation rate and - will be used to determine to interpolation point of the resampling - process. - */ - d_int_rate = filter_size; - set_rate(rate); - - // Store the last filter between calls to work - d_last_filter = 0; - - d_start_index = 0; - - d_filters = std::vector<gr_fir_fff*>(d_int_rate); - d_diff_filters = std::vector<gr_fir_fff*>(d_int_rate); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_int_rate); - for(unsigned int i = 0; i < d_int_rate; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); - d_diff_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); - } - - // Now, actually set the filters' taps - std::vector<float> dtaps; - create_diff_taps(taps, dtaps); - create_taps(taps, d_taps, d_filters); - create_taps(dtaps, d_dtaps, d_diff_filters); -} - -gr_pfb_arb_resampler_fff::~gr_pfb_arb_resampler_fff () -{ - for(unsigned int i = 0; i < d_int_rate; i++) { - delete d_filters[i]; - delete d_diff_filters[i]; - } -} - -void -gr_pfb_arb_resampler_fff::create_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_fff*> &ourfilter) -{ - unsigned int ntaps = newtaps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_int_rate); - - // Create d_numchan vectors to store each channel's taps - ourtaps.resize(d_int_rate); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = newtaps; - while((float)(tmp_taps.size()) < d_int_rate*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(unsigned int i = 0; i < d_int_rate; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - ourtaps[d_int_rate-1-i] = std::vector<float>(d_taps_per_filter, 0); - for(unsigned int j = 0; j < d_taps_per_filter; j++) { - ourtaps[d_int_rate - 1 - i][j] = tmp_taps[i + j*d_int_rate]; - } - - // Build a filter for each channel and add it's taps to it - ourfilter[i]->set_taps(ourtaps[d_int_rate-1-i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter + 1); - - d_updated = true; -} - -void -gr_pfb_arb_resampler_fff::create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps) -{ - // Calculate the differential taps (derivative filter) by taking the difference - // between two taps. Duplicate the last one to make both filters the same length. - float tap; - difftaps.clear(); - for(unsigned int i = 0; i < newtaps.size()-1; i++) { - tap = newtaps[i+1] - newtaps[i]; - difftaps.push_back(tap); - } - difftaps.push_back(tap); -} - -void -gr_pfb_arb_resampler_fff::print_taps() -{ - unsigned int i, j; - for(i = 0; i < d_int_rate; i++) { - printf("filter[%d]: [", i); - for(j = 0; j < d_taps_per_filter; j++) { - printf(" %.4e", d_taps[i][j]); - } - printf("]\n"); - } -} - -int -gr_pfb_arb_resampler_fff::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *in = (float *) input_items[0]; - float *out = (float *) output_items[0]; - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - int i = 0, count = d_start_index; - unsigned int j; - float o0, o1; - - // Restore the last filter position - j = d_last_filter; - - // produce output as long as we can and there are enough input samples - int max_input = ninput_items[0]-(int)d_taps_per_filter; - while((i < noutput_items) && (count < max_input)) { - // start j by wrapping around mod the number of channels - while((j < d_int_rate) && (i < noutput_items)) { - // Take the current filter and derivative filter output - o0 = d_filters[j]->filter(&in[count]); - o1 = d_diff_filters[j]->filter(&in[count]); - - out[i] = o0 + o1*d_acc; // linearly interpolate between samples - i++; - - // Adjust accumulator and index into filterbank - d_acc += d_flt_rate; - j += d_dec_rate + (int)floor(d_acc); - d_acc = fmodf(d_acc, 1.0); - } - if(i < noutput_items) { // keep state for next entry - float ss = (int)(j / d_int_rate); // number of items to skip ahead by - count += ss; // we have fully consumed another input - j = j % d_int_rate; // roll filter around - } - } - - // Store the current filter position and start of next sample - d_last_filter = j; - d_start_index = std::max(0, count - ninput_items[0]); - - // consume all we've processed but no more than we can - consume_each(std::min(count, ninput_items[0])); - return i; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.h b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.h deleted file mode 100644 index d2e375210d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.h +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009-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_GR_PFB_ARB_RESAMPLER_FFF_H -#define INCLUDED_GR_PFB_ARB_RESAMPLER_FFF_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_pfb_arb_resampler_fff; -typedef boost::shared_ptr<gr_pfb_arb_resampler_fff> gr_pfb_arb_resampler_fff_sptr; -GR_CORE_API gr_pfb_arb_resampler_fff_sptr gr_make_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size=32); - -class gr_fir_fff; - -/*! - * \class gr_pfb_arb_resampler_fff - * - * \brief Polyphase filterbank arbitrary resampler with - * float input, float output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block takes in a signal stream and performs arbitrary - * resampling. The resampling rate can be any real - * number <EM>r</EM>. The resampling is done by constructing - * <EM>N</EM> filters where <EM>N</EM> is the interpolation rate. We - * then calculate <EM>D</EM> where <EM>D = floor(N/r)</EM>. - * - * Using <EM>N</EM> and <EM>D</EM>, we can perform rational resampling - * where <EM>N/D</EM> is a rational number close to the input rate - * <EM>r</EM> where we have <EM>N</EM> filters and we cycle through - * them as a polyphase filterbank with a stride of <EM>D</EM> so that - * <EM>i+1 = (i + D) % N</EM>. - * - * To get the arbitrary rate, we want to interpolate between two - * points. For each value out, we take an output from the current - * filter, <EM>i</EM>, and the next filter <EM>i+1</EM> and then - * linearly interpolate between the two based on the real resampling - * rate we want. - * - * The linear interpolation only provides us with an approximation to - * the real sampling rate specified. The error is a quantization error - * between the two filters we used as our interpolation points. To - * this end, the number of filters, <EM>N</EM>, used determines the - * quantization error; the larger <EM>N</EM>, the smaller the - * noise. You can design for a specified noise floor by setting the - * filter size (parameters <EM>filter_size</EM>). The size defaults to - * 32 filters, which is about as good as most implementations need. - * - * The trick with designing this filter is in how to specify the taps - * of the prototype filter. Like the PFB interpolator, the taps are - * specified using the interpolated filter rate. In this case, that - * rate is the input sample rate multiplied by the number of filters - * in the filterbank, which is also the interpolation rate. All other - * values should be relative to this rate. - * - * For example, for a 32-filter arbitrary resampler and using the - * GNU Radio's firdes utility to build the filter, we build a low-pass - * filter with a sampling rate of <EM>fs</EM>, a 3-dB bandwidth of - * <EM>BW</EM> and a transition bandwidth of <EM>TB</EM>. We can also - * specify the out-of-band attenuation to use, <EM>ATT</EM>, and the - * filter window function (a Blackman-harris window in this case). The - * first input is the gain of the filter, which we specify here as the - * interpolation rate (<EM>32</EM>). - * - * <B><EM>self._taps = gr.firdes.low_pass_2(32, 32*fs, BW, TB, - * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B> - * - * The theory behind this block can be found in Chapter 7.5 of - * the following book. - * - * <B><EM>f. harris, "Multirate Signal Processing for Communication - * Systems", Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B> - */ - -class GR_CORE_API gr_pfb_arb_resampler_fff : public gr_block -{ - private: - /*! - * Build the polyphase filterbank arbitray resampler. - * \param rate (float) Specifies the resampling rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the filter_size sampling rate. - * \param filter_size (unsigned int) The number of filters in the filter bank. This is directly - related to quantization noise introduced during the resampling. - Defaults to 32 filters. - */ - friend GR_CORE_API gr_pfb_arb_resampler_fff_sptr gr_make_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size); - - std::vector<gr_fir_fff*> d_filters; - std::vector<gr_fir_fff*> d_diff_filters; - std::vector< std::vector<float> > d_taps; - std::vector< std::vector<float> > d_dtaps; - unsigned int d_int_rate; // the number of filters (interpolation rate) - unsigned int d_dec_rate; // the stride through the filters (decimation rate) - float d_flt_rate; // residual rate for the linear interpolation - float d_acc; - unsigned int d_last_filter; - int d_start_index; - unsigned int d_taps_per_filter; - bool d_updated; - - /*! - * Build the polyphase filterbank arbitray resampler. - * \param rate (float) Specifies the resampling rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the filter_size sampling rate. - * \param filter_size (unsigned int) The number of filters in the filter bank. This is directly - related to quantization noise introduced during the resampling. - Defaults to 32 filters. - */ - gr_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size); - - void create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - * \param newtaps (vector of floats) The prototype filter to populate the filterbank. - * The taps should be generated at the interpolated sampling rate. - * \param ourtaps (vector of floats) Reference to our internal member of holding the taps. - * \param ourfilter (vector of filters) Reference to our internal filter to set the taps for. - */ - void create_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_fff*> &ourfilter); - - -public: - ~gr_pfb_arb_resampler_fff (); - - // FIXME: See about a set_taps function during runtime. - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - void set_rate (float rate) { - d_dec_rate = (unsigned int)floor(d_int_rate/rate); - d_flt_rate = (d_int_rate/rate) - d_dec_rate; - set_relative_rate(rate); - } - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.i b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.i deleted file mode 100644 index ad09053610..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_arb_resampler_fff); - -gr_pfb_arb_resampler_fff_sptr gr_make_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size=32); - -class gr_pfb_arb_resampler_fff : public gr_block -{ - private: - gr_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size); - - public: - ~gr_pfb_arb_resampler_fff (); - - //void set_taps (const std::vector<float> &taps); - void print_taps(); - void set_rate (float rate); -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc deleted file mode 100644 index a8cb849e27..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ /dev/null @@ -1,240 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pfb_channelizer_ccf.h> -#include <gr_fir_ccf.h> -#include <gr_fir_util.h> -#include <gri_fft.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <cstring> - -gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate) -{ - return gnuradio::get_initial_sptr(new gr_pfb_channelizer_ccf (numchans, taps, - oversample_rate)); -} - - -gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate) - : gr_block ("pfb_channelizer_ccf", - gr_make_io_signature (numchans, numchans, sizeof(gr_complex)), - gr_make_io_signature (1, numchans, sizeof(gr_complex))), - d_updated (false), d_numchans(numchans), d_oversample_rate(oversample_rate) -{ - // The over sampling rate must be rationally related to the number of channels - // in that it must be N/i for i in [1,N], which gives an outputsample rate - // of [fs/N, fs] where fs is the input sample rate. - // This tests the specified input sample rate to see if it conforms to this - // requirement within a few significant figures. - double intp = 0; - double fltp = modf(numchans / oversample_rate, &intp); - if(fltp != 0.0) - throw std::invalid_argument("gr_pfb_channelizer: oversample rate must be N/i for i in [1, N]"); - - set_relative_rate(1.0/intp); - - d_filters = std::vector<gr_fir_ccf*>(d_numchans); - d_channel_map.resize(d_numchans); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_numchans); - for(unsigned int i = 0; i < d_numchans; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - d_channel_map[i] = i; - } - - // Now, actually set the filters' taps - set_taps(taps); - - // Create the FFT to handle the output de-spinning of the channels - d_fft = new gri_fft_complex (d_numchans, false); - - // Although the filters change, we use this look up table - // to set the index of the FFT input buffer, which equivalently - // performs the FFT shift operation on every other turn. - d_rate_ratio = (int)rintf(d_numchans / d_oversample_rate); - d_idxlut = new int[d_numchans]; - for(unsigned int i = 0; i < d_numchans; i++) { - d_idxlut[i] = d_numchans - ((i + d_rate_ratio) % d_numchans) - 1; - } - - // Calculate the number of filtering rounds to do to evenly - // align the input vectors with the output channels - d_output_multiple = 1; - while((d_output_multiple * d_rate_ratio) % d_numchans != 0) - d_output_multiple++; - set_output_multiple(d_output_multiple); -} - -gr_pfb_channelizer_ccf::~gr_pfb_channelizer_ccf () -{ - delete d_fft; - delete [] d_idxlut; - - for(unsigned int i = 0; i < d_numchans; i++) { - delete d_filters[i]; - } -} - -void -gr_pfb_channelizer_ccf::set_taps (const std::vector<float> &taps) -{ - gruel::scoped_lock guard(d_mutex); - unsigned int i,j; - - unsigned int ntaps = taps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_numchans); - - // Create d_numchan vectors to store each channel's taps - d_taps.resize(d_numchans); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = taps; - while((float)(tmp_taps.size()) < d_numchans*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_numchans; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - d_taps[i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - d_taps[i][j] = tmp_taps[i + j*d_numchans]; // add taps to channels in reverse order - } - - // Build a filter for each channel and add it's taps to it - d_filters[i]->set_taps(d_taps[i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter+1); - - d_updated = true; -} - -void -gr_pfb_channelizer_ccf::print_taps() -{ - unsigned int i, j; - for(i = 0; i < d_numchans; i++) { - printf("filter[%d]: [", i); - for(j = 0; j < d_taps_per_filter; j++) { - printf(" %.4e", d_taps[i][j]); - } - printf("]\n\n"); - } -} - -std::vector< std::vector<float> > -gr_pfb_channelizer_ccf::taps() const -{ - return d_taps; -} - -void -gr_pfb_channelizer_ccf::set_channel_map(const std::vector<int> &map) -{ - gruel::scoped_lock guard(d_mutex); - - if(map.size() > 0) { - unsigned int max = (unsigned int)*std::max_element(map.begin(), map.end()); - unsigned int min = (unsigned int)*std::min_element(map.begin(), map.end()); - if((max >= d_numchans) || (min < 0)) { - throw std::invalid_argument("gr_pfb_channelizer_ccf::set_channel_map: map range out of bounds.\n"); - } - d_channel_map = map; - } -} - -std::vector<int> -gr_pfb_channelizer_ccf::channel_map() const -{ - return d_channel_map; -} - - -int -gr_pfb_channelizer_ccf::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gruel::scoped_lock guard(d_mutex); - - gr_complex *in = (gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - size_t noutputs = output_items.size(); - - int n=1, i=-1, j=0, oo=0, last; - int toconsume = (int)rintf(noutput_items/d_oversample_rate); - while(n <= toconsume) { - j = 0; - i = (i + d_rate_ratio) % d_numchans; - last = i; - while(i >= 0) { - in = (gr_complex*)input_items[j]; - d_fft->get_inbuf()[d_idxlut[j]] = d_filters[i]->filter(&in[n]); - j++; - i--; - } - - i = d_numchans-1; - while(i > last) { - in = (gr_complex*)input_items[j]; - d_fft->get_inbuf()[d_idxlut[j]] = d_filters[i]->filter(&in[n-1]); - j++; - i--; - } - - n += (i+d_rate_ratio) >= (int)d_numchans; - - // despin through FFT - d_fft->execute(); - - // Send to output channels - for(unsigned int nn = 0; nn < noutputs; nn++) { - out = (gr_complex*)output_items[nn]; - out[oo] = d_fft->get_outbuf()[d_channel_map[nn]]; - } - oo++; - } - - consume_each(toconsume); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h deleted file mode 100644 index 79ad322f9a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef INCLUDED_GR_PFB_CHANNELIZER_CCF_H -#define INCLUDED_GR_PFB_CHANNELIZER_CCF_H - -#include <gr_core_api.h> -#include <gr_block.h> -#include <gruel/thread.h> - -class gr_pfb_channelizer_ccf; -typedef boost::shared_ptr<gr_pfb_channelizer_ccf> gr_pfb_channelizer_ccf_sptr; -GR_CORE_API gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate=1); - -class gr_fir_ccf; -class gri_fft_complex; - - -/*! - * \class gr_pfb_channelizer_ccf - * - * \brief Polyphase filterbank channelizer with - * gr_complex input, gr_complex output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block takes in complex inputs and channelizes it to <EM>M</EM> - * channels of equal bandwidth. Each of the resulting channels is - * decimated to the new rate that is the input sampling rate - * <EM>fs</EM> divided by the number of channels, <EM>M</EM>. - * - * The PFB channelizer code takes the taps generated above and builds - * a set of filters. The set contains <EM>M</EM> number of filters - * and each filter contains ceil(taps.size()/decim) number of taps. - * Each tap from the filter prototype is sequentially inserted into - * the next filter. When all of the input taps are used, the remaining - * filters in the filterbank are filled out with 0's to make sure each - * filter has the same number of taps. - * - * Each filter operates using the gr_fir filter classs of GNU Radio, - * which takes the input stream at <EM>i</EM> and performs the inner - * product calculation to <EM>i+(n-1)</EM> where <EM>n</EM> is the - * number of filter taps. To efficiently handle this in the GNU Radio - * structure, each filter input must come from its own input - * stream. So the channelizer must be provided with <EM>M</EM> streams - * where the input stream has been deinterleaved. This is most easily - * done using the gr_stream_to_streams block. - * - * The output is then produced as a vector, where index <EM>i</EM> in - * the vector is the next sample from the <EM>i</EM>th channel. This - * is most easily handled by sending the output to a - * gr_vector_to_streams block to handle the conversion and passing - * <EM>M</EM> streams out. - * - * The input and output formatting is done using a hier_block2 called - * pfb_channelizer_ccf. This can take in a single stream and outputs - * <EM>M</EM> streams based on the behavior described above. - * - * The filter's taps should be based on the input sampling rate. - * - * For example, using the GNU Radio's firdes utility to building - * filters, we build a low-pass filter with a sampling rate of - * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition - * bandwidth of <EM>TB</EM>. We can also specify the out-of-band - * attenuation to use, <EM>ATT</EM>, and the filter window - * function (a Blackman-harris window in this case). The first input - * is the gain of the filter, which we specify here as unity. - * - * <B><EM>self._taps = gr.firdes.low_pass_2(1, fs, BW, TB, - * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B> - * - * The filter output can also be overs ampled. The over sampling rate - * is the ratio of the the actual output sampling rate to the normal - * output sampling rate. It must be rationally related to the number - * of channels as N/i for i in [1,N], which gives an outputsample rate - * of [fs/N, fs] where fs is the input sample rate and N is the number - * of channels. - * - * For example, for 6 channels with fs = 6000 Hz, the normal rate is - * 6000/6 = 1000 Hz. Allowable oversampling rates are 6/6, 6/5, 6/4, - * 6/3, 6/2, and 6/1 where the output sample rate of a 6/1 oversample - * ratio is 6000 Hz, or 6 times the normal 1000 Hz. A rate of 6/5 = 1.2, - * so the output rate would be 1200 Hz. - * - * The theory behind this block can be found in Chapter 6 of - * the following book. - * - * <B><EM>f. harris, "Multirate Signal Processing for Communication - * Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B> - * - */ - -class GR_CORE_API gr_pfb_channelizer_ccf : public gr_block -{ - private: - /*! - * Build the polyphase filterbank decimator. - * \param numchans (unsigned integer) Specifies the number of channels <EM>M</EM> - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. - * \param oversample_rate (float) The over sampling rate is the ratio of the the actual - * output sampling rate to the normal output sampling rate. - * It must be rationally related to the number of channels - * as N/i for i in [1,N], which gives an outputsample rate - * of [fs/N, fs] where fs is the input sample rate and N is - * the number of channels. - * - * For example, for 6 channels with fs = 6000 Hz, the normal - * rate is 6000/6 = 1000 Hz. Allowable oversampling rates - * are 6/6, 6/5, 6/4, 6/3, 6/2, and 6/1 where the output - * sample rate of a 6/1 oversample ratio is 6000 Hz, or - * 6 times the normal 1000 Hz. - */ - friend GR_CORE_API gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate); - - bool d_updated; - unsigned int d_numchans; - float d_oversample_rate; - std::vector<gr_fir_ccf*> d_filters; - std::vector< std::vector<float> > d_taps; - unsigned int d_taps_per_filter; - gri_fft_complex *d_fft; - int *d_idxlut; - int d_rate_ratio; - int d_output_multiple; - std::vector<int> d_channel_map; - gruel::mutex d_mutex; // mutex to protect set/work access - - /*! - * Build the polyphase filterbank decimator. - * \param numchans (unsigned integer) Specifies the number of channels <EM>M</EM> - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. - * \param oversample_rate (float) The output over sampling rate. - */ - gr_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate); - -public: - ~gr_pfb_channelizer_ccf (); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. - */ - void set_taps (const std::vector<float> &taps); - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - - /*! - * Return a vector<vector<>> of the filterbank taps - */ - std::vector<std::vector<float> > taps() const; - - /*! - * Set the channel map. Channels are numbers as: - * - * N/2+1 | ... | N-1 | 0 | 1 | 2 | ... | N/2 - * <------------------- 0 --------------------> - * freq - * - * So output stream 0 comes from channel 0, etc. Setting a new - * channel map allows the user to specify which channel in frequency - * he/she wants to got to which output stream. - * - * The map should have the same number of elements as the number of - * output connections from the block. The minimum value of the map - * is 0 (for the 0th channel) and the maximum number is N-1 where N - * is the number of channels. - * - * We specify M as the number of output connections made where M <= - * N, so only M out of N channels are driven to an output - * stream. The number of items in the channel map should be at least - * M long. If there are more channels specified, any value in the - * map over M-1 will be ignored. If the size of the map is less than - * M the behavior is unknown (we don't wish to check every entry - * into the work function). - * - * This means that if the channelizer is splitting the signal up - * into N channels but only M channels are specified in the map - * (where M <= N), then M output streams must be connected and the - * map and the channel numbers used must be less than N-1. Output - * channel number can be reused, too. By default, the map is - * [0...M-1] with M = N. - */ - void set_channel_map(const std::vector<int> &map); - - /*! - * Gets the current channel map. - */ - std::vector<int> channel_map() const; - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i deleted file mode 100644 index 1f2b49452f..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_channelizer_ccf); - -gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate=1); - -class gr_pfb_channelizer_ccf : public gr_block -{ - private: - gr_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate); - - public: - ~gr_pfb_channelizer_ccf (); - - void set_taps (const std::vector<float> &taps); - void print_taps(); - std::vector<std::vector<float> > taps() const; - - void set_channel_map(const std::vector<int> &map); - std::vector<int> channel_map() const; -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc deleted file mode 100644 index efe417918a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc +++ /dev/null @@ -1,441 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009-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 <cstdio> -#include <cmath> - -#include <gr_pfb_clock_sync_ccf.h> -#include <gr_fir_ccf.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <gr_math.h> - -gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps) -{ - return gnuradio::get_initial_sptr(new gr_pfb_clock_sync_ccf (sps, loop_bw, taps, - filter_size, - init_phase, - max_rate_deviation, - osps)); -} - -static int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)}; -static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); -gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps) - : gr_block ("pfb_clock_sync_ccf", - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signaturev (1, 4, iosig)), - d_updated (false), d_nfilters(filter_size), - d_max_dev(max_rate_deviation), - d_osps(osps), d_error(0), d_out_idx(0) -{ - d_nfilters = filter_size; - d_sps = floor(sps); - - // Set the damping factor for a critically damped system - d_damping = sqrtf(2.0f)/2.0f; - - // Set the bandwidth, which will then call update_gains() - set_loop_bandwidth(loop_bw); - - // Store the last filter between calls to work - // The accumulator keeps track of overflow to increment the stride correctly. - // set it here to the fractional difference based on the initial phaes - d_k = init_phase; - d_rate = (sps-floor(sps))*(double)d_nfilters; - d_rate_i = (int)floor(d_rate); - d_rate_f = d_rate - (float)d_rate_i; - d_filtnum = (int)floor(d_k); - - d_filters = std::vector<gr_fir_ccf*>(d_nfilters); - d_diff_filters = std::vector<gr_fir_ccf*>(d_nfilters); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_nfilters); - for(int i = 0; i < d_nfilters; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - d_diff_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - } - - // Now, actually set the filters' taps - std::vector<float> dtaps; - create_diff_taps(taps, dtaps); - set_taps(taps, d_taps, d_filters); - set_taps(dtaps, d_dtaps, d_diff_filters); -} - -gr_pfb_clock_sync_ccf::~gr_pfb_clock_sync_ccf () -{ - for(int i = 0; i < d_nfilters; i++) { - delete d_filters[i]; - delete d_diff_filters[i]; - } -} - -bool -gr_pfb_clock_sync_ccf::check_topology(int ninputs, int noutputs) -{ - return noutputs == 1 || noutputs == 4; -} - - - -/******************************************************************* - SET FUNCTIONS -*******************************************************************/ - - -void -gr_pfb_clock_sync_ccf::set_loop_bandwidth(float bw) -{ - if(bw < 0) { - throw std::out_of_range ("gr_pfb_clock_sync_cc: invalid bandwidth. Must be >= 0."); - } - - d_loop_bw = bw; - update_gains(); -} - -void -gr_pfb_clock_sync_ccf::set_damping_factor(float df) -{ - if(df < 0 || df > 1.0) { - throw std::out_of_range ("gr_pfb_clock_sync_cc: invalid damping factor. Must be in [0,1]."); - } - - d_damping = df; - update_gains(); -} - -void -gr_pfb_clock_sync_ccf::set_alpha(float alpha) -{ - if(alpha < 0 || alpha > 1.0) { - throw std::out_of_range ("gr_pfb_clock_sync_cc: invalid alpha. Must be in [0,1]."); - } - d_alpha = alpha; -} - -void -gr_pfb_clock_sync_ccf::set_beta(float beta) -{ - if(beta < 0 || beta > 1.0) { - throw std::out_of_range ("gr_pfb_clock_sync_cc: invalid beta. Must be in [0,1]."); - } - d_beta = beta; -} - -/******************************************************************* - GET FUNCTIONS -*******************************************************************/ - - -float -gr_pfb_clock_sync_ccf::get_loop_bandwidth() const -{ - return d_loop_bw; -} - -float -gr_pfb_clock_sync_ccf::get_damping_factor() const -{ - return d_damping; -} - -float -gr_pfb_clock_sync_ccf::get_alpha() const -{ - return d_alpha; -} - -float -gr_pfb_clock_sync_ccf::get_beta() const -{ - return d_beta; -} - -float -gr_pfb_clock_sync_ccf::get_clock_rate() const -{ - return d_rate_f; -} - -/******************************************************************* -*******************************************************************/ - -void -gr_pfb_clock_sync_ccf::update_gains() -{ - float denom = (1.0 + 2.0*d_damping*d_loop_bw + d_loop_bw*d_loop_bw); - d_alpha = (4*d_damping*d_loop_bw) / denom; - d_beta = (4*d_loop_bw*d_loop_bw) / denom; -} - - -void -gr_pfb_clock_sync_ccf::set_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_ccf*> &ourfilter) -{ - int i,j; - - unsigned int ntaps = newtaps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_nfilters); - - // Create d_numchan vectors to store each channel's taps - ourtaps.resize(d_nfilters); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = newtaps; - while((float)(tmp_taps.size()) < d_nfilters*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_nfilters; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - //ourtaps[d_nfilters-1-i] = std::vector<float>(d_taps_per_filter, 0); - ourtaps[i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - //ourtaps[d_nfilters - 1 - i][j] = tmp_taps[i + j*d_nfilters]; - ourtaps[i][j] = tmp_taps[i + j*d_nfilters]; - } - - // Build a filter for each channel and add it's taps to it - //ourfilter[i]->set_taps(ourtaps[d_nfilters-1-i]); - ourfilter[i]->set_taps(ourtaps[i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter + d_sps); - - // Make sure there is enough output space for d_osps outputs/input. - set_output_multiple(d_osps); - - d_updated = true; -} - -void -gr_pfb_clock_sync_ccf::create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps) -{ - std::vector<float> diff_filter(3); - diff_filter[0] = -1; - diff_filter[1] = 0; - diff_filter[2] = 1; - - float pwr = 0; - difftaps.push_back(0); - for(unsigned int i = 0; i < newtaps.size()-2; i++) { - float tap = 0; - for(int j = 0; j < 3; j++) { - tap += diff_filter[j]*newtaps[i+j]; - pwr += fabsf(tap); - } - difftaps.push_back(tap); - } - difftaps.push_back(0); - - for(unsigned int i = 0; i < difftaps.size(); i++) { - difftaps[i] *= pwr; - } -} - -std::string -gr_pfb_clock_sync_ccf::get_taps_as_string() -{ - int i, j; - std::stringstream str; - str.precision(4); - str.setf(std::ios::scientific); - - str << "[ "; - for(i = 0; i < d_nfilters; i++) { - str << "[" << d_taps[i][0] << ", "; - for(j = 1; j < d_taps_per_filter-1; j++) { - str << d_taps[i][j] << ", "; - } - str << d_taps[i][j] << "],"; - } - str << " ]" << std::endl; - - return str.str(); -} - -std::string -gr_pfb_clock_sync_ccf::get_diff_taps_as_string() -{ - int i, j; - std::stringstream str; - str.precision(4); - str.setf(std::ios::scientific); - - str << "[ "; - for(i = 0; i < d_nfilters; i++) { - str << "[" << d_dtaps[i][0] << ", "; - for(j = 1; j < d_taps_per_filter-1; j++) { - str << d_dtaps[i][j] << ", "; - } - str << d_dtaps[i][j] << "],"; - } - str << " ]" << std::endl; - - return str.str(); -} - -std::vector< std::vector<float> > -gr_pfb_clock_sync_ccf::get_taps() -{ - return d_taps; -} - -std::vector< std::vector<float> > -gr_pfb_clock_sync_ccf::get_diff_taps() -{ - return d_dtaps; -} - -std::vector<float> -gr_pfb_clock_sync_ccf::get_channel_taps(int channel) -{ - std::vector<float> taps; - for(int i = 0; i < d_taps_per_filter; i++) { - taps.push_back(d_taps[channel][i]); - } - return taps; -} - -std::vector<float> -gr_pfb_clock_sync_ccf::get_diff_channel_taps(int channel) -{ - std::vector<float> taps; - for(int i = 0; i < d_taps_per_filter; i++) { - taps.push_back(d_dtaps[channel][i]); - } - return taps; -} - - -int -gr_pfb_clock_sync_ccf::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - float *err = NULL, *outrate = NULL, *outk = NULL; - if(output_items.size() == 4) { - err = (float *) output_items[1]; - outrate = (float*)output_items[2]; - outk = (float*)output_items[3]; - } - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - // We need this many to process one output - int nrequired = ninput_items[0] - d_taps_per_filter - d_osps; - - int i = 0, count = 0; - float error_r, error_i; - - // produce output as long as we can and there are enough input samples - while((i < noutput_items) && (count < nrequired)) { - while(d_out_idx < d_osps) { - d_filtnum = (int)floor(d_k); - - // Keep the current filter number in [0, d_nfilters] - // If we've run beyond the last filter, wrap around and go to next sample - // If we've go below 0, wrap around and go to previous sample - while(d_filtnum >= d_nfilters) { - d_k -= d_nfilters; - d_filtnum -= d_nfilters; - count += 1; - } - while(d_filtnum < 0) { - d_k += d_nfilters; - d_filtnum += d_nfilters; - count -= 1; - } - - out[i+d_out_idx] = d_filters[d_filtnum]->filter(&in[count+d_out_idx]); - d_k = d_k + d_rate_i + d_rate_f; // update phase - d_out_idx++; - - if(output_items.size() == 4) { - err[i] = d_error; - outrate[i] = d_rate_f; - outk[i] = d_k; - } - - // We've run out of output items we can create; return now. - if(i+d_out_idx >= noutput_items) { - consume_each(count); - return i; - } - } - - // reset here; if we didn't complete a full osps samples last time, - // the early return would take care of it. - d_out_idx = 0; - - // Update the phase and rate estimates for this symbol - gr_complex diff = d_diff_filters[d_filtnum]->filter(&in[count]); - error_r = out[i].real() * diff.real(); - error_i = out[i].imag() * diff.imag(); - d_error = (error_i + error_r) / 2.0; // average error from I&Q channel - - // Run the control loop to update the current phase (k) and - // tracking rate estimates based on the error value - d_rate_f = d_rate_f + d_beta*d_error; - d_k = d_k + d_alpha*d_error; - - // Keep our rate within a good range - d_rate_f = gr_branchless_clip(d_rate_f, d_max_dev); - - i+=d_osps; - count += (int)floor(d_sps); - } - - consume_each(count); - return i; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h deleted file mode 100644 index 8715b4b106..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h +++ /dev/null @@ -1,375 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef INCLUDED_GR_PFB_CLOCK_SYNC_CCF_H -#define INCLUDED_GR_PFB_CLOCK_SYNC_CCF_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_pfb_clock_sync_ccf; -typedef boost::shared_ptr<gr_pfb_clock_sync_ccf> gr_pfb_clock_sync_ccf_sptr; -GR_CORE_API gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size=32, - float init_phase=0, - float max_rate_deviation=1.5, - int osps=1); - -class gr_fir_ccf; - -/*! - * \class gr_pfb_clock_sync_ccf - * - * \brief Timing synchronizer using polyphase filterbanks - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block performs timing synchronization for PAM signals by - * minimizing the derivative of the filtered signal, which in turn - * maximizes the SNR and minimizes ISI. - * - * This approach works by setting up two filterbanks; one filterbank - * contains the signal's pulse shaping matched filter (such as a root - * raised cosine filter), where each branch of the filterbank contains - * a different phase of the filter. The second filterbank contains - * the derivatives of the filters in the first filterbank. Thinking of - * this in the time domain, the first filterbank contains filters that - * have a sinc shape to them. We want to align the output signal to be - * sampled at exactly the peak of the sinc shape. The derivative of - * the sinc contains a zero at the maximum point of the sinc (sinc(0) - * = 1, sinc(0)' = 0). Furthermore, the region around the zero point - * is relatively linear. We make use of this fact to generate the - * error signal. - * - * If the signal out of the derivative filters is d_i[n] for the ith - * filter, and the output of the matched filter is x_i[n], we - * calculate the error as: e[n] = (Re{x_i[n]} * Re{d_i[n]} + - * Im{x_i[n]} * Im{d_i[n]}) / 2.0 This equation averages the error in - * the real and imaginary parts. There are two reasons we multiply by - * the signal itself. First, if the symbol could be positive or - * negative going, but we want the error term to always tell us to go - * in the same direction depending on which side of the zero point we - * are on. The sign of x_i[n] adjusts the error term to do - * this. Second, the magnitude of x_i[n] scales the error term - * depending on the symbol's amplitude, so larger signals give us a - * stronger error term because we have more confidence in that - * symbol's value. Using the magnitude of x_i[n] instead of just the - * sign is especially good for signals with low SNR. - * - * The error signal, e[n], gives us a value proportional to how far - * away from the zero point we are in the derivative signal. We want - * to drive this value to zero, so we set up a second order loop. We - * have two variables for this loop; d_k is the filter number in the - * filterbank we are on and d_rate is the rate which we travel through - * the filters in the steady state. That is, due to the natural clock - * differences between the transmitter and receiver, d_rate represents - * that difference and would traverse the filter phase paths to keep - * the receiver locked. Thinking of this as a second-order PLL, the - * d_rate is the frequency and d_k is the phase. So we update d_rate - * and d_k using the standard loop equations based on two error - * signals, d_alpha and d_beta. We have these two values set based on - * each other for a critically damped system, so in the block - * constructor, we just ask for "gain," which is d_alpha while d_beta - * is equal to (gain^2)/4. - * - * The block's parameters are: - * - * \li \p sps: The clock sync block needs to know the number of samples per - * symbol, because it defaults to return a single point representing - * the symbol. The sps can be any positive real number and does not - * need to be an integer. - * - * \li \p loop_bw: The loop bandwidth is used to set the gain of the - * inner control loop (see: - * http://gnuradio.squarespace.com/blog/2011/8/13/control-loop-gain-values.html). - * This should be set small (a value of around 2pi/100 is suggested in - * that blog post as the step size for the number of radians around - * the unit circle to move relative to the error). - * - * \li \p taps: One of the most important parameters for this block is - * the taps of the filter. One of the benefits of this algorithm is - * that you can put the matched filter in here as the taps, so you get - * both the matched filter and sample timing correction in one go. So - * create your normal matched filter. For a typical digital - * modulation, this is a root raised cosine filter. The number of taps - * of this filter is based on how long you expect the channel to be; - * that is, how many symbols do you want to combine to get the current - * symbols energy back (there's probably a better way of stating - * that). It's usually 5 to 10 or so. That gives you your filter, but - * now we need to think about it as a filter with different phase - * profiles in each filter. So take this number of taps and multiply - * it by the number of filters. This is the number you would use to - * create your prototype filter. When you use this in the PFB - * filerbank, it segments these taps into the filterbanks in such a - * way that each bank now represents the filter at different phases, - * equally spaced at 2pi/N, where N is the number of filters. - * - * \li \p filter_size (default=32): The number of filters can also be - * set and defaults to 32. With 32 filters, you get a good enough - * resolution in the phase to produce very small, almost unnoticeable, - * ISI. Going to 64 filters can reduce this more, but after that - * there is very little gained for the extra complexity. - * - * \li \p init_phase (default=0): The initial phase is another - * settable parameter and refers to the filter path the algorithm - * initially looks at (i.e., d_k starts at init_phase). This value - * defaults to zero, but it might be useful to start at a different - * phase offset, such as the mid-point of the filters. - * - * \li \p max_rate_deviation (default=1.5): The next parameter is the - * max_rate_devitation, which defaults to 1.5. This is how far we - * allow d_rate to swing, positive or negative, from 0. Constraining - * the rate can help keep the algorithm from walking too far away to - * lock during times when there is no signal. - * - * \li \p osps (default=1): The osps is the number of output samples per symbol. By default, - * the algorithm produces 1 sample per symbol, sampled at the exact - * sample value. This osps value was added to better work with - * equalizers, which do a better job of modeling the channel if they - * have 2 samps/sym. - */ - -class GR_CORE_API gr_pfb_clock_sync_ccf : public gr_block -{ - private: - /*! - * Build the polyphase filterbank timing synchronizer. - * \param sps (double) The number of samples per symbol in the incoming signal - * \param loop_bw (float) The bandwidth of the control loop; set's alpha and beta. - * \param taps (vector<int>) The filter taps. - * \param filter_size (uint) The number of filters in the filterbank (default = 32). - * \param init_phase (float) The initial phase to look at, or which filter to start - * with (default = 0). - * \param max_rate_deviation (float) Distance from 0 d_rate can get (default = 1.5). - * \param osps (int) The number of output samples per symbol (default=1). - * - */ - - friend GR_CORE_API gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps); - - bool d_updated; - double d_sps; - double d_sample_num; - float d_loop_bw; - float d_damping; - float d_alpha; - float d_beta; - - int d_nfilters; - int d_taps_per_filter; - std::vector<gr_fir_ccf*> d_filters; - std::vector<gr_fir_ccf*> d_diff_filters; - std::vector< std::vector<float> > d_taps; - std::vector< std::vector<float> > d_dtaps; - - float d_k; - float d_rate; - float d_rate_i; - float d_rate_f; - float d_max_dev; - int d_filtnum; - int d_osps; - float d_error; - int d_out_idx; - - /*! - * Build the polyphase filterbank timing synchronizer. - */ - gr_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps); - - void create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps); - -public: - ~gr_pfb_clock_sync_ccf (); - - /*! \brief update the system gains from omega and eta - * - * This function updates the system gains based on the loop - * bandwidth and damping factor of the system. - * These two factors can be set separately through their own - * set functions. - */ - void update_gains(); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - */ - void set_taps (const std::vector<float> &taps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_ccf*> &ourfilter); - - /*! - * Returns all of the taps of the matched filter - */ - std::vector< std::vector<float> > get_taps(); - - /*! - * Returns all of the taps of the derivative filter - */ - std::vector< std::vector<float> > get_diff_taps(); - - /*! - * Returns the taps of the matched filter for a particular channel - */ - std::vector<float> get_channel_taps(int channel); - - /*! - * Returns the taps in the derivative filter for a particular channel - */ - std::vector<float> get_diff_channel_taps(int channel); - - /*! - * Return the taps as a formatted string for printing - */ - std::string get_taps_as_string(); - - /*! - * Return the derivative filter taps as a formatted string for printing - */ - std::string get_diff_taps_as_string(); - - - /******************************************************************* - SET FUNCTIONS - *******************************************************************/ - - - /*! - * \brief Set the loop bandwidth - * - * Set the loop filter's bandwidth to \p bw. This should be between - * 2*pi/200 and 2*pi/100 (in rads/samp). It must also be a positive - * number. - * - * When a new damping factor is set, the gains, alpha and beta, of the loop - * are recalculated by a call to update_gains(). - * - * \param bw (float) new bandwidth - * - */ - void set_loop_bandwidth(float bw); - - /*! - * \brief Set the loop damping factor - * - * Set the loop filter's damping factor to \p df. The damping factor - * should be sqrt(2)/2.0 for critically damped systems. - * Set it to anything else only if you know what you are doing. It must - * be a number between 0 and 1. - * - * When a new damping factor is set, the gains, alpha and beta, of the loop - * are recalculated by a call to update_gains(). - * - * \param df (float) new damping factor - * - */ - void set_damping_factor(float df); - - /*! - * \brief Set the loop gain alpha - * - * Set's the loop filter's alpha gain parameter. - * - * This value should really only be set by adjusting the loop bandwidth - * and damping factor. - * - * \param alpha (float) new alpha gain - * - */ - void set_alpha(float alpha); - - /*! - * \brief Set the loop gain beta - * - * Set's the loop filter's beta gain parameter. - * - * This value should really only be set by adjusting the loop bandwidth - * and damping factor. - * - * \param beta (float) new beta gain - * - */ - void set_beta(float beta); - - /*! - * Set the maximum deviation from 0 d_rate can have - */ - void set_max_rate_deviation(float m) - { - d_max_dev = m; - } - - /******************************************************************* - GET FUNCTIONS - *******************************************************************/ - - /*! - * \brief Returns the loop bandwidth - */ - float get_loop_bandwidth() const; - - /*! - * \brief Returns the loop damping factor - */ - float get_damping_factor() const; - - /*! - * \brief Returns the loop gain alpha - */ - float get_alpha() const; - - /*! - * \brief Returns the loop gain beta - */ - float get_beta() const; - - /*! - * \brief Returns the current clock rate - */ - float get_clock_rate() const; - - /******************************************************************* - *******************************************************************/ - - bool check_topology(int ninputs, int noutputs); - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i deleted file mode 100644 index 85915196f8..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_clock_sync_ccf); - -gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size=32, - float init_phase=0, - float max_rate_deviation=1.5, - int osps=1); - -class gr_pfb_clock_sync_ccf : public gr_block -{ - private: - gr_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps); - - public: - ~gr_pfb_clock_sync_ccf (); - - void set_taps (const std::vector<float> &taps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_ccf*> &ourfilter); - - std::vector< std::vector<float> > get_taps(); - std::vector< std::vector<float> > get_diff_taps(); - std::vector<float> get_channel_taps(int channel); - std::vector<float> get_diff_channel_taps(int channel); - std::string get_taps_as_string(); - std::string get_diff_taps_as_string(); - - void set_loop_bandwidth(float bw); - void set_damping_factor(float df); - void set_alpha(float alpha); - void set_beta(float beta); - void set_max_rate_deviation(float m); - - float get_loop_bandwidth() const; - float get_damping_factor() const; - float get_alpha() const; - float get_beta() const; - float get_clock_rate() const; -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.cc b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.cc deleted file mode 100644 index 886f989130..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.cc +++ /dev/null @@ -1,288 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <cstdio> -#include <cmath> - -#include <gr_pfb_clock_sync_fff.h> -#include <gr_fir_fff.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <gr_math.h> - -gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation) -{ - return gnuradio::get_initial_sptr(new gr_pfb_clock_sync_fff (sps, gain, taps, - filter_size, - init_phase, - max_rate_deviation)); -} - -static int ios[] = {sizeof(float), sizeof(float), sizeof(float), sizeof(float)}; -static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); -gr_pfb_clock_sync_fff::gr_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation) - : gr_block ("pfb_clock_sync_fff", - gr_make_io_signature (1, 1, sizeof(float)), - gr_make_io_signaturev (1, 4, iosig)), - d_updated (false), d_nfilters(filter_size), - d_max_dev(max_rate_deviation) -{ - d_nfilters = filter_size; - d_sps = floor(sps); - - // Store the last filter between calls to work - // The accumulator keeps track of overflow to increment the stride correctly. - // set it here to the fractional difference based on the initial phaes - set_alpha(gain); - set_beta(0.25*gain*gain); - d_k = init_phase; - d_rate = (sps-floor(sps))*(double)d_nfilters; - d_rate_i = (int)floor(d_rate); - d_rate_f = d_rate - (float)d_rate_i; - d_filtnum = (int)floor(d_k); - - d_filters = std::vector<gr_fir_fff*>(d_nfilters); - d_diff_filters = std::vector<gr_fir_fff*>(d_nfilters); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_nfilters); - for(int i = 0; i < d_nfilters; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); - d_diff_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); - } - - // Now, actually set the filters' taps - std::vector<float> dtaps; - create_diff_taps(taps, dtaps); - set_taps(taps, d_taps, d_filters); - set_taps(dtaps, d_dtaps, d_diff_filters); -} - -gr_pfb_clock_sync_fff::~gr_pfb_clock_sync_fff () -{ - for(int i = 0; i < d_nfilters; i++) { - delete d_filters[i]; - delete d_diff_filters[i]; - } -} - -bool -gr_pfb_clock_sync_fff::check_topology(int ninputs, int noutputs) -{ - return noutputs == 1 || noutputs == 4; -} - -void -gr_pfb_clock_sync_fff::set_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_fff*> &ourfilter) -{ - int i,j; - - unsigned int ntaps = newtaps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_nfilters); - - // Create d_numchan vectors to store each channel's taps - ourtaps.resize(d_nfilters); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = newtaps; - while((float)(tmp_taps.size()) < d_nfilters*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_nfilters; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - ourtaps[d_nfilters-1-i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - ourtaps[d_nfilters - 1 - i][j] = tmp_taps[i + j*d_nfilters]; - } - - // Build a filter for each channel and add it's taps to it - ourfilter[i]->set_taps(ourtaps[d_nfilters-1-i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter + d_sps); - - d_updated = true; -} - -void -gr_pfb_clock_sync_fff::create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps) -{ - float maxtap = 1e-20; - difftaps.clear(); - difftaps.push_back(0); //newtaps[0]); - for(unsigned int i = 1; i < newtaps.size()-1; i++) { - float tap = newtaps[i+1] - newtaps[i-1]; - difftaps.push_back(tap); - if(tap > maxtap) { - maxtap = tap; - } - } - difftaps.push_back(0);//-newtaps[newtaps.size()-1]); - - // Scale the differential taps; helps scale error term to better update state - // FIXME: should this be scaled this way or use the same gain as the taps? - for(unsigned int i = 0; i < difftaps.size(); i++) { - difftaps[i] /= maxtap; - } -} - -void -gr_pfb_clock_sync_fff::print_taps() -{ - int i, j; - printf("[ "); - for(i = 0; i < d_nfilters; i++) { - printf("[%.4e, ", d_taps[i][0]); - for(j = 1; j < d_taps_per_filter-1; j++) { - printf("%.4e,", d_taps[i][j]); - } - printf("%.4e],", d_taps[i][j]); - } - printf(" ]\n"); -} - -void -gr_pfb_clock_sync_fff::print_diff_taps() -{ - int i, j; - printf("[ "); - for(i = 0; i < d_nfilters; i++) { - printf("[%.4e, ", d_dtaps[i][0]); - for(j = 1; j < d_taps_per_filter-1; j++) { - printf("%.4e,", d_dtaps[i][j]); - } - printf("%.4e],", d_dtaps[i][j]); - } - printf(" ]\n"); -} - - -std::vector<float> -gr_pfb_clock_sync_fff::channel_taps(int channel) -{ - std::vector<float> taps; - for(int i = 0; i < d_taps_per_filter; i++) { - taps.push_back(d_taps[channel][i]); - } - return taps; -} - -std::vector<float> -gr_pfb_clock_sync_fff::diff_channel_taps(int channel) -{ - std::vector<float> taps; - for(int i = 0; i < d_taps_per_filter; i++) { - taps.push_back(d_dtaps[channel][i]); - } - return taps; -} - - -int -gr_pfb_clock_sync_fff::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *in = (float *) input_items[0]; - float *out = (float *) output_items[0]; - - float *err = 0, *outrate = 0, *outk = 0; - if(output_items.size() == 4) { - err = (float *) output_items[1]; - outrate = (float*)output_items[2]; - outk = (float*)output_items[3]; - } - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - // We need this many to process one output - int nrequired = ninput_items[0] - d_taps_per_filter; - - int i = 0, count = 0; - float error; - - // produce output as long as we can and there are enough input samples - while((i < noutput_items) && (count < nrequired)) { - d_filtnum = (int)floor(d_k); - - // Keep the current filter number in [0, d_nfilters] - // If we've run beyond the last filter, wrap around and go to next sample - // If we've go below 0, wrap around and go to previous sample - while(d_filtnum >= d_nfilters) { - d_k -= d_nfilters; - d_filtnum -= d_nfilters; - count += 1; - } - while(d_filtnum < 0) { - d_k += d_nfilters; - d_filtnum += d_nfilters; - count -= 1; - } - - out[i] = d_filters[d_filtnum]->filter(&in[count]); - float diff = d_diff_filters[d_filtnum]->filter(&in[count]); - error = out[i] * diff; - - // Run the control loop to update the current phase (k) and tracking rate - d_k = d_k + d_alpha*error + d_rate_i + d_rate_f; - d_rate_f = d_rate_f + d_beta*error; - - // Keep our rate within a good range - d_rate_f = gr_branchless_clip(d_rate_f, d_max_dev); - - i++; - count += (int)floor(d_sps); - - if(output_items.size() == 4) { - err[i] = error; - outrate[i] = d_rate_f; - outk[i] = d_k; - } - } - consume_each(count); - - return i; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h deleted file mode 100644 index 4909d556b9..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h +++ /dev/null @@ -1,266 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef INCLUDED_GR_PFB_CLOCK_SYNC_FFF_H -#define INCLUDED_GR_PFB_CLOCK_SYNC_FFF_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_pfb_clock_sync_fff; -typedef boost::shared_ptr<gr_pfb_clock_sync_fff> gr_pfb_clock_sync_fff_sptr; -GR_CORE_API gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size=32, - float init_phase=0, - float max_rate_deviation=1.5); - -class gr_fir_fff; - -/*! - * \class gr_pfb_clock_sync_fff - * - * \brief Timing synchronizer using polyphase filterbanks - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block performs timing synchronization for PAM signals by - * minimizing the derivative of the filtered signal, which in turn - * maximizes the SNR and minimizes ISI. - * - * This approach works by setting up two filterbanks; one filterbank - * contains the signal's pulse shaping matched filter (such as a root - * raised cosine filter), where each branch of the filterbank contains - * a different phase of the filter. The second filterbank contains - * the derivatives of the filters in the first filterbank. Thinking of - * this in the time domain, the first filterbank contains filters that - * have a sinc shape to them. We want to align the output signal to be - * sampled at exactly the peak of the sinc shape. The derivative of - * the sinc contains a zero at the maximum point of the sinc (sinc(0) - * = 1, sinc(0)' = 0). Furthermore, the region around the zero point - * is relatively linear. We make use of this fact to generate the - * error signal. - * - * If the signal out of the derivative filters is d_i[n] for the ith - * filter, and the output of the matched filter is x_i[n], we - * calculate the error as: e[n] = (Re{x_i[n]} * Re{d_i[n]} + - * Im{x_i[n]} * Im{d_i[n]}) / 2.0 This equation averages the error in - * the real and imaginary parts. There are two reasons we multiply by - * the signal itself. First, if the symbol could be positive or - * negative going, but we want the error term to always tell us to go - * in the same direction depending on which side of the zero point we - * are on. The sign of x_i[n] adjusts the error term to do - * this. Second, the magnitude of x_i[n] scales the error term - * depending on the symbol's amplitude, so larger signals give us a - * stronger error term because we have more confidence in that - * symbol's value. Using the magnitude of x_i[n] instead of just the - * sign is especially good for signals with low SNR. - * - * The error signal, e[n], gives us a value proportional to how far - * away from the zero point we are in the derivative signal. We want - * to drive this value to zero, so we set up a second order loop. We - * have two variables for this loop; d_k is the filter number in the - * filterbank we are on and d_rate is the rate which we travel through - * the filters in the steady state. That is, due to the natural clock - * differences between the transmitter and receiver, d_rate represents - * that difference and would traverse the filter phase paths to keep - * the receiver locked. Thinking of this as a second-order PLL, the - * d_rate is the frequency and d_k is the phase. So we update d_rate - * and d_k using the standard loop equations based on two error - * signals, d_alpha and d_beta. We have these two values set based on - * each other for a critically damped system, so in the block - * constructor, we just ask for "gain," which is d_alpha while d_beta - * is equal to (gain^2)/4. - * - * The block's parameters are: - * - * \li \p sps: The clock sync block needs to know the number of samples per - * symbol, because it defaults to return a single point representing - * the symbol. The sps can be any positive real number and does not - * need to be an integer. - * - * \li \p loop_bw: The loop bandwidth is used to set the gain of the - * inner control loop (see: - * http://gnuradio.squarespace.com/blog/2011/8/13/control-loop-gain-values.html). - * This should be set small (a value of around 2pi/100 is suggested in - * that blog post as the step size for the number of radians around - * the unit circle to move relative to the error). - * - * \li \p taps: One of the most important parameters for this block is - * the taps of the filter. One of the benefits of this algorithm is - * that you can put the matched filter in here as the taps, so you get - * both the matched filter and sample timing correction in one go. So - * create your normal matched filter. For a typical digital - * modulation, this is a root raised cosine filter. The number of taps - * of this filter is based on how long you expect the channel to be; - * that is, how many symbols do you want to combine to get the current - * symbols energy back (there's probably a better way of stating - * that). It's usually 5 to 10 or so. That gives you your filter, but - * now we need to think about it as a filter with different phase - * profiles in each filter. So take this number of taps and multiply - * it by the number of filters. This is the number you would use to - * create your prototype filter. When you use this in the PFB - * filerbank, it segments these taps into the filterbanks in such a - * way that each bank now represents the filter at different phases, - * equally spaced at 2pi/N, where N is the number of filters. - * - * \li \p filter_size (default=32): The number of filters can also be - * set and defaults to 32. With 32 filters, you get a good enough - * resolution in the phase to produce very small, almost unnoticeable, - * ISI. Going to 64 filters can reduce this more, but after that - * there is very little gained for the extra complexity. - * - * \li \p init_phase (default=0): The initial phase is another - * settable parameter and refers to the filter path the algorithm - * initially looks at (i.e., d_k starts at init_phase). This value - * defaults to zero, but it might be useful to start at a different - * phase offset, such as the mid-point of the filters. - * - * \li \p max_rate_deviation (default=1.5): The next parameter is the - * max_rate_devitation, which defaults to 1.5. This is how far we - * allow d_rate to swing, positive or negative, from 0. Constraining - * the rate can help keep the algorithm from walking too far away to - * lock during times when there is no signal. - * - * \li \p osps: note that unlike the ccf version of this algorithm, - * this block does \a not have a setting for the number of output - * samples per symbol. This is mostly because it should not be - * necessary as the reason for having multiple output sps is to - * perform equalization and the equalizers will take in complex - * numbers in order to do magnitude and phase correction. - */ - -class GR_CORE_API gr_pfb_clock_sync_fff : public gr_block -{ - private: - /*! - * Build the polyphase filterbank timing synchronizer. - * \param sps (double) The number of samples per second in the incoming signal - * \param gain (float) The alpha gain of the control loop; beta = (gain^2)/4 by default. - * \param taps (vector<int>) The filter taps. - * \param filter_size (uint) The number of filters in the filterbank (default = 32). - * \param init_phase (float) The initial phase to look at, or which filter to start - * with (default = 0). - * \param max_rate_deviation (float) Distance from 0 d_rate can get (default = 1.5). - * - */ - friend GR_CORE_API gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation); - - bool d_updated; - double d_sps; - double d_sample_num; - float d_alpha; - float d_beta; - int d_nfilters; - std::vector<gr_fir_fff*> d_filters; - std::vector<gr_fir_fff*> d_diff_filters; - std::vector< std::vector<float> > d_taps; - std::vector< std::vector<float> > d_dtaps; - float d_k; - float d_rate; - float d_rate_i; - float d_rate_f; - float d_max_dev; - int d_filtnum; - int d_taps_per_filter; - - /*! - * Build the polyphase filterbank timing synchronizer. - */ - gr_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation); - - void create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps); - -public: - ~gr_pfb_clock_sync_fff (); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - */ - void set_taps (const std::vector<float> &taps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_fff*> &ourfilter); - - /*! - * Returns the taps of the matched filter - */ - std::vector<float> channel_taps(int channel); - - /*! - * Returns the taps in the derivative filter - */ - std::vector<float> diff_channel_taps(int channel); - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - - /*! - * Print all of the filterbank taps of the derivative filter to screen. - */ - void print_diff_taps(); - - /*! - * Set the gain value alpha for the control loop - */ - void set_alpha(float alpha) - { - d_alpha = alpha; - } - - /*! - * Set the gain value beta for the control loop - */ - void set_beta(float beta) - { - d_beta = beta; - } - - /*! - * Set the maximum deviation from 0 d_rate can have - */ - void set_max_rate_deviation(float m) - { - d_max_dev = m; - } - - bool check_topology(int ninputs, int noutputs); - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.i b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.i deleted file mode 100644 index 754af1a87f..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.i +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_clock_sync_fff); - -gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size=32, - float init_phase=0, - float max_rate_deviation=1.5); - -class gr_pfb_clock_sync_fff : public gr_block -{ - private: - gr_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation); - - public: - ~gr_pfb_clock_sync_fff (); - - void set_taps (const std::vector<float> &taps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_fff*> &ourfilter); - - std::vector<float> channel_taps(int channel); - std::vector<float> diff_channel_taps(int channel); - void print_taps(); - void print_diff_taps(); - void set_alpha(float alpha); - void set_beta(float beta); - void set_max_rate_deviation(float m); -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc deleted file mode 100644 index e563daa513..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc +++ /dev/null @@ -1,176 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pfb_decimator_ccf.h> -#include <gr_fir_ccf.h> -#include <gr_fir_util.h> -#include <gri_fft.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <cstdio> - -gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel) -{ - return gnuradio::get_initial_sptr(new gr_pfb_decimator_ccf (decim, taps, channel)); -} - - -gr_pfb_decimator_ccf::gr_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel) - : gr_sync_block ("pfb_decimator_ccf", - gr_make_io_signature (decim, decim, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex))), - d_updated (false) -{ - d_rate = decim; - d_filters = std::vector<gr_fir_ccf*>(d_rate); - d_chan = channel; - d_rotator = new gr_complex[d_rate]; - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_rate); - for(unsigned int i = 0; i < d_rate; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - d_rotator[i] = gr_expj(i*2*M_PI*d_chan/d_rate); - } - - // Now, actually set the filters' taps - set_taps(taps); - - // Create the FFT to handle the output de-spinning of the channels - d_fft = new gri_fft_complex (d_rate, false); -} - -gr_pfb_decimator_ccf::~gr_pfb_decimator_ccf () -{ - delete d_fft; - for(unsigned int i = 0; i < d_rate; i++) { - delete d_filters[i]; - } -} - -void -gr_pfb_decimator_ccf::set_taps (const std::vector<float> &taps) -{ - unsigned int i,j; - - unsigned int ntaps = taps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_rate); - - // Create d_numchan vectors to store each channel's taps - d_taps.resize(d_rate); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = taps; - while((float)(tmp_taps.size()) < d_rate*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_rate; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - d_taps[i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - d_taps[i][j] = tmp_taps[i + j*d_rate]; // add taps to channels in reverse order - } - - // Build a filter for each channel and add it's taps to it - d_filters[i]->set_taps(d_taps[i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter); - - d_updated = true; -} - -void -gr_pfb_decimator_ccf::print_taps() -{ - unsigned int i, j; - for(i = 0; i < d_rate; i++) { - printf("filter[%d]: [", i); - for(j = 0; j < d_taps_per_filter; j++) { - printf(" %.4e", d_taps[i][j]); - } - printf("]\n\n"); - } -} - -#define ROTATEFFT - -int -gr_pfb_decimator_ccf::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in; - gr_complex *out = (gr_complex *) output_items[0]; - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - int i; - for(i = 0; i < noutput_items; i++) { - // Move through filters from bottom to top - out[i] = 0; - for(int j = d_rate-1; j >= 0; j--) { - // Take in the items from the first input stream to d_rate - in = (gr_complex*)input_items[d_rate - 1 - j]; - - // Filter current input stream from bottom filter to top - // The rotate them by expj(j*k*2pi/M) where M is the number of filters - // (the decimation rate) and k is the channel number to extract - - // This is the real math that goes on; we abuse the FFT to do this quickly - // for decimation rates > N where N is a small number (~5): - // out[i] += d_filters[j]->filter(&in[i])*gr_expj(j*d_chan*2*M_PI/d_rate); -#ifdef ROTATEFFT - d_fft->get_inbuf()[j] = d_filters[j]->filter(&in[i]); -#else - out[i] += d_filters[j]->filter(&in[i])*d_rotator[i]; -#endif - } - -#ifdef ROTATEFFT - // Perform the FFT to do the complex multiply despinning for all channels - d_fft->execute(); - - // Select only the desired channel out - out[i] = d_fft->get_outbuf()[d_chan]; -#endif - - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h deleted file mode 100644 index a2b347ae24..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef INCLUDED_GR_PFB_DECIMATOR_CCF_H -#define INCLUDED_GR_PFB_DECIMATOR_CCF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_pfb_decimator_ccf; -typedef boost::shared_ptr<gr_pfb_decimator_ccf> gr_pfb_decimator_ccf_sptr; -GR_CORE_API gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel=0); - -class gr_fir_ccf; -class gri_fft_complex; - -/*! - * \class gr_pfb_decimator_ccf - * \brief Polyphase filterbank bandpass decimator with gr_complex - * input, gr_complex output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block takes in a signal stream and performs interger down- - * sampling (decimation) with a polyphase filterbank. The first input - * is the integer specifying how much to decimate by. The second - * input is a vector (Python list) of floating-point taps of the - * prototype filter. The third input specifies the channel to extract. - * By default, the zeroth channel is used, which is the baseband - * channel (first Nyquist zone). - * - * The <EM>channel</EM> parameter specifies which channel to use since - * this class is capable of bandpass decimation. Given a complex input - * stream at a sampling rate of <EM>fs</EM> and a decimation rate of - * <EM>decim</EM>, the input frequency domain is split into - * <EM>decim</EM> channels that represent the Nyquist zones. Using the - * polyphase filterbank, we can select any one of these channels to - * decimate. - * - * The output signal will be the basebanded and decimated signal from - * that channel. This concept is very similar to the PFB channelizer - * (see #gr_pfb_channelizer_ccf) where only a single channel is - * extracted at a time. - * - * The filter's taps should be based on the sampling rate before - * decimation. - * - * For example, using the GNU Radio's firdes utility to building - * filters, we build a low-pass filter with a sampling rate of - * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition - * bandwidth of <EM>TB</EM>. We can also specify the out-of-band - * attenuation to use, <EM>ATT</EM>, and the filter window - * function (a Blackman-harris window in this case). The first input - * is the gain of the filter, which we specify here as unity. - * - * <B><EM>self._taps = gr.firdes.low_pass_2(1, fs, BW, TB, - * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B> - * - * The PFB decimator code takes the taps generated above and builds a - * set of filters. The set contains <EM>decim</EM> number of filters - * and each filter contains ceil(taps.size()/decim) number of taps. - * Each tap from the filter prototype is sequentially inserted into - * the next filter. When all of the input taps are used, the remaining - * filters in the filterbank are filled out with 0's to make sure each - * filter has the same number of taps. - * - * The theory behind this block can be found in Chapter 6 of - * the following book. - * - * <B><EM>f. harris, "Multirate Signal Processing for Communication - * Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B> - */ - -class GR_CORE_API gr_pfb_decimator_ccf : public gr_sync_block -{ - private: - /*! - * Build the polyphase filterbank decimator. - * \param decim (unsigned integer) Specifies the decimation rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. - * \param channel (unsigned integer) Selects the channel to return [default=0]. - */ - friend GR_CORE_API gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel); - - std::vector<gr_fir_ccf*> d_filters; - std::vector< std::vector<float> > d_taps; - gri_fft_complex *d_fft; - unsigned int d_rate; - unsigned int d_chan; - unsigned int d_taps_per_filter; - bool d_updated; - gr_complex *d_rotator; - - /*! - * Build the polyphase filterbank decimator. - * \param decim (unsigned integer) Specifies the decimation rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. - * \param channel (unsigned integer) Selects the channel to return [default=0]. - */ - gr_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel); - -public: - ~gr_pfb_decimator_ccf (); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. - */ - void set_taps (const std::vector<float> &taps); - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - - //void set_channel (unsigned int channel); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.i deleted file mode 100644 index e40d00fa9d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.i +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_decimator_ccf); - -gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel); - -class gr_pfb_decimator_ccf : public gr_sync_block -{ - private: - gr_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel); - - public: - ~gr_pfb_decimator_ccf (); - - void set_taps (const std::vector<float> &taps); - //void set_channel (unsigned int channel); -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc deleted file mode 100644 index 9c8e734ea9..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pfb_interpolator_ccf.h> -#include <gr_fir_ccf.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <cstdio> - -gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps) -{ - return gnuradio::get_initial_sptr(new gr_pfb_interpolator_ccf (interp, taps)); -} - - -gr_pfb_interpolator_ccf::gr_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps) - : gr_sync_interpolator ("pfb_interpolator_ccf", - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - interp), - d_updated (false) -{ - d_rate = interp; - d_filters = std::vector<gr_fir_ccf*>(d_rate); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_rate); - for(unsigned int i = 0; i < d_rate; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - } - - // Now, actually set the filters' taps - set_taps(taps); -} - -gr_pfb_interpolator_ccf::~gr_pfb_interpolator_ccf () -{ - for(unsigned int i = 0; i < d_rate; i++) { - delete d_filters[i]; - } -} - -void -gr_pfb_interpolator_ccf::set_taps (const std::vector<float> &taps) -{ - unsigned int i,j; - - unsigned int ntaps = taps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_rate); - - // Create d_numchan vectors to store each channel's taps - //std::vector< std::vector<float> > vtaps(d_rate); - d_taps.resize(d_rate); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = taps; - while((float)(tmp_taps.size()) < d_rate*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_rate; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - d_taps[i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - d_taps[i][j] = tmp_taps[i + j*d_rate]; // add taps to channels in reverse order - } - - // Build a filter for each channel and add it's taps to it - d_filters[i]->set_taps(d_taps[i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter); - - d_updated = true; -} - -void -gr_pfb_interpolator_ccf::print_taps() -{ - unsigned int i, j; - for(i = 0; i < d_rate; i++) { - printf("filter[%d]: [", i); - for(j = 0; j < d_taps_per_filter; j++) { - printf(" %.4e", d_taps[i][j]); - } - printf("]\n\n"); - } -} - -int -gr_pfb_interpolator_ccf::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - int i = 0, count = 0; - - while(i < noutput_items) { - for(unsigned int j = 0; j < d_rate; j++) { - out[i] = d_filters[j]->filter(&in[count]); - i++; - } - count++; - } - - return i; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h deleted file mode 100644 index aeae86e408..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef INCLUDED_GR_PFB_INTERPOLATOR_CCF_H -#define INCLUDED_GR_PFB_INTERPOLATOR_CCF_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_pfb_interpolator_ccf; -typedef boost::shared_ptr<gr_pfb_interpolator_ccf> gr_pfb_interpolator_ccf_sptr; -GR_CORE_API gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps); - -class gr_fir_ccf; - -/*! - * \class gr_pfb_interpolator_ccf - * \brief Polyphase filterbank interpolator with gr_complex input, - * gr_complex output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block takes in a signal stream and performs interger up- - * sampling (interpolation) with a polyphase filterbank. The first - * input is the integer specifying how much to interpolate by. The - * second input is a vector (Python list) of floating-point taps of - * the prototype filter. - * - * The filter's taps should be based on the interpolation rate - * specified. That is, the bandwidth specified is relative to the - * bandwidth after interpolation. - * - * For example, using the GNU Radio's firdes utility to building - * filters, we build a low-pass filter with a sampling rate of - * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition - * bandwidth of <EM>TB</EM>. We can also specify the out-of-band - * attenuation to use, ATT, and the filter window function (a - * Blackman-harris window in this case). The first input is the gain, - * which is also specified as the interpolation rate so that the - * output levels are the same as the input (this creates an overall - * increase in power). - * - * <B><EM>self._taps = gr.firdes.low_pass_2(interp, interp*fs, BW, TB, - * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B> - * - * The PFB interpolator code takes the taps generated above and builds - * a set of filters. The set contains <EM>interp</EM> number of - * filters and each filter contains ceil(taps.size()/interp) number of - * taps. Each tap from the filter prototype is sequentially inserted - * into the next filter. When all of the input taps are used, the - * remaining filters in the filterbank are filled out with 0's to make - * sure each filter has the same number of taps. - * - * The theory behind this block can be found in Chapter 7.1 of the - * following book. - * - * <B><EM>f. harris, "Multirate Signal Processing for Communication - * Systems</EM>," Upper Saddle River, NJ: Prentice Hall, - * Inc. 2004.</EM></B> - */ - -class GR_CORE_API gr_pfb_interpolator_ccf : public gr_sync_interpolator -{ - private: - /*! - * Build the polyphase filterbank interpolator. - * \param interp (unsigned integer) Specifies the interpolation rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the interpolated sampling rate. - */ - friend GR_CORE_API gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps); - - std::vector<gr_fir_ccf*> d_filters; - std::vector< std::vector<float> > d_taps; - unsigned int d_rate; - unsigned int d_taps_per_filter; - bool d_updated; - - /*! - * Construct a Polyphase filterbank interpolator - * \param interp (unsigned integer) Specifies the interpolation rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the interpolated sampling rate. - */ - gr_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps); - -public: - ~gr_pfb_interpolator_ccf (); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the interpolated sampling rate. - */ - void set_taps (const std::vector<float> &taps); - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.i deleted file mode 100644 index 427f1b913d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_interpolator_ccf); - -gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps); - -class gr_pfb_interpolator_ccf : public gr_sync_interpolator -{ - private: - gr_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps); - - public: - ~gr_pfb_interpolator_ccf (); - - void set_taps (const std::vector<float> &taps); - void print_taps(); -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc deleted file mode 100644 index cd01aaff5c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc +++ /dev/null @@ -1,287 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pfb_synthesizer_ccf.h> -#include <gri_fft.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <cstring> - -gr_pfb_synthesizer_ccf_sptr gr_make_pfb_synthesizer_ccf - (unsigned int numchans, const std::vector<float> &taps, bool twox) -{ - return gr_pfb_synthesizer_ccf_sptr - (new gr_pfb_synthesizer_ccf (numchans, taps, twox)); -} - - -gr_pfb_synthesizer_ccf::gr_pfb_synthesizer_ccf - (unsigned int numchans, const std::vector<float> &taps, bool twox) - : gr_sync_interpolator ("pfb_synthesizer_ccf", - gr_make_io_signature (1, numchans, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - numchans), - d_updated (false), d_numchans(numchans), d_state(0) -{ - // set up 2x multiplier; if twox==True, set to 2, otherwise to 1 - d_twox = (twox ? 2 : 1); - if(d_numchans % d_twox != 0) { - throw std::invalid_argument("gr_pfb_synthesizer_ccf: number of channels must be even for 2x oversampling.\n"); - } - - d_filters = std::vector<gri_fir_filter_with_buffer_ccf*>(d_twox*d_numchans); - d_channel_map.resize(d_twox*d_numchans); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_twox*d_numchans); - for(unsigned int i = 0; i < d_twox*d_numchans; i++) { - d_filters[i] = new gri_fir_filter_with_buffer_ccf(vtaps); - d_channel_map[i] = i; - } - - // Now, actually set the filters' taps - set_taps(taps); - - // Create the IFFT to handle the input channel rotations - d_fft = new gri_fft_complex (d_twox*d_numchans, false); - memset(d_fft->get_inbuf(), 0, d_twox*d_numchans*sizeof(gr_complex)); - - set_output_multiple(d_numchans); -} - -gr_pfb_synthesizer_ccf::~gr_pfb_synthesizer_ccf () -{ - delete d_fft; - for(unsigned int i = 0; i < d_twox*d_numchans; i++) { - delete d_filters[i]; - } -} - -void -gr_pfb_synthesizer_ccf::set_taps(const std::vector<float> &taps) -{ - gruel::scoped_lock guard(d_mutex); - if(d_twox == 1) - set_taps1(taps); - else - set_taps2(taps); -} - -void -gr_pfb_synthesizer_ccf::set_taps1(const std::vector<float> &taps) -{ - unsigned int i,j; - - unsigned int ntaps = taps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_numchans); - - // Create d_numchan vectors to store each channel's taps - d_taps.resize(d_numchans); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = taps; - while((float)(tmp_taps.size()) < d_numchans*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_numchans; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - d_taps[i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - d_taps[i][j] = tmp_taps[i + j*d_numchans]; // add taps to channels in reverse order - } - - // Build a filter for each channel and add it's taps to it - d_filters[i]->set_taps(d_taps[i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter+1); - - d_updated = true; -} - -void -gr_pfb_synthesizer_ccf::set_taps2 (const std::vector<float> &taps) -{ - unsigned int i,j; - int state = 0; - - unsigned int ntaps = taps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_numchans); - - // Create d_numchan vectors to store each channel's taps - d_taps.resize(d_twox*d_numchans); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = taps; - while((float)(tmp_taps.size()) < d_numchans*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_numchans; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - d_taps[i] = std::vector<float>(d_taps_per_filter, 0); - d_taps[d_numchans+i] = std::vector<float>(d_taps_per_filter, 0); - state = 0; - for(j = 0; j < d_taps_per_filter; j++) { - // add taps to channels in reverse order - // Zero out every other tap - if(state == 0) { - d_taps[i][j] = tmp_taps[i + j*d_numchans]; - d_taps[d_numchans + i][j] = 0; - state = 1; - } - else { - d_taps[i][j] = 0; - d_taps[d_numchans + i][j] = tmp_taps[i + j*d_numchans]; - state = 0; - } - } - - // Build a filter for each channel and add it's taps to it - d_filters[i]->set_taps(d_taps[i]); - d_filters[d_numchans + i]->set_taps(d_taps[d_numchans + i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter+1); - - d_updated = true; -} - -void -gr_pfb_synthesizer_ccf::print_taps() -{ - unsigned int i, j; - for(i = 0; i < d_twox*d_numchans; i++) { - printf("filter[%d]: [", i); - for(j = 0; j < d_taps_per_filter; j++) { - printf(" %.4e", d_taps[i][j]); - } - printf("]\n\n"); - } -} - - -std::vector< std::vector<float> > -gr_pfb_synthesizer_ccf::taps() const -{ - return d_taps; -} - -void -gr_pfb_synthesizer_ccf::set_channel_map(const std::vector<int> &map) -{ - gruel::scoped_lock guard(d_mutex); - - if(map.size() > 0) { - unsigned int max = (unsigned int)*std::max_element(map.begin(), map.end()); - unsigned int min = (unsigned int)*std::min_element(map.begin(), map.end()); - if((max >= d_twox*d_numchans) || (min < 0)) { - throw std::invalid_argument("gr_pfb_synthesizer_ccf::set_channel_map: map range out of bounds.\n"); - } - d_channel_map = map; - - // Zero out fft buffer so that unused channels are always 0 - memset(d_fft->get_inbuf(), 0,d_twox*d_numchans*sizeof(gr_complex)); - } -} - -std::vector<int> -gr_pfb_synthesizer_ccf::channel_map() const -{ - return d_channel_map; -} - -int -gr_pfb_synthesizer_ccf::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gruel::scoped_lock guard(d_mutex); - - gr_complex *in = (gr_complex*) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - unsigned int n, i; - size_t ninputs = input_items.size(); - - // Algoritm for critically sampled channels - if(d_twox == 1) { - for(n = 0; n < noutput_items/d_numchans; n++) { - for(i = 0; i < ninputs; i++) { - in = (gr_complex*)input_items[i]; - d_fft->get_inbuf()[d_channel_map[i]] = in[n]; - } - - // spin through IFFT - d_fft->execute(); - - for(i = 0; i < d_numchans; i++) { - out[i] = d_filters[i]->filter(d_fft->get_outbuf()[i]); - } - out += d_numchans; - } - } - - // Algorithm for oversampling by 2x - else { - for(n = 0; n < noutput_items/d_numchans; n++) { - for(i = 0; i < ninputs; i++) { - in = (gr_complex*)input_items[i]; - d_fft->get_inbuf()[d_channel_map[i]] = in[n]; - } - - // spin through IFFT - d_fft->execute(); - - // Output is sum of two filters, but the input buffer to the filters must be circularly - // shifted by numchans every time through, done by using d_state to determine which IFFT - // buffer position to pull from. - for(i = 0; i < d_numchans; i++) { - out[i] = d_filters[i]->filter(d_fft->get_outbuf()[d_state*d_numchans+i]); - out[i] += d_filters[d_numchans+i]->filter(d_fft->get_outbuf()[(d_state^1)*d_numchans+i]); - } - d_state ^= 1; - - out += d_numchans; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.h deleted file mode 100644 index 9e4f85497d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.h +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef INCLUDED_GR_PFB_SYNTHESIZER_CCF_H -#define INCLUDED_GR_PFB_SYNTHESIZER_CCF_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> -#include <gri_fir_filter_with_buffer_ccf.h> -#include <gruel/thread.h> - -class gr_pfb_synthesizer_ccf; -typedef boost::shared_ptr<gr_pfb_synthesizer_ccf> gr_pfb_synthesizer_ccf_sptr; -GR_CORE_API gr_pfb_synthesizer_ccf_sptr gr_make_pfb_synthesizer_ccf - (unsigned int numchans, const std::vector<float> &taps, bool twox=false); - -class gri_fft_complex; - - -/*! - * \class gr_pfb_synthesizer_ccf - * - * \brief Polyphase synthesis filterbank with - * gr_complex input, gr_complex output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk - */ - -class GR_CORE_API gr_pfb_synthesizer_ccf : public gr_sync_interpolator -{ - private: - /*! - * Build the polyphase synthesis filterbank. - * \param numchans (unsigned integer) Specifies the number of - channels <EM>M</EM> - * \param taps (vector/list of floats) The prototype filter to - populate the filterbank. - * \param twox (bool) use 2x oversampling or not (default is no) - */ - friend GR_CORE_API gr_pfb_synthesizer_ccf_sptr gr_make_pfb_synthesizer_ccf - (unsigned int numchans, const std::vector<float> &taps, bool twox); - - bool d_updated; - unsigned int d_numchans; - unsigned int d_taps_per_filter; - gri_fft_complex *d_fft; - std::vector< gri_fir_filter_with_buffer_ccf*> d_filters; - std::vector< std::vector<float> > d_taps; - int d_state; - std::vector<int> d_channel_map; - unsigned int d_twox; - gruel::mutex d_mutex; // mutex to protect set/work access - - /*! - * \brief Tap setting algorithm for critically sampled channels - */ - void set_taps1(const std::vector<float> &taps); - - /*! - * \brief Tap setting algorithm for 2x over-sampled channels - */ - void set_taps2(const std::vector<float> &taps); - - /*! - * Build the polyphase synthesis filterbank. - * \param numchans (unsigned integer) Specifies the number of - channels <EM>M</EM> - * \param taps (vector/list of floats) The prototype filter - to populate the filterbank. - * \param twox (bool) use 2x oversampling or not (default is no) - */ - gr_pfb_synthesizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - bool twox); - -public: - ~gr_pfb_synthesizer_ccf (); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - * \param taps (vector/list of floats) The prototype filter to - populate the filterbank. - */ - void set_taps (const std::vector<float> &taps); - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - - /*! - * Return a vector<vector<>> of the filterbank taps - */ - std::vector<std::vector<float> > taps() const; - - /*! - * Set the channel map. Channels are numbers as: - * N/2+1 | ... | N-1 | 0 | 1 | 2 | ... | N/2 - * <------------------- 0 --------------------> - * freq - * - * So input stream 0 goes to channel 0, etc. Setting a new channel - * map allows the user to specify where in frequency he/she wants - * the input stream to go. This is especially useful to avoid - * putting signals into the channels on the edge of the spectrum - * which can either wrap around (in the case of odd number of - * channels) and be affected by filter rolloff in the transmitter. - * - * The map must be at least the number of streams being sent to the - * block. Less and the algorithm will not have enough data to - * properly setup the buffers. Any more channels specified will be - * ignored. - */ - void set_channel_map(const std::vector<int> &map); - - /*! - * Gets the current channel map. - */ - std::vector<int> channel_map() const; - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.i deleted file mode 100644 index c186ae355a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.i +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_synthesizer_ccf); - -gr_pfb_synthesizer_ccf_sptr gr_make_pfb_synthesizer_ccf - (unsigned int numchans, const std::vector<float> &taps, bool twox=false); - -class gr_pfb_synthesizer_ccf : public gr_sync_interpolator -{ - private: - gr_pfb_synthesizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - bool twox=false); - - public: - ~gr_pfb_synthesizer_ccf (); - - void set_taps (const std::vector<float> &taps); - void print_taps(); - std::vector< std::vector<float> > taps() const; - - void set_channel_map(const std::vector<int> &map); - std::vector<int> channel_map() const; -}; diff --git a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.cc.t deleted file mode 100644 index 445834dda0..0000000000 --- a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.cc.t +++ /dev/null @@ -1,172 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by - * generate_gr_rational_resampler_base_XXX.py Any changes made to this - * file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <@FIR_TYPE@.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <iostream> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (unsigned interpolation, - unsigned decimation, - const std::vector<@TAP_TYPE@> &taps) -{ - return gnuradio::get_initial_sptr (new @NAME@ (interpolation, decimation, taps)); -} - -@NAME@::@NAME@ (unsigned interpolation, unsigned decimation, - const std::vector<@TAP_TYPE@> &taps) - : gr_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_history(1), - d_interpolation(interpolation), d_decimation(decimation), - d_ctr(0), d_updated(false), - d_firs(interpolation) -{ - if (interpolation == 0) - throw std::out_of_range ("interpolation must be > 0"); - if (decimation == 0) - throw std::out_of_range ("decimation must be > 0"); - - set_relative_rate (1.0 * interpolation / decimation); - set_output_multiple (1); - - std::vector<@TAP_TYPE@> dummy_taps; - - for (unsigned i = 0; i < interpolation; i++) - d_firs[i] = gr_fir_util::create_@FIR_TYPE@ (dummy_taps); - - set_taps (taps); - install_taps (d_new_taps); -} - -@NAME@::~@NAME@ () -{ - int interp = interpolation(); - for (int i = 0; i < interp; i++) - delete d_firs[i]; -} - -void -@NAME@::set_taps (const std::vector<@TAP_TYPE@> &taps) -{ - d_new_taps = taps; - d_updated = true; - - // round up length to a multiple of the interpolation factor - int n = taps.size () % interpolation (); - if (n > 0){ - n = interpolation () - n; - while (n-- > 0) - d_new_taps.insert(d_new_taps.begin(), 0); - } - - assert (d_new_taps.size () % interpolation () == 0); -} - - -void -@NAME@::install_taps (const std::vector<@TAP_TYPE@> &taps) -{ - int nfilters = interpolation (); - int nt = taps.size () / nfilters; - - assert (nt * nfilters == (int) taps.size ()); - - std::vector< std::vector <@TAP_TYPE@> > xtaps (nfilters); - - for (int n = 0; n < nfilters; n++) - xtaps[n].resize (nt); - - for (int i = 0; i < (int) taps.size(); i++) - xtaps[i % nfilters][i / nfilters] = taps[i]; - - for (int n = 0; n < nfilters; n++) - d_firs[n]->set_taps (xtaps[n]); - - set_history (nt); - d_updated = false; - -#if 0 - for (int i = 0; i < nfilters; i++){ - std::cout << "filter[" << i << "] = "; - for (int j = 0; j < nt; j++) - std::cout << xtaps[i][j] << " "; - - std::cout << "\n"; - } -#endif - -} - -void -@NAME@::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - int nreqd = std::max((unsigned)1, (int)((double) (noutput_items+1) * decimation() / interpolation()) + history() - 1); - unsigned ninputs = ninput_items_required.size (); - for (unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = nreqd; -} - -int -@NAME@::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - - if (d_updated) { - install_taps (d_new_taps); - return 0; // history requirement may have increased. - } - - unsigned int ctr = d_ctr; - - int i = 0; - while (i < noutput_items){ - out[i++] = d_firs[ctr]->filter(in); - ctr += decimation(); - while (ctr >= interpolation()){ - ctr -= interpolation(); - in++; - } - } - - d_ctr = ctr; - consume_each(in - (@I_TYPE@ *) input_items[0]); - return i; -} diff --git a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t b/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t deleted file mode 100644 index 3eb85a9795..0000000000 --- a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by - * generate_gr_rational_resampler_base_XXX.py Any changes made to this - * file will be overwritten. - */ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -GR_CORE_API @SPTR_NAME@ -gr_make_@BASE_NAME@ (unsigned interpolation, - unsigned decimation, - const std::vector<@TAP_TYPE@> &taps); - -class @FIR_TYPE@; - -/*! - * \brief Rational Resampling Polyphase FIR filter with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_blk - */ -class GR_CORE_API @NAME@ : public gr_block -{ - private: - unsigned d_history; - unsigned d_interpolation, d_decimation; - unsigned d_ctr; - std::vector<@TAP_TYPE@> d_new_taps; - bool d_updated; - std::vector<@FIR_TYPE@ *> d_firs; - - friend GR_CORE_API @SPTR_NAME@ - gr_make_@BASE_NAME@ (unsigned interpolation, unsigned decimation, const std::vector<@TAP_TYPE@> &taps); - - - /*! - * Construct a FIR filter with the given taps - */ - @NAME@ (unsigned interpolation, unsigned decimation, - const std::vector<@TAP_TYPE@> &taps); - - void install_taps (const std::vector<@TAP_TYPE@> &taps); - - public: - ~@NAME@ (); - unsigned history () const { return d_history; } - void set_history (unsigned history) { d_history = history; } - - unsigned interpolation() const { return d_interpolation; } - unsigned decimation() const { return d_decimation; } - - void set_taps (const std::vector<@TAP_TYPE@> &taps); - - void forecast (int noutput_items, gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.i.t b/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.i.t deleted file mode 100644 index 1f789b0a35..0000000000 --- a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.i.t +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by - * generate_gr_rational_resampler_base_XXX.py Any changes made to this - * file will be overwritten. - */ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@SPTR_NAME@ gr_make_@BASE_NAME@ (int interpolation, int decimation, const std::vector<@TAP_TYPE@> &taps); - -class @NAME@ : public gr_block -{ - private: - @NAME@ (int interpolation, int decimation, const std::vector<@TAP_TYPE@> &taps); - - public: - ~@NAME@ (); - - void set_taps (const std::vector<@TAP_TYPE@> &taps); -}; diff --git a/gnuradio-core/src/lib/filter/gr_rotator.h b/gnuradio-core/src/lib/filter/gr_rotator.h index e31be6ee63..77946dd397 100644 --- a/gnuradio-core/src/lib/filter/gr_rotator.h +++ b/gnuradio-core/src/lib/filter/gr_rotator.h @@ -26,7 +26,7 @@ #include <gr_core_api.h> #include <gr_complex.h> -class GR_CORE_API gr_rotator { +class /*GR_CORE_API*/ gr_rotator { gr_complex d_phase; gr_complex d_phase_incr; unsigned int d_counter; diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir.h b/gnuradio-core/src/lib/filter/gr_single_pole_iir.h deleted file mode 100644 index d73ee857da..0000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir.h +++ /dev/null @@ -1,191 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GR_SINGLE_POLE_IIR_H_ -#define _GR_SINGLE_POLE_IIR_H_ - -#include <gr_core_api.h> -#include <stdexcept> -#include <gr_complex.h> -/*! - * \brief class template for single pole IIR filter - */ -template<class o_type, class i_type, class tap_type> -class gr_single_pole_iir { -public: - /*! - * \brief construct new single pole IIR with given alpha - * - * computes y(i) = (1-alpha) * y(i-1) + alpha * x(i) - */ - gr_single_pole_iir (tap_type alpha = 1.0) - { - d_prev_output = 0; - set_taps (alpha); - } - - /*! - * \brief compute a single output value. - * \returns the filtered input value. - */ - o_type filter (const i_type input); - - /*! - * \brief compute an array of N output values. - * \p input must have n valid entries. - */ - void filterN (o_type output[], const i_type input[], unsigned long n); - - /*! - * \brief install \p alpha as the current taps. - */ - void set_taps (tap_type alpha) - { - if (alpha < 0 || alpha > 1) - throw std::out_of_range ("Alpha must be in [0, 1]\n"); - - d_alpha = alpha; - d_one_minus_alpha = 1.0 - alpha; - } - - //! reset state to zero - void reset () - { - d_prev_output = 0; - } - - o_type prev_output () const { return d_prev_output; } - -protected: - tap_type d_alpha; - tap_type d_one_minus_alpha; - o_type d_prev_output; -}; - - -// -// general case. We may want to specialize this -// -template<class o_type, class i_type, class tap_type> -o_type -gr_single_pole_iir<o_type, i_type, tap_type>::filter (const i_type input) -{ - o_type output; - - output = d_alpha * input + d_one_minus_alpha * d_prev_output; - d_prev_output = output; - - return (o_type) output; -} - - -template<class o_type, class i_type, class tap_type> -void -gr_single_pole_iir<o_type, i_type, tap_type>::filterN (o_type output[], - const i_type input[], - unsigned long n) -{ - for (unsigned i = 0; i < n; i++) - output[i] = filter (input[i]); -} - - -// -// Specialized case for gr_complex output and double taps -// We need to have a gr_complexd type for the calculations and prev_output variable (in stead of double) - -template<class i_type> -class gr_single_pole_iir<gr_complex, i_type, double> { -public: - /*! - * \brief construct new single pole IIR with given alpha - * - * computes y(i) = (1-alpha) * y(i-1) + alpha * x(i) - */ - gr_single_pole_iir (double alpha = 1.0) - { - d_prev_output = 0; - set_taps (alpha); - } - - /*! - * \brief compute a single output value. - * \returns the filtered input value. - */ - gr_complex filter (const i_type input); - - /*! - * \brief compute an array of N output values. - * \p input must have n valid entries. - */ - void filterN (gr_complex output[], const i_type input[], unsigned long n); - - /*! - * \brief install \p alpha as the current taps. - */ - void set_taps (double alpha) - { - if (alpha < 0 || alpha > 1) - throw std::out_of_range ("Alpha must be in [0, 1]\n"); - - d_alpha = alpha; - d_one_minus_alpha = 1.0 - alpha; - } - - //! reset state to zero - void reset () - { - d_prev_output = 0; - } - - gr_complexd prev_output () const { return d_prev_output; } - -protected: - double d_alpha; - double d_one_minus_alpha; - gr_complexd d_prev_output; -}; - -template< class i_type> -gr_complex -gr_single_pole_iir<gr_complex, i_type, double>::filter (const i_type input) -{ - gr_complexd output; - - output = d_alpha * (gr_complexd)input + d_one_minus_alpha * d_prev_output; - d_prev_output = output; - - return (gr_complex) output; -} - -//Do we need to specialize this, although it is the same as the general case? - -template<class i_type> -void -gr_single_pole_iir<gr_complex, i_type, double>::filterN (gr_complex output[], - const i_type input[], - unsigned long n) -{ - for (unsigned i = 0; i < n; i++) - output[i] = filter (input[i]); -} - -#endif /* _GR_SINGLE_POLE_IIR_H_ */ diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.cc b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.cc deleted file mode 100644 index ae4f654dda..0000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_single_pole_iir_filter_cc.h> -#include <gr_io_signature.h> -#include <stdio.h> - - -gr_single_pole_iir_filter_cc_sptr -gr_make_single_pole_iir_filter_cc (double alpha, unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_single_pole_iir_filter_cc(alpha, vlen)); -} - -gr_single_pole_iir_filter_cc::gr_single_pole_iir_filter_cc ( - double alpha, unsigned int vlen) - : gr_sync_block ("single_pole_iir_filter_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen)), - d_vlen(vlen), d_iir(vlen) -{ - set_taps(alpha); -} - -gr_single_pole_iir_filter_cc::~gr_single_pole_iir_filter_cc () -{ - // nop -} - -void -gr_single_pole_iir_filter_cc::set_taps (double alpha) -{ - for (unsigned int i = 0; i < d_vlen; i++) - d_iir[i].set_taps(alpha); -} - -int -gr_single_pole_iir_filter_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - unsigned int vlen = d_vlen; - - if (d_vlen == 1){ - for (int i = 0; i < noutput_items; i++) - out[i] = d_iir[0].filter (in[i]); - } - else { - for (int i = 0; i < noutput_items; i++){ - for (unsigned int j = 0; j < vlen; j++){ - *out++ = d_iir[j].filter (*in++); - } - } - } - return noutput_items; -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h deleted file mode 100644 index 13c595826d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SINGLE_POLE_IIR_FILTER_CC_H -#define INCLUDED_GR_SINGLE_POLE_IIR_FILTER_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_single_pole_iir.h> -#include <gr_complex.h> -#include <stdexcept> - -class gr_single_pole_iir_filter_cc; -typedef boost::shared_ptr<gr_single_pole_iir_filter_cc> gr_single_pole_iir_filter_cc_sptr; - -GR_CORE_API gr_single_pole_iir_filter_cc_sptr -gr_make_single_pole_iir_filter_cc (double alpha, unsigned int vlen=1); - -/*! - * \brief single pole IIR filter with complex input, complex output - * \ingroup filter_blk - * - * The input and output satisfy a difference equation of the form - \htmlonly - \f{ - y[n] - (1-alpha) y[n-1] = alpha x[n] - \f} - \endhtmlonly - - \xmlonly - y[n] - (1-alpha) y[n-1] = alpha x[n] - \endxmlonly - - * with the corresponding rational system function - \htmlonly - \f{ - H(z) = \frac{alpha}{1 - (1-alpha) z^{-1}} - \f} - \endhtmlonly - - \xmlonly - H(z) = \ frac{alpha}{1 - (1-alpha) z^{-1}} - \endxmlonly - - * Note that some texts define the system function with a + in the denominator. - * If you're using that convention, you'll need to negate the feedback tap. - */ -class GR_CORE_API gr_single_pole_iir_filter_cc : public gr_sync_block -{ - private: - friend GR_CORE_API gr_single_pole_iir_filter_cc_sptr - gr_make_single_pole_iir_filter_cc (double alpha, unsigned int vlen); - - unsigned int d_vlen; - std::vector<gr_single_pole_iir<gr_complex,gr_complex,double> > d_iir; - - gr_single_pole_iir_filter_cc (double alpha, unsigned int vlen); - - public: - ~gr_single_pole_iir_filter_cc (); - - void set_taps (double alpha); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.i b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.i deleted file mode 100644 index 2f1f285de7..0000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,single_pole_iir_filter_cc); - -gr_single_pole_iir_filter_cc_sptr -gr_make_single_pole_iir_filter_cc (double alpha, unsigned int vlen=1); - -class gr_single_pole_iir_filter_cc : public gr_sync_block -{ - public: - ~gr_single_pole_iir_filter_cc (); - - void set_taps (double alpha); -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.cc b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.cc deleted file mode 100644 index 047b2ba25c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_single_pole_iir_filter_ff.h> -#include <gr_io_signature.h> -#include <stdio.h> - - -gr_single_pole_iir_filter_ff_sptr -gr_make_single_pole_iir_filter_ff (double alpha, unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_single_pole_iir_filter_ff(alpha, vlen)); -} - -gr_single_pole_iir_filter_ff::gr_single_pole_iir_filter_ff ( - double alpha, unsigned int vlen) - : gr_sync_block ("single_pole_iir_filter_ff", - gr_make_io_signature (1, 1, sizeof (float) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen), d_iir(vlen) -{ - set_taps(alpha); -} - -gr_single_pole_iir_filter_ff::~gr_single_pole_iir_filter_ff () -{ - // nop -} - -void -gr_single_pole_iir_filter_ff::set_taps (double alpha) -{ - for (unsigned int i = 0; i < d_vlen; i++) - d_iir[i].set_taps(alpha); -} - -int -gr_single_pole_iir_filter_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - unsigned int vlen = d_vlen; - - if (d_vlen == 1){ - for (int i = 0; i < noutput_items; i++) - out[i] = d_iir[0].filter (in[i]); - } - else { - for (int i = 0; i < noutput_items; i++){ - for (unsigned int j = 0; j < vlen; j++){ - *out++ = d_iir[j].filter (*in++); - } - } - } - return noutput_items; -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h deleted file mode 100644 index 8dcdad2c94..0000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SINGLE_POLE_IIR_FILTER_FF_H -#define INCLUDED_GR_SINGLE_POLE_IIR_FILTER_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_single_pole_iir.h> -#include <stdexcept> - -class gr_single_pole_iir_filter_ff; -typedef boost::shared_ptr<gr_single_pole_iir_filter_ff> gr_single_pole_iir_filter_ff_sptr; - -GR_CORE_API gr_single_pole_iir_filter_ff_sptr -gr_make_single_pole_iir_filter_ff (double alpha, unsigned int vlen=1); - -/*! - * \brief single pole IIR filter with float input, float output - * \ingroup filter_blk - * - * The input and output satisfy a difference equation of the form - \htmlonly - \f{ - y[n] - (1-alpha) y[n-1] = alpha x[n] - \f} - \endhtmlonly - - \xmlonly - y[n] - (1-alpha) y[n-1] = alpha x[n] - \endxmlonly - - * with the corresponding rational system function - \htmlonly - \f{ - H(z) = \frac{alpha}{1 - (1-alpha) z^{-1}} - \f} - \endhtmlonly - - \xmlonly -H(z) = \ frac{alpha}{1 - (1-alpha) z^{-1}} - \endxmlonly - - * Note that some texts define the system function with a + in the denominator. - * If you're using that convention, you'll need to negate the feedback tap. - */ -class GR_CORE_API gr_single_pole_iir_filter_ff : public gr_sync_block -{ - private: - friend GR_CORE_API gr_single_pole_iir_filter_ff_sptr - gr_make_single_pole_iir_filter_ff (double alpha, unsigned int vlen); - - unsigned int d_vlen; - std::vector<gr_single_pole_iir<float,float,double> > d_iir; - - gr_single_pole_iir_filter_ff (double alpha, unsigned int vlen); - - public: - ~gr_single_pole_iir_filter_ff (); - - void set_taps (double alpha); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.i b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.i deleted file mode 100644 index a835fabb2e..0000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,single_pole_iir_filter_ff); - -gr_single_pole_iir_filter_ff_sptr -gr_make_single_pole_iir_filter_ff (double alpha, unsigned int vlen=1); - -class gr_single_pole_iir_filter_ff : public gr_sync_block -{ - public: - ~gr_single_pole_iir_filter_ff (); - - void set_taps (double alpha); -}; diff --git a/gnuradio-core/src/lib/filter/gr_vec_types.h b/gnuradio-core/src/lib/filter/gr_vec_types.h deleted file mode 100644 index 2bcec44bf8..0000000000 --- a/gnuradio-core/src/lib/filter/gr_vec_types.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Cell single token vector types - Copyright (C) 2007 Free Software Foundation, Inc. - - This file is free software; you can 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 of the License, or (at your option) - any later version. - - This file is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with this file; see the file COPYING. If not, write to the Free - Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ - -/* As a special exception, if you include this header file into source files - compiled by GCC, this header file does not by itself cause the resulting - executable to be covered by the GNU General Public License. This exception - does not however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -/* Single token vector data types for the PowerPC SIMD/Vector Multi-media - eXtension */ - -#ifndef INCLUDED_GR_VEC_TYPES_H -#define INCLUDED_GR_VEC_TYPES_H - -#define qword __vector unsigned char - -#define vec_uchar16 __vector unsigned char -#define vec_char16 __vector signed char -#define vec_bchar16 __vector bool char - -#define vec_ushort8 __vector unsigned short -#define vec_short8 __vector signed short -#define vec_bshort8 __vector bool short - -#define vec_pixel8 __vector pixel - -#define vec_uint4 __vector unsigned int -#define vec_int4 __vector signed int -#define vec_bint4 __vector bool int - -#define vec_float4 __vector float - -#define vec_ullong2 __vector bool char -#define vec_llong2 __vector bool short - -#define vec_double2 __vector bool int - -#endif /* INCLUDED_GR_VEC_TYPES_H */ diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc deleted file mode 100644 index e958c5061f..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gri_fft_filter_ccc_generic.h> -#include <gri_fft.h> -#include <volk/volk.h> -#include <assert.h> -#include <stdexcept> -#include <cstdio> -#include <cstring> -#include <fftw3.h> - -gri_fft_filter_ccc_generic::gri_fft_filter_ccc_generic (int decimation, - const std::vector<gr_complex> &taps, - int nthreads) - : d_fftsize(-1), d_decimation(decimation), d_fwdfft(0), d_invfft(0), d_nthreads(nthreads) -{ - set_taps(taps); -} - -gri_fft_filter_ccc_generic::~gri_fft_filter_ccc_generic () -{ - delete d_fwdfft; - delete d_invfft; - gri_fft_free(d_xformed_taps); -} - -#if 0 -static void -print_vector_complex(const std::string label, const std::vector<gr_complex> &x) -{ - std::cout << label; - for (unsigned i = 0; i < x.size(); i++) - std::cout << x[i] << " "; - std::cout << "\n"; -} -#endif - - -/* - * determines d_ntaps, d_nsamples, d_fftsize, d_xformed_taps - */ -int -gri_fft_filter_ccc_generic::set_taps (const std::vector<gr_complex> &taps) -{ - int i = 0; - compute_sizes(taps.size()); - - d_tail.resize(tailsize()); - for (i = 0; i < tailsize(); i++) - d_tail[i] = 0; - - gr_complex *in = d_fwdfft->get_inbuf(); - gr_complex *out = d_fwdfft->get_outbuf(); - - float scale = 1.0 / d_fftsize; - - // Compute forward xform of taps. - // Copy taps into first ntaps slots, then pad with zeros - for (i = 0; i < d_ntaps; i++) - in[i] = taps[i] * scale; - - for (; i < d_fftsize; i++) - in[i] = 0; - - d_fwdfft->execute(); // do the xform - - // now copy output to d_xformed_taps - for (i = 0; i < d_fftsize; i++) - d_xformed_taps[i] = out[i]; - - return d_nsamples; -} - -// determine and set d_ntaps, d_nsamples, d_fftsize - -void -gri_fft_filter_ccc_generic::compute_sizes(int ntaps) -{ - int old_fftsize = d_fftsize; - d_ntaps = ntaps; - d_fftsize = (int) (2 * pow(2.0, ceil(log(double(ntaps)) / log(2.0)))); - d_nsamples = d_fftsize - d_ntaps + 1; - - if (0) - fprintf(stderr, "gri_fft_filter_ccc_generic: ntaps = %d, fftsize = %d, nsamples = %d\n", - d_ntaps, d_fftsize, d_nsamples); - - assert(d_fftsize == d_ntaps + d_nsamples -1 ); - - if (d_fftsize != old_fftsize){ // compute new plans - delete d_fwdfft; - delete d_invfft; - d_fwdfft = new gri_fft_complex(d_fftsize, true, d_nthreads); - d_invfft = new gri_fft_complex(d_fftsize, false, d_nthreads); - d_xformed_taps = gri_fft_malloc_complex(d_fftsize); - } -} - -void -gri_fft_filter_ccc_generic::set_nthreads(int n) -{ - d_nthreads = n; - if(d_fwdfft) - d_fwdfft->set_nthreads(n); - if(d_invfft) - d_invfft->set_nthreads(n); -} - -int -gri_fft_filter_ccc_generic::nthreads() const -{ - return d_nthreads; -} - -int -gri_fft_filter_ccc_generic::filter (int nitems, const gr_complex *input, gr_complex *output) -{ - int dec_ctr = 0; - int j = 0; - int ninput_items = nitems * d_decimation; - - for (int i = 0; i < ninput_items; i += d_nsamples){ - - memcpy(d_fwdfft->get_inbuf(), &input[i], d_nsamples * sizeof(gr_complex)); - - for (j = d_nsamples; j < d_fftsize; j++) - d_fwdfft->get_inbuf()[j] = 0; - - d_fwdfft->execute(); // compute fwd xform - - gr_complex *a = d_fwdfft->get_outbuf(); - gr_complex *b = d_xformed_taps; - gr_complex *c = d_invfft->get_inbuf(); - - volk_32fc_x2_multiply_32fc_a(c, a, b, d_fftsize); - - d_invfft->execute(); // compute inv xform - - // add in the overlapping tail - - for (j = 0; j < tailsize(); j++) - d_invfft->get_outbuf()[j] += d_tail[j]; - - // copy nsamples to output - j = dec_ctr; - while (j < d_nsamples) { - *output++ = d_invfft->get_outbuf()[j]; - j += d_decimation; - } - dec_ctr = (j - d_nsamples); - - // stash the tail - memcpy(&d_tail[0], d_invfft->get_outbuf() + d_nsamples, - tailsize() * sizeof(gr_complex)); - } - - assert(dec_ctr == 0); - - return nitems; -} diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h deleted file mode 100644 index 648c2b8c54..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_FFT_FILTER_CCC_GENERIC_H -#define INCLUDED_GRI_FFT_FILTER_CCC_GENERIC_H - -#include <gr_core_api.h> -#include <gr_complex.h> -#include <vector> - -class gri_fft_complex; - -/*! - * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps - * \ingroup filter_blk - */ -class GR_CORE_API gri_fft_filter_ccc_generic -{ - private: - int d_ntaps; - int d_nsamples; - int d_fftsize; // fftsize = ntaps + nsamples - 1 - int d_decimation; - gri_fft_complex *d_fwdfft; // forward "plan" - gri_fft_complex *d_invfft; // inverse "plan" - int d_nthreads; // number of FFTW threads to use - std::vector<gr_complex> d_tail; // state carried between blocks for overlap-add - std::vector<gr_complex> d_new_taps; - gr_complex *d_xformed_taps; // Fourier xformed taps - - void compute_sizes(int ntaps); - int tailsize() const { return d_ntaps - 1; } - - public: - /*! - * \brief Construct an FFT filter for complex vectors with the given taps and decimation rate. - * - * This is the basic implementation for performing FFT filter for fast convolution - * in other blocks for complex vectors (such as gr_fft_filter_ccc). - * \param decimation The decimation rate of the filter (int) - * \param taps The filter taps (complex) - * \param nthreads The number of threads for the FFT to use (int) - */ - gri_fft_filter_ccc_generic (int decimation, const std::vector<gr_complex> &taps, - int nthreads=1); - ~gri_fft_filter_ccc_generic (); - - /*! - * \brief Set new taps for the filter. - * - * Sets new taps and resets the class properties to handle different sizes - * \param taps The filter taps (complex) - */ - int set_taps (const std::vector<gr_complex> &taps); - - /*! - * \brief Set number of threads to use. - */ - void set_nthreads(int n); - - /*! - * \brief Get number of threads being used. - */ - int nthreads() const; - - /*! - * \brief Perform the filter operation - * - * \param nitems The number of items to produce - * \param input The input vector to be filtered - * \param output The result of the filter operation - */ - int filter (int nitems, const gr_complex *input, gr_complex *output); - -}; - -#endif /* INCLUDED_GRI_FFT_FILTER_CCC_GENERIC_H */ diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.cc b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.cc deleted file mode 100644 index bfc939869e..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.cc +++ /dev/null @@ -1,186 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gri_fft_filter_ccc_sse.h> -#include <gri_fft.h> -#include <assert.h> -#include <stdexcept> -#include <cstdio> -#include <xmmintrin.h> -#include <fftw3.h> - -gri_fft_filter_ccc_sse::gri_fft_filter_ccc_sse (int decimation, - const std::vector<gr_complex> &taps) - : d_fftsize(-1), d_decimation(decimation), d_fwdfft(0), d_invfft(0) -{ - d_xformed_taps = (gr_complex*)fftwf_malloc(1*sizeof(gr_complex)); - set_taps(taps); -} - -gri_fft_filter_ccc_sse::~gri_fft_filter_ccc_sse () -{ - fftwf_free(d_xformed_taps); - delete d_fwdfft; - delete d_invfft; -} - -#if 0 -static void -print_vector_complex(const std::string label, const std::vector<gr_complex> &x) -{ - std::cout << label; - for (unsigned i = 0; i < x.size(); i++) - std::cout << x[i] << " "; - std::cout << "\n"; -} -#endif - - -/* - * determines d_ntaps, d_nsamples, d_fftsize, d_xformed_taps - */ -int -gri_fft_filter_ccc_sse::set_taps (const std::vector<gr_complex> &taps) -{ - int i = 0; - compute_sizes(taps.size()); - - d_tail.resize(tailsize()); - for (i = 0; i < tailsize(); i++) - d_tail[i] = 0; - - gr_complex *in = d_fwdfft->get_inbuf(); - gr_complex *out = d_fwdfft->get_outbuf(); - - float scale = 1.0 / d_fftsize; - - // Compute forward xform of taps. - // Copy taps into first ntaps slots, then pad with zeros - for (i = 0; i < d_ntaps; i++) - in[i] = taps[i] * scale; - - for (; i < d_fftsize; i++) - in[i] = 0; - - d_fwdfft->execute(); // do the xform - - // now copy output to d_xformed_taps - for (i = 0; i < d_fftsize; i++) - d_xformed_taps[i] = out[i]; - - return d_nsamples; -} - -// determine and set d_ntaps, d_nsamples, d_fftsize - -void -gri_fft_filter_ccc_sse::compute_sizes(int ntaps) -{ - int old_fftsize = d_fftsize; - d_ntaps = ntaps; - d_fftsize = (int) (2 * pow(2.0, ceil(log(ntaps) / log(2)))); - d_nsamples = d_fftsize - d_ntaps + 1; - - if (0) - fprintf(stderr, "gri_fft_filter_ccc_sse: ntaps = %d, fftsize = %d, nsamples = %d\n", - d_ntaps, d_fftsize, d_nsamples); - - assert(d_fftsize == d_ntaps + d_nsamples -1 ); - - if (d_fftsize != old_fftsize){ // compute new plans - delete d_fwdfft; - delete d_invfft; - d_fwdfft = new gri_fft_complex(d_fftsize, true); - d_invfft = new gri_fft_complex(d_fftsize, false); - - fftwf_free(d_xformed_taps); - d_xformed_taps = (gr_complex*)fftwf_malloc((d_fftsize)*sizeof(gr_complex)); - } -} - -int -gri_fft_filter_ccc_sse::filter (int nitems, const gr_complex *input, gr_complex *output) -{ - int dec_ctr = 0; - int j = 0; - int ninput_items = nitems * d_decimation; - - for (int i = 0; i < ninput_items; i += d_nsamples){ - - memcpy(d_fwdfft->get_inbuf(), &input[i], d_nsamples * sizeof(gr_complex)); - - for (j = d_nsamples; j < d_fftsize; j++) - d_fwdfft->get_inbuf()[j] = 0; - - d_fwdfft->execute(); // compute fwd xform - - float *a = (float*)(d_fwdfft->get_outbuf()); - float *b = (float*)(&d_xformed_taps[0]); - float *c = (float*)(d_invfft->get_inbuf()); - - __m128 x0, x1, x2, t0, t1, m; - m = _mm_set_ps(-1, 1, -1, 1); - for (j = 0; j < 2*d_fftsize; j+=4) { // filter in the freq domain - x0 = _mm_load_ps(&a[j]); - t0 = _mm_load_ps(&b[j]); - - t1 = _mm_shuffle_ps(t0, t0, _MM_SHUFFLE(3, 3, 1, 1)); - t0 = _mm_shuffle_ps(t0, t0, _MM_SHUFFLE(2, 2, 0, 0)); - t1 = _mm_mul_ps(t1, m); - - x1 = _mm_mul_ps(x0, t0); - x2 = _mm_mul_ps(x0, t1); - - x2 = _mm_shuffle_ps(x2, x2, _MM_SHUFFLE(2, 3, 0, 1)); - x2 = _mm_add_ps(x1, x2); - - _mm_store_ps(&c[j], x2); - } - - d_invfft->execute(); // compute inv xform - - // add in the overlapping tail - - for (j = 0; j < tailsize(); j++) - d_invfft->get_outbuf()[j] += d_tail[j]; - - // copy nsamples to output - j = dec_ctr; - while (j < d_nsamples) { - *output++ = d_invfft->get_outbuf()[j]; - j += d_decimation; - } - dec_ctr = (j - d_nsamples); - - // stash the tail - memcpy(&d_tail[0], d_invfft->get_outbuf() + d_nsamples, - tailsize() * sizeof(gr_complex)); - } - - assert(dec_ctr == 0); - - return nitems; -} diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h deleted file mode 100644 index 64b8c0c153..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_FFT_FILTER_CCC_SSE_H -#define INCLUDED_GRI_FFT_FILTER_CCC_SSE_H - -#include <gr_core_api.h> -#include <gr_complex.h> -#include <vector> - -class gri_fft_complex; - -/*! - * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps - * \ingroup filter_blk - */ -class GR_CORE_API gri_fft_filter_ccc_sse -{ - private: - int d_ntaps; - int d_nsamples; - int d_fftsize; // fftsize = ntaps + nsamples - 1 - int d_decimation; - gri_fft_complex *d_fwdfft; // forward "plan" - gri_fft_complex *d_invfft; // inverse "plan" - std::vector<gr_complex> d_tail; // state carried between blocks for overlap-add - gr_complex *d_xformed_taps; - std::vector<gr_complex> d_new_taps; - - void compute_sizes(int ntaps); - int tailsize() const { return d_ntaps - 1; } - - public: - /*! - * \brief Construct an FFT filter for complex vectors with the given taps and decimation rate. - * - * This is the basic implementation for performing FFT filter for fast convolution - * in other blocks for complex vectors (such as gr_fft_filter_ccc). - * \param decimation The decimation rate of the filter (int) - * \param taps The filter taps (complex) - */ - gri_fft_filter_ccc_sse (int decimation, const std::vector<gr_complex> &taps); - ~gri_fft_filter_ccc_sse (); - - /*! - * \brief Set new taps for the filter. - * - * Sets new taps and resets the class properties to handle different sizes - * \param taps The filter taps (complex) - */ - int set_taps (const std::vector<gr_complex> &taps); - - /*! - * \brief Perform the filter operation - * - * \param nitems The number of items to produce - * \param input The input vector to be filtered - * \param output The result of the filter operation - */ - int filter (int nitems, const gr_complex *input, gr_complex *output); - -}; - -#endif /* INCLUDED_GRI_FFT_FILTER_CCC_SSE_H */ diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc deleted file mode 100644 index c6e923ee11..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc +++ /dev/null @@ -1,175 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gri_fft_filter_fff_generic.h> -#include <gri_fft.h> -#include <volk/volk.h> -#include <assert.h> -#include <stdexcept> -#include <cstdio> -#include <cstring> - -gri_fft_filter_fff_generic::gri_fft_filter_fff_generic (int decimation, - const std::vector<float> &taps, - int nthreads) - : d_fftsize(-1), d_decimation(decimation), d_fwdfft(0), d_invfft(0), d_nthreads(nthreads) -{ - set_taps(taps); -} - -gri_fft_filter_fff_generic::~gri_fft_filter_fff_generic () -{ - delete d_fwdfft; - delete d_invfft; - gri_fft_free(d_xformed_taps); -} - -/* - * determines d_ntaps, d_nsamples, d_fftsize, d_xformed_taps - */ -int -gri_fft_filter_fff_generic::set_taps (const std::vector<float> &taps) -{ - int i = 0; - compute_sizes(taps.size()); - - d_tail.resize(tailsize()); - for (i = 0; i < tailsize(); i++) - d_tail[i] = 0; - - float *in = d_fwdfft->get_inbuf(); - gr_complex *out = d_fwdfft->get_outbuf(); - - float scale = 1.0 / d_fftsize; - - // Compute forward xform of taps. - // Copy taps into first ntaps slots, then pad with zeros - for (i = 0; i < d_ntaps; i++) - in[i] = taps[i] * scale; - - for (; i < d_fftsize; i++) - in[i] = 0; - - d_fwdfft->execute(); // do the xform - - // now copy output to d_xformed_taps - for (i = 0; i < d_fftsize/2+1; i++) - d_xformed_taps[i] = out[i]; - - return d_nsamples; -} - -// determine and set d_ntaps, d_nsamples, d_fftsize - -void -gri_fft_filter_fff_generic::compute_sizes(int ntaps) -{ - int old_fftsize = d_fftsize; - d_ntaps = ntaps; - d_fftsize = (int) (2 * pow(2.0, ceil(log(double(ntaps)) / log(2.0)))); - d_nsamples = d_fftsize - d_ntaps + 1; - - if (0) - fprintf(stderr, "gri_fft_filter_fff_generic: ntaps = %d, fftsize = %d, nsamples = %d\n", - d_ntaps, d_fftsize, d_nsamples); - - assert(d_fftsize == d_ntaps + d_nsamples -1 ); - - if (d_fftsize != old_fftsize){ // compute new plans - delete d_fwdfft; - delete d_invfft; - d_fwdfft = new gri_fft_real_fwd(d_fftsize); - d_invfft = new gri_fft_real_rev(d_fftsize); - d_xformed_taps = gri_fft_malloc_complex(d_fftsize/2+1); - } -} - -void -gri_fft_filter_fff_generic::set_nthreads(int n) -{ - d_nthreads = n; - if(d_fwdfft) - d_fwdfft->set_nthreads(n); - if(d_invfft) - d_invfft->set_nthreads(n); -} - -int -gri_fft_filter_fff_generic::nthreads() const -{ - return d_nthreads; -} - -int -gri_fft_filter_fff_generic::filter (int nitems, const float *input, float *output) -{ - int dec_ctr = 0; - int j = 0; - int ninput_items = nitems * d_decimation; - - for (int i = 0; i < ninput_items; i += d_nsamples){ - - memcpy(d_fwdfft->get_inbuf(), &input[i], d_nsamples * sizeof(float)); - - for (j = d_nsamples; j < d_fftsize; j++) - d_fwdfft->get_inbuf()[j] = 0; - - d_fwdfft->execute(); // compute fwd xform - - gr_complex *a = d_fwdfft->get_outbuf(); - gr_complex *b = d_xformed_taps; - gr_complex *c = d_invfft->get_inbuf(); - - volk_32fc_x2_multiply_32fc_a(c, a, b, d_fftsize/2+1); - - d_invfft->execute(); // compute inv xform - - // add in the overlapping tail - - for (j = 0; j < tailsize(); j++) - d_invfft->get_outbuf()[j] += d_tail[j]; - - // copy nsamples to output - - //memcpy(out, d_invfft->get_outbuf(), d_nsamples * sizeof(float)); - //out += d_nsamples; - - j = dec_ctr; - while (j < d_nsamples) { - *output++ = d_invfft->get_outbuf()[j]; - j += d_decimation; - } - dec_ctr = (j - d_nsamples); - - // stash the tail - memcpy(&d_tail[0], d_invfft->get_outbuf() + d_nsamples, - tailsize() * sizeof(float)); - } - - assert(dec_ctr == 0); - - return nitems; -} diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.h b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.h deleted file mode 100644 index 528bf5dd7d..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_FFT_FILTER_FFF_GENERIC_H -#define INCLUDED_GRI_FFT_FILTER_FFF_GENERIC_H - -#include <gr_core_api.h> -#include <gr_complex.h> -#include <vector> - -class gri_fft_real_fwd; -class gri_fft_real_rev; - -class GR_CORE_API gri_fft_filter_fff_generic -{ - private: - int d_ntaps; - int d_nsamples; - int d_fftsize; // fftsize = ntaps + nsamples - 1 - int d_decimation; - gri_fft_real_fwd *d_fwdfft; // forward "plan" - gri_fft_real_rev *d_invfft; // inverse "plan" - int d_nthreads; // number of FFTW threads to use - std::vector<float> d_tail; // state carried between blocks for overlap-add - std::vector<float> d_new_taps; - gr_complex *d_xformed_taps; // Fourier xformed taps - - - void compute_sizes(int ntaps); - int tailsize() const { return d_ntaps - 1; } - - public: - /*! - * \brief Construct a FFT filter for float vectors with the given taps and decimation rate. - * - * This is the basic implementation for performing FFT filter for fast convolution - * in other blocks for floating point vectors (such as gr_fft_filter_fff). - * \param decimation The decimation rate of the filter (int) - * \param taps The filter taps (float) - * \param nthreads The number of threads for the FFT to use (int) - */ - gri_fft_filter_fff_generic (int decimation, const std::vector<float> &taps, - int nthreads=1); - ~gri_fft_filter_fff_generic (); - - /*! - * \brief Set new taps for the filter. - * - * Sets new taps and resets the class properties to handle different sizes - * \param taps The filter taps (float) - */ - int set_taps (const std::vector<float> &taps); - - /*! - * \brief Set number of threads to use. - */ - void set_nthreads(int n); - - /*! - * \brief Get number of threads being used. - */ - int nthreads() const; - - /*! - * \brief Perform the filter operation - * - * \param nitems The number of items to produce - * \param input The input vector to be filtered - * \param output The result of the filter operation - */ - int filter (int nitems, const float *input, float *output); - -}; - -#endif /* INCLUDED_GRI_FFT_FILTER_FFF_GENERIC_H */ diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.cc b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.cc deleted file mode 100644 index 84fcfa4380..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gri_fft_filter_fff_sse.h> -#include <gri_fft.h> -#include <assert.h> -#include <stdexcept> -#include <cstdio> -#include <xmmintrin.h> -#include <fftw3.h> - -gri_fft_filter_fff_sse::gri_fft_filter_fff_sse (int decimation, - const std::vector<float> &taps) - : d_fftsize(-1), d_decimation(decimation), d_fwdfft(0), d_invfft(0) -{ - d_xformed_taps = (gr_complex*)fftwf_malloc(1*sizeof(gr_complex)); - set_taps(taps); -} - -gri_fft_filter_fff_sse::~gri_fft_filter_fff_sse () -{ - fftwf_free(d_xformed_taps); - delete d_fwdfft; - delete d_invfft; -} - -/* - * determines d_ntaps, d_nsamples, d_fftsize, d_xformed_taps - */ -int -gri_fft_filter_fff_sse::set_taps (const std::vector<float> &taps) -{ - int i = 0; - compute_sizes(taps.size()); - - d_tail.resize(tailsize()); - for (i = 0; i < tailsize(); i++) - d_tail[i] = 0; - - float *in = d_fwdfft->get_inbuf(); - gr_complex *out = d_fwdfft->get_outbuf(); - - float scale = 1.0 / d_fftsize; - - // Compute forward xform of taps. - // Copy taps into first ntaps slots, then pad with zeros - for (i = 0; i < d_ntaps; i++) - in[i] = taps[i] * scale; - - for (; i < d_fftsize; i++) - in[i] = 0; - - d_fwdfft->execute(); // do the xform - - // now copy output to d_xformed_taps - for (i = 0; i < d_fftsize/2+1; i++) - d_xformed_taps[i] = out[i]; - - return d_nsamples; -} - -// determine and set d_ntaps, d_nsamples, d_fftsize - -void -gri_fft_filter_fff_sse::compute_sizes(int ntaps) -{ - int old_fftsize = d_fftsize; - d_ntaps = ntaps; - d_fftsize = (int) (2 * pow(2.0, ceil(log(ntaps) / log(2)))); - d_nsamples = d_fftsize - d_ntaps + 1; - - if (0) - fprintf(stderr, "gri_fft_filter_fff_sse: ntaps = %d, fftsize = %d, nsamples = %d\n", - d_ntaps, d_fftsize, d_nsamples); - - assert(d_fftsize == d_ntaps + d_nsamples -1 ); - - if (d_fftsize != old_fftsize){ // compute new plans - delete d_fwdfft; - delete d_invfft; - d_fwdfft = new gri_fft_real_fwd(d_fftsize); - d_invfft = new gri_fft_real_rev(d_fftsize); - //d_xformed_taps.resize(d_fftsize/2+1); - - fftwf_free(d_xformed_taps); - d_xformed_taps = (gr_complex*)fftwf_malloc((d_fftsize/2+1)*sizeof(gr_complex)); - } -} - -int -gri_fft_filter_fff_sse::filter (int nitems, const float *input, float *output) -{ - int dec_ctr = 0; - int j = 0; - int ninput_items = nitems * d_decimation; - - for (int i = 0; i < ninput_items; i += d_nsamples){ - - memcpy(d_fwdfft->get_inbuf(), &input[i], d_nsamples * sizeof(float)); - - for (j = d_nsamples; j < d_fftsize; j++) - d_fwdfft->get_inbuf()[j] = 0; - - d_fwdfft->execute(); // compute fwd xform - - float *a = (float*)(d_fwdfft->get_outbuf()); - float *b = (float*)(&d_xformed_taps[0]); - float *c = (float*)(d_invfft->get_inbuf()); - - __m128 x0, x1, x2, t0, t1, m; - m = _mm_set_ps(-1, 1, -1, 1); - for (j = 0; j < d_fftsize; j+=4) { // filter in the freq domain - x0 = _mm_load_ps(&a[j]); - t0 = _mm_load_ps(&b[j]); - - t1 = _mm_shuffle_ps(t0, t0, _MM_SHUFFLE(3, 3, 1, 1)); - t0 = _mm_shuffle_ps(t0, t0, _MM_SHUFFLE(2, 2, 0, 0)); - t1 = _mm_mul_ps(t1, m); - - x1 = _mm_mul_ps(x0, t0); - x2 = _mm_mul_ps(x0, t1); - - x2 = _mm_shuffle_ps(x2, x2, _MM_SHUFFLE(2, 3, 0, 1)); - x2 = _mm_add_ps(x1, x2); - - _mm_store_ps(&c[j], x2); - } - - // Finish off the last one; do the complex multiply as floats - j = d_fftsize/2; - c[j] = (a[j] * b[j]) - (a[j+1] * b[j+1]); - c[j+1] = (a[j] * b[j+1]) + (a[j+1] * b[j]); - - d_invfft->execute(); // compute inv xform - - // add in the overlapping tail - - for (j = 0; j < tailsize(); j++) - d_invfft->get_outbuf()[j] += d_tail[j]; - - // copy nsamples to output - - //memcpy(out, d_invfft->get_outbuf(), d_nsamples * sizeof(float)); - //out += d_nsamples; - - j = dec_ctr; - while (j < d_nsamples) { - *output++ = d_invfft->get_outbuf()[j]; - j += d_decimation; - } - dec_ctr = (j - d_nsamples); - - // stash the tail - memcpy(&d_tail[0], d_invfft->get_outbuf() + d_nsamples, - tailsize() * sizeof(float)); - } - - assert(dec_ctr == 0); - - return nitems; -} diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.h b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.h deleted file mode 100644 index b6086562d9..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_FFT_FILTER_FFF_SSE_H -#define INCLUDED_GRI_FFT_FILTER_FFF_SSE_H - -#include <gr_core_api.h> -#include <gr_complex.h> -#include <vector> - -class gri_fft_real_fwd; -class gri_fft_real_rev; - -class GR_CORE_API gri_fft_filter_fff_sse -{ - private: - int d_ntaps; - int d_nsamples; - int d_fftsize; // fftsize = ntaps + nsamples - 1 - int d_decimation; - gri_fft_real_fwd *d_fwdfft; // forward "plan" - gri_fft_real_rev *d_invfft; // inverse "plan" - std::vector<float> d_tail; // state carried between blocks for overlap-add - //std::vector<gr_complex> d_xformed_taps; // Fourier xformed taps - gr_complex *d_xformed_taps; - std::vector<float> d_new_taps; - - - void compute_sizes(int ntaps); - int tailsize() const { return d_ntaps - 1; } - - public: - /*! - * \brief Construct a FFT filter for float vectors with the given taps and decimation rate. - * - * This is the basic implementation for performing FFT filter for fast convolution - * in other blocks for floating point vectors (such as gr_fft_filter_fff). - * \param decimation The decimation rate of the filter (int) - * \param taps The filter taps (float) - */ - gri_fft_filter_fff_sse (int decimation, const std::vector<float> &taps); - ~gri_fft_filter_fff_sse (); - - /*! - * \brief Set new taps for the filter. - * - * Sets new taps and resets the class properties to handle different sizes - * \param taps The filter taps (float) - */ - int set_taps (const std::vector<float> &taps); - - /*! - * \brief Perform the filter operation - * - * \param nitems The number of items to produce - * \param input The input vector to be filtered - * \param output The result of the filter operation - */ - int filter (int nitems, const float *input, float *output); - -}; - -#endif /* INCLUDED_GRI_FFT_FILTER_FFF_SSE_H */ diff --git a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t deleted file mode 100644 index 0ae644cc65..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <@NAME@.h> - -@NAME@::@NAME@(const std::vector<@TAP_TYPE@> &taps) -{ - d_buffer = NULL; - set_taps(taps); -} - -@NAME@::~@NAME@() -{ - if(d_buffer != NULL) - free(d_buffer); -} - -void -@NAME@::set_taps (const std::vector<@TAP_TYPE@> &taps) -{ - d_taps = gr_reverse(taps); - - if(d_buffer != NULL) { - free(d_buffer); - d_buffer = NULL; - } - - // FIXME: memalign this to 16-byte boundaries for SIMD later - size_t t = sizeof(@I_TYPE@) * 2 * d_taps.size(); - d_buffer = (@I_TYPE@*)malloc(t); - memset(d_buffer, 0x00, t); - d_idx = 0; -} - -@O_TYPE@ -@NAME@::filter (@I_TYPE@ input) -{ - unsigned int i; - - d_buffer[d_idx] = input; - d_buffer[d_idx+ntaps()] = input; - - // using the later for the case when ntaps=0; - // profiling shows this doesn't make a difference - //d_idx = (d_idx + 1) % ntaps(); - d_idx++; - if(d_idx >= ntaps()) - d_idx = 0; - - @ACC_TYPE@ out = 0; - for(i = 0; i < ntaps(); i++) { - out += @INPUT_CAST@ d_buffer[d_idx + i] * d_taps[i]; - } - return (@O_TYPE@)out; -} - -@O_TYPE@ -@NAME@::filter (const @I_TYPE@ input[], unsigned long dec) -{ - unsigned int i; - - for(i = 0; i < dec; i++) { - d_buffer[d_idx] = input[i]; - d_buffer[d_idx+ntaps()] = input[i]; - d_idx++; - if(d_idx >= ntaps()) - d_idx = 0; - } - - @ACC_TYPE@ out = 0; - for(i = 0; i < ntaps(); i++) { - out += @INPUT_CAST@ d_buffer[d_idx + i] * d_taps[i]; - } - return (@O_TYPE@)out; -} - -void -@NAME@::filterN (@O_TYPE@ output[], - const @I_TYPE@ input[], - unsigned long n) -{ - for(unsigned long i = 0; i < n; i++) { - output[i] = filter(input[i]); - } -} - -void -@NAME@::filterNdec (@O_TYPE@ output[], - const @I_TYPE@ input[], - unsigned long n, - unsigned long decimate) -{ - unsigned long j = 0; - for(unsigned long i = 0; i < n; i++) { - output[i] = filter(&input[j], decimate); - j += decimate; - } -} diff --git a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.h.t b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.h.t deleted file mode 100644 index efb314bed0..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.h.t +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * WARNING: This file is automatically generated by generate_gri_fir_XXX.py - * Any changes made to this file will be overwritten. - */ - - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <vector> -#include <gr_types.h> -#include <gr_reverse.h> -#include <string.h> -#include <cstdio> - -/*! - * \brief FIR with internal buffer for @I_TYPE@ input, - @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter - * - */ - -class GR_CORE_API @NAME@ { - -protected: - std::vector<@TAP_TYPE@> d_taps; // reversed taps - @I_TYPE@ *d_buffer; - unsigned int d_idx; - -public: - - // CONSTRUCTORS - - /*! - * \brief construct new FIR with given taps. - * - * Note that taps must be in forward order, e.g., coefficient 0 is - * stored in new_taps[0], coefficient 1 is stored in - * new_taps[1], etc. - */ - @NAME@ (const std::vector<@TAP_TYPE@> &taps); - - ~@NAME@ (); - - // MANIPULATORS - - /*! - * \brief compute a single output value. - * - * \p input is a single input value of the filter type - * - * \returns the filtered input value. - */ - @O_TYPE@ filter (@I_TYPE@ input); - - - /*! - * \brief compute a single output value; designed for decimating filters. - * - * \p input is a single input value of the filter type. The value of dec is the - * decimating value of the filter, so input[] must have dec valid values. - * The filter pushes dec number of items onto the circ. buffer before computing - * a single output. - * - * \returns the filtered input value. - */ - @O_TYPE@ filter (const @I_TYPE@ input[], unsigned long dec); - - /*! - * \brief compute an array of N output values. - * - * \p input must have (n - 1 + ntaps()) valid entries. - * input[0] .. input[n - 1 + ntaps() - 1] are referenced to compute the output values. - */ - void filterN (@O_TYPE@ output[], const @I_TYPE@ input[], - unsigned long n); - - /*! - * \brief compute an array of N output values, decimating the input - * - * \p input must have (decimate * (n - 1) + ntaps()) valid entries. - * input[0] .. input[decimate * (n - 1) + ntaps() - 1] are referenced to - * compute the output values. - */ - void filterNdec (@O_TYPE@ output[], const @I_TYPE@ input[], - unsigned long n, unsigned long decimate); - - /*! - * \brief install \p new_taps as the current taps. - */ - void set_taps (const std::vector<@TAP_TYPE@> &taps); - - // ACCESSORS - - /*! - * \return number of taps in filter. - */ - unsigned ntaps () const { return d_taps.size (); } - - /*! - * \return current taps - */ - const std::vector<@TAP_TYPE@> get_taps () const - { - return gr_reverse(d_taps); - } -}; - -#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/filter/gri_goertzel.cc b/gnuradio-core/src/lib/filter/gri_goertzel.cc deleted file mode 100644 index 2fbdd3b137..0000000000 --- a/gnuradio-core/src/lib/filter/gri_goertzel.cc +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <cmath> - -#include <gri_goertzel.h> - -gri_goertzel::gri_goertzel(int rate, int len, float freq) -{ - gri_setparms(rate, len, freq); -} - -void -gri_goertzel::gri_setparms(int rate, int len, float freq) -{ - d_d1 = 0.0; - d_d2 = 0.0; - - float w = 2.0*M_PI*freq/rate; - d_wr = 2.0*std::cos(w); - d_wi = std::sin(w); - d_len = len; - d_processed = 0; - -} - -gr_complex gri_goertzel::batch(float *in) -{ - d_d1 = 0.0; - d_d2 = 0.0; - - for(int i = 0; i < d_len; i++) - input(in[i]); - - return output(); -} - -void gri_goertzel::input(const float &input) -{ - float y = input + d_wr*d_d1 - d_d2; - d_d2 = d_d1; - d_d1 = y; - d_processed++; -} - -gr_complex gri_goertzel::output() -{ - gr_complex out((0.5*d_wr*d_d1-d_d2)/d_len, (d_wi*d_d1)/d_len); - d_d1 = 0.0; - d_d2 = 0.0; - d_processed = 0; - return out; -} diff --git a/gnuradio-core/src/lib/filter/gri_goertzel.h b/gnuradio-core/src/lib/filter/gri_goertzel.h deleted file mode 100644 index e28cb21a88..0000000000 --- a/gnuradio-core/src/lib/filter/gri_goertzel.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_GOERTZEL_H -#define INCLUDED_GRI_GOERTZEL_H - -#include <gr_core_api.h> -#include <gr_types.h> - -/*! - * \brief Implements Goertzel single-bin DFT calculation - * \ingroup misc - */ -class GR_CORE_API gri_goertzel -{ -public: - gri_goertzel() {} - gri_goertzel(int rate, int len, float freq); - void gri_setparms(int rate, int len, float freq); - - // Process a input array - gr_complex batch(float *in); - - // Process sample by sample - void input(const float &in); - gr_complex output(); - bool ready() const { return d_processed == d_len; } - -private: - float d_d1; - float d_d2; - float d_wr; - float d_wi; - int d_len; - int d_processed; -}; - -#endif /* INCLUDED_GRI_GOERTZEL_H */ diff --git a/gnuradio-core/src/lib/filter/gri_iir.h b/gnuradio-core/src/lib/filter/gri_iir.h deleted file mode 100644 index 86345f6c09..0000000000 --- a/gnuradio-core/src/lib/filter/gri_iir.h +++ /dev/null @@ -1,177 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_IIR_H -#define INCLUDED_GRI_IIR_H - -#include <gr_core_api.h> -#include <vector> -#include <stdexcept> - -/*! - * \brief base class template for Infinite Impulse Response filter (IIR) - */ -template<class i_type, class o_type, class tap_type> -class gri_iir { -public: - /*! - * \brief Construct an IIR with the given taps. - * - * This filter uses the Direct Form I implementation, where - * \p fftaps contains the feed-forward taps, and \p fbtaps the feedback ones. - * - * \p fftaps and \p fbtaps must have equal numbers of taps - * - * The input and output satisfy a difference equation of the form - - \f[ - y[n] - \sum_{k=1}^{M} a_k y[n-k] = \sum_{k=0}^{N} b_k x[n-k] - \f] - - * with the corresponding rational system function - - \f[ - H(z) = \frac{\sum_{k=0}^{N} b_k z^{-k}}{1 - \sum_{k=1}^{M} a_k z^{-k}} - \f] - - * Note that some texts define the system function with a + in the denominator. - * If you're using that convention, you'll need to negate the feedback taps. - */ - gri_iir (const std::vector<tap_type>& fftaps, - const std::vector<tap_type>& fbtaps) throw (std::invalid_argument) - { - set_taps (fftaps, fbtaps); - } - - gri_iir () : d_latest_n(0),d_latest_m(0) { } - - ~gri_iir () {} - - /*! - * \brief compute a single output value. - * \returns the filtered input value. - */ - o_type filter (const i_type input); - - /*! - * \brief compute an array of N output values. - * \p input must have N valid entries. - */ - void filter_n (o_type output[], const i_type input[], long n); - - /*! - * \return number of taps in filter. - */ - unsigned ntaps_ff () const { return d_fftaps.size (); } - unsigned ntaps_fb () const { return d_fbtaps.size (); } - - /*! - * \brief install new taps. - */ - void set_taps (const std::vector<tap_type> &fftaps, - const std::vector<tap_type> &fbtaps) throw (std::invalid_argument) - { - - - d_latest_n = 0; - d_latest_m = 0; - d_fftaps = fftaps; - d_fbtaps = fbtaps; - - int n = fftaps.size (); - int m = fbtaps.size (); - d_prev_input.resize (2 * n); - d_prev_output.resize (2 * m); - - for (int i = 0; i < 2 * n; i++){ - d_prev_input[i] = 0; - } - for (int i = 0; i < 2 * m; i++){ - d_prev_output[i] = 0; - } - } - -protected: - std::vector<tap_type> d_fftaps; - std::vector<tap_type> d_fbtaps; - int d_latest_n; - int d_latest_m; - std::vector<tap_type> d_prev_output; - std::vector<i_type> d_prev_input; -}; - - -// -// general case. We may want to specialize this -// -template<class i_type, class o_type, class tap_type> -o_type -gri_iir<i_type, o_type, tap_type>::filter (const i_type input) -{ - tap_type acc; - unsigned i = 0; - unsigned n = ntaps_ff (); - unsigned m = ntaps_fb (); - - if (n == 0) - return (o_type) 0; - - int latest_n = d_latest_n; - int latest_m = d_latest_m; - - acc = d_fftaps[0] * input; - for (i = 1; i < n; i ++) - acc += (d_fftaps[i] * d_prev_input[latest_n + i]); - for (i = 1; i < m; i ++) - acc += (d_fbtaps[i] * d_prev_output[latest_m + i]); - - // store the values twice to avoid having to handle wrap-around in the loop - d_prev_output[latest_m] = acc; - d_prev_output[latest_m+m] = acc; - d_prev_input[latest_n] = input; - d_prev_input[latest_n+n] = input; - - latest_n--; - latest_m--; - if (latest_n < 0) - latest_n += n; - if (latest_m < 0) - latest_m += m; - - d_latest_m = latest_m; - d_latest_n = latest_n; - return (o_type) acc; -} - - -template<class i_type, class o_type, class tap_type> -void -gri_iir<i_type, o_type, tap_type>::filter_n (o_type output[], - const i_type input[], - long n) -{ - for (int i = 0; i < n; i++) - output[i] = filter (input[i]); -} - -#endif /* INCLUDED_GRI_IIR_H */ - diff --git a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.cc b/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.cc deleted file mode 100644 index 52098bf1aa..0000000000 --- a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gri_mmse_fir_interpolator.h> -#include <gr_fir_util.h> -#include <gr_fir_fff.h> -#include <assert.h> -#include <cmath> -#include "interpolator_taps.h" - -gri_mmse_fir_interpolator::gri_mmse_fir_interpolator () -{ - filters.resize (NSTEPS + 1); - - for (int i = 0; i < NSTEPS + 1; i++){ - std::vector<float> t (&taps[i][0], &taps[i][NTAPS]); - filters[i] = gr_fir_util::create_gr_fir_fff (t); - } -} - -gri_mmse_fir_interpolator::~gri_mmse_fir_interpolator () -{ - for (int i = 0; i < NSTEPS + 1; i++) - delete filters[i]; -} - -unsigned -gri_mmse_fir_interpolator::ntaps () const -{ - return NTAPS; -} - -unsigned -gri_mmse_fir_interpolator::nsteps () const -{ - return NSTEPS; -} - -float -gri_mmse_fir_interpolator::interpolate (const float input[], float mu) const -{ - int imu = (int) rint (mu * NSTEPS); - - assert (imu >= 0); - assert (imu <= NSTEPS); - - float r = filters[imu]->filter (input); - return r; -} diff --git a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.h b/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.h deleted file mode 100644 index f479169bc8..0000000000 --- a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GRI_MMSE_FIR_INTERPOLATOR_H_ -#define _GRI_MMSE_FIR_INTERPOLATOR_H_ - -#include <gr_core_api.h> -#include <vector> - -class gr_fir_fff; - -/*! - * \brief Compute intermediate samples between signal samples x(k*Ts) - * \ingroup filter_primitive - * - * This implements a Mininum Mean Squared Error interpolator with 8 taps. - * It is suitable for signals where the bandwidth of interest B = 1/(4*Ts) - * Where Ts is the time between samples. - * - * Although mu, the fractional delay, is specified as a float, it is actually - * quantized. 0.0 <= mu <= 1.0. That is, mu is quantized in the interpolate - * method to 32nd's of a sample. - * - * For more information, in the GNU Radio source code, see: - * \li gnuradio-core/src/gen_interpolator_taps/README - * \li gnuradio-core/src/gen_interpolator_taps/praxis.txt - */ - -class GR_CORE_API gri_mmse_fir_interpolator { -public: - gri_mmse_fir_interpolator (); - ~gri_mmse_fir_interpolator (); - - unsigned ntaps () const; - unsigned nsteps () const; - - /*! - * \brief compute a single interpolated output value. - * \p input must have ntaps() valid entries. - * input[0] .. input[ntaps() - 1] are referenced to compute the output value. - * - * \p mu must be in the range [0, 1] and specifies the fractional delay. - * - * \returns the interpolated input value. - */ - float interpolate (const float input[], float mu) const; - -protected: - std::vector<gr_fir_fff *> filters; -}; - - -#endif /* _GRI_MMSE_FIR_INTERPOLATOR_H_ */ diff --git a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.cc b/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.cc deleted file mode 100644 index 174378c22a..0000000000 --- a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gri_mmse_fir_interpolator_cc.h> -#include <gr_fir_util.h> -#include <gr_fir_ccf.h> -#include <assert.h> -#include <cmath> -#include "interpolator_taps.h" - -gri_mmse_fir_interpolator_cc::gri_mmse_fir_interpolator_cc () -{ - filters.resize (NSTEPS + 1); - - for (int i = 0; i < NSTEPS + 1; i++){ - std::vector<float> t (&taps[i][0], &taps[i][NTAPS]); - filters[i] = gr_fir_util::create_gr_fir_ccf (t); - } -} - -gri_mmse_fir_interpolator_cc::~gri_mmse_fir_interpolator_cc () -{ - for (int i = 0; i < NSTEPS + 1; i++) - delete filters[i]; -} - -unsigned -gri_mmse_fir_interpolator_cc::ntaps () const -{ - return NTAPS; -} - -unsigned -gri_mmse_fir_interpolator_cc::nsteps () const -{ - return NSTEPS; -} - -gr_complex -gri_mmse_fir_interpolator_cc::interpolate (const gr_complex input[], float mu) -{ - int imu = (int) rint (mu * NSTEPS); - - assert (imu >= 0); - assert (imu <= NSTEPS); - - gr_complex r = filters[imu]->filter (input); - return r; -} diff --git a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.h b/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.h deleted file mode 100644 index bacd9ed92a..0000000000 --- a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GRI_MMSE_FIR_INTERPOLATOR_CC_H_ -#define _GRI_MMSE_FIR_INTERPOLATOR_CC_H_ - -#include <gr_core_api.h> -#include <gr_complex.h> -#include <vector> - -class gr_fir_ccf; - -/*! - * \brief Compute intermediate samples between signal samples x(k*Ts) - * \ingroup filter_primitive - * - * This implements a Mininum Mean Squared Error interpolator with 8 taps. - * It is suitable for signals where the bandwidth of interest B = 1/(4*Ts) - * Where Ts is the time between samples. - * - * Although mu, the fractional delay, is specified as a float, it is actually - * quantized. 0.0 <= mu <= 1.0. That is, mu is quantized in the interpolate - * method to 32nd's of a sample. - * - * For more information, in the GNU Radio source code, see: - * \li gnuradio-core/src/gen_interpolator_taps/README - * \li gnuradio-core/src/gen_interpolator_taps/praxis.txt - */ - -class GR_CORE_API gri_mmse_fir_interpolator_cc { -public: - gri_mmse_fir_interpolator_cc (); - ~gri_mmse_fir_interpolator_cc (); - - unsigned ntaps () const; - unsigned nsteps () const; - - /*! - * \brief compute a single interpolated output value. - * - * \p input must have ntaps() valid entries and be 8-byte aligned. - * input[0] .. input[ntaps() - 1] are referenced to compute the output value. - * \throws std::invalid_argument if input is not 8-byte aligned. - * - * \p mu must be in the range [0, 1] and specifies the fractional delay. - * - * \returns the interpolated input value. - */ - gr_complex interpolate (const gr_complex input[], float mu); - -protected: - std::vector<gr_fir_ccf *> filters; -}; - - -#endif /* _GRI_MMSE_FIR_INTERPOLATOR_CC_H_ */ diff --git a/gnuradio-core/src/lib/filter/interpolator_taps.h b/gnuradio-core/src/lib/filter/interpolator_taps.h deleted file mode 100644 index 76702b63fa..0000000000 --- a/gnuradio-core/src/lib/filter/interpolator_taps.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * This file was machine generated by gen_interpolator_taps. - * DO NOT EDIT BY HAND. - */ - -static const int NTAPS = 8; -static const int NSTEPS = 128; - -static const float taps[NSTEPS+1][NTAPS] = { - // -4 -3 -2 -1 0 1 2 3 mu - { 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 1.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00 }, // 0/128 - { -1.54700e-04, 8.53777e-04, -2.76968e-03, 7.89295e-03, 9.98534e-01, -5.41054e-03, 1.24642e-03, -1.98993e-04 }, // 1/128 - { -3.09412e-04, 1.70888e-03, -5.55134e-03, 1.58840e-02, 9.96891e-01, -1.07209e-02, 2.47942e-03, -3.96391e-04 }, // 2/128 - { -4.64053e-04, 2.56486e-03, -8.34364e-03, 2.39714e-02, 9.95074e-01, -1.59305e-02, 3.69852e-03, -5.92100e-04 }, // 3/128 - { -6.18544e-04, 3.42130e-03, -1.11453e-02, 3.21531e-02, 9.93082e-01, -2.10389e-02, 4.90322e-03, -7.86031e-04 }, // 4/128 - { -7.72802e-04, 4.27773e-03, -1.39548e-02, 4.04274e-02, 9.90917e-01, -2.60456e-02, 6.09305e-03, -9.78093e-04 }, // 5/128 - { -9.26747e-04, 5.13372e-03, -1.67710e-02, 4.87921e-02, 9.88580e-01, -3.09503e-02, 7.26755e-03, -1.16820e-03 }, // 6/128 - { -1.08030e-03, 5.98883e-03, -1.95925e-02, 5.72454e-02, 9.86071e-01, -3.57525e-02, 8.42626e-03, -1.35627e-03 }, // 7/128 - { -1.23337e-03, 6.84261e-03, -2.24178e-02, 6.57852e-02, 9.83392e-01, -4.04519e-02, 9.56876e-03, -1.54221e-03 }, // 8/128 - { -1.38589e-03, 7.69462e-03, -2.52457e-02, 7.44095e-02, 9.80543e-01, -4.50483e-02, 1.06946e-02, -1.72594e-03 }, // 9/128 - { -1.53777e-03, 8.54441e-03, -2.80746e-02, 8.31162e-02, 9.77526e-01, -4.95412e-02, 1.18034e-02, -1.90738e-03 }, // 10/128 - { -1.68894e-03, 9.39154e-03, -3.09033e-02, 9.19033e-02, 9.74342e-01, -5.39305e-02, 1.28947e-02, -2.08645e-03 }, // 11/128 - { -1.83931e-03, 1.02356e-02, -3.37303e-02, 1.00769e-01, 9.70992e-01, -5.82159e-02, 1.39681e-02, -2.26307e-03 }, // 12/128 - { -1.98880e-03, 1.10760e-02, -3.65541e-02, 1.09710e-01, 9.67477e-01, -6.23972e-02, 1.50233e-02, -2.43718e-03 }, // 13/128 - { -2.13733e-03, 1.19125e-02, -3.93735e-02, 1.18725e-01, 9.63798e-01, -6.64743e-02, 1.60599e-02, -2.60868e-03 }, // 14/128 - { -2.28483e-03, 1.27445e-02, -4.21869e-02, 1.27812e-01, 9.59958e-01, -7.04471e-02, 1.70776e-02, -2.77751e-03 }, // 15/128 - { -2.43121e-03, 1.35716e-02, -4.49929e-02, 1.36968e-01, 9.55956e-01, -7.43154e-02, 1.80759e-02, -2.94361e-03 }, // 16/128 - { -2.57640e-03, 1.43934e-02, -4.77900e-02, 1.46192e-01, 9.51795e-01, -7.80792e-02, 1.90545e-02, -3.10689e-03 }, // 17/128 - { -2.72032e-03, 1.52095e-02, -5.05770e-02, 1.55480e-01, 9.47477e-01, -8.17385e-02, 2.00132e-02, -3.26730e-03 }, // 18/128 - { -2.86289e-03, 1.60193e-02, -5.33522e-02, 1.64831e-01, 9.43001e-01, -8.52933e-02, 2.09516e-02, -3.42477e-03 }, // 19/128 - { -3.00403e-03, 1.68225e-02, -5.61142e-02, 1.74242e-01, 9.38371e-01, -8.87435e-02, 2.18695e-02, -3.57923e-03 }, // 20/128 - { -3.14367e-03, 1.76185e-02, -5.88617e-02, 1.83711e-01, 9.33586e-01, -9.20893e-02, 2.27664e-02, -3.73062e-03 }, // 21/128 - { -3.28174e-03, 1.84071e-02, -6.15931e-02, 1.93236e-01, 9.28650e-01, -9.53307e-02, 2.36423e-02, -3.87888e-03 }, // 22/128 - { -3.41815e-03, 1.91877e-02, -6.43069e-02, 2.02814e-01, 9.23564e-01, -9.84679e-02, 2.44967e-02, -4.02397e-03 }, // 23/128 - { -3.55283e-03, 1.99599e-02, -6.70018e-02, 2.12443e-01, 9.18329e-01, -1.01501e-01, 2.53295e-02, -4.16581e-03 }, // 24/128 - { -3.68570e-03, 2.07233e-02, -6.96762e-02, 2.22120e-01, 9.12947e-01, -1.04430e-01, 2.61404e-02, -4.30435e-03 }, // 25/128 - { -3.81671e-03, 2.14774e-02, -7.23286e-02, 2.31843e-01, 9.07420e-01, -1.07256e-01, 2.69293e-02, -4.43955e-03 }, // 26/128 - { -3.94576e-03, 2.22218e-02, -7.49577e-02, 2.41609e-01, 9.01749e-01, -1.09978e-01, 2.76957e-02, -4.57135e-03 }, // 27/128 - { -4.07279e-03, 2.29562e-02, -7.75620e-02, 2.51417e-01, 8.95936e-01, -1.12597e-01, 2.84397e-02, -4.69970e-03 }, // 28/128 - { -4.19774e-03, 2.36801e-02, -8.01399e-02, 2.61263e-01, 8.89984e-01, -1.15113e-01, 2.91609e-02, -4.82456e-03 }, // 29/128 - { -4.32052e-03, 2.43930e-02, -8.26900e-02, 2.71144e-01, 8.83893e-01, -1.17526e-01, 2.98593e-02, -4.94589e-03 }, // 30/128 - { -4.44107e-03, 2.50946e-02, -8.52109e-02, 2.81060e-01, 8.77666e-01, -1.19837e-01, 3.05345e-02, -5.06363e-03 }, // 31/128 - { -4.55932e-03, 2.57844e-02, -8.77011e-02, 2.91006e-01, 8.71305e-01, -1.22047e-01, 3.11866e-02, -5.17776e-03 }, // 32/128 - { -4.67520e-03, 2.64621e-02, -9.01591e-02, 3.00980e-01, 8.64812e-01, -1.24154e-01, 3.18153e-02, -5.28823e-03 }, // 33/128 - { -4.78866e-03, 2.71272e-02, -9.25834e-02, 3.10980e-01, 8.58189e-01, -1.26161e-01, 3.24205e-02, -5.39500e-03 }, // 34/128 - { -4.89961e-03, 2.77794e-02, -9.49727e-02, 3.21004e-01, 8.51437e-01, -1.28068e-01, 3.30021e-02, -5.49804e-03 }, // 35/128 - { -5.00800e-03, 2.84182e-02, -9.73254e-02, 3.31048e-01, 8.44559e-01, -1.29874e-01, 3.35600e-02, -5.59731e-03 }, // 36/128 - { -5.11376e-03, 2.90433e-02, -9.96402e-02, 3.41109e-01, 8.37557e-01, -1.31581e-01, 3.40940e-02, -5.69280e-03 }, // 37/128 - { -5.21683e-03, 2.96543e-02, -1.01915e-01, 3.51186e-01, 8.30432e-01, -1.33189e-01, 3.46042e-02, -5.78446e-03 }, // 38/128 - { -5.31716e-03, 3.02507e-02, -1.04150e-01, 3.61276e-01, 8.23188e-01, -1.34699e-01, 3.50903e-02, -5.87227e-03 }, // 39/128 - { -5.41467e-03, 3.08323e-02, -1.06342e-01, 3.71376e-01, 8.15826e-01, -1.36111e-01, 3.55525e-02, -5.95620e-03 }, // 40/128 - { -5.50931e-03, 3.13987e-02, -1.08490e-01, 3.81484e-01, 8.08348e-01, -1.37426e-01, 3.59905e-02, -6.03624e-03 }, // 41/128 - { -5.60103e-03, 3.19495e-02, -1.10593e-01, 3.91596e-01, 8.00757e-01, -1.38644e-01, 3.64044e-02, -6.11236e-03 }, // 42/128 - { -5.68976e-03, 3.24843e-02, -1.12650e-01, 4.01710e-01, 7.93055e-01, -1.39767e-01, 3.67941e-02, -6.18454e-03 }, // 43/128 - { -5.77544e-03, 3.30027e-02, -1.14659e-01, 4.11823e-01, 7.85244e-01, -1.40794e-01, 3.71596e-02, -6.25277e-03 }, // 44/128 - { -5.85804e-03, 3.35046e-02, -1.16618e-01, 4.21934e-01, 7.77327e-01, -1.41727e-01, 3.75010e-02, -6.31703e-03 }, // 45/128 - { -5.93749e-03, 3.39894e-02, -1.18526e-01, 4.32038e-01, 7.69305e-01, -1.42566e-01, 3.78182e-02, -6.37730e-03 }, // 46/128 - { -6.01374e-03, 3.44568e-02, -1.20382e-01, 4.42134e-01, 7.61181e-01, -1.43313e-01, 3.81111e-02, -6.43358e-03 }, // 47/128 - { -6.08674e-03, 3.49066e-02, -1.22185e-01, 4.52218e-01, 7.52958e-01, -1.43968e-01, 3.83800e-02, -6.48585e-03 }, // 48/128 - { -6.15644e-03, 3.53384e-02, -1.23933e-01, 4.62289e-01, 7.44637e-01, -1.44531e-01, 3.86247e-02, -6.53412e-03 }, // 49/128 - { -6.22280e-03, 3.57519e-02, -1.25624e-01, 4.72342e-01, 7.36222e-01, -1.45004e-01, 3.88454e-02, -6.57836e-03 }, // 50/128 - { -6.28577e-03, 3.61468e-02, -1.27258e-01, 4.82377e-01, 7.27714e-01, -1.45387e-01, 3.90420e-02, -6.61859e-03 }, // 51/128 - { -6.34530e-03, 3.65227e-02, -1.28832e-01, 4.92389e-01, 7.19116e-01, -1.45682e-01, 3.92147e-02, -6.65479e-03 }, // 52/128 - { -6.40135e-03, 3.68795e-02, -1.30347e-01, 5.02377e-01, 7.10431e-01, -1.45889e-01, 3.93636e-02, -6.68698e-03 }, // 53/128 - { -6.45388e-03, 3.72167e-02, -1.31800e-01, 5.12337e-01, 7.01661e-01, -1.46009e-01, 3.94886e-02, -6.71514e-03 }, // 54/128 - { -6.50285e-03, 3.75341e-02, -1.33190e-01, 5.22267e-01, 6.92808e-01, -1.46043e-01, 3.95900e-02, -6.73929e-03 }, // 55/128 - { -6.54823e-03, 3.78315e-02, -1.34515e-01, 5.32164e-01, 6.83875e-01, -1.45993e-01, 3.96678e-02, -6.75943e-03 }, // 56/128 - { -6.58996e-03, 3.81085e-02, -1.35775e-01, 5.42025e-01, 6.74865e-01, -1.45859e-01, 3.97222e-02, -6.77557e-03 }, // 57/128 - { -6.62802e-03, 3.83650e-02, -1.36969e-01, 5.51849e-01, 6.65779e-01, -1.45641e-01, 3.97532e-02, -6.78771e-03 }, // 58/128 - { -6.66238e-03, 3.86006e-02, -1.38094e-01, 5.61631e-01, 6.56621e-01, -1.45343e-01, 3.97610e-02, -6.79588e-03 }, // 59/128 - { -6.69300e-03, 3.88151e-02, -1.39150e-01, 5.71370e-01, 6.47394e-01, -1.44963e-01, 3.97458e-02, -6.80007e-03 }, // 60/128 - { -6.71985e-03, 3.90083e-02, -1.40136e-01, 5.81063e-01, 6.38099e-01, -1.44503e-01, 3.97077e-02, -6.80032e-03 }, // 61/128 - { -6.74291e-03, 3.91800e-02, -1.41050e-01, 5.90706e-01, 6.28739e-01, -1.43965e-01, 3.96469e-02, -6.79662e-03 }, // 62/128 - { -6.76214e-03, 3.93299e-02, -1.41891e-01, 6.00298e-01, 6.19318e-01, -1.43350e-01, 3.95635e-02, -6.78902e-03 }, // 63/128 - { -6.77751e-03, 3.94578e-02, -1.42658e-01, 6.09836e-01, 6.09836e-01, -1.42658e-01, 3.94578e-02, -6.77751e-03 }, // 64/128 - { -6.78902e-03, 3.95635e-02, -1.43350e-01, 6.19318e-01, 6.00298e-01, -1.41891e-01, 3.93299e-02, -6.76214e-03 }, // 65/128 - { -6.79662e-03, 3.96469e-02, -1.43965e-01, 6.28739e-01, 5.90706e-01, -1.41050e-01, 3.91800e-02, -6.74291e-03 }, // 66/128 - { -6.80032e-03, 3.97077e-02, -1.44503e-01, 6.38099e-01, 5.81063e-01, -1.40136e-01, 3.90083e-02, -6.71985e-03 }, // 67/128 - { -6.80007e-03, 3.97458e-02, -1.44963e-01, 6.47394e-01, 5.71370e-01, -1.39150e-01, 3.88151e-02, -6.69300e-03 }, // 68/128 - { -6.79588e-03, 3.97610e-02, -1.45343e-01, 6.56621e-01, 5.61631e-01, -1.38094e-01, 3.86006e-02, -6.66238e-03 }, // 69/128 - { -6.78771e-03, 3.97532e-02, -1.45641e-01, 6.65779e-01, 5.51849e-01, -1.36969e-01, 3.83650e-02, -6.62802e-03 }, // 70/128 - { -6.77557e-03, 3.97222e-02, -1.45859e-01, 6.74865e-01, 5.42025e-01, -1.35775e-01, 3.81085e-02, -6.58996e-03 }, // 71/128 - { -6.75943e-03, 3.96678e-02, -1.45993e-01, 6.83875e-01, 5.32164e-01, -1.34515e-01, 3.78315e-02, -6.54823e-03 }, // 72/128 - { -6.73929e-03, 3.95900e-02, -1.46043e-01, 6.92808e-01, 5.22267e-01, -1.33190e-01, 3.75341e-02, -6.50285e-03 }, // 73/128 - { -6.71514e-03, 3.94886e-02, -1.46009e-01, 7.01661e-01, 5.12337e-01, -1.31800e-01, 3.72167e-02, -6.45388e-03 }, // 74/128 - { -6.68698e-03, 3.93636e-02, -1.45889e-01, 7.10431e-01, 5.02377e-01, -1.30347e-01, 3.68795e-02, -6.40135e-03 }, // 75/128 - { -6.65479e-03, 3.92147e-02, -1.45682e-01, 7.19116e-01, 4.92389e-01, -1.28832e-01, 3.65227e-02, -6.34530e-03 }, // 76/128 - { -6.61859e-03, 3.90420e-02, -1.45387e-01, 7.27714e-01, 4.82377e-01, -1.27258e-01, 3.61468e-02, -6.28577e-03 }, // 77/128 - { -6.57836e-03, 3.88454e-02, -1.45004e-01, 7.36222e-01, 4.72342e-01, -1.25624e-01, 3.57519e-02, -6.22280e-03 }, // 78/128 - { -6.53412e-03, 3.86247e-02, -1.44531e-01, 7.44637e-01, 4.62289e-01, -1.23933e-01, 3.53384e-02, -6.15644e-03 }, // 79/128 - { -6.48585e-03, 3.83800e-02, -1.43968e-01, 7.52958e-01, 4.52218e-01, -1.22185e-01, 3.49066e-02, -6.08674e-03 }, // 80/128 - { -6.43358e-03, 3.81111e-02, -1.43313e-01, 7.61181e-01, 4.42134e-01, -1.20382e-01, 3.44568e-02, -6.01374e-03 }, // 81/128 - { -6.37730e-03, 3.78182e-02, -1.42566e-01, 7.69305e-01, 4.32038e-01, -1.18526e-01, 3.39894e-02, -5.93749e-03 }, // 82/128 - { -6.31703e-03, 3.75010e-02, -1.41727e-01, 7.77327e-01, 4.21934e-01, -1.16618e-01, 3.35046e-02, -5.85804e-03 }, // 83/128 - { -6.25277e-03, 3.71596e-02, -1.40794e-01, 7.85244e-01, 4.11823e-01, -1.14659e-01, 3.30027e-02, -5.77544e-03 }, // 84/128 - { -6.18454e-03, 3.67941e-02, -1.39767e-01, 7.93055e-01, 4.01710e-01, -1.12650e-01, 3.24843e-02, -5.68976e-03 }, // 85/128 - { -6.11236e-03, 3.64044e-02, -1.38644e-01, 8.00757e-01, 3.91596e-01, -1.10593e-01, 3.19495e-02, -5.60103e-03 }, // 86/128 - { -6.03624e-03, 3.59905e-02, -1.37426e-01, 8.08348e-01, 3.81484e-01, -1.08490e-01, 3.13987e-02, -5.50931e-03 }, // 87/128 - { -5.95620e-03, 3.55525e-02, -1.36111e-01, 8.15826e-01, 3.71376e-01, -1.06342e-01, 3.08323e-02, -5.41467e-03 }, // 88/128 - { -5.87227e-03, 3.50903e-02, -1.34699e-01, 8.23188e-01, 3.61276e-01, -1.04150e-01, 3.02507e-02, -5.31716e-03 }, // 89/128 - { -5.78446e-03, 3.46042e-02, -1.33189e-01, 8.30432e-01, 3.51186e-01, -1.01915e-01, 2.96543e-02, -5.21683e-03 }, // 90/128 - { -5.69280e-03, 3.40940e-02, -1.31581e-01, 8.37557e-01, 3.41109e-01, -9.96402e-02, 2.90433e-02, -5.11376e-03 }, // 91/128 - { -5.59731e-03, 3.35600e-02, -1.29874e-01, 8.44559e-01, 3.31048e-01, -9.73254e-02, 2.84182e-02, -5.00800e-03 }, // 92/128 - { -5.49804e-03, 3.30021e-02, -1.28068e-01, 8.51437e-01, 3.21004e-01, -9.49727e-02, 2.77794e-02, -4.89961e-03 }, // 93/128 - { -5.39500e-03, 3.24205e-02, -1.26161e-01, 8.58189e-01, 3.10980e-01, -9.25834e-02, 2.71272e-02, -4.78866e-03 }, // 94/128 - { -5.28823e-03, 3.18153e-02, -1.24154e-01, 8.64812e-01, 3.00980e-01, -9.01591e-02, 2.64621e-02, -4.67520e-03 }, // 95/128 - { -5.17776e-03, 3.11866e-02, -1.22047e-01, 8.71305e-01, 2.91006e-01, -8.77011e-02, 2.57844e-02, -4.55932e-03 }, // 96/128 - { -5.06363e-03, 3.05345e-02, -1.19837e-01, 8.77666e-01, 2.81060e-01, -8.52109e-02, 2.50946e-02, -4.44107e-03 }, // 97/128 - { -4.94589e-03, 2.98593e-02, -1.17526e-01, 8.83893e-01, 2.71144e-01, -8.26900e-02, 2.43930e-02, -4.32052e-03 }, // 98/128 - { -4.82456e-03, 2.91609e-02, -1.15113e-01, 8.89984e-01, 2.61263e-01, -8.01399e-02, 2.36801e-02, -4.19774e-03 }, // 99/128 - { -4.69970e-03, 2.84397e-02, -1.12597e-01, 8.95936e-01, 2.51417e-01, -7.75620e-02, 2.29562e-02, -4.07279e-03 }, // 100/128 - { -4.57135e-03, 2.76957e-02, -1.09978e-01, 9.01749e-01, 2.41609e-01, -7.49577e-02, 2.22218e-02, -3.94576e-03 }, // 101/128 - { -4.43955e-03, 2.69293e-02, -1.07256e-01, 9.07420e-01, 2.31843e-01, -7.23286e-02, 2.14774e-02, -3.81671e-03 }, // 102/128 - { -4.30435e-03, 2.61404e-02, -1.04430e-01, 9.12947e-01, 2.22120e-01, -6.96762e-02, 2.07233e-02, -3.68570e-03 }, // 103/128 - { -4.16581e-03, 2.53295e-02, -1.01501e-01, 9.18329e-01, 2.12443e-01, -6.70018e-02, 1.99599e-02, -3.55283e-03 }, // 104/128 - { -4.02397e-03, 2.44967e-02, -9.84679e-02, 9.23564e-01, 2.02814e-01, -6.43069e-02, 1.91877e-02, -3.41815e-03 }, // 105/128 - { -3.87888e-03, 2.36423e-02, -9.53307e-02, 9.28650e-01, 1.93236e-01, -6.15931e-02, 1.84071e-02, -3.28174e-03 }, // 106/128 - { -3.73062e-03, 2.27664e-02, -9.20893e-02, 9.33586e-01, 1.83711e-01, -5.88617e-02, 1.76185e-02, -3.14367e-03 }, // 107/128 - { -3.57923e-03, 2.18695e-02, -8.87435e-02, 9.38371e-01, 1.74242e-01, -5.61142e-02, 1.68225e-02, -3.00403e-03 }, // 108/128 - { -3.42477e-03, 2.09516e-02, -8.52933e-02, 9.43001e-01, 1.64831e-01, -5.33522e-02, 1.60193e-02, -2.86289e-03 }, // 109/128 - { -3.26730e-03, 2.00132e-02, -8.17385e-02, 9.47477e-01, 1.55480e-01, -5.05770e-02, 1.52095e-02, -2.72032e-03 }, // 110/128 - { -3.10689e-03, 1.90545e-02, -7.80792e-02, 9.51795e-01, 1.46192e-01, -4.77900e-02, 1.43934e-02, -2.57640e-03 }, // 111/128 - { -2.94361e-03, 1.80759e-02, -7.43154e-02, 9.55956e-01, 1.36968e-01, -4.49929e-02, 1.35716e-02, -2.43121e-03 }, // 112/128 - { -2.77751e-03, 1.70776e-02, -7.04471e-02, 9.59958e-01, 1.27812e-01, -4.21869e-02, 1.27445e-02, -2.28483e-03 }, // 113/128 - { -2.60868e-03, 1.60599e-02, -6.64743e-02, 9.63798e-01, 1.18725e-01, -3.93735e-02, 1.19125e-02, -2.13733e-03 }, // 114/128 - { -2.43718e-03, 1.50233e-02, -6.23972e-02, 9.67477e-01, 1.09710e-01, -3.65541e-02, 1.10760e-02, -1.98880e-03 }, // 115/128 - { -2.26307e-03, 1.39681e-02, -5.82159e-02, 9.70992e-01, 1.00769e-01, -3.37303e-02, 1.02356e-02, -1.83931e-03 }, // 116/128 - { -2.08645e-03, 1.28947e-02, -5.39305e-02, 9.74342e-01, 9.19033e-02, -3.09033e-02, 9.39154e-03, -1.68894e-03 }, // 117/128 - { -1.90738e-03, 1.18034e-02, -4.95412e-02, 9.77526e-01, 8.31162e-02, -2.80746e-02, 8.54441e-03, -1.53777e-03 }, // 118/128 - { -1.72594e-03, 1.06946e-02, -4.50483e-02, 9.80543e-01, 7.44095e-02, -2.52457e-02, 7.69462e-03, -1.38589e-03 }, // 119/128 - { -1.54221e-03, 9.56876e-03, -4.04519e-02, 9.83392e-01, 6.57852e-02, -2.24178e-02, 6.84261e-03, -1.23337e-03 }, // 120/128 - { -1.35627e-03, 8.42626e-03, -3.57525e-02, 9.86071e-01, 5.72454e-02, -1.95925e-02, 5.98883e-03, -1.08030e-03 }, // 121/128 - { -1.16820e-03, 7.26755e-03, -3.09503e-02, 9.88580e-01, 4.87921e-02, -1.67710e-02, 5.13372e-03, -9.26747e-04 }, // 122/128 - { -9.78093e-04, 6.09305e-03, -2.60456e-02, 9.90917e-01, 4.04274e-02, -1.39548e-02, 4.27773e-03, -7.72802e-04 }, // 123/128 - { -7.86031e-04, 4.90322e-03, -2.10389e-02, 9.93082e-01, 3.21531e-02, -1.11453e-02, 3.42130e-03, -6.18544e-04 }, // 124/128 - { -5.92100e-04, 3.69852e-03, -1.59305e-02, 9.95074e-01, 2.39714e-02, -8.34364e-03, 2.56486e-03, -4.64053e-04 }, // 125/128 - { -3.96391e-04, 2.47942e-03, -1.07209e-02, 9.96891e-01, 1.58840e-02, -5.55134e-03, 1.70888e-03, -3.09412e-04 }, // 126/128 - { -1.98993e-04, 1.24642e-03, -5.41054e-03, 9.98534e-01, 7.89295e-03, -2.76968e-03, 8.53777e-04, -1.54700e-04 }, // 127/128 - { 0.00000e+00, 0.00000e+00, 0.00000e+00, 1.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00 }, // 128/128 -}; - diff --git a/gnuradio-core/src/lib/filter/qa_ccomplex_dotprod_x86.cc b/gnuradio-core/src/lib/filter/qa_ccomplex_dotprod_x86.cc deleted file mode 100644 index 0d7b878da5..0000000000 --- a/gnuradio-core/src/lib/filter/qa_ccomplex_dotprod_x86.cc +++ /dev/null @@ -1,341 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <cppunit/TestAssert.h> -#include <qa_ccomplex_dotprod_x86.h> -#include <ccomplex_dotprod_x86.h> -#include <string.h> -#include <iostream> -#include <malloc16.h> -#include <sse_debug.h> -#include <cmath> -#include <gr_cpu.h> -#include <random.h> - -using std::cerr; - -/// Macro for primitive value comparisons -#define assertcomplexEqual(expected0,expected1,actual,delta) \ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected0, actual[0], delta); \ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected1, actual[1], delta); - - -#define MAX_BLKS 10 -#define FLOATS_PER_BLK 4 - -#define ERR_DELTA (1e-6) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = rint (uniform () * 32767); -} - -static void -zero_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = 0.0; -} - -void -ref_ccomplex_dotprod (const float *input, - const float *taps, unsigned n_2_ccomplex_blocks, - float *result) -{ - float sum0[2] = {0,0}; - float sum1[2] = {0,0}; - - do { - - sum0[0] += input[0] * taps[0] - input[1] * taps[1]; - sum0[1] += input[0] * taps[1] + input[1] * taps[0]; - sum1[0] += input[2] * taps[2] - input[3] * taps[3]; - sum1[1] += input[2] * taps[3] + input[3] * taps[2]; - - input += 4; - taps += 4; - - } while (--n_2_ccomplex_blocks != 0); - - - result[0] = sum0[0] + sum1[0]; - result[1] = sum0[1] + sum1[1]; -} - -void -qa_ccomplex_dotprod_x86::setUp () -{ - taps = (float *) calloc16Align (MAX_BLKS, - sizeof (float) * FLOATS_PER_BLK); - - input = (float *) calloc16Align (MAX_BLKS, - sizeof (float) * FLOATS_PER_BLK); - - if (taps == 0 || input == 0) - abort (); -} - -void -qa_ccomplex_dotprod_x86::tearDown () -{ - free16Align (taps); - free16Align (input); - taps = 0; - input = 0; -} - - -void -qa_ccomplex_dotprod_x86::zb () // "zero both" -{ - zero_floats (taps, MAX_BLKS * FLOATS_PER_BLK); - zero_floats (input, MAX_BLKS * FLOATS_PER_BLK); -} - -// -// t1 -// - -void -qa_ccomplex_dotprod_x86::t1_base (ccomplex_dotprod_t ccomplex_dotprod) -{ - float result[2]; - - // cerr << "Testing dump_xmm_regs\n"; - // dump_xmm_regs (); - - // test basic cases, 1 block - - zb (); - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (0.0, 0.0, result, ERR_DELTA); - - // vary each input - - zb (); - input[0] = 1.0; taps[0] = 1.0; taps[1] = -1.0; - ccomplex_dotprod (input, taps, 1, result); - //cerr << result[0] << " " << result[1] << "\n"; - assertcomplexEqual (1.0, -1.0, result, ERR_DELTA); - - zb (); - input[1] = 2.0; taps[0] = 1.0; taps[1] = -1.0; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (2.0, 2.0, result, ERR_DELTA); - - zb (); - input[2] = 3.0; taps[2] = 1.0; taps[3] = -1.0; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (3.0, -3.0, result, ERR_DELTA); - - zb (); - input[3] = 4.0; taps[2] = 1.0; taps[3] = -1.0; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (4.0, 4.0, result, ERR_DELTA); - - // vary each tap - - zb (); - input[0] = 1.0; taps[0] = 0.5; taps[1] = -0.5; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (0.5, -0.5, result, ERR_DELTA); - - zb (); - input[0] = 1.0; taps[0] = 2.0; taps[1] = -2.0; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (2.0, -2.0, result, ERR_DELTA); - - zb (); - input[0] = 1.0; taps[0] = 3.0; taps[1] = -3.0; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (3.0, -3.0, result, ERR_DELTA); - - zb (); - input[0] = 1.0; taps[0] = 4.0; taps[1] = -4.0; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (4.0, -4.0, result, ERR_DELTA); -} - -// -// t2 -// -void -qa_ccomplex_dotprod_x86::t2_base (ccomplex_dotprod_t ccomplex_dotprod) -{ - float result[2]; - - zb (); - input[0] = 1.0; input[1] = 3.0; taps[0] = 5.0; taps[1] = -2.0; - - //1*5-3*-2 =11, 1*-2+3*5=13 - - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (11.0, 13.0, result, ERR_DELTA); - - //7*5-13*-5 =100, 7*-5+13*5=30 - - input[2] = 7.0; input[3] = 13.0; taps[2] = 5.0; taps[3] = -5.0; - - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (111.0, 43.0, result, ERR_DELTA); - - input[4] = 19; input[5] = -19; taps[4] = 23.0; taps[5] = -23.0; - - //19*23--19*-23 =0, 19*-23+-19*23=-874 - - ccomplex_dotprod (input, taps, 2, result); - assertcomplexEqual (111.0, -831.0, result, ERR_DELTA); - -} - -// -// t3 -// -void -qa_ccomplex_dotprod_x86::t3_base (ccomplex_dotprod_t ccomplex_dotprod) -{ - srandom (0); // we want reproducibility - - for (unsigned int i = 0; i < 10; i++){ - random_floats (input, MAX_BLKS * FLOATS_PER_BLK); - random_floats (taps, MAX_BLKS * FLOATS_PER_BLK); - - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - float ref[2]; - ref_ccomplex_dotprod (input, taps, MAX_BLKS, ref); - float calc[2]; - ccomplex_dotprod (input, taps, MAX_BLKS, calc); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref[0], - calc[0], - fabs (ref[0]) * 1e-4); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref[1], - calc[1], - fabs (ref[1]) * 1e-4); - } -} - -void -qa_ccomplex_dotprod_x86::t1_3dnowext () -{ - if (!gr_cpu::has_3dnowext ()){ - cerr << "No 3DNow!Ext support; not tested\n"; - } - else - t1_base (ccomplex_dotprod_3dnowext); -} - -void -qa_ccomplex_dotprod_x86::t2_3dnowext () -{ - if (!gr_cpu::has_3dnowext ()){ - cerr << "No 3DNow!Ext support; not tested\n"; - } - else - t2_base (ccomplex_dotprod_3dnowext); -} - -void -qa_ccomplex_dotprod_x86::t3_3dnowext () -{ - if (!gr_cpu::has_3dnowext ()){ - cerr << "No 3DNow!Ext support; not tested\n"; - } - else - t3_base (ccomplex_dotprod_3dnowext); -} - -void -qa_ccomplex_dotprod_x86::t1_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t1_base (ccomplex_dotprod_3dnow); -} - -void -qa_ccomplex_dotprod_x86::t2_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t2_base (ccomplex_dotprod_3dnow); -} - -void -qa_ccomplex_dotprod_x86::t3_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t3_base (ccomplex_dotprod_3dnow); -} - -void -qa_ccomplex_dotprod_x86::t1_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t1_base (ccomplex_dotprod_sse); -} - -void -qa_ccomplex_dotprod_x86::t2_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t2_base (ccomplex_dotprod_sse); -} - -void -qa_ccomplex_dotprod_x86::t3_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t3_base (ccomplex_dotprod_sse); -} - diff --git a/gnuradio-core/src/lib/filter/qa_ccomplex_dotprod_x86.h b/gnuradio-core/src/lib/filter/qa_ccomplex_dotprod_x86.h deleted file mode 100644 index d24561c72b..0000000000 --- a/gnuradio-core/src/lib/filter/qa_ccomplex_dotprod_x86.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_CCOMPLEX_DOTPROD_X86_H_ -#define _QA_CCOMPLEX_DOTPROD_X86_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_ccomplex_dotprod_x86 : public CppUnit::TestCase { - public: - void setUp (); - void tearDown (); - - CPPUNIT_TEST_SUITE (qa_ccomplex_dotprod_x86); - CPPUNIT_TEST (t1_3dnowext); - CPPUNIT_TEST (t2_3dnowext); - CPPUNIT_TEST (t3_3dnowext); - CPPUNIT_TEST (t1_3dnow); - CPPUNIT_TEST (t2_3dnow); - CPPUNIT_TEST (t3_3dnow); - CPPUNIT_TEST (t1_sse); - CPPUNIT_TEST (t2_sse); - CPPUNIT_TEST (t3_sse); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t1_3dnowext (); - void t2_3dnowext (); - void t3_3dnowext (); - void t1_3dnow (); - void t2_3dnow (); - void t3_3dnow (); - void t1_sse (); - void t2_sse (); - void t3_sse (); - - - typedef void (*ccomplex_dotprod_t)(const float *input, - const float *taps, - unsigned n_2_ccomplex_blocks, - float *result); - - void t1_base (ccomplex_dotprod_t); - void t2_base (ccomplex_dotprod_t); - void t3_base (ccomplex_dotprod_t); - - void zb (); - - float *taps; // 16-byte aligned - float *input; // 16-byte aligned -}; - - -#endif /* _QA_CCOMPLEX_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_complex_dotprod_x86.cc b/gnuradio-core/src/lib/filter/qa_complex_dotprod_x86.cc deleted file mode 100644 index a21b95f633..0000000000 --- a/gnuradio-core/src/lib/filter/qa_complex_dotprod_x86.cc +++ /dev/null @@ -1,347 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <cppunit/TestAssert.h> -#include <qa_complex_dotprod_x86.h> -#include <complex_dotprod_x86.h> -#include <string.h> -#include <iostream> -#include <malloc16.h> -#include <sse_debug.h> -#include <cmath> -#include <gr_cpu.h> -#include <random.h> - -using std::cerr; - -/// Macro for primitive value comparisons -#define assertcomplexEqual(expected0,expected1,actual,delta) \ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected0, actual[0], delta); \ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected1, actual[1], delta); - - -#define MAX_BLKS 10 -#define FLOATS_PER_BLK 4 -#define SHORTS_PER_BLK 2 - -#define ERR_DELTA (1e-6) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = rint (uniform () * 32767); -} - -static void -zero_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = 0.0; -} - -static void -random_shorts (short *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (short) rint (uniform () * 32767); -} - -static void -zero_shorts (short *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = 0; -} - -void -ref_complex_dotprod (const short *input, - const float *taps, unsigned n_2_complex_blocks, - float *result) -{ - float sum0[2] = {0,0}; - float sum1[2] = {0,0}; - - do { - - sum0[0] += input[0] * taps[0]; - sum0[1] += input[0] * taps[1]; - sum1[0] += input[1] * taps[2]; - sum1[1] += input[1] * taps[3]; - - input += 2; - taps += 4; - - } while (--n_2_complex_blocks != 0); - - - result[0] = sum0[0] + sum1[0]; - result[1] = sum0[1] + sum1[1]; -} - -void -qa_complex_dotprod_x86::setUp () -{ - taps = (float *) calloc16Align (MAX_BLKS, - sizeof (float) * FLOATS_PER_BLK); - - input = (short *) calloc16Align (MAX_BLKS, - sizeof (short) * SHORTS_PER_BLK); - - if (taps == 0 || input == 0) - abort (); -} - -void -qa_complex_dotprod_x86::tearDown () -{ - free16Align (taps); - free16Align (input); - taps = 0; - input = 0; -} - - -void -qa_complex_dotprod_x86::zb () // "zero both" -{ - zero_floats (taps, MAX_BLKS * FLOATS_PER_BLK); - zero_shorts (input, MAX_BLKS * SHORTS_PER_BLK); -} - -// -// t1 -// - -void -qa_complex_dotprod_x86::t1_base (complex_dotprod_t complex_dotprod) -{ - float result[2]; - - // cerr << "Testing dump_xmm_regs\n"; - // dump_xmm_regs (); - - // test basic cases, 1 block - - zb (); - complex_dotprod (input, taps, 1, result); - assertcomplexEqual (0.0, 0.0, result, ERR_DELTA); - - // vary each input - - zb (); - input[0] = 1; taps[0] = 1.0; taps[1] = -1.0; - complex_dotprod (input, taps, 1, result); - //cerr << result[0] << " " << result[1] << "\n"; - assertcomplexEqual (1.0, -1.0, result, ERR_DELTA); - - zb (); - input[1] = 2; taps[2] = 1.0; taps[3] = -1.0; - complex_dotprod (input, taps, 1, result); - assertcomplexEqual (2.0, -2.0, result, ERR_DELTA); - - zb (); - input[2] = 3; taps[4] = 1.0; taps[5] = -1.0; - complex_dotprod (input, taps, 2, result); - assertcomplexEqual (3.0, -3.0, result, ERR_DELTA); - - zb (); - input[3] = 4; taps[6] = 1.0; taps[7] = -1.0; - complex_dotprod (input, taps, 2, result); - assertcomplexEqual (4.0, -4.0, result, ERR_DELTA); - - // vary each tap - - zb (); - input[0] = 1; taps[0] = 0.5; taps[1] = -0.5; - complex_dotprod (input, taps, 1, result); - assertcomplexEqual (0.5, -0.5, result, ERR_DELTA); - - zb (); - input[0] = 1; taps[0] = 2.0; taps[1] = -2.0; - complex_dotprod (input, taps, 1, result); - assertcomplexEqual (2.0, -2.0, result, ERR_DELTA); - - zb (); - input[0] = 1; taps[0] = 3.0; taps[1] = -3.0; - complex_dotprod (input, taps, 1, result); - assertcomplexEqual (3.0, -3.0, result, ERR_DELTA); - - zb (); - input[0] = 1; taps[0] = 4.0; taps[1] = -4.0; - complex_dotprod (input, taps, 1, result); - assertcomplexEqual (4.0, -4.0, result, ERR_DELTA); -} - -// -// t2 -// -void -qa_complex_dotprod_x86::t2_base (complex_dotprod_t complex_dotprod) -{ - float result[2]; - - zb (); - input[0] = 1; taps[0] = 2.0; taps[1] = -2.0; - input[1] = 3; taps[2] = 5.0; taps[3] = -5.0; - input[2] = 7; taps[4] = 11.0; taps[5] = -11.0; - input[3] = 13; taps[6] = 17.0; taps[7] = -17.0; - - complex_dotprod (input, taps, 2, result); - assertcomplexEqual (315.0, -315.0, result, ERR_DELTA); - - input[4] = 19; taps[8] = 23.0; taps[9] = -23.0; - complex_dotprod (input, taps, 3, result); - assertcomplexEqual (752.0, -752.0, result, ERR_DELTA); - -} - -// -// t3 -// -void -qa_complex_dotprod_x86::t3_base (complex_dotprod_t complex_dotprod) -{ - srandom (0); // we want reproducibility - - for (unsigned int i = 0; i < 10; i++){ - random_shorts (input, MAX_BLKS * SHORTS_PER_BLK); - random_floats (taps, MAX_BLKS * FLOATS_PER_BLK); - - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - float ref[2]; - ref_complex_dotprod (input, taps, MAX_BLKS, ref); - float calc[2]; - complex_dotprod (input, taps, MAX_BLKS, calc); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref[0], - calc[0], - fabs (ref[0]) * 1e-4); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref[1], - calc[1], - fabs (ref[1]) * 1e-4); - } -} - -void -qa_complex_dotprod_x86::t1_3dnowext () -{ - if (!gr_cpu::has_3dnowext ()){ - cerr << "No 3DNow!Ext support; not tested\n"; - } - else - t1_base (complex_dotprod_3dnowext); -} - -void -qa_complex_dotprod_x86::t2_3dnowext () -{ - if (!gr_cpu::has_3dnowext ()){ - cerr << "No 3DNow!Ext support; not tested\n"; - } - else - t2_base (complex_dotprod_3dnowext); -} - -void -qa_complex_dotprod_x86::t3_3dnowext () -{ - if (!gr_cpu::has_3dnowext ()){ - cerr << "No 3DNow!Ext support; not tested\n"; - } - else - t3_base (complex_dotprod_3dnowext); -} - -void -qa_complex_dotprod_x86::t1_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t1_base (complex_dotprod_3dnow); -} - -void -qa_complex_dotprod_x86::t2_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t2_base (complex_dotprod_3dnow); -} - -void -qa_complex_dotprod_x86::t3_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t3_base (complex_dotprod_3dnow); -} - -void -qa_complex_dotprod_x86::t1_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t1_base (complex_dotprod_sse); -} - -void -qa_complex_dotprod_x86::t2_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t2_base (complex_dotprod_sse); -} - -void -qa_complex_dotprod_x86::t3_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t3_base (complex_dotprod_sse); -} - diff --git a/gnuradio-core/src/lib/filter/qa_complex_dotprod_x86.h b/gnuradio-core/src/lib/filter/qa_complex_dotprod_x86.h deleted file mode 100644 index 9f9b460399..0000000000 --- a/gnuradio-core/src/lib/filter/qa_complex_dotprod_x86.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_COMPLEX_DOTPROD_X86_H_ -#define _QA_COMPLEX_DOTPROD_X86_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_complex_dotprod_x86 : public CppUnit::TestCase { - public: - void setUp (); - void tearDown (); - - CPPUNIT_TEST_SUITE (qa_complex_dotprod_x86); - CPPUNIT_TEST (t1_3dnowext); - CPPUNIT_TEST (t2_3dnowext); - CPPUNIT_TEST (t3_3dnowext); - CPPUNIT_TEST (t1_3dnow); - CPPUNIT_TEST (t2_3dnow); - CPPUNIT_TEST (t3_3dnow); - CPPUNIT_TEST (t1_sse); - CPPUNIT_TEST (t2_sse); - CPPUNIT_TEST (t3_sse); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t1_3dnowext (); - void t2_3dnowext (); - void t3_3dnowext (); - void t1_3dnow (); - void t2_3dnow (); - void t3_3dnow (); - void t1_sse (); - void t2_sse (); - void t3_sse (); - - - typedef void (*complex_dotprod_t)(const short *input, - const float *taps, - unsigned n_2_complex_blocks, - float *result); - - void t1_base (complex_dotprod_t); - void t2_base (complex_dotprod_t); - void t3_base (complex_dotprod_t); - - void zb (); - - float *taps; // 16-byte aligned - short *input; // 16-byte aligned -}; - - -#endif /* _QA_COMPLEX_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_dotprod.h b/gnuradio-core/src/lib/filter/qa_dotprod.h deleted file mode 100644 index bd5ba8f3ae..0000000000 --- a/gnuradio-core/src/lib/filter/qa_dotprod.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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_DOTPROD_H_ -#define _QA_DOTPROD_H_ - -#include <cppunit/TestSuite.h> - -CppUnit::TestSuite *qa_dotprod_suite (); - -#endif // _QA_DOTPROD_H_ - diff --git a/gnuradio-core/src/lib/filter/qa_dotprod_armv7_a.cc b/gnuradio-core/src/lib/filter/qa_dotprod_armv7_a.cc deleted file mode 100644 index 1e1ded7ea1..0000000000 --- a/gnuradio-core/src/lib/filter/qa_dotprod_armv7_a.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#include "qa_dotprod.h" - -CppUnit::TestSuite * -qa_dotprod_suite () -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite ("dotprod"); - - // empty test suite - - return s; -} diff --git a/gnuradio-core/src/lib/filter/qa_dotprod_generic.cc b/gnuradio-core/src/lib/filter/qa_dotprod_generic.cc deleted file mode 100644 index 2c49d1d28f..0000000000 --- a/gnuradio-core/src/lib/filter/qa_dotprod_generic.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 "qa_dotprod.h" - -CppUnit::TestSuite * -qa_dotprod_suite () -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite ("dotprod"); - - // empty test suite - - return s; -} diff --git a/gnuradio-core/src/lib/filter/qa_dotprod_powerpc.cc b/gnuradio-core/src/lib/filter/qa_dotprod_powerpc.cc deleted file mode 100644 index 2c49d1d28f..0000000000 --- a/gnuradio-core/src/lib/filter/qa_dotprod_powerpc.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 "qa_dotprod.h" - -CppUnit::TestSuite * -qa_dotprod_suite () -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite ("dotprod"); - - // empty test suite - - return s; -} diff --git a/gnuradio-core/src/lib/filter/qa_dotprod_x86.cc b/gnuradio-core/src/lib/filter/qa_dotprod_x86.cc deleted file mode 100644 index ec5625f10c..0000000000 --- a/gnuradio-core/src/lib/filter/qa_dotprod_x86.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 "qa_dotprod.h" -#include "qa_float_dotprod_x86.h" -#include "qa_complex_dotprod_x86.h" -#include "qa_ccomplex_dotprod_x86.h" - -CppUnit::TestSuite * -qa_dotprod_suite () -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite ("dotprod"); - - s->addTest (qa_float_dotprod_x86::suite ()); - s->addTest (qa_complex_dotprod_x86::suite ()); - s->addTest (qa_ccomplex_dotprod_x86::suite ()); - - return s; -} diff --git a/gnuradio-core/src/lib/filter/qa_filter.cc b/gnuradio-core/src/lib/filter/qa_filter.cc deleted file mode 100644 index 6296350845..0000000000 --- a/gnuradio-core/src/lib/filter/qa_filter.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2002,2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * 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_filter.h> -#include <qa_gr_fir_ccf.h> -#include <qa_gr_fir_fff.h> -#include <qa_gr_fir_ccc.h> -#include <qa_gr_fir_fcc.h> -#include <qa_gr_fir_scc.h> -#include <qa_gr_firdes.h> -#include <qa_dotprod.h> -#include <qa_gri_mmse_fir_interpolator.h> -#include <qa_gri_mmse_fir_interpolator_cc.h> -#include <qa_gr_rotator.h> -#include <qa_gri_fir_filter_with_buffer_ccf.h> -#include <qa_gri_fir_filter_with_buffer_ccc.h> -#include <qa_gri_fir_filter_with_buffer_fcc.h> -#include <qa_gri_fir_filter_with_buffer_fff.h> -#include <qa_gri_fir_filter_with_buffer_fsf.h> -#include <qa_gri_fir_filter_with_buffer_scc.h> - -CppUnit::TestSuite * -qa_filter::suite () -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite ("filter"); - - s->addTest (qa_dotprod_suite ()); - s->addTest (qa_gr_fir_fff::suite ()); - s->addTest (qa_gr_fir_ccc::suite ()); - s->addTest (qa_gr_fir_fcc::suite ()); - s->addTest (qa_gr_fir_scc::suite ()); - s->addTest (qa_gr_fir_ccf::suite ()); - s->addTest (qa_gri_mmse_fir_interpolator::suite ()); - s->addTest (qa_gri_mmse_fir_interpolator_cc::suite ()); - s->addTest (qa_gr_rotator::suite ()); - s->addTest (qa_gri_fir_filter_with_buffer_ccf::suite ()); - s->addTest (qa_gri_fir_filter_with_buffer_ccc::suite ()); - s->addTest (qa_gri_fir_filter_with_buffer_fcc::suite ()); - s->addTest (qa_gri_fir_filter_with_buffer_fff::suite ()); - s->addTest (qa_gri_fir_filter_with_buffer_fsf::suite ()); - s->addTest (qa_gri_fir_filter_with_buffer_scc::suite ()); - - return s; -} diff --git a/gnuradio-core/src/lib/filter/qa_filter.h b/gnuradio-core/src/lib/filter/qa_filter.h deleted file mode 100644 index 740d05ce40..0000000000 --- a/gnuradio-core/src/lib/filter/qa_filter.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _QA_FILTER_H_ -#define _QA_FILTER_H_ - -#include <gruel/attributes.h> -#include <cppunit/TestSuite.h> - -//! collect all the tests for the gr directory - -class __GR_ATTR_EXPORT qa_filter { - public: - //! return suite of tests for all of gr directory - static CppUnit::TestSuite *suite (); -}; - - -#endif /* _QA_FILTER_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_float_dotprod_x86.cc b/gnuradio-core/src/lib/filter/qa_float_dotprod_x86.cc deleted file mode 100644 index f8752d0716..0000000000 --- a/gnuradio-core/src/lib/filter/qa_float_dotprod_x86.cc +++ /dev/null @@ -1,270 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <cppunit/TestAssert.h> -#include <qa_float_dotprod_x86.h> -#include <float_dotprod_x86.h> -#include <string.h> -#include <iostream> -#include <malloc16.h> -#include <sse_debug.h> -#include <cmath> -#include <gr_cpu.h> -#include <random.h> - -using std::cerr; - - -#define MAX_BLKS 10 -#define FLOATS_PER_BLK 4 - -#define ERR_DELTA (1e-6) - - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = random () - RANDOM_MAX/2; -} - -static void -zero_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = 0.0; -} - -float -ref_float_dotprod (const float *input, - const float *taps, unsigned n_4_float_blocks) -{ - float sum0 = 0; - float sum1 = 0; - float sum2 = 0; - float sum3 = 0; - - do { - - sum0 += input[0] * taps[0]; - sum1 += input[1] * taps[1]; - sum2 += input[2] * taps[2]; - sum3 += input[3] * taps[3]; - - input += 4; - taps += 4; - - } while (--n_4_float_blocks != 0); - - - return sum0 + sum1 + sum2 + sum3; -} - -void -qa_float_dotprod_x86::setUp () -{ - taps = (float *) calloc16Align (MAX_BLKS, - sizeof (float) * FLOATS_PER_BLK); - - input = (float *) calloc16Align (MAX_BLKS, - sizeof (float) * FLOATS_PER_BLK); - - if (taps == 0 || input == 0) - abort (); -} - -void -qa_float_dotprod_x86::tearDown () -{ - free16Align (taps); - free16Align (input); - taps = 0; - input = 0; -} - - -void -qa_float_dotprod_x86::zb () // "zero both" -{ - zero_floats (taps, MAX_BLKS * FLOATS_PER_BLK); - zero_floats (input, MAX_BLKS * FLOATS_PER_BLK); -} - -// -// t1 -// - -void -qa_float_dotprod_x86::t1_base (float_dotprod_t float_dotprod) -{ - - // cerr << "Testing dump_xmm_regs\n"; - // dump_xmm_regs (); - - // test basic cases, 1 block - - zb (); - CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, float_dotprod (input, taps, 1), ERR_DELTA); - - // vary each input - - zb (); - input[0] = 0.5; taps[0] = 1.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (0.5, float_dotprod (input, taps, 1), ERR_DELTA); - - zb (); - input[1] = 2.0; taps[1] = 1.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (2.0, float_dotprod (input, taps, 1), ERR_DELTA); - - zb (); - input[2] = 3.0; taps[2] = 1.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0, float_dotprod (input, taps, 1), ERR_DELTA); - - zb (); - input[3] = 4.0; taps[3] = 1.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (4.0, float_dotprod (input, taps, 1), ERR_DELTA); - - // vary each tap - - zb (); - input[0] = 1.0; taps[0] = 0.5; - CPPUNIT_ASSERT_DOUBLES_EQUAL (0.5, float_dotprod (input, taps, 1), ERR_DELTA); - - zb (); - input[0] = 1.0; taps[0] = 2.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (2.0, float_dotprod (input, taps, 1), ERR_DELTA); - - zb (); - input[0] = 1.0; taps[0] = 3.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0, float_dotprod (input, taps, 1), ERR_DELTA); - - zb (); - input[0] = 1.0; taps[0] = 4.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (4.0, float_dotprod (input, taps, 1), ERR_DELTA); -} - -// -// t2 -// -void -qa_float_dotprod_x86::t2_base (float_dotprod_t float_dotprod) -{ - zb (); - input[0] = 1.0; taps[0] = 2.0; - input[1] = 3.0; taps[1] = 5.0; - input[2] = 7.0; taps[2] = 11.0; - input[3] = 13.0; taps[3] = 17.0; - - CPPUNIT_ASSERT_DOUBLES_EQUAL (315.0, float_dotprod (input, taps, 1), ERR_DELTA); - - input[4] = 19.0; taps[4] = 23.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (752.0, float_dotprod (input, taps, 2), ERR_DELTA); - -} - -// -// t3 -// -void -qa_float_dotprod_x86::t3_base (float_dotprod_t float_dotprod) -{ - srandom (0); // we want reproducibility - - for (unsigned int i = 0; i < 10; i++){ - random_floats (input, MAX_BLKS * FLOATS_PER_BLK); - random_floats (taps, MAX_BLKS * FLOATS_PER_BLK); - - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - float ref = ref_float_dotprod (input, taps, MAX_BLKS); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref, - float_dotprod (input, taps, MAX_BLKS), - fabs (ref) * 1e-4); - } -} - -void -qa_float_dotprod_x86::t1_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t1_base (float_dotprod_3dnow); -} - -void -qa_float_dotprod_x86::t2_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t2_base (float_dotprod_3dnow); -} - -void -qa_float_dotprod_x86::t3_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t3_base (float_dotprod_3dnow); -} - -void -qa_float_dotprod_x86::t1_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t1_base (float_dotprod_sse); -} - -void -qa_float_dotprod_x86::t2_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t2_base (float_dotprod_sse); -} - -void -qa_float_dotprod_x86::t3_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t3_base (float_dotprod_sse); -} diff --git a/gnuradio-core/src/lib/filter/qa_float_dotprod_x86.h b/gnuradio-core/src/lib/filter/qa_float_dotprod_x86.h deleted file mode 100644 index 38d6104fab..0000000000 --- a/gnuradio-core/src/lib/filter/qa_float_dotprod_x86.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_FLOAT_DOTPROD_X86_H_ -#define _QA_FLOAT_DOTPROD_X86_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_float_dotprod_x86 : public CppUnit::TestCase { - public: - void setUp (); - void tearDown (); - - CPPUNIT_TEST_SUITE (qa_float_dotprod_x86); - CPPUNIT_TEST (t1_3dnow); - CPPUNIT_TEST (t2_3dnow); - CPPUNIT_TEST (t3_3dnow); - CPPUNIT_TEST (t1_sse); - CPPUNIT_TEST (t2_sse); - CPPUNIT_TEST (t3_sse); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t1_3dnow (); - void t2_3dnow (); - void t3_3dnow (); - void t1_sse (); - void t2_sse (); - void t3_sse (); - - - typedef float (*float_dotprod_t)(const float *input, - const float *taps, - unsigned n_4_float_blocks); - - void t1_base (float_dotprod_t); - void t2_base (float_dotprod_t); - void t3_base (float_dotprod_t); - - - void zb (); - - float *taps; // 16-byte aligned - float *input; // 16-byte aligned - -}; - - -#endif /* _QA_FLOAT_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_ccc.cc b/gnuradio-core/src/lib/filter/qa_gr_fir_ccc.cc deleted file mode 100644 index 7474b76e25..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_ccc.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * FIXME. This code is virtually identical to qa_gr_fir_?CC.cc - * Kludge up some kind of macro to handle the minor differences. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> - -typedef gr_complex i_type; -typedef gr_complex o_type; -typedef gr_complex tap_type; -typedef gr_complex acc_type; - - -#include <qa_gr_fir_ccc.h> -#include <gr_fir_ccc.h> -#include <gr_fir_util.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <gr_types.h> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -// -// typedef for something logically "pointer to constructor". -// there may be a better way, please let me know... -// -typedef gr_fir_ccc* (*fir_maker_t)(const std::vector<tap_type> &taps); - - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_input (i_type *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (i_type) rint (uniform () * 32767); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) - sum += input[i] * taps[ntaps - i - 1]; - - return sum; -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// - -static void -test_random_io (fir_maker_t maker) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Our SIMD ccc kernel requires that the complex input be 64-bit (8-byte) aligned. - // i_type input[INPUT_LEN]; - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - - srandom (0); // we want reproducibility - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_input (input, INPUT_LEN); - random_complex (taps, MAX_TAPS); - - // compute expected output values - for (int o = 0; o < ol; o++){ - expected_output[o] = ref_dotprod (&input[o], taps, n); - } - - // build filter - - vector<tap_type> f1_taps (&taps[0], &taps[n]); - gr_fir_ccc *f1 = maker (f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < ol; o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], - actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - - delete f1; - } - } - free16Align(input); -} - -static void -for_each (void (*f)(fir_maker_t)) -{ - std::vector<gr_fir_ccc_info> info; - gr_fir_util::get_gr_fir_ccc_info (&info); // get all known ccc implementations - - for (std::vector<gr_fir_ccc_info>::iterator p = info.begin (); - p != info.end (); - ++p){ - - std::cerr << " [" << p->name << "]"; - f (p->create); - } - - std::cerr << std::endl; -} - -void -qa_gr_fir_ccc::t1 () -{ - for_each (test_random_io); -} diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_ccf.cc b/gnuradio-core/src/lib/filter/qa_gr_fir_ccf.cc deleted file mode 100644 index 84cb924aea..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_ccf.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * FIXME. This code is virtually identical to qa_gr_fir_?CC.cc - * Kludge up some kind of macro to handle the minor differences. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> - -typedef gr_complex i_type; -typedef gr_complex o_type; -typedef float tap_type; -typedef gr_complex acc_type; - - -#include <qa_gr_fir_ccf.h> -#include <gr_fir_ccf.h> -#include <gr_fir_util.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <gr_types.h> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -// -// typedef for something logically "pointer to constructor". -// there may be a better way, please let me know... -// -typedef gr_fir_ccf* (*fir_maker_t)(const std::vector<tap_type> &taps); - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (float) rint (uniform () * 32767); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) - sum += input[i] * taps[ntaps - i - 1]; - - return sum; -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// - -static void -test_random_io (fir_maker_t maker) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Our SIMD ccc kernel requires that the complex input be 64-bit (8-byte) aligned. - //i_type input[INPUT_LEN]; - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - - srandom (0); // we want reproducibility - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_complex (input, INPUT_LEN); - random_floats (taps, MAX_TAPS); - - // compute expected output values - for (int o = 0; o < ol; o++){ - expected_output[o] = ref_dotprod (&input[o], taps, n); - } - - // build filter - - vector<tap_type> f1_taps (&taps[0], &taps[n]); - gr_fir_ccf *f1 = maker (f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < ol; o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - - delete f1; - } - } - free16Align(input); -} - - -static void -for_each (void (*f)(fir_maker_t)) -{ - std::vector<gr_fir_ccf_info> info; - gr_fir_util::get_gr_fir_ccf_info (&info); // get all known ccf implementations - - for (std::vector<gr_fir_ccf_info>::iterator p = info.begin (); - p != info.end (); - ++p){ - - std::cerr << " [" << p->name << "]"; - f (p->create); - } - - std::cerr << std::endl; -} - - -void -qa_gr_fir_ccf::t1 () -{ - for_each (test_random_io); -} diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_ccf.h b/gnuradio-core/src/lib/filter/qa_gr_fir_ccf.h deleted file mode 100644 index bda79cc2fa..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_ccf.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GR_FIR_CCF_H_ -#define _QA_GR_FIR_CCF_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fir_ccf : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fir_ccf); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t1 (); - // void t2 (); - // void t3 (); - -}; - - -#endif /* _QA_GR_FIR_CCF_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_fcc.cc b/gnuradio-core/src/lib/filter/qa_gr_fir_fcc.cc deleted file mode 100644 index 4c77a5e5c0..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_fcc.cc +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * FIXME. This code is virtually identical to qa_gr_fir_?CC.cc - * Kludge up some kind of macro to handle the minor differences. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> - -typedef float i_type; -typedef gr_complex o_type; -typedef gr_complex tap_type; -typedef gr_complex acc_type; - - -#include <qa_gr_fir_fcc.h> -#include <gr_fir_fcc.h> -#include <gr_fir_util.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <gr_types.h> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <string.h> - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - - -// -// typedef for something logically "pointer to constructor". -// there may be a better way, please let me know... -// -typedef gr_fir_fcc* (*fir_maker_t)(const std::vector<tap_type> &taps); - - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_input (i_type *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (i_type) rint (uniform () * 32767); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) - sum += input[i] * taps[ntaps - i - 1]; - - return sum; -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// - -static void -test_random_io (fir_maker_t maker) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - i_type input[INPUT_LEN]; - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - - srandom (0); // we want reproducibility - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_input (input, INPUT_LEN); - random_complex (taps, MAX_TAPS); - - // compute expected output values - for (int o = 0; o < ol; o++){ - expected_output[o] = ref_dotprod (&input[o], taps, n); - } - - // build filter - - vector<tap_type> f1_taps (&taps[0], &taps[n]); - gr_fir_fcc *f1 = maker (f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < ol; o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], - actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - - delete f1; - } - } -} - -static void -for_each (void (*f)(fir_maker_t)) -{ - std::vector<gr_fir_fcc_info> info; - gr_fir_util::get_gr_fir_fcc_info (&info); // get all known fcc implementations - - for (std::vector<gr_fir_fcc_info>::iterator p = info.begin (); - p != info.end (); - ++p){ - - std::cerr << " [" << p->name << "]"; - f (p->create); - } - - std::cerr << std::endl; -} - -void -qa_gr_fir_fcc::t1 () -{ - for_each (test_random_io); -} diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_fcc.h b/gnuradio-core/src/lib/filter/qa_gr_fir_fcc.h deleted file mode 100644 index 23706fd9c1..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_fcc.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GR_FIR_FCC_H_ -#define _QA_GR_FIR_FCC_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fir_fcc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fir_fcc); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t1 (); -}; - - -#endif /* _QA_GR_FIR_FCC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_fff.cc b/gnuradio-core/src/lib/filter/qa_gr_fir_fff.cc deleted file mode 100644 index 80ed674658..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_fff.cc +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_gr_fir_fff.h> -#include <gr_fir_fff.h> -#include <gr_fir_util.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <string.h> - -using std::vector; - -typedef float i_type; -typedef float o_type; -typedef float tap_type; -typedef float acc_type; - -#define ERR_DELTA (1e-6) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - - -// -// typedef for something logically "pointer to constructor". -// there may be a better way, please let me know... -// -typedef gr_fir_fff* (*fir_maker_t)(const std::vector<tap_type> &taps); - - -// ---------------------------------------------------------------- - -const static i_type input_1[] = { - 234, -4, 23, -56, 45, 98, -23, -7 -}; - -const static tap_type taps_1a[] = { - -3 -}; - -const static o_type expected_1a[] = { - -702, 12, -69, 168, -135, -294, 69, 21 -}; - -const static tap_type taps_1b[] = { - -4, 5 -}; - -const static o_type expected_1b[] = { - 1186, -112, 339, -460, -167, 582, -87 -}; - -// ---------------------------------------------------------------- - -static void -test_known_io (fir_maker_t maker) -{ - vector<tap_type> t1a (&taps_1a[0], &taps_1a[NELEM (taps_1a)]); - vector<tap_type> t1b (&taps_1b[0], &taps_1b[NELEM (taps_1b)]); - - gr_fir_fff *f1 = maker (t1a); // create filter - CPPUNIT_ASSERT_EQUAL ((unsigned) 1, f1->ntaps ()); // check ntaps - - // check filter output - int n = NELEM (input_1) - f1->ntaps () + 1; - for (int i = 0; i < n; i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_1a[i], f1->filter (&input_1[i]), ERR_DELTA); - - f1->set_taps (t1b); // set new taps - CPPUNIT_ASSERT_EQUAL ((unsigned) 2, f1->ntaps ()); // check ntaps - - // check filter output - n = NELEM (input_1) - f1->ntaps () + 1; - for (int i = 0; i < n; i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_1b[i], f1->filter (&input_1[i]), ERR_DELTA); - - // test filterN interface - - o_type output[NELEM (expected_1b)]; - memset (output, 0, sizeof (output)); - - f1->filterN (output, input_1, n); - for (int i = 0; i < n; i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_1b[i], output[i], ERR_DELTA); - - delete f1; -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = rint (uniform () * 32768); -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) - sum += input[i] * taps[ntaps - i - 1]; - - return sum; -} - -static void -test_random_io (fir_maker_t maker) -{ - const int MAX_TAPS = 32; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - i_type input[INPUT_LEN]; - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - - srandom (0); // we want reproducibility - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_floats (input, INPUT_LEN); - random_floats (taps, MAX_TAPS); - - // compute expected output values - for (int o = 0; o < ol; o++){ - expected_output[o] = ref_dotprod (&input[o], taps, n); - } - - // build filter - - vector<tap_type> f1_taps (&taps[0], &taps[n]); - gr_fir_fff *f1 = maker (f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < ol; o++){ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_output[o], actual_output[o], - fabs (expected_output[o]) * 9e-3); - } - - delete f1; - } - } -} - - -static void -for_each (void (*f)(fir_maker_t)) -{ - std::vector<gr_fir_fff_info> info; - gr_fir_util::get_gr_fir_fff_info (&info); // get all known fff implementations - - for (std::vector<gr_fir_fff_info>::iterator p = info.begin (); - p != info.end (); - ++p){ - - std::cerr << " [" << p->name << "]"; - f (p->create); - } - - std::cerr << std::endl; -} - -void -qa_gr_fir_fff::t1 () -{ - for_each (test_known_io); -} - -void -qa_gr_fir_fff::t2 () -{ - for_each (test_random_io); -} diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_fff.h b/gnuradio-core/src/lib/filter/qa_gr_fir_fff.h deleted file mode 100644 index c896728960..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_fff.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GR_FIR_FFF_H_ -#define _QA_GR_FIR_FFF_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fir_fff : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fir_fff); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t1 (); - void t2 (); - -}; - - -#endif /* _QA_GR_FIR_FFF_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_scc.cc b/gnuradio-core/src/lib/filter/qa_gr_fir_scc.cc deleted file mode 100644 index 3f4a7be2c4..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_scc.cc +++ /dev/null @@ -1,179 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * FIXME. This code is virtually identical to qa_gr_fir_?CC.cc - * Kludge up some kind of macro to handle the minor differences. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> - -typedef short i_type; -typedef gr_complex o_type; -typedef gr_complex tap_type; -typedef gr_complex acc_type; - - -#include <qa_gr_fir_scc.h> -#include <gr_fir_scc.h> -#include <gr_fir_util.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <gr_types.h> -#include <cppunit/TestAssert.h> -#include <random.h> - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -// -// typedef for something logically "pointer to constructor". -// there may be a better way, please let me know... -// -typedef gr_fir_scc* (*fir_maker_t)(const std::vector<tap_type> &taps); - - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_input (i_type *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (i_type) rint (uniform () * 32767); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) - sum += (float) input[i] * taps[ntaps - i - 1]; - - return sum; -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// - -static void -test_random_io (fir_maker_t maker) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - i_type input[INPUT_LEN]; - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - - srandom (0); // we want reproducibility - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_input (input, INPUT_LEN); - random_complex (taps, MAX_TAPS); - - // compute expected output values - for (int o = 0; o < ol; o++){ - expected_output[o] = ref_dotprod (&input[o], taps, n); - } - - // build filter - - vector<tap_type> f1_taps (&taps[0], &taps[n]); - gr_fir_scc *f1 = maker (f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < ol; o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], - actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - - delete f1; - } - } -} - -static void -for_each (void (*f)(fir_maker_t)) -{ - std::vector<gr_fir_scc_info> info; - gr_fir_util::get_gr_fir_scc_info (&info); // get all known scc implementations - - for (std::vector<gr_fir_scc_info>::iterator p = info.begin (); - p != info.end (); - ++p){ - - std::cerr << " [" << p->name << "]"; - f (p->create); - } - - std::cerr << std::endl; -} - -void -qa_gr_fir_scc::t1 () -{ - for_each (test_random_io); -} diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_scc.h b/gnuradio-core/src/lib/filter/qa_gr_fir_scc.h deleted file mode 100644 index 4b5ffdae3c..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_scc.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GR_FIR_SCC_H_ -#define _QA_GR_FIR_SCC_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fir_scc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fir_scc); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - void t1 (); - -}; - - -#endif /* _QA_GR_FIR_SCC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gr_rotator.cc b/gnuradio-core/src/lib/filter/qa_gr_rotator.cc deleted file mode 100644 index b2885a12d4..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_rotator.cc +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gruel/attributes.h> -#include <cppunit/TestAssert.h> -#include <qa_gr_rotator.h> -#include <gr_rotator.h> -#include <stdio.h> -#include <cmath> -#include <gr_expj.h> - - -// error vector magnitude -__GR_ATTR_UNUSED static float -error_vector_mag(gr_complex a, gr_complex b) -{ - return abs(a-b); -} - -void -qa_gr_rotator::t1 () -{ - static const unsigned int N = 100000; - - gr_rotator r; - - double phase_incr = 2*M_PI / 1003; - double phase = 0; - - // Old code: We increment then return the rotated value, thus we need to start one tick back - // r.set_phase(gr_complex(1,0) * conj(gr_expj(phase_incr))); - - r.set_phase(gr_complex(1,0)); - r.set_phase_incr(gr_expj(phase_incr)); - - for (unsigned i = 0; i < N; i++){ - gr_complex expected = gr_expj(phase); - gr_complex actual = r.rotate(gr_complex(1, 0)); - -#if 0 - float evm = error_vector_mag(expected, actual); - printf("[%6d] expected: (%8.6f, %8.6f) actual: (%8.6f, %8.6f) evm: %8.6f\n", - i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm); -#endif - - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001); - - phase += phase_incr; - if (phase >= 2*M_PI) - phase -= 2*M_PI; - } -} diff --git a/gnuradio-core/src/lib/filter/qa_gr_rotator.h b/gnuradio-core/src/lib/filter/qa_gr_rotator.h deleted file mode 100644 index 739b23f8c3..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_rotator.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GR_ROTATOR_H_ -#define _QA_GR_ROTATOR_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_rotator : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_rotator); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - void t1 (); - -}; - -#endif /* _QA_GR_ROTATOR_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.cc deleted file mode 100644 index cfdbc53eb3..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.cc +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> -#include <qa_gri_fir_filter_with_buffer_ccc.h> -#include <gri_fir_filter_with_buffer_ccc.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -typedef gr_complex i_type; -typedef gr_complex o_type; -typedef gr_complex tap_type; -typedef gr_complex acc_type; - -using std::vector; - -#define MAX_DATA (32767) -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * MAX_DATA); - float im = rint (uniform () * MAX_DATA); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) { - sum += input[i] * taps[i]; - } - - return sum; -} - -void -qa_gri_fir_filter_with_buffer_ccc::t1 () -{ - test_decimate(1); -} - -void -qa_gri_fir_filter_with_buffer_ccc::t2 () -{ - test_decimate(2); -} - -void -qa_gri_fir_filter_with_buffer_ccc::t3 () -{ - test_decimate(5); -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// -void -qa_gri_fir_filter_with_buffer_ccc::test_decimate(unsigned int decimate) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Mem aligned buffer not really necessary, but why not? - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - srandom (0); // we want reproducibility - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_complex (input, INPUT_LEN); - random_complex (taps, MAX_TAPS); - - // compute expected output values - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < (int)(ol/decimate); o++){ - // use an actual delay line for this test - for(int dd = 0; dd < (int)decimate; dd++) { - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[decimate*o+dd]; - } - expected_output[o] = ref_dotprod (dline, taps, n); - } - - // build filter - vector<tap_type> f1_taps(&taps[0], &taps[n]); - gri_fir_filter_with_buffer_ccc *f1 = new gri_fir_filter_with_buffer_ccc(f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterNdec (actual_output, input, ol/decimate, decimate); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < (int)(ol/decimate); o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], - sqrt((float)n)*0.25*MAX_DATA*MAX_DATA * ERR_DELTA); - } - delete f1; - } - } - free16Align(input); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.h deleted file mode 100644 index c1f2df10c0..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GRI_FIR_FILTER_WITH_BUFFER_CCC_H_ -#define _QA_GRI_FIR_FILTER_WITH_BUFFER_CCC_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_fir_filter_with_buffer_ccc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_ccc); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void test_decimate(unsigned int decimate); - - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_CCC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.cc deleted file mode 100644 index 9a5be03518..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.cc +++ /dev/null @@ -1,167 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> -#include <qa_gri_fir_filter_with_buffer_ccf.h> -#include <gri_fir_filter_with_buffer_ccf.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -typedef gr_complex i_type; -typedef gr_complex o_type; -typedef float tap_type; -typedef gr_complex acc_type; - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (float) rint (uniform () * 32767); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) { - sum += input[i] * taps[i]; - } - - return sum; -} - -void -qa_gri_fir_filter_with_buffer_ccf::t1 () -{ - test_decimate(1); -} - -void -qa_gri_fir_filter_with_buffer_ccf::t2 () -{ - test_decimate(2); -} - -void -qa_gri_fir_filter_with_buffer_ccf::t3 () -{ - test_decimate(5); -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// -void -qa_gri_fir_filter_with_buffer_ccf::test_decimate (unsigned int decimate) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Mem aligned buffer not really necessary, but why not? - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - srandom (0); // we want reproducibility - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_complex (input, INPUT_LEN); - random_floats (taps, MAX_TAPS); - - // compute expected output values - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < (int)(ol/decimate); o++){ - // use an actual delay line for this test - for(int dd = 0; dd < (int)decimate; dd++) { - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[decimate*o+dd]; - } - expected_output[o] = ref_dotprod (dline, taps, n); - } - - // build filter - vector<tap_type> f1_taps(&taps[0], &taps[n]); - gri_fir_filter_with_buffer_ccf *f1 = new gri_fir_filter_with_buffer_ccf(f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterNdec (actual_output, input, ol/decimate, decimate); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < (int)(ol/decimate); o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - delete f1; - } - } - free16Align(input); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.h deleted file mode 100644 index 686bc85411..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GRI_FIR_FILTER_WITH_BUFFER_CCF_H_ -#define _QA_GRI_FIR_FILTER_WITH_BUFFER_CCF_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_fir_filter_with_buffer_ccf : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_ccf); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void test_decimate(unsigned int decimate); - - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_CCF_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.cc deleted file mode 100644 index 583697165f..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.cc +++ /dev/null @@ -1,168 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> -#include <qa_gri_fir_filter_with_buffer_fcc.h> -#include <gri_fir_filter_with_buffer_fcc.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -typedef float i_type; -typedef gr_complex o_type; -typedef gr_complex tap_type; -typedef gr_complex acc_type; - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (float) rint (uniform () * 32767); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) { - sum += input[i] * taps[i]; - } - - return sum; -} - -void -qa_gri_fir_filter_with_buffer_fcc::t1() -{ - test_decimate(1); -} - -void -qa_gri_fir_filter_with_buffer_fcc::t2() -{ - test_decimate(2); -} - -void -qa_gri_fir_filter_with_buffer_fcc::t3() -{ - test_decimate(5); -} - - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// -void -qa_gri_fir_filter_with_buffer_fcc::test_decimate(unsigned int decimate) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Mem aligned buffer not really necessary, but why not? - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - srandom (0); // we want reproducibility - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_floats (input, INPUT_LEN); - random_complex (taps, MAX_TAPS); - - // compute expected output values - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < (int)(ol/decimate); o++){ - // use an actual delay line for this test - for(int dd = 0; dd < (int)decimate; dd++) { - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[decimate*o+dd]; - } - expected_output[o] = ref_dotprod (dline, taps, n); - } - - // build filter - vector<tap_type> f1_taps(&taps[0], &taps[n]); - gri_fir_filter_with_buffer_fcc *f1 = new gri_fir_filter_with_buffer_fcc(f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterNdec (actual_output, input, ol/decimate, decimate); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < (int)(ol/decimate); o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - delete f1; - } - } - free16Align(input); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.h deleted file mode 100644 index 64eed25d3a..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GRI_FIR_FILTER_WITH_BUFFER_FCC_H_ -#define _QA_GRI_FIR_FILTER_WITH_BUFFER_FCC_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_fir_filter_with_buffer_fcc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_fcc); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void test_decimate(unsigned int decimate); - - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_FCC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc deleted file mode 100644 index 208ae01dbb..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> -#include <qa_gri_fir_filter_with_buffer_fff.h> -#include <gri_fir_filter_with_buffer_fff.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -typedef float i_type; -typedef float o_type; -typedef float tap_type; -typedef float acc_type; - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (float) rint (uniform () * 32767); -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) { - sum += input[i] * taps[i]; - } - return sum; -} - -void -qa_gri_fir_filter_with_buffer_fff::t1 () -{ - test_decimate(1); -} - -void -qa_gri_fir_filter_with_buffer_fff::t2 () -{ - test_decimate(2); -} - -void -qa_gri_fir_filter_with_buffer_fff::t3 () -{ - test_decimate(5); -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// -void -qa_gri_fir_filter_with_buffer_fff::test_decimate(unsigned int decimate) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Mem aligned buffer not really necessary, but why not? - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - srandom (0); // we want reproducibility - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_floats (input, INPUT_LEN); - random_floats (taps, MAX_TAPS); - - // compute expected output values - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < (int)(ol/decimate); o++){ - // use an actual delay line for this test - for(int dd = 0; dd < (int)decimate; dd++) { - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[decimate*o+dd]; - } - expected_output[o] = ref_dotprod (dline, taps, n); - } - - // build filter - vector<tap_type> f1_taps(&taps[0], &taps[n]); - gri_fir_filter_with_buffer_fff *f1 = new gri_fir_filter_with_buffer_fff(f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterNdec (actual_output, input, ol/decimate, decimate); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < (int)(ol/decimate); o++){ - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_output[o], actual_output[o], - fabsf (expected_output[o]) * ERR_DELTA); - } - delete f1; - } - } - free16Align(input); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.h deleted file mode 100644 index d219ec72d9..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GRI_FIR_FILTER_WITH_BUFFER_FFF_H_ -#define _QA_GRI_FIR_FILTER_WITH_BUFFER_FFF_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_fir_filter_with_buffer_fff : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_fff); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void test_decimate(unsigned int decimate); - - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_FFF_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc deleted file mode 100644 index e2b6fb04f0..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> -#include <qa_gri_fir_filter_with_buffer_fsf.h> -#include <gri_fir_filter_with_buffer_fsf.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -typedef float i_type; -typedef short o_type; -typedef float tap_type; -typedef float acc_type; - -using std::vector; - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (float) rint (uniform () * 128); -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) { - sum += input[i] * taps[i]; - } - return (o_type)sum; -} - -void -qa_gri_fir_filter_with_buffer_fsf::t1 () -{ - test_decimate(1); -} - -void -qa_gri_fir_filter_with_buffer_fsf::t2 () -{ - test_decimate(2); -} - -void -qa_gri_fir_filter_with_buffer_fsf::t3 () -{ - test_decimate(5); -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// -void -qa_gri_fir_filter_with_buffer_fsf::test_decimate (unsigned int decimate) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Mem aligned buffer not really necessary, but why not? - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - srandom (0); // we want reproducibility - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_floats (input, INPUT_LEN); - random_floats (taps, MAX_TAPS); - - // compute expected output values - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < (int)(ol/decimate); o++){ - // use an actual delay line for this test - for(int dd = 0; dd < (int)decimate; dd++) { - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[decimate*o+dd]; - } - expected_output[o] = ref_dotprod (dline, taps, n); - } - - // build filter - vector<tap_type> f1_taps(&taps[0], &taps[n]); - gri_fir_filter_with_buffer_fsf *f1 = new gri_fir_filter_with_buffer_fsf(f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterNdec (actual_output, input, ol/decimate, decimate); - - // check results - for (int o = 0; o < (int)(ol/decimate); o++){ - CPPUNIT_ASSERT_EQUAL(expected_output[o], actual_output[o]); - } - delete f1; - } - } - free16Align(input); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.h deleted file mode 100644 index 70030a0721..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GRI_FIR_FILTER_WITH_BUFFER_FSF_H_ -#define _QA_GRI_FIR_FILTER_WITH_BUFFER_FSF_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_fir_filter_with_buffer_fsf : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_fsf); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void test_decimate(unsigned int decimate); - - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_FSF_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.cc deleted file mode 100644 index 15f8b1f95a..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.cc +++ /dev/null @@ -1,167 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> -#include <qa_gri_fir_filter_with_buffer_scc.h> -#include <gri_fir_filter_with_buffer_scc.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -typedef short i_type; -typedef gr_complex o_type; -typedef gr_complex tap_type; -typedef gr_complex acc_type; - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_shorts (short *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (short) rint (uniform () * 16384); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) { - sum += (float)input[i] * taps[i]; - } - - return sum; -} - -void -qa_gri_fir_filter_with_buffer_scc::t1 () -{ - test_decimate(1); -} - -void -qa_gri_fir_filter_with_buffer_scc::t2 () -{ - test_decimate(2); -} - -void -qa_gri_fir_filter_with_buffer_scc::t3 () -{ - test_decimate(5); -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// -void -qa_gri_fir_filter_with_buffer_scc::test_decimate (unsigned int decimate) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Mem aligned buffer not really necessary, but why not? - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - srandom (0); // we want reproducibility - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_shorts (input, INPUT_LEN); - random_complex (taps, MAX_TAPS); - - // compute expected output values - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < (int)(ol/decimate); o++){ - // use an actual delay line for this test - for(int dd = 0; dd < (int)decimate; dd++) { - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[decimate*o+dd]; - } - expected_output[o] = ref_dotprod (dline, taps, n); - } - - // build filter - vector<tap_type> f1_taps(&taps[0], &taps[n]); - gri_fir_filter_with_buffer_scc *f1 = new gri_fir_filter_with_buffer_scc(f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterNdec (actual_output, input, ol/decimate, decimate); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < (int)(ol/decimate); o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - delete f1; - } - } - free16Align(input); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.h deleted file mode 100644 index f80056189f..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GRI_FIR_FILTER_WITH_BUFFER_SCC_H_ -#define _QA_GRI_FIR_FILTER_WITH_BUFFER_SCC_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_fir_filter_with_buffer_scc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_scc); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void test_decimate(unsigned int decimate); - - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_SCC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.cc b/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.cc deleted file mode 100644 index 7dca65b9a1..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <cppunit/TestAssert.h> -#include <qa_gri_mmse_fir_interpolator.h> -#include <gri_mmse_fir_interpolator.h> -#include <stdio.h> -#include <cmath> - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - - -static float -test_fcn (double index) -{ - return (2 * sin (index * 0.25 * 2 * M_PI + 0.125 * M_PI) - + 3 * sin (index * 0.077 * 2 * M_PI + 0.3 * M_PI)); -} - - -void -qa_gri_mmse_fir_interpolator::t1 () -{ - static const unsigned N = 100; - float input[N + 10]; - - for (unsigned i = 0; i < NELEM(input); i++) - input[i] = test_fcn ((double) i); - - gri_mmse_fir_interpolator intr; - float inv_nsteps = 1.0 / intr.nsteps (); - - for (unsigned i = 0; i < N; i++){ - for (unsigned imu = 0; imu <= intr.nsteps (); imu += 1){ - float expected = test_fcn ((i + 3) + imu * inv_nsteps); - float actual = intr.interpolate (&input[i], imu * inv_nsteps); - - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected, actual, 0.004); - // printf ("%9.6f %9.6f %9.6f\n", expected, actual, expected - actual); - } - } -} - diff --git a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.h b/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.h deleted file mode 100644 index 3f4dec7c29..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GRI_MMSE_FIR_INTERPOLATOR_H_ -#define _QA_GRI_MMSE_FIR_INTERPOLATOR_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_mmse_fir_interpolator : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_mmse_fir_interpolator); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - void t1 (); - -}; - - -#endif /* _QA_GRI_MMSE_FIR_INTERPOLATOR_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator_cc.cc b/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator_cc.cc deleted file mode 100644 index 1f70d7f42d..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator_cc.cc +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gruel/attributes.h> -#include <cppunit/TestAssert.h> -#include <qa_gri_mmse_fir_interpolator_cc.h> -#include <gri_mmse_fir_interpolator_cc.h> -#include <stdio.h> -#include <cmath> -#include <stdexcept> -#include <unistd.h> - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - - -static float -test_fcn_sin(double index) -{ - return (2 * sin (index * 0.25 * 2 * M_PI + 0.125 * M_PI) - + 3 * sin (index * 0.077 * 2 * M_PI + 0.3 * M_PI)); -} - -static float -test_fcn_cos(double index) -{ - return (2 * cos (index * 0.25 * 2 * M_PI + 0.125 * M_PI) - + 3 * cos (index * 0.077 * 2 * M_PI + 0.3 * M_PI)); -} - -static gr_complex -test_fcn(double index) -{ - return gr_complex(test_fcn_cos(index), test_fcn_sin(index)); -} - - -void -qa_gri_mmse_fir_interpolator_cc::t1() -{ - static const unsigned N = 100; - __GR_ATTR_ALIGNED(8) gr_complex input[N + 10]; - - for (unsigned i = 0; i < NELEM(input); i++) - input[i] = test_fcn ((double) i); - - gri_mmse_fir_interpolator_cc intr; - float inv_nsteps = 1.0 / intr.nsteps (); - - for (unsigned i = 0; i < N; i++){ - for (unsigned imu = 0; imu <= intr.nsteps (); imu += 1){ - gr_complex expected = test_fcn ((i + 3) + imu * inv_nsteps); - gr_complex actual = intr.interpolate (&input[i], imu * inv_nsteps); - - CPPUNIT_ASSERT_COMPLEXES_EQUAL (expected, actual, 0.004); - // printf ("%9.6f %9.6f %9.6f\n", expected, actual, expected - actual); - } - } -} - - -/* - * Force bad alignment and confirm that it raises an exception - */ -void -qa_gri_mmse_fir_interpolator_cc::t2_body() -{ - static const unsigned N = 100; - float float_input[2*(N+10) + 1]; - gr_complex *input; - - // We require that gr_complex be aligned on an 8-byte boundary. - // Ensure that we ARE NOT ;) - - if (((intptr_t) float_input & 0x7) == 0) - input = reinterpret_cast<gr_complex *>(&float_input[1]); - else - input = reinterpret_cast<gr_complex *>(&float_input[0]); - - - for (unsigned i = 0; i < (N+10); i++) - input[i] = test_fcn ((double) i); - - gri_mmse_fir_interpolator_cc intr; - float inv_nsteps = 1.0 / intr.nsteps (); - - for (unsigned i = 0; i < N; i++){ - for (unsigned imu = 0; imu <= intr.nsteps (); imu += 1){ - gr_complex expected = test_fcn ((i + 3) + imu * inv_nsteps); - gr_complex actual = intr.interpolate (&input[i], imu * inv_nsteps); - - CPPUNIT_ASSERT_COMPLEXES_EQUAL (expected, actual, 0.004); - // printf ("%9.6f %9.6f %9.6f\n", expected, actual, expected - actual); - } - } -} - -void -qa_gri_mmse_fir_interpolator_cc::t2() -{ - CPPUNIT_ASSERT_THROW(t2_body(), std::invalid_argument); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator_cc.h b/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator_cc.h deleted file mode 100644 index 6be3d97433..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator_cc.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GRI_MMSE_FIR_INTERPOLATOR_CC_H_ -#define _QA_GRI_MMSE_FIR_INTERPOLATOR_CC_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_mmse_fir_interpolator_cc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE(qa_gri_mmse_fir_interpolator_cc); - CPPUNIT_TEST(t1); - // CPPUNIT_TEST(t2); - CPPUNIT_TEST_SUITE_END(); - - private: - void t1(); - void t2(); - void t2_body(); - -}; - -#endif /* _QA_GRI_MMSE_FIR_INTERPOLATOR_CC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_rotator.cc b/gnuradio-core/src/lib/filter/qa_rotator.cc new file mode 100644 index 0000000000..b722f32c43 --- /dev/null +++ b/gnuradio-core/src/lib/filter/qa_rotator.cc @@ -0,0 +1,81 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gruel/attributes.h> +#include <cppunit/TestAssert.h> +#include <qa_rotator.h> +#include <analog/rotator.h> +#include <stdio.h> +#include <cmath> +#include <gr_expj.h> + +namespace gr { + namespace analog { + + // error vector magnitude + __GR_ATTR_UNUSED static float + error_vector_mag(gr_complex a, gr_complex b) + { + return abs(a-b); + } + + void + qa_rotator::t1() + { + static const unsigned int N = 100000; + + rotator r; + + double phase_incr = 2*M_PI / 1003; + double phase = 0; + + // Old code: We increment then return the rotated value, thus we + // need to start one tick back + // r.set_phase(gr_complex(1,0) * conj(gr_expj(phase_incr))); + + r.set_phase(gr_complex(1,0)); + r.set_phase_incr(gr_expj(phase_incr)); + + for(unsigned i = 0; i < N; i++) { + gr_complex expected = gr_expj(phase); + gr_complex actual = r.rotate(gr_complex(1, 0)); + +#if 0 + float evm = error_vector_mag(expected, actual); + printf("[%6d] expected: (%8.6f, %8.6f) actual: (%8.6f, %8.6f) evm: %8.6f\n", + i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm); +#endif + + CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001); + + phase += phase_incr; + if(phase >= 2*M_PI) + phase -= 2*M_PI; + } + } + + } /* namespace analog */ +} /* namespace gr */ diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_ccc.h b/gnuradio-core/src/lib/filter/qa_rotator.h index 0535e66528..a22e41ec26 100644 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_ccc.h +++ b/gnuradio-core/src/lib/filter/qa_rotator.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2008,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,22 +19,27 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ -#ifndef _QA_GR_FIR_CCC_H_ -#define _QA_GR_FIR_CCC_H_ + +#ifndef _QA_ANALOG_ROTATOR_H_ +#define _QA_ANALOG_ROTATOR_H_ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -class qa_gr_fir_ccc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fir_ccc); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); +namespace gr { + namespace analog { - private: - void t1 (); + class qa_rotator : public CppUnit::TestCase + { + CPPUNIT_TEST_SUITE(qa_rotator); + CPPUNIT_TEST(t1); + CPPUNIT_TEST_SUITE_END(); -}; + private: + void t1(); + }; + } /* namespace analog */ +} /* namespace gr */ -#endif /* _QA_GR_FIR_CCC_H_ */ +#endif /* _QA_ANALOG_ROTATOR_H_ */ diff --git a/gnuradio-core/src/lib/filter/short_dotprod_generic.c b/gnuradio-core/src/lib/filter/short_dotprod_generic.c deleted file mode 100644 index 49a9c0483c..0000000000 --- a/gnuradio-core/src/lib/filter/short_dotprod_generic.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "short_dotprod_generic.h" - - -int -short_dotprod_generic (const short *input, - const short *taps, unsigned n_4_short_blocks) -{ - int sum0 = 0; - int sum1 = 0; - int sum2 = 0; - int sum3 = 0; - - do { - - sum0 += input[0] * taps[0]; - sum1 += input[1] * taps[1]; - sum2 += input[2] * taps[2]; - sum3 += input[3] * taps[3]; - - input += 4; - taps += 4; - - } while (--n_4_short_blocks != 0); - - - return (sum0 + sum1 + sum2 + sum3); -} diff --git a/gnuradio-core/src/lib/filter/short_dotprod_generic.h b/gnuradio-core/src/lib/filter/short_dotprod_generic.h deleted file mode 100644 index e7d977a007..0000000000 --- a/gnuradio-core/src/lib/filter/short_dotprod_generic.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _SHORT_DOTPROD_GENERIC_H_ -#define _SHORT_DOTPROD_GENERIC_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -int -short_dotprod_generic (const short *input, - const short *taps, unsigned n_4_short_blocks); - - -#ifdef __cplusplus -} -#endif - - - -#endif /* _SHORT_DOTPROD_GENERIC_H_ */ diff --git a/gnuradio-core/src/lib/filter/short_dotprod_mmx.S b/gnuradio-core/src/lib/filter/short_dotprod_mmx.S deleted file mode 100644 index 0f6801e4bb..0000000000 --- a/gnuradio-core/src/lib/filter/short_dotprod_mmx.S +++ /dev/null @@ -1,117 +0,0 @@ -# -# Copyright 2002 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# SIMD MMX dot product -# Equivalent to the following C code: -# long dotprod(signed short *a,signed short *b,int cnt) -# { -# long sum = 0; -# cnt *= 4; -# while(cnt--) -# sum += *a++ + *b++; -# return sum; -# } -# a and b should also be 64-bit aligned, or speed will suffer greatly -# Copyright 1999, Phil Karn KA9Q -# May be used under the terms of the GNU public license - -#include "assembly.h" - - - .file "short_dotprod_mmx.S" -// .version "01.01" -.text - .p2align 3 -.globl GLOB_SYMB(short_dotprod_mmx) - DEF_FUNC_HEAD(short_dotprod_mmx) -GLOB_SYMB(short_dotprod_mmx): - pushl %ebp - movl %esp,%ebp - pushl %esi - pushl %edi - pushl %ecx - pushl %ebx - movl 8(%ebp),%esi # a - movl 12(%ebp),%edi # b - movl 16(%ebp),%ecx # cnt - pxor %mm0,%mm0 # clear running sum (in two 32-bit halves) - -# MMX dot product loop unrolled 4 times, crunching 16 terms per loop - .p2align 4 -.Loop1mmx: subl $4,%ecx - jl .Loop1Done - - movq (%esi),%mm1 # mm1 = a[3],a[2],a[1],a[0] - pmaddwd (%edi),%mm1 # mm1 = b[3]*a[3]+b[2]*a[2],b[1]*a[1]+b[0]*a[0] - paddd %mm1,%mm0 - - movq 8(%esi),%mm1 - pmaddwd 8(%edi),%mm1 - paddd %mm1,%mm0 - - movq 16(%esi),%mm1 - pmaddwd 16(%edi),%mm1 - paddd %mm1,%mm0 - - movq 24(%esi),%mm1 - addl $32,%esi - pmaddwd 24(%edi),%mm1 - addl $32,%edi - paddd %mm1,%mm0 - - jmp .Loop1mmx -.Loop1Done: - - addl $4,%ecx - -# MMX dot product loop, not unrolled, crunching 4 terms per loop -# This could be redone as Duff's Device on the unrolled loop above -.Loop2: subl $1,%ecx - jl .Loop2Done - - movq (%esi),%mm1 - addl $8,%esi - pmaddwd (%edi),%mm1 - addl $8,%edi - paddd %mm1,%mm0 - jmp .Loop2 -.Loop2Done: - - movd %mm0,%ebx # right-hand word to ebx - punpckhdq %mm0,%mm0 # left-hand word to right side of %mm0 - movd %mm0,%eax - addl %ebx,%eax # running sum now in %eax - emms # done with MMX - - popl %ebx - popl %ecx - popl %edi - popl %esi - movl %ebp,%esp - popl %ebp - ret - -FUNC_TAIL(short_dotprod_mmx) - .ident "Hand coded x86 MMX assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/short_dotprod_mmx64.S b/gnuradio-core/src/lib/filter/short_dotprod_mmx64.S deleted file mode 100644 index bafd0e04e2..0000000000 --- a/gnuradio-core/src/lib/filter/short_dotprod_mmx64.S +++ /dev/null @@ -1,105 +0,0 @@ -# -# Copyright 2002,2005 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# SIMD MMX dot product -# Equivalent to the following C code: -# long dotprod(signed short *a,signed short *b,int cnt) -# { -# long sum = 0; -# cnt *= 4; -# while(cnt--) -# sum += *a++ + *b++; -# return sum; -# } -# a and b should also be 64-bit aligned, or speed will suffer greatly -# Copyright 1999, Phil Karn KA9Q -# May be used under the terms of the GNU public license - -#include "assembly.h" - - - .file "short_dotprod_mmx64.S" -// .version "01.01" -.text - .p2align 3 -.globl GLOB_SYMB(short_dotprod_mmx) - DEF_FUNC_HEAD(short_dotprod_mmx) -GLOB_SYMB(short_dotprod_mmx): - - # a: rdi, b: rsi, cnt: rdx - - pxor %mm0,%mm0 # clear running sum (in two 32-bit halves) - -# MMX dot product loop unrolled 4 times, crunching 16 terms per loop - .p2align 4 -.Loop1mmx: sub $4,%rdx - jl .Loop1Done - - movq (%rdi),%mm1 # mm1 = a[3],a[2],a[1],a[0] - pmaddwd (%rsi),%mm1 # mm1 = b[3]*a[3]+b[2]*a[2],b[1]*a[1]+b[0]*a[0] - paddd %mm1,%mm0 - - movq 8(%rdi),%mm1 - pmaddwd 8(%rsi),%mm1 - paddd %mm1,%mm0 - - movq 16(%rdi),%mm1 - pmaddwd 16(%rsi),%mm1 - paddd %mm1,%mm0 - - movq 24(%rdi),%mm1 - add $32,%rdi - pmaddwd 24(%rsi),%mm1 - add $32,%rsi - paddd %mm1,%mm0 - - jmp .Loop1mmx -.Loop1Done: - - add $4,%rdx - -# MMX dot product loop, not unrolled, crunching 4 terms per loop -# This could be redone as Duff's Device on the unrolled loop above -.Loop2: sub $1,%rdx - jl .Loop2Done - - movq (%rdi),%mm1 - add $8,%rdi - pmaddwd (%rsi),%mm1 - add $8,%rsi - paddd %mm1,%mm0 - jmp .Loop2 -.Loop2Done: - - movd %mm0,%edx # right-hand word to edx - punpckhdq %mm0,%mm0 # left-hand word to right side of %mm0 - movd %mm0,%eax - addl %edx,%eax # running sum now in %eax - emms # done with MMX - - retq - -FUNC_TAIL(short_dotprod_mmx) - .ident "Hand coded x86_64 MMX assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/short_dotprod_x86.h b/gnuradio-core/src/lib/filter/short_dotprod_x86.h deleted file mode 100644 index 13d5ae2a3c..0000000000 --- a/gnuradio-core/src/lib/filter/short_dotprod_x86.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _SHORT_DOTPROD_X86_H_ -#define _SHORT_DOTPROD_X86_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -int -short_dotprod_mmx (const short *input, - const short *taps, unsigned n_4_short_blocks); - -int -short_dotprod_sse2 (const short *input, - const short *taps, unsigned n_4_short_blocks); - -#ifdef __cplusplus -} -#endif - - - -#endif /* _SHORT_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/sse_debug.c b/gnuradio-core/src/lib/filter/sse_debug.c deleted file mode 100644 index 870cc0543e..0000000000 --- a/gnuradio-core/src/lib/filter/sse_debug.c +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#include <stdio.h> -#include <sse_debug.h> -#include <string.h> - -void -format_xmm_regs (FILE *f, struct xmm_regs *r) -{ - int i; - - for (i = 0; i < 8; i++){ - union xmm_register *x = &r->xmm[i]; - fprintf (f, "xmm%d: %08lx %08lx %08lx %08lx", i, - x->ul[0], x->ul[1], x->ul[2], x->ul[3]); - fprintf (f, " %12g %12g %12g %12g\n", - x->f[0], x->f[1], x->f[2], x->f[3]); - } -} - - -void -get_xmm_regs (struct xmm_regs *x) -{ - asm ("movups %%xmm0,0x00(%0); \n" - "movups %%xmm1,0x10(%0); \n" - "movups %%xmm2,0x20(%0); \n" - "movups %%xmm3,0x30(%0); \n" - "movups %%xmm4,0x40(%0); \n" - "movups %%xmm5,0x50(%0); \n" - "movups %%xmm6,0x60(%0); \n" - "movups %%xmm7,0x70(%0); \n" : : "r" (x)); -} - -void -dump_xmm_regs (void) -{ - struct xmm_regs r; - - get_xmm_regs (&r); - format_xmm_regs (stderr, &r); -} - diff --git a/gnuradio-core/src/lib/filter/sse_debug.h b/gnuradio-core/src/lib/filter/sse_debug.h deleted file mode 100644 index b19b4e646c..0000000000 --- a/gnuradio-core/src/lib/filter/sse_debug.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _SSE_DEBUG_H_ -#define _SSE_DEBUG_H_ - -#ifdef __cplusplus -extern "C" { -#endif - - union xmm_register { - unsigned long ul[4]; - float f[4]; - }; - - struct xmm_regs { - union xmm_register xmm[8]; - }; - - // callable from asm, dumps all xmm regs - void dump_xmm_regs (void); - - void get_xmm_regs (struct xmm_regs *x); - -#ifdef __cplusplus -} -#endif - -#endif // _SSE_DEBUG_H_ diff --git a/gnuradio-core/src/lib/filter/sysconfig_armv7_a.cc b/gnuradio-core/src/lib/filter/sysconfig_armv7_a.cc deleted file mode 100644 index 2c415863b5..0000000000 --- a/gnuradio-core/src/lib/filter/sysconfig_armv7_a.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_fir_sysconfig_armv7_a.h> - -gr_fir_sysconfig * -gr_fir_sysconfig_singleton () -{ - static gr_fir_sysconfig *singleton = 0; - - if (singleton) - return singleton; - - singleton = new gr_fir_sysconfig_armv7_a (); - return singleton; -} diff --git a/gnuradio-core/src/lib/filter/sysconfig_generic.cc b/gnuradio-core/src/lib/filter/sysconfig_generic.cc deleted file mode 100644 index 88508f62b1..0000000000 --- a/gnuradio-core/src/lib/filter/sysconfig_generic.cc +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gr_fir_sysconfig_generic.h> - -gr_fir_sysconfig * -gr_fir_sysconfig_singleton () -{ - static gr_fir_sysconfig *singleton = 0; - - if (singleton) - return singleton; - - singleton = new gr_fir_sysconfig_generic (); - return singleton; -} diff --git a/gnuradio-core/src/lib/filter/sysconfig_powerpc.cc b/gnuradio-core/src/lib/filter/sysconfig_powerpc.cc deleted file mode 100644 index 911beae2a7..0000000000 --- a/gnuradio-core/src/lib/filter/sysconfig_powerpc.cc +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_sysconfig_powerpc.h> - -gr_fir_sysconfig * -gr_fir_sysconfig_singleton () -{ - static gr_fir_sysconfig *singleton = 0; - - if (singleton) - return singleton; - - singleton = new gr_fir_sysconfig_powerpc (); - return singleton; -} diff --git a/gnuradio-core/src/lib/filter/sysconfig_x86.cc b/gnuradio-core/src/lib/filter/sysconfig_x86.cc deleted file mode 100644 index 582df0ab72..0000000000 --- a/gnuradio-core/src/lib/filter/sysconfig_x86.cc +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_sysconfig_x86.h> - -gr_fir_sysconfig * -gr_fir_sysconfig_singleton () -{ - static gr_fir_sysconfig *singleton = 0; - - if (singleton) - return singleton; - - singleton = new gr_fir_sysconfig_x86 (); - return singleton; -} diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index ce9a80f377..e3dc18520b 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -22,26 +22,6 @@ ######################################################################## ######################################################################## -# Handle the generated sine table -######################################################################## -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_sine_table.py - COMMAND ${PYTHON_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/gen_sine_table.py > - ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h -) - -include(AddFileDependencies) -ADD_FILE_DEPENDENCIES(${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.cc - ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h -) - -add_custom_target(general_generated DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h -) - -######################################################################## # Handle the generated constants ######################################################################## execute_process(COMMAND ${PYTHON_EXECUTABLE} -c @@ -69,27 +49,11 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_BINARY_DIR}/gr_constants.cc) ######################################################################## list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/gr_circular_file.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_count_bits.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_fast_atan2f.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fft_vcc_fftw.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_misc.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_random.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_reverse.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_add_const_ss_generic.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_char_to_float.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_control_loop.cc ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_char.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_int.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_short.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_uchar.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_glfsr.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_interleaved_short_to_complex.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_int_to_float.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_short_to_float.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_uchar_to_float.cc ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.c ) @@ -99,13 +63,7 @@ list(APPEND gnuradio_core_sources list(APPEND test_gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/qa_general.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_circular_file.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_cpm.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_firdes.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fxpt.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fxpt_nco.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fxpt_vco.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_math.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_lfsr.cc ) ######################################################################## @@ -115,42 +73,15 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_core_api.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_circular_file.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_constants.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_count_bits.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_expj.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fft_vcc_fftw.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt_nco.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt_vco.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_log2_const.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_math.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_misc.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_nco.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_random.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_reverse.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_simple_framer_sync.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_test_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_vco.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_add_const_ss.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc_cc.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc_ff.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc2_cc.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc2_ff.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_char_to_float.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_control_loop.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_char.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_int.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_short.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_uchar.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_glfsr.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_interleaved_short_to_complex.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_15_1_0.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_32k.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_int_to_float.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_short_to_float.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_uchar_to_float.h ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.h ${CMAKE_CURRENT_SOURCE_DIR}/random.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio @@ -164,11 +95,6 @@ if(ENABLE_PYTHON) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/general.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_constants.i - ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc_cc.i - ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc_ff.i - ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc2_cc.i - ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc2_ff.i - ${CMAKE_CURRENT_SOURCE_DIR}/gri_control_loop.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig" ) @@ -179,130 +105,40 @@ endif(ENABLE_PYTHON) ######################################################################## set(gr_core_general_triple_threats complex_vec_test - gr_add_ff - gr_additive_scrambler_bb - gr_agc_cc - gr_agc_ff - gr_agc2_cc - gr_agc2_ff gr_align_on_samplenumbers_ss - gr_bin_statistics_f gr_block_gateway - gr_bytes_to_syms - gr_char_to_float - gr_char_to_short gr_check_counting_s gr_check_lfsr_32k_s - gr_complex_to_interleaved_short - gr_complex_to_xxx - gr_conjugate_cc gr_copy - gr_cpfsk_bc - gr_cpm - gr_ctcss_squelch_ff - gr_decode_ccsds_27_fb - gr_diff_decoder_bb - gr_diff_encoder_bb - gr_diff_phasor_cc - gr_dpll_bb - gr_deinterleave - gr_delay - gr_encode_ccsds_27_bb gr_endian_swap gr_fake_channel_coder_pp - gr_feedforward_agc_cc gr_feval - gr_fft_vcc - gr_fft_vfc - gr_firdes - gr_float_to_char - gr_float_to_complex - gr_float_to_int - gr_float_to_short - gr_float_to_uchar - gr_fmdet_cf - gr_frequency_modulator_fc - gr_framer_sink_1 - gr_glfsr_source_b - gr_glfsr_source_f gr_head - gr_int_to_float - gr_interleave - gr_interleaved_short_to_complex gr_iqcomp_cc - gr_keep_one_in_n - gr_keep_m_in_n gr_kludge_copy gr_lfsr_32k_source_s - gr_map_bb - gr_multiply_cc - gr_multiply_ff - gr_multiply_const_cc - gr_multiply_const_ff - gr_multiply_conjugate_cc - gr_nlog10_ff gr_nop gr_null_sink gr_null_source gr_pa_2x2_phase_combiner - gr_packet_sink - gr_peak_detector2_fb - gr_phase_modulator_fc - gr_pll_carriertracking_cc - gr_pll_freqdet_cf - gr_pll_refout_cc - gr_pn_correlator_cc gr_prefs - gr_probe_avg_mag_sqrd_c - gr_probe_avg_mag_sqrd_cf - gr_probe_avg_mag_sqrd_f - gr_pwr_squelch_cc - gr_pwr_squelch_ff - gr_quadrature_demod_cf - gr_random_pdu - gr_rail_ff - gr_regenerate_bb - gr_remez - gr_rms_cf - gr_rms_ff - gr_repeat - gr_short_to_float - gr_short_to_char - gr_simple_correlator - gr_simple_framer - gr_simple_squelch_cc gr_skiphead - gr_squelch_base_cc - gr_squelch_base_ff - gr_stream_mux - gr_stream_to_streams - gr_stream_to_vector - gr_streams_to_stream - gr_streams_to_vector - gr_stretch_ff gr_test - gr_threshold_ff - gr_throttle - gr_transcendental - gr_uchar_to_float - gr_vco_f gr_vector_map - gr_vector_to_stream - gr_vector_to_streams - gr_unpack_k_bits_bb - gr_pack_k_bits_bb - gr_descrambler_bb - gr_scrambler_bb - gr_probe_density_b gr_annotator_alltoall gr_annotator_1to1 gr_annotator_raw - gr_burst_tagger - gr_correlate_access_code_tag_bb - gr_tag_debug - gr_message_strobe ) +if(ENABLE_GR_CTRLPORT) +ADD_DEFINITIONS(-DGR_CTRLPORT) +list(APPEND gr_core_general_triple_threats + gr_ctrlport_probe_c + gr_ctrlport_probe2_c +) +endif(ENABLE_GR_CTRLPORT) + + foreach(file_tt ${gr_core_general_triple_threats}) list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.cc) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel") diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index b727bc8a6f..bcf4392bb4 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -22,252 +22,69 @@ %{ -#include <gri_control_loop.h> #include <gr_nop.h> #include <gr_null_sink.h> #include <gr_null_source.h> #include <gr_head.h> #include <gr_skiphead.h> -#include <gr_quadrature_demod_cf.h> -#include <gr_remez.h> -#include <gr_float_to_complex.h> #include <gr_check_counting_s.h> #include <gr_lfsr_32k_source_s.h> #include <gr_check_lfsr_32k_s.h> -#include <gr_stream_to_vector.h> -#include <gr_vector_to_stream.h> -#include <gr_keep_one_in_n.h> -#include <gr_keep_m_in_n.h> -#include <gr_fft_vcc.h> -#include <gr_fft_vfc.h> -#include <gr_float_to_int.h> -#include <gr_float_to_short.h> -#include <gr_float_to_char.h> -#include <gr_float_to_uchar.h> -#include <gr_short_to_float.h> -#include <gr_short_to_char.h> -#include <gr_int_to_float.h> -#include <gr_char_to_float.h> -#include <gr_char_to_short.h> -#include <gr_uchar_to_float.h> -#include <gr_frequency_modulator_fc.h> -#include <gr_phase_modulator_fc.h> -#include <gr_bytes_to_syms.h> -#include <gr_simple_correlator.h> -#include <gr_simple_framer.h> #include <gr_align_on_samplenumbers_ss.h> -#include <gr_complex_to_xxx.h> -#include <gr_complex_to_interleaved_short.h> -#include <gr_interleaved_short_to_complex.h> //#include <gr_endianness.h> #include <gr_endian_swap.h> -#include <gr_firdes.h> -#include <gr_interleave.h> -#include <gr_deinterleave.h> -#include <gr_delay.h> -#include <gr_simple_squelch_cc.h> -#include <gr_agc_ff.h> -#include <gr_agc_cc.h> -#include <gr_agc2_ff.h> -#include <gr_agc2_cc.h> -#include <gr_random_pdu.h> -#include <gr_rms_cf.h> -#include <gr_rms_ff.h> -#include <gr_nlog10_ff.h> #include <gr_fake_channel_coder_pp.h> -#include <gr_throttle.h> -#include <gr_transcendental.h> -#include <gr_stream_mux.h> -#include <gr_stream_to_streams.h> -#include <gr_streams_to_stream.h> -#include <gr_streams_to_vector.h> -#include <gr_vector_to_streams.h> -#include <gr_conjugate_cc.h> -#include <gr_vco_f.h> -#include <gr_threshold_ff.h> -#include <gr_packet_sink.h> -#include <gr_dpll_bb.h> -#include <gr_fmdet_cf.h> -#include <gr_pll_freqdet_cf.h> -#include <gr_pll_refout_cc.h> -#include <gr_pll_carriertracking_cc.h> -#include <gr_pn_correlator_cc.h> -#include <gr_probe_avg_mag_sqrd_c.h> -#include <gr_probe_avg_mag_sqrd_cf.h> -#include <gr_probe_avg_mag_sqrd_f.h> -#include <gr_regenerate_bb.h> #include <gr_pa_2x2_phase_combiner.h> #include <gr_kludge_copy.h> #include <gr_prefs.h> #include <gr_constants.h> #include <gr_test_types.h> #include <gr_test.h> -#include <gr_unpack_k_bits_bb.h> -#include <gr_pack_k_bits_bb.h> -#include <gr_diff_phasor_cc.h> -#include <gr_diff_encoder_bb.h> -#include <gr_diff_decoder_bb.h> -#include <gr_framer_sink_1.h> -#include <gr_map_bb.h> -#include <gr_multiply_cc.h> -#include <gr_multiply_ff.h> -#include <gr_multiply_const_cc.h> -#include <gr_multiply_const_ff.h> -#include <gr_multiply_conjugate_cc.h> #include <gr_feval.h> -#include <gr_pwr_squelch_cc.h> -#include <gr_pwr_squelch_ff.h> -#include <gr_ctcss_squelch_ff.h> -#include <gr_feedforward_agc_cc.h> -#include <gr_bin_statistics_f.h> -#include <gr_glfsr_source_b.h> -#include <gr_glfsr_source_f.h> -#include <gr_peak_detector2_fb.h> -#include <gr_repeat.h> -#include <gr_cpfsk_bc.h> -#include <gr_encode_ccsds_27_bb.h> -#include <gr_decode_ccsds_27_fb.h> -#include <gr_descrambler_bb.h> -#include <gr_scrambler_bb.h> -#include <gr_probe_density_b.h> -#include <gr_rail_ff.h> -#include <gr_stretch_ff.h> #include <gr_copy.h> -#include <gr_additive_scrambler_bb.h> #include <complex_vec_test.h> #include <gr_annotator_alltoall.h> #include <gr_annotator_1to1.h> #include <gr_annotator_raw.h> -#include <gr_burst_tagger.h> -#include <gr_cpm.h> -#include <gr_correlate_access_code_tag_bb.h> -#include <gr_add_ff.h> #include <gr_vector_map.h> -#include <gr_tag_debug.h> -#include <gr_message_strobe.h> %} -%include "gri_control_loop.i" %include "gr_nop.i" %include "gr_null_sink.i" %include "gr_null_source.i" %include "gr_head.i" %include "gr_skiphead.i" -%include "gr_quadrature_demod_cf.i" -%include "gr_remez.i" -%include "gr_float_to_complex.i" %include "gr_check_counting_s.i" %include "gr_lfsr_32k_source_s.i" %include "gr_check_lfsr_32k_s.i" -%include "gr_stream_to_vector.i" -%include "gr_vector_to_stream.i" -%include "gr_keep_one_in_n.i" -%include "gr_keep_m_in_n.i" -%include "gr_fft_vcc.i" -%include "gr_fft_vfc.i" -%include "gr_float_to_int.i" -%include "gr_float_to_short.i" -%include "gr_float_to_char.i" -%include "gr_float_to_uchar.i" -%include "gr_short_to_float.i" -%include "gr_short_to_char.i" -%include "gr_int_to_float.i" -%include "gr_char_to_float.i" -%include "gr_char_to_short.i" -%include "gr_uchar_to_float.i" -%include "gr_frequency_modulator_fc.i" -%include "gr_phase_modulator_fc.i" -%include "gr_bytes_to_syms.i" -%include "gr_simple_correlator.i" -%include "gr_simple_framer.i" %include "gr_align_on_samplenumbers_ss.i" -%include "gr_complex_to_xxx.i" -%include "gr_complex_to_interleaved_short.i" //%include "gr_endianness.i" %include "gr_endian_swap.i" -%include "gr_interleaved_short_to_complex.i" -%include "gr_firdes.i" -%include "gr_interleave.i" -%include "gr_deinterleave.i" -%include "gr_delay.i" -%include "gr_simple_squelch_cc.i" -%include "gr_agc_ff.i" -%include "gr_agc_cc.i" -%include "gr_agc2_ff.i" -%include "gr_agc2_cc.i" -%include "gr_random_pdu.i" -%include "gr_rms_cf.i" -%include "gr_rms_ff.i" -%include "gr_nlog10_ff.i" %include "gr_fake_channel_coder_pp.i" -%include "gr_throttle.i" -%include "gr_transcendental.i" -%include "gr_stream_mux.i" -%include "gr_stream_to_streams.i" -%include "gr_streams_to_stream.i" -%include "gr_streams_to_vector.i" -%include "gr_vector_to_streams.i" -%include "gr_conjugate_cc.i" -%include "gr_vco_f.i" -%include "gr_threshold_ff.i" -%include "gr_packet_sink.i" -%include "gr_dpll_bb.i" -%include "gr_fmdet_cf.i" -%include "gr_pll_freqdet_cf.i" -%include "gr_pll_refout_cc.i" -%include "gr_pll_carriertracking_cc.i" -%include "gr_pn_correlator_cc.i" -%include "gr_probe_avg_mag_sqrd_c.i" -%include "gr_probe_avg_mag_sqrd_cf.i" -%include "gr_probe_avg_mag_sqrd_f.i" -%include "gr_regenerate_bb.i" %include "gr_pa_2x2_phase_combiner.i" %include "gr_kludge_copy.i" %include "gr_prefs.i" %include "gr_constants.i" %include "gr_test_types.h" %include "gr_test.i" -%include "gr_unpack_k_bits_bb.i" -%include "gr_pack_k_bits_bb.i" -%include "gr_diff_phasor_cc.i" -%include "gr_diff_encoder_bb.i" -%include "gr_diff_decoder_bb.i" -%include "gr_framer_sink_1.i" -%include "gr_map_bb.i" -%include "gr_multiply_cc.i" -%include "gr_multiply_ff.i" -%include "gr_multiply_const_cc.i" -%include "gr_multiply_const_ff.i" -%include "gr_multiply_conjugate_cc.i" %include "gr_feval.i" -%include "gr_pwr_squelch_cc.i" -%include "gr_pwr_squelch_ff.i" -%include "gr_ctcss_squelch_ff.i" -%include "gr_feedforward_agc_cc.i" -%include "gr_bin_statistics_f.i" -%include "gr_glfsr_source_b.i" -%include "gr_glfsr_source_f.i" -%include "gr_peak_detector2_fb.i" -%include "gr_repeat.i" -%include "gr_cpfsk_bc.i" -%include "gr_encode_ccsds_27_bb.i" -%include "gr_decode_ccsds_27_fb.i" -%include "gr_descrambler_bb.i" -%include "gr_scrambler_bb.i" -%include "gr_probe_density_b.i" -%include "gr_rail_ff.i" -%include "gr_stretch_ff.i" %include "gr_copy.i" -%include "gr_additive_scrambler_bb.i" %include "complex_vec_test.i" %include "gr_annotator_alltoall.i" %include "gr_annotator_1to1.i" %include "gr_annotator_raw.i" -%include "gr_burst_tagger.i" -%include "gr_cpm.i" -%include "gr_correlate_access_code_tag_bb.i" -%include "gr_add_ff.i" %include "gr_vector_map.i" -%include "gr_tag_debug.i" %include "gr_block_gateway.i" -%include "gr_message_strobe.i" + + +#ifdef GR_CTRLPORT + +%{ +#include <gr_ctrlport_probe_c.h> +#include <gr_ctrlport_probe2_c.h> +%} + +%include "gr_ctrlport_probe_c.i" +%include "gr_ctrlport_probe2_c.i" + +#endif /* GR_CTRLPORT */ diff --git a/gnuradio-core/src/lib/general/general_generated.i b/gnuradio-core/src/lib/general/general_generated.i index 89b7e1776e..c3f67e0d47 100644 --- a/gnuradio-core/src/lib/general/general_generated.i +++ b/gnuradio-core/src/lib/general/general_generated.i @@ -2,76 +2,6 @@ // This file is machine generated. All edits will be overwritten // %{ -#include <gr_add_cc.h> -#include <gr_add_const_cc.h> -#include <gr_add_const_ff.h> -#include <gr_add_const_ii.h> -#include <gr_add_const_sf.h> -#include <gr_add_const_ss.h> -#include <gr_add_const_vcc.h> -#include <gr_add_const_vff.h> -#include <gr_add_const_vii.h> -#include <gr_add_const_vss.h> -#include <gr_add_ii.h> -#include <gr_add_ss.h> -#include <gr_add_vcc.h> -#include <gr_add_vff.h> -#include <gr_add_vii.h> -#include <gr_add_vss.h> -#include <gr_chunks_to_symbols_bc.h> -#include <gr_chunks_to_symbols_bf.h> -#include <gr_chunks_to_symbols_ic.h> -#include <gr_chunks_to_symbols_if.h> -#include <gr_chunks_to_symbols_sc.h> -#include <gr_chunks_to_symbols_sf.h> -#include <gr_divide_cc.h> -#include <gr_divide_ff.h> -#include <gr_divide_ii.h> -#include <gr_divide_ss.h> -#include <gr_multiply_const_ii.h> -#include <gr_multiply_const_ss.h> -#include <gr_multiply_const_vcc.h> -#include <gr_multiply_const_vff.h> -#include <gr_multiply_const_vii.h> -#include <gr_multiply_const_vss.h> -#include <gr_multiply_ii.h> -#include <gr_multiply_ss.h> -#include <gr_multiply_vcc.h> -#include <gr_multiply_vff.h> -#include <gr_multiply_vii.h> -#include <gr_multiply_vss.h> -#include <gr_mute_cc.h> -#include <gr_mute_ff.h> -#include <gr_mute_ii.h> -#include <gr_mute_ss.h> -#include <gr_noise_source_c.h> -#include <gr_noise_source_f.h> -#include <gr_noise_source_i.h> -#include <gr_noise_source_s.h> -#include <gr_packed_to_unpacked_bb.h> -#include <gr_packed_to_unpacked_ii.h> -#include <gr_packed_to_unpacked_ss.h> -#include <gr_probe_signal_b.h> -#include <gr_probe_signal_s.h> -#include <gr_probe_signal_i.h> -#include <gr_probe_signal_f.h> -#include <gr_probe_signal_c.h> -#include <gr_probe_signal_vb.h> -#include <gr_probe_signal_vs.h> -#include <gr_probe_signal_vi.h> -#include <gr_probe_signal_vf.h> -#include <gr_probe_signal_vc.h> -#include <gr_sig_source_c.h> -#include <gr_sig_source_f.h> -#include <gr_sig_source_i.h> -#include <gr_sig_source_s.h> -#include <gr_sub_cc.h> -#include <gr_sub_ff.h> -#include <gr_sub_ii.h> -#include <gr_sub_ss.h> -#include <gr_unpacked_to_packed_bb.h> -#include <gr_unpacked_to_packed_ii.h> -#include <gr_unpacked_to_packed_ss.h> #include <gr_vector_sink_b.h> #include <gr_vector_sink_c.h> #include <gr_vector_sink_f.h> @@ -84,76 +14,6 @@ #include <gr_vector_source_s.h> %} -%include <gr_add_cc.i> -%include <gr_add_const_cc.i> -%include <gr_add_const_ff.i> -%include <gr_add_const_ii.i> -%include <gr_add_const_sf.i> -%include <gr_add_const_ss.i> -%include <gr_add_const_vcc.i> -%include <gr_add_const_vff.i> -%include <gr_add_const_vii.i> -%include <gr_add_const_vss.i> -%include <gr_add_ii.i> -%include <gr_add_ss.i> -%include <gr_add_vcc.i> -%include <gr_add_vff.i> -%include <gr_add_vii.i> -%include <gr_add_vss.i> -%include <gr_chunks_to_symbols_bc.i> -%include <gr_chunks_to_symbols_bf.i> -%include <gr_chunks_to_symbols_ic.i> -%include <gr_chunks_to_symbols_if.i> -%include <gr_chunks_to_symbols_sc.i> -%include <gr_chunks_to_symbols_sf.i> -%include <gr_divide_cc.i> -%include <gr_divide_ff.i> -%include <gr_divide_ii.i> -%include <gr_divide_ss.i> -%include <gr_multiply_const_ii.i> -%include <gr_multiply_const_ss.i> -%include <gr_multiply_const_vcc.i> -%include <gr_multiply_const_vff.i> -%include <gr_multiply_const_vii.i> -%include <gr_multiply_const_vss.i> -%include <gr_multiply_ii.i> -%include <gr_multiply_ss.i> -%include <gr_multiply_vcc.i> -%include <gr_multiply_vff.i> -%include <gr_multiply_vii.i> -%include <gr_multiply_vss.i> -%include <gr_mute_cc.i> -%include <gr_mute_ff.i> -%include <gr_mute_ii.i> -%include <gr_mute_ss.i> -%include <gr_noise_source_c.i> -%include <gr_noise_source_f.i> -%include <gr_noise_source_i.i> -%include <gr_noise_source_s.i> -%include <gr_packed_to_unpacked_bb.i> -%include <gr_packed_to_unpacked_ii.i> -%include <gr_packed_to_unpacked_ss.i> -%include <gr_probe_signal_b.i> -%include <gr_probe_signal_s.i> -%include <gr_probe_signal_i.i> -%include <gr_probe_signal_f.i> -%include <gr_probe_signal_c.i> -%include <gr_probe_signal_vb.i> -%include <gr_probe_signal_vs.i> -%include <gr_probe_signal_vi.i> -%include <gr_probe_signal_vf.i> -%include <gr_probe_signal_vc.i> -%include <gr_sig_source_c.i> -%include <gr_sig_source_f.i> -%include <gr_sig_source_i.i> -%include <gr_sig_source_s.i> -%include <gr_sub_cc.i> -%include <gr_sub_ff.i> -%include <gr_sub_ii.i> -%include <gr_sub_ss.i> -%include <gr_unpacked_to_packed_bb.i> -%include <gr_unpacked_to_packed_ii.i> -%include <gr_unpacked_to_packed_ss.i> %include <gr_vector_sink_b.i> %include <gr_vector_sink_c.i> %include <gr_vector_sink_f.i> diff --git a/gnuradio-core/src/lib/general/gr_add_ff.cc b/gnuradio-core/src/lib/general/gr_add_ff.cc deleted file mode 100644 index 5f6676bb7b..0000000000 --- a/gnuradio-core/src/lib/general/gr_add_ff.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_add_ff.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_add_ff_sptr -gr_make_add_ff(size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_add_ff(vlen)); -} - -gr_add_ff::gr_add_ff (size_t vlen) - : gr_sync_block("add_ff", - gr_make_io_signature (1, -1, sizeof(float)*vlen), - gr_make_io_signature (1, 1, sizeof(float)*vlen)), - d_vlen (vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_add_ff::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *out = (float *) output_items[0]; - int noi = d_vlen*noutput_items; - - memcpy(out, input_items[0], noi*sizeof(float)); - if(is_unaligned()) { - for(size_t i = 1; i < input_items.size(); i++) - volk_32f_x2_add_32f_u(out, out, (const float*)input_items[i], noi); - } - else { - for(size_t i = 1; i < input_items.size(); i++) - volk_32f_x2_add_32f_a(out, out, (const float*)input_items[i], noi); - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.cc b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.cc deleted file mode 100644 index 35cbb9572f..0000000000 --- a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_additive_scrambler_bb.h> -#include <gr_io_signature.h> - -gr_additive_scrambler_bb_sptr -gr_make_additive_scrambler_bb(int mask, int seed, int len, int count) -{ - return gnuradio::get_initial_sptr(new gr_additive_scrambler_bb(mask, seed, len, count)); -} - -gr_additive_scrambler_bb::gr_additive_scrambler_bb(int mask, int seed, int len, int count) - : gr_sync_block("additive_scrambler_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_lfsr(mask, seed, len), - d_count(count), - d_bits(0) -{ -} - -int -gr_additive_scrambler_bb::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++) { - out[i] = in[i]^d_lfsr.next_bit(); - if (d_count > 0) { - if (++d_bits == d_count) { - d_lfsr.reset(); - d_bits = 0; - } - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h deleted file mode 100644 index 1c336306d6..0000000000 --- a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_ADDITIVE_SCRAMBLER_BB_H -#define INCLUDED_GR_ADDITIVE_SCRAMBLER_BB_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include "gri_lfsr.h" - -class gr_additive_scrambler_bb; -typedef boost::shared_ptr<gr_additive_scrambler_bb> gr_additive_scrambler_bb_sptr; - -GR_CORE_API gr_additive_scrambler_bb_sptr gr_make_additive_scrambler_bb(int mask, int seed, int len, int count=0); - -/*! - * Scramble an input stream using an LFSR. This block works on the LSB only - * of the input data stream, i.e., on an "unpacked binary" stream, and - * produces the same format on its output. - * - * \param mask Polynomial mask for LFSR - * \param seed Initial shift register contents - * \param len Shift register length - * \param count Number of bits after which shift register is reset, 0=never - * - * The scrambler works by XORing the incoming bit stream by the output of - * the LFSR. Optionally, after 'count' bits have been processed, the shift - * register is reset to the seed value. This allows processing fixed length - * vectors of samples. - * - * \ingroup coding_blk - */ - -class GR_CORE_API gr_additive_scrambler_bb : public gr_sync_block -{ - friend GR_CORE_API gr_additive_scrambler_bb_sptr gr_make_additive_scrambler_bb(int mask, int seed, int len, int count); - - gri_lfsr d_lfsr; - int d_count; - int d_bits; - - gr_additive_scrambler_bb(int mask, int seed, int len, int count); - -public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_ADDITIVE_SCRAMBLER_BB_H */ diff --git a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.i b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.i deleted file mode 100644 index acf9e8c47e..0000000000 --- a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,additive_scrambler_bb); - -gr_additive_scrambler_bb_sptr gr_make_additive_scrambler_bb(int mask, int seed, int len, int count=0); - -class gr_additive_scrambler_bb : public gr_sync_block -{ -private: - gr_additive_scrambler_bb(int mask, int seed, int len, int count); -}; diff --git a/gnuradio-core/src/lib/general/gr_agc2_cc.cc b/gnuradio-core/src/lib/general/gr_agc2_cc.cc deleted file mode 100644 index 5097babc9b..0000000000 --- a/gnuradio-core/src/lib/general/gr_agc2_cc.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_agc2_cc.h> -#include <gr_io_signature.h> -#include <gri_agc2_cc.h> - -gr_agc2_cc_sptr -gr_make_agc2_cc (float attack_rate, float decay_rate, float reference, - float gain, float max_gain) -{ - return gnuradio::get_initial_sptr(new gr_agc2_cc (attack_rate, decay_rate, reference, gain, max_gain)); -} - -gr_agc2_cc::gr_agc2_cc (float attack_rate, float decay_rate, float reference, - float gain, float max_gain) - : gr_sync_block ("gr_agc2_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - gri_agc2_cc (attack_rate, decay_rate, reference, gain, max_gain) -{ -} - -int -gr_agc2_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - scaleN (out, in, noutput_items); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_agc2_cc.h b/gnuradio-core/src/lib/general/gr_agc2_cc.h deleted file mode 100644 index 54bae1aae9..0000000000 --- a/gnuradio-core/src/lib/general/gr_agc2_cc.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_AGC2_CC_H -#define INCLUDED_GR_AGC2_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_agc2_cc.h> - -class gr_agc2_cc; -typedef boost::shared_ptr<gr_agc2_cc> gr_agc2_cc_sptr; - -GR_CORE_API gr_agc2_cc_sptr -gr_make_agc2_cc (float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0); -/*! - * \brief high performance Automatic Gain Control class - * \ingroup level_blk - * - * For Power the absolute value of the complex number is used. - */ - -class GR_CORE_API gr_agc2_cc : public gr_sync_block, public gri_agc2_cc -{ - friend GR_CORE_API gr_agc2_cc_sptr gr_make_agc2_cc (float attack_rate, float decay_rate, float reference, - float gain, float max_gain); - gr_agc2_cc (float attack_rate, float decay_rate, float reference, - float gain, float max_gain); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_AGC2_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_agc2_cc.i b/gnuradio-core/src/lib/general/gr_agc2_cc.i deleted file mode 100644 index 6d7b221010..0000000000 --- a/gnuradio-core/src/lib/general/gr_agc2_cc.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,agc2_cc) - -%include <gri_agc2_cc.i> - -gr_agc2_cc_sptr -gr_make_agc2_cc (float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0); - -class gr_agc2_cc : public gr_sync_block , public gri_agc2_cc -{ - gr_agc2_cc (float attack_rate, float decay_rate, float reference, - float gain, float max_gain); -}; diff --git a/gnuradio-core/src/lib/general/gr_agc2_ff.cc b/gnuradio-core/src/lib/general/gr_agc2_ff.cc deleted file mode 100644 index 792ee1c6be..0000000000 --- a/gnuradio-core/src/lib/general/gr_agc2_ff.cc +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_agc2_ff.h> -#include <gr_io_signature.h> -#include <gri_agc2_ff.h> - -gr_agc2_ff_sptr -gr_make_agc2_ff (float attack_rate, float decay_rate, float reference, - float gain, float max_gain) -{ - return gnuradio::get_initial_sptr(new gr_agc2_ff (attack_rate, decay_rate, reference, - gain, max_gain)); -} - -gr_agc2_ff::gr_agc2_ff (float attack_rate, float decay_rate, float reference, - float gain, float max_gain) - : gr_sync_block ("gr_agc2_ff", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (float))) - , gri_agc2_ff (attack_rate, decay_rate, reference, gain, max_gain) -{ -} - -int -gr_agc2_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - scaleN (out, in, noutput_items); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_agc2_ff.h b/gnuradio-core/src/lib/general/gr_agc2_ff.h deleted file mode 100644 index 48529948c0..0000000000 --- a/gnuradio-core/src/lib/general/gr_agc2_ff.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_AGC2_FF_H -#define INCLUDED_GR_AGC2_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_agc2_ff.h> -class gr_agc2_ff; -typedef boost::shared_ptr<gr_agc2_ff> gr_agc2_ff_sptr; - -GR_CORE_API gr_agc2_ff_sptr -gr_make_agc2_ff (float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0); -/*! - * \brief high performance Automatic Gain Control class - * - * \ingroup level_blk - * Power is approximated by absolute value - */ - -class GR_CORE_API gr_agc2_ff : public gr_sync_block, public gri_agc2_ff -{ - friend GR_CORE_API gr_agc2_ff_sptr gr_make_agc2_ff (float attack_rate, float decay_rate, - float reference, float gain, float max_gain); - gr_agc2_ff (float attack_rate, float decay_rate, float reference, float gain, float max_gain); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FLOAT_AGC2_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_agc2_ff.i b/gnuradio-core/src/lib/general/gr_agc2_ff.i deleted file mode 100644 index 646391aa7f..0000000000 --- a/gnuradio-core/src/lib/general/gr_agc2_ff.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,agc2_ff) - -%include <gri_agc2_ff.i> - -gr_agc2_ff_sptr -gr_make_agc2_ff (float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0); - -class gr_agc2_ff : public gr_sync_block , public gri_agc2_ff -{ - gr_agc2_ff (float attack_rate, float decay_rate, float reference, - float gain, float max_gain); -}; diff --git a/gnuradio-core/src/lib/general/gr_agc_cc.cc b/gnuradio-core/src/lib/general/gr_agc_cc.cc deleted file mode 100644 index e98f3a303f..0000000000 --- a/gnuradio-core/src/lib/general/gr_agc_cc.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_agc_cc.h> -#include <gr_io_signature.h> -#include <gri_agc_cc.h> - -gr_agc_cc_sptr -gr_make_agc_cc (float rate, float reference, - float gain, float max_gain) -{ - return gnuradio::get_initial_sptr(new gr_agc_cc (rate, reference, gain, max_gain)); -} - -gr_agc_cc::gr_agc_cc (float rate, float reference, - float gain, float max_gain) - : gr_sync_block ("gr_agc_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - gri_agc_cc (rate, reference, gain, max_gain) -{ -} - -int -gr_agc_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - scaleN (out, in, noutput_items); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_agc_cc.h b/gnuradio-core/src/lib/general/gr_agc_cc.h deleted file mode 100644 index 9f35350dbd..0000000000 --- a/gnuradio-core/src/lib/general/gr_agc_cc.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_AGC_CC_H -#define INCLUDED_GR_AGC_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_agc_cc.h> -class gr_agc_cc; -typedef boost::shared_ptr<gr_agc_cc> gr_agc_cc_sptr; - -GR_CORE_API gr_agc_cc_sptr -gr_make_agc_cc (float rate = 1e-4, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0); -/*! - * \brief high performance Automatic Gain Control class - * \ingroup level_blk - * - * For Power the absolute value of the complex number is used. - */ - -class GR_CORE_API gr_agc_cc : public gr_sync_block, public gri_agc_cc -{ - friend GR_CORE_API gr_agc_cc_sptr gr_make_agc_cc (float rate, float reference, - float gain, float max_gain); - gr_agc_cc (float rate, float reference, - float gain, float max_gain); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_AGC_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_agc_cc.i b/gnuradio-core/src/lib/general/gr_agc_cc.i deleted file mode 100644 index f942713b08..0000000000 --- a/gnuradio-core/src/lib/general/gr_agc_cc.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,agc_cc) - -%include <gri_agc_cc.i> - -gr_agc_cc_sptr -gr_make_agc_cc (float rate = 1e-4, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0); - -class gr_agc_cc : public gr_sync_block , public gri_agc_cc -{ - gr_agc_cc (float rate, float reference, - float gain, float max_gain); -}; diff --git a/gnuradio-core/src/lib/general/gr_agc_ff.cc b/gnuradio-core/src/lib/general/gr_agc_ff.cc deleted file mode 100644 index 6050dc7f0a..0000000000 --- a/gnuradio-core/src/lib/general/gr_agc_ff.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_agc_ff.h> -#include <gr_io_signature.h> -#include <gri_agc_ff.h> - -gr_agc_ff_sptr -gr_make_agc_ff (float rate, float reference, float gain, float max_gain) -{ - return gnuradio::get_initial_sptr(new gr_agc_ff (rate, reference, gain, max_gain)); -} - -gr_agc_ff::gr_agc_ff (float rate, float reference, float gain, float max_gain) - : gr_sync_block ("gr_agc_ff", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (float))) - , gri_agc_ff (rate, reference, gain, max_gain) -{ -} - -int -gr_agc_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - scaleN (out, in, noutput_items); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_agc_ff.h b/gnuradio-core/src/lib/general/gr_agc_ff.h deleted file mode 100644 index dc618213bb..0000000000 --- a/gnuradio-core/src/lib/general/gr_agc_ff.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_AGC_FF_H -#define INCLUDED_GR_AGC_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_agc_ff.h> -class gr_agc_ff; -typedef boost::shared_ptr<gr_agc_ff> gr_agc_ff_sptr; - -GR_CORE_API gr_agc_ff_sptr -gr_make_agc_ff (float rate = 1e-4, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0); - -/*! - * \brief high performance Automatic Gain Control class - * \ingroup level_blk - * - * Power is approximated by absolute value - */ - -class GR_CORE_API gr_agc_ff : public gr_sync_block, public gri_agc_ff -{ - friend GR_CORE_API gr_agc_ff_sptr gr_make_agc_ff (float rate, float reference, - float gain, float max_gain); - gr_agc_ff (float rate, float reference, float gain, float max_gain); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FLOAT_AGC_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_agc_ff.i b/gnuradio-core/src/lib/general/gr_agc_ff.i deleted file mode 100644 index 03c571e1a4..0000000000 --- a/gnuradio-core/src/lib/general/gr_agc_ff.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,agc_ff) - -%include <gri_agc_ff.i> - -gr_agc_ff_sptr -gr_make_agc_ff (float rate = 1e-4, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0); - -class gr_agc_ff : public gr_sync_block , public gri_agc_ff -{ - gr_agc_ff (float rate, float reference, float gain, float max_gain); -}; diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc index 963af9202a..1178bdc34f 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc @@ -79,8 +79,8 @@ gr_annotator_1to1::work (int noutput_items, } // Storing the current noutput_items as the value to the "noutput_items" key - pmt::pmt_t srcid = pmt::pmt_string_to_symbol(str.str()); - pmt::pmt_t key = pmt::pmt_string_to_symbol("seq"); + pmt::pmt_t srcid = pmt::string_to_symbol(str.str()); + pmt::pmt_t key = pmt::string_to_symbol("seq"); // Work does nothing to the data stream; just copy all inputs to outputs // Adds a new tag when the number of items read is a multiple of d_when @@ -92,7 +92,7 @@ gr_annotator_1to1::work (int noutput_items, // the 1-to-1 propagation policy. for(int i = 0; i < std::min(noutputs, ninputs); i++) { if(abs_N % d_when == 0) { - pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++); + pmt::pmt_t value = pmt::from_uint64(d_tag_counter++); add_item_tag(i, abs_N, key, value, srcid); } diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc index 01bdd30644..d8b7e2db7e 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc @@ -80,8 +80,8 @@ gr_annotator_alltoall::work (int noutput_items, } // Source ID and key for any tag that might get applied from this block - pmt::pmt_t srcid = pmt::pmt_string_to_symbol(str.str()); - pmt::pmt_t key = pmt::pmt_string_to_symbol("seq"); + pmt::pmt_t srcid = pmt::string_to_symbol(str.str()); + pmt::pmt_t key = pmt::string_to_symbol("seq"); // Work does nothing to the data stream; just copy all inputs to outputs // Adds a new tag when the number of items read is a multiple of d_when @@ -91,7 +91,7 @@ gr_annotator_alltoall::work (int noutput_items, for(int j = 0; j < noutput_items; j++) { for(int i = 0; i < noutputs; i++) { if(abs_N % d_when == 0) { - pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++); + pmt::pmt_t value = pmt::from_uint64(d_tag_counter++); add_item_tag(i, abs_N, key, value, srcid); } diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.cc b/gnuradio-core/src/lib/general/gr_annotator_raw.cc index d3dcce73af..c3aecdd938 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_raw.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_raw.cc @@ -55,7 +55,7 @@ void gr_annotator_raw::add_tag(uint64_t offset, pmt_t key, pmt_t val) gruel::scoped_lock l(d_mutex); gr_tag_t tag; - tag.srcid = pmt::pmt_intern(name()); + tag.srcid = pmt::intern(name()); tag.key = key; tag.value = val; tag.offset = offset; diff --git a/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc b/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc deleted file mode 100644 index 3938f2b487..0000000000 --- a/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc +++ /dev/null @@ -1,174 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_bin_statistics_f.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_bin_statistics_f_sptr -gr_make_bin_statistics_f(unsigned int vlen, - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, - size_t tune_delay, - size_t dwell_delay) -{ - return gnuradio::get_initial_sptr(new gr_bin_statistics_f(vlen, - msgq, - tune, - tune_delay, - dwell_delay)); -} - -gr_bin_statistics_f::gr_bin_statistics_f(unsigned int vlen, - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, - size_t tune_delay, - size_t dwell_delay) - : gr_sync_block("bin_statistics_f", - gr_make_io_signature(1, 1, sizeof(float) * vlen), - gr_make_io_signature(0, 0, 0)), - d_vlen(vlen), d_msgq(msgq), d_tune(tune), - d_tune_delay(tune_delay), d_dwell_delay(dwell_delay), - d_center_freq(0), d_delay(0), - d_max(vlen) -{ - enter_init(); -} - -gr_bin_statistics_f::~gr_bin_statistics_f() -{ - // NOP -} - -void -gr_bin_statistics_f::enter_init() -{ - d_state = ST_INIT; - d_delay = 0; -} - -void -gr_bin_statistics_f::enter_tune_delay() -{ - d_state = ST_TUNE_DELAY; - d_delay = d_tune_delay; - d_center_freq = d_tune->calleval(0); -} - -void -gr_bin_statistics_f::enter_dwell_delay() -{ - d_state = ST_DWELL_DELAY; - d_delay = d_dwell_delay; - reset_stats(); -} - -void -gr_bin_statistics_f::leave_dwell_delay() -{ - send_stats(); -} - -int -gr_bin_statistics_f::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *input = (const float *) input_items[0]; - size_t vlen = d_max.size(); - - int n = 0; - int t; - - while (n < noutput_items){ - switch (d_state){ - - case ST_INIT: - enter_tune_delay(); - break; - - case ST_TUNE_DELAY: - t = std::min(noutput_items - n, int(d_delay)); - n += t; - d_delay -= t; - assert(d_delay >= 0); - if (d_delay == 0) - enter_dwell_delay(); - break; - - case ST_DWELL_DELAY: - t = std::min(noutput_items - n, int(d_delay)); - for (int i = 0; i < t; i++){ - accrue_stats(&input[n * vlen]); - n++; - } - d_delay -= t; - assert(d_delay >= 0); - if (d_delay == 0){ - leave_dwell_delay(); - enter_tune_delay(); - } - break; - - default: - assert(0); - } - } - - return noutput_items; -} - -////////////////////////////////////////////////////////////////////////// -// virtual methods for gathering stats -////////////////////////////////////////////////////////////////////////// - -void -gr_bin_statistics_f::reset_stats() -{ - for (size_t i = 0; i < vlen(); i++){ - d_max[i] = 0; - } -} - -void -gr_bin_statistics_f::accrue_stats(const float *input) -{ - for (size_t i = 0; i < vlen(); i++){ - d_max[i] = std::max(d_max[i], input[i]); // compute per bin maxima - } -} - -void -gr_bin_statistics_f::send_stats() -{ - if (msgq()->full_p()) // if the queue is full, don't block, drop the data... - return; - - // build & send a message - gr_message_sptr msg = gr_make_message(0, center_freq(), vlen(), vlen() * sizeof(float)); - memcpy(msg->msg(), &d_max[0], vlen() * sizeof(float)); - msgq()->insert_tail(msg); -} diff --git a/gnuradio-core/src/lib/general/gr_bin_statistics_f.h b/gnuradio-core/src/lib/general/gr_bin_statistics_f.h deleted file mode 100644 index dd10759096..0000000000 --- a/gnuradio-core/src/lib/general/gr_bin_statistics_f.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_BIN_STATISTICS_F_H -#define INCLUDED_GR_BIN_STATISTICS_F_H - - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_feval.h> -#include <gr_message.h> -#include <gr_msg_queue.h> - -class gr_bin_statistics_f; -typedef boost::shared_ptr<gr_bin_statistics_f> gr_bin_statistics_f_sptr; - - -GR_CORE_API gr_bin_statistics_f_sptr -gr_make_bin_statistics_f(unsigned int vlen, // vector length - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, // callback - size_t tune_delay, // samples - size_t dwell_delay); // samples - -/*! - * \brief control scanning and record frequency domain statistics - * \ingroup sink_blk - */ -class GR_CORE_API gr_bin_statistics_f : public gr_sync_block -{ - friend GR_CORE_API gr_bin_statistics_f_sptr - gr_make_bin_statistics_f(unsigned int vlen, // vector length - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, // callback - size_t tune_delay, // samples - size_t dwell_delay); // samples - - enum state_t { ST_INIT, ST_TUNE_DELAY, ST_DWELL_DELAY }; - - size_t d_vlen; - gr_msg_queue_sptr d_msgq; - gr_feval_dd *d_tune; - size_t d_tune_delay; - size_t d_dwell_delay; - double d_center_freq; - - state_t d_state; - size_t d_delay; // nsamples remaining to state transition - - gr_bin_statistics_f(unsigned int vlen, - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, - size_t tune_delay, - size_t dwell_delay); - - void enter_init(); - void enter_tune_delay(); - void enter_dwell_delay(); - void leave_dwell_delay(); - -protected: - std::vector<float> d_max; // per bin maxima - - size_t vlen() const { return d_vlen; } - double center_freq() const { return d_center_freq; } - gr_msg_queue_sptr msgq() const { return d_msgq; } - - virtual void reset_stats(); - virtual void accrue_stats(const float *input); - virtual void send_stats(); - -public: - ~gr_bin_statistics_f(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_bin_statistics_f.i b/gnuradio-core/src/lib/general/gr_bin_statistics_f.i deleted file mode 100644 index 94a3db69a2..0000000000 --- a/gnuradio-core/src/lib/general/gr_bin_statistics_f.i +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -// Directors are only supported in Python, Java and C#. gr_feval_dd uses directors -#ifdef SWIGPYTHON - -GR_SWIG_BLOCK_MAGIC(gr,bin_statistics_f); - -gr_bin_statistics_f_sptr -gr_make_bin_statistics_f(unsigned int vlen, // vector length - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, // callback - size_t tune_delay, // samples - size_t dwell_delay); // samples - - -class gr_bin_statistics_f : public gr_sync_block -{ -private: - gr_bin_statistics_f(unsigned int vlen, - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, - size_t tune_delay, - size_t dwell_delay); -public: - ~gr_bin_statistics_f(); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_block_gateway.h b/gnuradio-core/src/lib/general/gr_block_gateway.h index c876ea8e14..ce87a76c25 100644 --- a/gnuradio-core/src/lib/general/gr_block_gateway.h +++ b/gnuradio-core/src/lib/general/gr_block_gateway.h @@ -227,7 +227,7 @@ public: } protected: - typedef std::map<pmt::pmt_t, gr_feval_p *, pmt::pmt_comperator> msg_handlers_feval_t; + typedef std::map<pmt::pmt_t, gr_feval_p *, pmt::comperator> msg_handlers_feval_t; msg_handlers_feval_t d_msg_handlers_feval; void dispatch_msg(pmt::pmt_t which_port, pmt::pmt_t msg){ diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.cc b/gnuradio-core/src/lib/general/gr_burst_tagger.cc deleted file mode 100644 index 83e84bfa09..0000000000 --- a/gnuradio-core/src/lib/general/gr_burst_tagger.cc +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_burst_tagger.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_burst_tagger_sptr -gr_make_burst_tagger(size_t itemsize) -{ - return gnuradio::get_initial_sptr(new gr_burst_tagger(itemsize)); -} - -gr_burst_tagger::gr_burst_tagger(size_t itemsize) - : gr_sync_block ("burst_tagger", - gr_make_io_signature2 (2, 2, itemsize, sizeof(short)), - gr_make_io_signature (1, 1, itemsize)), - d_itemsize(itemsize), d_state(false) -{ - std::stringstream str; - str << name() << unique_id(); - - d_true_key = pmt::pmt_string_to_symbol("burst"); - d_true_value = pmt::PMT_T; - - d_false_key = pmt::pmt_string_to_symbol("burst"); - d_false_value = pmt::PMT_F; - - d_id = pmt::pmt_string_to_symbol(str.str()); -} - -void -gr_burst_tagger::set_true_tag (const std::string &key, bool value) -{ - d_true_key = pmt::pmt_string_to_symbol(key); - if(value == true) { - d_true_value = pmt::PMT_T; - } - else { - d_true_value = pmt::PMT_F; - } -} - -void -gr_burst_tagger::set_false_tag (const std::string &key, bool value) -{ - d_false_key = pmt::pmt_string_to_symbol(key); - if(value == true) { - d_false_value = pmt::PMT_T; - } - else { - d_false_value = pmt::PMT_F; - } -} - -gr_burst_tagger::~gr_burst_tagger() -{ -} - -int -gr_burst_tagger::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *signal = (const char*)input_items[0]; - const short *trigger = (const short*)input_items[1]; - char *out = (char*)output_items[0]; - - memcpy(out, signal, noutput_items * d_itemsize); - - for(int i = 0; i < noutput_items; i++) { - if(trigger[i] > 0) { - if(d_state == false) { - d_state = true; - add_item_tag(0, nitems_written(0)+i, d_true_key, d_true_value, d_id); - } - } - else { - if(d_state == true) { - d_state = false; - add_item_tag(0, nitems_written(0)+i, d_false_key, d_false_value, d_id); - } - } - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.h b/gnuradio-core/src/lib/general/gr_burst_tagger.h deleted file mode 100644 index 9a7898b043..0000000000 --- a/gnuradio-core/src/lib/general/gr_burst_tagger.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_BURST_TAGGER_H -#define INCLUDED_GR_BURST_TAGGER_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_burst_tagger; -typedef boost::shared_ptr<gr_burst_tagger> gr_burst_tagger_sptr; - -GR_CORE_API gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize); - -/*! - * \brief output[i] = input[i] - * \ingroup misc_blk - * - */ -class GR_CORE_API gr_burst_tagger : public gr_sync_block -{ - size_t d_itemsize; - bool d_state; - pmt::pmt_t d_true_key; - pmt::pmt_t d_true_value; - - pmt::pmt_t d_false_key; - pmt::pmt_t d_false_value; - - pmt::pmt_t d_id; - - friend GR_CORE_API gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize); - gr_burst_tagger(size_t itemsize); - - public: - ~gr_burst_tagger(); - void set_true_tag (const std::string &key, bool value); - void set_false_tag (const std::string &key, bool value); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.i b/gnuradio-core/src/lib/general/gr_burst_tagger.i deleted file mode 100644 index a5511e48ad..0000000000 --- a/gnuradio-core/src/lib/general/gr_burst_tagger.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,burst_tagger) - -gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize); - -class gr_burst_tagger : public gr_sync_block -{ - private: - gr_burst_tagger(size_t itemsize); - - public: - void set_true_tag(const std::string &key, bool value); - void set_false_tag(const std::string &key, bool value); -}; diff --git a/gnuradio-core/src/lib/general/gr_bytes_to_syms.cc b/gnuradio-core/src/lib/general/gr_bytes_to_syms.cc deleted file mode 100644 index 7dafa29f99..0000000000 --- a/gnuradio-core/src/lib/general/gr_bytes_to_syms.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_bytes_to_syms.h> -#include <gr_io_signature.h> -#include <assert.h> - -static const int BITS_PER_BYTE = 8; - -gr_bytes_to_syms_sptr -gr_make_bytes_to_syms () -{ - return gnuradio::get_initial_sptr(new gr_bytes_to_syms ()); -} - -gr_bytes_to_syms::gr_bytes_to_syms () - : gr_sync_interpolator ("bytes_to_syms", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (float)), - BITS_PER_BYTE) -{ -} - -int -gr_bytes_to_syms::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (unsigned char *) input_items[0]; - float *out = (float *) output_items[0]; - - assert (noutput_items % BITS_PER_BYTE == 0); - - for (int i = 0; i < noutput_items / BITS_PER_BYTE; i++){ - int x = in[i]; - - *out++ = (((x >> 7) & 0x1) << 1) - 1; - *out++ = (((x >> 6) & 0x1) << 1) - 1; - *out++ = (((x >> 5) & 0x1) << 1) - 1; - *out++ = (((x >> 4) & 0x1) << 1) - 1; - *out++ = (((x >> 3) & 0x1) << 1) - 1; - *out++ = (((x >> 2) & 0x1) << 1) - 1; - *out++ = (((x >> 1) & 0x1) << 1) - 1; - *out++ = (((x >> 0) & 0x1) << 1) - 1; - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_bytes_to_syms.h b/gnuradio-core/src/lib/general/gr_bytes_to_syms.h deleted file mode 100644 index 23e5c6b91b..0000000000 --- a/gnuradio-core/src/lib/general/gr_bytes_to_syms.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_BYTES_TO_SYMS_H -#define INCLUDED_GR_BYTES_TO_SYMS_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_bytes_to_syms; -typedef boost::shared_ptr<gr_bytes_to_syms> gr_bytes_to_syms_sptr; - -GR_CORE_API gr_bytes_to_syms_sptr gr_make_bytes_to_syms (); - -/*! - * \brief Convert stream of bytes to stream of +/- 1 symbols - * \ingroup converter_blk - * - * input: stream of bytes; output: stream of float - * - * This block is deprecated. - * - * The combination of gr_packed_to_unpacked_bb followed by - * gr_chunks_to_symbols_bf or gr_chunks_to_symbols_bc handles the - * general case of mapping from a stream of bytes into arbitrary float - * or complex symbols. - * - * \sa gr_packed_to_unpacked_bb, gr_unpacked_to_packed_bb, - * \sa gr_chunks_to_symbols_bf, gr_chunks_to_symbols_bc. - */ -class GR_CORE_API gr_bytes_to_syms : public gr_sync_interpolator -{ - friend GR_CORE_API gr_bytes_to_syms_sptr gr_make_bytes_to_syms (); - - gr_bytes_to_syms (); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_BYTES_TO_SYMS_H */ diff --git a/gnuradio-core/src/lib/general/gr_bytes_to_syms.i b/gnuradio-core/src/lib/general/gr_bytes_to_syms.i deleted file mode 100644 index 185e7cd290..0000000000 --- a/gnuradio-core/src/lib/general/gr_bytes_to_syms.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,bytes_to_syms); - -gr_bytes_to_syms_sptr gr_make_bytes_to_syms (); - -class gr_bytes_to_syms : public gr_sync_interpolator -{ - gr_bytes_to_syms (); -}; diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.cc b/gnuradio-core/src/lib/general/gr_char_to_float.cc deleted file mode 100644 index f63aa5b169..0000000000 --- a/gnuradio-core/src/lib/general/gr_char_to_float.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_char_to_float.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_char_to_float_sptr -gr_make_char_to_float (size_t vlen, float scale) -{ - return gnuradio::get_initial_sptr(new gr_char_to_float (vlen, scale)); -} - -gr_char_to_float::gr_char_to_float (size_t vlen, float scale) - : gr_sync_block ("gr_char_to_float", - gr_make_io_signature (1, 1, sizeof (char)*vlen), - gr_make_io_signature (1, 1, sizeof (float)*vlen)), - d_vlen(vlen), d_scale(scale) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -float -gr_char_to_float::scale() const -{ - return d_scale; -} - -void -gr_char_to_float::set_scale(float scale) -{ - d_scale = scale; -} - -int -gr_char_to_float::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const int8_t *in = (const int8_t *) input_items[0]; - float *out = (float *) output_items[0]; - - // Note: the unaligned benchmarked much faster than the aligned - volk_8i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.h b/gnuradio-core/src/lib/general/gr_char_to_float.h deleted file mode 100644 index 5170c618c9..0000000000 --- a/gnuradio-core/src/lib/general/gr_char_to_float.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_CHAR_TO_FLOAT_H -#define INCLUDED_GR_CHAR_TO_FLOAT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_char_to_float; -typedef boost::shared_ptr<gr_char_to_float> gr_char_to_float_sptr; - -GR_CORE_API gr_char_to_float_sptr -gr_make_char_to_float (size_t vlen=1, float scale=1); - -/*! - * \brief Convert stream of chars to a stream of float - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar divider to change the output signal scale. - */ - -class GR_CORE_API gr_char_to_float : public gr_sync_block -{ - private: - friend GR_CORE_API gr_char_to_float_sptr - gr_make_char_to_float (size_t vlen, float scale); - gr_char_to_float (size_t vlen, float scale); - - size_t d_vlen; - float d_scale; - - public: - /*! - * Get the scalar divider value. - */ - float scale() const; - - /*! - * Set the scalar divider value. - */ - void set_scale(float scale); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_CHAR_TO_FLOAT_H */ diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.i b/gnuradio-core/src/lib/general/gr_char_to_float.i deleted file mode 100644 index c0b3d75fef..0000000000 --- a/gnuradio-core/src/lib/general/gr_char_to_float.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,char_to_float) - -gr_char_to_float_sptr -gr_make_char_to_float (size_t vlen=1, float scale=1); - -class gr_char_to_float : public gr_sync_block -{ -public: - float scale() const; - void set_scale(float scale); -}; diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.cc b/gnuradio-core/src/lib/general/gr_char_to_short.cc deleted file mode 100644 index bb9bd8909e..0000000000 --- a/gnuradio-core/src/lib/general/gr_char_to_short.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_char_to_short.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_char_to_short_sptr -gr_make_char_to_short (size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_char_to_short (vlen)); -} - -gr_char_to_short::gr_char_to_short (size_t vlen) - : gr_sync_block ("gr_char_to_short", - gr_make_io_signature (1, 1, sizeof (char)*vlen), - gr_make_io_signature (1, 1, sizeof (short)*vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(char); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_char_to_short::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const int8_t *in = (const int8_t *) input_items[0]; - int16_t *out = (int16_t *) output_items[0]; - - if(is_unaligned()) { - volk_8i_convert_16i_u(out, in, d_vlen*noutput_items); - } - else { - volk_8i_convert_16i_a(out, in, d_vlen*noutput_items); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.h b/gnuradio-core/src/lib/general/gr_char_to_short.h deleted file mode 100644 index 7ac5e97b93..0000000000 --- a/gnuradio-core/src/lib/general/gr_char_to_short.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_CHAR_TO_SHORT_H -#define INCLUDED_GR_CHAR_TO_SHORT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_char_to_short; -typedef boost::shared_ptr<gr_char_to_short> gr_char_to_short_sptr; - -GR_CORE_API gr_char_to_short_sptr -gr_make_char_to_short (size_t vlen=1); - -/*! - * \brief Convert stream of chars to a stream of float - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - */ - -class GR_CORE_API gr_char_to_short : public gr_sync_block -{ - private: - friend GR_CORE_API gr_char_to_short_sptr - gr_make_char_to_short (size_t vlen); - gr_char_to_short (size_t vlen); - - size_t d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_CHAR_TO_SHORT_H */ diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.i b/gnuradio-core/src/lib/general/gr_char_to_short.i deleted file mode 100644 index a53a0990e3..0000000000 --- a/gnuradio-core/src/lib/general/gr_char_to_short.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,char_to_short) - -gr_char_to_short_sptr gr_make_char_to_short (size_t vlen=1); - -class gr_char_to_short : public gr_sync_block -{ - -}; diff --git a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.cc b/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.cc deleted file mode 100644 index 596c149961..0000000000 --- a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_complex_to_interleaved_short.h> -#include <gr_io_signature.h> -#include <math.h> - -gr_complex_to_interleaved_short_sptr -gr_make_complex_to_interleaved_short () -{ - return gnuradio::get_initial_sptr(new gr_complex_to_interleaved_short ()); -} - -gr_complex_to_interleaved_short::gr_complex_to_interleaved_short () - : gr_sync_interpolator ("gr_complex_to_interleaved_short", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (short)), - 2) -{ -} - -int -gr_complex_to_interleaved_short::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - short *out = (short *) output_items[0]; - - for (int i = 0; i < noutput_items/2; i++){ - *out++ = (short) lrintf(in[i].real()); // FIXME saturate? - *out++ = (short) lrintf(in[i].imag()); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h b/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h deleted file mode 100644 index 66503413ff..0000000000 --- a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_COMPLEX_TO_INTERLEAVED_SHORT_H -#define INCLUDED_GR_COMPLEX_TO_INTERLEAVED_SHORT_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_complex_to_interleaved_short; -typedef boost::shared_ptr<gr_complex_to_interleaved_short> - gr_complex_to_interleaved_short_sptr; - -GR_CORE_API gr_complex_to_interleaved_short_sptr -gr_make_complex_to_interleaved_short (); - -/*! - * \brief Convert stream of complex to a stream of interleaved shorts - * \ingroup converter_blk - */ - -class GR_CORE_API gr_complex_to_interleaved_short : public gr_sync_interpolator -{ - friend GR_CORE_API gr_complex_to_interleaved_short_sptr gr_make_complex_to_interleaved_short (); - gr_complex_to_interleaved_short (); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_COMPLEX_TO_INTERLEAVED_SHORT_H */ diff --git a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.i b/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.i deleted file mode 100644 index 19c01b7c66..0000000000 --- a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_interleaved_short) - -gr_complex_to_interleaved_short_sptr gr_make_complex_to_interleaved_short (); - -class gr_complex_to_interleaved_short : public gr_sync_interpolator -{ - gr_complex_to_interleaved_short (); -}; diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc deleted file mode 100644 index cdf6d7f3a6..0000000000 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc +++ /dev/null @@ -1,280 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_complex_to_xxx.h> -#include <gr_io_signature.h> -#include <gr_math.h> -#include <volk/volk.h> - -// ---------------------------------------------------------------- - -gr_complex_to_float_sptr -gr_make_complex_to_float (unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_complex_to_float (vlen)); -} - -gr_complex_to_float::gr_complex_to_float (unsigned int vlen) - : gr_sync_block ("complex_to_float", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 2, sizeof (float) * vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_complex_to_float::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out0 = (float *) output_items[0]; - float* out1; - int noi = noutput_items * d_vlen; - - switch (output_items.size ()){ - case 1: - if(is_unaligned()) { - for (int i = 0; i < noi; i++){ - out0[i] = in[i].real (); - } - } - else { - volk_32fc_deinterleave_real_32f_a(out0, in, noi); - } - break; - - case 2: - out1 = (float *) output_items[1]; - if(is_unaligned()) { - for (int i = 0; i < noi; i++){ - out0[i] = in[i].real (); - out1[i] = in[i].imag (); - } - } - else { - volk_32fc_deinterleave_32f_x2_a(out0, out1, in, noi); - } - break; - - default: - abort (); - } - - return noutput_items; -} - -// ---------------------------------------------------------------- - -gr_complex_to_real_sptr -gr_make_complex_to_real (unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_complex_to_real (vlen)); -} - -gr_complex_to_real::gr_complex_to_real (unsigned int vlen) - : gr_sync_block ("complex_to_real", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_complex_to_real::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = noutput_items * d_vlen; - - if(is_unaligned()) { - for (int i = 0; i < noi; i++){ - out[i] = in[i].real (); - } - } - else { - volk_32fc_deinterleave_real_32f_a(out, in, noi); - } - - return noutput_items; -} - -// ---------------------------------------------------------------- - -gr_complex_to_imag_sptr -gr_make_complex_to_imag (unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_complex_to_imag (vlen)); -} - -gr_complex_to_imag::gr_complex_to_imag (unsigned int vlen) - : gr_sync_block ("complex_to_imag", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_complex_to_imag::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = noutput_items * d_vlen; - - if(is_unaligned()) { - for (int i = 0; i < noi; i++){ - out[i] = in[i].imag (); - } - } - else { - volk_32fc_deinterleave_imag_32f_a(out, in, noi); - } - - return noutput_items; -} - -// ---------------------------------------------------------------- - -gr_complex_to_mag_sptr -gr_make_complex_to_mag (unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_complex_to_mag (vlen)); -} - -gr_complex_to_mag::gr_complex_to_mag (unsigned int vlen) - : gr_sync_block ("complex_to_mag", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_complex_to_mag::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = noutput_items * d_vlen; - - // turned out to be faster than aligned/unaligned switching - volk_32fc_magnitude_32f_u(out, in, noi); - - return noutput_items; -} - -// ---------------------------------------------------------------- - -gr_complex_to_mag_squared_sptr -gr_make_complex_to_mag_squared (unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_complex_to_mag_squared (vlen)); -} - -gr_complex_to_mag_squared::gr_complex_to_mag_squared (unsigned int vlen) - : gr_sync_block ("complex_to_mag_squared", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_complex_to_mag_squared::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = noutput_items * d_vlen; - - if(is_unaligned()) { - volk_32fc_magnitude_squared_32f_u(out, in, noi); - } - else { - volk_32fc_magnitude_squared_32f_a(out, in, noi); - } - - return noutput_items; -} - -// ---------------------------------------------------------------- - -gr_complex_to_arg_sptr -gr_make_complex_to_arg (unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_complex_to_arg (vlen)); -} - -gr_complex_to_arg::gr_complex_to_arg (unsigned int vlen) - : gr_sync_block ("complex_to_arg", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_complex_to_arg::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = noutput_items * d_vlen; - - // The fast_atan2f is faster than Volk - for (int i = 0; i < noi; i++){ - // out[i] = std::arg (in[i]); - out[i] = gr_fast_atan2f(in[i]); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.h b/gnuradio-core/src/lib/general/gr_complex_to_xxx.h deleted file mode 100644 index a2f06ea28c..0000000000 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.h +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_COMPLEX_TO_XXX_H -#define INCLUDED_GR_COMPLEX_TO_XXX_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_complex.h> - -class gr_complex_to_float; -class gr_complex_to_real; -class gr_complex_to_imag; -class gr_complex_to_mag; -class gr_complex_to_mag_squared; -class gr_complex_to_arg; - -typedef boost::shared_ptr<gr_complex_to_float> gr_complex_to_float_sptr; -typedef boost::shared_ptr<gr_complex_to_real> gr_complex_to_real_sptr; -typedef boost::shared_ptr<gr_complex_to_imag> gr_complex_to_imag_sptr; -typedef boost::shared_ptr<gr_complex_to_mag> gr_complex_to_mag_sptr; -typedef boost::shared_ptr<gr_complex_to_mag_squared> gr_complex_to_mag_squared_sptr; -typedef boost::shared_ptr<gr_complex_to_arg> gr_complex_to_arg_sptr; - -GR_CORE_API gr_complex_to_float_sptr gr_make_complex_to_float (unsigned int vlen=1); -GR_CORE_API gr_complex_to_real_sptr gr_make_complex_to_real (unsigned int vlen=1); -GR_CORE_API gr_complex_to_imag_sptr gr_make_complex_to_imag (unsigned int vlen=1); -GR_CORE_API gr_complex_to_mag_sptr gr_make_complex_to_mag (unsigned int vlen=1); -GR_CORE_API gr_complex_to_mag_squared_sptr gr_make_complex_to_mag_squared (unsigned int vlen=1); -GR_CORE_API gr_complex_to_arg_sptr gr_make_complex_to_arg (unsigned int vlen=1); - -/*! - * \brief convert a stream of gr_complex to 1 or 2 streams of float - * \ingroup converter_blk - * \param vlen vector len (default 1) - */ -class GR_CORE_API gr_complex_to_float : public gr_sync_block -{ - friend GR_CORE_API gr_complex_to_float_sptr gr_make_complex_to_float (unsigned int vlen); - gr_complex_to_float (unsigned int vlen); - - unsigned int d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -/*! - * \brief complex in, real out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) - */ -class GR_CORE_API gr_complex_to_real : public gr_sync_block -{ - friend GR_CORE_API gr_complex_to_real_sptr gr_make_complex_to_real (unsigned int vlen); - gr_complex_to_real (unsigned int vlen); - - unsigned int d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -/*! - * \brief complex in, imaginary out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) - */ -class GR_CORE_API gr_complex_to_imag : public gr_sync_block -{ - friend GR_CORE_API gr_complex_to_imag_sptr gr_make_complex_to_imag (unsigned int vlen); - gr_complex_to_imag (unsigned int vlen); - - unsigned int d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -/*! - * \brief complex in, magnitude out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) - */ -class GR_CORE_API gr_complex_to_mag : public gr_sync_block -{ - friend GR_CORE_API gr_complex_to_mag_sptr - gr_make_complex_to_mag (unsigned int vlen); - gr_complex_to_mag (unsigned int vlen); - - unsigned int d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -/*! - * \brief complex in, magnitude squared out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) - */ -class GR_CORE_API gr_complex_to_mag_squared : public gr_sync_block -{ - friend GR_CORE_API gr_complex_to_mag_squared_sptr gr_make_complex_to_mag_squared (unsigned int vlen); - gr_complex_to_mag_squared (unsigned int vlen); - - unsigned int d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -/*! - * \brief complex in, angle out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) - */ -class GR_CORE_API gr_complex_to_arg : public gr_sync_block -{ - friend GR_CORE_API gr_complex_to_arg_sptr gr_make_complex_to_arg (unsigned int vlen); - gr_complex_to_arg (unsigned int vlen); - - unsigned int d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_COMPLEX_TO_XXX_H */ diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.i b/gnuradio-core/src/lib/general/gr_complex_to_xxx.i deleted file mode 100644 index 372b0e8b58..0000000000 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.i +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_float); -gr_complex_to_float_sptr gr_make_complex_to_float (unsigned int vlen=1); -class gr_complex_to_float : public gr_sync_block -{ - gr_complex_to_float (unsigned int vlen); -}; - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_real); -gr_complex_to_real_sptr gr_make_complex_to_real (unsigned int vlen=1); -class gr_complex_to_real : public gr_sync_block -{ - gr_complex_to_real (unsigned int vlen); -}; - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_imag); -gr_complex_to_imag_sptr gr_make_complex_to_imag (unsigned int vlen=1); -class gr_complex_to_imag : public gr_sync_block -{ - gr_complex_to_imag (unsigned int vlen); -}; - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_mag); -gr_complex_to_mag_sptr gr_make_complex_to_mag (unsigned int vlen=1); -class gr_complex_to_mag : public gr_sync_block -{ - gr_complex_to_mag (unsigned int vlen); -}; - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_mag_squared); -gr_complex_to_mag_squared_sptr gr_make_complex_to_mag_squared (unsigned int vlen=1); -class gr_complex_to_mag_squared : public gr_sync_block -{ - gr_complex_to_mag_squared (unsigned int vlen); -}; - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_arg); -gr_complex_to_arg_sptr gr_make_complex_to_arg (unsigned int vlen=1); -class gr_complex_to_arg : public gr_sync_block -{ - gr_complex_to_arg (unsigned int vlen); -}; - diff --git a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc b/gnuradio-core/src/lib/general/gr_conjugate_cc.cc deleted file mode 100644 index 94ac3e162b..0000000000 --- a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// WARNING: this file is machine generated. Edits will be over written - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_conjugate_cc.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_conjugate_cc_sptr -gr_make_conjugate_cc () -{ - return gnuradio::get_initial_sptr(new gr_conjugate_cc ()); -} - -gr_conjugate_cc::gr_conjugate_cc () - : gr_sync_block ("conjugate_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(gr_complex); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_conjugate_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *iptr = (gr_complex *) input_items[0]; - gr_complex *optr = (gr_complex *) output_items[0]; - - if(is_unaligned()) { - volk_32fc_conjugate_32fc_u(optr, iptr, noutput_items); - } - else { - volk_32fc_conjugate_32fc_a(optr, iptr, noutput_items); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_conjugate_cc.h b/gnuradio-core/src/lib/general/gr_conjugate_cc.h deleted file mode 100644 index e0a2af7164..0000000000 --- a/gnuradio-core/src/lib/general/gr_conjugate_cc.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// WARNING: this file is machine generated. Edits will be over written - -#ifndef INCLUDED_GR_CONJUGATE_CC_H -#define INCLUDED_GR_CONJUGATE_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_conjugate_cc; -typedef boost::shared_ptr<gr_conjugate_cc> gr_conjugate_cc_sptr; - -GR_CORE_API gr_conjugate_cc_sptr gr_make_conjugate_cc (); - -/*! - * \brief output = complex conjugate of input - * \ingroup math_blk - */ -class GR_CORE_API gr_conjugate_cc : public gr_sync_block -{ - friend GR_CORE_API gr_conjugate_cc_sptr gr_make_conjugate_cc (); - - gr_conjugate_cc (); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_conjugate_cc.i b/gnuradio-core/src/lib/general/gr_conjugate_cc.i deleted file mode 100644 index 444ebb1b8b..0000000000 --- a/gnuradio-core/src/lib/general/gr_conjugate_cc.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// WARNING: this file is machine generated. Edits will be over written - -GR_SWIG_BLOCK_MAGIC(gr,conjugate_cc) - -gr_conjugate_cc_sptr gr_make_conjugate_cc (); - -class gr_conjugate_cc : public gr_sync_block -{ - private: - gr_conjugate_cc (); -}; diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.cc b/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.cc deleted file mode 100644 index 73ded3c8b3..0000000000 --- a/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.cc +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,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 <gr_correlate_access_code_tag_bb.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <gr_count_bits.h> -#include <cstdio> -#include <iostream> - -#define VERBOSE 0 - - -gr_correlate_access_code_tag_bb_sptr -gr_make_correlate_access_code_tag_bb (const std::string &access_code, int threshold, const std::string &tag_name) -{ - return gnuradio::get_initial_sptr(new gr_correlate_access_code_tag_bb (access_code, threshold, tag_name)); -} - - -gr_correlate_access_code_tag_bb::gr_correlate_access_code_tag_bb ( - const std::string &access_code, int threshold, const std::string &tag_name) - : gr_sync_block ("correlate_access_code_tag_bb", - gr_make_io_signature (1, 1, sizeof(char)), - gr_make_io_signature (1, 1, sizeof(char))), - d_data_reg(0), d_mask(0), - d_threshold(threshold), d_len(0) - -{ - if (!set_access_code(access_code)){ - fprintf(stderr, "gr_correlate_access_code_tag_bb: access_code is > 64 bits\n"); - throw std::out_of_range ("access_code is > 64 bits"); - } - - std::stringstream str; - str << name() << unique_id(); - d_me = pmt::pmt_string_to_symbol(str.str()); - d_key = pmt::pmt_string_to_symbol(tag_name); -} - -gr_correlate_access_code_tag_bb::~gr_correlate_access_code_tag_bb () -{ -} - -bool -gr_correlate_access_code_tag_bb::set_access_code( - const std::string &access_code) -{ - d_len = access_code.length(); // # of bytes in string - if (d_len > 64) - return false; - - // set len top bits to 1. - d_mask = ((~0ULL) >> (64 - d_len)) << (64 - d_len); - - d_access_code = 0; - for (unsigned i=0; i < 64; i++){ - d_access_code <<= 1; - if (i < d_len) - d_access_code |= access_code[i] & 1; // look at LSB only - } - - return true; -} - -int -gr_correlate_access_code_tag_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - uint64_t abs_out_sample_cnt = nitems_written(0); - - for (int i = 0; i < noutput_items; i++){ - - out[i] = in[i]; - - // compute hamming distance between desired access code and current data - unsigned long long wrong_bits = 0; - unsigned int nwrong = d_threshold+1; - int new_flag = 0; - - wrong_bits = (d_data_reg ^ d_access_code) & d_mask; - nwrong = gr_count_bits64(wrong_bits); - - // test for access code with up to threshold errors - new_flag = (nwrong <= d_threshold); - - // shift in new data and new flag - d_data_reg = (d_data_reg << 1) | (in[i] & 0x1); - if (new_flag) { - if(VERBOSE) std::cout << "writing tag at sample " << abs_out_sample_cnt + i << std::endl; - add_item_tag(0, //stream ID - abs_out_sample_cnt + i - 64 + d_len, //sample - d_key, //frame info - pmt::pmt_t(), //data (unused) - d_me //block src id - ); - } - } - - return noutput_items; -} - diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.h b/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.h deleted file mode 100644 index 345d3004a5..0000000000 --- a/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,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_gr_correlate_access_code_tag_bb_H -#define INCLUDED_gr_correlate_access_code_tag_bb_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <string> - -class gr_correlate_access_code_tag_bb; -typedef boost::shared_ptr<gr_correlate_access_code_tag_bb> gr_correlate_access_code_tag_bb_sptr; - -/*! - * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" - * \param threshold maximum number of bits that may be wrong - * \param tag_name key of the tag inserted into the tag stream - */ -GR_CORE_API gr_correlate_access_code_tag_bb_sptr -gr_make_correlate_access_code_tag_bb (const std::string &access_code, int threshold, - const std::string &tag_name); - -/*! - * \brief Examine input for specified access code, one bit at a time. - * \ingroup sync_blk - * - * input: stream of bits, 1 bit per input byte (data in LSB) - * output: unaltered stream of bits (plus tags) - * - * This block annotates the input stream with tags. The tags have key - * name [tag_name], specified in the constructor. Used for searching - * an input data stream for preambles, etc. - */ -class GR_CORE_API gr_correlate_access_code_tag_bb : public gr_sync_block -{ - friend GR_CORE_API gr_correlate_access_code_tag_bb_sptr - gr_make_correlate_access_code_tag_bb (const std::string &access_code, int threshold, - const std::string &tag_name); - private: - unsigned long long d_access_code; // access code to locate start of packet - // access code is left justified in the word - unsigned long long d_data_reg; // used to look for access_code - unsigned long long d_mask; // masks access_code bits (top N bits are set where - // N is the number of bits in the access code) - unsigned int d_threshold; // how many bits may be wrong in sync vector - unsigned int d_len; //the length of the access code - - pmt::pmt_t d_key, d_me; //d_key is the tag name, d_me is the block name + unique ID - - protected: - gr_correlate_access_code_tag_bb(const std::string &access_code, int threshold, - const std::string &tag_name); - - public: - ~gr_correlate_access_code_tag_bb(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - - /*! - * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" - */ - bool set_access_code (const std::string &access_code); -}; - -#endif /* INCLUDED_gr_correlate_access_code_tag_bb_H */ diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.i b/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.i deleted file mode 100644 index f7ca4bea7b..0000000000 --- a/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.i +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,correlate_access_code_tag_bb); - -/*! - * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" - * \param threshold maximum number of bits that may be wrong - */ -gr_correlate_access_code_tag_bb_sptr -gr_make_correlate_access_code_tag_bb (const std::string &access_code, int threshold, const std::string &tag_name) - throw(std::out_of_range); - -/*! - * \brief Examine input for specified access code, one bit at a time. - * \ingroup block - * - * input: stream of bits, 1 bit per input byte (data in LSB) - * output: stream of bits, 2 bits per output byte (data in LSB, flag in next higher bit) - * - * Each output byte contains two valid bits, the data bit, and the - * flag bit. The LSB (bit 0) is the data bit, and is the original - * input data, delayed 64 bits. Bit 1 is the - * flag bit and is 1 if the corresponding data bit is the first data - * bit following the access code. Otherwise the flag bit is 0. - */ -class gr_correlate_access_code_tag_bb : public gr_sync_block -{ - friend gr_correlate_access_code_tag_bb_sptr - gr_make_correlate_access_code_tag_bb (const std::string &access_code, int threshold, const std::string &tag_name); - protected: - gr_correlate_access_code_tag_bb(const std::string &access_code, int threshold, const std::string &tag_name); - - public: - ~gr_correlate_access_code_tag_bb(); - - /*! - * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" - */ - bool set_access_code (const std::string &access_code); -}; diff --git a/gnuradio-core/src/lib/general/gr_count_bits.cc b/gnuradio-core/src/lib/general/gr_count_bits.cc deleted file mode 100644 index 4776fe61a9..0000000000 --- a/gnuradio-core/src/lib/general/gr_count_bits.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 <gr_count_bits.h> - -/* - * these are slow and obvious. If you need something faster, fix these - */ - -// return number of set bits in the low 8 bits of x -unsigned int -gr_count_bits8 (unsigned int x) -{ - int count = 0; - - for (int i = 0; i < 8; i++) - if (x & (1 << i)) - count++; - - return count; -} - -// return number of set bits in the low 16 bits of x -unsigned int -gr_count_bits16 (unsigned int x) -{ - int count = 0; - - for (int i = 0; i < 16; i++) - if (x & (1 << i)) - count++; - - return count; - -} - - -#if 0 // slow and obvious - -// return number of set bits in the low 32 bits of x -unsigned int -gr_count_bits32 (unsigned int x) -{ - int count = 0; - - for (int i = 0; i < 32; i++) - if (x & (1 << i)) - count++; - - return count; -} - -#else // fast and not so obvious - -// return number of set bits in the low 32 bits of x -unsigned int -gr_count_bits32 (unsigned int x) -{ - unsigned res = (x & 0x55555555) + ((x >> 1) & 0x55555555); - res = (res & 0x33333333) + ((res >> 2) & 0x33333333); - res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F); - res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF); - return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF); -} - -#endif - - -// return number of set bits in the low 64 bits of x -unsigned int -gr_count_bits64 (unsigned long long x) -{ - return gr_count_bits32((x >> 32) & 0xffffffff) + gr_count_bits32(x & 0xffffffff); -} diff --git a/gnuradio-core/src/lib/general/gr_count_bits.h b/gnuradio-core/src/lib/general/gr_count_bits.h deleted file mode 100644 index 76d0173eb5..0000000000 --- a/gnuradio-core/src/lib/general/gr_count_bits.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 _GR_COUNT_BITS_H_ -#define _GR_COUNT_BITS_H_ - -#include <gr_core_api.h> - -GR_CORE_API unsigned int gr_count_bits8(unsigned int x); // return number of set bits in the low 8 bits of x -GR_CORE_API unsigned int gr_count_bits16(unsigned int x); // return number of set bits in the low 16 bits of x -GR_CORE_API unsigned int gr_count_bits32(unsigned int x); // return number of set bits in the low 32 bits of x -GR_CORE_API unsigned int gr_count_bits64(unsigned long long int x); - -#endif /* _GR_COUNT_BITS_H_ */ diff --git a/gnuradio-core/src/lib/general/gr_cpfsk_bc.cc b/gnuradio-core/src/lib/general/gr_cpfsk_bc.cc deleted file mode 100644 index 24f0edd5cb..0000000000 --- a/gnuradio-core/src/lib/general/gr_cpfsk_bc.cc +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_cpfsk_bc.h> -#include <gr_io_signature.h> -#include <gr_expj.h> - -#define M_TWOPI (2*M_PI) - -gr_cpfsk_bc_sptr -gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym) -{ - return gnuradio::get_initial_sptr(new gr_cpfsk_bc(k, ampl, samples_per_sym)); -} - -gr_cpfsk_bc::gr_cpfsk_bc(float k, float ampl, int samples_per_sym) - : gr_sync_interpolator("cpfsk_bc", - gr_make_io_signature(1, 1, sizeof(char)), - gr_make_io_signature(1, 1, sizeof(gr_complex)), - samples_per_sym) -{ - d_samples_per_sym = samples_per_sym; - d_freq = k*M_PI/samples_per_sym; - d_ampl = ampl; - d_phase = 0.0; -} - -gr_cpfsk_bc::~gr_cpfsk_bc() -{ -} - -int -gr_cpfsk_bc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *in = (const char *)input_items[0]; - gr_complex *out = (gr_complex *)output_items[0]; - - for (int i = 0; i < noutput_items/d_samples_per_sym; i++) { - for (int j = 0; j < d_samples_per_sym; j++) { - if (in[i] == 1) - d_phase += d_freq; - else - d_phase -= d_freq; - - while (d_phase > M_TWOPI) - d_phase -= M_TWOPI; - while (d_phase < -M_TWOPI) - d_phase += M_TWOPI; - - *out++ = gr_expj(d_phase)*d_ampl; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_cpfsk_bc.h b/gnuradio-core/src/lib/general/gr_cpfsk_bc.h deleted file mode 100644 index 6ad2774b3a..0000000000 --- a/gnuradio-core/src/lib/general/gr_cpfsk_bc.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_CPFSK_BC_H -#define INCLUDED_GR_CPFSK_BC_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_cpfsk_bc; - -typedef boost::shared_ptr<gr_cpfsk_bc> gr_cpfsk_bc_sptr; - -GR_CORE_API gr_cpfsk_bc_sptr gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym); - -/*! - * \brief Perform continuous phase 2-level frequency shift keying modulation - * on an input stream of unpacked bits. - * \ingroup modulation_blk - * - * \param k modulation index - * \param ampl output amplitude - * \param samples_per_sym number of output samples per input bit - */ - -class GR_CORE_API gr_cpfsk_bc : public gr_sync_interpolator -{ -private: - friend GR_CORE_API gr_cpfsk_bc_sptr gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym); - - gr_cpfsk_bc(float k, float ampl, int samples_per_sym); - - int d_samples_per_sym; // Samples per symbol, square pulse - float d_freq; // Modulation index*pi/samples_per_sym - float d_ampl; // Output amplitude - float d_phase; // Current phase - - public: - ~gr_cpfsk_bc(); - - void set_amplitude(float amplitude) { d_ampl = amplitude; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_CPFSK_BC_H */ diff --git a/gnuradio-core/src/lib/general/gr_cpfsk_bc.i b/gnuradio-core/src/lib/general/gr_cpfsk_bc.i deleted file mode 100644 index b86dfb81bd..0000000000 --- a/gnuradio-core/src/lib/general/gr_cpfsk_bc.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,cpfsk_bc); - -gr_cpfsk_bc_sptr gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym); - -class gr_cpfsk_bc : public gr_sync_interpolator -{ -private: - gr_cpfsk_bc(float k, float ampl, int samples_per_sym); - -public: - void set_amplitude(float amplitude); -}; diff --git a/gnuradio-core/src/lib/general/gr_cpm.cc b/gnuradio-core/src/lib/general/gr_cpm.cc deleted file mode 100644 index 32ce6502dd..0000000000 --- a/gnuradio-core/src/lib/general/gr_cpm.cc +++ /dev/null @@ -1,218 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// Calculate the taps for the CPM phase responses - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <cmath> -#include <cfloat> -#include <gr_cpm.h> - -//gives us erf on compilers without it -#include <boost/math/special_functions/erf.hpp> -namespace bm = boost::math; - -#ifndef M_TWOPI -# define M_TWOPI (2*M_PI) -#endif - -//! Normalised sinc function, sinc(x)=sin(pi*x)/pi*x -inline double -sinc(double x) -{ - if (x == 0) { - return 1.0; - } - - return sin(M_PI * x) / (M_PI * x); -} - - -//! Taps for L-RC CPM (Raised cosine of length L symbols) -std::vector<float> -generate_cpm_lrc_taps(unsigned samples_per_sym, unsigned L) -{ - std::vector<float> taps(samples_per_sym * L, 1.0/L/samples_per_sym); - for (unsigned i = 0; i < samples_per_sym * L; i++) { - taps[i] *= 1 - cos(M_TWOPI * i / L / samples_per_sym); - } - - return taps; -} - - -/*! Taps for L-SRC CPM (Spectral raised cosine of length L symbols). - * - * L-SRC has a time-continuous phase response function of - * - * g(t) = 1/LT * sinc(2t/LT) * cos(beta * 2pi t / LT) / (1 - (4beta / LT * t)^2) - * - * which is the Fourier transform of a cos-rolloff function with rolloff - * beta, and looks like a sinc-function, multiplied with a rolloff term. - * We return the main lobe of the sinc, i.e., everything between the - * zero crossings. - * The time-discrete IR is thus - * - * g(k) = 1/Ls * sinc(2k/Ls) * cos(beta * pi k / Ls) / (1 - (4beta / Ls * k)^2) - * where k = 0...Ls-1 - * and s = samples per symbol. - */ -std::vector<float> -generate_cpm_lsrc_taps(unsigned samples_per_sym, unsigned L, double beta) -{ - double Ls = (double) L * samples_per_sym; - std::vector<double> taps_d(L * samples_per_sym, 0.0); - std::vector<float> taps(L * samples_per_sym, 0.0); - - double sum = 0; - for (unsigned i = 0; i < samples_per_sym * L; i++) { - double k = i - Ls/2; // Causal to acausal - - taps_d[i] = 1.0 / Ls * sinc(2.0 * k / Ls); - - // For k = +/-Ls/4*beta, the rolloff term's cos-function becomes zero - // and the whole thing converges to PI/4 (to prove this, use de - // l'hopital's rule). - if (fabs(fabs(k) - Ls/4/beta) < 2*DBL_EPSILON) { - taps_d[i] *= M_PI_4; - } else { - double tmp = 4.0 * beta * k / Ls; - taps_d[i] *= cos(beta * M_TWOPI * k / Ls) / (1 - tmp * tmp); - } - sum += taps_d[i]; - } - for (unsigned i = 0; i < samples_per_sym * L; i++) { - taps[i] = (float) taps_d[i] / sum; - } - - return taps; -} - - -//! Taps for L-REC CPM (Rectangular pulse shape of length L symbols) -std::vector<float> -generate_cpm_lrec_taps(unsigned samples_per_sym, unsigned L) -{ - return std::vector<float>(samples_per_sym * L, 1.0/L/samples_per_sym); -} - - -//! Helper function for TFM -double tfm_g0(double k, double sps) -{ - if (fabs(k) < 2 * DBL_EPSILON) { - return 1.145393004159143; // 1 + pi^2/48 / sqrt(2) - } - - const double pi2_24 = 0.411233516712057; // pi^2/24 - double f = M_PI * k / sps; - return sinc(k/sps) - pi2_24 * (2 * sin(f) - 2*f*cos(f) - f*f*sin(f)) / (f*f*f); -} - - -//! Taps for TFM CPM (Tamed frequency modulation) -// -// See [2, Chapter 2.7.2]. -// -// [2]: Anderson, Aulin and Sundberg; Digital Phase Modulation -std::vector<float> -generate_cpm_tfm_taps(unsigned sps, unsigned L) -{ - unsigned causal_shift = sps * L / 2; - std::vector<double> taps_d(sps * L, 0.0); - std::vector<float> taps(sps * L, 0.0); - - double sum = 0; - for (unsigned i = 0; i < sps * L; i++) { - double k = (double)(((int)i) - ((int)causal_shift)); // Causal to acausal - - taps_d[i] = tfm_g0(k - sps, sps) + - 2 * tfm_g0(k, sps) + - tfm_g0(k + sps, sps); - sum += taps_d[i]; - } - for (unsigned i = 0; i < sps * L; i++) { - taps[i] = (float) taps_d[i] / sum; - } - - return taps; -} - - -//! Taps for Gaussian CPM. Phase response is truncated after \p L symbols. -// \p bt sets the 3dB-time-bandwidth product. -// -// Note: for h = 0.5, this is the phase response for GMSK. -// -// This C99-compatible formula for the taps is taken straight -// from [1, Chapter 9.2.3]. -// A version in Q-notation can be found in [2, Chapter 2.7.2]. -// -// [1]: Karl-Dirk Kammeyer; Nachrichtenübertragung, 4th Edition. -// [2]: Anderson, Aulin and Sundberg; Digital Phase Modulation -// -std::vector<float> -generate_cpm_gaussian_taps(unsigned samples_per_sym, unsigned L, double bt) -{ - double Ls = (double) L * samples_per_sym; - std::vector<double> taps_d(L * samples_per_sym, 0.0); - std::vector<float> taps(L * samples_per_sym, 0.0); - - // alpha = sqrt(2/ln(2)) * pi * BT - double alpha = 5.336446256636997 * bt; - for (unsigned i = 0; i < samples_per_sym * L; i++) { - double k = i - Ls/2; // Causal to acausal - taps_d[i] = (bm::erf(alpha * (k / samples_per_sym + 0.5)) - - bm::erf(alpha * (k / samples_per_sym - 0.5))) - * 0.5 / samples_per_sym; - taps[i] = (float) taps_d[i]; - } - - return taps; -} - - -std::vector<float> -gr_cpm::phase_response(cpm_type type, unsigned samples_per_sym, unsigned L, double beta) -{ - switch (type) { - case LRC: - return generate_cpm_lrc_taps(samples_per_sym, L); - - case LSRC: - return generate_cpm_lsrc_taps(samples_per_sym, L, beta); - - case LREC: - return generate_cpm_lrec_taps(samples_per_sym, L); - - case TFM: - return generate_cpm_tfm_taps(samples_per_sym, L); - - case GAUSSIAN: - return generate_cpm_gaussian_taps(samples_per_sym, L, beta); - - default: - return generate_cpm_lrec_taps(samples_per_sym, 1); - } -} - diff --git a/gnuradio-core/src/lib/general/gr_cpm.h b/gnuradio-core/src/lib/general/gr_cpm.h deleted file mode 100644 index ef2ff84142..0000000000 --- a/gnuradio-core/src/lib/general/gr_cpm.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef INCLUDED_GR_CPM_H -#define INCLUDED_GR_CPM_H - -#include <gr_core_api.h> -#include <vector> - -class GR_CORE_API gr_cpm -{ - public: - enum cpm_type { - LRC, - LSRC, - LREC, - TFM, - GAUSSIAN, - GENERIC = 999 - }; - - /*! \brief Return the taps for an interpolating FIR filter (gr_interp_fir_filter_fff). - * - * These taps represent the phase response \f$g(k)\f$ for use in a CPM modulator, - * see also gr_cpmmod_bc. - * - * \param type The CPM type (Rectangular, Raised Cosine, Spectral Raised Cosine, - * Tamed FM or Gaussian). - * \param samples_per_sym Samples per symbol. - * \param L The length of the phase response in symbols. - * \param beta For Spectral Raised Cosine, this is the rolloff factor. For Gaussian - * phase responses, this the 3dB-time-bandwidth product. For all other - * cases, it is ignored. - * - * Output: returns a vector of length \a K = \p samples_per_sym x \p L. - * This can be used directly in an interpolating FIR filter such as - * gr_interp_fir_filter_fff with interpolation factor \p samples_per_sym. - * - * All phase responses are normalised s.t. \f$ \sum_{k=0}^{K-1} g(k) = 1\f$; this will cause - * a maximum phase change of \f$ h \cdot \pi\f$ between two symbols, where \a h is the - * modulation index. - * - * The following phase responses can be generated: - * - LREC: Rectangular phase response. - * - LRC: Raised cosine phase response, looks like 1 - cos(x). - * - LSRC: Spectral raised cosine. This requires a rolloff factor beta. - * The phase response is the Fourier transform of raised cosine - * function. - * - TFM: Tamed frequency modulation. This scheme minimizes phase change for - * rapidly varying input symbols. - * - GAUSSIAN: A Gaussian phase response. For a modulation index h = 1/2, this - * results in GMSK. - * - * A short description of all these phase responses can be found in [1]. - * - * [1]: Anderson, Aulin and Sundberg; Digital Phase Modulation - */ - static std::vector<float> - phase_response(cpm_type type, unsigned samples_per_sym, unsigned L, double beta=0.3); -}; - -#endif /* INCLUDED_GR_CPM_H */ - diff --git a/gnuradio-core/src/lib/general/gr_cpm.i b/gnuradio-core/src/lib/general/gr_cpm.i deleted file mode 100644 index 6c077687d5..0000000000 --- a/gnuradio-core/src/lib/general/gr_cpm.i +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- C++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%rename(cpm) gr_cpm; - -class gr_cpm -{ - public: - enum cpm_type { - LRC, - LSRC, - LREC, - TFM, - GAUSSIAN, - GENERIC = 999 - }; - - static std::vector<float> - phase_response(cpm_type type, unsigned samples_per_sym, unsigned L, double beta=0.3); -}; - diff --git a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.cc b/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.cc deleted file mode 100644 index d31763a6bf..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.cc +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_ctcss_squelch_ff.h> - -static float ctcss_tones[] = { - 67.0, 71.9, 74.4, 77.0, 79.7, 82.5, 85.4, 88.5, 91.5, 94.8, - 97.4, 100.0, 103.5, 107.2, 110.9, 114.8, 118.8, 123.0, 127.3, 131.8, - 136.5, 141.3, 146.2, 151.4, 156.7, 162.2, 167.9, 173.8, 179.9, 186.2, - 192.8, 203.5, 210.7, 218.1, 225.7, 233.6, 241.8, 250.3 -}; - -static int max_tone_index = 37; - -gr_ctcss_squelch_ff_sptr -gr_make_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate) -{ - return gnuradio::get_initial_sptr(new gr_ctcss_squelch_ff(rate, freq, level, len, ramp, gate)); -} - -int gr_ctcss_squelch_ff::find_tone(float freq) -{ - for (int i = 0; i <= max_tone_index; i++) - if (ctcss_tones[i] == freq) // FIXME: make almost equal - return i; - - return -1; -} - -gr_ctcss_squelch_ff::gr_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate) : - gr_squelch_base_ff("ctcss_squelch_ff", ramp, gate) -{ - d_freq = freq; - d_level = level; - - // Default is 100 ms detection time - if (len == 0) - d_len = (int)(rate/10.0); - else - d_len = len; - - int i = find_tone(freq); - - // Non-standard tones or edge tones get 2% guard band, otherwise - // guards are set at adjacent ctcss tone frequencies - float f_l, f_r; - if (i == -1 || i == 0) - f_l = freq*0.98; - else - f_l = ctcss_tones[i-1]; - - if (i == -1 || i == max_tone_index) - f_r = freq*1.02; - else - f_r = ctcss_tones[i+1]; - - d_goertzel_l = gri_goertzel(rate, d_len, f_l); - d_goertzel_c = gri_goertzel(rate, d_len, freq); - d_goertzel_r = gri_goertzel(rate, d_len, f_r); - - d_mute = true; -} - -std::vector<float> gr_ctcss_squelch_ff::squelch_range() const -{ - std::vector<float> r(3); - r[0] = 0.0; - r[1] = 1.0; - r[2] = (r[1]-r[0])/100; // step size - - return r; -} - -void gr_ctcss_squelch_ff::update_state(const float &in) -{ - d_goertzel_l.input(in); - d_goertzel_c.input(in); - d_goertzel_r.input(in); - - float d_out_l, d_out_c, d_out_r; - if (d_goertzel_c.ready()) { - d_out_l = abs(d_goertzel_l.output()); - d_out_c = abs(d_goertzel_c.output()); - d_out_r = abs(d_goertzel_r.output()); - - //printf("d_out_l=%f d_out_c=%f d_out_r=%f\n", d_out_l, d_out_c, d_out_r); - d_mute = (d_out_c < d_level || d_out_c < d_out_l || d_out_c < d_out_r); - } -} diff --git a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h b/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h deleted file mode 100644 index ef3d13ba7b..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_CTCSS_SQUELCH_FF_H -#define INCLUDED_GR_CTCSS_SQUELCH_FF_H - -#include <gr_core_api.h> -#include <gr_squelch_base_ff.h> -#include <gri_goertzel.h> - -class gr_ctcss_squelch_ff; -typedef boost::shared_ptr<gr_ctcss_squelch_ff> gr_ctcss_squelch_ff_sptr; - -GR_CORE_API gr_ctcss_squelch_ff_sptr -gr_make_ctcss_squelch_ff(int rate, float freq, float level=0.01, int len=0, int ramp=0, bool gate=false); - -/*! - * \brief gate or zero output if ctcss tone not present - * \ingroup level_blk - */ -class GR_CORE_API gr_ctcss_squelch_ff : public gr_squelch_base_ff -{ -private: - float d_freq; - float d_level; - int d_len; - bool d_mute; - - gri_goertzel d_goertzel_l; - gri_goertzel d_goertzel_c; - gri_goertzel d_goertzel_r; - - friend GR_CORE_API gr_ctcss_squelch_ff_sptr gr_make_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate); - gr_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate); - - int find_tone(float freq); - -protected: - virtual void update_state(const float &in); - virtual bool mute() const { return d_mute; } - -public: - std::vector<float> squelch_range() const; - float level() const { return d_level; } - void set_level(float level) { d_level = level; } - int len() const { return d_len; } -}; - -#endif /* INCLUDED_GR_CTCSS_SQUELCH_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.i b/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.i deleted file mode 100644 index b160c5dfd7..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,ctcss_squelch_ff); - -%include gr_squelch_base_ff.i - -gr_ctcss_squelch_ff_sptr -gr_make_ctcss_squelch_ff(int rate, float freq, float level=0.01, int len=0, int ramp=0, bool gate=false); - -class gr_ctcss_squelch_ff : public gr_squelch_base_ff -{ - gr_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate); - -public: - std::vector<float> squelch_range() const; - float level() const { return d_level; } - void set_level(float level) { d_level = level; } - int len() const { return d_len; } -}; diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.cc b/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.cc new file mode 100644 index 0000000000..ca6667a214 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.cc @@ -0,0 +1,156 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_ctrlport_probe2_c.h> +#include <gr_io_signature.h> + +gr_ctrlport_probe2_c_sptr +gr_make_ctrlport_probe2_c(const std::string &id, + const std::string &desc, int len) +{ + return gnuradio::get_initial_sptr + (new gr_ctrlport_probe2_c(id, desc, len)); +} + +gr_ctrlport_probe2_c::gr_ctrlport_probe2_c(const std::string &id, + const std::string &desc, int len) + : gr_sync_block("probe2_c", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(0, 0, 0)), + d_id(id), d_desc(desc), d_len(len) +{ + set_length(len); +} + +gr_ctrlport_probe2_c::~gr_ctrlport_probe2_c() +{ +} + +void +gr_ctrlport_probe2_c::forecast(int noutput_items, gr_vector_int &ninput_items_required) +{ + // make sure all inputs have noutput_items available + unsigned ninputs = ninput_items_required.size(); + for(unsigned i = 0; i < ninputs; i++) + ninput_items_required[i] = d_len; +} + +// boost::shared_mutex mutex_buffer; +// mutable boost::mutex mutex_notify; +// boost::condition_variable condition_buffer_ready; +std::vector<gr_complex> +gr_ctrlport_probe2_c::get() +{ + mutex_buffer.lock(); + d_buffer.clear(); + mutex_buffer.unlock(); + + // wait for condition + boost::mutex::scoped_lock lock(mutex_notify); + condition_buffer_ready.wait(lock); + + mutex_buffer.lock(); + std::vector<gr_complex> buf_copy = d_buffer; + assert(buf_copy.size() == d_len); + mutex_buffer.unlock(); + + return buf_copy; +} + +void +gr_ctrlport_probe2_c::set_length(int len) +{ + if(len > 8191) { + std::cerr << "probe2_c: length " << len + << " exceeds maximum buffer size of 8191" << std::endl; + len = 8191; + } + + d_len = len; + d_buffer.reserve(d_len); +} + +int +gr_ctrlport_probe2_c::length() const +{ + return (int)d_len; +} + +int +gr_ctrlport_probe2_c::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const gr_complex *in = (const gr_complex*)input_items[0]; + + // copy samples to get buffer if we need samples + mutex_buffer.lock(); + if(d_buffer.size() < d_len) { + // copy smaller of remaining buffer space and num inputs to work() + int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items ); + + // TODO: convert this to a copy operator for speed... + for(int i = 0; i < num_copy; i++) { + d_buffer.push_back(in[i]); + } + + // notify the waiting get() if we fill up the buffer + if(d_buffer.size() == d_len) { + condition_buffer_ready.notify_one(); + } + } + mutex_buffer.unlock(); + + return noutput_items; +} + +void +gr_ctrlport_probe2_c::setup_rpc() +{ +#ifdef GR_CTRLPORT + int len = static_cast<int>(d_len); + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_ctrlport_probe2_c, std::vector<std::complex<float> > >( + alias(), d_id.c_str(), &gr_ctrlport_probe2_c::get, + pmt::make_c32vector(0,-2), + pmt::make_c32vector(0,2), + pmt::make_c32vector(0,0), + "volts", d_desc.c_str(), RPC_PRIVLVL_MIN, + DISPXY | DISPOPTSCATTER))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_ctrlport_probe2_c, int>( + alias(), "length", &gr_ctrlport_probe2_c::length, + pmt::mp(1), pmt::mp(10*len), pmt::mp(len), + "samples", "get vector length", RPC_PRIVLVL_MIN, DISPNULL))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_set<gr_ctrlport_probe2_c, int>( + alias(), "length", &gr_ctrlport_probe2_c::set_length, + pmt::mp(1), pmt::mp(10*len), pmt::mp(len), + "samples", "set vector length", RPC_PRIVLVL_MIN, DISPNULL))); +#endif /* GR_CTRLPORT */ +} diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.h b/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.h new file mode 100644 index 0000000000..0920c0f4e8 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.h @@ -0,0 +1,72 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_CTRLPORT_PROBE2_C_H +#define INCLUDED_CTRLPORT_PROBE2_C_H + +#include <gr_core_api.h> +#include <gr_sync_block.h> +#include <rpcregisterhelpers.h> +#include <boost/thread/shared_mutex.hpp> + +class gr_ctrlport_probe2_c; +typedef boost::shared_ptr<gr_ctrlport_probe2_c> gr_ctrlport_probe2_c_sptr; + +GR_CORE_API gr_ctrlport_probe2_c_sptr +gr_make_ctrlport_probe2_c(const std::string &id, const std::string &desc, int len); + +class GR_CORE_API gr_ctrlport_probe2_c : public gr_sync_block +{ + private: + friend GR_CORE_API gr_ctrlport_probe2_c_sptr gr_make_ctrlport_probe2_c + (const std::string &id, const std::string &desc, int len); + + gr_ctrlport_probe2_c(const std::string &id, const std::string &desc, int len); + + std::string d_id; + std::string d_desc; + size_t d_len; + boost::shared_mutex mutex_buffer; + mutable boost::mutex mutex_notify; + boost::condition_variable condition_buffer_ready; + + std::vector<gr_complex> d_buffer; + + public: + ~gr_ctrlport_probe2_c(); + + void setup_rpc(); + + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + + std::vector<gr_complex> get(); + + void set_length(int len); + int length() const; + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_CTRLPORT_PROBE2_C_H */ + diff --git a/gnuradio-core/src/lib/general/gr_add_ff.i b/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.i index 75a87651fa..18858595ea 100644 --- a/gnuradio-core/src/lib/general/gr_add_ff.i +++ b/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.i @@ -20,13 +20,17 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,add_ff) +GR_SWIG_BLOCK_MAGIC(gr,ctrlport_probe2_c) -gr_add_ff_sptr -gr_make_add_ff (size_t vlen=1); +gr_ctrlport_probe2_c_sptr +gr_make_ctrlport_probe2_c(const std::string &id, const std::string &desc, int len); -class gr_add_ff : public gr_sync_block +class gr_ctrlport_probe2_c : public gr_sync_block { public: - + ~gr_ctrlport_probe2_c(); + std::vector<gr_complex> get(); + void set_length(int len); + int length() const; }; + diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.cc b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.cc new file mode 100644 index 0000000000..253d4c380e --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.cc @@ -0,0 +1,96 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_ctrlport_probe_c.h> +#include <gr_io_signature.h> + +gr_ctrlport_probe_c_sptr +gr_make_ctrlport_probe_c(const std::string &id, + const std::string &desc) +{ + return gnuradio::get_initial_sptr + (new gr_ctrlport_probe_c(id, desc)); +} + + +gr_ctrlport_probe_c::gr_ctrlport_probe_c(const std::string &id, + const std::string &desc) + : gr_sync_block("probe_c", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(0, 0, 0)), + d_id(id), d_desc(desc), d_ptr(NULL), d_ptrLen(0) +{ +} + +gr_ctrlport_probe_c::~gr_ctrlport_probe_c() +{ +} + +std::vector<gr_complex> +gr_ctrlport_probe_c::get() +{ + if(d_ptr != NULL && d_ptrLen > 0) { + ptrlock.lock(); + std::vector<gr_complex> vec(d_ptr, d_ptr+d_ptrLen); + ptrlock.unlock(); + return vec; + } + else { + std::vector<gr_complex> vec; + return vec; + } +} + +int +gr_ctrlport_probe_c::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const gr_complex *in = (const gr_complex*)input_items[0]; + + // keep reference to symbols + ptrlock.lock(); + d_ptr = in; + d_ptrLen = noutput_items; + ptrlock.unlock(); + + return noutput_items; +} + +void +gr_ctrlport_probe_c::setup_rpc() +{ +#ifdef GR_CTRLPORT + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_ctrlport_probe_c, std::vector<std::complex<float> > >( + alias(), d_id.c_str(), &gr_ctrlport_probe_c::get, + pmt::make_c32vector(0,-2), + pmt::make_c32vector(0,2), + pmt::make_c32vector(0,0), + "volts", d_desc.c_str(), RPC_PRIVLVL_MIN, + DISPXY | DISPOPTSCATTER))); +#endif /* GR_CTRLPORT */ +} diff --git a/gnuradio-core/src/lib/general/gr_glfsr_source_b.h b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.h index 7549a76b32..27666ab597 100644 --- a/gnuradio-core/src/lib/general/gr_glfsr_source_b.h +++ b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,47 +20,46 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_GR_GLFSR_SOURCE_B_H -#define INCLUDED_GR_GLFSR_SOURCE_B_H +#ifndef INCLUDED_CTRLPORT_PROBE_C_H +#define INCLUDED_CTRLPORT_PROBE_C_H #include <gr_core_api.h> #include <gr_sync_block.h> +#include <rpcregisterhelpers.h> +#include <boost/thread/shared_mutex.hpp> -class gri_glfsr; +class gr_ctrlport_probe_c; +typedef boost::shared_ptr<gr_ctrlport_probe_c> gr_ctrlport_probe_c_sptr; -class gr_glfsr_source_b; -typedef boost::shared_ptr<gr_glfsr_source_b> gr_glfsr_source_b_sptr; +GR_CORE_API gr_ctrlport_probe_c_sptr +gr_make_ctrlport_probe_c(const std::string &id, const std::string &desc); -GR_CORE_API gr_glfsr_source_b_sptr gr_make_glfsr_source_b(int degree, bool repeat=true, int mask=0, int seed=1); - -/*! - * \brief Galois LFSR pseudo-random source - * \ingroup source_blk - */ -class GR_CORE_API gr_glfsr_source_b : public gr_sync_block +class GR_CORE_API gr_ctrlport_probe_c : public gr_sync_block { private: - friend GR_CORE_API gr_glfsr_source_b_sptr - gr_make_glfsr_source_b(int degree, bool repeat, int mask, int seed); + friend GR_CORE_API gr_ctrlport_probe_c_sptr gr_make_ctrlport_probe_c + (const std::string &id, const std::string &desc); - gri_glfsr *d_glfsr; + gr_ctrlport_probe_c(const std::string &id, const std::string &desc); - bool d_repeat; - unsigned int d_index; - unsigned int d_length; + boost::shared_mutex ptrlock; - gr_glfsr_source_b(int degree, bool repeat, int mask, int seed); + std::string d_id; + std::string d_desc; + const gr_complex* d_ptr; + size_t d_ptrLen; public: + ~gr_ctrlport_probe_c(); + + void setup_rpc(); - ~gr_glfsr_source_b(); + std::vector<gr_complex> get(); int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - - unsigned int period() const { return d_length; } - int mask() const; }; -#endif /* INCLUDED_GR_GLFSR_SOURCE_B_H */ +#endif /* INCLUDED_CTRLPORT_GR_CTRLPORT_PROBE_C_H */ + diff --git a/gnuradio-core/src/lib/general/gr_multiply_cc.i b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.i index f0faa3594c..cd4c521cb0 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_cc.i +++ b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.i @@ -20,13 +20,15 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,multiply_cc) +GR_SWIG_BLOCK_MAGIC(gr,ctrlport_probe_c) -gr_multiply_cc_sptr -gr_make_multiply_cc (size_t vlen=1); +gr_ctrlport_probe_c_sptr +gr_make_ctrlport_probe_c(const std::string &id, const std::string &desc); -class gr_multiply_cc : public gr_sync_block +class gr_ctrlport_probe_c : public gr_sync_block { public: - + ~gr_ctrlport_probe_c(); + std::vector<gr_complex> get(); }; + diff --git a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc b/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc deleted file mode 100644 index 319aceeaab..0000000000 --- a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_decode_ccsds_27_fb.h> -#include <gr_io_signature.h> - -gr_decode_ccsds_27_fb_sptr -gr_make_decode_ccsds_27_fb() -{ - return gnuradio::get_initial_sptr(new gr_decode_ccsds_27_fb()); -} - -gr_decode_ccsds_27_fb::gr_decode_ccsds_27_fb() - : gr_sync_decimator("decode_ccsds_27_fb", - gr_make_io_signature(1, 1, sizeof(float)), - gr_make_io_signature(1, 1, sizeof(char)), - 2*8) // Rate 1/2 code, unpacked to packed translation -{ - float RATE = 0.5; - float ebn0 = 12.0; - float esn0 = RATE*pow(10.0, ebn0/10.0); - - gen_met(d_mettab, 100, esn0, 0.0, 256); - viterbi_chunks_init(d_state0); -} - -gr_decode_ccsds_27_fb::~gr_decode_ccsds_27_fb() -{ -} - -int -gr_decode_ccsds_27_fb::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *)input_items[0]; - unsigned char *out = (unsigned char *)output_items[0]; - - for (int i = 0; i < noutput_items*16; i++) { - // Translate and clip [-1.0..1.0] to [28..228] - float sample = in[i]*100.0+128.0; - if (sample > 255.0) - sample = 255.0; - else if (sample < 0.0) - sample = 0.0; - unsigned char sym = (unsigned char)(floor(sample)); - - d_viterbi_in[d_count % 4] = sym; - if ((d_count % 4) == 3) { - // Every fourth symbol, perform butterfly operation - viterbi_butterfly2(d_viterbi_in, d_mettab, d_state0, d_state1); - - // Every sixteenth symbol, read out a byte - if (d_count % 16 == 11) { - // long metric = - viterbi_get_output(d_state0, out++); - // printf("%li\n", *(out-1), metric); - } - } - - d_count++; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.h b/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.h deleted file mode 100644 index df8e6f449d..0000000000 --- a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_DECODE_CCSDS_27_FB_H -#define INCLUDED_GR_DECODE_CCSDS_27_FB_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -extern "C" { -#include <viterbi.h> -} - -class gr_decode_ccsds_27_fb; - -typedef boost::shared_ptr<gr_decode_ccsds_27_fb> gr_decode_ccsds_27_fb_sptr; - -GR_CORE_API gr_decode_ccsds_27_fb_sptr gr_make_decode_ccsds_27_fb(); - -/*! \brief A rate 1/2, k=7 convolutional decoder for the CCSDS standard - * \ingroup ecc - * - * This block performs soft-decision convolutional decoding using the Viterbi - * algorithm. - * - * The input is a stream of (possibly noise corrupted) floating point values - * nominally spanning [-1.0, 1.0], representing the encoded channel symbols - * 0 (-1.0) and 1 (1.0), with erased symbols at 0.0. - * - * The output is MSB first packed bytes of decoded values. - * - * As a rate 1/2 code, there will be one output byte for every 16 input symbols. - * - * This block is designed for continuous data streaming, not packetized data. - * The first 32 bits out will be zeroes, with the output delayed four bytes - * from the corresponding inputs. - */ - -class GR_CORE_API gr_decode_ccsds_27_fb : public gr_sync_decimator -{ -private: - friend GR_CORE_API gr_decode_ccsds_27_fb_sptr gr_make_decode_ccsds_27_fb(); - - gr_decode_ccsds_27_fb(); - - // Viterbi state - int d_mettab[2][256]; - struct viterbi_state d_state0[64]; - struct viterbi_state d_state1[64]; - unsigned char d_viterbi_in[16]; - - int d_count; - -public: - ~gr_decode_ccsds_27_fb(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_DECODE_CCSDS_27_FB_H */ diff --git a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.i b/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.i deleted file mode 100644 index f2e13b593a..0000000000 --- a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,decode_ccsds_27_fb); - -gr_decode_ccsds_27_fb_sptr gr_make_decode_ccsds_27_fb (); - -class gr_decode_ccsds_27_fb : public gr_sync_decimator -{ -private: - gr_decode_ccsds_27_fb(); -}; diff --git a/gnuradio-core/src/lib/general/gr_deinterleave.cc b/gnuradio-core/src/lib/general/gr_deinterleave.cc deleted file mode 100644 index e22db60c1a..0000000000 --- a/gnuradio-core/src/lib/general/gr_deinterleave.cc +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_deinterleave.h> -#include <gr_io_signature.h> -#include <string.h> - - -gr_deinterleave_sptr -gr_make_deinterleave (size_t itemsize) -{ - return gnuradio::get_initial_sptr(new gr_deinterleave (itemsize)); -} - -gr_deinterleave::gr_deinterleave (size_t itemsize) - : gr_sync_decimator ("deinterleave", - gr_make_io_signature (1, 1, itemsize), - gr_make_io_signature (1, gr_io_signature::IO_INFINITE, itemsize), - 1), - d_itemsize (itemsize) -{ -} - -gr_deinterleave::~gr_deinterleave () -{ - // NOP -} - -bool -gr_deinterleave::check_topology (int ninputs, int noutputs) -{ - set_decimation (noutputs); - return true; -} - -int -gr_deinterleave::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t nchan = output_items.size (); - size_t itemsize = d_itemsize; - const char *in = (const char *) input_items[0]; - char **out = (char **) &output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - for (unsigned int n = 0; n < nchan; n++){ - memcpy (out[n], in, itemsize); - out[n] += itemsize; - in += itemsize; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_deinterleave.h b/gnuradio-core/src/lib/general/gr_deinterleave.h deleted file mode 100644 index 0eecc44d13..0000000000 --- a/gnuradio-core/src/lib/general/gr_deinterleave.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_DEINTERLEAVE_H -#define INCLUDED_GR_DEINTERLEAVE_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_deinterleave; -typedef boost::shared_ptr<gr_deinterleave> gr_deinterleave_sptr; - -GR_CORE_API gr_deinterleave_sptr gr_make_deinterleave (size_t itemsize); - -/*! - * \brief deinterleave a single input into N outputs - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_deinterleave : public gr_sync_decimator -{ - friend GR_CORE_API gr_deinterleave_sptr gr_make_deinterleave (size_t itemsize); - - size_t d_itemsize; - - gr_deinterleave (size_t itemsize); - -public: - ~gr_deinterleave (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool check_topology (int ninputs, int noutputs); - -}; - -#endif /* INCLUDED_GR_DEINTERLEAVE_H */ diff --git a/gnuradio-core/src/lib/general/gr_deinterleave.i b/gnuradio-core/src/lib/general/gr_deinterleave.i deleted file mode 100644 index a70ce6c527..0000000000 --- a/gnuradio-core/src/lib/general/gr_deinterleave.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,deinterleave) - -gr_deinterleave_sptr gr_make_deinterleave (size_t itemsize); - -class gr_deinterleave : public gr_sync_decimator -{ - gr_deinterleave (size_t itemsize); -}; diff --git a/gnuradio-core/src/lib/general/gr_delay.cc b/gnuradio-core/src/lib/general/gr_delay.cc deleted file mode 100644 index 8f728948df..0000000000 --- a/gnuradio-core/src/lib/general/gr_delay.cc +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_delay.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_delay_sptr -gr_make_delay (size_t itemsize, int delay) -{ - return gnuradio::get_initial_sptr(new gr_delay (itemsize, delay)); -} - -gr_delay::gr_delay (size_t itemsize, int delay) - : gr_block ("delay", - gr_make_io_signature (1, -1, itemsize), - gr_make_io_signature (1, -1, itemsize)), - d_itemsize(itemsize) -{ - set_delay(delay); - d_delta = 0; -} - -void -gr_delay::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - // make sure all inputs have noutput_items available - unsigned ninputs = ninput_items_required.size (); - for (unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = noutput_items; -} - -void -gr_delay::set_delay (int d) -{ - // only set a new delta if there is a change in the delay; this - // protects from quickly-repeated calls to this function that would - // end with d_delta=0. - if(d != delay()) { - gruel::scoped_lock l(d_mutex_delay); - int old = delay(); - set_history(d+1); - d_delta += delay() - old; - } -} - -int -gr_delay::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gruel::scoped_lock l(d_mutex_delay); - assert(input_items.size() == output_items.size()); - - const char *iptr; - char *optr; - int cons, ret; - - // No change in delay; just memcpy ins to outs - if(d_delta == 0) { - for(size_t i = 0; i < input_items.size(); i++) { - iptr = (const char *) input_items[i]; - optr = (char *) output_items[i]; - std::memcpy(optr, iptr, noutput_items*d_itemsize); - } - cons = noutput_items; - ret = noutput_items; - } - - // Skip over d_delta items on the input - else if(d_delta < 0) { - int n_to_copy, n_adj; - int delta = -d_delta; - n_to_copy = std::max(0, noutput_items-delta); - n_adj = std::min(delta, noutput_items); - for(size_t i = 0; i < input_items.size(); i++) { - iptr = (const char *) input_items[i]; - optr = (char *) output_items[i]; - std::memcpy(optr, iptr+delta*d_itemsize, n_to_copy*d_itemsize); - } - cons = noutput_items; - ret = n_to_copy; - delta -= n_adj; - d_delta = -delta; - } - - //produce but not consume (inserts zeros) - else { // d_delta > 0 - int n_from_input, n_padding; - n_from_input = std::max(0, noutput_items-d_delta); - n_padding = std::min(d_delta, noutput_items); - for(size_t i = 0; i < input_items.size(); i++) { - iptr = (const char *) input_items[i]; - optr = (char *) output_items[i]; - std::memset(optr, 0, n_padding*d_itemsize); - std::memcpy(optr, iptr, n_from_input*d_itemsize); - } - cons = n_from_input; - ret = noutput_items; - d_delta -= n_padding; - } - - consume_each(cons); - return ret; -} diff --git a/gnuradio-core/src/lib/general/gr_delay.h b/gnuradio-core/src/lib/general/gr_delay.h deleted file mode 100644 index ed05c47f43..0000000000 --- a/gnuradio-core/src/lib/general/gr_delay.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_DELAY_H -#define INCLUDED_GR_DELAY_H - -#include <gr_core_api.h> -#include <gr_block.h> -#include <gruel/thread.h> - -class gr_delay; -typedef boost::shared_ptr<gr_delay> gr_delay_sptr; - -GR_CORE_API gr_delay_sptr gr_make_delay (size_t itemsize, int delay); - -/*! - * \brief delay the input by a certain number of samples - * \ingroup misc_blk - */ -class GR_CORE_API gr_delay : public gr_block -{ - friend GR_CORE_API gr_delay_sptr gr_make_delay (size_t itemsize, int delay); - - gr_delay (size_t itemsize, int delay); - - void forecast (int noutput_items, gr_vector_int &ninput_items_required); - - size_t d_itemsize; - int d_delta; - gruel::mutex d_mutex_delay; - - public: - int delay () const { return history()-1; } - void set_delay (int delay); - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_delay.i b/gnuradio-core/src/lib/general/gr_delay.i deleted file mode 100644 index f3d49891d7..0000000000 --- a/gnuradio-core/src/lib/general/gr_delay.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,delay) - - gr_delay_sptr gr_make_delay (size_t itemsize, int delay); - -class gr_delay : public gr_block -{ - private: - gr_delay (size_t itemsize, int delay); - - public: - int delay() const { return history()-1; } - void set_delay (int delay) { set_history(delay+1); } -}; diff --git a/gnuradio-core/src/lib/general/gr_descrambler_bb.cc b/gnuradio-core/src/lib/general/gr_descrambler_bb.cc deleted file mode 100644 index b5ae28fa97..0000000000 --- a/gnuradio-core/src/lib/general/gr_descrambler_bb.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_descrambler_bb.h> -#include <gr_io_signature.h> - -gr_descrambler_bb_sptr -gr_make_descrambler_bb(int mask, int seed, int len) -{ - return gnuradio::get_initial_sptr(new gr_descrambler_bb(mask, seed, len)); -} - -gr_descrambler_bb::gr_descrambler_bb(int mask, int seed, int len) - : gr_sync_block("descrambler_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_lfsr(mask, seed, len) -{ -} - -int -gr_descrambler_bb::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++) - out[i] = d_lfsr.next_bit_descramble(in[i]); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_descrambler_bb.h b/gnuradio-core/src/lib/general/gr_descrambler_bb.h deleted file mode 100644 index 333593caaf..0000000000 --- a/gnuradio-core/src/lib/general/gr_descrambler_bb.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_DESCRAMBLER_BB_H -#define INCLUDED_GR_DESCRAMBLER_BB_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include "gri_lfsr.h" - -class gr_descrambler_bb; -typedef boost::shared_ptr<gr_descrambler_bb> gr_descrambler_bb_sptr; - -GR_CORE_API gr_descrambler_bb_sptr gr_make_descrambler_bb(int mask, int seed, int len); - -/*! - * Descramble an input stream using an LFSR. This block works on the LSB only - * of the input data stream, i.e., on an "unpacked binary" stream, and - * produces the same format on its output. - * - * \param mask Polynomial mask for LFSR - * \param seed Initial shift register contents - * \param len Shift register length - * - * \ingroup coding_blk - */ - -class GR_CORE_API gr_descrambler_bb : public gr_sync_block -{ - friend GR_CORE_API gr_descrambler_bb_sptr gr_make_descrambler_bb(int mask, int seed, int len); - - gri_lfsr d_lfsr; - - gr_descrambler_bb(int mask, int seed, int len); - -public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_DESCRAMBLER_BB_H */ diff --git a/gnuradio-core/src/lib/general/gr_descrambler_bb.i b/gnuradio-core/src/lib/general/gr_descrambler_bb.i deleted file mode 100644 index c6cd0a2852..0000000000 --- a/gnuradio-core/src/lib/general/gr_descrambler_bb.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,descrambler_bb); - -gr_descrambler_bb_sptr gr_make_descrambler_bb(int mask, int seed, int len); - -class gr_descrambler_bb : public gr_sync_block -{ -private: - gr_descrambler_bb(int mask, int seed, int len); -}; diff --git a/gnuradio-core/src/lib/general/gr_diff_decoder_bb.cc b/gnuradio-core/src/lib/general/gr_diff_decoder_bb.cc deleted file mode 100644 index 74324a62ea..0000000000 --- a/gnuradio-core/src/lib/general/gr_diff_decoder_bb.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_diff_decoder_bb.h> -#include <gr_io_signature.h> - -gr_diff_decoder_bb_sptr -gr_make_diff_decoder_bb (unsigned int modulus) -{ - return gnuradio::get_initial_sptr(new gr_diff_decoder_bb(modulus)); -} - -gr_diff_decoder_bb::gr_diff_decoder_bb (unsigned int modulus) - : gr_sync_block ("diff_decoder_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_modulus(modulus) -{ - set_history(2); // need to look at two inputs -} - -int -gr_diff_decoder_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - in += 1; // ensure that in[-1] is valid - - unsigned modulus = d_modulus; - - for (int i = 0; i < noutput_items; i++){ - out[i] = (in[i] - in[i-1]) % modulus; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_diff_decoder_bb.h b/gnuradio-core/src/lib/general/gr_diff_decoder_bb.h deleted file mode 100644 index c4ebbc4765..0000000000 --- a/gnuradio-core/src/lib/general/gr_diff_decoder_bb.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_DIFF_DECODER_BB_H -#define INCLUDED_GR_DIFF_DECODER_BB_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_diff_decoder_bb; -typedef boost::shared_ptr<gr_diff_decoder_bb> gr_diff_decoder_bb_sptr; - -GR_CORE_API gr_diff_decoder_bb_sptr gr_make_diff_decoder_bb (unsigned int modulus); - -/*! - * \brief y[0] = (x[0] - x[-1]) % M - * \ingroup coding_blk - * - * Differential decoder - */ -class GR_CORE_API gr_diff_decoder_bb : public gr_sync_block -{ - friend GR_CORE_API gr_diff_decoder_bb_sptr gr_make_diff_decoder_bb (unsigned int modulus); - gr_diff_decoder_bb(unsigned int modulus); - - unsigned int d_modulus; - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_diff_decoder_bb.i b/gnuradio-core/src/lib/general/gr_diff_decoder_bb.i deleted file mode 100644 index 3dddb17c3e..0000000000 --- a/gnuradio-core/src/lib/general/gr_diff_decoder_bb.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,diff_decoder_bb) - -gr_diff_decoder_bb_sptr gr_make_diff_decoder_bb (unsigned int modulus); - -class gr_diff_decoder_bb : public gr_sync_block -{ - private: - gr_diff_decoder_bb (unsigned int modulus); -}; diff --git a/gnuradio-core/src/lib/general/gr_diff_encoder_bb.cc b/gnuradio-core/src/lib/general/gr_diff_encoder_bb.cc deleted file mode 100644 index 98492c746e..0000000000 --- a/gnuradio-core/src/lib/general/gr_diff_encoder_bb.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_diff_encoder_bb.h> -#include <gr_io_signature.h> - -gr_diff_encoder_bb_sptr -gr_make_diff_encoder_bb (unsigned int modulus) -{ - return gnuradio::get_initial_sptr(new gr_diff_encoder_bb(modulus)); -} - -gr_diff_encoder_bb::gr_diff_encoder_bb (unsigned int modulus) - : gr_sync_block ("diff_encoder_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_last_out(0), d_modulus(modulus) -{ -} - -int -gr_diff_encoder_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - unsigned last_out = d_last_out; - unsigned modulus = d_modulus; - - for (int i = 0; i < noutput_items; i++){ - out[i] = (in[i] + last_out) % modulus; - last_out = out[i]; - } - - d_last_out = last_out; - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_diff_encoder_bb.h b/gnuradio-core/src/lib/general/gr_diff_encoder_bb.h deleted file mode 100644 index e98876b700..0000000000 --- a/gnuradio-core/src/lib/general/gr_diff_encoder_bb.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_DIFF_ENCODER_BB_H -#define INCLUDED_GR_DIFF_ENCODER_BB_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_diff_encoder_bb; -typedef boost::shared_ptr<gr_diff_encoder_bb> gr_diff_encoder_bb_sptr; - -GR_CORE_API gr_diff_encoder_bb_sptr gr_make_diff_encoder_bb (unsigned int modulus); - -/*! - * \brief y[0] = (x[0] + y[-1]) % M - * \ingroup coding_blk - * - * Differential encoder - */ -class GR_CORE_API gr_diff_encoder_bb : public gr_sync_block -{ - friend GR_CORE_API gr_diff_encoder_bb_sptr gr_make_diff_encoder_bb (unsigned int modulus); - gr_diff_encoder_bb(unsigned int modulus); - - unsigned int d_last_out; - unsigned int d_modulus; - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_diff_encoder_bb.i b/gnuradio-core/src/lib/general/gr_diff_encoder_bb.i deleted file mode 100644 index 96dadaca5b..0000000000 --- a/gnuradio-core/src/lib/general/gr_diff_encoder_bb.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,diff_encoder_bb) - -gr_diff_encoder_bb_sptr gr_make_diff_encoder_bb (unsigned int modulus); - -class gr_diff_encoder_bb : public gr_sync_block -{ - private: - gr_diff_encoder_bb (unsigned int modulus); -}; diff --git a/gnuradio-core/src/lib/general/gr_diff_phasor_cc.cc b/gnuradio-core/src/lib/general/gr_diff_phasor_cc.cc deleted file mode 100644 index 89fa2041e7..0000000000 --- a/gnuradio-core/src/lib/general/gr_diff_phasor_cc.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_diff_phasor_cc.h> -#include <gr_io_signature.h> - -gr_diff_phasor_cc_sptr -gr_make_diff_phasor_cc () -{ - return gnuradio::get_initial_sptr(new gr_diff_phasor_cc()); -} - -gr_diff_phasor_cc::gr_diff_phasor_cc () - : gr_sync_block ("diff_phasor_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))) -{ - set_history(2); -} - - -gr_diff_phasor_cc::~gr_diff_phasor_cc(){} - -int -gr_diff_phasor_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex const *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - in += 1; // ensure that i - 1 is valid. - - for(int i = 0; i < noutput_items; i++){ - out[i] = in[i] * conj(in[i-1]); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_diff_phasor_cc.h b/gnuradio-core/src/lib/general/gr_diff_phasor_cc.h deleted file mode 100644 index 21c4f616d5..0000000000 --- a/gnuradio-core/src/lib/general/gr_diff_phasor_cc.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_DIFF_PHASOR_CC_H -#define INCLUDED_GR_DIFF_PHASOR_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -/*! - * \brief Please fix my documentation! - * \ingroup misc - */ -class gr_diff_phasor_cc; -typedef boost::shared_ptr<gr_diff_phasor_cc> gr_diff_phasor_cc_sptr; - -GR_CORE_API gr_diff_phasor_cc_sptr gr_make_diff_phasor_cc (); - - -class GR_CORE_API gr_diff_phasor_cc : public gr_sync_block -{ - friend GR_CORE_API gr_diff_phasor_cc_sptr gr_make_diff_phasor_cc (); - - gr_diff_phasor_cc (); //constructor - - public: - ~gr_diff_phasor_cc(); //destructor - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_diff_phasor_cc.i b/gnuradio-core/src/lib/general/gr_diff_phasor_cc.i deleted file mode 100644 index 8aecd5cc77..0000000000 --- a/gnuradio-core/src/lib/general/gr_diff_phasor_cc.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,diff_phasor_cc) - -gr_diff_phasor_cc_sptr gr_make_diff_phasor_cc (); - -class gr_diff_phasor_cc : public gr_sync_block -{ - private: - gr_diff_phasor_cc (); - - public: - ~gr_diff_phasor_cc(); -}; diff --git a/gnuradio-core/src/lib/general/gr_dpll_bb.cc b/gnuradio-core/src/lib/general/gr_dpll_bb.cc deleted file mode 100644 index 1d5a0d4fda..0000000000 --- a/gnuradio-core/src/lib/general/gr_dpll_bb.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_dpll_bb.h> -#include <gr_io_signature.h> -#include <cstdio> - -gr_dpll_bb_sptr -gr_make_dpll_bb (float period, float gain) -{ - return gnuradio::get_initial_sptr(new gr_dpll_bb (period, gain)); -} - -gr_dpll_bb::gr_dpll_bb (float period, float gain) - : gr_sync_block ("dpll_bb", - gr_make_io_signature (1, 1, sizeof (char)), - gr_make_io_signature (1, 1, sizeof (char))), - d_restart(0),d_pulse_phase(0) -{ - d_pulse_frequency = 1.0/period; - d_gain = gain; - d_decision_threshold = 1.0 - 0.5*d_pulse_frequency; -#if 1 - fprintf(stderr,"frequency = %f period = %f gain = %f threshold = %f\n", - d_pulse_frequency, - period, - d_gain, - d_decision_threshold); -#endif -} - -int -gr_dpll_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *iptr = (const char *) input_items[0]; - char *optr = (char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - optr[i]= 0; - if(iptr[i] == 1) { - if (d_restart == 0) { - d_pulse_phase = 1; - } else { - if (d_pulse_phase > 0.5) d_pulse_phase += d_gain*(1.0-d_pulse_phase); - else d_pulse_phase -= d_gain*d_pulse_phase; - } - d_restart = 3; - } - if (d_pulse_phase > d_decision_threshold) { - d_pulse_phase -= 1.0; - if (d_restart > 0) { - d_restart -= 1; - optr[i] = 1; - } - } - d_pulse_phase += d_pulse_frequency; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_dpll_bb.h b/gnuradio-core/src/lib/general/gr_dpll_bb.h deleted file mode 100644 index a7df974fb4..0000000000 --- a/gnuradio-core/src/lib/general/gr_dpll_bb.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_DPLL_BB_H -#define INCLUDED_GR_DPLL_BB_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_dpll_bb; -typedef boost::shared_ptr<gr_dpll_bb> gr_dpll_bb_sptr; - -GR_CORE_API gr_dpll_bb_sptr gr_make_dpll_bb (float period, float gain); - -/*! - * \brief Detect the peak of a signal - * \ingroup level_blk - * - * If a peak is detected, this block outputs a 1, - * or it outputs 0's. - */ -class GR_CORE_API gr_dpll_bb : public gr_sync_block -{ - friend GR_CORE_API gr_dpll_bb_sptr gr_make_dpll_bb (float period, float gain); - - gr_dpll_bb (float period, float gain); - - private: - unsigned char d_restart; - float d_pulse_phase, d_pulse_frequency,d_gain,d_decision_threshold; - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_dpll_bb.i b/gnuradio-core/src/lib/general/gr_dpll_bb.i deleted file mode 100644 index f31a873743..0000000000 --- a/gnuradio-core/src/lib/general/gr_dpll_bb.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,dpll_bb) - - gr_dpll_bb_sptr gr_make_dpll_bb (float period, float gain); - -class gr_dpll_bb : public gr_sync_block -{ - private: - gr_dpll_bb (float period, float gain); -}; diff --git a/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.cc b/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.cc deleted file mode 100644 index 4a92d113a5..0000000000 --- a/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 Free Software Foundation, Inc. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_encode_ccsds_27_bb.h> -#include <gr_io_signature.h> - -extern "C" { -#include <../viterbi/viterbi.h> -} - -gr_encode_ccsds_27_bb_sptr -gr_make_encode_ccsds_27_bb() -{ - return gnuradio::get_initial_sptr(new gr_encode_ccsds_27_bb()); -} - -gr_encode_ccsds_27_bb::gr_encode_ccsds_27_bb() - : gr_sync_interpolator("encode_ccsds_27_bb", - gr_make_io_signature(1, 1, sizeof(char)), - gr_make_io_signature(1, 1, sizeof(char)), - 16) // Rate 1/2 code, packed to unpacked conversion -{ - d_encstate = 0; -} - -gr_encode_ccsds_27_bb::~gr_encode_ccsds_27_bb() -{ -} - -int -gr_encode_ccsds_27_bb::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - unsigned char *in = (unsigned char *)input_items[0]; - unsigned char *out = (unsigned char *)output_items[0]; - - d_encstate = encode(out, in, noutput_items/16, d_encstate); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.h b/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.h deleted file mode 100644 index 94e9c33f1b..0000000000 --- a/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_ENCODE_CCSDS_27_BB_H -#define INCLUDED_GR_ENCODE_CCSDS_27_BB_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_encode_ccsds_27_bb; - -typedef boost::shared_ptr<gr_encode_ccsds_27_bb> gr_encode_ccsds_27_bb_sptr; - -GR_CORE_API gr_encode_ccsds_27_bb_sptr gr_make_encode_ccsds_27_bb(); - -/*! \brief A rate 1/2, k=7 convolutional encoder for the CCSDS standard - * \ingroup ecc - * - * This block performs convolutional encoding using the CCSDS standard - * polynomial ("Voyager"). - * - * The input is an MSB first packed stream of bits. - * - * The output is a stream of symbols 0 or 1 representing the encoded data. - * - * As a rate 1/2 code, there will be 16 output symbols for every input byte. - * - * This block is designed for continuous data streaming, not packetized data. - * There is no provision to "flush" the encoder. - */ - -class GR_CORE_API gr_encode_ccsds_27_bb : public gr_sync_interpolator -{ -private: - friend GR_CORE_API gr_encode_ccsds_27_bb_sptr gr_make_encode_ccsds_27_bb(); - - gr_encode_ccsds_27_bb(); - unsigned char d_encstate; - - public: - ~gr_encode_ccsds_27_bb(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_ENCODE_CCSDS_27_BB_H */ diff --git a/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.i b/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.i deleted file mode 100644 index e74e9174ac..0000000000 --- a/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,encode_ccsds_27_bb); - -gr_encode_ccsds_27_bb_sptr gr_make_encode_ccsds_27_bb (); - -class gr_encode_ccsds_27_bb : public gr_sync_interpolator -{ -private: - gr_encode_ccsds_27_bb(); -}; diff --git a/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.cc b/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.cc deleted file mode 100644 index 147b64e9bf..0000000000 --- a/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_feedforward_agc_cc.h> -#include <gr_io_signature.h> -#include <stdexcept> - -gr_feedforward_agc_cc_sptr -gr_make_feedforward_agc_cc(int nsamples, float reference) -{ - return gnuradio::get_initial_sptr(new gr_feedforward_agc_cc (nsamples, reference)); -} - -gr_feedforward_agc_cc::gr_feedforward_agc_cc (int nsamples, float reference) - : gr_sync_block ("gr_feedforward_agc_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_nsamples(nsamples), d_reference(reference) -{ - if (nsamples < 1) - throw std::invalid_argument("gr_feedforward_agc_cc: nsamples must be >= 1"); - - set_history(nsamples); -} - -gr_feedforward_agc_cc::~gr_feedforward_agc_cc() -{ -} - -inline static float -mag_squared(gr_complex x) -{ - return x.real() * x.real() + x.imag() * x.imag(); -} - -// approximate sqrt(x^2 + y^2) -inline static float -envelope(gr_complex x) -{ - float r_abs = std::fabs(x.real()); - float i_abs = std::fabs(x.imag()); - - if (r_abs > i_abs) - return r_abs + 0.4 * i_abs; - else - return i_abs + 0.4 * r_abs; -} - -int -gr_feedforward_agc_cc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - int nsamples = d_nsamples; - float gain; - - for (int i = 0; i < noutput_items; i++){ - //float max_env = 1e-12; // avoid divide by zero - float max_env = 1e-4; // avoid divide by zero, indirectly set max gain - for (int j = 0; j < nsamples; j++) - max_env = std::max(max_env, envelope(in[i+j])); - gain = d_reference / max_env; - out[i] = gain * in[i]; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h b/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h deleted file mode 100644 index 63e5e4c436..0000000000 --- a/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FEEDFORWARD_AGC_CC_H -#define INCLUDED_GR_FEEDFORWARD_AGC_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_feedforward_agc_cc; -typedef boost::shared_ptr<gr_feedforward_agc_cc> gr_feedforward_agc_cc_sptr; - -GR_CORE_API gr_feedforward_agc_cc_sptr -gr_make_feedforward_agc_cc(int nsamples, float reference = 1.0); - -/*! - * \brief Non-causal AGC which computes required gain based on max absolute value over nsamples - * \ingroup level_blk - */ -class GR_CORE_API gr_feedforward_agc_cc : public gr_sync_block -{ - friend GR_CORE_API gr_feedforward_agc_cc_sptr - gr_make_feedforward_agc_cc(int nsamples, float reference); - - int d_nsamples; - float d_reference; - - gr_feedforward_agc_cc(int nsamples, float reference); - - public: - ~gr_feedforward_agc_cc(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FEEDFORWARD_AGC_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.i b/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.i deleted file mode 100644 index 1fd5a2c26d..0000000000 --- a/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,feedforward_agc_cc); - -gr_feedforward_agc_cc_sptr -gr_make_feedforward_agc_cc(int nsamples, float reference = 1.0); - -class gr_feedforward_agc_cc : public gr_sync_block -{ - gr_feedforward_agc_cc(int nsamples, float reference); - - public: - ~gr_feedforward_agc_cc(); -}; diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.cc b/gnuradio-core/src/lib/general/gr_fft_vcc.cc deleted file mode 100644 index addcddb64a..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vcc.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2008,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_fft_vcc.h> // abstract class -#include <gr_fft_vcc_fftw.h> // concrete class -#include <gr_io_signature.h> -#include <gri_fft.h> -#include <math.h> -#include <string.h> - -gr_fft_vcc_sptr -gr_make_fft_vcc (int fft_size, bool forward, - const std::vector<float> &window, - bool shift, int nthreads) -{ - return gr_make_fft_vcc_fftw(fft_size, forward, - window, shift, nthreads); -} - -gr_fft_vcc::gr_fft_vcc (const std::string &name, - int fft_size, bool forward, const std::vector<float> &window, - bool shift) - : gr_sync_block (name, - gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex)), - gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex))), - d_fft_size(fft_size), d_forward(forward), d_shift(shift) -{ - set_window(window); -} - -gr_fft_vcc::~gr_fft_vcc () -{ -} - -bool -gr_fft_vcc::set_window(const std::vector<float> &window) -{ - if(window.size()==0 || window.size()==d_fft_size) { - d_window=window; - return true; - } - else - return false; -} - -void -gr_fft_vcc::set_nthreads(int n) -{ - throw std::runtime_error("gr_fft_vcc::set_nthreads not implemented."); -} - -int -gr_fft_vcc::nthreads() const -{ - throw std::runtime_error("gr_fft_vcc::nthreads not implemented."); - return 0; -} diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.h b/gnuradio-core/src/lib/general/gr_fft_vcc.h deleted file mode 100644 index db5690d41d..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vcc.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2008,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FFT_VCC_H -#define INCLUDED_GR_FFT_VCC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_fft_vcc; -typedef boost::shared_ptr<gr_fft_vcc> gr_fft_vcc_sptr; - -GR_CORE_API gr_fft_vcc_sptr -gr_make_fft_vcc (int fft_size, bool forward, - const std::vector<float> &window, - bool shift=false, int nthreads=1); - -/*! - * \brief Compute forward or reverse FFT. complex vector in / complex vector out. - * \ingroup dft_blk - * - * Abstract base class - */ -class GR_CORE_API gr_fft_vcc : public gr_sync_block -{ -protected: - friend GR_CORE_API gr_fft_vcc_sptr - gr_make_fft_vcc (int fft_size, bool forward, - const std::vector<float> &window, - bool shift); - - unsigned int d_fft_size; - std::vector<float> d_window; - bool d_forward; - bool d_shift; - - gr_fft_vcc (const std::string &name, int fft_size, bool forward, - const std::vector<float> &window, bool shift); - - public: - ~gr_fft_vcc (); - - virtual void set_nthreads(int n); - virtual int nthreads() const; - - bool set_window(const std::vector<float> &window); -}; - -#endif /* INCLUDED_GR_FFT_VCC_H */ diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.i b/gnuradio-core/src/lib/general/gr_fft_vcc.i deleted file mode 100644 index f9caae7d8d..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vcc.i +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2008,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr, fft_vcc) - -gr_fft_vcc_sptr -gr_make_fft_vcc (int fft_size, bool forward, - const std::vector<float> &window, - bool shift=false, int nthreads=1); - -class gr_fft_vcc : public gr_sync_block -{ - protected: - gr_fft_vcc (int fft_size, bool forward, - const std::vector<float> &window, - bool shift); - - public: - bool set_window(const std::vector<float> &window); - void set_nthreads(int n); - int nthreads() const; -}; diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc deleted file mode 100644 index 891173bcd8..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_fft_vcc_fftw.h> -#include <gr_io_signature.h> -#include <gri_fft.h> -#include <math.h> -#include <string.h> - -gr_fft_vcc_sptr -gr_make_fft_vcc_fftw (int fft_size, bool forward, - const std::vector<float> &window, - bool shift, int nthreads) -{ - return gnuradio::get_initial_sptr(new gr_fft_vcc_fftw - (fft_size, forward, window, - shift, nthreads)); -} - -gr_fft_vcc_fftw::gr_fft_vcc_fftw (int fft_size, bool forward, - const std::vector<float> &window, - bool shift, int nthreads) - : gr_fft_vcc("fft_vcc_fftw", fft_size, forward, window, shift) -{ - d_fft = new gri_fft_complex (d_fft_size, forward, nthreads); -} - -gr_fft_vcc_fftw::~gr_fft_vcc_fftw () -{ - delete d_fft; -} - -void -gr_fft_vcc_fftw::set_nthreads(int n) -{ - d_fft->set_nthreads(n); -} - -int -gr_fft_vcc_fftw::nthreads() const -{ - return d_fft->nthreads(); -} - -int -gr_fft_vcc_fftw::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - unsigned int input_data_size = input_signature()->sizeof_stream_item (0); - unsigned int output_data_size = output_signature()->sizeof_stream_item (0); - - int count = 0; - - while (count++ < noutput_items){ - - // copy input into optimally aligned buffer - - if (d_window.size()){ - gr_complex *dst = d_fft->get_inbuf(); - if(!d_forward && d_shift){ - unsigned int offset = (!d_forward && d_shift)?(d_fft_size/2):0; - int fft_m_offset = d_fft_size - offset; - for (unsigned int i = 0; i < offset; i++) // apply window - dst[i+fft_m_offset] = in[i] * d_window[i]; - for (unsigned int i = offset; i < d_fft_size; i++) // apply window - dst[i-offset] = in[i] * d_window[i]; - } else { - for (unsigned int i = 0; i < d_fft_size; i++) // apply window - dst[i] = in[i] * d_window[i]; - } - } - else { - if(!d_forward && d_shift) { // apply an ifft shift on the data - gr_complex *dst = d_fft->get_inbuf(); - unsigned int len = (unsigned int)(floor(d_fft_size/2.0)); // half length of complex array - memcpy(&dst[0], &in[len], sizeof(gr_complex)*(d_fft_size - len)); - memcpy(&dst[d_fft_size - len], &in[0], sizeof(gr_complex)*len); - } - else { - memcpy (d_fft->get_inbuf(), in, input_data_size); - } - } - - // compute the fft - d_fft->execute (); - - // copy result to our output - if(d_forward && d_shift) { // apply a fft shift on the data - unsigned int len = (unsigned int)(ceil(d_fft_size/2.0)); - memcpy(&out[0], &d_fft->get_outbuf()[len], sizeof(gr_complex)*(d_fft_size - len)); - memcpy(&out[d_fft_size - len], &d_fft->get_outbuf()[0], sizeof(gr_complex)*len); - } - else { - memcpy (out, d_fft->get_outbuf (), output_data_size); - } - - in += d_fft_size; - out += d_fft_size; - } - - return noutput_items; -} - diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h deleted file mode 100644 index 967ceaefb6..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FFT_VCC_FFTW_H -#define INCLUDED_GR_FFT_VCC_FFTW_H - -#include <gr_core_api.h> -#include <gr_fft_vcc.h> - -class gri_fft_complex; - -GR_CORE_API gr_fft_vcc_sptr -gr_make_fft_vcc_fftw (int fft_size, bool forward, - const std::vector<float> &window, - bool shift=false, int nthreads=1); - -/*! - * \brief Compute forward or reverse FFT. complex vector in / complex vector out. - * \ingroup dft_blk - * - * Concrete class that uses FFTW. - */ -class GR_CORE_API gr_fft_vcc_fftw : public gr_fft_vcc -{ - friend GR_CORE_API gr_fft_vcc_sptr - gr_make_fft_vcc_fftw (int fft_size, bool forward, - const std::vector<float> &window, - bool shift, int nthreads); - - gri_fft_complex *d_fft; - - gr_fft_vcc_fftw (int fft_size, bool forward, - const std::vector<float> &window, - bool shift, int nthreads=1); - - public: - ~gr_fft_vcc_fftw (); - - void set_nthreads(int n); - int nthreads() const; - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_FFT_VCC_FFTW_H */ diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.cc b/gnuradio-core/src/lib/general/gr_fft_vfc.cc deleted file mode 100644 index 2396055b93..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vfc.cc +++ /dev/null @@ -1,135 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_fft_vfc.h> -#include <gr_io_signature.h> -#include <gri_fft.h> -#include <math.h> -#include <stdexcept> -#include <string.h> -#include <cstdio> - - -// FIXME after this is working, change to use native real to complex fft. -// It should run twice as fast. - - - - -gr_fft_vfc_sptr -gr_make_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads) -{ - return gnuradio::get_initial_sptr(new gr_fft_vfc (fft_size, forward, - window, nthreads)); -} - -gr_fft_vfc::gr_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads) - : gr_sync_block ("fft_vfc", - gr_make_io_signature (1, 1, fft_size * sizeof (float)), - gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex))), - d_fft_size(fft_size), d_window() -{ - if (!forward){ - fprintf (stderr, "fft_vfc: forward must == true\n"); - throw std::invalid_argument ("fft_vfc: forward must == true"); - } - - d_fft = new gri_fft_complex (d_fft_size, forward, nthreads); - - set_window(window); -} - -gr_fft_vfc::~gr_fft_vfc () -{ - delete d_fft; -} - -void -gr_fft_vfc::set_nthreads(int n) -{ - d_fft->set_nthreads(n); -} - -int -gr_fft_vfc::nthreads() const -{ - return d_fft->nthreads(); -} - -int -gr_fft_vfc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - unsigned int output_data_size = output_signature()->sizeof_stream_item (0); - - int count = 0; - - while (count++ < noutput_items){ - - // copy input into optimally aligned buffer - - if (d_window.size()){ - gr_complex *dst = d_fft->get_inbuf(); - for (unsigned int i = 0; i < d_fft_size; i++) // apply window - dst[i] = in[i] * d_window[i]; - } - else { - gr_complex *dst = d_fft->get_inbuf(); - for (unsigned int i = 0; i < d_fft_size; i++) // float to complex conversion - dst[i] = in[i]; - } - - // compute the fft - d_fft->execute (); - - // cpoy result to our output - memcpy (out, d_fft->get_outbuf (), output_data_size); - - in += d_fft_size; - out += d_fft_size; - } - - return noutput_items; -} - -bool -gr_fft_vfc::set_window(const std::vector<float> &window) -{ - if(window.size()==0 || window.size()==d_fft_size) { - d_window=window; - return true; - } - else - return false; -} diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.h b/gnuradio-core/src/lib/general/gr_fft_vfc.h deleted file mode 100644 index 35b95313d3..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vfc.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FFT_VFC_H -#define INCLUDED_GR_FFT_VFC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gri_fft_complex; - -class gr_fft_vfc; -typedef boost::shared_ptr<gr_fft_vfc> gr_fft_vfc_sptr; - -GR_CORE_API gr_fft_vfc_sptr -gr_make_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads=1); - -/*! - * \brief Compute forward FFT. float vector in / complex vector out. - * \ingroup dft_blk - */ - -class GR_CORE_API gr_fft_vfc : public gr_sync_block -{ - friend GR_CORE_API gr_fft_vfc_sptr - gr_make_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads); - - unsigned int d_fft_size; - std::vector<float> d_window; - gri_fft_complex *d_fft; - - gr_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads=1); - - public: - ~gr_fft_vfc (); - - void set_nthreads(int n); - int nthreads() const; - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - bool set_window(const std::vector<float> &window); -}; - - -#endif /* INCLUDED_GR_FFT_VFC_H */ diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.i b/gnuradio-core/src/lib/general/gr_fft_vfc.i deleted file mode 100644 index d387ae155d..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vfc.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr, fft_vfc) - -gr_fft_vfc_sptr -gr_make_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads=1) -throw(std::exception); - -class gr_fft_vfc : public gr_sync_block -{ - protected: - gr_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads=1); - - public: - bool set_window(const std::vector<float> &window); - void set_nthreads(int n); - int nthreads() const; -}; diff --git a/gnuradio-core/src/lib/general/gr_firdes.cc b/gnuradio-core/src/lib/general/gr_firdes.cc deleted file mode 100644 index 4c72371410..0000000000 --- a/gnuradio-core/src/lib/general/gr_firdes.cc +++ /dev/null @@ -1,840 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_firdes.h> -#include <stdexcept> - - -using std::vector; - -#define IzeroEPSILON 1E-21 /* Max error acceptable in Izero */ - -static double Izero(double x) -{ - double sum, u, halfx, temp; - int n; - - sum = u = n = 1; - halfx = x/2.0; - do { - temp = halfx/(double)n; - n += 1; - temp *= temp; - u *= temp; - sum += u; - } while (u >= IzeroEPSILON*sum); - return(sum); -} - - -// -// === Low Pass === -// - -vector<float> -gr_firdes::low_pass_2(double gain, - double sampling_freq, // Hz - double cutoff_freq, // Hz BEGINNING of transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // attenuation dB - win_type window_type, - double beta) // used only with Kaiser -{ - sanity_check_1f (sampling_freq, cutoff_freq, transition_width); - - int ntaps = compute_ntaps_windes (sampling_freq, transition_width, - attenuation_dB); - - // construct the truncated ideal impulse response - // [sin(x)/x for the low pass case] - - vector<float> taps(ntaps); - vector<float> w = window (window_type, ntaps, beta); - - int M = (ntaps - 1) / 2; - double fwT0 = 2 * M_PI * cutoff_freq / sampling_freq; - for (int n = -M; n <= M; n++){ - if (n == 0) - taps[n + M] = fwT0 / M_PI * w[n + M]; - else { - // a little algebra gets this into the more familiar sin(x)/x form - taps[n + M] = sin (n * fwT0) / (n * M_PI) * w[n + M]; - } - } - - // find the factor to normalize the gain, fmax. - // For low-pass, gain @ zero freq = 1.0 - - double fmax = taps[0 + M]; - for (int n = 1; n <= M; n++) - fmax += 2 * taps[n + M]; - - gain /= fmax; // normalize - - for (int i = 0; i < ntaps; i++) - taps[i] *= gain; - - - return taps; -} - -vector<float> -gr_firdes::low_pass (double gain, - double sampling_freq, - double cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window_type, - double beta) // used only with Kaiser -{ - sanity_check_1f (sampling_freq, cutoff_freq, transition_width); - - int ntaps = compute_ntaps (sampling_freq, transition_width, - window_type, beta); - - // construct the truncated ideal impulse response - // [sin(x)/x for the low pass case] - - vector<float> taps(ntaps); - vector<float> w = window (window_type, ntaps, beta); - - int M = (ntaps - 1) / 2; - double fwT0 = 2 * M_PI * cutoff_freq / sampling_freq; - - for (int n = -M; n <= M; n++){ - if (n == 0) - taps[n + M] = fwT0 / M_PI * w[n + M]; - else { - // a little algebra gets this into the more familiar sin(x)/x form - taps[n + M] = sin (n * fwT0) / (n * M_PI) * w[n + M]; - } - } - - // find the factor to normalize the gain, fmax. - // For low-pass, gain @ zero freq = 1.0 - - double fmax = taps[0 + M]; - for (int n = 1; n <= M; n++) - fmax += 2 * taps[n + M]; - - gain /= fmax; // normalize - - for (int i = 0; i < ntaps; i++) - taps[i] *= gain; - - return taps; -} - - -// -// === High Pass === -// - -vector<float> -gr_firdes::high_pass_2 (double gain, - double sampling_freq, - double cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // attenuation dB - win_type window_type, - double beta) // used only with Kaiser -{ - sanity_check_1f (sampling_freq, cutoff_freq, transition_width); - - int ntaps = compute_ntaps_windes (sampling_freq, transition_width, - attenuation_dB); - - // construct the truncated ideal impulse response times the window function - - vector<float> taps(ntaps); - vector<float> w = window (window_type, ntaps, beta); - - int M = (ntaps - 1) / 2; - double fwT0 = 2 * M_PI * cutoff_freq / sampling_freq; - - for (int n = -M; n <= M; n++){ - if (n == 0) - taps[n + M] = (1 - (fwT0 / M_PI)) * w[n + M]; - else { - // a little algebra gets this into the more familiar sin(x)/x form - taps[n + M] = -sin (n * fwT0) / (n * M_PI) * w[n + M]; - } - } - - // find the factor to normalize the gain, fmax. - // For high-pass, gain @ fs/2 freq = 1.0 - - double fmax = taps[0 + M]; - for (int n = 1; n <= M; n++) - fmax += 2 * taps[n + M] * cos (n * M_PI); - - gain /= fmax; // normalize - - for (int i = 0; i < ntaps; i++) - taps[i] *= gain; - - - return taps; -} - - -vector<float> -gr_firdes::high_pass (double gain, - double sampling_freq, - double cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window_type, - double beta) // used only with Kaiser -{ - sanity_check_1f (sampling_freq, cutoff_freq, transition_width); - - int ntaps = compute_ntaps (sampling_freq, transition_width, - window_type, beta); - - // construct the truncated ideal impulse response times the window function - - vector<float> taps(ntaps); - vector<float> w = window (window_type, ntaps, beta); - - int M = (ntaps - 1) / 2; - double fwT0 = 2 * M_PI * cutoff_freq / sampling_freq; - - for (int n = -M; n <= M; n++){ - if (n == 0) - taps[n + M] = (1 - (fwT0 / M_PI)) * w[n + M]; - else { - // a little algebra gets this into the more familiar sin(x)/x form - taps[n + M] = -sin (n * fwT0) / (n * M_PI) * w[n + M]; - } - } - - // find the factor to normalize the gain, fmax. - // For high-pass, gain @ fs/2 freq = 1.0 - - double fmax = taps[0 + M]; - for (int n = 1; n <= M; n++) - fmax += 2 * taps[n + M] * cos (n * M_PI); - - gain /= fmax; // normalize - - for (int i = 0; i < ntaps; i++) - taps[i] *= gain; - - return taps; -} - -// -// === Band Pass === -// - -vector<float> -gr_firdes::band_pass_2 (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz center of transition band - double high_cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // attenuation dB - win_type window_type, - double beta) // used only with Kaiser -{ - sanity_check_2f (sampling_freq, - low_cutoff_freq, - high_cutoff_freq, transition_width); - - int ntaps = compute_ntaps_windes (sampling_freq, transition_width, - attenuation_dB); - - vector<float> taps(ntaps); - vector<float> w = window (window_type, ntaps, beta); - - int M = (ntaps - 1) / 2; - double fwT0 = 2 * M_PI * low_cutoff_freq / sampling_freq; - double fwT1 = 2 * M_PI * high_cutoff_freq / sampling_freq; - - for (int n = -M; n <= M; n++){ - if (n == 0) - taps[n + M] = (fwT1 - fwT0) / M_PI * w[n + M]; - else { - taps[n + M] = (sin (n * fwT1) - sin (n * fwT0)) / (n * M_PI) * w[n + M]; - } - } - - // find the factor to normalize the gain, fmax. - // For band-pass, gain @ center freq = 1.0 - - double fmax = taps[0 + M]; - for (int n = 1; n <= M; n++) - fmax += 2 * taps[n + M] * cos (n * (fwT0 + fwT1) * 0.5); - - gain /= fmax; // normalize - - for (int i = 0; i < ntaps; i++) - taps[i] *= gain; - - return taps; -} - - -vector<float> -gr_firdes::band_pass (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz center of transition band - double high_cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window_type, - double beta) // used only with Kaiser -{ - sanity_check_2f (sampling_freq, - low_cutoff_freq, - high_cutoff_freq, transition_width); - - int ntaps = compute_ntaps (sampling_freq, transition_width, - window_type, beta); - - // construct the truncated ideal impulse response times the window function - - vector<float> taps(ntaps); - vector<float> w = window (window_type, ntaps, beta); - - int M = (ntaps - 1) / 2; - double fwT0 = 2 * M_PI * low_cutoff_freq / sampling_freq; - double fwT1 = 2 * M_PI * high_cutoff_freq / sampling_freq; - - for (int n = -M; n <= M; n++){ - if (n == 0) - taps[n + M] = (fwT1 - fwT0) / M_PI * w[n + M]; - else { - taps[n + M] = (sin (n * fwT1) - sin (n * fwT0)) / (n * M_PI) * w[n + M]; - } - } - - // find the factor to normalize the gain, fmax. - // For band-pass, gain @ center freq = 1.0 - - double fmax = taps[0 + M]; - for (int n = 1; n <= M; n++) - fmax += 2 * taps[n + M] * cos (n * (fwT0 + fwT1) * 0.5); - - gain /= fmax; // normalize - - for (int i = 0; i < ntaps; i++) - taps[i] *= gain; - - return taps; -} - -// -// === Complex Band Pass === -// - -vector<gr_complex> -gr_firdes::complex_band_pass_2 (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz center of transition band - double high_cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // attenuation dB - win_type window_type, - double beta) // used only with Kaiser -{ - sanity_check_2f_c (sampling_freq, - low_cutoff_freq, - high_cutoff_freq, transition_width); - - int ntaps = compute_ntaps_windes (sampling_freq, transition_width, - attenuation_dB); - - - - vector<gr_complex> taps(ntaps); - vector<float> lptaps(ntaps); - vector<float> w = window (window_type, ntaps, beta); - - lptaps = low_pass_2(gain,sampling_freq,(high_cutoff_freq - low_cutoff_freq)/2,transition_width,attenuation_dB,window_type,beta); - - gr_complex *optr = &taps[0]; - float *iptr = &lptaps[0]; - float freq = M_PI * (high_cutoff_freq + low_cutoff_freq)/sampling_freq; - float phase=0; - if (lptaps.size() & 01) { - phase = - freq * ( lptaps.size() >> 1 ); - } else phase = - freq/2.0 * ((1 + 2*lptaps.size()) >> 1); - for(unsigned int i=0;i<lptaps.size();i++) { - *optr++ = gr_complex(*iptr * cos(phase),*iptr * sin(phase)); - iptr++, phase += freq; - } - - return taps; -} - - -vector<gr_complex> -gr_firdes::complex_band_pass (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz center of transition band - double high_cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window_type, - double beta) // used only with Kaiser -{ - sanity_check_2f_c (sampling_freq, - low_cutoff_freq, - high_cutoff_freq, transition_width); - - int ntaps = compute_ntaps (sampling_freq, transition_width, - window_type, beta); - - // construct the truncated ideal impulse response times the window function - - vector<gr_complex> taps(ntaps); - vector<float> lptaps(ntaps); - vector<float> w = window (window_type, ntaps, beta); - - lptaps = low_pass(gain,sampling_freq,(high_cutoff_freq - low_cutoff_freq)/2,transition_width,window_type,beta); - - gr_complex *optr = &taps[0]; - float *iptr = &lptaps[0]; - float freq = M_PI * (high_cutoff_freq + low_cutoff_freq)/sampling_freq; - float phase=0; - if (lptaps.size() & 01) { - phase = - freq * ( lptaps.size() >> 1 ); - } else phase = - freq/2.0 * ((1 + 2*lptaps.size()) >> 1); - for(unsigned int i=0;i<lptaps.size();i++) { - *optr++ = gr_complex(*iptr * cos(phase),*iptr * sin(phase)); - iptr++, phase += freq; - } - - return taps; -} - -// -// === Band Reject === -// - -vector<float> -gr_firdes::band_reject_2 (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz center of transition band - double high_cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // attenuation dB - win_type window_type, - double beta) // used only with Kaiser -{ - sanity_check_2f (sampling_freq, - low_cutoff_freq, - high_cutoff_freq, transition_width); - - int ntaps = compute_ntaps_windes (sampling_freq, transition_width, - attenuation_dB); - - // construct the truncated ideal impulse response times the window function - - vector<float> taps(ntaps); - vector<float> w = window (window_type, ntaps, beta); - - int M = (ntaps - 1) / 2; - double fwT0 = 2 * M_PI * low_cutoff_freq / sampling_freq; - double fwT1 = 2 * M_PI * high_cutoff_freq / sampling_freq; - - for (int n = -M; n <= M; n++){ - if (n == 0) - taps[n + M] = 1.0 + ((fwT0 - fwT1) / M_PI * w[n + M]); - else { - taps[n + M] = (sin (n * fwT0) - sin (n * fwT1)) / (n * M_PI) * w[n + M]; - } - } - - // find the factor to normalize the gain, fmax. - // For band-reject, gain @ zero freq = 1.0 - - double fmax = taps[0 + M]; - for (int n = 1; n <= M; n++) - fmax += 2 * taps[n + M]; - - gain /= fmax; // normalize - - for (int i = 0; i < ntaps; i++) - taps[i] *= gain; - - return taps; -} - -vector<float> -gr_firdes::band_reject (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz center of transition band - double high_cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window_type, - double beta) // used only with Kaiser -{ - sanity_check_2f (sampling_freq, - low_cutoff_freq, - high_cutoff_freq, transition_width); - - int ntaps = compute_ntaps (sampling_freq, transition_width, - window_type, beta); - - // construct the truncated ideal impulse response times the window function - - vector<float> taps(ntaps); - vector<float> w = window (window_type, ntaps, beta); - - int M = (ntaps - 1) / 2; - double fwT0 = 2 * M_PI * low_cutoff_freq / sampling_freq; - double fwT1 = 2 * M_PI * high_cutoff_freq / sampling_freq; - - for (int n = -M; n <= M; n++){ - if (n == 0) - taps[n + M] = 1.0 + ((fwT0 - fwT1) / M_PI * w[n + M]); - else { - taps[n + M] = (sin (n * fwT0) - sin (n * fwT1)) / (n * M_PI) * w[n + M]; - } - } - - // find the factor to normalize the gain, fmax. - // For band-reject, gain @ zero freq = 1.0 - - double fmax = taps[0 + M]; - for (int n = 1; n <= M; n++) - fmax += 2 * taps[n + M]; - - gain /= fmax; // normalize - - for (int i = 0; i < ntaps; i++) - taps[i] *= gain; - - return taps; -} - -// -// Hilbert Transform -// - -vector<float> -gr_firdes::hilbert (unsigned int ntaps, - win_type windowtype, - double beta) -{ - if(!(ntaps & 1)) - throw std::out_of_range("Hilbert: Must have odd number of taps"); - - vector<float> taps(ntaps); - vector<float> w = window (windowtype, ntaps, beta); - unsigned int h = (ntaps-1)/2; - float gain=0; - for (unsigned int i = 1; i <= h; i++) - { - if(i&1) - { - float x = 1/(float)i; - taps[h+i] = x * w[h+i]; - taps[h-i] = -x * w[h-i]; - gain = taps[h+i] - gain; - } - else - taps[h+i] = taps[h-i] = 0; - } - gain = 2 * fabs(gain); - for ( unsigned int i = 0; i < ntaps; i++) - taps[i] /= gain; - return taps; -} - -// -// Gaussian -// - -vector<float> -gr_firdes::gaussian (double gain, - double spb, - double bt, - int ntaps) -{ - - vector<float> taps(ntaps); - double scale = 0; - double dt = 1.0/spb; - double s = 1.0/(sqrt(log(2.0)) / (2*M_PI*bt)); - double t0 = -0.5 * ntaps; - double ts; - for(int i=0;i<ntaps;i++) - { - t0++; - ts = s*dt*t0; - taps[i] = exp(-0.5*ts*ts); - scale += taps[i]; - } - for(int i=0;i<ntaps;i++) - taps[i] = taps[i] / scale * gain; - return taps; -} - - -// -// Root Raised Cosine -// - -vector<float> -gr_firdes::root_raised_cosine (double gain, - double sampling_freq, - double symbol_rate, - double alpha, - int ntaps) -{ - ntaps |= 1; // ensure that ntaps is odd - - double spb = sampling_freq/symbol_rate; // samples per bit/symbol - vector<float> taps(ntaps); - double scale = 0; - for(int i=0;i<ntaps;i++) - { - double x1,x2,x3,num,den; - double xindx = i - ntaps/2; - x1 = M_PI * xindx/spb; - x2 = 4 * alpha * xindx / spb; - x3 = x2*x2 - 1; - if( fabs(x3) >= 0.000001 ) // Avoid Rounding errors... - { - if( i != ntaps/2 ) - num = cos((1+alpha)*x1) + sin((1-alpha)*x1)/(4*alpha*xindx/spb); - else - num = cos((1+alpha)*x1) + (1-alpha) * M_PI / (4*alpha); - den = x3 * M_PI; - } - else - { - if(alpha==1) - { - taps[i] = -1; - continue; - } - x3 = (1-alpha)*x1; - x2 = (1+alpha)*x1; - num = (sin(x2)*(1+alpha)*M_PI - - cos(x3)*((1-alpha)*M_PI*spb)/(4*alpha*xindx) - + sin(x3)*spb*spb/(4*alpha*xindx*xindx)); - den = -32 * M_PI * alpha * alpha * xindx/spb; - } - taps[i] = 4 * alpha * num / den; - scale += taps[i]; - } - - for(int i=0;i<ntaps;i++) - taps[i] = taps[i] * gain / scale; - - return taps; -} - -// -// === Utilities === -// - -// delta_f / width_factor gives number of taps required. -static const float width_factor[5] = { // indexed by win_type - 3.3, // WIN_HAMMING - 3.1, // WIN_HANN - 5.5, // WIN_BLACKMAN - 2.0, // WIN_RECTANGULAR - //5.0 // WIN_KAISER (guesstimate compromise) - //2.0 // WIN_KAISER (guesstimate compromise) - 10.0 // WIN_KAISER -}; - -int -gr_firdes::compute_ntaps_windes(double sampling_freq, - double transition_width, // this is frequency, not relative frequency - double attenuation_dB) -{ - // Based on formula from Multirate Signal Processing for - // Communications Systems, fredric j harris - int ntaps = (int)(attenuation_dB*sampling_freq/(22.0*transition_width)); - if ((ntaps & 1) == 0) // if even... - ntaps++; // ...make odd - return ntaps; -} - -int -gr_firdes::compute_ntaps (double sampling_freq, - double transition_width, - win_type window_type, - double beta) -{ - // normalized transition width - double delta_f = transition_width / sampling_freq; - - // compute number of taps required for given transition width - int ntaps = (int) (width_factor[window_type] / delta_f + 0.5); - if ((ntaps & 1) == 0) // if even... - ntaps++; // ...make odd - - return ntaps; -} - -double gr_firdes::bessi0(double x) -{ - double ax,ans; - double y; - - ax=fabs(x); - if (ax < 3.75) - { - y=x/3.75; - y*=y; - ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492 - +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2))))); - } - else - { - y=3.75/ax; - ans=(exp(ax)/sqrt(ax))*(0.39894228+y*(0.1328592e-1 - +y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2 - +y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1 - +y*0.392377e-2)))))))); - } - return ans; -} -vector<float> -gr_firdes::window (win_type type, int ntaps, double beta) -{ - vector<float> taps(ntaps); - int M = ntaps - 1; // filter order - - switch (type){ - case WIN_RECTANGULAR: - for (int n = 0; n < ntaps; n++) - taps[n] = 1; - - case WIN_HAMMING: - for (int n = 0; n < ntaps; n++) - taps[n] = 0.54 - 0.46 * cos ((2 * M_PI * n) / M); - break; - - case WIN_HANN: - for (int n = 0; n < ntaps; n++) - taps[n] = 0.5 - 0.5 * cos ((2 * M_PI * n) / M); - break; - - case WIN_BLACKMAN: - for (int n = 0; n < ntaps; n++) - taps[n] = 0.42 - 0.50 * cos ((2*M_PI * n) / (M-1)) - 0.08 * cos ((4*M_PI * n) / (M-1)); - break; - - case WIN_BLACKMAN_hARRIS: - for (int n = -ntaps/2; n < ntaps/2; n++) - taps[n+ntaps/2] = 0.35875 + 0.48829*cos((2*M_PI * n) / (float)M) + - 0.14128*cos((4*M_PI * n) / (float)M) + 0.01168*cos((6*M_PI * n) / (float)M); - break; - -#if 0 - case WIN_KAISER: - for (int n = 0; n < ntaps; n++) - taps[n] = bessi0(beta*sqrt(1.0 - (4.0*n/(M*M))))/bessi0(beta); - break; -#else - - case WIN_KAISER: - { - double IBeta = 1.0/Izero(beta); - double inm1 = 1.0/((double)(ntaps)); - double temp; - //fprintf(stderr, "IBeta = %g; inm1 = %g\n", IBeta, inm1); - - for (int i=0; i<ntaps; i++) { - temp = i * inm1; - //fprintf(stderr, "temp = %g\n", temp); - taps[i] = Izero(beta*sqrt(1.0-temp*temp)) * IBeta; - //fprintf(stderr, "taps[%d] = %g\n", i, taps[i]); - } - } - break; - -#endif - default: - throw std::out_of_range ("gr_firdes:window: type out of range"); - } - - return taps; -} - -void -gr_firdes::sanity_check_1f (double sampling_freq, - double fa, // cutoff freq - double transition_width) -{ - if (sampling_freq <= 0.0) - throw std::out_of_range ("gr_firdes check failed: sampling_freq > 0"); - - if (fa <= 0.0 || fa > sampling_freq / 2) - throw std::out_of_range ("gr_firdes check failed: 0 < fa <= sampling_freq / 2"); - - if (transition_width <= 0) - throw std::out_of_range ("gr_dirdes check failed: transition_width > 0"); -} - -void -gr_firdes::sanity_check_2f (double sampling_freq, - double fa, // first cutoff freq - double fb, // second cutoff freq - double transition_width) -{ - if (sampling_freq <= 0.0) - throw std::out_of_range ("gr_firdes check failed: sampling_freq > 0"); - - if (fa <= 0.0 || fa > sampling_freq / 2) - throw std::out_of_range ("gr_firdes check failed: 0 < fa <= sampling_freq / 2"); - - if (fb <= 0.0 || fb > sampling_freq / 2) - throw std::out_of_range ("gr_firdes check failed: 0 < fb <= sampling_freq / 2"); - - if (fa > fb) - throw std::out_of_range ("gr_firdes check failed: fa <= fb"); - - if (transition_width <= 0) - throw std::out_of_range ("gr_firdes check failed: transition_width > 0"); -} - -void -gr_firdes::sanity_check_2f_c (double sampling_freq, - double fa, // first cutoff freq - double fb, // second cutoff freq - double transition_width) -{ - if (sampling_freq <= 0.0) - throw std::out_of_range ("gr_firdes check failed: sampling_freq > 0"); - - if (fa < -sampling_freq / 2 || fa > sampling_freq / 2) - throw std::out_of_range ("gr_firdes check failed: 0 < fa <= sampling_freq / 2"); - - if (fb < -sampling_freq / 2 || fb > sampling_freq / 2) - throw std::out_of_range ("gr_firdes check failed: 0 < fb <= sampling_freq / 2"); - - if (fa > fb) - throw std::out_of_range ("gr_firdes check failed: fa <= fb"); - - if (transition_width <= 0) - throw std::out_of_range ("gr_firdes check failed: transition_width > 0"); -} diff --git a/gnuradio-core/src/lib/general/gr_firdes.h b/gnuradio-core/src/lib/general/gr_firdes.h deleted file mode 100644 index 8d98ebe0a1..0000000000 --- a/gnuradio-core/src/lib/general/gr_firdes.h +++ /dev/null @@ -1,373 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _GR_FIRDES_H_ -#define _GR_FIRDES_H_ - -#include <gr_core_api.h> -#include <vector> -#include <cmath> -#include <gr_complex.h> - -/*! - * \brief Finite Impulse Response (FIR) filter design functions. - * \ingroup filter_design - */ - -class GR_CORE_API gr_firdes { - public: - - enum win_type { - WIN_HAMMING = 0, // max attenuation 53 dB - WIN_HANN = 1, // max attenuation 44 dB - WIN_BLACKMAN = 2, // max attenuation 74 dB - WIN_RECTANGULAR = 3, - WIN_KAISER = 4, // max attenuation a function of beta, google it - WIN_BLACKMAN_hARRIS = 5, - WIN_BLACKMAN_HARRIS = 5, // alias for capitalization consistency - }; - - - // ... class methods ... - - /*! - * \brief use "window method" to design a low-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * The normalized width of the transition - * band is what sets the number of taps - * required. Narrow --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - static std::vector<float> - low_pass (double gain, - double sampling_freq, - double cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - /*! - * \brief use "window method" to design a low-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * \p attenuation_dB required stopband attenuation - * The normalized width of the transition - * band and the required stop band - * attenuation is what sets the number of taps - * required. Narrow --> more taps - * More attenuatin --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<float> - low_pass_2 (double gain, - double sampling_freq, - double cutoff_freq, // Hz beginning transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // out of band attenuation dB - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - /*! - * \brief use "window method" to design a high-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * The normalized width of the transition - * band is what sets the number of taps - * required. Narrow --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<float> - high_pass (double gain, - double sampling_freq, - double cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - /*! - * \brief use "window method" to design a high-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * \p attenuation_dB out of band attenuation - * The normalized width of the transition - * band and the required stop band - * attenuation is what sets the number of taps - * required. Narrow --> more taps - * More attenuation --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<float> - high_pass_2 (double gain, - double sampling_freq, - double cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // out of band attenuation dB - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - /*! - * \brief use "window method" to design a band-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p low_cutoff_freq: center of transition band (Hz) - * \p high_cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * The normalized width of the transition - * band is what sets the number of taps - * required. Narrow --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - static std::vector<float> - band_pass (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz center of transition band - double high_cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - /*! - * \brief use "window method" to design a band-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p low_cutoff_freq: center of transition band (Hz) - * \p high_cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * \p attenuation_dB out of band attenuation - * The normalized width of the transition - * band and the required stop band - * attenuation is what sets the number of taps - * required. Narrow --> more taps - * More attenuation --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<float> - band_pass_2 (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz beginning transition band - double high_cutoff_freq, // Hz beginning transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // out of band attenuation dB - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - /*! - * \brief use "window method" to design a complex band-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p low_cutoff_freq: center of transition band (Hz) - * \p high_cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * The normalized width of the transition - * band is what sets the number of taps - * required. Narrow --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<gr_complex> - complex_band_pass (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz center of transition band - double high_cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - /*! - * \brief use "window method" to design a complex band-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p low_cutoff_freq: center of transition band (Hz) - * \p high_cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * \p attenuation_dB out of band attenuation - * The normalized width of the transition - * band and the required stop band - * attenuation is what sets the number of taps - * required. Narrow --> more taps - * More attenuation --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<gr_complex> - complex_band_pass_2 (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz beginning transition band - double high_cutoff_freq, // Hz beginning transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // out of band attenuation dB - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - /*! - * \brief use "window method" to design a band-reject FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p low_cutoff_freq: center of transition band (Hz) - * \p high_cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * The normalized width of the transition - * band is what sets the number of taps - * required. Narrow --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<float> - band_reject (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz center of transition band - double high_cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - /*! - * \brief use "window method" to design a band-reject FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p low_cutoff_freq: center of transition band (Hz) - * \p high_cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * \p attenuation_dB out of band attenuation - * The normalized width of the transition - * band and the required stop band - * attenuation is what sets the number of taps - * required. Narrow --> more taps - * More attenuation --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<float> - band_reject_2 (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz beginning transition band - double high_cutoff_freq, // Hz beginning transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // out of band attenuation dB - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - /*!\brief design a Hilbert Transform Filter - * - * \p ntaps: Number of taps, must be odd - * \p window_type: What kind of window to use - * \p beta: Only used for Kaiser - */ - static std::vector<float> - hilbert (unsigned int ntaps = 19, - win_type windowtype = WIN_RECTANGULAR, - double beta = 6.76); - - /*! - * \brief design a Root Cosine FIR Filter (do we need a window?) - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p symbol rate: symbol rate, must be a factor of sample rate - * \p alpha: excess bandwidth factor - * \p ntaps: number of taps - */ - static std::vector<float> - root_raised_cosine (double gain, - double sampling_freq, - double symbol_rate, // Symbol rate, NOT bitrate (unless BPSK) - double alpha, // Excess Bandwidth Factor - int ntaps); - - /*! - * \brief design a Gaussian filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p symbols per bit: symbol rate, must be a factor of sample rate - * \p ntaps: number of taps - */ - static std::vector<float> - gaussian (double gain, - double spb, - double bt, // Bandwidth to bitrate ratio - int ntaps); - - // window functions ... - static std::vector<float> window (win_type type, int ntaps, double beta); - -private: - static double bessi0(double x); - static void sanity_check_1f (double sampling_freq, double f1, - double transition_width); - static void sanity_check_2f (double sampling_freq, double f1, double f2, - double transition_width); - static void sanity_check_2f_c (double sampling_freq, double f1, double f2, - double transition_width); - - static int compute_ntaps (double sampling_freq, - double transition_width, - win_type window_type, double beta); - - static int compute_ntaps_windes (double sampling_freq, - double transition_width, - double attenuation_dB); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_firdes.i b/gnuradio-core/src/lib/general/gr_firdes.i deleted file mode 100644 index 0493db6174..0000000000 --- a/gnuradio-core/src/lib/general/gr_firdes.i +++ /dev/null @@ -1,360 +0,0 @@ -/* -*- C++ -*- */ -/* - * Copyright 2002,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/*! - * \brief Finite Impulse Response (FIR) filter design functions. - */ - -%rename(firdes) gr_firdes; - -class gr_firdes { - public: - - enum win_type { - WIN_HAMMING = 0, // max attenuation 53 dB - WIN_HANN = 1, // max attenuation 44 dB - WIN_BLACKMAN = 2, // max attenuation 74 dB - WIN_RECTANGULAR = 3, - WIN_KAISER = 4, // max attenuation variable with beta, google it - WIN_BLACKMAN_hARRIS = 5, - }; - - // ... class methods ... - - /*! - * \brief use "window method" to design a low-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * The normalized width of the transition - * band is what sets the number of taps - * required. Narrow --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - static std::vector<float> - low_pass (double gain, - double sampling_freq, - double cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window = WIN_HAMMING, - double beta = 6.76 // used only with Kaiser - ) throw(std::out_of_range); - - /*! - * \brief use "window method" to design a low-pass FIR filter - * using alternative design criteria - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * \p attenuation_dB out of band attenuation - * The normalized width of the transition - * band and the required stop band - * attenuation is what sets the number of taps - * required. Narrow --> more taps - * More attenuation --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - static std::vector<float> - low_pass_2 (double gain, - double sampling_freq, - double cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // out of band attenuation - win_type window = WIN_HAMMING, - double beta = 6.76 // used only with Kaiser - ) throw(std::out_of_range); - - /*! - * \brief use "window method" to design a high-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * The normalized width of the transition - * band is what sets the number of taps - * required. Narrow --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<float> - high_pass (double gain, - double sampling_freq, - double cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window = WIN_HAMMING, - double beta = 6.76 // used only with Kaiser - ) throw(std::out_of_range); - - /*! - * \brief use "window method" to design a high-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * \p attenuation_dB out of band attenuation - * The normalized width of the transition - * band and the required stop band - * attenuation is what sets the number of taps - * required. Narrow --> more taps - * More attenuation --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<float> - high_pass_2 (double gain, - double sampling_freq, - double cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // out of band attenuation dB - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - - /*! - * \brief use "window method" to design a band-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p low_cutoff_freq: center of transition band (Hz) - * \p high_cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * The normalized width of the transition - * band is what sets the number of taps - * required. Narrow --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<float> - band_pass (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz center of transition band - double high_cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window = WIN_HAMMING, - double beta = 6.76 // used only with Kaiser - ) throw(std::out_of_range); - - - /*! - * \brief use "window method" to design a band-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p low_cutoff_freq: center of transition band (Hz) - * \p high_cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * \p attenuation_dB out of band attenuation - * The normalized width of the transition - * band and the required stop band - * attenuation is what sets the number of taps - * required. Narrow --> more taps - * More attenuation --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<float> - band_pass_2 (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz beginning transition band - double high_cutoff_freq, // Hz beginning transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // out of band attenuation dB - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - /*! - * \brief use "window method" to design a band-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p low_cutoff_freq: center of transition band (Hz) - * \p high_cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * The normalized width of the transition - * band is what sets the number of taps - * required. Narrow --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<gr_complex> - complex_band_pass (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz center of transition band - double high_cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window = WIN_HAMMING, // used only with Kaiser - double beta = 6.76 - ) throw(std::out_of_range); - - - /*! - * \brief use "window method" to design a complex band-pass FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p low_cutoff_freq: center of transition band (Hz) - * \p high_cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * \p attenuation_dB out of band attenuation - * The normalized width of the transition - * band and the required stop band - * attenuation is what sets the number of taps - * required. Narrow --> more taps - * More attenuation --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<gr_complex> - complex_band_pass_2 (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz beginning transition band - double high_cutoff_freq, // Hz beginning transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // out of band attenuation dB - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - /*! - * \brief use "window method" to design a band-reject FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p low_cutoff_freq: center of transition band (Hz) - * \p high_cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * The normalized width of the transition - * band is what sets the number of taps - * required. Narrow --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<float> - band_reject (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz center of transition band - double high_cutoff_freq, // Hz center of transition band - double transition_width, // Hz width of transition band - win_type window = WIN_HAMMING, // used only with Kaiser - double beta = 6.76 - ) throw(std::out_of_range); - - - /*! - * \brief use "window method" to design a band-reject FIR filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p low_cutoff_freq: center of transition band (Hz) - * \p high_cutoff_freq: center of transition band (Hz) - * \p transition_width: width of transition band (Hz). - * \p attenuation_dB out of band attenuation - * The normalized width of the transition - * band and the required stop band - * attenuation is what sets the number of taps - * required. Narrow --> more taps - * More attenuation --> more taps - * \p window_type: What kind of window to use. Determines - * maximum attenuation and passband ripple. - * \p beta: parameter for Kaiser window - */ - - static std::vector<float> - band_reject_2 (double gain, - double sampling_freq, - double low_cutoff_freq, // Hz beginning transition band - double high_cutoff_freq, // Hz beginning transition band - double transition_width, // Hz width of transition band - double attenuation_dB, // out of band attenuation dB - win_type window = WIN_HAMMING, - double beta = 6.76); // used only with Kaiser - - /*!\brief design a Hilbert Transform Filter - * - * \p ntaps: Number of taps, must be odd - * \p window_type: What kind of window to use - * \p beta: Only used for Kaiser - */ - static std::vector<float> - hilbert (unsigned int ntaps = 19, - win_type windowtype = WIN_RECTANGULAR, - double beta = 6.76 - ) throw(std::out_of_range); - - /*! - * \brief design a Root Cosine FIR Filter (do we need a window?) - * - * \p gain: overall gain of filter (typically 1.0) - * \p sampling_freq: sampling freq (Hz) - * \p symbol rate: symbol rate, must be a factor of sample rate - * \p alpha: excess bandwidth factor - * \p ntaps: number of taps - */ - static std::vector<float> - root_raised_cosine (double gain, - double sampling_freq, - double symbol_rate, // Symbol rate, NOT bitrate (unless BPSK) - double alpha, // Excess Bandwidth Factor - int ntaps) throw(std::out_of_range); - - /*! - * \brief design a Gaussian filter - * - * \p gain: overall gain of filter (typically 1.0) - * \p symbols per bit: symbol rate, must be a factor of sample rate - * \p bt: BT bandwidth time product - * \p ntaps: number of taps - */ - static std::vector<float> - gaussian (double gain, - double spb, - double bt, // Bandwidth to bitrate ratio - int ntaps) throw(std::out_of_range); - - /*! - * Return window given type, ntaps and optional beta. - */ - static std::vector<float> gr_firdes::window (win_type type, int ntaps, double beta) - throw(std::runtime_error); -}; diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.cc b/gnuradio-core/src/lib/general/gr_float_to_char.cc deleted file mode 100644 index d67ded3ea6..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_char.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_float_to_char.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_float_to_char_sptr -gr_make_float_to_char (size_t vlen, float scale) -{ - return gnuradio::get_initial_sptr(new gr_float_to_char (vlen, scale)); -} - -gr_float_to_char::gr_float_to_char (size_t vlen, float scale) - : gr_sync_block ("gr_float_to_char", - gr_make_io_signature (1, 1, sizeof (float)*vlen), - gr_make_io_signature (1, 1, sizeof (char)*vlen)), - d_vlen(vlen), d_scale(scale) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(char); - set_alignment(std::max(1,alignment_multiple)); -} - -float -gr_float_to_char::scale() const -{ - return d_scale; -} - -void -gr_float_to_char::set_scale(float scale) -{ - d_scale = scale; -} - -int -gr_float_to_char::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - int8_t *out = (int8_t *) output_items[0]; - - if(is_unaligned()) { - volk_32f_s32f_convert_8i_u(out, in, d_scale, d_vlen*noutput_items); - } - else { - volk_32f_s32f_convert_8i_a(out, in, d_scale, d_vlen*noutput_items); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.h b/gnuradio-core/src/lib/general/gr_float_to_char.h deleted file mode 100644 index 2df50f18d5..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_char.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FLOAT_TO_CHAR_H -#define INCLUDED_GR_FLOAT_TO_CHAR_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_float_to_char; -typedef boost::shared_ptr<gr_float_to_char> gr_float_to_char_sptr; - -GR_CORE_API gr_float_to_char_sptr -gr_make_float_to_char (size_t vlen=1, float scale=1); - -/*! - * \brief Convert stream of float to a stream of char - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar multiplier to change the output signal scale. - */ - -class GR_CORE_API gr_float_to_char : public gr_sync_block -{ - private: - friend GR_CORE_API gr_float_to_char_sptr gr_make_float_to_char - (size_t vlen, float scale); - gr_float_to_char (size_t vlen, float scale); - - size_t d_vlen; - float d_scale; - - public: - /*! - * Get the scalar multiplier value. - */ - float scale() const; - - /*! - * Set the scalar multiplier value. - */ - void set_scale(float scale); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_FLOAT_TO_CHAR_H */ diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.i b/gnuradio-core/src/lib/general/gr_float_to_char.i deleted file mode 100644 index b40389ede5..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_char.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,float_to_char) - -gr_float_to_char_sptr -gr_make_float_to_char (size_t vlen=1, float scale=1); - -class gr_float_to_char : public gr_sync_block -{ -public: - float scale() const; - void set_scale(float scale); -}; diff --git a/gnuradio-core/src/lib/general/gr_float_to_complex.cc b/gnuradio-core/src/lib/general/gr_float_to_complex.cc deleted file mode 100644 index c68eac8c7c..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_complex.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_float_to_complex.h> -#include <gr_io_signature.h> - -gr_float_to_complex_sptr -gr_make_float_to_complex (size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_float_to_complex (vlen)); -} - -gr_float_to_complex::gr_float_to_complex (size_t vlen) - : gr_sync_block ("gr_float_to_complex", - gr_make_io_signature (1, 2, sizeof (float) * vlen), - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen)), - d_vlen (vlen) -{ -} - -int -gr_float_to_complex::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *r = (float *)input_items[0]; - float *i = (float *)input_items[1]; - gr_complex *out = (gr_complex *) output_items[0]; - - switch (input_items.size ()){ - case 1: - for (size_t j = 0; j < noutput_items*d_vlen; j++) - out[j] = gr_complex (r[j], 0); - break; - - case 2: - for (size_t j = 0; j < noutput_items*d_vlen; j++) - out[j] = gr_complex (r[j], i[j]); - break; - - default: - assert (0); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_float_to_complex.h b/gnuradio-core/src/lib/general/gr_float_to_complex.h deleted file mode 100644 index 628b4a954e..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_complex.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FLOAT_TO_COMPLEX_H -#define INCLUDED_GR_FLOAT_TO_COMPLEX_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_complex.h> - -class gr_float_to_complex; -typedef boost::shared_ptr<gr_float_to_complex> gr_float_to_complex_sptr; - -GR_CORE_API gr_float_to_complex_sptr -gr_make_float_to_complex (size_t vlen = 1); - -/*! - * \brief Convert 1 or 2 streams of float to a stream of gr_complex - * \ingroup converter_blk - */ - -class GR_CORE_API gr_float_to_complex : public gr_sync_block -{ - friend GR_CORE_API gr_float_to_complex_sptr gr_make_float_to_complex (size_t vlen); - gr_float_to_complex (size_t vlen); - - size_t d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_FLOAT_TO_COMPLEX_H */ diff --git a/gnuradio-core/src/lib/general/gr_float_to_complex.i b/gnuradio-core/src/lib/general/gr_float_to_complex.i deleted file mode 100644 index ed5ad128b0..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_complex.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,float_to_complex) - -gr_float_to_complex_sptr gr_make_float_to_complex (size_t vlen = 1); - -class gr_float_to_complex : public gr_sync_block -{ - gr_float_to_complex (size_t vlen); -}; diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.cc b/gnuradio-core/src/lib/general/gr_float_to_int.cc deleted file mode 100644 index 43b8518956..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_int.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_float_to_int.h> -#include <gr_io_signature.h> -#include <gri_float_to_int.h> -#include <volk/volk.h> - -gr_float_to_int_sptr -gr_make_float_to_int (size_t vlen, float scale) -{ - return gnuradio::get_initial_sptr(new gr_float_to_int (vlen, scale)); -} - -gr_float_to_int::gr_float_to_int (size_t vlen, float scale) - : gr_sync_block ("gr_float_to_int", - gr_make_io_signature (1, 1, sizeof (float)*vlen), - gr_make_io_signature (1, 1, sizeof (int)*vlen)), - d_vlen(vlen), d_scale(scale) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(int); - set_alignment(std::max(1,alignment_multiple)); -} - -float -gr_float_to_int::scale() const -{ - return d_scale; -} - -void -gr_float_to_int::set_scale(float scale) -{ - d_scale = scale; -} -int -gr_float_to_int::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - // Disable the Volk for now. There is a problem for large 32-bit ints that - // are not properly represented by the precisions of a single float, which - // can cause wrapping from large, positive numbers to negative. - // In gri_float_to_int, the value is first promoted to a 64-bit - // value, clipped, then converted to a float. -#if 0 - const float *in = (const float *) input_items[0]; - int32_t *out = (int32_t *) output_items[0]; - - if(is_unaligned()) { - volk_32f_s32f_convert_32i_u(out, in, d_scale, d_vlen*noutput_items); - } - else { - volk_32f_s32f_convert_32i_a(out, in, d_scale, d_vlen*noutput_items); - } -#else - const float *in = (const float *) input_items[0]; - int *out = (int *) output_items[0]; - - gri_float_to_int (in, out, d_scale, d_vlen*noutput_items); - -#endif - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.h b/gnuradio-core/src/lib/general/gr_float_to_int.h deleted file mode 100644 index c10ea739d2..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_int.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FLOAT_TO_INT_H -#define INCLUDED_GR_FLOAT_TO_INT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_float_to_int; -typedef boost::shared_ptr<gr_float_to_int> gr_float_to_int_sptr; - -GR_CORE_API gr_float_to_int_sptr -gr_make_float_to_int (size_t vlen=1, float scale=1); - -/*! - * \brief Convert stream of float to a stream of short - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar multiplier to change the output signal scale. - */ - -class GR_CORE_API gr_float_to_int : public gr_sync_block -{ - private: - friend GR_CORE_API - gr_float_to_int_sptr gr_make_float_to_int (size_t vlen, float scale); - gr_float_to_int (size_t vlen, float scale); - - size_t d_vlen; - float d_scale; - - public: - /*! - * Get the scalar multiplier value. - */ - float scale() const; - - /*! - * Set the scalar multiplier value. - */ - void set_scale(float scale); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_FLOAT_TO_INT_H */ diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.i b/gnuradio-core/src/lib/general/gr_float_to_int.i deleted file mode 100644 index e2a2c53ceb..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_int.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,float_to_int) - -gr_float_to_int_sptr -gr_make_float_to_int (size_t vlen=1, float scale=1); - -class gr_float_to_int : public gr_sync_block -{ -public: - float scale() const; - void set_scale(float scale); -}; diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.cc b/gnuradio-core/src/lib/general/gr_float_to_short.cc deleted file mode 100644 index ab720168bf..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_short.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_float_to_short.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_float_to_short_sptr -gr_make_float_to_short (size_t vlen, float scale) -{ - return gnuradio::get_initial_sptr(new gr_float_to_short (vlen, scale)); -} - -gr_float_to_short::gr_float_to_short (size_t vlen, float scale) - : gr_sync_block ("gr_float_to_short", - gr_make_io_signature (1, 1, sizeof (float)*vlen), - gr_make_io_signature (1, 1, sizeof (short)*vlen)), - d_vlen(vlen), d_scale(scale) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(short); - set_alignment(std::max(1,alignment_multiple)); -} - -float -gr_float_to_short::scale() const -{ - return d_scale; -} - -void -gr_float_to_short::set_scale(float scale) -{ - d_scale = scale; -} - -int -gr_float_to_short::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - short *out = (short *) output_items[0]; - - if(is_unaligned()) { - volk_32f_s32f_convert_16i_u(out, in, d_scale, d_vlen*noutput_items); - } - else { - volk_32f_s32f_convert_16i_a(out, in, d_scale, d_vlen*noutput_items); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.h b/gnuradio-core/src/lib/general/gr_float_to_short.h deleted file mode 100644 index 9e43804f54..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_short.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FLOAT_TO_SHORT_H -#define INCLUDED_GR_FLOAT_TO_SHORT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_float_to_short; -typedef boost::shared_ptr<gr_float_to_short> gr_float_to_short_sptr; - -GR_CORE_API gr_float_to_short_sptr -gr_make_float_to_short (size_t vlen=1, float scale=1); - -/*! - * \brief Convert stream of float to a stream of short - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar multiplier to change the output signal scale. - */ - -class GR_CORE_API gr_float_to_short : public gr_sync_block -{ - friend GR_CORE_API - gr_float_to_short_sptr gr_make_float_to_short (size_t vlen, float scale); - gr_float_to_short (size_t vlen, float scale); - - size_t d_vlen; - float d_scale; - - public: - /*! - * Get the scalar multiplier value. - */ - float scale() const; - - /*! - * Set the scalar multiplier value. - */ - void set_scale(float scale); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_FLOAT_TO_SHORT_H */ diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.i b/gnuradio-core/src/lib/general/gr_float_to_short.i deleted file mode 100644 index ea59a388e2..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_short.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,float_to_short) - -gr_float_to_short_sptr -gr_make_float_to_short (size_t vlen=1, float scale=1); - -class gr_float_to_short : public gr_sync_block -{ -public: - float scale() const; - void set_scale(float scale); -}; diff --git a/gnuradio-core/src/lib/general/gr_float_to_uchar.cc b/gnuradio-core/src/lib/general/gr_float_to_uchar.cc deleted file mode 100644 index 5aec73b71f..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_uchar.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_float_to_uchar.h> -#include <gr_io_signature.h> -#include <gri_float_to_uchar.h> - -gr_float_to_uchar_sptr -gr_make_float_to_uchar () -{ - return gnuradio::get_initial_sptr(new gr_float_to_uchar ()); -} - -gr_float_to_uchar::gr_float_to_uchar () - : gr_sync_block ("gr_float_to_uchar", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (unsigned char))) -{ -} - -int -gr_float_to_uchar::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - gri_float_to_uchar (in, out, noutput_items); - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_float_to_uchar.h b/gnuradio-core/src/lib/general/gr_float_to_uchar.h deleted file mode 100644 index 7fd947048a..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_uchar.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FLOAT_TO_UCHAR_H -#define INCLUDED_GR_FLOAT_TO_UCHAR_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_float_to_uchar; -typedef boost::shared_ptr<gr_float_to_uchar> gr_float_to_uchar_sptr; - -GR_CORE_API gr_float_to_uchar_sptr -gr_make_float_to_uchar (); - -/*! - * \brief Convert stream of float to a stream of unsigned char - * \ingroup converter_blk - */ - -class GR_CORE_API gr_float_to_uchar : public gr_sync_block -{ - friend GR_CORE_API gr_float_to_uchar_sptr gr_make_float_to_uchar (); - gr_float_to_uchar (); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_FLOAT_TO_UCHAR_H */ diff --git a/gnuradio-core/src/lib/general/gr_float_to_uchar.i b/gnuradio-core/src/lib/general/gr_float_to_uchar.i deleted file mode 100644 index b35979213c..0000000000 --- a/gnuradio-core/src/lib/general/gr_float_to_uchar.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,float_to_uchar) - -gr_float_to_uchar_sptr gr_make_float_to_uchar (); - -class gr_float_to_uchar : public gr_sync_block -{ - gr_float_to_uchar (); -}; diff --git a/gnuradio-core/src/lib/general/gr_fmdet_cf.cc b/gnuradio-core/src/lib/general/gr_fmdet_cf.cc deleted file mode 100644 index f020362920..0000000000 --- a/gnuradio-core/src/lib/general/gr_fmdet_cf.cc +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_fmdet_cf.h> -#include <gr_io_signature.h> -#include <math.h> -#include <gr_math.h> - -#define M_TWOPI (2*M_PI) - -gr_fmdet_cf_sptr -gr_make_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl) -{ - return gnuradio::get_initial_sptr(new gr_fmdet_cf (samplerate, freq_low, freq_high, scl)); -} - -gr_fmdet_cf::gr_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl) - : gr_sync_block ("fmdet_cf", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (float))), - d_S1(0.1),d_S2(0.1), - d_S3(0.1),d_S4(0.1) -{ - const float h[]={0.003118678733, -0.012139843428, 0.027270898036, -0.051318579352, - 0.090406910552, -0.162926865366, 0.361885392563, 0.000000000000, - -0.361885392563, 0.162926865366, -0.090406910552, 0.051318579352, - -0.027270898036, 0.012139843428, -0.003118678733}; - - - - - float delta; - std::vector<float> taps(15); - - d_freqhi = freq_high; - d_freqlo = freq_low; - delta = (d_freqhi - d_freqlo); - d_scl = scl; - d_bias = 0.5*scl*(d_freqhi+d_freqlo)/delta; - for (int i=0;i<15;i++) taps[i] = h[i]; - // d_filter = gr_fir_util::create_gr_fir_ccf(taps); - -} - -int -gr_fmdet_cf::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *iptr = (gr_complex *) input_items[0]; - float *optr = (float *) output_items[0]; - // const gr_complex *scaleiptr = (gr_complex *) input_items[0]; - - int size = noutput_items; - - gr_complex Sdot,S0,S1=d_S1,S2=d_S2,S3=d_S3,S4=d_S4; - float d_8 = 8.0; - - while (size-- > 0) { - S0=*iptr++; - - - Sdot = d_scl * (-S0+d_8*S1-d_8*S1+S4); - - d_freq = (S2.real()*Sdot.imag()-S2.imag()*Sdot.real())/ - (S2.real()*S2.real()+S2.imag()*S2.imag()); - - S4=S3; - S3=S2; - S2=S1; - S1=S0; - - - *optr++ = d_freq-d_bias; - } - d_S1=S1; - d_S2=S2; - d_S3=S3; - d_S4=S4; - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_fmdet_cf.h b/gnuradio-core/src/lib/general/gr_fmdet_cf.h deleted file mode 100644 index f85630f2fb..0000000000 --- a/gnuradio-core/src/lib/general/gr_fmdet_cf.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FMDET_CF_H -#define INCLUDED_GR_FMDET_CF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_fmdet_cf; -typedef boost::shared_ptr<gr_fmdet_cf> gr_fmdet_cf_sptr; - -GR_CORE_API gr_fmdet_cf_sptr gr_make_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl); - -class gr_fir_ccf; - - -/*! - * \brief Implements an IQ slope detector - * - * - * input: stream of complex; output: stream of floats - * - * This implements a limiting slope detector. The limiter is in the - * normalization by the magnitude of the sample - */ - -class GR_CORE_API gr_fmdet_cf : public gr_sync_block -{ - friend GR_CORE_API gr_fmdet_cf_sptr gr_make_fmdet_cf (float samplerate, float freq_low, - float freq_high, float scl); - - gr_complex d_S1,d_S2,d_S3,d_S4; - float d_freq,d_freqlo,d_freqhi,d_scl,d_bias; - gr_fir_ccf* d_filter; - gr_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_fmdet_cf.i b/gnuradio-core/src/lib/general/gr_fmdet_cf.i deleted file mode 100644 index 2db596b7a9..0000000000 --- a/gnuradio-core/src/lib/general/gr_fmdet_cf.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,fmdet_cf) - -gr_fmdet_cf_sptr gr_make_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl); - -class gr_fmdet_cf : public gr_sync_block -{ - private: - gr_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl); -}; diff --git a/gnuradio-core/src/lib/general/gr_framer_sink_1.cc b/gnuradio-core/src/lib/general/gr_framer_sink_1.cc deleted file mode 100644 index 64a0af6a07..0000000000 --- a/gnuradio-core/src/lib/general/gr_framer_sink_1.cc +++ /dev/null @@ -1,190 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_framer_sink_1.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <stdexcept> -#include <string.h> - -#define VERBOSE 0 - -inline void -gr_framer_sink_1::enter_search() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_search\n"); - - d_state = STATE_SYNC_SEARCH; -} - -inline void -gr_framer_sink_1::enter_have_sync() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_have_sync\n"); - - d_state = STATE_HAVE_SYNC; - d_header = 0; - d_headerbitlen_cnt = 0; -} - -inline void -gr_framer_sink_1::enter_have_header(int payload_len, int whitener_offset) -{ - if (VERBOSE) - fprintf(stderr, "@ enter_have_header (payload_len = %d) (offset = %d)\n", payload_len, whitener_offset); - - d_state = STATE_HAVE_HEADER; - d_packetlen = payload_len; - d_packet_whitener_offset = whitener_offset; - d_packetlen_cnt = 0; - d_packet_byte = 0; - d_packet_byte_index = 0; -} - -gr_framer_sink_1_sptr -gr_make_framer_sink_1(gr_msg_queue_sptr target_queue) -{ - return gnuradio::get_initial_sptr(new gr_framer_sink_1(target_queue)); -} - - -gr_framer_sink_1::gr_framer_sink_1(gr_msg_queue_sptr target_queue) - : gr_sync_block ("framer_sink_1", - gr_make_io_signature (1, 1, sizeof(unsigned char)), - gr_make_io_signature (0, 0, 0)), - d_target_queue(target_queue) -{ - enter_search(); -} - -gr_framer_sink_1::~gr_framer_sink_1 () -{ -} - -int -gr_framer_sink_1::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - int count=0; - - if (VERBOSE) - fprintf(stderr,">>> Entering state machine\n"); - - while (count < noutput_items){ - switch(d_state) { - - case STATE_SYNC_SEARCH: // Look for flag indicating beginning of pkt - if (VERBOSE) - fprintf(stderr,"SYNC Search, noutput=%d\n", noutput_items); - - while (count < noutput_items) { - if (in[count] & 0x2){ // Found it, set up for header decode - enter_have_sync(); - break; - } - count++; - } - break; - - case STATE_HAVE_SYNC: - if (VERBOSE) - fprintf(stderr,"Header Search bitcnt=%d, header=0x%08x\n", - d_headerbitlen_cnt, d_header); - - while (count < noutput_items) { // Shift bits one at a time into header - d_header = (d_header << 1) | (in[count++] & 0x1); - if (++d_headerbitlen_cnt == HEADERBITLEN) { - - if (VERBOSE) - fprintf(stderr, "got header: 0x%08x\n", d_header); - - // we have a full header, check to see if it has been received properly - if (header_ok()){ - int payload_len; - int whitener_offset; - header_payload(&payload_len, &whitener_offset); - enter_have_header(payload_len, whitener_offset); - - if (d_packetlen == 0){ // check for zero-length payload - // build a zero-length message - // NOTE: passing header field as arg1 is not scalable - gr_message_sptr msg = - gr_make_message(0, d_packet_whitener_offset, 0, 0); - - d_target_queue->insert_tail(msg); // send it - msg.reset(); // free it up - - enter_search(); - } - } - else - enter_search(); // bad header - break; // we're in a new state - } - } - break; - - case STATE_HAVE_HEADER: - if (VERBOSE) - fprintf(stderr,"Packet Build\n"); - - while (count < noutput_items) { // shift bits into bytes of packet one at a time - d_packet_byte = (d_packet_byte << 1) | (in[count++] & 0x1); - if (d_packet_byte_index++ == 7) { // byte is full so move to next byte - d_packet[d_packetlen_cnt++] = d_packet_byte; - d_packet_byte_index = 0; - - if (d_packetlen_cnt == d_packetlen){ // packet is filled - - // build a message - // NOTE: passing header field as arg1 is not scalable - gr_message_sptr msg = - gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen_cnt); - memcpy(msg->msg(), d_packet, d_packetlen_cnt); - - d_target_queue->insert_tail(msg); // send it - msg.reset(); // free it up - - enter_search(); - break; - } - } - } - break; - - default: - assert(0); - - } // switch - - } // while - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_framer_sink_1.h b/gnuradio-core/src/lib/general/gr_framer_sink_1.h deleted file mode 100644 index 93e41745f3..0000000000 --- a/gnuradio-core/src/lib/general/gr_framer_sink_1.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FRAMER_SINK_1_H -#define INCLUDED_GR_FRAMER_SINK_1_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_msg_queue.h> - -class gr_framer_sink_1; -typedef boost::shared_ptr<gr_framer_sink_1> gr_framer_sink_1_sptr; - -GR_CORE_API gr_framer_sink_1_sptr -gr_make_framer_sink_1 (gr_msg_queue_sptr target_queue); - -/*! - * \brief Given a stream of bits and access_code flags, assemble packets. - * \ingroup sink_blk - * - * input: stream of bytes from gr_correlate_access_code_bb - * output: none. Pushes assembled packet into target queue - * - * The framer expects a fixed length header of 2 16-bit shorts - * containing the payload length, followed by the payload. If the - * 2 16-bit shorts are not identical, this packet is ignored. Better - * algs are welcome. - * - * The input data consists of bytes that have two bits used. - * Bit 0, the LSB, contains the data bit. - * Bit 1 if set, indicates that the corresponding bit is the - * the first bit of the packet. That is, this bit is the first - * one after the access code. - */ -class GR_CORE_API gr_framer_sink_1 : public gr_sync_block -{ - friend GR_CORE_API gr_framer_sink_1_sptr - gr_make_framer_sink_1 (gr_msg_queue_sptr target_queue); - - private: - enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; - - static const int MAX_PKT_LEN = 4096; - static const int HEADERBITLEN = 32; - - gr_msg_queue_sptr d_target_queue; // where to send the packet when received - state_t d_state; - unsigned int d_header; // header bits - int d_headerbitlen_cnt; // how many so far - - unsigned char d_packet[MAX_PKT_LEN]; // assembled payload - unsigned char d_packet_byte; // byte being assembled - int d_packet_byte_index; // which bit of d_packet_byte we're working on - int d_packetlen; // length of packet - int d_packet_whitener_offset; // offset into whitener string to use - int d_packetlen_cnt; // how many so far - - protected: - gr_framer_sink_1(gr_msg_queue_sptr target_queue); - - void enter_search(); - void enter_have_sync(); - void enter_have_header(int payload_len, int whitener_offset); - - bool header_ok() - { - // confirm that two copies of header info are identical - return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; - } - - void header_payload(int *len, int *offset) - { - // header consists of two 16-bit shorts in network byte order - // payload length is lower 12 bits - // whitener offset is upper 4 bits - *len = (d_header >> 16) & 0x0fff; - *offset = (d_header >> 28) & 0x000f; - } - - public: - ~gr_framer_sink_1(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FRAMER_SINK_1_H */ diff --git a/gnuradio-core/src/lib/general/gr_framer_sink_1.i b/gnuradio-core/src/lib/general/gr_framer_sink_1.i deleted file mode 100644 index 06281b138d..0000000000 --- a/gnuradio-core/src/lib/general/gr_framer_sink_1.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,framer_sink_1); - -gr_framer_sink_1_sptr -gr_make_framer_sink_1(gr_msg_queue_sptr target_queue); - -class gr_framer_sink_1 : public gr_sync_block -{ - protected: - gr_framer_sink_1(gr_msg_queue_sptr target_queue); - - public: - ~gr_framer_sink_1(); -}; diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc deleted file mode 100644 index 5c4daec583..0000000000 --- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_frequency_modulator_fc.h> -#include <gr_io_signature.h> -#include <gr_fxpt.h> -#include <math.h> -#include <boost/math/special_functions/trunc.hpp> - - -gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (double sensitivity) -{ - return gnuradio::get_initial_sptr(new gr_frequency_modulator_fc (sensitivity)); -} - -gr_frequency_modulator_fc::gr_frequency_modulator_fc (double sensitivity) - : gr_sync_block ("frequency_modulator_fc", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_sensitivity (sensitivity), d_phase (0) -{ -} - -int -gr_frequency_modulator_fc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - d_phase = d_phase + d_sensitivity * in[i]; - - while (d_phase > (float)(M_PI)) - d_phase -= (float)(2.0 * M_PI); - while (d_phase < (float)(-M_PI)) - d_phase += (float)(2.0 * M_PI); - - float oi, oq; - - gr_int32 angle = gr_fxpt::float_to_fixed (d_phase); - gr_fxpt::sincos (angle, &oq, &oi); - out[i] = gr_complex (oi, oq); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h deleted file mode 100644 index c680e96480..0000000000 --- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FREQUENCY_MODULATOR_FC_H -#define INCLUDED_GR_FREQUENCY_MODULATOR_FC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_frequency_modulator_fc; -typedef boost::shared_ptr<gr_frequency_modulator_fc> gr_frequency_modulator_fc_sptr; - -GR_CORE_API gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (double sensitivity); - -/*! - * \brief Frequency modulator block - * \ingroup modulation_blk - * - * float input; complex baseband output - */ -class GR_CORE_API gr_frequency_modulator_fc : public gr_sync_block -{ - float d_sensitivity; - float d_phase; - - friend GR_CORE_API gr_frequency_modulator_fc_sptr - gr_make_frequency_modulator_fc (double sensitivity); - - gr_frequency_modulator_fc (double sensitivity); - - public: - void set_sensitivity(float sens) { d_sensitivity = sens; } - float sensitivity() const { return d_sensitivity; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FREQUENCY_MODULATOR_FC_H */ diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.i b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.i deleted file mode 100644 index 9a740583b0..0000000000 --- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,frequency_modulator_fc) - -gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (double sensitivity); - -class gr_frequency_modulator_fc : public gr_sync_block -{ - private: - gr_frequency_modulator_fc (double sensitivity); -public: - void set_sensitivity(float sens) { d_sensitivity = sens; } - float sensitivity() const { return d_sensitivity; } -}; diff --git a/gnuradio-core/src/lib/general/gr_fxpt.cc b/gnuradio-core/src/lib/general/gr_fxpt.cc deleted file mode 100644 index 2ea8520e6b..0000000000 --- a/gnuradio-core/src/lib/general/gr_fxpt.cc +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_fxpt.h> - -const float gr_fxpt::s_sine_table[1 << NBITS][2] = { -#include "sine_table.h" -}; - -const float gr_fxpt::PI = 3.14159265358979323846; -const float gr_fxpt::TWO_TO_THE_31 = 2147483648.0; - diff --git a/gnuradio-core/src/lib/general/gr_fxpt.h b/gnuradio-core/src/lib/general/gr_fxpt.h deleted file mode 100644 index 9de6c0c18a..0000000000 --- a/gnuradio-core/src/lib/general/gr_fxpt.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FXPT_H -#define INCLUDED_GR_FXPT_H - -#include <gr_core_api.h> -#include <gr_types.h> - -/*! - * \brief fixed point sine and cosine and friends. - * \ingroup misc - * - * fixed pt radians - * --------- -------- - * -2**31 -pi - * 0 0 - * 2**31-1 pi - epsilon - * - */ -class GR_CORE_API gr_fxpt -{ - static const int WORDBITS = 32; - static const int NBITS = 10; - static const float s_sine_table[1 << NBITS][2]; - static const float PI; - static const float TWO_TO_THE_31; -public: - - static gr_int32 - float_to_fixed (float x) - { - // Fold x into -PI to PI. - int d = (int)floor(x/2/PI+0.5); - x -= d*2*PI; - // And convert to an integer. - return (gr_int32) ((float) x * TWO_TO_THE_31 / PI); - } - - static float - fixed_to_float (gr_int32 x) - { - return x * (PI / TWO_TO_THE_31); - } - - /*! - * \brief Given a fixed point angle x, return float sine (x) - */ - static float - sin (gr_int32 x) - { - gr_uint32 ux = x; - int index = ux >> (WORDBITS - NBITS); - return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1]; - } - - /* - * \brief Given a fixed point angle x, return float cosine (x) - */ - static float - cos (gr_int32 x) - { - gr_uint32 ux = x + 0x40000000; - int index = ux >> (WORDBITS - NBITS); - return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1]; - } - - /* - * \brief Given a fixedpoint angle x, return float cos(x) and sin (x) - */ - static void sincos(gr_int32 x, float *s, float *c) - { - gr_uint32 ux = x; - int sin_index = ux >> (WORDBITS - NBITS); - *s = s_sine_table[sin_index][0] * (ux >> 1) + s_sine_table[sin_index][1]; - - ux = x + 0x40000000; - int cos_index = ux >> (WORDBITS - NBITS); - *c = s_sine_table[cos_index][0] * (ux >> 1) + s_sine_table[cos_index][1]; - - return; - } - -}; - -#endif /* INCLUDED_GR_FXPT_H */ diff --git a/gnuradio-core/src/lib/general/gr_fxpt_nco.h b/gnuradio-core/src/lib/general/gr_fxpt_nco.h deleted file mode 100644 index 9473e6ddbc..0000000000 --- a/gnuradio-core/src/lib/general/gr_fxpt_nco.h +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FXPT_NCO_H -#define INCLUDED_GR_FXPT_NCO_H - -#include <gr_core_api.h> -#include <gr_fxpt.h> -#include <gr_complex.h> - -/*! - * \brief Numerically Controlled Oscillator (NCO) - * \ingroup misc - */ -class GR_CORE_API gr_fxpt_nco { - gr_uint32 d_phase; - gr_int32 d_phase_inc; - -public: - gr_fxpt_nco () : d_phase (0), d_phase_inc (0) {} - - ~gr_fxpt_nco () {} - - // radians - void set_phase (float angle) { - d_phase = gr_fxpt::float_to_fixed (angle); - } - - void adjust_phase (float delta_phase) { - d_phase += gr_fxpt::float_to_fixed (delta_phase); - } - - // angle_rate is in radians / step - void set_freq (float angle_rate){ - d_phase_inc = gr_fxpt::float_to_fixed (angle_rate); - } - - // angle_rate is a delta in radians / step - void adjust_freq (float delta_angle_rate) - { - d_phase_inc += gr_fxpt::float_to_fixed (delta_angle_rate); - } - - // increment current phase angle - - void step () - { - d_phase += d_phase_inc; - } - - void step (int n) - { - d_phase += d_phase_inc * n; - } - - // units are radians / step - float get_phase () const { return gr_fxpt::fixed_to_float (d_phase); } - float get_freq () const { return gr_fxpt::fixed_to_float (d_phase_inc); } - - // compute sin and cos for current phase angle - void sincos (float *sinx, float *cosx) const - { - *sinx = gr_fxpt::sin (d_phase); - *cosx = gr_fxpt::cos (d_phase); - } - - // compute cos and sin for a block of phase angles - void sincos (gr_complex *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = gr_complex(gr_fxpt::cos (d_phase) * ampl, gr_fxpt::sin (d_phase) * ampl); - step (); - } - } - - // compute sin for a block of phase angles - void sin (float *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (float)(gr_fxpt::sin (d_phase) * ampl); - step (); - } - } - - // compute cos for a block of phase angles - void cos (float *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (float)(gr_fxpt::cos (d_phase) * ampl); - step (); - } - } - - // compute sin for a block of phase angles - void sin (short *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (short)(gr_fxpt::sin (d_phase) * ampl); - step (); - } - } - - // compute cos for a block of phase angles - void cos (short *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (short)(gr_fxpt::cos (d_phase) * ampl); - step (); - } - } - - // compute sin for a block of phase angles - void sin (int *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (int)(gr_fxpt::sin (d_phase) * ampl); - step (); - } - } - - // compute cos for a block of phase angles - void cos (int *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (int)(gr_fxpt::cos (d_phase) * ampl); - step (); - } - } - - // compute cos or sin for current phase angle - float cos () const { return gr_fxpt::cos (d_phase); } - float sin () const { return gr_fxpt::sin (d_phase); } -}; - -#endif /* INCLUDED_GR_FXPT_NCO_H */ diff --git a/gnuradio-core/src/lib/general/gr_fxpt_vco.h b/gnuradio-core/src/lib/general/gr_fxpt_vco.h deleted file mode 100644 index 09c649de72..0000000000 --- a/gnuradio-core/src/lib/general/gr_fxpt_vco.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FXPT_VCO_H -#define INCLUDED_GR_FXPT_VCO_H - -#include <gr_core_api.h> -#include <gr_fxpt.h> -#include <gr_complex.h> - -/*! - * \brief Voltage Controlled Oscillator (VCO) - * \ingroup misc - */ -class GR_CORE_API gr_fxpt_vco { - gr_int32 d_phase; - -public: - gr_fxpt_vco () : d_phase (0) {} - - ~gr_fxpt_vco () {} - - // radians - void set_phase (float angle) { - d_phase = gr_fxpt::float_to_fixed (angle); - } - - void adjust_phase (float delta_phase) { - d_phase += gr_fxpt::float_to_fixed (delta_phase); - } - - float get_phase () const { return gr_fxpt::fixed_to_float (d_phase); } - - // compute sin and cos for current phase angle - void sincos (float *sinx, float *cosx) const - { - *sinx = gr_fxpt::sin (d_phase); - *cosx = gr_fxpt::cos (d_phase); - } - - // compute a block at a time - void cos (float *output, const float *input, int noutput_items, float k, float ampl = 1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (float)(gr_fxpt::cos (d_phase) * ampl); - adjust_phase(input[i] * k); - } - } - - // compute cos or sin for current phase angle - float cos () const { return gr_fxpt::cos (d_phase); } - float sin () const { return gr_fxpt::sin (d_phase); } -}; - -#endif /* INCLUDED_GR_FXPT_VCO_H */ diff --git a/gnuradio-core/src/lib/general/gr_glfsr_source_b.cc b/gnuradio-core/src/lib/general/gr_glfsr_source_b.cc deleted file mode 100644 index fcfeb80dcf..0000000000 --- a/gnuradio-core/src/lib/general/gr_glfsr_source_b.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_glfsr_source_b.h> -#include <gri_glfsr.h> -#include <gr_io_signature.h> -#include <stdexcept> - -gr_glfsr_source_b_sptr -gr_make_glfsr_source_b(int degree, bool repeat, int mask, int seed) -{ - return gnuradio::get_initial_sptr(new gr_glfsr_source_b(degree, repeat, mask, seed)); -} - -gr_glfsr_source_b::gr_glfsr_source_b(int degree, bool repeat, int mask, int seed) - : gr_sync_block ("glfsr_source_b", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof(unsigned char))), - d_repeat(repeat), - d_index(0) -{ - if (degree < 1 || degree > 32) - throw std::runtime_error("gr_glfsr_source_b: degree must be between 1 and 32 inclusive"); - d_length = (unsigned int)((1ULL << degree)-1); - - if (mask == 0) - mask = gri_glfsr::glfsr_mask(degree); - d_glfsr = new gri_glfsr(mask, seed); -} - -gr_glfsr_source_b::~gr_glfsr_source_b() -{ - delete d_glfsr; -} - -int -gr_glfsr_source_b::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - char *out = (char *) output_items[0]; - if ((d_index > d_length) && d_repeat == false) - return -1; /* once through the sequence */ - - int i; - for (i = 0; i < noutput_items; i++) { - out[i] = d_glfsr->next_bit(); - d_index++; - if (d_index > d_length && d_repeat == false) - break; - } - - return i; -} - -int -gr_glfsr_source_b::mask() const -{ - return d_glfsr->mask(); -} diff --git a/gnuradio-core/src/lib/general/gr_glfsr_source_b.i b/gnuradio-core/src/lib/general/gr_glfsr_source_b.i deleted file mode 100644 index ffdd52ddba..0000000000 --- a/gnuradio-core/src/lib/general/gr_glfsr_source_b.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,glfsr_source_b); - -gr_glfsr_source_b_sptr -gr_make_glfsr_source_b(int degree, bool repeat=true, int mask=0, int seed=1) - throw (std::runtime_error); - -class gr_glfsr_source_b : public gr_sync_block -{ -protected: - gr_glfsr_source_b(int degree, bool repeat, int mask, int seed); - -public: - unsigned int period() const; - int mask() const; -}; diff --git a/gnuradio-core/src/lib/general/gr_glfsr_source_f.cc b/gnuradio-core/src/lib/general/gr_glfsr_source_f.cc deleted file mode 100644 index a9efc8a706..0000000000 --- a/gnuradio-core/src/lib/general/gr_glfsr_source_f.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_glfsr_source_f.h> -#include <gri_glfsr.h> -#include <gr_io_signature.h> -#include <stdexcept> - -gr_glfsr_source_f_sptr -gr_make_glfsr_source_f(int degree, bool repeat, int mask, int seed) -{ - return gnuradio::get_initial_sptr(new gr_glfsr_source_f(degree, repeat, mask, seed)); -} - -gr_glfsr_source_f::gr_glfsr_source_f(int degree, bool repeat, int mask, int seed) - : gr_sync_block ("glfsr_source_f", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof(float))), - d_repeat(repeat), - d_index(0) -{ - if (degree < 1 || degree > 32) - throw std::runtime_error("gr_glfsr_source_f: degree must be between 1 and 32 inclusive"); - d_length = (unsigned int)((1ULL << degree)-1); - - if (mask == 0) - mask = gri_glfsr::glfsr_mask(degree); - d_glfsr = new gri_glfsr(mask, seed); -} - -gr_glfsr_source_f::~gr_glfsr_source_f() -{ - delete d_glfsr; -} - -int -gr_glfsr_source_f::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *out = (float *) output_items[0]; - if ((d_index > d_length) && d_repeat == false) - return -1; /* once through the sequence */ - - int i; - for (i = 0; i < noutput_items; i++) { - out[i] = (float)d_glfsr->next_bit()*2.0-1.0; - d_index++; - if (d_index > d_length && d_repeat == false) - break; - } - - return i; -} - -int -gr_glfsr_source_f::mask() const -{ - return d_glfsr->mask(); -} diff --git a/gnuradio-core/src/lib/general/gr_glfsr_source_f.h b/gnuradio-core/src/lib/general/gr_glfsr_source_f.h deleted file mode 100644 index 3549e3e5df..0000000000 --- a/gnuradio-core/src/lib/general/gr_glfsr_source_f.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_GLFSR_SOURCE_F_H -#define INCLUDED_GR_GLFSR_SOURCE_F_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gri_glfsr; - -class gr_glfsr_source_f; -typedef boost::shared_ptr<gr_glfsr_source_f> gr_glfsr_source_f_sptr; - -GR_CORE_API gr_glfsr_source_f_sptr gr_make_glfsr_source_f(int degree, bool repeat=true, int mask=0, int seed=1); - -/*! - * \brief Galois LFSR pseudo-random source generating float outputs -1.0 - 1.0 - * \ingroup source_blk - */ -class GR_CORE_API gr_glfsr_source_f : public gr_sync_block -{ - private: - friend GR_CORE_API gr_glfsr_source_f_sptr - gr_make_glfsr_source_f(int degree, bool repeat, int mask, int seed); - - gri_glfsr *d_glfsr; - - bool d_repeat; - unsigned int d_index; - unsigned int d_length; - - gr_glfsr_source_f(int degree, bool repeat, int mask, int seed); - - public: - - ~gr_glfsr_source_f(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - unsigned int period() const { return d_length; } - int mask() const; -}; - -#endif /* INCLUDED_GR_GLFSR_SOURCE_F_H */ diff --git a/gnuradio-core/src/lib/general/gr_glfsr_source_f.i b/gnuradio-core/src/lib/general/gr_glfsr_source_f.i deleted file mode 100644 index 2f84387c27..0000000000 --- a/gnuradio-core/src/lib/general/gr_glfsr_source_f.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,glfsr_source_f); - -gr_glfsr_source_f_sptr -gr_make_glfsr_source_f(int degree, bool repeat=true, int mask=0, int seed=1) - throw (std::runtime_error); - -class gr_glfsr_source_f : public gr_sync_block -{ -protected: - gr_glfsr_source_f(int degree, bool repeat, int mask, int seed); - -public: - unsigned int period() const; - int mask() const; -}; diff --git a/gnuradio-core/src/lib/general/gr_head.cc b/gnuradio-core/src/lib/general/gr_head.cc index cb07c84ddc..1726888113 100644 --- a/gnuradio-core/src/lib/general/gr_head.cc +++ b/gnuradio-core/src/lib/general/gr_head.cc @@ -26,6 +26,7 @@ #include <gr_head.h> #include <gr_io_signature.h> #include <string.h> +#include <iostream> gr_head::gr_head (size_t sizeof_stream_item, unsigned long long nitems) : gr_sync_block ("head", diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.cc b/gnuradio-core/src/lib/general/gr_int_to_float.cc deleted file mode 100644 index a7fb24dc69..0000000000 --- a/gnuradio-core/src/lib/general/gr_int_to_float.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_int_to_float.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_int_to_float_sptr -gr_make_int_to_float (size_t vlen, float scale) -{ - return gnuradio::get_initial_sptr(new gr_int_to_float (vlen, scale)); -} - -gr_int_to_float::gr_int_to_float (size_t vlen, float scale) - : gr_sync_block ("gr_int_to_float", - gr_make_io_signature (1, 1, sizeof (int32_t)*vlen), - gr_make_io_signature (1, 1, sizeof (float)*vlen)), - d_vlen(vlen), d_scale(scale) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_int_to_float::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const int32_t *in = (const int32_t *) input_items[0]; - float *out = (float *) output_items[0]; - - if(is_unaligned()) { - volk_32i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items); - } - else { - volk_32i_s32f_convert_32f_a(out, in, d_scale, d_vlen*noutput_items); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.h b/gnuradio-core/src/lib/general/gr_int_to_float.h deleted file mode 100644 index 6200c5be75..0000000000 --- a/gnuradio-core/src/lib/general/gr_int_to_float.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_INT_TO_FLOAT_H -#define INCLUDED_GR_INT_TO_FLOAT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_int_to_float; -typedef boost::shared_ptr<gr_int_to_float> gr_int_to_float_sptr; - -GR_CORE_API gr_int_to_float_sptr -gr_make_int_to_float (size_t vlen=1, float scale=1); - -/*! - * \brief Convert stream of int to a stream of float - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar divider to change the output signal scale. - */ - -class GR_CORE_API gr_int_to_float : public gr_sync_block -{ - private: - friend GR_CORE_API gr_int_to_float_sptr - gr_make_int_to_float (size_t vlen, float scale); - gr_int_to_float (size_t vlen, float scale); - - size_t d_vlen; - float d_scale; - - public: - /*! - * Get the scalar divider value. - */ - float scale() const; - - /*! - * Set the scalar divider value. - */ - void set_scale(float scale); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_INT_TO_FLOAT_H */ diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.i b/gnuradio-core/src/lib/general/gr_int_to_float.i deleted file mode 100644 index f3781ac8ab..0000000000 --- a/gnuradio-core/src/lib/general/gr_int_to_float.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,int_to_float) - -gr_int_to_float_sptr -gr_make_int_to_float (size_t vlen=1, float scale=1); - -class gr_int_to_float : public gr_sync_block -{ - float scale() const; - void set_scale(float scale); -}; diff --git a/gnuradio-core/src/lib/general/gr_interleave.cc b/gnuradio-core/src/lib/general/gr_interleave.cc deleted file mode 100644 index 5d572871eb..0000000000 --- a/gnuradio-core/src/lib/general/gr_interleave.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_interleave.h> -#include <gr_io_signature.h> -#include <string.h> - - -gr_interleave_sptr -gr_make_interleave (size_t itemsize) -{ - return gnuradio::get_initial_sptr(new gr_interleave (itemsize)); -} - -gr_interleave::gr_interleave (size_t itemsize) - : gr_sync_interpolator ("interleave", - gr_make_io_signature (1, gr_io_signature::IO_INFINITE, itemsize), - gr_make_io_signature (1, 1, itemsize), - 1), - d_itemsize (itemsize) -{ -} - -gr_interleave::~gr_interleave () -{ - // NOP -} - -bool -gr_interleave::check_topology (int ninputs, int noutputs) -{ - set_interpolation (ninputs); - return true; -} - -int -gr_interleave::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t nchan = input_items.size (); - size_t itemsize = d_itemsize; - const char **in = (const char **) &input_items[0]; - char *out = (char *) output_items[0]; - - for (int i = 0; i < noutput_items; i += nchan){ - for (unsigned int n = 0; n < nchan; n++){ - memcpy (out, in[n], itemsize); - out += itemsize; - in[n] += itemsize; - } - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_interleave.h b/gnuradio-core/src/lib/general/gr_interleave.h deleted file mode 100644 index 3b0202d008..0000000000 --- a/gnuradio-core/src/lib/general/gr_interleave.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_INTERLEAVE_H -#define INCLUDED_GR_INTERLEAVE_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_interleave; -typedef boost::shared_ptr<gr_interleave> gr_interleave_sptr; - -GR_CORE_API gr_interleave_sptr gr_make_interleave (size_t itemsize); - -/*! - * \brief interleave N inputs to a single output - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_interleave : public gr_sync_interpolator -{ - friend GR_CORE_API gr_interleave_sptr gr_make_interleave (size_t itemsize); - - size_t d_itemsize; - - gr_interleave (size_t itemsize); - -public: - ~gr_interleave (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool check_topology (int ninputs, int noutputs); - -}; - -#endif /* INCLUDED_GR_INTERLEAVE_H */ diff --git a/gnuradio-core/src/lib/general/gr_interleave.i b/gnuradio-core/src/lib/general/gr_interleave.i deleted file mode 100644 index 09a57c886c..0000000000 --- a/gnuradio-core/src/lib/general/gr_interleave.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,interleave) - -gr_interleave_sptr gr_make_interleave (size_t itemsize); - -class gr_interleave : public gr_sync_interpolator -{ - gr_interleave (size_t itemsize); -}; diff --git a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.cc b/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.cc deleted file mode 100644 index e7d375a355..0000000000 --- a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_interleaved_short_to_complex.h> -#include <gr_io_signature.h> -#include <gri_interleaved_short_to_complex.h> - -gr_interleaved_short_to_complex_sptr -gr_make_interleaved_short_to_complex () -{ - return gnuradio::get_initial_sptr(new gr_interleaved_short_to_complex ()); -} - -gr_interleaved_short_to_complex::gr_interleaved_short_to_complex () - : gr_sync_decimator ("gr_interleaved_short_to_complex", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (1, 1, sizeof (gr_complex)), - 2) -{ -} - -int -gr_interleaved_short_to_complex::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const short *in = (const short *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - gri_interleaved_short_to_complex (in, out, 2 * noutput_items); - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h b/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h deleted file mode 100644 index 159d107b33..0000000000 --- a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_INTERLEAVED_SHORT_TO_COMPLEX_H -#define INCLUDED_GR_INTERLEAVED_SHORT_TO_COMPLEX_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_interleaved_short_to_complex; -typedef boost::shared_ptr<gr_interleaved_short_to_complex> - gr_interleaved_short_to_complex_sptr; - -GR_CORE_API gr_interleaved_short_to_complex_sptr -gr_make_interleaved_short_to_complex (); - -/*! - * \brief Convert stream of interleaved shorts to a stream of complex - * \ingroup converter_blk - */ - -class GR_CORE_API gr_interleaved_short_to_complex : public gr_sync_decimator -{ - friend GR_CORE_API gr_interleaved_short_to_complex_sptr gr_make_interleaved_short_to_complex (); - gr_interleaved_short_to_complex (); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_INTERLEAVED_SHORT_TO_COMPLEX_H */ diff --git a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.i b/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.i deleted file mode 100644 index 7977105506..0000000000 --- a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,interleaved_short_to_complex) - -gr_interleaved_short_to_complex_sptr gr_make_interleaved_short_to_complex (); - -class gr_interleaved_short_to_complex : public gr_sync_decimator -{ - gr_interleaved_short_to_complex (); -}; diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc b/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc deleted file mode 100644 index 1becbfa116..0000000000 --- a/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_keep_m_in_n.h> -#include <gr_io_signature.h> -#include <string.h> -#include <stdio.h> - -gr_keep_m_in_n_sptr -gr_make_keep_m_in_n(size_t item_size, int m, int n, int offset) -{ - return gnuradio::get_initial_sptr(new gr_keep_m_in_n(item_size, m, n, offset)); -} - - -/* -* -* offset = 0, starts with 0th item -* offset = 1, starts with 1st item, etc... -* -* we take m items out of each n -*/ -gr_keep_m_in_n::gr_keep_m_in_n(size_t item_size, int m, int n, int offset) - : gr_block("keep_m_in_n", - gr_make_io_signature(1, 1, item_size), - gr_make_io_signature(1, 1, item_size)), - d_n(n), - d_m(m), - d_offset(offset), - d_itemsize(item_size) -{ - // sanity checking - assert(d_m > 0); - assert(d_n > 0); - assert(d_m <= d_n); - assert(d_offset <= (d_n-d_m)); - - set_output_multiple(m); -} - - -void -gr_keep_m_in_n::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - ninput_items_required[0] = d_n*(noutput_items/d_m); -} - -void -gr_keep_m_in_n::set_offset(int offset) -{ - d_offset = offset; -} - -int -gr_keep_m_in_n::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - uint8_t* out = (uint8_t*)output_items[0]; - const uint8_t* in = (const uint8_t*)input_items[0]; - - // iterate over data blocks of size {n, input : m, output} - int blks = std::min(noutput_items/d_m, ninput_items[0]/d_n); - for(int i=0; i<blks; i++) { - // set up copy pointers - const uint8_t* iptr = &in[(i*d_n + d_offset)*d_itemsize]; - uint8_t* optr = &out[i*d_m*d_itemsize]; - // perform copy - memcpy( optr, iptr, d_m*d_itemsize ); - } - - consume_each(d_n); - return d_m; -} diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.h b/gnuradio-core/src/lib/general/gr_keep_m_in_n.h deleted file mode 100644 index c6bf40ecf2..0000000000 --- a/gnuradio-core/src/lib/general/gr_keep_m_in_n.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_KEEP_M_IN_N_H -#define INCLUDED_GR_KEEP_M_IN_N_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_keep_m_in_n; -typedef boost::shared_ptr<gr_keep_m_in_n> gr_keep_m_in_n_sptr; - -GR_CORE_API gr_keep_m_in_n_sptr -gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset); - - -/*! - * \brief decimate a stream, keeping one item out of every n. - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_keep_m_in_n : public gr_block -{ - friend GR_CORE_API gr_keep_m_in_n_sptr - gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset); - - int d_n; - int d_m; - int d_count; - int d_offset; - int d_itemsize; - - protected: - gr_keep_m_in_n (size_t item_size, int m, int n, int offset); - void forecast (int noutput_items, gr_vector_int &ninput_items_required); - - public: - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void set_offset(int offset); - void set_n(int n){ d_n = n; } - void set_m(int m){ d_m = m; } - -}; - -#endif /* INCLUDED_GR_KEEP_M_IN_N_H */ diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc deleted file mode 100644 index fbba9e91c0..0000000000 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_keep_one_in_n.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_keep_one_in_n_sptr -gr_make_keep_one_in_n (size_t item_size, int n) -{ - return gnuradio::get_initial_sptr(new gr_keep_one_in_n (item_size, n)); -} - -gr_keep_one_in_n::gr_keep_one_in_n (size_t item_size, int n) - : gr_block ("keep_one_in_n", - gr_make_io_signature (1, 1, item_size), - gr_make_io_signature (1, 1, item_size)), - d_count(n) -{ - // To avoid bad behavior with using set_relative_rate in this block with - // VERY large values of n, we will keep track of things ourselves. Using - // this to turn off automatic tag propagation, which will be handled - // locally in general_work(). - set_tag_propagation_policy(TPP_DONT); - - set_n(n); -} - -void -gr_keep_one_in_n::set_n(int n) -{ - if (n < 1) - n = 1; - - d_n = n; - d_count = n; - - // keep our internal understanding of the relative rate of this block - // don't set the relative rate, though, and we will handle our own - // tag propagation. - d_decim_rate = 1.0/(float)d_n; -} - -int -gr_keep_one_in_n::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *in = (const char *) input_items[0]; - char *out = (char *) output_items[0]; - - size_t item_size = input_signature ()->sizeof_stream_item (0); - int ni = 0; - int no = 0; - - while (ni < ninput_items[0] && no < noutput_items){ - d_count--; - if (d_count <= 0){ - memcpy (out, in, item_size); // copy 1 item - out += item_size; - no++; - d_count = d_n; - } - in += item_size; - ni++; - } - - // Because we have set TPP_DONT, we have to propagate the tags here manually. - // Adjustment of the tag sample value is done using the float d_decim_rate. - std::vector<gr_tag_t> tags; - std::vector<gr_tag_t>::iterator t; - get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+ni); - for(t = tags.begin(); t != tags.end(); t++) { - gr_tag_t new_tag = *t; - new_tag.offset *= d_decim_rate; - add_item_tag(0, new_tag); - } - - consume_each (ni); - return no; -} diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.h b/gnuradio-core/src/lib/general/gr_keep_one_in_n.h deleted file mode 100644 index f37475204b..0000000000 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_KEEP_ONE_IN_N_H -#define INCLUDED_GR_KEEP_ONE_IN_N_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_keep_one_in_n; -typedef boost::shared_ptr<gr_keep_one_in_n> gr_keep_one_in_n_sptr; - -GR_CORE_API gr_keep_one_in_n_sptr -gr_make_keep_one_in_n (size_t item_size, int n); - - -/*! - * \brief decimate a stream, keeping one item out of every n. - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_keep_one_in_n : public gr_block -{ - friend GR_CORE_API gr_keep_one_in_n_sptr - gr_make_keep_one_in_n (size_t item_size, int n); - - int d_n; - int d_count; - float d_decim_rate; - - protected: - gr_keep_one_in_n (size_t item_size, int n); - - public: - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void set_n(int n); - -}; - -#endif /* INCLUDED_GR_KEEP_ONE_IN_N_H */ diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.i b/gnuradio-core/src/lib/general/gr_keep_one_in_n.i deleted file mode 100644 index 534098cded..0000000000 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,keep_one_in_n) - -gr_keep_one_in_n_sptr -gr_make_keep_one_in_n (size_t itemsize, int n); - -class gr_keep_one_in_n : public gr_block -{ - protected: - gr_keep_one_in_n (size_t itemsize, int n); - - public: - void set_n(int n); -}; diff --git a/gnuradio-core/src/lib/general/gr_log2_const.h b/gnuradio-core/src/lib/general/gr_log2_const.h deleted file mode 100644 index 40afcf8b80..0000000000 --- a/gnuradio-core/src/lib/general/gr_log2_const.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -/* - * a bit of template hackery... - */ -#ifndef INCLUDED_GR_LOG2_CONST_H -#define INCLUDED_GR_LOG2_CONST_H - -#include <gr_core_api.h> -#include <assert.h> - -template<unsigned int k> static inline int gr_log2_const() { assert(0); return 0; } - -template<> inline int gr_log2_const<1>() { return 0; } -template<> inline int gr_log2_const<2>() { return 1; } -template<> inline int gr_log2_const<4>() { return 2; } -template<> inline int gr_log2_const<8>() { return 3; } -template<> inline int gr_log2_const<16>() { return 4; } -template<> inline int gr_log2_const<32>() { return 5; } -template<> inline int gr_log2_const<64>() { return 6; } -template<> inline int gr_log2_const<128>() { return 7; } -template<> inline int gr_log2_const<256>() { return 8; } -template<> inline int gr_log2_const<512>() { return 9; } -template<> inline int gr_log2_const<1024>(){ return 10; } - -#endif /* INCLUDED_GR_LOG2_CONST_H */ diff --git a/gnuradio-core/src/lib/general/gr_map_bb.cc b/gnuradio-core/src/lib/general/gr_map_bb.cc deleted file mode 100644 index 7deb8971a5..0000000000 --- a/gnuradio-core/src/lib/general/gr_map_bb.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_map_bb.h> -#include <gr_io_signature.h> - -gr_map_bb_sptr -gr_make_map_bb (const std::vector<int> &map) -{ - return gnuradio::get_initial_sptr(new gr_map_bb (map)); -} - -gr_map_bb::gr_map_bb (const std::vector<int> &map) - : gr_sync_block ("map_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))) -{ - for (int i = 0; i < 0x100; i++) - d_map[i] = i; - - unsigned int size = std::min((size_t) 0x100, map.size()); - for (unsigned int i = 0; i < size; i++) - d_map[i] = map[i]; -} - -int -gr_map_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++) - out[i] = d_map[in[i]]; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_map_bb.h b/gnuradio-core/src/lib/general/gr_map_bb.h deleted file mode 100644 index 0a2f5a45f8..0000000000 --- a/gnuradio-core/src/lib/general/gr_map_bb.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_MAP_BB_H -#define INCLUDED_GR_MAP_BB_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_map_bb; -typedef boost::shared_ptr<gr_map_bb> gr_map_bb_sptr; - -GR_CORE_API gr_map_bb_sptr gr_make_map_bb(const std::vector<int> &map); - -/*! - * \brief output[i] = map[input[i]] - * \ingroup coding_blk - */ - -class GR_CORE_API gr_map_bb : public gr_sync_block -{ - friend GR_CORE_API gr_map_bb_sptr gr_make_map_bb(const std::vector<int> &map); - - unsigned char d_map[0x100]; - - gr_map_bb(const std::vector<int> &map); - -public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_MAP_BB_H */ diff --git a/gnuradio-core/src/lib/general/gr_map_bb.i b/gnuradio-core/src/lib/general/gr_map_bb.i deleted file mode 100644 index 9c8bff6447..0000000000 --- a/gnuradio-core/src/lib/general/gr_map_bb.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,map_bb); - -gr_map_bb_sptr gr_make_map_bb (const std::vector<int> &map); - -class gr_map_bb : public gr_sync_block -{ - private: - gr_map_bb (const std::vector<int> &map); -}; - diff --git a/gnuradio-core/src/lib/general/gr_message_strobe.cc b/gnuradio-core/src/lib/general/gr_message_strobe.cc deleted file mode 100644 index 6a9f807d18..0000000000 --- a/gnuradio-core/src/lib/general/gr_message_strobe.cc +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_message_strobe.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> -#include <iostream> - -// public constructor that returns a shared_ptr - -gr_message_strobe_sptr -gr_make_message_strobe (pmt::pmt_t msg, float period_ms) -{ - return gnuradio::get_initial_sptr(new gr_message_strobe(msg, period_ms)); -} - -gr_message_strobe::gr_message_strobe (pmt::pmt_t msg, float period_ms) - : gr_block("message_strobe", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(0, 0, 0)), - d_finished(false), - d_period_ms(period_ms), - d_msg(msg) -{ - message_port_register_out(pmt::mp("strobe")); - d_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&gr_message_strobe::run, this))); - - message_port_register_in(pmt::mp("set_msg")); - set_msg_handler(pmt::mp("set_msg"), boost::bind(&gr_message_strobe::set_msg, this, _1)); -} - -gr_message_strobe::~gr_message_strobe() -{ - d_finished = true; - d_thread->interrupt(); - d_thread->join(); -} - -void gr_message_strobe::run(){ - while(!d_finished) { - boost::this_thread::sleep(boost::posix_time::milliseconds(d_period_ms)); - if(d_finished){ return; } - - message_port_pub( pmt::mp("strobe"), d_msg ); - } -} diff --git a/gnuradio-core/src/lib/general/gr_message_strobe.h b/gnuradio-core/src/lib/general/gr_message_strobe.h deleted file mode 100644 index 89046ffc05..0000000000 --- a/gnuradio-core/src/lib/general/gr_message_strobe.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_MESSAGE_STROBE_H -#define INCLUDED_GR_MESSAGE_STROBE_H - -#include <gr_core_api.h> -#include <gr_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> - -class gr_message_strobe; -typedef boost::shared_ptr<gr_message_strobe> gr_message_strobe_sptr; - -GR_CORE_API gr_message_strobe_sptr gr_make_message_strobe (pmt::pmt_t msg, float period_ms); - -/*! - * \brief Send message at defined interval - * \ingroup msg_blk - */ -class GR_CORE_API gr_message_strobe : public gr_block -{ - private: - friend GR_CORE_API gr_message_strobe_sptr - gr_make_message_strobe(pmt::pmt_t msg, float period_ms); - - boost::shared_ptr<boost::thread> d_thread; - bool d_finished; - float d_period_ms; - pmt::pmt_t d_msg; - - void run(); - - protected: - gr_message_strobe (pmt::pmt_t msg, float period_ms); - - public: - ~gr_message_strobe (); - - void set_msg(pmt::pmt_t msg){ d_msg = msg; } -}; - -#endif /* INCLUDED_GR_MESSAGE_STROBE_H */ diff --git a/gnuradio-core/src/lib/general/gr_message_strobe.i b/gnuradio-core/src/lib/general/gr_message_strobe.i deleted file mode 100644 index 490aa8e8a1..0000000000 --- a/gnuradio-core/src/lib/general/gr_message_strobe.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,message_strobe); - -%{ -#include <gr_message_strobe.h> -%} - -%include "gr_message_strobe.h" - diff --git a/gnuradio-core/src/lib/general/gr_multiply_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_cc.cc deleted file mode 100644 index 4a3751419f..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_cc.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_multiply_cc.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_multiply_cc_sptr -gr_make_multiply_cc (size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_multiply_cc (vlen)); -} - -gr_multiply_cc::gr_multiply_cc (size_t vlen) - : gr_sync_block ("gr_multiply_cc", - gr_make_io_signature (1, -1, sizeof (gr_complex)*vlen), - gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(gr_complex); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_multiply_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *out = (gr_complex *) output_items[0]; - int noi = d_vlen*noutput_items; - - memcpy(out, input_items[0], noi*sizeof(gr_complex)); - if(is_unaligned()) { - for(size_t i = 1; i < input_items.size(); i++) - volk_32fc_x2_multiply_32fc_u(out, out, (gr_complex*)input_items[i], noi); - } - else { - for(size_t i = 1; i < input_items.size(); i++) - volk_32fc_x2_multiply_32fc_a(out, out, (gr_complex*)input_items[i], noi); - } - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc deleted file mode 100644 index 0c5fb4a926..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_multiply_conjugate_cc.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_multiply_conjugate_cc_sptr -gr_make_multiply_conjugate_cc (size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_multiply_conjugate_cc (vlen)); -} - -gr_multiply_conjugate_cc::gr_multiply_conjugate_cc (size_t vlen) - : gr_sync_block ("gr_multiply_conjugate_cc", - gr_make_io_signature (2, 2, sizeof (gr_complex)*vlen), - gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(gr_complex); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_multiply_conjugate_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in0 = (gr_complex *) input_items[0]; - gr_complex *in1 = (gr_complex *) input_items[1]; - gr_complex *out = (gr_complex *) output_items[0]; - int noi = d_vlen*noutput_items; - - if(is_unaligned()) { - volk_32fc_x2_multiply_conjugate_32fc_u(out, in0, in1, noi); - } - else { - volk_32fc_x2_multiply_conjugate_32fc_a(out, in0, in1, noi); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc deleted file mode 100644 index bd4511937f..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_multiply_const_cc.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_multiply_const_cc_sptr -gr_make_multiply_const_cc (gr_complex k, size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_multiply_const_cc (k, vlen)); -} - -gr_multiply_const_cc::gr_multiply_const_cc (gr_complex k, size_t vlen) - : gr_sync_block ("gr_multiply_const_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen), - gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)), - d_k(k), d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(gr_complex); - set_alignment(std::max(1,alignment_multiple)); -} - -gr_complex -gr_multiply_const_cc::k() const -{ - return d_k; -} - -void -gr_multiply_const_cc::set_k(gr_complex k) -{ - d_k = k; -} - -int -gr_multiply_const_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - int noi = d_vlen*noutput_items; - - if(is_unaligned()) { - volk_32fc_s32fc_multiply_32fc_u(out, in, d_k, noi); - } - else { - volk_32fc_s32fc_multiply_32fc_a(out, in, d_k, noi); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.h b/gnuradio-core/src/lib/general/gr_multiply_const_cc.h deleted file mode 100644 index 97962abc70..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_const_cc.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_MULTIPLY_CONST_CC_H -#define INCLUDED_GR_MULTIPLY_CONST_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_multiply_const_cc; -typedef boost::shared_ptr<gr_multiply_const_cc> gr_multiply_const_cc_sptr; - -GR_CORE_API gr_multiply_const_cc_sptr -gr_make_multiply_const_cc (gr_complex k, size_t vlen=1); - -/*! - * \brief Multiply stream of complex values with a constant \p k - * \ingroup math_blk - */ - -class GR_CORE_API gr_multiply_const_cc : public gr_sync_block -{ - private: - friend GR_CORE_API gr_multiply_const_cc_sptr - gr_make_multiply_const_cc (gr_complex k, size_t vlen); - gr_multiply_const_cc (gr_complex k, size_t vlen); - - gr_complex d_k; - size_t d_vlen; - - public: - gr_complex k() const; - void set_k(gr_complex k); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_MULTIPLY_CONST_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.i b/gnuradio-core/src/lib/general/gr_multiply_const_cc.i deleted file mode 100644 index c2f3cbed31..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_const_cc.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,multiply_const_cc) - -gr_multiply_const_cc_sptr -gr_make_multiply_const_cc (gr_complex k, size_t vlen=1); - -class gr_multiply_const_cc : public gr_sync_block -{ -public: - gr_complex k() const; - void set_k(gr_complex k); -}; diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc b/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc deleted file mode 100644 index 16ba39df93..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_multiply_const_ff.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_multiply_const_ff_sptr -gr_make_multiply_const_ff (float k, size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_multiply_const_ff (k, vlen)); -} - -gr_multiply_const_ff::gr_multiply_const_ff (float k, size_t vlen) - : gr_sync_block ("gr_multiply_const_ff", - gr_make_io_signature (1, 1, sizeof (float)*vlen), - gr_make_io_signature (1, 1, sizeof (float)*vlen)), - d_k(k), d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -float -gr_multiply_const_ff::k() const -{ - return d_k; -} - -void -gr_multiply_const_ff::set_k(float k) -{ - d_k = k; -} - -int -gr_multiply_const_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = d_vlen*noutput_items; - - if(is_unaligned()) { - volk_32f_s32f_multiply_32f_u(out, in, d_k, noi); - } - else { - volk_32f_s32f_multiply_32f_a(out, in, d_k, noi); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.h b/gnuradio-core/src/lib/general/gr_multiply_const_ff.h deleted file mode 100644 index fac73f88a2..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_const_ff.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_MULTIPLY_CONST_FF_H -#define INCLUDED_GR_MULTIPLY_CONST_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_multiply_const_ff; -typedef boost::shared_ptr<gr_multiply_const_ff> gr_multiply_const_ff_sptr; - -GR_CORE_API gr_multiply_const_ff_sptr -gr_make_multiply_const_ff (float k, size_t vlen=1); - -/*! - * \brief Multiply stream of float values with a constant \p k - * \ingroup math_blk - */ - -class GR_CORE_API gr_multiply_const_ff : public gr_sync_block -{ - private: - friend GR_CORE_API gr_multiply_const_ff_sptr - gr_make_multiply_const_ff (float k, size_t vlen); - gr_multiply_const_ff (float k, size_t vlen); - - float d_k; - size_t d_vlen; - - public: - float k() const; - void set_k(float k); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_MULTIPLY_CONST_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.i b/gnuradio-core/src/lib/general/gr_multiply_const_ff.i deleted file mode 100644 index 343f67cd25..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_const_ff.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,multiply_const_ff) - -gr_multiply_const_ff_sptr -gr_make_multiply_const_ff (float k, size_t vlen=1); - -class gr_multiply_const_ff : public gr_sync_block -{ -public: - float k() const; - void set_k(float k); -}; diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.cc b/gnuradio-core/src/lib/general/gr_multiply_ff.cc deleted file mode 100644 index bb7bd07550..0000000000 --- a/gnuradio-core/src/lib/general/gr_multiply_ff.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_multiply_ff.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_multiply_ff_sptr -gr_make_multiply_ff (size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_multiply_ff (vlen)); -} - -gr_multiply_ff::gr_multiply_ff (size_t vlen) - : gr_sync_block ("gr_multiply_ff", - gr_make_io_signature (1, -1, sizeof (float)*vlen), - gr_make_io_signature (1, 1, sizeof (float)*vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_multiply_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *out = (float *) output_items[0]; - int noi = d_vlen*noutput_items; - - memcpy(out, input_items[0], noi*sizeof(float)); - if(is_unaligned()) { - for(size_t i = 1; i < input_items.size(); i++) - volk_32f_x2_multiply_32f_u(out, out, (const float*)input_items[i], noi); - } - else { - for(size_t i = 1; i < input_items.size(); i++) - volk_32f_x2_multiply_32f_a(out, out, (const float*)input_items[i], noi); - } - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_nco.h b/gnuradio-core/src/lib/general/gr_nco.h deleted file mode 100644 index fb51106aab..0000000000 --- a/gnuradio-core/src/lib/general/gr_nco.h +++ /dev/null @@ -1,198 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GR_NCO_H_ -#define _GR_NCO_H_ - - -#include <vector> -#include <gr_sincos.h> -#include <cmath> -#include <gr_complex.h> - -/*! - * \brief base class template for Numerically Controlled Oscillator (NCO) - * \ingroup misc - */ - - -//FIXME Eventually generalize this to fixed point - -template<class o_type, class i_type> -class gr_nco { -public: - gr_nco () : phase (0), phase_inc(0) {} - - virtual ~gr_nco () {} - - // radians - void set_phase (double angle) { - phase = angle; - } - - void adjust_phase (double delta_phase) { - phase += delta_phase; - } - - - // angle_rate is in radians / step - void set_freq (double angle_rate){ - phase_inc = angle_rate; - } - - // angle_rate is a delta in radians / step - void adjust_freq (double delta_angle_rate) - { - phase_inc += delta_angle_rate; - } - - // increment current phase angle - - void step () - { - phase += phase_inc; - if (fabs (phase) > M_PI){ - - while (phase > M_PI) - phase -= 2*M_PI; - - while (phase < -M_PI) - phase += 2*M_PI; - } - } - - void step (int n) - { - phase += phase_inc * n; - if (fabs (phase) > M_PI){ - - while (phase > M_PI) - phase -= 2*M_PI; - - while (phase < -M_PI) - phase += 2*M_PI; - } - } - - // units are radians / step - double get_phase () const { return phase; } - double get_freq () const { return phase_inc; } - - // compute sin and cos for current phase angle - void sincos (float *sinx, float *cosx) const; - - // compute cos or sin for current phase angle - float cos () const { return std::cos (phase); } - float sin () const { return std::sin (phase); } - - // compute a block at a time - void sin (float *output, int noutput_items, double ampl = 1.0); - void cos (float *output, int noutput_items, double ampl = 1.0); - void sincos (gr_complex *output, int noutput_items, double ampl = 1.0); - void sin (short *output, int noutput_items, double ampl = 1.0); - void cos (short *output, int noutput_items, double ampl = 1.0); - void sin (int *output, int noutput_items, double ampl = 1.0); - void cos (int *output, int noutput_items, double ampl = 1.0); - -protected: - double phase; - double phase_inc; -}; - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::sincos (float *sinx, float *cosx) const -{ - gr_sincosf (phase, sinx, cosx); -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::sin (float *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (float)(sin () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::cos (float *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (float)(cos () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::sin (short *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (short)(sin() * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::cos (short *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (short)(cos () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::sin (int *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (int)(sin () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::cos (int *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (int)(cos () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::sincos (gr_complex *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - float cosx, sinx; - sincos (&sinx, &cosx); - output[i] = gr_complex(cosx * ampl, sinx * ampl); - step (); - } -} -#endif /* _NCO_H_ */ diff --git a/gnuradio-core/src/lib/general/gr_nlog10_ff.cc b/gnuradio-core/src/lib/general/gr_nlog10_ff.cc deleted file mode 100644 index 24cfe25fb5..0000000000 --- a/gnuradio-core/src/lib/general/gr_nlog10_ff.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_nlog10_ff.h> -#include <gr_io_signature.h> -#include <algorithm> - -gr_nlog10_ff_sptr -gr_make_nlog10_ff (float n, unsigned vlen, float k) -{ - return gnuradio::get_initial_sptr(new gr_nlog10_ff(n, vlen, k)); -} - -gr_nlog10_ff::gr_nlog10_ff(float n, unsigned vlen, float k) - : gr_sync_block("nlog10_ff", - gr_make_io_signature(1, 1, sizeof(float) * vlen), - gr_make_io_signature(1, 1, sizeof(float) * vlen)), - d_vlen(vlen), d_n(n), d_k(k) -{ -} - -gr_nlog10_ff::~gr_nlog10_ff() -{ -} - -int -gr_nlog10_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = noutput_items * d_vlen; - float n = d_n; - float k = d_k; - - for (int i = 0; i < noi; i++) - out[i] = n * log10(std::max(in[i], (float) 1e-18)) + k; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_nlog10_ff.h b/gnuradio-core/src/lib/general/gr_nlog10_ff.h deleted file mode 100644 index cfeba3feeb..0000000000 --- a/gnuradio-core/src/lib/general/gr_nlog10_ff.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_NLOG10_FF_H -#define INCLUDED_GR_NLOG10_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_nlog10_ff; -typedef boost::shared_ptr<gr_nlog10_ff> gr_nlog10_ff_sptr; - -GR_CORE_API gr_nlog10_ff_sptr gr_make_nlog10_ff (float n=1.0, unsigned vlen=1, float k=0); - -/*! - * \brief output = n*log10(input) + k - * \ingroup math_blk - */ -class GR_CORE_API gr_nlog10_ff : public gr_sync_block -{ - friend GR_CORE_API gr_nlog10_ff_sptr gr_make_nlog10_ff (float n, unsigned vlen, float k); - - unsigned int d_vlen; - float d_n; - float d_k; - - gr_nlog10_ff (float n, unsigned vlen, float k); - -public: - ~gr_nlog10_ff(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_NLOG10_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_nlog10_ff.i b/gnuradio-core/src/lib/general/gr_nlog10_ff.i deleted file mode 100644 index 73da597938..0000000000 --- a/gnuradio-core/src/lib/general/gr_nlog10_ff.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,nlog10_ff); - -gr_nlog10_ff_sptr gr_make_nlog10_ff (float n=1.0, unsigned vlen=1, float k=0); - -class gr_nlog10_ff : public gr_sync_block -{ - gr_nlog10_ff (float n, unsigned vlen, float k); - -public: - ~gr_nlog10_ff(); -}; diff --git a/gnuradio-core/src/lib/general/gr_nop.cc b/gnuradio-core/src/lib/general/gr_nop.cc index edfe1d76d9..164f3ba8dd 100644 --- a/gnuradio-core/src/lib/general/gr_nop.cc +++ b/gnuradio-core/src/lib/general/gr_nop.cc @@ -27,6 +27,10 @@ #include <gr_io_signature.h> #include <boost/bind.hpp> +#ifdef GR_CTRLPORT +#include <rpcregisterhelpers.h> +#endif + gr_nop_sptr gr_make_nop (size_t sizeof_stream_item) { @@ -37,7 +41,7 @@ gr_nop::gr_nop (size_t sizeof_stream_item) : gr_block ("nop", gr_make_io_signature (0, -1, sizeof_stream_item), gr_make_io_signature (0, -1, sizeof_stream_item)), - d_nmsgs_recvd(0) + d_nmsgs_recvd(0), d_ctrlport_test(0) { // Arrange to have count_received_msgs called when messages are received. message_port_register_in(pmt::mp("port")); @@ -64,3 +68,25 @@ gr_nop::general_work (int noutput_items, return noutput_items; } + +void +gr_nop::setup_rpc() +{ +#ifdef GR_CTRLPORT + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_nop, int>( + alias(), "test", + &gr_nop::ctrlport_test, + pmt::mp(-256), pmt::mp(255), pmt::mp(0), + "", "Simple testing variable", + RPC_PRIVLVL_MIN, DISPNULL))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_set<gr_nop, int>( + alias(), "test", + &gr_nop::set_ctrlport_test, + pmt::mp(-256), pmt::mp(255), pmt::mp(0), + "", "Simple testing variable", + RPC_PRIVLVL_MIN, DISPNULL))); +#endif /* GR_CTRLPORT */ +} diff --git a/gnuradio-core/src/lib/general/gr_nop.h b/gnuradio-core/src/lib/general/gr_nop.h index e0d59280f9..5f1cb13a02 100644 --- a/gnuradio-core/src/lib/general/gr_nop.h +++ b/gnuradio-core/src/lib/general/gr_nop.h @@ -42,8 +42,12 @@ class GR_CORE_API gr_nop : public gr_block friend GR_CORE_API gr_nop_sptr gr_make_nop (size_t sizeof_stream_item); gr_nop (size_t sizeof_stream_item); + std::vector<boost::any> d_rpc_vars; + void setup_rpc(); + protected: int d_nmsgs_recvd; + int d_ctrlport_test; // Method that just counts any received messages. void count_received_msgs(pmt::pmt_t msg); @@ -56,6 +60,8 @@ protected: int nmsgs_received() const { return d_nmsgs_recvd; } + int ctrlport_test() { return d_ctrlport_test; } + void set_ctrlport_test(int x) { d_ctrlport_test = x; } }; #endif /* INCLUDED_GR_NOP_H */ diff --git a/gnuradio-core/src/lib/general/gr_nop.i b/gnuradio-core/src/lib/general/gr_nop.i index 977a15d186..73ffa93630 100644 --- a/gnuradio-core/src/lib/general/gr_nop.i +++ b/gnuradio-core/src/lib/general/gr_nop.i @@ -25,6 +25,9 @@ GR_SWIG_BLOCK_MAGIC(gr,nop) gr_nop_sptr gr_make_nop (size_t sizeof_stream_item); class gr_nop : public gr_block { +public: + int ctrlport_test(); + void set_ctrlport_test(int x); private: gr_nop (size_t sizeof_stream_item); }; diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc deleted file mode 100644 index 0ea0c9e388..0000000000 --- a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pack_k_bits_bb.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <iostream> - -gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb(unsigned k) -{ - return gnuradio::get_initial_sptr(new gr_pack_k_bits_bb(k)); -} - - -gr_pack_k_bits_bb::gr_pack_k_bits_bb (unsigned k) - : gr_sync_decimator("pack_k_bits_bb", - gr_make_io_signature (1, 1, sizeof(unsigned char)), - gr_make_io_signature (1, 1, sizeof(unsigned char)), - k), - d_k (k) -{ - if (d_k == 0) - throw std::out_of_range("interpolation must be > 0"); -} - -gr_pack_k_bits_bb::~gr_pack_k_bits_bb() -{ -} - -int -gr_pack_k_bits_bb::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *)input_items[0]; - unsigned char *out = (unsigned char *)output_items[0]; - - for(int i = 0; i < noutput_items; i++) { - out[i] = 0x00; - for(unsigned int j = 0; j < d_k; j++) { - out[i] |= (0x01 & in[i*d_k+j])<<(d_k-j-1); - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h deleted file mode 100644 index 8e1508c78b..0000000000 --- a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_PACK_K_BITS_BB_H -#define INCLUDED_GR_PACK_K_BITS_BB_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_pack_k_bits_bb; -typedef boost::shared_ptr<gr_pack_k_bits_bb> gr_pack_k_bits_bb_sptr; -GR_CORE_API gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (unsigned k); - -class gr_pack_k_bits_bb; - -/*! - * \brief Converts a stream of bytes with 1 bit in the LSB to a byte with k relevent bits. - * \ingroup converter_blk - */ -class GR_CORE_API gr_pack_k_bits_bb : public gr_sync_decimator -{ - private: - friend GR_CORE_API gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (unsigned k); - - gr_pack_k_bits_bb (unsigned k); - - unsigned d_k; // number of relevent bits to pack from k input bytes - - public: - ~gr_pack_k_bits_bb (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i deleted file mode 100644 index 6ae2095ec7..0000000000 --- a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pack_k_bits_bb) - -gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (int k) throw(std::exception); - -class gr_pack_k_bits_bb : public gr_sync_decimator -{ - private: - gr_pack_k_bits_bb (int k); - - public: - ~gr_pack_k_bits_bb (); -}; diff --git a/gnuradio-core/src/lib/general/gr_packet_sink.cc b/gnuradio-core/src/lib/general/gr_packet_sink.cc deleted file mode 100644 index 19a8c5fc20..0000000000 --- a/gnuradio-core/src/lib/general/gr_packet_sink.cc +++ /dev/null @@ -1,207 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_packet_sink.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <gr_count_bits.h> -#include <string.h> - -#define VERBOSE 0 - -static const int DEFAULT_THRESHOLD = 12; // detect access code with up to DEFAULT_THRESHOLD bits wrong - -inline void -gr_packet_sink::enter_search() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_search\n"); - - d_state = STATE_SYNC_SEARCH; - d_shift_reg = 0; -} - -inline void -gr_packet_sink::enter_have_sync() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_have_sync\n"); - - d_state = STATE_HAVE_SYNC; - d_header = 0; - d_headerbitlen_cnt = 0; -} - -inline void -gr_packet_sink::enter_have_header(int payload_len) -{ - if (VERBOSE) - fprintf(stderr, "@ enter_have_header (payload_len = %d)\n", payload_len); - - d_state = STATE_HAVE_HEADER; - d_packetlen = payload_len; - d_packetlen_cnt = 0; - d_packet_byte = 0; - d_packet_byte_index = 0; -} - -gr_packet_sink_sptr -gr_make_packet_sink (const std::vector<unsigned char>& sync_vector, - gr_msg_queue_sptr target_queue, int threshold) -{ - return gnuradio::get_initial_sptr(new gr_packet_sink (sync_vector, target_queue, threshold)); -} - - -gr_packet_sink::gr_packet_sink (const std::vector<unsigned char>& sync_vector, - gr_msg_queue_sptr target_queue, int threshold) - : gr_sync_block ("packet_sink", - gr_make_io_signature (1, 1, sizeof(float)), - gr_make_io_signature (0, 0, 0)), - d_target_queue(target_queue), d_threshold(threshold == -1 ? DEFAULT_THRESHOLD : threshold) -{ - d_sync_vector = 0; - for(int i=0;i<8;i++){ - d_sync_vector <<= 8; - d_sync_vector |= sync_vector[i]; - } - - enter_search(); -} - -gr_packet_sink::~gr_packet_sink () -{ -} - -int -gr_packet_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *inbuf = (float *) input_items[0]; - int count=0; - - if (VERBOSE) - fprintf(stderr,">>> Entering state machine\n"),fflush(stderr); - - while (count<noutput_items) { - switch(d_state) { - - case STATE_SYNC_SEARCH: // Look for sync vector - if (VERBOSE) - fprintf(stderr,"SYNC Search, noutput=%d\n",noutput_items),fflush(stderr); - - while (count < noutput_items) { - if(slice(inbuf[count++])) - d_shift_reg = (d_shift_reg << 1) | 1; - else - d_shift_reg = d_shift_reg << 1; - - // Compute popcnt of putative sync vector - if(gr_count_bits64 (d_shift_reg ^ d_sync_vector) <= d_threshold) { - // Found it, set up for header decode - enter_have_sync(); - break; - } - } - break; - - case STATE_HAVE_SYNC: - if (VERBOSE) - fprintf(stderr,"Header Search bitcnt=%d, header=0x%08x\n", d_headerbitlen_cnt, d_header), - fflush(stderr); - - while (count < noutput_items) { // Shift bits one at a time into header - if(slice(inbuf[count++])) - d_header = (d_header << 1) | 1; - else - d_header = d_header << 1; - - if (++d_headerbitlen_cnt == HEADERBITLEN) { - - if (VERBOSE) - fprintf(stderr, "got header: 0x%08x\n", d_header); - - // we have a full header, check to see if it has been received properly - if (header_ok()){ - int payload_len = header_payload_len(); - if (payload_len <= MAX_PKT_LEN) // reasonable? - enter_have_header(payload_len); // yes. - else - enter_search(); // no. - } - else - enter_search(); // no. - break; // we're in a new state - } - } - break; - - case STATE_HAVE_HEADER: - if (VERBOSE) - fprintf(stderr,"Packet Build\n"),fflush(stderr); - - while (count < noutput_items) { // shift bits into bytes of packet one at a time - if(slice(inbuf[count++])) - d_packet_byte = (d_packet_byte << 1) | 1; - else - d_packet_byte = d_packet_byte << 1; - - if (d_packet_byte_index++ == 7) { // byte is full so move to next byte - d_packet[d_packetlen_cnt++] = d_packet_byte; - d_packet_byte_index = 0; - - if (d_packetlen_cnt == d_packetlen){ // packet is filled - - // build a message - gr_message_sptr msg = gr_make_message(0, 0, 0, d_packetlen_cnt); - memcpy(msg->msg(), d_packet, d_packetlen_cnt); - - d_target_queue->insert_tail(msg); // send it - msg.reset(); // free it up - - enter_search(); - break; - } - } - } - break; - - default: - assert(0); - - } // switch - - } // while - - return noutput_items; -} - diff --git a/gnuradio-core/src/lib/general/gr_packet_sink.h b/gnuradio-core/src/lib/general/gr_packet_sink.h deleted file mode 100644 index b4cb0b0f6e..0000000000 --- a/gnuradio-core/src/lib/general/gr_packet_sink.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_PACKET_SINK_H -#define INCLUDED_GR_PACKET_SINK_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_msg_queue.h> - -class gr_packet_sink; -typedef boost::shared_ptr<gr_packet_sink> gr_packet_sink_sptr; - -GR_CORE_API gr_packet_sink_sptr -gr_make_packet_sink (const std::vector<unsigned char>& sync_vector, - gr_msg_queue_sptr target_queue, - int threshold = -1 // -1 -> use default - ); -/*! - * \brief process received bits looking for packet sync, header, and process bits into packet - * \ingroup sink_blk - */ -class GR_CORE_API gr_packet_sink : public gr_sync_block -{ - friend GR_CORE_API gr_packet_sink_sptr - gr_make_packet_sink (const std::vector<unsigned char>& sync_vector, - gr_msg_queue_sptr target_queue, - int threshold); - - private: - enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; - - static const int MAX_PKT_LEN = 4096; - static const int HEADERBITLEN = 32; - - gr_msg_queue_sptr d_target_queue; // where to send the packet when received - unsigned long long d_sync_vector; // access code to locate start of packet - unsigned int d_threshold; // how many bits may be wrong in sync vector - - state_t d_state; - - unsigned long long d_shift_reg; // used to look for sync_vector - - unsigned int d_header; // header bits - int d_headerbitlen_cnt; // how many so far - - unsigned char d_packet[MAX_PKT_LEN]; // assembled payload - unsigned char d_packet_byte; // byte being assembled - int d_packet_byte_index; // which bit of d_packet_byte we're working on - int d_packetlen; // length of packet - int d_packetlen_cnt; // how many so far - - protected: - gr_packet_sink(const std::vector<unsigned char>& sync_vector, - gr_msg_queue_sptr target_queue, - int threshold); - - void enter_search(); - void enter_have_sync(); - void enter_have_header(int payload_len); - - int slice(float x) { return x > 0 ? 1 : 0; } - - bool header_ok() - { - // confirm that two copies of header info are identical - return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; - } - - int header_payload_len() - { - // header consists of two 16-bit shorts in network byte order - int t = (d_header >> 16) & 0xffff; - return t; - } - - public: - ~gr_packet_sink(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - - //! return true if we detect carrier - bool carrier_sensed() const - { - return d_state != STATE_SYNC_SEARCH; - } - -}; - -#endif /* INCLUDED_GR_PACKET_SINK_H */ diff --git a/gnuradio-core/src/lib/general/gr_packet_sink.i b/gnuradio-core/src/lib/general/gr_packet_sink.i deleted file mode 100644 index d1290f9d39..0000000000 --- a/gnuradio-core/src/lib/general/gr_packet_sink.i +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,packet_sink) - -gr_packet_sink_sptr -gr_make_packet_sink (const std::vector<unsigned char>& sync_vector, - gr_msg_queue_sptr target_queue, - int threshold = -1 // -1 -> use default - ); - -class gr_packet_sink : public gr_sync_block -{ - protected: - gr_packet_sink (const std::vector<unsigned char>& sync_vector, - gr_msg_queue_sptr target_queue, - int threshold); - public: - ~gr_packet_sink (); - - bool carrier_sensed() const; -}; diff --git a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.cc b/gnuradio-core/src/lib/general/gr_peak_detector2_fb.cc deleted file mode 100644 index a4179a8c2a..0000000000 --- a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.cc +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_peak_detector2_fb.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_peak_detector2_fb_sptr -gr_make_peak_detector2_fb (float threshold_factor_rise, - int look_ahead, float alpha) -{ - return gnuradio::get_initial_sptr(new gr_peak_detector2_fb (threshold_factor_rise, - look_ahead, alpha)); -} - -gr_peak_detector2_fb::gr_peak_detector2_fb (float threshold_factor_rise, - int look_ahead, float alpha) - : gr_sync_block ("peak_detector2_fb", - gr_make_io_signature (1, 1, sizeof(float)), - gr_make_io_signature2 (1, 2, sizeof(char), sizeof(float))), - d_threshold_factor_rise(threshold_factor_rise), - d_look_ahead(look_ahead), d_alpha(alpha), d_avg(0.0f), d_found(false) -{ -} - -int -gr_peak_detector2_fb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) { - float *iptr = (float *) input_items[0]; - char *optr = (char *) output_items[0]; - - assert(noutput_items >= 2); - - memset(optr, 0, noutput_items*sizeof(char)); - - for (int i = 0; i < noutput_items; i++) { - - if (!d_found) { - // Have not yet detected presence of peak - if (iptr[i] > d_avg * (1.0f + d_threshold_factor_rise)) { - d_found = true; - d_look_ahead_remaining = d_look_ahead; - d_peak_val = -(float)INFINITY; - } - else { - d_avg = d_alpha*iptr[i] + (1.0f - d_alpha)*d_avg; - } - } - else { - // Detected presence of peak - if (iptr[i] > d_peak_val) { - d_peak_val = iptr[i]; - d_peak_ind = i; - } - else if (d_look_ahead_remaining <= 0) { - optr[d_peak_ind] = 1; - d_found = false; - d_avg = iptr[i]; - } - - // Have not yet located peak, loop and keep searching. - d_look_ahead_remaining--; - } - - // Every iteration of the loop, write debugging signal out if - // connected: - if (output_items.size() == 2) { - float *sigout = (float *) output_items[1]; - sigout[i] = d_avg; - } - } // loop - - if (!d_found) - return noutput_items; - - // else if detected presence, keep searching during the next call to work. - int tmp = d_peak_ind; - d_peak_ind = 1; - - return tmp - 1; -} - - diff --git a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h b/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h deleted file mode 100644 index 665a6b882c..0000000000 --- a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_gr_peak_detector2_FB_H -#define INCLUDED_gr_peak_detector2_FB_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_peak_detector2_fb; -typedef boost::shared_ptr<gr_peak_detector2_fb> gr_peak_detector2_fb_sptr; - -GR_CORE_API gr_peak_detector2_fb_sptr gr_make_peak_detector2_fb (float threshold_factor_rise = 7, - int look_ahead = 1000, - float alpha = 0.001); - -/*! - * \brief Detect the peak of a signal - * \ingroup level_blk - * - * If a peak is detected, this block outputs a 1, - * or it outputs 0's. A separate debug output may be connected, to - * view the internal EWMA described below. - * - * \param threshold_factor_rise The threshold factor determins when a peak - * is present. An EWMA average of the signal is calculated and when the - * value of the signal goes over threshold_factor_rise*average, we - * call the peak. - * \param look_ahead The look-ahead value is used when the threshold is - * found to locate the peak within this range. - * \param alpha The gain value of a single-pole moving average filter - */ - -class GR_CORE_API gr_peak_detector2_fb : public gr_sync_block -{ - friend GR_CORE_API gr_peak_detector2_fb_sptr - gr_make_peak_detector2_fb (float threshold_factor_rise, int look_ahead, float alpha); - - gr_peak_detector2_fb (float threshold_factor_rise, int look_ahead, float alpha); - -private: - float d_threshold_factor_rise; - int d_look_ahead; - int d_look_ahead_remaining; - int d_peak_ind; - float d_peak_val; - float d_alpha; - float d_avg; - bool d_found; - -public: - - /*! \brief Set the threshold factor value for the rise time - * \param thr new threshold factor - */ - void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; } - - /*! \brief Set the look-ahead factor - * \param look new look-ahead factor - */ - void set_look_ahead(int look) { d_look_ahead = look; } - - /*! \brief Set the running average alpha - * \param alpha new alpha for running average - */ - void set_alpha(int alpha) { d_alpha = alpha; } - - /*! \brief Get the threshold factor value for the rise time - * \return threshold factor - */ - float threshold_factor_rise() { return d_threshold_factor_rise; } - - /*! \brief Get the look-ahead factor value - * \return look-ahead factor - */ - int look_ahead() { return d_look_ahead; } - - /*! \brief Get the alpha value of the running average - * \return alpha - */ - float alpha() { return d_alpha; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif - - diff --git a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.i b/gnuradio-core/src/lib/general/gr_peak_detector2_fb.i deleted file mode 100644 index ec7227e690..0000000000 --- a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.i +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -GR_SWIG_BLOCK_MAGIC(gr,peak_detector2_fb) - - gr_peak_detector2_fb_sptr gr_make_peak_detector2_fb (float threshold_factor_rise = 7, - int look_ahead = 1000, - float alpha=0.001); - -class gr_peak_detector2_fb : public gr_sync_block -{ -private: - gr_peak_detector2_fb (float threshold_factor_rise, int look_ahead, float alpha); - -public: - void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; } - void set_look_ahead(int look) { d_look_ahead = look; } - void set_alpha(int alpha) { d_avg_alpha = alpha; } - - float threshold_factor_rise() { return d_threshold_factor_rise; } - int look_ahead() { return d_look_ahead; } - float alpha() { return d_avg_alpha; } -}; - - diff --git a/gnuradio-core/src/lib/general/gr_phase_modulator_fc.cc b/gnuradio-core/src/lib/general/gr_phase_modulator_fc.cc deleted file mode 100644 index fb05c85a52..0000000000 --- a/gnuradio-core/src/lib/general/gr_phase_modulator_fc.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_phase_modulator_fc.h> -#include <gr_io_signature.h> -#include <gr_sincos.h> -#include <math.h> - - -gr_phase_modulator_fc_sptr gr_make_phase_modulator_fc (double sensitivity) -{ - return gnuradio::get_initial_sptr(new gr_phase_modulator_fc (sensitivity)); -} - -gr_phase_modulator_fc::gr_phase_modulator_fc (double sensitivity) - : gr_sync_block ("phase_modulator_fc", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_sensitivity (sensitivity), d_phase (0) -{ -} - -int -gr_phase_modulator_fc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - d_phase = d_sensitivity * in[i]; - float oi, oq; - gr_sincosf (d_phase, &oq, &oi); - out[i] = gr_complex (oi, oq); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_phase_modulator_fc.h b/gnuradio-core/src/lib/general/gr_phase_modulator_fc.h deleted file mode 100644 index 07f3b82d4c..0000000000 --- a/gnuradio-core/src/lib/general/gr_phase_modulator_fc.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_PHASE_MODULATOR_FC_H -#define INCLUDED_GR_PHASE_MODULATOR_FC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_phase_modulator_fc; -typedef boost::shared_ptr<gr_phase_modulator_fc> gr_phase_modulator_fc_sptr; - -GR_CORE_API gr_phase_modulator_fc_sptr gr_make_phase_modulator_fc (double sensitivity); - -/*! - * \brief Phase modulator block - * \ingroup modulation_blk - * output=complex(cos(in*sensitivity),sin(in*sensitivity)) - */ -class GR_CORE_API gr_phase_modulator_fc : public gr_sync_block -{ - double d_sensitivity; - double d_phase; - - friend GR_CORE_API gr_phase_modulator_fc_sptr - gr_make_phase_modulator_fc (double sensitivity); - - gr_phase_modulator_fc (double sensitivity); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_PHASE_MODULATOR_FC_H */ diff --git a/gnuradio-core/src/lib/general/gr_phase_modulator_fc.i b/gnuradio-core/src/lib/general/gr_phase_modulator_fc.i deleted file mode 100644 index c1816c647e..0000000000 --- a/gnuradio-core/src/lib/general/gr_phase_modulator_fc.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,phase_modulator_fc) - -gr_phase_modulator_fc_sptr gr_make_phase_modulator_fc (double sensitivity); - -class gr_phase_modulator_fc : public gr_sync_block -{ - private: - gr_phase_modulator_fc (double sensitivity); -}; diff --git a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.cc b/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.cc deleted file mode 100644 index b7b1291a3d..0000000000 --- a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.cc +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,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 <gr_pll_carriertracking_cc.h> -#include <gr_io_signature.h> -#include <gr_sincos.h> -#include <math.h> -#include <gr_math.h> - -#ifndef M_TWOPI -#define M_TWOPI (2.0f*M_PI) -#endif - -gr_pll_carriertracking_cc_sptr -gr_make_pll_carriertracking_cc (float loop_bw, float max_freq, float min_freq) -{ - return gnuradio::get_initial_sptr(new gr_pll_carriertracking_cc (loop_bw, max_freq, min_freq)); -} - -gr_pll_carriertracking_cc::gr_pll_carriertracking_cc (float loop_bw, - float max_freq, - float min_freq) - : gr_sync_block ("pll_carriertracking_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - gri_control_loop(loop_bw, max_freq, min_freq), - d_locksig(0), d_lock_threshold(0), d_squelch_enable(false) -{ -} - -float -gr_pll_carriertracking_cc::mod_2pi (float in) -{ - if(in>M_PI) - return in-M_TWOPI; - else if(in<-M_PI) - return in+M_TWOPI; - else - return in; -} - -float -gr_pll_carriertracking_cc::phase_detector(gr_complex sample,float ref_phase) -{ - float sample_phase; - // sample_phase = atan2(sample.imag(),sample.real()); - sample_phase = gr_fast_atan2f(sample.imag(),sample.real()); - return mod_2pi(sample_phase-ref_phase); -} - -bool -gr_pll_carriertracking_cc::lock_detector(void) -{ - return (fabsf(d_locksig) > d_lock_threshold); -} - -bool -gr_pll_carriertracking_cc::squelch_enable(bool set_squelch) -{ - return d_squelch_enable = set_squelch; -} - -float -gr_pll_carriertracking_cc::set_lock_threshold(float threshold) -{ - return d_lock_threshold = threshold; -} - -int -gr_pll_carriertracking_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *iptr = (gr_complex *) input_items[0]; - gr_complex *optr = (gr_complex *) output_items[0]; - - float error; - float t_imag, t_real; - - for (int i = 0; i < noutput_items; i++){ - gr_sincosf(d_phase, &t_imag, &t_real); - optr[i] = iptr[i] * gr_complex(t_real, -t_imag); - - error = phase_detector(iptr[i],d_phase); - - advance_loop(error); - phase_wrap(); - frequency_limit(); - - d_locksig = d_locksig * (1.0 - d_alpha) + \ - d_alpha*(iptr[i].real() * t_real + iptr[i].imag() * t_imag); - - if ((d_squelch_enable) && !lock_detector()) - optr[i] = 0; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.h b/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.h deleted file mode 100644 index b3bc5ddd0c..0000000000 --- a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,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_GR_PLL_CARRIERTRACKING_CC_H -#define INCLUDED_GR_PLL_CARRIERTRACKING_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_control_loop.h> - -class gr_pll_carriertracking_cc; -typedef boost::shared_ptr<gr_pll_carriertracking_cc> gr_pll_carriertracking_cc_sptr; - -GR_CORE_API gr_pll_carriertracking_cc_sptr gr_make_pll_carriertracking_cc (float loop_bw, - float max_freq, - float min_freq); -/*! - * \brief Implements a PLL which locks to the input frequency and outputs the - * input signal mixed with that carrier. - * \ingroup sync_blk - * - * input: stream of complex; output: stream of complex - * - * This PLL locks onto a [possibly noisy] reference carrier on - * the input and outputs that signal, downconverted to DC - * - * All settings max_freq and min_freq are in terms of radians per sample, - * NOT HERTZ. The loop bandwidth determins the lock range and should be set - * around pi/200 -- 2pi/100. - * \sa gr_pll_freqdet_cf, gr_pll_carriertracking_cc - */ - -class GR_CORE_API gr_pll_carriertracking_cc : public gr_sync_block, public gri_control_loop -{ - friend GR_CORE_API gr_pll_carriertracking_cc_sptr gr_make_pll_carriertracking_cc (float loop_bw, - float max_freq, - float min_freq); - - float d_locksig,d_lock_threshold; - bool d_squelch_enable; - gr_pll_carriertracking_cc (float loop_bw, float max_freq, float min_freq); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -private: - float mod_2pi (float in); - float phase_detector(gr_complex sample,float ref_phase); -public: - bool lock_detector(void); - bool squelch_enable(bool); - float set_lock_threshold(float); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.i b/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.i deleted file mode 100644 index a20adf7e20..0000000000 --- a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pll_carriertracking_cc); - -gr_pll_carriertracking_cc_sptr -gr_make_pll_carriertracking_cc (float loop_bw, - float max_freq, - float min_freq); - -class gr_pll_carriertracking_cc : public gr_sync_block, public gri_control_loop -{ - private: - gr_pll_carriertracking_cc (float loop_bw, float max_freq, float min_freq); - public: - bool lock_detector(void); - bool squelch_enable(bool); - float set_lock_threshold(float); - -}; diff --git a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.cc b/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.cc deleted file mode 100644 index f80f4ed07a..0000000000 --- a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pll_freqdet_cf.h> -#include <gr_io_signature.h> -#include <math.h> -#include <gr_math.h> - -#ifndef M_TWOPI -#define M_TWOPI (2.0f*M_PI) -#endif - -gr_pll_freqdet_cf_sptr -gr_make_pll_freqdet_cf (float loop_bw, float max_freq, float min_freq) -{ - return gnuradio::get_initial_sptr(new gr_pll_freqdet_cf (loop_bw, max_freq, min_freq)); -} - -gr_pll_freqdet_cf::gr_pll_freqdet_cf (float loop_bw, float max_freq, float min_freq) - : gr_sync_block ("pll_freqdet_cf", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (float))), - gri_control_loop(loop_bw, max_freq, min_freq) -{ -} - -float -gr_pll_freqdet_cf::mod_2pi (float in) -{ - if(in>M_PI) - return in-M_TWOPI; - else if(in<-M_PI) - return in+M_TWOPI; - else - return in; -} - -float -gr_pll_freqdet_cf::phase_detector(gr_complex sample,float ref_phase) -{ - float sample_phase; - sample_phase = gr_fast_atan2f(sample.imag(),sample.real()); - return mod_2pi(sample_phase-ref_phase); -} - -int -gr_pll_freqdet_cf::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *iptr = (gr_complex *) input_items[0]; - float *optr = (float *) output_items[0]; - - float error; - int size = noutput_items; - - while (size-- > 0) { - *optr++ = d_freq; - - error = phase_detector(*iptr++,d_phase); - - advance_loop(error); - phase_wrap(); - frequency_limit(); - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.h b/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.h deleted file mode 100644 index 3dfc8d7093..0000000000 --- a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_PLL_FREQDET_CF_H -#define INCLUDED_GR_PLL_FREQDET_CF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_control_loop.h> - -class gr_pll_freqdet_cf; -typedef boost::shared_ptr<gr_pll_freqdet_cf> gr_pll_freqdet_cf_sptr; - -GR_CORE_API gr_pll_freqdet_cf_sptr gr_make_pll_freqdet_cf (float loop_bw, - float max_freq, - float min_freq); -/*! - * \brief Implements a PLL which locks to the input frequency and outputs - * an estimate of that frequency. Useful for FM Demod. - * \ingroup sync_blk - * - * input: stream of complex; output: stream of floats - * - * This PLL locks onto a [possibly noisy] reference carrier on - * the input and outputs an estimate of that frequency in radians per sample. - * All settings max_freq and min_freq are in terms of radians per sample, - * NOT HERTZ. The loop bandwidth determins the lock range and should be set - * around pi/200 -- 2pi/100. - * \sa gr_pll_refout_cc, gr_pll_carriertracking_cc - */ - -class GR_CORE_API gr_pll_freqdet_cf : public gr_sync_block, public gri_control_loop -{ - friend GR_CORE_API gr_pll_freqdet_cf_sptr gr_make_pll_freqdet_cf (float loop_bw, - float max_freq, - float min_freq); - - float mod_2pi (float in); - gr_pll_freqdet_cf (float loop_bw, float max_freq, float min_freq); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -private: - float phase_detector(gr_complex sample,float ref_phase); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.i b/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.i deleted file mode 100644 index 87e515adb8..0000000000 --- a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pll_freqdet_cf) - - gr_pll_freqdet_cf_sptr gr_make_pll_freqdet_cf (float loop_bw, - float max_freq, - float min_freq); - -class gr_pll_freqdet_cf : public gr_sync_block, public gri_control_loop -{ - private: - gr_pll_freqdet_cf (float loop_bw, float max_freq, float min_freq); -}; diff --git a/gnuradio-core/src/lib/general/gr_pll_refout_cc.cc b/gnuradio-core/src/lib/general/gr_pll_refout_cc.cc deleted file mode 100644 index 9f95c3f64e..0000000000 --- a/gnuradio-core/src/lib/general/gr_pll_refout_cc.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pll_refout_cc.h> -#include <gr_io_signature.h> -#include <gr_sincos.h> -#include <math.h> -#include <gr_math.h> - -#ifndef M_TWOPI -#define M_TWOPI (2.0f*M_PI) -#endif - -gr_pll_refout_cc_sptr -gr_make_pll_refout_cc (float loop_bw, float max_freq, float min_freq) -{ - return gnuradio::get_initial_sptr(new gr_pll_refout_cc (loop_bw, max_freq, min_freq)); -} - -gr_pll_refout_cc::gr_pll_refout_cc (float loop_bw, float max_freq, float min_freq) - : gr_sync_block ("pll_refout_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - gri_control_loop(loop_bw, max_freq, min_freq) -{ -} - -float -gr_pll_refout_cc::mod_2pi (float in) -{ - if(in>M_PI) - return in-M_TWOPI; - else if(in<-M_PI) - return in+M_TWOPI; - else - return in; -} - -float -gr_pll_refout_cc::phase_detector(gr_complex sample,float ref_phase) -{ - float sample_phase; - sample_phase = gr_fast_atan2f(sample.imag(),sample.real()); - return mod_2pi(sample_phase-ref_phase); -} - -int -gr_pll_refout_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *iptr = (gr_complex *) input_items[0]; - gr_complex *optr = (gr_complex *) output_items[0]; - - float error; - float t_imag, t_real; - int size = noutput_items; - - while (size-- > 0) { - gr_sincosf(d_phase,&t_imag,&t_real); - *optr++ = gr_complex(t_real,t_imag); - - error = phase_detector(*iptr++,d_phase); - - advance_loop(error); - phase_wrap(); - frequency_limit(); - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_pll_refout_cc.h b/gnuradio-core/src/lib/general/gr_pll_refout_cc.h deleted file mode 100644 index ef5cd31e27..0000000000 --- a/gnuradio-core/src/lib/general/gr_pll_refout_cc.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_PLL_REFOUT_CC_H -#define INCLUDED_GR_PLL_REFOUT_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_control_loop.h> - -class gr_pll_refout_cc; -typedef boost::shared_ptr<gr_pll_refout_cc> gr_pll_refout_cc_sptr; - -GR_CORE_API gr_pll_refout_cc_sptr gr_make_pll_refout_cc (float loop_bw, - float max_freq, float min_freq); -/*! - * \brief Implements a PLL which locks to the input frequency and outputs a carrier - * \ingroup sync_blk - * - * input: stream of complex; output: stream of complex - * - * This PLL locks onto a [possibly noisy] reference carrier on - * the input and outputs a clean version which is phase and frequency - * aligned to it. - * - * All settings max_freq and min_freq are in terms of radians per sample, - * NOT HERTZ. The loop bandwidth determins the lock range and should be set - * around pi/200 -- 2pi/100. - * \sa gr_pll_freqdet_cf, gr_pll_carriertracking_cc - */ -class GR_CORE_API gr_pll_refout_cc : public gr_sync_block, public gri_control_loop -{ - friend GR_CORE_API gr_pll_refout_cc_sptr gr_make_pll_refout_cc (float loop_bw, - float max_freq, float min_freq); - - gr_pll_refout_cc (float loop_bw, float max_freq, float min_freq); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -private: - float mod_2pi (float in); - float phase_detector(gr_complex sample, float ref_phase); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_pll_refout_cc.i b/gnuradio-core/src/lib/general/gr_pll_refout_cc.i deleted file mode 100644 index 630c0444fa..0000000000 --- a/gnuradio-core/src/lib/general/gr_pll_refout_cc.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pll_refout_cc) - -gr_pll_refout_cc_sptr gr_make_pll_refout_cc (float loop_bw, - float max_freq, float min_freq); - -class gr_pll_refout_cc : public gr_sync_block, public gri_control_loop -{ - private: - gr_pll_refout_cc (float loop_bw, float max_freq, float min_freq); -}; diff --git a/gnuradio-core/src/lib/general/gr_pn_correlator_cc.cc b/gnuradio-core/src/lib/general/gr_pn_correlator_cc.cc deleted file mode 100644 index 818e48c34b..0000000000 --- a/gnuradio-core/src/lib/general/gr_pn_correlator_cc.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pn_correlator_cc.h> -#include <gr_io_signature.h> - -gr_pn_correlator_cc_sptr -gr_make_pn_correlator_cc(int degree, int mask, int seed) -{ - return gnuradio::get_initial_sptr(new gr_pn_correlator_cc(degree, mask, seed)); -} - -gr_pn_correlator_cc::gr_pn_correlator_cc(int degree, int mask, int seed) - : gr_sync_decimator ("pn_correlator_cc", - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - (unsigned int)((1ULL << degree)-1)) // PN code length -{ - d_len = (unsigned int)((1ULL << degree)-1); - if (mask == 0) - mask = gri_glfsr::glfsr_mask(degree); - d_reference = new gri_glfsr(mask, seed); - for (int i = 0; i < d_len; i++) // initialize to last value in sequence - d_pn = 2.0*d_reference->next_bit()-1.0; -} - -gr_pn_correlator_cc::~gr_pn_correlator_cc() -{ - delete d_reference; -} - -int -gr_pn_correlator_cc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - gr_complex sum; - - for (int i = 0; i < noutput_items; i++) { - sum = 0.0; - - for (int j = 0; j < d_len; j++) { - if (j != 0) // retard PN generator one sample per period - d_pn = 2.0*d_reference->next_bit()-1.0; // no conditionals - sum += *in++ * d_pn; - } - - *out++ = sum*gr_complex(1.0/d_len, 0.0); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_pn_correlator_cc.h b/gnuradio-core/src/lib/general/gr_pn_correlator_cc.h deleted file mode 100644 index 69bd2c502f..0000000000 --- a/gnuradio-core/src/lib/general/gr_pn_correlator_cc.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_PN_CORRELATOR_CC_H -#define INCLUDED_GR_PN_CORRELATOR_CC_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> -#include <gri_glfsr.h> - -class gr_pn_correlator_cc; -typedef boost::shared_ptr<gr_pn_correlator_cc> gr_pn_correlator_cc_sptr; - -GR_CORE_API gr_pn_correlator_cc_sptr -gr_make_pn_correlator_cc(int degree, int mask=0, int seed=1); -/*! - * \brief PN code sequential search correlator - * - * \ingroup sync_blk - * Receives complex baseband signal, outputs complex correlation against - * reference PN code, one sample per PN code period - */ - -class GR_CORE_API gr_pn_correlator_cc : public gr_sync_decimator -{ - friend GR_CORE_API gr_pn_correlator_cc_sptr gr_make_pn_correlator_cc(int degree, int mask, int seed); - - int d_len; - float d_pn; - gri_glfsr *d_reference; - - protected: - gr_pn_correlator_cc(int degree, int mask, int seed); - - public: - virtual int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - ~gr_pn_correlator_cc(); -}; - -#endif /* INCLUDED_GR_PN_CORRELATOR_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_pn_correlator_cc.i b/gnuradio-core/src/lib/general/gr_pn_correlator_cc.i deleted file mode 100644 index e992f33a7f..0000000000 --- a/gnuradio-core/src/lib/general/gr_pn_correlator_cc.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pn_correlator_cc) - -gr_pn_correlator_cc_sptr -gr_make_pn_correlator_cc(int degree, int mask=0, int seed=1); - -class gr_pn_correlator_cc : public gr_sync_decimator -{ - protected: - gr_pn_correlator_cc(); -}; diff --git a/gnuradio-core/src/lib/general/gr_prefs.cc b/gnuradio-core/src/lib/general/gr_prefs.cc index 9705eed4f7..5d9544f112 100644 --- a/gnuradio-core/src/lib/general/gr_prefs.cc +++ b/gnuradio-core/src/lib/general/gr_prefs.cc @@ -118,6 +118,19 @@ gr_prefs::_read_files() d_configs.erase(std::remove_if(d_configs.begin(), d_configs.end(), ::isspace), d_configs.end()); } +char * +gr_prefs::option_to_env(std::string section, std::string option) +{ + std::stringstream envname; + std::string secname=section, optname=option; + + std::transform(section.begin(), section.end(), secname.begin(), ::toupper); + std::transform(option.begin(), option.end(), optname.begin(), ::toupper); + envname << "GR_CONF_" << secname << "_" << optname; + + return getenv(envname.str().c_str()); +} + bool gr_prefs::has_section(const std::string §ion) { @@ -128,6 +141,9 @@ gr_prefs::has_section(const std::string §ion) bool gr_prefs::has_option(const std::string §ion, const std::string &option) { + if(option_to_env(section, option)) + return true; + if(has_section(section)) { size_t sec = d_configs.find("[" + section + "]#"); size_t opt = d_configs.find("#" + option + "=", sec); @@ -142,17 +158,9 @@ const std::string gr_prefs::get_string(const std::string §ion, const std::string &option, const std::string &default_val) { - std::stringstream envname; - std::string secname=section, optname=option; - - std::transform(section.begin(), section.end(), secname.begin(), ::toupper); - std::transform(option.begin(), option.end(), optname.begin(), ::toupper); - envname << "GR_CONF_" << secname << "_" << optname; - - char *v = getenv(envname.str().c_str()); - if(v) { - return std::string(v); - } + char *env = option_to_env(section, option); + if(env) + return std::string(env); if(has_option(section, option)) { std::string optname = "#" + option + "="; diff --git a/gnuradio-core/src/lib/general/gr_prefs.h b/gnuradio-core/src/lib/general/gr_prefs.h index dc2745d163..68957faab9 100644 --- a/gnuradio-core/src/lib/general/gr_prefs.h +++ b/gnuradio-core/src/lib/general/gr_prefs.h @@ -84,6 +84,7 @@ public: protected: virtual std::vector<std::string> _sys_prefs_filenames(); virtual void _read_files(); + virtual char * option_to_env(std::string section, std::string option); private: gruel::mutex d_mutex; diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.cc b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.cc deleted file mode 100644 index 6430d2753d..0000000000 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <gr_probe_avg_mag_sqrd_c.h> -#include <gr_io_signature.h> -#include <cmath> - -gr_probe_avg_mag_sqrd_c_sptr -gr_make_probe_avg_mag_sqrd_c(double threshold_db, double alpha) -{ - return gnuradio::get_initial_sptr(new gr_probe_avg_mag_sqrd_c(threshold_db, alpha)); -} - -gr_probe_avg_mag_sqrd_c::gr_probe_avg_mag_sqrd_c (double threshold_db, double alpha) - : gr_sync_block ("probe_avg_mag_sqrd_c", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(0, 0, 0)), - d_iir(alpha), d_unmuted(false), d_level(0) -{ - set_threshold (threshold_db); -} - -gr_probe_avg_mag_sqrd_c::~gr_probe_avg_mag_sqrd_c() -{ -} - - -int -gr_probe_avg_mag_sqrd_c::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - - for (int i = 0; i < noutput_items; i++){ - double mag_sqrd = in[i].real()*in[i].real() + in[i].imag()*in[i].imag(); - d_iir.filter(mag_sqrd); // computed for side effect: prev_output() - } - - d_unmuted = d_iir.prev_output() >= d_threshold; - d_level = d_iir.prev_output(); - return noutput_items; -} - -double -gr_probe_avg_mag_sqrd_c::threshold() const -{ - return 10 * std::log10(d_threshold); -} - -void -gr_probe_avg_mag_sqrd_c::set_threshold(double decibels) -{ - // convert to absolute threshold (mag squared) - d_threshold = std::pow(10.0, decibels/10); -} - -void -gr_probe_avg_mag_sqrd_c::set_alpha(double alpha) -{ - d_iir.set_taps(alpha); -} diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.h b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.h deleted file mode 100644 index 2811677cfc..0000000000 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_PROBE_AVG_MAG_SQRD_C_H -#define INCLUDED_GR_PROBE_AVG_MAG_SQRD_C_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_single_pole_iir.h> - -class gr_probe_avg_mag_sqrd_c; -typedef boost::shared_ptr<gr_probe_avg_mag_sqrd_c> gr_probe_avg_mag_sqrd_c_sptr; - -GR_CORE_API gr_probe_avg_mag_sqrd_c_sptr -gr_make_probe_avg_mag_sqrd_c (double threshold_db, double alpha = 0.0001); - -/*! - * \brief compute avg magnitude squared. - * \ingroup sink_blk - * - * input: gr_complex - * - * Compute a running average of the magnitude squared of the the input. - * The level and indication as to whether the level exceeds threshold - * can be retrieved with the level and unmuted accessors. - */ -class GR_CORE_API gr_probe_avg_mag_sqrd_c : public gr_sync_block -{ - double d_threshold; - gr_single_pole_iir<double,double,double> d_iir; - bool d_unmuted; - double d_level; - - friend GR_CORE_API gr_probe_avg_mag_sqrd_c_sptr - gr_make_probe_avg_mag_sqrd_c (double threshold_db, double alpha); - - gr_probe_avg_mag_sqrd_c (double threshold_db, double alpha); - -public: - ~gr_probe_avg_mag_sqrd_c (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - // ACCESSORS - bool unmuted () const { return d_unmuted; } - double level () const { return d_level; } - - double threshold() const; - - // SETTERS - void set_alpha (double alpha); - void set_threshold (double decibels); -}; - -#endif /* INCLUDED_GR_PROBE_AVG_MAG_SQRD_C_H */ diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.i b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.i deleted file mode 100644 index bce244c127..0000000000 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,probe_avg_mag_sqrd_c); - -gr_probe_avg_mag_sqrd_c_sptr -gr_make_probe_avg_mag_sqrd_c (double threshold_db, double alpha = 0.0001); - -class gr_probe_avg_mag_sqrd_c : public gr_sync_block -{ -public: - bool unmuted () const { return d_unmuted; } - double level () const { return d_level; } - void set_alpha (double alpha); - void set_threshold (double decibels); - double threshold(); -}; diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.cc b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.cc deleted file mode 100644 index b5946283b8..0000000000 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <gr_probe_avg_mag_sqrd_cf.h> -#include <gr_io_signature.h> -#include <cmath> - -gr_probe_avg_mag_sqrd_cf_sptr -gr_make_probe_avg_mag_sqrd_cf(double threshold_db, double alpha) -{ - return gnuradio::get_initial_sptr(new gr_probe_avg_mag_sqrd_cf(threshold_db, alpha)); -} - -gr_probe_avg_mag_sqrd_cf::gr_probe_avg_mag_sqrd_cf (double threshold_db, double alpha) - : gr_sync_block ("probe_avg_mag_sqrd_cf", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(1, 1, sizeof(float))), - d_iir(alpha), d_unmuted(false), d_level(0) -{ - set_threshold (threshold_db); -} - -gr_probe_avg_mag_sqrd_cf::~gr_probe_avg_mag_sqrd_cf() -{ -} - - -int -gr_probe_avg_mag_sqrd_cf::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - out[i] = d_iir.prev_output(); - double mag_sqrd = in[i].real()*in[i].real() + in[i].imag()*in[i].imag(); - d_iir.filter(mag_sqrd); // computed for side effect: prev_output() - } - - d_unmuted = d_iir.prev_output() >= d_threshold; - d_level = d_iir.prev_output(); - return noutput_items; -} - -double -gr_probe_avg_mag_sqrd_cf::threshold() const -{ - return 10 * std::log10(d_threshold); -} - -void -gr_probe_avg_mag_sqrd_cf::set_threshold(double decibels) -{ - // convert to absolute threshold (mag squared) - d_threshold = std::pow(10.0, decibels/10); -} - -void -gr_probe_avg_mag_sqrd_cf::set_alpha(double alpha) -{ - d_iir.set_taps(alpha); -} diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h deleted file mode 100644 index bb5d1ebf91..0000000000 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_PROBE_AVG_MAG_SQRD_CF_H -#define INCLUDED_GR_PROBE_AVG_MAG_SQRD_CF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_single_pole_iir.h> - -class gr_probe_avg_mag_sqrd_cf; -typedef boost::shared_ptr<gr_probe_avg_mag_sqrd_cf> gr_probe_avg_mag_sqrd_cf_sptr; - -GR_CORE_API gr_probe_avg_mag_sqrd_cf_sptr -gr_make_probe_avg_mag_sqrd_cf (double threshold_db, double alpha = 0.0001); - -/*! - * \brief compute avg magnitude squared. - * \ingroup sink_blk - * - * input: gr_complex - * output: gr_float - * - * Compute a running average of the magnitude squared of the the input. - * The level and indication as to whether the level exceeds threshold - * can be retrieved with the level and unmuted accessors. - * - */ -class GR_CORE_API gr_probe_avg_mag_sqrd_cf : public gr_sync_block -{ - double d_threshold; - gr_single_pole_iir<double,double,double> d_iir; - bool d_unmuted; - double d_level; - - friend GR_CORE_API gr_probe_avg_mag_sqrd_cf_sptr - gr_make_probe_avg_mag_sqrd_cf (double threshold_db, double alpha); - - gr_probe_avg_mag_sqrd_cf (double threshold_db, double alpha); - -public: - ~gr_probe_avg_mag_sqrd_cf (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - // ACCESSORS - bool unmuted () const { return d_unmuted; } - double level () const { return d_level; } - - double threshold() const; - - // SETTERS - void set_alpha (double alpha); - void set_threshold (double decibels); -}; - -#endif /* INCLUDED_GR_PROBE_AVG_MAG_SQRD_CF_H */ diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.i b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.i deleted file mode 100644 index bf76d973b7..0000000000 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,probe_avg_mag_sqrd_cf); - -gr_probe_avg_mag_sqrd_cf_sptr -gr_make_probe_avg_mag_sqrd_cf (double threshold_db, double alpha = 0.0001); - -class gr_probe_avg_mag_sqrd_cf : public gr_sync_block -{ -public: - bool unmuted () const { return d_unmuted; } - double level () const { return d_level; } - void set_alpha (double alpha); - void set_threshold (double decibels); - double threshold(); -}; diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.cc b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.cc deleted file mode 100644 index 4ed40743fc..0000000000 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <gr_probe_avg_mag_sqrd_f.h> -#include <gr_io_signature.h> -#include <cmath> - -gr_probe_avg_mag_sqrd_f_sptr -gr_make_probe_avg_mag_sqrd_f(double threshold_db, double alpha) -{ - return gnuradio::get_initial_sptr(new gr_probe_avg_mag_sqrd_f(threshold_db, alpha)); -} - -gr_probe_avg_mag_sqrd_f::gr_probe_avg_mag_sqrd_f (double threshold_db, double alpha) - : gr_sync_block ("probe_avg_mag_sqrd_f", - gr_make_io_signature(1, 1, sizeof(float)), - gr_make_io_signature(0, 0, 0)), - d_iir(alpha), d_unmuted(false), d_level(0) -{ - set_threshold (threshold_db); -} - -gr_probe_avg_mag_sqrd_f::~gr_probe_avg_mag_sqrd_f() -{ -} - - -int -gr_probe_avg_mag_sqrd_f::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - - for (int i = 0; i < noutput_items; i++){ - double mag_sqrd = in[i]*in[i]; - d_iir.filter(mag_sqrd); // computed for side effect: prev_output() - } - - d_unmuted = d_iir.prev_output() >= d_threshold; - d_level = d_iir.prev_output(); - return noutput_items; -} - -double -gr_probe_avg_mag_sqrd_f::threshold() const -{ - return 10 * std::log10(d_threshold); -} - -void -gr_probe_avg_mag_sqrd_f::set_threshold(double decibels) -{ - // convert to absolute threshold (mag sqrd) - d_threshold = std::pow(10.0, decibels/10); -} - -void -gr_probe_avg_mag_sqrd_f::set_alpha(double alpha) -{ - d_iir.set_taps(alpha); -} diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.h b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.h deleted file mode 100644 index b2efcc64eb..0000000000 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_PROBE_AVG_MAG_SQRD_F_H -#define INCLUDED_GR_PROBE_AVG_MAG_SQRD_F_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_single_pole_iir.h> - -class gr_probe_avg_mag_sqrd_f; -typedef boost::shared_ptr<gr_probe_avg_mag_sqrd_f> gr_probe_avg_mag_sqrd_f_sptr; - -GR_CORE_API gr_probe_avg_mag_sqrd_f_sptr -gr_make_probe_avg_mag_sqrd_f (double threshold_db, double alpha = 0.0001); - -/*! - * \brief compute avg magnitude squared. - * \ingroup sink_blk - * - * input: float - * - * Compute a running average of the magnitude squared of the the input. - * The level and indication as to whether the level exceeds threshold - * can be retrieved with the level and unmuted accessors. - */ -class GR_CORE_API gr_probe_avg_mag_sqrd_f : public gr_sync_block -{ - double d_threshold; - gr_single_pole_iir<double,double,double> d_iir; - bool d_unmuted; - double d_level; - - friend GR_CORE_API gr_probe_avg_mag_sqrd_f_sptr - gr_make_probe_avg_mag_sqrd_f (double threshold_db, double alpha); - - gr_probe_avg_mag_sqrd_f (double threshold_db, double alpha); - -public: - ~gr_probe_avg_mag_sqrd_f (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - // ACCESSORS - bool unmuted () const { return d_unmuted; } - double level () const { return d_level; } - - double threshold() const; - - // SETTERS - void set_alpha (double alpha); - void set_threshold (double decibels); -}; - -#endif /* INCLUDED_GR_PROBE_AVG_MAG_SQRD_F_H */ diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.i b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.i deleted file mode 100644 index 1c63ae8e9d..0000000000 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,probe_avg_mag_sqrd_f); - -gr_probe_avg_mag_sqrd_f_sptr -gr_make_probe_avg_mag_sqrd_f (double threshold_db, double alpha = 0.0001); - -class gr_probe_avg_mag_sqrd_f : public gr_sync_block -{ -public: - bool unmuted () const { return d_unmuted; } - double level () const { return d_level; } - double threshold() const; - void set_alpha (double alpha); - void set_threshold (double decibels); -}; diff --git a/gnuradio-core/src/lib/general/gr_probe_density_b.cc b/gnuradio-core/src/lib/general/gr_probe_density_b.cc deleted file mode 100644 index 31661780af..0000000000 --- a/gnuradio-core/src/lib/general/gr_probe_density_b.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_probe_density_b.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <iostream> - -gr_probe_density_b_sptr -gr_make_probe_density_b(double alpha) -{ - return gnuradio::get_initial_sptr(new gr_probe_density_b(alpha)); -} - -gr_probe_density_b::gr_probe_density_b(double alpha) - : gr_sync_block("density_b", - gr_make_io_signature(1, 1, sizeof(char)), - gr_make_io_signature(0, 0, 0)) -{ - set_alpha(alpha); - d_density = 1.0; -} - -gr_probe_density_b::~gr_probe_density_b() -{ -} - -int -gr_probe_density_b::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *in = (const char *)input_items[0]; - - for (int i = 0; i < noutput_items; i++) - d_density = d_alpha*(double)in[i] + d_beta*d_density; - - return noutput_items; -} - -void -gr_probe_density_b::set_alpha(double alpha) -{ - d_alpha = alpha; - d_beta = 1.0-d_alpha; -} - diff --git a/gnuradio-core/src/lib/general/gr_probe_density_b.h b/gnuradio-core/src/lib/general/gr_probe_density_b.h deleted file mode 100644 index ab84a63a96..0000000000 --- a/gnuradio-core/src/lib/general/gr_probe_density_b.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_PROBE_DENSITY_B_H -#define INCLUDED_GR_PROBE_DENSITY_B_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_probe_density_b; - -typedef boost::shared_ptr<gr_probe_density_b> gr_probe_density_b_sptr; - -GR_CORE_API gr_probe_density_b_sptr gr_make_probe_density_b(double alpha); - -/*! - * This block maintains a running average of the input stream and - * makes it available as an accessor function. The input stream - * is type unsigned char. - * - * If you send this block a stream of unpacked bytes, it will tell - * you what the bit density is. - * - * \param alpha Average filter constant - * - */ - -class GR_CORE_API gr_probe_density_b : public gr_sync_block -{ -private: - friend GR_CORE_API gr_probe_density_b_sptr gr_make_probe_density_b(double alpha); - - double d_alpha; - double d_beta; - double d_density; - - gr_probe_density_b(double alpha); - -public: - ~gr_probe_density_b(); - - /*! - * \brief Returns the current density value - */ - double density() const { return d_density; } - - /*! - * \brief Set the average filter constant - */ - void set_alpha(double alpha); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_PROBE_DENSITY_B_H */ diff --git a/gnuradio-core/src/lib/general/gr_probe_density_b.i b/gnuradio-core/src/lib/general/gr_probe_density_b.i deleted file mode 100644 index ca65708af6..0000000000 --- a/gnuradio-core/src/lib/general/gr_probe_density_b.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,probe_density_b); - -gr_probe_density_b_sptr gr_make_probe_density_b(double alpha); - -class gr_probe_density_b : public gr_sync_block -{ -public: - double density() const; - - void set_alpha(double alpha); - -private: - gr_probe_density_b(); -}; diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.cc b/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.cc deleted file mode 100644 index 90eab13eba..0000000000 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pwr_squelch_cc.h> - -gr_pwr_squelch_cc_sptr -gr_make_pwr_squelch_cc(double threshold, double alpha, int ramp, bool gate) -{ - return gnuradio::get_initial_sptr(new gr_pwr_squelch_cc(threshold, alpha, ramp, gate)); -} - -gr_pwr_squelch_cc::gr_pwr_squelch_cc(double threshold, double alpha, int ramp, bool gate) : - gr_squelch_base_cc("pwr_squelch_cc", ramp, gate), - d_iir(alpha) -{ - set_threshold(threshold); -} - -std::vector<float> gr_pwr_squelch_cc::squelch_range() const -{ - std::vector<float> r(3); - r[0] = -50.0; // min FIXME - r[1] = +50.0; // max FIXME - r[2] = (r[1] - r[0]) / 100; // step size - - return r; -} - -void gr_pwr_squelch_cc::update_state(const gr_complex &in) -{ - d_pwr = d_iir.filter(in.real()*in.real()+in.imag()*in.imag()); -} diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h b/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h deleted file mode 100644 index b2b4624f58..0000000000 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_PWR_SQUELCH_CC_H -#define INCLUDED_GR_PWR_SQUELCH_CC_H - -#include <gr_core_api.h> -#include <cmath> -#include <gr_squelch_base_cc.h> -#include <gr_single_pole_iir.h> - -class gr_pwr_squelch_cc; -typedef boost::shared_ptr<gr_pwr_squelch_cc> gr_pwr_squelch_cc_sptr; - -GR_CORE_API gr_pwr_squelch_cc_sptr -gr_make_pwr_squelch_cc(double db, double alpha = 0.0001, int ramp=0, bool gate=false); - -/*! - * \brief gate or zero output when input power below threshold - * \ingroup level_blk - */ -class GR_CORE_API gr_pwr_squelch_cc : public gr_squelch_base_cc -{ -private: - double d_threshold; - double d_pwr; - gr_single_pole_iir<double,double,double> d_iir; - - friend GR_CORE_API gr_pwr_squelch_cc_sptr gr_make_pwr_squelch_cc(double db, double alpha, int ramp, bool gate); - gr_pwr_squelch_cc(double db, double alpha, int ramp, bool gate); - -protected: - virtual void update_state(const gr_complex &in); - virtual bool mute() const { return d_pwr < d_threshold; } - -public: - std::vector<float> squelch_range() const; - - double threshold() const { return 10*log10(d_threshold); } - void set_threshold(double db) { d_threshold = std::pow(10.0, db/10); } - void set_alpha(double alpha) { d_iir.set_taps(alpha); } -}; - -#endif /* INCLUDED_GR_PWR_SQUELCH_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.i b/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.i deleted file mode 100644 index c8cafd7aac..0000000000 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pwr_squelch_cc); - -// retrieve info on the base class, without generating wrappers since -// the base class has a pure virual method. -%import "gr_squelch_base_cc.i" - -gr_pwr_squelch_cc_sptr -gr_make_pwr_squelch_cc(double db, double alpha=0.0001, int ramp=0, bool gate=false); - -class gr_pwr_squelch_cc : public gr_squelch_base_cc -{ -private: - gr_pwr_squelch_cc(double db, double alpha, int ramp, bool gate); - -public: - double threshold() const { return 10*log10(d_threshold); } - void set_threshold(double db) { d_threshold = std::pow(10.0, db/10); } - void set_alpha(double alpha) { d_iir.set_taps(alpha); } - std::vector<float> squelch_range() const; -}; diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.cc b/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.cc deleted file mode 100644 index cfa867243d..0000000000 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pwr_squelch_ff.h> - -gr_pwr_squelch_ff_sptr -gr_make_pwr_squelch_ff(double threshold, double alpha, int ramp, bool gate) -{ - return gnuradio::get_initial_sptr(new gr_pwr_squelch_ff(threshold, alpha, ramp, gate)); -} - -gr_pwr_squelch_ff::gr_pwr_squelch_ff(double threshold, double alpha, int ramp, bool gate) : - gr_squelch_base_ff("pwr_squelch_ff", ramp, gate), - d_iir(alpha) -{ - set_threshold(threshold); -} - -std::vector<float> gr_pwr_squelch_ff::squelch_range() const -{ - std::vector<float> r(3); - r[0] = -50.0; // min FIXME - r[1] = +50.0; // max FIXME - r[2] = (r[1] - r[0]) / 100; // step size - - return r; -} - -void gr_pwr_squelch_ff::update_state(const float &in) -{ - d_pwr = d_iir.filter(in*in); -} diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h b/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h deleted file mode 100644 index d5148c4096..0000000000 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_PWR_SQUELCH_FF_H -#define INCLUDED_GR_PWR_SQUELCH_FF_H - -#include <gr_core_api.h> -#include <cmath> -#include <gr_squelch_base_ff.h> -#include <gr_single_pole_iir.h> - -class gr_pwr_squelch_ff; -typedef boost::shared_ptr<gr_pwr_squelch_ff> gr_pwr_squelch_ff_sptr; - -GR_CORE_API gr_pwr_squelch_ff_sptr -gr_make_pwr_squelch_ff(double db, double alpha = 0.0001, int ramp=0, bool gate=false); - -/*! - * \brief gate or zero output when input power below threshold - * \ingroup level_blk - */ -class GR_CORE_API gr_pwr_squelch_ff : public gr_squelch_base_ff -{ -private: - double d_threshold; - double d_pwr; - gr_single_pole_iir<double,double,double> d_iir; - - friend GR_CORE_API gr_pwr_squelch_ff_sptr gr_make_pwr_squelch_ff(double db, double alpha, int ramp, bool gate); - gr_pwr_squelch_ff(double db, double alpha, int ramp, bool gate); - -protected: - virtual void update_state(const float &in); - virtual bool mute() const { return d_pwr < d_threshold; } - -public: - std::vector<float> squelch_range() const; - - double threshold() const { return 10*log10(d_threshold); } - void set_threshold(double db) { d_threshold = std::pow(10.0, db/10); } - void set_alpha(double alpha) { d_iir.set_taps(alpha); } -}; - -#endif /* INCLUDED_GR_PWR_SQUELCH_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.i b/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.i deleted file mode 100644 index 2682f27586..0000000000 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pwr_squelch_ff); - -// retrieve info on the base class, without generating wrappers since -// the base class has a pure virual method. -%import "gr_squelch_base_ff.i" - -gr_pwr_squelch_ff_sptr -gr_make_pwr_squelch_ff(double db, double alpha=0.0001, int ramp=0, bool gate=false); - -class gr_pwr_squelch_ff : public gr_squelch_base_ff -{ -private: - gr_pwr_squelch_ff(double db, double alpha, int ramp, bool gate); - -public: - double threshold() const { return 10*log10(d_threshold); } - void set_threshold(double db) { d_threshold = std::pow(10.0, db/10); } - void set_alpha(double alpha) { d_iir.set_taps(alpha); } - std::vector<float> squelch_range() const; -}; diff --git a/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.cc b/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.cc deleted file mode 100644 index fa09582762..0000000000 --- a/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_quadrature_demod_cf.h> -#include <gr_io_signature.h> -#include <gr_math.h> - -gr_quadrature_demod_cf::gr_quadrature_demod_cf (float gain) - : gr_sync_block ("quadrature_demod_cf", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (float))), - d_gain (gain) -{ - set_history (2); // we need to look at the previous value -} - -gr_quadrature_demod_cf_sptr -gr_make_quadrature_demod_cf (float gain) -{ - return gnuradio::get_initial_sptr(new gr_quadrature_demod_cf (gain)); -} - -int -gr_quadrature_demod_cf::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; - in++; // ensure that in[-1] is valid - - for (int i = 0; i < noutput_items; i++){ - gr_complex product = in[i] * conj (in[i-1]); - // out[i] = d_gain * arg (product); - out[i] = d_gain * gr_fast_atan2f(imag(product), real(product)); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.h b/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.h deleted file mode 100644 index 9f5976c971..0000000000 --- a/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_QUADRATURE_DEMOD_CF_H -#define INCLUDED_GR_QUADRATURE_DEMOD_CF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_quadrature_demod_cf; -typedef boost::shared_ptr<gr_quadrature_demod_cf> gr_quadrature_demod_cf_sptr; -GR_CORE_API gr_quadrature_demod_cf_sptr gr_make_quadrature_demod_cf (float gain); - -/*! - * \brief quadrature demodulator: complex in, float out - * \ingroup demodulation_blk - * - * This can be used to demod FM, FSK, GMSK, etc. - * The input is complex baseband. - */ -class GR_CORE_API gr_quadrature_demod_cf : public gr_sync_block -{ - friend GR_CORE_API gr_quadrature_demod_cf_sptr gr_make_quadrature_demod_cf (float gain); - gr_quadrature_demod_cf (float gain); - - float d_gain; - - public: - void set_gain(float gain) { d_gain = gain; } - float gain() const { return d_gain; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_QUADRATURE_DEMOD_CF_H */ diff --git a/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.i b/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.i deleted file mode 100644 index 4c9168e647..0000000000 --- a/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC (gr, quadrature_demod_cf) - -gr_quadrature_demod_cf_sptr gr_make_quadrature_demod_cf (float gain); - -class gr_quadrature_demod_cf : public gr_sync_block -{ - gr_quadrature_demod_cf (float gain); - -public: - void set_gain(float gain) { d_gain = gain; } - float gain() const { return d_gain; } -}; diff --git a/gnuradio-core/src/lib/general/gr_rail_ff.cc b/gnuradio-core/src/lib/general/gr_rail_ff.cc deleted file mode 100644 index cd33c10d39..0000000000 --- a/gnuradio-core/src/lib/general/gr_rail_ff.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_rail_ff.h> -#include <gr_io_signature.h> - -gr_rail_ff_sptr -gr_make_rail_ff(float lo, float hi) -{ - return gnuradio::get_initial_sptr(new gr_rail_ff(lo, hi)); -} - -gr_rail_ff::gr_rail_ff(float lo, float hi) - : gr_sync_block("rail_ff", - gr_make_io_signature(1, 1, sizeof(float)), - gr_make_io_signature(1, 1, sizeof(float))), - d_lo(lo), d_hi(hi) -{ -} - -int -gr_rail_ff::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - for (int i = 0; i < noutput_items; i++) { - if (in[i] < d_lo) - out[i] = d_lo; - else if (in[i] > d_hi) - out[i] = d_hi; - else - out[i] = in[i]; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_rail_ff.h b/gnuradio-core/src/lib/general/gr_rail_ff.h deleted file mode 100644 index 29db5b1fa1..0000000000 --- a/gnuradio-core/src/lib/general/gr_rail_ff.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_RAIL_FF_H_ -# define INCLUDED_GR_RAIL_FF_H_ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -/*! - * \brief clips input values to min, max - * \ingroup misc - */ - -class gr_rail_ff; -typedef boost::shared_ptr<gr_rail_ff> gr_rail_ff_sptr; - -GR_CORE_API gr_rail_ff_sptr gr_make_rail_ff(float lo, float hi); - -class GR_CORE_API gr_rail_ff : public gr_sync_block -{ - friend GR_CORE_API gr_rail_ff_sptr gr_make_rail_ff (float lo, float hi); - - float d_lo, d_hi; // the constant - gr_rail_ff(float lo, float hi); - - public: - float lo() const { return d_lo; } - void set_lo(float lo) { d_lo = lo; } - float hi() const { return d_hi; } - void set_hi(float hi) { d_hi = hi; } - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_rail_ff.i b/gnuradio-core/src/lib/general/gr_rail_ff.i deleted file mode 100644 index bdc453516e..0000000000 --- a/gnuradio-core/src/lib/general/gr_rail_ff.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,rail_ff); - -gr_rail_ff_sptr gr_make_rail_ff(float lo, float hi); - -class gr_rail_ff : public gr_sync_block -{ -private: - gr_rail_ff(float lo, float hi); -}; diff --git a/gnuradio-core/src/lib/general/gr_random_pdu.cc b/gnuradio-core/src/lib/general/gr_random_pdu.cc deleted file mode 100644 index 6d8c13614a..0000000000 --- a/gnuradio-core/src/lib/general/gr_random_pdu.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_random_pdu.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> -#include <iostream> -#include <vector> - -// public constructor that returns a shared_ptr - -gr_random_pdu_sptr -gr_make_random_pdu (int items_min, int items_max) -{ - return gnuradio::get_initial_sptr(new gr_random_pdu(items_min, items_max)); -} - -gr_random_pdu::gr_random_pdu (int items_min, int items_max) - : gr_block("random_pdu", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(0, 0, 0)), - urange(items_min, items_max), - brange(0, 255), - rvar(rng, urange), - bvar(rng, brange) -{ - message_port_register_out(pmt::mp("pdus")); - message_port_register_in(pmt::mp("generate")); - set_msg_handler(pmt::mp("generate"), boost::bind(&gr_random_pdu::generate_pdu, this, _1)); -} - -bool gr_random_pdu::start(){ - output_random(); - return true; -} - -void gr_random_pdu::output_random(){ - - // pick a random vector length - int len = rvar(); - - // fill it with random bytes - std::vector<unsigned char> vec; - for(int i=0; i<len; i++){ - vec.push_back((unsigned char) bvar()); - } - - // send the vector - pmt::pmt_t vecpmt( pmt::pmt_make_blob( &vec[0], len ) ); - pmt::pmt_t pdu( pmt::pmt_cons( pmt::PMT_NIL, vecpmt ) ); - message_port_pub( pmt::mp("pdus"), pdu ); - - std::cout << "sending new random vector of length " << len << "\n"; -} - diff --git a/gnuradio-core/src/lib/general/gr_random_pdu.h b/gnuradio-core/src/lib/general/gr_random_pdu.h deleted file mode 100644 index e6457d21b6..0000000000 --- a/gnuradio-core/src/lib/general/gr_random_pdu.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_RANDOM_PDU_H -#define INCLUDED_GR_RANDOM_PDU_H - -#include <gr_core_api.h> -#include <gr_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> - -#include <boost/random.hpp> -#include <boost/generator_iterator.hpp> - -class gr_random_pdu; -typedef boost::shared_ptr<gr_random_pdu> gr_random_pdu_sptr; - -GR_CORE_API gr_random_pdu_sptr gr_make_random_pdu (int mintime, int maxtime); - -/*! - * \brief Send message at defined interval - * \ingroup msg_blk - */ -class GR_CORE_API gr_random_pdu : public gr_block -{ - private: - friend GR_CORE_API gr_random_pdu_sptr - gr_make_random_pdu(int mintime, int maxtime); - - void output_random(); - - boost::mt19937 rng; - boost::uniform_int<> urange; - boost::uniform_int<> brange; - boost::variate_generator< boost::mt19937, boost::uniform_int<> > rvar; // pdu length - boost::variate_generator< boost::mt19937, boost::uniform_int<> > bvar; // pdu contents - - public: - gr_random_pdu (int, int); - bool start(); - void generate_pdu(pmt::pmt_t msg){ output_random(); } - void generate_pdu(){ output_random(); } -}; - -#endif /* INCLUDED_GR_RANDOM_PDU_H */ diff --git a/gnuradio-core/src/lib/general/gr_random_pdu.i b/gnuradio-core/src/lib/general/gr_random_pdu.i deleted file mode 100644 index 045a330605..0000000000 --- a/gnuradio-core/src/lib/general/gr_random_pdu.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,random_pdu); - -%{ -#include <gr_random_pdu.h> -%} - -%include "gr_random_pdu.h" - diff --git a/gnuradio-core/src/lib/general/gr_regenerate_bb.cc b/gnuradio-core/src/lib/general/gr_regenerate_bb.cc deleted file mode 100644 index c96cf247d0..0000000000 --- a/gnuradio-core/src/lib/general/gr_regenerate_bb.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_regenerate_bb.h> -#include <gr_io_signature.h> - -gr_regenerate_bb_sptr -gr_make_regenerate_bb (int period, unsigned int max_regen) -{ - return gnuradio::get_initial_sptr(new gr_regenerate_bb (period, max_regen)); -} - -gr_regenerate_bb::gr_regenerate_bb (int period, unsigned int max_regen) - : gr_sync_block ("regenerate_bb", - gr_make_io_signature (1, 1, sizeof (char)), - gr_make_io_signature (1, 1, sizeof (char))), - d_period(period), - d_countdown(0), - d_max_regen(max_regen), - d_regen_count(max_regen) -{ -} - -void gr_regenerate_bb::set_max_regen(unsigned int regen) -{ - d_max_regen = regen; - d_countdown = 0; - d_regen_count = d_max_regen; -} - -void gr_regenerate_bb::set_period(int period) -{ - d_period = period; - d_countdown = 0; - d_regen_count = d_max_regen; -} - -int -gr_regenerate_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *iptr = (const char *) input_items[0]; - char *optr = (char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - optr[i] = 0; - - if(d_regen_count < d_max_regen) { - d_countdown--; - - if(d_countdown == 0) { - optr[i] = 1; - d_countdown = d_period; - d_regen_count++; - } - } - - if(iptr[i] == 1) { - d_countdown = d_period; - optr[i] = 1; - d_regen_count = 0; - } - - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_regenerate_bb.h b/gnuradio-core/src/lib/general/gr_regenerate_bb.h deleted file mode 100644 index e820db69e8..0000000000 --- a/gnuradio-core/src/lib/general/gr_regenerate_bb.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_REGENERATE_BB_H -#define INCLUDED_GR_REGENERATE_BB_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_regenerate_bb; -typedef boost::shared_ptr<gr_regenerate_bb> gr_regenerate_bb_sptr; - -GR_CORE_API gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen=500); - -/*! - * \brief Detect the peak of a signal and repeat every period samples - * \ingroup level_blk - * - * If a peak is detected, this block outputs a 1 repeated every period samples - * until reset by detection of another 1 on the input or stopped after max_regen - * regenerations have occurred. - * - * Note that if max_regen=(-1)/ULONG_MAX then the regeneration will run forever. - */ -class GR_CORE_API gr_regenerate_bb : public gr_sync_block -{ - /*! - * \brief Make a regenerate block - * \param period The number of samples between regenerations - * \param max_regen The maximum number of regenerations to perform; if set to - * ULONG_MAX, it will regenerate continuously. - */ - friend GR_CORE_API gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen); - - gr_regenerate_bb (int period, unsigned int max_regen); - - private: - int d_period; - int d_countdown; - unsigned int d_max_regen; - unsigned int d_regen_count; - - public: - /*! \brief Reset the maximum regeneration count; this will reset the current regen. - */ - void set_max_regen(unsigned int regen); - - /*! \brief Reset the period of regenerations; this will reset the current regen. - */ - void set_period(int period); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_regenerate_bb.i b/gnuradio-core/src/lib/general/gr_regenerate_bb.i deleted file mode 100644 index 064b0a2789..0000000000 --- a/gnuradio-core/src/lib/general/gr_regenerate_bb.i +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,regenerate_bb) - -gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen=500); - -class gr_regenerate_bb : public gr_sync_block -{ - private: - gr_regenerate_bb (int period, unsigned int max_regen); - -public: - void set_max_regen(unsigned int regen); - - /*! \brief Reset the period of regenerations; this will reset the current regen. - */ - void set_period(int period); -}; diff --git a/gnuradio-core/src/lib/general/gr_remez.cc b/gnuradio-core/src/lib/general/gr_remez.cc deleted file mode 100644 index db4789e439..0000000000 --- a/gnuradio-core/src/lib/general/gr_remez.cc +++ /dev/null @@ -1,1033 +0,0 @@ -/************************************************************************** - * Parks-McClellan algorithm for FIR filter design (C version) - *------------------------------------------------- - * Copyright (c) 1995,1998 Jake Janovetz (janovetz@uiuc.edu) - * Copyright (c) 2004 Free Software Foundation, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301 USA - * - * - * Sep 1999 - Paul Kienzle (pkienzle@cs.indiana.edu) - * Modified for use in octave as a replacement for the matlab function - * remez.mex. In particular, magnitude responses are required for all - * band edges rather than one per band, griddensity is a parameter, - * and errors are returned rather than printed directly. - * Mar 2000 - Kai Habel (kahacjde@linux.zrz.tu-berlin.de) - * Change: ColumnVector x=arg(i).vector_value(); - * to: ColumnVector x(arg(i).vector_value()); - * There appear to be some problems with the routine Search. See comments - * therein [search for PAK:]. I haven't looked closely at the rest - * of the code---it may also have some problems. - *************************************************************************/ - -/* - * This code was extracted from octave.sf.net, and wrapped with - * GNU Radio glue. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <gr_remez.h> -#include <cmath> -#include <assert.h> -#include <iostream> - - -#ifndef LOCAL_BUFFER -#include <vector> -#define LOCAL_BUFFER(T, buf, size) \ - std::vector<T> buf ## _vector (size); \ - T *buf = &(buf ## _vector[0]) -#endif - - -#define CONST const -#define BANDPASS 1 -#define DIFFERENTIATOR 2 -#define HILBERT 3 - -#define NEGATIVE 0 -#define POSITIVE 1 - -#define Pi 3.14159265358979323846 -#define Pi2 (2*Pi) - -#define GRIDDENSITY 16 -#define MAXITERATIONS 40 - -/******************* - * CreateDenseGrid - *================= - * Creates the dense grid of frequencies from the specified bands. - * Also creates the Desired Frequency Response function (D[]) and - * the Weight function (W[]) on that dense grid - * - * - * INPUT: - * ------ - * int r - 1/2 the number of filter coefficients - * int numtaps - Number of taps in the resulting filter - * int numband - Number of bands in user specification - * double bands[] - User-specified band edges [2*numband] - * double des[] - Desired response per band [2*numband] - * double weight[] - Weight per band [numband] - * int symmetry - Symmetry of filter - used for grid check - * int griddensity - * - * OUTPUT: - * ------- - * int gridsize - Number of elements in the dense frequency grid - * double Grid[] - Frequencies (0 to 0.5) on the dense grid [gridsize] - * double D[] - Desired response on the dense grid [gridsize] - * double W[] - Weight function on the dense grid [gridsize] - *******************/ - -static void -CreateDenseGrid (int r, int numtaps, int numband, const double bands[], - const double des[], const double weight[], int gridsize, - double Grid[], double D[], double W[], - int symmetry, int griddensity) -{ - int i, j, k, band; - double delf, lowf, highf, grid0; - - delf = 0.5/(griddensity*r); - -/* - * For differentiator, hilbert, - * symmetry is odd and Grid[0] = max(delf, bands[0]) - */ - grid0 = (symmetry == NEGATIVE) && (delf > bands[0]) ? delf : bands[0]; - - j=0; - for (band=0; band < numband; band++) - { - lowf = (band==0 ? grid0 : bands[2*band]); - highf = bands[2*band + 1]; - k = (int)((highf - lowf)/delf + 0.5); /* .5 for rounding */ - for (i=0; i<k; i++) - { - D[j] = des[2*band] + i*(des[2*band+1]-des[2*band])/(k-1); - W[j] = weight[band]; - Grid[j] = lowf; - lowf += delf; - j++; - } - Grid[j-1] = highf; - } - -/* - * Similar to above, if odd symmetry, last grid point can't be .5 - * - but, if there are even taps, leave the last grid point at .5 - */ - if ((symmetry == NEGATIVE) && - (Grid[gridsize-1] > (0.5 - delf)) && - (numtaps % 2)) - { - Grid[gridsize-1] = 0.5-delf; - } -} - - -/******************** - * InitialGuess - *============== - * Places Extremal Frequencies evenly throughout the dense grid. - * - * - * INPUT: - * ------ - * int r - 1/2 the number of filter coefficients - * int gridsize - Number of elements in the dense frequency grid - * - * OUTPUT: - * ------- - * int Ext[] - Extremal indexes to dense frequency grid [r+1] - ********************/ - -static void -InitialGuess (int r, int Ext[], int gridsize) -{ - int i; - - for (i=0; i<=r; i++) - Ext[i] = i * (gridsize-1) / r; -} - - -/*********************** - * CalcParms - *=========== - * - * - * INPUT: - * ------ - * int r - 1/2 the number of filter coefficients - * int Ext[] - Extremal indexes to dense frequency grid [r+1] - * double Grid[] - Frequencies (0 to 0.5) on the dense grid [gridsize] - * double D[] - Desired response on the dense grid [gridsize] - * double W[] - Weight function on the dense grid [gridsize] - * - * OUTPUT: - * ------- - * double ad[] - 'b' in Oppenheim & Schafer [r+1] - * double x[] - [r+1] - * double y[] - 'C' in Oppenheim & Schafer [r+1] - ***********************/ - -static void -CalcParms (int r, int Ext[], double Grid[], double D[], double W[], - double ad[], double x[], double y[]) -{ - int i, j, k, ld; - double sign, xi, delta, denom, numer; - -/* - * Find x[] - */ - for (i=0; i<=r; i++) - x[i] = cos(Pi2 * Grid[Ext[i]]); - -/* - * Calculate ad[] - Oppenheim & Schafer eq 7.132 - */ - ld = (r-1)/15 + 1; /* Skips around to avoid round errors */ - for (i=0; i<=r; i++) - { - denom = 1.0; - xi = x[i]; - for (j=0; j<ld; j++) - { - for (k=j; k<=r; k+=ld) - if (k != i) - denom *= 2.0*(xi - x[k]); - } - if (fabs(denom)<0.00001) - denom = 0.00001; - ad[i] = 1.0/denom; - } - -/* - * Calculate delta - Oppenheim & Schafer eq 7.131 - */ - numer = denom = 0; - sign = 1; - for (i=0; i<=r; i++) - { - numer += ad[i] * D[Ext[i]]; - denom += sign * ad[i]/W[Ext[i]]; - sign = -sign; - } - delta = numer/denom; - sign = 1; - -/* - * Calculate y[] - Oppenheim & Schafer eq 7.133b - */ - for (i=0; i<=r; i++) - { - y[i] = D[Ext[i]] - sign * delta/W[Ext[i]]; - sign = -sign; - } -} - - -/********************* - * ComputeA - *========== - * Using values calculated in CalcParms, ComputeA calculates the - * actual filter response at a given frequency (freq). Uses - * eq 7.133a from Oppenheim & Schafer. - * - * - * INPUT: - * ------ - * double freq - Frequency (0 to 0.5) at which to calculate A - * int r - 1/2 the number of filter coefficients - * double ad[] - 'b' in Oppenheim & Schafer [r+1] - * double x[] - [r+1] - * double y[] - 'C' in Oppenheim & Schafer [r+1] - * - * OUTPUT: - * ------- - * Returns double value of A[freq] - *********************/ - -static double -ComputeA (double freq, int r, double ad[], double x[], double y[]) -{ - int i; - double xc, c, denom, numer; - - denom = numer = 0; - xc = cos(Pi2 * freq); - for (i=0; i<=r; i++) - { - c = xc - x[i]; - if (fabs(c) < 1.0e-7) - { - numer = y[i]; - denom = 1; - break; - } - c = ad[i]/c; - denom += c; - numer += c*y[i]; - } - return numer/denom; -} - - -/************************ - * CalcError - *=========== - * Calculates the Error function from the desired frequency response - * on the dense grid (D[]), the weight function on the dense grid (W[]), - * and the present response calculation (A[]) - * - * - * INPUT: - * ------ - * int r - 1/2 the number of filter coefficients - * double ad[] - [r+1] - * double x[] - [r+1] - * double y[] - [r+1] - * int gridsize - Number of elements in the dense frequency grid - * double Grid[] - Frequencies on the dense grid [gridsize] - * double D[] - Desired response on the dense grid [gridsize] - * double W[] - Weight function on the desnse grid [gridsize] - * - * OUTPUT: - * ------- - * double E[] - Error function on dense grid [gridsize] - ************************/ - -static void -CalcError (int r, double ad[], double x[], double y[], - int gridsize, double Grid[], - double D[], double W[], double E[]) -{ - int i; - double A; - - for (i=0; i<gridsize; i++) - { - A = ComputeA(Grid[i], r, ad, x, y); - E[i] = W[i] * (D[i] - A); - } -} - -/************************ - * Search - *======== - * Searches for the maxima/minima of the error curve. If more than - * r+1 extrema are found, it uses the following heuristic (thanks - * Chris Hanson): - * 1) Adjacent non-alternating extrema deleted first. - * 2) If there are more than one excess extrema, delete the - * one with the smallest error. This will create a non-alternation - * condition that is fixed by 1). - * 3) If there is exactly one excess extremum, delete the smaller - * of the first/last extremum - * - * - * INPUT: - * ------ - * int r - 1/2 the number of filter coefficients - * int Ext[] - Indexes to Grid[] of extremal frequencies [r+1] - * int gridsize - Number of elements in the dense frequency grid - * double E[] - Array of error values. [gridsize] - * OUTPUT: - * ------- - * int Ext[] - New indexes to extremal frequencies [r+1] - ************************/ -static int -Search (int r, int Ext[], - int gridsize, double E[]) -{ - int i, j, k, l, extra; /* Counters */ - int up, alt; - int *foundExt; /* Array of found extremals */ - -/* - * Allocate enough space for found extremals. - */ - foundExt = (int *)malloc((2*r) * sizeof(int)); - k = 0; - -/* - * Check for extremum at 0. - */ - if (((E[0]>0.0) && (E[0]>E[1])) || - ((E[0]<0.0) && (E[0]<E[1]))) - foundExt[k++] = 0; - -/* - * Check for extrema inside dense grid - */ - for (i=1; i<gridsize-1; i++) - { - if (((E[i]>=E[i-1]) && (E[i]>E[i+1]) && (E[i]>0.0)) || - ((E[i]<=E[i-1]) && (E[i]<E[i+1]) && (E[i]<0.0))) { - // PAK: we sometimes get too many extremal frequencies - if (k >= 2*r) return -3; - foundExt[k++] = i; - } - } - -/* - * Check for extremum at 0.5 - */ - j = gridsize-1; - if (((E[j]>0.0) && (E[j]>E[j-1])) || - ((E[j]<0.0) && (E[j]<E[j-1]))) { - if (k >= 2*r) return -3; - foundExt[k++] = j; - } - - // PAK: we sometimes get not enough extremal frequencies - if (k < r+1) return -2; - - -/* - * Remove extra extremals - */ - extra = k - (r+1); - assert(extra >= 0); - - while (extra > 0) - { - if (E[foundExt[0]] > 0.0) - up = 1; /* first one is a maxima */ - else - up = 0; /* first one is a minima */ - - l=0; - alt = 1; - for (j=1; j<k; j++) - { - if (fabs(E[foundExt[j]]) < fabs(E[foundExt[l]])) - l = j; /* new smallest error. */ - if ((up) && (E[foundExt[j]] < 0.0)) - up = 0; /* switch to a minima */ - else if ((!up) && (E[foundExt[j]] > 0.0)) - up = 1; /* switch to a maxima */ - else - { - alt = 0; - // PAK: break now and you will delete the smallest overall - // extremal. If you want to delete the smallest of the - // pair of non-alternating extremals, then you must do: - // - // if (fabs(E[foundExt[j]]) < fabs(E[foundExt[j-1]])) l=j; - // else l=j-1; - break; /* Ooops, found two non-alternating */ - } /* extrema. Delete smallest of them */ - } /* if the loop finishes, all extrema are alternating */ - -/* - * If there's only one extremal and all are alternating, - * delete the smallest of the first/last extremals. - */ - if ((alt) && (extra == 1)) - { - if (fabs(E[foundExt[k-1]]) < fabs(E[foundExt[0]])) - /* Delete last extremal */ - l = k-1; - // PAK: changed from l = foundExt[k-1]; - else - /* Delete first extremal */ - l = 0; - // PAK: changed from l = foundExt[0]; - } - - for (j=l; j<k-1; j++) /* Loop that does the deletion */ - { - foundExt[j] = foundExt[j+1]; - assert(foundExt[j]<gridsize); - } - k--; - extra--; - } - - for (i=0; i<=r; i++) - { - assert(foundExt[i]<gridsize); - Ext[i] = foundExt[i]; /* Copy found extremals to Ext[] */ - } - - free(foundExt); - return 0; -} - - -/********************* - * FreqSample - *============ - * Simple frequency sampling algorithm to determine the impulse - * response h[] from A's found in ComputeA - * - * - * INPUT: - * ------ - * int N - Number of filter coefficients - * double A[] - Sample points of desired response [N/2] - * int symmetry - Symmetry of desired filter - * - * OUTPUT: - * ------- - * double h[] - Impulse Response of final filter [N] - *********************/ -static void -FreqSample (int N, double A[], double h[], int symm) -{ - int n, k; - double x, val, M; - - M = (N-1.0)/2.0; - if (symm == POSITIVE) - { - if (N%2) - { - for (n=0; n<N; n++) - { - val = A[0]; - x = Pi2 * (n - M)/N; - for (k=1; k<=M; k++) - val += 2.0 * A[k] * cos(x*k); - h[n] = val/N; - } - } - else - { - for (n=0; n<N; n++) - { - val = A[0]; - x = Pi2 * (n - M)/N; - for (k=1; k<=(N/2-1); k++) - val += 2.0 * A[k] * cos(x*k); - h[n] = val/N; - } - } - } - else - { - if (N%2) - { - for (n=0; n<N; n++) - { - val = 0; - x = Pi2 * (n - M)/N; - for (k=1; k<=M; k++) - val += 2.0 * A[k] * sin(x*k); - h[n] = val/N; - } - } - else - { - for (n=0; n<N; n++) - { - val = A[N/2] * sin(Pi * (n - M)); - x = Pi2 * (n - M)/N; - for (k=1; k<=(N/2-1); k++) - val += 2.0 * A[k] * sin(x*k); - h[n] = val/N; - } - } - } -} - -/******************* - * isDone - *======== - * Checks to see if the error function is small enough to consider - * the result to have converged. - * - * INPUT: - * ------ - * int r - 1/2 the number of filter coeffiecients - * int Ext[] - Indexes to extremal frequencies [r+1] - * double E[] - Error function on the dense grid [gridsize] - * - * OUTPUT: - * ------- - * Returns 1 if the result converged - * Returns 0 if the result has not converged - ********************/ - -static bool -isDone (int r, int Ext[], double E[]) -{ - int i; - double min, max, current; - - min = max = fabs(E[Ext[0]]); - for (i=1; i<=r; i++) - { - current = fabs(E[Ext[i]]); - if (current < min) - min = current; - if (current > max) - max = current; - } - return (((max-min)/max) < 0.0001); -} - -/******************** - * remez - *======= - * Calculates the optimal (in the Chebyshev/minimax sense) - * FIR filter impulse response given a set of band edges, - * the desired reponse on those bands, and the weight given to - * the error in those bands. - * - * INPUT: - * ------ - * int numtaps - Number of filter coefficients - * int numband - Number of bands in filter specification - * double bands[] - User-specified band edges [2 * numband] - * double des[] - User-specified band responses [2 * numband] - * double weight[] - User-specified error weights [numband] - * int type - Type of filter - * - * OUTPUT: - * ------- - * double h[] - Impulse response of final filter [numtaps] - * returns - true on success, false on failure to converge - ********************/ - -static int -remez (double h[], int numtaps, - int numband, const double bands[], - const double des[], const double weight[], - int type, int griddensity) -{ - double *Grid, *W, *D, *E; - int i, iter, gridsize, r, *Ext; - double *taps, c; - double *x, *y, *ad; - int symmetry; - - if (type == BANDPASS) - symmetry = POSITIVE; - else - symmetry = NEGATIVE; - - r = numtaps/2; /* number of extrema */ - if ((numtaps%2) && (symmetry == POSITIVE)) - r++; - -/* - * Predict dense grid size in advance for memory allocation - * .5 is so we round up, not truncate - */ - gridsize = 0; - for (i=0; i<numband; i++) - { - gridsize += (int)(2*r*griddensity*(bands[2*i+1] - bands[2*i]) + .5); - } - if (symmetry == NEGATIVE) - { - gridsize--; - } - -/* - * Dynamically allocate memory for arrays with proper sizes - */ - Grid = (double *)malloc(gridsize * sizeof(double)); - D = (double *)malloc(gridsize * sizeof(double)); - W = (double *)malloc(gridsize * sizeof(double)); - E = (double *)malloc(gridsize * sizeof(double)); - Ext = (int *)malloc((r+1) * sizeof(int)); - taps = (double *)malloc((r+1) * sizeof(double)); - x = (double *)malloc((r+1) * sizeof(double)); - y = (double *)malloc((r+1) * sizeof(double)); - ad = (double *)malloc((r+1) * sizeof(double)); - -/* - * Create dense frequency grid - */ - CreateDenseGrid(r, numtaps, numband, bands, des, weight, - gridsize, Grid, D, W, symmetry, griddensity); - InitialGuess(r, Ext, gridsize); - -/* - * For Differentiator: (fix grid) - */ - if (type == DIFFERENTIATOR) - { - for (i=0; i<gridsize; i++) - { -/* D[i] = D[i]*Grid[i]; */ - if (D[i] > 0.0001) - W[i] = W[i]/Grid[i]; - } - } - -/* - * For odd or Negative symmetry filters, alter the - * D[] and W[] according to Parks McClellan - */ - if (symmetry == POSITIVE) - { - if (numtaps % 2 == 0) - { - for (i=0; i<gridsize; i++) - { - c = cos(Pi * Grid[i]); - D[i] /= c; - W[i] *= c; - } - } - } - else - { - if (numtaps % 2) - { - for (i=0; i<gridsize; i++) - { - c = sin(Pi2 * Grid[i]); - D[i] /= c; - W[i] *= c; - } - } - else - { - for (i=0; i<gridsize; i++) - { - c = sin(Pi * Grid[i]); - D[i] /= c; - W[i] *= c; - } - } - } - -/* - * Perform the Remez Exchange algorithm - */ - for (iter=0; iter<MAXITERATIONS; iter++) - { - CalcParms(r, Ext, Grid, D, W, ad, x, y); - CalcError(r, ad, x, y, gridsize, Grid, D, W, E); - int err = Search(r, Ext, gridsize, E); - if (err) return err; - for(int i=0; i <= r; i++) assert(Ext[i]<gridsize); - if (isDone(r, Ext, E)) - break; - } - - CalcParms(r, Ext, Grid, D, W, ad, x, y); - -/* - * Find the 'taps' of the filter for use with Frequency - * Sampling. If odd or Negative symmetry, fix the taps - * according to Parks McClellan - */ - for (i=0; i<=numtaps/2; i++) - { - if (symmetry == POSITIVE) - { - if (numtaps%2) - c = 1; - else - c = cos(Pi * (double)i/numtaps); - } - else - { - if (numtaps%2) - c = sin(Pi2 * (double)i/numtaps); - else - c = sin(Pi * (double)i/numtaps); - } - taps[i] = ComputeA((double)i/numtaps, r, ad, x, y)*c; - } - -/* - * Frequency sampling design with calculated taps - */ - FreqSample(numtaps, taps, h, symmetry); - -/* - * Delete allocated memory - */ - free(Grid); - free(W); - free(D); - free(E); - free(Ext); - free(x); - free(y); - free(ad); - return iter<MAXITERATIONS?0:-1; -} - -////////////////////////////////////////////////////////////////////////////// -// -// GNU Radio interface -// -////////////////////////////////////////////////////////////////////////////// - - -static void -punt (const std::string msg) -{ - std::cerr << msg << '\n'; - throw std::runtime_error (msg); -} - -std::vector<double> -gr_remez (int order, - const std::vector<double> &arg_bands, - const std::vector<double> &arg_response, - const std::vector<double> &arg_weight, - const std::string filter_type, - int grid_density - ) throw (std::runtime_error) -{ - int numtaps = order + 1; - if (numtaps < 4) - punt ("gr_remez: number of taps must be >= 3"); - - int numbands = arg_bands.size () / 2; - LOCAL_BUFFER (double, bands, numbands * 2); - if (numbands < 1 || arg_bands.size () % 2 == 1) - punt ("gr_remez: must have an even number of band edges"); - - for (unsigned int i = 1; i < arg_bands.size (); i++){ - if (arg_bands[i] < arg_bands[i-1]) - punt ("gr_remez: band edges must be nondecreasing"); - } - - if (arg_bands[0] < 0 || arg_bands[arg_bands.size () - 1] > 1) - punt ("gr_remez: band edges must be in the range [0,1]"); - - // Divide by 2 to fit with the implementation that uses a - // sample rate of [0, 0.5] instead of [0, 1.0] - for (int i = 0; i < 2 * numbands; i++) - bands[i] = arg_bands[i] / 2; - - LOCAL_BUFFER (double, response, numbands * 2); - if (arg_response.size () != arg_bands.size ()) - punt ("gr_remez: must have one response magnitude for each band edge"); - - for (int i = 0; i < 2 * numbands; i++) - response[i] = arg_response[i]; - - LOCAL_BUFFER (double, weight, numbands); - for (int i = 0; i < numbands; i++) - weight[i] = 1.0; - - if (arg_weight.size () != 0){ - if ((int) arg_weight.size () != numbands) - punt ("gr_remez: need one weight for each band [=length(band)/2]"); - for (int i = 0; i < numbands; i++) - weight[i] = arg_weight [i]; - } - - int itype = 0; - if (filter_type == "bandpass") - itype = BANDPASS; - else if (filter_type == "differentiator") - itype = DIFFERENTIATOR; - else if (filter_type == "hilbert") - itype = HILBERT; - else - punt ("gr_remez: unknown ftype '" + filter_type + "'"); - - if (grid_density < 16) - punt ("gr_remez: grid_density is too low; must be >= 16"); - - LOCAL_BUFFER (double, coeff, numtaps + 5); // FIXME why + 5? - int err = remez (coeff, numtaps, numbands, - bands, response, weight, itype, grid_density); - - if (err == -1) - punt ("gr_remez: failed to converge"); - - if (err == -2) - punt ("gr_remez: insufficient extremals -- cannot continue"); - - if (err == -3) - punt ("gr_remez: too many extremals -- cannot continue"); - - return std::vector<double> (&coeff[0], &coeff[numtaps]); -} - - - -#if 0 -/* == Octave interface starts here ====================================== */ - -DEFUN_DLD (remez, args, , - "b = remez(n, f, a [, w] [, ftype] [, griddensity])\n\ -Parks-McClellan optimal FIR filter design.\n\ -n gives the number of taps in the returned filter\n\ -f gives frequency at the band edges [ b1 e1 b2 e2 b3 e3 ...]\n\ -a gives amplitude at the band edges [ a(b1) a(e1) a(b2) a(e2) ...]\n\ -w gives weighting applied to each band\n\ -ftype is 'bandpass', 'hilbert' or 'differentiator'\n\ -griddensity determines how accurately the filter will be\n\ - constructed. The minimum value is 16, but higher numbers are\n\ - slower to compute.\n\ -\n\ -Frequency is in the range (0, 1), with 1 being the nyquist frequency") -{ - octave_value_list retval; - int i; - - int nargin = args.length(); - if (nargin < 3 || nargin > 6) { - print_usage("remez"); - return retval; - } - - int numtaps = NINT (args(0).double_value()) + 1; // #coeff = filter order+1 - if (numtaps < 4) { - error("remez: number of taps must be an integer greater than 3"); - return retval; - } - - ColumnVector o_bands(args(1).vector_value()); - int numbands = o_bands.length()/2; - OCTAVE_LOCAL_BUFFER(double, bands, numbands*2); - if (numbands < 1 || o_bands.length()%2 == 1) { - error("remez: must have an even number of band edges"); - return retval; - } - for (i=1; i < o_bands.length(); i++) { - if (o_bands(i)<o_bands(i-1)) { - error("band edges must be nondecreasing"); - return retval; - } - } - if (o_bands(0) < 0 || o_bands(1) > 1) { - error("band edges must be in the range [0,1]"); - return retval; - } - for(i=0; i < 2*numbands; i++) bands[i] = o_bands(i)/2.0; - - ColumnVector o_response(args(2).vector_value()); - OCTAVE_LOCAL_BUFFER (double, response, numbands*2); - if (o_response.length() != o_bands.length()) { - error("remez: must have one response magnitude for each band edge"); - return retval; - } - for(i=0; i < 2*numbands; i++) response[i] = o_response(i); - - std::string stype = std::string("bandpass"); - int density = 16; - OCTAVE_LOCAL_BUFFER (double, weight, numbands); - for (i=0; i < numbands; i++) weight[i] = 1.0; - if (nargin > 3) { - if (args(3).is_real_matrix()) { - ColumnVector o_weight(args(3).vector_value()); - if (o_weight.length() != numbands) { - error("remez: need one weight for each band [=length(band)/2]"); - return retval; - } - for (i=0; i < numbands; i++) weight[i] = o_weight(i); - } - else if (args(3).is_string()) - stype = args(3).string_value(); - else if (args(3).is_real_scalar()) - density = NINT(args(3).double_value()); - else { - error("remez: incorrect argument list"); - return retval; - } - } - if (nargin > 4) { - if (args(4).is_string() && !args(3).is_string()) - stype = args(4).string_value(); - else if (args(4).is_real_scalar() && !args(3).is_real_scalar()) - density = NINT(args(4).double_value()); - else { - error("remez: incorrect argument list"); - return retval; - } - } - if (nargin > 5) { - if (args(5).is_real_scalar() - && !args(4).is_real_scalar() - && !args(3).is_real_scalar()) - density = NINT(args(4).double_value()); - else { - error("remez: incorrect argument list"); - return retval; - } - } - - int itype; - if (stype == "bandpass") - itype = BANDPASS; - else if (stype == "differentiator") - itype = DIFFERENTIATOR; - else if (stype == "hilbert") - itype = HILBERT; - else { - error("remez: unknown ftype '%s'", stype.data()); - return retval; - } - - if (density < 16) { - error("remez: griddensity is too low; must be greater than 16"); - return retval; - } - - OCTAVE_LOCAL_BUFFER (double, coeff, numtaps+5); - int err = remez(coeff,numtaps,numbands,bands,response,weight,itype,density); - - if (err == -1) - warning("remez: -- failed to converge -- returned filter may be bad."); - else if (err == -2) { - error("remez: insufficient extremals--cannot continue"); - return retval; - } - else if (err == -3) { - error("remez: too many extremals--cannot continue"); - return retval; - } - - ColumnVector h(numtaps); - while(numtaps--) h(numtaps) = coeff[numtaps]; - - return octave_value(h); -} - -/* -%!test -%! b = [ -%! 0.0415131831103279 -%! 0.0581639884202646 -%! -0.0281579212691008 -%! -0.0535575358002337 -%! -0.0617245915143180 -%! 0.0507753178978075 -%! 0.2079018331396460 -%! 0.3327160895375440 -%! 0.3327160895375440 -%! 0.2079018331396460 -%! 0.0507753178978075 -%! -0.0617245915143180 -%! -0.0535575358002337 -%! -0.0281579212691008 -%! 0.0581639884202646 -%! 0.0415131831103279]; -%! assert(remez(15,[0,0.3,0.4,1],[1,1,0,0]),b,1e-14); - - */ - -#endif diff --git a/gnuradio-core/src/lib/general/gr_remez.h b/gnuradio-core/src/lib/general/gr_remez.h deleted file mode 100644 index d875b88229..0000000000 --- a/gnuradio-core/src/lib/general/gr_remez.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_REMEZ_H -#define INCLUDED_GR_REMEZ_H - -#include <gr_core_api.h> -#include <gr_types.h> -#include <string> -#include <stdexcept> - -/*! - * \brief Parks-McClellan FIR filter design. - * - * \ingroup filter_design - * - * Calculates the optimal (in the Chebyshev/minimax sense) FIR filter - * inpulse reponse given a set of band edges, the desired reponse on - * those bands, and the weight given to the error in those bands. - * - * \param order filter order (number of taps in the returned filter - 1) - * \param bands frequency at the band edges [ b1 e1 b2 e2 b3 e3 ...] - * \param ampl desired amplitude at the band edges [ a(b1) a(e1) a(b2) a(e2) ...] - * \param error_weight weighting applied to each band (usually 1) - * \param filter_type one of "bandpass", "hilbert" or "differentiator" - * \param grid_density determines how accurately the filter will be constructed. \ - * The minimum value is 16; higher values are slower to compute. - * - * Frequency is in the range [0, 1], with 1 being the Nyquist frequency (Fs/2) - * - * \returns vector of computed taps - * - * \throws std::runtime_error if args are invalid or calculation fails to converge. - */ - -GR_CORE_API std::vector<double> -gr_remez (int order, - const std::vector<double> &bands, - const std::vector<double> &l, - const std::vector<double> &error_weight, - const std::string filter_type = "bandpass", - int grid_density = 16 - ) throw (std::runtime_error); - - -#endif /* INCLUDED_GR_REMEZ_H */ diff --git a/gnuradio-core/src/lib/general/gr_remez.i b/gnuradio-core/src/lib/general/gr_remez.i deleted file mode 100644 index fe3eea20da..0000000000 --- a/gnuradio-core/src/lib/general/gr_remez.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%rename(remez) gr_remez; - -std::vector<double> -gr_remez (int order, - const std::vector<double> &bands, - const std::vector<double> &l, - const std::vector<double> &error_weight, - const std::string filter_type = "bandpass", - int grid_density = 16 - ) throw (std::runtime_error); diff --git a/gnuradio-core/src/lib/general/gr_repeat.cc b/gnuradio-core/src/lib/general/gr_repeat.cc deleted file mode 100644 index 2fa82cd94d..0000000000 --- a/gnuradio-core/src/lib/general/gr_repeat.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_repeat.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_repeat_sptr -gr_make_repeat(size_t itemsize, int interp) -{ - return gnuradio::get_initial_sptr(new gr_repeat(itemsize, interp)); -} - -gr_repeat::gr_repeat(size_t itemsize, int interp) - : gr_sync_interpolator("extend", - gr_make_io_signature(1, 1, itemsize), - gr_make_io_signature(1, 1, itemsize), - interp), - d_interp(interp), - d_itemsize(itemsize) -{ -} - -gr_repeat::~gr_repeat() -{ -} - -int -gr_repeat::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *in = (const char *) input_items[0]; - char *out = (char *)output_items[0]; - - for (int i = 0; i < noutput_items/d_interp; i++) { - for (int j = 0; j < d_interp; j++) { - memcpy(out, in, d_itemsize); - out += d_itemsize; - } - - in += d_itemsize; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_repeat.h b/gnuradio-core/src/lib/general/gr_repeat.h deleted file mode 100644 index 548ca79f4d..0000000000 --- a/gnuradio-core/src/lib/general/gr_repeat.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_REPEAT_H -#define INCLUDED_GR_REPEAT_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_repeat; - -typedef boost::shared_ptr<gr_repeat> gr_repeat_sptr; - -GR_CORE_API gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp); - -/*! - * \brief Repeat a sample 'interp' times in output stream - * \ingroup misc_blk - */ - -class GR_CORE_API gr_repeat : public gr_sync_interpolator -{ -private: - friend GR_CORE_API gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp); - - gr_repeat(size_t itemsize, int interp); - - int d_interp; - int d_itemsize; - - public: - ~gr_repeat(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_REPEAT_H */ diff --git a/gnuradio-core/src/lib/general/gr_repeat.i b/gnuradio-core/src/lib/general/gr_repeat.i deleted file mode 100644 index c657a4906f..0000000000 --- a/gnuradio-core/src/lib/general/gr_repeat.i +++ /dev/null @@ -1,11 +0,0 @@ -/* -*- c++ -*- */ - -GR_SWIG_BLOCK_MAGIC(gr,repeat); - -gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp); - -class gr_repeat : public gr_sync_interpolator -{ -private: - gr_repeat(); -}; diff --git a/gnuradio-core/src/lib/general/gr_rms_cf.cc b/gnuradio-core/src/lib/general/gr_rms_cf.cc deleted file mode 100644 index 44eb2221ea..0000000000 --- a/gnuradio-core/src/lib/general/gr_rms_cf.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <gr_rms_cf.h> -#include <gr_io_signature.h> -#include <cmath> - -gr_rms_cf_sptr -gr_make_rms_cf(double alpha) -{ - return gnuradio::get_initial_sptr(new gr_rms_cf(alpha)); -} - -gr_rms_cf::gr_rms_cf (double alpha) - : gr_sync_block ("rms_cf", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(1, 1, sizeof(float))), - d_iir(alpha) -{ - -} - -gr_rms_cf::~gr_rms_cf() -{ -} - - -int -gr_rms_cf::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - double mag_sqrd = in[i].real()*in[i].real() + in[i].imag()*in[i].imag(); - double f = d_iir.filter(mag_sqrd); - out[i] = sqrt(f); - } - - return noutput_items; -} - -void -gr_rms_cf::set_alpha(double alpha) -{ - d_iir.set_taps(alpha); -} diff --git a/gnuradio-core/src/lib/general/gr_rms_cf.h b/gnuradio-core/src/lib/general/gr_rms_cf.h deleted file mode 100644 index 9e701aa6a0..0000000000 --- a/gnuradio-core/src/lib/general/gr_rms_cf.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_RMS_CF_H -#define INCLUDED_GR_RMS_CF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_single_pole_iir.h> - -class gr_rms_cf; -typedef boost::shared_ptr<gr_rms_cf> gr_rms_cf_sptr; - -GR_CORE_API gr_rms_cf_sptr -gr_make_rms_cf (double alpha = 0.0001); - -/*! - * \brief RMS average power - * \ingroup math_blk - */ -class GR_CORE_API gr_rms_cf : public gr_sync_block -{ - gr_single_pole_iir<double,double,double> d_iir; - bool d_unmuted; - - friend GR_CORE_API gr_rms_cf_sptr - gr_make_rms_cf (double alpha); - - gr_rms_cf (double alpha); - -public: - ~gr_rms_cf (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool unmuted () const { return d_unmuted; } - - void set_alpha (double alpha); -}; - -#endif /* INCLUDED_GR_RMS_CF_H */ diff --git a/gnuradio-core/src/lib/general/gr_rms_cf.i b/gnuradio-core/src/lib/general/gr_rms_cf.i deleted file mode 100644 index a668200eef..0000000000 --- a/gnuradio-core/src/lib/general/gr_rms_cf.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,rms_cf); - -gr_rms_cf_sptr -gr_make_rms_cf (double alpha = 0.0001); - -class gr_rms_cf : public gr_sync_block -{ -public: - bool unmuted () const { return d_unmuted; } - void set_alpha (double alpha); -}; diff --git a/gnuradio-core/src/lib/general/gr_rms_ff.cc b/gnuradio-core/src/lib/general/gr_rms_ff.cc deleted file mode 100644 index 233f419cd2..0000000000 --- a/gnuradio-core/src/lib/general/gr_rms_ff.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <gr_rms_ff.h> -#include <gr_io_signature.h> -#include <cmath> - -gr_rms_ff_sptr -gr_make_rms_ff(double alpha) -{ - return gnuradio::get_initial_sptr(new gr_rms_ff(alpha)); -} - -gr_rms_ff::gr_rms_ff (double alpha) - : gr_sync_block ("rms_ff", - gr_make_io_signature(1, 1, sizeof(float)), - gr_make_io_signature(1, 1, sizeof(float))), - d_iir(alpha) -{ - -} - -gr_rms_ff::~gr_rms_ff() -{ -} - - -int -gr_rms_ff::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - double mag_sqrd = in[i]*in[i]; - double f = d_iir.filter(mag_sqrd); - out[i] = sqrt(f); - } - - return noutput_items; -} - -void -gr_rms_ff::set_alpha(double alpha) -{ - d_iir.set_taps(alpha); -} diff --git a/gnuradio-core/src/lib/general/gr_rms_ff.h b/gnuradio-core/src/lib/general/gr_rms_ff.h deleted file mode 100644 index 30cf7f9d9f..0000000000 --- a/gnuradio-core/src/lib/general/gr_rms_ff.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_RMS_FF_H -#define INCLUDED_GR_RMS_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_single_pole_iir.h> - -class gr_rms_ff; -typedef boost::shared_ptr<gr_rms_ff> gr_rms_ff_sptr; - -GR_CORE_API gr_rms_ff_sptr -gr_make_rms_ff (double alpha = 0.0001); - -/*! - * \brief RMS average power - * \ingroup math_blk - */ -class GR_CORE_API gr_rms_ff : public gr_sync_block -{ - gr_single_pole_iir<double,double,double> d_iir; - bool d_unmuted; - - friend GR_CORE_API gr_rms_ff_sptr - gr_make_rms_ff (double alpha); - - gr_rms_ff (double alpha); - -public: - ~gr_rms_ff (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool unmuted () const { return d_unmuted; } - - void set_alpha (double alpha); -}; - -#endif /* INCLUDED_GR_RMS_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_rms_ff.i b/gnuradio-core/src/lib/general/gr_rms_ff.i deleted file mode 100644 index 00b03f5d4b..0000000000 --- a/gnuradio-core/src/lib/general/gr_rms_ff.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,rms_ff); - -gr_rms_ff_sptr -gr_make_rms_ff (double alpha = 0.0001); - -class gr_rms_ff : public gr_sync_block -{ -public: - bool unmuted () const { return d_unmuted; } - void set_alpha (double alpha); -}; diff --git a/gnuradio-core/src/lib/general/gr_scrambler_bb.cc b/gnuradio-core/src/lib/general/gr_scrambler_bb.cc deleted file mode 100644 index 31eb192077..0000000000 --- a/gnuradio-core/src/lib/general/gr_scrambler_bb.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_scrambler_bb.h> -#include <gr_io_signature.h> - -gr_scrambler_bb_sptr -gr_make_scrambler_bb(int mask, int seed, int len) -{ - return gnuradio::get_initial_sptr(new gr_scrambler_bb(mask, seed, len)); -} - -gr_scrambler_bb::gr_scrambler_bb(int mask, int seed, int len) - : gr_sync_block("scrambler_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_lfsr(mask, seed, len) -{ -} - -int -gr_scrambler_bb::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++) - out[i] = d_lfsr.next_bit_scramble(in[i]); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_scrambler_bb.h b/gnuradio-core/src/lib/general/gr_scrambler_bb.h deleted file mode 100644 index edb429e0a0..0000000000 --- a/gnuradio-core/src/lib/general/gr_scrambler_bb.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_SCRAMBLER_BB_H -#define INCLUDED_GR_SCRAMBLER_BB_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include "gri_lfsr.h" - -class gr_scrambler_bb; -typedef boost::shared_ptr<gr_scrambler_bb> gr_scrambler_bb_sptr; - -GR_CORE_API gr_scrambler_bb_sptr gr_make_scrambler_bb(int mask, int seed, int len); - -/*! - * Scramble an input stream using an LFSR. This block works on the LSB only - * of the input data stream, i.e., on an "unpacked binary" stream, and - * produces the same format on its output. - * - * \param mask Polynomial mask for LFSR - * \param seed Initial shift register contents - * \param len Shift register length - * - * \ingroup coding_blk - */ - -class GR_CORE_API gr_scrambler_bb : public gr_sync_block -{ - friend GR_CORE_API gr_scrambler_bb_sptr gr_make_scrambler_bb(int mask, int seed, int len); - - gri_lfsr d_lfsr; - - gr_scrambler_bb(int mask, int seed, int len); - -public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_SCRAMBLER_BB_H */ diff --git a/gnuradio-core/src/lib/general/gr_scrambler_bb.i b/gnuradio-core/src/lib/general/gr_scrambler_bb.i deleted file mode 100644 index a7ef7b364f..0000000000 --- a/gnuradio-core/src/lib/general/gr_scrambler_bb.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,scrambler_bb); - -gr_scrambler_bb_sptr gr_make_scrambler_bb(int mask, int seed, int len); - -class gr_scrambler_bb : public gr_sync_block -{ -private: - gr_scrambler_bb(int mask, int seed, int len); -}; diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.cc b/gnuradio-core/src/lib/general/gr_short_to_char.cc deleted file mode 100644 index 8c146a351d..0000000000 --- a/gnuradio-core/src/lib/general/gr_short_to_char.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_short_to_char.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_short_to_char_sptr -gr_make_short_to_char (size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_short_to_char (vlen)); -} - -gr_short_to_char::gr_short_to_char (size_t vlen) - : gr_sync_block ("gr_short_to_char", - gr_make_io_signature (1, 1, sizeof (short)*vlen), - gr_make_io_signature (1, 1, sizeof (char)*vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(char); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_short_to_char::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const int16_t *in = (const int16_t *) input_items[0]; - int8_t *out = (int8_t *) output_items[0]; - - if(is_unaligned()) { - volk_16i_convert_8i_u(out, in, d_vlen*noutput_items); - } - else { - volk_16i_convert_8i_a(out, in, d_vlen*noutput_items); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.h b/gnuradio-core/src/lib/general/gr_short_to_char.h deleted file mode 100644 index bf96211c7c..0000000000 --- a/gnuradio-core/src/lib/general/gr_short_to_char.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SHORT_TO_CHAR_H -#define INCLUDED_GR_SHORT_TO_CHAR_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_short_to_char; -typedef boost::shared_ptr<gr_short_to_char> gr_short_to_char_sptr; - -GR_CORE_API gr_short_to_char_sptr -gr_make_short_to_char (size_t vlen=1); - -/*! - * \brief Convert stream of short to a stream of float - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - */ - -class GR_CORE_API gr_short_to_char : public gr_sync_block -{ - private: - friend GR_CORE_API gr_short_to_char_sptr - gr_make_short_to_char (size_t vlen); - gr_short_to_char (size_t vlen); - - size_t d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_SHORT_TO_CHAR_H */ diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.i b/gnuradio-core/src/lib/general/gr_short_to_char.i deleted file mode 100644 index 7389ed10ba..0000000000 --- a/gnuradio-core/src/lib/general/gr_short_to_char.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,short_to_char) - -gr_short_to_char_sptr -gr_make_short_to_char (size_t vlen=1); - -class gr_short_to_char : public gr_sync_block -{ - -}; diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.cc b/gnuradio-core/src/lib/general/gr_short_to_float.cc deleted file mode 100644 index 093d6024fa..0000000000 --- a/gnuradio-core/src/lib/general/gr_short_to_float.cc +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_short_to_float.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_short_to_float_sptr -gr_make_short_to_float (size_t vlen, float scale) -{ - return gnuradio::get_initial_sptr(new gr_short_to_float (vlen, scale)); -} - -gr_short_to_float::gr_short_to_float (size_t vlen, float scale) - : gr_sync_block ("gr_short_to_float", - gr_make_io_signature (1, 1, sizeof (short)*vlen), - gr_make_io_signature (1, 1, sizeof (float)*vlen)), - d_vlen(vlen), d_scale(scale) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -float -gr_short_to_float::scale() const -{ - return d_scale; -} - -void -gr_short_to_float::set_scale(float scale) -{ - d_scale = scale; -} - -int -gr_short_to_float::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const short *in = (const short *) input_items[0]; - float *out = (float *) output_items[0]; - - if(is_unaligned()) { - volk_16i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items); - } - else { - volk_16i_s32f_convert_32f_a(out, in, d_scale, d_vlen*noutput_items); - } - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.h b/gnuradio-core/src/lib/general/gr_short_to_float.h deleted file mode 100644 index 362549e70a..0000000000 --- a/gnuradio-core/src/lib/general/gr_short_to_float.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SHORT_TO_FLOAT_H -#define INCLUDED_GR_SHORT_TO_FLOAT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_short_to_float; -typedef boost::shared_ptr<gr_short_to_float> gr_short_to_float_sptr; - -GR_CORE_API gr_short_to_float_sptr -gr_make_short_to_float (size_t vlen=1, float scale=1); - -/*! - * \brief Convert stream of short to a stream of float - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar divider to change the output signal scale. - */ - -class GR_CORE_API gr_short_to_float : public gr_sync_block -{ - private: - friend GR_CORE_API gr_short_to_float_sptr - gr_make_short_to_float (size_t vlen, float scale); - gr_short_to_float (size_t vlen, float scale); - - size_t d_vlen; - float d_scale; - - public: - /*! - * Get the scalar divider value. - */ - float scale() const; - - /*! - * Set the scalar divider value. - */ - void set_scale(float scale); - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_SHORT_TO_FLOAT_H */ diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.i b/gnuradio-core/src/lib/general/gr_short_to_float.i deleted file mode 100644 index e781e292c9..0000000000 --- a/gnuradio-core/src/lib/general/gr_short_to_float.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,short_to_float) - -gr_short_to_float_sptr -gr_make_short_to_float (size_t vlen=1, float scale=1); - -class gr_short_to_float : public gr_sync_block -{ -public: - float scale() const; - void set_scale(float scale); -}; diff --git a/gnuradio-core/src/lib/general/gr_simple_correlator.cc b/gnuradio-core/src/lib/general/gr_simple_correlator.cc deleted file mode 100644 index b9209e74f0..0000000000 --- a/gnuradio-core/src/lib/general/gr_simple_correlator.cc +++ /dev/null @@ -1,237 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_simple_correlator.h> -#include <gr_simple_framer_sync.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <stdexcept> -#include <gr_count_bits.h> -#include <string.h> -#include <cstdio> - - -static const int THRESHOLD = 3; - -gr_simple_correlator_sptr -gr_make_simple_correlator (int payload_bytesize) -{ - return gnuradio::get_initial_sptr(new gr_simple_correlator (payload_bytesize)); -} - -gr_simple_correlator::gr_simple_correlator (int payload_bytesize) - : gr_block ("simple_correlator", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_payload_bytesize (payload_bytesize), - d_state (ST_LOOKING), d_osi (0), - d_bblen ((payload_bytesize + GRSF_PAYLOAD_OVERHEAD) * GRSF_BITS_PER_BYTE), - d_bitbuf (new unsigned char [d_bblen]), - d_pktbuf (new unsigned char [d_bblen/GRSF_BITS_PER_BYTE]), - d_bbi (0) -{ - d_avbi = 0; - d_accum = 0.0; - d_avg = 0.0; - for (int i = 0; i < AVG_PERIOD; i++) - d_avgbuf[i] = 0.0; - -#ifdef DEBUG_SIMPLE_CORRELATOR - d_debug_fp = fopen("corr.log", "w"); -#endif - enter_looking (); - -} - -gr_simple_correlator::~gr_simple_correlator () -{ -#ifdef DEBUG_SIMPLE_CORRELATOR - fclose(d_debug_fp); -#endif - delete [] d_bitbuf; - delete [] d_pktbuf; -} - - -void -gr_simple_correlator::enter_looking () -{ - fflush (stdout); - // fprintf (stderr, ">>> enter_looking\n"); - d_state = ST_LOOKING; - for (int i = 0; i < OVERSAMPLE; i++) - d_shift_reg[i] = 0; - d_osi = 0; - - d_avbi = 0; - d_avg = d_avg * 0.5; - d_accum = 0; - for (int i = 0; i < AVG_PERIOD; i++) - d_avgbuf[i] = 0.0; -} - -void -gr_simple_correlator::enter_under_threshold () -{ - fflush (stdout); - // fprintf (stderr, ">>> enter_under_threshold\n"); - d_state = ST_UNDER_THRESHOLD; - d_transition_osi = d_osi; -} - -void -gr_simple_correlator::enter_locked () -{ - d_state = ST_LOCKED; - int delta = sub_index (d_osi, d_transition_osi); - d_center_osi = add_index (d_transition_osi, delta/2); - d_center_osi = add_index (d_center_osi, 3); // FIXME - d_bbi = 0; - fflush (stdout); - // fprintf (stderr, ">>> enter_locked d_center_osi = %d\n", d_center_osi); - - d_avg = std::max(-1.0, std::min(1.0, d_accum * (1.0/AVG_PERIOD))); - // fprintf(stderr, ">>> enter_locked d_avg = %g\n", d_avg); -} - -static void -packit (unsigned char *pktbuf, const unsigned char *bitbuf, int bitcount) -{ - for (int i = 0; i < bitcount; i += 8){ - int t = bitbuf[i+0] & 0x1; - t = (t << 1) | (bitbuf[i+1] & 0x1); - t = (t << 1) | (bitbuf[i+2] & 0x1); - t = (t << 1) | (bitbuf[i+3] & 0x1); - t = (t << 1) | (bitbuf[i+4] & 0x1); - t = (t << 1) | (bitbuf[i+5] & 0x1); - t = (t << 1) | (bitbuf[i+6] & 0x1); - t = (t << 1) | (bitbuf[i+7] & 0x1); - *pktbuf++ = t; - } -} - -void -gr_simple_correlator::update_avg(float x) -{ - d_accum -= d_avgbuf[d_avbi]; - d_avgbuf[d_avbi] = x; - d_accum += x; - d_avbi = (d_avbi + 1) & (AVG_PERIOD-1); -} - - -int -gr_simple_correlator::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - - int n = 0; - int nin = ninput_items[0]; - int decision; - int hamming_dist; - -#ifdef DEBUG_SIMPLE_CORRELATOR - struct debug_data { - float raw_data; - float sampled; - float enter_locked; - } debug_data; -#endif - - while (n < nin){ - -#ifdef DEBUG_SIMPLE_CORRELATOR - debug_data.raw_data = in[n]; - debug_data.sampled = 0.0; - debug_data.enter_locked = 0.0; -#endif - - switch (d_state){ - - case ST_LOCKED: - if (d_osi == d_center_osi){ - -#ifdef DEBUG_SIMPLE_CORRELATOR - debug_data.sampled = 1.0; -#endif - decision = slice (in[n]); - - d_bitbuf[d_bbi] = decision; - d_bbi++; - if (d_bbi >= d_bblen){ - // printf ("got whole packet\n"); - packit (d_pktbuf, d_bitbuf, d_bbi); - printf ("seqno %3d\n", d_pktbuf[0]); - memcpy (out, &d_pktbuf[GRSF_PAYLOAD_OVERHEAD], d_payload_bytesize); - enter_looking (); - consume_each (n + 1); - return d_payload_bytesize; - } - } - break; - - case ST_LOOKING: - case ST_UNDER_THRESHOLD: - update_avg(in[n]); - decision = slice (in[n]); - d_shift_reg[d_osi] = (d_shift_reg[d_osi] << 1) | decision; - - hamming_dist = gr_count_bits64 (d_shift_reg[d_osi] ^ GRSF_SYNC); - // printf ("%2d %d\n", hamming_dist, d_osi); - - if (d_state == ST_LOOKING && hamming_dist <= THRESHOLD){ - // We're seeing a good PN code, remember location - enter_under_threshold (); - } - else if (d_state == ST_UNDER_THRESHOLD && hamming_dist > THRESHOLD){ - // no longer seeing good PN code, compute center of goodness - enter_locked (); -#ifdef DEBUG_SIMPLE_CORRELATOR - debug_data.enter_locked = 1.0; -#endif - } - break; - - default: - assert (0); - } - -#ifdef DEBUG_SIMPLE_CORRELATOR - fwrite(&debug_data, sizeof (debug_data), 1, d_debug_fp); -#endif - - d_osi = add_index (d_osi, 1); - n++; - } - - consume_each (n); - return 0; -} diff --git a/gnuradio-core/src/lib/general/gr_simple_correlator.h b/gnuradio-core/src/lib/general/gr_simple_correlator.h deleted file mode 100644 index 37d00c125e..0000000000 --- a/gnuradio-core/src/lib/general/gr_simple_correlator.h +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SIMPLE_CORRELATOR_H -#define INCLUDED_GR_SIMPLE_CORRELATOR_H - -#include <gr_core_api.h> -#include <gr_block.h> -#include <assert.h> - -//#define DEBUG_SIMPLE_CORRELATOR - -class gr_simple_correlator; -typedef boost::shared_ptr<gr_simple_correlator> gr_simple_correlator_sptr; - -GR_CORE_API gr_simple_correlator_sptr gr_make_simple_correlator (int payload_bytesize); - -/*! - * \brief inverse of gr_simple_framer (more or less) - * \ingroup sync_blk - */ -class GR_CORE_API gr_simple_correlator : public gr_block -{ - static const int OVERSAMPLE = 8; - enum state_t { ST_LOOKING, ST_UNDER_THRESHOLD, ST_LOCKED }; - - int d_payload_bytesize; - state_t d_state; - unsigned int d_osi; // over sample index [0,OVERSAMPLE-1] - unsigned int d_transition_osi; // first index where Hamming dist < thresh - unsigned int d_center_osi; // center of bit - unsigned long long int d_shift_reg[OVERSAMPLE]; - int d_bblen; // length of bitbuf - unsigned char *d_bitbuf; // demodulated bits - unsigned char *d_pktbuf; // temp packet buf - int d_bbi; // bitbuf index - - static const int AVG_PERIOD = 512; // must be power of 2 (for freq offset correction) - int d_avbi; - float d_avgbuf[AVG_PERIOD]; - float d_avg; - float d_accum; - -#ifdef DEBUG_SIMPLE_CORRELATOR - FILE *d_debug_fp; // binary log file -#endif - - friend GR_CORE_API gr_simple_correlator_sptr gr_make_simple_correlator (int payload_bytesize); - gr_simple_correlator (int payload_bytesize); - - - inline int slice (float x) - { - return x >= d_avg ? 1 : 0; - } - - void update_avg(float x); - - void enter_locked (); - void enter_under_threshold (); - void enter_looking (); - - static int add_index (int a, int b) - { - int t = a + b; - if (t >= OVERSAMPLE) - t -= OVERSAMPLE; - assert (t >= 0 && t < OVERSAMPLE); - return t; - } - - static int sub_index (int a, int b) - { - int t = a - b; - if (t < 0) - t += OVERSAMPLE; - assert (t >= 0 && t < OVERSAMPLE); - return t; - } - - - public: - ~gr_simple_correlator (); - - 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_GR_SIMPLE_CORRELATOR_H */ diff --git a/gnuradio-core/src/lib/general/gr_simple_correlator.i b/gnuradio-core/src/lib/general/gr_simple_correlator.i deleted file mode 100644 index 24d133072f..0000000000 --- a/gnuradio-core/src/lib/general/gr_simple_correlator.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,simple_correlator); - -gr_simple_correlator_sptr gr_make_simple_correlator (int payload_bytesize); - -class gr_simple_correlator : public gr_block -{ - private: - gr_simple_correlator (int payload_bytesize); -}; diff --git a/gnuradio-core/src/lib/general/gr_simple_framer.cc b/gnuradio-core/src/lib/general/gr_simple_framer.cc deleted file mode 100644 index 506603bb71..0000000000 --- a/gnuradio-core/src/lib/general/gr_simple_framer.cc +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_simple_framer.h> -#include <gr_simple_framer_sync.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <stdexcept> -#include <string.h> - - -gr_simple_framer_sptr -gr_make_simple_framer (int payload_bytesize) -{ - return gnuradio::get_initial_sptr(new gr_simple_framer (payload_bytesize)); -} - -gr_simple_framer::gr_simple_framer (int payload_bytesize) - : gr_block ("simple_framer", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_seqno (0), d_payload_bytesize (payload_bytesize), - d_input_block_size (payload_bytesize), - d_output_block_size (payload_bytesize + GRSF_OVERHEAD) -{ - set_output_multiple (d_output_block_size); -} - -void -gr_simple_framer::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - assert (noutput_items % d_output_block_size == 0); - - int nblocks = noutput_items / d_output_block_size; - int input_required = nblocks * d_input_block_size; - - unsigned ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) - ninput_items_required[i] = input_required; -} - -int -gr_simple_framer::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - int n = 0; - int nblocks = 0; - - memset (out, 0x55, noutput_items); - - while (n < noutput_items){ - out[0] = (GRSF_SYNC >> 56) & 0xff; - out[1] = (GRSF_SYNC >> 48) & 0xff; - out[2] = (GRSF_SYNC >> 40) & 0xff; - out[3] = (GRSF_SYNC >> 32) & 0xff; - out[4] = (GRSF_SYNC >> 24) & 0xff; - out[5] = (GRSF_SYNC >> 16) & 0xff; - out[6] = (GRSF_SYNC >> 8) & 0xff; - out[7] = (GRSF_SYNC >> 0) & 0xff; - out[8] = d_seqno++; - - memcpy (&out[9], in, d_input_block_size); - in += d_input_block_size; - out += d_output_block_size; - n += d_output_block_size; - nblocks++; - } - - assert (n == noutput_items); - - consume_each (nblocks * d_input_block_size); - return n; -} diff --git a/gnuradio-core/src/lib/general/gr_simple_framer.h b/gnuradio-core/src/lib/general/gr_simple_framer.h deleted file mode 100644 index 76a4b7baba..0000000000 --- a/gnuradio-core/src/lib/general/gr_simple_framer.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SIMPLE_FRAMER_H -#define INCLUDED_GR_SIMPLE_FRAMER_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_simple_framer; -typedef boost::shared_ptr<gr_simple_framer> gr_simple_framer_sptr; - -GR_CORE_API gr_simple_framer_sptr gr_make_simple_framer (int payload_bytesize); - -/*! - * \brief add sync field, seq number and command field to payload - * \ingroup sync_blk - */ -class GR_CORE_API gr_simple_framer : public gr_block -{ - int d_seqno; - int d_payload_bytesize; - int d_input_block_size; // bytes - int d_output_block_size; // bytes - - friend GR_CORE_API gr_simple_framer_sptr gr_make_simple_framer (int payload_bytesize); - gr_simple_framer (int payload_bytesize); - - 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); -}; - - -#endif /* INCLUDED_GR_SIMPLE_FRAMER_H */ diff --git a/gnuradio-core/src/lib/general/gr_simple_framer.i b/gnuradio-core/src/lib/general/gr_simple_framer.i deleted file mode 100644 index c13ead87bf..0000000000 --- a/gnuradio-core/src/lib/general/gr_simple_framer.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,simple_framer); - -gr_simple_framer_sptr gr_make_simple_framer (int payload_bytesize); - -class gr_simple_framer : public gr_block -{ - private: - gr_simple_framer (int payload_bytesize); -}; diff --git a/gnuradio-core/src/lib/general/gr_simple_framer_sync.h b/gnuradio-core/src/lib/general/gr_simple_framer_sync.h deleted file mode 100644 index 66173be421..0000000000 --- a/gnuradio-core/src/lib/general/gr_simple_framer_sync.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SIMPLE_FRAMER_SYNC_H -#define INCLUDED_GR_SIMPLE_FRAMER_SYNC_H - -/*! - * \brief Here are a couple of maximum length sequences (m-sequences) that were generated by the - * the "mseq" matlab/octave code downloaded from: - * <a href="http://www.mathworks.com/matlabcentral/fileexchange/990">http://www.mathworks.com/matlabcentral/fileexchange/990</a> - * - * <pre> - * 31-bit m-sequence: - * 0110100100001010111011000111110 - * 0x690AEC76 (padded on right with a zero) - * - * 63-bit m-sequence: - * 101011001101110110100100111000101111001010001100001000001111110 - * 0xACDDA4E2F28C20FC (padded on right with a zero) - * </pre> - */ - -static const unsigned long long GRSF_SYNC = 0xacdda4e2f28c20fcULL; - -static const int GRSF_BITS_PER_BYTE = 8; -static const int GRSF_SYNC_OVERHEAD = sizeof(GRSF_SYNC); -static const int GRSF_PAYLOAD_OVERHEAD = 1; // 1 byte seqno -static const int GRSF_TAIL_PAD = 1; // one byte trailing padding -static const int GRSF_OVERHEAD = GRSF_SYNC_OVERHEAD + GRSF_PAYLOAD_OVERHEAD + GRSF_TAIL_PAD; - - -#endif /* INCLUDED_GR_SIMPLE_FRAMER_SYNC_H */ diff --git a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.cc b/gnuradio-core/src/lib/general/gr_simple_squelch_cc.cc deleted file mode 100644 index 5d90a3da48..0000000000 --- a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <gr_simple_squelch_cc.h> -#include <gr_io_signature.h> -#include <cmath> - -gr_simple_squelch_cc_sptr -gr_make_simple_squelch_cc(double threshold_db, double alpha) -{ - return gnuradio::get_initial_sptr(new gr_simple_squelch_cc(threshold_db, alpha)); -} - -gr_simple_squelch_cc::gr_simple_squelch_cc (double threshold_db, double alpha) - : gr_sync_block ("simple_squelch_cc", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(1, 1, sizeof(gr_complex))), - d_iir(alpha), d_unmuted(false) -{ - set_threshold (threshold_db); -} - -gr_simple_squelch_cc::~gr_simple_squelch_cc() -{ -} - - -int -gr_simple_squelch_cc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - double mag_sqrd = in[i].real()*in[i].real() + in[i].imag()*in[i].imag(); - double f = d_iir.filter(mag_sqrd); - if (f >= d_threshold) - out[i] = in[i]; - else - out[i] = 0; - } - - d_unmuted = d_iir.prev_output() >= d_threshold; - return noutput_items; -} - -void -gr_simple_squelch_cc::set_threshold(double decibels) -{ - // convert to absolute threshold (mag squared) - d_threshold = std::pow(10.0, decibels/10); -} - -double -gr_simple_squelch_cc::threshold() const -{ - return 10 * log10(d_threshold); -} - -void -gr_simple_squelch_cc::set_alpha(double alpha) -{ - d_iir.set_taps(alpha); -} - -std::vector<float> -gr_simple_squelch_cc::squelch_range() const -{ - std::vector<float> r(3); - r[0] = -50.0; // min FIXME - r[1] = +50.0; // max FIXME - r[2] = (r[1] - r[0]) / 100; // step size - - return r; -} diff --git a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h b/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h deleted file mode 100644 index 4bf62c7ec6..0000000000 --- a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_SIMPLE_SQUELCH_CC_H -#define INCLUDED_GR_SIMPLE_SQUELCH_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_single_pole_iir.h> - -class gr_simple_squelch_cc; -typedef boost::shared_ptr<gr_simple_squelch_cc> gr_simple_squelch_cc_sptr; - -GR_CORE_API gr_simple_squelch_cc_sptr -gr_make_simple_squelch_cc (double threshold_db, double alpha = 0.0001); - -/*! - * \brief simple squelch block based on average signal power and threshold in dB. - * \ingroup level_blk - */ -class GR_CORE_API gr_simple_squelch_cc : public gr_sync_block -{ - double d_threshold; - gr_single_pole_iir<double,double,double> d_iir; - bool d_unmuted; - - friend GR_CORE_API gr_simple_squelch_cc_sptr - gr_make_simple_squelch_cc (double threshold_db, double alpha); - - gr_simple_squelch_cc (double threshold_db, double alpha); - -public: - ~gr_simple_squelch_cc (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool unmuted () const { return d_unmuted; } - - void set_alpha (double alpha); - void set_threshold (double decibels); - - double threshold() const; - std::vector<float> squelch_range() const; - -}; - -#endif /* INCLUDED_GR_SIMPLE_SQUELCH_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.i b/gnuradio-core/src/lib/general/gr_simple_squelch_cc.i deleted file mode 100644 index 17b469e156..0000000000 --- a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,simple_squelch_cc); - -gr_simple_squelch_cc_sptr -gr_make_simple_squelch_cc (double threshold_db, double alpha = 0.0001); - -class gr_simple_squelch_cc : public gr_sync_block -{ -public: - bool unmuted () const { return d_unmuted; } - void set_alpha (double alpha); - void set_threshold (double decibels); - - double threshold() const; - std::vector<float> squelch_range() const; -}; diff --git a/gnuradio-core/src/lib/general/gr_skiphead.cc b/gnuradio-core/src/lib/general/gr_skiphead.cc index 7b441bea9a..c93478597b 100644 --- a/gnuradio-core/src/lib/general/gr_skiphead.cc +++ b/gnuradio-core/src/lib/general/gr_skiphead.cc @@ -41,6 +41,31 @@ gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip) return gnuradio::get_initial_sptr(new gr_skiphead (itemsize, nitems_to_skip)); } +void +gr_skiphead::set_nitems_to_skip(uint64_t nitems_to_skip) +{ + d_nitems_to_skip = nitems_to_skip; + reset(); +} + +uint64_t +gr_skiphead::nitems_to_skip() const +{ + return d_nitems_to_skip; +} + +uint64_t +gr_skiphead::nitems_skiped() const +{ + return d_nitems; +} + +void +gr_skiphead::reset() +{ + d_nitems = 0; +} + int gr_skiphead::general_work(int noutput_items, gr_vector_int &ninput_items_, diff --git a/gnuradio-core/src/lib/general/gr_skiphead.h b/gnuradio-core/src/lib/general/gr_skiphead.h index 899b40f27a..710530ff4c 100644 --- a/gnuradio-core/src/lib/general/gr_skiphead.h +++ b/gnuradio-core/src/lib/general/gr_skiphead.h @@ -51,6 +51,26 @@ class GR_CORE_API gr_skiphead : public gr_block public: + /*! + * \brief Sets number of items to skip; resets current skip count to 0. + */ + void set_nitems_to_skip(uint64_t nitems_to_skip); + + /*! + * \brief Gets the number of items to skip. + */ + uint64_t nitems_to_skip() const; + + /*! + * \brief Gets the number of items already skipped. + */ + uint64_t nitems_skiped() const; + + /*! + * \brief Resets number of items skipped to 0. + */ + void reset(); + int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, diff --git a/gnuradio-core/src/lib/general/gr_skiphead.i b/gnuradio-core/src/lib/general/gr_skiphead.i index 3246db9702..8ab23a77a6 100644 --- a/gnuradio-core/src/lib/general/gr_skiphead.i +++ b/gnuradio-core/src/lib/general/gr_skiphead.i @@ -22,9 +22,14 @@ GR_SWIG_BLOCK_MAGIC(gr,skiphead); -gr_skiphead_sptr gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); +gr_skiphead_sptr gr_make_skiphead(size_t itemsize, + uint64_t nitems_to_skip); -class gr_skiphead : public gr_block { - friend gr_skiphead_sptr gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); - gr_skiphead (size_t itemsize, uint64_t nitems_to_skip); +class gr_skiphead : public gr_block +{ +public: + void set_nitems_to_skip(uint64_t nitems_to_skip); + uint64_t nitems_to_skip() const; + uint64_t nitems_skiped() const; + void reset(); }; diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_cc.cc b/gnuradio-core/src/lib/general/gr_squelch_base_cc.cc deleted file mode 100644 index b32a0a6954..0000000000 --- a/gnuradio-core/src/lib/general/gr_squelch_base_cc.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_squelch_base_cc.h> -#include <gr_io_signature.h> - -gr_squelch_base_cc::gr_squelch_base_cc(const char *name, int ramp, bool gate) : - gr_block(name, - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(1, 1, sizeof(gr_complex))) -{ - set_ramp(ramp); - set_gate(gate); - d_state = ST_MUTED; - d_envelope = d_ramp ? 0.0 : 1.0; - d_ramped = 0; -} - -int gr_squelch_base_cc::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - int j = 0; - - for (int i = 0; i < noutput_items; i++) { - update_state(in[i]); - - // Adjust envelope based on current state - switch(d_state) { - case ST_MUTED: - if (!mute()) - d_state = d_ramp ? ST_ATTACK : ST_UNMUTED; // If not ramping, go straight to unmuted - break; - - case ST_UNMUTED: - if (mute()) - d_state = d_ramp ? ST_DECAY : ST_MUTED; // If not ramping, go straight to muted - break; - - case ST_ATTACK: - d_envelope = 0.5-std::cos(M_PI*(++d_ramped)/d_ramp)/2.0; // FIXME: precalculate window for speed - if (d_ramped >= d_ramp) { // use >= in case d_ramp is set to lower value elsewhere - d_state = ST_UNMUTED; - d_envelope = 1.0; - } - break; - - case ST_DECAY: - d_envelope = 0.5-std::cos(M_PI*(--d_ramped)/d_ramp)/2.0; // FIXME: precalculate window for speed - if (d_ramped == 0.0) - d_state = ST_MUTED; - break; - }; - - // If unmuted, copy input times envelope to output - // Otherwise, if not gating, copy zero to output - if (d_state != ST_MUTED) - out[j++] = in[i]*gr_complex(d_envelope, 0.0); - else - if (!d_gate) - out[j++] = 0.0; - } - - consume_each(noutput_items); // Use all the inputs - return j; // But only report outputs copied -} diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_cc.h b/gnuradio-core/src/lib/general/gr_squelch_base_cc.h deleted file mode 100644 index f1814473fb..0000000000 --- a/gnuradio-core/src/lib/general/gr_squelch_base_cc.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SQUELCH_BASE_CC_H -#define INCLUDED_GR_SQUELCH_BASE_CC_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class GR_CORE_API gr_squelch_base_cc : public gr_block -{ -private: - int d_ramp; - int d_ramped; - bool d_gate; - double d_envelope; - enum { ST_MUTED, ST_ATTACK, ST_UNMUTED, ST_DECAY } d_state; - -protected: - virtual void update_state(const gr_complex &sample) {}; - virtual bool mute() const { return false; }; - -public: - gr_squelch_base_cc(const char *name, int ramp, bool gate); - - int ramp() const { return d_ramp; } - void set_ramp(int ramp) { d_ramp = ramp; } - bool gate() const { return d_gate; } - void set_gate(bool gate) { d_gate = gate; } - bool unmuted() const { return (d_state == ST_UNMUTED || d_state == ST_ATTACK); } - - virtual std::vector<float> squelch_range() const = 0; - - 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_GR_SQUELCH_BASE_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_cc.i b/gnuradio-core/src/lib/general/gr_squelch_base_cc.i deleted file mode 100644 index 6501b7d2bf..0000000000 --- a/gnuradio-core/src/lib/general/gr_squelch_base_cc.i +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gr_block.h> - -class gr_squelch_base_cc : public gr_block -{ -private: - enum { ST_MUTED, ST_ATTACK, ST_UNMUTED, ST_DECAY } d_state; - -public: - gr_squelch_base_cc(const char *name, int ramp, bool gate); - - int ramp() const { return d_ramp; } - void set_ramp(int ramp) { d_ramp = ramp; } - bool gate() const { return d_gate; } - void set_gate(bool gate) { d_gate = gate; } - bool unmuted() const { return (d_state == ST_UNMUTED || d_state == ST_ATTACK); } - - virtual std::vector<float> squelch_range() const = 0; -}; diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_ff.cc b/gnuradio-core/src/lib/general/gr_squelch_base_ff.cc deleted file mode 100644 index 4bf8cff971..0000000000 --- a/gnuradio-core/src/lib/general/gr_squelch_base_ff.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_squelch_base_ff.h> -#include <gr_io_signature.h> - -gr_squelch_base_ff::gr_squelch_base_ff(const char *name, int ramp, bool gate) : - gr_block(name, - gr_make_io_signature(1, 1, sizeof(float)), - gr_make_io_signature(1, 1, sizeof(float))) -{ - set_ramp(ramp); - set_gate(gate); - d_state = ST_MUTED; - d_envelope = d_ramp ? 0.0 : 1.0; - d_ramped = 0; -} - -int gr_squelch_base_ff::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - int j = 0; - - for (int i = 0; i < noutput_items; i++) { - update_state(in[i]); - - // Adjust envelope based on current state - switch(d_state) { - case ST_MUTED: - if (!mute()) - d_state = d_ramp ? ST_ATTACK : ST_UNMUTED; // If not ramping, go straight to unmuted - break; - - case ST_UNMUTED: - if (mute()) - d_state = d_ramp ? ST_DECAY : ST_MUTED; // If not ramping, go straight to muted - break; - - case ST_ATTACK: - d_envelope = 0.5-std::cos(M_PI*(++d_ramped)/d_ramp)/2.0; // FIXME: precalculate window for speed - if (d_ramped >= d_ramp) { // use >= in case d_ramp is set to lower value elsewhere - d_state = ST_UNMUTED; - d_envelope = 1.0; - } - break; - - case ST_DECAY: - d_envelope = 0.5-std::cos(M_PI*(--d_ramped)/d_ramp)/2.0; // FIXME: precalculate window for speed - if (d_ramped == 0.0) - d_state = ST_MUTED; - break; - }; - - // If unmuted, copy input times envelope to output - // Otherwise, if not gating, copy zero to output - if (d_state != ST_MUTED) - out[j++] = in[i]*d_envelope; - else - if (!d_gate) - out[j++] = 0.0; - } - - consume_each(noutput_items); // Use all the inputs - return j; // But only report outputs copied -} diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_ff.h b/gnuradio-core/src/lib/general/gr_squelch_base_ff.h deleted file mode 100644 index eb52635b45..0000000000 --- a/gnuradio-core/src/lib/general/gr_squelch_base_ff.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SQUELCH_BASE_FF_H -#define INCLUDED_GR_SQUELCH_BASE_FF_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class GR_CORE_API gr_squelch_base_ff : public gr_block -{ -private: - int d_ramp; - int d_ramped; - bool d_gate; - double d_envelope; - enum { ST_MUTED, ST_ATTACK, ST_UNMUTED, ST_DECAY } d_state; - -protected: - virtual void update_state(const float &sample) {}; - virtual bool mute() const { return false; }; - -public: - gr_squelch_base_ff(const char *name, int ramp, bool gate); - - int ramp() const { return d_ramp; } - void set_ramp(int ramp) { d_ramp = ramp; } - bool gate() const { return d_gate; } - void set_gate(bool gate) { d_gate = gate; } - bool unmuted() const { return (d_state == ST_UNMUTED || d_state == ST_ATTACK); } - - virtual std::vector<float> squelch_range() const = 0; - - 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_GR_SQUELCH_BASE_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_ff.i b/gnuradio-core/src/lib/general/gr_squelch_base_ff.i deleted file mode 100644 index a4e5c7115c..0000000000 --- a/gnuradio-core/src/lib/general/gr_squelch_base_ff.i +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gr_block.h> - -class gr_squelch_base_ff : public gr_block -{ -private: - enum { ST_MUTED, ST_ATTACK, ST_UNMUTED, ST_DECAY } d_state; - -public: - gr_squelch_base_ff(const char *name, int ramp, bool gate); - - int ramp() const { return d_ramp; } - void set_ramp(int ramp) { d_ramp = ramp; } - bool gate() const { return d_gate; } - void set_gate(bool gate) { d_gate = gate; } - bool unmuted() const { return (d_state == ST_UNMUTED || d_state == ST_ATTACK); } - - virtual std::vector<float> squelch_range() const = 0; -}; diff --git a/gnuradio-core/src/lib/general/gr_stream_mux.cc b/gnuradio-core/src/lib/general/gr_stream_mux.cc deleted file mode 100644 index 978d960b20..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_mux.cc +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_stream_mux.h> -#include <gr_io_signature.h> -#include <string.h> -#include <cstdio> - -#define VERBOSE 0 - -gr_stream_mux_sptr -gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths) -{ - return gnuradio::get_initial_sptr(new gr_stream_mux (itemsize, lengths)); -} - -gr_stream_mux::gr_stream_mux (size_t itemsize, const std::vector<int> &lengths) - : gr_block ("stream_mux", - gr_make_io_signature (1, -1, itemsize), - gr_make_io_signature (1, 1, itemsize)), - d_itemsize(itemsize), - d_stream(0), - d_residual(0), - d_lengths(lengths) -{ - if(d_lengths[d_stream] == 0) { - increment_stream(); - } - d_residual = d_lengths[d_stream]; -} - -gr_stream_mux::~gr_stream_mux(void) -{ -} - -void -gr_stream_mux::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size (); - for (unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = (d_lengths[i] == 0 ? 0 : 1); -} - -void gr_stream_mux::increment_stream() -{ - do { - d_stream = (d_stream+1) % d_lengths.size(); - } while(d_lengths[d_stream] == 0); - - d_residual = d_lengths[d_stream]; -} - -int -gr_stream_mux::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - char *out = (char *) output_items[0]; - const char *in; - int out_index = 0; - std::vector<int> input_index(d_lengths.size(), 0); - - if(VERBOSE) { - printf("mux: nouput_items: %d d_stream: %d\n", noutput_items, d_stream); - for(size_t i = 0; i < d_lengths.size(); i++) - printf("\tninput_items[%zu]: %d\n", i, ninput_items[i]); - } - - while (1) { - int r = std::min(noutput_items - out_index, - std::min(d_residual, - ninput_items[d_stream] - input_index[d_stream])); - if(VERBOSE) { - printf("mux: r=%d\n", r); - printf("\tnoutput_items - out_index: %d\n", - noutput_items - out_index); - printf("\td_residual: %d\n", - d_residual); - printf("\tninput_items[d_stream] - input_index[d_stream]: %d\n", - ninput_items[d_stream] - input_index[d_stream]); - } - - if(r <= 0) { - return out_index; - } - - in = (const char *) input_items[d_stream] + input_index[d_stream]*d_itemsize; - - memcpy(&out[out_index*d_itemsize], in, r*d_itemsize); - out_index += r; - input_index[d_stream] += r; - d_residual -= r; - - consume(d_stream, r); - - if(d_residual == 0) { - increment_stream(); - } - } -} diff --git a/gnuradio-core/src/lib/general/gr_stream_mux.h b/gnuradio-core/src/lib/general/gr_stream_mux.h deleted file mode 100644 index 742bf082d1..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_mux.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_STREAM_MUX_H -#define INCLUDED_GR_STREAM_MUX_H - - -#include <gr_core_api.h> -#include <gr_block.h> -#include <vector> - -/*! - * \brief Creates a stream muxing block to multiplex many streams into - * one with a specified format. - * \ingroup converter_blk - * - * \param itemsize the item size of the stream - * \param length a vector (list/tuple) specifying the number of - * items from each stream the mux together. - * Warning: this requires that at least as many items - * per stream are available or the system will wait - * indefinitely for the items. - * - */ -class gr_stream_mux; -typedef boost::shared_ptr<gr_stream_mux> gr_stream_mux_sptr; - - - -GR_CORE_API gr_stream_mux_sptr -gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths); - - -/*! - * \brief Stream muxing block to multiplex many streams into - * one with a specified format. - * - * Muxes N streams together producing an output stream that - * contains N0 items from the first stream, N1 items from the second, - * etc. and repeats: - * - * [N0, N1, N2, ..., Nm, N0, N1, ...] - */ - -class GR_CORE_API gr_stream_mux : public gr_block -{ - friend GR_CORE_API gr_stream_mux_sptr - gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths); - - protected: - gr_stream_mux (size_t itemsize, const std::vector<int> &lengths); - - private: - size_t d_itemsize; - unsigned int d_stream; // index of currently selected stream - int d_residual; // number if items left to put into current stream - gr_vector_int d_lengths; // number if items to pack per stream - - void increment_stream(); - - public: - ~gr_stream_mux(void); - - void forecast (int noutput_items, gr_vector_int &ninput_items_required); - - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - - -#endif diff --git a/gnuradio-core/src/lib/general/gr_stream_mux.i b/gnuradio-core/src/lib/general/gr_stream_mux.i deleted file mode 100644 index 7cc116a23b..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_mux.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <vector> - -GR_SWIG_BLOCK_MAGIC(gr,stream_mux) - -gr_stream_mux_sptr -gr_make_stream_mux (size_t itemsize, - const std::vector<int> &lengths); - -class gr_stream_mux : public gr_block -{ - protected: - gr_make_stream_mux (size_t itemsize, - const std::vector<int> &lengths); - - public: - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; diff --git a/gnuradio-core/src/lib/general/gr_stream_to_streams.cc b/gnuradio-core/src/lib/general/gr_stream_to_streams.cc deleted file mode 100644 index de72adb1dd..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_to_streams.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_stream_to_streams.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_stream_to_streams_sptr -gr_make_stream_to_streams (size_t item_size, size_t nstreams) -{ - return gnuradio::get_initial_sptr(new gr_stream_to_streams (item_size, nstreams)); -} - -gr_stream_to_streams::gr_stream_to_streams (size_t item_size, size_t nstreams) - : gr_sync_decimator ("stream_to_streams", - gr_make_io_signature (1, 1, item_size), - gr_make_io_signature (nstreams, - nstreams, item_size), - nstreams) -{ -} - -int -gr_stream_to_streams::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t item_size = output_signature()->sizeof_stream_item (0); - - const char *in = (const char *) input_items[0]; - char **outv = (char **) &output_items[0]; - int nstreams = output_items.size(); - - for (int i = 0; i < noutput_items; i++){ - for (int j = 0; j < nstreams; j++){ - memcpy(outv[j], in, item_size); - outv[j] += item_size; - in += item_size; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_stream_to_streams.h b/gnuradio-core/src/lib/general/gr_stream_to_streams.h deleted file mode 100644 index 117f57bf5e..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_to_streams.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_STREAM_TO_STREAMS_H -#define INCLUDED_GR_STREAM_TO_STREAMS_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_stream_to_streams; -typedef boost::shared_ptr<gr_stream_to_streams> gr_stream_to_streams_sptr; - -GR_CORE_API gr_stream_to_streams_sptr -gr_make_stream_to_streams (size_t item_size, size_t nstreams); - - -/*! - * \brief convert a stream of items into a N streams of items - * \ingroup slicedice_blk - * - * Converts a stream of N items into N streams of 1 item. - * Repeat ad infinitum. - */ -class GR_CORE_API gr_stream_to_streams : public gr_sync_decimator -{ - friend GR_CORE_API gr_stream_to_streams_sptr - gr_make_stream_to_streams (size_t item_size, size_t nstreams); - - protected: - gr_stream_to_streams (size_t item_size, size_t nstreams); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_STREAM_TO_STREAMS_H */ diff --git a/gnuradio-core/src/lib/general/gr_stream_to_streams.i b/gnuradio-core/src/lib/general/gr_stream_to_streams.i deleted file mode 100644 index 4d324372ee..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_to_streams.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,stream_to_streams) - -gr_stream_to_streams_sptr -gr_make_stream_to_streams (size_t itemsize, size_t nstreams); - -class gr_stream_to_streams : public gr_sync_decimator -{ - protected: - gr_stream_to_streams (size_t itemsize, size_t nstreams); - - public: -}; diff --git a/gnuradio-core/src/lib/general/gr_stream_to_vector.cc b/gnuradio-core/src/lib/general/gr_stream_to_vector.cc deleted file mode 100644 index d38cdd4348..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_to_vector.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_stream_to_vector.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_stream_to_vector_sptr -gr_make_stream_to_vector (size_t item_size, size_t nitems_per_block) -{ - return gnuradio::get_initial_sptr(new gr_stream_to_vector (item_size, nitems_per_block)); -} - -gr_stream_to_vector::gr_stream_to_vector (size_t item_size, size_t nitems_per_block) - : gr_sync_decimator ("stream_to_vector", - gr_make_io_signature (1, 1, item_size), - gr_make_io_signature (1, 1, item_size * nitems_per_block), - nitems_per_block) -{ -} - -int -gr_stream_to_vector::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t block_size = output_signature()->sizeof_stream_item (0); - - const char *in = (const char *) input_items[0]; - char *out = (char *) output_items[0]; - - memcpy (out, in, noutput_items * block_size); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_stream_to_vector.h b/gnuradio-core/src/lib/general/gr_stream_to_vector.h deleted file mode 100644 index 362349965f..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_to_vector.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_STREAM_TO_VECTOR_H -#define INCLUDED_GR_STREAM_TO_VECTOR_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_stream_to_vector; -typedef boost::shared_ptr<gr_stream_to_vector> gr_stream_to_vector_sptr; - -GR_CORE_API gr_stream_to_vector_sptr -gr_make_stream_to_vector (size_t item_size, size_t nitems_per_block); - - -/*! - * \brief convert a stream of items into a stream of blocks containing nitems_per_block - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_stream_to_vector : public gr_sync_decimator -{ - friend GR_CORE_API gr_stream_to_vector_sptr - gr_make_stream_to_vector (size_t item_size, size_t nitems_per_block); - - protected: - gr_stream_to_vector (size_t item_size, size_t nitems_per_block); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_STREAM_TO_VECTOR_H */ diff --git a/gnuradio-core/src/lib/general/gr_stream_to_vector.i b/gnuradio-core/src/lib/general/gr_stream_to_vector.i deleted file mode 100644 index ef867012ad..0000000000 --- a/gnuradio-core/src/lib/general/gr_stream_to_vector.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,stream_to_vector) - -gr_stream_to_vector_sptr -gr_make_stream_to_vector (size_t itemsize, size_t nitems_per_block); - -class gr_stream_to_vector : public gr_sync_decimator -{ - protected: - gr_stream_to_vector (size_t itemsize, size_t nitems_per_block); - - public: -}; diff --git a/gnuradio-core/src/lib/general/gr_streams_to_stream.cc b/gnuradio-core/src/lib/general/gr_streams_to_stream.cc deleted file mode 100644 index 8bce747227..0000000000 --- a/gnuradio-core/src/lib/general/gr_streams_to_stream.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_streams_to_stream.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_streams_to_stream_sptr -gr_make_streams_to_stream (size_t item_size, size_t nstreams) -{ - return gnuradio::get_initial_sptr(new gr_streams_to_stream (item_size, nstreams)); -} - -gr_streams_to_stream::gr_streams_to_stream (size_t item_size, size_t nstreams) - : gr_sync_interpolator ("streams_to_stream", - gr_make_io_signature (nstreams, nstreams, item_size), - gr_make_io_signature (1, 1, item_size), - nstreams) -{ -} - -int -gr_streams_to_stream::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t item_size = output_signature()->sizeof_stream_item (0); - - const char **inv = (const char **) &input_items[0]; - char *out = (char *) output_items[0]; - int nstreams = input_items.size(); - - assert (noutput_items % nstreams == 0); - int ni = noutput_items / nstreams; - - for (int i = 0; i < ni; i++){ - for (int j = 0; j < nstreams; j++){ - memcpy(out, inv[j], item_size); - out += item_size; - inv[j] += item_size; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_streams_to_stream.h b/gnuradio-core/src/lib/general/gr_streams_to_stream.h deleted file mode 100644 index f636837675..0000000000 --- a/gnuradio-core/src/lib/general/gr_streams_to_stream.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_STREAMS_TO_STREAM_H -#define INCLUDED_GR_STREAMS_TO_STREAM_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_streams_to_stream; -typedef boost::shared_ptr<gr_streams_to_stream> gr_streams_to_stream_sptr; - -GR_CORE_API gr_streams_to_stream_sptr -gr_make_streams_to_stream (size_t item_size, size_t nstreams); - - -/*! - * \brief Convert N streams of 1 item into a 1 stream of N items - * \ingroup slicedice_blk - * - * Convert N streams of 1 item into 1 stream of N items. - * Repeat ad infinitum. - */ -class GR_CORE_API gr_streams_to_stream : public gr_sync_interpolator -{ - friend GR_CORE_API gr_streams_to_stream_sptr - gr_make_streams_to_stream (size_t item_size, size_t nstreams); - - protected: - gr_streams_to_stream (size_t item_size, size_t nstreams); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_STREAMS_TO_STREAM_H */ diff --git a/gnuradio-core/src/lib/general/gr_streams_to_stream.i b/gnuradio-core/src/lib/general/gr_streams_to_stream.i deleted file mode 100644 index a09ded0710..0000000000 --- a/gnuradio-core/src/lib/general/gr_streams_to_stream.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,streams_to_stream) - -gr_streams_to_stream_sptr -gr_make_streams_to_stream (size_t itemsize, size_t nstreams); - -class gr_streams_to_stream : public gr_sync_interpolator -{ - protected: - gr_streams_to_stream (size_t itemsize, size_t nstreams); - - public: -}; diff --git a/gnuradio-core/src/lib/general/gr_streams_to_vector.cc b/gnuradio-core/src/lib/general/gr_streams_to_vector.cc deleted file mode 100644 index cf862ca954..0000000000 --- a/gnuradio-core/src/lib/general/gr_streams_to_vector.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_streams_to_vector.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_streams_to_vector_sptr -gr_make_streams_to_vector (size_t item_size, size_t nstreams) -{ - return gnuradio::get_initial_sptr(new gr_streams_to_vector (item_size, nstreams)); -} - -gr_streams_to_vector::gr_streams_to_vector (size_t item_size, size_t nstreams) - : gr_sync_block ("streams_to_vector", - gr_make_io_signature (nstreams, nstreams, item_size), - gr_make_io_signature (1, 1, nstreams * item_size)) -{ -} - -int -gr_streams_to_vector::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t item_size = input_signature()->sizeof_stream_item(0); - int nstreams = input_items.size(); - - const char **inv = (const char **) &input_items[0]; - char *out = (char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - for (int j = 0; j < nstreams; j++){ - memcpy(out, inv[j], item_size); - inv[j] += item_size; - out += item_size; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_streams_to_vector.h b/gnuradio-core/src/lib/general/gr_streams_to_vector.h deleted file mode 100644 index 1df2890999..0000000000 --- a/gnuradio-core/src/lib/general/gr_streams_to_vector.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_STREAMS_TO_VECTOR_H -#define INCLUDED_GR_STREAMS_TO_VECTOR_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_streams_to_vector; -typedef boost::shared_ptr<gr_streams_to_vector> gr_streams_to_vector_sptr; - -GR_CORE_API gr_streams_to_vector_sptr -gr_make_streams_to_vector (size_t item_size, size_t nstreams); - - -/*! - * \brief convert N streams of items to 1 stream of vector length N - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_streams_to_vector : public gr_sync_block -{ - friend GR_CORE_API gr_streams_to_vector_sptr - gr_make_streams_to_vector (size_t item_size, size_t nstreams); - - protected: - gr_streams_to_vector (size_t item_size, size_t nstreams); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_STREAMS_TO_VECTOR_H */ diff --git a/gnuradio-core/src/lib/general/gr_streams_to_vector.i b/gnuradio-core/src/lib/general/gr_streams_to_vector.i deleted file mode 100644 index 4d5eca45ef..0000000000 --- a/gnuradio-core/src/lib/general/gr_streams_to_vector.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,streams_to_vector) - -gr_streams_to_vector_sptr -gr_make_streams_to_vector (size_t itemsize, size_t nstreams); - -class gr_streams_to_vector : public gr_sync_block -{ - protected: - gr_streams_to_vector (size_t itemsize, size_t nstreams); - - public: -}; diff --git a/gnuradio-core/src/lib/general/gr_stretch_ff.cc b/gnuradio-core/src/lib/general/gr_stretch_ff.cc deleted file mode 100644 index e89eadf8b1..0000000000 --- a/gnuradio-core/src/lib/general/gr_stretch_ff.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_stretch_ff.h> -#include <gr_io_signature.h> - -gr_stretch_ff_sptr -gr_make_stretch_ff(float lo, size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_stretch_ff(lo, vlen)); -} - -gr_stretch_ff::gr_stretch_ff(float lo, size_t vlen) - : gr_sync_block("stretch_ff", - gr_make_io_signature(1, 1, vlen * sizeof(float)), - gr_make_io_signature(1, 1, vlen * sizeof(float))), - d_lo(lo), d_vlen(vlen) -{ -} - -int -gr_stretch_ff::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - for (int count = 0; count < noutput_items; count++) { - float vmax = in[0] - d_lo; - - for (unsigned int i = 1; i < d_vlen; i++) { - float vtmp = in[i] - d_lo; - if (vtmp > vmax) - vmax = vtmp; - } - - if (vmax != 0.0) - for (unsigned int i = 0; i < d_vlen; i++) - out[i] = d_lo * (1.0 - (in[i] - d_lo) / vmax); - else - for (unsigned int i = 0; i < d_vlen; i++) - out[i] = in[i]; - - in += d_vlen; - out += d_vlen; - } - - return noutput_items; -} - diff --git a/gnuradio-core/src/lib/general/gr_stretch_ff.h b/gnuradio-core/src/lib/general/gr_stretch_ff.h deleted file mode 100644 index f592c94a78..0000000000 --- a/gnuradio-core/src/lib/general/gr_stretch_ff.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_STRETCH_FF_H_ -# define INCLUDED_GR_STRETCH_FF_H_ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -/*! - * \brief adjust y-range of an input vector by mapping to range - * (max-of-input, stipulated-min). Primarily for spectral signature - * matching by normalizing spectrum dynamic ranges. - * \ingroup misc_blk - */ - - -class gr_stretch_ff; -typedef boost::shared_ptr<gr_stretch_ff> gr_stretch_ff_sptr; - -GR_CORE_API gr_stretch_ff_sptr gr_make_stretch_ff(float lo, size_t vlen); - -class GR_CORE_API gr_stretch_ff : public gr_sync_block -{ - friend GR_CORE_API gr_stretch_ff_sptr gr_make_stretch_ff(float lo, size_t vlen); - - float d_lo; // the constant - size_t d_vlen; - gr_stretch_ff(float lo, size_t vlen); - - public: - float lo() const { return d_lo; } - void set_lo(float lo) { d_lo = lo; } - size_t vlen() const { return d_vlen; } - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_stretch_ff.i b/gnuradio-core/src/lib/general/gr_stretch_ff.i deleted file mode 100644 index 81366655eb..0000000000 --- a/gnuradio-core/src/lib/general/gr_stretch_ff.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,stretch_ff); - -gr_stretch_ff_sptr gr_make_stretch_ff(float lo, size_t vlen); - -class gr_stretch_ff : public gr_sync_block -{ -private: - gr_stretch_ff(float lo, size_t vlen); -}; - diff --git a/gnuradio-core/src/lib/general/gr_tag_debug.cc b/gnuradio-core/src/lib/general/gr_tag_debug.cc deleted file mode 100644 index ecf1b65e1f..0000000000 --- a/gnuradio-core/src/lib/general/gr_tag_debug.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_tag_debug.h> -#include <gr_io_signature.h> -#include <iostream> -#include <iomanip> - -gr_tag_debug_sptr -gr_make_tag_debug(size_t sizeof_stream_item, const std::string &name) -{ - return gnuradio::get_initial_sptr - (new gr_tag_debug(sizeof_stream_item, name)); -} - -gr_tag_debug::gr_tag_debug(size_t sizeof_stream_item, const std::string &name) - : gr_sync_block("tag_debug", - gr_make_io_signature(1, -1, sizeof_stream_item), - gr_make_io_signature(0, 0, 0)), - d_name(name), d_display(true) -{ -} - -std::vector<gr_tag_t> -gr_tag_debug::current_tags() -{ - gruel::scoped_lock l(d_mutex); - return d_tags; -} - -void -gr_tag_debug::set_display(bool d) -{ - gruel::scoped_lock l(d_mutex); - d_display = d; -} - -int -gr_tag_debug::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gruel::scoped_lock l(d_mutex); - - std::stringstream sout; - if(d_display) { - sout << std::endl - << "----------------------------------------------------------------------"; - sout << std::endl << "Tag Debug: " << d_name << std::endl; - } - - uint64_t abs_N, end_N; - for(size_t i = 0; i < input_items.size(); i++) { - abs_N = nitems_read(i); - end_N = abs_N + (uint64_t)(noutput_items); - - d_tags.clear(); - get_tags_in_range(d_tags, i, abs_N, end_N); - - if(d_display) { - sout << "Input Stream: " << std::setw(2) << std::setfill('0') << i << std::setfill(' ') << std::endl; - for(d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) { - sout << std::setw(10) << "Offset: " << d_tags_itr->offset - << std::setw(10) << "Source: " << (pmt::pmt_is_symbol(d_tags_itr->srcid) ? pmt::pmt_symbol_to_string(d_tags_itr->srcid) : "n/a") - << std::setw(10) << "Key: " << pmt::pmt_symbol_to_string(d_tags_itr->key) - << std::setw(10) << "Value: "; - sout << d_tags_itr->value << std::endl; - } - } - } - - if(d_display) { - sout << "----------------------------------------------------------------------"; - sout << std::endl; - - if(d_tags.size() > 0) - std::cout << sout.str(); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_tag_debug.h b/gnuradio-core/src/lib/general/gr_tag_debug.h deleted file mode 100644 index 57578884a8..0000000000 --- a/gnuradio-core/src/lib/general/gr_tag_debug.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_TAG_DEBUG_H -#define INCLUDED_GR_TAG_DEBUG_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gruel/thread.h> -#include <stddef.h> - -class gr_tag_debug; -typedef boost::shared_ptr<gr_tag_debug> gr_tag_debug_sptr; - -GR_CORE_API gr_tag_debug_sptr -gr_make_tag_debug(size_t sizeof_stream_item, const std::string &name); - -/*! - * \brief Bit bucket that prints out any tag received. - * \ingroup sink_blk - * - * This block collects all tags sent to it on all input ports and - * displays them to stdout in a formatted way. The \p name parameter - * is used to identify which debug sink generated the tag, so when - * connecting a block to this debug sink, an appropriate name is - * something that identifies the input block. - * - * This block otherwise acts as a NULL sink in that items from the - * input stream are ignored. It is designed to be able to attach to - * any block and watch all tags streaming out of that block for - * debugging purposes. - * - * The tags from the last call to this work function are stored and - * can be retrieved using the function 'current_tags'. - */ -class GR_CORE_API gr_tag_debug : public gr_sync_block -{ - private: - friend GR_CORE_API gr_tag_debug_sptr - gr_make_tag_debug(size_t sizeof_stream_item, const std::string &name); - gr_tag_debug(size_t sizeof_stream_item, const std::string &name); - - std::string d_name; - std::vector<gr_tag_t> d_tags; - std::vector<gr_tag_t>::iterator d_tags_itr; - bool d_display; - gruel::mutex d_mutex; - - public: - /*! - * \brief Returns a vector of gr_tag_t items as of the last call to - * work. - */ - std::vector<gr_tag_t> current_tags(); - - /*! - * \brief Set the display of tags to stdout on/off. - */ - void set_display(bool d); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_TAG_DEBUG_H */ diff --git a/gnuradio-core/src/lib/general/gr_tag_debug.i b/gnuradio-core/src/lib/general/gr_tag_debug.i deleted file mode 100644 index 3af1bdcfef..0000000000 --- a/gnuradio-core/src/lib/general/gr_tag_debug.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,tag_debug) - -%include <gr_tags.i> - -gr_tag_debug_sptr -gr_make_tag_debug(size_t sizeof_stream_item, const std::string &name); - -class gr_tag_debug : public gr_sync_block -{ -public: - std::vector<gr_tag_t> current_tags(); - void set_display(bool d); -}; diff --git a/gnuradio-core/src/lib/general/gr_threshold_ff.cc b/gnuradio-core/src/lib/general/gr_threshold_ff.cc deleted file mode 100644 index 952613151f..0000000000 --- a/gnuradio-core/src/lib/general/gr_threshold_ff.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// WARNING: this file is machine generated. Edits will be over written - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_threshold_ff.h> -#include <gr_io_signature.h> - -gr_threshold_ff_sptr -gr_make_threshold_ff (float lo, float hi, float initial_state) -{ - return gnuradio::get_initial_sptr(new gr_threshold_ff (lo, hi, initial_state)); -} - -gr_threshold_ff::gr_threshold_ff (float lo, float hi, float initial_state) - : gr_sync_block ("threshold_ff", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (float))), - d_lo (lo), d_hi (hi), d_last_state (initial_state) -{ -} - -int -gr_threshold_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - - for(int i=0; i<noutput_items; i++) { - if (in[i] > d_hi) { - out[i] = 1.0; - d_last_state = 1.0; - } else if (in[i] < d_lo) { - out[i] = 0.0; - d_last_state = 0.0; - } else - out[i] = d_last_state; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_threshold_ff.h b/gnuradio-core/src/lib/general/gr_threshold_ff.h deleted file mode 100644 index 678f8b1d2d..0000000000 --- a/gnuradio-core/src/lib/general/gr_threshold_ff.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_THRESHOLD_FF_H -#define INCLUDED_GR_THRESHOLD_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_threshold_ff; -typedef boost::shared_ptr<gr_threshold_ff> gr_threshold_ff_sptr; - -GR_CORE_API gr_threshold_ff_sptr gr_make_threshold_ff (float lo, float hi, float initial_state=0); - -/*! - * \brief Please fix my documentation - * \ingroup misc_blk - */ -class GR_CORE_API gr_threshold_ff : public gr_sync_block -{ - friend GR_CORE_API gr_threshold_ff_sptr gr_make_threshold_ff (float lo, float hi, float initial_state); - - float d_lo,d_hi; // the constant - float d_last_state; - gr_threshold_ff (float lo, float hi, float initial_state); - - public: - float lo () const { return d_lo; } - void set_lo (float lo) { d_lo = lo; } - float hi () const { return d_hi; } - void set_hi (float hi) { d_hi = hi; } - float last_state () const { return d_last_state; } - void set_last_state (float last_state) { d_last_state = last_state; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_threshold_ff.i b/gnuradio-core/src/lib/general/gr_threshold_ff.i deleted file mode 100644 index 7584feea8a..0000000000 --- a/gnuradio-core/src/lib/general/gr_threshold_ff.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,threshold_ff); - -gr_threshold_ff_sptr gr_make_threshold_ff (float lo, float hi, float initial_state=0); - -class gr_threshold_ff : public gr_sync_block -{ - private: - gr_threshold_ff (float lo, float hi, float initial_state); - - public: - float lo () const { return d_lo; } - void set_lo (float lo) { d_lo = lo; } - float hi () const { return d_hi; } - void set_hi (float hi) { d_hi = hi; } - float last_state () const { return d_last_state; } - void set_last_state (float last_state) { d_last_state = last_state; } -}; diff --git a/gnuradio-core/src/lib/general/gr_throttle.cc b/gnuradio-core/src/lib/general/gr_throttle.cc deleted file mode 100644 index 040ab52205..0000000000 --- a/gnuradio-core/src/lib/general/gr_throttle.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005-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 <gr_throttle.h> -#include <gr_io_signature.h> -#include <cstring> -#include <boost/thread/thread.hpp> - -class gr_throttle_impl : public gr_throttle{ -public: - gr_throttle_impl(size_t itemsize): - gr_sync_block("throttle", - gr_make_io_signature(1, 1, itemsize), - gr_make_io_signature(1, 1, itemsize)), - d_itemsize(itemsize) - { - /* NOP */ - } - - void set_sample_rate(double rate){ - //changing the sample rate performs a reset of state params - d_start = boost::get_system_time(); - d_total_samples = 0; - d_samps_per_tick = rate/boost::posix_time::time_duration::ticks_per_second(); - d_samps_per_us = rate/1e6; - } - - int work ( - int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items - ){ - //calculate the expected number of samples to have passed through - boost::system_time now = boost::get_system_time(); - boost::int64_t ticks = (now - d_start).ticks(); - uint64_t expected_samps = uint64_t(d_samps_per_tick*ticks); - - //if the expected samples was less, we need to throttle back - if (d_total_samples > expected_samps){ - boost::this_thread::sleep(boost::posix_time::microseconds( - long((d_total_samples - expected_samps)/d_samps_per_us) - )); - } - - //copy all samples output[i] <= input[i] - const char *in = (const char *) input_items[0]; - char *out = (char *) output_items[0]; - std::memcpy(out, in, noutput_items * d_itemsize); - d_total_samples += noutput_items; - return noutput_items; - } - -private: - boost::system_time d_start; - size_t d_itemsize; - uint64_t d_total_samples; - double d_samps_per_tick, d_samps_per_us; -}; - -gr_throttle::sptr -gr_make_throttle(size_t itemsize, double samples_per_sec) -{ - gr_throttle::sptr throttle(new gr_throttle_impl(itemsize)); - throttle->set_sample_rate(samples_per_sec); - return throttle; -} diff --git a/gnuradio-core/src/lib/general/gr_throttle.h b/gnuradio-core/src/lib/general/gr_throttle.h deleted file mode 100644 index 876d6d8269..0000000000 --- a/gnuradio-core/src/lib/general/gr_throttle.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005-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_GR_THROTTLE_H -#define INCLUDED_GR_THROTTLE_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -/*! - * \brief throttle flow of samples such that the average rate does not exceed samples_per_sec. - * \ingroup misc_blk - * - * input: one stream of itemsize; output: one stream of itemsize - * - * N.B. this should only be used in GUI apps where there is no other - * rate limiting block. It is not intended nor effective at precisely - * controlling the rate of samples. That should be controlled by a - * source or sink tied to sample clock. E.g., a USRP or audio card. - */ -class GR_CORE_API gr_throttle : virtual public gr_sync_block -{ -public: - typedef boost::shared_ptr<gr_throttle> sptr; - - //! Sets the sample rate in samples per second - virtual void set_sample_rate(double rate) = 0; -}; - -GR_CORE_API gr_throttle::sptr gr_make_throttle(size_t itemsize, double samples_per_sec); - -#endif /* INCLUDED_GR_THROTTLE_H */ diff --git a/gnuradio-core/src/lib/general/gr_throttle.i b/gnuradio-core/src/lib/general/gr_throttle.i deleted file mode 100644 index 5ba32de6ed..0000000000 --- a/gnuradio-core/src/lib/general/gr_throttle.i +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005-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 <gr_throttle.h> -%} - -GR_SWIG_BLOCK_MAGIC(gr,throttle); - -%include <gr_throttle.h> diff --git a/gnuradio-core/src/lib/general/gr_transcendental.cc b/gnuradio-core/src/lib/general/gr_transcendental.cc deleted file mode 100644 index c1482491ba..0000000000 --- a/gnuradio-core/src/lib/general/gr_transcendental.cc +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gr_transcendental.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <complex> //complex math -#include <cmath> //real math -#include <map> - -/*********************************************************************** - * work function creation and registration - **********************************************************************/ -typedef int(*work_fcn_type)(int, gr_vector_const_void_star &, gr_vector_void_star &); -struct map_val_type{ - work_fcn_type work_fcn; - size_t io_size; -}; -typedef std::map<std::string, map_val_type> map_type; - -//construct map on first use idiom -static map_type &get_map(void){ - static map_type map; - return map; -} - -//static initialization of this object registers a function -struct gr_transcendental_registrant{ - gr_transcendental_registrant( - const std::string &key, - const work_fcn_type &work_fcn, - const size_t io_size - ){ - map_val_type val; - val.work_fcn = work_fcn; - val.io_size = io_size; - get_map()[key] = val; - } -}; - -//macro to create a work function and register it -#define REGISTER_FUNCTION(__fcn__, __type__, __key__) \ - static int __key__ ## _work( \ - int noutput_items, \ - gr_vector_const_void_star &input_items, \ - gr_vector_void_star &output_items \ - ){ \ - const __type__ *in = (const __type__ *) input_items[0]; \ - __type__ *out = (__type__ *) output_items[0]; \ - for (size_t i = 0; i < size_t(noutput_items); i++){ \ - out[i] = std::__fcn__(in[i]); \ - } \ - return noutput_items; \ - } \ - gr_transcendental_registrant __key__ ## _registrant(#__key__, &__key__ ## _work, sizeof(__type__)); - -//register work functions for real types -#define REGISTER_REAL_FUNCTIONS(__fcn__) \ - REGISTER_FUNCTION(__fcn__, float, __fcn__ ## _float) \ - REGISTER_FUNCTION(__fcn__, double, __fcn__ ## _double) - -//register work functions for complex types -#define REGISTER_COMPLEX_FUNCTIONS(__fcn__) \ - REGISTER_FUNCTION(__fcn__, std::complex<float>, __fcn__ ## _complex_float) \ - REGISTER_FUNCTION(__fcn__, std::complex<double>, __fcn__ ## _complex_double) - -//register both complex and real -#define REGISTER_FUNCTIONS(__fcn__) \ - REGISTER_REAL_FUNCTIONS(__fcn__) \ - REGISTER_COMPLEX_FUNCTIONS(__fcn__) - -//create and register transcendental work functions -REGISTER_FUNCTIONS(cos) -REGISTER_FUNCTIONS(sin) -REGISTER_FUNCTIONS(tan) -REGISTER_REAL_FUNCTIONS(acos) -REGISTER_REAL_FUNCTIONS(asin) -REGISTER_REAL_FUNCTIONS(atan) -REGISTER_FUNCTIONS(cosh) -REGISTER_FUNCTIONS(sinh) -REGISTER_FUNCTIONS(tanh) -REGISTER_FUNCTIONS(exp) -REGISTER_FUNCTIONS(log) -REGISTER_FUNCTIONS(log10) -REGISTER_FUNCTIONS(sqrt) - -/*********************************************************************** - * implementation block simply calls into the function pointer - **********************************************************************/ -class gr_transcendental_impl : public gr_transcendental{ -public: - gr_transcendental_impl( - const work_fcn_type &work_fcn, const size_t io_size - ): - gr_sync_block( - "transcendental", - gr_make_io_signature(1, 1, io_size), - gr_make_io_signature(1, 1, io_size) - ), - _work_fcn(work_fcn) - { - // NOP - } - - int work( - int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items - ){ - return _work_fcn(noutput_items, input_items, output_items); - } - -private: - const work_fcn_type &_work_fcn; -}; - -/*********************************************************************** - * factory function to make transcendental block - **********************************************************************/ -gr_transcendental::sptr gr_make_transcendental( - const std::string &name, - const std::string &type -){ - //search for an entry in the map - const std::string key = name + "_" + type; - const bool has_key = get_map().count(key) != 0; - if (!has_key) throw std::runtime_error( - "could not find transcendental function for " + key - ); - - //make a new block with found work function - return gr_transcendental::sptr(new gr_transcendental_impl( - get_map()[key].work_fcn, get_map()[key].io_size - )); -} diff --git a/gnuradio-core/src/lib/general/gr_transcendental.h b/gnuradio-core/src/lib/general/gr_transcendental.h deleted file mode 100644 index 9841a53e95..0000000000 --- a/gnuradio-core/src/lib/general/gr_transcendental.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_TRANSCENDENTAL_H -#define INCLUDED_GR_TRANSCENDENTAL_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <string> - -/*! - * \brief A block that performs various transcendental math operations. - * - * Possible function names can be found in the cmath library. - * IO may be either complex or real, double or single precision. - * - * Possible type strings: float, double, complex_float, complex_double - * - * output[i] = trans_fcn(input[i]) - */ -class GR_CORE_API gr_transcendental : virtual public gr_sync_block{ -public: - typedef boost::shared_ptr<gr_transcendental> sptr; -}; - -GR_CORE_API gr_transcendental::sptr gr_make_transcendental( - const std::string &name, - const std::string &type = "float" -); - -#endif /* INCLUDED_GR_TRANSCENDENTAL_H */ diff --git a/gnuradio-core/src/lib/general/gr_transcendental.i b/gnuradio-core/src/lib/general/gr_transcendental.i deleted file mode 100644 index 6acdb10b7e..0000000000 --- a/gnuradio-core/src/lib/general/gr_transcendental.i +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -//////////////////////////////////////////////////////////////////////// -// block headers -//////////////////////////////////////////////////////////////////////// -%{ -#include <gr_transcendental.h> -%} - -//////////////////////////////////////////////////////////////////////// -// block magic -//////////////////////////////////////////////////////////////////////// -GR_SWIG_BLOCK_MAGIC(gr,transcendental) -%include <gr_transcendental.h> diff --git a/gnuradio-core/src/lib/general/gr_uchar_to_float.cc b/gnuradio-core/src/lib/general/gr_uchar_to_float.cc deleted file mode 100644 index 981a934400..0000000000 --- a/gnuradio-core/src/lib/general/gr_uchar_to_float.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_uchar_to_float.h> -#include <gr_io_signature.h> -#include <gri_uchar_to_float.h> - -gr_uchar_to_float_sptr -gr_make_uchar_to_float () -{ - return gnuradio::get_initial_sptr(new gr_uchar_to_float ()); -} - -gr_uchar_to_float::gr_uchar_to_float () - : gr_sync_block ("gr_uchar_to_float", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (float))) -{ -} - -int -gr_uchar_to_float::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - float *out = (float *) output_items[0]; - - gri_uchar_to_float (in, out, noutput_items); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_uchar_to_float.h b/gnuradio-core/src/lib/general/gr_uchar_to_float.h deleted file mode 100644 index c02601cca6..0000000000 --- a/gnuradio-core/src/lib/general/gr_uchar_to_float.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_UCHAR_TO_FLOAT_H -#define INCLUDED_GR_UCHAR_TO_FLOAT_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_uchar_to_float; -typedef boost::shared_ptr<gr_uchar_to_float> gr_uchar_to_float_sptr; - -GR_CORE_API gr_uchar_to_float_sptr -gr_make_uchar_to_float (); - -/*! - * \brief Convert stream of unsigned chars to a stream of float - * \ingroup converter_blk - */ - -class GR_CORE_API gr_uchar_to_float : public gr_sync_block -{ - friend GR_CORE_API gr_uchar_to_float_sptr gr_make_uchar_to_float (); - gr_uchar_to_float (); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_UCHAR_TO_FLOAT_H */ diff --git a/gnuradio-core/src/lib/general/gr_uchar_to_float.i b/gnuradio-core/src/lib/general/gr_uchar_to_float.i deleted file mode 100644 index b6cc353296..0000000000 --- a/gnuradio-core/src/lib/general/gr_uchar_to_float.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,uchar_to_float) - -gr_uchar_to_float_sptr gr_make_uchar_to_float (); - -class gr_uchar_to_float : public gr_sync_block -{ - gr_uchar_to_float (); -}; diff --git a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.cc b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.cc deleted file mode 100644 index 00b88e9724..0000000000 --- a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_unpack_k_bits_bb.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <iostream> - -gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (unsigned k) -{ - return gnuradio::get_initial_sptr(new gr_unpack_k_bits_bb (k)); -} - - -gr_unpack_k_bits_bb::gr_unpack_k_bits_bb (unsigned k) - : gr_sync_interpolator ("unpack_k_bits_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char)), - k), - d_k (k) -{ - if (d_k == 0) - throw std::out_of_range ("interpolation must be > 0"); -} - -gr_unpack_k_bits_bb::~gr_unpack_k_bits_bb () -{ -} - -int -gr_unpack_k_bits_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - int n = 0; - for (unsigned int i = 0; i < noutput_items/d_k; i++){ - unsigned int t = in[i]; - for (int j = d_k - 1; j >= 0; j--) - out[n++] = (t >> j) & 0x01; - } - - assert(n == noutput_items); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h deleted file mode 100644 index c3ea28d3fa..0000000000 --- a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_UNPACK_K_BITS_BB_H -#define INCLUDED_GR_UNPACK_K_BITS_BB_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_unpack_k_bits_bb; -typedef boost::shared_ptr<gr_unpack_k_bits_bb> gr_unpack_k_bits_bb_sptr; -GR_CORE_API gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (unsigned k); - -class gr_unpack_k_bits_bb; - -/*! - * \brief Converts a byte with k relevent bits to k output bytes with 1 bit in the LSB. - * \ingroup converter_blk - */ -class GR_CORE_API gr_unpack_k_bits_bb : public gr_sync_interpolator -{ - private: - friend GR_CORE_API gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (unsigned k); - - gr_unpack_k_bits_bb (unsigned k); - - unsigned d_k; // number of relevent bits to unpack into k output bytes - - public: - ~gr_unpack_k_bits_bb (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i deleted file mode 100644 index de0f4b33e7..0000000000 --- a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,unpack_k_bits_bb) - -gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (int k) throw(std::exception); - -class gr_unpack_k_bits_bb : public gr_sync_interpolator -{ - private: - gr_unpack_k_bits_bb (int k); - - public: - ~gr_unpack_k_bits_bb (); -}; diff --git a/gnuradio-core/src/lib/general/gr_vco.h b/gnuradio-core/src/lib/general/gr_vco.h deleted file mode 100644 index 3ceaf15dd4..0000000000 --- a/gnuradio-core/src/lib/general/gr_vco.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GR_VCO_H_ -#define _GR_VCO_H_ - - -#include <vector> -#include <gr_sincos.h> -#include <cmath> -#include <gr_complex.h> - -/*! - * \brief base class template for Voltage Controlled Oscillator (VCO) - * \ingroup misc - */ - -//FIXME Eventually generalize this to fixed point - -template<class o_type, class i_type> -class gr_vco { -public: - gr_vco () : d_phase (0) {} - - virtual ~gr_vco () {} - - // radians - void set_phase (double angle) { - d_phase = angle; - } - - void adjust_phase (double delta_phase) { - d_phase += delta_phase; - if (fabs (d_phase) > M_PI){ - - while (d_phase > M_PI) - d_phase -= 2*M_PI; - - while (d_phase < -M_PI) - d_phase += 2*M_PI; - } - } - - double get_phase () const { return d_phase; } - - // compute sin and cos for current phase angle - void sincos (float *sinx, float *cosx) const; - - // compute cos or sin for current phase angle - float cos () const { return std::cos (d_phase); } - float sin () const { return std::sin (d_phase); } - - // compute a block at a time - void cos (float *output, const float *input, int noutput_items, double k, double ampl = 1.0); - -protected: - double d_phase; -}; - -template<class o_type, class i_type> -void -gr_vco<o_type,i_type>::sincos (float *sinx, float *cosx) const -{ - gr_sincosf (d_phase, sinx, cosx); -} - -template<class o_type, class i_type> -void -gr_vco<o_type,i_type>::cos (float *output, const float *input, int noutput_items, double k, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = cos() * ampl; - adjust_phase(input[i] * k); - } -} -#endif /* _GR_VCO_H_ */ diff --git a/gnuradio-core/src/lib/general/gr_vco_f.cc b/gnuradio-core/src/lib/general/gr_vco_f.cc deleted file mode 100644 index 0899bc77e0..0000000000 --- a/gnuradio-core/src/lib/general/gr_vco_f.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_vco_f.h> -#include <gr_io_signature.h> -#include <math.h> - -gr_vco_f_sptr -gr_make_vco_f(double sampling_rate, double sensitivity, double amplitude) -{ - return gnuradio::get_initial_sptr(new gr_vco_f(sampling_rate, sensitivity, amplitude)); -} - - -gr_vco_f::gr_vco_f(double sampling_rate, double sensitivity, double amplitude) - : gr_sync_block("vco_f", - gr_make_io_signature(1, 1, sizeof(float)), - gr_make_io_signature(1, 1, sizeof(float))), - d_sampling_rate(sampling_rate), d_sensitivity(sensitivity), d_amplitude(amplitude), - d_k(d_sensitivity/d_sampling_rate) -{ -} - -int -gr_vco_f::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *input = (const float *)input_items[0]; - float *output = (float *)output_items[0]; - - d_vco.cos(output, input, noutput_items, d_k, d_amplitude); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_vco_f.h b/gnuradio-core/src/lib/general/gr_vco_f.h deleted file mode 100644 index 83f6a9773e..0000000000 --- a/gnuradio-core/src/lib/general/gr_vco_f.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_VCO_F_H -#define INCLUDED_GR_VCO_F_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_fxpt_vco.h> - -/*! - * \brief VCO - Voltage controlled oscillator - * \ingroup misc - * - * \param sampling_rate sampling rate (Hz) - * \param sensitivity units are radians/sec/volt - * \param amplitude output amplitude - */ -class gr_vco_f; -typedef boost::shared_ptr<gr_vco_f> gr_vco_f_sptr; - - -GR_CORE_API gr_vco_f_sptr gr_make_vco_f(double sampling_rate, double sensitivity, double amplitude); - -/*! - * \brief VCO - Voltage controlled oscillator - * \ingroup modulator_blk - * - * input: float stream of control voltages; output: float oscillator output - */ -class GR_CORE_API gr_vco_f : public gr_sync_block -{ - friend GR_CORE_API gr_vco_f_sptr gr_make_vco_f(double sampling_rate, double sensitivity, double amplitude); - - /*! - * \brief VCO - Voltage controlled oscillator - * - * \param sampling_rate sampling rate (Hz) - * \param sensitivity units are radians/sec/volt - * \param amplitude output amplitude - */ - gr_vco_f(double sampling_rate, double sensitivity, double amplitude); - - double d_sampling_rate; - double d_sensitivity; - double d_amplitude; - double d_k; - gr_fxpt_vco d_vco; - -public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_VCO_F_H */ diff --git a/gnuradio-core/src/lib/general/gr_vco_f.i b/gnuradio-core/src/lib/general/gr_vco_f.i deleted file mode 100644 index 8ecf314116..0000000000 --- a/gnuradio-core/src/lib/general/gr_vco_f.i +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,vco_f); - -/*! - * \brief VCO - Voltage controlled oscillator - * - * \param sampling_rate sampling rate (Hz) - * \param sensitivity units are radians/sec/volt - * \param amplitude output amplitude - */ -gr_vco_f_sptr gr_make_vco_f(double sampling_rate, double sensitivity, double amplitude); - - -class gr_vco_f : public gr_sync_block { - private: - gr_vco_f(double sampling_rate, double sensitivity, double amplitude); -}; diff --git a/gnuradio-core/src/lib/general/gr_vector_to_stream.cc b/gnuradio-core/src/lib/general/gr_vector_to_stream.cc deleted file mode 100644 index 621b7ec581..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_to_stream.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_vector_to_stream.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_vector_to_stream_sptr -gr_make_vector_to_stream (size_t item_size, size_t nitems_per_block) -{ - return gnuradio::get_initial_sptr(new gr_vector_to_stream (item_size, nitems_per_block)); -} - -gr_vector_to_stream::gr_vector_to_stream (size_t item_size, size_t nitems_per_block) - : gr_sync_interpolator ("vector_to_stream", - gr_make_io_signature (1, 1, item_size * nitems_per_block), - gr_make_io_signature (1, 1, item_size), - nitems_per_block) -{ -} - -int -gr_vector_to_stream::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t block_size = output_signature()->sizeof_stream_item (0); - - const char *in = (const char *) input_items[0]; - char *out = (char *) output_items[0]; - - memcpy (out, in, noutput_items * block_size); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_vector_to_stream.h b/gnuradio-core/src/lib/general/gr_vector_to_stream.h deleted file mode 100644 index 9fc8030f5b..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_to_stream.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_VECTOR_TO_STREAM_H -#define INCLUDED_GR_VECTOR_TO_STREAM_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_vector_to_stream; -typedef boost::shared_ptr<gr_vector_to_stream> gr_vector_to_stream_sptr; - -GR_CORE_API gr_vector_to_stream_sptr -gr_make_vector_to_stream (size_t item_size, size_t nitems_per_block); - - -/*! - * \brief convert a stream of blocks of nitems_per_block items into a stream of items - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_vector_to_stream : public gr_sync_interpolator -{ - friend GR_CORE_API gr_vector_to_stream_sptr - gr_make_vector_to_stream (size_t item_size, size_t nitems_per_block); - - protected: - gr_vector_to_stream (size_t item_size, size_t nitems_per_block); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_VECTOR_TO_STREAM_H */ diff --git a/gnuradio-core/src/lib/general/gr_vector_to_stream.i b/gnuradio-core/src/lib/general/gr_vector_to_stream.i deleted file mode 100644 index 99776eeb86..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_to_stream.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,vector_to_stream) - -gr_vector_to_stream_sptr -gr_make_vector_to_stream (size_t itemsize, size_t nitems_per_block); - -class gr_vector_to_stream : public gr_sync_decimator -{ - protected: - gr_vector_to_stream (size_t itemsize, size_t nitems_per_block); - - public: -}; diff --git a/gnuradio-core/src/lib/general/gr_vector_to_streams.cc b/gnuradio-core/src/lib/general/gr_vector_to_streams.cc deleted file mode 100644 index 7ab352a4fb..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_to_streams.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_vector_to_streams.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_vector_to_streams_sptr -gr_make_vector_to_streams (size_t item_size, size_t nstreams) -{ - return gnuradio::get_initial_sptr(new gr_vector_to_streams (item_size, nstreams)); -} - -gr_vector_to_streams::gr_vector_to_streams (size_t item_size, size_t nstreams) - : gr_sync_block ("vector_to_streams", - gr_make_io_signature (1, 1, nstreams * item_size), - gr_make_io_signature (nstreams, nstreams, item_size)) -{ -} - -int -gr_vector_to_streams::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - size_t item_size = output_signature()->sizeof_stream_item(0); - int nstreams = output_items.size(); - - const char *in = (const char *) input_items[0]; - char **outv = (char **) &output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - for (int j = 0; j < nstreams; j++){ - memcpy(outv[j], in, item_size); - outv[j] += item_size; - in += item_size; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_vector_to_streams.h b/gnuradio-core/src/lib/general/gr_vector_to_streams.h deleted file mode 100644 index 8db4230536..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_to_streams.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_VECTOR_TO_STREAMS_H -#define INCLUDED_GR_VECTOR_TO_STREAMS_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_vector_to_streams; -typedef boost::shared_ptr<gr_vector_to_streams> gr_vector_to_streams_sptr; - -GR_CORE_API gr_vector_to_streams_sptr -gr_make_vector_to_streams (size_t item_size, size_t nstreams); - - -/*! - * \brief Convert 1 stream of vectors of length N to N streams of items - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_vector_to_streams : public gr_sync_block -{ - friend GR_CORE_API gr_vector_to_streams_sptr - gr_make_vector_to_streams (size_t item_size, size_t nstreams); - - protected: - gr_vector_to_streams (size_t item_size, size_t nstreams); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_VECTOR_TO_STREAMS_H */ diff --git a/gnuradio-core/src/lib/general/gr_vector_to_streams.i b/gnuradio-core/src/lib/general/gr_vector_to_streams.i deleted file mode 100644 index d4123135bc..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_to_streams.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,vector_to_streams) - -gr_vector_to_streams_sptr -gr_make_vector_to_streams (size_t itemsize, size_t nstreams); - -class gr_vector_to_streams : public gr_sync_block -{ - protected: - gr_vector_to_streams (size_t itemsize, size_t nstreams); - - public: -}; diff --git a/gnuradio-core/src/lib/general/gri_add_const_ss.h b/gnuradio-core/src/lib/general/gri_add_const_ss.h deleted file mode 100644 index 7433ee41bc..0000000000 --- a/gnuradio-core/src/lib/general/gri_add_const_ss.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_ADD_CONST_SS_H -#define INCLUDED_GRI_ADD_CONST_SS_H - -/*! - * \brief Low-level, high-speed add_const_ss primitive - * - * copy src to dst adding konst - */ - -void -gri_add_const_ss (short *dst, const short *src, int nshorts, short konst); - - -#endif /* _INCLUDED_GRI_ADD_CONST_SS_H_ */ diff --git a/gnuradio-core/src/lib/general/gri_add_const_ss_generic.cc b/gnuradio-core/src/lib/general/gri_add_const_ss_generic.cc deleted file mode 100644 index 3b5ee18247..0000000000 --- a/gnuradio-core/src/lib/general/gri_add_const_ss_generic.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gri_add_const_ss.h> - -void -gri_add_const_ss (short *dst, const short *src, int nshorts, short konst) -{ - static const int STRIDE = 8; - - int i; - - for (i = 0; i < nshorts - (STRIDE - 1); i += STRIDE){ - dst[i + 0] = src[i + 0] + konst; - dst[i + 1] = src[i + 1] + konst; - dst[i + 2] = src[i + 2] + konst; - dst[i + 3] = src[i + 3] + konst; - dst[i + 4] = src[i + 4] + konst; - dst[i + 5] = src[i + 5] + konst; - dst[i + 6] = src[i + 6] + konst; - dst[i + 7] = src[i + 7] + konst; - } - - for (; i < nshorts; i++) - dst[i] = src[i] + konst; -} diff --git a/gnuradio-core/src/lib/general/gri_agc2_cc.h b/gnuradio-core/src/lib/general/gri_agc2_cc.h deleted file mode 100644 index 55aa19b9ae..0000000000 --- a/gnuradio-core/src/lib/general/gri_agc2_cc.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _GRI_AGC2_CC_H_ -#define _GRI_AGC2_CC_H_ - -#include <gr_core_api.h> -#include <math.h> - -/*! - * \brief high performance Automatic Gain Control class - * - * For Power the absolute value of the complex number is used. - */ -class GR_CORE_API gri_agc2_cc { - - public: - gri_agc2_cc (float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0) - : _attack_rate(attack_rate), _decay_rate(decay_rate), _reference(reference), - _gain(gain), _max_gain(max_gain) {}; - - float decay_rate () const { return _decay_rate; } - float attack_rate () const { return _attack_rate; } - float reference () const { return _reference; } - float gain () const { return _gain; } - float max_gain() const { return _max_gain; } - - void set_decay_rate (float rate) { _decay_rate = rate; } - void set_attack_rate (float rate) { _attack_rate = rate; } - void set_reference (float reference) { _reference = reference; } - void set_gain (float gain) { _gain = gain; } - void set_max_gain(float max_gain) { _max_gain = max_gain; } - - gr_complex scale (gr_complex input){ - gr_complex output = input * _gain; - - float tmp = -_reference + sqrt(output.real()*output.real() + - output.imag()*output.imag()); - float rate = _decay_rate; - if((tmp) > _gain) - rate = _attack_rate; - _gain -= tmp*rate; - -#if 0 - fprintf(stdout, "rate = %f\ttmp = %f\t gain = %f\n", rate, tmp, _gain); -#endif - - // Not sure about this; will blow up if _gain < 0 (happens when rates are too high), - // but is this the solution? - if (_gain < 0.0) - _gain = 10e-5; - - if (_max_gain > 0.0 && _gain > _max_gain) - _gain = _max_gain; - return output; - } - - void scaleN (gr_complex output[], const gr_complex input[], unsigned n){ - for (unsigned i = 0; i < n; i++) - output[i] = scale (input[i]); - } - - protected: - float _attack_rate; // attack rate for fast changing signals - float _decay_rate; // decay rate for slow changing signals - float _reference; // reference value - float _gain; // current gain - float _max_gain; // max allowable gain -}; - -#endif /* _GRI_AGC2_CC_H_ */ diff --git a/gnuradio-core/src/lib/general/gri_agc2_cc.i b/gnuradio-core/src/lib/general/gri_agc2_cc.i deleted file mode 100644 index 08716c6edc..0000000000 --- a/gnuradio-core/src/lib/general/gri_agc2_cc.i +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <math.h> - -/*! - * \brief high performance Automatic Gain Control class with attack and decay rates - * - * For Power the absolute value of the complex number is used. - */ - - -class gri_agc2_cc { - - public: - gri_agc2_cc (float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0); - float decay_rate (); - float attack_rate (); - float reference (); - float gain (); - float max_gain (); - void set_decay_rate (float rate); - void set_attack_rate (float rate); - void set_reference (float reference); - void set_gain (float gain); - void set_max_gain(float max_gain); - }; diff --git a/gnuradio-core/src/lib/general/gri_agc2_ff.h b/gnuradio-core/src/lib/general/gri_agc2_ff.h deleted file mode 100644 index a8b46bec5c..0000000000 --- a/gnuradio-core/src/lib/general/gri_agc2_ff.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _GRI_AGC2_FF_H_ -#define _GRI_AGC2_FF_H_ - -#include <gr_core_api.h> -#include <math.h> - -/*! - * \brief high performance Automatic Gain Control class with attack and decay rate - * - * Power is approximated by absolute value - */ - -class GR_CORE_API gri_agc2_ff { - - public: - gri_agc2_ff (float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0) - : _attack_rate(attack_rate), _decay_rate(decay_rate), _reference(reference), - _gain(gain), _max_gain(max_gain) {}; - - float attack_rate () const { return _attack_rate; } - float decay_rate () const { return _decay_rate; } - float reference () const { return _reference; } - float gain () const { return _gain; } - float max_gain () const { return _max_gain; } - - void set_attack_rate (float rate) { _attack_rate = rate; } - void set_decay_rate (float rate) { _decay_rate = rate; } - void set_reference (float reference) { _reference = reference; } - void set_gain (float gain) { _gain = gain; } - void set_max_gain (float max_gain) { _max_gain = max_gain; } - - float scale (float input){ - float output = input * _gain; - - float tmp = (fabsf(output)) - _reference; - float rate = _decay_rate; - if(fabsf(tmp) > _gain) - rate = _attack_rate; - _gain -= tmp*rate; - -#if 0 - fprintf(stdout, "rate = %f\ttmp = %f\t gain = %f\n", rate, tmp, _gain); -#endif - - // Not sure about this - if (_gain < 0.0) - _gain = 10e-5; - - if (_max_gain > 0.0 && _gain > _max_gain) - _gain = _max_gain; - return output; - } - - void scaleN (float output[], const float input[], unsigned n){ - for (unsigned i = 0; i < n; i++) - output[i] = scale (input[i]); - } - - protected: - float _attack_rate; // attack_rate for fast changing signals - float _decay_rate; // decay rate for slow changing signals - float _reference; // reference value - float _gain; // current gain - float _max_gain; // maximum gain -}; - -#endif /* _GRI_AGC2_FF_H_ */ diff --git a/gnuradio-core/src/lib/general/gri_agc2_ff.i b/gnuradio-core/src/lib/general/gri_agc2_ff.i deleted file mode 100644 index 9f97d8f0dd..0000000000 --- a/gnuradio-core/src/lib/general/gri_agc2_ff.i +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <math.h> - -/*! - * \brief high performance Automatic Gain Control class - * - * Power is approximated by absolute value - */ - - -class gri_agc2_ff { - - public: - gri_agc2_ff (float attack_rate = 1e-1, float decay_rate = 1e-2, - float reference = 1.0, float gain = 1.0, float max_gain = 0.0); - float attack_rate (); - float decay_rate (); - float reference (); - float gain (); - float max_gain (); - void set_attack_rate (float rate); - void set_decay_rate (float rate); - void set_reference (float reference); - void set_gain (float gain); - void set_max_gain (float max_gain); - }; diff --git a/gnuradio-core/src/lib/general/gri_agc_cc.h b/gnuradio-core/src/lib/general/gri_agc_cc.h deleted file mode 100644 index 90edc5dcd2..0000000000 --- a/gnuradio-core/src/lib/general/gri_agc_cc.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_AGC_CC_H -#define INCLUDED_GRI_AGC_CC_H - -#include <gr_core_api.h> -#include <math.h> - -/*! - * \brief high performance Automatic Gain Control class - * - * For Power the absolute value of the complex number is used. - */ - -class GR_CORE_API gri_agc_cc { - - public: - gri_agc_cc (float rate = 1e-4, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0) - : _rate(rate), _reference(reference), - _gain(gain), _max_gain(max_gain) {}; - - float rate () const { return _rate; } - float reference () const { return _reference; } - float gain () const { return _gain; } - float max_gain() const { return _max_gain; } - - void set_rate (float rate) { _rate = rate; } - void set_reference (float reference) { _reference = reference; } - void set_gain (float gain) { _gain = gain; } - void set_max_gain(float max_gain) { _max_gain = max_gain; } - - gr_complex scale (gr_complex input){ - gr_complex output = input * _gain; - - _gain += _rate * (_reference - sqrt(output.real()*output.real() + - output.imag()*output.imag())); - if (_max_gain > 0.0 && _gain > _max_gain) - _gain = _max_gain; - return output; - } - - void scaleN (gr_complex output[], const gr_complex input[], unsigned n){ - for (unsigned i = 0; i < n; i++) - output[i] = scale (input[i]); - } - - protected: - float _rate; // adjustment rate - float _reference; // reference value - float _gain; // current gain - float _max_gain; // max allowable gain -}; - -#endif /* INCLUDED_GRI_AGC_CC_H */ diff --git a/gnuradio-core/src/lib/general/gri_agc_cc.i b/gnuradio-core/src/lib/general/gri_agc_cc.i deleted file mode 100644 index d3dd9b61bc..0000000000 --- a/gnuradio-core/src/lib/general/gri_agc_cc.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 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 <math.h> - -/*! - * \brief high performance Automatic Gain Control class - * - * For Power the absolute value of the complex number is used. - */ - - -class gri_agc_cc { - - public: - gri_agc_cc (float rate = 1e-4, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0); - float rate (); - float reference (); - float gain (); - float max_gain (); - }; diff --git a/gnuradio-core/src/lib/general/gri_agc_ff.h b/gnuradio-core/src/lib/general/gri_agc_ff.h deleted file mode 100644 index 1c233c7461..0000000000 --- a/gnuradio-core/src/lib/general/gri_agc_ff.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_AGC_FF_H -#define INCLUDED_GRI_AGC_FF_H - -#include <gr_core_api.h> -#include <math.h> - -/*! - * \brief high performance Automatic Gain Control class - * - * Power is approximated by absolute value - */ -class GR_CORE_API gri_agc_ff { - - public: - gri_agc_ff (float rate = 1e-4, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0) - : _rate(rate), _reference(reference), _gain(gain), _max_gain(max_gain) {}; - - float rate () const { return _rate; } - float reference () const { return _reference; } - float gain () const { return _gain; } - float max_gain () const { return _max_gain; } - - void set_rate (float rate) { _rate = rate; } - void set_reference (float reference) { _reference = reference; } - void set_gain (float gain) { _gain = gain; } - void set_max_gain (float max_gain) { _max_gain = max_gain; } - - float scale (float input){ - float output = input * _gain; - _gain += (_reference - fabsf (output)) * _rate; - if (_max_gain > 0.0 && _gain > _max_gain) - _gain = _max_gain; - return output; - } - - void scaleN (float output[], const float input[], unsigned n){ - for (unsigned i = 0; i < n; i++) - output[i] = scale (input[i]); - } - - protected: - float _rate; // adjustment rate - float _reference; // reference value - float _gain; // current gain - float _max_gain; // maximum gain -}; - -#endif /* INCLUDED_GRI_AGC_FF_H */ - diff --git a/gnuradio-core/src/lib/general/gri_agc_ff.i b/gnuradio-core/src/lib/general/gri_agc_ff.i deleted file mode 100644 index df4acf7af8..0000000000 --- a/gnuradio-core/src/lib/general/gri_agc_ff.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <math.h> - -/*! - * \brief high performance Automatic Gain Control class - * - * Power is approximated by absolute value - */ - -class gri_agc_ff { - - public: - gri_agc_ff (float rate = 1e-4, float reference = 1.0, - float gain = 1.0, float max_gain = 0.0); -}; diff --git a/gnuradio-core/src/lib/general/gri_char_to_float.cc b/gnuradio-core/src/lib/general/gri_char_to_float.cc deleted file mode 100644 index fd9a6636a1..0000000000 --- a/gnuradio-core/src/lib/general/gri_char_to_float.cc +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gri_char_to_float.h> - -void -gri_char_to_float (const char *in, float *out, int nsamples) -{ - while (nsamples >= 4){ - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; - out[3] = in[3]; - out += 4; - in += 4; - nsamples -= 4; - } - - while (nsamples-- > 0) - *out++ = *in++; -} diff --git a/gnuradio-core/src/lib/general/gri_char_to_float.h b/gnuradio-core/src/lib/general/gri_char_to_float.h deleted file mode 100644 index 8bd3bfde7d..0000000000 --- a/gnuradio-core/src/lib/general/gri_char_to_float.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_CHAR_TO_FLOAT_H -#define INCLUDED_GRI_CHAR_TO_FLOAT_H - -#include <gr_core_api.h> - -/* - * convert array of chars to floats - */ -GR_CORE_API void gri_char_to_float (const char *in, float *out, int nsamples); - - -#endif /* INCLUDED_GRI_CHAR_TO_FLOAT_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/gri_control_loop.cc b/gnuradio-core/src/lib/general/gri_control_loop.cc deleted file mode 100644 index bb3c4a3263..0000000000 --- a/gnuradio-core/src/lib/general/gri_control_loop.cc +++ /dev/null @@ -1,210 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gri_control_loop.h> -#include <gr_math.h> -#include <stdexcept> - -#define M_TWOPI (2.0f*M_PI) - -gri_control_loop::gri_control_loop(float loop_bw, - float max_freq, float min_freq) - : d_phase(0), d_freq(0), d_max_freq(max_freq), d_min_freq(min_freq) -{ - // Set the damping factor for a critically damped system - d_damping = sqrtf(2.0f)/2.0f; - - // Set the bandwidth, which will then call update_gains() - set_loop_bandwidth(loop_bw); -} - -gri_control_loop::~gri_control_loop() -{ -} - -void -gri_control_loop::update_gains() -{ - float denom = (1.0 + 2.0*d_damping*d_loop_bw + d_loop_bw*d_loop_bw); - d_alpha = (4*d_damping*d_loop_bw) / denom; - d_beta = (4*d_loop_bw*d_loop_bw) / denom; -} - -void -gri_control_loop::advance_loop(float error) -{ - d_freq = d_freq + d_beta * error; - d_phase = d_phase + d_freq + d_alpha * error; -} - - -void -gri_control_loop::phase_wrap() -{ - while(d_phase>M_TWOPI) - d_phase -= M_TWOPI; - while(d_phase<-M_TWOPI) - d_phase += M_TWOPI; -} - -void -gri_control_loop::frequency_limit() -{ - if (d_freq > d_max_freq) - d_freq = d_max_freq; - else if (d_freq < d_min_freq) - d_freq = d_min_freq; -} - -/******************************************************************* - SET FUNCTIONS -*******************************************************************/ - -void -gri_control_loop::set_loop_bandwidth(float bw) -{ - if(bw < 0) { - throw std::out_of_range ("gri_control_loop: invalid bandwidth. Must be >= 0."); - } - - d_loop_bw = bw; - update_gains(); -} - -void -gri_control_loop::set_damping_factor(float df) -{ - if(df < 0 || df > 1.0) { - throw std::out_of_range ("gri_control_loop: invalid damping factor. Must be in [0,1]."); - } - - d_damping = df; - update_gains(); -} - -void -gri_control_loop::set_alpha(float alpha) -{ - if(alpha < 0 || alpha > 1.0) { - throw std::out_of_range ("gri_control_loop: invalid alpha. Must be in [0,1]."); - } - d_alpha = alpha; -} - -void -gri_control_loop::set_beta(float beta) -{ - if(beta < 0 || beta > 1.0) { - throw std::out_of_range ("gri_control_loop: invalid beta. Must be in [0,1]."); - } - d_beta = beta; -} - -void -gri_control_loop::set_frequency(float freq) -{ - if(freq > d_max_freq) - d_freq = d_min_freq; - else if(freq < d_min_freq) - d_freq = d_max_freq; - else - d_freq = freq; -} - -void -gri_control_loop::set_phase(float phase) -{ - d_phase = phase; - while(d_phase>M_TWOPI) - d_phase -= M_TWOPI; - while(d_phase<-M_TWOPI) - d_phase += M_TWOPI; -} - -void -gri_control_loop::set_max_freq(float freq) -{ - d_max_freq = freq; -} - -void -gri_control_loop::set_min_freq(float freq) -{ - d_min_freq = freq; -} - -/******************************************************************* - GET FUNCTIONS -*******************************************************************/ - - -float -gri_control_loop::get_loop_bandwidth() const -{ - return d_loop_bw; -} - -float -gri_control_loop::get_damping_factor() const -{ - return d_damping; -} - -float -gri_control_loop::get_alpha() const -{ - return d_alpha; -} - -float -gri_control_loop::get_beta() const -{ - return d_beta; -} - -float -gri_control_loop::get_frequency() const -{ - return d_freq; -} - -float -gri_control_loop::get_phase() const -{ - return d_phase; -} - -float -gri_control_loop::get_max_freq() const -{ - return d_max_freq; -} - -float -gri_control_loop::get_min_freq() const -{ - return d_min_freq; -} diff --git a/gnuradio-core/src/lib/general/gri_control_loop.h b/gnuradio-core/src/lib/general/gri_control_loop.h deleted file mode 100644 index 304857ac75..0000000000 --- a/gnuradio-core/src/lib/general/gri_control_loop.h +++ /dev/null @@ -1,230 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef GRI_CONTROL_LOOP -#define GRI_CONTROL_LOOP - -#include <gr_core_api.h> - -class GR_CORE_API gri_control_loop -{ - protected: - float d_phase, d_freq; - float d_max_freq, d_min_freq; - float d_damping, d_loop_bw; - float d_alpha, d_beta; - - public: - gri_control_loop(float loop_bw, float max_freq, float min_freq); - virtual ~gri_control_loop(); - - /*! \brief update the system gains from the loop bandwidth and damping factor - * - * This function updates the system gains based on the loop - * bandwidth and damping factor of the system. - * These two factors can be set separately through their own - * set functions. - */ - void update_gains(); - - /*! \brief update the system gains from the loop bandwidth and damping factor - * - * This function updates the system gains based on the loop - * bandwidth and damping factor of the system. - * These two factors can be set separately through their own - * set functions. - */ - void advance_loop(float error); - - /*! \brief Keep the phase between -2pi and 2pi - * - * This function keeps the phase between -2pi and 2pi. If the phase - * is greater than 2pi by d, it wraps around to be -2pi+d; similarly if - * it is less than -2pi by d, it wraps around to 2pi-d. - * - * This function should be called after advance_loop to keep the phase - * in a good operating region. It is set as a separate method in case - * another way is desired as this is fairly heavy-handed. - */ - void phase_wrap(); - - /*! \brief Keep the frequency between d_min_freq and d_max_freq - * - * This function keeps the frequency between d_min_freq and d_max_freq. - * If the frequency is greater than d_max_freq, it is set to d_max_freq. - * If the frequency is less than d_min_freq, it is set to d_min_freq. - * - * This function should be called after advance_loop to keep the frequency - * in the specified region. It is set as a separate method in case - * another way is desired as this is fairly heavy-handed. - */ - void frequency_limit(); - - /******************************************************************* - SET FUNCTIONS - *******************************************************************/ - - /*! - * \brief Set the loop bandwidth - * - * Set the loop filter's bandwidth to \p bw. This should be between - * 2*pi/200 and 2*pi/100 (in rads/samp). It must also be a positive - * number. - * - * When a new damping factor is set, the gains, alpha and beta, of the loop - * are recalculated by a call to update_gains(). - * - * \param bw (float) new bandwidth - * - */ - void set_loop_bandwidth(float bw); - - /*! - * \brief Set the loop damping factor - * - * Set the loop filter's damping factor to \p df. The damping factor - * should be sqrt(2)/2.0 for critically damped systems. - * Set it to anything else only if you know what you are doing. It must - * be a number between 0 and 1. - * - * When a new damping factor is set, the gains, alpha and beta, of the loop - * are recalculated by a call to update_gains(). - * - * \param df (float) new damping factor - * - */ - void set_damping_factor(float df); - - /*! - * \brief Set the loop gain alpha - * - * Set's the loop filter's alpha gain parameter. - * - * This value should really only be set by adjusting the loop bandwidth - * and damping factor. - * - * \param alpha (float) new alpha gain - * - */ - void set_alpha(float alpha); - - /*! - * \brief Set the loop gain beta - * - * Set's the loop filter's beta gain parameter. - * - * This value should really only be set by adjusting the loop bandwidth - * and damping factor. - * - * \param beta (float) new beta gain - * - */ - void set_beta(float beta); - - /*! - * \brief Set the control loop's frequency. - * - * Set's the control loop's frequency. While this is normally updated by the - * inner loop of the algorithm, it could be useful to manually initialize, - * set, or reset this under certain circumstances. - * - * \param freq (float) new frequency - * - */ - void set_frequency(float freq); - - /*! - * \brief Set the control loop's phase. - * - * Set's the control loop's phase. While this is normally updated by the - * inner loop of the algorithm, it could be useful to manually initialize, - * set, or reset this under certain circumstances. - * - * \param phase (float) new phase - * - */ - void set_phase(float phase); - - /*! - * \brief Set the control loop's maximum frequency. - * - * Set the maximum frequency the control loop can track. - * - * \param freq (float) new max frequency - */ - void set_max_freq(float freq); - - /*! - * \brief Set the control loop's minimum frequency. - * - * Set the minimum frequency the control loop can track. - * - * \param freq (float) new min frequency - */ - void set_min_freq(float freq); - - /******************************************************************* - GET FUNCTIONS - *******************************************************************/ - - /*! - * \brief Returns the loop bandwidth - */ - float get_loop_bandwidth() const; - - /*! - * \brief Returns the loop damping factor - */ - float get_damping_factor() const; - - /*! - * \brief Returns the loop gain alpha - */ - float get_alpha() const; - - /*! - * \brief Returns the loop gain beta - */ - float get_beta() const; - - /*! - * \brief Get the control loop's frequency estimate - */ - float get_frequency() const; - - /*! - * \brief Get the control loop's phase estimate - */ - float get_phase() const; - - /*! - * \brief Get the control loop's maximum frequency. - */ - float get_max_freq() const; - - /*! - * \brief Get the control loop's minimum frequency. - */ - float get_min_freq() const; -}; - -#endif /* GRI_CONTROL_LOOP */ diff --git a/gnuradio-core/src/lib/general/gri_control_loop.i b/gnuradio-core/src/lib/general/gri_control_loop.i deleted file mode 100644 index 8a23207e50..0000000000 --- a/gnuradio-core/src/lib/general/gri_control_loop.i +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -class gri_control_loop -{ - public: - gri_control_loop(float loop_bw, float max_freq, float min_freq); - virtual ~gri_control_loop(); - - void update_gains(); - void advance_loop(float error); - void phase_wrap(); - void frequency_limit(); - - /******************************************************************* - SET FUNCTIONS - *******************************************************************/ - - void set_loop_bandwidth(float bw); - void set_damping_factor(float df); - void set_alpha(float alpha); - void set_beta(float beta); - void set_frequency(float freq); - void set_phase(float phase); - - - /******************************************************************* - GET FUNCTIONS - *******************************************************************/ - - float get_loop_bandwidth() const; - float get_damping_factor() const; - float get_alpha() const; - float get_beta() const; - float get_frequency() const; - float get_phase() const; -}; diff --git a/gnuradio-core/src/lib/general/gri_fft.cc b/gnuradio-core/src/lib/general/gri_fft.cc deleted file mode 100644 index 68e7e69519..0000000000 --- a/gnuradio-core/src/lib/general/gri_fft.cc +++ /dev/null @@ -1,330 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2008,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 <gri_fft.h> -#include <gr_sys_paths.h> -#include <fftw3.h> - -#ifdef _MSC_VER //http://www.fftw.org/install/windows.html#DLLwisdom -static void my_fftw_write_char(char c, void *f) { fputc(c, (FILE *) f); } -#define fftw_export_wisdom_to_file(f) fftw_export_wisdom(my_fftw_write_char, (void*) (f)) -#define fftwf_export_wisdom_to_file(f) fftwf_export_wisdom(my_fftw_write_char, (void*) (f)) -#define fftwl_export_wisdom_to_file(f) fftwl_export_wisdom(my_fftw_write_char, (void*) (f)) - -static int my_fftw_read_char(void *f) { return fgetc((FILE *) f); } -#define fftw_import_wisdom_from_file(f) fftw_import_wisdom(my_fftw_read_char, (void*) (f)) -#define fftwf_import_wisdom_from_file(f) fftwf_import_wisdom(my_fftw_read_char, (void*) (f)) -#define fftwl_import_wisdom_from_file(f) fftwl_import_wisdom(my_fftw_read_char, (void*) (f)) -#endif //_MSC_VER - -#include <gr_complex.h> -#include <stdlib.h> -#include <string.h> -#include <stdio.h> -#include <cassert> -#include <stdexcept> - -#include <boost/filesystem/operations.hpp> -#include <boost/filesystem/path.hpp> -namespace fs = boost::filesystem; - -gr_complex * -gri_fft_malloc_complex(int size) -{ - return (gr_complex*)fftwf_malloc(sizeof(gr_complex)*size); -} - -float * -gri_fft_malloc_float(int size) -{ - return (float*)fftwf_malloc(sizeof(float)*size); -} - -void -gri_fft_free(void *b) -{ - fftwf_free(b); -} - -boost::mutex & -gri_fft_planner::mutex() -{ - static boost::mutex s_planning_mutex; - - return s_planning_mutex; -} - -static const char * -wisdom_filename () -{ - static fs::path path; - path = fs::path(gr_appdata_path()) / ".gr_fftw_wisdom"; - return path.string().c_str(); -} - -static void -gri_fftw_import_wisdom () -{ - const char *filename = wisdom_filename (); - FILE *fp = fopen (filename, "r"); - if (fp != 0){ - int r = fftwf_import_wisdom_from_file (fp); - fclose (fp); - if (!r){ - fprintf (stderr, "gri_fftw: can't import wisdom from %s\n", filename); - } - } -} - -static void -gri_fftw_config_threading (int nthreads) -{ - static int fftw_threads_inited = 0; - -#ifdef FFTW3F_THREADS - if (fftw_threads_inited == 0) - { - fftw_threads_inited = 1; - fftwf_init_threads(); - } - - fftwf_plan_with_nthreads(nthreads); -#endif -} - -static void -gri_fftw_export_wisdom () -{ - const char *filename = wisdom_filename (); - FILE *fp = fopen (filename, "w"); - if (fp != 0){ - fftwf_export_wisdom_to_file (fp); - fclose (fp); - } - else { - fprintf (stderr, "gri_fftw: "); - perror (filename); - } -} - -// ---------------------------------------------------------------- - -gri_fft_complex::gri_fft_complex (int fft_size, bool forward, int nthreads) -{ - // Hold global mutex during plan construction and destruction. - gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex()); - - assert (sizeof (fftwf_complex) == sizeof (gr_complex)); - - if (fft_size <= 0) - throw std::out_of_range ("gri_fftw: invalid fft_size"); - - d_fft_size = fft_size; - d_inbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) * inbuf_length ()); - if (d_inbuf == 0) - throw std::runtime_error ("fftwf_malloc"); - - d_outbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) * outbuf_length ()); - if (d_outbuf == 0){ - fftwf_free (d_inbuf); - throw std::runtime_error ("fftwf_malloc"); - } - - d_nthreads = nthreads; - gri_fftw_config_threading (nthreads); - gri_fftw_import_wisdom (); // load prior wisdom from disk - - d_plan = fftwf_plan_dft_1d (fft_size, - reinterpret_cast<fftwf_complex *>(d_inbuf), - reinterpret_cast<fftwf_complex *>(d_outbuf), - forward ? FFTW_FORWARD : FFTW_BACKWARD, - FFTW_MEASURE); - - if (d_plan == NULL) { - fprintf(stderr, "gri_fft_complex: error creating plan\n"); - throw std::runtime_error ("fftwf_plan_dft_1d failed"); - } - gri_fftw_export_wisdom (); // store new wisdom to disk -} - -gri_fft_complex::~gri_fft_complex () -{ - // Hold global mutex during plan construction and destruction. - gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex()); - - fftwf_destroy_plan ((fftwf_plan) d_plan); - fftwf_free (d_inbuf); - fftwf_free (d_outbuf); -} - -void -gri_fft_complex::set_nthreads(int n) -{ - if (n <= 0) - throw std::out_of_range ("gri_fftw: invalid number of threads"); - d_nthreads = n; - -#ifdef FFTW3F_THREADS - fftwf_plan_with_nthreads(d_nthreads); -#endif -} - -void -gri_fft_complex::execute () -{ - fftwf_execute ((fftwf_plan) d_plan); -} - -// ---------------------------------------------------------------- - -gri_fft_real_fwd::gri_fft_real_fwd (int fft_size, int nthreads) -{ - // Hold global mutex during plan construction and destruction. - gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex()); - - assert (sizeof (fftwf_complex) == sizeof (gr_complex)); - - if (fft_size <= 0) - throw std::out_of_range ("gri_fftw: invalid fft_size"); - - d_fft_size = fft_size; - d_inbuf = (float *) fftwf_malloc (sizeof (float) * inbuf_length ()); - if (d_inbuf == 0) - throw std::runtime_error ("fftwf_malloc"); - - d_outbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) * outbuf_length ()); - if (d_outbuf == 0){ - fftwf_free (d_inbuf); - throw std::runtime_error ("fftwf_malloc"); - } - - d_nthreads = nthreads; - gri_fftw_config_threading (nthreads); - gri_fftw_import_wisdom (); // load prior wisdom from disk - - d_plan = fftwf_plan_dft_r2c_1d (fft_size, - d_inbuf, - reinterpret_cast<fftwf_complex *>(d_outbuf), - FFTW_MEASURE); - - if (d_plan == NULL) { - fprintf(stderr, "gri_fft_real_fwd: error creating plan\n"); - throw std::runtime_error ("fftwf_plan_dft_r2c_1d failed"); - } - gri_fftw_export_wisdom (); // store new wisdom to disk -} - -gri_fft_real_fwd::~gri_fft_real_fwd () -{ - // Hold global mutex during plan construction and destruction. - gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex()); - - fftwf_destroy_plan ((fftwf_plan) d_plan); - fftwf_free (d_inbuf); - fftwf_free (d_outbuf); -} - -void -gri_fft_real_fwd::set_nthreads(int n) -{ - if (n <= 0) - throw std::out_of_range ("gri_fftw: invalid number of threads"); - d_nthreads = n; - -#ifdef FFTW3F_THREADS - fftwf_plan_with_nthreads(d_nthreads); -#endif -} - -void -gri_fft_real_fwd::execute () -{ - fftwf_execute ((fftwf_plan) d_plan); -} - -// ---------------------------------------------------------------- - -gri_fft_real_rev::gri_fft_real_rev (int fft_size, int nthreads) -{ - // Hold global mutex during plan construction and destruction. - gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex()); - - assert (sizeof (fftwf_complex) == sizeof (gr_complex)); - - if (fft_size <= 0) - throw std::out_of_range ("gri_fftw: invalid fft_size"); - - d_fft_size = fft_size; - d_inbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) * inbuf_length ()); - if (d_inbuf == 0) - throw std::runtime_error ("fftwf_malloc"); - - d_outbuf = (float *) fftwf_malloc (sizeof (float) * outbuf_length ()); - if (d_outbuf == 0){ - fftwf_free (d_inbuf); - throw std::runtime_error ("fftwf_malloc"); - } - - d_nthreads = nthreads; - gri_fftw_config_threading (nthreads); - gri_fftw_import_wisdom (); // load prior wisdom from disk - - // FIXME If there's ever a chance that the planning functions - // will be called in multiple threads, we've got to ensure single - // threaded access. They are not thread-safe. - d_plan = fftwf_plan_dft_c2r_1d (fft_size, - reinterpret_cast<fftwf_complex *>(d_inbuf), - d_outbuf, - FFTW_MEASURE); - - if (d_plan == NULL) { - fprintf(stderr, "gri_fft_real_rev: error creating plan\n"); - throw std::runtime_error ("fftwf_plan_dft_c2r_1d failed"); - } - gri_fftw_export_wisdom (); // store new wisdom to disk -} - -gri_fft_real_rev::~gri_fft_real_rev () -{ - fftwf_destroy_plan ((fftwf_plan) d_plan); - fftwf_free (d_inbuf); - fftwf_free (d_outbuf); -} - -void -gri_fft_real_rev::set_nthreads(int n) -{ - if (n <= 0) - throw std::out_of_range ("gri_fftw: invalid number of threads"); - d_nthreads = n; - -#ifdef FFTW3F_THREADS - fftwf_plan_with_nthreads(d_nthreads); -#endif -} - -void -gri_fft_real_rev::execute () -{ - fftwf_execute ((fftwf_plan) d_plan); -} - diff --git a/gnuradio-core/src/lib/general/gri_fft.h b/gnuradio-core/src/lib/general/gri_fft.h deleted file mode 100644 index 65e9d046e2..0000000000 --- a/gnuradio-core/src/lib/general/gri_fft.h +++ /dev/null @@ -1,185 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GRI_FFT_H_ -#define _GRI_FFT_H_ - -/* - * Wrappers for FFTW single precision 1d dft - */ - -#include <gr_core_api.h> -#include <gr_complex.h> -#include <boost/thread.hpp> - -/*! \brief Helper function for allocating complex fft buffers - */ -gr_complex* gri_fft_malloc_complex(int size); - -/*! \brief Helper function for allocating float fft buffers - */ -float* gri_fft_malloc_float(int size); - -/*! \brief Helper function for freeing fft buffers - */ -void gri_fft_free(void *b); - - -/*! - * \brief Export reference to planner mutex for those apps that - * want to use FFTW w/o using the gri_fftw* classes. - */ -class GR_CORE_API gri_fft_planner { -public: - typedef boost::mutex::scoped_lock scoped_lock; - /*! - * Return reference to planner mutex - */ - static boost::mutex &mutex(); -}; - -/*! - * \brief FFT: complex in, complex out - * \ingroup misc - */ -class GR_CORE_API gri_fft_complex { - int d_fft_size; - int d_nthreads; - gr_complex *d_inbuf; - gr_complex *d_outbuf; - void *d_plan; - -public: - gri_fft_complex (int fft_size, bool forward = true, int nthreads=1); - virtual ~gri_fft_complex (); - - /* - * These return pointers to buffers owned by gri_fft_complex into which - * input and output take place. It's done this way in order to - * ensure optimal alignment for SIMD instructions. - */ - gr_complex *get_inbuf () const { return d_inbuf; } - gr_complex *get_outbuf () const { return d_outbuf; } - - int inbuf_length () const { return d_fft_size; } - int outbuf_length () const { return d_fft_size; } - - /*! - * Set the number of threads to use for caclulation. - */ - void set_nthreads(int n); - - /*! - * Get the number of threads being used by FFTW - */ - int nthreads() const { return d_nthreads; } - - /*! - * compute FFT. The input comes from inbuf, the output is placed in outbuf. - */ - void execute (); -}; - -/*! - * \brief FFT: real in, complex out - * \ingroup misc - */ -class GR_CORE_API gri_fft_real_fwd { - int d_fft_size; - int d_nthreads; - float *d_inbuf; - gr_complex *d_outbuf; - void *d_plan; - -public: - gri_fft_real_fwd (int fft_size, int nthreads=1); - virtual ~gri_fft_real_fwd (); - - /* - * These return pointers to buffers owned by gri_fft_real_fwd into - * which input and output take place. It's done this way in order - * to ensure optimal alignment for SIMD instructions. - */ - float *get_inbuf () const { return d_inbuf; } - gr_complex *get_outbuf () const { return d_outbuf; } - - int inbuf_length () const { return d_fft_size; } - int outbuf_length () const { return d_fft_size / 2 + 1; } - - /*! - * Set the number of threads to use for caclulation. - */ - void set_nthreads(int n); - - /*! - * Get the number of threads being used by FFTW - */ - int nthreads() const { return d_nthreads; } - - /*! - * compute FFT. The input comes from inbuf, the output is placed in outbuf. - */ - void execute (); -}; - -/*! - * \brief FFT: complex in, float out - * \ingroup misc - */ -class GR_CORE_API gri_fft_real_rev { - int d_fft_size; - int d_nthreads; - gr_complex *d_inbuf; - float *d_outbuf; - void *d_plan; - -public: - gri_fft_real_rev (int fft_size, int nthreads=1); - virtual ~gri_fft_real_rev (); - - /* - * These return pointers to buffers owned by gri_fft_real_rev into - * which input and output take place. It's done this way in order - * to ensure optimal alignment for SIMD instructions. - */ - gr_complex *get_inbuf () const { return d_inbuf; } - float *get_outbuf () const { return d_outbuf; } - - int inbuf_length () const { return d_fft_size / 2 + 1; } - int outbuf_length () const { return d_fft_size; } - - /*! - * Set the number of threads to use for caclulation. - */ - void set_nthreads(int n); - - /*! - * Get the number of threads being used by FFTW - */ - int nthreads() const { return d_nthreads; } - - /*! - * compute FFT. The input comes from inbuf, the output is placed in outbuf. - */ - void execute (); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gri_float_to_char.cc b/gnuradio-core/src/lib/general/gri_float_to_char.cc deleted file mode 100644 index 3e779b0e70..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_char.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#define _ISOC9X_SOURCE -#include <gri_float_to_char.h> -#include <math.h> - -static const int MIN_CHAR = -128; -static const int MAX_CHAR = 127; - - -void -gri_float_to_char (const float *in, char *out, int nsamples) -{ - for (int i = 0; i < nsamples; i++){ - long int r = (long int) rint (in[i]); - if (r < MIN_CHAR) - r = MIN_CHAR; - else if (r > MAX_CHAR) - r = MAX_CHAR; - out[i] = r; - } -} diff --git a/gnuradio-core/src/lib/general/gri_float_to_char.h b/gnuradio-core/src/lib/general/gri_float_to_char.h deleted file mode 100644 index 172a7da651..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_char.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_FLOAT_TO_CHAR_H -#define INCLUDED_GRI_FLOAT_TO_CHAR_H - -#include <gr_core_api.h> - -/*! - * convert array of floats to chars with rounding and saturation. - */ -GR_CORE_API void gri_float_to_char (const float *in, char *out, int nsamples); - -#endif /* INCLUDED_GRI_FLOAT_TO_CHAR_H */ diff --git a/gnuradio-core/src/lib/general/gri_float_to_int.cc b/gnuradio-core/src/lib/general/gri_float_to_int.cc deleted file mode 100644 index 525ea675d2..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_int.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#define _ISOC9X_SOURCE -#include <gri_float_to_int.h> -#include <math.h> -#include <stdint.h> - -static const int64_t MAX_INT = 2147483647; // (2^31)-1 -static const int64_t MIN_INT = -2147483647; // -(2^31)-1 - - -void -gri_float_to_int (const float *in, int *out, float scale, int nsamples) -{ - for (int i = 0; i < nsamples; i++){ - int64_t r = llrintf(scale * in[i]); - if (r < MIN_INT) - r = MIN_INT; - else if (r > MAX_INT) - r = MAX_INT; - out[i] = static_cast<int>(r); - } -} diff --git a/gnuradio-core/src/lib/general/gri_float_to_int.h b/gnuradio-core/src/lib/general/gri_float_to_int.h deleted file mode 100644 index 84f72a420d..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_int.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_FLOAT_TO_INT_H -#define INCLUDED_GRI_FLOAT_TO_INT_H - -#include <gr_core_api.h> - -/*! - * convert array of floats to int with rounding and saturation. - */ -GR_CORE_API void gri_float_to_int (const float *in, int *out, float scale, int nsamples); - -#endif /* INCLUDED_GRI_FLOAT_TO_INT_H */ diff --git a/gnuradio-core/src/lib/general/gri_float_to_short.cc b/gnuradio-core/src/lib/general/gri_float_to_short.cc deleted file mode 100644 index 4508e37a7d..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_short.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#define _ISOC9X_SOURCE -#include <gri_float_to_short.h> -#include <math.h> - -static const int MIN_SHORT = -32768; -static const int MAX_SHORT = 32767; - - -void -gri_float_to_short (const float *in, short *out, int nsamples) -{ - for (int i = 0; i < nsamples; i++){ - long int r = (long int) rint (in[i]); - if (r < MIN_SHORT) - r = MIN_SHORT; - else if (r > MAX_SHORT) - r = MAX_SHORT; - out[i] = r; - } -} diff --git a/gnuradio-core/src/lib/general/gri_float_to_short.h b/gnuradio-core/src/lib/general/gri_float_to_short.h deleted file mode 100644 index b9cdf685be..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_short.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_FLOAT_TO_SHORT_H -#define INCLUDED_GRI_FLOAT_TO_SHORT_H - -#include <gr_core_api.h> - -/*! - * convert array of floats to shorts with rounding and saturation. - */ -GR_CORE_API void gri_float_to_short (const float *in, short *out, int nsamples); - -#endif /* INCLUDED_GRI_FLOAT_TO_SHORT_H */ diff --git a/gnuradio-core/src/lib/general/gri_float_to_uchar.cc b/gnuradio-core/src/lib/general/gri_float_to_uchar.cc deleted file mode 100644 index 9ea42a31b5..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_uchar.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#define _ISOC9X_SOURCE -#include <gri_float_to_uchar.h> -#include <math.h> - -static const int MIN_UCHAR = 0; -static const int MAX_UCHAR = 255; - - -void -gri_float_to_uchar (const float *in, unsigned char *out, int nsamples) -{ - for (int i = 0; i < nsamples; i++){ - long int r = (long int) rint (in[i]); - if (r < MIN_UCHAR) - r = MIN_UCHAR; - else if (r > MAX_UCHAR) - r = MAX_UCHAR; - out[i] = r; - } -} diff --git a/gnuradio-core/src/lib/general/gri_float_to_uchar.h b/gnuradio-core/src/lib/general/gri_float_to_uchar.h deleted file mode 100644 index e24b1973fd..0000000000 --- a/gnuradio-core/src/lib/general/gri_float_to_uchar.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_FLOAT_TO_UCHAR_H -#define INCLUDED_GRI_FLOAT_TO_UCHAR_H - -#include <gr_core_api.h> - -/*! - * convert array of floats to unsigned chars with rounding and saturation. - */ -GR_CORE_API void gri_float_to_uchar (const float *in, unsigned char *out, int nsamples); - -#endif /* INCLUDED_GRI_FLOAT_TO_UCHAR_H */ diff --git a/gnuradio-core/src/lib/general/gri_glfsr.cc b/gnuradio-core/src/lib/general/gri_glfsr.cc deleted file mode 100644 index ba6951882b..0000000000 --- a/gnuradio-core/src/lib/general/gri_glfsr.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gri_glfsr.h> -#include <stdexcept> - -static int s_polynomial_masks[] = { - 0x00000000, - 0x00000001, // x^1 + 1 - 0x00000003, // x^2 + x^1 + 1 - 0x00000005, // x^3 + x^1 + 1 - 0x00000009, // x^4 + x^1 + 1 - 0x00000012, // x^5 + x^2 + 1 - 0x00000021, // x^6 + x^1 + 1 - 0x00000041, // x^7 + x^1 + 1 - 0x0000008E, // x^8 + x^4 + x^3 + x^2 + 1 - 0x00000108, // x^9 + x^4 + 1 - 0x00000204, // x^10 + x^4 + 1 - 0x00000402, // x^11 + x^2 + 1 - 0x00000829, // x^12 + x^6 + x^4 + x^1 + 1 - 0x0000100D, // x^13 + x^4 + x^3 + x^1 + 1 - 0x00002015, // x^14 + x^5 + x^3 + x^1 + 1 - 0x00004001, // x^15 + x^1 + 1 - 0x00008016, // x^16 + x^5 + x^3 + x^2 + 1 - 0x00010004, // x^17 + x^3 + 1 - 0x00020013, // x^18 + x^5 + x^2 + x^1 + 1 - 0x00040013, // x^19 + x^5 + x^2 + x^1 + 1 - 0x00080004, // x^20 + x^3 + 1 - 0x00100002, // x^21 + x^2 + 1 - 0x00200001, // x^22 + x^1 + 1 - 0x00400010, // x^23 + x^5 + 1 - 0x0080000D, // x^24 + x^4 + x^3 + x^1 + 1 - 0x01000004, // x^25 + x^3 + 1 - 0x02000023, // x^26 + x^6 + x^2 + x^1 + 1 - 0x04000013, // x^27 + x^5 + x^2 + x^1 + 1 - 0x08000004, // x^28 + x^3 + 1 - 0x10000002, // x^29 + x^2 + 1 - 0x20000029, // x^30 + x^4 + x^1 + 1 - 0x40000004, // x^31 + x^3 + 1 - 0x80000057 // x^32 + x^7 + x^5 + x^3 + x^2 + x^1 + 1 -}; - -int gri_glfsr::glfsr_mask(int degree) -{ - if (degree < 1 || degree > 32) - throw std::runtime_error("gri_glfsr::glfsr_mask(): degree must be between 1 and 32 inclusive"); - return s_polynomial_masks[degree]; -} diff --git a/gnuradio-core/src/lib/general/gri_glfsr.h b/gnuradio-core/src/lib/general/gri_glfsr.h deleted file mode 100644 index 9aae2d9f17..0000000000 --- a/gnuradio-core/src/lib/general/gri_glfsr.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_GLFSR_H -#define INCLUDED_GRI_GLFSR_H - -#include <gr_core_api.h> - -/*! - * \brief Galois Linear Feedback Shift Register using specified polynomial mask - * \ingroup misc - * - * Generates a maximal length pseudo-random sequence of length 2^degree-1 - */ - -class GR_CORE_API gri_glfsr -{ - private: - int d_shift_register; - int d_mask; - - public: - - gri_glfsr(int mask, int seed) { d_shift_register = seed; d_mask = mask; } - static int glfsr_mask(int degree); - - unsigned char next_bit() { - unsigned char bit = d_shift_register & 1; - d_shift_register >>= 1; - if (bit) - d_shift_register ^= d_mask; - return bit; - } - - int mask() const { return d_mask; } -}; - -#endif /* INCLUDED_GRI_GLFSR_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/gri_int_to_float.cc b/gnuradio-core/src/lib/general/gri_int_to_float.cc deleted file mode 100644 index 91da08897f..0000000000 --- a/gnuradio-core/src/lib/general/gri_int_to_float.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#define _ISOC9X_SOURCE -#include <gri_int_to_float.h> -#include <math.h> - -void -gri_int_to_float (const int *in, float *out, int nsamples) -{ - for (int i = 0; i < nsamples; i++){ - out[i] = static_cast<float>(in[i]); - } -} diff --git a/gnuradio-core/src/lib/general/gri_int_to_float.h b/gnuradio-core/src/lib/general/gri_int_to_float.h deleted file mode 100644 index 4b08b7c6be..0000000000 --- a/gnuradio-core/src/lib/general/gri_int_to_float.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_INT_TO_FLOAT_H -#define INCLUDED_GRI_INT_TO_FLOAT_H - -#include <gr_core_api.h> - -/* - * convert array of ints to floats - */ -GR_CORE_API void gri_int_to_float (const int *in, float *out, int nsamples); - - -#endif /* INCLUDED_GRI_INT_TO_FLOAT_H */ diff --git a/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.cc b/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.cc deleted file mode 100644 index 7d0af0fc75..0000000000 --- a/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gri_interleaved_short_to_complex.h> -#include <assert.h> - -void -gri_interleaved_short_to_complex (const short *in, - gr_complex *out, int nsamples) -{ - assert (nsamples % 2 == 0); - - for (int i = 0; i < nsamples/2; i++){ - out[i] = gr_complex (in[i*2 + 0], in[i*2 + 1]); - } -} diff --git a/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.h b/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.h deleted file mode 100644 index 8d8a0d16ef..0000000000 --- a/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_INTERLEAVED_SHORT_TO_COMPLEX_H -#define INCLUDED_GRI_INTERLEAVED_SHORT_TO_COMPLEX_H - -#include <gr_core_api.h> -#include <gr_complex.h> - -/* - * convert array of interleaved shorts to complex. - * the shorts contains real, imaginary, real, imaginary... - * nsamples is the number of shorts; it must be even. - */ -GR_CORE_API void gri_interleaved_short_to_complex (const short *in, gr_complex *out, int nsamples); - -#endif /* INCLUDED_GRI_INTERLEAVED_SHORT_TO_COMPLEX_H */ - - diff --git a/gnuradio-core/src/lib/general/gri_lfsr.h b/gnuradio-core/src/lib/general/gri_lfsr.h deleted file mode 100644 index 4202360774..0000000000 --- a/gnuradio-core/src/lib/general/gri_lfsr.h +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_LFSR_H -#define INCLUDED_GRI_LFSR_H - -#include <gr_core_api.h> -#include <stdexcept> -#include <stdint.h> - -/*! - * \brief Fibonacci Linear Feedback Shift Register using specified polynomial mask - * \ingroup misc - * - * Generates a maximal length pseudo-random sequence of length 2^degree-1 - * - * Constructor: gri_lfsr(int mask, int seed, int reg_len); - * - * mask - polynomial coefficients representing the locations - * of feedback taps from a shift register which are xor'ed - * together to form the new high order bit. - * - * Some common masks might be: - * x^4 + x^3 + x^0 = 0x19 - * x^5 + x^3 + x^0 = 0x29 - * x^6 + x^5 + x^0 = 0x61 - * - * seed - the initialization vector placed into the register - * durring initialization. Low order bit corresponds - * to x^0 coefficient -- the first to be shifted as output. - * - * reg_len - specifies the length of the feedback shift register - * to be used. Durring each iteration, the register - * is rightshifted one and the new bit is placed in bit reg_len. - * reg_len should generally be at least order(mask) + 1 - * - * - * see http://en.wikipedia.org/wiki/Linear_feedback_shift_register - * for more explanation. - * - * - * - * next_bit() - Standard LFSR operation - * - * Perform one cycle of the LFSR. The output bit is taken from - * the shift register LSB. The shift register MSB is assigned from - * the modulo 2 sum of the masked shift register. - * - * next_bit_scramble(unsigned char input) - Scramble an input stream - * - * Perform one cycle of the LFSR. The output bit is taken from - * the shift register LSB. The shift register MSB is assigned from - * the modulo 2 sum of the masked shift register and the input LSB. - * - * next_bit_descramble(unsigned char input) - Descramble an input stream - * - * Perform one cycle of the LFSR. The output bit is taken from - * the modulo 2 sum of the masked shift register and the input LSB. - * The shift register MSB is assigned from the LSB of the input. - * - * See http://en.wikipedia.org/wiki/Scrambler for operation of these - * last two functions (see multiplicative scrambler.) - * - */ - -class GR_CORE_API gri_lfsr -{ - private: - uint32_t d_shift_register; - uint32_t d_mask; - uint32_t d_seed; - uint32_t d_shift_register_length; // less than 32 - - static uint32_t - popCount(uint32_t x) - { - uint32_t r = x - ((x >> 1) & 033333333333) - - ((x >> 2) & 011111111111); - return ((r + (r >> 3)) & 030707070707) % 63; - } - - public: - - gri_lfsr(uint32_t mask, uint32_t seed, uint32_t reg_len) - : d_shift_register(seed), - d_mask(mask), - d_seed(seed), - d_shift_register_length(reg_len) - { - if (reg_len > 31) - throw std::invalid_argument("reg_len must be <= 31"); - } - - unsigned char next_bit() { - unsigned char output = d_shift_register & 1; - unsigned char newbit = popCount( d_shift_register & d_mask )%2; - d_shift_register = ((d_shift_register>>1) | (newbit<<d_shift_register_length)); - return output; - } - - unsigned char next_bit_scramble(unsigned char input) { - unsigned char output = d_shift_register & 1; - unsigned char newbit = (popCount( d_shift_register & d_mask )%2)^(input & 1); - d_shift_register = ((d_shift_register>>1) | (newbit<<d_shift_register_length)); - return output; - } - - unsigned char next_bit_descramble(unsigned char input) { - unsigned char output = (popCount( d_shift_register & d_mask )%2)^(input & 1); - unsigned char newbit = input & 1; - d_shift_register = ((d_shift_register>>1) | (newbit<<d_shift_register_length)); - return output; - } - - /*! - * Reset shift register to initial seed value - */ - void reset() { d_shift_register = d_seed; } - - /*! - * Rotate the register through x number of bits - * where we are just throwing away the results to get queued up correctly - */ - void pre_shift(int num){ - for(int i=0; i<num; i++){ - next_bit(); - } - } - - int mask() const { return d_mask; } -}; - -#endif /* INCLUDED_GRI_LFSR_H */ diff --git a/gnuradio-core/src/lib/general/gri_short_to_float.cc b/gnuradio-core/src/lib/general/gri_short_to_float.cc deleted file mode 100644 index d5d0e786e3..0000000000 --- a/gnuradio-core/src/lib/general/gri_short_to_float.cc +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gri_short_to_float.h> - -void -gri_short_to_float (const short *in, float *out, int nsamples) -{ - while (nsamples >= 4){ - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; - out[3] = in[3]; - out += 4; - in += 4; - nsamples -= 4; - } - - while (nsamples-- > 0) - *out++ = *in++; -} diff --git a/gnuradio-core/src/lib/general/gri_short_to_float.h b/gnuradio-core/src/lib/general/gri_short_to_float.h deleted file mode 100644 index 2ffdbb45b8..0000000000 --- a/gnuradio-core/src/lib/general/gri_short_to_float.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_SHORT_TO_FLOAT_H -#define INCLUDED_GRI_SHORT_TO_FLOAT_H - -#include <gr_core_api.h> - -/* - * convert array of shorts to floats - */ -GR_CORE_API void gri_short_to_float (const short *in, float *out, int nsamples); - - -#endif /* INCLUDED_GRI_SHORT_TO_FLOAT_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/gri_uchar_to_float.cc b/gnuradio-core/src/lib/general/gri_uchar_to_float.cc deleted file mode 100644 index 91f3e7336a..0000000000 --- a/gnuradio-core/src/lib/general/gri_uchar_to_float.cc +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gri_uchar_to_float.h> - -void -gri_uchar_to_float (const unsigned char *in, float *out, int nsamples) -{ - while (nsamples >= 4){ - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; - out[3] = in[3]; - out += 4; - in += 4; - nsamples -= 4; - } - - while (nsamples-- > 0) - *out++ = *in++; -} diff --git a/gnuradio-core/src/lib/general/gri_uchar_to_float.h b/gnuradio-core/src/lib/general/gri_uchar_to_float.h deleted file mode 100644 index 633c5d4ce7..0000000000 --- a/gnuradio-core/src/lib/general/gri_uchar_to_float.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_UCHAR_TO_FLOAT_H -#define INCLUDED_GRI_UCHAR_TO_FLOAT_H - -#include <gr_core_api.h> - -/* - * convert array of unsigned chars to floats - */ -GR_CORE_API void gri_uchar_to_float (const unsigned char *in, float *out, int nsamples); - - -#endif /* INCLUDED_GRI_UCHAR_TO_FLOAT_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/qa_general.cc b/gnuradio-core/src/lib/general/qa_general.cc index 26b21983e6..e2328c2cb2 100644 --- a/gnuradio-core/src/lib/general/qa_general.cc +++ b/gnuradio-core/src/lib/general/qa_general.cc @@ -26,28 +26,16 @@ */ #include <qa_general.h> -#include <qa_gr_firdes.h> #include <qa_gr_circular_file.h> -#include <qa_gr_cpm.h> -#include <qa_gr_fxpt.h> -#include <qa_gr_fxpt_nco.h> -#include <qa_gr_fxpt_vco.h> #include <qa_gr_math.h> -#include <qa_gri_lfsr.h> CppUnit::TestSuite * qa_general::suite () { CppUnit::TestSuite *s = new CppUnit::TestSuite ("general"); - s->addTest (qa_gr_firdes::suite ()); s->addTest (qa_gr_circular_file::suite ()); - s->addTest (qa_gr_cpm::suite ()); - s->addTest (qa_gr_fxpt::suite ()); - s->addTest (qa_gr_fxpt_nco::suite ()); - s->addTest (qa_gr_fxpt_vco::suite ()); s->addTest (qa_gr_math::suite ()); - s->addTest (qa_gri_lfsr::suite ()); return s; } diff --git a/gnuradio-core/src/lib/general/qa_gr_cpm.cc b/gnuradio-core/src/lib/general/qa_gr_cpm.cc deleted file mode 100644 index ee3e2bdea0..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_cpm.cc +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <qa_gr_cpm.h> -#include <gr_cpm.h> -#include <cppunit/TestAssert.h> - -const double DELTA = 1e-5; -const int L = 5; -const int samples_per_sym = 4; -const float taps_lrc[20] = { - 0, 0.002447174185242, 0.009549150281253, 0.020610737385376, - 0.034549150281253, 0.050000000000000, 0.065450849718747, 0.079389262614624, - 0.090450849718747, 0.097552825814758, 0.100000000000000, 0.097552825814758, - 0.090450849718747, 0.079389262614624, 0.065450849718747, 0.050000000000000, - 0.034549150281253, 0.020610737385376, 0.009549150281253, 0.002447174185242 -}; - - -const float taps_lsrc[20] = { // beta = 0.2 - 0.000000000000000, 0.009062686687436, 0.019517618142920, 0.030875041875917, - 0.042552315421249, 0.053912556756416, 0.064308860403517, 0.073130584159352, - 0.079847961304114, 0.084051371489937, 0.085482007518284, 0.084051371489937, - 0.079847961304114, 0.073130584159352, 0.064308860403517, 0.053912556756416, - 0.042552315421249, 0.030875041875917, 0.019517618142920, 0.009062686687436 -}; - - -const float taps_tfm[20] = { - -0.003946522220317, -0.005147757690530, -0.003171631690177, 0.003959659609805, - 0.017498721302356, 0.037346982678383, 0.062251889790391, 0.087364237065604, - 0.110049050955117, 0.125677762224511, 0.132288693729399, 0.125677762224511, - 0.110049050955117, 0.087364237065604, 0.062251889790391, 0.037346982678383, - 0.017498721302356, 0.003959659609805, -0.003171631690177, -0.005147757690530 -}; - - -const float taps_gaussian[20] = { // BT = 0.3 - 0.000000743866524, 0.000009286258371, 0.000085441834550, 0.000581664421923, - 0.002945540765422, 0.011178079812344, 0.032117220937421, 0.070841188736816, - 0.122053715366673, 0.167389736919915, 0.185594670675172, 0.167389736919915, - 0.122053715366673, 0.070841188736816, 0.032117220937421, 0.011178079812344, - 0.002945540765422, 0.000581664421923, 0.000085441834550, 0.000009286258371 -}; - - -// Check LREC phase response -void -qa_gr_cpm::t1 () -{ - std::vector<float> taps(gr_cpm::phase_response(gr_cpm::LREC, samples_per_sym, L)); - - for (int i = 0; i < L * samples_per_sym; i++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], 0.05, DELTA); - } -} - - -// Check LRC phase response -void -qa_gr_cpm::t2 () -{ - std::vector<float> taps(gr_cpm::phase_response(gr_cpm::LRC, samples_per_sym, L)); - float sum = 0; - - for (int i = 0; i < L * samples_per_sym; i++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], taps_lrc[i], DELTA); - sum += taps[i]; - } - - CPPUNIT_ASSERT_DOUBLES_EQUAL(sum, 1.0, DELTA); -} - - -// Check LSRC phase response -void -qa_gr_cpm::t3 () -{ - std::vector<float> taps(gr_cpm::phase_response(gr_cpm::LSRC, samples_per_sym, L, 0.2)); - float sum = 0; - - for (int i = 0; i < L * samples_per_sym; i++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], taps_lsrc[i], DELTA); - sum += taps[i]; - } - - CPPUNIT_ASSERT_DOUBLES_EQUAL(sum, 1.0, DELTA); -} - - -// Check the TFM phase response -void -qa_gr_cpm::t4 () -{ - std::vector<float> taps(gr_cpm::phase_response(gr_cpm::TFM, samples_per_sym, L)); - float sum = 0; - - for (int i = 0; i < L * samples_per_sym; i++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], taps_tfm[i], DELTA); - sum += taps[i]; - } - - CPPUNIT_ASSERT_DOUBLES_EQUAL(sum, 1.0, DELTA); -} - - -// Check the Gaussian phase response -void -qa_gr_cpm::t5 () -{ - std::vector<float> taps(gr_cpm::phase_response(gr_cpm::GAUSSIAN, samples_per_sym, L, 0.3)); - float sum = 0; - - for (int i = 0; i < L * samples_per_sym; i++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], taps_gaussian[i], DELTA); - sum += taps[i]; - } - - CPPUNIT_ASSERT_DOUBLES_EQUAL(sum, 1.0, DELTA); -} - diff --git a/gnuradio-core/src/lib/general/qa_gr_cpm.h b/gnuradio-core/src/lib/general/qa_gr_cpm.h deleted file mode 100644 index 2f46b42a78..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_cpm.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GR_CPM_H -#define _QA_GR_CPM_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_cpm : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_cpm); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST (t4); - CPPUNIT_TEST (t5); - CPPUNIT_TEST_SUITE_END (); - - private: - void t1 (); - void t2 (); - void t3 (); - void t4 (); - void t5 (); - -}; - - -#endif /* _QA_GR_CPM_H */ - diff --git a/gnuradio-core/src/lib/general/qa_gr_firdes.cc b/gnuradio-core/src/lib/general/qa_gr_firdes.cc deleted file mode 100644 index 877b4bd561..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_firdes.cc +++ /dev/null @@ -1,618 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <qa_gr_firdes.h> -#include <gr_firdes.h> -#include <cppunit/TestAssert.h> -#include <gr_complex.h> -#include <string.h> -#include <iostream> -#include <iomanip> -#include <stdio.h> - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -using std::vector; - -#if 0 -static void -print_taps (std::ostream &s, vector<float> &v) -{ - - for (unsigned int i = 0; i < v.size (); i++){ - printf ("tap[%2d] = %16.7e\n", i, v[i]); - } -} -#endif - -static void -check_symmetry (vector<float> &v) -{ - int n = v.size (); - int m = n / 2; - - for (int i = 0; i < m; i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL (v[i], v[n - i - 1], 1e-9); -} - -const static float t1_exp[53] = { - -9.0525491e-04, - 2.0713841e-04, - 1.2388536e-03, - 2.9683491e-04, - -1.7744775e-03, - -1.3599906e-03, - 2.2031884e-03, - 3.2744040e-03, - -1.8868084e-03, - -5.9935520e-03, - 6.4301129e-18, - 8.9516686e-03, - 4.2178580e-03, - -1.0998557e-02, - -1.1173409e-02, - 1.0455756e-02, - 2.0686293e-02, - -5.2032238e-03, - -3.1896964e-02, - -7.4998410e-03, - 4.3362070e-02, - 3.2502845e-02, - -5.3328082e-02, - -8.5621715e-02, - 6.0117975e-02, - 3.1128189e-01, - 4.3769023e-01, - 3.1128189e-01, - 6.0117975e-02, - -8.5621715e-02, - -5.3328082e-02, - 3.2502845e-02, - 4.3362070e-02, - -7.4998410e-03, - -3.1896964e-02, - -5.2032238e-03, - 2.0686293e-02, - 1.0455756e-02, - -1.1173409e-02, - -1.0998557e-02, - 4.2178580e-03, - 8.9516686e-03, - 6.4301129e-18, - -5.9935520e-03, - -1.8868084e-03, - 3.2744040e-03, - 2.2031884e-03, - -1.3599906e-03, - -1.7744775e-03, - 2.9683491e-04, - 1.2388536e-03, - 2.0713841e-04, - -9.0525491e-04 -}; - -const static float t2_exp[53] = { - 9.0380036e-04, - -2.0680559e-04, - -1.2368630e-03, - -2.9635796e-04, - 1.7716263e-03, - 1.3578053e-03, - -2.1996482e-03, - -3.2691427e-03, - 1.8837767e-03, - 5.9839217e-03, - -6.4197810e-18, - -8.9372853e-03, - -4.2110807e-03, - 1.0980885e-02, - 1.1155456e-02, - -1.0438956e-02, - -2.0653054e-02, - 5.1948633e-03, - 3.1845711e-02, - 7.4877902e-03, - -4.3292396e-02, - -3.2450620e-02, - 5.3242393e-02, - 8.5484132e-02, - -6.0021374e-02, - -3.1078172e-01, - 5.6184036e-01, - -3.1078172e-01, - -6.0021374e-02, - 8.5484132e-02, - 5.3242393e-02, - -3.2450620e-02, - -4.3292396e-02, - 7.4877902e-03, - 3.1845711e-02, - 5.1948633e-03, - -2.0653054e-02, - -1.0438956e-02, - 1.1155456e-02, - 1.0980885e-02, - -4.2110807e-03, - -8.9372853e-03, - -6.4197810e-18, - 5.9839217e-03, - 1.8837767e-03, - -3.2691427e-03, - -2.1996482e-03, - 1.3578053e-03, - 1.7716263e-03, - -2.9635796e-04, - -1.2368630e-03, - -2.0680559e-04, - 9.0380036e-04 -}; - -const static float t3_exp[107] = { - -1.8970841e-06, - -7.1057165e-04, - 5.4005696e-04, - 4.6233178e-04, - 2.0572044e-04, - 3.5209916e-04, - -1.4098573e-03, - 1.1279077e-04, - -6.2994129e-04, - 1.1450432e-03, - 1.3637283e-03, - -6.4360141e-04, - 3.6509900e-04, - -3.2864159e-03, - 7.0192874e-04, - 3.7524730e-04, - 2.0256115e-03, - 3.0641893e-03, - -3.6618244e-03, - 7.5592739e-05, - -5.5586505e-03, - 2.3849572e-03, - 4.0114378e-03, - 1.6636450e-03, - 4.7835698e-03, - -1.0191196e-02, - -3.8158931e-04, - -5.5551580e-03, - 5.3901658e-03, - 1.1366769e-02, - -3.0000482e-03, - 4.9341680e-03, - -2.0093076e-02, - 5.5752542e-17, - 1.2093617e-03, - 8.6089745e-03, - 2.2382140e-02, - -1.6854567e-02, - 1.6913920e-03, - -3.1222520e-02, - 3.2711059e-03, - 2.2604836e-02, - 8.1451107e-03, - 3.7583180e-02, - -5.2293688e-02, - -8.0551542e-03, - -4.0092729e-02, - 1.5582236e-02, - 9.7452506e-02, - -1.6183170e-02, - 8.3281815e-02, - -2.8196752e-01, - -1.0965768e-01, - 5.2867508e-01, - -1.0965768e-01, - -2.8196752e-01, - 8.3281815e-02, - -1.6183170e-02, - 9.7452506e-02, - 1.5582236e-02, - -4.0092729e-02, - -8.0551542e-03, - -5.2293688e-02, - 3.7583180e-02, - 8.1451107e-03, - 2.2604836e-02, - 3.2711059e-03, - -3.1222520e-02, - 1.6913920e-03, - -1.6854567e-02, - 2.2382140e-02, - 8.6089745e-03, - 1.2093617e-03, - 5.5752542e-17, - -2.0093076e-02, - 4.9341680e-03, - -3.0000482e-03, - 1.1366769e-02, - 5.3901658e-03, - -5.5551580e-03, - -3.8158931e-04, - -1.0191196e-02, - 4.7835698e-03, - 1.6636450e-03, - 4.0114378e-03, - 2.3849572e-03, - -5.5586505e-03, - 7.5592739e-05, - -3.6618244e-03, - 3.0641893e-03, - 2.0256115e-03, - 3.7524730e-04, - 7.0192874e-04, - -3.2864159e-03, - 3.6509900e-04, - -6.4360141e-04, - 1.3637283e-03, - 1.1450432e-03, - -6.2994129e-04, - 1.1279077e-04, - -1.4098573e-03, - 3.5209916e-04, - 2.0572044e-04, - 4.6233178e-04, - 5.4005696e-04, - -7.1057165e-04, - -1.8970841e-06 -}; - - -const static float t4_exp[] = { // low pass - 0.001059958362, -0.0002263929928, --0.001277606934, --0.0009675776237, - 0.001592264394, - 0.00243603508, --0.001451682881, --0.004769335967, -5.281541594e-18, - 0.007567512803, - 0.003658855334, --0.009761494584, - -0.01011830103, - 0.009636915289, - 0.0193619132, --0.004935568199, - -0.03060629964, --0.007267376408, - 0.04236677289, - 0.03197422624, - -0.05274848267, - -0.0850463286, - 0.05989059806, - 0.31065014, - 0.4370569289, - 0.31065014, - 0.05989059806, - -0.0850463286, - -0.05274848267, - 0.03197422624, - 0.04236677289, --0.007267376408, - -0.03060629964, --0.004935568199, - 0.0193619132, - 0.009636915289, - -0.01011830103, --0.009761494584, - 0.003658855334, - 0.007567512803, -5.281541594e-18, --0.004769335967, --0.001451682881, - 0.00243603508, - 0.001592264394, --0.0009675776237, --0.001277606934, -0.0002263929928, - 0.001059958362, -}; - - -const static float t5_exp[] = { //high pass --0.001062123571, --0.0002268554381, - 0.001280216733, - 0.000969554123, --0.001595516922, --0.002441011136, - 0.001454648213, - 0.004779078532, --5.292330097e-18, --0.007582970895, - -0.00366632943, - 0.009781434201, - 0.01013896987, --0.009656600654, - -0.01940146461, - 0.004945650231, - 0.03066881932, - 0.00728222169, - -0.04245331511, - -0.03203954175, - 0.05285623297, - 0.08522006124, - -0.06001294032, - -0.3112847209, - 0.5630782247, - -0.3112847209, - -0.06001294032, - 0.08522006124, - 0.05285623297, - -0.03203954175, - -0.04245331511, - 0.00728222169, - 0.03066881932, - 0.004945650231, - -0.01940146461, --0.009656600654, - 0.01013896987, - 0.009781434201, - -0.00366632943, --0.007582970895, --5.292330097e-18, - 0.004779078532, - 0.001454648213, --0.002441011136, --0.001595516922, - 0.000969554123, - 0.001280216733, --0.0002268554381, --0.001062123571, -}; - -const static float t6_exp[] = { // bandpass -0.0002809273137, --0.001047327649, -7.936541806e-05, --0.0004270860809, -0.0007595835486, -0.0008966081077, --0.0004236323002, -0.0002423936094, --0.002212299034, -0.0004807534278, -0.0002620361629, - 0.001443728455, - 0.002229931997, --0.002720607212, -5.731141573e-05, --0.004297634587, - 0.001878833398, - 0.003217151389, - 0.001357055153, - 0.003965090029, --0.008576190099, --0.0003257228818, --0.004805727862, - 0.004721920472, - 0.01007549558, --0.002688719891, - 0.004467967432, - -0.01837076992, -5.119658377e-17, - 0.001125075156, - 0.008071650751, - 0.02113764361, - -0.01602453552, - 0.001618095324, - -0.03004053794, - 0.003163811285, - 0.0219683405, - 0.007950295694, - 0.03682873398, - -0.05142467469, - -0.00794606097, - -0.03965795785, - 0.01544955093, - 0.09681399167, - -0.01610304788, - 0.08297294378, - -0.2811714709, - -0.1094062924, - 0.5275565982, - -0.1094062924, - -0.2811714709, - 0.08297294378, - -0.01610304788, - 0.09681399167, - 0.01544955093, - -0.03965795785, - -0.00794606097, - -0.05142467469, - 0.03682873398, - 0.007950295694, - 0.0219683405, - 0.003163811285, - -0.03004053794, - 0.001618095324, - -0.01602453552, - 0.02113764361, - 0.008071650751, - 0.001125075156, -5.119658377e-17, - -0.01837076992, - 0.004467967432, --0.002688719891, - 0.01007549558, - 0.004721920472, --0.004805727862, --0.0003257228818, --0.008576190099, - 0.003965090029, - 0.001357055153, - 0.003217151389, - 0.001878833398, --0.004297634587, -5.731141573e-05, --0.002720607212, - 0.002229931997, - 0.001443728455, -0.0002620361629, -0.0004807534278, --0.002212299034, -0.0002423936094, --0.0004236323002, -0.0008966081077, -0.0007595835486, --0.0004270860809, -7.936541806e-05, --0.001047327649, -0.0002809273137, -}; - -void -qa_gr_firdes::t1 () -{ - vector<float> taps = - gr_firdes::low_pass ( 1.0, - 8000, - 1750, - 500, - gr_firdes::WIN_HAMMING); - - // cout << "ntaps: " << taps.size () << endl; - // print_taps (cout, taps); - - CPPUNIT_ASSERT_EQUAL (NELEM (t1_exp), taps.size ()); - for (unsigned int i = 0; i < taps.size (); i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL (t1_exp[i], taps[i], 1e-9); - - check_symmetry (taps); -} - -void -qa_gr_firdes::t2 () -{ - vector<float> taps = - gr_firdes::high_pass ( 1.0, - 8000, - 1750, - 500, - gr_firdes::WIN_HAMMING); - - // cout << "ntaps: " << taps.size () << endl; - // print_taps (cout, taps); - - CPPUNIT_ASSERT_EQUAL (NELEM (t2_exp), taps.size ()); - - for (unsigned int i = 0; i < taps.size (); i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL (t2_exp[i], taps[i], 1e-9); - - check_symmetry (taps); -} - -void -qa_gr_firdes::t3 () -{ - vector<float> taps = - gr_firdes::band_pass ( 1.0, - 20e6, - 5.75e6 - (5.28e6/2), - 5.75e6 + (5.28e6/2), - 0.62e6, - gr_firdes::WIN_HAMMING); - - // cout << "ntaps: " << taps.size () << endl; - // print_taps (cout, taps); - - CPPUNIT_ASSERT_EQUAL (NELEM (t3_exp), taps.size ()); - - for (unsigned int i = 0; i < taps.size (); i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL (t3_exp[i], taps[i], 1e-7); - - check_symmetry (taps); -} - -void -qa_gr_firdes::t4 () -{ - vector<float> taps = - gr_firdes::low_pass_2 ( 1.0, - 8000, - 1750, - 500, - 66, - gr_firdes::WIN_HAMMING); - - // std::cout << "ntaps: " << taps.size () << std::endl; - // print_taps (std::cout, taps); - - CPPUNIT_ASSERT_EQUAL (NELEM (t4_exp), taps.size ()); - for (unsigned int i = 0; i < taps.size (); i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL (t4_exp[i], taps[i], 1e-9); - - - check_symmetry (taps); -} - -void -qa_gr_firdes::t5 () -{ - vector<float> taps = - gr_firdes::high_pass_2 ( 1.0, - 8000, - 1750, - 500, - 66, - gr_firdes::WIN_HAMMING); - - // std::cout << "ntaps: " << taps.size () << std::endl; - // print_taps (std::cout, taps); - - CPPUNIT_ASSERT_EQUAL (NELEM (t5_exp), taps.size ()); - - for (unsigned int i = 0; i < taps.size (); i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL (t5_exp[i], taps[i], 1e-9); - - check_symmetry (taps); -} - -void -qa_gr_firdes::t6 () -{ - vector<float> taps = - gr_firdes::band_pass_2 ( 1.0, - 20e6, - 5.75e6 - (5.28e6/2), - 5.75e6 + (5.28e6/2), - 0.62e6, - 66, - gr_firdes::WIN_HAMMING); - - // std::cout << "ntaps: " << taps.size () << std::endl; - // print_taps (std::cout, taps); - - CPPUNIT_ASSERT_EQUAL (NELEM (t6_exp), taps.size ()); - - for (unsigned int i = 0; i < taps.size (); i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL (t6_exp[i], taps[i], 1e-7); - - check_symmetry (taps); -} - -void -qa_gr_firdes::t7 () -{ -} diff --git a/gnuradio-core/src/lib/general/qa_gr_firdes.h b/gnuradio-core/src/lib/general/qa_gr_firdes.h deleted file mode 100644 index 98cee99b97..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_firdes.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GR_FIRDES_H_ -#define _QA_GR_FIRDES_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_firdes : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_firdes); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST (t4); - CPPUNIT_TEST (t5); - CPPUNIT_TEST (t6); - CPPUNIT_TEST (t7); - CPPUNIT_TEST_SUITE_END (); - - private: - void t1 (); - void t2 (); - void t3 (); - void t4 (); - void t5 (); - void t6 (); - void t7 (); - -}; - - -#endif /* _QA_GR_FIRDES_H_ */ diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt.cc deleted file mode 100644 index 7eac0d8964..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt.cc +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <qa_gr_fxpt.h> -#include <gr_fxpt.h> -#include <cppunit/TestAssert.h> -#include <iostream> -#include <stdio.h> -#include <unistd.h> -#include <math.h> - -static const float SIN_COS_TOLERANCE = 1e-5; - -void -qa_gr_fxpt::t0 () -{ - CPPUNIT_ASSERT_DOUBLES_EQUAL (M_PI/2, gr_fxpt::fixed_to_float (0x40000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, gr_fxpt::fixed_to_float (0x00000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL (-M_PI, gr_fxpt::fixed_to_float (0x80000000), SIN_COS_TOLERANCE); - - if (0){ - /* - * These are disabled because of some precision issues. - * - * Different compilers seem to have different opinions on whether - * the calulations are done single or double (or extended) - * precision. Any of the answers are fine for our real purpose, but - * sometimes the answer is off by a few bits at the bottom. - * Hence, the disabled check. - */ - CPPUNIT_ASSERT_EQUAL ((gr_int32) 0x40000000, gr_fxpt::float_to_fixed (M_PI/2)); - CPPUNIT_ASSERT_EQUAL ((gr_int32) 0, gr_fxpt::float_to_fixed (0)); - CPPUNIT_ASSERT_EQUAL ((gr_int32) 0x80000000, gr_fxpt::float_to_fixed (-M_PI)); - } -} - -void -qa_gr_fxpt::t1 () -{ - - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x00000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0.707106781, gr_fxpt::sin (0x20000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 1, gr_fxpt::sin (0x40000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0.707106781, gr_fxpt::sin (0x60000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x7fffffff), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x80000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x80000001), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL (-1, gr_fxpt::sin (-0x40000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL (-0.707106781, gr_fxpt::sin (-0x20000000), SIN_COS_TOLERANCE); - - - for (float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600){ - float expected = sin (p); - float actual = gr_fxpt::sin (gr_fxpt::float_to_fixed (p)); - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected, actual, SIN_COS_TOLERANCE); - } -} - -void -qa_gr_fxpt::t2 () -{ - for (float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600){ - float expected = cos (p); - float actual = gr_fxpt::cos (gr_fxpt::float_to_fixed (p)); - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected, actual, SIN_COS_TOLERANCE); - } -} - -void -qa_gr_fxpt::t3 () -{ - for (float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600){ - float expected_sin = sin (p); - float expected_cos = cos (p); - float actual_sin; - float actual_cos; - gr_fxpt::sincos (gr_fxpt::float_to_fixed (p), &actual_sin, &actual_cos); - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_sin, actual_sin, SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_cos, actual_cos, SIN_COS_TOLERANCE); - } -} diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt.h b/gnuradio-core/src/lib/general/qa_gr_fxpt.h deleted file mode 100644 index 72211563e7..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_QA_GR_FXPT_H -#define INCLUDED_QA_GR_FXPT_H - - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fxpt : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fxpt); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void t0 (); - void t1 (); - void t2 (); - void t3 (); - -}; - -#endif /* INCLUDED_QA_GR_FXPT_H */ - - diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc deleted file mode 100644 index 6f208eac80..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <qa_gr_fxpt_nco.h> -#include <gr_fxpt_nco.h> -#include <gr_nco.h> -#include <cppunit/TestAssert.h> -#include <iostream> -#include <stdio.h> -#include <unistd.h> -#include <math.h> - -static const float SIN_COS_TOLERANCE = 1e-5; - -//static const float SIN_COS_FREQ = 5003; -static const float SIN_COS_FREQ = 4096; - -static const int SIN_COS_BLOCK_SIZE = 100000; - -static double max_d(double a, double b) -{ - return fabs(a) > fabs(b) ? a : b; -} - -void -qa_gr_fxpt_nco::t0 () -{ - gr_nco<float,float> ref_nco; - gr_fxpt_nco new_nco; - double max_error = 0, max_phase_error = 0; - - ref_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); - new_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); - - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE); - - for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - float ref_sin = ref_nco.sin (); - float new_sin = new_nco.sin (); - //printf ("i = %6d\n", i); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_sin, new_sin, SIN_COS_TOLERANCE); - - max_error = max_d (max_error, ref_sin-new_sin); - - float ref_cos = ref_nco.cos (); - float new_cos = new_nco.cos (); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_cos, new_cos, SIN_COS_TOLERANCE); - - max_error = max_d (max_error, ref_cos-new_cos); - - ref_nco.step (); - new_nco.step (); - - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE); - - max_phase_error = max_d (max_phase_error, ref_nco.get_phase()-new_nco.get_phase()); - } - // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); -} - -void -qa_gr_fxpt_nco::t1 () -{ - gr_nco<float,float> ref_nco; - gr_fxpt_nco new_nco; - gr_complex ref_block[SIN_COS_BLOCK_SIZE]; - gr_complex new_block[SIN_COS_BLOCK_SIZE]; - double max_error = 0; - - ref_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); - new_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); - - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE); - - ref_nco.sincos ((gr_complex*)ref_block, SIN_COS_BLOCK_SIZE); - new_nco.sincos ((gr_complex*)new_block, SIN_COS_BLOCK_SIZE); - - for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i].real(), new_block[i].real(), SIN_COS_TOLERANCE); - max_error = max_d (max_error, ref_block[i].real()-new_block[i].real()); - - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i].imag(), new_block[i].imag(), SIN_COS_TOLERANCE); - max_error = max_d (max_error, ref_block[i].imag()-new_block[i].imag()); - } - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE); - // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); -} - -void -qa_gr_fxpt_nco::t2 () -{ -} - -void -qa_gr_fxpt_nco::t3 () -{ -} diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.h b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.h deleted file mode 100644 index 8998922bbb..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_QA_GR_FXPT_NCO_H -#define INCLUDED_QA_GR_FXPT_NCO_H - - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fxpt_nco : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fxpt_nco); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void t0 (); - void t1 (); - void t2 (); - void t3 (); - -}; - -#endif /* INCLUDED_QA_GR_FXPT_NCO_H */ - - diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc deleted file mode 100644 index 5b6993a30c..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <qa_gr_fxpt_vco.h> -#include <gr_fxpt_vco.h> -#include <gr_vco.h> -#include <cppunit/TestAssert.h> -#include <iostream> -#include <stdio.h> -#include <unistd.h> -#include <math.h> - -static const float SIN_COS_TOLERANCE = 1e-5; - -static const float SIN_COS_K = 0.42; -static const float SIN_COS_AMPL = 0.8; - -static const int SIN_COS_BLOCK_SIZE = 100000; - -static double max_d(double a, double b) -{ - return fabs(a) > fabs(b) ? a : b; -} - -void -qa_gr_fxpt_vco::t0 () -{ - gr_vco<float,float> ref_vco; - gr_fxpt_vco new_vco; - double max_error = 0, max_phase_error = 0; - float input[SIN_COS_BLOCK_SIZE]; - - for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - input[i] = sin(double(i)); - } - - for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - float ref_cos = ref_vco.cos (); - float new_cos = new_vco.cos (); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_cos, new_cos, SIN_COS_TOLERANCE); - - max_error = max_d (max_error, ref_cos-new_cos); - - ref_vco.adjust_phase (input[i]); - new_vco.adjust_phase (input[i]); - - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_vco.get_phase(), new_vco.get_phase(), SIN_COS_TOLERANCE); - - max_phase_error = max_d (max_phase_error, ref_vco.get_phase()-new_vco.get_phase()); - } - // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); -} - - -void -qa_gr_fxpt_vco::t1 () -{ - gr_vco<float,float> ref_vco; - gr_fxpt_vco new_vco; - float ref_block[SIN_COS_BLOCK_SIZE]; - float new_block[SIN_COS_BLOCK_SIZE]; - float input[SIN_COS_BLOCK_SIZE]; - double max_error = 0; - - for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - input[i] = sin(double(i)); - } - - ref_vco.cos (ref_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL); - new_vco.cos (new_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL); - - for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i], new_block[i], SIN_COS_TOLERANCE); - max_error = max_d (max_error, ref_block[i]-new_block[i]); - } - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_vco.get_phase(), new_vco.get_phase(), SIN_COS_TOLERANCE); - // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, ref_vco.get_phase()-new_vco.get_phase()); -} - -void -qa_gr_fxpt_vco::t2 () -{ -} - -void -qa_gr_fxpt_vco::t3 () -{ -} diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.h b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.h deleted file mode 100644 index fab8022e36..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_QA_GR_FXPT_VCO_H -#define INCLUDED_QA_GR_FXPT_VCO_H - - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fxpt_vco : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fxpt_vco); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void t0 (); - void t1 (); - void t2 (); - void t3 (); - -}; - -#endif /* INCLUDED_QA_GR_FXPT_VCO_H */ - - diff --git a/gnuradio-core/src/lib/general/qa_gri_lfsr.cc b/gnuradio-core/src/lib/general/qa_gri_lfsr.cc deleted file mode 100644 index 87d610df68..0000000000 --- a/gnuradio-core/src/lib/general/qa_gri_lfsr.cc +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gri_lfsr.h> -#include <qa_gri_lfsr.h> -#include <cppunit/TestAssert.h> -#include <stdio.h> -#include <string.h> -#include <vector> - -void -qa_gri_lfsr::test_lfsr () -{ - int mask = 0x19; - int seed = 0x01; - int length = 5; - - gri_lfsr lfsr1(mask,seed,length); - gri_lfsr lfsr2(mask,seed,length); - - unsigned char expected[] = {1, 0, 1, 1, 0, 1, 0, 1, 0, 0}; - - for(unsigned int i=0; i<31; i++){ - lfsr1.next_bit(); - } - - // test that after one lfsr cycle we still match out uncycled lfsr - for (unsigned int i = 0; i < 41; i++) { - CPPUNIT_ASSERT_EQUAL((int) lfsr1.next_bit(), (int) lfsr2.next_bit()); - } - - // test the known correct values at the given shift offset - for(unsigned int i=0; i<10; i++){ - CPPUNIT_ASSERT_EQUAL((int) lfsr1.next_bit(), (int) expected[i]); - } - - // test for register length too long - CPPUNIT_ASSERT_THROW(gri_lfsr(mask, seed, 32), std::invalid_argument); -} - -void -qa_gri_lfsr::test_scrambler() -{ - // CCSDS 7-bit scrambler - int mask = 0x8A; - int seed = 0x7F; - int length = 7; - - gri_lfsr scrambler(mask, seed, length); - - // Impulse (1 and 126 more zeroes) - unsigned char src[] = - { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0 }; // flush bits - - // Impulse response (including leading bits) - unsigned char expected[] = - { 1, 1, 1, 1, 1, 1, 1, - 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, - 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, - 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, - 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, - 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, - 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, - 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, }; - - int len = sizeof(src); - std::vector<unsigned char> actual(len); - - for (int i = 0; i < len; i++) - actual[i] = scrambler.next_bit_scramble(src[i]); - - CPPUNIT_ASSERT(memcmp(expected, &actual[0], len) == 0); -} - -void -qa_gri_lfsr::test_descrambler() -{ - // CCSDS 7-bit scrambler - int mask = 0x8A; - int seed = 0x7F; - int length = 7; - - gri_lfsr descrambler(mask, seed, length); - - // Scrambled sequence (impulse response) - unsigned char src[] = - { 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, - 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, - 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, - 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, - 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, - 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, - 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0 }; - - // Original (garbage while synchronizing, them impulse) - unsigned char expected[] = - { 0, 1, 0, 0, 1, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - - int len = sizeof(src); - std::vector<unsigned char> actual(len); - - for (int i = 0; i < len; i++) - actual[i] = descrambler.next_bit_descramble(src[i]); - - CPPUNIT_ASSERT(memcmp(expected, &actual[0], len) == 0); -} diff --git a/gnuradio-core/src/lib/general/qa_gri_lfsr.h b/gnuradio-core/src/lib/general/qa_gri_lfsr.h deleted file mode 100644 index e91843bbb3..0000000000 --- a/gnuradio-core/src/lib/general/qa_gri_lfsr.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _QA_GRI_LFSR_H_ -#define _QA_GRI_LFSR_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_lfsr : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE(qa_gri_lfsr); - CPPUNIT_TEST(test_lfsr); - CPPUNIT_TEST(test_scrambler); - CPPUNIT_TEST(test_descrambler); - CPPUNIT_TEST_SUITE_END(); - - private: - void test_lfsr(); - void test_scrambler(); - void test_descrambler(); -}; - -#endif /* _QA_GRI_LFSR_H_ */ diff --git a/gnuradio-core/src/lib/gengen/CMakeLists.txt b/gnuradio-core/src/lib/gengen/CMakeLists.txt index db3103a26a..45834ced5f 100644 --- a/gnuradio-core/src/lib/gengen/CMakeLists.txt +++ b/gnuradio-core/src/lib/gengen/CMakeLists.txt @@ -84,36 +84,6 @@ endmacro(expand_h_cc_i) expand_h_cc_i(gr_vector_source_X b s i f c) expand_h_cc_i(gr_vector_insert_X b) expand_h_cc_i(gr_vector_sink_X b s i f c) -expand_h_cc_i(gr_noise_source_X s i f c) -expand_h_cc_i(gr_fastnoise_source_X s i f c) -expand_h_cc_i(gr_sig_source_X s i f c) -expand_h_cc_i(gr_probe_signal_X b s i f c) -expand_h_cc_i(gr_probe_signal_vX b s i f c) - -expand_h_cc_i(gr_add_const_XX bb ss ii ff cc sf) -expand_h_cc_i(gr_multiply_const_XX ss ii) -expand_h_cc_i(gr_add_XX ss ii cc) -expand_h_cc_i(gr_sub_XX ss ii ff cc) -expand_h_cc_i(gr_multiply_XX ss ii) -expand_h_cc_i(gr_divide_XX ss ii ff cc) -expand_h_cc_i(gr_mute_XX ss ii ff cc) -expand_h_cc_i(gr_add_const_vXX ss ii ff cc) -expand_h_cc_i(gr_multiply_const_vXX ss ii ff cc) -expand_h_cc_i(gr_integrate_XX ss ii ff cc) -expand_h_cc_i(gr_moving_average_XX ss ii ff cc) - -expand_h_cc_i(gr_chunks_to_symbols_XX bf bc sf sc if ic) -expand_h_cc_i(gr_unpacked_to_packed_XX bb ss ii) -expand_h_cc_i(gr_packed_to_unpacked_XX bb ss ii) -expand_h_cc_i(gr_xor_XX bb ss ii) -expand_h_cc_i(gr_and_XX bb ss ii) -expand_h_cc_i(gr_and_const_XX bb ss ii) -expand_h_cc_i(gr_or_XX bb ss ii) -expand_h_cc_i(gr_not_XX bb ss ii) -expand_h_cc_i(gr_sample_and_hold_XX bb ss ii ff) -expand_h_cc_i(gr_argmax_XX fs is ss) -expand_h_cc_i(gr_max_XX ff ii ss) -expand_h_cc_i(gr_peak_detector_XX fb ib sb) add_custom_target(gengen_generated DEPENDS ${generated_gengen_includes} @@ -157,15 +127,13 @@ list(APPEND gnuradio_core_sources install(FILES ${generated_gengen_includes} ${CMAKE_CURRENT_SOURCE_DIR}/gr_endianness.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_noise_type.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sig_source_waveform.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel" ) if(ENABLE_PYTHON) install(FILES - ${generated_gengen_swigs} + ${generated_gengen_swigs} ${CMAKE_CURRENT_SOURCE_DIR}/gr_endianness.i ${CMAKE_CURRENT_SOURCE_DIR}/gengen.i ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i diff --git a/gnuradio-core/src/lib/gengen/generate_common.py b/gnuradio-core/src/lib/gengen/generate_common.py index 13d01b0f90..68913f9a75 100755 --- a/gnuradio-core/src/lib/gengen/generate_common.py +++ b/gnuradio-core/src/lib/gengen/generate_common.py @@ -32,45 +32,11 @@ ss_signatures = ['s', 'i', 'f', 'c'] ss_roots = [ 'gr_vector_source_X', 'gr_vector_sink_X', - 'gr_noise_source_X', - 'gr_sig_source_X', - 'gr_probe_signal_X', - 'gr_probe_signal_vX' ] # regular blocks reg_signatures = ['ss', 'ii', 'ff', 'cc'] -reg_roots = [ - 'gr_add_const_XX', - 'gr_sub_XX', - 'gr_divide_XX', - 'gr_mute_XX', - 'gr_add_const_vXX', - 'gr_multiply_const_vXX', - 'gr_integrate_XX', - 'gr_moving_average_XX', - ] - -# other blocks -others = ( - ('gr_chunks_to_symbols_XX', ('bf', 'bc', 'sf', 'sc', 'if', 'ic')), - ('gr_unpacked_to_packed_XX', ('bb','ss','ii')), - ('gr_packed_to_unpacked_XX', ('bb','ss','ii')), - ('gr_xor_XX', ('bb','ss','ii')), - ('gr_and_XX', ('bb','ss','ii')), - ('gr_and_const_XX', ('bb','ss','ii')), - ('gr_or_XX', ('bb','ss','ii')), - ('gr_not_XX', ('bb','ss','ii')), - ('gr_sample_and_hold_XX', ('bb','ss','ii','ff')), - ('gr_argmax_XX', ('fs','is','ss')), - ('gr_max_XX', ('ff','ii','ss')), - ('gr_peak_detector_XX', ('fb','ib','sb')), - ('gr_multiply_XX', ('ss','ii')), - ('gr_multiply_const_XX', ('ss','ii')), - ('gr_add_XX', ('ss','cc','ii')) - ) - def expand_h_cc_i (root, sig): # root looks like 'gr_vector_sink_X' @@ -82,23 +48,11 @@ def expand_h_cc_i (root, sig): def generate (): - expand_h_cc_i ('gr_add_const_XX', 'sf') # for MC4020 expand_h_cc_i ('gr_vector_sink_X', 'b') expand_h_cc_i ('gr_vector_source_X', 'b') - expand_h_cc_i ('gr_probe_signal_X', 'b') - expand_h_cc_i ('gr_probe_signal_vX', 'b') for r in ss_roots: for s in ss_signatures: expand_h_cc_i (r, s) - for r in reg_roots : - for s in reg_signatures: - expand_h_cc_i (r, s) - - for root, sigs in others: - for s in sigs: - expand_h_cc_i (root, s) - - if __name__ == '__main__': generate () diff --git a/gnuradio-core/src/lib/gengen/gengen.i b/gnuradio-core/src/lib/gengen/gengen.i index d1895bfa83..7d8c27fe68 100644 --- a/gnuradio-core/src/lib/gengen/gengen.i +++ b/gnuradio-core/src/lib/gengen/gengen.i @@ -22,12 +22,8 @@ %{ #include "gr_endianness.h" -#include "gr_sig_source_waveform.h" -#include "gr_noise_type.h" %} %include "gr_endianness.i" -%include "gr_sig_source_waveform.h" -%include "gr_noise_type.h" %include "gengen_generated.i" diff --git a/gnuradio-core/src/lib/gengen/gr_add_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_add_XX.cc.t deleted file mode 100644 index 5a888125bf..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_XX.cc.t +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (size_t vlen) -{ - return gnuradio::get_initial_sptr (new @NAME@ (vlen)); -} - -@NAME@::@NAME@ (size_t vlen) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)*vlen), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)*vlen)), - d_vlen (vlen) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - for (size_t i = 0; i < noutput_items*d_vlen; i++){ - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc += ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_add_XX.h.t b/gnuradio-core/src/lib/gengen/gr_add_XX.h.t deleted file mode 100644 index cd6d80cd9a..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_XX.h.t +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -/*! - * \brief output = sum (input_0, input_1, ...) - * \ingroup math_blk - * - * Add across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - @NAME@ (size_t vlen); - - size_t d_vlen; - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_add_XX.i.t b/gnuradio-core/src/lib/gengen/gr_add_XX.i.t deleted file mode 100644 index b2c5106106..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (size_t vlen); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_add_const_XX.cc.t deleted file mode 100644 index 3dccc86b80..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_const_XX.cc.t +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (@O_TYPE@ k) -{ - return gnuradio::get_initial_sptr (new @NAME@ (k)); -} - -@NAME@::@NAME@ (@O_TYPE@ k) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_k (k) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0]; - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int size = noutput_items; - - while (size >= 8){ - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - size -= 8; - } - - while (size-- > 0) - *optr++ = *iptr++ + d_k; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_XX.h.t b/gnuradio-core/src/lib/gengen/gr_add_const_XX.h.t deleted file mode 100644 index 00d2c9b587..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_const_XX.h.t +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - -/*! - * \brief output = input + constant - * \ingroup math_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - - @O_TYPE@ d_k; // the constant - @NAME@ (@O_TYPE@ k); - - public: - @O_TYPE@ k () const { return d_k; } - void set_k (@O_TYPE@ k) { d_k = k; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_XX.i.t b/gnuradio-core/src/lib/gengen/gr_add_const_XX.i.t deleted file mode 100644 index b7921554e5..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_const_XX.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (@TYPE@ k); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (@TYPE@ k); - - public: - @TYPE@ k () const { return d_k; } - void set_k (@TYPE@ k) { d_k = k; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t deleted file mode 100755 index b29f3014d8..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k) -{ - return gnuradio::get_initial_sptr (new @NAME@ (k)); -} - -@NAME@::@NAME@ (const std::vector<@I_TYPE@> &k) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof(@I_TYPE@)*k.size()), - gr_make_io_signature (1, 1, sizeof(@O_TYPE@)*k.size())) -{ - d_k = k; -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *iptr = (@O_TYPE@ *)input_items[0]; - @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; - - int nitems_per_block = output_signature()->sizeof_stream_item(0)/sizeof(@I_TYPE@); - - for (int i = 0; i < noutput_items; i++) - for (int j = 0; j < nitems_per_block; j++) - *optr++ = *iptr++ + d_k[j]; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t deleted file mode 100644 index 438a84bfdd..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); - -/*! - * \brief output vector = input vector + constant vector - * \ingroup math_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); - - std::vector<@I_TYPE@> d_k; // the constant - @NAME@ (const std::vector<@I_TYPE@> &k); - - public: - const std::vector<@I_TYPE@> k () const { return d_k; } - void set_k (const std::vector<@I_TYPE@> &k) { d_k = k; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.i.t b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.i.t deleted file mode 100755 index e0e6ae9051..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (const std::vector<@I_TYPE@> &k); - - public: - std::vector<@I_TYPE@> k () const { return d_k; } - void set_k (const std::vector<@I_TYPE@> &k) { d_k = k; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_and_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_and_XX.cc.t deleted file mode 100644 index 9d60e092af..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_and_XX.cc.t +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ () -{ - return gnuradio::get_initial_sptr (new @NAME@ ()); -} - -@NAME@::@NAME@ () - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - for (int i = 0; i < noutput_items; i++) { - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc = acc & ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_and_XX.h.t b/gnuradio-core/src/lib/gengen/gr_and_XX.h.t deleted file mode 100644 index 2247780968..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_and_XX.h.t +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - -/*! - * \brief output = input_0 & input_1 & , ... & input_N) - * \ingroup math_blk - * - * bitwise boolean and across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - - @NAME@ (); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_and_XX.i.t b/gnuradio-core/src/lib/gengen/gr_and_XX.i.t deleted file mode 100644 index 06db5ca59d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_and_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_and_const_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_and_const_XX.cc.t deleted file mode 100644 index d4f9a4b613..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_and_const_XX.cc.t +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (@I_TYPE@ k) -{ - return gnuradio::get_initial_sptr (new @NAME@ (k)); -}; - -@NAME@::@NAME@ (@I_TYPE@ k) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_k (k) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0]; - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int size = noutput_items; - - while (size >= 8) { - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - *optr++ = *iptr++ & d_k; - size -= 8; - } - - while (size-- > 0) - *optr++ = *iptr++ & d_k; - - return (noutput_items); -} diff --git a/gnuradio-core/src/lib/gengen/gr_and_const_XX.h.t b/gnuradio-core/src/lib/gengen/gr_and_const_XX.h.t deleted file mode 100644 index b331f33ccd..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_and_const_XX.h.t +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - -/*! - * \brief output_N = input_N & value - * \ingroup math_blk - * - * bitwise boolean and of const to the data stream. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - - @O_TYPE@ d_k; // the constant - @NAME@ (@O_TYPE@ k); - - public: - @O_TYPE@ k () const { return d_k; } - void set_k (@O_TYPE@ k) { d_k = k; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_and_const_XX.i.t b/gnuradio-core/src/lib/gengen/gr_and_const_XX.i.t deleted file mode 100644 index c797c45eb7..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_and_const_XX.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (@O_TYPE@ k); - - public: - @O_TYPE@ k () const { return d_k; } - void set_k (@O_TYPE@ k) { d_k = k; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_argmax_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_argmax_XX.cc.t deleted file mode 100644 index f780bd811f..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_argmax_XX.cc.t +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ ( size_t vlen ) -{ - return @SPTR_NAME@ ( new @NAME@(vlen)); -} - -@NAME@::@NAME@( size_t vlen) - : gr_sync_block ( "@BASE_NAME@", - gr_make_io_signature (1, -1, vlen*sizeof (@I_TYPE@)), - gr_make_io_signature (2, 2, sizeof (@O_TYPE@))), - d_vlen(vlen) -{ -} - - -int -@NAME@::work( int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - - int ninputs = input_items.size (); - - @O_TYPE@ *x_optr = (@O_TYPE@ *) output_items[0]; - @O_TYPE@ *y_optr = (@O_TYPE@ *) output_items[1]; - - for (int i=0; i<noutput_items; i++) { - - @I_TYPE@ max = ((@I_TYPE@ *) input_items[0])[i*d_vlen]; - int x = 0; - int y = 0; - - for (int j=0; j < (int) d_vlen; j++ ) { - for (int k=0; k<ninputs; k++) { - if ( ((@I_TYPE@ *) input_items[k])[i*d_vlen + j] > max) { - max = ((@I_TYPE@ *) input_items[k])[i*d_vlen + j]; - x = j; - y = k; - } - } - } - - *x_optr++ = (@O_TYPE@) x; - *y_optr++ = (@O_TYPE@) y; - } - return noutput_items; -} - diff --git a/gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t b/gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t deleted file mode 100644 index a706221fb9..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - @NAME@ (size_t vlen); - size_t d_vlen; - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_argmax_XX.i.t b/gnuradio-core/src/lib/gengen/gr_argmax_XX.i.t deleted file mode 100644 index 233551ad93..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_argmax_XX.i.t +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (size_t vlen); - size_t d_vlen; -}; diff --git a/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.cc.t deleted file mode 100644 index 4a642c13e2..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.cc.t +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <iostream> -#include <string.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D) -{ - return gnuradio::get_initial_sptr (new @NAME@ (symbol_table,D)); -} - -@NAME@::@NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D) - : gr_sync_interpolator ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, -1, sizeof (@O_TYPE@)), - D), - d_D (D), - d_symbol_table (symbol_table) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert (noutput_items % d_D == 0); - assert (input_items.size() == output_items.size()); - int nstreams = input_items.size(); - - for (int m=0;m<nstreams;m++) { - const @I_TYPE@ *in = (@I_TYPE@ *) input_items[m]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[m]; - - // per stream processing - for (int i = 0; i < noutput_items / d_D; i++){ - assert (((unsigned int)in[i]*d_D+d_D) <= d_symbol_table.size()); - memcpy(out, &d_symbol_table[(unsigned int)in[i]*d_D], d_D*sizeof(@O_TYPE@)); - out+=d_D; - } - // end of per stream processing - - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.h.t b/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.h.t deleted file mode 100644 index 17d5688b86..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.h.t +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D = 1); - -/*! - * \brief Map a stream of symbol indexes (unpacked bytes or shorts) to stream of float or complex onstellation points.in \p D dimensions (\p D = 1 by default) - * \ingroup converter_blk - * - * input: stream of @I_TYPE@; output: stream of @O_TYPE@ - * - * out[n D + k] = symbol_table[in[n] D + k], k=0,1,...,D-1 - * - * The combination of gr_packed_to_unpacked_XX followed by - * gr_chunks_to_symbols_XY handles the general case of mapping - * from a stream of bytes or shorts into arbitrary float - * or complex symbols. - * - * \sa gr_packed_to_unpacked_bb, gr_unpacked_to_packed_bb, - * \sa gr_packed_to_unpacked_ss, gr_unpacked_to_packed_ss, - * \sa gr_chunks_to_symbols_bf, gr_chunks_to_symbols_bc. - * \sa gr_chunks_to_symbols_sf, gr_chunks_to_symbols_sc. - */ - -class GR_CORE_API @NAME@ : public gr_sync_interpolator -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D); - - int d_D; - std::vector<@O_TYPE@> d_symbol_table; - @NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D = 1); - - public: - int D () const { return d_D; } - std::vector<@O_TYPE@> symbol_table () const { return d_symbol_table; } - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool check_topology(int ninputs, int noutputs) { return ninputs == noutputs; } -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.i.t b/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.i.t deleted file mode 100644 index 14c8be4863..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D = 1); - -class @NAME@ : public gr_sync_interpolator -{ -private: - @NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D = 1); - -public: - int D () const { return d_D; } - std::vector<@O_TYPE@> symbol_table () const { return d_symbol_table; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_divide_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_divide_XX.cc.t deleted file mode 100644 index 63450cb3df..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_divide_XX.cc.t +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (size_t vlen) -{ - return gnuradio::get_initial_sptr (new @NAME@ (vlen)); -} - -@NAME@::@NAME@ (size_t vlen) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)*vlen), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)*vlen)), - d_vlen (vlen) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - if (ninputs == 1){ // compute reciprocal - for (size_t i = 0; i < noutput_items*d_vlen; i++) - *optr++ = (@O_TYPE@) ((@O_TYPE@) 1 / - ((@I_TYPE@ *) input_items[0])[i]); - } - - else { - for (size_t i = 0; i < noutput_items*d_vlen; i++){ - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc /= ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_divide_XX.h.t b/gnuradio-core/src/lib/gengen/gr_divide_XX.h.t deleted file mode 100644 index 40ee27a51d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_divide_XX.h.t +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -/*! - * \brief output = input_0 / input_1 / input_x ...) - * \ingroup math_blk - * - * Divide across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - @NAME@ (size_t vlen); - - size_t d_vlen; - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_divide_XX.i.t b/gnuradio-core/src/lib/gengen/gr_divide_XX.i.t deleted file mode 100644 index b2c5106106..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_divide_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (size_t vlen); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_fastnoise_source_X.cc.t b/gnuradio-core/src/lib/gengen/gr_fastnoise_source_X.cc.t deleted file mode 100644 index 7be7bdde86..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_fastnoise_source_X.cc.t +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <@NAME@.h> -#include <gr_io_signature.h> -#include <stdexcept> - - -@NAME@_sptr -gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed, long samples) -{ - return gnuradio::get_initial_sptr(new @NAME@ (type, ampl, seed, samples)); -} - - -@NAME@::@NAME@ (gr_noise_type_t type, float ampl, long seed, long samples) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof (@TYPE@))), - d_type (type), - d_ampl (ampl), - d_rng (seed) -{ - d_samples.resize(samples); - generate(); -} - -void -@NAME@::generate() -{ - int noutput_items = d_samples.size(); - switch (d_type){ -#if @IS_COMPLEX@ // complex? - - case GR_UNIFORM: - for (int i = 0; i < noutput_items; i++) - d_samples[i] = gr_complex (d_ampl * ((d_rng.ran1 () * 2.0) - 1.0), - d_ampl * ((d_rng.ran1 () * 2.0) - 1.0)); - break; - - case GR_GAUSSIAN: - for (int i = 0; i < noutput_items; i++) - d_samples[i] = d_ampl * d_rng.rayleigh_complex (); - break; - -#else // nope... - - case GR_UNIFORM: - for (int i = 0; i < noutput_items; i++) - d_samples[i] = (@TYPE@)(d_ampl * ((d_rng.ran1 () * 2.0) - 1.0)); - break; - - case GR_GAUSSIAN: - for (int i = 0; i < noutput_items; i++) - d_samples[i] = (@TYPE@)(d_ampl * d_rng.gasdev ()); - break; - - case GR_LAPLACIAN: - for (int i = 0; i < noutput_items; i++) - d_samples[i] = (@TYPE@)(d_ampl * d_rng.laplacian ()); - break; - - case GR_IMPULSE: // FIXME changeable impulse settings - for (int i = 0; i < noutput_items; i++) - d_samples[i] = (@TYPE@)(d_ampl * d_rng.impulse (9)); - break; -#endif - - default: - throw std::runtime_error ("invalid type"); - } - -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @TYPE@ *out = (@TYPE@ *) output_items[0]; - - for(int i=0; i<noutput_items; i++){ -#ifdef __USE_GNU - size_t idx = lrand48() % d_samples.size(); -#else - size_t idx = rand() % d_samples.size(); -#endif - out[i] = d_samples[idx]; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_fastnoise_source_X.h.t b/gnuradio-core/src/lib/gengen/gr_fastnoise_source_X.h.t deleted file mode 100644 index 007e449759..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_fastnoise_source_X.h.t +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_noise_type.h> -#include <gr_random.h> - - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @NAME@_sptr; - -/*! \brief Make a noise source - * \param type the random distribution to use (see gr_noise_type.h) - * \param ampl a scaling factor for the output - * \param seed seed for random generators. Note that for uniform and - * Gaussian distributions, this should be a negative number. - * \param samples number of samples to pre-generate. - */ -GR_CORE_API @NAME@_sptr -gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed = 0, long samples=1024*16); - -/*! - * \brief Random number source - * \ingroup source_blk - * - * \details - * Generate random values from different distributions. - * Currently, only Gaussian and uniform are enabled. - * - * \param type the random distribution to use (see gr_noise_type.h) - * \param ampl a scaling factor for the output - * \param seed seed for random generators. Note that for uniform and - * Gaussian distributions, this should be a negative number. - * \param samples number of samples to pre-generate. - */ -class GR_CORE_API @NAME@ : public gr_sync_block { - friend GR_CORE_API @NAME@_sptr - - gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed, long samples); - - gr_noise_type_t d_type; - float d_ampl; - gr_random d_rng; - std::vector<@TYPE@> d_samples; - - @NAME@ (gr_noise_type_t type, float ampl, long seed = 0, long samples=1024*16); - - public: - void set_type (gr_noise_type_t type) { d_type = type; generate(); } - void set_amplitude (float ampl) { d_ampl = ampl; generate(); } - void generate(); - - gr_noise_type_t type () const { return d_type; } - float amplitude () const { return d_ampl; } - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_fastnoise_source_X.i.t b/gnuradio-core/src/lib/gengen/gr_fastnoise_source_X.i.t deleted file mode 100644 index e1f7c775be..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_fastnoise_source_X.i.t +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@NAME@_sptr -gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed = 0, long samples = 1024*16); - -class @NAME@ : public gr_block { - private: - @NAME@ (gr_noise_type_t type, float ampl, long seed = 0, long samples = 1024*16); - - public: - void set_type (gr_noise_type_t type) { d_type = type; } - void set_amplitude (float ampl) { d_ampl = ampl; } - - gr_noise_type_t type () const { return d_type; } - float amplitude () const { return d_ampl; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t deleted file mode 100644 index 1dbee49db9..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (int decim) -{ - return gnuradio::get_initial_sptr (new @NAME@ (decim)); -} - -@NAME@::@NAME@ (int decim) - : gr_sync_decimator ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)), - decim), - d_decim(decim), - d_count(0) -{ -} - -@NAME@::~@NAME@ () -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - - for (int i = 0; i < noutput_items; i++) { - out[i] = (@O_TYPE@)0; - for (int j = 0; j < d_decim; j++) - out[i] += in[i*d_decim+j]; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t b/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t deleted file mode 100644 index abb13ea904..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class @NAME@; - -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int decim); - -/*! - * \brief output = sum(input[0]...input[n]) - * \ingroup math_blk - * - * Integrate successive samples in input stream and decimate - */ -class GR_CORE_API @NAME@ : public gr_sync_decimator -{ -private: - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@(int decim); - - @NAME@ (int decim); - - int d_decim; - int d_count; - -public: - ~@NAME@ (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t b/gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t deleted file mode 100644 index a96e5fd29d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@SPTR_NAME@ gr_make_@BASE_NAME@ (int decim); - -class @NAME@ : public gr_sync_decimator -{ -private: - @NAME@ (); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_max_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_max_XX.cc.t deleted file mode 100644 index c53820cd60..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_max_XX.cc.t +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ ( size_t vlen ) -{ - return @SPTR_NAME@ ( new @NAME@(vlen)); -} - -@NAME@::@NAME@( size_t vlen) - : gr_sync_block ( "@BASE_NAME@", - gr_make_io_signature (1, -1, vlen*sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_vlen(vlen) -{ -} - -int -@NAME@::work( int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - for (int i=0; i<noutput_items; i++) { - - @I_TYPE@ max = ((@I_TYPE@ *) input_items[0])[i*d_vlen]; - - for (int j=0; j < (int) d_vlen; j++ ) { - for (int k=0; k<ninputs; k++) { - if ( ((@I_TYPE@ *) input_items[k])[i*d_vlen + j] > max) { - max = ((@I_TYPE@*) input_items[k])[i*d_vlen + j]; - } - } - } - - *optr++ = (@O_TYPE@) max; - } - return noutput_items; -} - diff --git a/gnuradio-core/src/lib/gengen/gr_max_XX.h.t b/gnuradio-core/src/lib/gengen/gr_max_XX.h.t deleted file mode 100644 index a706221fb9..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_max_XX.h.t +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - @NAME@ (size_t vlen); - size_t d_vlen; - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_max_XX.i.t b/gnuradio-core/src/lib/gengen/gr_max_XX.i.t deleted file mode 100644 index 233551ad93..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_max_XX.i.t +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (size_t vlen); - size_t d_vlen; -}; diff --git a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t deleted file mode 100644 index ddee30bd77..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (int length, @O_TYPE@ scale, int max_iter) -{ - return gnuradio::get_initial_sptr (new @NAME@ (length, scale, max_iter)); -} - -@NAME@::@NAME@ (int length, @O_TYPE@ scale, int max_iter) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_length(length), - d_scale(scale), - d_max_iter(max_iter), - d_new_length(length), - d_new_scale(scale), - d_updated(false) -{ - set_history(length); -} - -@NAME@::~@NAME@ () -{ -} - -void -@NAME@::set_length_and_scale(int length, @O_TYPE@ scale) -{ - d_new_length = length; - d_new_scale = scale; - d_updated = true; -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - if (d_updated) { - d_length = d_new_length; - d_scale = d_new_scale; - set_history(d_length); - d_updated = false; - return 0; // history requirements might have changed - } - - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - - @I_TYPE@ sum = 0; - int num_iter = (noutput_items>d_max_iter) ? d_max_iter : noutput_items; - for (int i = 0; i < d_length-1 ; i++) { - sum += in[i]; - } - - for (int i = 0; i < num_iter; i++) { - sum += in[i+d_length-1]; - out[i] = sum * d_scale; - sum -= in[i]; - } - - return num_iter; -} diff --git a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t deleted file mode 100644 index 37678abe13..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; - -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int length, @O_TYPE@ scale, int max_iter = 4096); - -/*! - * \brief output is the moving sum of the last N samples, scaled by the scale factor - * \ingroup filter_blk - * - * max_iter limits how long we go without flushing the accumulator - * This is necessary to avoid numerical instability for float and complex. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ -private: - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@(int length, @O_TYPE@ scale, int max_iter); - - @NAME@ (int length, @O_TYPE@ scale, int max_iter = 4096); - - int d_length; - @O_TYPE@ d_scale; - int d_max_iter; - - int d_new_length; - @O_TYPE@ d_new_scale; - bool d_updated; - -public: - ~@NAME@ (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - int length() const { return d_new_length; } - @O_TYPE@ scale() const { return d_new_scale; } - - void set_length_and_scale(int length, @O_TYPE@ scale); -}; - -#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.i.t b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.i.t deleted file mode 100644 index 6e3b9ca9bc..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.i.t +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@SPTR_NAME@ gr_make_@BASE_NAME@ (int length, @O_TYPE@ scale, int max_iter=4096); - -class @NAME@ : public gr_sync_block -{ -private: - @NAME@ (); - - public: - int length() const; - @O_TYPE@ scale() const; - void set_length_and_scale(int length, @O_TYPE@ scale); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_multiply_XX.cc.t deleted file mode 100644 index a60118e14c..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_XX.cc.t +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (size_t vlen) -{ - return gnuradio::get_initial_sptr (new @NAME@ (vlen)); -} - -@NAME@::@NAME@ (size_t vlen) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)*vlen), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)*vlen)), - d_vlen (vlen) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - for (size_t i = 0; i < noutput_items*d_vlen; i++){ - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc *= ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_XX.h.t b/gnuradio-core/src/lib/gengen/gr_multiply_XX.h.t deleted file mode 100644 index 18ec6d0beb..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_XX.h.t +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -/*! - * \brief output = prod (input_0, input_1, ...) - * \ingroup math_blk - * - * Multiply across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - @NAME@ (size_t vlen); - - size_t d_vlen; - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_XX.i.t b/gnuradio-core/src/lib/gengen/gr_multiply_XX.i.t deleted file mode 100644 index b2c5106106..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (size_t vlen); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.cc.t deleted file mode 100644 index 424b62412c..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.cc.t +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (@O_TYPE@ k) -{ - return gnuradio::get_initial_sptr (new @NAME@ (k)); -} - -@NAME@::@NAME@ (@O_TYPE@ k) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_k (k) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0]; - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int size = noutput_items; - - while (size >= 8){ - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - *optr++ = *iptr++ * d_k; - size -= 8; - } - - while (size-- > 0) - *optr++ = *iptr++ * d_k; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.h.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.h.t deleted file mode 100644 index 274fc3b998..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.h.t +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - -/*! - * \brief output = input * constant - * \ingroup math_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); - - @O_TYPE@ d_k; // the constant - @NAME@ (@O_TYPE@ k); - - public: - @O_TYPE@ k () const { return d_k; } - void set_k (@O_TYPE@ k) { d_k = k; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.i.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.i.t deleted file mode 100644 index b7921554e5..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (@TYPE@ k); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (@TYPE@ k); - - public: - @TYPE@ k () const { return d_k; } - void set_k (@TYPE@ k) { d_k = k; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t deleted file mode 100755 index eb896dee53..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k) -{ - return gnuradio::get_initial_sptr (new @NAME@ (k)); -} - -@NAME@::@NAME@ (const std::vector<@I_TYPE@> &k) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof(@I_TYPE@)*k.size()), - gr_make_io_signature (1, 1, sizeof(@O_TYPE@)*k.size())) -{ - d_k = k; -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *iptr = (@O_TYPE@ *)input_items[0]; - @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; - - int nitems_per_block = output_signature()->sizeof_stream_item(0)/sizeof(@I_TYPE@); - - for (int i = 0; i < noutput_items; i++) - for (int j = 0; j < nitems_per_block; j++) - *optr++ = *iptr++ * d_k[j]; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t deleted file mode 100644 index 2c6edd3642..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); - -/*! - * \brief output vector = input vector * constant vector (element-wise) - * \ingroup math_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); - - std::vector<@I_TYPE@> d_k; // the constant - @NAME@ (const std::vector<@I_TYPE@> &k); - - public: - const std::vector<@I_TYPE@> k () const { return d_k; } - void set_k (const std::vector<@I_TYPE@> &k) { d_k = k; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.i.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.i.t deleted file mode 100755 index e0e6ae9051..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (const std::vector<@I_TYPE@> &k); - - public: - std::vector<@I_TYPE@> k () const { return d_k; } - void set_k (const std::vector<@I_TYPE@> &k) { d_k = k; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_mute_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_mute_XX.cc.t deleted file mode 100644 index 4b8ff8415d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_mute_XX.cc.t +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> -#include <string.h> - - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (bool mute) -{ - return gnuradio::get_initial_sptr (new @NAME@ (mute)); -} - -@NAME@::@NAME@ (bool mute) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_mute (mute) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0]; - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int size = noutput_items; - - if (d_mute){ - memset (optr, 0, noutput_items * sizeof(@O_TYPE@)); - } - else { - while (size >= 8){ - *optr++ = *iptr++; - *optr++ = *iptr++; - *optr++ = *iptr++; - *optr++ = *iptr++; - *optr++ = *iptr++; - *optr++ = *iptr++; - *optr++ = *iptr++; - *optr++ = *iptr++; - size -= 8; - } - - while (size-- > 0) - *optr++ = *iptr++; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_mute_XX.h.t b/gnuradio-core/src/lib/gengen/gr_mute_XX.h.t deleted file mode 100644 index ca23904e9d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_mute_XX.h.t +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (bool mute=false); - -/*! - * \brief output = input or zero if muted. - * \ingroup level_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (bool mute); - - bool d_mute; - @NAME@ (bool mute); - - public: - bool mute () const { return d_mute; } - void set_mute (bool mute) { d_mute = mute; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_mute_XX.i.t b/gnuradio-core/src/lib/gengen/gr_mute_XX.i.t deleted file mode 100644 index ffcfac8a65..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_mute_XX.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@(bool mute=false); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (bool mute); - - public: - bool mute () const { return d_mute; } - void set_mute (bool mute) { d_mute = mute; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_noise_source_X.cc.t b/gnuradio-core/src/lib/gengen/gr_noise_source_X.cc.t deleted file mode 100644 index 3078f6366e..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_noise_source_X.cc.t +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <@NAME@.h> -#include <gr_io_signature.h> -#include <stdexcept> - - -@NAME@_sptr -gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed) -{ - return gnuradio::get_initial_sptr(new @NAME@ (type, ampl, seed)); -} - - -@NAME@::@NAME@ (gr_noise_type_t type, float ampl, long seed) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof (@TYPE@))), - d_type (type), - d_ampl (ampl), - d_rng (seed) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @TYPE@ *out = (@TYPE@ *) output_items[0]; - - switch (d_type){ -#if @IS_COMPLEX@ // complex? - - case GR_UNIFORM: - for (int i = 0; i < noutput_items; i++) - out[i] = gr_complex (d_ampl * ((d_rng.ran1 () * 2.0) - 1.0), - d_ampl * ((d_rng.ran1 () * 2.0) - 1.0)); - break; - - case GR_GAUSSIAN: - for (int i = 0; i < noutput_items; i++) - out[i] = d_ampl * d_rng.rayleigh_complex (); - break; - -#else // nope... - - case GR_UNIFORM: - for (int i = 0; i < noutput_items; i++) - out[i] = (@TYPE@)(d_ampl * ((d_rng.ran1 () * 2.0) - 1.0)); - break; - - case GR_GAUSSIAN: - for (int i = 0; i < noutput_items; i++) - out[i] = (@TYPE@)(d_ampl * d_rng.gasdev ()); - break; - - case GR_LAPLACIAN: - for (int i = 0; i < noutput_items; i++) - out[i] = (@TYPE@)(d_ampl * d_rng.laplacian ()); - break; - - case GR_IMPULSE: // FIXME changeable impulse settings - for (int i = 0; i < noutput_items; i++) - out[i] = (@TYPE@)(d_ampl * d_rng.impulse (9)); - break; -#endif - - default: - throw std::runtime_error ("invalid type"); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_noise_source_X.h.t b/gnuradio-core/src/lib/gengen/gr_noise_source_X.h.t deleted file mode 100644 index 31ffb2b169..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_noise_source_X.h.t +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_noise_type.h> -#include <gr_random.h> - - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @NAME@_sptr; - -/*! \brief Make a noise source - * \param type the random distribution to use (see gr_noise_type.h) - * \param ampl a scaling factor for the output - * \param seed seed for random generators. Note that for uniform and - * Gaussian distributions, this should be a negative number. - */ -GR_CORE_API @NAME@_sptr -gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed = 0); - -/*! - * \brief Random number source - * \ingroup source_blk - * - * \details - * Generate random values from different distributions. - * Currently, only Gaussian and uniform are enabled. - * - * \param type the random distribution to use (see gr_noise_type.h) - * \param ampl a scaling factor for the output - * \param seed seed for random generators. Note that for uniform and - * Gaussian distributions, this should be a negative number. - */ -class GR_CORE_API @NAME@ : public gr_sync_block { - friend GR_CORE_API @NAME@_sptr - - gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed); - - gr_noise_type_t d_type; - float d_ampl; - gr_random d_rng; - - @NAME@ (gr_noise_type_t type, float ampl, long seed = 0); - - public: - void set_type (gr_noise_type_t type) { d_type = type; } - void set_amplitude (float ampl) { d_ampl = ampl; } - - gr_noise_type_t type () const { return d_type; } - float amplitude () const { return d_ampl; } - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_noise_source_X.i.t b/gnuradio-core/src/lib/gengen/gr_noise_source_X.i.t deleted file mode 100644 index df27ab79b6..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_noise_source_X.i.t +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@NAME@_sptr -gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed = 0); - -class @NAME@ : public gr_block { - private: - @NAME@ (gr_noise_type_t type, float ampl, long seed = 0); - - public: - void set_type (gr_noise_type_t type) { d_type = type; } - void set_amplitude (float ampl) { d_ampl = ampl; } - - gr_noise_type_t type () const { return d_type; } - float amplitude () const { return d_ampl; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_noise_type.h b/gnuradio-core/src/lib/gengen/gr_noise_type.h deleted file mode 100644 index d2aba9b0c7..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_noise_type.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_NOISE_TYPE_H -#define INCLUDED_GR_NOISE_TYPE_H - -typedef enum { - GR_UNIFORM = 200, GR_GAUSSIAN, GR_LAPLACIAN, GR_IMPULSE -} gr_noise_type_t; - -#endif /* INCLUDED_GR_NOISE_TYPE_H */ diff --git a/gnuradio-core/src/lib/gengen/gr_not_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_not_XX.cc.t deleted file mode 100644 index 4806b142f2..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_not_XX.cc.t +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ () -{ - return gnuradio::get_initial_sptr (new @NAME@ ()); -} - -@NAME@::@NAME@ () - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - const @I_TYPE@ *inptr = (const @I_TYPE@ *) input_items[0]; - - - for (int i = 0; i < noutput_items; i++) { - *optr++ = ~(inptr[i]); - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_not_XX.h.t b/gnuradio-core/src/lib/gengen/gr_not_XX.h.t deleted file mode 100644 index aff4211099..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_not_XX.h.t +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - -/*! - * \brief output = ~input_0 - * \ingroup math_blk - * - * bitwise boolean not across input stream. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - - @NAME@ (); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_not_XX.i.t b/gnuradio-core/src/lib/gengen/gr_not_XX.i.t deleted file mode 100644 index 06db5ca59d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_not_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_or_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_or_XX.cc.t deleted file mode 100644 index ee55eedda4..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_or_XX.cc.t +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ () -{ - return gnuradio::get_initial_sptr (new @NAME@ ()); -} - -@NAME@::@NAME@ () - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - for (int i = 0; i < noutput_items; i++) { - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc = acc | ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_or_XX.h.t b/gnuradio-core/src/lib/gengen/gr_or_XX.h.t deleted file mode 100644 index 8860eedd50..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_or_XX.h.t +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - -/*! - * \brief output = input_0 | input_1 | , ... | input_N) - * \ingroup math_blk - * - * bitwise boolean or across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - - @NAME@ (); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_or_XX.i.t b/gnuradio-core/src/lib/gengen/gr_or_XX.i.t deleted file mode 100644 index 06db5ca59d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_or_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_packed_to_unpacked_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_packed_to_unpacked_XX.cc.t deleted file mode 100644 index 75e53c4ca1..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_packed_to_unpacked_XX.cc.t +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <gr_log2_const.h> - -static const unsigned int BITS_PER_TYPE = sizeof(@I_TYPE@) * 8; -static const unsigned int LOG2_L_TYPE = gr_log2_const<sizeof(@I_TYPE@) * 8>(); - - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness) -{ - return @SPTR_NAME@ - (new @NAME@ (bits_per_chunk,endianness)); -} - -@NAME@::@NAME@ (unsigned int bits_per_chunk, - gr_endianness_t endianness) - : gr_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, -1, sizeof (@O_TYPE@))), - d_bits_per_chunk(bits_per_chunk),d_endianness(endianness),d_index(0) -{ - assert (bits_per_chunk <= BITS_PER_TYPE); - assert (bits_per_chunk > 0); - - set_relative_rate ((1.0 * BITS_PER_TYPE) / bits_per_chunk); -} - -void -@NAME@::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - - int input_required = (int) ceil((d_index + noutput_items * d_bits_per_chunk) / (1.0 * BITS_PER_TYPE)); - unsigned ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) { - ninput_items_required[i] = input_required; - //printf("Forecast wants %d needs %d\n",noutput_items,ninput_items_required[i]); - } -} - -unsigned int -get_bit_le (const @I_TYPE@ *in_vector,unsigned int bit_addr) -{ - @I_TYPE@ x = in_vector[bit_addr>>LOG2_L_TYPE]; - return (x>>(bit_addr&(BITS_PER_TYPE-1)))&1; -} - -unsigned int -get_bit_be (const @I_TYPE@ *in_vector,unsigned int bit_addr) -{ - @I_TYPE@ x = in_vector[bit_addr>>LOG2_L_TYPE]; - return (x>>((BITS_PER_TYPE-1)-(bit_addr&(BITS_PER_TYPE-1))))&1; -} - -int -@NAME@::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - unsigned int index_tmp = d_index; - - assert (input_items.size() == output_items.size()); - int nstreams = input_items.size(); - - for (int m=0; m < nstreams; m++){ - const @I_TYPE@ *in = (@I_TYPE@ *) input_items[m]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[m]; - index_tmp = d_index; - - // per stream processing - - switch (d_endianness){ - - case GR_MSB_FIRST: - for (int i = 0; i < noutput_items; i++){ - //printf("here msb %d\n",i); - @O_TYPE@ x = 0; - for(unsigned int j=0; j<d_bits_per_chunk; j++, index_tmp++) - x = (x<<1) | get_bit_be(in, index_tmp); - out[i] = x; - } - break; - - case GR_LSB_FIRST: - for (int i = 0; i < noutput_items; i++){ - //printf("here lsb %d\n",i); - @O_TYPE@ x = 0; - for(unsigned int j=0; j<d_bits_per_chunk; j++, index_tmp++) - x = (x<<1) | get_bit_le(in, index_tmp); - out[i] = x; - } - break; - - default: - assert(0); - } - - //printf("almost got to end\n"); - assert(ninput_items[m] >= (int) ((d_index+(BITS_PER_TYPE-1))>>LOG2_L_TYPE)); - } - - d_index = index_tmp; - consume_each (d_index >> LOG2_L_TYPE); - d_index = d_index & (BITS_PER_TYPE-1); - //printf("got to end\n"); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_packed_to_unpacked_XX.h.t b/gnuradio-core/src/lib/gengen/gr_packed_to_unpacked_XX.h.t deleted file mode 100644 index e95771b371..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_packed_to_unpacked_XX.h.t +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_block.h> -#include <gr_endianness.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ -gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); - -/*! - * \brief Convert a stream of packed bytes or shorts to stream of unpacked bytes or shorts. - * \ingroup converter_blk - * - * input: stream of @I_TYPE@; output: stream of @O_TYPE@ - * - * This is the inverse of gr_unpacked_to_packed_XX. - * - * The bits in the bytes or shorts input stream are grouped into chunks of - * \p bits_per_chunk bits and each resulting chunk is written right- - * justified to the output stream of bytes or shorts. - * All b or 16 bits of the each input bytes or short are processed. - * The right thing is done if bits_per_chunk is not a power of two. - * - * The combination of gr_packed_to_unpacked_XX_ followed by - * gr_chunks_to_symbols_Xf or gr_chunks_to_symbols_Xc handles the - * general case of mapping from a stream of bytes or shorts into - * arbitrary float or complex symbols. - * - * \sa gr_packed_to_unpacked_bb, gr_unpacked_to_packed_bb, - * \sa gr_packed_to_unpacked_ss, gr_unpacked_to_packed_ss, - * \sa gr_chunks_to_symbols_bf, gr_chunks_to_symbols_bc. - * \sa gr_chunks_to_symbols_sf, gr_chunks_to_symbols_sc. - */ - -class GR_CORE_API @NAME@ : public gr_block -{ - friend GR_CORE_API @SPTR_NAME@ - gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); - - @NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); - - unsigned int d_bits_per_chunk; - gr_endianness_t d_endianness; - unsigned int d_index; - - 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); - - bool check_topology(int ninputs, int noutputs) { return ninputs == noutputs; } - -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_packed_to_unpacked_XX.i.t b/gnuradio-core/src/lib/gengen/gr_packed_to_unpacked_XX.i.t deleted file mode 100644 index 1e978956a1..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_packed_to_unpacked_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); - -class @NAME@ : public gr_block -{ - @NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.cc.t deleted file mode 100644 index 54af3c0cd4..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.cc.t +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> -#include <string.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (float threshold_factor_rise, - float threshold_factor_fall, - int look_ahead, float alpha) -{ - return gnuradio::get_initial_sptr (new @NAME@ (threshold_factor_rise, - threshold_factor_fall, - look_ahead, alpha)); -} - -@NAME@::@NAME@ (float threshold_factor_rise, - float threshold_factor_fall, - int look_ahead, float alpha) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (char))), - d_threshold_factor_rise(threshold_factor_rise), - d_threshold_factor_fall(threshold_factor_fall), - d_look_ahead(look_ahead), d_avg_alpha(alpha), d_avg(0), d_found(0) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0]; - char *optr = (char *) output_items[0]; - - memset(optr, 0, noutput_items*sizeof(char)); - - @I_TYPE@ peak_val = -(@I_TYPE@)INFINITY; - int peak_ind = 0; - unsigned char state = 0; - int i = 0; - - //printf("noutput_items %d\n",noutput_items); - while(i < noutput_items) { - if(state == 0) { // below threshold - if(iptr[i] > d_avg*d_threshold_factor_rise) { - state = 1; - } - else { - d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg; - i++; - } - } - else if(state == 1) { // above threshold, have not found peak - //printf("Entered State 1: %f i: %d noutput_items: %d\n", iptr[i], i, noutput_items); - if(iptr[i] > peak_val) { - peak_val = iptr[i]; - peak_ind = i; - d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg; - i++; - } - else if (iptr[i] > d_avg*d_threshold_factor_fall) { - d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg; - i++; - } - else { - optr[peak_ind] = 1; - state = 0; - peak_val = -(@I_TYPE@)INFINITY; - //printf("Leaving State 1: Peak: %f Peak Ind: %d i: %d noutput_items: %d\n", - //peak_val, peak_ind, i, noutput_items); - } - } - } - - if(state == 0) { - //printf("Leave in State 0, produced %d\n",noutput_items); - return noutput_items; - } - else { // only return up to passing the threshold - //printf("Leave in State 1, only produced %d of %d\n",peak_ind,noutput_items); - return peak_ind+1; - } -} diff --git a/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.h.t b/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.h.t deleted file mode 100644 index 3e05594fbd..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.h.t +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (float threshold_factor_rise = 0.25, - float threshold_factor_fall = 0.40, - int look_ahead = 10, - float alpha = 0.001); - -/*! - * \brief Detect the peak of a signal - * \ingroup level_blk - * - * If a peak is detected, this block outputs a 1, - * or it outputs 0's. - * - * \param threshold_factor_rise The threshold factor determins when a peak - * has started. An average of the signal is calculated and when the - * value of the signal goes over threshold_factor_rise*average, we - * start looking for a peak. - * \param threshold_factor_fall The threshold factor determins when a peak - * has ended. An average of the signal is calculated and when the - * value of the signal goes bellow threshold_factor_fall*average, we - * stop looking for a peak. - * \param look_ahead The look-ahead value is used when the threshold is - * found to look if there another peak within this step range. - * If there is a larger value, we set that as the peak and look ahead - * again. This is continued until the highest point is found with - * This look-ahead range. - * \param alpha The gain value of a moving average filter - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (float threshold_factor_rise, - float threshold_factor_fall, - int look_ahead, float alpha); - - @NAME@ (float threshold_factor_rise, - float threshold_factor_fall, - int look_ahead, float alpha); - - private: - float d_threshold_factor_rise; - float d_threshold_factor_fall; - int d_look_ahead; - float d_avg_alpha; - float d_avg; - unsigned char d_found; - - public: - - /*! \brief Set the threshold factor value for the rise time - * \param thr new threshold factor - */ - void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; } - - /*! \brief Set the threshold factor value for the fall time - * \param thr new threshold factor - */ - void set_threshold_factor_fall(float thr) { d_threshold_factor_fall = thr; } - - /*! \brief Set the look-ahead factor - * \param look new look-ahead factor - */ - void set_look_ahead(int look) { d_look_ahead = look; } - - /*! \brief Set the running average alpha - * \param alpha new alpha for running average - */ - void set_alpha(int alpha) { d_avg_alpha = alpha; } - - /*! \brief Get the threshold factor value for the rise time - * \return threshold factor - */ - float threshold_factor_rise() { return d_threshold_factor_rise; } - - /*! \brief Get the threshold factor value for the fall time - * \return threshold factor - */ - float threshold_factor_fall() { return d_threshold_factor_fall; } - - /*! \brief Get the look-ahead factor value - * \return look-ahead factor - */ - int look_ahead() { return d_look_ahead; } - - /*! \brief Get the alpha value of the running average - * \return alpha - */ - float alpha() { return d_avg_alpha; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.i.t b/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.i.t deleted file mode 100644 index 212ce0c946..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.i.t +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (float threshold_factor_rise = 0.25, - float threshold_factor_fall = 0.40, - int look_ahead = 10, - float alpha=0.001); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (float threshold_factor_rise, - float threshold_factor_fall, - int look_ahead, float alpha); - - public: - void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; } - void set_threshold_factor_fall(float thr) { d_threshold_factor_fall = thr; } - void set_look_ahead(int look) { d_look_ahead = look; } - void set_alpha(int alpha) { d_avg_alpha = alpha; } - - float threshold_factor_rise() { return d_threshold_factor_rise; } - float threshold_factor_fall() { return d_threshold_factor_fall; } - int look_ahead() { return d_look_ahead; } - float alpha() { return d_avg_alpha; } -}; diff --git a/gnuradio-core/src/lib/gengen/gr_probe_signal_X.cc.t b/gnuradio-core/src/lib/gengen/gr_probe_signal_X.cc.t deleted file mode 100644 index 9a10bab596..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_probe_signal_X.cc.t +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <@NAME@.h> -#include <gr_io_signature.h> - -@NAME@_sptr -gr_make_@BASE_NAME@() -{ - return gnuradio::get_initial_sptr(new @NAME@()); -} - -@NAME@::@NAME@ () -: gr_sync_block ("@BASE_NAME@", - gr_make_io_signature(1, 1, sizeof(@TYPE@)), - gr_make_io_signature(0, 0, 0)), - d_level(0) -{ -} - -@NAME@::~@NAME@() -{ -} - - -int -@NAME@::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const @TYPE@ *in = (const @TYPE@ *) input_items[0]; - - if (noutput_items > 0) - d_level = in[noutput_items-1]; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_probe_signal_X.h.t b/gnuradio-core/src/lib/gengen/gr_probe_signal_X.h.t deleted file mode 100644 index 936f437f1c..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_probe_signal_X.h.t +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005, 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @NAME@_sptr; - -GR_CORE_API @NAME@_sptr -gr_make_@BASE_NAME@ (); - -/*! - * \brief Sink that allows a sample to be grabbed from Python. - * \ingroup sink_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - @TYPE@ d_level; - - friend GR_CORE_API @NAME@_sptr - gr_make_@BASE_NAME@(); - - @NAME@(); - -public: - ~@NAME@(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - @TYPE@ level() const { return d_level; } - -}; - -#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/gengen/gr_probe_signal_X.i.t b/gnuradio-core/src/lib/gengen/gr_probe_signal_X.i.t deleted file mode 100644 index ec96436864..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_probe_signal_X.i.t +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005, 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@NAME@_sptr -gr_make_@BASE_NAME@ (); - -class @NAME@ : public gr_sync_block -{ -public: - @TYPE@ level (); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.cc.t b/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.cc.t deleted file mode 100644 index 1aedca4ec4..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.cc.t +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <@NAME@.h> -#include <gr_io_signature.h> -#include <iostream> - -@NAME@_sptr -gr_make_@BASE_NAME@(size_t size) -{ - return gnuradio::get_initial_sptr(new @NAME@(size)); -} - -@NAME@::@NAME@ (size_t size) -: gr_sync_block ("@BASE_NAME@", - gr_make_io_signature(1, 1, size*sizeof(@TYPE@)), - gr_make_io_signature(0, 0, 0)), - d_level(size, 0), d_size(size) -{ -} - -@NAME@::~@NAME@() -{ -} - -int -@NAME@::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const @TYPE@ *in = (const @TYPE@ *) input_items[0]; - - for (size_t i=0; i<d_size; i++) - d_level[i] = in[(noutput_items-1)*d_size+i]; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.h.t b/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.h.t deleted file mode 100644 index ee673c14ab..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.h.t +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005, 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <vector> - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @NAME@_sptr; - -GR_CORE_API @NAME@_sptr -gr_make_@BASE_NAME@ (size_t size); - -/*! - * \brief Sink that allows a sample to be grabbed from Python. - * \ingroup sink_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - std::vector<@TYPE@> d_level; - - friend GR_CORE_API @NAME@_sptr - gr_make_@BASE_NAME@(size_t size); - - @NAME@(size_t size); - - size_t d_size; - -public: - ~@NAME@(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - std::vector<@TYPE@> level() const { return d_level; } - -}; - -#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.i.t b/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.i.t deleted file mode 100644 index b7de091259..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.i.t +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005, 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@NAME@_sptr -gr_make_@BASE_NAME@ (size_t size); - -class @NAME@ : public gr_sync_block -{ -public: - std::vector<@TYPE@> level (); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.cc.t deleted file mode 100644 index 68f4d544ea..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.cc.t +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ () -{ - return gnuradio::get_initial_sptr (new @NAME@ ()); -} - -@NAME@::@NAME@ () - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature2 (2, 2, sizeof (@I_TYPE@), sizeof(char)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_data(0) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0]; - const char *ctrl = (const char *) input_items[1]; - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - if(ctrl[i]) { - d_data = iptr[i]; - } - optr[i] = d_data; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.h.t b/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.h.t deleted file mode 100644 index 0364941cbc..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.h.t +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - -/*! - * \brief sample and hold circuit - * \ingroup level_blk - * - * Samples the data stream (input stream 0) and holds the value - * if the control signal is 1 (intput stream 1). - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - - @NAME@ (); - - private: - @O_TYPE@ d_data; - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.i.t b/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.i.t deleted file mode 100644 index 4620b0f2c4..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_sig_source_X.cc.t b/gnuradio-core/src/lib/gengen/gr_sig_source_X.cc.t deleted file mode 100644 index 6959eac824..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_sig_source_X.cc.t +++ /dev/null @@ -1,241 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <@NAME@.h> -#include <algorithm> -#include <gr_io_signature.h> -#include <stdexcept> -#include <algorithm> -#include <gr_complex.h> - - -@NAME@::@NAME@ (double sampling_freq, gr_waveform_t waveform, - double frequency, double ampl, @TYPE@ offset) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof (@TYPE@))), - d_sampling_freq (sampling_freq), d_waveform (waveform), d_frequency (frequency), - d_ampl (ampl), d_offset (offset) -{ - d_nco.set_freq (2 * M_PI * d_frequency / d_sampling_freq); -} - -@NAME@_sptr -gr_make_@BASE_NAME@ (double sampling_freq, gr_waveform_t waveform, - double frequency, double ampl, @TYPE@ offset) -{ - return gnuradio::get_initial_sptr(new @NAME@ (sampling_freq, waveform, frequency, ampl, offset)); -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @TYPE@ *optr = (@TYPE@ *) output_items[0]; - @TYPE@ t; - - switch (d_waveform){ - -#if @IS_COMPLEX@ // complex? - - case GR_CONST_WAVE: - t = (gr_complex) d_ampl + d_offset; - std::fill_n(optr, noutput_items, t); - break; - - case GR_SIN_WAVE: - case GR_COS_WAVE: - d_nco.sincos (optr, noutput_items, d_ampl); - if (d_offset == gr_complex(0,0)) - break; - - for (int i = 0; i < noutput_items; i++){ - optr[i] += d_offset; - } - break; - - /* Implements a real square wave high from -PI to 0. - * The imaginary square wave leads by 90 deg. - */ - case GR_SQR_WAVE: - for (int i = 0; i < noutput_items; i++){ - if (d_nco.get_phase() < -1*M_PI/2) - optr[i] = gr_complex(d_ampl, 0)+d_offset; - else if (d_nco.get_phase() < 0) - optr[i] = gr_complex(d_ampl, d_ampl)+d_offset; - else if (d_nco.get_phase() < M_PI/2) - optr[i] = gr_complex(0, d_ampl)+d_offset; - else - optr[i] = d_offset; - d_nco.step(); - } - break; - - /* Implements a real triangle wave rising from -PI to 0 and - * falling from 0 to PI. The imaginary triangle wave leads by 90 deg. - */ - case GR_TRI_WAVE: - for (int i = 0; i < noutput_items; i++){ - if (d_nco.get_phase() < -1*M_PI/2){ - optr[i] = gr_complex(d_ampl*d_nco.get_phase()/M_PI + d_ampl, - -1*d_ampl*d_nco.get_phase()/M_PI - d_ampl/2)+d_offset; - } - else if (d_nco.get_phase() < 0){ - optr[i] = gr_complex(d_ampl*d_nco.get_phase()/M_PI + d_ampl, - d_ampl*d_nco.get_phase()/M_PI + d_ampl/2)+d_offset; - } - else if (d_nco.get_phase() < M_PI/2){ - optr[i] = gr_complex(-1*d_ampl*d_nco.get_phase()/M_PI + d_ampl, - d_ampl*d_nco.get_phase()/M_PI + d_ampl/2)+d_offset; - } - else{ - optr[i] = gr_complex(-1*d_ampl*d_nco.get_phase()/M_PI + d_ampl, - -1*d_ampl*d_nco.get_phase()/M_PI + 3*d_ampl/2)+d_offset; - } - d_nco.step(); - } - break; - - /* Implements a real saw tooth wave rising from -PI to PI. - * The imaginary saw tooth wave leads by 90 deg. - */ - case GR_SAW_WAVE: - for (int i = 0; i < noutput_items; i++){ - if (d_nco.get_phase() < -1*M_PI/2){ - optr[i] = gr_complex(d_ampl*d_nco.get_phase()/(2*M_PI) + d_ampl/2, - d_ampl*d_nco.get_phase()/(2*M_PI) + 5*d_ampl/4)+d_offset; - } - else{ - optr[i] = gr_complex(d_ampl*d_nco.get_phase()/(2*M_PI) + d_ampl/2, - d_ampl*d_nco.get_phase()/(2*M_PI) + d_ampl/4)+d_offset; - } - d_nco.step(); - } - break; - -#else // nope... - - case GR_CONST_WAVE: - t = (@TYPE@) d_ampl + d_offset; - std::fill_n(optr, noutput_items, t); - break; - - case GR_SIN_WAVE: - d_nco.sin (optr, noutput_items, d_ampl); - if (d_offset == 0) - break; - - for (int i = 0; i < noutput_items; i++){ - optr[i] += d_offset; - } - break; - - case GR_COS_WAVE: - d_nco.cos (optr, noutput_items, d_ampl); - if (d_offset == 0) - break; - - for (int i = 0; i < noutput_items; i++){ - optr[i] += d_offset; - } - break; - - /* The square wave is high from -PI to 0. */ - case GR_SQR_WAVE: - t = (@TYPE@) d_ampl + d_offset; - for (int i = 0; i < noutput_items; i++){ - if (d_nco.get_phase() < 0) - optr[i] = t; - else - optr[i] = d_offset; - d_nco.step(); - } - break; - - /* The triangle wave rises from -PI to 0 and falls from 0 to PI. */ - case GR_TRI_WAVE: - for (int i = 0; i < noutput_items; i++){ - double t = d_ampl*d_nco.get_phase()/M_PI; - if (d_nco.get_phase() < 0) - optr[i] = static_cast<@TYPE@>(t + d_ampl + d_offset); - else - optr[i] = static_cast<@TYPE@>(-1*t + d_ampl + d_offset); - d_nco.step(); - } - break; - - /* The saw tooth wave rises from -PI to PI. */ - case GR_SAW_WAVE: - for (int i = 0; i < noutput_items; i++){ - t = static_cast<@TYPE@>(d_ampl*d_nco.get_phase()/(2*M_PI) + d_ampl/2 + d_offset); - optr[i] = t; - d_nco.step(); - } - break; - -#endif - - default: - throw std::runtime_error ("gr_sig_source: invalid waveform"); - } - - return noutput_items; -} - -void -@NAME@::set_sampling_freq (double sampling_freq) -{ - d_sampling_freq = sampling_freq; - d_nco.set_freq (2 * M_PI * d_frequency / d_sampling_freq); -} - -void -@NAME@::set_waveform (gr_waveform_t waveform) -{ - d_waveform = waveform; -} - -void -@NAME@::set_frequency (double frequency) -{ - d_frequency = frequency; - d_nco.set_freq (2 * M_PI * d_frequency / d_sampling_freq); -} - -void -@NAME@::set_amplitude (double ampl) -{ - d_ampl = ampl; -} - -void -@NAME@::set_offset (@TYPE@ offset) -{ - d_offset = offset; -} - diff --git a/gnuradio-core/src/lib/gengen/gr_sig_source_X.h.t b/gnuradio-core/src/lib/gengen/gr_sig_source_X.h.t deleted file mode 100644 index baa82dbe20..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_sig_source_X.h.t +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_sig_source_waveform.h> -#include <gr_fxpt_nco.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @NAME@_sptr; - -/*! - * \brief signal generator with @TYPE@ output. - * \ingroup source_blk - */ - -class GR_CORE_API @NAME@ : public gr_sync_block { - friend GR_CORE_API @NAME@_sptr - gr_make_@BASE_NAME@ (double sampling_freq, gr_waveform_t waveform, - double frequency, double ampl, @TYPE@ offset); - - double d_sampling_freq; - gr_waveform_t d_waveform; - double d_frequency; - double d_ampl; - @TYPE@ d_offset; - gr_fxpt_nco d_nco; - - - @NAME@ (double sampling_freq, gr_waveform_t waveform, - double wave_freq, double ampl, @TYPE@ offset); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - // ACCESSORS - double sampling_freq () const { return d_sampling_freq; } - gr_waveform_t waveform () const { return d_waveform; } - double frequency () const { return d_frequency; } - double amplitude () const { return d_ampl; } - @TYPE@ offset () const { return d_offset; } - - // MANIPULATORS - void set_sampling_freq (double sampling_freq); - void set_waveform (gr_waveform_t waveform); - void set_frequency (double frequency); - void set_amplitude (double ampl); - void set_offset (@TYPE@ offset); -}; - -GR_CORE_API @NAME@_sptr -gr_make_@BASE_NAME@ (double sampling_freq, gr_waveform_t waveform, - double wave_freq, double ampl, @TYPE@ offset = 0); - - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_sig_source_X.i.t b/gnuradio-core/src/lib/gengen/gr_sig_source_X.i.t deleted file mode 100644 index 7bd85fcb81..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_sig_source_X.i.t +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@NAME@_sptr -gr_make_@BASE_NAME@ (double sampling_freq, gr_waveform_t waveform, - double wave_freq, double ampl, @TYPE@ offset = 0); - - -class @NAME@ : public gr_sync_block { - private: - @NAME@ (double sampling_freq, gr_waveform_t waveform, - double wave_freq, double ampl, @TYPE@ offset); - - public: - - // ACCESSORS - double sampling_freq () const { return d_sampling_freq; } - gr_waveform_t waveform () const { return d_waveform; } - double frequency () const { return d_frequency; } - double amplitude () const { return d_ampl; } - @TYPE@ offset () const { return d_offset; } - - // MANIPULATORS - void set_sampling_freq (double sampling_freq); - void set_waveform (gr_waveform_t waveform); - void set_frequency (double frequency); - void set_amplitude (double ampl); - void set_offset (@TYPE@ offset); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_sig_source_waveform.h b/gnuradio-core/src/lib/gengen/gr_sig_source_waveform.h deleted file mode 100644 index 9fe233ba4a..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_sig_source_waveform.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_SIG_SOURCE_WAVEFORM_H -#define INCLUDED_GR_SIG_SOURCE_WAVEFORM_H - -typedef enum { - GR_CONST_WAVE = 100, GR_SIN_WAVE, GR_COS_WAVE, GR_SQR_WAVE, GR_TRI_WAVE, GR_SAW_WAVE -} gr_waveform_t; - -#endif /* INCLUDED_GR_SIG_SOURCE_WAVEFORM_H */ diff --git a/gnuradio-core/src/lib/gengen/gr_sub_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_sub_XX.cc.t deleted file mode 100644 index 11eb7440e0..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_sub_XX.cc.t +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (size_t vlen) -{ - return gnuradio::get_initial_sptr (new @NAME@ (vlen)); -} - -@NAME@::@NAME@ (size_t vlen) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)*vlen), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)*vlen)), - d_vlen (vlen) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - if (ninputs == 1){ // negate - for (size_t i = 0; i < noutput_items*d_vlen; i++) - *optr++ = (@O_TYPE@) -((@I_TYPE@ *) input_items[0])[i]; - } - - else { - for (size_t i = 0; i < noutput_items*d_vlen; i++){ - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc -= ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_sub_XX.h.t b/gnuradio-core/src/lib/gengen/gr_sub_XX.h.t deleted file mode 100644 index f96c934845..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_sub_XX.h.t +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -/*! - * \brief output = input_0 - input_1 - ...) - * \ingroup math_blk - * - * Subtract across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - @NAME@ (size_t vlen); - - size_t d_vlen; - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_sub_XX.i.t b/gnuradio-core/src/lib/gengen/gr_sub_XX.i.t deleted file mode 100644 index b2c5106106..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_sub_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004, 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (size_t vlen); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_unpacked_to_packed_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_unpacked_to_packed_XX.cc.t deleted file mode 100644 index ed2b713dbb..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_unpacked_to_packed_XX.cc.t +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> -#include <assert.h> - -static const unsigned int BITS_PER_TYPE = sizeof(@O_TYPE@) * 8; - - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness) -{ - return @SPTR_NAME@ - (new @NAME@ (bits_per_chunk,endianness)); -} - -@NAME@::@NAME@ (unsigned int bits_per_chunk, - gr_endianness_t endianness) - : gr_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, -1, sizeof (@O_TYPE@))), - d_bits_per_chunk(bits_per_chunk),d_endianness(endianness),d_index(0) -{ - assert (bits_per_chunk <= BITS_PER_TYPE); - assert (bits_per_chunk > 0); - - set_relative_rate (bits_per_chunk/(1.0 * BITS_PER_TYPE)); -} - -void -@NAME@::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - int input_required = (int) ceil( (d_index+noutput_items * 1.0 * BITS_PER_TYPE)/d_bits_per_chunk); - unsigned ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) { - ninput_items_required[i] = input_required; - } -} - -unsigned int -get_bit_be1 (const @I_TYPE@ *in_vector,unsigned int bit_addr, unsigned int bits_per_chunk) { - unsigned int byte_addr = (int)bit_addr/bits_per_chunk; - @I_TYPE@ x = in_vector[byte_addr]; - unsigned int residue = bit_addr - byte_addr * bits_per_chunk; - //printf("Bit addr %d byte addr %d residue %d val %d\n",bit_addr,byte_addr,residue,(x>>(bits_per_chunk-1-residue))&1); - return (x >> (bits_per_chunk-1-residue))&1; -} - -int -@NAME@::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - unsigned int index_tmp = d_index; - - assert (input_items.size() == output_items.size()); - int nstreams = input_items.size(); - - for (int m=0; m< nstreams; m++) { - const @I_TYPE@ *in = (@I_TYPE@ *) input_items[m]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[m]; - index_tmp=d_index; - - // per stream processing - - //assert((ninput_items[m]-d_index)*d_bits_per_chunk >= noutput_items*BITS_PER_TYPE); - - switch(d_endianness){ - - case GR_MSB_FIRST: - for(int i=0;i<noutput_items;i++) { - @O_TYPE@ tmp=0; - for(unsigned int j=0; j<BITS_PER_TYPE; j++) { - tmp = (tmp<<1) | get_bit_be1(in,index_tmp,d_bits_per_chunk); - index_tmp++; - } - out[i] = tmp; - } - break; - - case GR_LSB_FIRST: - for(int i=0;i<noutput_items;i++) { - unsigned long tmp=0; - for(unsigned int j=0; j<BITS_PER_TYPE; j++) { - tmp = (tmp>>1)| (get_bit_be1(in,index_tmp,d_bits_per_chunk)<<(BITS_PER_TYPE-1)); - index_tmp++; - } - out[i] = tmp; - } - break; - - default: - assert(0); - } - } - - d_index = index_tmp; - consume_each ((int)(d_index/d_bits_per_chunk)); - d_index = d_index%d_bits_per_chunk; - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_unpacked_to_packed_XX.h.t b/gnuradio-core/src/lib/gengen/gr_unpacked_to_packed_XX.h.t deleted file mode 100644 index a7b7b54df9..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_unpacked_to_packed_XX.h.t +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_block.h> -#include <gr_endianness.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @NAME@_sptr; - -GR_CORE_API @SPTR_NAME@ -gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); - -/*! - * \brief Convert a stream of unpacked bytes or shorts into a stream of packed bytes or shorts. - * \ingroup converter_blk - * - * input: stream of @I_TYPE@; output: stream of @O_TYPE@ - * - * This is the inverse of gr_packed_to_unpacked_XX. - * - * The low \p bits_per_chunk bits are extracted from each input byte or short. - * These bits are then packed densely into the output bytes or shorts, such that - * all 8 or 16 bits of the output bytes or shorts are filled with valid input bits. - * The right thing is done if bits_per_chunk is not a power of two. - * - * The combination of gr_packed_to_unpacked_XX followed by - * gr_chunks_to_symbols_Xf or gr_chunks_to_symbols_Xc handles the - * general case of mapping from a stream of bytes or shorts into arbitrary float - * or complex symbols. - * - * \sa gr_packed_to_unpacked_bb, gr_unpacked_to_packed_bb, - * \sa gr_packed_to_unpacked_ss, gr_unpacked_to_packed_ss, - * \sa gr_chunks_to_symbols_bf, gr_chunks_to_symbols_bc. - * \sa gr_chunks_to_symbols_sf, gr_chunks_to_symbols_sc. - */ -class GR_CORE_API @NAME@ : public gr_block -{ - friend GR_CORE_API @SPTR_NAME@ - gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); - - @NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); - - unsigned int d_bits_per_chunk; - gr_endianness_t d_endianness; - unsigned int d_index; - - 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); - - bool check_topology(int ninputs, int noutputs) { return ninputs == noutputs; } -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_unpacked_to_packed_XX.i.t b/gnuradio-core/src/lib/gengen/gr_unpacked_to_packed_XX.i.t deleted file mode 100644 index 1e978956a1..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_unpacked_to_packed_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); - -class @NAME@ : public gr_block -{ - @NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); -}; diff --git a/gnuradio-core/src/lib/gengen/gr_xor_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_xor_XX.cc.t deleted file mode 100644 index d6990aa4f5..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_xor_XX.cc.t +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ () -{ - return gnuradio::get_initial_sptr (new @NAME@ ()); -} - -@NAME@::@NAME@ () - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - for (int i = 0; i < noutput_items; i++) { - @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; - for (int j = 1; j < ninputs; j++) - acc = acc ^ ((@I_TYPE@ *) input_items[j])[i]; - - *optr++ = (@O_TYPE@) acc; - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/gengen/gr_xor_XX.h.t b/gnuradio-core/src/lib/gengen/gr_xor_XX.h.t deleted file mode 100644 index 8fe47d9e00..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_xor_XX.h.t +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - -/*! - * \brief output = input_0 ^ input_1 ^ , ... ^ input_N) - * \ingroup math_blk - * - * bitwise boolean xor across all input streams. - */ -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); - - @NAME@ (); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_xor_XX.i.t b/gnuradio-core/src/lib/gengen/gr_xor_XX.i.t deleted file mode 100644 index 06db5ca59d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_xor_XX.i.t +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (); - -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (); -}; diff --git a/gnuradio-core/src/lib/hier/CMakeLists.txt b/gnuradio-core/src/lib/hier/CMakeLists.txt deleted file mode 100644 index 192dd5939a..0000000000 --- a/gnuradio-core/src/lib/hier/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 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. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - -list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/gr_channel_model.cc -) - -install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/gr_channel_model.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "core_devel" -) - -if(ENABLE_PYTHON) - install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/hier.i - ${CMAKE_CURRENT_SOURCE_DIR}/gr_channel_model.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "core_swig" - ) -endif(ENABLE_PYTHON) diff --git a/gnuradio-core/src/lib/hier/gr_channel_model.cc b/gnuradio-core/src/lib/hier/gr_channel_model.cc deleted file mode 100644 index 7da3578093..0000000000 --- a/gnuradio-core/src/lib/hier/gr_channel_model.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gr_channel_model.h> -#include <gr_io_signature.h> -#include <gr_sig_source_f.h> -#include <iostream> - -// Shared pointer constructor -gr_channel_model_sptr -gr_make_channel_model(double noise_voltage, - double frequency_offset, - double epsilon, - const std::vector<gr_complex> &taps, - double noise_seed) -{ - return gnuradio::get_initial_sptr(new gr_channel_model(noise_voltage, - frequency_offset, - epsilon, - taps, - noise_seed)); -} - -// Hierarchical block constructor -gr_channel_model::gr_channel_model(double noise_voltage, - double frequency_offset, - double epsilon, - const std::vector<gr_complex> &taps, - double noise_seed) - : gr_hier_block2("gr_channel_model", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(1, 1, sizeof(gr_complex))) -{ - d_taps = taps; - while(d_taps.size() < 2) { - d_taps.push_back(0); - } - - d_timing_offset = gr_make_fractional_interpolator_cc(0, epsilon); - - d_multipath = gr_make_fir_filter_ccc(1, d_taps); - - d_noise_adder = gr_make_add_cc(); - d_noise = gr_make_fastnoise_source_c(GR_GAUSSIAN, noise_voltage, noise_seed, 1024*8); - d_freq_offset = gr_make_sig_source_c(1, GR_SIN_WAVE, frequency_offset, 1.0, 0.0); - d_mixer_offset = gr_make_multiply_cc(); - - connect(self(), 0, d_timing_offset, 0); - connect(d_timing_offset, 0, d_multipath, 0); - connect(d_multipath, 0, d_mixer_offset, 0); - connect(d_freq_offset, 0, d_mixer_offset, 1); - connect(d_mixer_offset, 0, d_noise_adder, 1); - connect(d_noise, 0, d_noise_adder, 0); - connect(d_noise_adder, 0, self(), 0); -} - -void -gr_channel_model::set_noise_voltage(double noise_voltage) -{ - d_noise->set_amplitude(noise_voltage); -} - -void -gr_channel_model::set_frequency_offset(double frequency_offset) -{ - d_freq_offset->set_frequency(frequency_offset); -} - -void -gr_channel_model::set_taps(const std::vector<gr_complex> &taps) -{ - d_taps = taps; - while(d_taps.size() < 2) { - d_taps.push_back(0); - } - d_multipath->set_taps(d_taps); -} - -void -gr_channel_model::set_timing_offset(double epsilon) -{ - d_timing_offset->set_interp_ratio(epsilon); -} - - -double -gr_channel_model::noise_voltage() const -{ - return d_noise->amplitude(); -} - -double -gr_channel_model::frequency_offset() const -{ - return d_freq_offset->frequency(); -} - -std::vector<gr_complex> -gr_channel_model::taps() const -{ - return d_multipath->taps(); -} - -double -gr_channel_model::timing_offset() const -{ - return d_timing_offset->interp_ratio(); -} diff --git a/gnuradio-core/src/lib/hier/gr_channel_model.h b/gnuradio-core/src/lib/hier/gr_channel_model.h deleted file mode 100644 index 5796a6db24..0000000000 --- a/gnuradio-core/src/lib/hier/gr_channel_model.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gr_core_api.h> -#include <gr_top_block.h> -#include <gr_fractional_interpolator_cc.h> -#include <gr_sig_source_c.h> -#include <gr_fir_filter_ccc.h> -#include <gr_add_cc.h> -#include <gr_fastnoise_source_c.h> -#include <gr_multiply_cc.h> - -class gr_channel_model; -typedef boost::shared_ptr<gr_channel_model> gr_channel_model_sptr; - - -GR_CORE_API gr_channel_model_sptr gr_make_channel_model(double noise_voltage=0.0, - double frequency_offset=0.0, - double epsilon=1.0, - const std::vector<gr_complex> &taps=std::vector<gr_complex>(1, 1), - double noise_seed=0); - -/*! - * \brief channel simulator - * \ingroup misc_blk - */ -class GR_CORE_API gr_channel_model : public gr_hier_block2 -{ - private: - gr_channel_model(double noise_voltage, - double frequency_offset, - double epsilon, - const std::vector<gr_complex> &taps, - double noise_seed); - - friend GR_CORE_API gr_channel_model_sptr gr_make_channel_model(double noise_voltage, - double frequency_offset, - double epsilon, - const std::vector<gr_complex> &taps, - double noise_seed); - - gr_fractional_interpolator_cc_sptr d_timing_offset; - gr_sig_source_c_sptr d_freq_offset; - gr_fir_filter_ccc_sptr d_multipath; - gr_add_cc_sptr d_noise_adder; - gr_fastnoise_source_c_sptr d_noise; - gr_multiply_cc_sptr d_mixer_offset; - - std::vector<gr_complex> d_taps; - - public: - void set_noise_voltage(double noise_voltage); - void set_frequency_offset(double frequency_offset); - void set_taps(const std::vector<gr_complex> &taps); - void set_timing_offset(double epsilon); - - double noise_voltage() const; - double frequency_offset() const; - std::vector<gr_complex> taps() const; - double timing_offset() const; -}; diff --git a/gnuradio-core/src/lib/hier/gr_channel_model.i b/gnuradio-core/src/lib/hier/gr_channel_model.i deleted file mode 100644 index 9aa6ebf5b0..0000000000 --- a/gnuradio-core/src/lib/hier/gr_channel_model.i +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,channel_model) - -gr_channel_model_sptr gr_make_channel_model(double noise_voltage=0.0, - double frequency_offset=0.0, - double epsilon=1.0, - const std::vector<gr_complex> &taps=std::vector<gr_complex>(1, 1), - double noise_seed=0); - -class gr_channel_model : public gr_hier_block2 -{ - private: - gr_channel_model(double noise_voltage, - double frequency_offset, - double epsilon, - const std::vector<gr_complex> &taps, - double noise_seed); - - public: - void set_noise_voltage(double noise_voltage); - void set_frequency_offset(double frequency_offset); - void set_taps(const std::vector<gr_complex> &taps); - void set_timing_offset(double epsilon); - - double noise_voltage() const; - double frequency_offset() const; - std::vector<gr_complex> taps() const; - double timing_offset() const; -}; diff --git a/gnuradio-core/src/lib/hier/hier.i b/gnuradio-core/src/lib/hier/hier.i deleted file mode 100644 index 82044415e1..0000000000 --- a/gnuradio-core/src/lib/hier/hier.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%{ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_channel_model.h> -%} - -%include "gr_channel_model.i" - diff --git a/gnuradio-core/src/lib/io/CMakeLists.txt b/gnuradio-core/src/lib/io/CMakeLists.txt index 59ca06b5a2..7aeea798cd 100644 --- a/gnuradio-core/src/lib/io/CMakeLists.txt +++ b/gnuradio-core/src/lib/io/CMakeLists.txt @@ -37,9 +37,6 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4937.cc ${CMAKE_CURRENT_SOURCE_DIR}/microtune_xxxx.cc ${CMAKE_CURRENT_SOURCE_DIR}/ppio_ppdev.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_wavfile.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_pdu.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_stream_pdu_base.cc ) ######################################################################## @@ -60,9 +57,6 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/microtune_eval_board_defs.h ${CMAKE_CURRENT_SOURCE_DIR}/microtune_xxxx.h ${CMAKE_CURRENT_SOURCE_DIR}/ppio_ppdev.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_wavfile.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_pdu.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_stream_pdu_base.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel" ) @@ -84,29 +78,11 @@ endif(ENABLE_PYTHON) # Handle triple-threat files that have cc, h, and i ######################################################################## set(gr_core_io_triple_threats - gr_file_sink - gr_file_sink_base - gr_file_source - gr_file_descriptor_sink - gr_file_descriptor_source - gr_message_debug - gr_message_sink - gr_message_source - gr_message_burst_source - gr_pdu_to_tagged_stream microtune_xxxx_eval_board microtune_4702_eval_board microtune_4937_eval_board ppio sdr_1000 - gr_udp_sink - gr_udp_source - gr_wavfile_source - gr_wavfile_sink - gr_tagged_file_sink - gr_tagged_stream_to_pdu - gr_tuntap_pdu - gr_socket_pdu ) foreach(file_tt ${gr_core_io_triple_threats}) diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc deleted file mode 100644 index 099d46dbd0..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_file_descriptor_sink.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <stdio.h> - -#ifdef HAVE_IO_H -#include <io.h> -#endif - -gr_file_descriptor_sink::gr_file_descriptor_sink (size_t itemsize, int fd) - : gr_sync_block ("file_descriptor_sink", - gr_make_io_signature (1, 1, itemsize), - gr_make_io_signature (0, 0, 0)), - d_itemsize (itemsize), d_fd (fd) -{ -} - -gr_file_descriptor_sink_sptr -gr_make_file_descriptor_sink (size_t itemsize, int fd) -{ - return gnuradio::get_initial_sptr(new gr_file_descriptor_sink (itemsize, fd)); -} - -gr_file_descriptor_sink::~gr_file_descriptor_sink () -{ - close (d_fd); -} - -int -gr_file_descriptor_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - char *inbuf = (char *) input_items[0]; - unsigned long byte_size = noutput_items * d_itemsize; - - while (byte_size > 0){ - ssize_t r; - - r = write (d_fd, inbuf, byte_size); - if (r == -1){ - if (errno == EINTR) - continue; - else { - perror ("gr_file_descriptor_sink"); - return -1; // indicate we're done - } - } - else { - byte_size -= r; - inbuf += r; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h deleted file mode 100644 index 3b1c1167f7..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FILE_DESCRIPTOR_SINK_H -#define INCLUDED_GR_FILE_DESCRIPTOR_SINK_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_file_descriptor_sink; -typedef boost::shared_ptr<gr_file_descriptor_sink> gr_file_descriptor_sink_sptr; - -GR_CORE_API gr_file_descriptor_sink_sptr gr_make_file_descriptor_sink (size_t itemsize, int fd); - -/*! - * \brief Write stream to file descriptor. - * \ingroup sink_blk - */ - -class GR_CORE_API gr_file_descriptor_sink : public gr_sync_block -{ - friend GR_CORE_API gr_file_descriptor_sink_sptr gr_make_file_descriptor_sink (size_t itemsize, int fd); - - private: - size_t d_itemsize; - int d_fd; - - protected: - gr_file_descriptor_sink (size_t itemsize, int fd); - - public: - ~gr_file_descriptor_sink (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SINK_H */ diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.i b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.i deleted file mode 100644 index 2c256e44d1..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,file_descriptor_sink) - -gr_file_descriptor_sink_sptr -gr_make_file_descriptor_sink (size_t itemsize, int fd); - -class gr_file_descriptor_sink : public gr_sync_block -{ - protected: - gr_file_descriptor_sink (size_t itemsize, int fd); - - public: - ~gr_file_descriptor_sink (); -}; diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_source.cc b/gnuradio-core/src/lib/io/gr_file_descriptor_source.cc deleted file mode 100644 index a63abf96b7..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_source.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_file_descriptor_source.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <stdio.h> -#include <string.h> - -#ifdef HAVE_IO_H -#include <io.h> -#endif - -gr_file_descriptor_source::gr_file_descriptor_source (size_t itemsize, - int fd, - bool repeat) - : gr_sync_block ("file_descriptor_source", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, itemsize)), - d_itemsize (itemsize), d_fd (fd), d_repeat (repeat), - d_residue (new unsigned char[itemsize]), d_residue_len (0) -{ -} - -// public constructor that returns a shared_ptr - -gr_file_descriptor_source_sptr -gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat) -{ - return gr_file_descriptor_source_sptr ( - new gr_file_descriptor_source (itemsize, fd, repeat)); -} - -gr_file_descriptor_source::~gr_file_descriptor_source () -{ - close (d_fd); - delete [] d_residue; -} - -int -gr_file_descriptor_source::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert (noutput_items > 0); - - char *o = (char *) output_items[0]; - int nread = 0; - - while (1){ - int r = read_items (o, noutput_items - nread); - if (r == -1){ - if (errno == EINTR) - continue; - else { - perror ("file_descriptor_source[read]"); - return -1; - } - } - else if (r == 0){ // end of file - if (!d_repeat) - break; - else { - flush_residue (); - if (lseek (d_fd, 0, SEEK_SET) == -1){ - perror ("file_descriptor_source[lseek]"); - return -1; - } - } - } - else { - o += r * d_itemsize; - nread += r; - break; - } - } - - if (nread == 0) // EOF - return -1; - - return nread; -} - -int -gr_file_descriptor_source::read_items (char *buf, int nitems) -{ - assert (nitems > 0); - assert (d_residue_len < d_itemsize); - - int nbytes_read = 0; - - if (d_residue_len > 0){ - memcpy (buf, d_residue, d_residue_len); - nbytes_read = d_residue_len; - d_residue_len = 0; - } - - int r = read (d_fd, buf + nbytes_read, nitems * d_itemsize - nbytes_read); - if (r <= 0){ - handle_residue (buf, nbytes_read); - return r; - } - - r = handle_residue (buf, r + nbytes_read); - - if (r == 0) // block until we get something - return read_items (buf, nitems); - - return r; -} - -int -gr_file_descriptor_source::handle_residue (char *buf, int nbytes_read) -{ - assert (nbytes_read >= 0); - int nitems_read = nbytes_read / d_itemsize; - d_residue_len = nbytes_read % d_itemsize; - if (d_residue_len > 0){ - // fprintf (stderr, "handle_residue: %d\n", d_residue_len); - memcpy (d_residue, buf + nbytes_read - d_residue_len, d_residue_len); - } - return nitems_read; -} diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_source.h b/gnuradio-core/src/lib/io/gr_file_descriptor_source.h deleted file mode 100644 index ebabd81eda..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_source.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H -#define INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_file_descriptor_source; -typedef boost::shared_ptr<gr_file_descriptor_source> gr_file_descriptor_source_sptr; - -GR_CORE_API gr_file_descriptor_source_sptr -gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat = false); - -/*! - * \brief Read stream from file descriptor. - * \ingroup source_blk - */ - -class GR_CORE_API gr_file_descriptor_source : public gr_sync_block -{ - friend GR_CORE_API gr_file_descriptor_source_sptr - gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat); - private: - size_t d_itemsize; - int d_fd; - bool d_repeat; - - unsigned char *d_residue; - unsigned long d_residue_len; - - protected: - gr_file_descriptor_source (size_t itemsize, int fd, bool repeat); - - int read_items (char *buf, int nitems); - int handle_residue (char *buf, int nbytes_read); - void flush_residue () { d_residue_len = 0; } - - - public: - ~gr_file_descriptor_source (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H */ diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_source.i b/gnuradio-core/src/lib/io/gr_file_descriptor_source.i deleted file mode 100644 index 3ca0825225..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_source.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,file_descriptor_source) - -gr_file_descriptor_source_sptr -gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat=false); - -class gr_file_descriptor_source : public gr_sync_block -{ - protected: - gr_file_descriptor_source (size_t itemsize, int fd, bool repeat); - - public: - ~gr_file_descriptor_source (); -}; diff --git a/gnuradio-core/src/lib/io/gr_file_sink.cc b/gnuradio-core/src/lib/io/gr_file_sink.cc deleted file mode 100644 index 10c8360cb6..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_sink.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_file_sink.h> -#include <gr_io_signature.h> -#include <stdexcept> - - -gr_file_sink_sptr -gr_make_file_sink (size_t itemsize, const char *filename) -{ - return gnuradio::get_initial_sptr(new gr_file_sink (itemsize, filename)); -} - -gr_file_sink::gr_file_sink(size_t itemsize, const char *filename) - : gr_sync_block ("file_sink", - gr_make_io_signature(1, 1, itemsize), - gr_make_io_signature(0, 0, 0)), - gr_file_sink_base(filename, true), - d_itemsize(itemsize) -{ -} - -gr_file_sink::~gr_file_sink () -{ -} - -int -gr_file_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - char *inbuf = (char*)input_items[0]; - int nwritten = 0; - - do_update(); // update d_fp is reqd - - if(!d_fp) - return noutput_items; // drop output on the floor - - while(nwritten < noutput_items) { - int count = fwrite(inbuf, d_itemsize, noutput_items - nwritten, d_fp); - if(count == 0) { - if(ferror(d_fp)) { - std::stringstream s; - s << "file_sink write failed with error " << fileno(d_fp) << std::endl; - throw std::runtime_error(s.str()); - } - else { // is EOF - break; - } - } - nwritten += count; - inbuf += count * d_itemsize; - } - - if(d_unbuffered) - fflush (d_fp); - - return nwritten; -} diff --git a/gnuradio-core/src/lib/io/gr_file_sink.h b/gnuradio-core/src/lib/io/gr_file_sink.h deleted file mode 100644 index e40ec9ab8d..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_sink.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FILE_SINK_H -#define INCLUDED_GR_FILE_SINK_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_file_sink_base.h> - -class gr_file_sink; -typedef boost::shared_ptr<gr_file_sink> gr_file_sink_sptr; - -GR_CORE_API gr_file_sink_sptr gr_make_file_sink(size_t itemsize, const char *filename); - -/*! - * \brief Write stream to file. - * \ingroup sink_blk - */ - -class GR_CORE_API gr_file_sink : public gr_sync_block, public gr_file_sink_base -{ - friend GR_CORE_API gr_file_sink_sptr gr_make_file_sink(size_t itemsize, const char *filename); - - private: - size_t d_itemsize; - - protected: - gr_file_sink(size_t itemsize, const char *filename); - - public: - ~gr_file_sink(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FILE_SINK_H */ diff --git a/gnuradio-core/src/lib/io/gr_file_sink.i b/gnuradio-core/src/lib/io/gr_file_sink.i deleted file mode 100644 index 47ab9e9649..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_sink.i +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,file_sink) - -gr_file_sink_sptr -gr_make_file_sink (size_t itemsize, const char *filename); - -class gr_file_sink : public gr_sync_block, public gr_file_sink_base -{ - protected: - gr_file_sink (size_t itemsize, const char *filename); - - public: - ~gr_file_sink (); - - /*! - * \brief open filename and begin output to it. - */ - bool open(const char *filename); - - /*! - * \brief close current output file. - */ - void close(); -}; diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.cc b/gnuradio-core/src/lib/io/gr_file_sink_base.cc deleted file mode 100644 index d0aca418e7..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.cc +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2007,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_file_sink_base.h> -#include <cstdio> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <stdio.h> -#include <gruel/thread.h> - -// win32 (mingw/msvc) specific -#ifdef HAVE_IO_H -#include <io.h> -#endif -#ifdef O_BINARY -#define OUR_O_BINARY O_BINARY -#else -#define OUR_O_BINARY 0 -#endif - -// should be handled via configure -#ifdef O_LARGEFILE -#define OUR_O_LARGEFILE O_LARGEFILE -#else -#define OUR_O_LARGEFILE 0 -#endif - -gr_file_sink_base::gr_file_sink_base(const char *filename, bool is_binary) - : d_fp(0), d_new_fp(0), d_updated(false), d_is_binary(is_binary) -{ - if (!open(filename)) - throw std::runtime_error ("can't open file"); -} - -gr_file_sink_base::~gr_file_sink_base () -{ - close(); - if (d_fp){ - fclose(d_fp); - d_fp = 0; - } -} - -bool -gr_file_sink_base::open(const char *filename) -{ - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function - - // we use the open system call to get access to the O_LARGEFILE flag. - int fd; - if ((fd = ::open (filename, - O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY, - 0664)) < 0){ - perror (filename); - return false; - } - if (d_new_fp){ // if we've already got a new one open, close it - fclose(d_new_fp); - d_new_fp = 0; - } - - if ((d_new_fp = fdopen (fd, d_is_binary ? "wb" : "w")) == NULL){ - perror (filename); - ::close(fd); // don't leak file descriptor if fdopen fails. - } - - d_updated = true; - return d_new_fp != 0; -} - -void -gr_file_sink_base::close() -{ - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function - - if (d_new_fp){ - fclose(d_new_fp); - d_new_fp = 0; - } - d_updated = true; -} - -void -gr_file_sink_base::do_update() -{ - if (d_updated){ - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this block - if (d_fp) - fclose(d_fp); - d_fp = d_new_fp; // install new file pointer - d_new_fp = 0; - d_updated = false; - } -} - -void -gr_file_sink_base::set_unbuffered(bool unbuffered) -{ - d_unbuffered = unbuffered; -} diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.h b/gnuradio-core/src/lib/io/gr_file_sink_base.h deleted file mode 100644 index 8a70cee768..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FILE_SINK_BASE_H -#define INCLUDED_GR_FILE_SINK_BASE_H - -#include <gr_core_api.h> -#include <boost/thread.hpp> -#include <cstdio> - -/*! - * \brief Common base class for file sinks - */ -class GR_CORE_API gr_file_sink_base -{ - protected: - FILE *d_fp; // current FILE pointer - FILE *d_new_fp; // new FILE pointer - bool d_updated; // is there a new FILE pointer? - bool d_is_binary; - boost::mutex d_mutex; - bool d_unbuffered; - - protected: - gr_file_sink_base(const char *filename, bool is_binary); - - public: - ~gr_file_sink_base(); - - /*! - * \brief Open filename and begin output to it. - */ - bool open(const char *filename); - - /*! - * \brief Close current output file. - * - * Closes current output file and ignores any output until - * open is called to connect to another file. - */ - void close(); - - /*! - * \brief if we've had an update, do it now. - */ - void do_update(); - - - /*! - * \brief turn on unbuffered writes for slower outputs - */ - void set_unbuffered(bool unbuffered); -}; - - -#endif /* INCLUDED_GR_FILE_SINK_BASE_H */ diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.i b/gnuradio-core/src/lib/io/gr_file_sink_base.i deleted file mode 100644 index 993dba2770..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.i +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -class gr_file_sink_base -{ - protected: - gr_file_sink_base(const char *filename, bool is_binary); - - public: - ~gr_file_sink_base(); - - /*! - * \brief Open filename and begin output to it. - */ - bool open(const char *filename); - - /*! - * \brief Close current output file. - * - * Closes current output file and ignores any output until - * open is called to connect to another file. - */ - void close(); - - /*! - * \brief if we've had an update, do it now. - */ - void do_update(); - - /*! - *\brief turn on unbuffered mode for slow outputs - */ - void set_unbuffered(bool unbuffered); -}; diff --git a/gnuradio-core/src/lib/io/gr_file_source.cc b/gnuradio-core/src/lib/io/gr_file_source.cc deleted file mode 100644 index 6da7abac21..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_source.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gruel/thread.h> -#include <gr_file_source.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <stdio.h> - -// win32 (mingw/msvc) specific -#ifdef HAVE_IO_H -#include <io.h> -#endif -#ifdef O_BINARY -#define OUR_O_BINARY O_BINARY -#else -#define OUR_O_BINARY 0 -#endif -// should be handled via configure -#ifdef O_LARGEFILE -#define OUR_O_LARGEFILE O_LARGEFILE -#else -#define OUR_O_LARGEFILE 0 -#endif - -gr_file_source::gr_file_source(size_t itemsize, const char *filename, bool repeat) - : gr_sync_block("file_source", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, itemsize)), - d_itemsize(itemsize), d_fp(0), d_new_fp (0), d_repeat(repeat), - d_updated(false) -{ - open(filename, repeat); -} - -// public constructor that returns a shared_ptr - -gr_file_source_sptr -gr_make_file_source (size_t itemsize, const char *filename, bool repeat) -{ - return gnuradio::get_initial_sptr(new gr_file_source (itemsize, filename, repeat)); -} - -gr_file_source::~gr_file_source () -{ - close(); - if(d_fp) { - fclose(d_fp); - d_fp = 0; - } -} - -int -gr_file_source::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - char *o = (char *) output_items[0]; - int i; - int size = noutput_items; - - do_update(); // update d_fp is reqd - if(d_fp == NULL) - throw std::runtime_error("work with file not open"); - - gruel::scoped_lock lock(fp_mutex); // hold for the rest of this function - while (size) { - i = fread(o, d_itemsize, size, (FILE *) d_fp); - - size -= i; - o += i * d_itemsize; - - if (size == 0) // done - break; - - if (i > 0) // short read, try again - continue; - - // We got a zero from fread. This is either EOF or error. In - // any event, if we're in repeat mode, seek back to the beginning - // of the file and try again, else break - - if (!d_repeat) - break; - - if (fseek ((FILE *) d_fp, 0, SEEK_SET) == -1) { - std::stringstream s; - s << "[" << __FILE__ << "]" << " fseek failed" << std::endl; - throw std::runtime_error(s.str()); - } - } - - if (size > 0){ // EOF or error - if (size == noutput_items) // we didn't read anything; say we're done - return -1; - return noutput_items - size; // else return partial result - } - - return noutput_items; -} - -bool -gr_file_source::seek (long seek_point, int whence) -{ - // obtain exclusive access for duration of this function - gruel::scoped_lock lock(fp_mutex); - return fseek((FILE *) d_fp, seek_point * d_itemsize, whence) == 0; -} - -void -gr_file_source::open(const char *filename, bool repeat) -{ - // obtain exclusive access for duration of this function - gruel::scoped_lock lock(fp_mutex); - - int fd; - - // we use "open" to use to the O_LARGEFILE flag - if((fd = ::open(filename, O_RDONLY | OUR_O_LARGEFILE | OUR_O_BINARY)) < 0) { - perror(filename); - throw std::runtime_error("can't open file"); - } - - if(d_new_fp) { - fclose(d_new_fp); - d_new_fp = 0; - } - - if((d_new_fp = fdopen (fd, "rb")) == NULL) { - perror(filename); - ::close(fd); // don't leak file descriptor if fdopen fails - throw std::runtime_error("can't open file"); - } - - d_updated = true; - d_repeat = repeat; -} - -void -gr_file_source::close() -{ - // obtain exclusive access for duration of this function - gruel::scoped_lock lock(fp_mutex); - - if(d_new_fp != NULL) { - fclose(d_new_fp); - d_new_fp = NULL; - } - d_updated = true; -} - -void -gr_file_source::do_update() -{ - if(d_updated) { - gruel::scoped_lock lock(fp_mutex); // hold while in scope - - if(d_fp) - fclose(d_fp); - - d_fp = d_new_fp; // install new file pointer - d_new_fp = 0; - d_updated = false; - } -} diff --git a/gnuradio-core/src/lib/io/gr_file_source.h b/gnuradio-core/src/lib/io/gr_file_source.h deleted file mode 100644 index 0478fba04b..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_source.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FILE_SOURCE_H -#define INCLUDED_GR_FILE_SOURCE_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <boost/thread/mutex.hpp> - -class gr_file_source; -typedef boost::shared_ptr<gr_file_source> gr_file_source_sptr; - -GR_CORE_API gr_file_source_sptr -gr_make_file_source (size_t itemsize, const char *filename, bool repeat = false); - -/*! - * \brief Read stream from file - * \ingroup source_blk - */ - -class GR_CORE_API gr_file_source : public gr_sync_block -{ - private: - size_t d_itemsize; - FILE *d_fp; - FILE *d_new_fp; - bool d_repeat; - bool d_updated; - - protected: - gr_file_source(size_t itemsize, const char *filename, bool repeat); - - void do_update(); - - boost::mutex fp_mutex; - - public: - /*! - * \brief Create a file source. - * - * Opens \p filename as a source of items into a flowgraph. The data - * is expected to be in binary format, item after item. The \p - * itemsize of the block determines the conversion from bits to - * items. - * - * If \p repeat is turned on, the file will repeat the file after - * it's reached the end. - * - * \param itemsize the size of each item in the file, in bytes - * \param filename name of the file to source from - * \param repeat repeat file from start - */ - friend GR_CORE_API gr_file_source_sptr - gr_make_file_source(size_t itemsize, - const char *filename, - bool repeat); - - ~gr_file_source(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - /*! - * \brief Seek file to \p seek_point relative to \p whence - * - * \param seek_point sample offset in file - * \param whence one of SEEK_SET, SEEK_CUR, SEEK_END (man fseek) - */ - bool seek(long seek_point, int whence); - - /*! - * \brief Opens a new file. - * - * \param filename name of the file to source from - * \param repeat repeat file from start - */ - void open(const char *filename, bool repeat); - - /*! - * \brief Close the file handle. - */ - void close(); - -}; - -#endif /* INCLUDED_GR_FILE_SOURCE_H */ diff --git a/gnuradio-core/src/lib/io/gr_file_source.i b/gnuradio-core/src/lib/io/gr_file_source.i deleted file mode 100644 index e71cef0d14..0000000000 --- a/gnuradio-core/src/lib/io/gr_file_source.i +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -%constant int SEEK_SET = 0; /* Seek from beginning of file. */ -%constant int SEEK_CUR = 1; /* Seek from current position. */ -%constant int SEEK_END = 2; /* Seek from end of file. */ - - -GR_SWIG_BLOCK_MAGIC(gr,file_source) - -gr_file_source_sptr -gr_make_file_source (size_t itemsize, const char *filename, bool repeat=false); - -class gr_file_source : public gr_sync_block -{ - protected: - gr_file_source (size_t itemsize, const char *filename, bool repeat); - - public: - ~gr_file_source (); - - bool seek (long seek_point, int whence); - void open (const char *filename, bool repeat); - void close(); -}; diff --git a/gnuradio-core/src/lib/io/gr_message_burst_source.cc b/gnuradio-core/src/lib/io/gr_message_burst_source.cc deleted file mode 100644 index e9e2dfd4dc..0000000000 --- a/gnuradio-core/src/lib/io/gr_message_burst_source.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_message_burst_source.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> -#include <gr_tags.h> - -// public constructor that returns a shared_ptr - -gr_message_burst_source_sptr -gr_make_message_burst_source(size_t itemsize, int msgq_limit) -{ - return gnuradio::get_initial_sptr(new gr_message_burst_source(itemsize, msgq_limit)); -} - -// public constructor that takes existing message queue -gr_message_burst_source_sptr -gr_make_message_burst_source(size_t itemsize, gr_msg_queue_sptr msgq) -{ - return gnuradio::get_initial_sptr(new gr_message_burst_source(itemsize, msgq)); -} - -gr_message_burst_source::gr_message_burst_source (size_t itemsize, int msgq_limit) - : gr_sync_block("message_burst_source", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(1, 1, itemsize)), - d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false) -{ - std::stringstream id; - id << name() << unique_id(); - d_me = pmt::pmt_string_to_symbol(id.str()); -} - -gr_message_burst_source::gr_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq) - : gr_sync_block("message_burst_source", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(1, 1, itemsize)), - d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false) -{ - std::stringstream id; - id << name() << unique_id(); - d_me = pmt::pmt_string_to_symbol(id.str()); -} - -gr_message_burst_source::~gr_message_burst_source() -{ -} - -int -gr_message_burst_source::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - char *out = (char *) output_items[0]; - int nn = 0; - - uint64_t abs_sample_count = nitems_written(0); - - while (nn < noutput_items){ - if (d_msg){ - // - // Consume whatever we can from the current message - // - - int mm = std::min(noutput_items - nn, (int)((d_msg->length() - d_msg_offset) / d_itemsize)); - memcpy (out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize); - - nn += mm; - out += mm * d_itemsize; - d_msg_offset += mm * d_itemsize; - assert(d_msg_offset <= d_msg->length()); - - if (d_msg_offset == d_msg->length()){ - if (d_msg->type() == 1) // type == 1 sets EOF - d_eof = true; - d_msg.reset(); - //tag end of burst - add_item_tag(0, //stream ID - abs_sample_count+nn-1, //sample number - pmt::pmt_string_to_symbol("tx_eob"), - pmt::pmt_from_bool(1), - d_me //block src id - ); - } - } - else { - // - // No current message - // - if (d_msgq->empty_p() && nn > 0){ // no more messages in the queue, return what we've got - break; - } - - if (d_eof) - return -1; - - d_msg = d_msgq->delete_head(); // block, waiting for a message - d_msg_offset = 0; - //tag start of burst - add_item_tag(0, //stream ID - abs_sample_count+nn, //sample number - pmt::pmt_string_to_symbol("tx_sob"), - pmt::pmt_from_bool(1), - d_me //block src id - ); - - - if ((d_msg->length() % d_itemsize) != 0) - throw std::runtime_error("msg length is not a multiple of d_itemsize"); - } - } - - return nn; -} diff --git a/gnuradio-core/src/lib/io/gr_message_burst_source.h b/gnuradio-core/src/lib/io/gr_message_burst_source.h deleted file mode 100644 index 63e2201139..0000000000 --- a/gnuradio-core/src/lib/io/gr_message_burst_source.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_MESSAGE_BURST_SOURCE_H -#define INCLUDED_GR_MESSAGE_BURST_SOURCE_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> - -class gr_message_burst_source; -typedef boost::shared_ptr<gr_message_burst_source> gr_message_burst_source_sptr; - -GR_CORE_API gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, int msgq_limit=0); -GR_CORE_API gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq); - -/*! - * \brief Turn received messages into a stream and tag them for UHD to send. - * \ingroup source_blk - */ -class GR_CORE_API gr_message_burst_source : public gr_sync_block -{ - private: - size_t d_itemsize; - gr_msg_queue_sptr d_msgq; - gr_message_sptr d_msg; - unsigned d_msg_offset; - bool d_eof; - - pmt::pmt_t d_me; - - friend GR_CORE_API gr_message_burst_source_sptr - gr_make_message_burst_source(size_t itemsize, int msgq_limit); - friend GR_CORE_API gr_message_burst_source_sptr - gr_make_message_burst_source(size_t itemsize, gr_msg_queue_sptr msgq); - - protected: - gr_message_burst_source (size_t itemsize, int msgq_limit); - gr_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq); - - public: - ~gr_message_burst_source (); - - gr_msg_queue_sptr msgq() const { return d_msgq; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_gr_message_burst_source_H */ diff --git a/gnuradio-core/src/lib/io/gr_message_burst_source.i b/gnuradio-core/src/lib/io/gr_message_burst_source.i deleted file mode 100644 index f7ad840c22..0000000000 --- a/gnuradio-core/src/lib/io/gr_message_burst_source.i +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,message_burst_source); - -gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, int msgq_limit=0); -gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq); - -class gr_message_burst_source : public gr_sync_block -{ - protected: - gr_message_burst_source (size_t itemsize, int msgq_limit); - gr_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq); - - public: - ~gr_message_burst_source (); - - gr_msg_queue_sptr msgq() const; -}; diff --git a/gnuradio-core/src/lib/io/gr_message_debug.cc b/gnuradio-core/src/lib/io/gr_message_debug.cc deleted file mode 100644 index 9eb1bb6399..0000000000 --- a/gnuradio-core/src/lib/io/gr_message_debug.cc +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_message_debug.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> -#include <iostream> - -// public constructor that returns a shared_ptr - -gr_message_debug_sptr -gr_make_message_debug () -{ - return gnuradio::get_initial_sptr(new gr_message_debug()); -} - -void -gr_message_debug::print(pmt::pmt_t msg) -{ - std::cout << "******* MESSAGE DEBUG PRINT ********\n"; - pmt::pmt_print(msg); - std::cout << "************************************\n"; -} - -void -gr_message_debug::store(pmt::pmt_t msg) -{ - gruel::scoped_lock guard(d_mutex); - d_messages.push_back(msg); -} - -void -gr_message_debug::print_pdu(pmt::pmt_t pdu) -{ - pmt::pmt_t meta = pmt::pmt_car(pdu); - pmt::pmt_t vector = pmt::pmt_cdr(pdu); - std::cout << "* MESSAGE DEBUG PRINT PDU VERBOSE *\n"; - pmt::pmt_print(meta); - size_t len = pmt::pmt_length(vector); - std::cout << "pdu_length = " << len << std::endl; - std::cout << "contents = " << std::endl; - size_t offset(0); - const uint8_t* d = (const uint8_t*) pmt_uniform_vector_elements(vector, offset); - for(size_t i=0; i<len; i+=16){ - printf("%04x: ", ((unsigned int)i)); - for(size_t j=i; j<std::min(i+16,len); j++){ - printf("%02x ",d[j] ); - } - - std::cout << std::endl; - } - - std::cout << "***********************************\n"; -} - -int -gr_message_debug::num_messages() -{ - return (int)d_messages.size(); -} - -pmt::pmt_t -gr_message_debug::get_message(int i) -{ - gruel::scoped_lock guard(d_mutex); - - if((size_t)i >= d_messages.size()) { - throw std::runtime_error("gr_message_debug: index for message out of bounds.\n"); - } - - return d_messages[i]; -} - -gr_message_debug::gr_message_debug() - : gr_block("message_debug", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(0, 0, 0)) -{ - message_port_register_in(pmt::mp("print")); - set_msg_handler(pmt::mp("print"), boost::bind(&gr_message_debug::print, this, _1)); - - message_port_register_in(pmt::mp("store")); - set_msg_handler(pmt::mp("store"), boost::bind(&gr_message_debug::store, this, _1)); - - message_port_register_in(pmt::mp("print_pdu")); - set_msg_handler(pmt::mp("print_pdu"), boost::bind(&gr_message_debug::print_pdu, this, _1)); -} - -gr_message_debug::~gr_message_debug() -{ -} diff --git a/gnuradio-core/src/lib/io/gr_message_debug.h b/gnuradio-core/src/lib/io/gr_message_debug.h deleted file mode 100644 index f1374e8062..0000000000 --- a/gnuradio-core/src/lib/io/gr_message_debug.h +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_MESSAGE_DEBUG_H -#define INCLUDED_GR_MESSAGE_DEBUG_H - -#include <gr_core_api.h> -#include <gr_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> -#include <gruel/thread.h> - -class gr_message_debug; -typedef boost::shared_ptr<gr_message_debug> gr_message_debug_sptr; - -GR_CORE_API gr_message_debug_sptr gr_make_message_debug(); - -/*! - * \brief Print received messages to stdout - * \ingroup sink_blk - */ -class GR_CORE_API gr_message_debug : public gr_block -{ - private: - friend GR_CORE_API gr_message_debug_sptr - gr_make_message_debug(); - - /*! - * \brief Messages received in this port are printed to stdout. - * - * This port receives messages from the scheduler's message handling - * mechanism and prints it to stdout. This message handler function - * is only meant to be used by the scheduler to handle messages - * posted to port 'print'. - * - * \param msg A pmt message passed from the scheduler's message handling. - */ - void print(pmt::pmt_t msg); - - /*! - * \brief PDU formatted messages received in this port are printed to stdout. - * - * This port receives messages from the scheduler's message handling - * mechanism and prints it to stdout. This message handler function - * is only meant to be used by the scheduler to handle messages - * posted to port 'print'. - * - * \param pdu A PDU message passed from the scheduler's message handling. - */ - void print_pdu(pmt::pmt_t pdu); - - /*! - * \brief Messages received in this port are stored in a vector. - * - * This port receives messages from the scheduler's message handling - * mechanism and stores it in a vector. Messages can be retrieved - * later using the 'get_message' function. This message handler - * function is only meant to be used by the scheduler to handle - * messages posted to port 'store'. - * - * \param msg A pmt message passed from the scheduler's message handling. - */ - void store(pmt::pmt_t msg); - - gruel::mutex d_mutex; - std::vector<pmt::pmt_t> d_messages; - - protected: - gr_message_debug (); - - public: - ~gr_message_debug (); - - /*! - * \brief Reports the number of messages received by this block. - */ - int num_messages(); - - /*! - * \brief Get a message (as a PMT) from the message vector at index \p i. - * - * Messages passed to the 'store' port will be stored in a - * vector. This function retrieves those messages by index. They are - * index in order of when they were received (all messages are just - * pushed onto the back of a vector). This is mostly useful in - * debugging message passing graphs and in QA code. - * - * \param i The index in the vector for the message to retrieve. - * - * \return a message at index \p i as a pmt_t. - */ - pmt::pmt_t get_message(int i); -}; - -#endif /* INCLUDED_GR_MESSAGE_DEBUG_H */ diff --git a/gnuradio-core/src/lib/io/gr_message_debug.i b/gnuradio-core/src/lib/io/gr_message_debug.i deleted file mode 100644 index 65d3bfc4aa..0000000000 --- a/gnuradio-core/src/lib/io/gr_message_debug.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,message_debug); - -%{ -#include <gr_message_debug.h> -%} - -%include "gr_message_debug.h" - diff --git a/gnuradio-core/src/lib/io/gr_message_sink.cc b/gnuradio-core/src/lib/io/gr_message_sink.cc deleted file mode 100644 index 3816f5da48..0000000000 --- a/gnuradio-core/src/lib/io/gr_message_sink.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_message_sink.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> - -// public constructor that returns a shared_ptr - -gr_message_sink_sptr -gr_make_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block) -{ - return gnuradio::get_initial_sptr(new gr_message_sink(itemsize, msgq, dont_block)); -} -gr_message_sink_sptr -gr_make_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, const std::string& lengthtagname) -{ - return gnuradio::get_initial_sptr(new gr_message_sink(itemsize, msgq, dont_block, lengthtagname)); -} - -gr_message_sink::gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block) - : gr_sync_block("message_sink", - gr_make_io_signature(1, 1, itemsize), - gr_make_io_signature(0, 0, 0)), - d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block), d_tags(false), d_items_read(0) -{ -} - -gr_message_sink::gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, const std::string& lengthtagname) - : gr_sync_block("message_sink", - gr_make_io_signature(1, 1, itemsize), - gr_make_io_signature(0, 0, 0)), - d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block), d_tags(true), d_lengthtagname(lengthtagname), d_items_read(0) -{ -} - -gr_message_sink::~gr_message_sink() -{ -} - -int -gr_message_sink::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *in = (const char *) input_items[0]; - - if (d_tags) { - long packet_length = 0; - std::vector<gr_tag_t> tags; - this->get_tags_in_range(tags, 0, d_items_read, d_items_read+1); - //const size_t ninput_items = noutput_items; //assumption for sync block, this can change - for (unsigned int i = 0; i < tags.size(); i++) { - if (pmt::pmt_symbol_to_string(tags[i].key) == d_lengthtagname) { - packet_length = pmt::pmt_to_long(tags[i].value); - } - } - assert(packet_length != 0); - - // FIXME run this multiple times if input_items >= N * packet_length - if (noutput_items >= packet_length ) { - // If the message queue is full we drop the packet. - if (!d_msgq->full_p()) { - gr_message_sptr msg = gr_make_message(0, // msg type - d_itemsize, // arg1 for other end - packet_length, // arg2 for other end (redundant) - packet_length * d_itemsize); // len of msg - memcpy(msg->msg(), in, packet_length * d_itemsize); - d_msgq->handle(msg); // send it - } - d_items_read += packet_length; - return packet_length; - } else { - return 0; - } - } else { - // If the queue if full we drop all the data we got. - if (!d_msgq->full_p()) { - // build a message to hold whatever we've got - gr_message_sptr msg = gr_make_message(0, // msg type - d_itemsize, // arg1 for other end - noutput_items, // arg2 for other end (redundant) - noutput_items * d_itemsize); // len of msg - memcpy(msg->msg(), in, noutput_items * d_itemsize); - - d_msgq->handle(msg); // send it - } - return noutput_items; - } -} diff --git a/gnuradio-core/src/lib/io/gr_message_sink.h b/gnuradio-core/src/lib/io/gr_message_sink.h deleted file mode 100644 index 2db84cff44..0000000000 --- a/gnuradio-core/src/lib/io/gr_message_sink.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_MESSAGE_SINK_H -#define INCLUDED_GR_MESSAGE_SINK_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> -#include <string> - -class gr_message_sink; -typedef boost::shared_ptr<gr_message_sink> gr_message_sink_sptr; - -GR_CORE_API gr_message_sink_sptr gr_make_message_sink ( - size_t itemsize, - gr_msg_queue_sptr msgq, - bool dont_block -); - -GR_CORE_API gr_message_sink_sptr gr_make_message_sink ( - size_t itemsize, - gr_msg_queue_sptr msgq, - bool dont_block, - const std::string& lengthtagname -); - -/*! - * \brief Gather received items into messages and insert into msgq - * \ingroup sink_blk - */ -class GR_CORE_API gr_message_sink : public gr_sync_block -{ - private: - size_t d_itemsize; - gr_msg_queue_sptr d_msgq; - bool d_dont_block; - bool d_tags; - std::string d_lengthtagname; - uint64_t d_items_read; - - friend GR_CORE_API gr_message_sink_sptr - gr_make_message_sink(size_t itemsize, gr_msg_queue_sptr msgq, - bool dont_block); - friend GR_CORE_API gr_message_sink_sptr - gr_make_message_sink(size_t itemsize, gr_msg_queue_sptr msgq, - bool dont_block, const std::string& lengthtagname); - - protected: - gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); - gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, - const std::string& lengthtagname); - - public: - ~gr_message_sink (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_MESSAGE_SINK_H */ diff --git a/gnuradio-core/src/lib/io/gr_message_sink.i b/gnuradio-core/src/lib/io/gr_message_sink.i deleted file mode 100644 index b22eff18c0..0000000000 --- a/gnuradio-core/src/lib/io/gr_message_sink.i +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,message_sink); - -#include <string> - -gr_message_sink_sptr gr_make_message_sink (size_t itemsize, - gr_msg_queue_sptr msgq, - bool dont_block); -gr_message_sink_sptr gr_make_message_sink (size_t itemsize, - gr_msg_queue_sptr msgq, - bool dont_block, - const std::string& lengthtagname); - -class gr_message_sink : public gr_sync_block -{ - protected: - gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); - gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, const std::string& lengthtagname); - - public: - ~gr_message_sink (); -}; diff --git a/gnuradio-core/src/lib/io/gr_message_source.cc b/gnuradio-core/src/lib/io/gr_message_source.cc deleted file mode 100644 index 0b79bb526b..0000000000 --- a/gnuradio-core/src/lib/io/gr_message_source.cc +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_message_source.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> - - -// public constructor that returns a shared_ptr -gr_message_source_sptr -gr_make_message_source(size_t itemsize, int msgq_limit) -{ - return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq_limit)); -} - -// public constructor that takes existing message queue -gr_message_source_sptr -gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq) -{ - return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq)); -} - -// public constructor that takes existing message queue and adds messages length tags. -gr_message_source_sptr -gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname) -{ - return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq, lengthtagname)); -} - -gr_message_source::gr_message_source (size_t itemsize, int msgq_limit) - : gr_sync_block("message_source", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(1, 1, itemsize)), - d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false), - d_tags(false) -{ -} - -gr_message_source::gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq) - : gr_sync_block("message_source", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(1, 1, itemsize)), - d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false), d_tags(false) -{ -} - -gr_message_source::~gr_message_source() -{} - -gr_message_source::gr_message_source(size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname) - : gr_sync_block("message_source", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(1, 1, itemsize)), - d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false), - d_tags(true), d_lengthtagname(lengthtagname) -{ -} - -int -gr_message_source::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - char *out = (char *) output_items[0]; - int nn = 0; - - while (nn < noutput_items){ - if (d_msg){ - // - // Consume whatever we can from the current message - // - int mm = std::min(noutput_items - nn, (int)((d_msg->length() - d_msg_offset) / d_itemsize)); - memcpy (out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize); - - if (d_tags && (d_msg_offset == 0)) { - const uint64_t offset = this->nitems_written(0) + nn; - pmt::pmt_t key = pmt::pmt_string_to_symbol(d_lengthtagname); - pmt::pmt_t value = pmt::pmt_from_long(d_msg->length()); - this->add_item_tag(0, offset, key, value); - } - nn += mm; - out += mm * d_itemsize; - d_msg_offset += mm * d_itemsize; - assert(d_msg_offset <= d_msg->length()); - - if (d_msg_offset == d_msg->length()){ - if (d_msg->type() == 1) // type == 1 sets EOF - d_eof = true; - d_msg.reset(); - } - } - else { - // - // No current message - // - if (d_msgq->empty_p() && nn > 0){ // no more messages in the queue, return what we've got - break; - } - - if (d_eof) - return -1; - - d_msg = d_msgq->delete_head(); // block, waiting for a message - d_msg_offset = 0; - - if ((d_msg->length() % d_itemsize) != 0) - throw std::runtime_error("msg length is not a multiple of d_itemsize"); - } - } - - return nn; -} diff --git a/gnuradio-core/src/lib/io/gr_message_source.h b/gnuradio-core/src/lib/io/gr_message_source.h deleted file mode 100644 index 1828475987..0000000000 --- a/gnuradio-core/src/lib/io/gr_message_source.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_MESSAGE_SOURCE_H -#define INCLUDED_GR_MESSAGE_SOURCE_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> - -class gr_message_source; -typedef boost::shared_ptr<gr_message_source> gr_message_source_sptr; - -GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, int msgq_limit=0); -GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq); -GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq, - const std::string& lengthtagname); - -/*! - * \brief Turn received messages into a stream - * \ingroup source_blk - */ -class GR_CORE_API gr_message_source : public gr_sync_block -{ - private: - size_t d_itemsize; - gr_msg_queue_sptr d_msgq; - gr_message_sptr d_msg; - unsigned d_msg_offset; - bool d_eof; - bool d_tags; - // FIXME: Is this adequate tagname length. - std::string d_lengthtagname; - - friend GR_CORE_API gr_message_source_sptr - gr_make_message_source(size_t itemsize, int msgq_limit); - friend GR_CORE_API gr_message_source_sptr - gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq); - friend GR_CORE_API gr_message_source_sptr - gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname); - - protected: - gr_message_source (size_t itemsize, int msgq_limit); - gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq); - gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname); - - public: - ~gr_message_source (); - - gr_msg_queue_sptr msgq() const { return d_msgq; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_MESSAGE_SOURCE_H */ diff --git a/gnuradio-core/src/lib/io/gr_message_source.i b/gnuradio-core/src/lib/io/gr_message_source.i deleted file mode 100644 index bb1ddfcc31..0000000000 --- a/gnuradio-core/src/lib/io/gr_message_source.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,message_source); - -#include <string> - -gr_message_source_sptr gr_make_message_source (size_t itemsize, int msgq_limit=0); -gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq); -gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname); - -class gr_message_source : public gr_sync_block -{ - protected: - gr_message_source (size_t itemsize, int msgq_limit); - gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq); - gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname); - - public: - ~gr_message_source (); - - gr_msg_queue_sptr msgq() const; -}; diff --git a/gnuradio-core/src/lib/io/gr_pdu.cc b/gnuradio-core/src/lib/io/gr_pdu.cc deleted file mode 100644 index 302fd7b9bb..0000000000 --- a/gnuradio-core/src/lib/io/gr_pdu.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pdu.h> - -size_t -gr_pdu_itemsize(gr_pdu_vector_type type){ - switch(type){ - case pdu_byte: - return 1; - case pdu_float: - return sizeof(float); - case pdu_complex: - return sizeof(gr_complex); - default: - throw std::runtime_error("bad type!"); - } -} - -bool -gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v){ - switch(type){ - case pdu_byte: - return pmt::pmt_is_u8vector(v); - case pdu_float: - return pmt::pmt_is_f32vector(v); - case pdu_complex: - return pmt::pmt_is_c32vector(v); - default: - throw std::runtime_error("bad type!"); - } -} - -pmt::pmt_t -gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items){ - switch(type){ - case pdu_byte: - return pmt::pmt_init_u8vector(items, buf); - case pdu_float: - return pmt::pmt_init_f32vector(items, (const float*)buf); - case pdu_complex: - return pmt::pmt_init_c32vector(items, (const gr_complex*)buf); - default: - throw std::runtime_error("bad type!"); - } -} - -gr_pdu_vector_type type_from_pmt(pmt::pmt_t vector){ - if(pmt_is_u8vector(vector)) - return pdu_byte; - if(pmt_is_f32vector(vector)) - return pdu_float; - if(pmt_is_c32vector(vector)) - return pdu_complex; - throw std::runtime_error("bad type!"); -} diff --git a/gnuradio-core/src/lib/io/gr_pdu.h b/gnuradio-core/src/lib/io/gr_pdu.h deleted file mode 100644 index 53058ccb6c..0000000000 --- a/gnuradio-core/src/lib/io/gr_pdu.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef GR_PDU_H -#define GR_PDU_H - -#include <gr_core_api.h> -#include <gr_complex.h> -#include <gruel/pmt.h> - -#define PDU_PORT_ID pmt::mp("pdus") -#define PDU_LENGTH_TAG pmt::mp("pdu_length") - -enum gr_pdu_vector_type { pdu_byte, pdu_float, pdu_complex }; - -GR_CORE_API size_t gr_pdu_itemsize(gr_pdu_vector_type type); -GR_CORE_API bool gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v); -GR_CORE_API pmt::pmt_t gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items); -GR_CORE_API gr_pdu_vector_type type_from_pmt(pmt::pmt_t vector); - -#endif diff --git a/gnuradio-core/src/lib/io/gr_pdu.i b/gnuradio-core/src/lib/io/gr_pdu.i deleted file mode 100644 index ada3a63a73..0000000000 --- a/gnuradio-core/src/lib/io/gr_pdu.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */
-/*
- * Copyright 2005 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-%{
-#include <gr_pdu.h>
-%}
-
-enum gr_pdu_vector_type { pdu_byte, pdu_float, pdu_complex };
-
-
-
diff --git a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc b/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc deleted file mode 100644 index a702b66a2b..0000000000 --- a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pdu_to_tagged_stream.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> - - -// public constructor that returns a shared_ptr - -gr_pdu_to_tagged_stream_sptr -gr_make_pdu_to_tagged_stream(gr_pdu_vector_type t) -{ - return gnuradio::get_initial_sptr(new gr_pdu_to_tagged_stream(t)); -} - -gr_pdu_to_tagged_stream::gr_pdu_to_tagged_stream (gr_pdu_vector_type t) - : gr_sync_block("pdu_to_tagged_stream", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(1, 1, gr_pdu_itemsize(t))), - d_vectortype(t), d_itemsize(gr_pdu_itemsize(t)) -{ - message_port_register_in(PDU_PORT_ID); -} - -gr_pdu_to_tagged_stream::~gr_pdu_to_tagged_stream() -{ -} - -int -gr_pdu_to_tagged_stream::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - char *out = (char *) output_items[0]; - int nout = 0; - - // if we have remaining output, send it - if(d_remain.size() > 0){ - nout = std::min((size_t)d_remain.size()/d_itemsize, (size_t)noutput_items); - memcpy(out, &d_remain[0], nout*d_itemsize); - d_remain.erase( d_remain.begin(), d_remain.begin()+nout); - noutput_items -= nout; - out += nout*d_itemsize; - } - - // if we have space for at least one item output as much as we can - if(noutput_items > 0){ - - // grab a message if one exists - //pmt::pmt_t msg( delete_head_nowait( PDU_PORT_ID ) ); - pmt::pmt_t msg( delete_head_blocking( PDU_PORT_ID ) ); - if(msg.get() == NULL ){ - return nout; - } - - // make sure type is valid - if(!pmt::pmt_is_pair(msg)){ - throw std::runtime_error("received a malformed pdu message!"); - } - -// printf("got a msg\n"); -// pmt::pmt_print(msg); - - // grab the components of the pdu message - pmt::pmt_t meta(pmt::pmt_car(msg)); // make sure this is NIL || Dict ? - pmt::pmt_t vect(pmt::pmt_cdr(msg)); // make sure this is a vector? - - // compute offset for output tag - uint64_t offset = nitems_written(0) + nout; - - // add a tag for pdu length - add_item_tag(0, offset, PDU_LENGTH_TAG, pmt::pmt_from_long( pmt::pmt_length(vect) ), pmt::mp(alias())); - - // if we recieved metadata add it as tags - if( !pmt_eq(meta, pmt::PMT_NIL) ){ - pmt::pmt_t pair(pmt::pmt_dict_keys( meta )); - while( !pmt_eq(pair, pmt::PMT_NIL) ){ - pmt::pmt_t k(pmt::pmt_cdr(pair)); - pmt::pmt_t v(pmt::pmt_dict_ref(meta, k, pmt::PMT_NIL)); - add_item_tag(0, offset, k, v, pmt::mp(alias())); - } - } - - // copy vector output - size_t ncopy = std::min((size_t)noutput_items, (size_t)pmt::pmt_length(vect)); - size_t nsave = pmt::pmt_length(vect) - ncopy; - - // copy output - size_t io(0); - nout += ncopy; - memcpy(out, pmt_uniform_vector_elements(vect,io), ncopy*d_itemsize); - - // save leftover items if needed for next work call - if(nsave > 0){ - d_remain.resize(nsave*d_itemsize, 0); - memcpy(&d_remain[0], pmt_uniform_vector_elements(vect,ncopy), nsave*d_itemsize); - } - - } - - return nout; -} diff --git a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.h b/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.h deleted file mode 100644 index 3105a3d386..0000000000 --- a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_PDU_TO_TAGGED_STREAM_H -#define INCLUDED_GR_PDU_TO_TAGGED_STREAM_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> -#include <gr_pdu.h> - -class gr_pdu_to_tagged_stream; -typedef boost::shared_ptr<gr_pdu_to_tagged_stream> gr_pdu_to_tagged_stream_sptr; - -GR_CORE_API gr_pdu_to_tagged_stream_sptr gr_make_pdu_to_tagged_stream (gr_pdu_vector_type t); - -/*! - * \brief Turn received messages into a stream - * \ingroup source_blk - */ -class GR_CORE_API gr_pdu_to_tagged_stream : public gr_sync_block -{ - private: - gr_pdu_vector_type d_vectortype; - size_t d_itemsize; - std::vector<uint8_t> d_remain; - - friend GR_CORE_API gr_pdu_to_tagged_stream_sptr - gr_make_pdu_to_tagged_stream(gr_pdu_vector_type t); - - protected: - gr_pdu_to_tagged_stream (gr_pdu_vector_type t); - - public: - ~gr_pdu_to_tagged_stream (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - -#endif /* INCLUDED_GR_PDU_TO_TAGGED_SOURCE_H */ diff --git a/gnuradio-core/src/lib/io/gr_socket_pdu.cc b/gnuradio-core/src/lib/io/gr_socket_pdu.cc deleted file mode 100644 index bb374b3006..0000000000 --- a/gnuradio-core/src/lib/io/gr_socket_pdu.cc +++ /dev/null @@ -1,157 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_socket_pdu.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> -#include <iostream> -#include <gr_pdu.h> -#include <boost/format.hpp> - -// public constructor that returns a shared_ptr -gr_socket_pdu_sptr -gr_make_socket_pdu (std::string type, std::string addr, std::string port, int MTU) -{ - return gnuradio::get_initial_sptr(new gr_socket_pdu(type,addr,port,MTU)); -} - -gr_socket_pdu::gr_socket_pdu (std::string type, std::string addr, std::string port, int MTU) - : gr_stream_pdu_base(MTU) -{ - - if( (type == "TCP_SERVER") || (type == "TCP_CLIENT")){ - boost::asio::ip::tcp::resolver resolver(_io_service); - boost::asio::ip::tcp::resolver::query query(boost::asio::ip::tcp::v4(), addr, port); - _tcp_endpoint = *resolver.resolve(query); - } - if( (type == "UDP_SERVER") || (type == "UDP_CLIENT")){ - boost::asio::ip::udp::resolver resolver(_io_service); - boost::asio::ip::udp::resolver::query query(boost::asio::ip::udp::v4(), addr, port); - if( (type == "UDP_SERVER") ){ - _udp_endpoint = *resolver.resolve(query); - } else { - _udp_endpoint_other = *resolver.resolve(query); - } - } - - // register ports - message_port_register_out(pmt::mp("pdus")); - message_port_register_in(pmt::mp("pdus")); - - // set up socketry - if (type == "TCP_SERVER"){ - _acceptor_tcp.reset(new boost::asio::ip::tcp::acceptor(_io_service, _tcp_endpoint)); - _acceptor_tcp->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); - start_tcp_accept(); - // bind tcp server send handler - set_msg_handler(pmt::mp("pdus"), boost::bind(&gr_socket_pdu::tcp_server_send, this, _1)); - } else if(type =="TCP_CLIENT"){ - boost::system::error_code error = boost::asio::error::host_not_found; - _tcp_socket.reset(new boost::asio::ip::tcp::socket(_io_service)); - _tcp_socket->connect(_tcp_endpoint, error); - if(error){ - throw boost::system::system_error(error); - } - set_msg_handler(pmt::mp("pdus"), boost::bind(&gr_socket_pdu::tcp_client_send, this, _1)); - _tcp_socket->async_read_some( - boost::asio::buffer(rxbuf), - boost::bind(&gr_socket_pdu::handle_tcp_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); - - } else if(type =="UDP_SERVER"){ - _udp_socket.reset(new boost::asio::ip::udp::socket(_io_service, _udp_endpoint)); - _udp_socket->async_receive_from( boost::asio::buffer(rxbuf), _udp_endpoint_other, - boost::bind(&gr_socket_pdu::handle_udp_read, this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); - set_msg_handler(pmt::mp("pdus"), boost::bind(&gr_socket_pdu::udp_send, this, _1)); - } else if(type =="UDP_CLIENT"){ - _udp_socket.reset(new boost::asio::ip::udp::socket(_io_service, _udp_endpoint)); - _udp_socket->async_receive_from( boost::asio::buffer(rxbuf), _udp_endpoint_other, - boost::bind(&gr_socket_pdu::handle_udp_read, this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); - set_msg_handler(pmt::mp("pdus"), boost::bind(&gr_socket_pdu::udp_send, this, _1)); - } else { - throw std::runtime_error("unknown socket type!"); - } - - // start thread for io_service - d_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&gr_socket_pdu::run_io_service, this))); - d_started = true; -} - -void tcp_connection::handle_read(const boost::system::error_code& error/*error*/, size_t bytes_transferred) - { - if(!error) - { - pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t*)&buf[0]); - pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector); - - d_block->message_port_pub( pmt::mp("pdus"), pdu ); - - socket_.async_read_some( - boost::asio::buffer(buf), - boost::bind(&tcp_connection::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); - - } else { - std::cout << "error occurred\n"; - } - - } - - -void gr_socket_pdu::tcp_server_send(pmt::pmt_t msg){ - pmt::pmt_t vector = pmt::pmt_cdr(msg); - for(size_t i=0; i<d_tcp_connections.size(); i++){ - d_tcp_connections[i]->send(vector); - } -} - -void gr_socket_pdu::tcp_client_send(pmt::pmt_t msg){ - pmt::pmt_t vector = pmt::pmt_cdr(msg); - size_t len = pmt::pmt_length(vector); - size_t offset(0); - boost::array<char, 10000> txbuf; - memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len); - _tcp_socket->send(boost::asio::buffer(txbuf,len)); -} - -void gr_socket_pdu::udp_send(pmt::pmt_t msg){ - pmt::pmt_t vector = pmt::pmt_cdr(msg); - size_t len = pmt::pmt_length(vector); - size_t offset(0); - boost::array<char, 10000> txbuf; - memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len); - if(_udp_endpoint_other.address().to_string() != "0.0.0.0") - _udp_socket->send_to(boost::asio::buffer(txbuf,len), _udp_endpoint_other); -} diff --git a/gnuradio-core/src/lib/io/gr_socket_pdu.h b/gnuradio-core/src/lib/io/gr_socket_pdu.h deleted file mode 100644 index 2fedb317db..0000000000 --- a/gnuradio-core/src/lib/io/gr_socket_pdu.h +++ /dev/null @@ -1,203 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SOCKET_PDU_H -#define INCLUDED_GR_SOCKET_PDU_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> -#include <gr_stream_pdu_base.h> -#include <boost/array.hpp> -#include <boost/asio.hpp> -#include <iostream> - -class gr_socket_pdu; -typedef boost::shared_ptr<gr_socket_pdu> gr_socket_pdu_sptr; - -GR_CORE_API gr_socket_pdu_sptr gr_make_socket_pdu (std::string type, std::string addr, std::string port, int MTU=10000); - -class tcp_connection - : public boost::enable_shared_from_this<tcp_connection> -{ -public: - typedef boost::shared_ptr<tcp_connection> pointer; - gr_socket_pdu *d_block; - boost::array<char, 10000> buf; - - static pointer create(boost::asio::io_service& io_service) - { - return pointer(new tcp_connection(io_service)); - } - - boost::asio::ip::tcp::socket& socket() - { - return socket_; - } - - void start(gr_socket_pdu* parent) - { - d_block = parent; -// message_ = "connected to gr_socket_pdu\n"; -// boost::asio::async_write(socket_, boost::asio::buffer(message_), -// boost::bind(&tcp_connection::handle_write, shared_from_this(), -// boost::asio::placeholders::error, -// boost::asio::placeholders::bytes_transferred)); - - socket_.async_read_some( - boost::asio::buffer(buf), - boost::bind(&tcp_connection::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); - } - void send(pmt::pmt_t vector){ - size_t len = pmt::pmt_length(vector); - size_t offset(0); - boost::array<char, 10000> txbuf; - memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len); - boost::asio::async_write(socket_, boost::asio::buffer(txbuf, len), - boost::bind(&tcp_connection::handle_write, shared_from_this(), - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); - } - - ~tcp_connection(){ -// std::cout << "tcp_connection destroyed\n"; - } - -private: - tcp_connection(boost::asio::io_service& io_service) - : socket_(io_service) - { - } - - void handle_read(const boost::system::error_code& error/*error*/, size_t bytes_transferred); - - void handle_write(const boost::system::error_code& /*error*/, - size_t /*bytes_transferred*/) - { - } - - boost::asio::ip::tcp::socket socket_; - std::string message_; -}; - - -/*! - * \brief Gather received items into messages and insert into msgq - * \ingroup sink_blk - */ -class GR_CORE_API gr_socket_pdu : public gr_stream_pdu_base -{ - private: - friend GR_CORE_API gr_socket_pdu_sptr - gr_make_socket_pdu(std::string type, std::string addr, std::string port, int MTU); - - boost::asio::io_service _io_service; - - boost::array<char, 10000> rxbuf; - - // tcp specific - boost::asio::ip::tcp::endpoint _tcp_endpoint; - - // specific to tcp server - boost::shared_ptr<boost::asio::ip::tcp::acceptor> _acceptor_tcp; - std::vector<tcp_connection::pointer> d_tcp_connections; - void tcp_server_send(pmt::pmt_t msg); - void tcp_client_send(pmt::pmt_t msg); - void udp_send(pmt::pmt_t msg); - - // specific to tcp client - boost::shared_ptr<boost::asio::ip::tcp::socket> _tcp_socket; - - // specific to udp client/server - boost::asio::ip::udp::endpoint _udp_endpoint; - boost::asio::ip::udp::endpoint _udp_endpoint_other; - boost::shared_ptr<boost::asio::ip::udp::socket> _udp_socket; - - void handle_receive(const boost::system::error_code& error, std::size_t ){ - } - - void start_tcp_accept(){ - tcp_connection::pointer new_connection = - tcp_connection::create(_acceptor_tcp->get_io_service()); - - _acceptor_tcp->async_accept(new_connection->socket(), - boost::bind(&gr_socket_pdu::handle_tcp_accept, this, new_connection, - boost::asio::placeholders::error)); - } - - void handle_tcp_accept(tcp_connection::pointer new_connection, const boost::system::error_code& error){ - if (!error) - { - new_connection->start(this); - d_tcp_connections.push_back(new_connection); - start_tcp_accept(); - } else { - std::cout << error << std::endl; - } - } - - void run_io_service(){ - _io_service.run(); - } - - void handle_udp_read(const boost::system::error_code& error/*error*/, size_t bytes_transferred){ - if(!error){ - pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t*)&rxbuf[0]); - pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector); - - message_port_pub( pmt::mp("pdus"), pdu ); - - _udp_socket->async_receive_from( boost::asio::buffer(rxbuf), _udp_endpoint_other, - boost::bind(&gr_socket_pdu::handle_udp_read, this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); - } else { - throw boost::system::system_error(error); -// std::cout << "error occurred\n"; - } - } - void handle_tcp_read(const boost::system::error_code& error/*error*/, size_t bytes_transferred){ - if(!error) - { - pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t*)&rxbuf[0]); - pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector); - - message_port_pub( pmt::mp("pdus"), pdu ); - - _tcp_socket->async_read_some( - boost::asio::buffer(rxbuf), - boost::bind(&gr_socket_pdu::handle_tcp_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); - - } else { - //std::cout << "error occurred\n"; - throw boost::system::system_error(error); - } - } - - protected: - gr_socket_pdu (std::string type, std::string addr, std::string port, int MTU=10000); - public: - ~gr_socket_pdu () {} -}; - -#endif /* INCLUDED_GR_TUNTAP_PDU_H */ diff --git a/gnuradio-core/src/lib/io/gr_socket_pdu.i b/gnuradio-core/src/lib/io/gr_socket_pdu.i deleted file mode 100644 index 3e20b63e20..0000000000 --- a/gnuradio-core/src/lib/io/gr_socket_pdu.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,socket_pdu); - -%ignore tcp_connection; - -%{ -#include <gr_socket_pdu.h> -%} - -%include "gr_stream_pdu_base.h" -%include "gr_socket_pdu.h" - diff --git a/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc b/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc deleted file mode 100644 index 7250c33e59..0000000000 --- a/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <ciso646> -#include <gr_stream_pdu_base.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> -#include <iostream> -#include <gr_pdu.h> -#include <boost/asio.hpp> -#include <boost/format.hpp> - -#ifdef HAVE_IO_H -#include <io.h> -#endif - -static const long timeout_us = 100*1000; //100ms - -gr_stream_pdu_base::gr_stream_pdu_base (int MTU) - : gr_sync_block("stream_pdu_base", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(0, 0, 0)), - d_finished(false), d_started(false), d_fd(-1) -{ - // reserve space for rx buffer - d_rxbuf.resize(MTU,0); -} - -gr_stream_pdu_base::~gr_stream_pdu_base() -{ - stop_rxthread(); -} - -void gr_stream_pdu_base::stop_rxthread(){ - d_finished = true; - if(d_started){ - d_thread->interrupt(); - d_thread->join(); - } - } - -void gr_stream_pdu_base::start_rxthread(pmt::pmt_t _rxport){ - rxport = _rxport; - d_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&gr_stream_pdu_base::run, this))); - d_started = true; - } - -void gr_stream_pdu_base::run(){ - while(!d_finished) { - if(not wait_ready()){ continue; } - const int result = read( d_fd, &d_rxbuf[0], d_rxbuf.size() ); - if(result <= 0){ throw std::runtime_error("gr_stream_pdu_base, bad socket read!"); } - pmt::pmt_t vector = pmt::pmt_init_u8vector(result, &d_rxbuf[0]); - pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector); - message_port_pub(rxport, pdu); - } -} - -void gr_stream_pdu_base::send(pmt::pmt_t msg){ - pmt::pmt_t vector = pmt::pmt_cdr(msg); - size_t offset(0); - size_t itemsize(gr_pdu_itemsize(type_from_pmt(vector))); - int len( pmt::pmt_length(vector)*itemsize ); - - const int rv = write(d_fd, pmt::pmt_uniform_vector_elements(vector, offset), len); - if(rv != len){ - std::cerr << boost::format("WARNING: gr_stream_pdu_base::send(pdu) write failed! (d_fd=%d, len=%d, rv=%d)") - % d_fd % len % rv << std::endl; - } -} - -int -gr_stream_pdu_base::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - throw std::runtime_error("should not be called.\n"); - return 0; -} - -bool gr_stream_pdu_base::wait_ready(){ - //setup timeval for timeout - timeval tv; - tv.tv_sec = 0; - tv.tv_usec = timeout_us; - - //setup rset for timeout - fd_set rset; - FD_ZERO(&rset); - FD_SET(d_fd, &rset); - - //call select with timeout on receive socket - return ::select(d_fd+1, &rset, NULL, NULL, &tv) > 0; -} diff --git a/gnuradio-core/src/lib/io/gr_stream_pdu_base.h b/gnuradio-core/src/lib/io/gr_stream_pdu_base.h deleted file mode 100644 index 35bacf523f..0000000000 --- a/gnuradio-core/src/lib/io/gr_stream_pdu_base.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_STREAM_PDU_BASE_H -#define INCLUDED_GR_STREAM_PDU_BASE_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> - -/*! - * \brief Gather received items into messages and insert into msgq - * \ingroup sink_blk - */ -class GR_CORE_API gr_stream_pdu_base : public gr_sync_block -{ - public: - boost::shared_ptr<boost::thread> d_thread; - bool d_finished; - bool d_started; - std::vector<uint8_t> d_rxbuf; - void run(); - int d_fd; - gr_stream_pdu_base (int MTU=10000); - ~gr_stream_pdu_base (); - void send(pmt::pmt_t msg); - bool wait_ready(); - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - void start_rxthread(pmt::pmt_t _rxport); - void stop_rxthread(); - private: - pmt::pmt_t rxport; -}; - -typedef boost::shared_ptr<gr_stream_pdu_base> gr_stream_pdu_base_sptr; - -#endif /* INCLUDED_GR_TUNTAP_PDU_H */ diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc b/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc deleted file mode 100644 index 6d642088e2..0000000000 --- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc +++ /dev/null @@ -1,216 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_tagged_file_sink.h> -#include <gr_io_signature.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <iostream> - -#ifdef HAVE_IO_H -#include <io.h> -#endif - -#ifdef O_BINARY -#define OUR_O_BINARY O_BINARY -#else -#define OUR_O_BINARY 0 -#endif - -// should be handled via configure -#ifdef O_LARGEFILE -#define OUR_O_LARGEFILE O_LARGEFILE -#else -#define OUR_O_LARGEFILE 0 -#endif - - -gr_tagged_file_sink::gr_tagged_file_sink (size_t itemsize, double samp_rate) - : gr_sync_block ("tagged_file_sink", - gr_make_io_signature (1, 1, itemsize), - gr_make_io_signature (0, 0, 0)), - d_itemsize (itemsize), d_n(0), d_sample_rate(samp_rate) -{ - d_state = NOT_IN_BURST; - d_last_N = 0; - d_timeval = 0; -} - -gr_tagged_file_sink_sptr -gr_make_tagged_file_sink (size_t itemsize, double samp_rate) -{ - return gnuradio::get_initial_sptr(new gr_tagged_file_sink (itemsize, samp_rate)); -} - -gr_tagged_file_sink::~gr_tagged_file_sink () -{ -} - -int -gr_tagged_file_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - char *inbuf = (char *) input_items[0]; - - uint64_t start_N = nitems_read(0); - uint64_t end_N = start_N + (uint64_t)(noutput_items); - pmt::pmt_t bkey = pmt::pmt_string_to_symbol("burst"); - //pmt::pmt_t tkey = pmt::pmt_string_to_symbol("time"); // use gr_tags::key_time - - std::vector<gr_tag_t> all_tags; - get_tags_in_range(all_tags, 0, start_N, end_N); - - std::sort(all_tags.begin(), all_tags.end(), gr_tag_t::offset_compare); - - std::vector<gr_tag_t>::iterator vitr = all_tags.begin(); - - int idx = 0, idx_stop = 0; - while(idx < noutput_items) { - if(d_state == NOT_IN_BURST) { - while(vitr != all_tags.end()) { - if((pmt::pmt_eqv((*vitr).key, bkey)) && - pmt::pmt_is_true((*vitr).value)) { - - uint64_t N = (*vitr).offset; - idx = (int)(N - start_N); - - //std::cout << std::endl << "Found start of burst: " - // << idx << ", " << N << std::endl; - - // Find time burst occurred by getting latest time tag and extrapolating - // to new time based on sample rate of this block. - std::vector<gr_tag_t> time_tags; - //get_tags_in_range(time_tags, 0, d_last_N, N, gr_tags::key_time); - get_tags_in_range(time_tags, 0, d_last_N, N, - pmt::pmt_string_to_symbol("time")); - if(time_tags.size() > 0) { - const gr_tag_t tag = time_tags[time_tags.size()-1]; - - uint64_t time_nitems = tag.offset; - - // Get time based on last time tag from USRP - pmt::pmt_t time = tag.value; - int tsecs = pmt::pmt_to_long(pmt::pmt_tuple_ref(time, 0)); - double tfrac = pmt::pmt_to_double(pmt::pmt_tuple_ref(time, 1)); - - // Get new time from last time tag + difference in time to when - // burst tag occured based on the sample rate - double delta = (double)(N - time_nitems) / d_sample_rate; - d_timeval = (double)tsecs + tfrac + delta; - - //std::cout.setf(std::ios::fixed, std::ios::floatfield); - //std::cout.precision(8); - //std::cout << "Time found: " << (double)tsecs + tfrac << std::endl; - //std::cout << " time: " << d_timeval << std::endl; - //std::cout << " time at N = " << time_nitems << " burst N = " << N << std::endl; - } - else { - // if no time tag, use last seen tag and update time based on - // sample rate of the block - d_timeval += (double)(N - d_last_N) / d_sample_rate; - //std::cout << "Time not found" << std::endl; - //std::cout << " time: " << d_timeval << std::endl; - } - d_last_N = N; - - std::stringstream filename; - filename.setf(std::ios::fixed, std::ios::floatfield); - filename.precision(8); - filename << "file" << unique_id() << "_" << d_n << "_" << d_timeval << ".dat"; - d_n++; - - int fd; - if ((fd = ::open (filename.str().c_str(), - O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY, - 0664)) < 0){ - perror (filename.str().c_str()); - return -1; - } - - // FIXME: - //if ((d_handle = fdopen (fd, d_is_binary ? "wb" : "w")) == NULL){ - if ((d_handle = fdopen (fd, "wb")) == NULL){ - perror (filename.str().c_str()); - ::close(fd); // don't leak file descriptor if fdopen fails. - } - - //std::cout << "Created new file: " << filename.str() << std::endl; - - d_state = IN_BURST; - break; - } - - vitr++; - } - if(d_state == NOT_IN_BURST) - return noutput_items; - } - else { // In burst - while(vitr != all_tags.end()) { - if((pmt::pmt_eqv((*vitr).key, bkey)) && - pmt::pmt_is_false((*vitr).value)) { - uint64_t N = (*vitr).offset; - idx_stop = (int)N - start_N; - - //std::cout << "Found end of burst: " - // << idx_stop << ", " << N << std::endl; - - int count = fwrite (&inbuf[d_itemsize*idx], d_itemsize, - idx_stop-idx, d_handle); - if (count == 0) { - if(ferror(d_handle)) { - perror("gr_tagged_file_sink: error writing file"); - } - } - idx = idx_stop; - d_state = NOT_IN_BURST; - vitr++; - fclose(d_handle); - break; - } - else { - vitr++; - } - } - if(d_state == IN_BURST) { - int count = fwrite (&inbuf[d_itemsize*idx], d_itemsize, - noutput_items-idx, d_handle); - if (count == 0) { - if(ferror(d_handle)) { - perror("gr_tagged_file_sink: error writing file"); - } - } - idx = noutput_items; - } - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.h b/gnuradio-core/src/lib/io/gr_tagged_file_sink.h deleted file mode 100644 index d6f931a677..0000000000 --- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_TAGGED_FILE_SINK_H -#define INCLUDED_GR_TAGGED_FILE_SINK_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <cstdio> // for FILE - -class gr_tagged_file_sink; -typedef boost::shared_ptr<gr_tagged_file_sink> gr_tagged_file_sink_sptr; - -GR_CORE_API gr_tagged_file_sink_sptr gr_make_tagged_file_sink (size_t itemsize, - double samp_rate); - -/*! - * \brief Write stream to file descriptor. - * \ingroup sink_blk - */ - -class GR_CORE_API gr_tagged_file_sink : public gr_sync_block -{ - friend GR_CORE_API gr_tagged_file_sink_sptr gr_make_tagged_file_sink (size_t itemsize, - double samp_rate); - - private: - enum { - NOT_IN_BURST = 0, - IN_BURST - }; - - size_t d_itemsize; - int d_state; - FILE *d_handle; - int d_n; - double d_sample_rate; - uint64_t d_last_N; - double d_timeval; - - protected: - gr_tagged_file_sink (size_t itemsize, double samp_rate); - - public: - ~gr_tagged_file_sink (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_TAGGED_FILE_SINK_H */ diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.i b/gnuradio-core/src/lib/io/gr_tagged_file_sink.i deleted file mode 100644 index 2f2596e122..0000000000 --- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,tagged_file_sink) - -gr_tagged_file_sink_sptr -gr_make_tagged_file_sink (size_t itemsize, double samp_rate); - -class gr_tagged_file_sink : public gr_sync_block -{ - protected: - gr_tagged_file_sink (size_t itemsize, double samp_rate); - - public: - ~gr_tagged_file_sink (); -}; diff --git a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc deleted file mode 100644 index 1b869edfab..0000000000 --- a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_tagged_stream_to_pdu.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> - -// public constructor that returns a shared_ptr - -gr_tagged_stream_to_pdu_sptr -gr_make_tagged_stream_to_pdu(gr_pdu_vector_type t) -{ - return gnuradio::get_initial_sptr(new gr_tagged_stream_to_pdu(t)); -} - -gr_tagged_stream_to_pdu::gr_tagged_stream_to_pdu (gr_pdu_vector_type t) - : gr_sync_block("tagged_stream_to_pdu", - gr_make_io_signature(1, 1, gr_pdu_itemsize(t)), - gr_make_io_signature(0, 0, 0)), - d_vectortype(t), d_itemsize(gr_pdu_itemsize(t)), d_inpdu(false), - d_pdu_meta(pmt::PMT_NIL), d_pdu_vector(pmt::PMT_NIL) -{ - message_port_register_out(PDU_PORT_ID); -} - -gr_tagged_stream_to_pdu::~gr_tagged_stream_to_pdu() -{ - printf("destructor running\n"); -} - -int -gr_tagged_stream_to_pdu::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const uint8_t *in = (const uint8_t*) input_items[0]; - uint64_t abs_N = nitems_read(0); - - // if we are not in a pdu already, start a new one - if(!d_inpdu){ - get_tags_in_range(d_tags, 0, abs_N, abs_N+1); - bool found_length_tag(false); - for(d_tags_itr = d_tags.begin(); (d_tags_itr != d_tags.end()) && (!found_length_tag); d_tags_itr++){ - if( pmt::pmt_equal( (*d_tags_itr).key, PDU_LENGTH_TAG ) ){ - if( (*d_tags_itr).offset != abs_N ){ - throw std::runtime_error("expected next pdu length tag on a different item..."); - } - found_length_tag = true; - d_pdu_length = pmt::pmt_to_long( (*d_tags_itr).value ); - d_pdu_remain = d_pdu_length; - d_pdu_meta = pmt::pmt_make_dict(); - break; - } // if have length tag - } // iter over tags - if(!found_length_tag){ - throw std::runtime_error("tagged stream does not contain a pdu_length tag!"); - } - } - - size_t ncopy = std::min((size_t)noutput_items, d_pdu_remain); - - // copy any tags in this range into our meta object - get_tags_in_range(d_tags, 0, abs_N, abs_N+ncopy); - for(d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++){ - if( ! pmt_equal( (*d_tags_itr).key, PDU_LENGTH_TAG ) ){ - d_pdu_meta = pmt_dict_add(d_pdu_meta, (*d_tags_itr).key, (*d_tags_itr).value); - } - } - - // copy samples for this vector into either a pmt or our save buffer - if(ncopy == d_pdu_remain){ // we will send this pdu - if(d_save.size() == 0){ - d_pdu_vector = gr_pdu_make_vector(d_vectortype, in, ncopy); - send_message(); - } else { - size_t oldsize = d_save.size(); - d_save.resize((oldsize + ncopy)*d_itemsize, 0); - memcpy( &d_save[oldsize*d_itemsize], in, ncopy*d_itemsize ); - d_pdu_vector = gr_pdu_make_vector(d_vectortype, &d_save[0], d_pdu_length); - send_message(); - d_save.clear(); - } - } else { - d_inpdu = true; - size_t oldsize = d_save.size(); - d_save.resize( (oldsize+ncopy)*d_itemsize ); - memcpy( &d_save[oldsize*d_itemsize], in, ncopy*d_itemsize ); - d_pdu_remain -= ncopy; - } - - return ncopy; -} - -void gr_tagged_stream_to_pdu::send_message(){ - - if(pmt::pmt_length(d_pdu_vector) != d_pdu_length){ - throw std::runtime_error("msg length not correct"); - } - - pmt::pmt_t msg = pmt::pmt_cons( d_pdu_meta, d_pdu_vector ); - message_port_pub( PDU_PORT_ID, msg ); - - d_pdu_meta = pmt::PMT_NIL; - d_pdu_vector = pmt::PMT_NIL; - d_pdu_length = 0; - d_pdu_remain = 0; - d_inpdu = false; -} diff --git a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.h b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.h deleted file mode 100644 index c3fff35815..0000000000 --- a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_TAGGED_STREAM_TO_PDU_H -#define INCLUDED_GR_TAGGED_STREAM_TO_PDU_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> -#include <gr_pdu.h> - -class gr_tagged_stream_to_pdu; -typedef boost::shared_ptr<gr_tagged_stream_to_pdu> gr_tagged_stream_to_pdu_sptr; - -GR_CORE_API gr_tagged_stream_to_pdu_sptr gr_make_tagged_stream_to_pdu (gr_pdu_vector_type t); - -/*! - * \brief Turn received messages into a stream - * \ingroup source_blk - */ -class GR_CORE_API gr_tagged_stream_to_pdu : public gr_sync_block -{ - private: - gr_pdu_vector_type d_vectortype; - size_t d_itemsize; - - std::vector<uint8_t> d_save; - - std::vector<gr_tag_t> d_tags; - std::vector<gr_tag_t>::iterator d_tags_itr; - - bool d_inpdu; - - size_t d_pdu_length; - size_t d_pdu_remain; - pmt::pmt_t d_pdu_meta; - pmt::pmt_t d_pdu_vector; - - friend GR_CORE_API gr_tagged_stream_to_pdu_sptr - gr_make_tagged_stream_to_pdu(gr_pdu_vector_type t); - - protected: - gr_tagged_stream_to_pdu (gr_pdu_vector_type t); - - public: - ~gr_tagged_stream_to_pdu (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void send_message(); - -}; - -#endif /* INCLUDED_GR_PDU_TO_TAGGED_SOURCE_H */ diff --git a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.i b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.i deleted file mode 100644 index f12987b74c..0000000000 --- a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,tagged_stream_to_pdu); - -%{ -#include <gr_tagged_stream_to_pdu.h> -%} - -%include <gr_tagged_stream_to_pdu.h> - - diff --git a/gnuradio-core/src/lib/io/gr_tuntap_pdu.cc b/gnuradio-core/src/lib/io/gr_tuntap_pdu.cc deleted file mode 100644 index 8dd4b18a10..0000000000 --- a/gnuradio-core/src/lib/io/gr_tuntap_pdu.cc +++ /dev/null @@ -1,145 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_tuntap_pdu.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> -#include <iostream> -#include <gr_pdu.h> -#include <boost/format.hpp> - -#if (defined(linux) || defined(__linux) || defined(__linux__)) - -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -#include <arpa/inet.h> -#include <linux/if.h> - - -// public constructor that returns a shared_ptr - -gr_tuntap_pdu_sptr -gr_make_tuntap_pdu (std::string dev, int MTU) -{ - return gnuradio::get_initial_sptr(new gr_tuntap_pdu(dev, MTU)); -} - -gr_tuntap_pdu::gr_tuntap_pdu (std::string dev, int MTU) - : gr_stream_pdu_base(MTU) -{ - - // make the tuntap - char dev_cstr[1024]; - memset(dev_cstr, 0x00, 1024); - strncpy(dev_cstr, dev.c_str(), std::min(sizeof(dev_cstr), dev.size())); - d_fd = tun_alloc(dev_cstr); - if(d_fd <= 0){ - throw std::runtime_error("TunTap make: tun_alloc failed (are you running as root?)"); - } - - std::cout << boost::format( - "Allocated virtual ethernet interface: %s\n" - "You must now use ifconfig to set its IP address. E.g.,\n" - " $ sudo ifconfig %s 192.168.200.1\n" - "Be sure to use a different address in the same subnet for each machine.\n" - ) % dev % dev << std::endl; - - // set up output message port - message_port_register_out(pmt::mp("pdus")); - start_rxthread(pmt::mp("pdus")); - - // set up input message port - message_port_register_in(pmt::mp("pdus")); - set_msg_handler(pmt::mp("pdus"), boost::bind(&gr_tuntap_pdu::send, this, _1)); -} - - -int gr_tuntap_pdu::tun_alloc(char *dev, int flags) { - struct ifreq ifr; - int fd, err; - const char *clonedev = "/dev/net/tun"; - - /* Arguments taken by the function: - * - * char *dev: the name of an interface (or '\0'). MUST have enough - * space to hold the interface name if '\0' is passed - * int flags: interface flags (eg, IFF_TUN etc.) - */ - - /* open the clone device */ - if( (fd = open(clonedev, O_RDWR)) < 0 ) { - return fd; - } - - /* preparation of the struct ifr, of type "struct ifreq" */ - memset(&ifr, 0, sizeof(ifr)); - - ifr.ifr_flags = flags; /* IFF_TUN or IFF_TAP, plus maybe IFF_NO_PI */ - - if (*dev) { - /* if a device name was specified, put it in the structure; otherwise, - * the kernel will try to allocate the "next" device of the - * specified type */ - strncpy(ifr.ifr_name, dev, IFNAMSIZ); - } - - /* try to create the device */ - if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ) { - close(fd); - return err; - } - - /* if the operation was successful, write back the name of the - * interface to the variable "dev", so the caller can know - * it. Note that the caller MUST reserve space in *dev (see calling - * code below) */ - strcpy(dev, ifr.ifr_name); - - /* this is the special file descriptor that the caller will use to talk - * with the virtual interface */ - return fd; -} - -#else //if not linux - -gr_block_sptr -gr_make_tuntap_pdu(std::string dev, int MTU) -{ - gr_block_sptr rv; - throw std::runtime_error("tuntap only implemented on linux"); - return rv; -} - -#endif diff --git a/gnuradio-core/src/lib/io/gr_tuntap_pdu.h b/gnuradio-core/src/lib/io/gr_tuntap_pdu.h deleted file mode 100644 index 18c83f42b2..0000000000 --- a/gnuradio-core/src/lib/io/gr_tuntap_pdu.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_TUNTAP_PDU_H -#define INCLUDED_GR_TUNTAP_PDU_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> -#include <gr_stream_pdu_base.h> - -#if (defined(linux) || defined(__linux) || defined(__linux__)) - -#include <linux/if_tun.h> - -class gr_tuntap_pdu; -typedef boost::shared_ptr<gr_tuntap_pdu> gr_tuntap_pdu_sptr; - -GR_CORE_API gr_tuntap_pdu_sptr gr_make_tuntap_pdu (std::string dev, int MTU=10000); - -/*! - * \brief Gather received items into messages and insert into msgq - * \ingroup sink_blk - */ -class GR_CORE_API gr_tuntap_pdu : public gr_stream_pdu_base -{ - private: - friend GR_CORE_API gr_tuntap_pdu_sptr - gr_make_tuntap_pdu(std::string dev, int MTU); - int tun_alloc(char* dev, int flags = IFF_TAP | IFF_NO_PI); - std::string d_dev; - protected: - gr_tuntap_pdu (std::string dev, int MTU=10000); - - public: - ~gr_tuntap_pdu () {} - -}; - -#else // if not linux - -class gr_tuntap_pdu -{ -private: - gr_tuntap_pdu() {}; -public: - ~gr_tuntap_pdu() {}; -}; - -GR_CORE_API gr_block_sptr gr_make_tuntap_pdu (std::string dev, int MTU=0); - -#endif - -#endif /* INCLUDED_GR_TUNTAP_PDU_H */ diff --git a/gnuradio-core/src/lib/io/gr_tuntap_pdu.i b/gnuradio-core/src/lib/io/gr_tuntap_pdu.i deleted file mode 100644 index 589bbc3853..0000000000 --- a/gnuradio-core/src/lib/io/gr_tuntap_pdu.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,tuntap_pdu); - -%{ -#include <gr_tuntap_pdu.h> -%} - -%include "gr_tuntap_pdu.h" - diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.cc b/gnuradio-core/src/lib/io/gr_udp_sink.cc deleted file mode 100644 index 6b1d34ef7e..0000000000 --- a/gnuradio-core/src/lib/io/gr_udp_sink.cc +++ /dev/null @@ -1,304 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <boost/asio.hpp> - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <gr_udp_sink.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <errno.h> -#include <stdio.h> -#include <string.h> -#if defined(HAVE_NETDB_H) -#include <netdb.h> -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> //usually included by <netdb.h>? -#endif -typedef void* optval_t; -#elif defined(HAVE_WINDOWS_H) -// if not posix, assume winsock -#define USING_WINSOCK -#include <winsock2.h> -#include <ws2tcpip.h> -#define SHUT_RDWR 2 -typedef char* optval_t; -#endif - -#include <gruel/thread.h> - -#define SNK_VERBOSE 0 - -static int is_error( int perr ) -{ - // Compare error to posix error code; return nonzero if match. -#if defined(USING_WINSOCK) -#define ENOPROTOOPT 109 -#define ECONNREFUSED 111 - // All codes to be checked for must be defined below - int werr = WSAGetLastError(); - switch( werr ) { - case WSAETIMEDOUT: - return( perr == EAGAIN ); - case WSAENOPROTOOPT: - return( perr == ENOPROTOOPT ); - case WSAECONNREFUSED: - return( perr == ECONNREFUSED ); - default: - fprintf(stderr,"gr_udp_source/is_error: unknown error %d\n", perr ); - throw std::runtime_error("internal error"); - } - return 0; -#else - return( perr == errno ); -#endif -} - -static void report_error( const char *msg1, const char *msg2 ) -{ - // Deal with errors, both posix and winsock -#if defined(USING_WINSOCK) - int werr = WSAGetLastError(); - fprintf(stderr, "%s: winsock error %d\n", msg1, werr ); -#else - perror(msg1); -#endif - if( msg2 != NULL ) - throw std::runtime_error(msg2); - return; -} - -gr_udp_sink::gr_udp_sink (size_t itemsize, - const char *host, unsigned short port, - int payload_size, bool eof) - : gr_sync_block ("udp_sink", - gr_make_io_signature (1, 1, itemsize), - gr_make_io_signature (0, 0, 0)), - d_itemsize (itemsize), d_payload_size(payload_size), d_eof(eof), - d_socket(-1), d_connected(false) -{ -#if defined(USING_WINSOCK) // for Windows (with MinGW) - // initialize winsock DLL - WSADATA wsaData; - int iResult = WSAStartup( MAKEWORD(2,2), &wsaData ); - if( iResult != NO_ERROR ) { - report_error( "gr_udp_source WSAStartup", "can't open socket" ); - } -#endif - - // create socket - d_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if(d_socket == -1) { - report_error("socket open","can't open socket"); - } - - // Don't wait when shutting down - linger lngr; - lngr.l_onoff = 1; - lngr.l_linger = 0; - if(setsockopt(d_socket, SOL_SOCKET, SO_LINGER, (optval_t)&lngr, sizeof(linger)) == -1) { - if( !is_error(ENOPROTOOPT) ) { // no SO_LINGER for SOCK_DGRAM on Windows - report_error("SO_LINGER","can't set socket option SO_LINGER"); - } - } - - // Get the destination address - connect(host, port); -} - -// public constructor that returns a shared_ptr - -gr_udp_sink_sptr -gr_make_udp_sink (size_t itemsize, - const char *host, unsigned short port, - int payload_size, bool eof) -{ - return gnuradio::get_initial_sptr(new gr_udp_sink (itemsize, - host, port, - payload_size, eof)); -} - -gr_udp_sink::~gr_udp_sink () -{ - if (d_connected) - disconnect(); - - if (d_socket != -1){ - shutdown(d_socket, SHUT_RDWR); -#if defined(USING_WINSOCK) - closesocket(d_socket); -#else - ::close(d_socket); -#endif - d_socket = -1; - } - -#if defined(USING_WINSOCK) // for Windows (with MinGW) - // free winsock resources - WSACleanup(); -#endif -} - -int -gr_udp_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *in = (const char *) input_items[0]; - ssize_t r=0, bytes_sent=0, bytes_to_send=0; - ssize_t total_size = noutput_items*d_itemsize; - - #if SNK_VERBOSE - printf("Entered udp_sink\n"); - #endif - - gruel::scoped_lock guard(d_mutex); // protect d_socket - - while(bytes_sent < total_size) { - bytes_to_send = std::min((ssize_t)d_payload_size, (total_size-bytes_sent)); - - if(d_connected) { - r = send(d_socket, (in+bytes_sent), bytes_to_send, 0); - if(r == -1) { // error on send command - if( is_error(ECONNREFUSED) ) - r = bytes_to_send; // discard data until receiver is started - else { - report_error("udp_sink",NULL); // there should be no error case where - return -1; // this function should not exit immediately - } - } - } - else - r = bytes_to_send; // discarded for lack of connection - bytes_sent += r; - - #if SNK_VERBOSE - printf("\tbyte sent: %d bytes\n", r); - #endif - } - - #if SNK_VERBOSE - printf("Sent: %d bytes (noutput_items: %d)\n", bytes_sent, noutput_items); - #endif - - return noutput_items; -} - -void gr_udp_sink::connect( const char *host, unsigned short port ) -{ - if(d_connected) - disconnect(); - - if(host != NULL ) { - // Get the destination address - struct addrinfo *ip_dst; - struct addrinfo hints; - memset( (void*)&hints, 0, sizeof(hints) ); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_protocol = IPPROTO_UDP; - char port_str[12]; - sprintf( port_str, "%d", port ); - - // FIXME leaks if report_error throws below - int ret = getaddrinfo( host, port_str, &hints, &ip_dst ); - if( ret != 0 ) - report_error("gr_udp_source/getaddrinfo", - "can't initialize destination socket" ); - - // don't need d_mutex lock when !d_connected - if(::connect(d_socket, ip_dst->ai_addr, ip_dst->ai_addrlen) == -1) { - report_error("socket connect","can't connect to socket"); - } - d_connected = true; - - freeaddrinfo(ip_dst); - } - - return; -} - -void gr_udp_sink::disconnect() -{ - if(!d_connected) - return; - - #if SNK_VERBOSE - printf("gr_udp_sink disconnecting\n"); - #endif - - gruel::scoped_lock guard(d_mutex); // protect d_socket from work() - - // Send a few zero-length packets to signal receiver we are done - if(d_eof) { - int i; - for( i = 0; i < 3; i++ ) - (void) send( d_socket, NULL, 0, 0 ); // ignore errors - } - - // Sending EOF can produce ERRCONNREFUSED errors that won't show up - // until the next send or recv, which might confuse us if it happens - // on a new connection. The following does a nonblocking recv to - // clear any such errors. - timeval timeout; - timeout.tv_sec = 0; // zero time for immediate return - timeout.tv_usec = 0; - fd_set readfds; - FD_ZERO(&readfds); - FD_SET(d_socket, &readfds); - int r = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout); - if(r < 0) { - #if SNK_VERBOSE - report_error("udp_sink/select",NULL); - #endif - } - else if(r > 0) { // call recv() to get error return - r = recv(d_socket, (char*)&readfds, sizeof(readfds), 0); - if(r < 0) { - #if SNK_VERBOSE - report_error("udp_sink/recv",NULL); - #endif - } - } - - // Since I can't find any way to disconnect a datagram socket in Cygwin, - // we just leave it connected but disable sending. -#if 0 - // zeroed address structure should reset connection - struct sockaddr addr; - memset( (void*)&addr, 0, sizeof(addr) ); - // addr.sa_family = AF_UNSPEC; // doesn't work on Cygwin - // addr.sa_family = AF_INET; // doesn't work on Cygwin - - if(::connect(d_socket, &addr, sizeof(addr)) == -1) - report_error("socket connect","can't connect to socket"); -#endif - - d_connected = false; - - return; -} diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.h b/gnuradio-core/src/lib/io/gr_udp_sink.h deleted file mode 100644 index bf042a6d12..0000000000 --- a/gnuradio-core/src/lib/io/gr_udp_sink.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_UDP_SINK_H -#define INCLUDED_GR_UDP_SINK_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gruel/thread.h> - -class gr_udp_sink; -typedef boost::shared_ptr<gr_udp_sink> gr_udp_sink_sptr; - -GR_CORE_API gr_udp_sink_sptr -gr_make_udp_sink (size_t itemsize, - const char *host, unsigned short port, - int payload_size=1472, bool eof=true); - -/*! - * \brief Write stream to an UDP socket. - * \ingroup sink_blk - * - * \param itemsize The size (in bytes) of the item datatype - * \param host The name or IP address of the receiving host; use - * NULL or None for no connection - * \param port Destination port to connect to on receiving host - * \param payload_size UDP payload size by default set to 1472 = - * (1500 MTU - (8 byte UDP header) - (20 byte IP header)) - * \param eof Send zero-length packet on disconnect - */ - -class GR_CORE_API gr_udp_sink : public gr_sync_block -{ - friend GR_CORE_API gr_udp_sink_sptr gr_make_udp_sink (size_t itemsize, - const char *host, - unsigned short port, - int payload_size, bool eof); - private: - size_t d_itemsize; - - int d_payload_size; // maximum transmission unit (packet length) - bool d_eof; // send zero-length packet on disconnect - int d_socket; // handle to socket - bool d_connected; // are we connected? - gruel::mutex d_mutex; // protects d_socket and d_connected - - protected: - /*! - * \brief UDP Sink Constructor - * - * \param itemsize The size (in bytes) of the item datatype - * \param host The name or IP address of the receiving host; use - * NULL or None for no connection - * \param port Destination port to connect to on receiving host - * \param payload_size UDP payload size by default set to - * 1472 = (1500 MTU - (8 byte UDP header) - (20 byte IP header)) - * \param eof Send zero-length packet on disconnect - */ - gr_udp_sink (size_t itemsize, - const char *host, unsigned short port, - int payload_size, bool eof); - - public: - ~gr_udp_sink (); - - /*! \brief return the PAYLOAD_SIZE of the socket */ - int payload_size() { return d_payload_size; } - - /*! \brief Change the connection to a new destination - * - * \param host The name or IP address of the receiving host; use - * NULL or None to break the connection without closing - * \param port Destination port to connect to on receiving host - * - * Calls disconnect() to terminate any current connection first. - */ - void connect( const char *host, unsigned short port ); - - /*! \brief Send zero-length packet (if eof is requested) then stop sending - * - * Zero-byte packets can be interpreted as EOF by gr_udp_source. Note that - * disconnect occurs automatically when the sink is destroyed, but not when - * its top_block stops.*/ - void disconnect(); - - // should we export anything else? - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_UDP_SINK_H */ diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.i b/gnuradio-core/src/lib/io/gr_udp_sink.i deleted file mode 100644 index ba7043937a..0000000000 --- a/gnuradio-core/src/lib/io/gr_udp_sink.i +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -GR_SWIG_BLOCK_MAGIC(gr,udp_sink) - -gr_udp_sink_sptr -gr_make_udp_sink (size_t itemsize, - const char *host, unsigned short port, - int payload_size=1472, bool eof=true) throw (std::runtime_error); - -class gr_udp_sink : public gr_sync_block -{ - protected: - gr_udp_sink (size_t itemsize, - const char *host, unsigned short port, - int payload_size, bool eof) - throw (std::runtime_error); - - public: - ~gr_udp_sink (); - - int payload_size() { return d_payload_size; } - void connect( const char *host, unsigned short port ); - void disconnect(); - -}; diff --git a/gnuradio-core/src/lib/io/gr_udp_source.cc b/gnuradio-core/src/lib/io/gr_udp_source.cc deleted file mode 100644 index eca8e89d01..0000000000 --- a/gnuradio-core/src/lib/io/gr_udp_source.cc +++ /dev/null @@ -1,374 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <gr_udp_source.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <errno.h> -#include <stdio.h> -#include <string.h> - -#if defined(HAVE_NETDB_H) -#include <netdb.h> -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif -typedef void* optval_t; - -// ntohs() on FreeBSD may require both netinet/in.h and arpa/inet.h, in order -#if defined(HAVE_NETINET_IN_H) -#include <netinet/in.h> -#endif -#if defined(HAVE_ARPA_INET_H) -#include <arpa/inet.h> -#endif - -#elif defined(HAVE_WINDOWS_H) -// if not posix, assume winsock -#define USING_WINSOCK -#include <winsock2.h> -#include <ws2tcpip.h> -#define SHUT_RDWR 2 -typedef char* optval_t; -#endif - -#define USE_SELECT 1 // non-blocking receive on all platforms -#define USE_RCV_TIMEO 0 // non-blocking receive on all but Cygwin -#define SRC_VERBOSE 0 - -static int is_error( int perr ) -{ - // Compare error to posix error code; return nonzero if match. -#if defined(USING_WINSOCK) -#define ENOPROTOOPT 109 - // All codes to be checked for must be defined below - int werr = WSAGetLastError(); - switch( werr ) { - case WSAETIMEDOUT: - return( perr == EAGAIN ); - case WSAENOPROTOOPT: - return( perr == ENOPROTOOPT ); - default: - fprintf(stderr,"gr_udp_source/is_error: unknown error %d\n", perr ); - throw std::runtime_error("internal error"); - } - return 0; -#else - return( perr == errno ); -#endif -} - -static void report_error( const char *msg1, const char *msg2 ) -{ - // Deal with errors, both posix and winsock -#if defined(USING_WINSOCK) - int werr = WSAGetLastError(); - fprintf(stderr, "%s: winsock error %d\n", msg1, werr ); -#else - perror(msg1); -#endif - if( msg2 != NULL ) - throw std::runtime_error(msg2); - return; -} - -gr_udp_source::gr_udp_source(size_t itemsize, const char *host, - unsigned short port, int payload_size, - bool eof, bool wait) - : gr_sync_block ("udp_source", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(1, 1, itemsize)), - d_itemsize(itemsize), d_payload_size(payload_size), - d_eof(eof), d_wait(wait), d_socket(-1), d_residual(0), d_temp_offset(0) -{ - int ret = 0; - -#if defined(USING_WINSOCK) // for Windows (with MinGW) - // initialize winsock DLL - WSADATA wsaData; - int iResult = WSAStartup( MAKEWORD(2,2), &wsaData ); - if( iResult != NO_ERROR ) { - report_error( "gr_udp_source WSAStartup", "can't open socket" ); - } -#endif - - // Set up the address stucture for the source address and port numbers - // Get the source IP address from the host name - struct addrinfo *ip_src; // store the source IP address to use - struct addrinfo hints; - memset( (void*)&hints, 0, sizeof(hints) ); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_protocol = IPPROTO_UDP; - hints.ai_flags = AI_PASSIVE; - char port_str[12]; - sprintf( port_str, "%d", port ); - - // FIXME leaks if report_error throws below - ret = getaddrinfo( host, port_str, &hints, &ip_src ); - if( ret != 0 ) - report_error("gr_udp_source/getaddrinfo", - "can't initialize source socket" ); - - // FIXME leaks if report_error throws below - d_temp_buff = new char[d_payload_size]; // allow it to hold up to payload_size bytes - - // create socket - d_socket = socket(ip_src->ai_family, ip_src->ai_socktype, - ip_src->ai_protocol); - if(d_socket == -1) { - report_error("socket open","can't open socket"); - } - - // Turn on reuse address - int opt_val = 1; - if(setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, (optval_t)&opt_val, sizeof(int)) == -1) { - report_error("SO_REUSEADDR","can't set socket option SO_REUSEADDR"); - } - - // Don't wait when shutting down - linger lngr; - lngr.l_onoff = 1; - lngr.l_linger = 0; - if(setsockopt(d_socket, SOL_SOCKET, SO_LINGER, (optval_t)&lngr, sizeof(linger)) == -1) { - if( !is_error(ENOPROTOOPT) ) { // no SO_LINGER for SOCK_DGRAM on Windows - report_error("SO_LINGER","can't set socket option SO_LINGER"); - } - } - -#if USE_RCV_TIMEO - // Set a timeout on the receive function to not block indefinitely - // This value can (and probably should) be changed - // Ignored on Cygwin -#if defined(USING_WINSOCK) - DWORD timeout = 1000; // milliseconds -#else - timeval timeout; - timeout.tv_sec = 1; - timeout.tv_usec = 0; -#endif - if(setsockopt(d_socket, SOL_SOCKET, SO_RCVTIMEO, (optval_t)&timeout, sizeof(timeout)) == -1) { - report_error("SO_RCVTIMEO","can't set socket option SO_RCVTIMEO"); - } -#endif // USE_RCV_TIMEO - - // bind socket to an address and port number to listen on - if(bind (d_socket, ip_src->ai_addr, ip_src->ai_addrlen) == -1) { - report_error("socket bind","can't bind socket"); - } - freeaddrinfo(ip_src); - -} - -gr_udp_source_sptr -gr_make_udp_source (size_t itemsize, const char *ipaddr, - unsigned short port, int payload_size, bool eof, bool wait) -{ - return gnuradio::get_initial_sptr(new gr_udp_source (itemsize, ipaddr, - port, payload_size, eof, wait)); -} - -gr_udp_source::~gr_udp_source () -{ - delete [] d_temp_buff; - - if (d_socket != -1){ - shutdown(d_socket, SHUT_RDWR); -#if defined(USING_WINSOCK) - closesocket(d_socket); -#else - ::close(d_socket); -#endif - d_socket = -1; - } - -#if defined(USING_WINSOCK) // for Windows (with MinGW) - // free winsock resources - WSACleanup(); -#endif -} - -int -gr_udp_source::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - char *out = (char *) output_items[0]; - ssize_t r=0, nbytes=0, bytes_received=0; - ssize_t total_bytes = (ssize_t)(d_itemsize*noutput_items); - - #if SRC_VERBOSE - printf("\nEntered udp_source\n"); - #endif - - // Remove items from temp buffer if they are in there - if(d_residual) { - nbytes = std::min(d_residual, total_bytes); - memcpy(out, d_temp_buff+d_temp_offset, nbytes); - bytes_received = nbytes; - - #if SRC_VERBOSE - printf("\tTemp buff size: %d offset: %d (bytes_received: %d) (noutput_items: %d)\n", - d_residual, d_temp_offset, bytes_received, noutput_items); - #endif - - // Increment pointer - out += bytes_received; - - // Update indexing of amount of bytes left in the buffer - d_residual -= nbytes; - d_temp_offset += nbytes; - - // Return now with what we've got. - assert(nbytes % d_itemsize == 0); - return nbytes/d_itemsize; - } - - while(1) { - // get the data into our output buffer and record the number of bytes - -#if USE_SELECT - // RCV_TIMEO doesn't work on all systems (e.g., Cygwin) - // use select() instead of, or in addition to RCV_TIMEO - fd_set readfds; - timeval timeout; - timeout.tv_sec = 1; // Init timeout each iteration. Select can modify it. - timeout.tv_usec = 0; - FD_ZERO(&readfds); - FD_SET(d_socket, &readfds); - r = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout); - if(r < 0) { - report_error("udp_source/select",NULL); - return -1; - } - else if(r == 0 ) { // timed out - if( d_wait ) { - // Allow boost thread interrupt, then try again - //boost::this_thread::interruption_point(); - //continue; - return 0; - } - else - return -1; - } -#endif // USE_SELECT - - // This is a non-blocking call with a timeout set in the constructor - r = recv(d_socket, d_temp_buff, d_payload_size, 0); // get the entire payload or the what's available - - // If r > 0, round it down to a multiple of d_itemsize - // (If sender is broken, don't propagate problem) - if (r > 0) - r = (r/d_itemsize) * d_itemsize; - - // Check if there was a problem; forget it if the operation just timed out - if(r == -1) { - if( is_error(EAGAIN) ) { // handle non-blocking call timeout - #if SRC_VERBOSE - printf("UDP receive timed out\n"); - #endif - - if( d_wait ) { - // Allow boost thread interrupt, then try again - //boost::this_thread::interruption_point(); - //continue; - return 0; - } - else - return -1; - } - else { - report_error("udp_source/recv",NULL); - return -1; - } - } - else if(r==0) { - if(d_eof) { - // zero-length packet interpreted as EOF - - #if SNK_VERBOSE - printf("\tzero-length packet received; returning EOF\n"); - #endif - - return -1; - } - else{ - // do we need to allow boost thread interrupt? - boost::this_thread::interruption_point(); - continue; - } - } - else { - // Calculate the number of bytes we can take from the buffer in this call - nbytes = std::min(r, total_bytes-bytes_received); - - // adjust the total number of bytes we have to round down to nearest integer of an itemsize - nbytes -= ((bytes_received+nbytes) % d_itemsize); - - // copy the number of bytes we want to look at here - memcpy(out, d_temp_buff, nbytes); - - d_residual = r - nbytes; // save the number of bytes stored - d_temp_offset=nbytes; // reset buffer index - - // keep track of the total number of bytes received - bytes_received += nbytes; - - // increment the pointer - out += nbytes; - - // Immediately return when data comes in - break; - } - - #if SNK_VERBOSE - printf("\tbytes received: %d bytes (nbytes: %d)\n", bytes, nbytes); - #endif - } - - #if SRC_VERBOSE - printf("Total Bytes Received: %d (bytes_received / noutput_items = %d / %d)\n", - bytes_received, bytes_received, noutput_items); - #endif - - // bytes_received is already set to some integer multiple of itemsize - return bytes_received/d_itemsize; -} - -// Return port number of d_socket -int gr_udp_source::get_port(void) -{ - sockaddr_in name; - socklen_t len = sizeof(name); - int ret = getsockname( d_socket, (sockaddr*)&name, &len ); - if( ret ) { - report_error("gr_udp_source/getsockname",NULL); - return -1; - } - return ntohs(name.sin_port); -} diff --git a/gnuradio-core/src/lib/io/gr_udp_source.h b/gnuradio-core/src/lib/io/gr_udp_source.h deleted file mode 100644 index 56dcb3c0a9..0000000000 --- a/gnuradio-core/src/lib/io/gr_udp_source.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_UDP_SOURCE_H -#define INCLUDED_GR_UDP_SOURCE_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gruel/thread.h> - -class gr_udp_source; -typedef boost::shared_ptr<gr_udp_source> gr_udp_source_sptr; - -GR_CORE_API gr_udp_source_sptr gr_make_udp_source(size_t itemsize, const char *host, - unsigned short port, - int payload_size=1472, - bool eof=true, bool wait=true); - -/*! - * \brief Read stream from an UDP socket. - * \ingroup source_blk - * - * \param itemsize The size (in bytes) of the item datatype - * \param host The name or IP address of the receiving host; can be - * NULL, None, or "0.0.0.0" to allow reading from any - * interface on the host - * \param port The port number on which to receive data; use 0 to - * have the system assign an unused port number - * \param payload_size UDP payload size by default set to 1472 = - * (1500 MTU - (8 byte UDP header) - (20 byte IP header)) - * \param eof Interpret zero-length packet as EOF (default: true) - * \param wait Wait for data if not immediately available - * (default: true) - * -*/ - -class GR_CORE_API gr_udp_source : public gr_sync_block -{ - friend GR_CORE_API gr_udp_source_sptr gr_make_udp_source(size_t itemsize, - const char *host, - unsigned short port, - int payload_size, - bool eof, bool wait); - - private: - size_t d_itemsize; - int d_payload_size; // maximum transmission unit (packet length) - bool d_eof; // zero-length packet is EOF - bool d_wait; // wait if data if not immediately available - int d_socket; // handle to socket - char *d_temp_buff; // hold buffer between calls - ssize_t d_residual; // hold information about number of bytes stored in the temp buffer - size_t d_temp_offset; // point to temp buffer location offset - - protected: - /*! - * \brief UDP Source Constructor - * - * \param itemsize The size (in bytes) of the item datatype - * \param host The name or IP address of the receiving host; can be - * NULL, None, or "0.0.0.0" to allow reading from any - * interface on the host - * \param port The port number on which to receive data; use 0 to - * have the system assign an unused port number - * \param payload_size UDP payload size by default set to 1472 = - * (1500 MTU - (8 byte UDP header) - (20 byte IP header)) - * \param eof Interpret zero-length packet as EOF (default: true) - * \param wait Wait for data if not immediately available - * (default: true) - */ - gr_udp_source(size_t itemsize, const char *host, unsigned short port, - int payload_size, bool eof, bool wait); - - public: - ~gr_udp_source(); - - /*! \brief return the PAYLOAD_SIZE of the socket */ - int payload_size() { return d_payload_size; } - - /*! \brief return the port number of the socket */ - int get_port(); - - // should we export anything else? - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_UDP_SOURCE_H */ diff --git a/gnuradio-core/src/lib/io/gr_udp_source.i b/gnuradio-core/src/lib/io/gr_udp_source.i deleted file mode 100644 index 18823a356f..0000000000 --- a/gnuradio-core/src/lib/io/gr_udp_source.i +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,udp_source) - -gr_udp_source_sptr -gr_make_udp_source (size_t itemsize, const char *host, - unsigned short port, int payload_size=1472, - bool eof=true, bool wait=true) throw (std::runtime_error); - -class gr_udp_source : public gr_sync_block -{ - protected: - gr_udp_source (size_t itemsize, const char *host, - unsigned short port, int payload_size, bool eof, bool wait) throw (std::runtime_error); - - public: - ~gr_udp_source (); - - int payload_size() { return d_payload_size; } - int get_port(); -}; diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.cc b/gnuradio-core/src/lib/io/gr_wavfile_sink.cc deleted file mode 100644 index 8526032f6d..0000000000 --- a/gnuradio-core/src/lib/io/gr_wavfile_sink.cc +++ /dev/null @@ -1,280 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2007,2008,2009,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 <gr_wavfile_sink.h> -#include <gr_io_signature.h> -#include <gri_wavfile.h> -#include <stdexcept> -#include <climits> -#include <cstring> -#include <cmath> -#include <fcntl.h> -#include <gruel/thread.h> -#include <boost/math/special_functions/round.hpp> - -// win32 (mingw/msvc) specific -#ifdef HAVE_IO_H -#include <io.h> -#endif -#ifdef O_BINARY -#define OUR_O_BINARY O_BINARY -#else -#define OUR_O_BINARY 0 -#endif - -// should be handled via configure -#ifdef O_LARGEFILE -#define OUR_O_LARGEFILE O_LARGEFILE -#else -#define OUR_O_LARGEFILE 0 -#endif - - -gr_wavfile_sink_sptr -gr_make_wavfile_sink(const char *filename, - int n_channels, - unsigned int sample_rate, - int bits_per_sample) -{ - return gnuradio::get_initial_sptr(new gr_wavfile_sink (filename, - n_channels, - sample_rate, - bits_per_sample)); -} - -gr_wavfile_sink::gr_wavfile_sink(const char *filename, - int n_channels, - unsigned int sample_rate, - int bits_per_sample) - : gr_sync_block ("wavfile_sink", - gr_make_io_signature(1, n_channels, sizeof(float)), - gr_make_io_signature(0, 0, 0)), - d_sample_rate(sample_rate), d_nchans(n_channels), - d_fp(0), d_new_fp(0), d_updated(false) -{ - if (bits_per_sample != 8 && bits_per_sample != 16) { - throw std::runtime_error("Invalid bits per sample (supports 8 and 16)"); - } - d_bytes_per_sample = bits_per_sample / 8; - d_bytes_per_sample_new = d_bytes_per_sample; - - if (!open(filename)) { - throw std::runtime_error ("can't open file"); - } - - if (bits_per_sample == 8) { - d_max_sample_val = 0xFF; - d_min_sample_val = 0; - d_normalize_fac = d_max_sample_val/2; - d_normalize_shift = 1; - } else { - d_max_sample_val = 0x7FFF; - d_min_sample_val = -0x7FFF; - d_normalize_fac = d_max_sample_val; - d_normalize_shift = 0; - if (bits_per_sample != 16) { - fprintf(stderr, "Invalid bits per sample value requested, using 16"); - } - } -} - - -bool -gr_wavfile_sink::open(const char* filename) -{ - gruel::scoped_lock guard(d_mutex); - - // we use the open system call to get access to the O_LARGEFILE flag. - int fd; - if ((fd = ::open (filename, - O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY, - 0664)) < 0){ - perror (filename); - return false; - } - - if (d_new_fp) { // if we've already got a new one open, close it - fclose(d_new_fp); - d_new_fp = 0; - } - - if ((d_new_fp = fdopen (fd, "wb")) == NULL) { - perror (filename); - ::close(fd); // don't leak file descriptor if fdopen fails. - return false; - } - d_updated = true; - - if (!gri_wavheader_write(d_new_fp, - d_sample_rate, - d_nchans, - d_bytes_per_sample_new)) { - fprintf(stderr, "[%s] could not write to WAV file\n", __FILE__); - exit(-1); - } - - return true; -} - - -void -gr_wavfile_sink::close() -{ - gruel::scoped_lock guard(d_mutex); - - if (!d_fp) - return; - - close_wav(); -} - -void gr_wavfile_sink::close_wav() -{ - unsigned int byte_count = d_sample_count * d_bytes_per_sample; - - gri_wavheader_complete(d_fp, byte_count); - - fclose(d_fp); - d_fp = NULL; -} - - -gr_wavfile_sink::~gr_wavfile_sink () -{ - if (d_new_fp) { - fclose(d_new_fp); - } - - close(); -} - - -int -gr_wavfile_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float **in = (float **) &input_items[0]; - int n_in_chans = input_items.size(); - - short int sample_buf_s; - - int nwritten; - - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this block - do_update(); // update: d_fp is reqd - if (!d_fp) // drop output on the floor - return noutput_items; - - for (nwritten = 0; nwritten < noutput_items; nwritten++) { - for (int chan = 0; chan < d_nchans; chan++) { - // Write zeros to channels which are in the WAV file - // but don't have any inputs here - if (chan < n_in_chans) { - sample_buf_s = - convert_to_short(in[chan][nwritten]); - } else { - sample_buf_s = 0; - } - - gri_wav_write_sample(d_fp, sample_buf_s, d_bytes_per_sample); - - if (feof(d_fp) || ferror(d_fp)) { - fprintf(stderr, "[%s] file i/o error\n", __FILE__); - close(); - exit(-1); - } - d_sample_count++; - } - } - - return nwritten; -} - - -short int -gr_wavfile_sink::convert_to_short(float sample) -{ - sample += d_normalize_shift; - sample *= d_normalize_fac; - if (sample > d_max_sample_val) { - sample = d_max_sample_val; - } else if (sample < d_min_sample_val) { - sample = d_min_sample_val; - } - - return (short int) boost::math::iround(sample); -} - - -void -gr_wavfile_sink::set_bits_per_sample(int bits_per_sample) -{ - gruel::scoped_lock guard(d_mutex); - if (bits_per_sample == 8 || bits_per_sample == 16) { - d_bytes_per_sample_new = bits_per_sample / 8; - } -} - - -void -gr_wavfile_sink::set_sample_rate(unsigned int sample_rate) -{ - gruel::scoped_lock guard(d_mutex); - d_sample_rate = sample_rate; -} - - -void -gr_wavfile_sink::do_update() -{ - if (!d_updated) { - return; - } - - if (d_fp) { - close_wav(); - } - - d_fp = d_new_fp; // install new file pointer - d_new_fp = 0; - d_sample_count = 0; - d_bytes_per_sample = d_bytes_per_sample_new; - - if (d_bytes_per_sample == 1) { - d_max_sample_val = UCHAR_MAX; - d_min_sample_val = 0; - d_normalize_fac = d_max_sample_val/2; - d_normalize_shift = 1; - } else if (d_bytes_per_sample == 2) { - d_max_sample_val = SHRT_MAX; - d_min_sample_val = SHRT_MIN; - d_normalize_fac = d_max_sample_val; - d_normalize_shift = 0; - } - - d_updated = false; -} diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.h b/gnuradio-core/src/lib/io/gr_wavfile_sink.h deleted file mode 100644 index 162151b7a8..0000000000 --- a/gnuradio-core/src/lib/io/gr_wavfile_sink.h +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_WAVFILE_SINK_H -#define INCLUDED_GR_WAVFILE_SINK_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_file_sink_base.h> -#include <boost/thread.hpp> - -class gr_wavfile_sink; -typedef boost::shared_ptr<gr_wavfile_sink> gr_wavfile_sink_sptr; - -/* - * \p filename The .wav file to be opened - * \p n_channels Number of channels (2 = stereo or I/Q output) - * \p sample_rate Sample rate [S/s] - * \p bits_per_sample 16 or 8 bit, default is 16 - */ -GR_CORE_API gr_wavfile_sink_sptr -gr_make_wavfile_sink (const char *filename, - int n_channels, - unsigned int sample_rate, - int bits_per_sample = 16); - -/*! - * \brief Write stream to a Microsoft PCM (.wav) file. - * - * Values must be floats within [-1;1]. - * Check gr_make_wavfile_sink() for extra info. - * - * \ingroup sink_blk - */ -class GR_CORE_API gr_wavfile_sink : public gr_sync_block -{ -private: - friend GR_CORE_API gr_wavfile_sink_sptr gr_make_wavfile_sink (const char *filename, - int n_channels, - unsigned int sample_rate, - int bits_per_sample); - - gr_wavfile_sink(const char *filename, - int n_channels, - unsigned int sample_rate, - int bits_per_sample); - - unsigned d_sample_rate; - int d_nchans; - unsigned d_sample_count; - int d_bytes_per_sample; - int d_bytes_per_sample_new; - int d_max_sample_val; - int d_min_sample_val; - int d_normalize_shift; - int d_normalize_fac; - - FILE *d_fp; - FILE *d_new_fp; - bool d_updated; - boost::mutex d_mutex; - - /*! - * \brief Convert a sample value within [-1;+1] to a corresponding - * short integer value - */ - short convert_to_short(float sample); - - /*! - * \brief If any file changes have occurred, update now. This is called - * internally by work() and thus doesn't usually need to be called by - * hand. - */ - void do_update(); - - /*! - * \brief Writes information to the WAV header which is not available - * a-priori (chunk size etc.) and closes the file. Not thread-safe and - * assumes d_fp is a valid file pointer, should thus only be called by - * other methods. - */ - void close_wav(); - -public: - ~gr_wavfile_sink (); - - /*! - * \brief Opens a new file and writes a WAV header. Thread-safe. - */ - bool open(const char* filename); - - /*! - * \brief Closes the currently active file and completes the WAV - * header. Thread-safe. - */ - void close(); - - /*! - * \brief Set the sample rate. This will not affect the WAV file - * currently opened. Any following open() calls will use this new - * sample rate. - */ - void set_sample_rate(unsigned int sample_rate); - - /*! - * \brief Set bits per sample. This will not affect the WAV file - * currently opened (see set_sample_rate()). If the value is neither - * 8 nor 16, the call is ignored and the current value is kept. - */ - void set_bits_per_sample(int bits_per_sample); - - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - -#endif /* INCLUDED_GR_WAVFILE_SINK_H */ diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.i b/gnuradio-core/src/lib/io/gr_wavfile_sink.i deleted file mode 100644 index 48d1130bd2..0000000000 --- a/gnuradio-core/src/lib/io/gr_wavfile_sink.i +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -GR_SWIG_BLOCK_MAGIC(gr,wavfile_sink); - -gr_wavfile_sink_sptr -gr_make_wavfile_sink (const char *filename, - int n_channels, - unsigned int sample_rate, - int bits_per_sample = 16) throw (std::runtime_error); - -class gr_wavfile_sink : public gr_sync_block -{ -protected: - gr_wavfile_sink(const char *filename, - int n_channels, - unsigned int sample_rate, - int bits_per_sample) throw (std::runtime_error); - -public: - ~gr_wavfile_sink (); - bool open(const char* filename); - void close(); - void set_sample_rate(unsigned int sample_rate); - void set_bits_per_sample(int bits_per_sample); -}; - diff --git a/gnuradio-core/src/lib/io/gr_wavfile_source.cc b/gnuradio-core/src/lib/io/gr_wavfile_source.cc deleted file mode 100644 index c8372868ba..0000000000 --- a/gnuradio-core/src/lib/io/gr_wavfile_source.cc +++ /dev/null @@ -1,171 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_wavfile_source.h> -#include <gr_io_signature.h> -#include <gri_wavfile.h> -#include <sys/types.h> -#include <fcntl.h> -#include <stdexcept> - -// win32 (mingw/msvc) specific -#ifdef HAVE_IO_H -#include <io.h> -#endif -#ifdef O_BINARY -#define OUR_O_BINARY O_BINARY -#else -#define OUR_O_BINARY 0 -#endif -// should be handled via configure -#ifdef O_LARGEFILE -#define OUR_O_LARGEFILE O_LARGEFILE -#else -#define OUR_O_LARGEFILE 0 -#endif - - -gr_wavfile_source_sptr -gr_make_wavfile_source (const char *filename, bool repeat) -{ - return gnuradio::get_initial_sptr(new gr_wavfile_source (filename, repeat)); -} - - -gr_wavfile_source::gr_wavfile_source (const char *filename, bool repeat) - : gr_sync_block ("wavfile_source", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 2, sizeof(float))), - d_fp(NULL), d_repeat(repeat), - d_sample_rate(1), d_nchans(1), d_bytes_per_sample(2), d_first_sample_pos(0), - d_samples_per_chan(0), d_sample_idx(0) -{ - // we use "open" to use to the O_LARGEFILE flag - - int fd; - if ((fd = open (filename, O_RDONLY | OUR_O_LARGEFILE | OUR_O_BINARY)) < 0) { - perror (filename); - throw std::runtime_error ("can't open file"); - } - - if ((d_fp = fdopen (fd, "rb")) == NULL) { - perror (filename); - throw std::runtime_error ("can't open file"); - } - - // Scan headers, check file validity - if (!gri_wavheader_parse(d_fp, - d_sample_rate, - d_nchans, - d_bytes_per_sample, - d_first_sample_pos, - d_samples_per_chan)) { - throw std::runtime_error("is not a valid wav file"); - } - - if (d_samples_per_chan == 0) { - throw std::runtime_error("WAV file does not contain any samples"); - } - - if (d_bytes_per_sample == 1) { - d_normalize_fac = 128; - d_normalize_shift = 1; - } else { - d_normalize_fac = 0x7FFF; - d_normalize_shift = 0; - } - - // Re-set the output signature - set_output_signature(gr_make_io_signature(1, d_nchans, sizeof(float))); -} - - -gr_wavfile_source::~gr_wavfile_source () -{ - fclose(d_fp); -} - - -int -gr_wavfile_source::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float **out = (float **) &output_items[0]; - int n_out_chans = output_items.size(); - - int i; - short sample; - - for (i = 0; i < noutput_items; i++) { - if (d_sample_idx >= d_samples_per_chan) { - if (!d_repeat) { - // if nothing was read at all, say we're done. - return i ? i : -1; - } - - if (fseek (d_fp, d_first_sample_pos, SEEK_SET) == -1) { - fprintf(stderr, "[%s] fseek failed\n", __FILE__); - exit(-1); - } - - d_sample_idx = 0; - } - - for (int chan = 0; chan < d_nchans; chan++) { - sample = gri_wav_read_sample(d_fp, d_bytes_per_sample); - - if (chan < n_out_chans) { - out[chan][i] = convert_to_float(sample); - } - } - - d_sample_idx++; - - // OK, EOF is not necessarily an error. But we're not going to - // deal with handling corrupt wav files, so if they give us any - // trouble they won't be processed. Serves them bloody right. - if (feof(d_fp) || ferror(d_fp)) { - if (i == 0) { - fprintf(stderr, "[%s] WAV file has corrupted header or i/o error\n", __FILE__); - return -1; - } - return i; - } - } - - return noutput_items; -} - - -float -gr_wavfile_source::convert_to_float(short int sample) -{ - float sample_out = (float) sample; - sample_out /= d_normalize_fac; - sample_out -= d_normalize_shift; - return sample_out; -} diff --git a/gnuradio-core/src/lib/io/gr_wavfile_source.h b/gnuradio-core/src/lib/io/gr_wavfile_source.h deleted file mode 100644 index 02e6e36788..0000000000 --- a/gnuradio-core/src/lib/io/gr_wavfile_source.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_WAVFILE_SOURCE_H -#define INCLUDED_GR_WAVFILE_SOURCE_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <cstdio> // for FILE - -class gr_wavfile_source; -typedef boost::shared_ptr<gr_wavfile_source> gr_wavfile_source_sptr; - -GR_CORE_API gr_wavfile_source_sptr -gr_make_wavfile_source (const char *filename, bool repeat = false); - -/*! - * \brief Read stream from a Microsoft PCM (.wav) file, output floats - * - * Unless otherwise called, values are within [-1;1]. - * Check gr_make_wavfile_source() for extra info. - * - * \ingroup source_blk - */ - -class GR_CORE_API gr_wavfile_source : public gr_sync_block -{ -private: - friend GR_CORE_API gr_wavfile_source_sptr gr_make_wavfile_source (const char *filename, - bool repeat); - gr_wavfile_source(const char *filename, bool repeat); - - FILE *d_fp; - bool d_repeat; - - unsigned d_sample_rate; - int d_nchans; - int d_bytes_per_sample; - int d_first_sample_pos; - unsigned d_samples_per_chan; - unsigned d_sample_idx; - int d_normalize_shift; - int d_normalize_fac; - - /*! - * \brief Convert an integer sample value to a float value within [-1;1] - */ - float convert_to_float(short int sample); - -public: - ~gr_wavfile_source (); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - /*! - * \brief Read the sample rate as specified in the wav file header - */ - unsigned int sample_rate() const { return d_sample_rate; }; - - /*! - * \brief Return the number of bits per sample as specified in the wav - * file header. Only 8 or 16 bit are supported here. - */ - int bits_per_sample() const { return d_bytes_per_sample * 8; }; - - /*! - * \brief Return the number of channels in the wav file as specified in - * the wav file header. This is also the max number of outputs you can - * have. - */ - int channels() const { return d_nchans; }; -}; - -#endif /* INCLUDED_GR_WAVFILE_SOURCE_H */ diff --git a/gnuradio-core/src/lib/io/gr_wavfile_source.i b/gnuradio-core/src/lib/io/gr_wavfile_source.i deleted file mode 100644 index 5af2224f14..0000000000 --- a/gnuradio-core/src/lib/io/gr_wavfile_source.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,wavfile_source); - -gr_wavfile_source_sptr -gr_make_wavfile_source (const char *filename, - bool repeat = false) throw (std::runtime_error); - -class gr_wavfile_source : public gr_sync_block -{ -private: - gr_wavfile_source(const char *filename, - bool repeat) throw (std::runtime_error); - -public: - ~gr_wavfile_source(); - - unsigned int sample_rate(); - int bits_per_sample(); - int channels(); -}; - diff --git a/gnuradio-core/src/lib/io/gri_wavfile.cc b/gnuradio-core/src/lib/io/gri_wavfile.cc deleted file mode 100644 index 277e6b7b0e..0000000000 --- a/gnuradio-core/src/lib/io/gri_wavfile.cc +++ /dev/null @@ -1,251 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gri_wavfile.h> -#include <cstring> -#include <stdint.h> -#include <boost/detail/endian.hpp> //BOOST_BIG_ENDIAN - -# define VALID_COMPRESSION_TYPE 0x0001 - -// Basically, this is the opposite of htonx() and ntohx() -// Define host to/from worknet (little endian) short and long -#ifdef BOOST_BIG_ENDIAN - - static inline uint16_t __gri_wav_bs16(uint16_t x) - { - return (x>>8) | (x<<8); - } - - static inline uint32_t __gri_wav_bs32(uint32_t x) - { - return (uint32_t(__gri_wav_bs16(uint16_t(x&0xfffful)))<<16) | (__gri_wav_bs16(uint16_t(x>>16))); - } - - #define htowl(x) __gri_wav_bs32(x) - #define wtohl(x) __gri_wav_bs32(x) - #define htows(x) __gri_wav_bs16(x) - #define wtohs(x) __gri_wav_bs16(x) - -#else - - #define htowl(x) uint32_t(x) - #define wtohl(x) uint32_t(x) - #define htows(x) uint16_t(x) - #define wtohs(x) uint16_t(x) - -#endif // BOOST_BIG_ENDIAN - -// WAV files are always little-endian, so we need some byte switching macros -static inline uint32_t host_to_wav(uint32_t x) { return htowl(x); } -static inline uint16_t host_to_wav(uint16_t x) { return htows(x); } -static inline int16_t host_to_wav(int16_t x) { return htows(x); } -static inline uint32_t wav_to_host(uint32_t x) { return wtohl(x); } -static inline uint16_t wav_to_host(uint16_t x) { return wtohs(x); } -static inline int16_t wav_to_host(int16_t x) { return wtohs(x); } - -bool -gri_wavheader_parse(FILE *fp, - unsigned int &sample_rate_o, - int &nchans_o, - int &bytes_per_sample_o, - int &first_sample_pos_o, - unsigned int &samples_per_chan_o) -{ - // _o variables take return values - char str_buf[8] = {0}; - - uint32_t file_size; - uint32_t fmt_hdr_skip; - uint16_t compression_type; - uint16_t nchans; - uint32_t sample_rate; - uint32_t avg_bytes_per_sec; - uint16_t block_align; - uint16_t bits_per_sample; - uint32_t chunk_size; - - size_t fresult; - - fresult = fread(str_buf, 1, 4, fp); - if (fresult != 4 || strncmp(str_buf, "RIFF", 4) || feof(fp)) { - return false; - } - - fresult = fread(&file_size, 1, 4, fp); - - fresult = fread(str_buf, 1, 8, fp); - if (fresult != 8 || strncmp(str_buf, "WAVEfmt ", 8) || feof(fp)) { - return false; - } - - fresult = fread(&fmt_hdr_skip, 1, 4, fp); - - fresult = fread(&compression_type, 1, 2, fp); - if (wav_to_host(compression_type) != VALID_COMPRESSION_TYPE) { - return false; - } - - fresult = fread(&nchans, 1, 2, fp); - fresult = fread(&sample_rate, 1, 4, fp); - fresult = fread(&avg_bytes_per_sec, 1, 4, fp); - fresult = fread(&block_align, 1, 2, fp); - fresult = fread(&bits_per_sample, 1, 2, fp); - - if (ferror(fp)) { - return false; - } - - fmt_hdr_skip = wav_to_host(fmt_hdr_skip); - nchans = wav_to_host(nchans); - sample_rate = wav_to_host(sample_rate); - bits_per_sample = wav_to_host(bits_per_sample); - - if (bits_per_sample != 8 && bits_per_sample != 16) { - return false; - } - - fmt_hdr_skip -= 16; - if (fmt_hdr_skip) { - fseek(fp, fmt_hdr_skip, SEEK_CUR); - } - - // data chunk - fresult = fread(str_buf, 1, 4, fp); - if (strncmp(str_buf, "data", 4)) { - return false; - } - - fresult = fread(&chunk_size, 1, 4, fp); - if (ferror(fp)) { - return false; - } - - // More byte swapping - chunk_size = wav_to_host(chunk_size); - - // Output values - sample_rate_o = (unsigned) sample_rate; - nchans_o = (int) nchans; - bytes_per_sample_o = (int) (bits_per_sample / 8); - first_sample_pos_o = (int) ftell(fp); - samples_per_chan_o = (unsigned) (chunk_size / (bytes_per_sample_o * nchans)); - return true; -} - - -short int -gri_wav_read_sample(FILE *fp, int bytes_per_sample) -{ - int16_t buf_16bit; - - if(!fread(&buf_16bit, bytes_per_sample, 1, fp)) { - return 0; - } - if(bytes_per_sample == 1) { - return (short) buf_16bit; - } - return (short)wav_to_host(buf_16bit); -} - - -bool -gri_wavheader_write(FILE *fp, - unsigned int sample_rate, - int nchans, - int bytes_per_sample) -{ - const int header_len = 44; - char wav_hdr[header_len] = "RIFF\0\0\0\0WAVEfmt \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0data\0\0\0"; - uint16_t nchans_f = (uint16_t) nchans; - uint32_t sample_rate_f = (uint32_t) sample_rate; - uint16_t block_align = bytes_per_sample * nchans; - uint32_t avg_bytes = sample_rate * block_align; - uint16_t bits_per_sample = bytes_per_sample * 8; - - nchans_f = host_to_wav(nchans_f); - sample_rate_f = host_to_wav(sample_rate_f); - block_align = host_to_wav(block_align); - avg_bytes = host_to_wav(avg_bytes); - bits_per_sample = host_to_wav(bits_per_sample); - - wav_hdr[16] = 0x10; // no extra bytes - wav_hdr[20] = 0x01; // no compression - memcpy((void *) (wav_hdr + 22), (void *) &nchans_f, 2); - memcpy((void *) (wav_hdr + 24), (void *) &sample_rate_f, 4); - memcpy((void *) (wav_hdr + 28), (void *) &avg_bytes, 4); - memcpy((void *) (wav_hdr + 32), (void *) &block_align, 2); - memcpy((void *) (wav_hdr + 34), (void *) &bits_per_sample, 2); - - fwrite(&wav_hdr, 1, header_len, fp); - if (ferror(fp)) { - return false; - } - - return true; -} - - -void -gri_wav_write_sample(FILE *fp, short int sample, int bytes_per_sample) -{ - void *data_ptr; - unsigned char buf_8bit; - int16_t buf_16bit; - - if (bytes_per_sample == 1) { - buf_8bit = (unsigned char) sample; - data_ptr = (void *) &buf_8bit; - } else { - buf_16bit = host_to_wav((int16_t) sample); - data_ptr = (void *) &buf_16bit; - } - - fwrite(data_ptr, 1, bytes_per_sample, fp); -} - - -bool -gri_wavheader_complete(FILE *fp, unsigned int byte_count) -{ - uint32_t chunk_size = (uint32_t) byte_count; - chunk_size = host_to_wav(chunk_size); - - fseek(fp, 40, SEEK_SET); - fwrite(&chunk_size, 1, 4, fp); - - chunk_size = (uint32_t) byte_count + 36; // fmt chunk and data header - chunk_size = host_to_wav(chunk_size); - fseek(fp, 4, SEEK_SET); - - fwrite(&chunk_size, 1, 4, fp); - - if (ferror(fp)) { - return false; - } - - return true; -} diff --git a/gnuradio-core/src/lib/io/gri_wavfile.h b/gnuradio-core/src/lib/io/gri_wavfile.h deleted file mode 100644 index 16280e34a9..0000000000 --- a/gnuradio-core/src/lib/io/gri_wavfile.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// This file stores all the RIFF file type knowledge for the gr_wavfile_* -// blocks. - -#include <gr_core_api.h> -#include <cstdio> - -/*! - * \brief Read signal information from a given WAV file. - * - * \param[in] fp File pointer to an opened, empty file. - * \param[out] sample_rate Stores the sample rate [S/s] - * \param[out] nchans Number of channels - * \param[out] bytes_per_sample Bytes per sample, can either be 1 or 2 (corresponding o - * 8 or 16 bit samples, respectively) - * \param[out] first_sample_pos Number of the first byte containing a sample. Use this - * with fseek() to jump from the end of the file to the - * first sample when in repeat mode. - * \param[out] samples_per_chan Number of samples per channel - * \return True on a successful read, false if the file could not be read or is - * not a valid WAV file. - */ -bool -gri_wavheader_parse(FILE *fp, - unsigned int &sample_rate, - int &nchans, - int &bytes_per_sample, - int &first_sample_pos, - unsigned int &samples_per_chan); - - -/*! - * \brief Read one sample from an open WAV file at the current position. - * - * Takes care of endianness. - */ -short int -gri_wav_read_sample(FILE *fp, int bytes_per_sample); - - -/*! - * \brief Write a valid RIFF file header - * - * Note: Some header values are kept blank because they're usually not known - * a-priori (file and chunk lengths). Use gri_wavheader_complete() to fill - * these in. - */ -bool -gri_wavheader_write(FILE *fp, - unsigned int sample_rate, - int nchans, - int bytes_per_sample); - -/*! - * \brief Write one sample to an open WAV file at the current position. - * - * Takes care of endianness. - */ -void -gri_wav_write_sample(FILE *fp, short int sample, int bytes_per_sample); - - -/*! - * \brief Complete a WAV header - * - * Note: The stream position is changed during this function. If anything - * needs to be written to the WAV file after calling this function (which - * shouldn't happen), you need to fseek() to the end of the file (or - * whereever). - * - * \param[in] fp File pointer to an open WAV file with a blank header - * \param[in] byte_count Length of all samples written to the file in bytes. - */ -bool -gri_wavheader_complete(FILE *fp, unsigned int byte_count); diff --git a/gnuradio-core/src/lib/io/io.i b/gnuradio-core/src/lib/io/io.i index e2de4eb976..6cd3e06f47 100644 --- a/gnuradio-core/src/lib/io/io.i +++ b/gnuradio-core/src/lib/io/io.i @@ -26,10 +26,6 @@ #include "config.h" #endif -#include <gr_file_sink.h> -#include <gr_file_source.h> -#include <gr_file_descriptor_sink.h> -#include <gr_file_descriptor_source.h> #include <gr_histo_sink_f.h> #include <microtune_4702_eval_board.h> #include <microtune_4937_eval_board.h> @@ -37,27 +33,8 @@ #include <gr_oscope_sink_x.h> #include <gr_oscope_sink_f.h> #include <ppio.h> -#include <gr_message_source.h> -#include <gr_message_burst_source.h> -#include <gr_message_sink.h> -#include <gr_udp_sink.h> -#include <gr_udp_source.h> -#include <gr_wavfile_sink.h> -#include <gr_wavfile_source.h> -#include <gr_tagged_file_sink.h> -#include <gr_pdu_to_tagged_stream.h> -#include <gr_tagged_stream_to_pdu.h> -#include <gr_message_debug.h> -#include <gr_pdu.h> -#include <gr_tuntap_pdu.h> -#include <gr_socket_pdu.h> %} -%include "gr_file_sink_base.i" -%include "gr_file_sink.i" -%include "gr_file_source.i" -%include "gr_file_descriptor_sink.i" -%include "gr_file_descriptor_source.i" %include "gr_histo_sink.i" %include "microtune_xxxx_eval_board.i" %include "microtune_4702_eval_board.i" @@ -65,19 +42,5 @@ %include "sdr_1000.i" %include "gr_oscope_sink.i" %include "ppio.i" -%include "gr_message_source.i" -%include "gr_message_burst_source.i" -%include "gr_message_sink.i" -%include "gr_udp_sink.i" -%include "gr_udp_source.i" -%include "gr_wavfile_sink.i" -%include "gr_wavfile_source.i" -%include "gr_tagged_file_sink.i" -%include "gr_pdu_to_tagged_stream.i" -%include "gr_tagged_stream_to_pdu.i" -%include "gr_message_debug.i" -%include "gr_pdu.i" -%include "gr_tuntap_pdu.i" -%include "gr_socket_pdu.i" diff --git a/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt b/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt deleted file mode 100644 index f073249f62..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright 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. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## -#MSVC workaround: we cant have dynamically sized arrays. -#So ifdef a max array bounds that is larger than NN and NROOTS -#Its a bit of a hack, but if you look at the code, its so full of ifdefs, -#and lacks optimization where it should be pre-allocating these arrays. -if(MSVC) - set_source_files_properties( - ${CMAKE_CURRENT_SOURCE_DIR}/exercise.c - ${CMAKE_CURRENT_SOURCE_DIR}/decode_rs.c - PROPERTIES COMPILE_DEFINITIONS "MAX_ARRAY=256;" - ) -endif(MSVC) - -set(gr_core_rs_sources - ${CMAKE_CURRENT_SOURCE_DIR}/encode_rs.c - ${CMAKE_CURRENT_SOURCE_DIR}/decode_rs.c - ${CMAKE_CURRENT_SOURCE_DIR}/init_rs.c -) - -######################################################################## -# Setup sources and includes -######################################################################## -list(APPEND gnuradio_core_sources ${gr_core_rs_sources}) - -install( - FILES ${CMAKE_CURRENT_SOURCE_DIR}/rs.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "core_devel" -) - -######################################################################## -# Register unit tests -######################################################################## -if(ENABLE_TESTING) -add_executable(gr_core_rstest - ${gr_core_rs_sources} - ${CMAKE_CURRENT_SOURCE_DIR}/rstest.c - ${CMAKE_CURRENT_SOURCE_DIR}/exercise.c -) -add_test(gr-core-reed-solomon-test gr_core_rstest) -endif(ENABLE_TESTING) diff --git a/gnuradio-core/src/lib/reed-solomon/Makefile.in.karn b/gnuradio-core/src/lib/reed-solomon/Makefile.in.karn deleted file mode 100644 index 8550b41581..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/Makefile.in.karn +++ /dev/null @@ -1,99 +0,0 @@ -# Copyright 2002 Phil Karn, KA9Q -# May be used under the terms of the GNU General Public License (GPL) -# @configure_input@ -srcdir = @srcdir@ -prefix = @prefix@ -exec_prefix=@exec_prefix@ -VPATH = @srcdir@ -CC=@CC@ - -CFLAGS=@CFLAGS@ @ARCH_OPTION@ -Wall - -LIB= encode_rs_char.o encode_rs_int.o encode_rs_8.o \ - decode_rs_char.o decode_rs_int.o decode_rs_8.o \ - init_rs_char.o init_rs_int.o ccsds_tab.o \ - encode_rs_ccsds.o decode_rs_ccsds.o ccsds_tal.o - -all: librs.a librs.so.@SO_VERSION@ - -test: rstest - ./rstest - -rstest: rstest.o exercise_int.o exercise_char.o exercise_8.o exercise_ccsds.o \ - librs.a - gcc -g -o $@ $^ - -install: all - install -D -m 644 -p librs.a librs.so.@SO_VERSION@ @libdir@ - (cd @libdir@;ln -f -s librs.so.@SO_VERSION@ librs.so) - ldconfig - install -m 644 -p rs.h @includedir@ - install -m 644 rs.3 @mandir@/man3 - -librs.a: $(LIB) - ar rv $@ $^ - -librs.so.@SO_VERSION@: librs.a - gcc -shared -Xlinker -soname=librs.so.@SO_NAME@ -o $@ -Wl,-whole-archive $^ -Wl,-no-whole-archive -lc - -encode_rs_char.o: encode_rs.c - gcc $(CFLAGS) -c -o $@ $^ - -encode_rs_int.o: encode_rs.c - gcc -DBIGSYM=1 $(CFLAGS) -c -o $@ $^ - -encode_rs_8.o: encode_rs.c - gcc -DFIXED=1 $(CFLAGS) -c -o $@ $^ - -decode_rs_char.o: decode_rs.c - gcc $(CFLAGS) -c -o $@ $^ - -decode_rs_int.o: decode_rs.c - gcc -DBIGSYM=1 $(CFLAGS) -c -o $@ $^ - -decode_rs_8.o: decode_rs.c - gcc -DFIXED=1 $(CFLAGS) -c -o $@ $^ - -init_rs_char.o: init_rs.c - gcc $(CFLAGS) -c -o $@ $^ - -init_rs_int.o: init_rs.c - gcc -DBIGSYM=1 $(CFLAGS) -c -o $@ $^ - -ccsds_tab.o: ccsds_tab.c - -ccsds_tab.c: gen_ccsds - ./gen_ccsds > ccsds_tab.c - -gen_ccsds: gen_ccsds.o init_rs_char.o - gcc -o $@ $^ - -gen_ccsds.o: gen_ccsds.c - gcc $(CFLAGS) -c -o $@ $^ - -ccsds_tal.o: ccsds_tal.c - -ccsds_tal.c: gen_ccsds_tal - ./gen_ccsds_tal > ccsds_tal.c - -exercise_char.o: exercise.c - gcc $(CFLAGS) -c -o $@ $^ - -exercise_int.o: exercise.c - gcc -DBIGSYM=1 $(CFLAGS) -c -o $@ $^ - -exercise_8.o: exercise.c - gcc -DFIXED=1 $(CFLAGS) -c -o $@ $^ - -exercise_ccsds.o: exercise.c - gcc -DCCSDS=1 $(CFLAGS) -c -o $@ $^ - - -clean: - rm -f *.o *.a ccsds_tab.c ccsds_tal.c gen_ccsds gen_ccsds_tal \ - rstest librs.so.@SO_VERSION@ - -distclean: clean - rm -f config.log config.cache config.status config.h makefile - - diff --git a/gnuradio-core/src/lib/reed-solomon/README b/gnuradio-core/src/lib/reed-solomon/README deleted file mode 100644 index 341832dbd5..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/README +++ /dev/null @@ -1,5 +0,0 @@ -This code is from http://people.qualcomm.com/karn/code/fec -It is based on reed-soloman-3.1.1 (1 Jan 2002). - -I has been converted to use automake, to better integrate with GNU -Radio's build strategy. diff --git a/gnuradio-core/src/lib/reed-solomon/README.karn b/gnuradio-core/src/lib/reed-solomon/README.karn deleted file mode 100644 index f30644ffea..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/README.karn +++ /dev/null @@ -1,22 +0,0 @@ -This package implements a general purpose Reed-Solomon encoding and decoding -facility. See the rs.3 man page for details. - -To install, simply do the following after extracting this tarball into -an empty directory: - -./configure -make -make install - -The command "make test" runs a battery of encode/decode tests using a -variety of RS codes using random data and random errors. Each test -should pass with an "OK"; if any fail, please let me know so I can -track down the problem. - -Phil Karn (karn@ka9q.net) 1 Jan 2002 - -Copyright 2002, Phil Karn, KA9Q -This software may be used under the terms of the GNU General Public License (GPL). - - - diff --git a/gnuradio-core/src/lib/reed-solomon/ccsds.h b/gnuradio-core/src/lib/reed-solomon/ccsds.h deleted file mode 100644 index 0f2bde6186..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/ccsds.h +++ /dev/null @@ -1 +0,0 @@ -extern unsigned char Taltab[],Tal1tab[]; diff --git a/gnuradio-core/src/lib/reed-solomon/char.h b/gnuradio-core/src/lib/reed-solomon/char.h deleted file mode 100644 index 7b2030a0b0..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/char.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Include file to configure the RS codec for character symbols - * - * Copyright 2002, Phil Karn, KA9Q - * May be used under the terms of the GNU General Public License (GPL) - */ - -#define DTYPE unsigned char - -#include <gr_core_api.h> - -/* Reed-Solomon codec control block */ -struct rs { - unsigned int mm; /* Bits per symbol */ - unsigned int nn; /* Symbols per block (= (1<<mm)-1) */ - unsigned char *alpha_to; /* log lookup table */ - unsigned char *index_of; /* Antilog lookup table */ - unsigned char *genpoly; /* Generator polynomial */ - unsigned int nroots; /* Number of generator roots = number of parity symbols */ - unsigned char fcr; /* First consecutive root, index form */ - unsigned char prim; /* Primitive element, index form */ - unsigned char iprim; /* prim-th root of 1, index form */ -}; - -static inline unsigned int modnn(struct rs *rs, unsigned int x){ - while (x >= rs->nn) { - x -= rs->nn; - x = (x >> rs->mm) + (x & rs->nn); - } - return x; -} -#define MODNN(x) modnn(rs,x) - -#define MM (rs->mm) -#define NN (rs->nn) -#define ALPHA_TO (rs->alpha_to) -#define INDEX_OF (rs->index_of) -#define GENPOLY (rs->genpoly) -#define NROOTS (rs->nroots) -#define FCR (rs->fcr) -#define PRIM (rs->prim) -#define IPRIM (rs->iprim) -#define A0 (NN) - -#define ENCODE_RS encode_rs_char -#define DECODE_RS decode_rs_char -#define INIT_RS init_rs_char -#define FREE_RS free_rs_char - -GR_CORE_API void ENCODE_RS(void *p,DTYPE *data,DTYPE *parity); -GR_CORE_API int DECODE_RS(void *p,DTYPE *data,int *eras_pos,int no_eras); -GR_CORE_API void *INIT_RS(unsigned int symsize,unsigned int gfpoly,unsigned int fcr, - unsigned int prim,unsigned int nroots); -GR_CORE_API void FREE_RS(void *p); - - - - diff --git a/gnuradio-core/src/lib/reed-solomon/decode_rs.c b/gnuradio-core/src/lib/reed-solomon/decode_rs.c deleted file mode 100644 index f9438cf266..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/decode_rs.c +++ /dev/null @@ -1,270 +0,0 @@ -/* Reed-Solomon decoder - * Copyright 2002 Phil Karn, KA9Q - * May be used under the terms of the GNU General Public License (GPL) - */ - -#ifdef DEBUG -#include <stdio.h> -#endif - -#include <string.h> - -#define NULL ((void *)0) -#define min(a,b) ((a) < (b) ? (a) : (b)) - -#ifdef FIXED -#include "fixed.h" -#elif defined(BIGSYM) -#include "int.h" -#else -#include "char.h" -#endif - -int DECODE_RS( -#ifndef FIXED -void *p, -#endif -DTYPE *data, int *eras_pos, int no_eras){ - -#ifndef FIXED - struct rs *rs = (struct rs *)p; -#endif - int deg_lambda, el, deg_omega; - int i, j, r, k; -#ifdef MAX_ARRAY - DTYPE u,q,tmp,num1,num2,den,discr_r; - DTYPE lambda[MAX_ARRAY], s[MAX_ARRAY]; /* Err+Eras Locator poly - * and syndrome poly */ - DTYPE b[MAX_ARRAY], t[MAX_ARRAY], omega[MAX_ARRAY]; - DTYPE root[MAX_ARRAY], reg[MAX_ARRAY], loc[MAX_ARRAY]; -#else - DTYPE u,q,tmp,num1,num2,den,discr_r; - DTYPE lambda[NROOTS+1], s[NROOTS]; /* Err+Eras Locator poly - * and syndrome poly */ - DTYPE b[NROOTS+1], t[NROOTS+1], omega[NROOTS+1]; - DTYPE root[NROOTS], reg[NROOTS+1], loc[NROOTS]; -#endif - int syn_error, count; - - /* form the syndromes; i.e., evaluate data(x) at roots of g(x) */ - for(i=0;(unsigned int)i<NROOTS;i++) - s[i] = data[0]; - - for(j=1;(unsigned int)j<NN;j++){ - for(i=0;(unsigned int)i<NROOTS;i++){ - if(s[i] == 0){ - s[i] = data[j]; - } else { - s[i] = data[j] ^ ALPHA_TO[MODNN(INDEX_OF[s[i]] + (FCR+i)*PRIM)]; - } - } - } - - /* Convert syndromes to index form, checking for nonzero condition */ - syn_error = 0; - for(i=0;(unsigned int)i<NROOTS;i++){ - syn_error |= s[i]; - s[i] = INDEX_OF[s[i]]; - } - - if (!syn_error) { - /* if syndrome is zero, data[] is a codeword and there are no - * errors to correct. So return data[] unmodified - */ - count = 0; - goto finish; - } - memset(&lambda[1],0,NROOTS*sizeof(lambda[0])); - lambda[0] = 1; - - if (no_eras > 0) { - /* Init lambda to be the erasure locator polynomial */ - lambda[1] = ALPHA_TO[MODNN(PRIM*(NN-1-eras_pos[0]))]; - for (i = 1; i < no_eras; i++) { - u = MODNN(PRIM*(NN-1-eras_pos[i])); - for (j = i+1; j > 0; j--) { - tmp = INDEX_OF[lambda[j - 1]]; - if(tmp != A0) - lambda[j] ^= ALPHA_TO[MODNN(u + tmp)]; - } - } - -#if DEBUG >= 1 - /* Test code that verifies the erasure locator polynomial just constructed - Needed only for decoder debugging. */ - - /* find roots of the erasure location polynomial */ - for(i=1;i<=no_eras;i++) - reg[i] = INDEX_OF[lambda[i]]; - - count = 0; - for (i = 1,k=IPRIM-1; i <= NN; i++,k = MODNN(k+IPRIM)) { - q = 1; - for (j = 1; j <= no_eras; j++) - if (reg[j] != A0) { - reg[j] = MODNN(reg[j] + j); - q ^= ALPHA_TO[reg[j]]; - } - if (q != 0) - continue; - /* store root and error location number indices */ - root[count] = i; - loc[count] = k; - count++; - } - if (count != no_eras) { - printf("count = %d no_eras = %d\n lambda(x) is WRONG\n",count,no_eras); - count = -1; - goto finish; - } -#if DEBUG >= 2 - printf("\n Erasure positions as determined by roots of Eras Loc Poly:\n"); - for (i = 0; i < count; i++) - printf("%d ", loc[i]); - printf("\n"); -#endif -#endif - } - for(i=0;(unsigned int)i<NROOTS+1;i++) - b[i] = INDEX_OF[lambda[i]]; - - /* - * Begin Berlekamp-Massey algorithm to determine error+erasure - * locator polynomial - */ - r = no_eras; - el = no_eras; - while ((unsigned int)(++r) <= NROOTS) { /* r is the step number */ - /* Compute discrepancy at the r-th step in poly-form */ - discr_r = 0; - for (i = 0; i < r; i++){ - if ((lambda[i] != 0) && (s[r-i-1] != A0)) { - discr_r ^= ALPHA_TO[MODNN(INDEX_OF[lambda[i]] + s[r-i-1])]; - } - } - discr_r = INDEX_OF[discr_r]; /* Index form */ - if (discr_r == A0) { - /* 2 lines below: B(x) <-- x*B(x) */ - memmove(&b[1],b,NROOTS*sizeof(b[0])); - b[0] = A0; - } else { - /* 7 lines below: T(x) <-- lambda(x) - discr_r*x*b(x) */ - t[0] = lambda[0]; - for (i = 0 ; (unsigned int)i < NROOTS; i++) { - if(b[i] != A0) - t[i+1] = lambda[i+1] ^ ALPHA_TO[MODNN(discr_r + b[i])]; - else - t[i+1] = lambda[i+1]; - } - if (2 * el <= r + no_eras - 1) { - el = r + no_eras - el; - /* - * 2 lines below: B(x) <-- inv(discr_r) * - * lambda(x) - */ - for (i = 0; (unsigned int)i <= NROOTS; i++) - b[i] = (lambda[i] == 0) ? A0 : MODNN(INDEX_OF[lambda[i]] - discr_r + NN); - } else { - /* 2 lines below: B(x) <-- x*B(x) */ - memmove(&b[1],b,NROOTS*sizeof(b[0])); - b[0] = A0; - } - memcpy(lambda,t,(NROOTS+1)*sizeof(t[0])); - } - } - - /* Convert lambda to index form and compute deg(lambda(x)) */ - deg_lambda = 0; - for(i=0;(unsigned int)i<NROOTS+1;i++){ - lambda[i] = INDEX_OF[lambda[i]]; - if(lambda[i] != A0) - deg_lambda = i; - } - /* Find roots of the error+erasure locator polynomial by Chien search */ - memcpy(®[1],&lambda[1],NROOTS*sizeof(reg[0])); - count = 0; /* Number of roots of lambda(x) */ - for (i = 1,k=IPRIM-1; (unsigned int)i <= NN; i++,k = MODNN(k+IPRIM)) { - q = 1; /* lambda[0] is always 0 */ - for (j = deg_lambda; j > 0; j--){ - if (reg[j] != A0) { - reg[j] = MODNN(reg[j] + j); - q ^= ALPHA_TO[reg[j]]; - } - } - if (q != 0) - continue; /* Not a root */ - /* store root (index-form) and error location number */ -#if DEBUG>=2 - printf("count %d root %d loc %d\n",count,i,k); -#endif - root[count] = i; - loc[count] = k; - /* If we've already found max possible roots, - * abort the search to save time - */ - if(++count == deg_lambda) - break; - } - if (deg_lambda != count) { - /* - * deg(lambda) unequal to number of roots => uncorrectable - * error detected - */ - count = -1; - goto finish; - } - /* - * Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo - * x**NROOTS). in index form. Also find deg(omega). - */ - deg_omega = 0; - for (i = 0; (unsigned int)i < NROOTS;i++){ - tmp = 0; - j = (deg_lambda < i) ? deg_lambda : i; - for(;j >= 0; j--){ - if ((s[i - j] != A0) && (lambda[j] != A0)) - tmp ^= ALPHA_TO[MODNN(s[i - j] + lambda[j])]; - } - if(tmp != 0) - deg_omega = i; - omega[i] = INDEX_OF[tmp]; - } - omega[NROOTS] = A0; - - /* - * Compute error values in poly-form. num1 = omega(inv(X(l))), num2 = - * inv(X(l))**(FCR-1) and den = lambda_pr(inv(X(l))) all in poly-form - */ - for (j = count-1; j >=0; j--) { - num1 = 0; - for (i = deg_omega; i >= 0; i--) { - if (omega[i] != A0) - num1 ^= ALPHA_TO[MODNN(omega[i] + i * root[j])]; - } - num2 = ALPHA_TO[MODNN(root[j] * (FCR - 1) + NN)]; - den = 0; - - /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */ - for (i = (int)min((unsigned int)deg_lambda,NROOTS-1) & ~1; i >= 0; i -=2) { - if(lambda[i+1] != A0) - den ^= ALPHA_TO[MODNN(lambda[i+1] + i * root[j])]; - } - if (den == 0) { -#if DEBUG >= 1 - printf("\n ERROR: denominator = 0\n"); -#endif - count = -1; - goto finish; - } - /* Apply error to data */ - if (num1 != 0) { - data[loc[j]] ^= ALPHA_TO[MODNN(INDEX_OF[num1] + INDEX_OF[num2] + NN - INDEX_OF[den])]; - } - } - finish: - if(eras_pos != NULL){ - for(i=0;i<count;i++) - eras_pos[i] = loc[i]; - } - return count; -} diff --git a/gnuradio-core/src/lib/reed-solomon/decode_rs_ccsds.c b/gnuradio-core/src/lib/reed-solomon/decode_rs_ccsds.c deleted file mode 100644 index 2543d3a640..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/decode_rs_ccsds.c +++ /dev/null @@ -1,27 +0,0 @@ -/* This function wraps around the fixed 8-bit decoder, performing the - * basis transformations necessary to meet the CCSDS standard - * - * Copyright 2002, Phil Karn, KA9Q - * May be used under the terms of the GNU General Public License (GPL) - */ -#define FIXED 1 -#include "fixed.h" -#include "ccsds.h" - -int decode_rs_ccsds(unsigned char *data,int *eras_pos,int no_eras){ - int i,r; - unsigned char cdata[NN]; - - /* Convert data from dual basis to conventional */ - for(i=0;i<NN;i++) - cdata[i] = Tal1tab[data[i]]; - - r = decode_rs_8(cdata,eras_pos,no_eras); - - if(r > 0){ - /* Convert from conventional to dual basis */ - for(i=0;i<NN;i++) - data[i] = Taltab[cdata[i]]; - } - return r; -} diff --git a/gnuradio-core/src/lib/reed-solomon/encode_rs.c b/gnuradio-core/src/lib/reed-solomon/encode_rs.c deleted file mode 100644 index cd31f32c6e..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/encode_rs.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Reed-Solomon encoder - * Copyright 2002, Phil Karn, KA9Q - * May be used under the terms of the GNU General Public License (GPL) - */ -#include <string.h> - -#ifdef FIXED -#include "fixed.h" -#elif defined(BIGSYM) -#include "int.h" -#else -#include "char.h" -#endif - -void ENCODE_RS( -#ifndef FIXED -void *p, -#endif -DTYPE *data, DTYPE *bb){ -#ifndef FIXED - struct rs *rs = (struct rs *)p; -#endif - unsigned int i, j; - DTYPE feedback; - - memset(bb,0,NROOTS*sizeof(DTYPE)); - - for(i=0;i<NN-NROOTS;i++){ - feedback = INDEX_OF[data[i] ^ bb[0]]; - if(feedback != A0){ /* feedback term is non-zero */ -#ifdef UNNORMALIZED - /* This line is unnecessary when GENPOLY[NROOTS] is unity, as it must - * always be for the polynomials constructed by init_rs() - */ - feedback = MODNN(NN - GENPOLY[NROOTS] + feedback); -#endif - for(j=1;j<NROOTS;j++) - bb[j] ^= ALPHA_TO[MODNN(feedback + GENPOLY[NROOTS-j])]; - } - /* Shift */ - memmove(&bb[0],&bb[1],sizeof(DTYPE)*(NROOTS-1)); - if(feedback != A0) - bb[NROOTS-1] = ALPHA_TO[MODNN(feedback + GENPOLY[0])]; - else - bb[NROOTS-1] = 0; - } -} diff --git a/gnuradio-core/src/lib/reed-solomon/encode_rs_ccsds.c b/gnuradio-core/src/lib/reed-solomon/encode_rs_ccsds.c deleted file mode 100644 index a748b34689..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/encode_rs_ccsds.c +++ /dev/null @@ -1,24 +0,0 @@ -/* This function wraps around the fixed 8-bit encoder, performing the - * basis transformations necessary to meet the CCSDS standard - * - * Copyright 2002, Phil Karn, KA9Q - * May be used under the terms of the GNU General Public License (GPL) - */ -#define FIXED -#include "fixed.h" -#include "ccsds.h" - -void encode_rs_ccsds(unsigned char *data,unsigned char *parity){ - int i; - unsigned char cdata[NN-NROOTS]; - - /* Convert data from dual basis to conventional */ - for(i=0;i<NN-NROOTS;i++) - cdata[i] = Tal1tab[data[i]]; - - encode_rs_8(cdata,parity); - - /* Convert parity from conventional to dual basis */ - for(i=0;i<NN-NROOTS;i++) - parity[i] = Taltab[parity[i]]; -} diff --git a/gnuradio-core/src/lib/reed-solomon/exercise.c b/gnuradio-core/src/lib/reed-solomon/exercise.c deleted file mode 100644 index de33a6bff3..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/exercise.c +++ /dev/null @@ -1,134 +0,0 @@ -/* Exercise an RS codec a specified number of times using random - * data and error patterns - * - * Copyright 2002 Phil Karn, KA9Q - * May be used under the terms of the GNU General Public License (GPL) - */ -#define FLAG_ERASURE 1 /* Randomly flag 50% of errors as erasures */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#ifdef FIXED -#include "fixed.h" -#define EXERCISE exercise_8 -#elif defined(CCSDS) -#include "fixed.h" -#include "ccsds.h" -#define EXERCISE exercise_ccsds -#elif defined(BIGSYM) -#include "int.h" -#define EXERCISE exercise_int -#else -#include "char.h" -#define EXERCISE exercise_char -#endif - -#ifdef FIXED -#define PRINTPARM printf("(255,223):"); -#elif defined(CCSDS) -#define PRINTPARM printf("CCSDS (255,223):"); -#else -#define PRINTPARM printf("(%d,%d):",rs->nn,rs->nn-rs->nroots); -#endif - -/* Exercise the RS codec passed as an argument */ -int EXERCISE( -#if !defined(CCSDS) && !defined(FIXED) -void *p, -#endif -int trials){ -#if !defined(CCSDS) && !defined(FIXED) - struct rs *rs = (struct rs *)p; -#endif -#if MAX_ARRAY - DTYPE block[MAX_ARRAY],tblock[MAX_ARRAY]; - unsigned int i; - int errors; - int errlocs[MAX_ARRAY]; - int derrlocs[MAX_ARRAY]; -#else - DTYPE block[NN],tblock[NN]; - unsigned int i; - int errors; - int errlocs[NN]; - int derrlocs[NROOTS]; -#endif - int derrors; - int errval,errloc; - int erasures; - int decoder_errors = 0; - - while(trials-- != 0){ - /* Test up to the error correction capacity of the code */ - for(errors=0;(unsigned int)errors <= NROOTS/2;errors++){ - - /* Load block with random data and encode */ - for(i=0;i<NN-NROOTS;i++) - block[i] = random() & NN; - -#if defined(CCSDS) || defined(FIXED) - ENCODE_RS(&block[0],&block[NN-NROOTS]); -#else - ENCODE_RS(rs,&block[0],&block[NN-NROOTS]); -#endif - - /* Make temp copy, seed with errors */ - memcpy(tblock,block,sizeof(tblock)); - memset(errlocs,0,sizeof(errlocs)); - memset(derrlocs,0,sizeof(derrlocs)); - erasures=0; - for(i=0;i<(unsigned int)errors;i++){ - do { - errval = random() & NN; - } while(errval == 0); /* Error value must be nonzero */ - - do { - errloc = random() % NN; - } while(errlocs[errloc] != 0); /* Must not choose the same location twice */ - - errlocs[errloc] = 1; - -#if FLAG_ERASURE - if(random() & 1) /* 50-50 chance */ - derrlocs[erasures++] = errloc; -#endif - tblock[errloc] ^= errval; - } - - /* Decode the errored block */ -#if defined(CCSDS) || defined(FIXED) - derrors = DECODE_RS(tblock,derrlocs,erasures); -#else - derrors = DECODE_RS(rs,tblock,derrlocs,erasures); -#endif - - if(derrors != errors){ - PRINTPARM - printf(" decoder says %d errors, true number is %d\n",derrors,errors); - decoder_errors++; - } - for(i=0;i<(unsigned int)derrors;i++){ - if(errlocs[derrlocs[i]] == 0){ - PRINTPARM - printf(" decoder indicates error in location %d without error\n",i); - decoder_errors++; - } - } - if(memcmp(tblock,block,sizeof(tblock)) != 0){ - PRINTPARM - printf(" uncorrected errors! output ^ input:"); - decoder_errors++; - for(i=0;i<NN;i++) - printf(" %02x",tblock[i] ^ block[i]); - printf("\n"); - } - } - } - return decoder_errors; -} diff --git a/gnuradio-core/src/lib/reed-solomon/fixed.h b/gnuradio-core/src/lib/reed-solomon/fixed.h deleted file mode 100644 index 30091e7bf3..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/fixed.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Configure the RS codec with fixed parameters for CCSDS standard - * (255,223) code over GF(256). Note: the conventional basis is still - * used; the dual-basis mappings are performed in [en|de]code_rs_ccsds.c - * - * Copyright 2002 Phil Karn, KA9Q - * May be used under the terms of the GNU General Public License (GPL) - */ -#define DTYPE unsigned char - -#include <gr_core_api.h> - -static inline int mod255(int x){ - while (x >= 255) { - x -= 255; - x = (x >> 8) + (x & 255); - } - return x; -} -#define MODNN(x) mod255(x) - -extern unsigned char CCSDS_alpha_to[]; -extern unsigned char CCSDS_index_of[]; -extern unsigned char CCSDS_poly[]; - -#define MM 8 -#define NN 255 -#define ALPHA_TO CCSDS_alpha_to -#define INDEX_OF CCSDS_index_of -#define GENPOLY CCSDS_poly -#define NROOTS 32 -#define FCR 112 -#define PRIM 11 -#define IPRIM 116 -#define A0 (NN) - -#define ENCODE_RS encode_rs_8 -#define DECODE_RS decode_rs_8 - -GR_CORE_API void ENCODE_RS(DTYPE *data,DTYPE *parity); -GR_CORE_API int DECODE_RS(DTYPE *data, int *eras_pos, int no_eras);
\ No newline at end of file diff --git a/gnuradio-core/src/lib/reed-solomon/gen_ccsds.c b/gnuradio-core/src/lib/reed-solomon/gen_ccsds.c deleted file mode 100644 index 1e4e4f5363..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/gen_ccsds.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Generate tables for CCSDS code - * Copyright 2002 Phil Karn, KA9Q - * May be used under the terms of the GNU General Public License (GPL) - */ -#include <stdio.h> -#include "char.h" - -int main(){ - struct rs *rs; - int i; - - rs = init_rs_char(8,0x187,112,11,32); /* CCSDS standard */ - printf("unsigned char CCSDS_alpha_to[] = {"); - for(i=0;i<256;i++){ - if((i % 16) == 0) - printf("\n"); - printf("0x%02x,",rs->alpha_to[i]); - } - printf("\n};\n\nunsigned char CCSDS_index_of[] = {"); - for(i=0;i<256;i++){ - if((i % 16) == 0) - printf("\n"); - printf("%3d,",rs->index_of[i]); - } - printf("\n};\n\nunsigned char CCSDS_poly[] = {"); - for(i=0;i<33;i++){ - if((i % 16) == 0) - printf("\n"); - - printf("%3d,",rs->genpoly[i]); - } - printf("\n};\n"); - exit(0); -} diff --git a/gnuradio-core/src/lib/reed-solomon/gen_ccsds_tal.c b/gnuradio-core/src/lib/reed-solomon/gen_ccsds_tal.c deleted file mode 100644 index 9dde18917b..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/gen_ccsds_tal.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Conversion lookup tables from conventional alpha to Berlekamp's - * dual-basis representation. Used in the CCSDS version only. - * taltab[] -- convert conventional to dual basis - * tal1tab[] -- convert dual basis to conventional - - * Note: the actual RS encoder/decoder works with the conventional basis. - * So data is converted from dual to conventional basis before either - * encoding or decoding and then converted back. - * - * Copyright 2002 Phil Karn, KA9Q - * May be used under the terms of the GNU General Public License (GPL) - */ -#include <stdio.h> -unsigned char Taltab[256],Tal1tab[256]; - -static unsigned char tal[] = { 0x8d, 0xef, 0xec, 0x86, 0xfa, 0x99, 0xaf, 0x7b }; - -/* Generate conversion lookup tables between conventional alpha representation - * (@**7, @**6, ...@**0) - * and Berlekamp's dual basis representation - * (l0, l1, ...l7) - */ -int main(){ - int i,j,k; - - for(i=0;i<256;i++){/* For each value of input */ - Taltab[i] = 0; - for(j=0;j<8;j++) /* for each column of matrix */ - for(k=0;k<8;k++){ /* for each row of matrix */ - if(i & (1<<k)) - Taltab[i] ^= tal[7-k] & (1<<j); - } - Tal1tab[Taltab[i]] = i; - } - printf("unsigned char Taltab[] = {\n"); - for(i=0;i<256;i++){ - if((i % 16) == 0) - printf("\n"); - printf("0x%02x,",Taltab[i]); - } - printf("\n};\n\nunsigned char Tal1tab[] = {"); - for(i=0;i<256;i++){ - if((i % 16) == 0) - printf("\n"); - printf("0x%02x,",Tal1tab[i]); - } - printf("\n};\n"); - exit(0); -} - diff --git a/gnuradio-core/src/lib/reed-solomon/init_rs.c b/gnuradio-core/src/lib/reed-solomon/init_rs.c deleted file mode 100644 index 4ec77cd723..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/init_rs.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Initialize a RS codec - * - * Copyright 2002 Phil Karn, KA9Q - * May be used under the terms of the GNU General Public License (GPL) - */ -#include <stdlib.h> - -#ifdef CCSDS -#include "ccsds.h" -#elif defined(BIGSYM) -#include "int.h" -#else -#include "char.h" -#endif - -#define NULL ((void *)0) - -void FREE_RS(void *p){ - struct rs *rs = (struct rs *)p; - - free(rs->alpha_to); - free(rs->index_of); - free(rs->genpoly); - free(rs); -} - -/* Initialize a Reed-Solomon codec - * symsize = symbol size, bits (1-8) - * gfpoly = Field generator polynomial coefficients - * fcr = first root of RS code generator polynomial, index form - * prim = primitive element to generate polynomial roots - * nroots = RS code generator polynomial degree (number of roots) - */ -void *INIT_RS(unsigned int symsize,unsigned int gfpoly,unsigned fcr,unsigned prim, - unsigned int nroots){ - struct rs *rs; - int sr,root,iprim; - unsigned int i, j; - - if(symsize > 8*sizeof(DTYPE)) - return NULL; /* Need version with ints rather than chars */ - - if(fcr >= (1u<<symsize)) - return NULL; - if(prim == 0 || prim >= (1u<<symsize)) - return NULL; - if(nroots >= (1u<<symsize)) - return NULL; /* Can't have more roots than symbol values! */ - - rs = (struct rs *)calloc(1,sizeof(struct rs)); - rs->mm = symsize; - rs->nn = (1<<symsize)-1; - - rs->alpha_to = (DTYPE *)malloc(sizeof(DTYPE)*(rs->nn+1)); - if(rs->alpha_to == NULL){ - free(rs); - return NULL; - } - rs->index_of = (DTYPE *)malloc(sizeof(DTYPE)*(rs->nn+1)); - if(rs->index_of == NULL){ - free(rs->alpha_to); - free(rs); - return NULL; - } - - /* Generate Galois field lookup tables */ - rs->index_of[0] = A0; /* log(zero) = -inf */ - rs->alpha_to[A0] = 0; /* alpha**-inf = 0 */ - sr = 1; - for(i=0;i<rs->nn;i++){ - rs->index_of[sr] = i; - rs->alpha_to[i] = sr; - sr <<= 1; - if(sr & (1<<symsize)) - sr ^= gfpoly; - sr &= rs->nn; - } - if(sr != 1){ - /* field generator polynomial is not primitive! */ - free(rs->alpha_to); - free(rs->index_of); - free(rs); - return NULL; - } - - /* Form RS code generator polynomial from its roots */ - rs->genpoly = (DTYPE *)malloc(sizeof(DTYPE)*(nroots+1)); - if(rs->genpoly == NULL){ - free(rs->alpha_to); - free(rs->index_of); - free(rs); - return NULL; - } - rs->fcr = fcr; - rs->prim = prim; - rs->nroots = nroots; - - /* Find prim-th root of 1, used in decoding */ - for(iprim=1;(iprim % prim) != 0;iprim += rs->nn) - ; - rs->iprim = iprim / prim; - - rs->genpoly[0] = 1; - for (i = 0,root=fcr*prim; i < nroots; i++,root += prim) { - rs->genpoly[i+1] = 1; - - /* Multiply rs->genpoly[] by @**(root + x) */ - for (j = i; j > 0; j--){ - if (rs->genpoly[j] != 0) - rs->genpoly[j] = rs->genpoly[j-1] ^ rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[j]] + root)]; - else - rs->genpoly[j] = rs->genpoly[j-1]; - } - /* rs->genpoly[0] can never be zero */ - rs->genpoly[0] = rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[0]] + root)]; - } - /* convert rs->genpoly[] to index form for quicker encoding */ - for (i = 0; i <= nroots; i++) - rs->genpoly[i] = rs->index_of[rs->genpoly[i]]; - -#if 0 - printf ("genpoly:\n"); - for (i = nroots; i >= 0; i--){ - printf (" %3d*X^%d\n", rs->alpha_to[rs->genpoly[i]], i); - } -#endif - - return rs; -} diff --git a/gnuradio-core/src/lib/reed-solomon/int.h b/gnuradio-core/src/lib/reed-solomon/int.h deleted file mode 100644 index 403d68757b..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/int.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Include file to configure the RS codec for integer symbols - * - * Copyright 2002, Phil Karn, KA9Q - * May be used under the terms of the GNU General Public License (GPL) - */ -#define DTYPE int - -#include <gr_core_api.h> - -/* Reed-Solomon codec control block */ -struct GR_CORE_API rs { - unsigned int mm; /* Bits per symbol */ - unsigned int nn; /* Symbols per block (= (1<<mm)-1) */ - int *alpha_to; /* log lookup table */ - int *index_of; /* Antilog lookup table */ - int *genpoly; /* Generator polynomial */ - unsigned int nroots; /* Number of generator roots = number of parity symbols */ - unsigned int fcr; /* First consecutive root, index form */ - unsigned int prim; /* Primitive element, index form */ - unsigned int iprim; /* prim-th root of 1, index form */ -}; - -static inline int modnn(struct rs *rs,int x){ - while (x >= rs->nn) { - x -= rs->nn; - x = (x >> rs->mm) + (x & rs->nn); - } - return x; -} -#define MODNN(x) modnn(rs,x) - -#define MM (rs->mm) -#define NN (rs->nn) -#define ALPHA_TO (rs->alpha_to) -#define INDEX_OF (rs->index_of) -#define GENPOLY (rs->genpoly) -#define NROOTS (rs->nroots) -#define FCR (rs->fcr) -#define PRIM (rs->prim) -#define IPRIM (rs->iprim) -#define A0 (NN) - -#define ENCODE_RS encode_rs_int -#define DECODE_RS decode_rs_int -#define INIT_RS init_rs_int -#define FREE_RS free_rs_int - -GR_CORE_API void ENCODE_RS(void *p,DTYPE *data,DTYPE *parity); -GR_CORE_API int DECODE_RS(void *p,DTYPE *data,int *eras_pos,int no_eras); -void *INIT_RS(unsigned int symsize,unsigned int gfpoly,unsigned int fcr, - unsigned int prim,unsigned int nroots); -GR_CORE_API void FREE_RS(void *p); - - - diff --git a/gnuradio-core/src/lib/reed-solomon/rs.3 b/gnuradio-core/src/lib/reed-solomon/rs.3 deleted file mode 100644 index c3953ce57a..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/rs.3 +++ /dev/null @@ -1,170 +0,0 @@ -.TH REED-SOLOMON 3 -.SH NAME -init_rs_int, encode_rs_int, decode_rs_int, free_rs_int, -init_rs_char, encode_rs_char, decode_rs_char, free_rs_char, -encode_rs_8, decode_rs_8, encode_rs_ccsds, decode_rs_ccsds -.SH SYNOPSIS -.nf -.ft B -#include "rs.h" - -void *init_rs_int(unsigned int symsize,unsigned int gfpoly,unsigned fcr, -unsigned prim,unsigned int nroots); -void encode_rs_int(void *rs,int *data,int *parity); -int decode_rs_int(void *rs,int *data,int *eras_pos,int no_eras); -void free_rs_int(void *rs); - -void *init_rs_char(unsigned int symsize,unsigned int gfpoly,unsigned fcr, -unsigned prim,unsigned int nroots); -void encode_rs_char(void *rs,unsigned char *data,unsigned char *parity); -int decode_rs_char(void *rs,unsigned char *data,int *eras_pos,int no_eras); -void free_rs_char(void *rs); - -void encode_rs_8(unsigned char *data,unsigned char *parity); -int decode_rs_8(unsigned char *data,int *eras_pos,int no_eras); - -void encode_rs_ccsds(unsigned char *data,unsigned char *parity); -int decode_rs_ccsds(unsigned char *data,int *eras_pos,int no_eras); - -unsigned char Taltab[256]; -unsigned char Tal1tab[256]; - -.fi - -.SH DESCRIPTION -These functions implement Reed-Solomon error control encoding and -decoding. For optimal performance in a variety of applications, three -sets of functions are supplied. To access these functions, add "-lrs" -to your linker command line. - -The functions with names ending in "_int" handle data in integer arrays, -permitting arbitrarily large codewords limited only by machine -resources. - -The functions with names ending in "_char" take unsigned char arrays and can -handle codes with symbols of 8 bits or less (i.e., with codewords of -255 symbols or less). - -\fBencode_rs_8\fR and \fBdecode_rs_8\fR implement a specific -(255,223) code with 8-bit symbols specified by the CCSDS: -a field generator of 1 + X + X^2 + X^7 + X^8 and a code -generator with first consecutive root = 112 and a primitive element of -11. These functions use the conventional -polynomial form, \fBnot\fR the dual-basis specified in -the CCSDS standard, to represent symbols. - -For full CCSDS compatibility, \fBencode_rs_ccsds\fR and -\fBdecode_rs_ccsds\fR are provided. These functions use two lookup -tables, \fBTaltab\fR to convert from conventional to dual-basis, and -\fBTal1tab\fR to perform the inverse mapping from dual-basis to -conventional form, before and after calls to \fBencode_rs_8\fR -and \fBdecode_rs_8\fR. - -The _8 and _ccsds functions do not require initialization. -To use the general purpose RS encoder or decoder (i.e., -the _char or _int versions), the user must first -call \fBinit_rs_int\fR or \fBinit_rs_char\fR as appropriate. The -arguments are as follows: - -\fBsymsize\fR gives the symbol size in bits, up to 8 for \fBinit_rs_char\fR -or 32 for \fBinit_rs_int\fR on a machine with 32-bit ints (though such a -huge code would exhaust memory limits on a 32-bit machine). The resulting -Reed-Solomon code word will have 2^\fBsymsize\fR - 1 symbols, -each containing \fBsymsize\fR bits. - -\fBgfpoly\fR gives the extended Galois field generator polynomial coefficients, -with the 0th coefficient in the low order bit. The polynomial -\fImust\fR be primitive; if not, the call will fail and NULL will be -returned. - -\fBfcr\fR gives, in index form, the first consecutive root of the -Reed Solomon code generator polynomial. - -\fBprim\fR gives, in index form, the primitive element in the Galois field -used to generate the Reed Solomon code generator polynomial. - -\fBnroots\fR gives the number of roots in the Reed Solomon code -generator polynomial. This equals the number of parity symbols -per code block. - -The resulting Reed-Solomon code has parameters (N,K), where -N = 2^\fBsymsize\fR-1 and K = N-\fBnroots\fR. - -The \fBencode_rs_char\fR and \fBencode_rs_int\fR functions accept -the pointer returned by \fBinit_rs_char\fR or -\fBinit_rs_int\fR, respectively, to -encode a block of data using the specified code. -The input data array is expected to -contain K symbols (of \fBsymsize\fR bits each, right justified -in each char or int) and \fBnroots\fR parity symbols will be placed -into the \fBparity\fR array, right justified. - -The \fBdecode_rs_char\fR and \fBdecode_rs_int\fR functions correct -the errors in a Reed-Solomon codeword up to the capability of the code. -An optional list of "erased" symbol indices may be given in the \fBeras_pos\fR -array to assist the decoder; this parameter may be NULL if no erasures -are given. The number of erased symbols must be given in the \fBno_eras\fR -parameter. - -To maximize performance, the encode and decode functions perform no -"sanity checking" of their inputs. Decoder failure may result if -\fBeras_pos\fR contains duplicate entries, and both encoder and -decoder will fail if an input symbol exceeds its allowable range. -(Symbol range overflow cannot occur with the _8 or _ccsds functions, -or with the _char functions when 8-bit symbols are specified.) - -The decoder corrects the symbols "in place", returning the number -of symbols in error. If the codeword is uncorrectable, -1 is returned -and the data block is unchanged. If \fBeras_pos\fR is non-null, it is -used to return a list of corrected symbol positions, in no particular -order. This means that the -array passed through this parameter \fImust\fR have at least \fBnroots\fR -elements to prevent a possible buffer overflow. - -The \fBfree_rs_int\fR and \fBfree_rs_char\fR functions free the internal -space allocated by the \fBinit_rs_int\fR and \fBinit_rs_char\fR functions, -respecitively. - -The functions \fBencode_rs_8\fR and \fBdecode_rs_8\fR do not have -corresponding \fBinit\fR and \fBfree\fR, nor do they take the -\fBrs\fR argument accepted by the other functions as their parameters -are statically compiled. These functions implement a code -equivalent to calling - -\fBinit_rs_char\fR(8,0x187,112,11,32); - -and using the resulting pointer with \fBencode_rs_char\fR and -\fBdecode_rs_char\fR. - -.SH RETURN VALUES -\fBinit_rs_int\fR and \fBinit_rs_char\fR return a pointer to an internal -control structure that must be passed to the corresponding encode, decode -and free functions. These functions return NULL on error. - -The decode functions return a count of corrected -symbols, or -1 if the block was uncorrectible. - -.SH AUTHOR -Phil Karn, KA9Q (karn@ka9q.net), based heavily on earlier work by Robert -Morelos-Zaragoza (rober@spectra.eng.hawaii.edu) and Hari Thirumoorthy -(harit@spectra.eng.hawaii.edu). - -.SH COPYRIGHT -Copyright 2002, Phil Karn, KA9Q. May be used under the terms of the -GNU General Public License (GPL). - -.SH SEE ALSO -CCSDS 101.0-B-5: Telemetry Channel Coding. -http://www.ccsds.org/documents/pdf/CCSDS-101.0-B-5.pdf - -.SH NOTE -CCSDS chose the "dual basis" symbol representation because it -simplified the implementation of a Reed-Solomon encoder in dedicated -hardware. However, this approach holds no advantages for a software -implementation on a general purpose computer, so use of the dual basis -is recommended only if compatibility with the CCSDS standard is needed, -e.g., to decode data from an existing spacecraft using the CCSDS -standard. If you just want a fast (255,223) RS codec without needing -to interoperate with a CCSDS standard code, use \fBencode_rs_8\fR -and \fBdecode_rs_8\fR. - diff --git a/gnuradio-core/src/lib/reed-solomon/rs.h b/gnuradio-core/src/lib/reed-solomon/rs.h deleted file mode 100644 index 97e78769ea..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/rs.h +++ /dev/null @@ -1,31 +0,0 @@ -#include <gr_core_api.h> -/* User include file for the Reed-Solomon codec - * Copyright 2002, Phil Karn KA9Q - * May be used under the terms of the GNU General Public License (GPL) - */ - -/* General purpose RS codec, 8-bit symbols */ -GR_CORE_API void encode_rs_char(void *rs,unsigned char *data,unsigned char *parity); -GR_CORE_API int decode_rs_char(void *rs,unsigned char *data,int *eras_pos, - int no_eras); -GR_CORE_API void *init_rs_char(unsigned int symsize,unsigned int gfpoly, - unsigned int fcr,unsigned int prim,unsigned int nroots); -GR_CORE_API void free_rs_char(void *rs); - -/* General purpose RS codec, integer symbols */ -GR_CORE_API void encode_rs_int(void *rs,int *data,int *parity); -GR_CORE_API int decode_rs_int(void *rs,int *data,int *eras_pos,int no_eras); -GR_CORE_API void *init_rs_int(unsigned int symsize,unsigned int gfpoly,unsigned int fcr, - unsigned int prim,unsigned int nroots); -GR_CORE_API void free_rs_int(void *rs); - -/* CCSDS standard (255,223) RS codec with conventional (*not* dual-basis) - * symbol representation - */ -GR_CORE_API void encode_rs_8(unsigned char *data,unsigned char *parity); -GR_CORE_API int decode_rs_8(unsigned char *data,int *eras_pos,int no_eras); - -/* Tables to map from conventional->dual (Taltab) and - * dual->conventional (Tal1tab) bases - */ -extern unsigned char Taltab[],Tal1tab[]; diff --git a/gnuradio-core/src/lib/reed-solomon/rstest.c b/gnuradio-core/src/lib/reed-solomon/rstest.c deleted file mode 100644 index d8fc5448a7..0000000000 --- a/gnuradio-core/src/lib/reed-solomon/rstest.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Test the Reed-Solomon codecs - * for various block sizes and with random data and random error patterns - * - * Copyright 2002 Phil Karn, KA9Q - * May be used under the terms of the GNU General Public License (GPL) - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include "rs.h" - -int exercise_char(void *,int); - -#ifdef ALL_VERSIONS -int exercise_int(void *,int); -int exercise_8(int); -int exercise_ccsds(int); -#endif - -struct { - int symsize; - int genpoly; - int fcs; - int prim; - int nroots; - int ntrials; -} Tab[] = { - {2, 0x7, 1, 1, 1, 10 }, - {3, 0xb, 1, 1, 2, 10 }, - {4, 0x13, 1, 1, 4, 10 }, - {5, 0x25, 1, 1, 6, 10 }, - {6, 0x43, 1, 1, 8, 10 }, - {7, 0x89, 1, 1, 10, 10 }, - {8, 0x11d, 1, 1, 32, 10 }, - {8, 0x187, 112,11, 32, 10 }, /* Duplicates CCSDS codec */ -#ifdef ALL_VESIONS - {9, 0x211, 1, 1, 32, 10 }, - {10,0x409, 1, 1, 32, 10 }, - {11,0x805, 1, 1, 32, 10 }, - {12,0x1053, 1, 1, 32, 5 }, - {13,0x201b, 1, 1, 32, 2 }, - {14,0x4443, 1, 1, 32, 1 }, - {15,0x8003, 1, 1, 32, 1 }, - {16,0x1100b, 1, 1, 32, 1 }, -#endif - {0, 0, 0, 0, 0}, -}; - -int main(){ - void *handle; - int errs,terrs; - int i; - - terrs = 0; - srandom(time(NULL)); - -#ifdef ALL_VERSIONS - printf("Testing fixed (255,223) RS codec..."); - fflush(stdout); - errs = exercise_8(10); - terrs += errs; - if(errs == 0){ - printf("OK\n"); - } - printf("Testing CCSDS standard (255,223) RS codec..."); - fflush(stdout); - errs = exercise_ccsds(10); - terrs += errs; - if(errs == 0){ - printf("OK\n"); - } -#endif - - for(i=0;Tab[i].symsize != 0;i++){ - int nn,kk; - - nn = (1<<Tab[i].symsize) - 1; - kk = nn - Tab[i].nroots; - printf("Testing (%d,%d) RS codec...",nn,kk); - fflush(stdout); - if(Tab[i].symsize <= 8){ - if((handle = init_rs_char(Tab[i].symsize,Tab[i].genpoly,Tab[i].fcs,Tab[i].prim,Tab[i].nroots)) == NULL){ - printf("init_rs_char failed!\n"); - continue; - } - errs = exercise_char(handle,Tab[i].ntrials); - } else { -#ifdef ALL_VERSIONS - if((handle = init_rs_int(Tab[i].symsize,Tab[i].genpoly,Tab[i].fcs,Tab[i].prim,Tab[i].nroots)) == NULL){ - printf("init_rs_int failed!\n"); - continue; - } - errs = exercise_int(handle,Tab[i].ntrials); -#else - printf ("init_rs_init support is not enabled\n"); - exit (1); -#endif - - } - terrs += errs; - if(errs == 0){ - printf("OK\n"); - } - free_rs_char(handle); - } - if(terrs == 0) - printf("All codec tests passed!\n"); - - exit(0); -} - - diff --git a/gnuradio-core/src/lib/runtime/CMakeLists.txt b/gnuradio-core/src/lib/runtime/CMakeLists.txt index 80db1e7e7e..a322d1b998 100644 --- a/gnuradio-core/src/lib/runtime/CMakeLists.txt +++ b/gnuradio-core/src/lib/runtime/CMakeLists.txt @@ -92,6 +92,20 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/gr_select_handler.cc ) +if(ENABLE_GR_CTRLPORT) +list(APPEND gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/ice_application_base.cc + ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_ice.cc + ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_booter_ice.cc + ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_booter_aggregator.cc + ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_aggregator.cc + ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_selector.cc + ${CMAKE_CURRENT_SOURCE_DIR}/rpcpmtconverters_ice.cc + ${CMAKE_CURRENT_SOURCE_DIR}/rpcmanager.cc +) +endif(ENABLE_GR_CTRLPORT) + + ######################################################################## # Append gnuradio-core test sources ######################################################################## @@ -162,6 +176,28 @@ install(FILES COMPONENT "core_devel" ) + +if(ENABLE_GR_CTRLPORT) +ADD_DEFINITIONS(-DGR_CTRLPORT) +INSTALL(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/ice_application_base.h + ${CMAKE_CURRENT_SOURCE_DIR}/ice_server_template.h + ${CMAKE_CURRENT_SOURCE_DIR}/rpccallbackregister_base.h + ${CMAKE_CURRENT_SOURCE_DIR}/rpcmanager_base.h + ${CMAKE_CURRENT_SOURCE_DIR}/rpcmanager.h + ${CMAKE_CURRENT_SOURCE_DIR}/rpcpmtconverters_ice.h + ${CMAKE_CURRENT_SOURCE_DIR}/rpcregisterhelpers.h + ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_aggregator.h + ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_base.h + ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_booter_aggregator.h + ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_booter_base.h + ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_booter_ice.h + ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_selector.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "core_devel" +) +endif(ENABLE_GR_CTRLPORT) + ######################################################################## # Install swig headers ######################################################################## diff --git a/gnuradio-core/src/lib/runtime/ICE_LICENSE b/gnuradio-core/src/lib/runtime/ICE_LICENSE new file mode 100644 index 0000000000..43ea7572d9 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/ICE_LICENSE @@ -0,0 +1,54 @@ +Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. + +This copy of Ice is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +Ice is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +details. + +You should have received a copy of the GNU General Public License version +2 along with this program; if not, see http://www.gnu.org/licenses. + +Linking Ice statically or dynamically with other software (such as a +library, module or application) is making a combined work based on Ice. +Thus, the terms and conditions of the GNU General Public License version +2 cover this combined work. + +If such software can only be used together with Ice, then not only the +combined work but the software itself is a work derived from Ice and as +such shall be licensed under the terms of the GNU General Public License +version 2. This includes the situation where Ice is only being used +through an abstraction layer. + +As a special exception to the above, ZeroC grants to the contributors for +the following projects the permission to license their Ice-based software +under the terms of the GNU Lesser General Public License (LGPL) version +2.1 or of the BSD license: + + - Orca Robotics (http://orca-robotics.sourceforge.net) + + - Mumble (http://mumble.sourceforge.net) + +This exception does not extend to the parts of Ice used by these +projects, or to any other derived work: as a whole, any work based on Ice +shall be licensed under the terms and conditions of the GNU General +Public License version 2. + +You may also combine Ice with any software not derived from Ice, provided +the license of such software is compatible with the GNU General Public +License version 2. In addition, as a special exception, ZeroC grants you +permission to combine Ice with: + + - the OpenSSL library, or with a modified version of the OpenSSL library + that uses the same license as OpenSSL + + - any library not derived from Ice and licensed under the terms of + the Apache License, version 2.0 + (http://www.apache.org/licenses/LICENSE-2.0.html) + +If you modify this copy of Ice, you may extend any of the exceptions +provided above to your version of Ice, but you are not obligated to +do so. diff --git a/gnuradio-core/src/lib/runtime/IcePy_Communicator.h b/gnuradio-core/src/lib/runtime/IcePy_Communicator.h new file mode 100644 index 0000000000..d613190d2c --- /dev/null +++ b/gnuradio-core/src/lib/runtime/IcePy_Communicator.h @@ -0,0 +1,35 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef ICEPY_COMMUNICATOR_H +#define ICEPY_COMMUNICATOR_H + +#include <Ice/CommunicatorF.h> +#include <gr_core_api.h> + +namespace IcePy +{ + +extern PyTypeObject CommunicatorType; + +GR_CORE_API bool initCommunicator(PyObject*); + +GR_CORE_API Ice::CommunicatorPtr getCommunicator(PyObject*); + +GR_CORE_API PyObject* createCommunicator(const Ice::CommunicatorPtr&); +GR_CORE_API PyObject* getCommunicatorWrapper(const Ice::CommunicatorPtr&); + +} + +extern "C" PyObject* IcePy_initialize(PyObject*, PyObject*); +extern "C" PyObject* IcePy_initializeWithProperties(PyObject*, PyObject*); +extern "C" PyObject* IcePy_initializeWithLogger(PyObject*, PyObject*); +extern "C" PyObject* IcePy_initializeWithPropertiesAndLogger(PyObject*, PyObject*); + +#endif diff --git a/gnuradio-core/src/lib/runtime/frontend.ice b/gnuradio-core/src/lib/runtime/frontend.ice new file mode 100644 index 0000000000..befb5b7a97 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/frontend.ice @@ -0,0 +1,102 @@ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <gnuradio.ice> + +[["python:package:gnuradio.ctrlport"]] +module GNURadio { + module Frontend { + + exception NotSupported {}; + exception InvalidSetting { string msg; }; + exception ReceiverFailure { string msg; }; + exception NotExist {}; + dictionary<string, string> TunerArgs; + + struct TunerStatus { + int a2dbits; + float gain; + bool isInverted; + }; + + interface Tuner { + TunerStatus configureTuner(TunerArgs args); //ADDED + idempotent TunerStatus status(); + idempotent float setGain(float gain) throws NotSupported, InvalidSetting; + idempotent bool setInversion(bool inverted) throws NotSupported, InvalidSetting; + }; + + struct ChannelStatus { + string uid; + bool active; + float freq; + float bandwidth; + int payloadBits; + bool isComplex; + string signalName; + }; + + interface Channel extends Component { + idempotent ChannelStatus status(); + idempotent FeedInfo feed(); + idempotent bool active(); + void start(); + void stop(); + idempotent float setCenterFreq(float freq) throws NotSupported, InvalidSetting; + idempotent float setBandwidth(float bw) throws NotSupported, InvalidSetting; + idempotent int setPayloadBits(int bits) throws NotSupported, InvalidSetting; + idempotent bool setComplex(bool complex) throws NotSupported, InvalidSetting; + void removeChannel() throws NotSupported; + }; + + sequence<Tuner*> TunerSeq; + sequence<Channel*> ChannelSeq; + + struct ChannelizerStatus { + string uid; + string signalName; + }; + + interface Channelizer extends Component { + idempotent ChannelizerStatus status(); + idempotent Tuner* getTuner(); + idempotent ChannelSeq getChannels(); + idempotent ChannelSeq getActiveChannels(); + idempotent ChannelSeq getInactiveChannels(); + Channel* createChannel(float freq, float bw, int payloadBits, string address, int port) throws NotSupported; + }; + + sequence<Channelizer*> ChannelizerSeq; + + interface Receiver extends AbstractReceiver { + idempotent ChannelizerSeq getInputs(); +// idempotent ChannelizerSeq getActiveInputs(); +// idempotent ChannelizerSeq getInactiveInputs(); + idempotent Channel* getChannelByID(string id) throws NotExist; + idempotent Channelizer* getChannelizerByID(string id) throws NotExist; + }; + + + }; + + + +}; diff --git a/gnuradio-core/src/lib/runtime/gnuradio.ice b/gnuradio-core/src/lib/runtime/gnuradio.ice new file mode 100644 index 0000000000..e17d91901b --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gnuradio.ice @@ -0,0 +1,154 @@ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +[["python:package:gnuradio.ctrlport"]] + +#ifndef GNURADIO_DEBUG +#define GNURADIO_DEBUG + +module GNURadio { +class Knob {}; +class KnobB extends Knob { bool value; }; +class KnobC extends Knob { byte value; }; +class KnobI extends Knob { int value; }; +class KnobF extends Knob { float value; }; +class KnobD extends Knob { double value; }; +class KnobL extends Knob { long value; }; +class KnobS extends Knob { string value; }; + +sequence<bool> VectorB; sequence<byte> VectorC; +sequence<int> VectorI; sequence<float> VectorF; +sequence<double> VectorD; sequence<string> VectorS; +sequence<long> VectorL; + +class KnobVecB extends Knob { VectorB value; }; +class KnobVecC extends Knob { VectorC value; }; +class KnobVecI extends Knob { VectorI value; }; +class KnobVecF extends Knob { VectorF value; }; +class KnobVecD extends Knob { VectorD value; }; +class KnobVecL extends Knob { VectorL value; }; +class KnobVecS extends Knob { VectorS value; }; + +enum KnobType { KNOBBOOL, KNOBCHAR, KNOBINT, KNOBFLOAT, + KNOBDOUBLE, KNOBSTRING, KNOBLONG, KNOBVECBOOL, + KNOBVECCHAR, KNOBVECINT, KNOBVECFLOAT, KNOBVECDOUBLE, + KNOBVECSTRING, KNOBVECLONG }; + +const int DISPNULL = 0x0000; +const int DISPTIME = 0x0001; +const int DISPXY = 0x0002; +const int DISPPSD = 0x0004; +const int DISPSPEC = 0x0008; +const int DISPRAST = 0x0010; +const int DISPOPTCPLX = 0x0100; +const int DISPOPTLOG = 0x0200; +const int DISPOPTSTEM = 0x0400; +const int DISPOPTSTRIP = 0x0800; +const int DISPOPTSCATTER = 0x1000; + +struct KnobProp { + KnobType type; + string units; + string description; + int display; + Knob min; + Knob max; + Knob defaultvalue; +}; + +sequence<string> KnobIDList; +dictionary<string, Knob> KnobMap; +dictionary<string, KnobProp> KnobPropMap; +dictionary<string, string> WaveformArgMap; + +interface StreamReceiver { + void push(VectorC data); +}; + +interface ControlPort { + void set(KnobMap knobs); + idempotent KnobMap get(KnobIDList knobs); + idempotent KnobPropMap properties(KnobIDList knobs); + void shutdown(); + +// string subscribe(StreamReceiver* proxy, string streamName, int requestedPeriod, int RequestedSize); +// idempotent void unsubscribe(string streamID); +}; + +struct FeedInfo { + string protocol; + string address; + string iface; + string port; +}; + +//TODO: convert this part to a Feed Info +struct ReceiverInfo { + string uid; + string signalType; + string signalName; + string allocatableObjectID; + string signalProtocol; + string signalAddress; + string signalInterface; + string signalPort; +}; + +interface Component { + void setName(string newName); +}; + +module Frontend { + interface AbstractReceiver extends Component { + idempotent ReceiverInfo getReceiverInfo(); + }; +}; + +module Booter { + dictionary<string, string> WaveformArgs; + + exception WaveformRunningError { + string waveformClass; + float centerFrequencyHz; + }; + exception SignalSourceError {string msg; }; + + interface WaveformBooter extends Frontend::AbstractReceiver { + string launchWaveform(string waveformClass, WaveformArgs args) + throws WaveformRunningError, SignalSourceError; + +// string launchWaveformWithSession(string waveformClass, WaveformArgs args, IceGrid::Session* session) +// throws WaveformRunningError; + WaveformArgMap getDriverEnum(); + WaveformArgMap getSourceInfo(); + idempotent bool waveformRunning(); + idempotent string getWaveformClass(); + void shutdown(); + }; +}; + +//interface Pingable { +// bool ping(); +//}; + +}; + +#endif diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.cc b/gnuradio-core/src/lib/runtime/gr_basic_block.cc index 6ff57a1d6c..35ea797167 100644 --- a/gnuradio-core/src/lib/runtime/gr_basic_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_basic_block.cc @@ -30,8 +30,6 @@ #include <sstream> #include <iostream> -using namespace pmt; - static long s_next_id = 0; static long s_ncurrently_allocated = 0; @@ -51,7 +49,8 @@ gr_basic_block::gr_basic_block(const std::string &name, d_symbolic_id(global_block_registry.block_register(this)), d_symbol_name(global_block_registry.register_symbolic_name(this)), d_color(WHITE), - message_subscribers(pmt::pmt_make_dict()) + d_rpc_set(false), + message_subscribers(pmt::make_dict()) { s_ncurrently_allocated++; } @@ -80,7 +79,7 @@ gr_basic_block::set_block_alias(std::string name) void gr_basic_block::message_port_register_in(pmt::pmt_t port_id) { - if(!pmt::pmt_is_symbol(port_id)) { + if(!pmt::is_symbol(port_id)) { throw std::runtime_error("message_port_register_in: bad port id"); } msg_queue[port_id] = msg_queue_t(); @@ -90,10 +89,10 @@ gr_basic_block::message_port_register_in(pmt::pmt_t port_id) pmt::pmt_t gr_basic_block::message_ports_in() { - pmt::pmt_t port_names = pmt::pmt_make_vector(msg_queue.size(), pmt::PMT_NIL); + pmt::pmt_t port_names = pmt::make_vector(msg_queue.size(), pmt::PMT_NIL); msg_queue_map_itr itr = msg_queue.begin(); for(size_t i = 0; i < msg_queue.size(); i++) { - pmt::pmt_vector_set(port_names, i, (*itr).first); + pmt::vector_set(port_names, i, (*itr).first); itr++; } return port_names; @@ -103,23 +102,23 @@ gr_basic_block::message_ports_in() void gr_basic_block::message_port_register_out(pmt::pmt_t port_id) { - if(!pmt::pmt_is_symbol(port_id)) { + if(!pmt::is_symbol(port_id)) { throw std::runtime_error("message_port_register_out: bad port id"); } - if(pmt::pmt_dict_has_key(message_subscribers, port_id)) { + if(pmt::dict_has_key(message_subscribers, port_id)) { throw std::runtime_error("message_port_register_out: port already in use"); } - message_subscribers = pmt::pmt_dict_add(message_subscribers, port_id, pmt::PMT_NIL); + message_subscribers = pmt::dict_add(message_subscribers, port_id, pmt::PMT_NIL); } pmt::pmt_t gr_basic_block::message_ports_out() { - size_t len = pmt::pmt_length(message_subscribers); - pmt::pmt_t port_names = pmt::pmt_make_vector(len, pmt::PMT_NIL); - pmt::pmt_t keys = pmt::pmt_dict_keys(message_subscribers); + size_t len = pmt::length(message_subscribers); + pmt::pmt_t port_names = pmt::make_vector(len, pmt::PMT_NIL); + pmt::pmt_t keys = pmt::dict_keys(message_subscribers); for(size_t i = 0; i < len; i++) { - pmt::pmt_vector_set(port_names, i, pmt::pmt_nth(i, keys)); + pmt::vector_set(port_names, i, pmt::nth(i, keys)); } return port_names; } @@ -127,19 +126,19 @@ gr_basic_block::message_ports_out() // - publish a message on a message port void gr_basic_block::message_port_pub(pmt::pmt_t port_id, pmt::pmt_t msg) { - if(!pmt::pmt_dict_has_key(message_subscribers, port_id)) { + if(!pmt::dict_has_key(message_subscribers, port_id)) { throw std::runtime_error("port does not exist"); } - pmt::pmt_t currlist = pmt::pmt_dict_ref(message_subscribers, port_id, pmt::PMT_NIL); + pmt::pmt_t currlist = pmt::dict_ref(message_subscribers, port_id, pmt::PMT_NIL); // iterate through subscribers on port - while(pmt::pmt_is_pair(currlist)) { - pmt::pmt_t target = pmt::pmt_car(currlist); + while(pmt::is_pair(currlist)) { + pmt::pmt_t target = pmt::car(currlist); - pmt::pmt_t block = pmt::pmt_car(target); - pmt::pmt_t port = pmt::pmt_cdr(target); + pmt::pmt_t block = pmt::car(target); + pmt::pmt_t port = pmt::cdr(target); - currlist = pmt::pmt_cdr(currlist); + currlist = pmt::cdr(currlist); gr_basic_block_sptr blk = global_block_registry.block_lookup(block); //blk->post(msg); blk->post(port, msg); @@ -149,33 +148,33 @@ void gr_basic_block::message_port_pub(pmt::pmt_t port_id, pmt::pmt_t msg) // - subscribe to a message port void gr_basic_block::message_port_sub(pmt::pmt_t port_id, pmt::pmt_t target){ - if(!pmt::pmt_dict_has_key(message_subscribers, port_id)){ + if(!pmt::dict_has_key(message_subscribers, port_id)){ std::stringstream ss; - ss << "Port does not exist: \"" << pmt::pmt_write_string(port_id) << "\" on block: " << pmt::pmt_write_string(target) << std::endl; + ss << "Port does not exist: \"" << pmt::write_string(port_id) << "\" on block: " << pmt::write_string(target) << std::endl; throw std::runtime_error(ss.str()); } - pmt::pmt_t currlist = pmt::pmt_dict_ref(message_subscribers,port_id,pmt::PMT_NIL); + pmt::pmt_t currlist = pmt::dict_ref(message_subscribers,port_id,pmt::PMT_NIL); // ignore re-adds of the same target - if(!pmt::pmt_list_has(currlist, target)) - message_subscribers = pmt::pmt_dict_add(message_subscribers,port_id,pmt::pmt_list_add(currlist,target)); + if(!pmt::list_has(currlist, target)) + message_subscribers = pmt::dict_add(message_subscribers,port_id,pmt::list_add(currlist,target)); } void gr_basic_block::message_port_unsub(pmt::pmt_t port_id, pmt::pmt_t target){ - if(!pmt::pmt_dict_has_key(message_subscribers, port_id)){ + if(!pmt::dict_has_key(message_subscribers, port_id)){ std::stringstream ss; - ss << "Port does not exist: \"" << pmt::pmt_write_string(port_id) << "\" on block: " << pmt::pmt_write_string(target) << std::endl; + ss << "Port does not exist: \"" << pmt::write_string(port_id) << "\" on block: " << pmt::write_string(target) << std::endl; throw std::runtime_error(ss.str()); } // ignore unsubs of unknown targets - pmt::pmt_t currlist = pmt::pmt_dict_ref(message_subscribers,port_id,pmt::PMT_NIL); - message_subscribers = pmt::pmt_dict_add(message_subscribers,port_id,pmt::pmt_list_rm(currlist,target)); + pmt::pmt_t currlist = pmt::dict_ref(message_subscribers,port_id,pmt::PMT_NIL); + message_subscribers = pmt::dict_add(message_subscribers,port_id,pmt::list_rm(currlist,target)); } void -gr_basic_block::_post(pmt_t which_port, pmt_t msg) +gr_basic_block::_post(pmt::pmt_t which_port, pmt::pmt_t msg) { insert_tail(which_port, msg); } @@ -186,7 +185,7 @@ gr_basic_block::insert_tail(pmt::pmt_t which_port, pmt::pmt_t msg) gruel::scoped_lock guard(mutex); if( (msg_queue.find(which_port) == msg_queue.end()) || (msg_queue_ready.find(which_port) == msg_queue_ready.end())){ - std::cout << "target port = " << pmt::pmt_symbol_to_string(which_port) << std::endl; + std::cout << "target port = " << pmt::symbol_to_string(which_port) << std::endl; throw std::runtime_error("attempted to insert_tail on invalid queue!"); } @@ -197,7 +196,7 @@ gr_basic_block::insert_tail(pmt::pmt_t which_port, pmt::pmt_t msg) global_block_registry.notify_blk(alias()); } -pmt_t +pmt::pmt_t gr_basic_block::delete_head_nowait(pmt::pmt_t which_port) { gruel::scoped_lock guard(mutex); @@ -206,13 +205,13 @@ gr_basic_block::delete_head_nowait(pmt::pmt_t which_port) return pmt::pmt_t(); } - pmt_t m(msg_queue[which_port].front()); + pmt::pmt_t m(msg_queue[which_port].front()); msg_queue[which_port].pop_front(); return m; } -pmt_t +pmt::pmt_t gr_basic_block::delete_head_blocking(pmt::pmt_t which_port) { gruel::scoped_lock guard(mutex); @@ -221,7 +220,7 @@ gr_basic_block::delete_head_blocking(pmt::pmt_t which_port) msg_queue_ready[which_port]->wait(guard); } - pmt_t m(msg_queue[which_port].front()); + pmt::pmt_t m(msg_queue[which_port].front()); msg_queue[which_port].pop_front(); return m; } diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.h b/gnuradio-core/src/lib/runtime/gr_basic_block.h index 024159c4cc..31081698c7 100644 --- a/gnuradio-core/src/lib/runtime/gr_basic_block.h +++ b/gnuradio-core/src/lib/runtime/gr_basic_block.h @@ -38,6 +38,10 @@ #include <boost/thread/condition_variable.hpp> #include <iostream> +#ifdef GR_CTRLPORT +#include <rpcregisterhelpers.h> +#endif + /*! * \brief The abstract base class for all signal processing blocks. * \ingroup internal @@ -56,13 +60,13 @@ class GR_CORE_API gr_basic_block : public gr_msg_accepter, public boost::enable_ private: //msg_handler_t d_msg_handler; - typedef std::map<pmt::pmt_t , msg_handler_t, pmt::pmt_comperator> d_msg_handlers_t; + typedef std::map<pmt::pmt_t , msg_handler_t, pmt::comperator> d_msg_handlers_t; d_msg_handlers_t d_msg_handlers; typedef std::deque<pmt::pmt_t> msg_queue_t; - typedef std::map<pmt::pmt_t, msg_queue_t, pmt::pmt_comperator> msg_queue_map_t; - typedef std::map<pmt::pmt_t, msg_queue_t, pmt::pmt_comperator>::iterator msg_queue_map_itr; - std::map<pmt::pmt_t, boost::shared_ptr<boost::condition_variable>, pmt::pmt_comperator> msg_queue_ready; + typedef std::map<pmt::pmt_t, msg_queue_t, pmt::comperator> msg_queue_map_t; + typedef std::map<pmt::pmt_t, msg_queue_t, pmt::comperator>::iterator msg_queue_map_itr; + std::map<pmt::pmt_t, boost::shared_ptr<boost::condition_variable>, pmt::comperator> msg_queue_ready; gruel::mutex mutex; //< protects all vars @@ -81,7 +85,10 @@ class GR_CORE_API gr_basic_block : public gr_msg_accepter, public boost::enable_ std::string d_symbol_name; std::string d_symbol_alias; vcolor d_color; + bool d_rpc_set; + msg_queue_map_t msg_queue; + std::vector<boost::any> d_rpc_vars; // container for all RPC variables gr_basic_block(void){} //allows pure virtual interface sub-classes @@ -141,7 +148,7 @@ class GR_CORE_API gr_basic_block : public gr_msg_accepter, public boost::enable_ gr_basic_block_sptr to_basic_block(); // Needed for Python type coercion bool alias_set() { return !d_symbol_alias.empty(); } std::string alias(){ return alias_set()?d_symbol_alias:symbol_name(); } - pmt::pmt_t alias_pmt(){ return pmt::pmt_intern(alias()); } + pmt::pmt_t alias_pmt(){ return pmt::intern(alias()); } void set_block_alias(std::string name); // ** Message passing interface ** @@ -222,12 +229,53 @@ class GR_CORE_API gr_basic_block : public gr_msg_accepter, public boost::enable_ if(msg_queue.find(which_port) != msg_queue.end()){ return true; } - if(pmt::pmt_dict_has_key(message_subscribers, which_port)){ + if(pmt::dict_has_key(message_subscribers, which_port)){ return true; } return false; } - + +#ifdef GR_CTRLPORT + /*! + * \brief Add an RPC variable (get or set). + * + * Using controlport, we create new getters/setters and need to + * store them. Each block has a vector to do this, and these never + * need to be accessed again once they are registered with the RPC + * backend. This function takes a + * boost::shared_sptr<rpcbasic_base> so that when the block is + * deleted, all RPC registered variables are cleaned up. + * + * \param s an rpcbasic_sptr of the new RPC variable register to store. + */ + void add_rpc_variable(rpcbasic_sptr s) + { + d_rpc_vars.push_back(s); + } +#endif /* GR_CTRLPORT */ + + /*! + * \brief Set up the RPC registered variables. + * + * This must be overloaded by a block that wants to use + * controlport. This is where rpcbasic_register_{get,set} pointers + * are created, which then get wrapped as shared pointers + * (rpcbasic_sptr(...)) and stored using add_rpc_variable. + */ + virtual void setup_rpc() {}; + + /*! + * \brief Ask if this block has been registered to the RPC. + * + * We can only register a block once, so we use this to protect us + * from calling it multiple times. + */ + bool is_rpc_set() { return d_rpc_set; } + + /*! + * \brief When the block is registered with the RPC, set this. + */ + void rpc_set() { d_rpc_set = true; } /*! * \brief Confirm that ninputs and noutputs is an acceptable combination. @@ -270,9 +318,6 @@ class GR_CORE_API gr_basic_block : public gr_msg_accepter, public boost::enable_ * If the block inherits from gr_hier_block2, the runtime system will * ensure that no reentrant calls are made to msg_handler. */ - //template <typename T> void set_msg_handler(T msg_handler){ - // d_msg_handler = msg_handler_t(msg_handler); - //} template <typename T> void set_msg_handler(pmt::pmt_t which_port, T msg_handler){ if(msg_queue.find(which_port) == msg_queue.end()){ throw std::runtime_error("attempt to set_msg_handler() on bad input message port!"); } diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc b/gnuradio-core/src/lib/runtime/gr_block.cc index 4950e8666c..8c8b85dc7e 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_block.cc @@ -46,6 +46,7 @@ gr_block::gr_block (const std::string &name, d_max_noutput_items(0), d_min_noutput_items(0), d_tag_propagation_policy(TPP_ALL_TO_ALL), + d_pc_rpc_set(false), d_max_output_buffer(std::max(output_signature->max_streams(),1), -1), d_min_output_buffer(std::max(output_signature->max_streams(),1), -1) { @@ -329,6 +330,17 @@ gr_block::pc_noutput_items() } float +gr_block::pc_noutput_items_avg() +{ + if(d_detail) { + return d_detail->pc_noutput_items_avg(); + } + else { + return 0; + } +} + +float gr_block::pc_noutput_items_var() { if(d_detail) { @@ -351,6 +363,17 @@ gr_block::pc_nproduced() } float +gr_block::pc_nproduced_avg() +{ + if(d_detail) { + return d_detail->pc_nproduced_avg(); + } + else { + return 0; + } +} + +float gr_block::pc_nproduced_var() { if(d_detail) { @@ -373,6 +396,17 @@ gr_block::pc_input_buffers_full(int which) } float +gr_block::pc_input_buffers_full_avg(int which) +{ + if(d_detail) { + return d_detail->pc_input_buffers_full_avg(static_cast<size_t>(which)); + } + else { + return 0; + } +} + +float gr_block::pc_input_buffers_full_var(int which) { if(d_detail) { @@ -395,6 +429,17 @@ gr_block::pc_input_buffers_full() } std::vector<float> +gr_block::pc_input_buffers_full_avg() +{ + if(d_detail) { + return d_detail->pc_input_buffers_full_avg(); + } + else { + return std::vector<float>(1,0); + } +} + +std::vector<float> gr_block::pc_input_buffers_full_var() { if(d_detail) { @@ -417,6 +462,17 @@ gr_block::pc_output_buffers_full(int which) } float +gr_block::pc_output_buffers_full_avg(int which) +{ + if(d_detail) { + return d_detail->pc_output_buffers_full_avg(static_cast<size_t>(which)); + } + else { + return 0; + } +} + +float gr_block::pc_output_buffers_full_var(int which) { if(d_detail) { @@ -439,6 +495,17 @@ gr_block::pc_output_buffers_full() } std::vector<float> +gr_block::pc_output_buffers_full_avg() +{ + if(d_detail) { + return d_detail->pc_output_buffers_full_avg(); + } + else { + return std::vector<float>(1,0); + } +} + +std::vector<float> gr_block::pc_output_buffers_full_var() { if(d_detail) { @@ -461,6 +528,17 @@ gr_block::pc_work_time() } float +gr_block::pc_work_time_avg() +{ + if(d_detail) { + return d_detail->pc_work_time_avg(); + } + else { + return 0; + } +} + +float gr_block::pc_work_time_var() { if(d_detail) { @@ -479,6 +557,118 @@ gr_block::reset_perf_counters() } } +void +gr_block::setup_pc_rpc() +{ + d_pc_rpc_set = true; +#ifdef GR_CTRLPORT + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( + alias(), "noutput_items", &gr_block::pc_noutput_items, + pmt::mp(0), pmt::mp(32768), pmt::mp(0), + "", "noutput items", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( + alias(), "avg noutput_items", &gr_block::pc_noutput_items_avg, + pmt::mp(0), pmt::mp(32768), pmt::mp(0), + "", "Average noutput items", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( + alias(), "var noutput_items", &gr_block::pc_noutput_items_var, + pmt::mp(0), pmt::mp(32768), pmt::mp(0), + "", "Var. noutput items", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( + alias(), "nproduced", &gr_block::pc_nproduced, + pmt::mp(0), pmt::mp(32768), pmt::mp(0), + "", "items produced", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( + alias(), "avg nproduced", &gr_block::pc_nproduced_avg, + pmt::mp(0), pmt::mp(32768), pmt::mp(0), + "", "Average items produced", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( + alias(), "var nproduced", &gr_block::pc_nproduced_var, + pmt::mp(0), pmt::mp(32768), pmt::mp(0), + "", "Var. items produced", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( + alias(), "work time", &gr_block::pc_work_time, + pmt::mp(0), pmt::mp(1e9), pmt::mp(0), + "", "clock cycles in call to work", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( + alias(), "avg work time", &gr_block::pc_work_time_avg, + pmt::mp(0), pmt::mp(1e9), pmt::mp(0), + "", "Average clock cycles in call to work", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( + alias(), "var work time", &gr_block::pc_work_time_var, + pmt::mp(0), pmt::mp(1e9), pmt::mp(0), + "", "Var. clock cycles in call to work", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, std::vector<float> >( + alias(), "input \% full", &gr_block::pc_input_buffers_full, + pmt::make_c32vector(0,0), pmt::make_c32vector(0,1), pmt::make_c32vector(0,0), + "", "how full input buffers are", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, std::vector<float> >( + alias(), "avg input \% full", &gr_block::pc_input_buffers_full_avg, + pmt::make_c32vector(0,0), pmt::make_c32vector(0,1), pmt::make_c32vector(0,0), + "", "Average of how full input buffers are", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, std::vector<float> >( + alias(), "var input \% full", &gr_block::pc_input_buffers_full_var, + pmt::make_c32vector(0,0), pmt::make_c32vector(0,1), pmt::make_c32vector(0,0), + "", "Var. of how full input buffers are", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, std::vector<float> >( + alias(), "output \% full", &gr_block::pc_output_buffers_full, + pmt::make_c32vector(0,0), pmt::make_c32vector(0,1), pmt::make_c32vector(0,0), + "", "how full output buffers are", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, std::vector<float> >( + alias(), "avg output \% full", &gr_block::pc_output_buffers_full_avg, + pmt::make_c32vector(0,0), pmt::make_c32vector(0,1), pmt::make_c32vector(0,0), + "", "Average of how full output buffers are", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, std::vector<float> >( + alias(), "var output \% full", &gr_block::pc_output_buffers_full_var, + pmt::make_c32vector(0,0), pmt::make_c32vector(0,1), pmt::make_c32vector(0,0), + "", "Var. of how full output buffers are", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); +#endif /* GR_CTRLPORT */ +} + std::ostream& operator << (std::ostream& os, const gr_block *m) { diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index e4b30267e6..f13f54870d 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -379,72 +379,108 @@ class GR_CORE_API gr_block : public gr_basic_block { // --------------- Performance counter functions ------------- /*! - * \brief Gets average noutput_items performance counter. + * \brief Gets instantaneous noutput_items performance counter. */ float pc_noutput_items(); /*! + * \brief Gets average noutput_items performance counter. + */ + float pc_noutput_items_avg(); + + /*! * \brief Gets variance of noutput_items performance counter. */ float pc_noutput_items_var(); /*! - * \brief Gets average num items produced performance counter. + * \brief Gets instantaneous num items produced performance counter. */ float pc_nproduced(); /*! + * \brief Gets average num items produced performance counter. + */ + float pc_nproduced_avg(); + + /*! * \brief Gets variance of num items produced performance counter. */ float pc_nproduced_var(); /*! - * \brief Gets average fullness of \p which input buffer. + * \brief Gets instantaneous fullness of \p which input buffer. */ float pc_input_buffers_full(int which); /*! + * \brief Gets average fullness of \p which input buffer. + */ + float pc_input_buffers_full_avg(int which); + + /*! * \brief Gets variance of fullness of \p which input buffer. */ float pc_input_buffers_full_var(int which); /*! - * \brief Gets average fullness of all input buffers. + * \brief Gets instantaneous fullness of all input buffers. */ std::vector<float> pc_input_buffers_full(); /*! + * \brief Gets average fullness of all input buffers. + */ + std::vector<float> pc_input_buffers_full_avg(); + + /*! * \brief Gets variance of fullness of all input buffers. */ std::vector<float> pc_input_buffers_full_var(); /*! - * \brief Gets average fullness of \p which input buffer. + * \brief Gets instantaneous fullness of \p which input buffer. */ float pc_output_buffers_full(int which); /*! + * \brief Gets average fullness of \p which input buffer. + */ + float pc_output_buffers_full_avg(int which); + + /*! * \brief Gets variance of fullness of \p which input buffer. */ float pc_output_buffers_full_var(int which); /*! - * \brief Gets average fullness of all output buffers. + * \brief Gets instantaneous fullness of all output buffers. */ std::vector<float> pc_output_buffers_full(); + + /*! + * \brief Gets average fullness of all output buffers. + */ + std::vector<float> pc_output_buffers_full_avg(); + /*! * \brief Gets variance of fullness of all output buffers. */ std::vector<float> pc_output_buffers_full_var(); /*! - * \brief Gets average clock cycles spent in work. + * \brief Gets instantaneous clock cycles spent in work. */ float pc_work_time(); /*! * \brief Gets average clock cycles spent in work. */ + float pc_work_time_avg(); + + /*! + * \brief Gets average clock cycles spent in work. + */ float pc_work_time_var(); /*! @@ -452,6 +488,24 @@ class GR_CORE_API gr_block : public gr_basic_block { */ void reset_perf_counters(); + /*! + * \brief Sets up export of perf. counters to ControlPort. Only + * called by the scheduler. + */ + void setup_pc_rpc(); + + /*! + * \brief Checks if this block is already exporting perf. counters + * to ControlPort. + */ + bool is_pc_rpc_set() { return d_pc_rpc_set; } + + /*! + * \brief If the block calls this in its constructor, it's + * perf. counters will not be exported. + */ + void no_pc_rpc() { d_pc_rpc_set = true; } + // ---------------------------------------------------------------------------- // Functions to handle thread affinity @@ -490,6 +544,7 @@ class GR_CORE_API gr_block : public gr_basic_block { int d_min_noutput_items; tag_propagation_policy_t d_tag_propagation_policy; // policy for moving tags downstream std::vector<unsigned int> d_affinity; // thread affinity proc. mask + bool d_pc_rpc_set; protected: gr_block (void){} //allows pure virtual interface sub-classes diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.cc b/gnuradio-core/src/lib/runtime/gr_block_detail.cc index 82081039ac..c85c0e9fba 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.cc @@ -28,8 +28,6 @@ #include <gr_buffer.h> #include <iostream> -using namespace pmt; - static long s_ncurrently_allocated = 0; long @@ -43,14 +41,19 @@ gr_block_detail::gr_block_detail (unsigned int ninputs, unsigned int noutputs) d_ninputs (ninputs), d_noutputs (noutputs), d_input (ninputs), d_output (noutputs), d_done (false), + d_ins_noutput_items(0), d_avg_noutput_items(0), d_var_noutput_items(0), + d_ins_nproduced(0), d_avg_nproduced(0), d_var_nproduced(0), + d_ins_input_buffers_full(ninputs, 0), d_avg_input_buffers_full(ninputs, 0), d_var_input_buffers_full(ninputs, 0), + d_ins_output_buffers_full(noutputs, 0), d_avg_output_buffers_full(noutputs, 0), d_var_output_buffers_full(noutputs, 0), + d_ins_work_time(0), d_avg_work_time(0), d_var_work_time(0), d_pc_counter(0) @@ -158,8 +161,8 @@ gr_block_detail::nitems_written(unsigned int which_output) void gr_block_detail::add_item_tag(unsigned int which_output, const gr_tag_t &tag) { - if(!pmt_is_symbol(tag.key)) { - throw pmt_wrong_type("gr_block_detail::add_item_tag key", tag.key); + if(!pmt::is_symbol(tag.key)) { + throw pmt::wrong_type("gr_block_detail::add_item_tag key", tag.key); } else { // Add tag to gr_buffer's deque tags @@ -170,8 +173,8 @@ gr_block_detail::add_item_tag(unsigned int which_output, const gr_tag_t &tag) void gr_block_detail::remove_item_tag(unsigned int which_input, const gr_tag_t &tag) { - if(!pmt_is_symbol(tag.key)) { - throw pmt_wrong_type("gr_block_detail::add_item_tag key", tag.key); + if(!pmt::is_symbol(tag.key)) { + throw pmt::wrong_type("gr_block_detail::add_item_tag key", tag.key); } else { // Add tag to gr_buffer's deque tags @@ -194,7 +197,7 @@ gr_block_detail::get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end, - const pmt_t &key) + const pmt::pmt_t &key) { std::vector<gr_tag_t> found_items; @@ -204,11 +207,11 @@ gr_block_detail::get_tags_in_range(std::vector<gr_tag_t> &v, d_input[which_input]->get_tags_in_range(found_items, abs_start, abs_end); // Filter further by key name - pmt_t itemkey; + pmt::pmt_t itemkey; std::vector<gr_tag_t>::iterator itr; for(itr = found_items.begin(); itr != found_items.end(); itr++) { itemkey = (*itr).key; - if(pmt_eqv(key, itemkey)) { + if(pmt::eqv(key, itemkey)) { v.push_back(*itr); } } @@ -248,35 +251,43 @@ gr_block_detail::stop_perf_counters(int noutput_items, int nproduced) gruel::high_res_timer_type diff = d_end_of_work - d_start_of_work; if(d_pc_counter == 0) { + d_ins_work_time = diff; d_avg_work_time = diff; d_var_work_time = 0; + d_ins_nproduced = nproduced; d_avg_nproduced = nproduced; d_var_nproduced = 0; + d_ins_noutput_items = noutput_items; d_avg_noutput_items = noutput_items; d_var_noutput_items = 0; for(size_t i=0; i < d_input.size(); i++) { float pfull = static_cast<float>(d_input[i]->items_available()) / static_cast<float>(d_input[i]->max_possible_items_available()); + d_ins_input_buffers_full[i] = pfull; d_avg_input_buffers_full[i] = pfull; d_var_input_buffers_full[i] = 0; } for(size_t i=0; i < d_output.size(); i++) { float pfull = 1.0f - static_cast<float>(d_output[i]->space_available()) / static_cast<float>(d_output[i]->bufsize()); + d_ins_output_buffers_full[i] = pfull; d_avg_output_buffers_full[i] = pfull; d_var_output_buffers_full[i] = 0; } } else { float d = diff - d_avg_work_time; + d_ins_work_time = diff; d_avg_work_time = d_avg_work_time + d/d_pc_counter; d_var_work_time = d_var_work_time + d*d; d = nproduced - d_avg_nproduced; + d_ins_nproduced = nproduced; d_avg_nproduced = d_avg_nproduced + d/d_pc_counter; d_var_nproduced = d_var_nproduced + d*d; d = noutput_items - d_avg_noutput_items; + d_ins_noutput_items = noutput_items; d_avg_noutput_items = d_avg_noutput_items + d/d_pc_counter; d_var_noutput_items = d_var_noutput_items + d*d; @@ -285,6 +296,7 @@ gr_block_detail::stop_perf_counters(int noutput_items, int nproduced) static_cast<float>(d_input[i]->max_possible_items_available()); d = pfull - d_avg_input_buffers_full[i]; + d_ins_input_buffers_full[i] = pfull; d_avg_input_buffers_full[i] = d_avg_input_buffers_full[i] + d/d_pc_counter; d_var_input_buffers_full[i] = d_var_input_buffers_full[i] + d*d; } @@ -294,6 +306,7 @@ gr_block_detail::stop_perf_counters(int noutput_items, int nproduced) static_cast<float>(d_output[i]->bufsize()); d = pfull - d_avg_output_buffers_full[i]; + d_ins_output_buffers_full[i] = pfull; d_avg_output_buffers_full[i] = d_avg_output_buffers_full[i] + d/d_pc_counter; d_var_output_buffers_full[i] = d_var_output_buffers_full[i] + d*d; } @@ -311,18 +324,66 @@ gr_block_detail::reset_perf_counters() float gr_block_detail::pc_noutput_items() { - return d_avg_noutput_items; + return d_ins_noutput_items; } float gr_block_detail::pc_nproduced() { - return d_avg_nproduced; + return d_ins_nproduced; } float gr_block_detail::pc_input_buffers_full(size_t which) { + if(which < d_ins_input_buffers_full.size()) + return d_ins_input_buffers_full[which]; + else + return 0; +} + +std::vector<float> +gr_block_detail::pc_input_buffers_full() +{ + return d_ins_input_buffers_full; +} + +float +gr_block_detail::pc_output_buffers_full(size_t which) +{ + if(which < d_ins_output_buffers_full.size()) + return d_ins_output_buffers_full[which]; + else + return 0; +} + +std::vector<float> +gr_block_detail::pc_output_buffers_full() +{ + return d_ins_output_buffers_full; +} + +float +gr_block_detail::pc_work_time() +{ + return d_ins_work_time; +} + +float +gr_block_detail::pc_noutput_items_avg() +{ + return d_avg_noutput_items; +} + +float +gr_block_detail::pc_nproduced_avg() +{ + return d_avg_nproduced; +} + +float +gr_block_detail::pc_input_buffers_full_avg(size_t which) +{ if(which < d_avg_input_buffers_full.size()) return d_avg_input_buffers_full[which]; else @@ -330,13 +391,13 @@ gr_block_detail::pc_input_buffers_full(size_t which) } std::vector<float> -gr_block_detail::pc_input_buffers_full() +gr_block_detail::pc_input_buffers_full_avg() { return d_avg_input_buffers_full; } float -gr_block_detail::pc_output_buffers_full(size_t which) +gr_block_detail::pc_output_buffers_full_avg(size_t which) { if(which < d_avg_output_buffers_full.size()) return d_avg_output_buffers_full[which]; @@ -345,13 +406,13 @@ gr_block_detail::pc_output_buffers_full(size_t which) } std::vector<float> -gr_block_detail::pc_output_buffers_full() +gr_block_detail::pc_output_buffers_full_avg() { return d_avg_output_buffers_full; } float -gr_block_detail::pc_work_time() +gr_block_detail::pc_work_time_avg() { return d_avg_work_time; } diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.h b/gnuradio-core/src/lib/runtime/gr_block_detail.h index 32a01e763a..8a5a08bcf3 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.h +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.h @@ -184,6 +184,14 @@ class GR_CORE_API gr_block_detail { std::vector<float> pc_output_buffers_full(); float pc_work_time(); + float pc_noutput_items_avg(); + float pc_nproduced_avg(); + float pc_input_buffers_full_avg(size_t which); + std::vector<float> pc_input_buffers_full_avg(); + float pc_output_buffers_full_avg(size_t which); + std::vector<float> pc_output_buffers_full_avg(); + float pc_work_time_avg(); + float pc_noutput_items_var(); float pc_nproduced_var(); float pc_input_buffers_full_var(size_t which); @@ -205,15 +213,20 @@ class GR_CORE_API gr_block_detail { bool d_done; // Performance counters + float d_ins_noutput_items; float d_avg_noutput_items; float d_var_noutput_items; + float d_ins_nproduced; float d_avg_nproduced; float d_var_nproduced; + std::vector<float> d_ins_input_buffers_full; std::vector<float> d_avg_input_buffers_full; std::vector<float> d_var_input_buffers_full; + std::vector<float> d_ins_output_buffers_full; std::vector<float> d_avg_output_buffers_full; std::vector<float> d_var_output_buffers_full; gruel::high_res_timer_type d_start_of_work, d_end_of_work; + float d_ins_work_time; float d_avg_work_time; float d_var_work_time; float d_pc_counter; diff --git a/gnuradio-core/src/lib/runtime/gr_block_registry.cc b/gnuradio-core/src/lib/runtime/gr_block_registry.cc index ff23d97eb2..eaa770dcaf 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_registry.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_registry.cc @@ -8,7 +8,7 @@ gr_block_registry global_block_registry; gr_block_registry::gr_block_registry(){ - d_ref_map = pmt::pmt_make_dict(); + d_ref_map = pmt::make_dict(); } long gr_block_registry::block_register(gr_basic_block* block){ @@ -29,9 +29,9 @@ long gr_block_registry::block_register(gr_basic_block* block){ void gr_block_registry::block_unregister(gr_basic_block* block){ d_map[block->name()].erase( d_map[block->name()].find(block->symbolic_id())); - d_ref_map = pmt::pmt_dict_delete(d_ref_map, pmt::pmt_intern(block->symbol_name())); + d_ref_map = pmt::dict_delete(d_ref_map, pmt::intern(block->symbol_name())); if(block->alias_set()){ - d_ref_map = pmt::pmt_dict_delete(d_ref_map, pmt::pmt_intern(block->alias())); + d_ref_map = pmt::dict_delete(d_ref_map, pmt::intern(block->alias())); } } @@ -44,18 +44,18 @@ std::string gr_block_registry::register_symbolic_name(gr_basic_block* block){ } void gr_block_registry::register_symbolic_name(gr_basic_block* block, std::string name){ - if(pmt_dict_has_key(d_ref_map, pmt::pmt_intern(name))){ + if(dict_has_key(d_ref_map, pmt::intern(name))){ throw std::runtime_error("symbol already exists, can not re-use!"); } - d_ref_map = pmt_dict_add(d_ref_map, pmt::pmt_intern(name), pmt::pmt_make_any(block)); + d_ref_map = dict_add(d_ref_map, pmt::intern(name), pmt::make_any(block)); } gr_basic_block_sptr gr_block_registry::block_lookup(pmt::pmt_t symbol){ - pmt::pmt_t ref = pmt_dict_ref(d_ref_map, symbol, pmt::PMT_NIL); - if(pmt::pmt_eq(ref, pmt::PMT_NIL)){ + pmt::pmt_t ref = dict_ref(d_ref_map, symbol, pmt::PMT_NIL); + if(pmt::eq(ref, pmt::PMT_NIL)){ throw std::runtime_error("block lookup failed! block not found!"); } - gr_basic_block* blk = boost::any_cast<gr_basic_block*>( pmt::pmt_any_ref(ref) ); + gr_basic_block* blk = boost::any_cast<gr_basic_block*>( pmt::any_ref(ref) ); return blk->shared_from_this(); } diff --git a/gnuradio-core/src/lib/runtime/gr_block_registry.h b/gnuradio-core/src/lib/runtime/gr_block_registry.h index 3a9d9868f6..2e0a3b6d5c 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_registry.h +++ b/gnuradio-core/src/lib/runtime/gr_block_registry.h @@ -1,6 +1,7 @@ #ifndef GR_BLOCK_REGISTRY_H #define GR_BLOCK_REGISTRY_H +#include <gr_core_api.h> #include <map> #include <gr_basic_block.h> @@ -9,7 +10,7 @@ class gr_basic_block; class gr_block; #endif -class gr_block_registry { +class GR_CORE_API gr_block_registry { public: gr_block_registry(); @@ -37,7 +38,7 @@ class gr_block_registry { }; -extern gr_block_registry global_block_registry; +GR_CORE_API extern gr_block_registry global_block_registry; #endif diff --git a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc index 9294a5dca2..de1e227ef0 100644 --- a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc +++ b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc @@ -28,6 +28,7 @@ #include <gr_block_detail.h> #include <gr_io_signature.h> #include <gr_buffer.h> +#include <gr_prefs.h> #include <volk/volk.h> #include <iostream> #include <map> @@ -78,7 +79,7 @@ gr_flat_flowgraph::setup_connections() std::cout << boost::format("flat_fg connecting msg primitives: (%s, %s)->(%s, %s)\n") % i->src().block() % i->src().port() % i->dst().block() % i->dst().port(); - i->src().block()->message_port_sub( i->src().port(), pmt::pmt_cons(i->dst().block()->alias_pmt(), i->dst().port()) ); + i->src().block()->message_port_sub( i->src().port(), pmt::cons(i->dst().block()->alias_pmt(), i->dst().port()) ); } } @@ -324,6 +325,15 @@ gr_flat_flowgraph::setup_buffer_alignment(gr_block_sptr block) } } +std::string +gr_flat_flowgraph::edge_list() +{ + std::stringstream s; + for(gr_edge_viter_t e = d_edges.begin(); e != d_edges.end(); e++) + s << (*e) << std::endl; + return s.str(); +} + void gr_flat_flowgraph::dump() { for (gr_edge_viter_t e = d_edges.begin(); e != d_edges.end(); e++) @@ -401,3 +411,17 @@ void gr_flat_flowgraph::replace_endpoint(const gr_msg_endpoint &e, const gr_msg_ } } +void +gr_flat_flowgraph::enable_pc_rpc() +{ +#ifdef GR_PERFORMANCE_COUNTERS + if(gr_prefs::singleton()->get_bool("PerfCounters", "on", false)) { + gr_basic_block_viter_t p; + for(p = d_blocks.begin(); p != d_blocks.end(); p++) { + gr_block_sptr block = cast_to_block_sptr(*p); + if(!block->is_pc_rpc_set()) + block->setup_pc_rpc(); + } + } +#endif /* GR_PERFORMANCE_COUNTERS */ +} diff --git a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h index 5c8268d7df..3cd3228f41 100644 --- a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h +++ b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h @@ -50,6 +50,9 @@ public: // Merge applicable connections from existing flat flowgraph void merge_connections(gr_flat_flowgraph_sptr sfg); + // Return a string list of edges + std::string edge_list(); + void dump(); /*! @@ -60,6 +63,12 @@ public: void replace_endpoint(const gr_msg_endpoint &e, const gr_msg_endpoint &r, bool is_src); void clear_endpoint(const gr_msg_endpoint &e, bool is_src); + /*! + * Enables export of perf. counters to ControlPort on all blocks in + * the flowgraph. + */ + void enable_pc_rpc(); + private: gr_flat_flowgraph(); diff --git a/gnuradio-core/src/lib/runtime/gr_flowgraph.h b/gnuradio-core/src/lib/runtime/gr_flowgraph.h index bef70f626f..40e9dc3675 100644 --- a/gnuradio-core/src/lib/runtime/gr_flowgraph.h +++ b/gnuradio-core/src/lib/runtime/gr_flowgraph.h @@ -73,7 +73,7 @@ public: inline bool gr_msg_endpoint::operator==(const gr_msg_endpoint &other) const { return (d_basic_block == other.d_basic_block && - pmt::pmt_equal(d_port, other.d_port)); + pmt::equal(d_port, other.d_port)); } @@ -237,7 +237,7 @@ void gr_flowgraph::disconnect(gr_basic_block_sptr src_block, int src_port, inline std::ostream& operator <<(std::ostream &os, const gr_endpoint endp) { - os << endp.block() << ":" << endp.port(); + os << endp.block()->alias() << ":" << endp.port(); return os; } diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2.cc b/gnuradio-core/src/lib/runtime/gr_hier_block2.cc index 8c2794c63c..9e924fdaf5 100644 --- a/gnuradio-core/src/lib/runtime/gr_hier_block2.cc +++ b/gnuradio-core/src/lib/runtime/gr_hier_block2.cc @@ -86,7 +86,7 @@ void gr_hier_block2::msg_connect(gr_basic_block_sptr src, pmt::pmt_t srcport, gr_basic_block_sptr dst, pmt::pmt_t dstport) { - if(!pmt::pmt_is_symbol(srcport)){throw std::runtime_error("bad port id"); } + if(!pmt::is_symbol(srcport)){throw std::runtime_error("bad port id"); } d_detail->msg_connect(src, srcport, dst, dstport); } @@ -101,7 +101,7 @@ void gr_hier_block2::msg_disconnect(gr_basic_block_sptr src, pmt::pmt_t srcport, gr_basic_block_sptr dst, pmt::pmt_t dstport) { - if(!pmt::pmt_is_symbol(srcport)){throw std::runtime_error("bad port id"); } + if(!pmt::is_symbol(srcport)){throw std::runtime_error("bad port id"); } d_detail->msg_disconnect(src, srcport, dst, dstport); } diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2.h b/gnuradio-core/src/lib/runtime/gr_hier_block2.h index f80dd73e4b..aa6b180cac 100644 --- a/gnuradio-core/src/lib/runtime/gr_hier_block2.h +++ b/gnuradio-core/src/lib/runtime/gr_hier_block2.h @@ -175,28 +175,28 @@ public: return message_port_is_hier_in(port_id) || message_port_is_hier_out(port_id); } bool message_port_is_hier_in(pmt::pmt_t port_id){ - return pmt::pmt_list_has(hier_message_ports_in, port_id); + return pmt::list_has(hier_message_ports_in, port_id); } bool message_port_is_hier_out(pmt::pmt_t port_id){ - return pmt::pmt_list_has(hier_message_ports_out, port_id); + return pmt::list_has(hier_message_ports_out, port_id); } pmt::pmt_t hier_message_ports_in; pmt::pmt_t hier_message_ports_out; void message_port_register_hier_in(pmt::pmt_t port_id){ - if(pmt::pmt_list_has(hier_message_ports_in, port_id)) + if(pmt::list_has(hier_message_ports_in, port_id)) throw std::invalid_argument("hier msg in port by this name already registered"); if(msg_queue.find(port_id) != msg_queue.end()) throw std::invalid_argument("block already has a primitive input port by this name"); - hier_message_ports_in = pmt::pmt_list_add(hier_message_ports_in, port_id); + hier_message_ports_in = pmt::list_add(hier_message_ports_in, port_id); } void message_port_register_hier_out(pmt::pmt_t port_id){ - if(pmt::pmt_list_has(hier_message_ports_out, port_id)) + if(pmt::list_has(hier_message_ports_out, port_id)) throw std::invalid_argument("hier msg out port by this name already registered"); - if(pmt::pmt_dict_has_key(message_subscribers, port_id)) + if(pmt::dict_has_key(message_subscribers, port_id)) throw std::invalid_argument("block already has a primitive output port by this name"); - hier_message_ports_out = pmt::pmt_list_add(hier_message_ports_out, port_id); + hier_message_ports_out = pmt::list_add(hier_message_ports_out, port_id); } }; diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc b/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc index add6da0248..c8564f6698 100644 --- a/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc +++ b/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc @@ -25,6 +25,7 @@ #include <gr_hier_block2_detail.h> #include <gr_io_signature.h> +#include <gr_prefs.h> #include <stdexcept> #include <sstream> #include <boost/format.hpp> @@ -154,7 +155,7 @@ gr_hier_block2_detail::msg_connect(gr_basic_block_sptr src, pmt::pmt_t srcport, // register the subscription // this is done later... -// src->message_port_sub(srcport, pmt::pmt_cons(dst->alias_pmt(), dstport)); +// src->message_port_sub(srcport, pmt::cons(dst->alias_pmt(), dstport)); // add block uniquely to list to internal blocks if (std::find(d_blocks.begin(), d_blocks.end(), dst) == d_blocks.end()){ @@ -196,7 +197,7 @@ gr_hier_block2_detail::msg_disconnect(gr_basic_block_sptr src, pmt::pmt_t srcpor std::cout << "disconnecting message port..." << std::endl; // unregister the subscription - if already subscribed - src->message_port_unsub(srcport, pmt::pmt_cons(dst->alias_pmt(), dstport)); + src->message_port_unsub(srcport, pmt::cons(dst->alias_pmt(), dstport)); // remove edge for this message connection bool hier_out = (d_owner == src.get()) && src->message_port_is_hier_out(srcport);; @@ -474,6 +475,31 @@ gr_hier_block2_detail::flatten_aux(gr_flat_flowgraph_sptr sfg) const gr_edge_viter_t p; gr_msg_edge_viter_t q,u; + // Only run setup_rpc if ControlPort config param is enabled. + bool ctrlport_on = gr_prefs::singleton()->get_bool("ControlPort", "on", false); + + // For every block (gr_block and gr_hier_block2), set up the RPC + // interface. + for(p = edges.begin(); p != edges.end(); p++) { + gr_basic_block_sptr b; + b = p->src().block(); + + if(ctrlport_on) { + if(!b->is_rpc_set()) { + b->setup_rpc(); + b->rpc_set(); + } + } + + b = p->dst().block(); + if(ctrlport_on) { + if(!b->is_rpc_set()) { + b->setup_rpc(); + b->rpc_set(); + } + } + } + if (GR_HIER_BLOCK2_DETAIL_DEBUG) std::cout << "Flattening stream connections: " << std::endl; diff --git a/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.cc b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.cc index 3c4a75fd37..32b6a09033 100644 --- a/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.cc @@ -31,7 +31,7 @@ gr_tagged_stream_block::gr_tagged_stream_block (const std::string &name, gr_io_signature_sptr output_signature, const std::string &length_tag_key) : gr_block(name, input_signature, output_signature), - d_length_tag_key(pmt::pmt_string_to_symbol(length_tag_key)), + d_length_tag_key(pmt::string_to_symbol(length_tag_key)), d_n_input_items_reqd(input_signature->min_streams(), 0), d_length_tag_key_str(length_tag_key) { @@ -62,7 +62,7 @@ gr_tagged_stream_block::parse_length_tags( for (unsigned i = 0; i < tags.size(); i++) { for (unsigned k = 0; k < tags[i].size(); k++) { if (tags[i][k].key == d_length_tag_key) { - n_input_items_reqd[i] = pmt::pmt_to_long(tags[i][k].value); + n_input_items_reqd[i] = pmt::to_long(tags[i][k].value); remove_item_tag(i, tags[i][k]); } } @@ -84,7 +84,7 @@ gr_tagged_stream_block::update_length_tags(int n_produced, int n_ports) for (int i = 0; i < n_ports; i++) { add_item_tag(i, nitems_written(i), d_length_tag_key, - pmt::pmt_from_long(n_produced) + pmt::from_long(n_produced) ); } return; diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.cc b/gnuradio-core/src/lib/runtime/gr_top_block.cc index e47473edd8..c6118bcfdd 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_top_block.cc @@ -28,6 +28,7 @@ #include <gr_top_block.h> #include <gr_top_block_impl.h> #include <gr_io_signature.h> +#include <gr_prefs.h> #include <iostream> gr_top_block_sptr @@ -57,6 +58,10 @@ void gr_top_block::start(int max_noutput_items) { d_impl->start(max_noutput_items); + + if(gr_prefs::singleton()->get_bool("ControlPort", "on", false)) { + setup_rpc(); + } } void @@ -90,6 +95,12 @@ gr_top_block::unlock() d_impl->unlock(); } +std::string +gr_top_block::edge_list() +{ + return d_impl->edge_list(); +} + void gr_top_block::dump() { @@ -113,3 +124,37 @@ gr_top_block::to_top_block() { return cast_to_top_block_sptr(shared_from_this()); } + +void +gr_top_block::setup_rpc() +{ +#ifdef GR_CTRLPORT + // Getters + add_rpc_variable( + rpcbasic_sptr(new rpcbasic_register_get<gr_top_block, int>( + alias(), "max nouptut_items", + &gr_top_block::max_noutput_items, + pmt::mp(0), pmt::mp(8192), pmt::mp(8192), + "items", "Max number of output items", + RPC_PRIVLVL_MIN, DISPNULL))); + + if(gr_prefs::singleton()->get_bool("ControlPort", "edges_list", false)) { + add_rpc_variable( + rpcbasic_sptr(new rpcbasic_register_get<gr_top_block, std::string>( + alias(), "edge list", + &gr_top_block::edge_list, + pmt::mp(""), pmt::mp(""), pmt::mp(""), + "edges", "List of edges in the graph", + RPC_PRIVLVL_MIN, DISPNULL))); + } + + // Setters + add_rpc_variable( + rpcbasic_sptr(new rpcbasic_register_set<gr_top_block, int>( + alias(), "max noutput_items", + &gr_top_block::set_max_noutput_items, + pmt::mp(0), pmt::mp(8192), pmt::mp(8192), + "items", "Max number of output items", + RPC_PRIVLVL_MIN, DISPNULL))); +#endif /* GR_CTRLPORT */ +} diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.h b/gnuradio-core/src/lib/runtime/gr_top_block.h index 04d1e95e57..694e9575b4 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.h +++ b/gnuradio-core/src/lib/runtime/gr_top_block.h @@ -58,7 +58,7 @@ public: * allowed for any block in the flowgraph. This passes through to * the start function; see that function for more details. */ - void run(int max_noutput_items=100000); + void run(int max_noutput_items=100000000); /*! * Start the contained flowgraph. Creates one or more threads to @@ -71,7 +71,7 @@ public: * always be less than this, but this will cap it as a maximum. Use * this to adjust the maximum latency a flowgraph can exhibit. */ - void start(int max_noutput_items=100000); + void start(int max_noutput_items=100000000); /*! * Stop the running flowgraph. Notifies each thread created by the @@ -83,7 +83,7 @@ public: /*! * Wait for a flowgraph to complete. Flowgraphs complete when * either (1) all blocks indicate that they are done (typically only - * when using gr.file_source, or gr.head, or (2) after stop() has been + * when using blocks.file_source, or gr.head, or (2) after stop() has been * called to request shutdown. Calling wait on a top_block that is * not running IS NOT an error (wait returns w/o blocking). */ @@ -112,6 +112,12 @@ public: virtual void unlock(); /*! + * Returns a string that lists the edge connections in the flattened + * flowgraph. + */ + std::string edge_list(); + + /*! * Displays flattened flowgraph edges and block connectivity */ void dump(); @@ -123,6 +129,8 @@ public: void set_max_noutput_items(int nmax); gr_top_block_sptr to_top_block(); // Needed for Python type coercion + + void setup_rpc(); }; inline gr_top_block_sptr cast_to_top_block_sptr(gr_basic_block_sptr block) { diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.i b/gnuradio-core/src/lib/runtime/gr_top_block.i index 6ae4c65a99..1612ddf8c5 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.i +++ b/gnuradio-core/src/lib/runtime/gr_top_block.i @@ -38,12 +38,13 @@ private: public: ~gr_top_block(); - void start(int max_noutput_items=100000) throw (std::runtime_error); + void start(int max_noutput_items=100000000) throw (std::runtime_error); void stop(); //void wait(); //void run() throw (std::runtime_error); void lock(); void unlock() throw (std::runtime_error); + std::string edge_list(); void dump(); int max_noutput_items(); diff --git a/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc b/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc index 4a3694163b..b6d427ce27 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc +++ b/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc @@ -29,6 +29,7 @@ #include <gr_flat_flowgraph.h> #include <gr_scheduler_sts.h> #include <gr_scheduler_tpb.h> +#include <gr_prefs.h> #include <stdexcept> #include <iostream> @@ -108,6 +109,12 @@ gr_top_block_impl::start(int max_noutput_items) d_ffg->validate(); d_ffg->setup_connections(); + // Only export perf. counters if ControlPort config param is enabled + // and if the PerfCounter option 'export' is turned on. + gr_prefs *p = gr_prefs::singleton(); + if(p->get_bool("ControlPort", "on", false) && p->get_bool("PerfCounters", "export", false)) + d_ffg->enable_pc_rpc(); + d_scheduler = make_scheduler(d_ffg, d_max_noutput_items); d_state = RUNNING; } @@ -175,6 +182,15 @@ gr_top_block_impl::restart() d_state = RUNNING; } +std::string +gr_top_block_impl::edge_list() +{ + if(d_ffg) + return d_ffg->edge_list(); + else + return ""; +} + void gr_top_block_impl::dump() { diff --git a/gnuradio-core/src/lib/runtime/gr_top_block_impl.h b/gnuradio-core/src/lib/runtime/gr_top_block_impl.h index f55c3f021b..3e4da332ae 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block_impl.h +++ b/gnuradio-core/src/lib/runtime/gr_top_block_impl.h @@ -42,7 +42,7 @@ public: ~gr_top_block_impl(); // Create and start scheduler threads - void start(int max_noutput_items=100000); + void start(int max_noutput_items=100000000); // Signal scheduler threads to stop void stop(); @@ -56,6 +56,9 @@ public: // Unlock the top block at end of reconfiguration void unlock(); + // Return a string list of edges + std::string edge_list(); + // Dump the flowgraph to stdout void dump(); diff --git a/gnuradio-core/src/lib/runtime/ice_application_base.cc b/gnuradio-core/src/lib/runtime/ice_application_base.cc new file mode 100644 index 0000000000..88db6056c1 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/ice_application_base.cc @@ -0,0 +1,43 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <ice_application_base.h> + +int ice_application_common::d_reacquire_attributes(0); +bool ice_application_common::d_main_called(false); +bool ice_application_common::d_have_ice_config(false); +boost::shared_ptr<boost::thread> ice_application_common::d_thread; +std::string ice_application_common::d_endpointStr(""); + +boost::shared_ptr<ice_application_common> +ice_application_common::Instance() +{ + static boost::shared_ptr<ice_application_common> + instance(new ice_application_common()); + return instance; +} + +int ice_application_common::run(int, char**) +{ + communicator()->waitForShutdown(); + return EXIT_SUCCESS; +} diff --git a/gnuradio-core/src/lib/runtime/ice_application_base.h b/gnuradio-core/src/lib/runtime/ice_application_base.h new file mode 100644 index 0000000000..799ab9c21e --- /dev/null +++ b/gnuradio-core/src/lib/runtime/ice_application_base.h @@ -0,0 +1,222 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef ICE_APPLICATION_BASE_H +#define ICE_APPLICATION_BASE_H + +#include <gr_core_api.h> +#include <gr_prefs.h> +#include <Ice/Ice.h> +#include <boost/thread.hpp> +#include <boost/thread/mutex.hpp> +#include <stdio.h> +#include <iostream> +#include <set> +#include <string> +#include <stdio.h> + +namespace { + static const unsigned int ICEAPPLICATION_ACTIVATION_TIMEOUT_MS(600); +}; + + +class GR_CORE_API ice_application_common : public Ice::Application +{ + public: + template<typename TserverBase, typename TserverClass> friend class ice_application_base; + static boost::shared_ptr<ice_application_common> Instance(); + ~ice_application_common() {;} + static int d_reacquire_attributes; + + protected: + static bool d_main_called, d_have_ice_config; + static std::string d_endpointStr; + static boost::shared_ptr<boost::thread> d_thread; + ice_application_common() {;} + int run(int, char*[]); +}; + +template<typename TserverBase, typename TserverClass> +class ice_application_base +{ +public: + boost::shared_ptr<ice_application_common> d_application; + ice_application_base(TserverClass* _this); + ~ice_application_base() {;} + + static TserverBase* i(); + static const std::vector<std::string> endpoints(); + +protected: + bool have_ice_config() { return d_application->d_have_ice_config; } + void set_endpoint(const std::string& endpoint) { d_application->d_endpointStr = endpoint;} + + //this one is the key... overwrite in templated/inherited variants + virtual TserverBase* i_impl() = 0; + + //tools for the i_impl... + //tell it when it has to resync with the communicator + virtual bool reacquire_sync(); + virtual void sync_reacquire(); + + static TserverClass* d_this; + + int d_reacquire; + //static int d_reacquire_attributes; + +private: + void starticeexample(); + + bool application_started(); + + int run(int, char*[]); + + static void kickoff(); +}; + +template<typename TserverBase, typename TserverClass> +TserverClass* ice_application_base<TserverBase, TserverClass>::d_this(0); + +//template<typename TserverBase, typename TserverClass> +//int ice_application_base<TserverBase, TserverClass>::d_reacquire_attributes(0); + +template<typename TserverBase, typename TserverClass> +ice_application_base<TserverBase, TserverClass>::ice_application_base(TserverClass* _this) + : d_reacquire(0) +{ + //d_reacquire_attributes = 0; + d_this = _this; + d_application = ice_application_common::Instance(); +} + +template<typename TserverBase, typename TserverClass> +void ice_application_base<TserverBase, TserverClass>::starticeexample() +{ + char* argv[2]; + argv[0] = (char*)""; + + std::string conffile = gr_prefs::singleton()->get_string("ControlPort", "config", ""); + + if(conffile.size() > 0) { + std::stringstream iceconf; + ice_application_common::d_have_ice_config = true; + ice_application_common::d_main_called = true; + iceconf << conffile; + d_application->main(0, argv, iceconf.str().c_str()); + } + else { + ice_application_common::d_have_ice_config = false; + ice_application_common::d_main_called = true; + d_application->main(0, argv); + } +} + +template<typename TserverBase, typename TserverClass> +void ice_application_base<TserverBase, TserverClass>::kickoff() +{ + static bool run_once = false; + + //if(!d_this->application_started()) { + if(!run_once) { + ++d_this->d_application->d_reacquire_attributes; + + ice_application_common::d_thread = boost::shared_ptr<boost::thread> + (new boost::thread(boost::bind(&ice_application_base::starticeexample, d_this))); + + ::timespec timer_ts, rem_ts; + timer_ts.tv_sec = 0; timer_ts.tv_nsec = ICEAPPLICATION_ACTIVATION_TIMEOUT_MS*1000; + + int iter = 0; + while(!d_this->application_started()) { + ::nanosleep(&timer_ts, &rem_ts); + if(!d_this->application_started()) + std::cout << "@"; + if(iter++ > 100) { + std::cout << "ice_application_base::kickoff(), timeout waiting to get communicator() d_application->main() might have failed?!" << std::endl;; + break; + } + } + + run_once = true; + } + + return; +} + + +template<typename TserverBase, typename TserverClass> +bool ice_application_base<TserverBase, TserverClass>::reacquire_sync() +{ + return (d_this->d_reacquire != d_application->d_reacquire_attributes); +} + +template<typename TserverBase, typename TserverClass> +void ice_application_base<TserverBase, TserverClass>::sync_reacquire() +{ + d_this->d_reacquire = d_application->d_reacquire_attributes; +} + + +template<typename TserverBase, typename TserverClass> +const std::vector<std::string> ice_application_base<TserverBase, TserverClass>::endpoints() +{ + std::vector<std::string> ep; ep.push_back(d_this->d_application->d_endpointStr); return ep; +} + +template<typename TserverBase, typename TserverClass> +TserverBase* ice_application_base<TserverBase, TserverClass>::i() +{ + //printf("indacall\n"); + + assert(d_this != 0); + if(!d_this->application_started()) { + //printf("anotherkickoff\n"); + kickoff(); + } + //printf("donekickedoff\n"); + + /*else if(!d_proxy) { + d_proxy = d_this->i_impl(); + assert(d_proxy != 0); + }*/ + + return d_this->i_impl(); +} + +/*template<typename TserverBase, typename TserverClass> + int ice_application_base<TserverBase, TserverClass>::run(int argc, char* argv[]) { + int implreturn(run_impl(argc, argv)); + ice_application_base<TserverBase, TserverClass>::communicator()->waitForShutdown(); + return implreturn; + }*/ + +template<typename TserverBase, typename TImplClass> +bool ice_application_base<TserverBase, TImplClass>::application_started() +{ + return ice_application_base<TserverBase, TImplClass>::d_this->d_application->communicator(); +} + +/*template<typename TserverBase, typename TImplClass> +int ice_application_base<TserverBase, TImplClass>::run_impl(int argc, char* argv[]) { return EXIT_SUCCESS; } +*/ + +#endif diff --git a/gnuradio-core/src/lib/runtime/ice_server_template.h b/gnuradio-core/src/lib/runtime/ice_server_template.h new file mode 100644 index 0000000000..8ddb03cc8e --- /dev/null +++ b/gnuradio-core/src/lib/runtime/ice_server_template.h @@ -0,0 +1,96 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef ICE_SERVER_TEMPLATE_H +#define ICE_SERVER_TEMPLATE_H + +#include <ice_application_base.h> +#include <iostream> + +template<typename TserverBase, typename TserverClass, typename TImplClass, typename TIceClass> +class ice_server_template : public ice_application_base<TserverBase, TImplClass> +{ +public: + ice_server_template(TImplClass* _this, + const std::string& contolPortName, + const std::string& endpointName); + ~ice_server_template(); + +protected: + //virtual bool application_started(); + TserverBase* i_impl(); + friend class ice_application_base<TserverBase, TImplClass>; + +private: + //virtual int run_impl(int, char*[]); + Ice::ObjectAdapterPtr d_adapter; + TserverBase* d_iceserver; + const std::string d_contolPortName, d_endpointName; +}; + +template<typename TserverBase, typename TserverClass, typename TImplClass, typename TIceClass> +ice_server_template<TserverBase, TserverClass, TImplClass, TIceClass>::ice_server_template + (TImplClass* _this, const std::string& controlPortName, const std::string& endpointName) + : ice_application_base<TserverBase, TImplClass>(_this), + d_iceserver(0), + d_contolPortName(controlPortName), + d_endpointName(endpointName) +{;} + +template<typename TserverBase, typename TserverClass, typename TImplClass, typename TIceClass> +ice_server_template<TserverBase, TserverClass,TImplClass, TIceClass>::~ice_server_template() +{ + if(d_adapter) { + d_adapter->deactivate(); + delete(d_iceserver); + d_adapter = 0; + } +} + +template<typename TserverBase, typename TserverClass, typename TImplClass, typename TIceClass> +TserverBase* ice_server_template<TserverBase, TserverClass, TImplClass, TIceClass>::i_impl() +{ + if(ice_application_base<TserverBase, TImplClass>::d_this->reacquire_sync()) { + d_adapter = (ice_application_base<TserverBase, TImplClass>::d_this->have_ice_config()) ? + ice_application_base<TserverBase, TImplClass>::d_this->d_this->d_application->communicator()->createObjectAdapter(d_contolPortName) : + ice_application_base<TserverBase, TImplClass>::d_this->d_this->d_application->communicator()->createObjectAdapterWithEndpoints(d_contolPortName,"tcp -h *"); + + TserverClass* server_ice(new TserverClass()); + TIceClass obj(server_ice); + + Ice::Identity id(ice_application_base<TserverBase, TImplClass>::d_this->d_this->d_application->communicator()->stringToIdentity(d_endpointName)); + d_adapter->add(obj, id); + d_adapter->activate(); + ice_application_base<TserverBase, TImplClass>::d_this->set_endpoint(ice_application_common::communicator()->proxyToString(d_adapter->createDirectProxy(id))); + + std::cout << std::endl << "Ice Radio Endpoint: " + << ice_server_template<TserverBase, TserverClass, TImplClass, TIceClass>::endpoints()[0] + << std::endl; + + d_iceserver = (TserverBase*) server_ice; + ice_application_base<TserverBase, TImplClass>::d_this->sync_reacquire(); + } + + return d_iceserver; +} + +#endif /* ICE_SERVER_TEMPLATE_H */ diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.h b/gnuradio-core/src/lib/runtime/nop.h index ed628385ce..5b3166da7b 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_ff.h +++ b/gnuradio-core/src/lib/runtime/nop.h @@ -1,9 +1,9 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio - * + * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) @@ -20,37 +20,38 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_GR_MULTIPLY_FF_H -#define INCLUDED_GR_MULTIPLY_FF_H +#ifndef INCLUDED_CTRLPORT_NOP_H +#define INCLUDED_CTRLPORT_NOP_H -#include <gr_core_api.h> +#include <ctrlport/api.h> #include <gr_sync_block.h> -class gr_multiply_ff; -typedef boost::shared_ptr<gr_multiply_ff> gr_multiply_ff_sptr; - -GR_CORE_API gr_multiply_ff_sptr -gr_make_multiply_ff (size_t vlen=1); - -/*! - * \brief Multiply streams of complex values - * \ingroup math_blk - */ - -class GR_CORE_API gr_multiply_ff : public gr_sync_block -{ - private: - friend GR_CORE_API gr_multiply_ff_sptr - gr_make_multiply_ff (size_t vlen); - gr_multiply_ff (size_t vlen); - - size_t d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - +namespace gr { + namespace ctrlport { + + /*! + * \brief A NOP block for testing ctrlport + * + */ + class CTRLPORT_API nop : virtual public gr_sync_block + { + public: + // gr::ctrlport::nop::sptr + typedef boost::shared_ptr<nop> sptr; + + /*! + * Build a simple test block + */ + static sptr make(size_t itemsize, int a, int b); + + virtual void set_a(int b) = 0; + virtual void set_b(int b) = 0; + virtual int a() const = 0; + virtual int b() const = 0; + }; + + } /* namespace ctrlport */ +} /* namespace gr */ + +#endif /* INCLUDED_CTRLPORT_NOP_H */ -#endif /* INCLUDED_GR_MULTIPLY_FF_H */ diff --git a/gnuradio-core/src/lib/runtime/nop_impl.cc b/gnuradio-core/src/lib/runtime/nop_impl.cc new file mode 100644 index 0000000000..def1740678 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/nop_impl.cc @@ -0,0 +1,119 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "nop_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace ctrlport { + + nop::sptr + nop::make(size_t itemsize, int a, int b) + { + return gnuradio::get_initial_sptr + (new nop_impl(itemsize, a, b)); + } + + + nop_impl::nop_impl(size_t itemsize, int a, int b) + : gr_sync_block("nop", + gr_make_io_signature(1, 1, itemsize), + gr_make_io_signature(0, 0, 0)) + { + set_a(a); + set_b(b); + } + + nop_impl::~nop_impl() + { + } + + void + nop_impl::set_a(int a) + { + d_a = a; + } + + void + nop_impl::set_b(int b) + { + d_b = b; + } + + int + nop_impl::a() const + { + return d_a; + } + + int + nop_impl::b() const + { + return d_b; + } + + int + nop_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + return noutput_items; + } + + void + nop_impl::setup_rpc() + { + d_get_32i_rpcs.push_back(get_32i_sptr + (new get_32i_t(d_name, "a", this, unique_id(), + &nop_impl::a, + pmt::mp(-128), pmt::mp(127), pmt::mp(0), + "", "Value of a", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_get_32i_rpcs.push_back(get_32i_sptr + (new get_32i_t(d_name, "b", this, unique_id(), + &nop_impl::b, + pmt::mp(-128), pmt::mp(127), pmt::mp(0), + "", "Value of b", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_set_32i_rpcs.push_back(set_32i_sptr + (new set_32i_t(d_name, "a", this, unique_id(), + &nop_impl::set_a, + pmt::mp(-128), pmt::mp(127), pmt::mp(0), + "", "Value of a", + RPC_PRIVLVL_MIN, DISPNULL))); + + d_set_32i_rpcs.push_back(set_32i_sptr + (new set_32i_t(d_name, "b", this, unique_id(), + &nop_impl::set_b, + pmt::mp(-128), pmt::mp(127), pmt::mp(0), + "", "Value of b", + RPC_PRIVLVL_MIN, DISPNULL))); + } + + } /* namespace ctrlport */ +} /* namespace gr */ diff --git a/gnuradio-core/src/lib/runtime/nop_impl.h b/gnuradio-core/src/lib/runtime/nop_impl.h new file mode 100644 index 0000000000..a39ddac8f9 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/nop_impl.h @@ -0,0 +1,67 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_CTRLPORT_NOP_IMPL_H +#define INCLUDED_CTRLPORT_NOP_IMPL_H + +#include <ctrlport/nop.h> +#include <ctrlport/rpcregisterhelpers.h> +#include <boost/thread/shared_mutex.hpp> + +namespace gr { + namespace ctrlport { + + class CTRLPORT_API nop_impl : public nop + { + private: + typedef rpcbasic_register_get<nop_impl, int> get_32i_t; + typedef rpcbasic_register_set<nop_impl, int> set_32i_t; + + typedef boost::shared_ptr<get_32i_t> get_32i_sptr; + typedef boost::shared_ptr<set_32i_t> set_32i_sptr; + + std::vector<get_32i_sptr> d_get_32i_rpcs; + std::vector<set_32i_sptr> d_set_32i_rpcs; + + void setup_rpc(); + + int d_a, d_b; + + public: + nop_impl(size_t itemsize, int a, int b); + ~nop_impl(); + + void set_a(int a); + void set_b(int b); + int a() const; + int b() const; + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace ctrlport */ +} /* namespace gr */ + +#endif /* INCLUDED_CTRLPORT_NOP_IMPL_H */ + diff --git a/gnuradio-core/src/lib/runtime/pycallback_object.h b/gnuradio-core/src/lib/runtime/pycallback_object.h new file mode 100644 index 0000000000..f2cd085641 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/pycallback_object.h @@ -0,0 +1,205 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <iostream> +#include <rpcregisterhelpers.h> +#include <ice_application_base.h> +#include <IcePy_Communicator.h> +#include <pythread.h> +#include <boost/format.hpp> + +enum pyport_t { + PYPORT_STRING, + PYPORT_FLOAT +}; + +class Instance +{ +public: + static boost::shared_ptr<ice_application_common> get_application() + { + return ice_application_common::Instance(); + } + static Ice::CommunicatorPtr get_swig_communicator() + { + return get_application()->communicator(); + } +}; + +int pycallback_object_count = 500; + +// a simple to-PMT converter template class-function +template <class myType> class pmt_assist +{ +public: + static pmt::pmt_t make(myType _val) + { + return pmt::mp(_val); + } +}; + +/* template specializations for vectors that cant use pmt::mp() */ +template<> +pmt::pmt_t pmt_assist<std::vector<float> >::make(std::vector<float> _val) +{ + return pmt::init_f32vector(_val.size(), &_val[0]); +} + +template<> +pmt::pmt_t pmt_assist<std::vector<gr_complex> >::make(std::vector<gr_complex> _val) +{ + return pmt::init_c32vector(_val.size(), &_val[0]); +} + +template <class myType> class pycallback_object +{ +public: + pycallback_object(std::string name, std::string functionbase, + std::string units, std::string desc, + myType min, myType max, myType deflt, + DisplayType dtype) : + d_callback(NULL), + d_functionbase(functionbase), d_units(units), d_desc(desc), + d_min(min), d_max(max), d_deflt(deflt), d_dtype(dtype), + d_name(name), d_id(pycallback_object_count++) + { + d_callback = NULL; + } + + void add_rpc_variable(rpcbasic_sptr s) + { + d_rpc_vars.push_back(s); + } + + myType get() { + myType rVal; + if(d_callback == NULL) { + printf("WARNING: pycallback_object get() called without py callback set!\n"); + return rVal; + } + else { + // obtain PyGIL + PyGILState_STATE state = PyGILState_Ensure(); + + PyObject *func; + //PyObject *arglist; + PyObject *result; + + func = (PyObject *) d_callback; // Get Python function + //arglist = Py_BuildValue(""); // Build argument list + result = PyEval_CallObject(func,NULL); // Call Python + //result = PyEval_CallObject(func,arglist); // Call Python + //Py_DECREF(arglist); // Trash arglist + if(result) { // If no errors, return double + rVal = pyCast(result); + } + Py_XDECREF(result); + + // release PyGIL + PyGILState_Release(state); + return rVal; + } + } + + void set_callback(PyObject *cb) + { + d_callback = cb; + } + + void setup_rpc() + { +#ifdef GR_CTRLPORT + add_rpc_variable( + rpcbasic_sptr(new rpcbasic_register_get<pycallback_object, myType>( + (boost::format("%s%d") % d_name % d_id).str() , d_functionbase.c_str(), + &pycallback_object::get, pmt_assist<myType>::make(d_min), + pmt_assist<myType>::make(d_max), pmt_assist<myType>::make(d_deflt), + d_units.c_str(), d_desc.c_str(), RPC_PRIVLVL_MIN, d_dtype))); +#endif /* GR_CTRLPORT */ + } + +private: + PyObject* d_callback; + std::string d_functionbase, d_units, d_desc; + myType d_min, d_max, d_deflt; + DisplayType d_dtype; + + myType pyCast(PyObject* obj) { + printf("TYPE NOT IMPLEMENTED!\n"); + assert(0); + }; + std::vector<boost::any> d_rpc_vars; // container for all RPC variables + std::string d_name; + int d_id; + +}; + + +// template specialization conversion functions +// get data out of the PyObject and into the real world +template<> +std::string pycallback_object<std::string>::pyCast(PyObject* obj) +{ + return std::string(PyString_AsString(obj)); +} + +template<> +double pycallback_object<double>::pyCast(PyObject* obj) +{ + return PyFloat_AsDouble(obj); +} + +template<> +float pycallback_object<float>::pyCast(PyObject* obj) +{ + return (float)PyFloat_AsDouble(obj); +} + +template<> +int pycallback_object<int>::pyCast(PyObject* obj) +{ + return PyInt_AsLong(obj); +} + +template<> +std::vector<float> pycallback_object<std::vector<float> >::pyCast(PyObject* obj) +{ + int size = PyObject_Size(obj); + std::vector<float> rval(size); + for(int i=0; i<size; i++) { + rval[i] = (float)PyFloat_AsDouble(PyList_GetItem(obj, i)); + } + return rval; +} + +template<> +std::vector<gr_complex> pycallback_object<std::vector<gr_complex> >::pyCast(PyObject* obj) +{ + int size = PyObject_Size(obj); + std::vector<gr_complex> rval(size); + for(int i=0; i<size; i++){ rval[i] = \ + gr_complex((float)PyComplex_RealAsDouble(PyList_GetItem(obj, i)), + (float)PyComplex_ImagAsDouble(PyList_GetItem(obj, i))); + } + return rval; +} +// TODO: add more template specializations as needed! diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.cc b/gnuradio-core/src/lib/runtime/qa_block_tags.cc index d6b1065e32..c3c18cac01 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.cc +++ b/gnuradio-core/src/lib/runtime/qa_block_tags.cc @@ -23,6 +23,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> #endif + #include <qa_block_tags.h> #include <gr_block.h> #include <gr_top_block.h> @@ -31,15 +32,11 @@ #include <gr_head.h> #include <gr_annotator_alltoall.h> #include <gr_annotator_1to1.h> -#include <gr_keep_one_in_n.h> -#include <gr_firdes.h> #include <gr_tags.h> // ---------------------------------------------------------------- -using namespace pmt; - // set to 1 to turn on debug output // The debug output fully checks that the tags seen are what are expected. While // this behavior currently works with our implementation, there is no guarentee @@ -119,39 +116,39 @@ qa_block_tags::t1 () str1 << ann1->name() << ann1->unique_id(); str2 << ann2->name() << ann2->unique_id(); - pmt_t expected_tags3[8]; - expected_tags3[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); - expected_tags3[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags3[2] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); - expected_tags3[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags3[4] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(2)); - expected_tags3[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags3[6] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags3[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - - pmt_t expected_tags4[8]; - expected_tags4[0] = mp(pmt_from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); - expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); - expected_tags4[2] = mp(pmt_from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); - expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags4[4] = mp(pmt_from_uint64(20000), mp(str2.str()), mp("seq"), mp(2)); - expected_tags4[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags4[6] = mp(pmt_from_uint64(30000), mp(str2.str()), mp("seq"), mp(3)); - expected_tags4[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); + pmt::pmt_t expected_tags3[8]; + expected_tags3[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); + expected_tags3[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags3[2] = mp(pmt::from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); + expected_tags3[3] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags3[4] = mp(pmt::from_uint64(20000), mp(str1.str()), mp("seq"), mp(2)); + expected_tags3[5] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); + expected_tags3[6] = mp(pmt::from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags3[7] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); + + pmt::pmt_t expected_tags4[8]; + expected_tags4[0] = mp(pmt::from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); + expected_tags4[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); + expected_tags4[2] = mp(pmt::from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); + expected_tags4[3] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags4[4] = mp(pmt::from_uint64(20000), mp(str2.str()), mp("seq"), mp(2)); + expected_tags4[5] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); + expected_tags4[6] = mp(pmt::from_uint64(30000), mp(str2.str()), mp("seq"), mp(3)); + expected_tags4[7] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); std::cout << std::endl << "qa_block_tags::t1" << std::endl; // For annotator 3, we know it gets tags from ann0 and ann1, test this for(size_t i = 0; i < tags3.size(); i++) { std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags3[i]), pmt_write_string(expected_tags3[i])); + CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags3[i]), pmt::write_string(expected_tags3[i])); } // For annotator 4, we know it gets tags from ann0 and ann2, test this std::cout << std::endl; for(size_t i = 0; i < tags4.size(); i++) { std::cout << "tags4[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i])); + CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags4[i]), pmt::write_string(expected_tags4[i])); } #endif } @@ -209,33 +206,33 @@ qa_block_tags::t2 () str0 << ann0->name() << ann0->unique_id(); str1 << ann1->name() << ann1->unique_id(); - pmt_t expected_tags2[12]; - expected_tags2[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); - expected_tags2[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags2[2] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); - expected_tags2[3] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags2[4] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags2[5] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags2[6] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(6)); - expected_tags2[7] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags2[8] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags2[9] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(9)); - expected_tags2[10] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - expected_tags2[11] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); - - pmt_t expected_tags4[12]; - expected_tags4[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(2)); - expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags4[2] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); - expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(5)); - expected_tags4[4] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags4[5] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags4[6] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(8)); - expected_tags4[7] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags4[8] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags4[9] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(11)); - expected_tags4[10] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - expected_tags4[11] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); + pmt::pmt_t expected_tags2[12]; + expected_tags2[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); + expected_tags2[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags2[2] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); + expected_tags2[3] = mp(pmt::from_uint64(10000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags2[4] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags2[5] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags2[6] = mp(pmt::from_uint64(20000), mp(str1.str()), mp("seq"), mp(6)); + expected_tags2[7] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); + expected_tags2[8] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); + expected_tags2[9] = mp(pmt::from_uint64(30000), mp(str1.str()), mp("seq"), mp(9)); + expected_tags2[10] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); + expected_tags2[11] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); + + pmt::pmt_t expected_tags4[12]; + expected_tags4[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(2)); + expected_tags4[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags4[2] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); + expected_tags4[3] = mp(pmt::from_uint64(10000), mp(str1.str()), mp("seq"), mp(5)); + expected_tags4[4] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags4[5] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags4[6] = mp(pmt::from_uint64(20000), mp(str1.str()), mp("seq"), mp(8)); + expected_tags4[7] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); + expected_tags4[8] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); + expected_tags4[9] = mp(pmt::from_uint64(30000), mp(str1.str()), mp("seq"), mp(11)); + expected_tags4[10] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); + expected_tags4[11] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); std::cout << std::endl << "qa_block_tags::t2" << std::endl; @@ -245,13 +242,13 @@ qa_block_tags::t2 () // inconceivable for ann3 to have it wrong. for(size_t i = 0; i < tags2.size(); i++) { std::cout << "tags2[" << i << "] = " << tags2[i] << "\t\t" << expected_tags2[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags2[i]), pmt_write_string(expected_tags2[i])); + CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags2[i]), pmt::write_string(expected_tags2[i])); } std::cout << std::endl; for(size_t i = 0; i < tags4.size(); i++) { std::cout << "tags2[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i])); + CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags4[i]), pmt::write_string(expected_tags4[i])); } #endif } @@ -303,39 +300,39 @@ qa_block_tags::t3 () str1 << ann1->name() << ann1->unique_id(); str2 << ann2->name() << ann2->unique_id(); - pmt_t expected_tags3[8]; - expected_tags3[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); - expected_tags3[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags3[2] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); - expected_tags3[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags3[4] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(2)); - expected_tags3[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags3[6] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags3[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - - pmt_t expected_tags4[8]; - expected_tags4[0] = mp(pmt_from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); - expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); - expected_tags4[2] = mp(pmt_from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); - expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags4[4] = mp(pmt_from_uint64(20000), mp(str2.str()), mp("seq"), mp(2)); - expected_tags4[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags4[6] = mp(pmt_from_uint64(30000), mp(str2.str()), mp("seq"), mp(3)); - expected_tags4[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); + pmt::pmt_t expected_tags3[8]; + expected_tags3[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); + expected_tags3[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags3[2] = mp(pmt::from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); + expected_tags3[3] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags3[4] = mp(pmt::from_uint64(20000), mp(str1.str()), mp("seq"), mp(2)); + expected_tags3[5] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); + expected_tags3[6] = mp(pmt::from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags3[7] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); + + pmt::pmt_t expected_tags4[8]; + expected_tags4[0] = mp(pmt::from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); + expected_tags4[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); + expected_tags4[2] = mp(pmt::from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); + expected_tags4[3] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags4[4] = mp(pmt::from_uint64(20000), mp(str2.str()), mp("seq"), mp(2)); + expected_tags4[5] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); + expected_tags4[6] = mp(pmt::from_uint64(30000), mp(str2.str()), mp("seq"), mp(3)); + expected_tags4[7] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); std::cout << std::endl << "qa_block_tags::t3" << std::endl; // For annotator 3, we know it gets tags from ann0 and ann1, test this for(size_t i = 0; i < tags3.size(); i++) { std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags3[i]), pmt_write_string(expected_tags3[i])); + CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags3[i]), pmt::write_string(expected_tags3[i])); } // For annotator 4, we know it gets tags from ann0 and ann2, test this std::cout << std::endl; for(size_t i = 0; i < tags4.size(); i++) { std::cout << "tags4[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i])); + CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags4[i]), pmt::write_string(expected_tags4[i])); } #endif } @@ -370,6 +367,7 @@ qa_block_tags::t4 () } +/* void qa_block_tags::t5 () { @@ -411,23 +409,23 @@ qa_block_tags::t5 () str1 << ann1->name() << ann1->unique_id(); str2 << ann2->name() << ann2->unique_id(); - pmt_t expected_tags1[5]; - expected_tags1[0] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags1[1] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(1)); - expected_tags1[2] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags1[3] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(3)); - - pmt_t expected_tags2[10]; - expected_tags2[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); - expected_tags2[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags2[2] = mp(pmt_from_uint64(1000), mp(str1.str()), mp("seq"), mp(1)); - expected_tags2[3] = mp(pmt_from_uint64(1000), mp(str0.str()), mp("seq"), mp(1)); - expected_tags2[4] = mp(pmt_from_uint64(2000), mp(str1.str()), mp("seq"), mp(2)); - expected_tags2[5] = mp(pmt_from_uint64(2000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags2[6] = mp(pmt_from_uint64(3000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags2[7] = mp(pmt_from_uint64(3000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags2[8] = mp(pmt_from_uint64(4000), mp(str1.str()), mp("seq"), mp(4)); - expected_tags2[9] = mp(pmt_from_uint64(4000), mp(str0.str()), mp("seq"), mp(4)); + pmt::pmt_t expected_tags1[5]; + expected_tags1[0] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags1[1] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(1)); + expected_tags1[2] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags1[3] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(3)); + + pmt::pmt_t expected_tags2[10]; + expected_tags2[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); + expected_tags2[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags2[2] = mp(pmt::from_uint64(1000), mp(str1.str()), mp("seq"), mp(1)); + expected_tags2[3] = mp(pmt::from_uint64(1000), mp(str0.str()), mp("seq"), mp(1)); + expected_tags2[4] = mp(pmt::from_uint64(2000), mp(str1.str()), mp("seq"), mp(2)); + expected_tags2[5] = mp(pmt::from_uint64(2000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags2[6] = mp(pmt::from_uint64(3000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags2[7] = mp(pmt::from_uint64(3000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags2[8] = mp(pmt::from_uint64(4000), mp(str1.str()), mp("seq"), mp(4)); + expected_tags2[9] = mp(pmt::from_uint64(4000), mp(str0.str()), mp("seq"), mp(4)); std::cout << std::endl << "qa_block_tags::t5" << std::endl; @@ -435,7 +433,7 @@ qa_block_tags::t5 () std::cout << "tags1.size(): " << tags1.size() << std::endl; for(size_t i = 0; i < tags1.size(); i++) { std::cout << "tags1[" << i << "] = " << tags1[i] << "\t\t" << expected_tags1[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags1[i]), pmt_write_string(expected_tags1[i])); + CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags1[i]), pmt::write_string(expected_tags1[i])); } // annotator 2 gets tags from annotators 0 and 1 @@ -443,8 +441,8 @@ qa_block_tags::t5 () std::cout << "tags2.size(): " << tags2.size() << std::endl; for(size_t i = 0; i < tags2.size(); i++) { std::cout << "tags2[" << i << "] = " << tags2[i] << "\t\t" << expected_tags2[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags2[i]), pmt_write_string(expected_tags2[i])); + CPPUNIT_ASSERT_EQUAL(pmt::write_string(tags2[i]), pmt::write_string(expected_tags2[i])); } #endif } - +*/ diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.h b/gnuradio-core/src/lib/runtime/qa_block_tags.h index 6b7e5975d1..039d345cdf 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.h +++ b/gnuradio-core/src/lib/runtime/qa_block_tags.h @@ -35,7 +35,7 @@ class qa_block_tags : public CppUnit::TestCase { CPPUNIT_TEST (t2); CPPUNIT_TEST (t3); CPPUNIT_TEST (t4); - CPPUNIT_TEST (t5); + //CPPUNIT_TEST (t5); CPPUNIT_TEST_SUITE_END (); private: @@ -44,7 +44,7 @@ class qa_block_tags : public CppUnit::TestCase { void t2 (); void t3 (); void t4 (); - void t5 (); + //void t5 (); }; diff --git a/gnuradio-core/src/lib/runtime/qa_set_msg_handler.cc b/gnuradio-core/src/lib/runtime/qa_set_msg_handler.cc index c84a219bd1..ac06a3f8bc 100644 --- a/gnuradio-core/src/lib/runtime/qa_set_msg_handler.cc +++ b/gnuradio-core/src/lib/runtime/qa_set_msg_handler.cc @@ -37,8 +37,6 @@ #define VERBOSE 0 -using namespace pmt; - /* * The gr_nop block has been instrumented so that it counts * the number of messages sent to it. We use this feature @@ -65,9 +63,9 @@ void qa_set_msg_handler::t0() tb->start(); // Send them... - pmt_t port(pmt_intern("port")); + pmt::pmt_t port(pmt::intern("port")); for (int i = 0; i < NMSGS; i++){ - send(nop, port, mp(mp("example-msg"), mp(i))); + send(nop, port, pmt::mp(pmt::mp("example-msg"), pmt::mp(i))); } // Give the messages a chance to be processed diff --git a/gnuradio-core/src/lib/runtime/rpccallbackregister_base.h b/gnuradio-core/src/lib/runtime/rpccallbackregister_base.h new file mode 100644 index 0000000000..dbfda4ed47 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/rpccallbackregister_base.h @@ -0,0 +1,105 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef RPCCALLBACKREGISTER_BASE_H +#define RPCCALLBACKREGISTER_BASE_H + +#include <gruel/msg_accepter.h> +#include <gruel/msg_producer.h> + +typedef uint32_t DisplayType; + +// DisplayType Plotting types +const uint32_t DISPNULL = 0x0000; +const uint32_t DISPTIME = 0x0001; +const uint32_t DISPXY = 0x0002; +const uint32_t DISPPSD = 0x0004; +const uint32_t DISPSPEC = 0x0008; +const uint32_t DISPRAST = 0x0010; + +// DisplayType Options +const uint32_t DISPOPTCPLX = 0x0100; +const uint32_t DISPOPTLOG = 0x0200; +const uint32_t DISPOPTSTEM = 0x0400; +const uint32_t DISPOPTSTRIP = 0x0800; +const uint32_t DISPOPTSCATTER = 0x1000; + +enum priv_lvl_t { + RPC_PRIVLVL_ALL = 0, + RPC_PRIVLVL_MIN = 9, + RPC_PRIVLVL_NONE = 10 +}; + +enum KnobType { + KNOBBOOL, KNOBCHAR, KNOBINT, KNOBFLOAT, + KNOBDOUBLE, KNOBSTRING, KNOBLONG, KNOBVECBOOL, + KNOBVECCHAR, KNOBVECINT, KNOBVECFLOAT, KNOBVECDOUBLE, + KNOBVECSTRING, KNOBVECLONG +}; + +struct callbackregister_base +{ + struct callback_base_t + { + public: + callback_base_t(const priv_lvl_t priv_, const std::string& units_, + const DisplayType display_, const std::string& desc_, + const pmt::pmt_t min_, const pmt::pmt_t max_, const pmt::pmt_t def) + : priv(priv_), units(units_), description(desc_), + min(min_), max(max_), defaultvalue(def), display(display_) + { + } + + priv_lvl_t priv; + std::string units, description; + pmt::pmt_t min, max, defaultvalue; + DisplayType display; + }; + + template<typename T, typename Tsptr> + class callback_t : public callback_base_t + { + public: + callback_t(T* callback_, priv_lvl_t priv_, + const std::string& units_, const DisplayType display_, const:: std::string& desc_, + const pmt::pmt_t& min_, const pmt::pmt_t& max_, const pmt::pmt_t& def_) : + callback_base_t(priv_, units_, display_, desc_, min_, max_, def_), + callback(callback_) + { + } + + Tsptr callback; + }; + + typedef callback_t<gruel::msg_accepter, gruel::msg_accepter_sptr> configureCallback_t; + typedef callback_t<gruel::msg_producer, gruel::msg_producer_sptr> queryCallback_t; + + callbackregister_base() {;} + virtual ~callbackregister_base() {;} + + virtual void registerConfigureCallback(const std::string &id, const configureCallback_t callback) = 0; + virtual void unregisterConfigureCallback(const std::string &id) = 0; + virtual void registerQueryCallback(const std::string &id, const queryCallback_t callback) = 0; + virtual void unregisterQueryCallback(const std::string &id) = 0; +}; + +#endif /* RPCCALLBACKREGISTER_BASE_H */ diff --git a/gnuradio-core/src/lib/runtime/rpcmanager.cc b/gnuradio-core/src/lib/runtime/rpcmanager.cc new file mode 100644 index 0000000000..4d164b63f3 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/rpcmanager.cc @@ -0,0 +1,72 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <rpcmanager.h> +#include <iostream> +#include <stdexcept> + +bool rpcmanager::booter_registered(false); +bool rpcmanager::aggregator_registered(false); +rpcserver_booter_base* rpcmanager::boot(0); +std::auto_ptr<rpcserver_booter_aggregator> rpcmanager::aggregator(0); + +rpcmanager::rpcmanager() {;} + +rpcmanager::~rpcmanager() +{ + if(boot) + delete boot; +} + +rpcserver_booter_base* +rpcmanager::get() +{ + if(aggregator_registered) { + return aggregator.get(); + } + else if(booter_registered) { + return boot; + } + assert(booter_registered || aggregator_registered); + return boot; +} + +void +rpcmanager::register_booter(rpcserver_booter_base* booter) +{ + if(make_aggregator && !aggregator_registered) { + aggregator.reset(new rpcserver_booter_aggregator()); + aggregator_registered = true; + } + + if(aggregator_registered) { + rpcmanager::rpcserver_booter_base_sptr bootreg(booter); + aggregator->agg()->registerServer(bootreg); + } + else if(!booter_registered) { + boot = booter; + booter_registered = true; + } + else { + throw std::runtime_error("rpcmanager: Aggregator not in use, and a rpc booter is already registered\n"); + } +} diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h b/gnuradio-core/src/lib/runtime/rpcmanager.h index 826e287714..8cb176b2e5 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h +++ b/gnuradio-core/src/lib/runtime/rpcmanager.h @@ -1,9 +1,9 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio - * + * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) @@ -20,38 +20,40 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_GR_MULTIPLY_CONJUGATE_CC_H -#define INCLUDED_GR_MULTIPLY_CONJUGATE_CC_H +#ifndef RPCMANAGER_H +#define RPCMANAGER_H #include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_multiply_conjugate_cc; -typedef boost::shared_ptr<gr_multiply_conjugate_cc> -gr_multiply_conjugate_cc_sptr; +#include <rpcmanager_base.h> +#include <rpcserver_booter_aggregator.h> +#include <memory> +#include <iostream> -GR_CORE_API gr_multiply_conjugate_cc_sptr -gr_make_multiply_conjugate_cc (size_t vlen=1); +class GR_CORE_API rpcmanager : public virtual rpcmanager_base +{ + public: + rpcmanager(); + ~rpcmanager(); -/*! - * \brief Multiplies a stream by the conjugate of the second stream - * \ingroup math_blk - */ + static rpcserver_booter_base* get(); -class GR_CORE_API gr_multiply_conjugate_cc : public gr_sync_block -{ - private: - friend GR_CORE_API gr_multiply_conjugate_cc_sptr - gr_make_multiply_conjugate_cc (size_t vlen); - gr_multiply_conjugate_cc (size_t vlen); + static void register_booter(rpcserver_booter_base* booter); - size_t d_vlen; + template<typename T> class rpcserver_booter_register_helper + { + public: + rpcserver_booter_register_helper() { + rpcmanager::register_booter(new T()); + } + + //TODO: unregister + }; - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + private: + static bool make_aggregator, booter_registered, aggregator_registered; + static void rpcserver_booter_base_sptr_dest( rpcserver_booter_base* b) {;} + static rpcserver_booter_base* boot; + static std::auto_ptr<rpcserver_booter_aggregator> aggregator; }; - -#endif /* INCLUDED_GR_MULTIPLY_CONJUGATE_CC_H */ +#endif /* RPCMANAGER_H */ diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.i b/gnuradio-core/src/lib/runtime/rpcmanager_base.h index f280c0248a..60425c4a15 100644 --- a/gnuradio-core/src/lib/general/gr_keep_m_in_n.i +++ b/gnuradio-core/src/lib/runtime/rpcmanager_base.h @@ -1,35 +1,46 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2012 Free Software Foundation, Inc. - * + * * This file is part of GNU Radio * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. - * + * * GNU Radio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with GNU Radio; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,keep_m_in_n) +#ifndef RPCMANAGER_BASE_H +#define RPCMANAGER_BASE_H + +#include <boost/shared_ptr.hpp> -gr_keep_m_in_n_sptr -gr_make_keep_m_in_n (size_t itemsize, int m, int n, int offset); +class rpcserver_booter_base; +//class rpcserver_booter_aggregator; -class gr_keep_m_in_n : public gr_sync_block +class rpcmanager_base { - protected: - gr_keep_m_in_n (size_t itemsize, int m, int n, int offset); public: - void set_offset(int offset); + typedef boost::shared_ptr<rpcserver_booter_base> rpcserver_booter_base_sptr; + rpcmanager_base() {;} + ~rpcmanager_base() {;} + + //static rpcserver_booter_base* get(); + + //static void register_booter(rpcserver_booter_base_sptr booter); + +private: }; + +#endif /* RPCMANAGER_BASE_H */ diff --git a/gnuradio-core/src/lib/runtime/rpcpmtconverters_ice.cc b/gnuradio-core/src/lib/runtime/rpcpmtconverters_ice.cc new file mode 100644 index 0000000000..5aa7bc7cbd --- /dev/null +++ b/gnuradio-core/src/lib/runtime/rpcpmtconverters_ice.cc @@ -0,0 +1,128 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <rpcpmtconverters_ice.h> +#include <Ice/Ice.h> +#include <gnuradio.h> + +GNURadio::KnobPtr +rpcpmtconverter::from_pmt(const pmt::pmt_t& knob, const Ice::Current& c) +{ + if(pmt::is_real(knob)) { + return new GNURadio::KnobD(Ice::Double(pmt::to_double(knob))); + } + else if(pmt::is_symbol(knob)) { + std::string stuff = pmt::symbol_to_string(knob); + if(stuff.length() != 1) { + return new GNURadio::KnobS(stuff); + } + else { + return new GNURadio::KnobC(stuff[0]); + } + + //TODO: FLOAT!!! + } + else if(pmt::is_integer(knob)) { + return new GNURadio::KnobI(pmt::to_long(knob)); + } + else if(pmt::is_bool(knob)) { + return new GNURadio::KnobB(pmt::to_bool(knob)); + } + else if(pmt::is_uint64(knob)) { + return new GNURadio::KnobL(pmt::to_uint64(knob)); + //const std::complex<float> *c32vector_elements(pmt_t v, size_t &len); //< len is in elements + } + else if(pmt::is_c32vector(knob)) { // c32 sent as interleaved floats + size_t size(pmt::length(knob)); + const float* start((const float*) pmt::c32vector_elements(knob,size)); + return new GNURadio::KnobVecF(std::vector<float>(start,start+size*2)); + } + else if (pmt::is_s32vector(knob)) { + size_t size(pmt::length(knob)); + const int* start((const int*) pmt::s32vector_elements(knob,size)); + return new GNURadio::KnobVecI(std::vector<int>(start,start+size)); + } + else if(pmt::is_f32vector(knob)) { + size_t size(pmt::length(knob)); + const float* start((const float*) pmt::f32vector_elements(knob,size)); + return new GNURadio::KnobVecF(std::vector<float>(start,start+size)); + } + else if (pmt::is_u8vector(knob)) { + size_t size(pmt::length(knob)); + const uint8_t* start((const uint8_t*) pmt::u8vector_elements(knob,size)); + return new GNURadio::KnobVecC(std::vector<Ice::Byte>(start,start+size)); + } + else { + std::cerr << "Error: Don't know how to handle Knob Type (from): " << std::endl; assert(0);} + //TODO: VECTORS!!! + return new GNURadio::Knob(); +} + +pmt::pmt_t +rpcpmtconverter::to_pmt(const GNURadio::KnobPtr& knob, const Ice::Current& c) +{ + std::string id(knob->ice_id(c).substr(12)); + if(id == "KnobD") { + GNURadio::KnobDPtr k(GNURadio::KnobDPtr::dynamicCast(knob)); + return pmt::mp(k->value); + } + else if(id == "KnobF") { + GNURadio::KnobFPtr k(GNURadio::KnobFPtr::dynamicCast(knob)); + return pmt::mp(k->value); + } + else if(id == "KnobI") { + GNURadio::KnobIPtr k(GNURadio::KnobIPtr::dynamicCast(knob)); + return pmt::mp(k->value); + } + else if(id == "KnobS") { + GNURadio::KnobSPtr k(GNURadio::KnobSPtr::dynamicCast(knob)); + return pmt::string_to_symbol(k->value); + } + else if(id == "KnobB") { + GNURadio::KnobBPtr k(GNURadio::KnobBPtr::dynamicCast(knob)); + return pmt::mp(k->value); + } + else if(id == "KnobC") { + GNURadio::KnobCPtr k(GNURadio::KnobCPtr::dynamicCast(knob)); + return pmt::mp(k->value); + } + else if(id == "KnobL") { + GNURadio::KnobLPtr k(GNURadio::KnobLPtr::dynamicCast(knob)); + return pmt::mp((long)k->value); + } else if(id == "KnobVecC") { + GNURadio::KnobVecCPtr k(GNURadio::KnobVecCPtr::dynamicCast(knob)); + return pmt::init_u8vector(k->value.size(), &k->value[0]); + } else if(id == "KnobVecI") { + GNURadio::KnobVecIPtr k(GNURadio::KnobVecIPtr::dynamicCast(knob)); + return pmt::init_s32vector(k->value.size(), &k->value[0]); + } + //else if(id == "KnobVecF") { + // GNURadio::KnobVecFPtr k(GNURadio::KnobVecFPtr::dynamicCast(knob)); + // return pmt::mp(k->value); + //TODO: FLOAT!!! + //TODO: VECTORS!!! + else { + std::cerr << "Error: Don't know how to handle Knob Type: " << id << std::endl; assert(0); + } + + return pmt::pmt_t(); +} diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i b/gnuradio-core/src/lib/runtime/rpcpmtconverters_ice.h index e7979dbcdf..4403b96a2a 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i +++ b/gnuradio-core/src/lib/runtime/rpcpmtconverters_ice.h @@ -1,9 +1,9 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio - * + * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) @@ -20,13 +20,16 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,multiply_conjugate_cc) +#ifndef RPCPMTCONVERTERS_ICE_H +#define RPCPMTCONVERTERS_ICE_H -gr_multiply_conjugate_cc_sptr -gr_make_multiply_conjugate_cc (size_t vlen=1); +#include <gruel/pmt.h> +#include <gnuradio.h> -class gr_multiply_conjugate_cc : public gr_sync_block +namespace rpcpmtconverter { -public: + pmt::pmt_t to_pmt(const GNURadio::KnobPtr& knob, const Ice::Current& c); + GNURadio::KnobPtr from_pmt(const pmt::pmt_t& knob, const Ice::Current& c); +} -}; +#endif /* RPCPMTCONVERTERS_ICE_H */ diff --git a/gnuradio-core/src/lib/runtime/rpcregisterhelpers.h b/gnuradio-core/src/lib/runtime/rpcregisterhelpers.h new file mode 100644 index 0000000000..1be3769ac8 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/rpcregisterhelpers.h @@ -0,0 +1,659 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef RPCREGISTERHELPERS_H +#define RPCREGISTERHELPERS_H + +#include <stdio.h> +#include <sstream> +#include <iostream> +#include <rpcserver_booter_base.h> +#include <rpcmanager.h> +#include <rpcserver_selector.h> +#include <rpcserver_base.h> +#include <gr_block_registry.h> + +// Base classes +template<typename T, typename Tto> class rpcextractor_base + : public virtual gruel::msg_accepter +{ +public: + rpcextractor_base(T* source, void (T::*func)(Tto)) : + _source(source), _func(func) {;} + ~rpcextractor_base() {;} + + void post(pmt::pmt_t which_port, pmt::pmt_t msg) { + throw std::runtime_error("rpcextractor_base: no post defined for this data type.\n"); + } + +protected: + T* _source; + void (T::*_func)(Tto); +}; + +template<typename T, typename Tto> +class rpcbasic_extractor : public virtual rpcextractor_base<T,Tto> +{ +public: + rpcbasic_extractor(T* source, void (T::*func)(Tto)) : + rpcextractor_base<T,Tto>(source, func) + {;} +}; + +template<typename T, typename Tfrom> +class rpcinserter_base : public virtual gruel::msg_producer +{ +public: + rpcinserter_base(T* source, Tfrom (T::*func)()) : _source(source), _func(func) {;} + rpcinserter_base() {;} + + pmt::pmt_t retrieve() { assert(0); return pmt::pmt_t(); } + +protected: + T* _source; + Tfrom (T::*_func)(); +}; + +template<typename T, typename Tfrom> +class rpcbasic_inserter : + public virtual rpcinserter_base<T,Tfrom> +{ +public: + rpcbasic_inserter(T* source, Tfrom (T::*func)()const) + : rpcinserter_base<T,Tfrom>(source, func) + {;} + + rpcbasic_inserter(T* source, Tfrom (T::*func)()) + : rpcinserter_base<T,Tfrom>(source, func) + {;} + + pmt::pmt_t retrieve() + { + return pmt::mp((rpcinserter_base<T,Tfrom>:: + _source->*rpcinserter_base<T,Tfrom>::_func)()); + } +}; + +// Specialized Extractor Templates +template<typename T> +class rpcbasic_extractor<T,double> : public virtual rpcextractor_base<T,double> +{ +public: + rpcbasic_extractor(T* source, void (T::*func)(double)) + : rpcextractor_base<T,double>(source, func) + {;} + + void post(pmt::pmt_t which_port, pmt::pmt_t msg) + { + (rpcextractor_base<T,double>::_source->*rpcextractor_base<T,double>::_func) + (pmt::to_double(msg)); + } +}; + +template<typename T> +class rpcbasic_extractor<T,float> : public virtual rpcextractor_base<T,float> +{ +public: + rpcbasic_extractor(T* source, void (T::*func)(float)) + : rpcextractor_base<T,float>(source, func) + {;} + + void post(pmt::pmt_t which_port, pmt::pmt_t msg) + { + (rpcextractor_base<T,float>::_source->*rpcextractor_base<T,float>::_func) + (pmt::to_double(msg)); + } +}; + +template<typename T> +class rpcbasic_extractor<T,long> : public virtual rpcextractor_base<T,long> +{ +public: + rpcbasic_extractor(T* source, void (T::*func)(long)) + : rpcextractor_base<T,long>(source, func) + {;} + + void post(pmt::pmt_t which_port, pmt::pmt_t msg) + { + (rpcextractor_base<T,long>::_source->*rpcextractor_base<T,long>::_func) + (pmt::to_long(msg)); + } +}; + +template<typename T> +class rpcbasic_extractor<T,int> : public virtual rpcextractor_base<T,int> +{ +public: + rpcbasic_extractor(T* source, void (T::*func)(int)) + : rpcextractor_base<T,int>(source, func) + {;} + + void post(pmt::pmt_t which_port, pmt::pmt_t msg) + { + (rpcextractor_base<T,int>::_source->*rpcextractor_base<T,int>::_func) + (pmt::to_long(msg)); + } +}; + +template<typename T> +class rpcbasic_extractor<T,bool> : public virtual rpcextractor_base<T,bool> +{ +public: + rpcbasic_extractor(T* source, void (T::*func)(bool)) + : rpcextractor_base<T,bool>(source, func) + {;} + + void post(pmt::pmt_t which_port, pmt::pmt_t msg) + { + (rpcextractor_base<T,bool>::_source->*rpcextractor_base<T,bool>::_func) + (pmt::to_bool(msg)); + } +}; + +template<typename T> +class rpcbasic_extractor<T,std::complex<double> > + : public virtual rpcextractor_base<T,std::complex<double> > +{ +public: + rpcbasic_extractor(T* source, void (T::*func)(std::complex<double>)) + : rpcextractor_base<T,std::complex<double> >(source, func) + {;} + + void post(pmt::pmt_t which_port, pmt::pmt_t msg) + { + (rpcextractor_base<T,std::complex<double> >:: + _source->*rpcextractor_base<T,std::complex<double> >::_func)(pmt::to_complex(msg)); + } +}; + +template<typename T> +class rpcbasic_extractor<T,std::string> + : public virtual rpcextractor_base<T,std::string> +{ +public: + rpcbasic_extractor(T* source, void (T::*func)(std::string)) + : rpcextractor_base<T,std::string>(source, func) + {;} + + void post(pmt::pmt_t which_port, pmt::pmt_t msg) + { + (rpcextractor_base<T,std::string>:: + _source->*rpcextractor_base<T,std::string>::_func)(pmt::symbol_to_string(msg)); + } +}; + +template<typename T> +class rpcbasic_inserter<T,uint64_t> : public virtual rpcinserter_base<T,uint64_t> +{ +public: + rpcbasic_inserter(T* source, uint64_t (T::*func)() const) + : rpcinserter_base<T,uint64_t>(source, func) + {;} + + rpcbasic_inserter(T* source, uint64_t (T::*func)()) + : rpcinserter_base<T,uint64_t>(source, func) + {;} + + pmt::pmt_t retrieve() + { + return pmt::from_uint64((rpcinserter_base<T,uint64_t>:: + _source->*rpcinserter_base<T,uint64_t>::_func)()); + } +}; + +template<typename T> +class rpcbasic_inserter<T,std::vector< int > > + : public virtual rpcinserter_base<T,std::vector< int > > +{ +public: + rpcbasic_inserter(T* source, std::vector<int > (T::*func)() const) + : rpcinserter_base<T,std::vector<int > >(source, func) + {;} + + rpcbasic_inserter(T* source, std::vector<int > (T::*func)()) + : rpcinserter_base<T,std::vector<int > >(source, func) + {;} + + pmt::pmt_t retrieve() + { + std::vector< int > + vec((rpcinserter_base<T,std::vector<int > >:: + _source->*rpcinserter_base<T,std::vector< int > >::_func)()); + return pmt::init_s32vector(vec.size(), &vec[0]); + } +}; + +template<typename T> +class rpcbasic_inserter<T,std::vector< std::complex<float> > > + : public virtual rpcinserter_base<T,std::vector< std::complex<float> > > +{ +public: + rpcbasic_inserter(T* source, std::vector<std::complex<float> > (T::*func)() const) + : rpcinserter_base<T,std::vector<std::complex<float> > >(source, func) + {;} + + rpcbasic_inserter(T* source, std::vector<std::complex<float> > (T::*func)()) + : rpcinserter_base<T,std::vector<std::complex<float> > >(source, func) + {;} + + pmt::pmt_t retrieve() + { + std::vector< std::complex<float> > + vec((rpcinserter_base<T,std::vector<std::complex<float> > >:: + _source->*rpcinserter_base<T,std::vector< std::complex<float> > >::_func)()); + return pmt::init_c32vector(vec.size(), &vec[0]); + } +}; + +template<typename T> +class rpcbasic_inserter<T,std::vector< float> > + : public virtual rpcinserter_base<T,std::vector< float > > +{ +public: + rpcbasic_inserter(T* source, std::vector<float> (T::*func)() const) + : rpcinserter_base<T,std::vector<float > >(source, func) + {;} + + rpcbasic_inserter(T* source, std::vector<float> (T::*func)()) + : rpcinserter_base<T,std::vector<float> >(source, func) + {;} + + pmt::pmt_t retrieve() + { + std::vector< float > vec((rpcinserter_base<T,std::vector<float> >:: + _source->*rpcinserter_base<T,std::vector< float> >::_func)()); + return pmt::init_f32vector(vec.size(), &vec[0]); + } +}; + +template<typename T> +class rpcbasic_inserter<T,std::vector< uint8_t> > + : public virtual rpcinserter_base<T,std::vector< uint8_t > > { +public: + rpcbasic_inserter(T* source, std::vector<uint8_t> (T::*func)() const) + : rpcinserter_base<T,std::vector<uint8_t > >(source, func) + {;} + + rpcbasic_inserter(T* source, std::vector<uint8_t> (T::*func)()) + : rpcinserter_base<T,std::vector<uint8_t> >(source, func) + {;} + + pmt::pmt_t retrieve() + { + std::vector< uint8_t > vec((rpcinserter_base<T,std::vector<uint8_t> >:: + _source->*rpcinserter_base<T,std::vector< uint8_t> >::_func)()); + return pmt::init_u8vector(vec.size(), &vec[0]); + } +}; + +template <typename T> +struct rpc_register_base +{ + rpc_register_base() {count++;} +protected: static int count; +}; + +// Base class to inherit from and create universal shared pointers. +class rpcbasic_base +{ +public: + rpcbasic_base() {} + virtual ~rpcbasic_base() {}; +}; + +typedef boost::shared_ptr<rpcbasic_base> rpcbasic_sptr; + +template<typename T, typename Tto> +struct rpcbasic_register_set : public rpcbasic_base +{ + // Function used to add a 'set' RPC call using a gr_basic_block's alias. + rpcbasic_register_set(const std::string& block_alias, + const char* functionbase, + void (T::*function)(Tto), + const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, + const char* units_ = "", + const char* desc_ = "", + priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN, + DisplayType display_ = DISPNULL) + { + d_min = min; + d_max = max; + d_def = def; + d_units = units_; + d_desc = desc_; + d_minpriv = minpriv_; + d_display = display_; + d_object = dynamic_cast<T*>(global_block_registry.block_lookup(pmt::intern(block_alias)).get()); +#ifdef RPCSERVER_ENABLED + callbackregister_base::configureCallback_t + extractor(new rpcbasic_extractor<T,Tto>(d_object, function), + minpriv_, std::string(units_), + display_, std::string(desc_), min, max, def); + std::ostringstream oss(std::ostringstream::out); + oss << block_alias << "::" << functionbase; + d_id = oss.str(); + //std::cerr << "REGISTERING SET: " << d_id << " " << desc_ << std::endl; + rpcmanager::get()->i()->registerConfigureCallback(d_id, extractor); +#endif + } + + // Function used to add a 'set' RPC call using a name and the object + rpcbasic_register_set(const std::string& name, + const char* functionbase, + T* obj, + void (T::*function)(Tto), + const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, + const char* units_ = "", + const char* desc_ = "", + priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN, + DisplayType display_ = DISPNULL) + { + d_min = min; + d_max = max; + d_def = def; + d_units = units_; + d_desc = desc_; + d_minpriv = minpriv_; + d_display = display_; + d_object = obj; +#ifdef RPCSERVER_ENABLED + callbackregister_base::configureCallback_t + extractor(new rpcbasic_extractor<T,Tto>(d_object, function), + minpriv_, std::string(units_), + display_, std::string(desc_), min, max, def); + std::ostringstream oss(std::ostringstream::out); + oss << name << "::" << functionbase; + d_id = oss.str(); + //std::cerr << "REGISTERING SET: " << d_id << " " << desc_ << std::endl; + rpcmanager::get()->i()->registerConfigureCallback(d_id, extractor); +#endif + } + + ~rpcbasic_register_set() + { +#ifdef RPCSERVER_ENABLED + rpcmanager::get()->i()->unregisterConfigureCallback(d_id); +#endif + } + + + pmt::pmt_t min() const { return d_min; } + pmt::pmt_t max() const { return d_max; } + pmt::pmt_t def() const { return d_def; } + std::string units() const { return d_units; } + std::string description() const { return d_desc; } + priv_lvl_t privilege_level() const { return d_minpriv; } + DisplayType default_display() const { return d_display; } + + void set_min(pmt::pmt_t p) { d_min = p; } + void set_max(pmt::pmt_t p) { d_max = p; } + void set_def(pmt::pmt_t p) { d_def = p; } + void units(std::string u) { d_units = u; } + void description(std::string d) { d_desc = d; } + void privilege_level(priv_lvl_t p) { d_minpriv = p; } + void default_display(DisplayType d) { d_display = d; } + +private: + std::string d_id; + pmt::pmt_t d_min, d_max, d_def; + std::string d_units, d_desc; + priv_lvl_t d_minpriv; + DisplayType d_display; + T *d_object; +}; + + +template<typename T, typename Tfrom> +class rpcbasic_register_get : public rpcbasic_base +{ +public: + // Function used to add a 'set' RPC call using a gr_basic_block's alias. + // primary constructor to allow for T get() functions + rpcbasic_register_get(const std::string& block_alias, + const char* functionbase, + Tfrom (T::*function)(), + const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, + const char* units_ = "", + const char* desc_ = "", + priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN, + DisplayType display_ = DISPNULL) + { + d_min = min; + d_max = max; + d_def = def; + d_units = units_; + d_desc = desc_; + d_minpriv = minpriv_; + d_display = display_; + d_object = dynamic_cast<T*>(global_block_registry.block_lookup(pmt::intern(block_alias)).get()); +#ifdef RPCSERVER_ENABLED + callbackregister_base::queryCallback_t + inserter(new rpcbasic_inserter<T,Tfrom>(d_object, function), + minpriv_, std::string(units_), display_, std::string(desc_), min, max, def); + std::ostringstream oss(std::ostringstream::out); + oss << block_alias << "::" << functionbase; + d_id = oss.str(); + //std::cerr << "REGISTERING GET: " << d_id << " " << desc_ << std::endl; + rpcmanager::get()->i()->registerQueryCallback(d_id, inserter); +#endif + } + + + // alternate constructor to allow for T get() const functions + rpcbasic_register_get(const std::string& block_alias, + const char* functionbase, + Tfrom (T::*function)() const, + const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, + const char* units_ = "", + const char* desc_ = "", + priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN, + DisplayType display_ = DISPNULL) + { + d_min = min; + d_max = max; + d_def = def; + d_units = units_; + d_desc = desc_; + d_minpriv = minpriv_; + d_display = display_; + d_object = dynamic_cast<T*>(global_block_registry.block_lookup(pmt::intern(block_alias)).get()); +#ifdef RPCSERVER_ENABLED + callbackregister_base::queryCallback_t + inserter(new rpcbasic_inserter<T,Tfrom>(d_object, (Tfrom (T::*)())function), + minpriv_, std::string(units_), display_, std::string(desc_), min, max, def); + std::ostringstream oss(std::ostringstream::out); + oss << block_alias << "::" << functionbase; + d_id = oss.str(); + //std::cerr << "REGISTERING GET CONST: " << d_id << " " << desc_ << " " << display_ << std::endl; + rpcmanager::get()->i()->registerQueryCallback(d_id, inserter); +#endif + } + + // Function used to add a 'set' RPC call using a name and the object + // primary constructor to allow for T get() functions + rpcbasic_register_get(const std::string& name, + const char* functionbase, + T* obj, + Tfrom (T::*function)(), + const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, + const char* units_ = "", + const char* desc_ = "", + priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN, + DisplayType display_ = DISPNULL) + { + d_min = min; + d_max = max; + d_def = def; + d_units = units_; + d_desc = desc_; + d_minpriv = minpriv_; + d_display = display_; + d_object = obj; +#ifdef RPCSERVER_ENABLED + callbackregister_base::queryCallback_t + inserter(new rpcbasic_inserter<T,Tfrom>(d_object, function), + minpriv_, std::string(units_), display_, std::string(desc_), min, max, def); + std::ostringstream oss(std::ostringstream::out); + oss << name << "::" << functionbase; + d_id = oss.str(); + //std::cerr << "REGISTERING GET: " << d_id << " " << desc_ << std::endl; + rpcmanager::get()->i()->registerQueryCallback(d_id, inserter); +#endif + } + + + // alternate constructor to allow for T get() const functions + rpcbasic_register_get(const std::string& name, + const char* functionbase, + T* obj, + Tfrom (T::*function)() const, + const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, + const char* units_ = "", + const char* desc_ = "", + priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN, + DisplayType display_ = DISPNULL) + { + d_min = min; + d_max = max; + d_def = def; + d_units = units_; + d_desc = desc_; + d_minpriv = minpriv_; + d_display = display_; + d_object = obj; +#ifdef RPCSERVER_ENABLED + callbackregister_base::queryCallback_t + inserter(new rpcbasic_inserter<T,Tfrom>(d_object, (Tfrom (T::*)())function), + minpriv_, std::string(units_), display_, std::string(desc_), min, max, def); + std::ostringstream oss(std::ostringstream::out); + oss << name << "::" << functionbase; + d_id = oss.str(); + //std::cerr << "REGISTERING GET CONST: " << d_id << " " << desc_ << " " << display_ << std::endl; + rpcmanager::get()->i()->registerQueryCallback(d_id, inserter); +#endif + } + + ~rpcbasic_register_get() + { +#ifdef RPCSERVER_ENABLED + rpcmanager::get()->i()->unregisterQueryCallback(d_id); +#endif + } + + pmt::pmt_t min() const { return d_min; } + pmt::pmt_t max() const { return d_max; } + pmt::pmt_t def() const { return d_def; } + std::string units() const { return d_units; } + std::string description() const { return d_desc; } + priv_lvl_t privilege_level() const { return d_minpriv; } + DisplayType default_display() const { return d_display; } + + void set_min(pmt::pmt_t p) { d_min = p; } + void set_max(pmt::pmt_t p) { d_max = p; } + void set_def(pmt::pmt_t p) { d_def = p; } + void units(std::string u) { d_units = u; } + void description(std::string d) { d_desc = d; } + void privilege_level(priv_lvl_t p) { d_minpriv = p; } + void default_display(DisplayType d) { d_display = d; } + +private: + std::string d_id; + pmt::pmt_t d_min, d_max, d_def; + std::string d_units, d_desc; + priv_lvl_t d_minpriv; + DisplayType d_display; + T *d_object; +}; + +/* + * This class can wrap a pre-existing variable type for you + * it will define the getter and rpcregister call for you. + * + * It should be used for read-only getters. + * + */ +template<typename Tfrom> +class rpcbasic_register_variable : public rpcbasic_base +{ +protected: + rpcbasic_register_get< rpcbasic_register_variable<Tfrom>, Tfrom > d_rpc_reg; + Tfrom *d_variable; + Tfrom get() { return *d_variable; } +public: + // empty constructor which should never be called but needs to exist for ues in varous STL data structures + void setptr(Tfrom* _variable){ rpcbasic_register_variable<Tfrom>::d_variable = _variable; } + rpcbasic_register_variable() : + d_rpc_reg("FAIL", "FAIL", this, &rpcbasic_register_variable::get, + pmt::PMT_NIL, pmt::PMT_NIL, pmt::PMT_NIL, DISPNULL, + "FAIL", "FAIL", RPC_PRIVLVL_MIN), + d_variable(NULL) + { + throw std::runtime_error("ERROR: rpcbasic_register_variable called with no args. If this happens, someone has tried to use rpcbasic_register_variable incorrectly."); + }; + + rpcbasic_register_variable(const std::string& namebase, + const char* functionbase, + Tfrom *variable, + const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, + const char* units_ = "", + const char* desc_ = "", + priv_lvl_t minpriv_ = RPC_PRIVLVL_MIN, + DisplayType display_=DISPNULL) : + d_rpc_reg(namebase, functionbase, this, &rpcbasic_register_variable::get, + min, max, def, units_, desc_, minpriv_, display_), + d_variable(variable) + { + //std::cerr << "REGISTERING VAR: " << " " << desc_ << std::endl; + } +}; + +template<typename Tfrom> class rpcbasic_register_variable_rw : public rpcbasic_register_variable<Tfrom> { + private: + rpcbasic_register_set< rpcbasic_register_variable_rw<Tfrom>, Tfrom > d_rpc_regset; + public: + // empty constructor which should never be called but needs to exist for ues in varous STL data structures + rpcbasic_register_variable_rw() : + d_rpc_regset("FAIL","FAIL",this,&rpcbasic_register_variable<Tfrom>::get,pmt::PMT_NIL,pmt::PMT_NIL,pmt::PMT_NIL,DISPNULL,"FAIL","FAIL",RPC_PRIVLVL_MIN) + { + throw std::runtime_error("ERROR: rpcbasic_register_variable_rw called with no args. if this happens someone used rpcbasic_register_variable_rw incorrectly.\n"); + }; + void set(Tfrom _variable){ *(rpcbasic_register_variable<Tfrom>::d_variable) = _variable; } + rpcbasic_register_variable_rw( + const std::string& namebase, + const char* functionbase, + Tfrom *variable, + const pmt::pmt_t &min, const pmt::pmt_t &max, const pmt::pmt_t &def, + const char* units_ = "", + const char* desc_ = "", + priv_lvl_t minpriv = RPC_PRIVLVL_MIN, + DisplayType display_=DISPNULL) : + rpcbasic_register_variable<Tfrom>(namebase,functionbase,variable,min,max,def,units_,desc_), + d_rpc_regset(namebase,functionbase,this,&rpcbasic_register_variable_rw::set,min,max,def,units_,desc_,minpriv,display_) + { + // no action + } +}; + + + + +#endif diff --git a/gnuradio-core/src/lib/runtime/rpcserver_aggregator.cc b/gnuradio-core/src/lib/runtime/rpcserver_aggregator.cc new file mode 100644 index 0000000000..d750d64905 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/rpcserver_aggregator.cc @@ -0,0 +1,93 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <rpcserver_aggregator.h> +#include <rpcserver_booter_base.h> +#include <iostream> +#include <sstream> +#include <stdexcept> + +rpcserver_aggregator::rpcserver_aggregator() + : d_type(std::string("aggregator")) +{;} + +rpcserver_aggregator::~rpcserver_aggregator() +{;} + +const std::string& +rpcserver_aggregator::type() +{ + return d_type; +} + +const std::vector<std::string>& +rpcserver_aggregator::registeredServers() +{ + return d_registeredServers; +} + +void +rpcserver_aggregator::registerConfigureCallback(const std::string &id, + const configureCallback_t callback) +{ + std::for_each(d_serverlist.begin(), d_serverlist.end(), + registerConfigureCallback_f<rpcmanager_base::rpcserver_booter_base_sptr, configureCallback_t>(id, callback)); +} + +void +rpcserver_aggregator::unregisterConfigureCallback(const std::string &id) +{ + std::for_each(d_serverlist.begin(), d_serverlist.end(), + unregisterConfigureCallback_f<rpcmanager_base::rpcserver_booter_base_sptr, configureCallback_t>(id)); +} + +void +rpcserver_aggregator::registerQueryCallback(const std::string &id, const queryCallback_t callback) +{ + std::for_each(d_serverlist.begin(), d_serverlist.end(), + registerQueryCallback_f<rpcmanager_base::rpcserver_booter_base_sptr, queryCallback_t>(id, callback)); +} + +void +rpcserver_aggregator::unregisterQueryCallback(const std::string &id) +{ + std::for_each(d_serverlist.begin(), d_serverlist.end(), + unregisterQueryCallback_f<rpcmanager_base::rpcserver_booter_base_sptr, queryCallback_t>(id)); +} + +void +rpcserver_aggregator::registerServer(rpcmanager_base::rpcserver_booter_base_sptr server) +{ + std::vector<std::string>::iterator it(std::find(d_registeredServers.begin(), + d_registeredServers.end(), + server->type())); + if(it != d_registeredServers.end()) { + d_serverlist.push_back(server); + d_registeredServers.push_back(server->type()); + } + else { + std::stringstream s; + s << "rpcserver_aggregator::registerServer: server of type " + << server->type() << " already registered" << std::endl; + throw std::runtime_error(s.str().c_str()); + } +} diff --git a/gnuradio-core/src/lib/runtime/rpcserver_aggregator.h b/gnuradio-core/src/lib/runtime/rpcserver_aggregator.h new file mode 100644 index 0000000000..050d9bb1e5 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/rpcserver_aggregator.h @@ -0,0 +1,100 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef RPCSERVER_AGGREGATOR_H +#define RPCSERVER_AGGREGATOR_H + +#include <vector> +#include <string> +#include <rpcserver_base.h> +#include <rpcmanager_base.h> + +class rpcserver_aggregator : public virtual rpcserver_base +{ +public: + rpcserver_aggregator(); + virtual ~rpcserver_aggregator(); + + void registerConfigureCallback(const std::string &id, const configureCallback_t callback); + void unregisterConfigureCallback(const std::string &id); + + void registerQueryCallback(const std::string &id, const queryCallback_t callback); + void unregisterQueryCallback(const std::string &id); + + void registerServer(rpcmanager_base::rpcserver_booter_base_sptr server); + + const std::string& type(); + + const std::vector<std::string>& registeredServers(); + +private: + template<class T, typename Tcallback> + struct registerConfigureCallback_f: public std::unary_function<T,void> + { + registerConfigureCallback_f(const std::string &_id, const Tcallback _callback) + : id(_id), callback(_callback) + {;} + + void operator()(T& x) { x->i()->registerConfigureCallback(id, callback); } + const std::string& id; const Tcallback& callback; + }; + + template<class T, typename Tcallback> + struct unregisterConfigureCallback_f: public std::unary_function<T,void> + { + unregisterConfigureCallback_f(const std::string &_id) + : id(_id) + {;} + + void operator()(T& x) { x->i()->unregisterConfigureCallback(id); } + const std::string& id; + }; + + template<class T, typename Tcallback> + struct registerQueryCallback_f: public std::unary_function<T,void> + { + registerQueryCallback_f(const std::string &_id, const Tcallback _callback) + : id(_id), callback(_callback) + {;} + + void operator()(T& x) { x->i()->registerQueryCallback(id, callback); } + const std::string& id; const Tcallback& callback; + }; + + template<class T, typename Tcallback> + struct unregisterQueryCallback_f: public std::unary_function<T,void> + { + unregisterQueryCallback_f(const std::string &_id) + : id(_id) + {;} + + void operator()(T& x) { x->i()->unregisterQueryCallback(id); } + const std::string& id; + }; + + const std::string d_type; + typedef std::vector<rpcmanager_base::rpcserver_booter_base_sptr> rpcServerMap_t; + std::vector<std::string> d_registeredServers; + rpcServerMap_t d_serverlist; +}; + +#endif /* RPCSERVER_AGGREGATOR_H */ diff --git a/gnuradio-core/src/lib/runtime/rpcserver_base.h b/gnuradio-core/src/lib/runtime/rpcserver_base.h new file mode 100644 index 0000000000..bc985c8d53 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/rpcserver_base.h @@ -0,0 +1,47 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef RPCSERVER_BASE_H +#define RPCSERVER_BASE_H + +#include <rpccallbackregister_base.h> + +class rpcserver_base : public virtual callbackregister_base +{ +public: + rpcserver_base() : cur_priv(RPC_PRIVLVL_ALL) {;} + virtual ~rpcserver_base() {;} + + virtual void registerConfigureCallback(const std::string &id, const configureCallback_t callback) = 0; + virtual void unregisterConfigureCallback(const std::string &id) = 0; + virtual void registerQueryCallback(const std::string &id, const queryCallback_t callback) = 0; + virtual void unregisterQueryCallback(const std::string &id) = 0; + virtual void setCurPrivLevel(const priv_lvl_t priv) { cur_priv = priv; } + + typedef boost::shared_ptr<rpcserver_base> rpcserver_base_sptr; +protected: + priv_lvl_t cur_priv; + +private: +}; + +#endif /* RPCSERVER_BASE_H */ diff --git a/gnuradio-core/src/lib/general/gr_multiply_cc.h b/gnuradio-core/src/lib/runtime/rpcserver_booter_aggregator.cc index d25935b4ca..c4c1b03c15 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_cc.h +++ b/gnuradio-core/src/lib/runtime/rpcserver_booter_aggregator.cc @@ -20,37 +20,43 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_GR_MULTIPLY_CC_H -#define INCLUDED_GR_MULTIPLY_CC_H +#include <rpcserver_booter_aggregator.h> -#include <gr_core_api.h> -#include <gr_sync_block.h> +rpcserver_booter_aggregator::rpcserver_booter_aggregator() : + d_type(std::string("aggregator")), server(new rpcserver_aggregator()) +{;} + +rpcserver_booter_aggregator::~rpcserver_booter_aggregator() +{;} -class gr_multiply_cc; -typedef boost::shared_ptr<gr_multiply_cc> gr_multiply_cc_sptr; - -GR_CORE_API gr_multiply_cc_sptr -gr_make_multiply_cc (size_t vlen=1); - -/*! - * \brief Multiply streams of complex values - * \ingroup math_blk - */ - -class GR_CORE_API gr_multiply_cc : public gr_sync_block +rpcserver_base* +rpcserver_booter_aggregator::i() { - private: - friend GR_CORE_API gr_multiply_cc_sptr - gr_make_multiply_cc (size_t vlen); - gr_multiply_cc (size_t vlen); + return &(*server); +} - size_t d_vlen; +const std::string& +rpcserver_booter_aggregator::type() +{ + return d_type; +} - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; +const std::vector<std::string> +rpcserver_booter_aggregator::endpoints() +{ + std::vector<std::string> ep; + ep.push_back(std::string("TODO")); + return ep; +} +const std::vector<std::string>& +rpcserver_booter_aggregator::registeredServers() +{ + return server->registeredServers(); +} -#endif /* INCLUDED_GR_MULTIPLY_CC_H */ +rpcserver_aggregator* +rpcserver_booter_aggregator::agg() +{ + return &(*server); +} diff --git a/gnuradio-core/src/lib/general/gr_add_ff.h b/gnuradio-core/src/lib/runtime/rpcserver_booter_aggregator.h index ff5604c97d..da190a0be1 100644 --- a/gnuradio-core/src/lib/general/gr_add_ff.h +++ b/gnuradio-core/src/lib/runtime/rpcserver_booter_aggregator.h @@ -1,9 +1,9 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio - * + * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) @@ -20,37 +20,37 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_GR_ADD_FF_H -#define INCLUDED_GR_ADD_FF_H +#ifndef RPCSERVER_BOOTER_AGGREGATOR +#define RPCSERVER_BOOTER_AGGREGATOR #include <gr_core_api.h> -#include <gr_sync_block.h> +#include <rpcserver_booter_base.h> +#include <rpcserver_aggregator.h> +#include <boost/shared_ptr.hpp> +#include <string> -class gr_add_ff; -typedef boost::shared_ptr<gr_add_ff> gr_add_ff_sptr; +class rpcserver_server; -GR_CORE_API gr_add_ff_sptr -gr_make_add_ff (size_t vlen=1); +class GR_CORE_API rpcserver_booter_aggregator : + public virtual rpcserver_booter_base +{ + public: + rpcserver_booter_aggregator(); + ~rpcserver_booter_aggregator(); -/*! - * \brief Add streams of complex values - * \ingroup math_blk - */ + rpcserver_base* i(); + const std::string& type(); + const std::vector<std::string> endpoints(); -class GR_CORE_API gr_add_ff : public gr_sync_block -{ - private: - friend GR_CORE_API gr_add_ff_sptr - gr_make_add_ff (size_t vlen); - gr_add_ff (size_t vlen); + const std::vector<std::string>& registeredServers(); - size_t d_vlen; + protected: + friend class rpcmanager; + rpcserver_aggregator* agg(); - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); +private: + std::string d_type; + boost::shared_ptr<rpcserver_aggregator> server; }; - -#endif /* INCLUDED_GR_ADD_FF_H */ +#endif /* RPCSERVER_BOOTER_AGGREGATOR */ diff --git a/gnuradio-core/src/lib/runtime/rpcserver_booter_base.h b/gnuradio-core/src/lib/runtime/rpcserver_booter_base.h new file mode 100644 index 0000000000..682944dada --- /dev/null +++ b/gnuradio-core/src/lib/runtime/rpcserver_booter_base.h @@ -0,0 +1,44 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef RPCSERVER_BOOTER_BASE +#define RPCSERVER_BOOTER_BASE + +#include <string> +#include <vector> + +class rpcserver_base; + +class rpcserver_booter_base +{ +public: + rpcserver_booter_base() {;} + virtual ~rpcserver_booter_base() {;} + + virtual rpcserver_base* i()=0; + virtual const std::vector<std::string> endpoints()=0; + virtual const std::string& type()=0; + +private: +}; + +#endif /* RPCSERVER_BOOTER_BASE */ diff --git a/gnuradio-core/src/lib/runtime/rpcserver_booter_ice.cc b/gnuradio-core/src/lib/runtime/rpcserver_booter_ice.cc new file mode 100644 index 0000000000..7cc8cc8938 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/rpcserver_booter_ice.cc @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <rpcserver_ice.h> +#include <rpcserver_booter_ice.h> + +namespace { + static const char* const CONTROL_PORT_CLASS("ice"); + static const char* const CONTROL_PORT_NAME("ControlPort"); + static const char* const ENDPOINT_NAME("gnuradio"); +}; + +rpcserver_booter_ice::rpcserver_booter_ice() : + ice_server_template<rpcserver_base, rpcserver_ice, + rpcserver_booter_ice, GNURadio::ControlPortPtr> + (this, std::string(CONTROL_PORT_NAME), std::string(ENDPOINT_NAME)), + d_type(std::string(CONTROL_PORT_CLASS)) +{;} + +rpcserver_booter_ice::~rpcserver_booter_ice() +{;} + +rpcserver_base* +rpcserver_booter_ice::i() +{ + return ice_server_template<rpcserver_base, rpcserver_ice, + rpcserver_booter_ice, GNURadio::ControlPortPtr>::i(); +} + +const std::vector<std::string> +rpcserver_booter_ice::endpoints() +{ + return ice_server_template<rpcserver_base, rpcserver_ice, + rpcserver_booter_ice, GNURadio::ControlPortPtr>::endpoints(); +} diff --git a/gnuradio-core/src/lib/runtime/rpcserver_booter_ice.h b/gnuradio-core/src/lib/runtime/rpcserver_booter_ice.h new file mode 100644 index 0000000000..69dfcc7602 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/rpcserver_booter_ice.h @@ -0,0 +1,49 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef RPCSERVER_BOOTER_ICE_H +#define RPCSERVER_BOOTER_ICE_H + +#include <rpcserver_booter_base.h> +#include <ice_server_template.h> +#include <gnuradio.h> + +class rpcserver_base; +class rpcserver_ice; + +class rpcserver_booter_ice : public virtual rpcserver_booter_base, + public virtual ice_server_template<rpcserver_base, rpcserver_ice, + rpcserver_booter_ice, GNURadio::ControlPortPtr> +{ +public: + rpcserver_booter_ice(); + ~rpcserver_booter_ice(); + + rpcserver_base* i(); + const std::string & type() {return d_type;} + const std::vector<std::string> endpoints(); + +private: + std::string d_type; +}; + +#endif /* RPCSERVER_BOOTER_ICE_H */ diff --git a/gnuradio-core/src/lib/runtime/rpcserver_ice.cc b/gnuradio-core/src/lib/runtime/rpcserver_ice.cc new file mode 100644 index 0000000000..12229a0688 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/rpcserver_ice.cc @@ -0,0 +1,165 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <rpcserver_ice.h> +#include <IceUtil/IceUtil.h> +#include <Ice/Ice.h> +#include <iostream> +#include <sstream> +#include <stdexcept> +#include <gruel/pmt.h> + +#define DEBUG 0 + +using namespace rpcpmtconverter; + +rpcserver_ice::rpcserver_ice() +{} + +rpcserver_ice::~rpcserver_ice() +{} + +void +rpcserver_ice::registerConfigureCallback(const std::string &id, + const configureCallback_t callback) +{ + { + ConfigureCallbackMap_t::const_iterator iter(d_setcallbackmap.find(id)); + if(iter != d_setcallbackmap.end()) { + std::stringstream s; + s << "rpcserver_ice:: rpcserver_ice ERROR registering set, already registered: " + << id << std::endl; + throw std::runtime_error(s.str().c_str()); + } + } + + if(DEBUG) + std::cout << "rpcserver_ice registering set: " << id << std::endl; + + d_setcallbackmap.insert(ConfigureCallbackMap_t::value_type(id, callback)); +} + +void +rpcserver_ice::unregisterConfigureCallback(const std::string &id) +{ + ConfigureCallbackMap_t::iterator iter(d_setcallbackmap.find(id)); + if(iter == d_setcallbackmap.end()) { + std::stringstream s; + s << "rpcserver_ice:: rpcserver_ice ERROR unregistering set, not registered: " + << id << std::endl; + throw std::runtime_error(s.str().c_str()); + } + + if(DEBUG) + std::cout << "rpcserver_ice unregistering set: " << id << std::endl; + + d_setcallbackmap.erase(iter); +} + +void +rpcserver_ice::registerQueryCallback(const std::string &id, + const queryCallback_t callback) +{ + { + QueryCallbackMap_t::const_iterator iter(d_getcallbackmap.find(id)); + if(iter != d_getcallbackmap.end()) { + std::stringstream s; + s << "rpcserver_ice:: rpcserver_ice ERROR registering get, already registered: " + << id << std::endl; + throw std::runtime_error(s.str().c_str()); + } + } + + if(DEBUG) + std::cout << "rpcserver_ice registering get: " << id << std::endl; + + d_getcallbackmap.insert(QueryCallbackMap_t::value_type(id, callback)); +} + +void +rpcserver_ice::unregisterQueryCallback(const std::string &id) +{ + QueryCallbackMap_t::iterator iter(d_getcallbackmap.find(id)); + if(iter == d_getcallbackmap.end()) { + std::stringstream s; + s << "rpcserver_ice:: rpcserver_ice ERROR unregistering get, registered: " + << id << std::endl; + throw std::runtime_error(s.str().c_str()); + } + + if(DEBUG) + std::cout << "rpcserver_ice unregistering get: " << id << std::endl; + + d_getcallbackmap.erase(iter); +} + +void +rpcserver_ice::set(const GNURadio::KnobMap& knobs, const Ice::Current& c) +{ + std::for_each(knobs.begin(), knobs.end(), + set_f<GNURadio::KnobMap::value_type,ConfigureCallbackMap_t> + (c, d_setcallbackmap, cur_priv)); +} + +GNURadio::KnobMap +rpcserver_ice::get(const GNURadio::KnobIDList& knobs, const Ice::Current& c) +{ + GNURadio::KnobMap outknobs; + + if(knobs.size() == 0) { + std::for_each(d_getcallbackmap.begin(), d_getcallbackmap.end(), + get_all_f<QueryCallbackMap_t::value_type, QueryCallbackMap_t, GNURadio::KnobMap> + (c, d_getcallbackmap, cur_priv, outknobs)); + } + else { + std::for_each(knobs.begin(), knobs.end(), + get_f<GNURadio::KnobIDList::value_type, QueryCallbackMap_t> + (c, d_getcallbackmap, cur_priv, outknobs)); + } + return outknobs; +} + +GNURadio::KnobPropMap +rpcserver_ice::properties(const GNURadio::KnobIDList& knobs, const Ice::Current& c) +{ + GNURadio::KnobPropMap outknobs; + + if(knobs.size() == 0) { + std::for_each(d_getcallbackmap.begin(), d_getcallbackmap.end(), + properties_all_f<QueryCallbackMap_t::value_type, + QueryCallbackMap_t,GNURadio::KnobPropMap>(c, d_getcallbackmap, cur_priv, outknobs)); + } + else { + std::for_each(knobs.begin(), knobs.end(), + properties_f<GNURadio::KnobIDList::value_type, + QueryCallbackMap_t, GNURadio::KnobPropMap>(c, d_getcallbackmap, cur_priv, outknobs)); + } + return outknobs; +} + +void +rpcserver_ice::shutdown(const Ice::Current& c) +{ + if(DEBUG) + std::cout << "Shutting down..." << std::endl; + c.adapter->getCommunicator()->shutdown(); +} diff --git a/gnuradio-core/src/lib/runtime/rpcserver_ice.h b/gnuradio-core/src/lib/runtime/rpcserver_ice.h new file mode 100644 index 0000000000..66ed8d5156 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/rpcserver_ice.h @@ -0,0 +1,221 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef RPCSERVER_ICE_H +#define RPCSERVER_ICE_H + +#include <rpcserver_base.h> +#include <rpcpmtconverters_ice.h> +#include <string> +#include <map> +#include <gnuradio.h> +#include <Ice/Exception.h> + +class rpcserver_ice : public virtual rpcserver_base, public GNURadio::ControlPort +{ +public: + rpcserver_ice(); + virtual ~rpcserver_ice(); + + void registerConfigureCallback(const std::string &id, const configureCallback_t callback); + void unregisterConfigureCallback(const std::string &id); + + void registerQueryCallback(const std::string &id, const queryCallback_t callback); + void unregisterQueryCallback(const std::string &id); + + virtual void set(const GNURadio::KnobMap&, const Ice::Current&); + + GNURadio::KnobMap get(const GNURadio::KnobIDList&, const Ice::Current&); + + GNURadio::KnobPropMap properties(const GNURadio::KnobIDList&, const Ice::Current&); + + virtual void shutdown(const Ice::Current&); + +private: + typedef std::map<std::string, configureCallback_t> ConfigureCallbackMap_t; + ConfigureCallbackMap_t d_setcallbackmap; + + typedef std::map<std::string, queryCallback_t> QueryCallbackMap_t; + QueryCallbackMap_t d_getcallbackmap; + + template<typename T, typename TMap> struct set_f + : public std::unary_function<T,void> + { + set_f(const Ice::Current& _c, TMap& _setcallbackmap, const priv_lvl_t& _cur_priv) : + c(_c), d_setcallbackmap(_setcallbackmap), cur_priv(_cur_priv) + {;} + + void operator()(const T& p) + { + ConfigureCallbackMap_t::const_iterator iter(d_setcallbackmap.find(p.first)); + if(iter != d_setcallbackmap.end()) { + if(cur_priv <= iter->second.priv) { + (*iter->second.callback).post(pmt::PMT_NIL, rpcpmtconverter::to_pmt(p.second,c)); + } + else { + std::cout << "Key " << p.first << " requires PRIVLVL <= " + << iter->second.priv << " to set, currently at: " + << cur_priv << std::endl; + } + } + else { + throw IceUtil::NullHandleException(__FILE__, __LINE__); + } + } + + const Ice::Current& c; + TMap& d_setcallbackmap; + const priv_lvl_t& cur_priv; + }; + + template<typename T, typename TMap> + struct get_f : public std::unary_function<T,void> + { + get_f(const Ice::Current& _c, TMap& _getcallbackmap, + const priv_lvl_t& _cur_priv, GNURadio::KnobMap& _outknobs) : + c(_c), d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs) + {} + + void operator()(const T& p) + { + QueryCallbackMap_t::const_iterator iter(d_getcallbackmap.find(p)); + if(iter != d_getcallbackmap.end()) { + if(cur_priv <= iter->second.priv) { + outknobs[p] = rpcpmtconverter::from_pmt((*iter->second.callback).retrieve(), c); + } + else { + std::cout << "Key " << iter->first << " requires PRIVLVL: <= " + << iter->second.priv << " to get, currently at: " + << cur_priv << std::endl; + } + } + else { + throw IceUtil::NullHandleException(__FILE__, __LINE__); + } + } + + const Ice::Current& c; + TMap& d_getcallbackmap; + const priv_lvl_t& cur_priv; + GNURadio::KnobMap& outknobs; + }; + + template<typename T, typename TMap, typename TKnobMap> + struct get_all_f : public std::unary_function<T,void> + { + get_all_f(const Ice::Current& _c, TMap& _getcallbackmap, + const priv_lvl_t& _cur_priv, TKnobMap& _outknobs) : + c(_c), d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs) + {;} + + void operator()(const T& p) + { + if(cur_priv <= p.second.priv) { + outknobs[p.first] = rpcpmtconverter::from_pmt(p.second.callback->retrieve(), c); + } + else { + std::cout << "Key " << p.first << " requires PRIVLVL <= " + << p.second.priv << " to get, currently at: " + << cur_priv << std::endl; + } + } + + const Ice::Current& c; + TMap& d_getcallbackmap; + const priv_lvl_t& cur_priv; + TKnobMap& outknobs; + }; + + template<typename T, typename TMap, typename TKnobMap> + struct properties_all_f : public std::unary_function<T,void> + { + properties_all_f(const Ice::Current& _c, QueryCallbackMap_t& _getcallbackmap, + const priv_lvl_t& _cur_priv, GNURadio::KnobPropMap& _outknobs) : + c(_c), d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs) + {;} + + void operator()(const T& p) + { + if(cur_priv <= p.second.priv) { + GNURadio::KnobProp prop;//(new GNURadio::KnobProp()); + prop.type = GNURadio::KNOBDOUBLE; + prop.units = p.second.units; + prop.description = p.second.description; + prop.min = rpcpmtconverter::from_pmt(p.second.min, c); + prop.max = rpcpmtconverter::from_pmt(p.second.max, c); + prop.display = static_cast<uint32_t>(p.second.display); + outknobs[p.first] = prop; + } + else { + std::cout << "Key " << p.first << " requires PRIVLVL <= " + << p.second.priv << " to get, currently at: " + << cur_priv << std::endl; + } + } + + const Ice::Current& c; + TMap& d_getcallbackmap; + const priv_lvl_t& cur_priv; + TKnobMap& outknobs; + }; + + template<class T, typename TMap, typename TKnobMap> + struct properties_f : public std::unary_function<T,void> + { + properties_f(const Ice::Current& _c, TMap& _getcallbackmap, + const priv_lvl_t& _cur_priv, TKnobMap& _outknobs) : + c(_c), d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs) + {;} + + void operator()(const T& p) + { + typename TMap::const_iterator iter(d_getcallbackmap.find(p)); + if(iter != d_getcallbackmap.end()) { + if(cur_priv <= iter->second.priv) { + GNURadio::KnobProp prop; + prop.type = GNURadio::KNOBDOUBLE; + prop.units = iter->second.units; + prop.description = iter->second.description; + prop.min = rpcpmtconverter::from_pmt(iter->second.min, c); + prop.max = rpcpmtconverter::from_pmt(iter->second.max, c); + prop.display = static_cast<uint32_t>(iter->second.display); + //outknobs[iter->first] = prop; + outknobs[p] = prop; + } + else { + std::cout << "Key " << iter->first << " requires PRIVLVL: <= " << + iter->second.priv << " to get, currently at: " << cur_priv << std::endl; + } + } + else { + throw IceUtil::NullHandleException(__FILE__, __LINE__); + } + } + + const Ice::Current& c; + TMap& d_getcallbackmap; + const priv_lvl_t& cur_priv; + TKnobMap& outknobs; + }; +}; + +#endif /* RPCSERVER_ICE_H */ diff --git a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.i b/gnuradio-core/src/lib/runtime/rpcserver_selector.cc index ec760b309a..362d5f060a 100644 --- a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.i +++ b/gnuradio-core/src/lib/runtime/rpcserver_selector.cc @@ -20,12 +20,21 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,pdu_to_tagged_stream); +#include <rpcserver_booter_aggregator.h> +#include <rpcmanager.h> +#include <rpcserver_selector.h> -%{ -#include <gr_pdu_to_tagged_stream.h> -%} +bool rpcmanager::make_aggregator(false); -%include <gr_pdu_to_tagged_stream.h> +#ifdef RPCSERVER_ICE + #include <rpcserver_booter_ice.h> + rpcmanager::rpcserver_booter_register_helper<rpcserver_booter_ice> boot_ice; +#endif +#ifdef RPCSERVER_ERLANG + #error TODO ERLANG +#endif +#ifdef RPCSERVER_XMLRPC + #error TODO XMLRPC +#endif diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.i b/gnuradio-core/src/lib/runtime/rpcserver_selector.h index e5fdea3488..fa63c9a2dc 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_ff.i +++ b/gnuradio-core/src/lib/runtime/rpcserver_selector.h @@ -1,9 +1,9 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio - * + * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) @@ -20,13 +20,13 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,multiply_ff) +#ifndef RPCSERVER_SELECTOR +#define RPCSERVER_SELECTOR -gr_multiply_ff_sptr -gr_make_multiply_ff (size_t vlen=1); +#define RPCSERVER_ENABLED -class gr_multiply_ff : public gr_sync_block -{ -public: +#define RPCSERVER_ICE +//#define RPCSERVER_ERLANG +//#define RPCSERVER_XMLRPC -}; +#endif diff --git a/gnuradio-core/src/lib/runtime/runtime.i b/gnuradio-core/src/lib/runtime/runtime.i index dd7b095547..ac0092f917 100644 --- a/gnuradio-core/src/lib/runtime/runtime.i +++ b/gnuradio-core/src/lib/runtime/runtime.i @@ -71,3 +71,81 @@ %include <gr_tagged_stream_block.i> %include <gr_top_block.i> %include <gr_logger.i> + +#ifdef GR_CTRLPORT + +typedef uint32_t DisplayType; + +// DisplayType Plotting types +const uint32_t DISPNULL = 0x0000; +const uint32_t DISPTIME = 0x0001; +const uint32_t DISPXY = 0x0002; +const uint32_t DISPPSD = 0x0004; +const uint32_t DISPSPEC = 0x0008; +const uint32_t DISPRAST = 0x0010; + +// DisplayType Options +const uint32_t DISPOPTCPLX = 0x0100; +const uint32_t DISPOPTLOG = 0x0200; +const uint32_t DISPOPTSTEM = 0x0400; +const uint32_t DISPOPTSTRIP = 0x0800; +const uint32_t DISPOPTSCATTER = 0x1000; + +enum priv_lvl_t { + RPC_PRIVLVL_ALL = 0, + RPC_PRIVLVL_MIN = 9, + RPC_PRIVLVL_NONE = 10 +}; + +enum KnobType { + KNOBBOOL, KNOBCHAR, KNOBINT, KNOBFLOAT, + KNOBDOUBLE, KNOBSTRING, KNOBLONG, KNOBVECBOOL, + KNOBVECCHAR, KNOBVECINT, KNOBVECFLOAT, KNOBVECDOUBLE, + KNOBVECSTRING, KNOBVECLONG +}; + +%template(StrVector) std::vector<std::string>; + +%{ +#include <rpcserver_booter_base.h> +#include <rpcserver_booter_aggregator.h> +#include <pycallback_object.h> +%} + +%include <rpcserver_booter_base.h> +%include <rpcserver_booter_aggregator.h> +%include <pycallback_object.h> + +// Declare this class here but without the nested templated class +// inside (replaces include of rpcmanager.h) +class GR_CORE_API rpcmanager : public virtual rpcmanager_base +{ + public: + rpcmanager(); + ~rpcmanager(); + + static rpcserver_booter_base* get(); + + static void register_booter(rpcserver_booter_base* booter); +}; + + +// Attach a new python callback method to Python function +%extend pycallback_object { + // Set a Python function object as a callback function + // Note : PyObject *pyfunc is remapped with a typempap + void activate(PyObject *pyfunc) + { + self->set_callback(pyfunc); + Py_INCREF(pyfunc); + } +} + +%template(RPC_get_string) pycallback_object<std::string>; +%template(RPC_get_int) pycallback_object<int>; +%template(RPC_get_float) pycallback_object<float>; +%template(RPC_get_double) pycallback_object<double>; +%template(RPC_get_vector_float) pycallback_object<std::vector<float> >; +%template(RPC_get_vector_gr_complex) pycallback_object<std::vector<gr_complex> >; + +#endif /* GR_CTRLPORT */ diff --git a/gnuradio-core/src/lib/swig/CMakeLists.txt b/gnuradio-core/src/lib/swig/CMakeLists.txt index 2c89494e78..2132e2ca09 100644 --- a/gnuradio-core/src/lib/swig/CMakeLists.txt +++ b/gnuradio-core/src/lib/swig/CMakeLists.txt @@ -39,6 +39,12 @@ if(ENABLE_GR_LOG) SET(GR_SWIG_FLAGS "-DENABLE_GR_LOG") endif(ENABLE_GR_LOG) +if(ENABLE_GR_CTRLPORT) + list(APPEND GR_SWIG_FLAGS -DGR_CTRLPORT) + list(APPEND GR_SWIG_LIBRARIES ${ICE_LIBRARIES}) + list(APPEND GR_SWIG_INCLUDE_DIRS ${ICE_INCLUDE_DIR}) +endif(ENABLE_GR_CTRLPORT) + link_directories(${Boost_LIBRARY_DIRS}) ######################################################################## @@ -51,9 +57,10 @@ link_directories(${Boost_LIBRARY_DIRS}) # X86_64, g++'s resident set size was 650MB! # ---------------------------------------------------------------- -set(GR_SWIG_TARGET_DEPS general_generated gengen_generated filter_generated pmt_swig) +set(GR_SWIG_TARGET_DEPS gnuradio_core_generated_sources + general_generated gengen_generated filter_generated pmt_swig) -foreach(what runtime general gengen filter io hier) +foreach(what runtime general gengen io) SET(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${what}_swig_doc.i) SET(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../${what} ${CMAKE_CURRENT_BINARY_DIR}/../${what}) GR_SWIG_MAKE(gnuradio_core_${what} gnuradio_core_${what}.i) diff --git a/gnuradio-core/src/lib/swig/gnuradio_core.py b/gnuradio-core/src/lib/swig/gnuradio_core.py index 23de740778..1fd558a11b 100644 --- a/gnuradio-core/src/lib/swig/gnuradio_core.py +++ b/gnuradio-core/src/lib/swig/gnuradio_core.py @@ -23,6 +23,4 @@ from gnuradio_core_runtime import * from gnuradio_core_general import * from gnuradio_core_gengen import * -from gnuradio_core_filter import * from gnuradio_core_io import * -from gnuradio_core_hier import * diff --git a/gnuradio-core/src/lib/swig/gnuradio_core_filter.i b/gnuradio-core/src/lib/swig/gnuradio_core_filter.i deleted file mode 100644 index e9a44e54b9..0000000000 --- a/gnuradio-core/src/lib/swig/gnuradio_core_filter.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -%include "filter_swig_doc.i" - -#ifndef SWIGIMPORTED -%module(directors="1") gnuradio_core_filter -#endif - - //%feature("autodoc", "1"); // generate python docstrings - -%include "gnuradio.i" // the common stuff - -%include "filter.i" diff --git a/gnuradio-core/src/lib/swig/gr_swig_block_magic.i b/gnuradio-core/src/lib/swig/gr_swig_block_magic.i index 4016ae7727..6d1af6136d 100644 --- a/gnuradio-core/src/lib/swig/gr_swig_block_magic.i +++ b/gnuradio-core/src/lib/swig/gr_swig_block_magic.i @@ -48,3 +48,11 @@ BASE_NAME ## _sptr.__repr__ = lambda self: "<gr_block %s (%d)>" % (self.name(), BASE_NAME = BASE_NAME.make; %} %enddef + +%define GR_SWIG_BLOCK_MAGIC_FACTORY(PKG, BASE_NAME, FACTORY) +%template(FACTORY ## _sptr) boost::shared_ptr<gr:: ## PKG ## :: ## BASE_NAME>; +%pythoncode %{ +FACTORY ## _sptr.__repr__ = lambda self: "<gr_block %s (%d)>" % (self.name(), self.unique_id()) +FACTORY = BASE_NAME ## _make_ ## FACTORY; +%} +%enddef diff --git a/gnuradio-core/src/lib/viterbi/CMakeLists.txt b/gnuradio-core/src/lib/viterbi/CMakeLists.txt deleted file mode 100644 index add5c77e80..0000000000 --- a/gnuradio-core/src/lib/viterbi/CMakeLists.txt +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright 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. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## - -set(viterbi_sources - ${CMAKE_CURRENT_SOURCE_DIR}/metrics.c - ${CMAKE_CURRENT_SOURCE_DIR}/tab.c - ${CMAKE_CURRENT_SOURCE_DIR}/viterbi.c -) - -######################################################################## -# define missing erf function with C linkage (hack for metrics.c) -######################################################################## -if(MSVC) -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/boost_math_erf.cc " -#include <boost/math/special_functions/erf.hpp> -extern \"C\" double erf(double x){ - return boost::math::erf(x); -} -") -list(APPEND viterbi_sources ${CMAKE_CURRENT_BINARY_DIR}/boost_math_erf.cc) -endif(MSVC) - -######################################################################## -# Append gnuradio-core library sources -######################################################################## -list(APPEND gnuradio_core_sources ${viterbi_sources}) - -######################################################################## -# Install runtime headers -######################################################################## -install( - FILES ${CMAKE_CURRENT_SOURCE_DIR}/viterbi.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "core_devel" -) - -######################################################################## -# Create some text executables (not registered tests) -# Its not much to build so the sources are just re-listed, -# rather than create a new library just for these two apps. -######################################################################## -#ADD_EXECUTABLE(viterbi_encode ${CMAKE_CURRENT_SOURCE_DIR}/encode.cc ${viterbi_sources}) -#ADD_EXECUTABLE(viterbi_decode ${CMAKE_CURRENT_SOURCE_DIR}/decode.cc ${viterbi_sources}) diff --git a/gnuradio-core/src/lib/viterbi/decode.cc b/gnuradio-core/src/lib/viterbi/decode.cc deleted file mode 100644 index 368e697134..0000000000 --- a/gnuradio-core/src/lib/viterbi/decode.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * This is a minimal example demonstrating how to call the Viterbi decoder - * in continuous streaming mode. It accepts data on stdin and writes to - * stdout. - * - */ - -extern "C" { -#include "viterbi.h" -} - -#include <cstdio> -#include <cmath> - -#define MAXCHUNKSIZE 4096 -#define MAXENCSIZE MAXCHUNKSIZE*16 - -int main() -{ - unsigned char data[MAXCHUNKSIZE]; - signed char syms[MAXENCSIZE]; - int count = 0; - - // Initialize metric table - int mettab[2][256]; - int amp = 100; - float RATE=0.5; - float ebn0 = 12.0; - float esn0 = RATE*pow(10.0, ebn0/10); - gen_met(mettab, amp, esn0, 0.0, 4); - - // Initialize decoder state - struct viterbi_state state0[64]; - struct viterbi_state state1[64]; - unsigned char viterbi_in[16]; - viterbi_chunks_init(state0); - - while (!feof(stdin)) { - unsigned int n = fread(syms, 1, MAXENCSIZE, stdin); - unsigned char *out = data; - - for (unsigned int i = 0; i < n; i++) { - - // FIXME: This implements hard decoding by slicing the input stream - unsigned char sym = syms[i] > 0 ? -amp : amp; - - // Write the symbol to the decoder input - viterbi_in[count % 4] = sym; - - // Every four symbols, perform the butterfly2 operation - if ((count % 4) == 3) { - viterbi_butterfly2(viterbi_in, mettab, state0, state1); - - // Every sixteen symbols, perform the readback operation - if ((count > 64) && (count % 16) == 11) { - viterbi_get_output(state0, out); - fwrite(out++, 1, 1, stdout); - } - } - - count++; - } - } - - return 0; -} diff --git a/gnuradio-core/src/lib/viterbi/encode.cc b/gnuradio-core/src/lib/viterbi/encode.cc deleted file mode 100644 index 83a85fcacb..0000000000 --- a/gnuradio-core/src/lib/viterbi/encode.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * This is a minimal example demonstrating how to call the ECC encoder - * in continuous streaming mode. It accepts data on stdin and writes to - * stdout. - * - * FIXME: This does not flush the final bits out of the encoder. - * - */ - -extern "C" { -#include "viterbi.h" -} - -#include <cstdio> - -#define MAXCHUNKSIZE 4096 -#define MAXENCSIZE MAXCHUNKSIZE*16 - -int main() -{ - unsigned char encoder_state = 0; - unsigned char data[MAXCHUNKSIZE]; - unsigned char syms[MAXENCSIZE]; - - while (!feof(stdin)) { - unsigned int n = fread(data, 1, MAXCHUNKSIZE, stdin); - encoder_state = encode(syms, data, n, encoder_state); - fwrite(syms, 1, n*16, stdout); - } - - return 0; -} diff --git a/gnuradio-core/src/lib/viterbi/metrics.c b/gnuradio-core/src/lib/viterbi/metrics.c deleted file mode 100644 index 0d91c301ff..0000000000 --- a/gnuradio-core/src/lib/viterbi/metrics.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 1995 Phil Karn, KA9Q - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * Generate metric tables for a soft-decision convolutional decoder - * assuming gaussian noise on a PSK channel. - * - * Works from "first principles" by evaluating the normal probability - * function and then computing the log-likelihood function - * for every possible received symbol value - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -/* Symbols are offset-binary, with 128 corresponding to an erased (no - * information) symbol - */ -#define OFFSET 128 - -#include <stdlib.h> -#include <math.h> - -//declare erf in case it was missing in math.h and provided for by the build system -extern double erf(double x); - -/* Normal function integrated from -Inf to x. Range: 0-1 */ -#define normal(x) (0.5 + 0.5*erf((x)/M_SQRT2)) - -/* Logarithm base 2 */ -#define gr_log2(x) (log(x)*M_LOG2E) - -/* Generate log-likelihood metrics for 8-bit soft quantized channel - * assuming AWGN and BPSK - */ -void -gen_met(int mettab[2][256], /* Metric table, [sent sym][rx symbol] */ - int amp, /* Signal amplitude, units */ - double esn0, /* Es/N0 ratio in dB */ - double bias, /* Metric bias; 0 for viterbi, rate for sequential */ - int scale) /* Scale factor */ -{ - double noise; - int s,bit; - double metrics[2][256]; - double p0,p1; - - /* Es/N0 as power ratio */ - esn0 = pow(10.,esn0/10); - - noise = 0.5/esn0; /* only half the noise for BPSK */ - noise = sqrt(noise); /* noise/signal Voltage ratio */ - - /* Zero is a special value, since this sample includes all - * lower samples that were clipped to this value, i.e., it - * takes the whole lower tail of the curve - */ - p1 = normal(((0-OFFSET+0.5)/amp - 1)/noise); /* P(s|1) */ - - /* Prob of this value occurring for a 0-bit */ /* P(s|0) */ - p0 = normal(((0-OFFSET+0.5)/amp + 1)/noise); - metrics[0][0] = gr_log2(2*p0/(p1+p0)) - bias; - metrics[1][0] = gr_log2(2*p1/(p1+p0)) - bias; - - for(s=1;s<255;s++){ - /* P(s|1), prob of receiving s given 1 transmitted */ - p1 = normal(((s-OFFSET+0.5)/amp - 1)/noise) - - normal(((s-OFFSET-0.5)/amp - 1)/noise); - - /* P(s|0), prob of receiving s given 0 transmitted */ - p0 = normal(((s-OFFSET+0.5)/amp + 1)/noise) - - normal(((s-OFFSET-0.5)/amp + 1)/noise); - -#ifdef notdef - printf("P(%d|1) = %lg, P(%d|0) = %lg\n",s,p1,s,p0); -#endif - metrics[0][s] = gr_log2(2*p0/(p1+p0)) - bias; - metrics[1][s] = gr_log2(2*p1/(p1+p0)) - bias; - } - /* 255 is also a special value */ - /* P(s|1) */ - p1 = 1 - normal(((255-OFFSET-0.5)/amp - 1)/noise); - /* P(s|0) */ - p0 = 1 - normal(((255-OFFSET-0.5)/amp + 1)/noise); - - metrics[0][255] = gr_log2(2*p0/(p1+p0)) - bias; - metrics[1][255] = gr_log2(2*p1/(p1+p0)) - bias; -#ifdef notdef - /* The probability of a raw symbol error is the probability - * that a 1-bit would be received as a sample with value - * 0-128. This is the offset normal curve integrated from -Inf to 0. - */ - printf("symbol Pe = %lg\n",normal(-1/noise)); -#endif - for(bit=0;bit<2;bit++){ - for(s=0;s<256;s++){ - /* Scale and round to nearest integer */ - mettab[bit][s] = floor(metrics[bit][s] * scale + 0.5); -#ifdef notdef - printf("metrics[%d][%d] = %lg, mettab = %d\n", - bit,s,metrics[bit][s],mettab[bit][s]); -#endif - } - } -} diff --git a/gnuradio-core/src/lib/viterbi/tab.c b/gnuradio-core/src/lib/viterbi/tab.c deleted file mode 100644 index 1c135acfee..0000000000 --- a/gnuradio-core/src/lib/viterbi/tab.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 1995 Phil Karn, KA9Q - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* 8-bit parity lookup table, generated by partab.c */ -unsigned char Partab[] = { - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, -}; diff --git a/gnuradio-core/src/lib/viterbi/viterbi.c b/gnuradio-core/src/lib/viterbi/viterbi.c deleted file mode 100644 index fc88866035..0000000000 --- a/gnuradio-core/src/lib/viterbi/viterbi.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Copyright 1995 Phil Karn, KA9Q - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * Viterbi decoder for K=7 rate=1/2 convolutional code - * Some modifications from original Karn code by Matt Ettus - */ - -#include "viterbi.h" - -/* The two generator polynomials for the NASA Standard K=7 code. - * Since these polynomials are known to be optimal for this constraint - * length there is not much point in changing them. But if you do, you - * will have to regenerate the BUTTERFLY macro calls in viterbi() - */ -#define POLYA 0x6d -#define POLYB 0x4f - -/* The basic Viterbi decoder operation, called a "butterfly" - * operation because of the way it looks on a trellis diagram. Each - * butterfly involves an Add-Compare-Select (ACS) operation on the two nodes - * where the 0 and 1 paths from the current node merge at the next step of - * the trellis. - * - * The code polynomials are assumed to have 1's on both ends. Given a - * function encode_state() that returns the two symbols for a given - * encoder state in the low two bits, such a code will have the following - * identities for even 'n' < 64: - * - * encode_state(n) = encode_state(n+65) - * encode_state(n+1) = encode_state(n+64) = (3 ^ encode_state(n)) - * - * Any convolutional code you would actually want to use will have - * these properties, so these assumptions aren't too limiting. - * - * Doing this as a macro lets the compiler evaluate at compile time the - * many expressions that depend on the loop index and encoder state and - * emit them as immediate arguments. - * This makes an enormous difference on register-starved machines such - * as the Intel x86 family where evaluating these expressions at runtime - * would spill over into memory. - */ -#define BUTTERFLY(i,sym) { \ - int m0,m1;\ -\ - /* ACS for 0 branch */\ - m0 = state[i].metric + mets[sym]; /* 2*i */\ - m1 = state[i+32].metric + mets[3^sym]; /* 2*i + 64 */\ - if(m0 > m1){\ - next[2*i].metric = m0;\ - next[2*i].path = state[i].path << 1;\ - } else {\ - next[2*i].metric = m1;\ - next[2*i].path = (state[i+32].path << 1)|1;\ - }\ - /* ACS for 1 branch */\ - m0 = state[i].metric + mets[3^sym]; /* 2*i + 1 */\ - m1 = state[i+32].metric + mets[sym]; /* 2*i + 65 */\ - if(m0 > m1){\ - next[2*i+1].metric = m0;\ - next[2*i+1].path = state[i].path << 1;\ - } else {\ - next[2*i+1].metric = m1;\ - next[2*i+1].path = (state[i+32].path << 1)|1;\ - }\ -} - -extern unsigned char Partab[]; /* Parity lookup table */ - -/* Convolutionally encode data into binary symbols */ -unsigned char -encode(unsigned char *symbols, - unsigned char *data, - unsigned int nbytes, - unsigned char encstate) -{ - int i; - - while(nbytes-- != 0){ - for(i=7;i>=0;i--){ - encstate = (encstate << 1) | ((*data >> i) & 1); - *symbols++ = Partab[encstate & POLYA]; - *symbols++ = Partab[encstate & POLYB]; - } - data++; - } - - return encstate; -} - -/* Viterbi decoder */ -int -viterbi(unsigned long *metric, /* Final path metric (returned value) */ - unsigned char *data, /* Decoded output data */ - unsigned char *symbols, /* Raw deinterleaved input symbols */ - unsigned int nbits, /* Number of output bits */ - int mettab[2][256] /* Metric table, [sent sym][rx symbol] */ - ){ - unsigned int bitcnt = 0; - int mets[4]; - long bestmetric; - int beststate,i; - struct viterbi_state state0[64],state1[64],*state,*next; - - state = state0; - next = state1; - - /* Initialize starting metrics to prefer 0 state */ - state[0].metric = 0; - for(i=1;i<64;i++) - state[i].metric = -999999; - state[0].path = 0; - - for(bitcnt = 0;bitcnt < nbits;bitcnt++){ - /* Read input symbol pair and compute all possible branch - * metrics - */ - mets[0] = mettab[0][symbols[0]] + mettab[0][symbols[1]]; - mets[1] = mettab[0][symbols[0]] + mettab[1][symbols[1]]; - mets[2] = mettab[1][symbols[0]] + mettab[0][symbols[1]]; - mets[3] = mettab[1][symbols[0]] + mettab[1][symbols[1]]; - symbols += 2; - - /* These macro calls were generated by genbut.c */ - BUTTERFLY(0,0); - BUTTERFLY(1,1); - BUTTERFLY(2,3); - BUTTERFLY(3,2); - BUTTERFLY(4,3); - BUTTERFLY(5,2); - BUTTERFLY(6,0); - BUTTERFLY(7,1); - BUTTERFLY(8,0); - BUTTERFLY(9,1); - BUTTERFLY(10,3); - BUTTERFLY(11,2); - BUTTERFLY(12,3); - BUTTERFLY(13,2); - BUTTERFLY(14,0); - BUTTERFLY(15,1); - BUTTERFLY(16,2); - BUTTERFLY(17,3); - BUTTERFLY(18,1); - BUTTERFLY(19,0); - BUTTERFLY(20,1); - BUTTERFLY(21,0); - BUTTERFLY(22,2); - BUTTERFLY(23,3); - BUTTERFLY(24,2); - BUTTERFLY(25,3); - BUTTERFLY(26,1); - BUTTERFLY(27,0); - BUTTERFLY(28,1); - BUTTERFLY(29,0); - BUTTERFLY(30,2); - BUTTERFLY(31,3); - - /* Swap current and next states */ - if(bitcnt & 1){ - state = state0; - next = state1; - } else { - state = state1; - next = state0; - } - // ETTUS - //if(bitcnt > nbits-7){ - /* In tail, poison non-zero nodes */ - //for(i=1;i<64;i += 2) - // state[i].metric = -9999999; - //} - /* Produce output every 8 bits once path memory is full */ - if((bitcnt % 8) == 5 && bitcnt > 32){ - /* Find current best path */ - bestmetric = state[0].metric; - beststate = 0; - for(i=1;i<64;i++){ - if(state[i].metric > bestmetric){ - bestmetric = state[i].metric; - beststate = i; - } - } -#ifdef notdef - printf("metrics[%d] = %d state = %lx\n",beststate, - state[beststate].metric,state[beststate].path); -#endif - *data++ = state[beststate].path >> 24; - } - - } - /* Output remaining bits from 0 state */ - // ETTUS Find best state instead - bestmetric = state[0].metric; - beststate = 0; - for(i=1;i<64;i++){ - if(state[i].metric > bestmetric){ - bestmetric = state[i].metric; - beststate = i; - } - } - if((i = bitcnt % 8) != 6) - state[beststate].path <<= 6-i; - - *data++ = state[beststate].path >> 24; - *data++ = state[beststate].path >> 16; - *data++ = state[beststate].path >> 8; - *data = state[beststate].path; - //printf ("BS = %d\tBSM = %d\tM0 = %d\n",beststate,state[beststate].metric,state[0].metric); - *metric = state[beststate].metric; - return 0; -} - - -void -viterbi_chunks_init(struct viterbi_state* state) { - // Initialize starting metrics to prefer 0 state - int i; - state[0].metric = 0; - state[0].path = 0; - for(i=1;i<64;i++) - state[i].metric = -999999; -} - -void -viterbi_butterfly8(unsigned char *symbols, int mettab[2][256], struct viterbi_state *state0, struct viterbi_state *state1) -{ - unsigned int bitcnt; - int mets[4]; - - struct viterbi_state *state, *next; - state = state0; - next = state1; - // Operate on 16 symbols (8 bits) at a time - for(bitcnt = 0;bitcnt < 8;bitcnt++){ - // Read input symbol pair and compute all possible branch metrics - mets[0] = mettab[0][symbols[0]] + mettab[0][symbols[1]]; - mets[1] = mettab[0][symbols[0]] + mettab[1][symbols[1]]; - mets[2] = mettab[1][symbols[0]] + mettab[0][symbols[1]]; - mets[3] = mettab[1][symbols[0]] + mettab[1][symbols[1]]; - symbols += 2; - - // These macro calls were generated by genbut.c - BUTTERFLY(0,0);BUTTERFLY(1,1);BUTTERFLY(2,3);BUTTERFLY(3,2); - BUTTERFLY(4,3);BUTTERFLY(5,2);BUTTERFLY(6,0);BUTTERFLY(7,1); - BUTTERFLY(8,0);BUTTERFLY(9,1);BUTTERFLY(10,3);BUTTERFLY(11,2); - BUTTERFLY(12,3);BUTTERFLY(13,2);BUTTERFLY(14,0);BUTTERFLY(15,1); - BUTTERFLY(16,2);BUTTERFLY(17,3);BUTTERFLY(18,1);BUTTERFLY(19,0); - BUTTERFLY(20,1);BUTTERFLY(21,0);BUTTERFLY(22,2);BUTTERFLY(23,3); - BUTTERFLY(24,2);BUTTERFLY(25,3);BUTTERFLY(26,1);BUTTERFLY(27,0); - BUTTERFLY(28,1);BUTTERFLY(29,0);BUTTERFLY(30,2);BUTTERFLY(31,3); - - // Swap current and next states - if(bitcnt & 1){ - state = state0; - next = state1; - } else { - state = state1; - next = state0; - } - } -} - -void -viterbi_butterfly2(unsigned char *symbols, int mettab[2][256], struct viterbi_state *state0, struct viterbi_state *state1) -{ - //unsigned int bitcnt; - int mets[4]; - - struct viterbi_state *state, *next; - state = state0; - next = state1; - // Operate on 4 symbols (2 bits) at a time - - // Read input symbol pair and compute all possible branch metrics - mets[0] = mettab[0][symbols[0]] + mettab[0][symbols[1]]; - mets[1] = mettab[0][symbols[0]] + mettab[1][symbols[1]]; - mets[2] = mettab[1][symbols[0]] + mettab[0][symbols[1]]; - mets[3] = mettab[1][symbols[0]] + mettab[1][symbols[1]]; - - // These macro calls were generated by genbut.c - BUTTERFLY(0,0);BUTTERFLY(1,1);BUTTERFLY(2,3);BUTTERFLY(3,2); - BUTTERFLY(4,3);BUTTERFLY(5,2);BUTTERFLY(6,0);BUTTERFLY(7,1); - BUTTERFLY(8,0);BUTTERFLY(9,1);BUTTERFLY(10,3);BUTTERFLY(11,2); - BUTTERFLY(12,3);BUTTERFLY(13,2);BUTTERFLY(14,0);BUTTERFLY(15,1); - BUTTERFLY(16,2);BUTTERFLY(17,3);BUTTERFLY(18,1);BUTTERFLY(19,0); - BUTTERFLY(20,1);BUTTERFLY(21,0);BUTTERFLY(22,2);BUTTERFLY(23,3); - BUTTERFLY(24,2);BUTTERFLY(25,3);BUTTERFLY(26,1);BUTTERFLY(27,0); - BUTTERFLY(28,1);BUTTERFLY(29,0);BUTTERFLY(30,2);BUTTERFLY(31,3); - - state = state1; - next = state0; - - // Read input symbol pair and compute all possible branch metrics - mets[0] = mettab[0][symbols[2]] + mettab[0][symbols[3]]; - mets[1] = mettab[0][symbols[2]] + mettab[1][symbols[3]]; - mets[2] = mettab[1][symbols[2]] + mettab[0][symbols[3]]; - mets[3] = mettab[1][symbols[2]] + mettab[1][symbols[3]]; - - // These macro calls were generated by genbut.c - BUTTERFLY(0,0);BUTTERFLY(1,1);BUTTERFLY(2,3);BUTTERFLY(3,2); - BUTTERFLY(4,3);BUTTERFLY(5,2);BUTTERFLY(6,0);BUTTERFLY(7,1); - BUTTERFLY(8,0);BUTTERFLY(9,1);BUTTERFLY(10,3);BUTTERFLY(11,2); - BUTTERFLY(12,3);BUTTERFLY(13,2);BUTTERFLY(14,0);BUTTERFLY(15,1); - BUTTERFLY(16,2);BUTTERFLY(17,3);BUTTERFLY(18,1);BUTTERFLY(19,0); - BUTTERFLY(20,1);BUTTERFLY(21,0);BUTTERFLY(22,2);BUTTERFLY(23,3); - BUTTERFLY(24,2);BUTTERFLY(25,3);BUTTERFLY(26,1);BUTTERFLY(27,0); - BUTTERFLY(28,1);BUTTERFLY(29,0);BUTTERFLY(30,2);BUTTERFLY(31,3); -} - -unsigned char -viterbi_get_output(struct viterbi_state *state, unsigned char *outbuf) { - // Produce output every 8 bits once path memory is full - // if((bitcnt % 8) == 5 && bitcnt > 32) { - - // Find current best path - unsigned int i,beststate; - int bestmetric; - - bestmetric = state[0].metric; - beststate = 0; - for(i=1;i<64;i++) - if(state[i].metric > bestmetric) { - bestmetric = state[i].metric; - beststate = i; - } - *outbuf = state[beststate].path >> 24; - return bestmetric; -} - - -//printf ("BS = %d\tBSM = %d\tM0 = %d\n",beststate,state[beststate].metric,state[0].metric); -// In tail, poison non-zero nodes -//if(bits_out > packet_size-7) -// for(i=1;i<64;i += 2) -// state[i].metric = -9999999; - diff --git a/gnuradio-core/src/lib/viterbi/viterbi.h b/gnuradio-core/src/lib/viterbi/viterbi.h deleted file mode 100644 index bcdbe116d6..0000000000 --- a/gnuradio-core/src/lib/viterbi/viterbi.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* The path memory for each state is 32 bits. This is slightly shorter - * than we'd like for K=7, especially since we chain back every 8 bits. - * But it fits so nicely into a 32-bit machine word... - */ - -#include <gr_core_api.h> - -struct viterbi_state { - unsigned long path; /* Decoded path to this state */ - long metric; /* Cumulative metric to this state */ -}; - -GR_CORE_API -int gen_met(int mettab[2][256], /* Metric table */ - int amp, /* Signal amplitude */ - double esn0, /* Es/N0 ratio in dB */ - double bias, /* Metric bias */ - int scale); /* Scale factor */ - -GR_CORE_API unsigned char -encode(unsigned char *symbols, unsigned char *data, - unsigned int nbytes,unsigned char encstate); - -GR_CORE_API void -viterbi_chunks_init(struct viterbi_state* state); - - GR_CORE_API void -viterbi_butterfly2(unsigned char *symbols, int mettab[2][256], - struct viterbi_state *state0, struct viterbi_state *state1); - -GR_CORE_API unsigned char -viterbi_get_output(struct viterbi_state *state, unsigned char *outbuf); |