This repository contains a Register-Transfer Level (RTL) implementation of a Single-Cycle RISC-V Processor supporting the RV32I base integer instruction set. Designed using Verilog HDL, this project serves as a core module for understanding computer architecture principles, specifically the data path and control logic of a RISC-style processor.
The processor is capable of executing a variety of instructions including arithmetic, logic, load/store capabilities, and control flow operations (branch/jump) in a single clock cycle.
- Core Architecture: 32-bit Single-Cycle RISC-V (RV32I).
- Instruction Support:
- Arithmetic/Logic:
ADD,SUB,AND,OR,XOR,SLL,SRL,SRA,SLT,SLTU. - Immediates:
ADDI,ANDI,ORI,XORI,SLLI,SRLI,SRAI,SLTI,SLTIU. - Memory Access:
LB,LH,LW,LBU,LHU,SB,SH,SW. - Control Flow:
BEQ,BNE,BLT,BGE,BLTU,BGEU,JAL,JALR. - Upper Immediate:
LUI,AUIPC.
- Arithmetic/Logic:
- Modular Design: Distinct modules for ALU, Control Unit, Register File, Immediate Generator, and Memory interfaces.
- Debug-Ready: The top-level module exposes critical internal signals (PC, ALU Output, Register Write Data) for easy waveform analysis and debugging.
- Language: Verilog HDL
- IDE / Synthesis: Intel Quartus Prime
- Simulation: ModelSim / Quartus Vector Waveform (
.vwf) - Target Device: Generic FPGA / Simulation-only (configurable)
RISC-V_Single_Cycle_Processor/
├── toplevel_rv32i.v # Top-level module integrating all components
├── ctrl_unit_rv32i.v # Main Control Unit (Decoder & Control Signals)
├── alu_rv32i.v # Arithmetic Logic Unit (ALU)
├── reg_file_rv32i.v # 32x32-bit Register File
├── data_mem_rv32i.v # Data Memory Module
├── instr_rom_rv32i.v # Instruction Memory (ROM)
├── imm_select_rv32i.v # Immediate Generator
├── brancher_rv32i.v # Branch comparison logic
├── test_vector.s # RISC-V Assembly test code for validation
└── *.v # Component submodules (Adder, Muxes, etc.)
- Intel Quartus Prime (Lite/Standard/Pro) installed.
- A RISC-V Assembler (like Venus) if you wish to modify
test_vector.sand regenerate memory initialization files.
- Launch Intel Quartus Prime.
- Open the project file:
toplevel_rv32i.qpf. - Ensure all Verilog files are added to the project hierarchy.
- Run Analysis & Synthesis to check for syntax errors and logic validity.
- (Optional) Run full compilation if targeting specific FPGA hardware.
Using Vector Waveform File (.vwf):
- Open
toplevel_rv32i.vwf(if available). - Run Functional Simulation to verify instruction execution cycle-by-cycle.
Using ModelSim:
- Launch ModelSim from Quartus.
- Compile all
.vfiles. - Simulate
toplevel_rv32imodule. - Monitor
PC,instr,ALU_output, anddmem_outto track program flow.
A sample assembly program is provided in test_vector.s to validate the processor's functionality.
Test Scenario (test_vector.s):
- Initialize: Loads values
a = 2325andb = 71. - Operations:
- Performs Division (manual loop) to find
2325 / 71. - Performs Remainder (manual loop) to find
2325 % 71. - Performs Multiplication (manual loop) to verify
(Quotient * b) + Remainder == a.
- Performs Division (manual loop) to find
- Result:
- If the validation passes, the processor stores
1in registera0. - Use the simulation waveform to check if register
a0(x10) contains1at the end of execution.
- If the validation passes, the processor stores
- Implement Pipelining (5-stage) to improve throughput.
- Add Hazard Detection and Forwarding Unit.
- Support CSR (Control and Status Registers) for system-level instructions.
- Interface with physical FPGA I/O (LEDs, 7-Segment Displays).
This project is open-source and available under the MIT License.
Authors: Rafi Ananta Alden, Didan Attaric Course: EL3011 Computer System Architecture