JP2011141619A - Microprocessor - Google Patents

Microprocessor Download PDF

Info

Publication number
JP2011141619A
JP2011141619A JP2010000727A JP2010000727A JP2011141619A JP 2011141619 A JP2011141619 A JP 2011141619A JP 2010000727 A JP2010000727 A JP 2010000727A JP 2010000727 A JP2010000727 A JP 2010000727A JP 2011141619 A JP2011141619 A JP 2011141619A
Authority
JP
Japan
Prior art keywords
flag
instruction
setting
register
memory
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2010000727A
Other languages
Japanese (ja)
Inventor
Jun Takanashi
潤 高梨
Masanao Sasai
政尚 笹井
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Renesas Electronics Corp
Original Assignee
Renesas Electronics Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Renesas Electronics Corp filed Critical Renesas Electronics Corp
Priority to JP2010000727A priority Critical patent/JP2011141619A/en
Publication of JP2011141619A publication Critical patent/JP2011141619A/en
Pending legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To efficiently compare a preceding input value and this-time input value, in a microprocessor skipping execution of some processing according to a comparison result between the preceding input value and this-time input value of the processing. <P>SOLUTION: The microprocessor 100 includes: a main memory 110 provided with an evacuation area 112 storing a value of a register a; a cache memory 120; and a flag 180 having first and second status. The microprocessor 100 copes with a flag reset instruction, a flag setting-equipped memory read instruction, a flag setting-equipped memory write instruction, a flag setting-equipped register setting instruction, and a flag reference-equipped branch instruction. <P>COPYRIGHT: (C)2011,JPO&INPIT

Description

本発明は、マイクロプロセッサに関する。   The present invention relates to a microprocessor.

近年、マイクロプロセッサが様々な分野で広く利用されるようになっており、マイクロプロセッサに対して、種々の視点から改良する試みがなされている。   In recent years, microprocessors have been widely used in various fields, and attempts have been made to improve the microprocessors from various viewpoints.

例えば、特許文献1に開示された技術は、キャッシュミスとキャッシュヒット時のコードを夫々作成しておき、キャッシュミスまたはキャッシュヒットが生じた際に、対応するコードに分岐する。この技術によれば、コンバイルの効率を向上させることができるとされている。   For example, the technique disclosed in Patent Document 1 creates a code at the time of a cache miss and a cache hit, and branches to a corresponding code when a cache miss or a cache hit occurs. According to this technique, it is said that the efficiency of the combine can be improved.

また、特許文献2に開示された技術は、CPU内(汎用演算ユニット内や浮動小数点演算ユニット内など)に履歴記憶を設け、既に実行した各命令に対して、演算の入力と結果のデータ、主記憶のリード/ライトアドレスとデータなどを履歴記憶に記憶しておく。再度同じ命令(演算命令またはリード/ライト命令)を実行する際に、履歴記憶の内容に応じて演算またはリード/ライトの実行をスキップする。具体的には、演算命令を実行する場合には、現在の入力データと、履歴記憶において記憶され、過去における該演算命令の入力データとを比較し、それらが同じである場合には、演算の実行をスキップする。また、リード/ライト命令を実行する場合には、現在のリード/ライトアドレスと履歴記憶に記憶されたリード/ライトアドレスとを比較し、それらが同じである場合には、リード/ライトの実行をスキップする。こうすることにより、命令の実行時間を短縮し、主記憶に対するロード/ストア操作を抑制することができるとされている。また、実行される命令に対応する履歴情報の有無を判定する時間を短縮するために、命令を命令キューに登録する際に、該命令に対して、対応する履歴情報の有無をVフィールドに登録する。そして、命令キュー内の命令を実行する際に、そのVフィールドを参照し、対応する履歴情報があれば、上述した比較を行う。   Further, the technique disclosed in Patent Document 2 provides a history storage in a CPU (in a general-purpose arithmetic unit, a floating-point arithmetic unit, etc.), and for each instruction that has already been executed, input of arithmetic and result data, The main memory read / write address and data are stored in the history memory. When the same instruction (calculation instruction or read / write instruction) is executed again, execution of the calculation or read / write is skipped according to the contents of the history storage. Specifically, when executing an arithmetic instruction, the current input data is stored in the history storage, and the input data of the arithmetic instruction in the past is compared. Skip execution. When a read / write instruction is executed, the current read / write address is compared with the read / write address stored in the history storage. If they are the same, the read / write is executed. skip. By doing so, it is said that instruction execution time can be shortened and load / store operations for main memory can be suppressed. In addition, when registering an instruction in the instruction queue, the presence / absence of corresponding history information is registered in the V field when the instruction is registered in the instruction queue in order to shorten the time for determining the presence / absence of history information corresponding to the executed instruction. To do. Then, when executing an instruction in the instruction queue, the V field is referred to, and if there is corresponding history information, the above-described comparison is performed.

特開平10−91455号公報Japanese Patent Laid-Open No. 10-91455 再公表特許WO98/11484号公報Republished patent WO98 / 11484

マイクロプロセッサが行う処理のうち、ある処理(処理Bとする)の入力値は、他の処理(処理Aとする)の実行結果である場合がある。この場合において、例えば図16に示すフローのように、特許文献2の手法を適用することができる。分かりやすいように、例として、処理Aでは1つの命令(命令A)のみが実行され、処理Bでは1つの命令(命令B)のみが実行される。   Of the processes performed by the microprocessor, an input value of a certain process (referred to as process B) may be an execution result of another process (referred to as process A). In this case, for example, the method of Patent Document 2 can be applied as in the flow shown in FIG. For ease of understanding, as an example, only one instruction (instruction A) is executed in process A, and only one instruction (instruction B) is executed in process B.

CPU内に履歴記憶を設け、過去に実行された命令Bの入力値と実行結果とを対応付けて記憶するための履歴記憶を設ける。そして、命令Aの実行により命令Bの今回の入力値を得ると(S10)、履歴記憶に記憶された命令Bの以前の入力値と実行結果を読み込んで、以前の入力値と今回の入力値を比較する(S12、S14)。比較の結果、以前の入力値のうちに、今回の入力値と同じ入力値がある場合には(S14:Yes)、命令Bの実行をスキップする。一方、今回の入力値と同じ入力値が無い場合には、今回の入力値を履歴記憶に追加すると共に、命令Bを実行する(S14:No、S16、S18)。そして、命令Bの今回の実行結果を、履歴記憶に追加する(S20)。   A history storage is provided in the CPU, and a history storage for storing the input value of the instruction B executed in the past and the execution result in association with each other is provided. When the current input value of the command B is obtained by executing the command A (S10), the previous input value and the execution result of the command B stored in the history storage are read, and the previous input value and the current input value are read. Are compared (S12, S14). As a result of the comparison, if there is an input value that is the same as the current input value among the previous input values (S14: Yes), execution of the instruction B is skipped. On the other hand, if there is no input value that is the same as the current input value, the current input value is added to the history storage and the command B is executed (S14: No, S16, S18). Then, the current execution result of the instruction B is added to the history storage (S20).

図16に示すフローから分かるように、この手法では、命令Bを実行する度に過去の入力値との比較を行う必要がある。特許文献2に記載されたように、命令キューに命令を登録する際に、履歴記憶のVフィールドに該命令に対応する履歴情報の有無を記載するようにしたとしても、命令Bの実行に際して、該命令に対応する履歴情報の有無が分かるようになったに過ぎず、上記比較を省くことができない。   As can be seen from the flow shown in FIG. 16, in this method, it is necessary to compare with a past input value every time the instruction B is executed. As described in Patent Document 2, when registering an instruction in the instruction queue, even if the history information corresponding to the instruction is described in the V field of the history storage, Only the presence / absence of history information corresponding to the command can be known, and the comparison cannot be omitted.

本発明の一つの態様は、マイクロプロセッサである。このマイクロプロセッサは、メインメモリと、キャッシュメモリと、第1と第2のステータスを有するフラグとを備える。   One embodiment of the present invention is a microprocessor. The microprocessor includes a main memory, a cache memory, and a flag having first and second statuses.

このマイクロプロセッサは、上記フラグの設定を伴うメモリリード命令であるフラグ設定付きメモリリード命令と、上記フラグの設定を伴い、メモリリード以外によりデータを得ると共に該データをレジスタに設定するレジスタ設定命令であるフラグ設定付きレジスタ設定命令と、上記フラグの設定を伴うメモリライト命令であるフラグ設定付きライト命令と、フラグリセット命令と、フラグ参照分岐命令とに対応する。   This microprocessor includes a memory read instruction with a flag setting, which is a memory read instruction accompanied by the setting of the flag, and a register setting instruction that obtains data by other than the memory read and sets the data in a register together with the setting of the flag. It corresponds to a register setting instruction with a flag setting, a write instruction with a flag setting which is a memory write instruction with the setting of the flag, a flag reset instruction, and a flag reference branch instruction.

該マイクロプロセッサは、フラグリセット命令に従ってフラグを第1のステータスに設定する。   The microprocessor sets the flag to the first status according to the flag reset instruction.

