JP2629613B2 - Branch prediction device - Google Patents

Branch prediction device

Info

Publication number
JP2629613B2
JP2629613B2 JP6209501A JP20950194A JP2629613B2 JP 2629613 B2 JP2629613 B2 JP 2629613B2 JP 6209501 A JP6209501 A JP 6209501A JP 20950194 A JP20950194 A JP 20950194A JP 2629613 B2 JP2629613 B2 JP 2629613B2
Authority
JP
Japan
Prior art keywords
branch
address
instruction
holding circuit
entry
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
JP6209501A
Other languages
Japanese (ja)
Other versions
JPH0876999A (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.)
NEC Corp
Original Assignee
NEC Corp
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 NEC Corp filed Critical NEC Corp
Priority to JP6209501A priority Critical patent/JP2629613B2/en
Publication of JPH0876999A publication Critical patent/JPH0876999A/en
Application granted granted Critical
Publication of JP2629613B2 publication Critical patent/JP2629613B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、データ処理装置におけ
る分岐命令の分岐先を予測する分岐予測装置に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a branch prediction device for predicting a branch destination of a branch instruction in a data processing device.

【0002】[0002]

【従来の技術】従来この種の技術では、分岐命令自身の
アドレスと分岐が生起した場合の分岐先予測アドレスと
を対にして分岐予測テーブルに記憶しておくことによ
り、フェッチした命令のアドレスをキーとして上記テー
ブルを索引して分岐先予測アドレスを得ている。この従
来の技術では、プロセッサの性能向上のために、動作周
波数の改善及び登録可能な分岐予測テーブルのエントリ
の増加を図る場合には、以下の問題が発生する。すなわ
ち、命令フェッチアドレスを保持するレジスタにおい
て、分岐命令の命令アドレスが確定してから、分岐予測
テーブルを索引して得た分岐先予測アドレスが確定する
までの時間が、分岐生起予測成功時の実効的な分岐命令
処理時間となる。そして、この処理に要する回路的な遅
延時間が分岐命令の処理を高速化する上での障壁とな
る。
2. Description of the Related Art Conventionally, in this type of technique, the address of a fetched instruction is stored in a branch prediction table by pairing the address of the branch instruction itself and the predicted address of the branch destination when a branch occurs. The above table is indexed as a key to obtain a predicted branch destination address. In this conventional technique, the following problems occur when the operating frequency is improved and the number of entries in the branch prediction table that can be registered is increased in order to improve the performance of the processor. That is, in the register holding the instruction fetch address, the time from when the instruction address of the branch instruction is determined to when the branch destination prediction address obtained by indexing the branch prediction table is determined is the effective time when the branch occurrence prediction is successful. Branch instruction processing time. The circuit delay time required for this processing becomes a barrier to speeding up the processing of the branch instruction.

【0003】この問題を解決するために、分岐予測テー
ブルにキーとして記憶するアドレスとして、分岐命令の
命令アドレスを使用するのではなく、分岐命令の直前の
命令の命令アドレスを使用する技術が提案されている。
たとえば、特開昭63−1124135号公報には、分
岐命令の直前の命令の命令アドレスと分岐先アドレスと
を分岐予測テーブルに記憶しておき、分岐命令の直前の
アドレスで分岐予測テーブルの索引を行って分岐予測を
高速に行う技術が記載されている。
In order to solve this problem, a technique has been proposed in which, instead of using the instruction address of a branch instruction as an address to be stored as a key in a branch prediction table, the instruction address of the instruction immediately before the branch instruction is used. ing.
For example, in Japanese Patent Application Laid-Open No. 63-124135, the instruction address of the instruction immediately before the branch instruction and the branch destination address are stored in the branch prediction table, and the index of the branch prediction table is stored at the address immediately before the branch instruction. A technique for performing branch prediction at high speed is described.

【0004】[0004]

【発明が解決しようとする課題】しかしながら、特開昭
63−1124135号公報の従来技術では、以下のよ
うな問題がある。図8を参照すると、分岐予測テーブル
は、分岐命令のM命令前の命令アドレスをキーとして記
憶しており、分岐予測の方向として分岐の生起を予測す
る「T」または分岐が生起しない旨を予測する「N」を
記憶するフィールドと、分岐先予測アドレスを記憶する
フィールドとを含んでいる。ここでは、過去の分岐状況
として、アドレス「AAA」の分岐命令1から命令アド
レス「BBB」に分岐し、さらにアドレス「BBB+
1」の分岐命令2から命令アドレス「CCC」に分岐す
るシーケンスが事前に実行されていたと仮定する。この
場合、分岐予測テーブルに、分岐命令の命令アドレスか
らM命令分前に実行していた命令の命令アドレスをキー
としてアドレスの登録を行い、アドレス「AAA−M」
をキーとして分岐先予測アドレス「BBB」が登録さ
れ、アドレス「AAA−M+2」をキーとして分岐先予
測アドレス「CCC」が登録されている状態となる。
However, the prior art disclosed in Japanese Patent Application Laid-Open No. 63-1124135 has the following problems. Referring to FIG. 8, the branch prediction table stores the instruction address before the M instruction of the branch instruction as a key, and predicts "T" for predicting the occurrence of a branch or that no branch will occur as the direction of branch prediction. And a field for storing a predicted branch destination address. Here, as the past branch situation, the branch instruction 1 at the address “AAA” branches to the instruction address “BBB”, and further the address “BBB +
It is assumed that the sequence of branching from the branch instruction 2 of “1” to the instruction address “CCC” has been executed in advance. In this case, the address is registered in the branch prediction table using the instruction address of the instruction executed M instructions before the instruction address of the branch instruction as a key, and the address “AAA-M”
, The branch destination prediction address “BBB” is registered, and the branch destination prediction address “CCC” is registered using the address “AAA-M + 2” as a key.

【0005】この状態において、分岐命令1を再度実行
した結果、実際の分岐先アドレスが「DDD」となる
と、アドレス「AAA−M」をキーとして登録されてい
た分岐先予測アドレスは「BBB」から「DDD」に変
更される。このとき問題となるのは、アドレス「AAA
−M+2」をキーとして登録されている分岐先予測アド
レス「CCC」である。変更後の実行シーケンスにおい
ては、アドレス「AAA−M+2」をキーとして得られ
るのはアドレス「DDD+1」の命令11に対応する分
岐先予測アドレスである。しかし、命令11が分岐命令
であるとは限らない。命令11が分岐命令でないのにも
拘わらず分岐先予測アドレスに分岐させてしまうと、不
正動作に陥るおそれが生ずる。また、例え命令11が分
岐命令であったとしてもその分岐先が「CCC」である
とは限らず、この場合にも何らかのリカバリ処理が必要
となる。
In this state, if the actual branch destination address becomes "DDD" as a result of executing the branch instruction 1 again, the predicted branch destination address registered using the address "AAA-M" as a key is changed from "BBB". Changed to "DDD". The problem at this time is that the address "AAA
The branch destination prediction address “CCC” is registered using “−M + 2” as a key. In the execution sequence after the change, what is obtained using the address “AAA-M + 2” as a key is the predicted branch destination address corresponding to the instruction 11 at the address “DDD + 1”. However, the instruction 11 is not always a branch instruction. If the instruction 11 is not a branch instruction but branches to the predicted branch destination address, an illegal operation may occur. Further, even if the instruction 11 is a branch instruction, the branch destination is not always “CCC”, and in this case, some recovery processing is required.

【0006】従って、特開昭63−1124135号公
報の従来技術では、上述のような場合に正常な動作が保
証できず、また分岐制御の複雑化もしくは性能の低下を
招いていた。
Therefore, in the prior art disclosed in Japanese Patent Application Laid-Open No. 63-1124135, a normal operation cannot be guaranteed in the above-described case, and branch control becomes complicated or performance is reduced.

【0007】本発明の目的は、上述の問題を解決して、
分岐予測処理の高速化を図ると共に、分岐制御における
不正動作を防止することにある。
An object of the present invention is to solve the above-mentioned problems,
An object of the present invention is to increase the speed of a branch prediction process and prevent an illegal operation in branch control.

