JP2605715B2 - Division circuit - Google Patents

Division circuit

Info

Publication number
JP2605715B2
JP2605715B2 JP62114124A JP11412487A JP2605715B2 JP 2605715 B2 JP2605715 B2 JP 2605715B2 JP 62114124 A JP62114124 A JP 62114124A JP 11412487 A JP11412487 A JP 11412487A JP 2605715 B2 JP2605715 B2 JP 2605715B2
Authority
JP
Japan
Prior art keywords
value
dividend
shift register
divisor
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
JP62114124A
Other languages
Japanese (ja)
Other versions
JPS63278141A (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.)
Panasonic Holdings Corp
Original Assignee
Matsushita Electric Industrial 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 Matsushita Electric Industrial Co Ltd filed Critical Matsushita Electric Industrial Co Ltd
Priority to JP62114124A priority Critical patent/JP2605715B2/en
Publication of JPS63278141A publication Critical patent/JPS63278141A/en
Application granted granted Critical
Publication of JP2605715B2 publication Critical patent/JP2605715B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Description

【発明の詳細な説明】 産業上の利用分野 本発明は符号なし整数の除算を行う除算回路に関する
ものである。
Description: BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a division circuit for dividing an unsigned integer.

従来の技術 従来の除算回路の構成図を第4図に示す。2. Description of the Related Art FIG. 4 shows a configuration diagram of a conventional division circuit.

2は除算演算の開始時に被除数を入力して演算中は部
分剰余を、演算終了時には演算結果の余りを保持する被
除数レジスタ、3は除数を入力し保持する除数レジス
タ、12は被除数レジスタ2の値と除数レジスタ3の値と
の加算あるいは減算を行う演算回路、19は演算回路12の
演算を示す演算フラグ、13は演算回路12のキャリー出力
を保持するキャリフラグ、20は演算回路12の出力を被除
数レジスタ2に入力する時に左に1ビットシフトするシ
フタ、10は部分商を保持し、演算終了時には演算結果の
商を保持する部分商レジスタ、11はキャリフラグ13より
次の演算フラグを生成する演算制御回路、18は除算演算
処理を制御するタイミング制御回路、21はデータの入出
力を行う入出力データバスである。
2 is a dividend input at the start of the division operation and a partial remainder during the operation, and a dividend register holding the remainder of the operation result at the end of the operation, 3 is a divisor register that inputs and holds the divisor, and 12 is a value of the dividend register 2 An arithmetic circuit for performing addition or subtraction of the arithmetic circuit 12 and the value of the divisor register 3; 19, an arithmetic flag indicating the arithmetic operation of the arithmetic circuit 12, 13 a carry flag for holding the carry output of the arithmetic circuit 12, and 20 an output of the arithmetic circuit 12. A shifter that shifts one bit to the left when inputting to the dividend register 2, 10 holds a partial quotient, and a partial quotient register that holds the quotient of the operation result at the end of the operation. 11 generates a next operation flag from the carry flag 13. An operation control circuit, 18 is a timing control circuit for controlling the division operation processing, and 21 is an input / output data bus for inputting / outputting data.

以上のように構成された従来の除算の除算回路につい
て、以下にその動作を説明する。
The operation of the conventional division circuit configured as above will be described below.

除算の始めに、被除数及び除数をそれぞれ被除数レジ
スタ2と除数レジスタ3に入力し、演算フラグ19を1に
設定する。
At the beginning of the division, the dividend and the divisor are input to the dividend register 2 and the divisor register 3, respectively, and the operation flag 19 is set to 1.

演算回路12において、演算フラグ19が0のときは被除
数レジスタ2と除数レジスタ3の加算を、演算フラグ19
が1のときは被除数レジスタ2から除数レジスタ3の減
算を行う。演算回路12の加減算の結果によりオーバーフ
ローが発生した場合は、キャリフラグ13を1に、オーバ
ーフローが発生しない場合は、0に設定する。このキャ
リフラグ13を部分商レジスタ10の右入力より入力し、部
分商レジスタ10の内容を左に1ビットシフトする。さら
にキャリフラグ13は演算制御回路11を通して、演算フラ
グ19に入力される。演算回路12の出力はシフタ20を通し
て左に1ビットシフトし被除数レジスタ2に入力され
る。
In the arithmetic circuit 12, when the arithmetic flag 19 is 0, the addition of the dividend register 2 and the divisor register 3 is performed.
Is 1, subtraction of the divisor register 3 from the dividend register 2 is performed. The carry flag 13 is set to 1 when an overflow occurs as a result of the addition and subtraction of the arithmetic circuit 12, and is set to 0 when no overflow occurs. The carry flag 13 is input from the right input of the partial quotient register 10, and the contents of the partial quotient register 10 are shifted one bit to the left. Further, the carry flag 13 is input to the operation flag 19 through the operation control circuit 11. The output of the arithmetic circuit 12 is shifted one bit to the left through the shifter 20 and input to the dividend register 2.

以上の加減算およびシフトは、除数のビット長+1回
繰り返される。
The above addition, subtraction and shift are repeated by the bit length of the divisor +1 times.