また、フラグ設定付きメモリリード命令に従って読出しを行い、読出し時にキャッシュミスが生じた場合と、リードアドレスが非キャッシュ領域のアドレスであり、かつ読み出したデータが前記リードアドレスに対応するキャッシュデータと異なる場合において、フラグを前記第2のステータスに設定する。   In addition, when reading is performed according to a memory read instruction with a flag set, a cache miss occurs at the time of reading, and the read address is an address in a non-cache area, and the read data is different from the cache data corresponding to the read address The flag is set to the second status.

また、フラグ設定付きメモリライト命令に従って書込みを行い、書込み時にキャッシミスが生じた場合と、ライトアドレスに対応するキャッシュデータと書込データが異なる場合において、フラグを第2のステータスに設定する。   Further, writing is performed according to the memory write instruction with flag setting, and the flag is set to the second status when a cache miss occurs during writing and when the cache data corresponding to the write address and the write data are different.

また、フラグ設定付きレジスタ設定命令に従って、今回得られたデータと、該命令の前回の実行により設定されたレジスタの値とを比較し、一致しない場合にのみ、フラグを第2のステータスに設定すると共に、今回得られたデータでレジスタの値を更新する。   Further, according to the register setting instruction with flag setting, the data obtained this time is compared with the register value set by the previous execution of the instruction, and the flag is set to the second status only when they do not match. At the same time, the value of the register is updated with the data obtained this time.

また、フラグ参照付き分岐命令に従って、フラグを参照し、フラグが第1のステータスであるときには、指定された分岐先への分岐をし、フラグが第2のステータスであるときには、次の命令を実行する。   Also, according to the branch instruction with flag reference, the flag is referred to. When the flag is in the first status, the branch is made to the specified branch destination, and when the flag is in the second status, the next instruction is executed. To do.

なお、上記態様のマイクロプロセッサを方法やシステムに置き換えて表現したもの、該マイクロプロセッサの一部の処理をコンピュータに実行せしめるプログラム、該マイクロプロセッサを備えた装置なども、本発明の態様としては有効である。   Note that a representation in which the microprocessor of the above aspect is replaced with a method or system, a program that causes a computer to execute a part of the processing of the microprocessor, an apparatus including the microprocessor, and the like are also effective as an aspect of the present invention. It is.

本発明にかかる技術によれば、ある処理の前の入力値と今回の入力値との比較結果に応じて該処理の実行をスキップするマイクロプロセッサにおいて、入力値の比較を効率良く行うことができる。   According to the technology of the present invention, input values can be compared efficiently in a microprocessor that skips execution of the process according to a comparison result between an input value before a certain process and the current input value. .

本発明の第1の実施の形態にかかるマイクロプロセッサを示す図である。It is a figure which shows the microprocessor concerning the 1st Embodiment of this invention. 図1に示すマイクロプロセッサがフラグ設定付きメモリライト命令を実行するフローチャートである。2 is a flowchart for executing a memory write instruction with a flag set by the microprocessor shown in FIG. 1. 図1に示すマイクロプロセッサがフラグ設定付きメモリリード命令を実行するフローチャートである。3 is a flowchart for executing a memory read instruction with a flag set by the microprocessor shown in FIG. 1. 図1に示すマイクロプロセッサがフラグ設定付きレジスタ設定命令を実行するフローチャートである。FIG. 3 is a flowchart in which the microprocessor shown in FIG. 1 executes a register setting instruction with flag setting. 図1に示すマイクロプロセッサがフラグ参照付き分岐命令を実行するフローチャートである。2 is a flowchart for executing a branch instruction with a flag reference by the microprocessor shown in FIG. 処理例を示す図である。It is a figure which shows the process example. 図1に示すマイクロプロセッサにより図6に示す処理を実行するための命令コードである。7 is an instruction code for executing the processing shown in FIG. 6 by the microprocessor shown in FIG. 図1に示すマイクロプロセッサが図7に示す命令コードを実行するフローチャートである。8 is a flowchart in which the microprocessor shown in FIG. 1 executes the instruction code shown in FIG. 図7に示す命令コードの実行に伴う各構成要素の状態遷移を示す図である(その1)。FIG. 8 is a diagram showing a state transition of each component accompanying execution of the instruction code shown in FIG. 7 (No. 1). 図7に示す命令コードの実行に伴う各構成要素の状態遷移を示す図である(その2)。FIG. 8 is a diagram showing state transition of each component accompanying execution of the instruction code shown in FIG. 7 (No. 2). 図6に示す処理例を本発明とは別の手法で実現する場合の命令コードの一例を示す図である。It is a figure which shows an example of the instruction code in the case of implement | achieving the process example shown in FIG. 6 by the method different from this invention. 図11に示す命令コードの実行に伴い各構成要素の遷移を示す図である。It is a figure which shows the transition of each component accompanying execution of the instruction code shown in FIG. 図6に示す処理例を本発明とは別の手法で実現する場合の命令コードの別の例を示す図である。It is a figure which shows another example of the instruction code in the case of implement | achieving the process example shown in FIG. 6 with the method different from this invention. 図13に示す命令コードの実行に伴う各構成要素の状態遷移を示す図である(その1)。It is a figure which shows the state transition of each component accompanying execution of the instruction code shown in FIG. 13 (the 1). 図13に示す命令コードの実行に伴う各構成要素の状態遷移を示す図である(その2)。It is a figure which shows the state transition of each component accompanying execution of the instruction code shown in FIG. 13 (the 2). 特許文献2の手法の問題点を説明するための図である。It is a figure for demonstrating the problem of the method of patent document 2. FIG.

以下、図面を参照して本発明の実施の形態について説明する。説明の明確化のため、以下の記載及び図面は、適宜、省略、及び簡略化がなされている。また、様々な処理を行う機能ブロックとして図面に記載される各要素は、ハードウェア的には、CPU、メモリ、その他の回路で構成することができ、ソフトウェア的には、メモリにロードされたプログラムなどによって実現される。なお、各図面において、同一の要素には同一の符号が付されており、必要に応じて重複説明は省略されている。   Embodiments of the present invention will be described below with reference to the drawings. For clarity of explanation, the following description and drawings are omitted and simplified as appropriate. Each element described in the drawings as a functional block for performing various processes can be configured by a CPU, a memory, and other circuits in terms of hardware, and a program loaded in the memory in terms of software. Etc. Note that, in each drawing, the same element is denoted by the same reference numeral, and redundant description is omitted as necessary.

図1は、本発明の第1の実施の形態にかかるマイクロプロセッサ100を示す。マイクロプロセッサ100は、メインメモリ110、キャッシュメモリ120、メモリI/O130と、CPU140、レジスタ群150、バス190を備える。   FIG. 1 shows a microprocessor 100 according to a first embodiment of the present invention. The microprocessor 100 includes a main memory 110, a cache memory 120, a memory I / O 130, a CPU 140, a register group 150, and a bus 190.

CPU130は、命令を制御する命令制御ユニット、分岐演算を行う分岐演算ユニット、固定小数点命令とロード/ストア命令を実行する汎用演算ユニット、浮動小数点演算を実行する浮動小数点演算ユニットなどの図示しない構成要素を備える。CPU140は、レジスタ群150内の各レジスタに直接アクセスする一方、バス190を介して、メインメモリ110、キャッシュメモリ120、メモリI/O130との間のデータや命令の受渡しを行う。   The CPU 130 includes components (not shown) such as an instruction control unit that controls instructions, a branch operation unit that performs branch operations, a general-purpose operation unit that executes fixed-point instructions and load / store instructions, and a floating-point operation unit that executes floating-point operations. Is provided. The CPU 140 directly accesses each register in the register group 150, and transfers data and instructions to / from the main memory 110, the cache memory 120, and the memory I / O 130 via the bus 190.

レジスタ群150には、複数のレジスタ(レジスタa、b、c、・・・)と、フラグレジスタ180を備える。   The register group 150 includes a plurality of registers (registers a, b, c,...) And a flag register 180.

以下において、説明上の便宜のため、フラグレジスタ180をフラグ180といい、単に「レジスタ」をいう場合には、フラグ180以外のレジスタを意味する。   In the following description, for convenience of explanation, the flag register 180 is referred to as a flag 180, and the term “register” simply refers to a register other than the flag 180.

メインメモリ110には、レジスタの値を保存するための退避領域112が設けられている。   The main memory 110 is provided with a save area 112 for saving register values.

マイクロプロセッサ100は、以下の点において、キャッシュメモリを備える通常のマイクロプロセッサと異なる。
(1)フラグ180を有する。
(3)CPU140は下記の5つの命令に対応する:
フラグリセット命令、フラグ設定付きメモリリード命令、フラグ設定付きメモリリード命令、フラグ設定付きレジスタ設定命令、フラグ参照付き分岐命令。
The microprocessor 100 is different from a normal microprocessor including a cache memory in the following points.
(1) It has a flag 180.
(3) The CPU 140 corresponds to the following five commands:
Flag reset instruction, memory read instruction with flag setting, memory read instruction with flag setting, register setting instruction with flag setting, branch instruction with flag reference.

