A clean implementation of a single-cycle RISC-V RV32I processor with UART communication interface.
This repository contains a synthesizable Verilog implementation of a single-cycle RISC-V processor supporting the RV32I base instruction set. The design emphasizes modularity and clarity while maintaining full functionality.
The processor implements a classic single-cycle datapath with the following components:
- Arithmetic Unit: Configurable ALU supporting ADD, SUB, OR, AND, SLT operations
- Register Bank: 32 general-purpose registers (x0-x31)
- Program Counter: 16-bit counter for instruction addressing
- Instruction Memory: ROM containing program instructions
- Data Memory: RAM for load/store operations
- Control Unit: Hierarchical decoder for instruction control signals
- Immediate Generator: Supports I, S, B, U, and J-type immediate formats
src/
├── single_cycle_processor/
│ ├── src/ # Core processor modules
│ └── sim/ # Testbenches
└── uart/
└── src/ # UART communication modules
riscv_core.v- Top-level processor integrationarithmetic_unit.v- ALU implementationregister_bank.v- Register filecounter.v- Program counterinstruction_memory.v- Instruction ROMdata_mem.v- Data RAMcontrol_unit.v- Main control logicinstruction_decoder.v- Opcode decoderalu_decoder.v- ALU operation decoderimmediate_generator.v- Immediate value extractoradder_unit.v- Simple adder module
baud_generator.v- Configurable baud rate clockuart_transmitter.v- Serial data transmissionuart_receiver.v- Serial data reception
Requirements:
- Icarus Verilog
- GTKWave (optional, for waveform viewing)
To run simulation:
cd src/single_cycle_processor/src
iverilog -g2012 -o ../sim/test *.v ../sim/tb_riscv_core.v
cd ../sim
vvp test
gtkwave riscv_core.vcd- Full RV32I instruction support (ADD, SUB, AND, OR, SLT, Load, Store, Branch, JAL, LUI)
- Parameterized data widths for flexibility
- Clean hierarchical design
- Comprehensive testbench with detailed output
- UART interface for external communication
- Synthesizable for FPGA deployment
- Well-documented code structure
The processor operates on a single clock cycle per instruction. Control signals are generated combinationally from the instruction opcode, while the datapath executes the operation within one clock period.
Key design decisions:
- Register 0 hardwired to zero
- Little-endian memory organization
- Synchronous register writes
- Asynchronous reads for register file and memories