Add lit tests for Kelvin SystemC HW simulation test
The simulation uses .bin format. Add custom command to generate the
binary file from ELF via objcopy.
Change-Id: I2a53188a3b9a012d48ef840bd70cfd8d25a3fcf5
diff --git a/audio_prep/mfcc_test.run b/audio_prep/mfcc_test.run
index 95e774d..23b584d 100644
--- a/audio_prep/mfcc_test.run
+++ b/audio_prep/mfcc_test.run
@@ -1,3 +1,4 @@
+// UNSUPPORTED: kelvin_hw
// RUN: ${TEST_RUNNER_CMD} %S/mfcc_test 2>&1 | tee %t
// RUN: cat %t | FileCheck %s
// CHECK: PASSED
diff --git a/cmake/riscv_iree_gcc.cmake b/cmake/riscv_iree_gcc.cmake
index c1d34e1..d484ae2 100644
--- a/cmake/riscv_iree_gcc.cmake
+++ b/cmake/riscv_iree_gcc.cmake
@@ -30,6 +30,7 @@
set(CMAKE_AR "${RISCV_TOOLCHAIN_ROOT}/bin/riscv32-unknown-elf-ar")
set(CMAKE_RANLIB "${RISCV_TOOLCHAIN_ROOT}/bin/riscv32-unknown-elf-ranlib")
set(CMAKE_STRIP "${RISCV_TOOLCHAIN_ROOT}/bin/riscv32-unknown-elf-strip")
+set(CMAKE_OBJCOPY "${RISCV_TOOLCHAIN_ROOT}/bin/riscv32-unknown-elf-objcopy")
set(RISCV_COMPILER_FLAGS "" CACHE STRING "RISC-V compiler flags for C, CXX, and ASM")
set(RISCV_COMPILER_FLAGS_CXX)
diff --git a/risp4ml/common/image_test.run b/risp4ml/common/image_test.run
index d8bf7c4..7afb694 100644
--- a/risp4ml/common/image_test.run
+++ b/risp4ml/common/image_test.run
@@ -1,3 +1,4 @@
+// UNSUPPORTED: kelvin_hw
// RUN: ${TEST_RUNNER_CMD} %S/image_test 2>&1 | tee %t
// RUN: cat %t | FileCheck %s
// CHECK: PASSED
diff --git a/risp4ml/isp_stages/CMakeLists.txt b/risp4ml/isp_stages/CMakeLists.txt
index ac2023b..59ed028 100644
--- a/risp4ml/isp_stages/CMakeLists.txt
+++ b/risp4ml/isp_stages/CMakeLists.txt
@@ -138,10 +138,26 @@
pw_assert_basic
TESTFILES
"wbg_test.run"
+ "wbg_bin_test.run"
+)
+
+if (${BUILD_WITH_KELVIN})
+# Kelvin-only systemc tests
+add_custom_command(
+ TARGET
+ risp4ml_isp_stages_wbg_test
+ POST_BUILD
+ COMMAND
+ ${CMAKE_OBJCOPY} -g -O binary
+ wbg_test
+ wbg_test.bin
+ BYPRODUCTS
+ wbg_test.bin
+ COMMENT
+ "Objcopy the binary file"
)
# Do not compile the following tests for Kelvin
-if (${BUILD_WITH_KELVIN})
return()
endif()
diff --git a/risp4ml/isp_stages/blc_test.run b/risp4ml/isp_stages/blc_test.run
index 830fef0..dcff7f0 100644
--- a/risp4ml/isp_stages/blc_test.run
+++ b/risp4ml/isp_stages/blc_test.run
@@ -1,3 +1,4 @@
+// UNSUPPORTED: kelvin_hw
// RUN: ${TEST_RUNNER_CMD} %S/blc_test 2>&1 | tee %t
// RUN: cat %t | FileCheck %s
// CHECK: PASSED
diff --git a/risp4ml/isp_stages/dg_test.run b/risp4ml/isp_stages/dg_test.run
index 86724e1..d18f528 100644
--- a/risp4ml/isp_stages/dg_test.run
+++ b/risp4ml/isp_stages/dg_test.run
@@ -1,3 +1,4 @@
+// UNSUPPORTED: kelvin_hw
// RUN: ${TEST_RUNNER_CMD} %S/dg_test 2>&1 | tee %t
// RUN: cat %t | FileCheck %s
// CHECK: PASSED
diff --git a/risp4ml/isp_stages/wbg_bin_test.run b/risp4ml/isp_stages/wbg_bin_test.run
new file mode 100644
index 0000000..efba30b
--- /dev/null
+++ b/risp4ml/isp_stages/wbg_bin_test.run
@@ -0,0 +1,2 @@
+// REQUIRES: kelvin_hw
+// RUN: ${TEST_RUNNER_CMD} %S/wbg_test.bin
diff --git a/risp4ml/isp_stages/wbg_test.run b/risp4ml/isp_stages/wbg_test.run
index 761aefb..cfdff4f 100644
--- a/risp4ml/isp_stages/wbg_test.run
+++ b/risp4ml/isp_stages/wbg_test.run
@@ -1,3 +1,4 @@
+// UNSUPPORTED: kelvin_hw
// RUN: ${TEST_RUNNER_CMD} %S/wbg_test 2>&1 | tee %t
// RUN: cat %t | FileCheck %s
// CHECK: PASSED
diff --git a/samples/branch_mul/CMakeLists.txt b/samples/branch_mul/CMakeLists.txt
index e45a432..0ab0419 100644
--- a/samples/branch_mul/CMakeLists.txt
+++ b/samples/branch_mul/CMakeLists.txt
@@ -25,4 +25,24 @@
"LINKER:--defsym=__tcm_length__=4M"
TESTFILES
"branch_mul.run"
+ "branch_mul_bin.run"
)
+
+# Kelvin-only systemc tests
+if (${BUILD_WITH_KELVIN})
+
+add_custom_command(
+ TARGET
+ samples_branch_mul_branch_mul_emitc_static
+ POST_BUILD
+ COMMAND
+ ${CMAKE_OBJCOPY} -g -O binary
+ branch_mul_emitc_static
+ branch_mul_emitc_static.bin
+ BYPRODUCTS
+ branch_mul_emitc_static.bin
+ COMMENT
+ "Objcopy the binary file"
+)
+
+endif()
diff --git a/samples/branch_mul/branch_mul.run b/samples/branch_mul/branch_mul.run
index 5f8c701..b8dcfdb 100644
--- a/samples/branch_mul/branch_mul.run
+++ b/samples/branch_mul/branch_mul.run
@@ -1 +1,2 @@
+// UNSUPPORTED: kelvin_hw
// RUN: ${TEST_RUNNER_CMD} %S/branch_mul_emitc_static
diff --git a/samples/branch_mul/branch_mul_bin.run b/samples/branch_mul/branch_mul_bin.run
new file mode 100644
index 0000000..e91b92a
--- /dev/null
+++ b/samples/branch_mul/branch_mul_bin.run
@@ -0,0 +1,2 @@
+// REQUIRES: kelvin_hw
+// RUN: ${TEST_RUNNER_CMD} %S/branch_mul_emitc_static.bin
diff --git a/samples/lit.cfg.py b/samples/lit.cfg.py
index d94a4d0..c4e2590 100644
--- a/samples/lit.cfg.py
+++ b/samples/lit.cfg.py
@@ -36,6 +36,9 @@
kelvin_cmd = (
f"{config.environment['ROOTDIR']}/sw/kelvin/build_tools/test_runner.sh ")
+kelvin_hw_cmd = (
+ f"{config.environment['ROOTDIR']}/sw/kelvin/build_tools/core_sim_test_runner.sh "
+)
qemu_cmd = (f"{config.environment['ROOTDIR']}/sw/vec/scripts/test_runner.py "
"qemu --qemu-path "
f"{config.environment['OUT']}/host/qemu/qemu-system-riscv32")
@@ -57,6 +60,9 @@
if runner and runner == "kelvin":
config.environment["TEST_RUNNER_CMD"] = kelvin_cmd
config.available_features.add("kelvin")
+elif runner and runner == "kelvin_hw":
+ config.environment["TEST_RUNNER_CMD"] = kelvin_hw_cmd
+ config.available_features.add("kelvin_hw")
elif runner and runner == "qemu":
config.environment["TEST_RUNNER_CMD"] = qemu_cmd
config.available_features.add("qemu")
diff --git a/samples/microbenchmarks/conv1x1_test.run b/samples/microbenchmarks/conv1x1_test.run
index 2aa9a92..f554269 100644
--- a/samples/microbenchmarks/conv1x1_test.run
+++ b/samples/microbenchmarks/conv1x1_test.run
@@ -1 +1,2 @@
+// UNSUPPORTED: kelvin_hw
// RUN: ${TEST_RUNNER_CMD} %S/conv1x1_test_emitc_static
diff --git a/samples/simple_vec_mul/CMakeLists.txt b/samples/simple_vec_mul/CMakeLists.txt
index e6844ad..5f9a9f2 100644
--- a/samples/simple_vec_mul/CMakeLists.txt
+++ b/samples/simple_vec_mul/CMakeLists.txt
@@ -165,4 +165,38 @@
"-DBUILD_EMITC"
TESTFILES
"simple_test.run"
+ "simple_int_static_bin_test.run"
)
+
+# Kelvin-only systemc tests
+if (${BUILD_WITH_KELVIN})
+
+add_custom_command(
+ TARGET
+ samples_simple_vec_mul_simple_int_vec_mul_bytecode_static
+ POST_BUILD
+ COMMAND
+ ${CMAKE_OBJCOPY} -g -O binary
+ simple_int_vec_mul_bytecode_static
+ simple_int_vec_mul_bytecode_static.bin
+ BYPRODUCTS
+ simple_int_vec_mul_bytecode_static.bin
+ COMMENT
+ "Objcopy the binary file"
+)
+
+add_custom_command(
+ TARGET
+ samples_simple_vec_mul_simple_int_vec_mul_emitc_static
+ POST_BUILD
+ COMMAND
+ ${CMAKE_OBJCOPY} -g -O binary
+ simple_int_vec_mul_emitc_static
+ simple_int_vec_mul_emitc_static.bin
+ BYPRODUCTS
+ simple_int_vec_mul_emitc_static.bin
+ COMMENT
+ "Objcopy the binary file"
+)
+
+endif()
diff --git a/samples/simple_vec_mul/simple_int_static_bin_test.run b/samples/simple_vec_mul/simple_int_static_bin_test.run
new file mode 100644
index 0000000..92c2f3f
--- /dev/null
+++ b/samples/simple_vec_mul/simple_int_static_bin_test.run
@@ -0,0 +1,3 @@
+// REQUIRES: kelvin_hw
+// RUN: ${TEST_RUNNER_CMD} %S/simple_int_vec_mul_bytecode_static.bin
+// RUN: ${TEST_RUNNER_CMD} %S/simple_int_vec_mul_emitc_static.bin
diff --git a/samples/simple_vec_mul/simple_test.run b/samples/simple_vec_mul/simple_test.run
index 07c6d94..4421333 100644
--- a/samples/simple_vec_mul/simple_test.run
+++ b/samples/simple_vec_mul/simple_test.run
@@ -1,3 +1,4 @@
+// UNSUPPORTED: kelvin_hw
// RUN: ${TEST_RUNNER_CMD} %S/simple_int_vec_mul_bytecode_static
// RUN: ${TEST_RUNNER_CMD} %S/simple_int_vec_mul_emitc_static
// RUN: ${TEST_RUNNER_CMD} %S/simple_int_vec_mul_bytecode_vmvx