JP4111645B2 - Memory bus access control method after cache miss - Google Patents
Memory bus access control method after cache miss Download PDFInfo
- Publication number
- JP4111645B2 JP4111645B2 JP34101499A JP34101499A JP4111645B2 JP 4111645 B2 JP4111645 B2 JP 4111645B2 JP 34101499 A JP34101499 A JP 34101499A JP 34101499 A JP34101499 A JP 34101499A JP 4111645 B2 JP4111645 B2 JP 4111645B2
- Authority
- JP
- Japan
- Prior art keywords
- instruction
- branch
- memory bus
- cache
- fetch
- 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
Links
Images
Landscapes
- Executing Machine-Instructions (AREA)
- Memory System Of A Hierarchy Structure (AREA)
- Advance Control (AREA)
Description
【0001】
【発明の属する技術分野】
本発明は、パイプライン処理により命令フェッチ、命令保持、命令デコード、実行を行う情報処理装置のメモリバスアクセス方式に関し、特に分岐成立側命令系列(以下、ターゲット側命令系列)と分岐非成立側命令系列(以下、シーケンシャル側命令系列)を、平行してフェッチするデュアル命令フェッチ型の情報処理システムにおける効率的なメモリバスアクセス方式を提供する。
【0002】
【従来の技術】
パイプライン処理により命令フェッチ、命令保持、命令デコード、命令実行を行うマイクロプロセッサ(または情報処理装置)は、連続する命令列の命令フェッチを先行して行って、実行ユニットでの実行ステージに空きが発生することをなくし、高速処理を実現する。しかし、命令系列内に分岐命令が存在する場合は、その分岐命令の実行を待ってターゲット側命令系列に分岐するのか、シーケンシャル側命令系列を続けるのかに従って、次にフェッチする命令系列が異なる。その結果、一時的に実行ユニットの実行サイクルに空きが生じる。ここで、ターゲット側命令系列とは、分岐命令を実行した結果、分岐が成立した時に実行される分岐先の命令系列であり、シーケンシャル側命令系列とは、分岐命令を実行した結果、分岐が不成立の時に実行される命令系列である。
【0003】
かかる事態を防止するために、ターゲット側命令系列とシーケンシャル側命令系列との両方の命令列に対して、CPUが同時に命令フェッチ要求を出して、CPU内の2つの命令バッファにそれぞれ格納するデュアル命令フェッチ型の情報処理装置が提案されている。このデュアル命令フェッチ型であれば、分岐命令の実行結果がターゲット側への分岐または非分岐のいずれであっても、次に実行される命令系列が命令バッファに保持されているので、分岐命令の分岐方向の予測ミスに伴う新たな命令フェッチに伴う実行ステージの遅れをできるだけ少なくすることができる。
【0004】
また、マイクロプロセッサであるCPUは、命令フェッチを高速化するために、キャッシュメモリを利用する。外部のメモリバスを介してでなければ、命令やデータ等が格納されている外部のメインメモリから、それらの命令やデータをフェッチすることはできない。かかるメモリバスアクセスは、比較的長い時間(多くのパイプラインサイクル)を要するので、メインメモリ内の命令やデータを格納するキャッシュメモリがCPUに隣接して設けられる。通常、CPUからの命令フェッチには、キャッシュメモリに対して要求され、フェッチされた命令が命令バッファに格納される。キャッシュメモリに格納されておらず、キャッシュミスした場合は、メモリバスを介してメインメモリからフェッチ対象の命令をフェッチし、命令バッファに格納すると共にキャッシュメモリにも格納する。
【0005】
【発明が解決しようとする課題】
しかしながら、メインメモリから命令フェッチするメモリバスアクセスを頻繁に行うと、メモリバス内のトラフィックが増大する。かかるメモリバスのトラフィックの増大は、メモリバスアクセスの遅延を招く。特に、分岐命令を実行する前の段階で、実際には実行されないかもしれないターゲット側またはシーケンシャル側の命令をメインメモリから取得する結果、分岐命令の実行の結果必要になった命令をメインメモリからフェッチすることに、長時間を要するようになるのは、好ましくない。
【0006】
そこで、本発明の目的は、過剰なメモリバスアクセスを軽減し、より効率的な命令フェッチを可能にする情報処理装置のメモリバスアクセス方式を提供することにある。
【0007】
【課題を解決するための手段】
上記の目的を達成するために、本発明の一つの側面は、分岐命令のシーケンシャル側とターゲット側の命令系列の両方をフェッチする命令フェッチ部と、命令フェッチ部からのフェッチ要求に応答してキャッシュメモリまたはメインメモリから命令をフェッチするキャッシュ制御部と、メインメモリへのアクセスを行うメモリバスアクセス部と、フェッチした命令を保持する命令バッファとを有する情報処理装置において、
前記命令バッファに格納される分岐命令の分岐予測を分岐命令の実行に先行して行う分岐予測部を有し、前記キャッシュ制御部は、前記分岐命令の分岐方向が未確定の場合に、分岐予測部からの分岐予測方向に応じて、前記メインメモリへのメモリバスアクセスを行うことを特徴とする。
【0008】
上記の発明において、より好ましい第1の実施例では、前記分岐命令の分岐方向が未確定の場合に、キャッシュ制御部は、分岐命令の分岐予測方向の命令についてキャッシュミスを起こした場合は、メインメモリへのメモリバスアクセスを行って命令フェッチを行い、分岐予測方向ではない命令についてキャッシュミスを起こした場合は、メモリバスアクセスを行わないで命令フェッチを中止する。
【0009】
即ち、第1に、分岐命令の分岐予測方向がターゲット側にある場合で、シーケンシャル側の命令についてキャッシュミスを起こした場合は、メモリバスアクセスを行わないで命令フェッチを中止し、第2に、分岐命令の分岐予測方向がシーケンシャル側にある場合で、ターゲット側の命令についてキャッシュミスを起こした場合は、メモリバスアクセスを行わないで命令フェッチを中止する。それ以外の場合は、キャッシュ制御部は、メモリバスアクセスを行って命令フェッチを行う。それ以外の場合は、キャッシュミス後にメモリバスアクセスを許可する。
【0010】
上記の発明において、より好ましい第2の実施例では、前記分岐命令の分岐方向が未確定の場合に、キャッシュ制御部は、分岐命令の分岐予測方向がシーケンシャル側にある場合で、ターゲット側の命令についてキャッシュミスを起こした場合は、メモリバスアクセスを行わないで命令フェッチを中止する。それ以外の場合は、キャッシュ制御部は、メモリバスアクセスを行って命令フェッチを行う。従って、上記第1の実施例と異なり、第2の実施例では、分岐予測方向がターゲット側の場合であってシーケンシャル側の命令についてキャッシュミスを起こしたら、メモリバスアクセスにより命令フェッチを行う。シーケンシャル側の命令フェッチがキャッシュミスする確率は低く、そのような頻度の少ないケースにおいてメモリバスアクセスを禁止する必要性が少ないからである。
【0011】
上記の目的を達成するために、本発明の別の側面は、分岐命令のシーケンシャル側とターゲット側の命令系列の両方をフェッチする命令フェッチ部と、命令フェッチ部からのフェッチ要求に応答してキャッシュメモリまたはメインメモリから命令をフェッチするキャッシュ制御部と、メインメモリへのアクセスを行うメモリバスアクセス部と、フェッチした命令を保持する命令バッファとを有する情報処理装置において、
前記命令バッファに格納される分岐命令の分岐予測を分岐命令の実行に先行して行う分岐予測部を有し、前記キャッシュ制御部は、前記分岐命令の分岐方向が未確定の場合に、キャッシュミスしたらメモリバスアクセスを行わないで命令フェッチを中止し、前記分岐命令が確定している場合に、当該確定した分岐方向の命令についてキャッシュミスしたらメモリバスアクセスを行うことを特徴とする。
【0012】
上記の発明によれば、分岐確定後の分岐方向の命令についてのみ、キャッシュミス後のメモリバスアクセスを行うことになり、メモリバスのトラフィックスを軽減することができる。即ち、分岐未確定の段階では、使用されるか否か不明であるので、キャッシュミス後のメモリバスアクセスは全面的に禁止する。また、分岐未確定時のターゲット側の命令は、キャッシュメモリに格納されている範囲内で、命令バッファへのプリフェッチが行われる。
【0013】
【発明の実施の形態】
以下、図面を参照して本発明の実施の形態例を説明する。しかしながら、かかる実施の形態例が、本発明の技術的範囲を限定するものではない。
【0014】
図1は、本発明の実施の形態例における情報処理装置のシステム図である。図1に示された情報処理装置は、マイクロプロセッサであり、チップ内にCPU40と、キャッシュメモリユニット50と、メモリバスアクセス部60とを有する。メモリバスアクセス部60から左側がチップ外であり、外部のメモリバス62を介してメインメモリ64に接続される。
【0015】
CPU40は、命令をデコードしてその命令を実行する命令デコーダ及び命令実行部49を有する。図1に示されたCPU40は、分岐命令のシーケンス側とターゲット側との命令を両方、同時にフェッチを行うデュアル命令フェッチ方式の命令フェッチ部410,411を有する。更に、CPU40は、シーケンス側とターゲット側のフェッチされた命令を格納する命令バッファ470,471を有し、当該命令バッファの命令のうち、セレクタ48で選択された側の命令が、命令デコーダ49に供給される。セレクタ48の選択は、後述する分岐命令の分岐予測信号S430,S431に従って行われる。
【0016】
命令デコーダでデコードされた命令は、命令実行部49で実行され、図示しない所定のレジスタなどに実行結果が書き込まれる。命令デコーダ及び命令実行部49は、分岐命令の分岐先アドレス情報S12を分岐側アドレス生成部46に供給する。分岐側アドレス生成部46は、その分岐先アドレス情報S12に従って、分岐先アドレスA10を生成し、分岐先アドレスバッファ45に供給する。分岐先アドレスバッファ45は、その供給されたターゲット側の命令のアドレスである分岐先アドレスを、その後の命令フェッチのために保持する。更に、連続側アドレスバッファ44は、シーケンシャル側の命令のアドレスをインクリメントして生成し、保持する。
【0017】
命令フェッチ部410,411は、それぞれアドレス選択部420,421を有する。アドレス選択部420,421には、連続側アドレスバッファ44からシーケンシャル側のアドレスA1が、分岐先アドレスバッファ45からターゲット側の分岐先アドレスA2が、そして、命令実行部49から命令実行の結果生成したアドレスA3がそれぞれ供給され、その中から選択されたアドレスが、キャッシュメモリユニット50に命令フェッチ要求S20と共に供給される。命令フェッチ部410,411は、命令実行部49から供給される分岐確定信号S10に応答して、一方がシーケンシャル側の命令フェッチ部になり、他方がターゲット側の命令フェッチ部になる。また、分岐確定信号S10に従って、命令フェッチが分岐未確定段階のプリフェッチか、分岐が確定したあとのフェッチかの区別を、命令フェッチ要求S20に添付して、キャッシュメモリユニットに与える。
【0018】
キャッシュメモリユニット50は、キャッシュメモリ52と、キャッシュ制御部54,56を有する。キャッシュ制御部54,56は、命令フェッチ部410,411からのフェッチ要求S20に応答してキャッシュメモリ52またはメインメモリ64から命令をフェッチする。従って、キャッシュメモリユニット50は、シーケンシャル側とターゲット側の命令フェッチ要求を同時に受け付けることができる2ポート形式になっている。キャッシュ制御部54,56は、キャッシュメモリ52に対してアドレスADを与えて命令をフェッチするが、その命令フェッチに対してキャッシュヒットしたかキャッシュミスしたかを示すヒット・ミス信号CHMが、キャッシュメモリ52からそれぞれのキャッシュ制御部54,56に返信される。
【0019】
各キャッシュ制御部54,56は、フェッチ要求S20に応答してキャッシュメモリに命令フェッチした結果、キャッシュヒットした場合は、そのフェッチした命令を、対応する命令バッファ470,471に供給して格納する。キャッシュ制御部54,56は、キャッシュミスした場合は、後述するアルゴリズムに従って、メインメモリ64から命令をフェッチするようメモリバスアクセス部60にメモリバスアクセス要求を行う。但し、本実施の形態例では、このメモリバスアクセスは、分岐未確定の段階では一部制限されている。
【0020】
メモリバスアクセス部60は、外部のメモリバス62を介してメインメモリ64に接続され、メモリバス62の制御を行い、キャッシュ制御部54,56からのメインメモリ64へのフェッチ要求に応答して、メモリバスアクセスを行う。メインメモリ64からフェッチされた命令は、それぞれ対応するキャッシュ制御部54,56に供給され、対応する命令バッファ470,471に格納されると共に、キャッシュメモリ52にも記憶される。
【0021】
キャッシュ制御部54,56は、フェッチ要求信号S20に応答して、キャッシュメモリ52から命令をフェッチしたか、メモリバスアクセスしてメインメモリ64から命令をフェッチしたか、或いは命令フェッチを中止したかについての完了通知信号S22を、対応するアドレス選択部420,421に供給する。
【0022】
図1の情報処理装置は、CPU40内に分岐予測部430,431を有する。この分岐予測部430,431は、命令バッファに格納される命令コードが有する分岐予測ビットS30,S32に従って、そのフェッチされた分岐命令の分岐予測を行い、分岐予測情報S430,S431を適宜アドレス選択部420,421に供給する。アドレス選択部420,421は、フェッチ要求信号S20に、その分岐予測情報、フェッチ先アドレス、及び分岐確定か否かの情報を加えて、キャッシュ制御部54,56に供給する。
【0023】
図1に示された情報処理装置は、デュアル命令フェッチ方式であり、命令列のシーケンシャル側の命令列とターゲット側の命令列との両方をフェッチし、命令バッファ470,471に格納する。かかる命令フェッチは、分岐命令が命令実行部49で実行されて分岐が確定する前の分岐未確定の段階で行われ、そのプリフェッチされたシーケンシャル側とターゲット側の命令列が、命令バッファ470,471に格納される。従って、分岐命令が実行された結果、いずれの方向に分岐が確定しても、分岐命令が確定した後の命令のデコードと実行のステージを、パイプラインのサイクルを乱すことなく行うことができる。
【0024】
更に、図1に示された情報処理装置は、分岐予測部430,431によってフェッチされた命令の分岐予測を行い、分岐予測結果S430,S431に応じて、命令バッファ470,471の一方の命令をデコードする。分岐命令が確定する前に、分岐予測に従って命令のデコードをすることにより、分岐確定時におけるパイプライン処理のサイクルの乱れを少なくすることができる。
【0025】
キャッシュ制御部54,56は、一般的には、フェッチ要求に応答して、キャッシュメモリ52から命令をフェッチし、キャッシュヒットした場合は、そのフェッチした命令を命令バッファに格納し、キャッシュミスした場合は、メモリバスアクセス部60にメモリバスアクセス要求を出して、メインメモリ64から命令をフェッチする。
【0026】
しかしながら、キャッシュメモリユニット50内のデータバスは高速であるのに対して、外部にあるメモリバス62は、その動作周波数が遅くまたバス幅も狭い。従って、メモリバスアクセスが頻繁に行われるとメモリバス62へのトラフィックが増大し、メモリバスアクセス自体が時間を要することになる。従って、外部のメモリバス62へのアクセス頻度を高くすると、例えば急に必要になった命令のフェッチをメインメモリから行わなければならなくなった時、そのメモリバスアクセスに時間がかかるという課題を有する。
【0027】
本実施の形態例におけるキャッシュ制御部54,56は、後述する通り、分岐が確定していない場合は、必要に応じてまたは全て、キャッシュミスした後のメモリバスアクセスを行わないで命令フェッチを中止する。
【0028】
第1の実施例では、分岐予測方向でない命令については、上記のキャッシュミス後のメモリバスアクセスを行わないで、命令フェッチを中止する。分岐予測方向でない命令の場合は、その後分岐命令が確定した時点でその命令フェッチが無駄になる可能性が高いので、かかる命令に対するメモリバスアクセスは行わないほうが効率的である。但し、分岐予測方向の命令については、キャッシュミス後にメモリバスアクセスを行う。
【0029】
第2の実施例では、分岐予測方向がシーケンシャル側であって、ターゲット側の命令についてキャッシュミスを起こした場合は、そのメモリバスアクセスは行わないで命令フェッチを中止する。但し、分岐予測の方向がターゲット側であって、シーケンシャル側の命令についてキャッシュミスを起こした場合は、分岐予測方向と違う側の命令であっても、メモリバスアクセスを行って、命令フェッチを完了させる。その理由は、キャッシュミスをしてメモリバスアクセスされる場合は、その命令と連続するアドレスの命令が一括してキャッシュメモリ52にフェッチされるので、シーケンシャル側の命令系列がキャッシュミスを起こす可能性は低い。従って、かかる頻度の低いメモリバスアクセスを許可しても、メモリバス62のトラフィックの増大にはあまりつながらないからである。第2の実施例の場合、分岐予測方向の命令に対しては、キャッシュミス後にメモリバスアクセスを許可する。
【0030】
第3の実施例としては、分岐命令が未確定の間は、キャッシュヒットした命令のみ命令バッファに格納し、キャッシュミスしたらメモリバスアクセスは行わずに命令フェッチを中止し、分岐命令が確定した後において、キャッシュミスした命令のメモリバスアクセスを行うようにする。この場合でも、以前にフェッチした命令がキャッシュメモリに記録されている限り、デュアル命令フェッチ方式により、両側の命令をプリフェッチして命令バッファに格納することができる。そして、確実に使用される分岐確定後の分岐方向の命令に対してのみメモリバスアクセスを行うので、メモリバスへのアクセス頻度を下げることができる。
【0031】
図2は、キャッシュ制御部のブロック図である。前述した通り、CPU40からフェッチ要求S20Bが、フェッチアドレスS20Aと分岐予測情報S20Cと共に供給される。アドレスS20Aはキャッシュメモリ52に供給されると共に、バスアクセスアドレス保持部72で保持される。また、フェッチ要求信号S20Aと分岐予測情報S20Cとは、バスアクセス要否判定部70に供給される。
【0032】
バスアクセス要否判定部70は、キャッシュメモリ52からのキャッシュ・ヒット・ミス信号CHMによるキャッシュヒット判定結果と、分岐予測情報S20Cと、現在シーケンシャル側かターゲット側かのステータスなどに応じて、メモリバスアクセスを要求するか否かを判定する。また、バスアクセス要否判定部70は、その判定結果を、バスアクセス要求信号S71としてバスアクセス制御部74に供給し、バスアクセス不要信号S70を完了通知判定部78に供給する。
【0033】
上記の判定でメモリバスアクセスが必要と判定された場合は、バスアクセス制御部74は、バスアクセス要求信号S71に応答して、メモリバスアクセス部60にバスアクセス要求信号S76を送ると共に、バスアクセスアドレス保持部72に制御信号S75を出力して、保持しているフェッチアドレスを出力させる。また、上記の判定でメモリバスアクセスが不要と判定された場合は、バスアクセス制御部74は、メモリバスアクセスは行わない。この判定は、上記の実施例1,2,3のアルゴリズムに従う。
【0034】
メモリバスアクセスに応答して、メインメモリ64からデータが返信されたときは、バスアクセス制御部74は、メモリバスアクセス部60からデータ有効信号S77を受信し、それに応答して、バスアクセス完了信号S74を完了通知判定部78に供給する。完了通知判定部78は、バスアクセス完了信号S74やバスアクセス不要信号S70に従って、命令をキャッシュメモリ52からフェッチしたのか、命令フェッチを中止したのか、メモリバスアクセスによりメインメモリからフェッチしたのかの完了通知信号S22を、CPUの命令フェッチ部に送る。
【0035】
メインメモリからフェッチされた命令は、キャッシュ制御部を介して、キャッシュメモリに格納されると共に、命令バッファにも格納される。
【0036】
以下、上記の第1、第2、第3の実施例におけるメモリバスアクセスを行わないアルゴリズムについて、説明する。
【0037】
図3は、上記の第1の実施例における命令フェッチの動作を示す図表である。図表に沿ってその命令フェッチの動作を説明する。第1の実施例では、
(1)分岐命令の分岐方向が確定していない場合には、
(1-1)分岐予測部による分岐予測方向がターゲット側の場合には、第1に、シーケンシャル側の命令フェッチは、命令キャッシュミスを起こしたら、メモリバスアクセスしないで、命令フェッチを中止し、メモリバスアクセスをしない。第2に、ターゲット側の命令フェッチは、命令キャッシュミスを起こしたら、メモリバスアクセスして命令フェッチを完了する。
(1-2)分岐命令実行での分岐予測方向がシーケンシャル側の場合には、第1に、ターゲット側の命令フェッチは、命令キャッシュミスを起こしたら、メモリバスアクセスしないで、命令フェッチを中止し、メモリバスアクセスをしない。第2に、シーケンシャル側の命令フェッチは、命令キャッシュミスを起こしたら、メモリバスアクセスして命令フェッチを完了する。
(2)分岐命令の分岐方向が確定している場合には、
分岐方向が確定した側(シーケンシャル側、または、ターゲット側)のみを命令フェッチする。その場合は、キャッシュミスを起こしたらメモリバスアクセスして命令フェッチを完了する。
【0038】
以上の通り、第1の実施例では、分岐方向が未確定の間は、分岐予測方向の命令フェッチについてのみ、キャッシュミス後のメモリバスアクセスを行うことを許可し、分岐予測方向ではない命令フェッチは、キャッシュミス後のメモリバスアクセスは禁止して、無駄になる可能性の高い命令フェッチのためのメモリバスアクセスは行わない。いずれの場合でもキャッシュヒットした場合は、それでフェッチされた命令は命令バッファ内に格納され、命令フェッチは完了する。
【0039】
また、命令フェッチ部410,411内のアドレス選択部420,421は、命令フェッチが完了しなかった命令であって、分岐確定信号S10により分岐が確定した方向の命令については、改めて命令フェッチ要求を出す。この時にキャッシュミスが生じたら、メモリバスアクセスを行って
必要な命令のフェッチを行う。そのとき、それに連続する命令列もキャッシュメモリ52に格納される。
【0040】
図4は、第1の実施例を改良した第2の実施例における命令フェッチの動作を示す図表である。図表に沿ってその命令フェッチの動作を説明する。第2の実施例では、
(1)分岐命令の分岐方向が確定していない場合には、
(1-1)分岐予測部の分岐予測方向がターゲット側の場合には、第1に、シーケンシャル側の命令フェッチは、命令キャッシュミスを起こしたら、メモリバスアクセスして、命令フェッチを完了する。第2に、ターゲット側の命令フェッチは、命令キャッシュミスを起こしたら、メモリバスアクセスして、命令フェッチを完了する。
(1-2)分岐命令実行での分岐予測方向がシーケンシャル側の場合には、第1に、ターゲット側の命令フェッチは、命令キャッシュミスを起こしたら、メモリバスアクセスしないで、命令フェッチを中止し、メモリバスアクセスをしない。第2に、シーケンシャル側の命令フェッチは、命令キャッシュミスを起こしたらメモリバスアクセスして、命令フェッチを完了する。
(2)分岐命令の分岐方向が確定している場合には、
分岐方向が確定した側(シーケンシャル側、または、ターゲット側)のみを命令フェッチする。その場合は、キャッシュミスを起こしたらメモリバスアクセスして命令フェッチを完了する。
【0041】
第2の実施例が第1の実施例と異なるところは、分岐予測方向がターゲット側であってシーケンシャル側の命令フェッチに対してキャッシュミスが生じた場合は、分岐予測方向とは異なる側の命令ではあるが、メモリバスアクセスをして命令フェッチを完了することにある。かかるケースは、極めて可能性が低いので頻度が低く、従って、メモリバスアクセスを許可してもメモリバスのトラフィックを増大することにはならない。
【0042】
図5は、第3の実施例における命令フェッチの動作を示す図表である。図表に沿ってその命令フェッチの動作を説明する。第3の実施例では、
(1)分岐命令の分岐方向が確定していない場合は、
(1-1)分岐予測部の分岐予測方向がターゲット側の場合には、第1に、シーケンシャル側の命令フェッチは、命令キャッシュミスを起こしたら、メモリバスアクセスしないで、命令フェッチを中止し、メモリバスアクセスをしない。第2に、ターゲット側の命令フェッチも、命令キャッシュミスを起こしたら、メモリバスアクセスしないで、命令フェッチを中止し、メモリバスアクセスをしない。
(1-2)分岐予測部の分岐予測方向がシーケンシャル側の場合には、第1に、ターゲット側の命令フェッチは、命令キャッシュミスを起こしたら、メモリバスアクセスしないで、命令フェッチを中止し、メモリバスアクセスをしない。第2に、シーケンシャル側の命令フェッチも、命令キャッシュミスを起こしたら、メモリバスアクセスしないで、命令フェッチを中止し、メモリバスアクセスをしない。
(2)分岐方向が確定している場合には、
分岐方向が確定した側(シーケンシャル側、または、ターゲット側)のみを命令フェッチする。この場合、キャッシュミスを起こしてもメモリバスアクセスしてメインメモリから命令をフェッチして命令フェッチを完了する。
【0043】
第3の実施例は、分岐命令が実行されず分岐未確定の間は、一切のメモリバスアクセスを禁止し、分岐方向が確定した命令についてのみメモリバスアクセスを許可する。分岐未確定の場合は、メモリバスアクセスのよる命令フェッチが無駄になる可能性があるので、そのメモリバスアクセスを禁止してメモリバスのトラフィックを少なくする。キャッシュメモリには、分岐確定した命令が予め格納されるので、キャッシュミス自体はそれほど高い確率で発生するものではない。従って、キャッシュメモリからの命令フェッチだけでプリフェッチして、命令デコーダにシーケンス側とターゲット側の両方の命令系列を格納するだけでも、全体のパイプライン動作をあまり乱すことなく命令の実行を行うことが可能である。
【0044】
最後に、第4の実施例として、上記以外のメモリバスアクセスを減らす方法について説明する。図6は、第4の実施例における命令フェッチの動作を示す図表である。図表に沿ってその命令フェッチの動作を説明する。第4の実施例では、(1)分岐命令の分岐方向が確定していない場合
(1-1)分岐予測部での分岐予測方向がターゲット側の場合には、シーケンシャル側の命令フェッチは、命令キャッシュミスを起こしたら、メモリバスアクセスしないで、命令フェッチを中止し、メモリバスアクセスをしない。一方で、ターゲット側の命令フェッチは、命令キャッシュミスを起こしたら、メモリバスアクセスして命令フェッチを完了する。
(1-2)分岐予測部での分岐予測方向がシーケンシャル側の場合には、第1に、ターゲット側の命令フェッチは、命令キャッシュミスを起こしたらメモリバスアクセスして、命令フェッチを完了する。第2に、シーケンシャル側の命令も、命令キャッシュミスを起こしたら、メモリバスアクセスして、命令フェッチを完了する。
(2)分岐命令の分岐方向が確定している場合
分岐方向が確定した側(シーケンシャル側、または、ターゲット側)のみを命令フェッチする。この場合は、キャッシュミスに対してメモリバスアクセスを行った命令フェッチを完了する。
【0045】
上記第4の実施例の場合は、分岐命令の分岐未確定の場合は、少なくとも分岐予測方向がターゲット側であって、シーケンシャル側の命令フェッチでキャッシュミスを起こしたらメモリバスアクセスは行わない。これにより、その分だけメモリバスアクセスの回数を減らすことができる。
【0046】
上記第4の実施例と同様に、分岐未確定の時に、任意の命令フェッチに対してメモリバスアクセスを禁止するようにしても、その分だけメモリバスアクセスの回数を減らすことはできる。但し、それに伴って分岐予測されている方向の命令プリフェッチができない場合も発生する。メモリバスアクセスの禁止と命令プリフェッチの失敗とのバランスを考慮して、設定することが望ましい。
【0047】
上記4つの実施例のうち、メモリバスアクセスの禁止と命令プリフェッチの失敗とをある程度バランスさせている第2の実施例の動作について、図1を参照して説明する。前提として、シーケンシャル側の命令フェッチは、ポート0側で行われ、ターゲット側の命令フェッチは、ポート1側で行われると仮定する。
(1)分岐命令の分岐方向が確定していない場合において、
(1-1)分岐予測部430,431での分岐予測方向がターゲット側の場合には、シーケンシャル側の命令フェッチは、CPU40の命令フェッチ部410(Port-0)が命令フェッチ要求S20をキャッシュメモリユニット50内のキャッシュ制御部54(Port-0)に供給し、その命令フェッチ要求が命令キャッシュメモリ52に渡される。この命令フェッチ要求には、フェッチアドレスに加えて、分岐未確定か否かの情報、分岐予測情報なども添付される。
【0048】
命令キャッシュメモリ52において、命令キャッシュミスを起こしたら、その信号CHMがキャッシュ制御部54に返され、キャッシュ制御部54は、メモリバスアクセス部60にメモリバスアクセス要求を出す。それに応答して、メモリバスアクセス部60はメモリバス62にアクセスして、命令を主記憶64から読み出して、キャッシュ制御部54に渡し、メモリキャッシュ52に書き込み、且つ、CPU40内命令バッファ(0)470に格納して、命令フェッチを完了する。命令フェッチ完了信号S22が、命令フェッチ部410に返信される。
【0049】
シーケンシャル側の命令フェッチのキャッシュミスの頻度はそれほど高くないので、この場合にメモリバスアクセスを許可しても全体のメモリバスの効率を低下させることにはあまりならない。
【0050】
ターゲット側の命令フェッチは、CPU40内の命令フェッチ部411から命令フェッチ要求をキャッシュ制御部56(Port-1)に供給し、その命令フェッチ要求が命令キャッシュメモリ52に渡される。
【0051】
命令キャッシュメモリ52において、命令キャッシュミスを起こしたら、キャッシュ制御部56(Port-1)がメモリバスアクセス部60にメモリバスアクセス要求を出し、メモリバスアクセス部60はメモリバス62にアクセスして、命令を主記憶64から読み出して、キャッシュ制御部56(Port-1)に渡し、キャッシュメモリ52に書き込み、且つ、CPU40の命令バッファ(1)471に格納して、命令フェッチを完了する。そして、命令フェッチ完了信号が命令フェッチ部411に返信される。
【0052】
この場合は、使用確率が高い分岐予測方向の命令がキャッシュミスしているので、メモリバスアクセスを許可して、プリフェッチを完了することが、分岐後のパイプライン動作の乱れを防止することになる。
(1-2)分岐予測部での分岐予測方向がシーケンシャル側の場合には、ターゲット側の命令フェッチは、CPU40内の命令フェッチ部411から命令フェッチ要求がキャッシュ制御部56(Port-1)に出され、その命令フェッチ要求が命令キャッシュメモリに渡される。
【0053】
命令キャッシュメモリ52において、命令キャッシュミスを起こしても、キャッシュ制御部(Port-1)56がメモリバスアクセス部60にメモリバスアクセス要求を出さない。その結果、メモリバスアクセス部60はメモリバスアクセスしない。そして、キャッシュ制御部56は、命令フェッチを中止し、アドレス選択部421に命令フェッチをキャンセルした結果信号を返信する。
【0054】
一方、シーケンシャル側の命令フェッチは、CPU40内の命令フェッチ部410から命令フェッチ要求がキャッシュ制御部(Port-0)54に出され、その命令フェッチ要求が命令キャッシュメモリ52に渡される。
【0055】
命令キャッシュメモリ52において、命令キャッシュミスを起こしたら、キャッシュ制御部54がメモリバスアクセス部60にメモリバスアクセス要求を出し、メモリバスアクセス部60はメモリバス62にアクセスして、命令を主記憶64から読み出して、キャッシュ制御部54に返す。キャッシュ制御部54は、その命令をキャッシュメモリ52に書き込み、且つ、CPUの命令バッファ(0)470に格納して、命令フェッチを完了する。
(2)分岐命令の実行により分岐方向が確定している場合
命令フェッチ部420,421は、分岐命令の実行により分岐方向が確定した側(シーケンシャル側、または、ターゲット側)のみを、命令フェッチする。その時、分岐確定方向がシーケンシャル側の場合には、命令フェッチ部420が、キャッシュ制御部(Port-0)54を介して、メモリバスアクセス部60にバスアクセスを要求する。メモリバスアクセス部60は、フェッチ要求された命令を主記憶64から読み出し、キャッシュ制御部54を介して、命令バッファ(0)470とキャッシュメモリ52に命令を格納して、命令フェッチを完了する。
【0056】
分岐確定方向がターゲット側の場合には、命令フェッチ部411が、キャッシュ制御部(Port-1)56を介して、メモリバスアクセス部60にバスアクセスを要求する。メモリバスアクセス部60が、フェッチ要求された命令を主記憶64からを読み出し、キャッシュ制御部56を介して、命令バッファ(1)471に命令を格納して、命令フェッチを完了する。なお、分岐確定方向がターゲット側になった時点で、ターゲット側はシーケンシャル側に、シーケンシャル側はターゲット側に交代する。
【0057】
図7は、上記の第1または第2の実施例によりメモリバスアクセスが制限された場合の、具体的なパイプライン動作を示す図表である。この例は、図7の表の下に示したシーケンシャル側の命令列01〜09と分岐命令03に対応するターゲット側の命令列51〜54を例にして、パイプライン動作を示すものである。この例では、分岐命令03についての分岐予測は、分岐しない、つまりシーケンシャル側の方向が予測されている場合である。
【0058】
パイプライン動作は、次のステージで構成される。
P:命令フェッチ要求ステージ:CPUがキャッシュ制御部に命令フェッチ要求をする。この段階では、分岐未確定のプリフェッチか、分岐確定後のフェッチかの区別を付けて命令フェッチ要求される。
T:フェッチステージ:キャッシュメモリでヒットミス判定を行い命令を取り出す準備をする。
C:命令バッファステージ:命令バッファに命令を取りこむ。
D:デコードステージ:命令デコーダが命令を解読し制御信号を生成する。
E:実行ステージ:デコード結果の制御信号に応答して命令を実行する。
W:書き込みステージ:命令を実行した結果をレジスタに書き込む。
M:キャッシュミス:キャッシュミスが発生した。
B:バスアクセス保持ステージ:メモリバスにアクセスするためアドレスをバスアクセスアドレス保持部にて保持する。
R:バスアクセス要求ステージ:メモリバスアクセス部に読み出しリクエストを出す。バスアクセスして命令が読み出されるまで18サイクルを要すると仮定する。
【0059】
図7に戻り、命令01は、サイクル1の命令フェッチ要求ステージP、サイクル2のフェッチステージTによりキャッシュメモリから命令をフェッチすることができ、サイクル3で命令バッファに命令が取り込まれる(ステージD)。そして、サイクル5,6,7の3サイクルで命令が実行される(ステージE)。実行後に命令実行結果が各種レジスタに書き込まれる(ステージW)。
【0060】
命令02も、ステージP、T、Cを経て、命令が命令バッファに取り込まれる。そして、命令01の実行ステージEが終了した次のサイクル8で、デコードステージDで待機していた命令02が実行され(ステージE)、実行結果がレジスタに書き込まれる(ステージW)。
【0061】
命令03は、命令バッファステージCの時点で、分岐予測部により分岐命令であることが判別され、分岐方向はシーケンシャル側であると予測される。従って、サイクル6からターゲット側の命令列51、52,53も命令プリフェッチが開始される。
【0062】
命令03〜07までは、全てキャッシュヒットしてパイプラインサイクルを乱すことなく、それぞれの実行ステージEが実行される。そして、命令08〜10がキャッシュミス(ステージM)を起こしたとする。また、ターゲット側の命令51〜53もキャッシュミス(ステージM)を起こしたとする。
【0063】
命令08は、サイクル8の時点では分岐命令03の分岐が未確定であり、分岐未確定の命令プリフェッチとして要求される(ステージP)。そこで、サイクル10でキャッシュミスを起こすが、第1または第2の実施例では、分岐予測がシーケンシャル側の時にシーケンシャル側の命令がキャッシュミスを起こすと、そのメモリバスアクセスを許可している。従って、サイクル11でバスアクセス保持ステージB、サイクル12からバスアクセス要求ステージRに入る。バスアクセス要求ステージRは、18サイクルを要すると仮定したので、サイクル30でフェッチされた命令が命令バッファに格納され、命令バッファステージCになる。
【0064】
命令08のメモリバスアクセスに伴い、それに後続する命令もメインメモリからフェッチされてキャッシュメモリに格納されるので、命令09以降の命令バッファステージCは、命令08のステージCに続いて起こることになる。
【0065】
一方、命令51は、サイクル8の時点でキャッシュミスを起こすが、分岐予測方向がシーケンシャル側であるので、ターゲット側の命令51に対するメモリバスアクセスは禁止される。命令52、53も同様にメモリバスアクセスは禁止される。従って、命令08がメモリバスアクセス要求するしたサイクル12では、メモリバスは空き状態にあり、即メモリバスアクセスを行うことができ、サイクル32で命令08が実行される(ステージE)。
【0066】
尚、命令11、12は、それぞれ分岐が確定した後に分岐確定後の命令フェッチステージPを迎えるので、キャッシュミスしてもメモリバスアクセスは実行される。但し、図7の例では、すでに命令08のメモリバスアクセスでキャッシュメモリに命令11、12が格納されているので、キャッシュミスは起こしていない。
【0067】
図7の例は、第1の実施例でも第2の実施例でも、同様の動作になる。即ち、分岐未確定時の命令08のプリフェッチに対してキャッシュミスを起こしても、分岐予測方向側の命令08に対しては、メモリバスアクセスは許可される。
【0068】
第3の実施例の場合は、分岐未確定時の命令08のプリフェッチに対して、キャッシュミス後のメモリバスアクセスは禁止される。その場合は、分岐確定後に再度命令フェッチ部からの命令フェッチに応答して、キャッシュミス後にメモリバスアクセスにより命令がフェッチされる。その場合のメモリバスアクセスは、高速に行われる。
【0069】
図8は、従来例のメモリバスアクセスが制限されていない場合の、具体的なパイプライン動作を示す図表である。この例も、図7の場合と同じ命令列に対するパイプライン動作を示すものである。
【0070】
この例では、命令51は分岐予測方向ではないが、メモリバスアクセスを許可される。従って、サイクル10からバスアクセス要求ステージRになっている。このステージRは18サイクルを要するので、命令08がサイクル10でキャッシュミス(ステージM)を起こしても、メモリバスがビジー状態であり、そのメモリバスアクセスRは、サイクル28まで待たされることになる。その結果、命令08の実行ステージEは、サイクル48まで遅れることになる。
【0071】
このように、従来例に比較して、本実施例では、分岐未確定の段階でのメモリバスアクセスを制限したので、使用可能性が高い命令に対するメモリバスアクセスを効率的に行うことができ、パイプラインサイクルの乱れを最小限に止めることができる。
【0072】
以上、本発明の保護範囲は、上記の実施の形態例に限定されるものではなく、特許請求の範囲に記載された発明とその均等物にまで及ぶものである。
【0073】
【発明の効果】
以上、本発明によれば、分岐未確定の場合の命令フェッチに対して、キャッシュミスした時のメインメモリへのアクセスを適宜制限したので、分岐予測方向の命令や分岐確定後の命令に対するメインメモリへのアクセスをより効率的に行うことができる。
【図面の簡単な説明】
【図1】本発明の実施の形態例における情報処理装置のシステム図である。
【図2】キャッシュ制御部のブロック図である。
【図3】第1の実施例における命令フェッチの動作を示す図表である。
【図4】第2の実施例における命令フェッチの動作を示す図表である。
【図5】第3の実施例における命令フェッチの動作を示す図表である。
【図6】第4の実施例における命令フェッチの動作を示す図表である。
【図7】第1または第2の実施例によりメモリバスアクセスが制限された場合の、具体的なパイプライン動作を示す図表である。
【図8】従来例の場合の具体的なパイプライン動作を示す図表である。
【符号の説明】
40 CPU
410,411 命令フェッチ部
430,431 分岐予測部
50 キャッシュメモリユニット
52 キャッシュメモリ
54,56 キャッシュ制御部
60 メモリバスアクセス部
62 メモリバス
64 メインメモリ[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a memory bus access method of an information processing apparatus that performs instruction fetch, instruction hold, instruction decode, and execution by pipeline processing, and in particular, a branch success side instruction series (hereinafter, target side instruction series) and a branch non-establishment side instruction Provided is an efficient memory bus access method in a dual instruction fetch type information processing system for fetching a series (hereinafter referred to as a sequential instruction series) in parallel.
[0002]
[Prior art]
A microprocessor (or information processing device) that performs instruction fetch, instruction hold, instruction decode, and instruction execution by pipeline processing performs instruction fetch of a continuous instruction sequence in advance, and there is a vacancy in the execution stage in the execution unit. It eliminates the occurrence and realizes high-speed processing. However, when there is a branch instruction in the instruction series, the instruction series to be fetched next differs depending on whether the branch instruction is executed after branching to the target instruction series or the sequential instruction series is continued. As a result, there is a vacancy in the execution cycle of the execution unit temporarily. Here, the target side instruction series is a branch destination instruction series that is executed when a branch is established as a result of executing a branch instruction, and the sequential side instruction series is that the branch is not established as a result of executing the branch instruction. This is a sequence of instructions executed at the time.
[0003]
In order to prevent such a situation, the dual instruction in which the CPU issues an instruction fetch request simultaneously to both instruction sequences of the target side instruction sequence and the sequential side instruction sequence and stores them in two instruction buffers in the CPU, respectively. A fetch type information processing apparatus has been proposed. With this dual instruction fetch type, even if the execution result of a branch instruction is either a branch to the target side or a non-branch, the instruction sequence to be executed next is held in the instruction buffer. Execution stage delays associated with new instruction fetches due to branch direction mispredictions can be minimized.
[0004]
Further, the CPU that is a microprocessor uses a cache memory in order to speed up instruction fetch. Unless the external memory bus is used, the instructions and data cannot be fetched from the external main memory storing the instructions and data. Since such a memory bus access requires a relatively long time (many pipeline cycles), a cache memory for storing instructions and data in the main memory is provided adjacent to the CPU. Normally, instruction fetch from the CPU is requested from the cache memory, and the fetched instruction is stored in the instruction buffer. If a cache miss occurs without being stored in the cache memory, the instruction to be fetched is fetched from the main memory via the memory bus, stored in the instruction buffer, and also stored in the cache memory.
[0005]
[Problems to be solved by the invention]
However, if the memory bus access for fetching instructions from the main memory is frequently performed, traffic in the memory bus increases. Such an increase in memory bus traffic causes a delay in memory bus access. In particular, as a result of acquiring a target or sequential instruction that may not actually be executed from the main memory before executing a branch instruction from the main memory, an instruction required as a result of execution of the branch instruction is read from the main memory. It is not preferable that fetching takes a long time.
[0006]
Accordingly, an object of the present invention is to provide a memory bus access method for an information processing apparatus that reduces excessive memory bus access and enables more efficient instruction fetching.
[0007]
[Means for Solving the Problems]
In order to achieve the above object, one aspect of the present invention provides an instruction fetch unit that fetches both sequential and target instruction sequences of a branch instruction, and a cache in response to a fetch request from the instruction fetch unit. In an information processing apparatus having a cache control unit that fetches an instruction from a memory or a main memory, a memory bus access unit that accesses the main memory, and an instruction buffer that holds the fetched instruction.
A branch prediction unit that performs branch prediction of a branch instruction stored in the instruction buffer prior to execution of the branch instruction, and the cache control unit performs branch prediction when a branch direction of the branch instruction is uncertain. A memory bus access to the main memory is performed in accordance with a branch prediction direction from the unit.
[0008]
In the first aspect of the invention described above, in a more preferred first embodiment, when the branch direction of the branch instruction is uncertain, the cache control unit performs main processing when a cache miss occurs for an instruction in the branch prediction direction of the branch instruction. When a memory miss is performed for an instruction that is not in the branch prediction direction, the instruction fetch is stopped without performing the memory bus access.
[0009]
That is, first, when the branch prediction direction of the branch instruction is on the target side, and a cache miss occurs for the sequential side instruction, the instruction fetch is stopped without performing the memory bus access, and secondly, When the branch prediction direction of the branch instruction is on the sequential side and a cache miss occurs with respect to the instruction on the target side, the instruction fetch is stopped without performing the memory bus access. In other cases, the cache control unit performs an instruction fetch by performing a memory bus access. In other cases, memory bus access is permitted after a cache miss.
[0010]
In the above-described invention, in a more preferred second embodiment, when the branch direction of the branch instruction is uncertain, the cache control unit determines that the branch instruction direction of the branch instruction is on the sequential side and the instruction on the target side When a cache miss occurs, instruction fetch is stopped without performing memory bus access. In other cases, the cache control unit performs an instruction fetch by performing a memory bus access. Therefore, unlike the first embodiment, in the second embodiment, when a branch prediction direction is on the target side and a cache miss occurs with respect to a sequential instruction, instruction fetch is performed by memory bus access. This is because the instruction fetch on the sequential side has a low probability of cache miss, and there is little need to prohibit memory bus access in such a low frequency case.
[0011]
In order to achieve the above object, another aspect of the present invention provides an instruction fetch unit for fetching both a sequential side and a target side instruction sequence of a branch instruction, and a cache in response to a fetch request from the instruction fetch unit. In an information processing apparatus having a cache control unit that fetches an instruction from a memory or a main memory, a memory bus access unit that accesses the main memory, and an instruction buffer that holds the fetched instruction.
A branch prediction unit that performs branch prediction of a branch instruction stored in the instruction buffer prior to execution of the branch instruction, and the cache control unit performs a cache miss when a branch direction of the branch instruction is uncertain. Then, the instruction fetch is stopped without performing the memory bus access, and when the branch instruction is confirmed, the memory bus access is performed when a cache miss occurs with respect to the instruction in the confirmed branch direction.
[0012]
According to the above invention, the memory bus access after the cache miss is performed only for the instruction in the branch direction after the branch is confirmed, and the memory bus traffic can be reduced. In other words, since it is unclear whether or not the branch is used at the stage where the branch is not yet determined, memory bus access after a cache miss is completely prohibited. Further, the instruction on the target side when the branch is unconfirmed is prefetched into the instruction buffer within the range stored in the cache memory.
[0013]
DETAILED DESCRIPTION OF THE INVENTION
Embodiments of the present invention will be described below with reference to the drawings. However, such an embodiment does not limit the technical scope of the present invention.
[0014]
FIG. 1 is a system diagram of an information processing apparatus according to an embodiment of the present invention. The information processing apparatus shown in FIG. 1 is a microprocessor, and includes a
[0015]
The
[0016]
The instruction decoded by the instruction decoder is executed by the
[0017]
The instruction fetch
[0018]
The
[0019]
When each
[0020]
The memory
[0021]
In response to the fetch request signal S20, the
[0022]
The information processing apparatus in FIG. 1 includes
[0023]
The information processing apparatus shown in FIG. 1 is a dual instruction fetch method, fetches both a sequential instruction string and a target instruction string of an instruction string and stores them in
[0024]
Further, the information processing apparatus shown in FIG. 1 performs branch prediction of the instructions fetched by the
[0025]
In general, the
[0026]
However, the data bus in the
[0027]
As will be described later, the
[0028]
In the first embodiment, for instructions that are not in the branch prediction direction, the instruction fetch is stopped without performing the memory bus access after the cache miss. In the case of an instruction that is not in the branch prediction direction, there is a high possibility that the instruction fetch will be wasted when the branch instruction is determined thereafter. Therefore, it is more efficient not to perform memory bus access to such an instruction. However, for the instruction in the branch prediction direction, the memory bus is accessed after a cache miss.
[0029]
In the second embodiment, when the branch prediction direction is the sequential side and a cache miss occurs with respect to the instruction on the target side, the instruction fetch is stopped without performing the memory bus access. However, if the branch prediction direction is the target side and a cache miss occurs for an instruction on the sequential side, even if the instruction is on the side different from the branch prediction direction, the memory bus is accessed and the instruction fetch is completed Let The reason for this is that when a memory bus is accessed due to a cache miss, instructions at addresses consecutive to that instruction are fetched to the
[0030]
As a third embodiment, while the branch instruction is not confirmed, only the cache hit instruction is stored in the instruction buffer, and when the cache miss occurs, the instruction fetch is stopped without performing the memory bus access and the branch instruction is confirmed. In
[0031]
FIG. 2 is a block diagram of the cache control unit. As described above, the fetch request S20B is supplied from the
[0032]
The bus access
[0033]
If it is determined in the above determination that the memory bus access is necessary, the bus
[0034]
When data is returned from the
[0035]
The instruction fetched from the main memory is stored in the cache memory and also in the instruction buffer via the cache control unit.
[0036]
The algorithm that does not perform memory bus access in the first, second, and third embodiments will be described below.
[0037]
FIG. 3 is a chart showing an instruction fetch operation in the first embodiment. The instruction fetch operation will be described with reference to the chart. In the first embodiment,
(1) If the branch direction of the branch instruction is not fixed,
(1-1) When the branch prediction direction by the branch prediction unit is the target side, first, when the instruction fetch on the sequential side causes an instruction cache miss, the instruction fetch is stopped without accessing the memory bus, Do not access the memory bus. Second, in the instruction fetch on the target side, when an instruction cache miss occurs, the memory bus is accessed to complete the instruction fetch.
(1-2) If the branch prediction direction in the branch instruction execution is the sequential side, first, the instruction fetch on the target side stops the instruction fetch without accessing the memory bus if an instruction cache miss occurs Do not access the memory bus. Second, in the sequential instruction fetch, when an instruction cache miss occurs, the memory bus is accessed to complete the instruction fetch.
(2) If the branch direction of the branch instruction is fixed,
Instruction fetch is performed only on the side where the branch direction is determined (sequential side or target side). In that case, if a cache miss occurs, the memory bus is accessed to complete the instruction fetch.
[0038]
As described above, in the first embodiment, while the branch direction is uncertain, only the instruction fetch in the branch prediction direction is permitted to perform a memory bus access after a cache miss, and the instruction fetch is not in the branch prediction direction. The memory bus access after a cache miss is prohibited, and the memory bus access for instruction fetch that is likely to be wasted is not performed. In any case, when a cache hit occurs, the instruction fetched by the cache hit is stored in the instruction buffer, and the instruction fetch is completed.
[0039]
Further, the
Fetch the necessary instructions. At that time, the instruction sequence continuous with the instruction is also stored in the
[0040]
FIG. 4 is a chart showing an instruction fetch operation in the second embodiment which is an improvement of the first embodiment. The instruction fetch operation will be described with reference to the chart. In the second embodiment,
(1) If the branch direction of the branch instruction is not fixed,
(1-1) When the branch prediction direction of the branch prediction unit is the target side, first, when an instruction cache miss occurs in the sequential instruction fetch, the memory bus is accessed and the instruction fetch is completed. Second, in the instruction fetch on the target side, when an instruction cache miss occurs, the memory bus is accessed to complete the instruction fetch.
(1-2) If the branch prediction direction in the branch instruction execution is the sequential side, first, the instruction fetch on the target side stops the instruction fetch without accessing the memory bus if an instruction cache miss occurs Do not access the memory bus. Second, in the sequential instruction fetch, when an instruction cache miss occurs, the memory bus is accessed to complete the instruction fetch.
(2) If the branch direction of the branch instruction is fixed,
Instruction fetch is performed only on the side where the branch direction is determined (sequential side or target side). In that case, if a cache miss occurs, the memory bus is accessed to complete the instruction fetch.
[0041]
The second embodiment differs from the first embodiment in that when the branch prediction direction is the target side and a cache miss occurs with respect to the instruction fetch on the sequential side, the instruction on the side different from the branch prediction direction However, the instruction is to complete the instruction fetch by accessing the memory bus. Such a case is very unlikely and therefore is less frequent, so allowing memory bus access does not increase memory bus traffic.
[0042]
FIG. 5 is a table showing an instruction fetch operation in the third embodiment. The instruction fetch operation will be described with reference to the chart. In the third embodiment,
(1) If the branch direction of the branch instruction is not fixed,
(1-1) When the branch prediction direction of the branch prediction unit is the target side, first, when the instruction fetch on the sequential side causes an instruction cache miss, the instruction fetch is stopped without accessing the memory bus, Do not access the memory bus. Second, in the case of instruction fetch on the target side, if an instruction cache miss occurs, the instruction fetch is stopped and the memory bus is not accessed without accessing the memory bus.
(1-2) When the branch prediction direction of the branch prediction unit is the sequential side, first, when the instruction fetch on the target side causes an instruction cache miss, the instruction fetch is stopped without accessing the memory bus, Do not access the memory bus. Secondly, the instruction fetch on the sequential side also stops the instruction fetch and does not access the memory bus without accessing the memory bus if an instruction cache miss occurs.
(2) If the branch direction is fixed,
Instruction fetch is performed only on the side where the branch direction is determined (sequential side or target side). In this case, even if a cache miss occurs, the memory bus is accessed and an instruction is fetched from the main memory to complete the instruction fetch.
[0043]
The third embodiment prohibits any memory bus access while the branch instruction is not executed and the branch is uncertain, and permits the memory bus access only for the instruction whose branch direction is determined. If the branch has not been determined, instruction fetch by memory bus access may be wasted, so that memory bus access is prohibited to reduce memory bus traffic. Since the branch-fixed instruction is stored in advance in the cache memory, the cache miss itself does not occur with a very high probability. Therefore, even if only prefetching is performed by fetching instructions from the cache memory and both the sequence side and target side instruction sequences are stored in the instruction decoder, the instructions can be executed without significantly disturbing the entire pipeline operation. Is possible.
[0044]
Finally, as a fourth embodiment, a method for reducing memory bus accesses other than those described above will be described. FIG. 6 is a table showing instruction fetch operations in the fourth embodiment. The instruction fetch operation will be described with reference to the chart. In the fourth embodiment, (1) when the branch direction of the branch instruction is not fixed
(1-1) When the branch prediction direction in the branch prediction unit is the target side, the instruction fetch on the sequential side stops the instruction fetch without accessing the memory bus if an instruction cache miss occurs, and accesses the memory bus Do not do. On the other hand, in the instruction fetch on the target side, when an instruction cache miss occurs, the memory bus is accessed to complete the instruction fetch.
(1-2) When the branch prediction direction in the branch prediction unit is the sequential side, first, the instruction fetch on the target side accesses the memory bus when an instruction cache miss occurs and completes the instruction fetch. Second, when an instruction cache miss occurs in the sequential side instruction, the memory bus is accessed to complete the instruction fetch.
(2) When the branch direction of the branch instruction is fixed
Instruction fetch is performed only on the side where the branch direction is determined (sequential side or target side). In this case, the instruction fetch that performed the memory bus access to the cache miss is completed.
[0045]
In the case of the fourth embodiment, when the branch instruction has not been determined, at least the branch prediction direction is the target side, and the memory bus access is not performed if a cache miss occurs in the instruction fetch on the sequential side. As a result, the number of memory bus accesses can be reduced accordingly.
[0046]
Similar to the fourth embodiment, even if the memory bus access is prohibited for an arbitrary instruction fetch when the branch is not yet determined, the number of memory bus accesses can be reduced by that amount. However, there are cases where instruction prefetching in the direction predicted to branch cannot be performed. It is desirable to set in consideration of the balance between memory bus access prohibition and instruction prefetch failure.
[0047]
Of the above four embodiments, the operation of the second embodiment that balances the prohibition of memory bus access and the failure of instruction prefetch to some extent will be described with reference to FIG. As a premise, it is assumed that the instruction fetch on the sequential side is performed on the
(1) When the branch direction of the branch instruction is not fixed,
(1-1) When the branch prediction direction in the
[0048]
If an instruction cache miss occurs in the
[0049]
Since the frequency of cache misses for sequential instruction fetches is not so high, even if memory bus access is permitted in this case, the efficiency of the entire memory bus is not reduced much.
[0050]
In the instruction fetch on the target side, an instruction fetch request is supplied from the instruction fetch
[0051]
When an instruction cache miss occurs in the
[0052]
In this case, since the instruction in the branch prediction direction having a high use probability has a cache miss, allowing the memory bus access and completing the prefetch prevents the pipeline operation after the branch from being disturbed. .
(1-2) If the branch prediction direction in the branch prediction unit is the sequential side, the instruction fetch on the target side is sent from the instruction fetch
[0053]
Even if an instruction cache miss occurs in the
[0054]
On the other hand, in the instruction fetch on the sequential side, an instruction fetch request is issued from the instruction fetch
[0055]
If an instruction cache miss occurs in the
(2) When the branch direction is fixed by executing a branch instruction
The instruction fetch
[0056]
When the branch decision direction is the target side, the instruction fetch
[0057]
FIG. 7 is a chart showing a specific pipeline operation when memory bus access is restricted by the first or second embodiment. This example shows the pipeline operation by taking the sequential instruction sequences 01 to 09 and the
[0058]
Pipeline operations consist of the following stages.
P: Instruction fetch request stage: The CPU issues an instruction fetch request to the cache control unit. At this stage, an instruction fetch request is made with a distinction between prefetch with branch unconfirmed and fetch after branch confirmation.
T: Fetch stage: A hit miss determination is made in the cache memory and preparations for fetching an instruction are made.
C: Instruction buffer stage: An instruction is fetched into the instruction buffer.
D: Decode stage: The instruction decoder decodes the instruction and generates a control signal.
E: Execution stage: An instruction is executed in response to the control signal of the decoding result.
W: Write stage: The result of executing the instruction is written to the register.
M: Cache miss: A cache miss occurred.
B: Bus access holding stage: An address is held in the bus access address holding unit for accessing the memory bus.
R: Bus access request stage: A read request is issued to the memory bus access unit. Assume that 18 cycles are required until an instruction is read by bus access.
[0059]
Referring back to FIG. 7, the instruction 01 can fetch an instruction from the cache memory by the instruction fetch request stage P in
[0060]
The
[0061]
The
[0062]
For the
[0063]
The
[0064]
As the
[0065]
On the other hand, the
[0066]
Since the
[0067]
The example of FIG. 7 operates similarly in both the first embodiment and the second embodiment. That is, even if a cache miss occurs for the prefetch of the
[0068]
In the case of the third embodiment, the memory bus access after a cache miss is prohibited with respect to the prefetch of the
[0069]
FIG. 8 is a chart showing a specific pipeline operation when the memory bus access of the conventional example is not restricted. This example also shows the pipeline operation for the same instruction sequence as in FIG.
[0070]
In this example,
[0071]
As described above, compared to the conventional example, in this embodiment, the memory bus access at the stage where the branch is not yet determined is limited. Therefore, the memory bus access can be efficiently performed for the highly usable instruction. Pipeline cycle disturbance can be minimized.
[0072]
As described above, the protection scope of the present invention is not limited to the above-described embodiment, but extends to the invention described in the claims and equivalents thereof.
[0073]
【The invention's effect】
As described above, according to the present invention, the access to the main memory at the time of a cache miss is appropriately restricted with respect to the instruction fetch when the branch is unconfirmed, so the main memory for the instruction in the branch prediction direction and the instruction after the branch is confirmed Can be accessed more efficiently.
[Brief description of the drawings]
FIG. 1 is a system diagram of an information processing apparatus according to an embodiment of the present invention.
FIG. 2 is a block diagram of a cache control unit.
FIG. 3 is a chart showing an instruction fetch operation in the first embodiment.
FIG. 4 is a chart showing an instruction fetch operation in the second embodiment.
FIG. 5 is a chart showing an instruction fetch operation in the third embodiment;
FIG. 6 is a chart showing an instruction fetch operation in the fourth embodiment.
FIG. 7 is a chart showing a specific pipeline operation when memory bus access is restricted according to the first or second embodiment;
FIG. 8 is a chart showing a specific pipeline operation in the case of a conventional example.
[Explanation of symbols]
40 CPU
410,411 Instruction fetch section
430,431 Branch prediction unit
50 cache memory unit
52 cache memory
54, 56 Cache control unit
60 Memory bus access section
62 Memory bus
64 Main memory
Claims (5)
前記命令バッファに格納される分岐命令の分岐予測を分岐命令の実行に先行して行う分岐予測部を有し、
前記分岐命令の分岐方向が未確定の場合に、前記キャッシュ制御部は、キャッシュメモリから命令フェッチを行い、前記分岐命令の分岐予測方向の命令についてキャッシュミスを起こした場合は、前記メインメモリへのメモリバスアクセスを行って命令フェッチを行い、分岐予測方向ではない命令についてキャッシュミスを起こした場合は、メモリバスアクセスを行わないで命令フェッチを中止することを特徴とする情報処理装置。 An instruction fetch unit that fetches both sequential and target instruction sequences of a branch instruction; a cache control unit that fetches an instruction from a cache memory or a main memory in response to a fetch request from the instruction fetch unit; and the main In an information processing apparatus having a memory bus access unit for accessing a memory and an instruction buffer for holding the fetched instruction,
A branch prediction unit that performs branch prediction of a branch instruction stored in the instruction buffer prior to execution of the branch instruction;
When the branch direction of the branch instruction is uncertain, the cache control unit fetches an instruction from the cache memory, and when a cache miss occurs for an instruction in the branch prediction direction of the branch instruction, An information processing apparatus that performs an instruction fetch by performing a memory bus access, and stops an instruction fetch without performing a memory bus access when a cache miss occurs for an instruction that is not in a branch prediction direction.
前記命令バッファに格納される分岐命令の分岐予測を分岐命令の実行に先行して行う分岐予測部を有し、
前記分岐命令の分岐方向が未確定の場合に、前記キャッシュ制御部は、キャッシュメモリから命令フェッチを行い、前記分岐命令の分岐予測方向がシーケンシャル側にある場合で、ターゲット側の命令についてキャッシュミスを起こした場合は、メモリバスアクセスを行わないで命令フェッチを中止することを特徴とする情報処理装置。 An instruction fetch unit that fetches both sequential and target instruction sequences of a branch instruction; a cache control unit that fetches an instruction from a cache memory or a main memory in response to a fetch request from the instruction fetch unit; and the main In an information processing apparatus having a memory bus access unit for accessing a memory and an instruction buffer for holding the fetched instruction,
A branch prediction unit that performs branch prediction of a branch instruction stored in the instruction buffer prior to execution of the branch instruction;
When the branch direction of the branch instruction is uncertain, the cache control unit fetches an instruction from the cache memory, and when the branch instruction prediction direction of the branch instruction is on the sequential side, a cache miss is performed on the instruction on the target side. An information processing apparatus characterized in that when it happens, instruction fetch is stopped without performing memory bus access.
前記キャッシュ制御部は、前記分岐命令が確定している場合に、当該確定した分岐方向の命令についてキャッシュミスした命令のメモリバスアクセスを行うことを特徴とする情報処理装置。 In claim 1 or 2,
The cache control unit, when the branch instruction is confirmed, performs a memory bus access of a cache missed instruction for the instruction in the confirmed branch direction.
Priority Applications (4)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP34101499A JP4111645B2 (en) | 1999-11-30 | 1999-11-30 | Memory bus access control method after cache miss |
| US09/666,853 US7134004B1 (en) | 1999-09-29 | 2000-09-20 | Processing device for buffering sequential and target sequences and target address information for multiple branch instructions |
| KR1020000056979A KR100719420B1 (en) | 1999-09-29 | 2000-09-28 | Information processing device |
| US11/444,221 US20060224870A1 (en) | 1999-09-29 | 2006-05-31 | Information processing device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP34101499A JP4111645B2 (en) | 1999-11-30 | 1999-11-30 | Memory bus access control method after cache miss |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JP2001154845A JP2001154845A (en) | 2001-06-08 |
| JP4111645B2 true JP4111645B2 (en) | 2008-07-02 |
Family
ID=18342425
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP34101499A Expired - Fee Related JP4111645B2 (en) | 1999-09-29 | 1999-11-30 | Memory bus access control method after cache miss |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP4111645B2 (en) |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7587580B2 (en) * | 2005-02-03 | 2009-09-08 | Qualcomm Corporated | Power efficient instruction prefetch mechanism |
| WO2008029450A1 (en) * | 2006-09-05 | 2008-03-13 | Fujitsu Limited | Information processing device having branching prediction mistake recovery mechanism |
| JP2011028540A (en) * | 2009-07-27 | 2011-02-10 | Renesas Electronics Corp | Information processing system, method for controlling cache memory, program and compiler |
-
1999
- 1999-11-30 JP JP34101499A patent/JP4111645B2/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| JP2001154845A (en) | 2001-06-08 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP4417715B2 (en) | Method and apparatus for decoupling tag and data access in cache memory | |
| JPH10232827A (en) | Method and device for writing back prefetch cache | |
| JPH06318177A (en) | Method, apparatus and computer system for reducing cache miss penalty | |
| US5515521A (en) | Circuit and method for reducing delays associated with contention interference between code fetches and operand accesses of a microprocessor | |
| US6912650B2 (en) | Pre-prefetching target of following branch instruction based on past history | |
| JP2596712B2 (en) | System and method for managing execution of instructions, including adjacent branch instructions | |
| JP4173858B2 (en) | Instruction cache and method for reducing memory contention | |
| US7111127B2 (en) | System for supporting unlimited consecutive data stores into a cache memory | |
| JP2004145454A (en) | Information processing apparatus and information processing method | |
| US7134004B1 (en) | Processing device for buffering sequential and target sequences and target address information for multiple branch instructions | |
| JP4111645B2 (en) | Memory bus access control method after cache miss | |
| US20020188817A1 (en) | Store buffer pipeline | |
| JP3741945B2 (en) | Instruction fetch control device | |
| JPH0477344B2 (en) | ||
| JPH04369061A (en) | Cache memory control method | |
| JP3284508B2 (en) | Data prefetch control device | |
| JP3039391B2 (en) | Memory system | |
| JP4049490B2 (en) | Information processing device | |
| JPH02236651A (en) | Memory buffer | |
| JP3476314B2 (en) | Microprocessor | |
| JP3761890B2 (en) | Cache memory device | |
| JPH0760387B2 (en) | Information processing equipment | |
| JPH08286914A (en) | Memory controller | |
| JPH027128A (en) | information processing equipment | |
| JPH01193938A (en) | Instruction pre-reader |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20061004 |
|
| A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20070305 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20070417 |
|
| A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20070615 |
|
| A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20080108 |
|
| A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20080206 |
|
| A911 | Transfer of reconsideration by examiner before appeal (zenchi) |
Free format text: JAPANESE INTERMEDIATE CODE: A911 Effective date: 20080313 |
|
| 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: 20080408 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20080408 |
|
| 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: 20110418 Year of fee payment: 3 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110418 Year of fee payment: 3 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120418 Year of fee payment: 4 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20130418 Year of fee payment: 5 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20140418 Year of fee payment: 6 |
|
| LAPS | Cancellation because of no payment of annual fees |