CIC Filter implementation for Normalized Correlation This is a follow-on to the original post ...

I am trying to implement real-time correlation of two signals. I noticed the CIC Filter discussion here:

How to find correlation/cross-correlation of two signals in real time?

... however I need to use a normalized correlation for detection.  What would the complete block diagram or equation be for a normalized CIC Filter?

Additional:
I don't have to use the CIC - it just appeared to be computationally cheap and simple to implement.  Would a moving window sum of the signal product, divided by the product of stdevs (to normalize) also work?

I.e., if I took the most recent N samples of each signal, and computed the normalized cross correlation, would that be the typical approach?

Follow-on:  I have experimented with various ways of measuring signal similarity, and am getting some odd results.  My scenario is two signals, X and Y, aligned in time.  The X series counts from 0 to 20 over 21 samples (N).  The Y series counts from 20 to 0.  

I calculate the Pearson product-moment correlation coefficient over the entire series and get an R value of '-1', as expected.  But since I'm interested in getting (near) real-time indication of similarity, I implemented the CIC filter approach, as discussed below, and normalized the value by dividing by the square root of the product of two other CIC filters (that each square the X and Y inputs, respectively).

So I am computing the normalized cross correlation of X and Y, using a 'window' of 3, by:

R(normal) = Rxy / (Rxx * Ryy)^0.5, using three CIC structures suggested by Boschen in:

How to find correlation/cross-correlation of two signals in real time?

Note I am not scaling this by N, as suggested by the answer below (I'm still not clear on this).

Now the problem ... the normalized value I get is '+1', not '-1'.  Also, the result using the three CIC filter structures seems to be sensitive to when the data series is near, or crosses, zero.  My guess is I'm still not implementing this correctly ... or is the CIC approach just sensitive this way?

As a further experiment, I implemented a 'windowed' Pearson correlation calculation, computing normalized value 'R' for the most recent 3 samples, and obtained correlation values near '-1', as expected, and it does this consistently regardless of whether the data series is near or crosses zero.

The CIC approach would seem to be preferred as a faster computation, but is giving inconsistent results.
So, assuming you already know that the two streams you're multiplying point-wise are aligned, and you want the output of your system to be the correlation coefficient of zero shift for the length of the CIC-built averager, this is the way to go.

So, the output of your CIC will be the sum of all point-wise products of the last N samples flying through.

Now, if either input stream becomes overly "strong", that product might become very large, regardless of whether the correlation is actually strong or not.

To avoid that, you'd usually just divide by the square root of the product of energies of both sequences. Assuming the signals are stochastic stationary signals, that would be the product of the square roots of N times the variance, which is simply N times the product of the standard deviations. If you have knowledge of these, a simple multiplication of an input or the output by 1/(N·std1·std2) would do.

Assuming you have no knowledge, you can measure: Just use the same CIC structure on the two squared inputs (instead of their product) to get the instantaneous energy, and divide the result of your CIC correlator by the square root of that.