フラグ180は、CPU140によりステータスが設定される。フラグレジスタ180は、「同一」または「異なる」の2つのステータスを有し、例えば値「0」が「同一」ステータスを示し、値「1」が「異なる」ステータスを示す。   The status of the flag 180 is set by the CPU 140. The flag register 180 has two statuses “same” or “different”. For example, a value “0” indicates a “same” status, and a value “1” indicates a “different” status.

フラグリセット命令は、フラグ180のステータスをリセットする命令である。この命令に対して、CPU140は、フラグ180のステータスを2つのステータスのうちの所定の一方に設定する。本実施の形態において、例として、CPU140は、フラグリセット命令に対して、フラグ180のステータスを「0」(同一)に設定する。   The flag reset command is a command for resetting the status of the flag 180. In response to this instruction, the CPU 140 sets the status of the flag 180 to a predetermined one of the two statuses. In the present embodiment, as an example, the CPU 140 sets the status of the flag 180 to “0” (same) in response to the flag reset command.

フラグ設定付きメモリライト命令は、フラグ180の設定を伴うメモリライト命令である。この命令に対して、CPU140は、通常のメモリライト時の処理以外に、フラグ180の設定を行う場合がある。図2は、CPU140がこの命令を実行するフローチャートの一例である。   The memory write instruction with flag setting is a memory write instruction with the setting of the flag 180. In response to this command, the CPU 140 may set the flag 180 in addition to the normal memory write process. FIG. 2 is an example of a flowchart in which the CPU 140 executes this command.

CPU140は、フラグ設定付きメモリライト命令を実行する際に、2つの場合においてフラグ180のステータスを、フラグリセット命令により設定されるステータスと異なるステータスすなわち「1」(異なる)に設定する。1つは、キャッシュミスの場合(S100:Yes)であり、もう1つは、キャッシュミスではないが、ライトアドレスに対応するキャッシュデータと書込データとが異なる場合(S100:No、S108:No)である。   When executing the memory write command with flag setting, the CPU 140 sets the status of the flag 180 to a status different from the status set by the flag reset command, that is, “1” (different) in two cases. One is a cache miss (S100: Yes), and the other is not a cache miss, but the cache data corresponding to the write address is different from the write data (S100: No, S108: No). ).

図2に示すように、上記2つの場合において、CPU140は、フラグ180を「1」に設定すると共に、キャッシュデータの更新とメインメモリ110への書込みを行う(S102、S104、S106)。キャッシュデータの更新は、具体的には、上記ライトアドレスのデータがキャッシュメモリ120に記憶されていない場合、該ライトアドレスのデータをキャッシュメモリ120に追加し、キャッシュメモリ120に記憶されたライトアドレスのデータと書込データとが異なる場合、キャッシュメモリ120に記憶されたライトアドレスのデータを書込データに置換えることである。   As shown in FIG. 2, in the above two cases, the CPU 140 sets the flag 180 to “1” and updates the cache data and writes to the main memory 110 (S102, S104, S106). Specifically, when the data of the write address is not stored in the cache memory 120, the cache data is updated by adding the data of the write address to the cache memory 120 and changing the write address of the write address stored in the cache memory 120. When the data and the write data are different, the write address data stored in the cache memory 120 is replaced with the write data.

上記2つの場合以外(S100:No、S108:Yes)、CPU140は、通常のメモリライトを実行し、フラグ180の設定をしない。   Except for the above two cases (S100: No, S108: Yes), the CPU 140 executes normal memory write and does not set the flag 180.

フラグ設定付きメモリリード命令は、フラグ180の設定を伴うメモリリード命令である。この命令に対して、CPU140は、通常のメモリリード時の処理以外に、フラグ180の設定を行う場合がある。図3は、CPU140がこの命令を実行するフローチャートの一例である。   The memory read instruction with flag setting is a memory read instruction with the setting of the flag 180. In response to this command, the CPU 140 may set the flag 180 in addition to the normal memory read process. FIG. 3 is an example of a flowchart in which the CPU 140 executes this command.

CPU140は、フラグ設定付きメモリリード命令を実行する際に、2つの場合においてフラグ180のステータスを「1」(異なる)に設定する。1つは、リードアドレスがメモリI/O130を含む非キャッシュ領域を示すアドレスであり、かつメモリI/O130に読み出したデータがリードアドレスに対応するキャッシュデータと異なる場合(S110:Yes、S112、S114:No)である。もう1つは、キャッシュミスの場合(S110:No、S120:Yes)である。   When executing the memory read command with flag setting, the CPU 140 sets the status of the flag 180 to “1” (different) in two cases. One is an address in which the read address indicates a non-cache area including the memory I / O 130, and the data read to the memory I / O 130 is different from the cache data corresponding to the read address (S110: Yes, S112, S114). : No). The other is a case of a cache miss (S110: No, S120: Yes).

図3に示すように、上記2つの場合において、CPU140は、リードアドレスに対応するキャッシュデータを更新すると共に、フラグ180を「1」に設定する(S116、S118)。そして、上記キャッシュデータを、該リード命令により指定されたレジスタに設定する(S122)。   As shown in FIG. 3, in the above two cases, the CPU 140 updates the cache data corresponding to the read address and sets the flag 180 to “1” (S116, S118). Then, the cache data is set in the register designated by the read instruction (S122).

上記2つの場合以外(S110:No、S120:No)、CPU140は、通常のメモリリードを実行し、リードアドレスに対応するキャッシュデータを、該リード命令により指定されたレジスタに設定する(S122)。この場合、CPU140は、フラグ180の設定をしない。   In cases other than the above two cases (S110: No, S120: No), the CPU 140 executes a normal memory read, and sets the cache data corresponding to the read address in the register designated by the read instruction (S122). In this case, the CPU 140 does not set the flag 180.

本発明の説明中でいう「レジスタ設定命令」は、メモリリード以外によりデータを得ると共に該データをレジスタに設定する命令を意味する。例えば、レジスタ変数として割り当てられているレジスタからデータを取得して設定対象のレジスタに設定したり、他のレジスタに格納された値に対して何らかの演算を施して得たデータを設定対象のレジスタに設定したりするなどの命令である。フラグ設定付きレジスタ設定命令は、フラグ180の設定を伴うレジスタ設定命令である。この命令に対して、CPU140は、上述したレジスタ設定命令に対応する処理以外に、フラグ180の設定を行う場合がある。図4は、CPU140がこの命令を実行するフローチャートの一例である。   The “register setting instruction” in the description of the present invention means an instruction for obtaining data by other than memory reading and setting the data in a register. For example, data is obtained from a register assigned as a register variable and set in the register to be set, or data obtained by performing some operation on the value stored in another register is set in the register to be set. It is a command to set. The register setting instruction with flag setting is a register setting instruction with setting of the flag 180. In response to this instruction, the CPU 140 may set the flag 180 in addition to the processing corresponding to the register setting instruction described above. FIG. 4 is an example of a flowchart in which the CPU 140 executes this command.

CPU140は、フラグ設定付きレジスタ設定命令を実行する際に、今回得られたデータと、該命令の前回の実行により設定されたレジスタの値(レジスタ保存値)とを比較し、一致しない場合にのみ、フラグ180を「1」(異なる)に設定すると共に、今回得られたデータで上記レジスタの値を更新する(S130:No、S132、S134)。なお、レジスタ保存値と今回得られたデータとが同じである場合には、CPU140は、フラグ180とレジスタの設定をせずに次の命令に移行する。   When executing the register setting instruction with flag setting, the CPU 140 compares the data obtained this time with the register value (register stored value) set by the previous execution of the instruction, and only when they do not match The flag 180 is set to “1” (different), and the value of the register is updated with the data obtained this time (S130: No, S132, S134). If the register saved value and the data obtained this time are the same, the CPU 140 proceeds to the next instruction without setting the flag 180 and the register.

フラグ参照付き分岐命令は、フラグ180のステータスに応じて、該命令により指定された分岐先への分岐と、次の命令の実行とのいずれかを行う命令である。図5は、CPU140がこの命令を実行するフローチャートである。   The branch instruction with flag reference is an instruction that performs either a branch to a branch destination specified by the instruction or execution of the next instruction according to the status of the flag 180. FIG. 5 is a flowchart in which the CPU 140 executes this command.

CPU140は、この命令を実行する際に、まず、フラグ180を参照する。フラグ180が、2つのステータスのうちの、フラグリセット命令に従って設定されるステータス(本実施の形態では、「0」(同一))である場合(S140:Yes)、CPU140は、指定された分岐先への分岐を行う(S142)。   The CPU 140 first refers to the flag 180 when executing this instruction. When the flag 180 is one of the two statuses set according to the flag reset instruction (“0” (same) in the present embodiment) (S140: Yes), the CPU 140 determines the designated branch destination. Branch to (S142).

一方、ステップS140において、フラグ180が、フラグリセット命令に従って設定されるステータスと異なる場合(S140:No)、CPU140は、指定された分岐先への分岐をせずに次の命令を実行する。   On the other hand, when the flag 180 is different from the status set according to the flag reset instruction in step S140 (S140: No), the CPU 140 executes the next instruction without branching to the designated branch destination.

