JP2013250593A - Semiconductor device - Google Patents

Semiconductor device Download PDF

Info

Publication number
JP2013250593A
JP2013250593A JP2012122689A JP2012122689A JP2013250593A JP 2013250593 A JP2013250593 A JP 2013250593A JP 2012122689 A JP2012122689 A JP 2012122689A JP 2012122689 A JP2012122689 A JP 2012122689A JP 2013250593 A JP2013250593 A JP 2013250593A
Authority
JP
Japan
Prior art keywords
branch
instruction
prediction
fixed
history table
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2012122689A
Other languages
Japanese (ja)
Inventor
Toshiyuki Ogawa
敏行 小川
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Renesas Electronics Corp
Original Assignee
Renesas Electronics Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Renesas Electronics Corp filed Critical Renesas Electronics Corp
Priority to JP2012122689A priority Critical patent/JP2013250593A/en
Publication of JP2013250593A publication Critical patent/JP2013250593A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Advance Control (AREA)

Abstract

PROBLEM TO BE SOLVED: To suppress power consumption while maintaining the performance of a semiconductor for performing dynamic branch prediction using a branch history table.SOLUTION: An instruction processing part for processing the fetch and execution of an instruction including a condition branch instruction executes a fixing instruction to instruct the fixing of a branch prediction direction showing either "branched" or "not branched". With respect to a condition branch instruction after the fixing instruction is executed, the instruction processing part executes branch prediction in the branch prediction direction instructed by the fixing instruction without referring to a branch history table BHT (S120 to S122).

Description

本発明は半導体装置に関し、例えば分岐予測を行うプロセッサに関する。   The present invention relates to a semiconductor device, for example, a processor that performs branch prediction.

パイプライン処理プロセッサにおいて、パイプライン処理の効果を可能な限り維持し、性能を高めるために、プログラム実行の流れの中で条件分岐命令が分岐するかしないか(Taken or Not−Taken)の予測、所謂「分岐予測」が行われている(特許文献1〜5)。   In a pipeline processor, in order to maintain the effect of pipeline processing as much as possible and to improve performance, prediction of whether or not a conditional branch instruction branches in the flow of program execution (Take or Not-Take), So-called “branch prediction” is performed (Patent Documents 1 to 5).

分岐予測の手法は様々ある。例えば、特許文献2の[0005]段落に開示されたように、動的分岐予測手法の1つとして、分岐履歴テーブル(BHT:Branch History Table)を用いる技術が知られている。   There are various branch prediction methods. For example, as disclosed in paragraph [0005] of Patent Document 2, a technique using a branch history table (BHT) is known as one of dynamic branch prediction methods.

該技術は、条件分岐命令の実行に際して、分岐履歴テーブルに格納された履歴を参照して分岐予測を行うと共に、該条件分岐命令の実行結果に基づいて分岐履歴テーブルを更新することにより学習を行う。   In the technique, when executing a conditional branch instruction, branch prediction is performed by referring to the history stored in the branch history table, and learning is performed by updating the branch history table based on the execution result of the conditional branch instruction. .

また、既存のプロセッサの中では、上記機能が実装されていながら、制御レジスタにより該機能を無効にできるものがある。このプロセッサは、該機能が有効にされているときには、分岐履歴テーブルを用いた動的分岐予測を行い、該機能が無効にされているときには、全ての条件分岐命令に対して、Not−Taken(分岐しない)との予測を行う。   In addition, among existing processors, there are some which can disable the function by a control register while the function is mounted. This processor performs dynamic branch prediction using a branch history table when the function is enabled, and for all conditional branch instructions when the function is disabled, Predicted that it will not branch).

特開2010−079841号公報JP 2010-079841 A 特開2009−048633号公報JP 2009-048633 A 特開2007−058875号公報JP 2007-058875 A 特開2001−142705号公報JP 2001-142705 A 特開平08−249181号公報Japanese Patent Laid-Open No. 08-249181

昨今において、プロセッサを備えた半導体装置は、高機能化と多機能化の一図を辿っており、必然的に消費電力も多くなる。このような背景において、機能性を維持しながらいかに消費電力を削減するかについて、半導体装置の開発者はしのぎを削っている。   In recent years, a semiconductor device provided with a processor has followed a diagram of high functionality and multi-functionality, which inevitably increases power consumption. Against this background, semiconductor device developers are struggling to reduce power consumption while maintaining functionality.

分岐履歴テーブルを用いて動的分岐予測を行うプロセッサは、条件分岐命令を実行する度に、分岐履歴テーブルを参照するため、分岐履歴テーブルへのリードが必ず発生する。また、条件分岐命令の実行結果に基づいた分岐履歴テーブルの更新時には、分岐履歴テーブルへのライトも発生する。例えば、1ビット学習の場合には、分岐予測が失敗であるときにのみ分岐履歴テーブルへのライトが発生し、2ビット学習の場合には、分岐予測の成功と失敗のいずれのときにも分岐履歴テーブルへのライトが発生する。   Since a processor that performs dynamic branch prediction using a branch history table refers to the branch history table every time a conditional branch instruction is executed, a read to the branch history table always occurs. In addition, when the branch history table is updated based on the execution result of the conditional branch instruction, writing to the branch history table also occurs. For example, in the case of 1-bit learning, a write to the branch history table occurs only when the branch prediction is unsuccessful, and in the case of 2-bit learning, the branch is performed both when the branch prediction is successful and when it is failed. A write to the history table occurs.

分岐履歴テーブルは、メモリにより構成される。条件分岐命令の度に分岐履歴テーブルであるメモリへのアクセスはプロセッサの消費電力増加の1つの要因となる。   The branch history table is configured by a memory. Access to the memory that is the branch history table for each conditional branch instruction is one factor in increasing the power consumption of the processor.

一方、分岐履歴テーブルを用いた動的分岐予測の機能を無効にしてしまうと、常にNot−Takenの分岐予測が行われるため、分岐履歴テーブルへのアクセスを無くすことができるが、プロセッサの性能が低下する。   On the other hand, if the function of dynamic branch prediction using the branch history table is disabled, not-taken branch prediction is always performed, so access to the branch history table can be eliminated, but the processor performance is reduced. descend.

その他の課題と新規な特徴は、本明細書の記述および添付図面から明らかになるであろう。   Other problems and novel features will become apparent from the description of the specification and the accompanying drawings.

一実施の形態による半導体装置は、命令のフェッチと実行を含む処理を行い、条件分岐命令の実行に際して分岐予測を行う命令処理部と、条件分岐命令の実行の結果、分岐したか否かの履歴を格納するためのものであり、前記命令処理部により更新される分岐履歴テーブルとを備える。   A semiconductor device according to an embodiment performs processing including fetch and execution of an instruction, performs an instruction processing unit that performs branch prediction when executing a conditional branch instruction, and history of whether or not a branch has occurred as a result of execution of the conditional branch instruction And a branch history table updated by the instruction processing unit.

命令処理部は、「分岐する」と「分岐しない」のいずれか一方を示す分岐予測方向に固定することを指示する固定命令を実行することを可能とする。   The instruction processing unit can execute a fixed instruction instructing fixing in a branch prediction direction indicating either “branch” or “not branch”.

命令実行部は、条件分岐命令に対して、分岐履歴テーブルに格納された前記履歴を参照して分岐予測を行う動的分岐を行う。命令処理部は、固定命令を実行した後では、条件分岐命令に対して、前記分岐履歴テーブルを参照せずに、前記固定命令が指示する分岐予測方向に分岐予測をする固定予測を行う。   The instruction execution unit performs a dynamic branch for performing branch prediction with respect to the conditional branch instruction with reference to the history stored in the branch history table. After executing the fixed instruction, the instruction processing unit performs a fixed prediction for performing a branch prediction in a branch prediction direction indicated by the fixed instruction without referring to the branch history table for the conditional branch instruction.

望ましくは、命令処理部は、条件分岐命令に対して固定予測を行う際には、その条件分岐命令の実行結果に基づいて分岐履歴テーブルを更新しないようにしてもよい。   Desirably, the instruction processing unit may not update the branch history table based on the execution result of the conditional branch instruction when performing fixed prediction on the conditional branch instruction.

さらに望ましくは、命令処理部は、固定命令が指示する分岐予測の方向の固定を解除する固定を解除する固定解除命令を実行することを可能としてもよい。固定解除命令を実行した後は、条件分岐命令に対して、命令処理部は分岐履歴テーブルに格納された履歴を参照して分岐予測をする動的予測を行うと共にこの条件分岐命令の実行結果に基づいて前記分岐履歴テーブルを更新する。   More preferably, the instruction processing unit may be able to execute a fixed release instruction for releasing the fixation for releasing the fixation of the branch prediction direction indicated by the fixed instruction. After executing the fixed release instruction, the instruction processing unit performs dynamic prediction to perform branch prediction with reference to the history stored in the branch history table for the conditional branch instruction and displays the execution result of the conditional branch instruction. Based on this, the branch history table is updated.

別の実施の形態によれば、命令処理部は、「分岐する」と「分岐しない」のいずれか一方を示す分岐予測方向に固定することを示す固定指示が含まれる条件分岐命令である固定指示付き分岐命令を実行することを可能とする。   According to another embodiment, the instruction processing unit is a fixed instruction that is a conditional branch instruction including a fixed instruction indicating that the instruction is fixed in a branch prediction direction indicating either “branch” or “not branch” It is possible to execute an attached branch instruction.

命令処理部は、固定指示付き分岐命令に対して、分岐履歴テーブルを参照せずに、固定指示が示す分岐予測方向に分岐予測をする固定予測を行う。   The instruction processing unit performs fixed prediction on the branch instruction with a fixed instruction without performing a branch prediction in the branch prediction direction indicated by the fixed instruction without referring to the branch history table.

命令処理部は、さらに固定指示が含まれない条件分岐命令に対して、分岐履歴テーブルに格納された前記履歴を参照して分岐予測をする動的予測を行うと共に、前記条件分岐命令の実行結果に基づいて前記分岐履歴テーブルを更新する。   The instruction processing unit performs dynamic prediction for performing branch prediction with reference to the history stored in the branch history table for a conditional branch instruction that does not include a fixed instruction, and the execution result of the conditional branch instruction. The branch history table is updated based on

なお、上記の又は後述の各実施の形態の装置を方法やシステムに置き換えて表現したもの、これらの装置または該装置の一部をコンピュータに実行せしめるプログラムなども、実施の形態として有効である。   In addition, a representation in which the devices in the above-described or following embodiments are replaced with methods and systems, a program that causes a computer to execute these devices or a part of the devices, and the like are also effective as the embodiments.

上述した実施の形態によれば、分岐履歴テーブルを用いた動的分岐予測を行う半導体装置の性能を維持しつつ、消費電力を抑制することができる。   According to the above-described embodiment, it is possible to suppress power consumption while maintaining the performance of a semiconductor device that performs dynamic branch prediction using a branch history table.

第1〜第3の技術を説明するための半導体装置を示す図である。It is a figure which shows the semiconductor device for demonstrating the 1st-3rd technique. 第1の技術を適用した場合、図1に示す半導体装置における命令処理部が対応する固定命令の例を示す図である。FIG. 2 is a diagram illustrating an example of a fixed instruction to which an instruction processing unit in the semiconductor device illustrated in FIG. 1 corresponds when the first technique is applied. 第1の技術を適用した場合、図1に示す半導体装置における命令処理部が対応する固定解除命令の例を示す図である。It is a figure which shows the example of the fixed release command which the command processing part in the semiconductor device shown in FIG. 1 respond | corresponds when the 1st technique is applied. 第1の技術を適用した場合のプログラムと従来のプログラムの比較例を示す図である。It is a figure which shows the comparative example of the program at the time of applying a 1st technique, and the conventional program. 第1の技術を適用した場合、図1に示す半導体装置における命令処理部が行う処理を示すフローチャートの例を示す図である。FIG. 3 is a diagram illustrating an example of a flowchart illustrating processing performed by an instruction processing unit in the semiconductor device illustrated in FIG. 1 when the first technique is applied. 第2の技術を適用した場合、図1に示す半導体装置における命令処理部が対応する固定指示付き分岐命令の例を示す図である。FIG. 10 is a diagram illustrating an example of a branch instruction with a fixed instruction to which the instruction processing unit in the semiconductor device illustrated in FIG. 1 corresponds when the second technique is applied. 第1の技術を適用した場合のプログラム例を示す図である。It is a figure which shows the example of a program at the time of applying a 1st technique. 第2の技術を適用した場合、図1に示す半導体装置における命令処理部が行う処理を示すフローチャートの例を示す図である。It is a figure which shows the example of the flowchart which shows the process which the command process part in the semiconductor device shown in FIG. 1 performs when the 2nd technique is applied. 第3の技術を適用した場合、図1に示す半導体装置における命令処理部が行う処理を示すフローチャートの例を示す図である。It is a figure which shows the example of the flowchart which shows the process which the command process part in the semiconductor device shown in FIG. 1 performs when the 3rd technique is applied. 第4の技術を説明するための半導体装置を示す図である。It is a figure which shows the semiconductor device for demonstrating the 4th technique. 図10に示す半導体装置における命令処理部が行う処理を示すフローチャートの例を示す図である。It is a figure which shows the example of the flowchart which shows the process which the command process part in the semiconductor device shown in FIG. 10 performs. 第1の実施の形態にかかる半導体装置を示す図である。1 is a diagram illustrating a semiconductor device according to a first embodiment. 図12に示す半導体装置におけるCPU(Central Processing Unit)を示す図である。FIG. 13 is a diagram showing a CPU (Central Processing Unit) in the semiconductor device shown in FIG. 12. 第3の実施の形態の半導体装置におけるCPUを示す図である。It is a figure which shows CPU in the semiconductor device of 3rd Embodiment. 第4の実施の形態の半導体装置におけるCPUを示す図である。It is a figure which shows CPU in the semiconductor device of 4th Embodiment. 図15に示すCPUにおける領域設定レジスタと、プログラムの実行領域との対応関係を示す図である。FIG. 16 is a diagram illustrating a correspondence relationship between an area setting register and a program execution area in the CPU illustrated in FIG. 15.