【0008】また、分岐先を予測するタイミングを柔軟
に設定できるようにすることにより、システムの仕様に
応じた構成を採用できるようにすることにある。
Another object of the present invention is to make it possible to flexibly set the timing for predicting a branch destination, so that a configuration according to the specifications of the system can be adopted.

【0009】[0009]

【課題を解決するための手段】上記課題を解決するため
に本発明の分岐予測装置は、分岐命令の分岐履歴をこの
分岐命令のM(Mは正の整数)個前の命令と関連付けて
保持する分岐履歴保持手段と、この分岐履歴保持手段を
検索して次に分岐し得るアドレスを予測する分岐予測ア
ドレス検索手段と、この分岐予測アドレス検索手段によ
って検索された分岐予測に関する情報を保持する分岐予
測情報保持手段と、直前に実行したM個の命令中に分岐
の生起した分岐命令が存在する場合には前記分岐予測情
報保持手段に保持された分岐予測結果を使用しないよう
に制御する分岐予測制御手段とを含む。
In order to solve the above-mentioned problems, a branch prediction apparatus according to the present invention holds a branch history of a branch instruction in association with an instruction M (M is a positive integer) before the branch instruction. Branch history holding means, a branch prediction address search means for searching the branch history holding means and predicting the next branchable address, and a branch for holding information on the branch prediction searched by the branch prediction address search means A prediction information holding unit, and a branch prediction unit configured to control not to use a branch prediction result held in the branch prediction information holding unit when a branch instruction having a branch is present in the M instructions executed immediately before. Control means.

【0010】また、本発明の分岐予測装置において、前
記分岐履歴保持手段は、少なくとも一つのエントリを有
し各エントリに分岐命令の前回分岐したアドレスを保持
する分岐履歴アドレス保持回路と、この分岐履歴アドレ
ス保持回路の各エントリに対応して分岐命令の直前の命
令の命令アドレスを保持する命令アドレス保持回路と、
この命令アドレス保持回路の各エントリに対応してその
エントリの内容が有効なものであるか否かを保持するエ
ントリ有効性保持回路と、前記分岐履歴アドレス保持回
路の各エントリに対応して前記分岐命令により前回分岐
が生起したか否かを保持する分岐生起保持回路とを有
し、前記分岐予測アドレス検索手段は、分岐命令の前記
直前の命令の命令アドレスによって前記命令アドレス保
持回路を検索するアドレス比較器と、このアドレス比較
器における比較結果によって前記エントリ有効性保持回
路と前記分岐履歴アドレス保持回路と前記分岐生起保持
回路とに保持された情報を選択する選択器とを有し、前
記分岐予測情報保持手段は、前記選択器により選択され
た前記エントリ有効性保持回路からの情報を保持する分
岐予測有効性保持回路と、前記選択器により選択された
前記分岐履歴アドレス保持回路からの情報を保持する分
岐予測アドレス保持回路と、前記分岐生起保持回路から
の情報を保持する分岐予測生起保持回路とを有し、前記
分岐予測制御手段は、前記分岐予測有効性保持回路が有
効である旨を保持し、かつ、前記分岐予測生起保持回路
が生起である旨を保持している場合には、直前に実行し
た命令が分岐の生起した分岐命令であると判断して前記
分岐予測アドレス保持回路に保持されたアドレスを分岐
予測結果として使用しないように制御する。
Further, in the branch prediction apparatus of the present invention, the branch history holding means has a branch history address holding circuit having at least one entry and holding in each entry the address of the previous branch of the branch instruction; An instruction address holding circuit for holding an instruction address of an instruction immediately before a branch instruction corresponding to each entry of the address holding circuit;
An entry validity holding circuit that holds whether or not the contents of the entry are valid for each entry of the instruction address holding circuit; and the branch corresponding to each entry of the branch history address holding circuit. A branch occurrence holding circuit for holding whether or not a previous branch was caused by an instruction; and the branch prediction address search means searches the instruction address holding circuit by an instruction address of the instruction immediately before the branch instruction. A comparator for selecting information held in the entry validity holding circuit, the branch history address holding circuit, and the branch occurrence holding circuit based on a comparison result in the address comparator; and The information holding means is a branch prediction validity holding circuit for holding information from the entry validity holding circuit selected by the selector. A branch prediction address holding circuit that holds information from the branch history address holding circuit selected by the selector, and a branch prediction occurrence holding circuit that holds information from the branch occurrence holding circuit, The branch prediction control means holds that the branch prediction validity holding circuit is valid, and when the branch prediction occurrence holding circuit holds that occurrence is occurring, the instruction executed immediately before It is determined that the instruction is a branch instruction in which a branch has occurred, and control is performed so that the address held in the branch prediction address holding circuit is not used as a branch prediction result.

【0011】また、本発明の他の分岐予測装置におい
て、前記分岐履歴保持手段は、少なくとも一つのエント
リを有し各エントリに分岐命令の前回分岐したアドレス
を保持する分岐履歴アドレス保持回路と、この分岐履歴
アドレス保持回路の各エントリに対応して分岐命令の直
前の命令の命令アドレスを保持する命令アドレス保持回
路と、この命令アドレス保持回路の各エントリに対応し
てそのエントリの内容が有効なものであるか否かを保持
するエントリ有効性保持回路とを有し、前記分岐予測ア
ドレス検索手段は、分岐命令の前記直前の命令の命令ア
ドレスによって前記命令アドレス保持回路を検索するア
ドレス比較器と、このアドレス比較器における比較結果
によって前記エントリ有効性保持回路と前記分岐履歴ア
ドレス保持回路とに保持された情報を選択する選択器と
を有し、前記分岐予測情報保持手段は、前記選択器によ
り選択された前記エントリ有効性保持回路からの情報を
保持する分岐予測有効性保持回路と、前記選択器により
選択された前記分岐履歴アドレス保持回路からの情報を
保持する分岐予測アドレス保持回路とを有し、前記分岐
予測制御手段は、前記分岐予測有効性保持回路が有効で
ある旨を保持している場合には、直前に実行した命令が
分岐の生起した分岐命令であると判断して前記分岐予測
アドレス保持回路に保持されたアドレスを分岐予測結果
として使用しないように制御する。
Further, in another branch prediction device of the present invention, the branch history holding means has at least one entry, and holds a branch history address holding circuit for holding an address of a previous branch of a branch instruction in each entry. An instruction address holding circuit that holds the instruction address of the instruction immediately before the branch instruction corresponding to each entry of the branch history address holding circuit, and that the contents of the entry are valid for each entry of the instruction address holding circuit An entry validity holding circuit that holds whether or not the branch prediction address search means, the branch prediction address search means, an address comparator that searches the instruction address holding circuit by the instruction address of the instruction immediately before the branch instruction, According to the comparison result in the address comparator, the entry validity holding circuit and the branch history address holding circuit A selector for selecting the held information, wherein the branch prediction information holding means holds a branch prediction validity holding circuit for holding information from the entry validity holding circuit selected by the selector; A branch prediction address holding circuit for holding information from the branch history address holding circuit selected by the selector, wherein the branch prediction control means holds that the branch prediction validity holding circuit is valid. If so, it is determined that the instruction executed immediately before is a branch instruction in which a branch has occurred, and control is performed so that the address held in the branch prediction address holding circuit is not used as a branch prediction result.

【0012】また、本発明の他の分岐予測装置におい
て、前記分岐履歴保持手段は、少なくとも一つのエント
リを有し各エントリに分岐命令の前回分岐したアドレス
を保持する分岐履歴アドレス保持回路と、この分岐履歴
アドレス保持回路の各エントリに対応して分岐命令の前
記M個前の命令の命令アドレスを保持する命令アドレス
保持回路と、この命令アドレス保持回路の各エントリに
対応してそのエントリの内容が有効なものであるか否か
を保持するエントリ有効性保持回路と、前記分岐履歴ア
ドレス保持回路の各エントリに対応して前記分岐命令に
より前回分岐が生起したか否かを保持する分岐生起保持
回路とを有し、前記分岐予測アドレス検索手段は、分岐
命令の前記M個前の命令の命令アドレスによって前記命
令アドレス保持回路を検索するアドレス比較器と、この
アドレス比較器における比較結果によって前記エントリ
有効性保持回路と前記分岐履歴アドレス保持回路と前記
分岐生起保持回路とに保持された情報を選択する選択器
とを有し、前記分岐予測情報保持手段は、前記選択器に
より選択された前記エントリ有効性保持回路からの情報
を保持する分岐予測有効性保持回路と、前記選択器によ
り選択された前記分岐履歴アドレス保持回路からの情報
を保持する分岐予測アドレス保持回路と、前記分岐生起
保持回路からの情報を保持する分岐予測生起保持回路と
を有し、前記分岐予測制御手段は、分岐生起後(M−
1)命令分を計数する命令数カウンタをさらに有し、こ
の命令数カウンタが(M−1)命令分を計数している途
中である場合、もしくは、前記分岐予測有効性保持回路
が有効である旨を保持し、かつ、前記分岐予測生起保持
回路が生起である旨を保持している場合には、直前に実
行したM個の命令中に分岐の生起した分岐命令が存在す
ると判断して前記分岐予測アドレス保持回路に保持され
たアドレスを分岐予測結果として使用しないように制御
する。
In another branch prediction apparatus of the present invention, the branch history holding means has at least one entry, and a branch history address holding circuit for holding, in each entry, an address of a previous branch instruction of a branch instruction. An instruction address holding circuit for holding an instruction address of the instruction M before the branch instruction corresponding to each entry of the branch history address holding circuit; and a content of the entry corresponding to each entry of the instruction address holding circuit. An entry validity holding circuit for holding whether or not the branch is valid; and a branch occurrence holding circuit for holding whether or not a previous branch was caused by the branch instruction corresponding to each entry of the branch history address holding circuit Wherein the branch prediction address search means includes an instruction address holding circuit that stores the instruction address of the instruction M before the branch instruction. An address comparator to be searched, and a selector for selecting information held in the entry validity holding circuit, the branch history address holding circuit, and the branch occurrence holding circuit based on a comparison result in the address comparator, The branch prediction information holding unit includes a branch prediction validity holding circuit that holds information from the entry validity holding circuit selected by the selector, and a branch prediction address holding circuit that stores information from the branch history address holding circuit selected by the selector. A branch prediction address holding circuit for holding information, and a branch prediction occurrence holding circuit for holding information from the branch occurrence holding circuit, wherein the branch prediction control means operates after the branch occurrence (M−
1) An instruction number counter for counting instructions is further provided, and when this instruction number counter is in the process of counting (M-1) instructions, or the branch prediction validity holding circuit is valid. And that the branch prediction occurrence holding circuit holds that the occurrence has occurred, it is determined that the branch instruction in which the branch occurred is present in the M instructions executed immediately before, and Control is performed so that the address held in the branch prediction address holding circuit is not used as a branch prediction result.

【0013】また、本発明の他の分岐予測装置におい
て、前記分岐履歴保持手段は、少なくとも一つのエント
リを有し各エントリに分岐命令の前回分岐したアドレス
を保持する分岐履歴アドレス保持回路と、この分岐履歴
アドレス保持回路の各エントリに対応して分岐命令の前
記M個前の命令の命令アドレスを保持する命令アドレス
保持回路と、この命令アドレス保持回路の各エントリに
対応してそのエントリの内容が有効なものであるか否か
を保持するエントリ有効性保持回路とを有し、前記分岐
予測アドレス検索手段は、分岐命令の前記M個前の命令
の命令アドレスによって前記命令アドレス保持回路を検
索するアドレス比較器と、このアドレス比較器における
比較結果によって前記エントリ有効性保持回路と前記分
岐履歴アドレス保持回路とに保持された情報を選択する
選択器とを有し、前記分岐予測情報保持手段は、前記選
択器により選択された前記エントリ有効性保持回路から
の情報を保持する分岐予測有効性保持回路と、前記選択
器により選択された前記分岐履歴アドレス保持回路から
の情報を保持する分岐予測アドレス保持回路とを有し、
前記分岐予測制御手段は、分岐生起後(M−1)命令分
を計数する命令数カウンタをさらに有し、この命令数カ
ウンタが(M−1)命令分を計数している途中である場
合、もしくは、前記分岐予測有効性保持回路が有効であ
る旨を保持している場合には、直前に実行したM個の命
令中に分岐の生起した分岐命令が存在すると判断して前
記分岐予測アドレス保持回路に保持されたアドレスを分
岐予測結果として使用しないように制御する。
Further, in another branch prediction device of the present invention, the branch history holding means has at least one entry, and a branch history address holding circuit for holding an address of a previous branch of a branch instruction in each entry. An instruction address holding circuit for holding an instruction address of the instruction M before the branch instruction corresponding to each entry of the branch history address holding circuit; and a content of the entry corresponding to each entry of the instruction address holding circuit. An entry validity retaining circuit that retains whether the instruction is valid or not, wherein the branch prediction address retrieval means retrieves the instruction address retaining circuit according to the instruction address of the instruction M before the branch instruction. An address comparator, and the entry validity holding circuit and the branch history address holding based on a comparison result in the address comparator. And a selector for selecting the information held in the path and the branch prediction information holding means, wherein the branch prediction information holding means holds information from the entry validity holding circuit selected by the selector. And a branch prediction address holding circuit that holds information from the branch history address holding circuit selected by the selector,
The branch prediction control means further includes an instruction number counter for counting (M-1) instructions after the occurrence of the branch. When the instruction number counter is in the course of counting (M-1) instructions, Alternatively, when the branch prediction validity holding circuit holds that the branch prediction address holding circuit is valid, it is determined that the branch instruction in which the branch has occurred is present in the M instructions executed immediately before and the branch prediction address holding circuit is held. Control is performed so that the address held in the circuit is not used as a branch prediction result.

【0014】また、本発明の他の分岐予測装置におい
て、前記分岐予測制御手段は、分岐予測が誤った場合に
も分岐が生起したものとみなして前記分岐予測アドレス
保持回路に保持されたアドレスを分岐予測結果として使
用しないように制御する。
In another branch prediction device of the present invention, the branch prediction control means considers that a branch has occurred even when a branch prediction is incorrect, and stores the address held in the branch prediction address holding circuit. Control not to use as a branch prediction result.

【0015】また、本発明の他の分岐予測装置におい
て、前記前記分岐履歴保持手段は、分岐命令に対する分
岐予測が誤った場合で、かつ、その分岐命令の直前に実
行したM個の命令中に分岐の生起した他の分岐命令が存
在しない場合には、前記分岐予測が誤った分岐命令の命
令アドレスよりもM命令前の命令の命令アドレス前記を
命令アドレス保持回路に保持すると共にその対応するエ
ントリについて前記分岐履歴アドレス保持回路に最も最
近に分岐した際の分岐先命令アドレスを保持する。
In another branch prediction apparatus according to the present invention, the branch history holding means is configured to determine whether a branch prediction for a branch instruction is erroneous and that the M branch instructions executed immediately before the branch instruction have a different one. If there is no other branch instruction in which the branch has occurred, the instruction address of the instruction M instructions before the instruction address of the branch instruction whose branch prediction is incorrect is held in the instruction address holding circuit and the corresponding entry is stored. The branch history address holding circuit holds the branch destination instruction address at the time of the most recent branch.

【0016】[0016]

【実施例】次に本発明の分岐予測装置の第一の実施例に
ついて図面を参照して詳細に説明する。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Next, a first embodiment of the branch prediction device of the present invention will be described in detail with reference to the drawings.

