JP4271589B2 - Control method of arithmetic device, program thereof and recording medium - Google Patents

Control method of arithmetic device, program thereof and recording medium Download PDF

Info

Publication number
JP4271589B2
JP4271589B2 JP2004006729A JP2004006729A JP4271589B2 JP 4271589 B2 JP4271589 B2 JP 4271589B2 JP 2004006729 A JP2004006729 A JP 2004006729A JP 2004006729 A JP2004006729 A JP 2004006729A JP 4271589 B2 JP4271589 B2 JP 4271589B2
Authority
JP
Japan
Prior art keywords
register
value
dividend
quotient
integer
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
JP2004006729A
Other languages
Japanese (ja)
Other versions
JP2005202571A (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.)
Schneider Electric Japan Holdings Ltd
Original Assignee
Digital Electronics 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 Digital Electronics Corp filed Critical Digital Electronics Corp
Priority to JP2004006729A priority Critical patent/JP4271589B2/en
Publication of JP2005202571A publication Critical patent/JP2005202571A/en
Application granted granted Critical
Publication of JP4271589B2 publication Critical patent/JP4271589B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Images

Description

本発明は、例えば、スケーリング処理などに好適に用いられ、それぞれ浮動小数点数として与えられる被除数を、除数で割ったときの余りと、必要に応じて商(整商)とを、より短い時間で得る演算装置の制御方法、演算装置、並びに、そのプログラムおよび記録媒体に関するものである。   The present invention is preferably used for, for example, scaling processing, and the remainder obtained by dividing the dividend given as a floating-point number by the divisor and, if necessary, the quotient (arrangement) in a shorter time. The present invention relates to an arithmetic device control method, an arithmetic device, a program thereof, and a recording medium.

従来から、例えば、三角関数など、周期的に値が変化する関数を演算する際、ある範囲の変域内の引数に対応する値を記憶しておき、それを参照して、上記変域から外れた引数に対応する値を算出する方法が広く使用されている。   Conventionally, for example, when calculating a function whose value periodically changes, such as a trigonometric function, a value corresponding to an argument in a certain range is stored, and the value is deviated from the above range by referring to it. A method for calculating a value corresponding to the argument is widely used.

例えば、三角関数y=sin(x)の場合を例にすると、−π/2≦x≦+π/2に対応するyをそれぞれ記憶しておき、入力xの絶対値が大きいときには、x(被除数)をπ/2(除数)で除算して、その余りを求めることによって、−π/2〜π/2の範囲に入れた後、それに対応して記憶されたyから、関数の値を算出している。   For example, taking the case of trigonometric function y = sin (x) as an example, y corresponding to −π / 2 ≦ x ≦ + π / 2 is stored, and when the absolute value of input x is large, x (dividend) ) Is divided by π / 2 (divisor) and the remainder is obtained, and then the value of the function is calculated from y stored correspondingly after entering the range of −π / 2 to π / 2. is doing.

一方、浮動小数点数ではなく、整数を除算する場合、後述の特許文献1には、被除数および除数の最上位桁に続く0の無効ビット数をもとにシフト量を算出する概算桁合わせ回路と、そのシフト量だけ被除数を左シフトする左シフタと、被除数から除数を減算したときに部分剰余と部分商とが同時に求められるよう除数を変換する除数変換部と、左シフトされた被除数を1ビットづつ左シフトしながら除数を繰返し減算する除算処理部とを備えることにより、部分剰余と部分商とが同時に求められて、除算処理工程を節約でき、被除数の上位無効ビット数分除算回路の冗長な演算を削減して、回路規模を増大せずに、除算回路における繰返し処理回数を減少する構成が開示されている。
特開2002−175179号公報(公開日:2002年6月21日)
On the other hand, when dividing an integer instead of a floating-point number, Patent Document 1 described later includes an approximate digit alignment circuit that calculates a shift amount based on the number of invalid bits of 0 following the most significant digit of the dividend and the divisor. A left shifter that shifts the dividend to the left by the shift amount, a divisor conversion unit that converts the divisor so that a partial remainder and a partial quotient can be obtained simultaneously when the divisor is subtracted from the dividend, and the left-shifted dividend is 1 bit By providing a division processing unit that repeatedly subtracts the divisor while shifting leftward one by one, the partial remainder and partial quotient can be obtained simultaneously, saving the division processing step, and the redundant circuit of the division circuit for dividing the upper invalid bits of the dividend A configuration is disclosed in which the number of iterations in the division circuit is reduced without reducing the operation and increasing the circuit scale.
JP 2002-175179 A (publication date: June 21, 2002)

しかしながら、上記除数および被除数が浮動小数点数として表現されている場合には、上記特許文献1の方法をそのまま採用することはできない。一方、剰余を算出するにあたって、余りx2および商qを、q=INT(x/y)およびx2=x−q*yによって計算すると、浮動小数点演算に時間がかかるという問題を生じる。   However, when the divisor and the dividend are expressed as floating-point numbers, the method of Patent Document 1 cannot be adopted as it is. On the other hand, when calculating the remainder, if the remainder x2 and the quotient q are calculated by q = INT (x / y) and x2 = x−q * y, there arises a problem that it takes time for the floating point calculation.

本発明は、上記の問題点に鑑みてなされたものであり、その目的は、より少ない演算量および演算時間で、整数化された除算結果と余りとを算出可能な演算装置の制御方法、演算装置、並びに、そのプログラムおよび記録媒体を提供することにある。   The present invention has been made in view of the above-described problems, and an object of the present invention is to provide a control method and a calculation method for an arithmetic device capable of calculating an integer division result and a remainder with a smaller calculation amount and calculation time. It is to provide an apparatus, a program thereof, and a recording medium.

本発明に係る演算装置の制御方法は、上記課題を解決するために、仮数部および指数部を含む浮動小数点数として与えられる被除数および除数をそれぞれ記憶する被除数および除数レジスタと、商を記憶する商レジスタと、これらの各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有する演算装置の制御方法であって、上記演算回路が、上記制御回路の指示に基づいて、上記被除数レジスタの指数部から、上記除数レジスタの指数部を減算する減算工程と、左シフトされたときは、その桁も含めた上記被除数レジスタの仮数部から、上記除数レジスタの仮数部を減算できる場合、上記商レジスタの最下位桁に1を設定し、減算できない場合は、上記商レジスタの最下位桁に0を設定する処理と、上記被除数レジスタの仮数部および上記商レジスタを1桁ずつ左シフトする処理とを、上記制御回路の指示に基づいて、上記演算回路が、上記減算工程の減算結果の回数だけ繰り返す繰り返し工程とを含んでいることを特徴としている。   In order to solve the above problems, a control method for an arithmetic unit according to the present invention includes a dividend and a divisor register for storing a dividend and a divisor given as floating point numbers including a mantissa part and an exponent part, respectively, and a quotient for storing a quotient. A control method for an arithmetic unit comprising a register, an arithmetic circuit that performs an operation with reference to values of the registers, and a control circuit that controls the registers and the arithmetic circuit, wherein the arithmetic circuit includes the control circuit The subtraction step for subtracting the exponent part of the divisor register from the exponent part of the dividend register based on the instruction of the divisor register, and when shifted left, from the mantissa part of the dividend register including the digit, the divisor register When the mantissa part of the quotient register can be subtracted, 1 is set to the least significant digit of the quotient register, and when the subtraction cannot be performed, 0 is set to the least significant digit of the quotient register. And repeating the process of shifting the mantissa part of the dividend register and the quotient register one digit at a time, based on an instruction from the control circuit, by the number of subtraction results of the subtraction process. It is characterized by including.

上記構成では、繰り返し工程の両処理の繰り返し回数が、減算工程での減算結果の回数に設定されているので、繰り返し工程の終了時点における商レジスタの値が、整数化された除算結果であり、当該時点における被除数レジスタの値が、余りになる。   In the above configuration, since the number of repetitions of both processes in the repetition process is set to the number of subtraction results in the subtraction process, the value of the quotient register at the end of the repetition process is an integerized division result, The value of the dividend register at the time is the remainder.

