diff --git a/boards/openhwgroup/cv32a6_testbench/Kconfig.cv32a6_testbench b/boards/openhwgroup/cv32a6_testbench/Kconfig.cv32a6_testbench new file mode 100644 index 0000000000000..425c953a608ff --- /dev/null +++ b/boards/openhwgroup/cv32a6_testbench/Kconfig.cv32a6_testbench @@ -0,0 +1,5 @@ +# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH +# SPDX-License-Identifier: Apache-2.0 +config BOARD_CV32A6_TESTBENCH + select SOC_CV32A6 + select SOC_FAMILY_CVA6_PROVIDE_TEST_POWEROFF \ No newline at end of file diff --git a/boards/openhwgroup/cv32a6_testbench/board.yml b/boards/openhwgroup/cv32a6_testbench/board.yml new file mode 100644 index 0000000000000..3a32f31b39fd9 --- /dev/null +++ b/boards/openhwgroup/cv32a6_testbench/board.yml @@ -0,0 +1,7 @@ +# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH +# SPDX-License-Identifier: Apache-2.0 +board: + name: cv32a6_testbench + vendor: openhwgroup + socs: + - name: cv32a6 \ No newline at end of file diff --git a/boards/openhwgroup/cv32a6_testbench/cv32a6_testbench.dts b/boards/openhwgroup/cv32a6_testbench/cv32a6_testbench.dts new file mode 100644 index 0000000000000..6f825954f918c --- /dev/null +++ b/boards/openhwgroup/cv32a6_testbench/cv32a6_testbench.dts @@ -0,0 +1,45 @@ +/* + * Copyright(c) 2024, CISPA Helmholtz Center for Information Security + * SPDX-License-Identifier: Apache-2.0 + */ +/dts-v1/; + +#include + +/ { + model = "CVA6 CPU in testbench"; + compatible = "ariane,cv32a6_testbench"; + + chosen { + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + zephyr,sram = &memory0; + }; +}; + +&uart0 { + status = "okay"; +}; + +&spi0 { + status = "okay"; +}; + +&clint{ + status = "okay"; +}; + + +&dma0 { + status = "disabled"; +}; + + + +&mdio0{ + status = "disabled"; +}; + +ð0 { + status = "disabled"; +}; diff --git a/boards/openhwgroup/cv32a6_testbench/cv32a6_testbench_defconfig b/boards/openhwgroup/cv32a6_testbench/cv32a6_testbench_defconfig new file mode 100644 index 0000000000000..2113689f909e6 --- /dev/null +++ b/boards/openhwgroup/cv32a6_testbench/cv32a6_testbench_defconfig @@ -0,0 +1,40 @@ +# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH +# SPDX-License-Identifier: Apache-2.0 +CONFIG_BASE64=y +CONFIG_INCLUDE_RESET_VECTOR=y +CONFIG_CONSOLE=y +CONFIG_SERIAL=y +CONFIG_UART_CONSOLE=y +CONFIG_UART_NS16550=y +CONFIG_UART_NS16550_ACCESS_WORD_ONLY=y +CONFIG_CONSOLE_HANDLER=y +CONFIG_XIP=n +CONFIG_INIT_STACKS=y +CONFIG_SYS_CLOCK_TICKS_PER_SEC=25000000 +CONFIG_FPU=y +CONFIG_POWEROFF=y + +# RNG +CONFIG_TIMER_RANDOM_GENERATOR=y +CONFIG_TEST_RANDOM_GENERATOR=y + +# IRQs +CONFIG_MULTI_LEVEL_INTERRUPTS=y +CONFIG_2ND_LEVEL_INTERRUPTS=y +# 1 PLIC +CONFIG_NUM_2ND_LEVEL_AGGREGATORS=1 +CONFIG_PLIC=y +CONFIG_3RD_LEVEL_INTERRUPTS=n + + +# logging +CONFIG_LOG=y +# immediate is required so it is not lost on test failure +CONFIG_LOG_MODE_IMMEDIATE=y +CONFIG_LOG_DEFAULT_LEVEL=4 +CONFIG_THREAD_NAME=y + +CONFIG_ISR_STACK_SIZE=32768 +CONFIG_MAIN_STACK_SIZE=32768 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=32768 +CONFIG_IDLE_STACK_SIZE=32768 \ No newline at end of file diff --git a/boards/openhwgroup/cv64a6_testbench/Kconfig.cv64a6_testbench b/boards/openhwgroup/cv64a6_testbench/Kconfig.cv64a6_testbench new file mode 100644 index 0000000000000..cd09c836a3ed9 --- /dev/null +++ b/boards/openhwgroup/cv64a6_testbench/Kconfig.cv64a6_testbench @@ -0,0 +1,5 @@ +# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH +# SPDX-License-Identifier: Apache-2.0 +config BOARD_CV64A6_TESTBENCH + select SOC_CV64A6_IMAFDC + select SOC_FAMILY_CVA6_PROVIDE_TEST_POWEROFF \ No newline at end of file diff --git a/boards/openhwgroup/cv64a6_testbench/board.yml b/boards/openhwgroup/cv64a6_testbench/board.yml new file mode 100644 index 0000000000000..48fec1506bf5b --- /dev/null +++ b/boards/openhwgroup/cv64a6_testbench/board.yml @@ -0,0 +1,7 @@ +# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH +# SPDX-License-Identifier: Apache-2.0 +board: + name: cv64a6_testbench + vendor: openhwgroup + socs: + - name: cv64a6 \ No newline at end of file diff --git a/boards/openhwgroup/cv64a6_testbench/cv64a6_testbench.dts b/boards/openhwgroup/cv64a6_testbench/cv64a6_testbench.dts new file mode 100644 index 0000000000000..ad366bce074f6 --- /dev/null +++ b/boards/openhwgroup/cv64a6_testbench/cv64a6_testbench.dts @@ -0,0 +1,45 @@ +/* + * Copyright(c) 2024, CISPA Helmholtz Center for Information Security + * SPDX-License-Identifier: Apache-2.0 + */ +/dts-v1/; + +#include + +/ { + model = "CVA6 CPU in testbench"; + compatible = "ariane,cv64a6_testbench"; + + chosen { + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + zephyr,sram = &memory0; + }; +}; + +&uart0 { + status = "okay"; +}; + +&spi0 { + status = "okay"; +}; + +&clint{ + status = "okay"; +}; + + +&dma0 { + status = "disabled"; +}; + + + +&mdio0{ + status = "disabled"; +}; + +ð0 { + status = "disabled"; +}; diff --git a/boards/openhwgroup/cv64a6_testbench/cv64a6_testbench_defconfig b/boards/openhwgroup/cv64a6_testbench/cv64a6_testbench_defconfig new file mode 100644 index 0000000000000..2113689f909e6 --- /dev/null +++ b/boards/openhwgroup/cv64a6_testbench/cv64a6_testbench_defconfig @@ -0,0 +1,40 @@ +# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH +# SPDX-License-Identifier: Apache-2.0 +CONFIG_BASE64=y +CONFIG_INCLUDE_RESET_VECTOR=y +CONFIG_CONSOLE=y +CONFIG_SERIAL=y +CONFIG_UART_CONSOLE=y +CONFIG_UART_NS16550=y +CONFIG_UART_NS16550_ACCESS_WORD_ONLY=y +CONFIG_CONSOLE_HANDLER=y +CONFIG_XIP=n +CONFIG_INIT_STACKS=y +CONFIG_SYS_CLOCK_TICKS_PER_SEC=25000000 +CONFIG_FPU=y +CONFIG_POWEROFF=y + +# RNG +CONFIG_TIMER_RANDOM_GENERATOR=y +CONFIG_TEST_RANDOM_GENERATOR=y + +# IRQs +CONFIG_MULTI_LEVEL_INTERRUPTS=y +CONFIG_2ND_LEVEL_INTERRUPTS=y +# 1 PLIC +CONFIG_NUM_2ND_LEVEL_AGGREGATORS=1 +CONFIG_PLIC=y +CONFIG_3RD_LEVEL_INTERRUPTS=n + + +# logging +CONFIG_LOG=y +# immediate is required so it is not lost on test failure +CONFIG_LOG_MODE_IMMEDIATE=y +CONFIG_LOG_DEFAULT_LEVEL=4 +CONFIG_THREAD_NAME=y + +CONFIG_ISR_STACK_SIZE=32768 +CONFIG_MAIN_STACK_SIZE=32768 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=32768 +CONFIG_IDLE_STACK_SIZE=32768 \ No newline at end of file diff --git a/samples/boards/openhwgroup/sim_fail/CMakeLists.txt b/samples/boards/openhwgroup/sim_fail/CMakeLists.txt new file mode 100644 index 0000000000000..52e70ed5f2017 --- /dev/null +++ b/samples/boards/openhwgroup/sim_fail/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(cv64a6_sim_fail) + +target_sources(app PRIVATE src/main.c) diff --git a/samples/boards/openhwgroup/sim_fail/README.rst b/samples/boards/openhwgroup/sim_fail/README.rst new file mode 100644 index 0000000000000..c2d5c4af71693 --- /dev/null +++ b/samples/boards/openhwgroup/sim_fail/README.rst @@ -0,0 +1,32 @@ +.. _hello_world: + +Failing test +########### + +Overview +******** + +A simple sample that can be used in the cv64a6 simulator. +Prints "Test failure" to the console and indicates failure to the testbench. + +Building and Running +******************** + +This application can be built and executed in the cv64a6 testbench as follows: + +.. code-block:: console + west build -p always -b cv64a6_testbench samples/boards/openhwgroup/cva6/sim_fail/ + ln -s $(pwd)/build/zephyr/zephyr.elf build/zephyr/zephyr.o + python3 $CVA6_ROOT/verif/sim/cva6.py --elf_tests $ZEPHYR_ROOT/build/zephyr/zephyr.o --iss_yaml cva6.yaml --target cv64a6_imafdc_sv39 --iss=veri-testharness --spike_params="/top/max_steps_enabled=y" $DV_OPTS + + +To build for another board, change "cv64a6_testbench" above to that board's name. + +Sample Output +============= + +.. code-block:: console + + Test Failure x86 + +Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`. diff --git a/samples/boards/openhwgroup/sim_fail/prj.conf b/samples/boards/openhwgroup/sim_fail/prj.conf new file mode 100644 index 0000000000000..b2a4ba591044e --- /dev/null +++ b/samples/boards/openhwgroup/sim_fail/prj.conf @@ -0,0 +1 @@ +# nothing here diff --git a/samples/boards/openhwgroup/sim_fail/sample.yaml b/samples/boards/openhwgroup/sim_fail/sample.yaml new file mode 100644 index 0000000000000..ed984e5194250 --- /dev/null +++ b/samples/boards/openhwgroup/sim_fail/sample.yaml @@ -0,0 +1,17 @@ +# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH +# SPDX-License-Identifier: Apache-2.0 +sample: + description: Test failure sample adapted for CVA6 testbench + name: Test failure test +common: + tags: introduction + integration_platforms: + - native_sim + harness: console + harness_config: + type: one_line + regex: + - "Test Failure (.*)" +tests: + sample.basic.helloworld: + tags: introduction diff --git a/samples/boards/openhwgroup/sim_fail/src/main.c b/samples/boards/openhwgroup/sim_fail/src/main.c new file mode 100644 index 0000000000000..f32ede1d141f7 --- /dev/null +++ b/samples/boards/openhwgroup/sim_fail/src/main.c @@ -0,0 +1,16 @@ +/* + * Copyright(c) 2024, CISPA Helmholtz Center for Information Security + * SPDX - License - Identifier : Apache-2.0 + */ +#include +#include + + +int main(void) +{ + printf("Test failure %s\n", CONFIG_BOARD_TARGET); + + z_cv64a6_finish_test(0xdead); + + return 0; +} diff --git a/samples/boards/openhwgroup/sim_hello_world/CMakeLists.txt b/samples/boards/openhwgroup/sim_hello_world/CMakeLists.txt new file mode 100644 index 0000000000000..bb7b720afddfb --- /dev/null +++ b/samples/boards/openhwgroup/sim_hello_world/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(hello_world_cv64a6_sim) + +target_sources(app PRIVATE src/main.c) diff --git a/samples/boards/openhwgroup/sim_hello_world/README.rst b/samples/boards/openhwgroup/sim_hello_world/README.rst new file mode 100644 index 0000000000000..0d1c16332db07 --- /dev/null +++ b/samples/boards/openhwgroup/sim_hello_world/README.rst @@ -0,0 +1,32 @@ +.. _hello_world: + +Hello World +########### + +Overview +******** + +A simple sample that can be used in the cv64a6 simulator. +Prints "Hello World" to the console and indicates success to the testbench. + +Building and Running +******************** + +This application can be built and executed in the cv64a6 testbench as follows: + +.. code-block:: console + west build -p always -b cv64a6_testbench samples/boards/openhwgroup/sim_hello_world/ + ln -s $(pwd)/build/zephyr/zephyr.elf build/zephyr/zephyr.o + python3 $CVA6_ROOT/verif/sim/cva6.py --elf_tests $ZEPHYR_ROOT/build/zephyr/zephyr.o --iss_yaml cva6.yaml --target cv64a6_imafdc_sv39 --iss=veri-testharness --spike_params="/top/max_steps_enabled=y" $DV_OPTSreset + + +To build for another board, change "cv64a6_testbench" above to that board's name. + +Sample Output +============= + +.. code-block:: console + + Hello World! x86 + +Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`. diff --git a/samples/boards/openhwgroup/sim_hello_world/prj.conf b/samples/boards/openhwgroup/sim_hello_world/prj.conf new file mode 100644 index 0000000000000..b2a4ba591044e --- /dev/null +++ b/samples/boards/openhwgroup/sim_hello_world/prj.conf @@ -0,0 +1 @@ +# nothing here diff --git a/samples/boards/openhwgroup/sim_hello_world/sample.yaml b/samples/boards/openhwgroup/sim_hello_world/sample.yaml new file mode 100644 index 0000000000000..c8789f1937208 --- /dev/null +++ b/samples/boards/openhwgroup/sim_hello_world/sample.yaml @@ -0,0 +1,17 @@ +# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH +# SPDX-License-Identifier: Apache-2.0 +sample: + description: Hello World sample adapted for CVA6 testbench + name: hello world test +common: + tags: introduction + integration_platforms: + - native_sim + harness: console + harness_config: + type: one_line + regex: + - "Hello World! (.*)" +tests: + sample.basic.helloworld: + tags: introduction diff --git a/samples/boards/openhwgroup/sim_hello_world/src/main.c b/samples/boards/openhwgroup/sim_hello_world/src/main.c new file mode 100644 index 0000000000000..6f50d6d6f8af8 --- /dev/null +++ b/samples/boards/openhwgroup/sim_hello_world/src/main.c @@ -0,0 +1,17 @@ +/* + * + * Copyright(c) 2024, CISPA Helmholtz Center for Information Security + * SPDX - License - Identifier : Apache-2.0 + */ +#include +#include + + +int main(void) +{ + printf("Hello World! %s\n", CONFIG_BOARD_TARGET); + + z_cv64a6_finish_test(0); + + return 0; +}