JPH0381174B2 - - Google Patents

Info

Publication number
JPH0381174B2
JPH0381174B2 JP59197421A JP19742184A JPH0381174B2 JP H0381174 B2 JPH0381174 B2 JP H0381174B2 JP 59197421 A JP59197421 A JP 59197421A JP 19742184 A JP19742184 A JP 19742184A JP H0381174 B2 JPH0381174 B2 JP H0381174B2
Authority
JP
Japan
Prior art keywords
circuit
output
point number
register
input
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 - Lifetime
Application number
JP59197421A
Other languages
Japanese (ja)
Other versions
JPS6175431A (en
Inventor
Yoshihisa Soda
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.)
NEC Corp
Original Assignee
Nippon Electric Co 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 Nippon Electric Co Ltd filed Critical Nippon Electric Co Ltd
Priority to JP59197421A priority Critical patent/JPS6175431A/en
Publication of JPS6175431A publication Critical patent/JPS6175431A/en
Publication of JPH0381174B2 publication Critical patent/JPH0381174B2/ja
Granted legal-status Critical Current

Links

Description

【発明の詳細な説明】 (技術分野) 本発明は演算装置、とくに固定小数点から浮動
小数点数および、浮動小数点数から固定小数点数
に変換する回路を有する演算装置に関する。
TECHNICAL FIELD The present invention relates to an arithmetic device, and particularly to an arithmetic device having a circuit for converting fixed point numbers to floating point numbers and from floating point numbers to fixed point numbers.

(従来技術) 一般に、固定小数点数の負数は2進補数で表わ
され、浮動小数点数の負数は、その絶対値と負数
を表わす符号ビツトとで表わされるので、固定小
数点数から浮動小数点数に変換する場合および逆
に浮動小数点数から固定小数点数に変換する場合
には、それぞれ、負数の固定小数点数(2進補
数)からそれと同じ絶対値をもつ正数の固定小数
への変換および、この逆の正数の固定小数点数か
ら同じ絶対値をもつ負数の固定小数点数への変換
が必要となる。
(Prior art) Generally, a negative number in a fixed-point number is represented by a binary complement, and a negative number in a floating-point number is represented by its absolute value and a sign bit representing the negative number. When converting from a floating point number to a fixed point number, the conversion from a negative fixed point number (binary complement) to a positive fixed point number with the same absolute value, and this It is necessary to convert the opposite positive fixed-point number to a negative fixed-point number with the same absolute value.

これを行なうのに従来技術においては、後に詳
述するように、制御機能付の反転回路と、A+1
演算回路(1加算回路)とを用いて行なつてい
る。
In order to do this, in the prior art, as will be explained in detail later, an inverting circuit with a control function and an A+1
This is done using an arithmetic circuit (1 adder circuit).

このために回路を複雑にし、演算速度が低下す
るという欠点を有している。
This has the drawback of complicating the circuit and reducing the calculation speed.

(発明の目的) 本発明の目的は上述の従来の欠点を除去し、よ
り簡単な回路を用い演算速度の向上した固定小数
点数から浮動小数点数への変換および浮動小数点
数から固定小数点数への変換を行なう回路を含む
演算装置を提供することにある。
(Objective of the Invention) The object of the present invention is to eliminate the above-mentioned conventional drawbacks, and to convert fixed-point numbers to floating-point numbers and from floating-point numbers to fixed-point numbers using simpler circuits and with improved calculation speed. An object of the present invention is to provide an arithmetic device including a circuit that performs conversion.

(発明の構成) 本発明の装置は、固定小数点から浮動小数点数
および浮動小数点数から固定小数点数に変換する
機能を有する演算装置において、変換すべき入力
情報を格納する入力レジスタと、入力浮動小数点
数の指数部に特定の演算を施こして出力する指数
部演算回路と、前記入力レジスタの出力に対し前
記指数部演算回路の出力に応ずるシフトを行ない
結果を出力するシフト回路と、固定小数点数から
浮動小数点数への変換かまたは浮動小数点数から
固定小数点数への変換かに応じて前記入力レジス
タの出力かまたは前記シフト回路の出力かを選択
する第1の選択回路と、前記第1の選択回路の出
力から1を減算し結果の各桁のビツトを反転して
出力する−1演算回路と、前記変換すべき入力
数情報の正負に応じて前記第1の選択回路の出力
かまたは前記−1演算回路の出力かを選択する
第2の選択回路とを含む。
(Structure of the Invention) The device of the present invention is an arithmetic device having a function of converting from a fixed point number to a floating point number and from a floating point number to a fixed point number. an exponent calculation circuit that performs a specific operation on the exponent part of a number and outputs the result; a shift circuit that performs a shift on the output of the input register according to the output of the exponent calculation circuit and outputs the result; and a fixed-point number. a first selection circuit that selects the output of the input register or the output of the shift circuit depending on whether the conversion is to a floating point number or from a floating point number to a fixed point number; -1 arithmetic circuit that subtracts 1 from the output of the selection circuit and inverts the bits of each digit of the result and outputs the result; and the output of the first selection circuit or the -1 arithmetic circuit;

(実施例) 次に図面を参照して本発明を詳細に説明する。(Example) Next, the present invention will be explained in detail with reference to the drawings.

