commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11575 - gnuradio/branches/developers/trondeau/pfb/gnu


From: trondeau
Subject: [Commit-gnuradio] r11575 - gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter
Date: Tue, 11 Aug 2009 16:55:57 -0600 (MDT)

Author: trondeau
Date: 2009-08-11 16:55:57 -0600 (Tue, 11 Aug 2009)
New Revision: 11575

Modified:
   
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc
   
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h
Log:
Bug fixes for PFB decimator and added documenation of its behavior.

Modified: 
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc
      2009-08-11 22:54:32 UTC (rev 11574)
+++ 
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc
      2009-08-11 22:55:57 UTC (rev 11575)
@@ -82,18 +82,26 @@
   d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_rate);
 
   // Create d_numchan vectors to store each channel's taps
-  std::vector< std::vector<float> > vtaps(d_rate);
+  d_taps.resize(d_rate);
 
+  // Make a vector of the taps plus fill it out with 0's to fill
+  // each polyphase filter with exactly d_taps_per_filter
+  std::vector<float> tmp_taps;
+  tmp_taps = taps;
+  while((float)(tmp_taps.size()) < d_rate*d_taps_per_filter) {
+    tmp_taps.push_back(0.0);
+  }
+  
   // Partition the filter
   for(i = 0; i < d_rate; i++) {
     // Each channel uses all d_taps_per_filter with 0's if not enough taps to 
fill out
-    vtaps[i] = std::vector<float>(d_taps_per_filter, 0);
+    d_taps[i] = std::vector<float>(d_taps_per_filter, 0);
     for(j = 0; j < d_taps_per_filter; j++) {
-      vtaps[i][j] = taps[i + j*d_rate];  // add taps to channels in reverse 
order
+      d_taps[i][j] = tmp_taps[i + j*d_rate];  // add taps to channels in 
reverse order
     }
     
     // Build a filter for each channel and add it's taps to it
-    d_filters[i]->set_taps(vtaps[i]);
+    d_filters[i]->set_taps(d_taps[i]);
   }
 
   // Set the history to ensure enough input items for each filter
@@ -102,7 +110,21 @@
   d_updated = true;
 }
 
+void
+gr_pfb_decimator_ccf::print_taps()
+{
+  unsigned int i, j;
+  for(i = 0; i < d_rate; i++) {
+    printf("filter[%d]: [", i);
+    for(j = 0; j < d_taps_per_filter; j++) {
+      printf(" %.4e", d_taps[i][j]);
+    }
+    printf("]\n\n");
+  }
+}
+
 #define ROTATEFFT
+
 int
 gr_pfb_decimator_ccf::work (int noutput_items,
                            gr_vector_const_void_star &input_items,

Modified: 
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h
===================================================================
--- 
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h
       2009-08-11 22:54:32 UTC (rev 11574)
+++ 
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h
       2009-08-11 22:55:57 UTC (rev 11575)
@@ -36,17 +36,77 @@
 class gri_fft_complex;
 
 /*!
- * \brief FIR filter with gr_complex input, gr_complex output and float taps
+ * \class gr_pfb_decimator_ccf
+ * \brief Polyphase filterbank bandpass decimator with gr_complex 
+ *        input, gr_complex output and float taps
+ *
  * \ingroup filter_blk
+ * 
+ * This block takes in a signal stream and performs interger down-
+ * sampling (decimation) with a polyphase filterbank. The first input
+ * is the integer specifying how much to decimate by. The second
+ * input is a vector (Python list) of floating-point taps of the 
+ * prototype filter. The third input specifies the channel to extract.
+ * By default, the zeroth channel is used, which is the baseband 
+ * channel (first Nyquist zone).
+ *
+ * The <EM>channel</EM> parameter specifies which channel to use since
+ * this class is capable of bandpass decimation. Given a complex input
+ * stream at a sampling rate of <EM>fs</EM> and a decimation rate of
+ * <EM>decim</EM>, the input frequency domain is split into 
+ * <EM>decim</EM> channels that represent the Nyquist zones. Using the
+ * polyphase filterbank, we can select any one of these channels to
+ * decimate.
+ *
+ * The output signal will be the basebanded and decimated signal from
+ * that channel. This concept is very similar to the PFB channelizer
+ * (see #gr_pfb_channelizer_ccf) where only a single channel is 
+ * extracted at a time.
+ *
+ * The filter's taps should be based on the sampling rate before
+ * decimation.
+ *
+ * For example, using the GNU Radio's firdes utility to building
+ * filters, we build a low-pass filter with a sampling rate of 
+ * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition
+ * bandwidth of <EM>TB</EM>. We can also specify the out-of-band
+ * attenuation to use, <EM>ATT</EM>, and the filter window
+ * function (a Blackman-harris window in this case). The first input
+ *  is the gain of the filter, which we specify here as unity.
+ *
+ *      <B><EM>self._taps = gr.firdes.low_pass_2(1, fs, BW, TB, 
+ *           attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B>
+ *
+ * The PFB decimator code takes the taps generated above and builds a
+ * set of filters. The set contains <EM>decim</EM> number of filters
+ * and each filter contains ceil(taps.size()/decim) number of taps.
+ * Each tap from the filter prototype is sequentially inserted into
+ * the next filter. When all of the input taps are used, the remaining
+ * filters in the filterbank are filled out with 0's to make sure each 
+ * filter has the same number of taps.
+ *
+ * The theory behind this block can be found in Chapter 6 of 
+ * the following book.
+ *
+ *    <B><EM>f. harris, Multirate Signal Processing for Communication 
+ *       Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B>
  */
+
 class gr_pfb_decimator_ccf : public gr_sync_block
 {
  private:
+  /*!
+   * Build the polyphase filterbank decimator.
+   * \param decim   (unsigned integer) Specifies the decimation rate to use
+   * \param taps    (vector/list of floats) The prototype filter to populate 
the filterbank.
+   * \param channel (unsigned integer) Selects the channel to return 
[default=0].
+   */
   friend gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int 
decim,
                                                              const 
std::vector<float> &taps,
                                                              unsigned int 
channel);
 
   std::vector<gr_fir_ccf*> d_filters;
+  std::vector< std::vector<float> > d_taps;
   gri_fft_complex         *d_fft;
   unsigned int             d_rate;
   unsigned int             d_chan;
@@ -55,8 +115,10 @@
   gr_complex              *d_rotator;
 
   /*!
-   * Construct a Polyphase filterbank for channelization with the given 
-   * number of channels and taps
+   * Build the polyphase filterbank decimator.
+   * \param decim   (unsigned integer) Specifies the decimation rate to use
+   * \param taps    (vector/list of floats) The prototype filter to populate 
the filterbank.
+   * \param channel (unsigned integer) Selects the channel to return 
[default=0].
    */
   gr_pfb_decimator_ccf (unsigned int decim, 
                        const std::vector<float> &taps,
@@ -65,9 +127,19 @@
 public:
   ~gr_pfb_decimator_ccf ();
   
-  void set_taps (const std::vector<float> &taps);
-  //void set_channel (unsigned int channel);
+  /*!
+   * Resets the filterbank's filter taps with the new prototype filter
+   * \param taps    (vector/list of floats) The prototype filter to populate 
the filterbank.
+   */
+   void set_taps (const std::vector<float> &taps);
 
+  /*!
+   * Print all of the filterbank taps to screen.
+   */
+  void print_taps();
+   
+ //void set_channel (unsigned int channel);
+
   int work (int noutput_items,
            gr_vector_const_void_star &input_items,
            gr_vector_void_star &output_items);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]