digital signal processors for real-time embedded systems
DESCRIPTION
Digital Signal Processors for Real-Time Embedded Systems. By Jeremy Kohel. Overview. What is a DSP? Common characteristics of DSP’s Software considerations Available tools Example code. What is a DSP?. Definition: - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/1.jpg)
Digital Signal Processors for Digital Signal Processors for Real-Time Embedded SystemsReal-Time Embedded Systems
By Jeremy Kohel
![Page 2: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/2.jpg)
OverviewOverview
What is a DSP?Common characteristics of DSP’sSoftware considerationsAvailable toolsExample code
![Page 3: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/3.jpg)
What is a DSP?What is a DSP?
Definition:
“A specialized microprocessor designed specifically for the rapid processing of digital signals in real time.”
What does this mean?
Where are they found?
![Page 4: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/4.jpg)
Digital Signal Processing in Digital Signal Processing in ActionAction
![Page 5: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/5.jpg)
Common characteristics of Common characteristics of DSP’sDSP’s
The ability to perform many highly numeric intensive tasks at fast speeds
Efficient instructions (MAC’s)Efficient memory accessEfficient address generation
![Page 6: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/6.jpg)
MAC’sMAC’s
MAC’s = multiply-accumulate instructionsHighly used in DSP applicationsMust be done in at most a single instruction
cycleEquivalent to “a = a + (b x c)” where “a” is
an accumulator register
![Page 7: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/7.jpg)
MAC’s (cont.)MAC’s (cont.)
MAC’s are helpful to calculate the sum of many multiplication operations– Vector dot products used in many algorithms,
i.e. filtering
Some DSP’s have multiple accumulators and multiplier units so they can perform many MAC’s in a single instruction cycle
![Page 8: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/8.jpg)
Basic DSP architectureBasic DSP architecture
![Page 9: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/9.jpg)
MAC exampleMAC example
![Page 10: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/10.jpg)
Efficient Memory AccessEfficient Memory Access
DSP’s must be able to make multiple access to memory in a single instruction cycle
Allows for fetching the next instruction while at the same time fetching operands and/or saving data to memory from a previous instruction
![Page 11: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/11.jpg)
In order for this to happen…In order for this to happen…
Requires multiple on-chip busesRequires multiple on-chip memory banksOnly a few instructions in the entire
instruction set have this ability
![Page 12: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/12.jpg)
Address GenerationAddress Generation
DSP’s require separate generation units in order to find the next address needed
Run in the background outside the main data path
Allows an address of operand access to be calculated at the same time as performing arithmetic operations
![Page 13: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/13.jpg)
Software ConsiderationsSoftware Considerations
How will the program be developed/tested– DSP hardware, simulator
In what language will the program be developed?– Assembly, C/C++, Ada, etc.
![Page 14: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/14.jpg)
Cross Compiler vs. Native Cross Compiler vs. Native CompilerCompiler
DSP object code differs from the object code of a regular, CPU-driven workstation
Cross compiler runs on CPU workstation and creates DSP object code
Native compiler runs on CPU workstation and creates object code for that computer
Either have DSP hardware at hand or test with a simulator to mimic hardware
![Page 15: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/15.jpg)
Language DilemmaLanguage Dilemma
Assembly vs. CCompilers are available for other higher
level languages C is most commonly used in real-time
applicationsAdvantages and disadvantages of each
![Page 16: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/16.jpg)
DSP AssemblyDSP Assembly
More efficient than C codeProvides a more optimal solutionIncludes 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
![Page 17: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/17.jpg)
Disadvantages of DSP Disadvantages of DSP AssemblyAssembly
Takes longer to write codeMore difficult to write solutionsR7 = Max(R5, R6)LDF R7, R6
COMF R5, R7
LDFLT R7, R5
![Page 18: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/18.jpg)
More DisadvantagesMore Disadvantages
DSP data is stored differently (No integers)Only fractional part of floating point
numbersTherefore you can’t get a number greater
than 1 – $7FFFFF = 0.99999988709
Highest number allowed MSB is the sign bit
![Page 19: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/19.jpg)
Problems?Problems?
There can be numbers larger than 1 or smaller than –1
This is allowed using the accumulator and 56 bits
Accumulator = A2(8 bits):A1(24 bits):A0(24 bits)
![Page 20: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/20.jpg)
Acc (cont.)Acc (cont.)
If the number stored is 24 bits then its stored in A1 with A0 being zeroed out and A2 being sign extended – $FF:834345:000000
Otherwise the MSB of A2 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)
![Page 21: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/21.jpg)
Embedded CEmbedded C
Easier to write code forPrograms are shorter and less complexCompilers availableC is very versatile, and highly portable
![Page 22: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/22.jpg)
Problems with CProblems with C
The resulting assembly code is not optimal and therefore must be hand optimized
Many compilers claim code optimized for density and execution time– Most of the time this is not the case
Compilers allow for assembly code to be inserted inline
![Page 23: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/23.jpg)
Other issuesOther issues
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)
![Page 24: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/24.jpg)
![Page 25: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/25.jpg)
Software ToolsSoftware Tools
DirectDSP by SignalogicCreates an interface between the DSP
hardware and other well known development environments– Matlab, Visual Studio, .NET
Real-time watchesWaveform generator
![Page 26: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/26.jpg)
DirectDSPDirectDSP
![Page 27: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/27.jpg)
Code Composer StudioCode Composer Studio
Distributed by Texas InstrumentsProvides a user-friendly IDEC/C++ compilerProject ManagerSimulator
![Page 28: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/28.jpg)
CCSCCS
Real-time analysis (similar to DirectDSP)– Cache log – Color codes cache hits to optimize algorithm
placement
Code Coverage– Highlights lines of code not executed– Lists number of times lines are executed
Allows optimization
![Page 29: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/29.jpg)
ANSI C Code GeneratorANSI C Code Generator
Distributed by HyperceptionWorks in coordination with graphical
design environments Creates C code based on the designGood for porting algorithmsDecrease develop time
![Page 30: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/30.jpg)
Problems with code Problems with code generationgeneration
Doesn’t provide optimized code– Must be hand optimized
Won’t generate assembly libraries
![Page 31: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/31.jpg)
Code ExampleCode Example
void UserProc(void* ptrIn, void* ptrOut, long nLen, short int nNumTrace)
{
#ifdef defined(TMS320C3x) || defined(TMS320C4x) || defined(DSP5600x) || defined(ADSP2106x)
#define x ((long*)ptrIn)
#define y ((long*)ptrOut)
#endif
short int n;
![Page 32: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/32.jpg)
More codeMore code
for (n=0; n<nLen; n++)
{
x[n] = 0.75*x[n] + 1000;
y[n] = x[n];
}
}
![Page 33: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/33.jpg)
Conclusion – Things to Conclusion – Things to rememberremember
DSP’s are not versatile, they are specialized to a specific task– CPU/DSP systems popular
They value efficiency over oscillator frequency
When developing a DSP application higher level languages are easier, but will not give as optimized code as assembly
![Page 34: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/34.jpg)
ReferencesReferences
[1] “Choosing a DSP Processor”, Berkeley Design Technology white paper, http://www.bdti.com/articles/choose_2000.pdf
[2] Jennifer Eyre and Jeff Bier, “The Evolution of DSP Processors”,
Berkeley Design Technology white paperhttp://www.bdti.com/articles/evolution.pdf
[3] “Adding user defined C routines to real-time DSP code”, Signal Logic, http://www.signalogic.com/index.pl?page=ccode#using
[4] "DSP Algorithm Development Tools" DSP & Multimedia Technology, November 1993
![Page 35: Digital Signal Processors for Real-Time Embedded Systems](https://reader035.vdocument.in/reader035/viewer/2022062423/56814e93550346895dbc3c90/html5/thumbnails/35.jpg)
References (cont.)References (cont.)
[5] “Digital Signal Processing, C6000 DSPs”, Texas Instruments, http://focus.ti.com/paramsearch/docs/parametricsearch.tsp?family=dsp§ionId=2&tabId=57&familyId=132
[6] “C-Language Programming for DSP”, Pentek Inc white paper,
http://www.pentek.com/deliver/TechDoc.cfm/C_LangProg.pdf?Filename=C_LangProg.pdf