[Top][All Lists]

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

Re: [Discuss-gnuradio] noutput_items in every block

From: Michael Dickens
Subject: Re: [Discuss-gnuradio] noutput_items in every block
Date: Tue, 02 Jan 2018 08:43:13 -0500

If one uses gr::block and ::general_work, then I believe that there are no 
constraints on the I/O streams & one can have generalized ninput and noutput 
items on each stream.

It's when one moves to specialized blocks (e.g., gr::sync_block, 
gr::sync_interpolator, gr::tagged_stream, etc), that constraints are put on the 
I/O streams.

Thus, Sakthivel, for your I/Q example you'd want to inherit from gr::sync_block 
and use ::work() to guarantee that the ninput items are the same for each 
stream. You can see the (quite simple) code for ::forecast which provides this 
guarantee here: < 

Cheers! - MLD

On Tue, Jan 2, 2018, at 8:26 AM, Jeff Long wrote:
> Correction: sync_block guarantees number of inputs (on each port) to be 
> equal to number of outputs. The sync_decimator and sync_interpolator 
> allow number of inputs (on each port) a 1:N or N:1 relationship between 
> input and output. Sorry for the confusion.
> On 01/02/2018 08:07 AM, Jeff Long wrote:
> > Yes, you'll get the same number of samples on both inputs if you derive 
> > from sync_block. For example, here is the code from the "add" block:
> > 
> > add_ff_impl::work(int noutput_items,
> >      gr_vector_const_void_star &input_items,
> >      gr_vector_void_star &output_items)
> > {
> >    float *out = (float *) output_items[0];
> >    int noi = d_vlen*noutput_items;
> > 
> >    memcpy(out, input_items[0], noi*sizeof(float));
> >    for(size_t i = 1; i < input_items.size(); i++)
> >      volk_32f_x2_add_32f(out, out, (const float*)input_items[i], noi);
> >    return noutput_items;
> > }
> > 
> > For blocks derived from sync_decimator or sync_interpolator, you can 
> > also assume that the number of input and output items will be the same 
> > (or related).
> > 
> > On 01/02/2018 05:46 AM, Sakthivel Velumani wrote:
> >> Hi Michael,
> >>
> >> Thank you very much for the detailed explanation. I have one more 
> >> query - If a block has two input streams, will the no of items be same 
> >> in both streams? say for example I build a block that takes I and Q 
> >> samples as input and the algorithm demands I sample and its 
> >> corresponding Q sample to work correctly. In this case does the 
> >> scheduler guarantee that the items in both buffer are of same number 
> >> and in the same order? or do I have to check that I am processing 
> >> every Q sample and its corresponding I sample using tags or some other 
> >> mechanism?

reply via email to

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