discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Block with N inputs and M outputs (M>=N)


From: Michael Dickens
Subject: Re: [Discuss-gnuradio] Block with N inputs and M outputs (M>=N)
Date: Mon, 10 Apr 2006 21:09:41 -0400

Achilleas - I did not have the gr_sync_interpolator code in front of me when I wrote originally, so it was a guess ... which was not entirely correct (the interpolation must be an -integer- value, while yours is not guaranteed to be so). Thus, yes, you will need to inherit from "gr_block" and, since M and N are reasonably small, you can use "set_output_multiple(M)" to guarantee a multiple of N input items when you use write "forecast()" to handle this. For example, if "d_M" and "d_N" are the values of M and N at instantiation, then ...

1) In your instantiator, include:
+++
// Set the approximate output rate / input rate
  set_relative_rate (1.0 * d_M / ((double) d_N));
// Set the output multiple to guarantee a multiple of M
  set_output_multiple (d_M);
+++
2) In forecast (), include:
+++
// Check that the number of requested output items is a multiple of M
  assert (noutput_items % d_M == 0);
// find the number of input items required to
// generate the requested number of output items
  int ninput_items =  d_N * noutput_items / d_M;
// set all streams' input requirements
  unsigned ninputs = ninput_items_required.size ();
  for (unsigned i = 0; i < ninputs; i++)
    ninput_items_required[i] = ninput_items;
+++
3) In general_work (), include:
+++
// Check that the number of requested output items is a multiple of M
  assert (noutput_items % d_M == 0);
// find the number of input items required to
// generate the requested number of output items
  int ninput_items = d_N * noutput_items / d_M;
+++
to get the number of input items as make sure it really is a multiple of N (via that the # of output items is a multiple of M). You can, of course, choose other means for doing this which are more in your coding style. And the asserts can be dropped (I use #if's) once you're happy that it's all working as you want. Hope this is clear! - MLD




reply via email to

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