マイクロプロセッサ100のこのような構成によれば、第1の処理(以下処理Aという)の処理結果を入力値とする第2の処理(以下処理Bという)の実行の前に、処理Bをスキップするか否かの判定を下記のように行うことができる。   According to such a configuration of the microprocessor 100, the process B is skipped before the execution of the second process (hereinafter referred to as process B) using the process result of the first process (hereinafter referred to as process A) as an input value. Whether or not to do so can be determined as follows.

まず、処理Aの実行の前に、フラグリセット命令を実行する。これにより、フラグ180は、「0」(同一)に設定される。   First, a flag reset instruction is executed before execution of process A. Thereby, the flag 180 is set to “0” (same).

そして、処理Aの各命令を実行する。処理Aの各命令のうち、リード命令についてはフラグ設定付きメモリリード命令、ライト命令についてはフラグ設定付きメモリライト命令、レジスタ設定付き命令についてはフラグ設定付きレジスタ設定命令を用いるようにすれば、処理Aの実行が完了した時点で、処理Aの今回の処理結果と前回の処理結果とが同一であるか否かは、フラグ180のステータスにより示される。処理Bは、処理Aの処理結果を入力値とするため、フラグ180のステータスは、処理Bの今回の入力値と前回の入力値とが同一であるか否かを示すことになる。   Then, each instruction of process A is executed. Among the instructions of process A, if a memory read instruction with a flag setting is used for a read instruction, a memory write instruction with a flag setting is used for a write instruction, and a register setting instruction with a flag setting is used for an instruction with a register setting, The status of the flag 180 indicates whether or not the current processing result of the processing A and the previous processing result are the same when the execution of A is completed. Since the process B uses the process result of the process A as an input value, the status of the flag 180 indicates whether or not the current input value and the previous input value of the process B are the same.

例えば、処理Aは、レジスタaの値とレジスタbの値を加算してレジスタcに格納するレジスタ設定命令のフラグ設定付き命令を実行する処理であり、処理Bは、レジスタcの値を入力値とする処理である場合、CPU140は、レジスタaとレジスタbの値を加算して和を得、この和と、レジスタcに格納された、前回の処理Aの処理結果とを比較する。一致すれば、レジスタcとフラグ180の設定をせずに次の命令に移行する一方、一致しない場合には、フラグ180を「1」(異なる)に設定すると共に、レジスタcの値を新しく得た和で更新する。   For example, the process A is a process for executing an instruction with a flag setting of a register setting instruction that adds the value of the register a and the value of the register b and stores the result in the register c, and the process B uses the value of the register c as an input value. CPU 140 adds the values of registers a and b to obtain a sum, and compares this sum with the processing result of the previous process A stored in register c. If they match, the process proceeds to the next instruction without setting the register c and the flag 180. If they do not match, the flag 180 is set to “1” (different) and the value of the register c is newly obtained. Update with the sum.

また例えば、処理Aは、所定のリードアドレスからデータをレジスタaに読み出す処理であり、処理Bは、レジスタaの値を入力値とする処理である場合、CPU140は、メモリリードを行い、キャッシュミスの場合と、リードアドレスがメモリI/O130を含む非キャッシュ領域を示すアドレスであり、かつメモリI/O130に読み出したデータがリードアドレスに対応するキャッシュデータと異なる場合において、リードアドレスに対応するキャッシュデータを更新すると共に、フラグ180を「1」に設定する。そして、キャッシュデータを、レジスタaに設定する。それ以外の場合には、CPU140は、通常のメモリリードを実行し、リードアドレスに対応するキャッシュデータをレジスタaに設定する。   Further, for example, when the process A is a process of reading data from a predetermined read address to the register a, and the process B is a process using the value of the register a as an input value, the CPU 140 performs a memory read and performs a cache miss. And the cache corresponding to the read address when the read address is an address indicating a non-cache area including the memory I / O 130 and the data read to the memory I / O 130 is different from the cache data corresponding to the read address. The data is updated and the flag 180 is set to “1”. Then, the cache data is set in the register a. In other cases, the CPU 140 executes normal memory read and sets the cache data corresponding to the read address in the register a.

処理Bの処理結果は、退避領域112を用いて保存する。退避領域112における処理Bの処理結果の更新は、処理Bが実行された場合にのみ行う。処理Bの前には、フラグ参照付き分岐命令を実行し、フラグ180が「0」であれば処理Bをスキップする。後に処理Bの処理結果を用いる際に、退避領域112から処理Bの処理結果を読み出せばよい。勿論、フラグ参照付き分岐命令の前に退避領域112から処理Bの処理結果を読み出して後の処理に備えるようにしてもよい。   The processing result of processing B is stored using the save area 112. The update of the process result of process B in the save area 112 is performed only when process B is executed. Before the process B, a branch instruction with a flag reference is executed. If the flag 180 is “0”, the process B is skipped. When the process result of process B is used later, the process result of process B may be read from the save area 112. Of course, the processing result of processing B may be read from the save area 112 before the branch instruction with flag reference to prepare for the subsequent processing.

こうすることにより、処理Aの実行が完了した時点で、フラグ180が処理Bをスキップするか否かを示すステータスになるため、処理Bの入力値を保存する必要が無く、メモリ消費を抑制することができる。さらに、処理Bの入力値の比較は、処理Aの実行中に行われるため、効率が良い。   By doing this, when execution of the process A is completed, the flag 180 becomes a status indicating whether or not the process B is skipped, so that it is not necessary to save the input value of the process B, and memory consumption is suppressed. be able to. Furthermore, since the comparison of the input value of the process B is performed during the execution of the process A, the efficiency is high.

また、処理Aに含まれるメモリリード/ライト命令についてフラグ設定付きリード/ライト命令を用い、キャッシュヒット/ミスや、読出データまたは書込データとキャッシュデータの比較結果に応じてフラグ180のステータスを設定するので、簡単である。   In addition, the read / write instruction with flag setting is used for the memory read / write instruction included in the process A, and the status of the flag 180 is set according to the cache hit / miss or the comparison result between the read data or the write data and the cache data. It's so easy.

以下、図6に示す具体的な処理例を用いて詳細に説明する。以下の説明及び図示において、「MEM+数字」は、リードアドレスまたはライトアドレスを意味する。なお、説明を簡潔化するために、誤解が生じない前提下で、「MEM+数字」により該アドレスが示す領域を指す場合もある。   Hereinafter, a detailed processing example shown in FIG. 6 will be described in detail. In the following description and illustration, “MEM + number” means a read address or a write address. For the sake of brevity, the area indicated by the address may be indicated by “MEM + number” under the assumption that no misunderstanding occurs.

図6に示す処理例は、「MEM1」に格納されている値を、「MEM2」に格納されている値で除算し、除算結果をレジスタcに格納する処理である。図6に示すように、この処理を、処理Aと処理Bに分けることができる。処理Aは、「MEM1」と「MEM2」に格納されている値をレジスタbとレジスタcにそれぞれ読み出す処理であり、処理Bは、レジスタbの値をレジスタcの値で除算し、除算結果をレジスタaに格納する処理である。   The processing example illustrated in FIG. 6 is processing for dividing the value stored in “MEM1” by the value stored in “MEM2” and storing the division result in the register c. As shown in FIG. 6, this processing can be divided into processing A and processing B. The process A is a process of reading the values stored in “MEM1” and “MEM2” into the register b and the register c, respectively. The process B divides the value of the register b by the value of the register c, and the division result is obtained. This is a process of storing in the register a.

図7は、図6に示す処理を実現するために、マイクロプロセッサ100が実行する命令コードである。図7の各行の命令を説明する。   FIG. 7 shows instruction codes executed by the microprocessor 100 in order to realize the processing shown in FIG. The instructions on each line in FIG. 7 will be described.

1行目は、フラグリセット命令である。この命令の実行により、フラグ180のステータスが「0」(同一)に設定される。   The first line is a flag reset instruction. By executing this instruction, the status of the flag 180 is set to “0” (same).

2行目は、「MEM1」に格納されている値をレジスタbに読み出すための、フラグ設定付きメモリリード命令である。この命令は、図3に示すフローチャートで実行される。   The second line is a memory read instruction with a flag setting for reading the value stored in “MEM1” to the register b. This command is executed in the flowchart shown in FIG.

3行目も、「MEM2」に格納されている値をレジスタcに読み出すための、フラグ設定付きメモリリード命令である。この命令も、図3に示すフローチャートで実行される。   The third line is also a memory read instruction with a flag setting for reading the value stored in “MEM2” to the register c. This command is also executed in the flowchart shown in FIG.

ここで、処理Aが完了する。処理Aの実行中に、「MEM1」と「MEM2」のリード時にキャッシュミスが生じた場合や、読み出したデータがキャッシュデータと異なる場合には、フラグ180は「異なる」に変更される。   Here, the process A is completed. If a cache miss occurs when “MEM1” and “MEM2” are read during execution of process A, or if the read data is different from the cache data, the flag 180 is changed to “different”.

