3121 views|0 replies

2015

Posts

0

Resources
The OP
 

Introducing the nonlinear operation table lookup method [Copy link]

. In real-time DSP applications, the table lookup method is generally used to appropriately reduce the calculation accuracy to improve the calculation speed of the program. The table lookup method is the most commonly used method to quickly implement nonlinear operations. When using this method, a table must be made according to the range and accuracy requirements of the independent variable. Obviously, the larger the input range and the higher the accuracy requirements, the larger the table required, that is, the larger the storage capacity. The calculation required for the table lookup method is to determine the address of the table according to the input value, and the corresponding value can be obtained according to the address, so the amount of calculation is small. The table lookup method is more suitable for the two cases where the nonlinear function is a periodic function or the input value range of the nonlinear function is known. Examples 1.12 and 1.13 illustrate these two cases respectively. Example 1.12 Given the sine function y=cos(x), make a 512-point table and explain the table lookup method. Since the sine function is a periodic function and the function value is between -1 and +1, the table lookup method is more appropriate. Since the range of Q15 is between 1 and 32767/32768, in principle, the range from -1 to +1 must be represented by Q14. However, for convenience and overall accuracy, similar situations are still represented by Q15, and +1 is represented by 32767. (1) The C language program that generates 512 point values is as follows. #define N 512 #define pi 3.14159 int sin_tab[512]; void main() { int i; for(i=0;i<N;i++)sin_tab=(int)(32767*sin(2*pi*i/N)); Copy code (2) Table lookup Table lookup is actually to determine the address of the table based on the input value. Assume that the input x is between 0 and 2π, then the address of the 512-point table corresponding to x is: index=(int)(512*x/2π), then y=sin(x)=sin_tab[index] If x is represented by Q12 fixed-point numbers, 512/2π is represented by Q8 as 20861, then the formula for calculating the address of the sine table is. index=(x*20861L)>>20; Copy code Example 1.12 Use the table lookup method to calculate the logarithm with base 2. The range of the independent variable value is known to be 0.5-1, and the independent variable range is required to be evenly divided into 10 equal parts. Try to make this table and explain the table lookup method. (1) Make a table: y=log2(x). Since x is between 0.5 and 1, y is between -1 and 0. Both x and y can be represented by Q15. Since x is evenly divided into 10 segments, the range of the 10 segments corresponding to the input x is shown in Table 3.2. If the logarithmic value of each segment is the logarithmic value of the first point, then the logarithmic value of the first segment in the table is y0(Q15)=(int)(log(0.5)*32768), the logarithmic value of the second segment is y1(Q15)=(int)(log2(0.55)*32768), and so on, as shown in Table 3.2. (2) Table lookup: When looking up a table, first calculate the address of the table based on the input value. The calculation method is: index=((x-16384)*20)>>15; Copy code In the formula, index is the address used for table lookup. For example, given the input x=26869, then index=6, so y= -10549. Table 1.2 logtab0 10-point logarithmic table address input value logarithmic value (Q15) 0 0.50-0.55 -32768 1 0.55-0.60 -28262 2 0.60-0.65 -24149 3 0.65-0.70 -20365 4 0.70-0.75 -16862 5 0.75-0.80 -13600 6 0.80-0.85 -10549 7 0.85-0.90 -7683 8 0.90-0.95 -4981 9 0.95-1.00 -2425

This post is from DSP and ARM Processors
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list