Git Product home page Git Product logo

rv32's Introduction

32-bit RISC-V processor design

Implements RV32I instruction set except for interrupts and some CSRs.

Warning: CSR and system instructions weren't really tested so may not work properly

Default software runs a 2.5D maze game through the VGA port, using SW2 and SW3 to turn and move.

Implemented CSRs:

  • cycle/cycleh -- doesn't count

  • time/timeh -- doesn't count

  • instret/instreth -- doesn't count

  • mvendorid

  • marchid

  • mimpid

  • misa -- ignores writes

  • mstatus -- all but mpie and mie are hardwired

  • mie -- all but meie, mtie, and msie are hardwired

  • mtvec -- hardwired to 0x10040

  • mscratch

  • mepc

  • mcause

  • mip -- ignores writes

  • used FPGA: ChinaQMTECH's QM_XC6SLX16_DDR3 board with the vga output board. Docs archived on archive.org

  • used programmer: Digilent's Hs2 JTAG programmer

Building (On Ubuntu 16.04)

Requires Xilinx's ISE v. 14.7 to be installed in /opt/Xilinx (just leave the default installation directory)

sudo apt-get install git g++ autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
sudo mkdir /opt/riscv
sudo chown $USER /opt/riscv # so you don't need root when building; you can change back after building riscv-gnu-toolchain
git clone --recursive https://github.com/riscv/riscv-gnu-toolchain.git
export PATH=/opt/riscv/bin:"$PATH"
cd riscv-gnu-toolchain
./configure --prefix=/opt/riscv --with-arch=rv32i
make
sudo chown -R root:root /opt/riscv # change owner back to root as the compiler is finished installing
cd ..
git clone https://github.com/programmerjake/rv32.git
cd rv32/software
make
cd ..
# at this point the built bitstream is in output.bit
djtgcfg prog -d JtagHS2 -i 0 -f output.bit # program the FPGA

Simulating using Icarus Verilog

Doesn't require Xilinx's ISE or Digilent's programmer

sudo apt-get install git g++ autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
sudo mkdir /opt/riscv
sudo chown $USER /opt/riscv # so you don't need root when building; you can change back after building riscv-gnu-toolchain
git clone --recursive https://github.com/riscv/riscv-gnu-toolchain.git
export PATH=/opt/riscv/bin:"$PATH"
cd riscv-gnu-toolchain
./configure --prefix=/opt/riscv --with-arch=rv32i
make
sudo chown -R root:root /opt/riscv # change owner back to root as the compiler is finished installing
cd ..
git clone https://github.com/programmerjake/rv32.git
cd rv32/software
make ram0_byte0.hex
cd ..
iveriog -o rv32 -Wall *.v
vvp -n rv32 # doesn't terminate, press Ctrl+C when it's generated enough output

The output is in dump.vcd, which can be viewed with GTKWave.

Building the hardware (only required if verilog source is modified)

Requires having built the software at least once to generate the ram initialization files.

Run (. /opt/Xilinx/14.7/ISE_DS/settings64.sh; ise&) in a terminal.
Switch the view to Implementation
Select main.v
Run "Generate Programming File"
Open a terminal and run:

export PATH=/opt/riscv/bin:"$PATH"
cd rv32/software
make
cd ..
# at this point the built bitstream is in output.bit
djtgcfg prog -d JtagHS2 -i 0 -f output.bit # program the FPGA

rv32's People

Contributors

programmerjake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rsrg

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.