Let’s cover some signal processing basics:
Say our block’s input signal is x[k] and the output signal is y[k].
Let’s assume there’s one input to keep things simple.
If a block has a history of N, the output depends on N samples of the
input, or
y[k] = f(x[k], x[k-1], …, x[k-N-1]).
If the block is linear, then
y[k] = \sum_{l = 0}^{N-1} a_l x[k-l]
Any block like this is equivalent to an FIR filter, regardless of what
it’s called.
But say we are actually filtering, and have an odd number of taps.
How about making a filter with zero phase? That would ask for:
y[k] = \sum_{l = (N-1)/2}^{(N-1)/2} a_l x[k-l]
Whoops–if we want to keep causality, that won’t work. /That’s/ a block
that would be looking into the future.[1]
So we relax the requirements, and simply use the next samples we have
available in the input buffer. But what about the delay line?
GNU Radio understands this problem, and offers to take care of the delay
line for you by providing set_history(). So let’s think of set_history()
as a signal-processing related setting.
forecast() is an entirely different beast. It tells the scheduler how
man input items a block requires before it can produce any (or a given
amount of) output. In a sync block, we ‘trick’ the scheduler to give us
more samples to include the delay line (when we consume noutput_items
items, the delay line is still in there).
So if you override forecast(), then yes, obviously, the scheduler will
give you this much input. It’s hard-wired to do so.
In a sync block (and related, i.e. sync_interpolator), it is always
clear how many input items I need to produce an number of output items.
That’s why forecast() needn’t be overridden in those cases (probably:
shouldn’t); the stock blocks do stick to this (with, possibly, some
exceptions but I can’t think of any right now).
In a gr::block, things are different. You only choose this type of block
if you don’t know the ratio input:output (or there isn’t a rational
one). An example of the latter is the fractional resampler (its
forecast() looks very much like that of a sync_interpolator!).
An example of the former would be any gr_tagged_stream_block.
There are other settings that control streaming behaviour, such as
set_output_multiple().
If you have any more questions, do add some specifics of what you’re
trying to achieve.
MB
[1] The peak detector does this, and in a sense is looking into the
future. But it has to look back inside the input buffer, and thus is
causing latency, even if it doesn’t look like it if your time
reference is sample time.
On Tue, Aug 27, 2013 at 12:43:34PM -0500, Miklos M. wrote:
discusses the whole concept several times.
sync_interpolator for which forecast actually requests "noutput_items
If you need the precise history inside forecast(), chances are the
buffer (which will be hard to debug).
(or more) you have requested in your forecast, so magically you will
interacting. Supposedly, the scheduler can figure out a static
scheduler make optimal schedule?
ninput_items. So if you have no history configured, it must consume
Best,
Discuss-gnuradio mailing list
Kaiserstraße 12
Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page
Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page
–
Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)
Dipl.-Ing. Martin B.
Research Associate
Kaiserstraße 12
Building 05.01
76131 Karlsruhe
Phone: +49 721 608-43790
Fax: +49 721 608-46071
www.cel.kit.edu
KIT – University of the State of Baden-Württemberg and
National Laboratory of the Helmholtz Association