The present invention relates to computing and floating point arithmetic, and, more particularly, to systems and methods to implement an improved floating point adder.
The Institute of Electrical and Electronics Engineers (IEEE) specifies a standard, IEEE Std 754, for representation and conversion of exponential or floating point numbers. For example, integer numbers can be converted to exponential numbers and binary numbers can be used to represent different parts of the exponential numbers. In particular, an exponential, or floating point, number includes a sign, a significand or mantissa, and an exponent. The precision of the floating point number indicates the number of bits available to represent the floating point number; that is, the higher the precision, the more bits available. A single precision floating point number is represented by 32 bits: one bit for the sign bit, eight bits for the exponent, and 23 bits for the mantissa. For norm numbers, a bit value of one is understood to precede the 23 bits of the mantissa, becoming in effect, an implicit one most significant bit.
Floating point arithmetic is used for high-powered computing operations that require millions or billions or more of floating point operations per second (FLOPS). Basic functional building blocks such as floating point adders, multipliers and dividers are used to perform the arithmetic operations on floating point numbers. Numerous methods and systems of implementing binary adders in compliance with the IEEE 754 standard are well known in the art. A common general technique for adding two floating point numbers includes aligning and then adding the mantissas of the floating point numbers to produce an arithmetic result for a mantissa. Arriving at the final result for the mantissa and for the calculation typically involves continued shifting and aligning, followed by a final rounding step, according to, for example, the round to nearest method of IEEE Std 754.
The design of floating point arithmetic functions to manage high amounts of data throughput at ever increasing speeds and in ever reducing chip area presents challenges for designers of circuit architecture to contend with. Implementations of floating point arithmetic functional blocks, such as binary floating point adder implementations, need to become faster, more efficient, and take up less space on-chip. Accordingly, it would be desirable to provide alternative implementations and schemes that do not suffer from the drawbacks and weaknesses of existing implementations but rather that are faster, more efficient, that consume incrementally less space on chip.
The presently preferred embodiments described herein include systems and methods for implementing an improved floating point adder that integrates adding and rounding.
A method of adding a first floating point number to a second floating point number is provided according to one aspect of the invention. According to the method, a first mantissa, a second mantissa, and an input bit are added together to produce a third mantissa. The third mantissa is normalized to produce a final mantissa. The third mantissa and the final mantissa are correctly rounded as a result of the act of adding.
A method of adding a first floating point number to a second floating point number is provided according to a further aspect of the invention. According to the method, a first mantissa is added to a second mantissa. A fourth mantissa is added to an input bit to round the fourth mantissa. A third mantissa is normalized. The acts of adding are integrated together within a single adder to produce the third mantissa.
A method of adding a first floating point number to a second floating point number is provided according to another aspect of the invention. According to the method, a first mantissa, a second mantissa, and an input bit are added together to produce a third mantissa and an output bit. The third mantissa is rounded by updating the input bit based on the output bit to produce a fourth mantissa. The fourth mantissa is normalized. The acts of adding and rounding are integrated within a single adder so that a separate adder to produce a correctly rounded result is not needed and so that the acts of adding and rounding are performed prior to the act of normalizing.
A method of adding a first floating point number to a second floating point number is provided according to a further aspect of the invention. According to the method, a first floating point number having a first mantissa and a second floating point number having a second mantissa are received. The first floating point number, when added to the second floating point number, produces a third floating point number having a third mantissa. The first mantissa and the second mantissa are respectively left-shifted as appropriate to obtain a fourth mantissa and a fifth mantissa. A first carry bit is produced from a second carry bit and from round control variables derived from the first mantissa and the second mantissa. The fourth mantissa, the fifth mantissa and the first carry bit are added together to produce a sixth mantissa and the second carry bit. The sixth mantissa is correctly rounded. The sixth mantissa is right-shifted to produce the third mantissa.
A floating point adder system to add a first floating point number to a second floating point number is provided according to another aspect of the invention. The system includes an adder and a shifter coupled to the adder. The adder performs an add operation to add a first mantissa, a second mantissa, and an input bit together to produce a third mantissa. The shifter normalizes the third mantissa to produce a final mantissa, The third mantissa and the final mantissa are correctly rounded as a result of the add operation performed by the adder.
The foregoing and other features, aspects, and advantages will become more apparent from the following detailed description when read in conjunction with the following drawings, wherein:
The present invention will now be described in detail with reference to the accompanying drawings, which are provided as illustrative examples of preferred embodiments of the present invention.
The presently preferred embodiments described herein include systems and methods for implementing an improved floating point adder that integrates adding and rounding. Two mantissas are added together to produce a correctly rounded mantissa prior to normalization of the mantissa, making a follow on rounding stage unnecessary and conserving more space on chip. With feedback of a carry output of the adder, a less significant bit of the correctly rounded mantissa is a function of a more significant bit of the mantissa.
Similarly, the first unpack stage 104 of
Processing of the exemplary FADD 100 shown in
The floating point numbers f1 and f0 are processed by the unpack stages 104, 106, respectively, as described above, so that on the left-hand side of
Processing of the remaining mantissa m3 continues downward with the introduction of two control variables, K3 and L3 to the adder 130. L3 and K3 respectively represent the least significant bit m3[0] and the second least significant bit m3[1] of the mantissa m3 that serves an input to the adder stage 114.
A control variable for the FADD 100, ADD, is calculated by applying the Boolean equivalence function to the sign bits s1 and s0, so that when s1 and s0 are both false or are both true, the floating point numbers f0 and f1 have the same sign, an addition operation is being performed, and ADD is true, that is, is equal to a logic one. Similarly, when s1 and s0 are different valued, a subtraction operation is being performed, and ADD is false, that is, is equal to a logic zero. The inverter 110 is provided to complement the ADD control variable to produce the SUB control variable which is input to the complement stage 112 and the adder 132.
Processing continues and the right shifter 108 receives and shifts the bits of the 25 bit mantissa m2 to the right according to the value of the following control variable, RSHIFT, where
RSHIFT=e3−e2.
Accordingly, if RSHIFT is equal to zero, the mantissa m2 is not shifted. The right shifter 108 produces a 25 bit mantissa m4 as well as a series of control variables K4, L4, G4, R4, and S4. TABLE I is a truth table for generation of K4, L4, G4, R4, and S4 within the right shifter 108 given the value of the control variable RSHIFT. For example, if RSHIFT is equal to 23, then K4 is equal to the most significant bit m2[24] of the mantissa m2, that is, K4 is False. The control variables L4 and K4 respectively represent the least significant bit m4[0] and the second least significant bit m4[1] of the mantissa m4.
At the complement stage 112, if SUB is False, then ADD is True and an addition is being preformed and none of the inputs to the complement stage 112 are complemented. If, however, SUB is True, each binary digit of the mantissa m4 as well as each of the control variables K4, L4, G4, R4, and S4 are complemented by the complement stage 112. The operation of the complement stage 112 is summarized as follows:
TABLE II is a truth table for generation of Cin, G8, R8, and S8 within the adder 132 given the values of the control variable SUB and the input control variables G6, R6, and S6. For example, if SUB is True, and G6, R6, and S6 are all True, then G8, R8, and S8 are all False and the overflow bit Cin is True. The signal Cin serves as a carry input to the adder stage 114 as well as the adder 130.
Cin = SUB & G6 & R6 & S6
where & = AND; and ˜ = NOT
Cin = SUB & G6 & R6 & S6
where & = AND; and ˜ = NOT
TABLE III is a truth table for generation of K8 and L8 within the adder 130 given the values of Cin from the adder 132 and of the pairs of input control variables K3, L3 and K6, L6. For example, if Cin is False, and K3, L3 and K6, L6 are all True, then K8 and L8 are True and False, respectively. The control variables K8 and L8 join with G8, R8, and S8 to form a 5 bit word that is input to the left shifter 134.
The adder stage 114 receives the 25 bit mantissa m3, the 25 bit mantissa m6, and the Cin bit signal and adds these together to produce a 25 bit mantissa m7. The carry out bit of the adder stage 114 is discarded and is not used to obtain the final result of the FADD 100.
Processing continues to the normalizer stage 116, which receives the 25 bit mantissa m7 the control variable G8 from the adder 132. The count up to e3 leading zeros stage 120 examines each bit of the mantissa m7 beginning with the most significant bit m7[24] and counts logic zeros until the stage 120 counts e3 logic zeros, until the stage 120 encounters a logic one, or until the 25 bits of the mantissa m7 are exhausted, whichever comes first. The stage 120 outputs a control variable LSHIFT that is equal to the number of counted leading logic zeros in the mantissa m7. The left shifter 118 receives and shifts the bits of the 25 bit mantissa m7 to the left to produce a 25 bit mantissa m11 according to the value of the control variable, LSHIFT. Accordingly, if LSHIFT is equal to zero, the mantissa m7 is not shifted and the mantissa m11 equals the mantissa m7. If LSHIFT is equal to one, then the control variable G8 is shifted in to become the least significant bit of the mantissa m11. If LSHIFT is greater than one, the control variable G8 is shifted in, followed by LSHIFT-1 logic zeros, to form the latter part of the mantissa m10.
Returning to the left shifter 134, the shifter 134 receives the 5 bit word consisting of the control variables K8, L8, G8, R8, and S8 and shifts the bits of the 5 bit word to the left to produce a 5 bit word that consists of the control variables K10, L10, G10, R10, and S10, according to the value of the control variable, LSHIFT. TABLE IV is a truth table for generation of K10, L10, G10, R10, and S10 within the left shifter 134 given the values of the control variable LSHIFT and the input control variables K8, L8, G8, R8,and S8. For example, if LSHIFT is equal to three, then K10 is equal to R8, L10 is equal to S8, and G10, R10, and S10 are all False. The 5 bit word of K10 L10 G10 R10 S10 serves as the input to the round control logic 126.
Next, the round control logic 126 receives the control variables K10, L10, G10, R10, and S10. TABLE V is a truth table for generation of the control signal increment (INC) within the round control logic 126 given the values of the input control variables K10, L10, G10, R10, and S10. For example, if K10 and S10 are False and L10, G10, and R10 are True, then INC is True. The signal INC serves as a carry input to the rounding stage 128.
Processing of the mantissa m11 continues downward with the removal of the least significant bit m11[0] from the mantissa m11 to produce a 24 bit mantissa m12. The rounding stage 128 adds the signal INC to the mantissa m12 to produce a 24 bit mantissa m13. The rounding stage 128 is in effect an additional adder stage that follows the normalizer stage 116.
Next, the most significant bit of the 24 bit mantissa m13 is removed to produce the 23 bit mantissa m of the floating point number fresult output of the FADD 100. The most significant bit serves as an input to the increment adder stage 124.
The subtract stage 122 subtracts the 8 bit control variable LSHIFT from the 8 bit exponent field value e3 from the unpack stage 104 and produces an 8 bit output that is in turn sent to the increment adder stage 124. The increment adder stage 124 adds the 8 bit output of the subtract stage 122 to the one bit most significant bit described above to produce the 8 bit exponent field e of the floating point number fresult. The sign bit s1 of the floating point number f1 becomes the sign bit s of the floating point number fresult. All parts s, e, and m of the floating point number fresult are thus known and processing of the FADD 100 terminates.
Processing of the exemplary FADD 200 shown in
The floating point numbers f1 and f0 are processed by the unpack stages 104, 106, respectively, as described above, so that on the left-hand side of
Processing of the remaining mantissa m3 continues downward with the introduction of three control variables, J3, K3, and L3 to the round control logic 226. J3, L3, and K3 respectively represent the most significant bit m3[24], the least significant bit m3[0], and the second least significant bit m3[1] of the mantissa m3 that serves as an input to the adder stage 214.
A control variable for the FADD 200, ADD, is calculated by applying the Boolean equivalence function to the sign bits s1 and s0, so that when s1 and s0 are both false or are both true, the floating point numbers f0 and f1 have the same sign, an addition operation is being performed, and ADD is true, that is, is equal to a logic one. Similarly, when s1 and s0 are different valued, a subtraction operation is being performed, and ADD is false, that is, is equal to a logic zero. The inverter 210 is provided to complement the ADD control variable to produce the SUB control variable which is input to the complement stage 212 and the round control logic 226.
Processing continues and the right shifter 208 receives and shifts the bits of the 25 bit mantissa m2 to the right according to the value of the following control variable, RSHIFT, where
RSHIFT=e3−e2.
Accordingly, if RSHIFT is equal to zero, the mantissa m2 is not shifted. The right shifter 208 produces a 25 bit mantissa m4 as well as a series of control variables J4, K4, L4, G4, R4, and S4. TABLE I is a truth table for generation of J4, K4, L4, G4, R4, and S4 within the right shifter 208 given the value of the control variable RSHIFT. For example, if RSHIFT is equal to 23, then K4 is equal to the most significant bit m2[24] of the mantissa m2, that is, K4 is False. The control variables J4, L4, and K4 respectively represent the most significant bit m4[24], the least significant bit m4[0], and the second least significant bit m4[1] of the mantissa m4.
At the complement stage 212, if SUB is False, then ADD is True and an addition is being performed and none of the inputs to the complement stage 212 are complemented. If, however, SUB is True, each binary digit of the mantissa m4 as well as each of the control variables J4, K4, L4, G4, R4, and S4 are complemented by the complement stage 212. The operation of the complement stage 212 is summarized as follows:
TABLE VI is a truth table for generation of internal control variables L and K within the round control logic 226 given the values of the input control variables K3, K6, L3, and L6. For example, if K3, K6, L3, and L6 are all true, then L and K are False and True, respectively.
TABLE VII is a truth table for generation of the control variables GEN, PROP and G8 within the round control logic 226 given the values of the internal control variables K and L shown in TABLE VI and of the input control variables SUB, J3, J6, G6, R6, and S6. For example, if J3, J6, SUB, K, L, G6, R6, and S6 are all True, then GEN and PROP are both True and G8 is False. The control variables GEN and PROP are input to the carry logic 228. G8 serves as an input to the left shifter 218 of the normalizer stage 216. TABLE VII also explains the generation of the signal Cin within the carry logic 228 given the values of the control variables GEN and PROP from the round control logic 226. Similarly, TABLE VIII is a truth table for generation of the signal Cin within the carry logic 228 given the values of the control variables GEN and PROP and the signal C23 from the adder stage 214. C23 is the second most significant carry bit of the adder stage 214, with C24 or Cout representing the most significant carry bit of the adder stage 214. For example, if GEN is False and PROP is True, then Cin follows the value of C23. If GEN and PROP are both False, then Cin is False. Finally, if GEN is True, then Cin is True.
Cin = GEN | (PROP & C23)
where & = AND; | = OR
The adder stage 214 receives the 25 bit mantissa m3, the 25 bit mantissa m6, and the Cin bit signal and adds these together to produce a 25 bit mantissa m7. The second most significant carry bit C23 of the adder stage 214 is fed back to the carry logic 228 as described above. Thus, the input carry bit Cin to the adder stage 214 is a function of the carry bit C23 of the adder stage 214.
Processing continues to the normalizer stage 216, which receives the 25 bit mantissa m7 and the control variable G8 from the round control logic 226. The count up to e3 leading zeros stage 220 examines each bit of the mantissa m7 beginning with the most significant bit m7[24] and counts logic zeros until the stage 220 counts e3 logic zeros, until the stage 220 encounters a logic one, or until the 25 bits of.the mantissa m7 are exhausted, whichever comes first. The stage 220 outputs a control variable LSHIFT that is equal to the number of counted leading logic zeros in the mantissa m7. The left shifter 218 receives and shifts the bits of the 25 bit mantissa m7 to the left to produce a 25 bit mantissa m10 according to the value of the control variable, LSHIFT. Accordingly, if LSHIFT is equal to zero, the mantissa m7 is not shifted and the mantissa m10 equals the mantissa m7. If LSHIFT is equal to one, then the control variable G8 is shifted in to become the least significant bit of the mantissa m10. If LSHIFT is greater than one, the control variable G8 is shifted in, followed by LSHIFT-1 logic zeros, to form the latter part of the mantissa m10.
Processing of the mantissa m10 continues downward with the removal of the least significant bit m10[0] from the mantissa m10. Next, the most significant bit of the resulting 24 bit mantissa is removed to produce the 23 bit mantissa m of the floating point number fresult output of the FADD 200. The most significant bit serves as an input to the increment adder stage 224.
The subtract stage 222 subtracts the 8 bit control variable LSHIFT from the 8 bit exponent field value e3 from the unpack stage 104 and produces an 8 bit output that is in turn sent to the increment adder stage 224. The increment adder stage 224 adds the 8 bit output of the subtract stage 222 to the one bit most significant bit described above to produce the 8 bit exponent field e of the floating point number fresult, The sign bit s1 of the floating point number f1 becomes the sign bit s of the floating point number fresult. All parts s, e, and m of the floating point number fresult are thus known and processing of the FADD 200 terminates.
Processing of the exemplary FADD 300 shown in
On the left-hand side of
On the right-hand side of
A control variable for the FADD 300, ADD, is calculated by applying the Boolean equivalence function to the sign bits s1 and s0, so that when s1 and s0 are both false or are both true, the floating point numbers f0 and f1 have the same sign, an addition operation is being performed, and ADD is true, that is, is equal to a logic one. Similarly, when s1 and s0 are different valued, a subtraction operation is being performed, and ADD is false, that is, is equal to a logic zero. The inverter 310 is provided to complement the ADD control variable to produce the SUB control variable which is input to the complement stage 312 and the round control logic 326.
On the left-hand side of
m3={m3[24], m3[23], . . . , m3[1], m3[0]}={0, m1[24]=1, m1[23], . . . , m1[2], m1[1]}.
If ADD=False, then m1 passes through the second right shifter 304 without any change so that m3 is equal to m1.
Processing of the mantissa m3 continues downward with the introduction of two control variables, L3 and G3 to the round control logic 326. G3 and L3 respectively represent the least significant bit m3[0], and the second least significant bit m3[1] of the mantissa m3. Next, the guard bit G3 of m3, that is, m3[0], is removed and a new guard bit G5 generated from the round control logic 326 is added as the new least significant bit to produce a mantissa m5. The most significant bit of m5, m5[24], is complemented by the inverter 306 and returned as the new most significant bit to form a mantissa m7 that serves as an input to the adder stage 314.
Returning to the right-hand side of
RSHIFT=e1−e0+ADD.
Accordingly, if RSHIFT is equal to zero mantissa m0 is not shifted. The first right shifter 308 produces a 25 bit mantissa m2 as well as a series of control variables L2, G2, R2, and S2. TABLE IX is a truth table for generation of L2, G2, R2, and S2 within the first right shifter 308 given the value of the control variable RSHIFT. For example, if RSHIFT is equal to 23, then L2 is equal to the most significant bit m0[23] of the mantissa m0, that is, L2 is True. The control variables G2 and L2 respectively represent the least significant bit m2[0], and the second least significant bit m2[1] of the mantissa m2.
At the complement stage 312, if SUB is False, then ADD is True and an addition is being performed and none of the inputs to the complement stage 312 are complemented. If, however, SUB is True, each binary digit of the mantissa m2 as well as each of the control variables L2, G2, R2, and S2 are complemented by the complement stage 312. The operation of the complement stage 312 is summarized as follows:
TABLE X is a truth table for generation of internal control variables G, L, and G5 within the round control logic 326 given the values of the input control variables L3, L4, G3, and G4 and the internal control variable X. For example, if L3, L4, G3, and G4 are all true, then G and L are False and True. As another example, if G3 or X is True, then G5 is True; otherwise G5 is False. As described above, G5 becomes the least significant bit of the 25 bit mantissa m5. The internal control variable X used to produce G5 is generated according to TABLE XI below.
TABLE XI is a truth table for generation of the control variables GEN and PROP and the internal control variable X within the round control logic 326 given the values of the internal control variables L and G shown in TABLE X and of the input control variables SUB, R4, and S4. For example, if L, G, R4, S4, and SUB are all True, then GEN and PROP are both True and X is False. The control variables GEN and PROP are input to the carry logic 328. TABLE XI also explains the generation of the signal Cin within the carry logic 328 given the values of the control variables GEN and PROP from the round control logic 326. Similarly, TABLE XII is a truth table for generation of the signal Cin within the carry logic 328 given the values of the control variables GEN and PROP and the signal Cout from the adder stage 314. Cout is the most significant carry bit of the adder stage 214. For example, if GEN is False and PROP is True, then Cin follows the value of Cout. If GEN and PROP are both False, then Cin is False. Finally, if GEN is True, then Cin is True.
Cin = GEN | (PROP & Cout)
where & = AND; | = OR
The adder stage 314 receives the 25 bit mantissa m7, the 25 bit mantissa m4, and the Cin bit signal and adds these together to produce a 25 bit mantissa m8. The most significant carry bit Cout of the adder stage 314 is fed back to the carry logic 328 as described above. Thus, the input carry bit Cin to the adder stage 314 is a function of the carry bit Cout of the adder stage 314. Next, the most significant bit of m8, m8[24], is complemented by the inverter 330 and returned as the new most significant bit to form a mantissa m9 that serves as an input to the normalizer stage 316.
Processing continues to the normalizer stage 316, which receives the 25 bit mantissa m9. The count up to e1 leading zeros stage 320 examines each bit of the mantissa m9 beginning with the most significant bit m9[24] and counts logic zeros until the stage 320 counts e1 leading zeros, until the stage 320 encounters a logic one, or until the 25 bits of the mantissa m9 are exhausted, whichever comes first. The stage 320 outputs a control variable LSHIFT that is equal to the number of counted leading logic zeros in the mantissa m9 The left shifter 318 receives and shifts the bits of the 25 bit mantissa m9 to the left to produce a 25 bit mantissa m10 according to the value of the control variable, LSHIFT. Accordingly, if LSHIFT is equal to zero, the mantissa m9 is not shifted and the mantissa m10 equals the mantissa m9. If LSHIFT is greater than zero, then LSHIFT logic zeros are shifted in to form the latter part of the mantissa m10.
Processing of the mantissa m10 continues downward with the removal of G10 from the mantissa m10. G10 represents the least significant bit m10[0] of the mantissa m10. Next, the most significant bit of the resulting 24 bit mantissa is removed to produce the 23 bit mantissa m of the floating point number fresult output of the FADD 300.
The subtract stage 322 subtracts the 8 bit control variable LSHIFT from the 8 bit exponent field value e1 and produces an 8 bit output that is in turn sent to the increment adder stage 324. The increment adder stage 324 adds the 8 bit output of the subtract stage 322 to the one bit control variable ADD to yield an 8 bit output. The count up to e1 leading zeros stage 320 also outputs a control variable NOTZERO that is True if the mantissa m9 is not equal to zero and False if m9 is equal to zero. The eight AND gates 332 each receive a respective bit of the 8 bit output of the increment adder stage 324 along with the control variable NOTZERO. If the mantissa m9 is nonzero, then NOTZERO is True and the 8 bit output of the increment adder stage 324 is passed through the eight AND gates 332 to produce the 8 bit exponent field e of the floating point number fresult. If the mantissa m9 is zero, then NOTZERO is False, the outputs of the eight AND gates 332 are zero, and the 8 bit exponent field e is zero. The sign bit s1 of the floating point number f1 becomes the sign bit s of the floating point number fresult. All parts s, e, and m of the floating point number fresult are thus known and processing of the FADD 300 terminates.
An example that demonstrates the operation of the FADDs 100, 200, 300 according to the embodiments is now described. The swapper stage 102 receives two floating point numbers, i1 and i0, and compares the numbers to determine their relative size. The number that is less than or equal to the other number is designated f0. The floating point number f0 has the following values:
The floating point number f1 has the following values:
The ADD and SUB control variables are calculated:
The floating point numbers f1 and f0, including m1=mf1 and m0=mf0, are processed by the unpack stages 104, 106, respectively, so that on the left-hand side of
and on the right-hand side of
Processing of the mantissa m3 continues downward with the introduction of two control variables, K3=m3[1]=1 and L3=m3[0]=0 to the adder 130.
Processing continues and the right shifter 108 receives and shifts the bits of the 25 bit mantissa m2 to the right according to the value of the following control variable, RSHIFT
RSHIFT=e3−e2=(1 0 0 1 0 1 0 1 0)−(1 0 0 1 0 1 1 0)=0 0 0 0 0 0 0 0.
Since RSHIFT is equal to zero, the mantissa m2 is not shifted. The right shifter 108 produces a 25 bit mantissa m4
as well as a series of control variables K4, L4, G4, R4, and S4. By inspection of TABLE I,
K4=m2[1]=m4[1]=0, L4=m2[0]=m4[0]=1, G4=R4=S4=0.
At the complement stage 112, SUB is False since ADD is True and an addition is being performed and none of the inputs to the complement stage 112 are complemented. The operation of the complement stage 112 is summarized as follows:
The adder 132 receives the control variable SUB and the input control variables G6, R6, and S6, and, according to TABLE II, generates:
G8=R8=S8=0, and Cin=0.
The adder 130 receives the values of Cin from the adder 132 and of the pairs of input control variables K3, L3 and K6, L6, and, according to TABLE III, generates:
K8=L8=1
The adder stage 114 receives the 25 bit mantissa m3, the 25 bit mantissa m6, and the Cin bit signal and adds these together to produce a 25 bit mantissa m7. The carry out bit of the adder stage 114 is discarded and is not used to obtain the final result of the FADD 100.
Processing continues to the normalizer stage 116, which receives the 25 bit mantissa m7 and the control variable G8 from the adder 132. The control variable LSHIFT is equal to the number of counted leading logic zeros in the mantissa m7 and is therefore zero. Since LSHIFT is equal to zero, the mantissa m7 is not shifted and the mantissa m11 equals the mantissa m7
The control variables K8 and L8 join with G8, R8, and S8 to form a 5 bit word that is input to the left shifter 134:
K8L8G8R8S8=1 1 0 0 0.
The shifter 134 receives the 5 bit word consisting of the control variables K8, L8, G8, R8, and S8 and shifts the bits of the 5 bit word to the left to produce a 5 bit word that consists of the control variables K10, L10, G10, R10, and S10, according to the value of the control variable, LSHIFT. Since LSHIFT=0, there is no shift and, according to TABLE IV, the 5 bit word is equal to
K10L10G10R10S10=K8L8G8R8S8=1 1 0 0 0.
Next, the round control logic 126 receives the control variables K10, L10, G10, R10, and S10, and, according to TABLE V, generates:
INC=1.
The signal INC serves as a carry input to the rounding stage 128.
Processing of the mantissa m11 continues downward with the removal of the least significant bit m11[0] from the mantissa m11 to produce a 24 bit mantissa m12
The rounding stage 128 adds the signal INC to the mantissa m12 to produce a 24 bit mantissa m13
Next, the most significant bit of the 24 bit mantissa m13 is removed to produce the 23 bit mantissa m
of the floating point number fresult output of the FADD 100. The most significant bit msb=1 serves as an input to the increment adder stage 124.
The subtract stage 122 subtracts the 8 bit control variable LSHIFT 00000000 from the 8 bit exponent field value e3 10010110 from the unpack stage 104 and produces an 8 bit output 10010110 that is in turn sent to the increment adder stage 124. The increment adder stage 124 adds the 8 bit output 10010110 of the subtract stage 122 to the one bit most significant bit msb=1 to produce the 8 bit exponent field e 10010111 of the floating point number fresult. The sign bit s1=0 of the floating point number f1 becomes the sign bit s of the floating point number fresult. All parts s, e, and m of the floating point number fresult, are thus known and processing of the FADD 100 terminates.
The floating point numbers f1 and f0, including m1=m0 and m1=mf0, are processed by the unpack stages 104, 106, respectively, so that on the left-hand side of
and on the right-hand side of
Processing of the mantissa m3 continues downward with the introduction of two control variables, J3=m3[24]=0, K3=m3[1]=1, and L3=m3[0]=0 to the round control logic 226.
Processing continues and the right shifter 208 receives and shifts the bits of the 25 bit mantissa m2 to the right according to the value of the following control variable, RSHIFT
RSHIFT=e3−e2=(1 0 0 1 0 1 1 0)−(1 0 0 1 0 1 1 0)=0 0 0 0 0 0 0 0.
Since RSHIFT is equal to zero, the mantissa m2 is not shifted. The right shifter 208 produces a 25 bit mantissa m4
as well as a series of control variables J4, K4, L4, G4, R4, and S4. By inspection of TABLE I,
At the complement stage 212, SUB is False since ADD is True and an addition is being performed and none of the inputs to the complement stage 212 are complemented. The operation of the complement stage 212 is summarized as follows:
The round control logic 226 receives the control variable SUB and the input control variables J3, K3, L3, J6, K6, L6, G6, R6, and S6, and, according to TABLES VI and VII, generates:
The control variables GEN and PROP and the signal C23 from the adder stage 214 are input to the carry logic 228, which, according to TABLES VII and VIII, generates
Cin=True=1.
In this example, Cin does not depend on the value of C23 from the adder stage 214.
The adder stage 214 receives the 25 bit mantissa m3, the 25 bit mantissa m6, and the Cin bit signal and adds these together to produce a 25 bit mantissa m7. The second most significant carry bit C23 of the adder stage 214 is fed back to the carry logic 228.
Processing continues to the normalizer stage 216, which receives the 25 bit mantissa m7 and the control variable G8 from the round control logic 226. The control variable LSHIFT is equal to the number of counted leading logic zeros in the mantissa m7 and is therefore zero. Since LSHIFT is equal to zero, the mantissa m7 is not shifted and the mantissa m10 equals the mantissa m7
Processing of the mantissa m10 continues downward with the removal of the least significant bit m10[0] from the mantissa m10. Next, the most significant bit of the resulting 24 bit mantissa is removed to produce the 23 bit mantissa m
of the floating point number fresult output of the FADD 200. The most significant bit msb=1 serves as an input to the increment adder stage 224.
The subtract stage 222 subtracts the 8 bit control variable LSHIFT 00000000 from the 8 bit exponent field value e3 106101010 from the unpack stage 104 and produces an 8 bit output 10010110 that is in turn sent to the increment adder stage 224. The increment adder stage 224 adds the 8 bit output 10010110 of the subtract stage 222 to the one bit most significant bit msb=1 to produce the 8 bit exponent field e 10010111 of the floating point number fresult. The sign bit s1=0 of the floating point number f1 becomes the sign bit s of the floating point number fresult. All parts s, e, and m of the floating point number fresult are thus known and processing of the FADD 200 terminates.
On the left-hand side of
and on the right-hand side of
On the left-hand side of
Processing of the mantissa m3 continues downward with the introduction of two control variables, L3=m3[1]=1, and G3=m3[0]=0 to the round control logic 326.
Processing continues and the first right shifter 308 receives and shifts the bits of the 25 bit mantissa m0 to the right according to the value of the following control variable, RSHIFT
RSHIFT=e3−e2+ADD=(1 0 0 1 0 1 1 0)−(1 0 0 1 0 1 1 0)+(1)=0 0 0 0 0 0 0 1.
Since RSHIFT is equal to one, each bit of the mantissa m0 is shifted to the right by one. The first right shifter 308 produces a 25 bit mantissa m2
as well as a series of control variables L2, G2, R2, and S2. By inspection of TABLE IX,
L2=m0[0]=m2[1]=0, G2=m0[0]=m2[0]=1, R2=S2=0.
At the complement stage 312, SUB is False since ADD is True and an addition is being performed and none of the inputs to the complement stage 312 are complemented. The operation of the complement stage 312 is summarized as follows:
The round control logic 326 receives the control variable SUB and the input control variables L3, G6, L4, G4, R4, and S4, and, according to TABLES X and XI, generates:
The control variables GEN and PROP and the signal Cout from the adder stage 314 are input to the carry logic 328, which, according to TABLES XI and XII, generates
Cin=Cout.
In this example, Cin follows the value of Cout from the adder stage 314.
Next, the guard bit G3 of m3, that is, m3[0]=0, is removed and a new guard bit G5=0 generated from the round control logic 326 is added as the new least significant bit to produce a mantissa m5
The most significant bit of m5, m5[24], is complemented by the inverter 306 and returned. as the new most significant bit to form a mantissa m7
that serves as an input to the adder stage 314.
The adder stage 314 receives the 25 bit mantissa m7, the 25. bit mantissa m4, and the Cin bit signal and adds these together to produce a 25 bit mantissa m8. The most significant carry bit Cout of the adder stage 314 is fed back to the carry logic 328. In order to calculate Cout from the adder stage 314, since Cin follows the value of Cout, an initial value of logic zero is assumed for Cin. If Cout is found to be equal to a logic one when the sum is performed, then Cin is adjusted to a logic one and the sum is performed again. The following illustrates the final sum, once Cin is found to be a logic one.
Next, the most significant bit of m8, m8[24], is complemented by the inverter 330 and returned as the new most significant bit to form a mantissa m9 that serves as an input to the normalizer stage 316
Processing continues to the normalizer stage 316, which receives the 25 bit mantissa m9. The control variable. LSHIFT is equal to the number of counted leading logic zeros in the mantissa m9 and is therefore zero. Since LSHIFT is equal to zero, the mantissa m9 is not shifted and the mantissa m10 equals the mantissa m9
Processing of the mantissa m10 continues downward with the removal of the least significant bit G10 from the mantissa m10. Next, the most significant bit of the resulting 24 bit mantissa is removed to produce the 23 bit mantissa m
of the floating point number fresult output of the FADD 300.
The subtract stage 322 subtracts the 8 bit control variable LSHIFT 00000000 from the 8 bit exponent field value e1 10010110 and produces an 8 bit output 10010110 that is in turn sent to the increment adder stage 324. The increment adder stage 324 adds the 8 bit output 10010110 of the subtract stage 322 to the one bit control variable ADD=1 to produce the 8 bit exponent field e 10010111 of the floating point number fresult. The sign bit s1=0 of the floating point number f1 becomes the sign bit s of the floating point number fresult. All parts s, e, and m of the floating point number fresult are thus known and processing of the FADD 300 terminates.
Another example that demonstrates the operation of the FADDs 100, 200, 300 according to the embodiments is now described. The swapper stage 102 receives two floating point numbers, i1 and i0, and compares the numbers to determine their relative size. The number that is less than or equal to the other number is designated f0. The floating point number f0 has the following values:
The floating point number f1 has the following values:
The ADD and SUB control variables are calculated:
The floating point numbers f1 and f0, including m1=mf1 and m0=mf0, are processed by the unpack stages 104, 106, respectively, so that on the left-hand side of
and on the right-hand side of
Processing of the mantissa m3 continues downward with the introduction of two control variables, K3=m3[1]=1 and L3=m3[0]=1 to the adder 130.
Processing continues and the right shifter 108 receives and shifts the bits of the 25 bit mantissa m2 to the right according to the value of the following control variable, RSHIFT
RSHIFT=e3−e2=(1 0 0 1 0 1 1 0)−(1 0 0 1 0 1 0 1)=0 0 0 0 0 0 0 1.
Since RSHIFT is equal to one, the right shifter 108 shifts the bits of the mantissa m2 to the right by one, producing a 25 bit mantissa m4
as well as a series of control variables K4, L4, G4, R4, and S4. By inspection of TABLE I, with RSHIFT equal to one,
K4=m2[2]=m4[1]=0, L4=m2[1]=m4[0]=1, G4=m2[0]=1, R4=S4=0.
At the complement stage 112, SUB is True since ADD is False and a subtraction is being performed and so the inputs to the complement stage 112 are complemented. The operation of the complement stage 112 is summarized as follows:
The adder 132 receives the control variable SUB and the input control variables G6, R6, and S6, and, according to TABLE II, generates:
G8=1, R8=S8=0, and Cin=0.
The adder 130 receives the values of Cin from the adder 132 and of the pairs of input control variables K3, L3 and K6, L6, and, according to TABLE III, generates:
K8=0, L8=1.
The adder stage 114 receives the 25 bit-mantissa m3, the 25 bit mantissa m6, and the Cin bit signal and adds these together to produce a 25 bit mantissa m7. The carry out bit of the adder stage 114 is discarded and is not used to obtain the final result of the FADD 100.
Processing continues to the normalizer stage 116, which receives the 25 bit mantissa m7 and the control variable G8 from the adder 132. The control variable LSHIFT is equal to the number of counted leading logic zeros in the mantissa m7 and is therefore one. Since LSHIFT is equal to one, the left shifter 118 shifts the bits of the mantissa m7 to the left by one and brings in the control variable G8=1, producing the mantissa m11
The control variables K8 and L8 join with G8, R8, and S8 to form a 5 bit word that is input to the left shifter 134:
K8 L8 G8 R8 S8=0 1 1 0 0.
The shifter 134 receives the 5 bit word consisting of the control variables K8, L8, G8, R8, and S8 and shifts the bits of the 5 bit word to the left to produce a 5 bit word that consists of the control variables K10, L10, G10, R10, and S10, according to the value of the control variable, LSHIFT, which in this case is equal to one. According to TABLE IV, the 5 bit word is equal to
K10 L10 G10 R10 S10=L8 G8 R8 S8 False=1 1 0 0 0.
Next, the round control logic 126 receives the control variables K10, L10, G10, R10, and S10, and, according to TABLE V, generates:
INC=1.
The signal INC serves as a carry input to the rounding stage 128.
Processing of the mantissa m11 continues downward with the removal of the least significant bit m11[0] from the mantissa m11 to produce a 24 bit mantissa m12
The rounding stage 128 adds the signal INC to the mantissa m12 to produce a 24 bit mantissa m13
Next, the most significant bit of the 24 bit mantissa m13 is removed to produce the 23 bit mantissa m
of the floating point number fresult output of the FADD 100. The most significant bit msb=1 serves as an input to the increment adder stage 124.
The subtract stage 122 subtracts the 8 bit control variable LSHIFT 00000001 from the 8 bit exponent field value e3 10010110 from the unpack stage 104 and produces an 8 bit output 10010101 that is in turn sent to the increment adder stage 124. The increment adder stage 124 adds the 8 bit output 10010101 of the subtract stage 122 to the one bit most significant bit msb=1 to produce the 8 bit exponent field e 10010110 of the floating point number fresult. The sign bit s1=0 of the floating point number f1 becomes the sign bit s of the floating point number fresult. All parts s, e, and m of the floating point number fresult are thus known and processing of the FADD 100 terminates.
The floating point numbers f1 and f0, including m1=mf1 and m0=mf0, are processed by the unpack stages 104, 106, respectively, so that on the left-hand side of
and on the right-hand side of
Processing of the mantissa m3 continues downward with the introduction of two control variables, J3=m3[24]=0, K3=m3[1]=1, and L3=m3[0]=1 to the round control logic 226.
Processing continues and the right shifter 208 receives and shifts the bits of the 25 bit mantissa m2 to the right according to the value of the following control variable, RSHIFT
RSHIFT=e3−e2=(1 0 0 1 0 1 1 0)−(1 0 0 1 0 1 0 1)=0 0 0 0 0 0 0 1.
Since RSHIFT is equal to one, the right shifter 208 shifts the bits of the mantissa m2 to the right by one, producing a 25 bit mantissa m4
as well as a series of control variables J4, K4, L4, G4, R4, and S4. By inspection of TABLE I, with RSHIFT equal to one,
At the complement stage 212, SUB is True since ADD is False and a subtraction is being performed and so the inputs to the complement stage 212 are complemented. The operation of the complement stage 212 is summarized as follows:
The round control logic 226 receives the control variable SUB and the input control variables J3, K3, L3, J6, K6, L6, G6, R6, and S6, and, according to TABLES VI and VII, generates:
The control variables GEN and PROP and the signal C23 from the adder stage 214 are input to the carry logic 228, which, according to TABLES VII and VIII, generates
Cin=C23.
In this example, Cin follows the value of C23 from the adder stage 214.
The adder stage 214 receives the 25 bit mantissa m3, the 25 bit mantissa m6, and the Cin bit signal and adds these together to produce a 25 bit mantissa m7. The second most significant carry bit C23 of the adder stage 214 is fed back to the carry logic 228. In order to calculate C23 from the adder stage 214, since Cin follows the value of C23, an initial value of logic zero is assumed for Cin. If C23 is found to be equal to a logic one when the sum is performed, then Cin is adjusted to a logic one and the sum is performed again. The following illustrates the final sum, once Cin is found to be a logic one.
Processing continues to the normalizer stage 216, which receives the 25 bit mantissa m7 and the control variable G8 from the round control logic 226. The control variable LSHIFT is equal to the number of counted leading logic zeros in the mantissa m7 and is therefore one. Since LSHIFT is equal to one, the left shifter 218 shifts the bits of the mantissa m7 to the left by one and brings in the control variable G8=1, producing the mantissa m10
Processing of the mantissa m10 continues downward with the removal of the least significant bit m10[0] from the mantissa m10. Next, the most significant bit of the resulting 24 bit mantissa is removed to produce the 23 bit mantissa m
of the floating point number fresult output of the FADD 200. The most significant bit msb=1 serves as an input to the increment adder stage 224.
The subtract stage 222 subtracts the 8 bit control variable LSHIFT 00000001 from the 8 bit exponent field value e3 10010110 from the unpack stage 104 and produces an 8 bit output 10010101 that is in turn sent to the increment adder stage 224. The increment adder stage 224 adds the 8 bit output 10010101 of the subtract stage 222 to the one bit most significant bit msb=1 to produce the 8 bit exponent field e 10010110 of the floating point number fresult. The sign bit s1=0 of the floating point number f1 becomes the sign bit s of the floating point number fresult. All parts s, e, and m of the floating point number fresult are thus known and processing of the FADD 200 terminates.
On the left-hand side of
and on the right-hand side of
On the left-hand side of
that is equal to the mantissa m1.
Processing of the mantissa m3 continues downward with the introduction of two control variables, L3=m3[1]=1, and G3=m3[0]=0 to the round control logic 326.
Processing continues and the first right shifter 308 receives and shifts the bits of the 25 bit mantissa m0 to the right according to the value of the following control variable, RSHIFT
RSHIFT=e3−e2+ADD=(1 0 0 1 0 1 1 0)−(1 0 0 1 0 1 0 1)+(0)=0 0 0 0 0 0 0 1.
Since RSHIFT is equal to one, each bit of the mantissa m0 is shifted to the right by one. The first right shifter 308 produces a 25 bit mantissa m2
as well as a series of control variables L2, G2, R2, and S2. By inspection of TABLE IX,
L2=m0[1]=m2[1]=1, G2=m0[0]=m2[0]=1, R2=S2=0.
At the complement stage 312, SUB is True since ADD is False and a subtraction is being performed and so the inputs to the complement stage 312 are complemented. The operation of the complement stage 312 is summarized as follows:
The round control logic 326 receives the control variable SUB and the input control variables L3, G3, L4, G4, P4, and S4, and, according to TABLES X and XI, generates:
The control variables GEN and PROP and the signal Cout from the adder stage 314 are input to the carry logic 328, which, according to TABLES XI and XII, generates
Cin=Cout.
In this example, Cin follows the value of Cout from the adder stage 314.
Next, the guard bit G3 of m3, that is, m3[0]=0, is removed and a new guard bit G5=1 generated from the round control logic 326 is added as the new least significant bit to produce a mantissa m5
The most significant bit of m5, m5[24], is complemented by the inverter 306 and returned as the new most significant bit to form a mantissa m7
that serves as an input to the adder stage 314.
The adder stage 314 receives the 25 bit mantissa m7, the 25 bit mantissa m4, and the Cin bit signal and adds these together to produce a 25 bit mantissa m8. The most significant carry bit Cout of the adder stage 314 is fed back to the carry logic 328. In order to calculate Cout from the adder stage 314, since Cin follows the value of Cout, an initial value of logic zero is assumed for Cin. If Cout is found to be equal to a logic one when the sum is performed, then Cin is adjusted to a logic one and the sum is performed again. The following illustrates the final sum, once Cin is found to be a logic one.
Next, the most significant bit of m8, m8[24], is complemented by the inverter 330 and returned as the new most significant bit to form a mantissa m9 that serves as an input to the normalizer stage 316
Processing continues to the normalizer stage 316, which receives the 25 bit mantissa m9. The control variable LSHIFT is equal to the number of counted leading logic zeros in the mantissa m9 and is therefore zero. Since LSHIFT is equal to zero, the mantissa m9 is not shifted and the mantissa m10 equals the mantissa m9
Processing of the mantissa m10 continues downward with the removal of the least significant bit G10 from the mantissa m10. Next, the most significant bit of the resulting 24 bit mantissa is removed to produce the 23 bit mantissa m
of the floating point number fresult output of the FADD 300.
The subtract stage 322 subtracts the 8 bit control variable LSHIFT 00000000 from the 8 bit exponent field value el 10010110 and produces an 8 bit output 10010110 that is in turn sent to the increment adder stage 324. The increment adder stage 324 adds the 8 bit output 10010110 of the subtract stage 322 to the one bit control variable ADD=0 to produce the 8 bit exponent field e 10010110 of the floating point number fresult. The sign bit s1=0 of the floating point number f1 becomes the sign bit s of the floating point number fresult. All parts s, e, and m of the floating point number fresult are thus known and processing of the FADD 300 terminates.
Of course, it should be understood that the floating point adder 100, 200, 300 system configurations, control logic implementations, and connections shown in
The 32 bits of a single precision floating point number include one bit for a sign bit, eight bits for an exponent field, and 23 bits for the mantissa. For norm numbers, a bit value of one is understood to precede the 23 bits of the mantissa, becoming in effect, an implicit one most significant bit. A norm number has an exponent field that takes on a value between zero and 255. A denorm number, by contrast, has an implicit zero most significant bit of the mantissa, a mantissa that is not equal to zero, and an exponent field that is equivalent to zero.
One notable difference between the FADDs 100, 200, 300 is that the FADD 300 is not designed to handle denorm numbers, while the FADDs 100, 200 are equipped to handle denorm numbers. Of course, depending on the demands of a particular application, the capability of handling denorm numbers may or may not be necessary. It should be understood that, where necessary or as desired, all embodiments may be easily modified to handle denorm numbers as in
Of course, it should be understood that although inverters and complement stages are illustrated at various points in the FADDs 100, 200, 300, a given signal value and the complement of the given signal value are available at all places as suitable, even though inverters and complement stages are illustrated for clarity. For example, the functions performed by the complement stage 312 of
The present invention can be implemented in digital electronic circuitry, or in computer hardware, firmware, software, or in combinations of them. Apparatus of the invention can be implemented in a computer program product tangibly embodied in a machine-readable storage device for execution by a programmable processor; and method acts of the invention can be performed by a programmable processor executing a program of instructions to perform functions of the invention by operating on input data and generating output. The invention can be implemented advantageously in one or more computer programs that executable on a programmable system including at least one programmable processor coupled to receive data and instructions from, and to transmit data and instructions to, a data storage system, at least one input device, and at least one output device. Each computer program can be implemented in a high-level procedural or object-oriented programming language, or in assembly or machine language if desired; and in any case, the language can be a compiled or interpreted language. Suitable processors include, by way of example, both general and special purpose microprocessors. Generally, a processor will receive instructions and data from a read-only memory and/or a random access memory. Generally, a computer will include one or more mass storage devices for storing data files; such devices include magnetic disks, such as internal hard disks and removable disks; magneto-optical disks; and optical disks. Storage devices suitable for tangibly embodying computer program instructions and data include all forms of non-volatile memory, including by way of example semiconductor memory devices, such as EPROM, EEPROM, and flash memory devices; magnetic disks such as internal hard disks and removable disks; magneto-optical disks; and CD-ROM disks. Any of the foregoing can be supplemented by, or incorporated in, ASICs (application-specific integrated circuits).
Although the present invention has been particularly described with reference to the preferred embodiments, it should be readily apparent to those of ordinary skill in the art that changes and modifications in the form and details may be made without departing from the spirit and scope of the invention. It is intended that the appended claims include such changes and modifications.
Number | Date | Country | |
---|---|---|---|
Parent | 09919713 | Jul 2001 | US |
Child | 11140410 | May 2005 | US |