JP2939248B2 - Branch prediction method and processor - Google Patents

Branch prediction method and processor

Info

Publication number
JP2939248B2
JP2939248B2 JP19000398A JP19000398A JP2939248B2 JP 2939248 B2 JP2939248 B2 JP 2939248B2 JP 19000398 A JP19000398 A JP 19000398A JP 19000398 A JP19000398 A JP 19000398A JP 2939248 B2 JP2939248 B2 JP 2939248B2
Authority
JP
Japan
Prior art keywords
instruction
branch
execution
decoded
history information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
JP19000398A
Other languages
Japanese (ja)
Other versions
JPH1185516A (en
Inventor
哲也 田中
崇夫 山本
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Panasonic Holdings Corp
Original Assignee
Matsushita Electric Industrial Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Matsushita Electric Industrial Co Ltd filed Critical Matsushita Electric Industrial Co Ltd
Priority to JP19000398A priority Critical patent/JP2939248B2/en
Publication of JPH1185516A publication Critical patent/JPH1185516A/en
Application granted granted Critical
Publication of JP2939248B2 publication Critical patent/JP2939248B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Advance Control (AREA)

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、特に分岐命令を先
行的に解読し分岐の結果を予測し、予測に基づいてあら
かじめ分岐先の命令を読み出し、実際の分岐命令実行時
に予測が的中した場合は、分岐命令による命令の読み出
し遅延による性能低下を低減する分岐予測方法およびプ
ロセッサに関するものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a method for decoding a branch instruction in advance, predicting a result of a branch, reading an instruction of a branch destination in advance based on the prediction, and achieving a prediction when an actual branch instruction is executed. The present invention relates to a branch prediction method and a processor for reducing performance degradation due to instruction reading delay due to a branch instruction.

【0002】[0002]

【従来の技術】近年、計算機の発展に伴い、プロセッサ
を用いた装置がさまざまな分野に普及している。プロセ
ッサは、分岐命令によるハザードを低減するため、分岐
予測装置を備えている場合がある。従来の分岐予測装置
を備えたプロセッサでは、命令を実行前に先行的に解読
し、分岐命令である場合は分岐結果を予測し、分岐命令
の実行結果に基づいてあらかじめ分岐先の命令を読み出
す。
2. Description of the Related Art In recent years, with the development of computers, devices using processors have become widespread in various fields. The processor may include a branch prediction device in order to reduce a hazard caused by a branch instruction. 2. Description of the Related Art In a processor including a conventional branch prediction device, an instruction is decoded in advance before execution, and if the instruction is a branch instruction, a branch result is predicted, and an instruction at a branch destination is read in advance based on the execution result of the branch instruction.

【0003】分岐予測の方法としては静的分岐予測と動
的分岐予測とがある。静的分岐予測はハードウェアで分
岐成立か不成立かを予め決めておくことである。例え
ば、すべての分岐は常に不成立になると予測すると決め
ることができる。この場合、不成立の割合が多いとその
効果は高くなるが、成立の割合が多い場合は逆効果とな
る。また別の例では、後方分岐は分岐成立、前方分岐は
分岐不成立であると予測すると決める方法もある。この
方法はBTFN(Backward branch T
aken,Forward branch Not T
aken)法と呼ばれる。後方分岐はループを形成する
ことが多いので、ほとんどの場合分岐が成立すると仮定
できる。そのため後方分岐に関しては高い精度で予測す
ることができる。しかし、前方分岐に関しては上記と同
様に効果が出ない場合がある。
[0003] Branch prediction methods include static branch prediction and dynamic branch prediction. Static branch prediction is to determine in advance whether a branch is taken or not taken by hardware. For example, it can be determined that all branches are always predicted not to be taken. In this case, if the ratio of non-establishment is large, the effect is increased, but if the ratio of establishment is large, the effect is opposite. In another example, there is a method of determining that the backward branch is predicted to be taken and the forward branch is predicted to be not taken. This method is based on BTFN (Backward branch T).
aken, Forward branch Not T
aken) method. Since the backward branch often forms a loop, it can be assumed that the branch is taken in most cases. Therefore, the backward branch can be predicted with high accuracy. However, in the case of the forward branch, the same effect as described above may not be obtained.

【0004】こういった静的分岐予測の課題を解決する
のが、動的分岐予測である。動的分岐予測では各分岐命
令の結果を履歴として残しておき、次回の分岐の予測に
用いる。図8に動的分岐予測の概念図を示す。図8に示
すように動的分岐予測を行うには、1エントリが分岐命
令の絶対的なアドレスと分岐結果情報(例えば分岐成立
時は“1”、分岐不成立時は“0”)からなるテーブル
が分岐予測を行うための分岐予測情報として必要にな
る。分岐命令が実行されるとそのアドレスと結果がいず
れかのエントリに記録される。次に、同じアドレスの分
岐命令が先行解読されたとき、そのアドレスを用いて該
当するエントリを検索し、記録されている分岐結果情報
を参考にして分岐予測を行う。分岐予測が分岐成立なら
ば、分岐先の命令を命令の格納されたメモリから読み出
し、分岐予測が分岐不成立ならば、次の命令をメモリか
ら読み出す。さらに、同分岐命令が実行されるとき分岐
結果が予測結果と一致している場合は、予測により先行
的にメモリから読み出された命令を実行する。このとき
分岐先の命令をメモリから読み出す際の遅延は、先行的
に行われているので低減される。なお、図8は、アドレ
スA〜Dと各アドレスA〜Dに対応した分岐命令の結果
情報を概念的に示すものである。
[0004] Dynamic branch prediction solves the problem of such static branch prediction. In dynamic branch prediction, the result of each branch instruction is left as a history and used for prediction of the next branch. FIG. 8 shows a conceptual diagram of dynamic branch prediction. As shown in FIG. 8, in order to perform dynamic branch prediction, a table in which one entry includes an absolute address of a branch instruction and branch result information (for example, “1” when a branch is taken and “0” when a branch is not taken). Are required as branch prediction information for performing branch prediction. When a branch instruction is executed, its address and result are recorded in any of the entries. Next, when a branch instruction having the same address is decoded in advance, a corresponding entry is searched using the address, and branch prediction is performed with reference to the recorded branch result information. If the branch prediction is taken, the instruction at the branch destination is read from the memory storing the instruction. If the branch prediction is not taken, the next instruction is read from the memory. Further, when the branch result matches the prediction result when the same branch instruction is executed, the instruction read from the memory in advance by the prediction is executed. At this time, the delay in reading the instruction at the branch destination from the memory is reduced because it is performed in advance. FIG. 8 conceptually shows addresses A to D and result information of branch instructions corresponding to the addresses A to D.

【0005】以上のように、従来の動的分岐予測では、
各分岐命令毎に分岐結果の予測を与えることができ、前
回(それ以前を含んでも良い)の結果を用いて予測する
ので、分岐予測の精度を高くすることができる。このと
き、分岐命令のアドレスと結果情報を保持するテーブル
と、必要なエントリを検索する手段が必要である。
As described above, in the conventional dynamic branch prediction,
The prediction of the branch result can be given for each branch instruction, and the prediction is performed using the result of the previous (or earlier), so that the accuracy of the branch prediction can be increased. At this time, a table for holding the address of the branch instruction and the result information and a means for searching for a necessary entry are required.

【0006】[0006]

【発明が解決しようとする課題】しかしながら、従来の
動的分岐予測では、各分岐命令毎にアドレスを保持して
いるので、分岐予測を行うために、大きな記憶容量を必
要とし、また該当する分岐命令の情報を高速に検索する
必要があるため、各エントリ毎にアドレスの比較装置が
必要になるという問題点を有している。通常、分岐予測
の効果を高めるためには多くの分岐命令をカバーする必
要がある。そのため、上記テーブルのエントリを多くと
る(通常512〜1024エントリ)が、その場合上記
問題はさらに大きくなる。
However, in the conventional dynamic branch prediction, since an address is held for each branch instruction, a large storage capacity is required for performing the branch prediction. Since it is necessary to search for instruction information at high speed, there is a problem that an address comparing device is required for each entry. Usually, in order to enhance the effect of branch prediction, it is necessary to cover many branch instructions. Therefore, the number of entries in the table is increased (usually 512 to 1024 entries).

【0007】本発明の第1の目的は、分岐予測精度の低
下を最小限にしつつ、分岐予測情報を保持するための記
憶容量を低減し、情報検索を行う回路を簡単化すること
ができる分岐予測方法を提供することである。本発明の
第2の目的は、分岐予測精度の低下を最小限にしつつ、
分岐予測情報を保持するための記憶容量を低減し、情報
検索を行う回路を簡単化することができる分岐予測装置
を備えたプロセッサを提供することである。
A first object of the present invention is to reduce a storage capacity for holding branch prediction information and to simplify a circuit for performing information retrieval while minimizing a decrease in branch prediction accuracy. It is to provide a prediction method. A second object of the present invention is to minimize a decrease in branch prediction accuracy,
An object of the present invention is to provide a processor including a branch prediction device capable of reducing a storage capacity for holding branch prediction information and simplifying a circuit for performing information search.

【0008】[0008]

【課題を解決するための手段】この課題を解決するため
に、本発明の分岐予測方法は、分岐命令の成立・不成立
を示す分岐結果を起点からの相対位置に対応して履歴情
報として記録する第1のステップと、次回の分岐命令の
実行前の先行解読時に起点からの先行解読命令の相対位
置を基に前記履歴情報を参照して前記次回の分岐命令の
分岐結果を予測する第2のステップとを含む。
In order to solve this problem, a branch prediction method according to the present invention uses a branch instruction that is taken or not taken.
A first step of recording, as history information , a branch result corresponding to the relative position from the starting point, and the history based on the relative position of the preceding decoding instruction from the starting point at the time of preceding decoding before execution of the next branch instruction. A second step of predicting a branch result of the next branch instruction with reference to information.

【0009】この場合、第1のステップは、起点の命令
の位置を保持する起点位置保持ステップと、命令を実行
のために解読する実行解読ステップと、起点位置保持ス
テップで保持した命令位置を基準として実行のために解
読した命令の相対位置を得る命令位置獲得ステップと、
解読した命令が分岐命令であった場合に、分岐命令の分
岐結果を履歴情報として分岐命令の相対位置に対応して
記録する履歴記録ステップとからなる。
In this case, the first step includes a starting position holding step for holding the position of the starting instruction, an execution decoding step for decoding the instruction for execution, and a reference to the instruction position held in the starting position holding step. An instruction position obtaining step of obtaining a relative position of an instruction decoded for execution as
If the decoded instruction is a branch instruction, a history recording step of recording the branch result of the branch instruction as history information corresponding to the relative position of the branch instruction.

【0010】また、第2のステップは、次回の命令の実
行前に命令を先行解読する先行解読ステップと、起点位
置保持ステップで保持した命令位置を基準として先行解
読した命令の相対位置を得る先行命令位置獲得ステップ
と、先行解読した命令が分岐命令であった場合に、先行
解読した分岐命令の相対位置に対応した履歴情報を参照
する履歴参照ステップと、履歴情報を参照した結果を用
いて先行解読した分岐命令の実行結果を予測する予測ス
テップとからなる。
The second step includes a preceding decoding step of precedingly decoding the instruction before execution of the next instruction, and a preceding step of obtaining a relative position of the previously decoded instruction based on the instruction position held in the starting position holding step. An instruction position acquisition step, a history reference step of referring to history information corresponding to the relative position of the previously decoded branch instruction when the preceding decoded instruction is a branch instruction, and a preceding step using the result obtained by referring to the history information. A prediction step of predicting the execution result of the decoded branch instruction.

【0011】また、上記の起点位置保持ステップは、例
えば実行しようとする起点の命令のアドレスを保持する
ステップからなる。具体的に言えば、この起点位置保持
ステップは、例えばプログラムのループ構造を検出する
ループ検出ステップと、ループ検出ステップにより検出
したプログラムのループ構造を基にループの先頭命令の
アドレスを取り出し保持するステップとからなる。上記
のループ検出ステップは、例えば後方に分岐する分岐命
令を解読することによりプログラムのループ構造を検出
するステップからなる。
The starting point holding step includes, for example, a step of holding an address of an instruction of a starting point to be executed. More specifically, the starting position holding step includes, for example, a loop detecting step of detecting a loop structure of the program, and a step of extracting and holding the address of the first instruction of the loop based on the loop structure of the program detected by the loop detecting step. Consists of The above-described loop detecting step includes a step of detecting a loop structure of a program by decoding a branch instruction that branches backward, for example.

【0012】上記の起点位置保持ステップは、他に例え
ばプログラムブロックの先頭アドレスを検出するブロッ
ク先頭アドレス検出ステップと、ブロック先頭アドレス
検出ステップで検出されたアドレスを保持するブロック
先頭アドレス保持ステップとからなる場合もある。上記
の命令位置獲得ステップは、例えば実行のため解読した
命令を計数して命令数を得るステップからなり、これに
対応して先行命令位置獲得ステップが、先行解読した命
令を計数して命令数を得るステップからなる。
The starting position holding step includes, for example, a block head address detecting step for detecting a head address of a program block, and a block head address holding step for holding an address detected in the block head address detecting step. In some cases. The above-mentioned instruction position obtaining step includes, for example, a step of counting the number of instructions decoded for execution to obtain the number of instructions, and in response to this, the preceding instruction position obtaining step counts the number of the previously decoded instructions and reduces the number of instructions. The steps of obtaining.

【0013】また、命令位置獲得ステップは、他に例え
ば実行のための解読により分岐命令であることが判明し
た命令を計数して命令数を得るステップからなり、これ
に対応して先行命令位置獲得ステップが、先行解読によ
り分岐命令であることが判明した命令を計数して命令数
を得るステップからなる場合もある。さらに、命令位置
獲得ステップは、他に例えば実行のための解読した命令
のアドレスと起点位置保持ステップにより保持されたア
ドレスとの差分を得るステップからなり、これに対応し
て先行命令位置獲得ステップが、先行解読した命令のア
ドレスと起点位置保持ステップにより保持されたアドレ
スとの差分を得るステップからなる場合もある。
The instruction position obtaining step further includes, for example, a step of counting instructions which have been found to be branch instructions by decoding for execution to obtain the number of instructions, and correspondingly obtaining a preceding instruction position. In some cases, the step includes a step of counting instructions which are determined to be branch instructions by preceding decoding to obtain the number of instructions. Further, the instruction position obtaining step further includes, for example, a step of obtaining a difference between the address of the decoded instruction for execution and the address held by the starting position holding step. There may be a step of obtaining a difference between the address of the pre-decoded instruction and the address held in the starting position holding step.

【0014】 本発明の分岐予測方法によれば、分岐命令
の成立・不成立を示す分岐結果を起点からの相対位置に
対応して履歴情報として記録し、次回の分岐命令の実行
時に起点からの先行解読命令の相対位置を基に履歴情報
を参照して分岐命令の分岐結果を予測するようにしてい
るので、分岐予測を行うために必要な分岐予測情報とし
て起点の情報と相対位置情報と履歴情報だけで複数の分
岐命令の分岐結果を予測でき、分岐命令毎に絶対的なア
ドレスおよび履歴情報を保持する従来例の場合の情報量
に比べて、起点の情報と分岐命令毎に相対位置情報およ
び履歴情報を保持する場合の情報量が少ないため、分岐
予測情報を保持するメモリ容量を従来より少なくするこ
とができる。
[0014] According to the branch prediction method of the present invention, the branch instruction
The branching result indicating whether the
Correspondingly records as history information and executes the next branch instruction
Sometimes history information based on the relative position of the preceding decoding instruction from the starting point
Is used to predict the branch result of a branch instruction
Therefore, as branch prediction information necessary for performing branch prediction,
Only the start point information, relative position information, and history information.
The result of a branch instruction can be predicted.
Information amount in the case of the conventional example holding dress and history information
Compared to the information of the starting point and the relative position information and
Branching due to the small amount of information when
Reduce the memory capacity to hold prediction information
Can be.

【0015】また、従来は分岐命令毎にそのアドレスを
保持し、分岐命令が現れるたびに対応する分岐命令を検
索する構成で、分岐命令のアドレスと保持されている全
てのアドレスとを比較するための複数の比較器を備えた
検索回路が必要であるが、本発明の分岐予測方法によれ
ば、相対位置情報(例えば、相対アドレス値)はアドレ
ス情報より情報量が少ないため、比較器の規模を小さく
でき、検索回路の回路規模を小さくできる。また、低消
費電力化にもつながる。
Further, conventionally, the address is retained for each branch instruction, and each time a branch instruction appears, the corresponding branch instruction is searched. In order to compare the address of the branch instruction with all the retained addresses, However, according to the branch prediction method of the present invention, the relative position information (for example, the relative address value) has a smaller amount of information than the address information. Can be reduced, and the circuit scale of the search circuit can be reduced. It also leads to lower power consumption.

【0016】また、本発明のプロセッサは、分岐命令の
成立・不成立を示す分岐結果を起点からの相対位置に対
応して履歴情報として記録する第1の手段と、次回の分
岐命令の実行前の先行解読時に起点からの先行解読命令
の相対位置を基に履歴情報を参照して次回の分岐命令の
分岐結果を予測する第2の手段とを備えている。この場
合、第1の手段は、起点の命令の位置を保持する起点位
置保持手段と、命令を実行のために解読する実行解読手
段と、起点位置保持手段で保持した命令位置を基準とし
て実行のために解読した命令の相対位置を得る命令位置
獲得手段と、解読した命令が分岐命令であった場合に、
分岐命令の分岐結果を履歴情報として分岐命令の相対位
置に対応して記録する履歴記録手段とからなる。
Further, the processor of the present invention provides a
A first means for recording, as history information , a branch result indicating whether a branch has been taken or not , corresponding to a relative position from the starting point; And second means for predicting the branch result of the next branch instruction by referring to the history information. In this case, the first means includes a starting position holding means for holding the position of the starting instruction, an execution decoding means for decoding the instruction for execution, and an execution position based on the instruction position held by the starting position holding means. Instruction position obtaining means for obtaining the relative position of the decoded instruction, and when the decoded instruction is a branch instruction,
History recording means for recording the branch result of the branch instruction as history information corresponding to the relative position of the branch instruction.

