Skip to content

Latest commit

Β 

History

History
126 lines (97 loc) Β· 3.27 KB

File metadata and controls

126 lines (97 loc) Β· 3.27 KB

RISC-V Processor Implementations

This repository contains two implementations of a RISC-V RV32I processor:

Projects

1. Single Cycle Processor

A straightforward single-cycle implementation of the RISC-V RV32I architecture. Each instruction completes in one clock cycle.

πŸ“ Location: Single_Cycle_Processor/
πŸ“– Documentation: Single_Cycle_Processor/README.md

Key Features:

  • Simple datapath design
  • One instruction per cycle
  • Full RV32I support
  • UART communication interface

2. Pipelined Processor

A high-performance 5-stage pipelined processor with hazard detection and control.

πŸ“ Location: Pipelined_Processor/
πŸ“– Documentation: Pipelined_Processor/README.md

Key Features:

  • 5-stage pipeline (IF, ID, EX, MEM, WB)
  • Data hazard detection
  • Pipeline stalling mechanism
  • Branch/jump handling
  • Higher throughput than single-cycle

Architecture

Both processors implement the RISC-V 32-bit base integer instruction set (RV32I):

  • Arithmetic operations (ADD, SUB, AND, OR, SLT)
  • Memory operations (LW, SW)
  • Control flow (BEQ, JAL)
  • Immediate operations (ADDI, LUI)

Directory Structure

RISC-V-Processor/
β”œβ”€β”€ Single_Cycle_Processor/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ single_cycle_processor/
β”‚   β”‚   β”‚   β”œβ”€β”€ src/          # Core modules
β”‚   β”‚   β”‚   └── sim/          # Testbenches
β”‚   β”‚   └── uart/
β”‚   β”‚       └── src/          # UART modules
β”‚   └── README.md
β”‚
└── Pipelined_Processor/
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ pipelined_processor/
    β”‚   β”‚   β”œβ”€β”€ src/          # Core modules
    β”‚   β”‚   └── sim/          # Testbenches
    β”‚   └── uart/
    β”‚       └── src/          # UART modules
    └── README.md

Getting Started

Prerequisites

  • Icarus Verilog (for simulation)
  • GTKWave (optional, for waveform viewing)
  • Quartus (optional, for FPGA synthesis)

Running Simulations

Single Cycle:

cd Single_Cycle_Processor/src/single_cycle_processor/src
iverilog -g2012 -o ../sim/test *.v ../sim/tb_riscv_core.v
cd ../sim
vvp test
gtkwave riscv_core.vcd

Pipelined:

cd Pipelined_Processor/src/pipelined_processor/src
iverilog -g2012 -o ../sim/test *.v ../sim/tb_riscv_pipeline.v
cd ../sim
vvp test
gtkwave riscv_pipeline.vcd

Implementation Comparison

Feature Single Cycle Pipelined
CPI 1 (fixed) ~1 (variable)
Clock Period Long Short
Throughput Lower Higher
Complexity Simple Complex
Hazard Handling Not needed Required
Best For Learning, simple apps Performance-critical

Design Philosophy

Both implementations prioritize:

  • Clarity: Clean, readable Verilog code
  • Modularity: Well-separated functional blocks
  • Parameterization: Configurable data widths
  • Testability: Comprehensive testbenches
  • Synthesis: FPGA-ready designs

Hardware Requirements

Tested on:

  • Altera DE2-115 FPGA Board
  • Xilinx FPGAs (with minor modifications)

License

This project is for educational purposes.

Author

Bavan2002

Acknowledgments

Based on the RISC-V instruction set architecture specification.