Arithmetic device for performing division or square root operation of floating point number and arithmetic method therefor

When division X/Y of floating point numbers is performed, bit string data of a mantissa x including a fraction xf of X or a mantissa y including a fraction yf of Y is shifted in accordance with magnitude relation between them to perform a fraction computation. Thereby, a fraction division result in which the position of the most significant bit is fixed at a prescribed digit is generated. When a square root operation √Y is performed, a fraction square root operation result in which the position of the most significant bit is fixed at a prescribed digit is generated by an exception handling if all of the three conditions that all the bits in the fraction of Y are one, a difference between the exponent ye of Y and a bias value b is an odd number, and a rounding mode is a positive infinity direction are satisfied.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to an arithmetic device for performing division of floating point numbers or for performing square root operations, and also relates to an arithmetic method therefor.

2. Description of the Related Art

In recent years, various floating point arithmetic instructions are prepared as the instruction set architectures and arithmetic devices used for executing such floating point arithmetic instructions are provided in CPUs (Central Processing Units) in information processing devices such as server computers, personal computers, and the like (see Patent Documents 1 and 2 listed below).

The SRT (Sweeney-Robertson-Tocher) method, the Newton-Raphson method, the Goldschmidt method, etc. are employed as arithmetic algorithms for division and square root operations of floating point numbers. In these arithmetic methods, loop handling such as described below is performed.

FIG. 1shows a configuration of the above described conventional arithmetic device for performing division and square root operations of floating point numbers. The arithmetic device shown inFIG. 1includes registers11,12,15through18,21,22,26,29, and30, a fraction digit adjustment shifters13and14, selectors19,20, and31, a special operand processing circuit23, an exponent computation circuit24, a fraction computation circuit25, a fraction rounding circuit27, and a fraction normalization shifter28.

The special operand processing circuit23does not cause the computation unit to perform a usual computation process when two operands op1and op2are prescribed data, but causes the computation unit to perform exception handling such as a special operand process that outputs computation results of a fixed value data for the prescribed operand or error handling, or the like. The exponent computation circuit24performs the computation of the exponents of op1and op2. Also, the fraction computation circuit25performs division and square root operation of the fractions of op1and op2.

In the above floating point arithmetics, the computation results output from the fraction computation circuit25are not always the normalized numbers (this will be explained later). Further, the rounding process by using the fraction rounding circuit27is performed on the computation results, however, there is a probability that the most significant bit is carried over after the rounding process. Thus, usually, after the rounding process, the normalization shifting is performed on the fraction by using the fraction normalization shifter28, and the value in accordance with the shifted amount is added to the exponent by using the register29.

FIG. 2shows a configuration of the special operand processing circuit23shown inFIG. 1. The special operand processing circuit23includes a special operand detection circuit41and a generation circuit42. The special operand detection circuit41detects, on the basis of the values of op1and op2that are the computation target operands, the operands that have to undergo the special operand process or the exception handling, outputs the detection signals to the generation circuit42, and outputs a selection signal denoted by “sel normal/special”.

The generation circuit42generates a special computation result or an exception flag on the basis of the detection signal from the special operand detection circuit41, a rounding mode designation signal rd defined in a specification for floating point number arithmetics whose representative example is the IEEE (Institute of Electrical and Electronic Engineers)754, and the overflow/underflow detection signal “exp ovf/udf” from the exponent computation circuit24, and outputs it as the signal denoted by “special res”.

The selector31shown inFIG. 1operates in accordance with the selection signal “sel normal/special”, selects the signal “special res” output from the generation circuit42or a normal computation result that is generated by the exponent computation circuit24and the fraction computation circuit25in order to output the selected signal/result.

However, the above conventional arithmetic device has the problems as described below.

In division and square root operations of floating point numbers, results of the fraction computation circuit25are not always the normalized numbers, accordingly the results of the rounding process influences the computation results of the exponent.

Then, the selection signal for the fraction normalization shifter28and the input signal for the register29used for the addition of exponent are generated from a carry out signal of the incrementer in the fraction rounding circuit27or the significant bit signal that corresponds to the carry out signal. Accordingly, because it takes substantial time for the carry of the incrementer to arrive at the carry out signal or the significant bit signal, these signals can often serve as a bottle neck in view of the delay. Also, there is a probability that the overflow or underflow can be caused in the exponent computation circuit24depending on the results of the exponent addition. Thus, exception handling for the addition results has to be prepared to be performed after the addition.

As described above, the flow of data starting from the computation results in the fraction computation circuit25has been a factor that prevents the arithmetic devices from increasing the computation speed, and also has been a factor that complicates the circuit configurations.Patent Document 1:Japanese Patent Application Publication No. 07-182143Patent Document 2:Publication of Japanese Translation of PCT application No. 04-507023

SUMMARY OF THE INVENTION

It is an object of the present invention to standardize, into a uniform format, results of a fraction computation in division and square root operations of floating point numbers, and thereby to increase the computation speed and simplify the circuit configurations.

The first arithmetic device comprises a comparison unit, a shifting unit, a fraction computation unit and an exponent computation unit, and performs a computation on floating point operands X and Y having a fraction and an exponent.

