JP2000029787A - Processor equipped with writing-in mechanism for instruction caches - Google Patents

Processor equipped with writing-in mechanism for instruction caches

Info

Publication number
JP2000029787A
JP2000029787A JP10200266A JP20026698A JP2000029787A JP 2000029787 A JP2000029787 A JP 2000029787A JP 10200266 A JP10200266 A JP 10200266A JP 20026698 A JP20026698 A JP 20026698A JP 2000029787 A JP2000029787 A JP 2000029787A
Authority
JP
Japan
Prior art keywords
instruction
cache
data
writing
written
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.)
Granted
Application number
JP10200266A
Other languages
Japanese (ja)
Other versions
JP3693503B2 (en
Inventor
Hiroyasu Nishiyama
博泰 西山
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.)
Hitachi Ltd
Original Assignee
Hitachi 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 Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP20026698A priority Critical patent/JP3693503B2/en
Publication of JP2000029787A publication Critical patent/JP2000029787A/en
Application granted granted Critical
Publication of JP3693503B2 publication Critical patent/JP3693503B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

PROBLEM TO BE SOLVED: To suppress low the decrease in performance due to main storage reference at dynamic instructing generating by providing in an instruction set an instruction, capable of specifying by each memory area as an area which is written through a data cache or an area which is written through an instruction cache. SOLUTION: In the instruction set, the instruction is provided which can specify each memory area as an area which is written via the data case or an area which is written through the instruction cache. This processor writes an instruction generated dynamically by ALU 105 directly to the instruction cache 102 through a memory unit 107, after it is stored in a register 106. The generated instruction, when executed is read out of the instruction cache 102 by a memory unit 107 and passed to an instruction decoder 108. Thus, the instruction written to the instruction cache 102 can be executed directly not through a main storage 104, so that the execution of the dynamically generated instruction can be speeded up.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、プロセッサに関
し、特に、実行時に動的に機械語命令プログラムを生成
して実行を行う仮想マシンインタプリタ等を実行するの
に適したマイクロプロセッサに関する。
The present invention relates to a processor and, more particularly, to a microprocessor suitable for executing a virtual machine interpreter or the like which dynamically generates and executes a machine language instruction program at the time of execution.

【0002】[0002]

【従来の技術】従来のマイクロプロセッサでは、主記憶
(メインメモリ)とCPUとの間に、高速な中間記憶装
置として、キャッシュを設けることが多い。このキャッ
シュは、その構成上、データキャッシュと命令キャッシ
ュを分離した非統合型キャッシュと、データキャッシュ
と命令キャッシュを統合した統合型キャッシュとに分類
することができる。前者の非統合型キャッシュは、後者
の統合型キャッシュと比較して、データキャッシュと命
令キャッシュのそれぞれに、独立に高いデータ供給バン
ド幅を与えることができるので、一般に高い性能を得る
ことができる。このため、ハイエンドのマイクロプロセ
ッサでは、非統合型のキャッシュが利用されることが多
い。
2. Description of the Related Art In a conventional microprocessor, a cache is often provided as a high-speed intermediate storage device between a main memory (main memory) and a CPU. This cache can be classified into a non-integrated cache in which a data cache and an instruction cache are separated, and an integrated cache in which a data cache and an instruction cache are integrated. Compared with the latter unified cache, the former non-integrated cache can generally provide higher data supply bandwidth to each of the data cache and the instruction cache, so that generally higher performance can be obtained. For this reason, non-integrated caches are often used in high-end microprocessors.

