WO2008038373A1 - Processor for increasing the branching prediction speed - Google Patents

Processor for increasing the branching prediction speed Download PDF

Info

Publication number
WO2008038373A1
WO2008038373A1 PCT/JP2006/319339 JP2006319339W WO2008038373A1 WO 2008038373 A1 WO2008038373 A1 WO 2008038373A1 JP 2006319339 W JP2006319339 W JP 2006319339W WO 2008038373 A1 WO2008038373 A1 WO 2008038373A1
Authority
WO
WIPO (PCT)
Prior art keywords
instruction
branch prediction
branch
identification information
task identification
Prior art date
Application number
PCT/JP2006/319339
Other languages
French (fr)
Japanese (ja)
Inventor
Shinichiro Tago
Original Assignee
Fujitsu Limited
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 Fujitsu Limited filed Critical Fujitsu Limited
Priority to PCT/JP2006/319339 priority Critical patent/WO2008038373A1/en
Publication of WO2008038373A1 publication Critical patent/WO2008038373A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3836Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution
    • G06F9/3851Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution from multiple instruction streams, e.g. multistreaming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3802Instruction prefetching
    • G06F9/3804Instruction prefetching for branches, e.g. hedging, branch folding

Definitions

  • the present invention relates to a processor that enables high-speed branch prediction by suppressing BTB (Branch Target Buffer) clearing frequency and entry frequency by task switching.
  • BTB Branch Target Buffer
  • a branch instruction is a factor that degrades the instruction supply performance in a processor that performs a knock-line process.
  • the processor sequentially executes instructions having consecutive normal addresses. However, if a branch instruction is executed and it is decided to branch, the branch destination address must be calculated according to the procedure indicated in the branch instruction and the instruction must be executed by jumping to that address from the next time. Don't be.
  • the processor that performs the pipeline processing performs prefetching of instructions having consecutive normal addresses, and smoothly executes the pipeline processing. After the branch is determined, the branch destination address is calculated and the branch destination is calculated. When the instruction at the address is read and executed, the prefetch instruction that cannot be read remains in the pipeline, and the supply of the branch destination instruction to be executed next is delayed.
  • Branch prediction is a technique for predicting instruction execution order and prefetching instructions to prevent prefetching of instructions and reducing pipeline disruption.
  • BTB is an instruction address that calculates the address of the branch destination instruction in advance when the previous branch is executed in order to provide the address of the branch destination instruction and perform instruction prefetching earlier when a branch is predicted. This is a device that holds the address of the branch destination instruction in correspondence with.
  • a processor When a processor is operated using dynamic address conversion, a plurality of physical addresses may be assigned to one logical address.
  • multiple tasks share a logical address space. For example, as shown in Figure 1, when multiple tasks ⁇ ⁇ ⁇ , ⁇ , ... in the main memory 1 are expanded in the virtual memory space 2. Etc.
  • the present invention has been made in view of such a problem, and BT by task switching.
  • An object of the present invention is to provide a processor capable of high-speed branch prediction by suppressing the B clear frequency and the BTB entry frequency.
  • the present invention provides a processor that prefetches instructions by branch prediction, and includes branch prediction information including a tag indicating an instruction address and task identification information in a storage area used in branch prediction Branch prediction information writing means for writing
  • high-speed branch prediction is enabled by suppressing the frequency of BTB clearing and the frequency of entry to the BTB due to task switching.
  • FIG. 1 is a diagram illustrating an example of a multitask system.
  • FIG. 2 is a block diagram of a processor according to an embodiment of the present invention.
  • ⁇ 1-31—] is a diagram illustrating a first configuration example of branch prediction information entered in the BTB.
  • [4] It is a diagram showing a second configuration example of the branch prediction information entered in the BTB.
  • FIG. 5 is a flowchart for explaining a read operation from a BTB.
  • FIG. 6 is a flowchart for explaining the operation of updating the BTB.
  • FIG. 2 is a block diagram of a processor according to an embodiment of the present invention.
  • the processor 100 includes an instruction cache controller 11, an instruction fetch controller 12, an instruction decoder 13, an instruction execution controller 14, an operation execution unit 15, a load store execution unit 16, and a branch execution.
  • Unit 17, branch prediction unit 18, and BTB (Branch Target Buffer) 19 are provided.
  • BTB 19 a memory device such as RAM (Random Access Memory) is used.
  • the instruction cache controller 12 reads an instruction from the cache memory in response to an instruction fetch request from the instruction fetch controller 13.
  • the instruction fetch controller 13 reads an instruction from the instruction cache controller 12 by making an instruction fetch request using an address to the instruction fetch controller 12.
  • the instruction fetch controller 13 issues a read request for the branch prediction information entered in the BTB 19, and if it is branch prediction information corresponding to the fetched instruction (BTB hit), the instruction fetch controller 13 Request branch prediction for the instruction.
  • the instruction fetch controller 13 adds a processing result related to branch prediction to the instruction acquired from the instruction cache controller 12 and sends the result to the instruction decoder 13.
  • the instruction decoder 13 decodes the instruction and sends it to the instruction execution controller 14.
  • the instruction execution controller 14 sends the instruction decoded by the instruction decoder 13 to any one of the operation execution unit 15, the load store execution unit 16, or the branch execution unit 17 according to the type of instruction.
  • the branch execution unit 17 executes a branch instruction and determines whether or not a branch is possible. If the branch execution unit 17 determines to branch, branch prediction information is entered into the BTB 19, and the instruction fetch controller 12 fetches the instruction at the branch destination address. On the other hand, if the branch execution unit 17 determines not to branch, the instruction fetch controller 12 fetches the instruction at the sequential next address without branching.
  • FIG. 3 is a diagram illustrating a first configuration example of the branch prediction information entered in the BTB.
  • branch prediction information 5 is registered in BTB19.
  • Tag comparison data 6a is generated by the current task ID stored in the register 20 by the OS (Operating System) and the address tag based on the address of the branch instruction.
  • Branch prediction information 5 including a Valid flag having a value "1", tag comparison data 6a based on the current task ID and address tag, and a branch destination address is registered in the BTB 19. The value of the Valid flag of branch prediction information 5 registered in BTB19 is then updated as necessary.
  • the tag comparison data 6b is generated from the current task ID stored in the register 20 and the address tag based on the address of the branch instruction that also fetches the cache power. . And branch prediction information read from BTB19 If the valid flag power of 5 is “l” and the data consisting of the task ID and address tag of branch prediction information 5 matches the tag comparison data 6b, it is determined that the BTB has been hit.
  • the branch prediction information 5 stored in BTB19 by task A becomes available again when task A power is switched to task B and then switched to task A. It is possible to improve the processing efficiency without having to re-entry prediction information.
  • FIG. 4 is a diagram showing a second configuration example of the branch prediction information entered in the BTB.
  • tag comparison data 6-2a is generated by performing a predetermined calculation using a part of the address tag and the current task ID stored in the register 20.
  • This tag comparison data 6-2a is an address tag having a shorter bit length than the tag comparison data 6a based on the task ID and address tag shown in FIG.
  • the branch prediction information 5-2 consisting of the Valid flag with the value "1", tag comparison data 6-2a based on the current task ID and address tag, and the branch destination address, is registered in BTB19. It is done. The value of the Valid flag in the branch prediction information 5-2 registered in BTB19 is then updated as necessary.
  • tag comparison data 6-2b is determined by the current task ID stored in register 20 and the address tag based on the address of the branch instruction fetched from the cache. Is generated. And the valid flag power of branch prediction information 5-2 read from BTB19 is “l”, and the data with the task ID and address tag of branch prediction information 5-2 matches the tag comparison data 6-2b If it does, branch prediction information 5-2 corresponding to the instruction of the current task is determined (BTB hit).
  • the operation executed at the time of registration and reading is, for example, an EOR (exclusive logic) operation.
  • an EOR operation may be performed using the upper address of the branch instruction and the task ID.
  • the operation executed at the time of registration and reading may be an operation that sets the task ID to the upper address of the branch instruction.
  • the task ID can be included without increasing the storage area of the BTB 19. Moreover, it is possible to prevent the branch prediction information 5-2 from being used accidentally by switching tasks.
  • branch prediction information 5 or 5-2 stored in the BTB 19 is not invalidated.
  • branch prediction information 5 or 5-2 can be used without registering again. Therefore, it is possible to eliminate the waste of processing, and the processing related to branch prediction can be performed at high speed.
  • FIGS. 5 and 6 the same processing is possible in the first configuration example shown in FIG. 3, which will be described based on the second configuration example shown in FIG.
  • FIG. 5 is a flowchart for explaining an operation of reading BTB force branch prediction information.
  • an instruction fetch request is sent from the instruction fetch controller 12 to the instruction cache controller 11 to acquire an instruction (step S11).
  • a read request is made from the instruction fetch controller 12 to the BTB 19 (step S12).
  • the instruction fetch controller 12 generates tag comparison data 6-2b with the current task ID, the address at which the instruction was fetched, and the power. (Step S13).
  • the instruction fetch controller 12 determines whether or not the Valid flag of the branch prediction information 5 read from the BTB 19 is "1" and the address tag matches the tag comparison data 6-2b (Ste S14). Branch prediction information read from BTB19 5—Valid flag of S-2 If S is not “l” or the address tag does not match tag comparison data 6—2b (BTB miss), branch prediction satisfies the branch condition It is “not-taken” indicating that it is predicted not to The instruction fetch controller 12 causes the instruction cache controller 11 to sequentially fetch the instruction at the next address (step S14-2), and returns to step S12.
  • step S15 if the valid flag of the branch prediction information 5-2 read from the BTB 19 is “1” and the address tag matches the tag comparison data 6-2b in step S14 (BTB hit).
  • the instruction fetch controller 12 obtains the branch prediction direction from the branch prediction unit by sending the address fetched instruction to the branch prediction unit 18, and the branch prediction direction predicts that the branch condition is satisfied. It is determined whether or not the force indicates “taken” (step S15).
  • step S15 if the branch prediction direction indicates "not-taken" in which the branch condition is predicted not to be satisfied, the instruction fetch controller 12 sequentially sends the next address to the instruction cache controller 11. Is fetched (step S16), and the process returns to step S12.
  • step S16 the instruction fetch controller 12 reads the branch prediction address 5-2 of the branch prediction information 5-2 read from the BTB 19 into the instruction cache controller 11. Is fetched (step S16), and the process returns to step S12.
  • FIG. 6 is a flowchart for explaining the operation of updating the BTB.
  • the instruction execution controller 14 instructs the execution unit 15, the load / store execution unit 16, or the branch execution unit 17 to execute depending on the type of instruction sent from the instruction decoder 13 (step S 21 ), It is determined whether or not the instruction to be executed hits BTB19 at the time of instruction fetch (step S22).
  • step S23 it is determined whether the instruction to be executed is a branch instruction. If the instruction to be executed is a branch instruction, BTB update is not performed (step S24), and the BTB update operation is terminated. On the other hand, if the instruction to be executed is other than a branch instruction, the branch prediction information 5-2 of the hit BTB 19 is invalidated (step S25). Write "0" to the Valid flag in this branch prediction information 5-2 to end the BTB update operation.
  • step S26 It is determined whether the instruction to be executed is a branch instruction (step S26). Task ID mismatch is included as a case where the instruction to be executed does not hit BTB19. If it is a branch instruction, the branch instruction executed by the branch execution unit 17 is registered in the BTB 19 (step S27).
  • step S272 the current task ID and branch instruction address force tag comparison data 6a are generated (step S272), and the branch destination address is calculated (step S274).
  • step S274 the branch prediction information 5-2 including the Valid flag with the value “1”, the tag comparison data 6a, and the branch destination address is written to BT B19 (step S276), and the operation of registering in BTB19 is terminated. . Also, the operation of updating BTB 19 is ended.
  • step S26 If it is determined that the instruction to be executed in step S26 is other than a branch instruction, BTB update is not performed (step S28), and the BTB update operation is terminated. In other words, clearing of BTB19 is suppressed.
  • steps S23, S24, and S25 are processing when the current task ID of the instruction to be executed matches the task ID of the branch prediction information 5-2 read from BTB19.
  • steps S26, S27 and S28 are performed when the current task ID of the instruction to be executed does not match the task ID of the branch prediction information 5-2 from which the BTB 19 force is also read, or the fetched instruction This is executed when the address and branch prediction information 5-2 address do not match.
  • Step S27 is a registration process to the BTB 19 that is performed when a certain branch instruction is executed for the first time.
  • step S28 even if the task IDs do not match, the BTB update is not performed. Therefore, the branch prediction information 5-2 read from the BTB 19 in step S14 in Fig. 5 has the Valid flag set to "1". It will be left in BTB19. Therefore, when returning to the original task, the branch prediction information 5-2 can be used without reentry.
  • the branch prediction is regarded as “not-taken”, and the instruction b2 at the address 4 following the address 0 is fetched (step S14-2 in FIG. 5). Thereafter, since the instructions bl and b2 are arithmetic instructions, the arithmetic execution unit 15 executes the arithmetic. In this case, since the executed instructions bl and b2 are other than branch instructions, the BTB update is not performed (step S28 in FIG. 6).
  • the value "0" is obtained by the EOR operation between the upper address "0" of the current instruction and the current task ID "0", and the branch prediction information 5-2 read from the BTB19 By comparing the upper address of the address tag with “0” (Fig. 4), a task ID match is obtained.
  • branch prediction Since branch prediction is performed and the branch direction is indicated, the instruction at the branch prediction destination address 30 is fetched to obtain instruction j (step S16 in FIG. 5). After that, the branch is performed with the instruction a, the branch prediction is hit, and then the instruction j is executed. Therefore, even if a task ID mismatch occurs, the branch prediction information 5 entered in the BTB 19 is not cleared, so that it is possible to efficiently process after switching to the original task. In addition, it is possible to prevent misreading of branch prediction information 5 due to task ID mismatch.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Advance Control (AREA)

