Trigonometric function calculation method, apparatus and device, and readable storage medium

By combining the lookup table method and the CORDIC algorithm, and by using the method of splitting the angle to be solved and storing iterative information in a table, the problems of hardware resource consumption and computational latency in traditional trigonometric function calculation methods are solved, achieving high-precision and low-latency trigonometric function calculation.

CN120848839APending Publication Date: 2025-10-28CHONGQING CHANGAN AUTOMOBILE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410505593.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-25
Publication Date
2025-10-28

AI Technical Summary

Technical Problem

Traditional methods for calculating trigonometric functions have shortcomings in terms of hardware resource consumption and computational latency. The lookup table method requires a large amount of storage space, the CORDIC algorithm is slow to iterate and consumes a lot of hardware resources at high precision, and the Taylor expansion method is computationally complex and consumes a lot of resources.

Method used

A method combining lookup table and CORDIC algorithm is adopted. By splitting the angle to be solved, the iteration information is determined by using the iteration information storage table, the number of CORDIC iterations is reduced, and the remaining solution angles are iteratively calculated by combining CORDIC cells, thereby improving the calculation speed and accuracy.

Benefits of technology

It reduces the latency and hardware resource consumption of trigonometric function calculations, improves calculation accuracy, and meets the requirements of high precision and low latency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120848839A_ABST
    Figure CN120848839A_ABST
Patent Text Reader

Abstract

The invention provides a trigonometric function calculation method, device and equipment and a readable storage medium, and the method comprises the steps: carrying out the splitting of a to-be-solved angle if the to-be-solved angle corresponding to a trigonometric function meets a preset condition, and obtaining a first angle; determining iteration information corresponding to the first angle from an iteration information storage table; based on the iteration information, determining a residual solving angle corresponding to the angle to be solved; and carrying out iterative calculation on the residual solving angles by using a coordinate rotation digital calculation (CORDIC) unit to obtain a solving result corresponding to the angle to be solved. Therefore, by adopting the method of combining the table look-up method and the CORDIC, the effects of reducing the iterative calculation times of the trigonometric function and accelerating angle convergence can be realized, so that the calculation delay is reduced, the hardware resources are reduced, and a high-precision solving result is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of vehicle data processing technology, specifically to a trigonometric function calculation method, apparatus, device, and readable storage medium. Background Technology

[0002] LiDAR sensors are widely used in autonomous vehicles. In order to detect obstacles in the environment around the vehicle more accurately, the processed point cloud data of the LiDAR is required to have higher accuracy and real-time performance. The processing of LiDAR point cloud data includes the calculation of trigonometric functions.

[0003] Traditional methods for calculating trigonometric functions include lookup table method, Coordinate Rotation Digital Computer (CORDIC) algorithm, and Taylor expansion method. Lookup table method pre-stores trigonometric function values ​​(such as sine and cosine) in read-only memory (ROM), and the result is directly accessed by looking up the table. This method is simple and efficient, but it consumes a large amount of storage space, lacks flexibility, and the hardware resource consumption increases exponentially with increasing precision, making it unsuitable for high-precision trigonometric function calculations. Taylor expansion requires frequent calls to multipliers during hardware implementation, consuming significant hardware resources. The CORDIC algorithm has the disadvantage that when the input angle precision is high, the convergence is slow, resulting in unsatisfactory calculation results. Summary of the Invention

[0004] This application provides a method, apparatus, device, and readable storage medium for calculating trigonometric functions. The method can reduce the latency and hardware resource consumption of calculating trigonometric functions and improve the calculation accuracy.

[0005] The technical solution of this application is achieved as follows:

[0006] This application provides a method for calculating trigonometric functions, including: if the angle to be solved corresponding to the trigonometric function meets a preset condition, splitting the angle to be solved to obtain a first angle; the first angle includes the integer part of the angle to be solved; determining the iteration information corresponding to the first angle from an iteration information storage table; determining the remaining angles to be solved based on the iteration information; and iteratively calculating the remaining angles using a coordinate rotation digital computation CORDIC unit to obtain the solution result corresponding to the angle to be solved.

[0007] It is understood that, in this embodiment, when the angle to be solved corresponding to the trigonometric function meets the preset conditions, the partial iterative calculation of the CORDIC unit is first replaced by looking up the iterative information storage table to obtain the remaining angle to be solved. Then, the CORDIC unit iteratively calculates the remaining angle to obtain the final solution result. Thus, the method of combining the lookup table method and CORDIC can reduce the number of iterative calculations of the trigonometric function, accelerate angle convergence, thereby reducing computational latency, reducing hardware resources, and obtaining high-precision solution results.

[0008] In some embodiments, the iteration information storage table includes a first iteration angle storage table, wherein the iteration information includes an angle rotation direction identifier or a second angle iterated based on the first angle during the iteration process based on the first angle; determining the iteration information corresponding to the first angle from the iteration information storage table includes: inputting the first angle into a numerical comparator to obtain an angle range corresponding to the first angle and an identification information corresponding to the angle range; determining the angle rotation direction identifier or the second angle from the first iteration angle storage table based on the identification information; the angle rotation direction identifier includes at least one.

[0009] It is understandable that by determining the angle range and the identifier information of the angle range corresponding to the first angle, and then directly determining the corresponding angle rotation direction identifier or the second angle from the first iterative angle storage table based on the identifier information, the CORDIC algorithm iteration can be replaced by table lookup, thereby reducing the number of angle iterations and reducing the calculation delay of trigonometric functions.

[0010] In some embodiments, determining the remaining solution angle corresponding to the angle to be solved based on the iteration information includes: determining the remaining solution angle based on the first angle, at least one preset iteration angle stored in the second iteration angle storage table corresponding to the CORDIC cell, and the angle rotation direction identifier; the angle rotation direction identifier represents the rotation direction corresponding to the corresponding preset iteration angle in the circular system rotation mode.

[0011] It is understandable that by combining at least one preset iteration angle and angle rotation direction identifier stored in the first angle and second iteration angle storage tables, the remaining solution angles that need to be calculated by CORDIC cells can be quickly determined, thereby speeding up the calculation based on CORDIC cells.

[0012] In some embodiments, determining the remaining solution angle corresponding to the angle to be solved based on the iteration information includes: determining the remaining solution angle based on the second angle and the angle to be solved.

[0013] It is understandable that when the iteration information includes a second angle based on the first angle iteration, the remaining solution angles can be determined directly based on the second angle and the angle to be solved, so that the remaining solution angles can be calculated by CORDIC elements in the future, thereby improving the calculation speed of trigonometric functions.

[0014] In some embodiments, the iterative information storage table includes an iterative coordinate storage table, and the iterative information includes a first position coordinate value after iteration based on the first angle; determining the iterative information corresponding to the first angle from the iterative information storage table includes: inputting the first angle into a numerical comparator to obtain the angle range corresponding to the first angle and the identification information corresponding to the angle range; and determining the first position coordinate value from the iterative coordinate storage table according to the identification information.

[0015] Understandably, based on the identification information of the angle range corresponding to the first angle, the coordinate value of the first position is determined from the iterative coordinate storage table. This facilitates subsequent iterative calculations using CORDIC units based on the first position coordinate value, thereby obtaining the solution result corresponding to the angle to be solved.

[0016] In some embodiments, the solution result includes the trigonometric function value and angle error value corresponding to the angle to be solved; the step of using the CORDIC unit to iteratively calculate the remaining angle to obtain the solution result corresponding to the angle to be solved includes: inputting the first position coordinate value and the remaining angle to be solved into the CORDIC unit for iterative calculation until the convergence condition is met, and obtaining the trigonometric function value and angle error value corresponding to the angle to be solved.

