DSP knowledge Summary

Source: Internet
Author: User

Chapter 2 fixed-point operations on DSP Chips
1. Data overflow:
1> overflow classification:
Overflow ):
Underflow)
2> overflow result:
Unsigned char 0 255
Signed Char-128 127
Unsigned int 0 65535
Signed int-32768 32767
Overflow moves counter-clockwise on the circle; overflow moves along the clock on the circle.
Example: signed INT: 32767 + 1 =-32768;-32768-1 = 32767
Unsigned char: 255 + 1 = 0; 0-1 = 255
3> to avoid overflow, you can set the overflow protection function in DSP. When overflow occurs, the result is automatically set to the maximum or minimum value.

2. Fixed Point processor processing of floating point numbers:
1> define variables as float (double). Use C language to flat the difference between a fixed-point processor and a floating-point processor. However, the program code is huge and the computing speed is slow.
2> zoom in multiple times to indicate decimal places. For example, to indicate a variable with a precision of 0.01, zoom in 100 times to perform the operation, and then convert the operation. However, this practice is stiff. to redefine the above variables to 0.001 accuracy, we need to increase the accuracy by 1000 times, re-compile the entire program, and consider overflow and other issues.
3> calibration method: Q format: determines the decimal precision by assuming the right of the decimal place.
Q0: the decimal point is behind 0th digits.
Q15: the decimal point is behind 15th digits, 0 ~ All 14 digits are decimal places.
Conversion Formula: q = (INT) (F × POW (2, q ))
F = (float) (q x POW (2,-q ))
3. Q format Calculation
1> fixed-point addition and subtraction: The addition and subtraction must be converted to the same Q format.
2> fixed-point multiplication: data in different Q formats is multiplied, which is equivalent to the sum of Q values.
3> fixed-point Division: Division of data in different Q formats, equivalent to subtraction of Q values
4> shift left: The Shift left is equal to the increase of the Q value.
5> shift right: The Shift right is equal to Q reduction.
4. Application Format in Q format
In practice, floating point operations usually involve both integer and decimal parts. Therefore, you must select an appropriate calibration format to better process the operation. The following two methods are generally used:
1> moderate calibration can be used to indicate integer reset or decimal reset. For 32-bit systems of 2812, q15 format can be used to indicate-65536.0 ~ Data within the range of 65535.999969482.
2> all decimals are used. In this way, the multiplication between decimal places is always a decimal place and will never overflow. Take the maximum value (preferably the N power of 2) and convert it to the decimal number of X/MAX (if Max is the N power of 2, you can use shift instead of Division ).
5. TI's qmath. Lib library description:
See the detailed description of TI's document c28x iqmath library (sprc087a424.zip.
Ti provides a mathematical library qmath. Lib in Q format.
Pay attention to the time series and space requirements of Q format functions, so as to minimize the need for priority.
Chapter 2 Preparation of the CMD file
1. coff format
1> common object file format is a popular binary executable file format. binary executable files include library files (LIB) and target files (OBJ) the final executable file (out )., The binary file format (PE) of Windows 95 and NT4.0 and later operating systems on PCs is further expanded based on the coff format.
2> coff format: Detailed coff file formats include segment headers, executable code and initialization data, relocable information, row number entries, symbol tables, string tables, etc, these are of interest to the compiler and the compiling of the operating system. For C, you only need to understand the definition section and allocate space for the Section.
3> using coff is more conducive to modular programming. programmers can freely decide which codes belong to which segments and then process them differently.
2. The smallest unit in the target file of section is block. A block is a piece of code or data that eventually occupies continuous space in the memory image.
1> the coff target file contains three default blocks:
. Text executable code
. Data initialized data
. BSS is the reserved space for uninitialized data
2> Assembler's Block Processing
Uninitialized Block
. BSS variable storage space
. Usect User-Defined uninitialized segment
Initialization Block
. Text Assembly command code
. Data constant data (for example, initialization data for variables)
. Sect User-Defined initialized segment
. Asect Tong. sect, which has the absolute address location function and is generally not used
3> C language segments
Uninitialized block (data)
. BSS stores global and static variables
. BSS for long calls by. ebss (exceeds the 64 K address limit)
. STACK: Stack for storing C Language
. Sysmem stores C-language heap
. Sysmem for. esysmem long call (exceeds the 64 K address limit)
Initialization Block
. Text executable code and constant (Program)
Constant table generated by the. Switch switch statement (Program/64 K low data space)
. Pinit tables for global Constructors (C ++) (Program)
. Cinit is used to store the initialization constant values (Program) for global and static variables)
. Const global and static const variable initialization value and String constant, (data)
. Econst long. Const (can be located anywhere) (data)
3> Custom segments (c)
# Pragma data_section (function name or global variable name, "user-defined segment name in data space ");
# Pragma code_section (function name or global variable name, "user-defined segment name in the program space ");
It cannot be declared in the function body.
Must be declared before definition and use
# Pragma can prevent Optimization of uncalled Functions
3. Connect to the command file (CMD)
1> memory
Memory
{
Page 0:
Name 0 [ATTR]: rigin = constant, length = constant
Page N:
Name N [ATTR]: rigin = constant, length = constant
}
Page N: indicates the bucket. n <255; Page 0 indicates the bucket of the program; Page 1 indicates the bucket of the program.
Name: bucket name
ATTR: bucket attribute: Read-Only R, write only w, can contain executable code X, can be initialized I.
Orgin: used to define the starting address of a bucket.
Lenth: used to define the length of a bucket
2> sections CIDR Block
Sections
{
Name: [property, property,…]
}
Name: name of the output segment
Property: attributes of the output segment:
Load = allocation (forced address or bucket name) is the same as> allocation: defines where the output segment will be loaded.
Run = allocation (forced address or bucket name) is the same as> allocation: defines where the output segment will run.
Note: When only one keyword load or run is displayed in the CMD file, the addresses of both are overlapped.
Page = n, where the segment is located.
Example: ramfuncs: load = flashd,
Run = raml0,
Load_start (_ ramfuncsloadstart ),
Load_end (_ ramfuncsloadend ),
Run_start (_ ramfuncsrunstart ),
Page = 0

