22.09.2015 Views

of Microprocessors

Musical-Applications-of-Microprocessors-2ed-Chamberlin-H-1987

Musical-Applications-of-Microprocessors-2ed-Chamberlin-H-1987

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

668 MUSICAL ApPLICATIONS OF MICROPROCESSORS<br />

insure that the initial input data values are small enough so that after<br />

transformation they will still fit into the chosen data wordlength. This is<br />

perfectly feasible for a dedicated function single block size FFT routine (or<br />

hardware implementation <strong>of</strong> such a routine) but could get out <strong>of</strong> hand in a<br />

routine designed for a wide range <strong>of</strong> possible block sizes. Another possibility<br />

is to scan the data array after each iteration and divide all values by two.<br />

Unfortunately, this sacrifices small signal accuracy, when freedom from<br />

processing noise is needed most, in exchange for large signal-handling<br />

capability. Yet a third is to scale the calculations so that overflow is a distinct<br />

possibility and test for it during each iteration. Ifoverflow does occur, divide<br />

the data array by two, recording the number <strong>of</strong> times this is done, and<br />

continue. This technique is called conditional array scaling and has the best<br />

trade<strong>of</strong>f between accuracy and word size but suffers from additional<br />

complexity and an indefinite execution time as well as burdening successive<br />

processing steps with data having a variable scale factor.<br />

Since the 68000 readily handles 32-bit data values, the brute-force<br />

technique mentioned first above will be used. The intial input data,<br />

intermediate results stored in the data arrays, and the output data will be 32­<br />

bit signed integers. The SIN and COS multipliers will be obtained from a<br />

table as 16-bit unsigned binary fractions. When multiplied by the 32-bit data<br />

values, a 48-bit product is obtained. The intermediate calculations within a<br />

node are perfotmed using these 48-bit values, but the final node result that is<br />

stored back into the data array is just the most significant 32 bits. The sign <strong>of</strong><br />

the COS multiplier is handled by conditionally adding or subtracting the<br />

product according to the angle. The SIN multiplier is always positive, since<br />

the angle is always between 0 and 180°. For maximum accuracy, SIN or COS<br />

multipliers <strong>of</strong> unity (1. 0) are represented by a special value in the table, and<br />

multiplication is skipped when they are seen. Zero multipliers are also<br />

skipped, which gives a noticeable speed increase for the smaller record sizes,<br />

where zero and unity multipliers are proportionately abundant.<br />

Figure 18-8 shows the assembled 68000 FFT subroutine listing.<br />

Arguments and instructions for its use are given in the first few lines and<br />

should be self-explanatory. When filling the data arrays with 32-bit values, it<br />

is desirable to shift the data left as far as allowable to maximize accuracy. For<br />

example, if the original data are signed 16-bit integers and the transform size<br />

is 512 complex points, the 16-bit data can be sign extended to 32 bits and<br />

then shifted left seven positions before being stored into the data arrays. This<br />

leaves 9-bit positions available for the nine doublings incurred by the nine<br />

FFT iterations needed for 512 points. However, if real data is being<br />

transformed and this routine is followed by a real transformation routine,<br />

only six shifts should be done because the real transformation also tends to<br />

double the array values. The subroutine is completely self-contained except<br />

for an external cosine table (not shown but instructions for its generation are<br />

included), which can be shared with other synthesis routines. Since all

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

Saved successfully!

Ooh no, something went wrong!