Documente Academic
Documente Profesional
Documente Cultură
INTRODUCTIONTO DSP
OBJECTIVES
This introduction is designed to answer several basic questions for the beginning student and familiarizes the
student experienced in digital signal processing with the design and architecture of Texas Instrument's
TMS320C54x device. The topics presented in this section include:
The definition of digital signal processing (DSP)
The benefits of digital signal processors
Practical applications or uses of digital signal processing
General DSP design and architecture
Specific DSP architecture
INTRODUCTION TO DSP
What I s DSP?
Anal og Comput er
a bit loud
Digi tal Computer
DSP
ADC
1010 1001
DAC
OUTPUT
LECTURE 1 1- 1
Definition of a Digital Signal Processor
A digital signal processor (DSP) is an integrated circuit designed for high-speed data manipulations, and is
used in audio, communications, image manipulation, and other data-acquisition and data-control
applications.
How Digital Signal Processing Works
To explain how digital signal processing works, you must understand the difference between analog and
digital signals. Analog signals, which include sound intensity, pressure, light intensity, etc., are
continuously variable. Each of our senses is sensitive to different kinds of analog signals. Our ears are
sensitive to sound, our eyes are sensitive to light, and so on. Once we receive a signal, our sensory organs
convert it to an electrical signal and send it to our analog computer (the brain). Our brains are very powerful
parallel computers whose performance currently is unmatched by any digital computer. Our brains not only
analyze the information received, but also make decisions using this data.
Digital signals are those that are transmitted within or between computers, in which information is
represented by discrete states for example, high voltages and low voltages rather than by continuously
variable levels in a continuous stream, as in an analog signal.
How Analog and Digital Signals Work Together
Digital technology such as personal computers (PCs), assist us in many ways: writing documents, spell
checking, and drawing. Unfortunately, the world is analog, and electronic analog computers are not as
INTRODUCTION TO DSP
versatile as digital computers. Therefore, in order to make use of the tremendous processing power that
digital technology offers us, we must do the following:
Convert the analog signals into electrical signals, using a transducer (such as a microphone, as
shown in the diagram).
Digitize these signals (i.e., convert them from analog to digital using an analog-to-digital converter
(ADC)), as shown in the diagram.
Once the signal is in digital form, our computer can easily process it through a digital signal processor. The
DSP specializes in processing these signals, which makes it slightly different from microcomputers,
microcontrollers, or general-purpose microprocessors.
After the DSP has processed the signal, the output signal must be converted back to analog form so that we
can sense it. This is the digital-to-analog (DAC) conversion stage in the diagram. A loudspeaker, for
example, would reproduce analog signals coming from the DAC into sound.
So, we can see that to process the signal digitally, we need to convert it at least twice. Is it worth it? As you
will see, it really is, at least until someone designs an analog computer as versatile as a digital one.
INTRODUCTION TO DSP
0001
0 x 8 x 0011 0000
1 x 4 x 0011 0011
+
0010 0 x 2 x 0011 0000
1 x 1 x 0011 0011
0011
Shi f t ed and
5
added
3
Multiply and Add
Add
1+2 = 3
Multipl y 5*3 = 15
=
mul t i pl e t i mes
Most Common Oper at i on i n DSP
A = B* C + D
E = F* G + A
.
.
Mul t ipl y, Add, and Ac cumul at e
MAC I nst r uct i on
MAC Oper at i on
Typi cal l y 70 Cl ock Cycl es Wi t h
Or di nar y Pr ocessor s
Typi cal l y 1 Cl ock Cycl e Wi t h
Di gi t al Si gnal Pr ocessor s
LECTURE 1 1- 3
Why Do We Need Digital Signal Processors?
Why do we need a digital signal processor? Can we not use a general-purpose microprocessor to process
signals as well? Let us try to answer this question by giving an example of some arithmetic operations
performed by DSPs.
Add and Subtract
Add and subtract operations are performed quite simply by general-purpose microprocessors in a single or
very few clock cycles. Digital addition is similar to decimal add. Our example shows adding 1 plus 2. The
result is the decimal 3.
Multiply and Divide
The multiply and divide operations are more complex. A digital multiply operation consists of a series of
shift and add operations. Our example shows a multiplication of 3 by 5. Division, which is more complex,
will not be discussed here. It is discussed in TMS320C54x DSP Reference Set, Vol. 2 Mnemonic Instruction
Set, Chapter 2, reference number SPRU172B. The subtract conditionally (SUBC) instruction set describes
this process.
General-purpose microprocessors are quite slow in performing multiply and divide operations. They will
typically sequentially execute a series of shift, add, and subtract operations from their microcode to perform
a single multiply operation, and may consume many cycles to complete.
INTRODUCTION TO DSP
The DSP performs multiplication in a single cycle by implementing all shift and add operations in parallel.
The circuitry is relatively complex and consumes a considerable number of transistors. The benefit is very
fast multiplication, which is required for processing most digital signals.
When general-purpose DSPs are not fast enough, the signal is either processed using analog circuits (which
may have some drawbacks), or in specialized DSP hardware designed only for that task. This eliminates
many of the benefits of a programmable DSP.
Digital signal processing, by its nature, requires many calculations of the form:
A = B*C + D
This may appear to be a simple task, but when speed is also required, we find that specialized, dedicated
hardware to perform this task is very useful.
Multiply, Accumulate (MAC)
Most DSPs have a specialized instruction that allows them to multiply, add, and save the result in a single
cycle. This instruction is usually called MAC (short for Multiply, Accumulate).
INTRODUCTION TO DSP
Drop in Multiplication Times
TI ME ( ns)
600
500
400
300
200
100
0
5 ns
1971 1976 1998
YEARS
LECTURE 1 1- 4
We have established that for DSPs, we need specialized hardware that is capable of performing multiply and
accumulate functions in the shortest possible time (preferably in a single cycle). However, the central
problem remains. How can we achieve a fast multiply operation? Without a fast multiplier, a worthwhile
DSP design would only be a dream.
Designing fast multipliers was one of the greatest challenges in digital design up until the 1980s. In the
1970s, several of the worlds leading research laboratories sought to make fast digital multipliers a reality.
Multiply Times
In 1971, Lincoln Laboratories designed a multiplier using 10,000 integrated circuits, performing the
operation in just 600 ns. By the mid-1970s, multiply times of 200 ns were becoming commonplace. This
made it possible to design acceptable digital signal processors. These early designs were expensive and
bulky, but fast multiplication was determined to be possible.
In the early 1980s, single-chip DSPs with good performance started to appear, and ever since, multiply times
have continued to drop. Todays 16-bit fixed-point devices can achieve multiply times of 5 ns. Given the
origins of this technology, this is a remarkable achievement.
INTRODUCTION TO DSP
Digital Computers
von Neuman Machi ne
A
STORED
PROGRAM
AND
D
DATA
INPUT/
OUTPUT
ARI THMETI C
LOGI CUNI T
A = ADDRESS
D = DATA
Harvard Architecture
STORED
PROGRAM
A
ARI THMETI C
LOGI CUNI T
D
A
INPUT/
OUTPUT
D
STORED
DATA
1-
Now let us have a closer look at the internal architecture of computers so we can see how this has affected
the design of DSP chips.
Stored Program Machines
Computers need instructions to operate. At every clock cycle, they must be told what to do. If the
instructions are stored, the computer just has to fetch and execute them. Such computers are called stored
program machines. Our computer typically fetches an instruction and then data, operates on the data, and
returns the resulting data to the store.
Stored program machines use two well-known and widely used computer architectures: von Neuman and
Harvard.. The following diagram shows the structure of the two architectures.
von Neuman Architecture
The von Neuman machines store programming and data in the same memory area. In this type of machine,
an instruction contains the operation command and the address of the data on which the operation is
performed. There are two basic operation units within these machines: the arithmetic logic unit (ALU) and
the input/output unit. The ALU performs the core operations: multiply, add, subtract, and many more. It is
on these very simple core operations that complex software, such as word processing software, can be built.
The input/output unit manages the flow of external data for the machine.
INTRODUCTION TO DSP
Harvard Architecture
The primary difference between Harvard architecture and von Neuman architecture is that with Harvard,
program and data memories are physically separated transmission paths. This enables the machine to
transfer instructions and data simultaneously. Such a structure can greatly enhance performance, because
instructions and data can be fetched simultaneously. Harvard machines also have ALUs and input/output
units.
Von Neuman and Harvard Architecture History
The history of these two architectures is very interesting. The Harvard architecture was developed by
Howard Aiken in the late 1930s at Harvard University, with the Harvard Mark 1 becoming operational in
1944. The University of Pennsylvania followed in 1946 with the development of the Electronic Numerical
Integrator and Calculator (ENIAC ).
John von Neuman, a Hungarian-born mathematician, suggested a simpler and lower cost architecture,
namely a single memory for programming and data. This simple solution has set the standard ever since. In
1951, the Institute of Advanced Studies in Princeton built the first von Neuman machine.
Which Architecture is Best Suited for DSP?
Common general-purpose personal computers use processors designed with the von Neuman architecture
while the Harvard architecture is more commonly used in specialized microprocessors for real-time and
embedded applications.
DSPs typically use Harvard architecture, although von Neuman DSPs also exist. Many signal and image
processing applications require fast, real-time machines. The drawback to using a true Harvard architecture
is that since it uses separate program and data memories, it needs twice as many address and data pins on
the chip and twice as much external memory. Unfortunately, as the number of pins or chips increases, so
does the price.
Electronic designers, who have had to tackle problems like these before, have come up with an elegant
solution: a single data and address bus is used externally, while two (or more) separate buses for program
and data are used internally. Timing (multiplexing) handles the separation of program and data
information. In one clock cycle, the program information flows on the pins, and in the second cycle, data
follows on the same pins. Program and data information is then routed onto separate internal program and
data buses. Such machines are called modified Harvard architecture processors because the internal
architecture is Harvard while the external architecture is von Neuman. The performance of modified
Harvard architecture processors typically compares well with the performance of true Harvard architecture
processors because most DSP chips also incorporate multiple internal RAM/ROM cells for high-use
instructions and data. This significantly reduces the time used for external sequential program and data
access associated with classic von Neuman processors.
INTRODUCTION TO DSP
A Typical DSP Syst em
DSP
MEMORY
ADC
DAC
DSP Chi p
Memory
Converters (Opt ional )
Anal og t o Di git al
Di gi t al t o Anal og
Communi cat i on Port s
Serial
Parall el
PORTS
LECTURE 1 1- 2
Components of a Typical DSP System
Typical DSP systems consist of a DSP chip, memory, possibly an analog-to-digital converter (ADC), a
digital-to-analog converter (DAC), and communication channels. Not all DSP systems have the same
architecture with the same components. The selection of components in a DSP system depends on the
application. For example, a sound system would probably require A/D and D/A converters, whereas an
image processing system may not.
DSP Chip
A DSP chip can contain many hardware elements; some of the more common ones are listed below.
Central Arithmetic Unit
This part of the DSP performs major arithmetic functions such as multiplication and addition. It is
the part that makes the DSP so fast in comparison with traditional processors.
Auxiliary Arithmetic Unit
DSPs frequently have an auxiliary arithmetic unit that performs pointer arithmetic, mathematical
calculations, or logical operations in parallel with the main arithmetic unit.
Serial Ports
DSPs normally have internal serial ports for high-speed communication with other DSPs and data
converters. These serial ports are directly connected to the internal buses to improve performance,
to reduce external address decoding problems, and to reduce cost.
INTRODUCTION TO DSP
Memory
Memory holds information, data, and instructions for DSPs and is an essential part of any DSP system.
Although DSPs are intelligent machines, they still need to be told what to do. Memory devices hold a series
of instructions that tell the DSP which operations to perform on the data (i.e., information). In many cases,
the DSP reads some data, operates on it, and writes it back. Almost all DSP systems have some type of
memory device, whether it is on-chip memory or off-chip memory; however, on-chip memory operates
faster.
A/D and D/A Converters
Converters provide the translator function for the DSP. Since the DSP can only operate on digital data,
analog signals from the outside world must be converted to digital signals. When the DSP provides an
output, it may need to be converted back to an analog signal to be perceived by the outside world.
Analog-to-digital converters (ADCs) accept analog input and turn it into digital data that consist of only 0s
and 1s. Digital-to-analog converters (DACs) perform the reverse process; they accept digital data and
convert it to a continuous analog signal.
Ports
Communication ports are necessary for a DSP system. Raw information is received and processed; then that
information is transmitted to the outside world through these ports. For example, a DSP system could output
information to a printer through a port. The most common ports are serial and parallel ports. A serial port
accepts a serial (single) stream of data and converts it to the processor format. When the processor wishes to
output serial data, the port accepts processor data and converts it to a serial stream (e.g., modem connections
on PCs). A parallel port does the same job, except the output and input are in parallel (simultaneous)
format. The most common example of a parallel port is a printer port on a PC.
INTRODUCTION TO DSP
1-
Practical DSP Systems
Hi -Fi Equi pment
Toys
Vi deophones
Modems
Phone Syst ems
3D Graphi cs
Image Processi ng
And More ...
LECTURE 1 1-13
Practical Applications for DSP Systems
Since their introduction to the market, DSPs have found a wide variety of applications. They are used in
everyday hi-fi systems as well as high-end virtual-reality applications. Generally, DSP is not an expensive
technology. Some practical DSP systems are:
Hi-Fi Equipment
Toys
Videophones
Modems
Phone Systems
3D Graphics Systems
Image Processing Systems
Hi-Fi Equipment (Music Systems)
DSPs are now being used in sound processors that can create the illusion of three-dimensional sound or
modify the acoustics of a room to give the illusion of very large rooms and auditoriums. The result is movie
theater quality sound in a home music system.
Toys
Today, DSP technology is integrated in children's toys. Talking toys are commonplace; by pressing the
picture of a dog, children can hear it bark. They can also learn their alphabet by singing along with a
teaching toy. This clearly demonstrates that DSP technology is not expensive.
INTRODUCTION TO DSP
1-
Videophones
Videophones will affect the lives of people from all walks of life. They are quickly improving in quality. It
is only a matter of time before prices drop and videophones become widely used. DSPs are used for
compression and decompression of images in videophones. There are several international standards for
compressing moving images. Programmable DSPs are the perfect answer to evolving standards since this
may only require a software update.
Modems
As the Internet continues to grow, so has the use of modems. To be able to handle the ever-increasing
communications load, modems have become faster and more efficient. DSPs perform vital functions in
modems such as modulating the digital bit stream into a signal compatible with a phone line, canceling line
echoes, and compressing and decompressing data
Phone Systems
These days, it is quite common to call a company and be answered by a machine that provides alternatives
such as: Say 1 for sales, Say 2 for technical support, and so on. These phone systems use DSPs to
perform the function of voice recognition. DSPs are also commonly used in the communications industry for
the add-on features you can get from your telephone company like caller ID, voice messaging, and call back.
3D Graphics Systems
Most flight simulators use 3D real-time graphics to enhance realism. To calculate the necessary details in
three dimensions (and to be able to do this 30 times every second) requires very efficient and powerful
processors. DSPs are now widely used in virtual-reality applications.
Image Processing Systems
Personal handheld digital cameras are also now becoming widespread. DSPs are used to perform the
conversion of charge-coupled device (CCD) chip analog voltages (video) to compressed data, which is then
stored digitally in constant storage EEPROM (electrically erasable ROM). The DSP also senses the buttons,
controls exposure times, provides the CCD gate timing, and downloads images to the PC.
DSPs are also used extensively in image processing, such as robot vision, machine vision, image
compression, and fingerprint recognition. A simple example of an image-processing application is the
inspection of printed circuit boards. The system works by recording the image of a working board and
comparing (subtracting) it to newly manufactured ones as they pass beneath a CCD camera. These systems
also use the efficient multiply and add cycles in DSPs to perform two-dimensional filtering.
INTRODUCTION TO DSP
Analog Advantages
Low cost and simplicity in some applications
Attenuators/amplifiers
Simple filters
Wide bandwidth (GHz)
Low signal levels
Infinite effective sampling rate
Infinite resolution in frequency
No aliasing/reconstruction issues
Infinite resolution in amplitude
No quantitation noise
LECTURE 1 1-14
Digital Signal Processing (DSP)
Advantages
Repeatability
Low sensitivity to component tolerances
Low sensitivity to temperature changes
Low sensitivity to aging effects
Nearly identical performance fromunit to unit
Matchedcircuits cost less
High noise immunity
In many applications DSP offers higher
performance and lower cost
CD players versus phonographic turntable
LECTURE 1 1-15
INTRODUCTION TO DSP
Why Digital Processing?
ADC PROCES S DAC
Advantages t o Digi t al Processing
Programmabi l i t y
Stabilit y
Repeat abi li t y
Speci al Appl i cat i ons
LECTURE 1 1- 8
So, Why Convert From Analog to Digital?
Some applications require analog designs, and some require digital designs. To process signals digitally,
they must be converted from analog to digital numbers. After a signal is processed, it is then often converted
back to analog form. Considering the overhead, digital processing must offer some clear advantages that
include:
Programmability
Stability
Repeatability
Special Applications
INTRODUCTION TO DSP
Programmabilit y
One Hardware = Many Tasks
SOFTWARE 1
SOFTWARE 2
.
SOFTWARE N
S AME
HARDWARE
LOW- P ASS FI LTER
MUSI C SYNT HESI ZER
.
MOT OR CONT ROL
Upgradabilit y and Flexibility
Devel op New Code Upgrade
Anal og Sol der New Component
1-
Programmability
A single piece of digital DSP hardware can perform many functions. For example, a multimedia PC can
play music and also function as a word processor if it is loaded with suitable programs. This ability to use
the same hardware for many functions provides important flexibility. You can implement any new function
you think of, as long as you can program it.
Upgradability
Once you have designed and implemented your system, you may want to upgrade or add new functions.
Perhaps you would like to adapt your system to a new environment. With a digital system, this means
modifying your code. With an analog system, this could involve obtaining and soldering in new
components, or even a complete redesign.
Flexibility
A single DSP board can be made to perform many functions by simply loading new programs into it. In our
demonstrations, we are using the same DSK board as a music tune generator and as a low-pass filter by
simply loading it with different software. This flexibility reduces design time and complexity. With analog
circuits, a new circuit has to be designed for each new function.
INTRODUCTION TO DSP
Stability
The stability of analog circuits depends upon several factors. Analog circuits are affected by temperature
and aging, among other things. Also, two analog systems using the same design and components may differ
Analog Variabilit y
Analog Ci rcui t s are af fected by
Temperat ure
Agi ng
Tol erance of Component s
Two Anal og Syst ems usi ng t he same desi gn and
component s may di f f er i n perf ormance
1k + 10 years = 1.1k
LECTURE 1 1-10
in performance.
Temperature
1k + 10 years = 1.1k
Analog components such as resistors, capacitors, diodes, and operational amplifiers are affected by
temperature, humidity, and aging. A temperature-sensitive analog circuit may perform quite differently in
the UK than in Egypt, where the temperatures are different. This could prove disastrous for a company that
sells its products worldwide.
Digital circuits do not gradually change their characteristics over time, temperature, or humidity. They
either work or they dont work. In other words, digital circuits are repeatable as long as they are designed
with enough tolerance to operate properly over the range of expected conditions.
Aging
The effects of component aging can be detrimental to analog circuits as characteristics and performance
change. These effects can sometimes be anticipated, or their effect may not be critical. Analog designers
must be aware of these effects.
Tolerances
Components such as resistors and capacitors have tolerances. If a component tolerance is only accurate to
within 10%, two apparently identical analog circuits could perform differently enough to cause operational
problems. This can make design, manufacturing, and support expensive.
INTRODUCTION TO DSP
Digital Repeatabilit y
Perfect Reproducibilit y
Nearl y i dent i cal perf ormance f rom uni t t o uni t
Perf ormance not aff ect ed by t ol erance
No dri f t i n perf ormance due t o t emperat ure or agi ng
Guarant eed accuracy
A CD pl ayer al ways pl ays t he same musi c
quality
LECTURE 1 1-11
Digital Repeatability
A properly designed digital circuit will produce the same result every time, in addition to being identical
from unit to unit. If the same multiplication is performed on 500 computers, all 500 computers should
produce the same result. Component tolerances, aging, and temperature drifts also do not affect digital
circuits nearly as much.
A properly designed digital circuit will produce the same results in the UK as in Egypt, even when the
temperatures are different. On the other hand, 500 analog circuits could produce a range of results.
In digital circuitry, logical 1s and 0s are defined when an analog voltage is above or below an analog voltage
threshold. For a digital circuit to be repeatable, the analog voltage which represents the logical 1s and 0s
needs to be sufficiently greater or less than the threshold so as not to be affected by circuit variations or
noise. The only concern is that timing restrictions and maximum device ratings should not be exceeded. If
proper digital inputs are not maintained, the 1s and 0s can be corrupted, making a normally repeatable
digital circuit suddenly fail. On the other hand, analog circuit characteristics will tend to gradually drift.
Digital accuracy is determined by the number of bits used and is guaranteed to remain the same. With
analog circuits, the number of bits is effectively infinite, but the effects of noise, tolerances, and linearity can
rapidly diminish performance.
A digital CD player consistently produces the same high-quality digital music and is primarily only limited
by the analog components that are still required. Analog components in a CD player include the DAC,
laser, laser pickup, read head actuator, spindle motor and headphones.
INTRODUCTION TO DSP
Performance
Some speci al f unct i ons are best i mpl emented
digitally
Lossl ess Compressi on
Adapti ve Fi lt ers Li near Phase Fi lt ers
gain
f phase
frequency frequency
f
1
f
2
LECTURE 1 1-12
Compression
Storage media such as hard disk drives and satellite communications links for telephone and video are
examples where resources are limited in terms of the available size and bandwidths. More would be better,
but installing additional hardware tends to be very expensive. In these cases, costs are passed on to the
consumer in one way or another. An example would be the substantial cost difference between a 20-minute
and a 2-minute phone call, especially if the call is long distance.
Although the prices for installing more advanced hardware tend to be on a downward curve, our need for
more information is on an even more aggressive upward curve. Data compression can be a valuable tool for
providing adequate performance from available resources, and at a reasonable cost.
Let us consider the example of a satellite link or transmission channel. If one megabyte of data is
compressed down to half a megabyte and then transmitted, a decompressor can then recover the original data
at the other end. Considering that the transmission line is only aware that half a megabyte of data has been
passed, the data channel bandwidth is effectively doubled.
A DSP can compress raw binary data and signals through the use of appropriate software programs.
Lossless compression programs are suitable for exact binary data transfers. On the other hand, programs
designed for compressing speech and video offer much higher compression ratios but with some loss in
signal quality. Analog circuits can also be used for some very simple forms of lossless compression but offer
very little flexibility.
INTRODUCTION TO DSP
Adaptive Filters
DSP systems have been developed that cancel some of the noise within cabins of cars, helicopters, and
airplanes. The noises cancelled were those caused by engine vibrations. The noise cancellation systems
used the engine speed as a reference and produced an anti-noise signal from speakers to cancel the cabin
noise. Feedback from microphones in each headrest (or headphone) was used to adapt the characteristics of
the anti-noise until the best possible noise reduction was achieved. The system then continued to adapt
periodically to track changes in the cabin noise.
A DSP system can easily adapt to some changes in environmental variables. An adaptive algorithm simply
calculates the new parameters required and stores them back in main memory, overwriting the previous
values. A very basic level of adaptation is possible in analog systems, but the complete change of a complex
set of filter characteristics (used in noise cancellation) is beyond the practical scope of analog signal
processing.
A notch filter with a steep cut-off frequency would be one example of a filter that might be needed to
implement noise cancellation. In this case, the DSP has the ability to recalculate suitable notches to remove
the vibration noise as the engine RPM changes. It is virtually impossible to produce the many required
tunable filters using analog techniques alone.
Linear Phase Filters
There are some valuable signal processing techniques that are difficult or impossible to produce by analog
procedures. The classic example is that of a linear phase filter that is difficult to design in analog and even
then, over a limited bandwidth. With a digitally implemented filter, it is possible to keep the phase shift of
each component frequency consistent with all other frequencies. This is possible by using a finite impulse
response (FIR) filter. This term will be explained later.
INTRODUCTION TO DSP
DSP Development
ADD A, B
11100010010100001001
ASSEMBLER
HIGH-LEVEL LANGUAGE
CODE TEST
EMULATOR
S/W DESIGN
DSP
N
OK?
Y
Tools of the Trade
PRODUCT
LECTURE 1 1- 7
The Program
The DSP chip is a piece of hardware that cannot function without the intelligence of a program. A program
is a series of instructions that perform certain functions. In our demonstrations, we will see some examples
of programming to compose simple musical tunes. To write these programs, we must use the tools of the
trade.
Assemblers
Assemblers generate machine-level code from text instructions. Let us assume we were given the following
two lines to remember:
ADD A, B
111000100101010001001
Since we understand written words better than a series of 1s and 0s, which line is easier to understand and
remember? Assemblers take our text instructions and convert them into machine language. This relieves us
of the burden of having to remember binary instructions for DSP. We will talk more about assembly
language in the next chapter.
High-Level Language
High-level languages are like assembly languages, but much friendlier. Assembly languages have very basic
instructions, such as multiply, add, and compare. High-level languages have higher-level instructions, such
as print, and repeat until equal to zero. Therefore, it is easier to write programs in high-level languages.
INTRODUCTION TO DSP
While it is easier to write in high-level languages, assembly language can produce programs that are able to
execute faster. For this reason, both have their uses in DSPs. Sometimes it is necessary to write time-critical
sections of a program in assembly. A complete program may have sections of code in assembly and sections
in a high-level language. It is easy to combine both types of code into a single executable program.
Assembly and high-level programming languages make it possible to program DSPs to perform a variety of
functions.
Simulators
Flight simulators make you feel as if you are in the cockpit of a plane without the cost of an actual airplane,
fuel, or risk of crashing. Likewise, a DSP simulator is a software implementation of a DSP chip. A
simulator typically runs on a computer (PC or workstation), simulating almost all of the functionality of the
DSP. They are used to analyze the feasibility of designs before the designs are committed to hardware.
They are also very useful in determining whether or not a particular design will work.
Emulators
An emulator allows us to directly control and debug the results of instructions executing on the DSP.
Modern emulators do not replace the DSP chip on the board but exert their control through a serial
emulation scan path. Using these devices, it is possible to see all of the internal changes in the device at
each step. Developers can execute the instructions one step at a time, check voltage levels for correct
operation, and check each result in their own time. Emulators are invaluable tools in development
environments.
Debugger
A debugger interface is used to display program execution information in a useable format for the
programmer. The data displayed in the debugger windows is essentially a formatted data print of the
contents of the DSP memory. This memory is simply loaded into the PC using either an emulator or a
communications link with the PC using appropriate software.
For example, the memory window can display (and edit) data in hexadecimal, float or integer formats, but
the data is nonetheless binary 1s and 0s to the DSP. Likewise, the disassembly window is simply a
reformatting of the binary value into a recognizable alphanumeric mnemonic.
The CPU register window is a little different in that the C54x register values are not directly accessible as
memory data because they are not memory mapped registers. For the scan emulator, this job is quite easy
since the scan path simply routes through the internal registers of the DSP. For the DSK, this task is
accomplished using a special program that saves and restores the CPU registers from the DSP main memory.
Other than this, the data displayed in the CPU register window is simply another data form.
Debuggers consist of a user interface on the host PC computer, which can control and modify the contents
and execution of the chip. The user interface displays the contents of RAM, registers, and the disassembly of
the currently loaded program. The major advantage of debuggers over simulators is that they operate in real
time, allowing the designer to assess the performance of the system in a real-time environment.
INTRODUCTION TO DSP
Development Cycle
After the feasibility of the design is established through simulation, program design can begin. First, the
software is designed. This stage determines the complexity and the modules of the code. The modules of
software are written and tested, and then the full system is put together and tested. If everything works as
required, the result is version 1.0 of the product on the market. If it does not work as required, the process is
repeated until it does. When new requirements and improvements emerge as a result of user feedback, a new
version is produced via the same process.
INTRODUCTION TO DSP
Number Syst ems
Represent numbers di gi t al l y
Decimal 128 64 32 16 8 4 2 1
Di gi t Nu m be r
2
Di gi t Number
7
2
7
6
2
6
5
2
5
4
2
4
3
2
3
2
2
2
1
2
1
0
2
0
Any number can be represent ed as a seri es of 1s and 0s
Deci mal 3 i n bi nary
Decimal 0 0 0 0 0 0 2+ 1= 3
2
Digit Number
2
7
2
6
2
5
2
4
2
3
2
2
2
1
2
0
Digit Number 7 6 5 4 3 2 1 0
Binary 0 0 0 0 0 0 1 1 0000 0011
Deci mal 26 i n bi nar y
Deci mal 0 0 0 16+ 8+ 0 2= 0 26
Di gi t Nu m b e r
2
7
2
6
2
5
2
4
2
3
2
2
2
1
2
0
2
Digi t Number 7 6 5 4 3 2 1 0
Binary 0 0 0 1 1 0 1 0 0001 1 010
LECTURE 1 1-17
Number Systems
Let us now consider decimal, binary and hexadecimal (hex) number systems. The human-friendly decimal
system uses ten digits, 0 to 9, for number representation. Numbers larger than 9 are represented by carrying
a digit to the left. Number 10 represents one complete decimal count (digit 1x10) and a 0.
Binary
To represent numbers digitally, we are only allowed two binary digits, logic 1 and logic 0. Large numbers
can be represented in the binary system; however, more digits are needed to represent the same number in
the binary than are needed in the decimal system.
Consider the representation of decimal number 3 in binary, as shown in the preceding example. The value
of each binary digit is determined by its position. In the binary system, the maximum value the first digit
can have is 1. The second digit has a maximum value of 2. In an 8-bit system the decimal number 3 is
represented by setting the two least significant digits (LSB) to 1, or 0000 0011b.
To represent the decimal number 26, higher order binary digits are set to achieve the value 0001 1010b.
In an 8-bit binary system, the largest decimal number that can be represented is 2
8
-1 = 255 = 11111111b.
And the largest decimal number that can be represented in a 16-bit binary system is 2
16
-1 = 65,535.
INTRODUCTION TO DSP
Binary and Hex
Deci ma l 0, 1, 2, . , 9
Bi nar y 0, 1
Hex 0, 1, 2, . . , A, B, C, D, E, F
16 Deci ma l 0x10 Hex
20 Deci ma l 0x14 Hex
4 bi t s of bi nary syst em i s represent ed by a si ngl e hex di git
Deci mal 8+ 4+ 2+ 1= 15
D i g i t N u m b e r
2
3
2
2
2
1
2
0
2
Binary 1 1 1 1 1111
Hex F F
Deci mal 26 i n bi nar y and hex
Deci mal 0 0 0 16+ 8+ 0 2= 0 26
D i g i t N u m b e r
2
7
2
6
2
5
2
4
2
3
2
2
2
1
2
0
2
Di gi t Number 7 6 5 4 3 2 1 0
Bi nary 0 0 0 1 1 0 1 0 0001 1010
Hex 1 A 1A
LECTURE 1 1-18
Binary and Hexadecimal
Another useful number system is base 16 or hexadecimal (hex). After digit 9, the alphabet letters A to F are
used to represent the top base numbers 10 through 15. The largest decimal number that can be represented
with a single-digit hex number is 15, which is F in hex. To represent decimal number 16 in hex, the next
digit position is used: 0x10 hex. To distinguish hex numbers from decimal we will use a preceding 0x.
Another common convention is to follow the number with an 'h'. In this case, the first hexadecimal digit
must be decimal numeric digit (0-9) to avoid confusing the resulting string as a symbol in a program. For
example, 0F3h would be a valid hexadecimal representation while F3h could be confused with a symbol.
A similar convention to the trailing 'h' for hexadecimal is used for binary numbers by following the binary 1
and 0 digits with a 'b'. Again, by specifying that the first character in the digit stream as numeric 0 or 1,
with a trailing 'b' the character string can be identified as only being a binary value.
Hex notation is very useful because large numbers can be represented with fewer digits than with the binary
or decimal system. The hex format is also extremely convenient for digital or binary systems because each
hex digit replaces exactly four binary digits. This is because the biggest single hex number (0xF, or 0Fh) is
represented exactly in four binary digits: 0xF hex = 1111b.
The 8-bit binary representation of decimal 26 is 00011010b, or 0x1A (hex) which is much shorter. The hex
system may look confusing at first, but when you need to convert to binary numbers, or represent large
numbers, you will soon realize the benefits.
INTRODUCTION TO DSP
We will explain how to convert from hex to decimal and back in Chapter 6.
Signed I ntegers
Si gned magni t ude i nt eger s
Decimal
Signed
Hex
Binary
Sign Number
2 00 00 00 02 0 000 0000 0000 0000 0000 0000 0000 0010
3 00 00 00 03 0 000 0000 0000 0000 0000 0000 0000 0011
-2
-3
80 00 00 02
80 00 00 03
1
1
000 0000 0000 0000 0000 0000 0000 0010
000 0000 0000 0000 0000 0000 0000 0011
LECTURE 1 1-19
Signed Integers
To perform arithmetic, we need to be able to represent signed numbers. In the binary system, the most
significant bit (MSB) is used to indicate the sign of a number. When the MSB is set to 1, the number is
negative and when it is set to 0, the number is positive. Two conventions, signed magnitude and signed
twos complement (2s complement) exist for representing signed numbers.
The signed magnitude convention is familiar to us since this is how we represent negative decimal numbers.
For example, a +/- symbol is used for the sign bit to represent the negative of +10 as 10. However, this
leaves an interesting question about the value of 0. Is it +0 or 0, or are they the same? Another issue is
how to simplify the digital hardware in a DSP or microprocessor since smaller and faster circuits are an
advantage.
INTRODUCTION TO DSP
Twos Complement Notation
D i g i t n u m b e r
2
7
-2
6
2
5
2
4
2
3
2
2
2
1
2
0
2
Deci mal -128 64 32 16 8 4 2 1
Bi nary
t wo s compl ement
3 0 0 0 0 0 0 1 1
Deci mal
calculati on
0 0 0 0 0 0 +2 +1= 3
Bi nary
t wo s compl ement
-2 1 1 1 1 1 1 1 0
Deci mal
calculati on
-128 +64 +32 +16 +8 +4 +2 +0= -2
LECTURE 1 1-20
The table on the previous page shows binary notation for signed integers; 2, 3, -2 and -3 using a signed 32-
bit system. The first two positive integers are represented in the standard fashion. The last two negative
numbers have the top bit set to 1, but the rest of the representation remains the same.
This sign-representation system is not convenient for a binary or digital machine. The machine needs to
assess the sign bit and then carry out addition or subtraction, depending on the direction of the sign bit. A
more convenient system would use twos compliment notation to perform both addition and subtraction with
the same hardware.
Twos Complement Notation
To make it easier to understand twos complement notation, our example uses an 8-bit binary representation.
For positive numbers, such as the example +3, the MSB is set to 0, and the other bit values are exactly the
same as in standard binary notation.
The twos complement notation of a negative number is quite different. If the MSB is set to 1, the MSB
represents a negative value for that bit position. The top bit in an 8-bit system would therefore represent
negative 2
7
or -128 with the rest of the bits again representing positive values. The sum of the decimal
values of each bit that are set gives us the numbers decimal value. To represent 2 in twos complement, the
top bit is set to 1, representing 128, and the lower-order bits are set to make the result of the addition of all
bits equal to 2. In this case, 2 = 128 + 126.
The hardware method that is used to implement a twos complement converter and adder is even simpler.
This method negates a number by simply inverting all the bits and adding a 1 (as a carry bit) to the LSB. If
a 1 is added to the LSB, this causes a carry into the upper bits, which may ripple carry bits all the way to the
INTRODUCTION TO DSP
top bit. During addition, each binary bit cell receives two bits from the two operands, plus any carry that
may propagate from the next lower-bit cell. The 1 that is added into the LSB is simply implemented as a
carry bit as if it were coming from the next lower-bit cell.
The largest negative and positive values in twos complement form for an 8-bit system are as shown:
Most positive +1 * 2
7
- 1 = +127 >> 0111 1111b >> 0 +64+32+16+8+4+2+1
Most negative 1 * 2
7
= 128 >> 1000 0000b >> 128 +0
A 16-bit system would have a range of
Most positive +1 * 2
15
- 1 = +32767
Most negative 1 * 2
15
= 32768
For a 32-bit system such as a TMS320C31 32-bit processor
Most positive +1 * 2
31
1 = +2147483647
Most negative 1 * 2
31
= 2147483648
INTRODUCTION TO DSP
Fixed-Point Notation
Convent i ons
Number r ange i s bet ween 1 and - 1
Deci mal poi nt i s al ways i n a f ixed l ocat i on ( e. g. , 0. 74, 0. 34, et c. )
Mul t ipl yi ng a f ract ion by a f ract i on al ways resul t s in a f ract ion and wi l l
not pr oduce an over f l ow ( e. g. , 0. 99 x 0. 9999 = l ess t han 1)
Successi ve addi t i ons may cause over f l ow
Why?
Si gnal pr ocessi ng i s mul t i pl i cat i on- i nt ensi ve
Fixed- poi nt not at i on prevent s overf l ow ( usef ul wit h a smal l dynami c
r ange)
Fi xed- poi nt not at i on i s l ess expensi ve
How i s fi xed- poi nt not at i on reali zed i n a DSP?
Most f i xed- poi nt DSPs are 16 bi t s
The r ange of number s t hat can be r epr esent ed i s 3276 7 t o - 32768
The most common f i xed- poi nt f or mat i s Q15
Q15 Not at i on
Bit 15 Bits 14 to 0
si gn t wo s compl ement number
LECTURE 1 1-22
Fixed-Point Notation
Fixed-point notation, sometimes called fractional-point notation or Q format, uses an implied binary point
to represent binary fractions. This point always remains at a fixed location. The dynamic range of a
processor is the range between the smallest and the largest number it can represent. When the dynamic
range is limited,
In a 16-bit processor, the dynamic range is 32767 to 32768. Such a small dynamic range can easily create
overflows. For example, 200 350 = 70000, which is an overflow!
However, if the number range is limited, or more precisely scaled, to +1 to 1, a multiplication could never
produce an overflow. For example, the multiplication of two fractional numbers within the range of 1 to 1
must always produce a result that is also a fraction. The result is therefore confined to be within the range of
1 to 1. Unfortunately, successive additions can produce overflow values outside the range of 1 to 1. This
point should be remembered when performing fixed-point arithmetic.
Signal processing is both multiplication and addition intensive. An overflow can have serious consequences,
(e.g., unintentionally clipping a large signal). A fixed-point system can solve this problem by either
checking for overflows after each math operation, or by knowing that the inputs and outputs of the operation
are input bounded or well behaved.
INTRODUCTION TO DSP
Why Use a Fixed-Point System?
The cost of implementing many DSP systems is strongly dependent on the amount of chip silicon used to get
the job done, with most of the chip silicon being either in the processor or in the surrounding memory. If the
chip silicon is mostly used for data storage, such as long audio delay buffers, video or coefficient tables, the
difference between 16- and 32-bit data storage can be as much as 2:1.
Furthermore, routing twice as many signals around the chip and system board can consume extra space and
drive up the power consumption. Another advantage of short 16-bit fixed-point chips is that by making the
core processor small, not only are the chips smaller and less expensive, they are also usually a bit faster.
This may again lower the price of the DSP chip that, in price-sensitive volume applications, is an important
consideration. However, if a 16-bit system must also perform 32-bit operations, these advantages can be lost
and end up costing more. If a system can tolerate a smaller dynamic range and resolution, then the use of
16-bit data can be an economic advantage.
Fixed-Point Q Notation
As we have seen in multiplication and addition, overflows can be a problem for fixed-point DSPs. To
eliminate this problem, a programming convention called Q format is introduced where fixed-point DSPs
operate on fractional numbers which, by definition, cannot saturate. The principle of Q notation is the
application of a simple scaling coefficient to convert fractions to integers that a fixed-point DSP is designed
to handle. (Note that this is not an issue for floating-point DSP).
The letter Q represents the Quantity of fractional bits and the number following the Q indicates the number
of bits that are used for the fraction. This divides the number into an upper and lower region of bits where
the upper region contains the sign bit and any whole integer values, and the lower bits hold the fraction.
Any Q format is possible, but Q15 is the most widespread in 16-bit DSPs and Q31 is most often used for 32-
bit DSPs.
In Q15 format, an imaginary decimal point is placed between bits 15 and 16. The upper range in this case is
only one MSB (for a 16-bit DSP) which is essentially the sign bit, or bits 1631 in a 32-bit DSP. The
remaining 15 bits are used to represent the fractional part of the number. To convert a Q-format integer to a
floating-point value, a scaling coefficient is needed. If the Q number is 15, the coefficient or resolution of
the fraction will be 2^15 or 30.518e6.
INSTRUCTORS GUIDE INTRODUCTION TO DSP
Q15 Format
Dynamic range in Q15
Number Bi ggest Smal l est
Fr act i onal number 0. 999 - 1. 000
Scal ed i nt eger f or Q15 32767 - 32768
Number represent at i ons i n Q15
Decimal Q15 = Decimal x 2
15
Q15 I nteger
0.5 0. 5 x 32767 16384
0.05 0. 05 x 32767 1638
0.0012 0. 0012 x 32767 39
Rul es f or operati ons
Avoid operat i ons wit h number s lar ger t han 1
2. 0 x ( 0. 5 x 0. 45) = ( 0. 2 x 0. 5 x 0. 45) x 10 = ( 0. 5 x 0. 45) + ( 0. 5 x 0. 45)
Scal e number s bef or e t he oper at i on
0. 5 i n Q15 = 0. 5 x 3276 7 =16384
LECTURE 1 1-23
Dynamic Range in Q15
The dynamic range, or ratio of largest to smallest magnitude levels, is the same for Q15 and normal integers.
It is the scaling coefficient that sets the two apart, and other than this, you may have difficulty knowing
which format is in use. As mentioned previously, to prevent overflows the inputs and outputs can be
constrained to fractions in the range of 1 to 1 by simply applying a scaling coefficient.
Number Representation in Q15
Scaling a number is simple:
Integer = Q15_fractional_number 2
15
The second table on the slide shows several examples of scaling.
Rules for Operations
The most important rule in using the Q15 fixed-point format is to avoid using a number larger than 1 or
smaller than 1. There are some instances where this can be safely violated. For example, a property of a
2s complement adder is that if an addition overflow occurs, exceeding the available 16-bit range, a
subtraction can unwrap the result back down into a valid range. Generally, however, it is best to avoid the
problem in the first place. If a dynamic range greater than 32767 to 32768 (i.e., a 16-bit system) is
required, it is also possible to perform longhand arithmetic in pieces, but this consumes CPU cycles and
data.
The bottom portion of the slide shows an example where multiplying 0.5 and 0.45 (unscaled for clarity)
results in another fraction, which is not a problem. Multiplying the product by 2 can be done using two
methods. One method is to multiply one of the inputs by 2 first. If the result of this intermediate operation
exceeds +/1.0, we will have a problem. The inputs could be scaled down first and then scaled up
INSTRUCTORS GUIDE INTRODUCTION TO DSP
afterwards, but this is also far from efficient. An alternative method is to add the product to itself,
effectively multiplying by 2. This is one of the difficulties of using the fixed-point operation. The
programmer needs to think about these issues and plan ahead.
Another important rule is that all numbers must be scaled to the same Q format (Q15 in our examples),
placing the decimal points of both operands in the same place, before an addition or subtraction is
performed. Generally, this is also practiced in multiplication. However since the scaling coefficients are
multiplied, the correct fraction can be retrieved using yet another scaling constant. Nevertheless, mixing Q
formats is not desired.
INTRODUCTION TO DSP
Q15 Operations
Addi t i on
Decimal Q15 Scal e back
Q15 / 32767
0. 5 + 0.05 = 0. 55 16384 + 1638 =
18022
0.55
0. 5 0.05 = 0.45 16384 1638 =
Multi plicati on
2 x 0. 5 x 0.45 =
Decimal Q15 Back to Q15
Product / 32767
Scal e back
Q15 / 32767
0. 5 x 0. 45 = 0. 225 16384 x 14745 =
241584537
7373
0. 225 + 0. 225 = 0. 45 7373 + 7373 =
14746
0. 45
LECTURE 1 1-24
Q15 Addition
Q15-format addition is shown in the first example above. The numbers 0.5 and 0.55 are each scaled by
32767 (Q15 coefficient) and then added. Since both numbers are scaled to the same Q format, the decimal
point in both will be in the same place (bit 15). The sum is then scaled back to verify the result.
In the second example, the correct subtraction (sum of two's complement) is 14746, and the expected scaled
result is 14746 / 32767 = 0.45.
Q15 Multiplication
When scaled numbers are multiplied, the scaling coefficients are multiplied. To compensate, a second
scaling factor that will put the data in the correct bit position is used. The Q15 multiplication shown gives
an idea of how large the numbers can get. But as we can also see, the division by the Q-15 coefficient scales
the number back down and we get the correct result.
Anticipating this, the multiplier on a 16-bit DSP produces a 32-bit result. In actuality, the result is packed
into the upper bits and comes with two sign bits. The programmer can either downshift to the lower 16 bits,
or can left-shift up by one bit before storing the upper bits. Both methods will produce the same result, but
the DSP is usually optimized to do the up-shift by 1 bit and store, so this is normally what is done.
We can see how a Q15*Q15 multiply works by examining the process in long hand. In particular when the
scaling coefficients are multiplied the result is a new scaling constant with a Q value equal to the sum of the
two Q constants used on the operands. Given A and B in Q15 format, the result C=A*B is
C=(A*2
15
) * (B*2
15
) = A*B * 2
30
C=(A*Qx)*(B*Qy) = A*B * Qx+y
INTRODUCTION TO DSP
It is evident that the output is no longer in Q15 format. To compensate, we need to ask where the new
decimal point is. By noting that 2
30
is the same as saying Q30, we know that the decimal point is at bit 30 of
the 32-bit result. To get back to 2
15
(Q15), we can multiply by 2
15
(a shift right by 15), or by multiplying yet
again by 2
1
to a Q31 result. In this case, the correct bits are packed into the upper 16 bits of the DSP register
The fixed-point Q format has the advantage of preventing overflows but certainly introduces complications
for the DSP programmer.
INTRODUCTION TO DSP
31 ... 24 23 22 .............. 0
e s f
8 bits 1 bit 23 bits
Binary Decimal Equation
s = 0
X = 01.f x 2
e
X = 01.f x 2
e
1
s = 1
X = 10.f x 2
e
X = ( -2 + 0.f ) x 2
e
2
Exponent ( e)
Deci mal 0 1 127 -1 -128
Hex
two s comp.
00 01 7F FF 80
TMS Floating-Point Format
TMS single-precision floating-point format
Bit No
e = exponent is a signed two s compliment 8-bit fiel d and determines
the l ocation of the binary Q point
s = sign of mantissa (s = 0 positive, s =1 negative)
f = fractional part of the mantissa; an implied 1.0 is added to this fraction
but is not all ocated in the bit field since thi s val ue is al ways present
Conversion equations
Special case
s = 0 X = 0 e = -128
LECTURE 1 1-25
Copyright 1998, Texas Instruments Incorporated All Rights Reserved
Floating-Point Formats
Although the C54x device is fixed-point, a popular floating-point format (used, for example, in
TMS320C67x devices) standard is IEEE 754. The differences between various floating-point formats are
actually insignificant, and conversion can be performed in ASIC hardware or software.
TMS320 Single-Precision Floating-Point Format
The preceding table shows an example of a TMS320C67x floating-point bit assignments. The top eight bits
represent the exponent (e) in twos complement notation. Bit 23, (s), is the sign bit of the mantissa, and the
lower 23 bits are the fraction (f) of the mantissa. A value of 1.0 is also implied in the mantissa, but is not
allocated a bit position since it is always present. This format is called floating-point because of the implied
binary point floats around, depending on how large the exponent is. The exponent is essentially a variable Q
value that is automatically adjusted for maximum precision and range by the hardware.
Conversion Equations
The middle table on the slide shows the conversion equations for the TMS320 single-precision floating-point
format. The second column shows the binary and the third column shows the decimal version of the same
equation. The decimal version of the equation is easier to understand. There are two different equations for
positive and negative mantissa. We will use decimal examples of both equations to aid in the understanding
of this format.
INTRODUCTION TO DSP
The representation of 0.0 is a special case where any number with an exponent of -128 (0x80) is treated as
zero. Since -128 is the smallest possible value for the exponent, the scaling coefficient for these numbers
would produce very small values. The convention used in the assembler is to represent zero as 0x80000000.
For example, all of the following numbers are treated as the value 0:
0x80000000
0x80123456
0x80876345
This is a special case worth remembering.
INTRODUCTION TO DSP
Floating-Point Numbers
Cal cul at e 1. 0e0
I n hex 00 00 00 00
I n bi nar y 0000 0000 0000 0000 0000 0000 0000 0000
s = 0 Equati on 1 appl i es: X = 01. f x2
e
f = 0
01. 0 x 2
0 e = 0
= 1. 0
Cal cul at e 1. 5e01
I n hex 03 70 00 00
I n bi nar y 0011 0111 0000 0000 0000 0000 0000 0000
s = 0 Equati on 1 appl i es: X = 01. f x2
e
0011 e = 3
s111 ... f = 0. 5 + 0. 25 + 0.125 = 0.875
X = 01. 875 x 2
3
= 15. 0 deci mal
LECTURE 1 1-26
Floating-Point Numbers
Let us now find the binary representation of 1.0e0.
Since this is a positive number, the sign bit s=0. Therefore, Equation 1 applies. The fractional part of the
mantissa (f) is 0 (f=0), and the exponent (e) is also 0 (e=0). Now that we know the decimal values for all the
appropriate parts, we can express the 32-bit binary format. The fractional part of the mantissa (f) is zero, and
is represented by setting bits 0 to 22 and the sign bit to 0. This leaves the top eight bits for the exponent (e),
which are also set to 0. The top part of the slide shows the binary and hex representation for 1.0e0.
The binary representation of the floating-point number decimal 1.5e01 is next. This number is positive,
which implies that the sign bit s = 0 and that Equation 1 applies. Knowing that 1.875 x 8 = 15, the
fractional part of the mantissa is 0.875 (the 1.0 is implied) and the exponent e = 3 (2
3
=8). Adding fractions
0.5, 0.25 and 0.125 together yields 0.875, which corresponds to setting the top three bits (20,21 and 22) of
the fractional to 1. The binary representation of the floating-point value is shown in the bottom part of the
slide.
Calculating negative floating-point numbers is slightly different. Although it is important to understand
how binary representations correlate with decimal floating-point values, it is rarely necessary to perform the
calculation.
INTRODUCTION TO DSP
More on Floating Point
Cal cul at e - 2. 0e0
I n hex 00 80 00 00
I n bi nar y 0000 0000 1000 0000 0000 0000 0000 0000
s = 1 Equati on 2 appl i es: X = ( -2. 0 + 0. f ) x 2
e
f = 0
( -2. 0 + 0. 0 ) x 2
0 e = 0
= -2. 0
Addi t i on
1. 5 + (-2.0) = 0. 5
Multi plicati on
1.5e00 x 1.5e01 = 2. 25e01 = 22. 5
LECTURE 1 1-27
Negative Floating-Point Numbers
The binary representation in TMS320 format for -2.0e0 is now considered. Since the number is negative, the
sign bit s = 1, and equation 2 is applied. The mantissa is actually in twos compliment, so the fraction f (0.f)
is added to a decimal value of -2.0. The mantissa, -2.0+f, is then multiplied by the exponent multiplier, 2
e
.
To arrive at a value of -2.0 the fraction (f) and the exponent (e) are therefor both 0 with the sign bit set to 1.
The binary representation for -2.0e0 is shown on the top portion of the slide.
Addition and Multiplication
Addition and multiplication of floating-point numbers is simplicity in itself. The bottom portion of the slide
shows an example of each. The DSP programmer does not need to do any scaling or take any special
precautions before or after an addition, subtraction or multiply since this is all done in hardware. This is one
of the reasons why it is easier to program floating-point DSP devices.
INTRODUCTION TO DSP
Dynamic Range
Ranges of number syst ems
Numbers Base 2 Decimal
Twos
Complement
Hex
Largest Integer
2
31
- 1
2 147 483 647 7F FF FF FF
Smallest Integer
- 2
31
-2 147 483 648 80 00 00 00
Largest Q15 2
15
- 1 32 767 7F FF
Smallest Q15
- 2
15
-32 768 80 00
Largest Floating Point
127
( 2 - 2
-23
) x 2 3.402823 x
38
10
7F 7F FF FD
Smallest Floating Point -2 x 2
127
-3.402823 x
38
10
83 39 44 6E
The dynami c range of f l oat i ng- poi nt represent ati on i s very l arge
Concl usi on
Lar gest i nt eger x ( 1. 5 x 10
29
) ~ = l ar gest f l oat i ng poi nt
Lar gest Q15 x ( 1. 0 3 x 10
34
) ~ = l ar gest f l oat i ng poi nt
LECTURE 1 1-28
Comparison of Dynamic Ranges
The dynamic range in a number system means the distance, in unit steps, between the largest and smallest
number in that system. The larger the dynamic range is, the less potential it has of creating overflow
conditions. Some signal-processing applications need a larger dynamic range than others. For example, a
radar application may be trying to extract a tiny signal of only a few Vs buried in noise with an average
level of several volts.
The top table on the slide shows the dynamic ranges of a 32-bit signed integer notation, a fixed-point Q15
format used by 16 bit fixed point DSPs, and a 32-bit TMS320 single-precision floating-point format. It is
clear that the TMS320 floating-point format has a larger dynamic range, but to fully appreciate the
difference in dynamic range, you must multiply the largest integer with a constant value to reach the biggest
value in TMS320 single-precision floating-point format. This constant is very large, indicating the vast
difference in the dynamic ranges of the 32-bit signed integer notation and the TMS320 single-precision
floating-point notation. The same comparison with the Q15 format reveals an even bigger difference.
Clearly, the TMS320 single-precision floating-point format has a much larger dynamic range than the other
number systems. The TMS320C67x single-precision floating-point architecture is just one reason for its
popularity in certain signal-processing applications.
Note that the resolution in TMS320 single-precision floating-point is 24 bits. This extra precision is a big
benefit in applications such as digital audio. Humans also tend to respond to audio in a logarithmic way that
is very similar to floating point. Applications and demonstration examples that take advantage of this can be
downloaded from the Texas Instruments web site.
INTRODUCTION TO DSP
Fixed vs. Floating Point
DSP devi ces ar e desi gned as f l oat i ng poi nt or f i xed poi nt
Fi xed- poi nt devi ces ar e usual l y 16- bi t s, e. g. TMS320C5x
Fl oat i ng- poi nt devi ces are usual l y 32- bi t s, e. g. TMS320C3x
Fl oat i ng- poi nt devi ces usual l y have a f ul l set of f i xed- poi nt i nst r uct i ons
Fl oat i ng poi nt devi ces ar e easi er t o pr ogr a m
Fi xed- poi nt devi ces can emul at e f l oat i ng poi nt i n sof t war e
Compari son
Characteristic Floating point Fixed point
Dynamic range much larger smaller
Resolution comparable comparable
Speed comparable comparable
Ease of programming much easier more difficult
Compiler efficiency more efficient less efficient
Power consumption comparable comparable
Chip cost comparable comparable
System cost comparable comparable
Design cost less more
Time to market faster slower
LECTURE 1 1-29
DSP Devices
DSP devices are designed as fixed- or floating-point devices. The design philosophy, data paths, and
internal modules of each device are different. Generally, fixed-point devices address high-volume and
inexpensive applications while floating-point devices target high-performance applications. But these
differences are becoming hard to distinguish because the price of floating-point devices continues to fall.
Fixed-point devices, such as the TMS320C54x device, are usually 16 bits with fewer external pins.
Floating-point devices, such as the TMS320C67x device, are commonly 32 bits. Floating-point devices
usually have a full set of fixed-point instructions and can be used as fixed-point processors without any speed
penalty. Fixed-point devices can emulate floating-point devices in software, but there is a speed penalty
because the conversion from fixed- to floating- point is performed in software.
Comparison of Fixed vs. Floating-Point Devices
A table comparison of fixed- and floating-point devices shows clearly the key component of each of the
systems. Features like floating-point relieves the designer of any consideration of dynamic range in the
design, but can cost more in CPU and additional memory costs.
The speed of fixed point systems will tend to be slightly higher and consume less power, yet with the
parallelism and greater precision of 32 bit data, this can sometimes easily outweigh any speed penalty.
Floating-point devices are much easier to program; there is less concern with scaling, dynamic-range issues
and, in most cases, resolution. Resolution is often determined by bus width but this also drives system cost.
INTRODUCTION TO DSP
C compilers for floating-points devices are much more efficient than C compilers for fixed-point devices.
The primary reason for this is that the fixed-point devices do not have large register sets and therefore need
software modules for number conversions to provide a reasonable C interface. For example, when the C
programmer declares a floating-point number, an assembler routine needs to convert this format into fixed-
point format and back again after the processor has executed the necessary operations. Fixed-point devices
typically have 1 or 2 accumulators, whereas the C67x floating-point family has sixteen 32-bit registers that
can be used for math operations. Having more registers to work with is an advantage for a C compiler.
These are important points in choosing a device for an application. Programs written in C will tend to favor
floating-point devices.
Power consumption depends heavily on both the system architecture and the software that is used. In a
CMOS design, power is consumed when a capacitive node is charged from one supply rail to the other. If
the change in state does not occur, no power is consumed. Since the processor, memory and surrounding
system board may consist of millions of internal and external nodes, it is important to toggle as few as
possible to get complete a given task. The other variable is to try and minimize the capacitance of each
node. Simply put, toggles per second and higher capacitance equates to more power usage.
Power consumption is therefore related to clock rates and data-bus width. If it takes fewer cycles to get the
same job done on a wider bus, the net power usage may be the same or even better. For example, a 16-bit
fixed-point device might use a similar amount of power when compared to a 32-bit floating-point device
using only 16 bits of its data bus.
The cost of floating-point-device chips is also becoming comparable to traditional fixed-point devices.
Floating-point system costs need not be high just because they are internally using 32 bits. Minimum
systems are made possible through the efficient use of internal RAM and fewer external components. The
DSP Starter Kits and all of the applications that run on them would be an excellent example of a minimal
system.
The cost of programming, measured in the salary dollars paid out to a programmer, can also be a deciding
factor. Selling many units to a very large market can absorb the extra time required for a fixed-point design.
For smaller markets, or when time to market is important, the low design costs of floating-point are very
beneficial.
Selecting a device for a particular application is a complex decision and should be considered carefully along
with any other points that are specific to the design. Our discussion highlighted some of the more important
considerations.
INTRODUCTION TO DSP
TMS320 Famil y
16-Bit Fixed Point Devices
C1x Hard-Disk Controllers
C2x Fax Machi nes
C2xx Embedded Cont rol