Operation component and method based on cordic algorithm
By introducing shifters and selectors into the Cordic algorithm, the selection of addition and subtraction is optimized, reducing the number of adders and subtractors required in each iteration, solving the problem of high resource consumption when calculating angle rotation, and improving the calculation speed.
Patent Information
- Application Number
- PCT/CN2024/118577
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-04-30
- Filing Date
- 2024-09-12
- Publication Date
- 2025-11-06
AI Technical Summary
Existing technologies consume significant resources when performing angle rotation calculations, failing to effectively address the issue of maximizing resource utilization.
By employing a computational component based on the Cordic algorithm, and by setting first and second shifters, an adder selector, and a subtraction selector, appropriate data is selected for addition or subtraction operations, reducing the number of adders and subtractors required for each iteration and saving resource consumption.
By reducing the number of adders and subtractors required in each iteration, the resource consumption for angle rotation calculations is saved, thus improving the computation speed of the Cordic algorithm.
Smart Images

Figure CN2024118577_06112025_PF_FP_ABST
Abstract
Description
Operation component and method based on cordic algorithm
[0001] This application claims priority from the Chinese patent application No. 2024105425035, filed on April 30, 2024, and entitled "Operation component and method based on cordic algorithm", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0002] Embodiments of the present application relate to the chip field, in particular, to an operation component and method based on Cordic algorithm. BACKGROUND
[0003] In hardware development, the resource utilization needs to be refined, and the related art does not maximize the resource utilization when implementing a parallel structure. Moreover, the related art consumes a large amount of resources when performing angle rotation calculation.
[0004] The related art has not yet proposed an effective solution to the above technical problems.
[0005] SUMMARY
[0006] Embodiments of the present application provide an operation component and method based on Cordic algorithm to at least solve the problem of large resource consumption when performing angle rotation calculation in the related art.
[0007] According to an embodiment of the present application, an operation component based on Cordic algorithm is provided, which is configured to implement one iteration operation. The operation component comprises: a first shifter configured to shift an addition iteration result obtained in a previous iteration order according to a current iteration order to obtain first shift data; a second shifter configured to shift a subtraction iteration result obtained in the previous iteration order according to the current iteration order to obtain second shift data; an addition selector configured to select two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shift data and the second shift data as addition input data according to a rotation direction corresponding to the current iteration order; a subtraction selector configured to select two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shift data and the second shift data as subtraction input data according to the rotation direction corresponding to the current iteration order; the adder is configured to determine an addition iteration result corresponding to the current iteration order according to the addition input data; and the subtractor is configured to determine a subtraction iteration result corresponding to the current iteration order according to the subtraction input data.
[0008] In one example embodiment, the add selector comprises: a first add sub-selector configured to select one of the add iteration result of the previous iteration order and the subtract iteration result of the previous iteration order as one of the add input data according to the rotation direction corresponding to the current iteration order; and a second add sub-selector configured to select one of the first shift data and the second shift data as another of the add input data according to the rotation direction corresponding to the current iteration order; and the subtract selector comprises: a first subtract sub-selector configured to select one of the add iteration result of the previous iteration order and the subtract iteration result of the previous iteration order as one of the subtract input data according to the rotation direction corresponding to the current iteration order; and a second subtract sub-selector configured to select one of the first shift data and the second shift data as another of the subtract input data according to the rotation direction corresponding to the current iteration order.
[0009] In one example embodiment, the operation component further comprises an angle subtractor configured to obtain a remaining rotation angle corresponding to the current iteration order according to the target rotation angle and each rotation angle corresponding to the iteration orders; and the add selector and the subtract selector are configured to determine the rotation direction corresponding to the current iteration order according to the remaining rotation angle.
[0010] In one example embodiment, the add selector and the subtract selector are configured to determine the rotation direction corresponding to the current iteration order as counterclockwise when the remaining rotation angle is positive, and determine the rotation direction corresponding to the current iteration order as clockwise when the remaining rotation angle is negative.
[0011] In one example embodiment, a bit width of the angle subtractor corresponding to the current iteration order is less than or equal to a bit width of the angle subtractor corresponding to the previous iteration order.
[0012] In one example embodiment, the operation component further comprises: a first flip-flop configured to receive the add iteration result corresponding to the current iteration order, and output the add iteration result corresponding to the current iteration order under triggering of a first clock pulse; and a second flip-flop configured to receive the subtract iteration result corresponding to the current iteration order, and output the subtract iteration result corresponding to the current iteration order under triggering of a second clock pulse.
[0013] According to another embodiment of the present application, a Cordic algorithm-based operation method is provided for implementing one iteration operation, the method comprising: shifting an addition iteration result obtained in a previous iteration order according to a current iteration order to obtain first shift data; shifting a subtraction iteration result obtained in the previous iteration order according to the current iteration order to obtain second shift data; selecting two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shift data and the second shift data as addition input data according to a rotation direction corresponding to the current iteration order; selecting two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shift data and the second shift data as subtraction input data according to the rotation direction corresponding to the current iteration order; determining an addition iteration result corresponding to the current iteration order according to the addition input data; and determining a subtraction iteration result corresponding to the current iteration order according to the subtraction input data.
[0014] In one example embodiment, selecting two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shift data and the second shift data as addition input data according to a rotation direction corresponding to the current iteration order comprises: selecting one data from the addition iteration result obtained in the previous iteration order and the subtraction iteration result obtained in the previous iteration order as one of the addition input data according to the rotation direction corresponding to the current iteration order; and selecting one data from the first shift data and the second shift data as the other of the addition input data according to the rotation direction corresponding to the current iteration order; and selecting two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shift data and the second shift data as subtraction input data according to the rotation direction corresponding to the current iteration order comprises: selecting one data from the addition iteration result obtained in the previous iteration order and the subtraction iteration result obtained in the previous iteration order as one of the subtraction input data according to the rotation direction corresponding to the current iteration order; and selecting one data from the first shift data and the second shift data as the other of the subtraction input data according to the rotation direction corresponding to the current iteration order.
[0015] According to still another embodiment of the present application, a computer readable storage medium is also provided, and the computer readable storage medium stores a computer program, wherein the computer program is configured to execute the steps in any of the method embodiments described above when running.
[0016] According to a further embodiment of the present application, an electronic device is also provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor being arranged to run the computer program to perform the steps of any of the method embodiments described above.
[0017] According to the present application, since the operation component comprises a first shifter configured to shift the addition iteration result obtained in the previous iteration order according to the current iteration order to obtain first shifted data, a second shifter configured to shift the subtraction iteration result obtained in the previous iteration order according to the current iteration order to obtain second shifted data, an addition selector configured to select two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shifted data and the second shifted data as addition input data according to the rotation direction corresponding to the current iteration order, a subtraction selector configured to select two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shifted data and the second shifted data as subtraction input data according to the rotation direction corresponding to the current iteration order, an adder configured to determine the addition iteration result corresponding to the current iteration order according to the addition input data, and a subtractor configured to determine the subtraction iteration result corresponding to the current iteration order according to the subtraction input data, the operation relationship selected by the addition selector and the subtraction selector can save a group of adders and subtractors. Moreover, each iteration can reduce the resource consumption of a group of adders and subtractors compared with the traditional method, and the higher the rotation accuracy, the more resources are saved. Therefore, the problem of large resource consumption in angle rotation calculation in the related art can be solved, and the effect of saving the resource consumption of angle rotation calculation and improving the speed of Cordic algorithm operation can be achieved. BRIEF DESCRIPTION OF DRAWINGS
[0018] FIG. 1 is a schematic diagram of the principle of a Cordic algorithm according to an embodiment of the present application;
[0019] FIG. 2 is a schematic diagram of parallel structure calculation in the related art according to an embodiment of the present application;
[0020] FIG. 3 is a structural diagram of an operation component based on a Cordic algorithm according to an embodiment of the present application;
[0021] FIG. 4 is a structural diagram of an operation component based on a Cordic algorithm in the related art according to an embodiment of the present application;
[0022] FIG. 5 is a hardware structural block diagram of a mobile terminal of a Cordic algorithm-based operation method according to an embodiment of the present application;
[0023] FIG. 6 is a flowchart of a Cordic algorithm-based operation method according to an embodiment of the present application;
[0024] FIG. 7 is a diagram of angle values according to an embodiment of the present application. DETAILED DESCRIPTION
[0025] Hereinafter, embodiments of the present application will be described in detail with reference to the accompanying drawings and in conjunction with embodiments.
[0026] It should be noted that the terms "first", "second", and the like in the description and claims of the present application and the above-described accompanying drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence.
[0027] In the present embodiment, an operation component based on a Cordic algorithm is provided, which is configured to implement one iteration operation, and the operation component comprises:
[0028] A first shifter configured to shift the addition iteration result obtained in the previous iteration order according to the current iteration order to obtain first shifted data;
[0029] A second shifter configured to shift the subtraction iteration result obtained in the previous iteration order according to the current iteration order to obtain second shifted data;
[0030] An addition selector configured to select two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shifted data, and the second shifted data as addition input data according to the rotation direction corresponding to the current iteration order;
[0031] A subtraction selector configured to select two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shifted data, and the second shifted data as subtraction input data according to the rotation direction corresponding to the current iteration order;
[0032] An adder configured to determine the addition iteration result corresponding to the current iteration order according to the addition input data;
[0033] A subtractor configured to determine the subtraction iteration result corresponding to the current iteration order according to the subtraction input data.
[0034] The above components include a first shifter, configured to shift the addition iteration result obtained in the previous iteration order according to the current iteration order to obtain first shifted data; a second shifter, configured to shift the subtraction iteration result obtained in the previous iteration order according to the current iteration order to obtain second shifted data; an addition selector, configured to select two data as addition input data from the addition iteration result, the subtraction iteration result, the first shifted data, and the second shifted data according to the rotation direction corresponding to the current iteration order; a subtraction selector, configured to select two data as subtraction input data from the addition iteration result, the subtraction iteration result, the first shifted data, and the second shifted data according to the rotation direction corresponding to the current iteration order; an adder, configured to determine the addition iteration result corresponding to the current iteration order based on the addition input data; and a subtractor, configured to determine the subtraction iteration result corresponding to the current iteration order based on the subtraction input data. By using addition and subtraction selectors to select the operational relationships, a set of adders and subtractors can be saved. Furthermore, each iteration reduces the resource consumption of one set of adders and subtractors compared to traditional methods; the higher the rotation precision, the greater the resource savings. Therefore, this solves the problem of high resource consumption in angle rotation calculations in related technologies, achieving the effect of saving resources in angle rotation calculations and improving the speed of the Cordic algorithm.
[0035] Optionally, the Cordic (Coordinate Rotation Digital Computer) algorithm is an iterative algorithm for calculating a large number of mathematical functions (such as trigonometric, logarithmic, and exponential functions). It primarily utilizes rotational transformations to perform these mathematical operations. The Cordic algorithm is mainly used in calculators, digital signal processors (DSPs), graphics processing units (GPUs), and other embedded systems that require complex mathematical operations. The Cordic algorithm approximates the desired mathematical function value through a series of iterative steps. In each iteration, the result of the previous iteration is adjusted according to the current iteration order. A schematic diagram of the Cordic algorithm is shown in Figure 1. The core of the Cordic algorithm is pseudo-rotation, which refines the rotation angle θ into several fixed-size angles θ. i θ is specified i Satisfy tanθ i =2^-i, through a series of iterative rotations, each rotation being θ i , where i is the iteration order, and ∑θ is defined as ithe range of the rotation angle θ is [-99.7, 99.7]. If θ is greater than this range, it can be converted to an angle within the range through a trigonometric operation. The hardware implementation of the Cordic algorithm can be divided into serial and parallel structures. The serial structure occupies the least resources, which is due to the time-sharing multiplexing of the Cordic processing unit. Therefore, the control unit design is slightly complex, the timing control is relatively cumbersome, and the system processing speed is relatively low. As shown in FIG. 2, for the parallel structure, the input can be processed in a pipeline and the output can be output in a pipeline, and the processing speed is fast enough. At the same time, the resources consumed by the parallel structure also increase significantly.
[0036] Optionally, the application scenario of the present embodiment is the case of implementing angle rotation in hardware using the Cordic algorithm, for example, in the implementation of FFT Fourier transform in 5G NR, the operation component based on the Cordic algorithm is applied to solve the angle rotation.
[0037] Optionally, in the Cordic algorithm, the shift operation is one of the key steps in the iterative process of the algorithm. The first shifter and the second shifter refer to the shifters used in the same iteration. They shift the result of the last iteration according to the specific coefficient of the current iteration. The shift operation can be an arithmetic shift or a logical shift. After the shift operation is completed, the new data obtained will be used as the input of the adder-subtractor. Through continuous iteration, the Cordic algorithm gradually approaches the value of the target function until the required accuracy is reached. Since the shift operation is relatively simple, the Cordic algorithm avoids complex multiplication and division operations, and therefore is very efficient in hardware implementation.
[0038] Optionally, the addition selector selects appropriate data for subsequent addition operation according to the rotation direction corresponding to the current iteration order. For example, if the rotation direction corresponding to the current iteration is counterclockwise rotation, the addition selector may select the addition iteration result and the second shift data; if it is clockwise rotation, it may select the subtraction iteration result and the first shift data. For another example, if the rotation direction corresponding to the current iteration is counterclockwise rotation, the addition selector may select the subtraction iteration result and the first shift data; if it is clockwise rotation, it may select the addition iteration result and the second shift data. The output of the addition selector is the two inputs of the adder, which will be used to calculate the addition iteration result corresponding to the current iteration order. Through the addition operation in each iteration and the corresponding shift operation, the Cordic algorithm gradually approaches the calculation target. The logic of the addition selector ensures that the algorithm can achieve complex mathematical operations through simple addition and shift operations without performing multiplication and division operations. The addition selector can be implemented through a multiplexer, which can select one or two of multiple inputs as the output according to the value of the selection signal.
[0039] Optionally, the subtractor selector functions similarly to the adder selector, but it is used to select appropriate data for a subtraction operation. The subtractor selector determines which two data from the given data set to select for a subtraction operation based on the rotation direction corresponding to the current iteration order. The subtractor selector selects two data from the adder iteration result, the subtractor iteration result, the first shifted data, and the second shifted data based on the rotation direction of the current iteration. For example, if the current iteration requires a clockwise rotation, it can select the adder iteration result and the second shifted data; if it requires a counterclockwise rotation, it can select the subtractor iteration result and the first shifted data. As another example, if the current iteration requires a counterclockwise rotation, it can select the adder iteration result and the second shifted data; if it requires a clockwise rotation, it can select the subtractor iteration result and the first shifted data. The output of the subtractor selector will be used as the two inputs to the subtractor for calculating the subtractor iteration result corresponding to the current iteration order. Through the subtraction operation in the iteration and the corresponding shift operation, the Cordic algorithm gradually approaches the value of the target function. The subtractor selector can be implemented by a digital multiplexer, which is a logic component that selects different inputs based on a selection signal.
[0040] For example, the adder selector and the subtractor selector determine the addition and subtraction relationship between abcd, where a corresponds to the adder iteration result obtained in the previous iteration order, b corresponds to the second shifted data, c corresponds to the subtractor iteration result obtained in the previous iteration order, and d corresponds to the first shifted data. Based on the sign bit of the angle, there are two calculations: 1) a+b, c-d; 2) a-b, c+d. Based on the sign bit of the angle, the selector performs 2-to-1 selection, thereby saving a set of adder and subtractor.
[0041] Through the adder and subtractor selector logic, the Cordic algorithm can implement complex mathematical operations without performing multiplication and division, but only using addition, subtraction, and shift operations, thereby improving computational efficiency.
[0042] Optionally, in the operation component of the Cordic algorithm, the adder and the subtractor are the core components that perform actual numerical operations. They perform corresponding addition or subtraction operations based on the input data provided by the selector to determine the iteration result of the current iteration order.
[0043] The adder is configured to add the two input data provided by the adder selector to obtain the adder iteration result. The adder selector selects two data based on the rotation direction corresponding to the current iteration order. The adder iteration result of the current iteration order, which will be used in the next iteration or as part of the final output.
[0044] The subtractor is configured to subtract the two input data provided by the subtractor selector to obtain a subtraction iteration result. The subtractor selector selects the two data according to the rotation direction corresponding to the current iteration order. The subtraction iteration result of the current iteration order, which will also be used for the next iteration or as part of the final output.
[0045] In each iteration, the adder and the subtractor perform operations according to the decision of the selector. The iteration process is repeated until a predetermined number of iterations is reached or a specific accuracy requirement is met. The adder and the subtractor can be simple digital circuits, such as a combination of half adders and full adders, configured to perform binary addition operations. The subtractor can usually be implemented by an adder and an addition operation (i.e., adding a negative number, which is a complement).
[0046] For example, as shown in FIG. 3, a and c are used to represent the result data after each iteration, a0and c0represent the starting values of the iteration, which are the starting coordinate values of the input, a0represents the real part, and c0represents the imaginary part; b and d are used to represent the results after shifting, and no shifting is required in the first iteration, so b0is equal to c0, and d0is equal to a0; after each iteration, the count is incremented, and finally a24and c24are obtained. The input of the shifter is the output of the adder and the subtractor in the operation component corresponding to the previous iteration order, that is, a and c, and a and c also enter the selector; then the output of the shifter, as the candidate input of the adder and the subtractor of the current iteration, that is, b and d, also enters the selector.
[0047] In an exemplary embodiment, the adder selector includes: a first adder sub-selector configured to select one of the addition iteration result obtained from the previous iteration order and the subtraction iteration result obtained from the previous iteration order as an adder input data according to the rotation direction corresponding to the current iteration order; and a second adder sub-selector configured to select one of the first shifted data and the second shifted data as another adder input data according to the rotation direction corresponding to the current iteration order.
[0048] Optionally, the first adder sub-selector is configured to select one of the adder iteration result and the subtracter iteration result from the previous iteration order based on the rotation direction corresponding to the current iteration order. The adder iteration result and the subtracter iteration result are obtained by the adder and the subtracter in the previous iteration. The selected data is used as one input data of the adder. The second adder sub-selector is configured to select one of the first shifted data and the second shifted data based on the rotation direction corresponding to the current iteration order. The first shifted data and the second shifted data are calculated by the shifter based on the adder and the subtractor in the previous iteration. The selected data is used as another input data of the adder. Each sub-selector includes a selection logic which decides which input to select based on the rotation direction signal of the current iteration. For example, if the rotation direction is counterclockwise, the first adder sub-selector can select the adder iteration result, and the second adder sub-selector can select the second shifted data.
[0049] Each sub-selector can be implemented as a multiplexer which selects one input as the output based on a selection signal (usually a control bit or a group of control bits).
[0050] For example, as shown in FIG. 3, the two selectors connected to the adder on the left side are the first adder sub-selector and the second adder sub-selector. The first adder sub-selector is connected to a0 and c0, and the second adder sub-selector is connected to b0 and d0. For example, the first adder sub-selector selects a0, and the second adder sub-selector selects b0, and the adder performs a0+b0 operation. Compared with the operation process in the related art as shown in FIG. 4 (a hardware circuit diagram for parallel processing of cordic calculation, 5 adders are consumed for each iteration calculation, and the angle calculation is fixed bit width, which needs to be repeated 24 times when the maximum iteration is 24 times, and the adder resource consumption is very large). The embodiment only needs 3 adders for each iteration calculation, reducing 2 adders. Moreover, for the angle calculation, the bit width is reduced with the increase of the iteration number, and the maximum possible resource consumption is reduced without loss of calculation accuracy. The embodiment divides the adder selector into two sub-selectors, and the algorithm design becomes more flexible, and the performance and response time of each selector can be optimized independently.
[0051] The subtractor includes: a first subtractor sub-selector configured to select one of the adder iteration result from the previous iteration order and the subtracter iteration result from the previous iteration order as one subtractor input data based on the rotation direction corresponding to the current iteration order; and a second subtractor sub-selector configured to select one of the first shifted data and the second shifted data as another subtractor input data based on the rotation direction corresponding to the current iteration order.
[0052] Optionally, the first subtraction sub-selector selects one data from the addition iteration result and the subtraction iteration result according to the rotation direction corresponding to the current iteration order. The addition iteration result and the subtraction iteration result are generated by the adder and the subtractor in the previous iteration order. The selected data is used as one input of the subtractor. The second subtraction sub-selector selects one data from the first shift data and the second shift data according to the rotation direction corresponding to the current iteration order. The first shift data and the second shift data are generated by the shifter according to the addition result and the subtraction result of the previous iteration. The selected data is used as another input of the subtractor. Each sub-selector includes selection logic to determine which input to select according to the rotation direction signal of the current iteration. For example, if the rotation direction indicates clockwise, the first subtraction sub-selector can select the addition iteration result; if the rotation direction indicates counterclockwise, the subtraction iteration result can be selected. Each sub-selector can be implemented as a multiplexer which selects one or two inputs as the output according to the selection signal (usually a control bit or a group of control bits).
[0053] For example, as shown in FIG. 3, the two selectors connected with the subtractor on the left side are the first subtraction sub-selector and the second subtraction sub-selector. The first subtraction sub-selector is connected with a0 and c0, and the second subtraction sub-selector is connected with b0 and d0. For example, the first subtraction sub-selector selects c0, and the second subtraction sub-selector selects d0, then the subtractor performs the operation of c0-d0. Compared with the operation process in FIG. 4, the subtractor is also reduced, and the resource consumption is reduced.
[0054] By dividing the subtraction selector into two sub-selectors, the design of the algorithm becomes more modular, and the performance and response time of each selector can be optimized independently.
[0055] In one exemplary embodiment, the operation component further includes an angle subtractor configured to obtain a remaining rotation angle corresponding to the current iteration order according to the target rotation angle and each rotation angle corresponding to the iteration orders; and the addition selector and the subtraction selector are configured to determine the rotation direction corresponding to the current iteration order according to the remaining rotation angle.
[0056] Optionally, in the operation component of the Cordic algorithm, the angle subtractor is configured to calculate a remaining rotation angle corresponding to the current iteration order. The remaining rotation angle is the difference between the target rotation angle and the rotation angle that has been completed through the iteration process. The angle subtractor calculates the current remaining rotation angle by subtracting the rotation angle corresponding to the iteration order from the target rotation angle. In each iteration, the angle subtractor uses the current remaining rotation angle to determine the rotation direction and rotation amount of the next step. The iteration process is repeated until the remaining rotation angle is less than a certain pre-set accuracy threshold, at which point it is considered that the target rotation angle has been approximated. The angle subtractor can be a subtraction circuit capable of handling angle values. Since the angle values can be expressed in radians or degrees, the subtractor needs to be able to handle the corresponding numerical format. The angle subtractor ensures that the Cordic algorithm can update the remaining rotation angle after each iteration, thereby gradually approximating the target rotation angle.
[0057] Optionally, the addition selector and the subtraction selector are configured to determine that the rotation direction corresponding to the current iteration order is counterclockwise when the remaining rotation angle is positive, and to determine that the rotation direction corresponding to the current iteration order is clockwise when the remaining rotation angle is negative.
[0058] Optionally, the rotation angle corresponding to the iteration order i satisfies the relationship tan θ i = 2 -i , i starts from 0 and can take values as shown in FIG. 7.
[0059] Optionally, the adder selector and the subtractor selector determine the rotation direction of each iteration based on the positive or negative value of the remaining rotation angle. For example, the optional application of the adder selector and the subtractor selector in determining the rotation direction includes: remaining rotation angle: in each iteration of the Cordic algorithm, the current remaining rotation angle needs to be calculated, which is the difference between the target rotation angle and the rotation angle corresponding to the iteration order. Counterclockwise rotation: if the remaining rotation angle is positive, it means that the current vector needs to be rotated in the counterclockwise direction to approximate the target angle. Clockwise rotation: if the remaining rotation angle is negative, it means that the current vector needs to be rotated in the clockwise direction to approximate the target angle. When the remaining rotation angle is positive, the adder selector selects the appropriate data from the available data for addition operation to achieve counterclockwise rotation. The adder selector may select the addition iteration result of the previous iteration and the corresponding shift data to increase the angle in the current iteration. When the remaining rotation angle is negative, the subtractor selector selects the appropriate data from the available data for subtraction operation to achieve clockwise rotation. The subtractor selector may select the subtraction iteration result of the previous iteration and the corresponding shift data to decrease the angle in the current iteration. The adder and the subtractor perform the corresponding addition or subtraction operation according to the output of the selector, thereby achieving counterclockwise or clockwise rotation. Through the selection and rotation operation in each iteration, the Cordic algorithm gradually approximates the value of the target function. The adder selector and the subtractor selector ensure that each iteration is rotated in the correct direction to minimize the remaining rotation angle.
[0060] Through the cooperation of the adder selector and the subtractor selector, the Cordic algorithm can effectively determine the rotation direction of each iteration, whether counterclockwise or clockwise, aiming to reduce the remaining rotation angle until the required precision threshold is reached.
[0061] Optionally, the bit width of the angle subtractor corresponding to the current iteration order is less than or equal to the bit width of the angle subtractor corresponding to the previous iteration order.
[0062] In an exemplary embodiment, the operation component further comprises: a first flip-flop configured to receive the addition iteration result corresponding to the current iteration order, and output the addition iteration result corresponding to the current iteration order under the trigger of a first clock pulse; a second flip-flop configured to receive the subtraction iteration result corresponding to the current iteration order, and output the subtraction iteration result corresponding to the current iteration order under the trigger of a second clock pulse.
[0063] Optionally, the first flip-flop can also be configured to store the addition iteration result, and the second flip-flop can also be configured to store the subtraction iteration result, so as to be used in the next iteration. For example, as shown in FIG. 3, the flip-flop connected with the left addition device is the first flip-flop, and the first flip-flop is connected with CLK and rst_n. The flip-flop connected with the left subtraction device is the second flip-flop, and the second flip-flop is connected with CLK and rst_n. The work of the addition device and the subtraction device can be controlled by the triggering of the flip-flop. As shown in FIG. 3, the first flip-flop is connected with the first shifter, the selector 1 and the selector 3, and the second flip-flop is connected with the second shifter, the selector 2 and the selector 4. The outputs of the first shifter and the second shifter, i.e. b and d, also enter the selectors, and the iteration operation continues.
[0064] The present application will be described in detail below in combination with optional embodiments:
[0065] The Cordic algorithm used in the embodiment is used to obtain the coordinates after a given coordinate is rotated by a certain angle. The coordinates are expressed by complex numbers, the real part is the horizontal coordinate, and the imaginary part is the vertical coordinate. The final output result is a complex value. For example, for a given input complex number (x, y) and an input angle θ, the Cordic algorithm is used to obtain the complex value after rotation by θ. In hardware, the angle of each rotation is stored in a lookup table. The embodiment supports a maximum of 24 iterations, and the precision is 32 bits. First, the point is rotated to the first quadrant according to the trigonometric operation; then, the point is rotated according to the stored angle. After each rotation, the remaining rotation angle is reduced by the rotation angle. The angle subtractor with a precision of 32 bits is called once in each iteration. When the iteration number is 24, the angle subtractor is called 24 times. It should be noted that the iteration number and the precision are related to hardware resources. The greater the iteration number, the higher the precision, and the more hardware resources are consumed. This is a process of weighing the pros and cons. The precision of the calculation should meet the demand, and the resources should be saved as much as possible.
[0066] Further, in the embodiment, since the angle of each rotation is smaller and smaller, the bit occupied is smaller and smaller. In the calculation process, the bit width of the angle subtractor used in each iteration can be reduced gradually. When the iteration number is 24, the bit width of the angle subtractor in the last iteration can be changed to 8 bits. The reduction of the bit width of the angle subtractor has obvious effect on resource optimization.
[0067] In the process of operation based on the Cordic algorithm, for the calculation of the real part and the imaginary part of the coordinate point, 4 adders are needed in each iteration in the related scheme, and when the iteration is 24 times, 4*24=96 adders are used, and the higher the precision required, the larger the bit width of the adder. In the embodiment, by integrating the conditions, the number of adders used in each iteration calculation is reduced by 2 by using the complex selection method, and only 2 adders are needed for each iteration calculation, and when the iteration is 24 times, 2*24=48 adders are used, which greatly optimizes the consumption of hardware resources.
[0068] The method embodiments provided in the embodiments of the application can be executed in a mobile terminal, a computer terminal or similar computing device. Taking the case of running on a mobile terminal, FIG. 5 is a hardware structure block diagram of a mobile terminal of a Cordic algorithm-based operation method according to an embodiment of the application. As shown in FIG. 5, the mobile terminal can include one or more (only one is shown in FIG. 5) processors 502 (the processor 502 can include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 504 for storing data, wherein the mobile terminal can further include a transmission device 506 for communication function and an input and output device 508. Those skilled in the art can understand that the structure shown in FIG. 5 is only schematic, which does not limit the structure of the mobile terminal. For example, the mobile terminal can include more or fewer components than those shown in FIG. 5, or have a different configuration from that shown in FIG. 5.
[0069] The memory 504 can be used to store computer programs, for example, software programs of application software and modules, such as the computer program corresponding to the Cordic algorithm-based operation method in the embodiments of the application. The processor 502 executes various function applications and data processing by running the computer program stored in the memory 504, that is, implements the method described below. The memory 504 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 504 can further include a memory remotely arranged with respect to the processor 502, which can be connected to the mobile terminal through a network. Examples of the network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0070] The transmission device 506 is configured to receive or send data via a network. The network can be a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 506 comprises a network interface controller (NIC) configured to connect to other network devices via a base station to communicate with the Internet. In one example, the transmission device 506 can be a radio frequency (RF) module configured to communicate with the Internet via a wireless manner.
[0071] In the embodiment, a Cordic algorithm-based operation method is provided, and the operation method is used to implement one iteration operation. FIG. 6 is a flowchart of the Cordic algorithm-based operation method according to the embodiment of the present application. As shown in FIG. 6, the flowchart comprises the following steps:
[0072] In step S602, the addition iteration result obtained in the previous iteration order is shifted according to the current iteration order to obtain first shifted data.
[0073] In step S604, the subtraction iteration result obtained in the previous iteration order is shifted according to the current iteration order to obtain second shifted data.
[0074] In step S606, two data are selected from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shifted data and the second shifted data according to the rotation direction corresponding to the current iteration order to determine as addition input data.
[0075] In step S608, two data are selected from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shifted data and the second shifted data according to the rotation direction corresponding to the current iteration order to determine as subtraction input data.
[0076] In step S610, the addition iteration result corresponding to the current iteration order is determined according to the addition input data.
[0077] In step S612, the subtraction iteration result corresponding to the current iteration order is determined according to the subtraction input data.
[0078] By the above steps, the first shift data is obtained by shifting the addition iteration result of the previous iteration order according to the current iteration order; the second shift data is obtained by shifting the subtraction iteration result of the previous iteration order according to the current iteration order; two data are selected from the addition iteration result of the previous iteration order, the subtraction iteration result of the previous iteration order, the first shift data and the second shift data according to the rotation direction corresponding to the current iteration order to determine as the addition input data; two data are selected from the addition iteration result of the previous iteration order, the subtraction iteration result of the previous iteration order, the first shift data and the second shift data according to the rotation direction corresponding to the current iteration order to determine as the subtraction input data; the addition iteration result corresponding to the current iteration order is determined according to the addition input data; and the subtraction iteration result corresponding to the current iteration order is determined according to the subtraction input data. Therefore, the problem that resource consumption is relatively large when angle rotation calculation is performed in the related art can be solved, and the effect of saving resource consumption of angle rotation calculation and improving the speed of Cordic algorithm operation is achieved.
[0079] In one example embodiment, selecting two data from the addition iteration result of the previous iteration order, the subtraction iteration result of the previous iteration order, the first shift data and the second shift data according to the rotation direction corresponding to the current iteration order to determine as the subtraction input data comprises: selecting one data from the addition iteration result of the previous iteration order and the addition iteration result of the previous iteration order as one addition input data according to the rotation direction corresponding to the current iteration order; selecting one data from the first shift data and the second shift data as another addition input data according to the rotation direction corresponding to the current iteration order; and selecting two data from the addition iteration result of the previous iteration order, the subtraction iteration result of the previous iteration order, the first shift data and the second shift data according to the rotation direction corresponding to the current iteration order to determine as the input data of the subtractor comprises: selecting one data from the addition iteration result of the previous iteration order and the subtraction iteration result of the previous iteration order as one subtraction input data according to the rotation direction corresponding to the current iteration order; and selecting one data from the first shift data and the second shift data as another subtraction input data according to the rotation direction corresponding to the current iteration order.
[0080] In an example embodiment, the operation method further comprises the following steps: obtaining a remaining rotation angle corresponding to the current iteration order according to the target rotation angle and each rotation angle corresponding to the iteration orders; and determining the rotation direction corresponding to the current iteration order according to the remaining rotation angle. When the remaining rotation angle is positive, the rotation direction corresponding to the current iteration order is determined to be counterclockwise; and when the remaining rotation angle is negative, the rotation direction corresponding to the current iteration order is determined to be clockwise.
[0081] In an example embodiment, the operation method further comprises the following steps: outputting the addition iteration result corresponding to the current iteration order under the triggering of a first clock pulse; and outputting the subtraction iteration result corresponding to the current iteration order under the triggering of a second clock pulse.
[0082] From the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and a general hardware platform as required, and of course can also be realized by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, and the computer software product is stored in a storage medium (such as a ROM / RAM, a magnetic disk, or an optical disk), and includes a plurality of instructions for causing a terminal device (which can be a mobile phone, a computer, a server, or a network device) to execute the methods described in the various embodiments of the present application.
[0083] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program. The computer program is configured to execute the steps in any of the above method embodiments when running.
[0084] In an example embodiment, the above computer readable storage medium can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.
[0085] The embodiments of the present application also provide an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor is configured to execute the computer program to perform the steps in any of the above method embodiments.
[0086] In an example embodiment, the above electronic device can further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0087] The optional examples in this embodiment can refer to the examples described in the above embodiments and exemplary embodiments, which will not be repeated here.
[0088] Obviously, those skilled in the art should understand that the modules or steps of the present application described above can be realized by general computing devices, which can be centralized on a single computing device or distributed on a network composed of multiple computing devices, which can be realized by program codes executable by the computing devices, so that they can be stored in storage devices and executed by the computing devices, and in some cases, the steps shown or described can be executed in different order, or they can be made into individual integrated circuit modules, or multiple modules or steps can be made into a single integrated circuit module. Thus, the present application is not limited to any specific combination of hardware and software.
[0089] The above only describes optional embodiments of the present application and is not intended to limit the present application. Those skilled in the art can make various modifications and changes to the present application. Any modification, equivalent replacement, improvement, etc. within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A Cordic algorithm based operation component configured to implement one iteration operation, the operation component comprising: a first shifter configured to shift an addition iteration result of a previous iteration order according to a current iteration order to obtain first shifted data; a second shifter configured to shift a subtraction iteration result of the previous iteration order according to the current iteration order to obtain second shifted data; an addition selector configured to select two data from the addition iteration result of the previous iteration order, the subtraction iteration result of the previous iteration order, the first shifted data and the second shifted data as addition input data according to a rotation direction corresponding to the current iteration order; a subtraction selector configured to select two data from the addition iteration result of the previous iteration order, the subtraction iteration result of the previous iteration order, the first shifted data and the second shifted data as subtraction input data according to the rotation direction corresponding to the current iteration order; an adder configured to determine an addition iteration result corresponding to the current iteration order according to the addition input data; and a subtractor configured to determine a subtraction iteration result corresponding to the current iteration order according to the subtraction input data. The addition selector comprises: a first addition sub-selector configured to select one data from the addition iteration result of the previous iteration order and the subtraction iteration result of the previous iteration order as one of the addition input data according to the rotation direction corresponding to the current iteration order; and a second addition sub-selector configured to select one data from the first shifted data and the second shifted data as another of the addition input data according to the rotation direction corresponding to the current iteration order. The subtraction selector comprises: a first subtraction sub-selector configured to select one data from the addition iteration result of the previous iteration order and the subtraction iteration result of the previous iteration order as one of the subtraction input data according to the rotation direction corresponding to the current iteration order; and a second subtraction sub-selector configured to select one data from the first shifted data and the second shifted data as another of the subtraction input data according to the rotation direction corresponding to the current iteration order. The operation component further comprises an angle subtractor configured to determine a remaining rotation angle corresponding to the current iteration order according to a target rotation angle and each rotation angle corresponding to an iteration order. The addition selector and the subtraction selector are configured to determine the rotation direction corresponding to the current iteration order according to the remaining rotation angle. The addition selector and the subtraction selector are configured to: determine the rotation direction corresponding to the current iteration order as counterclockwise when the remaining rotation angle is positive; and determine the rotation direction corresponding to the current iteration order as clockwise when the remaining rotation angle is negative. A bit width of the angle subtractor corresponding to the current iteration order is less than or equal to a bit width of the angle subtractor corresponding to the previous iteration order. 2. The arithmetic component of claim 1, wherein, 3. The arithmetic component of claim 1, wherein, 4. The arithmetic component of claim 3, wherein, 5. The arithmetic component of claim 3, wherein, 6. The arithmetic component of claim 1, wherein, The operation component further comprises: a first flip-flop configured to receive the addition iteration result corresponding to the current iteration order, and output the addition iteration result corresponding to the current iteration order under the trigger of a first clock pulse; a second flip-flop configured to receive the subtraction iteration result corresponding to the current iteration order, and output the subtraction iteration result corresponding to the current iteration order under the trigger of a second clock pulse.
7. An operation method based on a Cordic algorithm, the operation method being used to implement one iteration operation, the method comprising: performing shift on the addition iteration result obtained in a previous iteration order according to a current iteration order to obtain first shift data; performing shift on the subtraction iteration result obtained in the previous iteration order according to the current iteration order to obtain second shift data; selecting two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shift data and the second shift data as addition input data according to a rotation direction corresponding to the current iteration order; selecting two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shift data and the second shift data as subtraction input data according to the rotation direction corresponding to the current iteration order; determining the addition iteration result corresponding to the current iteration order according to the addition input data; determining the subtraction iteration result corresponding to the current iteration order according to the subtraction input data.
8. The method according to claim 7, wherein, selecting two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shift data and the second shift data as addition input data according to a rotation direction corresponding to the current iteration order, comprises: selecting one data from the addition iteration result obtained in the previous iteration order and the subtraction iteration result obtained in the previous iteration order as one of the addition input data according to the rotation direction corresponding to the current iteration order; selecting one data from the first shift data and the second shift data as another of the addition input data according to the rotation direction corresponding to the current iteration order; selecting two data from the addition iteration result obtained in the previous iteration order, the subtraction iteration result obtained in the previous iteration order, the first shift data and the second shift data as subtraction input data according to the rotation direction corresponding to the current iteration order, comprises: selecting one data from the addition iteration result obtained in the previous iteration order and the subtraction iteration result obtained in the previous iteration order as one of the subtraction input data according to the rotation direction corresponding to the current iteration order; selecting one data from the first shift data obtained in the previous iteration order and the second shift data obtained in the previous iteration order as another of the subtraction input data according to the rotation direction corresponding to the current iteration order. 9. A computer-readable storage medium having stored therein a computer program, wherein, The computer program, which is executed by a processor, realizes the steps of the method as claimed in claim 7 or 8.
10. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor realizing the steps of the method as claimed in claim 7 or 8 when executing the computer program.
Citation Information
Patent Citations
Shallow iteration function operation method and device based on Cordic algorithm
CN116955891A
Cordic algorithm-based operation component and method
CN118363562A
Cordic unit
US20060059215A1
Double-Step CORDIC Processing for Conventional Signed Arithmetic With Decision Postponing
US20120265796A1