Handbook for Sound Engineers

(Wang) #1

1174 Chapter 31


register overflows at potentially many different places
in the code. Overflow occurs in two ways in a
fixed-point DSP.^3 Either a register overflows when too
many numbers are added to it or the program attempts
to store N bits from the accumulator and the discarded
bits are important. A complete solution to the overflow
problem requires the system designer to be aware of the
scaling of all the variables so that overflow is suffi-
ciently unlikely. An underflow occurs if a number is
smaller than the smallest number that can be repre-
sented. Floating-point arithmetic keeps track of the
scaling automatically in order to simplify the
programmer’s job. The exponent keeps track of where
the decimal point should be. Checking for over-
flow/underflow and preventing these conditions makes
changing a DSP algorithm more difficult because, not
only are algorithmic changes required, there are also
numeric issues to contend with. Usually, once an imple-
mentation for a particular application has matured past
the development stage, the code (which may have
begun as floating-point code) may be ported to a
fixed-point processor to allow the cost of the product to
be reduced.


The dynamic range supported in a fixed-point
processor is a function of the bit width of the
processor’s data registers. As with A/D conversion,
each bit adds 6 dB to the SNR. A 24-bit DSP has 48 dB
more dynamic range than a 16-bit DSP.


31.8.2 Implementation Issues


The implementation of an algorithm into a real system
is often much more complicated than using a compiler
to automatically optimize the code for maximum perfor-
mance. Real-time systems have constraints such as lim-
ited memory, limited computational performance, and
most importantly, need to handle the real-time data that
is continuously sent from the A/D converter to the DSP
and the real-time data that must be sent from the DSP
back to the D/A converter. Interruptions in this real-time
data are typically not acceptable because, for example,
in an audio application, these interruptions will cause
audible pops and clicks in the audio signal.


Real-time programming requires that all of the
computation required to produce the output signal must
happen within the amount of time it takes to acquire the
input signal from the A/D converter. In other words,
each time an input sample is acquired, an output sample
must be produced. If the processing takes too long to
produce the output, then, at some point, incoming data
from the A/D will not be able to be processed, and input


samples will be lost. As an example, assume a system
samples at 48 kHz and performs parametric equalization
on a signal. Assuming that each band of parametric
equalization requires 5 multiplies and 4 adds, which can
be implemented in 9 clock cycles, then a 100 MHz DSP
has 2083 instructions that can be executed in the time
between samples. These instructions would allow a
maximum of 231 bands of parametric equalization
(2083/9 = 231). Now, realistically, the system is
performing other tasks such as collecting data from the
A/D converter, sending data to the D/A converter,
handling overhead from calling subroutines and
returning from subroutines, and is possibly responding
to interrupts from other subsystems. So the actual
number of bands of equalization could be significantly
less than the theoretical maximum of 231 bands.
DSPs will have a fixed amount of internal memory
and a fixed amount of external memory that can
addressed. Depending on the system to be designed, it
can be advantageous to minimize the amount of external
memory that is required in a system because that can
lead to reduced parts costs, reduced manufacturing
expense, and higher reliability. However, there is
usually a trade-off between computational requirements
and memory usage. Often, it is possible to trade
memory space for increased computational power and
vice versa. A simple example of this would be the
creation of a sine wave. The DSP can either compute
the samples of a sine wave, or look-up the values in a
table. Either method will produce the appropriate sine
wave, but the former will require less memory and more
CPU while the latter will require more memory and less
CPU. The system designer usually makes a conscious
decision regarding which trade-off is more important.

31.8.3 System Delay

Depending on the application, one of the most impor-
tant issues in an implementation is the amount of delay
or latency that is introduced into the system by the sam-
pling and processing. Fig. 31-17 shows the typical digi-
tal system. The analog signal comes into the A/D
converter that digitizes and quantizes the signal. Once
digitized, the signal is typically stored in some data buf-
fers or arrays of data. The data buffers could be one
sample long or could be longer depending on whether
the algorithm operates on a sample-by-sample basis or
requires a buffer of data to perform its processing. The
system buffers are usually configured in a ping-pong
fashion so that while one buffer is filling up with new
data from the A/D, the other is being emptied by the
DSP as it pulls data from the buffer to process the data.
Free download pdf