JP2509279B2 - Floating point number-fixed point number converter - Google Patents

Floating point number-fixed point number converter

Info

Publication number
JP2509279B2
JP2509279B2 JP63033102A JP3310288A JP2509279B2 JP 2509279 B2 JP2509279 B2 JP 2509279B2 JP 63033102 A JP63033102 A JP 63033102A JP 3310288 A JP3310288 A JP 3310288A JP 2509279 B2 JP2509279 B2 JP 2509279B2
Authority
JP
Japan
Prior art keywords
point number
output
cycle
shift
bit
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.)
Expired - Fee Related
Application number
JP63033102A
Other languages
Japanese (ja)
Other versions
JPH01207823A (en
Inventor
久義 蔵屋
茂人 田中
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.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
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 Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP63033102A priority Critical patent/JP2509279B2/en
Publication of JPH01207823A publication Critical patent/JPH01207823A/en
Application granted granted Critical
Publication of JP2509279B2 publication Critical patent/JP2509279B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Description

【発明の詳細な説明】 〔概要〕 ディジタル信号を浮動小数点数処理から固定小数点数
処理にフォーマット変換する装置に関し、 IEEE標準浮動小数点数を、丸め処理及びオーバーフロ
ー処理を行って固定小数点数に変換することにより変換
の演算精度を上げることを目的とし、 1サイクル目にIEEE標準浮動小数点数の2の補数化信
号を生成してアキュムレータに格納し、2サイクル目に
該アキュムレータの該データをシフト計算部で求めたシ
フト数及び方向だけバレルシフタ回路でシフトし、この
シフトの際にオーバーフローが生じた時はクリップ部で
クリップしてアキュムレータに再度格納し、3サイクル
目では、2サイクル目でバレルシフタ回路がキャリイ検
出していた場合には2サイクル目のアキュムレータのデ
ータにそのキャリイビットが付加されて最終的な固定小
数点数としてアキュムレータに格納されるように構成し
たもの。
The present invention relates to a device for converting the format of a digital signal from floating-point number processing to fixed-point number processing, and converts an IEEE standard floating-point number into a fixed-point number by performing rounding processing and overflow processing. Therefore, in order to improve the calculation accuracy of the conversion, a two's complement signal of the IEEE standard floating point number is generated and stored in the accumulator in the first cycle, and the data in the accumulator is shifted in the second cycle. The barrel shifter circuit shifts only the number of shifts and the direction determined in step 3. If an overflow occurs during this shift, the clip is clipped by the clip part and stored again in the accumulator. In the third cycle, the barrel shifter circuit is carried in the second cycle. If it is detected, the carry bit is added to the data of the accumulator in the second cycle. Those There was configured to be stored in the appended with an accumulator as a final fixed point number.

〔産業上の利用分野〕[Industrial applications]

本発明は浮動小数点数−固定小数点数変換装置に関す
るものであり、特にディジタル信号を浮動小数点数処理
から固定小数点数処理にフォーマット変換する装置に関
するものである。
The present invention relates to a floating-point number-to-fixed-point number conversion device, and more particularly to a device for converting the format of a digital signal from floating-point number processing to fixed-point number processing.

浮動小数点数の処理は、ディジタル信号処理の精度が
高くまたダイナミックレンジも広い等の点から固定小数
点数処理よりも好ましいが、回路制御等においては固定
小数点数を用いて処理されることが多いため、浮動小数
点数から固定小数点数にフォーマット変換することが必
要である。
Floating-point number processing is preferable to fixed-point number processing in terms of high precision of digital signal processing and wide dynamic range, but fixed-point number processing is often used in circuit control and the like. , It is necessary to convert the format from floating point number to fixed point number.

〔従来の技術〕[Conventional technology]

IEEE標準32ビット浮動小数点数は、第10図に示す表現
形式を有し、指数部eは真値に127を加えた所謂「ゲタ
ばき」表面を採用し、仮数部fは1から2の間の数を表
現する符号絶対値表現を採用している。また、その絶対
値表現部fでは最上位ビット(正規化数の場合常に1)
を省略した所謂「かくれ」ビット表現を採用している。
また、MSBの符号ビットをSで表すと、浮動小数点数デ
ータXは、 X=(−1){2e-127}(1.f) で表される。
The IEEE standard 32-bit floating point number has the representation format shown in FIG. 10, the exponent part e adopts a so-called “gettering” surface in which 127 is added to the true value, and the mantissa part f is from 1 to 2. The sign absolute value expression that expresses the number between is adopted. In the absolute value expression part f, the most significant bit (always 1 in the case of a normalized number)
The so-called "hidden" bit representation that omits is used.
Further, when the sign bit of the MSB is represented by S, the floating point number data X is represented by X = (− 1) s {2 e-127 } (1.f).

この場合、従来の浮動小数点数−固定小数点数変換で
は、固定小数点の小数点位置が、データの最下位ビット
にあり、実質的に整数変換を意味するように変換されて
いた。
In this case, in the conventional floating-point number-to-fixed-point number conversion, the decimal point position of the fixed-point is at the least significant bit of the data, and the conversion is performed so as to substantially mean integer conversion.

〔発明が解決しようとする課題〕[Problems to be Solved by the Invention]

従来の浮動小数点数−固定小数点数変換は、IEEE標準
32ビットの浮動小数点数を扱ったものではなく、然もそ
の変換の際のビットの桁落ちは無視、即ち切り捨てられ
ていて丸め処理が行われていなかった。更に、オーバー
フロー処理も同様に行われておらず、演算精度の低下を
招く虞があった。
Traditional floating-point-to-fixed-point number conversion is an IEEE standard
It did not deal with 32-bit floating point numbers, and the precision of bit conversion during the conversion was ignored, that is, it was truncated and rounding was not performed. Furthermore, overflow processing is not performed in the same manner, which may lead to a decrease in calculation accuracy.

従って、本発明は、IEEE標準浮動小数点数を、丸め処
理及びオーバーフロー処理を行って固定小数点数に変換
し、その演算精度を上げることを目的とする。
Therefore, it is an object of the present invention to convert an IEEE standard floating point number into a fixed point number by performing rounding processing and overflow processing to improve the calculation accuracy.

〔課題を解決するための手段〕[Means for solving the problem]

第1図は、上記の目的を達成するための本発明に係る
浮動小数点数−固定小数点数変換装置の概念図を示し、
図中、1はアキュムレータ7に格納されたIEEE標準浮動
小数点数を、その符号ビットに合わせてフォーマット変
換する変換部、2は変換部1の出力と該符号を示すビッ
トにより2の補数化信号を発生する加算器、3は該浮動
小数点数の指数部からシフト数及びシフト方向を発生す
るシフト計算部、4は該シフト数及びシフト方向により
該浮動小数点数をシフトするバレルシフタ回路、5は加
算器2の出力又はバレルシフタ回路4の出力を選択する
選択器、6はバレルシフタ回路4がオーバーフローした
時のみ選択器5の出力をクリップしてアキュムレータ7
に与えるクリップ部、そして8は1サイクル目に該浮動
小数点数の符号ビットに応じて変換部1に制御信号を与
え、2サイクル目にシフト計算部3のラッチされた値を
出力させ、1サイクル目及び3サイクル目に加算器2の
出力を、2サイクル目にバレルシフタ回路4の出力をそ
れぞれ選択するように選択器5を制御し、バレルシフタ
回路4がキャリイ検出した時、3サイクル目に該キャリ
イ信号に基づいて加算器2に丸め信号を与える演算制御
部である。
FIG. 1 is a conceptual diagram of a floating point number-fixed point number converter according to the present invention for achieving the above object.
In the figure, 1 is a conversion unit for converting the format of an IEEE standard floating point number stored in an accumulator 7 according to its sign bit, 2 is a 2's complemented signal by the output of the conversion unit 1 and the bit indicating the sign. An adder that generates 3 is a shift calculator that generates a shift number and a shift direction from an exponent part of the floating point number, 4 is a barrel shifter circuit that shifts the floating point number according to the shift number and the shift direction, and 5 is an adder. A selector for selecting the output of 2 or the output of the barrel shifter circuit 4, and 6 for clipping the output of the selector 5 only when the barrel shifter circuit 4 overflows.
And the clip section 8 gives a control signal to the conversion section 1 according to the sign bit of the floating point number in the first cycle and outputs the latched value of the shift calculation section 3 in the second cycle. The selector 5 is controlled to select the output of the adder 2 in the third cycle and the output of the barrel shifter circuit 4 in the second cycle, and when the barrel shifter circuit 4 detects a carry, the carry is detected in the third cycle. It is an arithmetic control unit that gives a rounding signal to the adder 2 based on the signal.

〔作用〕[Action]

第1図に示した本発明に係る浮動小数点数−固定小数
点数変換装置を第2図乃至第4図に示したビット状態図
を参照して以下に説明する。
The floating point number-fixed point number converter according to the present invention shown in FIG. 1 will be described below with reference to the bit state diagrams shown in FIGS. 2 to 4.

まず、第2図(1)又は第3図(1)に示すようなア
キュムレータ7に格納されているIEEE標準浮動小数点数
が変換部1に送られ、その指数部がシフト計算部3に送
られる。また、浮動小数点数の符号ビットは演算制御部
8に送られる。演算制御部8では入力した符号ビットが
“0"(正の小数点数)であるか、“1"(負の小数点数)
であるかを判定して制御信号を変換部1へ送る。変換部
1では、この制御信号により浮動小数点数を第4図
(a)又は(b)に示すようにフォーマット変換する。
この場合、符号ビットが“1"の時には第3図(2)に示
すように仮数部の反転も行われる。
First, the IEEE standard floating-point number stored in the accumulator 7 as shown in FIG. 2 (1) or FIG. 3 (1) is sent to the conversion unit 1, and its exponent part is sent to the shift calculation unit 3. . Further, the sign bit of the floating point number is sent to the arithmetic control unit 8. In the arithmetic control unit 8, whether the input sign bit is "0" (positive decimal point number) or "1" (negative decimal point number)
Then, the control signal is sent to the conversion unit 1. The converter 1 converts the floating-point number into a format as shown in FIG. 4A or 4B by this control signal.
In this case, when the sign bit is "1", the mantissa part is also inverted as shown in FIG.

このフォーマット変換された浮動小数点数は加算器2
において演算制御部8からの符号ビットの値を加算する
ことによって第2図(2)及び第3図(3)に示すよう
に2の補数表現化されたビット値が得られ、選択器5に
送られる。選択器5は1サイクル目は加算器2の出力が
選択されるように演算制御部8によって制御され、クリ
ップ部6を介してアキュムレータ7に格納される。
This format-converted floating point number is added by adder 2
In (2) and (3) in FIG. 2, a bit value represented in 2's complement representation is obtained by adding the values of the sign bits from the operation control unit 8, and the selector 5 Sent. The selector 5 is controlled by the arithmetic control unit 8 so that the output of the adder 2 is selected in the first cycle, and is stored in the accumulator 7 via the clip unit 6.

一方、上記の1サイクル目では、シフト計算部3で
は、アキュムレータ7の浮動小数点数の指数部からシフ
ト数とシフト方向を求めてラッチしておく。
On the other hand, in the first cycle, the shift calculation unit 3 obtains the shift number and the shift direction from the exponent part of the floating point number of the accumulator 7 and latches them.

2サイクル目では、演算制御部8がシフト計算部3に
ラッチされていたシフト数及びシフト方向の値をバレル
シフタ回路4に出力させ、バレルシフタ回路4では、1
サイクル目でアキュムレータ7に格納されている第2図
(2)又は第3図(3)に示すビット値をそのまま入力
して指定されたシフト方向にそのシフト数だけシフトす
る。そのシフトされた値が第2図(3)又は第3図
(4)に示されている。2サイクル目では、演算制御部
8が選択器5を制御してバレルシフタ回路4の出力を選
択するので、このシフトされた値はクリップ部6に送ら
れる。クリップ部6では、上記のシフト動作において、
オーバーフロー検出が為された時には、演算制御部8は
クリップ部6を制御して正又は負の最大値に選択器5の
出力をクリップしてアキュムレータ7に格納する。
In the second cycle, the arithmetic control unit 8 outputs the number of shifts and the value in the shift direction latched by the shift calculation unit 3 to the barrel shifter circuit 4, and the barrel shifter circuit 4 outputs 1
At the second cycle, the bit values shown in FIG. 2 (2) or FIG. 3 (3) stored in the accumulator 7 are input as they are and shifted by the number of shifts in the designated shift direction. The shifted value is shown in FIG. 2 (3) or FIG. 3 (4). In the second cycle, the arithmetic control unit 8 controls the selector 5 to select the output of the barrel shifter circuit 4, so that this shifted value is sent to the clip unit 6. In the clip portion 6, in the above shift operation,
When the overflow is detected, the arithmetic control unit 8 controls the clipping unit 6 to clip the output of the selector 5 to the maximum positive or negative value and store it in the accumulator 7.

そして、3サイクル目では、2サイクル目でバレルシ
フタ回路4がキャリイ検出した時の信号により加算器2
にキャリイ信号として与え、アキュムレータ7から出力
された2サイクル目のビット値は変換部1を通過して加
算器2でキャリイビットが加算され、選択器5及びクリ
ップ部6を介してアキュムレータ7に最終的な固定小数
点数として格納されることになる。
Then, in the third cycle, the adder 2 is generated by the signal when the barrel shifter circuit 4 detects the carry in the second cycle.
To the accumulator 7, the bit value of the second cycle output from the accumulator 7 passes through the conversion unit 1, the carry bit is added in the adder 2, and the final value is added to the accumulator 7 via the selector 5 and the clip unit 6. Will be stored as a fixed-point number.

〔実 施 例〕〔Example〕

以下、本願発明に係る浮動小数点数−固定小数点数変
換装置の実施例を説明する。
An embodiment of the floating point number-fixed point number conversion device according to the present invention will be described below.

第5図は、本発明に係る浮動小数点数−固定小数点数
変換装置の一実施例を示している。
FIG. 5 shows an embodiment of the floating point number-fixed point number converter according to the present invention.

この実施例では、変換部1は、アキュムレータACCか
らの32ビット信号並びに演算制御部8からのセレクト信
号iNV及びMASK信号を入力するセレクタSEL1〜SEL3で構
成され、セレクタSEL1とSEL2の一方の端子にはそれぞれ
インバータ11、12が設けられている。シフト計算部3
は、加算器EAと、この加算器EAの桁上げ信号ECの反転信
号を制御信号として加算器EAの加算結果を反転及びイン
クリメントする反転部iNVERT及びインクリメント部iNC
と、このインクリメント部iNCの出力をクリップするク
リップ部CLiP2と、信号EC(シフト方向を示す信号)及
びクリップ部CLiP2の出力(シフト数を示す信号)をそ
れぞれラッチI及びラッチIIでラッチするラッチ部LT
と、で構成されている。また、バレルシフタ回路4はバ
レルシフタBSと、キャリイ検出回路CADETと、オーバー
フロー検出回路OVDETとで構成されている。更に、クリ
ップ部6は、アンドゲートGと、この出力によって制御
されるクリップ部CLiP1とを含んでいる。
In this embodiment, the conversion unit 1 is composed of selectors SEL1 to SEL3 to which the 32-bit signal from the accumulator ACC and the selection signals iNV and MASK signals from the operation control unit 8 are input, and one of the terminals of the selectors SEL1 and SEL2 is provided. Are provided with inverters 11 and 12, respectively. Shift calculator 3
Is an adder EA and an inversion unit iNVERT and an increment unit iNC that inverts and increments the addition result of the adder EA using the inverted signal of the carry signal EC of the adder EA as a control signal.
And a clip unit CLiP2 for clipping the output of the increment unit iNC, and a latch unit for latching the signal EC (a signal indicating the shift direction) and the output of the clip unit CLiP2 (a signal indicating the shift number) with a latch I and a latch II, respectively. LT
It consists of and. The barrel shifter circuit 4 includes a barrel shifter BS, a carry detection circuit CADET, and an overflow detection circuit OVDET. Further, the clip section 6 includes an AND gate G and a clip section CLiP1 controlled by this output.

これらの回路に与えられる制御信号iNV、MASK、CiN、
LAEN、OPSE、ACENは、演算命令、アキュムレータACCの
最上位ビット(以下、ビットAC31という)、及びキャリ
イ検出回路CADETの出力を受けた演算制御部ACUから出力
される信号である。
Control signals iNV, MASK, CiN provided to these circuits,
LAEN, OPSE, and ACEN are signals output from the arithmetic control unit ACU that receives the arithmetic instruction, the most significant bit of the accumulator ACC (hereinafter referred to as bit AC31), and the output of the carry detection circuit CADET.

尚、第5図の実施例中、第1図に示した加算器2、選
択器5、及びアキュムレータ7は以下それぞれ加算器AD
D、セレクタOPSEL、アキュムレータACCとして説明す
る。
In the embodiment shown in FIG. 5, the adder 2, the selector 5, and the accumulator 7 shown in FIG.
It is described as D, the selector OPSEL, and the accumulator ACC.

以下、この実施例の動作を説明する。 The operation of this embodiment will be described below.

まず、演算命令(浮動小数点から固定小数点への変換
命令)が、演算制御部ACUに入力されることにより、下
記の演算が開始される。
First, an arithmetic instruction (floating point to fixed point conversion instruction) is input to the arithmetic control unit ACU, whereby the following arithmetic operation is started.

(1)1サイクル目 第2図(1)又は第3図(1)に示すような32ビット
のレジスタで構成されるアキュムレータACCに格納され
ている浮動小数点データが、8ビット加算器EA及び、2
者択一のセレクタSEL1、2、3に入力される。
(1) First cycle Floating point data stored in the accumulator ACC composed of 32-bit registers as shown in FIG. 2 (1) or FIG. 3 (1) is the 8-bit adder EA, and Two
Input to alternative selectors SEL1, SEL2, SEL3.

セレクタSEL1には、アキュムレータACCの下位23ビッ
ト(仮数部)が入力され、演算制御部ACUからのセレク
ト信号iNVが“0"の場合、スルーで通過し、“1"の場合
には反転してセレクタSEL1より出力される。このセレク
ト信号iNVは、1サイクル目のとき、サインビットであ
るアキュムレータACCの最上位ビット(MSB)(以下、ビ
ットAC31と呼ぶ)が“0"の場合、つまり正の小数点数の
時は、“0"で、ビットAC31が“1"の場合、つまり負の小
数点数の時は“1"となるよう演算制御部ACUより出力さ
れる。
The lower 23 bits (mantissa part) of the accumulator ACC are input to the selector SEL1, and when the select signal iNV from the arithmetic control unit ACU is “0”, it passes through, and when it is “1”, it is inverted. Output from selector SEL1. This select signal iNV is "1" when the most significant bit (MSB) (hereinafter referred to as bit AC31) of the accumulator ACC which is a sign bit is "0" in the first cycle, that is, when the number is a positive decimal point. When the bit AC31 is "0" and the bit AC31 is "1", that is, when the decimal point number is negative, the arithmetic control unit ACU outputs "1".

また、セレクタSEL2には、アキュムレータACCの下位
から24ビット目、(以下、ビットAC23と呼ぶ)のいわゆ
る「かくれビット」が入力されるが、演算制御部ACUか
らのセレクト信号MASKが、1サイクル目は“1"となるた
め、セレクト信号iNVの反転信号が出力される。
Further, the selector SEL2 receives the 24th bit from the lower order of the accumulator ACC, so-called "hidden bit" (hereinafter referred to as bit AC23), but the select signal MASK from the arithmetic control unit ACU is the first cycle. Is "1", an inverted signal of the select signal iNV is output.

即ち、セレクト信号iNVが“1"の時(負数時)は
“0"、セレクト信号iNVが“0"の時(正数時)は“1"が
出力される(第2図(2)又は第3図(2)参照)。
That is, when the select signal iNV is "1" (negative number), "0" is output, and when the select signal iNV is "0" (positive number), "1" is output (Fig. 2 (2) or See FIG. 3 (2)).

セレクタSEL3には、アキュムレータACCの上位から8
ビットが入力されるが、1サイクル目では、セレクト信
号MASKが“1"となっているため、セレクト信号iNVをそ
のまま出力する。つまり、セレクト信号iNVが“1"の時
(負数時)は上位8ビットオール“1"を、“0"の時(正
数時)はオール“0"を出力する(第2図(2)、第3図
(2)参照)。
For selector SEL3, 8 from the top of accumulator ACC
Although the bit is input, the select signal iNV is output as it is because the select signal MASK is "1" in the first cycle. That is, when the select signal iNV is "1" (when a negative number), the upper 8 bits are all "1", and when the select signal iNV is "0" (when a positive number), all "0" are output ((2) in FIG. 2). , FIG. 3 (2)).

