decoder.v

来自「MIPS CPU tested in Icarus Verilog」· Verilog 代码 · 共 684 行 · 第 1/3 页

V
684
字号
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b0; // With 0 the Mux selects Output B from RegFile
		       ALUOP = S_SUBU; //Special SUBU Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b0; //SrcA = I[25-21]
		    end // case: S_SUBU

		    S_AND: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b0; // With 0 the Mux selects Output B from RegFile
		       ALUOP = S_AND; //Special AND Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b0; //SrcA = I[25-21]
		    end // case: S_AND

		    S_OR: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b0; // With 0 the Mux selects Output B from RegFile
		       ALUOP = S_OR; //Special OR Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b0; //SrcA = I[25-21]
		    end // case: S_OR

		    S_NOR: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b0; // With 0 the Mux selects Output B from RegFile
		       ALUOP = S_NOR; //Special NOR Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b0; //SrcA = I[25-21]
		    end // case: S_NOR

		    S_XOR: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b0; // With 0 the Mux selects Output B from RegFile
		       ALUOP = S_XOR; //XOR Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b0; //SrcA = I[25-21]
		    end // case: S_XOR

		    S_SLL: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b1; // With 1 the Mux selects the output of EXT-32
		       ALUOP = S_SLL; //Special SLL Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b1; //SrcA = I[20-16]
		    end // case: S_SLL

		    S_SLLV: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b0; // With 0 the Mux selects output B from RegFile
		       ALUOP = S_SLLV; //Special SLLV Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b0; //SrcA = I[25-21]
		    end // case: S_SLLV

		    S_SRA: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b1; // With 1 the Mux selects the output of EXT-32
		       ALUOP = S_SRA; //Special SRA Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b1; //SrcA = I[20-16]
		    end // case: S_SRA

		    S_SRAV: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b0; // With 0 the Mux selects output B from RegFile
		       ALUOP = S_SRAV; //Special SRAV Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b0; //SrcA = I[25-21]
		    end // case: S_SRAV

		    S_SRL: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b1; // With 1 the Mux selects the output of EXT-32
		       ALUOP = S_SRL; //Special SRL Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b1; //SrcA = I[20-16]
		    end // case: S_SRL

		    S_SRLV: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b0; // With 0 the Mux selects output B from RegFile
		       ALUOP = S_SRLV; //Special SRLV Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b0; //SrcA = I[25-21]
		    end // case: S_SRLV

		    S_MULT: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b0; // With 0 the Mux selects Output B from RegFile
		       ALUOP = S_MULT; //Special MULT Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b0; //SrcA = I[25-21]
		    end // case: S_MULT

		    S_MULTU: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b0; // With 0 the Mux selects Output B from RegFile
		       ALUOP = S_MULTU; //Special MULTU Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b0; //SrcA = I[25-21]
		    end // case: S_MULTU

		    S_DIV: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b0; // With 0 the Mux selects Output B from RegFile
		       ALUOP = S_DIV; //Special DIV Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b0; //SrcA = I[25-21]
		    end // case: S_DIV

		    S_DIVU: begin
		       Branch = 1'b0; //With 0, the PC is incremented in 1
		       Jump = 1'b0; //So that PC gets incremented in 1
		       Write_RF = 1'b1; //With 1 we write to the register file
		       Src2 = 1'b0; // With 0 the Mux selects Output B from RegFile
		       ALUOP = S_DIVU; //Special DIVU Opcode
		       RegDest = 2'b01; // With 1, the Mux selects Rd
		       Memory_Read = 1'b0; //Doesn't read from memory
		       Memory_Write = 1'b0; //Doesn't write to memory
		       Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		       IntFP = 1'b0; //Select the ALU unit
		       ArSh = 1'b0; //SrcA = I[25-21]
		    end // case: S_DIVU
		  endcase // case(Instruction[5:0])
	       end // case: 6'b000000

	       default: begin
		  Branch = 1'b0; //With 0, the PC is incremented in 1
		  Jump = 1'b0; //So that PC gets incremented in 1
		  Write_RF = 1'b0; //With 0 we don't write to the register file
		  Src2 = 1'b0; // With 0 the Mux selects Output B from RegFile
		  ALUOP = NOP; //No Operation Opcode
		  RegDest = 2'b00; // Doesn't matter
		  Memory_Read = 1'b0; //Doesn't read from memory
		  Memory_Write = 1'b0; //Doesn't write to memory
		  Mem2Reg = 3'b000; //With 0 the Mux selects the output from the ALU
		  IntFP = 1'b0; //Select the ALU unit
		  ArSh = 1'b0; //SrcA = I[25-21]
	       end // case: default
	     endcase // case(Instruction[InstWidth-1:InstWidth-6])
	  end // else: !if(Reset == 1)
     end // always @ (posedge Clock)
endmodule // decoder

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?