JP3971509B2 - Processor - Google Patents
Processor Download PDFInfo
- Publication number
- JP3971509B2 JP3971509B2 JP18093998A JP18093998A JP3971509B2 JP 3971509 B2 JP3971509 B2 JP 3971509B2 JP 18093998 A JP18093998 A JP 18093998A JP 18093998 A JP18093998 A JP 18093998A JP 3971509 B2 JP3971509 B2 JP 3971509B2
- Authority
- JP
- Japan
- Prior art keywords
- instruction
- address
- fetch
- decoding
- buffer
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Lifetime
Links
Images
Landscapes
- Advance Control (AREA)
Description
【0001】
【発明の属する技術分野】
本発明は、パイプライン処理によって機械語命令列を実行するプロセッサに関し、特に分岐処理を高速に実行するプロセッサに関する。
【0002】
【従来の技術】
CPU(以下プロセッサと呼ぶ)での処理の高速化の基本技術の一つにパイプライン処理がある。パイプライン処理は1個の命令の処理過程を複数の小さな処理単位(パイプラインステージ)に分割し、各ステージの処理を並列に行なうことにより処理速度を向上させる技術である。ところが、ループ処理等において分岐命令を実行した場合には、パイプラインストール(乱れ)が生じ、パイプライン処理の実効性能が理想性能を下回ることになる。この現象を分岐ハザードと呼ぶ。
【0003】
以下は分岐ハザードが発生するプログラムの具体例である。;以下にコメントを記す。
(命令1) mov 0,i;0をiに転送する
L:;分岐先を示すラベル
(命令2) add a,b,c;aとbの和をcに格納する
(命令3) mul a,b,d;aをbの積をdに格納する
(命令4) add i,1,i;iに1を加算する
(命令5) cmp i,3;iと3を比較する
(命令6) bcc L ;比較結果がi<3であった場合はLへ分岐する
上記のプログラムは、命令2から命令5までの処理が3回繰り返されるループ処理を記述している。このプログラムでは命令6(bcc)を実行した次のサイクルで新たに命令2をフェッチし、さらに次のサイクルで命令2をデコードし、その次のサイクルで命令2を実行することになる。その結果、命令6から命令2を実行するまでに2サイクルの分岐ハザードが生じてしまう。
【0004】
このような分岐ハザードを回避する技術として、特開平8-314719号に開示されたプロセッサがある。
このプロセッサでは、ループ処理の開始直前に、ループ処理先頭のプログラムコードをバッファに登録する。さらに、ループ処理においてループ末尾の命令からループ先頭に分岐した時点で、バッファからループ処理先頭のプログラムコードを取出して解読及び実行するように構成されている。これによれば、ループ処理の末尾から先頭に分岐した時点で、ループ処理先頭のプログラムコードをメモリから新たにフェッチする必要がなくなるので、分岐ハザードを回避することに成功している。
【0005】
【発明が解決しようとする課題】
しかしながら、上記の従来のプロセッサによれば、分岐ハザードを回避するための特別な回路を必要としているので、回路規模が大きいという問題があった。
具体的には、第1に、上記プロセッサは、ループ処理開始直前に、ループ処理先頭のプログラムコードをバッファに登録するのと同時に、当該プログラムコードに後続するアドレスを新たなフェッチアドレスとして計算を行なうために専用の加算器を必要としていた。加算器により算出されたフェッチアドレスは、アドレス用バッファに格納される。
【0006】
第2に、上記プロセッサは、ループ処理の末尾から先頭に分岐した時点で、アドレス用バッファからフェッチアドレスが取出されると同時に、フェッチアドレスから解読中の命令アドレスを算出するために専用の減算器を必要としていた。
このように、上記従来のプロセッサでは、専用の加算器と減算器とを必要としていたので、ハードウェア規模を増大させていた。
【0007】
本発明の目的は、分岐ハザードの低減を少ない回路規模で実現したパイプラインプロセッサを提供することを目的とする。
【0008】
【課題を解決するための手段】
上記課題を解決するため本発明のプロセッサは、メモリからコードをフェッチするフェッチ部と、フェッチされたコード中の命令を解読する解読部と、解読された命令を実行する実行部とを有し、プログラムループの直前に配置された登録命令と、プログラムループの末尾に配置されたループ命令とを用いて、高速にループ処理を実行するプロセッサであって、
前記解読部は、解読中の命令を指すポインタとして、解読中の命令のアドレスに一定のシフト値を加算した値を保持及び更新する解読命令カウンタを備え、
前記実行部は、解読部により前記登録命令が解読された場合に、フェッチ部によりプリフェッチされたプログラムループ先頭のコードを第1バッファに、解読命令カウンタに保持されているポインタを第2バッファに登録する登録手段と、解読部により前記ループ命令が解読されかつ分岐が成立する場合に、第2バッファに登録されたポインタをフェッチアドレスとして前記フェッチ部にフェッチさせ、第1バッファに登録されたコードを解読部に解読させる高速分岐手段とを備え、
前記シフト値は、第2バッファに格納されたポインタが、第1バッファに格納されたコードに後続するコードのアドレスを指すように定められている。
【0009】
ここで、前記一定のシフト値は、第1バッファの記憶領域サイズに等しい構成としてよい。
ここで、前記解読命令カウンタは、初期化時には、スタートアドレスと前記シフト値とを和を保持するようにしてもよい。
【0010】
【発明の実施の形態】
<第1の実施形態>
以下、本発明の実施例について図面を用いて詳細に説明する。
図1は、本発明の実施例によるプロセッサの構成を示すブロック図である。なお、図1には、プロセッサの他に、プロセッサの処理対象となる命令列(プログラム)を記憶する外部メモリ11も同時に示している。
【0011】
プロセッサ13は、外部メモリ11から命令をフェッチし、それを逐一解読して実行し、特に、分岐先情報登録命令(以下、登録命令と呼ぶ)と高速ループ命令との組みで指定されるループ処理を少ないハードウェア規模で高速に処理するように構成されている。
ここで、登録命令とは、プログラム中のループ処理の先頭命令の直前の配置され、ループ処理の先頭にあたる1つ以上の命令(又は命令コード)をプロセッサ内部に登録する命令である。また、高速ループ命令は、ループ処理の末尾に配置され、プロセッサ内部に登録された命令を用いて、条件を満たす場合にループ処理の先頭命令に分岐することを指示する命令である。登録命令、高速ループ命令は、それぞれニーモニック形式で”setlb”、”lcc”と表記する。
【0012】
そのため、プロセッサ13は、命令フェッチ部14、命令解読部15、命令実行部16、分岐先情報記憶部17を有する。これらの各部は、図示されていないクロック発生器からのクロック信号に同期して動作している。命令フェッチ部14、命令解読部15、命令実行部16は、命令パイプラインを構成しており、クロック信号に同期して並列に動作する。
【0013】
命令フェッチ部14は、外部メモリ11から命令をフェッチしフェッチ命令バッファ142に蓄積し、蓄積した命令を命令解読部15に送る。命令フェッチ部14はさらに、フェッチ命令カウンタ(以下FICと略す)141、フェッチ命令バッファ(以下FIBと略す)142、選択部143を有する。
FIC141は、フェッチすべき命令のアドレスを保持する。このアドレスは外部メモリ11に送られ、1回のフェッチを完了するとインクリメントされ、次にフェッチすべきアドレスに更新される。ただし、上記の高速ループ命令の実行ステージでは命令解読部15からの制御信号に従って、分岐先情報記憶部17から送られてくるフェッチアドレスに更新される。
【0014】
FIB142は、FIFO(First In First Out)メモリからなり、外部メモリ11からフェッチされた命令列を記憶する。
選択部143は、上記の高速ループ命令が実行された場合のみ分岐先情報記憶部17に登録された分岐先命令を選択し、それ以外の場合はFIB142にフェッチされた命令を選択し、命令解読部15に出力する。
【0015】
命令解読部15は、命令フェッチ部14から送られてきた命令を解読し、命令フェッチ部14、命令解読部15、命令実行部16、分岐先情報記憶部17の動作を制御するための制御信号を解読結果として出力する。このため命令解読部15は、解読命令カウンタ(以下DICと略す)151、解読命令バッファ(以下DIBと略す)152及び命令デコーダ153を有する。
【0016】
DIC151は、現在解読中の命令のアドレスに一定のシフト値(本実施例では4)を加算した値を保持及び更新する。このためDIC151は、起動時などのリセット時には初期値(スタートアドレス)にシフト値4を加算した値に初期化される。このDIC151は、通常は命令の解読を完了すると、その命令のコードサイズ分をインクリメントする。その結果、次に解読すべきアドレスに4を加算した値に更新される。ただし、上記高速ループ命令の実行ステージでは、命令解読部15からの制御信号に従って、分岐先情報記憶部17から送られてくるアドレスに更新される。なお上記シフト値は、分岐先命令記憶部171の記憶サイズ(バイト数)と同じ数値である。もし、その記憶サイズが8バイトであれば、DIC151は、現在解読中の命令のアドレスに8をシフト値として加算した値を保持することになる。
【0017】
DIB152は、レジスタからなり、FIB142から送られ、解読対象の命令を1つ記憶する。
命令デコーダ153は、DIB152に記憶されている命令を解読し、その解読結果によって命令フェッチ部14、命令解読部15、命令実行部16、分岐先情報記憶部17を制御する各種制御信号を出力する。解読した命令がDIC151のアドレスを利用する場合には、命令デコーダ153は、命令の種類に応じて上記4という値を調整(加算又は減算)するように命令実行部16を制御する。ただし高速ループ命令の場合、このような調整を必要としない。
【0018】
命令実行部16は、算術演算回路(ALU)やシフタなどからなり、命令解読部15から送られてきた制御信号に従って、プロセッサ13の命令で指定された演算や各部を制御したり、プロセッサ13に接続された図示されていない制御信号の入出力を行なったりする。
分岐先情報記憶部17は、命令解読部15が分岐先情報登録命令を解読した場合に分岐先情報を記憶する。このため分岐先情報記憶部17は分岐先命令記憶部171(以下BIRと略す)、分岐先フェッチアドレス記憶部(以下BAR)172からなる。
【0019】
BIR171は、レジスタからなり、命令解読部15が分岐先情報登録命令を解読した場合、次のサイクルでFIB142から4バイト分の命令列を読み出し、それを記憶する。これにより、ループ処理の命令列の先頭4バイトがBIR171に登録されたことになる。BIR171はループ命令バッファとも呼ぶ。
BAR172はレジスタからなり、命令解読部15が分岐先情報登録命令を解読した場合、次のサイクルでDIC151からアドレスを読み出し、それを記憶する。このアドレスは、解読中の命令のアドレスにBIR171の記憶サイズ(バイト数)を加算した値なので、BIR171の記憶内容に後続する命令列のアドレスを意味している。言い換えれば、BAR172の記憶内容は、高速ループ命令による分岐後に命令フェッチ部14がどこからフェッチすればよいかを示すポインタである。BAR172は、ループアドレスバッファとも呼ぶ
<解読命令カウンタの詳細構成>
図2は、DIC151の具体的な構成例を示す。同図のように、DIC151は、加算器31、レジスタ32、セレクタ33、34からなる。
【0020】
リセットなどによる初期化時には、加算器31は、リセットされたレジスタ32の値(スタートアドレス)と、一定数”4”とを加算する。レジスタ32は、その加算値を保持することにより初期化される。
通常、加算器31は、命令解読部15による命令解読後に、その命令語長(バイト数)と、現在のレジスタ32の値とを加算する。レジスタ32は、その加算値を保持することにより、((次の解読命令のアドレス)+4)に更新される。
【0021】
また分岐命令(高速ループ命令を含む)が実行される場合には、レジスタ32は、セレクタ33を介して入力される分岐先アドレスに更新される。
<登録命令、高速ループ命令の処理内容>
図3は、登録命令、高速ループ命令等の処理内容を示すフローチャートである。
【0022】
同図では、ループ処理の直前に配置される登録命令と、ループ処理の末尾に配置される高速ループ命令と、その他の命令に分けてその処理内容を示している。
同図において、命令デコーダ153による解読結果が登録命令(setlb)を示す場合には(ステップ31)、プロセッサ13は、FIB142の先頭から4バイト分の命令コードをBIR171へ転送し(ステップ32)、DIC151に保持されているアドレスをBAR172に転送し(ステップ33)、実行ステージサイクルが終了すると次の命令の実行を開始する。これにより、BIR171にはループ処理先頭の4バイト分の命令コードが保持され、BAR172にはループ処理先頭の4バイトに後続する命令のアドレスが保持される。
【0023】
また、命令デコーダ153による解読結果が高速ループ命令(lcc)を示す場合には(ステップ31)、プロセッサ13は、条件に応じて分岐する場合は(ステップ35)、BIR171からDIB152にループ処理先頭の命令を転送し(ステップ37)、BAR172からDIC151及びFIC141にアドレスを転送する。これにより、FIC141には、ループ処理先頭の4バイトに後続する命令のアドレスがフェッチアドレスとして保持され、DIC151には解読中の命令のアドレスに4を加えたアドレスが保持される。この場合、命令フェッチ部14は分岐先であるループ処理先頭の命令を新たにフェッチする必要がないので、分岐ハザードが生じない。しかも、FIC141は、特別な計算を必要とせず転送のみで、ループ処理先頭の4バイトに後続する命令のアドレスを得ることができる。
<選択部143、分岐先命令記憶部171の詳細構成>
図4は、選択部143および分岐先命令記憶部171の詳細な構成を示すブロック図である。
【0024】
同図では、選択部143及びBIR171に加えてFIB142も図示している。また、プログラム中の命令は可変語長(8ビットの整数倍)であるものとする。
FIB142は、フェッチされた命令コードを8ビット単位でシフトするキュー(16段程度が望ましい)として構成される。FIB142は、解読ステージの各サイクル毎にDIB152に対して選択部143を介してキュー先頭の4バイトを出力し、その4バイトを解読した命令解読部15から命令語長(当該4バイトの先頭からのバイト数)が与えられると、キュー先頭の命令語長分の命令コードをシフトすることにより削除する。その結果、通常、キューの先頭バイトは1つの命令の先頭バイトに一致する(高速ループ命令による分岐直後は必ずしも一致しない)。
【0025】
BIR171は、キュー171aと選択制御部171bとからなる。
キュー171aは、8ビット単位にリング状にシフトするキュー(4段)として構成され、上記登録命令の実行時にFIB142の先頭4バイトを格納し、上記高速ループ命令の実行時に保持している4バイトを選択部143を介してDIB152に出力し、その4バイトを解読した命令解読部15から命令語長(当該4バイトの先頭からのバイト数)が選択制御部171bを介して与えられると、先頭の命令語長分の命令コードをリング状にシフトする。このシフト動作は、合計4バイト分がシフトされるまで繰り返された後停止し、上記登録命令により格納された元の状態に戻る。この状態で、再度高速ループ命令による分岐がなさた場合、上記と同様に動作する。
【0026】
選択制御部171bは、高速ループ命令による分岐直後に、FIC141の命令コードの代わりにキュー171aに格納されている4バイト分の命令コードを出力するよう選択部143を制御する。詳しくは、高速ループ命令による分岐直後の解読ステージにおいて、4バイト全部を選択部143を介して出力し、命令解読部15から通知される命令語長に応じてキュー171aをシフトさせ、シフト後のキュー171aの命令コードの有効バイト数をカウントする。さらに、次の解読ステージにおいて、有効バイト数に応じて選択部143を制御する。
【0027】
選択部143は、セレクタ143a〜143dからなり、高速ループ命令に実行直後に、キュー171aに保持されている命令コードと、それに後続するFIB142に保持されている命令コードとを合せて4バイトになるよう選択する。
図5にセレクタ143a〜143dそれぞれの選択論理を示す。この選択論理によれば、セレクタ143a〜143dは、選択制御部171bから指示される有効バイト数に応じて、キュー171aの有効な命令コードとそれに後続するFIB142の命令コードとを連結した4バイト分の命令コードを出力する。なお、図5では、8ビット5入力1出力(5to1)のセレクタ4つを使用しているが、2to1、3to1、4to1、5to1の4つセレクタで構成してもよい。
<分岐命令の処理>
DIC151は、上記のように現在解読中の命令アドレスに一定数”4”を加算した値を保持するので、DIC151の値を読み出し又は書き込む命令については、一定数”4”を加減算により調整する必要がある。この調整は、高速ループ命令以外の命令であって、アドレス指定を伴う命令において必要となる。
【0028】
図6は、アドレス指定を伴う命令のオペレーション内容を示す図である。同図では、絶対アドレス指定を伴う代表的な命令とて、単純分岐命令(branch abs_adrs)、サブルーチンコール命令(call abs_adrs)、サブルーチンからのリターン命令(ret)を、相対アドレス指定を伴う代表的な命令として単純分岐命令(branch rel_adrs)記してある。図中の abs_adrは、32ビットの絶対アドレスを、rel_adrsは8又は16ビットの相対アドレスを示す。
【0029】
単純分岐命令(branch abs_adrs)の場合、命令実行部16は、絶対アドレス(abs_adr)をFIC141に格納し(オペレーション601)、絶対アドレス(abs_adr)に一定数4を加算し、その加算値をDIC151に格納する(602)。これにより、指定された絶対アドレスの命令からフェッチ・解読・実行を開始する。このように、絶対アドレスで分岐先が指定される分岐命令に対しては、当該絶対アドレスに4を加算した値をDIC151に設定するよう制御する。
【0030】
サブルーチンコール命令の場合、命令実行部16は、絶対アドレス(abs_adr)をFIC141に格納し(603)、DIC151に命令語長を加算した後DIC151の値から4を減算し、その減算値をスタックにプッシュし(604)、さらに絶対アドレス(abs_adr)に一定数4を加算した値をDIC151に格納する(605)。ここで、減算値は、サブルーチンコール命令の実行時に解読中だった命令つまり、サブルーチンコール命令の次の命令のアドレスを指す。このように、サブルーチンコール命令に対しては、DIC151のアドレスから4を減算した値を図外のスタックに退避するよう制御する。
【0031】
リターン命令の場合、命令実行部16は、スタックからサブルーチンコール命令の次の命令のアドレスをポップし(606)、そのアドレスをFIC141に格納し、さらにそのアドレスに4を加算し、加算値をDIC151に格納する(607)。このように、リターン命令に対しては、図外のスタックに退避された当該値に4を加算した値を復帰するよう制御する。
【0032】
また、相対アドレス指定を伴う単純分岐命令(branch rel_adrs)の場合、命令実行部16は、命令で指定された相対アドレス(abs_adr)と、DIC151の値とを加算し(608)、その加算結果をDIC151に、さらに、その加算結果に”−4”を加算して加算結果をFIC141に格納する(609)。このように、相対アドレスで分岐先が指定される分岐命令に対しては、DIC151の値から4を減算した値をDIC151に設定するよう制御する。ただし、高速ループ命令では、このような減算を要しない。
【0033】
上記のように、絶対アドレス指定の分岐命令に対しては、DIC151の更新は絶対アドレスに+4しておけばよく、FIC141の更新はそのまま絶対アドレスを用いればよい。
また、相対アドレス指定の分岐命令に対しては、DIC151の更新は、単に(DIC151)+(相対アドレス)を加算するだけでよく、+4する必要がなく、FIC141の更新は、(DIC151)+(相対アドレス)−4とする必要がある。
【0034】
なお、上記の何れの場合も、一定数4の加減算は、命令実行部16内部のALU(Arithmetic Logical Unit)により実行される。また、高速ループ命令以外ののアドレス指定を伴う命令については、命令実行部16は、上記と同様にアドレス計算を行なうことになる。
<動作説明>
以上のように構成された本実施形態におけるプロセッサについて、その動作を以下のプログラム例を用いて説明する。
【0035】
図7は、以下のプログラム例を実行した場合のパイプラインの状態を示す図である。
このプログラム例では、左から命令アドレス、命令、コメントを示している。
命令アドレスは32ビットアドレス中の下位16ビットのみを16進数で、命令はニーモニック形式で、コメントは;以下に命令内容の簡単な説明を記している。
【0036】
このプログラムでは、登録命令(setlb)の次の命令(add a,b,c)から高速ループ命令(lcc L)までの処理は、3回繰り返されるループ処理になっている。
図7では、横軸をサイクル単位の時間軸とし、縦軸のIF(ステージ)欄は、FIB142に保持されている先頭命令を示している。ただし、サイクル8、9、13、14ではBIR171に保持されている先頭命令を示している。DEC(ステージ)欄は、DIB152に保持されている解読中の命令を示す。EX(ステージ)欄は、命令実行部16において実行中の命令を示している。
【0037】
同図において、分岐先登録命令(setlb)が解読されると(サイクル3)、解読ステージ(サイクル3)において、FIB142からBIR171に4バイト分の命令コード(add命令とmul命令)が転送され、さらに実行ステージ(サイクル4)においてDIC151からBAR172に(解読中の命令アドレス)+4というアドレスが転送される。このとき、BAR172には、1007(1003+4)つまり、(add i,1,i)のアドレスが格納される。
【0038】
この後、高速ループ命令(lcc)が解読されると(サイクル8)、その実行ステージ(サイクル9)において、BIR171からDIB152に4バイト分の命令コードが転送され、BAR172からFIC141にアドレスが転送される。これにより、FIC141には、BIR171の4バイト分に命令コードに後続する命令のアドレスが格納される。
【0039】
また、サイクル13における高速ループ命令についても同様である。
このように、本プロセッサでは、DIC151は、常に解読中の命令のアドレスに4を加算したアドレスを保持しているため、登録命令(setlb)の実行に際して、分岐先のフェッチアドレスを求めるのに4を加算する加算器を不要にしている。
【0040】
また、高速ループ命令(lcc)による分岐に際して、FIC141とDIC151はいずれもBAR172からの同じアドレスが転送されるので、FIC141とDIC151とに対して個別にアドレス計算を行なう必要がないので、ここでも加算器(減算器)を不要にしている。
<第2の実施形態>
図8は、本発明の第2の実施形態におけるプロセッサの構成を示すブロック図である。
【0041】
同図の構成は、図1と比べてFIC(フェッチ命令カウンタ)141の代わりにFIC241を、DIC151の代わりにDIC251を備える点が異なっている。この差異により、同図の構成は、アドレス指定を伴う命令を実行した場合に、図1の構成では命令実行部16によってDIC151に保持されるべきアドレスを算出していたのに対して、命令実行部16ではなく命令フェッチ部24においてDIC151に保持されるべきアドレスを計算するように構成されている。これ以外は第1の実施形態と同じなので、以下異なる点を中心に説明する。
<フェッチ命令カウンタ241の詳細構成>
図9は、フェッチ命令カウンタ241及び解読命令カウンタ251の詳細な構成を示すブロック図である。
【0042】
フェッチ命令カウンタ241は、加算器91、ラッチ92、セレクタ93から構成される。
加算器91、ラッチ92、セレクタ93からなるループ回路は、4ずつカウントアップするカウンタを構成している。命令フェッチ部24は、FIB142に4バイト以上の空きが存在する場合に、4バイト分の命令コードのフェッチを行い、FIC141をカウントアップする。
【0043】
セレクタ93は、通常(分岐しない場合)は、加算器91の加算結果を選択し、高速ループ命令以外の分岐命令が実行された場合は実行部16から供給される分岐先アドレスを、高速ループ命令が実行された場合にはBAR172から供給されるフェッチアドレスを選択し、加算器91に出力する。ラッチ92の出力は、フェッチアドレスとして外部メモリ11に供給される。
<解読命令カウンタ251の詳細構成>
図9において、DIC251は、加算器101、ラッチ102、セレクタ103、セレクタ104から構成される。
【0044】
加算器101、セレクタ103、ラッチ102からなるループ回路は、解読ステージ毎に、解読された命令語長ずつカウントアップするカウンタを構成している。
加算器101は、解読ステージの後半で、ラッチ102の内容に解読された命令語長を加算し、DIC251を参照する命令(高速分岐命令以外の分岐命令など)の実行時には、ラッチ102の内容に”−4”を加算した値を出力する。
ラッチ102は、解読中の命令アドレスとシフト値”4”との和を保持する。また、ラッチ102は、初期化時には、FIC241から与えられる(スタートアドレス+4)を保持する。
【0045】
セレクタ103は、通常は命令解読部25から与えられる命令語長を選択し、相対アドレス指定を伴う命令やサブルーチンコール命令の実行時には、シフト値の調整用の”−4”を選択する。
セレクタ104は、通常は加算器101の加算結果を選択し、高速分岐命令の実行に際してBAR172の出力を選択し、他の分岐命令の実行に際してFIC241からの出力(加算器91からの(分岐先アドレス+4))を選択する。
<分岐先アドレスの計算>
図10は、アドレス指定を伴う命令のオペレーション内容を示す図である。同図では、図6と同様に単純分岐命令(branch abs_adrs)、サブルーチンコール命令(call abs_adrs)、サブルーチンからのリターン命令(ret)を、単純分岐命令(branch rel_adrs)記してある。なお、図10中の破線より上のオペレーションは解読ステージにおいて、破線より下のオペレーションは実行ステージにおいて実行されることを意味する。
【0046】
単純分岐命令(branch abs_adrs)の場合、命令実行部16が、絶対アドレス(abs_adr)をFIC241に格納し(オペレーション1001)、さらに命令フェッチ部24内の加算器91がFIC241に一定数4を加算し、その加算値をDIC251に格納する(1002)。このように、絶対アドレスで分岐先が指定される分岐命令に対しては、命令フェッチ部24内の加算器91を利用してシフト値”4”を加算しするように構成されている。
【0047】
サブルーチンコール命令の場合、命令実行部16は絶対アドレス(abs_adr)をFIC241に格納し(1003)、加算器101は、DIC251に命令語長を加算(1004)した後DIC251の値から4を減算し、命令実行部16がその減算値をスタックにプッシュし(1005)、さらに加算器91においてFIC241に一定数4を加算した値をDIC251に格納する(1006)。このように、スタックにプッシュする戻り先アドレスの計算におけるシフト値”4”の調整は、DIC251内の加算器101を利用し、DIC251の更新におけるシフト値の調整は、FIC241内の加算器91を利用している。
【0048】
リターン命令の場合、命令実行部16は、スタックからサブルーチンコール命令の次の命令のアドレスをポップし(1007)、そのアドレスをFIC241に格納し、さらにそのアドレスに4を加算し、加算値をDIC251に格納する(1008)。このように、リターン命令に対しては、シフト値”4”の調整は、FIC241内の加算器91を利用している。
【0049】
また、相対アドレス指定を伴う単純分岐命令(branch rel_adrs)の場合、命令実行部16は、加算器101によりDIC251に”−4”加算された値と、命令で指定された相対アドレス(abs_adr)とを加算し、その加算結果をFIC241に格納し(1009)、さらに、加算器91によりFIC241に”4”加算された値をDIC251格納する(1010)。このように、相対アドレスで分岐先が指定される分岐命令に対するシフト値の調整は、DIC251内の加算器101と、FIC241内の加算器91とを利用している。
【0050】
上記のように、本実施例のプロセッサは、図10における1002、1006、1008、1010のオペレーションは、FIC241内の加算器91を利用してシフト値”4”の加算を行い、1005、1009のオペレーションはDIC251内の加算器101を利用してシフト値”4”の減算を行っている。
<分岐タイミング>
図11は、相対分岐命令(branch rel_adrs)の動作タイミングを示すタイムチャートである。
【0051】
同図においてサイクルT1、T2はそれぞれ上記相対分岐命令(branch rel_adrs)の命令解読ステージ、命令実行ステージに相当する。また、サイクルT3、T4は、それぞれ分岐先命令の命令フェッチステージ、命令解読ステージに相当する。
サイクルT1において、加算器101は(DIC251−4)を計算し、さらに、サイクルT2において命令実行部16はその計算結果に相対アドレス(rel_adrs)を加算することにより分岐先アドレス(BA)を算出する。
【0052】
サイクルT3において、FIC241には分岐先アドレス(BA)が外部メモリ11に出力され、分岐先の命令コード(32ビット分)がフェッチされる。サイクルT3の後半で加算器91は(FIC241+4)を計算する。
サイクルT4において、加算器91の計算結果がDIC251及びFIC241に格納される。
【0053】
なお、上記各実施形態におけるプロセッサは、処理単位を32ビットとして説明したが、本発明を適用するには、16ビットでも64ビットでもよい。また、BIR171のサイズを4バイト(32ビット)としたが、このサイズは、高速ループ命令による分岐後にそのサイズ分の命令コードを解読し終えるまでに、少なくとも1命令をフェッチするだけのサイクルを保証できればよい。
【0054】
また、上記各実施形態では、プログラムが可変語長命令から構成されることを前提としたが、固定語長のプログラムであってもよい。その場合、DIC151、選択部143はより簡単な構成にすることができる。
また、図4に示したBIR171の構成ではキュー171a(リングバッファ)を用いているが、BIR171に格納された4バイト分の命令コードのうち、任意のバイトを先頭として出力する構成としてもよい。この場合のキュー171aの他の構成例を図12に示す。同図では、図4のBIR171においてキュー171aの代わりに4バイトのレジスタ120とセレクタ121a〜121dとを備える構成としている。セレクタ121a〜121dの選択論理を図13に示す。図12、13に示すように、レジスタ120に4バイトの命令コード(A、B、C、D)が格納されている場合、有効バイト数が4であれば、セレクタ121a〜121dは、A、B、C、Dと配列された32ビットを出力する。この32ビットは、図4に示したセレクタ143a〜143dを介してDIB152に格納される。
【0055】
また例えば、有効バイト数が3であれば、セレクタ121a〜121dは、BCDAと配列された32ビットを出力する。この出力は、図4に示したセレクタ143a〜143dによって有効バイト(3バイトBCD)のみが選択される。このとき、セレクタ143a〜143dは、この3バイト(BCD)を上位側とし、FIB142から1バイトを下位側とした4バイトを出力する。また、有効バイト数が2、1の場合も同様である。
【0056】
図12の構成は、図4と比べてシフト動作の代わりに選択動作をすることになるので、より高速な動作が可能である。
【0057】
【発明の効果】
本発明のプロセッサは、メモリからコードをフェッチするフェッチ部と、フェッチされたコード中の命令を解読する解読部と、解読された命令を実行する実行部とを有し、プログラムループの直前に配置された登録命令と、プログラムループの末尾に配置されたループ命令とを用いて、高速にループ処理を実行するプロセッサであって、
前記解読部は、解読中の命令を指すポインタとして、解読中の命令のアドレスに一定のシフト値を加算した値を保持及び更新する解読命令カウンタを備え、
前記実行部は、解読部により前記登録命令が解読された場合に、フェッチ部によりプリフェッチされたプログラムループ先頭のコードを第1バッファに、解読命令カウンタに保持されているポインタを第2バッファに登録する登録手段と、解読部により前記ループ命令が解読されかつ分岐が成立する場合に、第2バッファに登録されたポインタをフェッチアドレスとして前記フェッチ部にフェッチさせ、第1バッファに登録されたコードを解読部に解読させる高速分岐手段とを備え、
前記シフト値は、第2バッファに格納されたポインタが、第1バッファに格納されたコードに後続するコードのアドレスを指すように定められている。
【0058】
ここで、前記一定のシフト値は、第1バッファの記憶領域サイズに等しい構成としてよい。
ここで、前記解読命令カウンタは、初期化時には、スタートアドレスと前記シフト値とを和を保持するようにしてもよい。
この構成によれば、解読命令カウンタに実際に解読中の命令のアドレスに所定の値を加算したポインタを格納することによって、従来必要だった分岐情報登録命令実行時のアドレス加算と、ループ命令実行時のアドレス減算の処理が不要になり、これらの処理に必要な加算器および減算器も不要になり、その結果ハードウェア規模を削減できるという効果がある。分岐情報登録命令及びループ命令実行時にアドレス計算が不要であるため、これらの実質的な処理時間を短縮することができる。
【0059】
ここで、前記実行部は、さらに、絶対アドレス指定を伴う分岐命令が解読部により解読された場合、当該絶対アドレスをフェッチ命令カウンタに転送し、当該絶対アドレスに前記シフト値を加えた値を解読命令カウンタに転送する分岐手段を備える構成としてもよい。
また、前記分岐手段は、さらに、相対アドレス指定を伴う分岐命令が解読部により解読された場合、当該相対アドレスと解読命令カウンタに保持されたポインタとを加算した値を解読命令カウンタに転送し、その加算値から前記シフト値を減算した値をフェッチ命令カウンタに転送するように構成してもよい。
【0060】
この構成によれば、解読命令カウンタに保持されたポインタを用いて、絶対アドレスまたは相対アドレス指定を伴う分岐命令を実行する。
ここで前記フェッチ命令カウンタは、フェッチアドレスを保持するレジスタと、レジスタの値をインクリメントする加算器とを含み、前記分岐手段は、絶対アドレス指定を伴う分岐命令が解読部により解読された場合に、前記絶対アドレスに前記シフト値を加えた値の計算を、前記フェッチ命令カウンタ内の加算器に実行させ、その加算結果を解読命令カウンタに転送するようにしてもよい。
【0061】
この構成によれば、絶対アドレス指定を伴う分岐命令に対して、解読命令カウンタに格納すべきポインタの算出を、実行部の資源を占有しないで、フェッチ命令カウンタ内の加算器を用いて行なうことができる。
【図面の簡単な説明】
【図1】本発明の第1の実施形態におけるプロセッサの構成を示すブロック図である。
【図2】解読命令カウンタの詳細な構成を示す図である。
【図3】命令実行ステージにおける処理内容を示すフローチャートである。
【図4】選択部143および分岐先命令記憶部171の詳細な構成を示すブロック図である。
【図5】選択部143の選択制御論理を示す図である。
【図6】アドレスを伴う命令のオペレーション内容を示す図である。
【図7】プロセッサによってループ処理を実行した場合のパイプラインの状態を示す図である。
【図8】本発明の第2の実施形態におけるプロセッサの構成を示すブロック図である。
【図9】フェッチ命令カウンタ241及び解読命令カウンタ251の詳細な構成を示すブロック図である。
【図10】アドレス指定を伴う命令のオペレーション内容を示す図である。
【図11】相対分岐命令(branch rel_adrs)の動作タイミングを示すタイムチャートである。
【図12】図4のキューの他の構成例を示す。
【図13】図12におけるセレクタの選択論理を示す。
【符号の説明】
11 外部メモリ
13 プロセッサ
14 命令フェッチ部
15 命令解読部
16 命令実行部
17 分岐先情報記憶部
24 命令フェッチ部
25 命令解読部
31 加算器
32 レジスタ
33 セレクタ
91 加算器
92 ラッチ
93 セレクタ
101 加算器
102 ラッチ
103 セレクタ
104 セレクタ
120 レジスタ
121a〜121d セレクタ
141 フェッチ命令カウンタ
142 フェッチ命令バッファ
143 選択部
143a〜143d セレクタ
151 解読命令カウンタ
152 解読命令バッファ
153 命令デコーダ
171 分岐先命令記憶部
171a キュー
171b 選択制御部
172 分岐先フェッチアドレス記憶部[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a processor that executes a machine language instruction sequence by pipeline processing, and more particularly to a processor that executes branch processing at high speed.
[0002]
[Prior art]
Pipeline processing is one of the basic technologies for speeding up processing in a CPU (hereinafter referred to as a processor). Pipeline processing is a technique for improving the processing speed by dividing the processing process of one instruction into a plurality of small processing units (pipeline stages) and performing the processing of each stage in parallel. However, when a branch instruction is executed in loop processing or the like, pipeline installation (disturbance) occurs, and the effective performance of the pipeline processing falls below the ideal performance. This phenomenon is called a branching hazard.
[0003]
The following is a specific example of a program in which a branch hazard occurs. ; Comment below.
(Instruction 1)
L :; Label indicating the branch destination
(Instruction 2) add a, b, c; Store the sum of a and b in c
(Instruction 3) mul a, b, d; Stores a product of b in d
(Command 4) add i, 1, i; Add 1 to i
(Command 5) cmp i, 3; Compare i and 3
(Instruction 6) bcc L; Comparison result is i If <3, branch to L
The above program describes a loop process in which the processes from
[0004]
As a technique for avoiding such a branch hazard, there is a processor disclosed in Japanese Patent Laid-Open No. 8-314719.
In this processor, immediately before the start of the loop processing, the program code at the head of the loop processing is registered in the buffer. Further, at the time of branching from the instruction at the end of the loop to the head of the loop in the loop processing, the program code at the head of the loop processing is taken out from the buffer, and is decoded and executed. According to this, it is not necessary to newly fetch the program code at the beginning of the loop processing from the memory at the time of branching from the end of the loop processing to the beginning, so that the branch hazard is successfully avoided.
[0005]
[Problems to be solved by the invention]
However, according to the above-described conventional processor, a special circuit for avoiding the branch hazard is required, so that there is a problem that the circuit scale is large.
Specifically, first, the processor registers the program code at the head of the loop process in the buffer immediately before the start of the loop process, and at the same time, calculates the address following the program code as a new fetch address. Therefore, a dedicated adder was required. The fetch address calculated by the adder is stored in the address buffer.
[0006]
Second, when the processor branches from the end of the loop processing to the head, the fetch address is fetched from the address buffer, and at the same time, a dedicated subtractor is used to calculate the instruction address being decoded from the fetch address. Needed.
As described above, the conventional processor requires a dedicated adder and subtracter, which increases the hardware scale.
[0007]
An object of the present invention is to provide a pipeline processor that realizes reduction of branch hazards with a small circuit scale.
[0008]
[Means for Solving the Problems]
In order to solve the above problems, a processor of the present invention includes a fetch unit that fetches a code from a memory, a decryption unit that decrypts an instruction in the fetched code, and an execution unit that executes the decrypted instruction. A processor that executes loop processing at high speed using a registration instruction arranged immediately before the program loop and a loop instruction arranged at the end of the program loop,
The decoding unit includes a decoding instruction counter that holds and updates a value obtained by adding a certain shift value to the address of the instruction being decoded as a pointer to the instruction being decoded,
The execution unit registers, in the first buffer, the code at the head of the program loop prefetched by the fetch unit in the first buffer and the pointer held in the decoding instruction counter when the registration command is decoded by the decoding unit. When the loop instruction is decoded by the decoding unit and the branch is taken, the fetch unit uses the pointer registered in the second buffer as a fetch address to fetch the code registered in the first buffer. A high-speed branching means for causing the decoding unit to decode,
The shift value is determined so that the pointer stored in the second buffer points to the address of the code following the code stored in the first buffer.
[0009]
Here, the fixed shift value may be equal to the storage area size of the first buffer.
Here, the decoding instruction counter may hold the sum of the start address and the shift value at the time of initialization.
[0010]
DETAILED DESCRIPTION OF THE INVENTION
<First Embodiment>
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
FIG. 1 is a block diagram showing a configuration of a processor according to an embodiment of the present invention. In addition to the processor, FIG. 1 also shows an
[0011]
The
Here, the registration instruction is an instruction that is arranged immediately before the head instruction of the loop processing in the program and registers one or more instructions (or instruction codes) at the head of the loop processing in the processor. The high-speed loop instruction is an instruction that is arranged at the end of the loop processing and instructs to branch to the top instruction of the loop processing when the condition is satisfied using an instruction registered in the processor. The registration instruction and the high-speed loop instruction are expressed as “setlb” and “lcc” in mnemonic format, respectively.
[0012]
Therefore, the
[0013]
The instruction fetch
The
[0014]
The
The
[0015]
The
[0016]
The
[0017]
The
The
[0018]
The
The branch destination
[0019]
The
The
<Detailed configuration of decoding instruction counter>
FIG. 2 shows a specific configuration example of the
[0020]
At initialization by resetting or the like, the
Normally, the
[0021]
When a branch instruction (including a high-speed loop instruction) is executed, the
<Processing contents of registered instruction and high-speed loop instruction>
FIG. 3 is a flowchart showing processing contents such as a registration command and a high-speed loop command.
[0022]
In the figure, the processing contents are shown separately for a registration instruction arranged immediately before the loop processing, a high-speed loop instruction arranged at the end of the loop processing, and other instructions.
In the figure, when the result of decoding by the
[0023]
When the result of decoding by the
<Detailed Configuration of
FIG. 4 is a block diagram showing a detailed configuration of the
[0024]
In the figure, in addition to the
The
[0025]
The
The queue 171a is configured as a queue (four stages) that shifts in a ring shape in units of 8 bits, stores the first 4 bytes of the
[0026]
The selection control unit 171b controls the
[0027]
The
FIG. 5 shows the selection logic of each of the
<Branch instruction processing>
Since the
[0028]
FIG. 6 is a diagram showing the operation contents of an instruction with address designation. In the figure, typical instructions with absolute addressing include simple branch instructions (branch abs_adrs), subroutine call instructions (call abs_adrs), and return instructions from subroutines (ret). A simple branch instruction (branch rel_adrs) is written as an instruction. In the figure, abs_adr indicates a 32-bit absolute address, and rel_adrs indicates an 8- or 16-bit relative address.
[0029]
In the case of a simple branch instruction (branch abs_adrs), the
[0030]
In the case of a subroutine call instruction, the
[0031]
In the case of a return instruction, the
[0032]
In the case of a simple branch instruction (branch rel_adrs) with relative address designation, the
[0033]
As described above, for an absolute addressed branch instruction, the update of the
In addition, for a branch instruction with a relative address, the
[0034]
In any of the above cases, the addition / subtraction of the fixed
<Description of operation>
The operation of the processor according to this embodiment configured as described above will be described using the following program example.
[0035]
FIG. 7 is a diagram illustrating a pipeline state when the following program example is executed.
In this program example, an instruction address, an instruction, and a comment are shown from the left.
Only the lower 16 bits of the 32-bit address are in hexadecimal, the instruction is in mnemonic format, and the comment is; a brief description of the instruction content is given below.
[0036]
In this program, the processing from the instruction (add a, b, c) following the registration instruction (setlb) to the high-speed loop instruction (lcc L) is a loop process that is repeated three times.
In FIG. 7, the horizontal axis is the time axis of the cycle unit, and the IF (stage) column on the vertical axis indicates the head instruction held in the
[0037]
In the figure, when the branch destination registration instruction (setlb) is decoded (cycle 3), the instruction code (add instruction and mul instruction) for 4 bytes is transferred from the
[0038]
After that, when the high-speed loop instruction (lcc) is decoded (cycle 8), in the execution stage (cycle 9), the 4-byte instruction code is transferred from the
[0039]
The same applies to the high-speed loop instruction in
In this way, in this processor, the
[0040]
Further, since the same address from the
<Second Embodiment>
FIG. 8 is a block diagram showing a configuration of a processor according to the second embodiment of the present invention.
[0041]
The configuration of FIG. 6 differs from that of FIG. 1 in that an
<Detailed Configuration of Fetch
FIG. 9 is a block diagram showing a detailed configuration of the fetch
[0042]
The fetch
The loop circuit including the
[0043]
The selector 93 normally selects the addition result of the adder 91 (when not branching), and when a branch instruction other than the high speed loop instruction is executed, the branch destination address supplied from the
<Detailed Configuration of
In FIG. 9, the
[0044]
The loop circuit including the
The
The latch 102 holds the sum of the instruction address being decoded and the shift value “4”. The latch 102 holds (start address +4) given from the
[0045]
The selector 103 normally selects the instruction word length given from the
The selector 104 normally selects the addition result of the
<Calculation of branch destination address>
FIG. 10 is a diagram showing the operation contents of an instruction with address designation. In this figure, as in FIG. 6, a simple branch instruction (branch abs_adrs), a subroutine call instruction (call abs_adrs), and a return instruction (ret) from the subroutine are described as simple branch instructions (branch rel_adrs). In FIG. 10, an operation above the broken line means that the operation is executed at the decoding stage, and an operation below the broken line is executed at the execution stage.
[0046]
In the case of a simple branch instruction (branch abs_adrs), the
[0047]
In the case of a subroutine call instruction, the
[0048]
In the case of a return instruction, the
[0049]
Further, in the case of a simple branch instruction (branch rel_adrs) with relative address designation, the
[0050]
As described above, in the processor of this embodiment, the
<Branch timing>
FIG. 11 is a time chart showing the operation timing of a relative branch instruction (branch rel_adrs).
[0051]
In the figure, cycles T1 and T2 correspond to the instruction decoding stage and the instruction execution stage of the relative branch instruction (branch rel_adrs), respectively. Cycles T3 and T4 correspond to the instruction fetch stage and instruction decode stage of the branch destination instruction, respectively.
In cycle T1,
[0052]
In cycle T3, the branch destination address (BA) is output to the
In cycle T4, the calculation result of the
[0053]
The processor in each of the above embodiments has been described with the processing unit being 32 bits. However, in order to apply the present invention, it may be 16 bits or 64 bits. The size of
[0054]
In each of the above embodiments, it is assumed that the program is composed of variable word length instructions, but may be a fixed word length program. In that case, the
Further, although the queue 171a (ring buffer) is used in the configuration of the
[0055]
For example, if the number of valid bytes is 3, the
[0056]
Since the configuration of FIG. 12 performs a selection operation instead of the shift operation as compared with FIG. 4, a higher speed operation is possible.
[0057]
【The invention's effect】
The processor of the present invention has a fetch unit for fetching code from a memory, a decryption unit for decrypting an instruction in the fetched code, and an execution unit for executing the decrypted instruction, and is arranged immediately before the program loop. A processor that executes loop processing at high speed using a registered instruction and a loop instruction arranged at the end of a program loop,
The decoding unit includes a decoding instruction counter that holds and updates a value obtained by adding a certain shift value to the address of the instruction being decoded as a pointer to the instruction being decoded,
The execution unit registers, in the first buffer, the code at the head of the program loop prefetched by the fetch unit in the first buffer and the pointer held in the decoding instruction counter when the registration command is decoded by the decoding unit. When the loop instruction is decoded by the decoding unit and the branch is taken, the fetch unit uses the pointer registered in the second buffer as a fetch address to fetch the code registered in the first buffer. A high-speed branching means for causing the decoding unit to decode,
The shift value is determined so that the pointer stored in the second buffer points to the address of the code following the code stored in the first buffer.
[0058]
Here, the fixed shift value may be equal to the storage area size of the first buffer.
Here, the decoding instruction counter may hold the sum of the start address and the shift value at the time of initialization.
According to this configuration, by storing a pointer obtained by adding a predetermined value to the address of the instruction that is actually being decoded in the decoding instruction counter, it is possible to add an address when executing a branch information registration instruction and execute a loop instruction. This eliminates the need for the time address subtraction process, and eliminates the need for the adder and subtracter necessary for these processes, resulting in the effect of reducing the hardware scale. Since the address calculation is not required when the branch information registration instruction and the loop instruction are executed, the substantial processing time can be shortened.
[0059]
Here, the execution unit further transfers the absolute address to the fetch instruction counter when the branch instruction accompanied by the absolute address designation is decoded by the decoding unit, and decodes the value obtained by adding the shift value to the absolute address. A branching means for transferring to the instruction counter may be provided.
Further, the branch means further transfers a value obtained by adding the relative address and the pointer held in the decode instruction counter to the decode instruction counter when the decode instruction is decoded by the decoding unit, A value obtained by subtracting the shift value from the added value may be transferred to the fetch instruction counter.
[0060]
According to this configuration, a branch instruction with an absolute address or relative address designation is executed using the pointer held in the decoding instruction counter.
Here, the fetch instruction counter includes a register that holds a fetch address and an adder that increments the value of the register, and the branching unit is configured such that when a branch instruction with absolute address designation is decoded by a decoding unit, Calculation of a value obtained by adding the shift value to the absolute address may be executed by an adder in the fetch instruction counter, and the addition result may be transferred to the decoding instruction counter.
[0061]
According to this configuration, for a branch instruction with an absolute address specification, the pointer to be stored in the decoding instruction counter is calculated using the adder in the fetch instruction counter without occupying the resources of the execution unit. Can do.
[Brief description of the drawings]
FIG. 1 is a block diagram showing a configuration of a processor according to a first embodiment of the present invention.
FIG. 2 is a diagram showing a detailed configuration of a decryption instruction counter.
FIG. 3 is a flowchart showing processing contents in an instruction execution stage.
4 is a block diagram showing a detailed configuration of a
FIG. 5 is a diagram showing selection control logic of a
FIG. 6 is a diagram showing the operation content of an instruction with an address.
FIG. 7 is a diagram illustrating a pipeline state when a loop process is executed by a processor;
FIG. 8 is a block diagram illustrating a configuration of a processor according to a second embodiment of the present invention.
9 is a block diagram showing a detailed configuration of a fetch
FIG. 10 is a diagram showing the operation contents of an instruction with address designation.
FIG. 11 is a time chart showing the operation timing of a relative branch instruction (branch rel_adrs).
12 shows another configuration example of the queue of FIG.
13 shows selection logic of the selector in FIG.
[Explanation of symbols]
11 External memory
13 processor
14 Instruction fetch section
15 Instruction decoding part
16 Instruction execution part
17 Branch destination information storage unit
24 Instruction fetch section
25 Instruction decoding part
31 Adder
32 registers
33 Selector
91 Adder
92 Latch
93 Selector
101 adder
102 Latch
103 selector
104 selector
120 registers
121a to 121d selector
141 Fetch instruction counter
142 Fetch instruction buffer
143 selection part
143a to 143d selector
151 Decoding instruction counter
152 Decoding Instruction Buffer
153 instruction decoder
171 Branch destination instruction storage unit
171a Queue
171b Selection control unit
172 Branch destination fetch address storage unit
Claims (13)
前記解読部は、
解読中の命令を指すポインタとして、解読中の命令のアドレスに一定のシフト値を加算した値を保持する解読命令カウンタを備え、
前記実行部は、
前記解読部により前記登録命令が解読された場合に、前記フェッチ部によりフェッチされたプログラムループ先頭のコードを前記第1バッファに、前記解読命令カウンタに保持されているポインタを前記第2バッファに登録する登録手段と、
前記解読部により前記ループ命令が解読されかつ分岐が成立する場合に、前記第2バッファに登録されたポインタによって指される命令を前記フェッチ部にフェッチさせ、前記第1バッファに登録されたコードを前記解読部に解読させる高速分岐手段と、
絶対アドレス指定を伴う分岐命令が前記解読部により解読された場合、当該絶対アドレスをフェッチ命令カウンタに転送し、当該絶対アドレスに前記シフト値を加えた値を解読命令カウンタに転送する分岐手段とを備え、
前記シフト値は、前記登録命令が解読された場合に、前記登録手段が前記第2バッファに登録するポインタが、前記第1バッファに登録するコードに後続するコードのアドレスを指すように定められている
ことを特徴とするプロセッサ。A program loop having a fetch unit for fetching a code from the memory, a decoding unit for decoding an instruction in the fetched code, an execution unit for executing the decoded instruction, a first buffer, and a second buffer; A processor that executes a loop process at high speed using a registration instruction placed immediately before and a loop instruction placed at the end of the program loop,
The decoding unit is
As a pointer to an instruction in decode, it includes a decoded instruction counter that a value obtained by adding a fixed shift value to the address of the instruction in the decode Soo coercive,
The execution unit is
When the registering instruction is decoded by the decoding unit, the head code of the program loop fetched by the fetching unit is registered in the first buffer, and the pointer held in the decoding instruction counter is registered in the second buffer. Registration means to
When the decoding unit decodes the loop instruction and a branch is taken, the instruction pointed to by the pointer registered in the second buffer is fetched by the fetch unit, and the code registered in the first buffer is High-speed branching means for causing the decoding unit to decode ;
Branching means for transferring the absolute address to the fetch instruction counter and transferring the absolute address plus the shift value to the decoding instruction counter when a branch instruction with absolute address designation is decoded by the decoding unit; Prepared,
The shift value is determined so that, when the registration instruction is decoded, a pointer registered in the second buffer by the registration unit indicates an address of a code subsequent to a code registered in the first buffer. A processor characterized by being.
ことを特徴とする請求項1記載のプロセッサ。 The processor according to claim 1, wherein the constant shift value is equal to a storage area size of the first buffer.
ことを特徴とする請求項2記載のプロセッサ。The decoded instruction counter, when initialized, the processor of claim 2, wherein the holding the sum of the shift value as a start address.
ことを特徴とする請求項3記載のプロセッサ。The fetch unit includes an incrementer that updates the fetch address by the same number as the shift value, and the decoding instruction counter outputs an output from the incrementer as the pointer when the fetch address is initialized to a start address. The processor according to claim 3, wherein the processor is held.
ことを特徴とする請求項1記載のプロセッサ。Further, when a branch instruction with relative address designation is decoded by the decoding unit, the branching means transfers a value obtained by adding the relative address and the pointer held in the decoding instruction counter to the decoding instruction counter, and adds the same. The processor according to claim 1, wherein a value obtained by subtracting the shift value from a value is transferred to a fetch instruction counter.
ことを特徴とする請求項1記載のプロセッサ。The fetch instruction counter includes a register that holds a fetch address and an adder that increments the value of the register, and the branch unit is configured to output the absolute instruction when a branch instruction with absolute address designation is decoded by a decoding unit. 2. The processor according to claim 1 , wherein a calculation of a value obtained by adding the shift value to an address is executed by an adder in the fetch instruction counter, and a result of the addition is transferred to a decoding instruction counter.
前記フェッチ部は、
フェッチアドレスをカウントするフェッチ命令カウンタと、フェッチされたコードを保持するフェッチ命令バッファとを有し、
前記解読部は、
フェッチされたコード中の命令であって解読中の命令を保持する解読命令レジスタと、
解読中の命令を指すポインタを保持するものであって、前記ポインタは、解読命令レジスタに保持されている命令のアドレスと一定のシフト値との和である解読命令カウンタとを有し、
前記実行部は、
コードを保持する領域を有する第1バッファと、アドレスを保持する領域を有する第2バッファと、解読部において前記登録命令が解読された場合に、フェッチ命令バッファに保持されているコードを第1バッファに、解読命令カウンタに保持されているポインタを第2バッファに登録する登録手段と、
前記ループ命令が解読されかつ分岐が成立する場合に、第2バッファに登録されたポインタをフェッチ命令カウンタに、第1バッファからプログラムループ先頭のコードを解読命令レジスタに転送する高速分岐手段と、
絶対アドレス指定を伴う分岐命令が解読部により解読された場合、当該絶対アドレスをフェッチ命令カウンタに転送し、当該絶対アドレスに前記シフト値を加えた値を解読命令カウンタに転送する分岐手段とを有し、
前記第1バッファに登録されたコードは、前記プログラムループの先頭のコードを含み、前記シフト値は、第1バッファのサイズに等しく、第2バッファに登録されたポインタは、第1バッファに格納されたコードに後続するコードのアドレスを指すことを特徴とするプロセッサ。Pipeline processing comprising at least three stages, including a fetch unit for fetching code in the fetch stage, a decryption unit for decrypting the fetched instruction in the decryption stage, and an execution unit for executing the decrypted instruction in the execution stage A processor that executes loop processing at high speed using a registration instruction placed immediately before the program loop and a loop instruction placed at the end of the program loop,
The fetch unit
A fetch instruction counter that counts fetch addresses; and a fetch instruction buffer that holds fetched code;
The decoding unit is
An instruction in the fetched code that holds the instruction being decoded;
Holding a pointer to the instruction being decoded , said pointer having a decoding instruction counter which is the sum of the address of the instruction held in the decoding instruction register and a constant shift value;
The execution unit is
A first buffer having an area for holding a code; a second buffer having an area for holding an address; and a code held in a fetch instruction buffer when the registration instruction is decoded by a decoding unit. Registration means for registering the pointer held in the decryption instruction counter in the second buffer;
High-speed branching means for transferring the pointer registered in the second buffer to the fetch instruction counter and transferring the code at the head of the program loop from the first buffer to the decoding instruction register when the loop instruction is decoded and a branch is taken ;
Branching means for transferring the absolute address to the fetch instruction counter and transferring the absolute address plus the shift value to the decoding instruction counter when the branch instruction with the absolute address designation is decoded by the decoding unit. And
The code registered in the first buffer includes the head code of the program loop, the shift value is equal to the size of the first buffer, and the pointer registered in the second buffer is stored in the first buffer. A processor characterized by pointing to the address of a code that follows the code.
ことを特徴とする請求項7記載のプロセッサ。 The processor according to claim 7 , wherein the decoding instruction counter holds a sum of an initial value and the shift value at the time of initialization.
ことを特徴とする請求項8記載のプロセッサ。The fetch unit includes an incrementer that updates the fetch address by the same number as the shift value, and the decoding instruction counter outputs an output from the incrementer as the pointer when the fetch address is initialized to a start address. The processor according to claim 8, wherein the processor is held.
ことを特徴とする請求項8記載のプロセッサ。The program loop is composed of instructions of variable word length, and the processor further selects a code corresponding to the size of the decoding instruction buffer from the code held in the fetch instruction buffer and the code held in the first buffer. Selection means for selecting and outputting to the decoding instruction buffer; and a selection control unit for controlling the selection means to select the code of the fetch instruction buffer following the code of the first buffer, and the high-speed branching means includes: A selection control unit is activated when the loop instruction is decoded and a branch is taken, and the selection unit selects a code of a fetch instruction buffer when the selection control unit is not activated. The processor of claim 8 .
ことを特徴とする請求項7記載のプロセッサ。Further, when a branch instruction with relative address designation is decoded by the decoding unit, the branching means transfers a value obtained by adding the relative address and the pointer held in the decoding instruction counter to the decoding instruction counter, and adds the same. The processor according to claim 7, wherein a value obtained by subtracting the shift value from a value is transferred to a fetch instruction counter.
ことを特徴とする請求項11記載のプロセッサ。The fetch instruction counter includes an address register that holds a fetch address and a first adder that increments the fetch address of the address register by a predetermined number, and the decoding instruction counter includes a pointer register that holds the pointer; A second adder that increments the pointer of the pointer register by the decoded instruction word length, and the branch means is held in the second register when a branch instruction with relative addressing is decoded. A pointer and a negative number of the shift value are added to the second adder, the sum of the addition result and the relative address is stored in the first register as a branch destination address, and the shift value is set as the predetermined number The branch destination address of the first register and the predetermined number are added to the first adder, and the addition result is The processor of claim 11, wherein the storing the Ntarejisuta.
前記分岐手段は、絶対アドレス指定を伴う分岐命令が解読部により解読された場合に、前記絶対アドレスに前記シフト値を加えた値の計算を、前記フェッチ命令カウンタ内の加算器に実行させ、その加算結果を解読命令カウンタに転送する
ことを特徴とする請求項7記載のプロセッサ。The fetch instruction counter includes a register that holds a fetch address, and an adder that increments the value of the register,
The branching unit causes the adder in the fetch instruction counter to calculate a value obtained by adding the shift value to the absolute address when a branch instruction with absolute address designation is decoded by a decoding unit, The processor according to claim 7, wherein the addition result is transferred to a decoding instruction counter.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP18093998A JP3971509B2 (en) | 1997-06-30 | 1998-06-26 | Processor |
Applications Claiming Priority (3)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP17455197 | 1997-06-30 | ||
| JP9-174551 | 1997-06-30 | ||
| JP18093998A JP3971509B2 (en) | 1997-06-30 | 1998-06-26 | Processor |
Publications (3)
| Publication Number | Publication Date |
|---|---|
| JPH1173316A JPH1173316A (en) | 1999-03-16 |
| JPH1173316A5 JPH1173316A5 (en) | 2005-09-29 |
| JP3971509B2 true JP3971509B2 (en) | 2007-09-05 |
Family
ID=26496127
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP18093998A Expired - Lifetime JP3971509B2 (en) | 1997-06-30 | 1998-06-26 | Processor |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP3971509B2 (en) |
-
1998
- 1998-06-26 JP JP18093998A patent/JP3971509B2/en not_active Expired - Lifetime
Also Published As
| Publication number | Publication date |
|---|---|
| JPH1173316A (en) | 1999-03-16 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP3592230B2 (en) | Data processing device | |
| JP2816248B2 (en) | Data processor | |
| JPH0816391A (en) | Computer system, instruction bit length compression method, instruction generation method, and computer system operation method | |
| US11960891B2 (en) | Look-up table write | |
| JPH1091435A (en) | Processor for executing two types of instruction length codes and instruction code input device thereof | |
| EP1241567B1 (en) | Method and apparatus for executing coprocessor instructions | |
| KR100875377B1 (en) | Apparatus and Method for Performing Stack Pop and Push Operations in a Processing System | |
| US5590358A (en) | Processor with word-aligned branch target in a byte-oriented instruction set | |
| US20190391812A1 (en) | Conditional execution specification of instructions using conditional extension slots in the same execute packet in a vliw processor | |
| US5459847A (en) | Program counter mechanism having selector for selecting up-to-date instruction prefetch address based upon carry signal of adder which adds instruction size and LSB portion of address register | |
| US6108768A (en) | Reissue logic for individually reissuing instructions trapped in a multiissue stack based computing system | |
| KR100510030B1 (en) | Pipeline processor capable of reducing branch hazards with small-scale circuit | |
| EP1053522B1 (en) | Microprocessor including multiple register files occupying the same logical space | |
| WO2019133258A1 (en) | Look up table with data element promotion | |
| JP4955149B2 (en) | Digital signal processor with bit FIFO | |
| US6237086B1 (en) | 1 Method to prevent pipeline stalls in superscalar stack based computing systems | |
| JP3971509B2 (en) | Processor | |
| JP2538053B2 (en) | Control device | |
| US6170050B1 (en) | Length decoder for variable length data | |
| JPS59501426A (en) | Mechanism for calculating the next address in advance | |
| US6530013B1 (en) | Instruction control apparatus for loading plurality of instructions into execution stage | |
| US5649226A (en) | Processor having multiple instruction registers | |
| US11900112B2 (en) | Vector reverse | |
| JP2002229776A (en) | Data processor for executing multiple sets of instructions | |
| JP2825315B2 (en) | Information processing device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20050509 |
|
| A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20050509 |
|
| A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20061019 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20061031 |
|
| A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20061227 |
|
| 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: 20070515 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20070608 |
|
| R150 | Certificate of patent or registration of utility model |
Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20100615 Year of fee payment: 3 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110615 Year of fee payment: 4 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120615 Year of fee payment: 5 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120615 Year of fee payment: 5 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20130615 Year of fee payment: 6 |
|
| S533 | Written request for registration of change of name |
Free format text: JAPANESE INTERMEDIATE CODE: R313533 |
|
| R350 | Written notification of registration of transfer |
Free format text: JAPANESE INTERMEDIATE CODE: R350 |
|
| S111 | Request for change of ownership or part of ownership |
Free format text: JAPANESE INTERMEDIATE CODE: R313113 |
|
| R360 | Written notification for declining of transfer of rights |
Free format text: JAPANESE INTERMEDIATE CODE: R360 |
|
| R360 | Written notification for declining of transfer of rights |
Free format text: JAPANESE INTERMEDIATE CODE: R360 |
|
| R371 | Transfer withdrawn |
Free format text: JAPANESE INTERMEDIATE CODE: R371 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| S111 | Request for change of ownership or part of ownership |
Free format text: JAPANESE INTERMEDIATE CODE: R313113 |
|
| R371 | Transfer withdrawn |
Free format text: JAPANESE INTERMEDIATE CODE: R371 |
|
| S111 | Request for change of ownership or part of ownership |
Free format text: JAPANESE INTERMEDIATE CODE: R313113 |
|
| R350 | Written notification of registration of transfer |
Free format text: JAPANESE INTERMEDIATE CODE: R350 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| S131 | Request for trust registration of transfer of right |
Free format text: JAPANESE INTERMEDIATE CODE: R313135 |
|
| SZ02 | Written request for trust registration |
Free format text: JAPANESE INTERMEDIATE CODE: R313Z02 |
|
| S131 | Request for trust registration of transfer of right |
Free format text: JAPANESE INTERMEDIATE CODE: R313135 |
|
| SZ02 | Written request for trust registration |
Free format text: JAPANESE INTERMEDIATE CODE: R313Z02 |
|
| R350 | Written notification of registration of transfer |
Free format text: JAPANESE INTERMEDIATE CODE: R350 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| EXPY | Cancellation because of completion of term |