説明の明確化のため、以下の記載及び図面は、適宜、省略、及び簡略化がなされている。また、様々な処理を行う機能ブロックとして図面に記載される各要素は、ハードウェア的には、CPU、メモリ、その他の回路で構成することができ、ソフトウェア的には、メモリにロードされたプログラムなどによって実現される。したがって、これらの機能ブロックがハードウェアのみ、ソフトウェアのみ、またはそれらの組合せによっていろいろな形で実現できることは当業者には理解されるところであり、いずれかに限定されるものではない。なお、各図面において、同一の要素には同一の符号が付されており、必要に応じて重複説明は省略されている。   For clarity of explanation, the following description and drawings are omitted and simplified as appropriate. Each element described in the drawings as a functional block for performing various processes can be configured by a CPU, a memory, and other circuits in terms of hardware, and a program loaded in the memory in terms of software. Etc. Therefore, it is understood by those skilled in the art that these functional blocks can be realized in various forms by hardware only, software only, or a combination thereof, and is not limited to any one. Note that, in each drawing, the same element is denoted by the same reference numeral, and redundant description is omitted as necessary.

また、上述したプログラムは、様々なタイプの非一時的なコンピュータ可読媒体(non−transitory computer readable medium)を用いて格納され、コンピュータに供給することができる。非一時的なコンピュータ可読媒体は、様々なタイプの実体のある記録媒体(tangible storage medium)を含む。非一時的なコンピュータ可読媒体の例は、磁気記録媒体(例えばフレキシブルディスク、磁気テープ、ハードディスクドライブ)、光磁気記録媒体(例えば光磁気ディスク)、CD−ROM(Read Only Memory)CD−R、CD−R/W、半導体メモリ(例えば、マスクROM、PROM(Programmable ROM)、EPROM(Erasable PROM)、フラッシュROM、RAM(Random Access Memory))を含む。また、プログラムは、様々なタイプの一時的なコンピュータ可読媒体(transitory computer readable medium)によってコンピュータに供給されてもよい。一時的なコンピュータ可読媒体の例は、電気信号、光信号、及び電磁波を含む。一時的なコンピュータ可読媒体は、電線及び光ファイバ等の有線通信路、又は無線通信路を介して、プログラムをコンピュータに供給できる。   Further, the above-described program can be stored using various types of non-transitory computer readable media and supplied to a computer. Non-transitory computer readable media include various types of tangible storage media. Examples of non-transitory computer-readable media include magnetic recording media (for example, flexible disks, magnetic tapes, hard disk drives), magneto-optical recording media (for example, magneto-optical disks), CD-ROM (Read Only Memory) CD-R, CD -R / W, semiconductor memory (for example, mask ROM, PROM (Programmable ROM), EPROM (Erasable PROM), flash ROM, RAM (Random Access Memory)). The program may also be supplied to the computer by various types of transitory computer readable media. Examples of transitory computer readable media include electrical signals, optical signals, and electromagnetic waves. The temporary computer-readable medium can supply the program to the computer via a wired communication path such as an electric wire and an optical fiber, or a wireless communication path.

具体的な実施の形態の前に、実施の形態に適用される4つの技術を説明する。
まず、図1に示す半導体装置10を参照して、第1〜3の技術を説明する。
Prior to specific embodiments, four techniques applied to the embodiments will be described.
First, the first to third techniques will be described with reference to the semiconductor device 10 shown in FIG.

半導体装置10は、単一の半導体チップにより構成されるマイクロコンピュータを有する。半導体装置10は例えば、この半導体チップと電気的に接続される外部端子を有し、半導体チップを内部に樹脂で封止して外部端子を露出される半導体パッケージの形態をなす。マイクロコンピュータは、命令処理部12と分岐履歴テーブル14を備え、パイプライン処理によりプログラムを構成する命令列を実行する。   The semiconductor device 10 has a microcomputer constituted by a single semiconductor chip. For example, the semiconductor device 10 has an external terminal electrically connected to the semiconductor chip, and takes the form of a semiconductor package in which the semiconductor chip is sealed with resin and the external terminal is exposed. The microcomputer includes an instruction processing unit 12 and a branch history table 14, and executes an instruction sequence constituting a program by pipeline processing.

命令処理部12は、命令のフェッチと実行を含む処理を行い、条件分岐命令の実行に際して分岐予測を行う。   The instruction processing unit 12 performs processing including instruction fetch and execution, and performs branch prediction when executing a conditional branch instruction.

分岐履歴テーブル14は、条件分岐命令の実行の結果、分岐したか否かの履歴を格納するためのものであり、命令処理部12により更新される。   The branch history table 14 is used to store a history of whether or not a branch has occurred as a result of execution of a conditional branch instruction, and is updated by the instruction processing unit 12.

<第1の技術>
該第1の技術では、命令処理部12は、固定命令と固定解除命令とを実行することを可能とする構成をなす。
固定命令は、分岐予測に際して、分岐予測方向を「分岐する」(Taken)と「分岐しない」(Not−Taken)のいずれか一方に固定することを指示する命令である。
<First technology>
In the first technique, the instruction processing unit 12 is configured to be able to execute a fixed instruction and a fixed release instruction.
The fixed instruction is an instruction that instructs the branch prediction direction to be fixed to one of “branch” (Taken) and “not branch” (Not-Taken).

命令処理部12は、条件分岐命令に対して、前記分岐履歴テーブルに格納された前記履歴を参照して分岐予測を行う動的分岐を行う。動的予測とは、分岐履歴テーブル14に格納された履歴を参照して分岐予測をすることを意味する。   The instruction processing unit 12 performs a dynamic branch for performing a branch prediction with reference to the history stored in the branch history table for a conditional branch instruction. Dynamic prediction means that branch prediction is performed with reference to the history stored in the branch history table 14.

命令処理部12は、固定命令を実行した後では、条件分岐命令に対し固定予測を行う。固定予測とは、条件分岐命令に対して、分岐履歴テーブル14を参照せずに、該固定命令が指示する分岐予測方向に分岐予測をすることを意味する。また、命令処理部12は、固定予測の対象である条件分岐命令の実行後に、分岐履歴テーブル14の更新をしない。   The instruction processing unit 12 performs fixed prediction on the conditional branch instruction after executing the fixed instruction. “Fixed prediction” refers to branch prediction in a branch prediction direction designated by a fixed instruction without referring to the branch history table 14 for a conditional branch instruction. Further, the instruction processing unit 12 does not update the branch history table 14 after the execution of the conditional branch instruction that is the target of fixed prediction.

命令処理部12は、固定解除命令を実行した後では、条件分岐命令に対し動的予測を行うと共に、該条件分岐命令の実行結果に基づいて分岐履歴テーブル14を更新する。   After executing the fixed release instruction, the instruction processing unit 12 performs dynamic prediction on the conditional branch instruction and updates the branch history table 14 based on the execution result of the conditional branch instruction.

動的予測を行った条件分岐命令の実行後における分岐履歴テーブル14の更新について、分岐履歴テーブルを用いて動的分岐予測を行う従来のプロセッサのように、命令処理部12は、例えば、1ビット学習の場合には、分岐予測がミスであるときにのみ分岐履歴テーブル14を更新し、2ビット学習の場合には、分岐予測が正しいときとミスであるときのいずれのときにも分岐履歴テーブル14を更新する。   Regarding the update of the branch history table 14 after execution of the conditional branch instruction for which dynamic prediction has been performed, the instruction processing unit 12 has, for example, 1 bit as in a conventional processor that performs dynamic branch prediction using a branch history table. In the case of learning, the branch history table 14 is updated only when the branch prediction is a mistake, and in the case of 2-bit learning, the branch history table is obtained both when the branch prediction is correct and when it is a mistake. 14 is updated.

図2は、固定命令のフォーマットの例を示す。この例は、命令長を16ビットとした場合のものである。図示のように、固定命令は、上部に示す固定命令bptfと、下部に示す固定命令bpnfの2種類がある。   FIG. 2 shows an example of the format of a fixed instruction. In this example, the instruction length is 16 bits. As shown in the figure, there are two types of fixed instructions: a fixed instruction bptf shown at the top and a fixed instruction bpnf shown at the bottom.

固定命令bptfは、上位14ビットの「10101111111100」が、該命令が固定命令または固定解除命令であることを示し、下位2ビットの「00」が、該命令が分岐予測方向を「分岐する」(Taken)に固定することを指示する固定命令であることを示す。   In the fixed instruction bptf, “10101111111100” in the upper 14 bits indicates that the instruction is a fixed instruction or a fixed release instruction, and “00” in the lower 2 bits indicates that the instruction “branches” the branch prediction direction ( Taken) indicates that the instruction is fixed.

また、固定命令bpnfは、上位14ビットの「10101111111100」が、該命令が固定命令または固定解除命令であることを示し、下位2ビットの「01」が、該命令が分岐予測方向を「分岐しない」(Not−Taken)に固定することを指示する固定命令であることを示す。   In the fixed instruction bpnf, “10101111111100” in the upper 14 bits indicates that the instruction is a fixed instruction or a fixed release instruction, and “01” in the lower 2 bits indicates that the instruction does not branch the branch prediction direction. "(Not-Taken)" indicates that the instruction is a fixed instruction for fixing.

図3は、図2に示す固定命令に対応する固定解除命令の例を示す。図示のように、固定解除命令bprは、上位14ビットの「10101111111100」が、該命令が固定命令または固定解除命令であることを示し、下位2ビットの「10」が、該命令が、直前にあった固定命令に対応する固定解除命令であることを示す。   FIG. 3 shows an example of a fixed release instruction corresponding to the fixed instruction shown in FIG. As shown in the figure, in the fixed release instruction bpr, the upper 14 bits “10101111111100” indicates that the instruction is a fixed instruction or fixed release instruction, and the lower 2 bits “10” indicates that the instruction is immediately before Indicates that it is a fixed release command corresponding to the fixed command that was present.

命令処理部12は、固定命令を実行した後、固定解除命令を実行するまでは、条件分岐命令に対しては常に固定予測を行う。固定解除命令を実行することによって命令処理部12は固定予測による条件分岐を解除し、固定解除命令の後に実行される条件分岐命令に対して動的予測を行う。   After executing the fixed instruction, the instruction processing unit 12 always performs fixed prediction on the conditional branch instruction until the fixed release instruction is executed. By executing the fixed release instruction, the instruction processing unit 12 releases the conditional branch based on the fixed prediction, and performs dynamic prediction on the conditional branch instruction executed after the fixed release instruction.

図4は、ループ処理を実行させる従来のプログラム(図4左)と、該ループ処理を、固定命令と固定解除命令を含むプログラムで実行させるプログラム(図4右)の例を示す。なお、この例におけるループ処理は、0C000000から始まるエリアを4x1000バイト分初期化する処理である。"mov"は転送命令を示し、最初の3つのmov命令がループ処理の初期設定を行う。第1のmov命令は初期化するバイト数(1000)を、第2のmov命令は初期値(11223344)を、第3のmov命令は初期化するエリアの先頭アドレス(0C000000)を、それぞれレジスタr0、r1、r2に設定する命令である。ループ内において"mov"はレジスタr2の値で特定されるアドレス番地にレジスタr1の値を転送する転送命令である。"add"はレジスタr2の値に4を加算する加算命令である。"dt"はレジスタR0の値をデクリメントしてゼロ値となったときに特定のフラグに1をセットし、そうでないときは0とする命令である。"bf"は当該特定のフラグが0を示すときにLoopに分岐し、フラグが1のときは分岐することなくNOP(No operation)となる分岐命令である。   FIG. 4 shows an example of a conventional program that executes a loop process (FIG. 4 left) and a program that executes the loop process with a program including a fixed instruction and a fixed release instruction (right side of FIG. 4). The loop processing in this example is processing for initializing an area starting from 0C000000 for 4 × 1000 bytes. “mov” indicates a transfer command, and the first three mov commands perform initialization of loop processing. The first mov instruction indicates the number of bytes to be initialized (1000), the second mov instruction indicates the initial value (11223344), the third mov instruction indicates the start address (0C000000) of the area to be initialized, and the register r0. , R1 and r2. In the loop, “mov” is a transfer instruction for transferring the value of the register r1 to the address address specified by the value of the register r2. “add” is an addition instruction for adding 4 to the value of the register r2. “dt” is an instruction that sets a specific flag to 1 when the value of the register R0 is decremented to zero, and sets to 0 otherwise. “bf” is a branch instruction that branches to a Loop when the specific flag indicates 0, and becomes a NOP (No operation) without branching when the flag is 1.

分岐履歴テーブルを用いた分岐予測の機能を備えたプロセッサで図4の左部に示す従来のプログラムを実行する場合に、ループの各回の最後において、ループを繰り返すかループを脱出(正常終了)するかの分岐予測を行う。そのため、ループを繰り返した回数と、ループ実行の最後の分岐(ループの正常終了)の1回とを合わせた分(1000回)、分岐履歴テーブルへのアクセス(リード)が生じる。また、2ビット学習の場合には、分岐予測が正しくても誤っても、分岐予測の後に分岐履歴テーブルへのアクセス(ライト)が生じ、1ビット学習の場合には、分岐予測が誤ったときに、分岐予測の後に分岐履歴テーブルへのアクセス(ライト)が生じる。   When a processor having a branch prediction function using a branch history table executes the conventional program shown in the left part of FIG. 4, the loop is repeated or the loop is exited (normal end) at the end of each loop. Do branch prediction. For this reason, access (read) to the branch history table occurs by the sum (1000 times) of the number of times the loop is repeated and the last branch of the loop execution (normal end of the loop). In the case of 2-bit learning, whether the branch prediction is correct or incorrect, access (write) to the branch history table occurs after the branch prediction, and in the case of 1-bit learning, the branch prediction is incorrect. In addition, access (write) to the branch history table occurs after branch prediction.

ところで、ループ処理を行わせるプログラムの場合、プログラムの作成者は、ループ実行の最後の分岐を除き、ループが繰り返されることを知っている。そのため、図4の右部に示すように、ループ処理に先立って、固定命令bptfを挿入することにより、その後の分岐予測方向を「分岐予測」に固定すると共に、ループの正常終了後に、固定解除命令bprを挿入することにより、固定命令bptfによる分岐予測方向の固定を解除するようにプログラムを作成することができる。   By the way, in the case of a program that performs loop processing, the program creator knows that the loop is repeated except for the last branch of the loop execution. Therefore, as shown in the right part of FIG. 4, by inserting a fixed instruction bptf prior to loop processing, the subsequent branch prediction direction is fixed to “branch prediction”, and after the normal termination of the loop, the fixation is released. By inserting the instruction bpr, a program can be created so as to release the fixed branch prediction direction by the fixed instruction bptf.

