JP2664750B2 - Arithmetic device and arithmetic processing method - Google Patents

Arithmetic device and arithmetic processing method

Info

Publication number
JP2664750B2
JP2664750B2 JP63326451A JP32645188A JP2664750B2 JP 2664750 B2 JP2664750 B2 JP 2664750B2 JP 63326451 A JP63326451 A JP 63326451A JP 32645188 A JP32645188 A JP 32645188A JP 2664750 B2 JP2664750 B2 JP 2664750B2
Authority
JP
Japan
Prior art keywords
dividend
bit
divisor
value
quotient
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
JP63326451A
Other languages
Japanese (ja)
Other versions
JPH02171828A (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.)
Toshiba Corp
Original Assignee
Toshiba 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 Toshiba Corp filed Critical Toshiba Corp
Priority to JP63326451A priority Critical patent/JP2664750B2/en
Priority to US07/455,236 priority patent/US5097435A/en
Priority to KR1019890019415A priority patent/KR0169264B1/en
Publication of JPH02171828A publication Critical patent/JPH02171828A/en
Application granted granted Critical
Publication of JP2664750B2 publication Critical patent/JP2664750B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Description

【発明の詳細な説明】 [発明の目的] (産業上の利用分野) 本発明は、減算シフト型除算アルゴリズムを用いて除
算を行なう演算装置及び演算処理方法に係わり、特に符
号付き除数及び除数の演算が可能な演算処理装置及び演
算処理方法に関する。
Description: Object of the Invention (Industrial application field) The present invention relates to an arithmetic unit and an arithmetic processing method for performing division using a subtraction shift type division algorithm, and in particular, to signed divisors and divisors. The present invention relates to an arithmetic processing device and an arithmetic processing method capable of performing calculations.

(従来の技術) 従来より、高速除算が可能な演算処理方式として演算
シフト型アルゴリズムが知られている(例えば、堀越著
「コンピュータの高速演算方式」、近代科学社、198
0)。第5図にこの方式に基づく演算装置の回路構成例
を示す。この演算装置は、被除数32ビット、除数16ビッ
トの演算を対象としたもので、商16ビット、剰余16ビッ
トの演算結果を算出できる。
(Prior Art) Conventionally, an operation shift type algorithm has been known as an operation processing method capable of high-speed division (for example, Horikoshi “High-speed operation method of computer”, Kindai Kagakusha, 198).
0). FIG. 5 shows an example of a circuit configuration of an arithmetic unit based on this method. This arithmetic device is intended for a 32-bit dividend and a 16-bit divisor, and can calculate a 16-bit quotient and a 16-bit remainder operation result.

被除数レジスタ501には、初期値として32ビットの被
除数の絶対値が格納され延算の過程で途中結果が順次格
納される。シフタ502は被除数レジスタ501に格納された
値を1ビット上位ビット側にシフトして出力するか、或
は被除算レジスタ501の値をそのまま通過させる。一
方、除数レジスタ503には16ビットの除数の絶対値が格
納される。シフタ504は、除数レジスタ503に格納された
16ビットの除数を被除数のビット数と除数ビット数との
差のビット数、即ち16ビットだけ上位ビット側にシフト
してその値を固定する。シフタ502及び504からの各32ビ
ットの出力は、減算器505の第1及び第2のポートにそ
れぞれ入力されている。減算器505は、(シフタ502出
力)−(シフタ504出力)の演算を行なう。その際、演
算結果が0になったことを示すゼロフラグと、ボローの
発生の有無を示す信号とは、商検出回路506に与えられ
る。商検出回路506は、これらの情報に基づいて商ビッ
トを決定し、それをシフトレジスタ507に1ビットずつ
格納する。セレクタ508は、上記決定された商ビットに
基づいて減算器505の出力とシフタ502の出力のいずれか
一方を選択し、被除数レジスタ501に格納する。なお、
制御回路509は、これら各部を制御して繰返し演算の実
行を司る。
The dividend register 501 stores the 32-bit absolute value of the dividend as an initial value, and sequentially stores intermediate results in the course of the extension. The shifter 502 shifts the value stored in the dividend register 501 to the upper bit side by one bit and outputs it, or passes the value of the dividend register 501 as it is. On the other hand, the divisor register 503 stores the absolute value of the 16-bit divisor. The shifter 504 is stored in the divisor register 503.
The 16-bit divisor is shifted to the upper bit side by the number of bits of the difference between the number of bits of the dividend and the number of divisor bits, that is, 16 bits, and the value is fixed. The 32-bit outputs from the shifters 502 and 504 are input to the first and second ports of the subtractor 505, respectively. The subtractor 505 performs the operation of (output of shifter 502) − (output of shifter 504). At this time, a zero flag indicating that the operation result has become 0 and a signal indicating whether or not a borrow has occurred are supplied to the quotient detection circuit 506. The quotient detection circuit 506 determines a quotient bit based on these pieces of information, and stores the bit in the shift register 507 one bit at a time. The selector 508 selects one of the output of the subtracter 505 and the output of the shifter 502 based on the determined quotient bit, and stores it in the dividend register 501. In addition,
The control circuit 509 controls these units to execute repetitive operations.

次にこのように構成された演算装置を用いた除数手順
のうち、特に符号付き除算の手順について説明する。
Next, among the divisor procedures using the arithmetic unit configured as described above, a signed division procedure will be described in particular.