演算の結果、商は商レジスタ10に、余りは被除数レジ
スタ2に設定される。
As a result of the operation, the quotient is set in the quotient register 10 and the remainder is set in the dividend register 2.

(「コンピュータの高速演算方式」近代科学社、堀越彌
監訳 P.214〜224)。
("Computer high-speed computing method", modern science company, edited by Yasushi Horikoshi, pp. 214-224).

発明が解決しようとする問題点 しかしながら上記のような構成では、被除数及び除数
の内容にかかわらず処理に要する加減算及びシフトは除
数のビット長+1回繰り返されるため、除算に要する演
算時間が長いという問題点を有していた。
Problems to be Solved by the Invention However, in the above configuration, the addition / subtraction and shift required for the process are repeated +1 times the bit length of the divisor irrespective of the contents of the dividend and the divisor, so that the operation time required for the division is long. Had a point.

本発明はかかる点に鑑み、被除数又は除数の内容によ
って除算に要する演算時間の短縮が可能な除算回路を提
供することを目的とする。
In view of the above, an object of the present invention is to provide a division circuit capable of reducing the operation time required for division depending on the contents of a dividend or a divisor.

問題点を解決するための手段 本発明はnビットの被除数をnビットの除数で割る除
算回路において、被除数及び除数の最もMSB側にある
“1"のビット位置を0からn−1までの値で出力し、入
力の全てのビットが“0"のときはnを出力するプライオ
リティエンコーダと、被除数を前記プライオリティエン
コーダに入力して得られる第一の値から除数を前記プラ
イオリティエンコーダに入力して得られる第二の値を減
じるかまたは前記第二の値から前記第一の値を減じた値
を第三の値とし、nから前記第三の値を減じた値を第四
の値とし、被除数を下位側に入力し前記第四の値に等し
いビット数だけ左シフトする2nビット幅のバレルシフタ
と、前記バレルシフタの上位nビットの出力を受け、演
算の1処理ステップにつき1ビット左シフトする第一シ
フトレジスタと、前記バレルシフタの下位nビットの出
力を受け、演算の1処理ステップにつき1ビット左シフ
トし、MSBからのシフトあふれを前記第一シフトレジス
タLSBへのシフト入力とする第二シフトレジスタと、前
記第二シフトレジスタの値と除数との間で加減算を行
い、MSBからのキャリを前記第二シフトレジスタのLSBへ
のシフト入力とする演算回路と、前記第三の値を初期値
として演算の1処理ステップにつき1を減じるカウンタ
と、前記第二の値がnならば零除算フラグをセットして
処理を終了し、前記第二の値が0ならば0を第一シフト
レジスタに被除数を第二シフトレジスタにそれぞれセッ
トして処理を終了し、前記第四の値がnより大きければ
被除数を第一シフトレジスタに0を第二シフトレジスタ
にそれぞれセットして処理を終了し、これら以外の場合
には1つ前の処理ステップの前記演算回路のMSBからの
キャリにより前記演算回路の演算の種類を制御するとと
もに前記カウンタを1減じる制御回路とを備えた除算回
路である。
Means for Solving the Problems The present invention relates to a divider circuit for dividing an n-bit dividend by an n-bit divisor, wherein the bit position of "1" on the MSB side of the dividend and the divisor is set to a value from 0 to n-1. And a priority encoder that outputs n when all bits of the input are “0”, and a divisor from the first value obtained by inputting the dividend to the priority encoder and inputting the divisor to the priority encoder. Subtracting the second value or the value obtained by subtracting the first value from the second value as a third value, the value obtained by subtracting the third value from n as a fourth value, and the dividend Is input to the lower side, and a 2n-bit-wide barrel shifter that shifts left by the number of bits equal to the fourth value, and a first bit that receives the output of the upper n bits of the barrel shifter and shifts left by 1 bit per one processing step of the operation A shift register, and a second shift register that receives the lower n bits of the output of the barrel shifter, shifts one bit to the left for each processing step of the operation, and uses a shift overflow from the MSB as a shift input to the first shift register LSB. An arithmetic circuit that performs addition and subtraction between the value of the second shift register and the divisor, and uses the carry from the MSB as a shift input to the LSB of the second shift register, and calculates the third value as an initial value. And a counter for subtracting 1 for each processing step, and setting the division by zero flag if the second value is n, and terminating the process if the second value is 0, storing the dividend in the first shift register. If the fourth value is larger than n, the dividend is set in the first shift register and 0 is set in the second shift register, respectively, and the processing is terminated. And a control circuit for controlling the type of operation of the arithmetic circuit by the carry from the MSB of the arithmetic circuit in the immediately preceding processing step and decrementing the counter by 1 in other cases. It is.

