lowRISC的Ibex專案Hello World的仿真
記錄一下Ibex在Linux上仿真Hello World的具體流程
參考
運行環境
本文采樣的運行環境是 Ubuntu18.04
安裝各種包
采樣下面的命令(以后可能會升級,什么的,,,,,,)
sudo apt-get install autoconf bison build-essential clang-format curl \
doxygen flex g++ git libelf1 libelf-dev libftdi1-2 libftdi1-dev libssl-dev \
libusb-1.0-0 lsb-release make ninja-build pkgconf python3 python3-pip \
python3-setuptools python3-wheel python3-yaml srecord tree xsltproc \
zlib1g-dev xz-utils
git Ibex專案 并使用pip3安裝相關軟體包
mkdir ibex
cd ibex
git clone https://github.com/lowRISC/ibex
安裝相關python庫
pip3 install --user -r python-requirements.txt
安裝 RISC-V tool chain(這一步很慢,,,)
安裝的地方另起一個(不在ibex里面)
最好使用sudo make
我之前使用 make出現了很多錯誤,因為權限不夠,
安裝先決條件:一股腦裝就完事了,沒有裝就讓它裝,裝過了輸入此命令會提示裝過了,這波不虧,有點賺
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
git clone https://github.com/riscv/riscv-gnu-toolchain
./configure --prefix=/opt/riscv --with-arch=rv32imc --with-abi=ilp32
sudo make
添加安裝路徑到PATH(看了一個博客說一共有3種方法)
方法在這里,,,
本人采用的是第3種中,因為不想chmod
vi ~/.bash_profile
PATH=$PATH:~/.local/bin
source ~/.bash_profile
使用下面的命令驗證編譯工具是否安裝成功
which riscv32-unknown-elf-gcc
出現/opt/riscv/bin/riscv32-unknown-elf-gcc則說明成功了
安裝仿真軟體Verilator
什么是Verilator?老哥點這里
再次安裝相關依賴:(可能會重復安裝,系統會提醒,沒有關系的)
sudo apt-get install git make autoconf g++ flex bison
sudo apt-get install libfl2
sudo apt-get install libfl-dev
獲取安裝包
git clone https://git.veripool.org/git/verilator
unset VERILATOR_ROOT
安裝,沖!!
cd verilator
git pull
git tag
git checkout master
git checkout stable
git checkout v{version}
autoconf # Create ./configure script
./configure
make
make test
sudo make install
安裝FuseSoc工具
FuseSoc的作用跟Makefile的功能相似,由于Ibex已配置成FuseSoc可用的狀態,所以不用白不用,白嫖就完事,
git clone https://github.com/olofk/fusesoc
cd fusesoc
sudo pip install -e .
這里同樣也需要加路徑(FuseSoc的默認安裝路徑是~/.local/bin)
輸入which fusesoc驗證是否裝好
出現 .local/bin/fusesoc就說明ok了
開始跑Hello simple system
cd ibex
## Building Simulation
fusesoc --cores-root=. run --target=sim --setup --build lowrisc:ibex:ibex_simple_system --RV32M=1 --RV32E=0
## Building hello world
make -C examples/sw/simple_system/hello_test
## Running the Simulator
./build/lowrisc_ibex_ibex_simple_system_0/sim-verilator/Vibex_simple_system [-t] --raminit=<sw_vmem_file>
這里的<sw_vmem_file>是RISC-V的可執行檔案路徑,使用./examples/sw/simple_system/hello_test/hello_test.vmem 對于編譯好的hello world,使用,編譯出來的可執行檔案是Vibex_simple_system,–raminit=<sw_vmem_file>用于把編譯好的hello world RISC-V可執行代碼load到RAM里去,-t是用來生成GTKWave可看的waveform,可以不用加, 大功告成,最后Ibex的輸出寫在ibex_simple_system.log里,可以打開看看是否符合期望,由于Ibex帶了仿真的trace功能,指令trace資訊還會存在trace_core_00000000.log,(這里抄的別人的,覺得說得很好)
輸入上述命令的運行中間程序與結果

仿真的C語言截圖

運行的仿真結果,都把需要輸出的都列印了出來

trace_core的輸出:riscv CORE運行時的指令流、指令對應的機器碼,暫存器的操作以及對應的值

okk!!!!!!大功告成
接下跑一下Google的開源安全芯片專案:OPentitan——就是我,點我!!!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/250742.html
標籤:其他