このようにしてフォーマット変換された32ビットは、
32ビット加算器ADDに入力される。尚、加算器ADDの片側
入力は、変換命令時は、“0"となっている。
The 32-bit format converted in this way is
Input to 32-bit adder ADD. Incidentally, the one-side input of the adder ADD is "0" at the time of the conversion instruction.

また、キャリイン信号CiNは、1サイクル目、ビットA
C31の値が“1"の時(負数時)は“1"を、“0"の時(正
数時)は“0"をそれぞれ加算器ADDに与えるように、演
算制御部ACUより出力されて32ビットの加算器入力のLSB
に加算される。従って、1サイクル目データは、第2図
(2)又は第3図(3)に示す如く2の補数化される。
The carry-in signal CiN is bit A in the first cycle.
When the value of C31 is "1" (when it is a negative number), "1" is given to it, and when it is "0" (when it is a positive number), "0" is given to the adder ADD. 32-bit adder input LSB
Is added to. Therefore, the first cycle data is two's complemented as shown in FIG. 2 (2) or FIG. 3 (3).

その後、2者択一セレクタOPSELでは、演算制御部ACU
からのセレクト信号OPSEが“0"となっており、加算器AD
Dの出力をセレクトする。またクリップ部CLiP1は、信号
OVCLが“0"であるため、加算器ADDの値をそのまま出力
する。
After that, in the alternative selector OPSEL, the arithmetic control unit ACU
The select signal OPSE from is 0, and the adder AD
Select the output of D. The clip part CLiP1 is
Since OVCL is "0", the value of adder ADD is output as it is.