まず、図示しないメモリから被除数を読出し、その
絶対値を求めて被除数レジスタ501に格納する。
First, the dividend is read from a memory (not shown), and its absolute value is obtained and stored in the dividend register 501.

次に除数についても同様にメモリからの読出しを行
ない、その絶対値を求めて除数レジスタ503に格納す
る。
Next, the divisor is similarly read from the memory, and its absolute value is obtained and stored in the divisor register 503.

除数レジスタ503に格納された除数の絶対値(16ビ
ット)を、シフタ504で16ビット上位ビット側へシフト
し、被除数レジスタ501に格納されている被除数の絶対
値から上記シフトした値を減算する。
The absolute value (16 bits) of the divisor stored in the divisor register 503 is shifted to the upper 16 bits by the shifter 504, and the shifted value is subtracted from the absolute value of the dividend stored in the dividend register 501.

この演算結果が0以上の場合は、求めようとする商
が17ビット以上となるので、オーバーフローとなる。し
たがって、減算器505からゼロフラグが立った場合、及
びボローが起きなかった場合には、オーバーフローとし
てこの時点で演算を中止する。
If the result of this operation is 0 or more, the quotient to be obtained becomes 17 bits or more, so that an overflow occurs. Therefore, when the zero flag is set from the subtractor 505 and when no borrow occurs, the operation is stopped at this point as an overflow.

被除数レジスタ501に格納された数値をシフタ502で
1ビット上位側にシフトして、減算器505の一方の入力
ポートに与え、その値からシフタ504の出力である16ビ
ット除数をシフトした値を減算する。減算器505の減算
結果が0であるか又はボローの発生がないときには、商
ビット=1、減算器505の減算の結果、ボローが発生し
たときには商ッビット=0とする。算出された商ビット
はシフトレジスタ507の最下位ビットにシフトインされ
る。商ビット=1の場合には、セレクタ508で減算器505
の減算結果を選択し、被除数レジスタ501に格納する。
商ビット=0の場合には、セレクタ508でシフタ502の出
力を選択し、被除数レジスタ501に格納する。
The value stored in the dividend register 501 is shifted to the upper side by one bit by a shifter 502, applied to one input port of a subtractor 505, and a value obtained by shifting a 16-bit divisor output from the shifter 504 is subtracted from the value. I do. When the subtraction result of the subtracter 505 is 0 or no borrow occurs, the quotient bit is set to 1; when the subtraction of the subtractor 505 generates a borrow, the quotient bit is set to 0. The calculated quotient bit is shifted into the least significant bit of shift register 507. When the quotient bit = 1, the selector 508 uses the subtractor 505
Is selected and stored in the dividend register 501.
When the quotient bit = 0, the output of the shifter 502 is selected by the selector 508 and stored in the dividend register 501.

以上の処理を16回繰返す。これにより16ビットの
商がシフトレジスタ507に求まり、16ビットの剰余が被
除数レジスタ501の上位16ッビットに求められる。
The above process is repeated 16 times. As a result, a 16-bit quotient is obtained in the shift register 507, and a 16-bit remainder is obtained in the upper 16 bits of the dividend register 501.

商は絶対値形式で求まっているので、被除数、除数
の符号に従って符号を補正する。補正した結果、符号が
矛盾していればオーバーフローと判定する。
Since the quotient is obtained in the absolute value format, the sign is corrected according to the signs of the dividend and the divisor. If the codes are inconsistent as a result of the correction, it is determined that an overflow has occurred.

同じく剰余も絶対値形式で求まっているので、被除
数、除数の符号に従って符号を補正する。
Similarly, since the remainder is obtained in the absolute value format, the sign is corrected according to the signs of the dividend and the divisor.

ところで、上記の除算処理に要する全クロック数は、
次のようになる。
By the way, the total number of clocks required for the above division processing is
It looks like this:

全クロック数 =繰返し処理に要するクロック数×繰返し回数 +絶対値を求めるのに要するクロック数×2 +符号を補正するのに要するクロック数×2 ここで、もし繰返し処理におけるシフト処理をALU
(算術論理演算ユニット)で行なうとすれば、繰返しに
要するクロック数が3〜4クロックとなり、全処理クロ
ック数の大部分が、この繰返し処理のクロック数で占め
られてしまう。しかしながら、上述した回路は、繰返し
におけるシフト処理がハードウェア化されているので、
1回の繰返しに要するクロック数を1クロックにまで短
縮することができ、繰返し処理の高速化を図ることがで
きる。
The total number of clocks = the number of clocks required for the repetition processing × the number of repetitions + the number of clocks required for obtaining the absolute value × 2 + the number of clocks required for correcting the sign × 2 Here, if the shift processing in the repetition processing is ALU
If it is performed by the (arithmetic logic operation unit), the number of clocks required for repetition is 3 to 4 clocks, and most of the total number of processing clocks is occupied by the number of clocks for this repetition processing. However, in the above-described circuit, since the shift processing in the repetition is implemented by hardware,
The number of clocks required for one repetition can be reduced to one clock, and the repetition processing can be sped up.

