Hyperbolic function calculation device and method based on three-bit coding rotation CORDIC

Through the three-bit encoding rotation CORDIC method, grouping and Taylor expansion technology, the problem of the hyperbolic CORDIC algorithm is solved with many iterations and low accuracy, and the hyperbolic function calculation with high precision and low iterations is realized, reducing hardware resources and complex logic , improves the flexibility and application scope of the algorithm.

CN118939233APending Publication Date: 2024-11-12CHONGQING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410929266.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-11
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

The hyperbolic CORDIC algorithm has many iterations and low calculation accuracy. Existing research has failed to effectively reduce the number of iterations and improve the accuracy.

Method used

The three-bit encoding rotation CORDIC method is used to process 16-bit binary data through grouping, encoding and Taylor expansion, reducing the number of effective data bits in each subgroup, and using Taylor expansion to calculate the rotation factor of the encoded angle to achieve lower number of iterations and high Accuracy calculation.

Benefits of technology

High-precision hyperbolic CORDIC algorithm calculation is realized, reducing hardware resource requirements and complex repetitive iteration logic, and improving the flexibility and wide application of the algorithm.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939233A_ABST
    Figure CN118939233A_ABST
Patent Text Reader

Abstract

The invention discloses a hyperbolic function calculation device and a hyperbolic function calculation method based on a three-bit code rotation coordinate rotation digital computer (CORDIC), and relates to the field of signal processing in a field programmable gate array (FPGA), in particular to a hyperbolic function calculation device and a hyperbolic function calculation method based on a three-bit code rotation coordinate rotation digital computer (CORDIC) and a hyperbolic function calculation method based on a three-bit code rotation coordinate rotation digital computer (CORDIC). The method mainly comprises three parts of grouping, coding and Taylor expansion, and the angles are all 16-bit data and are composed of 1-bit sign bits, 1-bit integer bits and 14-bit decimal bits. Wherein the angle range is [0, pi / 4], 1-bit integer bits and 14-bit decimal bits are grouped, every 3 bits are grouped into one group, and the group is totally divided into 5 subgroups; the coding sequence is carried out from the low-bit subgroup to the high-bit subgroup, and the digits of the effective number in each subgroup can be reduced after coding, namely, the number of iterations required by each subgroup is reduced; calculating twiddle factors, namely sinh and cosh, corresponding to the encoded angle by using Taylor expansion, so as to achieve a scaling-free effect; and calculating x and y after iteration for five times from the high-position subgroup to the low-position subgroup, namely, cosh and sinh. The CORDIC algorithm provided by the invention has the advantages of few iterations, high calculation precision and low hardware resource consumption, can realize the calculation of a hyperbolic function, can also calculate an exponential function and a logarithmic function through simple transformation, and is suitable for most scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of digital signal processing, and in particular relates to an optimization method based on CORDIC. Background Art

[0002] The Coordinate Rotation Digital Computer (CORDIC) was first proposed in 1959 to solve the vector rotation problem in aviation control systems. A unified calculation formula was proposed in 1971. The CORDIC algorithm can approximate mathematical calculations such as trigonometric functions, inverse trigonometric functions, multiplication and division, logarithms, exponentials, and square roots using only simple shift and addition operations. Therefore, the CORDIC algorithm has been widely used in digital signal processing, such as fast Fourier transform (FFT), discrete cosine transform (DCT), QR decomposition, direct digital frequency synthesizer (DDS), etc. It is also widely used in the field of artificial intelligence, such as spiking neural networks (SNN), recurrent neural networks (RNNs), and Fitz-Hugh Nagumz (FHN).

