GNU Radio 3.6.4.2 C++ API
gr_pfb_channelizer_ccf Class Reference

Polyphase filterbank channelizer with gr_complex input, gr_complex output and float taps. More...

#include <gr_pfb_channelizer_ccf.h>

Inheritance diagram for gr_pfb_channelizer_ccf:
gr_block

Public Member Functions

 ~gr_pfb_channelizer_ccf ()
 
void set_taps (const std::vector< float > &taps)
 
void print_taps ()
 
std::vector< std::vector< float > > taps () const
 
void set_channel_map (const std::vector< int > &map)
 
std::vector< int > channel_map () const
 
int general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
 compute output items from input items More...
 
- Public Member Functions inherited from gr_block
 gr_block (void)
 
 gr_block (const std::string &name, gr_io_signature_sptr input_signature, gr_io_signature_sptr output_signature)
 
long unique_id (void) const
 
std::string name (void) const
 
virtual ~gr_block (void)
 
gr_io_signature_sptr input_signature (void) const
 
gr_io_signature_sptr output_signature (void) const
 
void set_input_signature (gr_io_signature_sptr sig)
 
void set_output_signature (gr_io_signature_sptr sig)
 
virtual bool check_topology (int ninputs, int noutputs)
 
virtual void forecast (int, std::vector< int > &)
 Overload me! I am the forecast. More...
 
virtual bool start (void)
 
virtual bool stop (void)
 
void consume_each (const int how_many_items)
 Call during work to consume items. More...
 
void consume (const size_t i, const int how_many_items)
 
void produce (const size_t o, const int how_many_items)
 
uint64_t nitems_read (const size_t which_input=0)
 Get absolute count of all items consumed on the given input port. More...
 
uint64_t nitems_written (const size_t which_output=0)
 Get absolute count of all items produced on the given output port. More...
 
void add_item_tag (const size_t which_output, const gr_tag_t &tag)
 
void add_item_tag (const size_t which_output, uint64_t abs_offset, const pmt::pmt_t &key, const pmt::pmt_t &value, const pmt::pmt_t &srcid=pmt::PMT_F)
 
void get_tags_in_range (std::vector< gr_tag_t > &tags, const size_t which_input, uint64_t abs_start, uint64_t abs_end, const pmt::pmt_t &key=pmt::pmt_t())
 
void set_alignment (const size_t alignment)
 
bool is_unaligned (void)
 
size_t fixed_rate_noutput_to_ninput (const size_t noutput_items)
 
size_t interpolation (void) const
 
void set_interpolation (const size_t)
 
size_t decimation (void) const
 
void set_decimation (const size_t)
 
int max_noutput_items (void) const
 
void set_max_noutput_items (int)
 
void unset_max_noutput_items (void)
 
bool is_set_max_noutput_items (void) const
 
unsigned history (void) const
 
void set_history (unsigned history)
 
void set_fixed_rate (const bool fixed_rate)
 
bool fixed_rate (void) const
 Get the fixed rate setting. More...
 
void set_relative_rate (const double relative_rate)
 
double relative_rate (void) const
 Get the relative rate setting. More...
 
void set_output_multiple (const size_t multiple)
 
size_t output_multiple (void) const
 Get the output multiple setting. More...
 
tag_propagation_policy_t tag_propagation_policy (void)
 
void set_tag_propagation_policy (tag_propagation_policy_t p)
 
void set_max_output_buffer (long)
 
void set_max_output_buffer (int, long)
 
long max_output_buffer (size_t)
 
void set_min_output_buffer (long)
 
void set_min_output_buffer (int, long)
 
long min_output_buffer (size_t)
 
std::string symbol_name () const
 
bool alias_set ()
 
std::string alias ()
 
pmt::pmt_t alias_pmt ()
 
void set_block_alias (std::string name)
 
template<typename T >
void set_msg_handler (pmt::pmt_t which_port, T msg_handler)
 
void message_port_register_in (pmt::pmt_t)
 
void message_port_register_out (pmt::pmt_t)
 
void message_port_pub (pmt::pmt_t, pmt::pmt_t)
 
void message_port_sub (pmt::pmt_t, pmt::pmt_t)
 
void message_port_unsub (pmt::pmt_t, pmt::pmt_t)
 
virtual bool message_port_is_hier (pmt::pmt_t port_id)
 
virtual bool message_port_is_hier_in (pmt::pmt_t port_id)
 
virtual bool message_port_is_hier_out (pmt::pmt_t port_id)
 