[0017] Understandably, after determining the first position coordinates and the remaining solution angle by looking up the iteration information storage table, these coordinates are input into the CORDIC cell. The iteration continues through the CORDIC cell until the convergence condition is met, at which point the trigonometric function values ​​and angle error values ​​corresponding to the solution angle can be obtained. Thus, by looking up the iteration information storage table before using the CORDIC cell, computation time is saved while ensuring computational accuracy.

[0018] In some embodiments, the step of splitting the angle to be solved to obtain a first angle includes: determining the integer part and the fractional part of the angle to be solved; splitting the fractional part into a first sub-part and a second sub-part; determining the angle corresponding to the integer part as the first angle, or determining the angle corresponding to the integer part and the angle corresponding to the first sub-part as the first angle, or determining the angle corresponding to the integer part and the angle corresponding to the second sub-part as the first angle.

[0019] It is understandable that by splitting the angle to be solved into its integer and fractional parts, and determining the angle corresponding to the integer part, or the angle corresponding to the integer part and the sub-part of the fractional part, as the first angle, it is easier to iterate by looking up the iteration information storage table, thereby speeding up the calculation.

[0020] In some embodiments, the trigonometric function calculation method further includes: obtaining the angle to be solved; and determining whether the angle to be solved meets the preset conditions based on the number of decimal places corresponding to the angle to be solved.

[0021] It is understandable that by determining the number of decimal places of the angle to be solved, it can be determined whether the angle needs to be solved by replacing part of the CORDIC cell calculation iterations with a lookup table, thereby speeding up the solution speed of the trigonometric function values ​​corresponding to the angle to be solved while ensuring the calculation accuracy.

[0022] In some embodiments, determining whether the angle to be solved meets the preset condition based on the number of decimal places of the angle to be solved includes: if the number of decimal places of the angle to be solved is greater than a preset threshold, determining that the angle to be solved meets the preset condition.

[0023] Understandably, if the number of decimal places of the angle to be solved exceeds a preset threshold, it indicates that the angle may contain a large number of decimal places. If calculation is performed solely using CORDIC cells, the number of iterations may be excessive, thus increasing hardware resource consumption. Therefore, in this case, the angle to be solved is confirmed to meet the preset conditions, and the angle is split to facilitate subsequent calculations using table lookup and CORDIC cell iterative calculations, thereby improving calculation speed and accuracy.

[0024] In some embodiments, determining whether the angle to be solved meets the preset condition based on the number of decimal places corresponding to the angle to be solved includes: if the number of decimal places of the angle to be solved is less than or equal to a preset threshold, determining that the angle to be solved does not meet the preset condition.

[0025] It is understandable that if the number of decimal places of the angle to be solved is less than or equal to the preset threshold, it means that the angle to be solved may be an integer or contain only a small number of decimal places, and the number of iterations is small. In this case, the trigonometric function value corresponding to the angle to be solved can be directly obtained by looking up the table, or the trigonometric function value can be directly calculated by CORDIC unit, thereby reducing the calculation delay while ensuring the calculation accuracy.

[0026] In some embodiments, the trigonometric function calculation method further includes: if the angle to be solved corresponding to the trigonometric function does not meet the preset condition, obtaining the initial position coordinate value corresponding to the angle to be solved; inputting the angle to be solved and the initial position coordinate into the CORDIC unit to obtain the solution result corresponding to the angle to be solved.

[0027] It is understandable that when the angle to be solved does not meet the preset conditions, by inputting the angle to be solved and the initial position coordinates corresponding to the angle to be solved into the CORDIC element, a high-precision calculation result can be obtained through the CORDIC element.

[0028] This application provides a trigonometric function calculation device, including:

[0029] The first processing module is used to split the angle to be solved into a first angle if the angle to be solved corresponding to the trigonometric function meets the preset conditions; the first angle includes the integer part of the angle to be solved.

[0030] The first determining module is used to determine the iteration information corresponding to the first angle from the iteration information storage table;

[0031] The second determining module is used to determine the remaining solving angles corresponding to the angle to be solved based on the iteration information;

[0032] The first iterative calculation module is used to perform iterative calculations on the remaining solution angles using the CORDIC unit to obtain the solution results corresponding to the angles to be solved.

[0033] This application provides a trigonometric function calculation device, including:

[0034] The memory is used to store trigonometric function calculation instructions;

[0035] The processor, when executing executable trigonometric function calculation instructions stored in the memory, implements the method provided in the embodiments of this application.

[0036] This application provides a computer-readable storage medium storing computer-executable instructions configured to perform the above-described trigonometric function calculation method. Attached Figure Description

[0037] Figure 1 A flowchart illustrating a trigonometric function calculation method provided in this application embodiment;

[0038] Figure 2 A flowchart illustrating a low-latency, high-precision CORDIC cell design method provided in this application embodiment;

[0039] Figure 3 A schematic diagram of a serial structure of a CORDIC computing unit provided in an embodiment of this application;

[0040] Figure 4 A schematic diagram illustrating the principle of a serial CORDIC computing unit for calculating trigonometric function values, provided in an embodiment of this application;

[0041] Figure 5 A schematic diagram illustrating the principle of a serial CORDIC calculation unit for calculating angle error, provided in an embodiment of this application;

[0042] Figure 6 A schematic diagram of a parallel structure of a CORDIC computing unit provided in an embodiment of this application;

[0043] Figure 7 A schematic diagram of a parallel pipeline structure for a CORDIC computing unit provided in an embodiment of this application;

[0044] Figure 8 A schematic diagram illustrating the principle of iterative computation using a parallel CORDIC computing unit, provided for an embodiment of this application;

[0045] Figure 9 A flowchart illustrating another low-latency, high-precision CORDIC cell design method provided in this application embodiment;

[0046] Figure 10 A schematic diagram of an iterative angle ROM provided in an embodiment of this application;

[0047] Figure 11 A flowchart illustrating another low-latency, high-precision CORDIC cell design method provided in this application embodiment;

[0048] Figure 12 This is a schematic diagram of the composition structure of a trigonometric function calculation device provided in an embodiment of this application;

[0049] Figure 13 This is a schematic diagram of the composition structure of a trigonometric function calculation device provided in an embodiment of this application. Detailed Implementation

[0050] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application.

[0051] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0052] In the following description, references to “some embodiments” or “other embodiments” describe a subset of all possible embodiments. However, it is understood that “some embodiments” or “other embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0053] In the following description, the terms "first" and "second" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first" and "second" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0055] In fields such as scientific computing, simulation, motion control, and signal processing, trigonometric functions are frequently used, and many calculations based on trigonometric function values ​​have high requirements for accuracy and real-time performance.

[0056] Traditional lookup table methods consume too much storage space. Taking the commonly used AT128 lidar as an example, the accuracy of the angle in the radar detection data is 0.01° / 256. If a lookup table is used, the sin function value requires 360° / (0.01° / 256)*4Byte = 36MB of space (trigonometric function values ​​are calculated and stored in FLOT type). The cos function is similar, occupying a relatively large amount of storage space.

[0057] Taylor expansion is also an important method for calculating trigonometric functions. Taylor expansion uses polynomial functions to approximate the original function, as shown in the following formula (1):

[0058]

[0059] Taylor expansion requires frequent calls to the multiplier during hardware implementation, which consumes significant hardware resources.

[0060] The CORDIC algorithm was proposed by J. Volder in 1959 and was first used in navigation systems. The iterative process of the CORDIC algorithm is shown in the following formula (2):

[0061]

[0062] The principle of the CORDIC algorithm in calculating the sin and cos functions through n iterations is shown in the following formula (3):

[0063]