また本発明は、2nビットの被除数をnビットの除数で
割る除算回路において、被除数の上位nビット及び除数
の最もMSB側にある“1"のビット位置を0からn−1ま
での値で出力し、入力の全てのビットが“0"のときはn
を出力するプライオリティエンコーダと、被除数の上位
nビットを前記プライオリティエンコーダに入力して得
られる第一の値から除数を前記プライオリティエンコー
ダに入力して得られる第二の値を減じるかまたは前記第
二の値から前記第一の値を減じた値を第三の値とし、被
除数を入力し前記第三の値に等しいビット数だけ左シフ
トする2nビット幅のバレルシフタと、前記バレルシフタ
の上位nビットの出力を受け、演算の1処理ステップに
つき1ビット左シフトする第一シフトレジスタと、前記
バレルシフタの下位nビットの出力を受け、演算の1処
理ステップにつき1ビット左シフトし、MSBからのシフ
トあふれを前記第一シフトレジスタのLSBへのシフト入
力とする第二シフトレジスタと、前記第二シフトレジス
タの値と除数との間で加減算を行い、MSBからのキャリ
を前記第二シフトレジスタのLSBへのシフト入力とする
演算回路と、前記第三の値を初期値として演算の1処理
ステップにつき1を減じるカウンタと、前記第二の値が
nならば零除算フラグをセットして処理を終了し、前記
第三の値が負ならばオーバフローフラグをセットして処
理を終了し、これら以外の場合には1つ前の処理ステッ
プの前記演算回路のMSBからのキャリにより前記演算回
路の演算の種類を制御するとともに前記カウンタを1減
じる制御回路とを備えた除算回路である。
The present invention also provides a divider circuit for dividing a 2n-bit dividend by an n-bit divisor, and outputs the upper n bits of the dividend and the bit position of "1" on the MSB side of the divisor as a value from 0 to n-1. When all bits of the input are “0”, n
And a second value obtained by inputting a divisor to the priority encoder from a first value obtained by inputting the higher n bits of the dividend to the priority encoder, or by subtracting the second value obtained by inputting the divisor to the priority encoder. A value obtained by subtracting the first value from the value is set as a third value, a dividend is input, a 2n-bit-wide barrel shifter that shifts left by the number of bits equal to the third value, and an output of upper n bits of the barrel shifter Receiving the output of the lower n bits of the barrel shifter and shifting left by one bit per one processing step of the operation, and eliminating the shift overflow from the MSB. A second shift register as a shift input to the LSB of the first shift register, and a value between the second shift register and the divisor. An arithmetic circuit that performs subtraction and uses the carry from the MSB as a shift input to the LSB of the second shift register; a counter that subtracts 1 for each processing step using the third value as an initial value; If the value of n is n, a divide-by-zero flag is set and the processing is terminated. If the third value is negative, an overflow flag is set and the processing is terminated. Otherwise, the immediately preceding processing step is performed. And a control circuit for controlling the type of operation of the arithmetic circuit by the carry from the MSB of the arithmetic circuit and reducing the counter by one.

作用 本発明は前記した構成により、プライオリティエンコ
ーダで被除数と除数の桁数を出力し、バレルシフタで被
除数をその桁数差だけシフトした後、被除数と除数の加
減算およびシフトを行うことで演算時間を短縮すること
ができる。また、プライオリティエンコーダの出力及び
加減算結果から零除算や商が0になる場合、商が被除数
に等しくなる場合、オーバーフローが容易にかつ高速に
検出できる。
Operation The present invention reduces the operation time by outputting the number of digits of the dividend and the divisor by the priority encoder, shifting the dividend by the difference in the number of digits by the barrel shifter, and performing addition / subtraction and shift of the dividend and the divisor by the above-described configuration. can do. Further, when the division by zero or the quotient becomes 0 or the quotient becomes equal to the dividend from the output of the priority encoder and the result of the addition / subtraction, the overflow can be easily and quickly detected.

