JP2004252554A - Rounding processing device of numerical coprocessor - Google Patents

Rounding processing device of numerical coprocessor Download PDF

Info

Publication number
JP2004252554A
JP2004252554A JP2003039702A JP2003039702A JP2004252554A JP 2004252554 A JP2004252554 A JP 2004252554A JP 2003039702 A JP2003039702 A JP 2003039702A JP 2003039702 A JP2003039702 A JP 2003039702A JP 2004252554 A JP2004252554 A JP 2004252554A
Authority
JP
Japan
Prior art keywords
rounding
mantissa
rounding error
unit
error
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
Application number
JP2003039702A
Other languages
Japanese (ja)
Inventor
Yoshitaka Kashiwagi
喜孝 柏木
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Yaskawa Electric Corp
Original Assignee
Yaskawa Electric Corp
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Yaskawa Electric Corp filed Critical Yaskawa Electric Corp
Priority to JP2003039702A priority Critical patent/JP2004252554A/en
Publication of JP2004252554A publication Critical patent/JP2004252554A/en
Pending legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To provide a rounding processing device for a numerical coprocessor capable of creating the magnitude relation between the magnitude of a rounding error and an operation result as a rounding error, further converting the rounding error to a floating point format so as to be smoothly usable for an operation to be successively performed. <P>SOLUTION: This rounding processing device for a numerical coprocessor comprises a rounding error creation part 17 for determining the difference between a mantissa b (S17) before rounding and a mantissa d after rounding (S22) in the rounding part 10 of the numerical coprocessor 3, and generating a rounding error S23 having the sign and magnitude of the rounding error; and a rounding error storage part 18 for storing the rounding error generated by the creation part 17, which is controlled by an operation part strobe bus S21 so as to enable a host processor to read the stored rounding error at an optional point of time through an internal data bus S4. <P>COPYRIGHT: (C)2004,JPO&NCIPI

Description

