JP3557366B2 - Size comparison method and device - Google Patents

Size comparison method and device Download PDF

Info

Publication number
JP3557366B2
JP3557366B2 JP10394599A JP10394599A JP3557366B2 JP 3557366 B2 JP3557366 B2 JP 3557366B2 JP 10394599 A JP10394599 A JP 10394599A JP 10394599 A JP10394599 A JP 10394599A JP 3557366 B2 JP3557366 B2 JP 3557366B2
Authority
JP
Japan
Prior art keywords
bit
carry
value
magnitude
binary number
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
JP10394599A
Other languages
Japanese (ja)
Other versions
JP2000293359A (en
Inventor
一文 田上
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Panasonic Corp
Panasonic Holdings Corp
Original Assignee
Panasonic Corp
Matsushita Electric Industrial Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Panasonic Corp, Matsushita Electric Industrial Co Ltd filed Critical Panasonic Corp
Priority to JP10394599A priority Critical patent/JP3557366B2/en
Publication of JP2000293359A publication Critical patent/JP2000293359A/en
Application granted granted Critical
Publication of JP3557366B2 publication Critical patent/JP3557366B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Description

【0001】
【発明の属する技術分野】
本発明は、2つの2進数の大小比較方法および装置に関するものである。
【0002】
【従来の技術】
従来の大小比較方法としては、比較する2つの2進数A,Bの減算(A−B)を行った場合のキャリー伝播を検出することにより、上記2つの2進数の大小関係を判定する方法がある。この方法は、例えば、特開平6−250821号公報に示されている。この特開平6−250821号公報に記載の従来例では、キャリー伝播により最上位ビットのキャリーを検出したらA大なりBと判定している。
【0003】
また、比較する2つの2進数の各ビット毎の大小関係を検出し、その検出結果を元に上記2つの2進数の大小関係を判定する方法がある。この方法は、例えば、特開平10−154066号公報に示されている。この特開平10−154066号公報に記載の従来例では、最上位ビットのビットの比較を行い、大小関係が検出できなければ1ビット下位のビットで比較を行う、というように順次各ビットの比較を最下位ビットまで行うことにより2つの2進数の大小関係を判定している。
【0004】
【発明が解決しようとする課題】
しかしながら、特開平6−250821号公報に記載の従来例では、検出するデータのビット幅が大きくなればなるほど最下位ビットから最上位ビットまでのキャリー伝播にかかる遅延が大きくなるし、その遅延を縮小するために回路の並列化を進めれば回路規模が大きくなるという問題点を有していた。
【0005】
一方、特開平10−154066号公報に記載の従来例でも同様のことが言え、検出するデータのビット幅が大きくなればなるほど最上位ビットから最下位ビットまでの情報伝播にかかる遅延が大きくなるし、その遅延を縮小するために回路の並列化を進めれば回路規模が大きくなるという問題点を有していた。
【0006】
本発明は、上記問題点を解決するもので、回路規模が小さく演算時間の短い大小比較方法と大小比較装置を提供することを目的とする。
【0007】
【課題を解決するための手段】
本発明の大小比較方法および装置は、2つの2進数A,Bの大小比較を行う際に、最上位ビットからは下位の方向へ順次ビットの大小比較を行い、最下位ビットから上位の方向へ上記2進数Aから上記2進数Bを減算した場合のキャリー伝播の検出を行い、上記大小比較結果と上記キャリー伝播結果から上記2進数AとBの大小関係を判定することにより、回路規模を小さく、かつ演算時間を短くする。
【0008】
具体的には、本発明の大小比較方法は、2つのnビット(nは正の整数)の2進数A,Bの大小比較を行う際に、ビット0(最下位ビット)からビット(k−1)(kは正の整数,0<k<n)までのビット範囲で、2進数Aから2進数Bを減算した場合のキャリー伝播を検出し、つまり2進数Aと2進数Bのビット反転と最下位ビットの桁位置における値“1”とを加えた場合に発生するビット(k−1)のキャリーを検出し、ビットkからビット(n−1)(最上位ビット)までのビット範囲で、2進数Aと2進数Bの大小関係を最上位ビットから下位ビットの方向に検出し、大小関係の検出結果とキャリーの検出結果から、2進数Aと2進数Bの大小関係を判定して出力することを特徴とする。
【0009】
これにより、最下位ビットからのキャリー伝播検出と、最上位ビットから順次大小関係検出とを同時に並列に実行することができ、演算時間を大幅に短縮することができ、しかも回路規模の増加は小さく抑えることができる。なお、上記2進数A,Bの上位ビットと下位ビットの区分けは、大小比較とキャリー伝搬の各々の処理時間を考慮して、両方の処理時間がほぼ等しくなるように決定するのが好ましく、ちょうど真ん中で行う必要はない。また、特に両方の処理時間がほぼ等しくなるように決定する必要はない。どのように上位ビットと下位ビットの区分けを設定しても、上記の大小比較とキャリー伝搬を同時に並列に実行することで、大小比較とキャリー伝搬の何れか片方のみを行う場合に比べて処理時間の短縮を図ることができる。
【0010】
大小検出は2進数AとBが2の補数表現される符号付き2進数であるとき、つぎのように行うことが好ましい。
【0011】
2進数Aの最上位ビットである(n−1)ビットが正の符号を示し、2進数Bの最上位ビットである(n−1)ビットが負の符号を示す場合はA大なりBと判定し、2進数Aの最上位ビットである(n−1)ビットが負の符号を示し、2進数Bの最上位ビットである(n−1)ビットが正の符号を示す場合はA小なりBと判定し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行する。
【0012】
2進数Aの(n−2)ビットが値“1”を示し、2進数Bの(n−2)ビットが値“0”を示す場合はA大なりBと判定し、2進数Aの(n−2)ビットが値“0”を示し、2進数Bの(n−2)ビットが値“1”を示す場合はA小なりBと判定し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行する。
【0013】
2進数Aの(n−3)ビットが値“1”を示し、2進数Bの(n−3)ビットが値“0”を示す場合はA大なりBと判定し、2進数Aの(n−3)ビットが値“0”を示し、2進数Bの(n−3)ビットが値“1”を示す場合はA小なりBと判定し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行する。
【0014】
上記の大小関係検出をkビットまで順次行い、kビットでも大小関係を検出できない場合は大小関係未検出と判定する。
【0015】
大小検出は2進数AとBが符号無し2進数であるとき、つぎのように行うことが好ましい。
【0016】
2進数Aの最上位ビットである(n−1)ビットが値“1”を示し、2進数Bの最上位ビットである(n−1)ビットが値“0”を示す場合はA大なりBと判定し、2進数Aの最上位ビットである(n−1)ビットが値“0”を示し、2進数Bの最上位ビットである(n−1)ビットが値“1”を示す場合はA小なりBと判定し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行する。
【0017】
2進数Aの(n−2)ビットが値“1”を示し、2進数Bの(n−2)ビットが値“0”を示す場合はA大なりBと判定し、2進数Aの(n−2)ビットが値“0”を示し、2進数Bの(n−2)ビットが値“1”を示す場合はA小なりBと判定し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行する。
【0018】
2進数Aの(n−3)ビットが値“1”を示し、2進数Bの(n−3)ビットが値“0”を示す場合はA大なりBと判定し、2進数Aの(n−3)ビットが値“0”を示し、2進数Bの(n−3)ビットが値“1”を示す場合はA小なりBと判定し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行する。
【0019】
上記の大小関係検出をkビットまで順次行い、kビットでも大小関係を検出できない場合は大小関係未検出と判定する。
【0020】
また、ビットkからビット(n−1)までのビット範囲で、2進数A,Bの大小関係を検出する際に、2進数A,Bが2の補数表現される符号付き2進数であればパッシブになり、符号無し2進数であればアクティブになる制御信号により、制御信号がパッシブであれば2進数A,Bを2の補数表現として大小関係を検出して出力し、制御信号がアクティブであれば2進数A,Bを符号無し2進数として大小関係を検出して出力することが好ましい。
【0021】
さらに、2進数A,Bの大小関係を判定する際に、ビットkからビット(n−1)までのビット範囲での大小関係が検出されたらその大小関係を出力し、大小関係が検出されなければキャリーの検出結果により、キャリーが検出されればA大なりBあるいはAとBは等しいと判定し、キャリーが検出されなければA小なりBと判定することが好ましい。
【0022】
また、ビット0からビット(k−1)までのビット範囲で、2進数Aと2進数Bのビット反転と最下位ビットの桁位置における値“1”とを加えた場合に発生するビット(k−1)のキャリーを検出する際に、2進数Aと2進数Bがビット0からビット(k−1)までのビット範囲で各ビット毎に全く等しいデータであるために、最下位ビットの桁位置に加えた値“1”がキャリー伝播の伝播元となり発生するビット(k−1)の第1のキャリーと、第1のキャリーが発生する場合も含めて総ての発生するキャリーを含むビット(k−1)の第2のキャリーを検出し、ビットkからビット(n−1)までのビット範囲での大小関係検出において大小関係が検出されたらその大小関係を出力し、大小関係が検出されなければキャリーの検出結果により、第1のキャリーが検出されればAとBは等しいと判定し、第1のキャリーが検出されずかつ第2のキャリーが検出されればA大なりBと判定し、第1のキャリーと第2のキャリーがともに検出されなければA小なりBと判定することが好ましい。
【0023】
このことにより、A大なりBとA小なりBとAとBは等しいという3つの状態を判定することができるようになる。
【0024】
同じ効果を得るため、ビット0からビット(k−1)までのビット範囲で、2進数Aと2進数Bのビット反転と最下位ビットの桁位置における値“1”とを加えた場合に発生するビット(k−1)のキャリーを検出する際に、2進数Aと2進数Bがビット0からビット(k−1)までのビット範囲で各ビット毎に全く等しいデータであるために、最下位ビットの桁位置に加えた値“1”がキャリー伝播の伝播元となり発生するビット(k−1)の第1のキャリーと、第1のキャリーが発生する場合以外で発生するキャリーを含むビット(k−1)の第2のキャリーを区別して検出し、ビットkからビット(n−1)までのビット範囲での大小関係検出において大小関係が検出されたらその大小関係を出力し、大小関係が検出されなければキャリーの検出結果により、第1のキャリーが検出されればAとBは等しいと判定して出力し、第2のキャリーが検出されればA大なりBと判定して出力し、第1のキャリーと第2のキャリーがともに検出されなければA小なりBと判定して出力するようにしてもよい。
【0025】
本発明の大小比較装置は、2つのnビットの2進数A,Bの大小比較を行う際に、ビット0(最下位ビット)からビット(k−1)までのビット範囲で、2進数Aから2進数Bを減算した場合のキャリー伝播の検出を行う、つまり2進数Aと2進数Bのビット反転と最下位ビットの桁位置における値“1”とを加えた場合に発生するビット(k−1)のキャリーを検出し出力するキャリー検出手段と、最上位ビットからKビットの範囲で、下位方向へ順次ビットの大小比較を行う大小検出手段と、大小検出手段の出力とキャリー検出手段の出力から2進数AとBの大小関係を判定する判定手段を備えていることを特徴とする。
【0026】
これにより、最下位ビットからのキャリー伝播検出と、最上位ビットから順次大小関係検出を同時に並列に実行することができ、演算時間を大幅に短縮することができ、しかも回路規模の増加は小さく抑えることができる。なお、上記2進数A,Bの上位ビットと下位ビットの区分けは、大小比較とキャリー伝搬の各々の処理時間を考慮して、両方の処理時間がほぼ等しくなるように決定するのが好ましく、ちょうど真ん中で行う必要はない。また、特に両方の処理時間がほぼ等しくなるように決定する必要はない。どのように上位ビットと下位ビットの区分けを設定しても、上記の大小比較とキャリー伝搬を同時に並列に実行することで、大小比較とキャリー伝搬の何れか片方のみを行う場合に比べて処理時間の短縮を図ることができる。
【0027】
上記の大小検出手段は、ビットkからビット(n−1)(最上位ビット)までのビット範囲で、2進数Aと2進数Bの大小関係を検出し、A大なりBの場合にアクティブになるA>B検出信号と、A小なりBの場合にアクティブになるA<B検出信号とを出力し、2進数Aと2進数Bの大小関係が検出できなければA>B検出信号とA<B検出信号が両方ともパッシブになるように構成されていることが好ましい。
【0028】
また、判定手段は、大小検出手段の出力とキャリー検出手段の出力から、2進数Aと2進数Bの大小関係を判定し、A大なりBあるいはAとBが等しい場合にパッシブになり、A小なりBの場合にアクティブになる大小比較判定信号を出力するように構成されていることが好ましい。
【0029】
大小検出手段の内部構成は2進数AとBが2の補数表現される符号付き2進数であるとき、つぎのように構成されていることが好ましい。
【0030】
2つのnビットの2進数A,Bが2の補数表現される符号付き2進数であるとき、2進数Aの最上位ビットである(n−1)ビットが正の符号を示し、2進数Bの最上位ビットである(n−1)ビットが負の符号を示す場合はA大なりBと判定してA>B検出信号をアクティブにして出力し、2進数Aの最上位ビットである(n−1)ビットが負の符号を示し、2進数Bの最上位ビットである(n−1)ビットが正の符号を示す場合はA小なりBと判定してA<B検出信号をアクティブにして出力し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行する。
【0031】
2進数Aの(n−2)ビットが値“1”を示し、2進数Bの(n−2)ビットが値“0”を示す場合はA大なりBと判定してA>B検出信号をアクティブにして出力し、2進数Aの(n−2)ビットが値“0”を示し、2進数Bの(n−2)ビットが値“1”を示す場合はA小なりBと判定してA<B検出信号をアクティブにして出力し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行する。
【0032】
2進数Aの(n−3)ビットが値“1”を示し、2進数Bの(n−3)ビットが値“0”を示す場合はA大なりBと判定してA>B検出信号をアクティブにして出力し、2進数Aの(n−3)ビットが値“0”を示し、2進数Bの(n−3)ビットが値“1”を示す場合はA小なりBと判定してA<B検出信号をアクティブにして出力し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行する。
【0033】
上記の大小関係検出をkビットまで順次行い、kビットでも大小関係を検出できない場合は大小関係未検出と判定してA>B検出信号とA<B検出信号とをともにパッシブにして出力する。
【0034】
また、大小検出手段の内部構成は2進数AとBが符号無し2進数であるとき、つぎのように構成されていることが好ましい。
【0035】
2つのnビットの2進数A,Bが符号無し2進数であるとき、2進数Aの最上位ビットである(n−1)ビットが値“1”を示し、2進数Bの最上位ビットである(n−1)ビットが値“0”を示す場合はA大なりBと判定してA>B検出信号をアクティブにして出力し、2進数Aの最上位ビットである(n−1)ビットが値“0”を示し、2進数Bの最上位ビットである(n−1)ビットが値“1”を示す場合はA小なりBと判定してA<B検出信号をアクティブにして出力し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行する。
【0036】
2進数Aの(n−2)ビットが値“1”を示し、2進数Bの(n−2)ビットが値“0”を示す場合はA大なりBと判定してA>B検出信号をアクティブにして出力し、2進数Aの(n−2)ビットが値“0”を示し、2進数Bの(n−2)ビットが値“1”を示す場合はA小なりBと判定してA<B検出信号をアクティブにして出力し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行する。
【0037】
2進数Aの(n−3)ビットが値“1”を示し、2進数Bの(n−3)ビットが値“0”を示す場合はA大なりBと判定してA>B検出信号をアクティブにして出力し、2進数Aの(n−3)ビットが値“0”を示し、2進数Bの(n−3)ビットが値“1”を示す場合はA小なりBと判定してA<B検出信号をアクティブにして出力し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行する。
【0038】
上記の大小関係検出をkビットまで順次行い、kビットでも大小関係を検出できない場合は大小関係未検出と判定してA>B検出信号とA<B検出信号とをともにパッシブにして出力する。
【0039】
さらに、2進数A,Bが2の補数表現される符号付き2進数であればパッシブになり、符号無し2進数であればアクティブになる制御信号により、2進数A,Bの最上位ビットであるビット(n−1)のデータを入れ替える手段を備えるように構成することが好ましい。
【0040】
このことにより、2の補数表現の2進数と符号無し2進数の両方に対応できる大小比較装置が得られる。
【0041】
またつぎのように構成しても同様の効果が得られる。2進数A,Bが2の補数表現される符号付き2進数であればパッシブになり、符号無し2進数であればアクティブになる制御信号により、2進数Aの(n−1)ビットが値“1”を示し、2進数Bの(n−1)ビットが値“0”を示す場合にアクティブとなる信号と、2進数Aの(n−1)ビットが値“0”を示し、2進数Bの(n−1)ビットが値“1”を示す場合にアクティブとなる信号とを入れ替えて出力する手段を備えるように構成する。
【0042】
また、判定手段は、大小検出手段の出力であるA<B検出信号がアクティブの時はアクティブになり、A>B検出信号がアクティブの時はパッシブになり、A<B検出信号とA>B検出信号がともにパッシブの時はキャリー検出手段の出力がパッシブであればアクティブになり、キャリー検出手段の出力がアクティブであればパッシブになる大小比較判定信号を出力するように構成されていることが好ましい。
【0043】
ここで、キャリー検出手段は、2進数Aと2進数Bがビット0からビット(k−1)までのビット範囲で各ビット毎に全く等しいデータであるために、最下位ビットの桁位置に加えた値“1”がキャリー伝播の伝播元となり発生するビット(k−1)の第1のキャリーと、第1のキャリーが発生する場合も含めて総ての発生するキャリーを含むビット(k−1)の第2のキャリーとを検出して出力するように構成されていることが好ましい。
【0044】
このとき、判定手段は、大小検出手段において大小関係が検出されたらその大小関係を出力し、大小関係が検出されない時は、キャリー検出手段の出力である第1のキャリーが検出されればAとBは等しいと判定してかつそのときアクティブになるA=B判定信号を出力し、第1のキャリーが検出されずかつ第2のキャリーが検出されればA大なりBと判定してかつそのときアクティブになるA>B判定信号を出力し、第1のキャリーと第2のキャリーがともに検出されなければA小なりBと判定してかつそのときアクティブとなるA<B判定信号を出力するように構成されていることが好ましい。
【0045】
このことにより、A大なりBとA小なりBとAとBは等しいという3つの状態を判定することができるようになる。
【0046】
同じ効果を得るため、キャリー検出手段は、2進数Aと2進数Bがビット0からビット(k−1)までのビット範囲で各ビット毎に全く等しいデータであるために、最下位ビットの桁位置に加えた値“1”がキャリー伝播の伝播元となり発生するビット(k−1)の第1のキャリーと、第1のキャリーが発生する場合以外で発生するキャリーを含むビット(k−1)の第2のキャリーとを検出して出力するように構成してもよい。
【0047】
このとき、判定手段は、大小関係検出において大小関係が検出されたらその大小関係を出力し、大小関係が検出されない時は、キャリー検出手段の出力である第1のキャリーが検出されればAとBは等しいと判定してかつそのときアクティブになるA=B判定信号を出力し、第2のキャリーが検出されればA大なりBと判定してかつそのときアクティブになるA>B判定信号を出力し、第1のキャリーと第2のキャリーがともに検出されなければA小なりBと判定してかつそのときアクティブとなるA<B判定信号を出力するように構成されていることが好ましい。
【0048】
【発明の実施の形態】
〔第1の実施の形態〕
以下、本発明の第1の実施の形態について、図面を参照しながら説明する。
【0049】
図1は本発明の第1の実施の形態における大小比較装置の構成を示すブロック図である。図1において、値A(0),A(1),…,A(7),B(0),B(1),…,B(7)は、比較する2つの8ビット幅の2進数A,Bのビット0〜7の値を示し、そのうちA(7),B(7)がそれぞれ最上位ビットの値を示す。
【0050】
キャリー検出手段10は、ビット0からビット3までの範囲で、2進数Aと2進数Bのビット反転とビット0における値“1”を加えた場合に生じるビット3のキャリーを検出する。大小検出手段20は、ビット4からビット7までの範囲で、2進数Aと2進数Bの大小関係を検出する。判定手段30は、キャリー検出手段10の出力と大小検出手段20の出力とから、2進数Aと2進数Bの大小関係を判定して出力する。
【0051】
なお、図中の制御信号CNTは、2進数A,Bが2の補数表現される数ならばパッシブであり、符号無し2進数ならばアクティブである制御信号である。
【0052】
以上のように構成された大小比較装置について、その動作を説明する。
【0053】
キャリー検出手段10は、ビット0からビット3までの範囲で、2進数Aと2進数Bのビット反転とビット0における値“1” を加えた場合に生じるビット3のキャリーを検出し、ビット3のキャリー信号C(3)として出力する。
【0054】
一方、大小検出手段20は、ビット4からビット7までの範囲で、2進数Aと2進数Bの大小比較を行い、A大なりBならばビット4のA>B検出信号BG(4)をアクティブにし、A小なりBならばビット4のA<B検出信号SL(4)をアクティブにし、A大なりBの状態とA小なりBの状態の両方とも検出できなければビット4のA>B検出信号BG(4)とビット4のA<B検出信号SL(4)の両方をパッシブにする。
【0055】
判定手段30は、ビット3のキャリー信号C(3)とビット4のA>B検出信号BG(4)とビット4のA<B検出信号SL(4)から、2進数Aと2進数Bの大小関係を判定して大小比較判定信号JGとして出力する。
【0056】
その際の判定手段30から出力される大小比較判定信号JGは、ビット4のA<B検出信号SL(4)がアクティブの時はアクティブになり、ビット4のA>B検出信号BG(4)がアクティブの時はパッシブになり、ビット4のA<B検出信号SL(4)とビット4のA>B検出信号BG(4)がともにパッシブの時はビット3のキャリー信号C(3)がパッシブであればアクティブになり、ビット3のキャリー信号C(3)がアクティブであればパッシブになる。
【0057】
以上のようにして出力される大小比較判定信号JGは、A大なりBあるいはAとBが等しければパッシブになり、A小なりBならばアクティブになり、2進数Aと2進数Bの大小関係を示す。
【0058】
このようにして、2進数Aと2進数Bの大小比較を行う際に、最下位ビットから上位の方向へはキャリー伝播を検出し、最上位ビットから下位の方向へは大小関係の情報を検出することにより、2種類の処理を並行して実行することができ、演算時間を大幅に削減することができ、しかも回路規模としては小さいものでよい。
【0059】
以下では、本実施の形態における構成要素の内部構成と動作の詳細について、さらに図2から図11までの各図を参照しながら説明する。
【0060】
図2は図1中のキャリー検出手段10の内部構成を示すブロック図である。このキャリー検出手段10は、8ビットのうちの下位4ビット分のキャリー検出を行うので、最下位ビット用の1個のキャリー検出要素100(0)とそれ以外の上位ビット用の3個のキャリー検出要素101(1),101(2),101(3)とで構成される。
【0061】
キャリー検出要素100(0)は、2進数A,Bのビット0の値A(0),B(0)が入力され、ビット0のキャリー信号C(0)を出力する。
【0062】
キャリー検出要素101(1)は、2進数A,Bのビット1の値A(1),B(1)とビット0のキャリー信号C(0)とが入力され、ビット1のキャリー信号C(1)を出力する。
【0063】
キャリー検出要素101(2)は、2進数A,Bのビット2の値A(2),B(2)とビット1のキャリー信号C(1)とが入力され、ビット2のキャリー信号C(2)を出力する。
【0064】
キャリー検出要素101(3)は、2進数A,Bのビット3の値A(3),B(3)とビット2のキャリー信号C(2)とが入力され、ビット3のキャリー信号C(3)を出力する。
【0065】
上記図2のキャリー検出手段10の構成で、遅延が最もクリティカルになるのは最下位ビットからキャリーが伝播してビット3のキャリー信号C(3)がアクティブになるときである。
【0066】
図3は図2中のキャリー検出要素100(0)の回路図である。このキャリー検出要素100(0)は、アンド回路1001とノット回路1002とで構成されている。
【0067】
このキャリー検出要素100(0)では、2進数Aのビット0の値A(0)が値“1”で、かつ2進数Bのビット0の値B(0)が値“0”ならば、ビット0のキャリー信号C(0)がアクティブになりキャリーが発生する。また、2進数Aのビット0の値A(0)が値“1”で、かつ2進数Bのビット0の値B(0)が値“1”がならば、ビット0のキャリー信号C(0)がアクティブになりキャリーが発生する。さらに、2進数Aのビット0の値A(0)が値“0”で、かつ2進数Bのビット0の値B(0)が値“0”がならば、ビット0のキャリー信号C(0)がアクティブになりキャリーが発生する。また、2進数Aのビット0の値A(0)が値“0”で、かつ2進数Bのビット0の値B(0)が値“1”がならば、ビット0のキャリー信号C(0)がパッシブになりキャリーが発生しない。
【0068】
この回路は、ビット0の桁位置に値“1”を加える場合を想定するので、後述の上位のビットのキャリー検出要素101(1),101(2),101(3)の回路に比べ簡略化されている。
【0069】
図4は図2中のキャリー検出要素101(i)(ただし、i=1,2,3)の回路図である。このキャリー検出要素101(i)は、アンド回路1011,1012,1013とオア回路1014とで構成されている。
【0070】
このキャリー検出要素101(i)では、2進数Aのビットiの値A(i)が値“1”で、かつ2進数Bのビットiの値B(i)が値“0”ならば、ビットiのキャリー信号C(i)がアクティブになりキャリーが発生する。また、2進数Aのビットiの値A(i)が値“0”で、かつ2進数Bのビットiの値B(i)が値“1”でない時に、下位ビットからのキャリー入力であるキャリー信号C(i−1)がアクティブであれば、キャリー信号C(i)がアクティブになりキャリーが発生する。それ以外では、キャリー信号C(i)はパッシブになりキャリーが発生しない。
【0071】
容易に想像が付くように、図2中のキャリー検出要素100(0)を図4に示したキャリー検出要素101(i)(ただし、i=0)に置き換えてキャリー入力に値“1”を入力するように構成しても構わない。
【0072】
図5は大小検出手段20の構成を示すブロック図である。この大小検出手段20は、8ビットのうちの上位4ビット分の大小検出を行うので、最上位ビット用の1個の大小検出要素200(7)とそれ以外の下位ビット用の3個の大小検出要素201(6),201(5),201(4)とで構成される。
【0073】
大小検出要素200(7)は、2進数A,Bのビット7の値A(7),B(7)が入力され、ビット7のA>B検出信号BG(7)およびA<B検出信号SL(7)を出力する。
【0074】
大小検出要素206(6)は、2進数A,Bのビット6の値A(6),B(6)とビット7のA>B検出信号BG(7)およびA<B検出信号SL(7)が入力され、ビット6のA>B検出信号BG(6)およびA<B検出信号SL(6)を出力する。
【0075】
大小検出要素206(5)は、2進数A,Bのビット5の値A(5),B(5)とビット6のA>B検出信号BG(6)およびA<B検出信号SL(6)が入力され、ビット5のA>B検出信号BG(5)およびA<B検出信号SL(5)を出力する。
【0076】
大小検出要素206(4)は、2進数A,Bのビット4の値A(4),B(4)とビット5のA>B検出信号BG(5)およびA<B検出信号SL(5)が入力され、ビット4のA>B検出信号BG(4)およびA<B検出信号SL(4)を出力する。
【0077】
上記図5の大小検出手段20の構成で、遅延が最もクリティカルになるのは最上位ビットから大小関係検出の情報が伝播し、ビット4から出力されるA>B検出信号BG(4)とA<B検出信号SL(4)が確定するまでであることが分かる。
【0078】
図6は2進数Aと2進数Bが2の補数表現される符号付き2進数である場合の図5中の大小検出要素200(7)の回路図である。この大小検出要素200(7)は、アンド回路2001,2002で構成されている。ここで、2進数Aと2進数Bは、符号付き2進数である場合、最上位ビットである符号ビットは正数の場合は値“0”をとり、負数の場合は値“1”をとる。
【0079】
この大小検出回路200(7)では、2進数Aのビット7の値A(7)が値“0”で、かつ2進数Bのビット7の値B(7)が値“1”ならば、A>B検出信号BG(7)がアクティブになり、さらに2進数Aのビット7の値A(7)が値“1”で、かつ2進数Bのビット7の値B(7)が値0ならば、A<B検出信号SL(7)がアクティブになり、それ以外ではA>B検出信号BG(7)とA<B検出信号SL(7)はともにパッシブになる。
【0080】
図7は図5中の大小検出要素201(i)(ただし、i=6,5,4)の回路図である。この大小検出要素201(i)は、アンド回路2011,2012,2013とオア回路2014,2015とで構成されている。
【0081】
この大小検出要素201(i)では、1ビット上位からのA<B検出信号SL(i+1)がアクティブならば、A<B検出信号SL(i)はアクティブになり、さらに1ビット上位からのA>B検出信号BG(i+1)がパッシブであり、かつ2進数Aのビットiの値A(i)が値“0”で、かつ2進数Bのビットiの値B(i)が値“1”ならば、A<B検出信号SL(i)はアクティブになる。また、1ビット上位からのA>B検出信号BG(i+1)がアクティブならば、A>B検出信号BG(i)はアクティブになり、さらに2進数Aのビットiの値A(i)が値“1”で、かつ2進数Bのビットiの値B(i)が値“0”ならば、A>B検出信号BG(i)はアクティブになる。
【0082】
以上のことから、A>B検出信号BG(i)はビットiより上位で既にA大なりBの状態が検出された場合にアクティブになり、A<B検出信号SL(i)はビットiより上位においてA小なりBの状態がA大なりBの状態検出よりも早く検出された場合(つまり、A大なりBが検出されたビットより上位のビットでA小なりBが検出された場合)にアクティブになる。
【0083】
図8は図2中の判定手段30の回路図である。この判定手段30は、アンド回路301とオア回路302とで構成されている。
【0084】
この判定手段30では、大小検出手段20の出力であるビット4のA<B検出信号SL(4)がアクティブならば、大小比較判定信号JGがアクティブになり、さらにビット4のA>B検出信号BG(4)がパッシブであり、かつキャリー検出手段10の出力であるビット3のキャリー信号C(3)がパッシブであれば、大小比較判定信号JGがアクティブになる。
【0085】
以上のことから、ビット4のA<B検出信号SL(4)がアクティブであれば、大小比較判定信号JGがアクティブになり、ビット4のA>B検出信号BG(4)がアクティブであれば、ビット4のA<B検出信号SL(4)は必ずパッシブになり、大小比較判定信号JGがパッシブになる。つまり、大小検出手段20において、2進数Aと2進数Bの大小関係が検出されれば、その結果が出力される。
【0086】
また、ビット4のA<B検出信号SL(4)とA>B検出信号BG(4)がともにパッシブの時は、ビット3のキャリー信号C(3)がアクティブであれば、大小比較判定信号JGがパッシブになり、ビット3のキャリー信号C(3)がパッシブであれば、大小比較判定信号JGがアクティブになる。つまり、大小検出手段20において2進数Aと2進数Bの大小関係が検出されなければ、キャリー検出手段10の出力であるビット3のキャリー信号C(3)で最終的に大小関係が決まる。
【0087】
図9は2進数Aと2進数Bが符号無し2進数である場合の図5中の大小検出要素200(7)の回路図である。この大小検出要素200(7)は、図6と同様に、アンド回路2001,2002で構成されている。図6との違いは、A>B検出信号BG(7)とA<B検出信号SL(7)を取り出す位置が入れ替わったことである。
【0088】
この大小検出回路200(7)では、2進数Aのビット7の値A(7)が値“1”で、かつ2進数Bのビット7の値B(7)が値“0”ならば、A>B検出信号BG(7)がアクティブになり、さらに2進数Aのビット7の値A(7)が値“0”で、かつ2進数Bのビット7の値B(7)が値“1”ならば、A<B検出信号SL(7)がアクティブになり、それ以外ではA>B検出信号BG(7)かつA<B検出信号SL(7)はパッシブになる。
【0089】
なお、2進数Aと2進数Bが符号無し2進数である場合の図5中の大小検出要素201(i)(ただし、i=6,5,4)については、図7と同じである。
【0090】
図6と図9から、2進数Aと2進数Bが2の補数表現される符号付き2進数である場合と2進数Aと2進数Bが符号無し2進数である場合とで、図5中の大小検出要素200(7)の回路は、ビット7のA>B検出信号BG(7)の生成回路と、ビット7のA<B検出信号SL(7)の生成回路が対称関係にあることが分かる。
【0091】
そこで、2進数Aの最上位ビットであるビット7の値A(7)と2進数Bの最上位ビットであるビット7の値B(7)とを入れ替える機能か、もしくはA>B検出信号BG(7)とA<B検出信号SL(7)とを入れ替える機能のいずれかを備えれば、2の補数表現される符号付き2進数と符号無し2進数との両方に同時に対応できる。
【0092】
図10は、2進数A,Bが2の補数表現される符号付き2進数であればパッシブになり、2進数A,Bが符号無し2進数であればアクティブになる制御信号CNTにより、2進数A,Bの最上位ビットであるビット7の値A(7),B(7)のデータを入れ替える手段を備えた大小検出手段21の構成を示すブロック図を示す。図10において、制御信号CNTによって切り替えが行われるマルチプレクサ202,203が2進数A,Bの最上位ビットであるビット7の値A(7),B(7)のデータを入れ替える手段を構成している。その他は図5と同じである。
【0093】
図11は、上記の制御信号CNTにより、A>B検出信号BG(7)とA<B検出信号SL(7)のを入れ替える手段を備えた大小関係検出手段22の構成を示すブロック図である。図11において、制御信号CNTによって切り替えが行われるマルチプレクサ204,205がA>B検出信号BG(7)とA<B検出信号SL(7)のを入れ替える手段を構成している。その他は図5と同じである。
【0094】
以上の図10または図11の構成を採用することにより、2の補数表現の2進数と符号無し2進数の両方に対応できる大小比較装置が得られる。
【0095】
以上のように、第1の実施の形態によれば、キャリー検出手段10と大小検出手段20,21または22と判定手段30とを備えることにより、2進数Aと2進数Bの大小比較を行う際に、最下位ビットから上位の方向へはキャリー伝播を検出し、最上位ビットから下位の方向へは大小関係の情報を検出することにより、並行して処理を実行することができ、演算時間を大幅に削減することができ、しかも回路規模は小さく抑えることができる。
【0096】
また、本実施の形態では、キャリー検出手段10と大小検出手段20,21または22は、1桁ずつ情報が伝播して行く構成で示したが、キャリールックアヘッド構成のように検出回路を並列化することにより、さらに高速化することも可能である。ただし、このときは並列化のために、多少回路規模が増加する。
【0097】
〔第2の実施の形態〕
以下本発明の第2の実施の形態について説明する。
【0098】
図12は本発明の第2の実施の形態における大小比較装置の構成を示すブロック図である。図12において、A(0),A(1),…,A(7),B(0),B(1),…,B(7)は、比較する2つの8ビット幅の2進数A,Bのビット0〜7の値を示し、そのうちA(7),B(7)がそれぞれ最上位ビットの値を示す。
【0099】
キャリー検出手段11は、ビット0からビット3までの範囲で、2進数Aと2進数Bのビット反転とビット0に値“1” を加えた場合に生じるビット3のキャリーを検出する。大小検出手段20は、ビット4からビット7までの範囲で、2進数Aと2進数Bの大小関係を検出する。判定手段31は、キャリー検出手段11の出力と大小検出手段20の出力とから、2進数Aと2進数Bの大小関係を判定して出力する。大小検出手段20は第1の実施の形態と同じ構成である。
【0100】
第2の実施の形態の構成は、第1の実施の形態において、キャリー検出手段11は2進数Aと2進数Bがビット0からビット3までの範囲で各ビット毎に全く等しいデータであるために、最下位ビットの桁位置に加える値“1”がキャリー伝播の伝播元となり発生するビット(k−1)の第1のキャリーC1(3)と、第1のキャリーC1(3)が発生する場合も含めて総ての発生するキャリーを含むビット(k−1)の第2のキャリーC2(3)とを検出して出力し、判定手段31はキャリー検出手段11の出力である第1のキャリーC1(3)と第2のキャリーC2(3)と大小検出手段20の出力であるA>B検出信号BG(4)とA<B検出信号SL(4)から2進数Aと2進数Bの大小関係を判定し、大小検出手段20において大小関係が検出されたらその大小関係を出力し、大小関係が検出されない時は、キャリー検出手段11の出力である第1のキャリーC1(3)が検出されればAとBは等しいと判定してかつそのときアクティブになるA=B判定信号JGABを出力し、第1のキャリーC1(3)が検出されずかつ第2のキャリーC2(3)が検出されればA大なりBと判定してかつそのときアクティブになるA>B判定信号JGAを出力し、第1のキャリーC1(3)と第2のキャリーC2(3)がともに検出されなければA小なりBと判定してかつそのときアクティブとなるA<B判定信号JGBを出力するように構成される。
【0101】
図13は図12中のキャリー検出手段11の内部構成を示すブロック図である。このキャリー検出手段11は、8ビットのうちの下位4ビット分のキャリー検出を行うので、最下位ビット用の1個のキャリー検出要素102(0)とそれ以外の上位ビット用の3個のキャリー検出要素103(1),103(2),103(3)とで構成される。
【0102】
キャリー検出要素102(0)は、2進数A,Bのビット0の値A(0),B(0)が入力され、ビット0の第1および第2のキャリー信号C1(0),C2(0)を出力する。
【0103】
キャリー検出要素103(1)は、2進数A,Bのビット1の値A(1),B(1)とビット0の第1および第2のキャリー信号C1(0),C2(0)とが入力され、ビット1の第1および第2のキャリー信号C1(1),C2(1)を出力する。
【0104】
キャリー検出要素103(2)は、2進数A,Bのビット2の値A(2),B(2)とビット1の第1および第2のキャリー信号C1(1),C2(1)とが入力され、ビット2の第1および第2のキャリー信号C1(2),C2(2)を出力する。
【0105】
キャリー検出要素103(3)は、2進数A,Bのビット3の値A(3),B(3)とビット2の第1および第2のキャリー信号C1(2),C2(2)とが入力され、ビット3の第1および第2のキャリー信号C1(3),C2(3)を出力する。
【0106】
図14は図13中のキャリー検出要素102(0)の回路図である。このキャリー検出要素102(0)は、第1の実施の形態におけるキャリー検出手段10のキャリー検出要素100(0)の回路に加え、2進数Aのビット0の値A(0)と2進数Bのビット0の値B(0)とが全く同じ値であることを検出する回路が付加された構成になっている。具体的には、AND回路1021,1022,1023とノット回路1024とで構成されている。
【0107】
このキャリー検出要素102(0)では、2進数Aのビット0の値A(0)と2進数Bのビット0の値B(0)とが全く同じ値であるときに第1のキャリー信号C1(0)がアクティブになる。また、第2のキャリー信号C2(0)については、図3のキャリー信号C(0)と同じである。
【0108】
図15は図13中のキャリー検出要素103(i)(ただし、i=1,2,3)の回路図である。このキャリー検出要素103(i)は、第1の実施の形態におけるキャリー検出手段10のキャリー検出要素101(i)の回路に加え、2進数Aのビットiの値A(i)と2進数Bのビットiの値B(i)とが全く同じ値であり、かつ1ビット下位までの2進数Aと2進数Bのデータが一致していることを検出する回路が付加された構成になっている。具体的には、アンド回路1031,1032,1033,1034とオア回路1035とで構成されている。
【0109】
このキャリー検出要素103(i)では、2進数Aのビットiの値A(i)と2進数Bのビットiの値B(i)とが全く同じ値であり、かつ1ビット下位までの2進数Aと2進数Bのデータが一致しているときに第1のキャリー信号C1(i)がアクティブになる。また、第2のキャリー信号C2(i)については、図4のキャリー信号C(i)と同じである。
【0110】
図16は図12中の判定手段31の回路図である。この判定手段31は、第1の実施の形態における判定手段30の回路に加え、以下の処理を行う回路を付加している。すなわち、A小なりBでない場合において、キャリー検出手段11の出力である第1のキャリーC1(3)と第2のキャリーC2(3)との組合せからA大なりBのときにアクティブになるA>B判定信号JGAと、AとBが等しいときにアクティブになるA=B判定信号JGABを生成し出力する回路を付加している。図中のA<B判定信号JGBは判定手段30の出力である大小比較判定信号JGと同じでA小なりBのときにアクティブになる信号である。具体的には、アンド回路311,312,313とオア回路314とで構成されている。
【0111】
以上のように構成された大小比較装置について、その動作を説明する。
【0112】
キャリー検出手段11でビット0からビット3までの範囲で2進数Aと2進数Bが各ビット毎に全く等しいデータであるために、最下位ビットの桁位置に加えた値“1”がキャリー伝播の伝播元となり発生するビット3の第1のキャリーを検出して出力することにより、判定手段31でA大なりBの状態とAとBは等しい状態は判別することが可能になる。
【0113】
第2の実施の形態を用いることにより、本発明の演算装置は2つの2進数A,Bの大小比較を行う際に、A大なりBの状態とA小なりBの状態とAとBは等しい状態の3つの状態を判定できる。
【0114】
また本実施の形態ではそれぞれ3つの状態でアクティブになる3つの信号を出力しているが、3つの状態を2つの信号の組合せで表現してもよく、容易に実現できる。
【0115】
〔第3の実施の形態〕
以下本発明の第3の実施の形態について説明する。
【0116】
図17は本発明の第3の実施の形態における大小比較装置の構成を示すブロック図である。図17において、A(0),A(1),…,A(7),B(0),B(1),…,B(7)は、比較する2つの8ビット幅の2進数A,Bのビット0〜7の値を示し、そのうちA(7),B(7)がそれぞれ最上位ビットの値を示す。
【0117】
キャリー検出手段12は、ビット0からビット3までの範囲で、2進数Aと2進数Bのビット反転とビット0に値“1” を加えた場合に生じるビット3のキャリーを検出する。大小検出手段20は、ビット4からビット7までの範囲で、2進数Aと2進数Bの大小関係を検出する。判定手段32は、キャリー検出手段12の出力と大小検出手段20の出力とから、2進数Aと2進数Bの大小関係を判定して出力する。大小検出手段20は第1の実施の形態と同じ構成である。
【0118】
第3の実施の形態の構成は、第1の実施の形態において、キャリー検出手段12は2進数Aと2進数Bがビット0からビット3までの範囲で各ビット毎に全く等しいデータであるために、最下位ビットの桁位置に加える値“1”がキャリー伝播の伝播元となり発生するビット(k−1)の第1のキャリーC1(3)と、第1のキャリーC1(3)が発生する場合以外で発生するキャリーを含むビット(k−1)の第2のキャリーC3(3)とを検出して出力し、判定手段32はキャリー検出手段12の出力である第1のキャリーC1(3)と第2のキャリーC3(3)と大小検出手段20の出力であるA>B検出信号BG(4)とA<B検出信号SL(4)から2進数Aと2進数Bの大小関係を判定し、大小検出手段20において大小関係が検出されたらその大小関係を出力し、大小関係が検出されない時は、キャリー検出手段12の出力である第1のキャリーC1(3)が検出されればAとBは等しいと判定してかつそのときアクティブになるA=B判定信号JGABを出力し、第2のキャリーC3(3)が検出されればA大なりBと判定してかつそのときアクティブになるA>B判定信号JGAを出力し、第1のキャリーC1(3)と第2のキャリーC3(3)がともに検出されなければA小なりBと判定してかつそのときアクティブとなるA<B判定信号JGBを出力するように構成される。
【0119】
図18は図17中のキャリー検出手段12の内部構成を示すブロック図である。このキャリー検出手段12は、8ビットのうちの下位4ビット分のキャリー検出を行うので、最下位ビット用の1個のキャリー検出要素104(0)とそれ以外の上位ビット用の3個のキャリー検出要素105(1),105(2),105(3)とで構成される。
【0120】
キャリー検出要素104(0)は、2進数A,Bのビット0の値A(0),B(0)が入力され、ビット0の第1および第2のキャリー信号C1(0),C3(0)を出力する。
【0121】
キャリー検出要素105(1)は、2進数A,Bのビット1の値A(1),B(1)とビット0の第1および第2のキャリー信号C1(0),C3(0)とが入力され、ビット1の第1および第2のキャリー信号C1(1),C3(1)を出力する。
【0122】
キャリー検出要素105(2)は、2進数A,Bのビット2の値A(2),B(2)とビット1の第1および第2のキャリー信号C1(1),C3(1)とが入力され、ビット2の第1および第2のキャリー信号C1(2),C3(2)を出力する。
【0123】
キャリー検出要素105(3)は、2進数A,Bのビット3の値A(3),B(3)とビット2の第1および第2のキャリー信号C1(2),C3(2)とが入力され、ビット3の第1および第2のキャリー信号C1(3),C3(3)を出力する。
【0124】
図19は図18中のキャリー検出要素104(0)の回路図である。このキャリー検出要素104(0)は、図14のキャリー検出要素102(0)とは異なり、第2のキャリー信号C3(0)は2進数Aのビット0の値A(0)と2進数Bのビット0の値B(0)とが同じ値である場合を含まない。つまり、図14の回路における第2のキャリー信号C2(0)は、2進数Aのビット0の値A(0)と2進数Bのビット0の値B(0)とが同じ値である場合にもアクティブとなったが、図19における第2のキャリー信号C3(0)は2進数Aのビット0の値A(0)と2進数Bのビット0の値B(0)とが同じ値である場合にはアクティブとはならない。したがって、第1のキャリー信号C1(0)と第2のキャリー信号C3(0)とは同時にアクティブになることはなくなっている。その他は図14と同様である。具体的には、AND回路1041,1042,1043で構成されている。
【0125】
図18中のキャリー検出要素105(i)(ただし、i=1,2,3)は、図図13中のキャリー検出要素103(i)と同様であり、その具体構成は図15に示したものと同様であるので、図示を省略する。
【0126】
図20は図17中の判定手段32の回路図である。この判定手段32は、第2の実施の形態における判定手段31の回路における第2のキャリー信号C2(3)が第3のキャリー信号C3(3)に変更されたこと、つまり第1のキャリー信号C1(0)と第2のキャリー信号C3(0)が同時にアクティブになることがなくなったことに起因して、回路構成が変更されている。具体的には、アンド回路321,322,323とオア回路324とで構成されている。
【0127】
以上のように構成された大小比較装置について、その動作を説明する。
【0128】
キャリー検出手段12でビット0からビット3までの範囲で2進数Aと2進数Bが各ビット毎に全く等しいデータであるために、最下位ビットの桁位置に加えた値“1”がキャリー伝播の伝播元となり発生するビット3の第1のキャリーを検出して出力することにより、判定手段32でA大なりBの状態とAとBは等しい状態は判別することが可能になる。
【0129】
第2の実施の形態を用いることにより、本発明の演算装置は2つの2進数A,Bの大小比較を行う際に、A大なりBの状態とA小なりBの状態とAとBは等しい状態の3つの状態を判定できる。
【0130】
また本実施の形態ではそれぞれ3つの状態でアクティブになる3つの信号を出力しているが、3つの状態を2つの信号の組合せで表現してもよく、容易に実現できる。
【0131】
なお、上記各実施の形態では、一例として8ビット2進数A,Bの比較を行うものを示したが、2進数A,Bのビット数は16ビット、32ビット,62ビット等任意のビット数の2進数に対して本発明を適用できるのはいうまでもない。
【0132】
また、上記2進数A,Bの上位ビットと下位ビットの区分けは、大小比較とキャリー伝搬の各々の処理時間を考慮して、両方の処理時間がほぼ等しくなるように決定するのが好ましく、ちょうど真ん中で行う必要はない。また、特に両方の処理時間が等しくなるように決定する必要はない。つまり、両方の処理時間が等しくなるように、上位ビットと下位ビットの区分けを設定しなくても、上記の大小比較とキャリー伝搬を同時に並列に実行することで、大小比較とキャリー伝搬の何れか片方のみを行う場合に比べて処理時間の短縮を図ることができる。
【0133】
また、上記の各実施の形態では、信号の状態を示すのに、アクティブとパッシブという表現を用いているが、ハイまたはロウの信号レベルの何れか一方をアクティブとし、他方をパッシブとしている。
【0134】
【発明の効果】
以上説明したように、本発明の大小比較方法および大小比較装置によれば、2進数Aと2進数Bの大小比較を行う際に、最下位ビットから上位方向へのキャリー伝播を検出する処理と、最上位ビットから下位方向への大小関係の検出処理を並列処理することにより、小さい回路規模で演算時間を大幅に削減した大小比較行うことができる。また、キャリー伝播を検出するビット範囲で2進数Aと2進数Bが各ビットで全く同じであることにより発生するキャリー伝播を個別に検出することにより、A大なりBの状態とA小なりBの状態とAとBは等しい状態の3つの状態を判定することが可能となる。
【図面の簡単な説明】
【図1】本発明の第1の実施の形態に係わる大小比較装置の構成を示すブロック図である。
【図2】キャリー検出手段10の構成を示すブロック図である。
【図3】キャリー検出手段10におけるキャリー検出要素100(0)の回路構成を示す回路図である。
【図4】キャリー検出手段10におけるキャリー検出要素101(i)の回路構成を示す回路図である。
【図5】大小検出手段20の構成を示すブロック図である。
【図6】比較データが2の補数表現される符号付き2進数データである場合に、大小検出手段20における大小検出要素200(7)の回路構成を示す回路図である。
【図7】大小検出手段20における大小検出要素201(i)の回路構成を示す回路図である。
【図8】判定手段30の構成を示す回路図である。
【図9】比較データが符号無し2進数データである場合に、大小検出手段20における大小検出要素200(7)の回路構成を示す回路図である。
【図10】制御信号により比較するデータの数体系を切り替え可能な、大小検出手段21の構成を示すブロック図である。
【図11】制御信号により比較するデータの数体系を切り替え可能な、大小検出手段22の構成を示すブロック図である。
【図12】本発明の第2の実施の形態に係わる大小比較装置の構成を示すブロック図である。
【図13】キャリー検出手段11の構成を示すブロック図である。
【図14】キャリー検出手段11におけるキャリー検出要素102(0)の回路構成を示す回路図である。
【図15】キャリー検出手段11におけるキャリー検出要素103(i)の回路構成を示す回路図である。
【図16】判定手段31の構成を示す回路図である。
【図17】本発明の第3の実施の形態に係わる大小比較装置の構成を示すブロック図である。
【図18】キャリー検出手段12の構成を示すブロック図である。
【図19】キャリー検出手段12におけるキャリー検出要素104(0)の回路構成を示す回路図である。
【図20】判定手段32の回路構成を示す回路図である。
【符号の説明】
10 キャリー検出手段
11 キャリー検出手段
12 キャリー検出手段
20 大小検出手段
21 大小検出手段
22 大小検出手段
30 判定手段
31 判定手段
32 判定手段
100(0) キャリー検出要素
101(1) キャリー検出要素
101(2) キャリー検出要素
101(3) キャリー検出要素
101(i) キャリー検出要素
102(0) キャリー検出要素
103(1) キャリー検出要素
103(2) キャリー検出要素
103(3) キャリー検出要素
103(i) キャリー検出要素
200(7) 大小検出要素
201(6) 大小検出要素
201(5) 大小検出要素
201(4) 大小検出要素
201(i) 大小検出要素
202 マルチプレクサ
203 マルチプレクサ
204 マルチプレクサ
205 マルチプレクサ
BG(7) A>B検出信号
BG(6) A>B検出信号
BG(5) A>B検出信号
BG(4) A>B検出信号
SL(3) A<B検出信号
SL(2) A<B検出信号
SL(1) A<B検出信号
SL(0) A<B検出信号
CNT 制御信号
JG 大小比較判定信号
JGA A>B判定信号
JGB A<B判定信号
JGAB A=B判定信号
[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a method and apparatus for comparing two binary numbers.
[0002]
[Prior art]
As a conventional magnitude comparison method, there is a method of judging magnitude relation between the two binary numbers A and B by detecting carry propagation when subtraction (AB) of the two binary numbers A and B to be compared is performed. is there. This method is disclosed, for example, in JP-A-6-250821. In the conventional example described in JP-A-6-250821, when a carry of the most significant bit is detected by carry propagation, it is determined that A is greater than B.
[0003]
There is also a method of detecting the magnitude relation of each bit of two binary numbers to be compared, and judging the magnitude relation of the two binary numbers based on the detection result. This method is disclosed in, for example, Japanese Patent Application Laid-Open No. 10-154066. In the conventional example described in Japanese Patent Application Laid-Open No. H10-154066, comparison of the most significant bit is performed, and if no magnitude relation is detected, comparison is performed with one lower bit. To the least significant bit to determine the magnitude relationship between the two binary numbers.
[0004]
[Problems to be solved by the invention]
However, in the conventional example described in JP-A-6-250821, as the bit width of the data to be detected increases, the delay required for carry propagation from the least significant bit to the most significant bit increases, and the delay is reduced. However, there is a problem that the circuit scale is increased if the parallelization of the circuit is advanced in order to achieve this.
[0005]
On the other hand, the same can be said for the conventional example described in Japanese Patent Application Laid-Open No. H10-154066. The larger the bit width of the data to be detected, the longer the delay required for information propagation from the most significant bit to the least significant bit. However, if the parallelization of the circuit is advanced in order to reduce the delay, there is a problem that the circuit scale becomes large.
[0006]
SUMMARY OF THE INVENTION An object of the present invention is to solve the above problems and to provide a size comparison method and a size comparison device having a small circuit scale and a short operation time.
[0007]
[Means for Solving the Problems]
The magnitude comparison method and apparatus according to the present invention, when performing magnitude comparison between two binary numbers A and B, perform magnitude comparison of bits sequentially from the most significant bit in the lower direction, and from the least significant bit to the upper direction. The carry propagation is detected when the binary number B is subtracted from the binary number A, and the magnitude relationship between the binary numbers A and B is determined from the magnitude comparison result and the carry propagation result, thereby reducing the circuit scale. And shorten the calculation time.
[0008]
More specifically, the magnitude comparison method of the present invention performs a magnitude comparison of two n-bit (n is a positive integer) binary numbers A and B from bit 0 (least significant bit) to bit (k− 1) Detects carry propagation when binary number B is subtracted from binary number A in a bit range up to (k is a positive integer, 0 <k <n). , Bit inversion of binary B and , The carry of the bit (k-1) generated when the value "1" at the digit position of the least significant bit is added is detected, and the carry from the bit k to the bit (n-1) (the most significant bit) is detected. The magnitude relationship between the binary A and the binary B is detected in the direction from the most significant bit to the lower bit, and the magnitude relationship between the binary A and the binary B is determined based on the magnitude relationship detection result and the carry detection result. It is characterized by outputting.
[0009]
As a result, the carry propagation detection from the least significant bit and the magnitude relationship detection sequentially from the most significant bit can be executed simultaneously in parallel, and the operation time can be greatly reduced, and the increase in the circuit scale is small. Can be suppressed. The upper bits and lower bits of the binary numbers A and B are preferably determined so that both processing times are substantially equal in consideration of the processing times of the magnitude comparison and the carry propagation. There is no need to do it in the middle. In addition, it is not necessary to determine that both processing times are substantially equal. Regardless of how the upper and lower bits are set, the above-described magnitude comparison and carry propagation are performed simultaneously and in parallel, so that the processing time is shorter than when only one of the magnitude comparison and carry propagation is performed. Can be shortened.
[0010]
The magnitude detection is preferably performed as follows when the binary numbers A and B are signed binary numbers represented by two's complement.
[0011]
When the (n-1) bit, which is the most significant bit of the binary number A, indicates a positive sign and the (n-1) bit, which is the most significant bit of the binary number B, indicates a negative sign, A is greater than B. It is determined that if the (n-1) bit that is the most significant bit of the binary number A indicates a negative sign and the (n-1) bit that is the most significant bit of the binary number B indicates a positive sign, the small A In other combinations, it is determined that the magnitude relationship has not been detected, and the processing shifts to magnitude relationship detection using 1-bit lower data.
[0012]
When the (n−2) bit of the binary number A indicates the value “1” and the (n−2) bit of the binary number B indicates the value “0”, it is determined that A is greater than B, and When the (n−2) bit indicates the value “0” and the (n−2) bit of the binary number B indicates the value “1”, it is determined that A is smaller than B, and in other combinations, the magnitude relation is not detected. The processing shifts to the detection of the magnitude relationship with the lower data of one bit.
[0013]
When the (n−3) bit of the binary number A indicates the value “1” and the (n−3) bit of the binary number B indicates the value “0”, it is determined that A is greater than B, and ( When the (n−3) bit indicates the value “0” and the (n−3) bit of the binary number B indicates the value “1”, it is determined that A is smaller than B, and in other combinations, the magnitude relation is not detected. The processing shifts to the detection of the magnitude relationship with the lower data of one bit.
[0014]
The above-described magnitude relation detection is sequentially performed up to k bits. If the magnitude relation cannot be detected even with k bits, it is determined that the magnitude relation has not been detected.
[0015]
The magnitude detection is preferably performed as follows when the binary numbers A and B are unsigned binary numbers.
[0016]
If the (n-1) bit, which is the most significant bit of the binary number A, indicates the value "1" and the (n-1) bit, which is the most significant bit of the binary number B, indicates the value "0", A is greater. B, the (n-1) -bit, which is the most significant bit of the binary number A, indicates the value "0", and the (n-1) -bit, which is the most significant bit of the binary number B, indicates the value "1". In this case, it is determined that A is smaller than B, and in other combinations, the magnitude relation is not detected, and the processing shifts to the magnitude relation detection using 1-bit lower data.
[0017]
When the (n−2) bit of the binary number A indicates the value “1” and the (n−2) bit of the binary number B indicates the value “0”, it is determined that A is greater than B, and When the (n−2) bit indicates the value “0” and the (n−2) bit of the binary number B indicates the value “1”, it is determined that A is smaller than B, and in other combinations, the magnitude relation is not detected. The processing shifts to the detection of the magnitude relationship with the lower data of one bit.
[0018]
When the (n−3) bit of the binary number A indicates the value “1” and the (n−3) bit of the binary number B indicates the value “0”, it is determined that A is greater than B, and ( When the (n−3) bit indicates the value “0” and the (n−3) bit of the binary number B indicates the value “1”, it is determined that A is smaller than B, and in other combinations, the magnitude relation is not detected. The processing shifts to the detection of the magnitude relationship with the lower data of one bit.
[0019]
The above-described magnitude relation detection is sequentially performed up to k bits. If the magnitude relation cannot be detected even with k bits, it is determined that the magnitude relation has not been detected.
[0020]
When detecting the magnitude relation between the binary numbers A and B in the bit range from the bit k to the bit (n-1), if the binary numbers A and B are signed binary numbers that are expressed in two's complement. If the control signal becomes passive and becomes an unsigned binary number and becomes active, and if the control signal is a passive signal, the binary numbers A and B are detected as a two's complement expression and the magnitude relation is detected and output. If there is, it is preferable to detect and output the magnitude relation as binary numbers A and B as unsigned binary numbers.
[0021]
Further, when determining the magnitude relation between the binary numbers A and B, if a magnitude relation in a bit range from bit k to bit (n-1) is detected, the magnitude relation is output, and the magnitude relation must be detected. For example, based on the carry detection result, it is preferable that if a carry is detected, it is determined that A is greater than B or that A and B are equal, and if no carry is detected, it is determined that A is less than B.
[0022]
In the bit range from bit 0 to bit (k-1), binary A , Bit inversion of binary B and , When detecting the carry of the bit (k-1) generated when adding the value "1" at the digit position of the least significant bit, the binary numbers A and B are converted from the bit 0 to the bit (k-1). Since the data is completely equal for each bit in the bit range up to, the value “1” added to the digit position of the least significant bit becomes the propagation source of carry propagation and the first carry of the generated bit (k−1) And the second carry of bit (k-1) including all of the occurring carry, including the case where the first carry occurs, is detected in the bit range from bit k to bit (n-1). If the magnitude relationship is detected in the magnitude relationship detection of the above, the magnitude relationship is output. If the magnitude relationship is not detected, A is determined to be equal to B if the first carry is detected based on the carry detection result. 1 carry not detected One if the second carry is detected determines that A greater than B, it is preferable to first carry and the second carry is determined that A small becomes B is not detected together.
[0023]
As a result, it is possible to determine three states that A is greater than B, A is less than B, and A and B are equal.
[0024]
To achieve the same effect, the binary number A and the bit range from bit 0 to bit (k-1) , Bit inversion of binary B and , When detecting the carry of the bit (k-1) generated when adding the value "1" at the digit position of the least significant bit, the binary numbers A and B are converted from the bit 0 to the bit (k-1). Since the data is completely equal for each bit in the bit range up to, the value “1” added to the digit position of the least significant bit becomes the propagation source of carry propagation and the first carry of the generated bit (k−1) And the second carry of the bit (k-1) including the carry occurring except when the first carry occurs is detected, and the magnitude in the bit range from the bit k to the bit (n-1) is detected. If a magnitude relationship is detected in the relationship detection, the magnitude relationship is output. If the magnitude relationship is not detected, A is determined to be equal to B if the first carry is detected based on the carry detection result. The second carry is detected If it is determine that A greater than B output, it may be the first carry and the second carry outputs is determined that both to be detected A small becomes B.
[0025]
When comparing the magnitudes of two n-bit binary numbers A and B, the magnitude comparison apparatus of the present invention performs the bit range from bit 0 (least significant bit) to bit (k-1) from binary number A to bit (k-1). Carry propagation when binary B is subtracted is detected, that is, binary A and binary , Bit inversion of binary B and , Carry detection means for detecting and outputting the carry of bit (k-1) generated when the value "1" at the least significant bit digit position is added, and in a downward direction within a range of K bits from the most significant bit It is characterized by comprising a magnitude detecting means for sequentially comparing the magnitude of bits, and a judging means for judging the magnitude relation between the binary numbers A and B from the output of the magnitude detecting means and the output of the carry detecting means.
[0026]
As a result, carry propagation detection from the least significant bit and magnitude relation detection sequentially from the most significant bit can be performed simultaneously in parallel, so that the operation time can be significantly reduced and the increase in circuit size is kept small. be able to. The upper bits and lower bits of the binary numbers A and B are preferably determined so that both processing times are substantially equal in consideration of the processing times of the magnitude comparison and the carry propagation. There is no need to do it in the middle. In addition, it is not necessary to determine that both processing times are substantially equal. No matter how the upper and lower bits are set, the above-described magnitude comparison and carry propagation are performed simultaneously in parallel, so that the processing time is shorter than when only one of the magnitude comparison and carry propagation is performed. Can be shortened.
[0027]
The magnitude detection means detects the magnitude relation between the binary numbers A and B in the bit range from bit k to bit (n-1) (most significant bit), and activates in the case of A greater than B A> B detection signal and an A <B detection signal that becomes active in the case of A less than B are output. If the magnitude relationship between the binary numbers A and B cannot be detected, the A> B detection signal and A <It is preferable that both the B detection signals are passive.
[0028]
The determining means determines the magnitude relationship between the binary number A and the binary number B from the output of the magnitude detecting means and the output of the carry detecting means, and becomes passive when A is greater than B or when A and B are equal to each other. It is preferable to be configured to output a magnitude comparison determination signal that becomes active in the case of less than B.
[0029]
When the binary numbers A and B are signed binary numbers represented by two's complement, the internal configuration of the magnitude detecting means is preferably configured as follows.
[0030]
When two n-bit binary numbers A and B are signed binary numbers represented by two's complement, (n-1) bits which are the most significant bits of the binary number A indicate a positive sign and the binary number B If the (n-1) bit, which is the most significant bit of, indicates a negative sign, it is determined that A is greater than B, the A> B detection signal is activated and output, and the most significant bit of the binary number A ( When the (n-1) bit indicates a negative sign and the (n-1) bit, which is the most significant bit of the binary number B, indicates a positive sign, it is determined that A is less than B and the A <B detection signal is activated. In the other combinations, the magnitude relation is not detected, and the processing shifts to the magnitude relation detection using 1-bit lower data.
[0031]
When the (n−2) bit of the binary number A indicates the value “1” and the (n−2) bit of the binary number B indicates the value “0”, it is determined that A is greater than B and A> B detection signal Is activated, and when the (n−2) bit of the binary number A indicates the value “0” and the (n−2) bit of the binary number B indicates the value “1”, it is determined that A is smaller than B. Then, the A <B detection signal is activated and output, and in other combinations, the magnitude relation is not detected, and the processing shifts to the magnitude relation detection using 1-bit lower data.
[0032]
When the (n-3) bit of the binary number A indicates the value "1" and the (n-3) bit of the binary number B indicates the value "0", it is determined that A is greater than B and the A> B detection signal Is activated and output. If the (n-3) bit of the binary number A indicates the value "0" and the (n-3) bit of the binary number B indicates the value "1", it is determined that A is smaller than B. Then, the A <B detection signal is activated and output, and in other combinations, the magnitude relation is not detected, and the processing shifts to the magnitude relation detection using 1-bit lower data.
[0033]
The magnitude relation detection is sequentially performed up to k bits. If the magnitude relation cannot be detected even with k bits, it is determined that the magnitude relation has not been detected, and the A> B detection signal and the A <B detection signal are both output passively.
[0034]
When the binary numbers A and B are unsigned binary numbers, the internal configuration of the magnitude detecting means is preferably configured as follows.
[0035]
When the two n-bit binary numbers A and B are unsigned binary numbers, the (n-1) bit which is the most significant bit of the binary number A indicates a value "1" and the most significant bit of the binary number B is If a certain (n-1) bit indicates the value "0", it is determined that A is greater than B, and an A> B detection signal is activated and output, and is the most significant bit of the binary number A (n-1). If the bit indicates the value “0” and the (n−1) bit, which is the most significant bit of the binary number B, indicates the value “1”, it is determined that A is less than B and the A <B detection signal is activated. In other combinations, the magnitude relation is not detected, and the processing shifts to the magnitude relation detection using 1-bit lower data.
[0036]
When the (n−2) bit of the binary number A indicates the value “1” and the (n−2) bit of the binary number B indicates the value “0”, it is determined that A is greater than B and A> B detection signal Is activated, and when the (n−2) bit of the binary number A indicates the value “0” and the (n−2) bit of the binary number B indicates the value “1”, it is determined that A is smaller than B. Then, the A <B detection signal is activated and output, and in other combinations, the magnitude relation is not detected, and the processing shifts to the magnitude relation detection using 1-bit lower data.
[0037]
When the (n-3) bit of the binary number A indicates the value "1" and the (n-3) bit of the binary number B indicates the value "0", it is determined that A is greater than B and the A> B detection signal Is activated and output. If the (n-3) bit of the binary number A indicates the value "0" and the (n-3) bit of the binary number B indicates the value "1", it is determined that A is smaller than B. Then, the A <B detection signal is activated and output, and in other combinations, the magnitude relation is not detected, and the processing shifts to the magnitude relation detection using 1-bit lower data.
[0038]
The magnitude relation detection is sequentially performed up to k bits. If the magnitude relation cannot be detected even with k bits, it is determined that the magnitude relation has not been detected, and the A> B detection signal and the A <B detection signal are both output passively.
[0039]
Further, if the binary numbers A and B are signed binary numbers represented by two's complement, they are passive, and if they are unsigned binary numbers, they are the most significant bits of the binary numbers A and B by a control signal that becomes active. It is preferable to provide a means for replacing the data of the bit (n-1).
[0040]
As a result, it is possible to obtain a magnitude comparison device that can handle both binary numbers in two's complement representation and unsigned binary numbers.
[0041]
The same effect can be obtained by the following configuration. If the binary numbers A and B are signed binary numbers represented by two's complement, they become passive, and if they are unsigned binary numbers, the control signal which becomes active causes the (n-1) bits of the binary number A to have the value " 1), the signal which becomes active when the (n-1) bit of the binary number B indicates the value "0", and the (n-1) bit of the binary number A indicates the value "0". When the (n-1) bit of B indicates the value "1", a signal which becomes active and replaces and outputs a signal is provided.
[0042]
The determination means becomes active when the A <B detection signal output from the magnitude detection means is active, becomes passive when the A> B detection signal is active, and outputs A <B detection signal and A> B. When both the detection signals are passive, the output of the carry detection means is passive when the output is passive, and when the output of the carry detection means is active, the output is a passive comparison signal. preferable.
[0043]
Here, the carry detecting means adds the digit position of the least significant bit to the digit position of the least significant bit because the binary number A and the binary number B are exactly the same data for each bit in the bit range from bit 0 to bit (k-1). The value “1” is the first carry of the bit (k−1) generated as the propagation source of the carry propagation, and the bit (k−k) including all the generated carry including the case where the first carry occurs. It is preferable to detect and output the second carry of 1).
[0044]
At this time, the determination means outputs the magnitude relation when the magnitude relation is detected by the magnitude detection means. When the magnitude relation is not detected, the determination means outputs A if the first carry which is the output of the carry detection means is detected. B outputs an A = B determination signal which is determined to be equal and becomes active at that time, and if the first carry is not detected and the second carry is detected, it is determined that A is greater than B and When the first carry and the second carry are not detected, it is determined that A is smaller than B, and an A <B determination signal that becomes active at that time is output. It is preferable that it is comprised as follows.
[0045]
As a result, it is possible to determine three states that A is greater than B, A is less than B, and A and B are equal.
[0046]
In order to obtain the same effect, the carry detection means uses the least significant bit because the binary number A and the binary number B are exactly the same data for each bit in the bit range from bit 0 to bit (k-1). The value “1” added to the position is the first carry of the bit (k−1) generated as the propagation source of the carry propagation, and the bit (k−1) including the carry generated except when the first carry occurs. ) May be configured to detect and output the second carry.
[0047]
At this time, when the magnitude relation is detected in the magnitude relation detection, the determination means outputs the magnitude relation. When the magnitude relation is not detected, if the first carry which is the output of the carry detection means is detected, A is determined. A = B determination signal that determines that B is equal and becomes active at that time, and determines that A is greater than B when the second carry is detected, and A> B determination signal that becomes active at that time Is output, and if both the first carry and the second carry are not detected, it is determined that A is smaller than B and an A <B determination signal which is active at that time is output. .
[0048]
BEST MODE FOR CARRYING OUT THE INVENTION
[First Embodiment]
Hereinafter, a first embodiment of the present invention will be described with reference to the drawings.
[0049]
FIG. 1 is a block diagram showing a configuration of a size comparison device according to the first embodiment of the present invention. In FIG. 1, the values A (0), A (1),..., A (7), B (0), B (1),..., B (7) are two 8-bit binary numbers to be compared. The values of bits 0 to 7 of A and B are shown, of which A (7) and B (7) show the value of the most significant bit, respectively.
[0050]
The carry detection means 10 outputs a binary number A in a range from bit 0 to bit 3. , Bit inversion of binary B and , Value "1" in bit 0 When Is detected, the carry of bit 3 that occurs when. The magnitude detecting means 20 detects the magnitude relation between the binary numbers A and B in the range from bit 4 to bit 7. The determination means 30 determines the magnitude relationship between the binary numbers A and B from the output of the carry detection means 10 and the output of the magnitude detection means 20 and outputs the result.
[0051]
The control signal CNT in the figure is a control signal that is passive if the binary numbers A and B are expressed in two's complement, and is an active control signal if it is an unsigned binary number.
[0052]
The operation of the size comparison device configured as described above will be described.
[0053]
The carry detection means 10 outputs a binary number A in a range from bit 0 to bit 3. , Bit inversion of binary B and , Value "1" in bit 0 When Is detected, and a carry of bit 3 generated when the signal is added is detected and output as carry signal C (3) of bit 3.
[0054]
On the other hand, the magnitude detection means 20 compares the magnitudes of the binary numbers A and B in the range from bit 4 to bit 7, and if A is greater than or equal to B, the bit 4 A> B detection signal BG (4) Activate, if A is less than B, activate A <B detection signal SL (4) of bit 4; if both A greater than B state and A less than B state cannot be detected, A> of bit 4 Both the B detection signal BG (4) and A <B detection signal SL (4) of bit 4 are made passive.
[0055]
The judging means 30 calculates a binary number A and a binary number B from the carry signal C (3) of bit 3, the A> B detection signal BG (4) of bit 4 and the A <B detection signal SL (4) of bit 4 The magnitude relationship is determined and output as a magnitude comparison determination signal JG.
[0056]
The magnitude comparison determination signal JG output from the determination means 30 at that time becomes active when the A <B detection signal SL (4) of bit 4 is active, and the A> B detection signal BG (4) of bit 4 Is active, the carry signal C (3) of bit 3 is passive when the A <B detection signal SL (4) of bit 4 and the A> B detection signal BG (4) of bit 4 are both passive. If it is passive, it becomes active, and if the carry signal C (3) of bit 3 is active, it becomes passive.
[0057]
The magnitude comparison determination signal JG output as described above becomes passive if A is greater than B or A is greater than B, becomes active if A is less than B, and becomes larger or smaller than binary A and binary B. Is shown.
[0058]
In this way, when comparing the magnitudes of the binary numbers A and B, the carry propagation is detected from the least significant bit to the upper direction, and the magnitude relation information is detected from the most significant bit to the lower direction. By doing so, two types of processing can be executed in parallel, the calculation time can be greatly reduced, and the circuit scale can be small.
[0059]
In the following, details of the internal configuration and operation of the components according to the present embodiment will be described with reference to FIGS. 2 to 11.
[0060]
FIG. 2 is a block diagram showing the internal configuration of the carry detecting means 10 in FIG. Since the carry detection means 10 performs carry detection for the lower 4 bits of the 8 bits, one carry detection element 100 (0) for the least significant bit and three carry detection elements for the other upper bits are provided. It comprises detection elements 101 (1), 101 (2) and 101 (3).
[0061]
The carry detection element 100 (0) receives the values A (0) and B (0) of bit 0 of the binary numbers A and B, and outputs a carry signal C (0) of bit 0.
[0062]
The carry detection element 101 (1) receives the values A (1) and B (1) of the bit 1 of the binary numbers A and B and the carry signal C (0) of the bit 0, and receives the carry signal C (0) of the bit 1 1) is output.
[0063]
The carry detection element 101 (2) receives the values A (2) and B (2) of the bits 2 of the binary numbers A and B and the carry signal C (1) of the bit 1, and receives the carry signal C (1) of the bit 2 Output 2).
[0064]
The carry detection element 101 (3) receives the values A (3) and B (3) of the bit 3 of the binary numbers A and B and the carry signal C (2) of the bit 2, and receives the carry signal C (2) of the bit 3 Output 3).
[0065]
In the configuration of the carry detection means 10 shown in FIG. 2, the delay becomes most critical when the carry propagates from the least significant bit and the carry signal C (3) of bit 3 becomes active.
[0066]
FIG. 3 is a circuit diagram of the carry detection element 100 (0) in FIG. The carry detection element 100 (0) includes an AND circuit 1001 and a knot circuit 1002.
[0067]
In this carry detection element 100 (0), if the value A (0) of bit 0 of binary A is “1” and the value B (0) of bit 0 of binary B is “0”, The carry signal C (0) of bit 0 becomes active, and a carry occurs. If the value A (0) of the bit 0 of the binary A is “1” and the value B (0) of the bit 0 of the binary B is “1”, the carry signal C ( 0) becomes active and carry occurs. Further, if the value A (0) of the bit 0 of the binary number A is “0” and the value B (0) of the bit 0 of the binary B is “0”, the carry signal C ( 0) becomes active and carry occurs. If the value A (0) of the bit 0 of the binary number A is “0” and the value B (0) of the bit 0 of the binary number B is “1”, the carry signal C ( 0) is passive and no carry occurs.
[0068]
Since this circuit assumes a case where a value “1” is added to the digit position of bit 0, it is simpler than the circuit of the carry detection elements 101 (1), 101 (2), and 101 (3) of the upper bits described later. Has been
[0069]
FIG. 4 is a circuit diagram of the carry detection element 101 (i) (where i = 1, 2, 3) in FIG. The carry detection element 101 (i) includes AND circuits 1011, 1012 and 1013 and an OR circuit 1014.
[0070]
In the carry detection element 101 (i), if the value A (i) of the bit i of the binary number A is “1” and the value B (i) of the bit i of the binary number B is “0”, Carry signal C (i) of bit i becomes active, and carry occurs. When the value A (i) of the bit i of the binary number A is “0” and the value B (i) of the bit i of the binary number B is not “1”, it is a carry input from the lower bit. If carry signal C (i-1) is active, carry signal C (i) becomes active and carry occurs. Otherwise, carry signal C (i) is passive and no carry occurs.
[0071]
As can be easily imagined, carry detection element 100 (0) in FIG. 2 is replaced with carry detection element 101 (i) (where i = 0) shown in FIG. 4 and a value “1” is input to the carry input. It may be configured to input.
[0072]
FIG. 5 is a block diagram showing the configuration of the size detecting means 20. Since the magnitude detection means 20 performs magnitude detection for the upper 4 bits of the 8 bits, one magnitude detection element 200 (7) for the most significant bit and three magnitudes for the other lower bits are provided. It comprises detection elements 201 (6), 201 (5) and 201 (4).
[0073]
The magnitude detection element 200 (7) receives the values A (7) and B (7) of bit 7 of the binary numbers A and B, and inputs the A> B detection signal BG (7) and A <B detection signal of bit 7 It outputs SL (7).
[0074]
The magnitude detection element 206 (6) includes the values A (6) and B (6) of bit 6 of the binary numbers A and B and the A> B detection signal BG (7) and A <B detection signal SL (7) of bit 7. ) Is input, and an A> B detection signal BG (6) and an A <B detection signal SL (6) of bit 6 are output.
[0075]
The magnitude detection element 206 (5) includes the values A (5) and B (5) of bit 5 of the binary numbers A and B and the A> B detection signal BG (6) and A <B detection signal SL (6) of bit 6. ) Is input, and an A> B detection signal BG (5) and an A <B detection signal SL (5) of bit 5 are output.
[0076]
The magnitude detection element 206 (4) includes the values A (4) and B (4) of bit 4 of the binary numbers A and B and the A> B detection signal BG (5) and A <B detection signal SL (5) of bit 5. ) Is input, and an A> B detection signal BG (4) and an A <B detection signal SL (4) of bit 4 are output.
[0077]
In the configuration of the magnitude detection means 20 of FIG. 5, the delay becomes the most critical because the information of magnitude relation detection is propagated from the most significant bit, and A> B detection signals BG (4) and A output from bit 4 It can be seen that it is until the B detection signal SL (4) is determined.
[0078]
FIG. 6 is a circuit diagram of the magnitude detection element 200 (7) in FIG. 5 in a case where the binary numbers A and B are signed binary numbers represented by two's complement. The magnitude detection element 200 (7) is composed of AND circuits 2001 and 2002. Here, when the binary numbers A and B are signed binary numbers, the sign bit that is the most significant bit takes a value “0” when it is a positive number and takes a value “1” when it is a negative number. .
[0079]
In the magnitude detection circuit 200 (7), if the value A (7) of the bit 7 of the binary number A is “0” and the value B (7) of the bit 7 of the binary number B is “1”, A> B The detection signal BG (7) becomes active, the value A (7) of the bit 7 of the binary A is “1”, and the value B (7) of the bit 7 of the binary B is 0. Then, the A <B detection signal SL (7) becomes active, and otherwise the A> B detection signal BG (7) and the A <B detection signal SL (7) become passive.
[0080]
FIG. 7 is a circuit diagram of the magnitude detection element 201 (i) (where i = 6, 5, 4) in FIG. The magnitude detection element 201 (i) includes AND circuits 2011, 2012, 2013 and OR circuits 2014, 2015.
[0081]
In the magnitude detection element 201 (i), if the A <B detection signal SL (i + 1) from the upper one bit is active, the A <B detection signal SL (i) becomes active, and the A from the upper one bit is further increased. > B The detection signal BG (i + 1) is passive, the value A (i) of the bit i of the binary A is “0”, and the value B (i) of the bit i of the binary B is “1” ", The A <B detection signal SL (i) becomes active. If the A> B detection signal BG (i + 1) from the upper one bit is active, the A> B detection signal BG (i) becomes active, and the value A (i) of the bit i of the binary number A becomes the value. If “1” and the value B (i) of the bit i of the binary number B is “0”, the A> B detection signal BG (i) becomes active.
[0082]
From the above, the A> B detection signal BG (i) becomes active when the state of A greater than B is already detected above bit i, and the A <B detection signal SL (i) is higher than bit i. When the state of A is smaller than B is detected earlier than the state of A is larger than B (that is, when A is smaller than B at a bit higher than the bit where A is larger than B is detected) Become active.
[0083]
FIG. 8 is a circuit diagram of the determination means 30 in FIG. The determination means 30 includes an AND circuit 301 and an OR circuit 302.
[0084]
In the determination means 30, if the A <B detection signal SL (4) of the bit 4 output from the magnitude detection means 20 is active, the magnitude comparison determination signal JG becomes active, and further, the A> B detection signal of the bit 4 If BG (4) is passive and the carry signal C (3) of bit 3, which is the output of the carry detection means 10, is passive, the magnitude comparison determination signal JG becomes active.
[0085]
From the above, if the A <B detection signal SL (4) of the bit 4 is active, the magnitude comparison determination signal JG becomes active, and if the A> B detection signal BG (4) of the bit 4 is active, , The A <B detection signal SL (4) of bit 4 is always passive, and the magnitude comparison determination signal JG is passive. That is, if the magnitude detection means 20 detects the magnitude relationship between the binary numbers A and B, the result is output.
[0086]
When the A <B detection signal SL (4) and the A> B detection signal BG (4) of the bit 4 are both passive, if the carry signal C (3) of the bit 3 is active, the magnitude comparison determination signal When the JG becomes passive and the carry signal C (3) of bit 3 is passive, the magnitude comparison determination signal JG becomes active. That is, if the magnitude relationship between the binary numbers A and B is not detected by the magnitude detection means 20, the magnitude relation is finally determined by the carry signal C (3) of the bit 3 which is the output of the carry detection means 10.
[0087]
FIG. 9 is a circuit diagram of the magnitude detection element 200 (7) in FIG. 5 when the binary numbers A and B are unsigned binary numbers. This magnitude detection element 200 (7) is composed of AND circuits 2001 and 2002 as in FIG. The difference from FIG. 6 is that the positions at which the A> B detection signal BG (7) and the A <B detection signal SL (7) are taken out are interchanged.
[0088]
In the magnitude detection circuit 200 (7), if the value A (7) of the bit 7 of the binary number A is “1” and the value B (7) of the bit 7 of the binary number B is “0”, A> B The detection signal BG (7) becomes active, the value A (7) of the bit 7 of the binary A is "0", and the value B (7) of the bit 7 of the binary B is the value " If 1 ", the A <B detection signal SL (7) becomes active; otherwise, the A> B detection signal BG (7) and A <B detection signal SL (7) become passive.
[0089]
Note that the magnitude detection element 201 (i) (where i = 6, 5, 4) in FIG. 5 when the binary numbers A and B are unsigned binary numbers is the same as in FIG.
[0090]
From FIGS. 6 and 9, the case where the binary numbers A and B are signed binary numbers represented by two's complement and the case where the binary numbers A and B are unsigned binary numbers are shown in FIG. In the circuit of the magnitude detection element 200 (7), the generation circuit of the bit 7 A> B detection signal BG (7) and the generation circuit of the bit 7 A <B detection signal SL (7) are symmetrical. I understand.
[0091]
Therefore, a function of exchanging the value A (7) of the bit 7 which is the most significant bit of the binary number A with the value B (7) of the bit 7 which is the most significant bit of the binary number B, or A> B detection signal BG If any of the functions for switching (7) and the A <B detection signal SL (7) is provided, both signed binary numbers and unsigned binary numbers expressed in 2's complement can be supported simultaneously.
[0092]
FIG. 10 shows a control signal CNT that is passive if the binary numbers A and B are signed binary numbers represented by two's complement and becomes active if the binary numbers A and B are unsigned binary numbers. FIG. 3 is a block diagram showing a configuration of a magnitude detecting means 21 provided with means for exchanging data of values A (7) and B (7) of bit 7 which is the most significant bit of A and B. In FIG. 10, multiplexers 202 and 203, which are switched by the control signal CNT, constitute means for exchanging data of the values A (7) and B (7) of the bit 7 which is the most significant bit of the binary numbers A and B. I have. Others are the same as FIG.
[0093]
FIG. 11 is a block diagram showing a configuration of the magnitude relation detecting means 22 including means for exchanging the A> B detection signal BG (7) and the A <B detection signal SL (7) by the control signal CNT. . In FIG. 11, multiplexers 204 and 205, which are switched by a control signal CNT, constitute means for exchanging an A> B detection signal BG (7) and an A <B detection signal SL (7). Others are the same as FIG.
[0094]
By employing the configuration of FIG. 10 or 11 described above, a magnitude comparison device that can support both binary numbers in 2's complement representation and unsigned binary numbers is obtained.
[0095]
As described above, according to the first embodiment, by providing the carry detection means 10, the size detection means 20, 21, or 22, and the determination means 30, the magnitude comparison between the binary number A and the binary number B is performed. At this time, by detecting the carry propagation from the least significant bit to the upper direction, and detecting the information of the magnitude relation from the most significant bit to the lower direction, the processing can be executed in parallel, and the operation time can be reduced. Can be greatly reduced, and the circuit scale can be kept small.
[0096]
Further, in the present embodiment, the carry detection means 10 and the magnitude detection means 20, 21 or 22 are shown in a configuration in which information propagates one digit at a time, but the detection circuits are parallelized as in a carry look ahead configuration. By doing so, it is possible to further increase the speed. However, in this case, the circuit scale is slightly increased due to parallelization.
[0097]
[Second embodiment]
Hereinafter, a second embodiment of the present invention will be described.
[0098]
FIG. 12 is a block diagram showing a configuration of a size comparison device according to the second embodiment of the present invention. 12, A (0), A (1),..., A (7), B (0), B (1),..., B (7) are two 8-bit binary numbers A to be compared. , B of bits 0 to 7, wherein A (7) and B (7) indicate the value of the most significant bit, respectively.
[0099]
The carry detecting means 11 outputs a binary number A in a range from bit 0 to bit 3. , Bit inversion of binary B and , Value “1” in bit 0 When Is detected, the carry of bit 3 that occurs when. The magnitude detecting means 20 detects the magnitude relation between the binary numbers A and B in the range from bit 4 to bit 7. The determination means 31 determines the magnitude relationship between the binary numbers A and B from the output of the carry detection means 11 and the output of the magnitude detection means 20 and outputs the result. The size detecting means 20 has the same configuration as that of the first embodiment.
[0100]
The configuration of the second embodiment is different from that of the first embodiment in that the carry detection means 11 has data in which the binary numbers A and B are completely equal for each bit in the range from bit 0 to bit 3. In addition, the first carry C1 (3) of the bit (k-1) and the first carry C1 (3) of the bit (k-1) generated by the value "1" added to the digit position of the least significant bit become the propagation source of the carry propagation. And the second carry C2 (3) of the bit (k-1) including the carry that occurs in all cases is detected and output. The determination means 31 outputs the first output which is the output of the carry detection means 11. From the carry C1 (3), the second carry C2 (3), and the A> B detection signal BG (4) and A <B detection signal SL (4) which are the outputs of the magnitude detection means 20. The magnitude relation of B is determined, and the magnitude When the relationship is detected, the magnitude relationship is output. When the magnitude relationship is not detected, if the first carry C1 (3) output from the carry detection means 11 is detected, it is determined that A and B are equal. Further, an A = B determination signal JGAB which becomes active at that time is output, and if the first carry C1 (3) is not detected and the second carry C2 (3) is detected, it is determined that A is greater than B. A> B determination signal JGA which becomes active at that time is output, and if both first carry C1 (3) and second carry C2 (3) are not detected, it is determined that A is smaller than B and at that time It is configured to output an active A <B determination signal JGB.
[0101]
FIG. 13 is a block diagram showing the internal configuration of the carry detecting means 11 in FIG. Since the carry detection means 11 performs carry detection for the lower 4 bits of the 8 bits, one carry detection element 102 (0) for the least significant bit and three carry detection elements 102 (0) for the other upper bits. It comprises detection elements 103 (1), 103 (2), and 103 (3).
[0102]
The carry detection element 102 (0) receives the values A (0) and B (0) of bit 0 of the binary numbers A and B, and outputs the first and second carry signals C1 (0) and C2 ( 0) is output.
[0103]
The carry detection element 103 (1) includes the values A (1) and B (1) of bit 1 of the binary numbers A and B, the first and second carry signals C1 (0) and C2 (0) of bit 0, and , And outputs first and second carry signals C1 (1) and C2 (1) of bit 1.
[0104]
The carry detection element 103 (2) outputs the values A (2) and B (2) of bit 2 of the binary numbers A and B, the first and second carry signals C1 (1) and C2 (1) of bit 1, and , And outputs first and second carry signals C1 (2) and C2 (2) of bit 2.
[0105]
The carry detection element 103 (3) outputs the values A (3) and B (3) of bit 3 of the binary numbers A and B, the first and second carry signals C1 (2) and C2 (2) of bit 2 and And outputs the first and second carry signals C1 (3) and C2 (3) of bit 3.
[0106]
FIG. 14 is a circuit diagram of the carry detection element 102 (0) in FIG. The carry detection element 102 (0) includes, in addition to the circuit of the carry detection element 100 (0) of the carry detection means 10 in the first embodiment, the value A (0) of the bit 0 of the binary number A and the binary number B A circuit for detecting that the value B (0) of bit 0 is exactly the same value is added. Specifically, it is composed of AND circuits 1021, 1022, 1023 and a knot circuit 1024.
[0107]
In the carry detection element 102 (0), when the value A (0) of bit 0 of the binary number A and the value B (0) of bit 0 of the binary number B are exactly the same value, the first carry signal C1 (0) becomes active. Further, second carry signal C2 (0) is the same as carry signal C (0) in FIG.
[0108]
FIG. 15 is a circuit diagram of the carry detection element 103 (i) (where i = 1, 2, 3) in FIG. The carry detection element 103 (i) includes the value A (i) of the bit i of the binary number A and the binary number B in addition to the circuit of the carry detection element 101 (i) of the carry detection means 10 in the first embodiment. And a circuit for detecting that the data of the binary number A and the data of the binary number B up to one bit lower are the same value as the value B (i) of the bit i. I have. More specifically, the circuit includes AND circuits 1031, 1032, 1033, and 1034 and an OR circuit 1035.
[0109]
In the carry detection element 103 (i), the value A (i) of the bit i of the binary number A is exactly the same as the value B (i) of the bit i of the binary number B, and 2 bits to the lower bit. The first carry signal C1 (i) becomes active when the data of the base A and the data of the base B match. Further, the second carry signal C2 (i) is the same as the carry signal C (i) in FIG.
[0110]
FIG. 16 is a circuit diagram of the determination means 31 in FIG. This determining means 31 has a circuit for performing the following processing in addition to the circuit of the determining means 30 in the first embodiment. That is, in the case where A is not less than B, the combination of the first carry C1 (3) and the second carry C2 (3), which is the output of the carry detection means 11, activates when A is greater than B. > A circuit for generating and outputting a B determination signal JGA and an A = B determination signal JGAB which becomes active when A and B are equal. The A <B determination signal JGB in the drawing is the same as the magnitude comparison determination signal JG output from the determination means 30 and is a signal that becomes active when A is less than B. Specifically, it is composed of AND circuits 311, 312 and 313 and an OR circuit 314.
[0111]
The operation of the size comparison device configured as described above will be described.
[0112]
Since the binary number A and the binary number B are completely equal for each bit in the range from bit 0 to bit 3 by the carry detection means 11, the value “1” added to the digit position of the least significant bit propagates in the carry. By detecting and outputting the first carry of the bit 3 which is generated as a propagation source of, the determination means 31 can determine the state of greater than A and the state where A and B are equal.
[0113]
By using the second embodiment, the arithmetic unit of the present invention, when comparing the magnitudes of two binary numbers A and B, determines the state of A greater than B, the state of A less than B, and A and B Three equal states can be determined.
[0114]
Further, in the present embodiment, three signals that become active in each of the three states are output. However, the three states may be represented by a combination of two signals, and can be easily realized.
[0115]
[Third Embodiment]
Hereinafter, a third embodiment of the present invention will be described.
[0116]
FIG. 17 is a block diagram showing a configuration of a magnitude comparison device according to the third embodiment of the present invention. 17, A (0), A (1),..., A (7), B (0), B (1),..., B (7) are two 8-bit wide binary numbers A to be compared. , B of bits 0 to 7, wherein A (7) and B (7) indicate the value of the most significant bit, respectively.
[0117]
The carry detecting means 12 outputs a binary number A in a range from bit 0 to bit 3. , Bit inversion of binary B and , Value “1” in bit 0 When Is detected, the carry of bit 3 that occurs when. The magnitude detecting means 20 detects the magnitude relation between the binary numbers A and B in the range from bit 4 to bit 7. The determination means 32 determines the magnitude relationship between the binary numbers A and B from the output of the carry detection means 12 and the output of the magnitude detection means 20 and outputs the result. The size detecting means 20 has the same configuration as that of the first embodiment.
[0118]
The configuration of the third embodiment is different from that of the first embodiment in that the carry detection means 12 has data in which the binary numbers A and B are completely equal for each bit in the range from bit 0 to bit 3. In addition, the first carry C1 (3) of the bit (k-1) and the first carry C1 (3) of the bit (k-1) generated by the value "1" added to the digit position of the least significant bit become the propagation source of the carry propagation. The second carry C3 (3) of the bit (k-1) including the carry generated in the case other than the case where the second carry C3 (3) is detected and output, and the determination means 32 outputs the first carry C1 ( 3), the second carry C3 (3) and the output of the magnitude detection means 20, A> B detection signal BG (4) and A <B detection signal SL (4), the magnitude relationship between the binary numbers A and B Is determined, and the magnitude relation is determined by the magnitude detection means 20. If issued, the magnitude relationship is output. If the magnitude relationship is not detected, if the first carry C1 (3) output from the carry detection means 12 is detected, it is determined that A and B are equal, and When the second carry C3 (3) is detected, an A = B determination signal JGAB is output. If both the first carry C1 (3) and the second carry C3 (3) are not detected, it is determined that A is smaller than B and an A <B determination signal JGB which becomes active at that time is output. Is done.
[0119]
FIG. 18 is a block diagram showing the internal configuration of carry detection means 12 in FIG. Since the carry detection means 12 performs carry detection for the lower 4 bits of the 8 bits, one carry detection element 104 (0) for the least significant bit and three carry signals for the other upper bits are provided. It consists of detection elements 105 (1), 105 (2) and 105 (3).
[0120]
The carry detection element 104 (0) receives the values A (0) and B (0) of bit 0 of the binary numbers A and B, and inputs the first and second carry signals C1 (0) and C3 ( 0) is output.
[0121]
The carry detection element 105 (1) includes the values A (1) and B (1) of bit 1 of the binary numbers A and B, the first and second carry signals C1 (0) and C3 (0) of bit 0, and , And outputs first and second carry signals C1 (1) and C3 (1) of bit 1.
[0122]
The carry detection element 105 (2) includes the values A (2) and B (2) of bit 2 of the binary numbers A and B, the first and second carry signals C1 (1) and C3 (1) of bit 1, and , And outputs first and second carry signals C1 (2) and C3 (2) of bit 2.
[0123]
The carry detection element 105 (3) outputs the values A (3) and B (3) of bit 3 of the binary numbers A and B, the first and second carry signals C1 (2) and C3 (2) of bit 2 and , And outputs first and second carry signals C1 (3) and C3 (3) of bit 3.
[0124]
FIG. 19 is a circuit diagram of the carry detection element 104 (0) in FIG. The carry detection element 104 (0) is different from the carry detection element 102 (0) of FIG. 14 in that the second carry signal C3 (0) has a value A (0) of bit 0 of the binary A and a binary B This does not include the case where the value B (0) of bit 0 is the same value. That is, the second carry signal C2 (0) in the circuit of FIG. 14 is a case where the value A (0) of bit 0 of binary A and the value B (0) of bit 0 of binary B are the same. 19, the second carry signal C3 (0) in FIG. 19 has the same value A (0) of bit 0 of binary A and the value B (0) of bit 0 of binary B. Is not active. Therefore, the first carry signal C1 (0) and the second carry signal C3 (0) are not simultaneously activated. Others are the same as FIG. Specifically, it is composed of AND circuits 1041, 1042 and 1043.
[0125]
The carry detection element 105 (i) (where i = 1, 2, 3) in FIG. 18 is the same as the carry detection element 103 (i) in FIG. 13, and the specific configuration is shown in FIG. Since it is the same as that of FIG.
[0126]
FIG. 20 is a circuit diagram of the determination means 32 in FIG. The determination means 32 determines that the second carry signal C2 (3) in the circuit of the determination means 31 in the second embodiment has been changed to the third carry signal C3 (3), that is, the first carry signal The circuit configuration has been changed because C1 (0) and the second carry signal C3 (0) are no longer active at the same time. Specifically, it is configured by AND circuits 321, 322 and 323 and an OR circuit 324.
[0127]
The operation of the size comparison device configured as described above will be described.
[0128]
Since the binary number A and the binary number B are completely equal for each bit in the range from bit 0 to bit 3 by the carry detection means 12, the value "1" added to the digit position of the least significant bit is propagated by the carry. By detecting and outputting the first carry of the bit 3 which is generated as a propagation source of, the determination means 32 can determine the state of greater than A and the state where A and B are equal.
[0129]
By using the second embodiment, the arithmetic unit of the present invention, when comparing the magnitudes of two binary numbers A and B, determines the state of A greater than B, the state of A less than B, and A and B Three equal states can be determined.
[0130]
Further, in the present embodiment, three signals that become active in each of the three states are output. However, the three states may be represented by a combination of two signals, and can be easily realized.
[0131]
In each of the above embodiments, an example is described in which 8-bit binary numbers A and B are compared, but the number of binary numbers A and B is arbitrary, such as 16 bits, 32 bits, and 62 bits. It is needless to say that the present invention can be applied to binary numbers.
[0132]
It is preferable that the upper bits and the lower bits of the binary numbers A and B are determined so that both processing times are substantially equal in consideration of the processing times of the magnitude comparison and the carry propagation. There is no need to do it in the middle. In addition, it is not necessary to determine that both processing times are equal. In other words, by performing the above-mentioned magnitude comparison and carry propagation simultaneously in parallel without setting the upper bit and lower bit division so that both processing times are equal, one of the magnitude comparison and carry propagation is performed. The processing time can be reduced as compared with the case where only one of them is performed.
[0133]
Further, in each of the above-described embodiments, the expression “active” or “passive” is used to indicate the state of a signal, but one of a high or low signal level is made active and the other is made passive.
[0134]
【The invention's effect】
As described above, according to the magnitude comparison method and the magnitude comparison apparatus of the present invention, when performing a magnitude comparison between the binary number A and the binary number B, a process for detecting a carry propagation from the least significant bit to the high order is performed. In addition, by performing parallel processing for detecting the magnitude relationship from the most significant bit to the lower direction, magnitude comparison can be performed with a small circuit scale and with greatly reduced operation time. In addition, by separately detecting the carry propagation generated when the binary number A and the binary number B are exactly the same for each bit in the bit range for detecting the carry propagation, the state of A greater than B and the smaller A And three states A and B are equal.
[Brief description of the drawings]
FIG. 1 is a block diagram illustrating a configuration of a size comparison device according to a first embodiment of the present invention.
FIG. 2 is a block diagram illustrating a configuration of a carry detection unit 10;
FIG. 3 is a circuit diagram showing a circuit configuration of carry detection element 100 (0) in carry detection means 10;
FIG. 4 is a circuit diagram showing a circuit configuration of carry detection element 101 (i) in carry detection means 10.
FIG. 5 is a block diagram showing a configuration of the size detecting means 20.
FIG. 6 is a circuit diagram showing a circuit configuration of a magnitude detection element 200 (7) in the magnitude detection means 20 when the comparison data is signed binary data represented by two's complement.
FIG. 7 is a circuit diagram showing a circuit configuration of a size detection element 201 (i) in the size detection means 20.
FIG. 8 is a circuit diagram showing a configuration of a determination unit 30.
FIG. 9 is a circuit diagram showing a circuit configuration of a size detection element 200 (7) in the size detection means 20 when the comparison data is unsigned binary data.
FIG. 10 is a block diagram showing a configuration of a size detecting means 21 capable of switching a number system of data to be compared by a control signal.
FIG. 11 is a block diagram showing a configuration of a size detecting means 22 capable of switching a number system of data to be compared by a control signal.
FIG. 12 is a block diagram illustrating a configuration of a magnitude comparison device according to a second embodiment of the present invention.
FIG. 13 is a block diagram showing a configuration of carry detection means 11;
FIG. 14 is a circuit diagram showing a circuit configuration of carry detection element 102 (0) in carry detection means 11;
FIG. 15 is a circuit diagram showing a circuit configuration of carry detection element 103 (i) in carry detection means 11.
FIG. 16 is a circuit diagram showing a configuration of a determination unit 31.
FIG. 17 is a block diagram illustrating a configuration of a size comparison device according to a third embodiment of the present invention.
FIG. 18 is a block diagram showing a configuration of carry detection unit 12;
FIG. 19 is a circuit diagram showing a circuit configuration of carry detection element 104 (0) in carry detection means 12.
FIG. 20 is a circuit diagram showing a circuit configuration of a determination unit 32.
[Explanation of symbols]
10 Carry detection means
11 Carry detection means
12 Carry detection means
20 Large and small detection means
21 Large and small detection means
22 Large and small detection means
30 Judgment means
31 Judgment means
32 Judgment means
100 (0) carry detection element
101 (1) Carry detection element
101 (2) Carry detection element
101 (3) Carry detection element
101 (i) Carry detection element
102 (0) Carry detection element
103 (1) Carry detection element
103 (2) Carry detection element
103 (3) Carry detection element
103 (i) Carry detection element
200 (7) Size detection element
201 (6) Size detection element
201 (5) Size detection element
201 (4) Size detection element
201 (i) Size detection element
202 multiplexer
203 multiplexer
204 multiplexer
205 multiplexer
BG (7) A> B detection signal
BG (6) A> B detection signal
BG (5) A> B detection signal
BG (4) A> B detection signal
SL (3) A <B detection signal
SL (2) A <B detection signal
SL (1) A <B detection signal
SL (0) A <B detection signal
CNT control signal
JG size comparison judgment signal
JGA A> B judgment signal
JGB A <B judgment signal
JGAB A = B judgment signal

Claims (15)

2つのnビット(nは正の整数)の2進数A,Bの大小比較を行う演算方法であって、
ビット0からビット(k−1)(kは正の整数,0<k<n)までのビット範囲で、前記2進数Aと前記2進数Bのビット反転と最下位ビットの桁位置における値“1”とを加えた場合に発生するビット(k−1)のキャリーを検出し、
ビットkからビット(n−1)までのビット範囲で、前記2進数Aと前記2進数Bの大小関係を検出し、
前記大小関係の検出結果と前記キャリーの検出結果から、前記2進数Aと前記2進数Bの大小関係を判定して出力することを特徴とする大小比較方法。
An arithmetic method for comparing the magnitudes of two n-bit (n is a positive integer) binary numbers A and B,
Bit 0 Bit (k-1) (k is a positive integer, 0 <k <n) in the range of bits to the a binary number A, the bit inversion and, the least significant bit digit position of the binary number B A carry of bit (k-1) generated when the value "1" is added is detected,
Detecting a magnitude relationship between the binary A and the binary B in a bit range from bit k to bit (n-1);
A magnitude comparison method comprising: determining a magnitude relation between the binary number A and the binary number B from a detection result of the magnitude relation and a detection result of the carry and outputting the result.
前記2つのnビットの2進数A,Bが2の補数表現される符号付き2進数であり、ビットkからビット(n−1)までのビット範囲で、前記2進数A,Bの大小関係を検出する際に、
前記2進数Aの最上位ビットである(n−1)ビットが正の符号を示し、前記2進数Bの最上位ビットである(n−1)ビットが負の符号を示す場合はA大なりBと判定し、前記2進数Aの最上位ビットである(n−1)ビットが負の符号を示し、前記2進数Bの最上位ビットである(n−1)ビットが正の符号を示す場合はA小なりBと判定し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行し、
前記2進数Aの(n−2)ビットが値“1”を示し、前記2進数Bの(n−2)ビットが値“0”を示す場合はA大なりBと判定し、前記2進数Aの(n−2)ビットが値“0”を示し、前記2進数Bの(n−2)ビットが値“1”を示す場合はA小なりBと判定し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行し、
前記2進数Aの(n−3)ビットが値“1”を示し、前記2進数Bの(n−3)ビットが値“0”を示す場合はA大なりBと判定し、前記2進数Aの(n−3)ビットが値“0”を示し、前記2進数Bの(n−3)ビットが値“1”を示す場合はA小なりBと判定し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行し、
前記の大小関係検出をkビットまで順次行い、kビットでも大小関係を検出できない場合は大小関係未検出と判定することを特徴とする請求項1に記載の大小比較方法。
The two n-bit binary numbers A and B are signed binary numbers represented by two's complement, and the magnitude relation between the binary numbers A and B is represented in a bit range from bit k to bit (n-1). When detecting,
When the (n-1) bit, which is the most significant bit of the binary number A, indicates a positive sign and the (n-1) bit, which is the most significant bit of the binary number B, indicates a negative sign, A is larger. B, and the (n-1) bit which is the most significant bit of the binary number A indicates a negative sign, and the (n-1) bit which is the most significant bit of the binary number B indicates a positive sign. In this case, it is determined that A is smaller than B, and in other combinations, the magnitude relation is not detected, and the processing shifts to the magnitude relation detection using 1-bit lower data.
When the (n-2) bit of the binary number A indicates a value "1" and the (n-2) bit of the binary number B indicates a value "0", it is determined that A is greater than B, and the binary number is determined. When the (n-2) bit of A indicates the value "0" and the (n-2) bit of the binary number B indicates the value "1", it is determined that A is smaller than B, and in other combinations, it is larger or smaller. As a relationship not detected, shift to magnitude relationship detection with 1-bit lower data,
When the (n-3) bits of the binary A indicate a value "1" and the (n-3) bits of the binary B indicate a value "0", it is determined that A is greater than B, and the binary When the (n-3) bit of A indicates the value "0" and the (n-3) bit of the binary B indicates the value "1", it is determined that A is smaller than B, and in other combinations, it is larger or smaller. As a relationship not detected, shift to magnitude relationship detection with 1-bit lower data,
2. The magnitude comparison method according to claim 1, wherein the magnitude relation detection is sequentially performed up to k bits, and when the magnitude relation cannot be detected even with k bits, it is determined that the magnitude relation has not been detected.
前記2つのnビットの2進数A,Bが符号無し2進数であり、ビットkからビット(n−1)までのビット範囲で、前記2進数A,Bの大小関係を検出する際に、
前記2進数Aの最上位ビットである(n−1)ビットが値“1”を示し、前記2進数Bの最上位ビットである(n−1)ビットが値“0”を示す場合はA大なりBと判定し、前記2進数Aの最上位ビットである(n−1)ビットが値“0”を示し、前記2進数Bの最上位ビットである(n−1)ビットが値“1”を示す場合はA小なりBと判定し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行し、
前記2進数Aの(n−2)ビットが値“1”を示し、前記2進数Bの(n−2)ビットが値“0”を示す場合はA大なりBと判定し、前記2進数Aの(n−2)ビットが値“0”を示し、前記2進数Bの(n−2)ビットが値“1”を示す場合はA小なりBと判定し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行し、
前記2進数Aの(n−3)ビットが値“1”を示し、前記2進数Bの(n−3)ビットが値“0”を示す場合はA大なりBと判定し、前記2進数Aの(n−3)ビットが値“0”を示し、前記2進数Bの(n−3)ビットが値“1”を示す場合はA小なりBと判定し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行し、
前記の大小関係検出をkビットまで順次行い、kビットでも大小関係を検出できない場合は大小関係未検出と判定することを特徴とする請求項1に記載の大小比較方法。
The two n-bit binary numbers A and B are unsigned binary numbers, and when detecting the magnitude relation between the binary numbers A and B in a bit range from bit k to bit (n-1),
When the (n-1) bit, which is the most significant bit of the binary number A, indicates a value "1" and the (n-1) bit, which is the most significant bit of the binary number B, indicates a value "0", A It is determined that the value is greater than B, and the (n-1) bit which is the most significant bit of the binary number A indicates a value "0", and the (n-1) bit which is the most significant bit of the binary number B is a value " If "1" is indicated, it is determined that A is smaller than B, and in other combinations, the magnitude relation is not detected, and the processing shifts to the magnitude relation detection with 1-bit lower data.
When the (n-2) bit of the binary number A indicates a value "1" and the (n-2) bit of the binary number B indicates a value "0", it is determined that A is greater than B, and the binary number is determined. When the (n-2) bit of A indicates the value "0" and the (n-2) bit of the binary number B indicates the value "1", it is determined that A is smaller than B, and in other combinations, it is larger or smaller. As a relationship not detected, shift to magnitude relationship detection with 1-bit lower data,
When the (n-3) bits of the binary A indicate a value "1" and the (n-3) bits of the binary B indicate a value "0", it is determined that A is greater than B, and the binary When the (n-3) bit of A indicates the value "0" and the (n-3) bit of the binary B indicates the value "1", it is determined that A is smaller than B, and in other combinations, it is larger or smaller. As a relationship not detected, shift to magnitude relationship detection with 1-bit lower data,
2. The magnitude comparison method according to claim 1, wherein the magnitude relation detection is sequentially performed up to k bits, and when the magnitude relation cannot be detected even with k bits, it is determined that the magnitude relation has not been detected.
ビットkからビット(n−1)までのビット範囲で、前記2進数A,Bの大小関係を検出する際に、
前記2進数A,Bが2の補数表現される符号付き2進数であればパッシブになり、符号無し2進数であればアクティブになる制御信号により、前記制御信号が前記パッシブであれば前記2進数A,Bを2の補数表現として大小関係を検出して出力し、前記制御信号が前記アクティブであれば前記2進数A,Bを符号無し2進数として大小関係を検出して出力することを特徴とする請求項1に記載の大小比較方法。
When detecting the magnitude relation between the binary numbers A and B in the bit range from bit k to bit (n-1),
If the binary numbers A and B are signed binary numbers represented by two's complement, the signal is passive. If the binary numbers A and B are unsigned binary numbers, the control signal becomes active. A and B are detected and output as a two's complement representation, and if the control signal is active, the binary numbers A and B are detected and output as unsigned binary numbers. The magnitude comparison method according to claim 1, wherein:
前記2進数A,Bの大小関係を判定する際に、
前記ビットkからビット(n−1)までのビット範囲での大小関係が検出されたらその大小関係を出力し、大小関係が検出されなければ前記キャリーの検出結果により、キャリーが検出されればA大なりBあるいはAとBは等しいと判定し、キャリーが検出されなければA小なりBと判定することを特徴とする請求項1に記載の大小比較方法。
When determining the magnitude relation between the binary numbers A and B,
If a magnitude relation in the bit range from the bit k to the bit (n-1) is detected, the magnitude relation is output. If the magnitude relation is not detected, the carry detection result is used. 2. The magnitude comparison method according to claim 1, wherein it is determined that greater than B or A is equal to B, and if no carry is detected, it is determined that A is less than B.
ビット0からビット(k−1)までのビット範囲で、前記2進数Aと前記2進数Bのビット反転と最下位ビットの桁位置における値“1”とを加えた場合に発生するビット(k−1)のキャリーを検出する際に、
前記2進数Aと前記2進数Bがビット0からビット(k−1)までのビット範囲で各ビット毎に全く等しいデータであるために、前記最下位ビットの桁位置に加えた値“1”がキャリー伝播の伝播元となり発生するビット(k−1)の第1のキャリーと、前記第1のキャリーが発生する場合も含めて総ての発生するキャリーを含むビット(k−1)の第2のキャリーを検出し、
前記ビットkからビット(n−1)までのビット範囲での大小関係検出において大小関係が検出されたらその大小関係を出力し、大小関係が検出されなければ前記キャリーの検出結果により、前記第1のキャリーが検出されればAとBは等しいと判定し、前記第1のキャリーが検出されずかつ前記第2のキャリーが検出されればA大なりBと判定し、前記第1のキャリーと前記第2のキャリーがともに検出されなければA小なりBと判定することを特徴とする請求項1に記載の大小比較方法。
In bit range from bit 0 to bit (k-1), bit occurring when added the the binary number A, and the bit inversion of the binary number B, and the value "1" in the digit position of the least significant bit When detecting the carry of (k-1),
Since the binary number A and the binary number B are exactly the same data for each bit in the bit range from bit 0 to bit (k−1), the value “1” added to the digit position of the least significant bit Is the first carry of the bit (k−1) generated as a propagation source of the carry propagation, and the first carry of the bit (k−1) including the all generated carry including the case where the first carry occurs. 2 Carry is detected,
If a magnitude relation is detected in the magnitude relation detection in the bit range from the bit k to the bit (n-1), the magnitude relation is output. If the magnitude relation is not detected, the first result is obtained based on the carry detection result. If the carry is detected, it is determined that A and B are equal. If the first carry is not detected and the second carry is detected, it is determined that A is greater than B, and the first carry and 2. The magnitude comparison method according to claim 1, wherein if both of the second carry are not detected, the magnitude is determined to be smaller than A.
ビット0からビット(k−1)までのビット範囲で、前記2進数Aと前記2進数Bのビット反転と最下位ビットの桁位置における値“1”とを加えた場合に発生するビット(k−1)のキャリーを検出する際に、
前記2進数Aと前記2進数Bがビット0からビット(k−1)までのビット範囲で各ビット毎に全く等しいデータであるために、前記最下位ビットの桁位置に加えた値“1”がキャリー伝播の伝播元となり発生するビット(k−1)の第1のキャリーと、前記第1のキャリーが発生する場合以外で発生するキャリーを含むビット(k−1)の第2のキャリーを区別して検出し、
前記ビットkからビット(n−1)までのビット範囲での大小関係検出において大小関係が検出されたらその大小関係を出力し、大小関係が検出されなければ前記キャリーの検出結果により、前記第1のキャリーが検出されればAとBは等しいと判定して出力し、前記第2のキャリーが検出されればA大なりBと判定して出力し、前記第1のキャリーと前記第2のキャリーがともに検出されなければA小なりBと判定して出力することを特徴とする請求項1に記載の大小比較方法。
In bit range from bit 0 to bit (k-1), bit occurring when added the the binary number A, and the bit inversion of the binary number B, and the value "1" in the digit position of the least significant bit When detecting the carry of (k-1),
Since the binary number A and the binary number B are exactly the same data for each bit in the bit range from bit 0 to bit (k−1), the value “1” added to the digit position of the least significant bit Is the first carry of the bit (k−1) generated as a propagation source of the carry propagation, and the second carry of the bit (k−1) including the carry generated except when the first carry occurs. Distinguish and detect,
If a magnitude relation is detected in the magnitude relation detection in the bit range from the bit k to the bit (n-1), the magnitude relation is output. If the magnitude relation is not detected, the first result is obtained based on the carry detection result. If the carry is detected, A and B are determined to be equal and output. If the second carry is detected, A is determined to be greater than B and output, and the first carry and the second carry are determined. 2. The magnitude comparison method according to claim 1, wherein if no carry is detected, the magnitude is determined to be smaller than A and output.
2つのnビットの2進数A,Bの大小比較を行う演算装置であって、
ビット0からビット(k−1)までのビット範囲で、前記2進数Aと前記2進数Bのビット反転と最下位ビットの桁位置における値“1”とを加えた場合に発生するビット(k−1)のキャリーを検出し出力するキャリー検出手段と、
ビットkからビット(n−1)までのビット範囲で、前記2進数Aと前記2進数Bの大小関係を検出し、A大なりBの場合にアクティブになるA>B検出信号と、A小なりBの場合にアクティブになるA<B検出信号とを出力し、前記2進数Aと前記2進数Bの大小関係が検出できなければ前記A>B検出信号と前記A<B検出信号が両方ともパッシブになる大小検出手段と、
前記大小検出手段の出力と前記キャリー検出手段の出力から、前記2進数Aと前記2進数Bの大小関係を判定し、A大なりBあるいはAとBが等しい場合にパッシブになり、A小なりBの場合にアクティブになる大小比較判定信号を出力する判定手段とを備えたことを特徴とする大小比較装置。
An arithmetic unit for comparing the magnitudes of two n-bit binary numbers A and B,
In bit range from bit 0 to bit (k-1), bit occurring when added the the binary number A, and the bit inversion of the binary number B, and the value "1" in the digit position of the least significant bit Carry detection means for detecting and outputting the carry of (k-1);
In a bit range from bit k to bit (n-1), a magnitude relationship between the binary number A and the binary number B is detected, and an A> B detection signal activated when A is greater than B; A <B detection signal that becomes active in the case of B is output. If the magnitude relationship between the binary number A and the binary number B cannot be detected, both the A> B detection signal and the A <B detection signal are output. Both large and small detection means that are passive,
From the output of the magnitude detection means and the output of the carry detection means, a magnitude relationship between the binary number A and the binary number B is determined. When the magnitude A is greater than B or when A and B are equal, it becomes passive, and A size comparison device comprising: a determination unit that outputs a size comparison determination signal that becomes active in the case of B.
前記大小検出手段は、
前記2つのnビットの2進数A,Bが2の補数表現される符号付き2進数であるとき、前記2進数Aの最上位ビットである(n−1)ビットが正の符号を示し、前記2進数Bの最上位ビットである(n−1)ビットが負の符号を示す場合はA大なりBと判定して前記A>B検出信号をアクティブにして出力し、前記2進数Aの最上位ビットである(n−1)ビットが負の符号を示し、前記2進数Bの最上位ビットである(n−1)ビットが正の符号を示す場合はA小なりBと判定して前記A<B検出信号をアクティブにして出力し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行し、
前記2進数Aの(n−2)ビットが値“1”を示し、前記2進数Bの(n−2)ビットが値“0”を示す場合はA大なりBと判定して前記A>B検出信号をアクティブにして出力し、前記2進数Aの(n−2)ビットが値“0”を示し、前記2進数Bの(n−2)ビットが値“1”を示す場合はA小なりBと判定して前記A<B検出信号をアクティブにして出力し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行し、
前記2進数Aの(n−3)ビットが値“1”を示し、前記2進数Bの(n−3)ビットが値“0”を示す場合はA大なりBと判定して前記A>B検出信号をアクティブにして出力し、前記2進数Aの(n−3)ビットが値“0”を示し、前記2進数Bの(n−3)ビットが値“1”を示す場合はA小なりBと判定して前記A<B検出信号をアクティブにして出力し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行し、
前記の大小関係検出をkビットまで順次行い、kビットでも大小関係を検出できない場合は大小関係未検出と判定して前記A>B検出信号と前記A<B検出信号とをともにパッシブにして出力することを特徴とする請求項8に記載の大小比較装置。
The magnitude detection means,
When the two n-bit binary numbers A and B are signed binary numbers represented by two's complement, (n-1) bits that are the most significant bits of the binary number A indicate a positive sign, If the (n-1) bit, which is the most significant bit of the binary number B, indicates a negative sign, it is determined that A is greater than B, the A> B detection signal is activated and output, and the most significant bit of the binary number A is output. When the (n-1) -bit, which is the most significant bit, indicates a negative sign and the (n-1) -bit, which is the most significant bit of the binary number B, indicates a positive sign, it is determined that A is smaller than B and The A <B detection signal is activated and output. In other combinations, the magnitude relation is not detected and the processing shifts to the magnitude relation detection with 1-bit lower data.
When the (n−2) bit of the binary number A indicates a value “1” and the (n−2) bit of the binary number B indicates a value “0”, it is determined that A is greater than B and the A> The B detection signal is activated and output. When the (n−2) bit of the binary number A indicates a value “0” and the (n−2) bit of the binary number B indicates a value “1”, A When it is determined that the magnitude is smaller than B, the A <B detection signal is activated and output. In other combinations, the magnitude relation is not detected and the processing shifts to the magnitude relation detection with one bit lower data.
When the (n-3) bits of the binary number A indicate a value "1" and the (n-3) bits of the binary number B indicate a value "0", it is determined that A is greater than B and the A> The B detection signal is activated and output. When the (n−3) bit of the binary number A indicates a value “0” and the (n−3) bit of the binary number B indicates a value “1”, A When it is determined that the magnitude is smaller than B, the A <B detection signal is activated and output. In other combinations, the magnitude relation is not detected and the processing shifts to the magnitude relation detection with one bit lower data.
The magnitude relation detection is sequentially performed up to k bits. If the magnitude relation cannot be detected even with k bits, it is determined that the magnitude relation has not been detected, and the A> B detection signal and the A <B detection signal are both passively output. The size comparison device according to claim 8, wherein the comparison is performed.
前記大小検出手段は、
前記2つのnビットの2進数A,Bが符号無し2進数であるとき、前記2進数Aの最上位ビットである(n−1)ビットが値“1”を示し、前記2進数Bの最上位ビットである(n−1)ビットが値“0”を示す場合はA大なりBと判定して前記A>B検出信号をアクティブにして出力し、前記2進数Aの最上位ビットである(n−1)ビットが値“0”を示し、前記2進数Bの最上位ビットである(n−1)ビットが値“1”を示す場合はA小なりBと判定して前記A<B検出信号をアクティブにして出力し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行し、
前記2進数Aの(n−2)ビットが値“1”を示し、前記2進数Bの(n−2)ビットが値“0”を示す場合はA大なりBと判定して前記A>B検出信号をアクティブにして出力し、前記2進数Aの(n−2)ビットが値“0”を示し、前記2進数Bの(n−2)ビットが値“1”を示す場合はA小なりBと判定して前記A<B検出信号をアクティブにして出力し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行し、
前記2進数Aの(n−3)ビットが値“1”を示し、前記2進数Bの(n−3)ビットが値“0”を示す場合はA大なりBと判定して前記A>B検出信号をアクティブにして出力し、前記2進数Aの(n−3)ビットが値“0”を示し、前記2進数Bの(n−3)ビットが値“1”を示す場合はA小なりBと判定して前記A<B検出信号をアクティブにして出力し、それ以外の組合せでは大小関係未検出として1ビット下位データでの大小関係検出に移行し、
前記の大小関係検出をkビットまで順次行い、kビットでも大小関係を検出できない場合は大小関係未検出と判定して前記A>B検出信号と前記A<B検出信号とをともにパッシブにして出力することを特徴とする請求項8に記載の大小比較装置。
The magnitude detection means,
When the two n-bit binary numbers A and B are unsigned binary numbers, the (n-1) bit that is the most significant bit of the binary number A indicates a value "1", and the most significant bit of the binary number B When the (n-1) -bit, which is the upper bit, indicates a value "0", it is determined that A is greater than B, the A> B detection signal is activated and output, and is the most significant bit of the binary A. When the (n-1) bit indicates a value "0" and the (n-1) bit, which is the most significant bit of the binary number B, indicates a value "1", it is determined that A is less than B and the A <A The B detection signal is activated and output, and in other combinations, the magnitude relation is not detected and the processing shifts to the magnitude relation detection with 1-bit lower data.
When the (n−2) bit of the binary number A indicates a value “1” and the (n−2) bit of the binary number B indicates a value “0”, it is determined that A is greater than B and the A> The B detection signal is activated and output. When the (n−2) bit of the binary number A indicates a value “0” and the (n−2) bit of the binary number B indicates a value “1”, A When it is determined that the magnitude is smaller than B, the A <B detection signal is activated and output. In other combinations, the magnitude relation is not detected and the processing shifts to the magnitude relation detection with one bit lower data.
When the (n-3) bits of the binary number A indicate a value "1" and the (n-3) bits of the binary number B indicate a value "0", it is determined that A is greater than B and the A> The B detection signal is activated and output. When the (n−3) bit of the binary number A indicates a value “0” and the (n−3) bit of the binary number B indicates a value “1”, A When it is determined that the magnitude is smaller than B, the A <B detection signal is activated and output. In other combinations, the magnitude relation is not detected and the processing shifts to the magnitude relation detection with one bit lower data.
The magnitude relation detection is sequentially performed up to k bits. If the magnitude relation cannot be detected even with k bits, it is determined that the magnitude relation has not been detected, and the A> B detection signal and the A <B detection signal are both passively output. The size comparison device according to claim 8, wherein the comparison is performed.
前記大小検出手段は、
前記2進数A,Bが2の補数表現される符号付き2進数であればパッシブになり、符号無し2進数であればアクティブになる制御信号により、前記2進数A,Bの最上位ビットであるビット(n−1)のデータを入れ替える手段を備えることを特徴とする請求項8に記載の大小比較装置。
The magnitude detection means,
If the binary numbers A and B are signed binary numbers expressed in two's complement, they are passive, and if they are unsigned binary numbers, they are the most significant bits of the binary numbers A and B by a control signal that becomes active. 9. The magnitude comparing apparatus according to claim 8, further comprising a unit for exchanging data of bit (n-1).
前記大小検出手段は、
前記2進数A,Bが2の補数表現される符号付き2進数であればパッシブになり、符号無し2進数であればアクティブになる制御信号により、前記2進数Aの(n−1)ビットが値“1”を示し、前記2進数Bの(n−1)ビットが値“0”を示す場合にアクティブとなる信号と、前記2進数Aの(n−1)ビットが値“0”を示し、前記2進数Bの(n−1)ビットが値“1”を示す場合にアクティブとなる信号とを入れ替えて出力する手段を備えることを特徴とする請求項8に記載の大小比較装置。
The magnitude detection means,
When the binary numbers A and B are signed binary numbers represented by two's complement, the binary numbers A and B become passive, and when the binary numbers A and B are unsigned binary numbers, the control signal becomes active. A signal which becomes active when the (n-1) bit of the binary number B indicates the value "0" and a (n-1) bit of the binary number A indicates the value "0". 9. The size comparison apparatus according to claim 8, further comprising means for replacing the signal which becomes active when the (n-1) bit of the binary number B indicates the value "1".
前記判定手段は、
前記大小検出手段の出力である前記A<B検出信号がアクティブの時はアクティブになり、前記A>B検出信号がアクティブの時はパッシブになり、前記A<B検出信号と前記A>B検出信号がともにパッシブの時は前記キャリー検出手段の出力がパッシブであればアクティブになり、前記キャリー検出手段の出力がアクティブであればパッシブになる大小比較判定信号を出力することにより前記2進数Aと前記2進数Bの大小関係を判定することを特徴とする請求項8に記載の大小比較装置。
The determining means includes:
When the A <B detection signal, which is the output of the magnitude detection means, is active, it becomes active, when the A> B detection signal is active, it becomes passive, and the A <B detection signal and the A> B detection When both signals are passive, if the output of the carry detection means is passive, the signal becomes active.If the output of the carry detection means is active, the signal becomes passive. The magnitude comparison apparatus according to claim 8, wherein the magnitude relation of the binary number B is determined.
前記キャリー検出手段は、
前記2進数Aと前記2進数Bがビット0からビット(k−1)までのビット範囲で各ビット毎に全く等しいデータであるために、前記最下位ビットの桁位置に加えた値“1”がキャリー伝播の伝播元となり発生するビット(k−1)の第1のキャリーと、前記第1のキャリーが発生する場合も含めて総ての発生するキャリーを含むビット(k−1)の第2のキャリーとを検出して出力し、
前記判定手段は、
前記大小検出手段において大小関係が検出されたらその大小関係を出力し、大小関係が検出されない時は、前記キャリー検出手段の出力である前記第1のキャリーが検出されればAとBは等しいと判定してかつそのときアクティブになるA=B判定信号を出力し、前記第1のキャリーが検出されずかつ前記第2のキャリーが検出されればA大なりBと判定してかつそのときアクティブになるA>B判定信号を出力し、前記第1のキャリーと前記第2のキャリーがともに検出されなければA小なりBと判定してかつそのときアクティブとなるA<B判定信号を出力することを特徴とする請求項8に記載の大小比較装置。
The carry detection means,
Since the binary number A and the binary number B are exactly the same data for each bit in the bit range from bit 0 to bit (k−1), the value “1” added to the digit position of the least significant bit Is the first carry of the bit (k−1) generated as a propagation source of the carry propagation, and the first carry of the bit (k−1) including the all generated carry including the case where the first carry occurs. 2 carry and output,
The determining means includes:
If the magnitude relation is detected by the magnitude detection means, the magnitude relation is output. If no magnitude relation is detected, A and B are equal if the first carry, which is the output of the carry detection means, is detected. An A = B determination signal is output which is determined and becomes active at that time, and if the first carry is not detected and the second carry is detected, it is determined that A is greater than B and then active. A> B determination signal is output, and if both the first carry and the second carry are not detected, it is determined that A is smaller than B and an A <B determination signal that is active at that time is output. The size comparison device according to claim 8, wherein:
前記キャリー検出手段は、
前記2進数Aと前記2進数Bがビット0からビット(k−1)までのビット範囲で各ビット毎に全く等しいデータであるために、前記最下位ビットの桁位置に加えた値“1”がキャリー伝播の伝播元となり発生するビット(k−1)の第1のキャリーと、前記第1のキャリーが発生する場合以外で発生するキャリーを含むビット(k−1)の第2のキャリーとを検出して出力し、
前記判定手段は、
前記大小関係検出において大小関係が検出されたらその大小関係を出力し、大小関係が検出されない時は、前記キャリー検出手段の出力である前記第1のキャリーが検出されればAとBは等しいと判定してかつそのときアクティブになるA=B判定信号を出力し、前記第2のキャリーが検出されればA大なりBと判定してかつそのときアクティブになるA>B判定信号を出力し、前記第1のキャリーと前記第2のキャリーがともに検出されなければA小なりBと判定してかつそのときアクティブとなるA<B判定信号を出力することを特徴とする請求項8に記載の大小比較装置。
The carry detection means,
Since the binary number A and the binary number B are exactly the same data for each bit in the bit range from bit 0 to bit (k−1), the value “1” added to the digit position of the least significant bit Are the propagation source of the carry propagation, and the first carry of the bit (k-1) generated and the second carry of the bit (k-1) including the carry generated when the first carry does not occur. Is detected and output,
The determining means includes:
If the magnitude relation is detected in the magnitude relation detection, the magnitude relation is output. If the magnitude relation is not detected, A and B are equal if the first carry, which is the output of the carry detection means, is detected. An A = B determination signal that is determined and activated at that time is output. If the second carry is detected, A is determined to be greater than A and an A> B determination signal that is activated at that time is output. 9. The method according to claim 8, wherein if both the first carry and the second carry are not detected, it is determined that A is smaller than B and an A <B determination signal which becomes active at that time is output. Size comparison device.
JP10394599A 1999-04-12 1999-04-12 Size comparison method and device Expired - Fee Related JP3557366B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP10394599A JP3557366B2 (en) 1999-04-12 1999-04-12 Size comparison method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP10394599A JP3557366B2 (en) 1999-04-12 1999-04-12 Size comparison method and device

Publications (2)

Publication Number Publication Date
JP2000293359A JP2000293359A (en) 2000-10-20
JP3557366B2 true JP3557366B2 (en) 2004-08-25

Family

ID=14367591

Family Applications (1)

Application Number Title Priority Date Filing Date
JP10394599A Expired - Fee Related JP3557366B2 (en) 1999-04-12 1999-04-12 Size comparison method and device

Country Status (1)

Country Link
JP (1) JP3557366B2 (en)

Also Published As

Publication number Publication date
JP2000293359A (en) 2000-10-20

Similar Documents

Publication Publication Date Title
JPH07210369A (en) Circuit and method for execution of parallel addition and average operation
US9146707B2 (en) Generating a fast 3x multiplicand term for radix-8 booth multiplication
US5367477A (en) Method and apparatus for performing parallel zero detection in a data processing system
EP1652063A1 (en) Arithmetic unit for addition or subtraction with preliminary saturation detection
US6629118B1 (en) Zero result prediction
JP3012357B2 (en) Shift amount detection circuit
JP3557366B2 (en) Size comparison method and device
JPH09222991A (en) Adding method and adder
GB2401962A (en) A sum bit generation circuit
JP4567753B2 (en) Parity generation circuit, counting circuit, and counting method
JPH1091397A (en) Arithmetic circuit
US6631393B1 (en) Method and apparatus for speculative addition using a limited carry
JP4317738B2 (en) Average value calculating apparatus and average value calculating method
US20050210089A1 (en) Saturating shift mechanisms within data processing systems
KR0175357B1 (en) Overflow Detection Circuit of Operator for High Speed
CN115833845B (en) Position output device and position output method
JP2002189588A (en) Adder adopting improved overflow flag generation system
US6411975B1 (en) Digital processing
KR19980023995A (en) Method for computing the selected sign three expressions in a single instruction cycle
US20040167949A1 (en) Data saturation manager and corresponding method
KR950010571B1 (en) Rounding circuit
Srivastava Architecture Optimisation Using Deterministic Completion Detection
KR950015180B1 (en) High speed adder
KR20010045217A (en) Data detector
JP3106525B2 (en) Addition method and its circuit

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20040120

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20040305

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: 20040511

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20040517

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

Free format text: PAYMENT UNTIL: 20090521

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20100521

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20110521

Year of fee payment: 7

LAPS Cancellation because of no payment of annual fees