第1図は本発明の一実施例を示すブロツク図で
ある。本実施例は、入力符号レジスタ1、入力指
数部レジスタ2、入力仮数部レジスタ3、指数部
演算回路4、シフト回路5、浮動/固定指示回路
6、第1選択回路7、−1演算回路8、第2選
択回路9、指数発生回路10、第3選択回路1
1、第4選択回路12、出力符号レジスタ13、
出力指数部レジスタ14および出力仮数部レジス
タ15を含んでいる。
FIG. 1 is a block diagram showing one embodiment of the present invention. This embodiment includes an input sign register 1, an input exponent register 2, an input mantissa register 3, an exponent calculation circuit 4, a shift circuit 5, a floating/fixed instruction circuit 6, a first selection circuit 7, and a -1 calculation circuit 8. , second selection circuit 9, index generation circuit 10, third selection circuit 1
1, fourth selection circuit 12, output sign register 13,
It includes an output exponent register 14 and an output mantissa register 15.

入力側および出力側の各レジスタは、全部で64
ビツト分の幅を有し、この中で符号レジスタ1お
よび13は第0ビツト目の1ビツト分、指数部レ
ジスタ2および14は第1ビツト目から第7ビツ
ト目までの7ビツト分、および仮数部レジスタ3
および15は第8ビツト目から第63ビツト目まで
の56ビツト分のそれぞれの幅を有している。
There are a total of 64 registers on the input and output sides.
Sign registers 1 and 13 have a width of 1 bit, the exponent registers 2 and 14 have a width of 7 bits from the 1st bit to the 7th bit, and the mantissa. part register 3
and 15 have a width of 56 bits from the 8th bit to the 63rd bit.

浮動小数点数の場合には指数部は16(16進数の
10)に対する冪乗を表わす。また仮数部の小数点
は、仮数部の最上位ビツトの左側(従つて仮数部
は小数点以下の部分を表わす)にあると仮定さ
れ、正負にかかわらずその絶対値で表わされ、符
号は符号ビツトにより負数は“1”、正数は“0”
として表わされる。
For floating point numbers, the exponent part is 16 (hexadecimal
10). The decimal point of the mantissa is assumed to be to the left of the most significant bit of the mantissa (therefore, the mantissa represents the part below the decimal point), and is expressed by its absolute value, regardless of whether it is positive or negative, and the sign is the sign bit. Therefore, negative numbers are “1” and positive numbers are “0”
It is expressed as

固定小数点数の場合には、小数点は最下位ビツ
トの右側(従つて常に整数を表わす)にあると仮
定され、下位の32ビツト分だけが有効桁として用
いられる。正数の場合には、それよりも上の桁
(つまり第0ビツト目から第31ビツト目まで)は
すべて0となる。負数は2の補数で表わされ、従
つて例えば−1は、FF……F(16進数のFの16個
分)、また−2はFF……FF(16進数のFが15個と
16進数のEが1個)で表わされる。一般に負数の
|X|は、 F=−(|X|−1) で表わされる。但しF=は対象となるすべて桁のビ
ツトを“1”とした数を表わすとする。
For fixed-point numbers, the decimal point is assumed to be to the right of the least significant bit (thus always representing an integer), and only the least significant 32 bits are used as significant digits. In the case of a positive number, all digits above it (that is, from the 0th bit to the 31st bit) are 0. Negative numbers are expressed as two's complement numbers, so for example -1 is FF...F (16 hexadecimal Fs), and -2 is FF...FF (15 hexadecimal Fs).
It is represented by one hexadecimal E. Generally, a negative number |X| is expressed as F=-(|X|-1). However, it is assumed that F= represents a number in which all target bits are set to "1".

従つて浮動小数点数および固定小数点数いずれ
の場合にも符号レジスタ1および13の内容とし
て、正数の場合には“0”が負数の場合には
“1”がそれぞれ格納される。
Therefore, for both floating point numbers and fixed point numbers, the contents of sign registers 1 and 13 are "0" for positive numbers and "1" for negative numbers.

さて、次に本実施例の動作について説明する。 Next, the operation of this embodiment will be explained.

最初に、正数の場合の固定小数点数から浮動小
数点数への変換から説明する。
First, we will explain conversion from a fixed-point number to a floating-point number in the case of a positive number.

まず、入力側に正の固定小数点数Xが入力され
るが、この結果、前述のように、入力符号レジス
タ1の内容は“0”に、また入力指数部レジスタ
2の内容もすべて“0”に、そして入力仮数部レ
ジスタ3の下位32ビツト分の幅の中にXが格納さ
れる。
First, a positive fixed-point number Then, X is stored within the width of the lower 32 bits of the input mantissa register 3.

一方、固定小数点数から浮動小数点数への変換
の場合には、浮動/固定指示回路6は、“0”を
出力し、これによつて第1選択回路7、第3選択
回路11および第4選択回路12はそれぞれの入
力を後述するように選択して下段に出力する。
On the other hand, in the case of conversion from a fixed point number to a floating point number, the floating/fixed instruction circuit 6 outputs "0", thereby causing the first selection circuit 7, the third selection circuit 11 and the fourth selection circuit 11 to The selection circuit 12 selects each input as described later and outputs it to the lower stage.