したがって、通常の除算と同様に、有効数字の回数だけ、繰り返し工程の両処理を繰り返して、除算結果を求め、当該除算結果を整数化すると共に、被除数から、整数化された値と除数との乗算結果を減算する場合と比較して、上記両処理の繰り返し回数を削減できる。   Therefore, as in normal division, both processes of the iteration process are repeated by the number of significant digits to obtain a division result, and the division result is converted to an integer, and the integer value and the divisor are calculated from the dividend. Compared with the case where the multiplication result is subtracted, the number of repetitions of both processes can be reduced.

この結果、より少ない演算量および演算時間で、整数化された除算結果と余りとを算出できる。   As a result, it is possible to calculate the integer division result and the remainder with a smaller calculation amount and calculation time.

また、本発明に係る演算装置は、上記課題を解決するために、仮数部および指数部を含む浮動小数点数として与えられる被除数および除数をそれぞれ記憶する被除数および除数レジスタと、商を記憶する商レジスタと、これらの各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有する演算装置であって、上記演算回路は、上記制御回路の指示に基づいて、上記被除数レジスタの指数部から、上記除数レジスタの指数部を減算すると共に、左シフトされたときは、その桁も含めた上記被除数レジスタの仮数部から、上記除数レジスタの仮数部を減算できる場合、上記商レジスタの最下位桁に1を設定し、減算できない場合は、上記商レジスタの最下位桁に0を設定する処理と、上記被除数レジスタの仮数部および上記商レジスタを1桁ずつ左シフトする処理とを、上記減算ステップの減算結果の回数だけ、繰り返すものであることを特徴としている。   In order to solve the above problems, an arithmetic unit according to the present invention includes a dividend and divisor register for storing a dividend and a divisor given as floating point numbers including a mantissa part and an exponent part, and a quotient register for storing a quotient. And an arithmetic circuit that performs an operation by referring to the values of the registers, and a control circuit that controls the registers and the arithmetic circuit. The arithmetic circuit is based on an instruction from the control circuit. The exponent part of the divisor register can be subtracted from the exponent part of the dividend register, and when shifted left, the mantissa part of the divisor register can be subtracted from the mantissa part of the dividend register including the digit. If the least significant digit of the quotient register is set to 1 and subtraction is not possible, the process of setting 0 to the least significant digit of the quotient register and the dividend Mantissa registers and a process of left-shifting the quotient register by one order of magnitude, and wherein the number of times of subtraction result of the subtraction step is to repeat.

当該演算装置は、上記演算装置の制御方法を実行できるので、上記演算装置の制御方法と同様に、より少ない演算量および演算時間で、整数化された除算結果と余りとを算出できる。   Since the arithmetic device can execute the control method of the arithmetic device, as in the control method of the arithmetic device, the arithmetic result and the remainder can be calculated with a smaller arithmetic amount and arithmetic time.

ところで、上記演算装置は、ハードウェアのみで実現してもよいが、ソフトウェアとハードウェアとを組み合わせて実現してもよい。具体的には、本発明に係るプログラムは、仮数部および指数部を含む浮動小数点数として与えられる被除数および除数をそれぞれ記憶する被除数および除数レジスタと、商を記憶する商レジスタと、これらの各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有するコンピュータに、上記各工程を実行させるプログラムである。また、本発明に係る記録媒体には、当該プログラムが記録されている。   By the way, although the said arithmetic unit may be implement | achieved only with hardware, you may implement | achieve combining software and hardware. Specifically, the program according to the present invention includes a dividend and divisor register for storing a dividend and a divisor given as floating point numbers including a mantissa part and an exponent part, a quotient register for storing a quotient, and each of these registers Is a program that causes a computer having an arithmetic circuit that performs an operation with reference to the value of the above and a control circuit that controls the registers and the arithmetic circuit to execute the processes. The program is recorded on the recording medium according to the present invention.

これらのプログラムが上記コンピュータで実行されると、当該コンピュータは、上記演算装置の制御方法の各工程を実行する。したがって、上記演算装置の制御方法と同様に、より少ない演算量および演算時間で、整数化された除算結果と余りとを算出できる。   When these programs are executed by the computer, the computer executes each step of the control method of the arithmetic device. Therefore, as in the control method of the arithmetic unit, the integer division result and the remainder can be calculated with a smaller calculation amount and calculation time.

本発明によれば、通常の除算の後、整数化して、余りを算出する場合よりも、繰り返し回数を削減できるので、より少ない演算量および演算時間で、整数化された除算結果と余りとを算出でき、スケーリング処理などを高速に実行できるという効果を奏する。   According to the present invention, it is possible to reduce the number of iterations compared to the case of calculating the remainder after normalization by dividing into integers. Therefore, the division result and the remainder converted to integers can be obtained with less calculation amount and calculation time. It is possible to calculate and to achieve an effect that a scaling process and the like can be executed at high speed.

本発明の一実施形態について図1ないし図5に基づいて説明すると以下の通りである。すなわち、本実施形態に係る演算装置の制御方法は、浮動小数点数の減算を用いて、浮動小数点数の除算結果(厳密には、整商)を求めているにも拘わらず、比較的高速に剰余を演算可能な方法であって、スケーリング処理などに好適に用いることができる。ここで、スケーリング処理は、例えば、三角関数sin(x)の入力xの絶対値が大きいときに、xをπ/2で除算して、その余りを求めることによって、−π/2〜π/2の範囲に入れる処理のように、ある被除数xを、除数yで割ったときの余りと、必要に応じて商(整商)とを求める処理であって、余りをx2、商をqとするとき、q=INT(x/y)、x2=x−q*yと表現できる。   An embodiment of the present invention will be described below with reference to FIGS. That is, the control method of the arithmetic unit according to the present embodiment uses a floating-point number subtraction to obtain a floating-point number division result (strictly, quotient), but relatively quickly. This is a method capable of calculating the remainder and can be suitably used for scaling processing and the like. Here, for example, when the absolute value of the input x of the trigonometric function sin (x) is large, the scaling process is performed by dividing x by π / 2 to obtain the remainder, thereby obtaining −π / 2 to π / 2 is a process for obtaining a remainder when dividing a given dividend x by a divisor y and a quotient (an adjusted quotient) as needed, such as a process of entering a range of 2, where the remainder is x2 and the quotient is q. Q = INT (x / y) and x2 = x−q * y.

具体的には、本実施形態に係る演算装置1は、浮動小数点演算によって、上記のスケーリング処理を行う装置であって、図1に示すように、予め定められたビット幅の、浮動小数点表示された数(浮動小数点数)を記憶する第1および第2レジスタ11・12と、予め定めれたビット幅の符号付きまたは符号なし整数を記憶する第3および第4レジスタ13・14と、指示に応じて、上記各レジスタ11〜14の値を参照して演算を行うと共に、指示に応じて、演算結果を上記各レジスタ11〜14へ書き込み可能な演算回路21と、上記各レジスタ11〜14への、あるいは、上記各レジスタ11〜14からのデータ転送を制御する転送制御回路22と、予め定められたアルゴリズムに従って、上記各レジスタ11〜14並びに演算回路21および転送制御回路22を制御する制御回路23と、演算の対象となる被除数xおよび除数yを記憶すると共に、演算結果が書き込まれるメモリ31とを備えている。なお、上記演算回路21および転送制御回路22が特許請求の範囲に記載の演算回路に対応する。   Specifically, the arithmetic device 1 according to the present embodiment is a device that performs the above-described scaling processing by floating-point arithmetic, and displays a floating-point value with a predetermined bit width as shown in FIG. First and second registers 11 and 12 for storing a predetermined number (floating point number), third and fourth registers 13 and 14 for storing a signed or unsigned integer of a predetermined bit width, and instructions Accordingly, an operation is performed with reference to the values of the registers 11 to 14, and an operation circuit 21 that can write the operation result to the registers 11 to 14 and an instruction to the registers 11 to 14 according to an instruction. Or the transfer control circuit 22 for controlling the data transfer from the registers 11 to 14 and the registers 11 to 14 and the arithmetic circuit 2 according to a predetermined algorithm. And a control circuit 23 for controlling the transfer control circuit 22 stores the dividend x and divisor y to be calculated of the subject, and a memory 31 that the operation result is written. The arithmetic circuit 21 and the transfer control circuit 22 correspond to the arithmetic circuit described in the claims.

