blob: dfa2792f0f8aad2c4735e6187584281cff35e9f9 [file] [log] [blame]
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01001#
Jonny Svärd229d7a02023-04-04 16:53:59 +02002# SPDX-FileCopyrightText: Copyright 2020-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
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})
Jonny Svärdd798c6e2022-05-24 13:23:00 +020063set(ETHOSU_COMMAND_OPTIONS
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010064 -t corstone-300
65 -a ethos-${ETHOSU_ARCH}
66 -m ${ETHOSU_NUM_MACS}
Jonny Svärdd798c6e2022-05-24 13:23:00 +020067 CACHE INTERNAL "Default test command options")
68
69if (ETHOSU_CTEST_TARMAC_TRACE)
70 list(APPEND ETHOSU_COMMAND_OPTIONS "--tarmac")
71endif()
72
73set(ETHOSU_COMMAND_DEFAULT ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/run_ctest.py
74 ${ETHOSU_COMMAND_OPTIONS}
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010075 CACHE INTERNAL "Default test command")
76
Per Åstranddfcc0172021-01-29 10:27:40 +010077# Enable trustzone support in core_software
78set(TRUSTZONE_BUILD ON)
79
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010080# Include common targets
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010081add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../common target)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010082
Nir Ekhauz4756bf12021-06-27 11:20:24 +030083target_compile_definitions(ethosu_target_common INTERFACE
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010084 # Confiugure NPU architecture and number of timing adapters
85 ETHOSU_NPU_COUNT=${ETHOSU_TARGET_NPU_COUNT}
86 ETHOSU_NPU_TA_COUNT=${ETHOSU_TARGET_NPU_TA_COUNT}
87
88 # Configure PMU events
Nir Ekhauz4756bf12021-06-27 11:20:24 +030089 ETHOSU_PMU_EVENT_0=${ETHOSU_PMU_EVENT_0}
90 ETHOSU_PMU_EVENT_1=${ETHOSU_PMU_EVENT_1}
91 ETHOSU_PMU_EVENT_2=${ETHOSU_PMU_EVENT_2}
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010092 ETHOSU_PMU_EVENT_3=${ETHOSU_PMU_EVENT_3}
Nir Ekhauz4756bf12021-06-27 11:20:24 +030093
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010094 # Placement or TLFu model and area. 0 = SRAM, 1 = DRAM
95 ETHOSU_MODEL=$<STREQUAL:${MEMORY_MODEL},dram>
96 ETHOSU_ARENA=$<STREQUAL:${MEMORY_ARENA},dram>)
Nir Ekhauz3c505ca2021-06-06 14:57:50 +030097
Nir Ekhauza58edd82021-10-04 12:21:17 +030098# AXI Timing adaptors
99set(registers MAXR MAXW MAXRW RLATENCY WLATENCY PULSE_ON PULSE_OFF BWCAP PERFCTRL PERFCNT MODE HISTBIN HISTCNT)
100
101foreach(register ${registers})
102 foreach(index RANGE 0 1)
103 set(name ETHOSU_TA_${register}_${index})
104 set(${name} -1 CACHE STRING "${name}")
Kristofer Jonsson64f37cd2021-10-19 10:54:47 +0200105
106 if (${name} GREATER_EQUAL 0)
107 target_compile_definitions(ethosu_target_common INTERFACE ${name}=${${name}})
108 endif()
Nir Ekhauza58edd82021-10-04 12:21:17 +0300109 endforeach()
110endforeach()
111
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100112# Linker script
Kristofer Jonssonec451552021-06-04 18:02:59 +0200113set(LINK_FILE platform CACHE STRING "Link file")
114
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100115ethosu_target_link_options(ethosu_target_link INTERFACE
Kristofer Jonssonec451552021-06-04 18:02:59 +0200116 LINK_FILE ${LINK_FILE}
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100117 ENTRY Reset_Handler)
118
119# Add drivers
120target_sources(ethosu_target_startup INTERFACE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100121 retarget.c
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200122 target.cpp)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100123
Kristofer Jonsson3b137322021-06-28 20:17:04 +0200124target_link_libraries(ethosu_target_startup INTERFACE
Kristofer Jonsson7b8fa5e2021-12-16 14:02:56 +0100125 $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver;timing_adapter>
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200126 mpu
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200127 ethosu_mhu_dummy
128 ethosu_uart_cmsdk_apb)
Kristofer Jonsson3b137322021-06-28 20:17:04 +0200129
Kristofer Jonssone56b6e42022-09-29 11:52:22 +0200130if (TARGET event_recorder)
131 target_include_directories(event_recorder BEFORE INTERFACE
132 event_recorder)
133endif()
134
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100135###############################################################################
136# Applications
137###############################################################################
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100138
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100139# Add all applications
140add_subdirectory(../../applications applications)