まず第1選択回路7は、入力仮数部レジスタ3
の出力側(ライン3000側)を選択し、これを演算
回路8および第2選択回路9の一方の入力側に供
給する。
First, the first selection circuit 7 selects the input mantissa register 3
The output side (line 3000 side) is selected and supplied to one input side of the arithmetic circuit 8 and the second selection circuit 9.

正数の場合には、入力符号レジスタ1の内容の
“0”がそのまま、出力符号レジスタ13に供給
格納されるとともに、この“0”が第2選択回路
9の選択制御信号として加えられ、この結果、回
路9は、第1選択回路7の出力(ライン7000側)
を選択し、これを第3選択回路11および第4選
択回路12にそれぞれ供給する。
In the case of a positive number, the “0” content of the input sign register 1 is supplied and stored as is to the output sign register 13, and this “0” is added as a selection control signal to the second selection circuit 9. As a result, circuit 9 outputs the output of first selection circuit 7 (line 7000 side)
is selected and supplied to the third selection circuit 11 and the fourth selection circuit 12, respectively.

第3選択回路11は、前述の回路6の出力の
“0”により、指数発生回路10の出力側(ライ
ン1000側)を選択してこれを出力指数部レジスタ
14に供給格納する。
The third selection circuit 11 selects the output side (line 1000 side) of the exponent generation circuit 10 based on the output "0" of the circuit 6 described above, and supplies and stores it in the output exponent register 14.

また第4選択回路12は、前述の回路6の出力
の“0”により、第2選択回路9からの出力のう
ちの左側から入る入力(ライン9000L)側を選択
して出力仮数部レジスタ15に供給格納する。第
4選択回路がライン9000L側の入力を選択した場
合には、第2選択回路9の出力は、下位の32ビツ
ト分が、出力仮数部レジスタ15の上位32ビツト
分の位置にくるように(つまり24ビツト分左シフ
トされた形で)格納される。
Further, the fourth selection circuit 12 selects the input (line 9000L) that enters from the left side of the output from the second selection circuit 9 based on the “0” of the output of the circuit 6 described above, and stores it in the output mantissa register 15. Supply and store. When the fourth selection circuit selects the input on the line 9000L side, the output of the second selection circuit 9 is output so that the lower 32 bits are located at the upper 32 bits of the output mantissa register 15 ( In other words, it is stored shifted to the left by 24 bits).

以上の結果、出力符号レジスタ13には“0”
が、また出力指数部レジスタには、指数発生回路
10の出力が、また出力仮数部レジスタ15に
は、上位32ビツトの位置にXが格納される。
As a result of the above, the output sign register 13 is “0”
However, the output exponent register 10 stores the output of the exponent generation circuit 10, and the output mantissa register 15 stores X in the upper 32 bits.

