diff options
Diffstat (limited to 'gnuradio-core/src/lib/general')
86 files changed, 1270 insertions, 5505 deletions
diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index e3dc18520b..d85039fe60 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -22,6 +22,26 @@ ######################################################################## ######################################################################## +# 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 @@ -50,9 +70,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_fast_atan2f.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}/gr_sincos.c ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.cc ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.c ) @@ -63,7 +85,11 @@ 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_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_sincos.cc ) ######################################################################## @@ -73,15 +99,20 @@ 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_endianness.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_expj.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_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_sincos.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_test_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_vco.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_15_1_0.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_32k.h ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.h ${CMAKE_CURRENT_SOURCE_DIR}/random.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio @@ -105,39 +136,11 @@ endif(ENABLE_PYTHON) ######################################################################## set(gr_core_general_triple_threats complex_vec_test - gr_align_on_samplenumbers_ss gr_block_gateway - gr_check_counting_s - gr_check_lfsr_32k_s - gr_copy - gr_endian_swap - gr_fake_channel_coder_pp gr_feval - gr_head - gr_iqcomp_cc - gr_kludge_copy - gr_lfsr_32k_source_s - gr_nop - gr_null_sink - gr_null_source - gr_pa_2x2_phase_combiner gr_prefs - gr_skiphead gr_test - gr_vector_map - gr_annotator_alltoall - gr_annotator_1to1 - gr_annotator_raw -) - -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) @@ -146,3 +149,11 @@ foreach(file_tt ${gr_core_general_triple_threats}) 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_general_triple_threats}) + +CHECK_CXX_SOURCE_COMPILES(" + #define _GNU_SOURCE + #include <math.h> + int main(){double x, sin, cos; sincos(x, &sin, &cos); return 0;} + " HAVE_SINCOS +) +GR_ADD_COND_DEF(HAVE_SINCOS) diff --git a/gnuradio-core/src/lib/general/README b/gnuradio-core/src/lib/general/README deleted file mode 100644 index 5fa18d7f64..0000000000 --- a/gnuradio-core/src/lib/general/README +++ /dev/null @@ -1,98 +0,0 @@ -Files beginning with Gr* define classes that inherit from VrSigProc. -These are high level signal processing modules that can be glued -together in your signal processing chain. - -All the others are either lower level routines which implement the -functionality of the Gr* modules, but are easier to test (fewer -dependencies), or they are general purpose. - -gr_fir_???.{h,cc}, where ??? are in F, S or C are low level Finite -Impulse Response Filters. These turn out to be where the bulk of the -cycles are burned in many applications. The ??? suffix specifies the -input type, output type and tap type of the arguments. We've -implemented the most frequently used ones. - -[Once upon a time this stuff was done with templates -(gr_fir<iType,oType,tapType>), but this turned out to be a headache. -The code appeared to trigger a bug in GCC where we were getting -multiple definitions of unrelated stuff when we started subclassing -partially specialized templates. It was also not obvious as to to -what combinations of iType, oType and tapType actually worked. We're -now explicit, and the world is a safer place to live...] - -The top level routines for FIR filtering are: - - GrFIRfilterFFF : Float input, Float output, Float taps - -- general purpose - - GrFIRfilterCCF : Complex input, Complex output, Float taps - -- applying real filter to a complex signal - - GrFIRfilterFCC : Float input, Complex output, Complex taps - -- applying complex filter to float input - - GrFIRfilterSCC : Short input, Complex output, Complex taps - -- applying complex filter to short input. Quantizes complex - coefficients to 16 bits and uses MMX or SSE2 as appropriate - - -The combination of down conversion (frequency translation) and channel -selection (filtering) is performed with: - - GrFreqXlatingFIRfilterSFC : Short input, Float taps, Complex baseband output - -- quantizes complex coefficents to 16 bits and uses MMX or - SSE2 (128-bit MMX) as appropriate [optimization to be done]. - - GrFreqXlatingFIRfilterFFC : Float input, Float taps, Complex baseband output - -- 3dnow or SSE as appropriate. - - -[ The stuff described from here down is used to implement the routines - above. This info is only relevant to those who are hacking the internals ] - - -A bit of indirection is involved in selecting the fastest -implementation for any given platform. The lower level classes -gr_fir_FFF.h, gr_fir_CCF, gr_fir_FCC and gr_fir_SCC have i/o -signatures similar to the high level clases above. These -should be considered the abstract base classes that you -work with. Note that they are not actually abstract (they've got a -default implementation; this might be considered a bug), but they -should not be directly instantiated by user code. - -Instead of directly instantiating a gr_fir_FFF, for example, your code -should actually: - - #include <gr_fir_util.h> - - // let the system pick the best implementation for you - gr_fir_FFF *filter = gr_fir_util::create_gr_fir_FFF (my_taps); - -Clear? The same for all the other gr_fir_XXX's. - - - -Performance hacking can be done by subclassing the appropriate -base class. For example, on the x86 platform, there are two -additional classes derived from gr_fir_FFF, gr_fir_FFF_sse and -gr_fir_FFF_3dnow. These classes are then made available to the rest -of the system by virtue of being added to gr_fir_sysconfig_x86.cc, -along with any guards (CPUID checks) needed to ensure that only -compatible code is executed on the current hardware. - - -TO DO ------- - -* Move all the machine specific code to a subdirectory, then have -configure symlink to the right directory. This will allow us to build on -any platform without choking. There is generic code for all routines, -only the machine dependent speedup will be lacking. - -* Add an interface to gr_fir_util that will return a vector of all -valid constructors with descriptive names for each i/o signature. -This will allow the test code and benchmarking code to be blissfully -ignorant of what platform they're running on. The actual building of -the vectors should be done bottom up through the gr_fir_sysconfig -hierarchy. - diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index bcf4392bb4..68b963702c 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -22,69 +22,20 @@ %{ -#include <gr_nop.h> -#include <gr_null_sink.h> -#include <gr_null_source.h> -#include <gr_head.h> -#include <gr_skiphead.h> -#include <gr_check_counting_s.h> -#include <gr_lfsr_32k_source_s.h> -#include <gr_check_lfsr_32k_s.h> -#include <gr_align_on_samplenumbers_ss.h> -//#include <gr_endianness.h> -#include <gr_endian_swap.h> -#include <gr_fake_channel_coder_pp.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_feval.h> -#include <gr_copy.h> #include <complex_vec_test.h> -#include <gr_annotator_alltoall.h> -#include <gr_annotator_1to1.h> -#include <gr_annotator_raw.h> -#include <gr_vector_map.h> +#include <gr_endianness.h> %} -%include "gr_nop.i" -%include "gr_null_sink.i" -%include "gr_null_source.i" -%include "gr_head.i" -%include "gr_skiphead.i" -%include "gr_check_counting_s.i" -%include "gr_lfsr_32k_source_s.i" -%include "gr_check_lfsr_32k_s.i" -%include "gr_align_on_samplenumbers_ss.i" -//%include "gr_endianness.i" -%include "gr_endian_swap.i" -%include "gr_fake_channel_coder_pp.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_feval.i" -%include "gr_copy.i" %include "complex_vec_test.i" -%include "gr_annotator_alltoall.i" -%include "gr_annotator_1to1.i" -%include "gr_annotator_raw.i" -%include "gr_vector_map.i" %include "gr_block_gateway.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 */ +%include "gr_endianness.h" diff --git a/gnuradio-core/src/lib/general/general_generated.i b/gnuradio-core/src/lib/general/general_generated.i deleted file mode 100644 index c3f67e0d47..0000000000 --- a/gnuradio-core/src/lib/general/general_generated.i +++ /dev/null @@ -1,26 +0,0 @@ -// -// This file is machine generated. All edits will be overwritten -// -%{ -#include <gr_vector_sink_b.h> -#include <gr_vector_sink_c.h> -#include <gr_vector_sink_f.h> -#include <gr_vector_sink_i.h> -#include <gr_vector_sink_s.h> -#include <gr_vector_source_b.h> -#include <gr_vector_source_c.h> -#include <gr_vector_source_f.h> -#include <gr_vector_source_i.h> -#include <gr_vector_source_s.h> -%} - -%include <gr_vector_sink_b.i> -%include <gr_vector_sink_c.i> -%include <gr_vector_sink_f.i> -%include <gr_vector_sink_i.i> -%include <gr_vector_sink_s.i> -%include <gr_vector_source_b.i> -%include <gr_vector_source_c.i> -%include <gr_vector_source_f.i> -%include <gr_vector_source_i.i> -%include <gr_vector_source_s.i> diff --git a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.cc b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.cc deleted file mode 100644 index 4728533964..0000000000 --- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.cc +++ /dev/null @@ -1,464 +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_align_on_samplenumbers_ss.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <stdexcept> -#include <string.h> -#include <cstdio> - -//define ALIGN_ADVANCED_IMPLEMENTATION to have an alternative implementation of the align algoritm which exactly follows the align_interval spec. -//It is more resource intensive, less tested and probably not needed -//define ALIGN_ADVANCED_IMPLEMENTATION - -//define DEBUG_TOCONSUME to see debug messages about the synchronisation part of this block -//define DEBUG_TOCONSUME -#ifdef DEBUG_TOCONSUME -#define tcPrintf if(dprint) printf -#else -#define tcPrintf //printf -#endif - -#define ePrintf printf - -gr_align_on_samplenumbers_ss_sptr -gr_make_align_on_samplenumbers_ss (int nchan, int align_interval) -{ - return gnuradio::get_initial_sptr(new gr_align_on_samplenumbers_ss (nchan,align_interval)); -} - -gr_align_on_samplenumbers_ss::gr_align_on_samplenumbers_ss (int nchan,int align_interval) - : gr_block ("align_on_samplenumbers_ss", - gr_make_io_signature (2, -1, sizeof (short)), //2, -1 - gr_make_io_signature (2, -1, sizeof (short))), //2,-1 - d_align_interval (align_interval), - d_nchan(nchan), - d_ninputs(0) -{ - if (d_align_interval<0) - set_output_multiple (d_nchan*2); - else - { - set_output_multiple (d_align_interval*d_nchan*2); - } - -} - -gr_align_on_samplenumbers_ss::~gr_align_on_samplenumbers_ss() -{ - -} -void -gr_align_on_samplenumbers_ss::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - //assert (0 == noutput_items % d_align_interval); - unsigned ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) - ninput_items_required[i] = std::max(noutput_items*d_nchan*2+ history() - 1,1024*d_nchan*2+ history() - 1);//TODO include the diffs found in determine input_items_required -} - -bool -gr_align_on_samplenumbers_ss::check_topology (int ninputs, int noutputs) -{ - bool result=true; - if(noutputs!=ninputs) - { - result=false; - ePrintf("gr_align_on_samplenumbers_ss: ERROR noutputs %i != ninputs %i\n",noutputs,ninputs); - } - if(d_nchan<2) - { - result=false; - ePrintf("gr_align_on_samplenumbers_ss: ERROR nchan %i<2 \n",d_nchan); - } - if((int)d_ninputs!=ninputs) - { - //Only resize and reset the status if there really changed something - //Don't reset the status if the user just called stop() and start(), although maybe we should. - d_state.resize(ninputs); - d_ninputs=ninputs; - for(unsigned int i=0;i<d_ninputs;i++) - { - d_state[i].sync_found=false; - d_state[i].sync_end_found=false; - } - d_in_presync=false; - } - return result; -} - -#ifdef ALIGN_ADVANCED_IMPLEMENTATION -int -gr_align_on_samplenumbers_ss::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ -#ifdef DEBUG_TOCONSUME - static int dcount=0; - bool dprint=false; - dcount++; - if(dcount>200) - { - dcount=0; - dprint=true; - } -#endif - const size_t item_size = output_signature()->sizeof_stream_item (0); - const unsigned ninputs = input_items.size(); - const unsigned noutputs = output_items.size(); - - int align_interval=d_align_interval*2*d_nchan; - if(d_align_interval<0) - { - //align once per noutput_items - align_interval=noutput_items; - align_interval=align_interval/(2*d_nchan); - align_interval=align_interval*(2*d_nchan); - } - - int min_ninput_items=noutput_items;//numeric_limits<int>::max(); - int noutput_items_produced=0; - for(unsigned int i=0;i<ninputs;i++) - { - d_state[i].ninput_items=ninput_items[i]; - d_state[i].ninput_items_used=0; - min_ninput_items=std::min(ninput_items[i],min_ninput_items); - } - for(int j=0;j<noutput_items-align_interval+1;j+=align_interval) - { - int common_end; - if(min_ninput_items>=align_interval) - common_end=align_interval; - else - { - common_end=min_ninput_items/(d_nchan*2); - common_end=common_end*(d_nchan*2); - } - if (common_end<=0) break; - - bool all_diffs_zero=true; - //bool sync_found=false; - int diff_comp_end_max=0; - for(unsigned int i=0;i<ninputs;i++) - { - unsigned short * uin=&(((unsigned short*)input_items[i])[d_state[i].ninput_items_used]); - unsigned int x_high16bits = uin[0]; - unsigned int x_low16bits = uin[1]; - d_state[i].ucounter_begin = x_high16bits<<16 | x_low16bits; - d_state[i].diff=d_state[0].ucounter_begin-d_state[i].ucounter_begin;//Result is a signed value,Will wrap around on 32 bit boundary - int common_last=std::max(common_end-d_nchan*2,0); - x_high16bits = uin[d_nchan*2]; - x_low16bits = uin[d_nchan*2+1]; - unsigned int ucounter_begin2 = x_high16bits<<16 | x_low16bits; -#ifdef DEBUG_TOCONSUME - if((d_state[i].ucounter_begin+1)!=(ucounter_begin2)) - if(ucounter_begin2==0) - ePrintf("SYNC counters are 0\n"); - else - ePrintf("Error: counter not continuous.\n ucounter_begin[%i]=%i +1 != ucounter_begin2=%i\n",i,d_state[i].ucounter_begin,ucounter_begin2); -#endif - x_high16bits = uin[common_last]; - x_low16bits = uin[common_last+1]; - d_state[i].ucounter_end = x_high16bits<<16 | x_low16bits; - d_state[i].diff_end=d_state[0].ucounter_end-d_state[i].ucounter_end;//Result is a signed value,Will wrap around on 32 bit boundary - d_state[i].diff_comp_end=d_state[i].ucounter_end-d_state[0].ucounter_end; - diff_comp_end_max=std::max(d_state[i].diff_comp_end,diff_comp_end_max); -#ifdef DEBUG_TOCONSUME - if(d_state[i].diff>256000000 || d_state[i].diff_end>256000000 || d_state[i].diff_comp_end>256000000) - { - tcPrintf("diff[%i]=%i diff_end=%i diff_comp_end=%i\n",i,d_state[i].diff,d_state[i].diff_end,d_state[i].diff_comp_end); - } -#endif - all_diffs_zero=all_diffs_zero && (0==d_state[i].diff_end); - if(d_state[i].ucounter_end<d_state[i].ucounter_begin+(unsigned)(common_last/(d_nchan*2))) //(unsigned)(common_last/(d_nchan*2))) - { - //printf("sync 1 ");// found ucounter_end[%i]=%i ucounter_begin[%i]=%i \n",i,d_state[i].ucounter_end,i,d_state[i].ucounter_begin); - //sync_found=true;//sync_found or 32 bit counter wraparound (0xffffffff -> 0x00000000) - if(!d_in_presync) - { -#ifdef DEBUG_TOCONSUME - printf("presync START with %i\n",i); -#endif - for(unsigned int k=0;k<ninputs;k++) - { - d_state[k].sync_found=false; - d_state[i].sync_end_found=false; - } - d_in_presync=true; - d_state[i].sync_found=true; - } else - { - //d_in_presync=true; -#ifdef DEBUG_TOCONSUME - if(d_state[i].sync_found) - printf("presync CONTINUE with %i\n",i); - else - printf("presync NEXT with %i\n",i); -#endif - d_state[i].sync_found=true; - d_state[i].sync_end_found=false; - } - } else - { - if(d_in_presync && d_state[i].sync_found) - { - d_state[i].sync_end_found=true; - bool all_syncs_found=true; - for(unsigned int k=0;k<ninputs;k++) - all_syncs_found=all_syncs_found && d_state[k].sync_end_found; - d_in_presync=!all_syncs_found; - if(!d_in_presync) - { - for(unsigned int k=0;k<ninputs;k++) - { - d_state[k].sync_found=false; - d_state[i].sync_end_found=false; - } -#ifdef DEBUG_TOCONSUME - printf("presync END\n"); -#endif - } - } - } - } - if(d_in_presync || all_diffs_zero) - { - for(unsigned int i=0;i<ninputs;i++) - { - memcpy(&(((unsigned short*)output_items[i])[j]),&(((const unsigned short*)input_items[i])[d_state[i].ninput_items_used]),common_end*item_size); - //consume(i,common_end); - d_state[i].ninput_items-=common_end; - d_state[i].ninput_items_used+=common_end; - min_ninput_items=std::min(d_state[i].ninput_items,min_ninput_items); -#ifdef DEBUG_TOCONSUME - if(common_end<256) - tcPrintf("common_end %i\n",common_end); -#endif - } - //min_ninput_items-=common_end; - noutput_items_produced+=common_end; - //return common_end; - } else - { - //printf("sync 2"); - for(unsigned int i=0;i<ninputs;i++) - { - int toconsume=std::min((d_state[i].diff_end+diff_comp_end_max)*d_nchan*2,d_state[i].ninput_items); - toconsume=toconsume/(d_nchan*2); - toconsume=toconsume*(d_nchan*2); - d_state[i].ninput_items-=toconsume; - d_state[i].ninput_items_used+=toconsume; - min_ninput_items=std::min(d_state[i].ninput_items,min_ninput_items); -#ifdef DEBUG_TOCONSUME - static int toconsume_counter=0; - toconsume_counter++; - //if(toconsume_counter>10) - { - tcPrintf("toconsume=%i diff_end[%i]*d_nchan*2=%i diff_comp_end_max*d_nchan*2=%i ninput_items[%i]=%i\n",toconsume,i,d_state[i].diff_end*d_nchan*2,diff_comp_end_max*d_nchan*2,i,ninput_items[i]); - toconsume_counter=0; - } -#endif - //printf("toconsume[%i]=%i\n",i,toconsume); - //consume(i,toconsume);//skip the difference in samplenumber items - } - //return 0; - } - } - for(unsigned int i=0;i<ninputs;i++) - consume(i,d_state[i].ninput_items_used); -#ifdef DEBUG_TOCONSUME - if(noutput_items_produced<256) - tcPrintf("noutput_items_produced %i\n",noutput_items_produced); -#endif - return noutput_items_produced; -} - - -#else /*ALIGN_ADVANCED_IMPLEMENTATION*/ -int -gr_align_on_samplenumbers_ss::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ -#ifdef DEBUG_TOCONSUME - static int dcount=0; - bool dprint=false; - dcount++; - if(dcount>2000) - { - dcount=0; - dprint=true; - } -#endif - const size_t item_size = output_signature()->sizeof_stream_item (0); - const unsigned ninputs = input_items.size(); - - int common_end=noutput_items; - //int diff_min=INT_MAX; - //int diff_max=INT_MIN; - for(unsigned int i=0;i<ninputs;i++) - { - unsigned short * uin=(unsigned short*)input_items[i]; - unsigned int x_high16bits = uin[0]; - unsigned int x_low16bits = uin[1]; - d_state[i].ucounter_begin = x_high16bits<<16 | x_low16bits; - d_state[i].diff=d_state[0].ucounter_end-d_state[i].ucounter_end;//Result is a signed value,Will wrap around on 32 bit boundary - x_high16bits = uin[d_nchan*2]; - x_low16bits = uin[d_nchan*2+1]; - unsigned int ucounter_begin2 = x_high16bits<<16 | x_low16bits; - if((d_state[i].ucounter_begin+1)!=(ucounter_begin2)){ - if(ucounter_begin2==0) - { -#ifdef DEBUG_TOCONSUME - ePrintf("SYNC counters are 0\n"); -#endif - } - else - { - ePrintf("Error: counter not continuous.\n ucounter_begin[%i]=%i +1 != ucounter_begin2=%i\n",i,d_state[i].ucounter_begin,ucounter_begin2); - } - } - - //diff_comp[i]=ucounter[i]-ucounter[0]; - //diff_min=std::min(diff[i],diff_min); - //diff_max=std::max(diff[i],diff_max); - common_end=std::max(std::min(ninput_items[i],common_end),0); - } - common_end=common_end/(d_nchan*2); - common_end=common_end*(d_nchan*2); -#ifdef DEBUG_TOCONSUME - if(common_end<d_nchan*2) - { - printf(" common_end %i\n",common_end); - for(int j=0;j<ninputs;j++) - printf("ninput_items[%i]=%i\n",j,ninput_items[j]); - } -#endif - bool all_diffs_zero=true; - bool sync_found=false; - int diff_comp_end_max=0; - for(unsigned int i=0;i<ninputs;i++) - { - unsigned short * uin=(unsigned short*)input_items[i]; - int common_last=common_end-(d_nchan*2); - unsigned int x_high16bits = uin[common_last]; - unsigned int x_low16bits = uin[common_last+1]; - d_state[i].ucounter_end = x_high16bits<<16 | x_low16bits; - d_state[i].diff_end=d_state[0].ucounter_end-d_state[i].ucounter_end;//Result is a signed value,Will wrap around on 32 bit boundary - d_state[i].diff_comp_end=d_state[i].ucounter_end-d_state[0].ucounter_end; - //diff_end_min=std::min(diff_end[i],diff_end_min); - //diff_end_max=std::max(diff_end[i],diff_end_max); - diff_comp_end_max=std::max(d_state[i].diff_comp_end,diff_comp_end_max); -#ifdef DEBUG_TOCONSUME - if(d_state[i].diff_end!=d_state[i].diff) - { - //samples_lost_or_syncstart=true; - printf("Us%i %i %i ",i,d_state[i].diff_end,d_state[i].diff); - } -#endif - all_diffs_zero=all_diffs_zero && (0==d_state[i].diff_end); - if((d_state[i].ucounter_end<d_state[i].ucounter_begin+(unsigned)(common_last/(d_nchan*2))) || (0==d_state[i].ucounter_end) || (0==d_state[i].ucounter_begin)) //(unsigned)(common_last/(d_nchan*2))) - { - sync_found=true;//sync_found or 32 bit counter wraparound (0xffffffff -> 0x00000000) -#ifdef DEBUG_TOCONSUME - tcPrintf("SYNC diff_end[%i]=%i ucounter_end[%i]=%i ucounter_begin[%i]=%i \n",i,d_state[i].diff_end,i,d_state[i].ucounter_end,i,d_state[i].ucounter_begin); - tcPrintf("ucounter_end=%i < %i = ucounter_begin+(unsigned)(common_last/(d_nchan*2) \n",d_state[i].ucounter_end,d_state[i].ucounter_begin+(unsigned)(common_last/(d_nchan*2))); - - printf("ucounter_end[%i]=%i ucounter_begin[%i]=%i\n",i,d_state[i].ucounter_end,i,d_state[i].ucounter_begin); - int expected_sync_position=common_last - d_state[i].ucounter_end*(d_nchan*2); - if(0==uin[expected_sync_position] && 0==uin[expected_sync_position+1]) - { - printf("sync found on input %i at position %i \n",i,expected_sync_position); - //sync_start[i]=expected_sync_position; - } else - { - printf("sync found on input %i position unclear, expected at %i value there %i\n",i,expected_sync_position,uin[expected_sync_position]<<16 | uin[expected_sync_position+1]); - //sync_start[i]=-1; - } - } else - { - tcPrintf("NOsync diff_end[%i]=%i ucounter_end[%i]=%i ucounter_begin[%i]=%i \n",i,d_state[i].diff_end,i,d_state[i].ucounter_end,i,d_state[i].ucounter_begin); -#endif - } - } - bool problem=false; - for(unsigned int i=0;i<ninputs;i++) - if((d_state[i].diff_end+diff_comp_end_max) >0x4000000) - { - problem=true; - ePrintf("Warning: counter diff greater as 64 Million\n"); - ePrintf(" You might want to swap master and slave.\n"); - ePrintf(" i=%i,d_state[i].diff_end+diff_comp_end_max=%i,d_state[i].diff_end=%i,diff_comp_end_max=%i,ucounter[i]=%i,ucounter[0]=%i\n", - i,d_state[i].diff_end+diff_comp_end_max,d_state[i].diff_end,diff_comp_end_max,d_state[i].ucounter_end,d_state[0].ucounter_end); - //ePrintf(" toconsume=%i\n",toconsume); - } - if(sync_found || all_diffs_zero || problem) - { -#ifdef DEBUG_TOCONSUME - if(all_diffs_zero) tcPrintf("ZERO\n"); - if(sync_found) tcPrintf("SYNC\n"); -#endif - for(unsigned int i=0;i<ninputs;i++) - { - memcpy(output_items[i],input_items[i],common_end*item_size); - consume(i,common_end); -#ifdef DEBUG_TOCONSUME - if(common_end<256) - tcPrintf("common_end %i\n",common_end); -#endif - } - return common_end; - } else - { - //int minconsume=0;//common_end/(2*d_nchan*2); - //min_consume=min_consume*d_nchan*2; - for(unsigned int i=0;i<ninputs;i++) - { - int toconsume=std::min((d_state[i].diff_end+diff_comp_end_max)*d_nchan*2,ninput_items[i]); - toconsume=toconsume/(d_nchan*2); - toconsume=toconsume*(d_nchan*2); -#ifdef DEBUG_TOCONSUME - //printf("dcount %i\n",dcount); - static int toconsume_counter=0; - toconsume_counter++; - //if(toconsume_counter>10) - { - tcPrintf("toconsume=%i diff_end[[%i]*d_nchan*2=%i diff_comp_end_max)*d_nchan*2=%i ninput_items[%i]=%i\n", - toconsume,i,d_state[i].diff_end*d_nchan*2,diff_comp_end_max*d_nchan*2,i,ninput_items[i]); - toconsume_counter=0; - } -#endif - consume(i,toconsume);//skip the difference in samplenumber items - //printf("toconsume%i %i diff_comp_end_max %i diff_end[[%i] %i\n",i,toconsume,diff_comp_end_max,i,d_state[i].diff_end); - } - return 0; - } - return -1;//Should never come here -} -#endif /*ALIGN_ADVANCED_IMPLEMENTATION*/ diff --git a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h deleted file mode 100644 index 1b71a3f4bc..0000000000 --- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h +++ /dev/null @@ -1,92 +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_ALIGN_ON_SAMPLE_NUMBERS_SS_H -#define INCLUDED_GR_ALIGN_ON_SAMPLE_NUMBERS_SS_H - -#include <gr_core_api.h> -#include <gr_block.h> - -/*! - * \brief align several complex short (interleaved short) input channels with corresponding unsigned 32 bit sample_counters (provided as interleaved 16 bit values) - * \ingroup misc - * \param number of complex_short input channels (including the 32 bit counting channel) - * \param align_interval is after how much samples (minimally) the sample-alignement is refreshed. Default is 128. - * A bigger value means less processing power but also requests more buffer space, which has a maximum. - * Decrease the align_interval if you get an error like: - * "sched: <gr_block align_on_samplenumbers_ss (0)> is requesting more input data than we can provide. - * ninput_items_required = 32768 - * max_possible_items_available = 16383 - * If this is a filter, consider reducing the number of taps." - * \ingroup block - * Pay attention on how you connect this block. - * It expects a minimum of 2 usrp_source_s with nchan number of channels and FPGA_MODE_COUNTING_32BIT enabled. - * This means that the first complex_short channel on every input is an interleaved 32 bit counter. - * The samples are aligned by dropping samples untill the samplenumbers match. - */ -class gr_align_on_samplenumbers_ss; -typedef boost::shared_ptr<gr_align_on_samplenumbers_ss> gr_align_on_samplenumbers_ss_sptr; - -GR_CORE_API gr_align_on_samplenumbers_ss_sptr gr_make_align_on_samplenumbers_ss (int nchan=2, int align_interval=128); - - - - -class GR_CORE_API gr_align_on_samplenumbers_ss : public gr_block -{ - int d_align_interval; - int d_sample_counter; - int d_nchan; - bool d_in_presync; - unsigned int d_ninputs; - class GR_CORE_API align_state { - public: - unsigned int ucounter_end; - unsigned int ucounter_begin; - int diff; - int diff_comp; - int diff_end; - int diff_comp_end; - bool sync_found; - bool sync_end_found; - int ninput_items; - int ninput_items_used; - }; - std::vector<align_state> d_state; - - friend GR_CORE_API gr_align_on_samplenumbers_ss_sptr gr_make_align_on_samplenumbers_ss (int nchan,int align_interval); - gr_align_on_samplenumbers_ss (int nchan,int align_interval); - - public: - ~gr_align_on_samplenumbers_ss(); - bool check_topology (int ninputs, int noutputs); - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_ALIGN_ON_SAMPLE_NUMBERS_SS_H */ diff --git a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i deleted file mode 100644 index 471f743010..0000000000 --- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i +++ /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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,align_on_samplenumbers_ss); - -gr_align_on_samplenumbers_ss_sptr -gr_make_align_on_samplenumbers_ss(int nchan=2, int align_interval=128) throw (std::exception); - -class gr_align_on_samplenumbers_ss : public gr_block -{ - public: - ~gr_align_on_samplenumbers_ss (); - private: - gr_align_on_samplenumbers_ss (int nchan,int align_interval); -}; diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc deleted file mode 100644 index 1178bdc34f..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ /dev/null @@ -1,107 +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_annotator_1to1.h> -#include <gr_io_signature.h> -#include <string.h> -#include <iostream> -#include <iomanip> - -gr_annotator_1to1_sptr -gr_make_annotator_1to1 (int when, size_t sizeof_stream_item) -{ - return gnuradio::get_initial_sptr (new gr_annotator_1to1 - (when, sizeof_stream_item)); -} - -gr_annotator_1to1::gr_annotator_1to1 (int when, size_t sizeof_stream_item) - : gr_sync_block ("annotator_1to1", - gr_make_io_signature (1, -1, sizeof_stream_item), - gr_make_io_signature (1, -1, sizeof_stream_item)), - d_itemsize(sizeof_stream_item), d_when((uint64_t)when) -{ - set_tag_propagation_policy(TPP_ONE_TO_ONE); - - d_tag_counter = 0; - set_relative_rate(1.0); -} - -gr_annotator_1to1::~gr_annotator_1to1 () -{ -} - -int -gr_annotator_1to1::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]; - - std::stringstream str; - str << name() << unique_id(); - - uint64_t abs_N = 0; - int ninputs = input_items.size(); - for(int i = 0; i < ninputs; i++) { - abs_N = nitems_read(i); - - std::vector<gr_tag_t> all_tags; - get_tags_in_range(all_tags, i, abs_N, abs_N + noutput_items); - - std::vector<gr_tag_t>::iterator itr; - for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { - d_stored_tags.push_back(*itr); - } - } - - // Storing the current noutput_items as the value to the "noutput_items" key - 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 - abs_N = nitems_read(0); - int noutputs = output_items.size(); - for(int j = 0; j < noutput_items; j++) { - // the min() is a hack to make sure this doesn't segfault if there are a - // different number of ins and outs. This is specifically designed to test - // 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::from_uint64(d_tag_counter++); - add_item_tag(i, abs_N, key, value, srcid); - } - - in = (const float*)input_items[i]; - out = (float*)output_items[i]; - out[j] = in[j]; - } - abs_N++; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.h b/gnuradio-core/src/lib/general/gr_annotator_1to1.h deleted file mode 100644 index 57e5720141..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.h +++ /dev/null @@ -1,75 +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_ANNOTATOR_1TO1_H -#define INCLUDED_GR_ANNOTATOR_1TO1_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_annotator_1to1; -typedef boost::shared_ptr<gr_annotator_1to1> gr_annotator_1to1_sptr; - -// public constructor -GR_CORE_API gr_annotator_1to1_sptr -gr_make_annotator_1to1 (int when, size_t sizeof_stream_item); - -/*! - * \brief 1-to-1 stream annotator testing block. FOR TESTING PURPOSES ONLY. - * - * This block creates tags to be sent downstream every 10,000 items it sees. The - * tags contain the name and ID of the instantiated block, use "seq" as a key, - * and have a counter that increments by 1 for every tag produced that is used - * as the tag's value. The tags are propagated using the 1-to-1 policy. - * - * It also stores a copy of all tags it sees flow past it. These tags can be - * recalled externally with the data() member. - * - * This block is only meant for testing and showing how to use the tags. - */ -class GR_CORE_API gr_annotator_1to1 : public gr_sync_block -{ - public: - ~gr_annotator_1to1 (); - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - std::vector<gr_tag_t> data() const - { - return d_stored_tags; - } - -protected: - gr_annotator_1to1 (int when, size_t sizeof_stream_item); - - private: - size_t d_itemsize; - uint64_t d_when; - uint64_t d_tag_counter; - std::vector<gr_tag_t> d_stored_tags; - - friend GR_CORE_API gr_annotator_1to1_sptr - gr_make_annotator_1to1 (int when, size_t sizeof_stream_item); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.i b/gnuradio-core/src/lib/general/gr_annotator_1to1.i deleted file mode 100644 index 2637b8d277..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.i +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,annotator_1to1); - -%include <gr_annotator_1to1.h> diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc deleted file mode 100644 index d8b7e2db7e..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc +++ /dev/null @@ -1,110 +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_annotator_alltoall.h> -#include <gr_io_signature.h> -#include <string.h> -#include <iostream> -#include <iomanip> - -gr_annotator_alltoall_sptr -gr_make_annotator_alltoall (int when, size_t sizeof_stream_item) -{ - return gnuradio::get_initial_sptr (new gr_annotator_alltoall - (when, sizeof_stream_item)); -} - -gr_annotator_alltoall::gr_annotator_alltoall (int when, - size_t sizeof_stream_item) - : gr_sync_block ("annotator_alltoall", - gr_make_io_signature (1, -1, sizeof_stream_item), - gr_make_io_signature (1, -1, sizeof_stream_item)), - d_itemsize(sizeof_stream_item), d_when((uint64_t)when) -{ - set_tag_propagation_policy(TPP_ALL_TO_ALL); - - d_tag_counter = 0; -} - -gr_annotator_alltoall::~gr_annotator_alltoall () -{ -} - -int -gr_annotator_alltoall::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]; - - std::stringstream str; - str << name() << unique_id(); - - uint64_t abs_N = 0, end_N; - int ninputs = input_items.size(); - for(int i = 0; i < ninputs; i++) { - abs_N = nitems_read(i); - end_N = abs_N + (uint64_t)(noutput_items); - - std::vector<gr_tag_t> all_tags; - get_tags_in_range(all_tags, i, abs_N, end_N); - - std::vector<gr_tag_t>::iterator itr; - for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { - d_stored_tags.push_back(*itr); - } - } - - // Source ID and key for any tag that might get applied from this block - 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 - abs_N = nitems_written(0); - int noutputs = output_items.size(); - - 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::from_uint64(d_tag_counter++); - add_item_tag(i, abs_N, key, value, srcid); - } - - // Sum all of the inputs together for each output. Just 'cause. - out = (float*)output_items[i]; - out[j] = 0; - for(int ins = 0; ins < ninputs; ins++) { - in = (const float*)input_items[ins]; - out[j] += in[j]; - } - } - abs_N++; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h deleted file mode 100644 index deb5874a49..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h +++ /dev/null @@ -1,76 +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_ANNOTATOR_ALLTOALL_H -#define INCLUDED_GR_ANNOTATOR_ALLTOALL_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_annotator_alltoall; -typedef boost::shared_ptr<gr_annotator_alltoall> gr_annotator_alltoall_sptr; - -// public constructor -GR_CORE_API gr_annotator_alltoall_sptr -gr_make_annotator_alltoall (int when, size_t sizeof_stream_item); - -/*! - * \brief All-to-all stream annotator testing block. FOR TESTING PURPOSES ONLY. - * - * This block creates tags to be sent downstream every 10,000 items it sees. The - * tags contain the name and ID of the instantiated block, use "seq" as a key, - * and have a counter that increments by 1 for every tag produced that is used - * as the tag's value. The tags are propagated using the all-to-all policy. - * - * It also stores a copy of all tags it sees flow past it. These tags can be - * recalled externally with the data() member. - * - * This block is only meant for testing and showing how to use the tags. - */ -class GR_CORE_API gr_annotator_alltoall : public gr_sync_block -{ - public: - ~gr_annotator_alltoall (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - std::vector<gr_tag_t> data() const - { - return d_stored_tags; - } - -protected: - gr_annotator_alltoall (int when, size_t sizeof_stream_item); - - private: - size_t d_itemsize; - uint64_t d_when; - uint64_t d_tag_counter; - std::vector<gr_tag_t> d_stored_tags; - - friend GR_CORE_API gr_annotator_alltoall_sptr - gr_make_annotator_alltoall (int when, size_t sizeof_stream_item); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i deleted file mode 100644 index 35190a3d1b..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,annotator_alltoall); - -%include <gr_annotator_alltoall.h> diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.cc b/gnuradio-core/src/lib/general/gr_annotator_raw.cc deleted file mode 100644 index c3aecdd938..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_raw.cc +++ /dev/null @@ -1,106 +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_annotator_raw.h> -#include <gr_io_signature.h> -#include <string.h> -#include <iostream> -#include <iomanip> -#include <stdexcept> - -using namespace pmt; - -gr_annotator_raw_sptr -gr_make_annotator_raw(size_t sizeof_stream_item) -{ - return gnuradio::get_initial_sptr(new gr_annotator_raw - (sizeof_stream_item)); -} - -gr_annotator_raw::gr_annotator_raw(size_t sizeof_stream_item) - : gr_sync_block("annotator_raw", - gr_make_io_signature(1, 1, sizeof_stream_item), - gr_make_io_signature(1, 1, sizeof_stream_item)), - d_itemsize(sizeof_stream_item) -{ - set_tag_propagation_policy(TPP_ONE_TO_ONE); - set_relative_rate(1.0); -} - -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::intern(name()); - tag.key = key; - tag.value = val; - tag.offset = offset; - - // add our new tag - d_queued_tags.push_back(tag); - // make sure our tags are in offset order - std::sort(d_queued_tags.begin(), d_queued_tags.end(), - gr_tag_t::offset_compare); - // make sure we are not adding an item in the past! - if(tag.offset > nitems_read(0)) { - throw std::runtime_error("gr_annotator_raw::add_tag: item added too far in the past\n."); - } -} - -gr_annotator_raw::~gr_annotator_raw() -{ -} - -int -gr_annotator_raw::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gruel::scoped_lock l(d_mutex); - - const char *in = (const char*)input_items[0]; - char *out = (char*)output_items[0]; - - uint64_t start_N = nitems_read(0); - uint64_t end_N = start_N + (uint64_t)(noutput_items); - - // locate queued tags that fall in this range and insert them when appropriate - std::vector<gr_tag_t>::iterator i = d_queued_tags.begin(); - while( i != d_queued_tags.end() ) { - if( (*i).offset >= start_N && (*i).offset < end_N) { - add_item_tag(0, (*i).offset,(*i).key, (*i).value, (*i).srcid); - i = d_queued_tags.erase(i); - } - else { - break; - } - } - - // copy data across - memcpy(out, in, noutput_items*d_itemsize); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.h b/gnuradio-core/src/lib/general/gr_annotator_raw.h deleted file mode 100644 index 02d0619081..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_raw.h +++ /dev/null @@ -1,69 +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_ANNOTATOR_RAW_H -#define INCLUDED_GR_ANNOTATOR_RAW_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_tags.h> -#include <gruel/thread.h> - -class gr_annotator_raw; -typedef boost::shared_ptr<gr_annotator_raw> gr_annotator_raw_sptr; - -// public constructor -GR_CORE_API gr_annotator_raw_sptr -gr_make_annotator_raw(size_t sizeof_stream_item); - -/*! - * \brief raw stream annotator testing block. - * - * This block creates arbitrary tags to be sent downstream - * blocks to be sent are set manually via accessor methods and are sent only once. - * - * This block is intended for testing of tag related blocks - */ -class GR_CORE_API gr_annotator_raw : public gr_sync_block -{ - public: - ~gr_annotator_raw(); - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - // insert a tag to be added - void add_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t val); - -protected: - gr_annotator_raw(size_t sizeof_stream_item); - - private: - size_t d_itemsize; - std::vector<gr_tag_t> d_queued_tags; - gruel::mutex d_mutex; - - friend GR_CORE_API gr_annotator_raw_sptr - gr_make_annotator_raw(size_t sizeof_stream_item); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.i b/gnuradio-core/src/lib/general/gr_annotator_raw.i deleted file mode 100644 index 4a58fe7c79..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_raw.i +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,annotator_raw); - -%include <gr_tags.i> -%include <gr_annotator_raw.h> diff --git a/gnuradio-core/src/lib/general/gr_check_counting_s.cc b/gnuradio-core/src/lib/general/gr_check_counting_s.cc deleted file mode 100644 index c3288f4813..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_counting_s.cc +++ /dev/null @@ -1,190 +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_check_counting_s.h> -#include <gr_io_signature.h> -#include <stdlib.h> -#include <stdio.h> - -gr_check_counting_s_sptr -gr_make_check_counting_s (bool do_32bit) -{ - return gnuradio::get_initial_sptr(new gr_check_counting_s (do_32bit)); -} - -gr_check_counting_s::gr_check_counting_s (bool do_32bit) - : gr_sync_block ("gr_check_counting", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (0, 0, 0)), - d_state(SEARCHING), d_history (0), d_current_count (0), d_current_count_32bit(0), - d_total_errors (0), d_total_shorts (0), - d_do_32bit(do_32bit) -{ - enter_SEARCHING (); -} - -int -gr_check_counting_s::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - unsigned short *in = (unsigned short *) input_items[0]; - if(d_do_32bit) - return check_32bit(noutput_items,in); - else - return check_16bit(noutput_items,in); -} - -int -gr_check_counting_s::check_16bit (int noutput_items, - unsigned short * in) -{ - for (int i = 0; i < noutput_items; i++){ - unsigned short x = in[i]; - - switch (d_state){ - - case SEARCHING: - if (x == d_current_count){ - right (); - log_error (d_current_count, x); - d_current_count = d_current_count + 1; - if (right_three_times ()) - enter_LOCKED (); - } - else { - wrong (); - log_error (d_current_count, x); - d_current_count = x + 1; - } - break; - - case LOCKED: - if (x == d_current_count){ - right (); - d_current_count = d_current_count + 1; - } - else { - wrong (); - log_error (d_current_count, x); - d_current_count = d_current_count + 1; - if (wrong_three_times ()) - enter_SEARCHING (); - } - break; - - default: - abort (); - } - - d_total_shorts++; - } - - return noutput_items; -} - -int -gr_check_counting_s::check_32bit (int noutput_items, - unsigned short * in) -{ - - for (int i = 0; i < noutput_items-1; i+=2){ - unsigned int x_high16bits = in[i]; - unsigned int x_low16bits = in[i+1]; - unsigned int x = x_high16bits<<16 | x_low16bits; - - switch (d_state){ - - case SEARCHING: - if (x == d_current_count_32bit){ - right (); - log_error_32bit (d_current_count_32bit, x); - d_current_count_32bit = d_current_count_32bit + 1; - if (right_three_times ()) - enter_LOCKED (); - } - else { - wrong (); - log_error_32bit (d_current_count_32bit, x); - d_current_count_32bit = x + 1; - } - break; - - case LOCKED: - if (x == d_current_count_32bit){ - right (); - d_current_count_32bit = d_current_count_32bit + 1; - } - else { - wrong (); - log_error_32bit (d_current_count_32bit, x); - d_current_count_32bit = d_current_count_32bit + 1; - if (wrong_three_times ()) - enter_SEARCHING (); - } - break; - - default: - abort (); - } - - d_total_shorts++; - } - - return noutput_items; -} - -void -gr_check_counting_s::enter_SEARCHING () -{ - d_state = SEARCHING; - fprintf (stdout, "gr_check_counting: enter_SEARCHING at offset %8ld (0x%08lx)\n", - d_total_shorts, d_total_shorts); -} - -void -gr_check_counting_s::enter_LOCKED () -{ - d_state = LOCKED; - fprintf (stdout, "gr_check_counting: enter_LOCKED at offset %8ld (0x%08lx)\n", - d_total_shorts, d_total_shorts); -} - -void -gr_check_counting_s::log_error (unsigned short expected, unsigned short actual) -{ - fprintf (stdout, -"gr_check_counting: expected %5d (0x%04x) got %5d (0x%04x) offset %8ld (0x%08lx)\n", - expected, expected, actual, actual, d_total_shorts, d_total_shorts); -} - -void -gr_check_counting_s::log_error_32bit (unsigned int expected, unsigned int actual) -{ - fprintf (stdout, -"gr_check_counting: expected %10d (0x%08x) got %10d (0x%08x) offset %8ld (0x%08lx)\n", - expected, expected, actual, actual, d_total_shorts, d_total_shorts); -} diff --git a/gnuradio-core/src/lib/general/gr_check_counting_s.h b/gnuradio-core/src/lib/general/gr_check_counting_s.h deleted file mode 100644 index 996fa3259f..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_counting_s.h +++ /dev/null @@ -1,89 +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_CHECK_COUNTING_S_H -#define INCLUDED_GR_CHECK_COUNTING_S_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_check_counting_s; -typedef boost::shared_ptr<gr_check_counting_s> gr_check_counting_s_sptr; - -GR_CORE_API gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit=false); - -/*! - * \brief sink that checks if its input stream consists of a counting sequence. - * \param do_32bit expect an interleaved 32 bit counter in stead of 16 bit counter (default false) - * \ingroup sink_blk - * - * This sink is typically used to test the USRP "Counting Mode" or "Counting mode 32 bit". - */ -class GR_CORE_API gr_check_counting_s : public gr_sync_block -{ - friend GR_CORE_API gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit); - - enum state { - SEARCHING, // searching for synchronization - LOCKED // is locked - }; - - state d_state; - unsigned int d_history; // bitmask of decisions - unsigned short d_current_count; - unsigned int d_current_count_32bit; - - long d_total_errors; - long d_total_shorts; - bool d_do_32bit; - - gr_check_counting_s (bool do_32bit); - - void enter_SEARCHING (); - void enter_LOCKED (); - - void right (){ - d_history = (d_history << 1) | 0x1; - } - - void wrong (){ - d_history = (d_history << 1) | 0x0; - d_total_errors++; - } - - bool right_three_times () { return (d_history & 0x7) == 0x7; } - bool wrong_three_times () { return (d_history & 0x7) == 0x0; } - - void log_error (unsigned short expected, unsigned short actual); - void log_error_32bit (unsigned int expected, unsigned int actual); - - int check_32bit (int noutput_items, unsigned short * in); - int check_16bit (int noutput_items, unsigned short * in); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_CHECK_COUNTING_S_H */ diff --git a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.cc b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.cc deleted file mode 100644 index 088b8c38ae..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.cc +++ /dev/null @@ -1,169 +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_check_lfsr_32k_s.h> -#include <gr_io_signature.h> -#include <stdlib.h> -#include <stdio.h> - -gr_check_lfsr_32k_s_sptr -gr_make_check_lfsr_32k_s () -{ - return gnuradio::get_initial_sptr(new gr_check_lfsr_32k_s ()); -} - -gr_check_lfsr_32k_s::gr_check_lfsr_32k_s () - : gr_sync_block ("gr_check_lfsr_32k", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (0, 0, 0)), - d_state(SEARCHING), d_history (0), d_ntotal (0), d_nright (0), - d_runlength (0), d_index(0) -{ - gri_lfsr_32k lfsr; - - for (int i = 0; i < BUFSIZE; i++) - d_buffer[i] = lfsr.next_short (); - - enter_SEARCHING (); -} - -int -gr_check_lfsr_32k_s::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - unsigned short *in = (unsigned short *) input_items[0]; - - for (int i = 0; i < noutput_items; i++){ - unsigned short x = in[i]; - unsigned short expected; - - switch (d_state){ - - case MATCH0: - if (x == d_buffer[0]) - enter_MATCH1 (); - break; - - case MATCH1: - if (x == d_buffer[1]) - enter_MATCH2 (); - else - enter_MATCH0 (); - break; - - case MATCH2: - if (x == d_buffer[2]) - enter_LOCKED (); - else - enter_MATCH0 (); - break; - - case LOCKED: - expected = d_buffer[d_index]; - d_index = d_index + 1; - if (d_index >= BUFSIZE) - d_index = 0; - - if (x == expected) - right (); - else { - wrong (); - log_error (expected, x); - if (wrong_three_times ()) - enter_SEARCHING (); - } - break; - - default: - abort (); - } - - d_ntotal++; - } - - return noutput_items; -} - -void -gr_check_lfsr_32k_s::enter_SEARCHING () -{ - d_state = SEARCHING; - wrong (); // reset history - wrong (); - wrong (); - - d_runlength = 0; - d_index = 0; // reset LFSR to beginning - - if (0) - fprintf (stdout, "gr_check_lfsr_32k: enter_SEARCHING at offset %8ld (0x%08lx)\n", - d_ntotal, d_ntotal); - - enter_MATCH0 (); -} - -void -gr_check_lfsr_32k_s::enter_MATCH0 () -{ - d_state = MATCH0; -} - -void -gr_check_lfsr_32k_s::enter_MATCH1 () -{ - d_state = MATCH1; -} - -void -gr_check_lfsr_32k_s::enter_MATCH2 () -{ - d_state = MATCH2; -} - -void -gr_check_lfsr_32k_s::enter_LOCKED () -{ - d_state = LOCKED; - right (); // setup history - right (); - right (); - - d_index = 3; // already matched first 3 items - - if (0) - fprintf (stdout, "gr_check_lfsr_32k: enter_LOCKED at offset %8ld (0x%08lx)\n", - d_ntotal, d_ntotal); -} - -void -gr_check_lfsr_32k_s::log_error (unsigned short expected, unsigned short actual) -{ - if (0) - fprintf (stdout, - "gr_check_lfsr_32k: expected %5d (0x%04x) got %5d (0x%04x) offset %8ld (0x%08lx)\n", - expected, expected, actual, actual, d_ntotal, d_ntotal); -} diff --git a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h deleted file mode 100644 index 2f980b427b..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h +++ /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. - */ -#ifndef INCLUDED_GR_CHECK_LFSR_32K_S_H -#define INCLUDED_GR_CHECK_LFSR_32K_S_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_lfsr_32k.h> - - -class gr_check_lfsr_32k_s; -typedef boost::shared_ptr<gr_check_lfsr_32k_s> gr_check_lfsr_32k_s_sptr; - -GR_CORE_API gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); - -/*! - * \brief sink that checks if its input stream consists of a lfsr_32k sequence. - * \ingroup sink_blk - * - * This sink is typically used along with gr_lfsr_32k_source_s to test - * the USRP using its digital loopback mode. - */ -class GR_CORE_API gr_check_lfsr_32k_s : public gr_sync_block -{ - friend GR_CORE_API gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); - - enum state { - SEARCHING, // searching for synchronization - MATCH0, - MATCH1, - MATCH2, - LOCKED // is locked - }; - - state d_state; - unsigned int d_history; // bitmask of decisions - - long d_ntotal; // total number of shorts - long d_nright; // # of correct shorts - long d_runlength; // # of correct shorts in a row - - static const int BUFSIZE = 2048 - 1; // ensure pattern isn't packet aligned - int d_index; - unsigned short d_buffer[BUFSIZE]; - - - gr_check_lfsr_32k_s (); - - void enter_SEARCHING (); - void enter_MATCH0 (); - void enter_MATCH1 (); - void enter_MATCH2 (); - void enter_LOCKED (); - - void right (){ - d_history = (d_history << 1) | 0x1; - d_nright++; - d_runlength++; - } - - void wrong (){ - d_history = (d_history << 1) | 0x0; - d_runlength = 0; - } - - bool right_three_times () { return (d_history & 0x7) == 0x7; } - bool wrong_three_times () { return (d_history & 0x7) == 0x0; } - - void log_error (unsigned short expected, unsigned short actual); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - long ntotal () const { return d_ntotal; } - long nright () const { return d_nright; } - long runlength () const { return d_runlength; } - -}; - - -#endif /* INCLUDED_GR_CHECK_LFSR_32K_S_H */ diff --git a/gnuradio-core/src/lib/general/gr_copy.cc b/gnuradio-core/src/lib/general/gr_copy.cc deleted file mode 100644 index 0a6f721f94..0000000000 --- a/gnuradio-core/src/lib/general/gr_copy.cc +++ /dev/null @@ -1,71 +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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_copy.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_copy_sptr -gr_make_copy(size_t itemsize) -{ - return gnuradio::get_initial_sptr(new gr_copy(itemsize)); -} - -gr_copy::gr_copy(size_t itemsize) - : gr_block ("copy", - gr_make_io_signature (1, 1, itemsize), - gr_make_io_signature (1, 1, itemsize)), - d_itemsize(itemsize), - d_enabled(true) -{ -} - -bool -gr_copy::check_topology(int ninputs, int noutputs) -{ - return ninputs == noutputs; -} - -int -gr_copy::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const uint8_t *in = (const uint8_t *) input_items[0]; - uint8_t *out = (uint8_t *) output_items[0]; - - int n = std::min<int>(ninput_items[0], noutput_items); - int j = 0; - - if (d_enabled) { - memcpy(out, in, n*d_itemsize); - j = n; - } - - consume_each(n); - return j; -} diff --git a/gnuradio-core/src/lib/general/gr_copy.h b/gnuradio-core/src/lib/general/gr_copy.h deleted file mode 100644 index b0769fa2b1..0000000000 --- a/gnuradio-core/src/lib/general/gr_copy.h +++ /dev/null @@ -1,63 +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. - */ - -#ifndef INCLUDED_GR_COPY_H -#define INCLUDED_GR_COPY_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_copy; -typedef boost::shared_ptr<gr_copy> gr_copy_sptr; - -GR_CORE_API gr_copy_sptr gr_make_copy(size_t itemsize); - -/*! - * \brief output[i] = input[i] - * \ingroup misc_blk - * - * When enabled (default), this block copies its input to its output. - * When disabled, this block drops its input on the floor. - * - */ -class GR_CORE_API gr_copy : public gr_block -{ - size_t d_itemsize; - bool d_enabled; - - friend GR_CORE_API gr_copy_sptr gr_make_copy(size_t itemsize); - gr_copy(size_t itemsize); - - public: - - bool check_topology(int ninputs, int noutputs); - - void set_enabled(bool enable) { d_enabled = enable; } - bool enabled() const { return d_enabled;} - - 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_ctrlport_probe2_c.cc b/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.cc deleted file mode 100644 index ca6667a214..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.cc +++ /dev/null @@ -1,156 +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_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 deleted file mode 100644 index 0920c0f4e8..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.h +++ /dev/null @@ -1,72 +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_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_ctrlport_probe_c.cc b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.cc deleted file mode 100644 index 253d4c380e..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.cc +++ /dev/null @@ -1,96 +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_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_ctrlport_probe_c.h b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.h deleted file mode 100644 index 27666ab597..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.h +++ /dev/null @@ -1,65 +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_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 gr_ctrlport_probe_c; -typedef boost::shared_ptr<gr_ctrlport_probe_c> gr_ctrlport_probe_c_sptr; - -GR_CORE_API gr_ctrlport_probe_c_sptr -gr_make_ctrlport_probe_c(const std::string &id, const std::string &desc); - -class GR_CORE_API gr_ctrlport_probe_c : public gr_sync_block -{ - private: - friend GR_CORE_API gr_ctrlport_probe_c_sptr gr_make_ctrlport_probe_c - (const std::string &id, const std::string &desc); - - gr_ctrlport_probe_c(const std::string &id, const std::string &desc); - - boost::shared_mutex ptrlock; - - 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(); - - std::vector<gr_complex> get(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_CTRLPORT_GR_CTRLPORT_PROBE_C_H */ - diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.i b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.i deleted file mode 100644 index cd4c521cb0..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.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,ctrlport_probe_c) - -gr_ctrlport_probe_c_sptr -gr_make_ctrlport_probe_c(const std::string &id, const std::string &desc); - -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_endian_swap.cc b/gnuradio-core/src/lib/general/gr_endian_swap.cc deleted file mode 100644 index 8bea0ca30d..0000000000 --- a/gnuradio-core/src/lib/general/gr_endian_swap.cc +++ /dev/null @@ -1,101 +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_endian_swap.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_endian_swap_sptr -gr_make_endian_swap (size_t item_size_bytes) -{ - return gnuradio::get_initial_sptr(new gr_endian_swap (item_size_bytes)); -} - -gr_endian_swap::gr_endian_swap (size_t item_size_bytes) - : gr_sync_block ("gr_endian_swap", - gr_make_io_signature (1, 1, item_size_bytes), - gr_make_io_signature (1, 1, item_size_bytes)) -{ - const int alignment_multiple = volk_get_alignment(); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_endian_swap::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]; - - int nbytes( output_signature()->sizeof_stream_item(0) ); - if(is_unaligned()) { - switch(nbytes){ - case 1: - memcpy(out,in,noutput_items); - break; - case 2: - memcpy(out,in,2*noutput_items); - volk_16u_byteswap_u((uint16_t*)out,noutput_items); - break; - case 4: - memcpy(out,in,4*noutput_items); - volk_32u_byteswap_u((uint32_t*)out,noutput_items); - break; - case 8: - memcpy(out,in,8*noutput_items); - volk_64u_byteswap_u((uint64_t*)out,noutput_items); - break; - default: - throw std::runtime_error("itemsize is not valid for gr_endian_swap!"); - } - } else { - switch(nbytes){ - case 1: - memcpy(out,in,noutput_items); - break; - case 2: - memcpy(out,in,2*noutput_items); - volk_16u_byteswap_a((uint16_t*)out,noutput_items); - break; - case 4: - memcpy(out,in,4*noutput_items); - volk_32u_byteswap_a((uint32_t*)out,noutput_items); - break; - case 8: - memcpy(out,in,8*noutput_items); - volk_64u_byteswap_a((uint64_t*)out,noutput_items); - break; - default: - throw std::runtime_error("itemsize is not valid for gr_endian_swap!"); - } - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_endian_swap.h b/gnuradio-core/src/lib/general/gr_endian_swap.h deleted file mode 100644 index 0baa3f3389..0000000000 --- a/gnuradio-core/src/lib/general/gr_endian_swap.h +++ /dev/null @@ -1,57 +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_ENDIAN_SWAP_H -#define INCLUDED_GR_ENDIAN_SWAP_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_endian_swap; -typedef boost::shared_ptr<gr_endian_swap> gr_endian_swap_sptr; - -GR_CORE_API gr_endian_swap_sptr -gr_make_endian_swap (size_t item_size_bytes=1); - -/*! - * \brief Convert stream of items into thier byte swapped version - * - * \param item_size_bytes number of bytes per item, 1=no-op,2=uint16_t,4=uint32_t,8=uint64_t - */ - -class GR_CORE_API gr_endian_swap : public gr_sync_block -{ - private: - friend GR_CORE_API gr_endian_swap_sptr - gr_make_endian_swap (size_t item_size_bytes); - gr_endian_swap (size_t item_size_bytes); - - size_t item_size_bytes; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_ENDIAN_SWAP_H */ diff --git a/gnuradio-core/src/lib/general/gr_endian_swap.i b/gnuradio-core/src/lib/general/gr_endian_swap.i deleted file mode 100644 index 6058b9de77..0000000000 --- a/gnuradio-core/src/lib/general/gr_endian_swap.i +++ /dev/null @@ -1,31 +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,endian_swap) - -gr_endian_swap_sptr -gr_make_endian_swap (size_t bytes_per_item=1); - -class gr_endian_swap : public gr_sync_block -{ -public: -}; diff --git a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.i b/gnuradio-core/src/lib/general/gr_endianness.h index c2dc1c61b7..c4ecb1383e 100644 --- a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.i +++ b/gnuradio-core/src/lib/general/gr_endianness.h @@ -19,13 +19,9 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ +#ifndef INCLUDED_GR_ENDIANNESS_H +#define INCLUDED_GR_ENDIANNESS_H -GR_SWIG_BLOCK_MAGIC(gr,lfsr_32k_source_s); +typedef enum {GR_MSB_FIRST, GR_LSB_FIRST} gr_endianness_t; -gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); - -class gr_lfsr_32k_source_s : public gr_sync_block -{ - private: - gr_lfsr_32k_source_s (); -}; +#endif /* INCLUDED_GR_ENDIANNESS_H */ diff --git a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.cc b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.cc deleted file mode 100644 index c1c3883c56..0000000000 --- a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.cc +++ /dev/null @@ -1,113 +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_fake_channel_coder_pp.h> -#include <gr_io_signature.h> -#include <string.h> -#include <stdexcept> -#include <string.h> - -static const int PAD_VAL = 0xAA; - -gr_fake_channel_encoder_pp_sptr -gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen) -{ - return gnuradio::get_initial_sptr(new gr_fake_channel_encoder_pp(input_vlen, - output_vlen)); -} - -gr_fake_channel_encoder_pp::gr_fake_channel_encoder_pp(int input_vlen, int output_vlen) - : gr_sync_block("fake_channel_encoder_pp", - gr_make_io_signature(1, 1, input_vlen * sizeof(unsigned char)), - gr_make_io_signature(1, 1, output_vlen * sizeof(unsigned char))), - d_input_vlen(input_vlen), d_output_vlen(output_vlen) -{ - if (input_vlen <= 0 || output_vlen <= 0 || input_vlen > output_vlen) - throw std::invalid_argument("gr_fake_channel_encoder_pp"); -} - -gr_fake_channel_encoder_pp::~gr_fake_channel_encoder_pp() -{ -} - -int -gr_fake_channel_encoder_pp::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 npad = d_output_vlen - d_input_vlen; - - for (int i = 0; i < noutput_items; i++){ - memcpy(out, in, d_input_vlen); - memset(out + d_input_vlen, PAD_VAL, npad); - in += d_input_vlen; - out += d_output_vlen; - } - - return noutput_items; -} - -// ------------------------------------------------------------------------ - -gr_fake_channel_decoder_pp_sptr -gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen) -{ - return gnuradio::get_initial_sptr(new gr_fake_channel_decoder_pp(input_vlen, - output_vlen)); -} - -gr_fake_channel_decoder_pp::gr_fake_channel_decoder_pp(int input_vlen, int output_vlen) - : gr_sync_block("fake_channel_decoder_pp", - gr_make_io_signature(1, 1, input_vlen * sizeof(unsigned char)), - gr_make_io_signature(1, 1, output_vlen * sizeof(unsigned char))), - d_input_vlen(input_vlen), d_output_vlen(output_vlen) -{ - if (input_vlen <= 0 || output_vlen <= 0 || output_vlen > input_vlen) - throw std::invalid_argument("gr_fake_channel_decoder_pp"); -} - -gr_fake_channel_decoder_pp::~gr_fake_channel_decoder_pp() -{ -} - -int -gr_fake_channel_decoder_pp::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++){ - memcpy(out, in, d_output_vlen); - in += d_input_vlen; - out += d_output_vlen; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h deleted file mode 100644 index 45808752d3..0000000000 --- a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h +++ /dev/null @@ -1,91 +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_FAKE_CHANNEL_CODER_PP_H -#define INCLUDED_GR_FAKE_CHANNEL_CODER_PP_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_fake_channel_encoder_pp; -typedef boost::shared_ptr<gr_fake_channel_encoder_pp> gr_fake_channel_encoder_pp_sptr; - -GR_CORE_API gr_fake_channel_encoder_pp_sptr -gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen); - -/*! - * \brief pad packet with alternating 1,0 pattern. - * \ingroup coding_blk - * - * input: stream of byte vectors; output: stream of byte vectors - */ -class GR_CORE_API gr_fake_channel_encoder_pp : public gr_sync_block -{ - int d_input_vlen; - int d_output_vlen; - - gr_fake_channel_encoder_pp(int input_vlen, int output_vlen); - - friend GR_CORE_API gr_fake_channel_encoder_pp_sptr - gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen); - -public: - ~gr_fake_channel_encoder_pp(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -// ------------------------------------------------------------------------ - -class gr_fake_channel_decoder_pp; -typedef boost::shared_ptr<gr_fake_channel_decoder_pp> gr_fake_channel_decoder_pp_sptr; - -GR_CORE_API gr_fake_channel_decoder_pp_sptr -gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen); - -/*! - * \brief remove fake padding from packet - * \ingroup coding_blk - * - * input: stream of byte vectors; output: stream of byte vectors - */ -class GR_CORE_API gr_fake_channel_decoder_pp : public gr_sync_block -{ - int d_input_vlen; - int d_output_vlen; - - gr_fake_channel_decoder_pp(int input_vlen, int output_vlen); - - friend GR_CORE_API gr_fake_channel_decoder_pp_sptr - gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen); - -public: - ~gr_fake_channel_decoder_pp(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FAKE_CHANNEL_CODER_PP_H */ diff --git a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.i b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.i deleted file mode 100644 index 123c84e473..0000000000 --- a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.i +++ /dev/null @@ -1,53 +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,fake_channel_encoder_pp) - -gr_fake_channel_encoder_pp_sptr -gr_make_fake_channel_encoder_pp(int input_vlen, - int output_vlen - ) throw(std::invalid_argument); - -class gr_fake_channel_encoder_pp : public gr_sync_block -{ - gr_fake_channel_encoder_pp(int input_vlen, int output_vlen); - -public: - ~gr_fake_channel_encoder_pp(); -}; - -// ------------------------------------------------------------------------ - -GR_SWIG_BLOCK_MAGIC(gr,fake_channel_decoder_pp) - -gr_fake_channel_decoder_pp_sptr -gr_make_fake_channel_decoder_pp(int input_vlen, - int output_vlen - ) throw(std::invalid_argument); - -class gr_fake_channel_decoder_pp : public gr_sync_block -{ - gr_fake_channel_decoder_pp(int input_vlen, int output_vlen); - -public: - ~gr_fake_channel_decoder_pp(); -}; diff --git a/gnuradio-core/src/lib/general/gr_check_counting_s.i b/gnuradio-core/src/lib/general/gr_fxpt.cc index 0275dad9db..2ea8520e6b 100644 --- a/gnuradio-core/src/lib/general/gr_check_counting_s.i +++ b/gnuradio-core/src/lib/general/gr_fxpt.cc @@ -20,12 +20,16 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,check_counting_s) +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit=false); +#include <gr_fxpt.h> -class gr_check_counting_s : public gr_sync_block -{ - private: - gr_check_counting_s (bool do_32bit); +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 new file mode 100644 index 0000000000..9de6c0c18a --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_fxpt.h @@ -0,0 +1,104 @@ +/* -*- 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 new file mode 100644 index 0000000000..9defa083da --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_fxpt_nco.h @@ -0,0 +1,153 @@ +/* -*- 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 new file mode 100644 index 0000000000..13be2526bd --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_fxpt_vco.h @@ -0,0 +1,73 @@ +/* -*- 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_head.cc b/gnuradio-core/src/lib/general/gr_head.cc deleted file mode 100644 index 1726888113..0000000000 --- a/gnuradio-core/src/lib/general/gr_head.cc +++ /dev/null @@ -1,62 +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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#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", - gr_make_io_signature (1, 1, sizeof_stream_item), - gr_make_io_signature (1, 1, sizeof_stream_item)), - d_nitems (nitems), d_ncopied_items (0) -{ -} - -gr_head_sptr -gr_make_head (size_t sizeof_stream_item, unsigned long long nitems) -{ - return gnuradio::get_initial_sptr(new gr_head (sizeof_stream_item, nitems)); -} - -int -gr_head::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - if (d_ncopied_items >= d_nitems) - return -1; // Done! - - unsigned n = std::min (d_nitems - d_ncopied_items, (unsigned long long) noutput_items); - - if (n == 0) - return 0; - - memcpy (output_items[0], input_items[0], n * input_signature()->sizeof_stream_item (0)); - d_ncopied_items += n; - - return n; -} diff --git a/gnuradio-core/src/lib/general/gr_head.h b/gnuradio-core/src/lib/general/gr_head.h deleted file mode 100644 index 48415892dd..0000000000 --- a/gnuradio-core/src/lib/general/gr_head.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2009,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_HEAD_H -#define INCLUDED_GR_HEAD_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <stddef.h> // size_t - -class gr_head; -typedef boost::shared_ptr<gr_head> gr_head_sptr; - -/*! - * \brief copies the first N items to the output then signals done - * \ingroup slicedice_blk - * - * Useful for building test cases - */ - -class GR_CORE_API gr_head : public gr_sync_block -{ - friend GR_CORE_API gr_head_sptr gr_make_head (size_t sizeof_stream_item, unsigned long long nitems); - gr_head (size_t sizeof_stream_item, unsigned long long nitems); - - unsigned long long d_nitems; - unsigned long long d_ncopied_items; - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void reset() { d_ncopied_items = 0; } - void set_length(int nitems) { d_nitems = nitems; } -}; - -GR_CORE_API gr_head_sptr -gr_make_head (size_t sizeof_stream_item, unsigned long long nitems); - - -#endif /* INCLUDED_GR_HEAD_H */ diff --git a/gnuradio-core/src/lib/general/gr_head.i b/gnuradio-core/src/lib/general/gr_head.i deleted file mode 100644 index 11f3331d47..0000000000 --- a/gnuradio-core/src/lib/general/gr_head.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2009,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,head); - -gr_head_sptr gr_make_head(size_t sizeof_stream_item, unsigned long long nitems); - -class gr_head : public gr_block { - gr_head(); -public: - void reset(); - void set_length(int nitems); -}; - diff --git a/gnuradio-core/src/lib/general/gr_iqcomp_cc.cc b/gnuradio-core/src/lib/general/gr_iqcomp_cc.cc deleted file mode 100644 index 599b25b728..0000000000 --- a/gnuradio-core/src/lib/general/gr_iqcomp_cc.cc +++ /dev/null @@ -1,62 +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_iqcomp_cc.h> -#include <gr_io_signature.h> - -gr_iqcomp_cc_sptr -gr_make_iqcomp_cc (float mu) -{ - return gnuradio::get_initial_sptr(new gr_iqcomp_cc (mu)); -} - -gr_iqcomp_cc::gr_iqcomp_cc (float mu) - : gr_sync_block ("iqcomp_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_mu (mu) -{ - d_wi=0.0; - d_wq=0.0; -} - -int -gr_iqcomp_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]; - - for(int i = 0 ; i < noutput_items ; i++) { - float i_out = iptr[i].real() - iptr[i].imag() * d_wq; - float q_out = iptr[i].imag() - iptr[i].real() * d_wi; - d_wi += d_mu * q_out * iptr[i].real(); - d_wq += d_mu * i_out * iptr[i].imag(); - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_iqcomp_cc.h b/gnuradio-core/src/lib/general/gr_iqcomp_cc.h deleted file mode 100644 index 2f5a44ebfb..0000000000 --- a/gnuradio-core/src/lib/general/gr_iqcomp_cc.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef INCLUDED_GR_IQCOMP_CC_H -#define INCLUDED_GR_IQCOMP_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_iqcomp_cc; -typedef boost::shared_ptr<gr_iqcomp_cc> gr_iqcomp_cc_sptr; - -GR_CORE_API gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); - -/*! - * \brief - * \ingroup misc_blk - */ -class GR_CORE_API gr_iqcomp_cc : public gr_sync_block -{ - friend GR_CORE_API gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); - - float d_mu, d_wi, d_wq; - gr_iqcomp_cc (float mu); - - public: - float mu () const { return d_mu; } - void set_mu (float mu) { d_mu = mu; } - - 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_kludge_copy.cc b/gnuradio-core/src/lib/general/gr_kludge_copy.cc deleted file mode 100644 index f6a8d8af68..0000000000 --- a/gnuradio-core/src/lib/general/gr_kludge_copy.cc +++ /dev/null @@ -1,64 +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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_kludge_copy.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_kludge_copy_sptr -gr_make_kludge_copy(size_t itemsize) -{ - return gnuradio::get_initial_sptr(new gr_kludge_copy(itemsize)); -} - -gr_kludge_copy::gr_kludge_copy(size_t itemsize) - : gr_sync_block ("kludge_copy", - gr_make_io_signature (1, -1, itemsize), - gr_make_io_signature (1, -1, itemsize)), - d_itemsize(itemsize) -{ -} - -bool -gr_kludge_copy::check_topology(int ninputs, int noutputs) -{ - return ninputs == noutputs; -} - -int -gr_kludge_copy::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 ninputs = input_items.size(); - for (int i = 0; i < ninputs; i++){ - memcpy(out[i], in[i], noutput_items * d_itemsize); - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_kludge_copy.h b/gnuradio-core/src/lib/general/gr_kludge_copy.h deleted file mode 100644 index 0bcf144699..0000000000 --- a/gnuradio-core/src/lib/general/gr_kludge_copy.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_KLUDGE_COPY_H -#define INCLUDED_GR_KLUDGE_COPY_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_kludge_copy; -typedef boost::shared_ptr<gr_kludge_copy> gr_kludge_copy_sptr; - -GR_CORE_API gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); - -/*! - * \brief output[i] = input[i] - * \ingroup misc_blk - * - * This is a short term kludge to work around a problem with the hierarchical block impl. - */ -class GR_CORE_API gr_kludge_copy : public gr_sync_block -{ - size_t d_itemsize; - - friend GR_CORE_API gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); - gr_kludge_copy(size_t itemsize); - - public: - - bool check_topology(int ninputs, int noutputs); - - 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_kludge_copy.i b/gnuradio-core/src/lib/general/gr_kludge_copy.i deleted file mode 100644 index 7ff2b57365..0000000000 --- a/gnuradio-core/src/lib/general/gr_kludge_copy.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,kludge_copy) - -gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); - -class gr_kludge_copy : public gr_sync_block -{ - private: - gr_kludge_copy(size_t itemsize); -}; diff --git a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.cc b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.cc deleted file mode 100644 index c9a8742486..0000000000 --- a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.cc +++ /dev/null @@ -1,70 +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_lfsr_32k_source_s.h> -#include <gr_io_signature.h> -#include <stdexcept> - - -gr_lfsr_32k_source_s_sptr -gr_make_lfsr_32k_source_s () -{ - return gnuradio::get_initial_sptr(new gr_lfsr_32k_source_s ()); -} - - -gr_lfsr_32k_source_s::gr_lfsr_32k_source_s () - : gr_sync_block ("lfsr_32k_source_s", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof (short))), - d_index (0) -{ - gri_lfsr_32k lfsr; - - for (int i = 0; i < BUFSIZE; i++) - d_buffer[i] = lfsr.next_short (); -} - -int -gr_lfsr_32k_source_s::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - short *out = (short *) output_items[0]; - short *buf = d_buffer; - int index = d_index; - - for (int i = 0; i < noutput_items; i++){ - out[i] = buf[index]; - // index = (index + 1) & (BUFSIZE - 1); - index = index + 1; - if (index >= BUFSIZE) - index = 0; - } - - d_index = index; - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h deleted file mode 100644 index db107652ad..0000000000 --- a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.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_LFSR_32K_SOURCE_S_H -#define INCLUDED_GR_LFSR_32K_SOURCE_S_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_lfsr_32k.h> - -class gr_lfsr_32k_source_s; -typedef boost::shared_ptr<gr_lfsr_32k_source_s> gr_lfsr_32k_source_s_sptr; - -GR_CORE_API gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); - -/*! - * \brief LFSR pseudo-random source with period of 2^15 bits (2^11 shorts) - * \ingroup source_blk - * - * This source is typically used along with gr_check_lfsr_32k_s to test - * the USRP using its digital loopback mode. - */ -class GR_CORE_API gr_lfsr_32k_source_s : public gr_sync_block -{ - friend GR_CORE_API gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); - - - static const int BUFSIZE = 2048 - 1; // ensure pattern isn't packet aligned - int d_index; - short d_buffer[BUFSIZE]; - - gr_lfsr_32k_source_s (); - - public: - - 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/general/gr_nco.h b/gnuradio-core/src/lib/general/gr_nco.h new file mode 100644 index 0000000000..fb51106aab --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_nco.h @@ -0,0 +1,198 @@ +/* -*- 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_nop.cc b/gnuradio-core/src/lib/general/gr_nop.cc deleted file mode 100644 index 164f3ba8dd..0000000000 --- a/gnuradio-core/src/lib/general/gr_nop.cc +++ /dev/null @@ -1,92 +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_nop.h> -#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) -{ - return gnuradio::get_initial_sptr (new gr_nop (sizeof_stream_item)); -} - -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_ctrlport_test(0) -{ - // Arrange to have count_received_msgs called when messages are received. - message_port_register_in(pmt::mp("port")); - set_msg_handler(pmt::mp("port"), boost::bind(&gr_nop::count_received_msgs, this, _1)); -} - -// Trivial message handler that just counts them. -// (N.B., This feature is used in qa_set_msg_handler) -void -gr_nop::count_received_msgs(pmt::pmt_t msg) -{ - d_nmsgs_recvd++; -} - -int -gr_nop::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - // eat any input that's available - for (unsigned i = 0; i < ninput_items.size (); i++) - consume (i, ninput_items[i]); - - 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 deleted file mode 100644 index 5f1cb13a02..0000000000 --- a/gnuradio-core/src/lib/general/gr_nop.h +++ /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. - */ - -#ifndef INCLUDED_GR_NOP_H -#define INCLUDED_GR_NOP_H - -#include <gr_core_api.h> -#include <gr_block.h> -#include <stddef.h> // size_t - -class gr_nop; -typedef boost::shared_ptr<gr_nop> gr_nop_sptr; - -GR_CORE_API gr_nop_sptr -gr_make_nop (size_t sizeof_stream_item); - -/*! - * \brief Does nothing. Used for testing only. - * \ingroup misc_blk - */ -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); - - public: - virtual int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - 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 deleted file mode 100644 index 73ffa93630..0000000000 --- a/gnuradio-core/src/lib/general/gr_nop.i +++ /dev/null @@ -1,34 +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. - */ - -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_null_sink.h b/gnuradio-core/src/lib/general/gr_null_sink.h deleted file mode 100644 index 7374293295..0000000000 --- a/gnuradio-core/src/lib/general/gr_null_sink.h +++ /dev/null @@ -1,53 +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. - */ - -#ifndef INCLUDED_GR_NULL_SINK_H -#define INCLUDED_GR_NULL_SINK_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <stddef.h> // size_t - -class gr_null_sink; -typedef boost::shared_ptr<gr_null_sink> gr_null_sink_sptr; - -GR_CORE_API gr_null_sink_sptr -gr_make_null_sink (size_t sizeof_stream_item); - -/*! - * \brief Bit bucket - * \ingroup sink_blk - */ -class GR_CORE_API gr_null_sink : public gr_sync_block -{ - friend GR_CORE_API gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item); - gr_null_sink (size_t sizeof_stream_item); - - public: - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - -#endif /* INCLUDED_GR_NULL_SINK_H */ diff --git a/gnuradio-core/src/lib/general/gr_null_sink.i b/gnuradio-core/src/lib/general/gr_null_sink.i deleted file mode 100644 index 80411f9b74..0000000000 --- a/gnuradio-core/src/lib/general/gr_null_sink.i +++ /dev/null @@ -1,31 +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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,null_sink) - -gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item); - -class gr_null_sink : public gr_sync_block { -private: - gr_null_sink (size_t sizeof_stream_item); -}; - diff --git a/gnuradio-core/src/lib/general/gr_null_source.cc b/gnuradio-core/src/lib/general/gr_null_source.cc deleted file mode 100644 index 1ad5c351d6..0000000000 --- a/gnuradio-core/src/lib/general/gr_null_source.cc +++ /dev/null @@ -1,52 +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_null_source.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_null_source::gr_null_source (size_t sizeof_stream_item) - : gr_sync_block ("null_source", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof_stream_item)) -{ -} - -gr_null_source_sptr -gr_make_null_source (size_t sizeof_stream_item) -{ - return gnuradio::get_initial_sptr (new gr_null_source (sizeof_stream_item)); -} - -int -gr_null_source::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - void *optr = (void *) output_items[0]; - memset (optr, 0, noutput_items * output_signature()->sizeof_stream_item (0)); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_null_source.h b/gnuradio-core/src/lib/general/gr_null_source.h deleted file mode 100644 index 1c64e8bd98..0000000000 --- a/gnuradio-core/src/lib/general/gr_null_source.h +++ /dev/null @@ -1,52 +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. - */ - -#ifndef INCLUDED_GR_NULL_SOURCE_H -#define INCLUDED_GR_NULL_SOURCE_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_null_source; -typedef boost::shared_ptr<gr_null_source> gr_null_source_sptr; - -GR_CORE_API gr_null_source_sptr -gr_make_null_source (size_t sizeof_stream_item); - -/*! - * \brief A source of zeros. - * \ingroup source_blk - */ -class GR_CORE_API gr_null_source : public gr_sync_block -{ - friend GR_CORE_API gr_null_source_sptr gr_make_null_source (size_t sizeof_stream_item); - - gr_null_source (size_t sizeof_stream_item); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - -#endif /* INCLUDED_GR_NULL_SOURCE_H */ diff --git a/gnuradio-core/src/lib/general/gr_null_source.i b/gnuradio-core/src/lib/general/gr_null_source.i deleted file mode 100644 index 120a59999c..0000000000 --- a/gnuradio-core/src/lib/general/gr_null_source.i +++ /dev/null @@ -1,31 +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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,null_source) - -gr_null_source_sptr gr_make_null_source (size_t sizeof_stream_item); - -class gr_null_source : public gr_sync_block { -private: - gr_null_source (size_t sizeof_stream_item); -}; - diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc deleted file mode 100644 index 2b718e5ce2..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc +++ /dev/null @@ -1,97 +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_ofdm_bpsk_demapper.h> -#include <gr_io_signature.h> - -gr_ofdm_bpsk_demapper_sptr -gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers) -{ - return gnuradio::get_initial_sptr(new gr_ofdm_bpsk_demapper (occupied_carriers)); -} - -gr_ofdm_bpsk_demapper::gr_ofdm_bpsk_demapper (unsigned occupied_carriers) - : gr_block ("ofdm_bpsk_demapper", - gr_make_io_signature (1, 1, sizeof(gr_complex)*occupied_carriers), - gr_make_io_signature (1, 1, sizeof(unsigned char))), - d_occupied_carriers(occupied_carriers), - d_byte_offset(0), d_partial_byte(0) -{ -} - -gr_ofdm_bpsk_demapper::~gr_ofdm_bpsk_demapper(void) -{ -} - -unsigned char gr_ofdm_bpsk_demapper::slicer(gr_complex x) -{ - return (unsigned char)(x.real() > 0 ? 1 : 0); -} - -void -gr_ofdm_bpsk_demapper::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] = 1; -} - -int -gr_ofdm_bpsk_demapper::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]; - unsigned char *out = (unsigned char *) output_items[0]; - - unsigned int i=0, bytes_produced=0; - - while(i < d_occupied_carriers) { - - while((d_byte_offset < 8) && (i < d_occupied_carriers)) { - //fprintf(stderr, "%f+j%f\n", in[i].real(), in[i].imag()); - d_partial_byte |= slicer(in[i++]) << (d_byte_offset++); - } - - if(d_byte_offset == 8) { - out[bytes_produced++] = d_partial_byte; - d_byte_offset = 0; - d_partial_byte = 0; - } - } - -#if 0 -printf("demod out: "); - for(i = 0; i < bytes_produced; i++) { - printf("%4x", out[i]); - } - printf(" \tlen: %d\n", i); -#endif - - consume_each(1); - return bytes_produced; -} diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h deleted file mode 100644 index d69d427edb..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h +++ /dev/null @@ -1,69 +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_OFDM_BPSK_DEMAPPER_H -#define INCLUDED_GR_OFDM_BPSK_DEMAPPER_H - - -#include <gr_core_api.h> -#include <gr_block.h> -#include <vector> - -class gr_ofdm_bpsk_demapper; -typedef boost::shared_ptr<gr_ofdm_bpsk_demapper> gr_ofdm_bpsk_demapper_sptr; - -GR_CORE_API gr_ofdm_bpsk_demapper_sptr -gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers); - - -/*! - * \brief take a vector of complex constellation points in from an FFT - * and demodulate to a stream of bits. Simple BPSK version. - * \ingroup ofdm_blk - */ -class GR_CORE_API gr_ofdm_bpsk_demapper : public gr_block -{ - friend GR_CORE_API gr_ofdm_bpsk_demapper_sptr - gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers); - - protected: - gr_ofdm_bpsk_demapper (unsigned int occupied_carriers); - - private: - unsigned char slicer(gr_complex x); - - unsigned int d_occupied_carriers; - unsigned int d_byte_offset; - unsigned char d_partial_byte; - - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - - public: - ~gr_ofdm_bpsk_demapper(void); - 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_ofdm_bpsk_demapper.i b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i deleted file mode 100644 index e58a4e40c5..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i +++ /dev/null @@ -1,40 +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,ofdm_bpsk_demapper) - -gr_ofdm_bpsk_demapper_sptr -gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers); - -class gr_ofdm_bpsk_demapper : public gr_sync_decimator -{ - protected: - gr_ofdm_bpsk_demapper (unsigned int occupied_carriers); - - 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_ofdm_frame_sink2.cc b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.cc deleted file mode 100644 index eb12327565..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.cc +++ /dev/null @@ -1,374 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,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_ofdm_frame_sink2.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <gr_math.h> -#include <math.h> -#include <cstdio> -#include <stdexcept> -#include <iostream> -#include <string.h> -#include <gr_constellation.h> - -#define VERBOSE 0 - -inline void -gr_ofdm_frame_sink2::enter_search() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_search\n"); - - d_state = STATE_SYNC_SEARCH; - -} - -inline void -gr_ofdm_frame_sink2::enter_have_sync() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_have_sync\n"); - - d_state = STATE_HAVE_SYNC; - - // clear state of demapper - d_byte_offset = 0; - d_partial_byte = 0; - - d_header = 0; - d_headerbytelen_cnt = 0; - - // Resetting PLL - d_freq = 0.0; - d_phase = 0.0; - fill(d_dfe.begin(), d_dfe.end(), gr_complex(1.0,0.0)); -} - -inline void -gr_ofdm_frame_sink2::enter_have_header() -{ - d_state = STATE_HAVE_HEADER; - - // header consists of two 16-bit shorts in network byte order - // payload length is lower 12 bits - // whitener offset is upper 4 bits - d_packetlen = (d_header >> 16) & 0x0fff; - d_packet_whitener_offset = (d_header >> 28) & 0x000f; - d_packetlen_cnt = 0; - - if (VERBOSE) - fprintf(stderr, "@ enter_have_header (payload_len = %d) (offset = %d)\n", - d_packetlen, d_packet_whitener_offset); -} - - -unsigned int gr_ofdm_frame_sink2::demapper(const gr_complex *in, - unsigned char *out) -{ - unsigned int i=0, bytes_produced=0; - gr_complex carrier; - - carrier=gr_expj(d_phase); - - gr_complex accum_error = 0.0; - //while(i < d_occupied_carriers) { - while(i < d_subcarrier_map.size()) { - if(d_nresid > 0) { - d_partial_byte |= d_resid; - d_byte_offset += d_nresid; - d_nresid = 0; - d_resid = 0; - } - - //while((d_byte_offset < 8) && (i < d_occupied_carriers)) { - while((d_byte_offset < 8) && (i < d_subcarrier_map.size())) { - //gr_complex sigrot = in[i]*carrier*d_dfe[i]; - gr_complex sigrot = in[d_subcarrier_map[i]]*carrier*d_dfe[i]; - - if(d_derotated_output != NULL){ - d_derotated_output[i] = sigrot; - } - - unsigned char bits = d_constell->decision_maker(&sigrot); - - gr_complex closest_sym = d_constell->points()[bits]; - - accum_error += sigrot * conj(closest_sym); - - // FIX THE FOLLOWING STATEMENT - if (norm(sigrot)> 0.001) d_dfe[i] += d_eq_gain*(closest_sym/sigrot-d_dfe[i]); - - i++; - - if((8 - d_byte_offset) >= d_nbits) { - d_partial_byte |= bits << (d_byte_offset); - d_byte_offset += d_nbits; - } - else { - d_nresid = d_nbits-(8-d_byte_offset); - int mask = ((1<<(8-d_byte_offset))-1); - d_partial_byte |= (bits & mask) << d_byte_offset; - d_resid = bits >> (8-d_byte_offset); - d_byte_offset += (d_nbits - d_nresid); - } - //printf("demod symbol: %.4f + j%.4f bits: %x partial_byte: %x byte_offset: %d resid: %x nresid: %d\n", - // in[i-1].real(), in[i-1].imag(), bits, d_partial_byte, d_byte_offset, d_resid, d_nresid); - } - - if(d_byte_offset == 8) { - //printf("demod byte: %x \n\n", d_partial_byte); - out[bytes_produced++] = d_partial_byte; - d_byte_offset = 0; - d_partial_byte = 0; - } - } - //std::cerr << "accum_error " << accum_error << std::endl; - - float angle = arg(accum_error); - - d_freq = d_freq - d_freq_gain*angle; - d_phase = d_phase + d_freq - d_phase_gain*angle; - if (d_phase >= 2*M_PI) d_phase -= 2*M_PI; - if (d_phase <0) d_phase += 2*M_PI; - - //if(VERBOSE) - // std::cerr << angle << "\t" << d_freq << "\t" << d_phase << "\t" << std::endl; - - return bytes_produced; -} - - -gr_ofdm_frame_sink2_sptr -gr_make_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, - float phase_gain, float freq_gain) -{ - return gnuradio::get_initial_sptr(new gr_ofdm_frame_sink2(constell, - target_queue, occupied_carriers, - phase_gain, freq_gain)); -} - - -gr_ofdm_frame_sink2::gr_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, - float phase_gain, float freq_gain) - : gr_sync_block ("ofdm_frame_sink2", - gr_make_io_signature2 (2, 2, sizeof(gr_complex)*occupied_carriers, sizeof(char)), - gr_make_io_signature (1, 1, sizeof(gr_complex)*occupied_carriers)), - d_constell(constell), - d_target_queue(target_queue), d_occupied_carriers(occupied_carriers), - d_byte_offset(0), d_partial_byte(0), - d_resid(0), d_nresid(0),d_phase(0),d_freq(0),d_phase_gain(phase_gain),d_freq_gain(freq_gain), - d_eq_gain(0.05) -{ - if (d_constell->dimensionality() != 1) - throw std::runtime_error ("This receiver only works with constellations of dimension 1."); - - std::string carriers = "FE7F"; - - // A bit hacky to fill out carriers to occupied_carriers length - int diff = (d_occupied_carriers - 4*carriers.length()); - while(diff > 7) { - carriers.insert(0, "f"); - carriers.insert(carriers.length(), "f"); - diff -= 8; - } - - // if there's extras left to be processed - // divide remaining to put on either side of current map - // all of this is done to stick with the concept of a carrier map string that - // can be later passed by the user, even though it'd be cleaner to just do this - // on the carrier map itself - int diff_left=0; - int diff_right=0; - - // dictionary to convert from integers to ascii hex representation - char abc[16] = {'0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - if(diff > 0) { - char c[2] = {0,0}; - - diff_left = (int)ceil((float)diff/2.0f); // number of carriers to put on the left side - c[0] = abc[(1 << diff_left) - 1]; // convert to bits and move to ASCI integer - carriers.insert(0, c); - - diff_right = diff - diff_left; // number of carriers to put on the right side - c[0] = abc[0xF^((1 << diff_right) - 1)]; // convert to bits and move to ASCI integer - carriers.insert(carriers.length(), c); - } - - // It seemed like such a good idea at the time... - // because we are only dealing with the occupied_carriers - // at this point, the diff_left in the following compensates - // for any offset from the 0th carrier introduced - unsigned int i,j,k; - for(i = 0; i < (d_occupied_carriers/4)+diff_left; i++) { - char c = carriers[i]; - for(j = 0; j < 4; j++) { - k = (strtol(&c, NULL, 16) >> (3-j)) & 0x1; - if(k) { - d_subcarrier_map.push_back(4*i + j - diff_left); - } - } - } - - // make sure we stay in the limit currently imposed by the occupied_carriers - if(d_subcarrier_map.size() > d_occupied_carriers) { - throw std::invalid_argument("gr_ofdm_mapper_bcv: subcarriers allocated exceeds size of occupied carriers"); - } - - d_bytes_out = new unsigned char[d_occupied_carriers]; - d_dfe.resize(occupied_carriers); - fill(d_dfe.begin(), d_dfe.end(), gr_complex(1.0,0.0)); - - d_nbits = d_constell->bits_per_symbol(); - - enter_search(); -} - -gr_ofdm_frame_sink2::~gr_ofdm_frame_sink2 () -{ - delete [] d_bytes_out; -} - - -int -gr_ofdm_frame_sink2::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]; - const char *sig = (const char *) input_items[1]; - unsigned int j = 0; - unsigned int bytes=0; - - // If the output is connected, send it the derotated symbols - if(output_items.size() >= 1) - d_derotated_output = (gr_complex *)output_items[0]; - else - d_derotated_output = NULL; - - if (VERBOSE) - fprintf(stderr,">>> Entering state machine\n"); - - 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); - - if (sig[0]) { // Found it, set up for header decode - enter_have_sync(); - } - break; - - case STATE_HAVE_SYNC: - // only demod after getting the preamble signal; otherwise, the - // equalizer taps will screw with the PLL performance - bytes = demapper(&in[0], d_bytes_out); - - if (VERBOSE) { - if(sig[0]) - printf("ERROR -- Found SYNC in HAVE_SYNC\n"); - fprintf(stderr,"Header Search bitcnt=%d, header=0x%08x\n", - d_headerbytelen_cnt, d_header); - } - - j = 0; - while(j < bytes) { - d_header = (d_header << 8) | (d_bytes_out[j] & 0xFF); - j++; - - if (++d_headerbytelen_cnt == HEADERBYTELEN) { - - 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()){ - enter_have_header(); - - if (VERBOSE) - printf("\nPacket Length: %d\n", d_packetlen); - - while((j < bytes) && (d_packetlen_cnt < d_packetlen)) { - d_packet[d_packetlen_cnt++] = d_bytes_out[j++]; - } - - if(d_packetlen_cnt == d_packetlen) { - gr_message_sptr msg = - gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen); - memcpy(msg->msg(), d_packet, d_packetlen_cnt); - d_target_queue->insert_tail(msg); // send it - msg.reset(); // free it up - - enter_search(); - } - } - else { - enter_search(); // bad header - } - } - } - break; - - case STATE_HAVE_HEADER: - bytes = demapper(&in[0], d_bytes_out); - - if (VERBOSE) { - if(sig[0]) - printf("ERROR -- Found SYNC in HAVE_HEADER at %d, length of %d\n", d_packetlen_cnt, d_packetlen); - fprintf(stderr,"Packet Build\n"); - } - - j = 0; - while(j < bytes) { - d_packet[d_packetlen_cnt++] = d_bytes_out[j++]; - - 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 - - return 1; -} diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h deleted file mode 100644 index a743e8c5a5..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,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_OFDM_FRAME_SINK2_H -#define INCLUDED_GR_OFDM_FRAME_SINK2_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_msg_queue.h> -#include <gr_constellation.h> - -class gr_ofdm_frame_sink2; -typedef boost::shared_ptr<gr_ofdm_frame_sink2> gr_ofdm_frame_sink2_sptr; - -GR_CORE_API gr_ofdm_frame_sink2_sptr -gr_make_ofdm_frame_sink2 (gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain=0.25, float freq_gain=0.25*0.25/4.0); - -/*! - * \brief Takes an OFDM symbol in, demaps it into bits of 0's and 1's, packs - * them into packets, and sends to to a message queue sink. - * \ingroup sink_blk - * \ingroup ofdm_blk - * - * NOTE: The mod input parameter simply chooses a pre-defined demapper/slicer. Eventually, - * we want to be able to pass in a reference to an object to do the demapping and slicing - * for a given modulation type. - */ -class GR_CORE_API gr_ofdm_frame_sink2 : public gr_sync_block -{ - friend GR_CORE_API gr_ofdm_frame_sink2_sptr - gr_make_ofdm_frame_sink2 (gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); - - private: - enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; - - static const int MAX_PKT_LEN = 4096; - static const int HEADERBYTELEN = 4; - - 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_headerbytelen_cnt; // how many so far - - unsigned char *d_bytes_out; // hold the current bytes produced by the demapper - - unsigned int d_occupied_carriers; - unsigned int d_byte_offset; - unsigned int d_partial_byte; - - unsigned char d_packet[MAX_PKT_LEN]; // assembled payload - 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 - - gr_complex * d_derotated_output; // Pointer to output stream to send deroated symbols out - - gr_constellation_sptr d_constell; - std::vector<gr_complex> d_dfe; - unsigned int d_nbits; - - unsigned char d_resid; - unsigned int d_nresid; - float d_phase; - float d_freq; - float d_phase_gain; - float d_freq_gain; - float d_eq_gain; - - std::vector<int> d_subcarrier_map; - - protected: - gr_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); - - void enter_search(); - void enter_have_sync(); - void enter_have_header(); - - bool header_ok() - { - // confirm that two copies of header info are identical - return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; - } - - unsigned char slicer(const gr_complex x); - unsigned int demapper(const gr_complex *in, - unsigned char *out); - - public: - ~gr_ofdm_frame_sink2(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_OFDM_FRAME_SINK2_H */ diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.i b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.i deleted file mode 100644 index 8c04d1e160..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,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,ofdm_frame_sink2); - -gr_ofdm_frame_sink2_sptr -gr_make_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain=0.25, float freq_gain=0.25*0.25/4); - -class gr_ofdm_frame_sink2 : public gr_sync_block -{ - protected: - gr_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); - - public: - ~gr_ofdm_frame_sink2(); -}; diff --git a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.cc b/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.cc deleted file mode 100644 index 3187536726..0000000000 --- a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.cc +++ /dev/null @@ -1,74 +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_pa_2x2_phase_combiner.h> -#include <gr_io_signature.h> - -gr_pa_2x2_phase_combiner_sptr -gr_make_pa_2x2_phase_combiner() -{ - return gnuradio::get_initial_sptr(new gr_pa_2x2_phase_combiner()); -} - -gr_pa_2x2_phase_combiner::gr_pa_2x2_phase_combiner () - : gr_sync_block ("pa_2x2_phase_combiner", - gr_make_io_signature (1, 1, NM * sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (float))) -{ - set_theta(0); -} - -void -gr_pa_2x2_phase_combiner::set_theta(float theta) -{ - d_theta = theta; - gr_complex j = gr_complex(0,1); - d_phase[0] = exp(j * (float) (M_PI * (sin(theta) + cos(theta)))); - d_phase[1] = exp(j * (float) (M_PI * cos(theta))); - d_phase[2] = exp(j * (float) (M_PI * sin(theta))); - d_phase[3] = exp(j * (float) 0.0); -} - -int -gr_pa_2x2_phase_combiner::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++){ - gr_complex acc = 0; - acc += in[0] * d_phase[0]; - acc += in[1] * d_phase[1]; - acc += in[2] * d_phase[2]; - acc += in[3] * d_phase[3]; - out[i] = acc; - in += 4; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.h b/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.h deleted file mode 100644 index d430d154fc..0000000000 --- a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.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_PA_2X2_PHASE_COMBINER_H -#define INCLUDED_GR_PA_2X2_PHASE_COMBINER_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_pa_2x2_phase_combiner; -typedef boost::shared_ptr<gr_pa_2x2_phase_combiner> gr_pa_2x2_phase_combiner_sptr; - -GR_CORE_API gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner (); - -/*! - * \brief pa_2x2 phase combiner - * \ingroup misc_blk - * - * Anntenas are arranged like this: - * - * 2 3 - * 0 1 - * - * dx and dy are lambda/2. - */ -class GR_CORE_API gr_pa_2x2_phase_combiner : public gr_sync_block -{ - static const int NM = 4; - - float d_theta; - gr_complex d_phase[NM]; - - gr_pa_2x2_phase_combiner (); - friend GR_CORE_API gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner(); - - public: - float theta() const { return d_theta; } - void set_theta(float theta); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_PA_2X2_PHASE_COMBINER_H */ diff --git a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.i b/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.i deleted file mode 100644 index 2cd373a5e4..0000000000 --- a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.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,pa_2x2_phase_combiner) - -gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner(); - -class gr_pa_2x2_phase_combiner : public gr_sync_block -{ - gr_pa_2x2_phase_combiner(); - - public: - float theta() const; - void set_theta(float theta); -}; diff --git a/gnuradio-core/src/lib/general/gr_null_sink.cc b/gnuradio-core/src/lib/general/gr_sincos.c index 1836655024..a8d01b0da4 100644 --- a/gnuradio-core/src/lib/general/gr_null_sink.cc +++ b/gnuradio-core/src/lib/general/gr_sincos.c @@ -24,26 +24,60 @@ #include "config.h" #endif -#include <gr_null_sink.h> -#include <gr_io_signature.h> +#ifndef _GNU_SOURCE +#define _GNU_SOURCE // ask for GNU extensions if available +#endif + +#include <gr_sincos.h> +#include <math.h> + +// ---------------------------------------------------------------- -gr_null_sink::gr_null_sink (size_t sizeof_stream_item) - : gr_sync_block ("null_sink", - gr_make_io_signature (1, 1, sizeof_stream_item), - gr_make_io_signature (0, 0, 0)) +#if defined (HAVE_SINCOS) + +void +gr_sincos (double x, double *sinx, double *cosx) { + sincos (x, sinx, cosx); } -gr_null_sink_sptr -gr_make_null_sink (size_t sizeof_stream_item) +#else + +void +gr_sincos (double x, double *sinx, double *cosx) { - return gnuradio::get_initial_sptr (new gr_null_sink (sizeof_stream_item)); + *sinx = sin (x); + *cosx = cos (x); } -int -gr_null_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +#endif + +// ---------------------------------------------------------------- + +#if defined (HAVE_SINCOSF) + +void +gr_sincosf (float x, float *sinx, float *cosx) { - return noutput_items; + sincosf (x, sinx, cosx); } + +#elif defined (HAVE_SINF) && defined (HAVE_COSF) + +void +gr_sincosf (float x, float *sinx, float *cosx) +{ + *sinx = sinf (x); + *cosx = cosf (x); +} + +#else + +void +gr_sincosf (float x, float *sinx, float *cosx) +{ + *sinx = sin (x); + *cosx = cos (x); +} + +#endif diff --git a/gnuradio-core/src/lib/general/gr_iqcomp_cc.i b/gnuradio-core/src/lib/general/gr_sincos.h index 5cca59dd5d..516f43437a 100644 --- a/gnuradio-core/src/lib/general/gr_iqcomp_cc.i +++ b/gnuradio-core/src/lib/general/gr_sincos.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2002,2004 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,17 +20,22 @@ * Boston, MA 02110-1301, USA. */ +#ifndef INCLUDED_GR_SINCOS_H +#define INCLUDED_GR_SINCOS_H -GR_SWIG_BLOCK_MAGIC(gr,iqcomp_cc) +#include <gr_core_api.h> -gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); +#ifdef __cplusplus +extern "C" { +#endif -class gr_iqcomp_cc : public gr_sync_block -{ - private: - gr_iqcomp_cc (float mu); +// compute sine and cosine at the same time - public: - float mu () const { return d_mu; } - void set_mu (float mu) { d_mu = mu; } +GR_CORE_API void gr_sincos (double x, double *sin, double *cos); +GR_CORE_API void gr_sincosf (float x, float *sin, float *cos); + +#ifdef __cplusplus }; +#endif + +#endif /* INCLUDED_GR_SINCOS_H */ diff --git a/gnuradio-core/src/lib/general/gr_skiphead.cc b/gnuradio-core/src/lib/general/gr_skiphead.cc deleted file mode 100644 index c93478597b..0000000000 --- a/gnuradio-core/src/lib/general/gr_skiphead.cc +++ /dev/null @@ -1,108 +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_skiphead.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_skiphead::gr_skiphead (size_t itemsize, uint64_t nitems_to_skip) - : gr_block ("skiphead", - gr_make_io_signature(1, 1, itemsize), - gr_make_io_signature(1, 1, itemsize)), - d_nitems_to_skip(nitems_to_skip), d_nitems(0) -{ -} - -gr_skiphead_sptr -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_, - 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]; - - int ninput_items = std::min(ninput_items_[0], noutput_items); - int ii = 0; // input index - - while (ii < ninput_items){ - - uint64_t ni_total = ii + d_nitems; // total items processed so far - if (ni_total < d_nitems_to_skip){ // need to skip some more - - int n_to_skip = (int) std::min(d_nitems_to_skip - ni_total, - (uint64_t)(ninput_items - ii)); - ii += n_to_skip; - } - - else { // nothing left to skip. copy away - - int n_to_copy = ninput_items - ii; - if (n_to_copy > 0){ - size_t itemsize = output_signature()->sizeof_stream_item(0); - memcpy(out, in + (ii*itemsize), n_to_copy*itemsize); - } - - d_nitems += ninput_items; - consume_each(ninput_items); - return n_to_copy; - } - } - - d_nitems += ninput_items; - consume_each(ninput_items); - return 0; -} diff --git a/gnuradio-core/src/lib/general/gr_skiphead.h b/gnuradio-core/src/lib/general/gr_skiphead.h deleted file mode 100644 index 710530ff4c..0000000000 --- a/gnuradio-core/src/lib/general/gr_skiphead.h +++ /dev/null @@ -1,80 +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_SKIPHEAD_H -#define INCLUDED_GR_SKIPHEAD_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <stddef.h> // size_t - -class gr_skiphead; -typedef boost::shared_ptr<gr_skiphead> gr_skiphead_sptr; - -GR_CORE_API gr_skiphead_sptr -gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); - - -/*! - * \brief skips the first N items, from then on copies items to the output - * \ingroup slicedice_blk - * - * Useful for building test cases and sources which have metadata or junk at the start - */ - -class GR_CORE_API gr_skiphead : public gr_block -{ - friend GR_CORE_API gr_skiphead_sptr gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); - gr_skiphead (size_t itemsize, uint64_t nitems_to_skip); - - uint64_t d_nitems_to_skip; - uint64_t d_nitems; // total items seen - - 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, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_SKIPHEAD_H */ diff --git a/gnuradio-core/src/lib/general/gr_skiphead.i b/gnuradio-core/src/lib/general/gr_skiphead.i deleted file mode 100644 index 8ab23a77a6..0000000000 --- a/gnuradio-core/src/lib/general/gr_skiphead.i +++ /dev/null @@ -1,35 +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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,skiphead); - -gr_skiphead_sptr gr_make_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_vco.h b/gnuradio-core/src/lib/general/gr_vco.h new file mode 100644 index 0000000000..3ceaf15dd4 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_vco.h @@ -0,0 +1,94 @@ +/* -*- 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_vector_map.cc b/gnuradio-core/src/lib/general/gr_vector_map.cc deleted file mode 100644 index 2a13efb06d..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_map.cc +++ /dev/null @@ -1,117 +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_vector_map.h> -#include <gr_io_signature.h> -#include <string.h> - -std::vector<int> -get_in_sizeofs(size_t item_size, std::vector<size_t> in_vlens) -{ - std::vector<int> in_sizeofs; - for(unsigned int i = 0; i < in_vlens.size(); i++) { - in_sizeofs.push_back(in_vlens[i]*item_size); - } - return in_sizeofs; -} - -std::vector<int> -get_out_sizeofs(size_t item_size, - std::vector< std::vector< std::vector<size_t> > > mapping) -{ - std::vector<int> out_sizeofs; - for(unsigned int i = 0; i < mapping.size(); i++) { - out_sizeofs.push_back(mapping[i].size()*item_size); - } - return out_sizeofs; -} - -gr_vector_map_sptr -gr_make_vector_map (size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping) -{ - return gnuradio::get_initial_sptr(new gr_vector_map(item_size, - in_vlens, - mapping)); -} - -gr_vector_map::gr_vector_map(size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping) - : gr_sync_block("vector_map", - gr_make_io_signaturev(in_vlens.size(), in_vlens.size(), - get_in_sizeofs(item_size, in_vlens)), - gr_make_io_signaturev(mapping.size(), mapping.size(), - get_out_sizeofs(item_size, mapping))), - d_item_size(item_size), d_in_vlens(in_vlens) -{ - set_mapping(mapping); -} - -void -gr_vector_map::set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping) { - // Make sure the contents of the mapping vectors are possible. - for(unsigned int i=0; i<mapping.size(); i++) { - for(unsigned int j=0; j<mapping[i].size(); j++) { - if(mapping[i][j].size() != 2) { - throw std::runtime_error("Mapping must be of the form (out_mapping_stream1, out_mapping_stream2, ...), where out_mapping_stream1 is of the form (mapping_element1, mapping_element2, ...), where mapping_element1 is of the form (input_stream, input_element). This error is raised because a mapping_element vector does not contain exactly 2 items."); - } - unsigned int s = mapping[i][j][0]; - unsigned int index = mapping[i][j][1]; - if(s >= d_in_vlens.size()) { - throw std::runtime_error("Stream numbers in mapping must be less than the number of input streams."); - } - if((index < 0) || (index >= d_in_vlens[s])) { - throw std::runtime_error ("Indices in mapping must be greater than 0 and less than the input vector lengths."); - } - } - } - gruel::scoped_lock guard(d_mutex); - d_mapping = mapping; -} - -int -gr_vector_map::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char **inv = (const char **) &input_items[0]; - char **outv = (char **) &output_items[0]; - - for(unsigned int n = 0; n < (unsigned int)(noutput_items); n++) { - for(unsigned int i = 0; i < d_mapping.size(); i++) { - unsigned int out_vlen = d_mapping[i].size(); - for(unsigned int j = 0; j < out_vlen; j++) { - unsigned int s = d_mapping[i][j][0]; - unsigned int k = d_mapping[i][j][1]; - memcpy(outv[i] + out_vlen*d_item_size*n + - d_item_size*j, inv[s] + d_in_vlens[s]*d_item_size*n + - k*d_item_size, d_item_size); - } - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_vector_map.h b/gnuradio-core/src/lib/general/gr_vector_map.h deleted file mode 100644 index f5492b1e3a..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_map.h +++ /dev/null @@ -1,83 +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_VECTOR_MAP_H -#define INCLUDED_GR_VECTOR_MAP_H - -#include <vector> -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> -#include <gruel/thread.h> - -class gr_vector_map; -typedef boost::shared_ptr<gr_vector_map> gr_vector_map_sptr; - -GR_CORE_API gr_vector_map_sptr -gr_make_vector_map (size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping); - -/*! - * \brief Maps elements from a set of input vectors to a set of output vectors. - * - * If in[i] is the input vector in the i'th stream then the output - * vector in the j'th stream is: - * - * out[j][k] = in[mapping[j][k][0]][mapping[j][k][1]] - * - * That is mapping is of the form (out_stream1_mapping, - * out_stream2_mapping, ...) and out_stream1_mapping is of the form - * (element1_mapping, element2_mapping, ...) and element1_mapping is - * of the form (in_stream, in_element). - * - * \param item_size (integer) size of vector elements - * - * \param in_vlens (vector of integers) number of elements in each - * input vector - * - * \param mapping (vector of vectors of vectors of integers) how to - * map elements from input to output vectors - * - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_vector_map : public gr_sync_block -{ - friend GR_CORE_API gr_vector_map_sptr - gr_make_vector_map(size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping); - size_t d_item_size; - std::vector<size_t> d_in_vlens; - std::vector< std::vector< std::vector<size_t> > > d_mapping; - gruel::mutex d_mutex; // mutex to protect set/work access - - protected: - gr_vector_map(size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping); - - public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping); -}; - -#endif /* INCLUDED_GR_VECTOR_MAP_H */ diff --git a/gnuradio-core/src/lib/general/gr_vector_map.i b/gnuradio-core/src/lib/general/gr_vector_map.i deleted file mode 100644 index e9fa3f27e5..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_map.i +++ /dev/null @@ -1,28 +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, vector_map); - -%template() std::vector<size_t>; -%template() std::vector< std::vector< std::vector<size_t> > >; - -%include "gr_vector_map.h" diff --git a/gnuradio-core/src/lib/general/gri_lfsr_15_1_0.h b/gnuradio-core/src/lib/general/gri_lfsr_15_1_0.h deleted file mode 100644 index 578739f7ef..0000000000 --- a/gnuradio-core/src/lib/general/gri_lfsr_15_1_0.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_LFSR_15_1_0_H -#define INCLUDED_GRI_LFSR_15_1_0_H - -#include <gr_core_api.h> - -/*! - * \brief Linear Feedback Shift Register using primitive polynomial x^15 + x + 1 - * \ingroup misc - * - * Generates a maximal length pseudo-random sequence of length 2^15 - 1 bits. - */ - -class GR_CORE_API gri_lfsr_15_1_0 { - unsigned long d_sr; // shift register - - public: - - gri_lfsr_15_1_0 () { reset (); } - - void reset () { d_sr = 0x7fff; } - - int next_bit (){ - d_sr = ((((d_sr >> 1) ^ d_sr) & 0x1) << 14) | (d_sr >> 1); - return d_sr & 0x1; - } - - int next_byte (){ - int v = 0; - for (int i = 0; i < 8; i++){ - v >>= 1; - if (next_bit ()) - v |= 0x80; - } - return v; - } -}; - -#endif /* INCLUDED_GRI_LFSR_15_1_0_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/gri_lfsr_32k.h b/gnuradio-core/src/lib/general/gri_lfsr_32k.h deleted file mode 100644 index e84512b9a6..0000000000 --- a/gnuradio-core/src/lib/general/gri_lfsr_32k.h +++ /dev/null @@ -1,80 +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_LFSR_32k_H -#define INCLUDED_GRI_LFSR_32k_H - -#include <gr_core_api.h> -#include <gri_lfsr_15_1_0.h> - -/*! - * \brief generate pseudo-random sequence of length 32768 bits. - * \ingroup misc - * - * This is based on gri_lfsr_15_1_0 with an extra 0 added at the end - * of the sequence. - */ - -class GR_CORE_API gri_lfsr_32k { - gri_lfsr_15_1_0 d_lfsr; - unsigned int d_count; - - public: - gri_lfsr_32k () { reset (); } - - void reset (){ - d_lfsr.reset (); - d_count = 0; - } - - int next_bit (){ - if (d_count == 32767){ - d_count = 0; - return 0; - } - d_count++; - return d_lfsr.next_bit (); - } - - int next_byte (){ - int v = 0; - for (int i = 0; i < 8; i++){ - v >>= 1; - if (next_bit ()) - v |= 0x80; - } - return v; - } - - int next_short (){ - int v = 0; - for (int i = 0; i < 16; i++){ - v >>= 1; - if (next_bit ()) - v |= 0x8000; - } - return v; - } - -}; - -#endif /* INCLUDED_GRI_LFSR_32k_H */ diff --git a/gnuradio-core/src/lib/general/qa_general.cc b/gnuradio-core/src/lib/general/qa_general.cc index e2328c2cb2..121551b050 100644 --- a/gnuradio-core/src/lib/general/qa_general.cc +++ b/gnuradio-core/src/lib/general/qa_general.cc @@ -27,7 +27,11 @@ #include <qa_general.h> #include <qa_gr_circular_file.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_sincos.h> CppUnit::TestSuite * qa_general::suite () @@ -35,7 +39,11 @@ qa_general::suite () CppUnit::TestSuite *s = new CppUnit::TestSuite ("general"); s->addTest (qa_gr_circular_file::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(gr::analog::qa_sincos::suite()); return s; } diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt.cc new file mode 100644 index 0000000000..7eac0d8964 --- /dev/null +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt.cc @@ -0,0 +1,103 @@ +/* -*- 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/gr_check_lfsr_32k_s.i b/gnuradio-core/src/lib/general/qa_gr_fxpt.h index 34d4a0b0c1..72211563e7 100644 --- a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.i +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt.h @@ -19,18 +19,30 @@ * 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 -GR_SWIG_BLOCK_MAGIC(gr,check_lfsr_32k_s) -gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); +#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 (); -class gr_check_lfsr_32k_s : public gr_sync_block -{ private: - gr_check_lfsr_32k_s (); + void t0 (); + void t1 (); + void t2 (); + void t3 (); -public: - long ntotal () const; - long nright () const; - long runlength () const; }; + +#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 new file mode 100644 index 0000000000..6f208eac80 --- /dev/null +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc @@ -0,0 +1,119 @@ +/* -*- 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/gr_copy.i b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.h index 12ddce6aaf..8998922bbb 100644 --- a/gnuradio-core/src/lib/general/gr_copy.i +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2009 Free Software Foundation, Inc. + * Copyright 2004 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,18 +19,30 @@ * 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 -GR_SWIG_BLOCK_MAGIC(gr,copy) -gr_copy_sptr gr_make_copy(size_t itemsize); +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestCase.h> -class gr_copy : public gr_block -{ - private: - gr_copy(size_t itemsize); +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 (); -public: + private: + void t0 (); + void t1 (); + void t2 (); + void t3 (); - void set_enabled(bool enabled); - bool enabled(); }; + +#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 new file mode 100644 index 0000000000..5b6993a30c --- /dev/null +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc @@ -0,0 +1,110 @@ +/* -*- 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 new file mode 100644 index 0000000000..fab8022e36 --- /dev/null +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.h @@ -0,0 +1,48 @@ +/* -*- 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_sincos.cc b/gnuradio-core/src/lib/general/qa_sincos.cc new file mode 100644 index 0000000000..0066ff6b92 --- /dev/null +++ b/gnuradio-core/src/lib/general/qa_sincos.cc @@ -0,0 +1,75 @@ +/* -*- 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 <qa_sincos.h> +#include <gr_sincos.h> +#include <gruel/attributes.h> +#include <cppunit/TestAssert.h> +#include <cmath> + +namespace gr { + namespace analog { + + void + qa_sincos::t1() + { + static const unsigned int N = 1000; + double c_sin, c_cos; + double gr_sin, gr_cos; + + for(unsigned i = 0; i < N; i++) { + double x = i/100.0; + c_sin = sin(x); + c_cos = cos(x); + + gr_sincos(x, &gr_sin, &gr_cos); + + CPPUNIT_ASSERT_DOUBLES_EQUAL(c_sin, gr_sin, 0.0001); + CPPUNIT_ASSERT_DOUBLES_EQUAL(c_cos, gr_cos, 0.0001); + } + } + + void + qa_sincos::t2() + { + static const unsigned int N = 1000; + float c_sin, c_cos; + float gr_sin, gr_cos; + + for(unsigned i = 0; i < N; i++) { + float x = i/100.0; + c_sin = sinf(x); + c_cos = cosf(x); + + gr_sincosf(x, &gr_sin, &gr_cos); + + CPPUNIT_ASSERT_DOUBLES_EQUAL(c_sin, gr_sin, 0.0001); + CPPUNIT_ASSERT_DOUBLES_EQUAL(c_cos, gr_cos, 0.0001); + } + } + + } /* namespace analog */ +} /* namespace gr */ diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.i b/gnuradio-core/src/lib/general/qa_sincos.h index 18858595ea..f18e879dd8 100644 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.i +++ b/gnuradio-core/src/lib/general/qa_sincos.h @@ -20,17 +20,28 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,ctrlport_probe2_c) +#ifndef _QA_ANALOG_SINCOS_H_ +#define _QA_ANALOG_SINCOS_H_ -gr_ctrlport_probe2_c_sptr -gr_make_ctrlport_probe2_c(const std::string &id, const std::string &desc, int len); +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestCase.h> -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; -}; +namespace gr { + namespace analog { + class qa_sincos : public CppUnit::TestCase + { + CPPUNIT_TEST_SUITE(qa_sincos); + CPPUNIT_TEST(t1); + CPPUNIT_TEST(t2); + CPPUNIT_TEST_SUITE_END(); + + private: + void t1(); + void t2(); + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* _QA_ANALOG_SINCOS_H_ */ |