⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 decoder.v

📁 MIPS CPU tested in Icarus Verilog
💻 V
📖 第 1 页 / 共 3 页
字号:
		  RegDest = 2'b00; // With 0, the Mux selects Rt
		  Memory_Read = 1'b1; //Reads from memory
		  Memory_Write = 1'b0; //Doesn't write to memory
		  Mem2Reg = 3'b101; //With 5 the Mux selects the output from the memory
		  IntFP = 1'b0; //Select the ALU unit
		  ArSh = 1'b0; //SrcA = I[25-21]
	       end // case: LW

	       // ################ Store Operations ################
	       SB: 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'b1; // With 1 the Mux selects the Offset
		  ALUOP = S_ADD; //SB Opcode (ALU Output = Immediate Num extended to 32)
		  RegDest = 2'b00; // With 0, the Mux selects Rt
		  Memory_Read = 1'b0; //Doesn't read from memory
		  Memory_Write = 1'b1; //Writes to memory
		  Mem2Reg = 3'b101; //With 5 the Mux selects the output from the memory
		  IntFP = 1'b0; //Select the ALU unit
		  ArSh = 1'b0; //SrcA = I[25-21]
	       end // case: SB

	       SH: 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'b1; // With 1 the Mux selects the Offset
		  ALUOP = SH; //SB Opcode (ALU Output = Immediate Num extended to 32)
		  RegDest = 2'b00; // With 0, the Mux selects Rt
		  Memory_Read = 1'b0; //Doesn't read from memory
		  Memory_Write = 1'b1; //Writes to memory
		  Mem2Reg = 3'b101; //With 5 the Mux selects the output from the memory
		  IntFP = 1'b0; //Select the ALU unit
		  ArSh = 1'b0; //SrcA = I[25-21]
	       end // case: SH

	       SW: 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'b1; // With 1 the Mux selects the Offset
		  ALUOP = SB; //SB Opcode (ALU Output = Immediate Num extended to 32)
		  RegDest = 2'b00; // With 0, the Mux selects Rt
		  Memory_Read = 1'b0; //Doesn't read from memory
		  Memory_Write = 1'b1; //Writes to memory
		  Mem2Reg = 3'b101; //With 5 the Mux selects the output from the memory
		  IntFP = 1'b0; //Select the ALU unit
		  ArSh = 1'b0; //SrcA = I[25-21]
	       end // case: SW

	       // ################ Jump & Branch Operations ################
	       J: begin
		  Branch = 1'b0; //With 0, the PC is incremented in 1
		  Jump = 1'b1; //Jump to target
		  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; //J Opcode
		  RegDest = 2'b00; // With 0, the Mux selects Rt
		  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: J

	       BEQ: begin
		  Branch = 1'b1; //It is branch
		  Jump = 1'b0; //So jump mux selects branch
		  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 = S_XOR; //BEQ Opcode
		  RegDest = 2'b00; // With 0, the Mux selects Rt
		  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: BEQ

	       BNE: begin
		  Branch = 1'b1; //Branch
		  Jump = 1'b0; //So that jump mux selects it
		  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 = S_AND; //BNE Opcode
		  RegDest = 2'b00; // With 0, the Mux selects Rt
		  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: BNE

	       6'b010001: begin
		  case(Instruction[5:0])
		    C_ABS_fmt: 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 = C_ABS_fmt; //COP ABS Opcode
		       RegDest = 2'b10; // With 2, the Mux selects fd
		       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 FPU
		       IntFP = 1'b1; //Select the FPU unit
		       ArSh = 1'b0; //SrcA = I[15-11]
		    end // case: C_ABS_fmt

		    C_ADD_fmt: 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 = C_ADD_fmt; //COP ADD Opcode
		       RegDest = 2'b10; // With 2, the Mux selects fd
		       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 FPU
		       IntFP = 1'b1; //Select the FPU unit
		       ArSh = 1'b0; //SrcA = I[15-11]
		    end // case: C_ADD_fmt

		    C_DIV_fmt: 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 = C_DIV_fmt; //COP DIV Opcode
		       RegDest = 2'b10; // With 2, the Mux selects fd
		       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 FPU
		       IntFP = 1'b1; //Select the FPU unit
		       ArSh = 1'b0; //SrcA = I[15-11]
		    end // case: C_DIV_fmt

		    C_MUL_fmt: 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 = C_MUL_fmt; //COP MUL Opcode
		       RegDest = 2'b10; // With 2, the Mux selects fd
		       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 FPU
		       IntFP = 1'b1; //Select the FPU unit
		       ArSh = 1'b0; //SrcA = I[15-11]
		    end // case: C_MUL_fmt

		    C_NEG_fmt: 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 = C_NEG_fmt; //COP NEG Opcode
		       RegDest = 2'b10; // With 2, the Mux selects fd
		       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 FPU
		       IntFP = 1'b1; //Select the FPU unit
		       ArSh = 1'b0; //SrcA = I[15-11]
		    end // case: C_NEG_fmt

		    C_SUB_fmt: 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 = C_SUB_fmt; //COP SUB Opcode
		       RegDest = 2'b10; // With 2, the Mux selects fd
		       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 FPU
		       IntFP = 1'b1; //Select the FPU unit
		       ArSh = 1'b0; //SrcA = I[15-11]
		    end // case: C_SUB_fmt
		  endcase // case(Instruction[5:0])
	       end // case: 6'b010001

	       // ################ Special Operations ################
	       6'b000000: begin
		  case(Instruction[5:0])
		    S_ADD: 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_ADD; //Special ADD 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_ADD

		    S_ADDU: 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_ADDU; //Special ADDU 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_ADDU

		    S_SUB: 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_SUB; //Special SUB 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_SUB

		    S_SUBU: begin

⌨️ 快捷键说明

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