CN110633447B - Spherical distance fixed-point calculation method based on FPGA and calculation device thereof - Google Patents
Spherical distance fixed-point calculation method based on FPGA and calculation device thereof Download PDFInfo
- Publication number
- CN110633447B CN110633447B CN201910813823.9A CN201910813823A CN110633447B CN 110633447 B CN110633447 B CN 110633447B CN 201910813823 A CN201910813823 A CN 201910813823A CN 110633447 B CN110633447 B CN 110633447B
- Authority
- CN
- China
- Prior art keywords
- function
- lookup table
- arcsine
- spherical distance
- coordinate
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000004364 calculation method Methods 0.000 title claims abstract description 69
- 238000000034 method Methods 0.000 claims abstract description 34
- 238000013139 quantization Methods 0.000 claims abstract description 29
- 230000006835 compression Effects 0.000 claims abstract description 9
- 238000007906 compression Methods 0.000 claims abstract description 9
- 230000006870 function Effects 0.000 claims description 318
- 238000006243 chemical reaction Methods 0.000 claims description 22
- 230000009466 transformation Effects 0.000 claims description 2
- 238000013501 data transformation Methods 0.000 claims 2
- 238000010276 construction Methods 0.000 description 8
- 230000008569 process Effects 0.000 description 5
- 230000008859 change Effects 0.000 description 4
- 230000009471 action Effects 0.000 description 3
- 101100021997 Arabidopsis thaliana CYP97A3 gene Proteins 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 2
- 150000001875 compounds Chemical class 0.000 description 2
- 101100021996 Arabidopsis thaliana CYP97C1 gene Proteins 0.000 description 1
- 101100510695 Arabidopsis thaliana LUT2 gene Proteins 0.000 description 1
- 238000009825 accumulation Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000011156 evaluation Methods 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000001131 transforming effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F17/00—Digital computing or data processing equipment or methods, specially adapted for specific functions
- G06F17/10—Complex mathematical operations
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- General Physics & Mathematics (AREA)
- Pure & Applied Mathematics (AREA)
- Mathematical Optimization (AREA)
- Algebra (AREA)
- Computational Mathematics (AREA)
- Databases & Information Systems (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Mathematical Analysis (AREA)
- Complex Calculations (AREA)
- Image Processing (AREA)
Abstract
The invention discloses a method for calculating a fixed point of a spherical distance based on an FPGA (field programmable gate array), which comprises the following steps of: 1) quantifying the function value of the sine function in the independent variable value interval of the sine function; 2) constructing a lookup table of a sine function; 3) determining an independent variable and an independent variable value range of the arcsine function, and performing non-uniform quantization and compression on a function value of the arcsine function; 4) constructing a lookup table of an arcsine function; 5) and respectively determining the independent variable corresponding to the sine function and the independent variable corresponding to the arcsine function, generating an index address, and accessing a lookup table of the sine function and the arcsine function to obtain the spherical distance between the corresponding fixed points. The invention also discloses a spherical distance fixed point calculation device for realizing the spherical distance fixed point calculation method based on the FPGA. The FPGA-based spherical distance fixed-point calculation method and the calculation device thereof can reduce the storage cost of the lookup table on the premise of ensuring the calculation precision of the FPGA for calculating the spherical distance.
Description
Technical Field
The invention relates to the technical field of circuits and information processing, in particular to a spherical distance fixed-point calculation method and a calculation device based on an FPGA (field programmable gate array).
Background
Solving the spherical distance between two points is one of the common operations in the astronomy and geographic fields, for example, when an orbiting satellite performs tasks such as real-time target search and cone search, a large amount of spherical distance calculation needs to be performed by using acquired longitude and latitude or geocentric Coordinate data, such as WGS84(World Geodetic System 1984) coordinates and CGCS2000(China Geodetic Coordinate System2000) coordinates. At present, an FPGA (Field Programmable Gate Array) has good stability and hardware parallel computing capability, and is widely applied to small platforms and devices with limited hardware capability, such as micro-nano satellites, light-weight loads, portable instruments and the like, so as to process various fixed-point numerical computing tasks.
Unlike the calculation of the fixed point distance on a plane, a large number of trigonometric solution problems are involved because the calculation of the spherical distance requires the use of spherical geometry for the solution. For example, the coordinates of the point S and the point D in the rectangular spatial coordinate system (for example, the geocentric coordinate system) are (x)1,y1,z1) And (x)2,y2,z2) And the spherical radius is r, the spherical distance between the two points S and D can be expressed as:
if the point S is known as the equatorial coordinate (α)1,1) Wherein, α1Which represents the longitude of the vehicle,1the latitude is expressed, and the latitude can be converted into a corresponding rectangular coordinate through the following formula;
similarly, if the known coordinates of point D are equatorial (α)2,2) The above formula can also be used to convert to the corresponding rectangular coordinates.
Obviously, it can be known from the above formula that sine and cosine (sin/cos) and arcsin (arcsin) trigonometric functions need to be applied when calculating the spherical distance. However, when the spherical distance calculation formula or the coordinate transformation formula is performed in the FPGA, since the FPGA bottom layer can only support two types of arithmetic operations, an alternative scheme needs to be designed to solve the trigonometric function value. Considering that the independent variable value range of sine-cosine and arcsine functions is limited, currently, in engineering implementation, effective calculation of the trigonometric functions in the FPGA is realized by constructing a lookup table, and the specific method is as follows:
quantizing the independent variables of the sine function and the cosine function in the value range;
calculating corresponding function values of each quantized independent variable and storing the function values in sequence to form a corresponding lookup table;
and taking the quantized independent variable as an index address, and accessing the lookup table through the index address to obtain a corresponding function value.
The inventor finds that the prior art has at least the following problems:
the method comprises the steps of quickly obtaining function values of nonlinear functions such as trigonometric functions and the like based on a lookup table, and reducing the calculation complexity by increasing the storage overhead; generally, in order to ensure the calculation accuracy, it is desirable that the argument has a smaller quantization interval, however, the smaller quantization interval increases the length of the lookup table, and the hardware storage overhead is correspondingly increased. Because in the distance calculation formula, the error of the arcsine function lookup table is amplified when multiplied by the spherical radius r, in the coordinate conversion formula, the error accumulation can be caused by the continuous multiplication of the trigonometric function, and the error is further amplified after the multiplication of the trigonometric function and the spherical radius r; therefore, the calculation of the spherical distance has higher requirements on the precision of the trigonometric function lookup table, and when the lookup table is constructed by adopting the prior art, if the accuracy of the calculation result of the spherical distance is ensured, the hardware storage overhead is greatly caused.
Disclosure of Invention
In order to solve the technical problems in the prior art, the invention provides a spherical distance fixed-point calculation method based on an FPGA and a calculation device thereof.
Therefore, the invention discloses a spherical distance fixed point calculation method based on FPGA, which comprises the following steps:
1) according to the property of the sine function, quantifying the function value of the sine function in the independent variable value interval of the sine function;
2) constructing a reference lookup table, a first-order increment lookup table and a second-order increment lookup table of the sine function based on the function value of the quantized sine function so as to store the function values of all the quantized sine functions;
3) according to a spherical distance calculation formula between two points, determining an independent variable and an independent variable value range of the arcsine function, and performing non-uniform quantization and compression on a function value of the arcsine function in an independent variable value interval of the arcsine function;
4) constructing a reference lookup table, a first-order increment lookup table and a second-order increment lookup table of the arcsine function based on the function value of the quantized arcsine function so as to store the function values of all the quantized arcsine functions;
5) according to the specific numerical value of the coordinate of the fixed point, the independent variable corresponding to the sine function and the independent variable corresponding to the arcsine function are respectively determined, an index address is generated based on the determined independent variables, and the index address is used for accessing a reference lookup table, a first-order increment lookup table and a second-order increment lookup table of the sine function and the arcsine function so as to obtain the spherical distance between the corresponding fixed points.
Further, in the method for calculating the fixed point of the spherical distance based on the FPGA, the step 1 includes:
equally dividing an argument value interval [0, pi/2 ] of the sine function into N subintervals with the length of pi/2N, and when the argument is positioned in the subinterval [ i pi/2N, (i +1) pi/2N) (i-0, 1, …, N-1), the function value of the corresponding sine function is y (i) -sin ((i +0.5) pi/2N);
wherein, the specific numerical value of N is set according to the requirement of distance estimation precision.
Further, in the method for calculating a fixed point of spherical distance based on FPGA, the step 2 includes:
setting three parameters B, E and M according to the specific value of N based on the property of the sine function, and making N equal to B.E.M;
a reference lookup table of a sine function of length B.E, a first order increment lookup table of a sine function of length B (M-1), and a second order increment lookup table of a sine function of length B (E-1) · (M-1) are constructed, respectively.
Further, in the method for calculating the fixed point of the spherical distance based on the FPGA, the following B · E numerical values are sequentially stored in a reference lookup table of a sine function with a length of B · E:
y(0),y(M),y(2M),…,y[(BE-1)M]。
further, in the FPGA-based spherical distance fixed-point calculation method, B groups of data are sequentially stored in a first-order increment lookup table of a sine function with the length of B (M-1), and each group of data comprises M-1 numerical values;
wherein, the M-1 data of the k (k ═ 0,1, …, B-1) group is:
further, in the FPGA-based spherical distance fixed-point calculation method, B groups of data are sequentially stored in a second-order increment lookup table of a sine function with the length of B (E-1) · (M-1), and each group of data comprises (E-1) · (M-1) numerical values;
wherein, the data of (E-1) · (M-1) of the k (k ═ 0,1, …, B-1) group is:
further, in the method for calculating the fixed point of the spherical distance based on the FPGA, it is assumed that: the coordinates of the two fixed points under the space direct coordinate system are respectively (x)1,y1,z1) And (x)2,y2,z2) The radius of the spherical surface is r, and the spherical distance between two fixed points is expressed as
The step 3 comprises the following steps:
with w ═ x1-x2)2+(y1-y2)2+(z1-z2)2As an argument of the arcsine function, the function value of the corresponding arcsine function is taken asAnd in the independent variable value range [0,2r ] of the arcsine function2]And carrying out non-uniform quantization and compression on the function value of the arcsine function.
Further, in the method for calculating the fixed point of the spherical distance based on the FPGA, the independent variable value range [0,2r ] of the arcsine function2]By internally performing function values of arcsine functionsNon-uniform quantization and compression, comprising:
a. according to the requirement of the calculation accuracy of the spherical distance, the minimum quantization interval delta is set and calculated as followsFunction values of the individual arcsine functions:
b. selecting the N' function values, including: 1 st to N th1All function values are reserved; n th1+1 to N2The individual function value is carried outThe times are extracted uniformly, corresponding to a quantization interval ofN th2+1 to Nth3The individual function value is carried outThe times are extracted uniformly, corresponding to a quantization interval ofN th3+1 to Nth4The individual function value is carried outThe times are extracted uniformly, corresponding to a quantization interval ofIn this way, the quantization interval is continuously increased toCovering all N' function values and obtaining the number of the compressed function values as
Wherein,and N1,N2,…,NsSelected according to the nature of the arcsine function and the particular value of N'.
Further, in the method for calculating a fixed point of spherical distance based on FPGA, the step 4 includes:
setting three parameters B ", E" and M ", based on the nature of the arcsine function and according to the specific value of N", and making N "═ B" · E "· M";
a reference look-up table of an arcsine function of length B '. E ', a first order increment look-up table of an arcsine function of length B '. cndot. (M ' -1), and a second order increment look-up table of an arcsine function of length B ' (E ' -1) · (M ' -1) are constructed, respectively.
In addition, the present invention also discloses a spherical distance fixed point calculation device for implementing the above spherical distance fixed point calculation method based on FPGA, which is characterized in that the calculation device comprises: the coordinate format conversion unit, the coordinate caching unit and the spherical distance calculation unit are electrically connected in sequence;
the coordinate format conversion unit is used for converting the longitude and latitude coordinates into space rectangular coordinates;
the coordinate caching unit is used for receiving and storing an externally input space rectangular coordinate and receiving and storing a conversion result output by the coordinate format conversion unit;
the spherical distance calculating unit is used for receiving the space rectangular coordinate output by the coordinate caching unit, and calculating and outputting the spherical distance by using the received space rectangular coordinate.
The FPGA-based spherical distance fixed-point calculation method and the calculation device thereof utilize the construction method and the index access method of the set lookup tables of the sine function and the arcsine function, can reduce the storage cost of the lookup tables of the sine function and the arcsine function on the premise of ensuring the calculation precision of the spherical distance calculated by the FPGA, are easy to realize and have high reliability.
Drawings
The accompanying drawings, which are included to provide a further understanding of embodiments of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the invention and not to limit the invention. In the drawings:
FIG. 1 is a flowchart of a method for computing a spherical distance fixed point based on an FPGA according to an embodiment of the present invention;
FIG. 2 is a reference look-up table of sine functions for example 1 of the present invention;
FIG. 3 is a first order incremental look-up table of the sine function of example 1 of the present invention;
FIG. 4 is a second order delta look-up table for the sine function of example 1 of the present invention;
FIG. 5 is a reference look-up table of the arcsine function of example 2 of the present invention;
FIG. 6 is a first order incremental look-up table of the arcsine function of example 2 of the present invention;
FIG. 7 is a second order delta lookup table for the arcsine function of example 2 of the present invention;
fig. 8 is a schematic structural diagram of a spherical distance fixed point calculation device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the specific embodiments of the present invention and the accompanying drawings. It is to be understood that the described embodiments are merely a few embodiments of the invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
The technical scheme provided by the embodiment of the invention is described in detail below with reference to the accompanying drawings.
Let the coordinates of the point S and the point D in the rectangular space coordinate system (for example, the geocentric coordinate system) be (x)1,y1,z1) And (x)2,y2,z2) Radius of the sphere r, the sphere between points S and DThe face distance may be expressed as:
if the point S is known as the equatorial coordinate (α)1,1) Wherein, α1Which represents the longitude of the vehicle,1the latitude is expressed, and the latitude can be converted into a corresponding rectangular coordinate through the following formula;
similarly, if the known coordinates of point D are equatorial (α)2,2) The above formula can also be used to convert to the corresponding rectangular coordinates.
It can be known from the above formula that sine and cosine (sin/cos) and arcsin (arcsin) trigonometric functions are required to be applied when calculating the spherical distance. However, when the spherical distance calculation formula or the coordinate conversion formula is operated in the FPGA, the bottom layer of the FPGA can only support addition arithmetic operation and multiplication arithmetic operation, and can not support sine and cosine arithmetic operation; in order to ensure that the fixed-point calculation of the spherical distance can be realized in the FPGA, the embodiment of the invention provides a fixed-point calculation method of the spherical distance based on the FPGA and a calculation device thereof.
As shown in fig. 1, an embodiment of the present invention provides a method for calculating a spherical distance fixed point based on an FPGA, where the method for calculating a spherical distance fixed point includes the following steps:
1) according to the property of the sine function, quantifying the function value of the sine function in the independent variable value interval of the sine function;
2) constructing a reference lookup table, a first-order increment lookup table and a second-order increment lookup table of the sine function based on the function value of the quantized sine function so as to store the function values of all the quantized sine functions;
3) according to a spherical distance calculation formula between two points, determining an independent variable and an independent variable value range of the arcsine function, and performing non-uniform quantization and compression on a function value of the arcsine function in an independent variable value interval of the arcsine function;
4) constructing a reference lookup table, a first-order increment lookup table and a second-order increment lookup table of the arcsine function based on the function value of the quantized arcsine function so as to store the function values of all the quantized arcsine functions;
5) according to the specific numerical value of the coordinate of the fixed point, the independent variable corresponding to the sine function and the independent variable corresponding to the arcsine function are respectively determined, an index address is generated based on the determined independent variables, and the index address is used for accessing a reference lookup table, a first-order increment lookup table and a second-order increment lookup table of the sine function and the arcsine function so as to obtain the spherical distance between the corresponding fixed points.
The following specifically describes each step and principle of the method for calculating the fixed point of the spherical distance based on the FPGA according to the embodiment of the present invention.
Specifically, since the function values of the sinusoidal function y ═ sinx in the interval [0, pi) and the interval [ -pi, 0) are axisymmetric with respect to the axis x ═ pi/2 and the axis x ═ pi/2, respectively, and the function values in the interval [0, pi) and the interval [ -pi, 0) are centrosymmetric with respect to the origin; therefore, only the function values corresponding to the different arguments of the sine function y ═ sinx in the interval [0, pi/2 ] need to be determined, and when the arguments of the sine function y ═ sinx are located in other intervals, the function values corresponding to the different arguments of the known sine function y ═ sinx in the interval [0, pi/2 ] can be simply transformed to obtain the function values.
Based on the analysis of the properties of the sinusoidal function, in order to reduce the values required to be stored in the reference lookup table, the first-order increment lookup table, and the second-order increment lookup table of the sinusoidal function as much as possible, in the embodiment of the present invention, step 1 includes:
equally dividing an argument evaluation interval [0, pi/2 ] of a sine function y-sinx into N subintervals with the length pi/2N, and when the argument x is positioned in the subinterval [ i pi/2N, (i +1) pi/2N) (i-0, 1, …, N-1), taking the function value of the corresponding sine function as y (i) -sin ((i +0.5) pi/2N);
wherein, the specific numerical value of N is set according to the requirement of distance estimation precision.
Further, based on the selection and division of the argument value interval of the sine function y ═ sinx, step 2 includes:
setting three parameters B, E and M according to the specific value of N based on the property of the sine function, and making N equal to B.E.M;
a reference lookup table of a sine function of length B.E, a first order increment lookup table of a sine function of length B (M-1), and a second order increment lookup table of a sine function of length B (E-1) · (M-1) are constructed, respectively.
The reference lookup table of the sine function with the length of B.E sequentially stores the following B.E numerical values:
y(0),y(M),y(2M),…,y[(BE-1)M]。
b groups of data are sequentially stored in a first-order increment lookup table of a sine function with the length of B (M-1), and each group of data comprises M-1 numerical values; m-1 values of group k (k-0, 1, …, B-1) are:
b groups of data are sequentially stored in a second-order increment lookup table of a sine function with the length of B (E-1) · (M-1), and each group of data comprises (E-1) · (M-1) numerical values; the (E-1) · (M-1) values of the k (k ═ 0,1, …, B-1) group are:
the following provides an example of constructing a lookup table of a sine function by using the construction method of the lookup table of the sine function provided by the embodiment of the invention;
example 1
Specifically, assume that: the section N8192, [0, pi/2 ] is equally divided into 8192 subintervals, the calculated sine function value is represented by 15 fixed points, and the section N B · E · M becomes 128 × 8 × 8, and a reference lookup table, a first order increment lookup table and a second order increment lookup table of the sine function are respectively constructed according to the construction method provided by the embodiment of the invention. As shown in fig. 2, fig. 3 and fig. 4, the length of the reference lookup table of the sine function is B · E — 1024, and the data bit width is 15 bits; the length of a first-order increment lookup table of the sine function is B (M-1) ═ 896, and the data bit width is 6 bits; the length of a second-order increment lookup table of the sine function is B (E-1) · (M-1) ═ 6272, and the data bit width is 2 bits; it can be seen that the storage overhead of the reference lookup table, the first-order increment lookup table and the second-order increment lookup table of the sine function is 33280 bits in total. If the lookup table of the sine function is constructed by directly using the construction method in the prior art, all 8192 numerical values need to be stored by 15 bits, and the storage overhead is 122880 bits.
Further, referring to the construction process and principle of the reference lookup table, the first-order increment lookup table and the second-order increment lookup table of the sine function, in the embodiment of the invention, when the reference lookup table, the first-order increment lookup table and the second-order increment lookup table of the sine function are constructed, the independent variable and the independent variable value range of the sine function are determined according to the spherical distance calculation formula between two points, and the function value of the sine function is non-uniformly quantized and compressed in the independent variable value range of the sine function.
Specifically, assume that: the coordinates of the two fixed points under the space direct coordinate system are respectively (x)1,y1,z1) And (x)2,y2,z2) The radius of the spherical surface is r, and the spherical distance between two fixed points is expressed as
Since the FGPA bottom layer can only support two types of arithmetic operations of addition and multiplication, in order to avoid performing complicated operations of division and division in the FPGA, let w ═ x1-x2)2+(y1-y2)2+(z1-z2)2Then the spherical distance between two fixed points can be expressed asMeanwhile, when x is more than or equal to 0 and less than or equal to 2r2When there isThen toWhen w is in the interval [0,4r ]2]When the internal change is carried out, only the interval [0,2r ] needs to be determined first2]When the independent variable w is located in other intervals, the function values corresponding to different independent variables w in the space can be obtained by simple calculation according to the formula 3.
Based on the above analysis of the properties of the arcsine function, taking into account the functionIn the interval [0,2r2]The internal change rates are different, in order to reduce the numerical values required to be stored in the reference lookup table, the first-order increment lookup table and the second-order increment lookup table of the arcsine function as much as possible and improve the precision of each lookup table of the arcsine function, in the embodiment of the invention, the step 3 comprises the following steps:
with w ═ x1-x2)2+(y1-y2)2+(z1-z2)2As an argument of the arcsine function, the function value of the corresponding arcsine function is taken asAnd in the independent variable value range [0,2r ] of the arcsine function2]And carrying out non-uniform quantization and compression on the function value of the arcsine function.
Wherein, in the independent variable value range [0,2r ] of the arcsine function2]Non-uniformly quantizing and compressing function values of an inner pair arcsine function, comprising:
a. according to the requirement of the calculation accuracy of the spherical distance, the minimum quantization interval delta is set and calculated as followsFunction values of the individual arcsine functions:
b. selecting N' function values, including: 1 st to N th1All function values are reserved; n th1+1 to N2The individual function value is carried outThe times are extracted uniformly, corresponding to a quantization interval ofN th2+1 to Nth3The individual function value is carried outThe times are extracted uniformly, corresponding to a quantization interval ofN th3+1 to Nth4The individual function value is carried outThe times are extracted uniformly, corresponding to a quantization interval ofIn this way, the quantization interval is continuously increased toCovering all N' function values and obtaining the number of the compressed function values as
Wherein,and N1,N2,…,NsSelected according to the nature of the arcsine function and the particular value of N'.
Further, based on the above-mentioned arcsine functionIs selected from the argument intervals, and is notThe processing mode of uniform quantization and compression, step 4 includes:
setting three parameters B ", E" and M ", based on the nature of the arcsine function and according to the specific value of N", and making N "═ B" · E "· M";
a reference look-up table of an arcsine function of length B '. E ', a first order increment look-up table of an arcsine function of length B '. cndot. (M ' -1), and a second order increment look-up table of an arcsine function of length B ' (E ' -1) · (M ' -1) are constructed, respectively.
Wherein, the reference lookup table of the arcsine function with the length of B 'E' sequentially stores the following B 'E' numerical values:
y(0),y(M″),y(2M″),…,y[(B″E″-1)M″]。
the first-order increment lookup table of the arcsine function with the length of B '. cndot (M' -1) sequentially stores B 'group data, and each group of data comprises M' -1 numerical values; the M "-1 values of the j (j ═ 0,1, …, B" -1) group are:
the second-order increment lookup table of the arcsine function with the length of B '(E' -1) · (M '-1) stores B' group data in sequence, and each group data comprises (E '-1) · (M' -1) numerical values; the values of (E "-1) · (M" -1) of the j (j ═ 0,1, …, B "-1) group are:
the following provides an example of constructing a lookup table of an arcsine function by using the construction method of the lookup table of the arcsine function provided by the embodiment of the invention;
example 2
In particular, assuming that r is the earth radius, when the distance estimation accuracy is required to be of the order of Km, at [0,2r ]2]With an internal Δ of 223For the quantization intervals, 11150848 arcsine function values can be obtained; get N1=512,N2=1536,N3=9728,N4=140800,N5=665088,N62762240 and N711150848N' taken simultaneously Andbased on the above-mentioned set parameters, after the non-uniform quantization process, the arcsine function value can be reduced to N ″ -32768, further, if N ″ -E ″ -M ″ -512 ″ -8 × is made to be N ″, a first-order increment lookup table and a second-order increment lookup table of the arcsine function are respectively constructed according to the construction method provided by the embodiment of the present invention, as shown in fig. 5, 6 and 7, the length of the reference lookup table of the arcsine function is B ″ -E ″ -4096, the data bit width is 14 bits, the length of the first-order increment lookup table of the arcsine function is B ″ (M ″ -1) · 3584, the data bit width is 3 bits, the length of the second-order increment lookup table of the arcsine function is B ″ (E ″ -1) · (M ″ -1) · 25088, the data is 2 bits, it is known that the storage of the reference lookup table, the first-order increment lookup table of the arcsine function, the storage table of the arcsine function is B · 1 · (E · 118272), the storage of the storage table of the data bit width is 2 bits, and the total storage of the FPGA is difficult to store the maximum required data by using the FPGA coding method, and if the maximum N ″ quantization overhead of the FPGA coding method.
Further, in the embodiment of the present invention, after the lookup table of the sine function and the lookup table of the arcsine function are constructed, according to the specific numerical value of the coordinates of the given fixed points, the lookup table of the sine function is used to solve the sine function and the cosine function, and the lookup table of the arcsine function is used to solve the arcsine function, so as to obtain the spherical distance between the corresponding fixed points.
Specifically, how to solve the sine and cosine functions by using the lookup table of the sine function is explained in detail below.
Suppose that: solving a sine function value y (N), wherein N is more than or equal to-2N and less than 2N so as to correspond to a phase change range of [ -pi, pi);
because the lookup table of the sine function provided by the embodiment of the invention only covers the variation range of [0, pi/2 ], the sine function value y (n) is transformed by using a formula 4;
according to equation 4, when | N ≧ N, the lookup table of the sine function is indexed and accessed by using N '═ 2N- | N | to obtain a corresponding function value y (N') from the lookup table of the sine function; when | N | < N, using N '═ N | to index and access the lookup table of the sine function, so as to obtain the corresponding function value y (N') from the lookup table of the sine function; the function value y (n') obtained from the lookup table of the sine function is transformed by the formula 4 to obtain the required sine function value y (n).
Similarly, based on the transform relationship of sine function and cosine function, assume: solving the cosine function value z (N), wherein-2N is less than or equal to N and less than 2N, so as to correspond to the phase change range of [ -pi, pi);
transforming the cosine function values z (n) using equation 5;
according to equation 5, when | N | ≧ N, the lookup table of the sine function is indexed and accessed by using N ═ N | -N to obtain the corresponding function value z (N') from the lookup table of the sine function; when | N | < N, indexing and accessing a lookup table of the sine function by using N '═ N- | N | to obtain a corresponding function value z (N') from the lookup table of the sine function; the function value z (n') obtained from the lookup table of the sine function is transformed by equation 5 to obtain the desired cosine function value z (n).
The embodiment of the invention provides a sine function index access method, wherein for how to use n ' to index and access a lookup table of a sine function to obtain a corresponding function value y (n ') (z (n '));
specifically, the sine function index access method comprises the following steps:
generating a read address of a reference lookup table of a sine function using equation 6;
generating a read address of a first order increment lookup table of the sine function by using the formula 7;
generating a read address of a second order increment lookup table of the sine function by using the formula 8;
in the above-mentioned formula, the compound of formula,represents the rounded down operator, mod represents the modulus operator; in equation 7, n 'modM is required to be greater than or equal to 1, and when n' modM is equal to 0, the output value of the first-order increment lookup table is directly set to 0; in formula 8, theAnd n' modM is greater than or equal to 1 whenOr when n' modM is equal to 0, directly setting the output value of the second-order increment lookup table to be 0;
let LUT0, LUT1, and LUT2 denote values output from a reference lookup table, a first order increment lookup table, and a second order increment lookup table of a sine function obtained based on read addresses of the above respective lookup tables, respectively, and L denotes a data bit width of the reference lookup table of the sine functionThen, the function value y (n ') (z (n')) can be obtained by the calculation of equation 9,
further, referring to the above method for solving sine and cosine functions by using the lookup table of sine functions, the following description will be made on how to solve arcsine functions by using the lookup table of arcsine functions.
Suppose that: the function value f (w) of the arcsine needs to be solved, wherein w is more than or equal to 0 and less than or equal to 4r2;
Because the lookup table of the arcsine function provided by the embodiment of the invention only covers 0,2r2]So that the arcsine function values f (w) are transformed by equation 10;
according to the formula 10, when w is more than or equal to 0 and less than 2r2When usingIndexing and accessing a lookup table of the arcsine function to obtain a corresponding function value f (n) from the lookup table of the arcsine function; when 2r is2≤w≤4r2When usingIndexing and accessing a lookup table of the arcsine function to obtain a corresponding function value f (n) from the lookup table of the arcsine function; the function value f (n) obtained from the look-up table of the arcsine function is transformed by the formula 10 to obtain the required arcsine function value f (w).
The embodiment of the invention provides an arcsine function index access method, wherein for how to use n to index and access a lookup table of an arcsine function, a corresponding function value f (n) is obtained;
specifically, the arcsine function index access method comprises the following steps:
compressing N from the range {0,1, …, N ' -1} to the range {0,1, …, N ' -1} by using formula 11 to obtain a parameter N ';
generating a read address of a reference lookup table of the arcsine function using equation 12;
generating a read address of a first order increment lookup table of the arcsine function by using the formula 13;
generating a read address of a second order increment lookup table of the arcsine function by using the formula 14;
in the above-mentioned formula, the compound of formula,represents the rounded down operator, mod represents the modulus operator; in equation 13, n 'modM ≧ 1 is required, and when n' modM ≧ 0, the first-order increment lookup table output value is directly set to 0; in formula 14, theAnd n 'modM' is not less than 1 whenOr when n' modM ═ 0, directly setting the output value of the second-order increment lookup table to 0;
assuming that LUTs 3, LUT4, and LUT5 respectively represent values output from a reference lookup table, a first order increment lookup table, and a second order increment lookup table of an arcsine function obtained based on read addresses of the above respective lookup tables, function values f (n) can be obtained by calculation in equation 15, and f (n) is approximately equal to f (n'): LUT3+ LUT4+ LUT5 (15).
In addition, as shown in fig. 8, an embodiment of the present invention further provides a spherical distance fixed point calculating device for implementing the above FPGA-based spherical distance fixed point calculating method, where the calculating device includes: the coordinate format conversion unit, the coordinate caching unit and the spherical distance calculation unit are electrically connected in sequence; the coordinate format conversion unit is used for converting the longitude and latitude coordinates into space rectangular coordinates; the coordinate caching unit is used for receiving and storing an externally input space rectangular coordinate and receiving and storing a conversion result output by the coordinate format conversion unit; the spherical distance calculating unit is used for receiving the space rectangular coordinates output by the coordinate caching unit, and calculating and outputting the spherical distance by using the received space rectangular coordinates.
The following describes the structure and principle of the spherical distance fixed point calculation device provided by the embodiment of the present invention.
Specifically, the spherical distance fixed point calculation device provided by the embodiment of the invention can calculate the corresponding spherical distance according to different types of coordinate format input;
for example, assume that: the input coordinates are longitude and latitude coordinates (alpha, alpha represents longitude and latitude, the spherical radius is r, and the coordinate format conversion unit is used for converting the longitude alpha and the latitude input into space rectangular coordinates; firstly, indexing a lookup table of a sine function by using latitude to obtain cos and sin function values, and calculating to obtain rcos and a spatial coordinate z ═ rsin; then, using longitude alpha to index a lookup table of the sine function to obtain cos alpha and sin alpha function values, and calculating space coordinates x (rcosco alpha) and y (rcosin alpha); when the coordinates of the two fixed points are in a longitude and latitude coordinate format, the two groups of coordinates need to be sent to the coordinate format conversion unit at an interval of more than 2 clock cycles so as to avoid data calculation conflict.
Meanwhile, since in practical applications, longitude and latitude are usually provided in the form of "degree minute second", for example, the longitude α is in the format α0Degree α1Minute α2Second; to facilitate indexing the lookup table, first 10-mWith respect to units, α is transformed to an approximation α' using equation 16:then according to the calculation accuracy requirement, the method is carried out by 10-m·2PDivided into intervals of [0, π/2]The calculated function value is used for constructing a lookup table of the sine function, so that when the sine and cosine function value is solved, only the low P bits of α 'are abandoned, and α'/2 is utilizedPThe read address of the lookup table of the sine function is calculated, and more complicated angle conversion operation can be avoided.
Similarly, in the embodiment of the present invention, the latitude may be processed by referring to the above-described processing method of the longitude.
Further, the coordinate caching unit is used for receiving and storing an externally input space rectangular coordinate, or receiving and storing a conversion result of the coordinate format conversion unit, and sending the space rectangular coordinate or the conversion result after subtraction processing to the spherical distance calculation unit; for example, when two sets of spatial direct coordinates are obtained as (x)1,y1,z1) And (x)2,y2,z2) The coordinate caching unit firstly leads the two groups of space rectangular coordinates to be correspondingly subtracted, and then sends the result after subtraction into the spherical distance calculating unit; the spherical distance calculating unit uses w ═ x1-x2)2+(y1-y2)2+(z1-z2)2And (4) accessing a lookup table of the arcsine function by indexing, and acquiring a corresponding function value f (w) to obtain the spherical distance between two fixed points.
In the embodiment of the invention, the coordinate format conversion unit, the coordinate caching unit and the spherical distance calculation unit are all arranged on the FPGA; the coordinate format conversion unit, the coordinate buffer unit and the spherical distance calculation unit comprise a data multiplexer, a data selector, a register, a complex multiplier, a complex adder, a complex subtracter and a processor which are electrically connected with each other according to the connection relationship shown in figure 8.
Therefore, the method and the device for calculating the spherical distance fixed point based on the FPGA provided by the embodiment of the invention utilize the construction method and the index access method of the set lookup tables of the sine function and the arcsine function, can reduce the storage cost of the lookup tables of the sine function and the arcsine function on the premise of ensuring the calculation precision of the spherical distance calculated by the FPGA, and are easy to implement and high in reliability.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. In addition, "front", "rear", "left", "right", "upper" and "lower" in this document are referred to the placement states shown in the drawings.
Finally, it should be noted that: the above examples are only for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.
Claims (10)
1. A sphere distance fixed point calculation method based on FPGA is characterized in that the method is used for realizing calculation of a sphere distance between two fixed points by a field programmable logic gate array, and the method comprises the following contents:
1) according to the property of the sine function, quantifying the function value of the sine function in the independent variable value interval of the sine function;
2) constructing a reference lookup table, a first-order increment lookup table and a second-order increment lookup table of the sine function based on the function value of the quantized sine function, and respectively storing the reference lookup table, the first-order increment lookup table and the second-order increment lookup table of the sine function in an internal memory of the field programmable gate array so as to store the function values of all the quantized sine functions;
3) according to a spherical distance calculation formula between two points, determining an independent variable and an independent variable value range of the arcsine function, and performing non-uniform quantization and compression on a function value of the arcsine function in an independent variable value interval of the arcsine function;
4) constructing a reference lookup table, a first-order increment lookup table and a second-order increment lookup table of the arcsine function based on the function value of the quantized arcsine function, and respectively storing the reference lookup table, the first-order increment lookup table and the second-order increment lookup table of the arcsine function in an internal memory of the field programmable gate array so as to store the function values of all the quantized arcsine functions;
5) respectively inputting coordinate data of two fixed points of a spherical distance to be calculated and spherical radius data into a field programmable gate array, if the input coordinate data format is an equatorial coordinate data format, sequentially selecting longitude data and latitude data contained in the coordinate data by a data selector in the field programmable gate array, determining read addresses of a reference lookup table, a first-order increment lookup table and a second-order increment lookup table of a corresponding sine function through address transformation, accessing the reference lookup table, the first-order increment lookup table and the second-order increment lookup table of the sine function stored in a memory in the field programmable gate array by using the determined read addresses, and obtaining a sine function value corresponding to the longitude data and the latitude data through data transformation; if the input coordinate data format is a rectangular coordinate data format, the field programmable gate array directly stores the coordinate data in a register; the data selector in the FPGA sequentially selects the x coordinate, the y coordinate and the z coordinate in rectangular coordinate data of two fixed points stored in a register to calculate difference values, the coordinate difference values are sent to a multiplier and an adder to calculate the square sum of the coordinate difference values, the corresponding argument of an arcsine function is determined, the FPGA generates read addresses for accessing a reference lookup table, a first-order increment lookup table and a second-order increment lookup table of the arcsine function based on the argument of the arcsine function, accesses the reference lookup table, the first-order increment lookup table and the second-order increment lookup table of the arcsine function stored in an internal memory of the FPGA by using the determined read addresses, and determines and outputs the spherical distance between the two fixed points through data transformation.
2. The FPGA-based spherical distance fixed-point calculation method according to claim 1, wherein the step 1 comprises:
equally dividing an argument value interval [0, pi/2 ] of the sine function into N subintervals with the length of pi/2N, and when the argument is positioned in the subinterval [ i pi/2N, (i +1) pi/2N) (i-0, 1, …, N-1), the function value of the corresponding sine function is y (i) -sin ((i +0.5) pi/2N);
wherein, the specific numerical value of N is set according to the requirement of distance estimation precision.
3. The FPGA-based spherical distance fixed-point calculation method according to claim 2, wherein the step 2 comprises:
setting three parameters B, E and M according to the specific value of N based on the property of the sine function, and making N equal to B.E.M;
a reference lookup table of a sine function of length B.E, a first order increment lookup table of a sine function of length B (M-1), and a second order increment lookup table of a sine function of length B (E-1) · (M-1) are constructed, respectively.
4. The FPGA-based spherical distance fixed-point calculation method of claim 3, wherein the following B-E numerical values are sequentially stored in the reference lookup table of the sine function with the length of B-E:
y(0),y(M),y(2M),…,y[(BE-1)M]。
5. the FPGA-based spherical distance fixed-point calculation method of claim 4, wherein B groups of data are sequentially stored in a first-order increment lookup table of a sine function with the length of B (M-1), and each group of data comprises M-1 numerical values;
wherein, the M-1 data of the k (k ═ 0,1, …, B-1) group is:
6. the FPGA-based spherical distance fixed-point calculation method of claim 5, wherein the second-order increment lookup table of the sine function with the length of B (E-1) · (M-1) stores B groups of data in turn, and each group of data comprises (E-1) · (M-1) values;
wherein, the data of (E-1) · (M-1) of the k (k ═ 0,1, …, B-1) group is:
7. the FPGA-based spherical distance fixed-point calculation method of claim 1, wherein it is assumed that: the coordinates of the two fixed points under the space direct coordinate system are respectively (x)1,y1,z1) And (x)2,y2,z2) The radius of the spherical surface is r, and the spherical distance between two fixed points is expressed as
The step 3 comprises the following steps:
with w ═ x1-x2)2+(y1-y2)2+(z1-z2)2As an argument of the arcsine function, the function value of the corresponding arcsine function is taken asAnd in the independent variable value range [0,2r ] of the arcsine function2]Non-uniform quantization of function values of an intra-pair arcsine functionAnd compression.
8. The FPGA-based spherical distance fixed-point calculation method of claim 7, wherein the argument interval [0,2r ] of the arcsine function is2]Non-uniformly quantizing and compressing function values of an inner pair arcsine function, comprising:
a. according to the requirement of the calculation accuracy of the spherical distance, the minimum quantization interval delta is set and calculated as followsFunction values of the individual arcsine functions:
b. selecting the N' function values, including: 1 st to N th1All function values are reserved; n th1+1 to N2The individual function value is carried outThe times are extracted uniformly, corresponding to a quantization interval ofN th2+1 to Nth3The individual function value is carried outThe times are extracted uniformly, corresponding to a quantization interval ofN th3+1 to Nth4The individual function value is carried outThe times are extracted uniformly, corresponding to a quantization interval ofIn this way, the quantization interval is continuously increased toCovering all N' function values and obtaining the number of the compressed function values as
9. The FPGA-based spherical distance fixed-point calculation method of claim 8, wherein the step 4 comprises:
setting three parameters B ", E" and M ", based on the nature of the arcsine function and according to the specific value of N", and making N "═ B" · E "· M";
a reference look-up table of an arcsine function of length B '. E ', a first order increment look-up table of an arcsine function of length B '. cndot. (M ' -1), and a second order increment look-up table of an arcsine function of length B ' (E ' -1) · (M ' -1) are constructed, respectively.
10. A spherical distance pointing computing device for implementing the FPGA-based spherical distance pointing computing method according to any one of claims 1 to 9, wherein the computing device comprises: the coordinate format conversion unit, the coordinate caching unit and the spherical distance calculation unit are electrically connected in sequence;
the coordinate format conversion unit is used for converting the longitude and latitude coordinates into space rectangular coordinates;
the coordinate caching unit is used for receiving and storing an externally input space rectangular coordinate and receiving and storing a conversion result output by the coordinate format conversion unit;
the spherical distance calculating unit is used for receiving the space rectangular coordinate output by the coordinate caching unit, and calculating and outputting the spherical distance by using the received space rectangular coordinate.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910813823.9A CN110633447B (en) | 2019-08-30 | 2019-08-30 | Spherical distance fixed-point calculation method based on FPGA and calculation device thereof |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910813823.9A CN110633447B (en) | 2019-08-30 | 2019-08-30 | Spherical distance fixed-point calculation method based on FPGA and calculation device thereof |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110633447A CN110633447A (en) | 2019-12-31 |
CN110633447B true CN110633447B (en) | 2020-09-04 |
Family
ID=68969703
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910813823.9A Active CN110633447B (en) | 2019-08-30 | 2019-08-30 | Spherical distance fixed-point calculation method based on FPGA and calculation device thereof |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110633447B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112214563B (en) * | 2020-09-08 | 2024-09-03 | 北京首钢自动化信息技术有限公司 | Distance calculation method and device based on region division and electronic equipment |
CN113515166B (en) * | 2021-04-28 | 2024-04-19 | 杭州电子科技大学 | Sine lookup table data compression method based on FPGA |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN100545892C (en) * | 2003-12-18 | 2009-09-30 | 汤姆森特许公司 | Generate the method and apparatus of the look-up table in the video picture field |
CN104765713A (en) * | 2014-12-20 | 2015-07-08 | 中国科学院西安光学精密机械研究所 | Method for realizing FPGA digital signal processing based on segmented table look-up trigonometric function |
CN104536720B (en) * | 2014-12-22 | 2017-11-28 | 浙江中控研究院有限公司 | The measuring method and system of angle measurement trigonometric function value based on FPGA |
CN106681697B (en) * | 2016-12-29 | 2018-10-12 | 中国电子科技集团公司第五十四研究所 | Target access calculates Parallel Implementation method under a kind of CUDA frameworks |
CN108983169B (en) * | 2018-07-17 | 2022-08-02 | 西安电子科技大学 | Meter wave radar terrain correction method based on digital elevation model |
-
2019
- 2019-08-30 CN CN201910813823.9A patent/CN110633447B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN110633447A (en) | 2019-12-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108021537B (en) | Softmax function calculation method based on hardware platform | |
EP2304546B1 (en) | Sine/cosine generator | |
Ramírez et al. | Fast RNS FPL-based communications receiver design and implementation | |
CN110633447B (en) | Spherical distance fixed-point calculation method based on FPGA and calculation device thereof | |
US5737253A (en) | Method and apparatus for direct digital frequency synthesizer | |
CN110488228B (en) | Linear frequency modulation signal generation method and device and storage medium | |
CN109085879A (en) | A kind of high-precision DDS frequency synthesizer for the multi-functional calibration platform of electricity | |
CN105680859B (en) | ADC built-in self-test circuit in system on chip and test method | |
JPH0522271B2 (en) | ||
US9151842B2 (en) | Method and apparatus for time of flight sensor 2-dimensional and 3-dimensional map generation | |
WO2001007992A1 (en) | Method and system for generating a trigonometric function | |
Thomas et al. | Fixed-point implementation of discrete Hirschman transform | |
CN110765238A (en) | Data encryption query method and device | |
Fang et al. | A unified reconfigurable CORDIC processor for floating-point arithmetic | |
CN1166226C (en) | Digital method for generating local oscillation signal and numeral controlled oscillator | |
Vinh et al. | FPGA Implementation of Trigonometric Function Using Loop-Optimized Radix-4 CORDIC | |
KR19990085924A (en) | Trigonometric function generator and method | |
Joseph et al. | FPGA implementation of Radix-2 FFT processor based on Radix-4 CORDIC | |
Pan et al. | Hierarchical resampling algorithm and architecture for distributed particle filters | |
CN104753530A (en) | Phase correction and nonuniform phase amplitude conversion method and device in DDS | |
Cao et al. | A piecewise cubic polynomial interpolation algorithm for approximating elementary function | |
CN117908833B (en) | Acceleration method and device of MCU high-order integer divider | |
Juang et al. | Optimization and Implementation of Scaling‐Free CORDIC‐Based Direct Digital Frequency Synthesizer for Body Care Area Network Systems | |
US20240134608A1 (en) | System and method to accelerate microprocessor operations | |
Huang et al. | FPGA Implementation of a Novel Type DDS Based on CORDIC Algorithm |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |