This project implements a 5-stage pipelined MIPS processor in Verilog as part of the CUFE CMP3010 [Computer Architecture] course. The processor supports instruction fetch, decode, execute, memory access, and write-back stages, with hazard detection and control logic for robust pipelined execution.
- Modular Design: Each pipeline stage is implemented as a separate module for clarity and extensibility.
- Hazard Handling: Includes dedicated units for hazard detection and jump/branch control to ensure correct instruction flow.
- Testability: Testbenches are provided for individual modules and full integration.
- Memory Management: Separate modules for instruction and data memory, supporting read/write operations.
- Fetch (
Fetch.v): Retrieves instructions from memory, increments the program counter, and handles branching. - Decode (
Decode.v,Decode2.v): Decodes instructions, generates control signals, and reads register values. - Execute (
ALU.v,FU.v): Performs arithmetic and logic operations, sets flags, and handles forwarding. - Memory (
Memory.v,Data_Memory.v): Accesses data memory for load/store instructions. - Write Back (
WriteBack.v): Writes results back to registers.
Hazard Detection:
HazardDetectionUnit.vstalls pipeline stages when data hazards are detected.
Jump/Branch Control:
JDU.vmanages jump instructions and flushes pipeline stages as needed.
Intermediate Buffers:
intermediate_buffers.vimplements pipeline registers between stages.
| File/Folder | Purpose & Details |
|---|---|
MIPS_phase_3.v |
Top-level processor module, connects all stages |
Fetch.v |
Instruction fetch logic |
Decode.v, Decode2.v |
Instruction decode and control unit |
ALU.v |
Arithmetic Logic Unit |
FU.v |
Forwarding Unit for data hazards |
HazardDetectionUnit.v |
Hazard detection logic |
JDU.v |
Jump/branch control unit |
Memory.v, Data_Memory.v |
Memory modules for instructions and data |
WriteBack.v |
Write-back stage logic |
intermediate_buffers.v |
Pipeline registers between stages |
testFetch.v, testInteg.v, Data_Memory_tb.v |
Testbenches for simulation |
tc_two_operands.asm |
Example assembly program for testing |
units.drawio |
Pipeline architecture diagram (add image here) |
README.md |
Project documentation |
- 5-stage pipelined architecture
- Data and control hazard detection and resolution
- Forwarding and stalling logic
- Branch and jump support
- Modular, extensible Verilog codebase
- Testbenches for validation
- Verilog HDL
- ModelSim / Vivado / Icarus Verilog (for simulation)
- Draw.io (for architecture diagrams)
- Assembly (for test programs)
- Clone the repository:
git clone https://github.com/<your-username>/Project_Processor-MIPS_phase3_new.git cd Project_Processor-MIPS_phase3_new
- Open the project in your preferred Verilog simulator (ModelSim, Vivado, etc.)
- Simulate the top-level module (
MIPS_phase_3.v) and testbenches. - Edit
tc_two_operands.asmto test custom instruction sequences.
// Example: Simulating the Fetch stage
module testFetch();
reg clk, reset;
wire [15:0] instruction;
reg [31:0] pcin;
wire [31:0] pcout;
Fetch f(pcin, pcout, instruction, clk, reset);
initial begin
clk = 0;
reset = 0;
pcin = 0;
forever #50 clk = ~clk;
end
always @(posedge clk) begin
pcin = pcout;
end
endmodule- Pipeline Buffers: Used to separate stages and maintain instruction/data flow.
- Hazard Detection: Ensures correct execution order and prevents data corruption.
- Forwarding Unit: Minimizes stalls by forwarding data between stages.
- Branch/Jump Logic: Handles control flow changes efficiently.
- Memory Modules: Support large address spaces and efficient access.
Project_Processor-MIPS_phase3_new/
│
├── MIPS_phase_3.v
├── Fetch.v
├── Decode.v
├── Decode2.v
├── ALU.v
├── FU.v
├── HazardDetectionUnit.v
├── JDU.v
├── Memory.v
├── Data_Memory.v
├── WriteBack.v
├── intermediate_buffers.v
├── testFetch.v
├── testInteg.v
├── Data_Memory_tb.v
├── tc_two_operands.asm
├── units.drawio
├── README.md
└── ...
Contributions, suggestions, and feedback are welcome! Feel free to fork the repo, open issues, or submit pull requests.
- Licensed under the MIT License
Design. Simulate. Learn. 🚀