JPH0895785A - Branch predicting device - Google Patents
Branch predicting deviceInfo
- Publication number
- JPH0895785A JPH0895785A JP23464494A JP23464494A JPH0895785A JP H0895785 A JPH0895785 A JP H0895785A JP 23464494 A JP23464494 A JP 23464494A JP 23464494 A JP23464494 A JP 23464494A JP H0895785 A JPH0895785 A JP H0895785A
- Authority
- JP
- Japan
- Prior art keywords
- branch
- instruction
- address
- flag
- branching
- 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.)
- Pending
Links
Landscapes
- Advance Control (AREA)
Abstract
Description
【0001】[0001]
【産業上の利用分野】本発明はCPUの分岐予測装置に
関する。BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a CPU branch prediction device.
【0002】[0002]
【従来の技術】図2は従来のCPUの分岐予測装置のブ
ロック図である。2. Description of the Related Art FIG. 2 is a block diagram of a conventional CPU branch prediction device.
【0003】図2において、プログラム2−9が分岐命
令を使用するとCPU2−1内の命令先読み部2−5が
この分岐命令を読み込む。分岐命令を読み込むと、分岐
アドレス記憶部2−6からその分岐命令のアドレスで検
索を行い、一致する分岐命令アドレス2−7を有するエ
ントリから分岐先アドレス2−8を得、この分岐先アド
レスより以降の命令を順次に先読みする。これは過去に
発生した分岐を分岐アドレス記憶部2−6に記憶してお
いて、同じアドレスの分岐は同じ分岐を行うものとして
分岐先の予測をするものである。In FIG. 2, when the program 2-9 uses a branch instruction, the instruction prefetching unit 2-5 in the CPU 2-1 reads this branch instruction. When the branch instruction is read, a search is performed from the branch address storage unit 2-6 with the address of the branch instruction, the branch destination address 2-8 is obtained from the entry having the matching branch instruction address 2-7, and from this branch destination address Subsequent instructions are prefetched in sequence. This is to predict the branch destination by storing the branches that have occurred in the past in the branch address storage unit 2-6 and assuming that the branches having the same address are the same branches.
【0004】一方、命令解析部2−4は命令先読み部2
−5より受け取った命令を解析して命令実行部2−3に
渡す。命令実行部2−3は命令解析部2−4より受け取
った命令を実行する。この場合、受け取った命令が分岐
命令の場合には、命令先読み部2−5で予測した分岐先
アドレス2−8が、解析して得た分岐先アドレスとして
正しいかどうかを判断し、正しければそのまま分岐を実
行する。しかし、間違っている場合は、先読みした命令
を全て無効とし、命令先読み部2−5は、解析結果によ
る正しいアドレスから命令の先読みを行い、また分岐ア
ドレス記憶部2−6の分岐先アドレス2−8を更新す
る。On the other hand, the instruction analysis section 2-4 is composed of the instruction prefetch section 2
The instruction received from -5 is analyzed and passed to the instruction execution section 2-3. The instruction execution unit 2-3 executes the instruction received from the instruction analysis unit 2-4. In this case, when the received instruction is a branch instruction, it is judged whether the branch destination address 2-8 predicted by the instruction prefetching unit 2-5 is correct as the branch destination address obtained by analysis, and if it is correct, it is left as it is. Take a branch. However, if it is incorrect, all the prefetched instructions are invalidated, the instruction prefetch unit 2-5 prefetches the instruction from the correct address according to the analysis result, and the branch destination address 2-of the branch address storage unit 2-6. Update 8.
【0005】[0005]
【発明が解決しようとする課題】上述した従来の分岐予
測装置では、過去の分岐結果と同じ分岐を行うものとし
て予測して先読みしているが、必ずしも予測が当たると
いうものではなかったため、予測がはずれた場合には、
命令の再読み込みを行う必要があるので、命令の実行速
度が低下するという欠点がある。In the above-described conventional branch prediction device, prediction is performed assuming that the same branch as the past branch result is taken and prefetching is performed, but the prediction is not necessarily correct, and therefore the prediction is not correct. If it comes off,
Since it is necessary to reload the instruction, there is a drawback that the instruction execution speed decreases.
【0006】[0006]
【課題を解決するための手段】本発明の分岐予測装置
は、プログラム内の命令によって分岐命令の前に予め分
岐の有無が設定される分岐フラグと、過去に発生した分
岐命令のアドレスごとに分岐先アドレスを記憶する分岐
アドレス記憶部と、メモリから命令を順次に読み込み、
分岐命令を読み込んだとき前記分岐フラグにより分岐の
有無を判断して分岐が設定されている場合にのみ、前記
分岐アドレス記憶部より分岐命令のアドレスで検索を行
い、一致する分岐命令アドレスのエントリから分岐先ア
ドレスを得、そのアドレス以降の命令を順次に読み込む
命令先読み部とを有することを特徴とする。A branch prediction apparatus according to the present invention branches according to a branch flag in which the presence or absence of a branch is set in advance by a command in a program and the address of a branch command that occurred in the past. A branch address storage unit that stores the destination address and instructions are sequentially read from the memory,
When a branch instruction is read, the presence or absence of a branch is judged by the branch flag, and only when the branch is set, a search is performed from the branch address storage unit with the address of the branch instruction, and the entry of the matching branch instruction address is searched. An instruction prefetch unit for obtaining a branch destination address and sequentially reading the instructions after the address is provided.
【0007】[0007]
【実施例】本発明の一実施例の構成を示す図1を参照す
ると、本実施例は、命令実行部1−3,命令解析部1−
4,命令先読み部1−5,分岐アドレス記憶部1−6お
よび分岐フラグ1−10を有するCPU1−1と、プロ
グラム1−9を記憶するメモリ1−2とで構成されてい
る。分岐アドレス記憶部1−6は、過去に発生した分岐
アドレス1−7ごとに分岐先アドレス1−8を記憶して
いる。また分岐フラグ1−10には、プログラム1−9
内の分岐フラグ設定命令によって、分岐命令の前に予め
分岐の有無が設定される。DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Referring to FIG. 1 showing the configuration of an embodiment of the present invention, the present embodiment is composed of an instruction executing section 1-3 and an instruction analyzing section 1-
4, a CPU 1-1 having an instruction prefetching unit 1-5, a branch address storage unit 1-6 and a branch flag 1-10, and a memory 1-2 storing a program 1-9. The branch address storage unit 1-6 stores a branch destination address 1-8 for each branch address 1-7 generated in the past. The branch flag 1-10 contains the program 1-9.
By the branch flag setting instruction in, the presence / absence of branch is set in advance before the branch instruction.
【0008】次に本実施例の動作を説明する。Next, the operation of this embodiment will be described.
【0009】先ず、分岐フラグ1−10の設定について
述べる。分岐フラグ1−10は、例えば外部ポートから
入出力デバイスの分岐条件をプログラム1−9によって
読み込み、プログラム1−9内の定数または変数と比較
する。その比較した結果を分岐フラグ設定のための命令
で分岐フラグ1−10に設定する。この設定は、プログ
ラム1−9内の分岐命令ステップ前に行なわれる必要が
あるので、分岐フラグ設定のための命令は、そのような
条件を満たす命令ステップに設置される。First, the setting of the branch flag 1-10 will be described. The branch flag 1-10 reads, for example, a branch condition of an input / output device from an external port by the program 1-9 and compares it with a constant or variable in the program 1-9. The comparison result is set in the branch flag 1-10 by the instruction for setting the branch flag. Since this setting needs to be performed before the branch instruction step in the program 1-9, the instruction for setting the branch flag is set at the instruction step satisfying such a condition.
【0010】さて、命令先読み部1−5は分岐命令を読
み込むまでは順次にメモリ1−2から命令を読み込んで
いる。分岐命令を読み込むと命令先読み部1−5は分岐
フラグ1−10の内容により、分岐の有無を判断し、分
岐フラグ1−10が分岐を表示している場合には分岐ア
ドレス記憶部1−6より分岐命令アドレスで検索を行
い、一致する分岐命令アドレス1−7をもつエントリか
ら分岐先アドレス1−8を得、分岐先アドレスより以降
の命令を順次読み込む。一方、分岐フラグ1−10が分
岐を表示していない場合には、分岐命令であるにも拘わ
らず、分岐先アドレス1−8によらずプログラム1−9
の命令ステップ順に命令を読み込んでいく。By the way, the instruction prefetching unit 1-5 sequentially reads instructions from the memory 1-2 until the branch instructions are read. When the branch instruction is read, the instruction prefetching unit 1-5 determines the presence / absence of a branch based on the contents of the branch flag 1-10. If the branch flag 1-10 indicates a branch, the branch address storage unit 1-6. The branch instruction address is searched, the branch destination address 1-8 is obtained from the entry having the matching branch instruction address 1-7, and the subsequent instructions are sequentially read from the branch destination address. On the other hand, when the branch flag 1-10 does not indicate a branch, the program 1-9 is executed regardless of the branch destination address 1-8, although the branch instruction is executed.
The commands are read in the order of the command step.
【0011】命令解析部1−4は命令先読み部1−5よ
り受け取った命令を解析して命令実行部1−3に渡す。
命令実行部1−3は命令解析部1−4より受け取った命
令を実行する。受け取った命令が分岐命令の場合、命令
先読み部1−5で予測した分岐先アドレス1−8が正し
いかどうかを判断し、正しければそのまま分岐を実行す
る。間違っている場合は先読みした命令を全て無効と
し、命令先読み部1−5は正しいアドレスから命令の先
読みを行い、分岐アドレス記憶部1−6の分岐先アドレ
スを更新する。分岐フラグ1−10は、命令実行部1−
3が命令を実行するとクリアされる。The instruction analyzing section 1-4 analyzes the instruction received from the instruction prefetching section 1-5 and transfers it to the instruction executing section 1-3.
The instruction execution unit 1-3 executes the instruction received from the instruction analysis unit 1-4. When the received instruction is a branch instruction, the instruction prefetch unit 1-5 determines whether or not the predicted branch destination address 1-8 is correct, and if correct, the branch is executed as it is. If it is wrong, all the prefetched instructions are invalidated, the instruction prefetch unit 1-5 prefetches the instruction from the correct address, and updates the branch destination address of the branch address storage unit 1-6. The branch flag 1-10 is used by the instruction execution unit 1-
Cleared when 3 executes the instruction.
【0012】[0012]
【発明の効果】以上説明したように本発明は、CPUの
分岐予測において、分岐フラグを設置し、プログラムが
分岐命令を使用する前に予め設定することによって、分
岐先アドレスを動的に変更するものでない限り発生した
分岐が2度目以降の場合、命令先読み部での分岐の予測
が確実に当たるようになるため、命令の再読み込みによ
るCPUの命令実行速度の低下を防止できる効果があ
る。As described above, according to the present invention, the branch destination address is dynamically changed by setting the branch flag in the branch prediction of the CPU and setting it before the program uses the branch instruction. Unless it is a branch, if the branch that has occurred is the second or later branch, the prediction of the branch in the instruction prefetching section will be performed correctly, so that there is an effect that the reduction of the instruction execution speed of the CPU due to the reloading of the instruction can be prevented.
【図1】本発明の一実施例のブロック図である。FIG. 1 is a block diagram of one embodiment of the present invention.
【図2】従来例のブロック図である。FIG. 2 is a block diagram of a conventional example.
1−1,2−1 CPU 1−2,2−2 メモリ 1−3,2−3 命令実行部 1−4,2−4 命令解析部 1−5,2−5 命令先読み部 1−6,2−6 分岐アドレス記憶部 1−7,2−7 分岐命令アドレス 1−8,2−8 分岐先アドレス 1−9,2−9 プログラム 1−10 分岐フラグ 1-1,2-1 CPU 1-2, 2-2 memory 1-3, 2-3 instruction execution unit 1-4, 2-4 instruction analysis unit 1-5, 2-5 instruction prefetch unit 1-6, 2-6 Branch address storage unit 1-7, 2-7 Branch instruction address 1-8, 2-8 Branch destination address 1-9, 2-9 Program 1-10 Branch flag
Claims (2)
前に予め分岐の有無が設定される分岐フラグと、 過去に発生した分岐命令のアドレスごとに分岐先アドレ
スを記憶する分岐アドレス記憶部と、 メモリから命令を順次に読み込み、分岐命令を読み込ん
だとき前記分岐フラグにより分岐の有無を判断して分岐
が設定されている場合にのみ、前記分岐アドレス記憶部
より分岐命令のアドレスで検索を行い、一致する分岐命
令アドレスのエントリから分岐先アドレスを得、そのア
ドレス以降の命令を順次に読み込む命令先読み部とを有
することを特徴とする分岐予測装置。1. A branch flag in which presence / absence of a branch is set in advance before a branch instruction by an instruction in a program, a branch address storage unit that stores a branch destination address for each address of a branch instruction that occurred in the past, and a memory. From the branch address storage unit to search for the branch instruction address and match only if the branch flag is judged by the branch flag when the branch instruction is read and the branch is set. A branch prediction device having a branch destination address from an entry of a branch instruction address to be read, and an instruction prefetch unit for sequentially reading instructions after the address.
入出力デバイスの分岐条件と、前記プログラム内の定数
もしくは変数の値との比較結果によって設定されること
を特徴とする請求項1記載の分岐予測装置。2. The branch according to claim 1, wherein the branch flag is set by a result of comparison between a branch condition of an input / output device read from the outside and a value of a constant or a variable in the program. Prediction device.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP23464494A JPH0895785A (en) | 1994-09-29 | 1994-09-29 | Branch predicting device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP23464494A JPH0895785A (en) | 1994-09-29 | 1994-09-29 | Branch predicting device |
Publications (1)
Publication Number | Publication Date |
---|---|
JPH0895785A true JPH0895785A (en) | 1996-04-12 |
Family
ID=16974260
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP23464494A Pending JPH0895785A (en) | 1994-09-29 | 1994-09-29 | Branch predicting device |
Country Status (1)
Country | Link |
---|---|
JP (1) | JPH0895785A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2000067255A1 (en) * | 1999-04-30 | 2000-11-09 | Fujitsu Limited | Disk apparatus |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS50114944A (en) * | 1974-02-18 | 1975-09-09 | ||
JPS5497341A (en) * | 1978-01-19 | 1979-08-01 | Toshiba Corp | Microprogram control system |
JPS5566028A (en) * | 1978-11-10 | 1980-05-19 | Nec Corp | Information processing unit |
JPS56114051A (en) * | 1980-02-14 | 1981-09-08 | Mitsubishi Electric Corp | Data process system |
JPS59183434A (en) * | 1983-04-01 | 1984-10-18 | Nippon Telegr & Teleph Corp <Ntt> | Prefetch control system of instruction |
JPS63168730A (en) * | 1987-01-07 | 1988-07-12 | Matsushita Electric Ind Co Ltd | Branching instruction processor |
-
1994
- 1994-09-29 JP JP23464494A patent/JPH0895785A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS50114944A (en) * | 1974-02-18 | 1975-09-09 | ||
JPS5497341A (en) * | 1978-01-19 | 1979-08-01 | Toshiba Corp | Microprogram control system |
JPS5566028A (en) * | 1978-11-10 | 1980-05-19 | Nec Corp | Information processing unit |
JPS56114051A (en) * | 1980-02-14 | 1981-09-08 | Mitsubishi Electric Corp | Data process system |
JPS59183434A (en) * | 1983-04-01 | 1984-10-18 | Nippon Telegr & Teleph Corp <Ntt> | Prefetch control system of instruction |
JPS63168730A (en) * | 1987-01-07 | 1988-07-12 | Matsushita Electric Ind Co Ltd | Branching instruction processor |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2000067255A1 (en) * | 1999-04-30 | 2000-11-09 | Fujitsu Limited | Disk apparatus |
US6701413B2 (en) | 1999-04-30 | 2004-03-02 | Fujitsu Limited | Disk drive performing a read-ahead operation of the data from the disk |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US4858104A (en) | Preceding instruction address based branch prediction in a pipelined processor | |
EP1889152B1 (en) | A method and apparatus for predicting branch instructions | |
US4974154A (en) | Computer with instruction prefetch queue retreat unit | |
KR20090094335A (en) | Methods and apparatus for recognizing a subroutine call | |
US5761490A (en) | Changing the meaning of a pre-decode bit in a cache memory depending on branch prediction mode | |
US6631459B1 (en) | Extended instruction word folding apparatus | |
US6119221A (en) | Instruction prefetching apparatus and instruction prefetching method for processing in a processor | |
US5729707A (en) | Instruction prefetch circuit and cache device with branch detection | |
KR100317240B1 (en) | Branch predictor using branch prediction accuracy history | |
US7797520B2 (en) | Early branch instruction prediction | |
JPH0895785A (en) | Branch predicting device | |
US6182211B1 (en) | Conditional branch control method | |
US5954814A (en) | System for using a branch prediction unit to achieve serialization by forcing a branch misprediction to flush a pipeline | |
US20030131345A1 (en) | Employing value prediction with the compiler | |
JP2002342075A (en) | Microprocessor | |
JP2508021B2 (en) | Data processing device | |
JPH1124923A (en) | Microprocessor | |
JPH0342723A (en) | Data processor | |
KR100240590B1 (en) | Apparatus and Methed for decoding instruction in superscalar Microprocessor | |
JP2591325B2 (en) | Branch control device | |
JPH0553807A (en) | Condition branching instruction prefetch control system | |
JPH0749782A (en) | Information processor | |
JPH0540624A (en) | Instruction fetching device for microprocessor of integrated circuit | |
JPH06175848A (en) | High-speed branch processing method of central processing unit | |
JPH04213727A (en) | Information processor |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 19961126 |