JPH0758463B2 - Data processing device - Google Patents

Data processing device

Info

Publication number
JPH0758463B2
JPH0758463B2 JP61204500A JP20450086A JPH0758463B2 JP H0758463 B2 JPH0758463 B2 JP H0758463B2 JP 61204500 A JP61204500 A JP 61204500A JP 20450086 A JP20450086 A JP 20450086A JP H0758463 B2 JPH0758463 B2 JP H0758463B2
Authority
JP
Japan
Prior art keywords
instruction
branch
address
data processing
displacement
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
JP61204500A
Other languages
Japanese (ja)
Other versions
JPS6359630A (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.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric 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 Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP61204500A priority Critical patent/JPH0758463B2/en
Publication of JPS6359630A publication Critical patent/JPS6359630A/en
Priority to US08/340,462 priority patent/US5440704A/en
Publication of JPH0758463B2 publication Critical patent/JPH0758463B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Description

【発明の詳細な説明】 [産業上の利用分野] この発明はデータ処理装置に関し、特に、パイプライン
機構を有するようなデータ処理装置に関する。
The present invention relates to a data processing device, and more particularly to a data processing device having a pipeline mechanism.

[従来の技術] 第2図は従来のパイプライン機構を有するデータ処理装
置において命令を処理する場合の機構を示した図であ
る。第2図において、データ処理装置はフェッチデコー
ド機構1と命令実行機構2と番地生成機構3とから構成
される。フェッチデコード機構1は命令のフェッチおよ
びデコードをするものであり、命令実行機構2は命令を
実行するものである。番地生成機構3はフェッチデコー
ド機構1にフェッチされデコードされている命令の番地
を示すプログラムカウンタ(以下、デコード用のプログ
ラムカウンタと称する)31と、加算器32とによって構成
され、或る命令をフェッチ,デコードした後、次にフェ
ッチすべき命令の番地を生成するものである。
[Prior Art] FIG. 2 is a diagram showing a mechanism for processing an instruction in a data processing device having a conventional pipeline mechanism. In FIG. 2, the data processing device comprises a fetch decode mechanism 1, an instruction execution mechanism 2 and an address generation mechanism 3. The fetch / decode mechanism 1 fetches and decodes an instruction, and the instruction execution mechanism 2 executes an instruction. The address generation mechanism 3 is composed of a program counter (hereinafter referred to as a decoding program counter) 31 indicating the address of an instruction fetched and decoded by the fetch decoding mechanism 1 and an adder 32, and fetches a certain instruction. After decoding, the address of the instruction to be fetched next is generated.

次に、動作について説明する。フェッチデコード機構1
に命令がフェッチされるとともに、デコードされ、それ
と同時に番地生成機構3ではフェッチされた命令の長さ
がデコード用のプログラムカウンタ31に加えられ、次に
フェッチすべき命令のアドレスが計算される。次に、命
令が命令実行機構2に移って実行されると同時に、フェ
ッチデコード機構1へは新たな次の命令がデコード用の
プログラムカウンタ31が示すアドレスよりフェッチさ
れ、デコードされる。
Next, the operation will be described. Fetch decoding mechanism 1
The instruction is fetched and decoded, and at the same time, the address generation mechanism 3 adds the length of the fetched instruction to the program counter 31 for decoding, and calculates the address of the instruction to be fetched next. Next, the instruction is transferred to the instruction execution mechanism 2 and executed, and at the same time, a new next instruction is fetched from the address indicated by the decoding program counter 31 and decoded by the fetch decoding mechanism 1.

[発明が解決しようとする問題点] 従来のデータ処理装置は上述のごとく構成されているの
で、条件ブランチ命令がフェッチされかつデコードさ
れ、それが命令実行機構2に移ると、フェッチデコード
機構1では、プログラム上の条件ブランチ命令の次に位
置する命令がフェッチされかつデコードされ、条件ブラ
ンチ命令を実行する。その結果、ブランチが起こった場
合には、既にフェッチされデコード中の命令をキャンセ
ルしなければならず、ブランチの飛び先番地より次の命
令のフェッチをやり直すことが必要となる。もし、パイ
プラインの1ステージに1マシンサイクルがかかるとす
れば、条件ブランチ命令には結局2マシンサイクルかか
ることになり、スループットが低下するという問題点が
あった。
[Problems to be Solved by the Invention] Since the conventional data processing device is configured as described above, when the conditional branch instruction is fetched and decoded and transferred to the instruction execution mechanism 2, the fetch decode mechanism 1 , The instruction located next to the conditional branch instruction in the program is fetched and decoded, and the conditional branch instruction is executed. As a result, when a branch occurs, the instruction that has already been fetched and is being decoded must be canceled, and the fetching of the next instruction from the jump destination address of the branch must be redone. If one stage of the pipeline takes one machine cycle, the conditional branch instruction will eventually take two machine cycles, resulting in a problem of lower throughput.

それゆえに、この発明の主たる目的は、条件ブランチ命
令を実行した場合に起こるパイプラインが乱れる頻度を
できる限り小さくするようにし、スループットを上げる
ことのできるようなデータ処理装置を提供することであ
る。
Therefore, a main object of the present invention is to provide a data processor capable of increasing the throughput by minimizing the frequency of disturbance of the pipeline that occurs when a conditional branch instruction is executed.

[問題点を解決するための手段] この発明にかかるデータ処理装置は、第1の機構と第2
の機構とがパイプライン処理の原理で命令を処理し、第
1の機構で第1の時期に処理している第1の命令の番地
をもとにして、第1の時期に引続く第2の時期に第1の
機構で処理すべき第2の命令の番地を計算し、条件分岐
命令がフェッチされデコードされた場合に、分岐が起こ
るか否かをパイプラインの初期のステージで予測し、分
岐が起こると判断されたとき、条件分岐命令の分岐条件
を反転するとともに条件分岐命令の変位と条件分岐命令
の命令長とを入替えるように構成したものである。
[Means for Solving Problems] A data processing device according to the present invention includes a first mechanism and a second mechanism.
The second mechanism continues the first period based on the address of the first instruction processed by the first mechanism at the first period. , The address of the second instruction to be processed by the first mechanism is calculated, and when the conditional branch instruction is fetched and decoded, it is predicted in the early stage of the pipeline whether a branch will occur, When it is determined that a branch will occur, the branch condition of the conditional branch instruction is reversed, and the displacement of the conditional branch instruction and the instruction length of the conditional branch instruction are interchanged.

[作用] この発明におけるデータ処理装置は、ブランチ命令がフ
ェッチされた場合にブランチが起こるかどうかをパイプ
ラインの初期のステージで予測してブランチが起こると
判断されたら、条件ブランチ命令のブランチ条件を反転
するとともに、ブランチの変位をその命令長と置換えて
やり、次のステージへその命令長を移し、ブランチの変
位を加えるとともに、ブランチの飛び先番地より次の命
令をフェッチする。
[Operation] The data processing device according to the present invention predicts whether a branch will occur when a branch instruction is fetched at an early stage of the pipeline, and if it is determined that the branch will occur, the branch condition of the conditional branch instruction is set. While inverting, the displacement of the branch is replaced with its instruction length, the instruction length is moved to the next stage, the displacement of the branch is added, and the next instruction is fetched from the jump destination address of the branch.

[発明の実施例] 第1図はこの発明の一実施例の概略ブロック図である。
この第1図に示した実施例において、フェッチデコード
機構1と命令実行機構2と番地生成機構3は前述の第2
図と同様にして構成され、さらに予測テーブル4と命令
長置換機構5とが設けられる。予測テーブル4はフェッ
チデコード機構1から与えられる条件ブランチ命令によ
って実際にブランチが起こるか否かを、その命令の過去
の振舞いによって予測するテーブルである。この予測テ
ーブル4には、条件ブランチ命令と、それが実際に起こ
るか否かを予測するためのフラグが記憶されている。そ
して、ブラグが立っていれば、ブランチが起こるであろ
うことを意味する。命令長置換機構5は条件ブランチ命
令のデコード結果の中のブランチ条件を示すビットを反
転する。たとえば、ゼロフラグが立っていればブランチ
するというのをゼロフラグが立っていなければブランチ
するというように変える。そして、デコード結果の中の
ブランチの変位をその命令の命令長に置換える。すなわ
ち、命令置換え機構5は予測テーブル4でブランチが起
こると予測されると、フェッチデコード機構1からの条
件ブランチ命令の変位をその命令の命令長に置換え、番
地生成機構3に含まれるプログラムカウンタ31にはフェ
ッチデコード期間中に命令長の代わりにブランチ変位を
加算し、命令実行機構2に含まれるプログラムカウンタ
(番地生成機構3に含まれるプログラムカウンタとは別
に命令実行機構2の中にある)には命令実行期間中にブ
ランチ変位の代わりに命令長が加算される。
Embodiment of the Invention FIG. 1 is a schematic block diagram of an embodiment of the present invention.
In the embodiment shown in FIG. 1, the fetch decode mechanism 1, the instruction execution mechanism 2 and the address generation mechanism 3 are the same as those in the second embodiment.
The configuration is similar to that of the figure, and a prediction table 4 and an instruction length replacement mechanism 5 are further provided. The prediction table 4 is a table for predicting whether or not a branch will actually occur by a conditional branch instruction given from the fetch decoding mechanism 1 based on the past behavior of the instruction. The prediction table 4 stores a conditional branch instruction and a flag for predicting whether or not it actually occurs. And if Bragg stands, it means that a branch will happen. The instruction length substitution mechanism 5 inverts the bit indicating the branch condition in the decoding result of the conditional branch instruction. For example, change from branching if the zero flag is set to branching if the zero flag is not set. Then, the displacement of the branch in the decoding result is replaced with the instruction length of the instruction. That is, when it is predicted that a branch will occur in the prediction table 4, the instruction replacement mechanism 5 replaces the displacement of the conditional branch instruction from the fetch decode mechanism 1 with the instruction length of that instruction, and the program counter 31 included in the address generation mechanism 3 Is added to the branch displacement instead of the instruction length during the fetch decoding period, and is added to the program counter included in the instruction execution mechanism 2 (in the instruction execution mechanism 2 separately from the program counter included in the address generation mechanism 3). Is added with the instruction length instead of the branch displacement during the instruction execution period.

次に、この発明の一実施例の具体的な動作について説明
する。フェッチデコード機構1に命令が来て、それが通
常の命令であれば、フェッチデコード機構1はその命令
をデコードし、その命令長を、命令長置換機構5を介し
て番地生成機構3のプログラムカウンタ31に加える。し
かしながら、フェッチデコード機構1に与えられた命令
が条件ブランチ命令であるとわかると、予測テーブル4
に基づいてブランチが起こるか否かが予測される。ブラ
ンチの起こることが予測されると、命令長置換機構5は
その条件ブランチ命令の変位とその命令長を交換し、ブ
ランチの条件を反転する。たとえば、Zフラグが立って
いればブランチするに対してZフラグが立っていなけれ
ばブランチするに置換えてやる。そして、命令実行機構
2には変位の代わりに命令長を与え、プログラムカウン
タ31には命令長の代わりに変位を加える。
Next, a specific operation of the embodiment of the present invention will be described. If an instruction comes to the fetch decode mechanism 1 and it is a normal instruction, the fetch decode mechanism 1 decodes the instruction, and the instruction length is transferred to the program counter of the address generation mechanism 3 via the instruction length replacement mechanism 5. Add to 31. However, when it is found that the instruction given to the fetch decoding mechanism 1 is a conditional branch instruction, the prediction table 4
Based on, it is predicted whether a branch will occur. When it is predicted that a branch will occur, the instruction length replacement mechanism 5 exchanges the displacement of the conditional branch instruction and its instruction length, and reverses the condition of the branch. For example, if the Z flag is set, branch is performed, whereas if the Z flag is not set, branch is performed. Then, an instruction length is given to the instruction execution mechanism 2 instead of the displacement, and a displacement is added to the program counter 31 instead of the instruction length.

そして、フェッチデコード機構1はブランチの飛び先番
地から次の命令をフェッチする。もし、フェッチデコー
ド機構1での予測が外れても、条件ブランチ命令のブラ
ンチ条件が反転されていて、なおかつブランチの変位は
その命令長に置換えられているので、命令実行機構2に
おいてプログラム上の条件ブランチ命令の次に位置する
命令へのブランチが起こり、フェッチデコード機構1へ
はこの命令がフェッチ,デコードされ、結局ブランチ条
件を反転する前の条件ブランチが起こらなかったのと同
じ動作が得られる。
Then, the fetch decoding mechanism 1 fetches the next instruction from the jump destination address of the branch. Even if the prediction in the fetch decode mechanism 1 is wrong, the branch condition of the conditional branch instruction is inverted, and the displacement of the branch is replaced by the instruction length, so that the instruction execution mechanism 2 has a program condition. A branch to the instruction located next to the branch instruction occurs, this instruction is fetched and decoded by the fetch decoding mechanism 1, and the same operation as that when the conditional branch before the branch condition is inverted does not occur is obtained.

なお、ブランチが起こると予測された場合にブランチ条
件を反転する代わりに、命令実行機構2での実行シーケ
ンスをブランチ条件が成立しなければブランチを起こす
ようなものにする(通常はブランチ条件が成立すれば、
ブランチを起こす)方法もある。
Instead of reversing the branch condition when it is predicted that a branch will occur, the execution sequence of the instruction execution mechanism 2 is set so that the branch is taken if the branch condition is not satisfied (normally, the branch condition is satisfied). if,
There is also a way to make a branch.

[発明の効果] 以上のように、この発明によれば、前もって条件ブラン
チ命令の実行結果を高い確率で予測することにより、条
件ブランチ命令の次にパイプラインに取込まれる命令が
フェッチ,デコードだけされて実行ステージへ行くまで
にキャンセルされ、新たに命令をフェッチし、デコード
し直さなければならない確率が減少するので、パイプラ
インの乱れる頻度が減少し、スループットを向上でき
る。
[Effects of the Invention] As described above, according to the present invention, by predicting the execution result of a conditional branch instruction in advance with a high probability, the only instruction fetched into the pipeline next to the conditional branch instruction is fetch and decode. Therefore, the probability of having to be fetched and decoded again by the time it goes to the execution stage and to be executed again is reduced, so that the pipeline is less disturbed and throughput can be improved.

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

第1図はこの発明の一実施例の概略ブロック図である。
第2図は従来のデータ処理装置の概略ブロック図であ
る。 図において、1はフェッチデコード機構、2は命令実行
機構、3は番地生成機構、4は予測テーブル、5は命令
長置換機構、31はプログラムカウンタ、32は加算器を示
す。
FIG. 1 is a schematic block diagram of an embodiment of the present invention.
FIG. 2 is a schematic block diagram of a conventional data processing device. In the figure, 1 is a fetch decode mechanism, 2 is an instruction execution mechanism, 3 is an address generation mechanism, 4 is a prediction table, 5 is an instruction length replacement mechanism, 31 is a program counter, and 32 is an adder.

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】第1の機構と第2の機構とを含み、前記第
1の機構と前記第2の機構とがパイプライン処理の原理
で命令を処理する命令処理手段と、 前記第1の機構で第1の時期に処理している第1の命令
の番地をもとにして、前記第1の時期に引続く第2の時
期に前記第1の機構で処理すべき第2の命令の番地を計
算する命令番地計算手段と、 前記第1の命令が分岐を起こすか否かを予測する分岐予
測手段と、 前記第1の命令によって示される分岐先命令までの変位
と前記第1の命令の命令長とを入替処理する変位入替手
段と、 前記分岐予測手段によって分岐を起こすことが判別され
たことに応じて、分岐条件を反転する分岐条件反転手段
とを備えたデータ処理装置。
1. An instruction processing unit including a first mechanism and a second mechanism, wherein the first mechanism and the second mechanism process an instruction on the principle of pipeline processing, and the first mechanism. Based on the address of the first instruction processed by the mechanism at the first time, the second instruction to be processed by the first mechanism at the second time subsequent to the first time is processed. Instruction address calculation means for calculating an address, branch prediction means for predicting whether or not the first instruction causes a branch, displacement to a branch destination instruction indicated by the first instruction, and the first instruction A data processing apparatus comprising: a displacement replacement unit that replaces the instruction length of 1. and a branch condition inversion unit that inverts a branch condition when the branch prediction unit determines that a branch will occur.
JP61204500A 1986-08-26 1986-08-29 Data processing device Expired - Fee Related JPH0758463B2 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP61204500A JPH0758463B2 (en) 1986-08-29 1986-08-29 Data processing device
US08/340,462 US5440704A (en) 1986-08-26 1994-11-14 Data processor having branch predicting function

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP61204500A JPH0758463B2 (en) 1986-08-29 1986-08-29 Data processing device

Publications (2)

Publication Number Publication Date
JPS6359630A JPS6359630A (en) 1988-03-15
JPH0758463B2 true JPH0758463B2 (en) 1995-06-21

Family

ID=16491558

Family Applications (1)

Application Number Title Priority Date Filing Date
JP61204500A Expired - Fee Related JPH0758463B2 (en) 1986-08-26 1986-08-29 Data processing device

Country Status (1)

Country Link
JP (1) JPH0758463B2 (en)

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS5762442A (en) * 1980-10-01 1982-04-15 Nec Corp Information processor

Also Published As

Publication number Publication date
JPS6359630A (en) 1988-03-15

Similar Documents

Publication Publication Date Title
JP2603626B2 (en) Data processing device
JPH1185515A (en) Microprocessor
EP0488819B1 (en) Conditional branch instructions execution apparatus
US6832305B2 (en) Method and apparatus for executing coprocessor instructions
JPH0795271B2 (en) Branch instruction execution device
JPH02287626A (en) Pipeline system branch instruction controller
JPH0758463B2 (en) Data processing device
JPS6355639A (en) Data processor
JP2944335B2 (en) Information processing device
JP2843844B2 (en) Parallel processing unit
JP2503223B2 (en) Prior control method
JPH0760385B2 (en) Data processing device having branch prediction function
JP3419276B2 (en) Instruction prefetch apparatus and instruction prefetch method
JPS63170740A (en) Data processor
JPH0934704A (en) Unconditional jump instruction processing method, device for the same and general-purpose register
JPH0774992B2 (en) Data processing device
JPS6411973B2 (en)
JPH0353322A (en) Information processor
JPH0433021A (en) Branching instruction control system
JPH0498426A (en) Microprocessor
JP2689894B2 (en) Micro program control type information processing device
JPH0922307A (en) Sequencer
JPH0358128A (en) Information processor
JPH0557614B2 (en)
JPH04160638A (en) Information processor

Legal Events

Date Code Title Description
S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313111

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

LAPS Cancellation because of no payment of annual fees