【0017】また、第2の手段は、次回の命令の実行前
に命令を先行解読する先行解読手段と、起点位置保持手
段で保持した命令位置を基準として先行解読した命令の
相対位置を得る先行命令位置獲得手段と、先行解読した
命令が分岐命令であった場合に、先行解読した分岐命令
の相対位置に対応した履歴情報を参照する履歴参照手段
と、履歴情報を参照した結果を用いて先行解読した分岐
命令の実行結果を予測する分岐予測手段とからなる。
The second means includes a preceding decoding means for decoding the instruction before execution of the next instruction, and a preceding means for obtaining a relative position of the previously decoded instruction based on the instruction position held by the starting position holding means. Instruction position acquisition means, history reference means for referring to history information corresponding to the relative position of the previously decoded branch instruction when the predecoded instruction is a branch instruction, and precedent using the result obtained by referring to the history information; Branch prediction means for predicting the execution result of the decoded branch instruction.

【0018】また、上記の起点位置保持手段は、例えば
実行しようとする起点の命令のアドレスを保持する手段
からなる。具体的に言えば、この起点位置保持手段は、
例えばプログラムのループ構造を検出するループ検出手
段と、ループ検出手段により検出したプログラムのルー
プ構造を基にループの先頭命令のアドレスを取り出し保
持するループ先頭アドレス保持手段とからなる。上記の
ループ検出手段は、例えば後方に分岐する分岐命令を解
読することによりプログラムのループ構造を検出する手
段からなる。
The starting position holding means comprises, for example, means for holding an address of an instruction of a starting point to be executed. More specifically, the starting position holding means includes:
For example, it comprises a loop detecting means for detecting the loop structure of the program, and a loop head address holding means for extracting and holding the address of the head instruction of the loop based on the loop structure of the program detected by the loop detecting means. The above-mentioned loop detecting means comprises, for example, means for detecting a loop structure of a program by decoding a backward branch instruction.

【0019】上記の起点位置保持手段は、他に例えばプ
ログラムブロックの先頭アドレスを検出するブロック先
頭アドレス検出手段と、ブロック先頭アドレス検出手段
で検出されたアドレスを保持するブロック先頭アドレス
保持手段とからなる場合もある。上記の命令位置獲得手
段は、例えば実行のため解読した命令を計数して命令数
を得る手段からなり、これに対応して先行命令位置獲得
手段が、先行解読した命令を計数して命令数を得る手段
からなる。
The starting position holding means includes, for example, a block head address detecting means for detecting a head address of a program block, and a block head address holding means for holding an address detected by the block head address detecting means. In some cases. The above-mentioned instruction position obtaining means includes, for example, means for counting instructions decoded for execution to obtain the number of instructions. Means to obtain.

【0020】また、命令位置獲得手段は、他に例えば実
行のための解読により分岐命令であることが判明した命
令を計数して命令数を得る手段からなり、これに対応し
て先行命令位置獲得手段が、先行解読により分岐命令で
あることが判明した命令を計数して命令数を得る手段か
らなる場合もある。さらに、命令位置獲得手段が、他に
例えば実行のための解読した命令のアドレスと起点位置
保持手段により保持されたアドレスとの差分を得る手段
からなり、これに対応して先行命令位置獲得手段が、先
行解読した命令のアドレスと起点位置保持手段により保
持されたアドレスとの差分を得る手段からなる場合もあ
る。
Further, the instruction position obtaining means includes means for obtaining the number of instructions by counting the number of instructions determined to be a branch instruction by decoding for execution, for example. In some cases, the means may be a means for counting instructions determined to be branch instructions by preceding decoding to obtain the number of instructions. Further, the instruction position obtaining means may further comprise a means for obtaining a difference between the address of the decoded instruction for execution and the address held by the starting position holding means, for example. There may be a case in which a means for obtaining a difference between the address of the instruction decoded in advance and the address held by the starting position holding means is provided.

【0021】 本発明のプロセッサによれば、分岐命令の
成立・不成立を示す分岐結果を起点からの相対位置に対
応して履歴情報として記録し、次回の分岐命令の実行時
に起点からの先行解読命令の相対位置を基に履歴情報を
参照して分岐命令の分岐結果を予測する手段を有してい
るので、分岐予測を行うために必要な分岐予測情報とし
て起点の情報と相対位置情報と履歴情報だけで複数の分
岐命令の分岐結果を予測でき、分岐命令毎に絶対的なア
ドレスおよび履歴情報を保持する従来例の場合の情報量
に比べて、起点の情報と分岐命令毎に相対位置情報およ
び履歴情報を保持する場合の情報量が少ないため、分岐
予測情報を保持するメモリ容量を従来より少なくするこ
とができる。
[0021] According to the processor of the present invention, the branch instruction
Indicate success / failureMatch the branch result to the relative position from the starting point.
In response to history informationAsRecord and execute next branch instruction
History information based on the relative position of the preceding decoding instruction from the starting point.
Means for predicting the branch result of a branch instruction by referring to
Therefore, as branch prediction information necessary for performing branch prediction,
Only the start point information, relative position information, and history information.
The result of a branch instruction can be predicted.
Information amount in the case of the conventional example holding dress and history information
Compared to the information of the starting point and the relative position information and
Branching due to the small amount of information when
Reduce the memory capacity to hold prediction information
Can be.

【0022】また、従来は分岐命令毎にそのアドレスを
保持し、分岐命令が現れるたびに対応する分岐命令を検
索する手段を持つ構成で、分岐命令のアドレスと保持さ
れている全てのアドレスとを比較するための複数の比較
器を備えた検索回路が必要であるが、本発明のプロセッ
サによれば、相対位置情報(例えば、相対アドレス値)
はアドレス情報より情報量が少ないため、比較器の規模
を小さくでき、検索回路の回路規模を小さくできる。ま
た、低消費電力化にもつながる。
Further, conventionally, a structure is provided in which the address is held for each branch instruction, and means for searching for the corresponding branch instruction each time the branch instruction appears is used. Although a search circuit having a plurality of comparators for comparison is required, according to the processor of the present invention, relative position information (for example, relative address value)
Since the information amount is smaller than the address information, the size of the comparator can be reduced, and the circuit size of the search circuit can be reduced. It also leads to lower power consumption.

【0023】[0023]

【発明の実施の形態】以下、本発明に係る分岐予測方法
およびプロセッサの実施の形態について、図1から図5
を用いて詳細に説明する。図1は本発明の実施の形態に
おけるプロセッサのハードウェア構成を示すブロック図
である。本プロセッサは大きく、命令供給部100と命
令実行部200に分かれる。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Embodiments of a branch prediction method and a processor according to the present invention will be described below with reference to FIGS.
This will be described in detail with reference to FIG. FIG. 1 is a block diagram illustrating a hardware configuration of a processor according to an embodiment of the present invention. This processor is roughly divided into an instruction supply unit 100 and an instruction execution unit 200.

【0024】本実施の形態では、相対位置情報として分
岐命令の個数情報の例を示している。分岐命令の個数情
報の場合、得られる情報は、連続した値(単純に1ずつ
増加する値)であるために、検索のために保持する必要
がなく、そのまま履歴情報を格納したインデックスとし
て使用することができる。命令供給部100は、プログ
ラムに従って命令101を命令メモリから読み出し、命
令実行部200へ命令のアドレス102とともに供給す
る。命令実行部200へ供給した命令が分岐命令であれ
ば、命令供給部100は、命令実行部200の分岐判定
結果201を参照して、分岐命令を実行する。命令実行
部200は命令供給部100から供給された命令を実行
する上で、通常のプロセッサが有する機能を備えてい
る。
In the present embodiment, an example of information on the number of branch instructions as relative position information is shown. In the case of the number information of the branch instructions, the obtained information is a continuous value (a value that simply increases by one), so that it is not necessary to hold the information for searching, and is used as an index storing the history information as it is. be able to. The instruction supply unit 100 reads the instruction 101 from the instruction memory according to the program, and supplies the instruction 101 to the instruction execution unit 200 together with the instruction address 102. If the instruction supplied to the instruction execution unit 200 is a branch instruction, the instruction supply unit 100 executes the branch instruction with reference to the branch determination result 201 of the instruction execution unit 200. The instruction execution unit 200 has a function of a normal processor for executing the instruction supplied from the instruction supply unit 100.

【0025】図2は図1における命令供給部100のよ
り詳細なブロック図を示している。以下、図2に示され
た各ブロックの構成について説明する。命令メモリ1は
命令を格納するもので、例えば4個の命令から成る命令
群1Aを一括して読み出すことができる。また、本実施
の形態では、1サイクルで命令群1Aを読み出すことが
できるものとする。この命令群1Aは命令バッファ6と
マルチプレクサ8へ与えられる。
FIG. 2 is a more detailed block diagram of the instruction supply unit 100 in FIG. Hereinafter, the configuration of each block shown in FIG. 2 will be described. The instruction memory 1 stores instructions, and can collectively read, for example, an instruction group 1A including four instructions. In this embodiment, it is assumed that the instruction group 1A can be read in one cycle. The instruction group 1A is supplied to the instruction buffer 6 and the multiplexer 8.

【0026】プリフェッチカウンタ2は、マルチプレク
サ4の出力4Aを命令メモリ1の読み出しアドレスとし
て格納するもので、制御回路26の制御信号55によっ
て制御され、出力されるアドレス2Aは命令メモリ1と
インクリメンタ3へ与えられる。インクリメンタ3は、
プリフェッチカウンタ2を更新するためのもので、プリ
フェッチカウンタ2から出力されるアドレス2Aを入力
とし、この例ではカウント値を4ずつ更新し、その出力
3Aはマルチプレクサ5へ与えられる。
The prefetch counter 2 stores the output 4A of the multiplexer 4 as a read address of the instruction memory 1. The prefetch counter 2 is controlled by a control signal 55 of the control circuit 26. The output address 2A is stored in the instruction memory 1 and the incrementer 3. Given to. Incrementor 3
For updating the prefetch counter 2, the address 2A output from the prefetch counter 2 is input. In this example, the count value is updated by 4 and the output 3A is given to the multiplexer 5.

【0027】マルチプレクサ4,5は、次サイクルのプ
リフェッチカウンタ2の値を選択するもので、それぞれ
制御回路26の制御信号50,51によって制御され
る。マルチプレクサ5は、インクリメンタ3の出力3A
と解読器14の出力である分岐先アドレス14Aとイン
クリメンタ16の生成アドレス16Aとを入力とし、制
御信号51に従って何れかを選択し、その出力5Aをマ
ルチプレクサ4へ与える。マルチプレクサ4は、マルチ
プレクサ5の出力5Aと先行解読器10の出力である先
行分岐先アドレス10Aとを入力とし、制御信号50に
従って何れかを選択し、その出力4Aをプリフェッチカ
ウンタ2へ与える。
The multiplexers 4 and 5 select the value of the prefetch counter 2 in the next cycle, and are controlled by control signals 50 and 51 of the control circuit 26, respectively. The multiplexer 5 outputs the output 3A of the incrementer 3
And a branch destination address 14A as an output of the decoder 14 and a generation address 16A of the incrementer 16 as inputs, select one according to the control signal 51, and give its output 5A to the multiplexer 4. The multiplexer 4 receives the output 5A of the multiplexer 5 and the preceding branch destination address 10A which is the output of the preceding decoder 10, selects one according to the control signal 50, and supplies the output 4A to the prefetch counter 2.

【0028】上記のプリフェッチカウンタ2とインクリ
メンタ3とマルチプレクサ4,5とが、命令を先行解読
するために命令メモリ1から読み出すときのアドレスを
生成する手段として機能する。命令バッファ6は、命令
メモリ1から読み出された命令群1Aを格納するもの
で、制御回路26の制御信号60によって制御される。
命令バッファ6から出力された命令群6Aはマルチプレ
クサ8と先行解読器10へ与えられる。
The prefetch counter 2, the incrementer 3, and the multiplexers 4 and 5 function as means for generating an address when the instruction is read from the instruction memory 1 in order to decode the instruction in advance. The instruction buffer 6 stores the instruction group 1A read from the instruction memory 1, and is controlled by a control signal 60 of the control circuit 26.
The instruction group 6A output from the instruction buffer 6 is supplied to the multiplexer 8 and the preceding decoder 10.

【0029】マルチプレクサ8は、命令メモリ1から読
み出された命令群1Aと命令バッファ6に保持されて出
力される命令群6Aを選択するもので、制御回路26の
制御信号52に従って何れかを選択し、その出力である
命令群8Aをマルチプレクサ9へ与える。マルチプレク
サ9は、マルチプレクサ8で選択出力された4個の命令
から成る命令群8Aから1個の命令を選択するもので、
制御回路26の制御信号53に従って何れか1個の命令
9Aを選択して命令レジスタ13へ与えるとともに命令
実行部200へ実行命令101として送る。
The multiplexer 8 selects the instruction group 1A read from the instruction memory 1 and the instruction group 6A held and output in the instruction buffer 6, and selects one according to the control signal 52 of the control circuit 26. Then, the instruction group 8A which is the output is given to the multiplexer 9. The multiplexer 9 selects one instruction from an instruction group 8A composed of four instructions selected and output by the multiplexer 8.
According to the control signal 53 of the control circuit 26, any one of the instructions 9A is selected and supplied to the instruction register 13 and sent to the instruction execution unit 200 as an execution instruction 101.

【0030】上記の命令バッファ6とマルチプレクサ8
とマルチプレクサ9とで命令を先行解読するために一時
的に命令群を保持しておく手段、および命令を実行する
ために命令実行部200および命令レジスタ13に命令
を供給する手段として機能する。先行解読器10は、命
令バッファ6に保持されて出力される命令群6Aを解読
し、後方分岐命令または前方分岐命令の判定と先行分岐
先アドレス10Aの生成を行うもので、実行前に命令を
先行解読する先行解読手段として機能する。この先行解
読器10による分岐判定結果10Bは制御回路26へ与
えられ、先行分岐先アドレス10Aはマルチプレクサ4
へ与えられる。
The above-mentioned instruction buffer 6 and multiplexer 8
The multiplexer 9 functions as a unit for temporarily storing an instruction group for pre-decoding the instruction, and a unit for supplying the instruction to the instruction execution unit 200 and the instruction register 13 for executing the instruction. The predecoder 10 decodes the instruction group 6A held and output in the instruction buffer 6, determines a backward branch instruction or a forward branch instruction, and generates the preceding branch destination address 10A. It functions as a leading decoding means for leading decoding. The branch determination result 10B by the preceding decoder 10 is provided to the control circuit 26, and the preceding branch destination address 10A is supplied to the multiplexer 4
Given to.

【0031】命令レジスタ13は、マルチプレクサ9か
ら出力される命令9Aを入力とし、分岐命令を実行する
ために解読される命令を保持するもので、制御回路26
の制御信号57によって制御される。この命令レジスタ
13の出力13Aは解読器14へ与えられる。解読器1
4は、前方に分岐する分岐命令か、後方に分岐する分岐
命令であることを解読するもので、分岐命令であること
を示す信号14Bを制御回路26に与えると同時に分岐
先アドレス14Aを生成し、マルチプレクサ5,18と
ループアドレスレジスタ19と比較器20とへ与え、命
令を実行のために解読する実行解読手段として機能す
る。また、この解読器14は、分岐命令であることを解
読し、さらにその分岐先アドレスによって後方分岐であ
ることを検出することで、プログラムのループ構造を検
出するループ検出手段として機能し、そのときの分岐先
アドレスがループ先頭アドレスとなる。
The instruction register 13 receives an instruction 9A output from the multiplexer 9 and holds an instruction decoded to execute a branch instruction.
Is controlled by the control signal 57. The output 13A of the instruction register 13 is provided to the decoder 14. Decryptor 1
Numeral 4 is used to decode a branch instruction that branches forward or a branch instruction that branches backward. A signal 14B indicating that the instruction is a branch instruction is supplied to the control circuit 26, and at the same time, a branch destination address 14A is generated. , Multiplexers 5 and 18, loop address register 19 and comparator 20 to function as execution decoding means for decoding instructions for execution. Further, the decoder 14 functions as a loop detecting means for detecting a branch instruction and further detecting a backward branch based on the branch destination address, thereby detecting a loop structure of the program. Is the loop start address.

【0032】プログラムカウンタ15は、マルチプレク
サ18の出力18Aを入力とし、命令レジスタ13に保
持されている命令に対応するアドレスを保持するもの
で、制御回路26の制御信号56で制御される。このプ
ログラムカウンタ15から出力されるアドレス15Aは
インクリメンタ16へ与えられる。インクリメンタ16
は、プログラムカウンタ15を更新するためのもので、
プログラムカウンタ15から出力されるアドレス15A
を入力とし、値を1ずつ更新することで次命令のアドレ
スを生成しており、その生成アドレス16Aはマルチプ
レクサ5,18に与えられる。
The program counter 15 receives the output 18A of the multiplexer 18 as an input and holds an address corresponding to the instruction held in the instruction register 13, and is controlled by a control signal 56 of the control circuit 26. The address 15A output from the program counter 15 is provided to an incrementer 16. Incrementer 16
Is for updating the program counter 15,
Address 15A output from program counter 15
And the value is updated one by one to generate the address of the next instruction. The generated address 16A is given to the multiplexers 5 and 18.

【0033】マルチプレクサ18は、インクリメンタ1
6の生成アドレス16Aと解読器14が出力する分岐先
アドレス14Aとを入力とし、解読器14で分岐命令が
解読された場合、解読器14が出力する分岐先アドレス
14Aを選択することでプログラムカウンタ15の値を
更新するもので、制御回路26の制御信号54によって
制御される。なお、分岐命令以外の場合には、インクリ
メンタ16の生成アドレス16Aを選択する。
The multiplexer 18 includes the incrementer 1
6 and the branch destination address 14A output by the decoder 14 are input, and when the branch instruction is decoded by the decoder 14, the branch counter address 14A output by the decoder 14 is selected, whereby the program counter is selected. 15 is updated, and is controlled by the control signal 54 of the control circuit 26. In the case other than the branch instruction, the generation address 16A of the incrementer 16 is selected.

【0034】ループアドレスレジスタ19は、起点の命
令の位置、例えば起点の命令のアドレスを保持する起点
位置保持手段またはループ先頭アドレスを取り出し保持
するループ先頭アドレス保持手段として機能するもの
で、解読器14が出力する分岐先アドレス14Aを入力
とし、制御回路26の制御信号58によって制御され
る。このループアドレスレジスタ19が出力するループ
先頭アドレス19Aは比較器20へ与えられる。
The loop address register 19 functions as a starting position holding means for holding the position of the starting instruction, for example, the address of the starting instruction, or as a loop starting address holding means for extracting and holding the loop starting address. Is controlled by a control signal 58 of the control circuit 26. The loop head address 19A output from the loop address register 19 is supplied to the comparator 20.

