0

連続する R-Type 命令が危険を引き起こす可能性があることを知っています。たとえば、次のようになります。

add $2, $2, $1
add $2, $2, $3

しかし、連続した I-Type 命令は使用できますか? 例えば:

addi $2, $0, 10
addi $2, $0, 5
4

1 に答える 1

2

あなたのケースを考えると:

addi $2, $0, 10 
addi $2, $0, 5

値が書き込まれた後に値を読み取ることはないため (書き込み後の読み取り)、データ ハザードに遭遇することはありません。

たぶん、次のように考えてください。

$2 = $0 + 10
$2 = $0 + 5

$2 が 2 番目の計算で使用されておらず、$0 が変更されていないことがわかります。したがって、データ ハザードはありません。

これを行う場合:

addi $2, $0, 10 # $2 = $0 + 10
addi $3, $2, 5  # $3 = $2 + 5

パイプライン処理では、2 回目の計算で読み取られたときに $2 が期待値であることは保証されません。

lw と sw も I タイプの命令であると考えてください。

RAW
    A Read After Write hazard occurs when, in the code as written, one instruction
    reads a location after an earlier instruction writes new data to it, but in the
     pipeline the write occurs after the read (so the instruction doing the read gets stale data).
WAR
    A Write After Read hazard is the reverse of a RAW: in the code a write occurs after a read,
     but the pipeline causes write to happen first.
WAW
    A Write After Write hazard is a situation in which two writes occur out of order. We normally
    only consider it a WAW hazard when there is no read in between; if there is, then we have a RAW
    and/or WAR hazard to resolve, and by the time we've gotten that straightened out the WAW has 
    likely taken care of itself.

http://www.cs.nmsu.edu/~pfeiffer/classes/473/notes/hazards.html

データの読み取りと書き込みの操作が I タイプの命令であり、これらの潜在的なデータ ハザードの定義を考えると、はい、I タイプの命令は依然としてハザードを持つ可能性があります。

于 2012-10-27T09:48:46.257 に答える