【0003】一方、このようなマイクロプロセッサで実
行されるプログラムを記述するプログラミング言語とし
て、Java(Javaは、米国 Sun Microsystems, I
nc.の商標)やSmalltalkといったものが知ら
れている。これらのプログラミング言語で記述されたプ
ログラムは、バイトコードと呼ばれる仮想的な計算機の
命令に一旦変換され、バイトコードは、通常、仮想マシ
ンインタプリタと呼ばれるソフトウェアによって実行さ
れる。
On the other hand, as a programming language for describing a program executed by such a microprocessor, Java (Java is a trademark of Sun Microsystems, I.
nc. and Smalltalk are known. Programs written in these programming languages are temporarily converted into virtual computer instructions called bytecodes, and the bytecodes are usually executed by software called a virtual machine interpreter.

【0004】しかし、このような仮想マシンインタプリ
タによる実行は、仮想マシン命令の解釈実行などのオー
バヘッドが大きい。従って、JavaやSmallta
lkで記述されたプログラムは、CやFORTRANと
いった従来のコンパイラ型言語で記述された場合に比べ
て、一般に、その実行速度は低速になる。これに対し
て、例えば、L.P. Deutsch と A.M. Chiffmanによる ”
Efficient Implementation of the Smalltalk-80 Syste
m”(In Proceedings of the 11th Annual ACM Symposi
um on Principles of Programming Languages pp.297-3
02, 1984)に示されているように、実行対象の仮想マシ
ン命令列に対して、それと等価な処理を行う機械語命令
を実行時に生成し、生成した機械語命令を直接実行する
ことでインタプリタ実行の高速化を行う手法が用いられ
る。このような手法は、機械語命令を実行時に動的に生
成することから動的コンパイル、または実行を行おうと
した時点でコンパイルを行うことからJIT(ジャスト
インタイム:Just-In-Time)コンパイルと呼ばれ、Ja
va仮想マシンの高速化などに利用されている。
However, execution by such a virtual machine interpreter has a large overhead such as interpretation and execution of a virtual machine instruction. Therefore, Java and Smallta
Generally, the execution speed of a program described in lk is lower than that of a program described in a conventional compiler type language such as C or FORTRAN. For example, LP Deutsch and AM Chiffman
Efficient Implementation of the Smalltalk-80 Syste
m ”(In Proceedings of the 11th Annual ACM Symposi
um on Principles of Programming Languages pp.297-3
02, 1984), a machine language instruction that performs the equivalent processing is generated at execution time for a virtual machine instruction sequence to be executed, and the generated machine language instruction is directly executed to execute the interpreter. A technique for speeding up execution is used. Such a method is called dynamic compilation because machine language instructions are dynamically generated at the time of execution, or JIT (Just-In-Time) compilation because it is compiled when execution is attempted. Called, Ja
It is used for speeding up va virtual machines.

【0005】[0005]

【発明が解決しようとする課題】このような実行時に命
令を動的に生成するJITコンパイル技術は、仮想マシ
ンインタプリタなどの高速化には有効であるが、非統合
型のキャッシュ機構を採用したマイクロプロセッサで利
用することを考えた場合、実行時に生成された命令を、
実行時に主記憶へ書き込むことが必要になることから、
次のような問題が生じることになる。
The JIT compilation technique for dynamically generating instructions at the time of execution is effective for speeding up a virtual machine interpreter or the like, but a microcontroller employing a non-integrated cache mechanism is effective. Considering the use in the processor, the instruction generated at the time of execution,
Since it is necessary to write to main memory at the time of execution,
The following problems will occur.

【0006】動的に生成された命令の主記憶への書き込
みは、プロセッサから見た場合、通常のデータの書き込
みと変わらないので、非統合型キャッシュを採用したプ
ロセッサでは、データキャッシュを介して行われること
になる。このため、生成された命令をデータキャッシュ
を介してメモリへ書き込んだ直後に、書き込んだ当該命
令を実行しようとしても、命令キャッシュとデータキャ
ッシュの整合性が保たれていないので、そのまま実行す
ることができない。すなわち、命令キャッシュの更新が
行われていないために、そのままでは予期しない命令を
実行してしまう可能性がある。そこで、ほとんどのマイ
クロプロセッサでは、指定したデータキャッシュ上のデ
ータを主記憶に書き戻したり、命令キャッシュ上のキャ
ッシュブロックを無効化するための命令を備えている。
そして、主記憶へ書き込んだ命令を実行する前に、この
ような命令を使って、書き込んだアドレスに対応する命
令キャッシュ上のデータを破棄(無効化)するととも
に、ライトバック(write-back)型のキャッシュであれ
ば、変更が主記憶に反映されるように、書き込んだアド
レスに対応するデータキャッシュ上のデータを主記憶に
書き戻す。
[0006] Writing a dynamically generated instruction to the main memory is not different from normal data writing from the viewpoint of the processor. Therefore, in a processor employing a non-integrated cache, the instruction is written via the data cache. Will be Therefore, immediately after the generated instruction is written to the memory via the data cache, even if the written instruction is to be executed, the instruction cache and the data cache are not maintained in a consistent state. Can not. That is, since the instruction cache is not updated, an unexpected instruction may be executed as it is. Therefore, most microprocessors have instructions for writing back data in a specified data cache to a main memory or invalidating a cache block in an instruction cache.
Before executing the instruction written to the main memory, the instruction cache data corresponding to the written address is discarded (invalidated) and the write-back type is used. In this case, the data in the data cache corresponding to the written address is written back to the main memory so that the change is reflected in the main memory.

【0007】つまり、動的な命令の生成・実行処理は、
以下のような流れで行われる。
In other words, dynamic instruction generation and execution processing
It is performed in the following flow.

【0008】1.書き込み対象アドレス(以下、アドレ
スAという)に対応するデータキャッシュのキャッシュ
ブロックへの、動的に生成された機械語命令の書き込み 2. アドレスAに対応する命令キャッシュのキャッシュ
ブロックの破棄 3. アドレスAに対応するデータキャッシュのキャッシ
ュブロックの主記憶への書き戻し(ライトバック型のキ
ャッシュの場合) 4. 主記憶のアドレスAから命令キャッシュの対応する
キャッシュブロックへの読み出し 5.命令キャッシュからの命令の読み出し及び実行 以上述べたように、非統合型キャッシュを採用したマイ
クロプロセッサにおいて、実行時に動的に命令を生成
し、当該生成された命令を実行しようとすると、動的に
生成された命令は、データキャッシュに書き込まれた
後、主記憶へ書き出され、その後、命令キャッシュへ読
み出す必要があるため、主記憶への書き込みや読み出し
を伴うことになり、このことは、実行速度の低下要因と
なりうる。
[0008] 1. Write a dynamically generated machine language instruction to the cache block of the data cache corresponding to the write target address (hereinafter, referred to as address A) 2. Discard the cache block of the instruction cache corresponding to address A 3. Address A 3. Write-back of the cache block of the data cache corresponding to the above to the main memory (in the case of the write-back type cache) 4. Read from the address A of the main memory to the corresponding cache block of the instruction cache Reading and Executing Instructions from the Instruction Cache As described above, in a microprocessor employing a non-integrated cache, if an instruction is dynamically generated at the time of execution, and if the generated instruction is executed, the The generated instruction must be written to the data cache, written to the main memory, and then read to the instruction cache, which involves writing and reading to the main memory. This can be a factor in reducing speed.

【0009】特に、プロセッサ内での命令レベル並列度
や動作周波数が向上し、主記憶参照に要する時間で、多
数の命令を処理可能なハイエンドマイクロプロセッサで
は、主記憶参照に要するオーバヘッドにより動的な命令
生成処理を行うプログラムの動作性能が低下してしまう
といった問題が深刻化するおそれがある。
Particularly, in a high-end microprocessor capable of processing a large number of instructions in the time required for referring to the main memory by improving the instruction level parallelism and the operating frequency in the processor, the dynamic required by the overhead required for the main memory reference is increased. There is a possibility that the problem that the operation performance of the program that performs the instruction generation processing is reduced may become serious.

【0010】なお、CやFORTRANといった従来の
静的なコンパイラ型言語では、機械語命令への変換がプ
ログラム実行前にあらかじめ行われ、実行時に動的に命
令を生成することがないため、分離型のキャッシュ構成
であっても、大きな問題とはならなかった。本発明の目
的は、仮想マシンインタプリタにおけるJITコンパイ
ルのような、実行時に動的に機械語命令の生成を行う処
理において、動的な命令生成時の主記憶参照によって生
じる性能低下を低く押えることができるプロセッサを提
供することにある。
In a conventional static compiler type language such as C or FORTRAN, conversion into machine language instructions is performed in advance before program execution, and instructions are not dynamically generated at the time of execution. Even with this cache configuration, there was no major problem. An object of the present invention is to suppress a decrease in performance caused by referencing main memory at the time of dynamic instruction generation in a process of dynamically generating machine language instructions at the time of execution, such as JIT compilation in a virtual machine interpreter. It is to provide a processor which can do it.

【0011】[0011]

【課題を解決するための手段】本発明に係るプロセッサ
は、命令セットの中に、所定のメモリ領域毎に、当該領
域が、データキャッシュを介して書き込みを行う領域
か、命令キャッシュを介して書き込みを行う領域かを指
定することができる命令を有することを特徴とする。こ
の場合、前記命令によって命令キャッシュを介して書き
込みを行う領域として指定されたメモリ領域に対して、
書き込みが指示された場合は、命令キャッシュを介して
書き込みを行う。
According to the present invention, there is provided a processor in which, for each predetermined memory area, an area for writing via a data cache or an area for writing via an instruction cache is included in an instruction set. Characterized by having an instruction capable of designating an area for performing In this case, for the memory area designated as the area to be written via the instruction cache by the instruction,
When writing is instructed, writing is performed via the instruction cache.

【0012】また、本発明に係る第2のプロセッサは、
データキャッシュを介して書き込みを行うモードか、命
令キャッシュを介して書き込みを行うモードであるかを
表すフラグを備え、当該フラグが命令キャッシュを介し
て書き込みを行うモードであることを示している場合
は、命令キャッシュを介して書き込みを行うことを特徴
とする。この場合、命令セットの中に、前記フラグを操
作する命令を有することが好ましい。
Further, a second processor according to the present invention comprises:
If there is a flag indicating whether the mode is a mode for writing via the data cache or a mode for writing via the instruction cache, and if the flag indicates a mode for writing via the instruction cache, , Writing is performed via an instruction cache. In this case, it is preferable that the instruction set includes an instruction for operating the flag.

【0013】また、本発明に係る第3のプロセッサは、
命令セットの中に、命令キャッシュを介してメモリへの
書き込みを行うことを指示する命令を有することを特徴
とする。
Further, a third processor according to the present invention comprises:
The present invention is characterized in that an instruction set includes an instruction for instructing writing to a memory via an instruction cache.

【0014】なお、上記第1から第3のプロセッサにお
いて、命令キャッシュを介した書き込みが指示された場
合、命令キャッシュとデータキャッシュの両方に書き込
みを行うようにしてもよい。このようにすれば、データ
キャッシュに命令キャッシュの更新データのコピーが存
在することになるので、命令キャッシュからメモリへの
直接的な書き戻し経路を設けることなく、命令キャッシ
ュにおいてキャッシュ溢れが生じた場合の更新データの
主記憶への書き戻しが可能になる。
In the first to third processors, when writing via the instruction cache is instructed, writing may be performed to both the instruction cache and the data cache. In this case, since a copy of the updated data of the instruction cache exists in the data cache, a cache overflow occurs in the instruction cache without providing a direct write-back path from the instruction cache to the memory. Write-back of the updated data to the main memory becomes possible.

【0015】更に、本発明に係る動的コンパイルの方法
は、前述の第1から第3のプロセッサを使った動的コン
パイルの方法であって、動的に生成した命令をメモリへ
書き込む場合、命令キャッシュを介して書き込むように
することを特徴とする。
Further, a dynamic compilation method according to the present invention is a dynamic compilation method using the above-described first to third processors, wherein a dynamically generated instruction is written in a memory. It is characterized in that writing is performed via a cache.

【0016】本発明によるプロセッサでは、命令キャッ
シュを介してメモリへの書き込みを行うことができるの
で、動的コンパイルによって、動的に生成した命令をメ
モリへ書き込む場合、命令キャッシュを介して書き込む
ことができ、主記憶参照の必要性が減り、仮想マシンイ
ンタプリタにおけるJITコンパイルのような、実行時
に動的に機械語命令の生成を行う処理において、動的な
命令生成時の主記憶参照によって生じる性能低下を低く
押えることができる
In the processor according to the present invention, writing to the memory can be performed via the instruction cache. Therefore, when dynamically generated instructions are written to the memory by dynamic compilation, the instructions can be written via the instruction cache. And the need for main memory reference is reduced, and in processing that dynamically generates machine language instructions at execution time, such as JIT compilation in a virtual machine interpreter, performance degradation caused by main memory reference during dynamic instruction generation Can be kept low

【0017】[0017]

【発明の実施の形態】以下、本発明の実施の形態につい
て、図面を参照しつつ、詳細に説明する。
Embodiments of the present invention will be described below in detail with reference to the drawings.

【0018】図9は、本発明を実施する計算機システム
の例を示す図である。仮想マシンインタプリタにおける
JITコンパイラなど実行時に命令生成処理を行うソフ
トウェアは、ディスク装置204から主記憶203に読
み出され、プロセッサ201によって実行される。この
ソフトウェアにより生成される機械語命令は、高速な中
間記憶装置であるキャッシュ202を介して主記憶20
3とプロセッサ201の間で読み書きされる。なお、こ
こでは、簡単のためメモリ階層をキャッシュと主記憶の
2階層としているが、本発明は、複数のキャッシュ階層
を持つマイクロプロセッサに対して適用することも可能
である。
FIG. 9 is a diagram showing an example of a computer system for implementing the present invention. Software that performs instruction generation processing at the time of execution, such as a JIT compiler in a virtual machine interpreter, is read from the disk device 204 to the main storage 203 and executed by the processor 201. The machine language instructions generated by this software are sent to the main memory 20 via a cache 202 which is a high-speed intermediate storage device.
3 and the processor 201. Here, for simplicity, the memory hierarchy is a cache and a main memory, but the present invention can also be applied to a microprocessor having a plurality of cache hierarchies.

【0019】図1は、本発明による非統合型キャッシュ
を採用したマイクロプロセッサの動作概要を説明する図
である。本発明と対比するため、まず、非統合型キャッ
シュを採用した従来のマイクロプロセッサの動作につい
て同図を使って説明する。非統合型キャッシュを採用し
た従来のマイクロプロセッサでは、CPU101が実行
する命令は、主記憶104から命令キャッシュ102へ
読み出され、CPU101へと受け渡される。このよう
にしてフェッチされた命令は、メモリユニット107を
介して、命令デコーダ108に渡される。更に、当該命
令は、命令デコーダ108でデコードされて、当該デコ
ード結果に基づいて、ALU105やレジスタ106が
制御されて、命令の実行が行われる。頻繁に実行される
命令は、高速な中間記憶装置である命令キャッシュ10
2に保存されることにより、低速な主記憶104を参照
する必要がなくなるため、高速な実行を行うことが可能
になる。
FIG. 1 is a diagram for explaining the outline of the operation of a microprocessor employing a non-integrated cache according to the present invention. First, the operation of a conventional microprocessor employing a non-integrated cache will be described with reference to FIG. In a conventional microprocessor employing a non-integrated cache, instructions to be executed by the CPU 101 are read from the main memory 104 to the instruction cache 102 and passed to the CPU 101. The instruction fetched in this way is passed to the instruction decoder 108 via the memory unit 107. Further, the instruction is decoded by the instruction decoder 108, and based on the decoding result, the ALU 105 and the register 106 are controlled to execute the instruction. Frequently executed instructions are stored in the instruction cache 10 which is a high-speed intermediate storage.
By saving the data in the second storage area, it is not necessary to refer to the low-speed main memory 104, so that high-speed execution can be performed.

【0020】図1において、破線は、従来のマイクロプ
ロセッサにおいて、動的命令生成処理での動的に生成さ
れた命令の流れを表す。また、実線は本発明における動
的に生成された命令の流れを表している。なお、ここで
の説明では、簡単のため、まず、キャッシュブロックの
競合や容量不足による溢れが生じない場合について説明
し、キャッシュブロックの溢れが発生する場合について
は後述する。
In FIG. 1, a broken line indicates a flow of dynamically generated instructions in a dynamic instruction generation process in a conventional microprocessor. The solid line represents the flow of dynamically generated instructions in the present invention. In this description, for simplicity, first, a case where overflow due to cache block contention or capacity shortage does not occur will be described, and a case where cache block overflow occurs will be described later.

【0021】同図の破線で示すように、従来の動的命令
生成処理においては、ALU105によって実行時に動
的に生成された命令は、レジスタ106に格納された
後、メモリユニット107を介して、データキャッシュ
103へ書き込まれる。データキャッシュ103がライ
トバック方式を採用している場合、この状態では、実行
すべき命令がデータキャッシュ103上にのみ存在する
ので、当該命令が書き込まれたキャッシュブロックを主
記憶104へ書き戻す。また、命令キャッシュ102上
に当該書き込みを行ったアドレスに対応するキャッシュ
ブロックが存在する可能性があるので、存在する場合に
は命令キャッシュ102上の当該ブロックを無効化す
る。これによって、動的に生成された命令の書き込みを
行ったアドレスに対応するキャッシュブロックは、命令
キャッシュ102上に存在しなくなるので、生成された
命令を実行しようとした時点で、主記憶104から命令
キャッシュ102上に命令が読み出され、メモリユニッ
ト107を介して命令デコーダ108へと受け渡され、
デコード結果に従って、CPU101での命令実行が行
われる。
As shown by the broken line in FIG. 2, in the conventional dynamic instruction generation processing, an instruction dynamically generated at the time of execution by the ALU 105 is stored in the register 106 and then transmitted to the memory unit 107 via the memory unit 107. The data is written to the data cache 103. When the data cache 103 employs the write-back method, the instruction to be executed exists only in the data cache 103 in this state, so that the cache block in which the instruction is written is written back to the main memory 104. Further, since there is a possibility that a cache block corresponding to the address at which the writing has been performed exists on the instruction cache 102, the block on the instruction cache 102 is invalidated if it exists. As a result, the cache block corresponding to the address at which the dynamically generated instruction has been written no longer exists in the instruction cache 102. Therefore, when the generated instruction is executed, The instruction is read onto the cache 102 and passed to the instruction decoder 108 via the memory unit 107,
The instruction is executed by the CPU 101 according to the decoding result.

【0022】これに対して、本発明における動的命令生
成処理での生成命令の流れでは、ALU105が動的に
生成した命令は、レジスタ106に格納された後、メモ
リユニット107を介して、命令キャッシュ102に直
接書き込まれる。そして、生成された命令を実行する場
合には、命令キャッシュ102上に生成された命令が存
在するため、メモリユニット107は、命令キャッシュ
102から実行すべき命令を読み出し、読み出した命令
を命令デコーダ108へ渡す。
On the other hand, in the flow of the generated instruction in the dynamic instruction generation processing of the present invention, the instruction dynamically generated by the ALU 105 is stored in the register 106 and then transmitted through the memory unit 107. Written directly to cache 102. When executing the generated instruction, since the generated instruction exists in the instruction cache 102, the memory unit 107 reads the instruction to be executed from the instruction cache 102, and stores the read instruction in the instruction decoder 108. Pass to

【0023】以上説明したように、従来のマイクロプロ
セッサでは、キャッシュ容量の余裕の有無に関わらず、
データキャッシュ103に書き込んだ命令を一度高速な
キャッシュメモリから低速な主記憶104へ書き込ん
で、再度命令キャッシュ102を介してCPU101へ
読み出さねばならなかった。これに対して、本発明によ
るマイクロプロセッサでは、主記憶104を介すること
なく直接命令キャッシュ102上に書き込んだ命令を実
行することができるので、動的に生成された命令の実行
を高速化することができる。
As described above, in the conventional microprocessor, regardless of whether there is a margin in the cache capacity,
The instruction written in the data cache 103 must once be written from the high-speed cache memory to the low-speed main memory 104 and read out to the CPU 101 again via the instruction cache 102. On the other hand, in the microprocessor according to the present invention, the instruction written in the instruction cache 102 can be directly executed without the intervention of the main memory 104, so that the speed of execution of the dynamically generated instruction can be increased. Can be.

【0024】以上の説明では、キャッシュブロックの競
合や容量不足によるキャッシュブロックの追い出しを考
慮していなかった。実際には、キャッシュ容量は限られ
ており、キャッシュブロックの競合は生じるため、追い
出し時の処理を考慮する必要がある。そこで、以下では
キャッシュ追い出し時の処理を考慮した命令書き込み処
理について説明する。
The above description does not consider cache block eviction due to cache block contention or capacity shortage. Actually, the cache capacity is limited, and contention of cache blocks occurs. Therefore, it is necessary to consider processing at the time of eviction. Therefore, an instruction writing process in consideration of a cache eviction process will be described below.

【0025】キャッシュへの書き込み処理において、競
合等によりキャッシュブロックを追い出す場合の処理
は、キャッシュがライトスルー(write-through)方式
を採用しているか、ライトバック方式を採用しているか
によってその処理が異なる。
In the process of writing data to the cache, the process for flushing the cache block due to competition or the like depends on whether the cache employs a write-through system or a write-back system. different.

【0026】ライトスルー方式の場合には、キャッシュ
への書き込みと同時に主記憶への書き込みも行われてい
るため、追い出し対象のキャッシュブロックを単に無効
化するだけで良い。すなわち、本発明による命令キャッ
シュをライトスルー方式のキャッシュとして構成した場
合は、命令キャッシュと主記憶の両方に、書き込み対象
の命令が書き込まれるので、主記憶上に最新のデータが
保存されていることになり、キャッシュブロックの追い
出し時にはキャッシュブロックの内容を破棄すれば良
い。
In the case of the write-through method, since writing to the main memory is performed simultaneously with writing to the cache, it is sufficient to simply invalidate the cache block to be evicted. That is, when the instruction cache according to the present invention is configured as a write-through cache, the instruction to be written is written to both the instruction cache and the main memory, so that the latest data is stored in the main memory. When the cache block is evicted, the contents of the cache block may be discarded.

【0027】一方、ライトバック方式の場合には、最新
のデータはキャッシュ上のみに存在するので、更新デー
タを含むキャッシュブロックの追い出し時には主記憶へ
のデータの書き戻し処理を行う必要がある。従来のプロ
セッサでは、CPUからキャッシュへのデータの書き込
みはデータキャッシュに対してのみ行われていたため、
キャッシュから主記憶へのデータの書き戻し処理はデー
タキャッシュだけでしか行われていなかった。本発明に
よるプロセッサでは、命令キャッシュに対する書き込み
も行うので、ライトバック方式を採用した場合、命令キ
ャッシュからの主記憶へのデータの書き戻し処理を考慮
する必要がある。このような命令キャッシュからの主記
憶へのデータの書き戻し処理には、命令キャッシュから
直接主記憶への書き込みを可能とする方式と、従来通り
主記憶への書き込みはデータキャッシュのみから行うよ
うにする方式とが考えられる。以下では、各方式につい
てその実現例を示す。
On the other hand, in the case of the write-back method, since the latest data exists only in the cache, it is necessary to write back the data to the main memory when flushing the cache block containing the updated data. In a conventional processor, data is written from the CPU to the cache only in the data cache.
The process of writing back data from the cache to the main memory has been performed only by the data cache. In the processor according to the present invention, writing to the instruction cache is also performed. Therefore, when the write-back method is adopted, it is necessary to consider a process of writing back data from the instruction cache to the main memory. For the write-back processing of data from the instruction cache to the main memory, a method that enables writing from the instruction cache directly to the main memory is used. It is considered that the method is In the following, examples of realizing the respective methods will be described.

【0028】図2は、命令キャッシュから主記憶へキャ
ッシュブロックを書き込み可能なようにアーキテクチャ
を拡張した場合の、動的に生成された命令の流れを表し
ている。図2において、ALU105によって動的に生
成され、レジスタ106に格納された命令は、メモリユ
ニット107を介して命令キャッシュ102に書き込ま
れる。ここで、書き込み対象となるキャッシュブロック
301に書き込みアドレスとは異なるアドレスに対応す
る命令が既に保持されている場合、そのキャッシュブロ
ックを利用可能とする必要があるが、当該キャッシュブ
ロック301の更新状態によってその処理が異なる。キ
ャッシュブロック301が書き込みが行われていない状
態(クリーン:clean)であれば、主記憶104上の内
容と命令キャッシュ102上の内容は一致しているの
で、主記憶104への書き戻しは行わず、命令キャッシ
ュ102上のキャッシュブロック301のデータを破棄
する。一方、キャッシュブロック301が書き込みが行
われた状態(ダーティ:dirty)であれば、命令キャッ
シュ102上のみに最新の命令が存在するので、まず、
キャッシュブロック301を対応する主記憶上の領域3
02へ書き戻す。
FIG. 2 shows the flow of dynamically generated instructions when the architecture is extended so that a cache block can be written from the instruction cache to the main memory. 2, an instruction dynamically generated by the ALU 105 and stored in the register 106 is written to the instruction cache 102 via the memory unit 107. Here, when an instruction corresponding to an address different from the write address is already held in the cache block 301 to be written, it is necessary to make the cache block available, but depending on the update state of the cache block 301, The processing is different. If the cache block 301 has not been written (clean), the contents in the main memory 104 and the contents in the instruction cache 102 match, so that writing back to the main memory 104 is not performed. , The data in the cache block 301 on the instruction cache 102 is discarded. On the other hand, if the cache block 301 has been written (dirty), the latest instruction exists only in the instruction cache 102.
Area 3 in main memory corresponding to cache block 301
Write back to 02.

【0029】命令キャッシュ102上の元のデータの破
棄または書き戻しが終了すると、動的に生成された命令
の書き込み対象アドレスに対応した主記憶104上のデ
ータブロック303をキャッシュブロック301へ読み
込んで、メモリユニット107から受け渡された書き込
み対象命令の書き込みを行う。これらの動作は、通常の
ライトバック型データキャッシュの動作と同様である。
When the discarding or writing back of the original data in the instruction cache 102 is completed, the data block 303 in the main memory 104 corresponding to the write target address of the dynamically generated instruction is read into the cache block 301, and The write target instruction passed from the memory unit 107 is written. These operations are the same as those of a normal write-back type data cache.

【0030】図3は、図2に示した命令キャッシュから
主記憶へのキャッシュブロックの書き戻し機構を追加し
た場合の主記憶への書き込み処理の流れを示す図であ
る。同図に示すように、処理を開始すると(S40
1)、まず、書き込みが命令キャッシュを介した書き込
みか否かを判別する(S402)。あるデータ書き込み
命令がデータキャッシュを介した書き込みか、命令キャ
ッシュを介した書き込みかを指定・判断する方法につい
ては、後述する。
FIG. 3 is a diagram showing a flow of a write process to the main memory when a mechanism for writing back a cache block from the instruction cache to the main memory shown in FIG. 2 is added. As shown in the figure, when the processing is started (S40)
1) First, it is determined whether the write is a write via the instruction cache (S402). A method of designating and determining whether a certain data write instruction is a write via a data cache or a write via an instruction cache will be described later.

