我有一个迷你项目,在这个项目中,我需要通过Verilog实现MIPS单周期处理器.在这里我写ALU和ALUControl和FileRegister,但我有一个问题,为此实现Pc(程序计数器)...我想要这个Pc支持分支和跳转.我需要支持分支的说明,但我不知道如何访问指令.请帮我实现InstructionMemory和Pc.这是我的代码:
module ALU(ALUctl, A, B, ALUOut, Zero);
input [3:0] ALUctl;
input [31:0] A,B;
output reg [31:0] ALUOut;
output Zero;
assign Zero = (ALUOut==0); //Zero is true if ALUOut is 0
always @(ALUctl, A, B) begin //reevaluate if these change
case (ALUctl)
0: ALUOut <= A & B;
1: ALUOut <= A | B;
2: ALUOut <= A + B;
6: ALUOut <= A - B;
7: ALUOut <= A < B ? 1 : 0;
12: ALUOut <= ~(A | …Run Code Online (Sandbox Code Playgroud) 我无法理解这段代码末尾的两行
input [15:0] offset ;
output [31:0] pc;
output [31:0] pc_plus_4;
reg [31:0] pc;
wire [31:0] pcinc ;
assign pcinc = pc +4 ;
assign pc_plus_4 = {pc[31],pcinc};
assign branch_aadr = {0,pcinc + {{13{offset[15]}},offset[15:0],2'b00}};
Run Code Online (Sandbox Code Playgroud)