【0035】比較器20は、解読した分岐命令の分岐先
アドレスと、それまでに格納しているループ先頭アドレ
スとを比較して、2回目以降のループを検出する手段と
して機能するもので、解読器14が出力する分岐先アド
レス14Aとループアドレスレジスタ19が出力するル
ープ先頭アドレス19Aとを入力とし、両者が一致した
ときに一致信号20Aを発生して制御回路26へ与え
る。
The comparator 20 compares the branch destination address of the decoded branch instruction with the loop start address stored so far, and functions as means for detecting the second or subsequent loop. A branch destination address 14A output from the detector 14 and a loop head address 19A output from the loop address register 19 are input. When they match, a match signal 20A is generated and supplied to the control circuit 26.

【0036】履歴ビットストリーム21は、制御回路2
6の制御信号59によって制御されるもので、ループ先
頭アドレス以降に存在する分岐命令の成立・不成立を示
分岐結果を1ビットの履歴として保持する機能を有す
る。この履歴ビットストリーム21には、命令実行部2
00から分岐判定結果201が履歴として入力され、ま
た保持された履歴21Aは制御回路26へ入力される。
本実施の形態では4ビットの履歴を保持できる構成を例
示しているが、4ビットでなくてもよく、例えば512
ビットでも同様の動作をする。
The history bit stream 21 is transmitted to the control circuit 2
6 is controlled by the control signal 59, and indicates whether a branch instruction existing after the loop start address is taken or not taken.
It has a function of holding a branch result as a 1-bit history. This history bit stream 21 includes an instruction execution unit 2
From 00, the branch determination result 201 is input as a history, and the held history 21A is input to the control circuit 26.
In the present embodiment, a configuration capable of holding a 4-bit history is illustrated. However, the configuration is not limited to 4-bit.
The same operation is performed for bits.

【0037】リードポインタ22は、履歴ビットストリ
ーム21から1ビット読み出すときのビット位置を表す
もので、起点位置保持手段で保持した命令位置を基準と
して先行解読した命令の相対位置を得る先行命令位置獲
得手段として機能する。この先行命令位置獲得手段は、
具体的には先行解読により分岐命令であることが判明し
た命令を計数して命令数を得る手段である。このリード
ポインタ22の出力22Aは履歴ビットストリーム21
と比較器24へ与えられる。また、このリードポインタ
22のリセットおよび更新は、制御回路26の制御信号
61,62によってそれぞれ制御される。
The read pointer 22 indicates a bit position when one bit is read from the history bit stream 21, and obtains a preceding instruction position for obtaining a relative position of the previously decoded instruction with reference to the instruction position held by the starting position holding means. Functions as a means. This preceding instruction position acquiring means is:
More specifically, the number of instructions is obtained by counting instructions determined to be branch instructions by preceding decoding. The output 22A of the read pointer 22 is the history bit stream 21
To the comparator 24. The reset and update of the read pointer 22 are controlled by control signals 61 and 62 of the control circuit 26, respectively.

【0038】ライトポインタ23は、履歴ビットストリ
ーム21に1ビット書き込むときのビット位置を表すも
ので、起点位置保持手段で保持した命令位置を基準とし
て実行のために解読した命令の相対位置を得る命令位置
獲得手段として機能する。この命令位置獲得手段は、具
体的には、実行のための解読により分岐命令であること
が判明した命令を計数して命令数を得る手段である。こ
のライトポインタ23の出力23Aは履歴ビットストリ
ーム21と比較器24へ与えられる。また、このライト
ポインタ23のリセットおよび更新は、制御回路26の
制御信号63,64によってそれぞれ制御される。
The write pointer 23 indicates a bit position when one bit is written in the history bit stream 21. An instruction for obtaining a relative position of an instruction decoded for execution with reference to the instruction position held by the starting position holding means. Functions as a position acquisition unit. Specifically, the instruction position obtaining means is a means for obtaining the number of instructions by counting the number of instructions determined to be branch instructions by decoding for execution. The output 23A of the write pointer 23 is provided to the history bit stream 21 and the comparator 24. The reset and update of the write pointer 23 are controlled by control signals 63 and 64 of the control circuit 26, respectively.

【0039】比較器24は、リードポインタ22の出力
22Aの値がライトポインタ23の出力23Aの値と一
致することを検出するためのもので、履歴ビットストリ
ーム21ではこれ以上の分岐命令の履歴を保持していな
いことを示すために用いられる。ここで、履歴ビットス
トリーム21とライトポインタ23とで、解読した命令
が分岐命令であった場合に、分岐命令の分岐結果を履歴
情報として分岐命令の相対位置に対応して記録する履歴
記録手段として機能し、履歴ビットストリーム21とリ
ードポインタ22と比較器24とで、先行解読した命令
が分岐命令であった場合に、先行解読した分岐命令の相
対位置に対応した履歴情報を参照する履歴参照手段およ
び、履歴情報を参照した結果を用いて先行解読した分岐
命令の実行結果を予測する分岐予測手段として機能す
る。この比較器24の出力24Aは制御回路26へ入力
される。
The comparator 24 is for detecting that the value of the output 22A of the read pointer 22 matches the value of the output 23A of the write pointer 23. Used to indicate that it does not hold. Here, when the decoded instruction is a branch instruction using the history bit stream 21 and the write pointer 23, the history recording unit records the branch result of the branch instruction as history information corresponding to the relative position of the branch instruction. History reference means for functioning, wherein the history bit stream 21, read pointer 22, and comparator 24 refer to history information corresponding to the relative position of the previously decoded branch instruction when the previously decoded instruction is a branch instruction. Also, it functions as a branch prediction unit that predicts the execution result of the previously decoded branch instruction using the result obtained by referring to the history information. The output 24A of the comparator 24 is input to the control circuit 26.

【0040】状態レジスタ25は、分岐予測の動作状態
を格納するもので、制御回路26の制御信号65を入力
とし、出力25Aを制御回路26へ返すことにより、履
歴情報が格納されていないときは“S0”の値をとり、
格納中は“S1”の値をとり、格納された履歴を用いて
分岐予測を行っているときは“S2”の値をとる。制御
回路26は、全体の動作を制御するものであり、前述し
たように、マルチプレクサ4,5,8,9,18の選択
肢を決定し、命令バッファ6、プリフェッチカウンタ
2、プログラムカウンタ15、命令レジスタ13、ルー
プアドレスレジスタ19の更新を制御し、履歴ビットス
トリーム21の読み出し、書き込みを制御し、リードポ
インタ22、ライトポインタ23のリセットと更新を制
御する。なお、制御回路26には、命令実行部200か
ら分岐判定結果201が入力される。
The state register 25 stores the operation state of branch prediction. The state register 25 receives a control signal 65 of the control circuit 26 as an input and returns an output 25A to the control circuit 26. Take the value of “S0”,
The value of "S1" is taken during storage, and the value of "S2" is taken when branch prediction is performed using the stored history. The control circuit 26 controls the overall operation. As described above, the control circuit 26 determines options of the multiplexers 4, 5, 8, 9, and 18, and stores the instruction buffer 6, the prefetch counter 2, the program counter 15, and the instruction register. 13. The update of the loop address register 19 is controlled, the reading and writing of the history bit stream 21 are controlled, and the reset and update of the read pointer 22 and the write pointer 23 are controlled. Note that the branch determination result 201 is input to the control circuit 26 from the instruction execution unit 200.

【0041】以上のように構成された本発明の実施の形
態によるプロセッサについて、図2の主な構成要素の動
作を説明する。プリフェッチカウンタ2は先行解読のた
め、実行に先だって命令メモリ1から命令を読み出すと
きのアドレスを保持している。プリフェッチカウンタ2
の値に対してインクリメンタ3で数値“4”が加算され
ることで次のサイクルのアドレスが生成され、マルチプ
レクサ5およびマルチプレクサ4を介して次のサイクル
でプリフェッチカウンタ2に格納され更新される。
The operation of the main components of FIG. 2 in the processor according to the embodiment of the present invention configured as described above will be described. The prefetch counter 2 holds an address at the time of reading an instruction from the instruction memory 1 prior to execution for pre-decoding. Prefetch counter 2
Is incremented by the incrementer 3 to generate the address of the next cycle, and is stored and updated in the prefetch counter 2 in the next cycle via the multiplexers 5 and 4.

【0042】マルチプレクサ5は、命令レジスタ13に
保持された実行対象の命令が解読器14で解読され、分
岐成立する分岐命令であることが検出された場合、解読
器14の出力する分岐先アドレス14Aを選択する。イ
ンクリメンタ16は、命令レジスタ13に格納されてい
る実行対象の命令の次の命令のアドレスを出力してお
り、マルチプレクサ5がこれを選択する場合は分岐予測
で分岐成立と予測されプリフェッチカウンタ2の値が変
更された後、分岐が不成立となった場合のプリフェッチ
カウンタ2を修正するためのパスである。なお、インク
リメンタ3は、分岐命令以外のときに選択されるパスで
ある。
The multiplexer 5 decodes the instruction to be executed held in the instruction register 13 by the decoder 14 and detects that the instruction is a branch instruction to be taken. Select The incrementer 16 outputs the address of the instruction next to the instruction to be executed stored in the instruction register 13. When the multiplexer 5 selects this, the branch prediction predicts that the branch is taken, and the prefetch counter 2 This is a path for correcting the prefetch counter 2 when the branch is not taken after the value is changed. Note that the incrementer 3 is a path selected when the instruction is not a branch instruction.

【0043】マルチプレクサ4は、先行解読器10で先
行解読され分岐が成立する分岐命令であると予測された
場合、先行解読器10の出力する先行分岐先アドレス1
0Aが選択され、それ以外の場合にはマルチプレクサ5
の出力5Aが選択される。なお、命令バッファ6に有効
な命令群が格納されている場合はプリフェッチカウンタ
2の更新は行われない。
When it is predicted that the branch instruction is pre-decoded by the pre-decoder 10 and the branch is taken, the multiplexer 4 outputs the pre-branch destination address 1 output from the pre-decoder 10.
0A is selected, otherwise multiplexer 5
Output 5A is selected. When a valid instruction group is stored in the instruction buffer 6, the prefetch counter 2 is not updated.

【0044】命令バッファ6は命令メモリ1から読み出
した命令群を保持する。保持された命令群は先行解読器
10で命令毎に解読され、分岐命令の検出が行われ、分
岐の結果を予測するのに使用される。また、命令バッフ
ァ6に保持された命令群は順次命令レジスタ13へ供給
される。命令バッファ6は保持している命令が無くなり
次第、次の命令群を命令メモリ1から読み出し保持す
る。命令レジスタ13に保持された命令が分岐命令であ
ることが検出され、命令実行部200が出力する分岐判
定結果で分岐が成立になった場合、命令バッファ6に保
持された命令群は無効化される。同様に、先行解読器1
0で分岐成立する分岐命令であると予測された場合も、
命令バッファ6は無効化される。
The instruction buffer 6 holds the instruction group read from the instruction memory 1. The held instruction group is decoded by the preceding decoder 10 for each instruction, a branch instruction is detected, and used for predicting the result of the branch. The instruction group held in the instruction buffer 6 is sequentially supplied to the instruction register 13. The instruction buffer 6 reads and holds the next instruction group from the instruction memory 1 as soon as the stored instruction is exhausted. When it is detected that the instruction held in the instruction register 13 is a branch instruction, and the branch is determined as a result of the branch determination output from the instruction execution unit 200, the instruction group held in the instruction buffer 6 is invalidated. You. Similarly, the leading decoder 1
If the branch instruction is predicted to be taken at 0,
The instruction buffer 6 is invalidated.

【0045】ここで、命令バッファ6の内容の有効、無
効について説明する。命令バッファ6は、命令群を先読
みして保持するが、分岐予測が外れた場合など、先読み
した命令群が結果として無効の場合がある。有効である
のは、先読みした命令群が将来使用される場合のことを
言う。マルチプレクサ8は次に実行すべき命令が含まれ
た命令群を命令メモリ1、命令バッファ6のそれぞれの
出力から選択する。命令バッファ6が無効の場合は選択
の対象にならない。マルチプレクサ9は、マルチプレク
サ8で選択された命令群の中から次に実行する命令を選
択する。命令群には4つの命令が含まれており、プログ
ラムカウンタ15に格納される次のサイクルの値の下位
2ビットを用いていずれかの命令を選択する。
Here, the validity and invalidity of the contents of the instruction buffer 6 will be described. The instruction buffer 6 prefetches and holds the instruction group, but there are cases where the prefetched instruction group is invalid as a result, for example, when a branch prediction is missed. It is valid when the prefetched instruction group is used in the future. The multiplexer 8 selects an instruction group including an instruction to be executed next from the respective outputs of the instruction memory 1 and the instruction buffer 6. When the instruction buffer 6 is invalid, it is not selected. The multiplexer 9 selects an instruction to be executed next from the instruction group selected by the multiplexer 8. The instruction group includes four instructions, and one of the instructions is selected using the lower two bits of the value of the next cycle stored in the program counter 15.

【0046】命令レジスタ13に格納された命令は、解
読器14で解読され、前方に分岐する分岐命令(For
ward Branch)であることを示す信号、後方
に分岐する分岐命令(Backward Branc
h)であることを示す信号、および分岐先アドレスを生
成する。分岐先アドレスは前方分岐あるいは後方分岐が
示されたときのみ有効になる。
The instruction stored in the instruction register 13 is decoded by the decoder 14 and a branch instruction (For
signal indicating that the instruction is a “ward branch”, and a branch instruction (backward branch) for branching backward.
h) and a branch destination address are generated. The branch destination address is valid only when a forward branch or a backward branch is indicated.

【0047】プログラムカウンタ15には、命令レジス
タ13に格納されている命令のアドレスが格納されてお
り、インクリメンタ16で数値“1”が加算され、マル
チプレクサ18を介して次の命令のアドレスとなる。マ
ルチプレクサ18は、解読器14で解読された命令が分
岐命令であり、命令実行部200の出力する分岐判定結
果が分岐成立を示している場合、分岐先アドレスを選択
し、次のサイクルで分岐先アドレスがプログラムカウン
タ15に格納されると同時に命令実行部200に実行命
令のアドレス102として出力される。なお、命令実行
部200では実行命令のアドレスはサブルーチンコール
命令のように命令のアドレスを必要とする命令を実行す
るのに用いられる。
The address of the instruction stored in the instruction register 13 is stored in the program counter 15. The value “1” is added by the incrementer 16, and becomes the address of the next instruction via the multiplexer 18. . The multiplexer 18 selects a branch destination address when the instruction decoded by the decoder 14 is a branch instruction and the branch determination result output from the instruction execution unit 200 indicates that the branch is taken, and selects the branch destination address in the next cycle. The address is stored in the program counter 15 and output to the instruction execution unit 200 at the same time as the address 102 of the execution instruction. The instruction execution unit 200 uses the address of the execution instruction to execute an instruction that requires an instruction address, such as a subroutine call instruction.

【0048】制御回路26は、後方分岐命令あるいは前
方分岐命令であることを示す信号、命令実行部200の
出力する分岐判定結果、先行解読の分岐命令の検出結
果、状態レジスタ25の動作状態、履歴ビットストリー
ム21の出力する分岐履歴から、各種制御信号、動作レ
ジスタ25の次サイクルの動作状態を生成するが、通常
のプロセッサの命令供給部の制御回路としての制御も行
う。
The control circuit 26 includes a signal indicating that the instruction is a backward branch instruction or a forward branch instruction, a branch determination result output from the instruction execution unit 200, a detection result of a previously decoded branch instruction, an operation state of the status register 25, and a history. From the branch history output from the bit stream 21, various control signals and the operation state of the operation register 25 in the next cycle are generated, but control is also performed as a control circuit of an instruction supply unit of a normal processor.

【0049】状態レジスタ25の動作状態は、ループ先
頭アドレスが検出される前は“S0”になっており、後
方分岐命令が検出され、ループ先頭アドレスがループア
ドレスレジスタ19に格納されるときに“S1”にな
る。動作状態が“S1”のときに再度後方分岐命令が検
出され、分岐先アドレスとループアドレスレジスタ19
の内容が一致した場合(すなわち、同じループを検出し
た場合)は“S2”になる。
The operation state of the status register 25 is "S0" before the loop head address is detected. S1 ". When the operation state is "S1", the backward branch instruction is detected again, and the branch destination address and the loop address register 19 are detected.
Are matched (that is, when the same loop is detected), "S2" is reached.

【0050】ループアドレスレジスタ19は状態レジス
タ25が“S0”のときは内容が無効である。動作状態
が“S0”のとき、解読器14で後方分岐命令が検出さ
れた場合、次サイクルで分岐先アドレス14Aを格納す
る。これがループの先頭アドレス、すなわち起点位置に
なる。状態レジスタ25のが“S1”または“S2”の
とき、後方分岐命令が検出され、分岐先アドレス14A
とループアドレスレジスタ19の内容が一致した場合は
ループアドレスレジスタ19は変化しない。動作状態が
いずれの状態でも分岐先アドレスとループアドレスレジ
スタ19の内容が一致しない場合はループアドレスレジ
スタ19に新たな分岐先アドレスが格納され、状態レジ
スタ25は“S1”になる。これは他のループが検出さ
れた場合にあたる。また、後方分岐が検出され、分岐が
不成立になった場合は状態レジスタが“S0”になり、
ループアドレスレジスタ19が無効化される。
When the status register 25 is "S0", the contents of the loop address register 19 are invalid. If the backward branch instruction is detected by the decoder 14 when the operation state is "S0", the branch destination address 14A is stored in the next cycle. This is the start address of the loop, that is, the starting position. When the status register 25 is "S1" or "S2", the backward branch instruction is detected and the branch destination address 14A is detected.
If the contents of the loop address register 19 match the contents of the loop address register 19, the loop address register 19 does not change. If the branch destination address does not match the contents of the loop address register 19 in any operation state, a new branch destination address is stored in the loop address register 19, and the state register 25 becomes "S1". This is when another loop is detected. When the backward branch is detected and the branch is not taken, the status register becomes “S0”,
The loop address register 19 is invalidated.