処理Aの後、処理Bの前に、4行目と5行目の命令が実行される。4行目は、「MEM5」に格納されている値をレジスタaに読み出すメモリリード命令である。なお、後述の説明から分かるように、[MEM5]は、処理Bの結果を保存する退避領域112のアドレスである。この命令は、処理Bがスキップされた場合に、処理Bの処理結果を用いる後の処理のために備えるものであり、フラグ付きである必要が無い。なお、4行目の命令のタイミングは、処理Aの直後に限らず、5行目のフラグ参照付き分岐命令と、処理Bの各命令とを除いた、処理Bの処理結果を用いる後処理の前の任意のタイミングであってもよい。   After the process A and before the process B, the instructions in the fourth and fifth lines are executed. The fourth line is a memory read instruction for reading the value stored in “MEM5” to the register a. As can be seen from the description below, [MEM5] is the address of the save area 112 that stores the result of the process B. This instruction is provided for subsequent processing using the processing result of processing B when processing B is skipped, and does not need to be flagged. Note that the timing of the instruction on the fourth line is not limited to immediately after the process A, but the post-process using the process result of the process B, excluding the branch instruction with flag reference on the fifth line and each instruction of the process B. It may be any previous timing.

5行目は、フラグ参照付き分岐命令である。この命令は、図5に示すフローチャートで実行される。具体的には、フラグ180が「0」(同一)である場合には、指定された分岐先(ここでは8行目)への分岐がなされ、次の命令から、分岐先の直前の命令までの各命令(ここでは6行目〜7行目までの命令)の実行がスキップされる。一方、フラグ180が「1」である場合には、分岐が行われず、次の命令が実行される。   The fifth line is a branch instruction with a flag reference. This command is executed in the flowchart shown in FIG. Specifically, when the flag 180 is “0” (same), a branch is made to the designated branch destination (the eighth line in this case), and from the next instruction to the instruction immediately before the branch destination. The execution of each instruction (in this case, instructions in the sixth to seventh lines) is skipped. On the other hand, when the flag 180 is “1”, the branch is not performed and the next instruction is executed.

6行目は、レジスタbの値をレジスタcの値で除算し、除算結果をレジスタaに格納する命令である。この命令により処理Bが実行される。   The sixth line is an instruction that divides the value of the register b by the value of the register c and stores the division result in the register a. Processing B is executed by this instruction.

7行目は、レジスタaの値を「MEM5」にライトする命令である。「MEM5」は、レジスタaの値を保存する退避領域112である。本実施の形態では、「MEM1」と「MEM2」に格納されている値を読み出す前に常にフラグリセット命令が実行されるので、このライト命令は、フラグ設定付きメモリライト命令と通常のライト命令のいずれであってもよい。通常のライト命令の場合、フラグ180の設定が行われない。フラグ設定付きメモリライト命令の場合、図2に示すフローチャートで実行されるため、通常のライト命令時の動作に加え、フラグ180は「異なる」に設定される場合がある。   The seventh line is an instruction to write the value of the register a to “MEM5”. “MEM5” is a save area 112 for storing the value of the register a. In the present embodiment, since the flag reset instruction is always executed before reading the values stored in “MEM1” and “MEM2”, the write instruction includes the memory write instruction with flag setting and the normal write instruction. Either may be sufficient. In the case of a normal write command, the flag 180 is not set. In the case of a memory write instruction with a flag setting, since it is executed according to the flowchart shown in FIG. 2, in addition to the operation at the time of a normal write instruction, the flag 180 may be set to “different”.

図8は、図7に示す命令コードが実行されるフローチャートを示す。まず、フラグ180は、「0」(同一)にリセットされる(S150)。そして、図7の2行目と3行目が示す処理Aが実行される(S152)。なお、処理Aの実行は、フラグ180の操作を含む。   FIG. 8 shows a flowchart in which the instruction code shown in FIG. 7 is executed. First, the flag 180 is reset to “0” (same) (S150). Then, the process A indicated by the second and third lines in FIG. 7 is executed (S152). The execution of the process A includes an operation of the flag 180.

処理Bの実行に先立って、退避領域112すなわち「MEM5」に格納された、処理Bの前回の結果をレジスタaに読み出す処理が行われる(S154)。   Prior to the execution of the process B, a process of reading the previous result of the process B stored in the save area 112, that is, “MEM5”, to the register a is performed (S154).

そして、処理Bの実行の前に、フラグ参照付き分岐命令が実行される。フラグ180が「0」(同一)であれば(S160:Yes)、処理Bはスキップされる。一方、フラグ180が「1」(異なる)であれば(S160:No)、処理Bは実行されると共に、その結果は退避領域112(「MEM5」)に書き込まれる。   Then, a branch instruction with a flag reference is executed before execution of the process B. If the flag 180 is “0” (same) (S160: Yes), the process B is skipped. On the other hand, if the flag 180 is “1” (different) (S160: No), the process B is executed and the result is written in the save area 112 (“MEM5”).

図9と図10は、図7に示す命令コードの実行に伴って、関連する構成要素の状態遷移を示す。図9と図10は、処理Bの実行の直前でフラグ180が「0」のままである場合と、処理Bの前にフラグ180が「1」に設定された場合にそれぞれ対応する。また、図中1列目は命令を示し、2列目は、同じ行の左端の命令の実行に要するステップ数(サイクル数)を示す。3列目からは、同じ行の左端の命令が実行される直前の上記各構成要素のそれぞれの状態である。   FIG. 9 and FIG. 10 show state transitions of related components as the instruction code shown in FIG. 7 is executed. FIGS. 9 and 10 correspond to the case where the flag 180 remains “0” immediately before execution of the process B and the case where the flag 180 is set to “1” before the process B, respectively. In the figure, the first column indicates an instruction, and the second column indicates the number of steps (cycle number) required to execute the leftmost instruction in the same row. From the third column, it is the state of each of the above-described components immediately before the leftmost instruction in the same row is executed.

図9に示すように、1行目の左端で示される1つ目の命令(フラグリセット命令)の実行の直前に、フラグ180のステータスが不定であり、レジスタa、b、cに記憶されたデータも不定である。また、メインメモリ110におけるアドレス「MEM1」、キャッシュメモリ120におけるアドレス「MEM1」のデータは「12」である。メインメモリ110におけるアドレス「MEM2」、キャッシュメモリ120におけるアドレス「MEM2」のデータは「3」である。メインメモリ110におけるアドレス「MEM5」、キャッシュメモリ120におけるアドレス「MEM5」のデータは「4」である。   As shown in FIG. 9, immediately before the execution of the first instruction (flag reset instruction) shown at the left end of the first line, the status of the flag 180 is undefined and stored in the registers a, b, and c. The data is also undefined. The data at the address “MEM1” in the main memory 110 and the address “MEM1” in the cache memory 120 is “12”. The data at the address “MEM2” in the main memory 110 and the address “MEM2” in the cache memory 120 is “3”. The data at the address “MEM5” in the main memory 110 and the address “MEM5” in the cache memory 120 is “4”.

この命令は、1サイクルで実行が完了する。その実行により、2行目に示されるように、フラグ180のステータスは「0」(同一)になる。他の各構成要素の状態は、変らない。   This instruction completes execution in one cycle. As a result, the status of the flag 180 becomes “0” (identical) as shown in the second line. The state of each other component does not change.

この状態で2行目左端の命令(フラグ設定付きメモリリード命令)が実行される。その実行により、3行目に示されるように、レジスタbの値は「12」になる。フラグ180を含む他の各構成要素の状態は、変わらない。なお、この命令も、1サイクルで実行が完了する。   In this state, the instruction at the left end of the second line (memory read instruction with flag setting) is executed. As a result, the value of the register b becomes “12” as shown in the third line. The states of other components including the flag 180 are not changed. Note that execution of this instruction is completed in one cycle.

この状態で3行目左端の命令(フラグ設定付きメモリリード命令)が実行される。その実行により、4行目に示されるように、レジスタcの値は「3」になる。フラグ180を含む他の各構成要素の状態は、変わらない。なお、この命令も、1サイクルで実行が完了する。   In this state, the instruction at the left end of the third line (memory read instruction with flag setting) is executed. As a result, the value of the register c becomes “3” as shown in the fourth line. The states of other components including the flag 180 are not changed. Note that execution of this instruction is completed in one cycle.

この状態で4行目左端の命令(メモリリード命令)が実行される。その実行により、5行目に示されるように、レジスタaの値は「4」になる。フラグ180を含む他の各構成要素の状態は変わらい。なお、この命令も、1サイクルで完了する。   In this state, the instruction at the left end of the fourth line (memory read instruction) is executed. As a result, the value of the register a becomes “4” as shown in the fifth line. The states of the other components including the flag 180 are not changed. This instruction is also completed in one cycle.