【0017】図1を参照すると、本発明の対象とするデ
ータ処理装置は、パイプライン動作する処理装置18
と、命令キャッシュ17を有している。命令キャッシュ
17は、プリフェッチ命令カウンタ1の値に基づいてア
クセスされ、命令キャッシュロードデータ19の書込
み、または、命令レジスタ3への読出しが行われる。プ
リフェッチ命令カウンタ1の値はフェッチ命令カウンタ
2に保持され、命令レジスタ3の命令と共に処理装置1
8に与えられる。命令レジスタ3は有効な命令語を含ん
でいるか否かを表すバリッドビットをも保持している。
処理装置18は、各種演算命令を実行する他、分岐命令
の実行も行う。この処理装置18の分岐命令の実行の際
には、分岐命令の分岐が生起したか否か、もしくは分岐
予測が成功したか否かが判断され、分岐命令の実行結果
としての分岐先アドレスを生成する。分岐予測失敗の旨
は信号線38により、分岐先アドレスは信号線23によ
り、出力される。また、処理装置18は必要に応じてホ
ールド信号を信号線37により出力する。
Referring to FIG. 1, a data processing apparatus to which the present invention is applied is a processing apparatus 18 which operates in a pipeline.
And an instruction cache 17. The instruction cache 17 is accessed based on the value of the prefetch instruction counter 1, and the instruction cache load data 19 is written or the instruction cache 3 is read. The value of the prefetch instruction counter 1 is held in the fetch instruction counter 2, and together with the instruction in the instruction register 3,
8 given. The instruction register 3 also holds a valid bit indicating whether or not a valid instruction word is included.
The processing unit 18 executes various operation instructions and also executes a branch instruction. When the processor 18 executes a branch instruction, it is determined whether or not a branch of the branch instruction has occurred or whether or not the branch prediction has been successful, and a branch destination address as an execution result of the branch instruction is generated. I do. The branch prediction failure is output via a signal line 38, and the branch destination address is output via a signal line 23. Further, the processing device 18 outputs a hold signal through a signal line 37 as necessary.

【0018】一方、分岐予測テーブルは、それぞれNエ
ントリからなる比較アドレスレジスタ群4及び分岐先予
測アドレスレジスタ群5により構成され、分岐命令自身
のアドレスを比較アドレスとして比較アドレスレジスタ
群4に、分岐が生起した場合の分岐先予測アドレスを分
岐先予測アドレスレジスタ群5に、それぞれ対応するア
ドレス同士が対になるように記憶している。比較アドレ
スレジスタ群4は、各エントリに有効な命令語を含んで
いるか否かを表すバリッドビットフィールドを含んでい
る。また、分岐先予測アドレスレジスタ群5は、分岐予
測の方向として分岐の生起を予測する「T」または分岐
が生起しない旨を予測する「N」を記憶するT/Nフィ
ールドを含んでいる。分岐予測テーブルへの新規登録時
には、登録活性化信号20がデコーダ9を介して送ら
れ、登録アドレス21及び分岐先予測アドレス22がそ
れぞれ比較アドレスレジスタ群4及び分岐先予測アドレ
スレジスタ群5の対応するエントリに格納される。
On the other hand, the branch prediction table is composed of a comparison address register group 4 and a branch destination prediction address register group 5 each having N entries, and the branch instruction is stored in the comparison address register group 4 using the address of the branch instruction itself as a comparison address. The branch destination predicted address in the case of occurrence is stored in the branch destination predicted address register group 5 such that the corresponding addresses are paired. The comparison address register group 4 includes a valid bit field indicating whether or not each entry contains a valid instruction word. The branch destination prediction address register group 5 includes a T / N field for storing “T” for predicting the occurrence of a branch or “N” for predicting that a branch will not occur as the direction of branch prediction. At the time of new registration in the branch prediction table, a registration activation signal 20 is sent via the decoder 9, and the registration address 21 and the branch destination prediction address 22 correspond to the comparison address register group 4 and the branch destination prediction address register group 5, respectively. Stored in the entry.

【0019】比較器11は、分岐予測テーブルの比較ア
ドレスレジスタ群4の各エントリとプリフェッチ命令カ
ウンタ1の値との一致比較を行う回路であり、その比較
結果は分岐予測テーブル出力選択制御回路14に送られ
る。これにより登録アドレスによる分岐予測テーブルの
索引が行われる。
The comparator 11 is a circuit for comparing each entry of the comparison address register group 4 of the branch prediction table with the value of the prefetch instruction counter 1. The comparison result is sent to the branch prediction table output selection control circuit 14. Sent. As a result, the branch prediction table is indexed by the registered address.

【0020】分岐予測テーブル出力選択制御回路14
は、比較器11の比較結果28と、処理装置18からの
ホールド信号37とを入力として、セレクタ12および
13の制御信号39と、分岐先予測アドレス有効レジス
タ6のマスク信号41とを生成する。
Branch prediction table output selection control circuit 14
Receives the comparison result 28 of the comparator 11 and the hold signal 37 from the processing unit 18 and generates a control signal 39 for the selectors 12 and 13 and a mask signal 41 for the branch destination prediction address valid register 6.

【0021】図2を参照すると、処理装置18によるホ
ールド指示37があった場合、すなわちホールド信号3
7が「1」である場合には、分岐予測テーブル出力選択
制御回路14によって、分岐先予測アドレス有効レジス
タ6及び分岐先予測アドレスレジスタ7がそれぞれ現在
の状態を維持するようにセレクタ12及び13の制御が
なされる。また、ホールド指示37がない場合には比較
器11の比較結果28で一致が検出されたエントリをセ
レクタ12及び13で選択する。ホールド指示37がな
く比較器11の比較結果28で一致が検出されなかった
場合には、マスク信号41が「0」となり、アンドゲー
ト15により分岐先予測アドレス有効レジスタ6が
「0」、すなわち無効状態とされる。なお、図中、
「×」はドントケア、すなわちどのような値でもかまわ
ないことを意味する。
Referring to FIG. 2, when there is a hold instruction 37 from the processor 18, that is, when the hold signal 3
7 is “1”, the branch prediction table output selection control circuit 14 controls the selectors 12 and 13 so that the branch destination prediction address valid register 6 and the branch destination prediction address register 7 maintain the current state, respectively. Control is exercised. If there is no hold instruction 37, the selectors 12 and 13 select an entry for which a match is detected in the comparison result 28 of the comparator 11. If no match is detected in the comparison result 28 of the comparator 11 without the hold instruction 37, the mask signal 41 becomes "0", and the AND gate 15 sets the branch destination prediction address valid register 6 to "0", that is, invalid. State. In the figure,
"X" means don't care, that is, any value is acceptable.

【0022】プリフェッチ命令カウンタ入力選択制御回
路(以下、「PIC選択制御回路」という)16は、命
令レジスタ3の有効ビットフィールド出力信号36と、
分岐先予測アドレス有効レジスタ6の出力信号30と、
分岐先予測アドレスレジスタ7の分岐予測方向フィール
ドの出力信号40と、処理装置18からのホールド指示
信号37と、処理装置18からの分岐予測失敗信号38
とを入力として、PIC入力セレクタ10への制御信号
32と、分岐先予測アドレス有効レジスタ6のマスク信
号42とを生成する。
The prefetch instruction counter input selection control circuit (hereinafter, referred to as a “PIC selection control circuit”) 16 outputs a valid bit field output signal 36 of the instruction register 3 and
An output signal 30 of the branch destination prediction address valid register 6;
An output signal 40 of the branch prediction direction field of the branch destination prediction address register 7, a hold instruction signal 37 from the processing device 18, and a branch prediction failure signal 38 from the processing device 18.
, The control signal 32 to the PIC input selector 10 and the mask signal 42 of the branch destination prediction address valid register 6 are generated.

【0023】図3を参照すると、PIC選択制御回路1
6は、分岐予測失敗時にはリカバリアドレス23を、ホ
ールド時には現プリフェッチアドレス25を、予測可能
時には予測アドレス26を、それ以外の場合には次の命
令アドレス24を、それぞれPIC1にセットするよう
にセレクタ10を制御する。そして、上記においてリカ
バリアドレス23または予測アドレス26を選択した場
合には、PIC選択制御回路16は、マスク信号42を
「0」にすることによって分岐先予測アドレス有効レジ
スタ6を無効状態とする。すなわち、リカバリアドレス
23または予測アドレス26が選択された場合というの
は、命令のシーケンスが連続しなくなる場合であり、こ
の場合には分岐後M命令分については分岐先予測アドレ
スを得ることができなくなる。但し、この第一の実施例
ではM=1と仮定している。
Referring to FIG. 3, PIC selection control circuit 1
6 is a selector 10 that sets the recovery address 23 when the branch prediction fails, the current prefetch address 25 when the branch is held, the prediction address 26 when the prediction is possible, and the next instruction address 24 otherwise. Control. Then, when the recovery address 23 or the prediction address 26 is selected in the above, the PIC selection control circuit 16 sets the mask signal 42 to “0” to make the branch destination prediction address valid register 6 invalid. That is, the case where the recovery address 23 or the prediction address 26 is selected is a case where the sequence of instructions is not continuous, and in this case, it becomes impossible to obtain the branch destination prediction address for the M instructions after branching. . However, in the first embodiment, it is assumed that M = 1.