【0031】判別の結果、当該書き込みがデータキャッ
シュを介したものであれば(S402:NO)、従来と
同じデータキャッシュを介した書き込み処理を行い(S
403)、処理を終了する(S408)。一方、命令キ
ャッシュを介した書き込みであれば(S402:YE
S)、書き込み対象アドレスに対応するキャッシュブロ
ックが命令キャッシュ上に存在するか否かを調べる(S
404)。その結果、書き込み対象アドレスに対応する
キャッシュブロックが命令キャッシュ上に存在しない場
合は(S404:NO)、続けて、データキャッシュに
書き込み対象アドレスに対応するキャッシュブロックが
存在するか否かを調べ、そのようなキャッシュブロック
が存在し、データキャッシュの当該キャッシュブロック
がダーティ状態であれば当該ブロックを主記憶に書き出
し(S405)、書き込み対象のアドレスに対応したブ
ロックを命令キャッシュに読み出す(S406)。これ
により、命令キャッシュ上に書き込み対象アドレスのキ
ャッシュブロックが確保されるので、命令キャッシュの
当該ブロックに動的に生成された命令を書き込み(S4
07)、処理を終える(S408)。一方、書き込み対
象アドレスに対応するキャッシュブロックが命令キャッ
シュ上に存在する場合は(S404:YES)、命令キ
ャッシュ上に書き込み対象アドレスのキャッシュブロッ
クが既に確保されているので、そのまま、命令キャッシ
ュに命令を書き込み(S407)、処理を終える(S4
08)。
As a result of the determination, if the write is via the data cache (S402: NO), the same write processing via the data cache as in the prior art is performed (S402).
403), and the process ends (S408). On the other hand, if the write is via the instruction cache (S402: YE
S), it is checked whether or not a cache block corresponding to the write target address exists in the instruction cache (S).
404). As a result, if the cache block corresponding to the write target address does not exist in the instruction cache (S404: NO), it is subsequently checked whether or not there is a cache block corresponding to the write target address in the data cache. If such a cache block exists and the cache block of the data cache is in a dirty state, the block is written to the main memory (S405), and the block corresponding to the write target address is read to the instruction cache (S406). As a result, a cache block of the address to be written is secured in the instruction cache, and the dynamically generated instruction is written in the block of the instruction cache (S4).
07), the process ends (S408). On the other hand, if the cache block corresponding to the write target address exists in the instruction cache (S404: YES), the cache block of the write target address is already secured in the instruction cache, and the instruction is stored in the instruction cache as it is. Write (S407) and end the process (S4
08).

