[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11576 - gnuradio/branches/developers/trondeau/pfb/gnu
From: |
trondeau |
Subject: |
[Commit-gnuradio] r11576 - gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter |
Date: |
Tue, 11 Aug 2009 16:56:57 -0600 (MDT) |
Author: trondeau
Date: 2009-08-11 16:56:56 -0600 (Tue, 11 Aug 2009)
New Revision: 11576
Modified:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h
Log:
Bug fixes for PFB channelizer and added documenation of its behavior.
Modified:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
===================================================================
---
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
2009-08-11 22:55:57 UTC (rev 11575)
+++
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
2009-08-11 22:56:56 UTC (rev 11576)
@@ -76,18 +76,26 @@
d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_numchans);
// Create d_numchan vectors to store each channel's taps
- std::vector< std::vector<float> > vtaps(d_numchans);
+ d_taps.resize(d_numchans);
+ // 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_numchans*d_taps_per_filter) {
+ tmp_taps.push_back(0.0);
+ }
+
// Partition the filter
for(i = 0; i < d_numchans; 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_numchans]; // add taps to channels in
reverse order
+ d_taps[i][j] = tmp_taps[i + j*d_numchans]; // 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
@@ -96,6 +104,20 @@
d_updated = true;
}
+void
+gr_pfb_channelizer_ccf::print_taps()
+{
+ unsigned int i, j;
+ for(i = 0; i < d_numchans; i++) {
+ printf("filter[%d]: [", i);
+ for(j = 0; j < d_taps_per_filter; j++) {
+ printf(" %.4e", d_taps[i][j]);
+ }
+ printf("]\n\n");
+ }
+}
+
+
int
gr_pfb_channelizer_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_channelizer_ccf.h
===================================================================
---
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h
2009-08-11 22:55:57 UTC (rev 11575)
+++
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h
2009-08-11 22:56:56 UTC (rev 11576)
@@ -34,25 +34,90 @@
class gr_fir_ccf;
class gri_fft_complex;
+
/*!
- * \brief FIR filter with gr_complex input, gr_complex output and float taps
+ * \class gr_pfb_channelizer_ccf
+ *
+ * \brief Polyphase filterbank channelizer with
+ * gr_complex input, gr_complex output and float taps
+ *
* \ingroup filter_blk
+ *
+ * This block takes in complex inputs and channelizes it to <EM>M</EM>
+ * channels of equal bandwidth. Each of the resulting channels is
+ * decimated to the new rate that is the input sampling rate
+ * <EM>fs</EM> divided by the number of channels, <EM>M</EM>.
+ *
+ * The PFB channelizer code takes the taps generated above and builds
+ * a set of filters. The set contains <EM>M</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.
+ *
+ * Each filter operates using the gr_fir filter classs of GNU Radio,
+ * which takes the input stream at <EM>i</EM> and performs the inner
+ * product calculation to <EM>i+(n-1)</EM> where <EM>n</EM> is the
+ * number of filter taps. To efficiently handle this in the GNU Radio
+ * structure, each filter input must come from its own input
+ * stream. So the channelizer must be provided with <EM>M</EM> streams
+ * where the input stream has been deinterleaved. This is most easily
+ * done using the gr_stream_to_streams block.
+ *
+ * The output is then produced as a vector, where index <EM>i</EM> in
+ * the vector is the next sample from the <EM>i</EM>th channel. This
+ * is most easily handled by sending the output to a
+ * gr_vector_to_streams block to handle the conversion and passing
+ * <EM>M</EM> streams out.
+ *
+ * The input and output formatting is done using a hier_block2 called
+ * pfb_channelizer_ccf. This can take in a single stream and outputs
+ * <EM>M</EM> streams based on the behavior described above.
+ *
+ * The filter's taps should be based on the input sampling rate.
+ *
+ * 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 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.
+ *
*/
+
class gr_pfb_channelizer_ccf : public gr_sync_block
{
private:
+ /*!
+ * Build the polyphase filterbank decimator.
+ * \param numchans (unsigned integer) Specifies the number of channels
<EM>M</EM>
+ * \param taps (vector/list of floats) The prototype filter to populate
the filterbank.
+ */
friend gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int
numchans,
const
std::vector<float> &taps);
std::vector<gr_fir_ccf*> d_filters;
+ std::vector< std::vector<float> > d_taps;
gri_fft_complex *d_fft;
unsigned int d_numchans;
unsigned int d_taps_per_filter;
bool d_updated;
/*!
- * Construct a Polyphase filterbank for channelization with the given
- * number of channels and taps
+ * Build the polyphase filterbank decimator.
+ * \param numchans (unsigned integer) Specifies the number of channels
<EM>M</EM>
+ * \param taps (vector/list of floats) The prototype filter to populate
the filterbank.
*/
gr_pfb_channelizer_ccf (unsigned int numchans,
const std::vector<float> &taps);
@@ -60,7 +125,16 @@
public:
~gr_pfb_channelizer_ccf ();
+ /*!
+ * 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();
int work (int noutput_items,
gr_vector_const_void_star &input_items,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11576 - gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter,
trondeau <=