【0024】なお、予測失敗信号38が「1」とは分岐
予測失敗の旨を、ホールド信号37が「1」とは処理装
置18においてホールドが発生した旨を、予測有効信号
30が「1」とは分岐先予測アドレスレジスタ7の分岐
先予測アドレスが有効である旨を、分岐生起予測信号4
0が「1」とは分岐が生起する方向を予測する旨を、命
令有効信号36が「1」とは命令レジスタ3の命令語が
有効である旨をそれぞれ意味する。また、命令語は全て
4バイトであるものと仮定している。
When the prediction failure signal 38 is "1", the branch prediction is failed, when the hold signal 37 is "1", the hold has occurred in the processor 18, and the prediction valid signal 30 is "1". Means that the branch destination prediction address of the branch destination prediction address register 7 is valid.
When "0" is "1", the direction in which the branch occurs is predicted, and when the instruction valid signal 36 is "1", the instruction word in the instruction register 3 is valid. Also, it is assumed that all instruction words are 4 bytes.

【0025】次に本発明の上記第一の実施例の動作につ
いて図面を参照して説明する。
Next, the operation of the first embodiment of the present invention will be described with reference to the drawings.

【0026】図4を参照すると、本実施例ではM=1と
仮定しているため、分岐命令の1つ前の命令の命令アド
レスをキーとして分岐予測テーブルへの登録がなされて
いる。また、メモリまたは命令キャッシュ中の命令の並
びに対して、矢印に従って命令の実行が進むことを想定
している。さらに、各命令においては後続命令に対する
ホールドは発生しないことを仮定している。
Referring to FIG. 4, since it is assumed that M = 1 in this embodiment, the instruction is registered in the branch prediction table using the instruction address of the instruction immediately before the branch instruction as a key. Also, it is assumed that the execution of the instruction proceeds according to the arrow with respect to the arrangement of the instruction in the memory or the instruction cache. Further, it is assumed that no hold occurs for a subsequent instruction in each instruction.

【0027】図5を参照すると、図4の命令シーケンス
を実行した場合の動作を示す図において、プリフェッチ
命令カウンタ1の値と、命令レジスタ3の命令語と、分
岐先予測アドレス有効レジスタ6の値と、分岐先予測ア
ドレスレジスタ7の分岐先予測アドレスとが示される。
Referring to FIG. 5, there is shown a diagram showing the operation when the instruction sequence of FIG. 4 is executed. In FIG. 5, the value of the prefetch instruction counter 1, the instruction word of the instruction register 3, and the value of the branch destination prediction address valid register 6 are shown. And the predicted branch destination address of the predicted branch destination address register 7.

【0028】まず、時刻0において、プリフェッチ命令
カウンタ1には初期値「AAA」が、分岐先予測アドレ
ス有効レジスタ6には初期値「0」が保持されているも
のとする。以降、時刻5まではプリフェッチ命令カウン
タ1は順次インクリメントされ、これに対応して命令レ
ジスタ3には1T遅れで対応する命令が保持される。
First, at time 0, it is assumed that the prefetch instruction counter 1 holds the initial value "AAA" and the branch destination prediction address valid register 6 holds the initial value "0". Thereafter, the prefetch instruction counter 1 is sequentially incremented until time 5, and the corresponding instruction is held in the instruction register 3 with a delay of 1T.

【0029】時刻4では分岐先予測アドレスとしてアド
レスBBBが索引されて、この結果時刻5で分岐先予測
アドレスレジスタ7に「BBB」が保持されると共に分
岐先予測アドレス有効レジスタ6に「1」が保持され
る。これにより、PIC選択制御回路16はセレクタ1
0に対し予測アドレス26を選択するよう指示し、この
結果時刻6ではプリフェッチ命令カウンタ1は「BB
B」を保持する。また、時刻5においてPIC選択制御
回路16がマスク信号42を「0」にするため、時刻6
における分岐先予測アドレス有効レジスタ6の値は強制
的に「0」とされる。この強制的な処理は、命令アドレ
スBBBの命令6において誤った動作をしないために必
要である。なぜなら、時刻6において分岐先予測アドレ
スレジスタ7に得られるアドレスは、命令アドレス「X
XX+4」の命令が分岐命令であった場合の分岐先予測
アドレスであり、本実行シーケンスのように命令アドレ
ス「XXX」から命令アドレス「BBB」に分岐が発生
した場合には、分岐先予測アドレスとして使用してはな
らないものだからである。
At time 4, the address BBB is indexed as a branch destination prediction address. As a result, at time 5, “BBB” is held in the branch destination prediction address register 7 and “1” is stored in the branch destination prediction address valid register 6. Will be retained. Thereby, the PIC selection control circuit 16 selects the selector 1
0 to select the prediction address 26. As a result, at time 6, the prefetch instruction counter 1 sets "BB
B ”is held. Further, at time 5, the PIC selection control circuit 16 sets the mask signal 42 to “0”.
Is forcibly set to "0". This compulsory processing is necessary to prevent an erroneous operation at the instruction 6 of the instruction address BBB. This is because the address obtained in the branch destination prediction address register 7 at the time 6 is the instruction address “X
This is a branch destination prediction address when the instruction of “XX + 4” is a branch instruction. When a branch occurs from the instruction address “XXX” to the instruction address “BBB” as in the present execution sequence, the branch destination prediction address is used. This is because it must not be used.

【0030】以降、同様にして、命令が実行されていく
が、アドレス「YYY」の分岐命令によりアドレス「C
CC」の分岐命令に分岐が発生した際、前述のように、
アドレス「CCC」の分岐命令においては分岐先予測ア
ドレスを得ることはできない。従って、分岐は生起しな
いものとして考え、以降、アドレス「CCC+4」、
「CCC+8」と進んでいく。このように誤った分岐予
測を行った場合には、処理装置18において、その分岐
予測失敗を検出して、実行すべきでない命令をキャンセ
ルすると共にリカバリアドレスを送出することにより、
アドレスDDDの命令から実行を再開する。
Thereafter, the instruction is executed in the same manner, but the address "C" is given by the branch instruction at the address "YYY".
When a branch occurs at the "CC" branch instruction, as described above,
For a branch instruction at address "CCC", a predicted branch destination address cannot be obtained. Therefore, it is considered that a branch does not occur, and the addresses “CCC + 4”,
Proceed with "CCC + 8". When the wrong branch prediction is performed as described above, the processor 18 detects the branch prediction failure, cancels the instruction that should not be executed, and sends the recovery address.
Execution is resumed from the instruction at the address DDD.

【0031】このように、本発明の第一の実施例である
分岐予測装置によれば、分岐予測テーブルへの登録のキ
ーとして分岐命令の1つ前のアドレスを使用することに
よって、分岐予測処理を高速化すると同時に、分岐が発
生する場合にマスク信号42で分岐先予測アドレス有効
レジスタ6を強制的にリセットすることによって、分岐
生起直後の分岐予測を抑止して不正動作を防止すること
ができる。
As described above, according to the branch predicting apparatus of the first embodiment of the present invention, by using the address immediately before the branch instruction as a key for registration in the branch prediction table, the branch prediction processing is performed. And at the same time, when the branch occurs, the branch destination prediction address valid register 6 is forcibly reset by the mask signal 42, so that the branch prediction immediately after the occurrence of the branch can be suppressed and the illegal operation can be prevented. .

【0032】次に本発明の分岐予測装置の第二の実施例
について図面を参照して詳細に説明する。
Next, a second embodiment of the branch prediction apparatus of the present invention will be described in detail with reference to the drawings.

【0033】本発明の第二の実施例は、分岐先予測アド
レスレジスタ群5において分岐予測の方向を指定するフ
ィールドを含まない点を除いて、第一の実施例のものと
同様である。本実施例では、比較アドレスレジスタ群4
における有効ビットフィールドの値が「有効」を示して
いれば対応する分岐先予測アドレスレジスタ群5のエン
トリが分岐生起方向に予測されているものとして動作す
る。
The second embodiment of the present invention is the same as that of the first embodiment except that the branch destination prediction address register group 5 does not include a field for specifying the direction of branch prediction. In this embodiment, the comparison address register group 4
If the value of the valid bit field indicates "valid", it operates as if the corresponding entry of the branch destination prediction address register group 5 is predicted in the branch occurrence direction.