図5は、命令処理部12によるプログラムの実行のフローチャートの例を示す。図示のように、固定命令が無い場合(S100:Yes)、または、固定命令があったものの、その後、固定解除命令があった場合(S100:Yes、S114:Yes)、命令処理部12は、条件分岐命令に対して、動的予測を行う。具体的には、条件分岐命令に対して、分岐履歴テーブル14を参照して分岐予測を行うと共に、該条件分岐命令の実行後、実行結果に基づいて分岐履歴テーブル14を更新する(S102:Yes、S106、S108、S110、S112)。   FIG. 5 shows an example of a flowchart of program execution by the instruction processing unit 12. As shown in the figure, when there is no fixed instruction (S100: Yes), or when there is a fixed instruction but there is a fixed release instruction (S100: Yes, S114: Yes), the instruction processing unit 12 Dynamic prediction is performed for conditional branch instructions. Specifically, for the conditional branch instruction, branch prediction is performed with reference to the branch history table 14, and after execution of the conditional branch instruction, the branch history table 14 is updated based on the execution result (S102: Yes). , S106, S108, S110, S112).

図4の左部に示す従来のプログラムの場合には、ステップS102〜ステップS112の処理がなされる。   In the case of the conventional program shown in the left part of FIG. 4, the processing of step S102 to step S112 is performed.

一方、固定命令の後、固定解除命令の前の間(S100:Yes、S114:No)、命令処理部12は、条件分岐命令に対して、固定予測を行う。具体的には、条件分岐命令に対して、分岐履歴テーブル14を参照せずに、固定命令が指示する分岐予測方向(TakenまたはNot−Taken)に分岐予測を行い、該条件分岐命令の実行後には、実行結果に関わらず、分岐履歴テーブル14の更新をしない(S116:Yes、S120、S122)。   On the other hand, after the fixed instruction and before the fixed release instruction (S100: Yes, S114: No), the instruction processing unit 12 performs fixed prediction on the conditional branch instruction. Specifically, for a conditional branch instruction, branch prediction is performed in the branch prediction direction (Taken or Not-Take) indicated by the fixed instruction without referring to the branch history table 14, and after execution of the conditional branch instruction Does not update the branch history table 14 regardless of the execution result (S116: Yes, S120, S122).

図4の右部に示すプログラムの場合、命令処理部12は、ループの正常終了まで、ループを繰り返すための分岐(Taken)に分岐予測をする。そのため、ループ実行の最後の分岐(1000回目)で予測が誤るが、他の全て(999回)の分岐予測が正しい結果になる。   In the case of the program shown in the right part of FIG. 4, the instruction processing unit 12 performs branch prediction on a branch (Taken) for repeating the loop until the loop ends normally. Therefore, the prediction is incorrect at the last branch (1000th) of the loop execution, but all other (999) branch predictions are correct.

なお、条件分岐命令以外の他の命令については、分岐予測が生じず、命令処理部12は、通常のプロセッサと同様にこれらの命令のフェッチ及び実行をする(S102:No、S104)(S116:No、S118)。   Note that branch instructions are not predicted for instructions other than conditional branch instructions, and the instruction processing unit 12 fetches and executes these instructions in the same manner as a normal processor (S102: No, S104) (S116: No, S118).

該第1の技術では、命令処理部12が固定命令と固定解除命令に対応し、固定命令と固定解除命令の間に位置する条件分岐命令に対して分岐予測を行う際に、分岐履歴テーブル14の参照をせずに、常に固定命令が指示する分岐予測方向に分岐予測を行うと共に、条件分岐命令の実行結果に基づいた分岐履歴テーブル14の更新をしない。そのため、ループなど、予め分岐するか否かが分かっているプログラムの場合、プログラムの作成者が固定命令を挿入することにより命令処理部12に固定予測をさせることができる。固定予測の場合に、分岐履歴テーブル14へのアクセスが発生しないため、半導体装置10の消費電力を抑制することができる。   In the first technique, when the instruction processing unit 12 corresponds to a fixed instruction and a fixed release instruction and performs branch prediction on a conditional branch instruction positioned between the fixed instruction and the fixed release instruction, the branch history table 14 The branch history table 14 is not updated based on the execution result of the conditional branch instruction, while the branch prediction is always performed in the branch prediction direction indicated by the fixed instruction without referring to. Therefore, in the case of a program such as a loop that is known in advance as to whether or not to branch, the instruction creator 12 can be caused to make a fixed prediction by inserting a fixed instruction by the program creator. In the case of fixed prediction, since access to the branch history table 14 does not occur, the power consumption of the semiconductor device 10 can be suppressed.

また、固定命令と対にして固定解除命令を使用することにより、固定命令の後に命令処理部12が常に固定予測を行うことを回避することができる。従って、分岐するか否かが分からない条件分岐命令の場合には、分岐履歴テーブルへのアクセスを伴う通常の動的分岐予測が行われるようにすることができ、半導体装置の性能低下を防ぐことができる。   Further, by using the fixed release instruction in pair with the fixed instruction, it is possible to avoid that the instruction processing unit 12 always performs the fixed prediction after the fixed instruction. Therefore, in the case of a conditional branch instruction that does not know whether or not to branch, normal dynamic branch prediction that accompanies access to the branch history table can be performed, thereby preventing performance degradation of the semiconductor device. Can do.

<第2の技術>
該第2の技術では、命令処理部12は、固定指示付き分岐命令を処理することを可能とする構成をなす。
固定指示付き分岐命令は、「分岐する」と「分岐しない」のいずれか一方を示す分岐予測方向に固定することを示す固定指示が含まれる条件分岐命令である。
<Second technology>
In the second technique, the instruction processing unit 12 is configured to be able to process a branch instruction with a fixed instruction.
The branch instruction with a fixed instruction is a conditional branch instruction including a fixed instruction indicating that the instruction is fixed in a branch prediction direction indicating either “branch” or “not branch”.

命令処理部12は、固定指示付き分岐命令に対して、固定予測を行う。ここで、固定予測とは、該条件分岐命令(固定指示付き分岐命令)に対して、分岐履歴テーブル14を参照せずに、該固定指示付き分岐命令に含まれる固定指示が示す分岐予測方向に分岐予測をすることを意味する。また、命令処理部12は、固定指示付き分岐命令に含まれる条件分岐命令の実行後に、分岐履歴テーブル14の更新をしない。   The instruction processing unit 12 performs fixed prediction on a branch instruction with a fixed instruction. Here, fixed prediction refers to the branch prediction direction indicated by the fixed instruction included in the branch instruction with fixed instructions without referring to the branch history table 14 for the conditional branch instruction (branch instruction with fixed instructions). This means branch prediction. Further, the instruction processing unit 12 does not update the branch history table 14 after executing the conditional branch instruction included in the branch instruction with a fixed instruction.

固定指示が含まれない通常の条件分岐命令に対しては、命令処理部12は、分岐履歴テーブル14に格納された履歴を参照して分岐予測をする動的予測を行う。動的予測と共に、命令処理部12は、該条件分岐命令の実行後に、実行結果に基づいて分岐履歴テーブル14を更新する。   For a normal conditional branch instruction that does not include a fixed instruction, the instruction processing unit 12 performs dynamic prediction that performs branch prediction with reference to the history stored in the branch history table 14. Along with the dynamic prediction, the instruction processing unit 12 updates the branch history table 14 based on the execution result after execution of the conditional branch instruction.

図5は、固定指示付き分岐命令のフォーマットの例を示す。この例は、命令長を16ビットとした場合のものである。図示のように、固定指示付き分岐命令は、上から下への順に、固定指示付き分岐命令bptt、固定指示付き分岐命令bpft、固定指示付き分岐命令bptf、固定指示付き分岐命令bpffの4種類がある。   FIG. 5 shows an example of the format of a branch instruction with a fixed instruction. In this example, the instruction length is 16 bits. As shown in the figure, there are four types of branch instructions with fixed instructions, from top to bottom: a branch instruction with fixed instructions bpt, a branch instruction with fixed instructions bpft, a branch instruction with fixed instructions bptf, and a branch instruction with fixed instructions bpff. is there.

この4種類の固定指示付き分岐命令のいずれも、上位13ビットの「1010111111110」が、該命令が固定指示付き分岐命令であることを示す。また、下位の3ビットのうちの上位の1ビットは、分岐条件(TrueまたはFalse)を示し、他の2ビットは、分岐予測方向(TakenまたはNot−Taken)を示す固定指示である。   In any of these four types of branch instructions with fixed instructions, “1010111111110” in the upper 13 bits indicates that the instruction is a branch instruction with fixed instructions. The upper 1 bit among the lower 3 bits indicates a branch condition (True or False), and the other 2 bits are fixed instructions indicating a branch prediction direction (Taken or Not-Taken).

固定指示付き分岐命令bpttは、分岐条件が「True」であり(Trueであるときに分岐する)、固定指示が「分岐する」(Taken)を示す。   The branch instruction with fixed instruction bptt indicates that the branch condition is “True” (branch when true), and the fixed instruction indicates “branch” (Taken).

固定指示付き分岐命令bpftは、分岐条件が「False」であり(Falseであるときに分岐する)、固定指示が「分岐する」(Taken)を示す。   The branch instruction bpft with a fixed instruction indicates that the branch condition is “False” (branch when it is False), and the fixed instruction indicates “branch” (Taken).

固定指示付き分岐命令bptfは、分岐条件が「True」であり、固定指示が「分岐しない」(Not−Taken)を示す。   The branch instruction bptf with a fixed instruction indicates that the branch condition is “True” and the fixed instruction indicates “not branch” (Not-Taken).

固定指示付き分岐命令bpffは、分岐条件が「False」であり、固定指示が「分岐しない」(Not−Taken)を示す。   The branch instruction bpff with a fixed instruction indicates that the branch condition is “False” and the fixed instruction indicates “not branch” (Not-Taken).

図7は、図4左部に示す従来のプログラムによるループ処理を、固定指示付き分岐命令を含むプログラムで実行させる場合の例を示す。   FIG. 7 shows an example in which the loop processing by the conventional program shown in the left part of FIG. 4 is executed by a program including a branch instruction with a fixed instruction.

図7に示すように、この場合、図4左部に示す従来のプログラムにおけるループ処理の最下行の固定指示付き分岐命令「bf Loop」の代わりに、固定指示付き分岐命令「bpft Loop」が用いられる。   As shown in FIG. 7, in this case, the branch instruction with fixed instruction “bpft Loop” is used instead of the branch instruction with fixed instruction “bf Loop” at the bottom of the loop processing in the conventional program shown in the left part of FIG. It is done.

前述したように、固定指示付き分岐命令bpftは、分岐条件が「False」であり、固定指示が「分岐する」(Taken)を示す。そのため、図7のプログラムにおける「bf Loop」は、「r0が0ではない場合(False)にループを繰り返す」条件分岐命令と、「分岐予測方向をTaken(ループを繰り返す)に固定する」固定指示を示すことになる。   As described above, in the branch instruction bpft with a fixed instruction, the branch condition is “False” and the fixed instruction indicates “branch” (Taken). Therefore, “bf Loop” in the program of FIG. 7 is a conditional branch instruction that “repeats the loop when r0 is not 0 (false)” and a fixed instruction that “fixes the branch prediction direction to Taken (repeats the loop)”. Will be shown.

図8は、命令処理部12によるプログラムの実行のフローチャートの例を示す。図示のように、固定指示が含まれない条件分岐命令(S130:Yes、S134:No)に対して、命令処理部12は、動的予測を行う。具体的には、分岐履歴テーブル14を参照して分岐予測を行うと共に、該条件分岐命令の実行後、実行結果に基づいて分岐履歴テーブル14を更新する(S136、S138、S140、S142)。   FIG. 8 shows an example of a flowchart of program execution by the instruction processing unit 12. As illustrated, the instruction processing unit 12 performs dynamic prediction for a conditional branch instruction (S130: Yes, S134: No) that does not include a fixed instruction. Specifically, branch prediction is performed with reference to the branch history table 14, and after execution of the conditional branch instruction, the branch history table 14 is updated based on the execution result (S136, S138, S140, S142).

図4の左部に示す従来のプログラムのように、固定指示が含まれない条件分岐命令の場合には、ステップS136〜ステップS142の処理がなされる。   In the case of a conditional branch instruction that does not include a fixed instruction as in the conventional program shown in the left part of FIG. 4, the processes in steps S136 to S142 are performed.

一方、固定指示付き分岐命令(S130:Yes、S134:Yes)に対して、命令処理部12は、固定予測を行う。具体的には、岐履歴テーブル14を参照せずに、該命令に含まれる固定指示が示す分岐予測方向に分岐予測を行い、該条件分岐命令の実行後には、実行結果に関わらず、分岐履歴テーブル14の更新をしない(S144、S146)。   On the other hand, for the branch instruction with a fixed instruction (S130: Yes, S134: Yes), the instruction processing unit 12 performs fixed prediction. Specifically, branch prediction is performed in the branch prediction direction indicated by the fixed instruction included in the instruction without referring to the branch history table 14, and after execution of the conditional branch instruction, the branch history is determined regardless of the execution result. The table 14 is not updated (S144, S146).

図7に示すプログラムの場合、命令処理部12は、ループの正常終了まで、ループを繰り返すための分岐(Taken)に分岐予測をする。そのため、ループ実行の最後の分岐(1000回目)で予測が誤るが、他の全て(999回)の分岐予測が正しい結果になる。   In the case of the program shown in FIG. 7, the instruction processing unit 12 performs branch prediction on a branch (Taken) for repeating the loop until the loop ends normally. Therefore, the prediction is incorrect at the last branch (1000th) of the loop execution, but all other (999) branch predictions are correct.

