A Moving Average (MA) filter computes the average of the last N samples. Its difference equation is given by,
where is the input signal, and
is the output signal.
For a DSP engineer a MA filter is a “good” smoothing filter in the sense of being optimal for reducing random white noise but, a “bad” low-pass filter since its roll-off is slow and the stopband attenuation is awful (sinc function). For a digital designer a MA filter is a small, low-power and fast structure since there are no multipliers to design, only adders/subtractors. Its recursive representation is given by,
which yields for relatively big N’s a very efficient implementation in terms of delay elements and number of full-adders. (Note that, except for the factor 1/N, this implementation equals to the one given by an integrator-comb section of a cascaded intergrator-comb (CIC) filter).
If the output of the MA filter is to be decimated (sample rate decrease by R) then it is a good idea to place decimation within the filter so that the sample values that are not needed for the final output are not computed. Well, you might say that this is exactly what efficient CIC decimation filters do. Right, but if the sample rate reduction factor, R, is a multiple of or equal to N, the averaging factor, then we can do better. The point is that if we take one output sample out of R and RN then we can do word-serial arithmetic, that is processing the input sample serially. An accumulate-and-dump circuit does the job,
where CKfast is the clock running at the original sampling rate, CKslow is the R-times reduced clock, and tcnt is a pulse every N clock cycles of CKfast (for example, the terminal count of a counter). Note that the accumulate register (ACC) must be of length bits, with
the length of the input signal, to accomodate the length of the output signal.
Compared to a first-order CIC decimation filter one saves the comb section (subtractor) at the cost of logic needed for resetting the ACC register.