【0034】図6を参照すると、本発明の第二の実施例
におけるPIC選択制御回路16は、図3の第一の実施
例のものと異なり、分岐予測方向を考慮しない。従っ
て、第一の実施例では分岐が生起しないものとして予測
している場合には次アドレス24を選択していたが、本
実施例では予測方向に拘わらず予測アドレス26を選択
することになる。
Referring to FIG. 6, the PIC selection control circuit 16 according to the second embodiment of the present invention does not consider the branch prediction direction, unlike the first embodiment of FIG. Accordingly, in the first embodiment, the next address 24 is selected when the prediction is made that the branch does not occur, but in the present embodiment, the prediction address 26 is selected regardless of the prediction direction.

【0035】このように、本発明の第二の実施例である
分岐予測装置によれば、分岐が生起する場合のみ分岐予
測テーブルに登録するようにしたことにより、分岐予測
テーブルの構成を簡略化し、さらに、命令アドレスの制
御を簡単化して、より効率的に分岐予測処理の高速化と
動作の安定を確保することができる。
As described above, according to the branch prediction apparatus of the second embodiment of the present invention, the configuration of the branch prediction table is simplified by registering the branch prediction table only when a branch occurs. Furthermore, the control of the instruction address can be simplified, and the speeding up of the branch prediction process and the stable operation can be ensured more efficiently.

【0036】次に本発明の分岐予測装置の第三の実施例
について図面を参照して詳細に説明する。
Next, a third embodiment of the branch prediction device of the present invention will be described in detail with reference to the drawings.

【0037】本発明の第三の実施例は、命令数カウンタ
を設けて、分岐後の命令数をカウントする点を除いて、
第一の実施例のものと同様である。つまり、第一の実施
例では分岐命令の1つ前の命令の命令アドレスをキーに
して分岐先予測アドレスを登録していたが、本実施例で
は、これを分岐命令のM命令分前の命令の命令アドレス
をキーにして登録する。このため、本実施例では、分岐
発生後M命令分の間、分岐先予測アドレスを使用しない
ようにさせるために、値(M−1)を1命令毎に減算し
ていく命令数カウンタを設ける。
The third embodiment of the present invention differs from the third embodiment in that an instruction counter is provided to count the number of instructions after branching.
This is the same as that of the first embodiment. That is, in the first embodiment, the branch destination prediction address is registered by using the instruction address of the instruction immediately before the branch instruction as a key, but in the present embodiment, this is set to the instruction M instructions before the branch instruction. Is registered using the instruction address as a key. For this reason, in the present embodiment, an instruction number counter for subtracting the value (M-1) for each instruction is provided in order not to use the branch destination prediction address for M instructions after the occurrence of the branch. .

【0038】図7を参照すると、本発明の第三の実施例
におけるPIC選択制御回路16は、命令数カウンタの
値を入力して、この値が1以上の場合にはマスク信号4
2を強制的に「0」にしている。また、分岐が発生する
場合においては、この命令数カウンタに値(M−1)を
セットすることによって、分岐後M命令分の分岐予測を
抑止している。
Referring to FIG. 7, the PIC selection control circuit 16 according to the third embodiment of the present invention inputs the value of the instruction number counter, and when this value is 1 or more, the mask signal 4
2 is forcibly set to "0". When a branch occurs, a value (M-1) is set in the instruction number counter to suppress branch prediction for M instructions after the branch.

【0039】このように、本発明の第三の実施例である
分岐予測装置によれば、分岐予測テーブルへの登録のキ
ーとして分岐命令のM命令分前のアドレスを使用するこ
とによって、分岐予測処理の高速化と動作の安定化をよ
り柔軟に実現することができる。
As described above, according to the branch predicting apparatus of the third embodiment of the present invention, by using the address M instructions before the branch instruction as a key for registration in the branch prediction table, the branch prediction is performed. Higher processing speed and stable operation can be realized more flexibly.

【0040】なお、上記実施例においては、フルアソシ
アティブな分岐予測テーブルの構成を前提としたが、こ
れはセットアソシアティブな構成を採ることも考えられ
る。さらに、セットアソシアティブな構成においては、
比較対象となるアドレスアレイを命令キャッシュのアド
レスアレイと共用する構成を採ることも考えられる。
In the above embodiment, the structure of the fully associative branch prediction table is premised. However, it is also conceivable that the set associative structure is adopted. Furthermore, in a set associative configuration,
It is also conceivable to adopt a configuration in which the address array to be compared is shared with the address array of the instruction cache.

【0041】[0041]

【発明の効果】以上の説明で明らかなように、本発明に
よると、分岐予測テーブルへの登録のキーとして分岐命
令のM命令分前のアドレスを使用することによって分岐
予測処理を高速化すると同時に、分岐が発生する場合に
分岐生起後M命令分の分岐予測を抑止して不正動作を防
止することができる。
As is apparent from the above description, according to the present invention, the branch prediction processing is accelerated by using the address M instructions before the branch instruction as a key for registration in the branch prediction table, and When a branch occurs, the branch prediction for M instructions after the occurrence of the branch can be suppressed to prevent illegal operation.

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

【図1】本発明の分岐予測装置の一実施例の構成を示す
ブロック図である。
FIG. 1 is a block diagram showing a configuration of an embodiment of a branch prediction device of the present invention.

【図2】本発明の第一の実施例における分岐予測テーブ
ル出力選択制御回路の動作を表す図である。
FIG. 2 is a diagram illustrating an operation of a branch prediction table output selection control circuit according to the first embodiment of the present invention.

【図3】本発明の第一の実施例におけるプリフェッチ命
令カウンタ入力選択制御回路の動作を表す図である。
FIG. 3 is a diagram illustrating an operation of a prefetch instruction counter input selection control circuit according to the first embodiment of the present invention.

【図4】本発明の第一の実施例の分岐予測装置における
命令シーケンスを説明するための図である。
FIG. 4 is a diagram for explaining an instruction sequence in the branch prediction device according to the first embodiment of the present invention.

【図5】本発明の第一の実施例の分岐予測装置の動作を
表す図である。
FIG. 5 is a diagram illustrating an operation of the branch prediction device according to the first embodiment of this invention.

【図6】本発明の第二の実施例における分岐予測テーブ
ル出力選択制御回路の動作を表す図である。
FIG. 6 is a diagram illustrating an operation of a branch prediction table output selection control circuit according to a second embodiment of the present invention.

【図7】本発明の第三の実施例における分岐予測テーブ
ル出力選択制御回路の動作を表す図である。
FIG. 7 is a diagram illustrating an operation of a branch prediction table output selection control circuit according to a third embodiment of the present invention.

【図8】従来技術における問題点を説明するための図で
ある。
FIG. 8 is a diagram for explaining a problem in the related art.

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

1 プリフェッチ命令カウンタ 2 フェッチ命令カウンタ 3 命令レジスタ 4 比較アドレスレジスタ群 5 分岐先予測アドレスレジスタ群 6 分岐先予測アドレス有効レジスタ 7 分岐先予測アドレスレジスタ 8 加算器 9 登録エントリ選択デコーダ 10 セレクタ 11 比較器 12,13 セレクタ 14 分岐予測テーブル出力選択制御回路 15 アンドゲート 16 プリフェッチ命令カウンタ入力選択制御回路 17 命令キャッシュ 18 処理装置 REFERENCE SIGNS LIST 1 prefetch instruction counter 2 fetch instruction counter 3 instruction register 4 comparison address register group 5 branch destination prediction address register group 6 branch destination prediction address valid register 7 branch destination prediction address register 8 adder 9 registration entry selection decoder 10 selector 11 comparator 12 , 13 selector 14 branch prediction table output selection control circuit 15 AND gate 16 prefetch instruction counter input selection control circuit 17 instruction cache 18 processing unit