なお、条件分岐命令以外の他の命令については、分岐予測が生じず、命令処理部12は、通常のプロセッサと同様にこれらの命令のフェッチ及び実行をする(S130:No、S132)。   Note that branch instructions are not predicted for instructions other than conditional branch instructions, and the instruction processing unit 12 fetches and executes these instructions in the same manner as a normal processor (S130: No, S132).

該第2の技術は、第1の技術と同様の効果を得ることができる。
さらに、該第2の技術では、固定指示が条件分岐命令に付属されており、命令処理部12は、固定指示付き分岐命令に対してのみ固定予測を行う。そのため、第1の技術における固定解除命令を使用する必要がなく、命令数を減らすことができ、ひいては、半導体装置10の性能を高めることができる。
The second technique can obtain the same effects as the first technique.
Further, in the second technique, a fixed instruction is attached to a conditional branch instruction, and the instruction processing unit 12 performs fixed prediction only for a branch instruction with a fixed instruction. Therefore, it is not necessary to use the fixed release instruction in the first technique, the number of instructions can be reduced, and consequently the performance of the semiconductor device 10 can be improved.

<第3の技術>
上述した第1と第2の技術は、条件分岐命令が固定命令と固定解除命令の間に位置するか否か、または、条件分岐命令が固定指示付き分岐命令であるか否かに応じて固定予測と動的予測の切替えを行う。対して、第3の技術では、命令処理部12は、動作モードに応じて固定予測と動的予測の切替えを行う。なお、夫々の動作モードに対して、「固定予測」か「動的予測」の設定が可能である。また、固定予測の設定には、分岐予測方向が含まれている。
<Third technology>
The first and second techniques described above are fixed depending on whether the conditional branch instruction is positioned between the fixed instruction and the fixed release instruction or whether the conditional branch instruction is a branch instruction with a fixed instruction. Switch between prediction and dynamic prediction. On the other hand, in the third technique, the instruction processing unit 12 performs switching between fixed prediction and dynamic prediction according to the operation mode. Note that “fixed prediction” or “dynamic prediction” can be set for each operation mode. The setting of fixed prediction includes a branch prediction direction.

ここでいう「固定予測」は、分岐履歴テーブル14を参照せずに、固定予測の設定に含まれる分岐予測方向に分岐予測をすることを意味する。また、この場合、固定予測の対象となる条件分岐命令の実行後に、実行結果に関わらず、分岐履歴テーブル14の更新をしない。   Here, “fixed prediction” means that branch prediction is performed in the branch prediction direction included in the setting of fixed prediction without referring to the branch history table 14. In this case, the branch history table 14 is not updated after execution of the conditional branch instruction subject to fixed prediction regardless of the execution result.

また、「動的予測」は、分岐履歴テーブル14を参照して分岐予測をすることを意味する。この場合、動的予測の対象となる条件分岐命令の実行後に、実行結果に基づいて、分岐履歴テーブル14を更新する。   “Dynamic prediction” means that branch prediction is performed with reference to the branch history table 14. In this case, the branch history table 14 is updated based on the execution result after execution of the conditional branch instruction to be subjected to dynamic prediction.

プロセッサのCPUは、最低でも2つの動作モードを有する。この2つの動作モードは、完全に無制限のCPU動作を許可するカーネルモード(特権モードや、スーパーバイザモードともいう)と、制限付きのCPU動作しか許可しないユーザモード(スレーブモードともいう)である。   The CPU of the processor has at least two operation modes. The two operation modes are a kernel mode (also referred to as a privileged mode or a supervisor mode) that allows a completely unlimited CPU operation, and a user mode (also referred to as a slave mode) that permits only a limited CPU operation.

本第3の技術では、命令処理部12は、少なくともカーネルモードとユーザモードを含む複数の動作モードを有し、夫々の動作モードに対して、動的予測の設定、または、「分岐する」と「分岐しない」のいずれか一方を示す分岐予測方向を含む固定予測の設定が可能である。   In the third technique, the instruction processing unit 12 has a plurality of operation modes including at least a kernel mode and a user mode, and setting dynamic prediction or “branch” for each operation mode. It is possible to set fixed prediction including a branch prediction direction indicating one of “do not branch”.

命令処理部12は、動的予測の設定がされている動作モードのときに、条件分岐命令に対して、分岐履歴テーブル14に格納された履歴を参照して分岐予測をすると共に、該条件分岐命令の実行結果に基づいて分岐履歴テーブル14を更新する。   The instruction processing unit 12 performs branch prediction with reference to the history stored in the branch history table 14 for the conditional branch instruction in the operation mode in which dynamic prediction is set, and the conditional branch The branch history table 14 is updated based on the instruction execution result.

また、固定予測の設定がされている動作モードのときに、命令処理部12は、条件分岐命令に対して、分岐履歴テーブル14を参照せずに、該固定予測の設定に含まれる分岐予測方向に分岐予測をする一方、分岐履歴テーブル14の更新をしない。   In the operation mode in which the fixed prediction is set, the instruction processing unit 12 does not refer to the branch history table 14 for the conditional branch instruction, and includes the branch prediction direction included in the fixed prediction setting. While branch prediction is performed, the branch history table 14 is not updated.

図9は、命令処理部12によるプログラムの実行のフローチャートの例を示す。該例では、命令処理部12がカーネルモードとユーザモードの2つのモードを有し、片方のモード(第1のモード)に対して、動的予測の設定がなされており、他方のモード(第2のモード)に対して、固定予測の設定(分岐予測方向を含む)がなされているとする。   FIG. 9 shows an example of a flowchart of program execution by the instruction processing unit 12. In this example, the instruction processing unit 12 has two modes, a kernel mode and a user mode, and dynamic prediction is set for one mode (first mode) and the other mode (first mode). Suppose that fixed prediction (including the branch prediction direction) is set for (mode 2).

図9に示すように、命令処理部12は、第1のモードで動作しているときに、条件分岐命令に対して(S150:Yes、S152、Yes)、動的予測を行う。具体的には、分岐履歴テーブル14に格納された履歴を参照して分岐予測をすると共に、該条件分岐命令の実行後、実行結果に基づいて分岐履歴テーブル14を更新する(S156、S158、S160、S162)。   As illustrated in FIG. 9, the instruction processing unit 12 performs dynamic prediction on the conditional branch instruction (S150: Yes, S152, Yes) when operating in the first mode. Specifically, branch prediction is performed by referring to the history stored in the branch history table 14, and after execution of the conditional branch instruction, the branch history table 14 is updated based on the execution result (S156, S158, S160). , S162).

第1のモードから第2のモードへの切替えが生じない限り(S164:No)、命令処理部12は、条件分岐命令に対して、ステップS156〜ステップS162の動的予測を行う。   Unless the switching from the first mode to the second mode occurs (S164: No), the instruction processing unit 12 performs dynamic prediction in steps S156 to S162 for the conditional branch instruction.

命令処理部12は、第2のモードで動作しているときの条件分岐命令に対して(S150:No、S166、Yes)、固定予測を行う。具体的には、分岐履歴テーブル14を参照せずに、該第2のモードに対して予め設定された分岐予測方向に分岐予測を行い、該条件分岐命令の実行後には、実行結果に関わらず、分岐履歴テーブル14の更新をしない(S170、S172)。   The instruction processing unit 12 performs fixed prediction on the conditional branch instruction when operating in the second mode (S150: No, S166, Yes). Specifically, branch prediction is performed in the branch prediction direction set in advance for the second mode without referring to the branch history table 14, and after execution of the conditional branch instruction, regardless of the execution result. The branch history table 14 is not updated (S170, S172).

第2のモードから第1のモードへの切替えが生じない限り(S174:No)、命令処理部12は、条件分岐命令に対して、ステップS170〜ステップS172の固定予測を行う。   As long as the switching from the second mode to the first mode does not occur (S174: No), the instruction processing unit 12 performs the fixed prediction of Step S170 to Step S172 for the conditional branch instruction.

第1のモードから第2のモードへの切替えが生じた場合に(S164:Yes)、命令処理部12は、その後、条件分岐命令に対して固定予測を行う(S170、S172)。   When switching from the first mode to the second mode occurs (S164: Yes), the instruction processing unit 12 thereafter performs fixed prediction on the conditional branch instruction (S170, S172).

また、第2のモードから第1のモードへの切替えが生じた場合に(S174:Yes)、命令処理部12は、その後、条件分岐命令に対して動的予測を行う(S156〜S162)。   When switching from the second mode to the first mode occurs (S174: Yes), the instruction processing unit 12 thereafter performs dynamic prediction on the conditional branch instruction (S156 to S162).

なお、条件分岐命令以外の他の命令については、分岐予測が生じず、命令処理部12は、通常のプロセッサと同様にこれらの命令のフェッチ及び実行をする(S152:No、S154)(S166:No、S168)。   Note that branch prediction is not performed for instructions other than conditional branch instructions, and the instruction processing unit 12 fetches and executes these instructions in the same manner as a normal processor (S152: No, S154) (S166: No, S168).

プロセッサにおいて、CPUは、動作モードによって実行するプログラムの種類が異なる。例えば、通常、OS(Operating System)のプログラムはカーネルモードで実行され、ユーザプログラムはユーザモードで実行される。また、同種類のプログラムの命令間の関連性より、OSのプログラムとユーザプログラムのような種類の異なるプログラムの命令間の関連性が低い。   In the processor, the CPU executes different types of programs depending on the operation mode. For example, normally, an OS (Operating System) program is executed in a kernel mode, and a user program is executed in a user mode. Further, the relevance between instructions of different types of programs such as the OS program and the user program is lower than the relevance between the instructions of the same type of program.

そのため、全てのプログラムに対して、分岐予測に際して、同様の分岐履歴テーブルの参照と学習を行うのでは、関連性の低い複数のプログラムにおける条件分岐命令の実行結果の履歴が混ざり合ってしまい、分岐予測がミスする確率が高くなるという問題が生じ得る。   For this reason, if the same branch history table is referenced and learned for branch prediction for all programs, the history of execution results of conditional branch instructions in a plurality of less relevant programs will be mixed, and branch There may be a problem that the probability that a prediction is missed increases.

本第3の技術は、夫々の動作モードに対して、分岐予測の方法(動的予測か固定予測)を設定可能にし、動作モードに応じて、該動作モードに対して設定された分岐予測の方法で分岐予測を行う。そのため、動作モードに応じて異なる分岐予測の方法を設定すれば、分岐予測の視点から、固定予測に設定された動作モードで実行されるプロフラムが、動的予測に設定された動作モードで実行されるプログラムに与える影響を失くすことができ、上記問題を回避することができる。   The third technique makes it possible to set a branch prediction method (dynamic prediction or fixed prediction) for each operation mode, and the branch prediction set for the operation mode according to the operation mode. Branch prediction by the method. Therefore, if different branch prediction methods are set according to the operation mode, the program executed in the operation mode set to fixed prediction is executed in the operation mode set to dynamic prediction from the viewpoint of branch prediction. Can be lost, and the above problem can be avoided.

例えば、カーネルモードに対して固定予測の設定をし、ユーザモードに対して動的予測の設定をすることによって、OSのプログラムにおける条件分岐命令の実行結果の影響を受けないユーザプログラム環境を構築することができる。   For example, by setting fixed prediction for the kernel mode and setting dynamic prediction for the user mode, a user program environment that is not affected by the execution result of the conditional branch instruction in the OS program is constructed. be able to.

また、半導体装置10のユーザは、消費電力の抑制を優先させたい場合には、より多くの動作モードに対して固定予測を設定し、性能を優先させたい場合には、より多くの動作モードに対して動的予測を設定するような運用も可能であり、消費電力の抑制と性能の維持のバランスの調整が柔軟である。   In addition, when the user of the semiconductor device 10 wants to prioritize the suppression of power consumption, he / she sets fixed prediction for more operation modes, and when he / she wants to prioritize performance, he / she enters more operation modes. On the other hand, operation such as setting dynamic prediction is possible, and the adjustment of the balance between the suppression of power consumption and the maintenance of performance is flexible.

なお、通常、プロセッサにおいて、動作モード間の遷移が必要となったときに、コンテキストスイッチが発生する。そのため、動作モード間の切替えは、コンテキストスイッチの発生により検知可能である。本第3の技術では、命令処理部12は、例えば、動作モード間の切替えに伴って発生するコンテキストスイッチにより動作モードの切替えを検出し、コンテキストスイッチに応じて、動的予測と固定予測の切替えをすることができる。   Normally, a context switch occurs when a transition between operation modes is required in a processor. Therefore, switching between operation modes can be detected by the occurrence of a context switch. In the third technology, for example, the instruction processing unit 12 detects the switching of the operation mode by a context switch that occurs in association with the switching between the operation modes, and switches between dynamic prediction and fixed prediction according to the context switch. Can do.

<第4の技術>
上述した第1の技術は、条件分岐命令が固定命令と固定解除命令の間に位置するか否かに応じて固定予測と動的予測の切替えを行う。第2の技術は、条件分岐命令が固定指示付き分岐命令であるか否かに応じて固定予測と動的予測の切替えを行う。また、第3の技術は、動作モードに応じて固定予測と動的予測の切替えを行う。
<Fourth technology>
The first technique described above performs switching between fixed prediction and dynamic prediction depending on whether or not the conditional branch instruction is located between the fixed instruction and the fixed release instruction. In the second technique, switching between fixed prediction and dynamic prediction is performed depending on whether or not the conditional branch instruction is a branch instruction with a fixed instruction. In the third technique, switching between fixed prediction and dynamic prediction is performed according to the operation mode.

対して、本第4の技術は、プログラムの実行領域に応じて固定予測と動的予測の切替えを行う。図10に示す半導体装置20を参照して、第4の技術を説明する。   On the other hand, the fourth technique performs switching between fixed prediction and dynamic prediction according to the execution area of the program. The fourth technique will be described with reference to the semiconductor device 20 shown in FIG.

半導体装置20は、例えばパイプライン処理を実行するマイクロコンピュータであり、命令処理部22と、分岐履歴テーブル24と、メモリ26を備える。   The semiconductor device 20 is, for example, a microcomputer that executes pipeline processing, and includes an instruction processing unit 22, a branch history table 24, and a memory 26.

命令処理部22は、命令のフェッチと実行を含む処理を行い、条件分岐命令の実行に際して分岐予測を行う。   The instruction processing unit 22 performs processing including instruction fetch and execution, and performs branch prediction when executing a conditional branch instruction.

