blob: 3a6f2918bcebe1a9aa1e72fee0552eecac6f1b5d [file] [log] [blame]
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01001#
Nir Ekhauz6110f412022-01-18 12:45:20 +02002# Copyright (c) 2020-2022 Arm Limited. All rights reserved.
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01003#
4# SPDX-License-Identifier: Apache-2.0
5#
6# Licensed under the Apache License, Version 2.0 (the License); you may
7# not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an AS IS BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19#############################################################################
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010020# Default parameters
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010021#############################################################################
22
Kristofer Jonssonec451552021-06-04 18:02:59 +020023set(TARGET_CPU "cortex-m55" CACHE INTERNAL "")
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010024
25if (NOT CMAKE_TOOLCHAIN_FILE)
26 set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/toolchain/armclang.cmake")
27endif()
28
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010029set(ETHOSU_TARGET_NPU_CONFIG "ethos-u55-128" CACHE STRING "NPU configuration")
30set(ETHOSU_TARGET_NPU_COUNT 1 CACHE INTERNAL "Number of NPUs")
31set(ETHOSU_TARGET_NPU_TA_COUNT 2 CACHE INTERNAL "Number of timing adapters per NPU")
Kristofer Jonssond3874052021-11-25 13:07:27 +010032
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010033set(ETHOSU_PMU_EVENT_0 -1 CACHE STRING "PMU Event #0")
34set(ETHOSU_PMU_EVENT_1 -1 CACHE STRING "PMU Event #1")
35set(ETHOSU_PMU_EVENT_2 -1 CACHE STRING "PMU Event #2")
36set(ETHOSU_PMU_EVENT_3 -1 CACHE STRING "PMU Event #3")
37
38set(MEMORY_MODEL "dram" CACHE STRING "Memory config for model")
39set(MEMORY_ARENA "dram" CACHE STRING "Memory config for arena")
Jonny Svärd991af2b2021-04-15 17:31:01 +020040
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010041#############################################################################
42# Project
43#############################################################################
44
Nir Ekhauz6110f412022-01-18 12:45:20 +020045cmake_minimum_required(VERSION 3.21)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010046
47project(ethos-u-corstone-300 VERSION 0.0.1)
48
49include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/helpers.cmake)
50
51#############################################################################
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010052# Corstone-300
53#############################################################################
54
Per Åstrand79929ff2021-01-26 14:42:43 +010055get_filename_component(ETHOSU_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME)
56message("Configuring target ${ETHOSU_TARGET}")
57
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010058# Enable CTest
59include(CTest)
60set(Python3_FIND_STRATEGY LOCATION)
61find_package(Python3 COMPONENTS Interpreter)
62ethosu_get_architecture(${ETHOSU_TARGET_NPU_CONFIG})
63set(ETHOSU_COMMAND_DEFAULT ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/run_ctest.py
64 -t corstone-300
65 -a ethos-${ETHOSU_ARCH}
66 -m ${ETHOSU_NUM_MACS}
67 CACHE INTERNAL "Default test command")
68
Per Åstranddfcc0172021-01-29 10:27:40 +010069# Enable trustzone support in core_software
70set(TRUSTZONE_BUILD ON)
71
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010072# Include common targets
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010073add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../common target)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010074
Nir Ekhauz4756bf12021-06-27 11:20:24 +030075target_compile_definitions(ethosu_target_common INTERFACE
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010076 # Confiugure NPU architecture and number of timing adapters
77 ETHOSU_NPU_COUNT=${ETHOSU_TARGET_NPU_COUNT}
78 ETHOSU_NPU_TA_COUNT=${ETHOSU_TARGET_NPU_TA_COUNT}
79
80 # Configure PMU events
Nir Ekhauz4756bf12021-06-27 11:20:24 +030081 ETHOSU_PMU_EVENT_0=${ETHOSU_PMU_EVENT_0}
82 ETHOSU_PMU_EVENT_1=${ETHOSU_PMU_EVENT_1}
83 ETHOSU_PMU_EVENT_2=${ETHOSU_PMU_EVENT_2}
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010084 ETHOSU_PMU_EVENT_3=${ETHOSU_PMU_EVENT_3}
Nir Ekhauz4756bf12021-06-27 11:20:24 +030085
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010086 # Placement or TLFu model and area. 0 = SRAM, 1 = DRAM
87 ETHOSU_MODEL=$<STREQUAL:${MEMORY_MODEL},dram>
88 ETHOSU_ARENA=$<STREQUAL:${MEMORY_ARENA},dram>)
Nir Ekhauz3c505ca2021-06-06 14:57:50 +030089
Nir Ekhauza58edd82021-10-04 12:21:17 +030090# AXI Timing adaptors
91set(registers MAXR MAXW MAXRW RLATENCY WLATENCY PULSE_ON PULSE_OFF BWCAP PERFCTRL PERFCNT MODE HISTBIN HISTCNT)
92
93foreach(register ${registers})
94 foreach(index RANGE 0 1)
95 set(name ETHOSU_TA_${register}_${index})
96 set(${name} -1 CACHE STRING "${name}")
Kristofer Jonsson64f37cd2021-10-19 10:54:47 +020097
98 if (${name} GREATER_EQUAL 0)
99 target_compile_definitions(ethosu_target_common INTERFACE ${name}=${${name}})
100 endif()
Nir Ekhauza58edd82021-10-04 12:21:17 +0300101 endforeach()
102endforeach()
103
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100104# Linker script
Kristofer Jonssonec451552021-06-04 18:02:59 +0200105set(LINK_FILE platform CACHE STRING "Link file")
106
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100107ethosu_target_link_options(ethosu_target_link INTERFACE
Kristofer Jonssonec451552021-06-04 18:02:59 +0200108 LINK_FILE ${LINK_FILE}
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100109 ENTRY Reset_Handler)
110
111# Add drivers
112target_sources(ethosu_target_startup INTERFACE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100113 retarget.c
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200114 target.cpp)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100115
Kristofer Jonsson3b137322021-06-28 20:17:04 +0200116target_link_libraries(ethosu_target_startup INTERFACE
Kristofer Jonsson7b8fa5e2021-12-16 14:02:56 +0100117 $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver;timing_adapter>
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200118 mpu
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200119 ethosu_mhu_dummy
120 ethosu_uart_cmsdk_apb)
Kristofer Jonsson3b137322021-06-28 20:17:04 +0200121
122if (TARGET ethosu_core_driver)
123 target_compile_definitions(ethosu_core_driver PUBLIC
124 ETHOSU)
125endif()
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100126
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100127###############################################################################
128# Applications
129###############################################################################
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100130
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100131# Add all applications
132add_subdirectory(../../applications applications)