# Run CMSIS5 on Gem5 ## Prerequisites ### 1. compile and install riscv64 compiler branch : rvv-next ```bash git clone https://github.com/riscv-collab/riscv-gnu-toolchain git checkout rvv-next ``` ### 2. build gem5 Reference: https://www.gem5.org/documentation/general_docs/building ```bash python3 $(which scons) build/RISCV/gem5.opt ``` ## Build Code Repository: https://github.com/nycu-caslab/riscv-vectorized-benchmark-suite 1. checkout to `feature/pooling` branch 2. the folders containing CMSIS5 implementation are: - _pooling - _conv_gemm - _fullconnect - _activation ### 3. build code with riscv compiler Using GNU GCC: ```bash /opt/riscv/bin/riscv64-unknown-linux-gnu-gcc -march=rv64gcv -DUSE_RISCV_VECTOR -DRVV -I../include -o pooling.o pooling.c ``` Using Clang: ```bash export GCC_TOOLCHAIN_DIR=/tools/gcc-riscv-linux-rvv clang --target=riscv64-unknown-elf \ -march=rv64gcv1p0 \ --gcc-toolchain=${GCC_TOOLCHAIN_DIR} \ -DUSE_RISCV_VECTOR -static -g -w \ -I ../include \ -o ./${TARGET}.o ./${TARGET}.c ``` ## Run the Bin File on qemu Run the bin file on qemu for function validation. ```bash qemu-riscv64 -cpu rv64,v=true,vlen=128,elen=64,vext_spec=v1.0 ./pooling.o ``` ```bash= --target=riscv64-unknown-linux-gnu -march=rv64gcv0p10 -menable-experimental-extensions --gcc-toolchain=${GCC_TOOLCHAIN_DIR} --sysroot=${GCC_TOOLCHAIN_DIR}sysroot -flax-vector-conversions -DUSE_RISCV_VECTOR -static -g -c -w -o ```