Skip to content

SystemVerilog implementation of RISC-V RV32I & RV64I cores. Features 5-stage pipelining, hazard resolution, forwarding units, and synthesizable FPGA wrappers. Includes comprehensive testbenches and architectural documentation.

License

Notifications You must be signed in to change notification settings

ridash2005/RISC-V_MultiPrecision_Processor_Core

RISC-V MultiPrecision Processor Core

License Verilog Status Verification

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.

🌟 Key Features

  • 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.

πŸ—οΈ High-Level Architecture

The processor executes instructions in a single clock cycle: Fetch $\rightarrow$ Decode $\rightarrow$ Execute $\rightarrow$ Memory $\rightarrow$ Writeback.

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
Loading

For a deep dive into the internal modules, signal flow, and decoder logic, implementation details, please read our Architecture Documentation:


πŸ“‚ Repository Structure

.
β”œβ”€β”€ 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 Reuse Summary

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.


πŸš€ Usage & Simulation

This processor is designed to be simulator-agnostic. It works out-of-the-box with Xilinx Vivado, ModelSim, and Icarus Verilog.

Quick Start (Vivado/ModelSim)

  1. 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.
  2. Set Top Module:
    • Set CPU.sv as the top module.
  3. Simulation:
    • Create a testbench instantiating CPU.
    • Run Behavioral Simulation.

For detailed step-by-step instructions, see the Getting Started Guide.


πŸ”§ Technical Specifications

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Β²

🀝 Community & Contribution

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.

οΏ½ License

This project is open-source and available under the MIT License.

About

SystemVerilog implementation of RISC-V RV32I & RV64I cores. Features 5-stage pipelining, hazard resolution, forwarding units, and synthesizable FPGA wrappers. Includes comprehensive testbenches and architectural documentation.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published