しかしながら、従来の方式では符号付き除算の際に上
記の繰返し処理の他にその前処理及び後処理、即ち被除
数と除数の絶対値を求めてから必要な繰返し処理を開始
し、最後に商と剰余の符号合せを行なうといったオーバ
ーヘッド(無駄時間)が存在するので、上記のように除
算を高速化するシフト処理のハードウェア化等で1回の
繰返し演算にかかるクロック数を短縮しても、これらの
オーバーヘッドに費やす時間によって全処理クロック数
は思った程には短縮できないという問題がある。このた
め、従来はハードウェア投資に見合った十分な速度向上
を図ることができなかった。
However, in the conventional method, in addition to the above-mentioned repetition processing at the time of signed division, the necessary repetition processing is started after obtaining the absolute values of the dividend and divisor, and finally the quotient and the remainder are obtained. Even if the number of clocks required for one repetitive operation is reduced by hardware such as shift processing for speeding up division as described above, these overheads (dead time) exist. There is a problem that the total number of processing clocks cannot be reduced as expected due to the time spent on overhead. For this reason, conventionally, it was not possible to achieve a sufficient speed increase corresponding to the hardware investment.

したがって、除算を高速化するには、繰返し演算に必
要な時間を短縮するだけでなく、これらのオーバーヘッ
ドを短縮することが重要になる。
Therefore, in order to speed up the division, it is important not only to reduce the time required for the repetitive operation but also to reduce these overheads.

(発明が解決しようとする課題) このように、減算シフト型アルゴリズムを用いた従来
の演算方式では、被除数及び除数の絶対値化、及び求め
られた商及び剰余の符号補正処理に時間がかかり、除算
処理の高速化が妨げられるという問題があった。
(Problems to be Solved by the Invention) As described above, in the conventional operation method using the subtraction shift type algorithm, it takes time to convert the dividend and the divisor into absolute values and to perform the sign correction processing of the obtained quotient and remainder. There has been a problem that speeding up of the division process is hindered.

本発明は、上記問題に鑑みなされたもので、繰返し演
算に必要な時間のみならず、その前処理及び後処理のオ
ーバーヘッドも削減し、十分な速度向上を図ることが可
能な演算装置及び演算処理方法を提供することを目的と
する。
The present invention has been made in view of the above problems, and has an arithmetic device and an arithmetic processing method capable of reducing not only the time required for the repetitive operation but also the overhead of pre-processing and post-processing thereof and achieving a sufficient speed improvement. The aim is to provide a method.

[発明の構成] (課題を解決するための手段) 本発明は、減算シフト型除算アルゴリズムを用いて符
号付き被除数と符号付き除数との間の商及び剰余を求め
る演算処理方法において、被除数及び除数の絶対値は求
めずに、被除数及び除数をそのまま演算処理の入力値と
して与え、被除数及び除数の符号ビットが同じである場
合は減算の繰返し、異なる場合は加算の繰返しにより演
算を進めていくことを特徴としている。
[Means for Solving the Problems] The present invention relates to an arithmetic processing method for obtaining a quotient and a remainder between a signed dividend and a signed divisor using a subtraction shift type division algorithm. Without calculating the absolute value of, the dividend and divisor are given as they are as the input values of the arithmetic processing, and if the sign bits of the dividend and divisor are the same, the subtraction is repeated, and if they are different, the operation is repeated by repeating the addition. It is characterized by.

即ち、本発明では、前記被除数又は演算の途中結果を
第1の入力値とし、前記被除数のビット数と前記除数の
ビット数との差のビット数分だけ前記除数を上位ビット
側にシフトした値を第2の入力値とし、前記被除数と除
数とが同一符号である場合には、前記第1の入力値と第
2の入力値との間の減算を行ない、前記被除数と除数と
が異符号である場合には、前記第1の入力値と第2の入
力値との間の加算を行ない、少なくとも前記減算若しく
は加算結果が0であるかどうか、キャリー若しくはボロ
ーの発生の有無、及び前記被除数の符号に基づいて商ビ
ットを決定するステップを所定回数繰返す。この繰返し
の過程において、前記被除数を前記第1の入力値の初期
値として与え、前記決定された商ビットが第1の値であ
る場合には前記演算結果を1ビット上位ビット側にシフ
トした値を前記第1の入力値として与え、決定された商
ビットが第2の値である場合には前記第1の入力値を1
ビット上位ビット側にシフトした値を与える。
That is, in the present invention, a value obtained by shifting the divisor to the higher-order bits by the number of bits of the difference between the number of bits of the dividend and the number of bits of the divisor, using the dividend or an intermediate result of the operation as a first input value. Is the second input value, and when the dividend and the divisor have the same sign, subtraction is performed between the first input value and the second input value, and the dividend and the divisor have different signs. , The addition between the first input value and the second input value is performed, at least whether the subtraction or addition result is 0, whether a carry or a borrow occurs, and the dividend The step of determining the quotient bit based on the sign of is repeated a predetermined number of times. In this iterative process, the dividend is given as an initial value of the first input value, and when the determined quotient bit is the first value, the operation result is shifted to the upper bit side by one bit. Is given as the first input value, and when the determined quotient bit is the second value, the first input value is set to 1
Give the value shifted to the higher bit side of the bit.

(作用) 本発明によれば、被除数及び除数の絶対値を求めず
に、そのまま演算処理に用いるようにしているので、繰
返しの前処理として被除数及び除数の絶対値を求めると
いう操作を省略できる。また、この発明によれば、演算
処理が符号付きで行われるため、剰余も符号付きで求め
られ、この符号補正のための手続きも省略することがで
きる。このように本発明によれば繰返し演算の前処理及
び後処理のオーバーヘッドを大幅に削減することができ
るので、ハードウェア化による利点が十分に生かされ、
除算処理の大幅な高速化を図ることができる。
(Operation) According to the present invention, since the absolute values of the dividend and the divisor are not determined, but are used as they are in the arithmetic processing, the operation of determining the absolute values of the dividend and the divisor as the repetitive preprocessing can be omitted. Further, according to the present invention, since the arithmetic processing is performed with a sign, the remainder is also obtained with a sign, and the procedure for this sign correction can be omitted. As described above, according to the present invention, the overhead of the pre-processing and post-processing of the repetitive operation can be significantly reduced, so that the advantages of hardware can be fully utilized,
The speed of the division process can be greatly increased.

