I am programming a filter for a FPGA.
The input is 14 bits, with registers arranged as [13:0], at a sample rate of 125 million samples per second.
I have coded the I/O to be this, where x[n] is input and y[n] is output:
aK,L[n] = x[n] − x[n − K] − x[n − L] + x[n − K − L]
b[n] = b[n − 1] + aK,L[n], n ≥ 0
c[n] = b[n] + MaK,L[n]
y[n] = y[n − 1] + c[n], n ≥ 0
There are 2 recursions needed, one at b[n] = b[n-1] + .... and one at y[n] = y[n-1] + ...
The first recursion at b[n] works properly, with expected outputs. The second recursion, however, exhibits some odd behavior. There are random spikes in the outputs for about 20 nanoseconds then return to expected values. The width of the input is 14 bits and all operations are done on 64 bit registers, oscillations are at a frequency of 100000hz, no overflow should be happening. Even if you're not sure how to fix this, any suggestions on what's causing this or possible solutions for this would be greatly appreciated (I honestly have no idea what could possibly be happening). Thanks in advance!
(Note: I should add that dividing c[n] by 1024 solves the issue, although I have no idea why. It does create new problems though, because of rounding errors, y[n] will approach to infinity if I divide c[n] by 1024. I am fine with dividing c[n] by 1024 if I can fix y[n] approaching infinity, as y[n] will simply be a trigger for the computer to capture x[n]).
- The code for this will be released as open-source once a working version is developed. For now, I'd prefer to not release any major section of the code just yet. If you need a specific module to know what's causing this problem, then let me know and I'll post code for it if reasonable. c[n] is correct, y[n] is incorrect after recursion. Every operation in the equation (coefficients, +, -, *, /, ect...) represents a module.
Additional information:
Compiler - Vivado 2016.02 on MBP r13' 2015
OS - computer:ubuntu 16.04 FPGASystem:debian Custom OS
Input - Advanced Digital Cable.