【0001】
【発明の属する技術分野】
本発明は、浮動小数点を演算する数値演算プロセッサの丸め処理装置に関する。
【0002】
【従来の技術】
最初に、IEEE754規格の浮動小数点フォーマットについて図7および図8を用いて説明する。図7は浮動小数点フォーマットを示す図、図8はガードビットを示す図である。
浮動小数点数N1は、図7に示すように符号部N2、指数部N3と仮数部N4がエンコードされたものである。例えば単精度の場合、浮動小数点数は32ビットで、符号部が1ビット、指数部が8ビット、仮数部が23ビットである。符号部が正負を、指数部が大きさを、仮数部が精度となる。仮数は
1.0≦仮数<2.0
となるように正規化される。小数点の左側の1は必ず存在するため、この1ビットはあるものとして、仮数部には小数点の右側の小数が入る。次に、浮動小数点で演算を行う時にIEEE754規格では仮数を無限大の精度をもつものとして演算するように記述されている。そのために仮数部のLSB側には、図8に示すようにガードビットN5と呼ばれる、余分なビットをつけて演算回路を構成し、IEEE754規格を満足させる。そのため、このガードビットは最終的に何らかの処理を施す必要があり、これが丸め処理になる。
【0003】
次に、従来の数値演算プロセッサについて、図5および図6を用いて説明する。図5は従来技術を示す数値演算プロセッサの丸め処理装置のブロック図、図6は図5の演算部の詳細を示したブロック図である。
図5において、1はマイクロプロセッサ、2はメモリ、3は数値演算プロセッサ、4は制御部、5は制御レジスタ部、6はデータレジスタ部、7は演算部、8は演算器、9は正規化部、10は丸め部である。マイクロプロセッサ1、メモリ2および数値演算プロセッサ3はデータバスS1、アドレスバスS2およびストローブバスS3で接続されている。数値演算プロセッサ3は、内部データバスS4によりデータバスS1と接続されると共に、該プロセッサ内に設けた制御部4と、制御レジスタ部5、データレジスタ部6および演算部7が内部データバスS4により夫々接続されている。演算部7内はデータレジスタ部6のデータを入力として、オペコードS9で指示された演算を実行し、符号a(S12)、指数a(S13)および仮数a(S14)を生成する演算器8と、符号a(S12)、指数a(S13)および仮数a(S14)を入力として、正規化を実行し、符号b(S15)、指数b(S16)と仮数b(S17)を生成する正規化部9と、符号b(S15)、指数b(S16)と仮数b(S17)を入力として、丸めモードS10に従い丸めを行い演算結果となる浮動小数点数を生成する丸め部10から構成される。
丸め部10では非正規化数が発生する可能性があるため、発生した場合には指数c(S18)と仮数c(S19)と非正規化数発生信号S20を生成し、正規化部9に再入力する。演算器8、正規化部9および丸め部10ではオーバーフローや不正確等の例外S11を発生する。アドレスバスS2と接続された内部アドレスバスS5と、ストローブバスS3と接続された内部ストローブバスS6は、制御部4と接続されている。演算部7の動作モードなどを設定する制御レジスタ部5へのデータのリード、ライトは、制御レジスタ部ストローブバスS7で制御される。同様に、演算部7のデータとなるデータレジスタ部6へのデータのリード、ライトは、データレジスタ部ストローブバスS8で制御される。演算部7のデータの入出力等の動作は、演算部ストローブバスS21で制御される。以上の構成において、数値演算プロセッサ3はデータレジスタ部6に書き込まれたデータを入力として演算部7で浮動小数点数による演算を実行し、結果をデータレジスタ部6に書き込む。
【0004】
続いて,図6では丸め部10について説明する。
図6において,11は丸め計算部、12は浮動小数点数作成部、13は例外生成部、14は非正規化数検出部、15は指数生成部、16は仮数生成部である。
丸め部10は、正規化部9で生成された、符号b(S15)、指数b(S16)および仮数b(S17)を入力とする。仮数b(S17)は丸め計算部11に入力され丸めモードS10に従い丸めを行い仮数d(S22)を生成する。
IEEE754では、最近値丸め、0方向への丸め、正の無限大方向への丸めと負の無限大方向への丸めの4つが、丸めモードとして規定されている。符号b(S15)、指数b(S16)および仮数d(S22)は浮動小数点数作成部12に入力され演算結果となる浮動小数点数を生成する。仮数b(S17)は例外生成部13に入力されて、丸めが行われた場合に発生する不正確例外の検出を行い、例外S11を発生させる。仮数d(S22)はさらに非正規化数検出部14に入力され、丸め後に非正規化数が発生しているか検査し、非正規化数発生信号S20を生成する。指数生成部15は、非正規化数発生信号S20と指数b(S16)を入力として指数c(S18)を、仮数生成部16は、非正規化数発生信号S20と仮数b(S17)を入力として仮数c(S19)を、それぞれ生成して、正規化部9に再入力する。このように、正規化や丸めは時間のかかる処理であり、従来の数値演算プロセッサの丸め回路において、丸め処理の高速性を改善するものが提案されている(例えば、特許文献1参照)。
【0005】
【特許文献1】
特開平8−202531号公報(明細書7頁,10頁,11頁、図2)
【0006】
特開平8−202531号公報記載の図2において、マルチステージの実行パイプラインによる、ある演算の実行中に生じる解を丸める装置は、演算がいつ繰返しになるかと解に関連した精度ビットとを検出して、丸め計算が必要かどうかを判定する第1回路を含んでいる。第1回路は丸め計算が必要なことを検出すると、丸めモードと検出精度に従って解の補正ファクタをセットする。この装置によって実施される方法では、ALU演算の実行中に生じる解の丸めは、演算が繰返しのとき、解に関連した精度ビットを検出して丸め計算が必要かどうかを判定するステップと、丸め計算が必要なとき、丸めモードと検出精度ビットに従って解の補正ファクタをセットするステップを通して生じる。これにより、従来の丸め回路は演算時間の短縮を図っている。
【0007】
【発明が解決しようとする課題】
しかしながら、従来技術の丸め回路は丸め処理の処理時間の短縮が目的であり、丸め時に発生する丸め誤差については鑑みられたものはなく、整数や固定小数点の丸めと異なり、浮動小数点数の演算では丸め誤差の小数点位置が変化するという問題があった。これより丸め誤差の取り得る値の範囲が非常に広いことになり、例えば、制御系などの演算のように、丸め誤差まで含めて管理する必要がある場合に問題となる。
次に、例えば乗算のように、ガードビットのサイズを大きくすることで、演算回路での演算精度を高くできるが、丸め処理でこの演算精度が捨てられてしまう。
さらに、丸め前の値をソフトウェアでは読み出すことができないので、丸め誤差の大きさを知ることができないという根本的な問題を有している。
【0008】
本発明は上記問題を解決するためになされたものであり、演算回路での演算精度を損なうことなく、丸め誤差と演算結果を比較することにより、丸め誤差の大きさと演算結果の大小関係を丸め誤差として作成することができ、さらに丸め誤差を浮動小数点フォーマットに変換し、引き続き行われる演算にスムーズに利用することが可能な数値演算プロセッサの丸め処理装置を提供することを目的とする。
【0009】
【課題を解決するための手段】
上記問題を解決するため、請求項1に記載の数値演算プロセッサの丸め処理装置に係る発明は、丸めモードに従って、正規化部で生成された仮数bに丸めを行い、仮数dを生成する丸め計算部と、符号b、指数bおよび仮数dから演算結果を作成する浮動小数点数作成部と、前記仮数dからオーバーフローとアンダーフローの例外を作成する例外生成部と、前記仮数dが非正規化数かどうかを検査する非正規化数検出部と、前記非正規化数検出部で非正規化数を検出した場合、前記仮数dから指数cを生成する指数生成部と、前記仮数dから仮数cを生成する仮数生成部より構成される丸め部を備えた数値演算プロセッサにおいて、丸め前の仮数bと丸め後の仮数dの差をとり、丸め誤差の符号と大きさをもつ丸め誤差を生成する丸め誤差作成部と、前記丸め誤差作成部の生成した丸め誤差を記憶し、演算部ストローブバスで制御され、内部データバスを介して、ホストプロセッサから記憶した丸め誤差の読み出しを、任意の時点で行える丸め誤差記憶部を備えたものである。
【0010】
このような手段により、丸め誤差と演算結果を比較することによって、丸め誤差の大きさと演算結果との大小関係を取得することができる。
また、丸めにより本来は捨てられるハードウェアの演算精度を、丸め誤差として取得することができる。
【0011】
また、請求項2の発明は,請求項1記載の数値演算プロセッサの丸め処理装置において、前記丸め誤差作成部は,丸め前の仮数bと丸め後の仮数dの大きさの比較から符号fを生成する丸め誤差符号生成部と、丸め前の仮数bと丸め後の仮数dの差の絶対値を正規化して仮数eおよび正規化に伴う指数調整を行うための指数調整値とを生成する丸め誤差仮数生成部と、指数bと指数調整値から指数fを生成し、指数bより指数調整値のほうが大きい場合に指数調整値と指数bの差から仮数調整値を生成する丸め誤差指数生成部と、前記仮数調整値を用いて仮数eの再調整を行い仮数fを生成する丸め誤差仮数調整部と、符号f、指数fおよび仮数fからIEEE754規格により定義された浮動小数点数フォーマットの丸め誤差を生成する丸め誤差浮動小数点数作成部を備えたものである。
【0012】
このような手段により,IEEE754規格のフォーマットで丸め誤差を生成させることで、丸め誤差も浮動小数点数で統一して管理することができる。
また、丸めにより、本来は捨てられるハードウェアの演算精度を、丸め誤差として取得することができる。そのため、ハードウェアの持つ演算精度をソフトウェアにも反映することができる。
さらに、丸め誤差が演算を行っている浮動小数点数と同じフォーマットなので、演算にこの丸め誤差を利用することにより、非常に精度の高い演算を行うことができる。
【0013】
また、請求項3の発明は,請求項1または2に記載の数値演算プロセッサの丸め処理装置において、前記丸め誤差記憶部として、制御レジスタ部を利用したものである。
【0014】
このような手段により、制御レジスタ部に丸め誤差を記憶させることにより、記憶回りの回路を簡略化することができる。
【0015】
また、請求項4の発明は,請求項1または2に記載の数値演算プロセッサの丸め処理装置において、前記丸め部に浮動小数点数作成部と丸め誤差作成部の出力である丸め誤差を一つのデータに連結するデータパック部を備え、このデータパック部の出力を記憶する前記丸め誤差記憶部として、データレジスタ部を利用したものである。
【0016】
このような手段により、演算結果と丸め誤差をペアで、データレジスタ部に記憶させることにより、演算値と演算の結果発生した丸め誤差をペアで扱えるため、演算結果と丸め誤差を、より詳細に管理することができる。
【0017】
【発明の実施の形態】
以下、本発明の実施例を図に基づいて具体的に説明する。
[第1実施例]
図1は本発明の第1実施例を示す数値演算プロセッサの丸め処理装置のブロック図である。なお、本発明の構成要素が従来技術と同じものについては、同一符号を付してその説明を省略し、異なる点のみ説明する。
図に於いて、17は丸め誤差作成部、18は丸め誤差記憶部である。
本発明が従来技術と異なる点は、以下のとおりである。
すなわち、丸め部10において、丸め前の仮数b(S17)と丸め後の仮数d(S22)の差をとり、丸め誤差の符号と大きさをもつ丸め誤差(S23)を生成する丸め誤差作成部(17)と、丸め誤差作成部(17)の生成した丸め誤差を記憶し、演算部ストローブバス(S21)で制御され、内部データバス(S4)を介して、ホストプロセッサから記憶した丸め誤差の読み出しを、任意の時点で行える丸め誤差記憶部(18)を備えた点である。
【0018】
次に,数値演算プロセッサ3の丸め部10を用いた丸め処理について説明する

