A repository for RISC-V Processor Design, bridging the gap from fundamental theory to advanced implementation. It features both Single-Cycle (Golden Reference) and 5-Stage Pipelined (High-Performance) architectures, providing a complete learning path for Computer Architecture students and engineers.
π New to this? Start with our Beginner's Guide for a jargon-free introduction.
- Evolutionary Learning Path: Step-by-step progression from simple 32-bit (rv32i_SingleCycle) & 64-bit (rv64i_SingleCycle) Single-Cycle designs to a robust 5-Stage Pipelined architecture.
- ASIC Proven: The Pipelined Core has been physically hardened using the Sky130 node and LibreLane (OpenLane) flow, continuing the journey from RTL to GDSII.
- Multi-Precision Support: Full source code for both 32-bit and 64-bit data paths.
- Advanced Features:
- Pipelining: 5-stage design (IF, ID, EX, MEM, WB) with Hazard Detection and Forwarding.
- Harvard Architecture: Separate Instruction and Data memories.
- GPIO: Standardized Memory-mapped I/O across all architectures (32-bit, 64-bit, and Pipelined).
- Synthesizable: Written in SystemVerilog, optimized for FPGAs (Artix-7, Cyclone V).
- Modular: Clean separation of Data Path, Control, and Hazards.
The processor executes instructions in a single clock cycle: Fetch
graph TD
%% Styling
classDef module fill:#e1f5fe,stroke:#01579b,stroke-width:2px;
classDef memory fill:#fff3e0,stroke:#e65100,stroke-width:2px;
subgraph Processor ["RISC-V Processor Core"]
PC[Program Counter]:::module
Control[Control Unit]:::module
RegFile[Register File]:::module
ALU[ALU]:::module
ImmGen[Immediate Gen]:::module
PC --> IM
IM --> Control
IM --> RegFile
IM --> ImmGen
RegFile --> ALU
ImmGen --> ALU
Control --> ALU
Control --> RegFile
Control --> DM
end
subgraph Memory ["Memory Subsystem"]
IM[Instruction Memory]:::memory
DM[Data Memory]:::memory
end
ALU --> DM
DM --> RegFile
ALU --> RegFile
For a deep dive into the internal modules, signal flow, and decoder logic, implementation details, please read our Architecture Documentation:
- Single-Cycle Walkthrough
- Pipelined Walkthrough
- ASIC Implementation Guide (Datasheet & Signoff)
- LibreLane Tool Guide (RTL-to-GDSII Tutorial)
.
βββ rv32i_SingleCycle/ # [Step 1] 32-bit Single-Cycle (Golden Reference)
β βββ src_modules/ # SystemVerilog source files
β βββ CPU.sv # Top-level processor
β βββ ALU.sv # Arithmetic Logic Unit
β βββ Register_File.sv # 32 x 32-bit registers
β βββ Control_Unit.sv # Instruction decoder
β βββ Immediate_Generator.sv # Immediate extraction
β βββ ... # Other modules
β
βββ rv64i_SingleCycle/ # [Step 2] 64-bit Single-Cycle (Advanced Data Width)
β βββ src_modules/ # Same structure as rv32i, 64-bit data paths
β
βββ rv32i_pipelined/ # [Step 3] 32-bit 5-Stage Pipelined (High Performance)
β βββ src_modules/
β β βββ CPU.sv # Top-level (with pipeline structure)
β β βββ FPGA_Wrapper.sv # FPGA synthesis wrapper
β β βββ ALU.sv # [REUSED] Identical to SingleCycle
β β βββ Register_File.sv # [REUSED] Identical to SingleCycle
β β βββ Immediate_Generator.sv # [REUSED] Identical to SingleCycle
β β βββ ALU_Decoder.sv # [REUSED] Identical to SingleCycle
β β βββ Main_Decoder.sv # [ADAPTED] LUI uses ALU path
β β βββ Control_Unit.sv # [ADAPTED] No branch resolution
β β βββ Program_Counter.sv # [ADAPTED] Added stall support
β β βββ IF_ID_Reg.sv # [NEW] Pipeline register
β β βββ ID_EX_Reg.sv # [NEW] Pipeline register
β β βββ EX_MEM_Reg.sv # [NEW] Pipeline register
β β βββ MEM_WB_Reg.sv # [NEW] Pipeline register
β β βββ Hazard_Unit.sv # [NEW] Stall/Flush detection
β β βββ Forwarding_Unit.sv # [NEW] Data forwarding
β β βββ Mux3.sv # [NEW] 3-to-1 multiplexer
β βββ tb/ # Testbenches
β βββ programs/ # Test programs (.hex)
β
βββ asic/rv32i_pipelined/ # [Step 4] ASIC Implementation (Sky130)
β βββ config_linux.json # OpenLane Configuration
β βββ reports/final/ # Final GDSII, LEF, Netlist, SPEF
β βββ runs/ # Run directories (gitignored)
β
βββ docs/ # Learning Center
β βββ ARCHITECTURE.md # Architecture Theory
β βββ TRANSITION_GUIDE.md # SingleCycle β Pipeline Evolution
β βββ RV32I_WALKTHROUGH.md # Single-Cycle Guide
β βββ RV32I_PIPELINED_WALKTHROUGH.md # Pipeline & Hazard Guide
β βββ GETTING_STARTED.md # Simulation Setup
β
βββ CONTRIBUTING.md # Guidelines for contributors
βββ LICENSE # MIT License
βββ README.md # Project Entry Point
| Module | SingleCycle | Pipelined | Status |
|---|---|---|---|
| ALU | β | β | REUSED (identical) |
| Register_File | β | β | REUSED (identical) |
| Immediate_Generator | β | β | REUSED (identical) |
| Main_Decoder | β | β | ADAPTED (LUI via ALU) |
| ALU_Decoder | β | β | REUSED (identical) |
| Control_Unit | β | β | ADAPTED (no branch logic) |
| Program_Counter | β | β | ADAPTED (stall support) |
| Pipeline Registers | β | β | NEW |
| Hazard_Unit | β | β | NEW |
| Forwarding_Unit | β | β | NEW |
π See TRANSITION_GUIDE.md for detailed explanation of every change.
This processor is designed to be simulator-agnostic. It works out-of-the-box with Xilinx Vivado, ModelSim, and Icarus Verilog.
- Choose your Core:
- Single-Cycle (32-bit): Add all files from
rv32i_SingleCycle/src_modules. - Pipelined (32-bit): Add all files from
rv32i_pipelined/src_modules.
- Single-Cycle (32-bit): Add all files from
- Set Top Module:
- Set
CPU.svas the top module.
- Set
- Simulation:
- Create a testbench instantiating
CPU. - Run Behavioral Simulation.
- Create a testbench instantiating
For detailed step-by-step instructions, see the Getting Started Guide.
| Feature | Single-Cycle RV32I | Single-Cycle RV64I | Pipelined RV32I |
|---|---|---|---|
| Pipeline Stages | 1 | 1 | 5 (IF/ID/EX/MEM/WB) |
| Throughput | 1 Inst / Cycle | 1 Inst / Cycle | ~1 Inst / Cycle (Higher Freq) |
| Hazard Handling | None Needed | None Needed | Forwarding & Stalling |
| Registers | 32 x 32-bit | 32 x 64-bit | 32 x 32-bit |
| Max Freq (Artix-7) | ~70 MHz | ~60 MHz | ~120 MHz+ |
| Max Freq (Sky130) | N/A | N/A | 31.7 MHz (Signoff) |
| Area (Sky130) | N/A | N/A | 0.37 mmΒ² |
We welcome contributions! Whether it's adding support for the M extension, optimizing the ALU, or improving documentation.
Please review CONTRIBUTING.md before submitting a Pull Request.
This project is open-source and available under the MIT License.