Digital Signal Processors for Real Time Embedded Systems

Digital Signal Processors for Real -Time Embedded Systems By Jeremy Kohel

Overview l What is a DSP? l Common characteristics of DSP’s l Software considerations l Available tools l Example code

What is a DSP? l Definition: “A specialized microprocessor designed specifically for the rapid processing of digital signals in real time. ” What does this mean? Where are they found?

Digital Signal Processing in Action

Common characteristics of DSP’s l The ability to perform many highly numeric intensive tasks at fast speeds l Efficient instructions (MAC’s) l Efficient memory access l Efficient address generation

MAC’s l MAC’s = multiply-accumulate instructions l Highly used in DSP applications l Must be done in at most a single instruction cycle l Equivalent to “a = a + (b x c)” where “a” is an accumulator register

MAC’s (cont. ) l MAC’s are helpful to calculate the sum of many multiplication operations – Vector dot products used in many algorithms, i. e. filtering l Some DSP’s have multiple accumulators and multiplier units so they can perform many MAC’s in a single instruction cycle

Basic DSP architecture

MAC example

Efficient Memory Access l DSP’s must be able to make multiple access to memory in a single instruction cycle l Allows for fetching the next instruction while at the same time fetching operands and/or saving data to memory from a previous instruction

In order for this to happen… l Requires multiple on-chip buses l Requires multiple on-chip memory banks l Only a few instructions in the entire instruction set have this ability

Address Generation l DSP’s require separate generation units in order to find the next address needed l Run in the background outside the main data path l Allows an address of operand access to be calculated at the same time as performing arithmetic operations

Software Considerations l How will the program be developed/tested – DSP hardware, simulator l In what language will the program be developed? – Assembly, C/C++, Ada, etc.

Cross Compiler vs. Native Compiler l DSP object code differs from the object code of a regular, CPU-driven workstation l Cross compiler runs on CPU workstation and creates DSP object code l Native compiler runs on CPU workstation and creates object code for that computer l Either have DSP hardware at hand or test with a simulator to mimic hardware

Language Dilemma l Assembly vs. C l Compilers are available for other higher level languages l C is most commonly used in real-time applications l Advantages and disadvantages of each

DSP Assembly l More efficient than C code l Provides a more optimal solution l Includes instructions to make common tasks more efficiently executed – “Loop” or “Repeat” instruction – Doesn’t waste cycles on checking count variables or branching back to the top of a loop

Disadvantages of DSP Assembly l Takes longer to write code l More difficult to write solutions l R 7 = Max(R 5, R 6) l LDF R 7, R 6 COMF R 5, R 7 LDFLT R 7, R 5

More Disadvantages l DSP data is stored differently (No integers) l Only fractional part of floating point numbers l Therefore you can’t get a number greater than 1 – $7 FFFFF = 0. 99999988709 Highest number allowed l MSB is the sign bit l

Problems? l There can be numbers larger than 1 or smaller than – 1 l This is allowed using the accumulator and 56 bits l Accumulator = A 2(8 bits): A 1(24 bits): A 0(24 bits)

Acc (cont. ) l If the number stored is 24 bits then its stored in A 1 with A 0 being zeroed out and A 2 being sign extended – $FF: 834345: 000000 l Otherwise the MSB of A 2 is the sign bit with the other 7 being the integer and the other 48 being the decimal – $00: 834345: 125345 (Allows for numbers between – 128. 0 and 127. 99)

Embedded C l Easier to write code for l Programs are shorter and less complex l Compilers available l C is very versatile, and highly portable

Problems with C l The resulting assembly code is not optimal and therefore must be hand optimized l Many compilers claim code optimized for density and execution time – Most of the time this is not the case l Compilers allow for assembly code to be inserted inline

Other issues l C requires a large number of external libraries that need to be compiled into the program – I/O libraries – Run-Time libraries (math, string, memory) – DSP libraries (matrix arithmetic, filtering, image processing)


Software Tools l Direct. DSP by Signalogic l Creates an interface between the DSP hardware and other well known development environments – Matlab, Visual Studio, . NET l Real-time watches l Waveform generator

Direct. DSP

Code Composer Studio l Distributed by Texas Instruments l Provides a user-friendly IDE l C/C++ compiler l Project Manager l Simulator

CCS l Real-time analysis (similar to Direct. DSP) – Cache log – Color codes cache hits to optimize algorithm placement l Code Coverage – Highlights lines of code not executed – Lists number of times lines are executed l Allows optimization

ANSI C Code Generator l Distributed by Hyperception l Works in coordination with graphical design environments l Creates C code based on the design l Good for porting algorithms l Decrease develop time

Problems with code generation l Doesn’t provide optimized code – Must be hand optimized l Won’t generate assembly libraries

Code Example void User. Proc(void* ptr. In, void* ptr. Out, long n. Len, short int n. Num. Trace) { #ifdef defined(TMS 320 C 3 x) || defined(TMS 320 C 4 x) || defined(DSP 5600 x) || defined(ADSP 2106 x) #define x ((long*)ptr. In) #define y ((long*)ptr. Out) #endif short int n;
![More code for (n=0; n<n. Len; n++) { x[n] = 0. 75*x[n] + 1000; More code for (n=0; n<n. Len; n++) { x[n] = 0. 75*x[n] + 1000;](http://slidetodoc.com/presentation_image_h/9933b6525fcf98d0cfb2a5820ae068a0/image-32.jpg)
More code for (n=0; n<n. Len; n++) { x[n] = 0. 75*x[n] + 1000; y[n] = x[n]; } }

Conclusion – Things to remember l DSP’s are not versatile, they are specialized to a specific task – CPU/DSP systems popular l They value efficiency over oscillator frequency l When developing a DSP application higher level languages are easier, but will not give as optimized code as assembly
![References l [1] “Choosing a DSP Processor”, Berkeley Design Technology white paper, http: //www. References l [1] “Choosing a DSP Processor”, Berkeley Design Technology white paper, http: //www.](http://slidetodoc.com/presentation_image_h/9933b6525fcf98d0cfb2a5820ae068a0/image-34.jpg)
References l [1] “Choosing a DSP Processor”, Berkeley Design Technology white paper, http: //www. bdti. com/articles/choose_2000. pdf l [2] Jennifer Eyre and Jeff Bier, “The Evolution of DSP Processors”, Berkeley Design Technology white paper http: //www. bdti. com/articles/evolution. pdf l [3] “Adding user defined C routines to real-time DSP code”, Signal Logic, http: //www. signalogic. com/index. pl? page=ccode#using l [4] "DSP Algorithm Development Tools" DSP & Multimedia Technology, November 1993
![References (cont. ) l [5] “Digital Signal Processing, C 6000 DSPs”, Texas Instruments, http: References (cont. ) l [5] “Digital Signal Processing, C 6000 DSPs”, Texas Instruments, http:](http://slidetodoc.com/presentation_image_h/9933b6525fcf98d0cfb2a5820ae068a0/image-35.jpg)
References (cont. ) l [5] “Digital Signal Processing, C 6000 DSPs”, Texas Instruments, http: //focus. ti. com/paramsearch/docs/parametricsearch. tsp? family=dsp §ion. Id=2&tab. Id=57&family. Id=132 l [6] “C-Language Programming for DSP”, Pentek Inc white paper, http: //www. pentek. com/deliver/Tech. Doc. cfm/C_Lang. Prog. pdf? Filena me=C_Lang. Prog. pdf
- Slides: 35