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