【0032】なお、命令書き込み対象アドレスに対応す
るキャッシュブロックがデータキャッシュ上に存在する
場合は、命令キャッシュとの整合性を保つため、該当す
るデータキャッシュのデータブロックを破棄(無効化)
するか、又は、命令キャッシュとともに、データキャッ
シュにも命令を書き込むようにすればよい。
When a cache block corresponding to an instruction write target address exists in the data cache, the data block of the data cache is discarded (invalidated) in order to maintain consistency with the instruction cache.
Alternatively, the instructions may be written in the data cache together with the instruction cache.

【0033】図4は、命令キャッシュ102から主記憶
104へ直接書き込みを行う機構を有しない場合の、動
的に生成された命令の流れを表している。この場合、命
令キャッシュから主記憶への直接的な書き戻し経路を設
ける必要がないので、図2に示したものに比べて、従来
のマイクロプロセッサに対するハードウェア的な変更量
が少なくてすむ。
FIG. 4 shows the flow of dynamically generated instructions when there is no mechanism for directly writing from the instruction cache 102 to the main memory 104. In this case, since there is no need to provide a direct write-back path from the instruction cache to the main memory, the amount of hardware changes to the conventional microprocessor is smaller than that shown in FIG.

【0034】図4に示すように、ALU105によって
動的に生成され、レジスタ106に格納された命令は、
メモリユニット107を介して命令キャッシュ102
と、データキャッシュ103に書き込まれる。すなわ
ち、データキャッシュ103上にも当該命令のコピーを
持つこととする。
As shown in FIG. 4, the instructions dynamically generated by ALU 105 and stored in register 106 are:
Instruction cache 102 via memory unit 107
Is written to the data cache 103. That is, it is assumed that the data cache 103 has a copy of the instruction.

