Forum: FPGA, VHDL & Verilog recursive average calculation

Author: Timon (Guest)
Posted on:
Attached files:

Rate this post
0 useful
not useful

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.

Author: S. N. (higgns)
Posted on:

Rate this post
0 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:
if in_valid = '1' then
    sum := sum + in_data;
    fifo_in <= in_data; fifo_we <= '1';

    if count = 31 then
        sum := sum - fifo_out;
        fifo_re <= '1';
        count <= count + 1;
    end if;
    avg <= sum / 32;
end if;

: Edited by User


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.