[0003] In order to ensure the convergence of the hyperbolic CORDIC algorithm, it needs to be executed twice when the iteration index i = (4, 13, 40, ..., k, 3k + 1). Since the asymptote of the unit hyperbolic function is y = x, its convergence range is only [-1.1182, 1.1182]. At the same time, the convergence speed of the traditional hyperbolic CORDIC algorithm is slow compared to the circular system and the linear system. This is because the characteristics of the hyperbolic function require more iterative steps to achieve the required accuracy. In addition, since the CORDIC algorithm is an iterative approximation method, each iteration will introduce a certain error, so it is necessary to weigh the accuracy and calculation time. Most of the existing hyperbolic CORDIC algorithms are aimed at eliminating the compensation of the scaling factor and using Taylor expansion to approximate the rotation factor. However, existing research cannot effectively reduce the number of algorithm iterations and improve the calculation accuracy of the algorithm. Summary of the invention

[0004] Based on this, the present invention aims at the problems of large number of iterations and low calculation accuracy in the hyperbolic CORDIC algorithm, and proposes a hyperbolic function calculation device and method based on three-bit coded rotation CORDIC, which can complete the calculation of the CORDIC algorithm with lower number of iterations and higher calculation accuracy.

[0005] The present invention provides an encoding method for a hyperbolic CORDIC algorithm:

[0006] A coding method based on the hyperbolic CORDIC algorithm mainly includes three parts: grouping, coding and Taylor expansion;

[0007] The angle processed by the present invention is 16-bit binary data, which consists of 1 sign bit, 1 integer bit and 14 decimal bits. The angle range is [0, π / 4], and the 1 integer bit and 14 decimal bits are grouped in groups of 3 bits; the encoding order is from the low-order subgroup to the high-order subgroup, and the number of bits of valid data in each subgroup can be reduced after encoding, that is, the number of iterations required for each subgroup is reduced; the rotation factors cosh and sinh corresponding to the angle after encoding are calculated using Taylor expansion.

[0008] The beneficial effects of the present invention are as follows: the present invention can complete the hyperbolic CORDIC algorithm calculation with high accuracy with fewer iterations, and reduce the hardware resources required by the algorithm, while also achieving the effect of no scaling factor and eliminating complex repeated iteration logic. Compared with most CORDIC algorithms, the present invention is more flexible and widely used. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] Figure 1 It is the algorithm flow chart of the present invention.

[0010] Figure 2 It is a grouping diagram of the present invention. DETAILED DESCRIPTION

[0011] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments. The embodiment described is only one of the embodiments of the present invention, not all embodiments.

[0012] The present invention provides a CORDIC optimization algorithm for calculating hyperbolic functions, which is denoted as three-bit coding (TBC). The coding flow chart is as follows: Figure 1 As shown, in this embodiment, the rotation angle and the hyperbolic function are both 16-bit data, consisting of 1 sign bit, 1 integer bit and 14 decimal bits. This device is a coding method, which specifically includes three parts: grouping, coding and Taylor expansion. The specific implementation steps of the three parts are as follows:

[0013] Step S1, the grouping order is from high to low angle, such as Figure 2 As shown. k represents the kth subgroup, and divides the integer part and the fractional part of the rotation angle into 5 subgroups according to 3-bit groups;

[0014] Step S2: By encoding the three consecutive angles in each subgroup, the original three rotations can be reduced to one. Encode the input angle |θ|∈[0,π / 4], and the encoding order is from the low-order subgroup to the high-order subgroup. The carry generated by the current subgroup and its adjacent low-order subgroup is added. When the data represented by the current subgroup is less than or equal to 4, there is at most 1 counter-clockwise rotated valid data in the subgroup, indicating that the valid data is rotated counter-clockwise. Among them, data 3 is a special case, recorded as 011 b , there are 2 bits of valid data rotated counterclockwise; when the data represented by the current subgroup is greater than 4, by advancing one bit to the adjacent high-order subgroup, the current subgroup has at most 1 bit of valid data rotated clockwise, indicating that the valid data is rotated clockwise, where data 5 is a special case, recorded as 101 b , there are 2 bits of valid data in counter-clockwise rotation; except 011 b and 101 b In addition, after encoding, there is at most one valid data, which can reduce the rotation from 3 times to 1 time; for 011 b and 101 b , their respective valid data are regarded as a whole and processed together during rotation, and the number of rotations can also be reduced to 1. Since the fifth subgroup is the lowest subgroup, the carry it receives is 0.