The comparison unit compares magnitude of a fraction xf of the X and a fraction yf of the Y. The shifting unit shifts a mantissa x including the xf or a mantissa y including the yf in accordance with a comparison result between the xf and the yf. The fraction computation unit performs a fraction computation by using the mantissa that was shifted by the shifting unit and another mantissa, and outputs a computation result of a fraction in which a position of a most significant bit is fixed to be in a prescribed digit. The exponent computation unit performs an exponent computation by using an exponent xe of the X and an exponent ye of the Y, modifies a result of the exponent computation in accordance with the comparison result, and outputs a computation result of an exponent.

The second arithmetic device comprises a fraction computation unit, an exponent computation unit and an exception handling unit, and performs a square root operation of √Y on a floating point operand Y having a fraction and an exponent.

The fraction computation unit performs a fraction computation by using a fraction of the Y and outputs a fraction square root operation result in which a position of a most significant bit is fixed to be in a prescribed digit when any of three conditions that all the information of a fraction of the Y is one, ye−b that is a difference between an exponent ye of the Y and a bias value b in accordance with a computation precision is an odd number, and a rounding mode is a positive infinity direction is not satisfied. The exponent computation unit performs an exponent computation by using an exponent of the Y and outputs a square root computation result of the exponent of the Y. The exception handling unit outputs a computation result of √Y including a fraction square root operation result in which a position of a most significant bit is fixed to be in a prescribed digit when the three conditions are satisfied.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

Hereinafter, embodiments for carrying out the present invention will be explained in detail, by referring to the drawings.

FIG. 3shows a principle of first and second arithmetic devices according to the present invention.

The first arithmetic device according to the present invention includes a comparison unit101, a shifting unit102, a fraction computation unit103, and an exponent computation unit104, and executes a division instruction of X/Y when the floating point numbers X and Y are input as operands.

The comparison unit101compares the fraction xf of X and the fraction yf of Y, and the shifting unit102shifts the bit string data of the mantissa x including xf or the mantissa y including yf in accordance with the comparison result between xf and yf. The fraction computation unit103performs the fraction computation by using the shifted x and y, and outputs the fraction division result whose most significant bit is fixed to be in a prescribed digit regardless of the comparison result. The exponent computation unit104performs the exponent computation by using the exponent xe of X and the exponent ye of Y, modifies the result of the exponent computation in accordance with the above comparison result, and outputs the exponent division result.

When a bit string data corresponding to xf and yf in the input operands are input to the comparison unit101, a signal that represents the magnitude relation between xf and yf is output to the shifting unit102and the exponent computation unit104. In accordance with the signal, the shifting unit102shifts the bit string data of x or y to the prescribed direction. The exponent computation unit104modifies the computation result of xe and ye on the basis of the prescribed computation. The fraction computation unit103uses the shifted bit string data, and thereby generates a bit string data of the fraction division result, the bit string data having its most significant bit fixed to be in the prescribed digit regardless of the magnitude relation between xf and yf.

In division of floating point numbers, as will be described later, the position of the most significant bit in the bit string data of the result of the x/y computation changes in accordance with the magnitude relation between xf and yf. Thus, another method is used as an arithmetic method for fractions only when a particular magnitude relation such as x<y is satisfied, thereby the most significant bit can be fixed to be in a prescribed position.

The second arithmetic device according to the present invention includes the fraction computation unit103, the exponent computation unit104, and an exception handling unit105, and performs a square root operation of √Y when the floating point number Y is input as an operand.

