JP3579087B2 - Arithmetic unit and microprocessor - Google Patents

Arithmetic unit and microprocessor Download PDF

Info

Publication number
JP3579087B2
JP3579087B2 JP15756694A JP15756694A JP3579087B2 JP 3579087 B2 JP3579087 B2 JP 3579087B2 JP 15756694 A JP15756694 A JP 15756694A JP 15756694 A JP15756694 A JP 15756694A JP 3579087 B2 JP3579087 B2 JP 3579087B2
Authority
JP
Japan
Prior art keywords
register
sum
bits
multiplier
partial product
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
JP15756694A
Other languages
Japanese (ja)
Other versions
JPH0822451A (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.)
Hitachi Ltd
Original Assignee
Hitachi 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 Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP15756694A priority Critical patent/JP3579087B2/en
Publication of JPH0822451A publication Critical patent/JPH0822451A/en
Application granted granted Critical
Publication of JP3579087B2 publication Critical patent/JP3579087B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/544Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices for evaluating functions by calculation
    • G06F7/5443Sum of products
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2207/00Indexing scheme relating to methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F2207/38Indexing scheme relating to groups G06F7/38 - G06F7/575
    • G06F2207/3804Details
    • G06F2207/3808Details concerning the type of numbers or the way they are handled
    • G06F2207/3828Multigauge devices, i.e. capable of handling packed numbers without unpacking them

Description

【0001】
【産業上の利用分野】
本発明は、画像処理等において用いられる積和演算等の演算処理を高速に行う手段に関する。
【0002】
【従来の技術】
従来、イメージ処理(画像処理)の分野においては、演算処理を行なう際に、高速、高精度等の、高度の演算性能が要求されるため、演算処理を行なうためには、処理内容に応じて、演算処理のための専用演算器を製作し、イメージ処理に応用してきた。
【0003】
このような専用演算器を、イメージ処理の内容に応じて製作し、イメージ処理を行なうシステムを設計製造するのでは、システムのコストの上昇を招いてしまう。
【0004】
一方、比較的低コストでシステム構築を行なえ、イメージ処理に応用可能な、汎用プロセッサの性能は向上してきたが、イメージ処理のすべてを、汎用プロセッサ内に内蔵された演算器で行なうほど、汎用プロセッサ内に内蔵された演算器の処理速度や処理内容は優れたものではない。
【0005】
ところで、イメージ処理で頻繁に行なわれる演算処理である、いわゆる積和演算は、乗算器と加算器とを、適宜組み合わせて構成した演算器で実行可能である。
【0006】
このような従来の演算器において、与えられた2つの数の乗算を行なう乗算器は、部分積の生成機能と部分積の加算機能とを有する。
【0007】
ここで、図19を参照して、部分積の生成と部分積加算を具体例に説明する。
【0008】
ここで、乗算に用いるデータのビット数は、5ビットとする。
【0009】
「部分積」は、乗数1901のビットを1ビットずつ調べ、ビットの内容が「1」であれば、被乗数1900の値、そのものであり、ビットの内容が「0」であれば、部分積を「0」とする。
【0010】
ただし、乗数1901の符号ビットで生成される部分積は、符号ビットの内容が「1」ならば、被乗数1901のビット反転の値と加算1とし、符号ビットが「0」ならば「0」とする。
【0011】
図19において、部分積は、矩形で囲んで表現しており、その内容を矩形内に示している。
【0012】
5ビットの乗算においては、乗数のビット数は5(ビット)あるので、図19に示すように、5個の部分積が生成される。図に示した演算例では、部分積1(1902)と、部分積2(1903)とは、その生成の際に、調べる対象となるビットの内容が「1」であるので、被乗数1900そのものとなる。
【0013】
また、部分積3(1904)と、部分積4(1905)とは、生成の際に、調べる対象となるビットの内容が「0」であるため「0」となり、部分積5(1906)は、乗数の符号ビットで生成され、かつ、生成の際に調べる対象となる符号ビットが「1」であるため、被乗数の負数となる。
【0014】
また、各部分積の加算は、乗数の下位ビットからの生成順に、部分積を1ビットずつ上位(左)にシフトしていき加算する。また、乗数、被乗数が、負数でも表現されている、いわゆる、2の補数表現のとき、部分積加算を正しく実行するには、符号を拡張(以下「符号拡張」と称する)して加算しなければならない。
【0015】
図19に示す例では、部分積1では、4ビット拡張(1907)し、部分積2では、3ビット拡張(1908)し、部分積3では、2ビット拡張(1909)し、部分積4では、1ビット拡張している(1910)。このような符号拡張により、正確な部分積加算を実行できる。
【0016】
通常、この部分積加算は、図20に示すような、桁上げ保存加算器と、桁上げ伝播加算器を使用して行なわれる。図20に示す部分積加算器は、3入力全加算器を配列して構成される桁上げ保存加算器である。
【0017】
ここで部分積加算器の基本構成要素となる、3入力全加算器の動作を図21に示す。
【0018】
3入力全加算器は、入力の3ビット(2100、2101、2102)を加算して、桁上げ2104と和2103を出力する。
【0019】
図21に示すように、3つの値を入力し、所定の場合には、桁上げ出力(2104)を行なって、加算(2103)を行なっている。
【0020】
図20に示す、桁上げ保存機能を有する加算器である全加算器(2000、2001、2002、2003、2004)では、図19に示す部分積1〜3を入力して、入力された部分積の加算を実行する。各全加算器によって行なわれる加算の結果の「桁上げ」は、次段の一桁上位の全加算器に、「和」は、次段の同じ桁の全加算器(2010、2011等)に入力し、図19に示す部分積4との加算を行なう。さらに、その結果は、部分積5の加算に使用する全加算器(2012等)に入力され、加算される。
【0021】
部分積5は、被乗数の値を反転させて、「1」を加算する必要があるので、全加算器2012の入力2013は、1を加算するための入力として使用する。
【0022】
一例として、1段目の全加算器2000は、部分積1の拡張符号2005(値は「1」)と、部分積2の拡張符号2006(値は「1」)と、部分積3の符号2007(値は「0」)を入力し、加算を行なう。
【0023】
そして、加算結果の桁上げ2008を、次段の一桁上位の全加算器2010に入力し、和2009を次段の同じ桁の全加算器2011に入力する。
【0024】
全加算器2010は、部分積1〜部分積3の拡張符号の加算結果の桁上げと和とを入力し、加算を行なう。その入力信号を生成する全加算器2014は、全加算器2000と同一の計算を行うので、全加算器2000の加算結果2009を、全加算器2010の入力とする構成とし、その結果、全加算器2000より、上位の桁の加算を行なう、即ち、左に存在する全加算器2014は、省略されうる。
【0025】
このように、桁上げ保存機能を有する加算器は、「桁上げ」を次段に送って、加算を繰り返すため、全部分積の加算が終了しても、2024から2038の2出力が残る。そのため、最終結果を得るためには、さらに、その2出力を加算するために、図20に示すような、いわゆる桁上げ伝播加算器が必要である。
【0026】
図20に示す構成では、桁上げ伝播加算器は、全加算器2015〜2022を有して構成される。これらの全加算器間の接続は、一例として、全加算器2016の桁上げ2023が、全加算器2015の入力となるような接続関係を有しており、文字通り桁上げ伝播加算器を構成している。
【0027】
【発明が解決しようとしている課題】
前述のように、例えば図20に示す積和演算器においては、桁上げ保存機能を有する加算器はもちろんのこと、桁上げ伝播加算器をも設けて、積和演算器を実現しなければならなかった。
【0028】
このように、従来の専用演算器を使用して演算を行なう場合においては、処理性能は満たされるものの、システムのコストの上昇を招くことがほとんどである。一方、汎用演算器を使用したのでは、コストの上昇は抑えられるものの、その処理性能は満足のいくものではないという問題が依然として存在する。
【0029】
しかしながら、汎用演算器の使用は、コストの低減のためには必要不可欠であるので、該汎用演算器の処理性能の向上を図る必要がある。
【0030】
そこで、本発明の目的は、汎用プロセッセが備える汎用演算器のうち、イメージ処理等で頻繁に使用される積和演算器の一部を独立に動作させる手段を設けることで、複数の積和演算を同時に行い、コストを抑えた、演算速度の速い、高性能のイメージ処理等に使用可能な演算手段を提供することにある。
【0031】
【課題を解決するための手段】
上記課題を解決し、本発明の目的を達成するために、以下の手段が考えられる。
【0032】
複数の被乗数を有するNビットの数と、前記各被乗数に対応する乗数を複数有するMビットの数との積を求めることによって、被乗数と乗数の組に対する乗算結果を求める演算器であって、以下の手段を備える演算器である。
【0033】
すなわち、被乗数を複数個保持し、各被乗数のビット長の総和がNを越えないことを条件として配置され、各被乗数の間に0を埋め込んだ状態で、Nビットの数を保持する第1レジスタと、前記各被乗数に対応する乗数を保持し、各乗数のビット長の総和がMを越えないことを条件として配置され、各乗数の間に0を埋め込んだ状態で、Mビットの数を保持する第2レジスタと、第1レジスタに保持された値と第2レジスタに保持された値との部分積を求めていく処理を行う部分積処理部と、前記部分積において、1組の被乗数と乗数の、乗算結果の符号を補償するため、乗算結果を2の補数表現したビットを埋込む符号拡張部と、各部分積の和を順次求めていく手段であって、ある組の被乗数と乗数に対する全ての部分積の総和が所定値を越えた場合、該越えた値を、次の他の組の被乗数と乗数に対する部分積の総和を求めていく際に廃棄する、各部分積の総和値を求める総和手段と、該手段によって求めた、総和値(「N+M」(ビット))のデータから、第1レジスタにおける各被乗数と、これに対応する第2レジスタにおける乗数との乗算結果である値を切り出し、被乗数と乗数との組に対応する乗算結果を、各組について求める処理手段とを備える。
【0034】
【作用】
本発明は、汎用の積和演算器であって、入力レジスタ等に格納された各データに対する乗算を分離して同時に行うための機能を有する部分積加算器と、各乗算結果に対して、加算を分離して同時に行うための機能を有する加算器を備えて、演算を行なう。
【0035】
まず、第1レジスタに、被乗数を複数個保持し、各被乗数のビット長の総和がNを越えないことを条件として配置し、各被乗数の間に0を埋め込んだ状態で、Nビットの数を保持しておく。そして、第2レジスタには、前記被乗数に対応する乗数を複数個保持し、各乗数のビット長の総和がMを越えないことを条件として配置し、各乗数の間に0を埋め込んだ状態で、Mビットの数を保持しておく。
【0036】
次に、部分積処理部は、第1レジスタに保持された値と第2レジスタに保持された値との部分積を求めていく処理を行い、符号拡張部は、前記部分積において、1組の被乗数と乗数の、乗算結果の符号を補償するため、乗算結果を2の補数表現したビットを埋込む処理を行なう。
【0037】
そして、総和手段は、各部分積の和を順次求めていき、ある組の被乗数と乗数に対する全ての部分積の総和が所定値を越えた場合、該越えた値を、次の他の組の被乗数と乗数に対する部分積の総和を求めていく際に廃棄する、各部分積の総和値を求める。
【0038】
最後に、処理手段が、総和手段によって求めた、総和値(「N+M」(ビット))のデータから、第1レジスタにおける各被乗数と、これに対応する第2レジスタにおける乗数との乗算結果である値を切り出し、被乗数と乗数との組に対応する乗算結果を、各組について求め、並列演算を実現する。
【0039】
【実施例】
以下、本発明の実施例について図面を参照して説明する。
【0040】
図1に、本発明にかかる実施例の構成図を示す。
【0041】
本実施例は、「a1×b1+c1」、「a2×b2+c2」なる演算を同時に実行するための演算器である。
【0042】
演算器全体は、レジスタ100にパック(データが詰めこまれた状態を、以下このように表現する)された、2つの被乗数a1、a2と、レジスタ101にパックされた、2つの乗数、b1、b2とを、それぞれ入力102、103とし、これら入力に基づいて生成した部分積を加算する機能を有する部分積加算器104を備える。
【0043】
また、レジスタ105にパックされた、2つの加数c1、c2を入力106とし、この入力データと、部分積加算器104の2出力である「a1×b1」、「a2×b2」との加算を、正確な位取りで実行するために、入力106の内容をシフトして、部分積加算器104の前記2出力に桁合わせする機能を有する「シフト アンド セレクタ」107と、部分積加算器104の2出力と、「シフトアンド セレクタ」107の出力を加算する機能を有する3入力全加算器列108と、3入力全加算器列の2出力を加算する機能を有する64ビット加算器109と、64ビット加算器109の出力を、指定されたフォーマットに変換するアライナ110と、加算結果がオーバーフローであるか、または、アンダーフローであるかを判定するオーバーフロー/アンダーフロー判定部111と、その判定結果がオーバーフローであれば、アライナ110の出力を最大値に、また判定結果がアンダーフローであれば、アライナ110の出力を最小値に置き換える最大値/最小値置換部112とを有して構成される。そして、最終的な演算結果は、レジスタ150にパックされた状態で出力される。
【0044】
図1の実施例において、「a1×b1+c1」、「a2×b2+c2」なる積和演算を行なう際の各構成要素の動作を、データ長32ビットのレジスタの、上位8ビットおよび下位8ビットに、2つのデータをパックした場合を例にとり説明する。
【0045】
積和演算を行うデータは、図2に示すデータフォーマット200の様に、32ビットの上位8ビットおよび下位8ビットに、2つのデータa1、a2をパックし、その間に「0」値を埋め込んで、32ビットのデータとしている。
【0046】
データb1、b2、c1、c2(図示せず)も同様に、32ビットの上位8ビットおよび下位8ビットに、2つのデータをパックし、その間に「0」値を埋め込んで、32ビットのデータとしている。
【0047】
データa1、a2をパックした32ビットのデータと、データb1、b2をパックした32ビットのデータとを、32ビットのデータ同士で乗算することによって、パックされた8ビットのデータ同士の乗算、即ち、「a1×b1」と「a2×b2」を同時に実行するものである。
【0048】
その際、32ビット乗算結果において、どの部分が乗算「a1×b1」と「a2×b2」に相当しているのかを図2に示している。なお、図2において、各部分積は、横長の矩形で表現している。
【0049】
さて、乗算「a1×b1」は、部分積25(203)から部分積32(204)までの、各々の上位15桁、また、乗算「a2×b2」は、部分積1(201)から部分積8(202)までの、各々の下位15桁を使用して計算される。そのため、図面中黒く塗られた部分は、乗算「a1×b1」と「a2×b2」の符号を拡張された部分となる。なお、符号拡張の概念については、前述の図19で示した通りである。
【0050】
また、乗数データb1とb2と間に「0」値が埋め込まれているため、それらのビット(値が「0」)から生成される部分積9〜24は、必ず「0」となる。そのため、全ての部分積を加算した時に、a2×b2による部分積加算の結果による桁上げが伝播することに起因する、乗算「a1×b1」への影響をなくすことができる。
【0051】
また、部分積25の加算で使用される、部分積25の32ビット用の符号拡張の加算分を「0」とすることで、32ビット乗算のための、符号拡張分の加算(部分積1から8までに対応する加算)結果が、「a1×b1」の演算結果への影響をなくすことができる。
【0052】
これら2点の工夫により、「a1×b1」と「a2×b2」を、分離した状態で演算することができる。
【0053】
次に、以上で説明した機能を有する部分積加算器104の動作について、詳細に説明する。
【0054】
図3は、乗算a2×b2の拡張符号の機能を、汎用の部分積加算器によって実現した構成例である。
【0055】
図2に示すように、この乗算の拡張符号が必要な範囲は、「部分積1」では、9桁目〜15桁目まで、「部分積2」では、10桁目〜15桁目まで、「部分積3」では、11桁目〜15桁目まで、「部分積4」では、12桁目〜15桁目まで、「部分積5」では13桁目〜15桁目まで、「部分積6」では14桁目〜15桁目まで、「部分積7」では15桁目である。
【0056】
図3では、一例として、部分積3〜5に相当する部分について図示した。
【0057】
なお、各全加算器の動作は、図21に示す通りである。
【0058】
全加算器300から305は、部分積3の15桁目から10桁目の加算に、全加算器306から311は、部分積4の15桁目から10桁目の加算に、全加算器312から317は、部分積5の15桁目から10桁目の加算にそれぞれ使用される。
【0059】
セレクタ318は、信号330が「1」ならば、2入力331、332のうち、332の方を選択する。他のセレクタ319〜321も、同様な動作をする。332は、乗算「a2×b2」の部分積3の符号であることから、信号330を「1」とすることで、符号を表現するための信号332によって、符号拡張して、全加算器によって部分積3を加算することができる。
【0060】
セレクタ323〜326、セレクタ327〜329も、信号330を「1」にすることによって、それぞれ、部分積4と部分積5の符号333、334を選択する。これにより、部分積4、部分積5についても、符号拡張を行なった加算が実現できる。
【0061】
そのほか、図3には示していないが、部分積1、2、6、7に対しても、信号330によって、符号拡張のための信号を選択するセレクタを、全加算器の入力側に設けた構成にすることによって、乗算「a2×b2」の部分積加算で、符号拡張した加算が実現できることになる。
【0062】
図22は、乗数b2の符号ビット(下位から8つ目のビット)から、部分積8を生成するための、汎用の部分積加算器の実現例である。全加算器2200〜2207は、部分積8の下位8ビットの加算を行なう。符号ビットから、部分積を生成するため、図19に示したように、データを反転させて、「1」を加える処理を実現するための構成である。
【0063】
論理ゲート2208は、信号2225が「1」のときに、入力2227を反転し、「0」のときには、入力2227の値に関係なく「1」を出力する機能を有する。また、セレクタ2216は、信号2226が「1」のとき論理ゲート2208の出力を選択し、信号2226が「0」のとき、部分積8の下位から8ビット目のデータ2227を選択する機能を有する。
【0064】
なお、「論理ゲート2208、セレクタ2216」と、「論理ゲート2209〜2215と、セレクタ2217〜2223」とは、同じ動作をする。また、セレクタ2224は、信号2226が「1」のとき「1」を出力する。
【0065】
論理ゲート2208〜2215と、セレクタ2216から2224を用い、信号2226を「1」にすることで、乗算「a2×b2」の部分積8の生成と加算が実現できることになる。他の部分積も同様に生成加算できる。このように、図3、図22に示す構成により、乗算「a2×b2」の部分積加算の演算が実行できることになる。
【0066】
次に、図4に示す構成を有する手段により、32ビット乗算を行なうための符号拡張分の加算(部分積1から8までの加算)結果による、乗算「a1×b1」への影響をなくすための機能を実現するが、この動作について説明する。
【0067】
まず、全加算器400〜407によって、部分積25の32桁目〜25桁目(乗算「a1×b1」の部分積1(図2中の部分積25))の値を加算する処理を行なう。また、全加算器408〜414は、部分積24までの加算結果を出力している。
【0068】
論理ゲート415は、信号431が「0」のとき、全加算器408の和433を「0」にする機能を有する。同様に、論理ゲート416〜422も、信号431が「0」のとき、全加算器409から414の和を「0」にする機能を有する。また、論理ゲート423は、信号431が「0」のとき、全加算器408の桁上げ432を、「0」にする機能を有する。
【0069】
同様に、論理ゲート424〜430も、信号431が「0」のとき、全加算器409から414の桁上げを「0」にする機能を有する。信号431が「1」のときは、論理素子415〜430は、全加算器408〜414からの、桁上げと和の値を、そのまま通過させる機能を有する。
【0070】
つまり、信号431を「0」にするこによって、部分積24までの加算結果と、部分積25との加算処理を制御することができる。これにより、32ビット乗算のための符号拡張分の加算(部分積1から8までの加算)結果による、乗算「a1×b1」への影響をなくすことが可能となる。
【0071】
以上説明してきた、図3、図22、図4に示す構成を有する手段を備えることにより、部分積加算器104は、通常の32ビット乗算と同一の処理で、「a1×b1」と「a2×b2」の2つの乗算の部分積加算を、並列に実行することができる。
【0072】
次に、「シフト アンド セレクタ」107は、「a1×b1+c1」、「a×b2+c2」の並列実行を行なうことを指示するコントロール信号113を受けとり、部分積加算器104の演算結果の、上位16桁と下位16桁に、それぞれc1とc2の位取りが正しく合うように、図5の500に示すようにパックされたc1、c2を、501に示すようにシフト処理し、c1とc2間に「0」を埋め込む。
【0073】
「a1×b1+c1」、「a2×b2+c2」の演算を、並列実行しないときには、シフトしない状態の、500を選択する。
【0074】
3入力全加算器列108は、図5に示すような、上位16桁と下位16桁に「a1×b1」と「a2×b2」の部分積加算の、桁上げ保存加算器の出力503と、「シフト アンド セレクタ」107で選択された、入力501とを、桁上げ保存加算し、加算結果506を得る。「a1×b1+c1」、「a2×b2+c2」の並列実行の場合、501において、c1とc2との間は、値「0」が埋っているため、a1×b1+c1、a2×b2+c2の間の桁では桁上げが起きない。その結果、c1、c2の加算は互いに影響しない。
【0075】
図6に、並列に実行した演算結果が、オーバーフローまたはアンダーフローであるかの判定を並列に実行する、オーバーフロー/アンダーフロー判定部111の構成例を示す。
【0076】
上位用判定部600、下位用判定部601は、それぞれ、図5に示す506の上位16ビットと下位16ビットを、予め定めている値である、8ビット用上限値603、8ビット用下限値604と比較する処理を行なう。
【0077】
上位用判定部600は、図5に示す506の上位16ビットの内容が、8ビット用上限値603より大きな場合は、オーバーフローが発生したと判断し、また、8ビット用下限値604より小さい場合は、アンダーフローが発生したと判断する。また、下位用判定部601は、図5に示す506の下位16ビットの内容に対し、上位用判定部600と同様の判断を行なう。
【0078】
32ビット用判定部602は、506の下位32ビットを、予め定めている値である、32ビット用上限値605と32ビット用下限値606とを、それぞれ用いて、32ビット乗算の場合のオーバーフロー、アンダーフローが発生したか否かを判定する。なお、上位用判定部600と、下位用判定部601とは、別々に動作するので、上位と下位の16ビットの、オーバーフロー、アンダーフローの判定は、並列に実行できる。
【0079】
なお、上位用判定部600が出力する判定信号607、608は、それぞれ、506の上位16ビットがオーバーフロー、アンダーフローの時「1」となり、下位用判定部601が出力する判定信号609、610は、それぞれ、506の下位16ビットがオーバーフロー、アンダーフローの時「1」となり、32ビット用判定部602が出力する判定信号611、612は、それぞれ、506の下位32ビットがオーバーフロー、アンダーフローの時「1」となる。
【0080】
これらの判定信号607から612は、判定結果を最大値/最小値置換部112に送られる。
【0081】
図7に、通常の積和演算の場合と、今まで述べてきた、「a1×b1+c1」、「a2×b2+c2」を求める並列演算を実行する場合の、2つの場合に対応できるように、64ビット加算器109の出力状態(701からのデータの取り出し方)を制御する機能を有するアライナ110の構成図を示す。
【0082】
セレクタ702は、データ719(701の上位9ビット目から上位16ビット目までのデータ)とデータ720(701の上位33ビット目から上位40ビット目までのデータ)との選択を、「a1×b1+c1」および「a2×b2+c2」の並列演算実行時で「0」となり、通常の積和演算時に「1」となる制御信号723で行なう。
【0083】
論理ゲート703〜718(計16個あるが、複雑になるため図面では2個を記載し、あとは省略してある)は、制御信号723で、データ721(701の下位24ビット目から下位9ビット目まで)を「0」とする(図中、724で0値と記載している部分)。
【0084】
すなわち、「a1×b1+c1」、「a2×b2+c2」の並列演算実行時は、制御信号723が「0」となり、第1に、セレクタ702は、データ719を選択し、図中d1部は、データ719で満たされ、第2に、論理ゲート713〜718は、アンドゲートであるので、データ721は「0」となる。また、データ722は変化しないので、アライナの出力は、724のようになる。
【0085】
一方、通常の積和演算時で、制御信号723が「1」となると、セレクタ702は、データ720を選択し、さらに、データ721は、論理ゲート713〜718を、そのまま通過する。また、データ722は変化しないのでアライナの出力は725のようになる。
【0086】
この結果、「a1×b1+c1」および「a2×b2+c2」の並列演算実行時では、演算結果d1、d2が、32ビットのレジスタに、724のようにパックされることになる。
【0087】
次に、図8に、演算条件およびオーバーフロー/アンダーフロー判定部111の判定結果と、最大値/最小値置換部112の出力との関係を示す。
【0088】
以下に、出力の態様を示す。
【0089】
まず、図8中(1)に示す例では、「a1×b1+c1」および「a2×b2+c2」の演算が同時実行された場合で、上位側の結果が、オーバーフローと判定された時、出力の上位8ビットに、予め定めておいた値である最大値(max)を出力し、出力の下位8ビットは、演算結果をそのまま出力する。
【0090】
また、図8中(2)に示す例では、上位側の結果がアンダーフローと判定された時、出力の上位8ビットに、予め定めておいた値である最小値(min)を出力し、出力の下位8ビットは、、演算結果をそのまま出力する。
【0091】
また、図8中(3)に示す例では、下位側の結果が、オーバーフローと判定された時、出力の下位8ビットに、予め定めておいた値である最大値(max)を出力し、出力の上位8ビットは、演算結果をそのまま出力する。
【0092】
また、図8中(4)に示す例では、下位側の結果がアンダーフローと判定された時、出力の下位8ビットに、予め定めておいた値である最小値(min)を出力し、出力の上位8ビットは、演算結果をそのまま出力する。
【0093】
さらに、通常積和実行時で、オーバーフローと判定された場合、32ビット全体に、予め定めておいた値である最大値を出力し(図8(5)の示す例)、アンダーフローと判定された場合、32ビット全体に、予め定めておいた値である最小値を出力することも考えられる(図8(6))。
【0094】
その他、「a1×b1+c1」および「a2×b2+c2」の並列演算が実行された場合でも、通常積和実行時でも、オーバーフローまたはアンダーフローとも判定されなかった場合には、入力値をそのまま出力することも考えられる(図8(7)の例)。
【0095】
次に、32ビットのすべてのビットにデータをパックした例、例えば、8ビットの画素データを4個詰めて行う、並列積和演算器の実施例を図9を参照して説明する。
【0096】
本実施例の構成は、パックされた4つの被乗数a1、a2、a3、a4と、パックされた4つの乗数b1、b2、b3、b4とから部分積を求め、加算する部分積加算器900と、パックされた4つの加数c1、c2、c3、c4を、部分積加算器900の出力と桁合わせする「シフト アンド セレクタ」901と、部分積加算器900の2出力と「シフト アンド セレクタ」901の出力とを加算する機能を有する3入力全加算器列902と、3入力全加算器列の2出力を加算する機能を有する64ビット加算器903と、該加算器の出力を指定されたフォーマットに変換するアライナ904と、加算結果がオーバーフロー、アンダーフローであるか否かを判定するオーバーフロー/アンダーフロー判定部905と、その結果に基づいて、予め定めた規則に従って、前記アライナ904の出力を所定の値に置き換える機能を有する最大値/最小値置換部906とを有して構成されている。
【0097】
図9に示す実施例において、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、「a4×b4+c4」の複数の積和演算を行なう際の動作を、データ長32ビットに、8ビットデータを4個を詰めた場合を例にとり説明する。
【0098】
積和演算を行うデータは、図10に示す、データフォーマット1000に示すように、4データ「a1、a2、a3、a4」で32ビットのデータを構成する。
【0099】
a1、a2、a3、a4、また、c1、c2、c3、c4についても、同様に、32ビットのデータとする。
【0100】
「a1、a2、a3、a4」をパックした32ビットデータと、「a1、a2、a3、a4」をパックした32ビットデータにおいて、32ビットデータ同士を乗算することで、8ビット同士の乗算「a1×b1」、「a2×b2」、「a3×b3」、「a4×b4」を同時に実行するものである。
【0101】
その際、32ビットデータの乗算結果のどの部分が、それぞれ乗算「a1×b1」、「a2×b2」、「a3×b3」、「a4×b4」に相当するかについて、図10を参照して説明する。
【0102】
なお、図10において、各部分積は、矩形で表現している。
【0103】
乗算「a1×b1」、「a2×b2」、「a3×b3」および「a4×b4」の各々の値は、それぞれ、部分積25から32、部分積17から24、部分積9から16、部分積1から8の加算によって求められる。そのため、図中黒く塗られた部分は、乗算「a1×b1」、「a2×b2」、「a3×b3」および「a4×b4」の拡張符号となる部分である。
【0104】
例えば、乗算「a4×b4」では、部分積1では9桁目〜15桁目まで、部分積2では10桁目〜15桁目まで、部分積3では11桁目〜15桁目まで、部分積4では12桁目〜15桁目まで、部分積5では13桁目〜15桁目まで、部分積6では14桁目〜15桁目まで、部分積7では15桁目が拡張符号となる部分である。
【0105】
また、前述した2乗算の並列演算と同様に、部分積8、16、24、32は、符号ビットに相当するため負数を作る必要がある。
【0106】
1つの部分積の加算に使用される32個の全加算器のうちの8個に、図22に示される示される論理ゲート2208〜2215とセレクタ2216〜2224と同じものを、全加算器2200〜2207と同じ接続関係で、追加することによって、負数の部分積の生成と加算が実現できる。論理ゲートとセレクタが追加される全加算器は、部分積8については、下位1ビット目〜8ビット目、部分積16については、9ビット目〜16ビット目、部分積24については、17ビット目〜24ビット目に、部分積32については、25ビット目〜35ビット目に対応する全加算器である。
【0107】
32ビット乗算の部分積加算で、部分積8と9、部分積16と17、部分積24と25の間で、加算結果の伝播をさせないようにする必要がある。また、部分積9〜16においては、下位8ビット(図中の斜線部分)を「0」とし、部分積17〜24においては、下位16ビット(図中の斜線部分)を「0」とし、部分積25〜32においては、下位24ビット(図中の斜線部分)を「0」とする。こらの機能により、4つの乗算の部分積加算の結果は、他と影響しあわず、そのため、4つの乗算の部分積加算が、並列に実行することができる。
【0108】
次に、図11に、4つの乗算の部分積加算の結果が、他と影響しあわない、部分積加算器の一部を例示する。
【0109】
図11に、部分積8の加算結果を、部分積9の加算へ伝播させない機能と、部分積9の下位8ビットを「0」にして、部分積1〜8までの加算結果を壊さない機能を実現する回路構成例を示す。
【0110】
全加算器1100〜1107によって、部分積8の13ビット目から6ビット目までに対する加算処理を行なう。
【0111】
また、全加算器1108〜1115によって、部分積9の13ビット目から6ビット目までに対する加算処理を行なう。論理ゲート1116、1120は、信号1133を「0」にすることによって、部分積8の加算結果1128、1129を全加算器1108に入力するのを阻止する機能を有する。論理ゲート1117〜1119、1120〜1123も、同様な動作を行ない、対応する全加算器への加算結果の入力を阻止する機能を有する。
【0112】
なお、信号1133は、4乗算を並列に実行するとき「0」となる。
【0113】
そのため、全加算器1108には、「0」が入力され、部分積9と加算される。これにより、部分積8の加算結果は、部分積9の10ビット目からの加算に使用ができなくなることになる。
【0114】
論理ゲート1124は、信号1142により部分積9の8ビット目に対して加算処理を行なう全加算器1112への入力を阻止する機能を有する。同様に、論理ゲート1125〜1127も、信号1133の入力により、同様の阻止動作をする。
【0115】
信号1142は、4乗算の並列演算のとき「0」となる。そのため、部分積9の8ビットより下位は、「0」となる。
【0116】
これらの構成により、信号1133、1142と、論理ゲート1016〜1127を用いて、部分積8までの加算と、部分積9の加算とを分離することができる。同様に、部分積16と部分積17、部分積24と部分積25の分離も実現できる。したがって、この部分積加算器では、4つの乗算の部分積加算の並列演算が実行できる。
【0117】
また、「シフト アンド セレクタ」901は、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、および「a4×b4+c4」を並列実行する旨の制御信号を受けとって、部分積加算器の結果の上位から16桁ごとに出力される「a1×b1」、「a2×b2」、「a3×b3」、および「a4×b4」のそれぞれに対し、加算値、c1、c2、c3、c4との位取りが正しく合わさるようにする。
【0118】
そのため、図12の1200に示すようにパックされた、c1、c2、c3、c4を、1201に示すように、c1の1ビット目が49桁目に、c2の1ビット目が33桁目に、c3の1ビット目が17桁目に、c4の1ビット目が1桁目にくるように、c1、c2、c3をシフトする。また、1201において、c1、c2、c3、c4のデータの存在しない部分には、値「0」を埋めておく。なお、「a1×b1+c1」、「a2×b2+c2」を並列演算実行しないときには、1200に示すようにパックされたデータをシフトしない。
【0119】
図13に、上位から16ビット単位に「a1×b1」、「b2×b2」、「a3×b3」、「a4×b4」の4つの並列乗算の結果(和と桁あげ)と、「シフトアンド セレクタ」で選択された入力の3入力を加算し、和と桁上げの2出力の加算結果を得る3入力全加算器列902の構成の一部を示す。
【0120】
全加算器1300と全加算器1301は、「a3×b3+c3」の演算結果を求める際、下位2ビットの演算に使用される。全加算器1302と全加算器1303は、「a4×b4+c4」の演算結果を求める際、上位2ビットの演算に使用される。
【0121】
論理素子1304は、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、「a4×b4+c4」の並列演算を実行する時に「0」となる信号1305によって、全加算器1302の桁上げ1306を阻止する。
【0122】
図では、「a3×b3+c3」と「a4×b4+c4」を演算する手段の中間部の構成を示したが、「a1×b1+c1」と「a2×b2+c2」を演算する手段の中間部、「a2×b2+c2」と「a3×b3+c3」を演算する手段の中間部にも、同様の構成の論理回路を設け、桁上げを阻止する。
【0123】
これにより、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、「a4×b4+c4」の並列演算を実行しても、4演算間での桁上げによる影響をなくすことができる。また、各乗算の境界において生じた桁上げは、オーバーフロー/アンダーフローの判定に使用するため、オーバーフロー/アンダーフロー判定部に送る。
【0124】
図14に、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、「a4×b4+c4」の積和演算の、各乗算値の境界での桁上げの阻止機能を有する64ビット加算器の構成の一部を示す。全加算器1400と1401は、「a3×b3+c3」の演算結果を求める際、下位2ビットの演算に使用される。
【0125】
全加算器1402と全加算器1403は、「a4×b4+c4」の演算結果を求める際、上位2ビットの演算に使用される。論理ゲート1404は、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、および「a4×b4+c4」の並列演算を実行する時に「0」となる信号1405によって、全加算器1402の桁上げ1406を阻止する。
【0126】
図14では、「a3×b3+c3」、「a4×b4+c4」を演算する手段の中間部の構成を示したが、「a1×b1+c1」と「a2×b2+c2」を演算する手段の中間部、「a2×b2+c2」と「a3×b3+c3」を演算する手段の中間部にも、同様の構成の論理回路を設け、桁上げを阻止する。
【0127】
これにより、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、「a4×b4+c4」の並列演算を実行しても、4演算間で、桁上げによる他の演算結果への影響をなくすことができる。また、各演算の境界に生じた桁上げは、オーバーフロー/アンダーフローの判定に使用するために、オーバーフロー/アンダーフロー判定部に送る。
【0128】
次に、図15に、オーバーフロー/アンダーフロー判定部の構成を示す。
【0129】
1500、1501、1502、1503は、それぞれ「a1×b1+c1用判定部」、「a2×b2+c2用判定部」、「a3×b3+c3用判定部」、「a4×b4+c4用判定部」である。
【0130】
1307〜1310は、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、「a4×b4+c4」の演算を並列実行した3入力全加算器列902によって求められる、各演算結果間における桁上げデータである。
【0131】
1407〜1410は、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、「a4×b4+c4」の演算を並列実行した64ビット加算器903によって求められる、各演算結果間における桁上げデータである。
【0132】
各判定部は、対応する演算の桁上げデータ2つと、64ビット加算器903の出力の対応する演算結果とから、8ビットに演算精度を制限していない演算結果を生成し、予め定めてある、8ビット用上限値および8ビット用下限値とを比較して、演算結果がオーバーフローとなるか、あるいは、アンダーフローとなるかを判定し、判定結果を出力する。
【0133】
例えば、「a1×b1+c1用判定部」1500は、桁上げ1307と、1407を加算する。
【0134】
その加算結果1504と、64ビット加算器の出力の下位16ビット1505とを、1504が上位にくるように連結し、18ビットの演算結果を生成する。
【0135】
新しくできた演算結果1506と、予め定めてある、8ビット用上限値および8ビット用下限値とを比較してオーバーフローとアンダーフローを判定し、判定結果1507を出力する。同様に、判定部1501、1502、1503も、オーバーフロー、アンダーフローの判定を行ない、判定結果をそれぞれ、1508、1509、1510として出力する。
【0136】
また、32ビット用判定部は、64ビット加算器の出力の下位32ビットを、予め定めた32ビット用上限値および32ビット用下限値と比較し、演算結果のオーバーフロー、アンダーフローを判定し、判定結果1511を出力する。
【0137】
次に、図16に、通常の積和演算の場合と、今まで述べてきた「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、および「a4×b4+c4」の並列演算実行の場合の、2つ場合に対応できるように、64ビット加算器903の出力状態(1601からのデータの取り出し方)を制御する機能を有するアライナ904の構成図を示す。 信号1600は、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、および「a4×b4+c4」の並列演算実行時で「0」となり、通常の積和演算時に「1」となる信号である。
【0138】
セレクタ1608は、データ1602(1601の下位56ビット目から下位49ビット目)とデータ1603(1601の下位32ビット目から下位25ビット目)のうち、信号1600が「1」のときデータ1603選択し、また、信号1600が「0」のときデータ1602を選択する。また、セレクタ1609は、データ1604(1601の下位40ビット目から下位33ビット目)とデータ1605(1601の下位24ビット目から下位17ビット目)のうち、信号1600が「1」のときデータ1605を選択し、また、信号1600が「0」のときデータ1604を選択する。
【0139】
さらに、セレクタ1610は、データ1605(1601の下位24ビット目から下位17ビット目)とデータ1606(1601の下位16ビット目から下位9ビット目)のうち、信号1600が「1」のときデータ1606を選択し、また、信号1600が「0」のときデータ1605を選択する。
【0140】
なお、データ1607(1601の下位8ビットのデータ)は、信号1600による選択制御を行なわない。この結果、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、および「a4×b4+c4」の並列演算実行時では、信号1600が「0」となるので、レジスタの領域d1、d2、d3、d4のそれぞれに、データ1602、1604、1605、1607が格納され、32ビットデータが、1611に示すようにパックされる。また、通常の積和演算では、データ1603、1605、1606、1607が格納され、1612に示すような32ビットデータが格納される。
【0141】
64ビット加算器の出力は、図16に示すアライナで、信号1600が、並列積和演算示す場合、即ち信号1600が「0」のときは1611、通常の32ビット積和演算の場合、即ち信号1600が「1」のときは1612のように、32ビットのデータに変換される。
【0142】
次に、最大値/最小値置換部906は、オーバーフロー/アンダーフロー判定部905からの判定信号を受けて、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、「a4×b4+c4」の並列演算実行時では、各演算結果に対して、所定の処理を行なう。
【0143】
所定の処理としては、例えば、判定結果がオーバーフローであれば、演算結果を、予め定めた、8ビットで表わされる最大値に置き換え、判定結果がアンダーフローであれば、演算結果を、予め定めた、8ビットで表わされる最小値に置き換え、また、いずれでもなければ、演算結果を置き換えずにそのまま出力する処理が考えられる。
【0144】
また、通常の積和演算時には、判定結果がオーバーフローであれば、演算結果を、予め定めた、32ビットで表わされる最大値に置き換え、判定結果がアンダーフローであれば、演算結果を、予め定めた、32ビットで表わされる最小値に置き換え、いずれでもなければ、演算結果を置き換えずにそのまま出力する処理をすればよい。
【0145】
上述のような構成により、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、および「a4×b4+c4」の各演算が分離して行なえ、32ビットの汎用の積和演算器を使用して、「a1×b1+c1」、「a2×b2+c2」、「a3×b3+c3」、および「a4×b4+c4」の各演算の並列実行が可能となる。
【0146】
もちろん、演算ビット数を考慮して本発明の技術的思想を適用することにより、本実施例により示した「32ビット×32ビット」の部分積和演算のみならず、他のビット数での部分積和演算を実行することができる。
【0147】
図17は、本発明にかかる積和演算器、または、乗算器を備えるマイクロプロセッサに対する命令コードの態様である。オペコード1700〜1703は、演算の種類によって定義される。また、オペランド1704〜1707は、演算に使われるデータのソースレジスタとターゲットレジスタを指定する。
【0148】
オペコード1700と1702は、それぞれ並列演算を行ない、同時に、複数の乗算または積和演算を行なうときに使用する。また、オペコード1701と1703は、それぞれ、通常の乗算または積和演算を行なうときに使用する。
【0149】
2データの並列演算を例にとり説明すると、オペコード1700「SplitMPY」は、a1、a2がパックされているソースレジスタr1と、b1、b2がパックされているソースレジスタr2に格納されている、データa1、a2、b1、b2を使用して、乗算「a1×b1」および「a2×b2」を並列に行ない、結果を、ターゲットレジスタr3に格納する命令である。
【0150】
また、オペコード1702「SplitMPYADD」は、a1、a2がパックされているソースレジスタr1と、b1、b2がパックされているソースレジスタr2と、c1、c2がパックされているソースレジスタr3(r3は、ターゲットレジスタを兼ねる)に格納されている、データa1、a2、b1、b2、c1、c2を使用して、積和演算「a1×b1+c1」および「a2×b2+c2」を並列に行ない、結果を、ターゲットレジスタを兼ねるレジスタr3に格納する命令である。
【0151】
なお、4データの並列演算も、データ数と並列演算の実行数が異なるだけであり、同様に、命令コードを設定することができる。
【0152】
一方、オペコード1701「ConnectMPY」は、1705に示されるレジスタr1とr2の値(値を、それぞれR1、R2とする)を用いて、乗算「R1×R2」を行ない、結果をレジスタr2に格納する命令である。また、1703「ConnectMPYADD」は、1707に示されるレジスタr1、r2、r3の値(値を、それぞれR1、R2、R3とする)を用いて、積和演算「R1×R2+R3」を行ない、結果を、ターゲットレジスタを兼ねるレジスタr3に格納する命令である。
【0153】
オペコード1703のみを有するアーキテクチャでは、「a1×b1+c1」および「a2×b2+c2」の演算を実行する場合、2度命令する必要があるが、前述のように、オペコード1702を定義して、並列演算させることにより、並列の積和演算「a1×b1+c1」および「a2×b2+c2」を、1度の命令で実行させることが可能となる。
【0154】
また、乗算についても、同様に、オペコード1700を定義することで、オペコード1701を使用する場合に比べて、必要な命令数が少なくなる。
【0155】
これによりプログラムが短くなり、プログラムはメモリに記憶されるため、これらの命令を使用すればメモリの容量を少なくすることが可能となり、本発明にかかる積和演算器等がマイクロプロセッサの構成要素となるときに、有効である。
【0156】
次に、図18に、本発明にかかる他の実施例を示す。
【0157】
図18は、本発明にかかる、乗算器(例えば、「a1×b1」なる演算を行なう手段)および積和演算器(例えば、「a1×b1+c1」なる演算を行なう手段)のうち少なくとも一方を備えたマイクロプロセッサ1800を有したシステムの構成図である。
【0158】
記憶装置には、マイクロプロセッサ1800が実行する処理を定めるプログラムや、必要なデータ等が記憶されている。本システムにおいて、マイクロプロセッサ1800が、前記プログラムにしたがって、ある画像処理を行なっているものとする。また、画像処理された画像は、CRT等によって実現される表示装置1802に表示される。このような表示処理は、マイクロプロセッサ1800が、予め定められているプログラムにしたがって行なわれる。
【0159】
さて、画像処理においては、積和演算を頻繁に実行する必要があり、積和演算に必要なデータは、記憶装置1801に記憶されているものとする。
【0160】
積和演算器1803は、本発明にかかる積和演算器であり、複数個の積和演算を並列に実行する。
【0161】
マイクロプロセッサ内のレジスタ1804が、記憶装置1801に記憶されているデータを使用して積和演算を行なうことを想定する。
【0162】
プログラムにより積和演算の実行が指示された場合、マイクロプロセッサ1800は、記憶装置1801にアクセスし、バス1805を介して、積和演算に必要なデータを、自己が備えるレジスタ1804に保持する。1回の、積和演算に必要なデータのみをアクセスしてもよいが、通常、一度に複数個の積和演算が行なわれるので、該当するデータを、すべてレジスタ1804に保持しておく。なお、レジスタ1804に保持される、被乗数データ(a1、a2、a3、a4)、乗数データ(b1、b2、b3、b4)、加算データ(c1、c2、c3、c4)の例を図18の左側に示す。図では、1回の積和演算を行なうための1組のデータを示したが、通常、複数組のデータを保持しておく。
【0163】
そして、次に、積和演算器が起動する。まず、レジスタ1804内の、積和演算に必要な全てのデータをソースバスを介して、取り込む。
【0164】
積和演算器は、取り込んだデータに基づいて、前述した積和演算を行ない、演算結果を順次、ターゲットバスを介して、レジスタ1804の空きエリアに送り、保持させる。もちろん、演算結果を後に使用するような画像処理を行なう場合、記憶装置1801に記憶することも考えられる。
【0165】
本発明にかかる積和演算器は、同時に複数種類の積和演算を行なうことができるため、画像処理の処理速度は、著しく向上する。
【0166】
複数の積和演算を並列に繰り返して実行できるため、例えば、積和演算を繰り返して行い、画像処理において頻繁に行なわれる処理である、離散コサイン変換等の処理に対しても高速な処理が行なえる。
【0167】
以上のように、本発明にかかる積和演算器(乗算器)を組み込んだマイクロプロセッサを実現し、該マイクロプロセッサ使用することにより、例えば、高速に画像処理を行なうことが可能なシステムを構築できる。もちろん、システムが対象とする処理内容は、画像処理に限られず、多量の積和演算を行なう処理であれば、いかなるものでもよい。
【0168】
【発明の効果】
以上述べたように、本発明によれば、複数の積和演算を並列に実行できるため、複数の積和演算を極めて高速に行なえる。
【図面の簡単な説明】
【図1】本発明にかかる実施例の構成図である。
【図2】乗算の符号拡張と分離機能の説明図である。
【図3】部分積加算器の符号拡張機能を実現するための手段の構成図である。
【図4】部分積加算器の分離機能を実現するための手段の構成図である。
【図5】「シフト アンド セレクタ」の動作の説明図である。
【図6】オーバーフロー/アンダーフロー判定部の構成図である。
【図7】アライナの構成図である。
【図8】最大値/最小値の置き換え処理の説明図である。
【図9】本発明にかかる他の実施例の構成図である。
【図10】乗算の符号拡張と分離機能の説明図である。
【図11】部分積加算器の構成図である。
【図12】「シフト アンド セレクタ」の動作の説明図である。
【図13】3入力全加算器列の構成図である。
【図14】64ビット加算器の構成図である。
【図15】オーバーフロー/アンダーフロー判定部の構成図である。
【図16】アライナの構成図である。
【図17】積和演算用の命令の説明図である。
【図18】本発明にかかる他の実施例の構成図である。
【図19】従来の乗算処理の説明図である。
【図20】従来の部分積加算器の説明図である。
【図21】全加算器の入出力関係の説明図である。
【図22】負数部分積加算機能を実現する手段の構成図である。
[0001]
[Industrial applications]
The present invention relates to means for performing arithmetic processing such as product-sum operation used in image processing or the like at high speed.
[0002]
[Prior art]
2. Description of the Related Art Conventionally, in the field of image processing (image processing), high-speed, high-precision, etc., high-level arithmetic performance is required when performing arithmetic processing. The company has produced a dedicated arithmetic unit for arithmetic processing and applied it to image processing.
[0003]
If such a dedicated arithmetic unit is manufactured according to the content of the image processing, and a system for performing the image processing is designed and manufactured, the cost of the system will increase.
[0004]
On the other hand, the performance of general-purpose processors that can be constructed at relatively low cost and can be applied to image processing has improved, but the more general processing is performed by the built-in arithmetic unit in the general-purpose processor, the more general-purpose processors The processing speed and processing content of the arithmetic unit built therein are not excellent.
[0005]
By the way, a so-called product-sum operation, which is an arithmetic process frequently performed in image processing, can be executed by an arithmetic unit configured by appropriately combining a multiplier and an adder.
[0006]
In such a conventional arithmetic unit, a multiplier for multiplying a given two numbers has a function of generating a partial product and a function of adding a partial product.
[0007]
Here, generation of a partial product and partial product addition will be described with reference to FIG.
[0008]
Here, the number of bits of data used for multiplication is 5 bits.
[0009]
The “partial product” is obtained by examining the bits of the multiplier 1901 bit by bit. If the bit content is “1”, it is the value of the multiplicand 1900 itself, and if the bit content is “0”, the partial product is calculated. It is set to “0”.
[0010]
However, the partial product generated by the sign bit of the multiplier 1901 is, if the sign bit content is “1”, the sum of the bit inversion of the multiplicand 1901 and the addition 1, and if the sign bit is “0”, it is “0”. I do.
[0011]
In FIG. 19, the partial product is represented by being surrounded by a rectangle, and its contents are shown in the rectangle.
[0012]
In the 5-bit multiplication, since the number of bits of the multiplier is 5 (bits), five partial products are generated as shown in FIG. In the calculation example shown in the figure, the partial product 1 (1902) and the partial product 2 (1903) are generated when their contents of the bit to be examined are “1”. Become.
[0013]
In addition, the partial product 3 (1904) and the partial product 4 (1905) become “0” because the content of the bit to be examined is “0” at the time of generation, and the partial product 5 (1906) becomes , And the sign bit to be examined at the time of generation is “1”, so that the multiplicand is a negative number.
[0014]
The addition of each partial product is performed by shifting the partial product one bit at a time to the upper (left) side in the order of generation from the lower bits of the multiplier, and then adding the products. In addition, when the multiplier and the multiplicand are expressed in negative numbers, that is, in a so-called two's complement expression, in order to correctly execute the partial product addition, the sign must be extended (hereinafter, referred to as “sign extension”) and added. Must.
[0015]
In the example shown in FIG. 19, the partial product 1 is extended by 4 bits (1907), the partial product 2 is extended by 3 bits (1908), the partial product 3 is extended by 2 bits (1909), and the partial product 4 is extended , One bit extended (1910). By such sign extension, accurate partial product addition can be performed.
[0016]
Usually, this partial product addition is performed using a carry save adder and a carry propagation adder as shown in FIG. The partial product adder shown in FIG. 20 is a carry save adder configured by arranging three-input full adders.
[0017]
FIG. 21 shows the operation of the three-input full adder, which is a basic component of the partial product adder.
[0018]
The 3-input full adder adds the input 3 bits (2100, 2101, 2102) and outputs a carry 2104 and a sum 2103.
[0019]
As shown in FIG. 21, three values are input, and in a predetermined case, carry output (2104) is performed and addition (2103) is performed.
[0020]
In a full adder (2000, 2001, 2002, 2003, 2004) which is an adder having a carry-save function shown in FIG. 20, partial products 1 to 3 shown in FIG. Perform the addition of The "carry" of the result of the addition performed by each full adder is sent to the next-stage full adder of the next digit, and the "sum" is sent to the next-stage full adder (2010, 2011, etc.). And performs addition with the partial product 4 shown in FIG. Further, the result is input to a full adder (2012 or the like) used for adding the partial product 5, and is added.
[0021]
Since the partial product 5 needs to invert the value of the multiplicand and add “1”, the input 2013 of the full adder 2012 is used as an input for adding 1.
[0022]
As an example, the first-stage full adder 2000 includes an extension code 2005 (value is “1”) of the partial product 1, an extension code 2006 (value is “1”) of the partial product 2, and a code of the partial product 3. 2007 (the value is “0”) is input and addition is performed.
[0023]
Then, the carry 2008 of the addition result is inputted to the next-stage full-adder 2010 one digit higher, and the sum 2009 is inputted to the next-stage full adder 2011 of the same digit.
[0024]
Full adder 2010 receives the carry and sum of the addition results of the extension codes of partial products 1 to 3 and performs addition. Since the full adder 2014 that generates the input signal performs the same calculation as the full adder 2000, the addition result 2009 of the full adder 2000 is used as an input of the full adder 2010, and as a result, the full addition The adder 2000 performs the addition of the upper digit, that is, the full adder 2014 existing on the left side can be omitted.
[0025]
As described above, the adder having the carry save function sends “carry” to the next stage and repeats the addition. Therefore, even if the addition of all partial products is completed, two outputs 2024 to 2038 remain. Therefore, in order to obtain the final result, a so-called carry propagation adder as shown in FIG. 20 is required to further add the two outputs.
[0026]
In the configuration shown in FIG. 20, the carry propagation adder includes full adders 2015 to 2022. As an example, the connection between these full adders has a connection relationship such that the carry 2023 of the full adder 2016 becomes an input of the full adder 2015, and literally constitutes a carry propagation adder. ing.
[0027]
[Problems to be solved by the invention]
As described above, for example, in the sum-of-products arithmetic unit shown in FIG. 20, not only an adder having a carry-save function, but also a carry propagation adder must be provided to realize the sum-of-products arithmetic unit. Did not.
[0028]
As described above, when the operation is performed using the conventional dedicated operation unit, the processing performance is satisfied, but the cost of the system is increased in most cases. On the other hand, although the use of the general-purpose arithmetic unit can suppress an increase in cost, there still remains a problem that its processing performance is not satisfactory.
[0029]
However, since the use of a general-purpose arithmetic unit is indispensable for cost reduction, it is necessary to improve the processing performance of the general-purpose arithmetic unit.
[0030]
Therefore, an object of the present invention is to provide a means for independently operating a part of a multiply-accumulate unit frequently used in image processing or the like among general-purpose arithmetic units included in a general-purpose processor, thereby enabling a plurality of multiply-accumulate operations to be performed. It is an object of the present invention to provide a computing means which can be used for high-speed image processing or the like, in which the cost is suppressed, the computation speed is high, and the cost is reduced.
[0031]
[Means for Solving the Problems]
To solve the above problems and achieve the object of the present invention, the following means are conceivable.
[0032]
An arithmetic unit for obtaining a product of a number of N bits having a plurality of multiplicands and a number of M bits having a plurality of multipliers corresponding to each of the multiplicands to obtain a multiplication result for a set of a multiplicand and a multiplier, An arithmetic unit comprising the means of (1).
[0033]
That is, a first register that holds a plurality of multiplicands and is arranged on condition that the sum of bit lengths of each multiplicand does not exceed N, and holds the number of N bits with 0 embedded between each multiplicand And the multipliers corresponding to the respective multiplicands are arranged, provided that the sum of the bit lengths of the respective multipliers does not exceed M, and the number of M bits is held with 0 embedded between the multipliers. A second register, a partial product processing unit for performing a process of obtaining a partial product of the value held in the first register and the value held in the second register, and a set of multiplicands in the partial product. A sign extension unit for embedding bits obtained by expressing the multiplication result in two's complement to compensate for the sign of the multiplication result of the multiplier, and a means for sequentially calculating the sum of each partial product; The sum of all partial products for If obtained, the excess value is discarded when calculating the sum of partial products for the next other set of multiplicands and multipliers, summing means for calculating the sum value of each partial product, From the data of the sum value (“N + M” (bits)), a value that is the result of multiplication of each multiplicand in the first register and the corresponding multiplier in the second register is cut out and corresponds to a set of the multiplicand and the multiplier. Processing means for obtaining a multiplication result for each set.
[0034]
[Action]
The present invention relates to a general-purpose sum-of-products arithmetic unit, which has a function of separating and simultaneously performing multiplication on each data stored in an input register or the like, and adding a multiplication result to each multiplication result. Are provided with an adder having a function of separating and simultaneously performing the operations.
[0035]
First, a plurality of multiplicands are held in the first register, arranged under the condition that the sum of the bit lengths of the multiplicands does not exceed N, and the number of N bits is written with 0 embedded between the multiplicands. Keep it. The second register holds a plurality of multipliers corresponding to the multiplicand, and arranges them on condition that the sum of the bit lengths of the multipliers does not exceed M, and embeds 0 between the multipliers. , M bits are held.
[0036]
Next, the partial product processing unit performs a process of obtaining a partial product of the value held in the first register and the value held in the second register, and the sign extension unit performs one set in the partial product. In order to compensate for the sign of the result of the multiplication of the multiplicand and the multiplier, a process of embedding bits obtained by expressing the result of the multiplication in 2's complement is performed.
[0037]
Then, the summation means sequentially calculates the sum of the partial products, and when the sum of all the partial products for a certain set of the multiplicand and the multiplier exceeds a predetermined value, the exceeded value is replaced with the value of the next other set. The sum of the partial products to be discarded when the sum of the partial products for the multiplicand and the multiplier is obtained is obtained.
[0038]
Finally, the processing means multiplies each multiplicand in the first register by a corresponding multiplier in the second register from the data of the sum (“N + M” (bits)) obtained by the summing means. A value is cut out, a multiplication result corresponding to a set of a multiplicand and a multiplier is obtained for each set, and a parallel operation is realized.
[0039]
【Example】
Hereinafter, embodiments of the present invention will be described with reference to the drawings.
[0040]
FIG. 1 shows a configuration diagram of an embodiment according to the present invention.
[0041]
The present embodiment is an arithmetic unit for simultaneously executing the operations “a1 × b1 + c1” and “a2 × b2 + c2”.
[0042]
The entire arithmetic unit is composed of two multiplicands a1 and a2 packed in the register 100 (the state in which data is packed is expressed as follows) and two multipliers b1 and b1 packed in the register 101. b2 as inputs 102 and 103, respectively, and a partial product adder 104 having a function of adding partial products generated based on these inputs.
[0043]
Further, the two addends c1 and c2 packed in the register 105 are used as an input 106, and the input data is added to two outputs “a1 × b1” and “a2 × b2” of the partial product adder 104. , A shift-and-selector 107 having the function of shifting the contents of the input 106 and aligning the two outputs of the partial product adder 104 with each other, A three-input full adder sequence 108 having a function of adding the two outputs and the output of the "shift and selector"107; a 64-bit adder 109 having a function of adding the two outputs of the three-input full adder sequence; An aligner 110 for converting the output of the bit adder 109 into a specified format, and an overflow for determining whether the addition result is an overflow or an underflow. The flow / underflow determination unit 111 determines whether the output of the aligner 110 is the maximum value if the determination result is an overflow, and the maximum / minimum value that replaces the output of the aligner 110 with the minimum value if the determination result is an underflow. And a value substitution unit 112. Then, the final operation result is output in a state packed in the register 150.
[0044]
In the embodiment of FIG. 1, the operation of each component when performing the product-sum operation of “a1 × b1 + c1” and “a2 × b2 + c2” is described in the upper 8 bits and the lower 8 bits of a register having a data length of 32 bits. The case where two data are packed will be described as an example.
[0045]
As for the data for which the product-sum operation is performed, two data a1 and a2 are packed in upper 8 bits and lower 8 bits of 32 bits as in a data format 200 shown in FIG. 2, and a “0” value is embedded between them. , 32-bit data.
[0046]
Similarly, data b1, b2, c1, and c2 (not shown) are packed with two data in the upper 8 bits and lower 8 bits of 32 bits, and a “0” value is embedded between them to form a 32-bit data. And
[0047]
By multiplying the 32-bit data packed with the data a1 and a2 and the 32-bit data packed with the data b1 and b2 with the 32-bit data, the multiplication of the packed 8-bit data, that is, , “A1 × b1” and “a2 × b2” are simultaneously executed.
[0048]
FIG. 2 shows which part of the result of the 32-bit multiplication corresponds to the multiplication “a1 × b1” and “a2 × b2”. In FIG. 2, each partial product is represented by a horizontally long rectangle.
[0049]
The multiplication “a1 × b1” is the upper 15 digits of each of the partial products 25 (203) to 32 (204), and the multiplication “a2 × b2” is the partial product 1 (201). Calculated using the lower 15 digits of each, up to product 8 (202). Therefore, the portion painted black in the drawing is a portion in which the signs of the multiplication “a1 × b1” and “a2 × b2” are extended. The concept of sign extension is as shown in FIG.
[0050]
Further, since the value “0” is embedded between the multiplier data b1 and b2, the partial products 9 to 24 generated from those bits (the value is “0”) are always “0”. Therefore, when all the partial products are added, it is possible to eliminate the influence on the multiplication “a1 × b1” caused by the propagation of the carry resulting from the partial product addition by a2 × b2.
[0051]
Also, by setting the addition of the sign extension for 32-bit of the partial product 25 used in the addition of the partial product 25 to “0”, the addition of the sign extension for the 32-bit multiplication (partial product 1 The addition results corresponding to (1) to (8) can be eliminated from affecting the calculation result of “a1 × b1”.
[0052]
By devising these two points, “a1 × b1” and “a2 × b2” can be calculated in a separated state.
[0053]
Next, the operation of the partial product adder 104 having the functions described above will be described in detail.
[0054]
FIG. 3 shows a configuration example in which the function of the extension code of multiplication a2 × b2 is realized by a general-purpose partial product adder.
[0055]
As shown in FIG. 2, the range in which the extension code of this multiplication is required is from the ninth digit to the fifteenth digit in “partial product 1”, from the tenth to fifteenth digit in “partial product 2”, In "partial product 3", from the 11th to the 15th digit, in "partial product 4", from the 12th to the 15th digit, and in "partial product 5", from the 13th to the 15th digit, the "partial product" 6 "is the 14th to 15th digits, and" Partial Product 7 "is the 15th digit.
[0056]
FIG. 3 illustrates a portion corresponding to the partial products 3 to 5 as an example.
[0057]
The operation of each full adder is as shown in FIG.
[0058]
The full adders 300 to 305 perform addition of the 15th to 10th digits of the partial product 3, and the full adders 306 to 311 perform addition of the 15th to 10th digits of the partial product 4. To 317 are used for the addition of the 15th to 10th digits of the partial product 5, respectively.
[0059]
If the signal 330 is “1”, the selector 318 selects 332 out of the two inputs 331 and 332. The other selectors 319 to 321 operate similarly. Since 332 is the sign of the partial product 3 of the multiplication “a2 × b2”, by signifying the signal 330 to “1”, the sign is extended by the signal 332 for expressing the sign and the full adder The partial product 3 can be added.
[0060]
The selectors 323 to 326 and the selectors 327 to 329 also select the codes 333 and 334 of the partial products 4 and 5, respectively, by setting the signal 330 to “1”. As a result, sign-extended addition can be realized for the partial products 4 and 5 as well.
[0061]
In addition, although not shown in FIG. 3, for the partial products 1, 2, 6, and 7, a selector for selecting a signal for sign extension by the signal 330 is provided on the input side of the full adder. With this configuration, sign-extended addition can be realized by partial product addition of multiplication “a2 × b2”.
[0062]
FIG. 22 is an implementation example of a general-purpose partial product adder for generating a partial product 8 from the sign bit (eighth bit from the lower order) of the multiplier b2. Full adders 2200 to 2207 add the lower 8 bits of partial product 8. In order to generate a partial product from a sign bit, as shown in FIG. 19, this is a configuration for realizing a process of inverting data and adding “1”.
[0063]
The logic gate 2208 has a function of inverting the input 2227 when the signal 2225 is “1” and outputting “1” regardless of the value of the input 2227 when the signal 2225 is “0”. The selector 2216 has a function of selecting the output of the logic gate 2208 when the signal 2226 is “1”, and selecting the data 2227 of the eighth bit from the lower order of the partial product 8 when the signal 2226 is “0”. .
[0064]
The “logical gate 2208 and selector 2216” and the “logical gates 2209 to 2215 and selectors 2217 to 2223” operate in the same manner. The selector 2224 outputs “1” when the signal 2226 is “1”.
[0065]
By setting the signal 2226 to “1” using the logic gates 2208 to 2215 and the selectors 2216 to 2224, generation and addition of the partial product 8 of the multiplication “a2 × b2” can be realized. Other partial products can be similarly generated and added. As described above, the configurations shown in FIGS. 3 and 22 can execute the operation of the partial product addition of the multiplication “a2 × b2”.
[0066]
Next, the means having the configuration shown in FIG. 4 is used to eliminate the influence on the multiplication “a1 × b1” due to the result of addition (addition of partial products 1 to 8) for sign extension for performing 32-bit multiplication. This function will be described below.
[0067]
First, a process of adding the values of the 32nd to 25th digits of the partial product 25 (the partial product 1 of the multiplication “a1 × b1” (the partial product 25 in FIG. 2)) by the full adders 400 to 407 is performed. . The full adders 408 to 414 output the addition results up to the partial product 24.
[0068]
The logic gate 415 has a function of setting the sum 433 of the full adder 408 to “0” when the signal 431 is “0”. Similarly, the logic gates 416 to 422 also have a function of setting the sum of the full adders 409 to 414 to “0” when the signal 431 is “0”. The logic gate 423 has a function of setting the carry 432 of the full adder 408 to “0” when the signal 431 is “0”.
[0069]
Similarly, the logic gates 424 to 430 also have a function of setting the carry of the full adders 409 to 414 to “0” when the signal 431 is “0”. When the signal 431 is “1”, the logic elements 415 to 430 have a function of passing the carry and sum values from the full adders 408 to 414 as they are.
[0070]
That is, by setting the signal 431 to “0”, it is possible to control the addition processing of the addition result up to the partial product 24 and the partial product 25. This makes it possible to eliminate the influence on the multiplication “a1 × b1” due to the addition of the sign extension for 32-bit multiplication (addition of partial products 1 to 8).
[0071]
The provision of the means having the configuration shown in FIGS. 3, 22, and 4 described above allows the partial product adder 104 to execute “a1 × b1” and “a2” in the same processing as ordinary 32-bit multiplication. × b2 ”can be performed in parallel.
[0072]
Next, “shift and selector” 107 receives control signal 113 instructing parallel execution of “a1 × b1 + c1” and “a × b2 + c2”, and receives the upper 16 digits of the operation result of partial product adder 104 5 so that the scales of c1 and c2 are correctly aligned with the lower 16 digits, respectively, and c1 and c2 packed as shown by 500 in FIG. 5 are shifted as shown by 501, and "0" is set between c1 and c2. Embed.
[0073]
When the operations of “a1 × b1 + c1” and “a2 × b2 + c2” are not executed in parallel, 500 that is not shifted is selected.
[0074]
As shown in FIG. 5, the three-input full adder sequence 108 outputs the output 503 of the carry save adder of the partial product addition of “a1 × b1” and “a2 × b2” to the upper 16 digits and the lower 16 digits. , And the input 501 selected by the “shift and selector” 107, carry-save addition is performed, and an addition result 506 is obtained. In the case of parallel execution of “a1 × b1 + c1” and “a2 × b2 + c2”, in 501, the value “0” is buried between c1 and c2, so the digits between a1 × b1 + c1 and a2 × b2 + c2 Carry does not occur. As a result, the addition of c1 and c2 does not affect each other.
[0075]
FIG. 6 illustrates a configuration example of the overflow / underflow determination unit 111 that determines in parallel whether an operation result executed in parallel is an overflow or an underflow.
[0076]
The upper-order determination unit 600 and the lower-order determination unit 601 respectively convert the upper 16 bits and the lower 16 bits of 506 shown in FIG. 604 is performed.
[0077]
The upper-order determination unit 600 determines that an overflow has occurred when the contents of the upper 16 bits of 506 shown in FIG. 5 are larger than the 8-bit upper limit value 603, and determines that the overflow is smaller than the 8-bit lower limit value 604. Determines that an underflow has occurred. Further, the lower-order determination unit 601 makes the same determination as the upper-order determination unit 600 on the contents of the lower 16 bits of 506 shown in FIG.
[0078]
The 32-bit determining unit 602 uses the lower 32 bits of 506 as a predetermined value, a 32-bit upper limit value 605 and a 32-bit lower limit value 606, respectively, and performs overflow in the case of 32-bit multiplication. , It is determined whether an underflow has occurred. It should be noted that since the upper-order determination unit 600 and the lower-order determination unit 601 operate separately, the determination of overflow and underflow of the upper and lower 16 bits can be performed in parallel.
[0079]
The determination signals 607 and 608 output by the higher-order determination unit 600 become “1” when the upper 16 bits of 506 overflow and underflow, respectively, and the determination signals 609 and 610 output by the lower-order determination unit 601 become When the lower 16 bits of 506 are overflow and underflow, respectively, it becomes “1”, and the determination signals 611 and 612 output by the 32-bit determination unit 602 are when the lower 32 bits of 506 are overflow and underflow, respectively. It becomes "1".
[0080]
These determination signals 607 to 612 are sent to the maximum / minimum value replacement unit 112 based on the determination results.
[0081]
FIG. 7 shows a case where 64 is used so as to be able to cope with two cases, that is, a case of a normal product-sum operation and a case of executing the parallel operation for obtaining “a1 × b1 + c1” and “a2 × b2 + c2” described above. FIG. 3 shows a configuration diagram of an aligner 110 having a function of controlling an output state of a bit adder 109 (how to extract data from 701).
[0082]
The selector 702 selects “a1 × b1 + c1” between the data 719 (data from the upper 9th bit to the upper 16th bit of 701) and the data 720 (data from the upper 33rd bit to the upper 40th bit of 701). ”And“ a2 × b2 + c2 ”, the control signal 723 becomes“ 0 ”during execution of the parallel operation, and becomes“ 1 ”during normal product-sum operation.
[0083]
Logic gates 703 to 718 (a total of 16 logic gates are shown but two are shown in the figure because of complexity) and are omitted from the control signal 723 are data 721 (lower 24 bits to lower 9 bits of 701). (Up to the first bit) is set to “0” (portion described as 0 value at 724 in the figure).
[0084]
That is, when the parallel operation of “a1 × b1 + c1” and “a2 × b2 + c2” is executed, the control signal 723 becomes “0”. First, the selector 702 selects the data 719, and the d1 part in the figure Secondly, since the logic gates 713 to 718 are AND gates, the data 721 becomes “0”. In addition, since the data 722 does not change, the output of the aligner is like 724.
[0085]
On the other hand, when the control signal 723 becomes “1” during normal product-sum operation, the selector 702 selects the data 720, and the data 721 passes through the logic gates 713 to 718 as it is. Since the data 722 does not change, the output of the aligner is 725.
[0086]
As a result, at the time of executing the parallel operation of “a1 × b1 + c1” and “a2 × b2 + c2”, the operation results d1 and d2 are packed into a 32-bit register like 724.
[0087]
Next, FIG. 8 shows the relationship between the calculation condition and the determination result of the overflow / underflow determination unit 111 and the output of the maximum / minimum value replacement unit 112.
[0088]
The following describes the output mode.
[0089]
First, in the example shown in (1) in FIG. 8, when the operations of “a1 × b1 + c1” and “a2 × b2 + c2” are executed simultaneously, and when the result on the upper side is determined to overflow, the upper output The maximum value (max) which is a predetermined value is output to 8 bits, and the lower 8 bits of the output output the operation result as it is.
[0090]
In the example shown in (2) in FIG. 8, when the upper result is determined to be an underflow, a predetermined minimum value (min) is output to the upper 8 bits of the output, The lower 8 bits of the output output the operation result as it is.
[0091]
Further, in the example shown in (3) in FIG. 8, when the result on the lower side is determined to overflow, the maximum value (max) which is a predetermined value is output to the lower 8 bits of the output, The upper 8 bits of the output output the operation result as it is.
[0092]
In the example shown in (4) of FIG. 8, when the lower result is determined to be an underflow, a predetermined minimum value (min) is output to the lower 8 bits of the output, The upper 8 bits of the output output the operation result as it is.
[0093]
Further, when it is determined that an overflow has occurred during normal product-sum execution, a maximum value that is a predetermined value is output to all 32 bits (example shown in FIG. 8 (5)), and it is determined that an underflow has occurred. In such a case, it is conceivable to output a minimum value that is a predetermined value to the entire 32 bits (FIG. 8 (6)).
[0094]
In addition, when the parallel operation of “a1 × b1 + c1” and “a2 × b2 + c2” is executed, or during normal product-sum execution, if neither overflow nor underflow is determined, the input value is output as it is. (Example of FIG. 8 (7)).
[0095]
Next, an example in which data is packed into all 32 bits, for example, an embodiment of a parallel multiply-accumulate unit that packs four 8-bit pixel data will be described with reference to FIG.
[0096]
The configuration of the present embodiment includes a partial product adder 900 for calculating and adding a partial product from four packed multiplicands a1, a2, a3, and a4 and four packed multipliers b1, b2, b3, and b4. , A "shift and selector" 901 for digit-aligning the four packed addends c1, c2, c3, and c4 with the output of the partial product adder 900; A three-input full adder sequence 902 having a function of adding the output of the adder 901 and a 64-bit adder 903 having a function of adding two outputs of the three-input full adder sequence, and the output of the adder is designated. An aligner 904 for converting to a format, an overflow / underflow determination unit 905 for determining whether or not the addition result is an overflow or an underflow; A maximum value / minimum value replacement unit 906 having a function of replacing the output of the aligner 904 with a predetermined value in accordance with predetermined rules.
[0097]
In the embodiment shown in FIG. 9, the operation of performing a plurality of product-sum operations of “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4” is performed with a data length of 32 bits. A case where four 8-bit data are packed will be described as an example.
[0098]
As shown in a data format 1000 shown in FIG. 10, the data on which the product-sum operation is performed constitutes 32-bit data by four data “a1, a2, a3, a4”.
[0099]
Similarly, a1, a2, a3, and a4, and c1, c2, c3, and c4 are also 32-bit data.
[0100]
By multiplying 32-bit data between 32-bit data packed with “a1, a2, a3, a4” and 32-bit data packed with “a1, a2, a3, a4”, multiplication of 8-bit data is performed. a1 × b1 ”,“ a2 × b2 ”,“ a3 × b3 ”, and“ a4 × b4 ”are simultaneously executed.
[0101]
At this time, with reference to FIG. 10, which part of the multiplication result of the 32-bit data corresponds to the multiplications “a1 × b1”, “a2 × b2”, “a3 × b3”, and “a4 × b4” respectively. Will be explained.
[0102]
In FIG. 10, each partial product is represented by a rectangle.
[0103]
The values of the multiplications “a1 × b1”, “a2 × b2”, “a3 × b3” and “a4 × b4” are respectively the partial products 25 to 32, the partial products 17 to 24, the partial products 9 to 16, It is obtained by adding the partial products 1 to 8. Therefore, the portions painted black in the figure are portions that become extension codes of the multiplications “a1 × b1”, “a2 × b2”, “a3 × b3”, and “a4 × b4”.
[0104]
For example, in the multiplication “a4 × b4”, the partial product 1 is from the 9th to the 15th digit, the partial product 2 is the 10th to the 15th digit, the partial product 3 is the 11th to the 15th digit, The extension code is the 12th to 15th digits for the product 4, the 13th to 15th digits for the partial product 5, the 14th to 15th digits for the partial product 6, and the 15th digit for the partial product 7. Part.
[0105]
Similarly to the above-described parallel operation of squaring, the partial products 8, 16, 24, and 32 correspond to sign bits, so that a negative number must be created.
[0106]
Eight of the 32 full adders used for the addition of one partial product include the same logic gates 2208 to 2215 and selectors 2216 to 2224 shown in FIG. With the same connection relationship as 2207, generation and addition of a partial product of a negative number can be realized by addition. The full adder to which the logic gate and the selector are added is composed of the lower 1st to 8th bits for the partial product 8, the 9th to 16th bits for the partial product 16, and the 17th bit for the partial product 24. A full adder corresponding to the 25th to 35th bits of the partial product 32 for the 24th to 24th bits.
[0107]
In the partial product addition of the 32-bit multiplication, it is necessary to prevent the propagation of the addition result between the partial products 8 and 9, the partial products 16 and 17, and the partial products 24 and 25. In the partial products 9 to 16, the lower 8 bits (shaded portion in the drawing) are set to "0", and in the partial products 17 to 24, the lower 16 bits (shaded portion in the drawing) are set to "0". In the partial products 25 to 32, the lower 24 bits (shaded portions in the drawing) are set to “0”. With these functions, the result of the partial product addition of the four multiplications does not affect the others, so that the partial product addition of the four multiplications can be performed in parallel.
[0108]
Next, FIG. 11 illustrates a part of the partial product adder in which the result of the partial product addition of the four multiplications does not affect the others.
[0109]
FIG. 11 shows a function that does not propagate the addition result of the partial product 8 to the addition of the partial product 9 and a function that sets the lower 8 bits of the partial product 9 to “0” and does not destroy the addition results of the partial products 1 to 8. An example of a circuit configuration for realizing is shown.
[0110]
The full adders 1100 to 1107 perform addition processing on the 13th to 6th bits of the partial product 8.
[0111]
In addition, full adders 1108 to 1115 perform addition processing on the 13th to 6th bits of partial product 9. The logic gates 1116 and 1120 have a function of preventing the addition results 1128 and 1129 of the partial product 8 from being input to the full adder 1108 by setting the signal 1133 to “0”. Logic gates 1117 to 1119 and 1120 to 1123 perform the same operation, and have a function of preventing the input of the addition result to the corresponding full adder.
[0112]
Note that the signal 1133 becomes “0” when the 4 multiplication is performed in parallel.
[0113]
Therefore, “0” is input to the full adder 1108 and added to the partial product 9. As a result, the result of addition of the partial product 8 cannot be used for addition from the 10th bit of the partial product 9.
[0114]
Logic gate 1124 has a function of blocking input to full adder 1112, which performs addition processing on the eighth bit of partial product 9 by signal 1142. Similarly, the logic gates 1125 to 1127 perform the same blocking operation in response to the input of the signal 1133.
[0115]
The signal 1142 becomes “0” at the time of parallel operation of quadruple multiplication. Therefore, the value lower than 8 bits of the partial product 9 is “0”.
[0116]
With these configurations, addition up to the partial product 8 and addition of the partial product 9 can be separated using the signals 1133 and 1142 and the logic gates 1016 to 1127. Similarly, the separation of the partial products 16 and 17 and the partial products 24 and 25 can be realized. Therefore, this partial product adder can execute parallel operation of partial product addition of four multiplications.
[0117]
The “shift and selector” 901 receives a control signal indicating that “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4” are executed in parallel, and receives a partial product adder. For each of “a1 × b1”, “a2 × b2”, “a3 × b3”, and “a4 × b4” output every 16 digits from the higher order of the result of the above, the added value, c1, c2, c3, Make sure that the scale with c4 matches correctly.
[0118]
Therefore, as shown by 1201, c1, c2, c3, and c4 packed as shown in 1200 in FIG. 12 are converted into the 49th digit in the first bit of c1 and the 33rd digit in the first bit of c2. , C3 are shifted to the 17th digit, and c1, c2, c3 are shifted so that the first bit of c4 is the first digit. In step 1201, a value “0” is embedded in a portion where data of c1, c2, c3, and c4 does not exist. When the parallel operation of “a1 × b1 + c1” and “a2 × b2 + c2” is not performed, the packed data is not shifted as indicated by 1200.
[0119]
FIG. 13 shows the results (sum and carry) of four parallel multiplications of “a1 × b1”, “b2 × b2”, “a3 × b3”, and “a4 × b4” in 16-bit units from the most significant bit, and “shift”. A part of the configuration of a three-input full adder array 902 that adds three inputs selected by the "and selector" and obtains a sum of two outputs of a sum and a carry is shown.
[0120]
The full adder 1300 and the full adder 1301 are used for the operation of the lower two bits when obtaining the operation result of “a3 × b3 + c3”. The full adder 1302 and the full adder 1303 are used for the operation of the upper two bits when obtaining the operation result of “a4 × b4 + c4”.
[0121]
The logic element 1304 generates the digit of the full adder 1302 by the signal 1305 which becomes “0” when the parallel operation of “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4” is executed. The raising 1306 is blocked.
[0122]
In the figure, the configuration of the middle part of the means for calculating “a3 × b3 + c3” and “a4 × b4 + c4” is shown, but the middle part of the means for calculating “a1 × b1 + c1” and “a2 × b2 + c2”, “a2 × A logic circuit having a similar configuration is also provided at an intermediate portion of the means for calculating “b2 + c2” and “a3 × b3 + c3” to prevent carry.
[0123]
As a result, even if the parallel operations of “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4” are executed, the effect of the carry among the four operations can be eliminated. The carry generated at the boundary of each multiplication is sent to an overflow / underflow determination unit for use in determining overflow / underflow.
[0124]
FIG. 14 shows a 64-bit addition having a function of preventing carry at the boundary of each multiplied value in the product-sum operation of “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4”. 2 shows a part of the configuration of the vessel. The full adders 1400 and 1401 are used for the operation of the lower two bits when obtaining the operation result of “a3 × b3 + c3”.
[0125]
The full adder 1402 and the full adder 1403 are used for the operation of the upper two bits when obtaining the operation result of “a4 × b4 + c4”. The logic gate 1404 uses the signal 1405 that becomes “0” when the parallel operation of “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4” is executed, to cause the full adder 1402 Block carry 1406.
[0126]
FIG. 14 shows the configuration of the intermediate part of the means for calculating “a3 × b3 + c3” and “a4 × b4 + c4”. However, the intermediate part of the means for calculating “a1 × b1 + c1” and “a2 × b2 + c2”, “a2 A logic circuit having a similar configuration is also provided at an intermediate portion of the means for calculating “× b2 + c2” and “a3 × b3 + c3” to prevent carry.
[0127]
As a result, even if the parallel operations of “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4” are executed, the effect of the carry on other operation results among the four operations Can be eliminated. Also, the carry generated at the boundary of each operation is sent to an overflow / underflow determination unit for use in determining overflow / underflow.
[0128]
Next, FIG. 15 shows a configuration of the overflow / underflow determination unit.
[0129]
1500, 1501, 1502, and 1503 are “a1 × b1 + c1 determination section”, “a2 × b2 + c2 determination section”, “a3 × b3 + c3 determination section”, and “a4 × b4 + c4 determination section”, respectively.
[0130]
1307 to 1310 are obtained by a three-input full adder sequence 902 that executes the operations of “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4” in parallel. Carry data.
[0131]
Reference numerals 1407 to 1410 denote carry between each calculation result obtained by the 64-bit adder 903 which executes the calculations of “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4” in parallel. Data.
[0132]
Each determination unit generates a calculation result that does not limit the calculation precision to 8 bits from two carry data of the corresponding calculation and the corresponding calculation result of the output of the 64-bit adder 903, and is determined in advance. , And the upper limit value for 8 bits and the lower limit value for 8 bits to determine whether the operation result overflows or underflows, and outputs the determination result.
[0133]
For example, “a1 × b1 + c1 determination unit” 1500 adds carry 1307 and 1407.
[0134]
The addition result 1504 and the lower 16 bits 1505 of the output of the 64-bit adder are concatenated so that 1504 is higher, and an 18-bit operation result is generated.
[0135]
The newly calculated operation result 1506 is compared with a predetermined upper limit value for 8 bits and a lower limit value for 8 bits to determine overflow and underflow, and a determination result 1507 is output. Similarly, the determination units 1501, 1502, and 1503 also determine overflow and underflow, and output the determination results as 1508, 1509, and 1510, respectively.
[0136]
Further, the 32-bit determination unit compares the lower 32 bits of the output of the 64-bit adder with a predetermined upper limit value for 32 bits and a lower limit value for 32 bits, and determines overflow and underflow of the operation result, The judgment result 1511 is output.
[0137]
Next, FIG. 16 shows the case of a normal product-sum operation and the parallel operation execution of “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4” described above. A configuration diagram of an aligner 904 having a function of controlling the output state of a 64-bit adder 903 (how to extract data from 1601) so as to be able to cope with two cases is shown. The signal 1600 becomes “0” when the parallel operation of “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4” is executed, and becomes “1” during the normal product-sum operation. Signal.
[0138]
The selector 1608 selects the data 1603 when the signal 1600 is “1” among the data 1602 (the lower 56 bits to the lower 49 bits of 1601) and the data 1603 (the lower 32 bits to the lower 25 bits of 1601). When the signal 1600 is "0", the data 1602 is selected. When the signal 1600 is “1” among the data 1604 (lower 40th bit to lower 33rd bit of 1601) and data 1605 (lower 24th bit to lower 17th bit of 1601), the selector 1609 outputs the data 1605 Is selected, and when the signal 1600 is "0", the data 1604 is selected.
[0139]
Further, the selector 1610 outputs the data 1606 when the signal 1600 is “1” among the data 1605 (lower 24 bits to lower 17 bits of 1601) and data 1606 (lower 16 bits to lower 9 bits of 1601). Is selected, and when the signal 1600 is "0", the data 1605 is selected.
[0140]
Note that data 1607 (data of lower 8 bits of 1601) is not subjected to selection control by signal 1600. As a result, the signal 1600 becomes “0” during the parallel operation of “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4”, so that the register areas d1 and d2 , D3, and d4, data 1602, 1604, 1605, and 1607 are stored, and 32-bit data is packed as indicated by 1611. In a normal product-sum operation, data 1603, 1605, 1606, and 1607 are stored, and 32-bit data indicated by 1612 is stored.
[0141]
The output of the 64-bit adder is an aligner shown in FIG. 16. When the signal 1600 indicates a parallel product-sum operation, that is, 1611 when the signal 1600 is “0”, and in the case of a normal 32-bit product-sum operation, When 1600 is “1”, the data is converted into 32-bit data, such as 1612.
[0142]
Next, the maximum value / minimum value replacement unit 906 receives the determination signal from the overflow / underflow determination unit 905, and receives “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4”. At the time of execution of the parallel operation of "", predetermined processing is performed on each operation result.
[0143]
As the predetermined processing, for example, if the determination result is an overflow, the calculation result is replaced with a predetermined maximum value represented by 8 bits, and if the determination result is an underflow, the calculation result is set to a predetermined value. , 8 bits, and if none of them, outputs the operation result without replacing it.
[0144]
At the time of normal product-sum operation, if the judgment result is an overflow, the operation result is replaced with a predetermined maximum value represented by 32 bits. If the judgment result is an underflow, the operation result is set at a predetermined value. Alternatively, the processing may be performed by replacing with the minimum value represented by 32 bits, and in any case, outputting the calculation result without replacing it.
[0145]
With the configuration as described above, the operations of “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4” can be performed separately, and a 32-bit general-purpose multiply-accumulate unit can be implemented. By using this, it is possible to execute the respective operations of “a1 × b1 + c1”, “a2 × b2 + c2”, “a3 × b3 + c3”, and “a4 × b4 + c4” in parallel.
[0146]
Of course, by applying the technical idea of the present invention in consideration of the number of operation bits, not only the partial product-sum operation of “32 bits × 32 bits” shown in the present embodiment, but also A product-sum operation can be performed.
[0147]
FIG. 17 shows an example of an instruction code for a microprocessor having a product-sum operation unit or a multiplier according to the present invention. The operation codes 1700 to 1703 are defined by the type of operation. The operands 1704 to 1707 specify a source register and a target register of data used for the operation.
[0148]
The opcodes 1700 and 1702 perform parallel operations, respectively, and are used when performing a plurality of multiplication or multiply-accumulate operations at the same time. Further, the operation codes 1701 and 1703 are used when performing a normal multiplication or a product-sum operation, respectively.
[0149]
Taking the parallel operation of two data as an example, the operation code 1700 “SplitMPY” is obtained by storing the data a1 stored in the source register r1 in which a1 and a2 are packed and the source register r2 in which b1 and b2 are packed. , A2, b1, and b2, the multiplication “a1 × b1” and “a2 × b2” are performed in parallel, and the result is stored in the target register r3.
[0150]
Further, the operation code 1702 “SplitMPYADD” includes a source register r1 in which a1 and a2 are packed, a source register r2 in which b1 and b2 are packed, and a source register r3 (r3 in which c1 and c2 are packed). Using the data a1, a2, b1, b2, c1, and c2 stored in the target register), a multiply-accumulate operation “a1 × b1 + c1” and “a2 × b2 + c2” are performed in parallel. This is an instruction to be stored in the register r3 also serving as a target register.
[0151]
In the parallel operation of four data, only the number of data and the number of executions of the parallel operation are different, and an instruction code can be set similarly.
[0152]
On the other hand, the operation code 1701 “ConnectMPY” performs the multiplication “R1 × R2” using the values of the registers r1 and r2 (the values are R1 and R2, respectively) shown in 1705, and stores the result in the register r2. Instruction. Also, 1703 “ConnectMPYADD” performs a product-sum operation “R1 × R2 + R3” using the values of the registers r1, r2, and r3 shown in 1707 (the values are R1, R2, and R3, respectively), and outputs the result. , An instruction to be stored in a register r3 also serving as a target register.
[0153]
In the architecture having only the operation code 1703, when executing the operations of “a1 × b1 + c1” and “a2 × b2 + c2”, it is necessary to instruct twice. However, as described above, the operation code 1702 is defined and the parallel operation is performed. This makes it possible to execute the parallel product-sum operations “a1 × b1 + c1” and “a2 × b2 + c2” with one instruction.
[0154]
Similarly, for the multiplication, the number of necessary instructions is reduced by defining the operation code 1700 as compared with the case where the operation code 1701 is used.
[0155]
As a result, the program is shortened and the program is stored in the memory.Thus, the use of these instructions makes it possible to reduce the capacity of the memory. It is effective when it becomes.
[0156]
Next, FIG. 18 shows another embodiment according to the present invention.
[0157]
FIG. 18 includes at least one of a multiplier (for example, a unit for performing an operation “a1 × b1”) and a product-sum operation unit (for example, a unit for performing an operation “a1 × b1 + c1”) according to the present invention. 1 is a configuration diagram of a system having a microprocessor 1800.
[0158]
The storage device stores a program that determines processing executed by the microprocessor 1800, necessary data, and the like. In this system, it is assumed that the microprocessor 1800 performs certain image processing according to the program. The processed image is displayed on a display device 1802 realized by a CRT or the like. Such display processing is performed by the microprocessor 1800 according to a predetermined program.
[0159]
Now, in image processing, it is necessary to frequently perform a product-sum operation, and it is assumed that data necessary for the product-sum operation is stored in the storage device 1801.
[0160]
The product-sum operation unit 1803 is a product-sum operation unit according to the present invention, and executes a plurality of product-sum operations in parallel.
[0161]
It is assumed that a register 1804 in a microprocessor performs a product-sum operation using data stored in a storage device 1801.
[0162]
When the execution of the product-sum operation is instructed by the program, the microprocessor 1800 accesses the storage device 1801 and holds data necessary for the product-sum operation in the register 1804 included in the microprocessor 1800 via the bus 1805. Only data necessary for one product-sum operation may be accessed. However, since a plurality of product-sum operations are usually performed at once, all the relevant data is held in the register 1804. Note that examples of multiplicand data (a1, a2, a3, a4), multiplier data (b1, b2, b3, b4), and addition data (c1, c2, c3, c4) held in the register 1804 are shown in FIG. Shown on the left. In the figure, one set of data for performing one product-sum operation is shown, but usually, a plurality of sets of data are held.
[0163]
Then, the product-sum operation unit is activated. First, all the data required for the product-sum operation in the register 1804 is fetched via the source bus.
[0164]
The sum-of-products arithmetic unit performs the above-described sum-of-products calculation based on the fetched data, and sequentially sends the calculation results to the empty area of the register 1804 via the target bus and holds the same. Of course, when performing image processing in which the calculation result is used later, it may be stored in the storage device 1801.
[0165]
Since the product-sum operation unit according to the present invention can simultaneously perform a plurality of types of product-sum operations, the processing speed of image processing is significantly improved.
[0166]
Since a plurality of product-sum operations can be repeatedly executed in parallel, for example, the product-sum operation is repeatedly performed, and high-speed processing can be performed even for processing such as discrete cosine transform, which is frequently performed in image processing. You.
[0167]
As described above, a microprocessor incorporating the product-sum operation unit (multiplier) according to the present invention is realized, and by using the microprocessor, for example, a system capable of performing high-speed image processing can be constructed. . Of course, the processing contents targeted by the system are not limited to image processing, and may be any processing that performs a large amount of product-sum operation.
[0168]
【The invention's effect】
As described above, according to the present invention, since a plurality of sum-of-products operations can be executed in parallel, a plurality of sum-of-products operations can be performed at an extremely high speed.
[Brief description of the drawings]
FIG. 1 is a configuration diagram of an embodiment according to the present invention.
FIG. 2 is an explanatory diagram of sign extension and separation functions of multiplication.
FIG. 3 is a configuration diagram of means for realizing a sign extension function of a partial product adder.
FIG. 4 is a configuration diagram of means for realizing a separating function of a partial product adder;
FIG. 5 is an explanatory diagram of an operation of a “shift and selector”.
FIG. 6 is a configuration diagram of an overflow / underflow determination unit.
FIG. 7 is a configuration diagram of an aligner.
FIG. 8 is an explanatory diagram of a maximum value / minimum value replacement process.
FIG. 9 is a configuration diagram of another embodiment according to the present invention.
FIG. 10 is an explanatory diagram of sign extension and separation functions of multiplication.
FIG. 11 is a configuration diagram of a partial product adder.
FIG. 12 is an explanatory diagram of an operation of a “shift and selector”.
FIG. 13 is a configuration diagram of a three-input full adder array.
FIG. 14 is a configuration diagram of a 64-bit adder.
FIG. 15 is a configuration diagram of an overflow / underflow determination unit.
FIG. 16 is a configuration diagram of an aligner.
FIG. 17 is an explanatory diagram of a product-sum operation instruction.
FIG. 18 is a configuration diagram of another embodiment according to the present invention.
FIG. 19 is an explanatory diagram of a conventional multiplication process.
FIG. 20 is an explanatory diagram of a conventional partial product adder.
FIG. 21 is an explanatory diagram of an input / output relationship of a full adder.
FIG. 22 is a configuration diagram of means for realizing a negative partial product addition function.

Claims (6)

複数の被乗数を有するNビットの数と、前記各被乗数に対応する乗数を有するMビットの数との積を求めることによって、被乗数と乗数との組に対する乗算結果を求める演算器であって、
8ビットの被乗数を複数個保持し、各被乗数のビット長の総和がN(Nは32ビット)を越えないことを条件として配置され、各被乗数の間に0を埋め込んだ状態で、Nビットの数を保持する第1レジスタと、
前記各被乗数に対応する8ビットの乗数を保持し、各乗数のビット長の総和がM(Mは32ビット)を越えないことを条件として配置され、各乗数の間に0を埋め込んだ状態で、Mビットの数を保持する第2レジスタと、
第1レジスタに保持された値と第2レジスタに保持された値との部分積を求めていく処理を行う部分積処理部と、
前記部分積において、1組の被乗数と乗数の、乗算結果の符号を補償するため、乗算結果を2の補数表現したビットを埋込む符号拡張部と、
前記符号拡張部で符号拡張が行われた後、各部分積の和を順次求めていく手段であって、ある組の被乗数と乗数に対する全ての部分積の総和が所定値を越えた場合、該越えた値を、次の他の組の被乗数と乗数に対する部分積の総和を求めていく際に廃棄する、各部分積の総和値を求める総和手段と、
前記総和手段によって求めた、総和値(「N+M」(ビット))のデータから、第1レジスタにおける各被乗数と、これに対応する第2レジスタにおける乗数との乗算結果である値を切り出し、被乗数と乗数との組に対応する乗算結果を、各組について求める処理手段とを有する演算器。
An arithmetic unit for calculating a product of an N-bit number having a plurality of multiplicands and an M-bit number having a multiplier corresponding to each of the multiplicands to obtain a multiplication result for a set of the multiplicand and the multiplier,
A plurality of 8-bit multiplicands are held, arranged under the condition that the sum of the bit lengths of each multiplicand does not exceed N (N is 32 bits) , and N bits are embedded with 0 embedded between each multiplicand. A first register for holding a number;
An 8-bit multiplier corresponding to each of the multiplicands is held, arranged under the condition that the sum of the bit lengths of the respective multipliers does not exceed M (M is 32 bits) , and 0 is embedded between the multipliers. , A second register holding the number of M bits;
A partial product processing unit for performing a process of calculating a partial product of the value held in the first register and the value held in the second register;
A sign extension unit that embeds bits obtained by expressing a result of the multiplication in 2's complement to compensate for a sign of the multiplication result of the set of the multiplicand and the multiplier in the partial product;
Means for sequentially calculating the sum of each partial product after the sign extension is performed by the sign extension unit, wherein when the sum of all partial products for a certain set of multiplicand and multiplier exceeds a predetermined value, Summing means for calculating the sum of each partial product, discarding the exceeded value when calculating the sum of partial products for the next other set of multiplicands and multipliers;
From the data of the sum value (“N + M” (bits)) obtained by the summing means, a value that is a multiplication result of each multiplicand in the first register and the corresponding multiplier in the second register is cut out, and the multiplicand A processing unit for obtaining a multiplication result corresponding to a set with a multiplier for each set.
請求項1において、
さらに、前記第1レジスタにおける各被乗数と、これに対応する第2レジスタにおける乗数との乗算結果に、値を加えるための加算数を複数個保持し、各加算数のビット長の総和が、予め定めた長さを越えないことを条件として配置され、各加算数の間に0を埋込み、加算数を保持する第3レジスタと、
前記第1レジスタにおける各被乗数と、これに対応する第2レジスタにおける乗数との乗算結果に対応する、第3レジスタにおける加算数を加算する加算手段を備えること
を特徴とする演算器。
In claim 1,
Further, a plurality of addition numbers for adding a value to a multiplication result of each multiplicand in the first register and a corresponding multiplier in the second register are held, and a total sum of bit lengths of each addition number is determined in advance. A third register which is arranged on condition that the length does not exceed a predetermined length, embeds 0 between each addition number, and holds the addition number;
An arithmetic unit comprising: an adder for adding an addition number in a third register corresponding to a result of multiplication of each multiplicand in the first register and a corresponding multiplier in the second register.
請求項1および2のいずれかにおいて、
前記第1レジスタにおける各被乗数と、これに対応する第2レジスタにおける乗数との乗算結果が、オーバーフロー、あるいは、アンダーフローである場合には、乗算結果を予め定めた値とする乗算値置換部を備えること
を特徴とする演算器。
In any one of claims 1 and 2,
If the multiplication result of each multiplicand in the first register and the corresponding multiplier in the second register is an overflow or an underflow, a multiplication value replacement unit that sets the multiplication result to a predetermined value is provided. An arithmetic unit, comprising:
複数の被乗数を有するNビットの数と、前記各被乗数に対応する乗数を有するMビットの数との積を求めることによって、被乗数と乗数の組に対する乗算結果を求める演算器であって、
被乗数を複数個保持し、各被乗数のビット長の総和がNを越えないことを条件として配置する、Nビットの数を保持する第1レジスタと、
前記各被乗数に対応する乗数を保持し、各乗数のビット長の総和がMを越えないことを条件として配置する、Mビットの数を保持する第2レジスタと、
第1レジスタに保持された値と第2レジスタに保持された値との部分積を求めていく処理を行う部分積処理部と、
前記部分積において、1組の被乗数と乗数の、乗算結果の符号を補償するため、乗算結果を2の補数表現したビットを埋込む符号拡張を行なう符号拡張部と、
ある組の被乗数(aビット)と乗数(bビット)に対する全ての部分積を求めた後、次の他の組の被乗数と乗数に対する部分積を求める際に、当該組に対する部分積において、被乗数の当該組より前の組に対応するビットに、0を埋め込む部分積編成手段と、
各部分積の和を順次求めていく手段であって、ある組の被乗数と乗数に対する全ての部分積の総和が所定値を越えた場合、該越えた値を、次の他の組の被乗数と乗数に対する部分積の総和を求めていく際に廃棄する、各部分積の総和値を求める総和手段と、
前記総和手段によって求めた、総和値(「N+M」(ビット))のデータから、第1レジスタにおける各被乗数と、これに対応する第2レジスタにおける乗数との乗算結果である値を切り出し、被乗数と乗数との組に対応する乗算結果を、各組について求める処理手段とを有する演算器。
An arithmetic unit for calculating a product of an N-bit number having a plurality of multiplicands and an M-bit number having a multiplier corresponding to each of the multiplicands to obtain a multiplication result for a set of a multiplicand and a multiplier,
A first register for holding a number of N bits, wherein the first register holds a plurality of multiplicands and is arranged on condition that the sum of bit lengths of each multiplicand does not exceed N;
A second register holding an M-bit number, holding a multiplier corresponding to each of the multiplicands, and arranging on condition that a sum of bit lengths of each multiplier does not exceed M;
A partial product processing unit for performing a process of calculating a partial product of the value held in the first register and the value held in the second register;
In the partial product, a sign extension unit that performs sign extension for embedding bits obtained by expressing the result of the multiplication in 2's complement to compensate for the sign of the result of the multiplication of the set of the multiplicand and the multiplier;
After calculating all partial products for a certain set of multiplicands (a bits) and multipliers (b bits), when obtaining partial products for the next other set of multiplicands and multipliers, the partial product for the set is Partial product knitting means for embedding 0 in a bit corresponding to a set before the set ;
Means for sequentially calculating the sum of each partial product, wherein when the sum of all partial products for a certain set of multiplicands and multipliers exceeds a predetermined value, the exceeded value is compared with the next other set of multiplicands. Summing means for calculating a sum value of each partial product, which is discarded when calculating a sum of partial products with respect to the multiplier;
From the data of the sum value (“N + M” (bits)) obtained by the summing means, a value that is a multiplication result of each multiplicand in the first register and the corresponding multiplier in the second register is cut out, and the multiplicand A processing unit for obtaining a multiplication result corresponding to a set with a multiplier for each set.
請求項4において、
さらに、前記第1レジスタにおける各被乗数と、これに対応する第2レジスタにおける乗数との乗算結果に、値を加えるための加算数を複数個保持し、各加算数のビット長の総和が、予め定めた長さを越えないことを条件として配置する、加算数を保持する第3レジスタと、
前記第1レジスタにおける各被乗数と、これに対応する第2レジスタにおける乗数との乗算結果に対応する、第3レジスタにおける加算数を加算する加算手段を備えること
を特徴とする演算器。
In claim 4,
Further, a plurality of addition numbers for adding a value to a multiplication result of each multiplicand in the first register and a corresponding multiplier in the second register are held, and a total sum of bit lengths of each addition number is determined in advance. A third register for holding an addition number, which is arranged on condition that the length does not exceed a predetermined length;
An arithmetic unit comprising: an adder for adding an addition number in a third register corresponding to a result of multiplication of each multiplicand in the first register and a corresponding multiplier in the second register.
請求項1、2、4および5いずれか記載の演算器と、
予め定められた命令コードが与えらた場合には、前記演算器にデータを与えるデータ入力部と、
前記演算器を起動する起動手段と、
前記演算器の演算結果を得て出力するデータ出力部とを備えること
を特徴とするマイクロプロセッサ。
An arithmetic unit according to claim 1, 2, 4, or 5,
When a predetermined instruction code is found supplied, a data input unit to provide data to the arithmetic unit,
Activating means for activating the computing unit;
A data output unit for obtaining and outputting the operation result of the operation unit.
JP15756694A 1994-07-08 1994-07-08 Arithmetic unit and microprocessor Expired - Fee Related JP3579087B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP15756694A JP3579087B2 (en) 1994-07-08 1994-07-08 Arithmetic unit and microprocessor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP15756694A JP3579087B2 (en) 1994-07-08 1994-07-08 Arithmetic unit and microprocessor

Publications (2)

Publication Number Publication Date
JPH0822451A JPH0822451A (en) 1996-01-23
JP3579087B2 true JP3579087B2 (en) 2004-10-20

Family

ID=15652490

Family Applications (1)

Application Number Title Priority Date Filing Date
JP15756694A Expired - Fee Related JP3579087B2 (en) 1994-07-08 1994-07-08 Arithmetic unit and microprocessor

Country Status (1)

Country Link
JP (1) JP3579087B2 (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1892589B (en) * 1995-08-31 2011-02-23 英特尔公司 Apparatus for performing multimedia application operation, system and method for implementing the operation
CN1109990C (en) * 1998-01-21 2003-05-28 松下电器产业株式会社 Method and apparatus for arithmetic operation
US7587582B1 (en) 1998-12-03 2009-09-08 Sun Microsystems, Inc. Method and apparatus for parallel arithmetic operations
AU2001281162A1 (en) * 2000-08-16 2002-02-25 Sun Microsystems, Inc. General purpose processor with graphics/media support
JP7052678B2 (en) * 2018-11-06 2022-04-12 株式会社デンソー Convolution calculation method
JP7230744B2 (en) * 2019-08-28 2023-03-01 株式会社デンソー Convolution operation method and operation processing device

Also Published As

Publication number Publication date
JPH0822451A (en) 1996-01-23

Similar Documents

Publication Publication Date Title
US6099158A (en) Apparatus and methods for execution of computer instructions
US5448509A (en) Efficient hardware handling of positive and negative overflow resulting from arithmetic operations
JP2662196B2 (en) Calculation result normalization method and apparatus
EP2435906B1 (en) Dsp engine with implicit mixed operands
US20170139677A1 (en) Multiplication of first and second operands using redundant representation
US20050235026A1 (en) Method and system for performing parallel integer multiply accumulate operations on packed data
US5426600A (en) Double precision division circuit and method for digital signal processor
US10409604B2 (en) Apparatus and method for performing multiply-and-accumulate-products operations
JP2004342106A (en) Modular binary multiplier for signed and unsigned operands of variable width
JP2002149400A (en) Simd arithmetic system capable of designating plural registers
US5247471A (en) Radix aligner for floating point addition and subtraction
JP3476960B2 (en) Arithmetic logic operation device and control method
JP3579087B2 (en) Arithmetic unit and microprocessor
US5867413A (en) Fast method of floating-point multiplication and accumulation
US6499046B1 (en) Saturation detection apparatus and method therefor
JP3803438B2 (en) Floating point multiplication and accumulator
US5825681A (en) Divider/multiplier circuit having high precision mode
US4823300A (en) Performing binary multiplication using minimal path algorithm
US5822786A (en) Apparatus and method for determining if an operand lies within an expand up or expand down segment
US20080071852A1 (en) Method to perform a subtraction of two operands in a binary arithmetic unit plus arithmetic unit to perform such a method
JPH04172526A (en) Floating point divider
EP1197874B1 (en) Signal processor and product-sum operating device for use therein with rounding function
US20030037088A1 (en) Speed of execution of a conditional subtract instruction and increasing the range of operands over which the instruction would be performed correctly
JP3638218B2 (en) Microprocessor with ALU instruction with shift function
KR100251547B1 (en) Digital signal processor

Legal Events

Date Code Title Description
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: 20040706

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20040715

LAPS Cancellation because of no payment of annual fees