[0015] Table 1 TBC encoding principle

[0016]

[0017]

[0018] The meanings of the parameters in Table 1 are:

[0019] (1) CB0: is the carry generated by the previous subgroup. The CB0 of the fifth subgroup is 0.

[0020] (2) CB1: The carry generated by the current subgroup. It is passed to the next subgroup.

[0021] (3)α i+2 α i+1 α i : Three adjacent angle values ​​in the same subgroup.

[0022] (4) c0: indicates the rotation position, 0 means rotation α i The position of , 1 means rotation α i+1 The position of 2 means rotation α i+2 location.

[0023] (5) c1: Indicates whether to skip the current rotation, that is, when the sum of the carry generated by the previous subgroup is 0. 0 does not skip, 1 skips.

[0024] (6) c2: indicates the direction of rotation. 0 indicates counterclockwise. 1 indicates clockwise. Since the absolute value of θ is encoded, the final direction of rotation is the XOR value of the sign bit of θ and c2.

[0025] (7) c3: Select the rotation mode. 0 means to execute single-bit iteration (SBI), corresponding to 1 valid data bit; 1 means to execute double-bit iteration (DBI), corresponding to 011 b and 101 b Condition.

[0026] The three single-bit rotations required for a subgroup can be converted into one SBI or one DBI through TBC coding, and then the subgroup is rotated without scaling through Taylor expansion of SBI or DBI.

[0027] Step S3: After encoding, each subgroup needs to undergo an SBI or DBI, and the corresponding rotation factor can be expanded by the Taylor formula described in equation (1). For SBI, θ = 2 -i , where i = 1, 2, ..., 14, for DBI, θ2 = (2 -(j-m) +2 -j ), where m is 1 or 2, corresponding to the special cases of data 3 and data 5, respectively, and j = 2, 5, 8, 11, 14. Substituting into formula (1) will produce terms containing 1 / 3! and 1 / 5! that cannot be converted into negative exponential powers of 2. Using the Taylor expansion of formula (2), it can be approximated as the sum of several negative exponential powers of 2. Combining formula (1) and formula (2), discarding the terms of negative exponential powers of 2 with a number greater than 14, the final result is the sum of several negative exponential powers of 2, which is the approximate result of cosh and sinh, as shown in Tables 2 and 3.

[0028]

[0029] Table 2 Taylor expansion of SBI

[0030]

[0031]

[0032] Table 3 Taylor expansion of DBI

[0033]

[0034] Since the maximum angle of the code is π / 4, that is, 16'b0011_0010_0100_0100, the encoded sp1 will not appear 101 bThe negative terms in Table 2 appear because when two or more consecutive terms are expanded, a carry term and a negative term are generated through TBC, for example, 2 -4 +2 -5 +2 -6 =2 -3 -2 -6 The advantage of this is that when there are three or more consecutive terms, the number of terms can be reduced, and the number of terms can be reduced, which can reduce the error caused by shifting to a certain extent;

[0035] Table 4 shows two examples of TBC encoding.

[0036] Table 4 TBC encoding example

[0037]

[0038] -1 means clockwise rotation at this position. Both Example 1 and Example 2 satisfy the requirement that the rotation angle remains unchanged before and after encoding, that is, (2 -1 )+(2 -3 +2 -4 )+(2 -7 )+(2 -8 +2 -9 +2 -10 )+(2 -12 +2 -14 )=(2 -1 +2 -2 )+(-2 -4 )+(2 -7 +2 -8 )+(-2 -11 )+(2 -12 +2 -14 ) and (2 -3 +2 -4 +2 -5 )+(2 -6 +2 -7 )+(2 -9 +2 -11 )+(2 -13 +2 -14 )=(2 -2 )+(-2 -7 )+(2 -9 +2 -11 )+(2 -13 +2 -14 ). The two equations hold, verifying the correctness of TBC.

[0039] The implementation examples described above are merely preferred implementation examples of the present invention and are not intended to limit the present invention. The protection scope of the present invention is not limited to the above embodiments. For technicians in the same field, all equivalent replacements, modifications, and modifications made based on the disclosure of the present invention should be included in the protection scope of the present invention.

