# Final project ## Install riscv-gnu-toolchain ### Getting the sources ```bash= git clone https://github.com/riscv/riscv-gnu-toolchain cd riscv-gnu-toolchain git submodule update --init --recursive ``` ### Prerequisites On Ubuntu, executing the following command should suffice: ```bash= sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build ``` ### Installation (Linux) To build the Linux cross-compiler, pick an install path. If you choose, say, /opt/riscv, then add /opt/riscv/bin to your PATH now. ```bash= vim ~/.bashrc export RISCV="/opt/riscv" export PATH=$PATH:$RISCV/bin :wq #save and quit source ~/.bashrc ``` Create a directory in opt ```bash= cd /opt sudo mkdir riscv sudo chown $USER riscv ``` Then, simply run the following command: ```bash= cd riscv-gnu-toolchain ./configure --prefix=$RISCV make linux ``` ## MEMZERO and MEMCOPY instructions [MEMZERO and MEMCOPY instructions](https://github.com/AndyGlew/Ri5-stuff/wiki/MEMZERO-and-MEMCOPY-instructions-proposal) ## Install riscv-opcodes ```bash= git clone https://github.com/riscv/riscv-opcodes ``` ## Install crosstool-NG ```bash= $ git clone https://github.com/crosstool-ng/crosstool-ng $ cd crosstool-ng $ ./bootstrap $ ./configure --prefix=/opt/crosstool-ng $ make $ make install $ export PATH="${PATH}:/opt/crosstool-ng/bin" $ source ~/.bashrc ``` ![](https://i.imgur.com/oZ00sLh.png) In `./configure` step, it may have some configure error and just install the relative tool. For example, ```bash= configure: error: missing required tool: help2man $ sudo apt-get install help2man ``` Note that if after the `libtool` installation is complete, re-execute the ./configure configuration command again, and find that the configuration is still wrong, and the same error is reported, try install `libtool-bin`: ```bash= configure: error: missing required tool: libtool $ sudo apt-get install libtool $ ./configure --prefix=/opt/crosstool-ng configure: error: missing required tool: libtool $ sudo apt-get install libtool-bin ``` ```bash= configure: error: curses library not found $ sudo apt-get install libncurses5-dev ``` ## Install riscv-tools ```bash= git clone https://github.com/riscv/riscv-tools.git cd riscv-tools git submodule update --init --recursive ./build.sh ``` - Modify the file `Makefile` in `riscv-tools/riscv-opcodes/`: ![](https://i.imgur.com/NS4nZuG.png) - Modify the file `parse-opcodes` in `riscv-tools/riscv-opcodes/`: `#!/usr/bin/python` change to `#!/usr/bin/python2` Now we will add a "MEMZERO" and "MEMCOPY" instruction to the ISA. The instruction and its semantics are given below: Open the file `riscv-opcodes/opcodes`, here you will be able to see the various opcodes and instruction bits assigned to various instructions. Assigned an unused instruction to modulo inst. ## Study PicoRV32 ### PicoRV32 [PicoRV32](https://github.com/YosysHQ/picorv32) is a CPU core that implements the [RISC-V RV32IMC Instruction Set](https://riscv.org/). It can be configured as RV32E, RV32I, RV32IC, RV32IM, or RV32IMC core, and optionally contains a built-in interrupt controller. ## References 1. [How to change permission of /root/opt while it is owned by root](https://askubuntu.com/questions/326460/how-to-change-permission-of-root-opt-while-it-is-owned-by-root) 2. [riscv-gnu-toolchain](https://github.com/riscv-collab/riscv-gnu-toolchain) 3.