本実施形態の演算装置1の演算対象となる浮動小数点数xおよびyは、nおよびmを予め定められた自然数とするとき、例えば、1ビットで表現される符号と、mビットの指数部と、nビットの仮数部とを含んでいる。なお、本実施形態に係る浮動小数点数では、仮数部の値は、絶対値で表現されている。   The floating-point numbers x and y to be calculated by the calculation device 1 according to the present embodiment are, for example, a code represented by 1 bit, an m-bit exponent part, and n and m, when n and m are predetermined natural numbers. , And an n-bit mantissa part. In the floating-point number according to the present embodiment, the value of the mantissa part is expressed as an absolute value.

一方、上記第1および第2レジスタ11・12は、浮動小数点数を記憶可能なレジスタ(浮動小数点レジスタ)であって、図2に示すように、それぞれ、符号、指数部および仮数部を記憶する領域AS1、AE1およびAM1、あるいは、AS2、AE2およびAM2を備えている。また、上記第1レジスタ(被除数レジスタ)11は、被除数および余りを記憶するために使用され、第2レジスタ12(除数レジスタ)は、除数を記憶するために使用される。なお、本実施形態では、これらの領域AS1(AS2)、AE1(AE2)およびAM1(AM2)のビット幅は、それぞれ、1ビット、mビットおよびnビットである。   On the other hand, the first and second registers 11 and 12 are registers (floating point registers) capable of storing floating-point numbers, and store a sign, an exponent part, and a mantissa part, respectively, as shown in FIG. Regions AS1, AE1 and AM1, or AS2, AE2 and AM2 are provided. The first register (dividend register) 11 is used for storing a dividend and a remainder, and the second register 12 (divisor register) is used for storing a divisor. In the present embodiment, the bit widths of these areas AS1 (AS2), AE1 (AE2), and AM1 (AM2) are 1 bit, m bits, and n bits, respectively.

また、第3レジスタ13は、商を記憶するためのレジスタ(商レジスタ)であって、そのビット幅は、商を、符号付きの整数で記憶可能なビット幅に設定されている。なお、図3の例では、第3レジスタ13のビット幅は、L+1ビットに設定されており、1ビットの符号と、Lビットの符号無し整数(絶対値)との組み合わせとして表現される商を記憶できる。さらに、第4レジスタ14は、作業用のレジスタであって、そのビット幅は、少なくともmビット(図2の例では、第3レジスタ13と同じくL+1ビット)に設定されている。   The third register 13 is a register (quotient register) for storing a quotient, and its bit width is set to a bit width capable of storing the quotient as a signed integer. In the example of FIG. 3, the bit width of the third register 13 is set to L + 1 bits, and a quotient expressed as a combination of a 1-bit code and an L-bit unsigned integer (absolute value) is represented. I can remember. Further, the fourth register 14 is a working register, and its bit width is set to at least m bits (L + 1 bits as in the third register 13 in the example of FIG. 2).

一方、本実施形態に係る演算回路21は、例えば、ALU(数値演算ユニット:Arithmetic Logical Unit)のように、組み合わせ論理回路および順序論理回路などの論理回路によって実現されており、以下の演算処理、すなわち、指数部同士の減算、仮数部同士の減算、符号部同士の排他的論理和演算、仮数部または整数部の算術シフト(左)、仮数部または整数部のインクリメント、指数部または整数部のデクリメント、仮数部同士またはレジスタと指示された値との比較演算、並びに、レジスタの特定のビットの評価が可能なように構成されている。   On the other hand, the arithmetic circuit 21 according to the present embodiment is realized by a logic circuit such as a combinational logic circuit and a sequential logic circuit, for example, an ALU (Arithmetic Logical Unit). That is, subtraction between exponent parts, subtraction between mantissa parts, exclusive OR operation between sign parts, arithmetic shift of mantissa part or integer part (left), increment of mantissa part or integer part, exponent part or integer part The decrement, the mantissa part or the comparison operation between the register and the indicated value, and the evaluation of a specific bit of the register are possible.

より詳細には、演算回路21は、制御回路23から指数部同士の減算が指示された場合、指示された2つのレジスタ(本実施形態では、第1および第2レジスタ11・12)の指数部の領域AE(この例では、AE1およびAE2)から読み出された値同士を減算し、減算結果(例えば、Xe−Ye)を、指示されたレジスタの指示された領域(例えば、第4レジスタ14)に格納できる。同様に、仮数部同士の減算が指示された場合、指示された2つのレジスタ(例えば、第1および第2レジスタ11・12)の仮数部の領域AM(例えば、AM1・AM2)から読み出された値同士を減算し、減算結果(例えば、Xm−Ym)を、指示されたレジスタの指示された領域(例えば、第1レジスタ11の仮数部の領域AM1)へ格納できる。   More specifically, when the subtraction between the exponent parts is instructed from the control circuit 23, the arithmetic circuit 21 uses the exponent parts of the instructed two registers (first and second registers 11 and 12 in this embodiment). The values read from the area AE (AE1 and AE2 in this example) are subtracted from each other, and the subtraction result (for example, Xe−Ye) is subtracted from the specified area (for example, the fourth register 14). ) Can be stored. Similarly, when the subtraction between the mantissa parts is instructed, it is read out from the mantissa area AM (eg, AM1 · AM2) of the two instructed registers (eg, the first and second registers 11 and 12). The subtracted values can be subtracted from each other, and the subtraction result (for example, Xm−Ym) can be stored in the designated area of the designated register (for example, the mantissa area AM1 of the first register 11).

また、演算回路21は、制御回路23から、符号部同士の排他的論理和演算が指示された場合、指示された2つのレジスタ(例えば、第1および第2レジスタ11・12)の符号の領域(例えば、AS1・AS2)から読み出された値同士の排他的論理和を算出し、演算結果(Xs EOR Ys)を、指示されたレジスタの指示された領域(例えば、第1レジスタ11の符号の領域AS1)へ格納できる。   In addition, when an exclusive OR operation between the code parts is instructed from the control circuit 23, the arithmetic circuit 21 is a code area of the instructed two registers (for example, the first and second registers 11 and 12). The exclusive OR of the values read from (for example, AS1 and AS2) is calculated, and the operation result (Xs EOR Ys) is calculated in the designated area of the designated register (for example, the sign of the first register 11). In the area AS1).

さらに、演算回路21は、制御回路23が仮数部または整数部の左シフトを指示した場合、演算回路21は、指示されたレジスタの指示された領域(例えば、第1レジスタ11の仮数部AM1、第3レジスタ13の整数部AM3など)から読み出した値を、指示された桁だけ、左シフトすると共に、シフト後の値を、読み出した領域に書き込むことができる。なお、この左シフトは、算術的な左シフトであり、シフトの結果、新たに挿入される下位桁の値は、”0”に設定されている。さらに、演算回路21は、例えば、最上位ビットが”1”のときに左シフトする場合など、左シフトの結果、桁あふれが発生した場合、桁あふれの発生を制御回路23へ伝えることができる。   Further, when the control circuit 23 instructs the left shift of the mantissa part or the integer part, the arithmetic circuit 21 reads the indicated area of the indicated register (for example, the mantissa part AM1 of the first register 11, The value read from the integer part AM3 of the third register 13 and the like can be shifted to the left by the designated digit, and the shifted value can be written in the read area. This left shift is an arithmetic left shift. As a result of the shift, the value of the newly inserted lower digit is set to “0”. Furthermore, the arithmetic circuit 21 can notify the control circuit 23 of the occurrence of an overflow when, for example, a left overflow occurs as a result of the left shift, for example, when the most significant bit is “1”. .

また、演算回路21は、制御回路23から、デクリメントまたはインクリメントが指示された場合、指示されたレジスタの指示された領域(第1レジスタ11の指数部AE1、第3レジスタ13の整数部AM3、第4レジスタ14など)から読み出した値をデクリメントまたはインクリメントして、上記値を読み出した領域へ演算結果を格納できる。   In addition, when the decrement or increment is instructed from the control circuit 23, the arithmetic circuit 21 indicates the designated area (the exponent part AE1 of the first register 11, the integer part AM3 of the third register 13, the second register 13). The value read from the 4 register 14 or the like can be decremented or incremented, and the calculation result can be stored in the area where the value is read.

さらに、演算回路21は、制御回路23から、仮数部同士の比較が指示された場合、指示された2つのレジスタの仮数部の領域(例えば、第1および第2レジスタ11・12の仮数部AM1・AM2)から値を読み出し、両者を比較すると共に、比較結果を、制御回路23へ返答できる。同様に、制御回路23から、予め定められた値との比較が指示された場合、指示された1つのレジスタの指示された領域(例えば、第4レジスタ14など)と、指示された値(例えば、0、n、またはL−1など)とを比較し、比較結果を返答できる。   Further, when the control circuit 23 instructs the mantissa parts to be compared with each other, the arithmetic circuit 21 has a mantissa part area of the two designated registers (for example, the mantissa part AM1 of the first and second registers 11 and 12). A value can be read from AM2) and compared, and the comparison result can be returned to the control circuit 23. Similarly, when a comparison with a predetermined value is instructed from the control circuit 23, an instructed area (for example, the fourth register 14) of one instructed register and an instructed value (for example, , 0, n, or L-1) and the comparison result can be returned.

