32 bit CPU based on MIPS architecture#
Implementation of a 32-bit MIPS Processor using Verilog HDL. The processor is capable of executing various MIPS instructions and includes key components such as the Instruction Memory, Register File, ALU, Data Memory, and Control Unit.
Instruction Set#
The MIPS Processor supports the following instructions:
ADD rd, rs, rt
: Reg[rd] = Reg[rs] + Reg[rt]BNE rs, rt, imm16
: Branch if (Reg[rs] != Reg[rt])J target
: Jump to the specified target addressJR rs
: Jump to the address stored in Reg[rs]LW rt, imm16(rs)
: Load data from memory to Reg[rt]SLT rd, rs, rt
: Set Reg[rd] to 1 if (Reg[rs] < Reg[rt]), otherwise 0SUB rd, rs, rt
: Reg[rd] = Reg[rs] - Reg[rt]SW rt, imm16(rs)
: Store data from Reg[rt] to memoryXORI rt, rs, imm16
: Reg[rt] = Reg[rs] XOR Zero_ext(Imm16)
Architecture#
The MIPS Processor follows a 5-stage pipeline architecture, consisting of the following stages:
Instruction Fetch (IF)
Instruction Decode (ID)
Execute (EX)
Memory Access (MEM)
Write Back (WB)
Each stage has its own set of registers and performs specific operations to execute the instructions.
Modules#
The design of the MIPS Processor includes the following modules:
InstructionMem: Stores and retrieves instructions based on the provided address.
RegFile: 32-register file module with read and write operations.
Add: 32-bit adder module.
ALU: 32-bit Arithmetic Logic Unit module for performing arithmetic and logical operations.
DataMem: Data memory module for storing and retrieving 32-bit data values.
Control Unit: Generates control signals for different stages of the processor pipeline.
ForwardingUnit: Solves data hazards in the pipelined processor by forwarding correct data to the ALU input.
mux3x32to32: 3x32 to 32 multiplexer module.
mips_32: The main module that integrates all the components and implements the 32-bit MIPS Processor.
Testing#
A testbench has been created to verify the functionality of the MIPS Processor. It includes test stimuli and checks the behavior of the processor by observing memory addresses and fetched instructions.
Usage#
To use the MIPS Processor, you can instantiate the mips_32
module in your Verilog design and provide appropriate inputs. Make sure to adhere to the instruction set and connect any required peripherals or memory modules.