This repository contains a Register-Transfer Level (RTL) implementation of a 32-bit RISC-V integer architecture (RV32I) pipelined processor, written in Verilog.
The core implements a classic 3-stage pipeline to achieve high throughput while maintaining simplicity:
- Instruction Fetch and Decode (IF_ID)
- Fetches instructions from the Instruction Memory (IMEM).
- Decodes the fetched instruction.
- Extracts immediate values and register addresses.
- Execute (EX)
- Computes standard arithmetic and logic unit (ALU) operations.
- Resolves branch targets and conditions.
- Computes memory addresses for load and store instructions.
- Writeback (WB)
- Interfaces with the Data Memory (DMEM).
- Performs memory reads (LOAD) and memory writes (STORE).
- Writes computed results or loaded data back to the register file.
Install the following before running the project:
- RISC-V GNU Toolchain
- Vivado (for simulation)
- Python
- Make
Download and install Git: https://git-scm.com/download/win
Use default installation settings.
Open a terminal using: Right Click → Git Bash Here
All project commands should be executed in Git Bash.
Download and install Node.js, which includes npm: https://nodejs.org/en/download
Verify installation in the Git Bash:
node --version
npm --versionInstall the RISC-V Embedded GCC toolchain using npm.
Install xpm:
npm install --global xpmInstall the RISC-V toolchain:
xpm install --global @xpack-dev-tools/riscv-none-elf-gccThe toolchain will be installed at a location similar to:
C:\Users\<username>\AppData\Roaming\xPacks\@xpack-dev-tools\riscv-none-elf-gcc\<version>\.content\bin
Add this bin directory to the Windows PATH.
Steps:
- Open Environment Variables
- Edit System Path
- Add the toolchain bin directory
Run in Git Bash:
riscv-none-elf-gcc --versionIf successful, the GCC version information will be displayed.
If you have Chocolatey installed, run:
choco install makeThen verify in Git Bash:
make --versionRun:
cd RISCV_Three_Stage/simulation
make additionThis will automatically:
- Compile the C program
- Generate instruction and data memory files
- Launch Vivado simulation
- Produce waveform output
Several testcases are supported out of the box:
make additionmake negativemake xormake fibmake sort
You can add completely new custom testcases by creating a code_[name].c in mem_generator/, editing mem_generator/Makefile to set it as a target, and making a new [name] rule in simulation/Makefile.
Upon completing execution, you will see output in the terminal showing the Program Counter (next_pc) progressing alongside specific register write results (time, result).
These final results are simultaneously written out locally:
simulation/simulation_results.txt: A clean log of exact timestamps, the active branches, and the changing result values of output variables.simulation/pipeline.vcd: A full Value Change Dump (VCD) waveform file containing the timing toggles of all processor signals for deep debugging.