まず,浮動小数点数による演算は、図6で説明した従来例と同じであるので、正規化部9が生成した、符号b(S15)、指数b(S16)と仮数b(S17)を用いて、丸め誤差を生成し、その丸め誤差を記憶する様子を説明する。なお、丸めモードとして最近値丸めを行うものとする。
丸め計算部11では丸めモードに従い、ガードビットを含んだ仮数b(S17)に丸め処理を行い仮数d(S22)を生成する。丸め誤差作成部17では、仮数b(S17)と仮数d(S22)を用いて丸め誤差を以下のようにして作成する。まず、仮数b(S17)が、
010000000000000000000000000
の場合、下位2ビットがガードビットで、上位2ビット目と3ビット目の間に小数点がある。この事は、これ以降の説明でも同様である。この時、仮数b(S17)はガードビットが0のため、丸め処理は行われず丸め誤差としては000を生成する。仮数b(S17)が、
010000000000000000000000001
の場合、丸め処理を行った結果の仮数d(S22)は
010000000000000000000000000
であり、
000000000000000000000000001
の大きさの丸め誤差が生じている。仮数d(S22)の最下位2ビットに、仮数b>仮数dのため負を示すため最上位を1とし、丸め誤差として101を生成する。仮数b(S17)が、
010000000000000000000000010
の場合、丸め処理を行った結果の仮数d(S22)は
010000000000000000000000100
であり、
000000000000000000000000010
の大きさの丸め誤差が生じている。さらに、仮数b<仮数dのため、符号は0として、010を丸め誤差として生成する。仮数b(S17)が、
010000000000000000000000011
の場合、丸め処理を行った結果の仮数d(S22)は
010000000000000000000000100
であり、
000000000000000000000000001
の大きさの丸め誤差が生じている。さらに、仮数b<仮数dのため、符号は0として001を丸め誤差として生成する。この例では、ガードビットを2ビットで説明しているが、ガードビットのビット数を多くすると、丸め誤差の精度も向上する。例えば、ガードビットを23ビットにして、16進数で3f800001である単精度浮動小数点数の二乗を考える。仮数は、
0100000000000000000000001
であり、乗算の結果は
0100000000000000000000001000000000000000000000001
となる。丸め処理後の仮数はガードビットのビット数にかかわらず、
0100000000000000000000001
となる。符号を考えないと、ガードビットが2ビットの場合は、丸め誤差は
00
であるが、23ビットの場合は、
000000000000000000000001
となる。
【0019】
このようにして得られた丸め誤差は丸め誤差記憶部18に記憶される。マイクロプロセッサからのアクセスがあると、制御部で演算部ストローブバスS21が生成され、丸め誤差記憶部18の値が読み出される。ソフトウエアで、この読み出した丸め誤差と演算結果の指数部を利用し、IEEE754規格のフォーマットの浮動小数点数へ変換も行える。
【0020】
[第2実施例]
図2は、本発明の第2実施例を示す数値演算プロセッサの丸め処理装置のブロック図である。
図において,19は丸め誤差符号生成部、20は丸め誤差仮数生成部、21は丸め誤差指数生成部、22は丸め誤差仮数調整部、23は丸め誤差浮動小数点数作成部である。
第2実施例が第1実施例と異なる点は以下のとおりである。
すなわち、丸め誤差作成部17が丸め誤差符号生成部19、丸め誤差仮数生成部20、丸め誤差指数生成部21、丸め誤差仮数調整部22および丸め誤差浮動小数点数作成部23から構成されている点である。
ここで、丸め誤差符号生成部19は、丸め前の仮数b(S17)と丸め後の仮数d(S22)の大きさの比較から符号f(S27)を生成するものである。また、丸め誤差仮数生成部20は、丸め前の仮数b(S17)と丸め後の仮数d(S22)の差の絶対値を正規化して仮数e(S25)および正規化に伴う指数調整を行うための指数調整値(S24)とを生成する。さらに、丸め誤差指数生成部21は、指数b(S16)と指数調整値(S24)から指数f(S28)を生成し、指数b(S16)より指数調整値(S24)のほうが大きい場合に指数調整値(S24)と指数b(S16)の差から仮数調整値(S26)を生成する。
そして、丸め誤差仮数調整部(22)は、前記仮数調整値(S26)を用いて仮数e(S25)の再調整を行い仮数f(S29)を生成する。丸め誤差浮動小数点数作成部(23)は、符号f(S27)、指数f(S28)および仮数f(S29)からIEEE754規格により定義された浮動小数点数フォーマットの丸め誤差(S23)を生成するものである。なお、第2実施例の同浮動小数点数による演算は、第1実施例と同じく、図6で説明した従来例と同じである。
【0021】
次に,正規化部9が生成した、符号b(S15)、指数b(S16)と仮数b(S17)を用いて、丸め誤差を生成し、その丸め誤差を記憶する様子を説明する。丸めモードは最近値丸めとする。
丸め誤差符号生成部は、丸め前の仮数b(S17)と丸め後の仮数d(S22)の比較を行い、仮数b(S17)≦仮数d(S22)のとき正を示す0を、仮数b(S17)>仮数d(S22)のとき負を示す1を値として、符号f(S27)を生成する。丸め誤差仮数生成部は、丸め前の仮数b(S17)から丸め後の仮数d(S22)の差の絶対値をとり、仮の丸め誤差を得る。この得られた仮の丸め誤差にたいして、正規化を行い仮数e(S25)を生成する。2のn乗を掛けて仮数e(S25)を正規化するので、このnを指数調整値S24とする。例えば、仮数b(S17)を
010000000000000000000000011
仮数d(S22)を
010000000000000000000000100
とすると、丸め誤差は
000000000000000000000000001
となり、これに2の25乗を掛けると正規化された仮数e(S25)として
010000000000000000000000000
を得ることができる。この時、指数調整値は25となる。丸め誤差指生成部は、指数b(S16)から指数調整値の差をとり、指数f(S28)を生成する。指数b<指数調整値の場合には、指数f(S28)を0として、指数調整値から指数b(S16)の差を仮数調整値S26として生成する。例えば、指数b(S16)が127のとき、指数調整値が25とすると、指数f(S28)は102となる。また、指数b(S16)が20、指数調整値が25のときは、指数b<指数調整値であるため、指数f(S28)を0とし、仮数調整値は5となる。丸め誤差仮数調整部では、指数b<指数調整値の場合、仮数を調整する必要があるため、仮数f(S29)を、仮数調整値だけ左にシフトさせ仮数f(S29)を生成する。指数b≧指数調整値の場合は、仮数を調整する必要がないので仮数f(S29)は仮数e(S25)となる。丸め誤差浮動小数点数作成部では、符号f(S27)、指数f(S28)と仮数f(S29)をIEEE754規格のフォーマットにエンコードし、浮動小数点数の丸め誤差S22を作成する。例えば、仮数b(S17)を
010000000000000000000000011
仮数d(S22)を
010000000000000000000000100
とすると、指数b(S16)が127のとき、仮数b<仮数なので符号f(S27)は0となる。仮数e(S25)は
010000000000000000000000000
で、指数調整値が25のため、指数f(S28)は102となる。この時仮数調整値は0なので、仮数f(S29)は
010000000000000000000000000
となる。IEEE754フォーマットにエンコードすると
00110011000000000000000000000000
つまり16進数で33000000が丸め誤差として得られる。参考までに演算結果は、符号b(S15)が0とすると
00111111100000000000000000000001、
つまり16進数で3f800001となる。この例ではガードビットを2ビットとしているが、第1実施例と同じく、ガードビットのビット数を多くとることにより丸め誤差の精度を高くすることができる。
【0022】
[第3実施例]
図3は、本発明の第3実施例を示す数値演算プロセッサの丸め処理装置のブロック図である。
図において,24はデータパック部である。
第3実施例が丸め誤差作成部17を設ける点は,第1,第2実施例と同じであるが,丸め誤差記憶部18として、制御レジスタ部5を利用する点で異なっている。
このような構成において,丸め誤差作成部17により作成された丸め誤差S23は、制御レジスタ部5に送られ、丸め誤差が制御レジスタ部に記憶される。ホストプロセッサは、制御レジスタ部の該当部分をリードすることで丸め誤差を得ることができる。
【0023】
[第4実施例]
図4は、本発明の第4実施例を示す数値演算プロセッサの丸め処理装置のブロック図である。
第4実施例が丸め誤差作成部17を設ける点は,第1,第2実施例と同じであるが,丸め誤差記憶部18として、丸め部10に浮動小数点数作成部12と丸め誤差作成部17の出力である丸め誤差S23を一つのデータに連結するデータパック部24を備え、このデータパック部24の出力を記憶する丸め誤差記憶部18として、データレジスタ部6を利用した点で異なっている。
このような構成において,丸め誤差作成部17により作成された丸め誤差S23は、データパック部で浮動小数点数作成部12とまとめられ、内部データバスS4を通して、データレジスタ部6に転送され、演算結果と丸め誤差がペアで、データレジスタ部に記憶される。ホストプロセッサは、データレジスタ部の該当部分をリードすることで演算結果のみ、丸め誤差のみ、演算結果と丸め誤差をそれぞれ得ることができる。
【0024】
【発明の効果】
以上述べたように、請求項1に記載の数値演算プロセッサの丸め処理装置によれば、丸め誤差と演算結果を比較することによって、丸め誤差の大きさと演算結果との大小関係を取得することができる。また、丸めにより本来は捨てられるハードウェアの演算精度を、丸め誤差として取得することができる。
【0025】
請求項2に記載の数値演算プロセッサの丸め処理装置によれば、IEEE754規格のフォーマットで丸め誤差を生成させることにより、丸め誤差も浮動小数点数で統一して管理することができる。また、丸めにより、本来は捨てられるハードウェアの演算精度を、丸め誤差として取得することができる。そのため、ハードウェアの持つ演算精度をソフトウェアにも反映することができる。さらに、丸め誤差が演算を行っている浮動小数点数と同じフォーマットなので、演算にこの丸め誤差を利用することにより、非常に精度の高い演算を行うことができる。
【0026】
請求項3に記載の数値演算プロセッサの丸め処理装置によれば、制御レジスタ部に丸め誤差を記憶させることにより、記憶回りの回路を簡略化することができる。
【0027】
請求項4に記載の数値演算プロセッサの丸め処理装置によれば、演算結果と丸め誤差をペアで、データレジスタ部に記憶させることにより、演算値と演算の結果発生した丸め誤差をペアで扱えるため、演算結果と丸め誤差を、より詳細に管理することができる。
【図面の簡単な説明】
【図1】本発明の第1実施例を示す数値演算プロセッサの丸め処理装置のブロック図
【図2】本発明の第2実施例を示す数値演算プロセッサの丸め処理装置のブロック図
【図3】本発明の第3実施例を示す数値演算プロセッサの丸め処理装置のブロック図
【図4】本発明の第4実施例を示す数値演算プロセッサの丸め処理装置のブロック図
【図5】従来技術を示す数値演算プロセッサの丸め処理装置のブロック図
【図6】図5の演算部の詳細を示したブロック図
【図7】浮動小数点フォーマットを示す図
【図8】ガードビットを示す図
【符号の説明】
1 マイクロプロセッサ
2 メモリ
3 数値演算プロセッサ
4 制御部
5 制御レジスタ部
6 データレジスタ部
7 演算部
8 演算器
9 正規化部
10 丸め部
11 丸め計算部
12 浮動小数点数作成部
13 例外生成部
14 非正規化数検出部
15 指数生成部
16 仮数生成部
17 丸め誤差作成部
18 丸め誤差記憶部
19 丸め誤差符号生成部
20 丸め誤差仮数生成部
21 丸め誤差指数生成部
22 丸め誤差仮数調整部
23 丸め誤差浮動小数点数作成部
24 データパック部
S1 データバス
S2 アドレスバス
S3 ストローブバス
S4 内部データバス
S5 内部アドレスバス
S6 内部ストローブバス
S7 制御レジスタ部ストローブバス
S8 データレジスタ部ストローブバス
S9 オペコード
S10 丸めモード
S11 例外
S12 符号a
S13 指数a
S14 仮数a
S15 符号b
S16 指数b
S17 仮数b
S18 指数c
S19 仮数c
S20 非正規化数発生信号
S21 演算部ストローブバス
S22 仮数d
S23 丸め誤差
S24 指数調整値
S25 仮数e
S26 仮数調整値
S27 符号f
S28 指数f
S29 仮数f
N1 浮動小数点数
N2 符号部
N3 指数部
N4 仮数部
N5 ガードビット
[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a rounding device of a numerical processor that calculates a floating point.
[0002]
[Prior art]
First, the floating point format of the IEEE754 standard will be described with reference to FIGS. FIG. 7 is a diagram showing a floating-point format, and FIG. 8 is a diagram showing guard bits.
The floating-point number N1 is obtained by encoding the sign part N2, the exponent part N3, and the mantissa part N4 as shown in FIG. For example, in the case of single precision, the floating point number is 32 bits, the sign part is 1 bit, the exponent part is 8 bits, and the mantissa part is 23 bits. The sign part is positive or negative, the exponent part is magnitude, and the mantissa part is precision. The mantissa is
1.0 ≦ mantissa <2.0
It is normalized so that Since there is always one to the left of the decimal point, assuming that this one bit is present, the mantissa part contains the decimal to the right of the decimal point. Next, the IEEE 754 standard describes that the mantissa is calculated as having an infinite precision when performing calculations at floating point. For this purpose, an arithmetic circuit is formed by adding an extra bit called a guard bit N5 to the LSB side of the mantissa as shown in FIG. 8 to satisfy the IEEE754 standard. Therefore, it is necessary to finally perform some processing on the guard bit, which is a rounding processing.
[0003]
Next, a conventional numerical processor will be described with reference to FIGS. FIG. 5 is a block diagram of a rounding device of a numerical processor showing a conventional technique, and FIG. 6 is a block diagram showing details of a calculation unit of FIG.
In FIG. 5, 1 is a microprocessor, 2 is a memory, 3 is a numerical operation processor, 4 is a control unit, 5 is a control register unit, 6 is a data register unit, 7 is an operation unit, 8 is an operation unit, and 9 is normalization. The part 10 is a rounding part. The microprocessor 1, the memory 2, and the numerical processor 3 are connected by a data bus S1, an address bus S2, and a strobe bus S3. The numerical operation processor 3 is connected to the data bus S1 by an internal data bus S4, and a control unit 4, a control register unit 5, a data register unit 6, and an operation unit 7 provided in the processor are connected by the internal data bus S4. Each is connected. The operation unit 7 receives the data of the data register unit 6 as input, executes the operation indicated by the operation code S9, and generates a code a (S12), an exponent a (S13), and a mantissa a (S14). , The sign a (S12), the exponent a (S13) and the mantissa a (S14) are input and normalization is performed to generate the sign b (S15), the exponent b (S16) and the mantissa b (S17). It comprises a unit 9 and a rounding unit 10 which receives a sign b (S15), an exponent b (S16) and a mantissa b (S17) and performs rounding in accordance with a rounding mode S10 to generate a floating-point number as an operation result.
Since there is a possibility that a denormalized number is generated in the rounding unit 10, an exponent c (S 18), a mantissa c (S 19) and a denormalized number generation signal S 20 are generated when the denormalized number is generated. Re-enter. The arithmetic unit 8, the normalizing unit 9 and the rounding unit 10 generate an exception S11 such as overflow or inaccuracy. The internal address bus S5 connected to the address bus S2 and the internal strobe bus S6 connected to the strobe bus S3 are connected to the control unit 4. Reading and writing of data to and from the control register unit 5 for setting the operation mode and the like of the arithmetic unit 7 are controlled by the control register unit strobe bus S7. Similarly, reading and writing of data from and to the data register unit 6 serving as data of the arithmetic unit 7 are controlled by the data register unit strobe bus S8. Operations such as data input / output of the arithmetic unit 7 are controlled by the arithmetic unit strobe bus S21. In the above configuration, the numerical operation processor 3 executes the operation based on the floating-point number in the operation unit 7 using the data written in the data register unit 6 as an input, and writes the result in the data register unit 6.
[0004]
Next, the rounding unit 10 will be described with reference to FIG.
In FIG. 6, 11 is a rounding calculation unit, 12 is a floating-point number generation unit, 13 is an exception generation unit, 14 is a denormalized number detection unit, 15 is an exponent generation unit, and 16 is a mantissa generation unit.
The rounding unit 10 receives the sign b (S15), the exponent b (S16), and the mantissa b (S17) generated by the normalization unit 9. The mantissa b (S17) is input to the rounding calculator 11 and is rounded according to the rounding mode S10 to generate a mantissa d (S22).
The IEEE 754 defines four rounding modes: round-to-nearest, round toward zero, round toward positive infinity, and round toward negative infinity. The sign b (S15), the exponent b (S16), and the mantissa d (S22) are input to the floating-point number generator 12 to generate a floating-point number as a calculation result. The mantissa b (S17) is input to the exception generation unit 13, which detects an inexact exception that occurs when the rounding is performed, and generates an exception S11. The mantissa d (S22) is further input to the denormalized number detection unit 14, and checks whether or not a denormalized number has occurred after rounding, and generates a denormalized number generation signal S20. The exponent generation unit 15 receives the denormalized number generation signal S20 and the exponent b (S16) as inputs, and receives the exponent c (S18). The mantissa generation unit 16 receives the denormalized number generation signal S20 and the mantissa b (S17). Are respectively generated and input to the normalization unit 9 again. As described above, normalization and rounding are time-consuming processes, and a rounding circuit of a conventional numerical processor that improves the speed of the rounding process has been proposed (for example, see Patent Document 1).
[0005]
[Patent Document 1]
JP-A-8-202531 (specification pages 7, 10, 11; FIG. 2)
[0006]
In FIG. 2 of JP-A-8-202531, a device for rounding a solution generated during execution of a certain operation by a multi-stage execution pipeline detects when the operation is repeated and an accuracy bit associated with the solution. And a first circuit for determining whether a rounding calculation is necessary. When the first circuit detects that a rounding calculation is required, it sets a solution correction factor according to the rounding mode and the detection accuracy. In the method performed by the apparatus, the rounding of the solution that occurs during the execution of the ALU operation includes, when the operation is repeated, detecting the precision bits associated with the solution to determine whether a rounding calculation is required; When computation is required, it occurs through the step of setting a solution correction factor according to the rounding mode and the detection precision bit. Thereby, the conventional rounding circuit shortens the operation time.
[0007]
[Problems to be solved by the invention]
However, the rounding circuit of the prior art aims to reduce the processing time of the rounding process, and there is no consideration for the rounding error generated at the time of rounding, and unlike the rounding of integers and fixed points, the rounding error in the arithmetic of floating point numbers is not considered. There is a problem that the decimal point position changes. Thus, the range of values that the rounding error can take is very wide, and this becomes a problem when it is necessary to manage including the rounding error, for example, in an operation of a control system.
Next, for example, by increasing the size of the guard bit as in the case of multiplication, the operation accuracy in the operation circuit can be increased, but this operation accuracy is discarded in the rounding process.
Furthermore, since the value before rounding cannot be read out by software, there is a fundamental problem that the magnitude of the rounding error cannot be known.
[0008]
The present invention has been made to solve the above-described problem. By comparing a rounding error with a calculation result without deteriorating calculation accuracy in a calculation circuit, a magnitude relationship between the magnitude of the rounding error and the calculation result is created as a rounding error. It is another object of the present invention to provide a rounding device for a numerical processor that can convert a rounding error into a floating-point format and can smoothly use the rounding error in subsequent calculations.
[0009]
[Means for Solving the Problems]
In order to solve the above problem, the invention according to the rounding device for a numerical processor according to claim 1, performs rounding on a mantissa b generated by a normalization unit according to a rounding mode to generate a mantissa d. A floating-point number creation unit that creates an operation result from a sign b, an exponent b, and a mantissa d; an exception generation unit that creates overflow and underflow exceptions from the mantissa d; A denormalized number detecting unit for checking whether or not an unnormalized number is detected by the denormalized number detecting unit, an exponent generating unit for generating an exponent c from the mantissa d, and a mantissa c from the mantissa d. In a numerical operation processor having a rounding section composed of a mantissa generating section for generating a rounding error, a difference between a mantissa b before rounding and a mantissa d after rounding is taken to generate a rounding error having a sign and a magnitude of the rounding error. And a rounding error storage unit that stores the rounding error generated by the rounding error creating unit, is controlled by the arithmetic unit strobe bus, and can read out the stored rounding error from the host processor via the internal data bus at any time. It is a thing.
[0010]
By such a means, by comparing the rounding error with the calculation result, it is possible to obtain the magnitude relation between the magnitude of the rounding error and the calculation result.
Also, the calculation accuracy of hardware that is originally discarded by rounding can be obtained as a rounding error.
[0011]
According to a second aspect of the present invention, in the rounding device for a numerical processor according to the first aspect, the rounding error creating section generates the code f from a comparison between the magnitudes of the mantissa b before rounding and the mantissa d after rounding. And a rounding error mantissa generating unit that normalizes the absolute value of the difference between the mantissa b before rounding and the mantissa d after rounding to generate a mantissa e and an exponent adjustment value for performing exponent adjustment accompanying the normalization. A rounding error exponent generating unit that generates an exponent f from the exponent b and the exponent adjustment value, and generates a mantissa adjustment value from the difference between the exponent adjustment value and the exponent b when the exponent adjustment value is greater than the exponent b; A rounding error mantissa adjustment unit that re-adjusts the mantissa e using the adjustment value to generate a mantissa f, and a round that generates a rounding error in a floating-point number format defined by the IEEE754 standard from the sign f, the exponent f, and the mantissa f. It is those with the error floating-point number generating unit.
[0012]
By generating a rounding error in the format of the IEEE 754 standard by such means, the rounding error can be uniformly managed by a floating point number.
In addition, by rounding, the calculation accuracy of hardware that is originally discarded can be obtained as a rounding error. Therefore, the calculation accuracy of the hardware can be reflected on the software.
Furthermore, since the rounding error has the same format as the floating-point number on which the operation is being performed, an extremely accurate operation can be performed by using the rounding error in the operation.
[0013]
According to a third aspect of the present invention, in the rounding device for a numerical processor according to the first or second aspect, a control register unit is used as the rounding error storage unit.
[0014]
By storing the rounding error in the control register section by such means, a circuit around storage can be simplified.
[0015]
According to a fourth aspect of the present invention, in the rounding device for a numerical processor according to the first or second aspect, the rounding error output from the floating-point number generating section and the rounding error generating section is connected to the rounding section into one data. A data register unit is used as the rounding error storage unit for storing the output of the data pack unit.
[0016]
By storing the operation result and the rounding error in a pair in the data register unit by such means, the operation result and the rounding error generated as a result of the operation can be handled in a pair, so that the operation result and the rounding error can be managed in more detail. Can be.
[0017]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, embodiments of the present invention will be specifically described with reference to the drawings.
[First embodiment]
FIG. 1 is a block diagram of a rounding device for a numerical processor according to a first embodiment of the present invention. Note that the same components as those of the related art are denoted by the same reference numerals and the description thereof will be omitted, and only different points will be described.
In the figure, reference numeral 17 denotes a rounding error creating unit, and reference numeral 18 denotes a rounding error storage unit.
The differences between the present invention and the prior art are as follows.
That is, the rounding unit 10 calculates the difference between the mantissa b (S17) before rounding and the mantissa d (S22) after rounding, and generates a rounding error (S23) having the sign and magnitude of the rounding error (17). And the rounding error generated by the rounding error generating unit (17) is stored, and the rounding error stored by the host processor is controlled by the arithmetic unit strobe bus (S21) via the internal data bus (S4) at any time. In that a rounding error storage section (18) that can be used in the above is provided.
[0018]
Next, a rounding process using the rounding unit 10 of the numerical processor 3 will be described.
.
First, the operation by the floating-point number is the same as that of the conventional example described with reference to FIG. 6, so that the sign b (S15), the exponent b (S16) and the mantissa b (S17) generated by the normalization unit 9 are used. , Generating a rounding error and storing the rounding error will be described. Note that the nearest value rounding is performed as the rounding mode.
The rounding calculation unit 11 performs a rounding process on the mantissa b (S17) including the guard bit according to the rounding mode to generate a mantissa d (S22). The rounding error creating unit 17 creates a rounding error using the mantissa b (S17) and the mantissa d (S22) as follows. First, the mantissa b (S17) is
01000000000000000000000000000
In the case of, the lower 2 bits are guard bits and there is a decimal point between the upper 2nd bit and the 3rd bit. This is the same in the following description. At this time, since the mantissa b (S17) has a guard bit of 0, the rounding process is not performed and 000 is generated as a rounding error. The mantissa b (S17) is
000000000000000000000000000001
In the case of, the mantissa d (S22) resulting from the rounding process is
01000000000000000000000000000
And
00000000000000000000000000010001
Rounding error occurs. In the least significant 2 bits of the mantissa d (S22), since the mantissa b> mantissa d indicates negative, the most significant bit is set to 1 and 101 is generated as a rounding error. The mantissa b (S17) is
0100000000000000000000000000010
In the case of, the mantissa d (S22) resulting from the rounding process is
0100000000000000000000000000100
And
0000000000000000000000000000010
Rounding error occurs. Further, since mantissa b <mantissa d, the sign is set to 0 and 010 is generated as a rounding error. The mantissa b (S17) is
000000000000000000000000000011
In the case of, the mantissa d (S22) resulting from the rounding process is
0100000000000000000000000000100
And
00000000000000000000000000010001
Rounding error occurs. Further, since the mantissa b <the mantissa d, the sign is set to 0 and 001 is generated as a rounding error. In this example, the guard bit is described as two bits. However, if the number of guard bits is increased, the accuracy of the rounding error is improved. For example, consider the square of a single-precision floating-point number that is 3f800001 in hexadecimal with guard bits being 23 bits. The mantissa is
0100000000000000000000000001
And the result of the multiplication is
01000000000000000000000000000000000000000000000000001
It becomes. Regarding the mantissa after rounding, regardless of the number of guard bits,
0100000000000000000000000001
It becomes. Without considering the sign, if the guard bit is 2 bits, the rounding error is
00
, But in the case of 23 bits,
0000000000000000000000000001
It becomes.
[0019]
The rounding error thus obtained is stored in the rounding error storage unit 18. When there is access from the microprocessor, the control unit generates the arithmetic unit strobe bus S21, and the value of the rounding error storage unit 18 is read. By using the read-out rounding error and the exponent part of the operation result, software can also convert the data into a floating-point number in the IEEE754 standard format.
[0020]
[Second embodiment]
FIG. 2 is a block diagram of a rounding device of a numerical processor according to a second embodiment of the present invention.
In the figure, 19 is a rounding error code generator, 20 is a rounding error mantissa generating unit, 21 is a rounding error exponent generating unit, 22 is a rounding error mantissa adjusting unit, and 23 is a rounding error floating point number generating unit.
The differences between the second embodiment and the first embodiment are as follows.
That is, the rounding error generator 17 is composed of a rounding error code generator 19, a rounding error mantissa generating unit 20, a rounding error exponent generating unit 21, a rounding error mantissa adjusting unit 22, and a rounding error floating point number generating unit 23.
Here, the rounding error code generation unit 19 generates a code f (S27) by comparing the magnitudes of the mantissa b (S17) before rounding and the mantissa d (S22) after rounding. In addition, the rounding error mantissa generating unit 20 normalizes the absolute value of the difference between the mantissa b (S17) before rounding and the mantissa d (S22) after rounding to adjust the mantissa e (S25) and the exponent accompanying the normalization. And an index adjustment value (S24). Further, the rounding error index generation unit 21 generates an index f (S28) from the index b (S16) and the index adjustment value (S24), and adjusts the index when the index adjustment value (S24) is larger than the index b (S16). A mantissa adjustment value (S26) is generated from the difference between the value (S24) and the index b (S16).
Then, the rounding error mantissa adjusting unit (22) re-adjusts the mantissa e (S25) using the mantissa adjustment value (S26) to generate a mantissa f (S29). The rounding error floating point generator (23) generates a rounding error (S23) in a floating point format defined by the IEEE754 standard from the sign f (S27), the exponent f (S28) and the mantissa f (S29). . The operation using the same floating-point number in the second embodiment is the same as that in the conventional example described with reference to FIG. 6, as in the first embodiment.
[0021]
Next, how the rounding error is generated using the code b (S15), exponent b (S16), and mantissa b (S17) generated by the normalizing unit 9 and how the rounding error is stored will be described. The rounding mode is the nearest round.
The rounding error code generation unit compares the mantissa b (S17) before the rounding with the mantissa d (S22) after the rounding, and when the mantissa b (S17) ≦ the mantissa d (S22), 0 indicating a positive value is added to the mantissa b ( If S17)> mantissa d (S22), sign f (S27) is generated with 1 indicating a negative value as a value. The rounding error mantissa generating unit obtains the absolute value of the difference between the mantissa b (S17) before rounding and the mantissa d (S22) after rounding to obtain a temporary rounding error. The obtained provisional rounding error is normalized to generate a mantissa e (S25). Since the mantissa e (S25) is normalized by multiplying by 2 to the power of n, this n is set as an exponent adjustment value S24. For example, the mantissa b (S17) is
000000000000000000000000000011
The mantissa d (S22)
0100000000000000000000000000100
Then the rounding error is
00000000000000000000000000010001
This is multiplied by 2 to the power of 25 to obtain a normalized mantissa e (S25).
01000000000000000000000000000
Can be obtained. At this time, the index adjustment value is 25. The rounding error finger generation unit calculates the difference between the index adjustment values from the index b (S16) and generates an index f (S28). If the index b <the index adjustment value, the index f (S28) is set to 0, and the difference of the index b (S16) from the index adjustment value is generated as the mantissa adjustment value S26. For example, when the index adjustment value is 25 when the index b (S16) is 127, the index f (S28) is 102. When the index b (S16) is 20 and the index adjustment value is 25, since the index b <the index adjustment value, the index f (S28) is set to 0 and the mantissa adjustment value is set to 5. The rounding error mantissa adjusting unit shifts the mantissa f (S29) to the left by the mantissa adjustment value to generate the mantissa f (S29) because the mantissa needs to be adjusted when the exponent b <the exponent adjustment value. When exponent b ≧ exponential adjustment value, it is not necessary to adjust the mantissa, so mantissa f (S29) becomes mantissa e (S25). The rounding error floating point number creation unit encodes the sign f (S27), the exponent f (S28), and the mantissa f (S29) into the format of the IEEE754 standard, and creates a rounding error S22 of the floating point number. For example, the mantissa b (S17) is
000000000000000000000000000011
The mantissa d (S22)
0100000000000000000000000000100
Then, when the exponent b (S16) is 127, the sign f (S27) becomes 0 because the mantissa b <mantissa. The mantissa e (S25) is
01000000000000000000000000000
Since the index adjustment value is 25, the index f (S28) is 102. At this time, since the mantissa adjustment value is 0, the mantissa f (S29) is
01000000000000000000000000000
It becomes. When encoding to IEEE 754 format
001100111000000000000000000000000000
That is, 33300000 in hexadecimal is obtained as a rounding error. For reference, the calculation result is assuming that the code b (S15) is 0.
0011111110000000000000000000000001,
That is, it becomes 3f800001 in hexadecimal. In this example, the guard bits are two bits. However, as in the first embodiment, the precision of the rounding error can be increased by increasing the number of guard bits.
[0022]
[Third embodiment]
FIG. 3 is a block diagram of a rounding device for a numerical processor according to a third embodiment of the present invention.
In the figure, reference numeral 24 denotes a data pack unit.
The third embodiment is the same as the first and second embodiments in that a rounding error creating unit 17 is provided, but differs in that a control register unit 5 is used as a rounding error storage unit 18.
In such a configuration, the rounding error S23 created by the rounding error creating unit 17 is sent to the control register unit 5, and the rounding error is stored in the control register unit. The host processor can obtain a rounding error by reading the corresponding portion of the control register section.
[0023]
[Fourth embodiment]
FIG. 4 is a block diagram of a rounding device for a numerical processor according to a fourth embodiment of the present invention.
The fourth embodiment is the same as the first and second embodiments in that a rounding error generator 17 is provided. However, as a rounding error storage unit 18, the output of the floating point number generator 12 and the output of the rounding error generator 17 are provided to the rounding unit 10. This is different from the first embodiment in that the data register unit 6 is used as a rounding error storage unit 18 that stores the output of the data packing unit 24, and a data pack unit 24 that connects the rounding error S23 to one data.
In such a configuration, the rounding error S23 created by the rounding error creating unit 17 is combined with the floating-point number creating unit 12 by the data pack unit, transferred to the data register unit 6 via the internal data bus S4, and the calculation result and the rounding error Are paired and stored in the data register section. The host processor can obtain only the operation result, only the rounding error, and the operation result and the rounding error by reading the corresponding portion of the data register section.
[0024]
【The invention's effect】
As described above, according to the rounding device of the numerical processor according to the first aspect, by comparing the rounding error with the calculation result, it is possible to obtain the magnitude relationship between the magnitude of the rounding error and the calculation result. Also, the calculation accuracy of hardware that is originally discarded by rounding can be obtained as a rounding error.
[0025]
According to the rounding device of the numerical processor according to the second aspect, by generating the rounding error in the format of the IEEE754 standard, the rounding error can be uniformly managed by the floating point number. In addition, by rounding, the calculation accuracy of hardware that is originally discarded can be obtained as a rounding error. Therefore, the calculation accuracy of the hardware can be reflected on the software. Furthermore, since the rounding error has the same format as the floating-point number on which the operation is being performed, an extremely accurate operation can be performed by using the rounding error in the operation.
[0026]
According to the rounding device of the numerical processor according to the third aspect, by storing the rounding error in the control register section, the circuit around the storage can be simplified.
[0027]
According to the rounding device of the numerical processor according to the fourth aspect, the arithmetic result and the rounding error generated as a result of the arithmetic can be handled as a pair by storing the arithmetic result and the rounding error in a pair in the data register section. Results and rounding errors can be managed in more detail.
[Brief description of the drawings]
FIG. 1 is a block diagram of a rounding device of a numerical processor showing a first embodiment of the present invention;
FIG. 2 is a block diagram of a rounding device of a numerical processor showing a second embodiment of the present invention;
FIG. 3 is a block diagram of a rounding device of a numerical processor showing a third embodiment of the present invention;
FIG. 4 is a block diagram of a rounding device of a numerical processor according to a fourth embodiment of the present invention;
FIG. 5 is a block diagram of a rounding device of a numerical processor showing a conventional technique.
FIG. 6 is a block diagram showing details of a calculation unit in FIG. 5;
FIG. 7 is a diagram showing a floating-point format.
FIG. 8 is a diagram showing guard bits.
[Explanation of symbols]
1 Microprocessor
2 memory
3 Numerical processor
4 control unit
5 Control register section
6 Data register section
7 Operation part
8 arithmetic unit
9 Normalization part
10 Rounding part
11 Rounding calculation unit
12 Floating point generator
13 Exception generator
14 Denormalized number detector
15 exponent generator
16 Mantissa generator
17 Rounding error generator
18 Rounding error storage unit
19 Rounding error code generator
20 Rounding error mantissa generator
21 Rounding error exponent generator
22 Rounding error mantissa adjustment unit
23 Rounding error floating point generator
24 Data pack section
S1 data bus
S2 address bus
S3 strobe bath
S4 Internal data bus
S5 Internal address bus
S6 Internal strobe bus
S7 Control register section strobe bus
S8 Data register section strobe bus
S9 operation code
S10 Rounding mode
S11 exception
S12 code a
S13 index a
S14 Mantissa a
S15 code b
S16 index b
S17 Mantissa b
S18 index c
S19 Mantissa c
S20 Denormalized number generation signal
S21 Operation unit strobe bus
S22 Mantissa d
S23 Rounding error
S24 Index adjustment value
S25 Mantissa e
S26 Mantissa adjustment value
S27 code f
S28 index f
S29 Mantissa f
N1 floating point number
N2 code part
N3 index part
N4 mantissa
N5 guard bit

Claims (4)

丸めモードに従って、正規化部(9)で生成された仮数b(S17)に丸めを行い、仮数d(S22)を生成する丸め計算部(11)と、
符号b(S15)、指数b(S16)および仮数d(S22)から演算結果を作成する浮動小数点数作成部(12)と、
前記仮数d(S22)からオーバーフローとアンダーフローの例外を作成する例外生成部(13)と、
前記仮数d(S22)が非正規化数かどうかを検査する非正規化数検出部(14)と、
前記非正規化数検出部(14)で非正規化数を検出した場合、前記仮数d(S22)から指数c(S18)を生成する指数生成部(15)と、
前記仮数d(S22)から仮数c(S19)を生成する仮数生成部(16)より構成される丸め部(10)を備えた数値演算プロセッサ(3)において、
丸め前の仮数b(S17)と丸め後の仮数d(S22)の差をとり、丸め誤差の符号と大きさをもつ丸め誤差(S23)を生成する丸め誤差作成部(17)と、
前記丸め誤差作成部(17)の生成した丸め誤差を記憶し、演算部ストローブバス(S21)で制御され、内部データバス(S4)を介して、ホストプロセッサから記憶した丸め誤差の読み出しを、任意の時点で行える丸め誤差記憶部(18)を備えることを特徴とする数値演算プロセッサの丸め処理装置。
A rounding calculation unit (11) that rounds the mantissa b (S17) generated by the normalization unit (9) according to the rounding mode and generates a mantissa d (S22);
A floating-point number creation unit (12) for creating an operation result from the sign b (S15), the exponent b (S16), and the mantissa d (S22);
An exception generation unit (13) for generating overflow and underflow exceptions from the mantissa d (S22);
A denormalized number detector (14) for checking whether the mantissa d (S22) is a denormalized number,
An exponent generation unit (15) that generates an exponent c (S18) from the mantissa d (S22) when the denormalized number detection unit (14) detects a denormalized number;
In a numerical processor (3) including a rounding section (10) including a mantissa generating section (16) for generating a mantissa c (S19) from the mantissa d (S22),
A rounding error creating unit (17) that calculates a difference between the mantissa b (S17) before rounding and the mantissa d (S22) after rounding and generates a rounding error (S23) having the sign and magnitude of the rounding error;
The rounding error generated by the rounding error creating unit (17) is stored, controlled by the arithmetic unit strobe bus (S21), and the stored rounding error is read from the host processor via the internal data bus (S4) at any time. A rounding processor for a numerical processor, comprising a rounding error storage unit (18) capable of performing the rounding.
前記丸め誤差作成部(17)は,丸め前の仮数b(S17)と丸め後の仮数d(S22)の大きさの比較から符号f(S27)を生成する丸め誤差符号生成部(19)と、
丸め前の仮数b(S17)と丸め後の仮数d(S22)の差の絶対値を正規化して仮数e(S25)および正規化に伴う指数調整を行うための指数調整値(S24)とを生成する丸め誤差仮数生成部(20)と、
指数b(S16)と指数調整値(S24)から指数f(S28)を生成し、指数b(S16)より指数調整値(S24)のほうが大きい場合に指数調整値(S24)と指数b(S16)の差から仮数調整値(S26)を生成する丸め誤差指数生成部(21)と、
前記仮数調整値(S26)を用いて仮数e(S25)の再調整を行い仮数f(S29)を生成する丸め誤差仮数調整部(22)と、
符号f(S27)、指数f(S28)および仮数f(S29)からIEEE754規格により定義された浮動小数点数フォーマットの丸め誤差(S23)を生成する丸め誤差浮動小数点数作成部(23)を備えることを特徴とする請求項1記載の数値演算プロセッサの丸め処理装置。
A rounding error code generation unit (19) configured to generate a code f (S27) from a comparison between the magnitude of the mantissa b (S17) before rounding and the size of the mantissa d (S22) after rounding;
The absolute value of the difference between the mantissa b (S17) before rounding and the mantissa d (S22) after rounding is normalized to obtain a mantissa e (S25) and an exponent adjustment value (S24) for performing exponent adjustment accompanying normalization. A rounding error mantissa generating unit (20) to be generated;
An index f (S28) is generated from the index b (S16) and the index adjustment value (S24). If the index adjustment value (S24) is larger than the index b (S16), the index adjustment value (S24) and the index b (S16) are generated. ), A rounding error exponent generator (21) that generates a mantissa adjustment value (S26) from the difference
A rounding error mantissa adjusting unit (22) for re-adjusting the mantissa e (S25) using the mantissa adjustment value (S26) and generating a mantissa f (S29);
A rounding error floating point number generating unit (23) for generating a rounding error (S23) in a floating point number format defined by the IEEE 754 standard from the sign f (S27), the exponent f (S28) and the mantissa f (S29). 2. The rounding device for a numerical processor according to claim 1, wherein
前記丸め誤差記憶部(18)として、制御レジスタ部(5)を利用したことを特徴とする請求項1または2に記載の数値演算プロセッサの丸め処理装置。3. A rounding device for a numerical processor according to claim 1, wherein a control register unit (5) is used as said rounding error storage unit (18). 前記丸め部(10)に浮動小数点数作成部(12)と丸め誤差作成部(17)の出力である丸め誤差(S23)を一つのデータに連結するデータパック部(24)を備え、このデータパック部(24)の出力を記憶する前記丸め誤差記憶部(18)として、データレジスタ部(6)を利用したことを特徴とする請求項1または2に記載の数値演算プロセッサの丸め処理装置。The rounding section (10) includes a data pack section (24) for linking the rounding error (S23) output from the floating point number generating section (12) and the rounding error generating section (17) into one data. 3. The rounding processing device for a numerical processor according to claim 1, wherein a data register section (6) is used as the rounding error storage section (18) for storing the output of (24).
JP2003039702A 2003-02-18 2003-02-18 Rounding processing device of numerical coprocessor Pending JP2004252554A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003039702A JP2004252554A (en) 2003-02-18 2003-02-18 Rounding processing device of numerical coprocessor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003039702A JP2004252554A (en) 2003-02-18 2003-02-18 Rounding processing device of numerical coprocessor

