JP3547585B2 - Microprocessor having conditional execution instruction - Google Patents

Microprocessor having conditional execution instruction Download PDF

Info

Publication number
JP3547585B2
JP3547585B2 JP12452597A JP12452597A JP3547585B2 JP 3547585 B2 JP3547585 B2 JP 3547585B2 JP 12452597 A JP12452597 A JP 12452597A JP 12452597 A JP12452597 A JP 12452597A JP 3547585 B2 JP3547585 B2 JP 3547585B2
Authority
JP
Japan
Prior art keywords
instruction
register
execution
general
data
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.)
Expired - Fee Related
Application number
JP12452597A
Other languages
Japanese (ja)
Other versions
JPH10320199A (en
Inventor
和雅 鈴木
篤史 毛利
朗 山田
豊彦 吉田
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.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric 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 Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP12452597A priority Critical patent/JP3547585B2/en
Priority to US08/942,295 priority patent/US6016543A/en
Publication of JPH10320199A publication Critical patent/JPH10320199A/en
Application granted granted Critical
Publication of JP3547585B2 publication Critical patent/JP3547585B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Advance Control (AREA)

Description

【0001】
【発明の属する技術分野】
この発明は、命令の一部に含まれる実行条件フィールドを用いて命令の実行を制御する条件実行命令を備えたマイクロプロセッサに関するものである。
【0002】
【従来の技術】
従来より、分岐のペナルティを減少させ、マイクロプロセッサの性能向上のための手法として、条件実行などの手法が検討されている。従来のARMマイクロプロセッサでは、条件実行の判定に用いるためのフラグとして、ネガティブフラグ(N),ゼロフラグ(Z),キャリーフラグ(C),オーバーフローフラグ(V)という特定の命令でのみ設定される専用フラグを用いている。
【0003】
また、マイクロプロセッサの性能向上のための従来の他の手法として、動作周波数の高速化を目的としてパイプラインの段数を多くした場合における演算結果のバイパス処理を用いた手法がある。この手法では、例えば、演算結果を汎用レジスタへ書き込む命令を実行し、次にそのレジスタを参照する命令を実行した場合、後者の命令でレジスタを参照する時点では、前者の命令における演算結果が汎用レジスタへ書き込まれていないため、前者の命令の演算結果を汎用レジスタを経由することなく、専用に設けられたバイパス経路を介して直接参照することで命令を効率良く実行する手法である。
【0004】
【発明が解決しようとする課題】
しかしながら、従来の条件実行命令を有するマイクロプロセッサにおいてバイパス経路を使用する場合、例えば、演算結果を汎用レジスタ内に書き込む条件実行命令を実行し、次にその演算結果が書き込まれた汎用レジスタを参照するのにバイパス経路を用いる命令を実行した場合に、前者の命令の実行条件が満たされず命令が無効となった場合には、後者の命令で間違ったデータをバイパスすることになり、誤動作を引き起こすという課題があった。
【0005】
この発明は上記のような課題を解決するためになされたもので、データを直接転送するバイパス経路を設けた条件実行命令を有するマイクロプロセッサにおいて、条件実行命令の後にバイパス経路を用いる命令が続いた場合でも、パイプラインのペナルティを課することなく効率良く、また誤動作なく命令を実行可能な条件実行命令を有するマイクロプロセッサを得ることを目的とする。
【0006】
【課題を解決するための手段】
請求項1記載の発明に係る条件実行命令を有するマイクロプロセッサは、実行条件フィールドおよび演算フィールドを含む条件実行命令等の各種命令をデコードする命令デコーダと命令デコーダの出力に従って命令を実行する命令実行部と、命令実行部で実行された命令の演算結果を格納すると共に、条件データが設定される汎用フラグを含んでなる制御レジスタと、命令実行部で実行された命令の演算結果を格納する汎用レジスタと、命令実行部に設けられ汎用レジスタに格納した演算結果を用いることなく、直前に実行された命令の演算結果を格納している制御レジスタ内の演算結果をバイパスするためのバイパス経路とを備える。特に、命令デコーダ内の条件実行判定部が、汎用フラグ内に設定された条件データと実行条件フィールド内に設定された条件とが合致しているか否かを判定し、バイパス制御部が条件実行判定部の判定結果に従って、バイパス経路を使用するか、若しくは、汎用レジスタに格納した演算結果を使用するかを制御して、条件実行命令の後にバイパス経路を用いる命令が続いた場合でも、パイプラインのペナルティを課することなく効率良く、また誤動作なく命令を実行するものである。
【0007】
請求項2記載の発明に係る条件実行命令を有するマイクロプロセッサは、バイパス制御部内のバイパス判定部が、命令実行部で実行される命令のパイプラインでデータ干渉が発生しているか否かを判定し、レジスタ出力制御部が、バイパス判定部の判定結果に基づいて、バイパス経路を介した制御レジスタのデータ転送動作を制御し、また、条件実行制御部内の条件実行判定部が、実行しようとする条件実行命令が有効であるか無効であるかを判定し、汎用レジスタ書き込み制御部が条件実行判定部の判定結果に基づいて汎用レジスタへのデータの書き込みを制御する。さらに、制御レジスタが、命令実行部で実行された命令の演算結果を取得して格納するレジスタと、汎用レジスタから演算結果を取得して格納すると共に、汎用レジスタを介して取得した演算結果をバイパス経路以外の経路でデータ転送するためのデータ転送経路に接続するレジスタとを有してなり、バイパス判定部がデータ干渉の発生を判定した場合であっても、レジスタ出力制御部は、条件実行判定部から送信される判定結果に従ってレジスタの動作を停止し、また汎用レジスタに格納していた演算結果のデータを使用するようにバイパス経路以外のデータ転送経路を介した制御レジスタのデータ転送を制御して、条件実行命令の後にバイパス経路を用いる命令が続いた場合でも、パイプラインのペナルティを課することなく効率良く、また誤動作なく命令を実行するものである。
【0008】
請求項3記載の発明に係る条件実行命令を有するマイクロプロセッサは、実行条件フィールドおよび演算フィールドを含む条件実行命令等の各種命令をデコードする命令デコーダと、条件が設定される汎用フラグを含む制御レジスタと、命令デコーダの出力に従って命令を実行する命令実行部と、命令実行部の実行結果を格納する複数の汎用レジスタと、命令実行部に設けられ、汎用レジスタを経由することなく、直前に実行された命令の演算結果を格納している複数のレジスタ内の演算結果をバイパスするための複数のバイパス経路と汎用レジスタを経由するデータ転送のためのデータ経路とを備える。特に、命令デコーダ内の条件実行制御部は、汎用フラグ内に設定された条件と実行条件フィールド内に設定された条件が合致しているか否かを判定し、バイパス制御部は、条件実行判定部の判定に従って、複数のバイパス経路および汎用レジスタを経由するデータ経路のうちいずれかを介したデータ転送を制御するので、条件実行命令の後にバイパス経路を用いる命令が続いた場合でも、パイプラインのペナルティを課することなく効率良く、また誤動作なく命令を実行するものである。
【0009】
請求項4記載の発明に係る条件実行命令を有するマイクロプロセッサは、バイパス制御部内のバイパス判定部が、命令実行部で実行される命令のパイプラインでデータ干渉が発生しているか否かを判定し、レジスタ出力制御部が、バイパス判定部の判定結果に基づいて、バイパス経路を介した制御レジスタのデータ転送動作を制御し、条件実行制御部内の条件実行判定部が、実行しようとする条件実行命令が有効であるか無効であるかを判定し、汎用レジスタ書き込み制御部が、条件実行判定部の判定結果に基づいて汎用レジスタへのデータの書き込みを制御し、バイパス判定部がデータ干渉の発生を判定した場合であっても、レジスタ出力制御部は、条件実行判定部から送信される判定結果に従って、複数のバイパス経路およびデータ経路のいずれかを選択して複数のレジスタあるいは複数の汎用レジスタのいずれかを介したデータ転送を制御するので、条件実行命令の後にバイパス経路を用いる命令が続いた場合でも、パイプラインのペナルティを課することなく効率良く、また誤動作なく命令を実行するものである。
【0010】
【発明の実施の形態】
以下、この発明の実施の一形態を説明する。
実施の形態1.
まず、この発明の条件実行命令を有するマイクロプロセッサの基本構成に関して説明する。
【0011】
マイクロプロセッサのハードウエア構成
図1は、この発明の条件実行命令を有するマイクロプロセッサの全体構成を示すブロック図であり、32ビットの内部データバスを有する32ビットマイクロプロセッサである。図において、1は条件実行命令を有するマイクロプロセッサコア、2は命令RAM6から64ビット幅のIDバスを介して入力した命令コードをデコードする処理を行う命令デコードユニット(命令デコーダ)、3はアドレス計算を行うメモリアクセスユニット(命令実行部)、4は算術論理演算またはシフト演算を行う整数演算ユニット、5は32ビット×64ワードの汎用レジスタ(複数の汎用レジスタ)、7はデータが格納されるデータRAMである。
【0012】
命令デコードユニット2において、8、9はそれぞれ命令コードをデコードするデコーダ、10はプロセッサの状態を示すプロセッサ状態語(Processor Status Word、以下プロセッサ状態語をPSWという)である。命令デコードユニット2は、さらに、制御信号11を作成し、それをメモリアクセスユニット3へ与える。また、命令デコードユニット2は、デコーダ9のデコード結果とPSW10の内容に基づいて制御信号12を作成しそれを整数演算ユニット4へ与える。
【0013】
メモリアクセスユニット3において、13はジャンプや分岐を含まない命令を実行するとPC(プログラムカウンタ)値に8を加えて次に実行する命令に対するPC値を算出するとともに、ジャンプや分岐を含む命令の実行時に分岐変位をPC値に加算したり、演算で指定されたアドレッシングモードに応じた計算を行ってジャンプ先の命令に対するPC値を計算するPC制御部である。14は、PC制御部13が計算したPC値を32ビット幅のIAバスを介して命令RAM6へ送るとともに、命令RAM6から命令コードを出力させるメモリ制御部である。
【0014】
メモリ制御部14は、32ビット幅のOAバスを介してアドレスデータをデータRAM7へ転送し、命令実行に必要なデータを64ビット幅のODバスを介してアクセスする。15は、汎用レジスタ5から32ビット幅のS1バス、S2バス、S6バスを介して転送された最大3ワードのデータを用いて算術論理演算を行い、演算結果を32ビット幅のW1バスを介して汎用レジスタ5に転送するALUである。16は、汎用レジスタ5からS1バス、S2バス、S6バスを介して転送されたデータを用いてシフト演算を行い、演算結果をW1バスを介して汎用レジスタ5へ転送するシフタである。
【0015】
メモリアクセスユニット3に対して、S1バス、S2バス、S5バス、S6バスを介して、32ビット長のデータを一時に4ワード転送することが可能である。従って、例えば、第1のレジスタの内容と第2のレジスタの内容との和でアドレッシングされるメモリの領域に第3のレジスタの内容をストアするとともに、第3のレジスタの内容をストアしたアドレスに所定値を加算して得られる値でアドレッシングされるメモリの領域に、第4のレジスタの内容をストアする2ワードストア命令を実現することができる。
【0016】
また、メモリアクセスユニット3は、W1バスおよびW3EバスおよびW3Oバスを介して、メモリアクセスユニット3内での2ワードの演算結果またはデータRAM7から転送された2ワードのデータを、汎用レジスタ5に転送することができる。
【0017】
整数演算ユニット4において、17は汎用レジスタ5から32ビット幅のS3バス、S4バス、S5バスを介して転送された最大3ワードのデータを用いて乗算を行い、演算結果を32ビット幅のW2バス、W3Eバス、W3Oバスを介して汎用レジスタ5へ転送する乗算器である。18は、乗算の結果を累積加算または累積減算して保持するアキュムレータである。アキュムレータとして、64ビットのものが2本組み込まれている。19は、汎用レジスタ5からS3バス、S4バス、S5バスを介して転送された最大3ワードのデータを用いて算術論理演算を行い、演算結果をW2バス、W3Eバス、W3Oバスを介して汎用レジスタ5へ転送するALUである。20は、汎用レジスタ5からS3バス、S4バス、S5バスを介して転送されたデータを用いてシフト演算を行い、演算結果をW2バス、W3Eバス、W3Oバスを介して汎用レジスタ5へ転送するシフタである。
【0018】
このマイクロプロセッサ1では、汎用レジスタ5から、最大6種類のレジスタ値を読み出すことが可能であり、読み出されたデータは、それぞれ、S1バス、S2バス、S3バス、S4バス、S5バス、S6バスへ出力される。また、汎用レジスタ5内へ、W1バス、W2バス、W3Eバス、W3Oバスを介して最大4種類のレジスタ値を同時に書き込むことが可能である。
【0019】
図2は、図1に示したこの発明における条件実行命令を有するマイクロプロセッサ1で用いられる命令フォーマットを示す説明図である。
命令フォーマットとして、1つの命令コードで2つの演算(operation)を指示する2演算命令のフォーマット101と、1つの令令コードで1つの演算を指示する1演算命令のフォーマット102とがある。
【0020】
2演算命令のフォーマット101には、フィールド103およびフィールド104からなるフォーマットフィールドと、2つの演算フィールド106、107に付属する各実行条件フィールド105とがある。1演算命令のフォーマット102には、フィールド108およびフィールド104からなるフオーマットフィールドと、フィールド108、109、110からなる演算フィールドと、演算フィールドに付属する実行条件フィールド105とがある。
【0021】
図3は、図1に示したこの発明における条件実行命令を有するマイクロプロセッサ1で用いられる命令フォーマットフィールドを示す説明図であり、図において、FMは、フィールド103およびフィールド104からなる2ビットの値である。
【0022】
フォーマットフィールドの値がFM=00の場合、この命令は2演算命令であることを示す。そして、演算フィールド106で指示されたoperation_0の演算と演算フィールド107で指示されたoperation_1の演算とが、デコード直後のクロックサイクルで並列に実行される。operation_0の演算はメモリアクセスユニット3で実行され、operation_1の演算は整数演算ユニット4で実行される。
【0023】
フォーマットフィールドの値がFM=01の場合、この命令は2演算命令であることを示す。そして、operation_0の演算がデコード直後のクロックサイクルに実行され、operation_1の演算がoperation_0の演算に対して1クロックサイクル遅れて実行される。
【0024】
フォーマットフィールドの値がFM=10の場合、この命令は2演算命令であることを示す。そして、operation_1の演算がデコード直後のクロックサイクルに実行され、operation_0の演算がoperation_1の演算に対して1クロックサイクル遅れて実行される。
【0025】
フォーマットフィールドの値がFM=11の場合、この命令は1演算命令であることを示す。そして、フィールド108、109、110からなる演算フィールドで指示された1つの演算がデコード直後のクロックサイクルで実行される。
【0026】
図4は、図1に示したこの発明における条件実行命令を有するマイクロプロセッサで用いられる命令フォーマット内の実行条件フィールド105の詳細な内容を示す説明図である。
実行条件フィールド105は、マイクロプロセッサ1の実行コントロールフラグF0、F1の値に応じて、演算フィールド106、107のoperation_0の演算やoperation_1の演算、および演算フィールド108、109、110の演算が有効であるか無効であるかを定める。実行コントロールフラグF0、F1の内容については後述する。
【0027】
演算が有効であるとは、演算結果がレジスタ、メモリおよびフラグに反映され、その演算による動作の結果が残ることを意味する。演算が無効であるとは、演算結果がレジスタ、メモリおよびフラグに反映されず、あたかも無効演算(NOP)が実行されたかのような動作の結果が残ることを意味する。
【0028】
実行条件フィールド105の値がCC=000ときには、実行コントロールフラグF0、F1の値に関わらず常に演算は有効である。命令に/TXを記述したときには、CC=000であることを意味する。
【0029】
実行条件フィールド105の値がCC=001のときには、実行コントロールフラグF0=真のときにのみ演算は有効である。実行コントロールフラグF1の状態はいずれでもよい。命令に/FXを記述したときには、CC=001であることを意味する。
【0030】
実行条件フィールド105の値がCC=010のときには、実行コントロールフラグF0=偽のときにのみ演算は有効である。実行コントロールフラグF1の状態はいずれでもよい。命令に/FXを記述したときには、CC=010であることを意味する。
【0031】
実行条件フィールド105の値がCC=011のときには、実行コントロールフラグF1=真のときにのみ演算は有効である。実行コントロールフラグF0の状態はいずれでもよい。命令に/XTを記述したときには、CC=011であることを意味する。CC=100のときには、実行コントロールフラグF1=偽のときにのみ演算は有効である。実行コントロールフラグF0の状態はいずれでもよい。命令に/XFを記述したときには、CC=100であることを意味する。
【0032】
実行条件フィールド105の値がCC=101のときには、実行コントロールフラグF0=真かつF1=真のときにのみ演算は有効である。命令に/TTを記述したときには、CC=101であることを意味する。CC=110のときには、実行コントロールフラグF0=真かつF1=偽のときのみ演算は有効である。命令に/TFを記述したときには、CC=110であることを意味する。
【0033】
実行条件フィールド105の値がCC=111のときの動作は未定義であり、ユーザは、CC=111となる命令を用いることはできない。
【0034】
図5は、図1に示したこの発明における条件実行命令を有するマイクロプロセッサで用いられる命令フォーマット内の演算フィールドを示す説明図である。図において、フォーマット111〜117は、それぞれ28ビットで表現される短型の演算フィールド106または演算フィールド107によるものである。フォーマット118、119は、フィールド108、109、110で構成される長型の演算フィールドによるものである。フォーマット111(Short_M)は、演算内容を指定するフィールド120、レジスタ番号を指定する2つのフィールド121、122、レジスタ番号または6ビット長の即値指定するフィールド123、およびフィールド123がレジスタ番号を示すのか即値を示すのかを指定するフィールド124で構成される。
【0035】
図5の説明図に示すように、フィールド124の値Xが「00」、「01」または「11」であるときにはフィールド123がレジスタ番号を示していることを示し、「10」であるときには即値を示していることを示す。このフォーマット111は、レジスタ間接アドレッシングのメモリアクセス演算に用いられる。
【0036】
フォーマット112(Short_A)は、演算内容を指定するフィールド120、レジスタ番号を指定する2つのフィールド121、122、レジスタ番号または6ビット長の即値を指定するフィールド123、およびフィールド123がレジスタ番号を示すのか即値を示すのかを指定するフィールド125で構成される。
【0037】
図5の説明図に示すように、フォーマット112内のフィールド125の値Xが「0」であるときにはフィールド123がレジスタ番号を示していることを示し、「1」であるときには即値を示していることを示す。このフォーマット112は、算術演算、論理演算、シフト演算およびビット演算に用いられる。
【0038】
フォーマット113(Short_B1)は、演算内容を指定するフィールド120およびレジスタ番号を指定するフィールド126で構成される。このフォーマット113は、レジスタ指定によるジャンプ命令および分岐命令に用いられる。
【0039】
フォーマット114(Short_B2)は、演算内容を指定するフィールド120および18ビット長のディスプレイスメントのフィールド127で構成される。このフォーマット114は、ジャンプ命令および分岐命令に用いられる。
【0040】
フォーマット115(Short_B3)は、演算内容を指定するフィールド120、レジスタ番号を指定するフィールド121、レジスタ番号または12ビット長の即値を指定するフィールド128、フィールド128がレジスタ番号を示すのか即値を示すのかを指定するフィールド129、およびゼロ判定に基づいてフィールド121に基づく条件ジャンプまたは条件分岐を行うか否かを指定するフィールド130で構成される。このフォーマット115は、条件ジャンプ命令および条件分岐命令に使用される。
【0041】
フォーマット116(Short_D1)は、演算内容を指定するフィールド120、レジスタ番号を指定するフィールド121、レジスタ番号または12ビット長の即値を指定するフィールド128、フィールド128がレジスタ番号を示すのか即値を示すのかを指定するフィールド129で構成される。このフォーマット116は、条件ジャンプ命令、条件分岐命令およびリピート命令に使用される。
【0042】
フォーマット117(Short_D2)は、演算内容を指定するフィールド120、レジスタ番号または12ビット長の即値を指定するフィールド128、フィールド128がレジスタ番号を示すのか即値を示すのかを指定するフィールド129、遅延命令(ディレイド命令)に関するフィールド131で構成される。このフォーマット117は、ディレイドジャンプ命令、ディレイド分岐命令およびリピート命令に使用される。
【0043】
フォーマット118(Long1)は、演算内容を指定するフィールド120、レジスタ番号を指定する2つのフィールド121、122、32ビット長の即値を指定するフィールド132で構成される。このフォーマット118は、複雑な算術演算、大きな即値を用いる算術演算、大きなディスプレイスメント付きレジスタ間接アドレッシングのメモリアクセス演算、大きな変位の分岐演算および絶対番値へのジャンプ命令などに使用される。
【0044】
フォーマット119(Long2)は、演算内容を指定するフィールド120、レジスタ番号を指定する2つのフィールド121、122、32ビット長の即値を指定するフィールド132、およびゼロ判定に基づいてフィールド132に基づく条件ジャンプまたは条件分岐を行うか否かを指定するフィールド133で構成される。
【0045】
このフォーマット119は、大きな分岐変位を持つ条件ジャンプや条件分岐命令に使用される。
【0046】
図6は、図1に示したこの発明における条件実行命令を有するマイクロプロセッサのレジスタの構成を示す説明図である。
このマイクロプロセッサ1は、64本の32ビット長の汎用レジスタ5、12本の制御レジスタ150、および2本のアキュムレータ18を備えている。R0の汎用レジスタ140の内容は常に0であり、そこへの書き込みは無視される。R62の汎用レジスタは、サブルーチンからの戻り先アドレスが設定されるリンクレジスタである。R63の汎用レジスタは、スタックポインタであり、PSW10のSMフィールドの値に応じてユーザスタックポインタ(SPU)または割り込みスタッタポインタ(SPI)として動作する。制御レジスタ150には、プログラムカウンタ151、PSW10、および各種の専用レジスタが含まれる。
【0047】
図5に示すフォーマット112による演算では、64本の汎用レジスタ5のそれぞれを上位16ビットと下位16ビットとに分けてアクセスできる。また、2本のアキュムレータ18を、上位32ビットと下位32ビットとに分けて別々にアクセスできる。
【0048】
図7は、図1に示したこの発明における条件実行命令を有するマイクロプロセッサのレジスタ内のPSWを示す説明図である。
PSW10の上位16ビットは、スタックポインタを切り替えるためのSMフィールド171、ソフトウェアデバッガトラップ(SDBT)の検出を示すEAフィールド172、SDBTの許可を指定するDBフィールド173、割り込み許可を指定するIEフィールド174、リピート動作の許可を指定するRPフィールド178、モジュロアドレッシングの許可を指定するMDフィールド176がある。
【0049】
下位16ビットは、フラグフィールド180である。フラグフィールド180には8個のフラグがあり、その中のF0フラグ181およびF1フラグ182は演算の有効/無効を指定する。各フラグの値は、比較演算や算術演算の結果に応じて変化する。また、フラグ初期化演算で初期化したり、フラグ値書き込み演算では任意の値をフラグフィールド180に書き込むことによって変化する。フラグフィールド180の内容は、フラグ値読み出し演算によって読み出される。
【0050】
以下、この発明の条件実行命令を有するマイクロプロセッサ1の命令一覧を示す。
【0051】

Figure 0003547585
【0052】
Figure 0003547585
【0053】
Figure 0003547585
【0054】
Figure 0003547585
reserved
【0055】
Figure 0003547585
【0056】
Figure 0003547585
【0057】
Figure 0003547585
【0058】
Figure 0003547585
【0059】
Figure 0003547585
【0060】
Figure 0003547585
【0061】
Figure 0003547585
【0062】
Figure 0003547585
【0063】
図8は、図1に示したこの発明における条件実行命令を有するマイクロプロセッサ1の並列2命令実行時のパイプライン動作を示す説明図である。
この動作は、命令のフォーマットフィールドの値FM=00のときに実行される。パイプライン190、195は、IFステージ191、D/Aステージ192、E/Mステージ193、Wステージ194で構成される。並列2命令実行時には、メモリアクセスユニット3での実行190と整数演算ユニット4での実行195が並列に行われる。
【0064】
図9は、図1に示したこの発明における条件実行命令を有するマイクロプロセッサのパイプライン動作を示す説明図であり、図において、各ステージはクロックに同期しており、クロックのHighの期間とLowの期間により、2つの期間に分割される。
【0065】
IFステージのクロックがHighのときがI1期間、LowのときがI2期間、D/AステージのクロックがHighのときがD1期間、LowのときがD2期間、E/MステージのクロックがHighのときがE1期間、LowのときがE2期間、IFステージのクロックがHighのときがW1期間、LowのときがW2期間である。
【0066】
IFステージでは命令のフェッチを行い、D/AステージではD1期間内に命令のデコード及び汎用レジスタのリードを行い、D2期間内にメモリのアドレス計算を行う。E/MステージとWステージのW1期間では演算の実行及びメモリのアクセスを行い、WステージのW2期間にて汎用レジスタへの書き込みを行う。
【0067】
図10は、マイクロプロセッサ1においてデータ干渉が起こる場合のプログラム例である。データ干渉については後述する。
【0068】
図において、ADD命令は、第2オペランド及び第3オペランドで指定される汎用レジスタの値を加算し、演算結果を第1オペランドで指定される汎用レジスタに書き込む命令である。ADD命令200では、汎用レジスタR2の値及び汎用レジスタR3の値が加算され、その加算結果が、汎用レジスタR4に書き込まれる。
【0069】
ADD命令210では、汎用レジスタR10の値及び汎用レジスタR4の値が加算され、その加算結果が、汎用レジスタR11内に書き込まれる。ADD命令210において、汎用レジスタR4の値は、ADD命令200の加算結果と等しい。
【0070】
ADD命令200において、汎用レジスタR4への加算結果の書き込みは、W2期間内に行われるために、ADD命令210のD2期間では、この汎用レジスタR4への加算結果の書き込みはまだ終っていないため、ADD命令210のD1期間で読み出した汎用レジスタR4の値は、演算に使用することができない。このような状況をデータ干渉と呼ぶ。データ干渉が起こる状況では、ADD命令200の加算結果を、汎用レジスタR4を経由せずに専用のデータ転送経路(バイパス経路)を介してADD命令210のD2期間に渡す制御を行う。
【0071】
図11は、図10のプログラムを実行したときのパイプラインの動作を示した説明図であり、図において、220は命令200に対応したパイプライン、230は命令210に対応したパイプラインである。パイプライン220とパイプライン230で同じ列にあるステージがそれぞれ同時に実行されることを示している。図11内の矢印が示すように、パイプライン220のE2期間からパイプライン230のD2期間に加算結果をバイパス経路を介して渡すことにより、パイプラインを乱さずに命令の実行を行う。
【0072】
図12は、図10に示すプログラムを実行するときのマイクロプロセッサ1の動作を説明するためのブロック図であり、図1に示すマイクロプロセッサ1のブロック図と同一の参照番号を用いている。即ち、ALU15、汎用レジスタ5、メモリアクセスユニット3、MUデコーダ8は、図1に示したものと同一構成要素である。
【0073】
メモリアクセスユニット3において、240はD2バスに出力されたデータをE1期間内に取り込み、取り込んだデータをALU15に出力するE1レジスタ、241は、ALU15からの出力データをE1バスを介してE2期間内に取り込み、取り込んだデータをE2バスに出力するとともに、レジスタ出力制御部252から出力される制御信号に従って取り込んだデータをバイパス経路B0を経由してD2バスへ出力するE2レジスタ、242は汎用レジスタ5の出力をS2バスを介してD2期間内に取り込み、レジスタ出力制御部252の出力に従って取り込んだデータをデータ経路D0を経由してD2バスへ出力するD2レジスタ、243はE2レジスタ241の出力をE2バスを介してW1期間内に取り込み、取り込んだデータをW1バスに出力するW1レジスタである。
【0074】
MUデコーダ8において、250はバイパス制御を行うバイパス制御部、260は条件実行命令における制御を行う条件実行制御部である。
【0075】
バイパス制御部250において、251はデータ干渉が起こっているか否かを判定するバイパス判定部、252はバイパス判定部の判定結果および条件実行判定部261の判定結果に従って、E2レジスタ241およびD2レジスタ242にD2バスへの出力を制御する信号を出力するレジスタ出力制御部である。
【0076】
条件実行制御部260において、261は条件実行命令が有効であるか無効であるかを判定する条件実行判定部、262は条件実行判定部261の判定結果に従って、汎用レジスタ5への書き込みを制御する信号を出力する汎用レジスタ書き込み制御部である。
【0077】
図13は、条件実行判定部261を示すブロック図であり、図において、270は図2における実行条件フィールド105と同じものである。271は図7におけるF0フラグ181およびF1フラグ182と同じものである。272は実行条件フィールド270に設定されている条件をデコードし実行コントロールフラグ271に設定されている条件と合致しているか否かを判断するデコーダである。
【0078】
次に動作について説明する。
先ず、図10に示すプログラムを実施の形態1の条件実行命令を有するマイクロプロセッサ1が実行したときの動作について説明する。
【0079】
図10に示すプログラム内の命令200が実行され得られる加算結果は、ALU15から出力され、E1バスを介して、命令200のE2期間内にE2レジスタ241に格納される。E2レジスタ241からの出力は、E2バスを介して命令200のW1期間内にW1レジスタ243に格納される。
【0080】
命令200の実行の場合には、実行条件フィールド270はCC=000の値を持ち、前に述べたように実行コントロールフラグ271の値によらずいつでも当該命令は有効である。従って、条件実行判定部261は、当該命令が有効であると判定し判定結果を汎用レジスタ書き込み制御部262およびレジスタ出力制御部252に出力する。汎用レジスタ書き込み制御部262は、条件実行判定部261の判定結果に従って書き込むことを許可する制御信号を汎用レジスタへ出力する。
【0081】
W1レジスタ243に格納されたデータは、汎用レジスタ書き込み制御部262の制御信号に従って、W1バスを介して汎用レジスタ内に、命令200のW2期間内に書き込まれる。命令210においてR4のデータは、汎用レジスタ5からS2バスを介して命令210のD2期間内にD2レジスタ242に取り込まれる。
【0082】
バイパス判定部251は、命令210がデータ干渉を起こしていると判定し、判定結果をレジスタ出力制御部252へ出力する。レジスタ出力制御部252は、バイパス判定部251の判定結果に従って、命令200の加算結果を保持しているE2レジスタ241に、D2バスへの出力を許可することを意味する制御信号を出力し、汎用レジスタ5のデータを保持するD2レジスタ242にD2バスへの出力を許可しないことを意味する制御信号を出力する。
【0083】
E2レジスタ241は、レジスタ出力制御部252の制御信号に従って保持したデータのD2バスへの出力を行う。一方、D2レジスタ242は、レジスタ出力制御部252の制御信号に従って保持したデータのD2バスへの出力を行わない。E1レジスタ240は、E2レジスタ241からの出力データをD2バスを介して命令210のE1期間内に取り込み、取り込まれたデータをALU15へ出力する。ALU15は、E1レジスタ240からの出力データをもとに命令210の加算演算を行う。
【0084】
次に、図10に示すプログラム内の命令200が条件実行命令であった場合の実施の形態1の条件実行命令を有するマイクロプロセッサ1の動作について説明する。
【0085】
図14は、図10に示すプログラム内の命令200が、条件実行命令である場合のデータ干渉の発生を示す説明図である。図において、命令280は条件実行命令であり、命令に/TXが記述されているため、前述したように実行コントロールフラグF0が1のとき命令280は有効になり、実行コントロールフラグF0が0のとき命令280は無効となる。実行コントロールフラグF1の値は考慮されない。
【0086】
命令280が有効のときには、命令291の汎用レジスタR4の値は、命令280の加算結果と一致し、命令280が無効のときは、命令291の汎用レジスタR4の値は、命令280を実行する以前の値と一致する。図14に示す命令280の加算結果は、ALU15から出力され、E1バスを介して命令200のE2期間内にE2レジスタ241内に格納される。E2レジスタ241からの出力は、E2バスを介して命令280のW1期間内にW1レジスタ243内に格納される。
【0087】
命令280の場合には、実行条件フィールド270はCC=001の値を持ち、条件実行判定部261は、実行コントロールフラグ271のF0フラグが1のとき命令280は有効であると判定し、F0フラグが0のとき命令280は無効であると判定し、判定結果を汎用レジスタ書き込み制御部262に出力するとともに、レジスタ出力制御部252に出力する。
【0088】
まず、命令280が有効であった場合、マイクロプロセッサ1が図10に示すプログラムを実行したときと同じ動作を行う。
次に、命令280が無効であったときの動作を説明する。
汎用レジスタ書き込み制御部262は、条件実行判定部261の判定結果に従って、書き込むことを許可しないことを指示する制御信号を汎用レジスタ5に対して出力する。W1レジスタ243内に格納されたデータは、汎用レジスタ書き込み制御部262の制御信号に従い、汎用レジスタ5への書き込みは行われない。命令290においてR4のデータは、汎用レジスタ5からS2バスを介して命令290のD2期間内にD2レジスタ242内に取り込まれる。
【0089】
バイパス判定部251は、命令210がデータ干渉を起こしていると判定し、判定結果をレジスタ出力制御部252へ出力する。レジスタ出力制御部252は、条件実行判定部261の判定結果に従って、バイパス判定部251の判定結果によらず、E2レジスタ241に対してバイパス経路B0を経由して行われるD2バスへの出力を許可しないことを意味する制御信号を出力する。さらに、レジスタ出力制御部252は、汎用レジスタ5のデータを保持するD2レジスタ242に、データ経路D0を経由したD2バスへのデータ出力を許可することを指示する制御信号を出力する。E2レジスタ241は、レジスタ出力制御部252から送信される制御信号に従って、保持したデータのバイパス経路B0を経由して行われるD2バスへの出力を実行しない。
【0090】
一方、D2レジスタ242は、レジスタ出力制御部252の制御信号に従って保持したデータのD2バスへの出力を行う。E1レジスタ240は、E2レジスタからの出力データをD2バスを介して命令210のE1期間内に取り込み、取り込まれたデータをALU15へ出力する。ALU15は、E1レジスタからの出力データをもとに命令280の加算演算を行う。
【0091】
以上のように、この実施の形態1によれば、条件実行命令を含む命令のパイプライン間でデータ干渉が発生しているか否かを判定し、バイパス判定部251での判定結果に基づいて行われるレジスタ出力制御部252の出力を、実行条件制御部260内の条件実行判定部261での判定結果に従って制御し、バイパス経路B0やデータ経路D0を介したデータ転送を制御するようにしたので、条件実行命令を実行するパイプラインにおいてデータ干渉が発生した場合でも、命令を効率良く実行し、データ干渉による誤動作を回避できる。
【0092】
実施の形態2.
図15は、この発明の実施の形態2におけるマイクロプロセッサで実行されるプログラム例を示す説明図である。実施の形態1のマイクロプロセッサの構成要素以外のこの実施の形態2のマイクロプロセッサの構成要素は、図17に示す説明図を用いて後述する。なお、図1および図12に示した実施の形態1のマイクロプロセッサの構成要素と同様のものについては、同一符号を用い、またそれらの説明を省略する。
【0093】
図15におけるLD2W命令300は、第2オペランド及び第3オペランドで指定された汎用レジスタに設定されている値の和で示されるメモリアドレスから8byteのデータを読み出し、第1オペランドで指定された汎用レジスタおよび、その汎用レジスタ内のレジスタ番号に1を加えた汎用レジスタ内に読み出したデータを書き込む命令である。また、図15において、第2オペランドのプラス(+)記号は、アドレッシングモードがポストインクリメントであることを示しており、メモリからデータを読み出した後、第2オペランドで指定されている汎用レジスタの値に8が加算される。
【0094】
図15に示すプログラムにおいて、命令300はレジスタR2およびR3の値の和で示されるメモリ内のメモリアドレスから8byteのデータを読み出し、読み出したデータをレジスタR10、R11へ書き込む命令である。また、レジスタR2へは、メモリからデータが読み出された後、8が加算される。
【0095】
命令310は条件実行命令である。命令310において記号/TXは、実行コントロールフラグF0が1のとき命令310は有効になり、実行コントロールフラグF0が0のとき命令310は無効となることを示している。実行コントロールフラグF1の値は考慮されない。命令310が有効のときは、命令300で更新されたレジスタR2の値およびR3の値の和で示されるメモリアドレスからデータが読み出され、読み出されたデータは、レジスタR12、R13内に書き込まれる。
【0096】
また、レジスタR2はメモリからデータが読み出された後、8が加算される。命令310が無効のときには、レジスタR12、R13および、R2の値は変化しない。
【0097】
命令320は、命令310が有効のときには、命令310で更新されたレジスタR2の値およびR3の値の和で示されるメモリ内のメモリアドレスからデータが読み出され、読み出されたデータはレジスタR14、R15へ書き込まれる。命令310が無効のときには、命令300で更新されたレジスタR2の値およびR3の値の加算で示されるメモリアドレスのデータが読み出され、読み出されたデータは、レジスタR14、R15内に書き込まれる。また、レジスタR2へは、メモリからデータが読み出された後、8が加算される。
【0098】
図16は、実施の形態2のマイクロプロセッサ1が、図15に示すプログラムを実行したときのパイプラインの動作を示した説明図であり、図において、命令300に対応したパイプラインが330であり、命令310に対応したパイプラインが340であり、命令320に対応したパイプラインが350である。
【0099】
図16において、パイプライン330、340および350で同じ列にあるステージがそれぞれ同時に実行されることを示している。命令300において、汎用レジスタR2に8が加算された値が書き戻されるのはW2期間であるため、命令310においてレジスタR2の値が読み出されるD1期間ではまだ更新されておらず、データ干渉が起こっている。そのため、矢印331に示すように命令300のD1期間で更新されたR2の値を、命令300のE1期間から命令310のD1期間に渡す。
【0100】
命令310において、命令が有効であるとき、レジスタR2の値に8が加算された値が書き戻されるのは、W2期間であるため、命令320においてレジスタR2の値が汎用レジスタ5から読み出されるD1期間では、レジスタR2の値はまだ更新されておらず、データ干渉が起こっている。そのため、矢印341に示すように、命令320のD1期間で更新されたレジスタR2の値を命令310のE1期間から命令320のD1期間に渡す。
【0101】
命令310が無効であるとき、命令300においてレジスタR2の値に8が加算された値が書き戻されるのはW2期間であるため、命令320においてレジスタR2が汎用レジスタ5から読み出されるD1期間ではまだ更新されておらず、データ干渉が起こっている。そのため、矢印332に示すように、命令300のD1期間で更新されたR2の値を命令300のW1期間から命令320のD1期間に渡す。
【0102】
図17は、図15に示すプログラムを実行するときの実施の形態2のマイクロプロセッサの動作を説明するためのブロック図である。図において、汎用レジスタ5、メモリアクセスユニット3、MUデコーダ8、データRAM7は、図1に示したものと同一の構成要素からなる。また、条件実行制御部260は、図12に示したものと同じ構成要素からなる。
【0103】
図17に示す命令実行ユニットとしてのメモリアクセスユニット3において、360はインクリメンタ370から得られる出力をD2期間内に取り込み、取り込んだデータをE1レジスタ361へ出力するD2レジスタである。361はD2レジスタ360から出力されたデータをE1期間内に取り込み、取り込んだデータをE2レジスタ362に出力するとともに、レジスタ出力制御部382から出力される制御信号に従って、バイパス経路B1を介してS1バスへ出力するE1レジスタである。
【0104】
363は加算器371からの出力データをD2期間内に取り込み、取り込んだデータをM1レジスタ364へ出力するD2レジスタである。364はD2レジスタ363の出力をE1期間内に取り込み、取り込んだデータをOAバスに出力するM1レジスタである。365はE2バスに出力されたデータをW1期間内に取り込み、取り込んだデータをW1バスに出力するとともに、レジスタ出力制御部382から出力される制御信号に従って、バイパス経路S2を介してS1バスへ出力するW1レジスタである。
【0105】
370はS1バスに出力されたデータに8を加算した値を出力するインクリメンタである。371はS1バスおよび、S2バスに出力されたデータを入力し、それらの加算結果をD2レジスタ363に出力する加算器である。MUデコーダ8において、380はバイパス制御を行うバイパス制御部である。
【0106】
バイパス制御部380において、381は命令を実行するパイプライン間でデータ干渉が発生しているか否かを判定し、さらにデータ干渉が発生している場合はどのように起こっているかを判定し、判定結果をレジスタ出力制御部382へ出力するバイパス判定部である。382はバイパス判定部381の判定結果および条件実行判定部261の判定結果に従って、バイパス経路B1を介したE1レジスタ361のデータ転送、バイパス経路B2を介したW1レジスタ365のデータ転送、およびデータ経路D1を介した汎用レジスタ5によるS1バスへのデータ転送を制御する制御信号を、これらのE1レジスタ361、W1レジスタ365および汎用レジスタ5へ出力するレジスタ出力制御部である。
【0107】
次に動作について説明する。
先ず、図15に示すプログラムを実施の形態2のマイクロプロセッサが実行したときの動作について説明する。
命令300において、汎用レジスタ5内のレジスタR2、R3のデータは、それぞれS1バス、S2バスを介して加算器371に出力されるとともに、レジスタR2のデータは、S1バスを介してインクリメンタ370にも出力される。加算器371から出力される加算結果は、D2レジスタ363、M1レジスタ364を経てOAバスへ出力され、データRAM7のメモリアドレスとして出力される。
【0108】
一方、インクリメンタ370では、汎用レジスタ5内のレジスタR2の値に8が加算され、その加算結果がD2レジスタ360を経てE1レジスタ361に出力される。E1レジスタ361に取り込まれたデータは、E2レジスタ362に取り込まれ、E2バスを介してW1レジスタに出力される。W1レジスタに取り込まれたデータは、W1バスを介して汎用レジスタ5内へ出力されレジスタR2の値が更新される。
【0109】
図15に示す命令310では、バイパス判定部381は、命令310のレジスタR2が命令300とデータ干渉を起こしていると判定し、判定結果をレジスタ出力制御部382に出力する。レジスタ出力制御部382では、バイパス判定部381の判定結果に従って、命令300のレジスタR2の加算結果を保持しているE1レジスタにS1バスへの出力を許可することを意味する制御信号を出力し、W1レジスタ365および汎用レジスタ5に対してS1バスへの出力を許可しないことを意味する制御信号を出力する。
【0110】
バイパス経路B1を介してS1バスへ出力されたE1レジスタ361からのデータは、加算器371へ入力されると同時に、インクリメンタ370内へ入力される。加算器371の加算結果は、D2レジスタ363、M1レジスタ364を経てOAバスに出力され、データRAM7に対するメモリアドレスとして出力される。また、インクリメンタ370での加算結果は、D2レジスタ360を経てE1レジスタ361に取り込まれる。E1レジスタ361に取り込まれたデータは、E2レジスタ362内へ取り込まれ、E2バスを介してW1レジスタ365へ出力される。W1レジスタ365に取り込まれたデータは、W1バスを介して汎用レジスタ5へ出力される。
【0111】
実行条件フィールド270はCC=001の値を持ち、条件実行判定部261は、実行コントロールフラグ271のF0フラグが1のとき命令310は有効であると判定し、F0フラグが0のとき命令310は無効であると判定し、判定結果を汎用レジスタ書き込み制御部262へ出力する同時に、レジスタ出力制御部382へ出力する。命令310が有効のときは、汎用レジスタ書き込み制御部262は、書き込みを許可することを指示する制御信号を汎用レジスタ5へ出力し、これにより汎用レジスタ5は、W1バスに出力されたR2の更新結果を書き込む。
【0112】
命令310が無効のときは、汎用レジスタ書き込み制御部262は、書き込みを許可しないことを指示する制御信号を汎用レジスタ5に対して出力し、これにより汎用レジスタ5は、W1バスに出力されたレジスタR2の更新結果の書き込みを実行しない。
【0113】
命令320では、バイパス判定部381は、命令320のレジスタR2が命令300および命令310とデータ干渉を起こしていると判定し、判定結果をレジスタ出力制御部382へ出力する。レジスタ出力制御部382は、条件実行判定部261から出力された命令310に対する判定結果に従って、命令310が有効のときには、命令310のレジスタR2の加算結果を保持しているE1レジスタ361に対し、バイパス経路B1を介したS1バスへのデータ転送を許可することを指示する制御信号を出力し、命令300のレジスタR2の加算結果を保持しているW1レジスタ365および、汎用レジスタ5に対しては、それぞれバイパス経路B2、データ経路D1を介したS1バスへの出力を許可しないことを指示する制御信号を出力する。
【0114】
命令310が無効のときには、レジスタ出力制御部382は、命令310のレジスタR2の加算結果を保持しているE1レジスタ361および汎用レジスタ5に対し、それぞれバイパス経路B1、データ経路D1を介したS1バスへのデータ転送を許可しないことを指示する制御信号を出力し、さらに命令300のレジスタR2への加算結果を保持しているW1レジスタ365に対し、バイパス経路B2を介したS1バスへデータ転送を許可することを指示する制御信号を出力する。
【0115】
インクリメンタ370および加算器371は、命令310が有効のとき、E1レジスタ361から出力されたデータをS1バスを介して入力する。一方、命令310が無効のときには、W1レジスタ365から出力されたデータをS1バスを介して入力する。加算器371の加算結果は、D2レジスタ363、M1レジスタ364を経てOAバスへ出力され、データRAM7のメモリアドレスとしてデータRAM7に出力される。
【0116】
インクリメンタ370の加算結果は、D2レジスタ360を経てE1レジスタ361へ出力される。E1レジスタ361に取り込まれたデータは、E2レジスタ362へ取り込まれ、E2バスを介してW1レジスタに出力される。W1レジスタに取り込まれたデータは、W1バスを介して汎用レジスタ5へ出力される。
【0117】
以上のように、この実施の形態2によれば、命令デコードユニット2内に設けられた条件実行制御部260内の条件実行判定部261が、データ干渉がどのように発生しているかを判定するバイパス制御部380内のバイパス判定部381の出力を制御し、レジスタ出力制御部382から出力される制御信号を制御して、バイパス経路B1、B2やデータ経路D1を選択してデータ転送を実行するように構成したので、条件実行命令を含む複数の命令のパイプラインにおいてデータ干渉が発生した場合でも、命令を効率良く実行でき、データ干渉による誤動作を回避できる。
【0118】
【発明の効果】
以上のように、請求項1記載の発明によれば、命令デコーダ内の条件実行判定部が、汎用フラグ内に設定された条件データと実行条件フィールド内に設定された条件とが合致しているか否かを判定し、バイパス制御部が条件実行判定部の判定結果に従って、バイパス経路を使用するか否かを制御するように構成したので、条件実行命令の後にバイパス経路を用いる命令が続いた場合でも、パイプラインのペナルティを課することなく効率良く、また誤動作なく命令を実行できる効果がある。
【0119】
請求項2記載の発明によれば、バイパス制御部内のバイパス判定部が、命令実行部で実行される命令のパイプラインでデータ干渉が発生しているか否かを判定し、レジスタ出力制御部が、バイパス判定部の判定結果に基づいて、バイパス経路を介した制御レジスタのデータ転送動作を制御し、また、条件実行制御部内の条件実行判定部が、実行しようとする条件実行命令が有効であるか無効であるかを判定し、汎用レジスタ書き込み制御部が条件実行判定部の判定結果に基づいて汎用レジスタへのデータの書き込みを制御し、バイパス判定部がデータ干渉の発生を判定した場合であっても、レジスタ出力制御部は、条件実行判定部から送信される判定結果に従ってレジスタの動作を停止し、また汎用レジスタ内のデータを使用するようにレジスタおよび汎用レジスタを制御するように構成したので、条件実行命令の後にバイパス経路を用いる命令が続いた場合でも、パイプラインのペナルティを課することなく効率良く、また誤動作なく命令を実行できる効果がある。
【0120】
請求項3記載の発明によれば、命令デコーダ内の条件実行制御部が、汎用フラグ内に設定された条件と実行条件フィールド内に設定された条件が合致しているか否かを判定し、バイパス制御部が条件実行判定部の判定に従って、複数のバイパス経路および汎用レジスタを経由するデータ経路のうちいずれかを介したデータ転送を制御するように構成したので、条件実行命令の後にバイパス経路を用いる命令が続いた場合でも、パイプラインのペナルティを課することなく効率良く、また誤動作なく命令を実行できる効果がある。
【0121】
請求項4記載の発明によれば、バイパス制御部内のバイパス判定部が、命令実行部で実行される命令のパイプラインでデータ干渉が発生しているか否かを判定し、レジスタ出力制御部がバイパス判定部の判定結果に基づいて、バイパス経路を介した制御レジスタのデータ転送動作を制御し、条件実行制御部内の条件実行判定部が、実行しようとする条件実行命令が有効であるか無効であるかを判定し、汎用レジスタ書き込み制御部が、条件実行判定部の判定結果に基づいて汎用レジスタへのデータの書き込みを制御し、バイパス判定部がデータ干渉の発生を判定した場合であっても、レジスタ出力制御部が条件実行判定部から送信される判定結果に従って、複数のバイパス経路およびデータ経路のいずれかを選択して複数のレジスタあるいは複数の汎用レジスタのいずれかを介したデータ転送を制御するように構成したので、条件実行命令の後にバイパス経路を用いる命令が続いた場合でも、パイプラインのペナルティを課することなく効率良く、また誤動作なく命令を実行できる効果がある。
【図面の簡単な説明】
【図1】この発明の実施の形態1における条件実行命令を有するマイクロプロセッサの基本構成を示すブロック図である。
【図2】図1に示したこの発明における条件実行命令を有するマイクロプロセッサで用いられる命令フォーマットを示す説明図である。
【図3】図1に示したこの発明における条件実行命令を有するマイクロプロセッサで用いられる命令フォーマットフィールドを示す説明図である。
【図4】図1に示したこの発明における条件実行命令を有するマイクロプロセッサで用いられる命令フォーマット内の実行条件フィールドの詳細な内容を示す説明図である。
【図5】図1に示したこの発明における条件実行命令を有するマイクロプロセッサで用いられる命令フォーマット内の演算フィールドを示す説明図である。
【図6】図1に示したこの発明における条件実行命令を有するマイクロプロセッサのレジスタの構成を示す説明図である。
【図7】図1に示したこの発明における条件実行命令を有するマイクロプロセッサのレジスタ内のPSWを示す説明図である。
【図8】図1に示したこの発明における条件実行命令を有するマイクロプロセッサのパイプライン動作を示す説明図である。
【図9】図1に示したこの発明における条件実行命令を有するマイクロプロセッサのパイプライン動作を示す説明図である。
【図10】この発明の一実施の形態におけるマイクロプロセッサのデータ干渉が起こる場合のプログラム例である。
【図11】図10に示すプログラムを実行したときのパイプラインの動作を示した説明図である。
【図12】図10に示すプログラムを実行するときのマイクロプロセッサの動作を説明するためのブロック図である。
【図13】条件実行判定部を示すブロック図である。
【図14】図10に示すプログラム内の命令が、条件実行命令である場合のデータ干渉の発生を示す説明図である。
【図15】この発明の実施の形態2におけるマイクロプロセッサで実行されるプログラム例を示す説明図である。
【図16】図15に示すプログラムを実行したときのパイプラインの動作を示す図である。
【図17】図15に示すプログラムを実行するときの実施の形態2のマイクロプロセッサの動作を説明するためのブロック図である。
【符号の説明】
2 命令デコードユニット(命令デコーダ)、3 メモリアクセスユニット(命令実行部)、5 汎用レジスタ(複数の汎用レジスタ)、241,242,361,365 複数のレジスタ、250,380 バイパス制御部、251,381 バイパス判定部、252,382 レジスタ出力制御部、260 条件実行制御部、261 条件実行判定部、262 汎用レジスタ書き込み制御部、B0,B1,B2 バイパス経路、D0,D1 データ経路。[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a microprocessor having a conditional execution instruction that controls execution of an instruction using an execution condition field included in a part of the instruction.
[0002]
[Prior art]
Conventionally, techniques such as conditional execution have been studied as techniques for reducing the penalty of branching and improving the performance of a microprocessor. In a conventional ARM microprocessor, as a flag to be used for determination of conditional execution, a dedicated flag set only by specific instructions such as a negative flag (N), a zero flag (Z), a carry flag (C), and an overflow flag (V) Using flags.
[0003]
As another conventional technique for improving the performance of a microprocessor, there is a technique using a bypass process of an operation result when the number of pipeline stages is increased for the purpose of increasing the operating frequency. In this method, for example, when an instruction for writing an operation result to a general-purpose register is executed, and then an instruction for referencing the register is executed, when the register is referred to by the latter instruction, the operation result of the former instruction is general-purpose. Since the instruction is not written in the register, the instruction is efficiently executed by directly referring to the operation result of the former instruction via a dedicated bypass path without passing through a general-purpose register.
[0004]
[Problems to be solved by the invention]
However, when a bypass path is used in a conventional microprocessor having a conditional execution instruction, for example, a conditional execution instruction for writing an operation result in a general-purpose register is executed, and then the general-purpose register in which the operation result is written is referred to. However, if an instruction using a bypass path is executed and the execution condition of the former instruction is not satisfied and the instruction becomes invalid, the latter instruction will bypass wrong data and cause a malfunction. There were challenges.
[0005]
SUMMARY OF THE INVENTION The present invention has been made to solve the above-described problems. In a microprocessor having a conditional execution instruction provided with a bypass path for directly transferring data, an instruction using a bypass path follows the conditional execution instruction. Even in such a case, it is an object of the present invention to obtain a microprocessor having a conditional execution instruction capable of executing an instruction efficiently without imposing a penalty on a pipeline and without malfunction.
[0006]
[Means for Solving the Problems]
A microprocessor having a conditional execution instruction according to the first aspect of the present invention includes an instruction decoder for decoding various instructions such as a conditional execution instruction including an execution condition field and an operation field. , An instruction execution unit that executes an instruction according to an output of the instruction decoder; Stores the operation result of the instruction executed by the instruction execution unit, conditions data Is included. Just Control register and instruction execution unit Of instructions executed in Store the result General Register and an instruction execution unit. , General registers Use the operation result stored in Without storing the operation result of the instruction executed immediately before control A bypass path for bypassing an operation result in the register. In particular, the condition execution determination unit in the instruction decoder determines whether the condition data set in the general-purpose flag and the condition set in the execution condition field match, and the bypass control unit determines whether the condition execution has been performed. Whether to use a bypass route according to the judgment result of the section Or use the operation result stored in the general-purpose register Is controlled, and even if an instruction using the bypass path follows the conditional execution instruction, the instruction is executed efficiently without imposing a penalty on the pipeline and without malfunction.
[0007]
In the microprocessor having the conditional execution instruction according to the second aspect of the present invention, the bypass determination unit in the bypass control unit determines whether data interference occurs in the pipeline of the instruction executed by the instruction execution unit. The register output control unit controls the data transfer operation of the control register via the bypass path based on the determination result of the bypass determination unit, and the condition execution determination unit in the condition execution control unit executes It is determined whether the execution instruction is valid or invalid, and the general-purpose register write control unit controls the writing of data to the general-purpose register based on the determination result of the condition execution determination unit. further, The control register obtains and stores the operation result of the instruction executed by the instruction execution unit, and obtains and stores the operation result from the general-purpose register, and transfers the operation result obtained via the general-purpose register to other than the bypass path. A register connected to a data transfer path for transferring data through the path of Even when the bypass determination unit determines the occurrence of data interference, the register output control unit stops the operation of the register according to the determination result transmitted from the condition execution determination unit, Of the operation result stored in Use data Control via a data transfer path other than the bypass path register Data transfer Is controlled, and even if an instruction using the bypass path follows the conditional execution instruction, the instruction is executed efficiently without imposing a penalty on the pipeline and without malfunction.
[0008]
A microprocessor having a conditional execution instruction according to the third aspect of the present invention is an instruction decoder for decoding various instructions such as a conditional execution instruction including an execution condition field and an operation field, and a control register including a general-purpose flag for setting a condition. An instruction execution unit that executes an instruction according to the output of the instruction decoder; a plurality of general-purpose registers that store the execution results of the instruction execution unit; and an instruction execution unit that is provided immediately before execution without passing through the general-purpose register. A plurality of bypass paths for bypassing the operation results in the plurality of registers storing the operation results of the instruction, and a data path for data transfer via general-purpose registers. In particular, the condition execution control unit in the instruction decoder determines whether the condition set in the general-purpose flag and the condition set in the execution condition field match, and the bypass control unit determines , The data transfer via one of the plurality of bypass paths and the data path passing through the general-purpose register is controlled. Therefore, even if an instruction using the bypass path follows the instruction that executes the condition, the penalty of the pipeline , And execute instructions efficiently and without malfunction.
[0009]
In the microprocessor having the conditional execution instruction according to the fourth aspect of the present invention, the bypass determination unit in the bypass control unit determines whether data interference occurs in the pipeline of the instruction executed by the instruction execution unit. The register output control unit controls the data transfer operation of the control register via the bypass path based on the determination result of the bypass determination unit, and the condition execution determination unit in the condition execution control unit executes a condition execution instruction to be executed. The general-purpose register write control unit controls whether data is written to the general-purpose register based on the determination result of the condition execution determination unit, and the bypass determination unit determines whether data interference occurs. Even in the case where the determination is made, the register output control unit determines the plurality of bypass paths and the data paths according to the determination result transmitted from the condition execution determination unit. Select one to control data transfer through either the plurality of registers or the plurality of general-purpose registers, so penalize the pipeline even if a condition execution instruction is followed by an instruction using a bypass path. The instruction is executed efficiently and without malfunction.
[0010]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, an embodiment of the present invention will be described.
Embodiment 1 FIG.
First, a basic configuration of a microprocessor having a conditional execution instruction according to the present invention will be described.
[0011]
Microprocessor hardware configuration
FIG. 1 is a block diagram showing the overall configuration of a microprocessor having a conditional execution instruction according to the present invention, which is a 32-bit microprocessor having a 32-bit internal data bus. In the figure, 1 is a microprocessor core having a condition execution instruction, 2 is an instruction decode unit (instruction decoder) for decoding an instruction code inputted from the instruction RAM 6 via a 64-bit ID bus, and 3 is an address calculator. Memory access unit (instruction execution unit) that performs an arithmetic operation, 4 is an integer operation unit that performs arithmetic logic operation or shift operation, 5 is a general-purpose register (a plurality of general-purpose registers) of 32 bits × 64 words, 7 is data in which data is stored RAM.
[0012]
In the instruction decoding unit 2, 8 and 9 are decoders for decoding instruction codes, respectively, and 10 is a processor status word (Processor Status Word, hereinafter referred to as PSW) indicating the status of the processor. Instruction decode unit 2 further creates control signal 11 and provides it to memory access unit 3. The instruction decode unit 2 creates a control signal 12 based on the result of decoding by the decoder 9 and the contents of the PSW 10 and supplies the control signal 12 to the integer operation unit 4.
[0013]
In the memory access unit 3, when an instruction not including a jump or a branch is executed, the PC 13 adds 8 to a PC (program counter) value to calculate a PC value for an instruction to be executed next, and executes an instruction including a jump or a branch. A PC control unit that sometimes adds a branch displacement to a PC value or calculates a PC value for an instruction at a jump destination by performing a calculation according to an addressing mode specified by an operation. Reference numeral 14 denotes a memory control unit that sends the PC value calculated by the PC control unit 13 to the instruction RAM 6 via the 32-bit IA bus and outputs an instruction code from the instruction RAM 6.
[0014]
The memory control unit 14 transfers address data to the data RAM 7 via a 32-bit OA bus, and accesses data necessary for executing an instruction via a 64-bit OD bus. Numeral 15 performs an arithmetic and logic operation using data of up to three words transferred from the general-purpose register 5 via the 32-bit wide S1, S2, and S6 buses, and outputs the calculation result via the 32-bit wide W1 bus. ALU that transfers the data to the general-purpose register 5. A shifter 16 performs a shift operation using data transferred from the general-purpose register 5 via the S1, S2, and S6 buses, and transfers the operation result to the general-purpose register 5 via the W1 bus.
[0015]
It is possible to transfer 32-bit data four words at a time to the memory access unit 3 via the S1, S2, S5, and S6 buses. Therefore, for example, the contents of the third register are stored in an area of the memory addressed by the sum of the contents of the first register and the contents of the second register, and the content of the third register is stored in the address where the contents of the third register are stored. A two-word store instruction for storing the contents of the fourth register in a memory area addressed by a value obtained by adding a predetermined value can be realized.
[0016]
The memory access unit 3 transfers the two-word operation result in the memory access unit 3 or the two-word data transferred from the data RAM 7 to the general-purpose register 5 via the W1 bus, the W3E bus, and the W3O bus. can do.
[0017]
In the integer operation unit 4, 17 multiplies using data of up to three words transferred from the general-purpose register 5 via the 32-bit width S3 bus, S4 bus, and S5 bus, and converts the operation result into a 32-bit width W2. This is a multiplier that transfers the data to the general-purpose register 5 via the bus, the W3E bus, and the W3O bus. Reference numeral 18 denotes an accumulator that holds the result of the multiplication by accumulative addition or subtraction. Two 64-bit accumulators are incorporated. 19 performs an arithmetic and logic operation using data of up to three words transferred from the general-purpose register 5 via the S3 bus, the S4 bus, and the S5 bus, and performs a general-purpose operation on the W2 bus, the W3E bus, and the W3O bus. ALU to be transferred to the register 5. Reference numeral 20 performs a shift operation using the data transferred from the general-purpose register 5 via the S3, S4, and S5 buses, and transfers the operation result to the general-purpose register 5 via the W2, W3E, and W3O buses. It is a shifter.
[0018]
In the microprocessor 1, up to six types of register values can be read from the general-purpose register 5, and the read data is S1 bus, S2 bus, S3 bus, S4 bus, S5 bus, S6 bus, respectively. Output to the bus. Further, up to four types of register values can be simultaneously written into the general-purpose register 5 via the W1 bus, the W2 bus, the W3E bus, and the W3O bus.
[0019]
FIG. 2 is an explanatory diagram showing an instruction format used in the microprocessor 1 having the conditional execution instruction according to the present invention shown in FIG.
As instruction formats, there are a two-operation instruction format 101 that specifies two operations with one instruction code, and a one-operation instruction format 102 that specifies one operation with one instruction code.
[0020]
The format 101 of the two-operation instruction includes a format field including a field 103 and a field 104, and execution condition fields 105 attached to the two operation fields 106 and 107. The format 102 of one operation instruction includes a format field including a field 108 and a field 104, an operation field including fields 108, 109, and 110, and an execution condition field 105 attached to the operation field.
[0021]
FIG. 3 is an explanatory diagram showing an instruction format field used in the microprocessor 1 having a conditional execution instruction according to the present invention shown in FIG. 1, where FM is a 2-bit value consisting of a field 103 and a field 104. It is.
[0022]
When the value of the format field is FM = 00, this instruction is a two-operation instruction. Then, the operation of operation_0 indicated by the operation field 106 and the operation of operation_1 indicated by the operation field 107 are executed in parallel in the clock cycle immediately after decoding. The operation of operation_0 is executed by the memory access unit 3, and the operation of operation_1 is executed by the integer operation unit 4.
[0023]
When the value of the format field is FM = 01, it indicates that this instruction is a two-operation instruction. Then, the operation of operation_0 is executed in the clock cycle immediately after decoding, and the operation of operation_1 is executed one clock cycle later than the operation of operation_0.
[0024]
When the value of the format field is FM = 10, it indicates that this instruction is a two-operation instruction. Then, the operation of operation_1 is executed in the clock cycle immediately after decoding, and the operation of operation_0 is executed one clock cycle later than the operation_1.
[0025]
If the value of the format field is FM = 11, it indicates that this instruction is a one-operation instruction. Then, one operation specified in the operation field including the fields 108, 109, and 110 is executed in the clock cycle immediately after decoding.
[0026]
FIG. 4 is an explanatory diagram showing the detailed contents of the execution condition field 105 in the instruction format used in the microprocessor having the conditional execution instruction according to the present invention shown in FIG.
In the execution condition field 105, the operation of the operation_0 and the operation of the operation_1 in the operation fields 106 and 107 and the operation of the operation fields 108, 109 and 110 are effective according to the values of the execution control flags F0 and F1 of the microprocessor 1. Or invalid. The contents of the execution control flags F0 and F1 will be described later.
[0027]
That the operation is valid means that the operation result is reflected in the register, the memory, and the flag, and the result of the operation by the operation remains. An invalid operation means that the operation result is not reflected in the register, the memory, and the flag, and an operation result as if an invalid operation (NOP) was executed remains.
[0028]
When the value of the execution condition field 105 is CC = 000, the operation is always valid regardless of the values of the execution control flags F0 and F1. When / TX is described in the instruction, it means that CC = 000.
[0029]
When the value of the execution condition field 105 is CC = 001, the operation is valid only when the execution control flag F0 = true. The state of the execution control flag F1 may be any. When / FX is described in the instruction, it means that CC = 001.
[0030]
When the value of the execution condition field 105 is CC = 010, the operation is valid only when the execution control flag F0 = false. The state of the execution control flag F1 may be any. When / FX is described in the instruction, it means that CC = 010.
[0031]
When the value of the execution condition field 105 is CC = 011, the operation is valid only when the execution control flag F1 = true. The state of the execution control flag F0 may be any state. When / XT is described in the instruction, it means that CC = 011. When CC = 100, the operation is valid only when the execution control flag F1 = false. The state of the execution control flag F0 may be any state. When / XF is described in the instruction, it means that CC = 100.
[0032]
When the value of the execution condition field 105 is CC = 101, the operation is valid only when the execution control flag F0 = true and F1 = true. When / TT is described in the instruction, it means that CC = 101. When CC = 110, the operation is valid only when the execution control flag F0 = true and F1 = false. When / TF is described in the instruction, it means that CC = 110.
[0033]
The operation when the value of the execution condition field 105 is CC = 111 is undefined, and the user cannot use an instruction with CC = 111.
[0034]
FIG. 5 is an explanatory diagram showing operation fields in the instruction format used in the microprocessor having the conditional execution instruction according to the present invention shown in FIG. In the figure, formats 111 to 117 are based on a short type operation field 106 or an operation field 107 represented by 28 bits. The formats 118 and 119 are based on long operation fields composed of fields 108, 109 and 110. The format 111 (Short_M) includes a field 120 for specifying the operation content, two fields 121 and 122 for specifying the register number, a field 123 for specifying the register number or immediate value of 6-bit length, and whether the field 123 indicates the register number. Is indicated by a field 124 for designating whether or not the data is displayed.
[0035]
As shown in the explanatory diagram of FIG. 5, when the value X of the field 124 is “00”, “01” or “11”, it indicates that the field 123 indicates a register number, and when the value X is “10”, the immediate value is Is shown. This format 111 is used for a memory access operation of register indirect addressing.
[0036]
The format 112 (Short_A) includes a field 120 for specifying the operation content, two fields 121 and 122 for specifying the register number, a field 123 for specifying the register number or the immediate value of 6-bit length, and whether the field 123 indicates the register number. It comprises a field 125 for specifying whether to indicate an immediate value.
[0037]
As shown in the explanatory diagram of FIG. 5, when the value X of the field 125 in the format 112 is “0”, it indicates that the field 123 indicates a register number, and when it is “1”, it indicates an immediate value. It indicates that. This format 112 is used for arithmetic operations, logical operations, shift operations, and bit operations.
[0038]
The format 113 (Short_B1) includes a field 120 for specifying the operation content and a field 126 for specifying the register number. This format 113 is used for jump instructions and branch instructions by register designation.
[0039]
The format 114 (Short_B2) includes a field 120 for specifying the operation content and a displacement 127 field having a length of 18 bits. This format 114 is used for jump instructions and branch instructions.
[0040]
The format 115 (Short_B3) includes a field 120 for specifying the operation content, a field 121 for specifying the register number, a field 128 for specifying the register number or the immediate value of 12-bit length, and whether the field 128 indicates the register number or the immediate value. It comprises a field 129 to specify and a field 130 to specify whether to perform a conditional jump or a conditional branch based on the field 121 based on the zero judgment. This format 115 is used for conditional jump instructions and conditional branch instructions.
[0041]
The format 116 (Short_D1) includes a field 120 for specifying the operation content, a field 121 for specifying the register number, a field 128 for specifying the register number or the immediate value of 12-bit length, and whether the field 128 indicates the register number or the immediate value. It consists of a field 129 to be specified. This format 116 is used for conditional jump instructions, conditional branch instructions, and repeat instructions.
[0042]
The format 117 (Short_D2) includes a field 120 for specifying an operation content, a field 128 for specifying a register number or a 12-bit immediate value, a field 129 for specifying whether the field 128 indicates a register number or an immediate value, a delay instruction ( Field 131 relating to a delayed instruction). This format 117 is used for a delayed jump instruction, a delayed branch instruction, and a repeat instruction.
[0043]
The format 118 (Long1) is composed of a field 120 for specifying the operation content, two fields 121 and 122 for specifying the register number, and a field 132 for specifying a 32-bit immediate value. The format 118 is used for a complex arithmetic operation, an arithmetic operation using a large immediate value, a memory access operation of large register indirect addressing with displacement, a branch operation with a large displacement, and a jump instruction to an absolute number value.
[0044]
The format 119 (Long2) is a conditional jump based on a field 120 for specifying the operation content, two fields 121 and 122 for specifying the register number, a field 132 for specifying a 32-bit immediate value, and a field 132 based on the zero judgment. Alternatively, it is constituted by a field 133 for designating whether or not to perform a conditional branch.
[0045]
This format 119 is used for a conditional jump or conditional branch instruction having a large branch displacement.
[0046]
FIG. 6 is an explanatory diagram showing a configuration of a register of a microprocessor having a conditional execution instruction according to the present invention shown in FIG.
The microprocessor 1 includes 64 32-bit general-purpose registers 5, 12 control registers 150, and two accumulators 18. The content of the general register 140 of R0 is always 0, and writing to it is ignored. The general-purpose register of R62 is a link register in which a return address from the subroutine is set. The general-purpose register of R63 is a stack pointer, and operates as a user stack pointer (SPU) or an interrupt stutter pointer (SPI) according to the value of the SM field of the PSW 10. The control register 150 includes a program counter 151, a PSW 10, and various dedicated registers.
[0047]
In the calculation using the format 112 shown in FIG. 5, each of the 64 general-purpose registers 5 can be accessed by being divided into upper 16 bits and lower 16 bits. Further, the two accumulators 18 can be separately accessed by dividing them into upper 32 bits and lower 32 bits.
[0048]
FIG. 7 is an explanatory diagram showing the PSW in the register of the microprocessor having the conditional execution instruction according to the present invention shown in FIG.
The upper 16 bits of the PSW 10 include an SM field 171 for switching a stack pointer, an EA field 172 indicating detection of a software debugger trap (SDBT), a DB field 173 specifying permission of SDBT, an IE field 174 specifying permission of interrupt, There is an RP field 178 for designating permission of a repeat operation, and an MD field 176 for designating permission of modulo addressing.
[0049]
The lower 16 bits are a flag field 180. The flag field 180 has eight flags, of which the F0 flag 181 and the F1 flag 182 specify the validity / invalidity of the operation. The value of each flag changes according to the result of the comparison operation or the arithmetic operation. In addition, it is changed by initializing by a flag initialization operation or by writing an arbitrary value to the flag field 180 in a flag value writing operation. The contents of the flag field 180 are read by a flag value read operation.
[0050]
Hereinafter, a list of instructions of the microprocessor 1 having the conditional execution instruction of the present invention is shown.
[0051]
Figure 0003547585
[0052]
Figure 0003547585
[0053]
Figure 0003547585
[0054]
Figure 0003547585
reserved
[0055]
Figure 0003547585
[0056]
Figure 0003547585
[0057]
Figure 0003547585
[0058]
Figure 0003547585
[0059]
Figure 0003547585
[0060]
Figure 0003547585
[0061]
Figure 0003547585
[0062]
Figure 0003547585
[0063]
FIG. 8 is an explanatory diagram showing a pipeline operation when the microprocessor 1 having the conditional execution instruction according to the present invention shown in FIG. 1 executes two parallel instructions.
This operation is executed when the value of the format field of the instruction is FM = 00. Each of the pipelines 190 and 195 includes an IF stage 191, a D / A stage 192, an E / M stage 193, and a W stage 194. When executing two parallel instructions, execution 190 in the memory access unit 3 and execution 195 in the integer operation unit 4 are performed in parallel.
[0064]
FIG. 9 is an explanatory diagram showing the pipeline operation of the microprocessor having the conditional execution instruction according to the present invention shown in FIG. 1. In the figure, each stage is synchronized with the clock, and the high period of the clock and the low period are shown. Is divided into two periods.
[0065]
When the clock of the IF stage is High for the I1 period, when it is Low, the I2 period, when the clock of the D / A stage is High, the D1 period, when it is Low, it is the D2 period, and when the clock of the E / M stage is High. Is the E1 period, when it is low, it is the E2 period, when the clock of the IF stage is high, it is the W1 period, and when it is low, it is the W2 period.
[0066]
At the IF stage, an instruction is fetched. At the D / A stage, the instruction is decoded and the general-purpose register is read within the period D1, and the memory address is calculated within the period D2. In the W1 period of the E / M stage and the W stage, execution of operations and access to the memory are performed, and writing to the general-purpose register is performed in the W2 period of the W stage.
[0067]
FIG. 10 is an example of a program when data interference occurs in the microprocessor 1. Data interference will be described later.
[0068]
In the figure, the ADD instruction is an instruction for adding the values of the general-purpose registers specified by the second operand and the third operand, and writing the operation result to the general-purpose register specified by the first operand. In the ADD instruction 200, the value of the general-purpose register R2 and the value of the general-purpose register R3 are added, and the addition result is written to the general-purpose register R4.
[0069]
In the ADD instruction 210, the value of the general-purpose register R10 and the value of the general-purpose register R4 are added, and the addition result is written into the general-purpose register R11. In the ADD instruction 210, the value of the general-purpose register R4 is equal to the addition result of the ADD instruction 200.
[0070]
In the ADD instruction 200, the writing of the addition result to the general-purpose register R4 is performed within the W2 period. Therefore, during the D2 period of the ADD instruction 210, the writing of the addition result to the general-purpose register R4 is not completed. The value of the general-purpose register R4 read in the period D1 of the ADD instruction 210 cannot be used for the operation. Such a situation is called data interference. In a situation where data interference occurs, control is performed to pass the addition result of the ADD instruction 200 to the D2 period of the ADD instruction 210 via a dedicated data transfer path (bypass path) without passing through the general-purpose register R4.
[0071]
FIG. 11 is an explanatory diagram showing the operation of the pipeline when the program of FIG. 10 is executed. In FIG. 11, reference numeral 220 denotes a pipeline corresponding to the instruction 200, and reference numeral 230 denotes a pipeline corresponding to the instruction 210. This shows that the stages in the same column in the pipeline 220 and the pipeline 230 are respectively executed simultaneously. As indicated by the arrow in FIG. 11, by passing the addition result from the E2 period of the pipeline 220 to the D2 period of the pipeline 230 via the bypass path, the instruction is executed without disturbing the pipeline.
[0072]
FIG. 12 is a block diagram for explaining the operation of the microprocessor 1 when executing the program shown in FIG. 10, and the same reference numerals as those in the block diagram of the microprocessor 1 shown in FIG. 1 are used. That is, the ALU 15, the general-purpose register 5, the memory access unit 3, and the MU decoder 8 are the same components as those shown in FIG.
[0073]
In the memory access unit 3, reference numeral 240 denotes an E1 register for fetching the data output to the D2 bus within the E1 period and outputting the fetched data to the ALU 15; 241 denotes output data from the ALU 15 for the E2 period via the E1 bus. The E2 register 242 outputs the fetched data to the D2 bus via the bypass path B0 while outputting the fetched data to the E2 bus, and outputs the fetched data in accordance with the control signal output from the register output control unit 252. Register 243 via the S2 bus and outputs the fetched data to the D2 bus via the data path D0 according to the output of the register output control unit 252. The D2 register 243 outputs the output of the E2 register 241 to the E2 Takes in the W1 period via the bus and Is W1 register for outputting the first bus.
[0074]
In the MU decoder 8, reference numeral 250 denotes a bypass control unit for performing bypass control, and reference numeral 260 denotes a condition execution control unit for controlling a condition execution instruction.
[0075]
In the bypass control unit 250, reference numeral 251 denotes a bypass determination unit that determines whether or not data interference has occurred. 252 denotes an E2 register 241 and a D2 register 242 according to the determination result of the bypass determination unit and the determination result of the condition execution determination unit 261. A register output control unit that outputs a signal for controlling output to the D2 bus.
[0076]
In the condition execution control unit 260, 261 is a condition execution determination unit that determines whether a condition execution instruction is valid or invalid, and 262 controls writing to the general-purpose register 5 according to the determination result of the condition execution determination unit 261. This is a general-purpose register write control unit that outputs a signal.
[0077]
FIG. 13 is a block diagram showing the condition execution determination unit 261. In the figure, 270 is the same as the execution condition field 105 in FIG. 271 is the same as the F0 flag 181 and the F1 flag 182 in FIG. A decoder 272 decodes the condition set in the execution condition field 270 and determines whether the condition matches the condition set in the execution control flag 271.
[0078]
Next, the operation will be described.
First, the operation when the microprocessor 1 having the conditional execution instruction according to the first embodiment executes the program shown in FIG. 10 will be described.
[0079]
The addition result obtained by executing the instruction 200 in the program shown in FIG. 10 is output from the ALU 15 and stored in the E2 register 241 via the E1 bus within the E2 period of the instruction 200. The output from the E2 register 241 is stored in the W1 register 243 via the E2 bus within the W1 period of the instruction 200.
[0080]
When the instruction 200 is executed, the execution condition field 270 has a value of CC = 000, and the instruction is always valid regardless of the value of the execution control flag 271 as described above. Therefore, the condition execution determination unit 261 determines that the instruction is valid, and outputs the determination result to the general-purpose register write control unit 262 and the register output control unit 252. The general-purpose register write control unit 262 outputs a control signal that permits writing according to the determination result of the condition execution determination unit 261 to the general-purpose register.
[0081]
The data stored in the W1 register 243 is written into the general-purpose register via the W1 bus during the W2 period of the instruction 200 according to the control signal of the general-purpose register write control unit 262. In the instruction 210, the data of R4 is taken into the D2 register 242 from the general-purpose register 5 via the S2 bus within the D2 period of the instruction 210.
[0082]
The bypass determination unit 251 determines that the instruction 210 causes data interference, and outputs a result of the determination to the register output control unit 252. The register output control unit 252 outputs a control signal indicating that output to the D2 bus is permitted to the E2 register 241 holding the addition result of the instruction 200 according to the determination result of the bypass determination unit 251. A control signal indicating that output to the D2 bus is not permitted is output to the D2 register 242 holding the data of the register 5.
[0083]
The E2 register 241 outputs the held data to the D2 bus according to the control signal of the register output control unit 252. On the other hand, the D2 register 242 does not output the held data to the D2 bus according to the control signal of the register output control unit 252. The E1 register 240 captures the output data from the E2 register 241 via the D2 bus within the E1 period of the instruction 210, and outputs the captured data to the ALU 15. The ALU 15 performs an addition operation on the instruction 210 based on the output data from the E1 register 240.
[0084]
Next, the operation of the microprocessor 1 having the conditional execution instruction according to the first embodiment when the instruction 200 in the program shown in FIG. 10 is a conditional execution instruction will be described.
[0085]
FIG. 14 is an explanatory diagram showing the occurrence of data interference when the instruction 200 in the program shown in FIG. 10 is a conditional execution instruction. In the figure, an instruction 280 is a conditional execution instruction and / TX is described in the instruction. Therefore, when the execution control flag F0 is 1, the instruction 280 is valid, and when the execution control flag F0 is 0, as described above. Instruction 280 is invalid. The value of the execution control flag F1 is not considered.
[0086]
When the instruction 280 is valid, the value of the general-purpose register R4 of the instruction 291 matches the addition result of the instruction 280, and when the instruction 280 is invalid, the value of the general-purpose register R4 of the instruction 291 becomes the value before executing the instruction 280. Matches the value of. The addition result of the instruction 280 shown in FIG. 14 is output from the ALU 15 and stored in the E2 register 241 via the E1 bus within the E2 period of the instruction 200. The output from the E2 register 241 is stored in the W1 register 243 via the E2 bus within the W1 period of the instruction 280.
[0087]
In the case of the instruction 280, the execution condition field 270 has a value of CC = 001, and the condition execution determination unit 261 determines that the instruction 280 is valid when the F0 flag of the execution control flag 271 is 1, and the F0 flag Is 0, the instruction 280 is determined to be invalid, and the determination result is output to the general-purpose register write control unit 262 and to the register output control unit 252.
[0088]
First, when the instruction 280 is valid, the same operation as when the microprocessor 1 executes the program shown in FIG. 10 is performed.
Next, the operation when the instruction 280 is invalid will be described.
The general-purpose register write control unit 262 outputs to the general-purpose register 5 a control signal indicating that writing is not permitted according to the determination result of the condition execution determination unit 261. The data stored in the W1 register 243 is not written to the general-purpose register 5 according to the control signal of the general-purpose register write control unit 262. In the instruction 290, the data of R4 is taken into the D2 register 242 from the general-purpose register 5 via the S2 bus within the D2 period of the instruction 290.
[0089]
The bypass determination unit 251 determines that the instruction 210 causes data interference, and outputs a result of the determination to the register output control unit 252. The register output control unit 252 permits the E2 register 241 to output to the D2 bus via the bypass path B0 regardless of the determination result of the bypass determination unit 251 according to the determination result of the condition execution determination unit 261. It outputs a control signal that means not to do so. Further, the register output control unit 252 outputs a control signal for instructing the D2 register 242 holding the data of the general-purpose register 5 to permit data output to the D2 bus via the data path D0. The E2 register 241 does not output the held data to the D2 bus via the bypass path B0 according to the control signal transmitted from the register output control unit 252.
[0090]
On the other hand, the D2 register 242 outputs the held data to the D2 bus according to the control signal of the register output control unit 252. The E1 register 240 captures the output data from the E2 register via the D2 bus within the E1 period of the instruction 210, and outputs the captured data to the ALU 15. The ALU 15 performs the addition operation of the instruction 280 based on the output data from the E1 register.
[0091]
As described above, according to the first embodiment, it is determined whether or not data interference has occurred between the pipelines of the instructions including the conditional execution instructions, and the execution is performed based on the determination result of the bypass determination unit 251. The output of the register output control unit 252 is controlled in accordance with the result of the determination by the condition execution determination unit 261 in the execution condition control unit 260, and the data transfer via the bypass path B0 and the data path D0 is controlled. Even when data interference occurs in a pipeline that executes a conditional execution instruction, the instruction can be executed efficiently and a malfunction due to the data interference can be avoided.
[0092]
Embodiment 2 FIG.
FIG. 15 is an explanatory diagram showing an example of a program executed by the microprocessor according to the second embodiment of the present invention. Components of the microprocessor according to the second embodiment other than the components of the microprocessor according to the first embodiment will be described later with reference to an explanatory diagram shown in FIG. Note that the same components as those of the microprocessor of the first embodiment shown in FIGS. 1 and 12 are denoted by the same reference numerals, and description thereof is omitted.
[0093]
The LD2W instruction 300 in FIG. 15 reads 8-byte data from the memory address indicated by the sum of the values set in the general-purpose registers specified by the second operand and the third operand, and reads the general-purpose register specified by the first operand. And an instruction to write the read data in the general-purpose register obtained by adding 1 to the register number in the general-purpose register. In FIG. 15, the plus (+) sign of the second operand indicates that the addressing mode is post-increment, and after reading data from the memory, the value of the general-purpose register specified by the second operand Is added to.
[0094]
In the program shown in FIG. 15, an instruction 300 is an instruction for reading 8-byte data from a memory address in the memory indicated by the sum of the values of the registers R2 and R3, and writing the read data to the registers R10 and R11. After data is read from the memory, 8 is added to the register R2.
[0095]
Instruction 310 is a conditional execution instruction. The symbol / TX in the instruction 310 indicates that when the execution control flag F0 is 1, the instruction 310 is valid, and when the execution control flag F0 is 0, the instruction 310 is invalid. The value of the execution control flag F1 is not considered. When the instruction 310 is valid, data is read from the memory address indicated by the sum of the value of the register R2 and the value of R3 updated by the instruction 300, and the read data is written into the registers R12 and R13. It is.
[0096]
In addition, 8 is added to the register R2 after the data is read from the memory. When the instruction 310 is invalid, the values of the registers R12, R13, and R2 do not change.
[0097]
When the instruction 310 is valid, the instruction 320 reads data from a memory address in the memory indicated by the sum of the value of the register R2 and the value of the register R3 updated by the instruction 310, and stores the read data in the register R14. , R15. When the instruction 310 is invalid, the data at the memory address indicated by the addition of the value of the register R2 and the value of the register R3 updated by the instruction 300 is read, and the read data is written into the registers R14 and R15. . After data is read from the memory, 8 is added to the register R2.
[0098]
FIG. 16 is an explanatory diagram showing the operation of the pipeline when the microprocessor 1 according to the second embodiment executes the program shown in FIG. 15. In FIG. 16, the pipeline corresponding to the instruction 300 is 330. , The pipeline corresponding to the instruction 310 is 340, and the pipeline corresponding to the instruction 320 is 350.
[0099]
FIG. 16 shows that the stages in the same column in the pipelines 330, 340 and 350 are each executed simultaneously. In the instruction 300, since the value obtained by adding 8 to the general-purpose register R2 is written back during the W2 period, the value has not been updated in the D1 period during which the value of the register R2 is read out in the instruction 310, and data interference may occur. ing. Therefore, the value of R2 updated in the period D1 of the instruction 300 is transferred from the period E1 of the instruction 300 to the period D1 of the instruction 310 as indicated by an arrow 331.
[0100]
In the instruction 310, when the instruction is valid, the value obtained by adding 8 to the value of the register R2 is written back during the W2 period. During the period, the value of the register R2 has not been updated yet, and data interference has occurred. Therefore, as indicated by an arrow 341, the value of the register R2 updated in the period D1 of the instruction 320 is transferred from the period E1 of the instruction 310 to the period D1 of the instruction 320.
[0101]
When the instruction 310 is invalid, the value obtained by adding 8 to the value of the register R2 in the instruction 300 is written back in the W2 period. Therefore, in the instruction 320, the register R2 is still read in the D1 period in which the register R2 is read from the general-purpose register 5. Not updated, causing data interference. Therefore, as indicated by the arrow 332, the value of R2 updated in the period D1 of the instruction 300 is transferred from the period W1 of the instruction 300 to the period D1 of the instruction 320.
[0102]
FIG. 17 is a block diagram for explaining an operation of the microprocessor according to the second embodiment when executing the program shown in FIG. In the figure, a general-purpose register 5, a memory access unit 3, an MU decoder 8, and a data RAM 7 are composed of the same components as those shown in FIG. Further, the condition execution control unit 260 includes the same components as those shown in FIG.
[0103]
In the memory access unit 3 as the instruction execution unit shown in FIG. 17, reference numeral 360 denotes a D2 register which captures the output obtained from the incrementer 370 within the D2 period and outputs the captured data to the E1 register 361. Numeral 361 captures the data output from the D2 register 360 during the E1 period, outputs the captured data to the E2 register 362, and, according to a control signal output from the register output control unit 382, connects the S1 bus via the bypass path B1. Is an E1 register output to
[0104]
A D2 register 363 captures output data from the adder 371 during the D2 period and outputs the captured data to the M1 register 364. An M1 register 364 captures the output of the D2 register 363 during the E1 period and outputs the captured data to the OA bus. 365 fetches the data output to the E2 bus within the W1 period, outputs the fetched data to the W1 bus, and outputs the data to the S1 bus via the bypass path S2 according to the control signal output from the register output control unit 382. W1 register.
[0105]
An incrementer 370 outputs a value obtained by adding 8 to the data output to the S1 bus. Reference numeral 371 denotes an adder that inputs data output to the S1 bus and the S2 bus, and outputs the result of addition to the D2 register 363. In the MU decoder 8, reference numeral 380 denotes a bypass control unit that performs bypass control.
[0106]
In the bypass control unit 380, 381 determines whether or not data interference has occurred between the pipelines executing instructions, and further determines how the data interference has occurred if data interference has occurred. A bypass determination unit that outputs a result to the register output control unit 382. 382 is a data transfer of the E1 register 361 via the bypass path B1, a data transfer of the W1 register 365 via the bypass path B2, and a data path D1 according to the determination result of the bypass determination unit 381 and the determination result of the condition execution determination unit 261. A register output control unit that outputs a control signal for controlling data transfer to the S1 bus by the general-purpose register 5 via the E1 register 361, the W1 register 365, and the general-purpose register 5.
[0107]
Next, the operation will be described.
First, the operation when the microprocessor of the second embodiment executes the program shown in FIG. 15 will be described.
In the instruction 300, the data of the registers R2 and R3 in the general-purpose register 5 are output to the adder 371 via the S1 bus and the S2 bus, respectively, and the data of the register R2 is transmitted to the incrementer 370 via the S1 bus. Is also output. The addition result output from the adder 371 is output to the OA bus via the D2 register 363 and the M1 register 364, and is output as a memory address of the data RAM 7.
[0108]
On the other hand, in the incrementer 370, 8 is added to the value of the register R2 in the general-purpose register 5, and the addition result is output to the E1 register 361 via the D2 register 360. The data captured by the E1 register 361 is captured by the E2 register 362 and output to the W1 register via the E2 bus. The data taken into the W1 register is output to the general-purpose register 5 via the W1 bus, and the value of the register R2 is updated.
[0109]
In the instruction 310 illustrated in FIG. 15, the bypass determination unit 381 determines that the register R2 of the instruction 310 is causing data interference with the instruction 300, and outputs a determination result to the register output control unit 382. The register output control unit 382 outputs a control signal indicating that output to the S1 bus is permitted to the E1 register holding the addition result of the register R2 of the instruction 300 according to the determination result of the bypass determination unit 381. It outputs a control signal to the W1 register 365 and the general-purpose register 5 indicating that output to the S1 bus is not permitted.
[0110]
The data from the E1 register 361 output to the S1 bus via the bypass path B1 is input to the adder 371 and at the same time to the incrementer 370. The addition result of the adder 371 is output to the OA bus via the D2 register 363 and the M1 register 364, and is output as a memory address for the data RAM 7. Further, the addition result at the incrementer 370 is taken into the E1 register 361 via the D2 register 360. The data captured by the E1 register 361 is captured by the E2 register 362 and output to the W1 register 365 via the E2 bus. The data taken into the W1 register 365 is output to the general-purpose register 5 via the W1 bus.
[0111]
The execution condition field 270 has a value of CC = 001, and the condition execution determination unit 261 determines that the instruction 310 is valid when the F0 flag of the execution control flag 271 is 1, and when the F0 flag is 0, the instruction 310 It determines that it is invalid, and outputs the determination result to the general-purpose register write control unit 262 and at the same time, to the register output control unit 382. When the instruction 310 is valid, the general-purpose register write control unit 262 outputs a control signal instructing permission of writing to the general-purpose register 5, so that the general-purpose register 5 updates the R2 output to the W1 bus. Write the result.
[0112]
When the instruction 310 is invalid, the general-purpose register write control unit 262 outputs a control signal indicating that writing is not permitted to the general-purpose register 5, whereby the general-purpose register 5 outputs the register output to the W1 bus. The writing of the update result of R2 is not executed.
[0113]
In the instruction 320, the bypass determination unit 381 determines that the register R2 of the instruction 320 causes data interference with the instruction 300 and the instruction 310, and outputs a determination result to the register output control unit 382. When the instruction 310 is valid, the register output control unit 382 bypasses the E1 register 361 holding the addition result of the register R2 of the instruction 310 according to the determination result for the instruction 310 output from the condition execution determination unit 261. A control signal indicating that data transfer to the S1 bus via the path B1 is permitted is output, and the W1 register 365 holding the addition result of the register R2 of the instruction 300 and the general-purpose register 5 are: Control signals are output to instruct that output to the S1 bus via the bypass path B2 and the data path D1 is not permitted.
[0114]
When the instruction 310 is invalid, the register output control unit 382 sends the E1 register 361 and the general-purpose register 5 holding the addition result of the register R2 of the instruction 310 to the S1 bus via the bypass path B1 and the data path D1, respectively. To the W1 register 365 which holds the result of adding the instruction 300 to the register R2 to the S1 bus via the bypass path B2. A control signal indicating permission is output.
[0115]
When the instruction 310 is valid, the incrementer 370 and the adder 371 input the data output from the E1 register 361 via the S1 bus. On the other hand, when the instruction 310 is invalid, the data output from the W1 register 365 is input via the S1 bus. The addition result of the adder 371 is output to the OA bus via the D2 register 363 and the M1 register 364, and is output to the data RAM 7 as a memory address of the data RAM 7.
[0116]
The addition result of the incrementer 370 is output to the E1 register 361 via the D2 register 360. The data captured by the E1 register 361 is captured by the E2 register 362 and output to the W1 register via the E2 bus. The data taken into the W1 register is output to the general-purpose register 5 via the W1 bus.
[0117]
As described above, according to the second embodiment, condition execution determination unit 261 in condition execution control unit 260 provided in instruction decode unit 2 determines how data interference has occurred. The output of the bypass determination unit 381 in the bypass control unit 380 is controlled, the control signal output from the register output control unit 382 is controlled, and the data transfer is executed by selecting the bypass paths B1 and B2 and the data path D1. With such a configuration, even when data interference occurs in a pipeline of a plurality of instructions including a conditional execution instruction, the instructions can be executed efficiently and a malfunction due to the data interference can be avoided.
[0118]
【The invention's effect】
As described above, according to the first aspect of the present invention, the condition execution determination unit in the instruction decoder determines whether the condition data set in the general-purpose flag matches the condition set in the execution condition field. The bypass control unit is configured to determine whether or not to use the bypass route according to the determination result of the condition execution determination unit. However, there is an effect that instructions can be executed efficiently without imposing a penalty on the pipeline and without malfunction.
[0119]
According to the second aspect of the present invention, the bypass determination unit in the bypass control unit determines whether data interference occurs in the pipeline of the instruction executed by the instruction execution unit, and the register output control unit The data transfer operation of the control register via the bypass path is controlled based on the determination result of the bypass determination unit, and the condition execution instruction to be executed by the condition execution determination unit in the condition execution control unit is valid. In this case, the general-purpose register write control unit controls data writing to the general-purpose register based on the determination result of the condition execution determination unit, and the bypass determination unit determines that data interference has occurred. Also, the register output control unit stops the operation of the register according to the judgment result transmitted from the condition execution judgment unit, and sets the register to use the data in the general-purpose register. And the general-purpose registers are controlled, so that even if a condition execution instruction is followed by an instruction using a bypass path, the effect is that the instruction can be executed efficiently without imposing a penalty on the pipeline and without malfunction. is there.
[0120]
According to the third aspect of the present invention, the condition execution control unit in the instruction decoder determines whether the condition set in the general-purpose flag and the condition set in the execution condition field match, and The control unit is configured to control the data transfer via one of the plurality of bypass paths and the data path passing through the general-purpose register according to the determination of the condition execution determination unit, so that the bypass path is used after the condition execution instruction. Even if the instruction continues, there is an effect that the instruction can be executed efficiently without imposing a penalty on the pipeline and without malfunction.
[0121]
According to the fourth aspect of the present invention, the bypass determination unit in the bypass control unit determines whether data interference has occurred in the pipeline of the instruction executed by the instruction execution unit, and the register output control unit determines The data transfer operation of the control register via the bypass path is controlled based on the determination result of the determination unit, and the condition execution determination unit in the condition execution control unit determines whether the condition execution instruction to be executed is valid or invalid. Whether the general-purpose register write control unit controls the writing of data to the general-purpose register based on the determination result of the condition execution determination unit, even if the bypass determination unit determines the occurrence of data interference, The register output control unit selects one of a plurality of bypass paths and a data path according to the determination result transmitted from the condition execution determination unit, and selects a plurality of registers or Is configured to control data transfer via any of the general-purpose registers, so that even when a condition execution instruction is followed by an instruction using a bypass path, it is efficient without imposing a pipeline penalty, and There is an effect that the instruction can be executed without malfunction.
[Brief description of the drawings]
FIG. 1 is a block diagram showing a basic configuration of a microprocessor having a conditional execution instruction according to Embodiment 1 of the present invention.
FIG. 2 is an explanatory diagram showing an instruction format used in a microprocessor having a conditional execution instruction according to the present invention shown in FIG. 1;
FIG. 3 is an explanatory diagram showing an instruction format field used in a microprocessor having a conditional execution instruction according to the present invention shown in FIG. 1;
FIG. 4 is an explanatory diagram showing detailed contents of an execution condition field in an instruction format used in a microprocessor having a conditional execution instruction in the present invention shown in FIG. 1;
FIG. 5 is an explanatory diagram showing an operation field in an instruction format used in a microprocessor having a conditional execution instruction according to the present invention shown in FIG. 1;
FIG. 6 is an explanatory diagram showing a configuration of a register of a microprocessor having a conditional execution instruction in the present invention shown in FIG. 1;
7 is an explanatory diagram showing a PSW in a register of the microprocessor having the conditional execution instruction according to the present invention shown in FIG. 1;
FIG. 8 is an explanatory diagram showing a pipeline operation of a microprocessor having a conditional execution instruction according to the present invention shown in FIG. 1;
FIG. 9 is an explanatory diagram showing a pipeline operation of a microprocessor having a conditional execution instruction in the present invention shown in FIG. 1;
FIG. 10 is an example of a program when data interference of a microprocessor occurs in one embodiment of the present invention.
FIG. 11 is an explanatory diagram showing an operation of the pipeline when the program shown in FIG. 10 is executed.
FIG. 12 is a block diagram for explaining the operation of the microprocessor when executing the program shown in FIG. 10;
FIG. 13 is a block diagram illustrating a condition execution determination unit.
FIG. 14 is an explanatory diagram showing occurrence of data interference when an instruction in the program shown in FIG. 10 is a condition execution instruction.
FIG. 15 is an explanatory diagram illustrating an example of a program executed by a microprocessor according to Embodiment 2 of the present invention;
FIG. 16 is a diagram showing an operation of the pipeline when the program shown in FIG. 15 is executed.
17 is a block diagram for explaining an operation of the microprocessor according to the second embodiment when executing the program shown in FIG.
[Explanation of symbols]
2 instruction decode unit (instruction decoder), 3 memory access unit (instruction execution unit), 5 general registers (plural general registers), 241, 242, 361, 365 plural registers, 250, 380 bypass control unit, 251, 381 Bypass determination section, 252, 382 register output control section, 260 condition execution control section, 261 condition execution determination section, 262 general-purpose register write control section, B0, B1, B2 bypass path, D0, D1 data path.

Claims (4)

実行条件フィールドおよび演算フィールドを含む条件実行命令等の各種命令をデコードする命令デコーダと、
前記命令デコーダの出力に従って命令を実行する命令実行部と、
前記命令実行部で実行された命令の演算結果を格納すると共に、条件データが設定される汎用フラグを含んでなる制御レジスタと、
前記命令実行部で実行された命令の演算結果を格納する汎用レジスタと、
前記命令実行部に設けられ前記汎用レジスタに格納した前記演算結果を用いることなく、直前に実行された命令の演算結果を格納している前記制御レジスタ内の前記演算結果をバイパスするためのバイパス経路とを備え、
前記命令デコーダは、
前記汎用フラグ内に設定された条件データと前記実行条件フィールド内に設定された条件とが合致しているか否かを判定する条件実行判定部と、
前記条件実行判定部の判定結果に従って、前記バイパス経路を使用するか、若しくは、前記汎用レジスタに格納した前記演算結果を使用するかを制御するバイパス制御部と
を有することを特徴とする条件実行命令を有するマイクロプロセッサ。
An instruction decoder for decoding various instructions such as a conditional execution instruction including an execution condition field and an operation field;
An instruction execution unit that executes an instruction according to an output of the instruction decoder;
Stores the operation result of the instruction executed by the instruction execution unit, and a control register comprising Nde contains generic flag condition data is set,
A general register that stores the operation result of the instruction executed by the instruction execution unit,
Provided in the instruction execution unit, wherein without using the operation result stored in general registers, a bypass for bypassing the calculation result of the control register that stores the operation result of the instruction executed immediately before With a route,
The instruction decoder comprises:
A condition execution determination unit that determines whether the condition data set in the general-purpose flag and the condition set in the execution condition field match each other ,
A bypass control unit for controlling whether to use the bypass path or to use the operation result stored in the general-purpose register according to a determination result of the condition execution determination unit. A microprocessor having:
バイパス制御部は、
命令実行部で実行される命令のパイプラインでデータ干渉が発生しているか否かを判定するバイパス判定部と、
前記バイパス判定部の判定結果に基づいて、バイパス経路を介した制御レジスタのデータ転送動作を制御するレジスタ出力制御部とを有し、
条件実行制御部は、
実行しようとする条件実行命令が有効であるか無効であるかを判定する条件実行判定部と、
前記条件実行判定部の判定結果に基づいて汎用レジスタへのデータの書き込みを制御する汎用レジスタ書き込み制御部とを有し、
前記制御レジスタは、
前記命令実行部で実行された命令の演算結果を取得して格納するレジスタと、前記汎用レジスタから前記演算結果を取得して格納すると共に、前記汎用レジスタを介して取得した前記演算結果を前記バイパス経路以外の経路でデータ転送するためのデータ転送経路に接続するレジスタとを有してなり、
前記レジスタ出力制御部は、
前記バイパス判定部がデータ干渉の発生を判定した場合であっても、前記条件実行判定部から送信される判定結果に従って、前記制御レジスタとバイパス経路を経由するデータ転送を停止し、前記汎用レジスタに格納していた前記演算結果のデータを使用するように前記バイパス経路以外のデータ転送経路を介した前記制御レジスタのデータ転送を制御することを特徴とする請求項1記載の条件実行命令を有するマイクロプロセッサ。
The bypass control unit
A bypass determination unit that determines whether or not data interference has occurred in a pipeline of instructions executed by the instruction execution unit;
A register output control unit that controls a data transfer operation of a control register via a bypass path based on a determination result of the bypass determination unit,
The conditional execution control unit
A condition execution determination unit that determines whether a condition execution instruction to be executed is valid or invalid;
A general-purpose register write control unit that controls writing of data to a general-purpose register based on a determination result of the condition execution determination unit,
The control register includes:
A register for acquiring and storing the operation result of the instruction executed by the instruction execution unit, and obtaining and storing the operation result from the general-purpose register; and bypassing the operation result obtained via the general-purpose register. A register connected to a data transfer path for transferring data through a path other than the path,
The register output control unit includes:
Also the bypass determination unit is a case where it is determined the occurrence of data interference, in accordance with the determination result transmitted from said condition execution determination unit, to stop the data transfer via the control register and the bypass path, the general purpose register 2. The microcontroller having a conditional execution instruction according to claim 1 , wherein data transfer of the control register via a data transfer path other than the bypass path is controlled so as to use the stored data of the operation result. Processor.
実行条件フィールドおよび演算フィールドを含む条件実行命令等の各種命令をデコードする命令デコーダと、
条件が設定される汎用フラグを含む制御レジスタと、
前記命令デコーダの出力に従って命令を実行する命令実行部と、
前記命令実行部の実行結果を格納する複数の汎用レジスタと、
前記命令実行部に設けられ、前記汎用レジスタを経由することなく、直前に実行された命令の演算結果を格納している複数のレジスタ内の前記演算結果をバイパスするための複数のバイパス経路と
前記汎用レジスタを経由するデータ転送のためのデータ経路とを備え、
前記命令デコーダは、
前記汎用フラグ内に設定された条件と前記実行条件フィールド内に設定された条件が合致しているか否かを判定する条件実行制御部と前記条件実行判定部の判定に従って、前記複数のバイパス経路および前記汎用レジスタを経由する前記データ経路のうちいずれかを介したデータ転送を制御するバイパス制御部とを有することを特徴とする条件実行命令を有するマイクロプロセッサ。
An instruction decoder for decoding various instructions such as a conditional execution instruction including an execution condition field and an operation field;
A control register including a general purpose flag for which a condition is set;
An instruction execution unit that executes an instruction according to an output of the instruction decoder;
A plurality of general-purpose registers for storing execution results of the instruction execution unit;
A plurality of bypass paths provided in the instruction execution unit, for bypassing the operation result in a plurality of registers storing the operation result of the instruction executed immediately before, without passing through the general-purpose register ;
A data path for data transfer via the general-purpose register,
The instruction decoder comprises:
Wherein the determining whether or not conditional execution control unit sets conditions to the conditions set in the general purpose flags said execution condition field is matched, according to the determination of the condition execution determination unit, the plurality of bypass paths And a bypass control unit for controlling data transfer via any of the data paths passing through the general-purpose register.
バイパス制御部は、
命令実行部で実行される命令のパイプラインでデータ干渉が発生しているか否かを判定するバイパス判定部と、
前記バイパス判定部の判定結果に基づいて、バイパス経路を介した制御レジスタのデータ転送動作を制御するレジスタ出力制御部とを有し、
条件実行制御部は、
実行しようとする条件実行命令が有効であるか無効であるかを判定する条件実行判定部と、
前記条件実行判定部の判定結果に基づいて汎用レジスタへのデータの書き込みを制御する汎用レジスタ書き込み制御部とを有し、
前記バイパス判定部がデータ干渉の発生を判定した場合であっても、前記レジスタ出力制御部は、前記条件実行判定部から送信される判定結果に従って、前記複数のバイパス経路および前記データ経路のいずれかを選択して前記複数のレジスタあるいは前記複数の汎用レジスタのいずれかを介したデータ転送を制御することを特徴とする請求項3記載の条件実行命令を有するマイクロプロセッサ。
The bypass control unit
A bypass determination unit that determines whether or not data interference has occurred in a pipeline of instructions executed by the instruction execution unit;
A register output control unit that controls a data transfer operation of a control register via a bypass path based on a determination result of the bypass determination unit,
The conditional execution control unit
A condition execution determination unit that determines whether a condition execution instruction to be executed is valid or invalid;
A general-purpose register write control unit that controls writing of data to a general-purpose register based on a determination result of the condition execution determination unit,
Even when the bypass determination unit determines the occurrence of data interference, the register output control unit is configured to output one of the plurality of bypass paths and the data path according to a determination result transmitted from the condition execution determination unit. 4. The microprocessor having a conditional execution instruction according to claim 3, wherein the microprocessor controls the data transfer via one of the plurality of registers or the plurality of general-purpose registers.
JP12452597A 1997-05-14 1997-05-14 Microprocessor having conditional execution instruction Expired - Fee Related JP3547585B2 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP12452597A JP3547585B2 (en) 1997-05-14 1997-05-14 Microprocessor having conditional execution instruction
US08/942,295 US6016543A (en) 1997-05-14 1997-10-01 Microprocessor for controlling the conditional execution of instructions

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP12452597A JP3547585B2 (en) 1997-05-14 1997-05-14 Microprocessor having conditional execution instruction

Publications (2)

Publication Number Publication Date
JPH10320199A JPH10320199A (en) 1998-12-04
JP3547585B2 true JP3547585B2 (en) 2004-07-28

Family

ID=14887650

Family Applications (1)

Application Number Title Priority Date Filing Date
JP12452597A Expired - Fee Related JP3547585B2 (en) 1997-05-14 1997-05-14 Microprocessor having conditional execution instruction

Country Status (1)

Country Link
JP (1) JP3547585B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060200654A1 (en) * 2005-03-04 2006-09-07 Dieffenderfer James N Stop waiting for source operand when conditional instruction will not execute
JP5326314B2 (en) * 2008-03-21 2013-10-30 富士通株式会社 Processor and information processing device

Also Published As

Publication number Publication date
JPH10320199A (en) 1998-12-04

Similar Documents

Publication Publication Date Title
US6560697B2 (en) Data processor having repeat instruction processing using executed instruction number counter
US6327647B1 (en) Method and apparatus for interfacing a processor to a coprocessor
EP0789297B1 (en) Data processor loading data and performing multiply-add operation in parallel
JP3881763B2 (en) Data processing device
US6016543A (en) Microprocessor for controlling the conditional execution of instructions
JP3745039B2 (en) Microprocessor with delayed instructions
US20010010072A1 (en) Instruction translator translating non-native instructions for a processor into native instructions therefor, instruction memory with such translator, and data processing apparatus using them
JP2507638B2 (en) Data processing device
JPH0766324B2 (en) Data processing device
EP0855648A2 (en) Data processing with parallel or sequential execution of program instructions
US5983338A (en) Method and apparatus for interfacing a processor to a coprocessor for communicating register write information
JPH1049368A (en) Microporcessor having condition execution instruction
JP3578883B2 (en) Data processing device
JPH01214932A (en) Data processor
JP2001034471A (en) Vliw system processor
US6055628A (en) Microprocessor with a nestable delayed branch instruction without branch related pipeline interlocks
JP2002215387A (en) Data processor provided with instruction translator, and memory interface device
JPH07120284B2 (en) Data processing device
JP3841967B2 (en) Microprocessor
JP3547585B2 (en) Microprocessor having conditional execution instruction
JP3182591B2 (en) Microprocessor
JP3568737B2 (en) Microprocessor with conditional execution instruction
EP1050800A1 (en) A pipelined execution unit
JP2522048B2 (en) Microprocessor and data processing device using the same
JPH0997180A (en) Programmable controller

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20031224

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20040220

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: 20040316

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20040414

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20080423

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20090423

Year of fee payment: 5

LAPS Cancellation because of no payment of annual fees