#include // supports printf #include "util.h" // supports verify // Add two Q1.31 fixed point numbers int add_q31(int a, int b) { return a + b; } // Multiplly two Q1.31 fixed point numbers int mul_q31(int a, int b) { long res = (long)a * (long)b; int result = res >> 31; // shift right to get the 32-bit result; this is equivalent to shifting left by 1 and discarding the bottom 32 bits //printf("mul_q31: a = %x, b = %x, res = %lx, result = %x\n", a, b, res, result); return result; } // low pass filter x with coefficients c, result in y // n is the length of x, m is the length of c // y[i] = c[0]*x[i] + c[1]*x[i+1] + ... + c[m-1]*x[i+m-1] // inputs in Q1.31 format void fir(int x[], int c[], int y[], int n, int m) { int i, j; for (j=0; j