The fraction computation unit103performs the fraction computation by using the fraction of Y, and outputs the normalized fraction square root computation result whose most significant bit is fixed to be in a prescribed digit when one of the three conditions (specifically, (1) all bits of the fraction of Y have the values of 1, (2) the difference between the exponent ye of Y and the bias value b i.e., ye−b is an odd number, and (3) the rounding mode defined in a specification for floating point number arithmetics whose most representative example is IEEE754 is positive infinity direction (rounding to a number closer to the positive infinity) is not satisfied. The exponent computation unit104performs the exponent computation by using the exponent of Y, and outputs the exponent square root operation result. The exception handling unit105outputs the operation result of √Y including the normalized fraction square root operation result whose most significant bit is fixed to be in a prescribed digit, when all the above three conditions are satisfied.

When one of the above three conditions is not satisfied, the bit string data of the normalized fraction square root operation result whose most significant bit is fixed to be in the prescribed digit is output from the fraction computation unit103, and the bit string data of the corresponding exponent square root operation result is output from the exponent computation unit104. When all the above three conditions are satisfied, the bit string data of the operation result of √Y including the normalized fraction square root operation result whose most significant bit is fixed to be in the prescribed digit is output from the exception handling unit105.

As will be described later, in the square root operations of floating point numbers, the position of the most significant bit in the bit string data of the computation result of the fraction changes only when all the above three conditions are satisfied. Because of this, the normalization can be performed by fixing the most significant bit to be in a prescribed position while such a case as above is handled as an exceptional case.

The comparison unit101corresponds to, for example a fraction comparison circuit303(that will be explained later) shown inFIG. 5or a fraction comparison circuit700shown inFIG. 9. The shifting unit102corresponds to, for example, a fraction digit adjustment shifter304shown inFIG. 5, a fraction digit adjustment shifter601shown inFIG. 8, or a fraction digit adjustment shifter701shown inFIG. 9.

The fraction computation unit103corresponds to, for example, a fraction computation circuit317and a fraction rounding circuit319shown inFIG. 5. The exponent computation unit104corresponds to, for example, an exponent computation circuit316shown inFIG. 5or an exponent computation circuit704shown inFIG. 9. The exception handling unit105corresponds to, for example, a special operand processing circuit315.

In the present embodiment, in division and square root operations of floating point numbers, the operands are optimized in the early stages of the operations or special input operands are processed in exception handling, thereby the result of the exponent computation can be established without waiting for the result of the rounding process to be finished. Thereby, it is possible to determine overflow/underflow only by the result of the exponent computation regardless of the result of the fraction computation. Thus, it is possible to remove a delaying factor that is the most significant in designing.

Hereinafter, explanations are given by using an example of the protocol of IEEE (Institute of Electrical and Electronic Engineers)754for floating point numbers. The IEEE floating point number consists of a sign s, an exponent e, and a fraction f as shown inFIG. 4, and defines a number (normalized number) represented by the numerical expression shown below,
(−1)s×2(e−b)×1.f
where b is a bias value that is 127 in the case of the single precision, and is 1023 in the case of the double precision. In the case of the single precision, the entire bit length of a floating point number is 32, and the bit lengths of s, e, and fare respectively 1, 8, and 23. Also, in the case of the double precision, the entire bit length of a floating point number is 64, and the bit lengths of s, e, and f are respectively 1, 11, and 52.

In the above numerical expression, the integer part of “1.f” is one (referred to as “implicit one”), and the part after the decimal point is a binary value represented by “f”. When the computation result is not within the range of the sufficient figure of f, the result is rounded to the least significant bit of the sufficient figure in accordance with the rounding rule of IEEE. When the size of this least significant bit of the sufficient figure is δ, δ=2−23in the case of the single precision, and δ=2−52in the case of the double precision. As is understood from the above explanation, the fraction of the floating point number format of the IEEE is a finite decimal whose minimum unit is δ. The existence range of “1.f” is represented by the inequality below,
1≦1.f≦2−δ  (1)
where “1.f” is not a number that can be consecutive values, but a multiple of δ that satisfies the existence range of the above inequality (1).
1.f=a×δ
where a is an integer.

In other words, “1.f” exists on the lattice points having the interval of δ on the line of real numbers. “Rounding” is to make approximations of numbers that are not multiples of δ by using the multiples of δ existing near them. Accordingly, a value before the “rounding” is a real number that is not subject to this kind of limitation, and a value after the “rounding” can be referred to as a value (=1.f) that satisfies the above limitation.

When a value of a certain computation result before rounding is a value that is out of the range of the inequality (1), the normalization shifting may be necessary for the value (=1.f) after rounding in order to change the value to a value (normalized number) that satisfies the IEEE floating point format.

When a value of a certain computation result before rounding is a value that is within the range of the inequality (1), it is not necessary to perform the normalization shifting on “1.f” after rounding. The upper limit and the lower limit of this inequality are multiples of δ, accordingly when a certain number is within the range of the inequality, the largest (smallest) value after rounding is the same as the upper (lower) limit, and will not exceed (fall less than) the upper (lower) limit.

Next, the fraction computation of the division X÷Y is considered. It is assumed that x represents the mantissa (1.f) of X and y represents the mantissa (1.f) of Y.

First, when x≧Y, the maximum value of the division (r=x÷y) is r=2−δ when y=1 and x=2−δ, and the minimum value thereof is r=1 when x=y. Accordingly, 1≦r≦2−δ is satisfied, and it can be recognized that the normalization shifting does not have to be performed on the value after rounding on the basis of the inequality (1).

When x<y, the normalization shifting on the value after rounding can be skipped by performing a pre-process that is appropriate for the operands. For example, one is subtracted from the exponent of X, and the division of r=2x÷y is performed with the mantissa of 2x.

From the inequality (2), it is recognized that the most significant bit of 2x/y is in the ones place in the mathematically precise value (value before rounding). Thus, the maximum value that 2x/y can be is examined further in detail.

Because x<y is satisfied, 2x/y becomes the maximum value when x/y is smaller than 1 and is closest to 1, that is, when x=y−δ. Then, r=2x/y=2−2δ/y is satisfied and also y<2 is satisfied, accordingly 2δ/y>2δ/2=δ is satisfied. Accordingly, the numerical expression below is satisfied.
2x/y=2−2δ/y<2−δ  (3)

When the inequality (2) and the expression (3) are combined, 1<2x/y<2−δ is satisfied, and it is recognized that the normalization shifting does not have to be performed on the value after rounding.

As a pre-process for the operands in the case of x<y, there is also a method of causing the mantissa to be y/2 by adding 1 to the exponent of Y. In this case too, it is possible to demonstrate, in the same manner as above, that the normalization shifting does not have to be performed on the value after rounding.

Next, the fraction computation of the square root operation of √Y is considered. It is assumed that the sign of Y is zero, its exponent is e, and its mantissa (1.f) is y. In this condition, √Y=√(2(e−b)×y) is satisfied.

When (e−b) is an even number (i.e., 2n), √Y can be changed as below.
√Y=√(22n×y)=(√y)×2n

When (e−b) is an odd number (i.e., 2n+1), √Y can be changed as below.
√Y=√(2(2n+1)×y)=√(22n×2y)={√(2y)}×2n

When (e−b) is an even number, if the square root q=√y(1≦y<2) is satisfied, q satisfies the inequality below.
1≦q<√2=1.0110 . . . (binary)  (4)

The inequality (4) represents that the normalization shifting does not have to be performed on the value of √Y after rounding.

When (e−b) is an odd number, if the root square q=√(2y), 2≦2y<4 is satisfied, accordingly q satisfies the inequality below.
√2≦q<2  (5)

From the inequality (5), it can be recognized that the most significant bit of √(2y) is in the ones place if this value is to be expressed in a mathematically precise manner. Then, the maximum value that √(2y) can be is examined further in detail.

√(2y) can become maximum when y=2−δ is satisfied. Then, √(2y)=√(4−δ) is satisfied. Also, it can be assumed that δ2<<δ is satisfied. The numerical expression below is obtained.
4−4δ+δ2<4−2δ<4−2δ+(δ/2)2
(2−δ)2<4−2δ<(2−δ/2)2
2−δ<√(4−2δ)<2−δ/2  (6)

The left side of the expression (6) includes the portion 2−δ<√(4−2δ), and it can be recognized that √(2y) has exceeded the range in which the necessity of the normalization shifting is eliminated.

Additionally, 2−δ represents the maximum value that “1.f” can be, and 2−δ/2 represents “the maximum value that 1.f can be +guard bit size”. “Guard bit” is a digit that is lower than the least significant bit, and the size thereof is δ/2. Accordingly, it is recognized that only when the rounding mode is “positive infinity direction”, the carrying-over of the most significant bit of √(2y) is caused and the normalization shifting becomes necessary.

It is when y=2−2δ is satisfied that √(2y) becomes the secondary largest value. In this condition, √(2y)=√(4−δ) is satisfied. When δ is replaced with 2δ in the expression (6), the inequality below is obtained.
2−2δ<√(4−4δ)<2−δ  (7)

From the inequality (7), it is recognized that √(2y) is within the range in which it eliminates the necessity of the normalization shifting. Because f(x)=√x (x>0) is a monotonically increasing function, to satisfy √x1<√x2 and to satisfy x1<x2 are in a relationship of the necessary and sufficient condition. In other words, when x1<x2 is satisfied, √x1>√x2 is not satisfied, and when x1<x2 is satisfied, √x1<√x2 is always satisfied.

Accordingly, it is recognized that only the case when y becomes the maximum value is the exceptional case, and the normalization shifting is not necessary on the computation results in the other cases.

In the above explanation, consideration is given to the case in which the input mantissa of the square root operation is within the range of 1≦y or 2y<4, however, it is possible to consider the case in which the mantissa is within the range of ¼≦y or 2y<1. Also in this case, the same explanation can be applied.

From the above consideration, by discriminating the operands when starting the computation and by performing a necessary pre-process, it is possible to delete the logic of the normalization shifting process that would be performed after the rounding process. The discrimination can be expressed as below.

2. Square Root Operation

(e−b) is an odd number and mantissa y=maxexception handling

Next, by referring toFIGS. 5 through 8, an arithmetic device for performing the above division and square root operation will be explained.

FIG. 5shows a configuration of an arithmetic device according to the present embodiment. The arithmetic device includes a first operand op1register301for storing the entirety of op1, a second operand op2register302for storing the entirety of op2, a first operand op1staging latch306for storing the entirety of op1, a first operand op1exponent staging latch308for storing the exponent of op1, a second operand op2staging latch307for storing the entirety of op2, a second operand op1exponent staging latch309for storing the exponent of op2, a fraction comparison result staging latch310for storing a fraction comparison result, a first operand op1fraction register313for storing the fraction of op1, a second operand op2fraction register314for storing the fraction of op2, a fraction computation circuit output staging latch318for storing a computation result of the fraction computation circuit, a fraction comparison circuit303, fraction digit adjustment shifters304and305, a first operand selector311for the fraction computation circuit, a second operand selector312for the fraction computation circuit, a computation circuit output selector320, a special operand processing circuit315, an exponent computation circuit316, a fraction computation circuit317, and a fraction rounding circuit319.

The special operand processing circuit315does not cause the computation unit to perform a usual computation process when the two operands (op1and op2) are prescribed data, but causes the computation unit to perform exception handling such as a special operand process that outputs a computation result of a fixed value data for the prescribed operand or error handling, or the like. For example, when the square root operation is instructed, all the bits in the fraction of the operand op2have the values of 1, the value of (e−b) i.e., the difference between the exponent of the operand op2and the bias value is an odd number, and the rounding direction is “positive infinity”, a signal “exp result+1” that is a carry signal for causing the carrying-out of the square root operation result to the most significant bit is output to the exponent computation circuit316. Also, when an overflow/underflow detection signal “exp ovf/udf” that will be explained later is received from the exponent computation circuit316, a special computation result or an exception flag is generated, and the generated special computation result or the exception flag is output as a signal “special res”.

The exponent computation circuit316performs the computation of the exponents of op1and op2. For example, in division, the exponent xe of op1and the exponent ye of op2are used in order to output xe−ye−1 or xe−ye+1 as the exponent computation result signal “exp result”. Further, when the signal “exp result+1” is received from the special operand processing circuit315, one is added to the exponent computation result that is an output of the exponent computation circuit316. Also, when the overflow/underflow is caused as a result of an exponent computation, an overflow/underflow detection signal “exp ovf/udf” is output to the special operand circuit.

Also, the fraction computation circuit317performs division and the square root operation of the fractions of op1and op2. op1and op2respectively correspond to the above described X and Y. Also, the signal denoted by “loop” is a feed-back signal used for performing division by repeating subtraction.

FIG. 6shows a configuration of the special operand processing circuit315shown inFIG. 5. The special operand processing circuit315includes a special operand detection circuit401, a generation circuit402, an AND circuit403, and an OR circuit404, and a selector405.

The special operand detection circuit401does not cause the computation unit to perform a usual computation process when the two operands (op1and op2) are prescribed data, but detects operands that have to undergo exception handling such as a special operand process that outputs a computation result of a fixed value data for the prescribed operand or error handling, or the like in order to output the detection signal to the generation circuit402and the OR circuit404.

One example of the above special operand process is a square root operation performed on an operand in which all the bits in the fraction have the values of 1 (y is the maximum value) in the case when the rounding mode is “positive infinity direction” and the value of (e−b) i.e., the difference between the exponent of the operand and the bias value is an odd number.

The AND circuit403outputs, to the OR circuit404and the exponent computation circuit316, the logical products of four signals411through414that will be explained below as the signal “exp result+1”. The signal411is an output signal of an instruction decoder (not shown) that is asserted when square root operations are instructed. The signal412is an output signal of an operand decoder (not shown) that is asserted when all the bits in the fraction of the operand op2has the values of one (y is the maximum value). The signal413is an output signal of an operand decoder (not shown) that is asserted when the value of (e−b) of the operand op2is an odd number. The signal414is an output signal of a computation mode register (not shown) that is asserted when the rounding mode is “positive infinity direction”.

Accordingly, the output signal “exp result+1” of the AND circuit403is asserted only if an arithmetic unit does not perform a usual computation process when an operand that is the square root operation target is prescribed data and exception handling such as a special operand process that outputs a computation result of a fixed data for the prescribed operand, error handling, or the like has to be performed in the square root operation. Also, the signal “exp result+1” that is a carry signal for causing the carrying-over in the most significant bit of the square root computation result is output to the exponent computation circuit.

The OR circuit404outputs, as the selection signal “sel normal/special”, the logical sum between the detection signal from the special operand detection circuit401and the output signal of the AND circuit403.

The generation circuit402generates a special computation result or an exception flag on the basis of the detection signal from the special operand detection circuit401, the output signal of the AND circuit403, the rounding mode designation signal rd, and the overflow/underflow detection signal “exp ovf/udf” from the exponent computation circuit316, and outputs the special computation result or the exception flag as the signal “special res” when the overflow/underflow is detected by the overflow/underflow detection signal. The exponent of the special computation result is output as a signal “special exp”, and the fraction is output as a signal “special fraction”.

Especially, when the output signal of the AND circuit403is asserted, the generation circuit402generates the result of the square root operation √(2y) of the fraction when the value of (e−b) is an odd number, all the bits in the fraction have the values of 1, and the rounding mode is “positive infinity direction”, and outputs the generated result as the signal “special fraction”. When all the bits in the fraction have the values of 1, the computation result of (2y) can be identified uniquely, accordingly the computation result is beforehand stored in, for example, the generation circuit402. In this case, the result of the square root operation of the exponent is supplied from the exponent computation circuit316as “exp result”.

The selector405operates in accordance with the output signal of the AND circuit403. When the output signal of the AND circuit403is asserted with all the conditions of the exception handling being satisfied, the selector405selects the computation result “exp result” from the exponent computation circuit316, and outputs the selected result. Also, when the output signal of the AND circuit403is deasserted with at least one of the conditions of the exception handling not being satisfied, the selector405selects the signal “special exp” from the generation circuit402. The special operand processing circuit315outputs, together with the signal “special fraction”, the output signal of the selector405as the signal “special res”.

The selector320shown inFIG. 5operates in accordance with the selection signal “sel normal/special” generated by the special operand processing circuit315, and selects and outputs the signal “special res” from the generation circuit402when the selection signal “sel normal/special” is asserted. Also, when the selection signal “sel normal/special” is deasserted, the selector320selects and outputs a normal computation result that is generated by the exponent computation circuit316and the fraction computation circuit317.

By using this special operand processing circuit315, the computation results in the case when the value of (e−b) of the operand that is the square root computation target is an odd number and all the bits in the fraction have the values of 1 can be generated independently of the fraction computation circuit317. In this case, the output of the fraction rounding circuit319is not selected, accordingly shifting for the normalization does not have to be performed.

FIG. 7shows the circuit portion consisting of the fraction comparison circuit303, the fraction digit adjustment shifters304and305, the fraction comparison result staging latch310, and the exponent computation circuit316shown inFIG. 5. In this example, when x<y is satisfied, one is subtracted from the exponent of X and division 2x÷y is performed on the assumption that the mantissa of the operand op1is x and the mantissa of the operand op2is y.

Then, a fraction “op1frac” of the operand op1corresponding to the mantissa x is input to the fraction comparison circuit303and the fraction digit adjustment shifter304, and a fraction “op2frac” of the operand op2corresponding to the mantissa x is input to the fraction comparison circuit303and the fraction digit adjustment shifter305. Then, the fraction comparison circuit303compares “op1frac” and “op2frac” to each other, and asserts, when op1frac<op2frac is satisfied, an output signal representing this comparison result.

In response to this, the fraction digit adjustment shifter304shifts the mantissa x to the left by one bit in accordance with the output from the fraction comparison circuit303in order to double the mantissa x including the implicit one. Thereby, the fraction computation circuit317generates the computation result of 2x/y.

Also, when it is assumed that the exponents of X and Y are respectively xe and ye, the division result of the exponents are as below.
(xe−1)−ye=xe−ye−1

Thus, the fraction comparison result staging latch310outputs the value of “−1” to the exponent computation circuit316when the output signal of the fraction comparison circuit303is asserted. In response to this, the exponent computation circuit316outputs the computation result “exp result” that is obtained by adding “−1” to the result of subtracting the exponent “op2exp” of the operand op2from the exponent “op1exp” of the operand op1for the mantissa X.

Further, this computation is not a square root operation, but division, accordingly, the output of the AND circuit403shown inFIG. 6is zero, and “sel normal” is selected as the signal “sel normal/special” that is the output of the special operand processing circuit315. Accordingly, the “sel normal” side is selected in the selector320, and “exp result” is output as the final computation result.

FIG. 8shows a configuration for performing, instead of performing division of 2x÷y, division of x÷(y/2) that is equivalent to the above division of 2x÷y when x<y is satisfied in the example shown inFIG. 7. In this configuration, one is added to the exponent of y, and the fraction digit adjustment shifter305shown inFIG. 7is replaced with the fraction digit adjustment shifter601.

When op1and op2are compared to each other by the fraction comparison circuit303and the output signal of the fraction comparison circuit303is asserted, the fraction digit adjustment shifter601shifts y to the right by one bit in order to multiply the mantissa y including the implicit one by ½. Thereby, the fraction computation circuit317generates the computation result of 2x/y similarly to the case shown inFIG. 5.

Also, the result of division of the exponent is as below.
xe−(ye+1)=xe−ye−1

Accordingly, the computation result of the operations of the fraction comparison result staging latch310and the exponent computation circuit316shown inFIG. 8is equivalent to the case shown inFIG. 5.

According to the configuration ofFIG. 7orFIG. 8, when the mantissas x and y of the two operands that are the targets of division satisfy x<y, a fraction computation result in which the most significant bit is fixed to be in the ones place can be obtained only by shifting one of the mantissas. Thereby, the normalization shifting after the rounding process becomes unnecessary.

In order to remove the fraction normalization shifter from an arithmetic device having an after-computation processing circuit both for the division and square root operation, discrimination of two cases that are shown in the examples ofFIGS. 7 and 8are required. In other words, it is necessary to perform the computation under the condition that the positions of the most significant bits of the results of division and square root operation are the same to each other.

In the examples shown inFIGS. 7 and 8, the most significant bit of the computation result after the rounding process is fixed to be in the ones place, however, the position of the most significant bit can be a place other than the ones place. For example, it is also possible to use an arithmetic method in which the most significant bit is fixed to be in the first decimal place. In this case, the above described pre-process of division is modified, for example, as described below, and in the square root operation, the computation of the fraction is performed within the range in which ¼≦y or 2y<1 is satisfied.

FIG. 9shows a configuration in which this computation method is applied. In this configuration, the fraction comparison circuit303shown inFIG. 7is replaced with a fraction comparison circuit700, and the fraction digit adjustment shifter304and the fraction digit adjustment shifter305are replaced with fraction digit adjustment shifters701and702. Also, the fraction comparison result staging latch310and the exponent computation circuit316are replaced with a register703and an exponent computation circuit704. Further, a subtraction circuit705is added in a stage later than the exponent computation circuit704, and a fraction normalization shifter706is added to a stage later than the fraction rounding circuit319.

When performing division, the fraction comparison circuit700compares “op1frac” and “op2frac” to each other, and asserts, when op1frac≧op2frac is satisfied, the output signal representing this computation result.

In response to this, the fraction digit adjustment shifter701shifts the mantissa x to the right by one bit in order to multiply the mantissa x including the implicit one by ½. Thereby, the fraction computation circuit317generates the computation result of x/(2y), and the fraction rounding circuit319outputs computation result in which the most significant bit is fixed to be in the first decimal place with respect to the computation result of the fraction computation circuit317. Then, the fraction normalization shifter706shifts the computation result of the fraction rounding circuit319to the left by one bit, and outputs the computation result in which the most significant bit is fixed to be in the first decimal place, and thereby performs the normalization.

Also, the result of division of the exponent is represented as below.
(xe+1)−ye=xe−ye+1

Then, the register703outputs to the exponent computation circuit704a value representing “+1” when the output signal of the fraction comparison circuit700is asserted. In response to this, the exponent computation circuit704outputs a value obtained by adding “+1” to the result of subtracting the exponent “op2exp” of the operand op2corresponding to ye from the exponent “op1exp” of the operand corresponding to xe.

However, it is necessary to perform subtraction on the result of the exponent computation because the fraction normalization shifter706shifts the result of the exponent computation to the left. Accordingly, the subtraction circuit705subtracts one from the output of the exponent computation circuit704, and outputs the result as the computation result “exp result”.

When op1frac<op2frac (x<y) is satisfied, the output signal of the fraction comparison circuit700is deasserted, and “op1frac” and “op2frac” are supplied to the fraction computation circuit317as they are, thereby x/y is generated as the computation result. Also, the exponent computation circuit704outputs the result of subtracting “op2exp” from “op1exp”. The post-processes performed by the fraction normalization shifter706and the subtraction circuit705are the same as in the case when x≧y is satisfied.

Next, when performing the square root operation, the signal “squareroot” that is an output of an instruction decoder (not shown) is asserted. In response to this, the fraction digit adjustment shifter702shifts the mantissa y to the right by two bits in order to multiply the mantissa y including the implicit one by ¼. The exponent computation circuit704performs the square root operation after adding two to “op2exp”. Thereby, the fraction computation circuit317shown inFIG. 5performs a computation in the range in which ¼≦y or 2y<1 is satisfied. The fraction rounding circuit319outputs a computation result in which the most significant bit is fixed to be in the first decimal place. The post-processes performed by the fraction normalization shifter706and the subtraction circuit705are the same as in the case of division.

According to the configuration shown inFIG. 9, fraction computation results in which the most significant bits are fixed to be in the first decimal place can be obtained both by division and square root operation. In this case, the normalization shifting has to be performed after the rounding process. However, a controlling process based on a carry-out signal output from the fraction rounding circuit319becomes unnecessary.

In the above configurations, the most significant bits of the results of the division and square root operation are fixed to be in the same positions, however, when after-computation processing circuits are provided respectively for division and square root operation, the positions expected for the most significant bits may be determined respectively for the computations.

FIG. 10shows the pipeline of the conventional arithmetic device and the pipeline of the arithmetic device shown inFIG. 5according to the present invention in order to show the effect of the speedup of computations in the present invention, in which the number of stages in the pipeline of the present invention is smaller. The left column represents names of stages including stage B (Beginning: pre-process), stage X1(eXecute1: first execution), stage X2(eXecute2: second execution), stage X* (eXecute*: the *-th execution), stage (new) lastX (final stage in the present invention), stage (old) lastX−1 (final−1 stage in the conventional example), and stage (old) lastX (final stage in the conventional example).

First, the pipeline process in the conventional example shown in the right half ofFIG. 10is explained. The pipeline in the conventional example consists of the register11for storing the operand op1, the register12for storing the operand op2, the fraction digit adjustment shifters13and14for adjusting the digits of the fractions of the operands that undergo the computation and computation precision, staging latches21and22for storing computation results between the pipeline computation stages, a division/square root operation unit25, a special operand processing circuit23, a fraction rounding processing circuit27, an one-bit left/right shifter28, a shifting amount storing staging latch29, a rounding process result storing staging latch30, an exponent computation circuit24, a selector (not denoted by any numeral), and a computation result storing register (result).

In the conventional examples, in the stage X1shown inFIG. 10, the fraction digit adjustment shifters13and14perform the adjustment of digits of the fraction of the operand that is going to undergo the computation. Next, in the stage X2through the stage (new) lastX, division or square root operation is performed by using the division/square root operation unit25on the basis of a loop process (“single/double sqr-exp: n cycle+1 cycle” inFIG. 10) for repeating subtraction. Also, in the stage (old) lastX−1 after this loop process, the fraction rounding circuit27performs fraction rounding process, and the one-bit left/right shifter performs the rounding process on the basis of the signal “sift amt” that is an output of the fraction rounding process circuit and indicates a rounding direction, and the rounding process result is stored in the rounding process result storing staging latch30. Further, in the stage (old) lastX, the exponent computation is performed by the exponent computation circuit24. Additionally, when an overflow/underflow is caused in the exponent computation circuit24, the exception handling according to the special operand processing circuit23is performed by using the overflow/underflow detection signal ov/ud, and when the exception handling is caused due to the signal “sel sp/nm” from the special operand processing circuit23, the output “special res” (not shown) output from the special operand processing circuit23is selected as the computation result, and in the other cases, the rounding process result stored in the rounding process result storing staging latch30is stored in the computation result storing register (result).

Next, the pipeline process shown in the left half inFIG. 10will be explained. The pipeline in the present invention includes the first operand register301for storing the operand op1, the second operand register302for storing the operand op2, the fraction comparison circuit303, the fraction digit adjustment shifters304and305for adjusting the digits of the fractions of the operands that undergo the computation and the computation precision, the staging latches313and314for storing the computation results between the pipeline computation stages, the division/square root operation unit317, the fraction rounding circuit319, a selector (not denoted by any numeral), and the computation result storing register (result).

According to the present invention, in the stage X1shown inFIG. 10, the fractions of the operand that are going to undergo the computation by the fraction comparison circuit303are compared, and the digit adjustment of the fractions of the operands to be computed are performed by using the fraction digit adjustment shifters304and305by using this comparison result. Next, in the stage X2through the stage (div/spr loop), division or a square root operation is performed in a loop process (“single/double: n cycle” inFIG. 10) in which subtraction is repeated, or the exception handling (“sqr-exp: m cycle” inFIG. 10) such as the special operand process of outputting the computation result of the fixed value for prescribed operand, the error handling or the like, without performing an usual computation process by using the arithmetic unit when the operands are the prescribed operands. Also, in the stage (new) lastX after the loop process, the fraction rounding circuit319performs the rounding process. Further, in accordance with the signal “sel sp/nm” from the special operand processing circuit315, the rounding process result is selected in the case of the usual process, and the rounding process result is registered in the computation result storing register (result). Alternatively, in the case of the special operand process, the error handling or the like, the output “special res” (not shown) of the special operand processing circuit315is selected as the computation result in accordance with the signal “sel sp/nm” from the special operand processing circuit315, and the selected output is stored in the computation result storing register (result) as the computation result.

Accordingly, in the case of the square root operation in the present invention, the exception handling by the special operand processing circuit315and the normal computation can be performed in parallel, therefore the latency or the number of computation cycles does not increase in the normal computations. Accordingly, as soon as the processes by the fraction rounding circuit319are finished, square root computations are completed (“single/double: n cycle” inFIG. 10).

In general, when division is to be performed, x and y have to be compared to each other before the fraction computation is performed as in the conventional examples, accordingly there is a probability that latency (number of computation cycles) in the computation pipeline increases.

However, as in the case of the conventional arithmetic device shown inFIG. 10, when the computation is continued without giving special treatment to the case of x<y, the normalization shifting after the rounding process and the exponent addition become necessary, and also it becomes necessary to calculate the quotient for one more bit because the position of the most significant bit of the computation result is not fixed. Accordingly, it is necessary to perform the loop process of the fraction one more time (“single/double: n+1 cycle” inFIG. 10). In the division/square root operation of the convergence type such as the Newton-Raphson method, the Goldschmidt method, etc, the precision of the convergence error that is higher by +1 bit is required. In other words, when the computation pipeline shown inFIG. 10according to the present invention and the computation pipeline in the conventional examples are compared to each other, the loop process of the fraction in division in the present invention is shortened by one stage (+1 cycle inFIG. 10), and because the exception handling (“sqr-exp: m cycle” inFIG. 10) such as the special operand process, the error handling or the like is shorter (m≦n inFIG. 10) than the normal computation process (“single/double: n cycle” inFIG. 10), accordingly the parallel processing can be realized, and the exception process after the rounding process as in the conventional pipeline can be skipped, thereby the pipeline can be shortened by two stages.

When the influence of the process of the exponent overflow/underflow upon the number of stages of the computation pipeline, the delay, and the complexity of the logic (fraction normalization process→exponent addition→exponent overflow/underflow→generation of a computation result and a flag in special operand process) is considered, it is possible to think that the arithmetic device according to the present invention has merits that are more important than the merit in the case of the comparison between x and y before the computation in the stage B inFIG. 10.

As described above, in the arithmetic device shown inFIG. 10, m≦n is usually satisfied where n represents the number of computation cycles necessary for the loop process of the fraction, and m represents the number of cycles necessary for the exception handling performed by the special operand processing circuit315. Thereby, the exception handling can be finished earlier than the loop process of the fraction.

By contrast, in the conventional arithmetic device, it is not possible to perform the process of the fraction overflow/underflow until the fraction computation is not finished, thus the exception handling is finished only when the process of the fraction rounding circuit27has been finished.

Also, in view of the simplicity of the computation, the method of the arithmetic device according to the present invention in which the operands are compared to each other in order to determine which operand is greater and an appropriate pre-process is performed on the input for the fraction computation circuit317is desirable.

As explained above, according to the present invention, the most significant bits of the results of the fraction computation can be fixed to be in prescribed positions regardless of the arithmetic method that is used for division/square root operation of floating point numbers. Accordingly, it is not necessary to determine whether the normalization shifting after the rounding process is necessary or not, thereby it is possible to determine overflow/under flow or the like in the computation results of the exponents separately from the computation of the corresponding fractions. Accordingly, the speed of the entire computation increases and the circuit configurations become simple.

Also, the occurrence frequency of the logic failures is reduced because of the simplified logic circuit, and the reduction of the time for the circuit simulation can be expected.