Skip to content

Commit 7565392

Browse files
boards: openhwgroup: add CV64A6 Testbench
Adds support for the CVA6 CPU in the hardware simulation / testbench environment. Especially, configurations are added that allow the application to indicate success or error to the testbench. The SoC currently contains the CVA6 CPU in 64-bit configuration with the SV39 MMU, interrupt controllers (CLINT and PLIC), UART, a SPI for booting from SD, a boot ROM, and I2C controller for on-board audio, a GPIO and the lowRISC ethernet subsystem (which is currently without a driver in zephyr). Two sample applications are provided, demonstrating how to indicate success or failure to the testbench. Signed-off-by: Eric Ackermann <[email protected]>
1 parent 494f880 commit 7565392

File tree

14 files changed

+252
-0
lines changed

14 files changed

+252
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
2+
# SPDX-License-Identifier: Apache-2.0
3+
config BOARD_CV64A6_TESTBENCH
4+
select SOC_CV64A6
5+
select SOC_SERIES_CV64A6_PROVIDE_TEST_POWEROFF
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
2+
# SPDX-License-Identifier: Apache-2.0
3+
board:
4+
name: cv64a6_testbench
5+
vendor: openhwgroup
6+
socs:
7+
- name: cv64a6
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright(c) 2024, CISPA Helmholtz Center for Information Security
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
/dts-v1/;
6+
7+
#include <openhwgroup/cv64a6.dtsi>
8+
9+
/ {
10+
model = "CVA6 CPU in testbench";
11+
compatible = "ariane,cv64a6_testbench";
12+
13+
chosen {
14+
zephyr,console = &uart0;
15+
zephyr,shell-uart = &uart0;
16+
zephyr,sram = &memory0;
17+
};
18+
};
19+
20+
&uart0 {
21+
status = "okay";
22+
};
23+
24+
&spi0 {
25+
status = "okay";
26+
};
27+
28+
&clint{
29+
status = "okay";
30+
};
31+
32+
33+
&dma0 {
34+
status = "disabled";
35+
};
36+
37+
38+
39+
&mdio0{
40+
status = "disabled";
41+
};
42+
43+
&eth0 {
44+
status = "disabled";
45+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
2+
# SPDX-License-Identifier: Apache-2.0
3+
CONFIG_BASE64=y
4+
CONFIG_INCLUDE_RESET_VECTOR=y
5+
CONFIG_CONSOLE=y
6+
CONFIG_SERIAL=y
7+
CONFIG_UART_CONSOLE=y
8+
CONFIG_UART_NS16550=y
9+
CONFIG_UART_NS16550_ACCESS_WORD_ONLY=y
10+
CONFIG_CONSOLE_HANDLER=y
11+
CONFIG_XIP=n
12+
CONFIG_INIT_STACKS=y
13+
CONFIG_SYS_CLOCK_TICKS_PER_SEC=25000000
14+
CONFIG_FPU=y
15+
CONFIG_POWEROFF=y
16+
17+
# RNG
18+
CONFIG_TIMER_RANDOM_GENERATOR=y
19+
CONFIG_TEST_RANDOM_GENERATOR=y
20+
21+
# IRQs
22+
CONFIG_MULTI_LEVEL_INTERRUPTS=y
23+
CONFIG_2ND_LEVEL_INTERRUPTS=y
24+
# 1 PLIC
25+
CONFIG_NUM_2ND_LEVEL_AGGREGATORS=1
26+
CONFIG_1ST_LEVEL_INTERRUPT_BITS=7
27+
CONFIG_2ND_LEVEL_INTERRUPT_BITS=23
28+
CONFIG_PLIC=y
29+
CONFIG_3RD_LEVEL_INTERRUPTS=n
30+
CONFIG_3RD_LEVEL_INTERRUPT_BITS=0
31+
32+
33+
# logging
34+
CONFIG_LOG=y
35+
# immediate is required so it is not lost on test failure
36+
CONFIG_LOG_MODE_IMMEDIATE=y
37+
CONFIG_LOG_DEFAULT_LEVEL=4
38+
CONFIG_THREAD_NAME=y
39+
40+
CONFIG_ISR_STACK_SIZE=32768
41+
CONFIG_MAIN_STACK_SIZE=32768
42+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=32768
43+
CONFIG_IDLE_STACK_SIZE=32768
44+
CONFIG_NET_TCP_WORKQ_STACK_SIZE=32768
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
7+
project(cv64a6_sim_fail)
8+
9+
target_sources(app PRIVATE src/main.c)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.. _hello_world:
2+
3+
Failing test
4+
###########
5+
6+
Overview
7+
********
8+
9+
A simple sample that can be used in the cv64a6 simulator.
10+
Prints "Test failure" to the console and indicates failure to the testbench.
11+
12+
Building and Running
13+
********************
14+
15+
This application can be built and executed in the cv64a6 testbench as follows:
16+
17+
.. code-block:: console
18+
west build -p always -b cv64a6_testbench samples/boards/openhwgroup/cv64a6/sim_fail/
19+
ln -s $(pwd)/build/zephyr/zephyr.elf build/zephyr/zephyr.o
20+
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
21+
22+
23+
To build for another board, change "cv64a6_testbench" above to that board's name.
24+
25+
Sample Output
26+
=============
27+
28+
.. code-block:: console
29+
30+
Test Failure x86
31+
32+
Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# nothing here
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
2+
# SPDX-License-Identifier: Apache-2.0
3+
sample:
4+
description: Test failure sample adapted for CVA6 testbench
5+
name: Test failure test
6+
common:
7+
tags: introduction
8+
integration_platforms:
9+
- native_sim
10+
harness: console
11+
harness_config:
12+
type: one_line
13+
regex:
14+
- "Test Failure (.*)"
15+
tests:
16+
sample.basic.helloworld:
17+
tags: introduction
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright(c) 2024, CISPA Helmholtz Center for Information Security
3+
* SPDX - License - Identifier : Apache-2.0
4+
*/
5+
#include <cv64a6.h>
6+
#include <stdio.h>
7+
8+
9+
int main(void)
10+
{
11+
printf("Test failure %s\n", CONFIG_BOARD_TARGET);
12+
13+
z_cv64a6_finish_test(0xdead);
14+
15+
return 0;
16+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
7+
project(hello_world_cv64a6_sim)
8+
9+
target_sources(app PRIVATE src/main.c)

0 commit comments

Comments
 (0)