(実施例) 以下、図面に基づいて本発明の好ましい実施例につい
て説明する。
Hereinafter, preferred embodiments of the present invention will be described with reference to the drawings.

第1図は本発明の一実施例に係る演算装置の構成を示
す図である。
FIG. 1 is a diagram showing a configuration of an arithmetic unit according to one embodiment of the present invention.

なお、この演算装置は、前述したものと同様、被除数
32ビット、除数16ビットの演算を対象としたもので、商
16ビット、剰余16ビットの演算結果を算出できるものと
する。
In addition, this arithmetic unit has a dividend
It targets 32-bit and 16-bit divisor operations.
It is assumed that a calculation result of 16 bits and a remainder of 16 bits can be calculated.

被除数レジスタ101には、初期値として32ビットの被
除数が格納され演算の過程で途中結果が順次格納され
る。格納される被除数は符号付き除算の場合には符号付
きのまま格納される。被除数の符号ビットは符号ビット
レジスタ102に格納される。シフタ103は被除数レジスタ
101に格納された値を1ビット上位ビットにシフトして
出力するか、或は被除数レジスタ101の値をそのまま通
過させる。一方、除数レジスタ104には16ビットの除数
が格納される。格納される除数も被除数と同様、符号付
き除算の場合には符号付きのまま格納される。除数の符
号ビットは符号ビットレジスタ105に格納される。シフ
タ106は、除数レジスタ104に格納された16ビットの除数
を被除数のビット数と除数のビット数との差のビット
数、即ち16ビットだけ上位ビット側にシフトしてその値
を固定する。補数器107は、被除数多び除数が同一符号
の場合にはシフタ106の出力を補数化し、異符号の場合
にはシフタ106の出力をそのまま通過させる。シフタ103
及び補数器107からの各32ビットの出力は、加算器108の
第1及び第2のポートにそれぞれ入力されている。加算
器108は、(シフタ103出力)+(補数器107出力)の演
算を行なう。その際、加算結果が0になったことを示す
ゼロフラグと、キャリーの発生の有無を示す信号とは、
商判定回路109に与えられる。また、商判定回路109に
は、符号ビットレジスタ102,105からの各符号ビット及
びシフタ103の桁溢れ出力も与えられている。商判定回
路109は、これらの情報に基づいて商ビットを決定し、
それをシフトレジスタ110に1ビットずつシフトインす
る。また、商判定回路109には、加算結果が0になった
とき1が立つALZEROフラグ120が設けられている。セレ
クタ111は、上記決定された商ビットに基づいて加算器1
08の出力とシフタ103の出力のいずれか一方を選択し、
被除数レジスタ101に格納する。また、制御回路112は、
これら各部を制御して繰返し演算の実行を司る。なお、
図示はしないが実際の回路では、この他に内部バス、各
レジスタ間のパス、汎用レジスタファイル等が適宜設け
られる。
The dividend register 101 stores a 32-bit dividend as an initial value, and sequentially stores intermediate results in the course of the operation. In the case of signed division, the dividend to be stored is stored as signed. The sign bit of the dividend is stored in the sign bit register 102. Shifter 103 is dividend register
The value stored in 101 is shifted to the upper bit by one bit and output, or the value of dividend register 101 is passed as it is. On the other hand, the divisor register 104 stores a 16-bit divisor. Like the dividend, the stored divisor is stored with a sign in the case of signed division. The sign bit of the divisor is stored in the sign bit register 105. The shifter 106 shifts the 16-bit divisor stored in the divisor register 104 by the number of bits of the difference between the number of bits of the dividend and the number of bits of the divisor, that is, by 16 bits, and fixes the value. The complementer 107 converts the output of the shifter 106 into a complement when the dividend and the divisor have the same sign, and passes the output of the shifter 106 as it is when the dividend and the divisor have different signs. Shifter 103
And the 32-bit output from the complementer 107 are input to the first and second ports of the adder 108, respectively. Adder 108 performs an operation of (output of shifter 103) + (output of complementer 107). At this time, a zero flag indicating that the addition result has become 0, and a signal indicating whether or not a carry has occurred are:
The quotient determination circuit 109 is provided. Further, the quotient determination circuit 109 is also provided with each sign bit from the sign bit registers 102 and 105 and the overflow output of the shifter 103. The quotient determination circuit 109 determines a quotient bit based on the information,
It is shifted into the shift register 110 one bit at a time. Further, the quotient determination circuit 109 is provided with an ALZERO flag 120 which becomes 1 when the addition result becomes 0. The selector 111 selects the adder 1 based on the determined quotient bit.
Select either the output of 08 or the output of shifter 103,
It is stored in the dividend register 101. Further, the control circuit 112
These parts are controlled to execute the repetitive operation. In addition,
Although not shown, in an actual circuit, an internal bus, a path between registers, a general-purpose register file, and the like are additionally provided as appropriate.

次にこのように構成された第1図に示す演算装置の処
理手順を第2図の流れ図(PAD図)に基づき説明する。
Next, the processing procedure of the arithmetic unit shown in FIG. 1 configured as described above will be described with reference to the flowchart (PAD diagram) of FIG.