実施例 第1図は本発明の実施例における除算回路の構成を示
すものである。第1図において、1は被除数の上位又は
0を保持する被除数レジスタA、2は被除数の下位又は
被除数を保持する被除数レジスタB、3は除数を保持す
る除数レジスタ、4はシフトカウントを保持するシフト
カウントレジスタ、5はシフトカウントレジスタ4の値
だけ左にシフトするバレルシフタ、6はnビットの入力
データの最もMSB側にある“1"のビット位置を出力し、
入力の全てのビットが“0"のときはnを出力するプライ
オリティエンコーダ、12は加算・減算・通過ができる演
算回路、13は演算回路12のキャリー出力を保持するキャ
リーフラグ、11はキャリーフラグ13により演算回路12の
演算を決める演算制御回路、9は演算処理中は部分剰余
を保持し、演算終了時は剰余を保持する部分剰余レジス
タ、10は演算処理中は部分商を保持し、演算終了時は商
を保持する部分商レジスタ、8はキャリーフラグ13をキ
ャリー入力とし、部分商レジスタ10を左へ1ビットシフ
ト又はバレルシフタの出力を通過させる部分商シフタ、
7は部分商シフタ8のキャリー出力をキャリー入力と
し、演算処理中は演算回路12の出力を左へ1ビットシフ
ト又は除算前処理中は入力データを通過させる部分剰余
シフタ、14はデータを転送するデータバスA、15はデー
タを転送するデータバスB、16は部分剰余レジスタ9と
除数レジスタ3の加減算とシフトの繰り返し回数をカウ
ントするループカウンタ、17はプライオリティエンコー
ダ6からの入力で、除数0,除数1を検出し、演算回路12
の出力で商が0になる場合と商のオーバーフローを検出
し、ループカウンタ16及び回路全体を制御する制御回
路、22は制御回路17が除数0を検出したとき、1を設定
する零除算フラグ、23は制御回路17がオーバーフローを
検出したとき、1を設定するオーバーフローフラグ、2
4,25は3入力1出力のセレクタ、26は2入力1出力のセ
レクタである。
Embodiment FIG. 1 shows a configuration of a division circuit in an embodiment of the present invention. In FIG. 1, reference numeral 1 denotes a dividend register A which holds the upper or zero of the dividend, 2 denotes a dividend register B which holds the lower or dividend of the dividend, 3 denotes a divisor register which holds the divisor, and 4 denotes a shift which holds a shift count. The count register 5, the barrel shifter which shifts to the left by the value of the shift count register 4, the 6 outputs the bit position of "1" on the MSB side of the n-bit input data,
When all the input bits are "0", a priority encoder that outputs n, 12 is an arithmetic circuit capable of addition, subtraction, and passage, 13 is a carry flag that holds the carry output of the arithmetic circuit 12, and 11 is a carry flag 13. An arithmetic control circuit that determines the operation of the arithmetic circuit 12 according to the following. 9 is a partial remainder register that holds the partial remainder during the arithmetic processing, and holds the remainder when the arithmetic processing is completed. 10 is a partial quotient that is held during the arithmetic processing. A partial quotient register for holding a quotient, a partial quotient shifter 8 for using the carry flag 13 as a carry input and shifting the partial quotient register 10 left by one bit or passing the output of a barrel shifter;
Numeral 7 designates the carry output of the partial quotient shifter 8 as a carry input, shifts the output of the arithmetic circuit 12 to the left by one bit during the arithmetic processing or passes the input data during the pre-division processing, and 14 transfers the data. Data buses A and 15 are data buses B for transferring data, 16 is a loop counter for counting the number of repetitions of addition / subtraction and shift of the partial remainder register 9 and the divisor register 3, and 17 is an input from the priority encoder 6 and a divisor 0, The divisor 1 is detected and the arithmetic circuit 12
A control circuit for controlling the loop counter 16 and the entire circuit by detecting the case where the quotient becomes 0 and the quotient overflow at the output of the control circuit 22; a zero division flag 22 for setting 1 when the control circuit 17 detects the divisor 0; 23 is an overflow flag that sets 1 when the control circuit 17 detects an overflow, 2
Reference numerals 4 and 25 denote a three-input one-output selector, and reference numeral 26 denotes a two-input one-output selector.

以上のように構成された本実施例の除算回路について
以下その動作を説明する。
The operation of the division circuit of the present embodiment configured as described above will be described below.

第1図に示す構成図を第2図に示すフローチャートに
従って説明する。ここで、被除数nビット、除数nビッ
トのとき通常除算、被除数2nビット、除数nビットのと
き拡張除算と呼ぶことにする。
The configuration diagram shown in FIG. 1 will be described with reference to the flowchart shown in FIG. Here, when the dividend is n bits and the divisor is n bits, it is called normal division, and when the dividend is 2n bits and the divisor is n bits, it is called extended division.

