2 example 2, 1 c code, 2 maverickcrunch assembly language instructions – Cirrus Logic EP93xx User Manual

Page 79: 2 example 2 -9

Advertising
background image

DS785UM1

3-9

Copyright 2007 Cirrus Logic

MaverickCrunch Co-Processor

EP93xx User’s Guide

3

3

3

loop

cfmul32 c0, c0, c3 ; c0 <= c0 * 5

cfsub32 c0, c0, c2 ; c0 <= c0 - 1

cfcmp32 r15, c0, c1 ; c0 < 10 ?

blt loop ; yes

cfstr32 c0, [r0, #0x0] ; no, store result

3.2.2 Example 2

The following function performs an FIR filter on the given input stream. The variable “data”
points to an array of floating point values to be filtered, “n” is the number of samples for which
the filter should be applied, “filter” is the FIR filter to be applied, and “m” is the number of taps
in the FIR filter. The “data” array must be “n + m - 1” samples in length, and “n” samples will
be produced.

3.2.2.1 C Code

void

ComputeFIR(float *data, int n, float *filter, int m)

{

int i, j;

float sum;

for(i = 0; i < n; i++)

{

sum = 0;

for(j = 0; j < m; j++)

{

sum += data[i + j] * filter[j];

}

data[i] = sum;

}

}

3.2.2.2 MaverickCrunch Assembly Language Instructions

ComputeFIR

mov r1, r1, lsl #2 ; n *= 4

mov r3, r3, lsl #2 ; m *= 4

outer_loop

mov r12, r3 ; j = m * 4

cfsub64 c0, c0, c0 ; int_sum = 0;

cfcvt32s c0, c0 ; sum = float(int_sum);

inner_loop

cfldrs c2, [r0], #4 ; c2 = *data++;

Advertising