分岐履歴テーブル24は、条件分岐命令の実行の結果、分岐したか否かの履歴を格納するためのものであり、命令処理部22により更新される。   The branch history table 24 is used to store a history of whether or not a branch is made as a result of execution of a conditional branch instruction, and is updated by the instruction processing unit 22.

メモリ26は、プログラムの実行領域を成し、複数のエリア(26A、26B、26C、・・・)を含む。該複数のエリアは、固定予測の設定と動的予測の設定のいずれか一方がされている。なお、固定予測の設定には、「分岐する」と「分岐しない」のいずれか一方である分岐予測方向が含まれている。   The memory 26 forms a program execution area and includes a plurality of areas (26A, 26B, 26C,...). In the plurality of areas, either fixed prediction setting or dynamic prediction setting is set. Note that the fixed prediction setting includes a branch prediction direction that is one of “branch” and “not branch”.

図10において、例として、領域26Aは、「分岐する」(Taken)の固定予測の設定がなされた固定予測領域である。また、領域26Bは、「分岐しない」(Not−Taken)の固定予測の設定がなされた固定予測領域である。また、領域26Cは、動的予測の設定がなされた動的予測領域である。   In FIG. 10, as an example, an area 26 </ b> A is a fixed prediction area in which fixed prediction of “branch” (Taken) is set. The region 26B is a fixed prediction region in which a fixed prediction of “Do not branch” (Not-Taken) is set. The region 26C is a dynamic prediction region in which dynamic prediction is set.

図11は、命令処理部22によるプログラムの実行のフローチャートの例を示す。図示のように、命令処理部22は、動的予測の設定がされているエリアを実行領域とするプログラムの条件分岐命令に対して(S180:Yes、S184:No)、動的予測を行う。具体的には、分岐履歴テーブル24に格納された履歴を参照して分岐予測をすると共に、該条件分岐命令の実行結果に基づいて分岐履歴テーブル24を更新する(S186、S188、S190、S192)。   FIG. 11 shows an example of a flowchart of program execution by the instruction processing unit 22. As illustrated, the instruction processing unit 22 performs dynamic prediction on a conditional branch instruction of a program whose execution region is an area where dynamic prediction is set (S180: Yes, S184: No). Specifically, branch prediction is performed with reference to the history stored in the branch history table 24, and the branch history table 24 is updated based on the execution result of the conditional branch instruction (S186, S188, S190, S192). .

例えば、メモリ26の動的予測領域26Cを実行領域とするプログラム内の条件分岐命令に対して、命令処理部22は、動的予測を行う。   For example, the instruction processing unit 22 performs dynamic prediction on a conditional branch instruction in a program that uses the dynamic prediction area 26C of the memory 26 as an execution area.

一方、固定予測の設定がされているエリアを実行領域とするプログラムの条件分岐命令に対して(S180:Yes、S184:Yes)、命令処理部22は、固定予測を行う。具体的には、分岐履歴テーブル24を参照せずに、該エリアに対して設定された分岐予測方向に分岐予測をする(S194)。この場合、命令処理部22は、該条件分岐命令の実行(S196)の後に、実行結果に関わらず、分岐履歴テーブル24の更新をしない。   On the other hand, the instruction processing unit 22 performs fixed prediction on a conditional branch instruction of a program whose execution region is an area where fixed prediction is set (S180: Yes, S184: Yes). Specifically, the branch prediction is performed in the branch prediction direction set for the area without referring to the branch history table 24 (S194). In this case, the instruction processing unit 22 does not update the branch history table 24 after execution of the conditional branch instruction (S196) regardless of the execution result.

例えば、メモリ26の固定予測領域26Aを実行領域とするプログラムの条件分岐命令に対して、命令処理部22は、常に「Taken」の分岐予測を行い、分岐履歴テーブル24の更新をしない。   For example, for a conditional branch instruction of a program that uses the fixed prediction area 26 A of the memory 26 as an execution area, the instruction processing unit 22 always performs a branch prediction of “Taken” and does not update the branch history table 24.

また、メモリ26の固定予測領域26Bを実行領域とするプログラムの条件分岐命令に対して、命令処理部22は、常に「Not−Taken」の分岐予測を行い、分岐履歴テーブル24の更新をしない。   In addition, the instruction processing unit 22 always performs “Not-Take” branch prediction for a conditional branch instruction of a program that uses the fixed prediction area 26 B of the memory 26 as an execution area, and does not update the branch history table 24.

なお、条件分岐命令以外の他の命令については、分岐予測が生じず、命令処理部22は、通常のプロセッサと同様にこれらの命令のフェッチ及び実行をする(S180:No、S182)。   Note that branch instructions are not predicted for instructions other than conditional branch instructions, and the instruction processing unit 22 fetches and executes these instructions in the same manner as a normal processor (S180: No, S182).

本第4の技術は、プログラムの実行領域として、異なる分岐予測の方法が設定された複数のエリアを有するメモリ26を提供すると共に、プログラムの実行領域となるエリアに応じて分岐予測の方法を切り替える。そのため、ユーザは、プログラムに含まれる条件分岐命令の多少や、条件分岐命令が分岐する場合と分岐しない場合の多少や、消費電力を優先させたいか性能を優先させたいかなどに応じて、プログラムが実行されるエリアを設定することにより、最適な分岐予測の方法を選択することができる。   The fourth technique provides a memory 26 having a plurality of areas in which different branch prediction methods are set as program execution areas, and switches the branch prediction method according to the area to be the program execution area. . Therefore, the user can program depending on the number of conditional branch instructions included in the program, the number of cases where the conditional branch instruction branches and does not branch, whether you want to prioritize power consumption or performance, etc. By setting an area in which is executed, an optimal branch prediction method can be selected.

勿論、第3の技術のときに説明した、関連性の低い複数のプログラムにおける条件分岐命令の実行結果の履歴が混ざり合ってしまい、分岐予測がミスする確率が高くなるという問題を回避するためにも、本第4の技術が有効である。この場合、例えば、関連性が高いプログラムに対しては実行領域を同様の設定(動的予測または固定予測)がされたエリアに指定し、関連性の低い複数のプログラムに対しては実行領域を異なる設定がされたエリアに指定すればよい。
勿論、メモリ26の各エリアの設定は、ユーザにより変更可能にしてもよい。
Of course, in order to avoid the problem described in the third technique, the history of execution results of conditional branch instructions in a plurality of less relevant programs is mixed, and the probability that a branch prediction is missed increases. However, the fourth technique is effective. In this case, for example, an execution region is designated as an area having the same setting (dynamic prediction or fixed prediction) for a highly relevant program, and an execution region is designated for a plurality of less relevant programs. It is only necessary to designate areas with different settings.
Of course, the setting of each area of the memory 26 may be changed by the user.

以上の各技術を踏まえて、実施の形態を説明する。
<第1の実施の形態>
図12は、第1の実施の形態にかかる半導体装置110を示す。半導体装置110は、単一の半導体チップにより構成されるマイクロコンピュータを有する。半導体装置110は例えば、この半導体チップと電気的に接続される外部端子を有し、半導体チップを内部に樹脂で封止して外部端子を露出される半導体パッケージの形態をなす。半導体装置110には外部デバイス120が接続される。外部デバイス120として種々の記憶装置が例示されている。この半導体装置110及び外部デバイス120により携帯電話を含むデジタル情報端末、またはデジタル家電などの電子機器100が構成される。なお以下において半導体装置110は、「マイクロコンピュータ110」とも称する。
The embodiment will be described based on the above technologies.
<First Embodiment>
FIG. 12 shows the semiconductor device 110 according to the first embodiment. The semiconductor device 110 has a microcomputer constituted by a single semiconductor chip. For example, the semiconductor device 110 has an external terminal electrically connected to the semiconductor chip, and takes the form of a semiconductor package in which the semiconductor chip is sealed with a resin and the external terminal is exposed. An external device 120 is connected to the semiconductor device 110. Various storage devices are illustrated as the external device 120. The semiconductor device 110 and the external device 120 constitute a digital information terminal including a mobile phone or an electronic device 100 such as a digital home appliance. Hereinafter, the semiconductor device 110 is also referred to as a “microcomputer 110”.

外部デバイス120は、不揮発性メモリと揮発性メモリが含まれている。図12において、揮発性メモリとしてDDR型DRAM(Double Data Rate型Dynamic Random Access Memory。以下「DDRメモリ」と称す)121とSRAM(Static Random Access Memory)122を例示しており、不揮発性メモリとしてフラッシュメモリ123を例示している。   The external device 120 includes a nonvolatile memory and a volatile memory. 12 exemplifies a DDR type DRAM (Double Data Rate Type Dynamic Random Access Memory, hereinafter referred to as “DDR memory”) 121 and an SRAM (Static Random Access Memory) 122 as a volatile memory, and flashes as a non-volatile memory. The memory 123 is illustrated.

フラッシュメモリ123は、ブートプログラムと、OSのプログラムと、ユーザプログラムが格納されている。電子機器100の起動時又はリセット時に、フラッシュメモリ123からブートプログラムがSRAM122にロードされ、マイクロコンピュータ110のCPU111により実行される。その後、ブートプログラムの実行に伴って、OSのプログラムの一部もSRAM122にロードされ、CPU111により実行される。また、ユーザプログラムも、実行に際してSRAM122にロードされる。   The flash memory 123 stores a boot program, an OS program, and a user program. When the electronic device 100 is activated or reset, a boot program is loaded from the flash memory 123 into the SRAM 122 and executed by the CPU 111 of the microcomputer 110. Thereafter, along with the execution of the boot program, a part of the OS program is also loaded into the SRAM 122 and executed by the CPU 111. The user program is also loaded into the SRAM 122 when executed.

すなわち、SRAM122は、プログラムの実行領域を構成する。フラッシュメモリ123に格納された各プログラムは、実行に際してSRAM122にロードされる。   That is, the SRAM 122 constitutes a program execution area. Each program stored in the flash memory 123 is loaded into the SRAM 122 upon execution.

DDRメモリ121は、SRAMより高速アクセスが可能なメモリであり、SRAMと同様にOS、ユーザプログラムの実行領域として使用される。   The DDR memory 121 is a memory that can be accessed at a higher speed than the SRAM, and is used as an execution area for the OS and the user program in the same manner as the SRAM.

なお半導体装置(マイクロコンピュータ)110が外部デバイス120の一部又は全部を有する構成でもよい。例えばSRAM122及びフラッシュメモリ123の一方又は双方がマイクロコンピュータと同じ半導体基板上に設けられても良いし、同一半導体パッケージ内のマイクロコンピュータと異なる半導体基板上に設けられてもよい。   The semiconductor device (microcomputer) 110 may have a part or all of the external device 120. For example, one or both of the SRAM 122 and the flash memory 123 may be provided on the same semiconductor substrate as the microcomputer, or may be provided on a semiconductor substrate different from the microcomputer in the same semiconductor package.

またDDRメモリ121も同様に、マイクロコンピュータと同じ半導体基板上に設けられても良いし、同一半導体パッケージ内のマイクロコンピュータと異なる半導体基板上に設けられてもよい。   Similarly, the DDR memory 121 may be provided on the same semiconductor substrate as the microcomputer, or may be provided on a semiconductor substrate different from the microcomputer in the same semiconductor package.

マイクロコンピュータ110は、中央演算処理装置としてのCPU111、DMA(Direct Memory Access)転送を行うDMAコントローラ112、バス119、時間を計測するタイムユニット114、シリアル通信デバイス(図示せず)と接続するためのシリアル通信インタフェース115、タイムユニット114及びシリアル通信インタフェース115のバス119とのデータの受渡しを制御する周辺バスコントローラ113、DDRメモリ121へのアクセスを制御するDDRコントローラ116、SRAM122とフラッシュメモリ123へのアクセスを制御するローカルバスコントローラ117、クロックを供給するクロック発信器(CPG)118を有する。   The microcomputer 110 is connected to a CPU 111 as a central processing unit, a DMA controller 112 that performs DMA (Direct Memory Access) transfer, a bus 119, a time unit 114 that measures time, and a serial communication device (not shown). Serial communication interface 115, time unit 114, peripheral bus controller 113 that controls data transfer with bus 119 of serial communication interface 115, DDR controller 116 that controls access to DDR memory 121, access to SRAM 122 and flash memory 123 A local bus controller 117 for controlling the clock and a clock generator (CPG) 118 for supplying a clock.

CPU111、DMAコントローラ112、周辺バスコントローラ113、DDRコントローラ116、ローカルバスコントローラ117は、バス119に接続されている。   The CPU 111, DMA controller 112, peripheral bus controller 113, DDR controller 116, and local bus controller 117 are connected to the bus 119.

なお、マイクロコンピュータ110において、DMAコントローラ112、周辺バスコントローラ113、タイムユニット114、シリアル通信インタフェース115、DDRコントローラ116、ローカルバスコントローラ117、クロック発信器118は、この種の半導体装置に備えられるものと同様であり、ここでは詳細な説明を省略する。   In the microcomputer 110, the DMA controller 112, the peripheral bus controller 113, the time unit 114, the serial communication interface 115, the DDR controller 116, the local bus controller 117, and the clock generator 118 are provided in this type of semiconductor device. This is the same, and detailed description is omitted here.

図13は、CPU111を詳細に示す図である。CPU111は、パイプライン処理により命令を実行し、命令フェッチ制御部140、予測結果判定部142、分岐履歴テーブル144、投機命令実行制御部146、命令キャッシュ148、プリデコーダ150、命令キュー152、命令デコーダ154、命令実行部156、汎用レジスタ158を有する。   FIG. 13 is a diagram showing the CPU 111 in detail. The CPU 111 executes an instruction by pipeline processing, and an instruction fetch control unit 140, a prediction result determination unit 142, a branch history table 144, a speculative instruction execution control unit 146, an instruction cache 148, a predecoder 150, an instruction queue 152, an instruction decoder 154, an instruction execution unit 156, and a general-purpose register 158.

CPU111において、分岐履歴テーブル144を除いた他の機能ブロックは、命令処理部を構成し、命令のフェッチと実行を含む処理を行い、条件分岐命令の実行に際して分岐予測を行う。   In the CPU 111, other functional blocks excluding the branch history table 144 constitute an instruction processing unit, perform processing including instruction fetch and execution, and perform branch prediction when executing a conditional branch instruction.

