10.07.2015 Views

Instruction Sets

Instruction Sets

Instruction Sets

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

72 CHAPTER 2 <strong>Instruction</strong> <strong>Sets</strong>often operate on values stored in arrays,loops are also a good illustration of anotheruse of the base-plus-offset addressing mode. A simple but common use of a loopis in the FIR filter, which is explained in Application Example 2.1; the loop-basedimplementation of the FIR filter is described in Example 2.5.Application Example 2.1FIR filtersA finite impulse response (FIR) filter is a commonly used method for processing signals; wemake use of it in Section 5.11. The FIR filter is a simple sum of products:∑c r x i (2.1)1≤i≤nIn use as a filter, the x i s are assumed to be samples of data taken periodically, while the c i sare coefficients. This computation is usually drawn like this:fc c 14c 2 c3x 1 x 2x 3 x 4. . .This representation assumes that the samples are coming in periodically and that the FIRfilter output is computed once every time a new sample comes in. The boxes represent delayelements that store the recent samples to provide the x i s. The delayed samples are individuallymultiplied by the c i s and then summed to provide the filter output.Example 2.5An FIR filter for the ARMThe C code for the FIR filter of Application Example 2.1 follows:for (i = 0, f = 0; i < N; i++)f = f + c[i] * x[i];We can address the arrays c and x using base-plus-offset addressing: We will load one registerwith the address of the zeroth element of each array and use the register holding i as the offset.The C language [Ker88] defines a for loop as equivalent to a while loop with properinitialization and termination. Using that rule, the for loop can be rewritten asi = 0;f = 0;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!