[0064] Let x0 = 1 / A n =0.607253, y0=0, z0=θ, we can obtain x n =cosθ,y n =sinθ.

[0065] The CORDIC algorithm obtains results by rotating the coordinates through successive approximations. High-precision trigonometric function calculations can be generated with only simple shifting and addition / subtraction operations. Due to its iterative computational nature, the CORDIC algorithm is also well-suited for pipelined implementation, significantly improving data throughput. Therefore, the CORDIC algorithm is very suitable for hardware implementation.

[0066] However, the CORDIC algorithm has a drawback: when the input angle precision is high, the convergence is slow, resulting in unsatisfactory calculation results. Taking the commonly used AT128 lidar as an example, the angle precision in the radar detection data is 0.01° / 256 = 3.90625 x 10⁻⁵. Using the CORDIC algorithm, at least 23 iterations are required to reach the order of magnitude of the target precision. It's important to note that in the CORDIC algorithm, the angle is obtained by adding and subtracting a series of angles (45° ± 26.6° ± 14.0° ± ...), with these results falling within the range of [-99.9°, 99.9°]. Therefore, when the target angle calculated using the CORDIC algorithm exceeds the range of [0°, 90°], preprocessing is necessary, as the CORDIC algorithm only calculates results within the range of [0°, 90°]. Furthermore, for the serial architecture of the CORDIC algorithm, multiple iterations lead to insufficient data throughput and excessive computational latency; for the parallel or parallel pipelined architecture of the CORDIC algorithm, multiple iterations result in massive hardware resource consumption.

[0067] In related technologies, an FPGA-based CORDIC optimization scheme overcomes the shortcomings of slow convergence and low accuracy of CORDIC when approaching the coordinate axes by combining Taylor's algorithm and CORDIC. However, the hardware design of this scheme is relatively complex, including a threshold judgment module, lookup table, Taylor calculation module, CORDIC calculation module, and quadrant compensation unit. Another trigonometric function arithmetic unit design scheme combines feedback and pipelined structure based on CORDIC algorithm. It proposes a configuration-based pseudo-pipelined CORDIC algorithm structure to achieve unlimited precision trigonometric function calculation by continuously feeding back the output of the operation iteration unit to its input in a pseudo-pipelined form. Although this scheme can further improve the calculation accuracy without increasing the hardware circuit overhead, the time consumption will be correspondingly extended, making it difficult to meet the requirements of low latency or real-time systems.

[0068] Based on the problems existing in related technologies, this application provides a method for calculating trigonometric functions. This method can be applied to vehicle-mounted devices, such as body controllers and sensors, and can reduce the latency and hardware resource consumption of calculating trigonometric functions while improving calculation accuracy. Figure 1 The diagram shown is a flowchart illustrating a trigonometric function calculation method provided in an embodiment of this application. The method includes the following steps:

[0069] S101. If the angle to be solved corresponding to the trigonometric function meets the preset conditions, the angle to be solved is split to obtain the first angle.

[0070] It should be noted that the angle to be solved for by the trigonometric function can be an integer or a decimal, and the range of the angle can be [0°, 360°]. A preset condition can be that the number of decimal places in the angle to be solved is greater than a preset threshold, which can be any positive integer, such as 1 or 2. The trigonometric function can be a sine function, a cosine function, etc. The first angle includes the integer part of the angle to be solved, or it can be a part of the angle to be solved, for example, the integer part of the angle to be solved, or the integer part of the angle to be solved plus a partial decimal part.

[0071] In some embodiments, if the angle to be solved meets a preset condition, it is considered that the angle has a large number of decimal places. If only CORDIC units are used for direct iterative calculation, the number of iterations will be very large, consuming significant hardware resources. Therefore, in this case, the angle to be solved can be split. For example, the angle to be solved can be split into two parts: the first part is the integer part of the angle to be solved, and the second part is the decimal part of the angle to be solved; or the first part is the integer part of the angle to be solved plus a portion of the decimal part of the angle to be solved, and the second part is the remaining decimal part of the angle to be solved. The angle value corresponding to the second part is less than 1°, and the angle value corresponding to the first part is much larger than the angle value corresponding to the second part.

[0072] In some embodiments, the angle to be solved can be split according to a preset rule. The preset rule can be a rule for splitting the angle. For example, the preset rule can be to split the angle to be solved into an integer part and a decimal part, or to split the angle to be solved into an integer part plus a decimal part and other decimal parts.

[0073] For example, if the angle to be solved is 42.186235°, it can be split into 42° and 0.186235°, with 42° being the first angle. Alternatively, it can be split into 42.18° and 0.006235°, with 42.18° being the first angle. The angle to be solved, the method of splitting the angle, and the first angle are merely illustrative examples, and this application does not limit them.

[0074] S102. Determine the iteration information corresponding to the first angle from the iteration information storage table.

[0075] It should be noted that the iteration information storage table is pre-created based on the iterative calculation results of the CORDIC unit for coordinate rotation digital calculation. The iteration information may include the rotation direction identifiers of each angle corresponding to the first angle during the iteration process, the second angle iterated based on the first angle, and the first position coordinates after iterating over the first angle. The second angle can be the angle that has already been iterated over based on the first angle.

[0076] In some embodiments, the rotation direction identifiers corresponding to each angle during the iteration process based on the first angle, the second angle iterated based on the first angle, and the first position coordinate value after iteration based on the first angle can be determined according to a pre-constructed iteration information storage table. The iteration information storage table includes a first iteration angle storage table and an iteration coordinate storage table. The rotation direction identifiers corresponding to each angle during the iteration process based on the first angle or the second angle iterated based on the first angle can be obtained from the first iteration angle storage table, and the first position coordinate value after iteration based on the first angle can be obtained from the iteration coordinate storage table.

[0077] S103. Based on the iteration information, determine the remaining solution angles corresponding to the angle to be solved.

[0078] It should be noted that the remaining solution angle corresponding to the angle to be solved can be the angle remaining after angle iteration by looking up the iteration information storage table. For example, if the angle to be solved is 35.216°, and the iteration is performed based on the first angle to 35.2° by looking up the iteration information storage table, then the remaining solution angle corresponding to the angle to be solved is 0.016°.

[0079] In some embodiments, the angles that have been iterated based on the first angle can be determined according to the iteration information, and the remaining solution angles corresponding to the angle to be solved can be determined according to the angle to be solved and the angles that have been iterated based on the first angle. In implementation, the angles that have been iterated based on the first angle can be calculated based on the rotation direction identifiers of each angle corresponding to the first angle during the iteration process and each preset iteration angle during the iteration process, and then the remaining solution angles corresponding to the angle to be solved can be determined according to the angle to be solved and the angles that have been iterated based on the first angle.

[0080] In other embodiments, the iteration information may include the angle that has already been iterated based on the first angle (the second angle). Therefore, the remaining angle corresponding to the angle to be solved can be determined directly based on the second angle and the angle to be solved in the iteration information. For example, if the angle to be solved is 45.61582° and the second angle is 45.212°, then the remaining angle corresponding to the angle to be solved is 0.04382°.

[0081] S104. Use the coordinate rotation digital calculation CORDIC element to iteratively calculate the remaining solution angles to obtain the solution results corresponding to the angles to be solved.

[0082] In some embodiments, after obtaining the remaining solution angle corresponding to the angle to be solved by looking up the iteration information storage table, the CORDIC unit can be used to iteratively calculate the remaining solution angle to obtain the solution result corresponding to the angle to be solved. In implementation, the first position coordinate value obtained based on the iteration information storage table after the first angle iteration can also be obtained. The first position coordinate and the remaining solution angle corresponding to the angle to be solved are input into the CORDIC unit to obtain the solution result corresponding to the angle to be solved. This solution result includes the trigonometric function value corresponding to the angle to be solved, and the difference between the iterated angle and the angle to be solved, i.e., the angle error value.

