Skip to content

vcs: add support for --max-instrs option #858

vcs: add support for --max-instrs option

vcs: add support for --max-instrs option #858

Workflow file for this run

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[3.6.0].compile
mill -i design[6.0.0].compile
- name: Generate Verilog
run: |
make difftest_verilog NOOP_HOME=$GITHUB_WORKSPACE
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 [email protected]:
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: 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
sed -i 's/isBatch: Boolean = false/isBatch: Boolean = true/' difftest/src/main/scala/Gateway.scala
make emu -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
cd difftest && git restore src
- 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
sed -i 's/hasGlobalEnable: Boolean = false/hasGlobalEnable: Boolean = true/' difftest/src/main/scala/Gateway.scala
make emu -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
cd difftest && git restore src
- 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
sed -i 's/hasGlobalEnable: Boolean = false/hasGlobalEnable: Boolean = true/' difftest/src/main/scala/Gateway.scala
sed -i 's/isSquash: Boolean = false/isSquash: Boolean = true/' difftest/src/main/scala/Gateway.scala
make emu -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
cd difftest && git restore src
- 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
sed -i 's/isSquash: Boolean = false/isSquash: Boolean = true/' difftest/src/main/scala/Gateway.scala
sed -i 's/isBatch: Boolean = false/isBatch: Boolean = true/' difftest/src/main/scala/Gateway.scala
sed -i 's/hasGlobalEnable: Boolean = false/hasGlobalEnable: Boolean = true/' difftest/src/main/scala/Gateway.scala
make emu -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
cd difftest && git restore src
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 [email protected]:
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 [email protected]:
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 (with DutZone PerfCnt)
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
sed -i 's/hasDutZone: Boolean = false/hasDutZone: Boolean = true/' difftest/src/main/scala/Gateway.scala
make simv 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 Squash DutZone Batch and Global Enable PerfCnt)
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
sed -i 's/isSquash: Boolean = false/isSquash: Boolean = true/' difftest/src/main/scala/Gateway.scala
sed -i 's/hasDutZone: Boolean = false/hasDutZone: Boolean = true/' difftest/src/main/scala/Gateway.scala
sed -i 's/isBatch: Boolean = false/isBatch: Boolean = true/' difftest/src/main/scala/Gateway.scala
sed -i 's/hasGlobalEnable: Boolean = false/hasGlobalEnable: Boolean = true/' difftest/src/main/scala/Gateway.scala
make simv 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