まず、通常除算について述べる。(イ)0を被除数レ
ジスタA1に、被除数を被除数レジスタB2に、除数を除数
レジスタ3にそれぞれ入力する。(ロ)被除数レジスタ
A1はデータバスB15からプライオリティエンコーダ6に
入力され、その出力(値はビット数nに等しい)は演算
回路12、データバスA14、部分剰余シフタ7をそのまま
通過して部分剰余レジスタ9に格納される。(ハ)被除
数レジスタB2はデータバスB15からプライオリティエン
コーダ6に入力され、その出力(k1とする)は演算回路
12で部分剰余レジスタ9の値nと減算(n1=n−k1)を
行い、その出力n1はデータバスA14から部分剰余シフタ
7をそのまま通過して部分剰余レジスタ9に格納され
る。(ニ)除数レジスタ3はデータバスB15からプライ
オリティエンコーダ6に入力され、その出力(k1とす
る)は演算回路12で部分剰余レジスタ9の値n1と加算
(n2=n1+k2)を行い、その出力n2はデータバスA14か
らシフトカウントレジスタ4に格納される。ここで、制
御回路17においてプライオリティエンコーダ6の出力k2
と、演算回路12の出力n2をチェックし、(カ)k2=nの
とき除数が0であるから零除算フラグ22をセットし、除
算を終了する。(ヨ)また、k2=0のとき除数は1であ
るから被除数レジスタB2をバレルシフタ5と部分商シフ
タ8とをそのまま通過して部分商レジスタ10に格納し、
0を部分剰余レジスタ9に格納して除算を終了する。
(タ)また、n2>nのときk1<k2であることを示し、被
除数<除数であるから商が0になり、0を部分商レジス
タ10に格納し、被除数レジスタB2をデータバスB15、演
算回路12、データバスA14、部分剰余シフタ7をいずれ
もそのまま通過して部分剰余レジスタ9に格納し除算を
終了する。(ホ)被除数レジスタA1、被除数レジスタB2
はバレルシフタ5でシフトカウントレジスタ4の値n2
ットだけ左にシフトし、部分剰余シフタ7、部分商シフ
タ8を通過して部分剰余レジスタ9、部分商レジスタ10
にそれぞれ格納される。一方、キャリーフラグ13に“1"
を格納する。(ヲ)ループカウンタ16に繰り返し回数N
(=n−n2)をセットする。(ヘ)キャリーフラグ13を
演算制御回路11に入力し、キャリーフラグ13が0のとき
部分剰余レジスタ9と除数レジスタ3の加算を、キャリ
ーフラグ13が1のとき部分剰余レジスタ9から除数レジ
スタ3の減算を、それぞれ演算回路12において行うよう
に制御し、その時生じたキャリーはキャリーフラグ13に
保持すると共に部分商シフタ8のキャリー入力として、
部分商レジスタ10は部分商シフタ8で左へ1ビットシフ
トされ、再び部分商レジスタ10に格納される。同時に演
算回路12の出力はデータバスA14を経由して、部分商シ
フタ8のキャリー出力をキャリー入力とする部分剰余シ
フタ7へ左へ1ビットシフトされて部分剰余レジスタ9
に格納される。(ト)ループカウンタ16はカウントダウ
ン(N←N−1)L、N=0になるまで(ヘ)を繰り返
す。(チ)終了時、商は部分商レジスタ10に、剰余は部
分剰余レジスタ9に格納されている。
First, ordinary division will be described. (A) Input 0 to the dividend register A1, input the dividend to the dividend register B2, and input the divisor to the divisor register 3. (B) dividend register
A1 is input from the data bus B15 to the priority encoder 6, and its output (the value is equal to the number of bits n) passes through the arithmetic circuit 12, the data bus A14, and the partial remainder shifter 7 and is stored in the partial remainder register 9. . (C) dividend register B2 is input from the data bus B15 to the priority encoder 6, (a k 1) and its output arithmetic circuit
At 12, the value n of the partial remainder register 9 is subtracted (n 1 = n−k 1 ), and the output n 1 passes through the partial remainder shifter 7 from the data bus A 14 and is stored in the partial remainder register 9. (D) the divisor register 3 are input from the data bus B15 to the priority encoder 6, the output (a k 1) adds the value n 1 of the partial remainder register 9 by the arithmetic circuit 12 (n 2 = n 1 + k 2) was carried out, its output n 2 are stored from the data bus A14 to the shift count register 4. Here, the output k 2 of the priority encoder 6 is output from the control circuit 17.
Then, the output n 2 of the arithmetic circuit 12 is checked. (F) When k 2 = n, the divisor is 0, so the zero division flag 22 is set, and the division is terminated. (K) Since the divisor is 1 when k 2 = 0, the dividend is passed through the barrel shifter 5 and the partial quotient shifter 8 as it is, and stored in the partial quotient register 10;
0 is stored in the partial remainder register 9 and the division ends.
(N) When n 2 > n, it indicates that k 1 <k 2 , and since the dividend is divisor <divisor, the quotient becomes 0, 0 is stored in the partial quotient register 10, and the dividend register B2 is stored in the data bus. B15, the arithmetic circuit 12, the data bus A14, and the partial remainder shifter 7 are all passed through as they are, stored in the partial remainder register 9, and the division is completed. (E) dividend register A1, dividend register B2
Is shifted to the left by the value n 2 bits of the shift count register 4 by the barrel shifter 5, passes through the partial remainder shifter 7 and the partial quotient shifter 8 and passes through the partial remainder register 9 and the partial quotient register 10.
Are stored respectively. On the other hand, carry flag 13 is set to “1”
Is stored. (ヲ) Number of repetitions N in the loop counter 16
(= N−n 2 ) is set. (F) The carry flag 13 is input to the arithmetic and control circuit 11, and when the carry flag 13 is 0, the addition of the partial remainder register 9 and the divisor register 3 is performed, and when the carry flag 13 is 1, the addition of the partial remainder register 9 to the divisor register 3 is performed. The subtraction is controlled so as to be performed in the arithmetic circuit 12, and the carry generated at that time is held in the carry flag 13 and at the same time as the carry input of the partial quotient shifter 8,
The partial quotient register 10 is shifted one bit to the left by the partial quotient shifter 8 and stored in the partial quotient register 10 again. At the same time, the output of the arithmetic circuit 12 is shifted to the left by one bit to the partial remainder shifter 7 having the carry output of the partial quotient shifter 8 as the carry input via the data bus A14, and the partial remainder register 9
Is stored in (G) The loop counter 16 repeats (f) until the countdown (N ← N−1) L and N = 0. (H) At the end, the quotient is stored in the partial quotient register 10 and the remainder is stored in the partial remainder register 9.

