这是一个课程项目,我有点陷入这一部分。根据我的教练提供的模型,处理器的PC部分看起来非常棘手且不清楚。当我进行模拟时,处理指令时我的PC地址设置为0。这是代码,我希望有人可以告诉我哪个部分我错了,为什么:
module Ifetc32(Instruction,PC_plus_4_out,Add_result,Read_data_1,Branch,nBranch,Jmp,Jal,Jrn,Zero,clock,reset,opcplus4);
output[31:0] Instruction;
output[31:0] PC_plus_4_out;
input[31:0] Add_result;
input[31:0] Read_data_1;
input Branch;
input nBranch;
input Jmp;
input Jal;
input Jrn;
input Zero;
input clock,reset;
output[31:0] opcplus4; // JAL PC+4
wire[31:0] PC_plus_4;
reg[31:0] PC;
reg[31:0] next_PC;
reg[31:0] opcplus4;
assign PC_plus_4[31:2] = PC[31:2]+1'b1;
assign PC_plus_4[1:0] = PC[1:0];
assign PC_plus_4_out = PC_plus_4;
always @* begin // beq $n ,$m if $n=$m branch bne if $n !=$m branch jr
next_PC=PC;
if(Branch==1'b1)
begin
if(Zero==1'b1)
begin
next_PC=PC+Add_result;
end
end
else if(nBranch==1'b1)
begin
if(Zero==1'b1)
begin
next_PC=PC+Add_result;
end
end
else if(Jrn==1'b1)
begin
next_PC=Read_data_1-4;
end
end
always @(negedge clock) begin //(J,Jal and reset)
if(reset==1'b1)
begin
opcplus4={32{1'b0}};
PC={32{1'b0}};
end
else
begin
if(Jmp==1'b1)
begin
next_PC={PC[31:28],Instruction[25:0],2'b00};
end
else if(Jal==1'b1)
begin
opcplus4=PC+4;
next_PC={PC[31:28],Instruction[25:0],2'b00};
end
else
next_PC=next_PC+4;
PC=next_PC;
end
end
endmodule