Http://www.cnblogs.com/scncart/articles/1805553.html

Comparison between fixed-point DSP and floating-point DSP

It may be helpful for entry-level DSP developers. This article focuses on the comparison between a fixed-point DSP and a floating-point DSP, mainly from three aspects. Thank you for your reference.

In general, the fixed-point DSP processor features fast speed, low power consumption, and low price. The floating-point DSP processor provides precise computing, large dynamic range, fast speed, easy programming, and high power consumption, high price.

**1. Macro differences**

From a macro perspective, the floating-point DSP has a much larger dynamic range than the fixed-point DSP. In fixed-point operations, the programmer must always pay attention to overflow. To prevent overflow, either shift calibration or tail truncation is performed continuously. The former consumes a lot of time and space, while the latter results in a loss of precision. On the contrary, the floating point operation DSP expands the dynamic range, improves accuracy, and saves operation time and storage space, because it greatly reduces calibration, shift, and overflow checks.

**For example**(From http://blog.sina.com.cn/s/blog_518dfe5b0100e17w.html)

The fixed-point calculation only processes a data as an integer. Generally, AD samples all the integers. This number has a scale factor relative to the real analog signal, as we all know, if a 16-bit ad is used to sample a signal from 0 to 5 V, the corresponding voltage is obtained by dividing the integer of the ad output by 2 ^ 16 and then multiplied by 5 V. In a fixed-point DSP, the 16-bit sampling is processed directly, instead of converting it into a voltage in decimal places, because the fixed-point DSP cannot represent a decimal point with sufficient precision, it can only calculate integers.

The advantage of floating-point DSP is that it can convert the integer obtained from the sampling to the voltage expressed in decimal places without losing precision (this decimal point is expressed in scientific Notation ), the reason is that the scientific notation can indicate a signal with a large dynamic range. Take the ieee754 floating point number as an example,

Single-precision floating point format: [31] 1-Digit Symbol [30-23] 8-digit index [22-00] 23-digit decimal

The minimum number that can be expressed is +-2 ^-149, and the maximum number is +-(2-2 ^ 23) * 2 ^ 127. (Here we will not study how this minimum and maximum range is calculated.) the dynamic range is 20 * log (Maximum/minimum) = a large dynamic range such as 1667.6db makes it almost unnecessary for us to consider multiplication and accumulation overflow during programming. If we use a fixed-point processor for programming, it is common to round and shift the calculation results, which may result in loss of precision to a certain extent. The reason is that the dynamic range of the signal processed by the fixed point processing is limited. For example, a 16-Bit fixed point DSP can indicate that the Integer Range is 1-65536, and its dynamic range is 20 * log (65536/1) = 96db. for 32-point DSPs, the dynamic range is 20 * log (2 ^ 32/1) = 192db, far smaller than the 32-bit IEEE floating point number 1667.6db. However, in fact, 192db is sufficient for the signals processed by most applications.

Due to the limitation of the number of digits of the AD converter, the dynamic range of the input signal is generally relatively small. However, in the signal processing of the DSP, the dynamic range of the signal of the intermediate node is increased due to the dot product operation, therefore, the DSP is selected based on the dynamic range of intermediate results in the signal processing process and the accuracy requirements of the algorithm for intermediate results.

**2. Hardware**

Aside from the comparison of these macro features, from a technical perspective, the difference between the fixed point and the floating point mainly lies in two aspects: hardware and software. The hardware difference is that the floating-point DSP processor has a floating-point/Integer multiplier, an integer/floating-point Arithmetic Logic Operation Unit ALU, and is suitable for storing registers with Extended Floating-point results.

**3. Software**

Let's look at the differences in software development, mainly including the characteristics and precautions of floating point DSP programming; the calibration, shift, and overflow detection operations of fixed point DSP for floating point operations. When comparing two floating point numbers, never use the operator = to determine if they are equal. Even if two identical numbers are compared, there may be slight rounding differences. Even defining accurate 0 is not very safe. Although the C language has 0, never write such code (x = 0), instead of writing it (FABS (X) <tiny), where tiny is defined as a small value, that is, the floating point format rounding error of the processor. (To be continued ~~)

**4. Application Example (**From http://www.embedcity.com/article.php? Id = 235**)**

Another important difference lies in the choice of fixed point and floating point DSP processors in application scenarios. Designers care about the final system performance, cost, and time to market.

**(1) mobile TV**

This is another easy-to-decide option. There is no need for floating point processing in mobile TV. Most signal chain processing is performed in standard decoder, such as MPEG-2, MPEG-4, JPEG-2000 and H.264. These algorithms are designed to be executed by fixed-point operations. Floating point operations with higher precision and greater dynamic ranges are not only useless, but cannot be used at all, because these algorithms are usually only accurate to bits. For example, the frequency-domain transformation used in video codecs is actually a form of DCT transformation (discrete cosine transformation ). On the surface, it seems that floating point operations are more suitable for DCT computing, just like fft computing. Floating point operations produce more precise DCT. Unfortunately, the DCT in the video decoder is designed on a fixed-point processor and only accurate to bits. Therefore, it is totally wrong to pursue a higher precision here. What's more, most of the work of video codecs is used to control code, and there is no need for floating-point encoding. For example, the entropy encoder used in video codecs accounts for a large part of the total workload (especially the cabac encoder used in H.264 algorithms ). The two processors mentioned here can clearly make the right choice based on the following facts, that is, the Blackfin Processor has a specially designed command to accelerate the performance of video algorithms. Instead, the sharc processor does not have special video commands. In addition, power consumption is crucial for the mobile market, which almost removes the floating point processor. These make selection easy. However, for other application instances, we need to perform more in-depth analysis to make the correct processor selection.

**(2) military radar**We 'd better start with an easy choice. You often use floating point processors in military radar. Why? In this application, floating point performance is indispensable. Radar relies on the determination of the maximum absolute value of the Self-fuzzy function. This function expresses the mutual correlation between the sent test signal and the received echo. This is the point of an exponential function. Such credits can be computed using FFT technology. Floating-point computation is very useful when computing large-scale FFT, and there is no obstacle to using a floating-point processor here. As long as the heat can be discharged (that is, the processor is not hot), power is not a big problem. The cost of the device is not a major problem, because these processor costs are only a small part of the overall system cost. In fact, it is generally not the case that the ADSP-21367 sharc is selected to do this, because one goal of the application is to provide as much processing capability as possible per square millimeter. Therefore, high-performance ADSP-TS201 in Adi's tigersharc series products will be more suitable for this application.

We hope that the comparison between the fixed-point DSP and floating-point DSP can help beginners establish a global perceptual knowledge.