最初のページ 戻る 次へ 最後のページ

cpu.v (ステートマシン)

reg [1:0] currentState,nextState;

・・・

/* CPUをステートマシンとして駆動 */

always @(posedge clock)

if (reset) begin currentState<=nextState; end

always @(currentState) begin

case (currentState)

InstructionFetch : instructionFetch;

InstructionDecode : instructionDecode;

Execute : execute;

WriteBack : writeBack;

default : resetAction;

endcase

end

クロック(立ち上がり)とき・・・

reset=1のときは状態遷移

現在の状態currentStateを更新

currentStateが変化したとき・・・

現在の状態

処理

InstructionFetch

「instructionFetch」を実行

InstructionDecode

「instructionDecode」を実行

Execute

「execute」を実行

WriteBack

「writeBack」を実行

default

「resetAction」を実行

最初はcurrentStateが未定(xx)

上の方で宣言