Trigonometric function implementation method based on memristor
The method addresses the limitations of existing trigonometric function calculations in memristor-based architectures by employing a grouped parallel pipeline design and Booth coding to achieve high-speed, high-precision trigonometric function calculations, enhancing computational efficiency and reducing energy consumption.
Patent Information
- Application Number
- CN202411249930.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-12-27
AI Technical Summary
Existing trigonometric function calculation methods in memristor-based in-memory computing architectures are limited by high time and energy consumption, and lack accuracy, failing to meet the demands of high data volume processing.
A trigonometric function implementation method using a memristor-based integrated storage and computing architecture with a grouped parallel pipeline design and data flow, employing the cordic algorithm and Booth coding to achieve high-precision calculations.
The method enables high-speed, high-precision trigonometric function calculations by improving computational sparsity and reducing energy consumption through parallel processing and memristor-based in-memory calculations.
Smart Images

Figure CN119201037A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of storage and computing integration, and specifically relates to a trigonometric function realization method based on a memristor. Background Art
[0002] In the past few decades, the rapid development of the Internet of Things, artificial intelligence, big data and related applications has led to an explosive growth in the amount of data. Faced with such a huge amount of data, our demand for high performance and low power consumption of processors is also increasing day by day. In the traditional von Neumann architecture, data needs to be transmitted between the memory and the processor through the data bus, and the limited bandwidth of the data bus causes the data transmission efficiency to be very small compared to the memory capacity. This phenomenon becomes more obvious after the memory capacity increases exponentially. This results in a lot of time and power consumption for data transmission between the processor and the memory when the computer is processing computing operations.
[0003] As one of the frequently performed operations in mathematical physics, trigonometric functions play an important role in many fields. In the past, many algorithms have been proposed to implement trigonometric function calculations, such as polynomial approximation, lookup table interpolation, cordic algorithm, etc. However, with the rapid growth of data volume today, the main bottleneck of real tasks has gradually shifted to memory bandwidth. The transmission of data between memory and processor consumes a lot of time and energy, which has gradually failed to meet current needs.
[0004] The emerging in-memory computing architecture integrates storage and computing, effectively solving the bandwidth problem of transmission. The new memory memristor has attracted widespread attention and research due to its integrated storage and computing features, and is considered to be one of the feasible solutions to solve the von Neumann bottleneck. The trigonometric function algorithm based on the memristor in-memory computing architecture can be integrated with other in-memory computing architectures to achieve the expansion of operators that can be implemented by in-memory computing. However, the existing research on trigonometric function calculation methods based on the memristor in-memory computing architecture is still immature. Although it avoids bandwidth limitations, it still takes a lot of time and energy to sort, and is also limited in accuracy. Therefore, in order to cope with the trigonometric function calculation needs under the rapid growth of data, it is urgent to study a high-precision trigonometric function implementation method based on the memristor in-memory computing architecture. Summary of the invention
[0005] In view of the shortcomings of the above-mentioned prior art and the problem of implementing trigonometric functions on integrated storage and computing hardware, the present invention proposes a trigonometric function implementation method based on memristors, which adopts a trigonometric function integrated storage and computing computing architecture with a grouped parallel pipeline design and the corresponding data flow to realize nonlinear function calculation tasks based on the cordic algorithm and achieve high-precision trigonometric function calculation.
[0006] The technical solution of the present invention is as follows:
[0007] A trigonometric function implementation method based on memristor, using a trigonometric function storage and computing integrated computing architecture and corresponding data flow designed with grouped parallel pipeline, the specific steps are as follows:
[0008] 1) Based on the n-bit precision cordic algorithm, the target angle is split and the coefficients of the split angle set are grouped. 1.1) Based on the transfer equation of the n-bit precision cordic algorithm, an angle set consisting of powers of 2 is established, and the transfer equation coefficients corresponding to the angle set are stored in the memristor array of the trigonometric function calculation module;
[0009] 1.2) Based on the angle set established in step 1.1), the target angle is binary-split to obtain the angle set coefficient a i ,
[0010] a i ∈{0,1},i=1,2...,n;
[0011] 1.3) Further according to Booth coding, the angle set coefficient a i Transformed into angle set coefficient b i , b i ∈{-1, 0, 1}, i=1,2…,n;
[0012] 1.4) Based on the angle splitting in step 1.3), the coefficient b i Perform average grouping: take the closest n The factor m of is used as the number of groups, and the system is divided into m groups, each group has (n / m) digits;
[0013] 2) Perform iterative calculations in the trigonometric function calculation module according to the group, and each group performs it synchronously with a parallelism of m
[0014] 2.1) The grouping coefficient b obtained in step 1.4) i Send it to m groups of trigonometric function calculation modules, and each module calculates the value according to b i The coefficient value enables the row selector, where the coefficient b i When it is 0, it is skipped. When it is 1, the row selector selects the transfer equation coefficient.
[0015] 1 and coefficient 2, when it is -1, the row selector corresponds to the selection transfer equation coefficient 1 and coefficient 3;
[0016] 2.2) Perform iterative calculations in the trigonometric function calculation module in sequence. The first iterative calculation takes angle 0 as the starting point, that is, the input coordinates are (1,0);
[0017] 2.3) According to the input coordinates and coefficient b iThe transfer equation coefficients stored in the selected memristor array are used to calculate the transfer equation of the cordic algorithm; the principle of in-memory calculation is used to perform multiplication and addition in the array to realize polynomial calculation, and the input coordinates of the next iteration are output;
[0018] 2.4) Repeat step 2.3) until a total of (n / m) iterations are completed, and the coordinates (X (n / m) ,Y (n / m) );
[0019] In the step 2), parallel calculation of m groups of trigonometric function calculation modules is implemented to obtain m group calculation coordinate results;
[0020] 3) Summarize the group calculation results and calculate the final result in the summary trigonometric function calculation module
[0021] 3.1) The grouped coordinate calculation results obtained in step 2) are used as a new angle set, and the cordic algorithm transfer equation coefficients corresponding to the m new angles in the new angle set are calculated using a digital circuit; and the obtained transfer equation coefficients are written into each memristor array in the summary calculation module; at the same time, the summary trigonometric function calculation module receives the coefficients b in step 1.4) i As the selection signal of its row selector, i=k×n / m+1, k=0,1,2...,m-1;
[0022] 3.2) Repeat steps 2.2) to 2.4) to complete m iterative calculations to obtain the final iterative calculation coordinates;
[0023] 3.3) Directly calculate the sin and cos function values based on the coordinates, and further calculate the tan function value; finally, the calculation of trigonometric functions is realized.
[0024] Furthermore, the parallel pipeline design of the method includes a trigonometric function storage and calculation integrated computing architecture, including an angle symbolization module and a trigonometric function calculation module. The angle symbolization module is used to perform binary angle splitting on the target angle of the cordic algorithm and output the angle set coefficient b i; A trigonometric function calculation module includes a plurality of x-coordinate calculation memristor array calculation blocks, a plurality of y-coordinate calculation memristor array calculation blocks and a data flow control center, wherein the peripheral circuit of each x / y-coordinate calculation memristor array block includes a row selector, a shifter and a cache; the x-coordinate calculation memristor array calculation block is used for iterative calculation of the X value in the coordinate, which corresponds to the cosine function, and the y-coordinate calculation memristor array calculation block is used for iterative calculation of the Y value in the coordinate, which corresponds to the sin function; the data flow control center is used to control the data flow between arrays; the size of the x / y-coordinate calculation memristor array calculation block is 3×n, which is used to store 3 weights, which correspond to the 3 coefficients involved in the transfer equation of the cordic algorithm, respectively; the memristor array calculation blocks are connected front and back in the architecture, and are calculated in sequence, and the number of the memristor array calculation blocks is determined by the angle accuracy n and the grouping m in the method, i.e. (n / m) blocks; the row selector is based on the coefficient b output by the angle symbolization module i The value is selected; the cache is placed at the output position of the array and is used to store the calculation results of the array calculation transfer equation.
[0025] The technical effects of the present invention are as follows:
[0026] The present invention discloses a trigonometric function realization method based on memristor, which is applicable to nonlinear function calculation tasks based on cordic algorithm, including hyperbolic function. Booth coding is used to decompose angles to improve the sparsity of coefficients. A trigonometric function calculation module and an array calculation block in the module are designed by grouping parallel pipeline, so as to realize high-speed calculation of high-precision trigonometric functions on a storage-computation integrated architecture. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 This is a schematic diagram of the cordic algorithm on which the present invention is based;
[0028] Figure 2 A schematic diagram of the data flow and architecture of the integrated storage and calculation of trigonometric functions in an embodiment of the present invention;
[0029] Figure 3 A block diagram of a trigonometric function calculation module in an embodiment of the present invention;
[0030] Figure 4 Schematic diagram of parallel data flow in a single trigonometric function calculation module in an embodiment of the present invention. DETAILED DESCRIPTION
[0031] The present invention will be further described clearly and completely below through specific embodiments in conjunction with the accompanying drawings. The description herein is only used to explain the present invention and is not intended to limit the present invention.
[0032] The present invention discloses a trigonometric function realization method based on a memristor. The method is realized by a trigonometric function storage-computation integrated computing architecture with a parallel pipeline design. The architecture mainly includes an angle symbolization module and a trigonometric function computing module. The method realizes a nonlinear function computing task based on a cordic algorithm. The deployment of the cordic algorithm on hardware is realized by algorithmic adaptation to hardware and architectural design.
[0033] Figure 1 The cordic algorithm can be shown as a schematic diagram. The cordic algorithm itself can decompose the target angle into the sum of multiple angles, and then obtain the trigonometric function value of the target angle through rotation. Figure 1 The cordic algorithm shown is based on the angle θ i Rotate to get angle θ i+1 , and (x i ,y i ) and (x i+1 ,y i+1 ) are angles θ i and angle θ i+1 Coordinates in the xy coordinate system. α i is the angle of this rotation. According to the calculation, it can be found that the angle θ obtained by each rotation i+1 The coordinates of can be expressed by the angle θ i The coordinates are calculated linearly. Therefore, we only need to select the appropriate angle to linearly iterate and calculate the trigonometric function. It can be noted that after rotation, the angle θ i+1 The corresponding sin and cos function results can be obtained by rotating the angle α i The tangent function of θ before rotation i The sin and cos functions are linearly obtained, and the transfer equations are formulas (1) and (2), which have 3 coefficients, coefficient 1 is The coefficient 2 is The coefficient 3 is
[0034]
[0035] Since the sin and cos functions are always less than 1, they can be represented by fixed-point numbers less than 1, meeting the hardware implementation's accuracy requirements for data storage.
[0036] The present invention makes some modifications to the target angle decomposition of the cordic algorithm in the angle symbolization module. First, in order to convert the target angle θ into binary representation, an angle set consisting of powers of 2 is established based on the transfer equation of the n-bit precision cordic algorithm, and the transfer equation coefficients corresponding to the angle set are stored in the memristor array of the trigonometric function calculation module. An angle set consisting of powers of 2 is established based on the transfer equation of the cordic algorithm: The target angle is binary-split to obtain the angle set coefficient a i , a i ∈{0, 1}, i=1, 2..., n, n is the calculation accuracy of the angle in the cordic algorithm. According to the binary representation of the angle, Booth coding is used to further simplify the expression to achieve computational sparsity and accelerate the calculation process. The angle after Booth coding is represented by the angle set composed of powers of 2: The angle set coefficient is b i , b i ∈{-1, 0, 1}, i=1, 2…, n, the angle symbolization module outputs the angle set coefficient b i Compared with the expression before Booth encoding, b i You can increase the number of zeros in the coefficients to speed up the calculation process.
[0037] Furthermore, the parallel pipeline design is used to group the angle sets after Booth coding evenly: for n-bit calculation accuracy, the n closest The factor m is used as the number of trigonometric function calculation modules, that is, it is divided into m groups, and then the n-bit precision is evenly distributed to the m trigonometric function calculation modules, and each module is divided into n / m bits. Taking the 16-bit precision cordic algorithm as an example, it is divided into 4 groups for parallel calculation, each group has 4-bit precision, and the angle set after grouping is expressed as:
[0038]
[0039] Each group is iterated 4 times, and then the 4-bit precision calculation results of each group are summarized as a new angle set, and then iterated 4 times to finally get a 16-bit precision result. This design can improve the parallelism of cordic operations and reduce the original 16-bit calculation iteration time to the equivalent 8-bit calculation iteration time.
[0040] The trigonometric function calculation module for implementing the method of the present invention comprises a plurality of X-coordinate calculation memristor array calculation blocks, a plurality of Y-coordinate calculation memristor array calculation blocks and a data flow control center, wherein the peripheral circuit of each X / Y-coordinate calculation memristor array block comprises a row selector, a shifter and a cache; the X-coordinate calculation memristor array calculation block is used for iterative calculation of the X value in the coordinate, which corresponds to the cosine function, and the Y-coordinate calculation memristor array calculation block is used for iterative calculation of the Y value in the coordinate, which corresponds to the sin function; the data flow control center is used for controlling the data flow between arrays; the X / Y-coordinate calculation memristor array blocks are connected front and back on the architecture, and calculation is performed in sequence, the number of memristor array calculation blocks is determined by the angle precision n and the grouping m in the calculation method, i.e., n / m blocks, and the row selector is based on the coefficient b output by the angle symbolization module i The value is selected, the corresponding value of 0 is skipped, the corresponding value of 1 is selected coefficient 1 and coefficient 2, and the corresponding value of -1 is selected coefficient 1 and coefficient 3; the cache is placed at the output position of the array to store the calculation results of the array calculation transfer equation. Considering the sparsity of the data input to the memristor array, the array can be i If the data is 0, it is skipped, thereby further reducing the energy consumption required for trigonometric function calculations.
[0041] Figure 2 This is a schematic diagram of the data flow and architecture of the trigonometric function storage and calculation integration in this embodiment. Figure 3 The block diagram of the trigonometric function calculation module of this embodiment takes the parallel pipeline design of the 16-bit precision cordic algorithm as an example. Figure 2 The trigonometric function calculation module and the summary trigonometric function calculation module on the Figure 3 The trigonometric function calculation module contains 4 arrays for calculating the X value in the coordinates, which corresponds to the cosine function, 4 arrays for calculating the Y value in the coordinates, which corresponds to the sin function, and a data flow control center. Each array is a 3x16 memristor array, and the periphery of the array block includes a row selector, a shifter, and a cache. In the pipeline design, Figure 2 The above four groups of calculation modules can perform calculations at the same time, respectively calculating the transfer equations at positions 1 to 4, 5 to 8, 9 to 12, and 13 to 16, with the starting point being angle 0. The four groups of x and y coordinates obtained by group calculation can be regarded as the sin and cos function values of four new angles. The four groups of coordinate results are written into the summary trigonometric function calculation module as a new angle set, and the iterative calculation is also started with angle 0 as the starting point. After four iterations, the final output result can be obtained.
[0042] like Figure 4As shown in the figure, the final goal of the four iterative calculations in a single trigonometric function calculation module is to calculate X4 and Y4. In the iterative calculation process, there will be intermediate results (X1, Y1)(X2, Y2)(X3, Y3). Figure 1 The cordic algorithm transfer equation in the linear process involves three coefficients: coefficient 1, coefficient 2, and coefficient 3. Therefore, the 3x16 memristor array stores the three coefficients of the transfer equation, that is, the three weights. This coefficient storage is used to replace the high-bit multiplier with the memristor array. It should be noted that since the values of the sin and cos functions must be less than 1, the output result of the memristor array will not overflow, and the highest 16 bits can be directly selected in the shift.
[0043] In this embodiment, the trigonometric function implementation method based on memristor has the following specific steps:
[0044] 1) Based on the 16-bit precision cordic algorithm, the target angle is split and the coefficients of the split angle set are grouped. 1.1) Based on the transfer equation of the 16-bit precision cordic algorithm, an angle set consisting of powers of 2 is established, and the transfer equation coefficients corresponding to the angle set are stored in the memristor array of the trigonometric function calculation module;
[0045] 1.2) Based on the angle set established in step 1.1), the target angle is binarized and split to obtain coefficient a i , a i ∈{0,1},i=1,2...,16;
[0046] 1.3) Further convert the coefficient a into i Transformed into coefficient b i , b i ∈{-1, 0, 1}, i=1,2…,16;
[0047] 1.4) Based on the angle splitting in step 1.3), the coefficient b i The students were divided into 4 groups, with 4 students in each group.
[0048] 2) Perform iterative calculations in the trigonometric function calculation module in groups, with each group performing the calculations synchronously and a parallelism of 4
[0049] 2.1) The grouping coefficient b obtained in step 1.4) i Sent to the trigonometric function calculation modules of group 1 to group 4, each module according to b i The coefficient value enables the row selector, where the coefficient b i When it is 0, it is skipped. When it is 1, it corresponds to the selection of transfer equation coefficients 1 and 2. When it is -1, it corresponds to the selection of transfer equation coefficients 1 and 3.
[0050] 2.2) Perform iterative calculations in the trigonometric function calculation module in sequence. The first iterative calculation takes angle 0 as the starting point, that is, the input coordinates are (1,0);
[0051] 2.3) According to the input coordinates and coefficient b i The transfer equation coefficients stored in the selected memristor array are used to calculate the transfer equation of the cordic algorithm; the principle of in-memory calculation is used to perform multiplication and addition in the array to realize polynomial calculation, and the input coordinates of the next iteration are output;
[0052] 2.4) Repeat step 2.3) until a total of 4 iterations are completed, and the coordinates after 4 iterations are obtained (X4, Y4)
[0053] In step 2), parallel calculation of 4 groups of trigonometric function calculation modules is implemented to obtain 4 group calculation coordinate results;
[0054] 3) Summarize the group calculation results and calculate the final result in the summary trigonometric function calculation module
[0055] 3.1) The grouped coordinate calculation results obtained in step 2) are used as a new angle set, and the cordic algorithm transfer equation coefficients corresponding to the four new angles in the new angle set are calculated using a digital circuit; and the obtained transfer equation coefficients are written into each memristor array in the summary calculation module; at the same time, the summary trigonometric function calculation module receives the coefficient b in step 1.4) i , as the selection signal of its row selector, i=1,5,9,13;
[0056] 3.2) Repeat steps 2.2) to 2.4) to complete 4 iterations to obtain the final iterative calculation coordinates;
[0057] 3.3) Directly calculate the sin and cos function values based on the coordinates, and further calculate the tan function value; finally, the calculation of trigonometric functions is realized.
[0058] The above realizes the high-speed calculation of 16-bit precision trigonometric functions on the integrated storage and computing architecture.
[0059] Finally, it should be noted that the purpose of publishing the embodiments is to help further understand the present invention, but those skilled in the art can understand that various substitutions and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the present invention should not be limited to the contents disclosed in the embodiments, and the scope of protection claimed by the present invention shall be subject to the scope defined in the claims.
Claims
1. A method for implementing trigonometric functions based on memristors, characterized in that a trigonometric function storage-computation integrated computing architecture and corresponding data flow with a grouped parallel pipeline design are adopted, and the specific steps are as follows: 1) Based on the n-bit precision cordic algorithm, the target angle is split and the split angle set coefficients are grouped 1.1) Based on the transfer equation of the n-bit precision cordic algorithm, an angle set consisting of powers of 2 is established, and the transfer equation coefficients corresponding to the angle set are stored in the memristor array of the trigonometric function calculation module; 1.2) Based on the angle set established in step 1.1), the target angle is binary-split to obtain the angle set coefficient a i , a i ∈{0,1},i=1,2...,n; 1.3) Further according to Booth coding, the angle set coefficient a i Transformed into angle set coefficient b i , b i ∈{-1, 0, 1}, i=1,2…,n; 1.4) Based on the angle splitting in step 1.3), the coefficient b i Perform average grouping: take the closest n The factor m of is used as the number of groups, and the system is divided into m groups, each group has (n / m) digits; 2) Perform iterative calculations in the trigonometric function calculation module according to the group, and each group performs it synchronously with a parallelism of m 2.1) The grouping coefficient b obtained in step 1.4) i Send it to m groups of trigonometric function calculation modules, and each module calculates the value according to b i The coefficient value enables the row selector, where the coefficient b i Skip when it is 0, select the corresponding transfer equation coefficient 1 and coefficient 2 when it is 1, and select the corresponding transfer equation coefficient 1 and coefficient 3 when it is -1; 2.2) Perform iterative calculations in the trigonometric function calculation module in sequence. The first iterative calculation takes angle 0 as the starting point, that is, the input coordinates are (1,0); 2.3) According to the input coordinates and coefficient b i The transfer equation coefficients stored in the selected memristor array are used to calculate the transfer equation using the cordic algorithm; Using the principle of in-memory calculation, multiplication and addition are performed in the array to realize polynomial calculation and output the input coordinates for the next iteration; 2.4) Repeat step 2.3) until a total of (n / m) iterations are completed, and the coordinates (X (n / m) ,Y (n / m) ); In the step 2), parallel calculation of m groups of trigonometric function calculation modules is implemented to obtain m group calculation coordinate results; 3) Summarize the group calculation results and calculate the final result in the summary trigonometric function calculation module 3.1) The grouped coordinate calculation results obtained in step 2) are used as a new angle set, and the cordic algorithm transfer equation coefficients corresponding to the m new angles in the new angle set are calculated using a digital circuit; and the obtained transfer equation coefficients are written into each memristor array in the summary calculation module; at the same time, the summary trigonometric function calculation module receives the coefficients b in step 1.4) i As the selection signal of its row selector, i=k×n / m+1, k=0,1,2...,m-1; 3.2) Repeat steps 2.2) to 2.4) to complete m iterative calculations to obtain the final iterative calculation coordinates; 3.3) Directly calculate the sin and cos function values based on the coordinates, and further calculate the tan function value; finally, the calculation of trigonometric functions is realized.
2. The method as claimed in claim 1, characterized in that The method is a parallel pipeline design trigonometric function storage and calculation integrated computing architecture, including an angle symbolization module and a trigonometric function calculation module. The angle symbolization module is used to perform binary angle splitting on the target angle of the cordic algorithm and output the angle set coefficient b i ; A trigonometric function calculation module comprises a plurality of x-coordinate calculation memristor array calculation blocks, a plurality of y-coordinate calculation memristor array calculation blocks and a data flow control center, wherein the peripheral circuit of each x / y-coordinate calculation memristor array block comprises a row selector, a shifter and a cache; the x-coordinate calculation memristor array calculation block is used for iterative calculation of the X value in the coordinate, which corresponds to the cos function, and the y-coordinate calculation memristor array calculation block is used for iterative calculation of the Y value in the coordinate, which corresponds to the sin function; the data flow control center is used for controlling the data flow between arrays; the x / y-coordinate calculation memristor array calculation block has a size of 3×n, which is used for storing 3 weights, which respectively correspond to 3 coefficients involved in the transfer equation of the cordic algorithm, and the memristor array calculation blocks are connected front and back in the architecture and perform calculations in sequence, and the number of the memristor array calculation blocks is determined by the angle accuracy n and the grouping m in the method, i.e. (n / m) blocks; The row selector is based on the coefficient b output by the angle symbolization module i Select the value; The cache is placed at the output position of the array and is used to store the calculation results of the array calculation transfer equation.