分岐履歴テーブル144は、条件分岐命令の実行の結果、分岐したか否かの履歴を格納するためのものである。分岐履歴テーブル144は、命令フェッチ制御部140と投機命令実行制御部146により参照可能であり、更新は、命令フェッチ制御部140によりなされる。   The branch history table 144 is used to store a history of whether or not a branch has occurred as a result of execution of a conditional branch instruction. The branch history table 144 can be referred to by the instruction fetch control unit 140 and the speculative instruction execution control unit 146, and is updated by the instruction fetch control unit 140.

命令フェッチ制御部140は、バス119を介してローカルバスコントローラ117、DDRコントローラ116に接続されており、SRAM122、DDRメモリ121または命令キャッシュ148から命令をフェッチして、命令コードを、プリデコーダ150と、命令キュー152および命令デコーダ154に転送する。   The instruction fetch control unit 140 is connected to the local bus controller 117 and the DDR controller 116 via the bus 119, fetches an instruction from the SRAM 122, the DDR memory 121, or the instruction cache 148, and sends an instruction code to the predecoder 150. , Transfer to instruction queue 152 and instruction decoder 154.

プリデコーダ150は、条件分岐命令をデコード(プリデコード)して、結果を命令キュー152、および命令フェッチ制御部140に転送する。   The predecoder 150 decodes (predecodes) the conditional branch instruction and transfers the result to the instruction queue 152 and the instruction fetch control unit 140.

命令デコーダ154は、命令キュー152、命令キャッシュ148からの命令をデコードして命令実行部156に出力する。   The instruction decoder 154 decodes instructions from the instruction queue 152 and the instruction cache 148 and outputs them to the instruction execution unit 156.

命令実行部156は、命令デコーダ154からの命令を実行する。命令の実行に伴って、必要に応じて汎用レジスタ158からの読出しまたは書込みを行う。   The instruction execution unit 156 executes the instruction from the instruction decoder 154. As the instruction is executed, reading from or writing to the general-purpose register 158 is performed as necessary.

命令フェッチ制御部140は、プリデコーダ150によるプリデコードの結果に基づいて、下記のように次の命令をフェッチする。   The instruction fetch control unit 140 fetches the next instruction based on the result of predecoding by the predecoder 150 as described below.

無条件分岐命令に対して、命令フェッチ制御部140は、プリデコーダ150によるプリデコードの結果から分岐先を取得し、該分岐先の命令をフェッチする。   For an unconditional branch instruction, the instruction fetch control unit 140 acquires a branch destination from the result of predecoding by the predecoder 150 and fetches the branch destination instruction.

条件分岐命令に対して、命令フェッチ制御部140は、まず、分岐予測を行う。分岐予測の結果が「分岐する」(Taken)である場合に、命令フェッチ制御部140は、プリデコーダ150によるプリデコードの結果から分岐先を取得し、該分岐先の命令をフェッチする。   For a conditional branch instruction, the instruction fetch control unit 140 first performs branch prediction. When the result of branch prediction is “branch” (Taken), the instruction fetch control unit 140 acquires a branch destination from the result of predecoding by the predecoder 150 and fetches the instruction at the branch destination.

一方、分岐予測の結果が「分岐しない」(Not−Taken)である場合には、命令フェッチ制御部140は、該条件分岐命令のアドレスの次のアドレスから命令をフェッチする。   On the other hand, when the result of the branch prediction is “do not branch” (Not-Taken), the instruction fetch control unit 140 fetches an instruction from the address next to the address of the conditional branch instruction.

投機命令実行制御部146は、命令フェッチ制御部140による分岐予測と協働して制御投機を行うものである。具体的には、条件分岐命令に対して命令フェッチ制御部140が分岐予測の結果に基づいてフェッチした命令をパイプラインに投入し、実行を開始させる。そして、分岐予測が正しい場合には、そのまま実行を継続させる。一方、分岐予測が誤った場合には、分岐予測の結果に基づいてパイプラインに投入した命令を無効化する。この場合、命令フェッチ制御部140は、分岐予測した方向とは反対の方向の命令をフェッチする。   The speculative instruction execution control unit 146 performs control speculation in cooperation with branch prediction by the instruction fetch control unit 140. Specifically, for the conditional branch instruction, the instruction fetched by the instruction fetch control unit 140 based on the result of the branch prediction is input to the pipeline to start execution. If the branch prediction is correct, the execution is continued as it is. On the other hand, if the branch prediction is incorrect, the instruction input to the pipeline is invalidated based on the branch prediction result. In this case, the instruction fetch control unit 140 fetches an instruction in a direction opposite to the branch predicted direction.

分岐予測の結果が正しいか否かの判断は、予測結果判定部142によりなされる。命令フェッチ制御部140は、予測結果判定部142による判定の結果に応じて、分岐予測した方向と反対の方向の命令をフェッチするか否かを決定する。   The prediction result determination unit 142 determines whether the branch prediction result is correct. The instruction fetch control unit 140 determines whether to fetch an instruction in the direction opposite to the branch predicted direction according to the determination result by the prediction result determination unit 142.

以上に説明したCPU111による処理の流れは、命令フェッチ制御部140による分岐予測の手法を除き、分岐予測を行う通常のプロセッサによる処理と同様であるため、さらなる詳細な説明を省略する。   Since the processing flow by the CPU 111 described above is the same as the processing by a normal processor that performs branch prediction, except for the branch prediction method by the instruction fetch control unit 140, further detailed description is omitted.

ここで、命令フェッチ制御部140による分岐予測の手法を説明する。
命令フェッチ制御部140は、前述した第1の技術により分岐予測を行う。すなわち、命令フェッチ制御部140は、上述した固定命令及び固定解除命令に対応する。
Here, a method of branch prediction by the instruction fetch control unit 140 will be described.
The instruction fetch control unit 140 performs branch prediction using the first technique described above. That is, the instruction fetch control unit 140 corresponds to the above-described fixed instruction and fixed release instruction.

そして、固定命令と固定解除命令の間の条件分岐命令に対しては、命令フェッチ制御部140は、固定予測として、分岐履歴テーブル144を参照せずに、上記固定命令が指示する分岐予測方向に分岐予測を行う。また、この場合において、分岐予測が正しいか否かに関わらず、命令フェッチ制御部140は、分岐履歴テーブル144の更新をしない。   For a conditional branch instruction between a fixed instruction and a fixed release instruction, the instruction fetch control unit 140 does not refer to the branch history table 144 as a fixed prediction, but in the branch prediction direction indicated by the fixed instruction. Perform branch prediction. In this case, the instruction fetch control unit 140 does not update the branch history table 144 regardless of whether or not the branch prediction is correct.

また、それ以外の条件分岐命令に対しては、命令フェッチ制御部140は、動的分岐予測として、分岐履歴テーブル144を参照して分岐予測を行うと共に、該条件分岐命令の投機実行に対して予測結果判定部142が判断した結果に基づいて分岐履歴テーブル144を更新する。   For other conditional branch instructions, the instruction fetch control unit 140 performs branch prediction by referring to the branch history table 144 as dynamic branch prediction, and for speculative execution of the conditional branch instruction. The branch history table 144 is updated based on the result determined by the prediction result determination unit 142.

命令フェッチ制御部140によるこのような分岐予測は、第1の技術に基づいたものである。そのため、該第1の実施の形態にかかる半導体装置110は、第1の技術について述べた全ての効果を得ることができる。   Such branch prediction by the instruction fetch control unit 140 is based on the first technique. Therefore, the semiconductor device 110 according to the first embodiment can obtain all the effects described for the first technique.

<第2の実施の形態>
第2の実施の形態も、半導体装置である。該半導体装置は、分岐予測の方法において第1の実施の形態の半導体装置110と異なる点を除き、半導体装置110と同様であるため、第2の実施の形態については、分岐予測の方法についてのみ説明する。また、簡潔のために、第2の実施の形態の半導体装置の図示を省略し、半導体装置110の機能ブロックを用いて説明する。
<Second Embodiment>
The second embodiment is also a semiconductor device. The semiconductor device is the same as the semiconductor device 110 except for the difference in the branch prediction method from the semiconductor device 110 of the first embodiment. Therefore, in the second embodiment, only the branch prediction method is used. explain. Further, for the sake of brevity, the semiconductor device of the second embodiment is not illustrated and will be described using functional blocks of the semiconductor device 110.

第2の実施の形態の半導体装置において、命令フェッチ制御部140は、前述した第2の技術により分岐予測を行う。すなわち、命令フェッチ制御部140は、前述した固定指示が含まれる条件分岐命令(固定指示付き分岐命令)に対応する。   In the semiconductor device of the second embodiment, the instruction fetch control unit 140 performs branch prediction using the second technique described above. That is, the instruction fetch control unit 140 corresponds to a conditional branch instruction (a branch instruction with a fixed instruction) including the above-described fixed instruction.

そして、固定指示付き分岐命令に対しては、命令フェッチ制御部140は、固定予測として、分岐履歴テーブル144を参照せずに、該固定指示付き分岐命令に含まれる固定指示が示す分岐予測方向に分岐予測を行う。また、この場合において、分岐予測が正しいか否かに関わらず、命令フェッチ制御部140は、分岐履歴テーブル144の更新をしない。   Then, for a branch instruction with a fixed instruction, the instruction fetch control unit 140 does not refer to the branch history table 144 as fixed prediction, but in the branch prediction direction indicated by the fixed instruction included in the branch instruction with the fixed instruction. Perform branch prediction. In this case, the instruction fetch control unit 140 does not update the branch history table 144 regardless of whether or not the branch prediction is correct.

また、固定指示が含まれない条件分岐命令に対しては、命令フェッチ制御部140は、動的分岐予測として、分岐履歴テーブル144を参照して分岐予測を行うと共に、該条件分岐命令の投機実行に対して予測結果判定部142が判断した結果に基づいて分岐履歴テーブル144を更新する。   For a conditional branch instruction that does not include a fixed instruction, the instruction fetch control unit 140 performs branch prediction with reference to the branch history table 144 as dynamic branch prediction and speculative execution of the conditional branch instruction. The branch history table 144 is updated based on the result determined by the prediction result determination unit 142.

このような分岐予測は、第2の技術に基づいたものである。そのため、該第2の実施の形態にかかる半導体装置は、第2の技術について述べた全ての効果を得ることができる。   Such branch prediction is based on the second technique. Therefore, the semiconductor device according to the second embodiment can obtain all the effects described for the second technique.

<第3の実施の形態>
本第3の実施の形態も、半導体装置である。該半導体装置は、CPU111の代わりに、図14に示すCPU200が設けられた点を除き、図12に示す半導体装置110と同様である。ここで、CPU200についてのみ説明する。また、CPU200についても、CPU111と異なる点のみを説明する。
<Third Embodiment>
The third embodiment is also a semiconductor device. The semiconductor device is the same as the semiconductor device 110 shown in FIG. 12 except that a CPU 200 shown in FIG. 14 is provided instead of the CPU 111. Here, only the CPU 200 will be described. Also, the CPU 200 will be described only with respect to differences from the CPU 111.

図14に示すように、CPU200は、命令フェッチ制御部140の代わりに命令フェッチ制御部240が設けられていると共に、ステータスレジスタ210を有する点を除き、半導体装置110におけるCPU111と同様である。   As shown in FIG. 14, the CPU 200 is the same as the CPU 111 in the semiconductor device 110 except that an instruction fetch control unit 240 is provided instead of the instruction fetch control unit 140 and a status register 210 is provided.

ステータスレジスタ210は、複数ビットを有し、CPU200の動作モードや使用するレジスタバンクなどを示す情報を格納している。   The status register 210 has a plurality of bits and stores information indicating an operation mode of the CPU 200, a register bank to be used, and the like.

本実施の形態において、CPU200は、カーネルモードとユーザモードの2つの動作モードを有する。CPU200の現在の動作モードは、ステータスレジスタ210の1ビット(以下「動作モードビット」という)により示される。また、動作モードの切替え時に、コンテキストスイッチの発生に伴って、動作モードビットの値が変更される。   In the present embodiment, the CPU 200 has two operation modes, a kernel mode and a user mode. The current operation mode of the CPU 200 is indicated by one bit of the status register 210 (hereinafter referred to as “operation mode bit”). In addition, when the operation mode is switched, the value of the operation mode bit is changed with the occurrence of the context switch.

CPU200において、命令フェッチ制御部240は、分岐予測の方法に関して、第1と第2の実施の形態の半導体装置におけるCPU111と異なる。   In the CPU 200, the instruction fetch control unit 240 is different from the CPU 111 in the semiconductor devices of the first and second embodiments with respect to the branch prediction method.

CPU200は、前述した第3の技術が適用されている。具体的には、CPU200の2つの動作モードのうちカーネルモードに対しては固定予測の設定がされており、ユーザモードに対しては動的予測の設定がさている。これらの設定は、例えば、ステータスレジスタ210や、または図示しない別のレジスタに格納されており、起動時にブートプログラムの実行により書き込まれている。また、固定予測の設定には、「分岐する」と「分岐しない」のいずれかの分岐予測方向も含まれている。なお、例として、カーネルモードに対して設定された固定予測に含まれる分岐予測方向が、「分岐しない」であるとする。   The above-described third technique is applied to the CPU 200. Specifically, of the two operation modes of the CPU 200, fixed prediction is set for the kernel mode, and dynamic prediction is set for the user mode. These settings are stored in, for example, the status register 210 or another register (not shown), and are written by executing the boot program at the time of startup. In addition, the setting of the fixed prediction includes a branch prediction direction of “branch” or “not branch”. As an example, it is assumed that the branch prediction direction included in the fixed prediction set for the kernel mode is “no branch”.

