|
StarCore code optimizer ( sco )
is
capable of handling
different coding techniques that often used to implement many of DSP
algorithms.
void fir( int *input,
/*
pointer to input
sample array of NTAPS points*/
int *output, /* pointer to output array of NPOINTS points */ int *coefficient /* pointer to coefficient array of NTAPS values */ ) { int i, j; int *data, *coef, *initial; int sum; int tmp1, tmp2; initial = input; for ( i = 0; i < NPOINTS; i++ ) { data = input++; coef = coefficient; sum = 0; for (j = 0; j < NTAPS; j++) { tmp1 = *data; if ( data == initial ) { data = initial + ( NTAPS - 1 ); } else { data--; } tmp2 = *coef++; sum += tmp1 * tmp2; } *output++ = sum; } }
void fir( int *input,
/*
pointer to input sample array of NTAPS points*/
void fir( int *input,
/*
pointer
to input sample array of NTAPS points*/
int *output, /* pointer to output array of NPOINTS points */ int *coefficient /* pointer to coefficient array of NTAPS values */ ) { int i, j; int *data, *coef, *initial; int sum; int tmp1, tmp2; initial = input; for ( i = 0; i < NPOINTS; i++ ) { data = input++; coef = coefficient; sum = 0; tmp1 = *data; if ( data==initial ) { data = initial + ( NTAPS - 1 ); } else { data--; } tmp2 = *coef++; for ( j = 1; j < NTAPS; j++ ) { sum += tmp1 * tmp2; tmp1 = *data; if ( data == initial ) { data = initial + ( NTAPS - 1 ); } else { data--; } tmp2 = *coef++; } sum += tmp1 * tmp2; *output++ = sum; } }
3. use of "arrays":
void fir( int input[],
/*
input sample array of NTAPS points */
int output[], /* output array of NPOINTS points */ int coefficient[] /* array of NTAPS coefficients */ ) { int i; int j; int sum; for ( i = 0; i < NPOINTS; i++ ) { sum = 0; for ( j = 0; j < NTAPS; j++ ) { if ( ( i - j ) < 0 ) { sum += input[i-j+NTAPS] * coefficient[j]; } else { sum += input[i-j] * coefficient[j]; } } output[i] = sum; } }
4. use of "arrays with a swap":
void fir( int input[],
/*
input sample array of
NTAPS points */
The
following table lists execution time
improvements achieved by sco
over
different implementations of the
|