[0083] In this embodiment, if the angle to be solved corresponding to the trigonometric function meets a preset condition, the angle to be solved is split to obtain a first angle; the iteration information corresponding to the first angle is determined from the iteration information storage table; the iteration information storage table is pre-created based on the iteration calculation results of the CORDIC unit; based on the iteration information, the remaining solution angles corresponding to the angle to be solved are determined; the remaining solution angles are iteratively calculated using the CORDIC unit to obtain the solution result corresponding to the angle to be solved. Thus, by combining the lookup table method with the CORDIC method, the number of iteration calculations for the trigonometric function can be reduced, and angle convergence can be accelerated, thereby reducing computational latency, reducing hardware resources, and obtaining high-precision solution results.

[0084] In some embodiments of this application, the iteration information storage table includes a first iteration angle storage table. The iteration information includes an angle rotation direction identifier during the iteration process based on the first angle or a second angle based on the first angle. There may be multiple angle rotation direction identifiers, each corresponding to a preset iteration angle. The angle rotation direction identifier can take the value 1 or 0. 1 can indicate that the corresponding preset iteration angle rotates clockwise, and 0 can indicate that the corresponding preset iteration angle rotates counterclockwise; or 1 can indicate that the corresponding preset iteration angle rotates counterclockwise, and 0 can indicate that the corresponding preset iteration angle rotates clockwise. The second angle can represent the sum of multiple angles rotated or iterated based on the first angle. For example, if the first angle is 45°, the calculation process of the second angle based on the iteration of the first angle is: 45° - 26.56505118° + 14.03624347° + 7.12501635° + 3.57633437° - 1.78991061° = 48.6173676°, where "+" indicates counterclockwise rotation and "-" indicates clockwise rotation.

[0085] In some embodiments, the iteration information corresponding to the first angle is determined from the iteration information storage table. That is, the above step S102 can be implemented by the following steps S1021A to S1022A. Each step is described below.

[0086] S1021A. Input the first angle into the numerical comparator to obtain the angle range corresponding to the first angle and the identification information corresponding to the angle range.

[0087] In some embodiments, the numerical comparator can compare the first angle with multiple preset angle ranges to determine the angle range corresponding to the first angle. The multiple preset angle ranges can be pre-set, and the first angle can be compared with the upper and lower limits of each preset angle range in turn to determine the angle range in which the first angle falls.

[0088] In some embodiments, a preset angle range corresponds to a type of identification information. The preset angle range and the corresponding identification information are pre-stored in an iterative information storage table. The identification information can be a decimal number, a binary number, etc. Therefore, after determining the angle range corresponding to the first angle, the identification information corresponding to the angle range can be obtained from the iterative information storage table.

[0089] S1022A. Based on the identification information, determine the angle rotation direction identifier or the second angle from the first iteration angle storage table.

[0090] In some embodiments, the angle rotation direction identifier includes at least one. The first iterative angle storage table stores a preset angle range, the corresponding identification information of the preset angle range, and the angle rotation identifier, or stores a preset angle range, the corresponding identification information of the preset angle range, and a second angle. Therefore, after obtaining the identification information corresponding to the angle range, the angle rotation direction identifier or the second angle can be directly obtained through the first iterative angle storage table.

[0091] It is understandable that by determining the angle range and the identifier information of the angle range corresponding to the first angle, and then directly determining the corresponding angle rotation direction identifier or the second angle from the first iterative angle storage table based on the identifier information, the CORDIC algorithm iteration can be replaced by table lookup, thereby reducing the number of angle iterations and reducing the calculation delay of trigonometric functions.

[0092] In some embodiments of this application, the remaining solution angle corresponding to the angle to be solved is determined based on the iteration information. That is, the above step S103 can be implemented by the following steps S1031A or S1031B. Steps S1031A and S1031B are described below.

[0093] S1031A: Based on the first angle and at least one preset iteration angle and angle rotation direction identifier stored in the second iteration angle storage table corresponding to the CORDIC cell, determine the remaining solution angle.

[0094] It should be noted that the angle rotation direction identifier indicates the rotation direction corresponding to the preset iteration angle in the circular system rotation mode. The second iteration angle storage table is different from the first iteration angle storage table. The second iteration angle storage table stores the preset rotation angle corresponding to each iteration. For example, the initial iteration angle (first angle) is 45°, the angle of the first iteration is 26.56505118°, the angle of the second iteration is 14.03624347°, the angle of the third iteration is 7.12501635°, ..., and the angle of the fifth iteration is 1.78991061°.

[0095] In some embodiments, the angles that have been iterated or calculated based on the first angle can be determined according to the first angle and the angle rotation direction identifiers corresponding to each preset iteration angle. Then, the remaining solution angles corresponding to the solution angles can be determined according to the angle to be solved and the angles that have been iterated or calculated based on the first angle.

[0096] It is understandable that by combining at least one preset iteration angle and angle rotation direction identifier stored in the first angle and second iteration angle storage tables, the remaining solution angles that need to be calculated by CORDIC cells can be quickly determined, thereby speeding up the calculation based on CORDIC cells.

[0097] S1031B. Based on the second angle and the angle to be solved, determine the remaining angles to be solved.

[0098] In some embodiments, the second iterative angle storage table directly stores the angle based on the first angle iteration, i.e., the second angle. Therefore, after obtaining the second angle, the remaining solution angle corresponding to the solution angle can be obtained directly based on the second angle and the angle to be solved, for example by subtracting the second angle from the angle to be solved.

[0099] It is understandable that when the iteration information includes a second angle based on the first angle iteration, the remaining solution angles can be determined directly based on the second angle and the angle to be solved, so that the remaining solution angles can be calculated by CORDIC elements in the future, thereby improving the calculation speed of trigonometric functions.

[0100] In some embodiments of this application, the iteration information storage table includes an iteration coordinate storage table. The iteration information includes the first position coordinate value after iteration based on the first angle. The first position coordinate value can be the position coordinate of the vector after multiple iterations based on the first angle in a circular system rotation mode, in a Cartesian coordinate system, and can include the horizontal coordinate and the vertical coordinate. Based on this, the iteration information corresponding to the first angle is determined from the iteration information storage table. That is, the above step S102 can be implemented by the following steps S1021B to S1022B, and each step is described below.

[0101] S1021B: Input the first angle into the numerical comparator to obtain the angle range corresponding to the first angle and the identification information corresponding to the angle range.

[0102] In some embodiments, the numerical comparator can compare the first angle with multiple preset angle ranges to determine the angle range corresponding to the first angle. The multiple preset angle ranges can be pre-set, and the first angle can be compared with the upper and lower limits of each preset angle range in turn to determine the angle range in which the first angle falls.

[0103] In some embodiments, a preset angle range corresponds to a type of identification information. The preset angle range and the corresponding identification information are pre-stored in an iterative information storage table. The identification information can be a decimal number, a binary number, etc. Therefore, after determining the angle range corresponding to the first angle, the identification information corresponding to the angle range can be obtained from the iterative information storage table.

[0104] S1022B. Determine the first position coordinate value from the iterative coordinate storage table based on the identification information.

[0105] In some embodiments, the iterative coordinate storage table stores a preset angle range, the identification information corresponding to the preset angle range, and the position coordinate value after iteration based on the first angle. Therefore, after determining the identification information of the angle range corresponding to the first angle, the first position coordinate value corresponding to the identification information can be determined from the iterative coordinate storage table.

