DSPLIB
From Texas Instruments Embedded Processors Wiki
Overview
The DSP Library (DSPLIB) is a collection of high-level optimized DSP function modules for the C55x DSP platform. This source-code library includes C-callable functions (ANSI-C language compatible) for general signal processing math and vector functions that have been ported to C55x DSPs. The functions listed in the features section are specifically optimized for the C55x DSPs.
Functions
Please check the product documentation or DSPLIB#Manuals for a detailed list of functions. Functions included are:
- FFT
- Filtering and convolution
- Adaptive filtering
- Correlation
- Math
- Trigonometric
- Miscellaneous
- Matrix
Download
- Download the TMS320C55x DSP Library here
Roadmap
- Update to rev 3 of 55x core.
- Note current library was originally written for the rev 2.2 of the 55x core. Updating to rev 3 should yield some performance improvements. The rev 2.2 code should operate correctly on the rev 3 core.
Manuals
- Please refer to C55x DSP Library Programmer’s Reference Manual for more details.
FAQ
Q: Can the DSPLIB implementation of FFT algorithms support 2048 or 4096 point complex FFTs?
- The C55x DSP Library Programmer's Reference Guide says that the number of elements in the input vector must be between 8 and 1024. This is the default configuration for the FFT routines.
- The DSPLIB FFT code implementation already supports larger sizes. The 1024 size was decided as the default based on customer requirements at the time the LIB was developed. The size is dependent on the twiddle table that is incorporated in the DSPLIB library. If you look in CCS folder at \C5500\dsplib\twiddle you will see that there are twiddle tables to support up to 4096 point FFT.
- To support the larger size you will need to rebuild the DSPLIB with the larger twiddle table. You will need to change the twiddle.asm file that is in the \dsplib\55x_src folder. There are 2 files, twiddle.asm and twiddle.inc. I think that twiddle.asm is the one that is used by the fft routines. Section 2.3 of the DSP Library Reference Guide describes how to rebuild the DSPLIB once twiddle.asm is replaced in the \dsp_src folder.
Q: Does the DSPLib use the FFT Coprocessor found in the 55x? =
- As of version 2.40 no.
- You may want to look at tidoc:sprabb6
Q: How do get a 2048 or 4096 FFT using the HW accelerator?
- See HWAFFT App Note (SPRABB6) which can be found at tidoc:sprabb6 and look at section 8 - Computation of Large (Greater Than 1024-Point) FFTs on the VC5505 and C5505/15
Q: Why does DSPLIB Add function give incorrect results?
The add.asm file of DSPLIB v2.40.00 incorrectly sets circular addressing mode for the Auxillary Register AR1. Circular addressing is not required for this function and causes AR1 to be set to zero for use as offset pointer for a circular buffer implementation.
The routines in the DSPlib are tested using test routines which come with the library. The file add.asm passes these test routines, because the registers BSA01, which is used for the computation of the start address of the circular buffer, and BK03, which determines the buffer size, were set to zero. This setting effectively disables the circular "wrapping" of the addresses, and has a linear addressing scheme as a consequence. If registers BSA01 and BK03 are non-zero then the test will fail.
To correct this situation change add.asm statement:
ST2mask .set 0000000000010010b to ST2mask .set 0000000000010000b
This bug has been reported for C55x DSPLIB v2.40.00.
How can I rebuild the DSPLIB v2.40.00 library for a newer CPU rev. 3.x?
Here is how to rebuild the DSP library package for CPU rev. 3.3 with options to choose memory model:
- Copy and rename Blt55xx.bat in the dsplib_2.40.00 folder. Open with a text editor.
- Comment out c:\ti\dosrun.bat (CCS3.3 relic). REM is the CMD line comment (remark)
- Specify the path to the most current Code Gen Tools (CGT)
Download Latest C55x Code Gen Tools here - Add OPTIONS for C5505/15 (cpu:3.3, 5505, 5515 are equivalent) and desired memory model (use --ptrdif_size=32 for huge mem model only)
- Change the name of the output library to represent memory model (DSPLIB=55xdsph)
- Either double click the batch file or run it from Windows CMD line to see the output...
- Include the newly created library file in your project and test it with the DSPLIB examples
Here is how the Blt55xh.bat file should look for C5505/15(cpu:3.3) & huge mem model:
REM this file is for building DSPLIB in huge memory module on C5505/15 REM call c:\ti\dosrun.bat set CGT_BIN=C:/Program Files/Texas Instruments/ccsv4/tools/compiler/C5500 Code Generation Tools 4.3.8/bin set PATH=%PATH%;%CGT_BIN% REM Equivalent OPTIONS for C5505/15, huge memory model: set OPTIONS= -g -vcpu:3.3 --memory_model=huge --ptrdiff_size=32 REM set OPTIONS= -g -v5515 --memory_model=huge --ptrdiff_size=32 REM set OPTIONS= -g -v5505 --memory_model=huge --ptrdiff_size=32 REM Equivalent OPTIONS for C5505/15, large memory model: REM set OPTIONS= -g -vcpu:3.3 --memory_model=large REM set OPTIONS= -g -v5515 --memory_model=large REM set OPTIONS= -g -v5505 --memory_model=large REM set OPTIONS= -g -v5505 -ml set DSPLIB=55xdsph set SRC=55x_src set FILES= *.asm set EXT=asm REM built library in SRC dir and then copy to root del %DSPLIB%.src del %DSPLIB%.lib cd %SRC% del *.obj cl55 %OPTIONS% %FILES% ar55 -r %DSPLIB%.src *.%EXT% ..\include\*.h ar55 -r %DSPLIB%.lib *.obj copy %DSPLIB%.src .. copy %DSPLIB%.lib .. del *.src del *.lib dir *.obj >> ..\junk.txt del *.obj cd ..
v2.40.00 Errata
Rather than post the full code diffs, these notes are intended as brief documentation of errors that have been confirmed in the latest release of DSPLIB.
add alters 3 status registers without save and restore
The vector add() routine modifies ST0_55, ST1_55, and ST2_55 without saving the original values. Although an attempt is made to reverse the flag changes in one or two status registers, there's no guarantee that the original settings are restored. This could be fixed by pushing the original status register values on the stack.
mul32 alters T3 and AR5 without saving
The C language ABI for the C5000 requires that the callee preserve T2, T3, AR5, AR6 and AR7. mul32() alters T3 and AR5 without saving and restoring the initial value. PSH T3, PSHBOTH XAR5 and POPBOTH XAR5, POP T3 are all that need to be added to fix this.
sqrt_16 has off-by-one error and is coded inefficiently
The vector square root routine incorrectly rounds the results by adding 1, such that the square root of zero is one, and all results are off by the same amount. This can be repair by changing the bit shift count in the final instruction. In addition, the code does not make use of the ROUND instruction or the Round modifier for any other instruction, and thus the code is more complex than it needs to be. If optimizations are made, then no stack space is needed for intermediate values.
unpack writes outside the stack 50% of the time
The unpack() routine that is part of the rfft() macro uses AADD #-2, SP and MOV pair(T2), dbl(*SP(#0)) to save T2 and T3, following by MOV dbl(*SP(#0)), pair(T2) and AADD #2, SP to restore them. However, if the stack pointer happens to be odd, then T3 will be written outside the stack where it can be trashed by any hardware interrupt. The single instruction PSH T2, T3 accomplishes the required task in half the cycles and one fifth the code size, including the matching POP T2, T3.
twiddle table is not aligned
The documentation for cfft() states that the twiddle table must be aligned on a 32-bit word boundary, and yet the twiddle.asm source does nothing to ensure that this happens. Adding a single line with " .align 1024" between the .sect and twiddle: label makes everything kosher.
Support
Related
Leave a Comment
Comments
Latest version and download location
What is the latest version of dsplib? 2.40.00? 3.3?
Where can we find a download link for dsplib?
Searching for dsplib on the main Texas Instruments site produces 106 results, but no master page seems to collect the relevant information in one place. I thought perhaps that this page would hold some information along these lines. Rsdio 22:07, 26 July 2010 (UTC)
open source community participation and contributions
dsplib is open source, but have there been any external improvements or additions? Is there a community for dsplib outside of Texas Instruments? If so, where do I find out more? Rsdio 22:58, 5 July 2010 (UTC)
