跳转至

救命指南

仓库

克隆仓库到本地

git clone git@github.com:alwaysmissin/ysyx-workbench.git
切换到指定的分支
git checkout -b <branch-name> origin/<branch-name>
拉取仓库中的子项目
git submodule update

ysyx 环境变量配置

将以下的配置添加到 shell 对应的配置文件中, 对环境变量进行初始化

export YSYX_HOME=<path-to-ysyx-workbench>
export NPC_HOME=$YSYX_HOME/npc
export AM_HOME=$YSYX_HOME/abstract-machine
export NVBOARD_HOME=$YSYX_HOME/nvboard
export NEMU_HOME=$YSYX_HOME/nemu
export NAVY_HOME=$YSYX_HOME/navy-apps

工具链配置

verilator

通过 git 安装 5.008 版本 Installation — Verilator Devel 5.031 documentation

# Prerequisites:
#sudo apt-get install git help2man perl python3 make autoconf g++ flex bison ccache
#sudo apt-get install libgoogle-perftools-dev numactl perl-doc
#sudo apt-get install libfl2  # Ubuntu only (ignore if gives error)
#sudo apt-get install libfl-dev  # Ubuntu only (ignore if gives error)
#sudo apt-get install zlibc zlib1g zlib1g-dev  # Ubuntu only (ignore if gives error)

git clone https://github.com/verilator/verilator   # Only first time

# Every time you need to build:
unsetenv VERILATOR_ROOT  # For csh; ignore error if on bash
unset VERILATOR_ROOT  # For bash
cd verilator
git pull         # Make sure git repository is up-to-date
git tag          # See what versions exist
#git checkout master      # Use development branch (e.g. recent bug fixes)
#git checkout stable      # Use most recent stable release
#git checkout v{version}  # Switch to specified release version
git checkout v5.008

autoconf         # Create ./configure script
./configure      # Configure and create Makefile
make -j `nproc`  # Build Verilator itself (if error, try just 'make')
sudo make install

riscv 交叉编译链

riscv64-gnu-*

直接通过 apt 安装

sudo apt install binutils-riscv64-linux-gnu 
sudo apt install gcc-riscv64-linux-gnu
sudo apt install g++-riscv64-linux-gnu
修改头文件
--- /usr/riscv64-linux-gnu/include/gnu/stubs.h
+++ /usr/riscv64-linux-gnu/include/gnu/stubs.h
@@ -5,5 +5,5 @@
 #include <bits/wordsize.h>

 #if __WORDSIZE == 32 && defined __riscv_float_abi_soft
-# include <gnu/stubs-ilp32.h>
+//# include <gnu/stubs-ilp32.h>
 #endif

riscv64-unknown-gnu-* (optional)

拉取并编译

git clone git@github.com:riscv-collab/riscv-gnu-toolchain.git
sudo apt-get install autoconf automake autotools-dev curl python3 python3-pip python3-tomli libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev
cd riscv-gnu-toolchain
./configure --prefix=/opt/riscv
make linux
添加环境变量
export PATH="$PATH:/opt/riscv/bin"

npc 相关

通过 mill 使用 scala

  1. 安装 jdk : sudo apt install openjdk-17-jdk
  2. 直接安装 mill
    # Mac/Linux 
    curl -L https://github.com/com-lihaoyi/mill/releases/download/0.12.4/0.12.4 > mill && chmod +x mill
    echo 0.12.4 > .mill-version
    

真值表优化器 espresso

curl -L https://github.com/chipsalliance/espresso/releases/download/v2.4/x86_64-linux-gnu-espresso > ./espresso
chmod +x espresso
sudo mv ./espresso /usr/local/bin

yosys-sta

sudo apt install -y yosys libunwind-dev libyaml-cpp-dev libgomp1 libtcl8.6
cd $NPC_HOME/yosys-sta
make init

其他相关工具链或依赖

 # menuconfig 依赖
sudo apt-get install libncurses5-dev libncursesw5-dev
# readline
sudo apt install libreadline-dev
# llvm
sudo apt install llvm
# sdl2
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev

先在 nemu 目录下进行 menuconfig 的生成

cd $(NEMU_HOME)
make menuconfig
将 nemu 中生成的 tools/kconfig/build 目录复制到 $(NPC_HOME)/tools/kconfig 中, 再进行 npc 的 menuconfig 生成
cp -r $NEMU_HOME/tools/kconfig/build $(NPC_HOME)/tools/kconfig
cd $NPC_HOME
make menuconfig
这样才可以生成成功