3> directly write the compilation command
-L rts2800_ml.lib: connect to the System File rts2800_ml.lib
-O filename. Out: The final binary file generated is named filename. Out.
-M filename. MAP: generate the ing file filename. Map.
-Stack 0x200 the stack is 512 words

4. Const segment:
The initialization value of the global variable limited by the keyword const (the local variable limited by const is not generated), and the value appears in the expression (used as a pointer, but not used to initialize the string array variable) in addition, when the array and struct are local variables, their initial values will be generated. const segment, but not global.
Chapter 2 C Language Environment
1. C language software development process
The software development process involves compiler, assembler, linker, archiver, library-build utility ), run Time support library, Hex conversion utility, cross reference Lister, and absolute Lister. Most of the settings can be set either through commands or through the project/build options of CCS.
1>. compiler: Compile the C language source code to generate the assembly language source code.
One-step compilation: cl2000-V28 [-options] filenames [object files] [-Z [link_options]
Distributed Compilation: grammar analysis: generate the intermediate file AC2000 file. C for file. If
Code optimization: generate the file opt2000 file. If
Code Generation: generate the cg2000 file. Opt Assembly file for file. ASM.
Assembly: generate the file. OBJ target file asm2000 file. ASM
2>. Assembler: translate the source assembly language file into a machine language target file. The machine language format is a common target file (coff ). The command format is as follows:
Asm2000 version [input file [object file [listing file] [Options]
3>. connector: combines multiple target files into a single executable target module. It creates an executable module and completes relocation and determines external references. The connector input is the relocated target file and target library file. The command format is as follows:
Assembly Language: lnk2000 [Options] filename1, filename2 ...... [Filenamen]
C language: lnk2000 {-c |-Cr} filenames [Options] [-O name. Out] [lnk. CMD] [-l libname, lib]
Note:-C automatically initializes variables during runtime
-Cr automatically initializes the variable when loading the program
Options: For more information, see the manual.
-O name. Out: output file name
Name of the CMD file connected by lnk. cmd
-L name of the supported library for libname. Lib connection
Example: lnk2000-C prog1 prog2 prog3-O Prog. Out rts2800.lib
4>. archiver)
Archiver can be used to separate and merge files in a document (archive) or library. These documents or libraries can be source or target files. The archive can create, add, delete, replace, and extract databases. The command format is as follows:
AR2000 [-] command [Options] libname [filename0, filename1 ,...... Filenamen]
1> this command is applicable to other DSP-like commands and formats. For details, refer to TI's documentation. The command is located in/ccs_v3.1/c2000/cgtools/bin.
2> command:
@ Use the CMD file
A (ADD) adds a specified file to a specified document
D (delete) delete a specified file in a specified document
R (replace) replaces the specified file in the specified document
T (table) List objects in a specified document
X (extract) extracts specified files from a specified document
3> options:
Q (quiet) shielding status information
Global symbols defined in the S (Symbol) Column (invalid for command A, R, D)
U updates the modification date synchronously when replacing the file
V (verbose) provides detailed descriptions
4> the document name specified by libname
5> file name specified in the filename document

5>. library-build utility: Create a running support library that meets your requirements. CCS provides the RTS library file (/ccs_v3.1/c2000/cgtools/LIB) and the corresponding source program file (RTS. SRC (/ccs_v3.1/c2000/cgtools/LIB ). For example, rts2800.lib: C/C ++ support library; rts2800_ml.lib C/C ++ support library in large memory mode; users can use the archive and library builder to access the RTS. SRC files are extracted, modified, and generated again.
The command format is as follows:
Mk2000-V28 [Options] src_arch1 [-l objlib1] src_arch1 [-l objlib1]…

6>. run Time Support Library ): it includes ANSI standard functions supported by the C compiler, compiler utility functions, floating-point functions, and I/O functions supported by the C compiler. CCS provides the RTS library file (/ccs_v3.1/c2000/cgtools/LIB) and the corresponding source program file (RTS. SRC (/ccs_v3.1/c2000/cgtools/LIB ). For example, rts2800.lib: C/C ++ support library; rts2800_ml.lib C/C ++ support library in large memory mode. library files include standard C/C ++ support library functions, floating-point computing programs, and system startup programs _ c_int00.

7>. hex conversion utility: it converts coff target files into target formats such as Ti-tagged, ASCII-Hex, Intel, Motorola-S, or Tektronix, you can download the converted file to the EPROM programmer.
Hex2000 [-options] filename
-A ASCII-HEX
-I intel
-T Ti-tagged
-M Motorola-S
-X Tektronix

8>. Cross Reference Lister: it uses the connected target file to generate a reference list file, which displays the symbols, their definitions, and the source files where the symbols are located.
Xref2000 [Options] [input filename [Output Filename]
Options:-LXX: XX rows (decimal number) are displayed on each page)
-Q (quiet) does not display prompt messages
Input filename OBJ file
X-ray file generated by Output Filename

9>. Absolute Lister: It inputs the connected target file, outputs The. Abs file, and generates a list file containing the absolute address through the Assembly. Abs file. Without an absolute list server, these operations will require tedious manual operations.
Abs2000 [-options] Input File
Options:-E: Change the default file suffix.
-Ea [.] asmext ASM-> asmtxt
-EC [.] cext C-> ctxt
-Eh [.] Hext H-> htxt
-EP [.] cppext CPP/CC/cxx-> ptxt
-Fs specifies the output file directory. For example,-FS c:/absdir
-Q: No prompt message is displayed.
Input File. Out File
Example: abs2000-ea S-ec csr-eh HSR hello. output file hello. S (hello. ASM), hello. CSR (hello. c), hello. HSR (hello. h ).
DSP Summary 3-C language environment 2
1. Create a user Library:
1> doscommand: use commands such as the archive AR2000 command and Assembly compilation connection to create a file manually.
2> Create CCS directly. When creating a project dialog box in CCS, you can select the option to create a lib file. You can directly integrate files such as ASM and C in the project to generate a library file (excluding the CMD file ).
2. Overview of CCS
DSP chip development tools can be divided into two categories:
Code Generation Tool:
Code debugging tools: C/assembly language source code debugger, DSK for beginners, simulator, EVM for evaluation modules, SWDS for software development systems, and xds for simulators.

3. C Compiler Optimization:
1> there are two types of C Compiler Optimization:
General Optimization of C language: Simplified expressions, data stream optimization, deletion of common subexpressions and redundant allocation, optimized redirection, simplified control flow, and optimized cycle-related variables, move the expressions with the same calculated values in the loop body to the loop body and run the row extension that supports library functions.
Optimization based on the DSP chip: efficient use of registers, automatic incremental register addressing, block duplication, parallel instructions, and latency redirection.
2> Optimization Options of CCS:

4. Use of the gel language:
General extension language (general extension language) is an explanatory language similar to C. It can create gel functions to extend the usage of CCS.
Gel is a subset of C language, but it cannot declare host variables. All variables must be defined in the DSP program and exist in the simulation/Actual Target Board, the unique identifier that is not defined on the target board is the gel function and its parameters.
The gel function can be called in any place where a c expression can be typed. It can be called in any dialog box where a c expression can be typed, or in other gel functions. Recursion is not supported.
You can add common gel functions to the CCS gel menu. In this case, you need to use the menuitem keyword to create a new drop-down menu list (level-1 menu) under the gel menu, and then use hotmenu, dialog and slider Add a new menu item (level-2 menu) to this menu item ).
When CCS is started, the gel function is automatically executed. The Automatic Execution of the gel function is set when the environment is set during setup of CCS. Automatically run the startup () function. This requires that the gel file be loaded when each project is created.
CCS provides a series of built-in gel functions. With these functions, you can control the status of the simulation/Actual Target Board, access the memory, and display the results in the output window.

5. Application of probe point
Probe point only temporarily interrupts program running, updates the window connected to it, and then automatically runs the program. The window connected to it can be set in probe point settings, and then replace.
You can use probe point to import data from a PC file or store data to a PC file. You can only use two formats for PC files: coff program files (. out); CCS data file (. dat ).
The probe point and break point can be used together to display graphics and animations. View-> graph-> time/frequency is used to display the graph. the pop-up dialog box is set to display a piece of memory data. You can use probe point to send data on the PC to the target board, then run the program. Then, you can create a breakpoint to automatically update the graph window. Use the animate command to automatically update the window after the breakpoint is reached.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.