diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-03-08 10:01:37 -0500 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-03-08 10:01:37 -0500 |
commit | fe70fa72ea22a133874337da2d03d30611e5ab1c (patch) | |
tree | 720a9e4e289e9a029fb363c635675daf91e5f77b /gnuradio-core/src/lib | |
parent | 0970c7eaa165c6dc7d70be55dbf3d272b88fc109 (diff) |
blocks: removed all nco/vco and fxpt stuff from core; now in gr-blocks.
Moved the nco/vco tests to gr-blocks/test and enabled them.
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r-- | gnuradio-core/src/lib/general/CMakeLists.txt | 30 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/general.i | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_fxpt.cc | 35 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_fxpt.h | 104 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_fxpt_nco.h | 153 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_fxpt_vco.h | 73 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_nco.h | 198 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_vco.h | 94 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_vco_f.cc | 58 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_vco_f.h | 75 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_vco_f.i | 38 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/qa_general.cc | 6 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/qa_gr_fxpt.cc | 103 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/qa_gr_fxpt.h | 48 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc | 119 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/qa_gr_fxpt_nco.h | 48 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc | 110 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/qa_gr_fxpt_vco.h | 48 |
18 files changed, 0 insertions, 1342 deletions
diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index bca0583b59..a8ad8573b5 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -22,26 +22,6 @@ ######################################################################## ######################################################################## -# Handle the generated sine table -######################################################################## -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_sine_table.py - COMMAND ${PYTHON_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/gen_sine_table.py > - ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h -) - -include(AddFileDependencies) -ADD_FILE_DEPENDENCIES(${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.cc - ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h -) - -add_custom_target(general_generated DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h -) - -######################################################################## # Handle the generated constants ######################################################################## execute_process(COMMAND ${PYTHON_EXECUTABLE} -c @@ -70,7 +50,6 @@ 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 @@ -86,9 +65,6 @@ 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 ) @@ -100,16 +76,11 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_circular_file.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_constants.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_test_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_vco.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_add_const_ss.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_control_loop.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.h @@ -158,7 +129,6 @@ set(gr_core_general_triple_threats gr_prefs gr_skiphead gr_test - gr_vco_f gr_vector_map gr_annotator_alltoall gr_annotator_1to1 diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 2712c4101c..dabdb1bddf 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -35,7 +35,6 @@ //#include <gr_endianness.h> #include <gr_endian_swap.h> #include <gr_fake_channel_coder_pp.h> -#include <gr_vco_f.h> #include <gr_pa_2x2_phase_combiner.h> #include <gr_kludge_copy.h> #include <gr_prefs.h> @@ -64,7 +63,6 @@ //%include "gr_endianness.i" %include "gr_endian_swap.i" %include "gr_fake_channel_coder_pp.i" -%include "gr_vco_f.i" %include "gr_pa_2x2_phase_combiner.i" %include "gr_kludge_copy.i" %include "gr_prefs.i" diff --git a/gnuradio-core/src/lib/general/gr_fxpt.cc b/gnuradio-core/src/lib/general/gr_fxpt.cc deleted file mode 100644 index 2ea8520e6b..0000000000 --- a/gnuradio-core/src/lib/general/gr_fxpt.cc +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_fxpt.h> - -const float gr_fxpt::s_sine_table[1 << NBITS][2] = { -#include "sine_table.h" -}; - -const float gr_fxpt::PI = 3.14159265358979323846; -const float gr_fxpt::TWO_TO_THE_31 = 2147483648.0; - diff --git a/gnuradio-core/src/lib/general/gr_fxpt.h b/gnuradio-core/src/lib/general/gr_fxpt.h deleted file mode 100644 index 9de6c0c18a..0000000000 --- a/gnuradio-core/src/lib/general/gr_fxpt.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FXPT_H -#define INCLUDED_GR_FXPT_H - -#include <gr_core_api.h> -#include <gr_types.h> - -/*! - * \brief fixed point sine and cosine and friends. - * \ingroup misc - * - * fixed pt radians - * --------- -------- - * -2**31 -pi - * 0 0 - * 2**31-1 pi - epsilon - * - */ -class GR_CORE_API gr_fxpt -{ - static const int WORDBITS = 32; - static const int NBITS = 10; - static const float s_sine_table[1 << NBITS][2]; - static const float PI; - static const float TWO_TO_THE_31; -public: - - static gr_int32 - float_to_fixed (float x) - { - // Fold x into -PI to PI. - int d = (int)floor(x/2/PI+0.5); - x -= d*2*PI; - // And convert to an integer. - return (gr_int32) ((float) x * TWO_TO_THE_31 / PI); - } - - static float - fixed_to_float (gr_int32 x) - { - return x * (PI / TWO_TO_THE_31); - } - - /*! - * \brief Given a fixed point angle x, return float sine (x) - */ - static float - sin (gr_int32 x) - { - gr_uint32 ux = x; - int index = ux >> (WORDBITS - NBITS); - return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1]; - } - - /* - * \brief Given a fixed point angle x, return float cosine (x) - */ - static float - cos (gr_int32 x) - { - gr_uint32 ux = x + 0x40000000; - int index = ux >> (WORDBITS - NBITS); - return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1]; - } - - /* - * \brief Given a fixedpoint angle x, return float cos(x) and sin (x) - */ - static void sincos(gr_int32 x, float *s, float *c) - { - gr_uint32 ux = x; - int sin_index = ux >> (WORDBITS - NBITS); - *s = s_sine_table[sin_index][0] * (ux >> 1) + s_sine_table[sin_index][1]; - - ux = x + 0x40000000; - int cos_index = ux >> (WORDBITS - NBITS); - *c = s_sine_table[cos_index][0] * (ux >> 1) + s_sine_table[cos_index][1]; - - return; - } - -}; - -#endif /* INCLUDED_GR_FXPT_H */ diff --git a/gnuradio-core/src/lib/general/gr_fxpt_nco.h b/gnuradio-core/src/lib/general/gr_fxpt_nco.h deleted file mode 100644 index 9defa083da..0000000000 --- a/gnuradio-core/src/lib/general/gr_fxpt_nco.h +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FXPT_NCO_H -#define INCLUDED_GR_FXPT_NCO_H - -#include <gr_core_api.h> -#include <gr_fxpt.h> -#include <gr_complex.h> - -/*! - * \brief Numerically Controlled Oscillator (NCO) - * \ingroup misc - */ -class /*GR_CORE_API*/ gr_fxpt_nco { - gr_uint32 d_phase; - gr_int32 d_phase_inc; - -public: - gr_fxpt_nco () : d_phase (0), d_phase_inc (0) {} - - ~gr_fxpt_nco () {} - - // radians - void set_phase (float angle) { - d_phase = gr_fxpt::float_to_fixed (angle); - } - - void adjust_phase (float delta_phase) { - d_phase += gr_fxpt::float_to_fixed (delta_phase); - } - - // angle_rate is in radians / step - void set_freq (float angle_rate){ - d_phase_inc = gr_fxpt::float_to_fixed (angle_rate); - } - - // angle_rate is a delta in radians / step - void adjust_freq (float delta_angle_rate) - { - d_phase_inc += gr_fxpt::float_to_fixed (delta_angle_rate); - } - - // increment current phase angle - - void step () - { - d_phase += d_phase_inc; - } - - void step (int n) - { - d_phase += d_phase_inc * n; - } - - // units are radians / step - float get_phase () const { return gr_fxpt::fixed_to_float (d_phase); } - float get_freq () const { return gr_fxpt::fixed_to_float (d_phase_inc); } - - // compute sin and cos for current phase angle - void sincos (float *sinx, float *cosx) const - { - *sinx = gr_fxpt::sin (d_phase); - *cosx = gr_fxpt::cos (d_phase); - } - - // compute cos and sin for a block of phase angles - void sincos (gr_complex *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = gr_complex(gr_fxpt::cos (d_phase) * ampl, gr_fxpt::sin (d_phase) * ampl); - step (); - } - } - - // compute sin for a block of phase angles - void sin (float *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (float)(gr_fxpt::sin (d_phase) * ampl); - step (); - } - } - - // compute cos for a block of phase angles - void cos (float *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (float)(gr_fxpt::cos (d_phase) * ampl); - step (); - } - } - - // compute sin for a block of phase angles - void sin (short *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (short)(gr_fxpt::sin (d_phase) * ampl); - step (); - } - } - - // compute cos for a block of phase angles - void cos (short *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (short)(gr_fxpt::cos (d_phase) * ampl); - step (); - } - } - - // compute sin for a block of phase angles - void sin (int *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (int)(gr_fxpt::sin (d_phase) * ampl); - step (); - } - } - - // compute cos for a block of phase angles - void cos (int *output, int noutput_items, double ampl=1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (int)(gr_fxpt::cos (d_phase) * ampl); - step (); - } - } - - // compute cos or sin for current phase angle - float cos () const { return gr_fxpt::cos (d_phase); } - float sin () const { return gr_fxpt::sin (d_phase); } -}; - -#endif /* INCLUDED_GR_FXPT_NCO_H */ diff --git a/gnuradio-core/src/lib/general/gr_fxpt_vco.h b/gnuradio-core/src/lib/general/gr_fxpt_vco.h deleted file mode 100644 index 13be2526bd..0000000000 --- a/gnuradio-core/src/lib/general/gr_fxpt_vco.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_FXPT_VCO_H -#define INCLUDED_GR_FXPT_VCO_H - -#include <gr_core_api.h> -#include <gr_fxpt.h> -#include <gr_complex.h> - -/*! - * \brief Voltage Controlled Oscillator (VCO) - * \ingroup misc - */ -class /*GR_CORE_API*/ gr_fxpt_vco { - gr_int32 d_phase; - -public: - gr_fxpt_vco () : d_phase (0) {} - - ~gr_fxpt_vco () {} - - // radians - void set_phase (float angle) { - d_phase = gr_fxpt::float_to_fixed (angle); - } - - void adjust_phase (float delta_phase) { - d_phase += gr_fxpt::float_to_fixed (delta_phase); - } - - float get_phase () const { return gr_fxpt::fixed_to_float (d_phase); } - - // compute sin and cos for current phase angle - void sincos (float *sinx, float *cosx) const - { - *sinx = gr_fxpt::sin (d_phase); - *cosx = gr_fxpt::cos (d_phase); - } - - // compute a block at a time - void cos (float *output, const float *input, int noutput_items, float k, float ampl = 1.0) - { - for (int i = 0; i < noutput_items; i++){ - output[i] = (float)(gr_fxpt::cos (d_phase) * ampl); - adjust_phase(input[i] * k); - } - } - - // compute cos or sin for current phase angle - float cos () const { return gr_fxpt::cos (d_phase); } - float sin () const { return gr_fxpt::sin (d_phase); } -}; - -#endif /* INCLUDED_GR_FXPT_VCO_H */ diff --git a/gnuradio-core/src/lib/general/gr_nco.h b/gnuradio-core/src/lib/general/gr_nco.h deleted file mode 100644 index fb51106aab..0000000000 --- a/gnuradio-core/src/lib/general/gr_nco.h +++ /dev/null @@ -1,198 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GR_NCO_H_ -#define _GR_NCO_H_ - - -#include <vector> -#include <gr_sincos.h> -#include <cmath> -#include <gr_complex.h> - -/*! - * \brief base class template for Numerically Controlled Oscillator (NCO) - * \ingroup misc - */ - - -//FIXME Eventually generalize this to fixed point - -template<class o_type, class i_type> -class gr_nco { -public: - gr_nco () : phase (0), phase_inc(0) {} - - virtual ~gr_nco () {} - - // radians - void set_phase (double angle) { - phase = angle; - } - - void adjust_phase (double delta_phase) { - phase += delta_phase; - } - - - // angle_rate is in radians / step - void set_freq (double angle_rate){ - phase_inc = angle_rate; - } - - // angle_rate is a delta in radians / step - void adjust_freq (double delta_angle_rate) - { - phase_inc += delta_angle_rate; - } - - // increment current phase angle - - void step () - { - phase += phase_inc; - if (fabs (phase) > M_PI){ - - while (phase > M_PI) - phase -= 2*M_PI; - - while (phase < -M_PI) - phase += 2*M_PI; - } - } - - void step (int n) - { - phase += phase_inc * n; - if (fabs (phase) > M_PI){ - - while (phase > M_PI) - phase -= 2*M_PI; - - while (phase < -M_PI) - phase += 2*M_PI; - } - } - - // units are radians / step - double get_phase () const { return phase; } - double get_freq () const { return phase_inc; } - - // compute sin and cos for current phase angle - void sincos (float *sinx, float *cosx) const; - - // compute cos or sin for current phase angle - float cos () const { return std::cos (phase); } - float sin () const { return std::sin (phase); } - - // compute a block at a time - void sin (float *output, int noutput_items, double ampl = 1.0); - void cos (float *output, int noutput_items, double ampl = 1.0); - void sincos (gr_complex *output, int noutput_items, double ampl = 1.0); - void sin (short *output, int noutput_items, double ampl = 1.0); - void cos (short *output, int noutput_items, double ampl = 1.0); - void sin (int *output, int noutput_items, double ampl = 1.0); - void cos (int *output, int noutput_items, double ampl = 1.0); - -protected: - double phase; - double phase_inc; -}; - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::sincos (float *sinx, float *cosx) const -{ - gr_sincosf (phase, sinx, cosx); -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::sin (float *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (float)(sin () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::cos (float *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (float)(cos () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::sin (short *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (short)(sin() * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::cos (short *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (short)(cos () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::sin (int *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (int)(sin () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::cos (int *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (int)(cos () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -gr_nco<o_type,i_type>::sincos (gr_complex *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - float cosx, sinx; - sincos (&sinx, &cosx); - output[i] = gr_complex(cosx * ampl, sinx * ampl); - step (); - } -} -#endif /* _NCO_H_ */ diff --git a/gnuradio-core/src/lib/general/gr_vco.h b/gnuradio-core/src/lib/general/gr_vco.h deleted file mode 100644 index 3ceaf15dd4..0000000000 --- a/gnuradio-core/src/lib/general/gr_vco.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GR_VCO_H_ -#define _GR_VCO_H_ - - -#include <vector> -#include <gr_sincos.h> -#include <cmath> -#include <gr_complex.h> - -/*! - * \brief base class template for Voltage Controlled Oscillator (VCO) - * \ingroup misc - */ - -//FIXME Eventually generalize this to fixed point - -template<class o_type, class i_type> -class gr_vco { -public: - gr_vco () : d_phase (0) {} - - virtual ~gr_vco () {} - - // radians - void set_phase (double angle) { - d_phase = angle; - } - - void adjust_phase (double delta_phase) { - d_phase += delta_phase; - if (fabs (d_phase) > M_PI){ - - while (d_phase > M_PI) - d_phase -= 2*M_PI; - - while (d_phase < -M_PI) - d_phase += 2*M_PI; - } - } - - double get_phase () const { return d_phase; } - - // compute sin and cos for current phase angle - void sincos (float *sinx, float *cosx) const; - - // compute cos or sin for current phase angle - float cos () const { return std::cos (d_phase); } - float sin () const { return std::sin (d_phase); } - - // compute a block at a time - void cos (float *output, const float *input, int noutput_items, double k, double ampl = 1.0); - -protected: - double d_phase; -}; - -template<class o_type, class i_type> -void -gr_vco<o_type,i_type>::sincos (float *sinx, float *cosx) const -{ - gr_sincosf (d_phase, sinx, cosx); -} - -template<class o_type, class i_type> -void -gr_vco<o_type,i_type>::cos (float *output, const float *input, int noutput_items, double k, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = cos() * ampl; - adjust_phase(input[i] * k); - } -} -#endif /* _GR_VCO_H_ */ diff --git a/gnuradio-core/src/lib/general/gr_vco_f.cc b/gnuradio-core/src/lib/general/gr_vco_f.cc deleted file mode 100644 index 0899bc77e0..0000000000 --- a/gnuradio-core/src/lib/general/gr_vco_f.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_vco_f.h> -#include <gr_io_signature.h> -#include <math.h> - -gr_vco_f_sptr -gr_make_vco_f(double sampling_rate, double sensitivity, double amplitude) -{ - return gnuradio::get_initial_sptr(new gr_vco_f(sampling_rate, sensitivity, amplitude)); -} - - -gr_vco_f::gr_vco_f(double sampling_rate, double sensitivity, double amplitude) - : gr_sync_block("vco_f", - gr_make_io_signature(1, 1, sizeof(float)), - gr_make_io_signature(1, 1, sizeof(float))), - d_sampling_rate(sampling_rate), d_sensitivity(sensitivity), d_amplitude(amplitude), - d_k(d_sensitivity/d_sampling_rate) -{ -} - -int -gr_vco_f::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *input = (const float *)input_items[0]; - float *output = (float *)output_items[0]; - - d_vco.cos(output, input, noutput_items, d_k, d_amplitude); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_vco_f.h b/gnuradio-core/src/lib/general/gr_vco_f.h deleted file mode 100644 index 83f6a9773e..0000000000 --- a/gnuradio-core/src/lib/general/gr_vco_f.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_VCO_F_H -#define INCLUDED_GR_VCO_F_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_fxpt_vco.h> - -/*! - * \brief VCO - Voltage controlled oscillator - * \ingroup misc - * - * \param sampling_rate sampling rate (Hz) - * \param sensitivity units are radians/sec/volt - * \param amplitude output amplitude - */ -class gr_vco_f; -typedef boost::shared_ptr<gr_vco_f> gr_vco_f_sptr; - - -GR_CORE_API gr_vco_f_sptr gr_make_vco_f(double sampling_rate, double sensitivity, double amplitude); - -/*! - * \brief VCO - Voltage controlled oscillator - * \ingroup modulator_blk - * - * input: float stream of control voltages; output: float oscillator output - */ -class GR_CORE_API gr_vco_f : public gr_sync_block -{ - friend GR_CORE_API gr_vco_f_sptr gr_make_vco_f(double sampling_rate, double sensitivity, double amplitude); - - /*! - * \brief VCO - Voltage controlled oscillator - * - * \param sampling_rate sampling rate (Hz) - * \param sensitivity units are radians/sec/volt - * \param amplitude output amplitude - */ - gr_vco_f(double sampling_rate, double sensitivity, double amplitude); - - double d_sampling_rate; - double d_sensitivity; - double d_amplitude; - double d_k; - gr_fxpt_vco d_vco; - -public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_VCO_F_H */ diff --git a/gnuradio-core/src/lib/general/gr_vco_f.i b/gnuradio-core/src/lib/general/gr_vco_f.i deleted file mode 100644 index 8ecf314116..0000000000 --- a/gnuradio-core/src/lib/general/gr_vco_f.i +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,vco_f); - -/*! - * \brief VCO - Voltage controlled oscillator - * - * \param sampling_rate sampling rate (Hz) - * \param sensitivity units are radians/sec/volt - * \param amplitude output amplitude - */ -gr_vco_f_sptr gr_make_vco_f(double sampling_rate, double sensitivity, double amplitude); - - -class gr_vco_f : public gr_sync_block { - private: - gr_vco_f(double sampling_rate, double sensitivity, double amplitude); -}; diff --git a/gnuradio-core/src/lib/general/qa_general.cc b/gnuradio-core/src/lib/general/qa_general.cc index 7f30c11e01..e2328c2cb2 100644 --- a/gnuradio-core/src/lib/general/qa_general.cc +++ b/gnuradio-core/src/lib/general/qa_general.cc @@ -27,9 +27,6 @@ #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> CppUnit::TestSuite * @@ -38,9 +35,6 @@ 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 ()); return s; diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt.cc deleted file mode 100644 index 7eac0d8964..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt.cc +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <qa_gr_fxpt.h> -#include <gr_fxpt.h> -#include <cppunit/TestAssert.h> -#include <iostream> -#include <stdio.h> -#include <unistd.h> -#include <math.h> - -static const float SIN_COS_TOLERANCE = 1e-5; - -void -qa_gr_fxpt::t0 () -{ - CPPUNIT_ASSERT_DOUBLES_EQUAL (M_PI/2, gr_fxpt::fixed_to_float (0x40000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, gr_fxpt::fixed_to_float (0x00000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL (-M_PI, gr_fxpt::fixed_to_float (0x80000000), SIN_COS_TOLERANCE); - - if (0){ - /* - * These are disabled because of some precision issues. - * - * Different compilers seem to have different opinions on whether - * the calulations are done single or double (or extended) - * precision. Any of the answers are fine for our real purpose, but - * sometimes the answer is off by a few bits at the bottom. - * Hence, the disabled check. - */ - CPPUNIT_ASSERT_EQUAL ((gr_int32) 0x40000000, gr_fxpt::float_to_fixed (M_PI/2)); - CPPUNIT_ASSERT_EQUAL ((gr_int32) 0, gr_fxpt::float_to_fixed (0)); - CPPUNIT_ASSERT_EQUAL ((gr_int32) 0x80000000, gr_fxpt::float_to_fixed (-M_PI)); - } -} - -void -qa_gr_fxpt::t1 () -{ - - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x00000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0.707106781, gr_fxpt::sin (0x20000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 1, gr_fxpt::sin (0x40000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0.707106781, gr_fxpt::sin (0x60000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x7fffffff), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x80000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x80000001), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL (-1, gr_fxpt::sin (-0x40000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL (-0.707106781, gr_fxpt::sin (-0x20000000), SIN_COS_TOLERANCE); - - - for (float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600){ - float expected = sin (p); - float actual = gr_fxpt::sin (gr_fxpt::float_to_fixed (p)); - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected, actual, SIN_COS_TOLERANCE); - } -} - -void -qa_gr_fxpt::t2 () -{ - for (float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600){ - float expected = cos (p); - float actual = gr_fxpt::cos (gr_fxpt::float_to_fixed (p)); - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected, actual, SIN_COS_TOLERANCE); - } -} - -void -qa_gr_fxpt::t3 () -{ - for (float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600){ - float expected_sin = sin (p); - float expected_cos = cos (p); - float actual_sin; - float actual_cos; - gr_fxpt::sincos (gr_fxpt::float_to_fixed (p), &actual_sin, &actual_cos); - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_sin, actual_sin, SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_cos, actual_cos, SIN_COS_TOLERANCE); - } -} diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt.h b/gnuradio-core/src/lib/general/qa_gr_fxpt.h deleted file mode 100644 index 72211563e7..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_QA_GR_FXPT_H -#define INCLUDED_QA_GR_FXPT_H - - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fxpt : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fxpt); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void t0 (); - void t1 (); - void t2 (); - void t3 (); - -}; - -#endif /* INCLUDED_QA_GR_FXPT_H */ - - diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc deleted file mode 100644 index 6f208eac80..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <qa_gr_fxpt_nco.h> -#include <gr_fxpt_nco.h> -#include <gr_nco.h> -#include <cppunit/TestAssert.h> -#include <iostream> -#include <stdio.h> -#include <unistd.h> -#include <math.h> - -static const float SIN_COS_TOLERANCE = 1e-5; - -//static const float SIN_COS_FREQ = 5003; -static const float SIN_COS_FREQ = 4096; - -static const int SIN_COS_BLOCK_SIZE = 100000; - -static double max_d(double a, double b) -{ - return fabs(a) > fabs(b) ? a : b; -} - -void -qa_gr_fxpt_nco::t0 () -{ - gr_nco<float,float> ref_nco; - gr_fxpt_nco new_nco; - double max_error = 0, max_phase_error = 0; - - ref_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); - new_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); - - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE); - - for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - float ref_sin = ref_nco.sin (); - float new_sin = new_nco.sin (); - //printf ("i = %6d\n", i); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_sin, new_sin, SIN_COS_TOLERANCE); - - max_error = max_d (max_error, ref_sin-new_sin); - - float ref_cos = ref_nco.cos (); - float new_cos = new_nco.cos (); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_cos, new_cos, SIN_COS_TOLERANCE); - - max_error = max_d (max_error, ref_cos-new_cos); - - ref_nco.step (); - new_nco.step (); - - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE); - - max_phase_error = max_d (max_phase_error, ref_nco.get_phase()-new_nco.get_phase()); - } - // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); -} - -void -qa_gr_fxpt_nco::t1 () -{ - gr_nco<float,float> ref_nco; - gr_fxpt_nco new_nco; - gr_complex ref_block[SIN_COS_BLOCK_SIZE]; - gr_complex new_block[SIN_COS_BLOCK_SIZE]; - double max_error = 0; - - ref_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); - new_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); - - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE); - - ref_nco.sincos ((gr_complex*)ref_block, SIN_COS_BLOCK_SIZE); - new_nco.sincos ((gr_complex*)new_block, SIN_COS_BLOCK_SIZE); - - for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i].real(), new_block[i].real(), SIN_COS_TOLERANCE); - max_error = max_d (max_error, ref_block[i].real()-new_block[i].real()); - - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i].imag(), new_block[i].imag(), SIN_COS_TOLERANCE); - max_error = max_d (max_error, ref_block[i].imag()-new_block[i].imag()); - } - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE); - // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); -} - -void -qa_gr_fxpt_nco::t2 () -{ -} - -void -qa_gr_fxpt_nco::t3 () -{ -} diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.h b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.h deleted file mode 100644 index 8998922bbb..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_QA_GR_FXPT_NCO_H -#define INCLUDED_QA_GR_FXPT_NCO_H - - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fxpt_nco : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fxpt_nco); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void t0 (); - void t1 (); - void t2 (); - void t3 (); - -}; - -#endif /* INCLUDED_QA_GR_FXPT_NCO_H */ - - diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc deleted file mode 100644 index 5b6993a30c..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <qa_gr_fxpt_vco.h> -#include <gr_fxpt_vco.h> -#include <gr_vco.h> -#include <cppunit/TestAssert.h> -#include <iostream> -#include <stdio.h> -#include <unistd.h> -#include <math.h> - -static const float SIN_COS_TOLERANCE = 1e-5; - -static const float SIN_COS_K = 0.42; -static const float SIN_COS_AMPL = 0.8; - -static const int SIN_COS_BLOCK_SIZE = 100000; - -static double max_d(double a, double b) -{ - return fabs(a) > fabs(b) ? a : b; -} - -void -qa_gr_fxpt_vco::t0 () -{ - gr_vco<float,float> ref_vco; - gr_fxpt_vco new_vco; - double max_error = 0, max_phase_error = 0; - float input[SIN_COS_BLOCK_SIZE]; - - for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - input[i] = sin(double(i)); - } - - for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - float ref_cos = ref_vco.cos (); - float new_cos = new_vco.cos (); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_cos, new_cos, SIN_COS_TOLERANCE); - - max_error = max_d (max_error, ref_cos-new_cos); - - ref_vco.adjust_phase (input[i]); - new_vco.adjust_phase (input[i]); - - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_vco.get_phase(), new_vco.get_phase(), SIN_COS_TOLERANCE); - - max_phase_error = max_d (max_phase_error, ref_vco.get_phase()-new_vco.get_phase()); - } - // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); -} - - -void -qa_gr_fxpt_vco::t1 () -{ - gr_vco<float,float> ref_vco; - gr_fxpt_vco new_vco; - float ref_block[SIN_COS_BLOCK_SIZE]; - float new_block[SIN_COS_BLOCK_SIZE]; - float input[SIN_COS_BLOCK_SIZE]; - double max_error = 0; - - for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - input[i] = sin(double(i)); - } - - ref_vco.cos (ref_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL); - new_vco.cos (new_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL); - - for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i], new_block[i], SIN_COS_TOLERANCE); - max_error = max_d (max_error, ref_block[i]-new_block[i]); - } - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_vco.get_phase(), new_vco.get_phase(), SIN_COS_TOLERANCE); - // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, ref_vco.get_phase()-new_vco.get_phase()); -} - -void -qa_gr_fxpt_vco::t2 () -{ -} - -void -qa_gr_fxpt_vco::t3 () -{ -} diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.h b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.h deleted file mode 100644 index fab8022e36..0000000000 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_QA_GR_FXPT_VCO_H -#define INCLUDED_QA_GR_FXPT_VCO_H - - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fxpt_vco : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fxpt_vco); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void t0 (); - void t1 (); - void t2 (); - void t3 (); - -}; - -#endif /* INCLUDED_QA_GR_FXPT_VCO_H */ - - |