JP2005128907A - Method for controlling arithmetic unit, arithmetic unit, its program, and recording medium - Google Patents
Method for controlling arithmetic unit, arithmetic unit, its program, and recording medium Download PDFInfo
- Publication number
- JP2005128907A JP2005128907A JP2003365520A JP2003365520A JP2005128907A JP 2005128907 A JP2005128907 A JP 2005128907A JP 2003365520 A JP2003365520 A JP 2003365520A JP 2003365520 A JP2003365520 A JP 2003365520A JP 2005128907 A JP2005128907 A JP 2005128907A
- Authority
- JP
- Japan
- Prior art keywords
- register
- registers
- value
- mantissa
- mantissa part
- 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.)
- Pending
Links
Images
Abstract
Description
本発明は、浮動小数点数を演算する際、正しく丸められた演算結果を、全体として、より短い時間で得る演算装置の制御方法、演算装置、並びに、そのプログラムおよび記録媒体に関するものである。 The present invention relates to a control method for an arithmetic device, an arithmetic device, a program, and a recording medium for obtaining a correct rounded operation result in a shorter time as a whole when calculating a floating point number.
従来から、floating 演算や、電卓のような簡易小数点付き演算のように、浮動小数点数を演算する際、演算精度を向上させたり、2進数と10進数との見かけ上の違いを補正したりするために、例えば、後述の特許文献1のように、演算結果として必要な桁数よりも1桁以上余分に演算し、演算の後で、当該値が、予め定められた数(2進演算の場合は、”1”、10進演算の場合は、”5”)を超えているか否かを判定し、超えている場合は、その上の桁を1増加させる処理(丸め処理)が広く行われている。
しかしながら、上記従来の構成では、1桁以上余分に演算した後で、丸め処理を行っているため、演算に時間がかかるという問題を生じる。 However, in the above-described conventional configuration, the calculation is time-consuming because the rounding process is performed after calculating one or more extra digits.
本発明は、上記の問題点に鑑みてなされたものであり、その目的は、正しく丸められた演算結果を、全体として、より短い時間で得ることが可能な演算装置の制御方法および演算装置を実現することにある。 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 for an arithmetic device and an arithmetic device capable of obtaining a correctly rounded arithmetic result as a whole in a shorter time. It is to be realized.
本発明に係る演算装置の制御方法は、上記課題を解決するために、仮数部および指数部を含む浮動小数点数として与えられるオペランドよりも仮数部の桁数が1桁大きな浮動小数点数を記憶可能な複数のレジスタと、当該各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有する演算装置の制御方法であって、加算または減算のための2つのオペランドが与えられた場合に、上記複数のレジスタの2つへ、それぞれの仮数部の最下位の桁の値が0になり、残余の値が、それぞれに対応するオペランドとなるように、上記制御回路が、上記各レジスタへオペランドを書き込む書き込み工程と、上記各オペランドを格納したレジスタのうち、両者の指数部の値が異なる場合は、大きい方を第1レジスタ、両者の指数部の値が同じ場合は、これらのレジスタの一方を第1レジスタとし、上記各オペランドを格納したレジスタのうち、上記第1レジスタではない方を第2レジスタとするとき、上記演算回路が上記第2レジスタの仮数部の値を、両者の指数部の差の桁分だけ右シフトして、上記複数のレジスタのいずれかへ格納する位合わせ工程と、上記第1レジスタの仮数部の値と、上記位合わせ工程にて、シフト結果が格納されたレジスタの仮数部の値との加算結果または減算結果を算出して、演算結果の仮数部を求める演算工程と、当該演算工程よりも前に実施され、上記制御回路が、上記第1レジスタの仮数部の最下位桁へ、丸め処理のために予め定められた数を設定する設定工程とを含んでいることを特徴としている。 In order to solve the above problems, the control method of the arithmetic unit according to the present invention can store a floating-point number whose mantissa part is one digit larger than the operand given as a floating-point number including a mantissa part and an exponent part. And a control circuit for controlling each of the registers and the arithmetic circuit, the control method for the arithmetic device comprising: a plurality of registers; When two operands are given, to the two of the plurality of registers, the value of the least significant digit of each mantissa is 0, and the remaining value is the corresponding operand. When the control circuit has a write step of writing an operand to each register and a register storing each of the operands, if the value of the exponent part is different, the larger one is If the value of the exponent part of the register is the same, when one of these registers is the first register and the one that is not the first register among the registers storing the operands is the second register, An alignment step in which the arithmetic circuit shifts the value of the mantissa part of the second register to the right by the digit of the difference between the two exponent parts and stores it in one of the plurality of registers; and the mantissa of the first register A calculation step of calculating an addition result or a subtraction result of a value of a part and a value of a mantissa part of a register in which a shift result is stored in the alignment step to obtain a mantissa part of the calculation result; And the control circuit includes a setting step for setting a predetermined number for rounding to the least significant digit of the mantissa part of the first register. .
また、本発明に係る演算装置は、上記課題を解決するために、仮数部および指数部を含む浮動小数点数として与えられるオペランドよりも仮数部の桁数が1桁大きな浮動小数点数を記憶可能な複数のレジスタと、当該各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有する演算装置であって、上記制御回路は、加算または減算のための2つのオペランドが与えられた場合に、上記複数のレジスタの2つへ、それぞれの仮数部の最下位の桁の値が0になり、残余の値が、それぞれに対応するオペランドとなるように、上記各レジスタへオペランドを書き込むものであり、上記演算回路は、上記各オペランドを格納したレジスタのうち、両者の指数部の値が異なる場合は、大きい方を第1レジスタ、両者の指数部の値が同じ場合は、これらのレジスタの一方を第1レジスタとし、上記各オペランドを格納したレジスタのうち、上記第1レジスタではない方を第2レジスタとするとき、上記第2レジスタの仮数部の値を、両者の指数部の差の桁分だけ右シフトして、上記複数のレジスタのいずれかへ格納すると共に、上記第1レジスタの仮数部の値と、当該シフト結果が格納されたレジスタの仮数部の値との加算結果または減算結果を算出して、演算結果の仮数部を求めるものであり、さらに、上記制御回路は、上記演算回路が演算結果の仮数部を求める前に、上記第1レジスタの仮数部の最下位桁へ、丸め処理のために予め定められた数を設定するものであることを特徴としている。 In order to solve the above problem, the arithmetic unit according to the present invention can store a floating-point number whose number of digits in the mantissa part is one digit larger than an operand given as a floating-point number including a mantissa part and an exponent part. An arithmetic device having a plurality of registers, an arithmetic circuit that performs an operation with reference to the value of each register, and a control circuit that controls the registers and the arithmetic circuit, wherein the control circuit is used for addition or subtraction. When the two operands are given, the value of the least significant digit of each mantissa becomes 0 and the remaining value becomes the corresponding operand to two of the plurality of registers. The operands are written to the respective registers, and the arithmetic circuit selects the larger one of the registers storing the respective operands when the value of the exponent part of the registers is different. If the value of the exponent part is the same, one of these registers is the first register, and the one that is not the first register among the registers storing the operands is the second register. The value of the mantissa part of the second register is right-shifted by the digit of the difference between the exponent parts of both, and is stored in one of the plurality of registers, and the value of the mantissa part of the first register and the shift The result of addition or subtraction with the value of the mantissa part of the register in which the result is stored is calculated to obtain the mantissa part of the operation result, and the control circuit further includes a mantissa part of the operation result. Before obtaining the value, a predetermined number is set for rounding to the least significant digit of the mantissa part of the first register.
さらに、本発明に係るプログラムは、仮数部および指数部を含む浮動小数点数として与えられるオペランドよりも仮数部の桁数が1桁大きな浮動小数点数を記憶可能な複数のレジスタと、当該各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有するコンピュータに、上記書き込み工程、位合わせ工程、演算工程および設定工程を実行させるプログラムである。 Furthermore, the program according to the present invention includes a plurality of registers capable of storing a floating-point number whose number of digits in the mantissa part is one digit larger than an operand given as a floating-point number including a mantissa part and an exponent part, This is a program that causes a computer having an arithmetic circuit that performs an operation with reference to values and a control circuit that controls the registers and the arithmetic circuit to execute the writing step, the alignment step, the calculating step, and the setting step.
一方、本発明に係る演算装置の制御方法は、上記課題を解決するために、仮数部および指数部を含む浮動小数点数として与えられるオペランドよりも仮数部の桁数が1桁大きな浮動小数点数を記憶可能な複数のレジスタと、上記オペランドを記憶可能な特定のレジスタと、当該各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有する演算装置の制御方法であって、乗算のための2つのオペランドが与えられた場合に、上記複数のレジスタの1つへ、それぞれの仮数部の最下位の桁の値が0になり、残余が、上記オペランドの一方となるように、上記制御回路が、当該レジスタへ当該オペランドを書き込むと共に、上記特定のレジスタへ、上記オペランドの他方を書き込む書き込み工程と、上記制御回路が、上記特定のレジスタの仮数部の各桁の値を、最下位の桁から順に取得する取得工程と、上記取得工程にして取得される各桁に対応して行われ、上記演算回路が、上記制御回路の指示に応じて、上記複数のレジスタのうち、現在の演算結果が格納されているレジスタの仮数部の値へ、上記複数のレジスタのうち、オペランドが書き込まれたレジスタの仮数部の値を、上記対応する桁の値の回数だけ加算し、加算結果を上記複数のレジスタの1つへ書き込む加算工程と、上記取得工程にして取得される各桁に対応して行われ、上記演算回路が、同じ桁に対応する上記加算工程にて加算結果が書き込まれたレジスタの仮数部の値を、1桁右シフトして、当該シフト結果を、新たな演算結果として、上記複数のレジスタの1つへ書き込むシフト工程と、上記各加算工程のうち、最後の加算工程の前に実施され、上記制御回路が、上記複数のレジスタのうち、オペランドが書き込まれたレジスタの仮数部の最下位桁へ、丸め処理のために予め定められた数を設定する設定工程とを含んでいることを特徴としている。 On the other hand, in order to solve the above-described problem, the control method of the arithmetic unit according to the present invention provides a floating-point number in which the number of digits of the mantissa part is one digit larger than the operand given as a floating-point number including a mantissa part and an exponent part. Arithmetic apparatus having a plurality of storable registers, a specific register capable of storing the operand, an arithmetic circuit that performs an operation with reference to the value of each register, and a control circuit that controls the registers and the arithmetic circuit When two operands for multiplication are given, the value of the least significant digit of each mantissa is set to 0 and the remainder is set to one of the plurality of registers. A writing step in which the control circuit writes the operand to the register and writes the other operand to the specific register so that the operand becomes one of the operands; The control circuit performs the acquisition step of acquiring the value of each digit of the mantissa part of the specific register in order from the least significant digit, and corresponding to each digit acquired in the acquisition step, the calculation In response to an instruction from the control circuit, the circuit changes the value of the mantissa part of the register in which the current operation result is stored among the plurality of registers to the register in which the operand is written. The mantissa value is added corresponding to the number of times of the corresponding digit, and the addition result is written to one of the plurality of registers, and each digit obtained in the acquisition step is performed. The arithmetic circuit shifts the mantissa value of the register in which the addition result is written in the addition step corresponding to the same digit to the right by one digit, and uses the shift result as a new calculation result. Write to one of the registers And the control circuit rounds to the least significant digit of the mantissa part of the register in which the operand is written out of the plurality of registers. And a setting step for setting a predetermined number for processing.
また、本発明に係る演算装置は、上記課題を解決するために、仮数部および指数部を含む浮動小数点数として与えられるオペランドよりも仮数部の桁数が1桁大きな浮動小数点数を記憶可能な複数のレジスタと、上記オペランドを記憶可能な特定のレジスタと、当該各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有する演算装置であって、上記制御回路は、乗算のための2つのオペランドが与えられた場合に、上記複数のレジスタの1つへ、それぞれの仮数部の最下位の桁の値が0になり、残余が、上記オペランドの一方となるように、当該レジスタへ当該オペランドを書き込むと共に、上記特定のレジスタへ、上記オペランドの他方を書き込むと共に、上記特定のレジスタの仮数部の各桁の値を、最下位の桁から順に取得するものであり、上記演算回路は、上記制御回路の指示に基づき、上記制御回路の取得した各桁について、上記複数のレジスタのうち、現在の演算結果が格納されているレジスタの仮数部の値へ、上記複数のレジスタのうち、オペランドが書き込まれたレジスタの仮数部の値を、上記対応する桁の値の回数だけ加算し、加算結果を上記複数のレジスタの1つへ書き込むと共に、当該レジスタの仮数部の値を、1桁右シフトして、当該シフト結果を、新たな演算結果として、上記複数のレジスタの1つへ書き込むものであり、上記制御回路は、さらに、上記演算回路による最後の加算の前に、上記複数のレジスタのうち、オペランドが書き込まれたレジスタの仮数部の最下位桁へ、丸め処理のために予め定められた数を設定するものであることを特徴としている。 In order to solve the above problem, the arithmetic unit according to the present invention can store a floating-point number whose number of digits in the mantissa part is one digit larger than an operand given as a floating-point number including a mantissa part and an exponent part. An arithmetic device having a plurality of registers, a specific register capable of storing the operand, an arithmetic circuit that performs an operation by referring to a value of each register, and a control circuit that controls the registers and the arithmetic circuit When the two operands for multiplication are given, the control circuit sets the least significant digit value of each mantissa part to one of the plurality of registers, and the remainder is the operand. And writing the operand to the register, writing the other operand to the specific register, and the mantissa part of the specific register. The value of each digit is obtained in order from the least significant digit, and the arithmetic circuit, based on an instruction from the control circuit, for each digit obtained by the control circuit, among the plurality of registers, The mantissa value of the register in which the operand is written out of the plurality of registers is added to the value of the mantissa part of the register storing the operation result by the number of times of the corresponding digit, and the addition result is obtained. Write to one of the plurality of registers, shift the mantissa value of the register to the right by one digit, and write the shift result to one of the plurality of registers as a new operation result. The control circuit is further configured in advance to perform rounding to the least significant digit of the mantissa part of the register in which the operand is written out of the plurality of registers before the final addition by the arithmetic circuit. It is characterized in that to set the number was fit.
さらに、本発明に係るプログラムは、上記課題を解決するために、仮数部および指数部を含む浮動小数点数として与えられるオペランドよりも仮数部の桁数が1桁大きな浮動小数点数を記憶可能な複数のレジスタと、上記オペランドを記憶可能な特定のレジスタと、当該各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有するコンピュータに、上記書き込み工程、取得工程、加算工程、シフト工程および設定工程を実行させることを特徴としている。 Furthermore, in order to solve the above-described problem, the program according to the present invention is capable of storing a plurality of floating-point numbers in which the number of digits of the mantissa part is one digit larger than the operand given as a floating-point number including a mantissa part and an exponent part. The writing step in a computer having a register of the above, a specific register capable of storing the operand, an arithmetic circuit that performs an operation with reference to a value of each register, and a control circuit that controls the registers and the arithmetic circuit The acquisition step, the addition step, the shift step, and the setting step are executed.
一方、本発明に係る演算装置の制御方法は、上記課題を解決するために、仮数部および指数部を含む浮動小数点数として与えられるオペランドを記憶可能な複数のレジスタと、当該各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有する演算装置の制御方法であって、除算のための2つのオペランドが与えられた場合に、上記制御回路が、上記複数のレジスタの2つへ、それぞれに対応するオペランドを書き込む書き込み工程と、上記複数のレジスタのうち、上記オペランドのうちの被序数が格納されたレジスタを被序数レジスタ、上記オペランドのうちの序数が格納されたレジスタを序数レジスタ、演算結果が格納されるレジスタを演算結果レジスタとするとき、上記演算回路が、上記被序数レジスタの仮数部の値を、当該仮数部の桁数の回数だけ、1桁ずつ右シフトしながら、当該被序数レジスタの仮数部の値から上記序数レジスタの仮数部の値を何回減算できるかを判定することによって、演算結果の各桁を求め、それぞれを、上記演算結果レジスタの仮数部の対応する桁へ格納する演算工程と、上記演算回路が、上記仮数部の桁数の回数だけ右シフトされた後の被序数レジスタの仮数部の値から、上記序数レジスタの仮数部の値を、丸め処理のために予め定められた回数、減算できた場合は、上記演算結果レジスタの仮数部を1増加させる丸め処理工程とを含んでいることを特徴としている。 On the other hand, in order to solve the above problems, the control method of the arithmetic device according to the present invention includes a plurality of registers capable of storing operands given as floating point numbers including a mantissa part and an exponent part, and values of the respective registers. A control method of an arithmetic unit having an arithmetic circuit that performs an arithmetic operation with reference, and a control circuit that controls each of the registers and the arithmetic circuit. When two operands for division are given, the control circuit A writing step of writing corresponding operands to two of the plurality of registers, a register storing the number of operands of the operand among the plurality of registers, a register of the number of operands, When the register storing the ordinal number is the ordinal register and the register storing the operation result is the operation result register, the above arithmetic circuit is The value of the mantissa part of the ordinal register is subtracted from the value of the mantissa part of the operand register by how many times the value of the mantissa part of the ordinal register is shifted right by one digit by the number of digits of the mantissa part. By calculating whether each digit of the operation result is obtained and determining each digit in the corresponding digit of the mantissa part of the operation result register, the arithmetic circuit determines the number of digits of the mantissa part. If the mantissa value of the ordinal register can be subtracted from the value of the mantissa part of the ordinal register after being shifted right by a predetermined number of times for rounding, the mantissa of the operation result register And a rounding process step of increasing the number by one.
また、本発明に係る演算装置は、上記課題を解決するために、仮数部および指数部を含む浮動小数点数として与えられるオペランドを記憶可能な複数のレジスタと、当該各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有する演算装置であって、上記制御回路は、除算のための2つのオペランドが与えられた場合に、上記制御回路が、上記複数のレジスタの2つへ、それぞれに対応するオペランドを書き込むものであり、上記演算回路は、上記複数のレジスタのうち、上記オペランドのうちの被序数が格納されたレジスタを被序数レジスタ、上記オペランドのうちの序数が格納されたレジスタを序数レジスタ、演算結果が格納されるレジスタを演算結果レジスタとするとき、上記被序数レジスタの仮数部の値を、当該仮数部の桁数の回数だけ、1桁ずつ右シフトしながら、当該被序数レジスタの仮数部の値から上記序数レジスタの仮数部の値を何回減算できるかを判定することによって、演算結果の各桁を求め、それぞれを、上記演算結果レジスタの仮数部の対応する桁へ格納すると共に、上記仮数部の桁数の回数だけ右シフトされた後の被序数レジスタの仮数部の値から、上記序数レジスタの仮数部の値を、丸め処理のために予め定められた回数、減算できた場合は、上記演算結果レジスタの仮数部を1増加させるものであることを特徴としている。 In order to solve the above problem, the arithmetic device according to the present invention refers to a plurality of registers capable of storing operands given as floating-point numbers including a mantissa part and an exponent part, and values of the respective registers. An arithmetic unit having an arithmetic circuit for calculating, and a control circuit for controlling each of the registers and the arithmetic circuit, wherein the control circuit, when two operands for division are given, An operand corresponding to each of the plurality of registers is written to two of the plurality of registers, and the arithmetic circuit selects a register in which the operand number of the operand is stored among the plurality of registers as an operand register, When the ordinal register of the operand is stored in the ordinal register and the register in which the operation result is stored is the operation result register, the above-mentioned ordinal number How many times can the value of the mantissa part of the ordinal register be subtracted from the value of the mantissa part of the ordinal register while shifting the right side of the mantissa part of the register by the number of digits of the mantissa part? To determine each digit of the operation result, store each in the corresponding digit of the mantissa part of the operation result register, and shift the right after the number of digits of the mantissa part. When the mantissa part value of the ordinal register can be subtracted from the value of the mantissa part of the register by a predetermined number of times for rounding, the mantissa part of the operation result register is incremented by 1. It is characterized by.
さらに、本発明に係るプログラムは、上記課題を解決するために、仮数部および指数部を含む浮動小数点数として与えられるオペランドを記憶可能な複数のレジスタと、当該各レジスタの値を参照して演算する演算回路と、上記各レジスタおよび演算回路を制御する制御回路とを有するコンピュータに、書き込み工程、演算工程および丸め処理工程を実行させることを特徴としている。 Further, in order to solve the above-described problem, the program according to the present invention calculates a plurality of registers capable of storing operands given as floating-point numbers including a mantissa part and an exponent part, and the values of the respective registers. And a computer having a control circuit that controls each of the registers and the arithmetic circuit are caused to execute a writing step, an arithmetic step, and a rounding step.
また、本発明に係る記録媒体は、上記課題を解決するために、上記各プログラムのいずれかが記録されていることを特徴としている。 In addition, the recording medium according to the present invention is characterized in that any one of the above programs is recorded in order to solve the above problems.
本発明に係る演算装置の制御方法および演算装置は、以上のように、演算回路が演算結果の仮数部を求める前に、制御回路が第1レジスタの仮数部の最下位桁に、丸め処理のために予め定められた数を設定している。 As described above, the control method and the arithmetic device of the arithmetic device according to the present invention perform rounding processing on the least significant digit of the mantissa part of the first register before the arithmetic circuit obtains the mantissa part of the arithmetic result. For this purpose, a predetermined number is set.
なお、当該構成および以降の構成において、丸め処理用の数は、演算の基数から、丸め処理によって繰り上げられる数の中の最小値を引いた数であり、例えば、2進演算する場合は、”1”、10進演算する場合は、”5”である。また、第2レジスタと、シフト結果が格納されたレジスタとは、同じレジスタであってもよいし、異なるレジスタであってもよいが、同じレジスタの場合は、演算装置に必要なレジスタの数を削減できる。さらに、当該構成および以降の構成において、右シフトは、より小さな桁へのシフトを意味している。 In the configuration and the subsequent configuration, the number for rounding is a number obtained by subtracting the minimum value from the numbers raised by the rounding from the radix of the operation. “1” is “5” when a decimal operation is performed. Further, the second register and the register storing the shift result may be the same register or different registers. In the case of the same register, the number of registers necessary for the arithmetic unit is set. Can be reduced. Further, in the configuration and the subsequent configuration, a right shift means a shift to a smaller digit.
ここで、上記第1レジスタは、オペランドよりも仮数部の桁数が1桁大きな浮動小数点数を記憶でき、しかも、上記各オペランドを格納したレジスタのうち、両者の指数部の値が異なる場合は、大きい方、あるいは、両者の指数部の値が同じ場合は、これらのレジスタの一方である。したがって、第1レジスタの仮数部の最下位桁は、丸め処理のための数を設定しなければ、必ず”0”になっている。 Here, the first register can store a floating-point number whose mantissa part is one digit larger than the operand, and, among the registers storing the operands, when the values of the exponent parts are different from each other, If the larger value or the value of the exponent part is the same, it is one of these registers. Therefore, the least significant digit of the mantissa part of the first register is always “0” unless a number for rounding is set.
上記構成では、この最下位桁に、丸め処理用の数を設定した後で、演算しているので、演算した後に、丸め処理を行う従来の構成とは異なり、演算の後の繰り上げ処理をすることなく、正しく丸められた演算結果を得ることができる。 In the above configuration, calculation is performed after setting the number for rounding processing to the least significant digit. Unlike the conventional configuration in which rounding processing is performed after the calculation, carry-up processing after calculation is performed. Therefore, a correctly rounded operation result can be obtained.
さらに、当該構成では、上記従来の構成と比較して、最下位桁の設定処理が増えている代わりに、演算後の繰り上げ処理が減っている。ここで、特定の桁の設定処理は、演算後の繰り上げ処理のように、ある桁の演算結果が他の桁の演算結果へ影響を及ぼす処理とは異なって、その桁の演算結果は、他の桁へ影響しない。したがって、より短い時間で、演算できる。この結果、正しく丸められた加算または減算結果を、全体として、より短い時間で得ることができる。 Further, in this configuration, compared with the above-described conventional configuration, the setting processing for the least significant digit is increased, but the carry processing after calculation is decreased. Here, the setting process for a specific digit is different from the process in which the calculation result of one digit affects the calculation result of another digit, such as the carry-up process after the calculation. Does not affect. Therefore, calculation can be performed in a shorter time. As a result, a correctly rounded addition or subtraction result can be obtained in a shorter time as a whole.
また、本発明に係る演算装置の制御方法および演算装置は、以上のように、オペランドの一方の仮数部の各桁について、当該桁が示す回数だけオペランドの他方を演算結果に加算すると共に演算結果を1桁右シフトすることによって、乗算結果を算出しているが、最後の加算の前の時点で、上述した演算装置の制御方法および演算装置と同様、オペランドが格納されたレジスタの仮数部の最下位桁に、丸め処理用の数を設定している。 In addition, as described above, the control method and the arithmetic device of the arithmetic device according to the present invention add the other of the operands to the arithmetic result for each digit of one mantissa part of the operand as many times as the number indicated by the digit and the arithmetic result. Is shifted by one digit to the right, the multiplication result is calculated, but at the time prior to the last addition, the mantissa part of the register in which the operand is stored is similar to the control method and arithmetic unit of the arithmetic unit described above. The number for rounding is set in the least significant digit.
なお、当該レジスタの仮数部の最下位桁も、丸め処理のための数を設定しなければ、必ず”0”になっている。また、この場合も、オペランドを格納するレジスタ、加算結果を書き込むレジスタおよび演算結果を書き込むレジスタは、常に同じレジスタであっても、各桁用の計算毎に異なるレジスタであってもよい。 Note that the least significant digit of the mantissa part of the register is always “0” unless a number for rounding is set. Also in this case, the register for storing the operand, the register for writing the addition result, and the register for writing the operation result may be always the same register or different for each digit calculation.
したがって、当該演算装置の制御方法および演算装置と同様に、最後の加算の後に丸め処理する構成と比較して、正しく丸められた乗算結果を、全体として、より短い時間で得ることができる。 Therefore, similarly to the control method and the arithmetic device of the arithmetic device, as a whole, the multiplication result that is correctly rounded can be obtained in a shorter time as compared with the configuration in which the rounding process is performed after the final addition.
また、本発明に係る演算装置の制御方法および演算装置は、以上のように、上記演算回路が、上記仮数部の桁数の回数だけ右シフトされた後の被序数レジスタの仮数部の値から、上記序数レジスタの仮数部の値を、丸め処理のために予め定められた回数、減算できた場合は、上記演算結果レジスタの仮数部を1増加させている。 In addition, as described above, the control method and the arithmetic device of the arithmetic device according to the present invention are based on the value of the mantissa part of the ordinal register after the arithmetic circuit is right-shifted by the number of digits of the mantissa part. When the value of the mantissa part of the ordinal register can be subtracted a predetermined number of times for rounding processing, the mantissa part of the arithmetic result register is incremented by one.
なお、除算の場合は、加減算および乗算の場合と異なり、丸め処理のために予め定められた回数は、丸め処理によって繰り上げられる数の中の最小値(しきい値)であり、例えば、2進演算する場合は、”1”、10進演算する場合は、”5”である。また、この場合も、被序数レジスタ、序数レジスタおよび演算結果レジスタは、常に同じレジスタであってもよいし、例えば、シフト毎になど、各時点で異なるレジスタを用いてもよい。 In the case of division, unlike the case of addition / subtraction and multiplication, the number of times determined in advance for the rounding process is the minimum value (threshold value) among the numbers raised by the rounding process. “1” is used for calculation, and “5” is used for decimal calculation. Also in this case, the ordinal number register, the ordinal number register, and the operation result register may always be the same register, or different registers may be used at each time point, for example, every shift.
したがって、従来の構成のように、演算結果レジスタにおいて、必要な桁よりも1桁下の値を求め、その後で、当該値が、しきい値を超えているか否かによって繰り上げの要否を判定し、必要な場合は、繰り上げのための演算を行う構成と比較して、必要な桁よりも1桁下の値をレジスタへ設定する処理や減算回数を削減できると共に、演算結果レジスタの仮数部に必要な桁数を削減できる。この結果、正しく丸められた除算結果を、全体として、より短い時間で得ることができる。 Therefore, as in the conventional configuration, the calculation result register obtains a value that is one digit lower than the required digit, and then determines whether it is necessary to carry it forward according to whether the value exceeds the threshold value. If necessary, the mantissa part of the operation result register can be reduced as compared with the configuration for performing the operation for carry-up, and the processing for setting the value one digit lower than the required digit and the number of subtractions can be reduced. Can reduce the number of digits required. As a result, a correctly rounded division result can be obtained in a shorter time as a whole.
ここで、上記演算装置は、ハードウェアのみによって実現されていてもよいが、ソフトウェアを用いて実現してもよい。具体的には、本発明に係る各プログラムを上記各コンピュータによって実行させることによって、あるいは、本発明に係る記録媒体に記録された各プログラムを上記コンピュータに読み取らせて実行させることによって、当該コンピュータを上記各演算装置として動作させることができる。したがって、上記各演算装置と同様に、正しく丸められた演算結果を、全体として、より短い時間で得ることができる。 Here, although the said arithmetic unit may be implement | achieved only by hardware, you may implement | achieve using software. Specifically, by causing each computer according to the present invention to be executed by each computer, or by causing the computer to read and execute each program recorded on the recording medium according to the present invention, the computer is executed. It can be operated as each of the above arithmetic devices. Therefore, as with the above arithmetic devices, a correct rounded calculation result can be obtained in a shorter time as a whole.
〔第1の実施形態〕
本発明の一実施形態について図1ないし図8に基づいて説明すると以下の通りである。すなわち、本実施形態に係る演算装置の制御方法は、少数部分を持つ数値を演算する際に、丸め処理をしているにも拘わらず、演算後に丸め処理をする場合よりも高速に演算可能な方法であって、例えば、電卓で使用される簡易小数点付きの演算や、浮動小数点数の演算に好適に用いることができる。
[First Embodiment]
An embodiment of the present invention will be described below with reference to FIGS. In other words, the control method of the arithmetic device according to the present embodiment can calculate at a higher speed than the case of performing rounding after calculation, even though rounding is performed when calculating a numerical value having a decimal part. It is a method, for example, and can be used suitably for the calculation with a simple decimal point used with a calculator, and the calculation of a floating point number.
具体的には、本実施形態に係る演算装置1は、浮動小数点の加算または減算を行う装置であって、図1に示すように、予め定められた桁数の、浮動小数点表示された数を記憶する第1および第2レジスタ11・12と、指示に応じて、上記各レジスタ11・12の値を参照して演算を行うと共に、指示に応じて、演算結果を上記各レジスタ11・12へ書き込み可能な演算回路21と、上記各レジスタ11・12への、あるいは、上記各レジスタからのデータ転送を制御する転送制御回路22と、予め定められたアルゴリズムに従って、上記各レジスタ11・12並びに演算回路21および転送制御回路22を制御する制御回路23とを備えている。
Specifically, the
本実施形態の演算装置1が演算する浮動小数点表示された数(浮動小数点数)は、nおよびmを予め定められた自然数とするとき、図2に示すように、例えば、1ビットで表現される符号と、m桁の指数部と、n桁の仮数部とを含んでいる。なお、本実施形態に係る浮動小数点数では、仮数部の値は、絶対値で表現されている。さらに、上記両レジスタ11・12は、丸め処理のために、図2に示す浮動小数点数の仮数部に、その最下位の桁よりも1つ下の桁を追加した浮動小数点数を記憶できるように構成されており、図3に示すように、符号を記憶する領域AS、m桁の指数部を記憶する領域AE、および、n+1桁の仮数部を記憶する領域AMとを備えている。
A floating point number (floating point number) calculated by the
一方、本実施形態に係る演算回路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, it is configured such that addition and subtraction of the mantissa part, comparison of absolute values, comparison of signs, calculation of a difference in value of the exponent part, and digit shift (right) are possible.
より詳細には、演算回路21は、制御回路23から仮数部の加算が指示された場合、指示された2つのレジスタ(本実施形態では、第1および第2レジスタ11・12)の仮数部の領域AMから読み出された値同士を加算し、加算結果を、指示されたレジスタ(例えば、第1レジスタ11)の仮数部の領域AMへ格納できる。同様に、制御回路23から仮数部の減算が指示された場合、指示されたレジスタ(例えば、第1レジスタ11)の仮数部の領域AMより読み出された値から、指示されたレジスタ(例えば、第2レジスタ12)の仮数部の領域AMより読み出された値を減算すると共に、減算結果を、指示されたレジスタ(例えば、第1レジスタ11)の仮数部の領域AMへ格納できる。
More specifically, when the addition of the mantissa part is instructed from the control circuit 23, the arithmetic circuit 21 determines the mantissa part of the instructed two registers (first and
また、演算回路21は、制御回路23から絶対値の比較が指示された場合、指示された2つのレジスタの領域AEおよびAMから、それぞれ出力された浮動小数点数の絶対値同士を比較して、制御回路23へ比較結果を伝えることができる。同様に、制御回路23から符号の比較が指示された場合、演算回路21は、指示された2つのレジスタの領域ASから、それぞれ出力された浮動小数点数の符号同士を比較して、制御回路23へ比較結果を伝えることができる。 When the control circuit 23 is instructed to compare the absolute values, the arithmetic circuit 21 compares the absolute values of the floating-point numbers output from the areas AE and AM of the two instructed registers, The comparison result can be transmitted to the control circuit 23. Similarly, when a sign comparison is instructed from the control circuit 23, the arithmetic circuit 21 compares the signs of the floating-point numbers output from the instructed areas AS of the two registers, and the control circuit 23. The comparison result can be communicated to.
さらに、演算回路21は、指数部の値の差の算出が制御回路23から指示された場合、指示された2つのレジスタの指数部の領域AEから読み出された値の差を算出し、算出結果を制御回路23へ出力できる。また、制御回路23が仮数部の右シフトを指示した場合、演算回路21は、上記各レジスタ11・12のうち、指示されたレジスタ(例えば、第2レジスタ12)の仮数部の領域AMから読み出された値を、指示された桁だけ、右シフトすると共に、シフト後の値を、当該レジスタの仮数部の領域AMに書き込むことができる。なお、この右シフトは、算術的な右シフトであり、シフトの結果、新たに挿入される上位桁の値は、”0”に設定されている。
Further, when the calculation of the difference between the exponent values is instructed from the control circuit 23, the arithmetic circuit 21 calculates the difference between the values read from the exponent area AE of the two designated registers. The result can be output to the control circuit 23. When the control circuit 23 instructs the right shift of the mantissa part, the arithmetic circuit 21 reads from the mantissa part area AM of the indicated register (for example, the second register 12) of the
また、本実施形態に係る転送制御回路22は、例えば、論理回路によって構成された回路であって、制御回路23の指示に応じて、レジスタ間の値の交換、および、仮数部の最下位桁の値の設定が可能なように構成されている。
Further, the
より詳細には、転送制御回路22は、制御回路23から内容の交換指示を受け取った場合、演算回路21は、指示された2つのレジスタの値を交換できる。例えば、本実施形態では、第1レジスタ11から出力された値を第2レジスタ12へ書き込むと共に、第2レジスタ12から出力された値を第1レジスタ11へ書き込むことができる。
More specifically, when the
さらに、転送制御回路22は、制御回路23から最下位桁の設定が指示された場合、指示されたレジスタ(例えば、第1レジスタ11)の最下位桁(n+1番目の桁)の記憶領域へ、指示された値を書き込むことができる。
Further, when the setting of the least significant digit is instructed from the control circuit 23, the
ここで、上記最下位の桁の設定処理は、加算または減算処理のように、桁上げまたは上の桁からの借りが発生する可能性があるために、ある桁での演算結果が他の桁の演算に影響する処理とは異なって、その桁(最下位の桁)の処理のみで処理が終了する。したがって、本実施形態に係る転送制御回路22は、上記演算回路21による加算処理および減算処理よりも短い時間で、最下位の桁を設定できる。
Here, in the setting process for the least significant digit, there is a possibility that a carry or a borrow from the upper digit may occur like an addition or subtraction process. Unlike the process that affects the calculation of, the process is completed only by the process of the digit (lowest digit). Therefore, the
また、制御回路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
上記制御回路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
また、上記演算装置1には、演算の対象となるオペランドを記憶すると共に、演算結果が書き込まれるメモリ31も設けられており、上記転送制御回路22は、制御回路23の指示に応じて、メモリ31から読み出したオペランドを、指示されたレジスタ(例えば、両レジスタ11・12)へ格納したり、制御回路23の指示に基づいて、指示されたレジスタ(例えば、第1レジスタ11)に格納された演算結果を、例えば、演算結果の表示処理など、後の処理で利用するために、メモリ31へ格納したりすることができる。
The
上記構成において、例えば、メモリ31の予め定められた記憶領域へ2つのオペランドが格納され、制御回路23の予め定められたアドレスへ加算開始の指示を示す命令が書き込まれるなどして、演算装置1へ加算(X+Y)が指示されると、図4に示すステップ1(以下では、S1のように略称する)において、制御回路23は、転送制御回路22へ指示して、演算の対象となる上記両オペランドXおよびYを両レジスタ11・12へ格納させる。なお、以下では、指示されたときの両オペランドの順番に拘わらず、第1レジスタ11に格納されたオペランドをX、第2レジスタ12に格納されたオペランドをYと称する。
In the above configuration, for example, two operands are stored in a predetermined storage area of the
ここで、上記図2に示すように、両オペランドを示す浮動小数点数は、符号を除いて、m+n桁であるのに対して、上記図3に示すように、両レジスタ11・12には、丸め処理用の桁が追加されているので、それらの桁数は、符号を除いて、m+n+1桁である。このように、オペランドの桁(符号を除く)の方が両レジスタ11・12に記憶可能な浮動小数点数の桁(符号を除く)よりも少ないが、上記S1において、上記転送制御回路22は、制御回路23の指示に応じ、両レジスタ11・12にオペランドXおよびYを格納する際、両レジスタ11・12の最下位の桁に”0”を設定している。
Here, as shown in FIG. 2, the floating point numbers indicating both operands are m + n digits excluding the sign, whereas, as shown in FIG. Since digits for rounding are added, the number of digits is m + n + 1 digits excluding the sign. As described above, the number of operand digits (excluding the sign) is less than the number of floating-point numbers (excluding the sign) that can be stored in both the
上記S1において、両レジスタ11・12にオペランドが格納されると、制御回路23は、S2において、両レジスタ11・12の絶対値の比較を演算回路21へ指示し、比較結果を受け取る。第1レジスタ11に格納された浮動小数点数Xの絶対値の方が第2レジスタ12に格納された浮動小数点数Yの絶対値よりも小さいことを、上記比較結果が示している場合、制御回路23は、S3において、演算回路21へ指示して、両レジスタ11および12に格納されている浮動小数点数XおよびYを交換した後、S4以降の処理を行う。一方、上記S2にて、浮動小数点数Xの絶対値の方が大きいか同じと判定した場合は、上記S3を実施せずに、S4以降の処理を行う。
When operands are stored in both
すなわち、S4において、制御回路23は、演算回路21へ両レジスタ11・12の指数部の値の差の算出を指示し、演算結果を受け取ると共に、さらに、演算結果の示す桁分だけ(差の桁分だけ)、第2レジスタ12の仮数部(Yの仮数部)を右シフトするように指示し、演算結果を第2レジスタ12の仮数部に書き込ませる。これにより、第2レジスタ12の仮数部の位が第1レジスタ11の仮数部の桁(指数部の値)に合わせられ、それぞれの仮数部は、指数部の値を、第1レジスタ11の指数部の値に揃えて浮動小数点表記したときの値になる。
That is, in S4, the control circuit 23 instructs the arithmetic circuit 21 to calculate the difference between the exponents of both the
なお、この状態における第2レジスタ12の仮数部の最下位の桁(n+1番目の桁)の値は、演算装置1へ指示されたオペランドのうち、指数部の値が小さかった方のオペランドの値に応じて設定されている。一方、第1レジスタ11の仮数部の最下位の桁の値は、”0”である。
In this state, the value of the least significant digit (n + 1 digit) of the mantissa part of the
本実施形態に係る制御回路23は、さらに、S5において、仮数部の加算または減算処理よりも前に、転送制御回路22へ指示して、第1レジスタ11の最下位の桁(Xの最下位の桁)に、丸め用の値として予め設定された値を設定させる。なお、丸め用の値は、丸め処理によって繰り上がりが発生する値のうちの最小値であり、例えば、浮動小数点数が2進数で表記されている場合は、”1”、10進数で表記されている場合は、”5”である。
In S5, the control circuit 23 according to the present embodiment further instructs the
さらに、上記S5にて丸め用の値が設定された後、制御回路23は、演算回路21へ対して、両レジスタ11・12の符号の領域ASも考慮して、両レジスタ11および12の仮数部の領域AMの値を加算させ、加算結果を、第1レジスタ11の仮数部の領域AMに格納させる(S6)。具体的には、制御回路23は、両レジスタ11・12の符号の領域ASの値に応じ、加算または減算を指示している。より詳細には、制御回路23は、演算回路21へ両レジスタ11・12の符号の比較を指示すると共に、演算回路21からの比較結果が、両者の符号同士の一致を示している場合、演算回路21へ加算を指示する。一方、不一致を示している場合、制御回路23は、演算回路21へ指示して、第1レジスタ11の仮数部から第2レジスタ12の仮数部を減算させる。なお、いずれの場合であっても、演算結果は、第1レジスタ11の仮数部の領域AMに格納される。ここで、上記S2およびS3において、絶対値の大きい方が第1レジスタ11に格納されているため、両レジスタ11・12に格納されている値に拘わらず、第1レジスタ11の符号の領域ASの値の変更は不要である。
Further, after the rounding value is set in S5, the control circuit 23 considers the sign area AS of both the
上記S6にて、第1レジスタ11の仮数部(Xの仮数部)に、両レジスタ11・12の仮数部(XおよびYの仮数部)の加算結果が書き込まれ、演算が終了すると、制御回路23は、S7において、演算結果を出力するために、転送制御回路22へ指示して、第1レジスタ11に格納された浮動小数点数Xを、メモリ31へ格納させる。ここで、上述したように、演算結果としての浮動小数点数の桁数(符号を除く)は、第1レジスタ11の桁数(符号を除く)よりも1桁小さいので、転送制御回路22は、第1レジスタ11の仮数部の最下位の桁を除いた部分をメモリ31へ格納する。
In S6, the addition result of the mantissa parts (X and Y mantissa parts) of both
上記構成では、上記S6にて加算処理を行う前に、上記S5において、本来0であるべき、第1レジスタ11の仮数部の最下位の桁を、丸め用の値に設定している。したがって、加算処理の後に、最下位の桁が丸め用の値以上であれば、最下位の1桁上の値(加算結果としての浮動小数点数の最下位の桁)に1を加算する場合と同様に、正しい丸め処理結果を得ることができる。
In the above configuration, before performing the addition process in S6, in S5, the least significant digit of the mantissa part of the
さらに、正しい丸め処理結果が得られているにも拘わらず、加算後に丸め処理する場合とは異なり、加算後の比較処理および1を加算する処理が不要である。ここで、本実施形態に係る加算方法では、加算後の比較処理および1を加算する処理に代えて、S5において、丸め用の値の設定処理が付加されているが、当該設定処理は、加算処理のように、ある桁での演算結果が他の桁の値へ影響を及ぼす処理とは異なり、他の桁の値には影響を及ぼさず、最下位の桁の設定だけで終了している。したがって、より短い時間で、演算することができる。したがって、全体で見ると、加算後に丸め処理を行う方法と比較して、より短い時間で、正しく丸められた加算結果を得ることができる。 Further, unlike the case of rounding after addition, although the correct rounding result is obtained, the comparison processing after addition and the processing of adding 1 are not required. Here, in the addition method according to the present embodiment, instead of the comparison process after addition and the process of adding 1, in S5, a rounding value setting process is added. Unlike the process where the operation result in one digit affects the value of the other digit as in the process, it does not affect the value of the other digit, and the process is completed only by setting the lowest digit. . Therefore, calculation can be performed in a shorter time. Therefore, when viewed as a whole, the rounded addition result can be obtained in a shorter time compared to the method of rounding after addition.
ところで、上記では、演算装置1に加算が指示された場合を例にして説明したが、減算(X−Y)が指示された場合には、上記演算装置1によって図5に示す処理が行われる。すなわち、図5では、S6の加算処理の代わりに、両レジスタ11・12に格納された浮動小数点数の符号も考慮して減算処理を行うステップ(S6a)が設けられており、当該ステップにおいて、制御回路23は、演算回路21へ対して、両レジスタ11・12の符号の領域ASの値に応じ、加算または減算を指示し、演算結果を、第1レジスタ11の仮数部の領域AMへ格納させる。より詳細には、制御回路23は、演算回路21へ両レジスタ11・12の符号の比較を指示し、演算回路21からの比較結果が両者の符合の不一致を示している場合、制御回路23は、演算回路21へ、加算の代わりに減算を指示し、一致を示している場合、演算回路21へ、減算の代わりに加算を指示する。これにより、加算の場合と同様に、全体で見ると、減算後に丸め処理を行う方法と比較して、より短い時間で、正しく丸められた減算結果を得ることができる。
In the above description, the case where addition is instructed to the
なお、上記では、仮数部が絶対値で表記される場合を例にして説明したが、制御回路23の指示に従う演算回路21が、両レジスタ11・12の値の符号も考慮して加算または減算できれば、補数表記される場合であっても、何ら支障なく、加算または演算でき、演算結果を第1レジスタ11に格納できる。
In the above description, the case where the mantissa part is expressed by an absolute value has been described as an example. However, the arithmetic circuit 21 in accordance with the instruction of the control circuit 23 performs addition or subtraction in consideration of the sign of the values of both
〔第2の実施形態〕
ところで、上記第1の実施形態では、浮動小数点数を加算または減算する場合について説明したが、乗算の場合であっても、桁のシフトおよび加算を繰り返して乗算結果を得る場合には、最後の加算の前に、丸め用の値を設定することによって、同様の効果を得ることができる。
[Second Embodiment]
By the way, in the first embodiment, the case of adding or subtracting a floating point number has been described. Even in the case of multiplication, the last shift and addition of digits are repeated to obtain a multiplication result. By setting a rounding value before the addition, a similar effect can be obtained.
すなわち、本実施形態に係る演算装置1bは、図6に示すように、図1に示す演算装置1の構成と略同一であるが、仮数部の領域AMの桁数がn桁である点を除いて、各レジスタ11・12と同一構成の第3レジスタ13bを備えていると共に、制御回路23が各部材11〜13b、21bおよび22bを制御する際のアルゴリズムが変更されている。
That is, as shown in FIG. 6, the
また、本実施形態において、第1の実施形態に係る演算回路21に代えて設けられた演算回路21bは、演算回路21が可能な演算に加えて、指数部の値同士の加算、符号同士の排他的論理和演算、および、仮数部の特定の桁のテストが可能なように構成されている。なお、加減算が不要であれば、演算回路21とは異なり、本実施形態の動作の説明において用いなかった処理(例えば、絶対値の比較処理など)を実施できなくてもよい。
In the present embodiment, the
より詳細には、本実施形態に係る演算回路21bは、制御回路23から指数部の加算が指示された場合、指示された2つのレジスタ(例えば、第2および第3レジスタ12・13b)の指数部の領域AEから読み出された値同士を加算し、加算結果を、指示されたレジスタ(例えば、第1レジスタ11)の指数部の領域AEへ格納できる。同様に、制御回路23から符号の排他的論理和演算が指示された場合、指示された2つのレジスタ(例えば、第2および第3レジスタ12・13b)の符号の領域ASから読み出された値同士の排他的論理和を算出し、演算結果を、指示されたレジスタ(例えば、第1レジスタ11)の符号の領域ASへ格納できる。また、演算回路21bは、制御回路23から、指定されたレジスタ(例えば、第3レジスタ13b)の指定された桁(例えば、最下位の桁)のテストが指示されると、当該桁の値を、制御回路23へ伝えることができる。
More specifically, the
さらに、本実施形態において、第1の実施形態の転送制御回路22に代えて設けられた転送制御回路22bは、転送制御回路22が可能な処理に加えて、制御回路23から指示されたレジスタに、”0”を示す浮動小数点数を格納できるように構成されている。
Further, in the present embodiment, the
上記構成において、例えば、メモリ31の予め定められた記憶領域へ2つのオペランドが格納され、制御回路23の予め定められたアドレスへ乗算開始の指示を示す命令が書き込まれるなどして、演算装置1へ乗算(Y*Z→X)が指示されると、図7に示すS11において、制御回路23は、転送制御回路22bへ指示して、乗算の対象となる上記両オペランドの一方を、第2レジスタ12へ格納させると共に、他方を第3レジスタ13bへ格納させる。なお、以下では、指示されたときの両オペランドの順番に拘わらず、第2レジスタ12に格納されたオペランドをY、第3レジスタ13bに格納されたオペランドをZと称する。また、転送制御回路22bは、第2レジスタ12へ格納する際、図4に示すS1と同様に、第2レジスタ12の最下位の桁(Yの最下位の桁)に”0”を設定する。
In the above configuration, for example, two operands are stored in a predetermined storage area of the
上記S11において、両レジスタ12・13bにオペランドが格納されると、制御回路23は、S12において、転送制御回路22bへ指示して、乗算結果の格納に用いる第1レジスタ11の浮動小数点数Xを”0”に設定する。
When the operands are stored in both the
さらに、S13において、制御回路23は、演算回路21bへ指示して、第2および第3レジスタ12・13bの指数部の値同士を加算させ、演算結果を、第1レジスタ11の指数部の領域AEに格納させる(Yの指数部+Zの指数部→Xの指数部)。また、S14において、制御回路23は、演算回路21bへ指示して、第2および第3レジスタ12・13bの符号の排他的論理和を算出させ、演算結果を、第1レジスタ11の符号の領域ASに格納させる(Yの符号 EX-OR Zの符号→Xの符号)。
Further, in S13, the control circuit 23 instructs the
また、制御回路23は、以下のS21〜S24の処理を、仮数部の桁数をnとするとき、(n−1)回繰り返す。一例として、演算回路21bが2進数で演算する場合について説明すると、S21において、制御回路23は、演算回路21bへ指示して、第3レジスタ13bの最下位の桁の値(Zの最下位桁)を読み出させ、当該値を受け取る。値が”1”であれば(S21にて、YES の場合)、制御回路23は、S22において、演算回路21bへ指示して、第1レジスタ11の仮数部の値に第2レジスタ12の仮数部の値を加算した値を、第1レジスタ11の仮数部の領域AMに格納させた後、S23以降の処理を実行する(Xの仮数部+Yの仮数部→Xの仮数部)。一方、値が”0”であれば(S21にて、NOの場合)、制御回路23は、S22の処理を行わずに、S23以降の処理を実行する。
Further, the control circuit 23 repeats the following processes of S21 to S24 (n-1) times, where n is the number of digits of the mantissa part. As an example, the case where the
すなわち、S23において、制御回路23は、演算回路21bへ指示して、第1レジスタ11の仮数部の値(Xの仮数部)を1桁分右シフトさせる。さらに、制御回路23は、S24において、演算回路21bへ指示して第3レジスタ13bの仮数部の値(Zの仮数部)を1桁分右シフトさせる。
That is, in S23, the control circuit 23 instructs the
上記S21〜S24の処理が(n−1)回繰り返されると、制御回路23は、S31において、演算回路21bへ第3レジスタ13bの最下位桁の値を読み出させ、当該値を受け取る。値が”0”であれば(S31にて、NOの場合)、制御回路23は、S32において、転送制御回路22bへ指示して、第2レジスタ12(Y)に”0”を格納した後、S5〜S7の処理を実行する。一方、値が”1”であれば(S31にて、YES の場合)、制御回路23は、S22の処理を行わずに、S5〜S7の処理を実行する。
When the processes of S21 to S24 are repeated (n-1) times, the control circuit 23 causes the
ここで、本実施形態のS5〜S7は、図4に示すS5〜S7と略同様であるが、S6に代えて設けられたS6bでは、S6とは異なり、符号を考慮することなく、仮数部の値同士が加算させる。具体的には、S6bにおいて、制御回路23は、演算回路21bへ指示して、第1レジスタ11の仮数部の値と第2レジスタ12の仮数部の値とを加算させ、加算結果を第1レジスタ11の仮数部の領域AMに格納させる。
Here, S5 to S7 of this embodiment are substantially the same as S5 to S7 shown in FIG. 4, but in S6b provided in place of S6, unlike S6, the significand part is not considered without considering the sign. The values of are added together. Specifically, in S6b, the control circuit 23 instructs the
なお、上記では、一例として、2進演算する場合を例にして説明したが、より一般的に、2以上の自然数をxとして、x進演算する場合は、上記S21およびS22の処理、すなわち、上記S22の処理を行うか否かを最下位の桁の値に応じて決定する処理に代えて、上記S22の処理を、第3レジスタ13bの最下位桁の値の回数だけ繰り返す処理が行われる。さらに、S24の後にも、第3レジスタ13bの最下位桁の値の回数だけ、S24と同様の処理、すなわち、第1レジスタ11の仮数部への第2レジスタ12の仮数部への加算処理が繰り返されると共に、最後の繰り返し時の加算処理に代えて、上記S31〜S32およびS5〜S7の処理が行われる。
In the above description, as an example, the case of binary calculation has been described as an example, but more generally, when a natural number of 2 or more is x and x-ary calculation is performed, the processing of S21 and S22, that is, Instead of the process of determining whether or not to perform the process of S22 according to the value of the least significant digit, a process of repeating the process of S22 as many times as the value of the least significant digit of the
また、上記では、S31およびS32の処理が行われる場合を例にして説明したが、第3レジスタ13bに格納される浮動小数点数の表現方法が、全体が”0”である場合を除いて、最上位の桁が”0”にならないような表現方法で表現されている場合、すなわち、上記S31の判定が常にYES になる場合は、S31およびS32の処理が不要である。この場合、上記第3レジスタ13bに格納されるオペランドが”0”の場合、演算結果が”0”にならないが、制御回路23が、S11の後、演算回路21bへ指示して、オペランドの双方、すなわち、第2レジスタ12の最下位の桁を除く部分、および、第3レジスタ12の値)が”0”であるか否かをテストさせ、一方が”0”であった場合は、それ以降の処理を実行せず、転送制御回路22bへ指示して、演算結果として、”0”を出力させればよい。なお、両オペランドが”0”でないことの事前確認は、S31およびS32を省略するか否かに拘わらず、演算速度向上に有効である。
Further, in the above description, the case where the processing of S31 and S32 is performed has been described as an example. However, the method of expressing the floating-point number stored in the
このように、本実施形態に係る演算装置1bは、浮動小数点数を乗算する際、桁のシフトおよび加算を繰り返して乗算結果を得ており、これら繰り返されるシフトおよび加算処理のうち、最後の加算処理の前に、丸め用の値を設定した後、最後の加算処理を行っている。したがって、第1の実施形態と同様に、全体で見ると、演算後に丸め処理を行う方法と比較して、より短い時間で、正しく丸められた乗算結果を得ることができる。
As described above, when multiplying the floating-point number, the
〔第3の実施形態〕
本実施形態では、正しく丸められた除算結果を高速に算出可能な構成について説明する。すなわち、本実施形態に係る演算装置1cは、被序数の右シフトと、演算結果の左シフトと、被序数と序数との比較に応じた演算結果の最下位の桁設定とを繰り返して、演算結果を算出しているが、丸め用の桁の設定処理および丸め処理に代えて、被序数と序数との比較結果に応じて上記丸め用の値の加算の要否を決定する処理を行っている。
[Third Embodiment]
In the present embodiment, a configuration capable of calculating a correctly rounded division result at high speed will be described. That is, the arithmetic device 1c according to the present embodiment repeats the right shift of the operand number, the left shift of the operator result, and the lowest digit setting of the operator result according to the comparison between the operand number and the ordinal number. The result is calculated, but instead of rounding digit setting processing and rounding processing, processing for determining whether or not to add the rounding value is performed according to the comparison result between the ordinal number and the ordinal number. Yes.
具体的には、本実施形態に係る演算装置1cは、第2の実施形態に係る演算装置1bと略同様の構成であるが、第1および第2レジスタ11・12に代えて、第3レジスタ13bと同一構成、すなわち、仮数部の桁数がn桁の第1および第2レジスタ11b・12bが設けられている共に、制御回路23が各部材11c〜13b、21cおよび22bを制御する際のアルゴリズムが変更されている。
Specifically, the arithmetic device 1c according to the present embodiment has substantially the same configuration as the
また、本実施形態において、第2の実施形態に係る演算回路21bに代えて設けられた演算回路21cは、演算回路21bが可能な演算に加えて、指数部の減算、仮数部同士の比較、仮数部の1増加、および、仮数部の桁シフト(左)が可能なように構成されている。なお、加減算および乗算が不要であれば、演算回路21および21bとは異なり、本実施形態の動作の説明において用いなかった処理(例えば、絶対値の比較処理など)を実施できなくてもよい。
In this embodiment, the
より詳細には、本実施形態に係る演算回路21cは、制御回路23から指数部の減算が指示された場合、指示されたレジスタ(例えば、第2レジスタ12c)の指数部の領域AEより読み出された値から、指示されたレジスタ(例えば、第3レジスタ13b)の指数部の領域AEより読み出された値を減算し、減算結果を、指示されたレジスタ(例えば、第1レジスタ11c)の指数部の領域AEへ格納できる。
More specifically, when the subtraction of the exponent part is instructed from the control circuit 23, the
また、制御回路23から仮数部の比較が指示された場合、指示された2つのレジスタ(例えば、第2および第3レジスタ12c・13b)の仮数部の領域AMから読み出された値同士を比較し、比較結果を、制御回路23へ伝えることができる。さらに、制御回路23から仮数部の1増加が指示された場合、指示されたレジスタ(例えば、第1レジスタ11c)の仮数部の値を1増加させて、当該レジスタの仮数部の領域AMへ格納できる。同様に、左シフトが指示された場合、指示されたレジスタ(例えば、第1レジスタ11c)の仮数部の値を左に1桁シフトして、当該レジスタの仮数部の領域AMへ、シフト結果を格納できる。なお、左シフトも、右シフトと同様に算術的な左シフトであり、シフトの結果、新たに挿入される下位桁の値は、”0”に設定されている。
When the comparison of the mantissa is instructed from the control circuit 23, the values read from the mantissa area AM of the two instructed registers (for example, the second and
上記構成において、例えば、メモリ31の予め定められた記憶領域へ2つのオペランドが格納され、制御回路23の予め定められたアドレスへ除算開始の指示を示す命令が書き込まれるなどして、演算装置1へ除算(Y/Z→X)が指示されると、図8に示すS41において、制御回路23は、転送制御回路22bへ指示して、被序数Yを第2レジスタ12cへ格納させると共に、序数Zを第3レジスタ13bへ格納させる。
In the above configuration, for example, two operands are stored in a predetermined storage area of the
上記S41において、両レジスタ12c・13bにオペランドが格納されると、制御回路23は、S42において、転送制御回路22bへ指示して、除算結果(商)の格納に用いる第1レジスタ11の浮動小数点数Xを”0”に設定する。
When the operand is stored in both
さらに、S43において、制御回路23は、演算回路21cへ指示して、第2レジスタ12cの指数部の値から、第3レジスタ13bの指数部の値を減算させ、演算結果を、第1レジスタ11cの指数部の領域AEに格納させる(Yの指数部−Zの指数部→Xの指数部)。また、S44において、制御回路23は、演算回路21bへ指示して、第2および第3レジスタ12c・13bの符号の排他的論理和を算出させ、演算結果を、第1レジスタ11cの符号の領域ASに格納させる(Yの符号 EX-OR Zの符号→Xの符号)。
Further, in S43, the control circuit 23 instructs the
また、制御回路23は、以下のS51〜S55の処理を、仮数部の桁数だけ(n回だけ)繰り返す。一例として、演算回路21cが2進数で演算する場合について説明すると、S51において、制御回路23は、演算回路21cへ指示して、第2レジスタ12cおよび第3レジスタ13bの仮数部の値同士(Yの仮数部およびZの仮数部)を比較させ、比較結果を受け取る。第2レジスタ12cの仮数部の値が第3レジスタ13bよりも大きいか同じ場合(上記S51にて、Y≧Zの場合)、制御回路23は、演算回路21cへ指示して、第2レジスタ12cの仮数部の値から第3レジスタ13bの仮数部の値を減算させ、減算結果を、第2レジスタ12cの仮数部の領域AMに格納させる(Yの仮数部−Zの仮数部→Yの仮数部)。さらに、制御回路23は、S53において、演算回路21cへ指示して、第1レジスタ11cの仮数部の最下位の桁(Xの最下位桁)に”1”を書き込んだ後、S54以降の処理を行う。一方、第2レジスタ12cの仮数部の値の方が小さい場合(上記S51にて、Y<Zの場合)は、上記S52およびS53の処理を行わずに、S54以降の処理を行う。
Further, the control circuit 23 repeats the following processes of S51 to S55 by the number of digits of the mantissa part (only n times). As an example, the case where the
すなわち、S54において、制御回路23は、演算回路21cへ指示して、第1レジスタ11cの仮数部の値(Xの仮数部)を1桁左にシフトさせる。また、S55において、制御回路23は、演算回路21cへ指示し、第2レジスタ12cの仮数部の値(Yの仮数部)を1桁右にシフトさせ、第2レジスタ12cの仮数部の領域AMに格納させる。
That is, in S54, the control circuit 23 instructs the
上記S51〜S55の処理がn回繰り返されると、制御回路23は、S61において、演算回路21cに、第2レジスタ12cおよび第3レジスタ13bの仮数部の値同士(Yの仮数部およびZの仮数部)を比較させ、比較結果を受け取る。第2レジスタ12cの方が大きいか同じことを比較結果が示している場合(上記S61にて、Y≧Zの場合)、制御回路23は、S62において、第1レジスタ11cの仮数部の値(Xの仮数部)を1増加させた後、S63以降の処理を行う。一方、第2レジスタ12cの方が小さいことを比較結果が示している場合(上記S61にて、Y<Zの場合)は、上記S62の処理を行わずにS63以降の処理が行われる。すなわち、制御回路23は、S63において、演算結果を出力するために、転送制御回路22bへ指示して、第1レジスタ11cに格納された浮動小数点数Xを、メモリ31へ格納させる。
When the processes of S51 to S55 are repeated n times, the control circuit 23 causes the
なお、上記では、一例として、2進演算する場合を例にして説明したが、より一般的にx進演算する場合は、上記S51〜S53の処理に代えて、上記S51およびS52の処理が、S51にて、第3レジスタ13bの仮数部の方が小さいと判定されるまでの間、繰り返され、その後、第1レジスタ11cの最下位の桁に、繰り返し回数が書き込まれる。さらに、上記S61およびS62の処理に代えて、上記S51およびS52の処理が、第3レジスタ13bの仮数部の方が小さいと判定されるか、繰り返し回数が上記丸め用の値(例えば、10進の場合で5回)になるまでの間、繰り返される。そして、繰り返し回数が上記丸め用の値になった場合は、S62の処理が行われた後、上記S63の処理が行われる。一方、繰り返し回数が上記丸め用の値に達するまでに繰り返しが終了した場合は、制御回路23は、上記S62の処理を行わずに、上記S63の処理を行う。
In the above description, as an example, a case where binary calculation is performed has been described as an example. However, in a case where x-ary calculation is performed more generally, instead of the processes of S51 to S53, the processes of S51 and S52 are as follows. The processing is repeated until it is determined in S51 that the mantissa part of the
上記構成では、商の最下位の桁を算出した後、被序数から序数を減算可能な回数が上記丸め用の値を超えているか否かによって、商に1を加えるか否かを判定している。したがって、商の最下位ビットよりも1桁下位の値(丸め用の桁の値)を決定した後で、丸め処理を行う構成に比べて、演算に必要な桁数および演算量を削減できる。 In the above configuration, after calculating the least significant digit of the quotient, it is determined whether or not 1 is added to the quotient depending on whether the number of times the ordinal number can be subtracted from the ordinal number exceeds the rounding value. Yes. Accordingly, the number of digits and the amount of calculation required for the calculation can be reduced as compared with the configuration in which the rounding process is performed after determining the value one digit lower than the least significant bit of the quotient (the value of the rounding digit).
本発明に係る演算装置の制御方法および演算装置は、浮動小数点数を演算する際、正しく丸められた演算結果を、全体として、より短い時間で得ることができるので、浮動小数点数を演算する用途に広く適用できる。 The arithmetic device control method and arithmetic device according to the present invention, when calculating a floating-point number, can obtain a correctly rounded operation result as a whole in a shorter time. Widely applicable to.
1・1b・1c 演算装置
11・11c 第1レジスタ(レジスタ;演算結果レジスタ)
12・12c 第2レジスタ(レジスタ;被序数レジスタ)
13b 第3レジスタ(特定のレジスタ;序数レジスタ)
21・21b・21c 演算回路
22・22b 転送制御回路(制御回路)
23 制御回路
1, 1b, 1c
12.12c Second register (register; ordinal number register)
13b Third register (specific register; ordinal register)
21, 21b,
23 Control circuit
Claims (10)
加算または減算のための2つのオペランドが与えられた場合に、上記複数のレジスタの2つへ、それぞれの仮数部の最下位の桁の値が0になり、残余の値が、それぞれに対応するオペランドとなるように、上記制御回路が、上記各レジスタへオペランドを書き込む書き込み工程と、
上記各オペランドを格納したレジスタのうち、両者の指数部の値が異なる場合は、大きい方を第1レジスタ、両者の指数部の値が同じ場合は、これらのレジスタの一方を第1レジスタとし、上記各オペランドを格納したレジスタのうち、上記第1レジスタではない方を第2レジスタとするとき、上記演算回路が上記第2レジスタの仮数部の値を、両者の指数部の差の桁分だけ右シフトして、上記複数のレジスタのいずれかへ格納する位合わせ工程と、
上記第1レジスタの仮数部の値と、上記位合わせ工程にて、シフト結果が格納されたレジスタの仮数部の値との加算結果または減算結果を算出して、演算結果の仮数部を求める演算工程と、
当該演算工程よりも前に実施され、上記制御回路が、上記第1レジスタの仮数部の最下位桁へ、丸め処理のために予め定められた数を設定する設定工程とを含んでいることを特徴とする演算装置の制御方法。 A plurality of registers capable of storing a floating-point number whose number of digits in the mantissa part is one digit larger than an operand given as a floating-point number including a mantissa part and an exponent part, and an arithmetic circuit for performing an operation with reference to the value of each register And a control method of an arithmetic unit having a control circuit for controlling each of the registers and the arithmetic circuit,
When two operands for addition or subtraction are given, the value of the least significant digit of each mantissa becomes 0 and the remaining value corresponds to each of two of the plurality of registers. A writing step in which the control circuit writes an operand to each of the registers so as to be an operand;
Of the registers storing the above operands, when the values of the exponents of the two are different, the larger one is the first register, and when the values of the exponents of both are the same, one of these registers is the first register, Of the registers storing the operands, when the second register is not the first register, the arithmetic circuit calculates the mantissa value of the second register by the difference between the exponents of the two registers. An alignment step of shifting right and storing in any of the plurality of registers;
An operation for calculating the mantissa part of the operation result by calculating an addition result or a subtraction result between the value of the mantissa part of the first register and the value of the mantissa part of the register storing the shift result in the alignment step. Process,
Executed before the operation step, and the control circuit includes a setting step for setting a predetermined number for rounding to the least significant digit of the mantissa part of the first register. A control method for an arithmetic device.
上記制御回路は、加算または減算のための2つのオペランドが与えられた場合に、上記複数のレジスタの2つへ、それぞれの仮数部の最下位の桁の値が0になり、残余の値が、それぞれに対応するオペランドとなるように、上記各レジスタへオペランドを書き込むものであり、
上記演算回路は、上記各オペランドを格納したレジスタのうち、両者の指数部の値が異なる場合は、大きい方を第1レジスタ、両者の指数部の値が同じ場合は、これらのレジスタの一方を第1レジスタとし、上記各オペランドを格納したレジスタのうち、上記第1レジスタではない方を第2レジスタとするとき、上記第2レジスタの仮数部の値を、両者の指数部の差の桁分だけ右シフトして、上記複数のレジスタのいずれかへ格納すると共に、上記第1レジスタの仮数部の値と、当該シフト結果が格納されたレジスタの仮数部の値との加算結果または減算結果を算出して、演算結果の仮数部を求めるものであり、
さらに、上記制御回路は、上記演算回路が演算結果の仮数部を求める前に、上記第1レジスタの仮数部の最下位桁へ、丸め処理のために予め定められた数を設定するものであることを特徴とする演算装置。 A plurality of registers capable of storing a floating-point number whose number of digits in the mantissa part is one digit larger than an operand given as a floating-point number including a mantissa part and an exponent part, and an arithmetic circuit for performing an operation by referring to the value of each register And a control circuit that controls each of the registers and the arithmetic circuit,
When two operands for addition or subtraction are given to the control circuit, the least significant digit value of each mantissa is set to 0 and the remaining value is set to two of the plurality of registers. , The operands are written to the registers so that the corresponding operands are
In the arithmetic circuit, when the values of the exponent parts of the operands are different from each other, the larger one is the first register, and when the values of the exponent parts are the same, one of these registers is assigned. When the second register is the first register and the one that stores each of the operands is not the first register, the value of the mantissa part of the second register is the digit of the difference between the exponents of the two registers. And right-shifted and stored in one of the plurality of registers, and the addition result or subtraction result of the value of the mantissa part of the first register and the value of the mantissa part of the register storing the shift result is To calculate the mantissa part of the operation result,
Further, the control circuit sets a predetermined number for rounding to the least significant digit of the mantissa part of the first register before the arithmetic circuit obtains the mantissa part of the operation result. An arithmetic device characterized by that.
乗算のための2つのオペランドが与えられた場合に、上記複数のレジスタの1つへ、それぞれの仮数部の最下位の桁の値が0になり、残余が、上記オペランドの一方となるように、上記制御回路が、当該レジスタへ当該オペランドを書き込むと共に、上記特定のレジスタへ、上記オペランドの他方を書き込む書き込み工程と、
上記制御回路が、上記特定のレジスタの仮数部の各桁の値を、最下位の桁から順に取得する取得工程と、
上記取得工程にして取得される各桁に対応して行われ、上記演算回路が、上記制御回路の指示に応じて、上記複数のレジスタのうち、現在の演算結果が格納されているレジスタの仮数部の値へ、上記複数のレジスタのうち、オペランドが書き込まれたレジスタの仮数部の値を、上記対応する桁の値の回数だけ加算し、加算結果を上記複数のレジスタの1つへ書き込む加算工程と、
上記取得工程にして取得される各桁に対応して行われ、上記演算回路が、同じ桁に対応する上記加算工程にて加算結果が書き込まれたレジスタの仮数部の値を、1桁右シフトして、当該シフト結果を、新たな演算結果として、上記複数のレジスタの1つへ書き込むシフト工程と、
上記各加算工程のうち、最後の加算工程の前に実施され、上記制御回路が、上記複数のレジスタのうち、オペランドが書き込まれたレジスタの仮数部の最下位桁へ、丸め処理のために予め定められた数を設定する設定工程とを含んでいることを特徴とする演算装置の制御方法。 A plurality of registers capable of storing a floating point number whose number of digits in the mantissa part is one digit larger than an operand given as a floating point number including a mantissa part and an exponent part; a specific register capable of storing the operand; A control method for an arithmetic device having an arithmetic circuit that performs an operation with reference to a register value, and a control circuit that controls each of the registers and the arithmetic circuit,
When two operands for multiplication are given, the value of the least significant digit of each mantissa part becomes 0 and the remainder becomes one of the operands to one of the plurality of registers. The control circuit writes the operand to the register and writes the other of the operands to the specific register;
An acquisition step in which the control circuit acquires the value of each digit of the mantissa part of the specific register in order from the least significant digit;
The mantissa of the register in which the operation result is stored among the plurality of registers according to an instruction from the control circuit is performed corresponding to each digit acquired in the acquisition step. The value of the mantissa of the register in which the operand is written is added by the number of times of the corresponding digit, and the addition result is written to one of the plurality of registers. Process,
The arithmetic circuit shifts the value of the mantissa part of the register in which the addition result is written in the addition step corresponding to the same digit to the right by one digit. A shift step of writing the shift result into one of the plurality of registers as a new operation result;
Of the above addition steps, the control circuit is executed before the final addition step, and the control circuit performs a rounding process in advance on the least significant digit of the mantissa part of the register in which the operand is written out of the plurality of registers. And a setting step for setting a predetermined number.
上記制御回路は、乗算のための2つのオペランドが与えられた場合に、上記複数のレジスタの1つへ、それぞれの仮数部の最下位の桁の値が0になり、残余が、上記オペランドの一方となるように、当該レジスタへ当該オペランドを書き込むと共に、上記特定のレジスタへ、上記オペランドの他方を書き込むと共に、上記特定のレジスタの仮数部の各桁の値を、最下位の桁から順に取得するものであり、
上記演算回路は、上記制御回路の指示に基づき、上記制御回路の取得した各桁について、上記複数のレジスタのうち、現在の演算結果が格納されているレジスタの仮数部の値へ、上記複数のレジスタのうち、オペランドが書き込まれたレジスタの仮数部の値を、上記対応する桁の値の回数だけ加算し、加算結果を上記複数のレジスタの1つへ書き込むと共に、当該レジスタの仮数部の値を、1桁右シフトして、当該シフト結果を、新たな演算結果として、上記複数のレジスタの1つへ書き込むものであり、
上記制御回路は、さらに、上記演算回路による最後の加算の前に、上記複数のレジスタのうち、オペランドが書き込まれたレジスタの仮数部の最下位桁へ、丸め処理のために予め定められた数を設定するものであることを特徴とする演算装置。 A plurality of registers capable of storing a floating point number whose number of digits in the mantissa part is one digit larger than an operand given as a floating point number including a mantissa part and an exponent part; a specific register capable of storing the operand; An arithmetic device having an arithmetic circuit that performs an operation referring to a value of a register, and a control circuit that controls each of the registers and the arithmetic circuit,
When two operands for multiplication are given, the control circuit sets the value of the least significant digit of each mantissa part to one of the plurality of registers to be 0, and the remainder is the value of the operand. Write the operand to the register so that it becomes one, write the other operand to the specific register, and obtain the value of each digit of the mantissa part of the specific register in order from the lowest digit Is what
The arithmetic circuit, based on an instruction from the control circuit, for each digit acquired by the control circuit, to the value of the mantissa part of the register in which the current arithmetic result is stored among the plurality of registers. Among the registers, the value of the mantissa part of the register in which the operand is written is added by the number of times of the corresponding digit, the addition result is written to one of the plurality of registers, and the value of the mantissa part of the register Is shifted one digit to the right, and the shift result is written to one of the plurality of registers as a new operation result.
The control circuit further includes a number predetermined for rounding to the least significant digit of the mantissa part of the register in which the operand is written out of the plurality of registers before the final addition by the arithmetic circuit. An arithmetic device characterized in that it is set.
除算のための2つのオペランドが与えられた場合に、上記制御回路が、上記複数のレジスタの2つへ、それぞれに対応するオペランドを書き込む書き込み工程と、
上記複数のレジスタのうち、上記オペランドのうちの被序数が格納されたレジスタを被序数レジスタ、上記オペランドのうちの序数が格納されたレジスタを序数レジスタ、演算結果が格納されるレジスタを演算結果レジスタとするとき、上記演算回路が、上記被序数レジスタの仮数部の値を、当該仮数部の桁数の回数だけ、1桁ずつ右シフトしながら、当該被序数レジスタの仮数部の値から上記序数レジスタの仮数部の値を何回減算できるかを判定することによって、演算結果の各桁を求め、それぞれを、上記演算結果レジスタの仮数部の対応する桁へ格納する演算工程と、
上記演算回路が、上記仮数部の桁数の回数だけ右シフトされた後の被序数レジスタの仮数部の値から、上記序数レジスタの仮数部の値を、丸め処理のために予め定められた回数、減算できた場合は、上記演算結果レジスタの仮数部を1増加させる丸め処理工程とを含んでいることを特徴とする演算装置の制御方法。 A plurality of registers capable of storing an operand given as a floating-point number including a mantissa part and an exponent part; an arithmetic circuit for performing an operation by referring to the value of each register; and a control circuit for controlling the registers and the arithmetic circuit. A method of controlling an arithmetic unit having
When two operands for division are given, the control circuit writes a corresponding operand to each of two of the plurality of registers;
Of the plurality of registers, a register storing the ordinal number of the operands is an ordinal register, a register storing the ordinal number of the operands is an ordinal register, and a register storing the operation result is an operation result register. When the arithmetic circuit shifts the value of the mantissa part of the mantissa register rightward by one digit by the number of digits of the mantissa part, the ordinal number from the value of the mantissa part of the mantissa register By determining how many times the value of the mantissa part of the register can be subtracted, each operation result is obtained, and each is stored in the corresponding digit of the mantissa part of the operation result register; and
A predetermined number of times for rounding the mantissa value of the ordinal register from the value of the mantissa part of the ordinal register after the arithmetic circuit is right-shifted by the number of digits of the mantissa part. And a rounding process for incrementing the mantissa part of the calculation result register by 1 when the calculation result register is subtracted.
上記制御回路は、除算のための2つのオペランドが与えられた場合に、上記制御回路が、上記複数のレジスタの2つへ、それぞれに対応するオペランドを書き込むものであり、
上記演算回路は、上記複数のレジスタのうち、上記オペランドのうちの被序数が格納されたレジスタを被序数レジスタ、上記オペランドのうちの序数が格納されたレジスタを序数レジスタ、演算結果が格納されるレジスタを演算結果レジスタとするとき、上記被序数レジスタの仮数部の値を、当該仮数部の桁数の回数だけ、1桁ずつ右シフトしながら、当該被序数レジスタの仮数部の値から上記序数レジスタの仮数部の値を何回減算できるかを判定することによって、演算結果の各桁を求め、それぞれを、上記演算結果レジスタの仮数部の対応する桁へ格納すると共に、上記仮数部の桁数の回数だけ右シフトされた後の被序数レジスタの仮数部の値から、上記序数レジスタの仮数部の値を、丸め処理のために予め定められた回数、減算できた場合は、上記演算結果レジスタの仮数部を1増加させるものであることを特徴とする演算装置。 A plurality of registers capable of storing an operand given as a floating-point number including a mantissa part and an exponent part; an arithmetic circuit for performing an operation by referring to the value of each register; and a control circuit for controlling the registers and the arithmetic circuit. An arithmetic unit having
In the control circuit, when two operands for division are given, the control circuit writes corresponding operands to two of the plurality of registers,
The arithmetic circuit stores a result of an operation in which a register in which an ordinal number of the operands is stored is an ordinal register, a register in which the ordinal number of the operands is stored, and an ordinal register. When the register is an arithmetic result register, the value of the mantissa part of the mantissa register is shifted right by one digit by the number of digits of the mantissa part, and the ordinal number is calculated from the value of the mantissa part of the mantissa register. By determining how many times the value of the mantissa part of the register can be subtracted, each digit of the operation result is obtained and stored in the corresponding digit of the mantissa part of the operation result register. The mantissa value of the ordinal register after being shifted right by the number of times could be subtracted a predetermined number of times for rounding from the mantissa value of the ordinal register. If the arithmetic unit, characterized in that in which increased by one mantissa of the operation result register.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2003365520A JP2005128907A (en) | 2003-10-27 | 2003-10-27 | Method for controlling arithmetic unit, arithmetic unit, its program, and recording medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2003365520A JP2005128907A (en) | 2003-10-27 | 2003-10-27 | Method for controlling arithmetic unit, arithmetic unit, its program, and recording medium |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2005128907A true JP2005128907A (en) | 2005-05-19 |
Family
ID=34644158
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2003365520A Pending JP2005128907A (en) | 2003-10-27 | 2003-10-27 | Method for controlling arithmetic unit, arithmetic unit, its program, and recording medium |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2005128907A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104866277A (en) * | 2014-02-26 | 2015-08-26 | 北京国睿中数科技股份有限公司 | Device and method for conjugate addition and subtraction of floating point complex numbers |
CN113703717A (en) * | 2021-08-31 | 2021-11-26 | 南京英锐创电子科技有限公司 | Binary floating-point number multiplication method, circuit and calculation device |
-
2003
- 2003-10-27 JP JP2003365520A patent/JP2005128907A/en active Pending
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104866277A (en) * | 2014-02-26 | 2015-08-26 | 北京国睿中数科技股份有限公司 | Device and method for conjugate addition and subtraction of floating point complex numbers |
CN113703717A (en) * | 2021-08-31 | 2021-11-26 | 南京英锐创电子科技有限公司 | Binary floating-point number multiplication method, circuit and calculation device |
CN113703717B (en) * | 2021-08-31 | 2024-01-26 | 南京英锐创电子科技有限公司 | Binary floating-point number multiplication circuit, control method thereof and computing device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CA2641334C (en) | Floating-point processor with reduced power requirements for selectable subprecision | |
JP4418578B2 (en) | Data processing apparatus and method for applying floating point arithmetic to first, second and third operands | |
US8990282B2 (en) | Apparatus and method for performing fused multiply add floating point operation | |
CN108139885B (en) | Floating point number rounding | |
KR20080055985A (en) | Floating-point processor with selectable subprecision | |
US10061561B2 (en) | Floating point addition with early shifting | |
JPH05250146A (en) | Arithmetic operation circuit executing integer involution processing | |
US4996660A (en) | Selection of divisor multipliers in a floating point divide circuit | |
US7016930B2 (en) | Apparatus and method for performing operations implemented by iterative execution of a recurrence equation | |
US6598065B1 (en) | Method for achieving correctly rounded quotients in algorithms based on fused multiply-accumulate without requiring the intermediate calculation of a correctly rounded reciprocal | |
JP2005128907A (en) | Method for controlling arithmetic unit, arithmetic unit, its program, and recording medium | |
JP2010218197A (en) | Floating point product sum arithmetic operation device, floating point product sum arithmetic operation method, and program for floating point product sum arithmetic operation | |
JPH0687219B2 (en) | Control method | |
US6820106B1 (en) | Method and apparatus for improving the performance of a floating point multiplier accumulator | |
US7243119B1 (en) | Floating point computing unit | |
KR20210124347A (en) | Anchor data point transformation | |
JP4271589B2 (en) | Control method of arithmetic device, program thereof and recording medium | |
US7237000B2 (en) | Speed of execution of a conditional subtract instruction and increasing the range of operands over which the instruction would be performed correctly | |
JP4428778B2 (en) | Arithmetic device, arithmetic method, and computing device | |
JP4893340B2 (en) | Calculation apparatus and calculation program | |
JP2664750B2 (en) | Arithmetic device and arithmetic processing method | |
JP2006338215A (en) | Vector product-sum operation circuit | |
JP2903529B2 (en) | Vector operation method | |
JP4109181B2 (en) | Logic circuit, and floating-point arithmetic circuit and microprocessor using the same | |
WO2020084692A1 (en) | Computation processing device and computation processing device control method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20051013 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20080226 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20080424 |
|
RD02 | Notification of acceptance of power of attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7422 Effective date: 20080424 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20080715 |
|
A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20081125 |