【0035】このようにデータキャッシュ103上にも
当該命令(に対応するキャッシュブロック)のコピーを
持つのは、本実施形態では、命令キャッシュ102から
主記憶104へのキャッシュブロックの書き戻しパスが
存在しないため、命令キャッシュ102に対して動的に
生成された命令の書き込みを行う際に、キャッシュ溢れ
が生じ、主記憶への書き戻しが必要になった場合、当該
書き戻しをできるようにするためである。
As described above, the data cache 103 also has a copy of the instruction (the cache block corresponding to the instruction). In this embodiment, there is a cache block write-back path from the instruction cache 102 to the main memory 104. Therefore, when writing a dynamically generated instruction to the instruction cache 102, cache overflow occurs, and if writing back to the main memory is required, the writing back can be performed. It is.

【0036】命令キャッシュ102への書き込みを行う
際、キャッシュ溢れが生じ、主記憶への書き戻しが必要
になった場合は、書き戻し対象となった命令キャッシュ
上のブロック501を破棄するとともに、対応するデー
タキャッシュ103上のブロック502の更新状況を調
べて、ダーティであれば、対応する主記憶104上の領
域504に書き戻す。次に、書き込み対象アドレスに対
応するブロック503を主記憶104から読み出し、命
令キャッシュ102とデータキャッシュ103の両方に
読み込む。そして、書き込み対象の命令を命令キャッシ
ュ102上のブロック501と、データキャッシュ10
3上のブロック502へ書き込む。
When writing to the instruction cache 102 causes overflow of the cache and writing back to the main memory is necessary, the block 501 in the instruction cache to be written back is discarded, and The update status of the block 502 on the data cache 103 is checked, and if it is dirty, it is written back to the corresponding area 504 on the main memory 104. Next, the block 503 corresponding to the write target address is read from the main memory 104 and read into both the instruction cache 102 and the data cache 103. Then, the instruction to be written is stored in the block 501 on the instruction cache 102 and the data cache 10.
3 to block 502.

【0037】なお、命令キャッシュ102上のデータに
対応して、データキャッシュ103上に確保されている
キャッシュブロックは、データキャッシュへのデータの
書き込みによる競合によって主記憶へ書き戻されること
があるが、その場合には、命令キャッシュ102上のキ
ャッシュブロックの内容と主記憶104上のデータは一
致しているので、特別な操作を行う必要はない。
It should be noted that a cache block secured on the data cache 103 corresponding to the data on the instruction cache 102 may be written back to the main memory due to contention caused by writing data to the data cache. In this case, since the contents of the cache block in the instruction cache 102 and the data in the main memory 104 match, there is no need to perform any special operation.

【0038】図5は、図4に示した命令キャッシュから
主記憶へのキャッシュブロックの書き戻し機構を追加し
ない場合の主記憶への書き込み処理の流れを示す図であ
る。同図に示すように、主記憶への書き込みを行う場合
(S601)、まず、命令キャッシュを介した書き込み
か否かのチェックを行う(S602)。書き込みが命令
キャッシュを介した書き込みか否かの指定・判定方法に
ついては後述する。
FIG. 5 is a diagram showing a flow of a write process to the main memory when the mechanism for writing back the cache block from the instruction cache to the main memory shown in FIG. 4 is not added. As shown in the figure, when writing to the main memory (S601), first, it is checked whether or not writing is performed via the instruction cache (S602). A method of specifying / determining whether the writing is a writing via the instruction cache will be described later.

【0039】チェックの結果、書き込みが、命令キャッ
シュを介した書き込みでなければ(S602:NO)、
通常のデータキャッシュを介した書き込み処理を行い
(S603)、書き込み処理を終了する(S610)。
As a result of the check, if the write is not a write via the instruction cache (S602: NO),
A write process is performed via a normal data cache (S603), and the write process ends (S610).

【0040】一方、命令キャッシュを介した書き込みで
あれば(S602:YES)、まず、データキャッシュ
に書き込み対象アドレスに対応するブロックが存在する
か否かを調べる(S604)。その結果、対応するブロ
ックがデータキャッシュに存在しなければ(S604:
NO)、データキャッシュに当該ブロックを読み出す
(S605)。更に、命令キャッシュに書き込み対象ア
ドレスに対応するブロックが存在するか否かを調べる
(S606)。
On the other hand, if the write is via the instruction cache (S602: YES), it is first checked whether or not a block corresponding to the write target address exists in the data cache (S604). As a result, if the corresponding block does not exist in the data cache (S604:
NO), the block is read out to the data cache (S605). Further, it is checked whether a block corresponding to the write target address exists in the instruction cache (S606).

【0041】その結果、命令キャッシュに当該ブロック
が存在しなければ(S606:NO)、続けて、データ
キャッシュの当該ブロックがダーティであるか否かを調
べて、ダーティであれば主記憶に当該ブロックを書き戻
す(S607)。次に、書き込み対象アドレスに対応す
るブロックを主記憶から命令キャッシュへ読み出す(S
608)。これにより、主記憶、データキャッシュ、命
令キャッシュの内容が一致するので、データキャッシュ
と命令キャッシュに書き込み対象の命令を書き込み(S
609)、処理を終了する(S610)。
As a result, if the block does not exist in the instruction cache (S606: NO), it is checked whether or not the block in the data cache is dirty. Is written back (S607). Next, the block corresponding to the write target address is read from the main memory to the instruction cache (S
608). As a result, the contents of the main memory, the data cache, and the instruction cache match, so that the instruction to be written is written to the data cache and the instruction cache (S
609), and the process ends (S610).

【0042】一方、命令キャッシュに当該ブロックが存
在すれば(S606:YES)、データキャッシュと命
令キャッシュの両方にブロックが存在することになるの
で、データキャッシュと命令キャッシュに書き込み対象
の命令を書き込み(S609)、処理を終了する(S6
10)。
On the other hand, if the block exists in the instruction cache (S606: YES), the block exists in both the data cache and the instruction cache, so that the instruction to be written is written in the data cache and the instruction cache ( In step S609, the process ends (S6).
10).

【0043】なお、上述した処理フローでは、データキ
ャッシュに書き込み対象アドレスに対応するブロックが
存在しなければ、主記憶からデータキャッシュへの読み
出しを行っているが(S605)、命令キャッシュとデ
ータキャッシュの間でデータの転送が可能であれば、命
令キャッシュに対応するデータが存在する場合は、主記
憶との間の転送は省略することができる。同様に、書き
込み対象アドレスに対応するブロックを主記憶から命令
キャッシュへ読み出しているが(S608)、命令キャ
ッシュとデータキャッシュの間でデータの転送が可能
で、データキャッシュに対応するデータが存在する場合
は、主記憶との間の転送は省略し、命令キャッシュから
コピーするように最適化することができる。
In the above-described processing flow, if there is no block corresponding to the write target address in the data cache, the data is read from the main memory to the data cache (S605). If data corresponding to the instruction cache exists, transfer to and from the main memory can be omitted if data transfer is possible between them. Similarly, the block corresponding to the write target address is read from the main memory to the instruction cache (S608), but data can be transferred between the instruction cache and the data cache and there is data corresponding to the data cache. Can be optimized to copy from the instruction cache, omitting transfers to and from main storage.

