lowRISCV ibex:
https://github.com/lowRISC/ibex/tree/master
https://github.com/lowRISC/ibex/blob/master/examples/simple_system/README.md
如有错误之处还请不吝赐教!
1、安装说明
下面将对安装环境说明:
2、安装verilator:
推荐用4.220,5.0x会遇到下面问题,当然可以通过verilaor编译选项忽略;
https://github.com/lowRISC/ibex/issues/2039
建议使用官网4.220的source编译,方法如下(可以直接git ,4.22.0版本再安装);
https://github.com/verilator/verilator/releases/tag/v4.220
Prerequisites:
sudo apt-get install git make autoconf g++ flex bison
sudo apt-get install libfl2 # Ubuntu only (ignore if gives error)
sudo apt-get install libfl-dev # Ubuntu only (ignore if gives error)
如果是4.220版本,可以直接从这里下载:
https://github.com/verilator/verilator/releases/tag/v4.220
unsetenv VERILATOR_ROOT # For csh; ignore error if on bash
unset VERILATOR_ROOT # For bash
autoconf # Create ./configure script
./configure
make
sudo make install**
3、clone ibex &安装依赖包
①clone项目:
mkdir ibex
cd ibex
git clone https://github.com/lowRISC/ibex
②安装依赖包:
pip3 install --user -r python-requirements.txt
这里可能会出现Failed to connect to github.com port 443 after 21053 ms: Connection refused,需要多试几次;
这里python-requirements.txt是安装了fusesoc和依赖库;
这里需要说明fusesoc一定要0.1的版本,edalize一定要0.3.3的版本否则会出现不少问题!
所以只要最好严格按照python-requirements.txt下载就可以了.。
③记得添加环境变量:fusesoc在~/.local/bin下
export PATH=$PATH:~/.local/bin
4、RISC-V Compiler Toolchain
网上很多博客要自己编译Toolchain,其实这里不用自己编译,否则会时间很长,我们可以直接下载编译gcc工具,增加环境变量即可,如ibex所说;
①直接从/lowrisc-toolchains下载放在~/ 下,然后解压:
https://github.com/lowRISC/lowrisc-toolchains/releases
tar -xf lowrisc-toolchain-gcc-rv32imcb-20230811-1.tar.xz
②添加环境变量$LRISCV_GCC
export LRISCV_GCC="~/lowrisc-toolchain-gcc-rv32imcb-20230811-1/bin/"
export PATH=$PATH:~/.local/bin:$LRISCV_GCC
5、其他
apt-get install libelf-dev
apt-get install srecord
到这里所有软件环境都配置成功喽!
6、运行Hello World
方法一:
在ibex根目录下运行:
①通过fusesoc建立Simple System仿真bin:
fusesoc --cores-root=. run --target=sim --setup --build lowrisc:ibex:ibex_simple_system --RV32E=0 --RV32M=ibex_pkg::RV32MFast
会遇到找不到anytree的问题,可以忽略;
②编译hello world:
make -C examples/sw/simple_system/hello_test
③运行仿真:
./build/lowrisc_ibex_ibex_simple_system_0/sim-verilator/Vibex_simple_system [-t] --meminit=ram,./examples/sw/simple_system/hello_test/hello_test.elf
会看到如下结果,发现performance counter跟官网描述不同,所以这里需要在①增加
–MHPMCounterNum=10;
方法二:
在ibex根目录下:
①编译:
make build-simple-system
②运行:
make run-simple-system
7、遇到的问题及解决
问题1:Performance Counters不对
这里如官网描述不符,原因是默认–MHPMCounterNum=0所以这里计数没有工作;
解决:
在这里增加–MHPMCounterNum=10,问题解决。
https://github.com/lowRISC/ibex/issues/1866
问题2:无法生成波形的问题
按照官网加[-t]选项,无法生成波形;
解决:
这里尝试在运行时加**–trace --trace=sim.vcd**