blob: 9956384eff62280830d14e95d0a1372cbdf1dcaa [file] [log] [blame]
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +00001#----------------------------------------------------------------------------
Kshitij Sisodia5385a642024-01-17 13:29:43 +00002# SPDX-FileCopyrightText: Copyright 2022, 2024 Arm Limited and/or its
3# affiliates <open-source-office@arm.com>
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +00004# SPDX-License-Identifier: Apache-2.0
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://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,
14# WITHOUT 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# Ethos-U NPU timing adapter initialization library #
21#########################################################
22
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000023# Timing adapter component is only available on certain implementations
24# on FPGA and FVP where it is necessary to run bandwidth and latency
25# sweeps on the Arm Ethos-U NPUs. The wrapper library here provides an
26# easy way to add initialisation of the timing adapter block.
27
Kshitij Sisodia9c6f9f82022-05-20 14:30:02 +010028cmake_minimum_required(VERSION 3.21.0)
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000029set(ETHOS_U_NPU_TA_COMPONENT ethos_u_ta)
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000030project(${ETHOS_U_NPU_TA_COMPONENT}
31 DESCRIPTION "Ethos-U NPU timing adapter initialization library"
32 LANGUAGES C CXX ASM)
33
Kshitij Sisodia5385a642024-01-17 13:29:43 +000034#
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000035# Checks
Kshitij Sisodia5385a642024-01-17 13:29:43 +000036#
Kshitij Sisodia8bc863d2022-03-24 17:53:34 +000037## Source generated Source path check
38if (NOT DEFINED SOURCE_GEN_DIR)
39 set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/ta)
40endif()
41
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000042## If a TA config file is provided, we generate a settings file
43if (DEFINED TA_CONFIG_FILE)
44 include(${TA_CONFIG_FILE})
45 set(TA_SETTINGS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/timing_adapter_settings.template)
46 configure_file("${TA_SETTINGS_TEMPLATE}" "${SOURCE_GEN_DIR}/timing_adapter_settings.h")
47endif()
48
49## Timing adapter Source path check
50if (NOT DEFINED ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH)
51 message(FATAL_ERROR "ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH should"
52 " be defined when ETHOS_U_NPU_ENABLED=${ETHOS_U_NPU_ENABLED}")
53endif()
54
Kshitij Sisodiaea8ce562022-04-12 11:10:11 +010055## TA driver
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000056add_subdirectory(${ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH} ${CMAKE_BINARY_DIR}/timing_adapter)
57
Kshitij Sisodiaea8ce562022-04-12 11:10:11 +010058## Logging utilities:
59if (NOT TARGET log)
60 if (NOT DEFINED LOG_PROJECT_DIR)
61 message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.")
62 endif()
63 add_subdirectory(${LOG_PROJECT_DIR} ${CMAKE_BINARY_DIR}/log)
64endif()
65
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000066# Create static library
67add_library(${ETHOS_U_NPU_TA_COMPONENT} STATIC)
68
69## Include directories - public
70target_include_directories(${ETHOS_U_NPU_TA_COMPONENT}
71 PUBLIC
72 include
73 ${SOURCE_GEN_DIR})
74
75## Component sources
76target_sources(${ETHOS_U_NPU_TA_COMPONENT}
77 PRIVATE
78 ethosu_ta_init.c)
79
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000080## Compile definitions
81target_compile_definitions(${ETHOS_U_NPU_TA_COMPONENT}
82 PUBLIC
83 ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
84
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000085## Add dependencies
86target_link_libraries(${ETHOS_U_NPU_TA_COMPONENT} PUBLIC
87 timing_adapter
88 log)
89
90# Display status
91message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
92message(STATUS "*******************************************************")
93message(STATUS "Library : " ${ETHOS_U_NPU_TA_COMPONENT})
94message(STATUS "*******************************************************")