Software

Run your own code

Step 1: Install the RISC-V toolchain

git clone https://github.com/riscv/riscv-gnu-toolchain
./configure --prefix=/opt/riscv --with-arch=rv32ima --with-abi=ilp32 --enable-multilib
make

Step 2: Setup your environment

Edit AsteRISC-firmware/riscv-env to set the path to your RISC-V toolchain installation.

For instance:

 7# RISC-V toolchain install path
 8RISCV_DIR=/opt/riscv
 9
10# Target triple <machine>-<vendor>-<os>
11RISCV_TT=riscv32-unknown-elf
12
13# Binary folder for gcc, as, ld, etc.
14RISCV_BIN=${RISCV_DIR}/bin
15
16# .a library folder for libc, etc
17RISCV_LIB=${RISCV_DIR}/${RISCV_TT}/lib
18
19# .h include folder for libc, etc
20RISCV_INC=${RISCV_DIR}/${RISCV_TT}/include
21
22# GCC library to use
23RISCV_GCC_LIB=rv32i/ilp32
24
25# Python3 command
26PYTHON3=python3

Step 3: Compile examples

make firmware

Step 4: Edit the default program

The default program is located in AsteRISC-firmware/firmware/user_programs/my_asterisc_program. You can edit the source code in src/my_asterisc_program.c.

Compile from the AsteRISC root directory or the AsteRISC-firmware directory with:

make firmware

Or from the my_asterisc_program directory with simply:

make

Step 5: Run a simulation of your program

make sim

Step 6: Add new programs

Follow the instructions in section User Programs to add new programs.