From 7c0f5550d06e9c5e2ab413e3e2b95a843a435135 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 4 Jul 2012 11:16:02 -0700 Subject: volk: fix volk_32f_x2_dot_prod_32f_u_sse tail case --- volk/include/volk/volk_32f_x2_dot_prod_32f_u.h | 3 --- volk/lib/testqa.cc | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/volk/include/volk/volk_32f_x2_dot_prod_32f_u.h b/volk/include/volk/volk_32f_x2_dot_prod_32f_u.h index ab33a2587..c43d229df 100644 --- a/volk/include/volk/volk_32f_x2_dot_prod_32f_u.h +++ b/volk/include/volk/volk_32f_x2_dot_prod_32f_u.h @@ -87,9 +87,6 @@ static inline void volk_32f_x2_dot_prod_32f_u_sse( float* result, const float* number = sixteenthPoints*16; for(;number < num_points; number++){ dotProduct += ((*aPtr++) * (*bPtr++)); - dotProduct += ((*aPtr++) * (*bPtr++)); - dotProduct += ((*aPtr++) * (*bPtr++)); - dotProduct += ((*aPtr++) * (*bPtr++)); } *result = dotProduct; diff --git a/volk/lib/testqa.cc b/volk/lib/testqa.cc index d1eb1cacb..507c78777 100644 --- a/volk/lib/testqa.cc +++ b/volk/lib/testqa.cc @@ -54,7 +54,7 @@ VOLK_RUN_TESTS(volk_32fc_x2_square_dist_32f_a, 1e-4, 0, 20460, 1); VOLK_RUN_TESTS(volk_32fc_x2_s32f_square_dist_scalar_mult_32f_a, 1e-4, 10, 20460, 1); VOLK_RUN_TESTS(volk_32f_x2_divide_32f_a, 1e-4, 0, 20460, 1); VOLK_RUN_TESTS(volk_32f_x2_dot_prod_32f_a, 1e-4, 0, 204600, 1); -//VOLK_RUN_TESTS(volk_32f_x2_dot_prod_32f_u, 1e-4, 0, 204600, 1); +VOLK_RUN_TESTS(volk_32f_x2_dot_prod_32f_u, 1e-4, 0, 204600, 1); VOLK_RUN_TESTS(volk_32f_x2_dot_prod_16i_a, 1e-4, 0, 204600, 1); //VOLK_RUN_TESTS(volk_32f_s32f_32f_fm_detect_32f_a, 1e-4, 2046, 10000); VOLK_RUN_TESTS(volk_32f_index_max_16u_a, 3, 0, 20460, 1); -- cgit From 61dd97409abde2412595fa762c0c4161863604f4 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 4 Jul 2012 11:17:48 -0700 Subject: volk: use loadu for unaligned volk_32f_x2_dot_prod_32f_u_sse* --- volk/include/volk/volk_32f_x2_dot_prod_32f_u.h | 48 +++++++++++++------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/volk/include/volk/volk_32f_x2_dot_prod_32f_u.h b/volk/include/volk/volk_32f_x2_dot_prod_32f_u.h index c43d229df..b24e8b1f7 100644 --- a/volk/include/volk/volk_32f_x2_dot_prod_32f_u.h +++ b/volk/include/volk/volk_32f_x2_dot_prod_32f_u.h @@ -48,14 +48,14 @@ static inline void volk_32f_x2_dot_prod_32f_u_sse( float* result, const float* for(;number < sixteenthPoints; number++){ - a0Val = _mm_load_ps(aPtr); - a1Val = _mm_load_ps(aPtr+4); - a2Val = _mm_load_ps(aPtr+8); - a3Val = _mm_load_ps(aPtr+12); - b0Val = _mm_load_ps(bPtr); - b1Val = _mm_load_ps(bPtr+4); - b2Val = _mm_load_ps(bPtr+8); - b3Val = _mm_load_ps(bPtr+12); + a0Val = _mm_loadu_ps(aPtr); + a1Val = _mm_loadu_ps(aPtr+4); + a2Val = _mm_loadu_ps(aPtr+8); + a3Val = _mm_loadu_ps(aPtr+12); + b0Val = _mm_loadu_ps(bPtr); + b1Val = _mm_loadu_ps(bPtr+4); + b2Val = _mm_loadu_ps(bPtr+8); + b3Val = _mm_loadu_ps(bPtr+12); c0Val = _mm_mul_ps(a0Val, b0Val); c1Val = _mm_mul_ps(a1Val, b1Val); @@ -118,14 +118,14 @@ static inline void volk_32f_x2_dot_prod_32f_u_sse3(float * result, const float * for(;number < sixteenthPoints; number++){ - a0Val = _mm_load_ps(aPtr); - a1Val = _mm_load_ps(aPtr+4); - a2Val = _mm_load_ps(aPtr+8); - a3Val = _mm_load_ps(aPtr+12); - b0Val = _mm_load_ps(bPtr); - b1Val = _mm_load_ps(bPtr+4); - b2Val = _mm_load_ps(bPtr+8); - b3Val = _mm_load_ps(bPtr+12); + a0Val = _mm_loadu_ps(aPtr); + a1Val = _mm_loadu_ps(aPtr+4); + a2Val = _mm_loadu_ps(aPtr+8); + a3Val = _mm_loadu_ps(aPtr+12); + b0Val = _mm_loadu_ps(bPtr); + b1Val = _mm_loadu_ps(bPtr+4); + b2Val = _mm_loadu_ps(bPtr+8); + b3Val = _mm_loadu_ps(bPtr+12); c0Val = _mm_mul_ps(a0Val, b0Val); c1Val = _mm_mul_ps(a1Val, b1Val); @@ -184,15 +184,15 @@ static inline void volk_32f_x2_dot_prod_32f_u_sse4_1(float * result, const float for(;number < sixteenthPoints; number++){ - aVal1 = _mm_load_ps(aPtr); aPtr += 4; - aVal2 = _mm_load_ps(aPtr); aPtr += 4; - aVal3 = _mm_load_ps(aPtr); aPtr += 4; - aVal4 = _mm_load_ps(aPtr); aPtr += 4; + aVal1 = _mm_loadu_ps(aPtr); aPtr += 4; + aVal2 = _mm_loadu_ps(aPtr); aPtr += 4; + aVal3 = _mm_loadu_ps(aPtr); aPtr += 4; + aVal4 = _mm_loadu_ps(aPtr); aPtr += 4; - bVal1 = _mm_load_ps(bPtr); bPtr += 4; - bVal2 = _mm_load_ps(bPtr); bPtr += 4; - bVal3 = _mm_load_ps(bPtr); bPtr += 4; - bVal4 = _mm_load_ps(bPtr); bPtr += 4; + bVal1 = _mm_loadu_ps(bPtr); bPtr += 4; + bVal2 = _mm_loadu_ps(bPtr); bPtr += 4; + bVal3 = _mm_loadu_ps(bPtr); bPtr += 4; + bVal4 = _mm_loadu_ps(bPtr); bPtr += 4; cVal1 = _mm_dp_ps(aVal1, bVal1, 0xF1); cVal2 = _mm_dp_ps(aVal2, bVal2, 0xF2); -- cgit From 3a142bebafdc018bccc80cf124a375b53db03581 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sat, 7 Jul 2012 08:34:38 -0700 Subject: Revert "Merge remote branch 'jblum-github/python_blocks2' into master" This reverts commit f8581fb475267e1a97eaab962e423559fb4bfce2, reversing changes made to 73800434abfb8c6efcf069222b5f0fea9c86870b. --- gnuradio-core/CMakeLists.txt | 4 +- gnuradio-core/src/lib/general/CMakeLists.txt | 1 - gnuradio-core/src/lib/general/general.i | 3 +- gnuradio-core/src/lib/general/gr_block_gateway.cc | 184 ---------------- gnuradio-core/src/lib/general/gr_block_gateway.h | 212 ------------------- gnuradio-core/src/lib/general/gr_block_gateway.i | 46 ---- .../src/python/gnuradio/gr/CMakeLists.txt | 3 - gnuradio-core/src/python/gnuradio/gr/__init__.py | 3 +- gnuradio-core/src/python/gnuradio/gr/gateway.py | 215 ------------------- .../src/python/gnuradio/gr/qa_block_gateway.py | 235 --------------------- 10 files changed, 4 insertions(+), 902 deletions(-) delete mode 100644 gnuradio-core/src/lib/general/gr_block_gateway.cc delete mode 100644 gnuradio-core/src/lib/general/gr_block_gateway.h delete mode 100644 gnuradio-core/src/lib/general/gr_block_gateway.i delete mode 100644 gnuradio-core/src/python/gnuradio/gr/gateway.py delete mode 100644 gnuradio-core/src/python/gnuradio/gr/qa_block_gateway.py diff --git a/gnuradio-core/CMakeLists.txt b/gnuradio-core/CMakeLists.txt index 5f26216d3..4e76b3c5a 100644 --- a/gnuradio-core/CMakeLists.txt +++ b/gnuradio-core/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2010-2012 Free Software Foundation, Inc. +# Copyright 2010-2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -64,7 +64,7 @@ GR_SET_GLOBAL(GNURADIO_CORE_INCLUDE_DIRS GR_SET_GLOBAL(GNURADIO_CORE_SWIG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/gruel/src/swig - ${CMAKE_BINARY_DIR}/gruel/src/swig + ${CMAKE_BINARY_DIR}/gruel/src/swig/ ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/swig ${GNURADIO_CORE_INCLUDE_DIRS} ) diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index 53cb16d38..5c7b0f374 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -187,7 +187,6 @@ set(gr_core_general_triple_threats gr_agc2_ff gr_align_on_samplenumbers_ss gr_bin_statistics_f - gr_block_gateway gr_bytes_to_syms gr_char_to_float gr_char_to_short diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 31acaefb8..c0ce65527 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004-2012 Free Software Foundation, Inc. + * Copyright 2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -264,4 +264,3 @@ %include "gr_add_ff.i" %include "gr_vector_map.i" %include "gr_tag_debug.i" -%include "gr_block_gateway.i" diff --git a/gnuradio-core/src/lib/general/gr_block_gateway.cc b/gnuradio-core/src/lib/general/gr_block_gateway.cc deleted file mode 100644 index 79b42803a..000000000 --- a/gnuradio-core/src/lib/general/gr_block_gateway.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2011-2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include - -/*********************************************************************** - * Helper routines - **********************************************************************/ -template -void copy_pointers(OutType &out, const InType &in){ - out.resize(in.size()); - for (size_t i = 0; i < in.size(); i++){ - out[i] = (void *)(in[i]); - } -} - -/*********************************************************************** - * The gr_block gateway implementation class - **********************************************************************/ -class gr_block_gateway_impl : public gr_block_gateway{ -public: - gr_block_gateway_impl( - gr_feval_ll *handler, - const std::string &name, - gr_io_signature_sptr in_sig, - gr_io_signature_sptr out_sig, - const gr_block_gw_work_type work_type, - const unsigned factor - ): - gr_block(name, in_sig, out_sig), - _handler(handler), - _work_type(work_type) - { - switch(_work_type){ - case GR_BLOCK_GW_WORK_GENERAL: - _decim = 1; //not relevant, but set anyway - _interp = 1; //not relevant, but set anyway - break; - - case GR_BLOCK_GW_WORK_SYNC: - _decim = 1; - _interp = 1; - this->set_fixed_rate(true); - break; - - case GR_BLOCK_GW_WORK_DECIM: - _decim = factor; - _interp = 1; - break; - - case GR_BLOCK_GW_WORK_INTERP: - _decim = 1; - _interp = factor; - this->set_output_multiple(_interp); - break; - } - } - - /******************************************************************* - * Overloads for various scheduler-called functions - ******************************************************************/ - void forecast( - int noutput_items, - gr_vector_int &ninput_items_required - ){ - switch(_work_type){ - case GR_BLOCK_GW_WORK_GENERAL: - _message.action = gr_block_gw_message_type::ACTION_FORECAST; - _message.forecast_args_noutput_items = noutput_items; - _message.forecast_args_ninput_items_required = ninput_items_required; - _handler->calleval(0); - ninput_items_required = _message.forecast_args_ninput_items_required; - return; - - default: - unsigned ninputs = ninput_items_required.size(); - for (unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = fixed_rate_noutput_to_ninput(noutput_items); - return; - } - } - - int general_work( - int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items - ){ - switch(_work_type){ - case GR_BLOCK_GW_WORK_GENERAL: - _message.action = gr_block_gw_message_type::ACTION_GENERAL_WORK; - _message.general_work_args_noutput_items = noutput_items; - _message.general_work_args_ninput_items = ninput_items; - copy_pointers(_message.general_work_args_input_items, input_items); - _message.general_work_args_output_items = output_items; - _handler->calleval(0); - return _message.general_work_args_return_value; - - default: - int r = work (noutput_items, input_items, output_items); - if (r > 0) consume_each(r*_decim/_interp); - return r; - } - } - - int work( - int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items - ){ - _message.action = gr_block_gw_message_type::ACTION_WORK; - _message.work_args_ninput_items = fixed_rate_noutput_to_ninput(noutput_items); - if (_message.work_args_ninput_items == 0) return -1; - _message.work_args_noutput_items = noutput_items; - copy_pointers(_message.work_args_input_items, input_items); - _message.work_args_output_items = output_items; - _handler->calleval(0); - return _message.work_args_return_value; - } - - int fixed_rate_noutput_to_ninput(int noutput_items){ - return (noutput_items*_decim/_interp) + history() - 1; - } - - int fixed_rate_ninput_to_noutput(int ninput_items){ - return std::max(0, ninput_items - (int)history() + 1)*_interp/_decim; - } - - bool start(void){ - _message.action = gr_block_gw_message_type::ACTION_START; - _handler->calleval(0); - return _message.start_args_return_value; - } - - bool stop(void){ - _message.action = gr_block_gw_message_type::ACTION_STOP; - _handler->calleval(0); - return _message.stop_args_return_value; - } - - gr_block_gw_message_type &gr_block_message(void){ - return _message; - } - -private: - gr_feval_ll *_handler; - gr_block_gw_message_type _message; - const gr_block_gw_work_type _work_type; - unsigned _decim, _interp; -}; - -boost::shared_ptr gr_make_block_gateway( - gr_feval_ll *handler, - const std::string &name, - gr_io_signature_sptr in_sig, - gr_io_signature_sptr out_sig, - const gr_block_gw_work_type work_type, - const unsigned factor -){ - return boost::shared_ptr( - new gr_block_gateway_impl(handler, name, in_sig, out_sig, work_type, factor) - ); -} diff --git a/gnuradio-core/src/lib/general/gr_block_gateway.h b/gnuradio-core/src/lib/general/gr_block_gateway.h deleted file mode 100644 index ae91d41b5..000000000 --- a/gnuradio-core/src/lib/general/gr_block_gateway.h +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright 2011-2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRBLOCK_GATEWAY_H -#define INCLUDED_GRBLOCK_GATEWAY_H - -#include -#include -#include - -/*! - * The work type enum tells the gateway what kind of block to implement. - * The choices are familiar gnuradio block overloads (sync, decim, interp). - */ -enum gr_block_gw_work_type{ - GR_BLOCK_GW_WORK_GENERAL, - GR_BLOCK_GW_WORK_SYNC, - GR_BLOCK_GW_WORK_DECIM, - GR_BLOCK_GW_WORK_INTERP, -}; - -/*! - * Shared message structure between python and gateway. - * Each action type represents a scheduler-called function. - */ -struct gr_block_gw_message_type{ - enum action_type{ - ACTION_GENERAL_WORK, //dispatch work - ACTION_WORK, //dispatch work - ACTION_FORECAST, //dispatch forecast - ACTION_START, //dispatch start - ACTION_STOP, //dispatch stop - }; - - action_type action; - - int general_work_args_noutput_items; - std::vector general_work_args_ninput_items; - std::vector general_work_args_input_items; //TODO this should be const void*, but swig cant int cast it right - std::vector general_work_args_output_items; - int general_work_args_return_value; - - int work_args_ninput_items; - int work_args_noutput_items; - std::vector work_args_input_items; //TODO this should be const void*, but swig cant int cast it right - std::vector work_args_output_items; - int work_args_return_value; - - int forecast_args_noutput_items; - std::vector forecast_args_ninput_items_required; - - bool start_args_return_value; - - bool stop_args_return_value; -}; - -/*! - * The gateway block which performs all the magic. - * - * The gateway provides access to all the gr_block routines. - * The methods prefixed with gr_block__ are renamed - * to class methods without the prefix in python. - */ -class GR_CORE_API gr_block_gateway : virtual public gr_block{ -public: - //! Provide access to the shared message object - virtual gr_block_gw_message_type &gr_block_message(void) = 0; - - long gr_block__unique_id(void) const{ - return gr_block::unique_id(); - } - - std::string gr_block__name(void) const{ - return gr_block::name(); - } - - unsigned gr_block__history(void) const{ - return gr_block::history(); - } - - void gr_block__set_history(unsigned history){ - return gr_block::set_history(history); - } - - void gr_block__set_fixed_rate(bool fixed_rate){ - return gr_block::set_fixed_rate(fixed_rate); - } - - bool gr_block__fixed_rate(void) const{ - return gr_block::fixed_rate(); - } - - void gr_block__set_output_multiple(int multiple){ - return gr_block::set_output_multiple(multiple); - } - - int gr_block__output_multiple(void) const{ - return gr_block::output_multiple(); - } - - void gr_block__consume(int which_input, int how_many_items){ - return gr_block::consume(which_input, how_many_items); - } - - void gr_block__consume_each(int how_many_items){ - return gr_block::consume_each(how_many_items); - } - - void gr_block__produce(int which_output, int how_many_items){ - return gr_block::produce(which_output, how_many_items); - } - - void gr_block__set_relative_rate(double relative_rate){ - return gr_block::set_relative_rate(relative_rate); - } - - double gr_block__relative_rate(void) const{ - return gr_block::relative_rate(); - } - - uint64_t gr_block__nitems_read(unsigned int which_input){ - return gr_block::nitems_read(which_input); - } - - uint64_t gr_block__nitems_written(unsigned int which_output){ - return gr_block::nitems_written(which_output); - } - - gr_block::tag_propagation_policy_t gr_block__tag_propagation_policy(void){ - return gr_block::tag_propagation_policy(); - } - - void gr_block__set_tag_propagation_policy(gr_block::tag_propagation_policy_t p){ - return gr_block::set_tag_propagation_policy(p); - } - - void gr_block__add_item_tag( - unsigned int which_output, const gr_tag_t &tag - ){ - return gr_block::add_item_tag(which_output, tag); - } - - void gr_block__add_item_tag( - unsigned int which_output, - uint64_t abs_offset, - const pmt::pmt_t &key, - const pmt::pmt_t &value, - const pmt::pmt_t &srcid=pmt::PMT_F - ){ - return gr_block::add_item_tag(which_output, abs_offset, key, value, srcid); - } - - std::vector gr_block__get_tags_in_range( - unsigned int which_input, - uint64_t abs_start, - uint64_t abs_end - ){ - std::vector tags; - gr_block::get_tags_in_range(tags, which_input, abs_start, abs_end); - return tags; - } - - std::vector gr_block__get_tags_in_range( - unsigned int which_input, - uint64_t abs_start, - uint64_t abs_end, - const pmt::pmt_t &key - ){ - std::vector tags; - gr_block::get_tags_in_range(tags, which_input, abs_start, abs_end, key); - return tags; - } -}; - -/*! - * Make a new gateway block. - * \param handler the swig director object with callback - * \param name the name of the block (Ex: "Shirley") - * \param in_sig the input signature for this block - * \param out_sig the output signature for this block - * \param work_type the type of block overload to implement - * \param factor the decimation or interpolation factor - * \return a new gateway block - */ -GR_CORE_API boost::shared_ptr gr_make_block_gateway( - gr_feval_ll *handler, - const std::string &name, - gr_io_signature_sptr in_sig, - gr_io_signature_sptr out_sig, - const gr_block_gw_work_type work_type, - const unsigned factor -); - -#endif /* INCLUDED_GRBLOCK_GATEWAY_H */ diff --git a/gnuradio-core/src/lib/general/gr_block_gateway.i b/gnuradio-core/src/lib/general/gr_block_gateway.i deleted file mode 100644 index 8adafdfea..000000000 --- a/gnuradio-core/src/lib/general/gr_block_gateway.i +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2011-2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -//////////////////////////////////////////////////////////////////////// -// standard includes -//////////////////////////////////////////////////////////////////////// -%include -%include -%include - -//////////////////////////////////////////////////////////////////////// -// block headers -//////////////////////////////////////////////////////////////////////// -%{ -#include -%} - -//////////////////////////////////////////////////////////////////////// -// data type support -//////////////////////////////////////////////////////////////////////// -%template(int_vector_t) std::vector; -%template(void_star_vector_t) std::vector; - -//////////////////////////////////////////////////////////////////////// -// block magic -//////////////////////////////////////////////////////////////////////// -GR_SWIG_BLOCK_MAGIC(gr,block_gateway); -%include diff --git a/gnuradio-core/src/python/gnuradio/gr/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/gr/CMakeLists.txt index 62f3d7e46..3e75ead03 100644 --- a/gnuradio-core/src/python/gnuradio/gr/CMakeLists.txt +++ b/gnuradio-core/src/python/gnuradio/gr/CMakeLists.txt @@ -23,7 +23,6 @@ include(GrPython) GR_PYTHON_INSTALL(FILES __init__.py exceptions.py - gateway.py gr_threading.py gr_threading_23.py gr_threading_24.py @@ -44,8 +43,6 @@ file(GLOB py_qa_test_files "qa_*.py") foreach(py_qa_test_file ${py_qa_test_files}) get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE) set(GR_TEST_PYTHON_DIRS - ${CMAKE_SOURCE_DIR}/gruel/src/python - ${CMAKE_BINARY_DIR}/gruel/src/swig ${CMAKE_BINARY_DIR}/gnuradio-core/src/python ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/swig ) diff --git a/gnuradio-core/src/python/gnuradio/gr/__init__.py b/gnuradio-core/src/python/gnuradio/gr/__init__.py index 5b9a6a32c..602d1119f 100644 --- a/gnuradio-core/src/python/gnuradio/gr/__init__.py +++ b/gnuradio-core/src/python/gnuradio/gr/__init__.py @@ -1,5 +1,5 @@ # -# Copyright 2003-2012 Free Software Foundation, Inc. +# Copyright 2003,2004,2006,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -44,7 +44,6 @@ from gnuradio_core import * from exceptions import * from hier_block2 import * from top_block import * -from gateway import basic_block, sync_block, decim_block, interp_block if _RTLD_GLOBAL != 0: sys.setdlopenflags(_dlopenflags) # Restore original flags diff --git a/gnuradio-core/src/python/gnuradio/gr/gateway.py b/gnuradio-core/src/python/gnuradio/gr/gateway.py deleted file mode 100644 index 244b8b592..000000000 --- a/gnuradio-core/src/python/gnuradio/gr/gateway.py +++ /dev/null @@ -1,215 +0,0 @@ -# -# Copyright 2011-2012 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -import gnuradio_core as gr_core -from gnuradio_core import io_signature, io_signaturev -from gnuradio_core import gr_block_gw_message_type -from gnuradio_core import block_gateway -import numpy - -######################################################################## -# Magic to turn pointers into numpy arrays -# http://docs.scipy.org/doc/numpy/reference/arrays.interface.html -######################################################################## -def pointer_to_ndarray(addr, dtype, nitems): - class array_like: - __array_interface__ = { - 'data' : (int(addr), False), - 'typestr' : dtype.base.str, - 'descr' : dtype.base.descr, - 'shape' : (nitems,) + dtype.shape, - 'strides' : None, - 'version' : 3 - } - return numpy.asarray(array_like()).view(dtype.base) - -######################################################################## -# Handler that does callbacks from C++ -######################################################################## -class gateway_handler(gr_core.feval_ll): - - #dont put a constructor, it wont work - - def init(self, callback): - self._callback = callback - - def eval(self, arg): - try: self._callback() - except Exception as ex: - print("handler caught exception: %s"%ex) - import traceback; traceback.print_exc() - raise ex - return 0 - -######################################################################## -# The guts that make this into a gr block -######################################################################## -class gateway_block(object): - - def __init__(self, name, in_sig, out_sig, work_type, factor): - - #ensure that the sigs are iterable dtypes - def sig_to_dtype_sig(sig): - if sig is None: sig = () - return map(numpy.dtype, sig) - self.__in_sig = sig_to_dtype_sig(in_sig) - self.__out_sig = sig_to_dtype_sig(out_sig) - - #cache the ranges to iterate when dispatching work - self.__in_indexes = range(len(self.__in_sig)) - self.__out_indexes = range(len(self.__out_sig)) - - #convert the signatures into gr.io_signatures - def sig_to_gr_io_sigv(sig): - if not len(sig): return io_signature(0, 0, 0) - return io_signaturev(len(sig), len(sig), [s.itemsize for s in sig]) - gr_in_sig = sig_to_gr_io_sigv(self.__in_sig) - gr_out_sig = sig_to_gr_io_sigv(self.__out_sig) - - #create internal gateway block - self.__handler = gateway_handler() - self.__handler.init(self.__gr_block_handle) - self.__gateway = block_gateway( - self.__handler, name, gr_in_sig, gr_out_sig, work_type, factor) - self.__message = self.__gateway.gr_block_message() - - #register gr_block functions - prefix = 'gr_block__' - for attr in [x for x in dir(self.__gateway) if x.startswith(prefix)]: - setattr(self, attr.replace(prefix, ''), getattr(self.__gateway, attr)) - self.pop_msg_queue = lambda: gr_core.gr_block_gw_pop_msg_queue_safe(self.__gateway) - - def to_basic_block(self): - """ - Makes this block connectable by hier/top block python - """ - return self.__gateway.to_basic_block() - - def __gr_block_handle(self): - """ - Dispatch tasks according to the action type specified in the message. - """ - if self.__message.action == gr_block_gw_message_type.ACTION_GENERAL_WORK: - self.__message.general_work_args_return_value = self.general_work( - - input_items=[pointer_to_ndarray( - self.__message.general_work_args_input_items[i], - self.__in_sig[i], - self.__message.general_work_args_ninput_items[i] - ) for i in self.__in_indexes], - - output_items=[pointer_to_ndarray( - self.__message.general_work_args_output_items[i], - self.__out_sig[i], - self.__message.general_work_args_noutput_items - ) for i in self.__out_indexes], - ) - - elif self.__message.action == gr_block_gw_message_type.ACTION_WORK: - self.__message.work_args_return_value = self.work( - - input_items=[pointer_to_ndarray( - self.__message.work_args_input_items[i], - self.__in_sig[i], - self.__message.work_args_ninput_items - ) for i in self.__in_indexes], - - output_items=[pointer_to_ndarray( - self.__message.work_args_output_items[i], - self.__out_sig[i], - self.__message.work_args_noutput_items - ) for i in self.__out_indexes], - ) - - elif self.__message.action == gr_block_gw_message_type.ACTION_FORECAST: - self.forecast( - noutput_items=self.__message.forecast_args_noutput_items, - ninput_items_required=self.__message.forecast_args_ninput_items_required, - ) - - elif self.__message.action == gr_block_gw_message_type.ACTION_START: - self.__message.start_args_return_value = self.start() - - elif self.__message.action == gr_block_gw_message_type.ACTION_STOP: - self.__message.stop_args_return_value = self.stop() - - def forecast(self, noutput_items, ninput_items_required): - """ - forecast is only called from a general block - this is the default implementation - """ - for ninput_item in ninput_items_required: - ninput_item = noutput_items + self.history() - 1; - return - - def general_work(self, *args, **kwargs): - """general work to be overloaded in a derived class""" - raise NotImplementedError("general work not implemented") - - def work(self, *args, **kwargs): - """work to be overloaded in a derived class""" - raise NotImplementedError("work not implemented") - - def start(self): return True - def stop(self): return True - -######################################################################## -# Wrappers for the user to inherit from -######################################################################## -class basic_block(gateway_block): - def __init__(self, name, in_sig, out_sig): - gateway_block.__init__(self, - name=name, - in_sig=in_sig, - out_sig=out_sig, - work_type=gr_core.GR_BLOCK_GW_WORK_GENERAL, - factor=1, #not relevant factor - ) - -class sync_block(gateway_block): - def __init__(self, name, in_sig, out_sig): - gateway_block.__init__(self, - name=name, - in_sig=in_sig, - out_sig=out_sig, - work_type=gr_core.GR_BLOCK_GW_WORK_SYNC, - factor=1, - ) - -class decim_block(gateway_block): - def __init__(self, name, in_sig, out_sig, decim): - gateway_block.__init__(self, - name=name, - in_sig=in_sig, - out_sig=out_sig, - work_type=gr_core.GR_BLOCK_GW_WORK_DECIM, - factor=decim, - ) - -class interp_block(gateway_block): - def __init__(self, name, in_sig, out_sig, interp): - gateway_block.__init__(self, - name=name, - in_sig=in_sig, - out_sig=out_sig, - work_type=gr_core.GR_BLOCK_GW_WORK_INTERP, - factor=interp, - ) diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_block_gateway.py b/gnuradio-core/src/python/gnuradio/gr/qa_block_gateway.py deleted file mode 100644 index 89eb8aed6..000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_block_gateway.py +++ /dev/null @@ -1,235 +0,0 @@ -# -# Copyright 2011-2012 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import pmt #from gruel import pmt -import numpy - -class add_2_f32_1_f32(gr.sync_block): - def __init__(self): - gr.sync_block.__init__( - self, - name = "add 2 f32", - in_sig = [numpy.float32, numpy.float32], - out_sig = [numpy.float32], - ) - - def work(self, input_items, output_items): - output_items[0][:] = input_items[0] + input_items[1] - return len(output_items[0]) - -class add_2_fc32_1_fc32(gr.sync_block): - def __init__(self): - gr.sync_block.__init__( - self, - name = "add 2 fc32", - in_sig = [numpy.complex64, numpy.complex64], - out_sig = [numpy.complex64], - ) - - def work(self, input_items, output_items): - output_items[0][:] = input_items[0] + input_items[1] - return len(output_items[0]) - -class convolve(gr.sync_block): - """ - A demonstration using block history to properly perform a convolution. - """ - def __init__(self): - gr.sync_block.__init__( - self, - name = "convolve", - in_sig = [numpy.float32], - out_sig = [numpy.float32] - ) - self._taps = [1, 0, 0, 0] - self.set_history(len(self._taps)) - - def work(self, input_items, output_items): - output_items[0][:] = numpy.convolve(input_items[0], self._taps, mode='valid') - return len(output_items[0]) - -class decim2x(gr.decim_block): - def __init__(self): - gr.decim_block.__init__( - self, - name = "decim2x", - in_sig = [numpy.float32], - out_sig = [numpy.float32], - decim = 2 - ) - - def work(self, input_items, output_items): - output_items[0][:] = input_items[0][::2] - return len(output_items[0]) - -class interp2x(gr.interp_block): - def __init__(self): - gr.interp_block.__init__( - self, - name = "interp2x", - in_sig = [numpy.float32], - out_sig = [numpy.float32], - interp = 2 - ) - - def work(self, input_items, output_items): - output_items[0][1::2] = input_items[0] - output_items[0][::2] = input_items[0] - return len(output_items[0]) - -class tag_source(gr.sync_block): - def __init__(self): - gr.sync_block.__init__( - self, - name = "tag source", - in_sig = None, - out_sig = [numpy.float32], - ) - - def work(self, input_items, output_items): - num_output_items = len(output_items[0]) - - #put code here to fill the output items... - - #make a new tag on the middle element every time work is called - count = self.nitems_written(0) + num_output_items/2 - key = pmt.pmt_string_to_symbol("example_key") - value = pmt.pmt_string_to_symbol("example_value") - self.add_item_tag(0, count, key, value) - - return num_output_items - -class tag_sink(gr.sync_block): - def __init__(self): - gr.sync_block.__init__( - self, - name = "tag sink", - in_sig = [numpy.float32], - out_sig = None, - ) - self.key = None - - def work(self, input_items, output_items): - num_input_items = len(input_items[0]) - - #put code here to process the input items... - - #print all the tags received in this work call - nread = self.nitems_read(0) - tags = self.get_tags_in_range(0, nread, nread+num_input_items) - for tag in tags: - print tag.offset - print pmt.pmt_symbol_to_string(tag.key) - print pmt.pmt_symbol_to_string(tag.value) - self.key = pmt.pmt_symbol_to_string(tag.key) - - return num_input_items - -class fc32_to_f32_2(gr.sync_block): - def __init__(self): - gr.sync_block.__init__( - self, - name = "fc32_to_f32_2", - in_sig = [numpy.complex64], - out_sig = [(numpy.float32, 2)], - ) - - def work(self, input_items, output_items): - output_items[0][::,0] = numpy.real(input_items[0]) - output_items[0][::,1] = numpy.imag(input_items[0]) - return len(output_items[0]) - -class test_block_gateway(gr_unittest.TestCase): - - def test_add_f32(self): - tb = gr.top_block() - src0 = gr.vector_source_f([1, 3, 5, 7, 9], False) - src1 = gr.vector_source_f([0, 2, 4, 6, 8], False) - adder = add_2_f32_1_f32() - sink = gr.vector_sink_f() - tb.connect((src0, 0), (adder, 0)) - tb.connect((src1, 0), (adder, 1)) - tb.connect(adder, sink) - tb.run() - self.assertEqual(sink.data(), (1, 5, 9, 13, 17)) - - def test_add_fc32(self): - tb = gr.top_block() - src0 = gr.vector_source_c([1, 3j, 5, 7j, 9], False) - src1 = gr.vector_source_c([0, 2j, 4, 6j, 8], False) - adder = add_2_fc32_1_fc32() - sink = gr.vector_sink_c() - tb.connect((src0, 0), (adder, 0)) - tb.connect((src1, 0), (adder, 1)) - tb.connect(adder, sink) - tb.run() - self.assertEqual(sink.data(), (1, 5j, 9, 13j, 17)) - - def test_convolve(self): - tb = gr.top_block() - src = gr.vector_source_f([1, 2, 3, 4, 5, 6, 7, 8], False) - cv = convolve() - sink = gr.vector_sink_f() - tb.connect(src, cv, sink) - tb.run() - self.assertEqual(sink.data(), (1, 2, 3, 4, 5, 6, 7, 8)) - - def test_decim2x(self): - tb = gr.top_block() - src = gr.vector_source_f([1, 2, 3, 4, 5, 6, 7, 8], False) - d2x = decim2x() - sink = gr.vector_sink_f() - tb.connect(src, d2x, sink) - tb.run() - self.assertEqual(sink.data(), (1, 3, 5, 7)) - - def test_interp2x(self): - tb = gr.top_block() - src = gr.vector_source_f([1, 3, 5, 7, 9], False) - i2x = interp2x() - sink = gr.vector_sink_f() - tb.connect(src, i2x, sink) - tb.run() - self.assertEqual(sink.data(), (1, 1, 3, 3, 5, 5, 7, 7, 9, 9)) - - def test_tags(self): - src = tag_source() - sink = tag_sink() - head = gr.head(gr.sizeof_float, 50000) #should be enough items to get a tag through - tb = gr.top_block() - tb.connect(src, head, sink) - tb.run() - self.assertEqual(sink.key, "example_key") - - def test_fc32_to_f32_2(self): - tb = gr.top_block() - src = gr.vector_source_c([1+2j, 3+4j, 5+6j, 7+8j, 9+10j], False) - convert = fc32_to_f32_2() - v2s = gr.vector_to_stream(gr.sizeof_float, 2) - sink = gr.vector_sink_f() - tb.connect(src, convert, v2s, sink) - tb.run() - self.assertEqual(sink.data(), (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) - -if __name__ == '__main__': - gr_unittest.run(test_block_gateway, "test_block_gateway.xml") - -- cgit From 71127c2d4082119ea086f9f881b349922ed8cf24 Mon Sep 17 00:00:00 2001 From: Wayne Roberts Date: Sun, 8 Jul 2012 16:57:01 -0400 Subject: digital: adding a GFSK mod/demodulator. Includes GRC files and an example in gr-digital/examples/demod --- gr-digital/examples/CMakeLists.txt | 1 + gr-digital/examples/demod/gfsk_loopback.grc | 646 ++++++++++++++++++++++++++++ gr-digital/grc/digital_gfsk_demod.xml | 95 ++++ gr-digital/grc/digital_gfsk_mod.xml | 74 ++++ gr-digital/python/CMakeLists.txt | 1 + gr-digital/python/__init__.py | 1 + gr-digital/python/gfsk.py | 306 +++++++++++++ 7 files changed, 1124 insertions(+) create mode 100644 gr-digital/examples/demod/gfsk_loopback.grc create mode 100644 gr-digital/grc/digital_gfsk_demod.xml create mode 100644 gr-digital/grc/digital_gfsk_mod.xml create mode 100644 gr-digital/python/gfsk.py diff --git a/gr-digital/examples/CMakeLists.txt b/gr-digital/examples/CMakeLists.txt index 33d257e59..63e1eba4e 100644 --- a/gr-digital/examples/CMakeLists.txt +++ b/gr-digital/examples/CMakeLists.txt @@ -71,6 +71,7 @@ install( demod/pam_timing.grc demod/ber_simulation.grc demod/dpsk_loopback.grc + demod/gfsk_loopback.grc DESTINATION ${GR_PKG_DIGITAL_EXAMPLES_DIR}/demod COMPONENT "digital_python" ) diff --git a/gr-digital/examples/demod/gfsk_loopback.grc b/gr-digital/examples/demod/gfsk_loopback.grc new file mode 100644 index 000000000..f74a83526 --- /dev/null +++ b/gr-digital/examples/demod/gfsk_loopback.grc @@ -0,0 +1,646 @@ + + + Sun Jul 8 16:56:18 2012 + + variable_slider + + id + freq + + + _enabled + True + + + label + Frequency (Hz) + + + value + 500 + + + min + 0 + + + max + samp_rate/2 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (34, 241) + + + _rotation + 0 + + + + gr_sig_source_x + + id + gr_sig_source_x_0 + + + _enabled + True + + + type + float + + + samp_rate + samp_rate + + + waveform + gr.GR_COS_WAVE + + + freq + freq + + + amp + 1 + + + offset + 0 + + + _coordinate + (215, 26) + + + _rotation + 0 + + + + gr_throttle + + id + gr_throttle_0_0 + + + _enabled + True + + + type + float + + + samples_per_second + samp_rate + + + vlen + 1 + + + _coordinate + (272.5, 142.0) + + + _rotation + 0 + + + + blks2_packet_encoder + + id + blks2_packet_encoder_0 + + + _enabled + True + + + type + float + + + samples_per_symbol + 2 + + + bits_per_symbol + 1 + + + access_code + + + + pad_for_usrp + True + + + payload_length + 0 + + + _coordinate + (261, 227) + + + _rotation + 0 + + + + variable + + id + samp_rate + + + _enabled + True + + + value + 10000 + + + _coordinate + (10, 170) + + + _rotation + 0 + + + + digital_gfsk_demod + + id + digital_gfsk_demod_0 + + + _enabled + True + + + samples_per_symbol + sps + + + sensitivity + fm_sensitivity + + + gain_mu + 0.175 + + + mu + 0.5 + + + omega_relative_limit + 0.005 + + + freq_error + 0.0 + + + verbose + False + + + log + False + + + _coordinate + (669, 257) + + + _rotation + 0 + + + + variable + + id + sps + + + _enabled + True + + + value + 8 + + + _coordinate + (47, 445) + + + _rotation + 0 + + + + digital_gfsk_mod + + id + digital_gfsk_mod_0 + + + _enabled + True + + + samples_per_symbol + sps + + + sensitivity + fm_sensitivity + + + bt + 0.35 + + + verbose + False + + + log + False + + + _coordinate + (456, 277) + + + _rotation + 0 + + + + variable + + id + fm_sensitivity + + + _enabled + True + + + value + 1.0 + + + _coordinate + (40, 366) + + + _rotation + 0 + + + + blks2_packet_decoder + + id + blks2_packet_decoder_0 + + + _enabled + True + + + type + float + + + access_code + + + + threshold + -1 + + + _coordinate + (705, 130) + + + _rotation + 0 + + + + gr_quadrature_demod_cf + + id + gr_quadrature_demod_cf_0 + + + _enabled + True + + + gain + 1 + + + _coordinate + (627, 417) + + + _rotation + 0 + + + + options + + id + gfsk_loopback + + + _enabled + True + + + title + + + + author + + + + description + + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + max_nouts + 0 + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + wxgui_scopesink2_0 + + + _enabled + True + + + type + float + + + title + Scope Plot + + + samp_rate + samp_rate + + + v_scale + 0 + + + v_offset + 0 + + + t_scale + 1./freq + + + ac_couple + False + + + xy_mode + False + + + num_inputs + 1 + + + win_size + + + + grid_pos + + + + notebook + + + + trig_mode + gr.gr_TRIG_MODE_AUTO + + + y_axis_label + Counts + + + _coordinate + (907, 59) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + wxgui_scopesink2_1 + + + _enabled + True + + + type + float + + + title + Scope Plot + + + samp_rate + samp_rate + + + v_scale + 0 + + + v_offset + 0 + + + t_scale + 0 + + + ac_couple + False + + + xy_mode + False + + + num_inputs + 1 + + + win_size + + + + grid_pos + + + + notebook + + + + trig_mode + gr.gr_TRIG_MODE_AUTO + + + y_axis_label + Counts + + + _coordinate + (853, 400) + + + _rotation + 0 + + + + digital_gfsk_mod_0 + digital_gfsk_demod_0 + 0 + 0 + + + gr_sig_source_x_0 + gr_throttle_0_0 + 0 + 0 + + + gr_throttle_0_0 + blks2_packet_encoder_0 + 0 + 0 + + + blks2_packet_encoder_0 + digital_gfsk_mod_0 + 0 + 0 + + + digital_gfsk_demod_0 + blks2_packet_decoder_0 + 0 + 0 + + + blks2_packet_decoder_0 + wxgui_scopesink2_0 + 0 + 0 + + + digital_gfsk_mod_0 + gr_quadrature_demod_cf_0 + 0 + 0 + + + gr_quadrature_demod_cf_0 + wxgui_scopesink2_1 + 0 + 0 + + diff --git a/gr-digital/grc/digital_gfsk_demod.xml b/gr-digital/grc/digital_gfsk_demod.xml new file mode 100644 index 000000000..ce3024d89 --- /dev/null +++ b/gr-digital/grc/digital_gfsk_demod.xml @@ -0,0 +1,95 @@ + + + + GFSK Demod + digital_gfsk_demod + from gnuradio import digital + digital.gfsk_demod( + samples_per_symbol=$samples_per_symbol, + sensitivity=$sensitivity, + gain_mu=$gain_mu, + mu=$mu, + omega_relative_limit=$omega_relative_limit, + freq_error=$freq_error, + verbose=$verbose, + log=$log, +) + + Samples/Symbol + samples_per_symbol + 2 + int + + + Sensitivity + sensitivity + 1.0 + real + + + Gain Mu + gain_mu + 0.175 + real + + + Mu + mu + 0.5 + real + + + Omega Relative Limit + omega_relative_limit + 0.005 + real + + + Freq Error + freq_error + 0.0 + real + + + Verbose + verbose + False + bool + #if str($verbose) == 'False' then 'part' else 'none'# + + + + + Logging + log + False + bool + #if str($log) == 'False' then 'part' else 'none'# + + + + + in + complex + + + out + byte + + diff --git a/gr-digital/grc/digital_gfsk_mod.xml b/gr-digital/grc/digital_gfsk_mod.xml new file mode 100644 index 000000000..2d6cd1ea5 --- /dev/null +++ b/gr-digital/grc/digital_gfsk_mod.xml @@ -0,0 +1,74 @@ + + + + GFSK Mod + digital_gfsk_mod + from gnuradio import digital + digital.gfsk_mod( + samples_per_symbol=$samples_per_symbol, + sensitivity=$sensitivity, + bt=$bt, + verbose=$verbose, + log=$log, +) + + Samples/Symbol + samples_per_symbol + 2 + int + + + Sensitivity + sensitivity + 1.0 + real + + + BT + bt + 0.35 + real + + + Verbose + verbose + False + bool + #if str($verbose) == 'False' then 'part' else 'none'# + + + + + Logging + log + False + bool + #if str($log) == 'False' then 'part' else 'none'# + + + + + in + byte + + + out + complex + + diff --git a/gr-digital/python/CMakeLists.txt b/gr-digital/python/CMakeLists.txt index c786b5a14..6a9f10295 100644 --- a/gr-digital/python/CMakeLists.txt +++ b/gr-digital/python/CMakeLists.txt @@ -30,6 +30,7 @@ GR_PYTHON_INSTALL( crc.py generic_mod_demod.py gmsk.py + gfsk.py modulation_utils.py ofdm.py ofdm_packet_utils.py diff --git a/gr-digital/python/__init__.py b/gr-digital/python/__init__.py index 7c76183c9..3fdbca769 100644 --- a/gr-digital/python/__init__.py +++ b/gr-digital/python/__init__.py @@ -31,6 +31,7 @@ from qam import * from bpsk import * from qpsk import * from gmsk import * +from gfsk import * from cpm import * from pkt import * from crc import * diff --git a/gr-digital/python/gfsk.py b/gr-digital/python/gfsk.py new file mode 100644 index 000000000..c85fdf0e0 --- /dev/null +++ b/gr-digital/python/gfsk.py @@ -0,0 +1,306 @@ +# +# GFSK modulation and demodulation. +# +# +# Copyright 2005,2006,2007 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +# See gnuradio-examples/python/digital for examples + +from gnuradio import gr +import modulation_utils +import digital_swig as digital +from math import pi +import numpy +from pprint import pprint +import inspect + +# default values (used in __init__ and add_options) +_def_samples_per_symbol = 2 +_def_sensitivity = 1 +_def_bt = 0.35 +_def_verbose = False +_def_log = False + +_def_gain_mu = None +_def_mu = 0.5 +_def_freq_error = 0.0 +_def_omega_relative_limit = 0.005 + + +# FIXME: Figure out how to make GFSK work with pfb_arb_resampler_fff for both +# transmit and receive so we don't require integer samples per symbol. + + +# ///////////////////////////////////////////////////////////////////////////// +# GFSK modulator +# ///////////////////////////////////////////////////////////////////////////// + +class gfsk_mod(gr.hier_block2): + + def __init__(self, + samples_per_symbol=_def_samples_per_symbol, + sensitivity=_def_sensitivity, + bt=_def_bt, + verbose=_def_verbose, + log=_def_log): + """ + Hierarchical block for Gaussian Frequency Shift Key (GFSK) + modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + @param samples_per_symbol: samples per baud >= 2 + @type samples_per_symbol: integer + @param bt: Gaussian filter bandwidth * symbol time + @type bt: float + @param verbose: Print information about modulator? + @type verbose: bool + @param debug: Print modualtion data to files? + @type debug: bool + """ + + gr.hier_block2.__init__(self, "gfsk_mod", + gr.io_signature(1, 1, gr.sizeof_char), # Input signature + gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature + + samples_per_symbol = int(samples_per_symbol) + self._samples_per_symbol = samples_per_symbol + self._bt = bt + self._differential = False + + if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2: + raise TypeError, ("samples_per_symbol must be an integer >= 2, is %r" % (samples_per_symbol,)) + + ntaps = 4 * samples_per_symbol # up to 3 bits in filter at once + #sensitivity = (pi / 2) / samples_per_symbol # phase change per bit = pi / 2 + + # Turn it into NRZ data. + self.nrz = gr.bytes_to_syms() + + # Form Gaussian filter + # Generate Gaussian response (Needs to be convolved with window below). + self.gaussian_taps = gr.firdes.gaussian( + 1.0, # gain + samples_per_symbol, # symbol_rate + bt, # bandwidth * symbol time + ntaps # number of taps + ) + + self.sqwave = (1,) * samples_per_symbol # rectangular window + self.taps = numpy.convolve(numpy.array(self.gaussian_taps),numpy.array(self.sqwave)) + self.gaussian_filter = gr.interp_fir_filter_fff(samples_per_symbol, self.taps) + + # FM modulation + self.fmmod = gr.frequency_modulator_fc(sensitivity) + + # small amount of output attenuation to prevent clipping USRP sink + self.amp = gr.multiply_const_cc(0.999) + + if verbose: + self._print_verbage() + + if log: + self._setup_logging() + + # Connect & Initialize base class + self.connect(self, self.nrz, self.gaussian_filter, self.fmmod, self.amp, self) + + def samples_per_symbol(self): + return self._samples_per_symbol + + def bits_per_symbol(self=None): # staticmethod that's also callable on an instance + return 1 + bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. + + + def _print_verbage(self): + print "bits per symbol = %d" % self.bits_per_symbol() + print "Gaussian filter bt = %.2f" % self._bt + + + def _setup_logging(self): + print "Modulation logging turned on." + self.connect(self.nrz, + gr.file_sink(gr.sizeof_float, "nrz.dat")) + self.connect(self.gaussian_filter, + gr.file_sink(gr.sizeof_float, "gaussian_filter.dat")) + self.connect(self.fmmod, + gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat")) + + + def add_options(parser): + """ + Adds GFSK modulation-specific options to the standard parser + """ + parser.add_option("", "--bt", type="float", default=_def_bt, + help="set bandwidth-time product [default=%default] (GFSK)") + add_options=staticmethod(add_options) + + + def extract_kwargs_from_options(options): + """ + Given command line options, create dictionary suitable for passing to __init__ + """ + return modulation_utils.extract_kwargs_from_options(gfsk_mod.__init__, + ('self',), options) + extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) + + + +# ///////////////////////////////////////////////////////////////////////////// +# GFSK demodulator +# ///////////////////////////////////////////////////////////////////////////// + +class gfsk_demod(gr.hier_block2): + + def __init__(self, + samples_per_symbol=_def_samples_per_symbol, + sensitivity=_def_sensitivity, + gain_mu=_def_gain_mu, + mu=_def_mu, + omega_relative_limit=_def_omega_relative_limit, + freq_error=_def_freq_error, + verbose=_def_verbose, + log=_def_log): + """ + Hierarchical block for Gaussian Minimum Shift Key (GFSK) + demodulation. + + The input is the complex modulated signal at baseband. + The output is a stream of bits packed 1 bit per byte (the LSB) + + @param samples_per_symbol: samples per baud + @type samples_per_symbol: integer + @param verbose: Print information about modulator? + @type verbose: bool + @param log: Print modualtion data to files? + @type log: bool + + Clock recovery parameters. These all have reasonble defaults. + + @param gain_mu: controls rate of mu adjustment + @type gain_mu: float + @param mu: fractional delay [0.0, 1.0] + @type mu: float + @param omega_relative_limit: sets max variation in omega + @type omega_relative_limit: float, typically 0.000200 (200 ppm) + @param freq_error: bit rate error as a fraction + @param float + """ + + gr.hier_block2.__init__(self, "gfsk_demod", + gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature + gr.io_signature(1, 1, gr.sizeof_char)) # Output signature + + self._samples_per_symbol = samples_per_symbol + self._gain_mu = gain_mu + self._mu = mu + self._omega_relative_limit = omega_relative_limit + self._freq_error = freq_error + self._differential = False + + if samples_per_symbol < 2: + raise TypeError, "samples_per_symbol >= 2, is %f" % samples_per_symbol + + self._omega = samples_per_symbol*(1+self._freq_error) + + if not self._gain_mu: + self._gain_mu = 0.175 + + self._gain_omega = .25 * self._gain_mu * self._gain_mu # critically damped + + # Demodulate FM + #sensitivity = (pi / 2) / samples_per_symbol + self.fmdemod = gr.quadrature_demod_cf(1.0 / sensitivity) + + # the clock recovery block tracks the symbol clock and resamples as needed. + # the output of the block is a stream of soft symbols (float) + self.clock_recovery = digital.clock_recovery_mm_ff(self._omega, self._gain_omega, + self._mu, self._gain_mu, + self._omega_relative_limit) + + # slice the floats at 0, outputting 1 bit (the LSB of the output byte) per sample + self.slicer = digital.binary_slicer_fb() + + if verbose: + self._print_verbage() + + if log: + self._setup_logging() + + # Connect & Initialize base class + self.connect(self, self.fmdemod, self.clock_recovery, self.slicer, self) + + def samples_per_symbol(self): + return self._samples_per_symbol + + def bits_per_symbol(self=None): # staticmethod that's also callable on an instance + return 1 + bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. + + + def _print_verbage(self): + print "bits per symbol = %d" % self.bits_per_symbol() + print "M&M clock recovery omega = %f" % self._omega + print "M&M clock recovery gain mu = %f" % self._gain_mu + print "M&M clock recovery mu = %f" % self._mu + print "M&M clock recovery omega rel. limit = %f" % self._omega_relative_limit + print "frequency error = %f" % self._freq_error + + + def _setup_logging(self): + print "Demodulation logging turned on." + self.connect(self.fmdemod, + gr.file_sink(gr.sizeof_float, "fmdemod.dat")) + self.connect(self.clock_recovery, + gr.file_sink(gr.sizeof_float, "clock_recovery.dat")) + self.connect(self.slicer, + gr.file_sink(gr.sizeof_char, "slicer.dat")) + + def add_options(parser): + """ + Adds GFSK demodulation-specific options to the standard parser + """ + parser.add_option("", "--gain-mu", type="float", default=_def_gain_mu, + help="M&M clock recovery gain mu [default=%default] (GFSK/PSK)") + parser.add_option("", "--mu", type="float", default=_def_mu, + help="M&M clock recovery mu [default=%default] (GFSK/PSK)") + parser.add_option("", "--omega-relative-limit", type="float", default=_def_omega_relative_limit, + help="M&M clock recovery omega relative limit [default=%default] (GFSK/PSK)") + parser.add_option("", "--freq-error", type="float", default=_def_freq_error, + help="M&M clock recovery frequency error [default=%default] (GFSK)") + add_options=staticmethod(add_options) + + def extract_kwargs_from_options(options): + """ + Given command line options, create dictionary suitable for passing to __init__ + """ + return modulation_utils.extract_kwargs_from_options(gfsk_demod.__init__, + ('self',), options) + extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) + + +# +# Add these to the mod/demod registry +# +modulation_utils.add_type_1_mod('gfsk', gfsk_mod) +modulation_utils.add_type_1_demod('gfsk', gfsk_demod) -- cgit From b34c497a27448cdadeecbf24bc95e8af5e4208c1 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sun, 8 Jul 2012 17:02:57 -0400 Subject: digital: patching ber_simulation.grc to use EbN0 instead of noise amplitude. --- gr-digital/examples/demod/ber_simulation.grc | 305 +++++++++++++-------------- 1 file changed, 143 insertions(+), 162 deletions(-) diff --git a/gr-digital/examples/demod/ber_simulation.grc b/gr-digital/examples/demod/ber_simulation.grc index 6a9361ed1..b7c6a624b 100644 --- a/gr-digital/examples/demod/ber_simulation.grc +++ b/gr-digital/examples/demod/ber_simulation.grc @@ -1,6 +1,6 @@ - Tue Apr 3 18:11:51 2012 + Thu Jul 5 15:57:06 2012 options @@ -43,6 +43,10 @@ run True + + max_nouts + 0 + realtime_scheduling @@ -57,10 +61,41 @@ - gr_noise_source_x + gr_throttle id - gr_noise_source_x + gr_throttle + + + _enabled + True + + + type + byte + + + samples_per_second + samp_rate + + + vlen + 1 + + + _coordinate + (284, 24) + + + _rotation + 0 + + + + gr_add_xx + + id + gr_add_xx _enabled @@ -71,20 +106,39 @@ complex - noise_type - gr.GR_GAUSSIAN + num_inputs + 2 - amp - noise + vlen + 1 - seed - 42 + _coordinate + (486, 151) + + + _rotation + 0 + + + + digital_constellation_decoder_cb + + id + digital_constellation_decoder_cb_0 + + + _enabled + True + + + constellation + const.base() _coordinate - (235, 379) + (618, 164) _rotation @@ -171,38 +225,30 @@ _coordinate - (1062, 11) + (791, 228) _rotation - 0 + 180 - gr_throttle + import id - gr_throttle + import _enabled True - type - byte - - - samples_per_second - samp_rate - - - vlen - 1 + import + import math _coordinate - (397, 27) + (18, 373) _rotation @@ -213,7 +259,7 @@ variable id - samp_rate + const _enabled @@ -221,11 +267,11 @@ value - 50e3 + digital.qpsk_constellation() _coordinate - (20, 168) + (116, 310) _rotation @@ -233,22 +279,22 @@ - import + variable id - import + samp_rate _enabled True - import - import math + value + 100e3 _coordinate - (138, 168) + (16, 308) _rotation @@ -271,7 +317,7 @@ title - "Constellation: "+str(const) + "Constellation: "+str(const.arity()) + "-PSK" samp_rate @@ -323,7 +369,7 @@ _coordinate - (828, 368) + (623, 228) _rotation @@ -331,10 +377,10 @@ - gr_add_xx + blks2_error_rate id - gr_add_xx + blks2_error_rate _enabled @@ -342,42 +388,19 @@ type - complex - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (652, 395) - - - _rotation - 0 - - - - digital_constellation_decoder_cb - - id - digital_constellation_decoder_cb_0 + 'BER' - _enabled - True + win_size + int(1e7) - constellation - const.base() + bits_per_symbol + const.bits_per_symbol() _coordinate - (693, 205) + (720, 25) _rotation @@ -385,45 +408,34 @@ - variable + gr_noise_source_x id - const + gr_noise_source_x _enabled True - value - digital.qpsk_constellation() - - - _coordinate - (16, 461) - - - _rotation - 0 + type + complex - - - variable - id - const_points + noise_type + gr.GR_GAUSSIAN - _enabled - True + amp + 1.0 / math.sqrt(2.0 * const.bits_per_symbol() * 10**(EbN0/10)) - value - const.points() + seed + 42 _coordinate - (17, 532) + (16, 224) _rotation @@ -431,38 +443,38 @@ - random_source_x + gr_chunks_to_symbols_xx id - random_source_x + gr_chunks_to_symbols_xx _enabled True - type + in_type byte - min - 0 + out_type + complex - max - len(const_points) + symbol_table + const.points() - num_samps - 1000000 + dimension + 1 - repeat - False + num_ports + 1 _coordinate - (15, 244) + (240, 140) _rotation @@ -470,69 +482,54 @@ - gr_chunks_to_symbols_xx + variable_slider id - gr_chunks_to_symbols_xx + EbN0 _enabled True - in_type - byte - - - out_type - complex - - - symbol_table - const_points - - - dimension - 1 + label + Eb/N0 (dB) - num_ports - 1 + value + 10 - _coordinate - (367, 260) + min + -10 - _rotation - 0 + max + 200 - - - blks2_error_rate - id - blks2_error_rate + num_steps + 211 - _enabled - True + style + wx.SL_HORIZONTAL - type - 'BER' + converver + float_converter - win_size - 1000000 + grid_pos + - bits_per_symbol - int(math.log(len(const_points))/math.log(2)) + notebook + _coordinate - (670, 41) + (311, 309) _rotation @@ -540,22 +537,18 @@ - variable_slider + random_source_x id - noise + random_source_x _enabled True - label - AWGN Noise - - - value - 0.10 + type + byte min @@ -563,31 +556,19 @@ max - 1 - - - num_steps - 100 + const.arity() - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - + num_samps + 10000000 - notebook - + repeat + True _coordinate - (268, 481) + (17, 125) _rotation -- cgit From 6c687bb86b6808822c6bb56e32645f0b2648a402 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sun, 8 Jul 2012 17:04:35 -0400 Subject: digital: fixes DxPSK mod/demod to use right API. --- gr-digital/grc/digital_dxpsk_demod.xml | 8 ++++---- gr-digital/grc/digital_dxpsk_mod.xml | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gr-digital/grc/digital_dxpsk_demod.xml b/gr-digital/grc/digital_dxpsk_demod.xml index 6366596d9..6082afa14 100644 --- a/gr-digital/grc/digital_dxpsk_demod.xml +++ b/gr-digital/grc/digital_dxpsk_demod.xml @@ -36,7 +36,7 @@ freq_bw=$freq_bw, phase_bw=$phase_bw, timing_bw=$timing_bw, - mod_code=$mod_code, + gray_coded=$gray_coded, verbose=$verbose, log=$log ) @@ -93,16 +93,16 @@ Gray Code - mod_code + gray_coded True enum diff --git a/gr-digital/grc/digital_dxpsk_mod.xml b/gr-digital/grc/digital_dxpsk_mod.xml index 58e30436d..93334d27d 100644 --- a/gr-digital/grc/digital_dxpsk_mod.xml +++ b/gr-digital/grc/digital_dxpsk_mod.xml @@ -33,7 +33,7 @@ digital.$(type)_mod( samples_per_symbol=$samples_per_symbol, excess_bw=$excess_bw, - mod_code=$mod_code, + gray_coded=$gray_coded, verbose=$verbose, log=$log) @@ -68,16 +68,16 @@ Gray Code - mod_code - "gray" + gray_coded + True enum -- cgit From c4805e3a02b7547823c81664dae497c145c8c66a Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sun, 8 Jul 2012 17:08:24 -0400 Subject: digital: fixes the digital demod GRC examples after last updates to gr-digital. --- gr-digital/examples/demod/digital_freq_lock.grc | 820 ++++----------- gr-digital/examples/demod/dpsk_loopback.grc | 198 ++-- gr-digital/examples/demod/mpsk_demod.grc | 10 +- gr-digital/examples/demod/pam_sync.grc | 1229 +++++++++-------------- gr-digital/examples/demod/pam_timing.grc | 370 ++++--- 5 files changed, 980 insertions(+), 1647 deletions(-) diff --git a/gr-digital/examples/demod/digital_freq_lock.grc b/gr-digital/examples/demod/digital_freq_lock.grc index 36037febb..df105dd7f 100644 --- a/gr-digital/examples/demod/digital_freq_lock.grc +++ b/gr-digital/examples/demod/digital_freq_lock.grc @@ -1,6 +1,6 @@ - Sat Mar 6 17:17:12 2010 + Thu Jul 5 18:11:22 2012 options @@ -44,105 +44,16 @@ True - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation + max_nouts 0 - - - gr_uchar_to_float - - id - gr_uchar_to_float_0 - - _enabled - True - - - _coordinate - (217, 108) - - - _rotation - 0 - - - - gr_uchar_to_float - - id - gr_uchar_to_float_0_0 - - - _enabled - True - - - _coordinate - (216, 273) - - - _rotation - 0 - - - - variable_slider - - id - freq_offset - - - _enabled - True - - - label - Frequency Offset - - - value - 0 - - - min - -0.5 - - - max - 0.5 - - - num_steps - 1000 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook + realtime_scheduling _coordinate - (293, 684) + (-1, 0) _rotation @@ -153,7 +64,7 @@ random_source_x id - random_source_x_0 + random_source_x _enabled @@ -169,11 +80,11 @@ max - pam_amp + 256 num_samps - 10000 + 10000000 repeat @@ -181,7 +92,7 @@ _coordinate - (13, 80) + (-2, 111) _rotation @@ -189,10 +100,10 @@ - random_source_x + gr_throttle id - random_source_x_0_0 + gr_throttle_0 _enabled @@ -200,54 +111,19 @@ type - byte - - - min - 0 - - - max - pam_amp - - - num_samps - 10000 - - - repeat - True - - - _coordinate - (15, 245) - - - _rotation - 0 - - - - const_source_x - - id - const_source_x_0 - - - _enabled - True + complex - type - float + samples_per_second + samp_rate - const - -0.5*(pam_amp-1) + vlen + 1 _coordinate - (213, 197) + (456, 134) _rotation @@ -255,26 +131,22 @@ - const_source_x + variable id - const_source_x_0_0 + sps _enabled True - type - float - - - const - -0.5*(pam_amp-1) + value + 4 _coordinate - (200, 360) + (166, -2) _rotation @@ -282,30 +154,22 @@ - gr_add_xx + variable id - gr_add_xx_0 + rolloff _enabled True - type - float - - - num_inputs - 2 - - - vlen - 1 + value + 0.35 _coordinate - (440, 167) + (231, 0) _rotation @@ -313,10 +177,10 @@ - gr_add_xx + digital_fll_band_edge_cc id - gr_add_xx_0_1 + digital_fll_band_edge_cc_0 _enabled @@ -324,42 +188,27 @@ type - float - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (430, 330) + cc - _rotation - 0 + samps_per_sym + sps - - - variable - id - nfilts + rolloff + rolloff - _enabled - True + filter_size + 44 - value - 32 + w + freq_bw _coordinate - (435, 686) + (81, 248) _rotation @@ -370,7 +219,7 @@ variable_slider id - noise_amp + freq_bw _enabled @@ -378,7 +227,7 @@ label - Channel Noise + FLL Loop Bandwidth value @@ -390,7 +239,7 @@ max - 1.0 + 0.1 num_steps @@ -414,7 +263,7 @@ _coordinate - (168, 684) + (80, 382) _rotation @@ -425,7 +274,7 @@ variable id - spb_gen + samp_rate _enabled @@ -433,11 +282,11 @@ value - 4 + 32000 _coordinate - (119, 841) + (439, -1) _rotation @@ -445,122 +294,42 @@ - variable + variable_slider id - pam_amp + noise_amp _enabled True - value - 2 - - - _coordinate - (223, 9) - - - _rotation - 0 - - - - variable - - id - spb - - - _enabled - True + label + Channel Noise value - 4.1 - - - _coordinate - (32, 842) - - - _rotation 0 - - - gr_float_to_complex - - id - gr_float_to_complex_0 - - - _enabled - True - - vlen - 1 - - - _coordinate - (590, 184) - - - _rotation - 0 - - - - gr_throttle - - id - gr_throttle_0 - - - _enabled - True - - - type - complex - - - samples_per_second - samp_rate - - - vlen - 1 - - - _coordinate - (788, 197) - - - _rotation + min 0 - - - notebook - id - notebook_0 + max + 1.0 - _enabled - True + num_steps + 1000 style - wx.NB_TOP + wx.SL_HORIZONTAL - labels - ['Freq', 'Time'] + converver + float_converter grid_pos @@ -572,7 +341,7 @@ _coordinate - (216, 845) + (553, 0) _rotation @@ -580,54 +349,42 @@ - wxgui_scopesink2 + variable_slider id - wxgui_scopesink2_0 + freq_offset _enabled True - type - complex - - - title - Signal into Receiver - - - samp_rate - samp_rate - - - v_scale - 0 + label + Frequency Offset - v_offset + value 0 - t_scale - 0 + min + -0.5 - ac_couple - False + max + 0.5 - xy_mode - False + num_steps + 1000 - num_inputs - 1 + style + wx.SL_HORIZONTAL - win_size - + converver + float_converter grid_pos @@ -635,11 +392,11 @@ notebook - notebook_0,1 + _coordinate - (1123, 392) + (673, -1) _rotation @@ -647,86 +404,38 @@ - wxgui_fftsink2 + gr_channel_model id - wxgui_fftsink2_0 + gr_channel_model_0 _enabled True - type - complex - - - title - Signal into Receiver - - - samp_rate - samp_rate - - - baseband_freq - 0 - - - y_per_div - 10 - - - y_divs - 10 - - - ref_level - 10 - - - ref_scale - 2.0 - - - fft_size - 1024 - - - fft_rate - 30 - - - peak_hold - False - - - average - False - - - avg_alpha - 0 + noise_voltage + noise_amp - win - None + freq_offset + freq_offset - win_size - + epsilon + 1.0 - grid_pos - + taps + 1.0 - notebook - notebook_0,0 + seed + 42 _coordinate - (1122, 473) + (649, 104) _rotation @@ -737,7 +446,7 @@ wxgui_scopesink2 id - wxgui_scopesink2_0_0 + wxgui_scopesink2_0 _enabled @@ -749,7 +458,7 @@ title - Frequency Corrected Signal + Signal into Receiver samp_rate @@ -791,9 +500,17 @@ notebook notebook_0,1 + + trig_mode + gr.gr_TRIG_MODE_AUTO + + + y_axis_label + Counts + _coordinate - (1122, 680) + (875, 0) _rotation @@ -804,7 +521,7 @@ wxgui_fftsink2 id - wxgui_fftsink2_0_0 + wxgui_fftsink2_0 _enabled @@ -816,7 +533,7 @@ title - Frequency Corrected Signal + Signal into Receiver samp_rate @@ -879,31 +596,12 @@ notebook_0,0 - _coordinate - (1121, 762) - - - _rotation - 0 - - - - variable - - id - samp_rate - - - _enabled - True - - - value - 32000 + freqvar + None _coordinate - (128, 9) + (875, 108) _rotation @@ -911,68 +609,46 @@ - variable + digital_psk_mod id - sig_amp + digital_psk_mod_0 _enabled True - value - 1 - - - _coordinate - (315, 9) + constellation_points + 2 - _rotation - 0 + mod_code + "gray" - - - variable - id - rolloff + differential + False - _enabled - True + samples_per_symbol + sps - value + excess_bw 0.35 - _coordinate - (398, 12) - - - _rotation - 0 - - - - variable - - id - rrctaps - - - _enabled - True + verbose + False - value - firdes.root_raised_cosine(nfilts,1.0,1.0/(spb*nfilts), .35, int(11*spb*nfilts)) + log + False _coordinate - (826, 61) + (194, 104) _rotation @@ -980,10 +656,10 @@ - root_raised_cosine_filter + wxgui_scopesink2 id - root_raised_cosine_filter_0 + wxgui_scopesink2_0_0 _enabled @@ -991,82 +667,63 @@ type - interp_fir_filter_ccf - - - decim - 1 - - - interp - spb_gen + complex - gain - 2*spb_gen + title + Frequency Corrected Signal samp_rate - 1.0 - - - sym_rate - 1./spb_gen - - - alpha - rolloff + samp_rate - ntaps - 44 + v_scale + 0 - _coordinate - (978, 157) + v_offset + 0 - _rotation + t_scale 0 - - - gr_fll_band_edge_cc - id - gr_fll_band_edge_cc_0 + ac_couple + False - _enabled - True + xy_mode + False - type - cc + num_inputs + 1 - samps_per_sym - spb_gen + win_size + - rolloff - rolloff + grid_pos + - filter_size - 44 + notebook + notebook_0,1 - alpha - alpha + trig_mode + gr.gr_TRIG_MODE_AUTO - beta - beta + y_axis_label + Counts _coordinate - (874, 664) + (439, 289) _rotation @@ -1074,81 +731,74 @@ - gr_channel_model + wxgui_fftsink2 id - gr_channel_model_0 + wxgui_fftsink2_0_0 _enabled True - noise_voltage - noise_amp - - - freq_offset - freq_offset + type + complex - epsilon - 1.0 + title + Frequency Corrected Signal - taps - 1.0 + samp_rate + samp_rate - seed - 42 + baseband_freq + 0 - _coordinate - (618, 376) + y_per_div + 10 - _rotation - 0 + y_divs + 10 - - - variable_slider - id - beta + ref_level + 10 - _enabled - True + ref_scale + 2.0 - label - Freq Beta + fft_size + 1024 - value - 0 + fft_rate + 30 - min - 0.0 + peak_hold + False - max - 0.01 + average + False - num_steps - 1000 + avg_alpha + 0 - style - wx.SL_HORIZONTAL + win + None - converver - float_converter + win_size + grid_pos @@ -1156,54 +806,38 @@ notebook - + notebook_0,0 + + + freqvar + None _coordinate - (668, 5) + (439, 423) _rotation - 180 + 0 - variable_slider + notebook id - alpha + notebook_0 _enabled True - - label - Freq Alpha - - - value - 0 - - - min - 0 - - - max - 0.1 - - - num_steps - 1000 - style - wx.SL_HORIZONTAL + wx.NB_TOP - converver - float_converter + labels + ['Freq', 'Time'] grid_pos @@ -1215,7 +849,7 @@ _coordinate - (552, 4) + (114, 521) _rotation @@ -1223,97 +857,49 @@ - random_source_x_0 - gr_uchar_to_float_0 - 0 - 0 - - - gr_uchar_to_float_0 - gr_add_xx_0 - 0 - 0 - - - const_source_x_0 - gr_add_xx_0 - 0 - 1 - - - gr_uchar_to_float_0_0 - gr_add_xx_0_1 + gr_channel_model_0 + wxgui_scopesink2_0 0 0 - const_source_x_0_0 - gr_add_xx_0_1 - 0 - 1 - - - random_source_x_0_0 - gr_uchar_to_float_0_0 + gr_channel_model_0 + wxgui_fftsink2_0 0 0 - gr_add_xx_0 - gr_float_to_complex_0 + random_source_x + digital_psk_mod_0 0 0 - gr_add_xx_0_1 - gr_float_to_complex_0 - 0 - 1 - - - gr_float_to_complex_0 + digital_psk_mod_0 gr_throttle_0 0 0 gr_throttle_0 - root_raised_cosine_filter_0 - 0 - 0 - - - gr_channel_model_0 - wxgui_scopesink2_0 - 0 - 0 - - - root_raised_cosine_filter_0 gr_channel_model_0 0 0 gr_channel_model_0 - wxgui_fftsink2_0 - 0 - 0 - - - gr_channel_model_0 - gr_fll_band_edge_cc_0 + digital_fll_band_edge_cc_0 0 0 - gr_fll_band_edge_cc_0 + digital_fll_band_edge_cc_0 wxgui_scopesink2_0_0 0 0 - gr_fll_band_edge_cc_0 + digital_fll_band_edge_cc_0 wxgui_fftsink2_0_0 0 0 diff --git a/gr-digital/examples/demod/dpsk_loopback.grc b/gr-digital/examples/demod/dpsk_loopback.grc index aef6a7738..c9867bea2 100644 --- a/gr-digital/examples/demod/dpsk_loopback.grc +++ b/gr-digital/examples/demod/dpsk_loopback.grc @@ -1,6 +1,6 @@ - Tue Apr 3 18:03:52 2012 + Thu Jul 5 16:26:53 2012 options @@ -17,11 +17,11 @@ author - Example + GNU Radio description - gnuradio flow graph + Encode a signal into a packet, modulate, demodulate, decode and show it's the same data. window_size @@ -43,6 +43,10 @@ run True + + max_nouts + 0 + realtime_scheduling @@ -72,7 +76,7 @@ _coordinate - (10, 170) + (11, 120) _rotation @@ -127,7 +131,7 @@ _coordinate - (12, 257) + (13, 188) _rotation @@ -135,10 +139,10 @@ - gr_throttle + gr_sig_source_x id - gr_throttle_0_0 + gr_sig_source_x_0 _enabled @@ -149,16 +153,28 @@ float - samples_per_second + samp_rate samp_rate - vlen + waveform + gr.GR_COS_WAVE + + + freq + freq + + + amp 1 + + offset + 0 + _coordinate - (225, 174) + (184, 9) _rotation @@ -166,10 +182,10 @@ - gr_sig_source_x + digital_dxpsk_mod id - gr_sig_source_x_0 + digital_dxpsk_mod_1 _enabled @@ -177,31 +193,31 @@ type - float + dbpsk - samp_rate - samp_rate + samples_per_symbol + 2 - waveform - gr.GR_COS_WAVE + excess_bw + 0.35 - freq - freq + gray_coded + True - amp - 1 + verbose + False - offset - 0 + log + False _coordinate - (203, 8) + (745, 16) _rotation @@ -209,10 +225,10 @@ - blks2_packet_decoder + gr_throttle id - blks2_packet_decoder_0 + gr_throttle_0_0 _enabled @@ -223,16 +239,16 @@ float - access_code - + samples_per_second + samp_rate - threshold - -1 + vlen + 1 _coordinate - (551, 65) + (358, 39) _rotation @@ -240,10 +256,10 @@ - digital_dxpsk_demod + blks2_packet_encoder id - digital_dxpsk_demod_0 + blks2_packet_encoder_0 _enabled @@ -251,51 +267,31 @@ type - dbpsk + float samples_per_symbol 2 - excess_bw - 0.35 - - - freq_bw - 6.28/100.0 - - - phase_bw - 6.28/100.0 - - - timing_bw - 6.28/100.0 + bits_per_symbol + 1 - omega_relative_limit - 0.005 + access_code + - gray_coded + pad_for_usrp True - verbose - False - - - log - False - - - sync_out - False + payload_length + 0 _coordinate - (639, 254) + (541, 9) _rotation @@ -303,10 +299,10 @@ - digital_dxpsk_mod + digital_dxpsk_demod id - digital_dxpsk_mod_0 + digital_dxpsk_demod_1 _enabled @@ -324,6 +320,22 @@ excess_bw 0.35 + + freq_bw + 6.28/100.0 + + + phase_bw + 6.28/100.0 + + + timing_bw + 6.28/100.0 + + + omega_relative_limit + 0.005 + gray_coded True @@ -336,20 +348,24 @@ log False + + sync_out + False + _coordinate - (421, 294) + (746, 135) _rotation - 0 + 180 - blks2_packet_encoder + blks2_packet_decoder id - blks2_packet_encoder_0 + blks2_packet_decoder_0 _enabled @@ -359,33 +375,21 @@ type float - - samples_per_symbol - 2 - - - bits_per_symbol - 1 - access_code - pad_for_usrp - True - - - payload_length - 0 + threshold + -1 _coordinate - (216, 286) + (545, 187) _rotation - 0 + 180 @@ -456,46 +460,46 @@ _coordinate - (760, 41) + (184, 165) _rotation - 0 + 180 - gr_sig_source_x_0 - gr_throttle_0_0 + blks2_packet_decoder_0 + wxgui_scopesink2_0 0 0 - gr_throttle_0_0 - blks2_packet_encoder_0 + blks2_packet_encoder_0 + digital_dxpsk_mod_1 0 0 - blks2_packet_decoder_0 - wxgui_scopesink2_0 + digital_dxpsk_mod_1 + digital_dxpsk_demod_1 0 0 - digital_dxpsk_demod_0 + digital_dxpsk_demod_1 blks2_packet_decoder_0 0 0 - digital_dxpsk_mod_0 - digital_dxpsk_demod_0 + gr_throttle_0_0 + blks2_packet_encoder_0 0 0 - blks2_packet_encoder_0 - digital_dxpsk_mod_0 + gr_sig_source_x_0 + gr_throttle_0_0 0 0 diff --git a/gr-digital/examples/demod/mpsk_demod.grc b/gr-digital/examples/demod/mpsk_demod.grc index d7cca9661..b718fb68a 100644 --- a/gr-digital/examples/demod/mpsk_demod.grc +++ b/gr-digital/examples/demod/mpsk_demod.grc @@ -1,6 +1,6 @@ - Tue Apr 3 18:01:57 2012 + Thu Jul 5 16:28:45 2012 options @@ -43,6 +43,10 @@ run True + + max_nouts + 0 + realtime_scheduling @@ -404,6 +408,10 @@ notebook notebook, 1 + + freqvar + None + _coordinate (847, 10) diff --git a/gr-digital/examples/demod/pam_sync.grc b/gr-digital/examples/demod/pam_sync.grc index 8571995a5..f870a0b06 100644 --- a/gr-digital/examples/demod/pam_sync.grc +++ b/gr-digital/examples/demod/pam_sync.grc @@ -1,6 +1,6 @@ - Sat Mar 6 17:17:22 2010 + Thu Jul 5 17:54:54 2012 options @@ -43,13 +43,17 @@ run True + + max_nouts + 0 + realtime_scheduling _coordinate - (10, 10) + (-1, 0) _rotation @@ -57,18 +61,22 @@ - gr_uchar_to_float + variable id - gr_uchar_to_float_0 + const _enabled True + + value + digital.qpsk_constellation() + _coordinate - (217, 108) + (336, -2) _rotation @@ -76,18 +84,22 @@ - gr_uchar_to_float + variable id - gr_uchar_to_float_0_0 + rrctaps _enabled True + + value + firdes.root_raised_cosine(nfilts,1.0,1.0/(spb*nfilts), rolloff, int(11*spb*nfilts)) + _coordinate - (216, 273) + (686, -1) _rotation @@ -98,7 +110,7 @@ variable id - samp_rate + rolloff _enabled @@ -106,11 +118,11 @@ value - 32000 + 0.35 _coordinate - (128, 9) + (607, -1) _rotation @@ -118,54 +130,68 @@ - variable_slider + variable id - freq_offset + spb _enabled True - label - Frequency Offset + value + 4.0 - value + _coordinate + (542, -1) + + + _rotation 0 + + + variable + + id + sig_amp + - min - -0.5 + _enabled + True - max - 0.5 + value + 1.0 - num_steps - 1000 + _coordinate + (861, 0) - style - wx.SL_HORIZONTAL + _rotation + 0 + + + virtual_sink - converver - float_converter + id + virtual_sink_0 - grid_pos - + _enabled + True - notebook - + stream_id + input_signal_probe _coordinate - (293, 684) + (330, 183) _rotation @@ -173,10 +199,10 @@ - random_source_x + gr_pfb_clock_sync_xxx id - random_source_x_0 + gr_pfb_clock_sync_xxx_0 _enabled @@ -184,27 +210,43 @@ type - byte + ccf - min - 0 + sps + spb - max - pam_amp + alpha + time_alpha - num_samps - 10000 + beta + time_beta - repeat - True + taps + rrctaps + + + filter_size + nfilts + + + init_phase + 16 + + + max_dev + 1.5 + + + osps + 1 _coordinate - (13, 80) + (598, 241) _rotation @@ -212,10 +254,10 @@ - random_source_x + digital_fll_band_edge_cc id - random_source_x_0_0 + digital_fll_band_edge_cc_0 _enabled @@ -223,27 +265,27 @@ type - byte + cc - min - 0 + samps_per_sym + spb - max - pam_amp + rolloff + rolloff - num_samps - 10000 + filter_size + 44 - repeat - True + w + freq_bw _coordinate - (15, 245) + (331, 239) _rotation @@ -251,26 +293,22 @@ - const_source_x + variable id - const_source_x_0 + nfilts _enabled True - type - float - - - const - -0.5*(pam_amp-1) + value + 32 _coordinate - (213, 197) + (598, 186) _rotation @@ -278,26 +316,22 @@ - const_source_x + variable id - const_source_x_0_0 + samp_rate _enabled True - type - float - - - const - -0.5*(pam_amp-1) + value + 128000 _coordinate - (200, 360) + (193, -1) _rotation @@ -305,10 +339,10 @@ - gr_add_xx + random_source_x id - gr_add_xx_0 + random_source_x _enabled @@ -316,19 +350,27 @@ type - float + byte - num_inputs - 2 + min + 0 - vlen - 1 + max + const.arity() + + + num_samps + 10000000 + + + repeat + True _coordinate - (440, 167) + (0, 72) _rotation @@ -336,30 +378,38 @@ - gr_add_xx + gr_chunks_to_symbols_xx id - gr_add_xx_0_1 + gr_chunks_to_symbols_xx _enabled True - type - float + in_type + byte - num_inputs - 2 + out_type + complex - vlen + symbol_table + const.points() + + + dimension + 1 + + + num_ports 1 _coordinate - (430, 330) + (196, 87) _rotation @@ -367,22 +417,30 @@ - variable + blks2_pfb_arb_resampler_ccf id - nfilts + blks2_pfb_arb_resampler_ccf_0 _enabled True - value + rate + spb + + + taps + firdes.root_raised_cosine(32, 32, 1.0, 0.35, 44*32) + + + size 32 _coordinate - (435, 686) + (435, 80) _rotation @@ -390,54 +448,38 @@ - variable_slider + gr_channel_model id - noise_amp + gr_channel_model_0 _enabled True - label - Channel Noise + noise_voltage + noise_amp - value - 0 + freq_offset + freq_offset - min - 0 + epsilon + interpratio - max + taps 1.0 - num_steps - 1000 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - + seed + 42 _coordinate - (168, 684) + (46, 183) _rotation @@ -445,319 +487,84 @@ - variable_slider + gr_multiply_const_vxx id - interpratio + gr_multiply_const_vxx_0 _enabled True - label - Timing Offset + type + complex - value - 1.00 + const + sig_amp - min - 0.99 + vlen + 1 - max - 1.01 + _coordinate + (659, 95) - num_steps - 1000 + _rotation + 0 + + + gr_throttle - style - wx.SL_HORIZONTAL + id + gr_throttle_0 - converver - float_converter + _enabled + True - grid_pos - + type + complex - notebook - + samples_per_second + samp_rate + + + vlen + 1 _coordinate - (40, 684) + (857, 95) _rotation - 180 + 0 - variable - - id - pam_amp - - - _enabled - True - - - value - 2 - - - _coordinate - (223, 9) - - - _rotation - 0 - - - - variable - - id - sig_amp - - - _enabled - True - - - value - 1 - - - _coordinate - (315, 9) - - - _rotation - 0 - - - - variable - - id - rolloff - - - _enabled - True - - - value - 0.35 - - - _coordinate - (397, 9) - - - _rotation - 0 - - - - gr_throttle - - id - gr_throttle_0 - - - _enabled - True - - - type - complex - - - samples_per_second - samp_rate - - - vlen - 1 - - - _coordinate - (253, 575) - - - _rotation - 0 - - - - variable_slider - - id - time_beta - - - _enabled - True - - - label - Timing Beta - - - value - 0 - - - min - 0.0 - - - max - 0.1 - - - num_steps - 1000 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (606, 8) - - - _rotation - 180 - - - - variable_slider - - id - time_alpha - - - _enabled - True - - - label - Timing Alpha - - - value - 0 - - - min - 0 - - - max - 1 - - - num_steps - 1000 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (490, 8) - - - _rotation - 0 - - - - variable_slider + virtual_source id - phase_alpha + virtual_source_0 _enabled True - label - Phase Alpha - - - value - 0 - - - min - 0 - - - max - 0.1 - - - num_steps - 1000 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - + stream_id + input_signal_probe _coordinate - (953, 8) + (835, 562) _rotation @@ -765,85 +572,18 @@ - variable_slider + digital_costas_loop_cc id - phase_beta + digital_costas_loop_cc_0 _enabled True - label - Phase Beta - - - value - 0 - - - min - 0.0 - - - max - 0.01 - - - num_steps - 1000 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (1066, 8) - - - _rotation - 180 - - - - gr_costas_loop_cc - - id - gr_costas_loop_cc_0 - - - _enabled - True - - - alpha - phase_alpha - - - beta - phase_beta - - - max_freq - 0.2 - - - min_freq - -0.2 + w + phase_bw order @@ -851,7 +591,7 @@ _coordinate - (915, 560) + (866, 246) _rotation @@ -862,7 +602,7 @@ wxgui_scopesink2 id - wxgui_scopesink2_0 + wxgui_scopesink2_0_0_1 _enabled @@ -874,7 +614,7 @@ title - Input Signal + Pre-sync Signal samp_rate @@ -882,7 +622,7 @@ v_scale - 0 + .5 v_offset @@ -914,34 +654,19 @@ notebook - notebook_0,0 - - - _coordinate - (1116, 559) - - - _rotation - 0 - - - - variable - - id - rrctaps + notebook_0,1 - _enabled - True + trig_mode + gr.gr_TRIG_MODE_AUTO - value - firdes.root_raised_cosine(nfilts,1.0,1.0/(spb*nfilts), rolloff, int(11*spb*nfilts)) + y_axis_label + Counts _coordinate - (436, 755) + (1081, 439) _rotation @@ -949,85 +674,70 @@ - notebook + wxgui_fftsink2 id - notebook_0 + wxgui_fftsink2_0 _enabled True - style - wx.NB_TOP - - - labels - ['Output Signal', 'Input Signal'] - - - grid_pos - + type + complex - notebook - + title + Received spectrum - _coordinate - (203, 823) + samp_rate + samp_rate - _rotation + baseband_freq 0 - - - wxgui_scopesink2 - - id - wxgui_scopesink2_0_0_1 - - _enabled - True + y_per_div + 10 - type - complex + y_divs + 10 - title - Input Signal + ref_level + 10 - samp_rate - samp_rate + ref_scale + 2.0 - v_scale - .5 + fft_size + 1024 - v_offset - 0 + fft_rate + 30 - t_scale - 0 + peak_hold + False - ac_couple + average False - xy_mode - False + avg_alpha + 0 - num_inputs - 1 + win + None win_size @@ -1041,9 +751,13 @@ notebook notebook_0,1 + + freqvar + None + _coordinate - (975, 312) + (1081, 563) _rotation @@ -1054,7 +768,7 @@ wxgui_fftsink2 id - wxgui_fftsink2_0 + wxgui_fftsink2_0_0 _enabled @@ -1066,7 +780,7 @@ title - Input Frequency + Post-sync spectrum samp_rate @@ -1126,195 +840,200 @@ notebook - notebook_0,1 + notebook_0,0 + + + freqvar + None _coordinate - (1116, 355) + (347, 516) _rotation - 0 + 180 - virtual_source + wxgui_scopesink2 id - virtual_source_0 + wxgui_scopesink2_0 _enabled True - stream_id - input_signal_probe + type + complex - _coordinate - (801, 453) + title + Post-sync Signal - _rotation - 0 + samp_rate + samp_rate - - - virtual_sink - id - virtual_sink_0 + v_scale + 0 - _enabled - True + v_offset + 0 - stream_id - input_signal_probe + t_scale + 0 - _coordinate - (280, 475) + ac_couple + False - _rotation - 0 + xy_mode + True - - - wxgui_fftsink2 - id - wxgui_fftsink2_0_0 + num_inputs + 1 - _enabled - True + win_size + - type - complex + grid_pos + - title - Output Frequency + notebook + notebook_0,0 - samp_rate - samp_rate + trig_mode + gr.gr_TRIG_MODE_AUTO - baseband_freq - 0 + y_axis_label + Counts - y_per_div - 10 + _coordinate + (1085, 213) - y_divs - 10 + _rotation + 0 + + + variable_slider - ref_level - 10 + id + freq_bw - ref_scale - 2.0 + _enabled + True - fft_size - 1024 + label + FLL Bandwidth - fft_rate - 30 + value + 0 - peak_hold - False + min + 0.0 - average - False + max + 0.05 - avg_alpha - 0 + num_steps + 1000 - win - None + style + wx.SL_HORIZONTAL - - win_size - + + converver + float_converter grid_pos - + (4,2,1,1) notebook - notebook_0,0 + _coordinate - (663, 687) + (341, 373) _rotation - 0 + 180 - gr_pfb_clock_sync_xxx + variable_slider id - gr_pfb_clock_sync_xxx_0 + time_alpha _enabled True - type - ccf + label + Timing Alpha - sps - spb + value + 0 - alpha - time_alpha + min + 0 - beta - time_beta + max + 1 - taps - rrctaps + num_steps + 1000 - filter_size - nfilts + style + wx.SL_HORIZONTAL - init_phase - 16 + converver + float_converter - max_dev - 1.5 + grid_pos + (5,2,1,1) + + + notebook + _coordinate - (662, 527) + (598, 388) _rotation @@ -1322,92 +1041,109 @@ - gr_float_to_complex + variable_slider id - gr_float_to_complex_0 + time_beta _enabled True - vlen - 1 - - - _coordinate - (592, 184) + label + Timing Beta - _rotation + value 0 - - - gr_channel_model - id - gr_channel_model_0 + min + 0.0 - _enabled - True + max + 0.1 - noise_voltage - noise_amp + num_steps + 1000 - freq_offset - freq_offset + style + wx.SL_HORIZONTAL - epsilon - interpratio + converver + float_converter - taps - 1.0 + grid_pos + (6,2,1,1) - seed - 42 + notebook + _coordinate - (60, 443) + (708, 388) _rotation - 0 + 180 - gr_multiply_const_vxx + variable_slider id - gr_multiply_const_vxx_0 + phase_bw _enabled True - type - complex + label + Costas Loop (Phase) Bandwidth - const - sig_amp + value + 0 - vlen - 1 + min + 0 + + + max + 0.1 + + + num_steps + 1000 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + (7,2,1,1) + + + notebook + _coordinate - (670, 322) + (866, 313) _rotation @@ -1415,30 +1151,34 @@ - blks2_pfb_arb_resampler_ccf + notebook id - blks2_pfb_arb_resampler_ccf_0 + notebook_0 _enabled True - rate - spb + style + wx.NB_TOP - taps - firdes.root_raised_cosine(32, 32, 1.0, 0.35, 44*32) + labels + ['Synched Signal', 'Received Signal'] - size - 32 + grid_pos + (1,1,8,1) + + + notebook + _coordinate - (778, 180) + (9, 601) _rotation @@ -1446,76 +1186,65 @@ - gr_fll_band_edge_cc + variable_slider id - gr_fll_band_edge_cc_0 + interpratio _enabled True - type - cc - - - samps_per_sym - spb - - - rolloff - rolloff + label + Timing Offset - filter_size - 44 + value + 1.00 - alpha - freq_alpha + min + 0.99 - beta - freq_beta + max + 1.01 - _coordinate - (429, 528) + num_steps + 1000 - _rotation - 0 + style + wx.SL_HORIZONTAL - - - variable - id - spb + converver + float_converter - _enabled - True + grid_pos + (3,2,1,1) - value - 4.0 + notebook + _coordinate - (40, 829) + (60, 407) _rotation - 0 + 180 variable_slider id - freq_alpha + noise_amp _enabled @@ -1523,7 +1252,7 @@ label - Freq Alpha + Channel Noise value @@ -1535,7 +1264,7 @@ max - 0.1 + 1.0 num_steps @@ -1551,7 +1280,7 @@ grid_pos - + (1,2,1,1) notebook @@ -1559,7 +1288,7 @@ _coordinate - (734, 10) + (125, 284) _rotation @@ -1570,7 +1299,7 @@ variable_slider id - freq_beta + freq_offset _enabled @@ -1578,7 +1307,7 @@ label - Freq Beta + Frequency Offset value @@ -1586,11 +1315,11 @@ min - 0.0 + -0.5 max - 0.01 + 0.5 num_steps @@ -1606,7 +1335,7 @@ grid_pos - + (2,2,1,1) notebook @@ -1614,103 +1343,61 @@ _coordinate - (836, 9) + (6, 284) _rotation - 180 + 0 - - random_source_x_0 - gr_uchar_to_float_0 - 0 - 0 - - - gr_uchar_to_float_0_0 - gr_add_xx_0_1 - 0 - 0 - - - const_source_x_0_0 - gr_add_xx_0_1 - 0 - 1 - - - random_source_x_0_0 - gr_uchar_to_float_0_0 - 0 - 0 - gr_channel_model_0 - gr_throttle_0 + virtual_sink_0 0 0 - gr_add_xx_0 - gr_float_to_complex_0 + digital_fll_band_edge_cc_0 + gr_pfb_clock_sync_xxx_0 0 0 - gr_add_xx_0_1 - gr_float_to_complex_0 - 0 - 1 - - - gr_uchar_to_float_0 - gr_add_xx_0 + gr_pfb_clock_sync_xxx_0 + digital_costas_loop_cc_0 0 0 - const_source_x_0 - gr_add_xx_0 - 0 - 1 - - - gr_throttle_0 - gr_fll_band_edge_cc_0 + digital_costas_loop_cc_0 + wxgui_scopesink2_0 0 0 - gr_fll_band_edge_cc_0 - gr_pfb_clock_sync_xxx_0 + blks2_pfb_arb_resampler_ccf_0 + gr_multiply_const_vxx_0 0 0 - gr_pfb_clock_sync_xxx_0 - gr_costas_loop_cc_0 + gr_chunks_to_symbols_xx + blks2_pfb_arb_resampler_ccf_0 0 0 - gr_costas_loop_cc_0 - wxgui_scopesink2_0 + gr_channel_model_0 + digital_fll_band_edge_cc_0 0 0 - gr_fll_band_edge_cc_0 + digital_fll_band_edge_cc_0 wxgui_fftsink2_0_0 0 0 - - virtual_source_0 - wxgui_scopesink2_0_0_1 - 0 - 0 - virtual_source_0 wxgui_fftsink2_0 @@ -1718,26 +1405,26 @@ 0 - gr_channel_model_0 - virtual_sink_0 + virtual_source_0 + wxgui_scopesink2_0_0_1 0 0 - gr_float_to_complex_0 - blks2_pfb_arb_resampler_ccf_0 + random_source_x + gr_chunks_to_symbols_xx 0 0 - blks2_pfb_arb_resampler_ccf_0 - gr_multiply_const_vxx_0 + gr_throttle_0 + gr_channel_model_0 0 0 gr_multiply_const_vxx_0 - gr_channel_model_0 + gr_throttle_0 0 0 diff --git a/gr-digital/examples/demod/pam_timing.grc b/gr-digital/examples/demod/pam_timing.grc index 02130f481..14a7d403e 100644 --- a/gr-digital/examples/demod/pam_timing.grc +++ b/gr-digital/examples/demod/pam_timing.grc @@ -1,6 +1,6 @@ - Mon Feb 1 18:54:46 2010 + Thu Jul 5 17:55:51 2012 options @@ -43,6 +43,10 @@ run True + + max_nouts + 0 + realtime_scheduling @@ -748,6 +752,14 @@ notebook + + trig_mode + gr.gr_TRIG_MODE_AUTO + + + y_axis_label + Counts + _coordinate (1116, 500) @@ -792,7 +804,7 @@ wxgui_scopesink2 id - wxgui_scopesink2_0_0 + wxgui_scopesink2_0_0_0 _enabled @@ -804,7 +816,7 @@ title - Error + Scope Plot samp_rate @@ -812,7 +824,7 @@ v_scale - 3 + 9 v_offset @@ -844,11 +856,42 @@ notebook - notebook_0,0 + notebook_0,1 + + + trig_mode + gr.gr_TRIG_MODE_AUTO + + + y_axis_label + Counts _coordinate - (1110, 651) + (1112, 881) + + + _rotation + 0 + + + + variable + + id + rrctaps + + + _enabled + True + + + value + firdes.root_raised_cosine(nfilts,1.0,1.0/(spb*nfilts), .35, int(11*spb*nfilts)) + + + _coordinate + (513, 679) _rotation @@ -859,7 +902,7 @@ wxgui_scopesink2 id - wxgui_scopesink2_0_0_0 + wxgui_scopesink2_0_0_1 _enabled @@ -867,11 +910,11 @@ type - float + complex title - Scope Plot + Error samp_rate @@ -879,7 +922,7 @@ v_scale - 9 + .5 v_offset @@ -911,11 +954,19 @@ notebook - notebook_0,1 + notebook_0,3 + + + trig_mode + gr.gr_TRIG_MODE_AUTO + + + y_axis_label + Counts _coordinate - (1112, 881) + (1115, 358) _rotation @@ -923,22 +974,22 @@ - variable + gr_float_to_complex id - rrctaps + gr_float_to_complex_0 _enabled True - value - firdes.root_raised_cosine(nfilts,1.0,1.0/(spb*nfilts), .35, int(11*spb*nfilts)) + vlen + 1 _coordinate - (513, 679) + (590, 184) _rotation @@ -946,50 +997,69 @@ - gr_pfb_clock_sync_xxx + blks2_pfb_arb_resampler_ccf id - gr_pfb_clock_sync_xxx_0 + blks2_pfb_arb_resampler_ccf_0 _enabled True - type - ccf + rate + spb - sps - spb + taps + firdes.root_raised_cosine(32, 32, 1.0, 0.35, 44*32) - alpha - alpha + size + 32 - beta - beta + _coordinate + (816, 181) - taps - rrctaps + _rotation + 0 + + + gr_channel_model - filter_size - nfilts + id + gr_channel_model_0 - init_phase - 16 + _enabled + True - max_dev - 1.5 + noise_voltage + noise_amp + + + freq_offset + freq_offset + + + epsilon + interpratio + + + taps + 1.0 + + + seed + 42 _coordinate - (512, 527) + (59, 543) _rotation @@ -997,10 +1067,10 @@ - wxgui_scopesink2 + gr_multiply_const_vxx id - wxgui_scopesink2_0_0_0_0 + gr_multiply_const_vxx_0 _enabled @@ -1008,55 +1078,97 @@ type - float + complex - title - Scope Plot + const + sig_amp - samp_rate - samp_rate + vlen + 1 - v_scale - 1.25 + _coordinate + (714, 382) - v_offset + _rotation 0 + + + variable - t_scale + id + spb + + + _enabled + True + + + value + 4.2563 + + + _coordinate + (42, 840) + + + _rotation 0 + + + gr_pfb_clock_sync_xxx - ac_couple - False + id + gr_pfb_clock_sync_xxx_0 - xy_mode - False + _enabled + True - num_inputs - 1 + type + ccf - win_size - + sps + spb - grid_pos - + alpha + alpha - notebook - notebook_0,2 + beta + beta + + + taps + rrctaps + + + filter_size + nfilts + + + init_phase + 16 + + + max_dev + 1.5 + + + osps + 1 _coordinate - (1111, 767) + (512, 527) _rotation @@ -1067,7 +1179,7 @@ wxgui_scopesink2 id - wxgui_scopesink2_0_0_1 + wxgui_scopesink2_0_0 _enabled @@ -1075,7 +1187,7 @@ type - complex + float title @@ -1087,7 +1199,7 @@ v_scale - .5 + 3 v_offset @@ -1119,34 +1231,19 @@ notebook - notebook_0,3 - - - _coordinate - (1115, 358) - - - _rotation - 0 - - - - gr_float_to_complex - - id - gr_float_to_complex_0 + notebook_0,0 - _enabled - True + trig_mode + gr.gr_TRIG_MODE_AUTO - vlen - 1 + y_axis_label + Counts _coordinate - (590, 184) + (1114, 615) _rotation @@ -1154,123 +1251,74 @@ - blks2_pfb_arb_resampler_ccf + wxgui_scopesink2 id - blks2_pfb_arb_resampler_ccf_0 + wxgui_scopesink2_0_0_0_0 _enabled True - rate - spb + type + float - taps - firdes.root_raised_cosine(32, 32, 1.0, 0.35, 44*32) + title + Scope Plot - size - 32 + samp_rate + samp_rate - _coordinate - (816, 181) + v_scale + 1.25 - _rotation + v_offset 0 - - - gr_channel_model - - id - gr_channel_model_0 - - - _enabled - True - - - noise_voltage - noise_amp - - freq_offset - freq_offset - - - epsilon - interpratio - - - taps - 1.0 - - - seed - 42 - - - _coordinate - (59, 543) - - - _rotation + t_scale 0 - - - gr_multiply_const_vxx - id - gr_multiply_const_vxx_0 - - - _enabled - True - - - type - complex + ac_couple + False - const - sig_amp + xy_mode + False - vlen + num_inputs 1 - _coordinate - (714, 382) + win_size + - _rotation - 0 + grid_pos + - - - variable - id - spb + notebook + notebook_0,2 - _enabled - True + trig_mode + gr.gr_TRIG_MODE_AUTO - value - 4.2563 + y_axis_label + Counts _coordinate - (42, 840) + (1080, 751) _rotation -- cgit From 504a14dc0f24e165d0704ca2c0321598ae86f02e Mon Sep 17 00:00:00 2001 From: Hendrik van Wyk Date: Sun, 8 Jul 2012 17:31:19 -0400 Subject: digital: fix for FLL block; uses actual FIR filter. This should work much more efficiently and also appears to fix issue 463. --- gr-digital/include/digital_fll_band_edge_cc.h | 40 +++++++++------ gr-digital/lib/digital_fll_band_edge_cc.cc | 70 ++++++++++++++++----------- 2 files changed, 67 insertions(+), 43 deletions(-) diff --git a/gr-digital/include/digital_fll_band_edge_cc.h b/gr-digital/include/digital_fll_band_edge_cc.h index c70bfc86d..68083bbae 100644 --- a/gr-digital/include/digital_fll_band_edge_cc.h +++ b/gr-digital/include/digital_fll_band_edge_cc.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009,2011 Free Software Foundation, Inc. + * Copyright 2009,2011,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -27,13 +27,19 @@ #include #include #include +#include +#include + +typedef gr_fir_ccc* (*fir_maker_t)(const std::vector &taps); +typedef gr_fir_ccc filter_t; class digital_fll_band_edge_cc; typedef boost::shared_ptr digital_fll_band_edge_cc_sptr; -DIGITAL_API digital_fll_band_edge_cc_sptr digital_make_fll_band_edge_cc (float samps_per_sym, - float rolloff, - int filter_size, - float bandwidth); +DIGITAL_API digital_fll_band_edge_cc_sptr +digital_make_fll_band_edge_cc(float samps_per_sym, + float rolloff, + int filter_size, + float bandwidth); /*! * \class digital_fll_band_edge_cc @@ -86,7 +92,8 @@ DIGITAL_API digital_fll_band_edge_cc_sptr digital_make_fll_band_edge_cc (float s * */ -class DIGITAL_API digital_fll_band_edge_cc : public gr_sync_block, public gri_control_loop +class DIGITAL_API digital_fll_band_edge_cc : + public gr_sync_block, public gri_control_loop { private: /*! @@ -96,10 +103,11 @@ class DIGITAL_API digital_fll_band_edge_cc : public gr_sync_block, public gri_co * \param filter_size (int) Size (in taps) of the filter * \param bandwidth (float) Loop bandwidth */ - friend DIGITAL_API digital_fll_band_edge_cc_sptr digital_make_fll_band_edge_cc (float samps_per_sym, - float rolloff, - int filter_size, - float bandwidth); + friend DIGITAL_API digital_fll_band_edge_cc_sptr + digital_make_fll_band_edge_cc(float samps_per_sym, + float rolloff, + int filter_size, + float bandwidth); float d_sps; float d_rolloff; @@ -108,6 +116,10 @@ class DIGITAL_API digital_fll_band_edge_cc : public gr_sync_block, public gri_co std::vector d_taps_lower; std::vector d_taps_upper; bool d_updated; + filter_t* d_filter_lower; + filter_t* d_filter_upper; + std::vector d_output_hist; + std::vector d_fllbuffer; /*! * Build the FLL @@ -130,7 +142,7 @@ class DIGITAL_API digital_fll_band_edge_cc : public gr_sync_block, public gri_co void design_filter(float samps_per_sym, float rolloff, int filter_size); public: - ~digital_fll_band_edge_cc (); + ~digital_fll_band_edge_cc(); /******************************************************************* SET FUNCTIONS @@ -206,9 +218,9 @@ public: */ void print_taps(); - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); }; #endif diff --git a/gr-digital/lib/digital_fll_band_edge_cc.cc b/gr-digital/lib/digital_fll_band_edge_cc.cc index 05c092622..f2cfb1020 100644 --- a/gr-digital/lib/digital_fll_band_edge_cc.cc +++ b/gr-digital/lib/digital_fll_band_edge_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009-2011 Free Software Foundation, Inc. + * Copyright 2009-2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -50,37 +50,38 @@ digital_make_fll_band_edge_cc (float samps_per_sym, float rolloff, static int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)}; static std::vector iosig(ios, ios+sizeof(ios)/sizeof(int)); -digital_fll_band_edge_cc::digital_fll_band_edge_cc (float samps_per_sym, float rolloff, - int filter_size, float bandwidth) - : gr_sync_block ("fll_band_edge_cc", - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signaturev (1, 4, iosig)), +digital_fll_band_edge_cc::digital_fll_band_edge_cc(float samps_per_sym, float rolloff, + int filter_size, float bandwidth) + : gr_sync_block("fll_band_edge_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signaturev(1, 4, iosig)), gri_control_loop(bandwidth, M_TWOPI*(2.0/samps_per_sym), -M_TWOPI*(2.0/samps_per_sym)), - d_updated (false) + d_updated(false) { // Initialize samples per symbol if(samps_per_sym <= 0) { - throw std::out_of_range ("digital_fll_band_edge_cc: invalid number of sps. Must be > 0."); + throw std::out_of_range("digital_fll_band_edge_cc: invalid number of sps. Must be > 0."); } d_sps = samps_per_sym; // Initialize rolloff factor if(rolloff < 0 || rolloff > 1.0) { - throw std::out_of_range ("digital_fll_band_edge_cc: invalid rolloff factor. Must be in [0,1]."); + throw std::out_of_range("digital_fll_band_edge_cc: invalid rolloff factor. Must be in [0,1]."); } d_rolloff = rolloff; // Initialize filter length if(filter_size <= 0) { - throw std::out_of_range ("digital_fll_band_edge_cc: invalid filter size. Must be > 0."); + throw std::out_of_range("digital_fll_band_edge_cc: invalid filter size. Must be > 0."); } d_filter_size = filter_size; // Build the band edge filters design_filter(d_sps, d_rolloff, d_filter_size); + d_output_hist.resize(filter_size,0); } -digital_fll_band_edge_cc::~digital_fll_band_edge_cc () +digital_fll_band_edge_cc::~digital_fll_band_edge_cc() { } @@ -93,7 +94,7 @@ void digital_fll_band_edge_cc::set_samples_per_symbol(float sps) { if(sps <= 0) { - throw std::out_of_range ("digital_fll_band_edge_cc: invalid number of sps. Must be > 0."); + throw std::out_of_range("digital_fll_band_edge_cc: invalid number of sps. Must be > 0."); } d_sps = sps; design_filter(d_sps, d_rolloff, d_filter_size); @@ -103,7 +104,7 @@ void digital_fll_band_edge_cc::set_rolloff(float rolloff) { if(rolloff < 0 || rolloff > 1.0) { - throw std::out_of_range ("digital_fll_band_edge_cc: invalid rolloff factor. Must be in [0,1]."); + throw std::out_of_range("digital_fll_band_edge_cc: invalid rolloff factor. Must be in [0,1]."); } d_rolloff = rolloff; design_filter(d_sps, d_rolloff, d_filter_size); @@ -113,7 +114,7 @@ void digital_fll_band_edge_cc::set_filter_size(int filter_size) { if(filter_size <= 0) { - throw std::out_of_range ("digital_fll_band_edge_cc: invalid filter size. Must be > 0."); + throw std::out_of_range("digital_fll_band_edge_cc: invalid filter size. Must be > 0."); } d_filter_size = filter_size; design_filter(d_sps, d_rolloff, d_filter_size); @@ -185,6 +186,8 @@ digital_fll_band_edge_cc::design_filter(float samps_per_sym, // Set the history to ensure enough input items for each filter set_history(filter_size+1); + d_filter_upper = gr_fir_util::create_gr_fir_ccc(d_taps_upper); + d_filter_lower = gr_fir_util::create_gr_fir_ccc(d_taps_lower); } void @@ -206,23 +209,25 @@ digital_fll_band_edge_cc::print_taps() } int -digital_fll_band_edge_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +digital_fll_band_edge_cc::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; + const gr_complex *in = (const gr_complex*)input_items[0]; + gr_complex *out = (gr_complex*)output_items[0]; + d_fllbuffer.reserve(d_filter_size+noutput_items); + float *frq = NULL; float *phs = NULL; float *err = NULL; if(output_items.size() == 4) { - frq = (float *) output_items[1]; - phs = (float *) output_items[2]; - err = (float *) output_items[3]; + frq = (float*)output_items[1]; + phs = (float*)output_items[2]; + err = (float*)output_items[3]; } - if (d_updated) { + if(d_updated) { d_updated = false; return 0; // history requirements may have changed. } @@ -231,17 +236,19 @@ digital_fll_band_edge_cc::work (int noutput_items, float error; gr_complex nco_out; gr_complex out_upper, out_lower; + gr_complex out_uppersse, out_lowersse; + copy( d_output_hist.begin(), d_output_hist.end(), d_fllbuffer.begin()); + for(i = 0; i < noutput_items; i++) { nco_out = gr_expj(d_phase); - out[i+d_filter_size-1] = in[i] * nco_out; - + d_fllbuffer[i+d_filter_size] = in[i] * nco_out; // Perform the dot product of the output with the filters out_upper = 0; out_lower = 0; - for(int k = 0; k < d_filter_size; k++) { - out_upper += d_taps_upper[k] * out[i+k]; - out_lower += d_taps_lower[k] * out[i+k]; - } + + out_upper = d_filter_lower->filter(&d_fllbuffer[i]); + out_lower = d_filter_upper->filter(&d_fllbuffer[i]); + error = norm(out_lower) - norm(out_upper); advance_loop(error); @@ -255,5 +262,10 @@ digital_fll_band_edge_cc::work (int noutput_items, } } + copy(d_fllbuffer.begin(), d_fllbuffer.begin()+noutput_items, out); + copy(d_fllbuffer.begin()+noutput_items, + d_fllbuffer.begin()+noutput_items+d_filter_size, + d_output_hist.begin()); + return noutput_items; } -- cgit From e1cfa5eeeaebce6720dd98001c83b84218ae4d80 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 8 Jul 2012 18:08:17 -0400 Subject: filter: warning fixes. --- gr-filter/lib/pfb_channelizer_ccf_impl.cc | 3 +-- gr-filter/lib/pfb_synthesizer_ccf_impl.cc | 3 +-- gr-filter/lib/qa_fir_filter_with_buffer.cc | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/gr-filter/lib/pfb_channelizer_ccf_impl.cc b/gr-filter/lib/pfb_channelizer_ccf_impl.cc index ca92066f5..28fc1dcc1 100644 --- a/gr-filter/lib/pfb_channelizer_ccf_impl.cc +++ b/gr-filter/lib/pfb_channelizer_ccf_impl.cc @@ -118,8 +118,7 @@ namespace gr { if(map.size() > 0) { unsigned int max = (unsigned int)*std::max_element(map.begin(), map.end()); - unsigned int min = (unsigned int)*std::min_element(map.begin(), map.end()); - if((max >= d_nfilts) || (min < 0)) { + if(max >= d_nfilts) { throw std::invalid_argument("pfb_channelizer_ccf_impl::set_channel_map: map range out of bounds.\n"); } d_channel_map = map; diff --git a/gr-filter/lib/pfb_synthesizer_ccf_impl.cc b/gr-filter/lib/pfb_synthesizer_ccf_impl.cc index 1e9c099c1..9dd519d57 100644 --- a/gr-filter/lib/pfb_synthesizer_ccf_impl.cc +++ b/gr-filter/lib/pfb_synthesizer_ccf_impl.cc @@ -204,8 +204,7 @@ namespace gr { if(map.size() > 0) { unsigned int max = (unsigned int)*std::max_element(map.begin(), map.end()); - unsigned int min = (unsigned int)*std::min_element(map.begin(), map.end()); - if((max >= d_twox*d_numchans) || (min < 0)) { + if(max >= d_twox*d_numchans) { throw std::invalid_argument("gr_pfb_synthesizer_ccf::set_channel_map: map range out of bounds.\n"); } d_channel_map = map; diff --git a/gr-filter/lib/qa_fir_filter_with_buffer.cc b/gr-filter/lib/qa_fir_filter_with_buffer.cc index 6a1744b0a..ab2958ed1 100644 --- a/gr-filter/lib/qa_fir_filter_with_buffer.cc +++ b/gr-filter/lib/qa_fir_filter_with_buffer.cc @@ -376,7 +376,7 @@ namespace gr { new kernel::fir_filter_with_buffer_ccf(f1_taps); // zero the output, then do the filtering - memset(actual_output, 0, sizeof(actual_output)); + memset(actual_output, 0, sizeof(OUTPUT_LEN*sizeof(gr_complex))); f1->filterNdec(actual_output, input, ol/decimate, decimate); // check results -- cgit From bf073d84627f728d2241bbcf48075bb3257b58ce Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 15 Jul 2012 14:28:04 -0400 Subject: volk: adding unaligned byteswap kernel. --- volk/apps/volk_profile.cc | 1 + volk/include/volk/volk_16u_byteswap_u.h | 76 +++++++++++++++++++++++++++++++++ volk/lib/testqa.cc | 3 +- 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 volk/include/volk/volk_16u_byteswap_u.h diff --git a/volk/apps/volk_profile.cc b/volk/apps/volk_profile.cc index 6244abb35..648f4d878 100644 --- a/volk/apps/volk_profile.cc +++ b/volk/apps/volk_profile.cc @@ -33,6 +33,7 @@ int main(int argc, char *argv[]) { //VOLK_PROFILE(volk_16i_permute_and_scalar_add_a, 1e-4, 0, 2046, 10000, &results); //VOLK_PROFILE(volk_16i_x4_quad_max_star_16i_a, 1e-4, 0, 2046, 10000, &results); VOLK_PROFILE(volk_16u_byteswap_a, 0, 0, 204600, 10000, &results); + VOLK_PROFILE(volk_16u_byteswap_u, 0, 0, 204600, 10000, &results); VOLK_PROFILE(volk_16i_32fc_dot_prod_32fc_a, 1e-4, 0, 204600, 10000, &results); VOLK_PROFILE(volk_32f_accumulator_s32f_a, 1e-4, 0, 204600, 10000, &results); VOLK_PROFILE(volk_32f_x2_add_32f_a, 1e-4, 0, 204600, 10000, &results); diff --git a/volk/include/volk/volk_16u_byteswap_u.h b/volk/include/volk/volk_16u_byteswap_u.h new file mode 100644 index 000000000..37bed7fce --- /dev/null +++ b/volk/include/volk/volk_16u_byteswap_u.h @@ -0,0 +1,76 @@ +#ifndef INCLUDED_volk_16u_byteswap_u_H +#define INCLUDED_volk_16u_byteswap_u_H + +#include +#include + +#ifdef LV_HAVE_SSE2 +#include + +/*! + \brief Byteswaps (in-place) an unaligned vector of int16_t's. + \param intsToSwap The vector of data to byte swap + \param numDataPoints The number of data points +*/ +static inline void volk_16u_byteswap_u_sse2(uint16_t* intsToSwap, unsigned int num_points){ + unsigned int number = 0; + uint16_t* inputPtr = intsToSwap; + __m128i input, left, right, output; + + const unsigned int eighthPoints = num_points / 8; + for(;number < eighthPoints; number++){ + // Load the 16t values, increment inputPtr later since we're doing it in-place. + input = _mm_loadu_si128((__m128i*)inputPtr); + // Do the two shifts + left = _mm_slli_epi16(input, 8); + right = _mm_srli_epi16(input, 8); + // Or the left and right halves together + output = _mm_or_si128(left, right); + // Store the results + _mm_storeu_si128((__m128i*)inputPtr, output); + inputPtr += 8; + } + + // Byteswap any remaining points: + number = eighthPoints*8; + for(; number < num_points; number++){ + uint16_t outputVal = *inputPtr; + outputVal = (((outputVal >> 8) & 0xff) | ((outputVal << 8) & 0xff00)); + *inputPtr = outputVal; + inputPtr++; + } +} +#endif /* LV_HAVE_SSE2 */ + +#ifdef LV_HAVE_GENERIC +/*! + \brief Byteswaps (in-place) an unaligned vector of int16_t's. + \param intsToSwap The vector of data to byte swap + \param numDataPoints The number of data points +*/ +static inline void volk_16u_byteswap_u_generic(uint16_t* intsToSwap, unsigned int num_points){ + unsigned int point; + uint16_t* inputPtr = intsToSwap; + for(point = 0; point < num_points; point++){ + uint16_t output = *inputPtr; + output = (((output >> 8) & 0xff) | ((output << 8) & 0xff00)); + *inputPtr = output; + inputPtr++; + } +} +#endif /* LV_HAVE_GENERIC */ + +#ifdef LV_HAVE_ORC +/*! + \brief Byteswaps (in-place) an unaligned vector of int16_t's. + \param intsToSwap The vector of data to byte swap + \param numDataPoints The number of data points +*/ +extern void volk_16u_byteswap_u_orc_impl(uint16_t* intsToSwap, unsigned int num_points); +static inline void volk_16u_byteswap_u_orc(uint16_t* intsToSwap, unsigned int num_points){ + volk_16u_byteswap_u_orc_impl(intsToSwap, num_points); +} +#endif /* LV_HAVE_ORC */ + + +#endif /* INCLUDED_volk_16u_byteswap_u_H */ diff --git a/volk/lib/testqa.cc b/volk/lib/testqa.cc index 507c78777..2e41c25da 100644 --- a/volk/lib/testqa.cc +++ b/volk/lib/testqa.cc @@ -20,6 +20,7 @@ VOLK_RUN_TESTS(volk_16i_convert_8i_u, 0, 0, 20460, 1); //VOLK_RUN_TESTS(volk_16i_permute_and_scalar_add_a, 1e-4, 0, 2046, 1000); //VOLK_RUN_TESTS(volk_16i_x4_quad_max_star_16i_a, 1e-4, 0, 2046, 1000); VOLK_RUN_TESTS(volk_16u_byteswap_a, 0, 0, 20460, 1); +VOLK_RUN_TESTS(volk_16u_byteswap_u, 0, 0, 20460, 1); //VOLK_RUN_TESTS(volk_16i_32fc_dot_prod_32fc_a, 1e-4, 0, 204600, 1); VOLK_RUN_TESTS(volk_32f_accumulator_s32f_a, 1e-4, 0, 20460, 1); VOLK_RUN_TESTS(volk_32f_x2_add_32f_a, 1e-4, 0, 20460, 1); @@ -36,7 +37,7 @@ VOLK_RUN_TESTS(volk_32fc_s32f_deinterleave_real_16i_a, 0, 32768, 20460, 1); VOLK_RUN_TESTS(volk_32fc_deinterleave_real_32f_a, 1e-4, 0, 20460, 1); VOLK_RUN_TESTS(volk_32fc_deinterleave_real_64f_a, 1e-4, 0, 20460, 1); VOLK_RUN_TESTS(volk_32fc_x2_dot_prod_32fc_a, 1e-4, 0, 2046000, 1); -VOLK_RUN_TESTS(volk_32fc_32f_dot_prod_32fc_a, 1e-4, 0, 2046000, 1); +VOLK_RUN_TESTS(volk_32fc_32f_dot_prod_32fc_a, 1e-4, 0, 204600, 1); VOLK_RUN_TESTS(volk_32fc_index_max_16u_a, 3, 0, 20460, 1); VOLK_RUN_TESTS(volk_32fc_s32f_magnitude_16i_a, 1, 32768, 20460, 1); VOLK_RUN_TESTS(volk_32fc_magnitude_32f_a, 1e-4, 0, 20460, 1); -- cgit From 85a32174858443d0b3e30c2626f83af9e851d9f1 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sun, 15 Jul 2012 14:36:49 -0400 Subject: digital: removing unused parameter from DPSK demod GRC block. --- gr-digital/grc/digital_dxpsk_demod.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/gr-digital/grc/digital_dxpsk_demod.xml b/gr-digital/grc/digital_dxpsk_demod.xml index 6082afa14..f3e9ee6fc 100644 --- a/gr-digital/grc/digital_dxpsk_demod.xml +++ b/gr-digital/grc/digital_dxpsk_demod.xml @@ -85,12 +85,6 @@ 6.28/100.0 real - - Omega Relative Limit - omega_relative_limit - 0.005 - real - Gray Code gray_coded -- cgit From 1979696fc7893a549a62488104d974735e299a21 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sun, 15 Jul 2012 14:54:01 -0400 Subject: digital: adding BER/SNR simulation example. --- gr-digital/examples/berawgn.py | 104 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100755 gr-digital/examples/berawgn.py diff --git a/gr-digital/examples/berawgn.py b/gr-digital/examples/berawgn.py new file mode 100755 index 000000000..d58dfbaae --- /dev/null +++ b/gr-digital/examples/berawgn.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python +""" +BER simulation for QPSK signals, compare to theoretical values. +Change the N_BITS value to simulate more bits per Eb/N0 value, +thus allowing to check for lower BER values. + +Lower values will work faster, higher values will use a lot of RAM. +Also, this app isn't highly optimized--the flow graph is completely +reinstantiated for every Eb/N0 value. +Of course, expect the maximum value for BER to be one order of +magnitude below what you chose for N_BITS. +""" + + +import math +import numpy +from scipy.special import erfc +import pylab +from gnuradio import gr, digital + +# Best to choose powers of 10 +N_BITS = 1e7 +RAND_SEED = 42 + +def berawgn(EbN0): + """ Calculates theoretical bit error rate in AWGN (for BPSK and given Eb/N0) """ + return 0.5 * erfc(math.sqrt(10**(float(EbN0)/10))) + +class BitErrors(gr.hier_block2): + """ Two inputs: true and received bits. We compare them and + add up the number of incorrect bits. Because integrate_ff() + can only add up a certain number of values, the output is + not a scalar, but a sequence of values, the sum of which is + the BER. """ + def __init__(self, bits_per_byte): + gr.hier_block2.__init__(self, "BitErrors", + gr.io_signature(2, 2, gr.sizeof_char), + gr.io_signature(1, 1, gr.sizeof_int)) + + # Bit comparison + comp = gr.xor_bb() + intdump_decim = 100000 + if N_BITS < intdump_decim: + intdump_decim = int(N_BITS) + self.connect(self, + comp, + gr.unpack_k_bits_bb(bits_per_byte), + gr.uchar_to_float(), + gr.integrate_ff(intdump_decim), + gr.multiply_const_ff(1.0/N_BITS), + self) + self.connect((self, 1), (comp, 1)) + +class BERAWGNSimu(gr.top_block): + " This contains the simulation flow graph " + def __init__(self, EbN0): + gr.top_block.__init__(self) + self.const = digital.qpsk_constellation() + # Source is N_BITS bits, non-repeated + data = map(int, numpy.random.randint(0, self.const.arity(), N_BITS/self.const.bits_per_symbol())) + src = gr.vector_source_b(data, False) + mod = gr.chunks_to_symbols_bc((self.const.points()), 1) + add = gr.add_vcc() + noise = gr.noise_source_c(gr.GR_GAUSSIAN, + self.EbN0_to_noise_voltage(EbN0), + RAND_SEED) + demod = digital.constellation_decoder_cb(self.const.base()) + ber = BitErrors(self.const.bits_per_symbol()) + self.sink = gr.vector_sink_f() + self.connect(src, mod, add, demod, ber, self.sink) + self.connect(noise, (add, 1)) + self.connect(src, (ber, 1)) + + def EbN0_to_noise_voltage(self, EbN0): + """ Converts Eb/N0 to a single-sided noise voltage (assuming unit symbol power) """ + return 1.0 / math.sqrt(2.0 * self.const.bits_per_symbol() * 10**(float(EbN0)/10)) + + +def simulate_ber(EbN0): + """ All the work's done here: create flow graph, run, read out BER """ + print "Eb/N0 = %d dB" % EbN0 + fg = BERAWGNSimu(EbN0) + fg.run() + return numpy.sum(fg.sink.data()) + +if __name__ == "__main__": + EbN0_min = 0 + EbN0_max = 15 + EbN0_range = range(EbN0_min, EbN0_max+1) + ber_theory = [berawgn(x) for x in EbN0_range] + print "Simulating..." + ber_simu = [simulate_ber(x) for x in EbN0_range] + + f = pylab.figure() + s = f.add_subplot(1,1,1) + s.semilogy(EbN0_range, ber_theory, 'g-.', label="Theoretical") + s.semilogy(EbN0_range, ber_simu, 'b-o', label="Simulated") + s.set_title('BER Simulation') + s.set_xlabel('Eb/N0 (dB)') + s.set_ylabel('BER') + s.legend() + s.grid() + pylab.show() + -- cgit From 209e98f351f873450c1b2cc0f5bb7877f32e83e4 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Mon, 16 Jul 2012 14:37:27 -0700 Subject: Comment out orc support for volk_16u_byteswap_u --- volk/include/volk/volk_16u_byteswap_u.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/volk/include/volk/volk_16u_byteswap_u.h b/volk/include/volk/volk_16u_byteswap_u.h index 37bed7fce..ffdd5ba33 100644 --- a/volk/include/volk/volk_16u_byteswap_u.h +++ b/volk/include/volk/volk_16u_byteswap_u.h @@ -60,7 +60,8 @@ static inline void volk_16u_byteswap_u_generic(uint16_t* intsToSwap, unsigned in } #endif /* LV_HAVE_GENERIC */ -#ifdef LV_HAVE_ORC +//#ifdef LV_HAVE_ORC +#if 0 /*! \brief Byteswaps (in-place) an unaligned vector of int16_t's. \param intsToSwap The vector of data to byte swap -- cgit From cf8b2a8ff57ff6d3fd4b78a897854cc9a6f49fe1 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 17 Jul 2012 10:29:35 -0700 Subject: volk: fix for win64 MSVC not having MMX support 1) For the machine defs that will pass on windows, generate a machine with mmx and without using mmx| 2) In the cmakelists, we overrule MMX arch on MSVC 64. Also overrule redundant machines for when MMX does pass. 3) Set LV_HAVE_SSE && LV_HAVE_MMX for volk_16i_32fc_dot_prod_32fc_a. Afterall, it is calling into MMX intrinsics as well. --- volk/gen/machines.xml | 6 +++--- volk/include/volk/volk_16i_32fc_dot_prod_32fc_a.h | 4 ++-- volk/lib/CMakeLists.txt | 8 +++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/volk/gen/machines.xml b/volk/gen/machines.xml index 8e3c9c8c2..d88a1a50c 100644 --- a/volk/gen/machines.xml +++ b/volk/gen/machines.xml @@ -10,7 +10,7 @@ -generic 32|64| mmx sse orc| +generic 32|64| mmx| sse orc| --> @@ -20,7 +20,7 @@ -generic 32|64| mmx sse sse2 orc| +generic 32|64| mmx| sse sse2 orc| @@ -45,7 +45,7 @@ -generic 32|64| mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx orc| +generic 32|64| mmx| sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx orc| diff --git a/volk/include/volk/volk_16i_32fc_dot_prod_32fc_a.h b/volk/include/volk/volk_16i_32fc_dot_prod_32fc_a.h index 940aa5de7..1f6554af8 100644 --- a/volk/include/volk/volk_16i_32fc_dot_prod_32fc_a.h +++ b/volk/include/volk/volk_16i_32fc_dot_prod_32fc_a.h @@ -37,7 +37,7 @@ static inline void volk_16i_32fc_dot_prod_32fc_a_generic(lv_32fc_t* result, cons #endif /*LV_HAVE_GENERIC*/ -#ifdef LV_HAVE_SSE +#if LV_HAVE_SSE && LV_HAVE_MMX static inline void volk_16i_32fc_dot_prod_32fc_a_sse( lv_32fc_t* result, const short* input, const lv_32fc_t* taps, unsigned int num_points) { @@ -116,7 +116,7 @@ static inline void volk_16i_32fc_dot_prod_32fc_a_sse( lv_32fc_t* result, const *result = *(lv_32fc_t*)(&res[0]); } -#endif /*LV_HAVE_SSE*/ +#endif /*LV_HAVE_SSE && LV_HAVE_MMX*/ #endif /*INCLUDED_volk_16i_32fc_dot_prod_32fc_a_H*/ diff --git a/volk/lib/CMakeLists.txt b/volk/lib/CMakeLists.txt index 8288786c9..59d78b446 100644 --- a/volk/lib/CMakeLists.txt +++ b/volk/lib/CMakeLists.txt @@ -135,6 +135,12 @@ if(NOT CROSSCOMPILE_MULTILIB AND CPU_IS_x86) if (${SIZEOF_CPU} EQUAL 32) OVERRULE_ARCH(64 "CPU width is 32 bits") endif() + + #MSVC 64 bit does not have MMX, overrule it + if (${SIZEOF_CPU} EQUAL 64 AND MSVC) + OVERRULE_ARCH(mmx "No MMX for Win64") + endif() + endif() ######################################################################## @@ -159,7 +165,7 @@ execute_process( # When this occurs, eliminate the redundant machines # to avoid unnecessary compilation of subset machines. ######################################################################## -foreach(arch orc 64 32) +foreach(arch mmx orc 64 32) foreach(machine_name ${available_machines}) string(REPLACE "_${arch}" "" machine_name_no_arch ${machine_name}) if (${machine_name} STREQUAL ${machine_name_no_arch}) -- cgit From 3d868e178994f2e147bbee2c26c09fe283ab6992 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Tue, 17 Jul 2012 15:36:43 -0700 Subject: volk: entirely remove commented out ORC clause for volk_16u_byteswap_u --- volk/include/volk/volk_16u_byteswap_u.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/volk/include/volk/volk_16u_byteswap_u.h b/volk/include/volk/volk_16u_byteswap_u.h index ffdd5ba33..8ef627a62 100644 --- a/volk/include/volk/volk_16u_byteswap_u.h +++ b/volk/include/volk/volk_16u_byteswap_u.h @@ -60,18 +60,4 @@ static inline void volk_16u_byteswap_u_generic(uint16_t* intsToSwap, unsigned in } #endif /* LV_HAVE_GENERIC */ -//#ifdef LV_HAVE_ORC -#if 0 -/*! - \brief Byteswaps (in-place) an unaligned vector of int16_t's. - \param intsToSwap The vector of data to byte swap - \param numDataPoints The number of data points -*/ -extern void volk_16u_byteswap_u_orc_impl(uint16_t* intsToSwap, unsigned int num_points); -static inline void volk_16u_byteswap_u_orc(uint16_t* intsToSwap, unsigned int num_points){ - volk_16u_byteswap_u_orc_impl(intsToSwap, num_points); -} -#endif /* LV_HAVE_ORC */ - - #endif /* INCLUDED_volk_16u_byteswap_u_H */ -- cgit