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

cpu.v (2.Instruction Decode)

task instructionDecode;

begin

nextState <= Execute;

dataReg<=DM[dRA];

case (ir[23:20])

`ADD : alucmd <= 4'h0;

`ADC : alucmd <= 4'h1;

`SUB : alucmd <= 4'h2;

`SUC : alucmd <= 4'h3;

`AND : alucmd <= 4'h4;

`OR : alucmd <= 4'h5;

`XOR : alucmd <= 4'h6;

`NOT : alucmd <= 4'h7;

`LD : alucmd <= 4'h8;

default : alucmd <= 4'hf;

endcase

case (ir[23:20])

`ADC , `SUC : csel <= 1'b1;

default : csel <= 1'b0;

endcase

pc <= nextpc;

end

endtask

LD命令、演算命令

ALUコマンドを設定

キャリーを含む演算ではalucにキャリーを入力

pcを更新

pcはつぎに実行する命令が格納されたアドレスを示す

DataMemoryから値を取得

 dRAはアドレシングモードにより決定

(組合せ論理回路)

ステートマシン

つぎの状態

nextpcはpc,ir,flagから決定(組合せ論理回路)

/* instructionSet.h */

`define ADD 4'b0000

`define ADC 4'b0001

`define SUB 4'b0010

`define SUC 4'b0011

`define AND 4'b0100

`define OR 4'b0101

`define XOR 4'b0110

`define NOT 4'b0111

`define LD 4'b1000

`define B 4'b1011

`define FIN 4'b1111

2進数でも16進数でもよい