Abstract

In a processor for looking-ahead an instruction by a branching prediction, branching prediction information indicating a command address and a task identifier is written in a storage region used for branching prediction.

Description

明 細 書  Specification
分岐予測を高速化するプロセッサ  Processor that speeds up branch prediction
技術分野  Technical field
[0001] 本発明は、タスクの切り替えによる BTB (Branch Target Buffer)のクリア頻度及びェ ントリ頻度を抑止することによって分岐予測の高速ィ匕を可能とするプロセッサに関す る。  The present invention relates to a processor that enables high-speed branch prediction by suppressing BTB (Branch Target Buffer) clearing frequency and entry frequency by task switching.
背景技術  Background art
[0002] ノ ィプライン処理を行うプロセッサにお 、て命令供給性能を低下させる要因として 分岐命令がある。プロセッサは、通常アドレスの連続する命令を順次実行していく。し かし、分岐命令が実行され、分岐することが決まった場合には、分岐命令に示された 手順で分岐先のアドレスを算出し、次回よりそのアドレスに飛んで命令を実行しなけ ればならない。  [0002] A branch instruction is a factor that degrades the instruction supply performance in a processor that performs a knock-line process. The processor sequentially executes instructions having consecutive normal addresses. However, if a branch instruction is executed and it is decided to branch, the branch destination address must be calculated according to the procedure indicated in the branch instruction and the instruction must be executed by jumping to that address from the next time. Don't be.
[0003] ノ ィプライン処理を行うプロセッサは、通常アドレスの連続する命令の先読みを行 い、パイプライン処理をスムースに動作させるのだ力 分岐が決定した後で分岐先ァ ドレスを算出して分岐先アドレスの命令を読み出し実行するとなると、読み出してはい けない先読み命令がパイプラインに残り、次に実行するべき分岐先の命令の供給が 遅れる。  [0003] The processor that performs the pipeline processing performs prefetching of instructions having consecutive normal addresses, and smoothly executes the pipeline processing. After the branch is determined, the branch destination address is calculated and the branch destination is calculated. When the instruction at the address is read and executed, the prefetch instruction that cannot be read remains in the pipeline, and the supply of the branch destination instruction to be executed next is delayed.
[0004] この問題を回避するために分岐予測手法と BTB (Branch Target Buffer)とを使うこ とはよく知られている。分岐予測とは、命令実行順序を予測し、命令の先読みを行う ことにより実行しな 、命令の先読みを防ぎ、パイプラインの乱れを削減する手法であ る。 BTBとは、分岐と予測された場合に、より早く分岐先命令のアドレスを提供し命令 先読みを行うために、前回分岐が実行されたときに予め分岐先命令のアドレスを算 出して、命令アドレスに対応させて分岐先命令のアドレスを保持しておく装置である。  [0004] It is well known to use a branch prediction method and BTB (Branch Target Buffer) to avoid this problem. Branch prediction is a technique for predicting instruction execution order and prefetching instructions to prevent prefetching of instructions and reducing pipeline disruption. BTB is an instruction address that calculates the address of the branch destination instruction in advance when the previous branch is executed in order to provide the address of the branch destination instruction and perform instruction prefetching earlier when a branch is predicted. This is a device that holds the address of the branch destination instruction in correspondence with.
[0005] 動的なアドレス変 能を使ってプロセッサを動作させるときには、 1つの論理アド レスに対して複数の物理アドレスが割り当てられることがある。特に、マルチタスクシス テムにおいては、複数のタスクが論理アドレス空間を共有する。例えば、図 1に示すよ うに、メインメモリ 1内の複数のタスク Α、 Β、 · · ·が仮想メモリ空間 2に展開される場合 などである。 [0005] When a processor is operated using dynamic address conversion, a plurality of physical addresses may be assigned to one logical address. In particular, in a multitasking system, multiple tasks share a logical address space. For example, as shown in Figure 1, when multiple tasks メ イ ン, Β, ... in the main memory 1 are expanded in the virtual memory space 2. Etc.
[0006] 通常、 BTBは論理アドレスを用いている。そのため、 BTBへの入力アドレスが共有 空間であった場合、 BTB力 読み出したデータが他のタスクの分岐命令の情報であ る可能性がある。もし他のタスクの分岐命令を読み出してしまった場合、分岐命令で はな 、にも関わらず、 BTBに格納されて ヽる分岐先と予測した命令を先読みしてしま う場合が発生する。従来、誤って BTB力 他のタスクの分岐命令を読み出さないよう に、タスクが切り替わるたびに命令で BTBをクリアしたり、一度 BTBの読み間違いが 発生したら BTBをクリアするなどの手法が用いられて 、た (例えば、特許文献 1)。 特許文献 1 :特開平 8— 249181号公報  [0006] Normally, BTB uses logical addresses. For this reason, if the input address to the BTB is a shared space, the data read out by the BTB may be information on branch instructions of other tasks. If a branch instruction of another task is read, the instruction that is predicted to be the branch destination stored in the BTB may be prefetched even though it is not a branch instruction. Conventionally, methods have been used such as clearing the BTB every time the task is switched, or clearing the BTB once a BTB reading error has occurred, so as not to accidentally read the branch instruction of another task. (For example, Patent Document 1). Patent Document 1: JP-A-8-249181
発明の開示  Disclosure of the invention
発明が解決しょうとする課題  Problems to be solved by the invention
[0007] しかしながら、上述した従来の手法では、マルチタスクシステムにおいてタスク切り 替えが頻繁に起こる場合、 BTBのクリア頻度が高くなり、分岐予測自体ができない状 態が多くなつてしまうといった問題があった。 [0007] However, in the conventional method described above, when task switching occurs frequently in a multitask system, there is a problem that the frequency of BTB clearing increases and there are many states in which branch prediction itself cannot be performed. .
[0008] 本発明はこのような問題点に鑑みてなされたものであり、タスクの切り替えによる BT[0008] The present invention has been made in view of such a problem, and BT by task switching.
Bのクリア頻度及び BTBへのエントリ頻度を抑止することによって分岐予測の高速ィ匕 を可能とするプロセッサを提供することを目的とする。 An object of the present invention is to provide a processor capable of high-speed branch prediction by suppressing the B clear frequency and the BTB entry frequency.
課題を解決するための手段  Means for solving the problem
[0009] 上記課題を解決するため、本発明は、分岐予測により命令を先読みするプロセッサ であって、分岐予測で使用される記憶領域に命令アドレスとタスク識別情報とを示す タグを含む分岐予測情報を書き込む分岐予測情報書込手段を有するように構成され る。 In order to solve the above problems, the present invention provides a processor that prefetches instructions by branch prediction, and includes branch prediction information including a tag indicating an instruction address and task identification information in a storage area used in branch prediction Branch prediction information writing means for writing
発明の効果  The invention's effect
[0010] 本発明によれば、タスクの切り替えによる BTBのクリア頻度及び BTBへのエントリ頻 度を抑止することによって分岐予測の高速ィ匕を可能とする。  [0010] According to the present invention, high-speed branch prediction is enabled by suppressing the frequency of BTB clearing and the frequency of entry to the BTB due to task switching.
図面の簡単な説明  Brief Description of Drawings
[0011] [図 1]マルチタスクシステムの例を示す図である。 O FIG. 1 is a diagram illustrating an example of a multitask system. O
[図 2]本発明の一実施例に係るプロセッサの構成図である。  FIG. 2 is a block diagram of a processor according to an embodiment of the present invention.
圆1— 31—]BTBにエントリされる分岐予測情報の第一の構成例を示す図である。  圆 1-31—] is a diagram illustrating a first configuration example of branch prediction information entered in the BTB.
圆 4]BTBにエントリされる分岐予測情報の第二の構成例を示す図である。  [4] It is a diagram showing a second configuration example of the branch prediction information entered in the BTB.
[図 5]BTBからの読み出し動作を説明するためのフローチャート図である。  FIG. 5 is a flowchart for explaining a read operation from a BTB.
[図 6]BTBを更新する動作を説明するためのフローチャート図である。  FIG. 6 is a flowchart for explaining the operation of updating the BTB.
符号の説明  Explanation of symbols
命令キャッシュコントローラ  Instruction cache controller
12 命令フェッチコントローラ  12 Instruction fetch controller
13 命令でコーダ  13 Coders with instructions
14 命令実行コントローラ  14 Instruction execution controller
15 演算実行ユニット  15 Arithmetic execution unit
16 ロードストア実行ユニット  16 Load store execution unit
17 分岐実行ユニット  17 Branch execution unit
18 分岐予測ユニット  18 Branch prediction unit
19 BTB (Branch Target Bulfer  19 BTB (Branch Target Bulfer
20 現在のタスク ID用レジスタ  20 Current task ID register
100 プロセッサ  100 processor
発明を実施するための最良の形態  BEST MODE FOR CARRYING OUT THE INVENTION
[0013] 以下、本発明の実施の形態を図面に基づいて説明する。本発明は、図 1に示すよう なマルチタスクシステムにお 、て実現される。  Hereinafter, embodiments of the present invention will be described with reference to the drawings. The present invention is realized in a multitask system as shown in FIG.
[0014] 図 2は、本発明の一実施例に係るプロセッサの構成図である。図 2において、プロセ ッサ 100は、命令キャッシュコントローラ 11と、命令フェッチコントローラ 12と、命令デ コーダ 13と、命令実行コントローラ 14と、演算実行ユニット 15と、ロードストア実行ュ ニット 16と、分岐実行ユニット 17と、分岐予測ユニット 18と、 BTB (Branch Target Buff er) 19とを備えている。 BTB 19として RAM (Random Access Memory)などのメモリ装 置が用いられる。  FIG. 2 is a block diagram of a processor according to an embodiment of the present invention. In FIG. 2, the processor 100 includes an instruction cache controller 11, an instruction fetch controller 12, an instruction decoder 13, an instruction execution controller 14, an operation execution unit 15, a load store execution unit 16, and a branch execution. Unit 17, branch prediction unit 18, and BTB (Branch Target Buffer) 19 are provided. As BTB 19, a memory device such as RAM (Random Access Memory) is used.
[0015] 命令キャッシュコントローラ 12は、命令フェッチコントローラ 13からの命令フェッチ要 求に応じてキャッシュメモリから命令を読み出す。 [0016] 命令フェッチコントローラ 13は、アドレスを用いた命令フェッチ要求を命令フェッチ コントローラ 12に行うことによって、命令キャッシュコントローラ 12から命令を読み出す 。同時に、命令フェッチコントローラ 13は、 BTB19にエントリされている分岐予測情 報の読み出し要求を行い、フェッチした命令に対応する分岐予測情報である(BTBヒ ット)場合に分岐予測ユニット 18に対してその命令の分岐予測を要求する。 The instruction cache controller 12 reads an instruction from the cache memory in response to an instruction fetch request from the instruction fetch controller 13. The instruction fetch controller 13 reads an instruction from the instruction cache controller 12 by making an instruction fetch request using an address to the instruction fetch controller 12. At the same time, the instruction fetch controller 13 issues a read request for the branch prediction information entered in the BTB 19, and if it is branch prediction information corresponding to the fetched instruction (BTB hit), the instruction fetch controller 13 Request branch prediction for the instruction.
[0017] 命令フェッチコントローラ 13は、命令キャッシュコントローラ 12から取得した命令に、 分岐予測に係る処理結果を付加して、命令デコーダ 13に送出する。命令デコーダ 1 3は、命令をデコードして命令実行コントローラ 14に送出する。  The instruction fetch controller 13 adds a processing result related to branch prediction to the instruction acquired from the instruction cache controller 12 and sends the result to the instruction decoder 13. The instruction decoder 13 decodes the instruction and sends it to the instruction execution controller 14.
[0018] 命令実行コントローラ 14は、命令の種類に応じて、演算実行ユニット 15、ロードスト ァ実行ユニット 16、又は分岐実行ユニット 17のいずれかに命令デコーダ 13によって デコードされた命令を送出する。  The instruction execution controller 14 sends the instruction decoded by the instruction decoder 13 to any one of the operation execution unit 15, the load store execution unit 16, or the branch execution unit 17 according to the type of instruction.
[0019] 分岐実行ユニット 17は、分岐命令を実行し、分岐がなされる力否かを判定する。分 岐実行ユニット 17が分岐すると判定した場合、 BTB19へ分岐予測情報がエントリさ れ、命令フェッチコントローラ 12によって分岐先アドレスの命令がフェッチされる。一 方、分岐実行ユニット 17が分岐しないと判定した場合、命令フェッチコントローラ 12 によって分岐せずシーケンシャルな次のアドレスの命令がフェッチされる。  [0019] The branch execution unit 17 executes a branch instruction and determines whether or not a branch is possible. If the branch execution unit 17 determines to branch, branch prediction information is entered into the BTB 19, and the instruction fetch controller 12 fetches the instruction at the branch destination address. On the other hand, if the branch execution unit 17 determines not to branch, the instruction fetch controller 12 fetches the instruction at the sequential next address without branching.
[0020] BTB19にエントリされる分岐予測情報の構成について図 3及び図 4で説明する。図 3は、 BTBにエントリされる分岐予測情報の第一の構成例を示す図である。図 3にお いて、初めて分岐命令が実行されると分岐予測情報 5が BTB19に登録される。 OS ( Operating System)によってレジスタ 20に格納された現在のタスク IDと分岐命令のァ ドレスに基づくアドレスタグとによって、タグ比較用データ 6aが生成される。  The configuration of the branch prediction information entered in the BTB 19 will be described with reference to FIGS. FIG. 3 is a diagram illustrating a first configuration example of the branch prediction information entered in the BTB. In Figure 3, when the first branch instruction is executed, branch prediction information 5 is registered in BTB19. Tag comparison data 6a is generated by the current task ID stored in the register 20 by the OS (Operating System) and the address tag based on the address of the branch instruction.
[0021] 値「1」の Validフラグと、現在のタスク IDとアドレスタグとによるタグ比較用データ 6a と、分岐先アドレスとで構成される分岐予測情報 5が、 BTB19に登録される。 BTB19 に登録された分岐予測情報 5の Validフラグの値は、その後必要に応じて更新される  [0021] Branch prediction information 5 including a Valid flag having a value "1", tag comparison data 6a based on the current task ID and address tag, and a branch destination address is registered in the BTB 19. The value of the Valid flag of branch prediction information 5 registered in BTB19 is then updated as necessary.
[0022] BTB19から分岐予測情報 5が読み出されると、レジスタ 20に格納された現在のタス ク IDとキャッシュ力もフェッチした分岐命令のアドレスに基づくアドレスタグとによって 、タグ比較用データ 6bが生成される。そして、 BTB19から読み出した分岐予測情報 5の Validフラグ力 「l」であり、かつ、分岐予測情報 5のタスク IDとアドレスタグとでなる データがタグ比較用データ 6bと一致する場合、 BTBにヒットしたと判断される。 [0022] When the branch prediction information 5 is read from the BTB 19, the tag comparison data 6b is generated from the current task ID stored in the register 20 and the address tag based on the address of the branch instruction that also fetches the cache power. . And branch prediction information read from BTB19 If the valid flag power of 5 is “l” and the data consisting of the task ID and address tag of branch prediction information 5 matches the tag comparison data 6b, it is determined that the BTB has been hit.
[0023] 本実施例では、分岐予測情報 5のタスク IDとアドレスタグとでなるデータがタグ比較 用データ 6bと一致しない場合、キャッシュミスと判定せず、 Validフラグを値「1」のまま とし、この分岐予測情報 5を BTB19に残しておく。その後、タスクが切り替わった後、 この分岐予測情報 5を有効に利用することが可能となる。  [0023] In this embodiment, if the data consisting of the task ID and address tag of the branch prediction information 5 does not match the tag comparison data 6b, the cache flag is not judged to be valid and the Valid flag is left as "1". This branch prediction information 5 is left in BTB19. After that, after the task is switched, this branch prediction information 5 can be used effectively.
[0024] すなわち、図 1において、タスク Aで BTB19に格納した分岐予測情報 5が、タスク A 力もタスク Bへ切り替わった後再度タスク Aへ切り替わった際に、再度利用可能となる ため、同一の分岐予測情報を再エントリする必要がなぐ処理効率を向上させること ができる。  [0024] That is, in FIG. 1, the branch prediction information 5 stored in BTB19 by task A becomes available again when task A power is switched to task B and then switched to task A. It is possible to improve the processing efficiency without having to re-entry prediction information.
[0025] BTB19の記憶領域を有効に利用するために、図 3に示す分岐予測情報 5を図 4に 示すように構成することができる。図 4は、 BTBにエントリされる分岐予測情報の第二 の構成例を示す図である。図 4に示す第二の構成例では、アドレスタグの一部とレジ スタ 20に格納されている現在のタスク IDとを用いて所定演算を行ってタグ比較用デ ータ 6— 2aを生成する。このタグ比較用データ 6— 2aは、図 3に示すタスク IDとァドレ スタグとによるタグ比較用データ 6aと比べるとビット長の短いアドレスタグとなる。  In order to effectively use the storage area of the BTB 19, the branch prediction information 5 shown in FIG. 3 can be configured as shown in FIG. FIG. 4 is a diagram showing a second configuration example of the branch prediction information entered in the BTB. In the second configuration example shown in FIG. 4, tag comparison data 6-2a is generated by performing a predetermined calculation using a part of the address tag and the current task ID stored in the register 20. . This tag comparison data 6-2a is an address tag having a shorter bit length than the tag comparison data 6a based on the task ID and address tag shown in FIG.
[0026] 値「1」の Validフラグと、現在のタスク IDとアドレスタグとに基づくタグ比較用データ 6— 2aと、分岐先アドレスとで構成される分岐予測情報 5— 2が、 BTB19に登録され る。 BTB19に登録された分岐予測情報 5— 2の Validフラグの値は、その後必要に 応じて更新される。  [0026] The branch prediction information 5-2, consisting of the Valid flag with the value "1", tag comparison data 6-2a based on the current task ID and address tag, and the branch destination address, is registered in BTB19. It is done. The value of the Valid flag in the branch prediction information 5-2 registered in BTB19 is then updated as necessary.
[0027] BTB19から分岐予測情報 5— 2が読み出されると、レジスタ 20に格納された現在 のタスク IDとキャッシュからフェッチした分岐命令のアドレスに基づくアドレスタグとに よって、タグ比較用データ 6— 2bが生成される。そして、 BTB19から読み出した分岐 予測情報 5— 2の Validフラグ力 「l」であり、かつ、分岐予測情報 5— 2のタスク IDとァ ドレスタグとでなるデータがタグ比較用データ 6— 2bと一致する場合、現在のタスクの 命令に対応した分岐予測情報 5— 2である(BTBにヒットした)と判断される。  [0027] When branch prediction information 5-2 is read from BTB19, tag comparison data 6-2b is determined by the current task ID stored in register 20 and the address tag based on the address of the branch instruction fetched from the cache. Is generated. And the valid flag power of branch prediction information 5-2 read from BTB19 is “l”, and the data with the task ID and address tag of branch prediction information 5-2 matches the tag comparison data 6-2b If it does, branch prediction information 5-2 corresponding to the instruction of the current task is determined (BTB hit).
[0028] 本実施例では、分岐予測情報 5— 2のタスク IDとアドレスタグとでなるデータがタグ 比較用データ 6— 2bと一致しない場合、キャッシュミスと判定せず、 Validフラグを値「 1」のままとし、この分岐予測情報 5— 2を BTB19に残しておく。その後、タスクが切り 替わった後、この分岐予測情報 5— 2を有効に利用することが可能となる。 In this embodiment, if the data consisting of the task ID and address tag of the branch prediction information 5-2 does not match the tag comparison data 6-2b, it is not determined as a cache miss and the Valid flag is set to “ Leave “1”, and leave this branch prediction information 5-2 in BTB19. After the task is switched, this branch prediction information 5-2 can be used effectively.
[0029] 登録時及び読出時に実行される演算は、例えば、 EOR (排他的論理)演算である。  [0029] The operation executed at the time of registration and reading is, for example, an EOR (exclusive logic) operation.
この場合、情報量の少な 、分岐命令の上位アドレスとタスク IDとで EOR演算すれば よい。或いは、登録時及び読出時に実行される演算は、タスク IDを分岐命令の上位 アドレスに設定するような演算であってもよい。  In this case, if the amount of information is small, an EOR operation may be performed using the upper address of the branch instruction and the task ID. Alternatively, the operation executed at the time of registration and reading may be an operation that sets the task ID to the upper address of the branch instruction.
[0030] 上述したような分岐予測情報 5— 2の構成によって、 BTB 19の記憶領域を増加させ ることなくタスク IDを含めることができる。また、タスクの切り替えによって誤って分岐 予測情報 5 - 2を使用してしまうことを防止することができる。  [0030] With the configuration of the branch prediction information 5-2 as described above, the task ID can be included without increasing the storage area of the BTB 19. Moreover, it is possible to prevent the branch prediction information 5-2 from being used accidentally by switching tasks.
[0031] また、図 3及び図 4で説明したように、タスク IDがー致しない場合においても、 BTB 19に格納されて 、る分岐予測情報 5又は 5— 2を無効としな 、ため、元のタスクに戻 つた際に、再度登録することなく分岐予測情報 5又は 5— 2を使用することができる。 従って、処理の無駄を省くことが可能となり、分岐予測に係る処理を高速可させること ができる。  [0031] As described with reference to FIGS. 3 and 4, even when the task ID does not match, the branch prediction information 5 or 5-2 stored in the BTB 19 is not invalidated. When returning to this task, branch prediction information 5 or 5-2 can be used without registering again. Therefore, it is possible to eliminate the waste of processing, and the processing related to branch prediction can be performed at high speed.
[0032] 次に、 BTB19からの分岐予測情報の読み出し動作及び更新動作について図 5及 び図 6で説明する。図 5及び図 6中、図 4に示す第二の構成例に基づいて説明する 力 図 3に示す第一の構成例においても同様の処理が可能である。  Next, the read operation and update operation of the branch prediction information from the BTB 19 will be described with reference to FIG. 5 and FIG. In FIGS. 5 and 6, the same processing is possible in the first configuration example shown in FIG. 3, which will be described based on the second configuration example shown in FIG.
[0033] 図 5は、 BTB力 分岐予測情報を読み出す動作を説明するためのフローチャート 図である。図 5において、命令フェッチコントローラ 12から命令キャッシュコントローラ 11に命令フェッチ要求を行って命令を取得する (ステップ S11)。  FIG. 5 is a flowchart for explaining an operation of reading BTB force branch prediction information. In FIG. 5, an instruction fetch request is sent from the instruction fetch controller 12 to the instruction cache controller 11 to acquire an instruction (step S11).
[0034] 次に、命令フェッチコントローラ 12から BTB19に読み出し要求がなされる (ステップ S12) 0命令フェッチコントローラ 12は、現在のタスク IDと命令をフェッチしたアドレス と力もタグ比較用データ 6 - 2bを生成する(ステップ S 13)。 [0034] Next, a read request is made from the instruction fetch controller 12 to the BTB 19 (step S12). 0 The instruction fetch controller 12 generates tag comparison data 6-2b with the current task ID, the address at which the instruction was fetched, and the power. (Step S13).
[0035] 命令フェッチコントローラ 12は、 BTB19から読み出した分岐予測情報 5の Validフ ラグが「1」であり、かつ、アドレスタグがタグ比較用データ 6— 2bと一致するか否かを 判断する (ステップ S14)。 BTB19から読み出した分岐予測情報 5— 2の Validフラグ 力 S「l」でないか、又は、アドレスタグがタグ比較用データ 6— 2bと一致しない場合 (B TBミス)、分岐予測は分岐条件が成立しないと予測したことを示す「not-taken」であ るとみなし、命令フェッチコントローラ 12は、命令キャッシュコントローラ 11にシーケン シャルに次のアドレスの命令をフェッチさせ (ステップ S 14— 2)、ステップ S 12へと戻 る。 [0035] The instruction fetch controller 12 determines whether or not the Valid flag of the branch prediction information 5 read from the BTB 19 is "1" and the address tag matches the tag comparison data 6-2b ( Step S14). Branch prediction information read from BTB19 5—Valid flag of S-2 If S is not “l” or the address tag does not match tag comparison data 6—2b (BTB miss), branch prediction satisfies the branch condition It is “not-taken” indicating that it is predicted not to The instruction fetch controller 12 causes the instruction cache controller 11 to sequentially fetch the instruction at the next address (step S14-2), and returns to step S12.
[0036] 一方、ステップ S14にて、 BTB19から読み出した分岐予測情報 5— 2の Validフラ グが「1」であり、かつ、アドレスタグがタグ比較用データ 6— 2bと一致する場合(BTB ヒット)、命令フェッチコントローラ 12は、分岐予測ユニット 18に命令をフェッチしたァ ドレスを送出することによって分岐予測ユニットから分岐予測方向を取得して、その分 岐予測方向が、分岐条件が成立すると予測した「taken」を示す力否かを判断する (ス テツプ S 15)。  [0036] On the other hand, if the valid flag of the branch prediction information 5-2 read from the BTB 19 is “1” and the address tag matches the tag comparison data 6-2b in step S14 (BTB hit The instruction fetch controller 12 obtains the branch prediction direction from the branch prediction unit by sending the address fetched instruction to the branch prediction unit 18, and the branch prediction direction predicts that the branch condition is satisfied. It is determined whether or not the force indicates “taken” (step S15).
[0037] ステップ S 15にお!/、て、分岐予測方向が分岐条件が不成立と予測した「not-taken」 を示す場合、命令フェッチコントローラ 12は、命令キャッシュコントローラ 11にシーケ ンシャルに次のアドレスの命令をフェッチさせて(ステップ S 16)、ステップ S12へと戻 る。  [0037] In step S15, if the branch prediction direction indicates "not-taken" in which the branch condition is predicted not to be satisfied, the instruction fetch controller 12 sequentially sends the next address to the instruction cache controller 11. Is fetched (step S16), and the process returns to step S12.
[0038] 一方、分岐予測方向が分岐条件が成立と予測した「taken」を示す場合、命令フェツ チコントローラ 12は、命令キャッシュコントローラ 11に BTB19から読み出した分岐予 測情報 5— 2の分岐先アドレスの命令をフェッチさせて(ステップ S 16)、ステップ S 12 へと戻る。  [0038] On the other hand, when the branch prediction direction indicates “taken” predicted to satisfy the branch condition, the instruction fetch controller 12 reads the branch prediction address 5-2 of the branch prediction information 5-2 read from the BTB 19 into the instruction cache controller 11. Is fetched (step S16), and the process returns to step S12.
[0039] 図 6は、 BTBを更新する動作を説明するためのフローチャート図である。図 6におい て、命令実行コントローラ 14で、命令デコーダ 13から送出された命令の種類に応じ て演算実行ユニット 15、ロードストア実行ユニット 16、分岐実行ユニット 17のいずれ かに実行を指示し (ステップ S21)、実行する命令が命令フェッチ時に BTB19にヒット して 、たか否かを判断する (ステップ S22)。  FIG. 6 is a flowchart for explaining the operation of updating the BTB. In FIG. 6, the instruction execution controller 14 instructs the execution unit 15, the load / store execution unit 16, or the branch execution unit 17 to execute depending on the type of instruction sent from the instruction decoder 13 (step S 21 ), It is determined whether or not the instruction to be executed hits BTB19 at the time of instruction fetch (step S22).
[0040] BTB19にヒットして ヽた場合、実行する命令は分岐命令カゝ否かを判断する (ステツ プ S23)。実行する命令は分岐命令である場合、 BTB更新を行わず (ステップ S24) 、 BTB更新の動作を終了する。一方、実行する命令は分岐命令以外である場合、ヒ ットした BTB19の分岐予測情報 5— 2を無効化する (ステップ S25)。この分岐予測情 報 5 - 2の Validフラグに "0 "を書き込み、 BTB更新の動作を終了する。  [0040] If BTB19 is hit, it is determined whether the instruction to be executed is a branch instruction (step S23). If the instruction to be executed is a branch instruction, BTB update is not performed (step S24), and the BTB update operation is terminated. On the other hand, if the instruction to be executed is other than a branch instruction, the branch prediction information 5-2 of the hit BTB 19 is invalidated (step S25). Write "0" to the Valid flag in this branch prediction information 5-2 to end the BTB update operation.
[0041] 一方、ステップ S22において、実行する命令が BTB19にヒットしていない場合、実 行する命令は分岐命令か否かを判断する (ステップ S26)。実行する命令が BTB19 にヒットしていない場合として、タスク IDの不一致が含まれる。分岐命令である場合、 分岐実行ユニット 17で実行した分岐命令を BTB19に登録する (ステップ S27)。 [0041] On the other hand, if the instruction to be executed does not hit BTB19 in step S22, It is determined whether the instruction to be executed is a branch instruction (step S26). Task ID mismatch is included as a case where the instruction to be executed does not hit BTB19. If it is a branch instruction, the branch instruction executed by the branch execution unit 17 is registered in the BTB 19 (step S27).
[0042] BTB19へ登録する動作について、ステップ S272、 S274及び S276で説明する。  [0042] The operation registered in the BTB 19 will be described in steps S272, S274, and S276.
先ず、現在のタスク IDと分岐命令のアドレス力 タグ比較用データ 6aを生成し (ステツ プ S272)、分岐先アドレスを算出する (ステップ S274)。そして、値「1」の Validフラグ と、タグ比較用データ 6aと、分岐先アドレスとで構成される分岐予測情報 5— 2を BT B19に書き込み (ステップ S276)、 BTB19へ登録する動作を終了する。また、 BTB 19を更新する動作も終了する。  First, the current task ID and branch instruction address force tag comparison data 6a are generated (step S272), and the branch destination address is calculated (step S274). Then, the branch prediction information 5-2 including the Valid flag with the value “1”, the tag comparison data 6a, and the branch destination address is written to BT B19 (step S276), and the operation of registering in BTB19 is terminated. . Also, the operation of updating BTB 19 is ended.
[0043] ステップ S26にて実行する命令は分岐命令以外であると判断した場合、 BTB更新 を行わず (ステップ S28)、 BTB更新の動作を終了する。すなわち、 BTB19のクリア が抑止される。  If it is determined that the instruction to be executed in step S26 is other than a branch instruction, BTB update is not performed (step S28), and the BTB update operation is terminated. In other words, clearing of BTB19 is suppressed.
[0044] 図 6において、ステップ S23、 S24及び S25は、実行する命令の現在のタスク IDと B TB19から読み出した分岐予測情報 5— 2のタスク IDとが一致する場合の処理となる  In FIG. 6, steps S23, S24, and S25 are processing when the current task ID of the instruction to be executed matches the task ID of the branch prediction information 5-2 read from BTB19.
[0045] 一方、ステップ S26、 S27及び S28は、実行する命令の現在のタスク IDと BTB 19 力も読み出した分岐予測情報 5— 2のタスク IDとが不一致である場合、又は、フェツ チした命令のアドレスと分岐予測情報 5— 2のアドレスとが不一致である場合に実行さ れる。ステップ S27は、ある分岐命令が初めて実行される場合に行われる BTB19へ の登録処理である。 On the other hand, steps S26, S27 and S28 are performed when the current task ID of the instruction to be executed does not match the task ID of the branch prediction information 5-2 from which the BTB 19 force is also read, or the fetched instruction This is executed when the address and branch prediction information 5-2 address do not match. Step S27 is a registration process to the BTB 19 that is performed when a certain branch instruction is executed for the first time.
[0046] ステップ S28では、タスク IDの不一致による場合であっても BTB更新が行われない ため、図 5のステップ S14にて BTB19から読み出した分岐予測情報 5— 2は、 Valid フラグが「1」のままで BTB19に残されることとなる。従って、元のタスクに戻ったときに その分岐予測情報 5— 2を再エントリすることなく使用することができる。  [0046] In step S28, even if the task IDs do not match, the BTB update is not performed. Therefore, the branch prediction information 5-2 read from the BTB 19 in step S14 in Fig. 5 has the Valid flag set to "1". It will be left in BTB19. Therefore, when returning to the original task, the branch prediction information 5-2 can be used without reentry.
[0047] 上述した本発明に係る動作を適応した場合のマルチシステムでの動作例を図 1で 説明する。  An example of operation in a multi-system when the operation according to the present invention described above is applied will be described with reference to FIG.
[0048] タスク ID「0」で識別されるタスク Aにて 0番地の命令 aを実行し、 30番地の命令 jに 分岐したとする。命令 aが分岐命令であるので、 BTB19の 0番目にエントリされる分岐 予測情報 5には、 Validフラグ「1」と、現在のタスク IDを含むタグ比較用データ 6aと、 命令 jの分岐先アドレス「30」とが設定される。 [0048] Suppose that task A identified by task ID “0” executes instruction 0 at address 0 and branches to instruction j at address 30. Since instruction a is a branch instruction, the 0th entry in BTB19 In the prediction information 5, the Valid flag “1”, the tag comparison data 6a including the current task ID, and the branch destination address “30” of the instruction j are set.
[0049] EOR演算を用いる分岐予測情報 5— 2の場合、分岐命令の上位アドレス「0」と現在 のタスク ID「0」との EOR演算の値は「0」となる。 In the case of branch prediction information 5-2 using EOR operation, the value of EOR operation between the upper address “0” of the branch instruction and the current task ID “0” is “0”.
[0050] 割り込みが発生し、タスク ID「1」で識別されるタスク Bが実行されると、 0番地の命令 blがフェッチされる。そして、 BTB 19の 0番地にエントリされている分岐予測情報 5の 分岐先アドレス「30」を読み出す。また、分岐予測情報 5のタスク ID「0」と現在のタス ク ID「1」との比較によって(図 3)、タスク IDの不一致を得る。 [0050] When an interrupt occurs and task B identified by task ID "1" is executed, instruction bl at address 0 is fetched. Then, the branch destination address “30” of the branch prediction information 5 entered at address 0 of BTB 19 is read. Also, by comparing the task ID “0” in branch prediction information 5 with the current task ID “1” (Fig. 3), the task ID mismatch is obtained.
[0051] EOR演算を用いる場合、現在の命令の上位アドレス「0」と現在のタスク ID「1」との[0051] When EOR operation is used, the upper address "0" of the current instruction and the current task ID "1"
EOR演算によって値「 1」を得て、 BTB19から読み出した分岐予測情報 5 - 2のアド レスタグの上位アドレスは「0」と比較することによって(図 4)、タスク IDの不一致を得る By obtaining the value “1” by EOR operation and comparing the upper address of the address tag of branch prediction information 5-2 read from BTB19 with “0” (Figure 4), a task ID mismatch is obtained.
[0052] タスク IDの不一致により、分岐予測は「not-taken」であるとみなされ、 0番地の次の 4番地の命令 b2がフェッチされる(図 5のステップ S14— 2)。その後、命令 bl及び b2 が演算命令であつたので演算実行ユニット 15にて演算が実行される。この場合、実 行する命令 bl及び b2が分岐命令以外であるので、 BTB更新は行われな 、(図 6の ステップ S 28)。 [0052] Due to the task ID mismatch, the branch prediction is regarded as “not-taken”, and the instruction b2 at the address 4 following the address 0 is fetched (step S14-2 in FIG. 5). Thereafter, since the instructions bl and b2 are arithmetic instructions, the arithmetic execution unit 15 executes the arithmetic. In this case, since the executed instructions bl and b2 are other than branch instructions, the BTB update is not performed (step S28 in FIG. 6).
[0053] 再び、割り込みが発生し、タスク ID「0」で識別されるタスク Aが実行開始され、 0番 地の命令 aがフェッチされる。そして、 BTB19の 0番地にエントリされている分岐予測 情報 5の分岐先アドレス「30」を読み出す。また、 BTB19の 0番地にエントリされてい る分岐予測情報 5のタスク ID「0」と現在のタスク ID「0」との比較によって(図 3)、タス ク IDの一致を得る。  [0053] An interrupt occurs again, task A identified by task ID "0" is started to be executed, and instruction a at address 0 is fetched. Then, the branch destination address “30” of the branch prediction information 5 entered at address 0 of BTB19 is read. Also, by comparing the task ID “0” of branch prediction information 5 entered at address 0 of BTB19 with the current task ID “0” (FIG. 3), the task ID matches.
[0054] EOR演算を用いる場合、現在の命令の上位アドレス「0」と現在のタスク ID「0」との EOR演算によって値「0」を得て、 BTB19から読み出した分岐予測情報 5 - 2のアド レスタグの上位アドレスは「0」と比較することによって(図 4)、タスク IDの一致を得る。  [0054] When using the EOR operation, the value "0" is obtained by the EOR operation between the upper address "0" of the current instruction and the current task ID "0", and the branch prediction information 5-2 read from the BTB19 By comparing the upper address of the address tag with “0” (Fig. 4), a task ID match is obtained.
[0055] 分岐予測がなされて分岐方向が示されるため、分岐予測先の 30番地の命令をフエ ツチして命令 jを得る(図 5のステップ S16)。その後、命令 aで分岐が行われて分岐予 測がヒットし、続いて命令 jが実行される。 [0056] 従って、タスク IDの不一致が発生しても BTB19にエントリされている分岐予測情報 5はクリアされないため、元のタスクに切り替わった後効率よく処理することが可能とな る。また、タスク IDの不一致による BTB19力もの分岐予測情報 5の読み間違いを防 止することができる。 [0055] Since branch prediction is performed and the branch direction is indicated, the instruction at the branch prediction destination address 30 is fetched to obtain instruction j (step S16 in FIG. 5). After that, the branch is performed with the instruction a, the branch prediction is hit, and then the instruction j is executed. Therefore, even if a task ID mismatch occurs, the branch prediction information 5 entered in the BTB 19 is not cleared, so that it is possible to efficiently process after switching to the original task. In addition, it is possible to prevent misreading of branch prediction information 5 due to task ID mismatch.
[0057] 本発明は、具体的に開示された実施例に限定されるものではなぐ特許請求の範 囲から逸脱することなぐ種々の変形や変更が可能である。  [0057] The present invention is not limited to the specifically disclosed embodiments, and various modifications and changes can be made without departing from the scope of the claims.

Claims

請求の範囲 The scope of the claims
[1] 分岐予測により命令を先読みするプロセッサであって、  [1] A processor that prefetches instructions by branch prediction,
分岐予測で使用される記憶領域に命令アドレスとタスク識別情報とを示すタグを含 む分岐予測情報を書き込む分岐予測情報書込手段を備えることを特徴とするプロセ ッサ。  A processor comprising branch prediction information writing means for writing branch prediction information including a tag indicating an instruction address and task identification information in a storage area used for branch prediction.
[2] 前記記憶領域に格納されている分岐予測情報から読み出したタスク識別情報と現 在のタスク識別情報とが不一致の場合、該記憶領域のクリアを抑止するクリア抑止手 段を備えることを特徴とする請求項 1記載のプロセッサ。  [2] A clear suppression means for suppressing clearing of the storage area when the task identification information read from the branch prediction information stored in the storage area does not match the current task identification information is provided. The processor according to claim 1.
[3] 前記クリア抑止手段は、実行される命令が分岐命令以外の命令である場合に実行 されることを特徴とする請求項 2記載のプロセッサ。  3. The processor according to claim 2, wherein the clear inhibiting unit is executed when an instruction to be executed is an instruction other than a branch instruction.
[4] 前記分岐予測情報書込手段は、前記記憶領域に格納されて!、る分岐予測情報か ら読み出したタスク識別情報と現在のタスク識別情報とが不一致で、かつ、実行され る命令が分岐命令である場合に実行されることを特徴とする請求項 1記載のプロセッ サ。  [4] The branch prediction information writing means stores the task identification information stored in the storage area! And read from the branch prediction information and the current task identification information, and an instruction to be executed. 2. The processor according to claim 1, wherein the processor is executed when the instruction is a branch instruction.
[5] 前記記憶領域に格納されている分岐予測情報から読み出したタスク識別情報と現 在のタスク識別情報とがー致し、かつ、実行される命令が分岐命令以外の命令であ る場合、該分岐予測情報を無効とする分岐予測情報無効手段を備えることを特徴と する請求項 1記載のプロセッサ。  [5] When the task identification information read from the branch prediction information stored in the storage area matches the current task identification information and the instruction to be executed is an instruction other than a branch instruction, 2. The processor according to claim 1, further comprising branch prediction information invalidating means for invalidating the branch prediction information.
[6] 前記記憶領域に格納されている分岐予測情報から読み出したタスク識別情報と現 在のタスク識別情報とがー致し、かつ、実行される命令が分岐命令である場合、該記 憶領域の更新を抑止する更新抑止手段を備えることを特徴とする請求項 1記載のプ ロセッサ。  [6] If the task identification information read from the branch prediction information stored in the storage area matches the current task identification information, and the instruction to be executed is a branch instruction, the storage area 2. The processor according to claim 1, further comprising update inhibiting means for inhibiting update.
[7] 命令アドレスとタスク識別情報とで前記タグを構成するタグ構成手段を備えることを 特徴とする請求項 1記載のプロセッサ。 7. The processor according to claim 1, further comprising tag configuration means for configuring the tag with an instruction address and task identification information.
[87] 命令アドレスとタスク識別情報とに演算を行って前記タグを生成するタグ生成手段 を備えることを特徴とする請求項 1記載のプロセッサ。 [9] 前記タグ生成手段は、前記命令アドレスの上位アドレス部分と前記タスク識別情報 とに前記演算を行うことを特徴とする請求項 8記載のプロセッサ。 87. The processor according to claim 1, further comprising tag generation means for generating the tag by performing an operation on an instruction address and task identification information. 9. The processor according to claim 8, wherein the tag generation means performs the calculation on an upper address part of the instruction address and the task identification information.
[10] 前記演算は、排他的論理和演算であることを特徴とする請求項 8記載のプロセッサ 10. The processor according to claim 8, wherein the operation is an exclusive OR operation.
[118] 前記記憶領域から前記分岐予測情報を読み出す読出手段と、 [118] reading means for reading the branch prediction information from the storage area;
現在のタスク識別情報と前記分岐予測情報の前記タスク識別情報とがー致するか 否かを判断するタスク一致判断手段と、  Task matching judgment means for judging whether or not the current task identification information matches the task identification information of the branch prediction information;
タスク識別情報が不一致の場合、分岐条件が不成立であるとみなす不成立みなし 手段とを備えることを特徴とする請求項 1記載のプロセッサ。  2. The processor according to claim 1, further comprising: an unsatisfied means for determining that the branch condition is not satisfied when the task identification information does not match.
[12] 前記命令アドレスと前記現在のタスク識別情報とで比較用タグを構成する比較用タ グ構成手段とを備えることを特徴とする請求項 11記載のプロセッサ。 12. The processor according to claim 11, further comprising comparison tag forming means for forming a comparison tag with the instruction address and the current task identification information.
[139] 前記命令アドレスと前記現在のタスク識別情報とに演算を行って前記比較用タグを 生成する比較用タグ生成手段を備えることを特徴とする請求項 118記載のプロセッ サ。  139. The processor according to claim 118, further comprising comparison tag generation means for generating the comparison tag by performing an operation on the instruction address and the current task identification information.
[14] 前記比較用タグ生成手段は、前記命令アドレスの上位アドレス部分と前記タスク識 別情報とに排他的論理和演算を行うことを特徴とする請求項 13記載のプロセッサ。 14. The processor according to claim 13, wherein the comparison tag generation means performs an exclusive OR operation on the upper address part of the instruction address and the task identification information.
[1510] 分岐予測により命令を先読みするプロセッサにおいて実行される方法であって、 分岐予測で使用される記憶領域に命令アドレスとタスク識別情報とを示すタグを含 む分岐予測情報を書き込む分岐予測情報書込手順と、 [1510] Branch prediction information is a method executed in a processor that prefetches instructions by branch prediction, and writes branch prediction information including a tag indicating an instruction address and task identification information in a storage area used for branch prediction. Writing procedure;
前記記憶領域に格納されている分岐予測情報力 読み出したタスク識別情報と現 在のタスク識別情報とが不一致の場合、該記憶領域のクリアを抑止するクリア抑止手 順を備えることを特徴とする方法。  Branch prediction information stored in the storage area When the read task identification information and the current task identification information do not match, the method includes a clear suppression procedure for suppressing the clearing of the storage area. .
PCT/JP2006/319339 2006-09-28 2006-09-28 Processor for increasing the branching prediction speed WO2008038373A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/JP2006/319339 WO2008038373A1 (en) 2006-09-28 2006-09-28 Processor for increasing the branching prediction speed

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2006/319339 WO2008038373A1 (en) 2006-09-28 2006-09-28 Processor for increasing the branching prediction speed

Publications (1)

Publication Number Publication Date
WO2008038373A1 true WO2008038373A1 (en) 2008-04-03

Family

ID=39229821

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2006/319339 WO2008038373A1 (en) 2006-09-28 2006-09-28 Processor for increasing the branching prediction speed

Country Status (1)

Country Link
WO (1) WO2008038373A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2021516384A (en) * 2018-02-13 2021-07-01 ▲龍▼芯中科技▲術▼有限公司Loongson Technology Corporation Limited Branch prediction circuit and its control method

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH03250221A (en) * 1990-02-28 1991-11-08 Hitachi Ltd Branch predicting system
JP2001236225A (en) * 2000-02-22 2001-08-31 Fujitsu Ltd Arithmetic unit and branch predicting method and information processor

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH03250221A (en) * 1990-02-28 1991-11-08 Hitachi Ltd Branch predicting system
JP2001236225A (en) * 2000-02-22 2001-08-31 Fujitsu Ltd Arithmetic unit and branch predicting method and information processor

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2021516384A (en) * 2018-02-13 2021-07-01 ▲龍▼芯中科技▲術▼有限公司Loongson Technology Corporation Limited Branch prediction circuit and its control method
JP7210600B2 (en) 2018-02-13 2023-01-23 ▲龍▼芯中科技▲術▼有限公司 BRANCH PREDICTION CIRCUIT AND CONTROL METHOD THEREOF

Similar Documents

Publication Publication Date Title
JP5137948B2 (en) Storage of local and global branch prediction information
US7711930B2 (en) Apparatus and method for decreasing the latency between instruction cache and a pipeline processor
US7478228B2 (en) Apparatus for generating return address predictions for implicit and explicit subroutine calls
US20050198480A1 (en) Apparatus and method of controlling instruction fetch
JP5734945B2 (en) Sliding window block based branch target address cache
US20070005938A1 (en) Branch instruction prediction
JP2006520964A5 (en)
US20180060075A1 (en) Method for reducing fetch cycles for return-type instructions
US7984280B2 (en) Storing branch information in an address table of a processor
US7877578B2 (en) Processing apparatus for storing branch history information in predecode instruction cache
TWI397816B (en) Methods and apparatus for reducing lookups in a branch target address cache
JP2008186233A (en) Instruction cache pre-fetch control method and device thereof
US10241796B2 (en) Compiler-assisted lookahead (CAL) memory system apparatus for microprocessors
US7913068B2 (en) System and method for providing asynchronous dynamic millicode entry prediction
JP5159258B2 (en) Arithmetic processing unit
JP2008165589A (en) Information processor
US20040225866A1 (en) Branch prediction in a data processing system
US20030204705A1 (en) Prediction of branch instructions in a data processing apparatus
JP3683439B2 (en) Information processing apparatus and method for suppressing branch prediction
WO2008038373A1 (en) Processor for increasing the branching prediction speed
WO2013121516A1 (en) Data processing device
JP2004038338A (en) Information processor having branch estimation mechanism
JP2011209774A (en) Branch prediction method and branch prediction circuit for executing the same
WO2012132214A1 (en) Processor and instruction processing method thereof
JP4728877B2 (en) Microprocessor and pipeline control method

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 06810786

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 06810786

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: JP