Method, system and device for realizing 32-bit integer division with high precision

文档序号:1042311 发布日期:2020-10-09 浏览:20次 中文

阅读说明:本技术 一种高精度实现32位整数除法的方法、系统及装置 (Method, system and device for realizing 32-bit integer division with high precision ) 是由 谭定富 于 2020-06-24 设计创作,主要内容包括:本发明公开了一种高精度实现32位整数除法的方法,所述方法包括:将第一被除数和第一除数均输入判零单元,当第一被除数和第一除数均不为0,判零单元输出第二被除数和第二除数;将第二被除数和第二除数输入符号提取模块,符号提取模块输出商的符号、第三被除数和第三除数;将第三被除数和第三除数输入缩放模块,对第三被除数和第三除数进行缩放,输出第四被除数、第四除数、第三被除数缩放因子和第三除数缩放因子;将第四被除数、第四除数输入CORDIC迭代单元,更新商及初值value,进行迭代;迭代完成后,CORDIC迭代单元将商输出到结果输出单元,结果输出单元输出商和缩放因子。本发明有效保证了商的精度,且输出位宽较小,方便后续使用,误差小于千分之一。(The invention discloses a method for realizing 32-bit integer division with high precision, which comprises the steps of inputting a first dividend and a first divisor into a zero judging unit, and outputting a second dividend and a second divisor by the zero judging unit when the first dividend and the first divisor are not 0; inputting the second dividend and the second divisor into a symbol extraction module, and outputting the symbol of the quotient, the third dividend and the third divisor by the symbol extraction module; inputting the third dividend and the third divisor into a scaling module, scaling the third dividend and the third divisor, and outputting a fourth dividend, a fourth divisor, a third dividend scaling factor and a third divisor scaling factor; inputting the fourth dividend and the fourth divisor into a CORDIC iteration unit, updating the quotient and the initial value, and performing iteration; and after the iteration is finished, the CORDIC iteration unit outputs the quotient to a result output unit, and the result output unit outputs the quotient and the scaling factor. The invention effectively ensures the precision of quotient, has small output bit width, is convenient for subsequent use, and has error less than one thousandth.)

1. A method for implementing 32-bit integer division with high precision, the method comprising:

inputting the first dividend and the first divisor into a zero judging unit, and outputting a second dividend and a second divisor by the zero judging unit when the first dividend and the first divisor are not 0;

inputting the second dividend and the second divisor into a symbol extraction module, and outputting the symbol of the quotient, the third dividend and the third divisor by the symbol extraction module;

inputting the third dividend and the third divisor into a scaling module, scaling the third dividend and the third divisor, and outputting a fourth dividend, a fourth divisor, a third dividend scaling factor and a third divisor scaling factor;

inputting the fourth dividend and the fourth divisor into a CORDIC iteration unit, updating the quotient and the initial value, and performing iteration;

and after the iteration is finished, the CORDIC iteration unit outputs the quotient to a result output unit, and the result output unit outputs the quotient and the scaling factor.

2. The method for high precision 32-bit integer division according to claim 1, further comprising:

inputting the first dividend and the first divisor into a zero judging unit, and outputting the first dividend and the first divisor, wherein the first dividend and the first divisor are respectively input into the zero judging unit and the zero judging unit comprises the following steps:

when the first dividend is 0, the result output unit directly outputs the quotient to be 0, and the scaling factor is 0;

when the first dividend is not 0 and the first divisor is 0, the result output unit directly outputs the quotient to be 4095 and the scaling factor to be 20.

3. The method for high precision 32-bit integer division according to claim 1, wherein the sign of the quotient is directly sent to a result output unit;

the third dividend scaling factor and the third divisor scaling factor are directly sent to a result output unit.

4. The method of claim 3, wherein the scaling the third dividend and the third divisor is specifically:

the third dividend and the third divisor are scaled to an effective bit number of 12 bits.

5. The method of claim 4, wherein the initial value is 2^12, and the number of iterations is 12.

6. The method of claim 5, wherein the iterative process comprises:

obtaining di-sign (fourth dividend) according to the sign of the fourth dividend input by the current iteration;

update the fourth dividend: the fourth dividend ═ (fourth dividend + di × fourth divisor) × 2, update quotient: the quotient-di value/2^ (i-1), i is the iteration number;

and judging whether the updated fourth dividend is 0 or not, if so, directly finishing the iteration, and outputting the quotient to a result output unit by the CORDIC iteration unit, otherwise, continuing the iteration.

7. The method of claim 6, wherein the quotient is computed by a sign of a quotient-by-quotient and the scaling factor is computed by a third dividend scaling factor-third divisor scaling factor-12.

8. A system for realizing 32-bit integer division with high precision is characterized by comprising a zero judging unit, a symbol extracting module, a scaling module, a CORDIC iteration unit and a result output unit, wherein,

the zero judging unit is used for judging whether the first dividend and the first divisor are zero or not and outputting a second dividend and a second divisor;

the symbol extraction module is used for outputting a symbol of a quotient, a third dividend and a third divisor;

the scaling module is used for scaling the third dividend and the third divisor and outputting a fourth dividend, a fourth divisor, a third dividend scaling factor and a third divisor scaling factor;

the CORDIC iteration unit is used for updating the quotient and the initial value and performing iteration;

the result output unit is used for outputting the quotient and the scaling factor.

9. An apparatus for implementing 32-bit integer division with high precision, comprising:

at least one processor;

and a memory communicatively coupled to the at least one processor;

wherein the memory stores instructions executable by the at least one processor, the instructions, when executed by the at least one processor, cause the at least one processor to perform the method of any of claims 1-7.

Technical Field

The invention belongs to the technical field of wireless communication, and particularly relates to a method, a system and a device for realizing 32-bit integer division with high precision.

Background

In the field of digital signal processing, 32-bit integer dividers are often used, such as in signal normalization, and channel estimation.

The existing division schemes often use derivative division, an SRT method, an addition and subtraction alternation method, a CORDIC method and the like, but the operation period of the methods often increases greatly along with the increase of digits, and the power consumption is wasted. Some of these methods require a multiplier resource, which consumes more resources and operation cycles. Moreover, with the increase of the data bit width, the intermediate bit width of the arithmetic unit is increased more and more, and the occupied storage space is large. In order to ensure the performance, the bit width of the output result is large, and the resource overhead is large when the subsequent addition and multiplication are used.

Disclosure of Invention

In view of the above problem, the present invention provides a method for implementing 32-bit integer division with high precision, wherein the method comprises:

inputting the first dividend and the first divisor into a zero judging unit, and outputting a second dividend and a second divisor by the zero judging unit when the first dividend and the first divisor are not 0;

inputting the second dividend and the second divisor into a symbol extraction module, and outputting the symbol of the quotient, the third dividend and the third divisor by the symbol extraction module;

inputting the third dividend and the third divisor into a scaling module, scaling the third dividend and the third divisor, and outputting a fourth dividend, a fourth divisor, a third dividend scaling factor and a third divisor scaling factor;

inputting the fourth dividend and the fourth divisor into a CORDIC iteration unit, updating the quotient and the initial value, and performing iteration;

and after the iteration is finished, the CORDIC iteration unit outputs the quotient to a result output unit, and the result output unit outputs the quotient and the scaling factor.

Further, the method further comprises:

inputting the first dividend and the first divisor into a zero judging unit, and outputting the first dividend and the first divisor, wherein the first dividend and the first divisor are respectively input into the zero judging unit and the zero judging unit comprises the following steps:

when the first dividend is 0, the result output unit directly outputs the quotient to be 0, and the scaling factor is 0;

when the first dividend is not 0 and the first divisor is 0, the result output unit directly outputs the quotient to be 4095 and the scaling factor to be 20.

Further, the symbol of the quotient is directly sent to a result output unit;

the third dividend scaling factor and the third divisor scaling factor are directly sent to a result output unit.

Further, the scaling the third dividend and the third divisor specifically includes:

the third dividend and the third divisor are scaled to an effective bit number of 12 bits.

Further, the initial value is 2^12, and the iteration number is 12.

Further, the iterative process includes:

obtaining di-sign (fourth dividend) according to the sign of the fourth dividend input by the current iteration;

update the fourth dividend: the fourth dividend ═ (fourth dividend + di × fourth divisor) × 2, update quotient: the quotient-di value/2^ (i-1), i is the iteration number;

and judging whether the updated fourth dividend is 0 or not, if so, directly finishing the iteration, and outputting the quotient to a result output unit by the CORDIC iteration unit, otherwise, continuing the iteration.

Further, the quotient is calculated by a sign of quotient x quotient, and the scaling factor is calculated by a third dividend scaling factor-third divisor scaling factor-12.

The invention also provides a system for realizing the 32-bit integer division with high precision, which comprises a zero judgment unit, a symbol extraction module, a scaling module, a CORDIC iteration unit and a result output unit, wherein,

the zero judging unit is used for judging whether the first dividend and the first divisor are zero or not and outputting a second dividend and a second divisor;

the symbol extraction module is used for outputting a symbol of a quotient, a third dividend and a third divisor;

the scaling module is used for scaling the third dividend and the third divisor and outputting a fourth dividend, a fourth divisor, a third dividend scaling factor and a third divisor scaling factor;

the CORDIC iteration unit is used for updating the quotient and the initial value and performing iteration;

the result output unit is used for outputting the quotient and the scaling factor.

The invention also provides a device for realizing the 32-bit integer division with high precision, which comprises:

at least one processor;

and a memory communicatively coupled to the at least one processor;

the memory stores instructions executable by the at least one processor, which when executed by the at least one processor, cause the at least one processor to perform the method described above.

The invention realizes division by CORDIC, only has addition and shift operation, has lower resource consumption and is convenient for hardware realization. And a zero judgment module is added in the CORDIC unit, so that invalid iteration is avoided, and the power consumption is reduced. The dividend and the divisor are scaled to the same amplitude position through the scaling module, so that the calculation bit width is reduced, the requirement on the iteration times is reduced, and the operation period is shortened. The output result uses the form of quotient plus scaling factor, thereby effectively ensuring the precision of quotient, having small output bit width, facilitating subsequent use, and having error less than one per thousand.

Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.

FIG. 1 shows an overall flow diagram of a method of an embodiment of the invention;

fig. 2 shows a schematic diagram of the operation of the ith CORDIC iteration unit according to the embodiment of the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

The invention provides a method for realizing 32-bit integer division with high precision, and exemplarily, fig. 1 shows an overall flow chart of the method according to the embodiment of the invention, as shown in fig. 1, the method includes:

the method comprises the following steps: inputting the first dividend and the first divisor into a zero judging unit, and outputting a second dividend and a second divisor by the zero judging unit when the first dividend and the first divisor are not 0, and carrying out the next step;

inputting the first dividend and the first divisor into a zero judging unit, and outputting the first dividend and the first divisor, wherein the first dividend and the first divisor are respectively input into the zero judging unit and the zero judging unit comprises the following steps:

when the first dividend is 0, the result output unit directly outputs the quotient to be 0, and the scaling factor is 0;

when the first dividend is not 0 and the first divisor is 0, the result output unit directly outputs the quotient to be 4095 and the scaling factor to be 20.

Step two: inputting the second dividend and the second divisor into a symbol extraction module, and outputting a quotient symbol, a third dividend and a third divisor by the symbol extraction module, wherein the quotient symbol is directly sent to a result output unit;

step three: inputting a third dividend and a third divisor into a scaling module, scaling the third dividend and the third divisor to an effective bit number of 12 bits, and outputting a fourth dividend, a fourth divisor, a third dividend scaling factor and a third divisor scaling factor, wherein the third dividend scaling factor and the third divisor scaling factor are directly sent to a result output unit;

step four: inputting the fourth dividend and the fourth divisor into the CORDIC iteration unit, updating the quotient and the initial value ^ 2^12, and performing iteration 12 times, wherein the operation of the ith CORDIC iteration unit is as shown in fig. 2:

