JP5609609B2 - Branch prediction apparatus and processor - Google Patents
Branch prediction apparatus and processor Download PDFInfo
- Publication number
- JP5609609B2 JP5609609B2 JP2010274921A JP2010274921A JP5609609B2 JP 5609609 B2 JP5609609 B2 JP 5609609B2 JP 2010274921 A JP2010274921 A JP 2010274921A JP 2010274921 A JP2010274921 A JP 2010274921A JP 5609609 B2 JP5609609 B2 JP 5609609B2
- Authority
- JP
- Japan
- Prior art keywords
- interval
- branch
- branch instruction
- storage unit
- instruction
- 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
Images
Landscapes
- Advance Control (AREA)
Description
本発明は、分岐予測装置およびプロセッサに関する。 The present invention relates to a branch prediction apparatus and a processor.
プロセッサの命令の一種である条件分岐命令では、条件分岐命令による分岐が成立したとき、命令実行経路が分岐する。したがって、条件分岐命令による分岐が成立したときには、条件分岐命令の次に実行される命令は、条件分岐命令に連続したアドレスの命令ではなく、条件分岐命令から離れたアドレスの命令に変更される。このため、条件分岐命令の次に実行される命令は、条件分岐命令が実行されるまで確定しない。すなわち、命令メモリから命令をフェッチ(取得)するためのアドレスは、条件分岐命令が実行されるまで確定しない。 In a conditional branch instruction which is a kind of instruction of a processor, an instruction execution path branches when a branch by a conditional branch instruction is established. Therefore, when the branch by the conditional branch instruction is established, the instruction executed next to the conditional branch instruction is changed to an instruction having an address separated from the conditional branch instruction, not an instruction having an address consecutive to the conditional branch instruction. For this reason, the instruction executed next to the conditional branch instruction is not determined until the conditional branch instruction is executed. That is, the address for fetching (acquiring) an instruction from the instruction memory is not determined until the conditional branch instruction is executed.
このため、プロセッサは、条件分岐命令が実行されるまでの間、命令メモリにアクセスできない。例えば、パイプライン処理を実施するプロセッサでは、命令メモリにアクセスできない期間(サイクル数)の発生は、性能劣化の要因になる。このため、パイプライン処理を実施するプロセッサは、例えば、分岐命令の結果を予測する分岐予測装置を有している。例えば、分岐予測装置には、動的分岐予測が広く採用されている。 For this reason, the processor cannot access the instruction memory until the conditional branch instruction is executed. For example, in a processor that performs pipeline processing, the occurrence of a period (the number of cycles) during which the instruction memory cannot be accessed causes performance degradation. For this reason, a processor that performs pipeline processing includes, for example, a branch prediction device that predicts the result of a branch instruction. For example, dynamic branch prediction is widely adopted for branch prediction devices.
動的分岐予測では、過去の条件分岐命令の実行結果をメモリに格納し、メモリに格納した実行結果を分岐予測に用いる(例えば、特許文献1、特許文献2参照)。分岐予測装置は、例えば、分岐命令による分岐が成立したか否かを示す分岐方向を記憶する方向履歴メモリと、分岐命令による分岐が成立したときの分岐先アドレスを記憶する分岐先履歴メモリとを有している。高速処理が必要なプロセッサに搭載された分岐予測装置は、例えば、命令のデコード処理が実施される前に、分岐予測を実施する。
In dynamic branch prediction, the execution result of a past conditional branch instruction is stored in a memory, and the execution result stored in the memory is used for branch prediction (see, for example,
命令のデコード処理が実施される前に分岐予測を実施する分岐予測装置は、命令フェッチ処理(命令メモリから命令を取得する処理)が実施される度に、方向履歴メモリ等の分岐予測用のメモリにアクセスする。これは、命令のデコード処理が実施されるまで、命令が分岐命令か否かわからないためである。このため、分岐予測装置は、分岐命令以外の命令が実行されるときにも、分岐予測用のメモリにアクセスする。このとき、分岐予測用のメモリへの不要なアクセスにより、不要な電力が消費される。 A branch prediction apparatus that performs branch prediction before instruction decode processing is executed is a branch prediction memory such as a direction history memory each time instruction fetch processing (processing to acquire an instruction from the instruction memory) is executed. To access. This is because it is not known whether the instruction is a branch instruction until the instruction decoding process is performed. For this reason, the branch prediction apparatus accesses the memory for branch prediction even when an instruction other than the branch instruction is executed. At this time, unnecessary power is consumed due to unnecessary access to the branch prediction memory.
本発明の一形態では、分岐予測装置は、分岐命令の結果を記憶する履歴記憶部を有し、履歴記憶部を参照して分岐予測を実施する予測部と、分岐命令に対応して分岐命令の間隔を記憶する間隔記憶部と、履歴記憶部を参照するタイミングを、間隔記憶部に記憶された分岐命令の間隔に基づいて決定する制御部と、分岐命令の間隔を計測するカウンタと、間隔記憶部の内容を、カウンタにより計測された分岐命令の間隔に基づいて更新する更新部とを有している。 In one aspect of the present invention, a branch prediction apparatus includes a history storage unit that stores a result of a branch instruction, a prediction unit that performs branch prediction with reference to the history storage unit, and a branch instruction corresponding to the branch instruction An interval storage unit that stores the interval of the history, a control unit that determines the timing of referring to the history storage unit based on the interval of the branch instruction stored in the interval storage unit, a counter that measures the interval of the branch instruction, and the interval And an update unit that updates the contents of the storage unit based on the interval of the branch instruction measured by the counter.
分岐予測用のメモリへの不要なアクセスを低減でき、消費電力を低減できる。 Unnecessary access to the branch prediction memory can be reduced, and power consumption can be reduced.
以下、実施形態を図面を用いて説明する。 Hereinafter, embodiments will be described with reference to the drawings.
図1は、一実施形態におけるプロセッサの例を示している。例えば、プロセッサは、パイプライン処理を実施する。プロセッサは、例えば、分岐予測装置BPRE1(図の波線で囲んだ部分)、プログラムカウンタPC、命令メモリIMEM、デコーダDEC、レジスタリード部RPD、算術論理演算ユニットALUおよびパイプラインレジスタPRG1、PRG2、PRG3を有している。以下、算術論理演算ユニットALUをALUとも称する。 FIG. 1 illustrates an example of a processor in one embodiment. For example, the processor performs pipeline processing. The processor includes, for example, a branch prediction device BPRE1 (the portion surrounded by a broken line in the figure), a program counter PC, an instruction memory IMEM, a decoder DEC, a register read unit RPD, an arithmetic logic unit ALU, and pipeline registers PRG1, PRG2, and PRG3. Have. Hereinafter, the arithmetic logic unit ALU is also referred to as ALU.
プログラムカウンタPCは、例えば、プロセッサが実行する命令のアドレスを示す値(以下、PC値とも称する)を、命令メモリIMEMおよび分岐予測装置BPRE1に出力する。例えば、プログラムカウンタPCの値(PC値)は、プロセッサが命令を実行する度に、増加する。あるいは、PC値は、分岐予測が実行されたとき、分岐予測装置BPRE1により予測された分岐先アドレスに設定される。なお、PC値は、パイプラインレジスタPRG1、PRG2、PRG3に順次転送される。 For example, the program counter PC outputs a value indicating an address of an instruction executed by the processor (hereinafter also referred to as a PC value) to the instruction memory IMEM and the branch prediction device BPRE1. For example, the value of the program counter PC (PC value) increases every time the processor executes an instruction. Alternatively, the PC value is set to the branch destination address predicted by the branch prediction device BPRE1 when the branch prediction is executed. The PC value is sequentially transferred to the pipeline registers PRG1, PRG2, and PRG3.
命令メモリIMEMは、PC値が示すアドレスの命令を、パイプラインレジスタPRG1に出力する。これにより、命令メモリIMEMから命令がフェッチ(取得)される。デコーダDECは、パイプラインレジスタPRG1に保持されている命令(命令メモリIMEMからフェッチした命令)を取得し、命令メモリIMEMからフェッチした命令を解読する。そして、デコーダDECは、解読結果を、パイプラインレジスタPRG2および分岐予測装置BPRE1に出力する。これにより、例えば、分岐予測装置BPRE1は、命令メモリIMEMからフェッチされた命令が分岐命令か否か判断できる。 The instruction memory IMEM outputs the instruction at the address indicated by the PC value to the pipeline register PRG1. As a result, the instruction is fetched (acquired) from the instruction memory IMEM. The decoder DEC acquires an instruction (an instruction fetched from the instruction memory IMEM) held in the pipeline register PRG1, and decodes the instruction fetched from the instruction memory IMEM. Then, the decoder DEC outputs the decoding result to the pipeline register PRG2 and the branch prediction device BPRE1. Thereby, for example, the branch prediction apparatus BPRE1 can determine whether or not the instruction fetched from the instruction memory IMEM is a branch instruction.
レジスタリード部RDPは、例えば、デコーダDECの解読結果をパイプラインレジスタPRG2から取得し、デコーダDECの解読結果に基づいて、命令のオペランド等をレジスタから読み出す。そして、レジスタリード部RDPは、レジスタから読み出したオペランド等をパイプラインレジスタPRG3に出力する。ALUは、例えば、パイプラインレジスタPRG3から命令のオペランド等を取得し、四則演算や論理演算等を実行する。このように、プロセッサは、パイプライン処理を実施する。 For example, the register read unit RDP acquires the decoding result of the decoder DEC from the pipeline register PRG2, and reads out the operand of the instruction from the register based on the decoding result of the decoder DEC. Then, the register read unit RDP outputs the operand read from the register to the pipeline register PRG3. For example, the ALU acquires an operand of an instruction from the pipeline register PRG3, and executes four arithmetic operations, logical operations, and the like. In this way, the processor performs pipeline processing.
分岐予測装置BPRE1は、間隔記憶部DMEM1、予測部PRED、予測制御部PCNT1、カウンタCOTおよび更新部UPP1を有し、分岐命令の結果を予測する。例えば、間隔記憶部DMEM1、予測部PREDおよび予測制御部PCNT1は、パイプライン処理の命令フェッチ処理(命令メモリIMEMから命令を取得する処理)が実施されるステージと同じステージで動作する。また、例えば、カウンタCOTおよび更新部UPP1は、パイプライン処理のデコード処理(命令を解読する処理)が実施されるステージと同じステージで動作する。 The branch prediction apparatus BPRE1 includes an interval storage unit DMEM1, a prediction unit PRED, a prediction control unit PCNT1, a counter COT, and an update unit UPP1, and predicts the result of a branch instruction. For example, the interval storage unit DMEM1, the prediction unit PRED, and the prediction control unit PCNT1 operate in the same stage as the stage in which the instruction fetch process of the pipeline process (a process of acquiring an instruction from the instruction memory IMEM) is performed. Further, for example, the counter COT and the update unit UPP1 operate in the same stage as the stage in which the pipeline processing decode processing (processing for decoding the instruction) is performed.
間隔記憶部DMEM1は、分岐命令に対応して分岐命令の間隔(以下、分岐命令間隔とも称する)を記憶する。例えば、間隔記憶部DMEM1は、分岐命令のPC値の一部(例えば、PC値の下位ビット)をアドレスとして、分岐命令間隔を記憶する。あるいは、間隔記憶部DMEM1は、分岐命令のPC値から生成されるハッシュ値をアドレスとして、分岐命令間隔を記憶する。 The interval storage unit DMEM1 stores a branch instruction interval (hereinafter also referred to as a branch instruction interval) corresponding to the branch instruction. For example, the interval storage unit DMEM1 stores the branch instruction interval by using a part of the PC value of the branch instruction (for example, the lower bits of the PC value) as an address. Alternatively, the interval storage unit DMEM1 stores the branch instruction interval using a hash value generated from the PC value of the branch instruction as an address.
予測制御部PCNT1は、予測部PREDの履歴記憶部HMEMを参照するタイミングを、間隔記憶部DMEM1に記憶された分岐命令間隔に基づいて決定する。例えば、予測制御部PCNT1は、命令フェッチ処理(命令メモリIMEMから命令を取得する処理)が実施される度にカウントアップするカウンタ(図1のカウンタCOTとは別のカウンタ)を有している。すなわち、予測制御部PCNT1内のカウンタは、PC値が変化する度にカウントアップする。そして、予測制御部PCNT1は、間隔記憶部DMEM1から読み出した分岐命令間隔と予測制御部PCNT1内のカウンタの値とが一致したとき、制御部PCNT1内のカウンタをリセットする。 The prediction control unit PCNT1 determines the timing for referring to the history storage unit HMEM of the prediction unit PRED based on the branch instruction interval stored in the interval storage unit DMEM1. For example, the prediction control unit PCNT1 has a counter (a counter different from the counter COT in FIG. 1) that counts up each time an instruction fetch process (a process for acquiring an instruction from the instruction memory IMEM) is performed. That is, the counter in the prediction control unit PCNT1 counts up whenever the PC value changes. The prediction control unit PCNT1 resets the counter in the control unit PCNT1 when the branch instruction interval read from the interval storage unit DMEM1 matches the counter value in the prediction control unit PCNT1.
また、予測制御部PCNT1は、間隔記憶部DMEM1から読み出した分岐命令間隔と予測制御部PCNT1内のカウンタの値とが一致したとき、例えば、履歴記憶部HMEMへの参照タイミングであることを示す情報を予測部PREDに通知する。さらに、予測制御部PCNT1は、間隔記憶部DMEM1から読み出した分岐命令間隔と予測制御部PCNT1内のカウンタの値とが一致したとき、例えば、次の分岐命令までの間隔を示す分岐命令間隔を間隔記憶部DMEM1から読み出す。 In addition, the prediction control unit PCNT1 indicates, for example, the reference timing to the history storage unit HMEM when the branch instruction interval read from the interval storage unit DMEM1 matches the counter value in the prediction control unit PCNT1. Is notified to the prediction unit PRED. Further, when the branch instruction interval read from the interval storage unit DMEM1 matches the counter value in the prediction control unit PCNT1, the prediction control unit PCNT1 sets, for example, a branch instruction interval indicating an interval until the next branch instruction. Read from the storage unit DMEM1.
すなわち、間隔記憶部DMEM1は、例えば、履歴記憶部HMEMが予測部PREDにより参照されるとき、予測制御部PCNT1により参照される。このように、予測制御部PCNT1は、間隔記憶部DMEM1から読み出した分岐命令間隔に基づいて、間隔記憶部DMEM1および履歴記憶部HMEMを参照するタイミングを決定する。すなわち、予測制御部PCNT1は、間隔記憶部DMEM1から読み出した分岐命令間隔に基づいて、命令が分岐命令か否かを予測する。 That is, the interval storage unit DMEM1 is referred to by the prediction control unit PCNT1 when the history storage unit HMEM is referred to by the prediction unit PRED, for example. As described above, the prediction control unit PCNT1 determines the timing for referring to the interval storage unit DMEM1 and the history storage unit HMEM based on the branch instruction interval read from the interval storage unit DMEM1. That is, the prediction control unit PCNT1 predicts whether the instruction is a branch instruction based on the branch instruction interval read from the interval storage unit DMEM1.
予測部PREDは、分岐命令の結果を記憶する履歴記憶部HMEMを有している。履歴記憶部HMEMは、例えば、分岐命令による分岐が成立したか否かを示す分岐方向を記憶する方向履歴メモリと、分岐命令による分岐が成立したときの分岐先アドレスを記憶する分岐先履歴メモリとを有している。なお、履歴記憶部HMEMは、分岐先履歴メモリを含まずに構成されてもよい。 The prediction unit PRED has a history storage unit HMEM that stores the result of the branch instruction. The history storage unit HMEM includes, for example, a direction history memory that stores a branch direction indicating whether or not a branch by a branch instruction is established, and a branch destination history memory that stores a branch destination address when a branch by a branch instruction is established. have. The history storage unit HMEM may be configured without including the branch destination history memory.
例えば、予測部PREDは、履歴記憶部HMEMに記憶されている分岐方向の情報に基づいて、分岐命令による分岐が成立するか否かを予測する。そして、予測部PREDは、分岐命令による分岐が成立すると予測したとき、履歴記憶部HMEMに記憶されている分岐先アドレスを、プログラムカウンタPCに通知する。これにより、分岐先アドレスがプログラムカウンタPCに設定される。このように、予測部PREDは、履歴記憶部HMEMに記憶されている情報を参照して、分岐予測を実施する。 For example, the prediction unit PRED predicts whether or not a branch by a branch instruction is established based on the information on the branch direction stored in the history storage unit HMEM. When the prediction unit PRED predicts that a branch instruction is taken, the prediction unit PRED notifies the program counter PC of the branch destination address stored in the history storage unit HMEM. As a result, the branch destination address is set in the program counter PC. Thus, the prediction unit PRED performs branch prediction with reference to the information stored in the history storage unit HMEM.
なお、上述したように、履歴記憶部HMEMが参照されるタイミングは、予測制御部PCNT1により制御される。例えば、予測部PREDは、履歴記憶部HMEMへの参照タイミングであることを示す情報を予測制御部PCNT1から受けたとき、履歴記憶部HMEMを参照する。すなわち、予測部PREDは、間隔記憶部DMEM1に記憶された分岐命令間隔で、履歴記憶部HMEMを参照する。これにより、予測部PREDは、命令が解読される前に分岐予測を実施するときにも、履歴記憶部HMEM等への不要なアクセスを低減できる。したがって、この実施形態では、履歴記憶部HMEMや間隔記憶部DMEM1への不要なアクセスを低減でき、消費電力を低減できる。 As described above, the timing at which the history storage unit HMEM is referred to is controlled by the prediction control unit PCNT1. For example, the prediction unit PRED refers to the history storage unit HMEM when receiving information from the prediction control unit PCNT1 indicating that it is the reference timing to the history storage unit HMEM. That is, the prediction unit PRED refers to the history storage unit HMEM at the branch instruction interval stored in the interval storage unit DMEM1. Thereby, the prediction unit PRED can reduce unnecessary access to the history storage unit HMEM and the like even when branch prediction is performed before the instruction is decoded. Therefore, in this embodiment, unnecessary access to the history storage unit HMEM and the interval storage unit DMEM1 can be reduced, and power consumption can be reduced.
カウンタCOTは、プログラムが実行されたときの分岐命令の間隔を計測する。例えば、カウンタCOTは、デコーダDECにより解読された命令が分岐命令のときに、更新部UPP1によりリセットされる。すなわち、カウンタCOTは、分岐命令が実行される度にリセットされる。そして、カウンタCOTは、例えば、パイプラインレジスタPRG1に保持されているPC値が変化する度に、カウントアップする。すなわち、カウンタCOTは、命令が命令メモリIMEMからフェッチされる度に、カウントアップする。更新部UPP1は、間隔記憶部DMEM1の内容を、カウンタCOTにより計測された分岐命令間隔に基づいて更新する。 The counter COT measures the interval between branch instructions when the program is executed. For example, the counter COT is reset by the updating unit UPP1 when the instruction decoded by the decoder DEC is a branch instruction. That is, the counter COT is reset every time a branch instruction is executed. For example, the counter COT counts up whenever the PC value held in the pipeline register PRG1 changes. That is, the counter COT counts up every time an instruction is fetched from the instruction memory IMEM. The update unit UPP1 updates the contents of the interval storage unit DMEM1 based on the branch instruction interval measured by the counter COT.
なお、分岐予測装置BPRE1の構成は、この例に限定されない。例えば、予測制御部PCNT1は、間隔記憶部DMEM1へのアクセスを停止可能に構成され、間隔記憶部DMEM1へのアクセスを分岐命令の連続する期間に停止してもよい。間隔記憶部DMEM1へのアクセスが停止されている期間では、例えば、分岐予測は命令毎に実施される。あるいは、予測制御部PCNT1は、例えば、予測部PRED内に設けられてもよい。 Note that the configuration of the branch prediction device BPRE1 is not limited to this example. For example, the prediction control unit PCNT1 may be configured to be able to stop access to the interval storage unit DMEM1, and may stop access to the interval storage unit DMEM1 during a period in which branch instructions are continuous. In a period in which access to the interval storage unit DMEM1 is stopped, for example, branch prediction is performed for each instruction. Alternatively, the prediction control unit PCNT1 may be provided in the prediction unit PRED, for example.
また、間隔記憶部DMEM1は、予測部PRED内に設けられてもよい。例えば、間隔記憶部DMEM1は、履歴記憶部HMEMの方向履歴メモリや分岐先履歴メモリのビット幅に分岐命令間隔を記憶するためのビットを追加して構成されてもよい。あるいは、間隔記憶部DMEM1は、予測部PREDにより参照されてもよい。例えば、予測部PREDが間隔記憶部DMEM1から分岐命令間隔を読み出す構成では、予測部PREDは、間隔記憶部DMEM1から読み出した分岐命令間隔を、予測制御部PCNT1に通知する。 Further, the interval storage unit DMEM1 may be provided in the prediction unit PRED. For example, the interval storage unit DMEM1 may be configured by adding a bit for storing the branch instruction interval to the bit width of the direction history memory or the branch destination history memory of the history storage unit HMEM. Alternatively, the interval storage unit DMEM1 may be referred to by the prediction unit PRED. For example, in a configuration in which the prediction unit PRED reads the branch instruction interval from the interval storage unit DMEM1, the prediction unit PRED notifies the prediction control unit PCNT1 of the branch instruction interval read from the interval storage unit DMEM1.
また、カウンタCOTは、更新部UPP1内に設けられてもよい。さらに、例えば、パイプライン処理の演算処理(ALUの処理)のステージで分岐命令の判定を実施するプロセッサに搭載される分岐予測装置BPRE1では、カウンタCOTおよび更新部UPP1は、演算処理のステージと同じステージで動作するように構成されてもよい。 Further, the counter COT may be provided in the update unit UPP1. Further, for example, in the branch prediction device BPRE1 installed in the processor that performs the branch instruction determination at the stage of the pipeline processing operation (ALU processing), the counter COT and the update unit UPP1 are the same as the operation processing stage. It may be configured to operate on a stage.
図2は、図1に示した分岐予測装置BPRE1の一例を示している。なお、図2では、更新部UPP1について説明する。図2の符号PC1、BRPCは、パイプラインレジスタPRG1およびレジスタREG1にそれぞれ保持されているPC値を示している。また、命令INSTは、例えば、命令メモリIMEMからフェッチされた命令を示すコードである。 FIG. 2 shows an example of the branch prediction device BPRE1 shown in FIG. In FIG. 2, the update unit UPP1 will be described. Reference numerals PC1 and BRPC in FIG. 2 indicate PC values held in the pipeline register PRG1 and the register REG1, respectively. The instruction INST is, for example, a code indicating an instruction fetched from the instruction memory IMEM.
更新部UPP1は、レジスタREG1および更新制御部UCNT1を有している。レジスタREG1は、例えば、分岐命令のPC値を保持する。例えば、レジスタREG1のレジスタ値BRPC(PC値)は、分岐命令が実行される度に更新される。更新制御部UCNT1は、命令INSTが分岐命令か否かを示す情報をデコーダDECから受けるとともに、カウンタCOTのカウンタ値WCTをカウンタCOTから受ける。そして、更新制御部UCNT1は、命令が分岐命令のとき、カウンタCOTをリセットするとともに、間隔記憶部DMEM1の内容を更新する。 The update unit UPP1 includes a register REG1 and an update control unit UCNT1. The register REG1 holds, for example, the PC value of the branch instruction. For example, the register value BRPC (PC value) of the register REG1 is updated every time a branch instruction is executed. The update control unit UCNT1 receives information indicating whether or not the instruction INST is a branch instruction from the decoder DEC and also receives the counter value WCT of the counter COT from the counter COT. When the instruction is a branch instruction, the update control unit UCNT1 resets the counter COT and updates the contents of the interval storage unit DMEM1.
例えば、更新制御部UCNT1は、レジスタ値BRPCに基づいて、間隔記憶部DMEM1の更新対象のアドレス(PC値の下位ビットやハッシュ値等)を算出する。そして、更新制御部UCNT1は、更新対象のアドレスのデータを、カウンタ値WCT(分岐命令間隔)に更新する。また、更新部UPP1は、例えば、間隔記憶部DMEM1の内容を更新する際に、レジスタ値BRPCを、パイプラインレジスタPRG1に保持されているPC値(PC1)に更新する。これにより、レジスタ値BRPCは、分岐命令が実行される度に更新される。 For example, the update control unit UCNT1 calculates an update target address (lower bits of PC value, hash value, etc.) of the interval storage unit DMEM1 based on the register value BRPC. Then, the update control unit UCNT1 updates the data of the update target address to the counter value WCT (branch instruction interval). For example, when updating the contents of the interval storage unit DMEM1, the update unit UPP1 updates the register value BRPC to the PC value (PC1) held in the pipeline register PRG1. Thereby, the register value BRPC is updated every time a branch instruction is executed.
図3は、図1に示した間隔記憶部DMEM1の最初の更新動作の一例を示している。図3では、プログラムカウンタPCの値(0x0024等)を16進で示している。また、図3の太い線で囲んだ命令brは、分岐命令を示している。そして、命令otherは、分岐命令以外の命令を示している。図3の○印は、分岐命令による分岐の成立(taken)を示し、×印は、分岐命令による分岐の不成立(not taken)を示している。図3の“−”は、レジスタREG1に意味のない値(初期値)が書き込まれていることを示している。また、間隔記憶部DMEM1の初期値は、例えば、“0”に設定されている。なお、この初期値は、特に意味はない。 FIG. 3 shows an example of the first update operation of the interval storage unit DMEM1 shown in FIG. In FIG. 3, the value of the program counter PC (0x0024 etc.) is shown in hexadecimal. Further, an instruction br surrounded by a thick line in FIG. 3 indicates a branch instruction. The instruction other indicates an instruction other than the branch instruction. In FIG. 3, “◯” indicates that a branch instruction is taken (taken), and “X” indicates that a branch instruction is not taken (not take). “-” In FIG. 3 indicates that a meaningless value (initial value) is written in the register REG1. The initial value of the interval storage unit DMEM1 is set to “0”, for example. This initial value has no particular meaning.
PC値が“0x0028”のとき、分岐命令brが実行される。このとき、カウンタ値WCTは、“0”にリセットされる。また、レジスタ値BRPCは、“0x0028”に更新される。PC値“0x0028”の分岐命令brによる分岐が成立したため、“0x0100”のPC値の命令が分岐命令brの次に実行される。このとき、カウンタ値WCTは、“0”から“1”にカウントアップする。 When the PC value is “0x0028”, the branch instruction br is executed. At this time, the counter value WCT is reset to “0”. The register value BRPC is updated to “0x0028”. Since the branch by the branch instruction br having the PC value “0x0028” is established, the instruction having the PC value “0x0100” is executed next to the branch instruction br. At this time, the counter value WCT is incremented from “0” to “1”.
PC値が“0x0104”のとき、PC値“0x0028”の分岐命令brの次の分岐命令brが実行される。このとき、レジスタ値BRPC(“0x0028”)に基づくアドレスの間隔記憶部DMEM1のデータは、カウンタ値WCTの“1”に更新される(図3の(a))。そして、カウンタ値WCTが“0”にリセットされ、レジスタ値BRPCが“0x0028”から“0x0104”に更新される。 When the PC value is “0x0104”, the branch instruction br next to the branch instruction br having the PC value “0x0028” is executed. At this time, the data in the address interval storage unit DMEM1 based on the register value BRPC (“0x0028”) is updated to “1” as the counter value WCT ((a) of FIG. 3). Then, the counter value WCT is reset to “0”, and the register value BRPC is updated from “0x0028” to “0x0104”.
PC値“0x0104”の分岐命令brによる分岐が不成立のため、PC値“0x0108”の命令が分岐命令brの次に実行される。このとき、カウンタ値WCTは、“0”から“1”にカウントアップする。プログラムは、次の分岐命令brが実行されるまで、連続したアドレスの順番で実行される。この間、カウンタ値WCTは、命令が実行される度にカウントアップする。なお、レジスタ値BRPCは、“0x0104”に保持されている。 Since the branch by the branch instruction br having the PC value “0x0104” is not established, the instruction having the PC value “0x0108” is executed next to the branch instruction br. At this time, the counter value WCT is incremented from “0” to “1”. The program is executed in the order of consecutive addresses until the next branch instruction br is executed. During this time, the counter value WCT is counted up each time an instruction is executed. Note that the register value BRPC is held at “0x0104”.
PC値が“0x0114”のとき、PC値“0x0104”の分岐命令brの次の分岐命令brが実行される。このとき、レジスタ値BRPC(“0x0104”)に基づくアドレスの間隔記憶部DMEM1のデータは、カウンタ値WCTの“3”に更新される(図3の(b))。そして、カウンタ値WCTが“0”にリセットされ、レジスタ値BRPCが“0x0104”から“0x0114”に更新される。この動作により、間隔記憶部DMEM1は、分岐命令に対応して分岐命令間隔を記憶する。 When the PC value is “0x0114”, the branch instruction br next to the branch instruction br having the PC value “0x0104” is executed. At this time, the data in the address interval storage unit DMEM1 based on the register value BRPC (“0x0104”) is updated to “3” of the counter value WCT ((b) in FIG. 3). Then, the counter value WCT is reset to “0”, and the register value BRPC is updated from “0x0104” to “0x0114”. By this operation, the interval storage unit DMEM1 stores the branch instruction interval corresponding to the branch instruction.
図4は、図1に示した分岐予測装置BPRE1の動作の一例を示している。なお、図4は、例えば、図3に示した更新動作が実施された後の分岐予測装置BPRE1の動作の一例を示している。図4の○印および×印の意味は、図3と同じである。なお、図4の例では、履歴記憶部HMEMは、分岐命令による分岐が成立したか否かを示す分岐方向を記憶する方向履歴メモリDIRMと、分岐命令による分岐が成立したときの分岐先アドレスを記憶する分岐先履歴メモリDESMとを有している。図4の“−”は、分岐先履歴メモリDESMに分岐先アドレスが記憶されていないことを示している。また、図4の網掛けは、履歴記憶部HMEMおよび間隔記憶部DMEM1が参照されない期間(命令サイクル)を示している。 FIG. 4 shows an example of the operation of the branch prediction apparatus BPRE1 shown in FIG. FIG. 4 shows an example of the operation of the branch prediction device BPRE1 after the update operation shown in FIG. 3 is performed, for example. The meanings of the circles and the crosses in FIG. 4 are the same as those in FIG. In the example of FIG. 4, the history storage unit HMEM stores a direction history memory DIRM that stores a branch direction indicating whether or not a branch by a branch instruction is established, and a branch destination address when the branch by the branch instruction is established. It has a branch destination history memory DESM for storing. “-” In FIG. 4 indicates that the branch destination address is not stored in the branch destination history memory DESM. 4 indicates a period (command cycle) in which the history storage unit HMEM and the interval storage unit DMEM1 are not referred to.
PC値が“0x0028”のとき、分岐予測装置BPRE1は、方向履歴メモリDIRMおよび分岐先履歴メモリDESMを参照して、分岐予測を実施する。例えば、分岐予測装置BPRE1は、PC値“0x0028”に基づくアドレスの方向履歴メモリDIRMの情報が分岐成立(taken)を示しているため、PC値“0x0028”の分岐命令brによる分岐が成立すると予測する。そして、分岐予測装置BPRE1は、分岐先履歴メモリDESMに記憶されている分岐先アドレス“0x0100”をプログラムカウンタPCに設定する。また、分岐予測装置BPRE1は、PC値“0x0028”の分岐命令brの次の分岐命令brまでの間隔を示す分岐命令間隔“1”を、PC値“0x0028”に基づくアドレスの間隔記憶部DMEM1から読み出す。 When the PC value is “0x0028”, the branch prediction device BPRE1 refers to the direction history memory DIRM and the branch destination history memory DESM to perform branch prediction. For example, the branch prediction device BPRE1 predicts that a branch by the branch instruction br of the PC value “0x0028” is established because the information in the direction history memory DIRM of the address based on the PC value “0x0028” indicates that the branch is established (taken). To do. Then, the branch prediction device BPRE1 sets the branch destination address “0x0100” stored in the branch destination history memory DESM in the program counter PC. Further, the branch prediction apparatus BPRE1 sets the branch instruction interval “1” indicating the interval from the branch instruction br of the PC value “0x0028” to the next branch instruction br from the address interval storage unit DMEM1 based on the PC value “0x0028”. read out.
分岐予測装置BPRE1は、間隔記憶部DMEM1から読み出した分岐命令間隔が“1”であるため、PC値“0x0028”の次の命令では、分岐予測を実施しない。すなわち、PC値が“0x0100”の期間T10では、分岐予測装置BPRE1は、分岐予測を実施しない。したがって、PC値が“0x0100”の期間T10では、間隔記憶部DMEM1、方向履歴メモリDIRMおよび分岐先履歴メモリDESMは、参照されない。 Since the branch instruction interval read from the interval storage unit DMEM1 is “1”, the branch prediction device BPRE1 does not perform branch prediction for the instruction next to the PC value “0x0028”. That is, in the period T10 in which the PC value is “0x0100”, the branch prediction device BPRE1 does not perform branch prediction. Therefore, in the period T10 in which the PC value is “0x0100”, the interval storage unit DMEM1, the direction history memory DIRM, and the branch destination history memory DESM are not referred to.
PC値が“0x0104”のとき、分岐予測装置BPRE1は、方向履歴メモリDIRMおよび分岐先履歴メモリDESMを参照して、分岐予測を実施する。この際、分岐予測装置BPRE1は、PC値“0x0104”に基づくアドレスの間隔記憶部DMEM1から分岐命令間隔“3”を読み出す。分岐予測装置BPRE1は、間隔記憶部DMEM1から読み出した分岐命令間隔が“3”であるため、PC値“0x0104”の後続3命令は分岐命令でないと予測する。したがって、PC値が“0x0108”から“0x0110”の期間T20では、分岐予測装置BPRE1は、分岐予測を実施しない。すなわち、PC値が“0x0108”から“0x0110”の期間T20では、間隔記憶部DMEM1、方向履歴メモリDIRMおよび分岐先履歴メモリDESMは、参照されない。 When the PC value is “0x0104”, the branch prediction device BPRE1 refers to the direction history memory DIRM and the branch destination history memory DESM to perform branch prediction. At this time, the branch prediction device BPRE1 reads the branch instruction interval “3” from the address interval storage unit DMEM1 based on the PC value “0x0104”. Since the branch instruction interval read from the interval storage unit DMEM1 is “3”, the branch predicting device BPRE1 predicts that the subsequent three instructions having the PC value “0x0104” are not branch instructions. Therefore, in the period T20 in which the PC value is “0x0108” to “0x0110”, the branch prediction device BPRE1 does not perform branch prediction. That is, in the period T20 in which the PC value is “0x0108” to “0x0110”, the interval storage unit DMEM1, the direction history memory DIRM, and the branch destination history memory DESM are not referenced.
PC値が“0x0114”のとき(“0x0108”から3命令後)、分岐予測装置BPRE1は、方向履歴メモリDIRMおよび分岐先履歴メモリDESMを参照して分岐予測を実施するとともに、間隔記憶部DMEM1から分岐命令間隔を読み出す。間隔記憶部DMEM1から読み出された分岐命令間隔が“7”であるため、PC値“0x0114”の後続7命令の期間T30では、間隔記憶部DMEM1、方向履歴メモリDIRMおよび分岐先履歴メモリDESMは、参照されない。 When the PC value is “0x0114” (after 3 instructions from “0x0108”), the branch prediction device BPRE1 performs branch prediction with reference to the direction history memory DIRM and the branch destination history memory DESM, and from the interval storage unit DMEM1. Read the branch instruction interval. Since the branch instruction interval read from the interval storage unit DMEM1 is “7”, the interval storage unit DMEM1, the direction history memory DIRM, and the branch destination history memory DESM are in the period T30 of the subsequent seven instructions with the PC value “0x0114”. , Not referenced.
このように、分岐予測装置BPRE1は、命令が分岐命令でないと予測される期間T10、T20、T30では、分岐予測を実施しない。したがって、この実施形態では、不要な分岐予測の回数を低減でき、消費電力を低減できる。例えば、命令が分岐命令でないと予測される期間T10、T20、T30では、間隔記憶部DMEM1、方向履歴メモリDIRMおよび分岐先履歴メモリDESMは参照されない。このため、この実施形態では、間隔記憶部DMEM1、方向履歴メモリDIRMおよび分岐先履歴メモリDESMへの不要なアクセスを低減でき、消費電力を低減できる。 Thus, the branch prediction device BPRE1 does not perform branch prediction in the periods T10, T20, and T30 in which the instruction is predicted not to be a branch instruction. Therefore, in this embodiment, the number of unnecessary branch predictions can be reduced, and power consumption can be reduced. For example, in the periods T10, T20, and T30 in which the instruction is predicted not to be a branch instruction, the interval storage unit DMEM1, the direction history memory DIRM, and the branch destination history memory DESM are not referenced. Therefore, in this embodiment, unnecessary access to the interval storage unit DMEM1, the direction history memory DIRM, and the branch destination history memory DESM can be reduced, and power consumption can be reduced.
ここで、分岐命令でない命令が分岐命令と予測されたとき(例えば、PC値“0x0104”の命令が分岐命令でないとき)には、履歴記憶部HMEM等が参照されるため、電力は消費されるが、誤動作にはならない。なお、この場合でも、命令毎に分岐予測が実施される構成に比べて、消費電力を低減できる。また、分岐命令でないと予測した期間に分岐命令brが実行されたとき(例えば、PC値“0x0110”の命令が分岐命令のとき)には、分岐予測が実施されず、分岐が不成立とみなされる。このとき、プロセッサのサイクル性能は劣化するが、誤動作にはならない。したがって、間隔記憶部DMEM1に記憶されている分岐命令間隔が実際の分岐命令間隔と異なるときにも、誤動作にはならない。 Here, when an instruction that is not a branch instruction is predicted to be a branch instruction (for example, when an instruction with a PC value of “0x0104” is not a branch instruction), the history storage unit HMEM and the like are referred to, so that power is consumed. However, it does not malfunction. Even in this case, power consumption can be reduced compared to a configuration in which branch prediction is performed for each instruction. Further, when the branch instruction br is executed during a period in which it is predicted not to be a branch instruction (for example, when the instruction with the PC value “0x0110” is a branch instruction), branch prediction is not performed and the branch is regarded as not established. . At this time, the cycle performance of the processor deteriorates but does not malfunction. Therefore, even when the branch instruction interval stored in the interval storage unit DMEM1 is different from the actual branch instruction interval, no malfunction occurs.
図5は、3ビットのデータ幅を有する間隔記憶部DMEM1の状態の一例を示している。なお、図5は、分岐命令間隔が“10”のときの間隔記憶部DMEM1の状態の一例を示している。 FIG. 5 shows an example of the state of the interval storage unit DMEM1 having a 3-bit data width. FIG. 5 shows an example of the state of the interval storage unit DMEM1 when the branch instruction interval is “10”.
間隔記憶部DMEM1のデータ幅で記憶できる最大値(図5の例では、“7”)以上の分岐命令間隔(図5の例では、“10”)は、複数回(複数個所)に分けて記憶される。例えば、PC値“0x0028”の分岐命令brの次の分岐命令br(PC値“0x0128”)までの間隔が“10”のとき、PC値“0x0028”に基づくアドレスの間隔記憶部DMEM1には、“7”が記憶される。そして、PC値“0x0028”の次のPC値“0x0100”から7命令後のPC値“0x011C”に基づくアドレスの間隔記憶部DMEM1には、“2”が記憶される。これにより、分岐予測装置BPRE1は、PC値“0x0128”の分岐命令に対して、分岐予測を実施することができる。 A branch instruction interval (“10” in the example of FIG. 5) greater than the maximum value (“7” in the example of FIG. 5) that can be stored with the data width of the interval storage unit DMEM1 is divided into a plurality of times (a plurality of locations). Remembered. For example, when the interval from the branch instruction br of the PC value “0x0028” to the next branch instruction br (PC value “0x0128”) is “10”, the interval storage unit DMEM1 of the address based on the PC value “0x0028” “7” is stored. Then, “2” is stored in the address interval storage unit DMEM1 based on the PC value “0x011C” seven instructions after the PC value “0x0100” next to the PC value “0x0028”. As a result, the branch prediction apparatus BPRE1 can perform branch prediction on the branch instruction having the PC value “0x0128”.
例えば、PC値が“0x0028”のとき、分岐予測装置BPRE1は、PC値“0x0028”に基づくアドレスの間隔記憶部DMEM1に記憶されている分岐命令間隔“7”を読み出す。分岐予測装置BPRE1は、間隔記憶部DMEM1から読み出した分岐命令間隔が“7”であるため、“0x0028”の後続7命令は分岐命令でないと予測する。したがって、PC値が“0x0100”から“0x0118”の7命令の間では、分岐予測装置BPRE1は、分岐予測を実施しない。 For example, when the PC value is “0x0028”, the branch prediction device BPRE1 reads the branch instruction interval “7” stored in the address interval storage unit DMEM1 based on the PC value “0x0028”. Since the branch instruction interval read from the interval storage unit DMEM1 is “7”, the branch predicting device BPRE1 predicts that the subsequent seven instructions “0x0028” are not branch instructions. Therefore, the branch prediction device BPRE1 does not perform the branch prediction between the seven instructions whose PC values are “0x0100” to “0x0118”.
そして、PC値が“0x011C”のとき(“0x0100”から7命令後)、PC値“0x011C”に基づくアドレスの間隔記憶部DMEM1に記憶されている分岐命令間隔“2”を読み出す。また、分岐予測装置BPRE1は、PC値“0x011C”の命令を分岐命令と予測しているため、分岐予測を実施する。なお、上述したように、分岐命令でない命令が分岐命令と予測されたときにも誤動作にはならない。分岐予測装置BPRE1は、間隔記憶部DMEM1から読み出した分岐命令間隔が“2”であるため、“0x011C”の後続2命令は分岐命令でないと予測する。 When the PC value is “0x011C” (7 instructions after “0x0100”), the branch instruction interval “2” stored in the address interval storage unit DMEM1 based on the PC value “0x011C” is read. Further, since the branch prediction apparatus BPRE1 predicts an instruction with the PC value “0x011C” as a branch instruction, it performs branch prediction. As described above, no malfunction occurs even when an instruction that is not a branch instruction is predicted as a branch instruction. Since the branch instruction interval read from the interval storage unit DMEM1 is “2”, the branch predicting device BPRE1 predicts that the subsequent two instructions of “0x011C” are not branch instructions.
PC値が“0x0128”のとき(“0x0120”から2命令後)、PC値“0x0128”に基づくアドレスの間隔記憶部DMEM1に記憶されている分岐命令間隔“3”を読み出す。また、分岐予測装置BPRE1は、PC値“0x0128”の命令を分岐命令と予測しているため、分岐予測を実施する。このように、この実施形態では、2つの分岐命令の間隔が間隔記憶部DMEM1に記憶できる最大値以上のときにも、2つの分岐命令のそれぞれに対して、分岐予測を実施できる。 When the PC value is “0x0128” (after two instructions from “0x0120”), the branch instruction interval “3” stored in the address interval storage unit DMEM1 based on the PC value “0x0128” is read. Further, since the branch prediction device BPRE1 predicts an instruction with the PC value “0x0128” as a branch instruction, it performs branch prediction. Thus, in this embodiment, branch prediction can be performed for each of the two branch instructions even when the interval between the two branch instructions is equal to or greater than the maximum value that can be stored in the interval storage unit DMEM1.
なお、間隔記憶部DMEM1のデータ幅は、3ビットに限定されない。また、例えば、3ビットのカウンタCOTを用いた構成においても、図5と同様の動作により、カウンタCOTの最大値以上の分岐命令間隔に対応できる。このように、この実施形態では、間隔記憶部DMEM1のデータ幅やカウンタCOTのビット幅を分岐命令間隔の最大値以下にできるため、分岐予測装置BPRE1の回路規模を小さくできる。 Note that the data width of the interval storage unit DMEM1 is not limited to 3 bits. Further, for example, even in a configuration using a 3-bit counter COT, it is possible to cope with a branch instruction interval equal to or larger than the maximum value of the counter COT by the same operation as in FIG. As described above, in this embodiment, the data width of the interval storage unit DMEM1 and the bit width of the counter COT can be made equal to or less than the maximum value of the branch instruction interval, so that the circuit scale of the branch prediction device BPRE1 can be reduced.
図6は、図2に示した更新部UPP1およびカウンタCOTの動作の一例を示している。処理S100−S140は、例えば、デコード処理が実施される度に実施される。なお、図6の符号DMAXは、間隔記憶部DMEM1のデータ幅で記憶できる最大値を示している。また、図6の符号BRPC’は、レジスタ値BRPCから算出されるアドレス(レジスタ値BRPCの下位ビットやハッシュ値等)を示している。 FIG. 6 shows an example of operations of the updating unit UPP1 and the counter COT shown in FIG. The processes S100 to S140 are performed every time the decoding process is performed, for example. 6 indicates the maximum value that can be stored with the data width of the interval storage unit DMEM1. 6 indicates an address calculated from the register value BRPC (lower bits of the register value BRPC, hash value, etc.).
処理S100では、例えば、更新部UPP1の更新制御部UCNT1は、デコーダDECから受けた情報に基づいて、デコード処理された命令が分岐命令か否かを判定する。命令が分岐命令でないとき(処理S100のNo)、更新部UPP1の動作は、処理S110に移る。処理S110では、更新制御部UCNT1は、カウンタ値WCTが最大値DMAXと一致するか否かを判定する。 In the process S100, for example, the update control unit UCNT1 of the update unit UPP1 determines whether the decoded instruction is a branch instruction based on the information received from the decoder DEC. When the instruction is not a branch instruction (No in process S100), the operation of the update unit UPP1 proceeds to process S110. In process S110, the update control unit UCNT1 determines whether or not the counter value WCT matches the maximum value DMAX.
カウンタ値WCTが最大値DMAXでないとき(処理S110のNo)、処理S120において、カウンタCOTのカウンタ値WCTがカウントアップする。これにより、カウンタCOTは、命令が命令メモリIMEMからフェッチされる度に、カウントアップする。一方、カウンタ値WCTが最大値DMAXのとき(処理S110のYes)、更新部UPP1の動作は、処理S130に移る。また、処理S100において、命令が分岐命令であると判定されたとき(処理S100のYes)、更新部UPP1の動作は、処理S130に移る。 When the counter value WCT is not the maximum value DMAX (No in step S110), the counter value WCT of the counter COT is incremented in step S120. As a result, the counter COT counts up every time an instruction is fetched from the instruction memory IMEM. On the other hand, when the counter value WCT is the maximum value DMAX (Yes in process S110), the operation of the update unit UPP1 moves to process S130. When it is determined in process S100 that the instruction is a branch instruction (Yes in process S100), the operation of the update unit UPP1 proceeds to process S130.
処理S130では、更新制御部UCNT1は、間隔記憶部DMEM1を更新する。例えば、更新制御部UCNT1は、更新する間隔記憶部DMEM1のアドレスADRをレジスタ値BRPCから算出する。そして、更新制御部UCNT1は、カウンタ値WCTをデータDATとして、間隔記憶部DMEM1のアドレスADR(BRPC’)の内容を更新する。これにより、間隔記憶部DMEM1は、分岐命令が実行される度に更新される。このため、実行される命令が分岐命令か否かの予測精度を向上できる。 In process S130, the update control unit UCNT1 updates the interval storage unit DMEM1. For example, the update control unit UCNT1 calculates the address ADR of the interval storage unit DMEM1 to be updated from the register value BRPC. Then, the update control unit UCNT1 updates the contents of the address ADR (BRPC ') of the interval storage unit DMEM1 using the counter value WCT as the data DAT. As a result, the interval storage unit DMEM1 is updated each time a branch instruction is executed. For this reason, it is possible to improve the prediction accuracy as to whether or not the instruction to be executed is a branch instruction.
なお、この実施形態では、分岐命令間隔が最大値DMAX以上のとき、処理S110および処理S130により、分岐命令(例えば、図5のPC値“0x0028”の分岐命令)に対応するアドレスに最大値DMAXを記憶できる。そして、間隔記憶部DMEM1に最大値DMAXを更新したときのPC値(例えば、図5のPC値“0x011C”)を起点にして、次に実施される分岐命令までの間隔が算出される。 In this embodiment, when the branch instruction interval is equal to or greater than the maximum value DMAX, the maximum value DMAX is added to the address corresponding to the branch instruction (for example, the branch instruction having the PC value “0x0028” in FIG. 5) by the processes S110 and S130. Can be stored. Then, using the PC value (for example, the PC value “0x011C” in FIG. 5) when the maximum value DMAX is updated in the interval storage unit DMEM1, the interval until the next branch instruction is calculated.
処理S140では、更新制御部UCNT1は、レジスタREG1およびカウンタCOTを初期化する。例えば、更新制御部UCNT1は、パイプラインレジスタPRG1に保持されているPC値(PC1)を、レジスタREG1のレジスタ値BRPCに設定する。また、更新制御部UCNT1は、カウンタCOTのカウンタ値WCTを“0”にリセットする。このように、カウンタCOTは、間隔記憶部DMEM1の内容が更新される度に、リセットされる。 In process S140, the update control unit UCNT1 initializes the register REG1 and the counter COT. For example, the update control unit UCNT1 sets the PC value (PC1) held in the pipeline register PRG1 to the register value BRPC of the register REG1. Further, the update control unit UCNT1 resets the counter value WCT of the counter COT to “0”. Thus, the counter COT is reset every time the content of the interval storage unit DMEM1 is updated.
なお、処理S140では、例えば、処理S110の判定結果(Yes)により処理S130が実施されたときには、レジスタ値BRPCは、間隔記憶部DMEM1を最大値DMAXに更新したときのPC値(例えば、図5のPC値“0x011C”)に設定される。これにより、この実施形態では、間隔記憶部DMEM1の最大値DMAX以上の分岐命令間隔を、複数回(複数個所)に分けて記憶できる。 In the process S140, for example, when the process S130 is performed based on the determination result (Yes) of the process S110, the register value BRPC is the PC value when the interval storage unit DMEM1 is updated to the maximum value DMAX (for example, FIG. 5). PC value “0x011C”). Thereby, in this embodiment, the branch instruction interval equal to or larger than the maximum value DMAX of the interval storage unit DMEM1 can be divided and stored a plurality of times (a plurality of locations).
このように、分岐命令が実行される度に間隔記憶部DMEM1の内容を更新する構成は、更新動作が単純である。このため、分岐予測装置BPRE1の構成を簡易にできる。なお、更新部UPP1の動作は、この例に限定されない。例えば、更新部UPP1の動作は、カウンタ値WCTが最大値DMAXになったとき(処理S110のYes)、処理S130、S140を実施せずに、終了してもよい。これにより、カウンタ値WCTは、間隔記憶部DMEM1が更新されるまで、最大値DMAXに維持される。この場合、更新部UPP1は、分岐命令間隔が最大値DMAX以上のとき、分岐命令間隔を複数回(複数個所)に分けずに、最大値DMAXを分岐命令間隔として間隔記憶部DMEM1に記憶する。この結果、分岐命令でない命令に対応するアドレス(例えば、図5のPC値“0x011C”に対応するアドレス)には、分岐命令間隔は記憶されない。 Thus, the configuration for updating the contents of the interval storage unit DMEM1 every time a branch instruction is executed has a simple update operation. For this reason, the configuration of the branch prediction device BPRE1 can be simplified. The operation of the update unit UPP1 is not limited to this example. For example, the operation of the updating unit UPP1 may be terminated without performing the processes S130 and S140 when the counter value WCT reaches the maximum value DMAX (Yes in the process S110). Thus, the counter value WCT is maintained at the maximum value DMAX until the interval storage unit DMEM1 is updated. In this case, when the branch instruction interval is equal to or greater than the maximum value DMAX, the updating unit UPP1 stores the maximum value DMAX as the branch instruction interval in the interval storage unit DMEM1 without dividing the branch instruction interval into a plurality of times (a plurality of locations). As a result, the branch instruction interval is not stored in an address corresponding to an instruction that is not a branch instruction (for example, an address corresponding to the PC value “0x011C” in FIG. 5).
ここで、例えば、リセット後の先頭の分岐命令に対するデコード処理が実施された時点では、レジスタ値BRPCやカウンタ値WCTは、意味のない値である。このため、リセット後の先頭の分岐命令では、意味のない値が間隔記憶部DMEM1に書き込まれる。この意味のない値の書き込みは、リセット後の先頭の分岐命令のみで発生するため、特に問題ない。なお、更新部UPP1は、書き込み不可を示すフラグ等を有し、意味のない値の書き込みを防止してもよい。例えば、フラグは、リセット後の先頭の分岐命令の次の分岐命令に対するデコード処理が実施されるまで、間隔記憶部DMEM1への書き込み不可を示している。 Here, for example, the register value BRPC and the counter value WCT are meaningless at the time when the decoding process is performed on the first branch instruction after reset. For this reason, a meaningless value is written in the interval storage unit DMEM1 in the first branch instruction after reset. This meaningless value writing occurs only with the first branch instruction after resetting, and thus there is no particular problem. Note that the update unit UPP1 may have a flag indicating that writing is impossible, and may prevent writing of a meaningless value. For example, the flag indicates that writing to the interval storage unit DMEM1 is impossible until the decoding process for the branch instruction next to the first branch instruction after reset is performed.
以上、この実施形態では、分岐予測装置BPRE1は、分岐命令間隔が記憶される間隔記憶部DMEM1を有している。間隔記憶部DMEM1に記憶された分岐命令間隔は、履歴記憶部HMEMおよび間隔記憶部DMEM1を参照するタイミングを決定するために使用される。例えば、予測制御部PCNT1は、履歴記憶部HMEMおよび間隔記憶部DMEM1を参照するタイミングを、間隔記憶部DMEM1から読み出した分岐命令間隔に基づいて決定する。これにより、この実施形態では、命令が解読される前に分岐予測を実施するときにも、履歴記憶部HMEMおよび間隔記憶部DMEM1への不要なアクセスを低減でき、消費電力を低減できる。したがって、この実施形態の分岐予測装置BPRE1は、高速処理の必要なプロセッサに搭載されたときにも、消費電力を低減できる。 As described above, in this embodiment, the branch prediction device BPRE1 has the interval storage unit DMEM1 in which the branch instruction interval is stored. The branch instruction interval stored in the interval storage unit DMEM1 is used to determine the timing for referring to the history storage unit HMEM and the interval storage unit DMEM1. For example, the prediction control unit PCNT1 determines the timing for referring to the history storage unit HMEM and the interval storage unit DMEM1 based on the branch instruction interval read from the interval storage unit DMEM1. Thus, in this embodiment, even when branch prediction is performed before an instruction is decoded, unnecessary access to the history storage unit HMEM and the interval storage unit DMEM1 can be reduced, and power consumption can be reduced. Therefore, the branch prediction apparatus BPRE1 of this embodiment can reduce power consumption even when mounted on a processor that requires high-speed processing.
図7は、別の実施形態における間隔記憶部DMEM2の一例を示している。上述した実施形態で説明した要素と同一の要素については、同一の符号を付し、これ等については、詳細な説明を省略する。なお、図7では、PC値“0x0028”の分岐命令brにより実行されなかったPC値および命令を破線で囲んだ枠内に示している。 FIG. 7 shows an example of the interval storage unit DMEM2 in another embodiment. The same elements as those described in the above-described embodiment are denoted by the same reference numerals, and detailed description thereof will be omitted. In FIG. 7, the PC value and the instruction that have not been executed by the branch instruction br having the PC value “0x0028” are shown in a frame surrounded by a broken line.
この実施形態の間隔記憶部DMEM2は、分岐命令による分岐が成立したときの分岐命令間隔と分岐命令による分岐が不成立のときの分岐命令間隔との両方を記憶する。分岐予測装置BPRE1のその他の構成は、上述した実施形態と同じである。また、この実施形態の分岐予測装置BPRE1が搭載されるプロセッサは、上述した実施形態と同じである。なお、例えば、間隔記憶部DMEM2は、履歴記憶部HMEMの方向履歴メモリや分岐先履歴メモリのビット幅に分岐命令間隔を記憶するためのビットを追加して構成されてもよい。 The interval storage unit DMEM2 of this embodiment stores both the branch instruction interval when the branch instruction is taken and the branch instruction interval when the branch instruction is not taken. Other configurations of the branch prediction apparatus BPRE1 are the same as those in the above-described embodiment. The processor on which the branch prediction device BPRE1 of this embodiment is mounted is the same as that of the above-described embodiment. For example, the interval storage unit DMEM2 may be configured by adding a bit for storing a branch instruction interval to the bit width of the direction history memory or the branch destination history memory of the history storage unit HMEM.
PC値“0x0028”に基づくアドレスの間隔記憶部DMEM2には、例えば、分岐命令brによる分岐が成立したときの分岐命令間隔“1”と分岐命令brによる分岐が不成立のときの分岐命令間隔“2”とがそれぞれ記憶される。例えば、予測制御部PCNT1は、PC値“0x0028”に基づくアドレスの方向履歴メモリDIRMの情報が分岐成立(taken)を示しているため、分岐命令による分岐が成立したときの分岐命令間隔“1”を間隔記憶部DMEM2から読み出す。したがって、分岐予測装置BPRE1は、“0x0028”の次の命令は分岐命令でないと予測する。図7の例では、方向履歴メモリDIRMの情報に基づいて参照される間隔記憶部DMEM2の分岐命令間隔を太い線で囲んで示している。 The address interval storage unit DMEM2 based on the PC value “0x0028” includes, for example, a branch instruction interval “1” when a branch by the branch instruction br is established and a branch instruction interval “2” when a branch by the branch instruction br is not established. "Is stored. For example, since the information in the direction history memory DIRM of the address based on the PC value “0x0028” indicates that the branch has been taken (taken), the prediction control unit PCNT1 has the branch instruction interval “1” when the branch by the branch instruction is taken. Are read from the interval storage unit DMEM2. Therefore, the branch prediction device BPRE1 predicts that the instruction next to “0x0028” is not a branch instruction. In the example of FIG. 7, the branch instruction interval of the interval storage unit DMEM2 referred to based on the information in the direction history memory DIRM is surrounded by a thick line.
なお、間隔記憶部DMEM2には、PC値“0x0028”の分岐命令brによる分岐が不成立のときの分岐命令間隔として“2”が記憶されている。このため、PC値“0x0028”の分岐命令brによる分岐が不成立のときには、分岐予測装置BPRE1は、“0x0028”の後続2命令は分岐命令でないと予測する。例えば、予測制御部PCNT1は、PC値“0x0028”に基づくアドレスの方向履歴メモリDIRMの情報が分岐の不成立(not taken)を示しているときには、“0x0028”の後続2命令は分岐命令でないと予測する。したがって、分岐予測装置BPRE1は、PC値が“0x0034”のとき(“0x002C”から2命令後)、分岐予測を実施する。 The interval storage unit DMEM2 stores “2” as the branch instruction interval when the branch by the branch instruction br having the PC value “0x0028” is not established. For this reason, when the branch by the branch instruction br of the PC value “0x0028” is not established, the branch predicting device BPRE1 predicts that the subsequent two instructions of “0x0028” are not branch instructions. For example, when the information in the direction history memory DIRM of the address based on the PC value “0x0028” indicates that the branch is not taken (not taken), the prediction control unit PCNT1 predicts that the subsequent two instructions of “0x0028” are not branch instructions. To do. Therefore, when the PC value is “0x0034” (after two instructions from “0x002C”), the branch prediction device BPRE1 performs branch prediction.
以上、この実施形態においても、上述した実施形態と同様の効果を得ることができる。さらに、この実施形態では、間隔記憶部DMEM2は、分岐命令による分岐が成立したときの分岐命令間隔と分岐命令による分岐が不成立のときの分岐命令間隔との両方を記憶する。このため、実行される命令が分岐命令か否かの予測精度を、分岐が成立するか否かにかかわらず、向上できる。 As described above, also in this embodiment, the same effect as that of the above-described embodiment can be obtained. Further, in this embodiment, the interval storage unit DMEM2 stores both the branch instruction interval when the branch instruction is taken and the branch instruction interval when the branch instruction is not taken. Therefore, it is possible to improve the prediction accuracy of whether or not the instruction to be executed is a branch instruction regardless of whether or not a branch is taken.
これにより、この実施形態では、例えば、分岐命令を分岐命令でないと予測する頻度を低減できるため、プロセッサのサイクル性能を向上できる。あるいは、この実施形態では、分岐命令以外の命令を分岐命令であると予測する頻度を低減できるため、履歴記憶部HMEMおよび間隔記憶部DMEM1への不要なアクセスをさらに低減できる。すなわち、この実施形態では、プロセッサのサイクル性能が低下することを防止しつつ、消費電力を低減できる。 Thereby, in this embodiment, for example, the frequency with which a branch instruction is predicted not to be a branch instruction can be reduced, and therefore the cycle performance of the processor can be improved. Alternatively, in this embodiment, since the frequency of predicting instructions other than branch instructions as branch instructions can be reduced, unnecessary access to the history storage unit HMEM and the interval storage unit DMEM1 can be further reduced. That is, in this embodiment, the power consumption can be reduced while preventing the cycle performance of the processor from being lowered.
図8は、別の実施形態における分岐予測装置BPRE2の一例を示している。上述した実施形態で説明した要素と同一の要素については、同一の符号を付し、これ等については、詳細な説明を省略する。図8の符号DISTは、パイプラインレジスタPRG1に保持されている分岐命令間隔を示している。また、符号BRDISTは、レジスタREG2に保持されている分岐命令間隔を示している。 FIG. 8 shows an example of the branch prediction apparatus BPRE2 in another embodiment. The same elements as those described in the above-described embodiment are denoted by the same reference numerals, and detailed description thereof will be omitted. A symbol DIST in FIG. 8 indicates a branch instruction interval held in the pipeline register PRG1. Reference numeral BRDIST indicates a branch instruction interval held in the register REG2.
この実施形態の分岐予測装置BPRE2の構成は、図1に示した予測制御部PCNT1および更新部UPP1の代わりに予測制御部PCNT2および更新部UPP2がそれぞれ設けられている。分岐予測装置BPRE2のその他の構成は、図1−図6で説明した実施形態と同じである。また、分岐予測装置BPRE2が搭載されるプロセッサは、図1−図6で説明した実施形態と同じである。 In the configuration of the branch prediction apparatus BPRE2 of this embodiment, a prediction control unit PCNT2 and an update unit UPP2 are provided instead of the prediction control unit PCNT1 and the update unit UPP1 shown in FIG. The other configuration of the branch prediction device BPRE2 is the same as that of the embodiment described with reference to FIGS. The processor on which the branch prediction device BPRE2 is mounted is the same as that in the embodiment described with reference to FIGS.
予測制御部PCNT2は、例えば、間隔記憶部DMEM1から読み出した分岐命令間隔DISTを、パイプラインレジスタPRG1に出力する。予測制御部PCNT2のその他の構成および動作は、予測制御部PCNT1と同じである。なお、予測制御部PCNT2は、例えば、間隔記憶部DMEM1から分岐命令間隔DISTを読み出さない命令では、パイプラインレジスタPRG1に保持される分岐命令間隔DISTを“0”に設定する。 For example, the prediction control unit PCNT2 outputs the branch instruction interval DIST read from the interval storage unit DMEM1 to the pipeline register PRG1. Other configurations and operations of the prediction control unit PCNT2 are the same as those of the prediction control unit PCNT1. For example, for an instruction that does not read the branch instruction interval DIST from the interval storage unit DMEM1, the prediction control unit PCNT2 sets the branch instruction interval DIST held in the pipeline register PRG1 to “0”.
更新部UPP2は、更新部UPP1にレジスタREG2および比較部COMが追加され、図2に示した更新制御部UCNT1の代わりに更新制御部UCNT2が設けられている。レジスタREG2は、例えば、分岐命令間隔DISTを保持する。例えば、レジスタREG2のレジスタ値BRDIST(DIST)は、分岐命令が実行される度に更新される。 In the update unit UPP2, a register REG2 and a comparison unit COM are added to the update unit UPP1, and an update control unit UCNT2 is provided instead of the update control unit UCNT1 shown in FIG. The register REG2 holds a branch instruction interval DIST, for example. For example, the register value BRDIST (DIST) of the register REG2 is updated every time a branch instruction is executed.
比較部COMは、カウンタCOTにより計測された分岐命令間隔とレジスタREG2のレジスタ値BRDISTとを比較する。なお、比較部COMは、更新制御部UCNT2内に設けられてもよい。更新部UPP2は、例えば、カウンタCOTにより計測された分岐命令間隔と間隔記憶部DMEM1に記憶されている分岐命令間隔BRDISTとが同じときには、間隔記憶部DMEM1を更新しない。更新部UPP2のその他の構成および動作は、図1−図6で説明した実施形態と同じである。 The comparison unit COM compares the branch instruction interval measured by the counter COT with the register value BRDIST of the register REG2. Note that the comparison unit COM may be provided in the update control unit UCNT2. For example, when the branch instruction interval measured by the counter COT and the branch instruction interval BRDIST stored in the interval storage unit DMEM1 are the same, the update unit UPP2 does not update the interval storage unit DMEM1. Other configurations and operations of the update unit UPP2 are the same as those in the embodiment described with reference to FIGS.
図9は、図8に示した更新部UPP2およびカウンタCOTの動作の一例を示している。処理S100−S142は、例えば、デコード処理が実施される度に実施される。図9に示した動作は、図6に示した動作に処理S124が追加され、処理S140の代わりに処理S142を実施する。更新部UPP2およびカウンタCOTのその他の動作は、図6に示した動作と同じである。 FIG. 9 shows an example of the operations of the update unit UPP2 and the counter COT shown in FIG. Processes S100 to S142 are performed each time the decoding process is performed, for example. In the operation illustrated in FIG. 9, the process S124 is added to the operation illustrated in FIG. 6, and the process S142 is performed instead of the process S140. The other operations of the updating unit UPP2 and the counter COT are the same as the operations illustrated in FIG.
処理S124は、命令が分岐命令のとき(処理S100のYes)に実施される。あるいは、処理S124は、命令が分岐命令以外のときでカウンタ値WCTが最大値DMAXのとき(処理S110のYes)、実施される。処理S124では、例えば、比較部COMは、カウンタ値WCTとレジスタ値BRDISTとを比較する。カウンタ値WCTとレジスタ値BRDISTとが一致しないとき(処理S124のNo)、更新制御部UCNT2は、処理S130において、間隔記憶部DMEM1を更新する。 Process S124 is performed when the instruction is a branch instruction (Yes in process S100). Alternatively, the process S124 is performed when the instruction is not a branch instruction and the counter value WCT is the maximum value DMAX (Yes in process S110). In the process S124, for example, the comparison unit COM compares the counter value WCT with the register value BRDIST. When the counter value WCT and the register value BRDIST do not match (No in process S124), the update control unit UCNT2 updates the interval storage unit DMEM1 in process S130.
一方、カウンタ値WCTとレジスタ値BRDISTとが一致したとき(処理S124のYes)、更新制御部UCNT2は、処理S142において、レジスタREG1、REG2およびカウンタCOTを初期化する。例えば、更新制御部UCNT2は、パイプラインレジスタPRG1に保持されているPC値(PC1)を、レジスタREG1のレジスタ値BRPCに設定する。また、更新制御部UCNT2は、パイプラインレジスタPRG1に保持されている分岐命令間隔DISTを、レジスタREG2のレジスタ値BRDISTに設定する。さらに、更新制御部UCNT2は、カウンタCOTのカウンタ値WCTを“0”にリセットする。 On the other hand, when the counter value WCT matches the register value BRDIST (Yes in process S124), the update control unit UCNT2 initializes the registers REG1, REG2 and the counter COT in process S142. For example, the update control unit UCNT2 sets the PC value (PC1) held in the pipeline register PRG1 to the register value BRPC of the register REG1. In addition, the update control unit UCNT2 sets the branch instruction interval DIST held in the pipeline register PRG1 to the register value BRDIST of the register REG2. Further, the update control unit UCNT2 resets the counter value WCT of the counter COT to “0”.
このように、更新制御部UCNT2は、カウンタ値WCTとレジスタ値BRDISTとが一致したときには、間隔記憶部DMEM1を更新せずに、レジスタREG1、REG2およびカウンタCOTを初期化する。これにより、この実施形態では、間隔記憶部DMEM1の更新回数を低減できる。この結果、消費電力を低減できる。 In this way, the update control unit UCNT2 initializes the registers REG1 and REG2 and the counter COT without updating the interval storage unit DMEM1 when the counter value WCT and the register value BRDIST match. Thereby, in this embodiment, the frequency | count of an update of the space | interval memory | storage part DMEM1 can be reduced. As a result, power consumption can be reduced.
なお、更新部UPP2の動作は、この例に限定されない。例えば、更新部UPP2の動作は、カウンタ値WCTが最大値DMAXになったとき(処理S110のYes)、処理S124、S130、S142を実施せずに、終了してもよい。この場合、更新部UPP2は、分岐命令間隔が最大値DMAX以上のとき、分岐命令間隔を複数回(複数個所)に分けずに、最大値DMAXを分岐命令間隔として間隔記憶部DMEM1に記憶する。 The operation of the updating unit UPP2 is not limited to this example. For example, the operation of the updating unit UPP2 may be terminated without performing the processes S124, S130, and S142 when the counter value WCT reaches the maximum value DMAX (Yes in the process S110). In this case, when the branch instruction interval is equal to or greater than the maximum value DMAX, the update unit UPP2 stores the maximum value DMAX in the interval storage unit DMEM1 as the branch instruction interval without dividing the branch instruction interval into a plurality of times (a plurality of locations).
また、例えば、更新部UPP2は、処理S124において、カウンタ値WCTがレジスタ値BRDIST以上か否かを判定してもよい。例えば、更新制御部UCNT2は、カウンタ値WCTがレジスタ値BRDISTより小さいとき、処理S130において、間隔記憶部DMEM1を更新する。これにより、カウンタ値WCTがレジスタ値BRDIST以上のときには、間隔記憶部DMEM2は、更新されない。 For example, the update unit UPP2 may determine whether or not the counter value WCT is equal to or greater than the register value BRDIST in the process S124. For example, when the counter value WCT is smaller than the register value BRDIST, the update control unit UCNT2 updates the interval storage unit DMEM1 in process S130. Thus, when the counter value WCT is equal to or greater than the register value BRDIST, the interval storage unit DMEM2 is not updated.
あるいは、更新部UPP2は、図10に示すように、間隔記憶部DMEM1を更新する際に、既に記憶されている分岐命令間隔を上限にして、分岐命令間隔を複数回(複数個所)に分けて更新してもよい。 Alternatively, as shown in FIG. 10, the update unit UPP2 divides the branch instruction interval into a plurality of times (multiple locations) with the already stored branch instruction interval as the upper limit when updating the interval storage unit DMEM1. It may be updated.
図10は、図8に示した更新部UPP2およびカウンタCOTの動作の別の例を示している。例えば、図10の動作は、カウンタCOTの計測に基づく分岐命令間隔(以下、実測の分岐命令間隔とも称する)が間隔記憶部DMEM1に記憶されている分岐命令間隔(以下、更新前の分岐命令間隔とも称する)より大きいとき、分岐命令間隔を複数回(複数個所)に分けて記憶する。例えば、更新前の分岐命令間隔に基づいて参照される間隔記憶部DMEM1のアドレス(以下、中継アドレスとも称する)に、実測の分岐命令間隔と更新前の分岐命令間隔との差分に基づいて算出される間隔が書き込まれる。 FIG. 10 shows another example of the operations of the update unit UPP2 and the counter COT shown in FIG. For example, in the operation of FIG. 10, a branch instruction interval (hereinafter referred to as an actually measured branch instruction interval) based on the measurement of the counter COT is stored in the interval storage unit DMEM1 (hereinafter referred to as a branch instruction interval before update). The branch instruction interval is divided into a plurality of times (multiple locations) and stored. For example, the address of the interval storage unit DMEM1 referred to based on the branch instruction interval before update (hereinafter also referred to as a relay address) is calculated based on the difference between the actually measured branch instruction interval and the branch instruction interval before update. Interval is written.
処理S100−S142は、例えば、デコード処理が実施される度に実施される。図10に示した動作は、図9に示した動作に処理S112、S114が追加されている。更新部UPP2およびカウンタCOTのその他の動作は、図9に示した動作と同じである。 Processes S100 to S142 are performed each time the decoding process is performed, for example. In the operation shown in FIG. 10, processes S112 and S114 are added to the operation shown in FIG. The other operations of the update unit UPP2 and the counter COT are the same as the operations illustrated in FIG.
処理S112は、命令が分岐命令以外のときでカウンタ値WCTが最大値DMAXでないとき(処理S110のNo)、実施される。処理S112では、更新制御部UCNT2は、カウンタ値WCTが“0”か否かを判定する。これにより、意味の無い値がレジスタ値BRDISTに保持されているときに、処理S114が実施されることを防止できる。 Process S112 is performed when the instruction is not a branch instruction and the counter value WCT is not the maximum value DMAX (No in process S110). In process S112, the update control unit UCNT2 determines whether or not the counter value WCT is “0”. Thereby, it is possible to prevent the process S114 from being performed when a meaningless value is held in the register value BRDIST.
カウンタ値WCTが“0”のとき(処理S112のYes)、カウンタ値WCTは、処理S120において、カウントアップする。一方、カウンタ値WCTが“0”でないとき(処理S112のNo)、更新部UPP2の動作は、処理S114に移る。処理S114では、更新制御部UCNT2は、カウンタ値WCTとレジスタ値BRDISTとが一致するか否かを判定する。カウンタ値WCTとレジスタ値BRDISTとが一致しないとき(処理S114のNo)、カウンタ値WCTは、処理S120において、カウントアップする。 When the counter value WCT is “0” (Yes in process S112), the counter value WCT is counted up in process S120. On the other hand, when the counter value WCT is not “0” (No in process S112), the operation of the update unit UPP2 proceeds to process S114. In process S114, the update control unit UCNT2 determines whether or not the counter value WCT matches the register value BRDIST. When the counter value WCT and the register value BRDIST do not match (No in process S114), the counter value WCT is counted up in process S120.
一方、カウンタ値WCTとレジスタ値BRDISTとが一致したとき(処理S114のYes)、更新制御部UCNT2は、処理S142において、レジスタREG1、REG2およびカウンタCOTを初期化する。これにより、カウンタCOTの計測に基づく分岐命令間隔が更新前の分岐命令間隔より大きいとき、カウンタ値WCTとレジスタ値BRDISTとが一致したときのPC値(以下、中継PC値とも称する)を起点にして、次に実施される分岐命令までの間隔(差分)が計測される。この計測により得られる間隔は、実測の分岐命令間隔と更新前の分岐命令間隔との差分に基づいて算出される間隔に対応する。 On the other hand, when the counter value WCT matches the register value BRDIST (Yes in process S114), the update control unit UCNT2 initializes the registers REG1, REG2 and the counter COT in process S142. Thus, when the branch instruction interval based on the measurement of the counter COT is larger than the branch instruction interval before the update, the PC value (hereinafter also referred to as the relay PC value) when the counter value WCT coincides with the register value BRDIST is used as a starting point. Thus, the interval (difference) until the next branch instruction is measured. The interval obtained by this measurement corresponds to the interval calculated based on the difference between the actually measured branch instruction interval and the branch instruction interval before update.
そして、中継PC値の後の分岐命令が実施されるとき(処理S100のYes)、例えば、処理S130において、更新前の分岐命令間隔に基づいて参照される間隔記憶部DMEM1の中継アドレス(BRPC’)に、中継PC値を起点にして計測されたカウンタ値WCTが書き込まれる。このように、更新部UPP2は、間隔記憶部DMEM1の内容を既に記憶されている分岐命令間隔より大きくなる値に更新せずに、中継PC値を用いて更新する。 When the branch instruction after the relay PC value is executed (Yes in process S100), for example, in process S130, the relay address (BRPC ′) of the interval storage unit DMEM1 referred to based on the branch instruction interval before the update. ), The counter value WCT measured from the relay PC value is written. In this way, the update unit UPP2 updates the contents of the interval storage unit DMEM1 using the relay PC value without updating the contents to a value that is larger than the already stored branch instruction interval.
すなわち、更新部UPP2は、例えば、分岐命令の分岐方向が今回と前回で異なるときにも、前回の分岐命令間隔の情報を残しつつ、中継PC値を用いて今回の分岐命令間隔の情報を間隔記憶部DMEM1に記憶する。これにより、例えば、この実施形態では、分岐の成立と不成立とで分岐命令間隔が異なるときにも、中継PC値を用いることにより、分岐の成立と不成立との両方に対応できる。 That is, for example, even when the branch direction of the branch instruction is different from the current time and the previous time, the update unit UPP2 keeps the information on the current branch instruction interval using the relay PC value while leaving the information on the previous branch instruction interval. Store in the storage unit DMEM1. Thereby, for example, in this embodiment, even when the branch instruction interval differs between the establishment and non-establishment of the branch, it is possible to cope with both the establishment and non-establishment of the branch by using the relay PC value.
なお、分岐の成立と不成立との両方に対応させる更新動作は、この例に限定されない。例えば、更新部UPP2は、意味の無い値がレジスタ値BRDISTに保持されていることを示すフラグを用いてもよい。例えば、分岐予測装置BPRE2は、レジスタ値BRDISTのデータ幅を分岐命令間隔DISTより1ビット増やし、最上位ビットをフラグに割り当ててもよい。フラグは、例えば、間隔記憶部DMEM1から分岐命令間隔DISTを読み出さない命令のときに、予測制御部PCNT2により“1”に設定される。このときのレジスタ値BRDISTは、最大値DMAXより大きくなるため、処理S102は、省かれてもよい。 Note that the update operation corresponding to both establishment and failure of the branch is not limited to this example. For example, the update unit UPP2 may use a flag indicating that a meaningless value is held in the register value BRDIST. For example, the branch prediction device BPRE2 may increase the data width of the register value BRDIST by 1 bit from the branch instruction interval DIST and assign the most significant bit to the flag. For example, the flag is set to “1” by the prediction control unit PCNT2 when the instruction does not read the branch instruction interval DIST from the interval storage unit DMEM1. Since the register value BRDIST at this time becomes larger than the maximum value DMAX, the process S102 may be omitted.
以上、この実施形態においても、上述した実施形態と同様の効果を得ることができる。さらに、この実施形態では、間隔記憶部DMEM1の内容が変化しないときには、間隔記憶部DMEM1を更新しない。これにより、この実施形態では、間隔記憶部DMEM1の更新回数を低減でき、消費電力を低減できる。また、中継PC値を用いて更新する場合、分岐の成立と不成立との両方に対応できるため、分岐命令を分岐命令でないと予測する頻度を低減できる。この結果、プロセッサのサイクル性能を向上できる。すなわち、この実施形態では、プロセッサのサイクル性能が低下することを防止しつつ、消費電力を低減できる。 As described above, also in this embodiment, the same effect as that of the above-described embodiment can be obtained. Furthermore, in this embodiment, when the contents of the interval storage unit DMEM1 do not change, the interval storage unit DMEM1 is not updated. Thereby, in this embodiment, the frequency | count of update of the space | interval memory | storage part DMEM1 can be reduced, and power consumption can be reduced. Further, when updating using the relay PC value, it is possible to cope with both the establishment and non-establishment of the branch, so that the frequency of predicting that the branch instruction is not a branch instruction can be reduced. As a result, the cycle performance of the processor can be improved. That is, in this embodiment, the power consumption can be reduced while preventing the cycle performance of the processor from being lowered.
図11は、演算処理のステージで更新動作を実施する分岐予測装置BPRE2の一例を示している。上述した実施形態で説明した要素と同一の要素については、同一の符号を付し、これ等については、詳細な説明を省略する。図11の符号PC3は、パイプラインレジスタPRG3に保持されているPC値を示している。この実施形態の分岐予測装置BPRE2の構成は、カウンタCOTおよび更新部UPP2が演算処理(ALUの処理)のステージと同じステージで動作するようにプロセッサと接続される。この実施形態の分岐予測装置BPRE2のその他の構成は、図8−図10で説明した実施形態の分岐予測装置BPRE2と同じである。また、この実施形態の分岐予測装置BPRE2の動作は、カウンタCOTおよび更新部UPP2が演算処理のステージと同じステージで動作することを除いて、図8に示した分岐予測装置BPRE2と同じである。 FIG. 11 shows an example of the branch prediction apparatus BPRE2 that performs the update operation at the stage of the arithmetic processing. The same elements as those described in the above-described embodiment are denoted by the same reference numerals, and detailed description thereof will be omitted. A code PC3 in FIG. 11 indicates a PC value held in the pipeline register PRG3. The configuration of the branch prediction device BPRE2 of this embodiment is connected to the processor so that the counter COT and the update unit UPP2 operate at the same stage as the stage of arithmetic processing (ALU processing). The other configuration of the branch prediction apparatus BPRE2 of this embodiment is the same as that of the branch prediction apparatus BPRE2 of the embodiment described with reference to FIGS. The operation of the branch prediction device BPRE2 of this embodiment is the same as that of the branch prediction device BPRE2 shown in FIG. 8 except that the counter COT and the update unit UPP2 operate at the same stage as the arithmetic processing stage.
以上、この実施形態においても、図8−図10で説明した実施形態と同様の効果を得ることができる。なお、図1−図7で説明した実施形態の分岐予測装置BPRE1も、カウンタCOTおよび更新部UPP1が演算処理のステージと同じステージで動作するようにプロセッサと接続されてもよい。この場合にも、図1−図7で説明した実施形態と同様の効果を得ることができる。 As described above, also in this embodiment, the same effect as that of the embodiment described with reference to FIGS. The branch prediction device BPRE1 of the embodiment described with reference to FIGS. 1 to 7 may also be connected to the processor so that the counter COT and the update unit UPP1 operate at the same stage as the operation processing stage. Also in this case, the same effect as the embodiment described with reference to FIGS. 1 to 7 can be obtained.
図12は、別の実施形態における分岐予測装置BPRE3の一例を示している。上述した実施形態で説明した要素と同一の要素については、同一の符号を付し、これ等については、詳細な説明を省略する。図12の符号TAGHは、例えば、パイプラインレジスタPRG1に保持されているタグ比較結果を示している。タグ比較結果TAGHは、予測制御部PCNT3から出力される。また、符号BRTAGHは、レジスタREG3に保持されているタグ比較結果を示している。 FIG. 12 shows an example of the branch prediction apparatus BPRE3 in another embodiment. The same elements as those described in the above-described embodiment are denoted by the same reference numerals, and detailed description thereof will be omitted. A code TAGH in FIG. 12 indicates, for example, a tag comparison result held in the pipeline register PRG1. The tag comparison result TAGH is output from the prediction control unit PCNT3. A symbol BRTAGH indicates a tag comparison result held in the register REG3.
この実施形態の分岐予測装置BPRE3の構成は、図8に示した間隔記憶部DMEM1、予測制御部PCNT2および更新部UPP2の代わりに間隔記憶部DMEM3、予測制御部PCNT3および更新部UPP3がそれぞれ設けられている。分岐予測装置BPRE3のその他の構成は、図8−図10で説明した実施形態と同じである。また、分岐予測装置BPRE3が搭載されるプロセッサの構成は、図1−図6で説明した実施形態と同じである。 The configuration of the branch prediction device BPRE3 of this embodiment is provided with an interval storage unit DMEM3, a prediction control unit PCNT3, and an update unit UPP3 instead of the interval storage unit DMEM1, the prediction control unit PCNT2, and the update unit UPP2 shown in FIG. ing. The other configuration of the branch prediction apparatus BPRE3 is the same as that of the embodiment described with reference to FIGS. The configuration of the processor on which the branch prediction device BPRE3 is mounted is the same as that of the embodiment described with reference to FIGS.
間隔記憶部DMEM3は、図13に示すように、タグTAGと分岐命令間隔DISTとを含むデータDATを記憶する。間隔記憶部DMEM3のその他の構成は、間隔記憶部DMEM1と同じである。なお、例えば、間隔記憶部DMEM3は、履歴記憶部HMEMの方向履歴メモリや分岐先履歴メモリのビット幅に分岐命令間隔を記憶するためのビットを追加して構成されてもよい。 As shown in FIG. 13, the interval storage unit DMEM3 stores data DAT including a tag TAG and a branch instruction interval DIST. Other configurations of the interval storage unit DMEM3 are the same as those of the interval storage unit DMEM1. For example, the interval storage unit DMEM3 may be configured by adding a bit for storing the branch instruction interval to the bit width of the direction history memory or the branch destination history memory of the history storage unit HMEM.
予測制御部PCNT3は、例えば、タグTAGとPC値の一部とを比較し、タグ比較結果TAGHをパイプラインレジスタPRG1に出力する。予測制御部PCNT3のその他の構成は、図8に示した予測制御部PCNT2と同じである。 For example, the prediction control unit PCNT3 compares the tag TAG with a part of the PC value, and outputs the tag comparison result TAGH to the pipeline register PRG1. The other configuration of the prediction control unit PCNT3 is the same as that of the prediction control unit PCNT2 shown in FIG.
更新部UPP3は、図8に示した更新部UPP2にレジスタREG3が追加され、更新制御部UCNT2の代わりに更新制御部UCNT3が設けられている。レジスタREG3は、例えば、タグ比較結果TAGHを保持する。例えば、レジスタREG3のレジスタ値BRTAGH(TAGH)は、分岐命令が実行される度に更新される。更新部UPP3のその他の構成は、図8に示した更新部UPP2と同じである。 In the update unit UPP3, a register REG3 is added to the update unit UPP2 illustrated in FIG. 8, and an update control unit UCNT3 is provided instead of the update control unit UCNT2. The register REG3 holds, for example, a tag comparison result TAGH. For example, the register value BRTAGH (TAGH) of the register REG3 is updated every time a branch instruction is executed. The other configuration of the update unit UPP3 is the same as that of the update unit UPP2 shown in FIG.
なお、分岐予測装置BPRE3の構成は、この例に限定されない。例えば、分岐予測装置BPRE3は、図11に示したように、カウンタCOTおよび更新部UPP3が演算処理のステージと同じステージで動作するようにプロセッサと接続されてもよい。 Note that the configuration of the branch prediction device BPRE3 is not limited to this example. For example, as shown in FIG. 11, the branch prediction device BPRE3 may be connected to the processor so that the counter COT and the update unit UPP3 operate at the same stage as the operation processing stage.
図13は、図12に示した間隔記憶部DMEM3および予測制御部PCNT3の一例を示している。なお、図13は、32ビット命令のときのプログラムカウンタPC、間隔記憶部DMEM3および予測制御部PCNT3の一例を示している。 FIG. 13 illustrates an example of the interval storage unit DMEM3 and the prediction control unit PCNT3 illustrated in FIG. FIG. 13 illustrates an example of the program counter PC, the interval storage unit DMEM3, and the prediction control unit PCNT3 for a 32-bit instruction.
間隔記憶部DMEM3は、例えば、PC値の下位8ビットのうちの上位6ビット(PCb)をアドレスADRに使用する。ここで、32ビット命令のプロセッサでは、PC値の最下位2ビット(PCa)は、固定値であるため、間隔記憶部DMEM3のアドレスADRに使用されなくてもよい。なお、アドレスADRのビット幅は、6ビットに限定されない。 For example, the interval storage unit DMEM3 uses the upper 6 bits (PCb) of the lower 8 bits of the PC value for the address ADR. Here, in the processor of the 32-bit instruction, since the least significant 2 bits (PCa) of the PC value are fixed values, they may not be used for the address ADR of the interval storage unit DMEM3. Note that the bit width of the address ADR is not limited to 6 bits.
間隔記憶部DMEM3のデータDATは、PC値の上位24ビット(PCc)を示すタグTAGと分岐命令間隔DISTとを有している。例えば、分岐命令間隔DISTには、4ビットが割り当てられている。なお、分岐命令間隔DISTのデータ幅は、4ビットに限定されない。また、タグTAGのデータ幅は、24ビットに限定されない。 The data DAT in the interval storage unit DMEM3 has a tag TAG indicating the upper 24 bits (PCc) of the PC value and a branch instruction interval DIST. For example, 4 bits are assigned to the branch instruction interval DIST. Note that the data width of the branch instruction interval DIST is not limited to 4 bits. Further, the data width of the tag TAG is not limited to 24 bits.
予測制御部PCNT3は、例えば、カウンタPCOT、タグ判定部DETおよび選択部SELを有している。例えば、予測制御部PCNT3は、PC値(PC0)を受け、カウンタPCOTを用いて命令数を計測する。また、予測制御部PCNT3は、タグTAGおよび分岐命令間隔DIST(DISTi)を間隔記憶部DMEM3から読み出し、タグ比較結果TAGHおよび分岐命令間隔DIST(DISTo)を出力する。例えば、予測制御部PCNT3は、先に読み出した分岐命令間隔DISTとカウンタPCOTにより計測された命令数とが一致したとき、PC値の下位8ビットのうちの上位6ビット部分PCbが示すアドレスADRのデータDAT(タグTAG、分岐命令間隔DIST)を読み出す。 The prediction control unit PCNT3 includes, for example, a counter PCOT, a tag determination unit DET, and a selection unit SEL. For example, the prediction control unit PCNT3 receives the PC value (PC0) and measures the number of instructions using the counter PCOT. Further, the prediction control unit PCNT3 reads the tag TAG and the branch instruction interval DIST (DISTi) from the interval storage unit DMEM3, and outputs the tag comparison result TAGH and the branch instruction interval DIST (DISTO). For example, the prediction control unit PCNT3, when the previously read branch instruction interval DIST matches the number of instructions measured by the counter PCOT, the address ADR indicated by the upper 6-bit portion PCb of the lower 8 bits of the PC value Data DAT (tag TAG, branch instruction interval DIST) is read.
カウンタPCOTは、例えば、PC値が更新される度に、カウントダウンするダウンカウンタである。なお、カウンタPCOTは、PC値が更新される度に、カウントアップするアップカウンタでもよい。すなわち、カウンタPCOTは、命令数を計測するカウンタである。 The counter PCOT is, for example, a down counter that counts down every time the PC value is updated. The counter PCOT may be an up counter that counts up whenever the PC value is updated. That is, the counter PCOT is a counter that measures the number of instructions.
タグ判定部DETは、間隔記憶部DMEM3から読み出したタグTAGとPC値の上位24ビット部分PCcとを比較し、比較結果であるタグ比較結果TAGHを出力する。例えば、タグ判定部DETは、タグTAGとPC値の上位24ビット部分PCcとが一致したとき、タグ比較結果TAGHを、“1”に設定する。また、例えば、タグ判定部DETは、タグTAGとPC値の上位24ビット部分PCcとが一致しないとき、タグ比較結果TAGHを、“0”に設定する。 The tag determination unit DET compares the tag TAG read from the interval storage unit DMEM3 with the upper 24-bit portion PCc of the PC value, and outputs a tag comparison result TAGH that is a comparison result. For example, the tag determination unit DET sets the tag comparison result TAGH to “1” when the tag TAG matches the upper 24-bit portion PCc of the PC value. For example, the tag determination unit DET sets the tag comparison result TAGH to “0” when the tag TAG does not match the upper 24-bit portion PCc of the PC value.
選択部SELは、例えば、タグ判定部DETから受けるタグ比較結果TAGHに応じて、間隔記憶部DMEM3から読み出した分岐命令間隔DISTiと“0”とのいずれかを、分岐命令間隔DISToとして出力する。例えば、選択部SELは、タグTAGとPC値の上位24ビット部分PCcとが一致したとき(例えば、TAGHが“1”のとき)、間隔記憶部DMEM3から読み出した分岐命令間隔DISTiを、分岐命令間隔DISToとして出力する。また、選択部SELは、タグTAGとPC値の上位24ビット部分PCcとが一致しないとき(例えば、TAGHが“0”のとき)、分岐命令間隔DISToを、例えば、“0”に設定する。 For example, the selection unit SEL outputs one of the branch instruction interval DISTi and “0” read from the interval storage unit DMEM3 as the branch instruction interval DISTo in accordance with the tag comparison result TAGH received from the tag determination unit DET. For example, the selection unit SEL uses the branch instruction interval DISTi read from the interval storage unit DMEM3 as the branch instruction when the tag TAG matches the upper 24-bit portion PCc of the PC value (for example, when TAGH is “1”). Output as interval DISTo. Further, the selection unit SEL sets the branch instruction interval DISTo to, for example, “0” when the tag TAG and the upper 24-bit portion PCc of the PC value do not match (for example, when TAGH is “0”).
図14は、図13に示した予測制御部PCNT3の動作の一例を示している。処理S200−S270は、例えば、命令フェッチ処理が実施される度に実施される。 FIG. 14 shows an example of the operation of the prediction control unit PCNT3 shown in FIG. Processes S200-S270 are performed each time an instruction fetch process is performed, for example.
処理S200では、カウンタPCOTのカウンタ値が“0”か否かを判定する。例えば、最初の分岐命令のPC値が出力されるまで、カウンタPCOTのカウンタ値は、“0”である。カウンタPCOTのカウンタ値が“0”でないとき(処理S200のNo)、カウンタPCOTのカウンタ値は、処理S210において、カウントダウンする。そして、予測制御部PCNT3は、処理S220において、分岐命令間隔DISToおよびタグ比較結果TAGHを、“0”に設定する。 In the process S200, it is determined whether or not the counter value of the counter PCOT is “0”. For example, the counter value of the counter PCOT is “0” until the PC value of the first branch instruction is output. When the counter value of the counter PCOT is not “0” (No in process S200), the counter value of the counter PCOT is counted down in process S210. In step S220, the prediction control unit PCNT3 sets the branch instruction interval DISTo and the tag comparison result TAGH to “0”.
一方、カウンタPCOTのカウンタ値が“0”のとき(処理S200のYes)、予測制御部PCNT3の動作は、処理S230に移る。処理S230では、予測制御部PCNT3は、例えば、履歴記憶部HMEMへの参照タイミングであることを予測部PREDに通知する。これにより、予測部PREDは、履歴記憶部HMEMを参照して分岐予測を実施する。また、処理S230では、予測制御部PCNT3は、タグTAGおよび分岐命令間隔DIST(DISTi)を含むデータDATを、間隔記憶部DMEM3のアドレスADR(PCb)から読み出す。アドレスADR(PCb)は、例えば、PC値の下位8ビットのうちの上位6ビット部分PCbが示すアドレスである。 On the other hand, when the counter value of the counter PCOT is “0” (Yes in process S200), the operation of the prediction control unit PCNT3 proceeds to process S230. In the process S230, the prediction control unit PCNT3 notifies the prediction unit PRED that it is the reference timing to the history storage unit HMEM, for example. Thereby, the prediction unit PRED performs branch prediction with reference to the history storage unit HMEM. In process S230, the prediction control unit PCNT3 reads data DAT including the tag TAG and the branch instruction interval DIST (DISTi) from the address ADR (PCb) of the interval storage unit DMEM3. The address ADR (PCb) is, for example, an address indicated by the upper 6-bit portion PCb of the lower 8 bits of the PC value.
そして、処理S240では、タグ判定部DETは、PC値の上位24ビット部分PCcと処理S230で読み出したタグTAGとを比較する。タグTAGと値PCcとが一致しないとき(処理S240のNo)、予測制御部PCNT3の動作は、処理S250に移る。処理S250では、例えば、タグ判定部DETはタグ比較結果TAGHを“0”に設定し、選択部SELは分岐命令間隔DISToを“0”に設定する。そして、予測制御部PCNT3は、処理S270において、カウンタPCOTのカウンタ値を分岐命令間隔DISTo(“0”)に設定する。 In step S240, the tag determination unit DET compares the upper 24-bit portion PCc of the PC value with the tag TAG read in step S230. When the tag TAG does not match the value PCc (No in process S240), the operation of the prediction control unit PCNT3 proceeds to process S250. In the process S250, for example, the tag determination unit DET sets the tag comparison result TAGH to “0”, and the selection unit SEL sets the branch instruction interval DISTo to “0”. Then, in step S270, the prediction control unit PCNT3 sets the counter value of the counter PCOT to the branch instruction interval DISTo (“0”).
一方、タグTAGと値PCcとが一致したとき(処理S240のYes)、予測制御部PCNT3の動作は、処理S260に移る。処理S260では、例えば、タグ判定部DETはタグ比較結果TAGHを“1”に設定する。また、選択部SELは、処理S230で読み出した分岐命令間隔DISTiを、分岐命令間隔DISToとして出力する。そして、予測制御部PCNT3は、処理S270において、カウンタPCOTのカウンタ値を分岐命令間隔DISTo(処理S230で読み出した分岐命令間隔DISTi)に設定する。 On the other hand, when the tag TAG matches the value PCc (Yes in process S240), the operation of the prediction control unit PCNT3 proceeds to process S260. In the process S260, for example, the tag determination unit DET sets the tag comparison result TAGH to “1”. In addition, the selection unit SEL outputs the branch instruction interval DISTi read in step S230 as the branch instruction interval DISTO. In step S270, the prediction control unit PCNT3 sets the counter value of the counter PCOT to the branch instruction interval DISTo (the branch instruction interval DISTi read in step S230).
このように、予測制御部PCNT3は、PC値の上位24ビット部分PCcと処理S230で読み出したタグTAGとが一致したときに、間隔記憶部DMEM3から読み出した分岐命令間隔DISTを有効にする。ここで、プログラムカウンタPCは、例えば、カウンタPCOTのカウンタ値が“0”でないとき(処理S200のNo)には、連続する次の命令を示す値(例えば、4増加した値)にPC値を更新する。なお、PC値は、例えば、カウンタPCOTのカウンタ値が“0”のとき(処理S200のYes)には、分岐予測の結果に応じた値に設定される。 In this way, the prediction control unit PCNT3 validates the branch instruction interval DIST read from the interval storage unit DMEM3 when the upper 24-bit portion PCc of the PC value matches the tag TAG read in step S230. Here, for example, when the counter value of the counter PCOT is not “0” (No in process S200), the program counter PC sets the PC value to a value indicating the next successive instruction (for example, a value increased by 4). Update. For example, when the counter value of the counter PCOT is “0” (Yes in process S200), the PC value is set to a value according to the branch prediction result.
予測制御部PCNT3の動作は、この例に限定されない。例えば、カウンタPCOTがアップカウンタのとき、処理S200では、分岐命令間隔DISTとカウンタPCOTのカウンタ値とが一致するか否かが判定される。この場合、カウンタPCOTのカウンタ値と比較される分岐命令間隔DISTとして、例えば、処理S270において、分岐命令間隔DISToがレジスタ等に保持される。さらに、処理S270において、カウンタPCOTは、例えば、“0”にリセットされる。 The operation of the prediction control unit PCNT3 is not limited to this example. For example, when the counter PCOT is an up counter, in step S200, it is determined whether or not the branch instruction interval DIST matches the counter value of the counter PCOT. In this case, as the branch instruction interval DIST compared with the counter value of the counter PCOT, for example, in step S270, the branch instruction interval DISTo is held in a register or the like. In step S270, the counter PCOT is reset to “0”, for example.
図15は、図12に示した更新部UPP3およびカウンタCOTの動作の一例を示している。なお、図15に示した動作では、更新部UPP3は、分岐命令以外の命令に対応するアドレスに分岐命令間隔を書き込まないように、間隔記憶部DMEM3を更新する。すなわち、図15に示した動作では、更新部UPP3は、分岐命令間隔が最大値DMAX以上のとき、分岐命令間隔を複数回(複数個所)に分けずに、間隔記憶部DMEM1を更新する。 FIG. 15 shows an example of operations of the updating unit UPP3 and the counter COT shown in FIG. In the operation illustrated in FIG. 15, the update unit UPP3 updates the interval storage unit DMEM3 so that the branch instruction interval is not written to an address corresponding to an instruction other than the branch instruction. That is, in the operation shown in FIG. 15, when the branch instruction interval is equal to or greater than the maximum value DMAX, the update unit UPP3 updates the interval storage unit DMEM1 without dividing the branch instruction interval a plurality of times (a plurality of locations).
図15の符号BRPCb、BRPCcは、PC値の一部分PCb、PCcにそれぞれ対応している。すなわち、レジスタ値BRPCbは、例えば、レジスタ値BRPCの下位8ビットのうちの上位6ビットである。また、レジスタ値BRPCcは、例えば、レジスタ値BRPCの上位24ビットである。 The codes BRPCb and BRPCc in FIG. 15 correspond to PC value portions PCb and PCc, respectively. That is, the register value BRPCb is, for example, the upper 6 bits of the lower 8 bits of the register value BRPC. The register value BRPCc is, for example, the upper 24 bits of the register value BRPC.
処理S100−S144は、例えば、デコード処理が実施される度に実施される。図15に示した動作は、図9に示した動作に処理S122が追加され、処理S124、S130、S142の代わりに処理S126、S132、S144がそれぞれ実施される。また、処理S110の判定結果(Yes)後に実施される処理は、図9に示した動作と異なる。更新部UPP3およびカウンタCOTのその他の動作は、図9に示した動作と同じである。 Processes S100-S144 are performed each time the decoding process is performed, for example. In the operation illustrated in FIG. 15, the process S122 is added to the operation illustrated in FIG. 9, and the processes S126, S132, and S144 are performed instead of the processes S124, S130, and S142. Moreover, the process implemented after the determination result (Yes) of process S110 differs from the operation | movement shown in FIG. The other operations of the update unit UPP3 and the counter COT are the same as the operations illustrated in FIG.
命令が分岐命令以外のときでカウンタ値WCTが最大値DMAXのとき(処理S110のYes)、カウンタ値WCTは、カウントアップされない。すなわち、カウンタ値WCTが最大値DMAXのとき、カウンタ値WCTは、間隔記憶部DMEM3が更新されるまで、間隔記憶部DMEM3のデータ幅で記憶できる最大値DMAXに維持される。 When the instruction is other than a branch instruction and the counter value WCT is the maximum value DMAX (Yes in step S110), the counter value WCT is not counted up. That is, when the counter value WCT is the maximum value DMAX, the counter value WCT is maintained at the maximum value DMAX that can be stored with the data width of the interval storage unit DMEM3 until the interval storage unit DMEM3 is updated.
処理S122は、命令が分岐命令のとき(処理S100のYes)、実施される。処理S122では、更新制御部UCNT3は、レジスタ値BRTAGHが“1”か否かを判定する。すなわち、更新制御部UCNT3は、更新対象のPC値の上位24ビット部分PCcとタグTAGとが一致するか否かを判定する。 Process S122 is performed when the instruction is a branch instruction (Yes in process S100). In process S122, the update control unit UCNT3 determines whether or not the register value BRTAGH is “1”. That is, the update control unit UCNT3 determines whether or not the upper 24-bit portion PCc of the PC value to be updated matches the tag TAG.
レジスタ値BRTAGHが“1”のとき(処理S122のYes)、更新部UPP3の動作は、処理S126に移る。処理S126では、例えば、比較部COMは、カウンタ値WCTとレジスタ値BRDISTとを比較する。そして、例えば、更新制御部UCNT3は、比較部COMの比較結果に基づいて、カウンタ値WCTがレジスタ値BRDIST以上か否かを判定する。すなわち、更新制御部UCNT3は、タグTAGと値PCcとが一致したとき、カウンタ値WCTがレジスタ値BRDIST以上か否かを判定する。 When the register value BRTAGH is “1” (Yes in process S122), the operation of the update unit UPP3 proceeds to process S126. In the process S126, for example, the comparison unit COM compares the counter value WCT with the register value BRDIST. For example, the update control unit UCNT3 determines whether or not the counter value WCT is greater than or equal to the register value BRDIST based on the comparison result of the comparison unit COM. That is, the update control unit UCNT3 determines whether the counter value WCT is equal to or greater than the register value BRDIST when the tag TAG and the value PCc match.
カウンタ値WCTがレジスタ値BRDISTより小さいとき(処理S126のNo)、更新制御部UCNT3は、処理S132において、間隔記憶部DMEM3を更新する。これにより、例えば、この実施形態では、分岐命令のときに分岐予測が実施されないことを防止できる。したがって、この実施形態では、プロセッサのサイクル性能が低下することを防止しつつ、消費電力を低減できる。 When the counter value WCT is smaller than the register value BRDIST (No in process S126), the update control unit UCNT3 updates the interval storage unit DMEM3 in process S132. Thereby, for example, in this embodiment, it is possible to prevent branch prediction from being performed at the time of a branch instruction. Therefore, in this embodiment, the power consumption can be reduced while preventing the cycle performance of the processor from being lowered.
また、カウンタ値WCTがレジスタ値BRDIST以上のとき(処理S126のYes)、更新制御部UCNT3は、処理S144において、レジスタREG1、REG2、REG3およびカウンタCOTを初期化する。このように、カウンタ値WCTがレジスタ値BRDIST以上のときには、間隔記憶部DMEM3は、更新されない。 When the counter value WCT is greater than or equal to the register value BRDIST (Yes in process S126), the update control unit UCNT3 initializes the registers REG1, REG2, REG3, and the counter COT in process S144. Thus, when the counter value WCT is equal to or greater than the register value BRDIST, the interval storage unit DMEM3 is not updated.
なお、レジスタ値BRTAGHが“1”でないとき(処理S122のNo)、更新制御部UCNT3は、処理S132において、間隔記憶部DMEM3を更新する。すなわち、更新制御部UCNT3は、タグTAGと値PCcとが一致しないとき、間隔記憶部DMEM3を更新する。 When the register value BRTAGH is not “1” (No in process S122), the update control unit UCNT3 updates the interval storage unit DMEM3 in process S132. That is, the update control unit UCNT3 updates the interval storage unit DMEM3 when the tag TAG and the value PCc do not match.
処理S132では、更新制御部UCNT3は、レジスタ値BRPCcおよびカウンタ値WCTに基づいて、間隔記憶部DMEM3のアドレスADR(レジスタ値BRPCb)のデータDATを更新する。これにより、間隔記憶部DMEM3のアドレスADR(レジスタ値BRPCb)のデータDATのタグTAGおよび分岐命令間隔DISTは、レジスタ値BRPCcおよびカウンタ値WCTにそれぞれ更新される。 In process S132, the update control unit UCNT3 updates the data DAT of the address ADR (register value BRPCb) of the interval storage unit DMEM3 based on the register value BRPCc and the counter value WCT. As a result, the tag TAG and the branch instruction interval DIST of the data DAT at the address ADR (register value BRPCb) of the interval storage unit DMEM3 are updated to the register value BRPCc and the counter value WCT, respectively.
このように、タグTAGと値PCcとが一致し、かつ、カウンタ値WCTがレジスタ値BRDISTより小さいとき、間隔記憶部DMEM3が更新される。あるいは、間隔記憶部DMEM3は、タグTAGと値PCcとが一致しないときに更新される。なお、例えば、処理S110の判定結果(Yes)後に処理S132が実施されたときには、間隔記憶部DMEM3に記憶される分岐命令間隔DISTは、最大値DMAXである。 As described above, when the tag TAG matches the value PCc and the counter value WCT is smaller than the register value BRDIST, the interval storage unit DMEM3 is updated. Alternatively, the interval storage unit DMEM3 is updated when the tag TAG and the value PCc do not match. For example, when the process S132 is performed after the determination result (Yes) of the process S110, the branch instruction interval DIST stored in the interval storage unit DMEM3 is the maximum value DMAX.
処理S144では、更新制御部UCNT3は、レジスタREG1、REG2、REG3およびカウンタCOTを初期化する。例えば、更新制御部UCNT3は、パイプラインレジスタPRG1に保持されているPC値(PC1)、分岐命令間隔DISTおよびタグ比較結果TAGHを、レジスタ値BRPC、レジスタ値BRDISTおよびレジスタ値BRTAGHにそれぞれ設定する。また、更新制御部UCNT3は、カウンタCOTのカウンタ値WCTを“0”にリセットする。このように、更新部UPP3は、例えば、分岐命令以外の命令に対応するアドレスに分岐命令間隔を書き込まないように、間隔記憶部DMEM3を更新する。 In process S144, the update control unit UCNT3 initializes the registers REG1, REG2, REG3 and the counter COT. For example, the update control unit UCNT3 sets the PC value (PC1), branch instruction interval DIST, and tag comparison result TAGH held in the pipeline register PRG1 to the register value BRPC, the register value BRDIST, and the register value BRTAGH, respectively. Further, the update control unit UCNT3 resets the counter value WCT of the counter COT to “0”. In this way, the update unit UPP3 updates the interval storage unit DMEM3 so as not to write the branch instruction interval to an address corresponding to an instruction other than the branch instruction, for example.
なお、更新部UPP3の動作は、この例に限定されない。例えば、更新部UPP3の動作は、カウンタ値WCTが最大値DMAXになったとき(処理S110のYes)、処理S122に移ってもよい。すなわち、更新部UPP3は、カウンタ値WCTが最大値DMAXになったときに、間隔記憶部DMEM3を更新してもよい。このとき、更新部UPP3は、間隔記憶部DMEM3を更新したことを示すフラグを設定する。 The operation of the update unit UPP3 is not limited to this example. For example, the operation of the update unit UPP3 may move to the process S122 when the counter value WCT reaches the maximum value DMAX (Yes in the process S110). That is, the update unit UPP3 may update the interval storage unit DMEM3 when the counter value WCT reaches the maximum value DMAX. At this time, the update unit UPP3 sets a flag indicating that the interval storage unit DMEM3 has been updated.
例えば、更新部UPP3は、間隔記憶部DMEM3を更新したことを示すフラグが設定されている間は、間隔記憶部DMEM3を更新しない。そして、フラグを設定した後に分岐命令が実行されたとき、間隔記憶部DMEM3を更新せずに、フラグをクリアする。この際、更新制御部UCNT3は、レジスタREG1、REG2、REG3およびカウンタCOTを初期化する。 For example, the update unit UPP3 does not update the interval storage unit DMEM3 while the flag indicating that the interval storage unit DMEM3 has been updated is set. When the branch instruction is executed after setting the flag, the flag is cleared without updating the interval storage unit DMEM3. At this time, the update control unit UCNT3 initializes the registers REG1, REG2, REG3 and the counter COT.
また、更新部UPP3は、処理S126において、カウンタ値WCTとレジスタ値BRDISTとが一致するか否かを判定してもよい。この場合、間隔記憶部DMEM3は、図9に示した動作と同様に、カウンタ値WCTとレジスタ値BRDISTとが一致しないときに更新される。例えば、更新制御部UCNT3は、カウンタ値WCTとレジスタ値BRDISTとが一致しないとき、処理S132において、間隔記憶部DMEM3を更新する。また、例えば、更新制御部UCNT3は、カウンタ値WCTとレジスタ値BRDISTとが一致したとき、間隔記憶部DMEM3を更新しない。すなわち、更新部UPP3は、カウンタ値WCTがレジスタ値BRDISTより小さいか否かにかかわらず、カウンタ値WCTとレジスタ値BRDISTとが一致しないときに、間隔記憶部DMEM3を更新してもよい。 Further, the update unit UPP3 may determine whether or not the counter value WCT and the register value BRDIST match in the process S126. In this case, the interval storage unit DMEM3 is updated when the counter value WCT and the register value BRDIST do not match, as in the operation shown in FIG. For example, when the counter value WCT and the register value BRDIST do not match, the update control unit UCNT3 updates the interval storage unit DMEM3 in process S132. For example, the update control unit UCNT3 does not update the interval storage unit DMEM3 when the counter value WCT matches the register value BRDIST. That is, the updating unit UPP3 may update the interval storage unit DMEM3 when the counter value WCT and the register value BRDIST do not match regardless of whether or not the counter value WCT is smaller than the register value BRDIST.
あるいは、更新部UPP3は、処理S110の判定結果(Yes)後に処理S122を実施し、かつ、処理S126において、カウンタ値WCTとレジスタ値BRDISTとが一致するか否かを判定してもよい。これにより、間隔記憶部DMEM3の最大値DMAX以上の分岐命令間隔は、図9に示した動作と同様に、複数回(複数個所)に分けて記憶される。 Alternatively, the updating unit UPP3 may perform the process S122 after the determination result (Yes) of the process S110, and may determine whether or not the counter value WCT and the register value BRDIST match in the process S126. Thereby, the branch instruction interval equal to or greater than the maximum value DMAX in the interval storage unit DMEM3 is stored in a plurality of times (in a plurality of locations) as in the operation shown in FIG.
また、更新部UPP3は、図10に示したように、処理S110の判定結果(No)後に、処理S112、S114を実施してもよい。すなわち、更新部UPP3は、間隔記憶部DMEM3の内容を既に記憶されている分岐命令間隔より大きくなる値に更新せずに、中継PC値を用いて更新してもよい。 Further, as illustrated in FIG. 10, the update unit UPP3 may perform the processes S112 and S114 after the determination result (No) of the process S110. That is, the update unit UPP3 may update the contents of the interval storage unit DMEM3 using the relay PC value without updating the contents of the interval storage unit DMEM3 to a value larger than the already stored branch instruction interval.
また、分岐先履歴メモリのビット幅に分岐命令間隔を記憶するためのビットを追加した構成の間隔記憶部DMEM3に対する更新動作では、更新部UPP3は、分岐命令による分岐が成立したときのみ、間隔記憶部DMEM3を更新してもよい。 In addition, in the update operation for the interval storage unit DMEM3 having a configuration in which a bit for storing the branch instruction interval is added to the bit width of the branch destination history memory, the update unit UPP3 stores the interval only when a branch by the branch instruction is established. The part DMEM3 may be updated.
以上、この実施形態においても、図8−図10で説明した実施形態と同様の効果を得ることができる。 As described above, also in this embodiment, the same effect as that of the embodiment described with reference to FIGS.
以上の実施形態において説明した発明を整理して、付記として開示する。
(付記1)
分岐命令の結果を記憶する履歴記憶部を有し、前記履歴記憶部を参照して分岐予測を実施する予測部と、
前記分岐命令に対応して前記分岐命令の間隔を記憶する間隔記憶部と、
前記履歴記憶部を参照するタイミングを、前記間隔記憶部に記憶された前記分岐命令の間隔に基づいて決定する制御部と、
前記分岐命令の間隔を計測するカウンタと、
前記間隔記憶部の内容を、前記カウンタにより計測された前記分岐命令の間隔に基づいて更新する更新部と
を備えていることを特徴とする分岐予測装置。
(付記2)
前記更新部は、前記分岐命令が実行される度に、前記間隔記憶部の内容を更新すること
を特徴とする付記1記載の分岐予測装置。
(付記3)
前記更新部は、前記カウンタの計測に基づく前記分岐命令の間隔が、前記間隔記憶部に記憶されている前記分岐命令の間隔と異なるとき、前記間隔記憶部の内容を更新すること
を特徴とする付記1記載の分岐予測装置。
(付記4)
前記更新部は、前記カウンタの計測に基づく前記分岐命令の間隔が、前記間隔記憶部に記憶されている前記分岐命令の間隔より大きいとき、前記記憶されている前記分岐命令の間隔に基づいて参照されるアドレスに、前記計測に基づく前記分岐命令の間隔と前記記憶されている前記分岐命令の間隔との差分に基づいて算出される間隔を書き込むこと
を特徴とする付記1記載の分岐予測装置。
(付記5)
前記間隔記憶部は、前記分岐命令による分岐が成立したときの前記分岐命令の間隔と前記分岐命令による分岐が不成立のときの前記分岐命令の間隔との両方を記憶すること
を特徴とする付記1記載の分岐予測装置。
(付記6)
前記更新部は、前記カウンタの計測に基づく前記分岐命令の間隔が、前記間隔記憶部に記憶されている前記分岐命令の間隔より小さいとき、前記間隔記憶部の内容を更新すること
を特徴とする付記1記載の分岐予測装置。
(付記7)
命令を解読する解読部と、分岐命令の分岐予測を実施する分岐予測装置とを備え、
前記分岐予測装置は、
分岐命令の結果を記憶する履歴記憶部を有し、前記履歴記憶部を参照して分岐予測を実施する予測部と、
前記分岐命令に対応して前記分岐命令の間隔を記憶する間隔記憶部と、
前記履歴記憶部を参照するタイミングを、前記間隔記憶部に記憶された前記分岐命令の間隔に基づいて決定する制御部と、
前記分岐命令の間隔を計測するカウンタと、
前記間隔記憶部の内容を、前記カウンタにより計測された前記分岐命令の間隔に基づいて更新する更新部と
を備えていることを特徴とするプロセッサ。
(付記8)
前記更新部は、前記分岐命令が実行される度に、前記間隔記憶部の内容を更新すること
を特徴とする付記7記載のプロセッサ。
(付記9)
前記更新部は、前記カウンタの計測に基づく前記分岐命令の間隔が、前記間隔記憶部に記憶されている前記分岐命令の間隔と異なるとき、前記間隔記憶部の内容を更新すること
を特徴とする付記7記載のプロセッサ。
(付記10)
前記更新部は、前記カウンタの計測に基づく前記分岐命令の間隔が、前記間隔記憶部に記憶されている前記分岐命令の間隔より大きいとき、前記記憶されている前記分岐命令の間隔に基づいて参照されるアドレスに、前記計測に基づく前記分岐命令の間隔と前記記憶されている前記分岐命令の間隔との差分に基づいて算出される間隔を書き込むこと
を特徴とする付記7記載のプロセッサ。
(付記11)
前記間隔記憶部は、前記分岐命令による分岐が成立したときの前記分岐命令の間隔と前記分岐命令による分岐が不成立のときの前記分岐命令の間隔との両方を記憶すること
を特徴とする付記7記載のプロセッサ。
(付記12)
前記更新部は、前記カウンタの計測に基づく前記分岐命令の間隔が、前記間隔記憶部に記憶されている前記分岐命令の間隔より小さいとき、前記間隔記憶部の内容を更新すること
を特徴とする付記7記載のプロセッサ。
The invention described in the above embodiments is organized and disclosed as an appendix.
(Appendix 1)
A prediction unit that has a history storage unit that stores a result of the branch instruction, and performs branch prediction with reference to the history storage unit;
An interval storage unit that stores an interval of the branch instruction corresponding to the branch instruction;
A control unit that determines the timing of referring to the history storage unit based on the interval of the branch instruction stored in the interval storage unit;
A counter for measuring the interval between the branch instructions;
An update unit that updates the contents of the interval storage unit based on the interval of the branch instruction measured by the counter.
(Appendix 2)
The branch prediction apparatus according to
(Appendix 3)
The update unit updates the contents of the interval storage unit when the interval of the branch instruction based on the measurement of the counter is different from the interval of the branch instruction stored in the interval storage unit. The branch prediction apparatus according to
(Appendix 4)
The updating unit refers to the branch instruction interval stored when the interval of the branch instruction based on the measurement of the counter is larger than the interval of the branch instruction stored in the interval storage unit. The branch prediction device according to
(Appendix 5)
The interval storage unit stores both the interval of the branch instruction when the branch by the branch instruction is established and the interval of the branch instruction when the branch by the branch instruction is not established. The branch prediction apparatus described.
(Appendix 6)
The update unit updates the contents of the interval storage unit when the interval of the branch instruction based on the measurement of the counter is smaller than the interval of the branch instruction stored in the interval storage unit. The branch prediction apparatus according to
(Appendix 7)
A decoding unit that decodes an instruction; and a branch prediction device that performs branch prediction of a branch instruction;
The branch prediction device
A prediction unit that has a history storage unit that stores a result of the branch instruction, and performs branch prediction with reference to the history storage unit;
An interval storage unit that stores an interval of the branch instruction corresponding to the branch instruction;
A control unit that determines the timing of referring to the history storage unit based on the interval of the branch instruction stored in the interval storage unit;
A counter for measuring the interval between the branch instructions;
An updater that updates the contents of the interval storage unit based on the interval of the branch instruction measured by the counter.
(Appendix 8)
The processor according to
(Appendix 9)
The update unit updates the contents of the interval storage unit when the interval of the branch instruction based on the measurement of the counter is different from the interval of the branch instruction stored in the interval storage unit. The processor according to
(Appendix 10)
The updating unit refers to the branch instruction interval stored when the interval of the branch instruction based on the measurement of the counter is larger than the interval of the branch instruction stored in the interval storage unit. The processor according to
(Appendix 11)
The interval storage unit stores both the interval of the branch instruction when the branch by the branch instruction is established and the interval of the branch instruction when the branch by the branch instruction is not established. The processor described.
(Appendix 12)
The update unit updates the contents of the interval storage unit when the interval of the branch instruction based on the measurement of the counter is smaller than the interval of the branch instruction stored in the interval storage unit. The processor according to
以上の詳細な説明により、実施形態の特徴点および利点は明らかになるであろう。これは、特許請求の範囲がその精神および権利範囲を逸脱しない範囲で前述のような実施形態の特徴点および利点にまで及ぶことを意図するものである。また、当該技術分野において通常の知識を有する者であれば、あらゆる改良および変更に容易に想到できるはずであり、発明性を有する実施形態の範囲を前述したものに限定する意図はなく、実施形態に開示された範囲に含まれる適当な改良物および均等物に拠ることも可能である。 From the above detailed description, features and advantages of the embodiments will become apparent. This is intended to cover the features and advantages of the embodiments described above without departing from the spirit and scope of the claims. Further, any person having ordinary knowledge in the technical field should be able to easily come up with any improvements and modifications, and there is no intention to limit the scope of the embodiments having the invention to those described above. It is also possible to rely on suitable improvements and equivalents within the scope disclosed in.
ALU‥算術論理演算ユニット;BPRE1、BPRE2、BPRE3‥分岐予測装置;COT‥カウンタ;DEC‥デコーダ;DESM‥分岐先履歴メモリ;DET‥タグ判定部;DIRM‥方向履歴メモリ;DMEM1、DMEM2、DMEM3‥間隔記憶部;HMEM‥履歴記憶部;IMEM‥命令メモリ;PC‥プログラムカウンタ;PCNT1、PCNT2、PCNT3‥予測制御部;PCOT‥カウンタ;PRED‥予測部;PRG1、PRG2、PRG3‥パイプラインレジスタ;REG1、REG2、REG3‥レジスタ;RPD‥レジスタリード部;SEL‥選択部;UCNT1、UCNT2、UCNT3‥更新制御部;UPP1、UPP2、UPP3‥更新部 ALU: Arithmetic logic unit; BPRE1, BPRE2, BPRE3: Branch prediction device; COT: Counter; DEC: Decoder; DESM: Branch destination history memory; DET: Tag decision unit; Interval memory unit; HMEM ... history memory unit; IMEM ... instruction memory; PC ... program counter; PCNT1, PCNT2, PCNT3 ... prediction control unit; PCOT ... counter; PRED ... prediction unit; REG2, REG3, register; RPD, register read section; SEL, selection section; UCNT1, UCNT2, UCNT3, update control section; UPP1, UPP2, UPP3, update section
Claims (5)
前記分岐命令に対応して前記分岐命令の間隔を記憶する間隔記憶部と、
前記履歴記憶部を参照するタイミングを、前記間隔記憶部に記憶された前記分岐命令の間隔に基づいて決定する制御部と、
前記分岐命令の間隔を計測するカウンタと、
前記間隔記憶部の内容を、前記カウンタにより計測された前記分岐命令の間隔に基づいて更新する更新部とを備え、
前記間隔記憶部は、前記分岐命令による分岐が成立したときの前記分岐命令の間隔と前記分岐命令による分岐が不成立のときの前記分岐命令の間隔との両方を記憶すること
を特徴とする分岐予測装置。 A prediction unit that has a history storage unit that stores a result of the branch instruction, and performs branch prediction with reference to the history storage unit;
An interval storage unit that stores an interval of the branch instruction corresponding to the branch instruction;
A control unit that determines the timing of referring to the history storage unit based on the interval of the branch instruction stored in the interval storage unit;
A counter for measuring the interval between the branch instructions;
An update unit that updates the content of the interval storage unit based on the interval of the branch instruction measured by the counter ;
The interval storage unit stores both the interval of the branch instruction when the branch by the branch instruction is established and the interval of the branch instruction when the branch by the branch instruction is not established.
The branch predicting apparatus according to claim.
を特徴とする請求項1記載の分岐予測装置。 The branch prediction apparatus according to claim 1, wherein the update unit updates the contents of the interval storage unit each time the branch instruction is executed.
を特徴とする請求項1記載の分岐予測装置。 The update unit updates the contents of the interval storage unit when the interval of the branch instruction based on the measurement of the counter is different from the interval of the branch instruction stored in the interval storage unit. The branch prediction apparatus according to claim 1.
前記分岐命令に対応して前記分岐命令の間隔を記憶する間隔記憶部と、
前記履歴記憶部を参照するタイミングを、前記間隔記憶部に記憶された前記分岐命令の間隔に基づいて決定する制御部と、
前記分岐命令の間隔を計測するカウンタと、
前記間隔記憶部の内容を、前記カウンタにより計測された前記分岐命令の間隔に基づいて更新する更新部とを備え、
前記更新部は、前記カウンタの計測に基づく前記分岐命令の間隔が、前記間隔記憶部に記憶されている前記分岐命令の間隔より大きいとき、前記記憶されている前記分岐命令の間隔に基づいて参照されるアドレスに、前記計測に基づく前記分岐命令の間隔と前記記憶されている前記分岐命令の間隔との差分に基づいて算出される間隔を書き込むこと
を特徴とする分岐予測装置。 A prediction unit that has a history storage unit that stores a result of the branch instruction, and performs branch prediction with reference to the history storage unit;
An interval storage unit that stores an interval of the branch instruction corresponding to the branch instruction;
A control unit that determines the timing of referring to the history storage unit based on the interval of the branch instruction stored in the interval storage unit;
A counter for measuring the interval between the branch instructions;
An update unit that updates the content of the interval storage unit based on the interval of the branch instruction measured by the counter;
The updating unit refers to the branch instruction interval stored when the interval of the branch instruction based on the measurement of the counter is larger than the interval of the branch instruction stored in the interval storage unit. is in the address, the based on the measurement the branch instruction interval and branch prediction device you and writes the interval is calculated based on the difference between the distance of the branch instruction being the storage of.
前記分岐予測装置は、
分岐命令の結果を記憶する履歴記憶部を有し、前記履歴記憶部を参照して分岐予測を実施する予測部と、
前記分岐命令に対応して前記分岐命令の間隔を記憶する間隔記憶部と、
前記履歴記憶部を参照するタイミングを、前記間隔記憶部に記憶された前記分岐命令の間隔に基づいて決定する制御部と、
前記分岐命令の間隔を計測するカウンタと、
前記間隔記憶部の内容を、前記カウンタにより計測された前記分岐命令の間隔に基づいて更新する更新部とを備え、
前記間隔記憶部は、前記分岐命令による分岐が成立したときの前記分岐命令の間隔と前記分岐命令による分岐が不成立のときの前記分岐命令の間隔との両方を記憶すること
を特徴とするプロセッサ。 A decoding unit that decodes an instruction; and a branch prediction device that performs branch prediction of a branch instruction;
The branch prediction device
A prediction unit that has a history storage unit that stores a result of the branch instruction, and performs branch prediction with reference to the history storage unit;
An interval storage unit that stores an interval of the branch instruction corresponding to the branch instruction;
A control unit that determines the timing of referring to the history storage unit based on the interval of the branch instruction stored in the interval storage unit;
A counter for measuring the interval between the branch instructions;
An update unit that updates the content of the interval storage unit based on the interval of the branch instruction measured by the counter ;
The interval storage unit stores both the interval of the branch instruction when the branch by the branch instruction is established and the interval of the branch instruction when the branch by the branch instruction is not established.
Processor characterized by.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2010274921A JP5609609B2 (en) | 2010-12-09 | 2010-12-09 | Branch prediction apparatus and processor |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2010274921A JP5609609B2 (en) | 2010-12-09 | 2010-12-09 | Branch prediction apparatus and processor |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JP2012123683A JP2012123683A (en) | 2012-06-28 |
| JP5609609B2 true JP5609609B2 (en) | 2014-10-22 |
Family
ID=46505040
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2010274921A Expired - Fee Related JP5609609B2 (en) | 2010-12-09 | 2010-12-09 | Branch prediction apparatus and processor |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP5609609B2 (en) |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| GB2285154B (en) * | 1993-12-24 | 1998-04-01 | Advanced Risc Mach Ltd | Branch cache |
| US5704054A (en) * | 1995-05-09 | 1997-12-30 | Yale University | Counterflow pipeline processor architecture for semi-custom application specific IC's |
| JP2939248B2 (en) * | 1997-07-14 | 1999-08-25 | 松下電器産業株式会社 | Branch prediction method and processor |
-
2010
- 2010-12-09 JP JP2010274921A patent/JP5609609B2/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| JP2012123683A (en) | 2012-06-28 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US8521996B2 (en) | Pipelined microprocessor with fast non-selective correct conditional branch instruction resolution | |
| US8635437B2 (en) | Pipelined microprocessor with fast conditional branch instructions based on static exception state | |
| US9442736B2 (en) | Techniques for selecting a predicted indirect branch address from global and local caches | |
| US9824016B2 (en) | Device and processing method | |
| US7975132B2 (en) | Apparatus and method for fast correct resolution of call and return instructions using multiple call/return stacks in the presence of speculative conditional instruction execution in a pipelined microprocessor | |
| US12190114B2 (en) | Segmented branch target buffer based on branch instruction type | |
| US20060090063A1 (en) | Method for executing structured symbolic machine code on a microprocessor | |
| CN111078296B (en) | Branch prediction method, branch prediction unit and processor core | |
| US11599361B2 (en) | Flushing a fetch queue using predecode circuitry and prediction information | |
| JPS58125148A (en) | Apparatus for forecasting conditioned branch instruction | |
| US9851973B2 (en) | Dynamic branch hints using branches-to-nowhere conditional branch | |
| EP3166015A1 (en) | Fetch ahead branch target buffer | |
| CN103353834A (en) | Branch mispredication behavior suppression on zero predicate branch mispredict | |
| US10353710B2 (en) | Techniques for predicting a target address of an indirect branch instruction | |
| US7454602B2 (en) | Pipeline having bifurcated global branch history buffer for indexing branch history table per instruction fetch group | |
| CN115769189A (en) | Instruction address translation and instruction prefetch engine | |
| EP0893756B1 (en) | Method and apparatus for controlling conditional branch execution in a data processor | |
| WO2003093979A1 (en) | A method for realizing autonomous load/store by using symbolic machine code | |
| US9569273B2 (en) | Apparatus and method for controlling execution of a single thread by multiple processors | |
| CN100530081C (en) | Branch prediction control | |
| US5453927A (en) | Data processor for processing branch instructions | |
| JP5609609B2 (en) | Branch prediction apparatus and processor | |
| EP4020167A1 (en) | Accessing a branch target buffer based on branch instruction information | |
| CN119025164B (en) | RISC-V vector instruction configuration determination method and device | |
| JP4702004B2 (en) | Microcomputer |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20130904 |
|
| A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20140416 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20140422 |
|
| A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20140619 |
|
| TRDD | Decision of grant or rejection written | ||
| A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20140805 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20140818 |
|
| R150 | Certificate of patent or registration of utility model |
Ref document number: 5609609 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
| LAPS | Cancellation because of no payment of annual fees |