The PyRISC project aims at providing various RISC-V toolset written in Python for educational purposes. It includes the RISC-V instruction set simulator and pipelined RISC-V processor simulators. All the simulators accept the executable file compiled with the standard GNU toolchain that supports RV32I base instruction set. Some of instructions are intentionally left unimplemented for class projects.
Currently, the following tools are available:
./sim
: A RISC-V instruction set simulator for RV32I base instruction set./pipe5
: A simulator for 5-stage pipelined RISC-V processor implementation with RV32I instruction set./asm
: Makefile, linker script, and examples for building PyRISC-compatible RISC-V executable files
Please see the README file in each subdirectory for more information.
The PyRISC toolset requires Python version 3.6 or higher. In addition, the PyRISC toolset depends on Python modules such as numpy
and pyelftools
. These modules can be installed on Ubuntu 18.04LTS as follows:
$ sudo apt-get install python3-numpy python3-pyelftools
In order to work with the PyRISC toolset, you need to build a RISC-V GNU toolchain for the RV32I instruction set. To build the RISC-V toolchain on your machine (on either Linux or MacOS), please take the following steps.
For Ubuntu 18.04LTS, perform the following command:
$ sudo apt-get install autoconf automake autotools-dev curl libmpc-dev
$ sudo apt-get install libmpfr-dev libgmp-dev gawk build-essential bison flex
$ sudo apt-get install texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
If your machine runs MacOS, perform the following command:
$ brew install gawk gnu-sed gmp mpfr libmpc isl zlib expat
$ git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
$ cd riscv-gnu-toolchain
$ mkdir build
$ cd build
$ ../configure --prefix=/opt/riscv --with-arch=rv32i
$ sudo make
Note that they are installed in the path given as the prefix, i.e. /opt/riscv
in this example.
$ export PATH=/opt/riscv/bin:$PATH
PyRISC is offered under the terms of the Open Source Initiative BSD 3-Clause License. More information about this license can be found here.
Jin-Soo Kim
Systems Software and Architecture Laboratory
Seoul National University
http://csl.snu.ac.kr