Discussion on How to Learn DSP Software Development

Source: Internet
Author: User

Address: http://www.analogcn.com/Article/wz3/201112/20111207164354.html

 

1. Find out the source and familiar manual of DSP-related resources

Generally, this is mainly from the official website of DSP chip manufacturers. Although the current DSP chip manufacturers provide Chinese official websites, I suggest you use an English website, some resources are not available on Chinese websites (for this reason, I personally think that resources on the Chinese side are not uploaded in time ),

 

Second, there are very few Chinese versions of general information. The Chinese and English versions are actually downloaded in the same version. Then, you must be familiar with the official website of DSP chip manufacturers, full use of official resources and support during development can greatly improve development efficiency;

 

At last, it should be noted that generally, the DSP chip manufacturers will open a technical exchange forum where administrators are generally the development engineers of DSP chip manufacturers and can obtain their technical support in the form of posts.

Another source of resources is a third-party company (domestic) that has cooperation with DSP chip manufacturers. Such companies have good contact with DSP chip manufacturers, generally related DSP chips, they will first make the Education Development Board, which is mainly used for teaching, so they will have relevant Chinese materials and corresponding demo programs. Based on this, they can learn from their experiences and their materials and procedures. Secondly, they will sell self-made simulators, which are cheaper than the original manufacturer, there is certainly no comprehensive simulator sold by the original manufacturer, but it is sufficient for basic project development.

The third part is for reference only. Ti and Adi, the two largest DSP manufacturers in the Chinese market, offer corresponding DSP training courses in China, but they are expensive, generally, companies send documents to learn.

Resources mainly include:

Datasheet (

The Data Manual describes the functions, internal structures, peripherals, software, and hardware of the DSP chip. The main function is to quickly understand the DSP)

Software tool manuals

(This manual mainly introduces the usage and precautions of DSP clock, memory, power management, and all peripherals. It is actually the register configuration, which can be called the DSP user manual)

Hardware tool manuals (

This manual is mainly for drawing the principle PCB provided by the official Team)

Program manuals (

This manual mainly introduces the use of compilers and built-in C libraries, the use of Assembly commands and Assembly syntax, and the use of simulation software officially provided)

Engineer to engineer note, reading engineer notes is the most appropriate)

Program examples (mainly for DSP peripherals, officially provided program examples, including C and Assembly)

2. Use of official simulation software and Simulators (if not used, you can skip it temporarily because some DSPs can be developed based on open-source operating systems, such as uClinux)

The method of using simulation software is actually very simple. Generally, this software is designed to be similar to VC. You try the options under each menu one by one. At this time, if you use it with examples, you can better understand it, however, I suggest that you develop DSP software first.

Datasheet,

Software tool manuals

Program manuals

These three documents start to be familiar with the use of simulation software. Of course, when you are familiar with these documents, you must keep reading them. There is no need to pay attention to the use of the simulator. Generally, the simulators are all done in a similar way, so there is no reverse insertion. Generally, the simulators are used together with the simulation software. (One thing to note is that DSP development is generally based on the C language. If you do not know the C language, please first learn the C language)

  Iii. DSP Minimum System Configuration

This part officially began to use DSP. The minimum system mainly refers to the DSP clock and memory system. At this time, you need to carefully read the introduction and the configuration of related registers against the software tool manualsh, combined with examples and engineer to engineer note, if the test clock is very simple after the program is written, you can use an oscilloscope to directly measure the clock to see if it is the number you configured, the next step is to test the memory. This test must write a simple small program. In fact, it is mainly to test whether the data bus works normally. If there is a problem when configuring the minimum system, there are two common problems, first, the register is incorrectly configured. The solution is to combine examples and engineer
To engineer note, read the manual carefully and check the routine. Second, there may be a problem with the hardware line on the Development Board. The solution is to combine the schematic diagram to check whether there is a short circuit problem on the line, whether the DSP operating voltage is normal or not, this step can be checked with the hardware engineer.

Iv. Use of DSP peripherals

In fact, this part is the same as the configuration of the smallest system, but some peripherals may be connected to other chips. Different functions are connected to different chips. At this time, you need to look at the information of these chips, then, write the code and test it again. The test method varies according to different functions. However, the most common method for DSP development is to use an oscilloscope. for audio and video, you can use a camera, display Screen, etc. For example, if there is a problem with intermediate development, the method is the same,

In combination with examples and engineer to engineer note, read the manual carefully and read the routine. Pay attention to the following points: do not doubt that the Manual cannot be implemented. You must have confidence in yourself.

V. DSP Optimization

In fact, at this step, you can use DSP completely. Next, you need to familiarize yourself with the entire internal structure of DSP, including the number of MAC addresses, there are several bit ALU, several BIT data registers, and so on, and what peripherals are connected on the external data bus, and how the internal data bus is connected, and how many bits are the data bus? In datasheet, there will be a clear Dsp Structure, what is the overall memory map of the DSP, and how many data memory files are on the chip, how many program memory are there and so on. Understanding this is actually to let you know what the DSP's computing performance can reach and what peripherals will transmit data through the external data bus, how the internal registers of the DSP transmit data can help you solve the problems you encounter during development, but the most important thing is to help you optimize the code that has been compiled, I personally think there are several optimization methods:

