Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
Kshitij Sisodia | 5385a64 | 2024-01-17 13:29:43 +0000 | [diff] [blame] | 2 | # SPDX-FileCopyrightText: Copyright 2022, 2024 Arm Limited and/or its |
| 3 | # affiliates <open-source-office@arm.com> |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 4 | # 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 Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 23 | # 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 Sisodia | 9c6f9f8 | 2022-05-20 14:30:02 +0100 | [diff] [blame] | 28 | cmake_minimum_required(VERSION 3.21.0) |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 29 | set(ETHOS_U_NPU_TA_COMPONENT ethos_u_ta) |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 30 | project(${ETHOS_U_NPU_TA_COMPONENT} |
| 31 | DESCRIPTION "Ethos-U NPU timing adapter initialization library" |
| 32 | LANGUAGES C CXX ASM) |
| 33 | |
Kshitij Sisodia | 5385a64 | 2024-01-17 13:29:43 +0000 | [diff] [blame] | 34 | # |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 35 | # Checks |
Kshitij Sisodia | 5385a64 | 2024-01-17 13:29:43 +0000 | [diff] [blame] | 36 | # |
Kshitij Sisodia | 8bc863d | 2022-03-24 17:53:34 +0000 | [diff] [blame] | 37 | ## Source generated Source path check |
| 38 | if (NOT DEFINED SOURCE_GEN_DIR) |
| 39 | set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/ta) |
| 40 | endif() |
| 41 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 42 | ## If a TA config file is provided, we generate a settings file |
| 43 | if (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") |
| 47 | endif() |
| 48 | |
| 49 | ## Timing adapter Source path check |
| 50 | if (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}") |
| 53 | endif() |
| 54 | |
Kshitij Sisodia | ea8ce56 | 2022-04-12 11:10:11 +0100 | [diff] [blame] | 55 | ## TA driver |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 56 | add_subdirectory(${ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH} ${CMAKE_BINARY_DIR}/timing_adapter) |
| 57 | |
Kshitij Sisodia | ea8ce56 | 2022-04-12 11:10:11 +0100 | [diff] [blame] | 58 | ## Logging utilities: |
| 59 | if (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) |
| 64 | endif() |
| 65 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 66 | # Create static library |
| 67 | add_library(${ETHOS_U_NPU_TA_COMPONENT} STATIC) |
| 68 | |
| 69 | ## Include directories - public |
| 70 | target_include_directories(${ETHOS_U_NPU_TA_COMPONENT} |
| 71 | PUBLIC |
| 72 | include |
| 73 | ${SOURCE_GEN_DIR}) |
| 74 | |
| 75 | ## Component sources |
| 76 | target_sources(${ETHOS_U_NPU_TA_COMPONENT} |
| 77 | PRIVATE |
| 78 | ethosu_ta_init.c) |
| 79 | |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 80 | ## Compile definitions |
| 81 | target_compile_definitions(${ETHOS_U_NPU_TA_COMPONENT} |
| 82 | PUBLIC |
| 83 | ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) |
| 84 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 85 | ## Add dependencies |
| 86 | target_link_libraries(${ETHOS_U_NPU_TA_COMPONENT} PUBLIC |
| 87 | timing_adapter |
| 88 | log) |
| 89 | |
| 90 | # Display status |
| 91 | message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) |
| 92 | message(STATUS "*******************************************************") |
| 93 | message(STATUS "Library : " ${ETHOS_U_NPU_TA_COMPONENT}) |
| 94 | message(STATUS "*******************************************************") |