また、演算回路21は、制御回路23から、あるビットの評価が指示された場合、指示されたレジスタの指示された領域のうち、指示されたビット(例えば、第1レジスタ11の領域AM1の最上位ビットなど)を評価して、当該ビットが”0”か”1”かを、制御回路23へ返答できる。   In addition, when an evaluation of a certain bit is instructed from the control circuit 23, the arithmetic circuit 21 selects the indicated bit (for example, the top of the area AM 1 of the first register 11) out of the indicated area of the indicated register. Evaluating the higher order bits), it is possible to return to the control circuit 23 whether the bit is “0” or “1”.

一方、本実施形態に係る転送制御回路22は、例えば、論理回路によって構成された回路であって、制御回路23の指示に応じて、各レジスタへ、予め定められた値を格納することができる。また、上記転送制御回路22は、制御回路23の指示に応じて、メモリ31から読み出した被除数xまたは除数yを、指示されたレジスタ(例えば、第1および第2レジスタ11・12)へ格納したり、制御回路23の指示に基づいて、指示されたレジスタ(例えば、第1および第3レジスタ11・13)に格納された演算結果X、Qを、例えば、演算結果の表示処理など、後の処理で利用するために、メモリ31へ格納したりすることができる。   On the other hand, the transfer control circuit 22 according to the present embodiment is, for example, a circuit configured by a logic circuit, and can store predetermined values in each register in accordance with an instruction from the control circuit 23. . Further, the transfer control circuit 22 stores the dividend x or divisor y read from the memory 31 in the designated register (for example, the first and second registers 11 and 12) in accordance with an instruction from the control circuit 23. Or the operation results X and Q stored in the instructed registers (for example, the first and third registers 11 and 13) based on the instruction of the control circuit 23, for example, a display process of the operation results, etc. It can be stored in the memory 31 for use in processing.

また、制御回路23は、例えば、演算回路21または転送制御回路22へ処理を特定する命令コードを示す制御信号を与えるなどして、演算回路21および転送制御回路22へ、実施すべき処理を示す制御信号を印加して、それぞれを制御できる。さらに、制御回路23は、予め定められた順序で、各レジスタ11・12、演算回路21および転送制御回路22を制御するだけではなく、予め定められたアルゴリズムに従って、演算回路21の演算結果のうち、比較結果および指数部の値の差を受け取って、それに応じて、それ以降における、各レジスタ11・12、演算回路21および転送制御回路22の制御を変更できる。なお、上記アルゴリズムの詳細については、演算装置1の全体の動作と合わせて後述する。   Further, the control circuit 23 indicates the processing to be performed to the arithmetic circuit 21 and the transfer control circuit 22 by giving a control signal indicating an instruction code for specifying the processing to the arithmetic circuit 21 or the transfer control circuit 22, for example. Each can be controlled by applying a control signal. Further, the control circuit 23 not only controls each of the registers 11 and 12, the arithmetic circuit 21 and the transfer control circuit 22 in a predetermined order, but also includes the result of the arithmetic circuit 21 according to a predetermined algorithm. By receiving the difference between the comparison result and the value of the exponent part, the control of each of the registers 11 and 12, the arithmetic circuit 21, and the transfer control circuit 22 can be changed accordingly. The details of the algorithm will be described later together with the overall operation of the arithmetic device 1.

上記制御回路23は、例えば、当該アルゴリズムで、各レジスタ11・12、演算回路21および転送制御回路22を制御できれば、予め定められたタイミングおよび順序で、それぞれへ、それぞれの制御信号を出力すると共に、予め定められたタイミングで、演算回路21の出力を読み出して、上記制御信号を与えるか否か、並びに、上記制御信号印加のタイミングおよび順序を変更する論理回路によって実現してもよい。また、例えば、CPUなどの演算手段が、ROMやRAMなどの記憶装置(いずれも図示せず)に格納されたプログラムを実行し、上記各レジスタ11・12、演算回路21および転送制御回路22を制御することによって実現してもよい。この場合は、これらの手段を有する1または複数のコンピュータが、上記プログラムを記録した記録媒体(例えば、CD−ROMなど)を読み取り、当該プログラムを実行するだけで、本実施形態に係る演算装置1を実現できる。   For example, if the control circuit 23 can control the registers 11 and 12, the arithmetic circuit 21 and the transfer control circuit 22 with the algorithm, the control circuit 23 outputs each control signal to each at a predetermined timing and order. Alternatively, it may be realized by a logic circuit that reads the output of the arithmetic circuit 21 at a predetermined timing and applies the control signal, and changes the timing and order of the application of the control signal. Further, for example, an arithmetic means such as a CPU executes a program stored in a storage device such as a ROM or a RAM (none of which is shown), and the registers 11 and 12, the arithmetic circuit 21 and the transfer control circuit 22 are connected. You may implement | achieve by controlling. In this case, one or a plurality of computers having these means reads the recording medium (for example, CD-ROM) on which the program is recorded, and executes the program, whereby the arithmetic device 1 according to the present embodiment is executed. Can be realized.

上記構成において、例えば、メモリ31の予め定められた記憶領域へ、被除数および除数が格納され、制御回路23の予め定められたアドレスへ演算開始の指示を示す命令が書き込まれるなどして、演算装置1へ、被除数xの除数yによるスケーリング処理の開始が指示されると、演算装置1は、図3に示すステップ1(以下では、S1のように略称する)において、詳細は後述するように、第1〜第4レジスタ11〜14を初期化して、第1および第2レジスタ11・12へ、被除数xおよび除数yを設定すると共に、第3レジスタ13に0を格納し、第4レジスタ14へ、被除数xの指数部から除数yの指数部を引いた値を設定する。なお、本実施形態に係る演算装置1は、上記S1における初期化処理において、スケーリング処理の要否や可否(後述)も併せて判定している。   In the above configuration, for example, the dividend and the divisor are stored in a predetermined storage area of the memory 31, and a command indicating an instruction to start the operation is written to a predetermined address of the control circuit 23. When the start of the scaling process by the divisor y of the dividend x is instructed to 1, the arithmetic unit 1 in step 1 shown in FIG. 3 (hereinafter abbreviated as S1), as will be described in detail later. The first to fourth registers 11 to 14 are initialized, the dividend x and the divisor y are set in the first and second registers 11 and 12, 0 is stored in the third register 13, and the fourth register 14 is stored. The value obtained by subtracting the exponent part of the divisor y from the exponent part of the dividend x is set. Note that the arithmetic device 1 according to the present embodiment also determines whether or not the scaling process is necessary or not (described later) in the initialization process in S1.

