JPH07121353A - Floating point adder / subtractor - Google Patents
Floating point adder / subtractorInfo
- Publication number
- JPH07121353A JPH07121353A JP5262813A JP26281393A JPH07121353A JP H07121353 A JPH07121353 A JP H07121353A JP 5262813 A JP5262813 A JP 5262813A JP 26281393 A JP26281393 A JP 26281393A JP H07121353 A JPH07121353 A JP H07121353A
- Authority
- JP
- Japan
- Prior art keywords
- mantissa
- bit
- subtraction
- true
- addition
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Abstract
(57)【要約】
【目的】より小さい規模の回路構成で高速に浮動小数点
数の加減算を実行する浮動小数点数か減算装置を提供す
ることを目的とする。
【構成】浮動小数点加減算装置は、主に仮数加算器11
2と1の補数器114と仮数増分器117により構成さ
れる。浮動小数点加減算における仮数部の丸めと絶対値
化が次の2つの場合に排他的に発生することに着目す
る。真の加算または指数差が0でない真の減算の場合、
仮数加算器112で仮数加減算を実行し次いで仮数増分
器117により正確に丸める。指数差が0の真の減算の
場合、仮数加算器112は仮数差を計算し、仮数差が負
であった場合1の補数器114と仮数増分器117を組
み合わせて構成される2の補数器により仮数の絶対値を
求める。
【効果】仮数加算器が一つで済むためため、回路規模が
従来より大幅に削減される。
(57) [Summary] [Objective] An object of the present invention is to provide a floating-point number or subtraction device that executes addition and subtraction of floating-point numbers at high speed with a circuit configuration of a smaller scale. [Structure] A floating point adder / subtractor is mainly composed of a mantissa adder 11
It is composed of a 2's and 1's complementer 114 and a mantissa incrementer 117. Note that rounding and absolute value conversion of the mantissa part in floating point addition / subtraction occur exclusively in the following two cases. For true addition or true subtraction where the exponent difference is non-zero,
Mantissa adder 112 performs mantissa addition / subtraction and then mantissa incrementer 117 rounds exactly. In the case of true subtraction where the exponent difference is 0, the mantissa adder 112 calculates the mantissa difference, and when the mantissa difference is negative, the 2's complement unit configured by combining the 1's complementer 114 and the mantissa incrementer 117. To obtain the absolute value of the mantissa. [Effect] Since only one mantissa adder is required, the circuit scale is significantly reduced as compared with the conventional one.
Description
【0001】[0001]
【産業上の利用分野】本発明は、情報処理装置において
浮動小数点数同士の和又は差を計算する浮動小数点加減
算装置に関する。BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a floating point addition / subtraction apparatus for calculating the sum or difference of floating point numbers in an information processing apparatus.
【0002】[0002]
【従来の技術】近年、ディジタル信号処理や数値計算な
ど多くの情報処理分野において高速な浮動小数点演算が
求められている。浮動小数点加減算は整数加減算に比べ
処理量が膨大であるため、浮動小数点加減算の高速化は
大幅な面積と素子数の増加を招く。最新の浮動小数点演
算ユニットを内蔵するマイクロプロセッサでは、パイプ
ライン処理技術を採用することにより浮動小数点加減算
の1クロック実行が実現されている。2. Description of the Related Art In recent years, high-speed floating point arithmetic is required in many information processing fields such as digital signal processing and numerical calculation. Since the floating-point addition / subtraction has a larger processing amount than the integer addition / subtraction, the speedup of the floating-point addition / subtraction causes a large increase in the area and the number of elements. In a microprocessor incorporating the latest floating point arithmetic unit, one clock execution of floating point addition / subtraction is realized by adopting a pipeline processing technique.
【0003】従来の浮動小数点加減算装置は、例えば特
開平1-302425号公報及び特開平2-289006号(米国特許第
311296号)公報に示されている。浮動小数点数演算に関
し例えばANSI/IEEE Std 754-1985(The Institute of E
lectrical and Electronics Engineers,Inc:"IEEE Stan
dard for Binary Floating-Point Arithmetic",1985、
以下IEEE754規格と呼ぶ)に則り説明するが、これは本
発明が特定の規格や仕様に依存することを意味するもの
ではない。また浮動小数点数が非正規化数や特殊数であ
る場合もしくは加減算の途中で上位桁あふれなどの浮動
小数点例外が発生する場合などは以下の説明と異なる動
作を招くが、本発明の本質から外れるためこのような特
殊な状況に関して省略する。詳細な説明中では、例えば
正規化数同士の加減算が丸めを伴ってあふれることなく
遂行され正規化数または0の和または差が得られる状況
のみを記述する。また丸めのアルゴリズムは本発明の本
質的な部分でないため、ここではIEEE754規格で規定さ
れた4つの丸めモードの内最も複雑で頻繁に使用される
最近値丸め(RNモード)に限り記述するが、他の3つの
丸め方式がこの記述からの類推により容易に実現できる
ことは明らかである。以下単に丸めと言えば、最近値丸
め(RNモード丸め)を指す。Conventional floating point addition / subtraction devices are disclosed in, for example, Japanese Patent Laid-Open Nos. 1-302425 and 2-289006 (US Pat.
311296). Regarding floating point arithmetic, for example, ANSI / IEEE Std 754-1985 (The Institute of E
electrical and Electronics Engineers, Inc: "IEEE Stan
dard for Binary Floating-Point Arithmetic ", 1985,
Hereinafter, description will be made according to the IEEE754 standard), but this does not mean that the present invention depends on a specific standard or specification. Also, if the floating point number is a denormalized number or a special number, or if a floating point exception such as a high-order overflow occurs during addition or subtraction, an operation different from the following explanation will be caused, but it is out of the essence of the present invention. Therefore, it omits about such a special situation. In the detailed description, for example, only the situation in which addition / subtraction of normalized numbers is performed with rounding without overflow and a normalized number or the sum or difference of 0 is obtained will be described. Further, since the rounding algorithm is not an essential part of the present invention, only the most complex and frequently used nearest rounding (RN mode) among the four rounding modes defined in the IEEE754 standard will be described here. It is clear that the other three rounding schemes can be easily implemented by analogy with this description. Speaking of rounding below, it refers to the most recent rounding (RN mode rounding).
【0004】以下の説明中で次の記号を定義する。加減
算される2つの浮動小数点数をAとBで、加減算結果をR
で表す。被演算数(被加数または被減数)Aの符号ビッ
トをsAで、指数部をeAで、仮数部をmAで表す。同様に演
算数(加数または減数)Bの符号ビット,指数部,仮数
部をそれぞれsB,eB,mBで、和または差Rの符号ビッ
ト,指数部,仮数部をそれぞれsR,eR,mRで表す。論理
変数に対する上線は論理否定を意味する。記号‘*’は
don'tcare、即ち0でも1でもよい論理であることを表
す。記号X,x,y,z,wなどは論理値0及び1のいずれ
かを表す論理変数である。The following symbols are defined in the following description. The two floating point numbers to be added and subtracted are A and B, and the addition and subtraction result is R
It is represented by. The sign bit of the operand (augend or minuend) A is represented by s A , the exponent part is represented by e A , and the mantissa part is represented by m A. Similarly, the sign bit, exponent part, and mantissa part of the operation number (addend or subtraction) B are respectively s B , e B , and m B , and the sign bit, exponent part, and mantissa part of the sum or difference R are respectively s R , Expressed as e R and m R. An overline for logical variables means logical negation. The symbol '*'
Don't care, that is, it is a logic that can be either 0 or 1. The symbols X, x, y, z, w, etc. are logical variables that represent either logical values 0 or 1.
【0005】加減算の対象となる浮動小数点数の仮数部
精度(有効桁数)の範囲内における最下位ビットを記号
Lで表し、ビットLより1桁下位のビットを記号Gで表
し、ビットGより1桁下位のビットを記号Rで表し、ビッ
トRより下位である該仮数部の全ビットの論理和即ちス
ティッキービットを記号Sで表す。仮数部中の1の位の
整数ビットは仮数部の最上位ビットであり、これを記号
Mで表し、ビットMより1桁下位のビットを記号Uで表
し、ビットMより1桁上位のビットを記号Vで表す。正規
化数に対する特定のビット位置とそれらに付けられた名
前との関係を(図2)に示す。ここで仮数部精度(有効
桁数)をnで表す。IEEE754規格によれば正規化数中のM
ビットは表現上隠れているが、浮動小数点加減算装置中
の内部表現ではこの限りではない。関数maxは、その引
き数の内大きい方の数を表す。The least significant bit within the range of mantissa precision (the number of significant digits) of the floating point number to be added and subtracted is a symbol
A bit that is one digit lower than the bit L is represented by a symbol G, a bit that is one digit less than the bit G is represented by a symbol R, and a logical sum of all bits of the mantissa that are lower than the bit R, that is, a sticky bit Is represented by the symbol S. The ones integer bit in the mantissa is the most significant bit of the mantissa
Bits that are one digit lower than the bit M are represented by the symbol U, and bits that are one digit higher than the bit M are represented by the symbol V. The relationship between specific bit positions for normalized numbers and the names assigned to them is shown in FIG. Here, the mantissa precision (the number of significant digits) is represented by n. According to the IEEE754 standard, M in the normalized number
Bits are hidden in the representation, but this is not the case in the internal representation in the floating-point adder / subtractor. The function max represents the larger number of its arguments.
【0006】また以下の詳細な説明の記述中において次
の術語を定義する。浮動小数点数は符号と指数部と仮数
部で構成されている。仮数部なる術語はその隠れた最上
位ビットを含む仮数全体を指す。(表1)に示すように
真の加算と真の減算なる術語を、符号sA及びsBと加減算
の組み合わせとの関係により定義する。一般に浮動小数
点加減算装置の処理手順は真の加算の場合と真の減算の
場合とに大別でき、その仮数部処理において真の加算,
真の減算の場合それぞれ加算,減算を行なう。仮数上位
あふれは、仮数部の和が2以上になることと定義する。
桁落ちは、仮数部の差の絶対値が1未満になることと定
義する。シフトは0拡張を伴う論理シフトを意味する。
MSB,LSBはそれぞれ最上位ビット,最下位ビットを意味
する。桁合わせは指数差のビット数だけ指数の小さい方
の浮動小数点数の仮数部を右へシフトすること、桁落ち
は仮数部のMSBが0である状態、正規化は桁落ちが発生
したときに仮数部のMSBが1となるまで仮数部を左シフ
トすると共に指数値よりそのシフトしたビット数を減ず
る動作を指す。The following terms will be defined in the following detailed description. A floating point number is composed of a sign, an exponent part, and a mantissa part. The term mantissa refers to the entire mantissa, including its hidden most significant bits. As shown in (Table 1), the terms of true addition and true subtraction are defined by the relationship between the codes s A and s B and the combination of addition and subtraction. Generally, the processing procedure of the floating-point adder / subtractor can be roughly divided into the case of true addition and the case of true subtraction.
In the case of true subtraction, addition and subtraction are performed respectively. Overflow of mantissa is defined as the sum of mantissas being 2 or more.
Digit cancellation is defined as the absolute value of the difference of the mantissa is less than 1. Shift means a logical shift with zero extension.
MSB and LSB mean the most significant bit and the least significant bit, respectively. For digit alignment, shift the mantissa part of the floating-point number with the smaller exponent to the right by the number of bits in the exponent difference, and digit loss is when the MSB of the mantissa is 0. Normalization is when digit loss occurs. This refers to the operation of left-shifting the mantissa until the MSB of the mantissa becomes 1, and subtracting the shifted number of bits from the exponent value.
【0007】[0007]
【表1】 [Table 1]
【0008】以下従来技術の浮動小数点加減算装置につ
いて図面を参照しながら説明する。 (第1従来例)図3は、第1の従来例におけるの浮動小
数点加減算装置の構成図を示す。同図において、301
は符号生成器で、2つの浮動小数点数の符号,演算の種
別,2つの指数の大小関係,2つの仮数の大小関係から
真の演算結果の符号を生成する。302は指数減算器
で、2つの指数の大小を比較すると共に指数差を求め
る。303は第1の指数選択器で、2つの指数の内大き
い方を選択する。304は右シフトエンコーダーで、指
数差の絶対値を求め演算前正規化における右シフト量を
計算する。305は仮数比較器で、2つの仮数の大小関
係を判断する。306は第1の小仮数選択器で、小さい
方の浮動小数点数の仮数部を選択する。307はニブル
レベルSビット生成器で、ニブル単位でSビットを求め
る。308,309,310はそれぞれ指数差1スキャ
ナ,指数差0スキャナ,指数差−1スキャナで、それぞれ
指数差が1,0,−1であることを検出する。311は指
数差選択器で、指数差が1,0,−1,ないしそれ以外の
いずれであるかを選択する。312は指数補正器で、大
きい方の指数よりあらかじめ予測した演算後正規化ビッ
ト数を減ずる。313は左シフトエンコーダーで、指数
差の絶対値を求め演算前正規化における右シフト量を計
算する。314,315は仮数左右シフタで、それぞれ
両仮数mA,mBの桁合わせあるいは演算前正規化のために
仮数を左または右へシフトする。316は大仮数選択器
で、大きい方の浮動小数点数の仮数部を選択する。31
7は第2の小仮数選択器で、小さい方の浮動小数点数の
仮数部を選択する。318はSビット生成器で、桁合わ
せ時にSビットを生成する。319は丸め論理で、仮に
丸められた加減算結果の最下位1ビットを補正して正確
な丸めを実現する。320は指数減分器で、演算後正規
化に関する指数予測値から1を減ずる。321は指数増
分器で、演算後正規化に関する指数予測値に1を加え
る。322は第2の指数選択器で、演算後正規化に関す
る指数値予測の±1だけの食い違いを補正する。32
3,324は仮数加減算器で、実質的に仮数部を加減算
し丸める。325は加減算結果選択器で、2つの加減算
結果の内正しいビット位置に丸め用の1が加えられた方
を選択する。A conventional floating point addition / subtraction device will be described below with reference to the drawings. (First Conventional Example) FIG. 3 is a block diagram of a floating point addition / subtraction device according to the first conventional example. In the figure, 301
Is a code generator, which generates a code of a true operation result from the code of two floating point numbers, the type of operation, the magnitude relationship of two exponents, and the magnitude relationship of two mantissas. An exponent subtractor 302 compares the magnitudes of two exponents and obtains an exponent difference. A first exponent selector 303 selects the larger of the two exponents. A right shift encoder 304 obtains the absolute value of the exponent difference and calculates the right shift amount in the pre-computation normalization. A mantissa comparator 305 determines the magnitude relationship between two mantissas. A first small mantissa selector 306 selects the mantissa part of the smaller floating-point number. A nibble level S-bit generator 307 calculates S bits in nibble units. Reference numerals 308, 309, and 310 denote an index difference 1 scanner, an index difference 0 scanner, and an index difference −1 scanner, which detect that the index difference is 1, 0, −1, respectively. Reference numeral 311 is an exponent difference selector for selecting whether the exponent difference is 1, 0, -1, or other. An exponential corrector 312 reduces the post-computation normalized bit number predicted in advance from the larger exponent. A left shift encoder 313 calculates the right shift amount in the pre-computation normalization by obtaining the absolute value of the index difference. Reference numerals 314 and 315 denote mantissa left and right shifters, which shift the mantissa left or right for digit alignment of both mantissas m A and m B or normalization before operation. A large mantissa selector 316 selects the mantissa part of the larger floating point number. 31
A second small mantissa selector 7 selects the mantissa part of the smaller floating point number. An S-bit generator 318 generates S-bits at the time of digit alignment. A rounding logic 319 corrects the least significant 1 bit of the provisionally rounded addition / subtraction result to realize accurate rounding. Reference numeral 320 denotes an exponent decrementer, which subtracts 1 from the exponent predicted value for post-computation normalization. Reference numeral 321 denotes an exponent incrementer, which adds 1 to the exponent predicted value for post-operation normalization. A second exponent selector 322 corrects the discrepancy of ± 1 in the exponent value prediction related to the post-computation normalization. 32
Reference numeral 3324 denotes a mantissa adder / subtractor which substantially adds and subtracts the mantissa part and rounds it. An addition / subtraction result selector 325 selects one of the two addition / subtraction results to which a rounding 1 is added to the correct bit position.
【0009】以上のように構成された第1の従来例の浮
動小数点加減算装置について、その動作を説明する。本
従来例は3段のパイプライン処理により浮動小数点数同
士を加減算する。本従来例は入力(sA,eA,mA)で表される
浮動小数点数Aと入力(sB,eB,mB)で表される浮動小数点
数Bを受け取り、これらの加算または減算を行なった後
出力(sR,eR,mR)で表される結果の和(A+B)または差
(A−B)を出力する。AとBは正規化数であり、mAとmBの
隠れたMSBの1はあらかじめ付加されているものとする。
前記3段のパイプライン処理の概要を次に述べる。 <第1段> ・指数部によりAとBの大小を比較する。The operation of the first conventional floating-point addition / subtraction device configured as described above will be described. In this conventional example, floating-point numbers are added and subtracted by three-stage pipeline processing. This conventional example receives a floating point number A represented by an input (s A , e A , m A ) and a floating point number B represented by an input (s B , e B , m B ), and adds or After the subtraction is performed, the sum (A + B) or difference (A−B) of the results represented by the outputs (s R , e R , m R ) is output. A and B are normalized numbers, and 1 of the hidden MSBs of m A and m B has been added in advance.
The outline of the three-stage pipeline processing will be described below. <1st stage> ・ Compare the magnitude of A and B by the exponent part.
【0010】・指数差が0であれば仮数部によりAとBの
大小を比較する。 ・指数差が1,0,−1であり且つ真の減算の場合桁落ち
するビット数を予測する。 ・2つの浮動小数点数の符号,大小関係,演算の種別よ
り結果の符号を決定する。 <第2段> ・桁落ち予測に基づき仮数を演算前に正規化、ないし桁
合わせする。If the exponent difference is 0, the mantissa part is used to compare the magnitudes of A and B. • Predict the number of bits with precision loss when the exponent difference is 1, 0, −1 and true subtraction.・ Determine the sign of the result based on the sign of the two floating point numbers, the magnitude relationship, and the type of operation. <2nd stage> ・ Based on the precision cancellation, the mantissa is normalized or aligned before calculation.
【0011】・指数差が1,0,−1であり且つ真の減算
の場合桁落ち予測に基づき指数値を調整する。 <第3段> ・実質的な仮数部の加減算と丸めを行なう。 ・1ビットだけ演算後正規化を行ない、指数部・仮数部
を補正する。When the index difference is 1, 0, −1 and true subtraction, the index value is adjusted based on the precision loss prediction. <Third stage> -Substantially add and subtract mantissa and round. -Corrects only one bit and then normalizes it to correct the exponent and mantissa.
【0012】本従来例により浮動小数点数AとBを加減算
する場合、その具体的な動作を以下に簡単に説明する。
仮数上位あふれの発生は、第1の仮数加減算器323で
求めた和のVビットが1になることで判定できる。左シフ
トエンコーダー313における桁落ちビット数予測は最
大1ビットの予測誤差を生じるため、予測が失敗した場
合加減算結果選択器325と指数増減器320〜322
によりそれぞれ指数部と仮数部の1ビット補正を行な
う。 <第1段> (1.1) 指数減算器302において指数差(eA−eB)を計
算する。 (1.2) 右シフトエンコーダー304において指数差の絶
対値|eA−eB|を計算する。 (1.3) 指数比較結果に基づき、第1の指数選択器303
によりeAとeBの内大きい方を選択し、max(eA,eB)を出力
する。 (1.4) 仮数比較器305において両仮数mAとmBの大小を
比較する。 (1.5) 符号生成器301において(表2)に基づき結果
の符号sRを決定する。In the case where the floating point numbers A and B are added and subtracted according to this conventional example, the specific operation will be briefly described below.
Occurrence of overflow of the mantissa can be determined by setting the V bit of the sum calculated by the first mantissa adder / subtractor 323 to 1. Prediction of the number of precision loss bits in the left shift encoder 313 causes a prediction error of 1 bit at the maximum. Therefore, when the prediction fails, the addition / subtraction result selector 325 and the exponent adjusters 320 to 322
1-bit correction of the exponent part and the mantissa part is carried out respectively. Calculating index difference (e A -e B) in the <First stage> (1.1) Index subtractor 302. (1.2) The right shift encoder 304 calculates the absolute value of the index difference | e A −e B |. (1.3) First index selector 303 based on the index comparison result
Selects the larger of e A and e B , and outputs max (e A , e B ). (1.4) The mantissa comparator 305 compares the magnitudes of both mantissas m A and m B. (1.5) The code generator 301 determines the resulting code s R based on (Table 2).
【0013】[0013]
【表2】 [Table 2]
【0014】(1.6) 指数差1スキャナ308,指数差0ス
キャナ309,指数差−1スキャナ310で、それぞれ
指数差が1,0,−1であることを検出する。 (1.7) 指数差選択器311で、指数差が1,0,−1ない
しそれら以外のいずれであるかを選択する。 (1.8) 第1の小仮数選択器306で、指数の小さい方の
仮数部を選択する。2つの指数値が等しい場合、第1の
小仮数選択器306はいずれの仮数部を選択してもよ
い。 (1.9) ニブルレベルSビット生成器307で、ニブル単
位でSビットを生成する。 <第2段> (2.1) 左シフトエンコーダー313は、両仮数mA,mBの
上位ビットをスキャンし、指数差−1,0,1に応じて仮
数部減算後に桁落ちするビット数を予測する。 (2.2) 第1の仮数左右シフタ314により、次のように
仮数mAを左または右へシフトする。指数差絶対値が1よ
り大である場合、指数eAが指数eBより小さければ仮数mA
を指数差の絶対値のビット数だけ右へシフト(桁合わ
せ)する。指数差が1,0,−1のいずれかである場合、
仮数mAを予測された桁落ちビット数だけ左へシフト(演
算前正規化)する。この出力をmA'で表す。 (2.3) 第2の仮数左右シフタ315により、次のように
仮数mBを左または右へシフトする。指数差絶対値が1よ
り大である場合、指数eBが指数eAより小さければ仮数mB
を指数差の絶対値のビット数だけ右へシフト(桁合わ
せ)する。指数差が1,0,−1のいずれかである場合、
仮数mBを予測された桁落ちビット数だけ左へシフト(演
算前正規化)する。この出力をmB'で表す。 (2.4) Sビット生成器318により、ニブルレベルのSビ
ットより実際のSビットを決定する。 (2.5) 丸め論理319で、Sビットなどの値に従い仮数
加減算器の下位ビットの調整を行なう。 (2.6) 指数補正器312で、値max(eA,eB)より桁落ちビ
ット数を減ずる。この出力をenormで表す。 (2.7) 2つの仮数部mA'とmB'の内、大仮数選択器316
により指数の大きい方の仮数部を選択しこれをmlとして
出力する。2つの指数値eAとeBが等しい場合、仮数比較
結果により2つの仮数の内大きい方をmlとして出力す
る。 (2.8) 2つの仮数部mA'とmB'の内、第2の小仮数選択器
317により指数の小さい方の仮数部を選択しこれをms
として出力する。2つの指数値eAとeBが等しい場合、仮
数比較結果により2つの仮数の内小さい方をmsとして出
力する。 <第3段> (3.1) 第1の仮数加減算器323により、真の加算の場
合mlとms'と仮数上位あふれが発生しないものとした場
合の丸め用の1を同時に加算して丸め、真の減算の場合m
lからms'を減ずると同時に1ビットの桁落ちが発生しな
いものとした場合の丸め用の1を加算して丸める。 (3.2) 第2の仮数加減算器324により、真の加算の場
合mlとms'と仮数上位あふれが発生するものとした場合
の丸め用の1を同時に加算して丸め、真の減算の場合ml
からms'を減ずると同時に1ビットの桁落ちが発生する
ものとした場合の丸め用の1を加算して丸める。 (3.3) 加減算結果選択器325において、仮数上位あふ
れあるいは1ビットの桁落ちが発生したか否かに従って
第1の仮数加減算器323で求めた加減算結果もしくは
第2の仮数加減算器324で求めた加減算結果もしくは
それらの値を1ビット左または右シフトした値の内いず
れかを選択する。 (3.4) 指数減分器320において、enormから1を減ず
る。 (3.5) 指数増分器321において、enormへ1を加える。 (3.6) 第2の指数選択器322において、仮数上位あふ
れが発生した場合あるいは1ビットの桁落ちが発生した
場合あるいはいずれも発生しない場合に対して、それぞ
れ値enorm+1あるいはenorm−1あるいはenormを選択
し、この値をeRとする。 (第2従来例)図4は、第2の従来例における浮動小数
点加減算装置の構成図を示す。同図において、401は
符号生成器で、2つの浮動小数点数の符号,演算の種
別,2つの指数の大小関係から仮の演算結果の符号を生
成する。402は指数減算器で、2つの指数の大小を比
較すると共に指数差を求める。403は第1の指数選択
器で、2つの指数の内大きい方を選択する。404は指
数差絶対値化器で、指数差の絶対値を求める。405は
大仮数選択器で、大きい方の浮動小数点数の仮数部を選
択する。406は小仮数選択器で、小さい方の浮動小数
点数の仮数部を選択する。407は仮数右シフタで、小
さい方の浮動小数点数の仮数部を桁合わせする。408
はSビット生成器で、桁合わせ時にSビットを生成する。
409は符号反転器で、2つの仮数の大小比較から真の
演算結果の符号を決定する。410は指数減分器で、演
算後正規化に関する指数予測値から1を減ずる。411
は指数増分器で、演算後正規化に関する指数予測値に1
を加える。412は第2の指数選択器で、演算後正規化
に関する指数値予測の±1だけの食い違いを補正する。
413は丸め論理で、Sビットや仮数下位ビットの値に
従い丸め用の桁上げ入力を制御する。414,415は
第1,第2の仮数加減算器で、実質的に仮数部を加減算
し丸める。416は加減算結果選択器で、2つの加減算
結果の内正しいビット位置に丸め用の1が加えられた方
を選択しあるいは真の減算の場合に仮数差の絶対値を選
択する。417は丸め補正器で、仮に丸められた加減算
結果の最下位1ビットを補正して正確な丸めを実現す
る。418は指数補正器で、指数値から演算後正規化の
補正値を減ずる。419は先行1検出器で、真の減算の
場合に仮数差の桁落ちしたビット数を検出する。420
は仮数左シフタで、桁落ちが発生したときに仮数部を正
規化する。(1.6) The index difference 1 scanner 308, the index difference 0 scanner 309, and the index difference −1 scanner 310 detect that the index difference is 1, 0, −1, respectively. (1.7) The exponent difference selector 311 selects whether the exponent difference is 1, 0, −1 or any other. (1.8) The first small mantissa selector 306 selects the mantissa part having the smaller exponent. If the two exponent values are equal, the first small mantissa selector 306 may select which mantissa part. (1.9) The nibble level S-bit generator 307 generates S bits in nibble units. <Second stage> (2.1) The left shift encoder 313 scans the high-order bits of both mantissas m A and m B , and predicts the number of digits to be lost after the mantissa part subtraction according to the exponent difference −1, 0, 1. To do. (2.2) The first mantissa left / right shifter 314 shifts the mantissa m A left or right as follows. If the absolute value of the exponent difference is greater than 1, and the exponent e A is less than the exponent e B , the mantissa m A
Is shifted to the right by the number of bits of the absolute value of the exponent difference (digit matching). If the exponential difference is 1, 0 or -1,
The mantissa m A is shifted to the left by the predicted number of precision loss bits (pre-normalization). This output is represented by m A '. (2.3) The second mantissa left / right shifter 315 shifts the mantissa m B left or right as follows. Mandatory mantissa m B if exponent e B is less than exponent e A when absolute value of exponent difference is greater than 1
Is shifted to the right by the number of bits of the absolute value of the exponent difference (digit matching). If the exponential difference is 1, 0 or -1,
The mantissa m B is shifted to the left by the predicted number of precision loss bits (pre-operation normalization). This output is represented by m B '. (2.4) The S bit generator 318 determines the actual S bit from the nibble level S bits. (2.5) The rounding logic 319 adjusts the lower bit of the mantissa adder / subtractor according to the value of the S bit or the like. (2.6) The exponent corrector 312 subtracts the number of precision loss bits from the value max (e A , e B ). This output is represented by e norm . (2.7) Large mantissa selector 316 of the two mantissa parts m A 'and m B '
Selects the mantissa with the larger exponent and outputs it as m l . When the two exponent values e A and e B are equal, the larger of the two mantissas is output as m l according to the mantissa comparison result. (2.8) Of the two mantissa parts m A 'and m B ', the second mantissa selector 317 selects the mantissa part with the smaller exponent and selects it as m s
Output as. When the two exponent values e A and e B are equal, the smaller of the two mantissas is output as m s according to the mantissa comparison result. <Third stage> (3.1) The first mantissa adder / subtractor 323 rounds by adding m l and m s ' for true addition and 1 for rounding when mantissa upper overflow does not occur. , M for true subtraction
At the same time as subtracting m s ' from l , rounding is performed by adding 1 for rounding when no loss of 1-bit digits occurs. (3.2) By the second mantissa adder / subtractor 324, in the case of true addition, m l and m s ' and 1 for rounding when mantissa upper overflow is assumed to be added at the same time for rounding and true subtraction. Case m l
When m s ' is subtracted from 1 and a 1-bit precision loss occurs, 1 is added for rounding and rounding is performed. (3.3) In the addition / subtraction result selector 325, the addition / subtraction result obtained by the first mantissa adder / subtractor 323 or the addition / subtraction obtained by the second mantissa adder / subtractor 324 is determined depending on whether the mantissa higher-order overflow or 1-bit precision loss has occurred. Select the result or one of those values shifted left or right by one bit. (3.4) In the exponent decrementer 320, subtract 1 from e norm . (3.5) In the exponent incrementer 321, add 1 to e norm . (3.6) In the second exponent selector 322, a value e norm +1 or e norm −1 or e norm −1 or e norm −1 or Select e norm and call this value e R. (Second Conventional Example) FIG. 4 is a block diagram of a floating point addition / subtraction device in the second conventional example. In the figure, reference numeral 401 denotes a code generator, which generates a temporary operation result code from the relationship between two floating-point number codes, operation types, and two exponents. Reference numeral 402 denotes an exponent subtractor, which compares the magnitude of two exponents and obtains an exponent difference. A first index selector 403 selects the larger of the two indexes. Reference numeral 404 is an exponent difference absolute value converter, which calculates the absolute value of the exponent difference. A large mantissa selector 405 selects the mantissa part of the larger floating point number. A small mantissa selector 406 selects the mantissa part of the smaller floating point number. A mantissa right shifter 407 aligns the digits of the mantissa part of the smaller floating-point number. 408
Is an S-bit generator that generates S-bits when aligning digits.
A sign inverter 409 determines the sign of the true operation result from the comparison of the magnitudes of two mantissas. An exponent decrementer 410 subtracts 1 from the exponent predicted value for post-computation normalization. 411
Is an exponent incrementer, which is 1 for the exponent prediction value for post-operation normalization
Add. Reference numeral 412 is a second exponent selector which corrects a discrepancy of ± 1 in exponent value prediction related to post-computation normalization.
A rounding logic 413 controls the carry input for rounding according to the value of the S bit or the mantissa lower bit. Reference numerals 414 and 415 denote first and second mantissa adder / subtractors, which substantially add and subtract the mantissa part and round it. Reference numeral 416 denotes an addition / subtraction result selector which selects which of the two addition / subtraction results is added with a rounding 1 at the correct bit position, or selects the absolute value of the mantissa difference in the case of true subtraction. A rounding corrector 417 corrects the least significant 1 bit of the provisionally rounded addition / subtraction result to realize accurate rounding. Reference numeral 418 is an exponent corrector, which subtracts the post-computation normalization correction value from the exponent value. Reference numeral 419 is a leading one detector, which detects the number of bits in which the mantissa difference is missed in the case of true subtraction. 420
Is a mantissa left shifter, which normalizes the mantissa part when a digit loss occurs.
【0015】上記のように構成された本従来例の動作を
以下に説明する。本従来例は3段のパイプライン処理に
より浮動小数点数同士を加減算する。本従来例は入力(s
A,eA,mA)で表される浮動小数点数Aと入力(sB,eB,mB)で
表される浮動小数点数Bを受け取り、これらの加算また
は減算を行なった後出力(sR,eR,mR)で表される結果の和
(A+B)または差(A−B)を出力する。AとBは正規化数
であり、mAとmBの隠れたMSBの1はあらかじめ付加されて
いるものとする。前記3段のパイプライン処理の概要を
次に述べる。 <第1段> ・指数部によりAとBの大小を比較し、小さい方の仮数部
を桁合わせする。The operation of the conventional example thus constructed will be described below. In this conventional example, floating-point numbers are added and subtracted by three-stage pipeline processing. In this conventional example, input (s
A floating point number A represented by A , e A , m A ) and a floating point number B represented by input (s B , e B , m B ) are received, and after addition or subtraction thereof, output ( The sum (A + B) or difference (A−B) of the results represented by s R , e R , m R ) is output. A and B are normalized numbers, and 1 of the hidden MSBs of m A and m B has been added in advance. The outline of the three-stage pipeline processing will be described below. <1st stage> -Compare the magnitudes of A and B by the exponent part and align the digit of the smaller mantissa part.
【0016】・真の減算で指数差が0の場合でなければ
結果の符号を決定する。 <第2段> ・実質的な仮数部の加減算と丸めを行なう。 ・真の減算の場合且つ指数差が0であれば仮数の大小判
定により最終的な符号を決定する。 <第3段> ・桁落ちした場合、仮数部と指数部の正規化を行なう。If the subtraction is true and the exponent difference is not 0, the sign of the result is determined. <Second stage> -Substantially adding and subtracting mantissa and rounding. In the case of true subtraction and if the exponent difference is 0, the final sign is determined by the mantissa magnitude judgment. <Third stage> ・ If a digit is lost, the mantissa part and the exponent part are normalized.
【0017】本従来例により浮動小数点数AとBを加減算
する場合、その具体的な動作を以下に簡単に説明する。
仮数上位あふれの発生は第1の仮数加減算器414で求
めた和のVビットが1になることで判定できる。 <第1段> (1.1) 指数減算器402において指数差(eA−eB)を計
算する。 (1.2) 指数差絶対値化器404において指数差の絶対値
|eA−eB|を計算する。 (1.3) 指数比較結果に基づき、第1の指数選択器403
によりeAとeBの内大きい方を選択し、max(eA,eB)を出力
する。 (1.4) 符号生成器401において(表2)に基づき仮の
符号を決定する。 (1.5) 2つの仮数部mAとmBの内、大仮数選択器405に
より指数の大きい方の仮数部を選択し、これをmlとす
る。2つの指数値eAとeBが等しい場合、大仮数選択器4
05はいずれの仮数部を選択してもよい。 (1.6) 2つの仮数部mAとmBの内、小仮数選択器406に
より指数の小さい方の仮数部を選択し、これをmsとす
る。2つの指数値eAとeBが等しい場合、小仮数選択器4
06は大仮数選択器405とは別の方を選択する。 (1.7) 仮数右シフタ407によりmsを|eA−eB|ビット
右へシフトする。これを桁合わせと呼び、桁合わせされ
たmsをms'で表す。 (1.8) Sビット生成器408により、上記桁合わせ時に
仮数部のRビットより右にこぼれた全ビットの論理和を
取りこれをSビットとする。 <第2段> (2.1) 丸め論理413で、Sビットなどの値に従い仮数
加減算器の下位ビットの調整を行なう。 (2.2) 第1の仮数加減算器414により、仮数の加減算
と丸めを同時に行なう。真の加算の場合、mlとms'と仮
数上位あふれが発生しないものとした場合の丸め用の1
を同時に加算して丸める。真の減算かつ指数差が0でな
い場合、mlからms'を減ずると同時に1ビットの桁落ち
が発生しないものとした場合の丸め用の1を加算して丸
める。真の減算かつ指数差が0である場合、mlからms'
を減ずる。 (2.3) 第2の仮数加減算器415により、仮数の加減算
と丸めを同時に行なう。真の加算の場合、mlとms'と仮
数上位あふれが発生するものとした場合の丸め用の1を
同時に加算して丸める。真の減算かつ指数差が0でない
場合、mlからms'を減ずると同時に1ビットの桁落ちが
発生するものとした場合の丸め用の1を加算して丸め
る。真の減算かつ指数差が0である場合、ms'からmlを
減ずる。 (2.4) 加減算結果選択器416において、第1の仮数加
減算器414と第2の仮数加減算器415で求めた加減
算結果の内正しい方を選択する。真の減算かつ指数差が
0である場合、結果が正となる方を選択する。真の減算
かつ指数差が0である場合以外において、仮数上位あふ
れあるいは1ビットの桁落ちが発生したか否かに従って
前記2つの加減算結果もしくはそれらの値を1ビット左
または右シフトした値の内正しいものを選択する。 (2.5) 指数減分器410において、値max(eA,eB)から1
を減ずる。 (2.6) 指数増分器411において、値max(eA,eB)へ1を
加える。 (2.7) 第2の指数選択器412において、仮数上位あふ
れが発生した場合あるいは1ビットの桁落ちが発生した
場合あるいはいずれも発生しない場合に対して、それぞ
れ値max(eA,eB)+1あるいはmax(eA,eB)−1あるいはmax
(eA,eB)を選択する。 (2.8) 丸め補正器417により、正確な丸めのために加
減算結果のLビットを補正する。 (2.9) 符号反転器409は、第2の仮数加減算器415
で求めた差が負であれば第1段において決定した符号を
反転させ、さもなければ第1段において決定した符号を
素通しさせ、これをsRとする。 <第3段> (3.1) 先行1検出器419は、丸められた和のMビット
より右へスキャンして最初にビット1が現われるビット
位置を探索し、そのビット位置とMビットとの距離を2
進数にエンコードする。真の加算ではこの距離は0であ
る。 (3.2) 仮数左シフタ420は、先行1検出器419で求
めたビット数だけ加減算結果を左へシフトすることによ
り、結果のMビットが1となるように仮数部を調整す
る。シフトした仮数部をmRとする。真の加算では既に仮
数部のMビットは1であるため、シフトしない。 (3.3) 指数補正器418において、補正された指数部よ
り前記エンコードされた左シフト数を減じた差をeRとす
る。真の加算ではエンコードされた左シフト数より0を
減ずる。(終わり) 上述のように従来技術の浮動小数点加減算装置において
は、仮数部の加減算と同時に丸め補正を行うために、第
1の仮数加減算器と第2の仮数加減算器とを備えてい
る。この2つの仮数加減算器によって、真の加算の場合
には上位桁あふれの発生の有無に対応し、真の減算で指
数差が0でない場合には桁落ちの発生の有無に対応し、
真の減算で指数差が0である場合には減算結果の正負に
対応することができるようになっている。In the case where the floating point numbers A and B are added and subtracted according to the conventional example, the specific operation will be briefly described below.
Occurrence of overflow of the mantissa can be determined by setting the V bit of the sum calculated by the first mantissa adder / subtractor 414 to 1. Calculating index difference (e A -e B) in the <First stage> (1.1) Index subtractor 402. (1.2) The absolute value of the index difference | e A −e B | is calculated in the index difference absolute value converter 404. (1.3) First index selector 403 based on the index comparison result
Selects the larger of e A and e B , and outputs max (e A , e B ). (1.4) The code generator 401 determines a temporary code based on (Table 2). (1.5) Of the two mantissa parts m A and m B , the mantissa part with the larger exponent is selected by the large mantissa selector 405, and this is designated as m l . If the two exponent values e A and e B are equal, the large mantissa selector 4
05 may select any mantissa part. (1.6) Of the two mantissa parts m A and m B , the mantissa part with the smaller exponent is selected by the small mantissa selector 406, and this is designated as m s . If the two exponent values e A and e B are equal, the fractional mantissa selector 4
06 selects a different one from the large mantissa selector 405. (1.7) The mantissa right shifter 407 shifts m s to the right | e A −e B | bit. This is called digit alignment, representing a digit alignment has been m s in m s'. (1.8) The S bit generator 408 takes the logical sum of all the bits spilled to the right of the R bits of the mantissa at the time of the above digit alignment and sets this as the S bit. <Second stage> (2.1) The rounding logic 413 adjusts the lower bit of the mantissa adder / subtractor according to the value of the S bit or the like. (2.2) The first mantissa adder / subtractor 414 simultaneously performs mantissa addition / subtraction and rounding. 1 for rounding when true addition and m l and m s ' and mantissa upper overflow do not occur
Are added at the same time and rounded. If true subtraction and the exponent difference is not 0, m s ' is subtracted from m l, and at the same time, rounding is performed by adding 1 for rounding assuming that no 1-bit precision loss occurs. If true subtraction and exponent difference is 0, m l to m s '
Reduce. (2.3) The second mantissa adder / subtractor 415 simultaneously performs addition and subtraction of the mantissa and rounding. In the case of true addition, m l and m s ' and 1 for rounding when mantissa upper overflow is assumed to occur are added together and rounded. When true subtraction and exponent difference are not 0, m s ' is subtracted from m l, and at the same time, rounding is performed by adding 1 for rounding when 1-bit precision loss occurs. If true subtraction and exponent difference is 0, then subtract m l from m s ′. (2.4) The addition / subtraction result selector 416 selects the correct one of the addition / subtraction results obtained by the first mantissa adder / subtractor 414 and the second mantissa adder / subtractor 415. If true subtraction and exponent difference is 0, choose the one with positive result. Except when true subtraction and exponent difference is 0, the result of the above two additions and subtractions or the value obtained by shifting those values by 1 bit to the left or right is determined according to whether the mantissa upper overflow or 1-bit precision loss occurs. Choose the right one. (2.5) In the exponent decrementer 410, the value max (e A , e B ) becomes 1
Reduce. (2.6) In the exponent incrementer 411, 1 is added to the value max (e A , e B ). (2.7) In the second exponent selector 412, the value max (e A , e B ) +1 for the mantissa upper overflow, the 1-bit precision loss, or neither. Or max (e A , e B ) −1 or max
Select (e A , e B ). (2.8) The rounding corrector 417 corrects the L bit of the addition / subtraction result for accurate rounding. (2.9) The sign inverter 409 uses the second mantissa adder / subtractor 415
If the difference obtained in step 1 is negative, the sign determined in the first stage is inverted, otherwise the sign determined in the first stage is passed through, and this is designated as s R. <Third stage> (3.1) The leading 1 detector 419 scans to the right from the M bits of the rounded sum to search for the bit position where bit 1 first appears, and finds the distance between the bit position and the M bit. Two
Encode to a base number. In true addition, this distance is zero. (3.2) The mantissa left shifter 420 adjusts the mantissa part so that the M bits of the result become 1 by shifting the addition / subtraction result to the left by the number of bits obtained by the preceding 1 detector 419. The shifted mantissa is m R. In true addition, the M bits of the mantissa part are already 1, so they are not shifted. (3.3) In the exponent corrector 418, the difference obtained by subtracting the encoded left shift number from the corrected exponent part is taken as e R. In true addition, 0 is subtracted from the encoded left shift number. (End) As described above, the conventional floating-point adder / subtractor is provided with the first mantissa adder / subtractor and the second mantissa adder / subtractor in order to perform rounding correction simultaneously with addition / subtraction of the mantissa part. These two mantissa adder / subtractors correspond to the presence or absence of upper digit overflow in the case of true addition, and the presence or absence of digit cancellation in the case of true subtraction where the exponent difference is not 0.
When the difference between the exponents is 0 in true subtraction, it is possible to deal with the positive or negative sign of the subtraction result.
【0018】[0018]
【発明が解決しようとする課題】しかしながら従来の浮
動小数点加減算装置によれば、一般に大きな回路規模を
要する仮数加減算器を2つ備えているので、ハードウェ
ア量が非常に大きくなるという問題あった。加えて、回
路規模が大きいために処理速度が遅くなるという問題が
あった。However, the conventional floating point adder / subtractor has two mantissa adder / subtractors which generally require a large circuit scale, and therefore has a problem that the amount of hardware becomes very large. In addition, there is a problem that the processing speed becomes slow due to the large circuit scale.
【0019】上記の課題に鑑み本発明は、従来の浮動小
数点加減算装置と同等の性能を持ちながらより少ないハ
ードウェア量で足りる新規の浮動小数点加減算装置を提
供することを目的とする。In view of the above problems, it is an object of the present invention to provide a novel floating-point addition / subtraction device which has performance equivalent to that of a conventional floating-point addition / subtraction device but requires less hardware.
【0020】[0020]
【課題を解決するための手段】上記の課題を解決するた
め本発明の浮動小数点加減算装置は、2つの浮動小数点
数のうち指数の小さい方の仮数部を選択し、指数が同じ
ならばいずれか一方の仮数部を選択する小仮数選択手段
と、2つの浮動小数点数のうち小仮数選択手段と異なる
方の仮数部を選択する大仮数選択手段と、小仮数選択手
段の出力を2つの浮動小数点数の指数差の絶対値だけ下
位側(以下右と呼ぶ)へ論理シフトする(以下桁合わせ
すると呼ぶ)桁合わせ手段と、正数へ正数を加える又は
正数から負数を減ずる又は負数へ負数を加える又は負数
から正数を減ずる場合(以下真の加算の場合と呼ぶ)、
大仮数選択手段の出力に前記桁合わせされた仮数値を加
え、正数へ負数を加える又は正数から正数を減ずる又は
負数へ正数を加える又は負数から負数を減ずる場合(以
下真の減算の場合と呼ぶ)、大仮数選択手段の出力から
前記桁合わせされた仮数値を減ずる仮数加減算手段と、
仮数加減算手段から出力される和が上位あふれを起こし
ている場合和を1ビット右シフトし、差が1ビットの桁
落ちを起こしている場合差を1ビット左シフトし、さも
なければ素通しさせる左右1ビットシフト手段と、左右
1ビットシフト手段の出力が負である場合その出力をビ
ット毎に反転し、さもなければ素通しさせる仮数ビット
反転手段と、桁合わせされた仮数値と左右1ビットシフ
ト手段の出力に基づいて丸め論理を決定する丸め補正手
段と、加数加減算結果が負の場合仮数ビット反転手段の
出力に2の補数化用の1を加え、丸め補正手段において
丸め用の1を加算すべきと決定された場合仮数ビット反
転手段の出力に1を加算し、さもなければこれを素通し
させる仮数増分手段とを備えている。In order to solve the above-mentioned problems, the floating-point addition / subtraction device of the present invention selects the mantissa part of the two floating-point numbers having the smaller exponent, and if the exponents are the same. The small mantissa selecting means for selecting one mantissa part, the large mantissa selecting means for selecting a mantissa part of the two floating point numbers different from the small mantissa selecting means, and the output of the small mantissa selecting means are two floating point numbers. Digit alignment means that logically shifts to the lower side (hereinafter referred to as right) by the absolute value of the exponential difference of numbers (hereinafter referred to as digit matching) and positive numbers are added to positive numbers, negative numbers are subtracted from positive numbers, or negative numbers are negative numbers. When adding or subtracting a positive number from a negative number (hereinafter referred to as true addition),
When adding the digit-matched mantissa value to the output of the large mantissa selecting means, adding a negative number to a positive number, subtracting a positive number from a positive number, or adding a positive number to a negative number or subtracting a negative number from a negative number (hereinafter, true subtraction And a mantissa adding / subtracting means for subtracting the digit-matched mantissa value from the output of the large mantissa selecting means,
If the sum output from the mantissa adder / subtractor causes upper overflow, the sum is shifted right by 1 bit, and if the difference causes a 1-bit precision loss, the difference is shifted left by 1 bit, and otherwise left and right are passed through. 1-bit shift means, mantissa bit inverting means for inverting the output bit by bit if the output of the left-right 1-bit shift means is negative, and passing through otherwise, digit-aligned mantissa value and left-right 1-bit shift means Rounding correction means for determining the rounding logic based on the output of the above, and if the addend / subtraction result is negative, add 1 for 2's complement to the output of the mantissa bit inverting means, and add 1 for rounding in the rounding correction means. A mantissa increment means for adding 1 to the output of the mantissa bit inverting means if it is determined to do so, and passing it through otherwise.
【0021】また、前記仮数加減算手段は、前記桁合わ
せされた仮数値を、真の加算の場合素通しさせ、真の減
算の場合ビット毎に反転させる第1の仮数ビット反転手
段と、桁合わせされた仮数値に基づき2の補数化用の桁
上げ入力を発生する桁上げ入力発生手段と、真の加算の
場合大仮数選択手段の出力と第1の仮数ビット反転手段
の出力とを加算し、真の減算の場合これらに加えて前記
桁上げ入力を加算する仮数加算手段とから構成されてい
てもよい。The mantissa adder / subtracter is digit-matched with first mantissa bit inverting means for passing the digit-matched mantissa value through in the case of true addition and inverting each bit in the case of true subtraction. Carry input generating means for generating a carry input for two's complementation based on the mantissa value, the output of the large mantissa selecting means and the output of the first mantissa bit inverting means in the case of true addition, and In the case of true subtraction, in addition to these, mantissa adding means for adding the carry input may be included.
【0022】また、前記仮数加減算手段は、大仮数選択
手段の出力を、真の加算の場合素通しさせ、真の減算の
場合ビット毎に反転させる第1の仮数ビット反転手段
と、第仮数選択手段の出力に基づき2の補数化用の桁上
げ入力を発生する桁上げ入力発生手段と、真の加算の場
合第1の仮数ビット反転手段の出力と前記桁合わせされ
た仮数値とを加算し、真の減算の場合これらに加えて前
記桁上げ入力を加算する仮数加算手段とから構成されて
いてもよい。Further, the mantissa adder / subtractor means passes through the output of the large mantissa selection means in the case of true addition, and inverts bit by bit in the case of true subtraction, and the mantissa selection means. Carry input generating means for generating a carry input for two's complementing based on the output of, and in the case of true addition, the output of the first mantissa bit inverting means and the mantissa value aligned with the digit are added, In the case of true subtraction, in addition to these, mantissa adding means for adding the carry input may be included.
【0023】[0023]
【作用】本発明の浮動小数点加減算装置は前記の構成に
より、真の加算の場合または真の減算で指数差が0でな
い場合には、小仮数選択手段と桁合わせ手段により指数
が小さい方の浮動小数点数の仮数部を桁合わせし、大仮
数選択手段により指数が大きい方の浮動小数点数の仮数
部を選択し、仮数加減算手段により仮数部の加算または
減算を行なった結果を左右1ビットシフト手段により桁
あふれ又は1ビットの桁落ちを正規化し、丸め補正手段
によ決定された丸め補正論理に従って、仮数増分手段に
より必要ならば丸めのために1を加える。The floating point adder / subtractor according to the present invention has the above-described structure, and in the case of true addition or when the exponent difference is not 0 in true subtraction, the floating point having a smaller exponent is selected by the small mantissa selecting means and the digit aligning means. The mantissa part of the decimal point number is aligned, the mantissa part of the floating point number having the larger exponent is selected by the large mantissa selecting means, and the result of addition or subtraction of the mantissa part by the mantissa adding / subtracting means is shifted to the left or right by 1 bit. To normalize the overflow or 1-bit precision loss, and add 1 for rounding if required by the mantissa incrementer according to the rounding correction logic determined by the rounding corrector.
【0024】また、真の減算の場合且つ指数差が0であ
る場合には、小仮数選択手段と大仮数選択手段によりそ
れぞれ別の浮動小数点数の仮数部を選択し、仮数加減算
手段により大仮数選択手段の出力から小仮数選択手段の
出力を減じ、仮数ビット反転手段により差が負である場
合に差の1の補数を求め、仮数増分手段により差が負で
ある場合に差の2の補数を求めるために差の1の補数へ
1を加え、正しく丸められた浮動小数点数同士の和また
は差を計算することを可能とする。When the subtraction is true and the exponent difference is 0, the small mantissa selecting means and the large mantissa selecting means select different mantissa parts of the floating point numbers, and the mantissa adder / subtracter means select the large mantissa. The output of the small mantissa selecting means is subtracted from the output of the selecting means, the one's complement of the difference is obtained by the mantissa bit inverting means, and the two's complement of the difference is obtained by the mantissa incrementing means. To the one's complement of the difference to find
Add one to allow the sum or difference of correctly rounded floating point numbers to be calculated.
【0025】[0025]
【実施例】以下本発明の一実施例について、図面を参照
しながら説明する。図1は本実施例の浮動小数点加減算
装置の構成図を示す。同図において、101は符号生成
器で、2つの浮動小数点数の符号,演算の種別,2つの
指数の大小関係から仮の演算結果の符号を生成する。DESCRIPTION OF THE PREFERRED EMBODIMENTS An embodiment of the present invention will be described below with reference to the drawings. FIG. 1 is a block diagram of the floating point addition / subtraction device of this embodiment. In the figure, reference numeral 101 denotes a code generator, which generates a temporary code of a calculation result from the relationship between the codes of two floating point numbers, the type of calculation, and the magnitude of two exponents.
【0026】102は指数減算器で、2つの指数の大小
を比較すると共に指数差を求める。103は指数選択器
で、2つの指数の内大きい方を選択する。104は指数
差絶対値化器で、指数差の絶対値を求める。105は大
仮数選択器で、大きい方の浮動小数点数の仮数部を選択
する。106は小仮数選択器で、小さい方の浮動小数点
数の仮数部を選択する。Reference numeral 102 denotes an exponent subtractor, which compares the magnitude of two exponents and obtains the exponent difference. An index selector 103 selects the larger of the two indexes. An exponent difference absolute value conversion unit 104 obtains the absolute value of the exponent difference. A large mantissa selector 105 selects the mantissa part of the larger floating point number. A small mantissa selector 106 selects the mantissa part of the smaller floating point number.
【0027】107は仮数右シフタで、小さい方の浮動
小数点数の仮数部を桁合わせする。108はSビット生
成器で、桁合わせ時にSビットを生成する。109は第
1の仮数ビット反転器で、真の減算の場合に小さい方の
浮動小数点数の仮数部の1の補数を取る。110は符号
反転器で、2つの仮数の大小比較から真の演算結果の符
号を決定する。Reference numeral 107 is a mantissa right shifter, which aligns the digits of the mantissa part of the smaller floating point number. Reference numeral 108 denotes an S bit generator, which generates S bits at the time of digit alignment. Reference numeral 109 denotes a first mantissa bit inverter, which takes the 1's complement of the mantissa part of the smaller floating-point number in the case of true subtraction. Reference numeral 110 is a sign inverter, which determines the sign of the true operation result from the magnitude comparison of two mantissas.
【0028】111は指数増減器で、指数値に1を加え
るあるいは減ずる。112は仮数加算器で、実質的に仮
数部を加減算する。113は左右1ビットシフタで、
(表3)に基づいて仮数部加減算結果を左または右へ1
ビットシフトする。114は第2の仮数ビット反転器
で、負の仮数減算結果の1の補数を取る。Reference numeral 111 is an exponent increase / decrease unit, which adds or subtracts 1 to the exponent value. Reference numeral 112 is a mantissa adder, which substantially adds and subtracts the mantissa part. 113 is a left and right 1-bit shifter,
1 to the left or right of the mantissa part addition / subtraction result based on (Table 3)
Bit shift. Reference numeral 114 denotes a second mantissa bit inverter, which takes the 1's complement of the negative mantissa subtraction result.
【0029】115は丸め補正器で、(表4)に基づい
て仮数加減算結果の丸め補正論理を決定する。116は
指数補正器で、指数値から演算後正規化の補正値を減ず
る。117は仮数増分器で、負の仮数減算結果の2の補
数を生成するか、正の仮数減算結果を丸めるために1を
加える。A rounding correction unit 115 determines the rounding correction logic of the mantissa addition / subtraction result based on (Table 4). An exponent corrector 116 subtracts the post-computation normalization correction value from the exponent value. Reference numeral 117 denotes a mantissa incrementer, which generates a two's complement of the negative mantissa subtraction result or adds 1 to round the positive mantissa subtraction result.
【0030】118は先行1検出器で、真の減算の場合
に仮数差の桁落ちしたビット数を検出する。119は仮
数左シフタで、桁落ちが発生したときに仮数部を正規化
する。以上のように構成された本発明の実施例における
浮動小数点加減算装置の動作を以下に説明する。本実施
例の浮動小数点加減算装置は、3段のパイプライン処理
により浮動小数点数同士を加減算する。本実施例は入力
(sA,eA,mA)で表される浮動小数点数Aと入力(sB,eB,mB)
で表される浮動小数点数Bを受け取り、これらの加算ま
たは減算を行なった後(sR,eR,mR)で表される結果の和
(A+B)または差(A−B)を出力する。AとBは正規化数
であり、mAとmBの隠れたMSBの1はあらかじめ付加されて
いるものとする。前記3段のパイプライン処理の概要を
次に述べる。 <第1段> ・指数部によりAとBの大小を比較し、小さい方の仮数部
を桁合わせする。Reference numeral 118 is a leading one detector, which detects the number of bits in which the mantissa difference is missed in the case of true subtraction. A mantissa left shifter 119 normalizes the mantissa part when a digit loss occurs. The operation of the floating point addition / subtraction device according to the embodiment of the present invention configured as described above will be described below. The floating-point addition / subtraction device of this embodiment performs addition / subtraction of floating-point numbers by a three-stage pipeline process. This example is input
Floating-point number A represented by (s A , e A , m A ) and input (s B , e B , m B )
Receives the floating-point number B represented by and outputs the sum (A + B) or difference (A-B) of the result represented by (s R , e R , m R ) after adding or subtracting these . A and B are normalized numbers, and 1 of the hidden MSBs of m A and m B has been added in advance. The outline of the three-stage pipeline processing will be described below. <1st stage> -Compare the magnitudes of A and B by the exponent part and align the digit of the smaller mantissa part.
【0031】・真の減算で指数差が0の場合でなければ
結果の符号を決定する。 <第2段> ・実質的な仮数部の加減算を行なう。 ・真の減算の場合且つ指数差が0であれば仮数の大小判
定により最終的な符号を決定する。 <第3段> ・仮数部の丸めを行なう。仮数部の差が負であれば、そ
の2の補数を取る。If the exponent difference is not 0 in true subtraction, the sign of the result is determined. <Second stage> -Substantially adding and subtracting the mantissa part. In the case of true subtraction and if the exponent difference is 0, the final sign is determined by the mantissa magnitude judgment. <Third stage> • Round the mantissa part. If the difference in the mantissa is negative, the two's complement is taken.
【0032】・桁落ちした場合、仮数部と指数部の正規
化を行なう。 本実施例により浮動小数点数AとBを加減算する場合、そ
の具体的な動作を以下に説明する。仮数上位あふれの発
生は、真の加算の場合に仮数加算器112で求めた和の
Vビットが1になることで判定できる。第3段は真の加算
の場合には実質的に動作せず、符号・指数部・仮数部は
第3段を素通りする。本パイプライン第3段における一
連の処理は、一般に演算後正規化と呼ばれる。 <第1段> (1.1) 指数減算器102において指数差(eA−eB)を計
算する。 (1.2) 指数差絶対値化器104において指数差の絶対値
|eA−eB|を計算する。 (1.3) 指数比較結果に基づき、指数選択器103により
eAとeBの内大きい方を選択し、max(eA,eB)を出力する。 (1.4) 符号生成器101において(表2)に基づき仮の
符号を決定する。 (1.5) 2つの仮数部mAとmBの内、大仮数選択器105に
より指数の大きい方の仮数部を選択し、これをmsとす
る。2つの指数値eAとeBが等しい場合、大仮数選択器1
05はいずれの仮数部を選択してもよい。 (1.6) 2つの仮数部mAとmBの内、小仮数選択器106に
より指数の小さい方の仮数部を選択し、これをmlとす
る。2つの指数値eAとeBが等しい場合、小仮数選択器1
06は大仮数選択器105とは別の方を選択する。 (1.7) 仮数右シフタ107によりmsを|eA−eB|ビット
右へシフトする。これを桁合わせと呼び、桁合わせされ
たmsをms'で表す。 (1.8) Sビット生成器108により、上記桁合わせ時に
仮数部のRビットより右にこぼれた全ビットの論理和を
取りこれをSビットとする。 (1.9) 第1の仮数ビット反転器109において、真の加
算の場合ms'を素通しさせ、真の減算の場合ms'をビット
反転させる。 <第2段> (2.1) 仮数加算器112によりmlと第1の仮数ビット反
転器109の出力と桁上げ入力を加算する。この桁上げ
入力は真の減算の場合に減数の2の補数を作るためであ
り、真の減算の場合にRビットにSビットの反転を加え
る。 (2.2) (表3)に基づき左右1ビットシフタ113にお
いて、和が仮数上位あふれを起こした場合和を1ビット
右シフトし、差が1ビットの桁落ちを起こした場合差を1
ビット左シフトし、さもなければ素通りさせる。 (2.3) (表3)に基づき指数増減器111において、和
が仮数上位あふれを起こした場合max(eA,eB)を1増や
し、差が1ビットの桁落ちを起こした場合max(eA,eB)を
1減らし、さもなければ素通しさせる。 (2.4) 丸め補正器115により、(表4)に基づき丸め
による増分論理を決定する。 (2.5) 真の減算の場合に差が負になった場合第2の仮数
ビット反転器114は仮数をビット反転させ、さもなけ
れば素通しさせる。 (2.6) 真の減算の場合に差が負になった場合符号反転器
110は第1段において決定した符号を反転させ、さも
なければ素通しさせる。これをsRとする。 <第3段> (3.1) 仮数増分器117により、真の減算の場合に差が
負になった場合仮数加減算結果に2の補数化用の1を加
え、さもなければ仮数加減算結果に丸め増分値を加え
る。 (3.2) 先行1検出器118は、差のMビットより右へス
キャンして最初にビット1が現われるビット位置を探索
し、そのビット位置とMビットとの距離を2進数にエン
コードする。真の加算ではこの距離は0である。 (3.3) 仮数左シフタ119は、先行1検出器118で求
めたビット数だけ差を左へシフトすることにより、差の
Mビットが1となるように仮数部を調整する。シフトし
た仮数部をmRとする。真の加算では既に仮数部のMビッ
トは1であるため、シフトしない。 (3.4) 指数補正器116において、補正された指数部よ
り前記エンコードされた左シフト数を減じた差をeRとす
る。真の加算ではエンコードされた左シフト数より0を
減ずる。(終わり)When the digit is lost, the mantissa part and the exponent part are normalized. When the floating point numbers A and B are added and subtracted according to the present embodiment, the specific operation will be described below. Occurrence of the mantissa higher overflow occurs in the sum calculated by the mantissa adder 112 in the case of true addition.
It can be determined by setting the V bit to 1. The third stage does not substantially operate in the case of true addition, and the sign, exponent part, and mantissa part pass through the third stage. The series of processing in the third stage of the pipeline is generally called post-operation normalization. Calculating index difference (e A -e B) in the <First stage> (1.1) Index subtractor 102. (1.2) The absolute value of the index difference | e A −e B | is calculated in the index difference absolute value converter 104. (1.3) Based on the index comparison result, the index selector 103
Write Select larger of e A and e B, and outputs the max (e A, e B) . (1.4) The code generator 101 determines a temporary code based on (Table 2). (1.5) Of the two mantissa parts m A and m B , the mantissa part with the larger exponent is selected by the large mantissa selector 105, and this is designated as m s . If the two exponent values e A and e B are equal, the large mantissa selector 1
05 may select any mantissa part. (1.6) Of the two mantissa parts m A and m B , the mantissa part with the smaller exponent is selected by the small mantissa selector 106, and this is designated as m l . If the two exponent values e A and e B are equal, the fractional mantissa selector 1
06 selects a different one from the large mantissa selector 105. (1.7) The mantissa right shifter 107 shifts m s to the right | e A −e B | bit. This is called digit alignment, representing a digit alignment has been m s in m s'. (1.8) The S-bit generator 108 takes the logical sum of all the bits spilled to the right of the R bits of the mantissa at the time of the digit alignment, and sets this as the S bit. (1.9) In the first mantissa bit inverter 109, m s ′ is passed through in the case of true addition, and m s ′ is bit-inverted in the case of true subtraction. <Second stage> (2.1) adds the output and carry input of m l and first mantissa bit inverter 109 by the mantissa adder 112. This carry input is for making the two's complement of the subtraction in the case of true subtraction, and adds the S bit inversion to the R bit in the case of true subtraction. (2.2) Based on (Table 3), in the left and right 1-bit shifter 113, the sum is shifted to the right by 1 bit when the sum causes the mantissa to overflow, and the difference is set to 1 when the difference causes a 1-bit precision loss.
Shift left by a bit, otherwise pass through. (2.3) Based on (Table 3), the exponent adjuster 111 increases max (e A , e B ) by 1 when the sum causes the mantissa to overflow, and max (e A , e B ) when the difference causes one-digit loss. Decrease A , e B ) by 1, otherwise let go through. (2.4) The rounding corrector 115 determines the increment logic by rounding based on (Table 4). (2.5) If the difference becomes negative in the case of true subtraction, the second mantissa bit inverter 114 bit-inverts the mantissa and otherwise passes it through. (2.6) If the difference becomes negative in the case of true subtraction The sign inverter 110 inverts the sign determined in the first stage, and otherwise passes it through. Let this be s R. <Third stage> (3.1) Mantissa incrementer 117 adds 1 for 2's complement to the mantissa addition / subtraction result when the difference becomes negative in the case of true subtraction, and otherwise rounds the mantissa addition / subtraction result Add value. (3.2) The leading one detector 118 scans to the right of the difference M bits to search for the bit position where the bit 1 first appears, and encodes the distance between the bit position and the M bit into a binary number. In true addition, this distance is zero. (3.3) The mantissa left shifter 119 shifts the difference to the left by the number of bits obtained by the preceding 1 detector 118, thereby reducing the difference.
Adjust the mantissa so that the M bit is 1. The shifted mantissa is m R. In true addition, the M bits of the mantissa part are already 1, so they are not shifted. (3.4) In the exponent corrector 116, the difference obtained by subtracting the encoded left shift number from the corrected exponent part is taken as e R. In true addition, 0 is subtracted from the encoded left shift number. (the end)
【0033】[0033]
【表3】 [Table 3]
【0034】[0034]
【表4】 [Table 4]
【0035】上記実施例において、真の減算における減
数の2の補数化について更に考察する。減数msは桁合わ
せされた後、第1の仮数ビット反転器109によってビ
ット反転される。さらに減算のためには被減数と減数
ms'の1の補数と減数ms'のLSBにおける1の3者を加算
する必要がある。即ち減数ms'の2の補数を取るために
その1の補数のLSBに1を足さねばならない。問題は減
数が桁合わせされてしまっているためにその下位側の数
ビットが失われていることである。このため桁合わせさ
れた減数ms'の1の補数のLSBに1を足すことはできな
い。In the above example, the two's complementation of the subtrahend in true subtraction is further considered. The digits of the subtraction m s are aligned and then bit-inverted by the first mantissa bit inverter 109. Further subtraction and subtraction for subtraction
it is necessary to add the three parties of 1 in the LSB of m s '1's complement and subtrahend m s'. That is, in order to take the 2's complement of the subtraction m s ', 1 must be added to the LSB of its 1's complement. The problem is that some of the lower bits are lost because the divisors have been aligned. For this reason, it is not possible to add one to the LSB of the one's complement of the digit-matched divisor m s '.
【0036】減数のSビットを使ってこの問題を解決で
きる。図5〜図8に仮数部における真の減算の仕組みを
示し、これに沿って説明する。図5において、被減数ml
は正規化された正数であり、減数ms'は既に桁合わせさ
れた正数で、そのLビットより右に仮想的にこぼれたビ
ットが示されており、これらは実際には既に消滅した情
報である。This problem can be solved by using the S bit of the reduction. The mechanism of true subtraction in the mantissa part is shown in FIGS. 5 to 8 and will be described along with it. 5, minuend m l
Is a normalized positive number, and the subtraction m s ' is a positive number that has already been aligned and shows a virtual spill bit to the right of its L bit, and these have actually disappeared. Information.
【0037】まず減数ms'の1の補数を取り、仮想的に
減数ms'のLSBに1を加算して2の補数を取る(図6)。
実際に仮想的なLSBに1を加算することはできないが、
その仮想的な1の加算を行なった結果、それによる桁上
げが現実のLSBにまで伝播して来るかどうかを判定する
ことはできる。この現実のLSBは、ここではRビットであ
るとする。桁上げが仮想的なLSBからRビットにまで伝播
して来る場合は桁合わせで減数ms'のLビットより右にこ
ぼれた全ビットz3z4 ‥‥zrの反転が1である場合に限
る。First, the 1's complement of the subtraction m s 'is taken, and 1 is virtually added to the LSB of the subtraction m s ' to obtain the 2's complement (FIG. 6).
Although you can't actually add 1 to the virtual LSB,
As a result of performing the virtual addition of 1, it is possible to determine whether or not the carry by it propagates to the actual LSB. This real LSB is assumed to be R bits here. When the carry propagates from the virtual LSB to the R bit, all digits z 3 z 4 ... z r spilled to the right from the L bit of the subtraction m s ' when digit alignment is 1 inversion of z r Limited to.
【0038】[0038]
【数1】 [Equation 1]
【0039】従って z3z4 ‥‥zr=00‥‥0 図7に示すように全てのzi(i=3,4,...,r−1,r)の論理和
はSであるから S=0 よってSが0のときのみ現実のLSBに1を加算すれば正し
い桁合わせされた減数の2の補数が得られる。この条件
は現実のLSBにSの論理否定を加算することと等価である
(図7)。結局RビットにSの論理否定を加えればよい
(図8)ことがわかる。Therefore, z 3 z 4・ ・ ・ z r = 00 ・ ・ ・ 0 As shown in FIG. 7, the logical sum of all z i (i = 3,4, ..., r−1, r) is S. Therefore, S = 0, so if 1 is added to the actual LSB only when S is 0, the correct complemented 2's complement of the divisor can be obtained. This condition is equivalent to adding the logical NOT of S to the actual LSB (Fig. 7). After all, it can be seen that the logical NOT of S should be added to the R bit (Fig. 8).
【0040】本実施例では3段のパイプラインで処理す
るので、上述の動作の記述のように浮動小数点数の符号
・指数部・仮数部をパイプライン1段毎に同期させなが
ら処理を進行させる。パイプライン処理の各段において
符号・指数部・仮数部の3つの部分を処理するタイミン
グの組み合わせは上記以外にも幾つか考えられるが、本
発明に関して本実施例とその各段における処理のタイミ
ングをずらした本実施例の変形との本質的な違いはな
い。本実施例ではパイプライン各段の回路遅延がなるべ
く均等になるような構造を意図して設計したが、他の回
路構成法によれば別の段区分があり得る。パイプライン
段数も3である必然性はなく、本実施例のパイプライン
構成は本発明のアルゴリズムの一実現例に過ぎない。In this embodiment, since processing is carried out by a three-stage pipeline, the processing proceeds while synchronizing the sign / exponent part / mantissa part of the floating point number for each pipeline stage as described in the above operation. . Several combinations of timings for processing the three parts of the sign, exponent part, and mantissa part in each stage of the pipeline processing are conceivable in addition to the above. However, regarding the present invention, the processing timings in this embodiment and each stage thereof will be described. There is essentially no difference from the modified version of this embodiment. In this embodiment, the structure was designed with the intention that the circuit delays of the respective stages of the pipeline are as uniform as possible, but there may be different stage divisions according to other circuit configuration methods. The number of pipeline stages does not necessarily have to be 3, and the pipeline configuration of this embodiment is merely one implementation example of the algorithm of the present invention.
【0041】本実施例と同等の機能を持つ他の変形され
た実施例が幾つか考えられる。次にその幾つかの変更点
について説明を付け加える。指数増減器111の回路構
成については、図9に示すように幾つかの選択肢があ
る。本実施例中で図9(a)のように表記された指数増減
器111は、詳細には図9(b)〜(d)のように構成され
る。Several other modified embodiments having the same function as this embodiment can be considered. Next, a description of some of the changes will be added. There are several options for the circuit configuration of the index adjuster 111, as shown in FIG. In the present embodiment, the index adjuster 111 shown in FIG. 9 (a) is configured in detail as shown in FIGS. 9 (b) to 9 (d).
【0042】図9(b)の指数増減器は、増分器602と
減分器603を直列に接続した単純な構成をとる。図9
(c)の指数増減器は、増分器605の前後にビット反転
器604,606を直列に接続した構成をとる。指数に
1を加える場合、ビット反転器604,606を素通し
させ増分器605で1を加える。指数から1を減ずる場
合、ビット反転器604,606でビット反転させ増分
器605で1を加える。指数値を変化させない場合、ビ
ット反転器604,606と増分器605を素通しさせ
る。この構成により指数値をデクリメントできることは
以下のように説明できる。The index adjuster of FIG. 9 (b) has a simple structure in which an incrementer 602 and a decrementer 603 are connected in series. Figure 9
The exponent adjuster of (c) has a configuration in which bit inverters 604 and 606 are connected in series before and after the incrementer 605. Exponentially
When adding 1, the bit inverters 604 and 606 are passed through and the incrementer 605 adds 1. When subtracting 1 from the exponent, the bit inverters 604 and 606 invert the bits and the incrementer 605 adds 1. When the exponent value is not changed, the bit inverters 604 and 606 and the incrementer 605 are passed through. The fact that the index value can be decremented by this configuration can be explained as follows.
【0043】[0043]
【数2】 [Equation 2]
【0044】だからTherefore
【0045】[0045]
【数3】 [Equation 3]
【0046】よりFrom
【0047】[0047]
【数4】 [Equation 4]
【0048】図9(d)の指数増減器は、第1の従来例の
指数増減器320,321,322に示された構成と同
じ構成をとる。仮数加算器112とその前後の仮数ビッ
ト反転器109,114の回路構成については、図10
に示すように幾つかの選択肢がある。図10(a)の構成
は本実施例中に示されたものである。上述したこれらの
仮数ビット反転器の動作を(表5)にまとめる。The index adjuster of FIG. 9 (d) has the same structure as the index adjusters 320, 321, 322 of the first conventional example. For the circuit configuration of the mantissa adder 112 and the mantissa bit inverters 109 and 114 before and after the mantissa adder 112, see FIG.
There are several options as shown in. The configuration shown in FIG. 10A is the one shown in this embodiment. The operation of these mantissa bit inverters described above is summarized in Table 5.
【0049】図10(b)は、仮数ビット反転器702を
仮数加算器705に関して仮数ビット反転器701の反
対側の入力に移した構成をとる。この仮数加減算器構成
における仮数ビット反転器の動作を(表6)に掲げる。In FIG. 10B, the mantissa bit inverter 702 is moved to the input on the opposite side of the mantissa bit inverter 701 with respect to the mantissa adder 705. The operation of the mantissa bit inverter in this mantissa adder / subtractor configuration is listed in (Table 6).
【0050】[0050]
【表5】 [Table 5]
【0051】[0051]
【表6】 [Table 6]
【0052】図10(b)の構成により仮数減算を実行で
きることは以下のように説明できる。The fact that the mantissa subtraction can be executed by the configuration of FIG. 10B can be explained as follows.
【0053】[0053]
【数5】 [Equation 5]
【0054】本実施例では正規化数同士を加減算して正
規化数の和または差を得る状況のみに関し記述したが、
被演算数の一方が非正規化数や0である場合、あるいは
演算結果が非正規化数や0である場合でも上述の算法を
変更することなく、正しく計算できることは明らかであ
る。但し指数下位あふれ検出機構など若干の回路追加は
必要である。In the present embodiment, the description has been made only on the situation of adding or subtracting normalized numbers to obtain the sum or difference of the normalized numbers.
Even if one of the operands is a denormalized number or 0, or if the operation result is a denormalized number or 0, it is clear that the calculation can be performed correctly without changing the above-mentioned arithmetic method. However, it is necessary to add some circuits such as the exponent lower overflow detection mechanism.
【0055】[0055]
【発明の効果】以上説明してきたように本発明の浮動小
数点加減算装置によれば、仮数部の加減算と丸めをパイ
プライン1段で処理するために2つの仮数加減算器が必
要であったのに対して、真の加算または指数差が0でな
い真の減算の場合には、仮数加減算器の加算結果を上位
桁あふれまたは上位桁落ちの有無に応じて左右1ビット
シフタで正規化して仮数増分器により正確に丸め、ま
た、指数差が0で真の減算の場合には、負の減算結果に
対して反転器及び仮数増分器により絶対値化(2の補数
化)をする。これにより、従来と同等の性能を1つの仮
数加減算器で発揮できる。したがって、従来の浮動小数
点加減算処理に比べ非常に小さい回路規模にすることが
できるという効果がある。加えて、回路規模が小さくな
ることにより回路のクリティカルパスを緩和されるので
回路を高速化することができるという効果がある。その
結果、浮動小数点加減算装置をより少ないコストで実現
できるのでその実用的効果は大きい。As described above, according to the floating point adder / subtractor of the present invention, two mantissa adders / subtractors are required to process addition / subtraction of the mantissa part and rounding in one pipeline stage. On the other hand, in the case of true addition or true subtraction in which the exponent difference is not 0, the addition result of the mantissa adder / subtractor is normalized by the left and right 1-bit shifters according to the presence or absence of upper digit overflow or upper digit loss, and then the mantissa incrementer is used. In the case of accurate rounding and true subtraction when the exponent difference is 0, the negative subtraction result is converted into an absolute value (two's complement) by the inverter and the mantissa incrementer. As a result, the performance equivalent to that of the related art can be exhibited by one mantissa adder / subtractor. Therefore, there is an effect that the circuit scale can be made extremely small as compared with the conventional floating point addition / subtraction processing. In addition, since the circuit size is reduced, the critical path of the circuit is mitigated, so that the circuit can be sped up. As a result, the floating-point adder / subtractor can be realized at a lower cost, and its practical effect is great.
【図1】本発明の実施例における浮動小数点加減算装置
の構成図である。FIG. 1 is a configuration diagram of a floating-point addition / subtraction device according to an embodiment of the present invention.
【図2】仮数部のビット位置の名称を説明する模式図で
ある。FIG. 2 is a schematic diagram illustrating names of bit positions of a mantissa part.
【図3】第1の従来例の浮動小数点加減算装置の構成図
である。FIG. 3 is a configuration diagram of a first conventional floating-point addition / subtraction device.
【図4】第2の従来例の浮動小数点加減算装置の構成図
である。FIG. 4 is a block diagram of a second conventional floating-point addition / subtraction device.
【図5】真の減算における最近値丸め算法を説明する模
式図(その1)である。FIG. 5 is a schematic diagram (No. 1) for explaining a nearest value rounding method in true subtraction.
【図6】真の減算における最近値丸め算法を説明する模
式図(その2)である。FIG. 6 is a schematic diagram (No. 2) for explaining a nearest-value rounding method in true subtraction.
【図7】真の減算における最近値丸め算法を説明する模
式図(その3)である。FIG. 7 is a schematic diagram (No. 3) explaining the nearest-value rounding method in true subtraction.
【図8】真の減算における最近値丸め算法を説明する模
式図(その4)である。FIG. 8 is a schematic diagram (No. 4) for explaining a nearest-value rounding method in true subtraction.
【図9】指数増減器の実現法を説明する構成図である。FIG. 9 is a configuration diagram illustrating a method of realizing an exponent adjuster.
【図10】仮数加減算器と1の補数器の実現法を説明す
る構成図である。FIG. 10 is a configuration diagram illustrating a method of implementing a mantissa adder / subtractor and a one's complementer.
101 符号生成器 102 指数減算器 103 指数選択器 104 指数差絶対値化器 105 仮数選択器 106 仮数選択器 107 仮数右シフタ 108 Sビット生成器 109 仮数ビット反転器 110 符号反転器 111 指数増減器 112 仮数加算器 113 左右1ビットシフタ 114 仮数ビット反転器 115 丸め補正器 116 指数補正器 117 仮数増分器 118 先行1検出器 119 仮数左シフタ 101 Code Generator 102 Exponent Subtractor 103 Exponent Selector 104 Exponential Difference Absolute Quantizer 105 Mantissa Selector 106 Mantissa Selector 107 Mantissa Right Shifter 108 S-bit Generator 109 Mantissa Bit Inverter 110 Sign Inverter 111 Exponent Increase / Decrease 112 Mantissa adder 113 Left and right 1-bit shifter 114 Mantissa bit inverter 115 Rounding corrector 116 Exponent corrector 117 Mantissa incrementer 118 Leading 1 detector 119 Mantissa left shifter
Claims (3)
数点形式の2数の和又は差を計算する浮動小数点加減算
装置であって、 2つの浮動小数点数のうち指数の小さい方の仮数部を選
択し、指数が同じならばいずれか一方の仮数部を選択す
る小仮数選択手段と、 2つの浮動小数点数のうち小仮数選択手段と異なる方の
仮数部を選択する大仮数選択手段と、 小仮数選択手段の出力を2つの浮動小数点数の指数差の
絶対値だけ下位側(以下右と呼ぶ)へ論理シフトする
(以下桁合わせすると呼ぶ)桁合わせ手段と、 正数へ正数を加える又は正数から負数を減ずる又は負数
へ負数を加える又は負数から正数を減ずる場合(以下真
の加算の場合と呼ぶ)、大仮数選択手段の出力に前記桁
合わせされた仮数値を加え、正数へ負数を加える又は正
数から正数を減ずる又は負数へ正数を加える又は負数か
ら負数を減ずる場合(以下真の減算の場合と呼ぶ)、大
仮数選択手段の出力から前記桁合わせされた仮数値を減
ずる仮数加減算手段と、 仮数加減算手段から出力される和が上位あふれを起こし
ている場合和を1ビット右シフトし、差が1ビットの桁
落ちを起こしている場合差を1ビット左シフトし、さも
なければ素通しさせる左右1ビットシフト手段と、 左右1ビットシフト手段の出力が負である場合その出力
をビット毎に反転し、さもなければ素通しさせる仮数ビ
ット反転手段と、 桁合わせされた仮数値と左右1ビットシフト手段の出力
に基づいて丸め論理を決定する丸め補正手段と、 加数加減算結果が負の場合仮数ビット反転手段の出力に
2の補数化用の1を加え、丸め補正手段において丸め用
の1を加算すべきと決定された場合仮数ビット反転手段
の出力に1を加算し、さもなければこれを素通しさせる
仮数増分手段とを備えることを特徴とする浮動小数点加
減算装置。1. A floating-point adder / subtractor for calculating the sum or difference of two floating-point numbers represented by a sign, an exponent part, and a mantissa part, and the mantissa of the smaller of the two exponents. A small mantissa selecting means for selecting a part and, if the exponents are the same, one of the mantissa parts, and a large mantissa selecting means for selecting a mantissa part of the two floating point numbers different from the small mantissa part. , The digit of the mantissa selection means is logically shifted to the lower side (hereinafter referred to as right) by the absolute value of the exponent difference between the two floating point numbers (hereinafter referred to as digit matching), and the positive number is converted to a positive number. When adding or subtracting a negative number from a positive number or adding a negative number to a negative number or subtracting a positive number from a negative number (hereinafter referred to as the case of true addition), the digit-matched mantissa value is added to the output of the large mantissa selection means, Add a negative number to a positive number or from a positive number When subtracting a number or adding a positive number to a negative number or subtracting a negative number from a negative number (hereinafter referred to as a true subtraction), a mantissa adder / subtractor that subtracts the digit-matched mantissa from the output of the large mantissa selector, and a mantissa If the sum output from the adder / subtractor causes an upper overflow, the sum is shifted to the right by 1 bit, and if the difference causes a loss of 1 bit, the difference is shifted to the left by 1 bit. The bit shift means and the mantissa bit inverting means for inverting the output of each bit when the output of the left and right 1-bit shift means is negative and passing through otherwise, and the digit-matched mantissa value and the left and right 1-bit shift means. Rounding correction means for determining rounding logic based on the output, and 1 for 2's complement addition to the output of the mantissa bit inverting means when the addend / subtraction result is negative, and the rounding correction means Floating point addition and subtraction device characterized by comprising when it is determined 1 and to be added to 1 is added to the output of the mantissa bit inversion means, otherwise the mantissa increment means for plain it for rounding.
せ、真の減算の場合ビット毎に反転させる第1の仮数ビ
ット反転手段と、 桁合わせされた仮数値に基づき2の補数化用の桁上げ入
力を発生する桁上げ入力発生手段と、 真の加算の場合大仮数選択手段の出力と第1の仮数ビッ
ト反転手段の出力とを加算し、真の減算の場合これらに
加えて前記桁上げ入力を加算する仮数加算手段と、を備
えることを特徴とする請求項1記載の浮動小数点加減算
装置。2. The mantissa adder / subtracter means is adapted to pass the digit-matched mantissa value through in the case of true addition, and to invert bit by bit in the case of true subtraction. Carry input generating means for generating a carry input for two's complementing based on the mantissa value, the output of the large mantissa selecting means and the output of the first mantissa bit inverting means in the case of true addition, The floating point addition / subtraction device according to claim 1, further comprising mantissa adding means for adding the carry input in the case of true subtraction.
真の減算の場合ビット毎に反転させる第1の仮数ビット
反転手段と、 大仮数選択手段の出力に基づき2の補数化用の桁上げ入
力を発生する桁上げ入力発生手段と、 真の加算の場合第1の仮数ビット反転手段の出力と前記
桁合わせされた仮数値とを加算し、真の減算の場合これ
らに加えて前記桁上げ入力を加算する仮数加算手段と、
を備えることを特徴とする請求項1記載の浮動小数点加
減算装置。3. The mantissa adder / subtractor causes the output of the large mantissa selector to pass through in the case of true addition,
In the case of true subtraction, first mantissa bit inverting means for inverting every bit, carry input generating means for generating a carry input for two's complement conversion based on the output of the big mantissa selecting means, and true add bit A mantissa adding means for adding the output of the first mantissa bit inverting means and the digit-matched mantissa value, and adding the carry input in addition to these for true subtraction;
The floating point addition / subtraction apparatus according to claim 1, further comprising:
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP5262813A JPH07121353A (en) | 1993-10-20 | 1993-10-20 | Floating point adder / subtractor |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP5262813A JPH07121353A (en) | 1993-10-20 | 1993-10-20 | Floating point adder / subtractor |
Publications (1)
Publication Number | Publication Date |
---|---|
JPH07121353A true JPH07121353A (en) | 1995-05-12 |
Family
ID=17380974
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP5262813A Pending JPH07121353A (en) | 1993-10-20 | 1993-10-20 | Floating point adder / subtractor |
Country Status (1)
Country | Link |
---|---|
JP (1) | JPH07121353A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2012174269A (en) * | 2011-02-17 | 2012-09-10 | Arm Ltd | Apparatus and method for executing floating point addition |
RU2686628C1 (en) * | 2017-12-25 | 2019-04-29 | Акционерное общество "Ангстрем" (АО "Ангстрем") | Addition-subtraction device for digital signal processor |
-
1993
- 1993-10-20 JP JP5262813A patent/JPH07121353A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2012174269A (en) * | 2011-02-17 | 2012-09-10 | Arm Ltd | Apparatus and method for executing floating point addition |
RU2686628C1 (en) * | 2017-12-25 | 2019-04-29 | Акционерное общество "Ангстрем" (АО "Ангстрем") | Addition-subtraction device for digital signal processor |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US5027308A (en) | Circuit for adding/subtracting two floating point operands | |
US5010508A (en) | Prenormalization for a floating-point adder | |
US6529928B1 (en) | Floating-point adder performing floating-point and integer operations | |
JP2508912B2 (en) | Floating point adder | |
JP3076046B2 (en) | Exception detection circuit | |
KR100232962B1 (en) | Fused floating point multiply and accumulate unit with carry correction | |
US8166092B2 (en) | Arithmetic device for performing division or square root operation of floating point number and arithmetic method therefor | |
US8185570B2 (en) | Three-term input floating-point adder-subtractor | |
US6895423B2 (en) | Apparatus and method of performing product-sum operation | |
US7720898B2 (en) | Apparatus and method for adjusting exponents of floating point numbers | |
KR100203468B1 (en) | Arithmetic apparatus for floating point numbers | |
US20030028572A1 (en) | Fast single precision floating point accumulator using base 32 system | |
US6175851B1 (en) | Fast adder/subtractor for signed floating point numbers | |
KR19980032114A (en) | Method and apparatus for generating an initial estimate of a square root floating point | |
US6785701B2 (en) | Apparatus and method of performing addition and rounding operation in parallel for floating-point arithmetic logical unit | |
US5282156A (en) | Leading one anticipator and floating point addition/subtraction apparatus employing same | |
TWI723681B (en) | Multi-input floating-point adder | |
KR19980082906A (en) | How to Convert Floating-Point Numbers to Integer Types | |
JPH07121353A (en) | Floating point adder / subtractor | |
JPH0635671A (en) | Floating point adder / subtractor | |
US7552165B2 (en) | Method and system to implement an improved floating point adder with integrated adding and rounding | |
JP2752564B2 (en) | Leading one prediction device and floating point addition / subtraction device | |
JP3187402B2 (en) | Floating point data addition / subtraction circuit | |
JP3512700B2 (en) | Floating point arithmetic unit | |
JPH05167456A (en) | Arithmetic operation circuit |