CN-121979482-A - High-precision calculation method and device for normalized arctangent function
Abstract
The invention discloses a high-precision computing method and a device for a normalized arctangent function, wherein the method comprises the steps of S1, decomposing and preprocessing input floating point data, obtaining symbols, step codes and mantissas of the input floating point data through data transformation, comparing the step codes with single-precision offset codes to obtain displacement codes, obtaining input data for second-order polynomial computing by utilizing the displacement codes, S2, simplifying a computing interval by utilizing odd function characteristics, S3, segmenting an effective interval in a layering manner and selecting polynomial coefficients, S4, carrying out parallel computing on a second-order polynomial and a fifth-order Taylor dual-path, S5, formatting a result, and S6, dynamically selecting and outputting. The apparatus is for performing the above method. The invention has the advantages of high precision, low delay, small area, low cost and the like.
Inventors
- PENG HAO
- LUO BO
- SUN SHUWEI
- ZHOU HUILI
- CHEN SHENGGANG
Assignees
- 湖南芯弘道信息科技有限责任公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260409
Claims (10)
- 1. A high-precision computing method for a normalized arctangent function, comprising: Step S1, decomposing and preprocessing input floating point data, obtaining a sign, a step code and a mantissa of the input floating point data through data transformation, and comparing the step code with a single-precision offset code to obtain a shifting code for shifting the mantissa part; step S2, simplifying a calculation interval by utilizing an odd function characteristic, carrying out normalization processing according to the odd function characteristic of the arctangent function, wherein only a [0,1] interval is considered in the implementation process, and the other half interval result is the same as the absolute value of the [0,1] interval result, and the difference is in a sign bit; step S3, layering and segmenting an effective interval and selecting polynomial coefficients; S4, performing parallel calculation on a second-order polynomial and a fifth-order Taylor dual-path; step S5, formatting the result; And S6, dynamically selecting and outputting.
- 2. The method for high-precision computation of a normalized arctangent function according to claim 1, the method is characterized in that the flow of the step S3 comprises the following steps: step 301, executing non-uniform hierarchical segmentation according to function characteristics in the interval [0,1 ]; Step S302, performing address decoding on the high order of the shifted initial data; step S303, determining the subinterval to which the data belongs; Step S304, reading from the coefficient lookup table according to the subinterval address: second order polynomial coefficients A0, A1, A2 A subinterval starting point reference value xi; step S305, outputting all parameters required by polynomial calculation.
- 3. The method according to claim 1 or 2, wherein the step S4 includes a path a including a second order polynomial approximation calculation and a path B including a fifth order taylor expansion calculation, and wherein the path a includes: Step A11, performing subtraction, namely x-xi; step A12, calculating a primary term A1 (x-xi); Step A13, calculating quadratic term A2 (x-xi)2; Step a14, summing to obtain a polynomial result of r1=a0+a1 (x-xi) +a2 (x-xi) 2; step A15, multiplexing the multiplier with the Taylor path hardware; path B includes: Step B11, calculating the sub-terms, namely x, x3/3 and x 5 /5; Step B12, adding and subtracting R < 2> = x-x 3/3+x 5 /5 according to a formula; step B13, performing normalization, namely R2X (1/2 pi); And step B14, obtaining a Taylor path normalization result.
- 4. The method for high-precision calculation of normalized arctangent function according to claim 3, wherein said step S5 comprises: Step S501, fixed point to floating point conversion, normalization and rounding of a second order polynomial result; Step S502, fixed point to floating point conversion, normalization and rounding of the five-order Taylor result; Step S503, two paths of the data are output in standard IEEE754 floating point number format; step S504, ensuring output precision and format uniformity.
- 5. The method for high-precision calculation of normalized arctangent function according to claim 3, wherein said step S6 comprises: step S601, judging according to the selection signal generated in the step S1; Step S602, selecting a second-order polynomial result in a medium-large data interval; step S603, selecting a fifth-order Taylor result in a small data interval; step S604, outputting a preset constant directly by a special value; and step S605, combining with the sign bit correction, and outputting a final normalized arctangent function value.
- 6. A high precision computing device for normalized arctangent functions, comprising: The data preprocessing unit is used for carrying out data preprocessing on the input floating point data to obtain symbols, indexes and mantissas of the input data, and carrying out data preparation processing on the obtained symbols, indexes and mantissas to obtain preparation data and related selection signals required by second-order polynomial calculation and fifth-order Taylor expansion; The second order polynomial computing unit is used for carrying out subinterval decoding processing on the data mapped to the interval [0,1 ] when carrying out second order polynomial path computation to obtain a corresponding subinterval, then generating a corresponding selection signal through the obtained subinterval, and obtaining the coefficient for carrying out the second order polynomial from the coefficient lookup table; The five-order Taylor expansion calculation unit is used for carrying out multiplication operation on the processed mantissa according to the five-order Taylor expansion form of arctan (x) when carrying out the five-order Taylor expansion path calculation to obtain three partial data of the five-order Taylor expansion, wherein the three partial data are X, X 3 /3、X 5 /5; the normalization processing unit is used for normalizing the obtained second-order polynomial and fifth-order Taylor expansion fixed-point format data; and the result selection unit is used for selecting floating point format data corresponding to a second-order polynomial, a fifth-order Taylor expansion or a constant term as a final logarithmic function result through a data selection signal obtained during preprocessing.
- 7. The device for high-precision calculation of normalized arctangent function according to claim 6, wherein the second order polynomial calculation unit shifts the mantissa and the first hidden spliced data by the judgment conditions of the step code and the offset code to obtain initial data of second order polynomial calculation, and simultaneously performs address decoding on a numerical upper part of the data to determine the position of the input data mapped to the subinterval in the [0,1] interval, and finds the corresponding coefficient from the coefficient lookup table by the position selection of the subinterval.
- 8. The apparatus of claim 7, wherein the second order polynomial computation unit comprises three multipliers, two adders and a subtractor, wherein the subtractor is configured to implement the x-xi logic, the three multipliers are configured to implement A1 (x-xi) and A2 (x-xi) 2 , and the two adders are configured to implement the addition of the three components.
- 9. The high-precision computing device for the normalized arctangent function according to claim 6, wherein the fifth-order taylor expansion computing unit obtains a selection signal for selecting a constant term or fifth-order taylor expansion by performing size judgment on the separated step code value and the first and second threshold values, and the initial data of the fifth-order taylor expansion is from a splice value of the separated mantissa portion and the first concealment.
- 10. The high-precision computing device for the normalized arctangent function according to claim 9, wherein the fifth-order taylor expansion computing unit comprises seven multipliers, an adder, a subtracter and a divider, wherein the first six multipliers are used for obtaining X 3 /3、X 5 /5, the subtracter is used for realizing X minus X 3 /3, the adder is used for realizing the value of X minus X 3 /3 plus X 5 /5, and the seventh multiplier is used for realizing the normalization operation of the arctangent function, namely normalized_atan (X) =arctan (X)/(2pi), so as to obtain the normalized fixed point result of the arctangent function taylor expansion.
Description
High-precision calculation method and device for normalized arctangent function Technical Field The invention mainly relates to the field of processors, in particular to a high-precision calculation method and device aiming at a normalized arctangent function. Background The conventional arctan function arctan (x) has the following basic features: the definition field is (- +++ - +++), any real number input can be accepted; the range is (-pi/2, pi/2), and the output range is about (-1.5708, 1.5708) radians. Normalized arctangent function is transformed by normalizing the output range of the arctangent function to the interval of [ -1/8, 1/8] by normalized_atan (x) =arctan (x)/(2pi) while the input x belongs to the interval of [ -1,1], which is a very important application transform in motor control systems and digital communication systems. Even though overflow risk of large-value calculation and capacity design of a lookup table are greatly reduced through normalization transformation and input data interval compression, most of the current implementation methods of the arc tangent function normalization are difficult to meet the requirements of precision and efficiency. The main methods for realizing the arctangent function include polynomial approximation, coordinate rotation (CORDIC), table lookup, etc., but all have the technical problem that the calculation accuracy and the calculation efficiency are difficult to balance. The polynomial approximation method adopts the same order in the whole definition domain, and has simple structure, but cannot be optimally configured according to the characteristic of the arctangent function, so that the calculation precision of a specific interval is ensured. In the coordinate rotation method, if the accuracy requirement is higher, the iteration times are more, and the hardware cost and the time delay are increased. The high-precision table lookup requires huge storage space, which increases the design cost of hardware. The arc tangent function of normalization processing is converted into hardware implementation, and the problem that the calculation accuracy and efficiency are required to be balanced in the conventional arc tangent function implementation process is also faced. From the above analysis, the conventional approach still has the following disadvantages: 1. The polynomial approximation method is that the global same-order number cannot be optimized according to the function characteristics, and the precision of a specific interval is insufficient; 2. The CORDIC coordinate rotation method has the advantages that the higher the precision is, the more the iteration times are, the high hardware cost is high, and the time delay is high; 3. The high-precision table look-up method needs huge storage and has high hardware cost. That is, when the hardware implements the normalized arctangent function, the calculation accuracy, the calculation efficiency and the hardware cost cannot be simultaneously considered. Disclosure of Invention The technical problem to be solved by the invention is to provide the high-precision calculation method and the device for the normalized arctangent function, which are high in precision, low in time delay, small in area and low in cost. In order to solve the technical problems, the invention adopts the following technical scheme: a high-precision computing method for a normalized arctangent function, comprising: Step S1, decomposing and preprocessing input floating point data, obtaining a sign, a step code and a mantissa of the input floating point data through data transformation, and comparing the step code with a single-precision offset code to obtain a shifting code for shifting the mantissa part; step S2, simplifying a calculation interval by utilizing an odd function characteristic, carrying out normalization processing according to the odd function characteristic of the arctangent function, wherein only a [0,1] interval is considered in the implementation process, and the other half interval result is the same as the absolute value of the [0,1] interval result, and the difference is in a sign bit; step S3, layering and segmenting an effective interval and selecting polynomial coefficients; S4, performing parallel calculation on a second-order polynomial and a fifth-order Taylor dual-path; step S5, formatting the result; And S6, dynamically selecting and outputting. As a further improvement of the method of the invention, the flow of the step S3 comprises the following steps: step 301, executing non-uniform hierarchical segmentation according to function characteristics in the interval [0,1 ]; Step S302, performing address decoding on the high order of the shifted initial data; step S303, determining the subinterval to which the data belongs; Step S304, reading from the coefficient lookup table according to the subinterval address: second order polynomial coefficients A0, A1, A2 A subinterval starting point reference value