High-precision floating point trigonometric function operation device and method
By fitting trigonometric functions in quadratic polynomial segments, the problems of many iterations and limited accuracy in high-precision calculations are solved, and efficient and fast trigonometric function calculations are realized, which improves the performance of the processor chip.
Patent Information
- Application Number
- CN202411822741.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-01-10
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The CORDIC algorithm has problems such as many iterations, slow calculation speed, limited accuracy and high hardware complexity in high-precision trigonometric function calculations, which are difficult to meet the needs of modern high-performance computing.
The quadratic polynomial segment fitting trigonometric function is used to efficiently calculate through floating point preprocessing, fixed-pointing, segment fitting coefficient table, multiplication and addition modules, which avoids the time and area cost of traditional CORDIC algorithms and improves the calculation accuracy. and speed.
It realizes high-precision and fast trigonometric function calculations, reduces hardware complexity and design costs, and improves the overall performance of the processor chip.
Smart Images

Figure CN119292559A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of floating point number calculation, and in particular to a high-precision floating point trigonometric function calculation device and method. Background Art
[0002] Floating-point operations have always been the focus of processor chip computing module design. In recent years, with the continuous development of scientific computing, graphics processing and machine learning, the requirements for the performance of computing platform processor chips have also continued to increase. The optimization of the floating-point unit (FPU) inside the processor is the key to improving the overall chip performance. The IEEE 754 standard is currently the most widely used floating-point standard, which specifies the format, rounding rules, exception handling and arithmetic operations of floating-point numbers, which provides a consistent and reliable framework for mathematical operations in processor chip design.
[0003] Trigonometric functions are an important class of functions, including sin, cos and arctan functions, which are widely used in the calculation of complex algorithms. However, due to their nonlinear characteristics and computational complexity, they are difficult to implement directly through basic operations, which poses certain challenges to chip design and implementation. By integrating a dedicated trigonometric function calculation unit into the processor chip, computing efficiency can be significantly improved, latency can be reduced, and power consumption can be reduced, thus meeting the needs of modern high-performance computing.
[0004] The Coordinate Rotation Digital Computer (CORDIC) algorithm is widely used in processor chip design to calculate trigonometric functions. Its core advantage is that it can calculate function values through iterative displacement and addition operations, avoiding the use of multiplication or division operations that occupy large areas and consume high power. In addition, CORDIC is suitable for accelerating calculations through pipelines and parallel processing, so it is often used in the design of high-performance processors and digital signal processors to support real-time trigonometric function calculation needs.
[0005] Although the CORDIC algorithm has many advantages in processor chip design, it also has some disadvantages and limitations, which will affect its use effect in some application scenarios. First, the CORDIC algorithm is essentially an iterative algorithm. The accuracy of the calculation result depends on the number of iterations. For high-precision calculations, more iterations are required. Therefore, in high-precision design implementation, the convergence speed may be slow, resulting in increased operation delay. Secondly, the CORDIC algorithm approximates the trigonometric function value based on the method of gradually rotating the vector. In order to avoid complex multiplication and division operations, it is replaced by a series of displacements and additions. Although this makes the hardware implementation simple, it can only provide limited accuracy, and more iterations have to be used to reduce the error. Finally, in order to adapt to different trigonometric function calculation requirements, multiple CORDIC modules may need to be implemented in the hardware design or complex control may be required, which increases the hardware complexity and design cost during chip design. Summary of the invention
[0006] To solve the above technical problems, the present invention provides a high-precision floating-point trigonometric function operation device and method, which uses quadratic polynomials to piecewise fit trigonometric functions and use quadratic polynomials to approximate the values of trigonometric functions, thereby avoiding the time and area costs of traditional designs using CORDIC. At the same time, it can more accurately approximate the true values of trigonometric functions, and optimize the calculation speed, calculation accuracy and resource occupancy of trigonometric functions in the processor chip design implementation.
[0007] To achieve the above object, the technical solution of the present invention is as follows: A high-precision floating-point trigonometric function operation device comprises a floating-point number preprocessing module, a fixed-point module, a piecewise fitting coefficient table, a temporary index module, a multiplication module 1, a multiplication module 2, a shift module 1, a shift module 2, an addition module 1, an addition module 2, a special processing module and a floating-point module; The input of the floating-point number preprocessing module is the floating-point number x and the trigonometric function selection signal. The module filters illegal inputs and special values that do not require operation in the input according to the trigonometric function selection signal, and sends the special values to the special processing module, which determines the type of the special value and directly outputs the corresponding function value; if the input is a non-special value, it is sent to the fixed-point module; The function of the fixed-point conversion module is to convert the floating-point number x to a fixed-point number, send the converted fixed-point number to the segmented fitting coefficient table, the multiplication module 1 and the multiplication module 2, and send the converted temporary index to the temporary index module for storage; The segmented fitting coefficient table stores the enlarged polynomial coefficients a, b, c obtained by fitting the sin, cos and arctan functions, for use by multiplication module 1, addition module 1 and addition module 2; The multiplication module 1 performs the operation of multiplying the coefficient a by x, and sends the fixed-point product operation result ax to the shift module 1; The shift module 1 shifts ax right or left by a specified number of bits so that it maintains the same magnification as b, and sends the result to the addition module 1; The addition module 1 performs the operation of adding ax and b, and sends the operation result to the multiplication module 2; The multiplication module 2 performs the operation of multiplying (ax+b) by x, and the structure of the multiplication module 2 is the same as that of the multiplication module 1, and the obtained result is sent to the shift module 2; The shift module 2 shifts the result (ax+b)x right or left by a specified number of bits to keep the same magnification as c, and sends the result to the addition module 2; The addition module 2 performs the operation of ((ax)+b)x+c, and the result is sent to the floating point module; The floating point conversion module is used to convert an integer number into a floating point number and then output a floating point number y.
[0008] In the above scheme, the illegal input is all values that are not in the domain of the function. For the sin and cos functions, special values include 0, integer multiples of ±0.25, and values exceeding 2^23. In this case, the function value is ±1 or 0.
[0009] In the above scheme, in the fixed-point conversion module, the floating-point number conversion process first determines the bit width of the target fixed-point format, then maps the sign bit of the floating-point number to the sign bit of the fixed-point number, and then scales the decimal part by left or right shift operations according to the exponent value of the floating-point number so that the data conforms to the fixed-point representation accuracy.
[0010] In the above scheme, in the fixed-point module, when calculating the sin and cos functions, there is the following processing flow: (1) If the exponent is less than 125, the input is between 0 and 0.25, and the decimal part is output directly; (2) If the exponent is 125, the input is between 0.25 and 0.5, the decimal part is inverted, added 1 and output; (3) If the exponent is 126, the input is between 0.5 and 1. Determine the highest bit of the decimal part: if the highest bit of the decimal part is 1, the input is between 0.75 and 1, set the highest bit of the decimal part to 0, invert the remaining part, add 1, and output; if the highest bit of the decimal part is 0, the input is between 0.5 and 0.75, and output the decimal part directly; (4) If the exponent is greater than 126, the input is greater than 1. The difference between the left-shifted exponent and 126 is used to determine the first and second digits of the left-shifted decimal part: if it is 00, the output value corresponds to between 0 and 0.25, and the decimal part is directly output; if it is 01, the output value corresponds to between 0.25 and 0.5, the decimal part is inverted, added by 1, and output; if it is 10, the output value corresponds to between 0.5 and 0.75, and the decimal part is directly output; if it is 11, the output value corresponds to between 0.75 and 1, the decimal part is inverted, added by 1, and output; (5) The difference between the index and 126 is recorded as the temporary index and sent to the temporary index module.
[0011] In the above scheme, the polynomial coefficients stored in the piecewise fitting coefficient table are the polynomial coefficients obtained by fitting using the C / C++ language mathematical function library, which are magnified by a specified multiple and then fixed-pointed.
[0012] In the above scheme, a 32-bit×32-bit multiplier designed with Booth coding and Wallace tree is used in the multiplication module 1, and a 64-bit fixed-point result is obtained after the multiplication operation.
[0013] In the above scheme, the number of bits shifted right or left in the shift module 1 is: the sum of the temporary index output by the temporary index module and the magnification of coefficient a minus the difference of the magnification of coefficient b.
[0014] In the above solution, the number of bits shifted right or left in the second shift module is: the sum of the temporary index output by the temporary index module and the magnification of coefficient b minus the difference of the magnification of coefficient c.
[0015] A high-precision floating-point trigonometric function calculation method, using the high-precision floating-point trigonometric function calculation device as described above, comprises the following steps: (1) The floating-point number x and the trigonometric function selection signal are input into the floating-point number preprocessing module. This module filters out illegal inputs and special values that do not require operation in the input according to the trigonometric function selection signal, and sends the special values to the special processing module. The special processing module determines the type of the special value and directly outputs the corresponding function value. If the input is not a special value, it is sent to the fixed-point module. (2) The fixed-point conversion module converts the floating-point number x to a fixed-point number, sends the converted fixed-point number to the piecewise fitting coefficient table, multiplication module 1 and multiplication module 2, and sends the converted temporary index to the temporary index module for storage; (3) Multiplication module 1 obtains the polynomial coefficient a from the piecewise fitting coefficient table, performs an operation of multiplying the coefficient a by x, and sends the fixed-point product operation result ax to shift module 1; (4) Shift module 1 obtains the temporary index from the temporary index module, shifts ax right or left by a specified number of bits to keep it the same magnification as b, and sends the result to addition module 1; (5) Addition module 1 obtains the polynomial coefficient b from the piecewise fitting coefficient table, performs the operation of ax plus b, and sends the operation result to multiplication module 2; (6) Multiplication module 2 performs the operation of multiplying (ax+b) by x, and the result is sent to shift module 2; (7) Shift module 2 obtains the temporary index from the temporary index module, right-shifts or left-shifts the result (ax+b)x by a specified number of bits to keep the same magnification as c, and sends the result to addition module 2; (8) Addition module 2 obtains the polynomial coefficient c from the piecewise fitting coefficient table and performs the operation ((ax)+b)x+c), and the result is sent to the floating point module; (9) The floating point module converts the integer number into a floating point number and outputs the floating point number y.
[0016] Through the above technical solution, the high-precision floating-point trigonometric function operation device and method provided by the present invention have the following beneficial effects: The present invention realizes the single-precision floating-point calculation of trigonometric functions in a simple and efficient manner. The operation device converts the input floating-point number into a fixed-point number after processing, searches for the corresponding coefficient through the segmented fitting coefficient table, and completes the efficient fixed-point calculation in the operation module. The temporary index module and the special processing module are used to ensure the accuracy and validity of the numerical value. The final result is restored to the floating-point format through the floating-point module, and the high-precision trigonometric function value is output. Compared with the trigonometric function calculation unit realized by the CORDIC algorithm, the calculation time is shortened, and it is more suitable for instantiation implementation in the processor chip design, thereby improving the overall system performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0018] Figure 1 A schematic diagram of the structure of a high-precision floating-point trigonometric function computing device disclosed in an embodiment of the present invention; Figure 2 This is the sine function accuracy test result; Figure 3 This is the cosine function accuracy test result; Figure 4 This is the result of the arctangent function accuracy test. DETAILED DESCRIPTION
[0019] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0020] In processor chip design, such as TI's C2000 extended instruction set, including SINPUF32, COSPUF32, ATANPUF32 and other instructions, the input of sin and cos instructions is the full real number range, while the arctan instruction retains the input range of [-1,1] The present invention is also designed according to this input range.
[0021] The functions are , and .
[0022] Trigonometric functions are fitted using quadratic polynomials, which is to obtain the approximate value of the function by calculating the result of a quadratic polynomial. Generally speaking, the fitting of quadratic polynomials is usually recorded as , but this requires three multiplications, which consumes more resources when implemented in hardware. Note that if the quadratic polynomial is expressed as , which can save one multiplication operation and is more conducive to design implementation. The coefficients a, b, and c in the quadratic polynomial are obtained by fitting the corresponding trigonometric function curve.
[0023] According to this method, the present invention provides a high-precision floating-point trigonometric function computing device, such as Figure 1 As shown, it includes a floating point preprocessing module, a fixed point module, a piecewise fitting coefficient table, a temporary index module, a multiplication module 1, a multiplication module 2, a shift module 1, a shift module 2, an addition module 1, an addition module 2, a special processing module and a floating point module. The overall input of the operation device is a floating point number x and a trigonometric function selection signal, and the overall output is a floating point number y.
[0024] The functions of each module are introduced below.
[0025] 1. Floating point preprocessing module The input of the floating-point number preprocessing module is the floating-point number x and the trigonometric function selection signal. The module filters illegal inputs and special values that do not need to be calculated in the input according to the trigonometric function selection signal. Illegal inputs include all values that are not in the function definition domain. For sin and cos, special values include 0, integer multiples of ±0.25, and values exceeding 2^23. The function value at this time is ±1 or 0. Special value processing is to prevent unnecessary errors from being introduced into the calculation process. When special value processing is required, it is sent to the special processing module to determine the special value type and output the corresponding function value. If the input is not a special value, it is sent to the fixed-point module.
[0026] 2. Fixed-point module The function of the fixed-point conversion module is to convert the floating-point number x to a fixed-point number, send the converted fixed-point number to the segmented fitting coefficient table, multiplication module 1 and multiplication module 2, and send the converted temporary index to the temporary index module for storage.
[0027] In the process of converting floating-point numbers to fixed-point, we first need to determine the bit width of the target fixed-point format. To ensure accurate conversion of floating-point numbers, this module selects the fixed-point bit width of x as 24 bits. The module maps the sign bit of the floating-point number to the sign bit of the fixed-point number, and then scales the decimal part by left or right shift operations according to the exponent value of the floating-point number so that the data conforms to the fixed-point representation accuracy. Due to the periodicity of the function, for the sin and cos functions, the absolute value of the value range is only between 0 and 1, so the fixed-point numbers involved in the calculation are also limited to between 0 and 0.25. The sin and cos functions can be calculated according to the following formula: ; ; When calculating the sin and cos functions, the following processing flow is used in combination with the above formula and the periodicity of the function: (1) If the exponent is less than 125, the input is between 0 and 0.25, and the decimal part is output directly; (2) If the exponent is 125, the input is between 0.25 and 0.5, the decimal part is inverted, added 1 and output; (3) If the exponent is 126, the input is between 0.5 and 1. Determine the highest bit of the decimal part: if the highest bit of the decimal part is 1, the input is between 0.75 and 1, set the highest bit of the decimal part to 0, invert the remaining part, add 1, and output; if the highest bit of the decimal part is 0, the input is between 0.5 and 0.75, and output the decimal part directly; (4) If the exponent is greater than 126, the input is greater than 1. The difference between the left-shifted exponent and 126 is used to determine the first and second digits of the left-shifted decimal part: if it is 00, the output value corresponds to between 0 and 0.25, and the decimal part is directly output; if it is 01, the output value corresponds to between 0.25 and 0.5, the decimal part is inverted, added by 1, and output; if it is 10, the output value corresponds to between 0.5 and 0.75, and the decimal part is directly output; if it is 11, the output value corresponds to between 0.75 and 1, the decimal part is inverted, added by 1, and output; (5) The difference between the index and 126 is recorded as a temporary index, which is sent to the temporary index module for storage and is subsequently used in shift modules 1 and 2.
[0028] The arctan function does not have periodicity. Its input is between 0 and 1, so the decimal part can be directly output.
[0029] 3. Segmented fitting coefficient table The segmented fitting coefficient table stores the enlarged polynomial coefficients a, b, c obtained by fitting the sin, cos and arctan functions, which are used by the multiplication module 1, the addition module 1 and the addition module 2.
[0030] The present invention performs polynomial coefficient fitting by using C / C++ language mathematical function library. The C++ program divides the domain of three trigonometric functions into 128 segments, a total of 384 segments, and independently performs quadratic fitting on each segment of the function curve to obtain 384 groups of coefficients, each group of coefficients including a, b and c. The coefficients obtained by the C++ program fitting are smaller floating-point numbers. In order to fully represent these smaller floating-point numbers and improve the calculation accuracy, it is necessary to first amplify the specified multiples and then fix them to cooperate with the fixed-point multiplication calculation. After multiple C++ program error experiments, a coefficient fixed-point scheme with the smallest error is selected, as shown in Table 1. After the original coefficient is amplified by the corresponding multiple, the decimal part is discarded, and the maximum number of fixed-point digits obtained will not exceed the reserved bit width, and the coefficients are subsequently input as multipliers into multiplication module one, addition module one and addition module two.
[0031] Table 1 Coefficient magnification and reserved bit width
[0032] The coefficients a, b, and c are stored in the module in the form of 3-segment ROM, and the depth of the 3-segment ROM is 384. The coefficients representing the sin curve are located in the first 128 addresses of the ROM, the coefficients representing the cos curve are located in the middle 128 addresses of the ROM, and the coefficients representing the arctan curve are located in the last 128 addresses of the ROM. Multiplication module 1, addition module 1, and addition module 2 can take out values from the ROM table of the corresponding coefficients according to the address for calculation.
[0033] 4. Multiplication module 1 The multiplication module 1 performs the operation of multiplying coefficient a by x. Since the multiplier is multiplexed by trigonometric functions, the multiplier width must meet the maximum requirement. Here, a 32-bit × 32-bit multiplier designed using Booth coding and Wallace tree is implemented. After the multiplication, the 64-bit fixed-point product operation result is sent to the shift module 1.
[0034] 5. Shift module 1 Because both a and x to be multiplied contain magnification factors, according to the nature of multiplication, they need to be restored before subsequent calculations. The function of shift module one is to divide the fixed-point product by the temporary exponent part and the fixed magnification factor contained in the coefficient, that is, to right-shift the input of shift module one by the same number of bits as the coefficient magnification factor value to obtain the actual ax value. Therefore, shift module one shifts ax right or left by the specified number of bits to keep it at the same magnification factor as b, and sends the result to addition module one. The number of bits shifted right or left in shift module one is: the sum of the temporary exponent output by the temporary exponent module and the magnification factor of coefficient a minus the difference between the magnification factor of coefficient b.
[0035] 6. Addition module 1 The addition module 1 performs the operation of adding ax to b, and sends the operation result to the multiplication module 2.
[0036] 7. Multiplication Module 2 The multiplication module 2 performs the operation of multiplying (ax+b) by x. The structure of the multiplication module 2 is the same as that of the multiplication module 1. The result is sent to the shift module 2.
[0037] 8. Shift module 2 The shift module 2 is the same as the shift module. Since the addition module 2 needs to perform the operation of (ax+b)x+c, the result of (ax+b)x is shifted right or left by the specified number of bits to keep it at the same magnification as c, and the result is sent to the addition module 2. The number of bits shifted right or left in the shift module 2 is: the sum of the temporary exponent output by the temporary exponent module and the magnification of coefficient a minus the difference of the magnification of coefficient b.
[0038] 9. Addition module 2 The addition module 2 performs the operation ((ax)+b)x+c, and the result is sent to the floating point module.
[0039] 10. Floating point module The floating point module is used to convert an integer to a floating point number and then output the floating point number y. For any unsigned integer, when converting it to a floating point number, you can start from the highest bit to the lowest bit to find the first non-zero bit. Assuming that the position is t, the integer can be expressed as , A single-bit value representing the decimal part of a floating-point number. Considering that the calculation result of the addition module 2 still contains the magnification of c, the magnification is removed by shifting, and according to this rule, the final floating-point output can be obtained.
[0040] A high-precision floating-point trigonometric function calculation method, using the above high-precision floating-point trigonometric function calculation device, comprises the following steps: (1) The floating-point number x and the trigonometric function selection signal are input into the floating-point number preprocessing module. This module filters out illegal inputs and special values that do not require operation in the input according to the trigonometric function selection signal, and sends the special values to the special processing module. The special processing module determines the type of the special value and directly outputs the corresponding function value. If the input is not a special value, it is sent to the fixed-point module. (2) The fixed-point conversion module converts the floating-point number x to a fixed-point number, sends the converted fixed-point number to the piecewise fitting coefficient table, multiplication module 1 and multiplication module 2, and sends the converted temporary index to the temporary index module for storage; (3) Multiplication module 1 obtains the polynomial coefficient a from the piecewise fitting coefficient table, performs an operation of multiplying the coefficient a by x, and sends the fixed-point product operation result ax to shift module 1; (4) Shift module 1 obtains the temporary index from the temporary index module, shifts ax right or left by a specified number of bits to keep it the same magnification as b, and sends the result to addition module 1; (5) Addition module 1 obtains the polynomial coefficient b from the piecewise fitting coefficient table, performs the operation of ax plus b, and sends the operation result to multiplication module 2; (6) Multiplication module 2 performs the operation of multiplying (ax+b) by x, and the result is sent to shift module 2; (7) Shift module 2 obtains the temporary index from the temporary index module, right-shifts or left-shifts the result (ax+b)x by a specified number of bits to keep the same magnification as c, and sends the result to addition module 2; (8) Addition module 2 obtains the polynomial coefficient c from the piecewise fitting coefficient table and performs the operation ((ax)+b)x+c), and the result is sent to the floating point module; (9) The floating point module converts the integer number into a floating point number and outputs the floating point number y.
[0041] The present invention divides the function definition domain into 128 segments for quadratic polynomial fitting, and obtains 128 sets of coefficients a, b, c. Through simulation using the C language mathematical function library, it can be seen that the fitting error in this case is , the error is smaller than the minimum error of single-precision data and will not introduce fitting error.
[0042] In the process of fixed-point calculation of floating-point numbers, the present invention performs variable quantization on the data before the multiplication operation unit to generate a "temporary index". If the value of the calculated data is very large or very small, the exponent can be changed to a certain extent and stored separately as needed, so that the decimal part of the floating-point number is completely retained during the calculation process, which is equivalent to increasing the quantization bit width. After the multiplication is calculated, the saved exponent value is restored to the data by a shift operation, which greatly reduces the error introduced by the calculation.
[0043] In order to test the calculation accuracy of the present invention, the calculation results of sin, cos and arctan are statistically analyzed. For each exponent, 1000 decimals are randomly generated as function test inputs. Under the same input conditions, the true value of the function is selected as C<math.h> Function value in double precision, calculation error result. Figures 2 to 4 The accuracy test results are shown. Both the average error and the maximum error meet the calculation requirements under normal circumstances. It can be seen that the single-precision floating-point trigonometric function calculation structure implemented in this design has high accuracy.
[0044] In summary, the present invention proposes an efficient computing structure for the calculation requirements of single-precision floating-point trigonometric functions in processor chip design and designs and implements it. Compared with the CORDIC implementation, the computing efficiency is improved and the overall performance of the processor chip is optimized.
[0045] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A high-precision floating-point trigonometric function computing device, characterized in that: It includes a floating point preprocessing module, a fixed point module, a piecewise fitting coefficient table, a temporary index module, a multiplication module 1, a multiplication module 2, a shift module 1, a shift module 2, an addition module 1, an addition module 2, a special processing module and a floating point module; The input of the floating-point number preprocessing module is the floating-point number x and the trigonometric function selection signal. The module filters illegal inputs and special values that do not require operation in the input according to the trigonometric function selection signal, and sends the special values to the special processing module, which determines the type of the special value and directly outputs the corresponding function value; if the input is a non-special value, it is sent to the fixed-point module; The function of the fixed-point conversion module is to convert the floating-point number x to a fixed-point number, send the converted fixed-point number to the segmented fitting coefficient table, the multiplication module 1 and the multiplication module 2, and send the converted temporary index to the temporary index module for storage; The segmented fitting coefficient table stores the enlarged polynomial coefficients a, b, c obtained by fitting the sin, cos and arctan functions, for use by multiplication module 1, addition module 1 and addition module 2; The multiplication module 1 performs the operation of multiplying the coefficient a by x, and sends the fixed-point product operation result ax to the shift module 1; The shift module 1 shifts ax right or left by a specified number of bits so that it maintains the same magnification as b, and sends the result to the addition module 1; The addition module 1 performs the operation of adding ax and b, and sends the operation result to the multiplication module 2; The multiplication module 2 performs the operation of multiplying (ax+b) by x, and the structure of the multiplication module 2 is the same as that of the multiplication module 1, and the obtained result is sent to the shift module 2; The shift module 2 shifts the result (ax+b)x right or left by a specified number of bits to keep the same magnification as c, and sends the result to the addition module 2; The addition module 2 performs the operation of ((ax)+b)x+c, and the result is sent to the floating point module; The floating point conversion module is used to convert an integer number into a floating point number and then output a floating point number y.
2. The high-precision floating-point trigonometric function computing device according to claim 1, characterized in that: The illegal inputs are all values that are not within the domain of the function. For the sin and cos functions, special values include 0, integer multiples of ±0.25, and values exceeding 2^23. In this case, the function value is ±1 or 0.
3. The high-precision floating-point trigonometric function computing device according to claim 1, characterized in that: In the fixed-point conversion module, the floating-point number conversion process first determines the bit width of the target fixed-point format, then maps the sign bit of the floating-point number to the sign bit of the fixed-point number, and then scales the decimal part by left or right shift operations according to the exponent value of the floating-point number so that the data conforms to the fixed-point representation accuracy.
4. The high-precision floating-point trigonometric function computing device according to claim 1, characterized in that: In the fixed-point module, when calculating the sin and cos functions, the following processing flow is performed: (1) If the exponent is less than 125, the input is between 0 and 0.25, and the decimal part is output directly; (2) If the exponent is 125, the input is between 0.25 and 0.5, the decimal part is inverted, added 1 and output; (3) If the exponent is 126, the input is between 0.5 and 1. Determine the highest bit of the decimal part: if the highest bit of the decimal part is 1, the input is between 0.75 and 1, set the highest bit of the decimal part to 0, invert the remaining part, add 1, and output; if the highest bit of the decimal part is 0, the input is between 0.5 and 0.75, and output the decimal part directly; (4) If the exponent is greater than 126, the input is greater than 1. The difference between the left-shifted exponent and 126 is used to determine the first and second digits of the left-shifted decimal part. If it is 00, the output value corresponds to between 0 and 0.25, and the decimal part is directly output. If it is 01, the output value corresponds to between 0.25 and 0.5, and the decimal part is inverted, added by 1, and output. If it is 10, the output value corresponds to between 0.5 and 0.75, and the decimal part is directly output; if it is 11, the output value corresponds to between 0.75 and 1, the decimal part is inverted and added to 1 and output; (5) The difference between the index and 126 is recorded as the temporary index and sent to the temporary index module.
5. The high-precision floating-point trigonometric function computing device according to claim 1, characterized in that: The polynomial coefficients stored in the piecewise fitting coefficient table are the polynomial coefficients obtained by fitting using the C / C++ language mathematical function library, which are magnified by a specified multiple and then fixed-pointed.
6. The high-precision floating-point trigonometric function computing device according to claim 1, characterized in that: The 32-bit × 32-bit multiplier designed using Booth coding and Wallace tree in multiplication module 1 obtains a 64-bit fixed-point result after multiplication operation.
7. The high-precision floating-point trigonometric function computing device according to claim 1, characterized in that: The number of bits shifted right or left in the shift module 1 is: the sum of the temporary index output by the temporary index module and the magnification of coefficient a minus the difference of the magnification of coefficient b.
8. The high-precision floating-point trigonometric function computing device according to claim 1, characterized in that: The number of bits shifted right or left in the shift module 2 is: the sum of the temporary index output by the temporary index module and the magnification of coefficient b minus the difference of the magnification of coefficient c.
9. A method for calculating high-precision floating-point trigonometric functions, using a high-precision floating-point trigonometric function calculation device as claimed in any one of claims 1 to 8, characterized in that: The steps include: (1) The floating-point number x and the trigonometric function selection signal are input into the floating-point number preprocessing module. This module filters out illegal inputs and special values that do not require operation in the input according to the trigonometric function selection signal, and sends the special values to the special processing module. The special processing module determines the type of the special value and directly outputs the corresponding function value. If the input is not a special value, it is sent to the fixed-point module. (2) The fixed-point conversion module converts the floating-point number x to a fixed-point number, sends the converted fixed-point number to the piecewise fitting coefficient table, multiplication module 1 and multiplication module 2, and sends the converted temporary index to the temporary index module for storage; (3) Multiplication module 1 obtains the polynomial coefficient a from the piecewise fitting coefficient table, performs an operation of multiplying the coefficient a by x, and sends the fixed-point product operation result ax to shift module 1; (4) Shift module 1 obtains the temporary index from the temporary index module, shifts ax right or left by a specified number of bits to keep it the same magnification as b, and sends the result to addition module 1; (5) Addition module 1 obtains the polynomial coefficient b from the piecewise fitting coefficient table, performs the operation of ax plus b, and sends the operation result to multiplication module 2; (6) Multiplication module 2 performs the operation of multiplying (ax+b) by x, and the result is sent to shift module 2; (7) Shift module 2 obtains the temporary index from the temporary index module, right-shifts or left-shifts the result (ax+b)x by a specified number of bits to keep the same magnification as c, and sends the result to addition module 2; (8) Addition module 2 obtains the polynomial coefficient c from the piecewise fitting coefficient table and performs the operation ((ax)+b)x+c), and the result is sent to the floating point module; (9) The floating point module converts the integer number into a floating point number and outputs the floating point number y.