目录
实验测试环境说明
工具链:riscv-gnu-toolchain rvv-0.8分支
(由于RV-V拓展目前仍处于draft状态,该分支针对的0.8版的标准)
地址:https://github.com/riscv/riscv-gnu-toolchain/tree/rvv-0.8.x
用途:用于生成含RV-V拓展的二进制文件
测试环境:spike(riscv ISA的模拟器) + pk(一个代理内核)
spike地址:https://github.com/riscv/riscv-isa-sim
pk地址:https://github.com/riscv/riscv-pk
用途:测试运行含RV-V拓展的二进制文件
工具链安装与测试
#拉分支代码(需要科学上网,不然拉的很慢)
git clone -b rvv-0.8 git@github.com:riscv/riscv-gnu-toolchain.git
cd riscv-gnu-toolchain
git submodule update --init --recursive
#安装环境依赖
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
#设置RISCV环境变量并编译
mkdir build && cd build
export RISCV=/path/to/install
../configure --prefix=$RISCV
make linux
make install
工具链的外网下载问题可以通过国内的码云(Gitee)镜像来解决,细节可以参考我的另一篇博客:利用码云镜像快速拉取riscv-gnu-toolchain工具链
如果之前安装过不含V拓展的riscv-gnu-toolchain工具链(即主分支),建议把之前的工具链的环境变量先去掉,否则可能编译失败(因为含V拓展的工具链名字一样,会冲突)。
同时该工具链目前只支持将含V拓展的汇编文件(.s)转化为二进制文件(.o)。
测试文件:saxpy.s
# void
# saxpy(size_t n, const float a, const float *x, float *y)
# {
# size_t i;
# for (i=0; i<n; i++) y[i] = a * x[i] + y[i];
# }
#
# register arguments:
# a0