discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: History and forecast


From: Jeff Long
Subject: Re: History and forecast
Date: Mon, 28 Aug 2023 09:17:14 -0400

You are correct! The code I was looking at takes advantage of the math done in a lower layer (the sync/interp/decim implementation).

Separately, having the (-1) exposed to the user is confusing. We really shouldn't bother the user with that. It may be left over from some assumption about how FIR filters work, or may just be "the way it's done".

On Mon, Aug 28, 2023 at 8:52 AM Marco Menchise <marco.menchise@gmail.com> wrote:


On Mon, Aug 28, 2023 at 1:08 PM Jeff Long <willcode4@gmail.com> wrote:
See fir_filter_blok.impl.cc for an example ...

forecast() does not include history. For a sync, interp or decim block, forecast is not required at all.
 
Sorry I can't find the code you pointed out. 

I saw this:
https://github.com/n-west/gnuradio-volk/blob/master/gnuradio-runtime/python/gnuradio/gr/gateway.py

I don't know what block is but it seems that default forecast implementation does include history. 


history() should be the number of previous items required, without the (-1).


If history=1 (default) there are no items prepended. So the number of prepended items should be history-1

This post 

https://lists.gnu.org/archive/html/discuss-gnuradio/2011-02/msg00480.html

seems to state the same thing: 

"If you set the history to 'N', this means you always have the last (N-1) input values kept in your buffer."

Am I wrong?

Thanks,
Marco



 

On Mon, Aug 28, 2023 at 5:08 AM Marco Menchise <marco.menchise@gmail.com> wrote:
Hi, I'm a gnuradio newbie. 

I'm trying to write a block that calculates output at time k based on three input samples: one at time k-N-1 (in the past), one at time k (the current sample) and one at k+M (in the future).

I spent some hours struggling against "history" and forecast function.

I found a good visualization of  the history concept. As I said, I also need to process "future" samples so I also investigated the "forecast" function.

Here is what I understood:

1) history=N tells the scheduler to prepend N-1 "old" samples to the input_items buffer. The oldest prepended sample has relative index = 0, so the "current" buffer starts at index N-1. 

2) The forecast function must return N-1 + noutput_items+ M, where M is the number of samples required in the future. Forecast *must* take into account history. Each general_work call is guaranteed to have *at least* N-1 + noutput_items+ M samples in input_items buffer.

3) I did some tests and noticed that the scheduler may pass to general_work *more* than N-1+noutput_items+M samples. Extra samples should be ignored by general_work. They will be passed again in the next call.

4) general_work must "consume" just noutput_items samples

I tried to collect all those concepts in the attached figure where I used both absolute and relative indexes to mark samples. I assumed history=4 and M=2. The input_items in the first general_work call has at least 9 samples. I must process input samples from 103 to 106 (included) using samples from 100 to 108 (included) and I must generate 4 output_samples. In the next call I must process samples from 107 to 110 (included) and, again, I must generate 4 output samples. I must ignore "extra" samples in both cases.

Is that correct? I'm I missing something?

Thanks,
Marco

 



gnuradio.drawio (1).png

reply via email to

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