FPGA: Add the function of fpga core difftest #1663
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: | |
jobs: | |
test-difftest-main: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Mill Installation | |
run: | | |
sudo curl -L https://github.com/com-lihaoyi/mill/releases/download/0.11.1/0.11.1 > /usr/local/bin/mill | |
chmod +x /usr/local/bin/mill | |
- name: Compile | |
run: | | |
mill -i design[chisel3].compile | |
mill -i design[chisel].compile | |
- name: Generate Verilog | |
run: | | |
make MFC=0 | |
make MFC=1 | |
test-difftest-nutshell: | |
runs-on: ubuntu-22.04 | |
needs: test-difftest-main | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Enable -Werror for EMU Build | |
run: | | |
echo "CXX_NO_WARNING=1" >> $GITHUB_ENV | |
- name: Prepare environment | |
run: | | |
cd $GITHUB_WORKSPACE/.. | |
git config --global url."https://github.com/".insteadOf git@github.com: | |
git config --global url."https://".insteadOf git:// | |
git clone https://github.com/OpenXiangShan/xs-env | |
cd xs-env | |
sudo -s ./setup-tools.sh | |
source ./setup.sh | |
- name: Prepare NutShell | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
rm -r NutShell | |
git clone -b dev-difftest --single-branch https://github.com/OSCPU/NutShell.git | |
cd NutShell && git submodule update --init | |
rm -r difftest | |
cp -r $GITHUB_WORKSPACE . | |
- name: Simulation without DiffTest | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make emu NO_DIFF=1 EMU_TRACE=1 -j2 | |
./build/emu -b 0 -e 100 -i ./ready-to-run/microbench.bin --dump-wave -C 10000 | |
./build/emu -b 0 -e 100 -i ./ready-to-run/microbench.bin --dump-wave-full -C 10000 | |
- name: Simulation with No Diff | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make emu -j2 | |
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --no-diff | |
- name: Basic Difftest | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Basic Difftest without Image | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
./build/emu -b 0 -e 0 --no-diff -C 10000 | |
- name: Basic Difftest with PGO build | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make -C ./difftest clean_obj | |
make emu PGO_WORKLOAD=`realpath ready-to-run/microbench.bin` LLVM_PROFDATA=llvm-profdata PGO_EMU_ARGS="--diff `realpath ./ready-to-run/riscv64-nemu-interpreter-so` 2>/dev/null" -j2 | |
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Difftest with Snapshot | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make emu EMU_SNAPSHOT=1 -j2 | |
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Difftest with Trace | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make emu EMU_TRACE=1 -j2 | |
./build/emu -b 10 -e 12 -i ./ready-to-run/microbench.bin --dump-wave --diff ./ready-to-run/riscv64-nemu-interpreter-so | |
./build/emu -b 10 -e 12 -i ./ready-to-run/microbench.bin --dump-wave-full --diff ./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Difftest with two threads | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make emu EMU_THREADS=2 -j2 | |
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Difftest with Verilator Coverage | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
rm -rf *.coverage | |
make emu EMU_COVERAGE=1 -j2 | |
./build/emu -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so -C 10000 --dump-coverage | |
make -C difftest coverage | |
ls -lh *.coverage | |
- name: Difftest with DiffTrace | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make emu -j2 | |
./build/emu -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so --dump-difftrace microbench | |
./build/emu -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so --load-difftrace microbench | |
- name: Difftest with Footprints | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make emu -j2 | |
./build/emu -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so --dump-footprints microbench.bin | |
./build/emu -e 0 -i microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so --as-footprints | |
- name: Difftest with Batch | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make emu MILL_ARGS="--difftest-config B" -j2 | |
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Difftest with Global DPI-C Enable | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make emu MILL_ARGS="--difftest-config E" -j2 | |
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Difftest with Squash and Global Enable | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make emu MILL_ARGS="--difftest-config ES" -j2 | |
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Difftest with Squash Batch and Global Enable | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make emu MILL_ARGS="--difftest-config ESB" -j2 | |
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Difftest with JsonProfile and DiffTestIOTrace | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make emu MILL_ARGS="--difftest-config ET" -j2 | |
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so --iotrace-name iotrace | |
cd difftest && export NOOP_HOME=$(pwd) | |
make difftest_verilog PROFILE=../build/generated-src/difftest_profile.json NUMCORES=1 CONFIG=EL MFC=1 | |
make emu WITH_CHISELDB=0 WITH_CONSTANTIN=0 -j2 | |
./build/emu -b 0 -e 0 -i ../ready-to-run/microbench.bin --diff ../ready-to-run/riscv64-nemu-interpreter-so --iotrace-name ../iotrace | |
- name: Difftest with JsonProfile and DiffTestIOTrace-ZSTD | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make emu MILL_ARGS="--difftest-config ET" IOTRACE_ZSTD=1 -j2 | |
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so --iotrace-name iotrace | |
cd difftest && export NOOP_HOME=$(pwd) | |
make difftest_verilog PROFILE=../build/generated-src/difftest_profile.json NUMCORES=1 CONFIG=EL MFC=1 | |
make emu WITH_CHISELDB=0 WITH_CONSTANTIN=0 IOTRACE_ZSTD=1 -j2 | |
./build/emu -b 0 -e 0 -i ../ready-to-run/microbench.bin --diff ../ready-to-run/riscv64-nemu-interpreter-so --iotrace-name ../iotrace | |
test-difftest-fuzzing: | |
# This test runs on ubuntu-20.04 for two reasons: | |
# (1) riscv-arch-test can be built with riscv-linux-gnu toolchain 9.4.0, | |
# which is the default apt-installed version on ubuntu 20.04. | |
# On ubuntu 22.04, toolchain 11.4.0 won't compile riscv-arch-test. | |
# (2) to test whether difftest compiles correctly on ubuntu 20.04 | |
runs-on: ubuntu-20.04 | |
needs: test-difftest-main | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Enable -Werror for EMU Build | |
run: | | |
echo "CXX_NO_WARNING=1" >> $GITHUB_ENV | |
- name: Prepare environment | |
run: | | |
cd $GITHUB_WORKSPACE/.. | |
git config --global url."https://github.com/".insteadOf git@github.com: | |
git config --global url."https://".insteadOf git:// | |
git clone https://github.com/OpenXiangShan/xs-env | |
cd xs-env | |
sudo -s ./setup-tools.sh | |
- name: Build the coverage-guided fuzzer - xfuzz | |
run: | | |
cd $GITHUB_WORKSPACE/.. | |
git clone https://github.com/OpenXiangShan/xfuzz.git | |
cargo install cargo-make | |
cd xfuzz && make init && make build | |
- name: Build the fuzzing corpus - riscv-arch-test | |
run: | | |
cd $GITHUB_WORKSPACE/.. | |
git clone https://github.com/OpenXiangShan/riscv-arch-test.git | |
cd riscv-arch-test/riscv-test-suite | |
make build_I CROSS=riscv64-linux-gnu- RISCV_ARCH=rv64gc -j2 | |
rm build/*.elf build/*.txt | |
- name: Build the REF - LLVM instrumented Spike | |
run: | | |
cd $GITHUB_WORKSPACE/.. | |
git clone https://github.com/OpenXiangShan/riscv-isa-sim.git | |
export SPIKE_HOME=$(pwd)/riscv-isa-sim | |
make -C riscv-isa-sim/difftest CPU=ROCKET_CHIP SANCOV=1 -j2 | |
- name: Build and run the rocket-chip fuzzer | |
run: | | |
cd $GITHUB_WORKSPACE/.. | |
export SPIKE_HOME=$(pwd)/riscv-isa-sim | |
export XFUZZ_HOME=$(pwd)/xfuzz | |
export NOOP_HOME=$(pwd)/rocket-chip | |
export CORPUS=$(pwd)/riscv-arch-test/riscv-test-suite/build | |
git clone -b dev-difftest --single-branch https://github.com/OpenXiangShan/rocket-chip.git | |
cd rocket-chip && make init | |
rm -r difftest | |
cp -r $GITHUB_WORKSPACE . | |
make bootrom CROSS=riscv64-linux-gnu- | |
make emu XFUZZ=1 REF=$SPIKE_HOME/difftest/build/riscv64-spike-so LLVM_COVER=1 -j2 | |
./build/fuzzer -v -- $CORPUS/I-add-01.bin | |
./build/fuzzer -f --max-runs 100 --corpus-input $CORPUS -- --max-cycles 10000 | grep max_runs | |
test-difftest-vcs: | |
runs-on: ubuntu-22.04 | |
needs: test-difftest-main | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Enable -Werror for EMU Build | |
run: | | |
echo "CXX_NO_WARNING=1" >> $GITHUB_ENV | |
- name: Prepare environment | |
run: | | |
cd $GITHUB_WORKSPACE/.. | |
git config --global url."https://github.com/".insteadOf git@github.com: | |
git config --global url."https://".insteadOf git:// | |
git clone https://github.com/OpenXiangShan/xs-env | |
cd xs-env | |
sudo -s ./setup-tools.sh | |
source ./setup.sh | |
- name: Prepare NutShell | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
rm -r NutShell | |
git clone -b dev-difftest --single-branch https://github.com/OSCPU/NutShell.git | |
cd NutShell && git submodule update --init | |
rm -r difftest | |
cp -r $GITHUB_WORKSPACE . | |
- name: Verilator Build with VCS Top (NO_DIFF) | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make simv NO_DIFF=1 VCS=verilator -j2 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +max-cycles=100000 | |
- name: Verilator Build with VCS Top (SYNTHESIS)(with DutZone) | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make simv MILL_ARGS="--difftest-config Z" SYNTHESIS=1 VCS=verilator -j2 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +no-diff +max-cycles=100000 | |
- name: Verilator Build with VCS Top (disable DPIC RAM/FLASH)(with DutZone) | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make simv MILL_ARGS="--difftest-config Z" DISABLE_DIFFTEST_RAM_DPIC=1 DISABLE_DIFFTEST_FLASH_DPIC=1 VCS=verilator -j2 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +no-diff +max-cycles=100000 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Verilator Build with VCS Top (with DutZone PerfCnt) | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make simv MILL_ARGS="--difftest-config ZP" DIFFTEST_PERFCNT=1 VCS=verilator -j2 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +no-diff +max-cycles=100000 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Verilator Build with VCS Top (with Batch InternalStep PerfCnt) | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make simv MILL_ARGS="--difftest-config BIP" DIFFTEST_PERFCNT=1 VCS=verilator -j2 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +no-diff +max-cycles=100000 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Verilator Build with VCS Top (with GlobalEnable Squash Replay Batch PerfCnt) | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make simv MILL_ARGS="--difftest-config ESRBP" DIFFTEST_PERFCNT=1 VCS=verilator -j2 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +no-diff +max-cycles=100000 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Verilator Build with VCS Top (with GlobalEnable Squash Replay Batch InternalStep NonBlock PerfCnt) | |
run: | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make simv MILL_ARGS="--difftest-config ESRBINP" DIFFTEST_PERFCNT=1 VCS=verilator -j2 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +no-diff +max-cycles=100000 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so | |
- name: Verilator Build with VCS Top (with workload-list) | |
run : | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
echo "./ready-to-run/microbench.bin 10000" > list.txt | |
echo "./ready-to-run/linux.bin 20000" >> list.txt | |
make simv VCS=verilator WORKLOAD_SWITCH=1 -j2 | |
./build/simv +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so +workload-list=./list.txt | |
- name: Verilator Build with VCS Top (with JsonProfile and DiffTestIOTrace) | |
run : | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make simv MILL_ARGS="--difftest-config ZET" VCS=verilator -j2 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so +iotrace-name=iotrace | |
cd difftest && export NOOP_HOME=$(pwd) | |
make difftest_verilog PROFILE=../build/generated-src/difftest_profile.json NUMCORES=1 CONFIG=ZEL MFC=1 | |
make simv VCS=verilator WITH_CHISELDB=0 WITH_CONSTANTIN=0 | |
./build/simv +workload=../ready-to-run/microbench.bin +e=0 +diff=../ready-to-run/riscv64-nemu-interpreter-so +iotrace-name=../iotrace | |
- name: Verilator Build with VCS Top (with JsonProfile and DiffTestIOTrace-ZSTD) | |
run : | | |
cd $GITHUB_WORKSPACE/../xs-env | |
source ./env.sh | |
cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
source ./env.sh | |
make clean | |
make simv MILL_ARGS="--difftest-config ZET" VCS=verilator IOTRACE_ZSTD=1 -j2 | |
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so +iotrace-name=iotrace | |
cd difftest && export NOOP_HOME=$(pwd) | |
make difftest_verilog PROFILE=../build/generated-src/difftest_profile.json NUMCORES=1 CONFIG=ZEL MFC=1 | |
make simv VCS=verilator WITH_CHISELDB=0 WITH_CONSTANTIN=0 IOTRACE_ZSTD=1 | |
./build/simv +workload=../ready-to-run/microbench.bin +e=0 +diff=../ready-to-run/riscv64-nemu-interpreter-so +iotrace-name=../iotrace | |
# test-difftest-fpga: | |
# runs-on: ubuntu-22.04 | |
# needs: test-difftest-main | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Prepare environment | |
# run: | | |
# cd $GITHUB_WORKSPACE/.. | |
# git config --global url."https://github.com/".insteadOf git@github.com: | |
# git config --global url."https://".insteadOf git:// | |
# git clone https://github.com/OpenXiangShan/xs-env | |
# cd xs-env | |
# sudo -s ./setup-tools.sh | |
# source ./setup.sh | |
# - name: Prepare NutShell | |
# run: | | |
# cd $GITHUB_WORKSPACE/../xs-env | |
# rm -r NutShell | |
# git clone -b dev-difftest --single-branch https://github.com/OSCPU/NutShell.git | |
# cd NutShell && git submodule update --init | |
# rm -r difftest | |
# cp -r $GITHUB_WORKSPACE . | |
# - name: Enable -Werror for EMU Build | |
# run: | | |
# echo "CXX_NO_WARNING=1" >> $GITHUB_ENV | |
# - name: FPGA-difftest Build | |
# run: | | |
# cd $GITHUB_WORKSPACE/../xs-env | |
# source ./env.sh | |
# cd $GITHUB_WORKSPACE/../xs-env/NutShell | |
# source ./env.sh | |
# make clean | |
# make sim-verilog MILL_ARGS="--difftest-config ENBF" -j2 | |
# make fpga-build DMA_CHANNELS=2 WITH_CHISELDB=0 WITH_CONSTANTIN=0 |