pmt::pmt_t message_ports_in ()
 Get input message port names. More...
 
pmt::pmt_t message_ports_out ()
 Get output message port names. More...
 
bool empty_p (pmt::pmt_t which_port)
 is the queue empty? More...
 
bool empty_p ()
 
void insert_tail (pmt::pmt_t, pmt::pmt_t)
 
pmt::pmt_t delete_head_nowait (pmt::pmt_t)
 
pmt::pmt_t delete_head_blocking (pmt::pmt_t)
 
msg_queue_t::iterator get_iterator (pmt::pmt_t which_port)
 
void erase_msg (pmt::pmt_t which_port, msg_queue_t::iterator it)
 
virtual bool has_msg_port (pmt::pmt_t which_port)
 
bool has_msg_handler (pmt::pmt_t which_port)
 Tests if there is a handler attached to port which_port. More...
 
virtual void dispatch_msg (pmt::pmt_t which_port, pmt::pmt_t msg)
 
void set_processor_affinity (const std::vector< int > &mask)
 Set the thread's affinity to processor core n. More...
 
void unset_processor_affinity ()
 Remove processor affinity to a specific core. More...
 
std::vector< int > processor_affinity ()
 Get the current processor affinity. More...
 
void work (const InputItems &, const OutputItems &)
 implements work -> calls general work More...
 
void notify_topology (const size_t, const size_t)
 notifications of new topological commits More...
 
void notify_active (void)
 start notification More...
 
void notify_inactive (void)
 stop notification More...
 
virtual void propagate_tags (const size_t, const gras::TagIter &)
 implements tag_propagation_policy() More...
 
void _update_input_reserve (void)
 
gras::BufferQueueSptr input_buffer_allocator (const size_t, const gras::SBufferConfig &)
 
gras::BufferQueueSptr output_buffer_allocator (const size_t, const gras::SBufferConfig &)
 

Friends

GR_CORE_API
gr_pfb_channelizer_ccf_sptr 
gr_make_pfb_channelizer_ccf (unsigned int numchans, const std::vector< float > &taps, float oversample_rate)
 

Additional Inherited Members

- Public Types inherited from gr_block
enum  { WORK_CALLED_PRODUCE = -2, WORK_DONE = -1 }
 Return options for the work call. More...
 
enum  tag_propagation_policy_t { TPP_DONT = 0, TPP_ALL_TO_ALL = 1, TPP_ONE_TO_ONE = 2 }
 
typedef std::deque< pmt::pmt_tmsg_queue_t
 
typedef std::map< pmt::pmt_t,
msg_queue_t,
pmt::pmt_comperator
msg_queue_map_t
 
typedef std::map< pmt::pmt_t,
msg_queue_t,
pmt::pmt_comperator >
::iterator 
msg_queue_map_itr
 
typedef boost::function< void(pmt::pmt_t)> msg_handler_t
 
typedef std::map< pmt::pmt_t,
msg_handler_t,
pmt::pmt_comperator
d_msg_handlers_t
 
- Public Attributes inherited from gr_block
long _unique_id
 
std::string _name
 
std::string d_symbol_alias
 
std::string d_symbol_name
 
msg_queue_map_t msg_queue
 
pmt::pmt_t message_subscribers
 
d_msg_handlers_t d_msg_handlers
 
gruel::mutex d_setlock
 
std::vector< int > d_affinity
 
gr_vector_int _work_ninput_items
 
gr_vector_int _fcast_ninput_items
 
size_t _num_outputs
 
ptrdiff_t _work_io_ptr_mask
 
size_t _output_multiple_items
 
double _relative_rate
 
bool _enable_fixed_rate
 
size_t _input_history_items
 
tag_propagation_policy_t _tag_prop_policy
 
size_t _interp
 
size_t _decim
 
gr_io_signature_sptr _in_sig
 
gr_io_signature_sptr _out_sig
 

Detailed Description

Polyphase filterbank channelizer with gr_complex input, gr_complex output and float taps.

This block takes in complex inputs and channelizes it to M channels of equal bandwidth. Each of the resulting channels is decimated to the new rate that is the input sampling rate fs divided by the number of channels, M.