以下では、第1〜第4レジスタ11〜14に格納された値を、それぞれ、X、Y、QおよびZで参照する。また、それぞれの符号を、例えば、Xの符号をXsのように、参照符号の末尾にsを付けて参照し、それぞれの仮数部または整数の絶対値を、参照符号の末尾にmをつけて参照する。さらに、XおよびYの指数部を、それぞれXe、Yeと称する。また、本実施形態に係る演算装置1では、一例として、三角関数Sin(x)を算出する際のxを、π/2でスケーリングして、−π/2から+π/2の範囲に入れているので、上記S1の初期化処理によって、上記第1レジスタ11にxが格納され、第2レジスタ12には、y=π/2が格納される。   Hereinafter, the values stored in the first to fourth registers 11 to 14 are referred to as X, Y, Q, and Z, respectively. Further, each code is referred to by adding s to the end of the reference code, for example, the code of X is Xs, and the mantissa part or the absolute value of the integer is added with m at the end of the reference code. refer. Furthermore, the exponent parts of X and Y are referred to as Xe and Ye, respectively. In addition, in the arithmetic device 1 according to the present embodiment, as an example, x when the trigonometric function Sin (x) is calculated is scaled by π / 2, and is put in a range of −π / 2 to + π / 2. Therefore, x is stored in the first register 11 and y = π / 2 is stored in the second register 12 by the initialization process of S1.

上記S1において、初期化処理が終了すると、演算装置1の制御回路23は、S2において、演算回路21へ指示して、第1および第2レジスタ11・12に格納された値の符号部同士の排他的論理和を算出させ、演算結果を、第1レジスタ11の符号部の領域AS1へ格納させる(Xs EOR Ys →Xs)。   When the initialization process is completed in S1, the control circuit 23 of the arithmetic device 1 instructs the arithmetic circuit 21 in S2, and the sign parts of the values stored in the first and second registers 11 and 12 are exchanged. The exclusive OR is calculated, and the calculation result is stored in the area AS1 of the sign part of the first register 11 (Xs EOR Ys → Xs).

また、制御回路23は、以下のS3〜S9の処理を、上記S1にて第4レジスタ14へ格納された値Zの回数だけ繰り返させる。具体的には、S3において、制御回路23は、演算回路21へ指示して、第1および第2レジスタ11・12に格納された値の仮数部Xm・Ymを比較させ、比較結果を受け取る。   Further, the control circuit 23 repeats the following processes of S3 to S9 as many times as the value Z stored in the fourth register 14 in S1. Specifically, in S3, the control circuit 23 instructs the arithmetic circuit 21 to compare the mantissa parts Xm and Ym of the values stored in the first and second registers 11 and 12, and receives the comparison result.

上記仮数部Xmが仮数部Ym以上の場合(上記S3にて、YES の場合)、制御回路23は、S4において、演算回路21へ指示して、第1レジスタ11の仮数部Xmから第2レジスタ12の仮数部Ymの値を減算させ、減算結果を、第1レジスタ11の仮数部の領域AM1へ格納させる。さらに、演算回路21は、制御回路23の指示に従って、上記第3レジスタ13に格納された値の仮数部Qmを1増加させ、演算結果を、第3レジスタ13の仮数部の領域AM1に格納する(S5)。   When the mantissa part Xm is greater than or equal to the mantissa part Ym (in the case of YES in S3), the control circuit 23 instructs the arithmetic circuit 21 in S4 to change from the mantissa part Xm of the first register 11 to the second register. The value of 12 mantissa part Ym is subtracted, and the subtraction result is stored in the mantissa part area AM 1 of the first register 11. Further, the arithmetic circuit 21 increments the mantissa part Qm of the value stored in the third register 13 by 1 according to the instruction of the control circuit 23, and stores the arithmetic result in the mantissa part area AM 1 of the third register 13. (S5).

上記S4およびS5の処理が終了した場合、あるいは、上記仮数部Xmが仮数部Ymよりも小さかった場合(上記S3にて、NOの場合)、制御回路23は、S6において、演算回路21へ指示して、第4レジスタ14に格納された値と”0”とを比較させ、比較結果を受け取る。両者が一致した場合(上記S6にてYES の場合)、詳細は後述するように、S21において、演算装置1は、第1レジスタ11に格納されている値Xの形式を変換して、当該値Xの仮数部の最上位ビットが1になるように正規化し、S22において、制御回路23は、転送制御回路22へ指示して、第1レジスタ11に格納された浮動小数点数Xと、第3レジスタ13に格納された商Qとを、メモリ31へ格納させるなどして、スケーリング処理の結果を出力させる。   When the processes of S4 and S5 are completed, or when the mantissa part Xm is smaller than the mantissa part Ym (NO in S3), the control circuit 23 instructs the arithmetic circuit 21 in S6. Then, the value stored in the fourth register 14 is compared with “0”, and the comparison result is received. If the two match (YES in S6), as will be described in detail later, in S21, the arithmetic unit 1 converts the format of the value X stored in the first register 11 to obtain the value. Normalization is performed so that the most significant bit of the mantissa part of X becomes 1, and in S22, the control circuit 23 instructs the transfer control circuit 22 to specify the floating point number X stored in the first register 11 and the third number. The quotient Q stored in the register 13 is stored in the memory 31, and the result of the scaling process is output.

一方、第4レジスタ14に格納された値が0でなかった場合(上記S6にてNOの場合)、制御回路23は、S7において、演算回路21へ指示して、第1レジスタ11に格納された値の指数部Xeから1減算させ、減算結果を、第1レジスタ11指数部の領域AE1へ格納させると共に、第4レジスタ14に格納された値Zから1減算させ、演算結果を第4レジスタ14に格納させる。また、演算回路21は、制御回路23の指示に従って、第1レジスタ11に格納された値の仮数部Xmを1ビット左シフトし、第1レジスタ11の仮数部の領域AM1へ演算結果を格納すると共に、第3レジスタ13に格納された値の絶対値Qmを、1ビット左シフトし、第3レジスタ13の絶対値の領域AM3へ演算結果を格納する(S8)。 On the other hand, if the value stored in the fourth register 14 is not 0 (NO in S6), the control circuit 23 instructs the arithmetic circuit 21 in S7 and stores it in the first register 11. 1 is subtracted from the exponent part Xe of the obtained value, the subtraction result is stored in the area AE1 of the exponent part of the first register 11 , and 1 is subtracted from the value Z stored in the fourth register 14, and the operation result is given as the fourth. It is stored in the register 14. In addition, the arithmetic circuit 21 shifts the mantissa part Xm of the value stored in the first register 11 to the left by 1 bit according to the instruction of the control circuit 23 and stores the arithmetic result in the mantissa part area AM1 of the first register 11. At the same time, the absolute value Qm of the value stored in the third register 13 is shifted one bit to the left, and the calculation result is stored in the absolute value area AM3 of the third register 13 (S8).

さらに、制御回路23は、S9において、上記S8における仮数部Xmの左シフトによって、桁あふれが発生しているか否かを判定し、桁あふれが発生していない場合(上記S9にて、YES の場合)、上記S3以降の処理を繰り返す。一方、桁あふれが発生している場合は、上記S4以降の処理を繰り返す。   Further, in S9, the control circuit 23 determines whether or not an overflow has occurred due to the left shift of the mantissa part Xm in S8. If no overflow has occurred (YES in S9). ), The above-described processing after S3 is repeated. On the other hand, when the digit overflow has occurred, the processing after S4 is repeated.

上記構成では、上記S3〜S5およびS7〜S9の繰り返し回数が、上記S1において第4レジスタ14に格納された値、すなわち、被除数xの指数部から除数yの指数部を引いた値に設定されている。したがって、繰り返しの終了時点(S6にて、YES の時点)における第3レジスタ13の値Qが、整数化された除算結果であり、当該時点における第1レジスタ11の値Xが、余りになる。   In the above configuration, the number of repetitions of S3 to S5 and S7 to S9 is set to the value stored in the fourth register 14 in S1, that is, the value obtained by subtracting the exponent part of the divisor y from the exponent part of the dividend x. ing. Accordingly, the value Q of the third register 13 at the end of the repetition (YES at S6) is the integer division result, and the value X of the first register 11 at that time becomes the remainder.