次に、拡張除算について述べる。(リ)被除数上位を
被除数レジスタA1に、被除数下位を被除数レジスタB2
に、除数を除数レジスタ3にそれぞれ格納する。(ヌ)
除数レジスタ3はデータバスB15からプライオリティエ
ンコーダ6に入力され、その出力(k1とする)は演算回
路12、データバスA14、部分剰余シフタ7をいずれもそ
のまま通過して部分剰余レジスタ9に格納される。
(カ)ここで、制御回路17において、プライオリティエ
ンコーダ6の出力k2をチェックし、k2=nのとき除数が
0であるから、零除算フラグ22をセットし除算を終了す
る。(ル)被除数レジスタA1はデータバスB15からプラ
イオリティエンコーダ6に入力し、その出力(k0とす
る)は演算回路12で部分剰余レジスタ9の値k2と減算
(n2=k2−k0)され、その出力n2はデータバスA14から
シフトカウントレジスタ4に格納される。(ワ)演算回
路12の出力n2を制御回路17に送り、n2<0ならばk0>k2
であることを示し、被除数/2n>除数であるから、オー
バーフローフラグ23をセットし除算を終了する。以下
(ホ)〜(チ)を実行する。
Next, extended division will be described. (I) The upper dividend is in the dividend register A1, and the lower dividend is in the dividend register B2.
Then, the divisor is stored in the divisor register 3 respectively. (Nu)
Divisor register 3 are input from the data bus B15 to the priority encoder 6, (a k 1) and its output is stored in the arithmetic circuit 12, a data bus A14, the partial remainder register 9 through it both the partial remainder shifter 7 You.
(F) where the control circuit 17 checks the output k 2 priority encoder 6, because the divisor when k 2 = n is 0, and ends the set zero division flag 22 division. (Le) dividend register A1 is input from the data bus B15 to the priority encoder 6, (a k 0) and its output is subtracted and the value k 2 of the partial remainder register 9 by the arithmetic circuit 12 (n 2 = k 2 -k 0 ) is, the output n 2 are stored from the data bus A14 to the shift count register 4. (C) The output n 2 of the arithmetic circuit 12 is sent to the control circuit 17, and if n 2 <0, k 0 > k 2
Since the dividend / 2n > divisor, the overflow flag 23 is set and the division is terminated. The following steps (e) to (h) are performed.

通常除算の前処理(イ)(ロ)(ハ)(ニ)の具体例
を第3図aに、拡張除算の前処理(リ)(ヌ)(ル)の
具体例を第3図bにそれぞれ示す。このように、除算の
最初に被除数を一度にシフトするため、それだけ時間を
短縮することができる。
A specific example of the pre-processing (a), (b), (c), and (d) of the normal division is shown in FIG. 3a, and a specific example of the pre-processing (li), (nu), and (l) of the extended division is shown in FIG. Shown respectively. As described above, since the dividend is shifted at one time at the beginning of the division, the time can be reduced accordingly.

以上のように、本実施例によれば、プライオリティエ
ンコーダ6とバレルシフタ5を用いる最初の被除数のシ
フト動作を含む前処理により、被除数と除数の演算及び
シフト動作の回数を減らすことができ、除算時間を短縮
することができる。さらに、除数が0の場合、除数が1
の場合、商が0の場合、商がオーバーフローの場合の検
出を容易に高速に行うことができる。
As described above, according to the present embodiment, the number of the operations of the dividend and the divisor and the number of shift operations can be reduced by the pre-processing including the shift operation of the first dividend using the priority encoder 6 and the barrel shifter 5, and the division time can be reduced. Can be shortened. Further, when the divisor is 0, the divisor is 1
In the case of, when the quotient is 0, it is possible to easily and quickly detect a case where the quotient overflows.

発明の効果 以上説明したように、本発明によれば、プライオリテ
ィエンコーダとバレルシフタを用いる最初の被除数のシ
フト動作を含む前処理により、被除数と除数の演算及び
シフト動作の回数が減小することで、除算時間を短縮で
き、さらに、除数が0の場合、除数が1の場合、商が0
の場合、商がオーバーフローの場合の検出を容易に高速
に行うことができ、その実用的効果は大きい。
Effect of the Invention As described above, according to the present invention, by performing preprocessing including the shift operation of the first dividend using the priority encoder and the barrel shifter, the number of operations of the dividend and the divisor and the number of shift operations are reduced, The division time can be reduced, and when the divisor is 0, when the divisor is 1, the quotient is 0.
In the case of (1), the case where the quotient overflows can be easily detected at high speed, and the practical effect is large.

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

第1図は本発明における一実施例の除算回路の構成図、
第2図は同実施例の動作説明のためのフローチャート、
第3図は同実施例の前処理部の具体例の説明図、第4図
は従来の除算回路の構成図である。 1……被除数レジスタA、2……被除数レジスタB、3
……除数レジスタ、4……シフトカウントレジスタ、5
……バレルシフタ、6……プライオリティエンコーダ、
7……部分剰余シフタ、8……部分商シフタ、9……部
分剰余レジスタ、10……部分商レジスタ、11……演算制
御回路、12……演算回路、13……キャリーフラグ、14…
…データバスA、15……データバスB、16……ループカ
ウンタ、17……制御回路、18……タイミング制御回路、
19……演算フラグ、20……シフタ、21……入出力データ
バス、22……零除算フラグ、23……オーバーフローフラ
グ、24……3入力1出力セレクタ、25……3入力1出力
セレクタ、26……2入力1出力セレクタ。
FIG. 1 is a configuration diagram of a division circuit according to one embodiment of the present invention,
FIG. 2 is a flowchart for explaining the operation of the embodiment,
FIG. 3 is an explanatory diagram of a specific example of a pre-processing unit of the embodiment, and FIG. 4 is a configuration diagram of a conventional division circuit. 1 ... dividend register A, 2 ... dividend register B, 3
…… Divisor register, 4… Shift count register, 5
…… Barrel shifter, 6 …… Priority encoder,
7 ... partial remainder shifter, 8 ... partial quotient shifter, 9 ... partial remainder register, 10 ... partial quotient register, 11 ... operation control circuit, 12 ... operation circuit, 13 ... carry flag, 14 ...
… Data bus A, 15… Data bus B, 16… Loop counter, 17… Control circuit, 18… Timing control circuit,
19: operation flag, 20: shifter, 21: input / output data bus, 22: division by zero flag, 23: overflow flag, 24: three-input one-output selector, 25: three-input one-output selector, 26 ... 2 input 1 output selector.