前述のように浮動小数点数の場合には、仮数部
レジスタ15の最上位の左側に水数点があると仮
定されており、従つてXは現在、真の値より32ビ
ツト分右シフトされた形で表わされている。これ
を打消すために、指数発生回路10は8を出力し
てこれを前述のように出力指数部レジスタ14に
格納する(232=(248=(16)8で定まる8)。
As mentioned above, in the case of floating point numbers, it is assumed that the water point is to the left of the topmost part of the mantissa register 15, so that X is currently shifted to the right by 32 bits from the true value. expressed in the form. In order to cancel this, the exponent generation circuit 10 outputs 8 and stores it in the output exponent register 14 as described above (8 determined by 2 32 =(2 4 ) 8 =(16) 8 ).

以上により正数の固定小数点数Xの浮動小数点
数への変換が完成されたことになる(但し、浮動
小数点数の正規化の処理は現在の対象には含まれ
ないものとする)。
With the above, the conversion of the positive fixed-point number X to a floating-point number is completed (however, the normalization process of the floating-point number is not included in the current target).

次に負数の場合の固定小数点数から浮動小数点
数への変換は次のようになる。
Next, the conversion from a fixed point number to a floating point number in the case of a negative number is as follows.

入力側に負の固定小数点数Xが入力されると、
前述のように、入力符号レジスタ1の内容には
“1”が、また、入力指数部レジスタ2の内容に
はすべて“1”が、そして仮数部レジスタ3に
は、 F=−(|X|−1) が格納される。但しFは、前述のように対象とす
る桁のすべてのビツトを“1”とした数を表わ
す。
When a negative fixed-point number X is input to the input side,
As mentioned above, the contents of the input sign register 1 are "1", the contents of the input exponent register 2 are all "1", and the mantissa register 3 is F=-(|X| -1) is stored. However, F represents a number in which all bits of the target digit are "1" as described above.

指示回路6は、前述と同様に“0”を出力し、
従つて入力仮数部レジスタ3の出力がライン3000
を介して第1選択回路7で選択され、下段に出力
される。
The instruction circuit 6 outputs "0" as described above,
Therefore, the output of input mantissa register 3 is line 3000.
is selected by the first selection circuit 7 and output to the lower stage.

さて負数の場合には、入力符号レジスタ1の内
容が“1”であるため、第2選択回路9は、前述
の正の場合とは反対の−1演算回路8の出力側
を選択する。−1演算回路8は、入力をAとし
た場合に、Aを常に正の整数とみて、それから1
を引き、結果の各ビツトを反転したものを出力す
る演算回路である。すなわち入力をAとした場合
に−1を出力する。
Now, in the case of a negative number, since the content of the input sign register 1 is "1", the second selection circuit 9 selects the output side of the -1 arithmetic circuit 8, which is opposite to the case of the above-mentioned positive number. -1 arithmetic circuit 8 assumes that the input is A, always considers A to be a positive integer, and then calculates 1
This is an arithmetic circuit that subtracts the result and inverts each bit of the result. That is, when the input is A, -1 is output.

上述のように、この演算回路8に対する入力は
現在の場合F=(|X|−1)であるためこの出力
は、 F=−(||−1)−1=F=−||=|X| となり、入力固定小数点負数の絶対値|X|が得
られる。
As mentioned above, the input to this arithmetic circuit 8 is currently F=(|X|-1), so the output is F=-(||-1)-1=F=-|||=| X|, and the absolute value |X| of the input fixed-point negative number is obtained.

これ以下は前述の正数の場合と全く同様にして
浮動小数点数に変換され、出力符号レジスタ13
の値の“1”で負数を表わす浮動小数点数への変
換が完成する。
Anything below this is converted to a floating point number in exactly the same way as the positive number described above, and the output sign register 13
The conversion to a floating point number representing a negative number is completed with the value "1".

このように、負数の場合には、負数の絶対値を
求める演算が必要になるが、本実施例においては
これを−1演算回路8を用いて行なつている。
In this way, in the case of a negative number, it is necessary to calculate the absolute value of the negative number, and in this embodiment, this is performed using the -1 calculation circuit 8.

次に浮動小数点数から固定小数点数への変換を
説明する。この場合には、入力を浮動小数点数の
符号、指数部および仮数部はそれぞれ、入力符号
レジスタ1、入力指数部レジスタ2、および入力
仮数部レジスタ3に格納される。
Next, conversion from floating point numbers to fixed point numbers will be explained. In this case, the sign, exponent, and mantissa of the input floating-point number are stored in input sign register 1, input exponent register 2, and input mantissa register 3, respectively.

最初に、入力する浮動小数点数を正数とする。
この場合には入力符号レジスタ1の内容は“0”
であり、この結果レジスタ13の内容も“0”と
なる。
First, let the input floating point number be a positive number.
In this case, the contents of input sign register 1 are “0”
As a result, the contents of the register 13 also become "0".

さて、浮動小数点数から固定小数点数への変換
の場合には、指示回路6の出力は“1”となり、
この結果、第1選択回路7、第3選択回路11お
よび、第4選択回路12はすべて、前述の固定小
数点数から浮動小数点数への変換の場合の反対側
を選択して下段に出力する。
Now, in the case of conversion from a floating point number to a fixed point number, the output of the instruction circuit 6 becomes "1",
As a result, the first selection circuit 7, the third selection circuit 11, and the fourth selection circuit 12 all select the opposite side in the case of conversion from a fixed point number to a floating point number and output it to the lower stage.

この結果、まず第1選択回路7は、シフト回路
5の出力側(ライン5000側)を選択して下段に出
力する。
As a result, the first selection circuit 7 first selects the output side (line 5000 side) of the shift circuit 5 and outputs it to the lower stage.

シフト回路5は、指数部演算回路4の出力で指
定される数だけ、仮数部レジスタ3の出力を右シ
フトして出力する。
The shift circuit 5 shifts the output of the mantissa register 3 to the right by the number specified by the output of the exponent calculation circuit 4 and outputs the result.

一方、指数部演算回路4は、14(16進数の
E)から、入力指数部レジスタ2の内容(つまり
入力浮動小数点数の指数)を減算した値を出力す
る。
On the other hand, the exponent calculation circuit 4 outputs a value obtained by subtracting the contents of the input exponent register 2 (that is, the exponent of the input floating point number) from 14 (E in hexadecimal).

この結果シフト回路5の出力には、入力浮動小
数点数が、小数点位置を最下位ビツトの右側にも
つ固定小数点数に変換されたものが出力される。
As a result, the shift circuit 5 outputs the input floating point number converted into a fixed point number with the decimal point position to the right of the least significant bit.

例えば、指数部の値として0をもつ浮動小数点
数の、仮数部のMSBは、小数点の一つ右側のビ
ツトを表わすが、この場合には、指数部演算回路
4の出力は14−0=14となりこの結果、仮数部レ
ジスタ3の出力はシフト回路5により、14×4=
56ビツト分だけ右シフトされ、もとのMSBは、
最下位ビツトの一つ右側にある前述の固定小数点
の次のビツト位置まで正しくシフトされて固定小
数点数に変換されることが分る。勿論、指数部が
0の浮動小数点数を固定小数点数に変換するとア
ンダフローして0になるので実際に有効な変換が
行なわれるためには指数部は0より大きい数であ
る必要がある。
For example, the MSB of the mantissa of a floating point number whose exponent part value is 0 represents the bit to the right of the decimal point. In this case, the output of the exponent part calculation circuit 4 is 14 - 0 = 14 As a result, the output of the mantissa register 3 is transferred by the shift circuit 5 to 14×4=
The original MSB is shifted to the right by 56 bits.
It can be seen that the bit position next to the above-mentioned fixed point, which is one bit to the right of the least significant bit, is correctly shifted and converted into a fixed point number. Of course, when a floating point number with an exponent part of 0 is converted to a fixed point number, it underflows and becomes 0, so the exponent part must be a number larger than 0 in order to actually perform an effective conversion.

こうして正しい固定小数点数に変換された回路
5の出力が、第1選択回路7で選択され、さら
に、レジスタ1の出力が“0”である結果、この
回路7の出力が第2選択回路9でそのまま選択さ
れて下段に出力される。
The output of the circuit 5 converted into a correct fixed-point number in this way is selected by the first selection circuit 7, and as a result of the output of the register 1 being "0", the output of this circuit 7 is selected by the second selection circuit 9. It is selected as is and output to the bottom row.

第3選択回路11は、指示回路6の出力が
“1”であることにより、第2選択回路9の出力
側を選択してレジスタ14に供給格納する。
Since the output of the instruction circuit 6 is "1", the third selection circuit 11 selects the output side of the second selection circuit 9 and supplies and stores it in the register 14.

第4選択回路12は同様に、指示回路6の出力
が“1”であることにより、第2選択回路9から
の出力のうちの右側から入る入力(ライン
9000R)側を選択してレジスタ15に供給格納す
る。第4選択回路12がライン9000R側の入力を
選択した場合には、第2選択回路9の出力は、そ
のまま、シフトされることなく、レジスタ15に
供給格納される。
Similarly, since the output of the instruction circuit 6 is "1", the fourth selection circuit 12 receives an input from the right side of the output from the second selection circuit 9 (line
9000R) side is selected and supplied to and stored in the register 15. When the fourth selection circuit 12 selects the input on the line 9000R side, the output of the second selection circuit 9 is directly supplied to and stored in the register 15 without being shifted.

以上の動作により、この場合には、入力の浮動
小数点数が、シフト回路5により固定小数点数に
変換され、それが各選択回路を介してそのまま出
力レジスタに格納され、浮動小数点数から固定小
数点数への変換が完成する。
Through the above operations, in this case, the input floating point number is converted to a fixed point number by the shift circuit 5, which is stored as it is in the output register via each selection circuit, and the floating point number is converted into a fixed point number. The conversion to is completed.

最後に、入力が負数の場合の浮動小数点数から
固定小数点数への変換を説明する。
Finally, we will explain conversion from a floating point number to a fixed point number when the input is a negative number.

負数の場合の入力は、前述の正数の場合に較べ
て、符号レジスタ1の内容が“1”にかわるだけ
で、指数部レジスタ2および仮数部レジスタ3の
内容は、同じ絶対値をもつ正の入力浮動小数点数
の場合と全く同様である。
In the case of a negative number, compared to the case of a positive number described above, only the contents of sign register 1 change to "1", and the contents of exponent register 2 and mantissa register 3 are positive with the same absolute value. The same is true for input floating point numbers.

従つて前述と同様にして、シフト回路5の出力
には、入力浮動小数点数の絶対値が正しく正の固
定小数点数に変換されたものが出力される。
Therefore, in the same way as described above, the output of the shift circuit 5 is the absolute value of the input floating point number correctly converted into a positive fixed point number.

第1選択回路7は、このシフト回路5の出力を
選択して−1演算回路8に供給する。
The first selection circuit 7 selects the output of the shift circuit 5 and supplies it to the -1 arithmetic circuit 8 .

一方、入力符号レジスタ1の内容の“1”は、
出力符号レジスタ13に供給格納されるととも
に、第2選択回路9の選択制御入力として供給さ
れ、回路9が−1演算回路8の出力側を選択し
て下段に出力するように制御する。
On the other hand, the content “1” of input sign register 1 is
It is supplied and stored in the output sign register 13 and is also supplied as a selection control input to the second selection circuit 9, which controls the circuit 9 to select the output side of the -1 arithmetic circuit 8 and output it to the lower stage.

前述のように−1演算回路8の入力には、入
力浮動小数点数の絶対値を固定小数点数に変換し
た数|X|が入力されるが、回路8は、これから
1を減じた結果の各桁のビツトを反転するという
演算を行なつて出力する。この結果||−1が
出力される。
As mentioned above, the input of the -1 arithmetic circuit 8 is the number |X| obtained by converting the absolute value of the input floating point number into a fixed point number. It performs the operation of inverting the bits of the digit and outputs the result. As a result, ||-1 is output.

さて、任意の正数Aに対して =F=−A ……(1) の関係がある。 Now, for any positive number A =F=-A...(1) There is a relationship between

これを用いると、上述の|X|−1は ||−1=F=−(|X|−1)→−|X| となり、前述のように、||−1は正の固定小
数点数|X|を、2進補数をとることにより負数
に変換した固定小数点数であることが分る。
Using this, | It can be seen that |X| is a fixed-point number converted into a negative number by taking binary complement.

第2選択回路9の出力は、前述と同様にして、
第3選択回路11および第4選択回路12で選択
され、各出力レジスタ14および15に供給格納
され、これとレジスタ13の内容とにより、正し
く負数の固定小数点数に変換された出力を与える
ことになる。
The output of the second selection circuit 9 is as described above.
It is selected by the third selection circuit 11 and the fourth selection circuit 12, and is supplied to and stored in each output register 14 and 15, and by this and the contents of the register 13, it is possible to provide an output correctly converted to a negative fixed-point number. Become.

以上のように負数の場合には、入力浮動小数点
数は、シフト回路5により、対応する絶対値をも
つ固定小数点数に変換され、これが−1演算回
路8により、負数の固定小数点数(2進補数)に
変換され、それが、第3選択回路11および第4
選択回路12で選択され、出力レジスタ14およ
び15に供給格納され、これらと符号レジスタ1
3の出力とによつて、負の固定小数点数に変換さ
れた出力を与えることになる。
As described above, in the case of a negative number, the input floating point number is converted by the shift circuit 5 into a fixed point number with the corresponding absolute value, and this is converted into a negative fixed point number (binary complement) by the -1 calculation circuit 8. number), which is converted into the third selection circuit 11 and the fourth selection circuit 11.
It is selected by the selection circuit 12 and is supplied to and stored in the output registers 14 and 15.
3 gives an output converted to a negative fixed-point number.

