JP3431503B2 - Information processing apparatus and program control method - Google Patents
Information processing apparatus and program control methodInfo
- Publication number
- JP3431503B2 JP3431503B2 JP18657098A JP18657098A JP3431503B2 JP 3431503 B2 JP3431503 B2 JP 3431503B2 JP 18657098 A JP18657098 A JP 18657098A JP 18657098 A JP18657098 A JP 18657098A JP 3431503 B2 JP3431503 B2 JP 3431503B2
- Authority
- JP
- Japan
- Prior art keywords
- instruction
- branch
- address
- conditional branch
- holding means
- 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
Links
Landscapes
- Advance Control (AREA)
Description
【0001】[0001]
【発明の属する技術分野】本発明は、命令をパイプライ
ン処理する情報処理装置における条件分岐の制御を行う
プログラム制御方法に関するものである。BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a program control method for controlling conditional branching in an information processing apparatus that pipelines instructions.
【0002】[0002]
【従来の技術】命令をパイプライン処理する情報処理装
置においては、各命令が順次パイプラインに送り込まれ
逐次実行されている時には、命令のオーバーラップ実行
により命令実行の高速化が図られている。しかし、条件
分岐命令により分岐する場合には、条件が判定された時
点から分岐先命令をフェッチするため、つまり、分岐判
定を行ってから分岐アドレスをプログラムカウンタに設
定するため、パイプラインに無駄な空き、すなわち分岐
ハザードが出る。2. Description of the Related Art In an information processing apparatus that pipelines instructions, the speed of instruction execution is increased by overlapping execution of instructions when the instructions are sequentially sent to the pipeline and sequentially executed. However, when branching by a conditional branch instruction, the branch destination instruction is fetched from the time when the condition is judged, that is, the branch address is set in the program counter after the branch judgment is made, so that there is no waste in the pipeline. There is a vacancy, that is, a branch hazard.
【0003】このような分岐ハザードは、条件成立時の
方が不成立時に比べて多い。命令フェッチステージが1
段の場合には、分岐ハザードが1サイクル多い。また、
命令フェッチステージが2段の場合には、分岐ハザード
が2サイクル多い。さらに、命令フェッチステージがN
段(Nは任意の正整数)の場合には、分岐ハザードがN
サイクル多い。Such branch hazards are greater when the condition is met than when the condition is not met. 1 instruction fetch stage
In the case of stages, the branch hazard is one cycle more. Also,
If there are two instruction fetch stages, the branch hazard is two cycles longer. Furthermore, if the instruction fetch stage is N
In the case of stages (N is an arbitrary positive integer), the branch hazard is N
There are many cycles.
【0004】この問題を解決する手段の1つとして従来
は、分岐命令の後続番地にある命令を遅延スロットで実
行することでパイプラインの分岐ハザードを削減する、
いわゆる遅延分岐と呼ばれる分岐方法が採られている。
上記した従来の分岐方法の一例は、例えば、特開平4−
127237号公報に開示されている。As one of means for solving this problem, conventionally, an instruction at a subsequent address of a branch instruction is executed in a delay slot to reduce a branch hazard of a pipeline.
A branching method called so-called delayed branching is adopted.
An example of the conventional branching method described above is disclosed in, for example, Japanese Patent Laid-Open No.
It is disclosed in Japanese Patent No. 127237.
【0005】[0005]
【発明が解決しようとする課題】上記のような従来の方
法では、遅延スロットの命令が分岐ハザードのサイクル
で実行されるため、分岐命令の実行サイクルが見かけ上
減少する。しかしながら、上記の遅延分岐による分岐方
法では、遅延スロットに置くことのできる命令に制限が
あること、あるいは分岐ハザードのサイクル数が多い場
合に遅延スロットに命令を適切に振り分けることが困難
になること等から、全ての場合で有効に分岐ハザードを
削減することはできないという問題を有していた。In the conventional method as described above, since the instruction in the delay slot is executed in the cycle of the branch hazard, the execution cycle of the branch instruction is apparently reduced. However, in the branch method using the above-described delay branch, there are restrictions on the instructions that can be placed in the delay slot, or it becomes difficult to properly distribute the instructions to the delay slot when the number of cycles of the branch hazard is large. Therefore, there is a problem that the branching hazard cannot be effectively reduced in all cases.
【0006】本発明の目的は、命令をパイプライン処理
する情報処理装置における条件分岐制御において、パイ
プラインの構成や命令の内容等に制限を受けることな
く、分岐ハザードを有効に低減することができるプログ
ラム制御方法を提供することである。An object of the present invention is to effectively reduce branch hazards in conditional branch control in an information processing apparatus that pipelines instructions without being restricted by the pipeline configuration, instruction content, and the like. A program control method is provided.
【0007】[0007]
【課題を解決するための手段】本発明の情報処理装置
は、命令解読ステージと命令実行ステージとを含む複数
のステージから構成され、前記命令解読ステージの前に
2段以上のステージを有するパイプラインで命令を処理
する情報処理装置であって、 前記情報処理装置が実行す
る命令を命令コードとして格納する命令コード格納手段
と、 前記命令コード格納手段からフェッチされる命令コ
ードのアドレスを指定する第1のアドレス保持手段と、
前記第1のアドレス保持手段が指定するアドレスに基づ
いて前記命令コード格納手段からフェッチされた命令コ
ードを格納する第1の命令保持手段と、前記第1の命令
保持手段に格納された命令コードが条件分岐命令である
か否かを判定する分岐判定手段と、 前記第1の命令保持
手段に格納された命令コードをデコードするデコード手
段と、 前記デコード手段におけるデコード結果に基づい
て演算を実行する演算手段と、 前記分岐判定手段の判定
結果が、前記第1の命令保持手段に格納された命令コー
ドが条件分岐命令であることを示すものである場合に
は、前記条件分岐命令の分岐判定前に、前記条件分岐命
令の後続アドレスが退避される第2のアドレス保持手段
と、 前記分岐判定手段の判定結果が、前記第1の命令保
持手段に格納された命令コードが条件分岐命令であるこ
とを示すものである場合には、前記条件分岐命令の分岐
判定前に、前記条件分岐命令の後続命令コードが退避さ
れる第2の命令保持手段とを備え、 前記分岐判定手段の
判定結果が、前記第1の命令保持手段に格納された命令
コードが条件分岐命令であることを示すものである場合
には、前記分岐先命令を先行的に前記パイプラインに投
入し、 前記条件分岐命令の条件成立の場合は、前記分岐
先命令を実行し、 前記条件分岐命令の条件不成立の場合
は、前記第2のアドレス保持手段へと退避された前記後
続アドレスを前記第1のアドレス保持手段へと戻し、前
記第2の命令保持手段へと退避された前記後続命令コー
ドを前記デコード手段でデコードすることにより、前記
条件分岐命令の後続命令を実行することを特徴とする。
また、本発明の第1のプログラム処理方法は、1つの命
令解読ステージと命令実行ステージとを含む複数のステ
ージから構成され、前記命令解読ステージの前にn
(n:2以上の整数)段のステージを有するパイプライ
ンで命令を処理し、前記パイプラインに投入される命令
のアドレスを示す第1のアドレス保持手段と、前記命令
解読ステージにおいてデコードされる命令を格納する第
1の命令保持手段と、前記第1のアドレス保持手段とは
異なる第2のアドレス保持手段と、前記第1の命令保持
手段とは異なる第2の命令保持手段とを備える情報処理
装置における条件分岐の制御を行うプログラム制御方法
であって、 前記命令解読ステージにおいてデコードされ
た命令が条件分岐命令である場合には、前記条件分岐命
令の前記命令実行ステージにおいて、前記条件分岐命令
の後続命令のパイプライン情報として、前記条件分岐命
令よりn+1後の命令のアドレスを前記第2のアドレス
保持手段へと、前記条件分岐命令より1つ後の命令の命
令コードを前記第2の命令保持手段へと退避し、分岐先
命令を先行的に前記パイプラインに投入し、 前記条件分
岐命令の条件成立の場合は、前記分岐先命令をそのまま
実行し、 前記条件分岐命令の条件不成立の場合は、前記
第2のアドレス保持手段へと退避された前記条件分岐命
令よりn+1後の命令のアドレスを前記第1のアドレス
保持手段へと戻し、前記第2の命令保持手段へと退避さ
れた前記条件分岐命令より1つ後の命令の命令コードを
デコードすることにより、前記条件分岐命令の後続命令
を実行することを特徴とする。 さらに、本発明の第2の
プログラム処理方法は、第1の命令解読ステージを含む
複数の命令解読ステージと命令実行ステージとを含む複
数のステージで構成され、前記第1の命令解読ステージ
の前にn(n:2以上の整数)段のステージを有するパ
イプラインで命令を処理し、前記パイプラインに投入さ
れる命令のアドレスを示す第1のアドレス保持手段と、
前記複数の命令解読ステージのいずれか においてデコー
ドされる命令を格納する第1の命令保持手段と、前記第
1のアドレス保持手段とは異なる第2のアドレス保持手
段と、前記第1の命令保持手段とは異なる第2の命令保
持手段とを備える情報処理装置における条件分岐の制御
を行うプログラム制御方法であって、 前記第1の命令解
読ステージにおいてデコードされた命令が条件分岐命令
である場合には、前記第1の命令解読ステージの次のス
テージにおいて、前記条件分岐命令の後続命令のパイプ
ライン情報として、前記条件分岐命令よりn+1後の命
令のアドレスを前記第2のアドレス保持手段へと、前記
条件分岐命令より1つ後の命令の命令コードを前記第2
の命令保持手段へと退避し、分岐先命令を先行的に前記
パイプラインに投入し、 前記条件分岐命令の条件成立の
場合は、前記分岐先命令をそのまま実行し、 前記条件分
岐命令の条件不成立の場合は、前記第2のアドレス保持
手段へと退避された前記条件分岐命令よりn+1後の命
令のアドレスを前記第1のアドレス保持手段へと戻し、
前記第2の命令保持手段へと退避された前記条件分岐命
令より1つ後の命令の命令コードをデコードすることに
より、前記条件分岐命令の後続命令を実行することを特
徴とする。 Information processing apparatus of the present invention
Has a plurality of instruction decoding stages and instruction execution stages.
Before the instruction decoding stage.
Process instructions in a pipeline with two or more stages
Information processing device that is executed by the information processing device.
Code storing means for storing an instruction to be executed as an instruction code
And an instruction code fetched from the instruction code storage means.
First address holding means for designating an address of the mode,
Based on the address designated by the first address holding means,
The instruction code fetched from the instruction code storage means.
A first command holding means for storing a code, and the first command
The instruction code stored in the holding means is a conditional branch instruction
Branch determination means for determining whether or not the first instruction holding
Decoding hand to decode the instruction code stored in the means
Stage and the decoding result in the decoding means
Means for executing the calculation by means of
The result is the instruction code stored in the first instruction holding means.
Code indicates a conditional branch instruction,
Before the branch judgment of the conditional branch instruction,
Second address holding means for saving the subsequent address of the command
And the decision result of the branch decision means is the first instruction protection
The instruction code stored in the holding means is a conditional branch instruction.
, The branch of the conditional branch instruction
Before the judgment, the instruction code following the conditional branch instruction is saved.
A second instruction holding means for
The determination result is the instruction stored in the first instruction holding unit.
If the code indicates a conditional branch instruction
The branch destination instruction in advance to the pipeline.
Type, if the conditions are satisfied in the conditional branch instruction, the branch
When the previous instruction is executed and the condition of the conditional branch instruction is not satisfied
Is stored in the second address holding means
The subsequent address is returned to the first address holding means,
The succeeding instruction code saved in the second instruction holding means.
By decoding the code with the decoding means,
It is characterized in that the instruction subsequent to the conditional branch instruction is executed.
Also, the first program processing method of the present invention is
Multiple stages, including an instruction decoding stage and an instruction execution stage.
And n before the instruction decoding stage.
Pipeline having (n: integer of 2 or more) stages
Instructions that are processed in the pipeline and input to the pipeline
Address holding means for indicating the address of the
Store the instruction to be decoded in the decode stage
1 instruction holding means and the first address holding means
Different second address holding means and the first instruction holding
Information processing including second instruction holding means different from the means
Control method for controlling conditional branching in device
And is decoded in the instruction decoding stage
If the specified instruction is a conditional branch instruction, the conditional branch instruction
Instruction at the instruction execution stage, the conditional branch instruction
As the pipeline information of the subsequent instruction of
The address of the instruction n + 1 after the instruction is the second address
The instruction of the instruction after the conditional branch instruction is sent to the holding means.
Instruction code is saved to the second instruction holding means, and the branch destination
Prior to charged into the pipeline instructions, the condition min
If the condition of the branch instruction is satisfied, the branch destination instruction remains unchanged.
Run, if the condition is not established in the conditional branch instruction, the
The conditional branch instruction saved to the second address holding means
The address of the instruction n + 1 after the instruction is the first address
It is returned to the holding means and saved in the second instruction holding means.
The instruction code of the instruction one instruction after the conditional branch instruction
By decoding, the subsequent instruction of the conditional branch instruction
It is characterized by executing. Furthermore, the second aspect of the present invention
The program processing method includes a first instruction decoding stage.
A plurality of instruction decoding stages and instruction execution stages.
Number of stages, the first instruction decoding stage
Before n has a stage of n (n: integer of 2 or more) stages
Ipline processes the instruction and puts it into the pipeline.
First address holding means for indicating an address of an instruction to be executed,
Decode the one of the plurality of instruction decoding stage
First instruction holding means for storing an instruction to be stored;
A second address holder different from the first address holder
And a second instruction storage different from the first instruction storage means.
Control of conditional branching in an information processing apparatus including a holding unit
And a program control method for executing the first command solution
The instruction decoded in the read stage is a conditional branch instruction
Then the next scan of the first instruction decode stage.
Pipe of the instruction subsequent to the conditional branch instruction
As line information, the instruction n + 1 later than the conditional branch instruction
The address of the command to the second address holding means,
The instruction code of the instruction one instruction after the conditional branch instruction is the second code.
To the instruction holding means of the branch destination instruction
When the condition of the conditional branch instruction is satisfied , it is input to the pipeline.
If executes the branch target instruction as the condition min
When the condition of the branch instruction is not satisfied, the second address is retained
Command n + 1 later than the conditional branch instruction saved to the means
The address of the command to the first address holding means,
The conditional branch instruction saved to the second instruction holding unit
To decode the instruction code of the instruction one instruction after
Therefore, the instruction subsequent to the conditional branch instruction is executed.
To collect.
【0008】この構成によると、命令をデコードし、命
令が条件分岐命令である場合には、条件分岐命令の分岐
判定前に分岐先命令を先行的にパイプラインに投入して
いるので、条件が成立したときには、分岐先命令につい
てのパイプライン処理の少なくとも最初のステージは終
えていて、条件成立後は2番目以降の何れかのステージ
から分岐先命令についてのパイプライン情報が継続され
ることになるため、条件分岐命令の分岐判定後に分岐先
命令をパイプラインに投入する場合に比べて、分岐先命
令を実行する場合の分岐ハザードを削減することができ
る。According to this structure, the instruction is decoded, and if the instruction is a conditional branch instruction, the branch of the conditional branch instruction is executed.
Since the branch destination instruction is inserted into the pipeline in advance before the judgment , at least the first stage of the pipeline processing for the branch destination instruction is completed when the condition is satisfied, and after the condition is satisfied, the second and subsequent stages are completed. Since the pipeline information about the branch destination instruction will be continued from any stage of, the branch destination instruction is executed as compared with the case where the branch destination instruction is input to the pipeline after the branch determination of the conditional branch instruction. In this case, the branching hazard can be reduced.
【0009】一方、命令をデコードし、命令が条件分岐
命令である場合には、条件分岐命令の分岐判定前に条件
分岐命令の後続命令のパイプライン情報として後続アド
レスおよび後続命令コードを退避しているので、条件が
不成立のときは、退避していた条件分岐命令の後続命令
のパイプライン情報をパイプラインに戻すことにより、
分岐ハザードを増加させることなく条件分岐命令の後続
命令を実行させることができる。On the other hand, when the instruction is decoded and the instruction is a conditional branch instruction, the subsequent address and the subsequent instruction code are saved as pipeline information of the subsequent instruction of the conditional branch instruction before the branch determination of the conditional branch instruction. Therefore, when the condition is not satisfied, by returning the pipeline information of the instruction subsequent to the saved conditional branch instruction to the pipeline,
The instruction subsequent to the conditional branch instruction can be executed without increasing the branch hazard.
【0010】したがって、全体として見れば、分岐不成
立時の分岐ハザードを増加させることなく、分岐成立時
の分岐ハザードを削減することができ、プログラムを効
率よく実行することができ、処理時間を短縮することが
可能となる。Therefore, as a whole, the branch hazard when the branch is taken can be reduced without increasing the branch hazard when the branch is not taken, the program can be efficiently executed, and the processing time is shortened. It becomes possible.
【0011】また、単純に命令をデコードし、命令が条
件分岐命令である場合には、条件分岐命令の分岐判定前
に条件分岐命令の後続命令のパイプライン情報として後
続アドレスおよび後続命令コードを退避し、分岐先命令
を先行的にパイプラインに投入するだけであるので、パ
イプラインの構成や命令の内容等に制限を受けることな
く、分岐ハザードを有効に低減することができる。Further, if the instruction is simply decoded and the instruction is a conditional branch instruction, the subsequent address and the subsequent instruction code are saved as pipeline information of the instruction subsequent to the conditional branch instruction before the branch determination of the conditional branch instruction. However, since the branch destination instruction is only put into the pipeline in advance, the branch hazard can be effectively reduced without being restricted by the pipeline configuration, the instruction content, and the like.
【0012】[0012]
【発明の実施の形態】(第1の実施の形態)
以下本発明の第1の実施の形態の条件分岐処理における
プログラム制御方法およびその装置について、図面を参
照しながら説明する。BEST MODE FOR CARRYING OUT THE INVENTION (First Embodiment) A program control method and apparatus for conditional branching processing according to a first embodiment of the present invention will be described below with reference to the drawings.
【0013】図1は本発明の第1の実施の形態のプログ
ラム制御装置の基本構成を示すブロック図である。図1
において、プログラムカウンタ部1は、命令コードを読
み出すためのアドレス生成手段となり、分岐判定器4か
ら条件分岐命令であることを示す分岐信号14と分岐先
命令のアドレスに対応する分岐アドレス15を入力し、
アドレス11を出力する。メモリ2は、命令コードを格
納する命令コード格納手段となり、プログラムカウンタ
部1からアドレス11を入力し、アドレス11に対応し
た第1の命令コード12を出力する。命令レジスタ部3
は、命令制御手段となり、メモリ2から第1の命令コー
ド12を入力し、分岐判定器4から分岐信号14を入力
し、第2の命令コード13を出力する。分岐判定器4
は、分岐判定手段となり、命令レジスタ部3から第2の
命令コード13を入力し、演算部6から条件フラグ信号
17を入力し、第2の命令コード13が条件分岐命令で
あるかどうかを判定し、条件分岐命令であるときに分岐
信号14と条件分岐命令中に含まれている分岐先命令の
アドレス、つまり分岐アドレス15を出力する。デコー
ダ部5は、命令をデコードする手段となり、命令レジス
タ部3から第2の命令コード13を入力し、制御信号1
6を出力する。演算部6は、演算手段となり、デコーダ
部5から制御信号16を入力し、演算を実行して条件フ
ラグ信号17を出力する。この図1の構成は、後述の第
2の実施の形態と共通である。FIG. 1 is a block diagram showing the basic arrangement of a program control device according to the first embodiment of the present invention. Figure 1
2, the program counter unit 1 serves as an address generating unit for reading an instruction code, and inputs a branch signal 14 indicating a conditional branch instruction and a branch address 15 corresponding to the address of a branch destination instruction from the branch determiner 4. ,
Address 11 is output. The memory 2 serves as an instruction code storage means for storing an instruction code, receives the address 11 from the program counter unit 1 and outputs the first instruction code 12 corresponding to the address 11. Instruction register unit 3
Serves as an instruction control unit, which inputs the first instruction code 12 from the memory 2, inputs the branch signal 14 from the branch determiner 4, and outputs the second instruction code 13. Branch decision device 4
Is a branch determining means, which inputs the second instruction code 13 from the instruction register unit 3 and the condition flag signal 17 from the arithmetic unit 6 and determines whether the second instruction code 13 is a conditional branch instruction. When it is a conditional branch instruction, the branch signal 14 and the address of the branch target instruction included in the conditional branch instruction, that is, the branch address 15 are output. The decoder unit 5 serves as a means for decoding an instruction, receives the second instruction code 13 from the instruction register unit 3, and outputs the control signal 1
6 is output. The arithmetic unit 6 serves as an arithmetic means, receives the control signal 16 from the decoder unit 5, executes an arithmetic operation, and outputs a condition flag signal 17. The configuration of FIG. 1 is described below .
This is common to the second embodiment.
【0014】図2は本発明の第1の実施の形態における
プログラムカウンタ部1の構成を示すブロック図であ
る。図2において、第1のプログラムカウンタ101
は、第1のアドレス保持手段となり、アドレス選択器出
力113を入力し、アドレス11を出力する。アドレス
加算器102は、アドレス11をインクリメントするア
ドレス加算手段となり、アドレス11を入力し、アドレ
ス加算器出力114を出力する。FIG. 2 is a block diagram showing the configuration of the program counter section 1 according to the first embodiment of the present invention. In FIG. 2, the first program counter 101
Serves as a first address holding means, inputs the address selector output 113, and outputs the address 11. The address adder 102 serves as an address adding unit that increments the address 11, inputs the address 11, and outputs an address adder output 114.
【0015】第2のプログラムカウンタ104は、命令
をデコードし、命令が条件分岐命令である場合には、条
件分岐命令の分岐判定前に条件分岐命令の後続命令のパ
イプライン情報の一つである条件分岐命令の後続命令の
アドレスを退避する第2のアドレス保持手段となり、ア
ドレス加算器出力114と第2のプログラムカウンタ用
分岐信号112を入力し、第2のプログラムカウンタ出
力115を出力し、アドレス加算器出力114が退避さ
れる後続命令のアドレスに対応し、第2のプログラムカ
ウンタ出力115がパイプラインに戻される後続命令の
アドレスに対応する。The second program counter 104 decodes the instruction, and when the instruction is a conditional branch instruction, it is one of the pipeline information of the instruction subsequent to the conditional branch instruction before the branch judgment of the conditional branch instruction. It becomes the second address holding means for saving the address of the instruction subsequent to the conditional branch instruction, receives the address adder output 114 and the second program counter branch signal 112, outputs the second program counter output 115, and outputs the address. The adder output 114 corresponds to the address of the subsequent instruction that is saved and the second program counter output 115 corresponds to the address of the subsequent instruction that is returned to the pipeline.
【0016】アドレス選択器103は、アドレス選択手
段となり、分岐アドレス15とアドレス加算器出力11
4と第2のプログラムカウンタ出力115とアドレス選
択器用分岐信号111を入力し、アドレス選択器出力1
13を出力する。このアドレス選択器103としては、
アドレス選択器用分岐信号111を基にして、条件分岐
命令の場合には分岐アドレス15を次アドレスとして選
択し、条件分岐命令以外の命令の場合には、アドレス加
算器出力114を次アドレスとして選択し、条件分岐命
令が不成立のときには条件分岐命令の実行ステージで第
2のプログラムカウンタ出力115を次アドレスとして
選択する。 The address selector 103 serves as address selecting means, and the branch address 15 and the address adder output 11
4 and the second program counter output 115 and the address selector branch signal 111 are input, and the address selector output 1
13 is output. As the address selector 103,
Based on the address selector branch signal 111, the branch address 15 is selected as the next address in the case of a conditional branch instruction, and the address adder output 114 is selected as the next address in the case of an instruction other than the conditional branch instruction. When the conditional branch instruction is not satisfied, the second program counter output 115 is selected as the next address in the execution stage of the conditional branch instruction.
【0017】なお、分岐判定器4は、条件分岐命令であ
るとき、実行ステージにおいて、条件フラグ信号17が
“0”の時には条件不成立であるとして、アドレス選択
器用分岐信号111と第1の命令レジスタ用分岐信号3
11を出力する。Note that the branch deciding unit 4 determines that the condition is not satisfied when the condition flag signal 17 is "0" at the execution stage when it is a conditional branch instruction, and the address selector branch signal 111 and the first instruction register. Branch signal 3
11 is output.
【0018】図4は本発明の第1の実施の形態における
命令レジスタ部3の構成を示すブロック図である。図4
において、第1の命令レジスタ301は、第1の命令保
持手段となり、第1の命令コード12と第1の命令レジ
スタ用分岐信号311を入力し、第1の命令レジスタ出
力314を出力する。この場合、第1の命令レジスタ3
01は、通常は第1の命令コード12を毎サイクル更新
しながら記憶するが、第1の命令レジスタ用分岐信号3
11が入力されたときは、前サイクルの命令コードを保
持する。FIG. 4 is a block diagram showing the configuration of the instruction register unit 3 in the first embodiment of the present invention. Figure 4
In, the first instruction register 301 serves as a first instruction holding unit, inputs the first instruction code 12 and the first instruction register branch signal 311, and outputs the first instruction register output 314. In this case, the first instruction register 3
01 normally stores the first instruction code 12 while updating it every cycle, but the first instruction register branch signal 3
When 11 is input, the instruction code of the previous cycle is held.
【0019】第2の命令レジスタ303は、第2の命令
保持手段となり、第1の命令コード12と第2の命令レ
ジスタ用分岐信号313を入力し、第2の命令レジスタ
出力316を出力する。上記の第2の命令レジスタ30
3は、条件分岐命令の後続命 令の命令コードを退避する
機能を有する。 The second instruction register 303 stores the second instruction
It serves as a holding means and serves as a first instruction code 12 and a second instruction record.
Input the branch signal 313 for the register to the second instruction register
The output 316 is output. The above second instruction register 30
3 saves the instruction code of the subsequent instruction of the conditional branch instruction
Have a function.
【0020】命令選択器302は、命令選択手段とな
り、第1の命令レジスタ出力314と第2の命令レジス
タ出力316とNOPコード315と命令選択器用分岐
信号312を入力し、第2の命令コード13を出力す
る。この場合、命令選択器302は、命令選択器用分岐
信号312に応じて第1の命令レジスタ出力314と第
2の命令レジスタ出力316とNOPコード315の何
れかを選択する。命令選択器302は、分岐不成立時に
第2の命令レジスタ出力316を選択することで、退避
していた後続命令の命令コードをパイプラインに戻す機
能を有する。 The instruction selector 302 serves as an instruction selecting means, and outputs the first instruction register output 314 and the second instruction register.
Data output 316, the NOP code 315, and the instruction selector branch signal 312 are input, and the second instruction code 13 is output. In this case, the instruction selector 302 is a branch for the instruction selector.
In response to the signal 312, the first instruction register output 314 and the first instruction register output 314
2 instruction register output 316 and NOP code 315
Select one. When the branch is not taken, the instruction selector 302
Saved by selecting the second instruction register output 316
To return the instruction code of the succeeding instruction to the pipeline
Have the ability.
【0021】上記のように、第1の実施の形態は、図1
の基本構成のプログラムカウンタ部1の構成を図2のよ
うにし、命令レジスタ部3の構成を図4のようにしたも
のである。なお、分岐信号14はアドレス選択器用分岐
信号111と第2のプログラムカウンタ用分岐信号11
2と第1の命令レジスタ用分岐信号311と命令選択器
用分岐信号312と第2の命令レジスタ用分岐信号31
3からなる。As described above, the first embodiment is similar to FIG.
The program counter section 1 of the configuration of the basic structure as in Figure 2 of the one in which the configuration of the instruction register unit 3 as in FIG. The branch signal 14 is the address selector branch signal 111 and the second program counter branch signal 11
2, the first instruction register branch signal 311, the instruction selector branch signal 312, and the second instruction register branch signal 31.
It consists of three.
【0022】以上のように構成されたプログラム制御装
置について、以下図6および図7を用いてその動作を説
明する。The operation of the program control device configured as described above will be described below with reference to FIGS. 6 and 7 .
【0023】図6は命令フェッチとして2ステージ設け
た場合の4段パイプライン(第1命令フェッチステージ
IF1、第2命令フェッチステージIF2、命令解読ス
テージDEC、命令実行ステージEX)の場合におい
て、条件分岐命令を実行する場合の制御フローを示すも
のである。この場合、条件分岐命令のアドレスがN番
地、分岐先命令のアドレスがM番地である。また、図7
はその時のタイミングチャートであり、(a)は条件成
立時であり、(b)は条件不成立時である。以下、各パ
イプラインステージ毎にその動作を説明する。なお、第
1命令フェッチステージおよび第2命令フェッチステー
ジについては説明を省略している。
(1)条件分岐命令の命令解読ステージ
分岐判定器4が第2の命令コード13をデコードして条
件分岐命令であると判定し、分岐信号14と分岐アドレ
ス15を出力する。
(2)条件分岐命令の実行ステージ
第2のプログラムカウンタ用分岐信号112により、条
件分岐命令の3つ後のアドレス(N+3)を第2のプロ
グラムカウンタ104に設定する。これによって、条件
分岐命令の3つ後の命令のアドレス(N+3)を退避す
る。FIG. 6 shows conditional branching in the case of a four-stage pipeline (first instruction fetch stage IF1, second instruction fetch stage IF2, instruction decoding stage DEC, instruction execution stage EX) when two stages are provided for instruction fetch. 6 shows a control flow when an instruction is executed. In this case, the address of the conditional branch instruction is N and the address of the branch target instruction is M. In addition, FIG. 7
Is a timing chart at that time, (a) is when the condition is satisfied, and (b) is when the condition is not satisfied. The operation of each pipeline stage will be described below. The description of the first instruction fetch stage and the second instruction fetch stage is omitted. (1) Instruction decoding stage of conditional branch instruction The stage branch determiner 4 decodes the second instruction code 13 and determines that it is a conditional branch instruction, and outputs a branch signal 14 and a branch address 15. (2) Execution stage of conditional branch instruction By the second program counter branch signal 112, the address (N + 3) three addresses after the conditional branch instruction is set in the second program counter 104. As a result, the address (N + 3) of the instruction three instructions after the conditional branch instruction is saved.
【0024】アドレス選択器用分岐信号111により、
アドレス選択器103が分岐アドレス15を選択して第
1のプログラムカウンタ101に分岐アドレス15を設
定し、アドレス11はM番地となる。これにより、分岐
判定が行われる時点(条件分岐命令の実行ステージの最
後)より前に、分岐先命令が先行的にパイプラインに投
入されたことになる。By the address selector branch signal 111,
The address selector 103 selects the branch address 15 and sets the branch address 15 in the first program counter 101, and the address 11 becomes the address M. As a result, the branch destination instruction is inserted into the pipeline in advance before the time point when the branch determination is performed (the end of the execution stage of the conditional branch instruction).
【0025】第2の命令レジスタ用分岐信号313によ
り、条件分岐命令の1つ後の命令コード(N+1)を第
2の命令レジスタ303に設定する。これによって、条
件分岐命令の1つ後の命令コード(N+1)を退避す
る。The instruction code (N + 1) immediately after the conditional branch instruction is set in the second instruction register 303 by the second instruction register branch signal 313. As a result, the instruction code (N + 1) immediately after the conditional branch instruction is saved.
【0026】命令選択器用分岐信号312により、命令
選択器302がNOPコード(無処理コード)315を
選択して第2の命令コード13は、NOP命令となる。
・条件成立時
(3)条件分岐命令の実行ステージの次ステージ
命令選択器用分岐信号312により、命令選択器302
がNOPコード(無処理コード)315を選択して第2
の命令コード13は、NOP命令となる。The instruction selector 302 selects the NOP code (unprocessed code) 315 by the instruction selector branch signal 312, and the second instruction code 13 becomes a NOP instruction. When the condition is satisfied (3) The instruction selector 302 is operated by the branch signal 312 for the instruction selector of the next stage of the execution stage of the conditional branch instruction.
Selects the NOP code (unprocessed code) 315 and the second
The instruction code 13 of is a NOP instruction.
【0027】(4)条件分岐命令の実行ステージの次々
ステージ
分岐信号14を解除し通常動作に戻り、第2の命令コー
ド13は、M番地の命令となる。その結果、N番地の条
件分岐命令の後に、2サイクルの分岐ハザードが入るも
のの、M番地以降の命令が順に実行されることになる。
・条件不成立時
(3)条件分岐命令の実行ステージの次ステージ
アドレス選択器用分岐信号111により、アドレス選択
器103が第2のプログラムカウンタ出力115を選択
して第1のプログラムカウンタ101に第2のプログラ
ムカウンタ104の値を設定し、アドレス11はN+3
番地となる。この結果、退避されていた後続命令のアド
レスがパイプラインに戻されることになる。(4) After the execution stage of the conditional branch instruction, the next stage branch signal 14 is released and the normal operation is resumed, and the second instruction code 13 becomes the instruction at the address M. As a result, after the conditional branch instruction at the address N, a two-cycle branch hazard is inserted, but the instructions at the address M and thereafter are executed in order. When the condition is not satisfied (3) The address selector 103 selects the second program counter output 115 by the branch signal 111 for the next stage address selector of the execution stage of the conditional branch instruction, and the first program counter 101 receives the second program counter output 115. Set the value of the program counter 104, and the address 11 is N + 3
It becomes the address. As a result, the saved address of the subsequent instruction is returned to the pipeline.
【0028】また、命令選択器用分岐信号312によ
り、命令選択器302が第2の命令レジスタ出力316
を選択して第2の命令コード13は、N+1番地の命令
となる。その結果、退避されていた後続命令の命令コー
ドがパイプラインに戻されることになる。The instruction selector branch signal 312 causes the instruction selector 302 to output the second instruction register output 316.
And the second instruction code 13 becomes the instruction at the address N + 1. As a result, the instruction code of the saved subsequent instruction is returned to the pipeline.
【0029】(4)条件分岐命令の実行ステージの次々
ステージ
第1の命令レジスタ用分岐信号311により、第1の命
令レジスタ301がN+2番地の命令を保持して第2の
命令コード13は、N+2番地の命令となる。(4) Successive stage after execution of conditional branch instruction By the first instruction register branch signal 311, the first instruction register 301 holds the instruction at address N + 2 and the second instruction code 13 becomes N + 2. It becomes an instruction of the address.
【0030】その結果、N番地の条件分岐命令の後に、
1サイクルの分岐ハザードが入るもののN+1番地以降
の命令が順に実行されることになる。As a result, after the conditional branch instruction at address N,
Although a one-cycle branch hazard is entered, instructions from address N + 1 onward will be executed in order.
【0031】図12は4段パイプライン(第1命令フェ
ッチステージIF1、第2命令フェッチステージIF
1、命令解読ステージDEC、命令実行ステージEX)
の場合において、条件分岐命令を実行する場合の従来例
のタイムチャートを示すものであり、(a)は条件成立
時であり、(b)は条件不成立時である。この場合、条
件分岐命令のアドレスがN番地、分岐先命令のアドレス
がM番地である。[0031] Figure 1 2 is a four-stage pipeline (first instruction fetch stage IF1, the second instruction fetch stage IF
1, instruction decoding stage DEC, instruction execution stage EX)
In the case of, the time chart of the conventional example in the case of executing the conditional branch instruction is shown, (a) is when the condition is satisfied, and (b) is when the condition is not satisfied. In this case, the address of the conditional branch instruction is N and the address of the branch target instruction is M.
【0032】図7と図12とを比較すると、条件成立時
の分岐ハザードが1サイクル削減されていることが判
る。[0032] Comparing FIGS. 7 and 1 2, it can be seen that the branch hazard when the condition is met is reduced by one cycle.
【0033】つぎに、以下図8および図9を用いて5段
パイプラインの動作を説明する。The operation of the 5-stage pipeline will be described below with reference to FIGS. 8 and 9 .
【0034】図8は命令フェッチに2ステージとった場
合の5段パイプライン(第1命令フェッチステージIF
1、第2命令フェッチステージIF2、第1命令解読ス
テージDEC1、第2命令解読ステージDEC2、命令
実行ステージEX)の場合において、条件分岐命令を実
行する場合の制御フローを示すものである。この場合、
条件分岐命令のアドレスがN番地、分岐先命令のアドレ
スがM番地である。また、図9はその時のタイミングチ
ャートであり、(a)は条件成立時であり、(b)は条
件不成立時である。以下、各パイプラインステージ毎に
その動作を説明する。なお、第1命令フェッチステー
ジ、第2命令フェッチステージおよび第1命令解読ステ
ージについては説明を省略している。
(1)条件分岐命令の第2命令解読ステージ
分岐判定器4が第2の命令コード13をデコードして条
件分岐命令であると判定し、分岐信号14と分岐アドレ
ス15を出力する。FIG. 8 shows a 5-stage pipeline (first instruction fetch stage IF) when two stages are used for instruction fetch.
1, a second instruction fetch stage IF2, a first instruction decoding stage DEC1, a second instruction decoding stage DEC2, an instruction execution stage EX), a control flow for executing a conditional branch instruction is shown. in this case,
The address of the conditional branch instruction is N, and the address of the branch destination instruction is M. Further, FIG. 9 is a timing chart at that time, where (a) is when the condition is satisfied and (b) is when the condition is not satisfied. The operation of each pipeline stage will be described below. The description of the first instruction fetch stage, the second instruction fetch stage, and the first instruction decoding stage is omitted. (1) Second instruction decoding stage of conditional branch instruction The branch decision unit 4 decodes the second instruction code 13 and determines that it is a conditional branch instruction, and outputs a branch signal 14 and a branch address 15.
【0035】第2のプログラムカウンタ用分岐信号11
2により、条件分岐命令の3つ後のアドレス(N+3)
を第2のプログラムカウンタ104に設定する。これに
よって、条件分岐命令の3つ後の命令のアドレス(N+
3)を退避する。Second branch signal for program counter 11
2, the address after the conditional branch instruction (N + 3)
Is set in the second program counter 104. As a result, the address (N +
3) is saved.
【0036】アドレス選択器用分岐信号111により、
アドレス選択器103が分岐アドレス15を選択して第
1のプログラムカウンタ101に分岐アドレス15を設
定し、アドレス11はM番地となる。これにより、分岐
判定が行われる時点(条件分岐命令の実行ステージの最
後)より前に、分岐先命令が先行的にパイプラインに投
入されたことになる。With the branch signal 111 for the address selector,
The address selector 103 selects the branch address 15 and sets the branch address 15 in the first program counter 101, and the address 11 becomes the address M. As a result, the branch destination instruction is inserted into the pipeline in advance before the time point when the branch determination is performed (the end of the execution stage of the conditional branch instruction).
【0037】第2の命令レジスタ用分岐信号313によ
り、条件分岐命令の1つ後の命令コード(N+1)を第
2の命令レジスタ303に設定する。これによって、条
件分岐命令の1つ後の命令コード(N+1)を退避す
る。The instruction code (N + 1) immediately after the conditional branch instruction is set in the second instruction register 303 by the second instruction register branch signal 313. As a result, the instruction code (N + 1) immediately after the conditional branch instruction is saved.
【0038】命令選択器用分岐信号312により、命令
選択器302がNOPコード(無処理コード)315を
選択して第2の命令コード13は、NOP命令となる。
(2)条件分岐命令の実行ステージ
命令選択器用分岐信号312により、命令選択器302
がNOPコード(無処理コード)315を選択して第2
の命令コード13は、NOP命令となる。
・条件成立時
(3)条件分岐命令の実行ステージの次ステージ
分岐信号14を解除し通常動作に戻り、第2の命令コー
ド13は、M番地の命令となる。The instruction selector 302 selects the NOP code (unprocessed code) 315 by the instruction selector branch signal 312, and the second instruction code 13 becomes a NOP instruction. (2) By the branch signal 312 for the execution stage instruction selector of the conditional branch instruction, the instruction selector 302
Selects the NOP code (unprocessed code) 315 and the second
The instruction code 13 of is a NOP instruction. When the condition is satisfied (3) The next stage branch signal 14 of the execution stage of the conditional branch instruction is released and the normal operation is resumed, and the second instruction code 13 becomes the instruction at the address M.
【0039】その結果、N番地の条件分岐命令の後に、
2サイクルの分岐ハザードが入るものの、M番地以降の
命令が順に実行されることになる。
・条件不成立時
(3)条件分岐命令の実行ステージの次ステージ
アドレス選択器用分岐信号111により、アドレス選択
器103が第2のプログラムカウンタ出力115を選択
して第1のプログラムカウンタ101に第2のプログラ
ムカウンタ104も値を設定し、アドレス11はN+3
番地となる。この結果、退避されていた後続命令のアド
レスがパイプラインに戻されることになる。As a result, after the conditional branch instruction at address N,
Although a two-cycle branch hazard is entered, the instructions after the address M will be executed in order. When the condition is not satisfied (3) The address selector 103 selects the second program counter output 115 by the branch signal 111 for the next stage address selector of the execution stage of the conditional branch instruction, and the first program counter 101 receives the second program counter output 115. The program counter 104 also sets a value, and the address 11 is N + 3.
It becomes the address. As a result, the saved address of the subsequent instruction is returned to the pipeline.
【0040】第1の命令レジスタ用分岐信号311によ
り、第1の命令レジスタ301がN+2番地の命令を保
持して第2の命令コード13はN+2番地の命令とな
る。By the first instruction register branch signal 311, the first instruction register 301 holds the instruction at address N + 2 and the second instruction code 13 becomes the instruction at address N + 2.
【0041】命令選択器用分岐信号312により、命令
選択器302が第2の命令レジスタ出力316を選択し
て第2の命令コード13は、N+1番地の命令となる。
その結果、退避されていた後続命令の命令コードがパイ
プラインに戻されることになる。The instruction selector 302 selects the second instruction register output 316 by the instruction selector branch signal 312, and the second instruction code 13 becomes the instruction at the address N + 1.
As a result, the instruction code of the saved subsequent instruction is returned to the pipeline.
【0042】(4)条件分岐命令の実行ステージの次々
ステージ
第1の命令レジスタ用分岐信号311により、第1の命
令レジスタ301がN+2番地の命令を保持して第2の
命令コード13は、N+2番地の命令となる。(4) Successive stages after execution of conditional branch instruction By the first instruction register branch signal 311, the first instruction register 301 holds the instruction at address N + 2 and the second instruction code 13 becomes N + 2. It becomes an instruction of the address.
【0043】その結果、N番地の条件分岐命令の後に、
2サイクルの分岐ハザードが入るもののN+1番地以降
の命令が順に実行されることになる。As a result, after the conditional branch instruction at address N,
Although a two-cycle branch hazard is entered, instructions from address N + 1 onward will be executed in sequence.
【0044】上記の図1,図2,図4,図6,図7,図
8および図9に示されたプログラム制御方法は、以下の
ようにまとめることができる。すなわち、プログラムカ
ウンタ部1が出力するアドレス11の当該命令コードを
メモリ2から命令レジスタ部3に取り出し、当該命令を
実行することにより、当該命令をパイプライン処理する
ときの条件分岐の制御を行う際に、命令をデコードし、
命令が条件分岐命令である場合には、条件分岐命令の分
岐判定前に、プログラムカウンタ部1で条件分岐命令の
3つ後の命令のアドレスを退避し、プログラムカウンタ
部1に分岐アドレス15を設定し、命令レジスタ部3で
条件分岐命令の1つ後の命令の命令コードを退避し、命
令レジスタ部3で命令コードを無処理命令コードに置換
し、条件成立時には、そのまま実行し、条件不成立時に
は、退避していた条件分岐命令の3つ後の命令のアドレ
スをプログラムカウンタ部1に設定し、命令レジスタ部
3で命令コードを退避していた条件分岐命令の1つ後の
命令の命令コードに置換し、ついで条件分岐命令の2つ
後の命令の命令コードを第1の命令レジスタ301で保
持して実行するということになる。なお、図8および図
9の場合には、命令コードを無処理命令コードに置換す
るステップが2つになる。The program control method shown in FIG. 1, FIG. 2, FIG. 4, FIG. 6, FIG. 7, FIG. 8 and FIG. 9 can be summarized as follows. That is, when the instruction code of the address 11 output from the program counter unit 1 is fetched from the memory 2 to the instruction register unit 3 and the instruction is executed, the conditional branching control for pipeline processing the instruction is performed. To decode the instruction,
If the instruction is a conditional branch instruction, the minute of the conditional branch instruction
Before the branch determination , the program counter section 1 saves the address of the instruction three instructions after the conditional branch instruction, sets the branch address 15 in the program counter section 1, and the instruction register section 3 sets the branch address one instruction after the conditional branch instruction. The instruction code of the instruction is saved, and the instruction register unit 3 replaces the instruction code with the unprocessed instruction code. When the condition is satisfied, the instruction code is executed as it is, and when the condition is not satisfied, the instruction three instructions after the saved conditional branch instruction is executed. The address is set in the program counter unit 1, the instruction code is replaced in the instruction register unit 3 with the instruction code of the instruction immediately after the conditional branch instruction that was saved, and then the instruction of the instruction two instructions after the conditional branch instruction. This means that the code is held in the first instruction register 301 and executed. In the case of FIGS. 8 and 9, there are two steps for replacing the instruction code with the non-processing instruction code.
【0045】上記の図1,図2,図4,図6,図7,図
8および図9に示されたプログラム制御装置は、以下の
ように構成される。すなわち、命令をパイプライン処理
するときの条件分岐の制御を行うもので、分岐アドレス
15と分岐信号14とを入力し、アドレス11を生成す
るプログラムカウンタ部1と、アドレス11に対応して
第1の命令コード12を格納または出力するメモリ2
と、第1の命令コード12と分岐信号14とを入力し、
第2の命令コード13を出力する命令レジスタ部3と、
第2の命令コード13をデコードして分岐を判定し、分
岐信号14と分岐アドレス15を出力する分岐判定器4
を備えている。The above Figures 1, 2, 4, 6, 7,
8 and the program controller shown in FIG. 9 are configured as follows. That is, it controls a conditional branch when an instruction is pipelined, and inputs a branch address 15 and a branch signal 14 to generate an address 11, and a program counter section 1 corresponding to the address 11 Memory 2 for storing or outputting the instruction code 12 of
And input the first instruction code 12 and the branch signal 14,
An instruction register unit 3 that outputs a second instruction code 13,
A branch determiner 4 that decodes the second instruction code 13 to determine a branch and outputs a branch signal 14 and a branch address 15.
Is equipped with.
【0046】この場合、プログラムカウンタ部1が第1
および第2のプログラムカウンタ101,104とアド
レス選択器103とアドレス加算器102とから構成さ
れている。そして、第1のプログラムカウンタ101が
アドレス選択器出力113を入力とし、アドレス11を
出力する。また、アドレス選択器103が分岐アドレス
15とアドレス加算器出力114と第2のプログラムカ
ウンタ出力115とを入力とし、分岐信号14により分
岐アドレス15とアドレス加算器出力114と第2のプ
ログラムカウンタ出力115との何れかを選択して出力
する。また、アドレス加算器102がアドレス11をイ
ンクリメントする。また、第2のプログラムカウンタ1
04がアドレス加算器出力114を入力とし、分岐信号
14によりアドレス加算器出力114を保持する。In this case, the program counter section 1 is the first
It is also composed of second program counters 101 and 104, an address selector 103, and an address adder 102. Then, the first program counter 101 receives the address selector output 113 as an input and outputs the address 11. Further, the address selector 103 receives the branch address 15, the address adder output 114 and the second program counter output 115 as input, and the branch signal 14 causes the branch address 15, the address adder output 114 and the second program counter output 115. And either of them are output. Further, the address adder 102 increments the address 11. In addition, the second program counter 1
04 receives the address adder output 114, and holds the address adder output 114 by the branch signal 14.
【0047】一方、命令レジスタ部3が第1および第2
の命令レジスタ301,303と命令選択器302とか
ら構成されている。そして、第1の命令レジスタ301
が第1の命令コード12を入力とし、分岐信号14によ
り第1の命令コード12を保持する。また、第2の命令
レジスタ303が第1の命令コード12を入力とし、分
岐信号14により第1の命令コード12を保持する。ま
た、命令選択器302が第1の命令レジスタ出力314
と第2の命令レジスタ出力316とNOPコード315
とを入力とし、分岐信号14により第1の命令レジスタ
出力314と第2の命令レジスタ出力316とNOPコ
ード315との何れかを選択して第2の命令コード13
として出力する。On the other hand, the instruction register unit 3 has the first and second
The instruction registers 301 and 303 and the instruction selector 302. Then, the first instruction register 301
Receives the first instruction code 12 and holds the first instruction code 12 by the branch signal 14. Further, the second instruction register 303 receives the first instruction code 12 as an input and holds the first instruction code 12 by the branch signal 14. In addition, the instruction selector 302 outputs the first instruction register output 314.
And second instruction register output 316 and NOP code 315
Is input and the branch signal 14 selects one of the first instruction register output 314, the second instruction register output 316, and the NOP code 315 to select the second instruction code 13
Output as.
【0048】この構成によると、条件分岐命令の分岐判
定前に、条件分岐命令の3つ後の命令のアドレスを第2
のプログラムカウンタ104に退避し、第1のプログラ
ムカウンタ101に分岐アドレス15を設定し、条件分
岐命令の1つ後の命令の命令コードを第2の命令レジス
タ303に退避し、命令選択器302でNOPコード3
15を選択し、条件成立時には、そのまま実行し、条件
不成立時には、第2のプログラムカウンタ104に退避
していたアドレスを第1のプログラムカウンタ101に
設定し、命令選択器302で第2の命令レジスタ303
を選択し、条件分岐命令の2つ後の命令の命令コードを
第1の命令レジスタ301で保持して実行するように制
御することで、命令フェッチステージが2ステージの場
合に、条件分岐命令の条件成立時の分岐ハザードを2サ
イクル削減することができる。According to this structure, the branch judgment of the conditional branch instruction is made.
A constant before, the address of the instruction following three conditional branch instruction second
In the program counter 104, the branch address 15 is set in the first program counter 101, the instruction code of the instruction after the conditional branch instruction is saved in the second instruction register 303, and the instruction selector 302 NOP code 3
When the condition 15 is selected, the condition is satisfied and the condition is satisfied, the condition is satisfied, and when the condition is not satisfied, the address saved in the second program counter 104 is set in the first program counter 101, and the second instruction register is set by the instruction selector 302. 303
Is selected and the instruction code of the instruction two instructions after the conditional branch instruction is held and executed in the first instruction register 301, and when the instruction fetch stage is two stages, the conditional branch instruction The branch hazard when the condition is satisfied can be reduced by 2 cycles.
【0049】以上のように、この実施の形態によれば、
条件分岐命令の分岐判定前に分岐アドレス15を第1の
プログラムカウンタ101に設定することによって先行
的にパイプラインに投入しているので、条件が成立した
ときには、分岐先命令についてのパイプライン処理の最
初の命令フェッチステージは終えていて、条件成立後は
2番目の命令解読ステージから分岐先命令についてのパ
イプライン処理が継続されることになるため、条件分岐
命令の分岐判定後に分岐先命令をパイプラインに投入す
る場合に比べて、分岐先命令を実行する場合の分岐ハザ
ードを削減することができる。As described above, according to this embodiment,
Since the branch address 15 is inserted into the pipeline in advance by setting the branch address 15 in the first program counter 101 before the branch judgment of the conditional branch instruction, when the condition is satisfied, the pipeline processing of the branch target instruction is executed. Since the first instruction fetch stage is completed and the pipeline processing for the branch target instruction is continued from the second instruction decoding stage after the condition is satisfied, the branch target instruction is piped after the branch judgment of the conditional branch instruction. It is possible to reduce the branch hazard when executing the branch destination instruction, as compared with the case where the branch target instruction is executed.
【0050】一方、条件分岐命令の分岐判定前に条件分
岐命令の後続命令のアドレスを第2のプログラムカウン
タ104に記憶させることで、条件分岐命令の後続命令
のアドレスを退避し、第1の命令レジスタ出力314を
第2の命令レジスタ303に格納することにより、条件
分岐命令の分岐判定前に条件分岐命令の後続命令の命令
コードを退避しているので、条件が不成立のときは、退
避していた条件分岐命令の後続命令のアドレスを第1の
プログラムカウンタ101に設定することによってパイ
プラインに戻すとともに、第2の命令レジスタ303か
ら命令コードを出力させることによってパイプラインに
戻すことにより、分岐ハザードを増加させることなく条
件分岐命令の後続命令を実行させることができる。した
がって、全体として見れば、分岐不成立時の分岐ハザー
ドを増加させることなく、分岐成立時の分岐ハザードを
削減することができ、プログラムを効率よく実行するこ
とができ、処理時間を短縮することが可能となる。On the other hand, by storing the address of the instruction subsequent to the conditional branch instruction in the second program counter 104 before the branch determination of the conditional branch instruction, the address of the instruction subsequent to the conditional branch instruction is saved and the first instruction is saved. By storing the register output 314 in the second instruction register 303, the instruction code of the instruction subsequent to the conditional branch instruction is saved before the branch determination of the conditional branch instruction. Therefore, when the condition is not satisfied, it is saved. Branch hazard by setting the address of the instruction subsequent to the conditional branch instruction to the pipeline by setting the first program counter 101 and returning to the pipeline by outputting the instruction code from the second instruction register 303. The instruction subsequent to the conditional branch instruction can be executed without increasing Therefore, as a whole, it is possible to reduce the branch hazard when the branch is taken without increasing the branch hazard when the branch is not taken, the program can be executed efficiently, and the processing time can be shortened. Becomes
【0051】また、単純に条件分岐命令の分岐判定前に
条件分岐命令の後続命令のアドレスと命令コードを退避
し、分岐アドレス15を先行的にパイプラインに投入す
るだけであるので、パイプラインの構成や命令の内容等
に制限を受けることなく、分岐ハザードを有効に低減す
ることができる。Further, since the address and the instruction code of the instruction subsequent to the conditional branch instruction are simply saved before the branch of the conditional branch instruction is judged , and the branch address 15 is inserted into the pipeline in advance, the pipeline The branch hazard can be effectively reduced without being restricted by the configuration or the content of the instruction.
【0052】特に、命令のフェッチステージが2段ある
4段パイプラインの場合に、条件成立時の分岐ハザード
を1サイクル削減することができる。また、命令のフェ
ッチステージが2段ある5段パイプラインの場合には、
条件成立時の分岐ハザードを2サイクル削減することが
できる。Particularly, in the case of a four-stage pipeline having two instruction fetch stages, the branch hazard when the condition is satisfied can be reduced by one cycle. Further, in the case of a 5-stage pipeline with two instruction fetch stages,
The branch hazard when the condition is satisfied can be reduced by 2 cycles.
【0053】なお、上述で命令のフェッチステージを2
段として説明したが、3段以上の任意の段数でも、フェ
ッチステージの段数に対応して命令レジスタを追加する
ことで同じ効果が得られることは明らかである。命令解
読ステージ1段のものと2段のものについて示したが、
3段以上のものについても、同じ効果が得られる。特
に、命令フェッチステージが3以上の場合において、命
令解読ステージを3以上にすることで、条件成立時の分
岐ハザードの削減サイクル数を3以上にすることもでき
る。In the above, the instruction fetch stage is set to 2
Although described as a stage, it is clear that the same effect can be obtained even if the number of stages is three or more by adding instruction registers corresponding to the number of stages of the fetch stage. I have shown the instruction decoding stage 1 stage and 2 stages,
The same effect can be obtained with three or more stages. In particular, when the instruction fetch stage is 3 or more, by setting the instruction decoding stage to 3 or more, the number of cycles of branch hazard reduction when the condition is satisfied can be set to 3 or more.
【0054】(第2の実施の形態)
以下本発明の第2の実施の形態の条件分岐処理における
プログラム制御方法およびその装置について、図面を参
照しながら説明する。[0054] The program control method and apparatus in conditional branch processing according to the second embodiment (second embodiment) Hereinafter the present invention will be described with reference to the drawings.
【0055】図3は本発明の第2の実施の形態における
プログラムカウンタ部1の構成を示すブロック図であ
る。図2と異なるのは、第2のプログラムカウンタ10
4の入力をアドレス加算器出力114からアドレス11
に変更した点である。図3において、図2と同一の機能
を有するものには同一の符号を付してその詳細な説明を
省略する。 FIG . 3 shows the second embodiment of the present invention.
FIG. 3 is a block diagram showing a configuration of a program counter unit 1.
It The difference from FIG. 2 is that the second program counter 10
4 input from address adder output 114 to address 11
It is a point changed to. In FIG. 3, the same function as in FIG.
The same reference numerals are given to those having
Omit it.
【0056】図5は本発明の第2の実施の形態における
命令レジスタ部3の構成を示すブロック図である。図4
と異なるのは、第2の命令保持手段となる第2の命令レ
ジスタ303の入力を、第1の命令コード12から第1
の命令レジスタ出力314に変更した点である。図5に
おいて、図4と同一の機能を有するものには同一の符号
を付してその詳細な説明を省略する。FIG. 5 is a block diagram showing the structure of the instruction register unit 3 in the second embodiment of the invention. Figure 4
Is different from the first instruction code 12 to the first instruction code
The instruction register output 314 is changed. 5 , those having the same functions as those in FIG. 4 are designated by the same reference numerals, and detailed description thereof will be omitted.
【0057】第2の実施の形態は、図1の基本構成のプ
ログラムカウンタ部1の構成を図3のようにし、命令レ
ジスタ部3の構成を図5のようにしたものである。な
お、分岐信号14はアドレス選択器用分岐信号111と
第2のプログラムカウンタ用分岐信号112と第1の命
令レジスタ用分岐信号311と命令選択器用分岐信号3
12と第2の命令レジスタ用分岐信号313からなる。[0057] The second embodiment is one in which as in Figure 3 the basic configuration of the program counter section 1 of the configuration of FIG. 1, the configuration of the instruction register unit 3 as in FIG. The branch signal 14 is the address selector branch signal 111, the second program counter branch signal 112, the first instruction register branch signal 311, and the instruction selector branch signal 3.
12 and a second instruction register branch signal 313.
【0058】以上のように構成されたプログラム制御装
置について、以下図10および図11を用いてその動作
を説明する。[0058] The configuration program controller as above, the operation will be described with reference to FIGS. 1 0 and 1 1 below.
【0059】図10は命令フェッチとして2ステージ設
けた場合の6段パイプライン(第1命令フェッチステー
ジIF1、第2命令フェッチステージIF2、第1命令
解読ステージDEC1、第2命令解読ステージDEC
2、第3命令解読ステージDEC3、命令実行ステージ
EX)の場合において、条件分岐命令を実行する場合の
制御フローを示すものである。この場合、条件分岐命令
のアドレスがN番地、分岐先命令のアドレスがM番地で
ある。また、図11はその時のタイミングチャートであ
る。以下、各パイプラインステージ毎にその動作を説明
する。なお、第1命令フェッチステージ、第2命令フェ
ッチステージおよび第1命令解読ステージについては説
明を省略している。
(1)条件分岐命令の第2命令解読ステージ
分岐判定器4が第2の命令コード13をデコードして条
件分岐命令であると判定し、分岐信号14と分岐アドレ
ス15を出力する。[0059] Figure 1 0 6-stage pipeline when provided 2-stage as an instruction fetch (first instruction fetch stage IF1, the second instruction fetch stage IF2, the first instruction decode stage DEC1, the second instruction decode stage DEC
2 shows a control flow when a conditional branch instruction is executed in the case of the second, third instruction decoding stage DEC3, and instruction execution stage EX). In this case, the address of the conditional branch instruction is N and the address of the branch target instruction is M. Further, FIG. 1 1 is a timing chart at that time. The operation of each pipeline stage will be described below. The description of the first instruction fetch stage, the second instruction fetch stage, and the first instruction decoding stage is omitted. (1) Second instruction decoding stage of conditional branch instruction The branch decision unit 4 decodes the second instruction code 13 and determines that it is a conditional branch instruction, and outputs a branch signal 14 and a branch address 15.
【0060】命令選択器用分岐信号312により、命令
選択器302がNOPコード(無処理コード)315を
選択して第2の命令コード13は、NOP命令となる。
(2)条件分岐命令の第3命令解読ステージ
第2のプログラムカウンタ用分岐信号112により、条
件分岐命令の3つ後のアドレス(N+3)を第2のプロ
グラムカウンタ104に設定する。これによって、条件
分岐命令の3つ後の命令のアドレス(N+3)を退避す
る。The instruction selector 302 selects the NOP code (unprocessed code) 315 by the instruction selector branch signal 312, and the second instruction code 13 becomes a NOP instruction. (2) Third instruction decoding stage of conditional branch instruction By the second program counter branch signal 112, the address (N + 3) after three conditional branch instructions is set in the second program counter 104. As a result, the address (N + 3) of the instruction three instructions after the conditional branch instruction is saved.
【0061】アドレス選択器用分岐信号111により、
アドレス選択器103が分岐アドレス15を選択して第
1のプログラムカウンタ101に分岐アドレス15を設
定し、アドレス11はM番地となる。これにより、分岐
判定が行われる時点(条件分岐命令の実行ステージの最
後)より前に、分岐先命令が先行的にパイプラインに投
入されたことになる。With the branch signal 111 for the address selector,
The address selector 103 selects the branch address 15 and sets the branch address 15 in the first program counter 101, and the address 11 becomes the address M. As a result, the branch destination instruction is inserted into the pipeline in advance before the time point when the branch determination is performed (the end of the execution stage of the conditional branch instruction).
【0062】第2の命令レジスタ用分岐信号313によ
り、条件分岐命令の1つ後の命令コード(N+1)を第
2の命令レジスタ303に設定する。これによって、条
件分岐命令の1つ後の命令コード(N+1)を退避す
る。The instruction code (N + 1) immediately after the conditional branch instruction is set in the second instruction register 303 by the second instruction register branch signal 313. As a result, the instruction code (N + 1) immediately after the conditional branch instruction is saved.
【0063】命令選択器用分岐信号312により、命令
選択器302がNOPコード(無処理コード)315を
選択して第2の命令コード13は、NOP命令となる。
(3)条件分岐命令の実行ステージ
命令選択器用分岐信号312により、命令選択器302
がNOPコード(無処理コード)315を選択して第2
の命令コード13は、NOP命令となる。
・条件成立時
(4)条件分岐命令の実行ステージの次ステージ
分岐信号14を解除し通常動作に戻り、第2の命令コー
ド13は、M番地の命令となる。The instruction selector branch signal 312 causes the instruction selector 302 to select the NOP code (unprocessed code) 315, and the second instruction code 13 becomes a NOP instruction. (3) By the branch signal 312 for the execution stage instruction selector of the conditional branch instruction, the instruction selector 302
Selects the NOP code (unprocessed code) 315 and the second
The instruction code 13 of is a NOP instruction. -When the condition is satisfied (4) The next stage branch signal 14 of the execution stage of the conditional branch instruction is released and the normal operation is resumed, and the second instruction code 13 becomes the instruction at the address M.
【0064】その結果、N番地の条件分岐命令の後に、
3サイクルの分岐ハザードが入るものの、M番地以降の
命令が順に実行されることになる。
・条件不成立時
(4)条件分岐命令の実行ステージの次ステージ
アドレス選択器用分岐信号111により、アドレス選択
器103が第2のプログラムカウンタ出力115を選択
して第1のプログラムカウンタ101に第2のプログラ
ムカウンタ104の値を設定し、アドレス11はN+3
番地となる。この結果、退避されていた後続命令のアド
レスがパイプラインに戻されることになる。また、第1
の命令レジスタ用分岐信号311により、第1の命令レ
ジスタ301がN+2番地の命令を保持する。As a result, after the conditional branch instruction at address N,
Although a branch hazard of 3 cycles is entered, the instructions after the address M will be executed in order. When the condition is not satisfied (4) The address selector 103 selects the second program counter output 115 by the branch signal 111 for the next stage address selector of the execution stage of the conditional branch instruction, and the first program counter 101 receives the second program counter output 115. Set the value of the program counter 104, and the address 11 is N + 3
It becomes the address. As a result, the saved address of the subsequent instruction is returned to the pipeline. Also, the first
The instruction register branch signal 311 causes the first instruction register 301 to hold the instruction at address N + 2.
【0065】命令選択器用分岐信号312により、命令
選択器302が第2の命令レジスタ出力316を選択し
て第2の命令コード13は、N+1番地の命令となる。
その結果、退避されていた後続命令の命令コードがパイ
プラインに戻されることになる。The instruction selector branch signal 312 causes the instruction selector 302 to select the second instruction register output 316, and the second instruction code 13 becomes the instruction at the address N + 1.
As a result, the instruction code of the saved subsequent instruction is returned to the pipeline.
【0066】(5)条件分岐命令の実行ステージの次々
ステージ
第1の命令レジスタ用分岐信号311により、第1の命
令レジスタ301がN+2番地の命令を保持して第2の
命令コード13は、N+2番地の命令となる。(5) Successive stages after execution of conditional branch instruction By the first instruction register branch signal 311, the first instruction register 301 holds the instruction at address N + 2 and the second instruction code 13 becomes N + 2. It becomes an instruction of the address.
【0067】その結果、N番地の条件分岐命令の後に、
3サイクルの分岐ハザードが入るもののN+1番地以降
の命令が順に実行されることになる。As a result, after the conditional branch instruction at address N,
Although the branch hazard of 3 cycles is entered, the instructions after the address N + 1 are sequentially executed.
【0068】上記の図1,図3,図6,図10および図
11に示されたプログラム制御方法は、以下のようにま
とめることができる。すなわち、プログラムカウンタ部
1が出力するアドレス11の当該命令コードをメモリ2
から命令レジスタ部3に取り出し、当該命令を実行する
ことにより、当該命令をパイプライン処理するときの条
件分岐の制御を行う際に、命令をデコードし、命令が条
件分岐命令である場合には、条件分岐命令の分岐判定前
に、命令レジスタ部3で命令コードを無処理命令コード
に置換し、ついでプログラムカウンタ部1で条件分岐命
令の3つ後の命令のアドレスを退避し、プログラムカウ
ンタ部1に分岐アドレス15を設定し、命令レジスタ部
3で条件分岐命令の1つ後の命令の命令コードを退避
し、命令レジスタ部3で命令コードを無処理命令コード
に置換し、ついで条件分岐命令の2つ後ろの命令の命令
コードを命令レジスタ部3で保持し、命令レジスタ部3
で命令コードを無処理命令コードに置換し、条件成立時
には、そのまま実行し、条件不成立時には、退避してい
た条件分岐命令の3つ後の命令のアドレスをプログラム
カウンタ部1に設定し、命令レジスタ部3が命令コード
を退避していた条件分岐命令の1つ後の命令の命令コー
ドに置換し、ついで条件分岐命令の2つ後の命令の命令
コードを命令レジスタ部3で保持して実行するというこ
とになる。The program control method shown in FIG. 1, FIG. 3, FIG. 6, FIG. 10 and FIG. 11 can be summarized as follows. That is, the instruction code of the address 11 output by the program counter unit 1 is stored in the memory 2
From the instruction register unit 3 to execute the instruction, the instruction is decoded when the conditional branch is controlled when the instruction is pipeline processed, and when the instruction is the conditional branch instruction, Before the branch judgment of the conditional branch instruction, the instruction register unit 3 replaces the instruction code with a non-processed instruction code, and the program counter unit 1 saves the address of the instruction three instructions after the conditional branch instruction. Branch address 15 is set in the instruction register unit 3, the instruction register unit 3 saves the instruction code of the instruction after the conditional branch instruction, the instruction register unit 3 replaces the instruction code with the unprocessed instruction code, and then the conditional branch instruction The instruction code of the instruction two behind is held in the instruction register unit 3, and the instruction register unit 3
Replaces the instruction code with an unprocessed instruction code, and when the condition is satisfied, it is executed as it is. When the condition is not satisfied, the address of the instruction three instructions after the saved conditional branch instruction is set in the program counter unit 1 and the instruction register The unit 3 replaces the instruction code with the instruction code of the instruction after the conditional branch instruction that has been saved, and then holds and executes the instruction code of the instruction after the conditional branch instruction in the instruction register unit 3. It turns out that.
【0069】上記の図1,図3,図6,図10および図
11に示されたプログラム制御装置は、以下のように構
成されている。すなわち、命令をパイプライン処理する
ときの条件分岐の制御を行うもので、分岐アドレス15
と分岐信号14とを入力し、アドレス11を生成するプ
ログラムカウンタ部1と、アドレス11に対応して第1
の命令コード12を格納または出力するメモリ2と、第
1の命令コード12と分岐信号14とを入力し、第2の
命令コード13を出力する命令レジスタ部3と、第2の
命令コード13をデコードして分岐を判定し、分岐信号
14と分岐アドレス15を出力する分岐判定器4を備え
ている。[0069] in the 1, 3, 6, a program control system shown in FIG. 1 0 and 1 1 is configured as follows. That is, it controls a conditional branch when the instruction is pipelined.
And a branch signal 14 to generate an address 11, and a program counter unit 1 for generating an address 11
Memory 2 for storing or outputting the instruction code 12 of No. 1, the instruction register unit 3 for inputting the first instruction code 12 and the branch signal 14 and outputting the second instruction code 13, and the second instruction code 13. A branch judging device 4 for decoding and judging a branch and outputting a branch signal 14 and a branch address 15 is provided.
【0070】この場合、プログラムカウンタ部1が第1
および第2のプログラムカウンタ101,104とアド
レス選択器103とアドレス加算器102とから構成さ
れている。そして、第1のプログラムカウンタ101が
アドレス選択器出力113を入力とし、アドレス11を
出力する。また、アドレス選択器103が分岐アドレス
15とアドレス加算器出力114と第2のプログラムカ
ウンタ出力115とを入力とし、分岐信号14により分
岐アドレス15とアドレス加算器出力114と第2のプ
ログラムカウンタ出力115との何れかを選択して出力
する。また、アドレス加算器102がアドレス11をイ
ンクリメントする。また、第2のプログラムカウンタ1
04がアドレス11を入力とし、分岐信号14によりア
ドレス11を保持する。In this case, the program counter section 1
It is also composed of second program counters 101 and 104, an address selector 103, and an address adder 102. Then, the first program counter 101 receives the address selector output 113 as an input and outputs the address 11. Further, the address selector 103 receives the branch address 15, the address adder output 114 and the second program counter output 115 as input, and the branch signal 14 causes the branch address 15, the address adder output 114 and the second program counter output 115. And either of them are output. Further, the address adder 102 increments the address 11. In addition, the second program counter 1
04 receives the address 11 and holds the address 11 by the branch signal 14.
【0071】一方、命令レジスタ部3が第1および第2
の命令レジスタ301,303と命令選択器302とか
ら構成されている。そして、第1の命令レジスタ301
が第1の命令コード12を入力とし、分岐信号14によ
り第1の命令コード12を保持する。また、第2の命令
レジスタ303が第1の命令レジスタ出力314を入力
とし、分岐信号14により第1の命令レジスタ出力31
4を保持する。また、命令選択器302が第1の命令レ
ジスタ出力314と第2の命令レジスタ出力316とN
OPコード315とを入力とし、分岐信号14により第
1の命令レジスタ出力314と第2の命令レジスタ出力
316とNOPコード315との何れかを選択して第2
の命令コード13として出力する。On the other hand, the instruction register unit 3 has the first and second instruction registers.
The instruction registers 301 and 303 and the instruction selector 302. Then, the first instruction register 301
Receives the first instruction code 12 and holds the first instruction code 12 by the branch signal 14. Further, the second instruction register 303 receives the first instruction register output 314 as an input, and the branch signal 14 causes the first instruction register output 31.
Hold 4 In addition, the instruction selector 302 outputs the first instruction register output 314, the second instruction register output 316, N
When the OP code 315 is input, any one of the first instruction register output 314, the second instruction register output 316, and the NOP code 315 is selected by the branch signal 14, and the second instruction register output 314 is selected.
Is output as the instruction code 13.
【0072】この構成によると、条件分岐命令の分岐判
定前に、命令選択器302でNOPコード315を選択
し、条件分岐命令の3つ後の命令のアドレスを第2のプ
ログラムカウンタ104に退避し、第1のプログラムカ
ウンタ101に分岐アドレス15を設定し、条件分岐命
令の1つ後の命令の命令コードを第2の命令レジスタ3
03に退避し、命令選択器302でNOPコード315
を選択し、条件成立時には、そのまま実行し、条件不成
立時には、第2のプログラムカウンタ104に退避して
いたアドレスを第1のプログラムカウンタ101に設定
し、命令選択器302で第2の命令レジスタ303を選
択し、条件分岐命令の2つ後の命令の命令コードを第1
の命令レジスタ301で保持して実行するように制御す
ることで、命令フェッチステージが2ステージの場合
に、条件分岐命令の条件成立時の分岐ハザードを2サイ
クル削減することができる。According to this structure, the branch judgment of the conditional branch instruction is made.
To a constant before, select the NOP code 315 in instruction selector 302, and saves the address of the instruction following three conditional branch instruction to the second program counter 104, sets a branch address 15 to the first program counter 101 Then, the instruction code of the instruction after the conditional branch instruction is stored in the second instruction register 3
03, and the NOP code 315 in the instruction selector 302
When the condition is satisfied, the program is executed as it is, and when the condition is not satisfied, the address saved in the second program counter 104 is set in the first program counter 101, and the second instruction register 303 is set by the instruction selector 302. And select the instruction code of the instruction two instructions after the conditional branch instruction as the first
When the instruction fetch stage has two stages, the branch hazard when the condition of the conditional branch instruction is satisfied can be reduced by two cycles by controlling the instruction register 301 to hold and execute the instruction.
【0073】以上のように、この実施の形態によれば、
前述の第1の実施の形態と同様に、命令のフェッチステ
ージが2段ある6段パイプラインの場合に、条件成立時
の分岐ハザードを2サイクル削減することができる。ま
た、第1の実施の形態に対して、分岐判定のステージを
1ステージ多くとることができる。As described above, according to this embodiment,
Similar to the above-described first embodiment, in the case of a 6-stage pipeline having two instruction fetch stages, the branch hazard when the condition is satisfied can be reduced by 2 cycles. Further, the number of stages of branch determination can be increased by one stage as compared with the first embodiment.
【0074】なお、上述で命令のフェッチステージを2
段として説明したが、3段以上の任意の段数でも、命令
レジスタを追加することで同じ効果が得られることは明
らかである。命令解読ステージが4ステージ以上であっ
ても、同様の効果が得られる。In the above, the instruction fetch stage is set to 2
Although the description has been given as a stage, it is apparent that the same effect can be obtained by adding the instruction register even if the number of stages is three or more. The same effect can be obtained even if the instruction decoding stage is four stages or more.
【0075】さらに、上述の第3命令解読ステージで行
った第2のプログラムカウンタ104への条件分岐命令
の3つ後のアドレス(N+3)の設定と、第2の命令レ
ジスタ303への条件分岐命令の1つ後の命令コード
(N+1)の設定を、第2命令解読ステージで行わせる
ことで、第1の実施の形態でも6段パイプラインを実現
できる。すなわち、第1の実施の形態との違いは、条件
分岐命令の後続命令の退避タイミングにある。 Furthermore, the address (N + 3) three times after the conditional branch instruction to the second program counter 104 performed in the above-mentioned third instruction decoding stage and the conditional branch instruction to the second instruction register 303 are set. By setting the instruction code (N + 1), which is one step after, in the second instruction decoding stage, the six-stage pipeline can be realized also in the first embodiment. That is, the difference from the first embodiment lies in the save timing of the instruction subsequent to the conditional branch instruction.
【0076】[0076]
【発明の効果】本発明のプログラム制御方法によれば、
命令をデコードし、命令が条件分岐命令である場合に
は、条件分岐命令の分岐判定前に分岐先命令を先行的に
パイプラインに投入しているので、条件が成立したとき
には、分岐先命令についてのパイプライン処理の少なく
とも最初のステージは終えていて、条件成立後は2番目
以降の何れかのステージから分岐先命令についてのパイ
プライン処理が継続されることになるため、条件分岐命
令の分岐判定後に分岐先命令をパイプラインに投入する
場合に比べて、分岐先命令を実行する場合の分岐ハザー
ドを削減することができる。According to the program control method of the present invention,
If the instruction is decoded and the instruction is a conditional branch instruction, the branch destination instruction is inserted into the pipeline in advance before the branch judgment of the conditional branch instruction. Since at least the first stage of the pipeline processing has been completed and after the condition is satisfied, the pipeline processing for the branch destination instruction will be continued from any of the second and subsequent stages, the branch determination of the conditional branch instruction is performed. It is possible to reduce the branch hazard when executing the branch destination instruction as compared with the case where the branch destination instruction is input to the pipeline later.
【0077】一方、命令をデコードし、命令が条件分岐
命令である場合には、条件分岐命令の分岐判定前に条件
分岐命令の後続命令のパイプライン情報として後続アド
レスおよび後続命令コードを退避しているので、条件が
不成立のときは、退避していた条件分岐命令の後続命令
のパイプライン情報をパイプラインに戻すことにより、
分岐ハザードを増加させることなく条件分岐命令の後続
命令を実行させることができる。On the other hand, if the instruction is decoded and the instruction is a conditional branch instruction, the subsequent address and the subsequent instruction code are saved as pipeline information of the subsequent instruction of the conditional branch instruction before the branch determination of the conditional branch instruction. Therefore, when the condition is not satisfied, by returning the pipeline information of the instruction subsequent to the saved conditional branch instruction to the pipeline,
The instruction subsequent to the conditional branch instruction can be executed without increasing the branch hazard.
【0078】したがって、全体として見れば、分岐不成
立時の分岐ハザードを増加させることなく、分岐成立時
の分岐ハザードを削減することができ、プログラムを効
率よく実行することができ、処理時間を短縮することが
可能となる。Therefore, as a whole, the branch hazard when the branch is taken can be reduced without increasing the branch hazard when the branch is not taken, the program can be executed efficiently, and the processing time is shortened. It becomes possible.
【0079】また、単純に命令をデコードし、命令が条
件分岐命令である場合には、条件分岐命令の分岐判定前
に条件分岐命令の後続命令のパイプライン情報として後
続アドレスおよび後続命令コードを退避し、分岐先命令
を先行的にパイプラインに投入するだけであるので、パ
イプラインの構成や命令の内容等に制限を受けることな
く、分岐ハザードを有効に低減することができる。Further, the instruction is simply decoded, and if the instruction is a conditional branch instruction, the subsequent address and the subsequent instruction code are saved as pipeline information of the instruction subsequent to the conditional branch instruction before the branch determination of the conditional branch instruction. However, since the branch destination instruction is only put into the pipeline in advance, the branch hazard can be effectively reduced without being restricted by the pipeline configuration, the instruction content, and the like.
【図1】本発明の第1および第2の実施の形態における
プログラム制御装置の基本構成を示すブロック図であ
る。FIG. 1 is a block diagram showing a basic configuration of a program control device according to first and second embodiments of the present invention.
【図2】本発明の第1の実施の形態におけるプログラム
カウンタ部の具体的な構成を示すブロック図である。FIG. 2 is a block diagram showing a specific configuration of a program counter section according to the first embodiment of the present invention.
【図3】本発明の第2の実施の形態におけるプログラム
カウンタ部の具体的な構成を示すブロック図である。FIG. 3 is a block diagram showing a specific configuration of a program counter section according to the second embodiment of the present invention.
【図4】本発明の第1の実施の形態における命令レジス
タ部の具体的な構成を示すブロック図である。 FIG. 4 is an instruction register according to the first embodiment of the present invention .
FIG. 3 is a block diagram showing a specific configuration of an input unit.
【図5】本発明の第2の実施の形態における命令レジス
タ部の具体的な構成を示すブロック図である。 FIG. 5 is an instruction register according to the second embodiment of the present invention .
FIG. 3 is a block diagram showing a specific configuration of an input unit.
【図6】本発明の第1の実施の形態における命令フェッ
チステージが2ステージの4段パイプラインの場合の条
件分岐の制御フローを示す流れ図である。 FIG. 6 is an instruction flag in the first embodiment of the present invention .
Articles for a four-stage pipeline with two stages
It is a flowchart which shows the control flow of case branch.
【図7】本発明の第1の実施の形態における命令フェッ
チステージが2ステージの4段パイプラインの場合の条
件分岐のタイミングを示すタイミング図である。 FIG. 7 is an instruction flag in the first embodiment of the present invention .
Articles for a four-stage pipeline with two stages
It is a timing diagram which shows the timing of case branch.
【図8】本発明の第1の実施の形態における命令フェッ
チステージが2ステージの5段パイプラインの場合の条
件分岐の制御フローを示す流れ図である。 FIG. 8 is an instruction flag in the first embodiment of the present invention .
Articles for a 5-stage pipeline with two stages
It is a flowchart which shows the control flow of case branch.
【図9】本発明の第1の実施の形態における命令フェッ
チステージが2ステージの5段パイプラインの場合の条
件分岐のタイミングを示すタイミング図である。 FIG. 9 is an instruction flag in the first embodiment of the present invention .
Articles for a 5-stage pipeline with two stages
It is a timing diagram which shows the timing of case branch.
【図10】本発明の第2の実施の形態における命令フェ
ッチステージが2ステージの6段パイプラインの場合の
条件分岐の制御フローを示す流れ図である。 FIG. 10 is an instruction buffer according to the second embodiment of the present invention .
In case of 6 stage pipeline with 2 stages
It is a flowchart which shows the control flow of a conditional branch.
【図11】本発明の第2の実施の形態における命令フェ
ッチステージが2ステージの6段パイプラインの場合の
条件分岐のタイミングを示すタイミング図である。 FIG. 11 is an instruction buffer according to the second embodiment of the present invention .
In case of 6 stage pipeline with 2 stages
It is a timing diagram which shows the timing of a conditional branch.
【図12】従来の命令フェッチステージが2ステージの
4段パイプラインの場合の条件分岐のタイミングを示す
タイミング図である。 FIG. 12 shows a conventional instruction fetch stage having two stages.
Shows the timing of conditional branching for a 4-stage pipeline
It is a timing diagram.
1 プログラムカウンタ部 2 メモリ 3 命令レジスタ部 4 分岐判定器 5 デコーダ部 6 演算部 11 アドレス 12 第1の命令コード 13 第2の命令コード 14 分岐信号 15 分岐アドレス 16 制御信号 17 条件フラグ信号 101 第1のプログラムカウンタ 102 アドレス加算器 103 アドレス選択器 104 第2のプログラムカウンタ 111 アドレス選択器用分岐信号 112 第2のプログラムカウンタ用分岐信号 113 アドレス選択器出力 114 アドレス加算器出力 115 第2のプログラムカウンタ出力 301 第1の命令レジスタ 302 命令選択器 303 第2の命令レジスタ 311 第1の命令レジスタ用分岐信号 312 命令選択器用分岐信号 314 命令レジスタ出力 315 NOPコード 1 Program counter section 2 memory 3 Instruction register section 4 Branch decision device 5 Decoder section 6 computing unit 11 addresses 12 First instruction code 13 Second instruction code 14 Branch signal 15 branch address 16 Control signal 17 Condition flag signal 101 first program counter 102 address adder 103 address selector 104 second program counter 111 Branch signal for address selector 112 Second program counter branch signal 113 Address selector output 114 address adder output 115 Second program counter output 301 First instruction register 302 Instruction selector 303 Second instruction register 311 First instruction register branch signal 312 Branch signal for instruction selector 314 Instruction register output 315 NOP code
フロントページの続き (58)調査した分野(Int.Cl.7,DB名) G06F 9/38 Continuation of front page (58) Fields surveyed (Int.Cl. 7 , DB name) G06F 9/38
Claims (3)
を含む複数のステージから構成され、前記命令解読ステ
ージの前に2段以上のステージを有するパイプラインで
命令を処理する情報処理装置であって、 前記情報処理装置が実行する命令を命令コードとして格
納する命令コード格納手段と、 前記命令コード格納手段からフェッチされる命令コード
のアドレスを指定する第1のアドレス保持手段と、 前記第1のアドレス保持手段が指定するアドレスに基づ
いて前記命令コード格納手段からフェッチされた命令コ
ードを格納する第1の命令保持手段と、 前記第1の命令保持手段に格納された命令コードが条件
分岐命令であるか否かを判定する分岐判定手段と、 前記第1の命令保持手段に格納された命令コードをデコ
ードするデコード手段と、 前記デコード手段におけるデコード結果に基づいて演算
を実行する演算手段と、 前記分岐判定手段の判定結果が、前記第1の命令保持手
段に格納された命令コードが条件分岐命令であることを
示すものである場合には、前記条件分岐命令の分岐判定
前に、前記条件分岐命令の後続アドレスが退避される第
2のアドレス保持手段と、 前記分岐判定手段の判定結果が、前記第1の命令保持手
段に格納された命令コードが条件分岐命令であることを
示すものである場合には、前記条件分岐命令の分岐判定
前に、前記条件分岐命令の後続命令コードが退避される
第2の命令保持手段とを備え、 前記分岐判定手段の判定結果が、前記第1の命令保持手
段に格納された命令コードが条件分岐命令であることを
示すものである場合には、前記分岐先命令を先行的に前
記パイプラインに投入し、 前記条件分岐命令の条件成立の場合は、前記分岐先命令
を実行し、 前記条件分岐命令の条件不成立の場合は、前記第2のア
ドレス保持手段へと退 避された前記後続アドレスを前記
第1のアドレス保持手段へと戻し、前記第2の命令保持
手段へと退避された前記後続命令コードを前記デコード
手段でデコードすることにより、前記条件分岐命令の後
続命令を実行することを特徴とする情報処理装置。 1. An instruction decoding stage and an instruction execution stage
Is composed of a plurality of stages including
Pipeline with two or more stages in front of
An information processing apparatus for processing instructions, wherein the instructions executed by the information processing apparatus are treated as instruction codes.
Instruction code storage means to be stored and instruction code fetched from the instruction code storage means
It based the address and the first address holding means for specifying, to the address where the first address holding means specifies
The instruction code fetched from the instruction code storage means.
A first instruction holding means for storing a code and an instruction code stored in the first instruction holding means
A branch determination means for determining whether or not the instruction is a branch instruction, and an instruction code stored in the first instruction holding means
Decoding means, and calculation based on the decoding result in the decoding means
And the determination result of the branch determining means is the first instruction holding means.
That the instruction code stored in the column is a conditional branch instruction
If so, the branch decision of the conditional branch instruction
First, the subsequent address of the conditional branch instruction is saved.
The address holding means of No. 2 and the judgment result of the branch judging means are the first instruction holding means.
That the instruction code stored in the column is a conditional branch instruction
If so, the branch decision of the conditional branch instruction
Previously, the instruction code subsequent to the conditional branch instruction is saved.
A second instruction holding unit, wherein the determination result of the branch determination unit is the first instruction holding unit.
That the instruction code stored in the column is a conditional branch instruction
If it is shown, the branch destination instruction is preceded by
If the condition of the conditional branch instruction is satisfied, the branch destination instruction is input to the pipeline.
Is executed, and if the condition is not established in the conditional branch instruction, the second A
Wherein the subsequent address that is removing all to dress holding means
Returning to the first address holding means, holding the second instruction
Means for decoding the subsequent instruction code saved in the means
After the conditional branch instruction by decoding by means
An information processing device, characterized in that it executes a subsequent instruction.
ージとを含む複数のステージから構成され、前記命令解
読ステージの前にn(n:2以上の整数)段のステージ
を有するパイプラインで命令を処理し、前記パイプライ
ンに投入される命令のアドレスを示す第1のアドレス保
持手段と、前記命令解読ステージにおいてデコードされ
る命令を格納する第1の命令保持手段と、前記第1のア
ドレス保持手段とは異なる第2のアドレス保持手段と、
前記第1の命令保持手段とは異なる第2の命令保持手段
とを備える情報処理装置における条件分岐の制御を行う
プログラム制御方法であって、 前記命令解読ステージにおいてデコードされた命令が条
件分岐命令である場合には、前記条件分岐命令の前記命
令実行ステージにおいて、前記条件分岐命令の後続命令
のパイプライン情報として、前記条件分岐命令よりn+
1後の命令のアドレスを前記第2のアドレス保持手段へ
と、前記条件分岐命令より1つ後の命令の命令コードを
前記第2の命令保持手段へと退避し、分岐先命令を先行
的に前記パイプラインに投入し、 前記条件分岐命令の条件成立の場合は、前記分岐先命令
をそのまま実行し、 前記条件分岐命令の条件不成立の場合は、前記第2のア
ドレス保持手段へと退避された前記条件分岐命令よりn
+1後の命令のアドレスを前記第1のアドレス保持手段
へと戻し、前記第2の命令保持手段へと退避された前記
条件分岐命令より1つ後の命令の命令コードをデコード
することにより、前記条件分岐命令の後続命令を実行す
ることを特徴とするプログラム制御方法。 2. An instruction decoding stage and an instruction execution stage.
And a plurality of stages including
N (n: integer of 2 or more) stages before the reading stage
Instructions in a pipeline having
The first address register that shows the address of the instruction
Holding means and decoded in the instruction decoding stage
And a first instruction holding means for storing an instruction to store
Second address holding means different from the dress holding means,
Second instruction holding means different from the first instruction holding means
Controls conditional branching in an information processing device including
A program control method, wherein the instructions decoded in the instruction decoding stage are
If it is a conditional branch instruction, the instruction of the conditional branch instruction
Instruction subsequent to the conditional branch instruction in the instruction execution stage
Pipeline information of n + from the conditional branch instruction
The address of the instruction after 1 is sent to the second address holding means.
And the instruction code of the instruction one instruction after the conditional branch instruction
Saves to the second instruction holding means and precedes the branch destination instruction
To the charged into the pipeline, if the conditions are satisfied in the conditional branch instruction, the branch target instruction
As it executes, if the condition is not established in the conditional branch instruction, the second A
From the conditional branch instruction saved to the dress holding means, n
The address of the instruction after +1 is stored in the first address holding means.
And returned to the second instruction holding means.
Decodes the instruction code of the instruction one instruction after the conditional branch instruction
To execute a subsequent instruction of the conditional branch instruction.
A program control method characterized by the following.
令解読ステージと命令実行ステージとを含む複数のステ
ージで構成され、前記第1の命令解読ステージの前にn
(n:2以上の整数)段のステージを有するパイプライ
ンで命令を処理し、前記パイプラインに投入される命令
のアドレスを示す第1のアドレス保持手段と、前記複数
の命令解読ステージのいずれかにおいてデコードされる
命令を 格納する第1の命令保持手段と、前記第1のアド
レス保持手段とは異なる第2のアドレス保持手段と、前
記第1の命令保持手段とは異なる第2の命令保持手段と
を備える情報処理装置における条件分岐の制御を行うプ
ログラム制御方法であって、 前記第1の命令解読ステージにおいてデコードされた命
令が条件分岐命令である場合には、前記第1の命令解読
ステージの次のステージにおいて、前記条件分岐命令の
後続命令のパイプライン情報として、前記条件分岐命令
よりn+1後の命令のアドレスを前記第2のアドレス保
持手段へと、前記条件分岐命令より1つ後の命令の命令
コードを前記第2の命令保持手段へと退避し、分岐先命
令を先行的に前記パイプラインに投入し、 前記条件分岐命令の条件成立の場合は、前記分岐先命令
をそのまま実行し、 前記条件分岐命令の条件不成立の場合は、前記第2のア
ドレス保持手段へと退避された前記条件分岐命令よりn
+1後の命令のアドレスを前記第1のアドレス保持手段
へと戻し、前記第2の命令保持手段へと退避された前記
条件分岐命令より1つ後の命令の命令コードをデコード
することにより、前記条件分岐命令の後続命令を実行す
ることを特徴とするプログラム制御方法。 3. A plurality of instructions including a first instruction decoding stage.
Multiple stages, including an instruction decoding stage and an instruction execution stage.
And n before the first instruction decoding stage.
Pipeline having (n: integer of 2 or more) stages
Instructions that are processed in the pipeline and input to the pipeline
First address holding means for indicating the address of the
Is decoded at any of the instruction decoding stages of
First instruction holding means for storing an instruction, and the first add
Address holding means different from the address holding means, and
A second instruction holding means different from the first instruction holding means;
A processor for controlling conditional branching in an information processing device equipped with
A program control method, wherein the instructions decoded in the first instruction decoding stage are
If the instruction is a conditional branch instruction, the first instruction decoding
In the next stage of the stage, the conditional branch instruction
The conditional branch instruction is used as pipeline information of the subsequent instruction.
The address of the instruction n + 1 later than the second address
To the holding means, an instruction of an instruction one after the conditional branch instruction
The code is saved to the second instruction holding means, and the branch destination is designated.
Instruction is put into the pipeline in advance, and if the condition of the conditional branch instruction is satisfied, the branch destination instruction
As it executes, if the condition is not established in the conditional branch instruction, the second A
From the conditional branch instruction saved to the dress holding means, n
The address of the instruction after +1 is stored in the first address holding means.
And returned to the second instruction holding means.
Decodes the instruction code of the instruction one instruction after the conditional branch instruction
To execute a subsequent instruction of the conditional branch instruction.
A program control method characterized by the following.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP18657098A JP3431503B2 (en) | 1997-07-02 | 1998-07-01 | Information processing apparatus and program control method |
Applications Claiming Priority (3)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP17707097 | 1997-07-02 | ||
| JP9-177070 | 1997-07-02 | ||
| JP18657098A JP3431503B2 (en) | 1997-07-02 | 1998-07-01 | Information processing apparatus and program control method |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JPH1173317A JPH1173317A (en) | 1999-03-16 |
| JP3431503B2 true JP3431503B2 (en) | 2003-07-28 |
Family
ID=26497744
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP18657098A Expired - Fee Related JP3431503B2 (en) | 1997-07-02 | 1998-07-01 | Information processing apparatus and program control method |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP3431503B2 (en) |
-
1998
- 1998-07-01 JP JP18657098A patent/JP3431503B2/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| JPH1173317A (en) | 1999-03-16 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US5404552A (en) | Pipeline risc processing unit with improved efficiency when handling data dependency | |
| JP3749233B2 (en) | Instruction execution method and apparatus in pipeline | |
| EP0297943B1 (en) | Microcode reading control system | |
| JPS62226232A (en) | Control system for branch instruction | |
| US6182211B1 (en) | Conditional branch control method | |
| JP3431503B2 (en) | Information processing apparatus and program control method | |
| JPH01183737A (en) | Information processor | |
| JP2772100B2 (en) | Parallel instruction fetch mechanism | |
| JP2924735B2 (en) | Pipeline operation device and decoder device | |
| JP2944563B2 (en) | Pipeline type information processing device | |
| JP2597744B2 (en) | Branch control method | |
| JP3493110B2 (en) | High-speed branch processing unit | |
| JPH0619705A (en) | Pipeline control method | |
| JPS60198640A (en) | Pipeline type information processor | |
| JPH0991139A (en) | Information processing device | |
| JPS6116334A (en) | Data processor | |
| JPH01271842A (en) | Information processor | |
| JPS59158441A (en) | Pipeline control system | |
| JPH0950374A (en) | Variable length delayed slot pipeline controller | |
| JPH08171492A (en) | Information processing device | |
| JPH04317130A (en) | Data processor | |
| JPH05181667A (en) | Microprogram control part | |
| JPH0338726A (en) | Branch instruction processor | |
| JPH06314196A (en) | Information processing method and device | |
| JPH10312280A (en) | Microprocessor |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20080523 Year of fee payment: 5 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20090523 Year of fee payment: 6 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20100523 Year of fee payment: 7 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110523 Year of fee payment: 8 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110523 Year of fee payment: 8 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120523 Year of fee payment: 9 |
|
| LAPS | Cancellation because of no payment of annual fees |