命令フェッチ制御部240は、条件分岐命令に対して、CPU200の現在の動作モードに対して設定された予測方法に従って分岐予測をする。具体的には、CPU200の現在の動作モードが、固定予測(分岐予測方向:分岐しない)が設定されたカーネルモードであるときに、命令フェッチ制御部240は、条件分岐命令に対して、分岐履歴テーブル144を参照せずに、常に「分岐しない」予測を行う。また、この場合において、分岐予測が正しいか否かに関わらず、命令フェッチ制御部140は、分岐履歴テーブル144の更新をしない。   The instruction fetch control unit 240 performs branch prediction on the conditional branch instruction according to the prediction method set for the current operation mode of the CPU 200. Specifically, when the current operation mode of the CPU 200 is a kernel mode in which fixed prediction (branch prediction direction: no branch) is set, the instruction fetch control unit 240 performs branch history for a conditional branch instruction. Without referring to the table 144, the prediction that “does not branch” is always performed. In this case, the instruction fetch control unit 140 does not update the branch history table 144 regardless of whether or not the branch prediction is correct.

一方、CPU200の現在の動作モードが、動的予測が設定されたユーザモードであるときには、命令フェッチ制御部240は、条件分岐命令に対して、分岐履歴テーブル144を参照して分岐予測を行うと共に、該条件分岐命令の投機実行に対して予測結果判定部142が判断した結果に基づいて分岐履歴テーブル144を更新する。   On the other hand, when the current operation mode of the CPU 200 is the user mode in which dynamic prediction is set, the instruction fetch control unit 240 performs branch prediction with respect to the conditional branch instruction by referring to the branch history table 144. The branch history table 144 is updated based on the result of the prediction result determination unit 142 determining the speculative execution of the conditional branch instruction.

このような分岐予測は、第3の技術に基づいたものである。そのため、該第3の実施の形態にかかる半導体装置は、第3の技術について述べた全ての効果を得ることができる。   Such branch prediction is based on the third technique. Therefore, the semiconductor device according to the third embodiment can obtain all the effects described for the third technique.

<第4の実施の形態>
本第4の実施の形態も、半導体装置である。該半導体装置は、CPU111の代わりに、図15に示すCPU300が設けられた点を除き、図12に示す半導体装置110と同様である。ここで、CPU300についてのみ説明する。また、CPU300についても、CPU111と異なる点のみを説明する。
<Fourth embodiment>
The fourth embodiment is also a semiconductor device. The semiconductor device is the same as the semiconductor device 110 shown in FIG. 12 except that a CPU 300 shown in FIG. 15 is provided instead of the CPU 111. Here, only the CPU 300 will be described. Also, only the CPU 300 will be described, which is different from the CPU 111.

図15に示すように、CPU300は、命令フェッチ制御部140の代わりに命令フェッチ制御部340が設けられていると共に、領域設定レジスタ310を有する点を除き、半導体装置110におけるCPU111と同様である。   As shown in FIG. 15, the CPU 300 is the same as the CPU 111 in the semiconductor device 110 except that an instruction fetch control unit 340 is provided instead of the instruction fetch control unit 140 and an area setting register 310 is provided.

領域設定レジスタ310は、複数組(図示の例では2組)の設定が格納されている。各組の設定は、プログラム実行領域における上限アドレス、下限アドレス、分岐予測方向の3つの情報から構成される。これらの設定は、起動時にブートプログラムの実行により書き込まれている。   The area setting register 310 stores a plurality of sets (two sets in the illustrated example). Each set of settings consists of three pieces of information: an upper limit address, a lower limit address, and a branch prediction direction in the program execution area. These settings are written by executing the boot program at startup.

例えば、組(1)の設定は、プログラム実行領域における上限アドレス「20000000」、下限アドレス「40000000」、「Taken」の分岐予測方向の3つの情報が含まれている。また、組(2)の設定は、プログラム実行領域における上限アドレス「80000000」、下限アドレス「A0000000」、「Not−Taken」の分岐予測方向の3つの情報が含まれている。   For example, the setting of the group (1) includes three pieces of information on the branch prediction directions of the upper limit address “20000000”, the lower limit address “40000000”, and “Taken” in the program execution area. In addition, the setting of the set (2) includes three pieces of information on the branch prediction directions of the upper limit address “80000000”, the lower limit address “A0000000”, and “Not-Taken” in the program execution area.

CPU300において、命令フェッチ制御部340は、分岐予測の方法に関して、第1〜第3の実施の形態の半導体装置におけるCPUと異なる。   In the CPU 300, the instruction fetch control unit 340 is different from the CPU in the semiconductor device of the first to third embodiments with respect to the branch prediction method.

CPU300は、前述した第4の技術が適用されている。具体的には、CPU300の命令フェッチ制御部340は、領域設定レジスタ310の各組の設定に基づいて、該組の設定に含まれる上限アドレスから下限アドレスまでのSRAM122のエリアを「固定予測領域」と看做し、領域設定レジスタ310内に設定されていないエリアを「動的予測領域」と看做す。   As for CPU300, the 4th technique mentioned above is applied. Specifically, the instruction fetch control unit 340 of the CPU 300 determines the area of the SRAM 122 from the upper limit address to the lower limit address included in the setting of the group based on the setting of each group of the area setting register 310 as a “fixed prediction area”. An area that is not set in the area setting register 310 is regarded as a “dynamic prediction area”.

図16は、領域設定レジスタ310に格納された設定の例と、SRAM122のエリアとの対応関係を示す。   FIG. 16 shows a correspondence relationship between the setting example stored in the area setting register 310 and the area of the SRAM 122.

例えば、組(1)に、上限アドレス、下限アドレス、分岐予測方向として、「20000000」、「40000000」、「Taken」が設定されているため、SRAM122における「20000000」〜「40000000」のエリアは、「Taken」の固定予測が設定された固定予測領域に看做される。   For example, since “20000000”, “40000000”, and “Taken” are set as the upper limit address, the lower limit address, and the branch prediction direction in the group (1), the areas “20000000” to “40000000” in the SRAM 122 are The fixed prediction area of “Taken” is regarded as the fixed prediction area.

また、組(2)に、上限アドレス、下限アドレス、分岐予測方向として、「80000000」、「A0000000」、「Not−Taken」が設定されているため、プログラム実行領域における「80000000」〜「A0000000」のエリアは、「Not−Taken」の固定予測が設定された固定予測領域に看做される。   Further, since “80000000”, “A0000000”, and “Not-Taken” are set as the upper limit address, the lower limit address, and the branch prediction direction in the group (2), “80000000” to “A0000000” in the program execution area. This area is regarded as a fixed prediction area in which a fixed prediction of “Not-Taken” is set.

SRAM122の他のエリアについては、領域設定レジスタ310において設定が無いため、動的予測が設定された動的予測領域に看做される。   Since other areas of the SRAM 122 are not set in the area setting register 310, they are regarded as dynamic prediction areas in which dynamic prediction is set.

そして、条件分岐命令に対して分岐予測を行う際に、命令フェッチ制御部340は、該条件分岐命令が含まれるプログラムの実行領域に基づいて分岐予測を行う。   When performing branch prediction on a conditional branch instruction, the instruction fetch control unit 340 performs branch prediction based on an execution area of a program including the conditional branch instruction.

具体的には、動的予測エリアと看做すエリアを実行領域とするプログラムの条件分岐命令に対して、命令フェッチ制御部340は、動的予測を行う。つまり、分岐履歴テーブル144を参照して分岐予測を行う共に、該条件分岐命令の投機実行に対して予測結果判定部142が判断した結果に基づいて分岐履歴テーブル144を更新する。   Specifically, the instruction fetch control unit 340 performs dynamic prediction on a conditional branch instruction of a program whose execution area is an area regarded as a dynamic prediction area. That is, branch prediction is performed with reference to the branch history table 144, and the branch history table 144 is updated based on a result determined by the prediction result determination unit 142 for speculative execution of the conditional branch instruction.

例えば、図16に示す例の場合、「00000000」〜「20000000」、「40000000」〜「80000000」、「A0000000」〜「FFFFFFFF」の各エリアを実行領域とするプログラムの条件分岐命令に対して、動的予測を行う。   For example, in the case of the example shown in FIG. 16, with respect to a conditional branch instruction of a program having each area of “00000000” to “20000000”, “40000000” to “80000000”, and “A0000000” to “FFFFFFFF” as an execution area, Perform dynamic prediction.

一方、固定予測と看做すエリアを実行領域とするプログラムの条件分岐命令に対して、命令フェッチ制御部340は、固定予測を行う。つまり、分岐履歴テーブル144を参照せずに、該エリアに対して設定された分岐予測方向に分岐予測を行う。また、該条件分岐命令の投機実行に対して予測結果判定部142が判断した結果に関わらず、分岐履歴テーブル144を更新しない。   On the other hand, the instruction fetch control unit 340 performs fixed prediction on a conditional branch instruction of a program whose execution area is an area regarded as fixed prediction. That is, branch prediction is performed in the branch prediction direction set for the area without referring to the branch history table 144. Further, the branch history table 144 is not updated regardless of the result of the prediction result determination unit 142 determining the speculative execution of the conditional branch instruction.

例えば、図16に示す例の場合、「20000000」〜「40000000」のエリアを実行領域とするプログラムの条件分岐命令に対して、「Taken」の固定予測を行い、「80000000」〜「A0000000」のエリアを実行領域とするプログラムの条件分岐命令に対して、「Not−Taken」の固定予測を行う。   For example, in the case of the example shown in FIG. 16, “Taken” is fixedly predicted for a conditional branch instruction of a program having an area “20000000” to “40000000” as an execution region, and “80000000” to “A0000000” For a conditional branch instruction of a program whose area is an execution area, a fixed prediction of “Not-Taken” is performed.

このような分岐予測は、第4の技術に基づいたものである。そのため、該第4の実施の形態にかかる半導体装置は、第4の技術について述べた全ての効果を得ることができる。   Such branch prediction is based on the fourth technique. Therefore, the semiconductor device according to the fourth embodiment can obtain all the effects described for the fourth technique.

以上、本発明者によってなされた発明を実施の形態に基づき具体的に説明したが、本発明は既に述べた実施の形態に限定されるものではなく、その要旨を逸脱しない範囲において種々の変更が可能であることはいうまでもない。   As mentioned above, the invention made by the present inventor has been specifically described based on the embodiments. However, the present invention is not limited to the embodiments already described, and various modifications can be made without departing from the scope of the invention. It goes without saying that it is possible.

10 半導体装置
12 命令処理部
14 分岐履歴テーブル
20 半導体装置
22 命令処理部
24 分岐履歴テーブル
26 メモリ
26A 固定予測領域
26B 固定予測領域
26C 動的予測領域
100 電子機器
110 半導体装置(マイクロコンピュータ)
111 CPU
112 DMAコントローラ
113 周辺バスコントローラ
114 タイムユニット
115 シリアル通信インタフェース
116 DDRコントローラ
117 ローカルバスコントローラ
118 クロック発信器
119 バス
120 外部デバイス
121 DDRメモリ
122 SRAM
123 フラッシュメモリ
140 命令フェッチ制御部
142 予測結果判定部
144 分岐履歴テーブル
146 投機命令実行制御部
148 命令キャッシュ
150 プリデコーダ
152 命令キュー
154 命令デコーダ
156 命令実行部
158 汎用レジスタ
200 CPU
210 ステータスレジスタ
240 命令フェッチ制御部
300 CPU
310 領域設定レジスタ
340 命令フェッチ制御部
DESCRIPTION OF SYMBOLS 10 Semiconductor device 12 Instruction processing part 14 Branch history table 20 Semiconductor device 22 Instruction processing part 24 Branch history table 26 Memory 26A Fixed prediction area 26B Fixed prediction area 26C Dynamic prediction area 100 Electronic device 110 Semiconductor device (microcomputer)
111 CPU
112 DMA controller 113 Peripheral bus controller 114 Time unit 115 Serial communication interface 116 DDR controller 117 Local bus controller 118 Clock generator 119 Bus 120 External device 121 DDR memory 122 SRAM
123 Flash memory 140 Instruction fetch control unit 142 Prediction result determination unit 144 Branch history table 146 Speculative instruction execution control unit 148 Instruction cache 150 Predecoder 152 Instruction queue 154 Instruction decoder 156 Instruction execution unit 158 General-purpose register 200 CPU
210 Status register 240 Instruction fetch control unit 300 CPU
310 Area setting register 340 Instruction fetch control unit

Claims (9)