[0106] Understandably, based on the identification information of the angle range corresponding to the first angle, the coordinate value of the first position is determined from the iterative coordinate storage table. This facilitates subsequent iterative calculations using CORDIC units based on the first position coordinate value, thereby obtaining the solution result corresponding to the angle to be solved.

[0107] In some embodiments of this application, the solution results include the trigonometric function values ​​and angle error values ​​corresponding to the angle to be solved; the remaining angles to be solved are iteratively calculated using CORDIC cells to obtain the solution results corresponding to the angles to be solved. That is, step S104 can be implemented by the following step S1041, which will be described below.

[0108] S1041. Input the first position coordinate value and the remaining solution angle into the CORDIC unit for iterative calculation until the convergence condition is met, and obtain the trigonometric function value and angle error value corresponding to the angle to be solved.

[0109] In some embodiments, the angle error value corresponding to the angle to be solved can be the angle to be solved and the actual angle during the iteration process (the angle determined by combining the lookup of the iteration information storage table and the calculation by the CORDIC cell). The convergence condition can be that the trigonometric function value output by the CORDIC cell meets the accuracy condition, for example, the difference between the reference solved angle and the angle to be solved corresponding to the trigonometric function value is less than or equal to a preset accuracy threshold. The trigonometric function value corresponding to the angle to be solved can be the sin value, cos value, etc. of the angle to be solved.

[0110] In some embodiments, after determining the first position coordinates and the remaining solution angle based on the first angle iteration according to the iteration information storage table, the calculation can continue through the CORDIC unit. The CORDIC unit can iterate based on its input first position coordinates and the remaining solution angle until the iteration result output by the CORDIC unit meets the convergence condition, and then the iteration process can be stopped, thereby obtaining the trigonometric function value and the corresponding angle error value corresponding to the angle to be solved.

[0111] Understandably, after determining the first position coordinates and the remaining solution angle by looking up the iteration information storage table, these coordinates are input into the CORDIC cell. The iteration continues through the CORDIC cell until the convergence condition is met, at which point the trigonometric function values ​​and angle error values ​​corresponding to the solution angle can be obtained. Thus, by looking up the iteration information storage table before using the CORDIC cell, computation time is saved while ensuring computational accuracy.

[0112] In some embodiments of this application, when implementing the step S101 of "splitting the angle to be solved to obtain a first angle", the integer part and the fractional part of the angle to be solved can be determined; the fractional part can be split into a first sub-part and a second sub-part; the angle corresponding to the integer part can be determined as the first angle, or the angle corresponding to the integer part and the angle corresponding to the first sub-part can be determined as the first angle, or the angle corresponding to the integer part and the angle corresponding to the second sub-part can be determined as the first angle.

[0113] It should be noted that the first sub-part and the second sub-part can be different parts of the decimal part of the angle to be solved. The integer part of the angle to be solved can be determined as the first angle, the first sub-part of the integer part and the decimal part of the angle to be solved can be determined as the first angle, or the second sub-part of the integer part and the decimal part of the angle to be solved can be determined as the first angle.

[0114] In some embodiments, the integer part angle or the integer part angle plus a fractional part angle (the angle corresponding to the first sub-part or the angle corresponding to the second sub-part) can be iterated by looking up an iteration information storage table. In implementation, the choice between the angle corresponding to the integer part of the angle to be solved, or the angle corresponding to both the integer part and the first sub-part of the fractional part, and whether to choose the first or second sub-part of the fractional part, can be preset.

[0115] It is understandable that by splitting the angle to be solved into its integer and fractional parts, and determining the angle corresponding to the integer part, or the angle corresponding to the integer part and the sub-part of the fractional part, as the first angle, it is easier to iterate by looking up the iteration information storage table, thereby speeding up the calculation.

[0116] In some embodiments of this application, before splitting the angle to be solved into its first angle, the angle to be solved can be obtained first; based on the number of decimal places corresponding to the angle to be solved, it can be determined whether the angle to be solved meets the preset conditions. After obtaining the angle to be solved, it can be determined whether the angle to be solved meets the preset conditions based on the number of decimal places of the angle to be solved.

[0117] In some embodiments, by determining whether the angle to be solved needs to be replaced by a table lookup method to replace part of the CORDIC cell calculation iteration based on the number of decimal places of the angle to be solved, the calculation speed of the trigonometric function value corresponding to the angle to be solved can be accelerated while ensuring the calculation accuracy.

[0118] In some embodiments of this application, in the process of determining whether the angle to be solved meets the preset conditions based on the number of decimal places corresponding to the angle to be solved, if it is determined that the number of decimal places of the angle to be solved is greater than the preset threshold, it is determined that the angle to be solved meets the preset conditions; if the number of decimal places of the angle to be solved is less than or equal to the preset threshold, it is determined that the angle to be solved does not meet the preset conditions.

[0119] In some embodiments, the preset threshold can be any pre-set positive integer, such as 1, 2, etc. In practice, the more decimal places the angle to be solved has, the more iterations will be. Therefore, by comparing the number of decimal places of the angle to be solved with the preset threshold, it can be determined whether the angle to be solved meets the preset conditions, thereby determining whether to use the method of calculation by lookup table combined with CORDIC cell or the method of calculation directly by CORDIC cell to determine the trigonometric function value.

[0120] In some embodiments, if the number of decimal places of the angle to be solved is greater than a preset threshold, it indicates that the angle may contain a large number of decimal places. If calculation is performed solely using CORDIC cells, the number of iterations may be very large, thereby increasing hardware resource consumption. Therefore, in this case, it is confirmed that the angle to be solved meets the preset conditions, and the angle to be solved is split to facilitate subsequent calculations using table lookup and CORDIC cell iterative calculation methods to improve calculation speed and accuracy.

[0121] In some embodiments, if the number of decimal places of the angle to be solved is less than or equal to a preset threshold, it indicates that the angle to be solved may be an integer or contain only a small number of decimal places, and the number of iterations is small. In this case, the trigonometric function value corresponding to the angle to be solved can be directly obtained by looking up a table, or the trigonometric function value can be directly calculated by CORDIC cell, thereby reducing the calculation delay while ensuring the calculation accuracy.

[0122] In some embodiments of this application, if the angle to be solved corresponding to the trigonometric function does not meet the preset conditions, the initial position coordinate value corresponding to the angle to be solved is obtained; the angle to be solved and the initial position coordinate are input into the CORDIC cell to obtain the solution result corresponding to the angle to be solved.

[0123] In some embodiments, the initial position coordinates can be the horizontal and vertical coordinates corresponding to the angle to be solved in the circular system rotation mode. If it is determined that the angle to be solved does not meet the preset conditions, the angle to be solved and the initial position coordinates corresponding to the angle to be solved can be directly input into the CORDIC unit, and the CORDIC unit can perform iterative calculation to obtain the solution result corresponding to the angle to be solved.

[0124] It is understandable that when the angle to be solved does not meet the preset conditions, by inputting the angle to be solved and the initial position coordinates corresponding to the angle to be solved into the CORDIC element, a high-precision calculation result can be obtained through the CORDIC element.

[0125] In this embodiment, if the angle to be solved corresponding to the trigonometric function meets a preset condition, the angle to be solved is split to obtain a first angle; the iteration information corresponding to the first angle is determined from the iteration information storage table; the iteration information storage table is pre-created based on the iteration calculation results of the CORDIC unit; based on the iteration information, the remaining solution angles corresponding to the angle to be solved are determined; the remaining solution angles are iteratively calculated using the CORDIC unit to obtain the solution result corresponding to the angle to be solved. Thus, by combining the lookup table method with the CORDIC method, the number of iteration calculations for the trigonometric function can be reduced, and angle convergence can be accelerated, thereby reducing computational latency, reducing hardware resources, and obtaining high-precision solution results.

