blob: 0d470914e44bd601d9daa8fa7f55f3749b3d2b7b [file] [log] [blame]
Kristofer Jonsson6e9fdc02022-01-14 16:38:17 +01001#
2# Copyright (c) 2020-2022 Arm Limited. All rights reserved.
3#
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
23# TODO Olympus CPU is backwards compatible with Cortex-M55
24set(TARGET_CPU "cortex-m55" CACHE INTERNAL "")
25
26if (NOT CMAKE_TOOLCHAIN_FILE)
27 set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/toolchain/armclang.cmake")
28endif()
29
30set(ETHOSU_TARGET_NPU_CONFIG "ethos-u55-128" CACHE STRING "NPU configuration")
31set(ETHOSU_TARGET_NPU_COUNT 1 CACHE INTERNAL "Number of NPUs")
32set(ETHOSU_TARGET_NPU_TA_COUNT 2 CACHE INTERNAL "Number of timing adapters per NPU")
33
34set(ETHOSU_PMU_EVENT_0 -1 CACHE STRING "PMU Event #0")
35set(ETHOSU_PMU_EVENT_1 -1 CACHE STRING "PMU Event #1")
36set(ETHOSU_PMU_EVENT_2 -1 CACHE STRING "PMU Event #2")
37set(ETHOSU_PMU_EVENT_3 -1 CACHE STRING "PMU Event #3")
38
39set(MEMORY_MODEL "dram" CACHE STRING "Memory config for model")
40set(MEMORY_ARENA "dram" CACHE STRING "Memory config for arena")
41
42set(SYSTEM_CORE_CLOCK "25000000" CACHE INTERNAL "System core clock (Hz)")
43
44#############################################################################
45# Project
46#############################################################################
47
48cmake_minimum_required(VERSION 3.21)
49
50project(ethos-u-corstone-polaris VERSION 0.0.1)
51
52include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/helpers.cmake)
53
54#############################################################################
55# Corstone-Polaris
56#############################################################################
57
58get_filename_component(ETHOSU_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME)
59message("Configuring target ${ETHOSU_TARGET}")
60
61# Enable CTest
62include(CTest)
63set(Python3_FIND_STRATEGY LOCATION)
64find_package(Python3 COMPONENTS Interpreter)
65ethosu_get_architecture(${ETHOSU_TARGET_NPU_CONFIG})
66set(ETHOSU_COMMAND_DEFAULT ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/run_ctest.py
67 -t corstone-polaris
68 -a ethos-${ETHOSU_ARCH}
69 -m ${ETHOSU_NUM_MACS}
70 CACHE INTERNAL "Default test command")
71
72# Enable trustzone support in core_software
73set(TRUSTZONE_BUILD OFF)
74
75# Include common targets
76add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../common target)
77
78target_compile_definitions(ethosu_target_common INTERFACE
79 # Confiugure NPU architecture and number of timing adapters
80 ETHOSU_NPU_COUNT=${ETHOSU_TARGET_NPU_COUNT}
81 ETHOSU_NPU_TA_COUNT=${ETHOSU_TARGET_NPU_TA_COUNT}
82
83 # Configure PMU events
84 ETHOSU_PMU_EVENT_0=${ETHOSU_PMU_EVENT_0}
85 ETHOSU_PMU_EVENT_1=${ETHOSU_PMU_EVENT_1}
86 ETHOSU_PMU_EVENT_2=${ETHOSU_PMU_EVENT_2}
87 ETHOSU_PMU_EVENT_3=${ETHOSU_PMU_EVENT_3}
88
89 # Placement or TLFu model and area. 0 = SRAM, 1 = DRAM
90 ETHOSU_MODEL=$<STREQUAL:${MEMORY_MODEL},dram>
91 ETHOSU_ARENA=$<STREQUAL:${MEMORY_ARENA},dram>)
92
93# AXI Timing adaptors
94set(registers MAXR MAXW MAXRW RLATENCY WLATENCY PULSE_ON PULSE_OFF BWCAP PERFCTRL PERFCNT MODE HISTBIN HISTCNT)
95
96foreach(register ${registers})
97 foreach(index RANGE 0 1)
98 set(name ETHOSU_TA_${register}_${index})
99 set(${name} -1 CACHE STRING "${name}")
100
101 if (${name} GREATER_EQUAL 0)
102 target_compile_definitions(ethosu_target_common INTERFACE ${name}=${${name}})
103 endif()
104 endforeach()
105endforeach()
106
107# Linker script
108set(LINK_FILE platform CACHE STRING "Link file")
109
110ethosu_target_link_options(ethosu_target_link INTERFACE
111 LINK_FILE ${LINK_FILE}
112 ENTRY Reset_Handler)
113
114# Add drivers
115target_sources(ethosu_target_startup INTERFACE
116 retarget.c
117 target.cpp)
118
119target_link_libraries(ethosu_target_startup INTERFACE
120 $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver;timing_adapter>
121 mpu
122 ethosu_mhu_dummy
123 ethosu_uart_cmsdk_apb)
124
125if (TARGET ethosu_core_driver)
126 target_compile_definitions(ethosu_core_driver PUBLIC
127 ETHOSU)
128endif()
129
130###############################################################################
131# Applications
132###############################################################################
133
134# Add all applications
135add_subdirectory(../../applications applications)