This repository contains Hardware Description Language (HDL) implementations of 32-bit RISC processors, including a custom educational 32-bit RISC core (risc32) and a standard RISC-V RV32I single-cycle processor (RV32I).
- Overview
- Directory Structure
- RISC-V RV32I Processor (
RV32I) - Custom 32-Bit RISC Architecture (
risc32)
This project explores RISC architectures optimized for FPGA development and digital design study. The implementations focus on simplicity, low logic resource utilization, and educational clarity in single-cycle datapaths.
RV32I/- Official RISC-V RV32I single-cycle processor implementation (seeRV32I/readme.mdfor detailed ISA and microarchitecture documentation).rtl/- Verilog RTL modules (ALU, Control Unit, Immediate Generator, Register File, Datapath, Memories).tb/- Testbenches for unit and integration verification.sim/- Simulation waveform outputs (.vcd).docs/- Documentation diagrams.
risc32/- Custom 32-bit RISC implementation.components/- Verilog source files for the processor's datapath and control units.testebenches/- Testbenches to verify the functionality of the processor.waveforms/- Output.vcdfiles generated during simulations.risc_reference/- Reference materials and diagrams.
An implementation of the base 32-bit integer RISC-V ISA (RV32I) using a Harvard single-cycle microarchitecture:
- Registers: 32 general-purpose 32-bit registers (
x0hardwired to zero,x1–x31) + 32-bitPC. - Supported Instructions:
- R-Type:
add,sub,and,or,xor - I-Type (ALU):
addi,andi,ori,xori - Memory (I/S-Type):
lw,sw - Branches (B-Type):
beq,bne,blt,bge - Jumps (J/I-Type):
jal,jalr
- R-Type:
- Full documentation (in Portuguese):
RV32I/readme.md
The instruction format has a fixed size (32 bits), following classic RISC standards for fast and efficient hardware decoding.
- R-Type: Arithmetic and logic operations between registers.
- I-Type: Operations with short immediates, loads, and some branches.
- S/B-Type: Store instructions and conditional branches.
- J-Type: Unconditional branches (jumps).
The base instruction set supports:
- Arithmetic & Logic:
add,sub,and,or,slt - Memory Transfer:
lw,sw - Control Flow:
beq,j
The modular division of the Verilog code in risc32/components/ reflects the datapath stages:
program_counter.v: Controls the program flow.instruction_fetch.v/instruction_memory.v: Instruction fetching and storage (ROM).data_memory.v: Data storage (RAM).register_files.v: The base register file of the architecture.alu_unit.v: Arithmetic Logic Unit (ALU).sign_extension.v: Sign extension module.control_unit.v/alu_control.v: Units responsible for routing and multiplexer control.datapath.v/RISC.v: Top-level integration modules.
The testbench modules in risc32/testebenches/ verify the execution of the entire datapath:
- Validation of R-Type and I-Type instructions.
- Validation of control flow (branches).
- Functional testing executing algorithms such as the Fibonacci sequence.
The RTL simulation generates a .vcd file in risc32/waveforms/, allowing graphical visualization of internal datapath signals in software like GTKWave.