[0126] The implementation process of the application embodiments in practical application scenarios is described below.

[0127] This application provides a design method for CORDIC cells based on low latency and high precision, such as... Figure 2 The diagram shown is a flowchart illustrating a low-latency, high-precision CORDIC cell design method provided in an embodiment of this application. The following is a summary of the process. Figure 2 The steps of this method are explained.

[0128] S201. Input the angle to be solved z0 (equivalent to "angle to be solved" in other embodiments), and the initial position coordinates x0 and y0 (equivalent to "initial position coordinate values" in other embodiments).

[0129] The initial position coordinates can be the x-coordinate x0 and y-coordinate y0 of the corresponding vector when the angle between the vector and the positive x-axis is z0 in the circular rotation mode.

[0130] S202. Determine whether the result of the lookup table (equivalent to the "iteration information storage table" in other embodiments) is needed to replace part of the iteration.

[0131] If yes, then proceed to step S203; otherwise, proceed to step S208.

[0132] S203. Extract the integer part of the angle or the integer part and a fractional part (equivalent to the "first angle" in other embodiments).

[0133] S204. Input the intercepted data into a numerical comparator to determine the angle range (equivalent to "the angle range corresponding to the first angle" in other embodiments).

[0134] The function of the numerical comparator is to compare the numerical value with the threshold of each range to determine the angle range to which the angle belongs, as well as the angle range code value corresponding to the range (equivalent to the "identification information corresponding to the angle range" in other embodiments).

[0135] S205. Based on the angle range encoding value, read the iteration direction value angle_sgn (equivalent to the "angle rotation direction identifier" in other embodiments) or the angle iteration value z from the angle iteration ROM (equivalent to the "first iteration angle storage table" in other embodiments). m (equivalent to "second angle" in other embodiments), x0' and y0' in the iteration value ROM (equivalent to "iteration coordinate storage table" in other embodiments) (equivalent to "first position coordinate value" in other embodiments).

[0136] The angle iteration ROM and the iteration value ROM are two different storage spaces. The angle iteration ROM stores the angle direction value angle_sgn for each iteration in the lookup table method iteration, or the angle z after the lookup table method iteration. m The iterative value ROM stores the position coordinates x0' and y0' after the lookup table method iteration.

[0137] S206. Use the angle calculator and parameters angle_sgn or z. m , calculate z0 to obtain z0'.

[0138] The angle_sgn is read and the CORDIC iterative angle stored in ROM is used to calculate z0', or z0' is calculated directly based on z0 and z0'. m z0' is calculated.

[0139] S207. Input x0', y0' and z0' into a serial or parallel CORDIC computing unit (equivalent to "CORDIC unit" in other embodiments) for subsequent iterative calculations.

[0140] The serial structure of the CORDIC computing unit is as follows: Figure 3 As shown, where x i y i and z i This represents the output result of the i-th iteration, x is calculated using a CORDIC computation unit with a serial structure. n y n The schematic diagram is as follows Figure 4 As shown, calculate z n The schematic diagram is as follows Figure 5 As shown; the parallel structure of the CORDIC computing unit is as follows Figure 6 As shown, j = 0, 1, ..., N-1, N represents the number of CORDIC computing units. The parallel pipeline structure of the CORDIC computing units is as follows: Figure 7 As shown, where k = 0, 1, ..., N-1. x is calculated using CORDIC computing units with a parallel structure. n y n z n The schematic diagram is as follows Figure 8 As shown.

[0141] S208. Iterative calculations are performed using the CORDIC computing unit until the target accuracy is reached (equivalent to "meeting the convergence condition" in other embodiments), yielding the trigonometric function value x. n y n and angle error z n .

[0142] The target accuracy is achieved when the angle error of the result output by the CORDIC calculation unit is less than or equal to a preset threshold. The angle error can be determined by summing the angle iterated by the lookup table method and the angle iterated by the CORDIC calculation unit, and then adding the angle z0 to be solved. The angle error represents the difference between the actual iterated angle and the angle to be solved. Under the condition of achieving the target accuracy, the trigonometric function value of the actual iterated angle can be used to replace the trigonometric function value of the angle to be solved.

[0143] If it is determined that it is not necessary to replace part of the CORDIC computation unit iteration with the lookup table method, the angle to be solved z0 and its corresponding initial position coordinates can be directly input into the CORDIC computation unit for calculation until the target accuracy is achieved, and the trigonometric function value x is obtained. n y n and angle error z n That is, step S208 can be executed after step S209.

[0144] The low-latency, high-precision CORDIC cell design method provided in this application adds a numerical comparator, an angle iteration ROM, an iteration value ROM, and an angle calculator before the original CORDIC calculation unit. This allows the iteration results of the integer part of the angle or the integer part plus some decimal places to be obtained by a lookup table, while the iteration of the remaining decimal part is performed by CORDIC iteration. This scheme can flexibly replace the operation of the iteration calculation unit with a lookup table, thus reducing the number of iterations of the iteration calculation unit. This method can reduce computational latency. In addition, for parallel architectures, reducing the number of iterations can also reduce hardware resources accordingly, and obtain high-precision calculation results.

[0145] In some embodiments of this application, such as Figure 9 The diagram shows a flowchart of another low-latency, high-precision CORDIC cell design method provided in this application embodiment. This method can be implemented through steps S301 to S308. Steps S301 to S304 and S201 to S204 have the same content, and steps S307 to S308 and S207 to S208 have the same content, which will not be repeated here. In step S305, the iteration direction value angle_sgn and the iteration value values ​​x0' and y0' in the angle iteration ROM are read according to the angle range encoding value. In step S306, z0' is calculated based on the angle calculator and the parameter angle_sgn. Furthermore, Figure 9 The diagram shows the angle range, address information, and angle sign (angle_sgn) corresponding to the integer part of z0 stored in the angle iteration ROM, as well as the angle range, address information, and position coordinates x0' and y0' corresponding to the integer part of z0 stored in the iteration value ROM.

[0146] For high-precision angle data, which contains both integer and decimal parts, with the decimal part having a relatively large number of digits, calculations show that the integer part can generally be completed in 6 iterations, while the two decimal places can generally be completed in 12 iterations. Taking the integer part iteration using a lookup table as an example... Figure 9 The design in the text will be explained in detail:

[0147] (1) Numerical comparator

[0148] The function of the numerical comparator is to compare the numerical value with the threshold values ​​of each range, determine the range to which the angle belongs, and encode it. Figure 9 Taking the integer part iteration using a lookup table as an example, the integer part of the angle data, i.e., 0° to 89°, is taken into the numerical comparator. For example, when calculating the sine and cosine function values ​​of 48.798984°, its integer part is 48°, which falls within the angle range of 47° to 50°. The encoding value for this angle range is 5'd13. This encoding value will be used as the address for subsequent access to storage resources.

[0149] (2) Storage design and data storage and retrieval

[0150] Two storage spaces are designed, named Angle Iteration ROM and Iteration Value ROM, respectively, to store the angle direction (angle_sgn) of each of the six iterations of the integer part, and x0' and y0' after the six iterations of the integer part. The storage address index is consistent with the encoding of the angle range, and the data can be directly read by comparing the encoded value 5'd13 using a data comparator. In the figure, the contents corresponding to 5'd13 in the Angle Iteration Direction ROM and Iteration Value ROM are angle_sgn = 110001 and x0' = 0.66102811, y0' = 0.750247537, respectively. The storage space size of Angle Iteration ROM and Iteration Value ROM is determined by the corresponding data volume. For the sake of simplicity and clarity, fixed-point data is not considered in this application.

[0151] (3) Angle calculator