このように負数の浮動小数点数を固定小数点数
に変換する場合には、絶対値を、負数(2進補
数)に変換する演算が必要であるが、本実施例に
おいては、これも、前述の負数からその絶対値を
求めるための演算に用いたと同じ−1演算回路
8をそのまま用いて行なつている。
In this way, when converting a negative floating point number to a fixed point number, an operation is required to convert the absolute value to a negative number (binary complement), but in this example, this is also performed as described above. The same -1 arithmetic circuit 8 used for calculating the absolute value of a negative number is used as is.

さて、以上の演算により、本実施例は、固定小
数点数から浮動小数点数へ、および浮動小数点数
から固定小数点数への変換を行なうが、これを従
来例と比較すると以下に述べるように、本実施例
の方が構成が簡単で、また演算速度が速いという
優れた特徴を有している。
Now, through the above operations, this embodiment converts a fixed-point number to a floating-point number, and from a floating-point number to a fixed-point number. Comparing this with the conventional example, as described below, the present embodiment The embodiment has the advantage of being simpler in structure and faster in calculation speed.

従来例のブロツク図を第2図に示す。 A block diagram of a conventional example is shown in FIG.

上述の本実施例と同じ回路要素には、同じ参照
数字にダツシユを付して示す。
Circuit elements that are the same as those in this embodiment described above are indicated by the same reference numerals with a dash.

