Forum Discussion
Altera_Forum
Honored Contributor
12 years agoIt's easy to average 2^n numbers - just apply numbers divided by 2^n (dividing by 2^n is just a binary shift by n bits) one by one to accumulator's input and after 2^n additions you'll get averaged value at accumulator's output.
If the number of values to average isn't 2 raised into n-th power you can use binary shift and multiplication by coef<1. Let the number of values be 10 so we have to divide each value by 10 or multiply by 0.1. 0.1=0.8/8. Firstly we shift values by 3 bits (2^3=8) and then multipies results by 0.8. Of course you have to enlarge the resolution so as not to reduce accuracy of the final result.