第2図(a)はメインフローを示す図である。まず、
ALZEROフラグ120が0に初期化される。この演算装置は
符号付き除算、符号なし除算のいずれの演算を行なうこ
ともできる。そこで、次に符号付き演算であるかどうか
の判定が行われ、もし符号付き演算であるならば、被除
数と除数の符号を符号ビットレジスタ102,105にそれぞ
れ格納する。続いて、オーバーフローをチェックするた
めの演算1を実行する。
FIG. 2A shows the main flow. First,
The ALZERO flag 120 is initialized to 0. This arithmetic unit can perform either signed division or unsigned division. Then, it is next determined whether or not the operation is a signed operation. If the operation is a signed operation, the signs of the dividend and the divisor are stored in the sign bit registers 102 and 105, respectively. Subsequently, the operation 1 for checking the overflow is executed.

第2図(b)はオーバーフローチェックのための演算
1の処理手順を示す図である。まず、被除数レジスタ10
1に格納されている32ビットの被除数を加算器108の第1
のポートに与える。次に符号ビットレジスタ102,105の
値が参照され、被除数と除数とが同符号であれば、除数
レジスタ104に格納されている16ビットの除数がシフタ1
06によって上位ビット側に16ビットシフトされ、補数器
107によって補数化された後、加算器108の第2のポート
に与えられる。また、被除数と除数とが異符号であれ
ば、除数レジスタ104に格納されている16ビットの除数
がシフタ106によって上位ビット側に16ビットシフトさ
れ、補数器107をそのまま通過した後、加算器108の第2
のポートに与えられる。そして、加算器108により加算
が実行される。この関係を第3図で説明する。この装置
では、同図a,dのように被除数と除数とが同符号の場合
には減算、同図b,cのように被除数と除数とが異符号の
場合には加算をそれぞれ繰返すことにより絶対値の減算
が行なわれる。この実施例では演算手段として加算器10
8を用いているので、前者の場合には加算器を用いて減
算を行なえるように除数を補数化している。この演算の
結果、商ビット=1となると、商が17ビット以上のオー
バーフローと判定され処理は終了する。なお、商ビット
は次の基準で決定される。この基準は演算1のみならず
後述する演算2にも適用される。
FIG. 2 (b) is a diagram showing a processing procedure of the operation 1 for the overflow check. First, the dividend register 10
The 32-bit dividend stored in 1 is added to the first
Give to the port. Next, the values of the sign bit registers 102 and 105 are referred to. If the dividend and the divisor have the same sign, the shifter 1 stores the 16-bit divisor stored in the divisor register 104.
06 shifts 16 bits to the upper bit side and complements
After being complemented by 107, it is provided to a second port of adder 108. If the dividend and the divisor have different signs, the 16-bit divisor stored in the divisor register 104 is shifted by the shifter 106 to the higher-order bit by 16 bits and passed through the complementer 107 as it is. Second
Given to the port. Then, the adder 108 performs the addition. This relationship will be described with reference to FIG. In this device, subtraction is performed when the dividend and the divisor have the same sign as shown in FIGS. A and d, and addition is repeated when the dividend and the divisor have different signs as shown in FIGS. Absolute value subtraction is performed. In this embodiment, an adder 10 is used as arithmetic means.
Since 8 is used, the divisor is complemented so that subtraction can be performed using an adder in the former case. As a result of this operation, when the quotient bit = 1, the quotient is determined to be an overflow of 17 bits or more, and the process ends. The quotient bit is determined based on the following criteria. This criterion is applied not only to Operation 1 but also to Operation 2 described later.

演算結果が0:商ビット=1 符号つき除算の場合: 商ビット=被除数の符号.EXOR.キャリー 符号なし除算の場合: 商ビット =シフタ103の桁溢れ.OR.キャリー 上記は被除数を除数で丁度割切れたこを意味する。
また、について第3図を用いて説明すると、いま、商
ビット=1となるには、|被除数|>|除数|であるこ
とが必要である。被除数の符号が正(0)であるとする
と、商ビット=1となるべき被除数>|除数|のときに
キャリーが発生する。このため、第3図に示すように、
被除数の符号=0の場合、キャリー=1で商ビット=
1、キャリー=0の商ビット=0とする。また、被除数
の符号が負(1)であるとすると、商ビット=1となる
べき|被除数|>|除数|のときにキャリーは発生しな
い。従って、第3図に示すように、被除数の符号=1の
場合、キャリー=0で商ビット=1、キャリー=1で商
ビット=0とする。なお、このオーバーフローチェック
では、シフタ103のシフト動作をまだ行なっていないの
で、シフタの桁溢れはない。従って演算1ではの符号
なし除算の場合、キャリーのみ参照される。
When the operation result is 0: quotient bit = 1 For signed division: quotient bit = sign of dividend. EXOR. Carry For unsigned division: quotient bit = overflow of shifter 103. OR. Carry In the above, the dividend is exactly the divisor It means broken octopus.
Also, with reference to FIG. 3, in order for the quotient bit = 1, it is necessary that | dividend |> | divisor |. Assuming that the sign of the dividend is positive (0), a carry occurs when the dividend> | divisor |, which should satisfy quotient bit = 1, is satisfied. For this reason, as shown in FIG.
When the sign of the dividend = 0, carry = 1 and quotient bit =
1, quotient bit of carry = 0 = 0. Assuming that the sign of the dividend is negative (1), no carry occurs when | dividend |> | divisor | where the quotient bit should be 1. Therefore, as shown in FIG. 3, when the sign of the dividend = 1, the quotient bit = 1 when carry = 0 and the quotient bit = 0 when carry = 1. In the overflow check, since the shift operation of the shifter 103 has not been performed yet, there is no overflow of the shifter. Therefore, in the case of unsigned division in operation 1, only carry is referred to.

