ci: add npc difftest
Some checks failed
Run CTests within npc / build-abstract-machine (push) Failing after 6m34s

This commit is contained in:
xinyangli 2024-04-05 11:30:52 +08:00
parent 6f7d7ba383
commit 90be25efc4
Signed by: xin
SSH key fingerprint: SHA256:qZ/tzd8lYRtUFSrfBDBMcUqV4GHKxqeqRA3huItgvbk
7 changed files with 119 additions and 12 deletions

View file

@ -0,0 +1,22 @@
name: Run CTests within npc
on: [push]
jobs:
build-abstract-machine:
runs-on: nix
steps:
- uses: https://github.com/cachix/cachix-action@v14
with:
name: ysyx
authToken: '${{ secrets.CACHIX_SIGNING_KEY }}'
- uses: actions/checkout@v4
with:
submodules: true
- name: Run tests
run: |
nix develop .#npc
mkdir -p npc/build
cd npc/build
cmake $cmakeFlags ../
make -j8
make test

View file

@ -50,6 +50,7 @@
};
};
packages.nemu = pkgs.callPackage ./nemu { am-kernels = self.packages.${system}.am-kernels; };
packages.nemu-lib = pkgs.callPackage ./nemu { am-kernels = self.packages.${system}.am-kernels; defconfig = "riscv32-lib_defconfig"; };
packages.abstract-machine = crossPkgs.callPackage ./abstract-machine { isa = "riscv"; platform = "nemu"; };
packages.am-kernels = crossPkgs.stdenv.mkDerivation rec {
@ -82,6 +83,7 @@
inputsFrom = [
self.packages.${system}.nemu
];
IMAGES_PATH = "${self.packages.${system}.am-kernels}/share/binary";
};
devShells.npc = with pkgs; mkShell {
@ -114,6 +116,10 @@
verilator
nvboard
] ++ self.checks.${system}.pre-commit-check.enabledPackages;
cmakeFlags = [
"-DDIFFTEST_LIB:string=${self.packages.${system}.nemu-lib}/lib/riscv32-nemu-interpreter-so"
];
};
}
);

View file

@ -0,0 +1,72 @@
#
# Automatically generated file; DO NOT EDIT.
# NEMU Configuration Menu
#
# CONFIG_ISA_x86 is not set
# CONFIG_ISA_mips32 is not set
CONFIG_ISA_riscv=y
# CONFIG_ISA_loongarch32r is not set
CONFIG_ISA="riscv32"
#
# ISA-dependent Options for riscv
#
# CONFIG_RV64 is not set
# CONFIG_RVE is not set
# end of ISA-dependent Options for riscv
CONFIG_ENGINE_INTERPRETER=y
CONFIG_ENGINE="interpreter"
CONFIG_MODE_SYSTEM=y
# CONFIG_TARGET_NATIVE_ELF is not set
CONFIG_TARGET_SHARE=y
# CONFIG_TARGET_AM is not set
#
# Build Options
#
CONFIG_CC_GCC=y
# CONFIG_CC_GPP is not set
# CONFIG_CC_CLANG is not set
CONFIG_CC="gcc"
# CONFIG_CC_O0 is not set
# CONFIG_CC_O1 is not set
CONFIG_CC_O2=y
# CONFIG_CC_O3 is not set
CONFIG_CC_OPT="-O2"
CONFIG_CC_LTO=y
CONFIG_CC_DEBUG=y
# CONFIG_CC_ASAN is not set
# end of Build Options
#
# Testing and Debugging
#
CONFIG_LOG_TRACE=y
# CONFIG_LOG_INFO is not set
# CONFIG_LOG_WARNING is not set
# CONFIG_LOG_ERROR is not set
CONFIG_LOG_LEVEL=4
# CONFIG_TRACE is not set
CONFIG_DIFFTEST_REF_PATH="none"
CONFIG_DIFFTEST_REF_NAME="none"
# end of Testing and Debugging
#
# Memory Configuration
#
CONFIG_MBASE=0x80000000
CONFIG_MSIZE=0x8000000
CONFIG_PC_RESET_OFFSET=0
# CONFIG_PMEM_MALLOC is not set
CONFIG_PMEM_GARRAY=y
CONFIG_MEM_RANDOM=y
# end of Memory Configuration
#
# Miscellaneous
#
CONFIG_TIMER_GETTIMEOFDAY=y
# CONFIG_TIMER_CLOCK_GETTIME is not set
CONFIG_RT_CHECK=y
# end of Miscellaneous

View file

@ -2,7 +2,8 @@
lib,
stdenv,
am-kernels,
dtc
dtc,
defconfig ? "alldefconfig",
}:
stdenv.mkDerivation rec {
@ -31,27 +32,27 @@ stdenv.mkDerivation rec {
configurePhase = ''
export NEMU_HOME=$(pwd)
make alldefconfig
make ${defconfig}
'';
buildPhase = ''
make
'';
doCheck = true;
checkPhase = ''
doCheck = (defconfig == "alldefconfig");
checkPhase = if doCheck then ''
export IMAGES_PATH=${am-kernels}/share/binary
make test
'';
'' else "";
installPhase = ''
mkdir -p $out/bin
mkdir -p $out/lib
make PREFIX=$out install
'';
shellHook = ''
export NEMU_HOME=$(pwd)
export IMAGES_PATH=${am-kernels}/share/binary
'';
meta = with lib; {

View file

@ -76,8 +76,13 @@ $(BINARY):: $(OBJS) $(ARCHIVES)
@$(LD) -o $@ $(OBJS) $(LDFLAGS) $(ARCHIVES) $(LIBS)
install: $(BINARY)
ifeq ($(SHARE),1)
@mkdir -p $(PREFIX)/lib
@cp $(BINARY) $(PREFIX)/lib/
else
@mkdir -p $(PREFIX)/bin
@cp $(BINARY) $(PREFIX)/bin/
endif
clean:
-rm -rf $(BUILD_DIR)

View file

@ -15,6 +15,7 @@ option(BUILD_SIM_TARGET "Whether to build verilator simulation binary" ON)
cmake_dependent_option(BUILD_SIM_NVBOARD_TARGET "Whether to build nvboard target" OFF "BUILD_SIM_TARGET" OFF)
option(ENABLE_YSYX_GIT_TRACKER "Ysyx tracker support" OFF)
set(TOPMODULE "Flow" CACHE STRING "Topmodule name in chisel")
set(DIFFTEST_LIB "" CACHE STRING "Dynamic library file used as difftest reference")
# -- Ysyx tracker, configure
if(ENABLE_YSYX_GIT_TRACKER)
@ -61,12 +62,6 @@ include_directories(include)
add_subdirectory(csrc)
add_test(
NAME V${TOPMODULE}
COMMAND V${TOPMODULE}
--no-bin -m ${PROJECT_SOURCE_DIR}/resource/addi.txt
--diff-lib /home/xin/repo/ysyx-workbench/nemu/build/riscv32-nemu-interpreter-so)
# -- Add build tracking
if(ENABLE_YSYX_GIT_TRACKER)
add_custom_command(

View file

@ -9,3 +9,9 @@ verilate(V${TOPMODULE} TRACE COVERAGE THREADS
VERILATOR_ARGS
"--vpi" # Enable VPI
)
add_test(
NAME V${TOPMODULE}
COMMAND V${TOPMODULE}
--no-bin -m ${PROJECT_SOURCE_DIR}/resource/addi.txt
--diff-lib ${DIFFTEST_LIB})