Claims (5)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 分岐命令の分岐履歴をこの分岐命令のM
(Mは正の整数)個前の命令と関連付けて保持する分岐
履歴保持手段と、 この分岐履歴保持手段を検索して次に分岐し得るアドレ
スを予測する分岐予測アドレス検索手段と、 この分岐予測アドレス検索手段によって検索された分岐
予測に関する情報を保持する分岐予測情報保持手段と、 直前に実行したM個の命令中に分岐の生起した分岐命令
が存在する場合には前記分岐予測情報保持手段に保持さ
れた分岐予測結果を使用しないように制御する分岐予測
制御手段とを含むことを特徴とする分岐予測装置。
1. The branch history of a branch instruction is stored in M
(M is a positive integer) a branch history holding unit that holds the instruction in association with the preceding instruction, a branch prediction address search unit that searches the branch history holding unit and predicts an address that can be taken next, A branch prediction information holding unit for holding information relating to a branch prediction searched by the address search unit; and a branch instruction where a branch has occurred among the M instructions executed immediately before, the branch prediction information holding unit. Branch prediction control means for controlling not to use the held branch prediction result.
【請求項2】 前記分岐履歴保持手段は、少なくとも一
つのエントリを有し各エントリに分岐命令の前回分岐し
たアドレスを保持する分岐履歴アドレス保持回路と、こ
の分岐履歴アドレス保持回路の各エントリに対応して分
岐命令の直前の命令の命令アドレスを保持する命令アド
レス保持回路と、この命令アドレス保持回路の各エント
リに対応してそのエントリの内容が有効なものであるか
否かを保持するエントリ有効性保持回路と、前記分岐履
歴アドレス保持回路の各エントリに対応して前記分岐命
令により前回分岐が生起したか否かを保持する分岐生起
保持回路とを有し、 前記分岐予測アドレス検索手段は、分岐命令の前記直前
の命令の命令アドレスによって前記命令アドレス保持回
路を検索するアドレス比較器と、このアドレス比較器に
おける比較結果によって前記エントリ有効性保持回路と
前記分岐履歴アドレス保持回路と前記分岐生起保持回路
とに保持された情報を選択する選択器とを有し、 前記分岐予測情報保持手段は、前記選択器により選択さ
れた前記エントリ有効性保持回路からの情報を保持する
分岐予測有効性保持回路と、前記選択器により選択され
た前記分岐履歴アドレス保持回路からの情報を保持する
分岐予測アドレス保持回路と、前記分岐生起保持回路か
らの情報を保持する分岐予測生起保持回路とを有し、 前記分岐予測制御手段は、前記分岐予測有効性保持回路
が有効である旨を保持し、かつ、前記分岐予測生起保持
回路が生起である旨を保持している場合には、直前に実
行した命令が分岐の生起した分岐命令であると判断して
前記分岐予測アドレス保持回路に保持されたアドレスを
分岐予測結果として使用しないように制御することを特
徴とする請求項1記載の分岐予測装置。
2. A branch history address holding circuit having at least one entry and holding in each entry the address of a previous branch instruction, and a branch history address holding circuit corresponding to each entry of the branch history address holding circuit. And an instruction address holding circuit for holding the instruction address of the instruction immediately before the branch instruction, and an entry validity holding for each entry of the instruction address holding circuit whether or not the contents of the entry are valid And a branch occurrence holding circuit that holds whether or not a previous branch has occurred by the branch instruction corresponding to each entry of the branch history address holding circuit. An address comparator for searching the instruction address holding circuit according to the instruction address of the instruction immediately before the branch instruction; A selector for selecting information held in the entry validity holding circuit, the branch history address holding circuit, and the branch occurrence holding circuit according to the comparison result in the branch prediction information holding means. A branch prediction validity holding circuit that holds information from the entry validity holding circuit selected by: a branch prediction address holding circuit that holds information from the branch history address holding circuit selected by the selector; A branch prediction occurrence holding circuit for holding information from the branch occurrence holding circuit, wherein the branch prediction control means holds that the branch prediction validity holding circuit is valid, and If the holding circuit holds that the branch has occurred, it is determined that the instruction executed immediately before is the branch instruction in which the branch has occurred, and the branch prediction address storage is performed. Branch predicting apparatus according to claim 1, wherein the controlling the address held in the circuit so as not to use as a branch prediction result.
【請求項3】 前記分岐履歴保持手段は、少なくとも一
つのエントリを有し各エントリに分岐命令の前回分岐し
たアドレスを保持する分岐履歴アドレス保持回路と、こ
の分岐履歴アドレス保持回路の各エントリに対応して分
岐命令の直前の命令の命令アドレスを保持する命令アド
レス保持回路と、この命令アドレス保持回路の各エント
リに対応してそのエントリの内容が有効なものであるか
否かを保持するエントリ有効性保持回路とを有し、 前記分岐予測アドレス検索手段は、分岐命令の前記直前
の命令の命令アドレスによって前記命令アドレス保持回
路を検索するアドレス比較器と、このアドレス比較器に
おける比較結果によって前記エントリ有効性保持回路と
前記分岐履歴アドレス保持回路とに保持された情報を選
択する選択器とを有し、 前記分岐予測情報保持手段は、前記選択器により選択さ
れた前記エントリ有効性保持回路からの情報を保持する
分岐予測有効性保持回路と、前記選択器により選択され
た前記分岐履歴アドレス保持回路からの情報を保持する
分岐予測アドレス保持回路とを有し、 前記分岐予測制御手段は、前記分岐予測有効性保持回路
が有効である旨を保持している場合には、直前に実行し
た命令が分岐の生起した分岐命令であると判断して前記
分岐予測アドレス保持回路に保持されたアドレスを分岐
予測結果として使用しないように制御することを特徴と
する請求項1記載の分岐予測装置。
3. A branch history address holding circuit having at least one entry and holding in each entry the address of a previous branch of a branch instruction, and a branch history address holding circuit corresponding to each entry of the branch history address holding circuit. And an instruction address holding circuit for holding the instruction address of the instruction immediately before the branch instruction, and an entry validity holding for each entry of the instruction address holding circuit whether or not the contents of the entry are valid An address comparator for searching the instruction address holding circuit according to the instruction address of the immediately preceding instruction of the branch instruction, and the entry according to a comparison result in the address comparator. A selector for selecting information held in the validity holding circuit and the branch history address holding circuit. The branch prediction information holding unit includes a branch prediction validity holding circuit that holds information from the entry validity holding circuit selected by the selector, and a branch prediction address holding circuit that stores information from the branch history address holding circuit selected by the selector. A branch prediction address holding circuit for holding information, and the branch prediction control means, when holding that the branch prediction validity holding circuit is valid, the instruction executed immediately before 2. The branch prediction apparatus according to claim 1, wherein it is determined that the generated branch instruction is a branch instruction, and control is performed such that the address held in the branch prediction address holding circuit is not used as a branch prediction result.
【請求項4】 前記分岐履歴保持手段は、少なくとも一
つのエントリを有し各エントリに分岐命令の前回分岐し
たアドレスを保持する分岐履歴アドレス保持回路と、こ
の分岐履歴アドレス保持回路の各エントリに対応して分
岐命令の前記M個前の命令の命令アドレスを保持する命
令アドレス保持回路と、この命令アドレス保持回路の各
エントリに対応してそのエントリの内容が有効なもので
あるか否かを保持するエントリ有効性保持回路と、前記
分岐履歴アドレス保持回路の各エントリに対応して前記
分岐命令により前回分岐が生起したか否かを保持する分
岐生起保持回路とを有し、 前記分岐予測アドレス検索手段は、分岐命令の前記M個
前の命令の命令アドレスによって前記命令アドレス保持
回路を検索するアドレス比較器と、このアドレス比較器
における比較結果によって前記エントリ有効性保持回路
と前記分岐履歴アドレス保持回路と前記分岐生起保持回
路とに保持された情報を選択する選択器とを有し、 前記分岐予測情報保持手段は、前記選択器により選択さ
れた前記エントリ有効性保持回路からの情報を保持する
分岐予測有効性保持回路と、前記選択器により選択され
た前記分岐履歴アドレス保持回路からの情報を保持する
分岐予測アドレス保持回路と、前記分岐生起保持回路か
らの情報を保持する分岐予測生起保持回路とを有し、 前記分岐予測制御手段は、分岐生起後(M−1)命令分
を計数する命令数カウンタをさらに有し、この命令数カ
ウンタが(M−1)命令分を計数している途中である場
合、もしくは、前記分岐予測有効性保持回路が有効であ
る旨を保持し、かつ、前記分岐予測生起保持回路が生起
である旨を保持している場合には、直前に実行したM個
の命令中に分岐の生起した分岐命令が存在すると判断し
て前記分岐予測アドレス保持回路に保持されたアドレス
を分岐予測結果として使用しないように制御することを
特徴とする請求項1記載の分岐予測装置。
4. A branch history address holding circuit having at least one entry and holding in each entry the address of a previous branch instruction, and a branch history address holding circuit corresponding to each entry of the branch history address holding circuit. And an instruction address holding circuit for holding the instruction address of the instruction M before the branch instruction, and for each entry of the instruction address holding circuit, whether or not the contents of the entry are valid. A branch validity holding circuit, and a branch occurrence holding circuit for holding whether or not a previous branch has occurred by the branch instruction corresponding to each entry of the branch history address holding circuit; Means for searching the instruction address holding circuit according to the instruction address of the instruction M before the branch instruction; A selector for selecting information held in the entry validity holding circuit, the branch history address holding circuit, and the branch occurrence holding circuit based on a comparison result in a comparator, wherein the branch prediction information holding means includes: A branch prediction validity holding circuit for holding information from the entry validity holding circuit selected by the selector, and a branch prediction address holding circuit for holding information from the branch history address holding circuit selected by the selector And a branch prediction occurrence holding circuit that holds information from the branch occurrence holding circuit, and the branch prediction control unit further includes an instruction number counter that counts (M−1) instructions after the branch occurrence. If the instruction number counter is in the course of counting (M-1) instructions, or holds that the branch prediction validity holding circuit is valid, On the other hand, when the branch prediction occurrence holding circuit holds that the branch is occurring, the branch prediction address holding circuit is determined by determining that the branch instruction in which the branch has occurred exists in the M instructions executed immediately before. 2. The branch prediction apparatus according to claim 1, wherein the control is performed such that the address held in the branch is not used as a branch prediction result.
【請求項5】 前記分岐履歴保持手段は、少なくとも一
つのエントリを有し各エントリに分岐命令の前回分岐し
たアドレスを保持する分岐履歴アドレス保持回路と、こ
の分岐履歴アドレス保持回路の各エントリに対応して分
岐命令の前記M個前の命令の命令アドレスを保持する命
令アドレス保持回路と、この命令アドレス保持回路の各
エントリに対応してそのエントリの内容が有効なもので
あるか否かを保持するエントリ有効性保持回路とを有
し、 前記分岐予測アドレス検索手段は、分岐命令の前記M個
前の命令の命令アドレスによって前記命令アドレス保持
回路を検索するアドレス比較器と、このアドレス比較器
における比較結果によって前記エントリ有効性保持回路
と前記分岐履歴アドレス保持回路とに保持された情報を
選択する選択器とを有し、 前記分岐予測情報保持手段は、前記選択器により選択さ
れた前記エントリ有効性保持回路からの情報を保持する
分岐予測有効性保持回路と、前記選択器により選択され
た前記分岐履歴アドレス保持回路からの情報を保持する
分岐予測アドレス保持回路とを有し、 前記分岐予測制御手段は、分岐生起後(M−1)命令分
を計数する命令数カウンタをさらに有し、この命令数カ
ウンタが(M−1)命令分を計数している途中である場
合、もしくは、前記分岐予測有効性保持回路が有効であ
る旨を保持している場合には、直前に実行したM個の命
令中に分岐の生起した分岐命令が存在すると判断して前
記分岐予測アドレス保持回路に保持されたアドレスを分
岐予測結果として使用しないように制御することを特徴
とする請求項1記載の分岐予測装置。
5. A branch history address holding circuit having at least one entry, wherein each entry holds an address of a previous branch of a branch instruction, and a branch history address holding circuit corresponding to each entry of the branch history address holding circuit. And an instruction address holding circuit for holding the instruction address of the instruction M before the branch instruction, and for each entry of the instruction address holding circuit, whether or not the contents of the entry are valid. An address validator that searches the instruction address holding circuit by the instruction address of the M-th previous instruction of the branch instruction; A selector for selecting information held in the entry validity holding circuit and the branch history address holding circuit according to a comparison result A branch prediction information holding unit that holds information from the entry validity holding circuit selected by the selector, and the branch history address selected by the selector. A branch prediction address holding circuit for holding information from a holding circuit, wherein the branch prediction control means further includes an instruction number counter for counting (M-1) instructions after the occurrence of the branch; Is being counted for (M-1) instructions, or if the branch prediction validity holding circuit holds that it is valid, the M instructions executed immediately before 2. The method according to claim 1, wherein it is determined that there is a branch instruction in which a branch has occurred, and the address held in the branch prediction address holding circuit is controlled so as not to be used as a branch prediction result. Prediction device.
JP6209501A 1994-09-02 1994-09-02 Branch prediction device Expired - Fee Related JP2629613B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP6209501A JP2629613B2 (en) 1994-09-02 1994-09-02 Branch prediction device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP6209501A JP2629613B2 (en) 1994-09-02 1994-09-02 Branch prediction device