以上の動作により、2の補数化されたデータが、アキ
ュムレータACCに格納される。なお、信号ACENは演算制
御部ACUからの各サイクルのイネーブル信号、信号CLKは
クロックである。
By the above-mentioned operation, the 2's complemented data is stored in the accumulator ACC. The signal ACEN is an enable signal for each cycle from the arithmetic and control unit ACU, and the signal CLK is a clock.

一方、加算器EAには、アキュムレータACCのビットAC3
1を除く上位ビットから8ビット(指数部)が入力され
てシフト数を計算するため、88(HEX)を加算する。これ
は、加算器を使って計算するため、第2図及び第3図に
おける浮動小数点位置から固定小数点位置への8ビット
シフト変換に際しては指数が78(HEX)の時、シフト数が
“ゼロ”となることから−78(HEX)を2の補数化した
値、つまり88(HEX)を加算するためである。加算された
値は、2の補数表現となっているため、その後、データ
を絶対値化する必要がある。そのため、加算器EAにおけ
る8ビット加算での桁上げ信号ECの反転信号が符号ビッ
トとなり、信号ECが“0"の時は、反転して“1"となり負
の数を示しており、反転器iNVERTで加算器EAの出力反転
を行ない、インクリメント部iNCで、インクリメント
(1加算)を行う。又、信号ECが“1"の場合は、正の数
となっており、反転器iNVERT、インクリメント部iNC
は、そのまま出力される。こうして絶対値化される。
On the other hand, the accumulator ACC bit AC3
Since 8 bits (exponent part) are input from the upper bits except 1 to calculate the shift number, add 88 (HEX) . Since this is calculated using an adder, when the exponent is 78 (HEX) in the 8-bit shift conversion from the floating point position to the fixed point position in Figs. 2 and 3, the shift number is "zero". This is because -78 (HEX) is a value obtained by complementing two, that is, 88 (HEX) is added. Since the added value is a two's complement expression, it is necessary to convert the data into an absolute value thereafter. Therefore, the inverted signal of the carry signal EC in the 8-bit addition in the adder EA becomes a sign bit, and when the signal EC is "0", it is inverted and becomes "1", indicating a negative number. iNVERT inverts the output of the adder EA, and the increment unit iNC increments (adds 1). When the signal EC is "1", it is a positive number, and the inverter iNVERT and increment unit iNC
Is output as is. In this way, it is converted into an absolute value.