[0152] Calculate z0' using the read angle_sgn. The calculation method is as follows: The counter cnt controls the sequential reading of values ​​as follows... Figure 10 The angle values ​​in the iterative angle ROM (equivalent to the "second iterative angle storage table" in other embodiments) shown are stored in the angle ROM. The angle ROM stores the rotation angle corresponding to different iteration numbers. The angle calculator is controlled according to angle_sgn: 1 indicates that the iteration is a counterclockwise rotation, corresponding to the operation "-", and 0 indicates that the iteration is a clockwise rotation, corresponding to the operation "+". After calculation, z0' = 48.798984° - 45° - 26.56505118° + 14.03624347° + 7.12501635° + 3.57633437° - 1.78991061° = 0.1816164°.

[0153] (4) CORDIC Calculation Unit

[0154] The calculated z0' and the table-lookup values ​​x0' and y0' are fed into commonly used serial or parallel CORDIC computation units for iterative calculation of the remaining fractional parts. This example uses 16 parallel pipelined iterative units. After 16 iterations, the angle error is 9.68 x 10⁻⁶, the function values ​​sin = 0.752461434; cos = 0.65875398, and the function value error is approximately 7.7 x 10⁻⁵.

[0155] This design uses a lookup table and 16 parallel pipelined processing units to achieve the effect of 23 parallel pipelined processing units. Through optimized design, computational latency and hardware resources are reduced, and high-precision computation results are obtained.

[0156] like Figure 11 The diagram shown is a flowchart illustrating another low-latency, high-precision CORDIC cell design method provided in this application embodiment. This method can be implemented through steps S401 to S408. Steps S401 to S404 and S301 to S304 have the same content, as do steps S407 to S408 and S307 to S308. The difference lies only in steps S405 and S406. In S405, the iterative angle value z in the angle iteration ROM is read according to the angle range encoding value. m The iteration values ​​are x0' and y0' in the ROM, while in step S305, the iteration direction value angle_sgn is read from the angle iteration ROM, and in S406, the parameter z is used. m z0' is calculated from z0, while in S306, z0' is calculated from z0 using the parameter angle_sgn.

[0157] Figure 11 and Figure 9 The storage design and implementation of the angle calculator differ, but we will still use a lookup table to iterate over the integer part as an example. Figure 11 As shown, the angle iteration ROM stores the angle z obtained after the first six iterations. mFor example, calculating the sine and cosine function values ​​of 48.798984°, the integer part is 48°, belonging to the angle range of 47° to 50°, and the encoded value of this angle range is 5'd13. Accessing the stored angle iteration ROM yields 48.6173676°. The angle calculator performs the calculation z0' = z0 - zm = 48.798984° - 48.6173676° = 0.1816164°. Using x0', y0', and z0' as inputs, subsequent CORDIC calculation units complete the iteration. Similarly, 16 parallel pipelined iteration units are used. After 16 iterations, the angle error is 9.68 x 10⁻⁶, the function values ​​sin = 0.752461434; cos = 0.65875398, and the function value error is approximately 7.7 x 10⁻⁵.

[0158] It should be noted that, Figure 9 and Figure 11 The example shown only illustrates the result of the integer part of the iteration (six iterations) obtained from the lookup table. In actual design, one can flexibly design whether lookup table data iteration is needed, flexibly design alternative iteration levels in the lookup table, and flexibly match subsequent iterations to achieve the desired design effect.

[0159] This application proposes a low-latency, high-precision CORDIC algorithm unit design method. This method combines a lookup table approach with CORDIC calculations, overcoming the drawbacks of CORDIC algorithms such as numerous iterations and slow convergence. Furthermore, this method is compatible with schemes using only CORDIC iterations. In this method, the lookup table stores the calculation results of the first few CORDIC algorithm iterations, and the CORDIC calculation unit performs subsequent iterations. The software can control whether to use the lookup table results to replace the previous CORDIC calculations. In practical designs, the integer part of the angle, or the integer and some decimal places of the iteration results, are typically stored in the storage resources. If it is an integer part, the storage resources store the results after the first six iterations. By combining the lookup table approach with CORDIC, the number of iterations can be reduced, and angle convergence can be accelerated. The iteration effect implemented by the lookup table is not limited; it is possible to jump directly to CORDIC iteration without using the lookup table, or to use the lookup table for partial iterations and then continue with CORDIC iterations. This approach is more flexible and can also reduce computational latency and achieve higher precision with fewer hardware resources.

[0160] This application provides a trigonometric function calculation device. Figure 12 This is a schematic diagram of the composition structure of a trigonometric function calculation device provided in an embodiment of this application, as shown below. Figure 12 As shown, the trigonometric function calculation device 500 includes:

[0161] The first processing module 501 is used to split the angle to be solved into a first angle if the angle to be solved corresponding to the trigonometric function meets the preset conditions; the first angle includes the integer part of the angle to be solved.

[0162] The first determining module 502 is used to determine the iteration information corresponding to the first angle from the iteration information storage table;

[0163] The second determining module 503 is used to determine the remaining solving angles corresponding to the angle to be solved based on the iteration information;

[0164] The first iterative calculation module 504 is used to perform iterative calculations on the remaining solution angles using the coordinate rotation digital calculation CORDIC unit to obtain the solution results corresponding to the angles to be solved.

[0165] In some embodiments, the iteration information storage table includes a first iteration angle storage table, wherein the iteration information includes an angle rotation direction identifier during iteration based on the first angle or a second angle iterated based on the first angle; the first determining module 502 includes:

[0166] The first acquisition submodule is used to input the first angle into a numerical comparator to obtain the angle range corresponding to the first angle and the identification information corresponding to the angle range;

[0167] The first determining submodule is used to determine the angle rotation direction identifier or the second angle from the first iterative angle storage table based on the identification information; the angle rotation direction identifier includes at least one.

[0168] In some embodiments, the second determining module 503 includes:

[0169] The second determining submodule is used to determine the remaining solution angle based on the first angle, at least one preset iteration angle stored in the second iteration angle storage table corresponding to the CORDIC unit, and the angle rotation direction identifier; the angle rotation direction identifier represents the rotation direction corresponding to the corresponding preset iteration angle in the circular system rotation mode.

[0170] In some embodiments, the second determining module 503 further includes:

[0171] The third determining submodule is used to determine the remaining solving angles based on the second angle and the angle to be solved.

[0172] In some embodiments, the iterative information storage table includes an iterative coordinate storage table, and the iterative information includes a first position coordinate value after iteration based on the first angle; the first determining module 502 further includes:

[0173] The second acquisition submodule is used to input the first angle into a numerical comparator to obtain the angle range corresponding to the first angle and the identification information corresponding to the angle range.

[0174] The fourth determining submodule is used to determine the first position coordinate value from the iterative coordinate storage table based on the identification information.

[0175] In some embodiments, the solution result includes the trigonometric function value and angle error value corresponding to the angle to be solved; the first iterative calculation module 504 includes:

[0176] The first iterative calculation submodule is used to input the first position coordinate value and the remaining solution angle into the CORDIC unit for iterative calculation until the convergence condition is met, and to obtain the trigonometric function value and angle error value corresponding to the solution angle.

[0177] In some embodiments, the first processing module 501 includes:

[0178] The fifth determining submodule is used to determine the integer part and the fractional part of the angle to be solved;

[0179] A splitting submodule is used to split the decimal part into a first subpart and a second subpart;

[0180] The sixth determining submodule is used to determine the angle corresponding to the integer part as the first angle, or to determine the angle corresponding to the integer part and the angle corresponding to the first subpart as the first angle, or to determine the angle corresponding to the integer part and the angle corresponding to the second subpart as the first angle.