【0051】ライトポインタ23は命令実行部200か
ら得られた分岐結果をライトポインタ23の示すビット
位置に格納した後インクリメントされ、リードポインタ
22は分岐予測を行うため履歴ビットストリーム21の
リードポインタ22の示すビット位置に格納された分岐
結果が参照された後インクリメントされる。ただし、比
較器24によりリードポインタ22の値とライトポイン
タ23の値とが等しいか大きいことが検出された場合は
リードポインタ22のインクリメントは行われない。ラ
イトポインタ23は状態レジスタ25の動作状態が“S
0”から“S1”になるとき0にリセットされる。ま
た、リードポインタ22はループアドレスレジスタ19
と解読器14の生成した分岐先アドレスが等しいことが
検出された場合に“0”にリセットされる。
The write pointer 23 is incremented after the branch result obtained from the instruction execution unit 200 is stored in the bit position indicated by the write pointer 23, and the read pointer 22 is read from the read pointer 22 of the history bit stream 21 for branch prediction. It is incremented after the branch result stored at the indicated bit position is referred to. However, when the comparator 24 detects that the value of the read pointer 22 is equal to or larger than the value of the write pointer 23, the read pointer 22 is not incremented. When the operation state of the status register 25 is "S"
When the value changes from "0" to "S1", it is reset to 0. The read pointer 22 is stored in the loop address register 19.
Is reset to "0" when it is detected that the branch address generated by the decoder 14 is equal to the branch address.

【0052】履歴ビットストリーム21は状態レジスタ
25が“S1”のとき、解読器14で前方分岐命令が検
出されると、ライトポインタ23の値が示すビット位置
に命令実行部200が出力する分岐判定結果を書き込
む。その後、ライトポインタ23はインクリメントされ
る。これを繰り返すことで、前方分岐命令の結果が履歴
ビットストリーム21のビット位置0(最も左のビッ
ト)から順次書き込まれることになる。状態レジスタ2
5が“S2”のとき、先行解読器10で次に実行される
命令が前方分岐命令であることが検出されると、リード
ポインタ22の値が示すビット位置の分岐結果を参照
し、分岐予測に用いる。例えば、前回の分岐が成立して
いる場合は今回も成立する、あるいは、前回が不成立の
場合は今回も不成立と予測することができる。ただし、
リードポインタ22の値がライトポインタ23の値と等
しいか大きいことが比較器24で検出された場合は予測
は行われない。これはライトポインタ23の値より大き
い値のビット位置には有効な履歴が格納されていないた
めである。
When the decoder 14 detects a forward branch instruction when the status register 25 is "S1", the branch bit output from the instruction execution unit 200 is output to the bit position indicated by the value of the write pointer 23. Write the result. Thereafter, the write pointer 23 is incremented. By repeating this, the result of the forward branch instruction is sequentially written from bit position 0 (leftmost bit) of the history bit stream 21. Status register 2
When 5 is "S2", when the preceding decoder 10 detects that the next instruction to be executed is a forward branch instruction, the preceding decoder 10 refers to the branch result at the bit position indicated by the value of the read pointer 22, and performs branch prediction. Used for For example, if the previous branch has been taken, it can be predicted that the current branch will be taken, or if the previous branch has not been taken, it can be predicted that this branch will not be taken again. However,
If the comparator 24 detects that the value of the read pointer 22 is equal to or larger than the value of the write pointer 23, no prediction is performed. This is because a valid history is not stored in a bit position having a value larger than the value of the write pointer 23.

【0053】図5に、ループ先頭アドレスと、ループの
先頭から1つめ、2つめ、3つめ、4つめの分岐命令の
結果情報を図8と同様に概念的に示している。以上のよ
うに各部分は動作する。以下、図3に示すタイムチャー
トと図4に示すプログラム例を用いて全体の動作の流れ
を説明する。
FIG. 5 conceptually shows the loop start address and the result information of the first, second, third, and fourth branch instructions from the top of the loop, similarly to FIG. Each part operates as described above. Hereinafter, the flow of the entire operation will be described using a time chart shown in FIG. 3 and a program example shown in FIG.

【0054】図4は命令メモリ1に格納されているプロ
グラムである。図3は図4のプログラムをアドレス0か
ら順次実行したときのタイムチャートであり、サイクル
C0〜C19毎に各信号の値を示している。図4におい
て、“beq TA”は条件付き分岐命令であり、TA
は分岐先アドレスである。“inst0”、“inst
2”、“inst4”、“inst20”は分岐命令以
外の命令であり命令実行部200により実行される。図
4のプログラムはループ構造をなしており、ループ内部
に3つの分岐命令、すなわちbeq命令を持つ。アドレ
ス1の分岐命令は前方分岐で分岐不成立、アドレス3の
分岐命令は前方分岐で分岐成立、アドレス21の分岐命
令は後方分岐で分岐成立である場合を例示している。
FIG. 4 shows a program stored in the instruction memory 1. FIG. 3 is a time chart when the program of FIG. 4 is sequentially executed from address 0, and shows the value of each signal in each of the cycles C0 to C19. In FIG. 4, "beq TA" is a conditional branch instruction, and TA
Is a branch destination address. “Inst0”, “inst
"2", "inst4", and "inst20" are instructions other than branch instructions and are executed by the instruction execution unit 200. The program in FIG. In this example, the branch instruction at address 1 is a branch not taken at a forward branch, the branch instruction at address 3 is a branch taken at a front branch, and the branch instruction at address 21 is a branch taken at a backward branch.

【0055】ここで、本実施の形態では後方分岐の分岐
予測は静的分岐予測により行われるとしており、常に分
岐成立すると予測する。本発明の分岐予測は前方分岐命
令のみに作用するとしている。図3にしたがって動作を
説明する。説明の簡単化のため、図3のサイクルC0は
図4のプログラムのループ処理の1回目の処理の最後の
サイクルであり、サイクルC1は2回目の処理の最初の
サイクルであるとしている。すなわち、サイクルC0で
はループの最後で分岐命令が実行されると同時に先行解
読により得られたループの先頭アドレスがプリフェッチ
カウンタ2に格納されている。
Here, in the present embodiment, the branch prediction of the backward branch is performed by the static branch prediction, and it is predicted that the branch is always taken. It is stated that the branch prediction of the present invention operates only on the forward branch instruction. The operation will be described with reference to FIG. For simplicity of description, it is assumed that cycle C0 in FIG. 3 is the last cycle of the first processing of the loop processing of the program in FIG. 4, and cycle C1 is the first cycle of the second processing. That is, in the cycle C0, the branch instruction is executed at the end of the loop, and at the same time, the leading address of the loop obtained by the preceding decoding is stored in the prefetch counter 2.

【0056】サイクルC0:命令レジスタ13にはルー
プの最後のすなわちアドレス21の命令“beq0”が
格納されており、解読器14は後方分岐命令であること
を示す信号と分岐先アドレスを生成する。プリフェッチ
カウンタ2は分岐先であるアドレス0になっており、命
令メモリ1からアドレス0に対応する命令群を読み出し
ている。この命令群は、アドレス0〜3の命令を含む。
以下命令群0〜3のように省略する。
Cycle C0: The instruction register 13 stores the last instruction of the loop, ie, the instruction "beq0" at address 21, and the decoder 14 generates a signal indicating a backward branch instruction and a branch destination address. The prefetch counter 2 is at address 0, which is a branch destination, and reads an instruction group corresponding to address 0 from the instruction memory 1. This instruction group includes instructions at addresses 0 to 3.
Hereinafter, the description is abbreviated as in instruction groups 0 to 3.

【0057】サイクルC1:解読器14の後方分岐命令
検出および命令実行部200の分岐判定結果が分岐成立
であることにより、状態レジスタ25が“S1”にな
る。これにより、ループアドレスレジスタ19は分岐先
アドレスが格納され、ライトポインタ23は“0”にリ
セットされる。また、命令メモリ1から読み出した命令
群0〜3は命令バッファ6に格納され、そのうちアドレ
ス0に対応する命令(以下、命令0のように省略する)
“inst0”が命令レジスタ13に格納されると同時
に命令実行部200に送られる。プリフェッチカウンタ
2の値はインクリメンタ3により“4”が加算された
後、マルチプレクサ5,4を経てプリフェッチカウンタ
2に格納される。先行解読器10では実行中の命令の次
に実行される命令1、すなわちアドレス1の命令を先行
的に解読し、分岐命令かどうかを判定する。ここでは前
方分岐命令であることが判明するが、状態レジスタ25
が“S1”になっているので分岐予測は行わない。これ
は、分岐は不成立であると予測することと同じ動作にな
る。この場合、先行解読した情報は無視される。
Cycle C1: The state register 25 is set to "S1" because the backward branch instruction detection of the decoder 14 and the branch determination result of the instruction execution unit 200 indicate that the branch is taken. As a result, the branch address is stored in the loop address register 19, and the write pointer 23 is reset to "0". The instruction groups 0 to 3 read from the instruction memory 1 are stored in the instruction buffer 6, and the instruction corresponding to the address 0 (hereinafter, abbreviated as the instruction 0).
“Inst0” is stored in the instruction register 13 and sent to the instruction execution unit 200 at the same time. After the value of the prefetch counter 2 is added with “4” by the incrementer 3, the value is stored in the prefetch counter 2 via the multiplexers 5 and 4. The preceding decoder 10 decodes the instruction 1 to be executed next to the instruction being executed, that is, the instruction at address 1 in advance, and determines whether the instruction is a branch instruction. Here, it is determined that the instruction is a forward branch instruction.
Is "S1", no branch prediction is performed. This is the same operation as predicting that a branch is not taken. In this case, the information decoded earlier is ignored.

【0058】サイクルC2:命令レジスタ13に命令1
すなわち、“beq 10”が格納され、解読器14で
分岐命令の判定が行われる。命令1はアドレス10への
分岐命令すなわち、前方分岐命令であるので、解読器1
4は分岐先アドレス10を出力する。命令1は命令実行
部200にも転送され、命令実行部200は分岐判定結
果を出力する。この場合、命令実行部200は分岐不成
立を出力する。
Cycle C2: Instruction 1 in instruction register 13
That is, “beq 10” is stored, and the decoder 14 determines a branch instruction. Since instruction 1 is a branch instruction to address 10, that is, a forward branch instruction,
4 outputs the branch destination address 10. The instruction 1 is also transferred to the instruction execution unit 200, and the instruction execution unit 200 outputs a branch determination result. In this case, the instruction execution unit 200 outputs a branch not taken.

【0059】サイクルC3:状態レジスタ25が“S
1”であるので、命令実行部200の出力した分岐判定
結果は履歴ビットストリーム21のライトポインタ23
が指し示すビット位置に書き込まれる。ここでは、ライ
トポインタ23は“0”なのでビット0の位置、つまり
最も左の位置に分岐不成立であることを示す“0”が書
き込まれる。xは不定値を表している。その後、ライト
ポインタ23の値はインクリメントされ“1”になる。
Cycle C3: The status register 25 sets "S
1 ”, the branch determination result output from the instruction execution unit 200 is the write pointer 23 of the history bit stream 21.
Is written to the bit position indicated by. Here, since the write pointer 23 is “0”, “0” indicating that the branch is not taken is written in the position of bit 0, that is, the leftmost position. x represents an indefinite value. Thereafter, the value of the write pointer 23 is incremented to "1".

【0060】命令レジスタ13には命令2すなわち、
“inst2”が格納され、命令実行部200にも転送
される。先行解読器10では次の命令を先行的に解読
し、分岐命令かどうかを判定する。ここでは前方分岐命
令であることが判明するが、状態レジスタ25が“S
1”になっているので分岐予測は行わない。これは、分
岐は不成立であると予測することと同じ動作になる。こ
の場合、先行解読した情報は無視される。
The instruction register 13 stores the instruction 2, ie,
“Inst2” is stored and transferred to the instruction execution unit 200. The preceding decoder 10 decodes the next instruction in advance and determines whether or not the instruction is a branch instruction. Here, it is determined that the instruction is a forward branch instruction.
Since it is 1 ", branch prediction is not performed. This is the same operation as predicting that a branch is not taken. In this case, information decoded in advance is ignored.

【0061】サイクルC4:命令レジスタ13に命令3
すなわち、“beq 20”が格納され、解読器14で
分岐命令の判定が行われる。命令3はアドレス20への
分岐命令すなわち、前方分岐命令であるので、解読器1
4は分岐先アドレス20を出力する。命令3は命令実行
部200にも転送され、命令実行部200は分岐判定結
果を出力する。この場合、命令実行部200は分岐成立
を出力する。
Cycle C4: Instruction 3 in instruction register 13
That is, “beq 20” is stored, and the decoder 14 determines the branch instruction. Since instruction 3 is a branch instruction to address 20, that is, a forward branch instruction,
4 outputs the branch destination address 20. The instruction 3 is also transferred to the instruction execution unit 200, and the instruction execution unit 200 outputs a branch determination result. In this case, the instruction execution unit 200 outputs a branch taken.

【0062】サイクルC5:状態レジスタ25が“S
1”であるので、分岐判定結果は履歴ビットストリーム
21のライトポインタ23が指し示すビット位置に書き
込まれる。ここでは、ライトポインタ23の値は“1”
なのでビット1の位置、すなわち左から2番目の位置に
分岐成立であることを示す“1”が書き込まれる。その
後、ライトポインタ23の値はインクリメントされ
“2”になる。
Cycle C5: The status register 25 sets "S
Since it is "1", the branch determination result is written into the bit position indicated by the write pointer 23 of the history bit stream 21. Here, the value of the write pointer 23 is "1".
Therefore, "1" indicating that the branch is taken is written at the position of bit 1, that is, the second position from the left. Thereafter, the value of the write pointer 23 is incremented to “2”.

【0063】サイクルC4で分岐成立しているが、分岐
先の命令の命令メモリ1からの読み出しが完了していな
いので、このサイクルはどの命令も実行していない。プ
リフェッチカウンタ2はマルチプレクサ5で選択された
分岐先アドレス20を格納しており、命令メモリ1から
の命令読み出しに用いている。サイクルC5はアドレス
3の前方分岐命令の分岐成立により生じたペナルティサ
イクルである。前方分岐命令で分岐不成立の場合はプリ
フェッチした後続の命令が有効なのでペナルティは発生
しないが、分岐成立の場合は後続の命令が無効であり、
分岐先アドレスを用いて有効な命令を命令メモリ1から
読み出すまで命令の実行ができない。このペナルティサ
イクルがプロセッサの性能を低下させる。
Although the branch is taken in cycle C4, no instruction has been executed in this cycle since the reading of the instruction at the branch destination from the instruction memory 1 has not been completed. The prefetch counter 2 stores the branch destination address 20 selected by the multiplexer 5 and is used for reading an instruction from the instruction memory 1. Cycle C5 is a penalty cycle caused by the branch taken by the forward branch instruction at address 3. If the branch is not taken by the forward branch instruction, no penalty occurs because the prefetched subsequent instruction is valid, but if the branch is taken, the subsequent instruction is invalid,
The instruction cannot be executed until a valid instruction is read from the instruction memory 1 using the branch destination address. This penalty cycle degrades the performance of the processor.

【0064】サイクルC6:命令レジスタ13には命令
20が格納されている。先行解読器10では命令21を
解読し、後方分岐命令であることが判明する。後方分岐
命令の場合は、ハードウェアで固定的に分岐すると予測
している。そのため、先行解読器10は分岐先アドレス
であるアドレス0を出力し、マルチプレクサ4を経てプ
リフェッチカウンタ2に送られる。
Cycle C6: The instruction 20 stores the instruction 20 in the instruction register 13. The leading decoder 10 decodes the instruction 21 and finds that it is a backward branch instruction. In the case of a backward branch instruction, it is predicted that the branch will be fixedly performed by hardware. Therefore, the preceding decoder 10 outputs the address 0, which is the branch destination address, and sends it to the prefetch counter 2 via the multiplexer 4.

【0065】サイクルC7:プリフェッチカウンタ2に
アドレス0が格納されるとともに、命令レジスタ13に
アドレス21の命令が格納され実行される。解読器14
で後方分岐命令であることが検出されると、分岐先アド
レスとループアドレスレジスタ19の値とが比較器20
で比較される。比較の結果、両者が一致すれば、前回と
同じループが実行されると判断する。その場合、状態レ
ジスタ25を“S2”にし、リードポインタ22を
“0”にする。命令実行部200からは分岐判定結果と
して分岐成立が出力され分岐が実行される。
Cycle C7: The address 0 is stored in the prefetch counter 2 and the instruction at the address 21 is stored in the instruction register 13 and executed. Decryptor 14
, The branch destination address and the value of the loop address register 19 are compared with each other by the comparator 20.
Are compared. As a result of the comparison, if they match, it is determined that the same loop as the previous time is executed. In that case, the status register 25 is set to “S2” and the read pointer 22 is set to “0”. The branch execution is output from the instruction execution unit 200 as a branch determination result, and the branch is executed.

【0066】サイクルC8:プログラムカウンタ15に
はサイクルC7で得られた分岐先アドレス0が格納され
る。一方、命令レジスタ13にはサイクルC7で命令メ
モリ1から読み出した命令0が格納される。ここで、分
岐命令のペナルティサイクルが生じていないのは後方分
岐命令の分岐予測によるものである。
Cycle C8: The branch destination address 0 obtained in cycle C7 is stored in the program counter 15. On the other hand, the instruction register 13 stores the instruction 0 read from the instruction memory 1 in cycle C7. Here, the penalty cycle of the branch instruction does not occur because of the branch prediction of the backward branch instruction.

【0067】状態レジスタ25が“S2”であるので、
先行解読器10は次の命令である命令1を先行解読す
る。先行解読の結果、“beq 10”すなわち前方分
岐命令であることが判明するので履歴ビットストリーム
21のリードポインタ22の値のビット位置の値を参照
し“0”の場合は分岐不成立、“1”の場合は分岐成立
であると予測する。この場合、リードポインタ22の値
は“0”なので、ビット0すなわち、最も左のビットを
参照する。最も左のビットの値は“0”であるので分岐
不成立と予測する。分岐予測が分岐不成立の場合は分岐
命令が無かった場合と同様の動作をすることになる。リ
ードポインタ22はインクリメントされ“1”になる。
Since the status register 25 is "S2",
The pre-decoder 10 pre-decodes the next instruction, instruction 1. As a result of the preceding decoding, it is found that the instruction is "beq 10", that is, a forward branch instruction. Therefore, the value of the bit position of the value of the read pointer 22 of the history bit stream 21 is referred to. In the case of, it is predicted that the branch is taken. In this case, since the value of the read pointer 22 is “0”, bit 0, that is, the leftmost bit is referred to. Since the value of the leftmost bit is “0”, it is predicted that the branch is not taken. When the branch prediction is not taken, the same operation as when there is no branch instruction is performed. The read pointer 22 is incremented to "1".

