Thursday, October 11, 2012

Understanding a Singal Processing Block in GNU Radio : Block Signatures

A block signature is simply a specification of the data types that enter and exit a signal processing block.
It has been defined in a class gr_io_signature.h which you can locate in /usr/local/include/gnuradio/gr_io_signature.h or
http://gnuradio.org/doc/doxygen/gr__io__signature_8h.html


Lets look inside the header for class definition.

class GR_CORE_API gr_io_signature {
  int                          d_min_streams;
  int                          d_max_streams;
  std::vector    d_sizeof_stream_item;

  gr_io_signature(int min_streams, int max_streams,
          const std::vector &sizeof_stream_items);

  friend GR_CORE_API gr_io_signature_sptr
  gr_make_io_signaturev(int min_streams,
            int max_streams,
            const std::vector &sizeof_stream_items);

 public:

  static const int IO_INFINITE = -1;

  ~gr_io_signature (); // constructor

  int min_streams () const { return d_min_streams; }
  int max_streams () const { return d_max_streams; }
  int sizeof_stream_item (int index) const;
  std::vector sizeof_stream_items() const;
};

1. min_streams  specify minimum number of streams (>= 0)
 

2. max_streams  specify maximum number of streams (>= min_streams or -1 -> infinite)

3. sizeof_stream_items specify the size of the items in the streams

The `size' (number of bytes occupied) of an item in the stream is given by d_sizeof_stream_item, a member variable with the type of size_t.

size_t is the unsigned integer type of the result of the sizeof operator (and of the offsetof operator) so it is guaranteed to be big enough to contain the size of the biggest object your system can handle

If there are more streams than there are entries in sizeof_stream_items, the
value of the last entry in sizeof_stream_items is used for the missing values.

Sizeof_stream_items must contain at least 1 entry.

It is important to realize that any block has two signatures, one for the input interface and one for the output interface. The header file makes it clear that, for a given interface, gr_io_signature defines the minimum and maximum number of streams flowing through that interface, as well as the number of bytes in a single element of the stream.

The main purpose of signatures is so Python can raise an error for improper connections.

The following are examples of improper connections:
• Too {many/few} {input/output} connections for a block
• Type mismatch, e.g., gr_complex output connected to gr_int16 input


More details can be found in the header file itself.

Reference : http://www.dtic.mil/cgi-bin/GetTRDoc?AD=ADA556803

No comments:

Post a Comment