第2図で明らかなように、従来例が上述の実施
例と異なる点は、反転回路16′が含まれている
こと、および前述の−1演算回路8のかわり
に、A+1演算回路18′が用いられている点で
ある。
As is clear from FIG. 2, the difference between the conventional example and the above-described embodiment is that an inverting circuit 16' is included, and instead of the -1 arithmetic circuit 8, an A+1 arithmetic circuit 18' is used. The point is that it is used.

反転回路16′は入力符号レジスタ1′の内容が
“0”(入力が正数)の場合には第1選択回路7′
の出力を反転せずにそのまま下段に出力し、レジ
スタ1の内容が“1”(入力が負数)の場合には、
第1選択回路7′の出力の各ビツトを反転して下
段に出力するような制御機能付反転回路である。
このため固定的に各ビツトを反転する反転回路に
比較して回路が複雑になり、それだけ時間遅れが
大きくなる。
When the content of the input sign register 1' is "0" (input is a positive number), the inverting circuit 16' switches to the first selection circuit 7'.
If the output of is output as is to the lower stage without inverting it, and the content of register 1 is "1" (input is a negative number),
This is an inverting circuit with a control function that inverts each bit of the output of the first selection circuit 7' and outputs it to the lower stage.
For this reason, the circuit becomes more complex than an inversion circuit that inverts each bit in a fixed manner, and the time delay increases accordingly.

またA+1演算回路18′は、入力をAとする
とそれに1を加算して出力する演算回路である。
Further, the A+1 arithmetic circuit 18' is an arithmetic circuit that, when input is A, adds 1 to it and outputs the result.

さて、第2図に示す従来例による変換動作は下
記の通りである。
Now, the conversion operation according to the conventional example shown in FIG. 2 is as follows.

まず入力が正数の場合には、固定小数点数から
浮動小数点数への変換に対しても、また逆の浮動
小数点数から固定小数点数への変換に対しても、
反転回路16′は反転を行なわず、また、前述の
説明で明らかなように、この場合には第2選択回
路9および9′はそれぞれ、−1演算回路8お
よびA+1演算回路18′の側を選択しないため
に、これ等の演算回路はともに演算に参加しな
い。このため、入力が正数の場合には従来例も上
述の実施例も全く同じ動作を行ない、前述の本実
施例の説明より正しい変換が行なわれることは明
らかである。
First, if the input is a positive number, both for conversion from fixed point number to floating point number, and vice versa, for conversion from floating point number to fixed point number.
The inverting circuit 16' does not perform inversion, and as is clear from the above description, in this case, the second selection circuits 9 and 9' operate on the side of the -1 arithmetic circuit 8 and the A+1 arithmetic circuit 18', respectively. Since they are not selected, neither of these arithmetic circuits participates in the calculation. Therefore, when the input is a positive number, both the conventional example and the above embodiment perform exactly the same operation, and it is clear from the above description of this embodiment that correct conversion is performed.