【0044】次に、あるデータ書き込みがデータキャッ
シュを介した書き込みか、命令キャッシュを介した書き
込みかを指定・判別する方法について説明する。このよ
うな方法として、例えば、以下の(a)〜(c)に示す
ようなものが考えられる。
Next, a method for designating and determining whether a certain data write is a write via a data cache or a write via an instruction cache will be described. For example, the following methods (a) to (c) are conceivable.

【0045】(a)ページなど所定のメモリ領域毎に、
命令キャッシュ及びデータキャッシュのいずれを介して
書き込みを行う領域かを指定できるようにし、書き込み
対象のアドレスによって判別する方法。
(A) For each predetermined memory area such as a page,
A method in which a write area can be designated via an instruction cache or a data cache, and a determination is made based on an address to be written.

【0046】(b)CPUに内部フラグを設け、フラグ
の設定によって、命令キャッシュ及びデータキャッシュ
のいずれを介して書き込みを行うモードであるかを指定
・判別する方法。
(B) A method in which an internal flag is provided in the CPU, and the setting of the flag specifies / determines whether the mode is one in which writing is performed via the instruction cache or the data cache.

【0047】(c)データ書き込み命令として、命令キ
ャッシュを介したものと、データキャッシュを介したも
のとを分けて用意し、これらの命令を使い分けること
で、指定・判別する方法。
(C) A method in which an instruction via a command cache and an instruction via a data cache are separately prepared as data write instructions, and these instructions are properly used to specify / determine.

【0048】まず、上述した(a)の方法に対応するも
のとして、マイクロプロセッサの命令セットのなかに、
メモリ領域毎に、データキャッシュを介して書き込みが
行われる領域か、命令キャッシュを介して書き込みが行
われる領域かを指定するための命令(例えば、「set-dw
rite」及び「set-iwrite」)を設けた場合について説明
する。プロセッサは、メモリに対する書き込みを実行す
る際、書き込み対象アドレスがいずれの領域に該当する
のか調べて、その結果に応じて、命令キャッシュまたは
データキャッシュを介した書き込みを行う。
First, as a method corresponding to the above method (a), the instruction set of the microprocessor includes:
An instruction (for example, “set-dw”) for specifying, for each memory area, whether the area is to be written via the data cache or the area to be written via the instruction cache.
rite ”and“ set-iwrite ”). When executing writing to the memory, the processor checks which area the write target address corresponds to, and performs writing via the instruction cache or the data cache according to the result.

【0049】命令「set-dwrite」は、そのオペランドに
よって指定されるアドレス領域(例えば、オペランドで
指定されるアドレスから1ページ分)は、データキャッ
シュを介して書き込みが行われるべき領域であることを
指定する命令であり、当該命令実行後は、指定されたア
ドレス領域に対する書き込みはデータキャッシュを介し
て行われるようになる。同様に、命令「set-iwrite」
は、オペランドによって指定されたアドレス領域は、命
令キャッシュを介して書き込みが行われるべき領域であ
ることを指定する命令であり、当該命令実行後は、指定
されたアドレス領域に対する書き込みは命令キャッシュ
を介して行われる。
The instruction "set-dwrite" indicates that the address area specified by the operand (for example, one page from the address specified by the operand) is an area to be written via the data cache. This is an instruction to be specified, and after execution of the instruction, writing to the specified address area is performed via the data cache. Similarly, the instruction "set-iwrite"
Is an instruction designating that the address area specified by the operand is an area where writing should be performed via the instruction cache. After execution of the instruction, writing to the specified address area is performed via the instruction cache. Done.

【0050】図6は、命令「set-dwrite」及び「set-iw
rite」を設けた場合のハードウェア構成例を示す図であ
る。これらの命令は、命令フェッチ・デコードユニット
1001によりメモリからの読み出され、デコードされ
て、実行制御が行われる。命令「set-dwrite」又は命令
「set-iwrite」が実行されると、命令キャッシュを介し
た書き込みかデータキャッシュを介した書き込みかを示
すビットとともに、オペランドで指定されたアドレス
が、方向テーブル1002に記憶される。
FIG. 6 shows instructions “set-dwrite” and “set-iw”.
FIG. 6 is a diagram illustrating an example of a hardware configuration when “rite” is provided. These instructions are read from the memory by the instruction fetch / decode unit 1001, decoded, and execution control is performed. When the instruction “set-dwrite” or the instruction “set-iwrite” is executed, the address specified by the operand is stored in the direction table 1002 together with the bit indicating whether the write is performed through the instruction cache or the data cache. It is memorized.

【0051】そして、メモリへの書き込みを行う命令、
例えば、ストア命令が実行され、データのストアを行う
場合には、まず、ストア命令で指定されたアドレッシン
グ・モードに従って、レジスタ1003の値とストア命
令中で指定された即値(immediate)のいずれかをマル
チプレクサ1004によって選択し、加算器1005
で、レジスタ1003の値と演算して、データを格納す
る実効アドレスを生成する。そして、生成されたアドレ
スが、方向テーブル1002に存在するか否かを比較器
1006により確認し、同時にそのアドレスに対して指
定された書き込み対象キャッシュが命令キャッシュであ
るか否かを比較器1007で調べる。その結果、方向テ
ーブル1002にストア・アドレスが存在し、かつ書き
込み対象キャッシュが命令キャッシュであると指定され
ていた場合は、デマルチプレクサ1008及びデマルチ
プレクサ1009によって、書き込みアドレス、書き込
みデータの供給先として、命令キャッシュ1011を選
択し、書き込みを行う。一方、方向テーブル1002に
ストア・アドレスが存在しないか、又は、書き込み対象
キャッシュが命令キャッシュであると指定されていない
場合は、デマルチプレクサ1008及びデマルチプレク
サ1009によって、書き込みアドレス、書き込みデー
タの供給先として、データキャッシュ1010を選択
し、書き込みを行う。なお、比較器1006が比較対象
とするビット数は、指定される領域の大きさによって、
定まる。
Then, an instruction for writing to the memory,
For example, when a store instruction is executed to store data, first, according to the addressing mode specified by the store instruction, either the value of the register 1003 or the immediate value (immediate) specified in the store instruction is stored. The selection is performed by a multiplexer 1004 and an adder 1005 is selected.
Then, an effective address for storing data is generated by calculating the value of the register 1003. Then, the comparator 1006 checks whether the generated address exists in the direction table 1002, and at the same time, the comparator 1007 determines whether the write target cache specified for the address is an instruction cache. Find out. As a result, when the store address exists in the direction table 1002 and the cache to be written is specified as the instruction cache, the demultiplexer 1008 and the demultiplexer 1009 set the write address and the write data as the supply destination. The instruction cache 1011 is selected and writing is performed. On the other hand, if the store address does not exist in the direction table 1002 or the write target cache is not designated as the instruction cache, the demultiplexer 1008 and the demultiplexer 1009 use the demultiplexer 1008 and the demultiplexer 1009 as the write address and write data supply destination. , The data cache 1010 is selected and writing is performed. Note that the number of bits to be compared by the comparator 1006 depends on the size of the designated area.
Is determined.