演算1が終了すると次に演算2の繰返し処理が行われ
る。この処理を第2図(c)に示す。この演算2では、
被除数レジスタ101の値をシフタ103で1ビット上位ビッ
ト側にシフトした値と、除数レジスタ104の値をシフタ1
06で上位ビット側に16ビットシフトして選択的に補数化
した値とを加算器108の入力ポートに与え、加算を実行
し、演算1で示した基準で商ビットを決定していく。決
定された商ビットはシフトレジスタ110の最下位ビット
にシフトインされる。商ビット=1の場合には、セレク
タ111で加算器108の加算結果を選択し、被除数レジスタ
101に格納する。商ビット=0の場合には、セレクタ111
でシフタ103の出力を選択し、被除数レジスタ101に格納
する。
When the operation 1 is completed, the operation 2 is repeated. This process is shown in FIG. In this operation 2,
The value of the dividend register 101 shifted to the upper bit side by one bit by the shifter 103 and the value of the divisor register 104 are
In step 06, a value which is shifted to the upper bit by 16 bits and selectively complemented is supplied to the input port of the adder 108, the addition is executed, and the quotient bit is determined based on the reference shown in the operation 1. The determined quotient bit is shifted into the least significant bit of the shift register 110. When the quotient bit = 1, the addition result of the adder 108 is selected by the selector 111 and the dividend register
Store in 101. When the quotient bit = 0, the selector 111
Select the output of the shifter 103 and store it in the dividend register 101.

なお、上記の基準はALZERO=0の場合にのみ適用され
る。もし演算結果が0となった場合には、ALZERO=1に
設定する。これにより、以後の繰返し演算では商ビット
は常に0とする。このALZEROフラグ120を用いることに
より、被除数が負の場合に、上記の判定基準で誤った商
ビットが出力されるのを防止することができる。
The above criterion is applied only when ALZERO = 0. If the calculation result becomes 0, ALZERO = 1 is set. Thus, the quotient bit is always set to 0 in the subsequent repetitive operations. By using the ALZERO flag 120, it is possible to prevent the wrong quotient bit from being output based on the above-described criterion when the dividend is negative.

この演算2を16回繰返すことにより16ビットの商がシ
フトレジスタ110に順次求まり、16ビットの剰余が被除
数レジスタ101の上位16ビットに求められる。このと
き、求められた商については絶対値表現となっている
が、剰余については、被除数を符号付きのまま演算に用
いているため符号付き表現となっている。このため剰余
の符号補正処理は省略できる。
By repeating this operation 2 16 times, a 16-bit quotient is sequentially obtained in the shift register 110, and a 16-bit remainder is obtained in the upper 16 bits of the dividend register 101. At this time, the obtained quotient is represented by an absolute value, but the remainder is represented by a sign because the dividend is used for the operation with the sign. For this reason, the remainder sign correction processing can be omitted.

演算2が終了すると第2図(a)に示すように、符号
付きの除算の場合、符号ビットレジスタ102,105に格納
されている符号ビットを参照し、被除数及び除数が異符
号である場合には、絶対値で求められている商の符号反
転処理を行なう。最後に被除数の符号、除数の符号及び
求められた商の符号に矛盾がないかどうかを調べ、矛盾
がある場合にはオーバーフローと判定し、矛盾がない場
合には正しい演算結果が求められたとして一連の処理を
終了する。
When the operation 2 is completed, as shown in FIG. 2 (a), in the case of signed division, reference is made to the code bits stored in the sign bit registers 102 and 105, and if the dividend and the divisor have different signs, Performs sign inversion processing of the quotient obtained by the absolute value. Finally, check whether the sign of the dividend, the sign of the divisor, and the sign of the obtained quotient are consistent.If there is a conflict, it is determined that an overflow has occurred.If there is no conflict, the correct operation result is determined. A series of processing ends.

このように、本実施例によれば、符号付き被除数、除
数をそのまま扱い、補数器107と加算器108とからなる演
算手段を用いて、被除数と除数とが同一符号である場合
には減算、異符号である場合には加算を行なっているの
で、繰返し演算の前処理を省略できる。また、求められ
た剰余は符号付きであるため、剰余の符号補正の後処理
も省略することができる。しかも繰返し演算処理は従来
と同様、ハードエェア化による高速化のメリットを十分
に発揮させて行なうことができる。この結果、ハードウ
ェアに見合った全体的な処理の高速化を図ることができ
る。
As described above, according to the present embodiment, the signed dividend and the divisor are handled as they are, and the arithmetic unit including the complementer 107 and the adder 108 is used to perform subtraction when the dividend and the divisor have the same sign. If the signs are different, addition is performed, so that the pre-processing of the repetitive operation can be omitted. In addition, since the obtained remainder is signed, post-processing of sign correction of the remainder can be omitted. In addition, the repetitive arithmetic processing can be performed by fully utilizing the merit of speeding up by hardware as in the related art. As a result, it is possible to speed up the overall processing corresponding to the hardware.

