Git Product home page Git Product logo

application-specific-riscv-research's Introduction

Application Specific RISC-V CPU Generator

The goal of this project is be able to take any application and produce a RISC-V CPU implementation best suited for it, Removing hardware from a traditional RISC-V CPU that wouldn't be used by the application.

Where everything is under /src

/analysis

Here goes the code responsible for analyzing compiled .s files and generating its corresponding verilog code.

/riscv CPU

RISC-V implementation in verilog capable of running all RISC-V instructions

/riscv code

Here goes the application we are optimizing for and its associated .s file.

insts.json

This is a JSON file that has a list of all RISC-V instructions and their extensions to more easily query and identify them in code.

Process

Compile C++/C code into searchable assembly instructions

Install RISC-V compiler

# Debian
$ sudo apt install g++-riscv64-linux-gnu

# Arch
$ sudo pacman -S riscv64-linux-gnu-gcc

Compile C++/C code into .s assembly instruction file

# don't fprget to cd to ./src/risccv code

# Debian
$ g++-riscv64-linux-gnu -S <C++/C file>

# Arch
$ riscv64-linux-gnu-g++ -S <C++/C file>

Now you can inspect which instructions exactly this program uses.

Analyse .s file

Run python code under /analysis and it will create a bar chart of the instructions used in the .s file under /riscv code.

compile verilog code

Download icarus verilog

# Debian
$ sudo apt install iverilog

# Arch
$ sudo pacman -S iverilog

Compile verilog code using list of all .v files as found under icarus_ref.txt. (make sure file names are in order of encapsulation/dependency. this is why we cannot use *.v to compile)

# don't forget to cd to ./src/riscv CPU
$ iverilog -o ricv -c icarus_ref.txt

Run implementation. text output of asserts should pop up in terminal.

$ vvp riscv

Produce verilog files according to application requirement

debug verilog code

Install GTKwave

$ sudo apt install gtkwave

Make sure you add this to the beginning of you simulation's initial begin. Just replace "riscv" with the simulation modules name

$dumpfile("riscv.vcd");
$dumpvars(0, rsicv);

View waveform.

$ sudo gtkwave "<directory of .vcd file>"

To Do

  • Finish implementation of RISC-V verilog implementation able of running all RISC-V instructions.
  • Categorize what part of the RISC-V CPU each instruction uses.
  • Make program that creates verilog code that implements RISC-V CPU with the minimum hardware required for an application.

Long term plan

  • Replace instructions rarely used by application by slower instructions but use less hardware.
  • Custom compiler that is able to produce RISC-V code while avoiding specific instructions.
  • Create a sort of "speed", "power" and "cost" profiles that alters which instructions are implemented and how they are implemented to better suit an end case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.