JP2007310668A - Microprocessor - Google Patents

Microprocessor Download PDF

Info

Publication number
JP2007310668A
JP2007310668A JP2006139234A JP2006139234A JP2007310668A JP 2007310668 A JP2007310668 A JP 2007310668A JP 2006139234 A JP2006139234 A JP 2006139234A JP 2006139234 A JP2006139234 A JP 2006139234A JP 2007310668 A JP2007310668 A JP 2007310668A
Authority
JP
Japan
Prior art keywords
instruction
branch
cpu
prefetch buffer
unit
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.)
Withdrawn
Application number
JP2006139234A
Other languages
Japanese (ja)
Inventor
Hiroyuki Takai
裕之 高井
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.)
Toshiba Corp
Kioxia Systems Co Ltd
Original Assignee
Toshiba Corp
Toshiba Memory Systems Co Ltd
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 Toshiba Corp, Toshiba Memory Systems Co Ltd filed Critical Toshiba Corp
Priority to JP2006139234A priority Critical patent/JP2007310668A/en
Publication of JP2007310668A publication Critical patent/JP2007310668A/en
Withdrawn legal-status Critical Current

Links

Images

Landscapes

  • Advance Control (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a microprocessor provided with a CPU capable of efficiently fetching instructions from a prefetch buffer predicting branch instructions. <P>SOLUTION: The microprocessor 100 includes a memory 3 having instructions stored therein, a CPU 1 for performing pipeline processing of fetched instructions, and a prefetch buffer 2 which reads ahead instructions in a request address from the CPU 1 and a plurality of following addresses from the memory and stores them therein. The prefetch buffer 2 predicts a branch by determining whether the stored instructions read ahead from the memory 3 includes a branch instruction or not and informs the CPU 1 of the branch prediction result. The CPU 1 controls fetching of instructions from the prefetch buffer 2 on the basis of the branch prediction result informed from the prefetch buffer 2. <P>COPYRIGHT: (C)2008,JPO&INPIT

Description

本発明は、マイクロプロセッサに関し、特に分岐予測を行うプリフェッチバッファおよびこのプリフェッチバッファからの命令をフェッチするCPUを備えるマイクロプロセッサに関する。   The present invention relates to a microprocessor, and more particularly to a microprocessor including a prefetch buffer that performs branch prediction and a CPU that fetches instructions from the prefetch buffer.

内蔵するフラッシュメモリに実行する命令を格納するマイクロプロセッサでは、フラッシュメモリの読み出し速度が遅いため、先読みした命令を格納しておくプリフェッチバッファを設けることが行われる。CPUがフラッシュメモリから命令を読み出す場合、一度の命令読み出し動作で、その命令のアドレスに後続する複数のアドレスの命令を先に読み出し、先読みした命令がプリフェッチバッファに格納される。そして、CPUへはプリフェッチバッファから1つずつ命令を供給し、プリフェッチバッファがCPUへ命令を供給している間に、さらに続きの命令をフラッシュメモリから読み出し、プリフェッチバッファに格納するという動作が行なわれる。これにより、プログラムが順次実行される場合は、CPUへは命令が途切れることなく供給される。   In a microprocessor that stores instructions to be executed in a built-in flash memory, since the reading speed of the flash memory is low, a prefetch buffer for storing prefetched instructions is provided. When the CPU reads an instruction from the flash memory, the instruction at a plurality of addresses following the instruction address is read first in a single instruction read operation, and the prefetched instruction is stored in the prefetch buffer. Then, instructions are supplied to the CPU one by one from the prefetch buffer, and while the prefetch buffer supplies instructions to the CPU, further instructions are read from the flash memory and stored in the prefetch buffer. . Thereby, when the program is sequentially executed, the instruction is supplied to the CPU without interruption.

ところが、プログラム実行中に分岐が発生すると、先読みしてプリフェッチバッファに格納していた命令が使用できず、その時点から新たに分岐先の命令をフラッシュメモリから読み出す必要が生じる。そのため、CPUからの命令読み出し要求に対する命令の供給が遅くなり、プログラムの実行が遅くなる。   However, if a branch occurs during program execution, the instruction that has been prefetched and stored in the prefetch buffer cannot be used, and a new branch destination instruction must be read from the flash memory from that point. Therefore, the supply of instructions in response to an instruction read request from the CPU is delayed, and the execution of the program is delayed.

そこで、このような遅れを回避するために、プリフェッチバッファに分岐予測手段を設け、分岐命令が実行されると予測されるときは、分岐先アドレスの命令をフラッシュメモリから先読みすることが行われる(例えば、特許文献1参照。)。   Therefore, in order to avoid such a delay, a branch prediction unit is provided in the prefetch buffer, and when a branch instruction is predicted to be executed, an instruction at the branch destination address is prefetched from the flash memory ( For example, see Patent Document 1.)

一方、CPUの命令実行を高速化する手法にパイプライン処理がある。パイプライン処理では、命令のフェッチ、命令のデコード、命令の実行という各ステージの処理を並行に行うことにより、複数の命令が並行に処理される。すなわち、ある命令の実行と、その次の命令のデコードと、その次の次の命令のフェッチが、並行に処理される。   On the other hand, there is a pipeline processing as a method for speeding up CPU instruction execution. In pipeline processing, a plurality of instructions are processed in parallel by performing processing at each stage of instruction fetch, instruction decode, and instruction execution in parallel. That is, execution of a certain instruction, decoding of the next instruction, and fetching of the next next instruction are processed in parallel.

このようなパイプライン処理を行うCPUが、分岐予測を行うプリフェッチバッファにより分岐命令と予測された命令をこのプリフェッチバッファからフェッチした場合、その命令が実際に分岐するかどうかは、その命令が実行ステージに進むまで不明である。   When a CPU that performs such pipeline processing fetches an instruction predicted as a branch instruction from a prefetch buffer that performs branch prediction from the prefetch buffer, whether or not the instruction actually branches is determined by the execution stage. It is unknown until proceeding to.

そのため、従来のパイプライン処理を行うCPUでは、プリフェッチバッファにより分岐命令と予測された命令をフェッチした場合、その命令とともにプリフェッチバッファにより先読みされた後続の命令を、その命令に引き続いてフェッチする。   Therefore, in a CPU that performs conventional pipeline processing, when an instruction predicted as a branch instruction is fetched by a prefetch buffer, a subsequent instruction prefetched by the prefetch buffer together with the instruction is fetched following the instruction.

ところが、プリフェッチバッファにより分岐命令と予測された命令が実際に分岐する場合、プリフェッチバッファにより先読みされた後続の命令の中には、実際には使用されない命令が含まれている。しかし、従来は、このような命令もそのままフェッチしていた。   However, when an instruction predicted as a branch instruction by the prefetch buffer actually branches, an instruction that is not actually used is included in the subsequent instructions prefetched by the prefetch buffer. However, conventionally, such an instruction is fetched as it is.

上述したように、従来のパイプライン処理を行うCPUには、分岐予測を行うプリフェッチバッファが分岐命令と予測した命令をこのプリフェッチバッファからフェッチするときに、実行不要な命令までフェッチしてしまい、その分無駄な電力を消費するなどの問題があった。
特開平8−106387号公報 (第7ページ、図10)
As described above, in a CPU that performs conventional pipeline processing, when a prefetch buffer that performs branch prediction fetches an instruction that is predicted to be a branch instruction from the prefetch buffer, an instruction that does not need to be executed is fetched. There was a problem of consuming unnecessary power.
JP-A-8-106387 (page 7, FIG. 10)

そこで、本発明の目的は、分岐命令を予測するプリフェッチバッファから命令を効率よくフェッチすることのできるCPUを備えるマイクロプロセッサを提供することにある。   Therefore, an object of the present invention is to provide a microprocessor including a CPU that can efficiently fetch an instruction from a prefetch buffer that predicts a branch instruction.

本発明の一態様によれば、命令を格納したメモリと、フェッチした命令をパイプライン処理するCPUと、前記CPUからの要求アドレスに対して、前記要求アドレスの命令とともに前記要求アドレスに後続する複数のアドレスの命令も前記メモリから先読みして格納しておき、前記CPUからのその後の要求アドレスに対応する命令を前記CPUへ出力するプリフェッチバッファとを備え、前記プリフェッチバッファは、前記CPUからの要求アドレスを元に分岐予測を行い、分岐が行われると予測した場合には前記メモリから分岐先の命令を含む複数のアドレスの命令を先読みして格納するとともに、前記分岐が行われると予測した命令を前記CPUがフェッチする際に、その分岐予測結果を前記CPUへ通知し、前記CPUは、前記プリフェッチバッファから通知された前記分岐予測結果にもとづいて前記プリフェッチバッファからの命令のフェッチを制御することを特徴とするマイクロプロセッサが提供される。   According to one aspect of the present invention, a memory that stores an instruction, a CPU that pipelines a fetched instruction, and a plurality of instructions that follow the request address together with the instruction at the request address with respect to the request address from the CPU And a prefetch buffer for prefetching and storing an instruction corresponding to a subsequent request address from the CPU to the CPU, and the prefetch buffer is a request from the CPU. Branch prediction is performed based on an address, and when it is predicted that a branch will be performed, an instruction at a plurality of addresses including a branch destination instruction is prefetched from the memory and stored, and the instruction predicted to perform the branch When the CPU fetches the branch prediction result, the CPU notifies the CPU of the branch prediction result. Microprocessor and controls fetching of instructions from the prefetch buffer is provided based on the branch prediction result notified from the fetch buffer.

本発明によれば、CPUは、プリフェッチバッファからフェッチした命令がプリフェッチバッファにより分岐命令と予測されているときは、その命令に後続する命令のフェッチを停止するので、命令の無駄なフェッチを少なくすることができる。   According to the present invention, when the instruction fetched from the prefetch buffer is predicted to be a branch instruction by the prefetch buffer, the CPU stops fetching the instruction subsequent to the instruction, thereby reducing useless fetching of the instruction. be able to.

以下、本発明の実施例を図面を参照して説明する。   Embodiments of the present invention will be described below with reference to the drawings.

図1は、本発明の実施例に係るマイクロプロセッサの基本構成を示すブロック図である。   FIG. 1 is a block diagram showing a basic configuration of a microprocessor according to an embodiment of the present invention.

本実施例のマイクロプロセッサ100は、CPU1と、プリフェッチバッファ2と、メモリ3とを備える。   The microprocessor 100 according to the present embodiment includes a CPU 1, a prefetch buffer 2, and a memory 3.

CPU1で実行する命令を格納するメモリ3は、例えばフラッシュメモリなどの読み出し速度の遅いメモリである。そこで、一度の読み出し動作で複数の連続した命令を読み出し、読み出し効率の向上を図る。ここでは、読み出しアドレスの入力から命令データの出力までにシステム・クロックの4クロックを要するものとし、1回の読み出し要求に対して4命令を出力するものとする。   A memory 3 for storing instructions to be executed by the CPU 1 is a memory having a low reading speed such as a flash memory. Therefore, a plurality of consecutive instructions are read out by a single read operation to improve read efficiency. Here, it is assumed that four clocks of the system clock are required from the input of the read address to the output of the instruction data, and four instructions are output in response to one read request.

プリフェッチバッファ2は、メモリ3から出力された複数の命令を一時格納しておき、CPU1からの要求アドレスに一致するアドレスの命令データをCPU1へ供給する。   The prefetch buffer 2 temporarily stores a plurality of instructions output from the memory 3 and supplies instruction data having an address matching the request address from the CPU 1 to the CPU 1.

また、プリフェッチバッファ2は、メモリ3から出力されて一時格納した命令の中に分岐命令が含まれるかどうかを予測し、分岐命令と予測した命令があるときは、その分岐先と予測されるアドレスの命令をCPU1からの要求に先立ってメモリから読み出しておく。   In addition, the prefetch buffer 2 predicts whether or not a branch instruction is included in the instruction output from the memory 3 and temporarily stored, and when there is an instruction predicted as a branch instruction, an address predicted as the branch destination. Are read from the memory prior to the request from the CPU 1.

プリフェッチバッファ2における分岐予測は、CPU1から入力される分岐発生情報を記録した分岐履歴にもとづいて行われる。   Branch prediction in the prefetch buffer 2 is performed based on a branch history in which branch occurrence information input from the CPU 1 is recorded.

さらに、プリフェッチバッファ2は、分岐命令と予測している命令の読み出しの要求をCPU1から受けたときは、その命令を分岐命令と予測していることを通知する分岐予測通知信号をCPU1へ出力する。   Further, when the prefetch buffer 2 receives a request for reading an instruction predicted as a branch instruction from the CPU 1, the prefetch buffer 2 outputs to the CPU 1 a branch prediction notification signal for notifying that the instruction is predicted as a branch instruction. .

CPU1は、プリフェッチバッファから供給された命令をパイプライン処理する。図2に、そのパイプライン処理の様子を示す。   The CPU 1 pipelines the instruction supplied from the prefetch buffer. FIG. 2 shows the pipeline processing.

CPU1は、システム・クロックの1クロックごとに、命令のフェッチ、フェッチした命令のデコード、デコードした命令の実行、という各ステージの処理が実行される。この各ステージの処理は並行して実行されるので、先に入力された命令1がデコードされているときに、次の命令2がフェッチされ、この命令2がデコードされているときに、さらに次の命令3がフェッチされる。   The CPU 1 executes each stage of processing such as fetching an instruction, decoding the fetched instruction, and executing the decoded instruction for each clock of the system clock. Since the processing of each stage is executed in parallel, when the previously input instruction 1 is decoded, the next instruction 2 is fetched, and when this instruction 2 is decoded, the next process is further performed. Instruction 3 is fetched.

次に、このようなパイプライン処理を行うCPU1に対して、プリフェッチバッファ2から分岐予測通知信号が出力されたときの動作を説明する。   Next, an operation when a branch prediction notification signal is output from the prefetch buffer 2 to the CPU 1 that performs such pipeline processing will be described.

図3は、プリフェッチバッファ2から分岐予測通知信号が出力されたときのCPU1のパイプラインの各ステージの動作の様子を示す図である。   FIG. 3 is a diagram illustrating an operation state of each stage of the pipeline of the CPU 1 when the branch prediction notification signal is output from the prefetch buffer 2.

プリフェッチバッファ2が分岐を予測している命令をCPU1がフェッチしたときに、プリフェッチバッファ2は、CPU1に対して、分岐予測通知信号を出力する。   When the CPU 1 fetches an instruction for which the prefetch buffer 2 predicts a branch, the prefetch buffer 2 outputs a branch prediction notification signal to the CPU 1.

分岐予測通知信号が入力されると、CPU1は、命令のフェッチ動作を停止する。これにより、プリフェッチバッファ2に格納されている後続の命令は、CPU1にフェッチされない。   When the branch prediction notification signal is input, the CPU 1 stops the instruction fetch operation. As a result, subsequent instructions stored in the prefetch buffer 2 are not fetched by the CPU 1.

一方、CPU1にフェッチされた、プリフェッチバッファ2により分岐が予測されている命令は、その後、デコードされ、実行される。この命令の実行が終了すると、CPU1は、プリフェッチバッファ2により分岐が予測されている命令の実行が終了したことを示す、実行終了フラグを立てる。   On the other hand, the instruction fetched by the CPU 1 and predicted to be branched by the prefetch buffer 2 is then decoded and executed. When the execution of this instruction is completed, the CPU 1 sets an execution end flag indicating that the execution of the instruction whose branch is predicted by the prefetch buffer 2 has ended.

実行終了フラグが立つと、CPU1は、命令のフェッチを再開する。このとき、プリフェッチバッファ2による予測通り、分岐が発生したときは、プリフェッチバッファ2が予測してメモリ1から読み出しておいた分岐先の命令が使用できるので、この分岐先の命令が直ちにプリフェッチバッファ2から供給され、CPU1にフェッチされる。   When the execution end flag is set, the CPU 1 resumes fetching instructions. At this time, as predicted by the prefetch buffer 2, when a branch occurs, the branch destination instruction predicted by the prefetch buffer 2 and read from the memory 1 can be used. And fetched by the CPU 1.

上述したように、本実施例のCPU1は、プリフェッチバッファ2から分岐予測通知信号が入力されると、命令のフェッチ動作を停止する。これにより、分岐が発生したときにはフェッチする必要のない、プリフェッチバッファ2に格納されている後続の命令を無駄にフェッチすることを防止することができる。   As described above, when the branch prediction notification signal is input from the prefetch buffer 2, the CPU 1 of this embodiment stops the instruction fetch operation. As a result, it is possible to prevent unnecessary fetching of subsequent instructions stored in the prefetch buffer 2, which need not be fetched when a branch occurs.

このプリフェッチバッファ2から分岐予測通知信号が出力されたときの本実施例のマイクロプロセッサの動作を図4〜6を用いてさらに詳しく説明する。   The operation of the microprocessor of this embodiment when the branch prediction notification signal is output from the prefetch buffer 2 will be described in more detail with reference to FIGS.

図4は、プリフェッチバッファ2の内部構成の例を示すブロック図である。   FIG. 4 is a block diagram showing an example of the internal configuration of the prefetch buffer 2.

分岐履歴生成部21は、CPU1から入力された分岐発生情報にもとづいて、分岐発生アドレスと分岐先アドレスを1組のエントリ情報とした分岐履歴を生成し保存する。   The branch history generation unit 21 generates and stores a branch history using the branch occurrence address and the branch destination address as a set of entry information based on the branch occurrence information input from the CPU 1.

分岐予測部22は、CPU1から入力された要求アドレスと分岐履歴生成部21に保存されている分岐履歴とを照合し、この要求アドレスに基づいてメモリ3から読み出される複数の命令の中に分岐命令が含まれるかどうかを予測する。分岐命令が含まれると予測されたときは、その分岐先のアドレスを分岐履歴の該当のエントリ情報から抽出し、予測分岐先アドレス格納部23へ出力する。   The branch prediction unit 22 collates the request address input from the CPU 1 with the branch history stored in the branch history generation unit 21, and includes a branch instruction among a plurality of instructions read from the memory 3 based on the request address. Predict whether or not will be included. When it is predicted that a branch instruction is included, the branch destination address is extracted from the corresponding entry information of the branch history and output to the predicted branch destination address storage unit 23.

また、分岐予測部22は、CPU1から入力された要求アドレスが分岐命令と予測した命令のアドレスであるときは、分岐予測通知信号をCPU1へ出力する。   Further, the branch prediction unit 22 outputs a branch prediction notification signal to the CPU 1 when the request address input from the CPU 1 is an address of an instruction predicted as a branch instruction.

分岐予測部22は、分岐予測部22から出力された予測分岐先アドレスを格納する。   The branch prediction unit 22 stores the predicted branch destination address output from the branch prediction unit 22.

アドレス選択部24は、分岐予測部22により分岐が予測されたときは、分岐予測部22に格納された予測分岐先アドレスを読み出しアドレスとしてメモリ3へ出力する。それ以外のときは、CPU1からの要求アドレスにもとづいてメモリ3への読み出しアドレスを出力する。   When the branch prediction unit 22 predicts a branch, the address selection unit 24 outputs the predicted branch destination address stored in the branch prediction unit 22 to the memory 3 as a read address. In other cases, the read address to the memory 3 is output based on the request address from the CPU 1.

命令バッファ25は、メモリ3から読み出された複数の命令データを一時格納する。   The instruction buffer 25 temporarily stores a plurality of instruction data read from the memory 3.

命令選択部26は、命令バッファ25に格納された命令データの中から、CPU1の要求アドレスに一致するアドレスの命令データをCPU1へ出力する。   The instruction selection unit 26 outputs, to the CPU 1, instruction data at an address that matches the request address of the CPU 1 from the instruction data stored in the instruction buffer 25.

図5は、CPU1の内部構成の例を示すブロック図である。   FIG. 5 is a block diagram illustrating an example of the internal configuration of the CPU 1.

アドレス生成部11は、命令の読み出しを要求するアドレスを生成し、プリフェッチバッファ2へ要求アドレスとして出力する。アドレス生成部11は、分岐命令検出部18より分岐検出信号が入力された場合には、分岐先のアドレスを生成し、そうでない場合は、前回フェッチを行ったアドレスを単純にインクリメントしたアドレスを生成する。   The address generation unit 11 generates an address for requesting reading of an instruction and outputs the request to the prefetch buffer 2 as a request address. The address generation unit 11 generates a branch destination address when a branch detection signal is input from the branch instruction detection unit 18, and otherwise generates an address obtained by simply incrementing the address fetched last time. To do.

フェッチ部12は、パイプライン処理のフェッチステージに当たり、プリフェッチバッファ2から入力された命令データをフェッチする。   The fetch unit 12 fetches instruction data input from the prefetch buffer 2 at the fetch stage of pipeline processing.

デコード部13は、パイプライン処理のデコードテージに当たり、フェッチ部12にフェッチされた命令データをデコードする。   The decode unit 13 decodes the instruction data fetched by the fetch unit 12 in the decode stage of the pipeline processing.

実行部14は、パイプライン処理の実行ステージに当たり、デコード部13でデコードされた命令を実行する。   The execution unit 14 executes the instruction decoded by the decoding unit 13 at the execution stage of the pipeline processing.

このフェッチ部12、デコード部13、実行部14には、レジスタ15、レジスタ16、レジスタ17が、それぞれ併設されている。   The fetch unit 12, the decode unit 13, and the execution unit 14 are provided with a register 15, a register 16, and a register 17, respectively.

レジスタ15へは、プリフェッチバッファ2からの分岐予測通知信号が入力される。レジスタ15へ入力された分岐予測通知信号は、レジスタ16、レジスタ17へ順次転送される。この転送される分岐予測通知信号は、分岐予測通知信号とともにプリフェッチバッファ2から入力された分岐命令と予測されている命令の処理済みステージを示すフラグとして用いられる。したがって、レジスタ17の出力は、分岐命令と予測されている命令の実行終了フラグに相当する。   The branch prediction notification signal from the prefetch buffer 2 is input to the register 15. The branch prediction notification signal input to the register 15 is sequentially transferred to the register 16 and the register 17. This transferred branch prediction notification signal is used as a flag indicating the branch instruction input from the prefetch buffer 2 together with the branch prediction notification signal and the processed stage of the predicted instruction. Therefore, the output of the register 17 corresponds to an execution end flag of an instruction predicted as a branch instruction.

分岐命令検出部18は、実行部14で実行された命令で分岐が発生したかどうかを検出する。分岐が発生ししたときは、分岐発生アドレスと分岐先アドレスを分岐発生情報としてプリフェッチバッファ2へ出力する。また、分岐が発生したときは、分岐先アドレスの生成をアドレス生成部11へ指示する。   The branch instruction detection unit 18 detects whether or not a branch has occurred in the instruction executed by the execution unit 14. When a branch occurs, the branch occurrence address and branch destination address are output to the prefetch buffer 2 as branch occurrence information. When a branch occurs, the address generation unit 11 is instructed to generate a branch destination address.

フェッチ制御部19は、フェッチ部12のフェッチ動作の停止および再開を制御する。プリフェッチバッファ2から分岐予測通知信号が入力されると、フェッチ制御部19は、フェッチ部12へフェッチ動作の停止を指示する。その後、レジスタ17に実行終了フラグが出力されると、フェッチ制御部19は、フェッチ部12へフェッチ動作の再開を指示するとともに、アドレス生成部11へ、フェッチを停止した時点のアドレスをインクリメントしてフェッチを再開することを指示するフェッチ再開信号を出力する。   The fetch control unit 19 controls the stop and restart of the fetch operation of the fetch unit 12. When a branch prediction notification signal is input from the prefetch buffer 2, the fetch control unit 19 instructs the fetch unit 12 to stop the fetch operation. Thereafter, when the execution end flag is output to the register 17, the fetch control unit 19 instructs the fetch unit 12 to resume the fetch operation, and increments the address when the fetch is stopped to the address generation unit 11. A fetch resumption signal instructing to resume fetching is output.

また、レジスタ17に実行終了フラグが出力される前に、分岐命令検出部18から分岐検出を示す信号が出力されたとき、もしくは、例外あるいは割り込みの発生があったときも、フェッチ制御部19は、フェッチ部12へフェッチ動作の再開を指示する。   The fetch control unit 19 also receives a signal indicating branch detection from the branch instruction detection unit 18 before the execution end flag is output to the register 17 or when an exception or an interrupt occurs. The fetch unit 12 is instructed to resume the fetch operation.

図6は、図4に示したプリフェッチバッファ2および図5に示したCPU1を用いたマイクロプロセッサのフェッチ制御動作の様子を示す動作波形図である。ここで、メモリ3の命令データの読み出しにはシステム・クロックの4クロックを要するものとし、1回の読み出し要求に対してメモリ3から4命令が出力されるものとする。また、システム・クロックのサイクル番号をc1、c2、c3、・・・と表すものとする。   FIG. 6 is an operation waveform diagram showing the state of the fetch control operation of the microprocessor using the prefetch buffer 2 shown in FIG. 4 and the CPU 1 shown in FIG. Here, it is assumed that reading of the instruction data from the memory 3 requires four system clocks, and four instructions are output from the memory 3 in response to one read request. Further, the cycle numbers of the system clock are represented as c1, c2, c3,.

いま、c1でCPU1から要求アドレスA0が出力され、プリフェッチバッファ2がメモリ3へ読み出しアドレスA0を出力したとする。   Now, it is assumed that the request address A0 is output from the CPU 1 at c1 and the prefetch buffer 2 outputs the read address A0 to the memory 3.

このアドレスA0に対してプリフェッチバッファ2の分岐予測部22が分岐予測した結果、分岐命令と予測され、その分岐先アドレスがA12と判明したとすると、この分岐先アドレスA12は予測分岐先アドレス格納部23に格納される。   As a result of branch prediction by the branch prediction unit 22 of the prefetch buffer 2 with respect to this address A0, if a branch instruction is predicted and the branch destination address is found to be A12, this branch destination address A12 is the predicted branch destination address storage unit. 23.

プリフェッチバッファ2から出力された読み出しアドレスA0に対して、メモリ3は、4クロック後のc5で、命令データD0〜D3を出力する。この命令データD0〜D3は、プリフェッチバッファ2に格納される。   For the read address A0 output from the prefetch buffer 2, the memory 3 outputs the instruction data D0 to D3 at c5 after 4 clocks. The instruction data D0 to D3 are stored in the prefetch buffer 2.

また、このc5で、プリフェッチバッファ2は、予測分岐先アドレス格納部23に格納されているアドレスA12を、次の読み出しアドレスとして、メモリ3へ出力する。   At c5, the prefetch buffer 2 outputs the address A12 stored in the predicted branch destination address storage unit 23 to the memory 3 as the next read address.

同じくc5で、プリフェッチバッファ2に格納された命令データD0〜D3の中から、CPU1からの要求アドレスA0に対する命令データD0がCPU1へ出力され、CPU1のフェッチ部12にフェッチされる。   Similarly, at c5, the instruction data D0 corresponding to the request address A0 from the CPU 1 is output from the instruction data D0 to D3 stored in the prefetch buffer 2 to the CPU 1 and fetched by the fetch unit 12 of the CPU 1.

このとき、プリフェッチバッファ2は、CPU1に対して、分岐予測通知信号を出力する。   At this time, the prefetch buffer 2 outputs a branch prediction notification signal to the CPU 1.

分岐予測通知信号の入力を受けて、CPU1のフェッチ制御部19は、フェッチ部12へフェッチ動作の停止を指示する。その結果、プリフェッチバッファ2に格納されている命令データD0〜D3のうち、命令データD3は、フェッチ部12にフェッチされない。   Upon receiving the branch prediction notification signal, the fetch control unit 19 of the CPU 1 instructs the fetch unit 12 to stop the fetch operation. As a result, of the instruction data D0 to D3 stored in the prefetch buffer 2, the instruction data D3 is not fetched by the fetch unit 12.

一方、c5でフェッチ部12にフェッチされた命令データD0は、c6でデコード部13によりデコードされ、c7で実行部14により実行される。その結果、c8で、CPU1のレジスタ17から実行終了フラグが出力される。この実行終了フラグの出力を受けて、フェッチ制御部19は、フェッチ部12へフェッチ動作の再開を指示する。   On the other hand, the instruction data D0 fetched by the fetch unit 12 at c5 is decoded by the decode unit 13 at c6 and executed by the execution unit 14 at c7. As a result, an execution end flag is output from the register 17 of the CPU 1 at c8. In response to the output of the execution end flag, the fetch control unit 19 instructs the fetch unit 12 to resume the fetch operation.

また、c7での命令データD0の実行の結果、プリフェッチバッファ2の予測通り分岐が発生し、その分岐先アドレスがA12であったとすると、CPU1は、c8で、要求アドレスA12を出力する。   As a result of execution of the instruction data D0 at c7, if a branch occurs as predicted by the prefetch buffer 2, and the branch destination address is A12, the CPU 1 outputs the request address A12 at c8.

次に、c9で、メモリ3から、先にc5で入力された読み出しアドレスA12に対する命令データD12〜D15が出力される。   Next, at c9, the instruction data D12 to D15 for the read address A12 previously input at c5 are output from the memory 3.

このとき、プリフェッチバッファ2による分岐予測が当たっており、また、CPU1のフェッチ部12のフェッチ動作が再開しているので、メモリ3から出力された命令データD12〜D15のうち、命令データD12が、直ちにCPU1のフェッチ部12にフェッチされる。   At this time, branch prediction by the prefetch buffer 2 is applied, and since the fetch operation of the fetch unit 12 of the CPU 1 is resumed, among the instruction data D12 to D15 output from the memory 3, the instruction data D12 is Immediately, it is fetched by the fetch unit 12 of the CPU 1.

このような本実施例によれば、プリフェッチバッファにおいて分岐予測を行い、分岐が予測される命令をCPUがフェッチしたときに、分岐予測通知信号をCPUへ出力する。この分岐予測通知信号の入力を受けて、CPUは後続の命令のフェッチ動作を停止する。これにより、CPUは、フェッチした命令が分岐命令と予測されるときは、プリフェッチバッファに格納されている命令の中で、分岐が発生したときにはフェッチする必要のない命令をフェッチしなくて済み、無駄なフェッチ動作を減らすことができる。その結果、マイクロプロセッサの消費電力を低減させることができる。   According to this embodiment, branch prediction is performed in the prefetch buffer, and when the CPU fetches an instruction that is predicted to branch, a branch prediction notification signal is output to the CPU. Upon receiving this branch prediction notification signal, the CPU stops the fetch operation of the subsequent instruction. Thus, when the fetched instruction is predicted to be a branch instruction, the CPU does not need to fetch an instruction stored in the prefetch buffer that does not need to be fetched when a branch occurs. Fetch operations can be reduced. As a result, the power consumption of the microprocessor can be reduced.

本発明の実施例に係るマイクロプロセッサの基本構成を示すブロック図。1 is a block diagram showing a basic configuration of a microprocessor according to an embodiment of the present invention. 本発明の実施例に係るマイクロプロセッサのCPUのパイプライン処理を説明するための図。The figure for demonstrating the pipeline process of CPU of the microprocessor which concerns on the Example of this invention. 本発明の実施例に係るマイクロプロセッサの動作を説明するための図。The figure for demonstrating operation | movement of the microprocessor which concerns on the Example of this invention. 本発明の実施例に係るマイクロプロセッサのプリフェッチバッファの構成の例を示すブロック図。The block diagram which shows the example of a structure of the prefetch buffer of the microprocessor which concerns on the Example of this invention. 本発明の実施例に係るマイクロプロセッサのCPUの構成の例を示すブロック図。The block diagram which shows the example of a structure of CPU of the microprocessor which concerns on the Example of this invention. 本発明の実施例に係るマイクロプロセッサの動作波形図。FIG. 3 is an operation waveform diagram of the microprocessor according to the embodiment of the present invention.

符号の説明Explanation of symbols

1 CPU
2 プリフェッチバッファ
3 メモリ
11 アドレス生成部
12 フェッチ部
13 デコード部
14 実行部
15〜17 レジスタ
18 分岐命令検出部
19 フェッチ制御部
21 分岐履歴生成部
22 分岐予測部
23 分岐予測先アドレス格納部
24 アドレス選択部
25 命令バッファ
26 命令選択部
100 マイクロプロセッサ
1 CPU
2 Prefetch buffer 3 Memory 11 Address generation unit 12 Fetch unit 13 Decode unit 14 Execution units 15 to 17 Register 18 Branch instruction detection unit 19 Fetch control unit 21 Branch history generation unit 22 Branch prediction unit 23 Branch prediction destination address storage unit 24 Address selection Unit 25 Instruction buffer 26 Instruction selection unit 100 Microprocessor

Claims (5)

命令を格納したメモリと、フェッチした命令をパイプライン処理するCPUと、前記CPUからの要求アドレスに対して、前記要求アドレスの命令とともに前記要求アドレスに後続する複数のアドレスの命令も前記メモリから先読みして格納しておき、前記CPUからのその後の要求アドレスに対応する命令を前記CPUへ出力するプリフェッチバッファと
を備え、
前記プリフェッチバッファは、
前記CPUからの要求アドレスを元に分岐予測を行い、分岐が行われると予測した場合には前記メモリから分岐先の命令を含む複数のアドレスの命令を先読みして格納するとともに、前記分岐が行われると予測した命令を前記CPUがフェッチする際に、その分岐予測結果を前記CPUへ通知し、
前記CPUは、
前記プリフェッチバッファから通知された前記分岐予測結果にもとづいて前記プリフェッチバッファからの命令のフェッチを制御する
ことを特徴とするマイクロプロセッサ。
A memory that stores instructions, a CPU that pipelines fetched instructions, and instructions at a plurality of addresses that follow the request address together with the instructions at the request address for the request address from the CPU are prefetched from the memory And a prefetch buffer for outputting an instruction corresponding to a subsequent request address from the CPU to the CPU,
The prefetch buffer is
Branch prediction is performed based on a request address from the CPU, and when it is predicted that a branch will be performed, instructions at a plurality of addresses including a branch destination instruction are prefetched and stored from the memory, and the branch is executed. When the CPU fetches the predicted instruction, the branch prediction result is notified to the CPU.
The CPU
A microprocessor which controls fetching of an instruction from the prefetch buffer based on the branch prediction result notified from the prefetch buffer.
前記プリフェッチバッファは、
前記CPUからの要求アドレスが前記分岐命令と予測した命令のアドレスであるときは、前記CPUが前記要求アドレスの命令をフェッチするときに、その命令が分岐命令であることを予測していることを前記CPUへ通知し、
前記CPUは、
前記プリフェッチバッファから分岐命令であるとの予測を通知された命令をフェッチしたときは、前記プリフェッチバッファからの後続の命令のフェッチを停止し、
前記分岐命令であるとの予測を通知された命令が実行された後に、停止していた命令のフェッチを再開する
ことを特徴とする請求項1に記載のマイクロプロセッサ。
The prefetch buffer is
When the request address from the CPU is the address of the instruction predicted as the branch instruction, when the CPU fetches the instruction at the request address, it is predicted that the instruction is a branch instruction. Notify the CPU,
The CPU
When fetching an instruction that has been notified of a branch instruction from the prefetch buffer, stop fetching subsequent instructions from the prefetch buffer;
2. The microprocessor according to claim 1, wherein fetching of the stopped instruction is resumed after the instruction notified of the branch instruction is executed.
前記CPUは、
プリフェッチバッファへ命令読み出しの要求アドレスを出力するアドレス生成部と、
前記要求アドレスの命令を前記プリフェッチバッファからフェッチするフェッチ部と、
フェッチした命令をデコードするデコード部と、
デコードした命令を実行する実行部と、
前記フェッチ部のフェッチ動作の停止および再開を制御するフェッチ制御部と、
前記実行部で実行した命令が分岐命令であったかどうかを判定する分岐命令検出部と
を有し、
前記フェッチ制御部は、前記フェッチ部がフェッチした命令に対して前記プリフェッチバッファから分岐命令であるとの予測を通知されたときは、前記フェッチ部へ後続の命令のフェッチを停止するよう指示し、前記フェッチ部がフェッチした命令が前記実行部により実行されたときに、前記フェッチ部へ命令のフェッチを再開するよう指示することを特徴とする請求項2に記載のマイクロプロセッサ。
The CPU
An address generation unit that outputs a request address for reading an instruction to a prefetch buffer;
A fetch unit for fetching an instruction at the request address from the prefetch buffer;
A decoding unit for decoding the fetched instruction;
An execution unit for executing the decoded instruction;
A fetch control unit that controls stop and restart of the fetch operation of the fetch unit;
A branch instruction detection unit for determining whether an instruction executed by the execution unit is a branch instruction;
When the fetch control unit is notified of the instruction fetched by the fetch unit as a branch instruction from the prefetch buffer, the fetch control unit instructs the fetch unit to stop fetching subsequent instructions, 3. The microprocessor according to claim 2, wherein when the instruction fetched by the fetch unit is executed by the execution unit, the fetch unit is instructed to resume fetching the instruction.
前記フェッチ制御部は、前記プリフェッチバッファから分岐命令と予測していることを通知された命令が実行される前に、分岐命令検出部により別の分岐が検出されたとき、もしくは、例外あるいは割り込みの発生があったときは、前記フェッチ部へ命令のフェッチを再開するよう指示することを特徴とする請求項3に記載のマイクロプロセッサ。   The fetch control unit detects when another branch is detected by the branch instruction detection unit before the instruction notified from the prefetch buffer that it is predicted to be a branch instruction, or when an exception or an interrupt is detected. 4. The microprocessor according to claim 3, wherein when it occurs, the fetch unit is instructed to resume fetching an instruction. 前記プリフェッチバッファは、前記分岐命令検出部から入力される分岐発生情報をもとに分岐履歴を生成し、前記分岐履歴に基づいて前記CPUからの要求アドレスに対する分岐予測を行うことを特徴とする請求項3に記載のマイクロプロセッサ。   The prefetch buffer generates a branch history based on branch occurrence information input from the branch instruction detection unit, and performs branch prediction for a request address from the CPU based on the branch history. Item 4. The microprocessor according to item 3.
JP2006139234A 2006-05-18 2006-05-18 Microprocessor Withdrawn JP2007310668A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2006139234A JP2007310668A (en) 2006-05-18 2006-05-18 Microprocessor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2006139234A JP2007310668A (en) 2006-05-18 2006-05-18 Microprocessor

Publications (1)

Publication Number Publication Date
JP2007310668A true JP2007310668A (en) 2007-11-29

Family

ID=38843456

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2006139234A Withdrawn JP2007310668A (en) 2006-05-18 2006-05-18 Microprocessor

Country Status (1)

Country Link
JP (1) JP2007310668A (en)

Similar Documents

Publication Publication Date Title
JP5889986B2 (en) System and method for selectively committing the results of executed instructions
JP2009540412A (en) Storage of local and global branch prediction information
JP2018005488A (en) Arithmetic processing unit and control method for arithmetic processing unit
JP5941488B2 (en) Convert conditional short forward branch to computationally equivalent predicate instruction
KR20090094335A (en) Methods and apparatus for recognizing a subroutine call
JP2007041837A (en) Instruction prefetch apparatus and method
JP4864840B2 (en) Microprocessor
US7877578B2 (en) Processing apparatus for storing branch history information in predecode instruction cache
JP2004145454A (en) Information processor and information processing method
JP5233078B2 (en) Processor and processing method thereof
JP5902208B2 (en) Data processing device
US20080065870A1 (en) Information processing apparatus
JP2004334773A (en) Information processing device
JP5209390B2 (en) Information processing apparatus and instruction fetch control method
JP2008299729A (en) Processor
JP2007310668A (en) Microprocessor
JP4728877B2 (en) Microprocessor and pipeline control method
JP5696210B2 (en) Processor and instruction processing method thereof
JP2011081564A (en) Controller, storage device, arithmetic processor, and control method
JP2008015668A (en) Task management device
JP4002288B2 (en) Information processing device
JP5679263B2 (en) Information processing apparatus and microinstruction processing method
JP5292831B2 (en) Programmable controller
JP2006235723A (en) Instruction fetch circuit
JP2007286739A (en) Pre-fetch buffer with branch prediction

Legal Events

Date Code Title Description
A711 Notification of change in applicant

Free format text: JAPANESE INTERMEDIATE CODE: A712

Effective date: 20081226

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20090210

A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20090804