blob: 358dab94ea43c3a13372cf93ea0edc3d566ed8cb [file] [log] [blame]
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +00001#----------------------------------------------------------------------------
2# Copyright (c) 2022 Arm Limited. All rights reserved.
3# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#----------------------------------------------------------------------------
17
18#########################################################
19# Ethos-U NPU timing adapter initialization library #
20#########################################################
21
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000022# Timing adapter component is only available on certain implementations
23# on FPGA and FVP where it is necessary to run bandwidth and latency
24# sweeps on the Arm Ethos-U NPUs. The wrapper library here provides an
25# easy way to add initialisation of the timing adapter block.
26
Kshitij Sisodia8c61c0a2022-05-17 11:16:22 +010027cmake_minimum_required(VERSION 3.16.3)
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000028set(ETHOS_U_NPU_TA_COMPONENT ethos_u_ta)
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000029project(${ETHOS_U_NPU_TA_COMPONENT}
30 DESCRIPTION "Ethos-U NPU timing adapter initialization library"
31 LANGUAGES C CXX ASM)
32
33# Checks
Kshitij Sisodia8bc863d2022-03-24 17:53:34 +000034## Source generated Source path check
35if (NOT DEFINED SOURCE_GEN_DIR)
36 set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/ta)
37endif()
38
Kshitij Sisodiada2ec062022-04-01 14:43:53 +010039# Base address definitions for the two timing adapters (platform should override these):
40set(TA0_BASE "0x58103000" CACHE STRING "Ethos-U NPU timing adapter 0")
41set(TA1_BASE "0x58103200" CACHE STRING "Ethos-U NPU timing adapter 1")
42
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000043## If a TA config file is provided, we generate a settings file
44if (DEFINED TA_CONFIG_FILE)
45 include(${TA_CONFIG_FILE})
46 set(TA_SETTINGS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/timing_adapter_settings.template)
47 configure_file("${TA_SETTINGS_TEMPLATE}" "${SOURCE_GEN_DIR}/timing_adapter_settings.h")
48endif()
49
50## Timing adapter Source path check
51if (NOT DEFINED ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH)
52 message(FATAL_ERROR "ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH should"
53 " be defined when ETHOS_U_NPU_ENABLED=${ETHOS_U_NPU_ENABLED}")
54endif()
55
Kshitij Sisodiaea8ce562022-04-12 11:10:11 +010056## TA driver
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000057add_subdirectory(${ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH} ${CMAKE_BINARY_DIR}/timing_adapter)
58
Kshitij Sisodiaea8ce562022-04-12 11:10:11 +010059## Logging utilities:
60if (NOT TARGET log)
61 if (NOT DEFINED LOG_PROJECT_DIR)
62 message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.")
63 endif()
64 add_subdirectory(${LOG_PROJECT_DIR} ${CMAKE_BINARY_DIR}/log)
65endif()
66
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000067# Create static library
68add_library(${ETHOS_U_NPU_TA_COMPONENT} STATIC)
69
70## Include directories - public
71target_include_directories(${ETHOS_U_NPU_TA_COMPONENT}
72 PUBLIC
73 include
74 ${SOURCE_GEN_DIR})
75
76## Component sources
77target_sources(${ETHOS_U_NPU_TA_COMPONENT}
78 PRIVATE
79 ethosu_ta_init.c)
80
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000081## Compile definitions
82target_compile_definitions(${ETHOS_U_NPU_TA_COMPONENT}
83 PUBLIC
84 ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
85
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000086## Add dependencies
87target_link_libraries(${ETHOS_U_NPU_TA_COMPONENT} PUBLIC
88 timing_adapter
89 log)
90
91# Display status
92message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
93message(STATUS "*******************************************************")
94message(STATUS "Library : " ${ETHOS_U_NPU_TA_COMPONENT})
95message(STATUS "*******************************************************")