したがって、通常の除算と同様に、有効数字の回数だけ、上記S3〜S5およびS7〜S9の処理を繰り返して、除算結果を求め、当該除算結果を整数化すると共に、被除数から、整数化された値と除数との乗算結果を減算する場合と比較して、上記処理の繰り返し回数を削減できる。この結果、より少ない演算量および演算時間で、整数化された除算結果と余りとを算出できる。   Therefore, as in normal division, the processes of S3 to S5 and S7 to S9 are repeated by the number of significant digits to obtain a division result, the division result is converted to an integer, and the integer is converted from the dividend. Compared to the case where the multiplication result of the value and the divisor is subtracted, the number of repetitions of the above process can be reduced. As a result, it is possible to calculate the integer division result and the remainder with a smaller calculation amount and calculation time.

なお、上記では、S1にて第4レジスタ14に格納された値Zだけ、S3〜S9の処理を繰り返すために、S7において、Zを減算すると共に、S6において、Zが0であるか否かを判定しているが、これに限るものではない。例えば、制御回路23が演算回路21へ指示して、Z<0か否かを判定させると共に、Zの減算処理を、判定の前に移動させてもよい。いずれの場合であっても、上記S3〜S5およびS7〜S9の繰り返す回数が、被除数xの指数部から除数yの指数部を引いた値であれば、同様の効果が得られる。 In the above, in order to repeat the processing of S3 to S9 by the value Z stored in the fourth register 14 in S1, Z is subtracted in S7, and whether or not Z is 0 in S6. However, the present invention is not limited to this. For example, the control circuit 23 may instruct the arithmetic circuit 21 to determine whether or not Z <0, and the Z subtraction process may be moved before the determination. In any case, the same effect can be obtained if the number of repetitions of S3 to S5 and S7 to S9 is a value obtained by subtracting the exponent part of the divisor y from the exponent part of the dividend x.

また、上記では、S5において、1を加算することによって、第3レジスタ13の整数部の値Qmの最下位ビットに1を設定しているが、上記S1における第3レジスタ13の0クリアあるいは上記S8における左シフトによって、最下位ビットが”0”なので、演算回路21が制御回路23の指示に応じて、最下位ビットに”1”を設定しても、同様の効果が得られる。   In the above description, in S5, 1 is set to the least significant bit of the value Qm of the integer part of the third register 13 by adding 1, but the third register 13 in S1 is cleared to 0 or Since the least significant bit is “0” by the left shift in S8, the same effect can be obtained even if the arithmetic circuit 21 sets “1” in the least significant bit in accordance with an instruction from the control circuit 23.

以下では、上記S1の初期化処理およびS21の正規化処理について、やや詳細に説明する。すなわち、上記S1では、図4に示す各ステップS31〜S36が行われている。すなわち、演算装置1が被除数xの除数yによるスケーリング処理の開始指示を受け付けると、S31において、演算装置1の制御回路23は、転送制御回路22へ指示して、第1レジスタ11へ被除数となる浮動小数点数xを格納させると共に、第2レジスタ12へ除数となる浮動小数点数yを格納させる。また、転送制御回路22は、S32において、制御回路23の指示に従って、第3レジスタ13の値を0に設定する。   Hereinafter, the initialization process of S1 and the normalization process of S21 will be described in some detail. That is, in S1, the steps S31 to S36 shown in FIG. 4 are performed. In other words, when the arithmetic device 1 receives an instruction to start scaling processing by the divisor y of the dividend x, the control circuit 23 of the arithmetic device 1 instructs the transfer control circuit 22 to become the dividend to the first register 11 in S31. A floating point number x is stored, and a floating point number y as a divisor is stored in the second register 12. In S32, the transfer control circuit 22 sets the value of the third register 13 to 0 in accordance with an instruction from the control circuit 23.

さらに、演算回路21は、S33において、制御回路23の指示に従って、第1レジスタ11に格納された値の指数部Xeから、第2レジスタ12に格納された値の指数部Yeを減算させ、第4レジスタ14に減算結果を格納させる。   Further, in S33, the arithmetic circuit 21 subtracts the exponent part Ye of the value stored in the second register 12 from the exponent part Xe of the value stored in the first register 11 according to the instruction of the control circuit 23, The subtraction result is stored in the 4 register 14.

また、演算装置1は、S34およびS35において、演算回路21へ指示して、第4レジスタ14に格納された値Zが0以上、かつ、予め定められた値(L−1)以下の範囲に入っているか否かを判定している。なお、Lは、第3レジスタ13において、整数の絶対値を格納するために設けられた領域のビット幅である。   In S34 and S35, the arithmetic unit 1 instructs the arithmetic circuit 21 so that the value Z stored in the fourth register 14 is in the range of 0 or more and a predetermined value (L-1) or less. It is judged whether it is in or not. Note that L is the bit width of an area provided for storing the absolute value of an integer in the third register 13.

本実施形態では、上記値Zが負であるか否か、および、(L−1)を超えているか否かによって、上記範囲内か否かを判定している。より詳細には、制御回路23は、S34において、演算回路21へ指示して、第4レジスタ14に格納された値Zが負であるか否かを判定させて、判定結果を受け取る。判定結果が負を示している場合(上記S34にてYES の場合)、これは、被除数Xが除数Yよりも小さいことを示しており、スケーリング処理するまでもなく、商は、0であり、被除数Xは、余りになることを示している。したがって、この場合、制御回路23は、図3に示すS2〜S21をスキップして、S22の処理を行い、上記S32にて第3レジスタ13に設定された値(Q=0)と、上記S31にて第1レジスタ11に設定された値(X=x)とをスケーリング結果として出力する。   In the present embodiment, whether the value Z is in the above range is determined based on whether the value Z is negative and whether it exceeds (L-1). More specifically, in S34, the control circuit 23 instructs the arithmetic circuit 21 to determine whether or not the value Z stored in the fourth register 14 is negative, and receives the determination result. When the determination result indicates negative (in the case of YES in S34 above), this indicates that the dividend X is smaller than the divisor Y, and the quotient is 0 without performing scaling processing. The dividend X indicates that there is a remainder. Therefore, in this case, the control circuit 23 skips S2 to S21 shown in FIG. 3, performs the process of S22, and sets the value (Q = 0) set in the third register 13 in S32 and the above S31. The value (X = x) set in the first register 11 is output as a scaling result.

一方、第4レジスタ14に格納された値Zが負ではない場合(上記S34にて、NOの場合)、制御回路23は、S35において、演算回路21へ指示し、第4レジスタ14に格納された値Zと上記値(L−1)とを比較させて、比較結果を受け取る。比較結果がL−1よりも大きいことを示している場合(上記S35にてYES の場合)、これは、商が第3レジスタ13に格納できない程大きくなることを示している。したがって、この場合は、制御回路23は、S36において、例えば、転送制御回路22へ指示して、第1レジスタ11を0クリアさせた後、メモリ31の演算結果を格納する領域に、第1レジスタ11の値を格納させると共に、例えば、メモリ31のうち、異常発生の有無を示す領域へ、異常発生を示す値を格納させるなどして、異常終了処理を行わせる。   On the other hand, when the value Z stored in the fourth register 14 is not negative (NO in S34), the control circuit 23 instructs the arithmetic circuit 21 in S35 and is stored in the fourth register 14. A comparison result is received by comparing the obtained value Z with the value (L-1). When the comparison result indicates that it is greater than L-1 (YES in S35), this indicates that the quotient becomes so large that it cannot be stored in the third register 13. Therefore, in this case, the control circuit 23 instructs the transfer control circuit 22, for example, to clear the first register 11 to 0 in S36, and then stores the operation result of the memory 31 in the first register area. 11 is stored, and for example, the abnormal end process is performed by storing a value indicating the occurrence of an abnormality in an area of the memory 31 indicating the presence or absence of an abnormality.

