This repository contains a 3-stage pipelined RISC-V processor implementation in Verilog, along with a C-to-RISC-V cross-compilation toolchain and simulation environment.
Click here to view the hand-drawn block diagrams.
Contains the Verilog source code for the RISC-V processor.
pipeline.v: The top-level module integrating all pipeline stagesIF_ID.v: Instruction Fetch and Decode stage logic, including the pipeline registerexecute.v: Execution stage containing the ALU and branch resolutionmemory.v: Instruction and Data memory moduleswb.v: Write-back stage logictestbench.v: The simulation testbench for verifying the processorfpga/: Contains the Vivado constraints (.xdc) and the top-level FPGA wrapper (fpga.v) for deployment to a Nexys A7 board
Provides the toolchain to write C code and convert it into memory initialization files for the Verilog simulator.
Contains the environment to run the Verilog simulation using Vivado's xsim.
Includes scripts to synthesize and implement the processor for the Nexys A7 (xc7a100tcsg324-1).
- Install Toolchain:
xpm install
- Configure Vivado Path:
Create a
.envfile in the root directory and setVIVADO_BIN_DIRto your Vivado binary directory (wherevivado.batorvivadois located). For example:VIVADO_BIN_DIR=C:\AMDDesignTools\2025.2\Vivado\bin
To compile the C programs into .hex files, use python run.py build <program>.
This will generate imem.hex and dmem.hex in the firmware/imem_dmem/ directory.
After running the build action, use python run.py sim to run the simulation.
Once finished, you can find the generated waveform file pipeline.vcd inside the simulation/ directory.
- First, compile the C program you want to run on the FPGA (Eg.
python run.py build addition) - Run the synthesis and implementation pipeline using
python run.py synth
Once the bitstream (fpga/build/fpga.bit) is generated, you can program the connected board directly:
- Ensure the board is connected via USB and turned ON
- Run
python run.py program