Claims (2)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】nビットの被除数をnビットの除数で割る
除算回路において、 被除数及び除数の最もMSB側にある“1"のビット位置を
0からn−1までの値で出力し、入力の全てのビットが
“0"のときはnを出力するプライオリティエンコーダ
と、 被除数を前記プライオリティエンコーダに入力して得ら
れる第一の値から除数を前記プライオリティエンコーダ
に入力して得られる第二の値を減じるかまたは前記第二
の値から前記第一の値を減じた値を第三の値とし、nか
ら前記第三の値を減じた値を第四の値とし、被除数を下
位側に入力し前記第四の値に等しいビット数だけ左シフ
トする2nビット幅のバレルシフタと、 前記バレルシフタの上位nビットの出力を受け、演算の
1処理ステップにつき1ビット左シフトする第一シフト
レジスタと、 前記バレルシフタの下位nビットの出力を受け、演算の
1処理ステップにつき1ビット左シフトし、MSBからの
シフトあふれを前記第一シフトレジスタのLSBへのシフ
ト入力とする第二シフトレジスタと、 前記第二シフトレジスタの値と除数との間で加減算を行
い、MSBからのキャリを前記第二シフトレジスタのLSBへ
のシフト入力とする演算回路と、 前記第三の値を初期値として演算の1処理ステップにつ
き1を減じるカウンタと、前記第二の値がnならば零除
算フラグをセットして処理を終了し、前記第二の値が0
ならば0を第一シフトレジスタに被除数を第二シフトレ
ジスタにそれぞれセットして処理を終了し、前記第四の
値がnより大きければ被除数を第一シフトレジスタに0
を第二シフトレジスタにそれぞれセットして処理を終了
し、これら以外の場合には1つ前の処理ステップの前記
演算回路のMSBからのキャリにより前記演算回路の演算
の種類を制御するとともに前記カウンタを1減じる制御
回路とを備え、 前記カウンタが0になるまで上記の操作を繰り返し、第
二シフトレジスタから商を第一シフトレジスタから剰余
を得ることを特徴とする除算回路。
1. A dividing circuit for dividing an n-bit dividend by an n-bit divisor, wherein a bit position of "1" on the MSB side of the dividend and the divisor is output as a value from 0 to n-1. A priority encoder that outputs n when all bits are “0”; and a second value obtained by inputting a divisor to the priority encoder from a first value obtained by inputting a dividend to the priority encoder. A value obtained by subtracting or subtracting the first value from the second value is set as a third value, a value obtained by subtracting the third value from n is set as a fourth value, and the dividend is input to the lower side. A 2n-bit-wide barrel shifter that shifts left by the number of bits equal to the fourth value; a first shift register that receives the output of the upper n bits of the barrel shifter and shifts one bit to the left for each processing step of the operation; A second shift register that receives the output of the lower n bits of the barrel shifter, shifts one bit to the left for each processing step of the operation, and uses the shift overflow from the MSB as a shift input to the LSB of the first shift register; An arithmetic circuit that performs addition and subtraction between the value of the two shift registers and the divisor, and uses the carry from the MSB as a shift input to the LSB of the second shift register; and one processing operation using the third value as an initial value A counter for decrementing 1 per step and a division by zero flag when the second value is n are set, and the processing is terminated.
If so, 0 is set in the first shift register and the dividend is set in the second shift register, respectively, and the process is terminated. If the fourth value is greater than n, the dividend is set to 0 in the first shift register.
Is set in the second shift register, respectively, and the processing is terminated. In other cases, the type of operation of the arithmetic circuit is controlled by carry from the MSB of the arithmetic circuit in the immediately preceding processing step, and the counter is controlled. And a control circuit for repeating the above operation until the counter becomes 0, and obtaining a quotient from the second shift register and a remainder from the first shift register.
【請求項2】2nビットの被除数をnビットの除数で割る
除算回路において、 被除数の上位nビット及び除数の最もMSB側にある“1"
のビット位置を0からn−1までの値で出力し、入力の
全てのビットが“0"のときはnを出力するプライオリテ
ィエンコーダと、 被除数の上位nビットを前記プライオリティエンコーダ
に入力して得られる第一の値から除数を前記プライオリ
ティエンコーダに入力して得られる第二の値を減じるか
または前記第二の値から前記第一の値を減じた値を第三
の値とし、被除数を入力し前記第三の値に等しいビット
数だけ左シフトする2nビット幅のバレルシフタと、 前記バレルシフタの上位nビットの出力を受け、演算の
1処理ステップにつき1ビット左シフトする第一シフト
レジスタと、 前記バレルシフタの下位nビットの出力を受け、演算の
1処理ステップにつき1ビット左シフトし、MSBからの
シフトあふれを前記第一シフトレジスタのLSBへのシフ
ト入力とする第二シフトレジスタと、 前記第二シフトレジスタの値と除数との間で加減算を行
い、MSBからのキャリを前記第二シフトレジスタのLSBへ
のシフト入力とする演算回路と、 前記第三の値を初期値として演算の1処理ステップにつ
き1を減じるカウンタと、 前記第二の値がnならば零除算フラグをセットして処理
を終了し、前記第三の値が負ならばオーバフローフラグ
をセットして処理を終了し、これら以外の場合には1つ
前の処理ステップの前記演算回路のMSBからのキャリに
より前記演算回路の演算の種類を制御するとともに前記
カウンタを1減じる制御回路とを備え、 前記カウンタが0になるまで上記の操作を繰り返し、第
二シフトレジスタから商を第一シフトレジスタから剰余
を得ることを特徴とする除算回路。
2. A dividing circuit for dividing a 2n-bit dividend by an n-bit divisor, wherein the upper n bits of the dividend and "1" which is closest to the MSB of the divisor.
Is output as a value from 0 to n−1, and when all the input bits are “0”, the priority encoder outputs n and the upper n bits of the dividend are input to the priority encoder to obtain Subtracting the second value obtained by inputting the divisor from the first value to the priority encoder or subtracting the first value from the second value as the third value, and inputting the dividend A 2n-bit-wide barrel shifter that shifts left by the number of bits equal to the third value; a first shift register that receives the output of the upper n bits of the barrel shifter and shifts one bit to the left for each processing step of the operation; The output of the lower n bits of the barrel shifter is shifted left by one bit per processing step of the operation, and the shift overflow from the MSB is transferred to the LSB of the first shift register. A second shift register serving as a shift input; an arithmetic circuit performing addition / subtraction between a value of the second shift register and a divisor; and a carry from an MSB serving as a shift input to an LSB of the second shift register; and A counter for subtracting 1 for one processing step with the third value as an initial value; and setting the divide-by-zero flag if the second value is n and terminating the process, and if the third value is negative, The overflow flag is set and the process is terminated. In other cases, the type of operation of the arithmetic circuit is controlled by the carry from the MSB of the arithmetic circuit in the immediately preceding processing step, and the counter is decreased by one. A division circuit which repeats the above operation until the counter reaches 0, and obtains a quotient from the second shift register and a remainder from the first shift register.
JP62114124A 1987-05-11 1987-05-11 Division circuit Expired - Fee Related JP2605715B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP62114124A JP2605715B2 (en) 1987-05-11 1987-05-11 Division circuit

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP62114124A JP2605715B2 (en) 1987-05-11 1987-05-11 Division circuit