The PFB channelizer code takes the taps generated above and builds a set of filters. The set contains M 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 i and performs the inner product calculation to i+(n-1) where n 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 M 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 i in the vector is the next sample from the ith channel. This is most easily handled by sending the output to a gr_vector_to_streams block to handle the conversion and passing M 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 M 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 fs, a 3-dB bandwidth of BW and a transition bandwidth of TB. We can also specify the out-of-band attenuation to use, ATT, 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 filter output can also be overs ampled. The over sampling rate is the ratio of the the actual output sampling rate to the normal output sampling rate. It must be rationally related to the number of channels as N/i for i in [1,N], which gives an outputsample rate of [fs/N, fs] where fs is the input sample rate and N is the number of channels.

For example, for 6 channels with fs = 6000 Hz, the normal rate is 6000/6 = 1000 Hz. Allowable oversampling rates are 6/6, 6/5, 6/4, 6/3, 6/2, and 6/1 where the output sample rate of a 6/1 oversample ratio is 6000 Hz, or 6 times the normal 1000 Hz. A rate of 6/5 = 1.2, so the output rate would be 1200 Hz.

The theory behind this block can be found in Chapter 6 of the following book.

f. harris, "Multirate Signal Processing for Communication Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.

Constructor & Destructor Documentation

gr_pfb_channelizer_ccf::~gr_pfb_channelizer_ccf ( )

Member Function Documentation

std::vector<int> gr_pfb_channelizer_ccf::channel_map ( ) const

Gets the current channel map.

int gr_pfb_channelizer_ccf::general_work ( int  noutput_items,
gr_vector_int &  ninput_items,
gr_vector_const_void_star &  input_items,
gr_vector_void_star &  output_items 
)
virtual

compute output items from input items

Parameters
noutput_itemsnumber of output items to write on each output stream
ninput_itemsnumber of input items available on each input stream
input_itemsvector of pointers to the input items, one entry per input stream
output_itemsvector of pointers to the output items, one entry per output stream
Returns
number of items actually written to each output stream, or -1 on EOF. It is OK to return a value less than noutput_items. -1 <= return value <= noutput_items

general_work must call consume or consume_each to indicate how many items were consumed on each input stream.

Reimplemented from gr_block.

void gr_pfb_channelizer_ccf::print_taps ( )

Print all of the filterbank taps to screen.

void gr_pfb_channelizer_ccf::set_channel_map ( const std::vector< int > &  map)

Set the channel map. Channels are numbers as:

N/2+1 | ... | N-1 | 0 | 1 |  2 | ... | N/2

<----------------— 0 -----------------—> freq

So output stream 0 comes from channel 0, etc. Setting a new channel map allows the user to specify which channel in frequency he/she wants to got to which output stream.

The map should have the same number of elements as the number of output connections from the block. The minimum value of the map is 0 (for the 0th channel) and the maximum number is N-1 where N is the number of channels.

We specify M as the number of output connections made where M <= N, so only M out of N channels are driven to an output stream. The number of items in the channel map should be at least M long. If there are more channels specified, any value in the map over M-1 will be ignored. If the size of the map is less than M the behavior is unknown (we don't wish to check every entry into the work function).

This means that if the channelizer is splitting the signal up into N channels but only M channels are specified in the map (where M <= N), then M output streams must be connected and the map and the channel numbers used must be less than N-1. Output channel number can be reused, too. By default, the map is [0...M-1] with M = N.

void gr_pfb_channelizer_ccf::set_taps ( const std::vector< float > &  taps)

Resets the filterbank's filter taps with the new prototype filter

Parameters
taps(vector/list of floats) The prototype filter to populate the filterbank.
std::vector<std::vector<float> > gr_pfb_channelizer_ccf::taps ( ) const

Return a vector<vector<>> of the filterbank taps

Friends And Related Function Documentation

GR_CORE_API gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf ( unsigned int  numchans,
const std::vector< float > &  taps,
float  oversample_rate 
)
friend

Build the polyphase filterbank decimator.

Parameters
numchans(unsigned integer) Specifies the number of channels M
taps(vector/list of floats) The prototype filter to populate the filterbank.
oversample_rate(float) The over sampling rate is the ratio of the the actual output sampling rate to the normal output sampling rate. It must be rationally related to the number of channels as N/i for i in [1,N], which gives an outputsample rate of [fs/N, fs] where fs is the input sample rate and N is the number of channels.

For example, for 6 channels with fs = 6000 Hz, the normal rate is 6000/6 = 1000 Hz. Allowable oversampling rates are 6/6, 6/5, 6/4, 6/3, 6/2, and 6/1 where the output sample rate of a 6/1 oversample ratio is 6000 Hz, or 6 times the normal 1000 Hz.


The documentation for this class was generated from the following file: