JP2006228257A - Instruction control method - Google Patents

Instruction control method Download PDF

Info

Publication number
JP2006228257A
JP2006228257A JP2006153452A JP2006153452A JP2006228257A JP 2006228257 A JP2006228257 A JP 2006228257A JP 2006153452 A JP2006153452 A JP 2006153452A JP 2006153452 A JP2006153452 A JP 2006153452A JP 2006228257 A JP2006228257 A JP 2006228257A
Authority
JP
Japan
Prior art keywords
instruction
branch
delay
predicted
issued
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.)
Granted
Application number
JP2006153452A
Other languages
Japanese (ja)
Other versions
JP3971780B2 (en
Inventor
Ryuichi Sunayama
竜一 砂山
Aiichiro Inoue
愛一郎 井上
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.)
Fujitsu Ltd
Original Assignee
Fujitsu 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 Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2006153452A priority Critical patent/JP3971780B2/en
Publication of JP2006228257A publication Critical patent/JP2006228257A/en
Application granted granted Critical
Publication of JP3971780B2 publication Critical patent/JP3971780B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Advance Control (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To surely prevent performance deterioration without requiring a large storage capacity for instruction control and by controlling so that the whole flow of instruction processing in a processor is not temporarily stopped in regard to an instruction control method. <P>SOLUTION: The instruction control method having a delay instruction for branching is constituted so that at the time of branch prediction, after a branch instruction is estimated not to be branch established and an instruction is issued with the delay instruction once replaced with a Non-Operation instruction, when the previous branch instruction is determined to be branch established, an instruction is issued with not only an instruction fetch request of a branch destination but also a corresponding delay instruction extracted from storage; after the instruction is estimated to be branch established and a delay instruction corresponding to the branch instruction is issued, an instruction of the estimated branch destination is issued; and when the estimated branch destination is correct, the instruction is continued to be executed as it is, or when the estimated branch destination is incorrect, an instruction refetch request of the branch destination instruction after the delay instruction is made. <P>COPYRIGHT: (C)2006,JPO&NCIPI

Description

本発明は命令制御方法及びプロセッサに係り、特に分岐予測を行うと共に分岐のための遅延命令を持つ命令制御において分岐命令を含めた複数の命令を高速に処理するための命令制御方法、及びそのような命令制御方法を用いるプロセッサに関する。   The present invention relates to an instruction control method and a processor, and more particularly to an instruction control method for performing a branch prediction and processing a plurality of instructions including a branch instruction at high speed in instruction control having a delay instruction for branching, and the like. The present invention relates to a processor using an instruction control method.

近年、プロセッサの性能を向上させるために、様々な命令処理方式が用いられる。その中の1つに、アウトオブオーダー処理方式がある。アウトオブオーダー処理方式を採用したプロセッサにおいては、1つの命令実行の完了を待たずに後続の命令列を順次、複数のパイプラインに投入して命令を実行させることで、性能の向上を行なっている。   In recent years, various instruction processing methods have been used to improve processor performance. One of them is an out-of-order processing method. In a processor adopting the out-of-order processing method, the performance is improved by sequentially executing subsequent instructions in a plurality of pipelines without waiting for completion of execution of one instruction. Yes.

しかし、先行している命令の実行結果が後続の命令の実行に影響を与える場合には、先行している命令実行が完了しなければ後続の命令を実行させることができない。後続の命令の実行に影響を与える命令の処理が遅ければ、その間後続の命令は実行できず、先行の命令完了を待ち続けることになる。このため、パイプラインに乱れが生じ、性能の低下を引き起こす。このようなパイプラインの乱れは、特に分岐命令の場合に顕著に現れる。   However, when the execution result of the preceding instruction affects the execution of the subsequent instruction, the subsequent instruction cannot be executed unless the preceding instruction execution is completed. If the processing of the instruction that affects the execution of the subsequent instruction is delayed, the subsequent instruction cannot be executed during that time, and the process waits for completion of the preceding instruction. For this reason, the pipeline is disturbed, resulting in performance degradation. Such pipeline disturbance is particularly noticeable in the case of branch instructions.

分岐命令の中でも、条件分岐と呼ばれる命令の場合、条件分岐命令の直前で分岐条件(通常はコンディションコード)を変更する命令があると、その命令が完了するまで分岐が確定しない。従って、分岐命令の後続のシーケンスがわからないために、後続の命令を投入できず、処理が止まってしまい処理能力が低下する。このことはアウトオブオーダー処理方式を採用したプロセッサに限らず、ロック・ステップ・パイプライン等の処理方式を採用しているプロセッサにおいても同様の問題が生じるが、アウトオブオーダー処理方式を採用しているプロセッサにおいては、より顕著に性能の低下が生じる。そこで、分岐命令による性能低下を抑えるために、通常は、分岐予測を行う分岐予測機構をプロセッサ内の命令制御装置に設けて、分岐命令の高速化を図っている。   Among branch instructions, in the case of an instruction called a conditional branch, if there is an instruction that changes the branch condition (usually the condition code) immediately before the conditional branch instruction, the branch is not fixed until the instruction is completed. Therefore, since the subsequent sequence of the branch instruction is not known, the subsequent instruction cannot be input, the processing is stopped, and the processing capability is reduced. This is not limited to processors that use the out-of-order processing method, but the same problem arises in processors that employ processing methods such as lock, step, and pipeline. In some processors, the performance is more significantly degraded. Therefore, in order to suppress the performance degradation due to the branch instruction, a branch prediction mechanism for performing branch prediction is usually provided in the instruction control device in the processor to speed up the branch instruction.

分岐予測機構を用いる場合、分岐命令を実行する時に分岐が生じるか否かか判明する前に、後続の命令や分岐先の命令を事前に実行する。分岐予測機構は、分岐命令を実行した結果、分岐が行われた場合に分岐先の命令アドレスと分岐命令自身の命令アドレスとを対にして分岐予測機構内に登録し、命令の実行にあたって、命令をプロセッサ内の主記憶装置から取り出す時に、その命令の実行に先立って検索する構造となっている。分岐予測機構を設けて分岐予測を行うことで、命令制御装置は、命令をできるだけ滞らせることなく、主記憶装置から命令フェッチを行い命令を順次投入することができる。   When the branch prediction mechanism is used, subsequent instructions and branch destination instructions are executed in advance before it is determined whether or not a branch occurs when executing a branch instruction. When a branch is executed as a result of executing a branch instruction, the branch prediction mechanism registers the branch destination instruction address and the instruction address of the branch instruction itself in the branch prediction mechanism, and executes the instruction when executing the instruction. Is retrieved from the main memory in the processor prior to execution of the instruction. By providing a branch prediction mechanism and performing branch prediction, the instruction control device can fetch instructions from the main storage device and sequentially input instructions without delaying instructions as much as possible.

ここで問題となるのが、分岐のための遅延命令を持つ命令制御方式を採用する場合である。この場合、分岐命令は、次のように実行される。例えば、命令シーケンスがa1、a2、a3、a4、a5、a6であり、a3が条件分岐で、a4が遅延命令の場合、a3が分岐する場合はa1、a2、a3、a4、b1、b2(b1は分岐先の命令)の順に命令が投入され、a3が分岐しない場合はa1、a2、a3、a5、a6の順に命令が投入される。
特開平4−213727号公報
The problem here is when an instruction control system having a delayed instruction for branching is employed. In this case, the branch instruction is executed as follows. For example, if the instruction sequence is a1, a2, a3, a4, a5, a6, a3 is a conditional branch, a4 is a delayed instruction, and a3 branches, a1, a2, a3, a4, b1, b2 ( The instructions are input in the order of b1), and if a3 does not branch, the instructions are input in the order of a1, a2, a3, a5, a6.
JP-A-4-213727

従来技術では、任意の命令アドレスの分岐命令が過去に分岐したか分岐しなかったかの情報を登録し、それと対にして分岐命令の命令アドレス、分岐した場合は分岐先の命令アドレス、分岐しなかった場合は次に実行される命令アドレスを持つことにより、分岐命令が分岐するか分岐しないかを予測していた。しかし、分岐命令が分岐した場合と分岐しない場合のいずれの場合においても情報と命令アドレスの対を登録しなければならず、命令制御に必要な記憶容量が大きくなってしまうという問題があった。   In the prior art, information on whether a branch instruction at an arbitrary instruction address has branched or not branched in the past was registered, and the instruction address of the branch instruction was paired with it, and if it was branched, the branch destination instruction address was not branched. In some cases, the instruction address to be executed next is used to predict whether the branch instruction will branch or not. However, in both cases where the branch instruction branches and does not branch, there is a problem in that the information and instruction address pair must be registered, and the storage capacity necessary for instruction control becomes large.

又、予測が失敗した場合、特に予測できなかった分岐命令がデコードされた場合には、分岐命令が分岐する、しないにかかわらず、常に分岐命令の分岐条件が確定して分岐判定が行われるまで、後続の命令の投入を一時的に止める必要があった。この結果、プロセッサ内の命令処理の全体の流れが一時的に停止され、著しく性能が低下してしまうという問題もあった。   In addition, when prediction fails, especially when an unpredictable branch instruction is decoded, the branch instruction always branches regardless of whether the branch instruction branches or not until branch determination is performed. It was necessary to temporarily stop the input of subsequent instructions. As a result, there is also a problem that the entire flow of instruction processing in the processor is temporarily stopped, and the performance is remarkably deteriorated.

そこで、本発明は、命令制御に大きな記憶容量を必要とせず、且つ、プロセッサ内の命令処理の全体の流れが一時的に停止されることを抑止して性能低下を確実に防止することのできる命令制御方法及びプロセッサを実現することを目的とする。   Therefore, the present invention does not require a large storage capacity for instruction control, and can prevent the entire flow of instruction processing in the processor from being temporarily stopped and reliably prevent performance degradation. It is an object to realize an instruction control method and a processor.

上記の課題は、分岐のための遅延命令をもつ命令制御方法であって、分岐予測を行った時、分岐命令が分岐不成立と予測され遅延命令が一旦Non-Operation命令に置きかえられて命令が発行された後、直前の分岐命令で分岐成立と確定した場合には分岐先の命令フェッチ要求と共に記憶装置より対応する遅延命令を取り出して命令を発行し、分岐成立と予測され該分岐命令に対応する遅延命令が発行された後、予測された分岐先の命令が発行されて予測された分岐先が正しい場合にはそのまま命令実行を継続すると共に予測された分岐先が誤っている場合には遅延命令後の分岐先命令の命令再フェッチ要求を行うステップを含むことを特徴とする命令制御方法によって達成できる。   The above problem is an instruction control method with a delayed instruction for branching. When branch prediction is performed, the branch instruction is predicted to be unsuccessful, and the delayed instruction is temporarily replaced with a non-operation instruction. After that, when it is determined that the branch is established by the immediately preceding branch instruction, a corresponding delay instruction is fetched from the storage device together with the branch destination instruction fetch request, and the instruction is issued. After the delayed instruction is issued, if the predicted branch destination is issued and the predicted branch destination is correct, the instruction execution is continued as it is, and if the predicted branch destination is incorrect, the delayed instruction This can be achieved by an instruction control method including a step of performing an instruction refetch request for a later branch destination instruction.

上記の課題は、分岐のための遅延命令をもつ命令制御方法であって、分岐予測を行った時、分岐命令が分岐不成立と予測され遅延命令が一旦Non-Operation命令に置き換えられて命令が発行された後、直前の分岐命令で分岐不成立と確定した場合にはそのまま命令実行を続行し、分岐成立と予測されその後分岐不成立と確定した場合には元のシーケンシャルな命令の命令再フェッチ要求を行ってフェッチ完了後直ちに命令を発行するステップを含むことを特徴とする命令制御方法によっても達成できる。   The above problem is an instruction control method having a delayed instruction for branching. When branch prediction is performed, the branch instruction is predicted to be unsuccessful, and the delayed instruction is temporarily replaced with a non-operation instruction. If the previous branch instruction is determined to be unsuccessful, the instruction execution is continued. If the branch is predicted to be established and then confirmed to be unsuccessful, an instruction refetch request for the original sequential instruction is made. This can also be achieved by an instruction control method including a step of issuing an instruction immediately after completion of fetching.

本発明によれば、命令制御に大きな記憶容量を必要とせず、且つ、プロセッサ内の命令処理の全体の流れが一時的に停止されることを抑止して性能低下を確実に防止することのできる命令制御方法及びプロセッサを実現することが可能となる。   According to the present invention, a large storage capacity is not required for instruction control, and the entire flow of instruction processing in the processor can be prevented from being temporarily stopped, and performance degradation can be reliably prevented. An instruction control method and a processor can be realized.

本発明では、分岐のための遅延命令を一時的に格納し、いつでも取り出せる記憶機構を、プロセッサの命令制御装置内に設けている。遅延命令を格納する場合は、格納されている遅延命令がどの分岐命令に対応しているかを示すタグ情報と共に保持する。本発明では、分岐が成立した分岐命令は分岐予測部に登録するが、分岐が成立しなかった分岐命令については登録を行わない。つまり、過去に分岐した分岐命令については、先行して分岐先の命令のフェッチを行うが、分岐予測が行われなかった場合は、そのままシーケンシャルな命令フェッチを行い、そのまま命令を実行パイプラインに投入する。   In the present invention, a storage mechanism for temporarily storing a delay instruction for branching and retrieving it at any time is provided in the instruction control unit of the processor. When a delayed instruction is stored, it is held together with tag information indicating which branch instruction corresponds to the stored delayed instruction. In the present invention, a branch instruction in which a branch is established is registered in the branch prediction unit, but a branch instruction in which a branch is not established is not registered. In other words, for branch instructions that have branched in the past, the branch destination instruction is fetched in advance, but if branch prediction is not performed, sequential instruction fetch is performed as it is, and the instruction is directly input to the execution pipeline. To do.

ただし、そのままだと分岐命令の遅延命令も投入することになるので、分岐予測されなかった分岐命令が発行され、且つ、無効(Annul)ビットが「1」であると、それに対応する遅延命令については一旦新しく設けた遅延命令を格納する記憶機構に保持し、実行パイプラインには遅延命令の代わりにNon-Operation命令を投入する。分岐条件が確定し、分岐命令が分岐しない場合は、そのまま命令処理を続行する(予測が当たったことになる)。このとき、該当する分岐命令の遅延命令は、エントリーからはずされる。   However, if it is left as it is, a branch instruction delay instruction is also input. Therefore, if a branch instruction that is not predicted to be branched is issued and the invalid bit is “1”, a corresponding delay instruction is issued. Is temporarily stored in a storage mechanism for storing a delay instruction, and a non-operation instruction is input to the execution pipeline instead of the delay instruction. If the branch condition is fixed and the branch instruction does not branch, the instruction processing is continued as it is (prediction is successful). At this time, the delay instruction of the corresponding branch instruction is removed from the entry.

分岐する場合は、分岐条件と分岐先アドレスが確定した時点で、分岐先の命令のフェッチ要求を出すと共に、分岐命令が完了すると、実行中の他の命令を実行パイプラインからクリアし、分岐命令の遅延命令を取りだして実行パイプラインに投入する。遅延命令の発行後は、分岐先の命令を投入する。遅延命令が発行されると、その遅延命令は、エントリーからはずされる。分岐予測が行われた場合、予測された分岐命令に対応する遅延命令の投入後、予測分岐先の命令が投入される。この場合、遅延命令の格納は行われない。   When branching, when the branch condition and branch destination address are determined, a fetch request for the branch destination instruction is issued. When the branch instruction is completed, the other instructions being executed are cleared from the execution pipeline, and the branch instruction is issued. Is taken out and put into the execution pipeline. After issuing the delay instruction, the branch destination instruction is input. When a delayed instruction is issued, the delayed instruction is removed from the entry. When branch prediction is performed, a predicted branch destination instruction is input after a delay instruction corresponding to the predicted branch instruction is input. In this case, the delayed instruction is not stored.

分岐条件が確定して分岐する場合は、予測した分岐先のアドレスが正しかった場合はそのまま命令実行が行われ、分岐するが分岐先のアドレスが間違っていた場合は分岐先のアドレスが確定した時点で分岐先の命令再フェッチ要求(再命令フェッチ要求)を出して、遅延命令を投入後に、分岐先の命令の投入を行う。分岐予測が行われて分岐条件が確定して分岐しない場合は、分岐判定が行われた時点で後続命令の命令再フェッチ要求を出す。分岐命令が完了すると、実行パイプラインはクリアされ、その後、後続命令の投入が行われる。   If the branch condition is confirmed and the branch is taken, if the predicted branch destination address is correct, the instruction is executed as it is, and if the branch destination is incorrect but the branch destination address is confirmed The branch destination instruction refetch request (re-instruction fetch request) is issued at, and after the delay instruction is input, the branch destination instruction is input. If branch prediction is performed and the branch condition is fixed and the branch is not taken, an instruction refetch request for the subsequent instruction is issued when the branch determination is made. When the branch instruction is completed, the execution pipeline is cleared, and then the subsequent instruction is input.

本発明では、分岐予測に失敗した場合、即ち、1)分岐予測を行ったが分岐しなかった、2)分岐予測を行ったが分岐先アドレスを間違えた、3)分岐予測ができず分岐した、の3つのケースについては命令再フェッチが必要であるが、これは従来技術の場合も同じである。しかし。その他のケースにおいては、命令フェッチ、実行パイプラインのいずれもその処理の流れを止めることなく命令処理を行うことが出来るため、より高速に命令処理を行うことができる。   In the present invention, when branch prediction fails, that is, 1) branch prediction is performed but branch is not performed, 2) branch prediction is performed but the branch destination address is wrong, and 3) branch prediction is not performed and branch is performed. In these three cases, instruction refetching is necessary, which is the same as in the prior art. However. In other cases, both the instruction fetch and the execution pipeline can perform instruction processing without stopping the processing flow, so that instruction processing can be performed at higher speed.

本発明になる命令制御方法及び本発明になるプロセッサの各実施例を、以下図面と共に説明する。   Embodiments of the instruction control method according to the present invention and the processor according to the present invention will be described below with reference to the drawings.

図1は、本発明になるプロセッサの一実施例を示すブロック図である。同図中、プロセッサ100は、命令ユニット21、メモリユニット22及び演算ユニット23を含む。命令ユニット21は、本発明になる命令制御方法の一実施例を採用する命令制御装置を構成する。メモリユニット22は、命令やデータ等を格納するために設けられ、演算ユニット23は、各種演算を実行するために設けられている。   FIG. 1 is a block diagram showing an embodiment of a processor according to the present invention. In the figure, a processor 100 includes an instruction unit 21, a memory unit 22, and an arithmetic unit 23. The instruction unit 21 constitutes an instruction control apparatus that employs an embodiment of the instruction control method according to the present invention. The memory unit 22 is provided for storing instructions, data, and the like, and the arithmetic unit 23 is provided for executing various arithmetic operations.

命令ユニット21は、図1に示す如く接続された分岐予測部1、命令フェッチ部2、命令バッファ部3、相対分岐アドレス生成部4、命令デコーダ部5、分岐命令実行部6、命令完了制御部9、分岐先アドレスレジスタ10及びプログラムカウンタ部11からなる。分岐命令実行部6は、分岐命令制御部7及びディレイスロットスタック部8からなる。プログラムカウンタ部11には、プログラムカウンタ(PC)とネクストプログラムカウンタ(nPC)が含まれる。   The instruction unit 21 includes a branch prediction unit 1, an instruction fetch unit 2, an instruction buffer unit 3, a relative branch address generation unit 4, an instruction decoder unit 5, a branch instruction execution unit 6, and an instruction completion control unit connected as shown in FIG. 9 includes a branch destination address register 10 and a program counter unit 11. The branch instruction execution unit 6 includes a branch instruction control unit 7 and a delay slot stack unit 8. The program counter unit 11 includes a program counter (PC) and a next program counter (nPC).

分岐命令の制御は、分岐予測部1、分岐命令制御部7、命令完了制御部9及び分岐先アドレスレジスタ10において独立して制御できる。実行パイプライン上に存在する分岐命令は、命令デコーダ部5においてデコードされると、一旦分岐命令制御部7の制御下となる。分岐命令制御部7では、分岐命令の分岐条件判定、分岐予測の成否及び命令再フェッチの制御を行う。分岐命令制御部7で制御可能な分岐命令数は、エントリー数で決定される。分岐命令制御部7での制御は、分岐命令の分岐条件確定及び分岐先アドレス生成までであり、それ以降は命令完了制御部9において制御が行われる。分岐先アドレスレジスタ10では、分岐命令制御部7での制御から開放された分岐する分岐命令の分岐先アドレスを制御しており、命令完了、即ち、プログラムカウンタ部11の更新まで制御する。命令完了制御部9では、全命令の命令完了条件を制御しており、分岐命令は、分岐の可否によらず必ず制御される。   The branch instruction can be controlled independently in the branch prediction unit 1, the branch instruction control unit 7, the instruction completion control unit 9, and the branch destination address register 10. A branch instruction existing on the execution pipeline is once under the control of the branch instruction control unit 7 once decoded by the instruction decoder unit 5. The branch instruction control unit 7 controls branch condition determination of branch instructions, success / failure of branch prediction, and instruction refetch. The number of branch instructions that can be controlled by the branch instruction control unit 7 is determined by the number of entries. The control in the branch instruction control unit 7 is until the branch condition determination of the branch instruction and the generation of the branch destination address, and thereafter, the control is performed in the instruction completion control unit 9. The branch destination address register 10 controls the branch destination address of the branch instruction that is released from the control by the branch instruction control unit 7 and controls until the instruction is completed, that is, the program counter unit 11 is updated. The instruction completion control unit 9 controls instruction completion conditions for all instructions, and branch instructions are always controlled regardless of whether or not branching is possible.

分岐先アドレス生成は、命令相対分岐とレジスタ相対分岐の2種類に分けられる。命令相対分岐の分岐先アドレス生成は、相対分岐アドレス生成部4で計算され、分岐命令制御部7経由で分岐先アドレスレジスタ10に供給される。レジスタ相対分岐の分岐先アドレスは、命令実行ユニット23内で計算され、分岐命令制御部7経由で分岐先アドレスレジスタ10に供給される。例えば、レジスタ相対分岐の分岐先アドレスの下位32ビットは分岐命令制御部7経由で、上位32ビットは直接プログラムカウンタ部11に供給される。アドレス相対分岐の分岐先アドレスは、上位32ビットが変わる時はボロウ(Borrow)ビット、キャリー(Carry)ビットの有無に基づいて計算により求められるので、分岐命令制御部7では分岐先命令アドレスは(下位32ビット+4ビットパリティ+Borrowビット+Carryビット)*エントリー数で制御される。分岐先アドレスレジスタ10においても同様に、分岐先命令アドレスは(下位32ビット+4ビットパリティ+Borrowビット+Carryビット)*エントリー数で構成されている。命令アドレスの上位32ビットが変わる時は、一旦命令バッファ部3に値をセットした後にプログラムカウンタ部11からのリトライにより命令フェッチを必ず行うようにする。   Branch destination address generation is divided into two types: instruction relative branch and register relative branch. The branch destination address generation of the instruction relative branch is calculated by the relative branch address generation unit 4 and supplied to the branch destination address register 10 via the branch instruction control unit 7. The branch destination address of the register relative branch is calculated in the instruction execution unit 23 and supplied to the branch destination address register 10 via the branch instruction control unit 7. For example, the lower 32 bits of the branch destination address of the register relative branch are supplied to the program counter unit 11 via the branch instruction control unit 7 and the upper 32 bits are directly supplied to the program counter unit 11. Since the branch destination address of the address relative branch is obtained by calculation based on the presence or absence of the Borrow bit and the Carry bit when the upper 32 bits are changed, the branch destination control address is ( (Lower 32 bits + 4 bits parity + Borrow bits + Carry bits) * Controlled by the number of entries. Similarly, in the branch destination address register 10, the branch destination instruction address is composed of (lower 32 bits + 4 bits parity + Borrow bits + Carry bits) * number of entries. When the upper 32 bits of the instruction address are changed, an instruction fetch is always performed by a retry from the program counter unit 11 after a value is once set in the instruction buffer unit 3.

使用するリソースの更新のための制御は、命令完了制御部9及びプログラムカウンタ部11で行われる。プログラムカウンタ部11の場合、コミットでは同時に何命令がコミットしたか、分岐する命令がコミットしたかどうかの情報が供給される。尚、分岐する命令がコミットした場合は、その情報が分岐命令制御部7にも供給される。本実施例では、PC=nPC+(同時コミットした数-1)*4、nPC=nPC+(同時コミットした数*4)若しくは分岐先アドレスとなる。本実施例では、分岐する分岐命令はそれより前にある命令とは同時にコミットできるが、その後ろにある命令とは同時コミットしないようになっている。これは、プログラムカウンタPCにセットするパスに、分岐先アドレスのパスを入れていないからであり、ネクストプログラムカウンタnPCと同様に、プログラムカウンタPCにも分岐先アドレスのパスを入れれば、分岐命令の同時コミット数の制約はなくなる。分岐しない分岐命令においては、本実施例においても、同時コミット数の制約は受けない。本実施例では、分岐命令がコミットする際に、コミットする位置の制約はなく、又、デコード時にも制約を受けない。   Control for updating resources to be used is performed by the instruction completion control unit 9 and the program counter unit 11. In the case of the program counter unit 11, information on how many instructions have been committed at the same time and whether a branching instruction has been committed are supplied. When the branching instruction is committed, the information is also supplied to the branch instruction control unit 7. In this embodiment, PC = nPC + (number of simultaneously committed-1) * 4, nPC = nPC + (number of simultaneously committed * 4), or branch destination address. In this embodiment, a branch instruction that branches can be committed at the same time as an instruction preceding it, but not at the same time as an instruction that follows. This is because the path of the branch destination address is not included in the path set in the program counter PC. Similarly to the next program counter nPC, if the path of the branch destination address is also included in the program counter PC, the branch instruction There is no restriction on the number of concurrent commits. A branch instruction that does not branch is not restricted by the number of simultaneous commits in this embodiment. In this embodiment, when the branch instruction commits, there is no restriction on the commit position, and there is no restriction at the time of decoding.

図2は、図1に示す命令ユニット21の要部を示すブロック図である。図2中、図1と同一部分には同一符号を付し、その説明は省略する。図2において、命令デコーダ部5には、命令ワードレジスタIWR0〜IWR3からなるレジスタ部15が設けられている。分岐命令制御部7は、m個のRSBR0〜RSBRm(Reservation Stations for Branch)からなる。ディレイスロットスタック部8は、n個のDSS0〜DSSn(Delay Slot Stacks)からなり、各種記憶装置により構成可能である。尚、図2の上部には、プリデコードが行われる区間(サイクル)Eと、デコードが行われる区間(サイクル)Dが示されている。   FIG. 2 is a block diagram showing a main part of the instruction unit 21 shown in FIG. In FIG. 2, the same parts as those of FIG. In FIG. 2, the instruction decoder unit 5 is provided with a register unit 15 including instruction word registers IWR0 to IWR3. The branch instruction control unit 7 includes m RSBR0 to RSBRm (Reservation Stations for Branch). The delay slot stack unit 8 includes n DSS0 to DSSn (Delay Slot Stacks), and can be configured by various storage devices. 2 shows a section (cycle) E in which predecoding is performed and a section (cycle) D in which decoding is performed.

本実施例では、説明の便宜上、SPARCアーキテクチャが採用されているものとして説明する。命令は、アウトオブオーダーで処理され、分岐命令実行部6においては、上記の如く複数のRSBR0〜RSBRm及び複数のDSS0〜DSSnが設けられている。又、分岐命令予測機構として、分岐予測部1が設けられている。   In this embodiment, for the sake of convenience of explanation, it is assumed that the SPARC architecture is adopted. The instructions are processed out-of-order, and the branch instruction execution unit 6 is provided with a plurality of RSBR0 to RSBRm and a plurality of DSS0 to DSSn as described above. Further, a branch prediction unit 1 is provided as a branch instruction prediction mechanism.

命令フェッチ要求が命令フェッチ部2から出されると、命令フェッチ要求が要求する命令アドレスに対して、分岐予測部1で分岐予測が行われる。分岐予測部1に、命令フェッチ要求が要求する命令アドレスに該当するエントリーが存在する場合は、対応する命令フェッチデータに分岐予測が行われたことを示すフラグBRHIS_HITが付加され、分岐予測された分岐先命令アドレスの命令フェッチ要求が命令フェッチ部2へ出力される。命令フェッチデータは、命令フェッチ部2から、付加されたフラグBRHIS_HITと共に命令デコーダ部5に供給される。命令デコーダ部5で命令がデコードされ、命令が無効(Annul)ビットを持つBPr,Bicc,BPcc, FBcc,FBPcc等の分岐命令の場合は、フラグBRHIS_HITと共に無効ビットを参照する。   When an instruction fetch request is issued from the instruction fetch unit 2, the branch prediction unit 1 performs branch prediction on the instruction address requested by the instruction fetch request. If the branch prediction unit 1 has an entry corresponding to the instruction address requested by the instruction fetch request, a flag BRHIS_HIT indicating that branch prediction has been performed is added to the corresponding instruction fetch data, and the branch predicted branch An instruction fetch request at the previous instruction address is output to the instruction fetch unit 2. The instruction fetch data is supplied from the instruction fetch unit 2 to the instruction decoder unit 5 together with the added flag BRHIS_HIT. In the case of a branch instruction such as BPR, Bicc, BPcc, FBcc, FBPcc, etc., in which the instruction is decoded by the instruction decoder unit 5 and the instruction has an invalid (Annul) bit, the invalid bit is referred to along with the flag BRHIS_HIT.

命令デコーダ部5は、フラグBRHIS_HIT=1の場合には、無条件で後続の1命令を実行するが、フラグBRHIS_HIT=0で無効ビット=1の場合には、後続の1命令をNon-Operation命令(NOP命令)としてデコードを行う。つまり、命令デコーダ部5は、フラグBRHIS_HIT=1であれば通常通りにデコードを行い、デコード結果が分岐命令でフラグBRHIS_HIT=0であり無効ビット=1の場合は、後続の1命令をNOP命令に変える。SPARCアーキテクチャでは、無効ビットを有する分岐命令は、分岐成立の場合はディレイスロット命令(遅延命令)を実行し、分岐不成立の場合で無効ビットが1の場合はディレイスロット命令を実行せず、無効ビットが0の場合のみディレイスロット命令を実行する。分岐予測を行うということは、命令が分岐命令であり、且つ、分岐成立と予測していることであるので、ディレイスロット命令を実行すると予測していることと実質的に同じである。尚、無効ビットを持たないCALL命令、JMPL命令及びRETURN命令は、無条件分岐であり、いずれもディレイスロット命令を必ず実行することから、同じように取り扱える。COND=1000であるALWAYS_BRANCH命令については、無条件分岐であるにもかかわらず、無効ビット=1の時はディレイスロット命令を実行しないが、このようなケースは出現頻度が少ないことから、命令再フェッチによりリカバリーすることができる。   When the flag BRHIS_HIT = 1, the instruction decoder unit 5 executes the subsequent one instruction unconditionally. However, when the flag BRHIS_HIT = 0 and the invalid bit = 1, the subsequent one instruction is a non-operation instruction. Decode as (NOP instruction). In other words, if the flag BRHIS_HIT = 1, the instruction decoder unit 5 performs decoding as usual. If the decoding result is a branch instruction and the flag BRHIS_HIT = 0 and the invalid bit = 1, the subsequent one instruction is changed to a NOP instruction. Change. In the SPARC architecture, a branch instruction having an invalid bit executes a delay slot instruction (delay instruction) when the branch is established, and does not execute the delay slot instruction when the invalid bit is 1 when the branch is not established. The delay slot instruction is executed only when is zero. Performing branch prediction is substantially the same as predicting that a delay slot instruction is executed because the instruction is a branch instruction and it is predicted that a branch is taken. Note that the CALL instruction, JMPL instruction, and RETURN instruction that do not have an invalid bit are unconditional branches, and since they always execute the delay slot instruction, they can be handled in the same way. For the ALWAYS_BRANCH instruction with COND = 1000, the delay slot instruction is not executed when the invalid bit is 1, even though it is an unconditional branch. Can be recovered.

分岐予測を行った場合、予測が当たった場合は命令再フェッチを行う必要はなく、予測した分岐先の命令シーケンスと実際の命令シーケンスは同じである。又、分岐予測が当たったということは、ディレイスロット命令の実行も正しく行われているということであり、この場合はそのまま命令を実行し続ける。   When branch prediction is performed, there is no need to re-fetch an instruction when the prediction is successful, and the predicted instruction sequence at the branch destination is the same as the actual instruction sequence. In addition, when the branch prediction is successful, the delay slot instruction is correctly executed. In this case, the instruction continues to be executed as it is.

分岐予測を行い予測が外れた場合は、命令再フェッチが必要である。分岐先の命令シーケンスは、間違ったものを実行しており、実際の命令シーケンスを実行し直す必要がある。この場合、ディレイスロット命令の実行も誤っているため、ディレイスロット命令からやり直す必要がある。本実施例では、分岐命令制御部8から分岐先の命令再フェッチ要求を命令フェッチ部2に出力した後、ディレイスロットスタック部8より再実行するディレイスロット命令を取り出し、命令デコーダ部5へディレイスロット命令を供給する。これにより、ディレイスロット命令を含めて、分岐予測のリカバリーを行っている。   When branch prediction is performed and prediction is lost, instruction refetch is required. The branch destination instruction sequence is executed incorrectly, and the actual instruction sequence must be re-executed. In this case, since the execution of the delay slot instruction is also incorrect, it is necessary to start over from the delay slot instruction. In this embodiment, after a branch destination instruction refetch request is output from the branch instruction control unit 8 to the instruction fetch unit 2, a delay slot instruction to be reexecuted is taken out from the delay slot stack unit 8, and the delay slot is sent to the instruction decoder unit 5. Supply instructions. As a result, the branch prediction recovery including the delay slot instruction is performed.

図3は、命令ユニット21の要部の動作を説明するフローチャートである。又、図4は、命令ユニット21の要部の動作を説明するタイムチャートである。   FIG. 3 is a flowchart for explaining the operation of the main part of the instruction unit 21. FIG. 4 is a time chart for explaining the operation of the main part of the instruction unit 21.

図3中、命令デコーダ部5において分岐命令のデコードが行われると、ステップS1は、命令デコーダ部5の命令ワードレジスタIWR0〜IWR3にセットされている、命令が分岐を予測している時に「1」になるフラグ+D0_BRHIS_HIT〜+D3_BRHIS_HITが、「1」であるか否かを判定する。フラグ+D0_BRHIS_HIT〜+D3_BRHIS_HITが「1」でありステップS1の判定結果がYESの場合には処理は後述するステップS4へ進み、「0」であり判定結果がNOであると処理はステップS2へ進む。ステップS2は、命令ワードレジスタIWR0〜IWR3にセットされている命令のオペコードの29ビット目+D0_OPC[29]〜+D3_OPC[29]が「0」であるか「1」であるかを判定することで、無効ビットが「0」であるか「1」であるかを判定する。無効ビットが「1」であると、処理はステップS3へ進み、分岐直後の命令をNOP命令として実行し、処理は後述するステップS5へ進む。他方、無効ビットが「0」であると、処理はステップS4へ進み、分岐直後の命令をそのまま実行し、処理はステップS5へ進む。ステップS1〜S4は、デコードが行われる区間Dに対応する。   In FIG. 3, when the branch instruction is decoded in the instruction decoder unit 5, step S <b> 1 is set in the instruction word registers IWR <b> 0 to IWR <b> 3 of the instruction decoder unit 5 when the instruction predicts a branch. It is determined whether or not the flags + D0_BRHIS_HIT to + D3_BRHIS_HIT that become “1” are “1”. If the flag + D0_BRHIS_HIT to + D3_BRHIS_HIT is “1” and the determination result in step S1 is YES, the process proceeds to step S4 described later, and if it is “0” and the determination result is NO, the process proceeds to step S2. . Step S2 determines whether the 29th bit + D0_OPC [29] to + D3_OPC [29] of the operation code of the instruction set in the instruction word registers IWR0 to IWR3 is “0” or “1” Then, it is determined whether the invalid bit is “0” or “1”. If the invalid bit is “1”, the process proceeds to step S3, the instruction immediately after the branch is executed as a NOP instruction, and the process proceeds to step S5 described later. On the other hand, if the invalid bit is “0”, the process proceeds to step S4, the instruction immediately after the branch is executed as it is, and the process proceeds to step S5. Steps S1 to S4 correspond to a section D where decoding is performed.

ステップS5は、分岐予測が正しいか否かを判定することで、命令再フェッチが必要であるか否かを判定する。分岐予測が正しくステップS5の判定結果がYESの場合、後続する命令が実行される。他方、分岐予測が正しくなくステップS5の判定結果がNOの場合、処理はステップS6へ進む。ステップS6は、命令フェッチ部2へ命令再フェッチ要求を行う。ステップS7は、ディレイスロットスタック部8からディレイスロット命令の再投入(セット)を行う。又、ステップS8は、正しい分岐先の命令を投入(発行)し、後続する命令を実行する。   In step S5, it is determined whether instruction refetch is necessary by determining whether the branch prediction is correct. If the branch prediction is correct and the determination result in step S5 is YES, the subsequent instruction is executed. On the other hand, if the branch prediction is not correct and the determination result in step S5 is NO, the process proceeds to step S6. In step S6, an instruction refetch request is made to the instruction fetch unit 2. In step S 7, the delay slot instruction is re-input (set) from the delay slot stack unit 8. In step S8, a correct branch destination instruction is input (issued), and the subsequent instruction is executed.

図4中、(a)は命令デコーダ5内の処理を示し、(b)は命令フェッチ部2の処理を示し、(c)はディレイスロットスタック部8内の処理を示す。図4に示す例では、(a)の区間Dで分岐命令の発行が行われ、これに続く区間でステップS5及びステップS6に対応する分岐判定及び命令再フェッチ要求が行われる。同図(b)の区間IAで命令再フェッチが開始され、同図(c)の区間E及び区間DでステップS7及びステップS8に対応するディレイスロット命令のセット及びディレイスロット命令の発行が行われる。又、同図(b)の区間IRで命令フェッチが完了する。   4A shows processing in the instruction decoder 5, FIG. 4B shows processing in the instruction fetch unit 2, and FIG. 4C shows processing in the delay slot stack unit 8. In the example shown in FIG. 4, a branch instruction is issued in the section D of (a), and branch determination and instruction refetch request corresponding to step S5 and step S6 are performed in the subsequent section. Instruction refetching is started in section IA in FIG. 7B, and delay slot instructions corresponding to step S7 and step S8 are set and delay slot instructions are issued in section E and section D in FIG. . Further, the instruction fetch is completed in the section IR of FIG.

図5は、ディレイスロットスタック部8の動作を説明する図である。説明の便宜上、同図はn=9(即ち、エントリーが10個)の場合を示す。ディレイスロットスタック部8は、ディレイスロット命令を、分岐命令の制御が終了するまで一時的に保持するスタック構造を有する。命令デコード部5で分岐命令をデコードすると、直後の命令にその命令がディレイスロット命令であることを示すフラグ+D_DELAY_SLOTを付加する。分岐命令制御部7では、命令が発行された時、即ち、対応する命令ワードレジスタIWRにセットされている命令が発行される時に「1」になる信号+D_REL=1であると、フラグ+D_DELAY_SLOT=1の場合は、ディレイスロットスタック部8にエントリーを作成する。   FIG. 5 is a diagram for explaining the operation of the delay slot stack unit 8. For convenience of explanation, this figure shows a case where n = 9 (that is, 10 entries). The delay slot stack unit 8 has a stack structure that temporarily holds a delay slot instruction until the control of the branch instruction is completed. When the instruction decode unit 5 decodes the branch instruction, a flag + D_DELAY_SLOT indicating that the instruction is a delay slot instruction is added to the immediately following instruction. In the branch instruction control unit 7, when the instruction is issued, that is, when the instruction set in the corresponding instruction word register IWR is issued, the signal + D_REL = 1 becomes the flag + D_DELAY_SLOT If = 1, an entry is created in the delay slot stack unit 8.

図6は、ディレイスロットスタック部8へのエントリーのロードを示す信号+LOAD_DELAY_SLOT_D0を生成するディレイスロットスタック部8内の回路構成を、D0について示す回路図である。D1〜D3についての回路構成は、D0についての回路構成と同様であるため、その図示及び説明は省略する。図6において、アンド回路181には、命令デコーダ部5から得られる+D0_DELAY_SLOT、+D_FCNT0、+D0_RELが入力される。+D0_DELAY_SLOTは、命令がディレイスロット命令であることを示すフラグである。+D_FCNT0は、命令発行時において命令の第1フローであることを示す信号である。+D0_RELは、命令ワードレジスタIWR0にセットされている命令が発行される時に「1」となる信号である。アンド回路181は、これらの信号+D0_DELAY_SLOT、+D_FCNT0、+D0_RELに基づいて、信号+LOAD_DELAY_SLOT_D0を生成する。   FIG. 6 is a circuit diagram showing a circuit configuration in the delay slot stack unit 8 that generates a signal + LOAD_DELAY_SLOT_D0 indicating loading of an entry into the delay slot stack unit 8 with respect to D0. Since the circuit configuration for D1 to D3 is the same as the circuit configuration for D0, illustration and description thereof are omitted. In FIG. 6, + D0_DELAY_SLOT, + D_FCNT0, and + D0_REL obtained from the instruction decoder unit 5 are input to the AND circuit 181. + D0_DELAY_SLOT is a flag indicating that the instruction is a delay slot instruction. + D_FCNT0 is a signal indicating the first flow of the instruction when the instruction is issued. + D0_REL is a signal that becomes “1” when an instruction set in the instruction word register IWR0 is issued. The AND circuit 181 generates a signal + LOAD_DELAY_SLOT_D0 based on these signals + D0_DELAY_SLOT, + D_FCNT0, and + D0_REL.

図7は、フラグ+D0_DELAY_SLOT、+D1_DELAY_SLOTを生成する命令デコーダ部5内の回路構成を示す回路図である。D2、D3についての回路構成は、D0、D1についての回路構成と同様であるため、その図示及び説明は省略する。図7において、アンド回路151は、信号+DELAY_SLOT_TGR及び信号+D0_RELに基づいて、ディレイスロットスタック部8に供給されるフラグ+DO_DELAY_SLOTを生成する。又、アンド回路152は、信号+DO_BRANCH及び信号+D1_RELに基づいて、ディレイスロットスタック部8に供給されるフラグ+D1_DELAY_SLOTを生成する。+DELAY_SLOT_TGRは、命令ワードレジスタIWR0にセットされている命令がディレイスロット命令であることを示す信号であり、+D0_RELは、命令ワードレジスタIWR0にセットされている命令が発行される時に「1」となる信号であり、これらの信号はいずれも命令デコーダ部5内で生成される。+DO_BRANCHは、命令ワードレジスタIWR0にセットされている命令が分岐命令であることを示す信号であり、+D1_RELは、命令ワードレジスタIWR1にセットされている命令が発行される時に「1」となる信号である。   FIG. 7 is a circuit diagram showing a circuit configuration in the instruction decoder unit 5 that generates the flags + D0_DELAY_SLOT and + D1_DELAY_SLOT. Since the circuit configuration for D2 and D3 is the same as the circuit configuration for D0 and D1, illustration and description thereof will be omitted. In FIG. 7, an AND circuit 151 generates a flag + DO_DELAY_SLOT supplied to the delay slot stack unit 8 based on a signal + DELAY_SLOT_TGR and a signal + D0_REL. The AND circuit 152 generates a flag + D1_DELAY_SLOT supplied to the delay slot stack unit 8 based on the signal + DO_BRANCH and the signal + D1_REL. + DELAY_SLOT_TGR is a signal indicating that the instruction set in the instruction word register IWR0 is a delay slot instruction, and + D0_REL is “1” when the instruction set in the instruction word register IWR0 is issued. These signals are all generated in the instruction decoder unit 5. + DO_BRANCH is a signal indicating that the instruction set in the instruction word register IWR0 is a branch instruction, and + D1_REL is “1” when the instruction set in the instruction word register IWR1 is issued. Signal.

ディレイスロットスタック部8に作成されるエントリーの構成は、以下の通りである。

DSS_VALID,
OPC[31:0,P3:P0],
IID[5:0],
PC[31:0,P3:P0],
IF_XV,
IF_XPTN_CODE[1:0],
IF_ADRS_MATCH_VALID

DSS_VALIDは、ディレイスロットスタック部8のVALID信号であり、この信号が「1」の時にエントリーが有効である。OPCは、ディレイスロット命令のオペコードである。IIDは、ディレイスロット命令の命令番号(Instruction ID)であり、ディレイスロット命令が命令シーケンスのどの位置にあるのかを示すタグ情報として用いられる。PCは、命令の命令アドレスである。IF_XVは、該当命令が置かれているアドレスで命令フェッチの際、何らかの例外が発生したことを示す。IF_XPTN_CODEは、IF_XVで示される命令フェッチ例外の種類を示す。IF_ADRS_MATCH_VALIDは、指定された命令アドレスで割り込みが発生することを示す。
The configuration of entries created in the delay slot stack unit 8 is as follows.

DSS_VALID,
OPC [31: 0, P3: P0],
IID [5: 0],
PC [31: 0, P3: P0],
IF_XV,
IF_XPTN_CODE [1: 0],
IF_ADRS_MATCH_VALID

DSS_VALID is a VALID signal of the delay slot stack unit 8, and the entry is valid when this signal is "1". OPC is an operation code of a delay slot instruction. IID is an instruction ID (Instruction ID) of the delay slot instruction, and is used as tag information indicating where the delay slot instruction is located in the instruction sequence. PC is the instruction address of the instruction. IF_XV indicates that an exception has occurred during instruction fetch at the address where the corresponding instruction is placed. IF_XPTN_CODE indicates the type of instruction fetch exception indicated by IF_XV. IF_ADRS_MATCH_VALID indicates that an interrupt occurs at a specified instruction address.

ディレイスロットスタック部8のエントリーは、ディレイスロット命令に対応する分岐命令(直前の分岐命令)の制御が終了するまで保持される。対応する分岐命令の制御が完了すると、+RSBR_COMPLETE=1となり、エントリーは開放、即ち、消去される。+RSBR_COMPLETEは、後述するように、分岐命令制御部7の対応する番目の分岐命令の制御が完了した時に「1」になる信号である。   The entry in the delay slot stack unit 8 is held until the control of the branch instruction (the immediately preceding branch instruction) corresponding to the delay slot instruction is completed. When the control of the corresponding branch instruction is completed, + RSBR_COMPLETE = 1 and the entry is released, that is, deleted. + RSBR_COMPLETE is a signal that becomes “1” when the control of the corresponding branch instruction of the branch instruction control unit 7 is completed, as will be described later.

対応する分岐命令の分岐判定が行われ、その結果命令再フェッチが必要な場合は、分岐命令制御部7から命令フェッチ部2に対して命令再フェッチ要求+RSBR_REIFCH_REQ=1が出される。命令再フェッチが必要になると、ディレイスロット命令の再実行が必要になる。命令再フェッチ要求+RSBR_REIFCH_REQ=1となると、ディレイスロットスタック部8から命令デコーダ部5内の対応する命令ワードレジスタIWR0 に信号+SET_IWR0_DELAY_SLOT_VALIDがセットされる。+SET_IWR0_DELAY_SLOT_VALIDは、ディレイスロット命令の再投入を要求するディレイスロット命令再セット要求である。ディレイスロット命令再セット要求+SET_IWR0_DELAY_SLOT_VALIDが「1」の場合は、常にディレイスロットスタック部8より命令が供給される。   When branch determination of the corresponding branch instruction is performed, and as a result instruction refetch is necessary, the instruction refetch request + RSBR_REIFCH_REQ = 1 is issued from the branch instruction control unit 7 to the instruction fetch unit 2. When instruction refetch is required, it is necessary to re-execute the delay slot instruction. When the instruction refetch request + RSBR_REIFCH_REQ = 1, the signal + SET_IWR0_DELAY_SLOT_VALID is set from the delay slot stack unit 8 to the corresponding instruction word register IWR0 in the instruction decoder unit 5. + SET_IWR0_DELAY_SLOT_VALID is a delay slot instruction reset request for requesting re-insertion of a delay slot instruction. When the delay slot instruction reset request + SET_IWR0_DELAY_SLOT_VALID is “1”, the instruction is always supplied from the delay slot stack unit 8.

図8は、ディレイスロット命令再セット要求+SET_IWR0_DELAY_SLOT_VALIDを生成するディレイスロットスタック部8内の回路構成を示す回路図である。同図中、アンド回路281には、信号+FLUSH_RS、+E0_VALID_FOR_DSS、+REIFCH_TGRが入力される。+FLUSH_RSは、命令再フェッチ要求を出した分岐命令が終了した時に「1」となる信号である。+E0_VALID_FOR_DSSは、ディレイスロットスタック部8から命令デコーダ部5内の対応する命令ワードレジスタIWR1に命令の再セットが完了した時に「1」となる信号である。+REIFCH_TGRは、分岐命令制御部7から命令再フェッチ要求を出した時に「1」となる信号であり、+FLUSH_RS=1になるとリセットされる。アンド回路282には、信号+E0_VALID_FOR_DSS、-REFCH_FGRが入力される。バッファ283には、信号+RS1が入力される。+RS1は、割り込み処理が発生した時に「1」となる信号である。アンド回路281、282の出力及びバッファ283の出力は、オア回路284に入力され、オア回路284の出力は、ラッチ回路285の入力端子INH及びリセット端子RSTに入力される。又、ラッチ回路285のセット端子SETには、信号+RSBR_REIFCH_REQが入力される。+RSBR_REIFCH_REQは、分岐命令制御部7から命令フェッチ部2への命令再フェッチ要求である。ディレイスロット命令再セット要求+SET_IWR0_DELAY_SLOT_VALIDは、ラッチ回路285から出力される。   FIG. 8 is a circuit diagram showing a circuit configuration in the delay slot stack unit 8 for generating the delay slot instruction reset request + SET_IWR0_DELAY_SLOT_VALID. In the figure, signals + FLUSH_RS, + E0_VALID_FOR_DSS, and + REIFCH_TGR are input to the AND circuit 281. + FLUSH_RS is a signal that becomes “1” when the branch instruction that issued the instruction refetch request is completed. + E0_VALID_FOR_DSS is a signal that becomes “1” when the instruction resetting from the delay slot stack unit 8 to the corresponding instruction word register IWR1 in the instruction decoder unit 5 is completed. + REIFCH_TGR is a signal that becomes “1” when an instruction refetch request is issued from the branch instruction control unit 7, and is reset when + FLUSH_RS = 1. Signals + E0_VALID_FOR_DSS and -REFCH_FGR are input to the AND circuit 282. A signal + RS1 is input to the buffer 283. + RS1 is a signal that becomes “1” when an interrupt process occurs. The outputs of the AND circuits 281 and 282 and the output of the buffer 283 are input to the OR circuit 284, and the output of the OR circuit 284 is input to the input terminal INH and the reset terminal RST of the latch circuit 285. The signal + RSBR_REIFCH_REQ is input to the set terminal SET of the latch circuit 285. + RSBR_REIFCH_REQ is an instruction refetch request from the branch instruction control unit 7 to the instruction fetch unit 2. The delay slot instruction reset request + SET_IWR0_DELAY_SLOT_VALID is output from the latch circuit 285.

分岐判定が行われ、命令再フェッチ要求が+RSBR_REIFCH_REQ=1となると、分岐命令は信号+RSBR_REIFCH_DONEを「1」にセットする。+RSBR_REIFCH_DONEは、命令が命令フェッチ要求を出したことを示す信号である。分岐命令の制御終了時、即ち、信号+RSBR_COMPLETE=1の時、信号+RSBR_REIFCH_DONE=1であると、該当する命令が図9に示す回路でセレクトされ、図10に示す回路で一旦ラッチに保持される。+RSBR_REIFCH_REQ=1となってからディレイスロット命令が発行されるまでは、最短で例えば3τの時間があるため、一旦ラッチアップされたデータを命令デコード部5に供給する。   When branch determination is performed and the instruction refetch request becomes + RSBR_REIFCH_REQ = 1, the branch instruction sets the signal + RSBR_REIFCH_DONE to “1”. + RSBR_REIFCH_DONE is a signal indicating that the instruction has issued an instruction fetch request. When the control of the branch instruction ends, that is, when the signal + RSBR_COMPLETE = 1, if the signal + RSBR_REIFCH_DONE = 1, the corresponding instruction is selected by the circuit shown in FIG. 9, and is temporarily held in the latch by the circuit shown in FIG. The Since there is a shortest time, for example, 3τ from when + RSBR_REIFCH_REQ = 1 to when the delay slot instruction is issued, the latched data is supplied to the instruction decoding unit 5.

図9は、信号+SEL_DSS0_ENTRYを生成する分岐命令制御部7内の回路構成を示す回路図である。DSS1〜DSS3についての回路構成は、DSS0についての回路構成と同様であるため、その図示及び説明は省略する。図7において、アンド回路171には、信号+RSBR0_COMPLETE、+RSBR0_REIFCH_DONEが入力され、アンド回路171からは信号+SEL_DSS0_ENTRYが出力される。+RSBR0_COMPLETEは、分岐命令制御部7の0番目の分岐命令の制御が完了した時に「1」となる信号である。+RSBR0_REIFCH_DONEは、分岐命令制御部7の0番目の分岐命令が命令再フェッチ要求を出した時に「1」となる信号である。+SEL_DSS0_ENTRYは、ディレイスロットスタック部8の0番目のDSS0から命令ワードレジスタIWR0に再セットする必要が生じた時に「1」となる信号である。   FIG. 9 is a circuit diagram showing a circuit configuration in the branch instruction control unit 7 that generates the signal + SEL_DSS0_ENTRY. Since the circuit configuration of DSS1 to DSS3 is the same as the circuit configuration of DSS0, illustration and description thereof are omitted. In FIG. 7, signals + RSBR0_COMPLETE and + RSBR0_REIFCH_DONE are input to the AND circuit 171, and a signal + SEL_DSS0_ENTRY is output from the AND circuit 171. + RSBR0_COMPLETE is a signal that becomes “1” when the control of the 0th branch instruction of the branch instruction control unit 7 is completed. + RSBR0_REIFCH_DONE is a signal that becomes “1” when the 0th branch instruction of the branch instruction control unit 7 issues an instruction refetch request. + SEL_DSS0_ENTRY is a signal which becomes “1” when it is necessary to reset the 0th DSS0 of the delay slot stack unit 8 to the instruction word register IWR0.

図10は、信号+SET_REIFCH_DELAY_OPC[31:0,P3:P0]、+SET_IWR0_DELAY_SLOT[31:0,P3:P0]を生成するディレイスロットスタック部8内の回路構成を示す回路図である。同図中、アンド回路381には信号+SEL_DSS0_ENTRY、+DSS0_OPC[31:0,P3:P0]が入力され、アンド回路382には信号+SEL_DSS1_ENTRY、+DSS1_OPC[31:0,P3:P0]が入力され、アンド回路383には信号+SEL_DSS2_ENTRY、+DSS2_OPC[31:0,P3:P0]が入力される。アンド回路381
〜383の出力はオア回路384に入力され、オア回路384からは信号+SET_REIFCH_DELAY_OPC[31:0,P3:P0]が出力される。信号+SEL_DSS0_ENTRYは、ディレイスロットスタック部8の0番目のDSS0から命令ワードレジスタIWR0に再セットする必要が生じた場合に「1」となる信号であり、信号+DSS0_OPC[31:0,P3:P0]は、ディレイスロットスタック部8の0番目のエントリーに格納されているオペコードである。信号+SEL_DSS1_ENTRYは、ディレイスロットスタック部8の1番目のDSS1から命令ワードレジスタIWR1に再セットする必要が生じた場合に「1」となる信号であり、信号+DSS1_OPC[31:0,P3:P0]は、ディレイスロットスタック部8の1番目のエントリーに格納されているオペコードである。信号+SEL_DSS2_ENTRYは、ディレイスロットスタック部8の2番目のDSS2から命令ワードレジスタIWR2に再セットする必要が生じた場合に「1」となる信号であり、信号+DSS2_OPC[31:0,P3:P0]は、ディレイスロットスタック部8の2番目のエントリーに格納されているオペコードである。信号+SET_REIFCH_DELAY_OPC[31:0,P3:P0]は、ディレイスロットスタック部8から命令ワードレジスタIWR0へのディレイスロット命令再セットの時にセットするべきオペコードである。
FIG. 10 is a circuit diagram illustrating a circuit configuration in the delay slot stack unit 8 that generates the signals + SET_REIFCH_DELAY_OPC [31: 0, P3: P0] and + SET_IWR0_DELAY_SLOT [31: 0, P3: P0]. In the figure, signals + SEL_DSS0_ENTRY and + DSS0_OPC [31: 0, P3: P0] are input to the AND circuit 381, and signals + SEL_DSS1_ENTRY and + DSS1_OPC [31: 0, P3: P0] are input to the AND circuit 382. Then, the signals + SEL_DSS2_ENTRY and + DSS2_OPC [31: 0, P3: P0] are input to the AND circuit 383. AND circuit 381
To 383 are input to the OR circuit 384, and the OR circuit 384 outputs a signal + SET_REIFCH_DELAY_OPC [31: 0, P3: P0]. The signal + SEL_DSS0_ENTRY becomes “1” when it is necessary to reset the instruction slot register IWR0 from the 0th DSS0 of the delay slot stack unit 8, and the signal + DSS0_OPC [31: 0, P3: P0 ] Is an operation code stored in the 0th entry of the delay slot stack unit 8. The signal + SEL_DSS1_ENTRY becomes “1” when it is necessary to reset the instruction word register IWR1 from the first DSS1 of the delay slot stack unit 8, and the signal + DSS1_OPC [31: 0, P3: P0 ] Is an opcode stored in the first entry of the delay slot stack unit 8. The signal + SEL_DSS2_ENTRY becomes “1” when it is necessary to reset the instruction word register IWR2 from the second DSS2 of the delay slot stack unit 8, and the signal + DSS2_OPC [31: 0, P3: P0 ] Is an opcode stored in the second entry of the delay slot stack unit 8. The signal + SET_REIFCH_DELAY_OPC [31: 0, P3: P0] is an opcode to be set when the delay slot instruction is reset from the delay slot stack unit 8 to the instruction word register IWR0.

ノア回路385には、信号+SEL_DSS0_ENTRY、+SEL_DSS1_ENTRY、+SEL_DSS2_ENTRYが入力され、ノア回路385の出力はラッチ回路386の入力端子INHに入力される。ラッチ回路386のセット端子SETには、信号+SET_REIFCH_DELAY_OPC[31:0,P3:P0]が入力される。ラッチ回路386は、信号+SET_IWR0_DELAY_SLOT[31:0,P3:P0]を出力する。信号+SET_IWR0_DELAY_SLOT[31:0,P3:P0]は、ディレイスロットスタック部8から命令ワードレジスタIWR0へのディレイスロット命令再セットの時にセットするべきオペコードであり、図8に示す回路が出力する信号+SET_IRW0_DELAY_SLOT_VALID=1の時にこのオペコードが命令ワードレジスタIWR0に再セットされる。   Signals + SEL_DSS0_ENTRY, + SEL_DSS1_ENTRY, and + SEL_DSS2_ENTRY are input to the NOR circuit 385, and the output of the NOR circuit 385 is input to the input terminal INH of the latch circuit 386. The signal + SET_REIFCH_DELAY_OPC [31: 0, P3: P0] is input to the set terminal SET of the latch circuit 386. The latch circuit 386 outputs the signal + SET_IWR0_DELAY_SLOT [31: 0, P3: P0]. The signal + SET_IWR0_DELAY_SLOT [31: 0, P3: P0] is an opcode to be set when the delay slot instruction is reset from the delay slot stack unit 8 to the instruction word register IWR0, and is a signal output from the circuit shown in FIG. When SET_IRW0_DELAY_SLOT_VALID = 1, this opcode is reset in the instruction word register IWR0.

尚、信号PC[31:0,P3:P0]、IF_XV、IF_XPTN_CODE[1:0]、E0_NOP(RSBR_DELAY_SLOT_ANNULLEDを選択)についても、同様の論理回路で生成可能であるので、その図示及び説明は省略する。   The signals PC [31: 0, P3: P0], IF_XV, IF_XPTN_CODE [1: 0], and E0_NOP (select RSBR_DELAY_SLOT_ANNULLED) can be generated by the same logic circuit, and thus illustration and description thereof are omitted. .

分岐判定が確定すると、そこで初めてディレイスロット命令の実行の有無が確定する。分岐予測が成功した場合は、ディレイスロット命令の再投入はしないが、分岐予測が失敗した場合は、再度ディレイスロット命令の実行の有無を判定しなければならない。本実施例では、ディレイスロット命令を実行する場合は、選択されたディレイスロットのオペコードがそのまま投入されるが、実行されない場合は、オペコードをNOP命令に変えた後にディレイスロット命令をNOP扱いとしていることを示すフラグ+E0_NOP=1と共に、命令デコード部5に命令を供給している。尚、ディレイスロット命令を実行しない場合、信号+IF_XV、+IF_ADRS_MATCH_VALIDは常に0となる。   When branch determination is confirmed, it is determined for the first time whether or not the delay slot instruction is executed. When the branch prediction is successful, the delay slot instruction is not re-input, but when the branch prediction is unsuccessful, it is necessary to determine again whether or not the delay slot instruction is executed. In this embodiment, when executing a delay slot instruction, the opcode of the selected delay slot is input as it is, but when not executed, the delay slot instruction is treated as a NOP after changing the opcode to a NOP instruction. An instruction is supplied to the instruction decoding unit 5 together with a flag + E0_NOP = 1 indicating If the delay slot instruction is not executed, the signals + IF_XV and + IF_ADRS_MATCH_VALID are always 0.

図11は、信号+RSBR0_DELAY_SLOT_ANNULLEDを生成する分岐命令制御部7内の回路構成を示す回路図である。RSBR1〜RSBR3についての回路構成は、RSBR0についての回路構成と同様であるため、その図示及び説明は省略する。図11において、アンド回路271には、信号+RSBR0_VALID、+RSBR0_OPC[29]、+RSBR0_RESOLVED、+RSBR0_TAKENが入力され、アンド回路272には、信号+RSBR0_VALID、+RSBR0_OPC[29]、+RSBR0_ALWAYSが入力される。分岐命令制御部7には、分岐命令が発行されるとエントリーが作成される。+RSBR0_VALIDは、分岐命令制御部7の0番目のエントリーが有効であることを示す信号である。+RSBR0_OPC[29]は、分岐命令制御部7の0番目の無効フィールドを示す信号である。+RSBR0_RESOLVEDは、分岐命令制御部7の0番目の分岐判定が完了すると「1」となる信号である。+RSBR0_TAKENは、分岐命令制御部7の0番目の分岐命令が分岐することが確定した時に「1」となる信号である。+RSBR0_ALWAYSは、分岐命令制御部7の0番目の分岐命令が相対分岐命令であり、且つ、無条件分岐であることを示す信号である。アンド回路271,272の出力は、オア回路273へ入力され、オア回路273からは、信号+RSBR0_DELAY_SLOT_ANNULLEDが出力される。+RSBR0_DELAY_SLOT_ANNULLEDは、分岐命令制御部7の0番目の分岐命令に対応するディレイスロット命令が無効にされたことを示す信号である。   FIG. 11 is a circuit diagram showing a circuit configuration in the branch instruction control unit 7 that generates the signal + RSBR0_DELAY_SLOT_ANNULLED. Since the circuit configuration of RSBR1 to RSBR3 is the same as the circuit configuration of RSBR0, illustration and description thereof are omitted. In FIG. 11, signals + RSBR0_VALID, + RSBR0_OPC [29], + RSBR0_RESOLVED, + RSBR0_TAKEN are input to the AND circuit 271, and signals + RSBR0_VALID, + RSBR0_OPC [29], + RSBR0_ALWAYS are input to the AND circuit 272. The An entry is created in the branch instruction control unit 7 when a branch instruction is issued. + RSBR0_VALID is a signal indicating that the 0th entry of the branch instruction control unit 7 is valid. + RSBR0_OPC [29] is a signal indicating the 0th invalid field of the branch instruction control unit 7. + RSBR0_RESOLVED is a signal that becomes “1” when the 0th branch determination of the branch instruction control unit 7 is completed. + RSBR0_TAKEN is a signal that becomes “1” when it is determined that the 0th branch instruction of the branch instruction control unit 7 is branched. + RSBR0_ALWAYS is a signal indicating that the 0th branch instruction of the branch instruction control unit 7 is a relative branch instruction and is an unconditional branch. The outputs of the AND circuits 271 and 272 are input to the OR circuit 273, and the OR circuit 273 outputs a signal + RSBR0_DELAY_SLOT_ANNULLED. + RSBR0_DELAY_SLOT_ANNULLED is a signal indicating that the delay slot instruction corresponding to the 0th branch instruction of the branch instruction control unit 7 is invalidated.

図12は、信号+D0_NOP、+D1_NOPを生成する命令デコーダ部5内の回路構成を示す回路図である。D1〜D3についての回路構成は、D0についての回路構成と同様であるため、その図示及び説明は省略する。図12において、アンド回路251には、信号+DELAY_SLOT_FGR、-D0_BRHIS_HIT、+D0_OPC[29]が入力され、アンド回路252には、信号+D0_BRANCH、-D1_BRHIS_HIT、+D1_OPC[29]が入力される。+DELAY_SLOT_FGRは、命令ワードレジスタIWR0にセットされている命令がディレイスロット命令であることを示すフラグである。-D0_BRHIS_HITは、命令ワードレジスタIWR0にセットされている命令が分岐すると予測している時に「1」となる信号である。+D0_OPC[29]は、命令ワードレジスタIWR0にセットされている命令のオペコードの29ビット目を示す。+D0_BRANCHは、命令ワードレジスタIWR0にセットされている命令が分岐命令であることを示す信号である。-D1_BRHIS_HITは、命令ワードレジスタIWR1にセットされている命令が分岐すると予測している時に「1」となる信号である。+D1_OPC[29] は、命令ワードレジスタIWR1にセットされている命令のオペコードの29ビット目を示す。   FIG. 12 is a circuit diagram showing a circuit configuration in the instruction decoder unit 5 that generates the signals + D0_NOP and + D1_NOP. Since the circuit configuration for D1 to D3 is the same as the circuit configuration for D0, illustration and description thereof are omitted. In FIG. 12, signals + DELAY_SLOT_FGR, -D0_BRHIS_HIT, + D0_OPC [29] are input to the AND circuit 251, and signals + D0_BRANCH, -D1_BRHIS_HIT, + D1_OPC [29] are input to the AND circuit 252. + DELAY_SLOT_FGR is a flag indicating that the instruction set in the instruction word register IWR0 is a delay slot instruction. -D0_BRHIS_HIT is a signal that is set to “1” when the instruction set in the instruction word register IWR0 is predicted to branch. + D0_OPC [29] indicates the 29th bit of the operation code of the instruction set in the instruction word register IWR0. + D0_BRANCH is a signal indicating that the instruction set in the instruction word register IWR0 is a branch instruction. -D1_BRHIS_HIT is a signal that becomes “1” when the instruction set in the instruction word register IWR1 is predicted to branch. + D1_OPC [29] indicates the 29th bit of the operation code of the instruction set in the instruction word register IWR1.

オア回路253には、アンド回路251の出力と、信号+E0_NOPが入力され、信号+D0_NOPが出力される。他方、アンド回路252は、信号+D1_NOPを出力する。+E0_NOPは、ディレイスロット命令が実行されないことを示すフラグである。+D0_NOPは、命令ワードレジスタIWR0にセットされている命令をNOP命令化した場合に「1」となる信号である。+D1_NOPは、命令ワードレジスタIWR1にセットされている命令をNOP命令化した場合に「1」となる信号である。   The output of the AND circuit 251 and the signal + E0_NOP are input to the OR circuit 253, and the signal + D0_NOP is output. On the other hand, the AND circuit 252 outputs a signal + D1_NOP. + E0_NOP is a flag indicating that the delay slot instruction is not executed. + D0_NOP is a signal that becomes “1” when the instruction set in the instruction word register IWR0 is converted into a NOP instruction. + D1_NOP is a signal that becomes “1” when the instruction set in the instruction word register IWR1 is converted into a NOP instruction.

このように、本実施例では、ディレイスロット命令であることを判別するために、全ての命令に、デコードサイクルで+D_DELAY_SLOTというフラグを付加している。このフラグ+D_DELAY_SLOTが「1」であると、その命令はディレイスロット命令であることを示し、「0」であると、ディレイスロット命令ではないことを示す。このフラグ+D_DELAY_SLOTが「1」であるディレイスロット命令が発行されると、ディレイスロットスタック部8にエントリーが作成される。命令デコード部5で分岐命令がデコードされると、直後の命令のフラグは+D_DELAY_SLOT=1となる。   As described above, in this embodiment, in order to determine that the instruction is a delay slot instruction, a flag of + D_DELAY_SLOT is added to all instructions in the decode cycle. When this flag + D_DELAY_SLOT is “1”, the instruction is a delay slot instruction, and when it is “0”, it is not a delay slot instruction. When a delay slot instruction whose flag + D_DELAY_SLOT is “1” is issued, an entry is created in the delay slot stack unit 8. When the branch instruction is decoded by the instruction decoding unit 5, the flag of the immediately following instruction becomes + D_DELAY_SLOT = 1.

又、本実施例では、ディレイスロット命令の実行の有無を示すため、全ての命令にデコードサイクルで+D_NOPというフラグを付加している。このフラグ+D_NOPが「1」であると、その命令は実行されない命令であることを示し、「0」であると、実行される命令であることを示す。(-D_BRHIS_HIT=1 & +D_BRANCH & +OPC[29]=1)又は(+E0_NOP=1)の場合は、デコードサイクルDで+D_NOP=1というフラグが付加される。前者は、分岐予測が行われなかった(或いは、分岐しないと予測された)分岐命令で、無効ビットが「1」である場合であり、この場合、ディレイスロット命令が実行されないと予測していることと同義である。後者は、分岐命令が分岐予測に失敗し、ディレイスロット命令からの再投入が必要である時、ディレイスロット命令が実行されないことを示すフラグである。   In this embodiment, in order to indicate whether or not the delay slot instruction is executed, a flag of + D_NOP is added to all instructions in the decode cycle. When this flag + D_NOP is “1”, it indicates that the instruction is not executed, and when it is “0”, it indicates that the instruction is executed. In the case of (-D_BRHIS_HIT = 1 & + D_BRANCH & + OPC [29] = 1) or (+ E0_NOP = 1), a flag of + D_NOP = 1 is added in the decoding cycle D. The former is a case where the branch prediction is not performed (or predicted not to branch) and the invalid bit is “1”. In this case, the delay slot instruction is predicted not to be executed. It is synonymous with that. The latter is a flag indicating that the delay slot instruction is not executed when the branch instruction fails in branch prediction and re-input from the delay slot instruction is necessary.

従って、本実施例では、分岐命令に対応するディレイスロット命令を格納するための記憶部を持つことにより、分岐予測に失敗した場合にディレイスロット命令の命令再フェッチを行わず、分岐先の命令再フェッチのみを行うため、より高速に命令再フェッチのリカバリーを行うことができる。又、ディレイスロット命令は、分岐先命令再フェッチのデータ待ちの間に再発行ができる。分岐予測は、ディレイスロット命令の実行有無の予測であるため、分岐予測に成功した場合は、何ら不都合を生じることなく、高速に命令の実行ができる。   Therefore, in this embodiment, by having a storage unit for storing the delay slot instruction corresponding to the branch instruction, when the branch prediction fails, the delay slot instruction is not refetched, and the branch destination instruction is replayed. Since only fetching is performed, instruction refetch recovery can be performed at higher speed. In addition, the delay slot instruction can be reissued while waiting for the branch destination instruction refetch data. Since the branch prediction is a prediction of whether or not the delay slot instruction is executed, if the branch prediction is successful, the instruction can be executed at high speed without causing any inconvenience.

尚、本発明は、以下に付記する発明をも包含するものである。
(付記1) 分岐のための遅延命令を用いる命令制御方法であって、
複数の遅延命令を、遅延命令に対応する分岐命令が分岐成立と予測されたか分岐不成立と予測されたかを示す情報と共に順次記憶装置に格納するステップを含むことを特徴とする、命令制御方法。
(付記2) 分岐命令が分岐不成立と予測された場合には遅延命令を一旦Non-Operation命令に置き換え、分岐成立と予測された場合には遅延命令を実行するステップを更に含むことを特徴とする、付記1記載の命令制御方法。
(付記3) 分岐命令が分岐不成立と予測され遅延命令が一旦Non-Operation命令に置きかえられた場合にはそのままNon-Operation命令を発行し、分岐成立と予測された場合には該当分岐命令に対応する遅延命令を発行後に予測された分岐先の命令を発行するステップを更に含むことを特徴とする、付記2記載の命令制御方法。
(付記4) 命令を記憶装置に格納する時に、該命令が命令シーケンスのどの位置の命令であるのかを判別するためのタグを前記記憶装置に登録するステップを更に含むことを特徴とする、付記1〜3のいずれか1項記載の命令制御方法。
(付記5) 分岐のための遅延命令をもつ命令制御方法であって、
分岐予測を行った時、分岐命令が分岐不成立と予測され遅延命令が一旦Non-Operation命令に置きかえられて命令が発行された後、直前の分岐命令で分岐成立と確定した場合には分岐先の命令フェッチ要求と共に記憶装置より対応する遅延命令を取り出して命令を発行し、分岐成立と予測され該分岐命令に対応する遅延命令が発行された後、予測された分岐先の命令が発行されて予測された分岐先が正しい場合にはそのまま命令実行を継続すると共に予測された分岐先が誤っている場合には遅延命令後の分岐先命令の命令再フェッチ要求を行うステップを含むことを特徴とする、命令制御方法。
(付記6) 分岐不成立と予測された後に分岐成立が確定した場合に、分岐先の命令フェッチを分岐確定直後に行ない、前記記憶装置より取り出された遅延命令の命令投入後に分岐先の命令を発行するステップを更に含むことを特徴とする、付記5記載の命令制御方法。
(付記7) 分岐成立と予測された後に分岐成立が確定して予測された分岐先が誤っていた場合に、分岐先が確定した直後に正しい分岐先の命令再フェッチを行ない遅延命令の命令投入後に分岐先の命令を発行するステップを更に含むことを特徴とする、付記5記載の命令制御方法。
(付記8) 分岐のための遅延命令をもつ命令制御方法であって、
分岐予測を行った時、分岐命令が分岐不成立と予測され遅延命令が一旦Non-Operation命令に置き換えられて命令が発行された後、直前の分岐命令で分岐不成立と確定した場合にはそのまま命令実行を続行し、分岐成立と予測されその後分岐不成立と確定した場合には元のシーケンシャルな命令の命令再フェッチ要求を行ってフェッチ完了後直ちに命令を発行するステップを含むことを特徴とする、命令制御方法。
(付記9) 記憶装置に格納されている前記遅延命令と、該遅延命令が命令シーケンスのどの位置の命令であるのかを判別するためのタグ情報とを、同時に前記記憶装置から消去するステップを更に含むことを特徴とする、付記8記載の命令制御方法。
(付記10) 分岐のための遅延命令を用いる命令制御を行うプロセッサであって、
記憶装置と、
分岐予測を行う分岐予測部と、
複数の遅延命令を、該分岐予測部において遅延命令に対応する分岐命令が分岐成立と予測されたか分岐不成立と予測されたかを示す情報と共に、順次該記憶装置に格納する制御手段とを備えたことを特徴とする、プロセッサ。
(付記11) 分岐命令が分岐不成立と予測された場合には遅延命令を一旦Non-Operation命令に置き換え、分岐成立と予測された場合には遅延命令を実行する手段を更に備えたことを特徴とする、付記10記載のプロセッサ。
(付記12) 分岐命令が分岐不成立と予測され遅延命令が一旦Non-Operation命令に置きかえられた場合にはそのままNon-Operation命令を発行し、分岐成立と予測された場合には該当分岐命令に対応する遅延命令を発行後に予測された分岐先の命令を発行する手段を更に備えたことを特徴とする、付記11記載のプロセッサ。
(付記13) 命令を前記記憶装置に格納する時に、該命令が命令シーケンスのどの位置の命令であるのかを判別するためのタグを前記記憶装置に登録する手段を更に備えたことを特徴とする、付記10〜12のいずれか1項記載のプロセッサ。
(付記14) 分岐のための遅延命令をもつ命令制御を行うプロセッサであって、
記憶装置と、
分岐予測を行う分岐予測部と、
該分岐予測部において分岐予測を行った時、分岐命令が分岐不成立と予測され遅延命令が一旦Non-Operation命令に置きかえられて命令が発行された後、直前の分岐命令で分岐成立と確定した場合には分岐先の命令フェッチ要求と共に記憶装置より対応する遅延命令を取り出して命令を発行し、分岐成立と予測され該分岐命令に対応する遅延命令が発行された後、予測された分岐先の命令が発行されて予測された分岐先が正しい場合にはそのまま命令実行を継続すると共に予測された分岐先が誤っている場合には遅延命令後の分岐先命令の命令再フェッチ要求を行う手段とを備えたことを特徴とする、プロセッサ。
(付記15) 分岐不成立と予測された後に分岐成立が確定した場合に、分岐先の命令フェッチを分岐確定直後に行ない、前記記憶装置より取り出された遅延命令の命令投入後に分岐先の命令を発行する手段を更に備えたことを特徴とする、付記14記載のプロセッサ。
(付記16) 分岐成立と予測された後に分岐成立が確定して予測された分岐先が誤っていた場合に、分岐先が確定した直後に正しい分岐先の命令再フェッチを行ない遅延命令の命令投入後に分岐先の命令を発行する手段を更に備えたことを特徴とする、付記14記載のプロセッサ。
(付記17) 分岐のための遅延命令をもつ命令制御を行うプロセッサであって、
分岐予測を行う分岐予測部と、
該分岐予測部において分岐予測を行った時、分岐命令が分岐不成立と予測され遅延命令が一旦Non-Operation命令に置き換えられて命令が発行された後、直前の分岐命令で分岐不成立と確定した場合にはそのまま命令実行を続行し、分岐成立と予測されその後分岐不成立と確定した場合には元のシーケンシャルな命令の命令再フェッチ要求を行ってフェッチ完了後直ちに命令を発行する手段とを備えたことを特徴とする、プロセッサ。
(付記18) 記憶装置と、
該記憶装置に格納されている前記遅延命令と、該遅延命令が命令シーケンスのどの位置の命令であるのかを判別するためのタグ情報とを、同時に前記記憶装置から消去する手段を更に備えたことを特徴とする、付記17記載のプロセッサ。
In addition, this invention also includes the invention attached to the following.
(Supplementary note 1) An instruction control method using a delayed instruction for branching,
An instruction control method comprising a step of sequentially storing a plurality of delayed instructions together with information indicating whether a branch instruction corresponding to the delayed instruction is predicted to be taken or not taken, in a storage device.
(Supplementary note 2) The method further includes a step of temporarily replacing the delayed instruction with a non-operation instruction when the branch instruction is predicted to fail, and executing the delayed instruction when the branch instruction is predicted to be established. The instruction control method according to appendix 1.
(Appendix 3) When a branch instruction is predicted to be unsuccessful and the delayed instruction is temporarily replaced with a non-operation instruction, a non-operation instruction is issued as it is. When a branch is predicted to be established, the corresponding branch instruction is handled. The instruction control method according to claim 2, further comprising a step of issuing a branch destination instruction predicted after issuing the delayed instruction.
(Supplementary note 4) The method further includes the step of registering, in the storage device, a tag for determining at which position of the instruction sequence the instruction is stored when the instruction is stored in the storage device. The command control method according to any one of 1 to 3.
(Supplementary Note 5) An instruction control method having a delayed instruction for branching,
When branch prediction is performed, the branch instruction is predicted to be unsuccessful, the delayed instruction is replaced with a non-operation instruction, and the instruction is issued. An instruction fetch request and a corresponding delay instruction are fetched from the storage device, and the instruction is issued. After the branch instruction is predicted and the delay instruction corresponding to the branch instruction is issued, the predicted branch destination instruction is issued and predicted. If the branch destination is correct, the instruction execution is continued as it is, and if the predicted branch destination is incorrect, a step is included in which an instruction refetch request for the branch destination instruction after the delayed instruction is made. Instruction control method.
(Supplementary note 6) When branch establishment is confirmed after branch failure is predicted, branch destination instruction fetch is performed immediately after branch decision, and branch destination instruction is issued after delay instruction fetched from the storage device is input The instruction control method according to claim 5, further comprising a step of:
(Supplementary note 7) If the predicted branch destination is incorrect after the branch establishment is predicted after the branch establishment is predicted, the correct branch destination instruction is refetched immediately after the branch destination is determined and the delayed instruction is input. The instruction control method according to appendix 5, further comprising a step of issuing a branch destination instruction later.
(Supplementary note 8) An instruction control method having a delayed instruction for branching,
When branch prediction is performed, the branch instruction is predicted to be unsuccessful, the delayed instruction is temporarily replaced with a non-operation instruction, and the instruction is issued. Instruction control, including a step of issuing an instruction immediately after completion of fetching by performing an instruction refetch request of the original sequential instruction when branch is predicted and branch is not established afterwards. Method.
(Supplementary Note 9) The step of simultaneously erasing the delay instruction stored in the storage device and the tag information for determining which position in the instruction sequence the delay instruction is from the storage device at the same time. The instruction control method according to appendix 8, characterized by comprising:
(Supplementary Note 10) A processor that performs instruction control using a delay instruction for branching,
A storage device;
A branch prediction unit for performing branch prediction;
Control means for sequentially storing a plurality of delayed instructions in the storage device together with information indicating whether a branch instruction corresponding to the delayed instruction is predicted to be taken or not taken in the branch predicting unit A processor.
(Additional remark 11) When the branch instruction is predicted that the branch is not established, the delay instruction is temporarily replaced with a non-operation instruction, and when it is predicted that the branch is established, the delay instruction is further executed. The processor according to appendix 10, wherein
(Supplementary note 12) When a branch instruction is predicted to be unsuccessful and a delayed instruction is temporarily replaced with a non-operation instruction, a non-operation instruction is issued as it is. When a branch is predicted to be established, the corresponding branch instruction is handled. 12. The processor according to claim 11, further comprising means for issuing a branch destination instruction predicted after issuing the delayed instruction.
(Additional remark 13) When storing an instruction in the storage device, it further comprises means for registering in the storage device a tag for determining which position in the instruction sequence the instruction is. The processor according to any one of appendices 10 to 12.
(Supplementary note 14) A processor for controlling an instruction having a delay instruction for branching,
A storage device;
A branch prediction unit for performing branch prediction;
When branch prediction is performed in the branch prediction unit, the branch instruction is predicted to be unsuccessful, the delayed instruction is replaced with a non-operation instruction, and the instruction is issued. The branch destination instruction fetch request and the corresponding delay instruction are fetched from the storage device and issued, and after the branch instruction is predicted and the delay instruction corresponding to the branch instruction is issued, the predicted branch destination instruction is issued. When the predicted branch destination is correct, the instruction execution is continued as it is, and when the predicted branch destination is incorrect, a means for performing an instruction refetch request for the branch destination instruction after the delayed instruction is provided. A processor, comprising:
(Supplementary note 15) When branch establishment is confirmed after branch failure is predicted, branch destination instruction fetch is performed immediately after branch confirmation, and branch destination instruction is issued after delay instruction fetched from the storage device is input The processor according to appendix 14, further comprising means for:
(Supplementary Note 16) If the predicted branch destination is incorrect after the branch establishment is predicted and the predicted branch destination is incorrect, the correct branch destination instruction is refetched immediately after the branch destination is determined and the delayed instruction is input. 15. The processor according to appendix 14, further comprising means for issuing a branch destination instruction later.
(Supplementary Note 17) A processor for controlling an instruction having a delay instruction for branching,
A branch prediction unit for performing branch prediction;
When branch prediction is performed in the branch prediction unit, the branch instruction is predicted to be unsuccessful, the delayed instruction is temporarily replaced with a non-operation instruction, and the instruction is issued. Has a means to continue the instruction execution as it is, and when it is predicted that the branch will be taken and then the branch will not take place, it will issue an instruction refetch request for the original sequential instruction and issue the instruction immediately after the fetch is completed A processor.
(Supplementary note 18) Storage device;
Means for simultaneously erasing the delayed instruction stored in the storage device and tag information for determining at which position of the instruction sequence the delayed instruction is stored in the storage device; The processor according to appendix 17, characterized by:

以上、本発明を実施例により説明したが、本発明は上記実施例に限定されるものではなく、種々の変形及び改良が可能であることは、言うまでもない。   As mentioned above, although this invention was demonstrated by the Example, this invention is not limited to the said Example, It cannot be overemphasized that various deformation | transformation and improvement are possible.

本発明になるプロセッサの一実施例を示すブロック図である。It is a block diagram which shows one Example of the processor which becomes this invention. 命令ユニットの要部を示すブロック図である。It is a block diagram which shows the principal part of an instruction unit. 命令ユニットの要部の動作を説明するフローチャートである。It is a flowchart explaining operation | movement of the principal part of an instruction unit. 命令ユニットの要部の動作を説明するタイムチャートである。It is a time chart explaining operation | movement of the principal part of an instruction unit. ディレイスロットスタック部の動作を説明する図である。It is a figure explaining operation | movement of a delay slot stack part. ディレイスロットスタック部内の回路構成を示す回路図である。It is a circuit diagram which shows the circuit structure in a delay slot stack part. 命令デコーダ部内の回路構成を示す回路図である。It is a circuit diagram which shows the circuit structure in an instruction decoder part. ディレイスロットスタック部内の回路構成を示す回路図である。It is a circuit diagram which shows the circuit structure in a delay slot stack part. 分岐命令制御部内の回路構成を示す回路図である。It is a circuit diagram which shows the circuit structure in a branch instruction control part. ディレイスロットスタック部内の回路構成を示す回路図である。It is a circuit diagram which shows the circuit structure in a delay slot stack part. 分岐命令制御部内の回路構成を示す回路図である。It is a circuit diagram which shows the circuit structure in a branch instruction control part. 命令デコーダ部内の回路構成を示す回路図である。It is a circuit diagram which shows the circuit structure in an instruction decoder part.

符号の説明Explanation of symbols

1 分岐予測部
2 命令フェッチ部
3 命令バッファ部
4 相対分岐アドレス生成部
5 命令デコーダ部
6 分岐命令実行部
7 分岐命令制御部
8 ディレイスロットスタック部
9 命令完了制御部
10 分岐先アドレスレジスタ
11 プログラムカウンタ部
21 命令ユニット
22 メモリユニット
23 演算ユニット
DESCRIPTION OF SYMBOLS 1 Branch prediction part 2 Instruction fetch part 3 Instruction buffer part 4 Relative branch address generation part 5 Instruction decoder part 6 Branch instruction execution part 7 Branch instruction control part 8 Delay slot stack part 9 Instruction completion control part 10 Branch destination address register 11 Program counter Unit 21 Instruction unit 22 Memory unit 23 Arithmetic unit

Claims (5)

分岐のための遅延命令をもつ命令制御方法であって、
分岐予測を行った時、分岐命令が分岐不成立と予測され遅延命令が一旦Non-Operation命令に置きかえられて命令が発行された後、直前の分岐命令で分岐成立と確定した場合には分岐先の命令フェッチ要求と共に記憶装置より対応する遅延命令を取り出して命令を発行し、分岐成立と予測され該分岐命令に対応する遅延命令が発行された後、予測された分岐先の命令が発行されて予測された分岐先が正しい場合にはそのまま命令実行を継続すると共に予測された分岐先が誤っている場合には遅延命令後の分岐先命令の命令再フェッチ要求を行うステップを含むことを特徴とする、命令制御方法。
An instruction control method having a delay instruction for branching, comprising:
When branch prediction is performed, if the branch instruction is predicted to be unsuccessful, the delayed instruction is temporarily replaced with a non-operation instruction, and the instruction is issued, then the branch destination An instruction fetch request and a corresponding delay instruction are fetched from the storage device, and the instruction is issued. After the branch instruction is predicted and the delay instruction corresponding to the branch instruction is issued, the predicted branch destination instruction is issued and predicted. If the branch destination is correct, the instruction execution is continued as it is, and if the predicted branch destination is incorrect, a step is included in which an instruction refetch request for the branch destination instruction after the delayed instruction is made. Instruction control method.
分岐不成立と予測された後に分岐成立が確定した場合に、分岐先の命令フェッチを分岐確定直後に行ない、前記記憶装置より取り出された遅延命令の命令投入後に分岐先の命令を発行するステップを更に含むことを特徴とする、請求項1記載の命令制御方法。   A step of fetching a branch destination instruction immediately after the branch is confirmed when branch establishment is confirmed after branch failure is predicted, and issuing a branch destination instruction after inputting a delayed instruction fetched from the storage device; The instruction control method according to claim 1, further comprising: 分岐成立と予測された後に分岐成立が確定して予測された分岐先が誤っていた場合に、分岐先が確定した直後に正しい分岐先の命令再フェッチを行ない遅延命令の命令投入後に分岐先の命令を発行するステップを更に含むことを特徴とする、請求項1記載の命令制御方法。   If the predicted branch destination is incorrect after the branch establishment is predicted and the predicted branch destination is incorrect, the correct branch destination instruction is refetched immediately after the branch destination is determined, and the branch destination 2. The instruction control method according to claim 1, further comprising a step of issuing an instruction. 分岐のための遅延命令をもつ命令制御方法であって、
分岐予測を行った時、分岐命令が分岐不成立と予測され遅延命令が一旦Non-Operation命令に置き換えられて命令が発行された後、直前の分岐命令で分岐不成立と確定した場合にはそのまま命令実行を続行し、分岐成立と予測されその後分岐不成立と確定した場合には元のシーケンシャルな命令の命令再フェッチ要求を行ってフェッチ完了後直ちに命令を発行するステップを含むことを特徴とする、命令制御方法。
An instruction control method having a delay instruction for branching, comprising:
When branch prediction is performed, the branch instruction is predicted to be unsuccessful, the delayed instruction is temporarily replaced with a non-operation instruction, and the instruction is issued. Instruction control, including a step of issuing an instruction immediately after completion of fetching by performing an instruction refetch request of the original sequential instruction when branch is predicted and branch is not established afterwards. Method.
記憶装置に格納されている前記遅延命令と、該遅延命令が命令シーケンスのどの位置の命令であるのかを判別するためのタグ情報とを、同時に前記記憶装置から消去するステップを更に含むことを特徴とする、請求項4記載の命令制御方法。   The method further comprises the step of simultaneously erasing the delay instruction stored in the storage device and tag information for determining which position in the instruction sequence the delay instruction is from the storage device. The instruction control method according to claim 4.
JP2006153452A 2006-06-01 2006-06-01 Instruction control method Expired - Fee Related JP3971780B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2006153452A JP3971780B2 (en) 2006-06-01 2006-06-01 Instruction control method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2006153452A JP3971780B2 (en) 2006-06-01 2006-06-01 Instruction control method

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
JP2002190556A Division JP3839755B2 (en) 2002-06-28 2002-06-28 Instruction control method and processor

Publications (2)

Publication Number Publication Date
JP2006228257A true JP2006228257A (en) 2006-08-31
JP3971780B2 JP3971780B2 (en) 2007-09-05

Family

ID=36989516

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2006153452A Expired - Fee Related JP3971780B2 (en) 2006-06-01 2006-06-01 Instruction control method

Country Status (1)

Country Link
JP (1) JP3971780B2 (en)

Also Published As

Publication number Publication date
JP3971780B2 (en) 2007-09-05

Similar Documents

Publication Publication Date Title
JP5889986B2 (en) System and method for selectively committing the results of executed instructions
US6898699B2 (en) Return address stack including speculative return address buffer with back pointers
KR101459536B1 (en) Methods and apparatus for changing a sequential flow of a program using advance notice techniques
EP1849063B1 (en) System and method of handling a branch misprediction
US8250349B2 (en) Branch prediction control device having return address stack and method of branch prediction
EP2069915B1 (en) Methods and system for resolving simultaneous predicted branch instructions
JP2001166935A (en) Branch prediction method for processor and processor
JP3839755B2 (en) Instruction control method and processor
JP3800533B2 (en) Program counter control method and processor
JP3683439B2 (en) Information processing apparatus and method for suppressing branch prediction
JP2001236224A (en) Method for reducing contamination of branch prediction table
JP3802038B2 (en) Information processing device
JP7409208B2 (en) arithmetic processing unit
JP3971780B2 (en) Instruction control method
JP4728877B2 (en) Microprocessor and pipeline control method
JP2001166934A (en) Instruction fetch controller
US11663014B2 (en) Speculatively executing instructions that follow a status updating instruction
JP3852782B2 (en) Instruction control device having branch prediction mechanism and control method thereof
JP2020060946A (en) Arithmetic processing device and arithmetic processing device control method
JPWO2008155839A1 (en) Instruction processing device
US20060112262A1 (en) Branch prediction of unconditionally executed branch instructions
JP2000339185A (en) Super scalar processor

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20060601

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20070201

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A132

Effective date: 20070213

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20070406

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

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

Ref document number: 3971780

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

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

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

Free format text: PAYMENT UNTIL: 20130615

Year of fee payment: 6

LAPS Cancellation because of no payment of annual fees