次に、負数の固定小数点数から浮動小数点数に
変換する場合には、第1選択回路7′の出力は前
述のように、 F=−(|X|−1) であり、これが反転回路16′により以下のよう
に変換される。
Next, when converting from a negative fixed point number to a floating point number, the output of the first selection circuit 7' is F=-(|X|-1) as described above, and this is the output of the inverting circuit 16. ′ is converted as follows.

F=−(||−1)=|X|−1 ((1)式参照) これがA+1演算回路18′で1が加算され、 |X|−1+1=|X| より|X|となり、回路18′の出力は、この
場合には前述の回路8の出力と全く同じになるた
め、前述の本実施例の場合と全く同様に変換が行
なわれることは明らかである。
F=-(||-1)=|X|-1 (see formula (1)) 1 is added to this in the A+1 arithmetic circuit 18', and from |X|-1+1=|X|, it becomes |X|, and the circuit Since the output of circuit 18' is in this case exactly the same as the output of circuit 8 described above, it is clear that the conversion is carried out in exactly the same manner as in the present embodiment described above.

また、負数の浮動小数点数から、固定小数点数
への変換の場合には、第1選択回路7′の出力に
は本実施例で説明したのと同様に、入力する負数
の浮動小数点数の絶対値を固定小数点数に変換し
た値の|X|が得られるが、これが反転回路1
6′により各ビツトごとに反転されて||とな
り、さらに、A+1演算回路18′において、1
が加算され||+1となつて出力される。
In addition, in the case of conversion from a negative floating point number to a fixed point number, the output of the first selection circuit 7' is the absolute value of the input negative floating point number, as explained in this embodiment. The value |X| is obtained by converting the value into a fixed-point number, and this is the inverting circuit 1.
6' inverts each bit to become ||, and further, in the A+1 arithmetic circuit 18', 1
is added and output as ||+1.

しかるに、 ||+1F=−|X|+1=F=−(|X|-1) となり、この場合にも回路18′の出力は、回路
8の出力と全く同じになるため、前述の本実施例
の場合と全く同様に変換が行なわれることは明ら
かである。
However, ||+1F = - | It is clear that the transformation takes place exactly as in the example.

以上のように、従来例と本実施例とは全く同様
な変換を行なうが、従来例は反転回路16′を含
み、この回路16′は前述のように、入力符号レ
ジスタ1′の内容により反転、否反転が制御され
る制御機能付反転回路であるために、固定的に反
転する反転回路に比較して回路が複雑になり、そ
れだけ時間遅れが大となる。従つてこれを含まな
い本実施例の方が、ハードウエアの簡単さ、およ
び演算速度の点で優れていることは明らかであ
る。
As described above, the conventional example and this embodiment perform completely similar conversion, but the conventional example includes an inversion circuit 16', and as described above, this circuit 16' is inverted depending on the contents of the input sign register 1'. Since this is an inverting circuit with a control function that controls whether or not to invert, the circuit becomes more complex than an inverting circuit which inverts in a fixed manner, and the time delay increases accordingly. Therefore, it is clear that this embodiment, which does not include this, is superior in terms of hardware simplicity and calculation speed.

なお以上は、本発明の一実施例を示したもので
本発明は以上の実施例に限定されるものではな
い。
Note that the above is one embodiment of the present invention, and the present invention is not limited to the above embodiment.

例えば、本実施例の指数部および仮数部のビツ
ト幅をそれぞれ7ビツトおよび56ビツトとしたが
これは一例であり、何もこれに限定される必要は
ない。
For example, in this embodiment, the bit widths of the exponent part and the mantissa part are 7 bits and 56 bits, respectively, but this is just an example, and there is no need to be limited thereto.

また本実施例においては指数部は16の冪算を指
定するとしたがこれも一例を示したもので、例え
ば2の冪乗を指定するようにすることもできる。
Further, in this embodiment, the exponent part specifies a power of 16, but this is also an example, and it is also possible to specify a power of 2, for example.

勿論これらに応じて、各レジスタのビツト幅、
指数部演算回路4、指数発生回路10および第4
選択回路12に用いられる各パラメータを適当に
選定する必要がある。
Of course, depending on these, the bit width of each register,
Exponent calculation circuit 4, exponent generation circuit 10 and fourth
It is necessary to appropriately select each parameter used in the selection circuit 12.

(発明の効果) 以上のように本発明を用いると、固定小数点数
から浮動小数点数に変換する場合および浮動小数
点数から固定小数点数に変換する場合特に浮動小
数点演算に用いる一般的演算回路と共用する場合
において、2進補数から絶対値に、また絶対値か
ら2進補数への変換に−1演算回路を用いて処
理することによりハードウエアが簡単になり処理
速度の向上した演算装置を提供できる。
(Effects of the Invention) As described above, when the present invention is used, when converting from a fixed-point number to a floating-point number and from a floating-point number to a fixed-point number, it can be used in common with a general arithmetic circuit used for floating-point arithmetic. In this case, by using a -1 arithmetic circuit to convert from a binary complement to an absolute value and from an absolute value to a binary complement, the hardware can be simplified and an arithmetic device with improved processing speed can be provided. .

これにより演算装置の性能向上が達成できる。 This makes it possible to improve the performance of the arithmetic device.

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