1. Generally, the first method to write code is to use C, which is based on the C-level optimization method. I will give several examples as follows:

(1) optimization cycle

For (I = 0; I <Max; I ++)

{

For (j = 0; j <Max; j ++)

{

Float sum = 0.0;

For (k = 0; k <Max; k ++)

{

Sum + = input [I * MAX + k] * input [J * MAX + k];

}

Cover [I * MAX + J] = sum/max;

}

}

For example, input [16] = {1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16:

7 17 27 37
17 43 69 95
27 69 111 153
37 95 153 211

Figure:

Principle: you only need to get the upper left or upper right corner, and then assign a half matrix to the other half to get the entire matrix.

After algorithm optimization:

For (I = 0; I <Max; I ++)

{

For (j = I; j <Max; j ++) // reduce the cycle by half

{

Float sum = 0.0;

For (k = 0; k <Max; k ++)

{

Sum + = input [I * MAX + k] * input [J * MAX + k];

}

Cover [I * MAX + J] = sum/max;

If (I! = J) // add or remove duplicates on the online.

{

Cover [J * MAX + I] = sum/max; // assign a value to the other half Matrix

}

}

}

(2) conditional jump (using conditional jump will waste more cycles in the pipeline)
K = k-1;

If (k <-1)

{

K =-1;

}

Principle: The Max function in C language is actually implemented by the Max command in DSP during compilation.

After optimization:

K = max (K-1,-1 );

After being converted to assembly:

R0 + =-1; // R0 = K;

R1 =-1;

R0 = max (r0, R1 );

(3) conditional jump in the For Loop

For

{

If {...} else {...}

}

Principle: reduce frequent conditional jumps. Of course not all situations can do this.

After optimization:

If

{

For {...}

}

Else

{

For {...}

}

(4) use assertion commands to avoid conditional jump

If ()

{

X = exp1;

}

Else

{

X = exp2;

}

Principle: using the assertion command if (CC) reg = reg consumes only one cycle.

After optimization:

X = exp1;

If (! A)

{

X = exp2;

}

(5) Division (modulo operation)

Generally, DSPs do not support division. Division operations are implemented by means of simulation. There are two types, namely low precision and high precision, but they all require a majority of cycles.

You can use the right shift method when the Division is 2 to the power of N.

For example, to improve performance, you can use a look-up table, which will result in loss of precision.

Hidden Division:

For (I = start; I <finish; I + = step)

At this time, the compiler will obtain the number of times logoff = (finish-Start)/step.

Clever Use of the inequality method for testing: (however, overflow may occur. Be careful when using this method)

If (x/y> A/B)

Convertible:

If (x * B> A * Y)

(6) Data Types

For fixed-point DSPs, floating-point operations are simulated and consume many cycles. Therefore, fixed-point DSPs generally perform fixed-point processing on floating-point DSPs, an example of a common method is as follows: 2.5 * A can be converted to 80 * A> 5, but you need to pay attention to anti-overflow when setting a point.

64-bit data is also simulated, which consumes many cycles. (Generally, only 32-bit data is supported)

It is appropriate to perform operations such as FFT and 16bit in digital signal processing.

For the control class, 32-bit operations are suitable for condition jump.

For example, if your DSP Mac is 16 bits, define 16 bits of data as much as possible during multiplication.

(7) Memory Allocation

Place frequently-computed data and program segments into the memory in the disk to enable the cache.

For example, if the DSP can access four different banks of SDRAM at the same time, you can put the data that needs to be computed at the same time into different banks.

(8) enable compilation Optimization Options for Simulation Software

You can check the corresponding menu items. However, enabling the automatic compilation optimization option may change the execution result, therefore, we need to test and compare the execution results before the compilation optimization option is enabled. In general, this is convenient and commonly used.

The above eight optimization methods are commonly used. Of course, there are many optimization methods based on the C-level algorithm class. This needs to be accumulated slowly. To sum up, in general, we first optimize the structure of the C layer (1-6 above), then conduct memory allocation, enable the compilation and optimization options of the simulation software, and implement the program segments with frequent operations by means of assembly, of course, if the performance meets the requirements, there is no need to use the assembly.

Vi. Summary

I think there is no shortcut to learning DSP software development. I spent a lot of text on "Understanding the sources of DSP-related resources and reading the manual". In fact, I want to say, it is critical to know how to obtain resources. Only when you are familiar with the manual can you fully use the DSP chip you want to develop. Secondly, the main feature of the DSP is high performance. You can perform some algorithm operations, therefore, DSP optimization is very important. There are many algorithm optimization methods, which can be basically divided into optimization on the C structure and optimization using the characteristics of DSP, optimization learning is easy to accumulate, so you have to look at the relevant information.

The procedure for getting started is as follows:

Prepare a Development Board, familiarize yourself with the manual and simulation software, check the manual against the routine, and then change the routine to see if it can be implemented as you wish. The minimum system and each peripheral are familiar with each other, congratulations! You are getting started...

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.