1 /* -*- c++ -*- */ 2 /* 3 * Copyright 2009,2010,2012 Free Software Foundation, Inc. 4 * 5 * This file is part of GNU Radio 6 * 7 * GNU Radio is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3, or (at your option) 10 * any later version. 11 * 12 * GNU Radio is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with GNU Radio; see the file COPYING. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, 20 * Boston, MA 02110-1301, USA. 21 */ 22 23 #ifndef INCLUDED_DIGITAL_PFB_CLOCK_SYNC_CCF_IMPL_H 24 #define INCLUDED_DIGITAL_PFB_CLOCK_SYNC_CCF_IMPL_H 25 26 #include <gnuradio/digital/pfb_clock_sync_ccf.h> 27 28 using namespace gr::filter; 29 30 namespace gr { 31 namespace digital { 32 33 class pfb_clock_sync_ccf_impl : public pfb_clock_sync_ccf 34 { 35 private: 36 bool d_updated; 37 double d_sps; 38 float d_loop_bw; 39 float d_damping; 40 float d_alpha; 41 float d_beta; 42 43 int d_nfilters; 44 int d_taps_per_filter; 45 std::vector<kernel::fir_filter_ccf*> d_filters; 46 std::vector<kernel::fir_filter_ccf*> d_diff_filters; 47 std::vector<std::vector<float>> d_taps; 48 std::vector<std::vector<float>> d_dtaps; 49 std::vector<float> d_updated_taps; 50 51 float d_k; 52 float d_rate; 53 float d_rate_i; 54 float d_rate_f; 55 float d_max_dev; 56 int d_filtnum; 57 int d_osps; 58 float d_error; 59 int d_out_idx; 60 61 uint64_t d_old_in, d_new_in, d_last_out; 62 63 void create_diff_taps(const std::vector<float>& newtaps, 64 std::vector<float>& difftaps); 65 66 public: 67 pfb_clock_sync_ccf_impl(double sps, 68 float loop_bw, 69 const std::vector<float>& taps, 70 unsigned int filter_size = 32, 71 float init_phase = 0, 72 float max_rate_deviation = 1.5, 73 int osps = 1); 74 ~pfb_clock_sync_ccf_impl(); 75 76 void setup_rpc(); 77 78 void update_gains(); 79 80 void forecast(int noutput_items, gr_vector_int& ninput_items_required); 81 82 void update_taps(const std::vector<float>& taps); 83 84 void set_taps(const std::vector<float>& taps, 85 std::vector<std::vector<float>>& ourtaps, 86 std::vector<kernel::fir_filter_ccf*>& ourfilter); 87 88 std::vector<std::vector<float>> taps() const; 89 std::vector<std::vector<float>> diff_taps() const; 90 std::vector<float> channel_taps(int channel) const; 91 std::vector<float> diff_channel_taps(int channel) const; 92 std::string taps_as_string() const; 93 std::string diff_taps_as_string() const; 94 95 void set_loop_bandwidth(float bw); 96 void set_damping_factor(float df); 97 void set_alpha(float alpha); 98 void set_beta(float beta); set_max_rate_deviation(float m)99 void set_max_rate_deviation(float m) { d_max_dev = m; } 100 101 float loop_bandwidth() const; 102 float damping_factor() const; 103 float alpha() const; 104 float beta() const; 105 float clock_rate() const; 106 107 float error() const; 108 float rate() const; 109 float phase() const; 110 111 /******************************************************************* 112 *******************************************************************/ 113 114 bool check_topology(int ninputs, int noutputs); 115 116 int general_work(int noutput_items, 117 gr_vector_int& ninput_items, 118 gr_vector_const_void_star& input_items, 119 gr_vector_void_star& output_items); 120 }; 121 122 } /* namespace digital */ 123 } /* namespace gr */ 124 125 #endif /* INCLUDED_DIGITAL_PFB_CLOCK_SYNC_CCF_IMPL_H */ 126