The invention relates to an internal data processing method for an FPGA, and particularly relates to a method of realizing accelerated parallel Jacobi computing for an FPGA.
Many algorithms in various fields, such as radars, wireless communication, image processing, etc., need to compute the eigenvalues of a matrix. For example, the computation of eigenvalues is a key step in sub-space-based direction-of-arrival (DOA) estimation algorithms and principle component analysis (PCA) algorithms.
Currently, algorithms for computing a large number of eigenvalues include, for example, QR algorithms, LU decomposition algorithms, algebraic methods, etc. Since the complexity of root extraction in algebraic methods increases as the dimensions of the matrix increase, algebraic methods are not suitable for obtaining eigenvalues from a large-scale matrix. Meanwhile, LU decomposition algorithms are only suitable for obtaining eigenvalues from an invertible matrix. Besides, while QR algorithms have been proven as faster than serial Jacobi computing in the computation for eigenvalues, studies have nonetheless shown that Jacobi computing exhibits a higher accuracy than that of QR algorithms. Jacobi computing refers to a process of gradually converting a matrix into a nearly-diagonal matrix through a series of rotations. The diagonal elements in the matrix are the eigenvalues of the matrix. In addition, owing to the inherent parallelism of Jacobi computing resulting from its decomposition of eigenvalues from a real symmetric matrix, parallel Jacobi computing (a parallel method for realizing Jacobi computing) has been broadly applied for eigenvalue decomposition in FPGA-related applications.
Currently, some studies have been undertaken in hope to accelerate parallel Jacobi computing. However, most of these acceleration methods are unable to realize one step of parallel Jacobi computing in one CORDIC algorithm cycle. While the conventional approximate Jacobi computing is capable of realizing one step of parallel Jacobi computing in one CORDIC algorithm cycle, the performance is not entirely satisfactory. This is because the rotations are approximate rotations, which increase the total number of rotations required. Besides, while the total lookup table (LUT) resources in an FPGA are limited, the consumption of the LUT resources in the FPGA is not considered when the conventional algorithms are put into practice.
To address the above issues, the invention proposes a method of realizing accelerated parallel Jacobi computing for an FPGA and designs a solution which brings forth favorable computation processing efficacies when the parallel Jacobi computing method is realized in the FPGA. With the method, the technical issues that internal data processing in an FPGA is slow and resource-consuming are addressed, and the objective of realizing one step of parallel Jacobi computing within one CORDIC algorithm cycle is achieved. Besides, the resource consumption in the FPGA is reduced.
To achieve the objectives, the invention provides a technical solution with the following steps.
(1) Initializing Processors:
Data of a n×n-dimensional matrix are input into the FPGA and a rotation transformation process using the parallel Jacobi computing is carried out. A coordinate rotation digital computer (CORDIC) algorithm is adopted in Jacobi computing to carry out a planar rotation, and a two-dimensional X-Y coordinate system is established in the planar rotation.
A plurality of processors are provided in a field programmable gate array (FPGA). The processors are arranged in an array. Each of the processors is connected with an adjacent processor via a data interface to exchange data and elements, and each element in the n×n-dimensional matrix for carrying out the parallel Jacobi computing is assigned to a processor Pij according to a formula as follows:
wherein Pij represents a processor in an ith row and a jth column, a2i,2j represents an element in a 2ith row and a 2jth column in the n×n-dimensional matrix, and Y represents dimensionality of the matrix.
A processor Pij whose subscripted symbol satisfies i=j is a diagonal processor and a processor Pij whose subscripted symbol does not satisfy i=j is a non-diagonal processor. In the processors Pij, an element whose subscripted symbol satisfies 2i=2j and 2i−1=2j−1 is a diagonal element, and an element whose subscripted symbol does not satisfy 2i=2j and 2i−1=2j−1 is a non-diagonal element.
The n×n-dimensional matrix is a real symmetric matrix. Therefore, with the assignment of the above process, only the upper right portion is preserved, and the lower left portion and the upper right portion are symmetric to each other with respect to the diagonal.
(2) Computing a Symbol Set Corresponding to a Rotation Angle 2θ by the Diagonal Processor and Outputting the Symbol Set to the Non-Diagonal Processor:
A symbol set {d2θ,k}, k=1, 2, . . . , N which corresponds to a rotation angle 2θ of the CORDIC algorithm, is obtained through iterations by using a formula as follows. A total number of the iterations is the same as a total number of iterations of the CORDIC algorithm:
wherein k represents an ordinal number of an iteration, N represents the total number of the iterations and is set as a data bit number adopted by the FPGA, αk represents a first symbol parameter of a kth iteration, βk represents a second symbol parameter of the kth iteration, θ0 represents a rotation angle initial value, that is, 2θ, θk represents a residual rotation angle through k times of iterations, ϕk−1 represents an angle parameter of a (k−1)th iteration, and d2θ,k represents a symbol corresponding to the rotation angle 2θ at the kth iteration.
Specifically, in a symbol computing module, d2θ,k is obtained by performing an exclusive OR operation on the sign bits of αk−1 and βk−1, where d2θ,k is 1 if the sign bits are the same, and d2θ,k is −1 if the sign bits are opposite. αk−12k−1 is obtained from αk−1 through a shift operation, and βk−12k−1 is obtained from βk−1 through a shift operation. If d2θ,k is 1, αk is obtained by performing a subtract operation on αk−12k−1 and βk−1, and βk is obtained by performing an add operation on βk−12k−1 and αk−1. If d2θ,k is −1, αk is obtained by performing an add operation on αk−12k−1 and βk−1, and βk is obtained by performing a subtract operation on βk−12k−1 and αk−1.
Iterative computing starts, and an initial rotation angle corresponding to the non-diagonal elements in the diagonal processor is θ. The computation is as follows:
a0=2apq, β0=app−aqq,
wherein apq, aqp respectively represent two non-diagonal elements initially included in the diagonal processor, aqp=apq, app, and app respectively represent diagonal elements initially included in the diagonal processor, α0 represents an initial first symbol parameter, and β0 represents an initial second symbol parameter.
The diagonal elements app and aqq of the diagonal processor obtain β0=app−aqq through a subtract operation. The non-diagonal element apq obtains α0=2apq in a shift operation. It is set that, in the parallel Jacobi computing, the rotation angle corresponding to the non-diagonal element in the current diagonal processor is θ, and β0 and α0 are input, as initial values, into a symbol set computing module, and the symbol computing module obtains a symbol set {d2θ,k} corresponding to the rotation angle 2θ through iterations.
The diagonal processor outputs the rotation angle 2θ obtained through computing carried out by itself and and the corresponding symbol set {d2θ,k} to a non-diagonal processor on the same row and a non-diagonal processor on the same column.
(3) Updating Elements of the Diagonal Processor:
The CORDIC algorithm is carried out on first to-be-rotated coordinates (2apq,app−aqq) by using d2θ,k obtained in each of the iterations in Step (2) as a rotation symbol of the kth iteration in the CORDIC algorithm. This process replaces the step of calculating a rotation symbol after each iteration in the conventional CORDIC algorithm. Accordingly, a planar rotation is carried out by using the rotation angle 2θ.
After all the iterations in Step (2) are completed, a final planar rotation result is multiplied by a first compensation factor to obtain rotated y coordinates, that is, y1=2apq sin 2θ+(app−aqq)cos 2θ. The first compensation factor is obtained according to a formula as follows:
wherein C1 represents the first compensation factor.
Diagonal elements in the diagonal processor are updated by using a formula as follows, and non-diagonal elements are set to 0:
wherein a′pp, a′qq represent two updated diagonal elements in the diagonal processor, y1 represents a rotated Y-axis coordinate of the first to-be-rotated coordinates.
(4) Updating Elements of the Non-Diagonal Processor:
(4.1) The non-diagonal processor Pij receives symbol sets output from two diagonal processors Pii, Pjj and represented as {d2θ
d
θ
+θ
,k=½(d2θ
d
θ
−θ
,k=½(d2θ
wherein dθ
Specifically, by subjecting each pair of symbols d2θ
(4.2) dθ
symbols in the two symbol sets {dθ
symbols, so as to establish lookup table data by using the values of the second compensation factor and the third compensation factor corresponding to the respective, different symbol combinations. The absolute value of each symbol in the first
symbols serves as a lookup address, and a lookup table is generated by using a block memory (block random access memory). An address bit number of the lookup table is set as
and a data depth is
wherein C2 represents the second compensation factor, and C3 represents the third compensation factor.
When the number of iterations of the CRODIC algorithm exceeds
(rounding up
the difference between the second and third compensation factors and 1 is less than 2−N+1, and the accuracy of N-bit signed fixed-point number is at most 2−N+1. Therefore, the remaining second and third compensation factors may be directly considered as 1, i.e., no compensation is required.
(4.3) For the non-diagonal processor, four elements included in the non-diagonal processor are represented as
The obtained dθ
wherein x2 and y2 respectively represent rotated coordinates of the second to-be-rotated coordinates.
The obtained dθ
wherein x3 and y3 respectively represent rotated coordinates of the third to-be-rotated coordinates.
(4.4) Adopting formulae as follows to update the elements in the non-diagonal processor:
a′
p
q
=½(x2+y3),
a′
p
q
=½(x3+y2),
a′
p
q
=½(x3−y2),
a′
p
q
=½(x2−y3),
wherein a′p
Specifically, by performing an add operation and a shift operation on x2 and y3, an updated value a′p
(5) Exchanging the Elements Between the Processors:
After the elements of the respective processors are updated, the matrix elements symmetric thereto are also updated to the same values. The updated elements between the processors are exchanged.
(5.A) The diagonal elements in the diagonal processor are exchanged.
It is assumed that a current diagonal processor Pii includes a diagonal element ap
For the diagonal element i represents a diagonal processor row/column ordinal number, if i=1, the diagonal element ap
For the diagonal element aq
a value of the diagonal element aq
the value of the diagonal element aq
(5.B) The non-diagonal elements in the diagonal processor and elements in the non-diagonal processor are exchanged by changing positions according to the following. Positions of the non-diagonal elements in the diagonal processor and the elements in the non-diagonal processor are shifted. It is noted that the elements may be shifted out of a processor to another processor. Accordingly, a subscripted row symbol of an element is the same as a row number of a diagonal element shifted to the same row after the exchanging of Step (5.A), and a subscripted column symbol of the element is the same as a column number of a diagonal element shifted to the same column after the exchanging of Step (5.A).
(6) Updating the non-diagonal elements in all the diagonal processors in the n×n-dimensional matrix by the Jacobi computing after the exchanging, returning to Step (2) for another round of processing and updating, repeating the updating until the non-diagonal elements in the n×n-dimensional matrix gradually converge to 0, finishing the updating when a predetermined convergence accuracy is met, and ending the parallel Jacobi computing.
The n×n-dimensional matrix is a covariance matrix of data collected by an antenna array or data before image dimensionality reduction, and is a real symmetric matrix.
In Step (1), if n in the n×n-dimensional matrix is an odd number, i.e., a matrix with odd-numbered dimensionality, the matrix is expanded into a matrix with even-number dimensionality by adding a n+1th column and a n+1th row, and element values of the added n+1th column and n+1th row are all set to 0.
In the invention, the kth symbol computed in Step (2) is provided to the CORDIC algorithms of Steps (3) and (4) for the kth iteration. Therefore, Steps (2), (3), and (4) are carried out simultaneously.
The updated values of the elements in the respective processors can be obtained by simply combining the computing results of the CORDIC algorithms. Therefore, operations for the elements of all the processors can be carried out simultaneously. According to the method of the invention, the time consumed for realizing one step of the parallel Jacobi computing is only one CORDIC cycle. Compared with the conventional method which consumes three CORDIC cycles, the computing time is significantly reduced, and the computing performance is facilitated.
The data of the n×n-dimensional matrix of the invention may be data collected by an antenna array for DOA estimation, or a covariance matrix used for reducing the dimensionality of image data by using a PCA algorithm.
The beneficial effects of the invention include the following.
The invention adopts a specifically designed linear combination method to replace the bilateral rotation method in the conventional parallel Jacobi computing. By using the symbol set of the rotation angle together with the combination of two symbol sets to replace the step of computing the rotation symbols in the CORDIC algorithm, the parallelism of the parallel Jacobi computing is facilitated, the computing time for each step in the parallel Jacobi computing is reduced, and one step of the parallel Jacobi computing can be realized in one CORDIC cycle.
The invention effectively facilitates the speed of realizing the parallel Jacobi computing in hardware. By realizing one step of the parallel Jacobi in one CORDIC algorithm cycle, the deficiency of the conventional method is alleviated. In addition, the time required is only one-third of that required by the conventional method.
The invention requires less FPGA resources while yields a higher internal computational processing performance of the FPGA. Accordingly, the invention is capable of facilitating the efficiency of realizing eigenvalue decomposition in the FPGA and is highly applicable in actual processing.
In the following, details of the invention will be described with reference to the accompanying drawings in combination with exemplary embodiments of the invention.
The framework realized in an FPGA of the invention mainly includes a diagonal processor and a non-diagonal processor. The framework of the diagonal processor is as shown in
The embodiment of the invention and the implementation process thereof are described in the following.
The specific implementation processes of the embodiment are realized in a Xilinx Virtex-7 XC7VX690T FPGA chip. Specifically, wireless signals emitted by a collector drone with a four-element antenna array is adopted in the implementation, and the signal incident direction is 0 degrees. A 4×4 real symmetric covariance matrix obtained through the computation carried out according to four data sets received by the four-element antenna is represented as A.
16-bit fixed-point number is adopted to obtain the eigenvalues under a condition that
Specifically, the following steps are included.
(1) Initializing the processors: The respective elements in Rr are assigned to the processors Pij. Each processor is connected with the adjacent processor via a data interface. A processor whose subscripted symbol satisfies i=j is defined as a diagonal processor, and a processor whose subscripted symbol does not satisfy such condition is defined as a non-diagonal processor. A matrix element whose subscripted symbol satisfies 2i=2j and 2i−1=2j−1 is defined as a diagonal element, and a matrix element whose subscripted symbol does not satisfy such condition is defined as a non-diagonal element.
(2) Computing a symbol set corresponding a rotation angle by the diagonal processor and outputting the symbol set to the non-diagonal processor: It is assumed that the non-diagonal elements included in the diagonal processor are apq, aqp, and aqp=apq. It is assumed that the diagonal elements included in the diagonal processor are app and app. It is also assumed that α0=2apq, β0=app−aqq. It is assumed that the rotation angle corresponding to the non-diagonal element in the current diagonal processor is θ. A symbol set d2θ,k, k=1, 2 . . . , 16, which corresponds to a rotation angle 2θ of the CORDIC algorithm is obtained through iterations. The number of iterations is the same as the number of iterations in the CORDIC algorithm, and the data bit number, i.e., 16, adopted in the current system is used.
(3) Updating the elements of the diagonal processor: A compensation factor is obtained. d2θ,k obtained in Step (2) is used as the rotation symbol of the kth iteration in the CORDIC algorithm. This process replaces the step of computing the rotation symbol after each iteration in the conventional CORDIC algorithm. The CORDIC algorithm is executed to rotate (2apq,app−aqq) by 2θ, and the result is multiplied by the compensation factor to obtain rotated y coordinates, i.e., y1=2apq sin 2θ+(app−aqq) cos 2θ, and the diagonal elements in the diagonal processor are updated. In addition, the non-diagonal elements are set to 0.
(4) Updating the elements of the non-diagonal processor: The non-diagonal processor Pij receives the symbol sets output from the two diagonal processors Pii, Pjj, and the symbol sets are represented as d2θ
dθ
It is assumed that the matrix elements included in the current non-diagonal processor are
and dθ
dθ
The elements of the non-diagonal processor are updated.
(5) Exchanging the elements between the processors: After the elements of the respective processors are updated, the matrix elements symmetric thereto are also updated to the same values. The updated elements are exchanged with the elements of other processors.
Then, the flow returns to Steps 2, 3, and 4 again for another round of computation and update. After three times of exchange, all the non-diagonal elements in the matrix have been updated once by the diagonal processors through Jacobi computing. Through multiple times of update, the non-diagonal elements in the matrix gradually converge to 0. The update ends after a predetermined convergence accuracy set by the user is met, and the parallel Jacobi computing ends.
The specific results are as follows:
First Round:
and the following is rendered after the update:
and the following is rendered after the element exchange:
Second Round:
and the following is rendered after the update:
and the following is rendered after the element exchange:
Eighth Round:
and the following is rendered after the update:
As shown above, the non-diagonal elements of the matrix has met the convergence condition (while parallel Jacobi computing is an algorithm that approximates the diagonal elements to 0, a fixed-point number with a limited number of bits is used in actual implementation to represent decimals, so even though the values of the non-diagonal elements may reach 0, errors are also introduced). At this time, the elements on the diagonal of Ā8 are the eigenvalues that are obtained. By applying the obtained eigenvalues to a signal direction-of-arrival (DOA) estimation algorithm, as shown in the following diagram, the power spectrum function of a multiple signal classification (MUSIC) algorithm reaches the peak value at 0 degrees, which shows that the invention realizes a proper function.
In the embodiment, the performance of the invention in the actual application is demonstrated in two aspects, i.e., operation time, FPGA resource consumption.
Operation time: Since 16-bit fixed-point number is set for the data, the number of times of internal iterations is 16 in the CORDIC algorithm. Considering the result compensation, there are 17 FPGA clock cycles for the CORDIC algorithm cycle. Considering also that the elements need to be exchanged between steps of the parallel Jacobi, which takes one clock cycle, it takes a total of 18 clock cycles for the method of realizing the accelerated parallel Jacobi computing of the invention to realize one step of the parallel Jacobi. In the embodiment, the convergence condition is set as the absolute value of the maximum value of the non-diagonal elements in the covariance matrix being less than 0.001. The convergence condition is met after 8 iterations, which takes 144 clock cycles. The clock frequency used in the example is set as 250M, which takes 0.576 milliseconds.
Resource consumption: A Verilog program realizing the example is integrated on the Vivado 2017.1 software platform. The results shows that the example consumes 2360 lookup tables (LUTs) and 688 registers (REGs), which respectively takes up 0.54% and 0.79% of the total resources. According to the above, the design consumes only a limited amount of FPGA resources.
According to the conventional method for realizing parallel Jacobi, the diagonal processors require a CORDIC algorithm cycle to obtain rotation angles, and then require two successive CORDIC algorithms using the rotation angles obtained by the diagonal processors to update the elements of the diagonal processors. In other words, the conventional method requires a total of three CORDIC algorithm cycles. The non-diagonal processor needs to wait for the diagonal processor to obtain the rotation angle. Then, the non-diagonal processor also requires two consecutive CORDIC algorithms to update the elements of the non-diagonal processor. The angles of two rotations are respectively the rotation angle transmitted from the diagonal processor on the same row and the rotation angle transmitted from the diagonal processor on the same column. The respective processors operate in parallel, and it requires at least three CORDIC algorithm cycles to realize one step of parallel Jacobi. According to the CORDIC algorithm used in the invention, the operations are carried out in parallel and only require only one CORDIC algorithm cycle. The comparison between the invention and the conventional method in terms of the processes of the processors is as shown in Table 2.
Based on the above, the invention significantly facilitates the speed of obtaining eigenvalues over the conventional method and is applicable when eigenvalue decomposition needs to be carried out quickly in actual processing.
The equivalent structural changes made by those skilled in the art based on the contents of the description and drawings of the invention shall be comprehensively covered in the scope of the invention.
Number | Date | Country | Kind |
---|---|---|---|
201910285351.4 | Apr 2019 | CN | national |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/CN2019/083494 | 4/19/2019 | WO | 00 |