なお、本発明は上述した実施例に限定されるものでは
ない。上記実施例では、演算手段として補数器107と加
算器108とを用いたが、例えば補数器と減算器とを用い
るようにしても良い。この場合には、例えば第4図に示
すように、被除数と除数とが異符号のときのみ除数の補
数化を行ない、符号つき除算の場合、 商ビット =〜(被除数の符号.EXOR.ボロー) 但し、〜:否定 という基準で商ビットを決定するようにすれば良い。
The present invention is not limited to the embodiments described above. In the above-described embodiment, the complementer 107 and the adder 108 are used as the calculation means. However, for example, a complementer and a subtractor may be used. In this case, as shown in FIG. 4, for example, the divisor is complemented only when the dividend and the divisor have opposite signs. In the case of signed division, the quotient bit = 〜 (sign of dividend.EXOR. Borrow) However, the quotient bit may be determined based on the criterion of ~: negation.

[発明の効果] 以上述べたように、本発明によれば、符号付き除算の
被除数及び除数の絶対値は求めず、両者が同一符号であ
る場合には減算、異符号である場合には加算を行なうよ
うにしたので、従来必要であった繰返し演算前後のオー
バーヘッドが縮小され、ハードウェア量に見合った高速
化を図ることができる。
[Effects of the Invention] As described above, according to the present invention, the absolute values of the dividend and divisor of signed division are not obtained, and if both have the same sign, subtraction is performed, and if they have different signs, addition is performed. Is performed, the overhead required before and after the repetitive operation, which was conventionally required, is reduced, and the speed can be increased in proportion to the amount of hardware.

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

第1図は本発明の一実施例に係る減算シフト型アルゴリ
ズムに基づく演算装置のブロック図、第2図は同装置の
処理の流れ図、第3図は同装置の商ビット判定基準を示
す図、第4図は本発明の他の実施例に係る商ビット判定
基準を示す図、第5図は従来の減算シフト型アルゴリズ
ムに基づく演算装置のブロック図である。 101,501……被除算レジスタ、102,105……符号ビットレ
ジスタ、103,106,502,504……シフタ、104,503……除数
レジスタ、107……補数器、108……加算器、109……商
判定回路、110,507……シフトレジスタ、111,508……セ
レクタ、112,509……制御回路、505……減算器、506…
…商検出回路。
FIG. 1 is a block diagram of an arithmetic unit based on a subtraction shift type algorithm according to one embodiment of the present invention, FIG. 2 is a flowchart of the processing of the arithmetic unit, FIG. FIG. 4 is a diagram showing a quotient bit criterion according to another embodiment of the present invention, and FIG. 5 is a block diagram of an arithmetic unit based on a conventional subtraction shift type algorithm. 101,501… Divided register, 102,105… Sign bit register, 103,106,502,504… Shifter, 104,503… Divisor register, 107… Complementer, 108… Adder, 109… Division decision circuit, 110,507… Shift register, 111,508 ... selector, 112,509 ... control circuit, 505 ... subtractor, 506 ...
... Square detection circuit.