Publications (2)

Publication Number Publication Date
JPS63278141A JPS63278141A (en) 1988-11-15
JP2605715B2 true JP2605715B2 (en) 1997-04-30

Family

ID=14629735

Family Applications (1)

Application Number Title Priority Date Filing Date
JP62114124A Expired - Fee Related JP2605715B2 (en) 1987-05-11 1987-05-11 Division circuit

Country Status (1)

Country Link
JP (1) JP2605715B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2708526B2 (en) * 1989-02-14 1998-02-04 富士通株式会社 Binary integer division processing method
JPH052471A (en) * 1991-06-26 1993-01-08 Kawasaki Steel Corp Divider device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS53112627A (en) * 1977-03-14 1978-10-02 Toshiba Corp Division control system

Also Published As

Publication number Publication date
JPS63278141A (en) 1988-11-15

Similar Documents

Publication Publication Date Title
US6099158A (en) Apparatus and methods for execution of computer instructions
JP6001276B2 (en) Apparatus and method for performing floating point addition
US5128889A (en) Floating-point arithmetic apparatus with compensation for mantissa truncation
US7373369B2 (en) Advanced execution of extended floating-point add operations in a narrow dataflow
JPH0343645B2 (en)
JP2605715B2 (en) Division circuit
JP2511527B2 (en) Floating point arithmetic unit
JPH07107664B2 (en) Multiplication circuit
JPS63123125A (en) Floating point adder
JPH10187416A (en) Floating point arithmetic unit
JPH10283164A (en) Division circuit
JP2995721B2 (en) Division device and division method
JP4428778B2 (en) Arithmetic device, arithmetic method, and computing device
JPS60167030A (en) System and circuit for shift flag generation
JP2856791B2 (en) Barrel shifter and floating point unit
JPH07104777B2 (en) Floating point adder / subtractor
JP2512939B2 (en) Fixed floating data conversion circuit
JP3068640B2 (en) Computing device
JPH0449138B2 (en)
WO1998006029A1 (en) Apparatus and methods for execution of computer instructions
JPS626258B2 (en)
JP2575856B2 (en) Arithmetic circuit
JPH04330519A (en) Multiplier
JPH0540606A (en) Floating point multiplier/divider
JPH0644041A (en) Floating point arithmetic unit

Legal Events

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