これに対して、演算装置1が、第4レジスタ14に格納された値Zが0以上、かつ、予め定められた値(L−1)以下の範囲に入っていると判定した場合(上記S34およびS35の双方でNOの場合)、制御回路23は、初期化処理を終了し、図3に示すS2以降の処理を実行する。   On the other hand, when the arithmetic unit 1 determines that the value Z stored in the fourth register 14 is in the range of 0 or more and not more than a predetermined value (L-1) (S34 described above). In the case of NO in both S35 and S35), the control circuit 23 ends the initialization process and executes the processes after S2 shown in FIG.

上記構成では、S2以降のスケーリング処理を開始する前に、演算装置1が、第4レジスタ14に格納された値Zが0以上、かつ、予め定められた値(L−1)以下の範囲に入っているか否かを判定し、入っていない場合は、S2以降の処理をスキップしている。この結果、S2以降の処理を行うまでもなく、余りおよび商が判明している場合、あるいは、当該処理を行うまでもなく、S2以降の処理で正しい商が算出できないと判明している場合は、当該処理をスキップでき、不要な処理の実施を防止できる。この結果、上記判定を行わない場合よりも、全ての処理が終わるまでの時間を短縮できる。   In the above configuration, before starting the scaling process after S2, the arithmetic unit 1 makes the value Z stored in the fourth register 14 be in a range not less than 0 and not more than a predetermined value (L-1). It is determined whether or not it is entered. If it is not entered, the processing after S2 is skipped. As a result, when the process after S2 is not performed and the remainder and the quotient are known, or when it is determined that the correct quotient cannot be calculated by the process after S2 without performing the process. The processing can be skipped, and unnecessary processing can be prevented. As a result, it is possible to shorten the time until all the processes are completed, compared with the case where the above determination is not performed.

一方、図3に示すS21の正規化処理では、図5に示すように、S41〜S51の処理が行われている。具体的には、制御回路23は、S41において、演算回路21へ指示して、第4レジスタ14の値Zとnとを比較させ、比較結果を受け取る。なお、nは、上述したように、第1および第2レジスタ11・12の仮数部のビット幅である。   On the other hand, in the normalization process of S21 shown in FIG. 3, the processes of S41 to S51 are performed as shown in FIG. Specifically, in S41, the control circuit 23 instructs the arithmetic circuit 21 to compare the value Z of the fourth register 14 with n, and receives the comparison result. Note that n is the bit width of the mantissa part of the first and second registers 11 and 12 as described above.

両者が一致しない場合(上記S41にてNOの場合)、制御回路23は、S42において、演算回路21へ指示して、第1レジスタ11の仮数部の最上位ビットの値を評価させ、評価結果を受け取る。   If they do not match (NO in S41), the control circuit 23 instructs the arithmetic circuit 21 in S42 to evaluate the value of the most significant bit of the mantissa part of the first register 11, and the evaluation result Receive.

最上位ビットが”1”を示している場合(上記S42にてYES の場合)、第1レジスタ11の値Xは、既に正規化されていることを示している。したがって、この場合、制御回路23は、正規化処理を終了し、図3に示すS22以降の処理を実行する。   If the most significant bit indicates “1” (YES in S42), the value X of the first register 11 indicates that it has already been normalized. Therefore, in this case, the control circuit 23 ends the normalization process, and executes the processes after S22 shown in FIG.

これに対して、最上位ビットが”1”ではない場合(上記S42にてNOの場合)、制御回路23は、S43において、演算回路21へ指示して、第1レジスタ11の指数部の値Xeを1減少させると共に、第1レジスタ11の指数部の領域AE1へ格納させる。さらに、演算回路21は、制御回路23の指示に基づいて、第1レジスタ11の仮数部の値Xmを1ビット左シフトさせ、その結果を、第1レジスタ11の仮数部の領域AM1へ格納させる。また、制御回路23は、演算回路21へ指示して、第4レジスタ14の値を1増加させる。さらに、制御回路23は、S41以降の処理を繰り返す。   On the other hand, when the most significant bit is not “1” (NO in S42), the control circuit 23 instructs the arithmetic circuit 21 in S43 to indicate the value of the exponent part of the first register 11. Xe is decremented by 1 and stored in the exponent part area AE1 of the first register 11. Further, the arithmetic circuit 21 shifts the value Xm of the mantissa part of the first register 11 to the left by 1 bit based on the instruction of the control circuit 23 and stores the result in the area AM1 of the mantissa part of the first register 11. . In addition, the control circuit 23 instructs the arithmetic circuit 21 to increase the value of the fourth register 14 by one. Further, the control circuit 23 repeats the processes after S41.

ここで、上記S41〜S43の処理は、第1レジスタ11の仮数部の最上位ビットが”1”になるまでの間、繰り返されるが、余りが0の場合、当該仮数部のビット幅の回数(n回)だけ繰り返しても、最上位ビットが”1”になることはない。この場合は、上記S41において、ループカウンタの値Zがnに一致する(上記S41にて、YES )。したがって、制御回路23は、制御回路23は、S51において、転送制御回路22へ指示して、第1レジスタ11へ0を格納させた後、正規化処理を終了し、図3に示すS22以降の処理を実行する。   Here, the processing of S41 to S43 is repeated until the most significant bit of the mantissa part of the first register 11 becomes “1”. If the remainder is 0, the number of times of the bit width of the mantissa part Even if it is repeated (n times), the most significant bit does not become “1”. In this case, in S41, the value Z of the loop counter coincides with n (YES in S41). Therefore, the control circuit 23 instructs the transfer control circuit 22 in S51 to store 0 in the first register 11, and then ends the normalization process. Execute the process.

上記構成では、S41〜S51の正規化処理によって、余りが0でない限り、余りの仮数部の最上位ビットが1になるように、余りの指数部が調整される。したがって、スケーリング処理後の演算において、余りが正規化されていることが求められている場合であっても、何ら支障なく、演算を続けることができる。   In the above configuration, the remainder exponent part is adjusted by the normalization process of S41 to S51 so that the most significant bit of the remainder mantissa part becomes 1 unless the remainder is 0. Therefore, even if the remainder after the scaling process is required to be normalized, the calculation can be continued without any trouble.

なお、上記では、上記S42およびS43の処理をn回繰り返すために、第4レジスタ14をループカウンタにして、上記S41にて、終了条件(Z==n)が成立しているか否かを判定しているが、これらの処理をn回繰り返すことができれば、これに限るものではない。例えば、別のレジスタを設け、当該レジスタをループカウンタにしてもよい。なお、この場合は、上記S41の前に、当該レジスタの値を0にクリアすると、S41の終了条件を同じ(==n)にできる。また、上記繰り返し回数は、第1および第2レジスタ11・12の仮数部のビット幅によって決まるので、プログラム中に、上記S42およびS43の処理のためのプログラムコードをn回繰り返して配置してもよい。いずれの場合であっても、上記S42およびS43の処理をn回繰り返すことができれば、同様の効果が得られる。   In the above, in order to repeat the processing of S42 and S43 n times, the fourth register 14 is set as a loop counter, and it is determined whether or not the end condition (Z == n) is satisfied in S41. However, the present invention is not limited to this as long as these processes can be repeated n times. For example, another register may be provided and the register may be a loop counter. In this case, if the value of the register is cleared to 0 before S41, the end condition of S41 can be made the same (== n). The number of repetitions is determined by the bit width of the mantissa part of the first and second registers 11 and 12, so that the program code for the processing of S42 and S43 may be repeated n times in the program. Good. In any case, the same effect can be obtained if the processes of S42 and S43 can be repeated n times.

本発明によれば、より短い時間で、それぞれ浮動小数点数として与えられる被除数を、除数で割ったときの余りと、必要に応じて商(整商)とを得ることができるので、例えば、スケーリング処理などを行う演算装置に好適に使用できる。   According to the present invention, it is possible to obtain a remainder when dividing a dividend given as a floating-point number by a divisor and a quotient (an integer quotient) if necessary in a shorter time. It can be suitably used for an arithmetic device that performs processing or the like.