1. obtaining di-sign (fourth dividend) according to the sign of the fourth dividend input by the current iteration;

2. update the fourth dividend: the fourth dividend ═ (fourth dividend + di × fourth divisor) × 2, update quotient: the quotient-di value/2^ (i-1), i is the iteration number;

3. and judging whether the updated fourth dividend is 0 or not, if so, directly finishing the iteration, and outputting the quotient to a result output unit by the CORDIC iteration unit, otherwise, outputting the fourth dividend and continuing the iteration.

Step five: after the iteration is completed, the CORDIC iteration unit outputs the quotient to the result output unit, and the result output unit outputs the quotient and the scaling factor, wherein the quotient is a sign of the quotient, and the scaling factor is a third dividend scaling factor-a third divisor scaling factor-12.

The intermediate bit width of the divider is within 14 bits, the intermediate bit width is realized by only adding and shifting, and the most significant bit of the quotient obtained by the divider is 12 bits. For calculating y/x, the quotient a is output, and the scaling factor b, y/x ═ a × 2^ (b). When a subsequent multiplication is used, a is used directly and b is kept on. When there is addition, the scaling factors before and after addition are aligned and then directly added.

For example, for a certain LTE receiver, the maximum receiving antenna is set to be 4, the maximum number of receiving layers is set to be 4, and when the actual receiving antenna is 4 and the number of receiving layers is 2, the received signal is set to beThe corresponding channel estimate isThen the value of y-H x + n,n is a 2 x 1 matrix, and an ML solution of x is required to be solved.

Inputting H and y into QR decomposition module, outputting to obtain 4 x 3 upper triangleMatrix array

Figure BDA0002556007860000054

It can be known that the ML solution of y ═ H × x + n is equivalent to the equation

Figure BDA0002556007860000055

By reverse-pushing to get x1=R23/R22,x2=(R13-R12*x2)/R11

At this time, in order to solve the equation, the dividend R needs to be obtained by using the divider according to the embodiment of the present invention23Divisor R22Input into a divider to obtain a quotient and scaling factors a, b, then x1And a is 2b, namely the requirement is obtained.

The invention realizes division by CORDIC, only has addition and shift operation, has lower resource consumption and is convenient for hardware realization. And a zero judgment module is added in the CORDIC unit, so that invalid iteration is avoided, and the power consumption is reduced. The dividend and the divisor are scaled to the same amplitude position through the scaling module, so that the calculation bit width is reduced, the requirement on the iteration times is reduced, and the operation period is shortened. The output result uses the form of quotient plus scaling factor, thereby effectively ensuring the precision of quotient, having small output bit width, facilitating subsequent use, and having error less than one per thousand.

The invention also provides a system for realizing the 32-bit integer division with high precision, which comprises a zero judgment unit, a symbol extraction module, a scaling module, a CORDIC iteration unit and a result output unit, wherein,

the zero judging unit is used for judging whether the first dividend and the first divisor are zero or not and outputting a second dividend and a second divisor;

the symbol extraction module is used for outputting a symbol of a quotient, a third dividend and a third divisor;

the scaling module is used for scaling the third dividend and the third divisor and outputting a fourth dividend, a fourth divisor, a third dividend scaling factor and a third divisor scaling factor;

the CORDIC iteration unit is used for updating the quotient and the initial value and performing iteration;

the result output unit is used for outputting the quotient and the scaling factor.

The invention also provides a device for realizing the 32-bit integer division with high precision, which comprises:

at least one processor;

and a memory communicatively coupled to the at least one processor;

the memory stores instructions executable by the at least one processor, which when executed by the at least one processor, cause the at least one processor to perform the above-described method of high precision 32-bit integer division.

It should be noted that "first", "second", "third", and "fourth" in the embodiments of the present invention are merely used for distinguishing purposes, and do not indicate a sequential relationship or any other substantial meaning.

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.

9页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:用于矩阵运算的加速器系统和方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类