【0068】サイクルC9:命令レジスタ13に命令
1、すなわち“beq 10”が格納され、解読器14
で分岐命令の判定が行われる。命令1はアドレス10へ
の分岐命令すなわち、前方分岐命令であるので、解読器
14は分岐先アドレス10を出力する。命令1は命令実
行部200にも転送され、命令実行部200は分岐判定
結果を出力する。この場合不成立が出力される。
Cycle C 9: Instruction 1, that is, “beq 10” is stored in the instruction register 13,
Is used to determine the branch instruction. Since the instruction 1 is a branch instruction to the address 10, that is, a forward branch instruction, the decoder 14 outputs the branch destination address 10. The instruction 1 is also transferred to the instruction execution unit 200, and the instruction execution unit 200 outputs a branch determination result. In this case, the failure is output.

【0069】サイクルC10:命令レジスタ13には命
令2すなわち、“inst2”が格納され、命令実行部
200にも転送される。先行解読器10では命令3を先
行的に解読し、分岐命令かどうかを判定する。ここでは
前方分岐命令すなわち、“beq 20”であることが
判明し、状態レジスタ25が“S2”になっているので
分岐予測が行われる。すなわち、履歴ビットストリーム
21のリードポインタ22の値のビット位置の値を参照
する。この場合、リードポインタ22の値は“1”なの
で、ビット1すなわち、左から2番目のビットを参照す
る。参照した値は“1”なので分岐成立と予測する。こ
れによりプリフェッチカウンタ2は先行解読器10の出
力する分岐先アドレス、つまりアドレス20を格納す
る。リードポインタ22はインクリメントされ“2”に
なる。
Cycle C 10: The instruction 2, ie, “inst 2”, is stored in the instruction register 13 and transferred to the instruction execution unit 200. The pre-decoder 10 pre-decodes the instruction 3 and determines whether it is a branch instruction. Here, it is determined that the instruction is a forward branch instruction, that is, “beq 20”, and since the status register 25 is “S2”, branch prediction is performed. That is, the value of the bit position of the value of the read pointer 22 of the history bit stream 21 is referred to. In this case, since the value of the read pointer 22 is “1”, bit 1, that is, the second bit from the left is referred to. Since the value referred to is "1", it is predicted that the branch is taken. Thus, the prefetch counter 2 stores the branch destination address output by the preceding decoder 10, that is, the address 20. The read pointer 22 is incremented to “2”.

【0070】サイクルC11:命令レジスタ13には命
令3すなわち、“beq 20”が格納され、解読器1
4で分岐命令のは分岐先アドレス20を出力する。命令
1は命令実行部200にも送られ、命令実行部200は
分岐判定結果を出力する。この場合、分岐成立が出力さ
れる。
Cycle C11: The instruction register 13 stores the instruction 3, ie, “beq 20”,
At step 4, the branch destination address 20 of the branch instruction is output. The instruction 1 is also sent to the instruction execution unit 200, and the instruction execution unit 200 outputs a branch determination result. In this case, a branch taken is output.

【0071】サイクルC12:このサイクルでは、サイ
クルC11の前方分岐命令で分岐成立であるのでペナル
ティが生じるはずであるが、サイクルC11で本発明の
分岐予測を行っているためペナルティは生じない。プロ
グラムカウンタ15にアドレス20が格納され、命令レ
ジスタ13にアドレス20の命令が格納される。アドレ
ス20の命令群20〜23はサイクルC10で分岐成立
と予測され、サイクルC11で命令メモリ1から先行的
に読み出されたものである。命令バッファ6には命令群
20〜23が格納され、先行解読器10はアドレス21
の命令を先行的に解読することができ、解読により後方
分岐命令であることが判明する。後方分岐の場合は常に
分岐成立すると予測されるため、プリフェッチカウンタ
2は先行解読器10の出力する分岐先アドレス、すなわ
ちアドレス0を格納する。
Cycle C12: In this cycle, a penalty should occur because the branch is taken by the forward branch instruction of cycle C11. However, no penalty occurs because the branch prediction of the present invention is performed in cycle C11. The address 20 is stored in the program counter 15, and the instruction at the address 20 is stored in the instruction register 13. The instruction groups 20 to 23 at the address 20 are predicted to be taken in the cycle C10, and are read from the instruction memory 1 in advance in the cycle C11. The instruction buffer 6 stores instruction groups 20 to 23, and the preceding decoder 10
Can be decoded in advance, and the decoding indicates that it is a backward branch instruction. In the case of a backward branch, the branch is always predicted to be taken. Therefore, the prefetch counter 2 stores the branch destination address output from the preceding decoder 10, that is, the address 0.

【0072】サイクルC13:プリフェッチカウンタ2
にアドレス0が格納されるとともに、命令レジスタ13
にアドレス21の命令が格納され実行される。解読器1
4で後方分岐命令であるとが検出されると、分岐先アド
レスとループアドレスレジスタ19の値とが比較器20
で比較され、両者が一致することで、前回と同じループ
が実行されることを確認する。この場合、状態レジスタ
25を“S2”にし、リードポインタ22を“0”にす
る。命令実行部200から分岐判定結果として分岐成立
が出力され、分岐を実行する。
Cycle C13: Prefetch counter 2
And the instruction register 13
The instruction at the address 21 is stored and executed. Decryptor 1
4, when it is detected that the instruction is a backward branch instruction, the branch destination address and the value of the loop address register 19 are compared with each other by the comparator 20.
And confirm that the same loop is executed by matching the two. In this case, the status register 25 is set to “S2”, and the read pointer 22 is set to “0”. The branch execution is output from the instruction execution unit 200 as a branch determination result, and the branch is executed.

【0073】サイクルC14以降はサイクルC8〜サイ
クルC13をループが終了するまで繰り返す。上記にお
いて、状態レジスタ25の状態が“S1”のとき、つま
りサイクルC1〜C7において、分岐命令の成立・不成
立を示す分岐結果を起点からの相対位置に対応して履歴
情報として記録する第1のステップが実行されることに
なる。また、状態レジスタ25の状態が“S2”のと
き、つまり各サイクルC8以降において、次回の分岐命
令の実行前の先行解読時に起点からの先行解読命令の相
対位置を基に前記履歴情報を参照して前記次回の分岐命
令の分岐結果を予測する第2のステップが実行されるこ
とになる。そして、上記第1のステップを実行するのが
第1の手段であり、第2のステップを実行するのが第2
の手段である。
After the cycle C14, the cycles C8 to C13 are repeated until the loop ends. In the above, the state register 25 state of "S1", in other words the cycle C1 to C7, met-branch instruction FuNaru
A first step of recording the branching result indicating standing as history information corresponding to the relative position from the starting point is executed. Further, when the state of the state register 25 is "S2", that is, in each cycle C8 and thereafter, the history information is referred to based on the relative position of the preceding decoded instruction from the starting point at the time of preceding decoding before execution of the next branch instruction. Thus, the second step of predicting the branch result of the next branch instruction is executed. The first means executes the first step, and the second means executes the second step.
Means.

【0074】なお、以上は分岐予測が当たった場合の動
作を示しているが、実際には予測が外れることもある。
以下に分岐予測が外れた場合の動作を説明する。 (1)分岐予測が不成立で分岐が成立した場合 分岐予測が分岐不成立の場合は先行解読器10が分岐命
令を検出しなかった場合と同様の動作であるので先行的
に命令メモリ1から命令を読み出す動作などを行わな
い。その後、命令実行部200で分岐成立であることが
判明すると、そこから命令メモリ1の読み出しを行う。
その場合1サイクルのペナルティが生じることになる。 (2)分岐予測が成立で分岐が不成立した場合 分岐予測が分岐成立の場合は先行解読器10が出力する
分岐先アドレスがプリフェッチカウンタ2に格納され、
先行的に命令メモリ1から命令が読み出される。その
後、命令実行部200で分岐不成立であることが判明す
ると、プログラムカウンタ15に格納された現在の命令
(分岐命令)の次のアドレス(インクリメンタ16の出
力)がマルチプレクサ5,4を経てプリフェッチカウン
タ2に格納され、命令メモリ1から分岐命令の後続の命
令が読み出される。その場合、1サイクルのペナルティ
が生じることになる。
Although the operation in the case where the branch prediction is successful has been described above, the prediction may actually be incorrect.
The operation when the branch prediction is incorrect will be described below. (1) In the case where the branch prediction is not taken and the branch is taken When the branch prediction is not taken, the operation is the same as the case where the preceding decoder 10 does not detect the branch instruction. Does not perform read operation. Thereafter, when the instruction execution unit 200 determines that the branch has been taken, the instruction memory 1 is read therefrom.
In that case, a one-cycle penalty will occur. (2) When the branch prediction is taken and the branch is not taken When the branch prediction is taken, the branch destination address output by the preceding decoder 10 is stored in the prefetch counter 2,
An instruction is read from the instruction memory 1 in advance. Thereafter, when the instruction execution unit 200 determines that the branch is not taken, the next address (output of the incrementer 16) of the current instruction (branch instruction) stored in the program counter 15 passes through the multiplexers 5 and 4 to the prefetch counter. 2 and the instruction following the branch instruction is read from the instruction memory 1. In that case, a one-cycle penalty will occur.

【0075】また、後方分岐の検出後、分岐が不成立
(ループの終了)となった場合は、状態レジスタ25を
“S0”にする。さらに、後方分岐命令の実行時、比較
器20で分岐先アドレスとループアドレスレジスタ19
とが比較され、不一致の場合は、状態レジスタ25を
“S1”にする。これはループ中に異なるループを検出
した場合の動作である。このような場合のために、複数
のループアドレスレジスタ19、履歴ビットストリーム
59、リードポインタ22、ライトポインタ23、比較
器20、比較器24のセットを設け、分岐先アドレスと
一致するループアドレスレジスタ19と同一セットの履
歴ビットストリーム59、リードポインタ22、ライト
ポインタ23、比較器20、比較器24を用いて各ルー
プに対応した分岐予測を行うようにすると、本発明にお
ける予測的中率を上げることができる。
If the branch is not taken (end of the loop) after the detection of the backward branch, the status register 25 is set to "S0". Further, when the backward branch instruction is executed, the branch destination address and the loop address register 19 are stored in the comparator 20.
Are compared, and if they do not match, the status register 25 is set to “S1”. This is an operation when a different loop is detected during a loop. For such a case, a set of a plurality of loop address registers 19, a history bit stream 59, a read pointer 22, a write pointer 23, a comparator 20, and a comparator 24 is provided, and a loop address register 19 corresponding to a branch destination address is provided. When the branch prediction corresponding to each loop is performed by using the history bit stream 59, the read pointer 22, the write pointer 23, the comparator 20, and the comparator 24 of the same set, the prediction accuracy rate in the present invention is increased. Can be.

【0076】以上のように、本発明の実施の形態によれ
ば、分岐命令の成立・不成立を示す分岐結果をループ先
頭アドレスからの実行した分岐命令数に対応して履歴情
報として記録し、次回の分岐命令の実行時に起点からの
先行解読した分岐命令数を基に履歴情報を参照して分岐
命令の分岐結果を予測するようにしているので、分岐予
測を行うために必要な分岐予測情報としてループ先頭ア
ドレスと履歴ビットストリームだけで複数の分岐命令の
分岐結果を予測でき、分岐命令毎に絶対的なアドレスお
よび履歴情報を保持する従来例の場合の情報量に比べ
て、ループ先頭アドレスと履歴ビットストリームを保持
する場合の情報量が少ないため、分岐予測情報を保持す
るメモリ容量を従来より少なくすることができる。ま
た、従来のように分岐命令毎にそのアドレスを保持し、
分岐命令が現れるたびに対応する分岐命令を検索する必
要がないため検索回路が不要であり、回路規模を小さく
できる。また、低消費電力化にもつながる。
As described above, according to the embodiment of the present invention, a branch result indicating whether a branch instruction has been taken or not has been recorded as history information corresponding to the number of executed branch instructions from the loop top address. At the time of execution of a branch instruction, the branch result is predicted by referring to the history information based on the number of previously decoded branch instructions from the starting point. The branch result of a plurality of branch instructions can be predicted only by the loop start address and the history bit stream. Since the amount of information for holding the bit stream is small, the memory capacity for holding the branch prediction information can be made smaller than before. Also, the address is held for each branch instruction as in the past,
Since there is no need to search for a corresponding branch instruction each time a branch instruction appears, a search circuit is not required, and the circuit scale can be reduced. It also leads to lower power consumption.

【0077】例えば、従来の分岐予測を行うプロセッサ
では、アドレスが32ビットと履歴ビットが1ビットと
を一つのエントリとして、512エントリあるいは10
24エントリの記憶素子が必要である。512エントリ
の場合、 (32+1)×512 すなわち、512の33倍のオーダーの記憶素子が必要
である。一方、本発明では、各履歴ビットに対応したア
ドレスは不要であるので、1エントリ当たり1ビットで
よい。ただし、起点アドレスを保持するための記憶素子
と、リードポインタおよびライトポインタを実現するた
めの記憶素子が必要である。アドレスが32ビットであ
り、リードポインタおよびライトポインタが512個の
履歴ビットを取り扱う場合、それぞれ9ビット必要であ
る。したがって、512エントリの場合、 (0+1)×512+(32+9+9) すなわち、高々512の2倍のオーダーの記憶素子で済
む。
For example, in a conventional processor that performs branch prediction, a 32-bit address and a 1-bit history bit form one entry as 512 entries or 10
24 storage elements are required. In the case of 512 entries, (32 + 1) × 512, that is, a storage element on the order of 33 times 512 is required. On the other hand, in the present invention, an address corresponding to each history bit is not required, so that one bit per entry is sufficient. However, a storage element for holding the starting address and a storage element for realizing the read pointer and the write pointer are required. When the address is 32 bits and the read pointer and the write pointer handle 512 history bits, each requires 9 bits. Therefore, in the case of 512 entries, (0 + 1) × 512 + (32 + 9 + 9), that is, a storage element of at most twice the order of 512 is sufficient.

【0078】また、検索回路においては、従来の分岐予
測を行うプロセッサでは、512個の32ビットアドレ
スの中から先行解読した分岐命令のアドレスと一致する
アドレスを高速に検索するため、32ビットの比較器が
512個必要になるが、本発明では、比較器20(32
ビット比較器)と比較器24(9ビット比較器)でよい
ため回路規模を大幅に低減できる。
In the search circuit, a conventional processor for performing branch prediction searches a 512-bit 32-bit address for an address that matches the address of a previously decoded branch instruction at high speed. Although 512 comparators are required, in the present invention, the comparator 20 (32
Since only the bit comparator) and the comparator 24 (9-bit comparator) are required, the circuit scale can be significantly reduced.

【0079】なお、本発明の実施の形態では、分岐結果
はループの最初の分岐結果を保持し、残りのループの分
岐予測に用いているが、毎回のループでの分岐の結果で
履歴を更新し、前回ループの分岐の結果で予測を行って
もよい。また、分岐結果の履歴情報を1ビットで表して
いるが、2ビット以上で構成し、同じ分岐命令について
の過去の2回以上の分岐の結果を用いて分岐予測を行う
ような履歴情報のもち方をしてもよい。つまり、複数の
履歴情報をもち、複数の履歴情報に基づいて分岐予測を
行うとしてもよい。この場合には、例えば過去2回とも
分岐成立であれば、今回も分岐成立すると予測し、過去
2回が分岐成立、分岐不成立となっている場合は交互に
成立と不成立を繰り返すものと考え、今回は分岐成立と
予測しても良い。
In the embodiment of the present invention, the branch result holds the first branch result of the loop and is used for branch prediction of the remaining loops, but the history is updated with the result of the branch in each loop. Alternatively, the prediction may be performed based on the result of the previous branch. Although the history information of the branch result is represented by one bit, the history information is composed of two bits or more, and the history information is such that the branch prediction is performed using the results of two or more past branches of the same branch instruction. May be better. That is, a plurality of pieces of history information may be used, and branch prediction may be performed based on the plurality of pieces of history information. In this case, for example, if the past two times are taken, the branch is predicted to be taken this time, and if the past two times are taken and the branch is not taken, it is considered that the taking and the taking are alternately repeated. This time, it may be predicted that the branch is taken.

【0080】また、分岐予測が外れた場合は、以降の分
岐予測を行わないようにしてもよいし、外れた場合のた
めに、別の履歴ビットストリームを持つことで精度向上
も可能である。また、本発明の実施の形態では、前方分
岐命令の個数を計数し、分岐命令数を索引に用いたが、
任意の命令の個数としても同様の効果が得られる。
Further, when the branch prediction is deviated, the subsequent branch prediction may not be performed, and in the case of deviated, the accuracy can be improved by having another history bit stream. In the embodiment of the present invention, the number of forward branch instructions is counted, and the number of branch instructions is used as an index.
The same effect can be obtained with any number of instructions.

【0081】また、図6の概念図に示すようにループ先
頭アドレスからのアドレスの差分を保持し、アドレスの
差分を検索しても同様の効果を得ることができる。つま
り、アドレスの差分を保持する場合、例えば32ビット
アドレスのプログラムにおいて、ループの構成サイズを
最大255個とみなせば、差分(相対アドレス値)を保
持するためのビット数は8ビットでよく、絶対的なアド
レスを保持する場合の1/4で済むからである。この場
合、命令位置獲得手段が、実行のための解読した命令の
アドレスと起点位置保持手段により保持されたアドレス
との差分を得る手段からなり、これに対応して先行命令
位置獲得手段が、先行解読した命令のアドレスと起点位
置保持手段により保持されたアドレスとの差分を得る手
段からなる。
As shown in the conceptual diagram of FIG. 6, the same effect can be obtained by holding the address difference from the loop start address and searching for the address difference. In other words, when the difference between addresses is held, for example, in a 32-bit address program, if the configuration size of the loop is regarded as a maximum of 255, the number of bits for holding the difference (relative address value) may be 8 bits, and This is because only one-fourth of the case where a typical address is held is required. In this case, the instruction position obtaining means comprises means for obtaining a difference between the address of the decoded instruction for execution and the address held by the starting position holding means, and the preceding instruction position obtaining means accordingly A means for obtaining a difference between the address of the decoded instruction and the address held by the starting position holding means.