Claims (2)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】被除数及び演算の途中結果の数値を順次格
納する被除数記憶手段と、 前記被除数の符号ビットを格納する第1の符号ビット格
納手段と、 前記被除数記憶手段に格納された数値を1ビット上位ビ
ット側にシフトする第1のシフト手段と、 除数を格納する除数記憶手段と、 前記除数の符号ビットを格納する第2の符号ビット格納
手段と、 前記除数記憶手段に格納された除数を当該除数のビット
数と前記被除数のビット数との差のビット数分だけ上位
ビット側にシフトする第2のシフト手段と、 前記第1及び第2の符号ビット格納手段に格納された値
が同じ場合には、前記第1のシフト手段の出力と前記第
2のシフト手段の出力との間の演算を行ない、前記第1
及び第2の符号ビット格納手段に格納された値が異なる
場合には、前記第1のシフト手段の出力と前記第2のシ
フト手段の出力との間の加算を行なう演算手段と、 少なくとも前記演算手段の演算結果が0であるかどう
か、キャリー若しくはボローの発生の有無、及び前記第
1の符号ビット格納手段に格納されている符号ビットの
値に基づいて商ビットの値を決定する商判定手段と、 この商判定手段で決定された商ビットが第1の値である
場合には前記演算手段の演算結果を選択して前記被除数
記憶手段に格納し、前記商判定手段で決定された商ビッ
トが第2の値である場合には前記第1のシフト手段の出
力を選択して前記被除数記憶手段に格納する選択手段
と、 前記演算手段における演算を所定回数実行させるため前
記各手段を制御する制御手段とを具備したことを特徴と
する演算装置。
1. A dividend storage means for sequentially storing a dividend and a numerical value of an intermediate result of an operation; a first sign bit storage means for storing a code bit of the dividend; and a value stored in the dividend storage means being 1 A first shift unit that shifts to a higher bit side, a divisor storage unit that stores a divisor, a second code bit storage unit that stores code bits of the divisor, and a divisor stored in the divisor storage unit. The second shift means for shifting to the upper bits by the number of bits of the difference between the number of bits of the divisor and the number of bits of the dividend is the same as the value stored in the first and second sign bit storage means. In this case, an operation between the output of the first shift means and the output of the second shift means is performed, and
And if the values stored in the second sign bit storage means are different, an operation means for performing an addition between the output of the first shift means and the output of the second shift means; Quotient determining means for determining whether the operation result of the means is 0, whether or not a carry or borrow has occurred, and determining the value of the quotient bit based on the value of the sign bit stored in the first sign bit storage means And if the quotient bit determined by the quotient determination means is the first value, select the operation result of the operation means and store it in the dividend storage means; Is a second value, selecting means for selecting the output of the first shift means and storing it in the dividend storage means; and controlling the respective means for causing the arithmetic means to execute a predetermined number of calculations. System Arithmetic apparatus characterized by comprising a means.
【請求項2】減算シフト型除算アルゴリズムを用いて符
号付き被除数と符号付き除数との間の商及び剰余を求め
る演算処理方法において、 前記被除数又は演算の途中結果を第1の入力値とし、前
記被除数のビット数と前記除数のビット数との差のビッ
ト数分だけ前記除数を上位ビット側にシフトした値を第
2の入力値とし、前記被除数と除数とが同一符号である
場合には、前記第1の入力値と第2の入力値との間の減
算を行ない、前記被除数と除数とが異符号である場合に
は、前記第1の入力値と第2の入力値との間の加算を行
ない、少なくとも前記減算若しくは加算結果が0である
かどうか、キャリー若しくはボローの発生の有無、及び
前記被除数の符号に基づいて商ビットを決定するステッ
プを、 前記被除数を前記第1の入力値の初期値として与え、前
記決定された商ビットが第1の値である場合には前記演
算結果を1ビット上位ビット側にシフトした値を前記第
1の入力値として与え、決定された商ビットが第2の値
である場合には前記第1の入力値を1ビット上位ビット
側にシフトした値を与えつつ、所定回数繰返すことによ
り、前記商及び剰余を求めていくことを特徴とする演算
処理方法。
2. A method for calculating a quotient and a remainder between a signed dividend and a signed divisor using a subtraction shift type division algorithm, wherein the dividend or the intermediate result of the operation is used as a first input value, A value obtained by shifting the divisor toward the higher bits by the number of bits of the difference between the number of bits of the dividend and the number of bits of the divisor is used as a second input value, and when the dividend and the divisor have the same sign, A subtraction is performed between the first input value and the second input value, and when the dividend and the divisor have opposite signs, a difference between the first input value and the second input value is calculated. Performing the addition, and determining at least whether the subtraction or addition result is 0, whether or not a carry or a borrow has occurred, and the sign of the dividend; and setting the dividend to the first input value. Early When the determined quotient bit is the first value, a value obtained by shifting the operation result to the upper bit side by 1 bit is provided as the first input value, and the determined quotient bit is the second input value. And calculating the quotient and the remainder by repeating the predetermined number of times while giving a value obtained by shifting the first input value to the upper bit side by one bit.
JP63326451A 1988-12-24 1988-12-24 Arithmetic device and arithmetic processing method Expired - Fee Related JP2664750B2 (en)

Priority Applications (3)

Application Number Priority Date Filing Date Title
JP63326451A JP2664750B2 (en) 1988-12-24 1988-12-24 Arithmetic device and arithmetic processing method
US07/455,236 US5097435A (en) 1988-12-24 1989-12-22 High speed dividing apparatus
KR1019890019415A KR0169264B1 (en) 1988-12-24 1989-12-23 An operation apparatus and method thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP63326451A JP2664750B2 (en) 1988-12-24 1988-12-24 Arithmetic device and arithmetic processing method

Publications (2)

Publication Number Publication Date
JPH02171828A JPH02171828A (en) 1990-07-03
JP2664750B2 true JP2664750B2 (en) 1997-10-22

Family

ID=18187955

Family Applications (1)

Application Number Title Priority Date Filing Date
JP63326451A Expired - Fee Related JP2664750B2 (en) 1988-12-24 1988-12-24 Arithmetic device and arithmetic processing method

Country Status (1)

Country Link
JP (1) JP2664750B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2984463B2 (en) * 1991-06-24 1999-11-29 株式会社日立製作所 Microcomputer
CN111309286B (en) * 2020-01-20 2023-03-28 西安电子科技大学 Data processing method for digital modular arithmetic and digital modular arithmetic circuit

Also Published As

Publication number Publication date
JPH02171828A (en) 1990-07-03

Similar Documents

Publication Publication Date Title
JP3418460B2 (en) Double precision division circuit and method
JP2835153B2 (en) High radix divider
US7016930B2 (en) Apparatus and method for performing operations implemented by iterative execution of a recurrence equation
JPH10500513A (en) Digital division execution unit
JPS63123125A (en) Floating point adder
JPH04270415A (en) High-performance adder
JPH0479015B2 (en)
JP2664750B2 (en) Arithmetic device and arithmetic processing method
JPH0546363A (en) Divider
JPH0346024A (en) Floating point computing element
JPS608933A (en) Arithmetic processing unit
US4870606A (en) Trigonometric function preprocessing system
JP3517162B2 (en) Division and square root arithmetic unit
JP2591250B2 (en) Data processing device
JP3205020B2 (en) Arithmetic unit
JP2615746B2 (en) Bit operation circuit
JPH0553759A (en) Fixed decimal point arithmetic unit
JP2856791B2 (en) Barrel shifter and floating point unit
JP2903529B2 (en) Vector operation method
JPH02166517A (en) Division system
JPH04160533A (en) Microprocessor
JPH01224833A (en) Floating point arithmetic system
JPS6051132B2 (en) Overrun correction method
JPH02178833A (en) Adder for adding data different in bit length
JP2001188670A (en) Arithmetic unit

Legal Events

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