命令のフェッチと実行を含む処理を行い、条件分岐命令の実行に際して分岐予測を行う命令処理部と、
条件分岐命令の実行の結果、分岐したか否かの履歴を格納するためのものであり、前記命令処理部により更新される分岐履歴テーブルとを備え、
前記命令処理部は、
「分岐する」と「分岐しない」のいずれか一方を示す分岐予測方向に固定することを指示する固定命令と、前記固定命令と対を成し、該固定命令が指示する前記分岐予測方向の固定を解除する固定解除命令とを実行することを可能とし、
条件分岐命令に対して、前記分岐履歴テーブルに格納された前記履歴を参照して分岐予測を行う動的分岐を行い、
前記固定命令を実行した後では、条件分岐命令に対して、前記分岐履歴テーブルを参照せずに、前記固定命令が指示する分岐予測方向に分岐予測をする固定予測を行う、
半導体装置。
An instruction processing unit that performs processing including instruction fetch and execution, and performs branch prediction when executing a conditional branch instruction;
As a result of execution of a conditional branch instruction, for storing a history of whether or not a branch, comprising a branch history table updated by the instruction processing unit,
The instruction processing unit
A fixed instruction instructing to fix in a branch prediction direction indicating either “branch” or “not branch” and the fixed instruction are paired with the fixed instruction instructed by the fixed instruction. It is possible to execute a fixed release command to release
For a conditional branch instruction, perform a dynamic branch that performs branch prediction with reference to the history stored in the branch history table,
After executing the fixed instruction, with respect to the conditional branch instruction, without performing a reference to the branch history table, performing a fixed prediction that performs branch prediction in the branch prediction direction indicated by the fixed instruction.
Semiconductor device.
前記命令実行処理部は、
前記固定命令を実行した後は、前記条件分岐命令に対して前記固定予測を行う際には、その条件分岐命令の実行結果に基づいた前記分岐履歴テーブルの更新をしない、請求項1に記載の半導体装置。
The instruction execution processing unit
2. The branch history table is not updated based on an execution result of the conditional branch instruction when the fixed prediction is performed on the conditional branch instruction after the fixed instruction is executed. Semiconductor device.
前記命令処理部は、
前記固定命令が指示する前記分岐予測の方向の固定を解除する固定を解除する固定解除命令を実行することを可能とし、
前記固定解除命令を実行した後は、条件分岐命令に対して、前記分岐履歴テーブルに格納された前記履歴を参照して分岐予測をする動的予測を行う共に前記条件分岐命令の実行結果に基づいて前記分岐履歴テーブルを更新する、請求項1に記載の半導体装置。
The instruction processing unit
It is possible to execute a fixing release instruction to release fixing to release the fixing of the branch prediction direction indicated by the fixing instruction,
After executing the fixed release instruction, the conditional branch instruction is subjected to dynamic prediction to perform branch prediction with reference to the history stored in the branch history table, and based on the execution result of the conditional branch instruction. The semiconductor device according to claim 1, wherein the branch history table is updated.
命令のフェッチと実行を含む処理を行い、条件分岐命令の実行に際して分岐予測を行う命令処理部と、
条件分岐命令の実行の結果、分岐したか否かの履歴を格納するためのものであり、前記命令処理部により更新される分岐履歴テーブルとを備え、
前記命令処理部は、
「分岐する」と「分岐しない」のいずれか一方を示す分岐予測方向に固定することを示す固定指示が含まれる条件分岐命令である固定指示付き分岐命令を実行することを可能とし、
前記固定指示付き分岐命令に対して、前記分岐履歴テーブルを参照せずに、前記固定指示が示す分岐予測方向に分岐予測をする固定予測を行い、
前記固定指示が含まれない条件分岐命令に対して、前記分岐履歴テーブルに格納された前記履歴を参照して分岐予測をする動的予測を行うと共に、前記条件分岐命令の実行結果に基づいて前記分岐履歴テーブルを更新する、
半導体装置。
An instruction processing unit that performs processing including instruction fetch and execution, and performs branch prediction when executing a conditional branch instruction;
As a result of execution of a conditional branch instruction, for storing a history of whether or not a branch, comprising a branch history table updated by the instruction processing unit,
The instruction processing unit
It is possible to execute a branch instruction with a fixed instruction that is a conditional branch instruction including a fixed instruction indicating that the instruction is fixed in a branch prediction direction indicating either “branch” or “not branch”.
For the branch instruction with a fixed instruction, without referring to the branch history table, performing a fixed prediction to perform branch prediction in the branch prediction direction indicated by the fixed instruction,
For a conditional branch instruction that does not include the fixed instruction, dynamic prediction is performed to perform branch prediction with reference to the history stored in the branch history table, and based on the execution result of the conditional branch instruction Update the branch history table,
Semiconductor device.
前記命令実行処理部は、
前記固定命令を実行した後は、前記条件分岐命令に対して前記固定予測を行う際には、前記分岐履歴テーブルの更新をしない、請求項4に記載の半導体装置。
The instruction execution processing unit
The semiconductor device according to claim 4, wherein after executing the fixed instruction, the branch history table is not updated when the fixed prediction is performed on the conditional branch instruction.
命令のフェッチと実行を含む処理を行い、条件分岐命令の実行に際して分岐予測を行う命令処理部と、
条件分岐命令の実行の結果、分岐したか否かの履歴を格納するためのものであり、前記命令処理部により更新される分岐履歴テーブルとを備え、
前記命令処理部は、
少なくともカーネルモードとユーザモードを含む複数の動作モードを有し、
各前記動作モードに対して、動的予測の設定、または、「分岐する」と「分岐しない」のいずれか一方を示す分岐予測方向を含む固定予測の設定が可能であり、
前記動的予測の設定がされている動作モードのときに、条件分岐命令に対して、前記分岐履歴テーブルに格納された前記履歴を参照して分岐予測をすると共に、前記条件分岐命令の実行結果に基づいて前記分岐履歴テーブルを更新し、
前記固定予測の設定がされている動作モードのときに、条件分岐命令に対して、前記分岐履歴テーブルを参照せずに、該固定予測の設定に含まれる前記分岐予測方向に分岐予測をする一方、前記分岐履歴テーブルの更新をしない、
半導体装置。
An instruction processing unit that performs processing including instruction fetch and execution, and performs branch prediction when executing a conditional branch instruction;
As a result of execution of a conditional branch instruction, for storing a history of whether or not a branch, comprising a branch history table updated by the instruction processing unit,
The instruction processing unit
A plurality of operation modes including at least a kernel mode and a user mode;
For each of the operation modes, dynamic prediction can be set, or fixed prediction including a branch prediction direction indicating “branch” or “not branch” can be set.
In the operation mode in which the dynamic prediction is set, for the conditional branch instruction, the branch prediction is performed with reference to the history stored in the branch history table, and the execution result of the conditional branch instruction Updating the branch history table based on
While in the operation mode in which the fixed prediction is set, the branch prediction is performed in the branch prediction direction included in the fixed prediction setting without referring to the branch history table for the conditional branch instruction. , Do not update the branch history table,
Semiconductor device.
前記カーネルモードに対して、前記固定予測の設定がされており、
前記ユーザモードに対して、前記動的予測の設定がされている、
請求項6に記載の半導体装置。
The fixed prediction is set for the kernel mode,
The dynamic prediction is set for the user mode,
The semiconductor device according to claim 6.
前記命令処理部は、
前記複数の動作モード間の切替えに伴って発生するコンテキストスイッチに応じて、前記動的予測と前記固定予測の切替えをする、
請求項6に記載の半導体装置。
The instruction processing unit
Switching between the dynamic prediction and the fixed prediction according to a context switch that occurs in association with switching between the plurality of operation modes,
The semiconductor device according to claim 6.
「分岐する」と「分岐しない」のいずれか一方の分岐予測方向に固定する固定予測と、動的予測とのいずれか一方の設定がなされている複数のエリアを有し、プログラムの実行領域を成すメモリと、
命令のフェッチと実行を含む処理を行い、条件分岐命令の実行に際して分岐予測を行う命令処理部と、
条件分岐命令の実行の結果、分岐したか否かの履歴を格納するためのものであり、前記命令処理部により更新される分岐履歴テーブルとを備え、
前記命令処理部は、
前記動的予測の設定がなされているエリアを実行領域とするプログラムの条件分岐命令に対して、前記分岐履歴テーブルに格納された前記履歴を参照して分岐予測をすると共に、前記条件分岐命令の実行結果に基づいて前記分岐履歴テーブルを更新し、
前記固定予測の設定がなされているエリアを実行領域とするプログラムの条件分岐命令に対して、前記分岐履歴テーブルを参照せずに、該エリアに対して設定された分岐予測方向に分岐予測をする一方、前記分岐履歴テーブルの更新をしない、
半導体装置。
It has multiple areas where either fixed prediction that fixes in one of the branch prediction directions of “branch” or “not branch” and dynamic prediction are set, and the program execution area Memory
An instruction processing unit that performs processing including instruction fetch and execution, and performs branch prediction when executing a conditional branch instruction;
As a result of execution of a conditional branch instruction, for storing a history of whether or not a branch, comprising a branch history table updated by the instruction processing unit,
The instruction processing unit
For a conditional branch instruction of a program whose execution area is an area where the dynamic prediction is set, branch prediction is performed with reference to the history stored in the branch history table, and the conditional branch instruction Update the branch history table based on the execution result,
For a conditional branch instruction of a program whose execution region is an area where the fixed prediction is set, branch prediction is performed in the branch prediction direction set for the area without referring to the branch history table. On the other hand, the branch history table is not updated.
Semiconductor device.
JP2012122689A 2012-05-30 2012-05-30 Semiconductor device Pending JP2013250593A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2012122689A JP2013250593A (en) 2012-05-30 2012-05-30 Semiconductor device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2012122689A JP2013250593A (en) 2012-05-30 2012-05-30 Semiconductor device

Publications (1)

Publication Number Publication Date
JP2013250593A true JP2013250593A (en) 2013-12-12

Family

ID=49849272

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2012122689A Pending JP2013250593A (en) 2012-05-30 2012-05-30 Semiconductor device

Country Status (1)

Country Link
JP (1) JP2013250593A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016525252A (en) * 2014-01-27 2016-08-22 ヴィア アライアンス セミコンダクター カンパニー リミテッド Fractional use of predictive history storage for operating system routines

Citations (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS518841A (en) * 1974-07-09 1976-01-24 Hitachi Ltd BUNKIMEIREISEIGYOHOSHIKI
JPS53126837A (en) * 1977-04-13 1978-11-06 Hitachi Ltd Order control unit
JPS56114051A (en) * 1980-02-14 1981-09-08 Mitsubishi Electric Corp Data process system
JPS599758A (en) * 1982-07-09 1984-01-19 Nec Corp Microprogram control data processing device
JPS59183434A (en) * 1983-04-01 1984-10-18 Nippon Telegr & Teleph Corp <Ntt> Prefetch control system of instruction
JPH01258031A (en) * 1988-04-06 1989-10-16 Mitsubishi Electric Corp Data processor
JPH0342723A (en) * 1989-07-11 1991-02-22 Nec Corp Data processor
JPH05224925A (en) * 1992-01-24 1993-09-03 Nec Corp Instruction prefetching system
JPH05233284A (en) * 1992-01-27 1993-09-10 Nec Corp Instruction prefetch system
JPH0863356A (en) * 1994-06-14 1996-03-08 Mitsubishi Electric Corp Branch estimation device
JPH08241198A (en) * 1995-03-06 1996-09-17 Fujitsu Ltd Branch instruction processing method
JPH10177481A (en) * 1996-12-10 1998-06-30 Texas Instr Inc <Ti> Microprocessor with improved branching predicting function and its operating method
JPH10240526A (en) * 1997-02-27 1998-09-11 Fujitsu Ltd Branching prediction device
JPH1115659A (en) * 1997-06-20 1999-01-22 Nec Corp Branch prediction system
JP2004303081A (en) * 2003-03-31 2004-10-28 Fujitsu Ltd Instruction prefetching circuit and microcontroller
JP2007058875A (en) * 1996-08-02 2007-03-08 Jackie A Freeman Programmable branch prediction system and method for computer system
JP2007317083A (en) * 2006-05-29 2007-12-06 Nec Computertechno Ltd Microprocessor and pipeline control method

Patent Citations (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS518841A (en) * 1974-07-09 1976-01-24 Hitachi Ltd BUNKIMEIREISEIGYOHOSHIKI
JPS53126837A (en) * 1977-04-13 1978-11-06 Hitachi Ltd Order control unit
JPS56114051A (en) * 1980-02-14 1981-09-08 Mitsubishi Electric Corp Data process system
JPS599758A (en) * 1982-07-09 1984-01-19 Nec Corp Microprogram control data processing device
JPS59183434A (en) * 1983-04-01 1984-10-18 Nippon Telegr & Teleph Corp <Ntt> Prefetch control system of instruction
JPH01258031A (en) * 1988-04-06 1989-10-16 Mitsubishi Electric Corp Data processor
JPH0342723A (en) * 1989-07-11 1991-02-22 Nec Corp Data processor
JPH05224925A (en) * 1992-01-24 1993-09-03 Nec Corp Instruction prefetching system
JPH05233284A (en) * 1992-01-27 1993-09-10 Nec Corp Instruction prefetch system
JPH0863356A (en) * 1994-06-14 1996-03-08 Mitsubishi Electric Corp Branch estimation device
JPH08241198A (en) * 1995-03-06 1996-09-17 Fujitsu Ltd Branch instruction processing method
JP2007058875A (en) * 1996-08-02 2007-03-08 Jackie A Freeman Programmable branch prediction system and method for computer system
JPH10177481A (en) * 1996-12-10 1998-06-30 Texas Instr Inc <Ti> Microprocessor with improved branching predicting function and its operating method
JPH10240526A (en) * 1997-02-27 1998-09-11 Fujitsu Ltd Branching prediction device
JPH1115659A (en) * 1997-06-20 1999-01-22 Nec Corp Branch prediction system
JP2004303081A (en) * 2003-03-31 2004-10-28 Fujitsu Ltd Instruction prefetching circuit and microcontroller
JP2007317083A (en) * 2006-05-29 2007-12-06 Nec Computertechno Ltd Microprocessor and pipeline control method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
JPN6015046687; 片山清和,安藤秀樹,島田俊夫: '分岐フィルタリングによる両パス実行性能の改善' 2000年記念並列処理シンポジウムJSPP2000 , 20000601, Pages:253〜260, 社団法人情報処理学会 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016525252A (en) * 2014-01-27 2016-08-22 ヴィア アライアンス セミコンダクター カンパニー リミテッド Fractional use of predictive history storage for operating system routines

Similar Documents

Publication Publication Date Title
CN108139908B (en) Move prefix instructions
KR20130016246A (en) Mapping between registers used by multiple instruction sets
JP4703718B2 (en) Selective subroutine return structure
US20120290806A1 (en) Selective routing of local memory accesses and device thereof
US20100169546A1 (en) Flash memory access circuit
US20160093404A1 (en) Method and apparatus for reverse memory sparing
GB2526646A (en) Decoding base instructions modified by a prefix instruction using modifier bits
JP2021527248A (en) Storage of accidental branch predictions to reduce the waiting time for misprediction recovery
JP4334598B1 (en) Information processing apparatus and error correction method
TWI597665B (en) Method and storage system for updating software in a storage system
JP5811245B1 (en) Information processing apparatus, memory order guarantee method, and program
CN112579162A (en) Method for selecting high-level features by coordinating hardware and software on heterogeneous ISA platform
KR102152735B1 (en) Graphic processor and method of oprating the same
EP2463776A2 (en) Bytecode branch processor and method
JP2013250593A (en) Semiconductor device
JP4985452B2 (en) Vector processing equipment
JP2018005655A (en) Memory controller and memory access method
CN112470122A (en) Branch target buffer with early return prediction
KR102581576B1 (en) Vector operand bit size control
CN108701031B (en) Register access control
CN108268118B (en) System and method for operating a microcontroller
US20210326132A1 (en) Methods and processors for performing resource deduction for execution of smart contract
US8516231B2 (en) Interrupt handling apparatus and method for equal-model processor and processor including the interrupt handling apparatus
JP4198016B2 (en) Information processing apparatus and interrupt control method thereof
JP2022033968A (en) Processing speed matching circuit and microprocessor

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20150219

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20151015

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20151124

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20160315