Jump to content

Summation block


pravin

Recommended Posts

Hi all,

i have to create simple summation block using general vi 

please find attached snapshot for ref. post-15324-0-82100100-1424435361_thumb.p

in that i want to replace this summation block with general vi logic to deploy in fpga. since fpga don't have summation block.

 

Request you all please let me know if any suggestion.

Thanks

Pravin 

 

Link to post

For loop with a shift register is the right way.  But one thing to mention if you didn't know is arrays in the FPGA are of a fixed size.  So another (less modular) solution is to have an index array function which pulls out all of your elements, and then wire that to a compound arithmetic.  This only works if you know the array size and on the FPGA you will know it at edit time.

Link to post

Its going to depend on how fast it needs to run but some general advice:

 

  • Typically we don't use floating point numbers on FPGA as it takes way too much space. You will need to convert to fixed point maths.
  • We avoid arrays for the same reason which makes this design tricky. You could use a FIFO to track the historical values though.
  • Every time you add a sample you update the running total instead of re-summing all values each time, it would be much quicker and avoid the use of arrays.

I would have a search for a moving average, I imagine someone has done this before. There is a mean in the FPGA palettes but I don't think it does a moving average like this, it will just output a value every time it has enough samples to calculate one

Link to post

attachicon.gifAvg_Running.pngThanks for the input.

how to convert below code in to FPGA

Depends on how fast you want it to run. You could of course store an array on the FPGA and sum it every time, but that will take a while for a decently large array. If thats fine, then you're close, you just need to remember that FPGA only supports fixed-size arrays and that the order in which you sum samples doesn't particularly matter. You really just need an array, a counter to keep track of your oldest value, and replace array subset.

 

If you do need this to run faster you should think about what happens on every iteration -- you only remove one value and add another value. So lets say you start with (A+B+C)/3 as your avg. On the next iteration its (B+C+D)/3. So the difference is adding (D/3), the newest sample divided by size, and subtracting the oldest sample/size (A/3).

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.