blob: 62b06ea2686ef90d360f4e188a4855d7434b86ee [file] [log] [blame]
Kristofer Jonsson93175812022-04-21 19:27:11 +02001#
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 Jonsson93175812022-04-21 19:27:11 +02003#
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#############################################################################
20# Default parameters
21#############################################################################
22
Davide Grohmanna8832cc2022-05-06 16:35:16 +020023set(TARGET_CPU "cortex-m85" CACHE INTERNAL "")
Kristofer Jonsson93175812022-04-21 19:27:11 +020024
25if (NOT CMAKE_TOOLCHAIN_FILE)
26 set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/toolchain/armclang.cmake")
27endif()
28
Davide Grohmann7275f502022-08-09 14:32:52 +020029set(ETHOSU_TARGET_NPU_CONFIG "ethos-u55-256" CACHE STRING "NPU configuration")
Kristofer Jonsson93175812022-04-21 19:27:11 +020030set(ETHOSU_TARGET_NPU_COUNT 1 CACHE INTERNAL "Number of NPUs")
Henrik Hoglindebe33a42022-06-17 11:32:17 +020031set(ETHOSU_TARGET_NPU_TA_COUNT 0 CACHE INTERNAL "Number of timing adapters per NPU")
Kristofer Jonsson93175812022-04-21 19:27:11 +020032
33set(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(FAST_MEMORY_SIZE 0 CACHE STRING "Size of relocated fast memory scratch tensor")
39
40if (${FAST_MEMORY_SIZE} EQUAL 0)
41 set(MEMORY_DEFAULT "sram")
42else()
43 set(MEMORY_DEFAULT "dram")
44endif()
45
46set(MEMORY_MODEL ${MEMORY_DEFAULT} CACHE STRING "Memory config for model")
47set(MEMORY_ARENA ${MEMORY_DEFAULT} CACHE STRING "Memory config for arena")
48
49set(SYSTEM_CORE_CLOCK "25000000" CACHE INTERNAL "System core clock (Hz)")
50
51#############################################################################
52# Project
53#############################################################################
54
55cmake_minimum_required(VERSION 3.21)
56
Kristofer Jonssonde1a9f62022-08-03 15:51:08 +020057project(ethos-u-corstone-310 VERSION 0.0.1)
Kristofer Jonsson93175812022-04-21 19:27:11 +020058
59include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/helpers.cmake)
60
61#############################################################################
62# Corstone-Polaris
63#############################################################################
64
65get_filename_component(ETHOSU_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME)
66message("Configuring target ${ETHOSU_TARGET}")
67
68# Enable CTest
69include(CTest)
70set(Python3_FIND_STRATEGY LOCATION)
71find_package(Python3 COMPONENTS Interpreter)
72ethosu_get_architecture(${ETHOSU_TARGET_NPU_CONFIG})
73set(ETHOSU_COMMAND_DEFAULT ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/run_ctest.py
74 -t corstone-310
75 -a ethos-${ETHOSU_ARCH}
76 -m ${ETHOSU_NUM_MACS}
77 CACHE INTERNAL "Default test command")
78
79# Enable trustzone support in core_software
80set(TRUSTZONE_BUILD OFF)
81
82# Include common targets
83add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../common target)
84
85target_compile_definitions(ethosu_target_common INTERFACE
86 # Confiugure NPU architecture and number of timing adapters
87 ETHOSU_NPU_COUNT=${ETHOSU_TARGET_NPU_COUNT}
88 ETHOSU_NPU_TA_COUNT=${ETHOSU_TARGET_NPU_TA_COUNT}
89
90 # Configure PMU events
91 ETHOSU_PMU_EVENT_0=${ETHOSU_PMU_EVENT_0}
92 ETHOSU_PMU_EVENT_1=${ETHOSU_PMU_EVENT_1}
93 ETHOSU_PMU_EVENT_2=${ETHOSU_PMU_EVENT_2}
94 ETHOSU_PMU_EVENT_3=${ETHOSU_PMU_EVENT_3}
95
96 # Placement or TLFu model and area. 0 = SRAM, 1 = DRAM
97 ETHOSU_FAST_MEMORY_SIZE=${FAST_MEMORY_SIZE}
98 ETHOSU_MODEL=$<STREQUAL:${MEMORY_MODEL},dram>
99 ETHOSU_ARENA=$<STREQUAL:${MEMORY_ARENA},dram>)
100
101# AXI Timing adaptors
102set(registers MAXR MAXW MAXRW RLATENCY WLATENCY PULSE_ON PULSE_OFF BWCAP PERFCTRL PERFCNT MODE HISTBIN HISTCNT)
103
104foreach(register ${registers})
105 foreach(index RANGE 0 1)
106 set(name ETHOSU_TA_${register}_${index})
107 set(${name} -1 CACHE STRING "${name}")
108
109 if (${name} GREATER_EQUAL 0)
110 target_compile_definitions(ethosu_target_common INTERFACE ${name}=${${name}})
111 endif()
112 endforeach()
113endforeach()
114
115# Linker script
116set(LINK_FILE platform CACHE STRING "Link file")
117
118ethosu_target_link_options(ethosu_target_link INTERFACE
119 LINK_FILE ${LINK_FILE}
120 ENTRY Reset_Handler)
121
122# Add drivers
123target_sources(ethosu_target_startup INTERFACE
124 retarget.c
125 target.cpp)
126
127target_link_libraries(ethosu_target_startup INTERFACE
128 $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver;timing_adapter>
129 mpu
130 ethosu_mhu_dummy
131 ethosu_uart_cmsdk_apb)
132
Kristofer Jonsson93175812022-04-21 19:27:11 +0200133###############################################################################
134# Applications
135###############################################################################
136
137# Add all applications
138add_subdirectory(../../applications applications)