また、シフト数は31ビットまでであるのでシフト数信
号は、5ビットで充分であり、それ以上の数は、シフト
数最大値にクリップしておく必要があるので、上位3ビ
ットのどれか1ビットでも“1"がある場合は、クリップ
部CLiP2で、最大値、IF(HEX)にする。その他の場合は、
クリップせず、5ビットがそのままラッチ部LTにラッチ
される。
In addition, since the shift number is up to 31 bits, the shift number signal is sufficient to be 5 bits, and the number more than that needs to be clipped to the maximum shift number value. If the bit has "1", set the maximum value to IF (HEX) in the clip part CLiP2. Otherwise,
5 bits are directly latched in the latch unit LT without clipping.

また、シフト方向(右シフト、あるいは左シフト)を
制御するため、桁上げ信号ECの値をラッチ部LTでラッチ
し、信号ECが“0"の場合は反転して“1"となる負数を示
すので右シフト、反対に“1"の場合は左シフトとする。
即ち、第2図又は第3図の場合は(70+88)(HEX)=F8
(HEX)で桁上げ信号ECは“0"となる。
Further, in order to control the shift direction (right shift or left shift), the value of the carry signal EC is latched by the latch unit LT, and when the signal EC is “0”, it is inverted and becomes a negative number which becomes “1”. As shown, shift to the right, and conversely, if "1", shift to the left.
That is, in the case of FIG. 2 or 3, (70 + 88) (HEX) = F8
The carry signal EC becomes "0" at (HEX) .