【0082】また、1つのパスだけでなく、複数のパス
を履歴として持つことで精度向上を図ることができる。
(木構造の履歴ビットストリーム)予測後、実行結果を
フィードバックしてさらに精度向上を図ることができ
る。ここで、木構造の履歴ビットストリームについて説
明する。ここでいうビットストリームとは、分岐の結果
の流れのことを表している。例えば、4ビットのストリ
ームで、○が分岐成立、×が分岐不成立であるとする
と、 ○ × ○ ○ というようになる。このストリームで予測を行うと、最
初が分岐成立、次が分岐不成立となる。このとき、も
し、最初の分岐が不成立であったとする。そうすると、
以降の分岐の履歴は信頼性がかなり低くなる。というの
は、分岐不成立であったために、命令の流れが変わり、
当てはまる分岐命令も異なるものとなるかも知れないか
らである。そこで、ビットストリームをつぎのように持
つことにする。 (1)が上記と同じ流れを示している。(2)は(1)
で最初の分岐命令の予測が外れた場合の代替ストリーム
を示している。以降、(3)、(4)はさらにそれぞれ
予測が外れた場合の代替ストリームを示している。この
構造のことが木構造である。
Further, not only one path but also a plurality of paths as histories can improve accuracy.
(History bit stream of tree structure) After prediction, the execution result can be fed back to further improve accuracy. Here, a history bit stream having a tree structure will be described. The bit stream referred to here indicates a flow resulting from the branch. For example, in a 4-bit stream, ○ indicates that the branch is taken and X indicates that the branch is not taken. When prediction is performed on this stream, the branch is taken first and the branch is not taken next. At this time, it is assumed that the first branch is not taken. Then,
The history of subsequent branches is much less reliable. Because the branch was not taken, the instruction flow changed,
The branch instructions that apply may also be different. Therefore, we have a bit stream as follows. (1) shows the same flow as above. (2) is (1)
2 shows an alternative stream when the prediction of the first branch instruction is incorrect. Hereinafter, (3) and (4) show alternative streams when prediction is further deviated, respectively. This structure is a tree structure.

【0083】また、分岐命令の個数を計数し、分岐命令
数を索引に用いたが、ループ先頭アドレスからのバイト
数としても同様の効果が得られる。また、上記の実施の
形態では、分岐命令数をカウントしていたが、実行する
全ての命令の数をカウントするようにし、その値を索引
として用いて、分岐命令に対応した位置にて分岐命令の
結果情報を記憶させるようにしてもよい。この場合、命
令位置獲得手段は、実行のため解読した命令を計数して
命令数を得る手段からなり、これに対応して先行命令位
置獲得手段が、先行解読した命令を計数して命令数を得
る手段からなる。
Although the number of branch instructions is counted and the number of branch instructions is used as an index, the same effect can be obtained by using the number of bytes from the loop start address. Further, in the above embodiment, the number of branch instructions is counted. However, the number of all instructions to be executed is counted, and the value is used as an index, and the branch instruction is located at a position corresponding to the branch instruction. May be stored. In this case, the instruction position obtaining means comprises means for counting the number of instructions decoded for execution to obtain the number of instructions. In response to this, the preceding instruction position obtaining means counts the number of instructions decoded before and counts the number of instructions. Means to obtain.

【0084】また、上記の実施の形態では、起点位置と
してループの先頭アドレスとしていたが、ループに限る
ものではない。例えば、プログラムを64バイトの大き
さを持つプログラムブロックに分割しプログラムブロッ
クの先頭アドレスを起点位置としてもよい。この場合、
起点位置保持手段は、プログラムブロックの先頭アドレ
スをを検出するブロック先頭アドレス検出手段と、ブロ
ック先頭アドレス検出手段で検出されたアドレスを保持
するブロック先頭アドレス保持手段とからなることとに
なる。
In the above embodiment, the starting point is the start address of the loop. However, the present invention is not limited to the loop. For example, the program may be divided into program blocks having a size of 64 bytes, and the start address of the program block may be used as the starting position. in this case,
The starting position holding means comprises a block head address detecting means for detecting a head address of a program block, and a block head address holding means for holding an address detected by the block head address detecting means.

【0085】以上で説明したプロセッサにおける分岐予
測装置で実施する分岐予測方法について、図7のフロー
チャートを用いて説明する。この分岐予測方法は、分岐
命令の成立・不成立を示す分岐結果を起点からの相対位
置に対応して履歴情報として記録する第1のステップ
と、次回の分岐命令の実行前の先行解読時に起点からの
先行解読命令の相対位置を基に履歴情報を参照して次回
の分岐命令の分岐結果を予測する第2のステップとを含
む。上記の第1のステップは、図3のタイムチャートに
おいて、状態レジスタ25の状態が“S1”のとき、す
なわちサイクルC1〜C7で実行される。また、第2の
ステップは、同図において、状態レジスタ25の状態が
“S2”のとき、すなわちサイクルC8以降で実行され
る。
A branch prediction method performed by the branch prediction device in the processor described above will be described with reference to the flowchart of FIG. This branch prediction method includes a first step of recording, as history information , a branch result indicating whether a branch instruction has been taken or not , corresponding to a relative position from the starting point, A second step of predicting the branch result of the next branch instruction by referring to the history information based on the relative position of the preceding decoding instruction. The first step is executed when the state of the state register 25 is “S1” in the time chart of FIG. 3, that is, in cycles C1 to C7. The second step is executed when the state of the state register 25 is “S2” in FIG.

【0086】この場合、上記の第1のステップは、図7
に示すように、起点の命令の位置を保持する起点位置保
持ステップST1と、命令を実行のために解読する実行
解読ステップST2と、起点位置保持ステップで保持し
た命令位置を基準として実行のために解読した命令の相
対位置を得る命令位置獲得ステップST3と、解読した
命令が分岐命令であった場合に、分岐命令の分岐結果を
履歴情報として分岐命令の相対位置に対応して記録する
履歴記録ステップST4とからなる。そして、上記起点
位置保持ステップST1を実行するのが起点位置保持手
段であり、実行解読ステップST2を実行するのが実行
解読手段であり、命令位置獲得ステップST3を実行す
るのが命令位置獲得手段であり、履歴記録ステップST
4を実行するのが履歴記録手段である。
In this case, the above-mentioned first step corresponds to FIG.
As shown in the figure, a start position holding step ST1 for holding the position of the start instruction, an execution decoding step ST2 for decoding the instruction for execution, and an execution position based on the instruction position held in the start position holding step. An instruction position obtaining step ST3 for obtaining a relative position of the decoded instruction; and a history recording step of recording the branch result of the branch instruction as history information corresponding to the relative position of the branch instruction when the decoded instruction is a branch instruction. ST4. The starting position holding step ST1 is executed by the starting position holding means, the execution decoding step ST2 is executed by the execution decoding means, and the instruction position obtaining step ST3 is executed by the instruction position obtaining means. Yes, history recording step ST
4 is executed by the history recording means.

【0087】また、第2のステップは、同図に示すよう
に、次回の命令の実行前に命令を先行解読する先行解読
ステップST5と、起点位置保持ステップで保持した命
令位置を基準として先行解読した命令の相対位置を得る
先行命令位置獲得ステップST6と、先行解読した命令
が分岐命令であった場合に、先行解読した分岐命令の相
対位置に対応した履歴情報を参照する履歴参照ステップ
ST7と、履歴情報を参照した結果を用いて先行解読し
た分岐命令の実行結果を予測する予測ステップST8と
からなる。そして、先行解読ステップST5を実行する
のが先行解読手段であり、先行命令位置獲得ステップS
T6を実行するのが先行命令位置獲得手段であり、履歴
参照ステップST7を実行するのが履歴参照手段であ
り、予測ステップST8を実行するのが分岐予測手段で
ある。
As shown in the figure, the second step is a preceding decoding step ST5 for precedingly decoding the instruction before the next execution of the instruction, and a preceding decoding step based on the instruction position held in the starting position holding step. A preceding instruction position obtaining step ST6 for obtaining a relative position of the decoded instruction; a history reference step ST7 for referring to history information corresponding to the relative position of the previously decoded branch instruction when the previously decoded instruction is a branch instruction; A prediction step ST8 for predicting the execution result of the previously decoded branch instruction using the result obtained by referring to the history information. The preceding decoding step ST5 is executed by the preceding decoding means, and the preceding instruction position acquiring step S5 is performed.
T6 is executed by the preceding instruction position obtaining means, the history reference step ST7 is executed by the history reference means, and the prediction step ST8 is executed by the branch prediction means.

【0088】また、上記の起点位置保持ステップST1
は、例えば実行しようとする起点の命令のアドレスを保
持するステップからなる。具体的に言えば、この起点位
置保持ステップST1は、例えばプログラムのループ構
造を検出するループ検出ステップと、ループ検出ステッ
プにより検出したプログラムのループ構造を基にループ
の先頭命令のアドレスを取り出し保持するステップとか
らなる。上記のループ検出ステップは、例えば後方に分
岐する分岐命令を解読することによりプログラムのルー
プ構造を検出するステップからなる。
Further, the starting position holding step ST1 described above.
Consists of, for example, a step of holding an address of an instruction of a starting point to be executed. More specifically, the starting position holding step ST1 extracts and holds the address of the first instruction of the loop based on, for example, a loop detection step for detecting the loop structure of the program and the loop structure of the program detected by the loop detection step. It consists of steps. The above-described loop detecting step includes a step of detecting a loop structure of a program by decoding a branch instruction that branches backward, for example.

【0089】上記の起点位置保持ステップST1は、他
に例えばプログラムブロックの先頭アドレスを検出する
ブロック先頭アドレス検出ステップと、ブロック先頭ア
ドレス検出ステップで検出されたアドレスを保持するブ
ロック先頭アドレス保持ステップとからなる場合もあ
る。上記の命令位置獲得ステップST3は、例えば実行
のため解読した命令を計数して命令数を得るステップか
らなり、これに対応して先行命令位置獲得ステップST
6が、先行解読した命令を計数して命令数を得るステッ
プからなる。
The starting position holding step ST1 includes, for example, a block head address detecting step for detecting the head address of the program block and a block head address holding step for holding the address detected in the block head address detecting step. In some cases. The instruction position obtaining step ST3 includes, for example, counting the number of instructions decoded for execution to obtain the number of instructions.
No. 6 comprises a step of counting instructions decoded earlier to obtain the number of instructions.

【0090】また、命令位置獲得ステップST3は、他
に例えば実行のための解読により分岐命令であることが
判明した命令を計数して命令数を得るステップからな
り、これに対応して先行命令位置獲得ステップST6
が、先行解読により分岐命令であることが判明した命令
を計数して命令数を得るステップからなる場合もある。
さらに、命令位置獲得ステップST3は、他に例えば実
行のための解読した命令のアドレスと起点位置保持ステ
ップにより保持されたアドレスとの差分を得るステップ
からなり、これに対応して先行命令位置獲得ステップS
T6が、先行解読した命令のアドレスと起点位置保持ス
テップにより保持されたアドレスとの差分を得るステッ
プからなる場合もある。
The instruction position obtaining step ST3 further comprises a step of counting the number of instructions which are determined to be branch instructions by decoding for execution to obtain the number of instructions. Acquisition step ST6
However, there may be a case where the number of instructions is obtained by counting instructions determined to be branch instructions by preceding decoding.
Further, the instruction position obtaining step ST3 further comprises a step of obtaining a difference between the address of the decoded instruction for execution and the address held by the starting position holding step, for example. S
In some cases, T6 includes a step of obtaining a difference between the address of the previously decoded instruction and the address held in the starting position holding step.

【0091】上記の履歴記録ステップST4は複数個の
履歴を記録するステップであってもよい。以上のような
分岐予測方法によると、分岐命令の成立・不成立を示す
分岐結果を起点からの相対位置に対応して履歴情報を記
録し、次回の分岐命令の実行時に起点からの先行解読命
令の相対位置を基に履歴情報を参照して分岐命令の分岐
結果を予測するようにしているので、分岐予測を行うた
めに必要な分岐予測情報として起点の情報と相対位置情
報と履歴情報だけで複数の分岐命令の分岐結果を予測で
き、分岐命令毎に絶対的なアドレスおよび履歴情報を保
持する従来例の場合の情報量に比べて、起点の情報と分
岐命令毎に相対位置情報および履歴情報を保持する場合
の情報量が少ないため、分岐予測情報を保持するメモリ
容量を従来より少なくすることができる。
The history recording step ST4 may be a step of recording a plurality of histories. According to the above-described branch prediction method, history information is recorded corresponding to the relative position from the start point , indicating whether the branch instruction is taken or not, and the next branch instruction is executed at the next execution of the branch instruction. Since the branch result of the branch instruction is predicted by referring to the history information based on the relative position of the preceding decoding instruction, the starting point information, the relative position information, and the history are used as the branch prediction information necessary for performing the branch prediction. The branch result of a plurality of branch instructions can be predicted using only the information, and the starting point information and the relative position information for each branch instruction are compared with the information amount of the conventional example in which the absolute address and the history information are retained for each branch instruction Further, since the amount of information when holding the history information is small, the memory capacity for holding the branch prediction information can be reduced as compared with the related art.

【0092】また、従来は分岐命令毎にそのアドレスを
保持し、分岐命令が現れるたびに対応する分岐命令を検
索する構成で、分岐命令のアドレスと保持されている全
てのアドレスとを比較するための複数の比較器を備えた
検索回路が必要であるが、本発明の分岐予測方法によれ
ば、相対位置情報(例えば、相対アドレス値)はアドレ
ス情報より情報量が少ないため、比較器の規模を小さく
でき、検索回路の回路規模を小さくできる。また、低消
費電力化にもつながる。
Conventionally, an address is held for each branch instruction, and a search is made for a corresponding branch instruction every time a branch instruction appears. In order to compare the address of a branch instruction with all the held addresses, However, according to the branch prediction method of the present invention, the relative position information (for example, relative address value) has a smaller amount of information than the address information. Can be reduced, and the circuit scale of the search circuit can be reduced. It also leads to lower power consumption.

【0093】[0093]

【発明の効果】本発明の分岐予測方法によれば、分岐命
令の成立・不成立を示す分岐結果を起点からの相対位置
に対応して履歴情報として記録し、次回の分岐命令の実
行時に起点からの先行解読命令の相対位置を基に履歴情
報を参照して分岐命令の分岐結果を予測するようにして
いるので、分岐予測を行うために必要な分岐予測情報と
して起点の情報と相対位置情報と履歴情報だけで複数の
分岐命令の分岐結果を予測でき、分岐命令毎に絶対的な
アドレスおよび履歴情報を保持する従来例の場合の情報
量に比べて、起点の情報と分岐命令毎に相対位置情報お
よび履歴情報を保持する場合の情報量が少ないため、分
岐予測情報を保持するメモリ容量を従来より少なくする
ことができる。
According to the branch prediction method of the present invention, a branch result indicating whether a branch instruction has been taken or not is recorded as history information corresponding to a relative position from the starting point, and the branch result is recorded from the starting point at the next execution of the branch instruction. The prediction result of the branch instruction is predicted by referring to the history information based on the relative position of the preceding decoding instruction of the starting instruction, so that the information of the starting point and the relative position information are used as the branch prediction information necessary for performing the branch prediction. The branch result of a plurality of branch instructions can be predicted using only the history information. Since the amount of information when storing information and history information is small, the memory capacity for storing branch prediction information can be reduced as compared with the related art.

【0094】また、従来は分岐命令毎にそのアドレスを
保持し、分岐命令が現れるたびに対応する分岐命令を検
索する構成で、分岐命令のアドレスと保持されている全
てのアドレスとを比較するための複数の比較器を備えた
検索回路が必要であるが、本発明の分岐予測方法によれ
ば、相対位置情報(例えば、相対アドレス値)はアドレ
ス情報より情報量が少ないため、比較器の規模を小さく
でき、検索回路の回路規模を小さくできる。また、低消
費電力化にもつながる。
Conventionally, the address is held for each branch instruction, and each time a branch instruction appears, the corresponding branch instruction is searched. In order to compare the address of the branch instruction with all the held addresses, However, according to the branch prediction method of the present invention, the relative position information (for example, relative address value) has a smaller amount of information than the address information. Can be reduced, and the circuit scale of the search circuit can be reduced. It also leads to lower power consumption.

【0095】本発明のプロセッサによれば、分岐命令の
成立・不成立を示す分岐結果を起点からの相対位置に対
応して履歴情報として記録し、次回の分岐命令の実行時
に起点からの先行解読命令の相対位置を基に履歴情報を
参照して分岐命令の分岐結果を予測する手段を有してい
るので、分岐予測を行うために必要な分岐予測情報とし
て起点の情報と相対位置情報と履歴情報だけで複数の分
岐命令の分岐結果を予測でき、分岐命令毎に絶対的なア
ドレスおよび履歴情報を保持する従来例の場合の情報量
に比べて、起点の情報と分岐命令毎に相対位置情報およ
び履歴情報を保持する場合の情報量が少ないため、分岐
予測情報を保持するメモリ容量を従来より少なくするこ
とができる。
According to the processor of the present invention, the branch instruction
The branch result indicating whether the branch was taken or not is recorded as history information corresponding to the relative position from the start point, and the next branch instruction is executed by referring to the history information based on the relative position of the preceding decoding instruction from the start point when the next branch instruction is executed. Means for predicting a branch result of a plurality of branch instructions, the branch result of a plurality of branch instructions can be predicted using only the information of the starting point, the relative position information, and the history information as the branch prediction information necessary for performing the branch prediction. Compared to the information amount in the conventional example in which the absolute address and the history information are stored for each instruction, the information amount in the case of holding the relative position information and the history information for each of the starting point information and the branch instruction is small, so that the branching is performed. The memory capacity for holding the prediction information can be made smaller than before.

【0096】また、従来は分岐命令毎にそのアドレスを
保持し、分岐命令が現れるたびに対応する分岐命令を検
索する手段を持つ構成で、分岐命令のアドレスと保持さ
れている全てのアドレスとを比較するための複数の比較
器を備えた検索回路が必要であるが、本発明のプロセッ
サによれば、相対位置情報(例えば、相対アドレス値)
はアドレス情報より情報量が少ないため、比較器の規模
を小さくでき、検索回路の回路規模を小さくできる。ま
た、低消費電力化にもつながる。
Conventionally, a configuration is provided in which the address is held for each branch instruction, and means for searching for the corresponding branch instruction each time the branch instruction appears is used. Although a search circuit having a plurality of comparators for comparison is required, according to the processor of the present invention, relative position information (for example, relative address value)
Since the information amount is smaller than the address information, the size of the comparator can be reduced, and the circuit size of the search circuit can be reduced. It also leads to lower power consumption.