この状態で5行目左端の命令(フラグ設定付き分岐命令)が実行される。フラグ180のステータスが「0」であるため、分岐先への分岐がなされる。この命令の実行による構成要素の状態変更が無い。したがって、ここで、処理Bの実行がスキップされたものの、処理Bの今回の実行結果になるはずの「4」は、レジスタaと退避領域112(「MEM5」に格納されている。
なお、この命令も、1サイクルで実行が完了する。
これにより、図7に示す命令コードは、計5サイクルで実行完了される。
In this state, the instruction at the left end of the fifth line (branch instruction with flag setting) is executed. Since the status of the flag 180 is “0”, the branch to the branch destination is made. There is no change in the state of the component by executing this command. Therefore, although the execution of the process B is skipped, “4”, which should be the current execution result of the process B, is stored in the register a and the save area 112 (“MEM5”).
Note that execution of this instruction is completed in one cycle.
Thereby, the execution of the instruction code shown in FIG. 7 is completed in a total of five cycles.

次に、処理Bの前にフラグ180が「異なる」に設定された場合を説明する。
図10に示すように、1行目の左端で示される1つ目の命令(フラグリセット命令)の実行の直前に、フラグ180のステータスが不定であり、レジスタa、b、cに記憶されたデータも不定である。また、メインメモリ110におけるアドレス「MEM1」、キャッシュメモリ120におけるアドレス「MEM1」のデータは「12」である。メインメモリ110におけるアドレス「MEM5」、キャッシュメモリ120におけるアドレス「MEM5」のデータは「4」である。
Next, a case where the flag 180 is set to “different” before the process B will be described.
As shown in FIG. 10, immediately before the execution of the first instruction (flag reset instruction) shown at the left end of the first line, the status of the flag 180 is undefined and stored in the registers a, b, and c. The data is also undefined. The data at the address “MEM1” in the main memory 110 and the address “MEM1” in the cache memory 120 is “12”. The data at the address “MEM5” in the main memory 110 and the address “MEM5” in the cache memory 120 is “4”.

しかし、アドレス「MEM2」のデータについては、図9の場合と異なる。メインメモリ110におけるアドレス「MEM2」のデータは「6」であることに対して、キャッシュメモリ120におけるアドレス「MEM2」のデータは「3」である。   However, the data of the address “MEM2” is different from the case of FIG. The data of the address “MEM2” in the main memory 110 is “6”, whereas the data of the address “MEM2” in the cache memory 120 is “3”.

フラグリセット命令は、1サイクルで実行が完了する。その実行により、2行目に示されるように、フラグ180のステータスは「0」にされる。他の各構成要素の状態は、変らない。   The flag reset instruction is completed in one cycle. As a result, the status of the flag 180 is set to “0” as shown in the second line. The state of each other component does not change.

この状態で2行目左端の命令(フラグ設定付きメモリリード命令)が実行される。その実行により、3行目に示されるように、レジスタbの値は「12」になる。フラグ180を含む他の各構成要素の状態は、変わらない。なお、この命令も、1サイクルで実行が完了する。   In this state, the instruction at the left end of the second line (memory read instruction with flag setting) is executed. As a result, the value of the register b becomes “12” as shown in the third line. The states of other components including the flag 180 are not changed. Note that execution of this instruction is completed in one cycle.

この状態で3行目左端の命令(フラグ設定付きメモリリード命令)が実行される。キャッシュミスが生じたため、該命令の実行により、4行目に示されるように、メインメモリ110からアドレス「MEM2」のデータ「6」はレジスタcに読み出され、キャッシュメモリ120のアドレス「MEM2」のデータは「6」に更新され、フラグ180のステータスは「1」(異なる)に設定される。他の各構成要素の状態は、変わらない。   In this state, the instruction at the left end of the third line (memory read instruction with flag setting) is executed. Since a cache miss has occurred, the execution of the instruction causes the data “6” at the address “MEM2” to be read from the main memory 110 to the register c and the address “MEM2” of the cache memory 120 as shown in the fourth line. Is updated to “6”, and the status of the flag 180 is set to “1” (different). The state of each other component does not change.

この状態で4行目左端の命令(メモリリード命令)が実行される。その実行により、5行目に示されるように、レジスタaの値は「4」になる。フラグ180を含む他の各構成要素の状態は変わらない。   In this state, the instruction at the left end of the fourth line (memory read instruction) is executed. As a result, the value of the register a becomes “4” as shown in the fifth line. The states of other components including the flag 180 are not changed.

この状態で5行目左端の命令(フラグ設定付き分岐命令)が実行される。フラグ180のステータスが「1」(異なる)であるため、分岐先への分岐がなされず、次の行の命令(処理Bの命令)への移行がなされる。なお、各構成要素の状態は、変更が無い。   In this state, the instruction at the left end of the fifth line (branch instruction with flag setting) is executed. Since the status of the flag 180 is “1” (different), the branch to the branch destination is not performed, and the transition to the instruction on the next line (the instruction of the process B) is performed. The state of each component is not changed.

そして、6行目の左端に示す処理Bの命令が実行される。その実行により、7行目に示されるように、レジスタaの値は「2」になる。他の構成要素の状態は、変らない。なお、この命令の実行は、32サイクルを要する。   Then, the process B instruction shown at the left end of the sixth line is executed. As a result, the value of the register a becomes “2” as shown in the seventh line. The state of other components does not change. The execution of this instruction requires 32 cycles.

この状態で、7行目のメモリライト命令が実行される。その実行により、8行目に示されるように、メインメモリ110とキャッシュメモリ120のアドレス「MEM5」のデータは、「2」に更新される。また、このメモリライト命令がフラグ設定付きメモリライト命令であれば、フラグ180を「異なる」に設定することは再度行われる。
これにより、図6に示す命令コードが示す処理は、計38サイクルで完了する。
In this state, the memory write instruction on the seventh line is executed. As a result, the data of the address “MEM5” in the main memory 110 and the cache memory 120 is updated to “2” as shown in the eighth line. If this memory write command is a memory write command with flag setting, the flag 180 is set to “different” again.
Thereby, the process indicated by the instruction code shown in FIG. 6 is completed in a total of 38 cycles.

ここで、図6に示す処理例を他の手法で実現する場合と比較してみる。
まず、処理Bの前回と今回の入力値の比較結果に応じて処理Bをスキップすることをしない場合と比較する。マイクロプロセッサは、キャッシュメモリ120とフラグ180に対応する構成要素を備えないものとする。また、処理Bの結果を退避領域112に退避させることもしない。
Here, the processing example shown in FIG. 6 will be compared with a case where it is realized by another method.
First, the processing B is compared with the case where the processing B is not skipped according to the comparison result of the previous input value and the current input value. It is assumed that the microprocessor does not include components corresponding to the cache memory 120 and the flag 180. Further, the result of process B is not saved in the save area 112.

図11は、この場合の命令コードであり、図12は、図11に示す命令コードの実行に伴う各構成要素の状態遷移を示す図である。   FIG. 11 is an instruction code in this case, and FIG. 12 is a diagram showing state transition of each component accompanying execution of the instruction code shown in FIG.

図11と図12から分かるように、処理Bの前回と今回の入力値の比較結果に応じて処理Bをスキップすることをしないため、処理Bの前回と今回の入力値(すなわち処理Aの前回と今回の処理結果)の関係にかかわらず、図6に示す処理の実現に要するサイクル数は、毎回同じの「34」である。   As can be seen from FIGS. 11 and 12, since the process B is not skipped in accordance with the comparison result between the previous value and the current input value of the process B, the previous value of the process B and the current input value (that is, the previous value of the process A) Regardless of the relationship between the current processing result and the current processing result, the number of cycles required to realize the processing shown in FIG. 6 is the same “34” every time.

本発明の実施の形態のマイクロプロセッサ100では、処理Bの入力値と今回の入力値が同一である場合には5サイクルを要し、異なる場合には38サイクルを要する。例えば、処理Bの前回と今回の入力値が同一である場合と、異なる場合との割合が「5:5」であるときに、マイクロプロセッサ100は上記手法より37%程度の処理時間を節約することができる。勿論、処理Bの実行回数が多いほど、処理Bのサイクル数が多いほど、処理時間を節約することができる。   In the microprocessor 100 according to the embodiment of the present invention, 5 cycles are required when the input value of the process B and the current input value are the same, and 38 cycles are required when they are different. For example, when the ratio between the previous and current input values for process B is the same as the current input value is “5: 5”, the microprocessor 100 saves about 37% of the processing time from the above method. be able to. Of course, the processing time can be saved as the number of executions of the process B is increased and the cycle number of the process B is increased.

次に、処理Bの前回と今回の入力値の比較結果に応じて処理Bをスキップするが、キャッシュメモリを用いない手法の場合と比較する。この場合のマイクロプロセッサは、処理Bの前回と今回の入力値を比較するためのフラグを有するが、マイクロプロセッサ100におけるフラグ180と区別するため、以下「同値フラグ」という。   Next, the process B is skipped according to the comparison result of the previous input value and the current input value of the process B, but the comparison is made with the method using no cache memory. The microprocessor in this case has a flag for comparing the previous input value of process B with the current input value, but in order to distinguish it from the flag 180 in the microprocessor 100, it is hereinafter referred to as “equivalent flag”.

この場合、図6に示す処理を実現するために、図13に示す命令コードが考えられる。なお、「MEM3」と「MEM4」は、メインメモリにおける、処理Bの前回の2つの入力値のそれぞれの退避領域である。   In this case, the instruction code shown in FIG. 13 can be considered to realize the processing shown in FIG. Note that “MEM3” and “MEM4” are save areas for the previous two input values of process B in the main memory.

図13の1行目は、アドレス「MEM1」のデータをレジスタbに読み出す命令である。この命令の実行により、処理Bの今回の1つ目の入力値は、レジスタbに格納される。   The first line in FIG. 13 is an instruction for reading the data of the address “MEM1” to the register b. By executing this instruction, the current first input value of the process B is stored in the register b.

2行目は、アドレス「MEM2」のデータをレジスタcに読み出す命令である。この命令の実行により、処理Bの今回の2つ目の入力値は、レジスタcに格納される。   The second line is an instruction for reading the data of the address “MEM2” to the register c. By executing this instruction, the current second input value of the process B is stored in the register c.

ここで、処理Aが完了するが、処理Bをスキップするか否かのため、続く3行目は、「MEM3」のデータをレジスタdに読み出す命令である。この命令の実行により、処理Bの前回の1つ目の入力値は、レジスタdに格納される。   Here, although the process A is completed, the subsequent third line is an instruction for reading the data of “MEM3” into the register d because of whether or not the process B is skipped. By executing this instruction, the previous first input value of the process B is stored in the register d.

4行目は、レジスタbとdを比較する命令である。この命令の実行により、処理Bの前回の1つ目の入力値と今回の1つ目の入力値とが同一である否かの結果が得られる。この結果は、同値フラグに設定される。   The fourth line is an instruction for comparing the registers b and d. By executing this command, the result of whether or not the previous first input value of process B and the current first input value are the same is obtained. This result is set in the equivalence flag.

5行目は、同値フラグの値を参照し、次の命令の実行、またはLABE1が示す分岐先(10行目)への分岐を行う命令である。具体的には、同値フラグが「同一」を示す場合には次の行の命令を実行し、同値フラグが「異なる」を示す場合には、6行目から9行目までをスキップして10行目のLABE1に分岐する。   The fifth line is an instruction for referring to the value of the equivalence flag and executing the next instruction or branching to the branch destination (line 10) indicated by LAVE1. Specifically, when the equivalence flag indicates “same”, the instruction on the next line is executed, and when the equivalence flag indicates “different”, the sixth to ninth lines are skipped and 10 is skipped. Branch to LAVE1 on the line.

6行目は、アドレス「MEM4」のデータをレジスタdに読み出す命令である。この命令の実行により、処理Bの前回の2つ目の入力値は、レジスタdに格納される。   The sixth line is an instruction for reading the data of the address “MEM4” to the register d. By executing this instruction, the previous second input value of the process B is stored in the register d.

7行目は、アドレス「MEM5」のデータをレジスタaに読み出す命令である。この命令の実行により、処理Bの前回の処理結果は、レジスタaに格納される。   The seventh line is an instruction for reading the data of the address “MEM5” to the register a. By executing this instruction, the previous processing result of the processing B is stored in the register a.

8行目は、レジスタcとdを比較する命令である。この命令の実行により、処理Bの前回の2つ目の入力値と今回の2つ目の入力値とが同一である否かの結果が得られる。この結果は、同値フラグに設定される。   The eighth line is an instruction for comparing the registers c and d. By executing this command, the result of whether or not the previous second input value of process B and the current second input value are the same is obtained. This result is set in the equivalence flag.

9行目は、同値フラグの値を参照し、次の命令の実行、またはLABE2が示す分岐先(15行目)への分岐を行う命令である。具体的には、同値フラグが「異なる」を示す場合には次の行の命令を実行し、同値フラグが「同一」を示す場合には、11行目から14行目までをスキップして15行目のLABE2に分岐する。   The ninth line is an instruction for referring to the value of the equivalence flag and executing the next instruction or branching to the branch destination (line 15) indicated by LAVE2. Specifically, when the equivalence flag indicates “different”, the instruction on the next line is executed, and when the equivalence flag indicates “same”, the 11th to 14th lines are skipped to 15 Branch to LAVE2 on the line.

11行目は、レジスタb、すなわち処理Bの今回の1つ目の入力値をメインメモリのアドレス「MEM3」にライトする命令である。12行目は、レジスタc、すなわち処理Bの今回の2つ目の入力値をメインメモリのアドレス「MEM4」にライトする命令である。13行目は、処理Bを実行する命令である。14行目は、レジスタa、すなわち処理Bの今回の処理結果をメインメモリのアドレス「MEM5」にライトする命令である。これらの処理により、処理Bの今回の2つの入力値と処理結果は、アドレス「MEM3」、「MEM4」、「MEM5」にそれぞれ格納される。   The eleventh line is an instruction to write the first input value of the register b, that is, the current process B to the address “MEM3” of the main memory. The 12th line is an instruction for writing the register c, that is, the current second input value of the process B to the address “MEM4” of the main memory. The 13th line is an instruction for executing the process B. The 14th line is an instruction to write the current processing result of the register a, that is, the processing B to the address “MEM5” of the main memory. With these processes, the current two input values and the process result of process B are stored in addresses “MEM3”, “MEM4”, and “MEM5”, respectively.

図14と図15は、図13に示す命令コードの実行に伴って、関連する構成要素の状態遷移を示す。図14は、処理Bの今回の2つの入力値が前回の2つの入力値とそれぞれ同様である場合に対応し、図15は、処理Bの1つ目の入力値について前回と今回とで同じであるが、2つ目の入力値については前回と今回とで異なる場合に対応する。   FIG. 14 and FIG. 15 show state transitions of related constituent elements as the instruction code shown in FIG. 13 is executed. FIG. 14 corresponds to the case where the current two input values of process B are the same as the previous two input values, respectively, and FIG. 15 is the same as the previous and current input values of process B. However, the second input value corresponds to a case where the previous input value is different from the current input value.

図14から分かるように、処理Bの今回の2つの入力値が前回の2つの入力値と同様である場合に、図13の命令コードが示す処理は、計9サイクルで完了する。また、図15から分かるように、処理Bの1つ目の入力値について前回と今回とで同じであるが、2つ目の入力値については前回と今回とで異なる場合には、図13の命令コードが示す処理は、計44サイクルで完了する。   As can be seen from FIG. 14, when the current two input values of process B are the same as the previous two input values, the process indicated by the instruction code of FIG. 13 is completed in a total of nine cycles. Further, as can be seen from FIG. 15, the first input value of process B is the same between the previous time and this time, but the second input value is different between the previous time and this time, the case of FIG. The process indicated by the instruction code is completed in a total of 44 cycles.

すなわち、この技術は、処理Bの前回と今回の入力値の比較結果に応じて処理Bをスキップすることをしない技術より、処理速度を22%程度速めることができるものの、本発明の実施の形態にかかるマイクロプロセッサ100ほどの効果を得ることができない。   That is, although this technique can increase the processing speed by about 22% compared to the technique that does not skip the process B according to the comparison result between the previous and current input values of the process B, the embodiment of the present invention. Therefore, the effect as much as that of the microprocessor 100 cannot be obtained.

また、この技術は、処理Bの入力値の数が多いほど比較する回数が多く、要するサイクル数も多くなる。さらに、処理Bの前回の入力値をすべて記憶しておく必要があるため、入力値の数が多いほどメモリの消費量が大きい。したがって、処理Bの入力値の数が多いほど、本発明の技術によるメモリ消費量の削減と高速化の効果がより顕著である。   In this technique, the greater the number of input values for process B, the greater the number of comparisons and the greater the number of cycles required. Furthermore, since it is necessary to store all the previous input values of the process B, the larger the number of input values, the larger the memory consumption. Therefore, the larger the number of input values of the process B, the more remarkable the effect of reducing the memory consumption and increasing the speed by the technique of the present invention.

<第2の実施の形態>
図1に示す第1の実施の形態では、処理Bの前回と今回1つ目の入力値が同一であるか否か、処理Bの前回と今回の2つ目の入力値が同一であるか否かについて、1つのフラグ180のみを用い、いずれ一方が「同一」ではない場合に、フラグ180を「異なる」に設定するようにしている。それぞれの入力値について別々のフラグを用いるようにしてもよい。
<Second Embodiment>
In the first embodiment shown in FIG. 1, whether or not the previous input of process B is the same as the first input value of this time, and whether the previous input of process B and the second input value of this time are the same. Whether or not, only one flag 180 is used, and when one of them is not “same”, the flag 180 is set to “different”. A separate flag may be used for each input value.

具体的には、フラグ180の代わりに、レジスタbに対応するフラグ180bと、レジスタcに対応するフラグ180cを設ける。処理Aの実行前にフラグ180bと180cをリセットする。そして、処理Aの実行に伴い、処理Bの前回と今回の1つ目の入力値が同一ではない場合(すなわちジメインメモリ110からレジスタbの今回の1つ目の入力をレジスタbに読み出す際にキャッシュミスが生じた場合と、読み出したデータとキャッシュデータとが異なる場合)にフラグ180bのステータスを「異なる」に設定する。同様に、処理Bの前回と今回の2つ目の入力値が同一ではない場合に、フラグ180cのステータスを「異なる」に設定する。   Specifically, instead of the flag 180, a flag 180b corresponding to the register b and a flag 180c corresponding to the register c are provided. Prior to execution of process A, the flags 180b and 180c are reset. When the process A is executed, the previous input of the process B and the first input value of this time are not the same (that is, when the first input of the register b is read from the main memory 110 to the register b). The status of the flag 180b is set to “different” when a cache miss occurs and when the read data and the cache data are different. Similarly, the status of the flag 180c is set to “different” when the previous input value and the second input value of process B are not the same.

そして、フラグ180bと180cのいずれか一方が「異なる」である場合に処理Bを実行し、処理結果を退避領域に保存する一方、フラグ180bと180cの両方とも「同一」である場合には処理Bをスキップする。
このような構成のマイクロプロセッサも、本発明の上述した効果を得ることができる。
Then, when either one of the flags 180b and 180c is “different”, the processing B is executed and the processing result is stored in the save area, while when both the flags 180b and 180c are “same”, the processing is performed. Skip B.
The microprocessor having such a configuration can also obtain the above-described effects of the present invention.

以上、実施の形態をもとに本発明を説明した。実施の形態は例示であり、本発明の主旨から逸脱しない限り、上述した各実施の形態に対してさまざまな変更、増減、組合せを行ってもよい。これらの変更、増減、組合せが行われた変形例も本発明の範囲にあることは当業者に理解されるところである。   The present invention has been described above based on the embodiment. The embodiment is an exemplification, and various modifications, increases / decreases, and combinations may be made to the above-described embodiments without departing from the gist of the present invention. It will be understood by those skilled in the art that modifications in which these changes, increases / decreases, and combinations are also within the scope of the present invention.

100 マイクロプロセッサ
110 メインメモリ
112 退避領域
120 キャッシュメモリ
130 メモリI/O
140 CPU
150 レジスタ群
180 フラグ
190 バス
a レジスタ
b レジスタ
c レジスタ
100 Microprocessor 110 Main memory 112 Save area 120 Cache memory 130 Memory I / O
140 CPU
150 register group 180 flag 190 bus a register b register c register

Claims (2)

メインメモリと、
キャッシュメモリと、
第1と第2のステータスを有するフラグとを備えたマイクロプロセッサであって、
前記フラグの設定を伴うメモリリード命令であるフラグ設定付きメモリリード命令と、前記フラグの設定を伴い、メモリリード以外によりデータを得ると共に該データをレジスタに設定するレジスタ設定命令であるフラグ設定付きレジスタ設定命令と、前記フラグの設定を伴うメモリライト命令であるフラグ設定付きライト命令と、フラグリセット命令と、フラグ参照分岐命令とに対応し、
前記フラグリセット命令に従って前記フラグを前記第1のステータスに設定し、
前記フラグ設定付きメモリリード命令に従って読出しを行い、読出し時にキャッシュミスが生じた場合と、リードアドレスが非キャッシュ領域のアドレスであり、かつ読み出したデータが前記リードアドレスに対応するキャッシュデータと異なる場合において、前記フラグを前記第2のステータスに設定し、
前記フラグ設定付きメモリライト命令に従って書込みを行い、書込み時にキャッシミスが生じた場合と、ライトアドレスに対応するキャッシュデータと書込データが異なる場合において、前記フラグを前記第2のステータスに設定し、
フラグ設定付きレジスタ設定命令に従って、今回得られたデータと、該命令の前回の実行により設定されたレジスタの値とを比較し、一致しない場合にのみ、前記フラグを前記第2のステータスに設定すると共に、今回得られたデータで前記レジスタの値を更新し、
前記フラグ参照付き分岐命令に従って、前記フラグを参照し、該フラグが前記第1のステータスであるときには、指定された分岐先への分岐をし、該フラグが前記第2のステータスであるときには、次の命令を実行することを特徴とするマイクロプロセッサ。
Main memory,
Cache memory,
A microprocessor comprising a flag having a first and a second status,
A memory read instruction with a flag setting which is a memory read instruction accompanied by the setting of the flag, and a register with a flag setting which is a register setting instruction which obtains data other than the memory read and sets the data in a register together with the setting of the flag. Corresponding to a setting instruction, a write instruction with flag setting that is a memory write instruction with the setting of the flag, a flag reset instruction, and a flag reference branch instruction,
Setting the flag to the first status according to the flag reset instruction;
When reading is performed in accordance with the memory read instruction with the flag set and a cache miss occurs at the time of reading, and when the read address is a non-cache area address and the read data is different from the cache data corresponding to the read address , Set the flag to the second status,
Write according to the memory write instruction with flag setting, and when the cache miss occurs at the time of writing and when the cache data corresponding to the write address and the write data are different, the flag is set to the second status,
According to the register setting instruction with flag setting, the data obtained this time is compared with the register value set by the previous execution of the instruction, and the flag is set to the second status only when they do not match. At the same time, the value of the register is updated with the data obtained this time,
According to the branch instruction with flag reference, the flag is referred to. When the flag is in the first status, a branch is made to the designated branch destination. When the flag is in the second status, A microprocessor that executes the following instructions.
前記メインメモリは、前記フラグ設定付きメモリリード命令と、前記フラグ設定付きメモリライト命令と、前記フラグ設定付きレジスタ設定命令のうちの1つまたは複数の命令の実行を含む第1の処理の処理結果を入力値とする第2の処理の処理結果を保存する退避領域が設けられており、
前記第1の処理の前に前記フラグリセット命令を実行することにより前記フラグを第1のステータスに設定し、
前記第2の処理の前に前記フラグ参照付き分岐命令を実行することにより、前記フラグのステータスが前記第1のステータスである場合に前記第2の処理の実行をスキップし、
前記第2の処理が実行された場合にのみ、前記退避領域に保存された処理結果を今回の処理結果で更新することを特徴とする請求項1に記載のマイクロプロセッサ。
The main memory is a processing result of a first process including execution of one or a plurality of instructions among the memory read instruction with flag setting, the memory write instruction with flag setting, and the register setting instruction with flag setting Is provided with a save area for storing the processing result of the second processing using as an input value,
Setting the flag to a first status by executing the flag reset instruction prior to the first process;
By executing the branch instruction with flag reference before the second process, the execution of the second process is skipped when the status of the flag is the first status,
2. The microprocessor according to claim 1, wherein the processing result stored in the save area is updated with the current processing result only when the second processing is executed.
JP2010000727A 2010-01-05 2010-01-05 Microprocessor Pending JP2011141619A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010000727A JP2011141619A (en) 2010-01-05 2010-01-05 Microprocessor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010000727A JP2011141619A (en) 2010-01-05 2010-01-05 Microprocessor

Publications (1)

Publication Number Publication Date
JP2011141619A true JP2011141619A (en) 2011-07-21

Family

ID=44457438

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010000727A Pending JP2011141619A (en) 2010-01-05 2010-01-05 Microprocessor

Country Status (1)

Country Link
JP (1) JP2011141619A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11126435B2 (en) 2017-05-26 2021-09-21 Renesas Electronics Corporation Branch destination prediction based on accord or discord of previous load data from a data cache line corresponding to a load instruction and present load data

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11126435B2 (en) 2017-05-26 2021-09-21 Renesas Electronics Corporation Branch destination prediction based on accord or discord of previous load data from a data cache line corresponding to a load instruction and present load data

Similar Documents

Publication Publication Date Title
US8555039B2 (en) System and method for using a local condition code register for accelerating conditional instruction execution in a pipeline processor
US20060294344A1 (en) Computer processor pipeline with shadow registers for context switching, and method
JP2006318051A (en) Microprocessor and method of controlling microprocessor
US9043806B2 (en) Information processing device and task switching method
JP2011517493A (en) System and method for selectively committing the results of executed instructions
WO2013136215A4 (en) Comparing sets of character data having termination characters
JP2011118743A (en) Vector computer and instruction control method therefor
JP6234484B2 (en) Computer system, computer program, and computer-implemented method for prefetching data on a chip
CN111208933B (en) Method, device, equipment and storage medium for data access
JP2013211023A (en) Method and system for accelerating procedure return sequences
JP3749233B2 (en) Instruction execution method and apparatus in pipeline
JP2000276381A (en) Method for estimating task execution time
JP2011048681A (en) Processor
JP2008310693A (en) Information processor
US20160004538A1 (en) Multiple issue instruction processing system and method
JP5233078B2 (en) Processor and processing method thereof
JP2011141619A (en) Microprocessor
JP2007200180A (en) Processor system
US20150052305A1 (en) Arithmetic processing device, arithmetic processing method and arithmetic processing system
JP4444305B2 (en) Semiconductor device
JP2010198128A (en) Processor system
CN107003855B (en) Atomic addition instruction with carry
JP7124608B2 (en) Calculator and calculation method
US20140365751A1 (en) Operand generation in at least one processing pipeline
JP6160571B2 (en) Data processing device