[0181] In some embodiments, the trigonometric function calculation device 500 further includes:

[0182] The second acquisition module is used to acquire the angle to be solved;

[0183] The third determining module is used to determine whether the angle to be solved meets the preset conditions based on the number of decimal places corresponding to the angle to be solved.

[0184] In some embodiments, the third determining module includes:

[0185] The seventh determination submodule is used to determine that the angle to be solved satisfies the preset condition if the number of decimal places of the angle to be solved is greater than a preset threshold.

[0186] In some embodiments, the third determining module includes:

[0187] The eighth determination submodule is used to determine that the angle to be solved does not meet the preset condition if the number of decimal places of the angle to be solved is less than or equal to a preset threshold.

[0188] In some embodiments, the trigonometric function calculation device 500 further includes:

[0189] The third acquisition module is used to acquire the initial position coordinates of the angle to be solved if the angle to be solved corresponding to the trigonometric function does not meet the preset condition.

[0190] The fourth acquisition module is used to input the angle to be solved and the initial position coordinates into the CORDIC unit to obtain the solution result corresponding to the angle to be solved.

[0191] It should be noted that the description of the trigonometric function calculation device in this application is similar to the description of the corresponding method embodiment described above, and has similar beneficial effects as the method embodiment; therefore, it will not be repeated. For technical details not disclosed in this device embodiment, please refer to the description of the method embodiment in this application for understanding.

[0192] It should be noted that, in the embodiments of this application, if the above-described trigonometric function calculation method is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to related solutions, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.

[0193] Accordingly, embodiments of this application provide a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the trigonometric function calculation method provided in the above embodiments.

[0194] This application also provides a device for calculating trigonometric functions. Figure 13 This is a schematic diagram of the composition structure of a trigonometric function calculation device provided in an embodiment of this application, as shown below. Figure 13As shown, the trigonometric function calculation device 600 includes: a memory 601, a processor 602, a communication interface 603, and a communication bus 604. The memory 601 stores instructions for performing trigonometric function calculations; the processor 602 executes the executable trigonometric function calculation instructions stored in the memory 601 to implement the trigonometric function calculation method provided in the above embodiment.

[0195] The descriptions of the above embodiments of the trigonometric function calculation device and storage medium are similar to those of the above method embodiments, and have similar beneficial effects. For technical details not disclosed in the embodiments of the trigonometric function calculation device and storage medium of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0196] It should be noted that, in this document, the term "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising at least one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0197] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.

[0198] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.

[0199] In addition, all functional units in the embodiments of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the above-mentioned integrated units can be implemented in the form of hardware or in the form of hardware plus software functional units.

[0200] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0201] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a product to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0202] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for calculating trigonometric functions, characterized in that, include: If the angle to be solved corresponding to the trigonometric function meets the preset conditions, the angle to be solved is split to obtain the first angle; The first angle includes the integer part of the angle to be solved; Determine the iteration information corresponding to the first angle from the iteration information storage table; Based on the iteration information, the remaining solution angles corresponding to the angle to be solved are determined; The remaining solution angles are iteratively calculated using a coordinate rotation digital computation CORDIC unit to obtain the solution results corresponding to the angles to be solved.

2. The method according to claim 1, characterized in that, The iteration information storage table includes a first iteration angle storage table, and the iteration information includes an angle rotation direction identifier or a second angle iterated based on the first angle during the iteration process based on the first angle. Determining the iteration information corresponding to the first angle from the iteration information storage table includes: The first angle is input into a numerical comparator to obtain the angle range corresponding to the first angle and the identification information corresponding to the angle range; Based on the identification information, the angle rotation direction identifier or the second angle is determined from the first iterative angle storage table; the angle rotation direction identifier includes at least one.

3. The method according to claim 2, characterized in that, The step of determining the remaining solution angles corresponding to the angle to be solved based on the iteration information includes: Based on the first angle, at least one preset iteration angle stored in the second iteration angle storage table corresponding to the CORDIC unit, and the angle rotation direction identifier, the remaining solution angle is determined; the angle rotation direction identifier represents the rotation direction corresponding to the corresponding preset iteration angle in the circular system rotation mode.

4. The method according to claim 2, characterized in that, The step of determining the remaining solution angles corresponding to the angle to be solved based on the iteration information includes: Based on the second angle and the angle to be solved, the remaining angles to be solved are determined.

5. The method according to claim 1, characterized in that, The iterative information storage table includes an iterative coordinate storage table, and the iterative information includes the first position coordinate value after iteration based on the first angle. Determining the iteration information corresponding to the first angle from the iteration information storage table includes: The first angle is input into a numerical comparator to obtain the angle range corresponding to the first angle and the identification information corresponding to the angle range; Based on the identification information, the first position coordinate value is determined from the iterative coordinate storage table.

6. The method according to claim 5, characterized in that, The solution results include the trigonometric function values ​​and angle error values ​​corresponding to the angle to be solved; The CORDIC unit, which utilizes coordinate rotation digital computation, iteratively calculates the remaining solution angles to obtain the solution results corresponding to the angles to be solved, including: The first position coordinates and the remaining solution angle are input into the CORDIC unit for iterative calculation until the convergence condition is met, and the trigonometric function value and angle error value corresponding to the solution angle are obtained.

7. The method according to claim 1, characterized in that, The step of splitting the angle to be solved to obtain the first angle includes: Determine the integer and fractional parts of the angle to be solved; The fractional part is split into a first sub-part and a second sub-part; The angle corresponding to the integer part is determined as the first angle, or the angle corresponding to the integer part and the angle corresponding to the first sub-part are determined as the first angle, or the angle corresponding to the integer part and the angle corresponding to the second sub-part are determined as the first angle.

8. The method according to claim 1, characterized in that, The method further includes: Obtain the angle to be solved; Based on the number of decimal places corresponding to the angle to be solved, determine whether the angle to be solved meets the preset condition.

9. The method according to claim 8, characterized in that, The step of determining whether the angle to be solved meets the preset condition based on the number of decimal places corresponding to the angle to be solved includes: If the number of decimal places of the angle to be solved is greater than a preset threshold, it is determined that the angle to be solved meets the preset condition.

10. The method according to claim 8, characterized in that, The step of determining whether the angle to be solved meets the preset condition based on the number of decimal places corresponding to the angle to be solved includes: If the number of decimal places of the angle to be solved is less than or equal to a preset threshold, it is determined that the angle to be solved does not meet the preset condition.

11. The method according to any one of claims 1 to 10, characterized in that, The method further includes: If the angle to be solved corresponding to the trigonometric function does not meet the preset condition, obtain the initial position coordinate value corresponding to the angle to be solved; The angle to be solved and the initial position coordinates are input into the CORDIC cell to obtain the solution result corresponding to the angle to be solved.

12. A trigonometric function calculation device, characterized in that, include: The first processing module is used to split the angle to be solved into a first angle if the angle to be solved corresponding to the trigonometric function meets the preset conditions. The first angle includes the integer part of the angle to be solved; The first determining module is used to determine the iteration information corresponding to the first angle from the iteration information storage table; The second determining module is used to determine the remaining solving angles corresponding to the angle to be solved based on the iteration information; The first iterative calculation module is used to perform iterative calculations on the remaining solution angles using the coordinate rotation digital calculation CORDIC unit to obtain the solution results corresponding to the angles to be solved.

13. A trigonometric function calculation device, characterized in that, include: Processor and memory; among which, The memory is used to store computer programs that can run on the processor; The processor is configured to perform the method as described in any one of claims 1 to 11 when running the computer program.

14. A computer-readable storage medium, characterized in that, The storage medium stores computer program code, which, when executed by a computer, performs the method described in any one of claims 1 to 11.