本発明の実施形態を示すものであり、演算装置の要部構成を示すブロック図である。BRIEF DESCRIPTION OF THE DRAWINGS FIG. 1, showing an embodiment of the present invention, is a block diagram illustrating a main configuration of an arithmetic device. 上記演算装置に設けられたレジスタを示す図面である。It is drawing which shows the register | resistor provided in the said arithmetic unit. 上記演算装置の動作を示す概略フローチャートである。It is a schematic flowchart which shows operation | movement of the said arithmetic unit. 上記動作のうち、初期化処理をより詳細に示すフローチャートである。It is a flowchart which shows an initialization process in more detail among the said operation | movement. 上記動作のうち、余りの正規化処理をより詳細に示すフローチャートである。It is a flowchart which shows the remainder normalization process in more detail among the said operation | movement.

符号の説明Explanation of symbols

1 演算装置
11 第1レジスタ(被除数レジスタ)
12 第2レジスタ(除数レジスタ)
13 第3レジスタ(商レジスタ)
21 演算回路
22 転送制御回路(演算回路)
23 制御回路
1 arithmetic unit 11 first register (dividend register)
12 Second register (divisor register)
13 Third register (quotient register)
21 arithmetic circuit 22 transfer control circuit (arithmetic circuit)
23 Control circuit

Claims (3)

仮数部および指数部を含む浮動小数点数として与えられる被除数および除数をそれぞれ記憶する被除数レジスタおよび除数レジスタと、商を記憶する商レジスタと、整数を記憶する整数レジスタと、これらの各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有する演算装置の制御方法であって
記被除数レジスタの指数部から、上記除数レジスタの指数部を減算する指数部減算工程と、
上記指数部減算工程の減算結果を上記整数レジスタの値に設定する整数レジスタ値初期設定工程と、
上記商レジスタの値を0に設定する商レジスタ値初期設定工程と、
上記指数部減算工程、整数レジスタ値初期設定工程および商レジスタ値初期設定工程よりも後に行われ、上記被除数レジスタの仮数部が上記除数レジスタの仮数部より大きいか又は等しい場合のみ、上記被除数レジスタの仮数部から上記除数レジスタの仮数部を減算して、上記商レジスタの値を1増加させる仮数部減算工程と、
上記仮数部減算工程の後に、上記整数レジスタの値が0であるか否かを判別する判別工程と、
上記判別工程において、上記整数レジスタの値が0でない場合、上記被除数レジスタの指数部と上記整数レジスタの値とをそれぞれ1減算し、上記被除数レジスタの仮数部および上記商レジスタを1桁ずつ左シフトさせ、上記仮数部減算工程に移行させる整数レジスタ値減算工程と、
上記判別工程において、上記整数レジスタの値が0である場合、上記被除数レジスタの浮動小数点数と上記商レジスタの値とを演算結果として出力する出力工程とを含んでいることを特徴とする演算装置の制御方法。
A dividend register and a divisor register for storing a dividend and a divisor given as floating point numbers including a mantissa part and an exponent part, respectively, a quotient register for storing a quotient, an integer register for storing an integer, and values of these registers A control method for an arithmetic device having an arithmetic circuit that performs a reference and a control circuit that controls each of the registers and the arithmetic circuit ,
From the exponent portion of the upper Symbol dividend register, and exponent subtraction step of subtracting the exponent of the divisor register,
An integer register value initial setting step of setting the subtraction result of the exponent part subtraction step to the value of the integer register;
A quotient register value initial setting step for setting the value of the quotient register to 0;
Only after the exponent subtraction step, integer register value initialization step, and quotient register value initialization step, the mantissa part of the dividend register is greater than or equal to the mantissa part of the divisor register. A mantissa subtraction step of subtracting the mantissa of the divisor register from the mantissa to increase the value of the quotient register by 1 ;
A determination step of determining whether the value of the integer register is 0 after the mantissa subtraction step;
In the determining step, when the value of the integer register is not 0, the exponent part of the dividend register and the value of the integer register are each subtracted, and the mantissa part of the dividend register and the quotient register are shifted to the left by one digit. And an integer register value subtraction step for shifting to the mantissa part subtraction step
And an output step of outputting the floating point number of the dividend register and the value of the quotient register as an operation result when the value of the integer register is 0 in the determination step. Control method.
仮数部および指数部を含む浮動小数点数として与えられる被除数および除数をそれぞれ記憶する被除数レジスタおよび除数レジスタと、商を記憶する商レジスタと、整数を記憶する整数レジスタと、これらの各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有するコンピュータに、請求項1記載の各工程を実行させるプログラム。 A dividend register and a divisor register for storing a dividend and a divisor given as floating point numbers including a mantissa part and an exponent part, respectively, a quotient register for storing a quotient, an integer register for storing an integer, and values of these registers A program for causing a computer having an arithmetic circuit to perform a reference and a control circuit for controlling each of the registers and the arithmetic circuit to execute each step according to claim 1. 請求項記載のプログラムが記録されたコンピュータ読み取り可能な記録媒体。 A computer-readable recording medium on which the program according to claim 2 is recorded.
JP2004006729A 2004-01-14 2004-01-14 Control method of arithmetic device, program thereof and recording medium Expired - Lifetime JP4271589B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2004006729A JP4271589B2 (en) 2004-01-14 2004-01-14 Control method of arithmetic device, program thereof and recording medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2004006729A JP4271589B2 (en) 2004-01-14 2004-01-14 Control method of arithmetic device, program thereof and recording medium

Publications (2)

Publication Number Publication Date
JP2005202571A JP2005202571A (en) 2005-07-28
JP4271589B2 true JP4271589B2 (en) 2009-06-03

Family

ID=34820607

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2004006729A Expired - Lifetime JP4271589B2 (en) 2004-01-14 2004-01-14 Control method of arithmetic device, program thereof and recording medium

Country Status (1)

Country Link
JP (1) JP4271589B2 (en)

Also Published As

Publication number Publication date
JP2005202571A (en) 2005-07-28

Similar Documents

Publication Publication Date Title
US7647367B2 (en) Apparatus and method for calculating a multiplication
JP4374363B2 (en) Bit field operation circuit
CN102084335B (en) Implementation of arbitrary galois field arithmetic on a programmable processor
CN107769791B (en) Apparatus and method for fixed-to-floating point conversion and negative power detector of 2
US9223545B2 (en) Modified fixed-point algorithm for implementing infrared sensor radiation equation
JP2835153B2 (en) High radix divider
JP6933810B2 (en) Arithmetic processing unit and control method of arithmetic processing unit
CN106250098B (en) Apparatus and method for controlling rounding when performing floating point operations
US9851947B2 (en) Arithmetic processing method and arithmetic processor having improved fixed-point error
GB2543511A (en) Rounding reciprocal square root results
JP4858794B2 (en) Floating point divider and information processing apparatus using the same
US9009209B2 (en) Processor, control method of processor, and computer readable storage medium storing processing program for division operation
JP2502836B2 (en) Preprocessing device for division circuit
JP4271589B2 (en) Control method of arithmetic device, program thereof and recording medium
JP5175983B2 (en) Arithmetic unit
JP4997812B2 (en) Calculation apparatus and calculation program
US7016927B2 (en) Method and apparatus for modular multiplication
US6820106B1 (en) Method and apparatus for improving the performance of a floating point multiplier accumulator
US7237000B2 (en) Speed of execution of a conditional subtract instruction and increasing the range of operands over which the instruction would be performed correctly
JP2005128907A (en) Method for controlling arithmetic unit, arithmetic unit, its program, and recording medium
JP3793505B2 (en) Arithmetic unit and electronic circuit device using the same
TWI753668B (en) Information processing apparatus, computer program, recording medium and information processing method
JP4893340B2 (en) Calculation apparatus and calculation program
JP4109181B2 (en) Logic circuit, and floating-point arithmetic circuit and microprocessor using the same
CN116991362A (en) Modular multiplication operation processing method, device, electronic equipment and readable medium

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20061017

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20081125

RD02 Notification of acceptance of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7422

Effective date: 20090106

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20090121

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20090224

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20090225

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120306

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Ref document number: 4271589

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120306

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130306

Year of fee payment: 4

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130306

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20140306

Year of fee payment: 5

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313111

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

EXPY Cancellation because of completion of term