Claims

1. A hyperbolic function calculation device and method based on three-bit coded rotation CORDIC, characterized in that: The device comprises: a grouping unit, used for grouping the input angle into groups of 3 bits, with each 3 bits forming a subgroup; The encoding unit is used to encode the subgroups processed by the grouping unit, and encode the 3 bits in each subgroup into 3 bits containing 1 or 2 binary 1s, each binary 1 represents 1 bit of valid data; The Taylor expansion unit is used to perform Taylor expansion on the encoded bits to obtain an approximate result of the rotation factor.

2. A hyperbolic CORDIC device and method based on three-bit code rotation according to claim 1, characterized in that: Contains a grouping, encoding, and Taylor expansion method: The grouping unit is used to group the input angle represented by the 16-bit binary to be calculated into groups of 3 bits, wherein the 16-bit binary representation includes 1 sign bit, 1 integer bit and 14 decimal bits, and the grouping is performed on the remaining 15 bits except the 1 sign bit, from high to low, and every 3 bits are a subgroup, which are respectively recorded as the first subgroup, the second subgroup, the third subgroup, the fourth subgroup, and the fifth subgroup; The encoding unit is used to encode the subgroups, and the encoding order is from the low-order subgroup to the high-order subgroup. Each subgroup consists of three bits of data, and the representation range is 0 to 7. The encoding rule is: the carry generated by the current subgroup and its adjacent low-order subgroup is added. When the data represented by the current subgroup is less than or equal to 4, there is at most 1 counterclockwise rotated valid data in the subgroup, indicating that the valid data is rotated counterclockwise, wherein data 3 is a special case, and there are 2 counterclockwise rotated valid data; when the data represented by the current subgroup is greater than 4, by carrying one bit to the adjacent high-order subgroup, the current subgroup has at most 1 clockwise rotated valid data, indicating that the valid data is rotated clockwise, wherein data 5 is a special case, and there are 2 counterclockwise rotated valid data; except for data 5 and data 3, there is at most one valid data after encoding, which can reduce the rotation from 3 times to 1 time; for the special cases of data 5 and data 3, their respective valid data are regarded as a whole and processed together during rotation, and the number of rotations can also be reduced to 1 time; The Taylor expansion unit performs Taylor expansion for the special case where each subgroup has at most 1 bit of valid data or data 5 and data 3 after encoding: Where n is a natural number, θ is the angle to be rotated for encoding each subgroup, and the angle to be rotated for 1 valid bit of data is θ1=2 -i , where i = 1, 2, ..., 14, the angle to be rotated for the special case of data 5 and data 3 is denoted as θ2 = (2 -(j-m) +2 -j ), where m is 1 or 2, corresponding to the special cases of data 3 and data 5, respectively, and j = 2, 5, 8, 11, 14, corresponding to the first to fifth subgroups, respectively; Taylor expansion will produce terms containing 1 / 3! and 1 / 5! that cannot be converted into negative exponential powers of 2, and the Taylor expansion of formula (2) is used to approximate the sum of several negative exponential powers of 2. Combining formula (1) and formula (2), discarding the terms of negative exponential powers of 2 with exponential powers less than -14, the final result is the sum of several negative exponential powers of 2, which is the approximate result of cosh and sinh; The grouping unit, the encoding unit and the Taylor expansion unit are arranged in a serial relationship. First, when the angle to be rotated is input into the device, the grouping unit groups its integer digits and decimal digits, and the grouping order is from high to low, with 3 digits in each group, for a total of 5 groups; then the encoding unit encodes the grouped subgroup data from low to high by carry, so that the number of iterations required for each subgroup is reduced from 3 times to 1 time after encoding; then Taylor expansion is used to approximate the angle of each subgroup after encoding into a rotation factor represented by a negative exponential power of 2; finally, in order of subgroups from high to low, the result after the fifth subgroup iteration is completed is the hyperbolic function value corresponding to the input angle.