尚、LAENは、演算制御部ACUからの1サイクル目のラ
ッチイネーブル信号である。
LAEN is a latch enable signal for the first cycle from the arithmetic control unit ACU.

(2)2サイクル目 1サイクル目で得られた結果より、データをシフトす
る。
(2) Second cycle Data is shifted from the result obtained in the first cycle.

まずアキュムレータACCに格納されている、2の補数
表現化された32ビットデータをセレクタSEL1、2、3に
入力する。
First, the 32-bit data represented by 2's complement stored in the accumulator ACC is input to the selectors SEL1, SEL2.

この2サイクル目では、セレクト信号iNV、MASKは演
算制御部ACUにより“0"となっており、セレクタSEL1、
2、3ともに、アキュムレータACCの値をそのまま出力
する。その後、そのデータを、バレルシフタBSに入力
し、ラッチ部LTのラッチIにラッチされている5ビット
のデータにより、シフトを行う。ラッチIの出力データ
の最下位ビット(以下、ビットLA0という)のみが“1"
のときは1ビット、ビットLA1のみが“1"のときは2ビ
ット、という様にして以下、5ビットの組み合わせで最
大31ビットのシフトが行える。
In the second cycle, the select signals iNV and MASK are set to "0" by the arithmetic control unit ACU, and the selectors SEL1 and
Both 2 and 3 output the value of the accumulator ACC as it is. Then, the data is input to the barrel shifter BS, and the 5-bit data latched in the latch I of the latch unit LT shifts the data. Only the least significant bit (hereinafter referred to as bit LA0) of the output data of latch I is "1"
In this case, 1 bit is used, and when only bit LA1 is "1", 2 bits are used. In the following, a maximum of 31 bits can be shifted by combining 5 bits.

また、ラッチIIの出力LRは、“1"の時はバレルシフタ
BSを左シフト、“0"の時は右シフトするために1サイク
ル目にラッチしておいた信号である。また、右シフト時
に起こる桁落ちビットを丸めるため、キャリイ検出部CA
DETにて検出し、信号COUTとして出力して演算制御部ACU
に入力し、レジスタ(図示せず)に格納しておく。ま
た、左シフト時に起こる、オーバーフローを、オーバー
フロー検出部OVDETで検出する。
Also, the output LR of the latch II is a barrel shifter when it is "1".
This signal is latched in the first cycle in order to shift BS to the left and shift it to the right when it is "0". In addition, the carry detection unit CA
Detected by DET, output as signal C OUT and calculation control unit ACU
To a register (not shown). Further, the overflow detection unit OVDET detects an overflow that occurs during left shift.

シフトされた結果をバレルシフタBSより出力し、セレ
クタOPSELに入力する。この2サイクル目では、セレク
ト信号OPSEは“1"となり、セレクタOPSELでは、バレル
シフタBSの出力をセレクトし出力する。
The shifted result is output from the barrel shifter BS and input to the selector OPSEL. In the second cycle, the select signal OPSE becomes "1", and the selector OPSEL selects and outputs the output of the barrel shifter BS.