Publications (1)

Publication Number Publication Date
JP2004252554A true JP2004252554A (en) 2004-09-09

Family

ID=33023809

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003039702A Pending JP2004252554A (en) 2003-02-18 2003-02-18 Rounding processing device of numerical coprocessor

Country Status (1)

Country Link
JP (1) JP2004252554A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007188424A (en) * 2006-01-16 2007-07-26 Hitachi Ltd Computing device, computing method, and computing program

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007188424A (en) * 2006-01-16 2007-07-26 Hitachi Ltd Computing device, computing method, and computing program
JP4490925B2 (en) * 2006-01-16 2010-06-30 株式会社日立製作所 Calculation device, calculation method, and calculation program

Similar Documents

Publication Publication Date Title
US9841948B2 (en) Microarchitecture for floating point fused multiply-add with exponent scaling
US5357237A (en) In a data processor a method and apparatus for performing a floating-point comparison operation
US11347511B2 (en) Floating-point scaling operation
US7346643B1 (en) Processor with improved accuracy for multiply-add operations
JP2557190B2 (en) Optimization system for argument reduction
US20130246496A1 (en) Floating-point vector normalisation
JP3178746B2 (en) Format converter for floating point numbers
JPH0544046B2 (en)
EP0596175A1 (en) Apparatus for executing the argument reduction in exponential computations of IEEE standard floating-point numbers
EP3365771B1 (en) Apparatus for calculating and retaining a bound on error during floating point operations and methods thereof
KR100465371B1 (en) apparatus and method for design of the floating point ALU performing addition and round operations in parallel
JPH09212337A (en) Floating-point arithmetic processor
US7752250B2 (en) Rounding floating point division results
US6233595B1 (en) Fast multiplication of floating point values and integer powers of two
JP2007515021A (en) Floating point arithmetic with scaled integers
Tsen et al. A combined decimal and binary floating-point multiplier
EP0738959A1 (en) Method and apparatus for finding arctangents
JP2004252554A (en) Rounding processing device of numerical coprocessor
US20220137925A1 (en) Device and method for hardware-efficient adaptive calculation of floating-point trigonometric functions using coordinate rotate digital computer (cordic)
US8250126B2 (en) Efficient leading zero anticipator
CN114691082A (en) Multiplier circuit, chip, electronic device, and computer-readable storage medium
KR20150107614A (en) A data processing apparatus and method for performing a shift function on a binary number
US7899859B2 (en) Efficient error-check and exact-check for Newton-Raphson divide and square-root operations
JP3257278B2 (en) Normalizer using redundant shift number prediction and shift error correction
JP4109181B2 (en) Logic circuit, and floating-point arithmetic circuit and microprocessor using the same