Publications (2)

Publication Number Publication Date
JPH0876999A JPH0876999A (en) 1996-03-22
JP2629613B2 true JP2629613B2 (en) 1997-07-09

Family

ID=16573854

Family Applications (1)

Application Number Title Priority Date Filing Date
JP6209501A Expired - Fee Related JP2629613B2 (en) 1994-09-02 1994-09-02 Branch prediction device

Country Status (1)

Country Link
JP (1) JP2629613B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100498425B1 (en) * 1998-02-04 2005-09-08 삼성전자주식회사 Branch prediction device
US8006078B2 (en) 2007-04-13 2011-08-23 Samsung Electronics Co., Ltd. Central processing unit having branch instruction verification unit for secure program execution

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63124135A (en) * 1986-11-13 1988-05-27 Mitsubishi Electric Corp Data processor
JPH0760385B2 (en) * 1987-06-30 1995-06-28 三菱電機株式会社 Data processing device having branch prediction function
US5265213A (en) * 1990-12-10 1993-11-23 Intel Corporation Pipeline system for executing predicted branch target instruction in a cycle concurrently with the execution of branch instruction

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
日経エレクトロニクス、〜373!(1985−7−15)PP.233−279

Also Published As

Publication number Publication date
JPH0876999A (en) 1996-03-22

Similar Documents

Publication Publication Date Title
EP0084114B1 (en) Instruction prefetching data processing apparatus including a conditional branch instruction predictor
US4763245A (en) Branch prediction mechanism in which a branch history table is updated using an operand sensitive branch table
US5687360A (en) Branch predictor using multiple prediction heuristics and a heuristic identifier in the branch instruction
JP2500958B2 (en) Digital data processor operating method and branch history table
EP0429790A2 (en) Methods and apparatus for insulating a branch prediction mechanism from data dependent branch table updates
US5297281A (en) Multiple sequence processor system
EP0125855B1 (en) Buffer-storage control system
JP3486690B2 (en) Pipeline processor
JP3798998B2 (en) Branch prediction apparatus and branch prediction method
JP3848161B2 (en) Memory access device and method using address translation history table
JP2629613B2 (en) Branch prediction device
US5732254A (en) Pipeline system branch history table storing branch instruction addresses and target addresses with inhibit bits
US5812837A (en) Data processing apparatus for controlling an interrupt process and its method
JPS5991551A (en) Instruction prefetching device forecasting address to be branched
JPH046983B2 (en)
JP2778610B2 (en) Pipeline operation control method and system
JP3558481B2 (en) Data processing device
JP2542565B2 (en) Branch predictive control method
JP2658342B2 (en) Data processing device
JP4049490B2 (en) Information processing device
JPH06301537A (en) Instruction fetching circuit
JPS6411973B2 (en)
JPS5991552A (en) Instruction prefetch device having set associative type history table
JPH04355833A (en) Branch history table control circuit
JPH06243043A (en) Entry clearing device for address conversion buffer

Legal Events

Date Code Title Description
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 19970225

LAPS Cancellation because of no payment of annual fees