その後、若し、シフトの際、左シフトをしてオーバー
フローが起っていた場合は、クリップ部CLiP1にて、正
の最大値又は負の最大値にデータをクリップする。
After that, if there is an overflow due to a left shift during the shift, the clipping unit CLiP1 clips the data to the maximum positive value or the maximum negative value.

オーバーフローしていない場合は、アンドゲートGの
出力OVCLが“0"となり、セレクタOPSELの出力をそのま
ま出力する。
When no overflow occurs, the output OVCL of the AND gate G becomes "0", and the output of the selector OPSEL is output as it is.

その後、アキュムレータACCに格納される(第2図
(3)又は第3図(4)参照)。
After that, it is stored in the accumulator ACC (see FIG. 2 (3) or FIG. 3 (4)).

(3)3サイクル目 3サイクル目は、2サイクル目のシフト動作で得られ
たアキュムレータACCのデータにキャリイ検出部CADETで
得られた信号COUTを、加算器ADDで加算する。
(3) Third Cycle In the third cycle, the signal C OUT obtained by the carry detection unit CADET is added to the data of the accumulator ACC obtained by the shift operation of the second cycle by the adder ADD.

即ち、まず、アキュムレータACCに格納されているシ
フトされたデータをセレクタSEL1、2、3に入力する。
そしてセレクト信号iNV、MASKは“0"とし、アキュムレ
ータACCの値を、セレクタSEL1、2、3は、そのまま出
力する。
That is, first, the shifted data stored in the accumulator ACC is input to the selectors SEL1, SEL2.
Then, the select signals iNV and MASK are set to "0", and the values of the accumulator ACC are output as they are to the selectors SEL1, SEL2.

そのデータを加算器ADDに入力する。 The data is input to the adder ADD.

またキャリイン信号CiNは、演算制御部ACUのレジスタ
に格納された信号COUTの値をそのまま丸め信号として出
力したもので加算器ADDに入力される。
The carry-in signal CiN is a signal obtained by directly outputting the value of the signal C OUT stored in the register of the arithmetic control unit ACU as a rounding signal and input to the adder ADD.

そして、シフトされたデータに加算されて丸められる
(第2図(4)又は第3図(5)参照)。
Then, it is added to the shifted data and rounded (see FIG. 2 (4) or FIG. 3 (5)).

尚、2サイクル目で、左シフトした場合は、信号CiN
は“0"となる。これは桁落ちビットがないためである。
In the second cycle, if the shift is to the left, the signal CiN
Becomes "0". This is because there is no precision loss bit.

その後、セレクト信号OPSEは“0"とし、セレクタOPSE
Lで加算器ADDの出力をセレクトし、クリップ部CLiP1
も、信号OVCLが“0"であるため、そのまま入力信号を出
力し、最終結果が、アキュムレータACCに格納され、変
換は終了する(第2図(4)又は第3図(5)参照)。
After that, the select signal OPSE is set to "0", and the selector OPSE
Select the output of the adder ADD with L, and clip part CLiP1
Also, since the signal OVCL is "0", the input signal is output as it is, the final result is stored in the accumulator ACC, and the conversion ends (see FIG. 2 (4) or FIG. 3 (5)).

第7図には上記の演算制御部ACUの入出力信号等のタ
イムチャートが示されている。
FIG. 7 shows a time chart of input / output signals of the arithmetic control unit ACU.

バレルシフタ回路4の動作は既に公知であるが、ここ
で第8図及び第9図により簡単に説明する。
The operation of the barrel shifter circuit 4 is already known, but will now be briefly described with reference to FIGS. 8 and 9.

まず、算術的に左シフトを行う場合は、MSB(符号ビ
ット)はその儘残してシフトし、消失ビットの論理和を
第5図のオーバーフロー検出回路OVDETで検出し、更に
消失ビットにMSBの符号と不一致のものがあるとオーバ
ーフローとして、クリップ部CLiPにて正又は負の最大値
にクリップする。
First, when performing an arithmetic left shift, the MSB (sign bit) is left unshifted and shifted, the logical sum of the lost bits is detected by the overflow detection circuit OVDET in FIG. 5, and the sign of the MSB is added to the lost bits. If there is a mismatch, the clip portion CLiP clips the positive or negative maximum value.

例えば、第8図(a)に示す2の補数表現の−17を基
本とし、1ビット左シフトすると同図(b)に示す如く
2倍の値の−34で、2ビット左シフトすると同図(c)
に示す如く4倍の値の−68で、3ビット左シフトすると
−136とならなければならないが、負の最大値−128を越
えてオーバーフローしてしまい、この場合は同図(d)
に示す如く−8となる。
For example, based on -17 of the two's complement representation shown in FIG. 8 (a), a left shift of 1 bit results in a doubled value of -34 as shown in FIG. 8 (b), and a left shift of 2 bits results in the same figure. (C)
As shown in (4), the value must be -68, which is a quadruple value, and it must be -136 when left-shifted by 3 bits, but it overflows beyond the negative maximum value of -128. In this case, (d) in the figure.
It becomes -8 as shown in.

このオーバーフローの検出は、符号ビット(MSB)と
消失ビットの論理和又は論理積の不一致で検出され、正
又は負の最大値にクリップする。
The detection of this overflow is detected by the disagreement of the logical sum or the logical product of the sign bit (MSB) and the erasure bit, and is clipped to the maximum positive or negative value.

算術的に右シフトする場合は、第9図(1)(a)に
示す2の補数表現の−66を5ビットシフトするとシフト
した後へはMSBが入り、同図(1)(b)に示す如く中
間結果は−3となる。
When arithmetically shifting to the right, MSB is inserted after shifting by -bit of -66 of 2's complement representation shown in (1) (a) of FIG. As shown, the intermediate result is -3.

この時のガードビットは同図(1)(c)に示す如く
1となり、スティッキービットは同図(d)に示す値の
論理和の1となる。これらはキャリイ検出回路CADET内
で行われる。
At this time, the guard bit becomes 1 as shown in (1) and (c) of the same figure, and the sticky bit becomes 1 of the logical sum of the values shown in (d) of the figure. These are performed in the carry detection circuit CADET.