第1図は本発明の一実施例を示すブロツク図お
よび第2図は従来例を示すブロツク図である。 図において、1…入力符号レジスタ、2……入
力指数部レジスタ、3……入力仮数部レジスタ、
4……指数部演算回路、5……シフト回路、6…
…浮動/固定指示回路、7……第1選択回路、8
……−1演算回路、9……第2選択回路、10
……指数発生回路、11……第3選択回路、12
……第4選択回路、13……出力符号レジスタ、
14……出力指数部レジスタ、15……出力仮数
部レジスタ。
FIG. 1 is a block diagram showing one embodiment of the present invention, and FIG. 2 is a block diagram showing a conventional example. In the figure, 1...input sign register, 2...input exponent register, 3...input mantissa register,
4... Exponent calculation circuit, 5... Shift circuit, 6...
...Floating/fixed instruction circuit, 7...First selection circuit, 8
...-1 arithmetic circuit, 9... second selection circuit, 10
...Exponent generation circuit, 11...Third selection circuit, 12
...Fourth selection circuit, 13...Output sign register,
14...Output exponent register, 15...Output mantissa register.

Claims (1)

【特許請求の範囲】 1 固定小数点数から浮動小数点数および浮動小
数点数から固定小数点数に変換する機能を有する
演算装置において、 変換すべき入力数情報を格納する入力レジスタ
と、 入力浮動小数点数の指数部に特定の演算を施こ
して出力する指数部演算回路と、 前記入力レジスタの出力に対し前記指数部演算
回路の出力に応ずるシフトを行ない結果を出力す
るシフト回路と、 固定小数点数から浮動小数点数への変換かまた
は浮動小数点数から固定小数点数への変換かに応
じて前記入力レジスタの出力かまたは前記シフト
回路の出力かを選択する第1の選択回路と、 前記第1の選択回路の出力から1を減算し結果
の各桁のビツトを反転して出力する−1演算回
路と、 前記変換すべき入力情報の正負に応じて前記第
1の選択回路の出力かまたは前記−1演算回路
の出力かを選択する第2の選択回路と を含むことを特徴とする演算装置。
[Scope of Claims] 1. In an arithmetic unit having a function of converting from a fixed point number to a floating point number and from a floating point number to a fixed point number, an input register that stores information on the number of inputs to be converted; an exponent calculation circuit that performs a specific operation on the exponent part and outputs the result; a shift circuit that performs a shift on the output of the input register according to the output of the exponent calculation circuit and outputs the result; a first selection circuit that selects the output of the input register or the output of the shift circuit depending on whether the conversion is to a decimal point number or from a floating point number to a fixed point number; and the first selection circuit. a -1 arithmetic circuit that subtracts 1 from the output of the output, inverts the bits of each digit of the result, and outputs the result; and a second selection circuit that selects an output of the circuit.
JP59197421A 1984-09-20 1984-09-20 Arithmetic device Granted JPS6175431A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP59197421A JPS6175431A (en) 1984-09-20 1984-09-20 Arithmetic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP59197421A JPS6175431A (en) 1984-09-20 1984-09-20 Arithmetic device

Publications (2)

Publication Number Publication Date
JPS6175431A JPS6175431A (en) 1986-04-17
JPH0381174B2 true JPH0381174B2 (en) 1991-12-27

Family

ID=16374234

Family Applications (1)

Application Number Title Priority Date Filing Date
JP59197421A Granted JPS6175431A (en) 1984-09-20 1984-09-20 Arithmetic device

Country Status (1)

Country Link
JP (1) JPS6175431A (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Also Published As

Publication number Publication date
JPS6175431A (en) 1986-04-17

Similar Documents

Publication Publication Date Title
US4807172A (en) Variable shift-count bidirectional shift control circuit
EP0328063B1 (en) Absolute value calculating circuit having a single adder
EP0136834B1 (en) A digital circuit performing an arithmetic operation with an overflow
EP0472139B1 (en) A floating-point processor
JPH0776911B2 (en) Floating point arithmetic unit
KR960003044B1 (en) Numerical expression converter and vector processor unit using the same
KR100302093B1 (en) How to multiply the binary input signal with the tap coefficient in the crossover digital finite impulse response filter and design the circuit arrangement and crossover digital filter
US4878192A (en) Arithmetic processor and divider using redundant signed digit arithmetic
JP2511527B2 (en) Floating point arithmetic unit
US4866655A (en) Arithmetic processor and divider using redundant signed digit
JPH07234778A (en) Arithmetic circuit
US5148161A (en) Digital signal processor for fixed and floating point data
JPH0381174B2 (en)
US4737925A (en) Method and apparatus for minimizing a memory table for use with nonlinear monotonic arithmetic functions
JPH0519170B2 (en)
JP2509279B2 (en) Floating point number-fixed point number converter
JP2578482B2 (en) Floating point arithmetic unit
JPH0677734A (en) Fm demodulator
JP3074958B2 (en) Serial multiplier with addition function
SU1522197A1 (en) Device for calculation of cosine of a number
JP2890412B2 (en) Code conversion circuit
US5483477A (en) Multiplying circuit and microcomputer including the same
JP2685466B2 (en) Address calculator
JPH05100825A (en) Normalization floating point adder/subtracter
JP2956252B2 (en) 4-point interpolation circuit