Kristofer Jonsson | 9317581 | 2022-04-21 19:27:11 +0200 | [diff] [blame] | 1 | # |
| 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 | |
Davide Grohmann | a8832cc | 2022-05-06 16:35:16 +0200 | [diff] [blame] | 23 | set(TARGET_CPU "cortex-m85" CACHE INTERNAL "") |
Kristofer Jonsson | 9317581 | 2022-04-21 19:27:11 +0200 | [diff] [blame] | 24 | |
| 25 | if (NOT CMAKE_TOOLCHAIN_FILE) |
| 26 | set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/toolchain/armclang.cmake") |
| 27 | endif() |
| 28 | |
Davide Grohmann | 7275f50 | 2022-08-09 14:32:52 +0200 | [diff] [blame^] | 29 | set(ETHOSU_TARGET_NPU_CONFIG "ethos-u55-256" CACHE STRING "NPU configuration") |
Kristofer Jonsson | 9317581 | 2022-04-21 19:27:11 +0200 | [diff] [blame] | 30 | set(ETHOSU_TARGET_NPU_COUNT 1 CACHE INTERNAL "Number of NPUs") |
Henrik Hoglind | ebe33a4 | 2022-06-17 11:32:17 +0200 | [diff] [blame] | 31 | set(ETHOSU_TARGET_NPU_TA_COUNT 0 CACHE INTERNAL "Number of timing adapters per NPU") |
Kristofer Jonsson | 9317581 | 2022-04-21 19:27:11 +0200 | [diff] [blame] | 32 | |
| 33 | set(ETHOSU_PMU_EVENT_0 -1 CACHE STRING "PMU Event #0") |
| 34 | set(ETHOSU_PMU_EVENT_1 -1 CACHE STRING "PMU Event #1") |
| 35 | set(ETHOSU_PMU_EVENT_2 -1 CACHE STRING "PMU Event #2") |
| 36 | set(ETHOSU_PMU_EVENT_3 -1 CACHE STRING "PMU Event #3") |
| 37 | |
| 38 | set(FAST_MEMORY_SIZE 0 CACHE STRING "Size of relocated fast memory scratch tensor") |
| 39 | |
| 40 | if (${FAST_MEMORY_SIZE} EQUAL 0) |
| 41 | set(MEMORY_DEFAULT "sram") |
| 42 | else() |
| 43 | set(MEMORY_DEFAULT "dram") |
| 44 | endif() |
| 45 | |
| 46 | set(MEMORY_MODEL ${MEMORY_DEFAULT} CACHE STRING "Memory config for model") |
| 47 | set(MEMORY_ARENA ${MEMORY_DEFAULT} CACHE STRING "Memory config for arena") |
| 48 | |
| 49 | set(SYSTEM_CORE_CLOCK "25000000" CACHE INTERNAL "System core clock (Hz)") |
| 50 | |
| 51 | ############################################################################# |
| 52 | # Project |
| 53 | ############################################################################# |
| 54 | |
| 55 | cmake_minimum_required(VERSION 3.21) |
| 56 | |
Kristofer Jonsson | de1a9f6 | 2022-08-03 15:51:08 +0200 | [diff] [blame] | 57 | project(ethos-u-corstone-310 VERSION 0.0.1) |
Kristofer Jonsson | 9317581 | 2022-04-21 19:27:11 +0200 | [diff] [blame] | 58 | |
| 59 | include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/helpers.cmake) |
| 60 | |
| 61 | ############################################################################# |
| 62 | # Corstone-Polaris |
| 63 | ############################################################################# |
| 64 | |
| 65 | get_filename_component(ETHOSU_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) |
| 66 | message("Configuring target ${ETHOSU_TARGET}") |
| 67 | |
| 68 | # Enable CTest |
| 69 | include(CTest) |
| 70 | set(Python3_FIND_STRATEGY LOCATION) |
| 71 | find_package(Python3 COMPONENTS Interpreter) |
| 72 | ethosu_get_architecture(${ETHOSU_TARGET_NPU_CONFIG}) |
| 73 | set(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 |
| 80 | set(TRUSTZONE_BUILD OFF) |
| 81 | |
| 82 | # Include common targets |
| 83 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../common target) |
| 84 | |
| 85 | target_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 |
| 102 | set(registers MAXR MAXW MAXRW RLATENCY WLATENCY PULSE_ON PULSE_OFF BWCAP PERFCTRL PERFCNT MODE HISTBIN HISTCNT) |
| 103 | |
| 104 | foreach(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() |
| 113 | endforeach() |
| 114 | |
| 115 | # Linker script |
| 116 | set(LINK_FILE platform CACHE STRING "Link file") |
| 117 | |
| 118 | ethosu_target_link_options(ethosu_target_link INTERFACE |
| 119 | LINK_FILE ${LINK_FILE} |
| 120 | ENTRY Reset_Handler) |
| 121 | |
| 122 | # Add drivers |
| 123 | target_sources(ethosu_target_startup INTERFACE |
| 124 | retarget.c |
| 125 | target.cpp) |
| 126 | |
| 127 | target_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 | |
| 133 | if (TARGET ethosu_core_driver) |
| 134 | target_compile_definitions(ethosu_core_driver PUBLIC |
| 135 | ETHOSU) |
| 136 | endif() |
| 137 | |
| 138 | ############################################################################### |
| 139 | # Applications |
| 140 | ############################################################################### |
| 141 | |
| 142 | # Add all applications |
| 143 | add_subdirectory(../../applications applications) |