ここで、−66を5ビット右シフトすると、−66×2-5
=−2.0625であり、小数点以下の値を丸めると−2又は
−3となる。
Here, if -66 is right-shifted by 5 bits, -66 x 2 -5
= -2.0625, and rounding the value after the decimal point gives -2 or -3.

この場合の、桁落ちビットの丸めには、中間結果に下
記に示すRの値を加算して求める最近値、プラス方向、
マイナス方向、ゼロ方向とする4つの方法がIEEE規格に
より決められている。
In this case, rounding of the precision loss bit is performed by adding the value of R shown below to the intermediate result, the latest value obtained, the plus direction,
Four methods of setting the minus direction and the zero direction are defined by the IEEE standard.

R=×+× R=+ R=0 R=〔+〕×S 但しはLSB、はガードビット、はスティッキー
ビット、Sは符号ビット(MSB)、+は論理和、×は論
理積を示す。
R = × + × R = + R = 0 R = [+] × S where LSB is a guard bit, is a sticky bit, S is a sign bit (MSB), + is a logical sum, and x is a logical product.

このRの値を夫々加算すると、第9図(2)に示す如
く、最近値丸め及びプラス方向丸めは−2となり、マイ
ナス方向丸めは−3となり、ゼロ方向丸めは−2とな
る。従って、−2とする場合はキャリイ検出回路CADET
から“1"が出力され、−3とする場合は“0"が出力され
て上記の丸め動作が加算器ADDにより行われることとな
る。
When the values of R are added respectively, as shown in FIG. 9 (2), the nearest value rounding and the plus rounding become -2, the minus rounding become -3, and the zero rounding becomes -2. Therefore, in the case of -2, carry detection circuit CADET
"1" is output from the output terminal, and when it is set to -3, "0" is output and the above rounding operation is performed by the adder ADD.

〔発明の効果〕〔The invention's effect〕

以上のように、本発明の浮動小数点数−固定小数点数
変換装置によれば、1サイクル目にIEEE標準浮動小数点
数の2の補数化信号を生成してアキュムレータに格納
し、2サイクル目に該アキュムレータの該データをシフ
ト計算部で求めたシフト数及び方向だけバレルシフタ回
路でシフトし、このシフトの際にオーバーフローが生じ
た時はクリップ部でクリップしてアキュムレータに再度
格納し、3サイクル目では、2サイクル目でバレルシフ
タ回路がキャリイ検出していた場合には2サイクル目の
アキュムレータのデータにそのキャリイビットが付加さ
れて最終的な固定小数点数としてアキュムレータに格納
されるように構成したので、IEEE標準浮動小数点数をオ
ーバーフロー処理及び丸め処理を含めて固定小数点数に
変換することができ、演算精度を向上させることができ
る。
As described above, according to the floating point number-fixed point number conversion device of the present invention, the two's complement signal of the IEEE standard floating point number is generated in the first cycle, stored in the accumulator, and stored in the accumulator in the second cycle. The data of the accumulator is shifted by the barrel shifter circuit by the number of shifts and the direction obtained by the shift calculator, and when an overflow occurs during this shift, it is clipped by the clip unit and stored again in the accumulator, and in the third cycle, When the barrel shifter circuit detects a carry in the second cycle, the carry bit is added to the data of the accumulator in the second cycle and the final fixed-point number is stored in the accumulator. Floating point numbers can be converted to fixed point numbers, including overflow and rounding. It is possible to improve the accuracy.

【図面の簡単な説明】[Brief description of drawings]

第1図は本発明に係る浮動小数点数−固定小数点数変換
装置を概念的に示した図、 第2図及び第3図は本発明に係る浮動小数点数−固定小
数点数変換装置の動作を説明するための状態遷移図、 第4図は本発明に係る浮動小数点数−固定小数点数変換
装置に用いる変換部でのフォーマット変換図、 第5図は本発明に係る浮動小数点数−固定小数点数変換
装置の一実施例を示す回路図、 第6図は本発明に係る浮動小数点数−固定小数点数変換
装置に用いる演算制御部の入出力信号を示す図、 第7図は本発明に係る浮動小数点数−固定小数点数変換
装置の一実施例のタイムチャート図、 第8図及び第9図は本発明に係る浮動小数点数−固定小
数点数変換装置に用いるバレルシフタ回路の動作を説明
するための図、 第10図はIEEE形式の浮動小数点数表現を示した図、であ
る。 第1図において、1……変換部、2……加算器、3……
シフト計算部、4……バレルシフタ回路、5……選択
器、6……クリップ部、7……アキュムレータ、8……
演算制御部。 図中、同一符号は同一又は相当部分を示す。
FIG. 1 is a diagram conceptually showing a floating-point-to-fixed-point number conversion apparatus according to the present invention, and FIGS. 2 and 3 explain the operation of the floating-point-to-fixed-point number conversion apparatus according to the present invention. 4 is a state transition diagram for performing the conversion, FIG. 4 is a format conversion diagram in the conversion unit used in the floating point number-fixed point number conversion device according to the present invention, and FIG. 5 is a floating point number-fixed point number conversion according to the present invention. FIG. 6 is a circuit diagram showing an embodiment of the device, FIG. 6 is a diagram showing input / output signals of an arithmetic control unit used in the floating point number-fixed point number conversion device according to the present invention, and FIG. 7 is a floating point number according to the present invention. A time chart diagram of an embodiment of the number-fixed point number converter, FIGS. 8 and 9 are diagrams for explaining the operation of the barrel shifter circuit used in the floating point number-fixed point number converter according to the present invention, Figure 10 shows IEEE floating point numbers It is the figure which showed the expression. In FIG. 1, 1 ... conversion unit, 2 ... adder, 3 ...
Shift calculation unit, 4 ... Barrel shifter circuit, 5 ... Selector, 6 ... Clip unit, 7 ... Accumulator, 8 ...
Arithmetic control unit. In the drawings, the same reference numerals indicate the same or corresponding parts.