【図面の簡単な説明】[Brief description of the drawings]

【図1】本発明の実施の形態におけるプロセッサの構成
を示すブロック図である。
FIG. 1 is a block diagram illustrating a configuration of a processor according to an embodiment of the present invention.

【図2】本発明の実施の形態におけるプロセッサの命令
供給部の構成を示すブロック図である。
FIG. 2 is a block diagram illustrating a configuration of an instruction supply unit of the processor according to the embodiment of the present invention.

【図3】本発明の実施の形態によるプロセッサの命令供
給部の動作を示すタイムチャートである。
FIG. 3 is a time chart illustrating an operation of an instruction supply unit of the processor according to the embodiment of the present invention.

【図4】本発明の実施の形態の動作説明用のプログラム
例を示す概略図である。
FIG. 4 is a schematic diagram showing an example of a program for explaining the operation of the embodiment of the present invention.

【図5】本発明の動的分岐予測の概念図である。FIG. 5 is a conceptual diagram of dynamic branch prediction according to the present invention.

【図6】本発明の動的分岐予測の概念図である。FIG. 6 is a conceptual diagram of dynamic branch prediction according to the present invention.

【図7】本発明の実施の形態の分岐予測方法を示すフロ
ーチャートである。
FIG. 7 is a flowchart showing a branch prediction method according to the embodiment of the present invention.

【図8】従来の動的分岐予測の概念図である。FIG. 8 is a conceptual diagram of conventional dynamic branch prediction.

【符号の説明】[Explanation of symbols]

100 命令供給部 101 命令 102 アドレス 200 命令実行部 201 分岐判定結果 1 命令メモリ 1A 命令群 2 プリフェッチカウンタ 3 インクリメンタ 4 マルチプレクサ 5 マルチプレクサ 6 命令バッファ 8 マルチプレクサ 9 マルチプレクサ 10 先行解読器 13 命令レジスタ 14 解読器 15 プログラムカウンタ 16 インクリメンタ 18 マルチプレクサ 19 ループアドレスレジスタ 20 比較器 21 履歴ビットストリーム 22 リードポインタ 23 ライトポインタ 24 比較器 25 状態レジスタ 26 制御回路 REFERENCE SIGNS LIST 100 instruction supply unit 101 instruction 102 address 200 instruction execution unit 201 branch determination result 1 instruction memory 1A instruction group 2 prefetch counter 3 incrementer 4 multiplexer 5 multiplexer 6 instruction buffer 8 multiplexer 9 multiplexer 10 predecoder 13 instruction register 14 decipherer 15 Program counter 16 incrementer 18 multiplexer 19 loop address register 20 comparator 21 history bit stream 22 read pointer 23 write pointer 24 comparator 25 status register 26 control circuit

フロントページの続き (56)参考文献 特開 平5−143334(JP,A) 特開 平1−142941(JP,A) 特開 平6−89173(JP,A) 特開 平3−147133(JP,A) 特開 平8−234980(JP,A) 原哲也、外3名”SIMP(単一命令 流/多重命令パイプライン)方式に基づ くスーパースカラ・プロセッサ「新風」 の命令供給機構”,情報処理学会研究報 告,Vol.90,No.7(90−ARC −80),80−7,平成2年(1990年)1 月25日,p.49−56 (58)調査した分野(Int.Cl.6,DB名) G06F 9/38 Continuation of the front page (56) References JP-A-5-143334 (JP, A) JP-A-1-142294 (JP, A) JP-A-6-89173 (JP, A) JP-A-3-147133 (JP) , A) JP-A-8-234980 (JP, A) Tetsuya Hara, 3 others "Instruction supply mechanism of super scalar processor" Shinkaze "based on SIMP (single instruction flow / multiple instruction pipeline) method" IPSJ Research Report, Vol. 90, No. 7 (90-ARC-80), 80-7, January 25, 1990, pp. 49-56 (58) (Int.Cl. 6 , DB name) G06F 9/38

