Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
| 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 Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 22 | # 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 Sisodia | 8c61c0a | 2022-05-17 11:16:22 +0100 | [diff] [blame^] | 27 | cmake_minimum_required(VERSION 3.16.3) |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 28 | set(ETHOS_U_NPU_TA_COMPONENT ethos_u_ta) |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 29 | project(${ETHOS_U_NPU_TA_COMPONENT} |
| 30 | DESCRIPTION "Ethos-U NPU timing adapter initialization library" |
| 31 | LANGUAGES C CXX ASM) |
| 32 | |
| 33 | # Checks |
Kshitij Sisodia | 8bc863d | 2022-03-24 17:53:34 +0000 | [diff] [blame] | 34 | ## Source generated Source path check |
| 35 | if (NOT DEFINED SOURCE_GEN_DIR) |
| 36 | set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/ta) |
| 37 | endif() |
| 38 | |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 39 | # Base address definitions for the two timing adapters (platform should override these): |
| 40 | set(TA0_BASE "0x58103000" CACHE STRING "Ethos-U NPU timing adapter 0") |
| 41 | set(TA1_BASE "0x58103200" CACHE STRING "Ethos-U NPU timing adapter 1") |
| 42 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 43 | ## If a TA config file is provided, we generate a settings file |
| 44 | if (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") |
| 48 | endif() |
| 49 | |
| 50 | ## Timing adapter Source path check |
| 51 | if (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}") |
| 54 | endif() |
| 55 | |
Kshitij Sisodia | ea8ce56 | 2022-04-12 11:10:11 +0100 | [diff] [blame] | 56 | ## TA driver |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 57 | add_subdirectory(${ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH} ${CMAKE_BINARY_DIR}/timing_adapter) |
| 58 | |
Kshitij Sisodia | ea8ce56 | 2022-04-12 11:10:11 +0100 | [diff] [blame] | 59 | ## Logging utilities: |
| 60 | if (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) |
| 65 | endif() |
| 66 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 67 | # Create static library |
| 68 | add_library(${ETHOS_U_NPU_TA_COMPONENT} STATIC) |
| 69 | |
| 70 | ## Include directories - public |
| 71 | target_include_directories(${ETHOS_U_NPU_TA_COMPONENT} |
| 72 | PUBLIC |
| 73 | include |
| 74 | ${SOURCE_GEN_DIR}) |
| 75 | |
| 76 | ## Component sources |
| 77 | target_sources(${ETHOS_U_NPU_TA_COMPONENT} |
| 78 | PRIVATE |
| 79 | ethosu_ta_init.c) |
| 80 | |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 81 | ## Compile definitions |
| 82 | target_compile_definitions(${ETHOS_U_NPU_TA_COMPONENT} |
| 83 | PUBLIC |
| 84 | ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) |
| 85 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 86 | ## Add dependencies |
| 87 | target_link_libraries(${ETHOS_U_NPU_TA_COMPONENT} PUBLIC |
| 88 | timing_adapter |
| 89 | log) |
| 90 | |
| 91 | # Display status |
| 92 | message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) |
| 93 | message(STATUS "*******************************************************") |
| 94 | message(STATUS "Library : " ${ETHOS_U_NPU_TA_COMPONENT}) |
| 95 | message(STATUS "*******************************************************") |