Claims (1)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】IEEE標準浮動小数点数を格納するアキュム
レータ(7)と、 該浮動小数点数を、その符号ビットに合わせてフォーマ
ット変換する変換部(1)と、 該変換部(1)の出力と該符号を示すビットにより2の
補数化信号を発生する加算器(2)と、 該浮動小数点数の指数部からシフト数及びシフト方向を
発生してラッチするシフト計算部(3)と、 該シフト数及びシフト方向により該浮動小数点数をシフ
トするバレルシフタ回路(4)と、 該加算器(2)の出力又は該バレルシフタ回路(4)の
出力を選択する選択器(5)と、 該バレルシフタ回路(4)がオーバーフローした時のみ
該選択器(5)の出力をクリップして該アキュムレータ
(7)に与えるクリップ部(6)と、 1サイクル目に該浮動小数点数の符号ビットに応じて該
変換部(1)に制御信号を与え、2サイクル目に該シフ
ト計算部(3)のラッチされた値を出力させ、1サイク
ル目及び3サイクル目に該加算器(2)の出力を、2サ
イクル目に該バレルシフタ回路(4)の出力をそれぞれ
選択するように該選択器(5)を制御し該バレルシフタ
回路(4)がキャリイ検出した時、3サイクル目に該キ
ャリイ信号に基づいて該加算器(2)に丸め信号を与え
る演算制御部(8)と、 を備えたことを特徴とする浮動小数点数−固定小数点数
変換装置。
1. An accumulator (7) for storing an IEEE standard floating point number, a converter (1) for converting the format of the floating point number according to its sign bit, and an output of the converter (1). An adder (2) for generating a two's complement signal by a bit indicating the sign, a shift calculator (3) for generating and latching a shift number and a shift direction from the exponent part of the floating point number, and the shift A barrel shifter circuit (4) for shifting the floating point number according to a number and a shift direction, a selector (5) for selecting the output of the adder (2) or the output of the barrel shifter circuit (4), and the barrel shifter circuit ( 4) according to the clip part (6) which clips the output of the selector (5) and gives it to the accumulator (7) only when it overflows, and the sign bit of the floating point number in the first cycle. A control signal is given to the conversion unit (1), the latched value of the shift calculation unit (3) is output in the second cycle, and the output of the adder (2) is output in the first cycle and the third cycle. In the second cycle, when the barrel shifter circuit (4) controls the selector (5) so as to select the output of the barrel shifter circuit (4), the third cycle detects the carry signal. A floating point number-fixed point number conversion device comprising: an arithmetic control unit (8) for giving a rounding signal to an adder (2).
JP63033102A 1988-02-16 1988-02-16 Floating point number-fixed point number converter Expired - Fee Related JP2509279B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP63033102A JP2509279B2 (en) 1988-02-16 1988-02-16 Floating point number-fixed point number converter

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP63033102A JP2509279B2 (en) 1988-02-16 1988-02-16 Floating point number-fixed point number converter

Publications (2)

Publication Number Publication Date
JPH01207823A JPH01207823A (en) 1989-08-21
JP2509279B2 true JP2509279B2 (en) 1996-06-19

Family

ID=12377300

Family Applications (1)

Application Number Title Priority Date Filing Date
JP63033102A Expired - Fee Related JP2509279B2 (en) 1988-02-16 1988-02-16 Floating point number-fixed point number converter

Country Status (1)

Country Link
JP (1) JP2509279B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7263539B2 (en) 2000-11-13 2007-08-28 Nec Electronics Corporation Circuit and method for generating fixed point data with reduced circuit scale

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04290122A (en) * 1991-03-19 1992-10-14 Fujitsu Ltd Numerical expression conversion device
JP4575609B2 (en) * 2001-03-13 2010-11-04 旭化成エレクトロニクス株式会社 Data converter
US7236995B2 (en) * 2002-12-27 2007-06-26 Arm Limited Data processing apparatus and method for converting a number between fixed-point and floating-point representations
JP2010170196A (en) 2009-01-20 2010-08-05 Sony Corp Arithmetic program conversion apparatus, arithmetic program conversion method, and program

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7263539B2 (en) 2000-11-13 2007-08-28 Nec Electronics Corporation Circuit and method for generating fixed point data with reduced circuit scale

Also Published As

Publication number Publication date
JPH01207823A (en) 1989-08-21

Similar Documents

Publication Publication Date Title
US5373459A (en) Floating point processor with high speed rounding circuit
KR960003044B1 (en) Numerical expression converter and vector processor unit using the same
JP3735425B2 (en) Absolute value comparison circuit
US4992969A (en) Integer division circuit provided with a overflow detector circuit
US4648059A (en) N-bit magnitude comparator
JP2509279B2 (en) Floating point number-fixed point number converter
JP3003467B2 (en) Arithmetic unit
JP2511527B2 (en) Floating point arithmetic unit
US6151612A (en) Apparatus and method for converting floating point number into integer in floating point unit
JP3356613B2 (en) Addition method and adder
US6477557B1 (en) Division circuit not requiring taking complements of divisor, dividend and remainder
JPH0511980A (en) Overflow detecting method and circuit
JP2578482B2 (en) Floating point arithmetic unit
JP2991788B2 (en) Decoder
CN114895868B (en) Division operation unit and divider based on two-bit quotient calculation
JP3074958B2 (en) Serial multiplier with addition function
JP2664750B2 (en) Arithmetic device and arithmetic processing method
JP2907276B2 (en) Arithmetic processing unit
JP4073513B2 (en) Floating point processor
JPH1040073A (en) Digital signal processor
JP2558939B2 (en) Rounding circuit
JP3284717B2 (en) Barrel shifter
JP2575856B2 (en) Arithmetic circuit
JPH03164830A (en) Multiplying device
JPH08212052A (en) Normalized data generation circuit

Legal Events

Date Code Title Description
LAPS Cancellation because of no payment of annual fees