Claims (12)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 分岐命令の成立・不成立を示す分岐結果
を起点からの相対位置に対応して履歴情報として記録す
る第1のステップと、次回の分岐命令の実行前の先行解
読時に起点からの先行解読命令の相対位置を基に前記履
歴情報を参照して前記次回の分岐命令の分岐結果を予測
する第2のステップとを含み 前記第1のステップが、起点の命令の位置を保持する起
点位置保持ステップと、命令を実行のために解読する実
行解読ステップと、前記起点位置保持ステップで保持し
た命令位置を基準として実行のために解読した命令の相
対位置を得る命令位置獲得ステップと、解読した命令が
分岐命令であった場合に、前記分岐命令の分岐結果を履
歴情報として前記分岐命令の前記相対位置に対応して記
録する履歴記録ステップとからなり、 前記第2のステップが、次回の命令の実行前に命令を先
行解読する先行解読ステップと、前記起点位置保持ステ
ップで保持した命令位置を基準として先行解読した命令
の相対位置を得る先行命令位置獲得ステップと、先行解
読した命令が分岐命令であった場合に、前記先行解読し
た分岐命令の相対位置に対応した前記履歴情報を参照す
る履歴参照ステップと、前記履歴情報を参照した結果を
用いて前記先行解読した分岐命令の実行結果を予測する
予測ステップとからなり、 前記起点位置保持ステップが、プログラムのループ構造
を検出するループ検出ステップと、前記ループ検出ステ
ップにより検出したプログラムのループ構造を基にルー
プの先頭命令のアドレスを取り出し保持するステップと
からなることを特徴とする 分岐予測方法。
A first step of recording as a history information a branch result indicating whether a branch instruction has been taken or not, corresponding to a relative position from the starting point; A second step of predicting a branch result of the next branch instruction by referring to the history information based on a relative position of the preceding decoding instruction , wherein the first step holds a position of an instruction at a starting point. Ki
A point holding step and the actual decoding of the instruction for execution.
Row deciphering step and the starting position holding step
Of instructions decoded for execution based on the instruction position
Instruction position acquisition step to obtain pair position and decoded instruction
If the instruction is a branch instruction, the result of the branch instruction is executed.
Recorded as history information corresponding to the relative position of the branch instruction.
And a history recording step of recording the instruction.
A preceding decoding step for line decoding, and the starting position holding step.
Instructions decoded earlier based on the instruction position held in the map
Preceding instruction position obtaining step for obtaining the relative position of
If the read instruction is a branch instruction,
Refer to the history information corresponding to the relative position of the
A history reference step, and a result obtained by referring to the history information.
To predict the execution result of the previously decoded branch instruction
A prediction step, wherein the starting position holding step is a loop structure of the program.
Detecting a loop, and detecting the loop.
Loop based on the loop structure of the program detected by
Extracting and holding the address of the first instruction of the loop
A branch prediction method characterized by comprising :
【請求項2】 前記ループ検出ステップは、後方に分岐
する分岐命令を解読することによりプログラムのループ
構造を検出するステップからなることを特徴とする請求
項1記載の分岐予測方法。
2. The loop detecting step branches backward.
Loop by decoding the branch instruction
Claims comprising the step of detecting a structure.
Item 2. The branch prediction method according to Item 1.
【請求項3】 分岐命令の成立・不成立を示す分岐結果
を起点からの相対位置に対応して履歴情報として記録す
る第1のステップと、次回の分岐命令の実行前の先行解
読時に起点からの先行解読命令の相対位置を基に前記履
歴情報を参照して前記次回の分岐命令の分岐結果を予測
する第2のステップとを含み、 前記第1のステップが、起点の命令の位置を保持する起
点位置保持ステップと 、命令を実行のために解読する実
行解読ステップと、前記起点位置保持ステップで保持し
た命令位置を基準として実行のために解読した命令の相
対位置を得る命令位置獲得ステップと、解読した命令が
分岐命令であった場合に、前記分岐命令の分岐結果を履
歴情報として前記分岐命令の前記相対位置に対応して記
録する履歴記録ステップとからなり、 前記第2のステップが、次回の命令の実行前に命令を先
行解読する先行解読ステップと、前記起点位置保持ステ
ップで保持した命令位置を基準として先行解読した命令
の相対位置を得る先行命令位置獲得ステップと、先行解
読した命令が分岐命令であった場合に、前記先行解読し
た分岐命令の相対位置に対応した前記履歴情報を参照す
る履歴参照ステップと、前記履歴情報を参照した結果を
用いて前記先行解読した分岐命令の実行結果を予測する
予測ステップとからなり、 前記起点位置保持ステップが、プログラムブロックの先
頭アドレスを検出するブロック先頭アドレス検出ステッ
プと、前記ブロック先頭アドレス検出ステップで検出さ
れたアドレスを保持するブロック先頭アドレス保持ステ
ップとからなることを特徴とする分岐予測方法。
3. A branch result indicating whether a branch instruction is taken or not taken.
Is recorded as history information corresponding to the relative position from the starting point.
First step and preceding solution before execution of next branch instruction
When reading, based on the relative position of the preceding decoding instruction from the starting point,
Predicts the branch result of the next branch instruction with reference to history information
A second step of holding the position of the instruction at the starting point.
A point holding step and the actual decoding of the instruction for execution.
Row deciphering step and the starting position holding step
Of instructions decoded for execution based on the instruction position
Instruction position acquisition step to obtain pair position and decoded instruction
If the instruction is a branch instruction, the result of the branch instruction is executed.
Recorded as history information corresponding to the relative position of the branch instruction.
And a history recording step of recording the instruction.
A preceding decoding step for line decoding, and the starting position holding step.
Instructions decoded earlier based on the instruction position held in the map
Preceding instruction position obtaining step for obtaining the relative position of
If the read instruction is a branch instruction,
Refer to the history information corresponding to the relative position of the
A history reference step, and a result obtained by referring to the history information.
To predict the execution result of the previously decoded branch instruction
A starting step , wherein the starting position holding step includes
Block start address detection step for detecting the start address
In the block start address detection step.
Block start address holding stage that holds the
And a branch prediction method.
【請求項4】 分岐命令の成立・不成立を示す分岐結果
を起点からの相対位置に対応して履歴情報として記録す
る第1のステップと、次回の分岐命令の実行前の先行解
読時に起点からの先行解読命令の相対位置を基に前記履
歴情報を参照して前記次回の分岐命令の分岐結果を予測
する第2のステップとを含み、 前記第1のステップが、起点の命令の位置を保持する起
点位置保持ステップと、命令を実行のために解読する実
行解読ステップと、前記起点位置保持ステップで保持し
た命令位置を基準として実行のために解読した命令の相
対位置を得る命令位置獲得ステップと、解読した命令が
分岐命令であった場合に、前記分岐命令の分岐結果を履
歴情報として前記分岐命令の前記相対位置に対応して記
録する履歴記録ステップとからなり、 前記第2のステップが、次回の命令の実行前に命令を先
行解読する先行解読ステップと、前記起点位置保持ステ
ップで保持した命令位置を基準として先行解読した命令
の相対位置を得る先行命令位置獲得ステップと、先行解
読した命令が分岐命令であった場合に、前記先行解読し
た分岐命令の相対位置に対応した前記履 歴情報を参照す
る履歴参照ステップと、前記履歴情報を参照した結果を
用いて前記先行解読した分岐命令の実行結果を予測する
予測ステップとからなり、 前記命令位置獲得ステップが、実行のため解読した命令
を計数して命令数を得るステップからなり、前記先行命
令位置獲得ステップが、先行解読した命令を計数して命
令数を得るステップからなることを特徴とする分岐予測
方法。
4. A branch result indicating whether a branch instruction is taken or not taken.
Is recorded as history information corresponding to the relative position from the starting point.
First step and preceding solution before execution of next branch instruction
When reading, based on the relative position of the preceding decoding instruction from the starting point,
Predicts the branch result of the next branch instruction with reference to history information
A second step of holding the position of the instruction at the starting point.
A point holding step and the actual decoding of the instruction for execution.
Row deciphering step and the starting position holding step
Of instructions decoded for execution based on the instruction position
Instruction position acquisition step to obtain pair position and decoded instruction
If the instruction is a branch instruction, the result of the branch instruction is executed.
Recorded as history information corresponding to the relative position of the branch instruction.
And a history recording step of recording the instruction.
A preceding decoding step for line decoding, and the starting position holding step.
Instructions decoded earlier based on the instruction position held in the map
Preceding instruction position obtaining step for obtaining the relative position of
If the read instruction is a branch instruction,
To refer to the history information corresponding to the relative position of the branch instruction
A history reference step, and a result obtained by referring to the history information.
To predict the execution result of the previously decoded branch instruction
A prediction step, wherein the instruction position obtaining step decodes the instruction for execution.
Counting the number of instructions to obtain the number of instructions.
The instruction position acquisition step counts instructions decoded earlier and issues instructions.
Branch prediction characterized by the step of obtaining an instruction number
Method.
【請求項5】 分岐命令の成立・不成立を示す分岐結果
を起点からの相対位置に対応して履歴情報として記録す
る第1のステップと、次回の分岐命令の実行前の先行解
読時に起点からの先行解読命令の相対位置を基に前記履
歴情報を参照して前記次回の分岐命令の分岐結果を予測
する第2のステップとを含み、 前記第1のステップが、起点の命令の位置を保持する起
点位置保持ステップと、命令を実行のために解読する実
行解読ステップと、前記起点位置保持ステップで保持し
た命令位置を基準として実行のために解読した命令の相
対位置を得る命令位置獲得ステップと、解読した命令が
分岐命令であった場合に、前記分岐命令の分岐結果を履
歴情報として前記分岐命令の前記相対位置に対応して記
録する履歴記録ステップとからなり、 前記第2のステップが、次回の命令の実行前に命令を先
行解読する先行解読ステップと、前記起点位置保持ステ
ップで保持した命令位置を基準として先行解読した命令
の相対位置を得る先行命令位置獲得ステップと、先行解
読した命令が分岐命令であった場合に、前記先行解読し
た分岐命令の相対位置に対応した前記履歴情報を参照す
る履歴参照ステップと、前記履歴情報を参照した結果を
用いて前記先行解読した分岐命令の実行結果を予測する
予測ステップとからなり、 前記命令位置獲得ステップが、実行のための解読により
分岐命令であることが判明した命令を計数して命令数を
得るステップからなり、前記先行命令位置獲得ステップ
が、先行解読により分岐命令であることが判明した命令
を計数して命令数を得るステップからなることを特徴と
する分岐予測方法。
5. A branch result indicating whether a branch instruction is taken or not taken.
Is recorded as history information corresponding to the relative position from the starting point.
First step and preceding solution before execution of next branch instruction
When reading, based on the relative position of the preceding decoding instruction from the starting point,
Predicts the branch result of the next branch instruction with reference to history information
A second step of holding the position of the instruction at the starting point.
A point holding step and the actual decoding of the instruction for execution.
Row deciphering step and the starting position holding step
Of instructions decoded for execution based on the instruction position
Instruction position acquisition step to obtain pair position and decoded instruction
If the instruction is a branch instruction, the result of the branch instruction is executed.
Recorded as history information corresponding to the relative position of the branch instruction.
And a history recording step of recording the instruction.
A preceding decoding step for line decoding, and the starting position holding step.
Instructions decoded earlier based on the instruction position held in the map
Preceding instruction position obtaining step for obtaining the relative position of
If the read instruction is a branch instruction,
Refer to the history information corresponding to the relative position of the
A history reference step, and a result obtained by referring to the history information.
To predict the execution result of the previously decoded branch instruction
A prediction step, wherein the instruction position acquisition step is performed by decoding for execution.
Count instructions found to be branch instructions and count
Obtaining the preceding instruction position.
Is an instruction that was found to be a branch instruction by preceding decoding
Counting the number of instructions to obtain the number of instructions.
Branch prediction method.
【請求項6】 分岐命令の成立・不成立を示す分岐結果
を起点からの相対位置に対応して履歴情報として記録す
る第1のステップと、次回の分岐命令の実行前の先行解
読時に起点からの先行解読命令の相対位置を基に前記履
歴情報を参照して前記次回の分岐命令の分岐結果を予測
する第2のステップとを含み、 前記第1のステップが、起点の命令の位置を保持する起
点位置保持ステップと、命令を実行のために解読する実
行解読ステップと、前記起点位置保持ステップで保持し
た命令位置を基準として実行のために解読した命令の相
対位置を得る命令位置獲得ステップと、解読した命令が
分岐命令であった場合に、前記分岐命令の分岐結果を履
歴情報として前記分岐命令の前記相対位置に対応して記
録する履歴記録ステップとからなり、 前記第2のステップが、次回の命令の実行前に命令を先
行解読する先行解読ステップと、前記起点位置保持ステ
ップで保持した命令位置を基準として先行解読した命令
の相対位置を得る先行命令位置獲得ステップと、先行解
読した命令が分岐命令であった場合に、前記先行解読し
た分岐命令の相対位置に対応した前記履歴情報を参照す
る履歴参照ステップと、前記履歴情報を参照した結果を
用いて前記先行解読した分岐命令の実行結果を予測する
予測ステップとからなり、 前記命令位置獲得ステップが、実行のための解読した命
令のアドレスと前記起点位置保持ステップにより保持さ
れたアドレスとの差分を得るステップからなり、前記先
行命令位置獲得ステップが、先行解読した命令のアドレ
スと前記起点位置保持ステップにより保持されたアドレ
スとの差分を得るステップからなることを特徴とする分
岐予測方法。
6. A branch result indicating whether a branch instruction is taken or not taken.
Is recorded as history information corresponding to the relative position from the starting point.
First step and preceding solution before execution of next branch instruction
When reading, based on the relative position of the preceding decoding instruction from the starting point,
Predicts the branch result of the next branch instruction with reference to history information
A second step of holding the position of the instruction at the starting point.
A point holding step and the actual decoding of the instruction for execution.
Row deciphering step and the starting position holding step
Of instructions decoded for execution based on the instruction position
Instruction position acquisition step to obtain pair position and decoded instruction
If the instruction is a branch instruction, the result of the branch instruction is executed.
Recorded as history information corresponding to the relative position of the branch instruction.
And a history recording step of recording the instruction.
A preceding decoding step for line decoding, and the starting position holding step.
Instructions decoded earlier based on the instruction position held in the map
Preceding instruction position obtaining step for obtaining the relative position of
If the read instruction is a branch instruction,
Refer to the history information corresponding to the relative position of the
A history reference step, and a result obtained by referring to the history information.
To predict the execution result of the previously decoded branch instruction
A predicting step, wherein the instruction position obtaining step includes the step of obtaining a decoded instruction for execution.
Command address and the starting position holding step.
Obtaining a difference from the specified address.
The line instruction position acquisition step determines the address of the previously decoded instruction.
Address and the address held in the starting position holding step.
A step of obtaining a difference from the
Forecasting method.
【請求項7】 分岐命令の成立・不成立を示す分岐結果
を起点からの相対位置に対応して履歴情報として記録す
る第1の手段と、次回の分岐命令の実行前の先行解読時
に起点からの先行解読命令の相対位置を基に前記履歴情
報を参照して前記次回の分岐命令の分岐結果を予測する
第2の手段とを備え、 前記第1の手段が、起点の命令の位置を保持する起点位
置保持手段と、命令を実行のために解読する実行解読手
段と、前記起点位置保持手段で保持した命令位置を基準
として実行のために解読した命令の相対位置を得る命令
位置獲得手段と、解読した命令が分岐命令であった場合
に、前記分岐命令の分岐結果を履歴情報として前記分岐
命令の前記相対位置に対応して記録する履歴記録手段と
からなり、 前記第2の手段が、次回の命令の実行前に命令を先行解
読する先行解読手段と、前記起点位置保持手段で保持し
た命令位置を基準として先行解読した命令の相 対位置を
得る先行命令位置獲得手段と、先行解読した命令が分岐
命令であった場合に、前記先行解読した分岐命令の相対
位置に対応した前記履歴情報を参照する履歴参照手段
と、前記履歴情報を参照した結果を用いて前記先行解読
した分岐命令の実行結果を予測する分岐予測手段とから
なり、 前記起点位置保持手段が、プログラムのループ構造を検
出するループ検出手段と、前記ループ検出手段により検
出したプログラムのループ構造を基にループの先頭命令
のアドレスを取り出し保持するループ先頭アドレス保持
手段とからなることを特徴とするプロセッサ。
7. A branch result indicating whether a branch instruction is taken or not taken.
Is recorded as history information corresponding to the relative position from the starting point.
First means, and preceding decoding before execution of the next branch instruction
The history information based on the relative position of the preceding decoding instruction from the origin.
The branch result of the next branch instruction with reference to the report
Second means, wherein the first means retains the position of the starting instruction.
Holding means and an execution interpreter for decoding instructions for execution
And the command position held by the starting position holding means.
Instruction to get relative position of instruction decoded for execution as
When the position acquisition means and the decoded instruction are branch instructions
The branch result of the branch instruction as history information;
History recording means for recording corresponding to the relative position of the instruction;
Made, the second means, the prior solution of the instruction before execution of the next instruction
Reading means for reading and holding by the starting position holding means.
And the instruction position relative location of the instruction that preceded decrypt the basis of
Preceding instruction position acquisition means to obtain and precedently decoded instruction branch
If it is an instruction, the relative value of the previously decoded branch instruction
History reference means for referring to the history information corresponding to a position
And the preceding decoding using a result obtained by referring to the history information.
Branch prediction means for predicting the execution result of a branch instruction
The starting position holding means detects the loop structure of the program.
Loop detecting means for detecting the
First instruction of loop based on the loop structure of the issued program
Loop start address holding
And a processor.
【請求項8】 前記ループ検出手段は、後方に分岐する
分岐命令を解読することによりプログラムのループ構造
を検出する手段からなることを特徴とする請求項7記載
のプロセッサ。
8. The loop detecting means branches backward.
Program loop structure by decoding branch instructions
8. The apparatus according to claim 7, further comprising means for detecting
Processor.
【請求項9】 分岐命令の成立・不成立を示す分岐結果
を起点からの相対位置に対応して履歴情報として記録す
る第1の手段と、次回の分岐命令の実行前の先行解読時
に起点からの先行解読命令の相対位置を基に前記履歴情
報を参照して前記次回の分岐命令の分岐結果を予測する
第2の手段とを備え、 前記第1の手段が、起点の命令の位置を保持する起点位
置保持手段と、命令を実行のために解読する実行解読手
段と、前記起点位置保持手段で保持した命令位置を基準
として実行のために解読した命令の相対位置を得る命令
位置獲得手段と、解読した命令が分岐命令であった場合
に、前記分岐命令の分岐結果を履歴情報として前記分岐
命令の前記相対位置に対応して記録する履歴記録手段と
からなり、 前記第2の手段が、次回の命令の実行前に命令を先行解
読する先行解読手段と、前記起点位置保持手段で保持し
た命令位置を基準として先行解読した命令の相対位置を
得る先行命令位置獲得手段と、先行解読した命令が分岐
命令であった場合に、前記先行解読した分岐命令の相対
位置に対応した前記履歴情報を参照する履歴参照手段
と、前記履歴情報を参照した結果を用いて前記先行解読
した分岐命令の実行結果を予測する分岐予測手段とから
なり、 前記起点位置保持手段が、プログラムブロックの先頭ア
ドレスを検出するブロック先頭アドレス検出手段と、前
記ブロック先頭アドレス検出手段で検出された アドレス
を保持するブロック先頭アドレス保持手段とからなるこ
とを特徴とするプロセッサ。
9. A branch result indicating whether a branch instruction is taken or not taken.
Is recorded as history information corresponding to the relative position from the starting point.
First means, and preceding decoding before execution of the next branch instruction
The history information based on the relative position of the preceding decoding instruction from the origin.
The branch result of the next branch instruction with reference to the report
Second means, wherein the first means retains the position of the starting instruction.
Holding means and an execution interpreter for decoding instructions for execution
And the command position held by the starting position holding means.
Instruction to get relative position of instruction decoded for execution as
When the position acquisition means and the decoded instruction are branch instructions
The branch result of the branch instruction as history information;
History recording means for recording corresponding to the relative position of the instruction;
Made, the second means, the prior solution of the instruction before execution of the next instruction
Reading means for reading and holding by the starting position holding means.
The relative position of the previously decoded instruction is
Preceding instruction position acquisition means to obtain and precedently decoded instruction branch
If it is an instruction, the relative value of the previously decoded branch instruction
History reference means for referring to the history information corresponding to a position
And the preceding decoding using a result obtained by referring to the history information.
Branch prediction means for predicting the execution result of a branch instruction
And the starting position holding means detects the start address of the program block.
A block start address detecting means for detecting a dress;
Detected address in the serial block start address detection means
And block start address holding means for holding
And a processor.
【請求項10】 分岐命令の成立・不成立を示す分岐結
果を起点からの相対位置に対応して履歴情報として記録
する第1の手段と、次回の分岐命令の実行前の先行解読
時に起点からの先行解読命令の相対位置を基に前記履歴
情報を参照して前記次回の分岐命令の分岐結果を予測す
る第2の手段とを備え、 前記第1の手段が、起点の命令の位置を保持する起点位
置保持手段と、命令を実行のために解読する実行解読手
段と、前記起点位置保持手段で保持した命令位置を基準
として実行のために解読した命令の相対位置を得る命令
位置獲得手段と、解読した命令が分岐命令であった場合
に、前記分岐命令の分岐結果を履歴情報として前記分岐
命令の前記相対位置に対応して記録する履歴記録手段と
からなり、 前記第2の手段が、次回の命令の実行前に命令を先行解
読する先行解読手段と、前記起点位置保持手段で保持し
た命令位置を基準として先行解読した命令の相対位置を
得る先行命令位置獲得手段と、先行解読した命令が分岐
命令であった場合に、前記先行解読した分岐命令の相対
位置に対応した前記履歴情報を参照する履歴参照手段
と、前記履歴情報を参照した結果を用いて前記先行解読
した分岐命令の実行結果を予測する分岐予測手段とから
なり、 前記命令位置獲得手段が、実行のため解読した命令を計
数して命令数を得る手段からなり、前記先行命令位置獲
得手段が、先行解読した命令を計数して命令数を得る手
段からなることを特徴とするプロセッサ。
10. A branch connection indicating whether a branch instruction is taken or not taken.
Record the result as history information corresponding to the relative position from the starting point
First means for performing the above, and preceding decoding before execution of the next branch instruction
Sometimes the history is based on the relative position of the preceding decoding instruction from the starting point.
Predicting the branch result of the next branch instruction with reference to the information
Second means, wherein the first means retains the position of the instruction at the starting point.
Holding means and an execution interpreter for decoding instructions for execution
And the command position held by the starting position holding means.
Instruction to get relative position of instruction decoded for execution as
When the position acquisition means and the decoded instruction are branch instructions
The branch result of the branch instruction as history information;
History recording means for recording corresponding to the relative position of the instruction;
Made, the second means, the prior solution of the instruction before execution of the next instruction
Reading means for reading and holding by the starting position holding means.
The relative position of the previously decoded instruction is
Preceding instruction position acquisition means to obtain and precedently decoded instruction branch
If it is an instruction, the relative value of the previously decoded branch instruction
History reference means for referring to the history information corresponding to a position
And the preceding decoding using a result obtained by referring to the history information.
Branch prediction means for predicting the execution result of a branch instruction
The instruction position obtaining means counts the instructions decoded for execution.
Means for obtaining the number of instructions by counting
Means for obtaining the number of instructions by counting the previously decoded instructions.
A processor comprising stages.
【請求項11】 分岐命令の成立・不成立を示す分岐結
果を起点からの相対位置に対応して履歴情報として記録
する第1の手段と、次回の分岐命令の実行前の先行解読
時に起点からの先行解読命令の相対位置を基に前記履歴
情報を参照して前記次回の分岐命令の分岐結果を予測す
る第2の手段とを備え、 前記第1の手段が、起点の命令の位置を保持する起点位
置保持手段と、命令を実行のために解読する実行解読手
段と、前記起点位置保持手段で保持した命令位置を基準
として実行のために解読した命令の相対位置を得る命令
位置獲得手段と、解読した命令が分岐命令であった場合
に、前記分岐命令の分岐結果を履歴情報 として前記分岐
命令の前記相対位置に対応して記録する履歴記録手段と
からなり、 前記第2の手段が、次回の命令の実行前に命令を先行解
読する先行解読手段と、前記起点位置保持手段で保持し
た命令位置を基準として先行解読した命令の相対位置を
得る先行命令位置獲得手段と、先行解読した命令が分岐
命令であった場合に、前記先行解読した分岐命令の相対
位置に対応した前記履歴情報を参照する履歴参照手段
と、前記履歴情報を参照した結果を用いて前記先行解読
した分岐命令の実行結果を予測する分岐予測手段とから
なり、 前記命令位置獲得手段が、実行のための解読により分岐
命令であることが判明した命令を計数して命令数を得る
手段からなり、前記先行命令位置獲得手段が、先行解読
により分岐命令であることが判明した命令を計数して命
令数を得る手段からなることを特徴とするプロセッサ。
11. A branch connection indicating whether a branch instruction is taken or not taken.
Record the result as history information corresponding to the relative position from the starting point
First means for performing the above, and preceding decoding before execution of the next branch instruction
Sometimes the history is based on the relative position of the preceding decoding instruction from the starting point.
Predicting the branch result of the next branch instruction with reference to the information
Second means, wherein the first means retains the position of the instruction at the starting point.
Holding means and an execution interpreter for decoding instructions for execution
And the command position held by the starting position holding means.
Instruction to get relative position of instruction decoded for execution as
When the position acquisition means and the decoded instruction are branch instructions
The branch result of the branch instruction as history information ;
History recording means for recording corresponding to the relative position of the instruction;
Made, the second means, the prior solution of the instruction before execution of the next instruction
Reading means for reading and holding by the starting position holding means.
The relative position of the previously decoded instruction is
Preceding instruction position acquisition means to obtain and precedently decoded instruction branch
If it is an instruction, the relative value of the previously decoded branch instruction
History reference means for referring to the history information corresponding to a position
And the preceding decoding using a result obtained by referring to the history information.
Branch prediction means for predicting the execution result of a branch instruction
The instruction position obtaining means branches by decoding for execution.
Count instructions found to be instructions to get the number of instructions
Means for acquiring the preceding instruction position,
Instructions that are determined to be branch instructions by
A processor comprising means for obtaining an instruction number.
【請求項12】 分岐命令の成立・不成立を示す分岐結
果を起点からの相対位置に対応して履歴情報として記録
する第1の手段と、次回の分岐命令の実行前の先行解読
時に起点からの先行解読命令の相対位置を基に前記履歴
情報を参照して前記次回の分岐命令の分岐結果を予測す
る第2の手段とを備え、 前記第1の手段が、起点の命令の位置を保持する起点位
置保持手段と、命令を実行のために解読する実行解読手
段と、前記起点位置保持手段で保持した命令位置を基準
として実行のために解読した命令の相対位置を得る命令
位置獲得手段と、解読した命令が分岐命令であった場合
に、前記分岐命令の分岐結果を履歴情報として前記分岐
命令の前記相対位置に対応して記録する履歴記録手段と
からなり、 前記第2の手段が、次回の命令の実行前に命令を先行解
読する先行解読手段と、前記起点位置保持手段で保持し
た命令位置を基準として先行解読した命令の相対位置を
得る先行命令位置獲得手段と、先行解読した命令が分岐
命令であった場合に、前記先行解読した分岐命令の相対
位置に対応した前記履歴情報を参照する履歴参照手段
と、前記履歴情報を参照した結果を用いて前記先行解読
した分岐命令の実行結果を予測する分岐予測手段とから
なり、 前記命令位置獲得手段が、実行のための解読した命令の
アドレスと前記起点位 置保持手段により保持されたアド
レスとの差分を得る手段からなり、前記先行命令位置獲
得手段が、先行解読した命令のアドレスと前記起点位置
保持手段により保持されたアドレスとの差分を得る手段
からなることを特徴とするプロセッサ。
12. A branch connection indicating whether a branch instruction is taken or not taken.
Record the result as history information corresponding to the relative position from the starting point
First means for performing the above, and preceding decoding before execution of the next branch instruction
Sometimes the history is based on the relative position of the preceding decoding instruction from the starting point.
Predicting the branch result of the next branch instruction with reference to the information
Second means, wherein the first means retains the position of the instruction at the starting point.
Holding means and an execution interpreter for decoding instructions for execution
And the command position held by the starting position holding means.
Instruction to get relative position of instruction decoded for execution as
When the position acquisition means and the decoded instruction are branch instructions
The branch result of the branch instruction as history information;
History recording means for recording corresponding to the relative position of the instruction;
Made, the second means, the prior solution of the instruction before execution of the next instruction
Reading means for reading and holding by the starting position holding means.
The relative position of the previously decoded instruction is
Preceding instruction position acquisition means to obtain and precedently decoded instruction branch
If it is an instruction, the relative value of the previously decoded branch instruction
History reference means for referring to the history information corresponding to a position
And the preceding decoding using a result obtained by referring to the history information.
Branch prediction means for predicting the execution result of a branch instruction
The instruction position obtaining means is configured to decode the decoded instruction for execution.
Ad held by the address and the origin position location holding means
Means for obtaining a difference from the
The obtaining means calculates the address of the instruction decoded earlier and the starting position.
Means for obtaining a difference from the address held by the holding means
A processor comprising:
JP19000398A 1997-07-14 1998-07-06 Branch prediction method and processor Expired - Fee Related JP2939248B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP19000398A JP2939248B2 (en) 1997-07-14 1998-07-06 Branch prediction method and processor

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
JP18834697 1997-07-14
JP9-188346 1997-07-14
JP19000398A JP2939248B2 (en) 1997-07-14 1998-07-06 Branch prediction method and processor

Publications (2)

Publication Number Publication Date
JPH1185516A JPH1185516A (en) 1999-03-30
JP2939248B2 true JP2939248B2 (en) 1999-08-25

Family

ID=26504864

Family Applications (1)

Application Number Title Priority Date Filing Date
JP19000398A Expired - Fee Related JP2939248B2 (en) 1997-07-14 1998-07-06 Branch prediction method and processor

Country Status (1)

Country Link
JP (1) JP2939248B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5609609B2 (en) * 2010-12-09 2014-10-22 富士通株式会社 Branch prediction apparatus and processor
US9176737B2 (en) * 2011-02-07 2015-11-03 Arm Limited Controlling the execution of adjacent instructions that are dependent upon a same data condition

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
原哲也、外3名"SIMP(単一命令流/多重命令パイプライン)方式に基づくスーパースカラ・プロセッサ「新風」の命令供給機構",情報処理学会研究報告,Vol.90,No.7(90−ARC−80),80−7,平成2年(1990年)1月25日,p.49−56

Also Published As

Publication number Publication date
JPH1185516A (en) 1999-03-30

Similar Documents

Publication Publication Date Title
US6898699B2 (en) Return address stack including speculative return address buffer with back pointers
EP1157329B1 (en) Methods and apparatus for branch prediction using hybrid history with index sharing
US6553488B2 (en) Method and apparatus for branch prediction using first and second level branch prediction tables
JP3182740B2 (en) A method and system for fetching non-consecutive instructions in a single clock cycle.
US4725947A (en) Data processor with a branch target instruction storage
US6178498B1 (en) Storing predicted branch target address in different storage according to importance hint in branch prediction instruction
US5848269A (en) Branch predicting mechanism for enhancing accuracy in branch prediction by reference to data
US6263427B1 (en) Branch prediction mechanism
US6081887A (en) System for passing an index value with each prediction in forward direction to enable truth predictor to associate truth value with particular branch instruction
US8943298B2 (en) Meta predictor restoration upon detecting misprediction
US20020199091A1 (en) Apparatus for branch prediction based on history table
JPS63175934A (en) Data processor
JPH06110683A (en) Method and apparatus for extending branch target of microprocessor
KR20000076502A (en) Method and apparatus for reducing latency in set-associative caches using set prediction
JP5209633B2 (en) System and method with working global history register
US6385720B1 (en) Branch prediction method and processor using origin information, relative position information and history information
US5822577A (en) Context oriented branch history table
JP2939248B2 (en) Branch prediction method and processor
US7234046B2 (en) Branch prediction using precedent instruction address of relative offset determined based on branch type and enabling skipping
WO2004068337A1 (en) Information processor
US20040003213A1 (en) Method for reducing the latency of a branch target calculation by linking the branch target address cache with the call-return stack
JP3082944B2 (en) Pipeline processing equipment
JP3765111B2 (en) Processor having branch registration instruction
JPH0588891A (en) Cache memory controller
JP2001022577A (en) Information processor

Legal Events

Date Code Title Description
LAPS Cancellation because of no payment of annual fees