EmbDev.net

Forum: FPGA, VHDL & Verilog recursive average calculation


von Timon (Guest)


Attached files:

Rate this post
useful
not useful
Hello,

I am trying to do linear regression (approximation) on current samples 
that I receive from a SINC filter. The SINC filter has a clock of 20MHz 
and the output(current sample) of the SINC filter block changes every 
1.25 MHz. Now I need to use this data (whenever there is new value) to 
do Linear regression which will have a clock of 160MHz. Can anyone give 
me an idea on how to do linear regression on the samples only when there 
is a new data(every 1.25MHz) from the SINC filter block??
To perform linear regression I need to find the average value of samples 
recursively for which I would need to increment a counter whenever there 
is new sample and reset to 0 after regression calculation, I also need 
an idea on how to realise this counter??

I have the VHDL code for recursive averaging, the count is not 
propererly implemented.

von S. N. (higgns)


Rate this post
useful
not useful
You will have to implement a simple 2-way-handshake to hand over data 
and guarantee their uniqueness between modules.

Further I'm not sure what you mean by "recursive average". I'm guessing 
moving average in which case the easiest way is to use a FWFT FIFO.
Say you want to average the latest 32 data points:
1
if in_valid = '1' then
2
    sum := sum + in_data;
3
    fifo_in <= in_data; fifo_we <= '1';
4
5
    if count = 31 then
6
        sum := sum - fifo_out;
7
        fifo_re <= '1';
8
    else
9
        count <= count + 1;
10
    end if;
11
    avg <= sum / 32;
12
end if;

: Edited by User
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.