pravin Posted February 20, 2015 Report Share Posted February 20, 2015 Hi all, i have to create simple summation block using general vi please find attached snapshot for ref. 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 Quote Link to comment
crossrulz Posted February 20, 2015 Report Share Posted February 20, 2015 FOR loop with a shift register and ADD inside. Quote Link to comment
hooovahh Posted February 20, 2015 Report Share Posted February 20, 2015 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. Quote Link to comment
pravin Posted February 23, 2015 Author Report Share Posted February 23, 2015 Thanks for the input. how to convert below code in to FPGA Quote Link to comment
JamesMc86 Posted February 23, 2015 Report Share Posted February 23, 2015 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 Quote Link to comment
smithd Posted February 23, 2015 Report Share Posted February 23, 2015 Avg_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). Quote Link to comment
pravin Posted February 25, 2015 Author Report Share Posted February 25, 2015 Hi , I have tried but got error while creating array. can you give me some ref example or link of above mentioned code. since i am beginner for labview fpga. Thanks Pravin Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.