【0052】次に、上述した(b)の方法に対応するも
のとして、マイクロプロセッサの内部に、メモリに対す
る書き込みを、データキャッシュを介して行うモードで
あるか、命令キャッシュを介して行うモードであるかを
表すフラグを設けるとともに、命令セットのなかにフラ
グ設定命令(例えば、「set-iwrite-flag」及び「reset
-iwrite-flag」)を設けた場合について説明する。命令
「set-iwrite-flag」及び「reset-iwrite-flag」は、C
PUに設けられた内部フラグ(iwrite-flag)を制御
(セット/リセット)するための命令であり、CPU
は、このフラグの設定値に従って、命令キャッシュを介
してデータの書き込みを行うか、データキャッシュを介
してデータの書き込みを行うかを決定する。
Next, as a method corresponding to the above-mentioned method (b), a mode in which writing to a memory is performed via a data cache or an instruction cache inside a microprocessor is performed. And a flag setting instruction (for example, “set-iwrite-flag” and “reset
-iwrite-flag ") will be described. The instructions "set-iwrite-flag" and "reset-iwrite-flag"
This is an instruction for controlling (set / reset) an internal flag (iwrite-flag) provided in the PU.
Determines whether to write data via the instruction cache or to write data via the data cache according to the setting value of this flag.

【0053】ここで、命令「set-iwrite-flag」は、命
令キャッシュを介して書き込みが行われるように、内部
フラグをセットする命令であり、当該命令実行後の書き
込み命令はすべて命令キャッシュを介して行われる。こ
れに対して、命令「reset-iwrite-flag」は、データキ
ャッシュを介して書き込みが行われるように、内部フラ
グをリセットする命令であり、当該命令実行後の書き込
みはすべてデータキャッシュを介して行われる。
Here, the instruction "set-iwrite-flag" is an instruction for setting an internal flag so that writing is performed via the instruction cache, and all write instructions after execution of the instruction are transmitted via the instruction cache. Done. On the other hand, the instruction “reset-iwrite-flag” is an instruction for resetting an internal flag so that writing is performed via the data cache, and all writing after execution of the instruction is performed via the data cache. Will be

【0054】図7は、内部フラグ並びに命令「set-iwri
te-flag」及び「reset-iwrite-flag」を設けた場合のハ
ードウェア構成例を示す図である。命令「set-iwrite-f
lag」及び「reset-iwrite-flag」は、命令フェッチ・デ
コードユニット1101により、メモリから読み出さ
れ、デコードされ、実行制御が行われる。命令「set-dw
rite-flag」又は「set-iwrite-flag」が実行されると、
現在の書き込みモードを表すフラグが内部フラグ(iwri
te-flag)1102に記憶される。
FIG. 7 shows an internal flag and an instruction "set-iwri".
It is a figure which shows the example of a hardware structure at the time of providing "te-flag" and "reset-iwrite-flag". The instruction `` set-iwrite-f
The “lag” and “reset-iwrite-flag” are read from the memory and decoded by the instruction fetch / decode unit 1101, and execution control is performed. The instruction `` set-dw
When "rite-flag" or "set-iwrite-flag" is executed,
The flag indicating the current write mode is an internal flag (iwri
te-flag) 1102.

【0055】そして、ストア命令等によりデータの書き
込みを行う場合には、図6の場合と同様にして実効アド
レスを、レジスタ1103、マルチプレクサ1104、
加算器1105によって生成する。そして、デマルチプ
レクサ1106、1107では、フラグ1102の値に
従ってアドレスおよびデータの供給先を選択し、データ
キャッシュ1109または命令キャッシュ1108へ書
き込みを行う。
When data is written by a store instruction or the like, the effective address is stored in the register 1103, the multiplexer 1104,
It is generated by the adder 1105. Then, the demultiplexers 1106 and 1107 select an address and a data supply destination in accordance with the value of the flag 1102, and write the data and data into the data cache 1109 or the instruction cache 1108.

【0056】最後に、上述した(c)の方法に対応する
ものとして、命令コードによって命令キャッシュを介し
てデータの書き込みを行うか、データキャッシュを介し
てデータの書き込みを行うかを指定・決定する場合につ
いて説明する。すなわち、マイクロプロセッサの命令セ
ットのなかに、データ書き込み命令として、通常の、デ
ータキャッシュを介してデータの書き込みを行う命令
(例えば、「write」)の他に、命令キャッシュを介し
てデータの書き込みを行う命令(例えば、「iwrite」)
を用意し、ソフトウェア等は、これら2種の命令を適宜
選択して使用することにより、主記憶への書き込みの際
に介するキャッシュの選択を行う。
Finally, as a method corresponding to the above-mentioned method (c), it is designated and determined whether to write data via an instruction cache or to write data via a data cache by an instruction code. The case will be described. That is, in the instruction set of the microprocessor, as a data write instruction, in addition to a normal instruction for writing data via the data cache (for example, “write”), a data write via the instruction cache is included. The instruction to perform (eg, "iwrite")
, And software or the like selects a cache for writing to the main memory by appropriately selecting and using these two types of instructions.

【0057】命令「iwrite」が実行されると、オペラン
ドで指定された実効アドレスに対して、オペランドで指
定したレジスタ等に格納されたデータ(命令)を、命令
キャッシュを介して書き込む。
When the instruction “iwrite” is executed, the data (instruction) stored in the register or the like specified by the operand is written to the effective address specified by the operand via the instruction cache.

【0058】図8は、命令「iwrite」を設けた場合のハ
ードウェア構成例を示す図である。命令「iwrite」は、
命令フェッチ・デコードユニット1201により主記憶
や命令キャッシュからの読み出され、デコードされ、実
行制御が行われる。命令キャッシュを対象としたストア
命令「iwrite」により、データのストアを行う場合に
は、まず、前述したのと同様にして、レジスタ120
3、マルチプレクサ1204、加算器1205でアドレ
スを生成する。デマルチプレクサ1206、1207で
は、命令フェッチ・デコードユニット1201からの、
当該命令が命令キャッシュを対象としたストア命令であ
ることを表す出力信号1202によりデータの書き込み
先として、命令キャッシュ1208を選択し、書き込み
を行う。
FIG. 8 is a diagram showing an example of a hardware configuration in the case where the instruction "iwrite" is provided. The instruction "iwrite"
The instruction fetch / decode unit 1201 reads the data from the main memory or the instruction cache, decodes the data, and controls the execution. When data is stored by a store instruction “iwrite” for the instruction cache, first, the register 120
3. The address is generated by the multiplexer 1204 and the adder 1205. In the demultiplexers 1206 and 1207, the instruction fetch / decode unit 1201
The instruction cache 1208 is selected as a data write destination by the output signal 1202 indicating that the instruction is a store instruction for the instruction cache, and writing is performed.

【0059】同様にデータキャッシュを対象としたスト
ア命令「write」によりデータのストアを行う場合に
は、デマルチプレクサ1206、1207では命令フェ
ッチ・デコードユニット1201からの出力信号120
2によりアドレスおよびデータの供給先として、データ
キャッシュを選択し、データキャッシュ1209への書
き込みを行う。
Similarly, when data is stored by a store instruction “write” for a data cache, the demultiplexers 1206 and 1207 output signals 120 from the instruction fetch / decode unit 1201.
2, the data cache is selected as the address and data supply destination, and writing to the data cache 1209 is performed.

【0060】以上説明したような、命令キャッシュへの
書き込みをソフトウェア的に制御できる機構をマイクロ
プロセッサに設けることにより、主記憶とキャッシュ間
(又は、上位キャッシュと下位キャッシュ間)の不要な
データの転送を減少させ、動的な命令生成を行うプログ
ラムの性能を向上させることが可能となる。
By providing a mechanism for controlling writing to the instruction cache by software as described above in the microprocessor, transfer of unnecessary data between the main memory and the cache (or between the upper cache and the lower cache) is performed. , And the performance of a program that dynamically generates instructions can be improved.

【0061】最後に、上述したような本発明によるマイ
クロプロセッサ上で実行される動的コンパイラについて
説明する。本発明によるマイクロプロセッサでは、命令
キャッシュへの書き込みをソフトウェア的に制御できる
ので、動的コンパイラは、プログラム実行時に動的に生
成した命令を主記憶に格納する際、上述したいずれかの
方法を使って、命令キャッシュを介して書き込むように
する。これ以外の動作は、従来の動的コンパイラの動作
と同様でよい。このようにすれば、動的に生成した命令
を主記憶に格納する場合の主記憶参照の必要性が減り、
プログラムの高速実行が可能になる。
Finally, a dynamic compiler executed on the microprocessor according to the present invention as described above will be described. In the microprocessor according to the present invention, since writing to the instruction cache can be controlled by software, the dynamic compiler uses any one of the above-described methods when storing dynamically generated instructions in the main memory during program execution. And write via the instruction cache. Other operations may be the same as those of the conventional dynamic compiler. This reduces the need for main memory reference when storing dynamically generated instructions in main memory,
The program can be executed at high speed.

【0062】[0062]

【発明の効果】以上、詳細に説明したように、本発明に
よれば、実行時に動的に機械語命令の生成を行うプログ
ラムにおいて、生成した機械語命令を直接命令キャッシ
ュへ書き込むことが可能となる。これにより、実行時に
動的に機械語命令の生成を行うプログラムの実行の高速
化が図れる。
As described above in detail, according to the present invention, in a program for dynamically generating a machine language instruction at the time of execution, it is possible to write the generated machine language instruction directly to the instruction cache. Become. As a result, it is possible to speed up the execution of a program that dynamically generates a machine language instruction at the time of execution.

【図面の簡単な説明】[Brief description of the drawings]

【図1】 本発明による非統合型キャッシュのマイクロ
プロセッサの動作概要を説明する図である。
FIG. 1 is a diagram illustrating an operation outline of a microprocessor of a non-integrated cache according to the present invention.

【図2】 命令キャッシュから主記憶への書き込みパス
を設けたマイクロプロセッサにおける、動的に生成され
た命令の流れを示す図である。
FIG. 2 is a diagram showing a flow of dynamically generated instructions in a microprocessor provided with a write path from an instruction cache to a main memory.

【図3】 命令キャッシュから主記憶への書き込みパス
を設けたマイクロプロセッサにおける、書き込み処理の
流れを示す図である。
FIG. 3 is a diagram showing a flow of a write process in a microprocessor provided with a write path from an instruction cache to a main memory.

【図4】 命令キャッシュから主記憶への書き込みパス
を有しないマイクロプロセッサにおける、動的に生成さ
れた命令の流れを示す図である。
FIG. 4 is a diagram showing a flow of dynamically generated instructions in a microprocessor having no write path from an instruction cache to a main memory.

【図5】 命令キャッシュから主記憶への書き込みパス
を有しないマイクロプロセッサにおける、書き込み処理
の流れを示す図である。
FIG. 5 is a diagram showing a flow of a write process in a microprocessor having no write path from an instruction cache to a main memory.

【図6】 所定のメモリ領域毎に、書き込み対象キャッ
シュを指定できる命令を設けたマイクロプロセッサのハ
ードウェア構成例を示す図である。
FIG. 6 is a diagram illustrating an example of a hardware configuration of a microprocessor provided with an instruction capable of specifying a write target cache for each predetermined memory area;

【図7】 命令キャッシュを介して書き込むモードか、
データキャッシュを介して書き込むモードかを指定する
内部フラグを設けたマイクロプロセッサのハードウェア
構成例を示す図である。
FIG. 7 shows a mode for writing via an instruction cache;
FIG. 3 is a diagram illustrating an example of a hardware configuration of a microprocessor provided with an internal flag that specifies a writing mode via a data cache.

【図8】 命令キャッシュを介して書き込みを行う命令
を設けたマイクロプロセッサのハードウェア構成例を示
す図である。
FIG. 8 is a diagram illustrating a hardware configuration example of a microprocessor provided with an instruction to perform writing via an instruction cache.

【図9】 本発明が適用される計算機システムの例を示
す図である。
FIG. 9 is a diagram illustrating an example of a computer system to which the present invention is applied.

【符号の説明】[Explanation of symbols]

101 CPU 102 命令キャッシュ 103 データキャッシュ 104 主記憶 105 ALU 106 レジスタ 107 メモリユニット 108 命令デコーダ 101 CPU 102 Instruction Cache 103 Data Cache 104 Main Memory 105 ALU 106 Register 107 Memory Unit 108 Instruction Decoder

Claims (7)

【特許請求の範囲】[Claims] 【請求項1】 命令セットの中に、所定のメモリ領域毎
に、当該領域が、データキャッシュを介して書き込みを
行う領域か、命令キャッシュを介して書き込みを行う領
域かを指定することができる命令を有することを特徴と
するプロセッサ。
1. An instruction capable of designating, in an instruction set, for each predetermined memory area, whether the area is an area for writing via a data cache or an area for writing via an instruction cache. A processor comprising:
【請求項2】 前記命令によって命令キャッシュを介し
て書き込みを行う領域として指定されたメモリ領域に対
して、書き込みが指示された場合は、命令キャッシュを
介して書き込みを行うことを特徴とする請求項1に記載
のプロセッサ。
2. The method according to claim 1, wherein when writing is instructed to a memory area specified as an area to be written via an instruction cache by the instruction, writing is performed via the instruction cache. The processor according to claim 1.
【請求項3】 データキャッシュを介して書き込みを行
うモードであるか、命令キャッシュを介して書き込みを
行うモードであるかを表すフラグを備え、 当該フラグが命令キャッシュを介して書き込みを行うモ
ードであることを示している場合は、命令キャッシュを
介して書き込みを行うことを特徴とするプロセッサ。
3. A mode for writing data via a data cache or a mode for writing data via an instruction cache, wherein the flag is a mode for writing data via an instruction cache. If so, writing is performed via an instruction cache.
【請求項4】 命令セットの中に、前記フラグを操作す
る命令を有することを特徴とする請求項3に記載のプロ
セッサ。
4. The processor according to claim 3, further comprising an instruction for operating said flag in an instruction set.
【請求項5】 命令セットの中に、命令キャッシュを介
してメモリへの書き込みを行うことを指示する命令を有
することを特徴とするプロセッサ。
5. The processor according to claim 1, further comprising an instruction in the instruction set for instructing writing to the memory via the instruction cache.
【請求項6】 命令キャッシュを介した書き込みが指示
された場合、命令キャッシュとデータキャッシュの両方
に書き込みを行うことを特徴とする請求項1乃至請求項
5のいずれか一項に記載のプロセッサ。
6. The processor according to claim 1, wherein when writing via the instruction cache is instructed, writing is performed to both the instruction cache and the data cache.
【請求項7】 請求項1乃至請求項6のいずれか一項に
記載のプロセッサを使った動的コンパイルの方法であっ
て、 動的に生成した命令をメモリへ書き込む場合、命令キャ
ッシュを介して書き込むようにすることを特徴とする動
的コンパイルの方法。
7. A method for dynamically compiling using a processor according to claim 1, wherein when dynamically generated instructions are written to a memory, said instructions are transmitted via an instruction cache. A dynamic compilation method characterized by writing.
JP20026698A 1998-07-15 1998-07-15 Processor with instruction cache write mechanism Expired - Fee Related JP3693503B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP20026698A JP3693503B2 (en) 1998-07-15 1998-07-15 Processor with instruction cache write mechanism

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP20026698A JP3693503B2 (en) 1998-07-15 1998-07-15 Processor with instruction cache write mechanism

Publications (2)

Publication Number Publication Date
JP2000029787A true JP2000029787A (en) 2000-01-28
JP3693503B2 JP3693503B2 (en) 2005-09-07

Family

ID=16421484

Family Applications (1)

Application Number Title Priority Date Filing Date
JP20026698A Expired - Fee Related JP3693503B2 (en) 1998-07-15 1998-07-15 Processor with instruction cache write mechanism

Country Status (1)

Country Link
JP (1) JP3693503B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006318471A (en) * 2005-05-09 2006-11-24 Sony Computer Entertainment Europe Ltd Memory caching in data processing

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006318471A (en) * 2005-05-09 2006-11-24 Sony Computer Entertainment Europe Ltd Memory caching in data processing
JP4666511B2 (en) * 2005-05-09 2011-04-06 ソニー コンピュータ エンタテインメント ヨーロッパ リミテッド Memory caching in data processing

Also Published As

Publication number Publication date
JP3693503B2 (en) 2005-09-07

Similar Documents

Publication Publication Date Title
JP3289661B2 (en) Cache memory system
US6456891B1 (en) System and method for transparent handling of extended register states
US6665776B2 (en) Apparatus and method for speculative prefetching after data cache misses
US7219185B2 (en) Apparatus and method for selecting instructions for execution based on bank prediction of a multi-bank cache
JP4057114B2 (en) Data processing system with cache and method therefor
JP3739491B2 (en) Harmonized software control of Harvard architecture cache memory using prefetch instructions
US7873814B1 (en) Microcode based hardware translator to support a multitude of processors
JP2902976B2 (en) Cache flush device
JP2000057054A (en) High speed address translation system
JPH0612327A (en) Data processor having cache memory
JPH10254772A (en) Method and system for executing cache coherence mechanism to be utilized within cache memory hierarchy
US6718539B1 (en) Interrupt handling mechanism in translator from one instruction set to another
JPH06236353A (en) Method and system for increase of parallelism of system memory of multiprocessor computer system
KR100505695B1 (en) Cache memory device having dynamically-allocated or deallocated buffers, digital data processing system comprising it and method thereof
US8266379B2 (en) Multithreaded processor with multiple caches
JP4018837B2 (en) Memory address conversion apparatus and data processing method in data processing system
JP3088303B2 (en) Cache memory bank controller
JP2002032264A (en) Cache memory device and central processing unit using the same
JP3693503B2 (en) Processor with instruction cache write mechanism
JP2001166989A (en) Memory system having prefetch mechanism and method for operating the system
CN115481072A (en) Inter-core data transmission method, multi-core chip and machine-readable storage medium
EP0101718B1 (en) Computer with automatic mapping of memory contents into machine registers
JP3830236B2 (en) Method and data processing system for using quick decode instructions
JPH08137748A (en) Computer having copy back cache and copy back cashe control method
US20020010837A1 (en) Cache memory system and method of controlling cache memory

Legal Events

Date Code Title Description
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20040827

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20050125

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20050325

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20050614

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20050621

LAPS Cancellation because of no payment of annual fees