Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2019-2020 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 | cmake_minimum_required(VERSION 3.15.6) |
| 20 | |
| 21 | project(ethosu_core_driver VERSION 0.0.1) |
| 22 | |
| 23 | # |
| 24 | # Build options |
| 25 | # |
| 26 | |
Kristofer Jonsson | 537c71c | 2020-05-05 14:17:22 +0200 | [diff] [blame] | 27 | option(DRIVER_PMU_AUTOINIT "Enable PMU boot auto-initialization" OFF) |
Kristofer Jonsson | daa0d20 | 2020-05-12 12:23:16 +0200 | [diff] [blame] | 28 | option(DRIVER_LOG_SUPPORT "Enable logging." OFF) |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 29 | |
Kristofer Jonsson | 537c71c | 2020-05-05 14:17:22 +0200 | [diff] [blame] | 30 | set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmsis" CACHE PATH "Path to CMSIS.") |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 31 | |
| 32 | # |
| 33 | # Global settings |
| 34 | # |
| 35 | |
| 36 | if(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m0") |
| 37 | add_compile_definitions(CPU_CORTEX_M0) |
| 38 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m3") |
| 39 | add_compile_definitions(CPU_CORTEX_M3) |
| 40 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m33") |
| 41 | add_compile_definitions(CPU_CORTEX_M33) |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 42 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m4") |
| 43 | add_compile_definitions(CPU_CORTEX_M4) |
| 44 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m55") |
| 45 | add_compile_definitions(CPU_CORTEX_M55) |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 46 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m7") |
| 47 | add_compile_definitions(CPU_CORTEX_M7) |
| 48 | else() |
| 49 | message(FATAL_ERROR "Unsupported compiler ${CMAKE_SYSTEM_PROCESSOR}.") |
| 50 | endif() |
| 51 | |
| 52 | # Enable logging support |
Kristofer Jonsson | daa0d20 | 2020-05-12 12:23:16 +0200 | [diff] [blame] | 53 | if(DRIVER_LOG_SUPPORT) |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 54 | add_compile_definitions(LOG_ENABLED) |
| 55 | endif() |
| 56 | |
| 57 | # Make include directories available for current- and sub projects |
| 58 | include_directories(include src) |
| 59 | include_directories(${CMSIS_PATH}/CMSIS/Core/Include) |
| 60 | |
| 61 | # |
| 62 | # Build libraries |
| 63 | # |
| 64 | |
| 65 | # Build driver library |
| 66 | add_library(ethosu_core_driver STATIC) |
Kristofer Jonsson | 537c71c | 2020-05-05 14:17:22 +0200 | [diff] [blame] | 67 | target_include_directories(ethosu_core_driver PUBLIC include) |
Jonny Svärd | 341a0df | 2020-05-20 17:56:37 +0200 | [diff] [blame^] | 68 | target_include_directories(ethosu_core_driver PRIVATE "${PROJECT_BINARY_DIR}/src") |
Kristofer Jonsson | 537c71c | 2020-05-05 14:17:22 +0200 | [diff] [blame] | 69 | target_sources(ethosu_core_driver PRIVATE src/ethosu_driver.c src/ethosu_device.c src/ethosu_pmu.c) |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 70 | |
Jonny Svärd | 341a0df | 2020-05-20 17:56:37 +0200 | [diff] [blame^] | 71 | # Configurables |
| 72 | set(NPU_QCONFIG "2" CACHE STRING "Default QCONFIG") |
| 73 | set(NPU_REGIONCFG_0 "3" CACHE STRING "Default region config 0") |
| 74 | set(NPU_REGIONCFG_1 "0" CACHE STRING "Default region config 1") |
| 75 | set(NPU_REGIONCFG_2 "1" CACHE STRING "Default region config 2") |
| 76 | set(NPU_REGIONCFG_3 "1" CACHE STRING "Default region config 3") |
| 77 | set(NPU_REGIONCFG_4 "1" CACHE STRING "Default region config 4") |
| 78 | set(NPU_REGIONCFG_5 "1" CACHE STRING "Default region config 5") |
| 79 | set(NPU_REGIONCFG_6 "1" CACHE STRING "Default region config 6") |
| 80 | set(NPU_REGIONCFG_7 "1" CACHE STRING "Default region config 7") |
Kristofer Jonsson | 537c71c | 2020-05-05 14:17:22 +0200 | [diff] [blame] | 81 | |
Jonny Svärd | 341a0df | 2020-05-20 17:56:37 +0200 | [diff] [blame^] | 82 | set(AXI_LIMIT0_MAX_BEATS_BYTES "0x0" CACHE STRING "Default AXI_LIMIT0_MAX_BEATS_BYTES ") |
| 83 | set(AXI_LIMIT0_MEM_TYPE "0x0" CACHE STRING "Default AXI_LIMIT0_MEM_TYPE ") |
| 84 | set(AXI_LIMIT0_MAX_OUTSTANDING_READS "32" CACHE STRING "Default AXI_LIMIT0_MAX_OUTSTANDING_READS ") |
| 85 | set(AXI_LIMIT0_MAX_OUTSTANDING_WRITES "16" CACHE STRING "Default AXI_LIMIT0_MAX_OUTSTANDING_WRITES ") |
| 86 | set(AXI_LIMIT1_MAX_BEATS_BYTES "0x0" CACHE STRING "Default AXI_LIMIT1_MAX_BEATS_BYTES ") |
| 87 | set(AXI_LIMIT1_MEM_TYPE "0x0" CACHE STRING "Default AXI_LIMIT1_MEM_TYPE ") |
| 88 | set(AXI_LIMIT1_MAX_OUTSTANDING_READS "32" CACHE STRING "Default AXI_LIMIT1_MAX_OUTSTANDING_READS ") |
| 89 | set(AXI_LIMIT1_MAX_OUTSTANDING_WRITES "16" CACHE STRING "Default AXI_LIMIT1_MAX_OUTSTANDING_WRITES ") |
| 90 | set(AXI_LIMIT2_MAX_BEATS_BYTES "0x0" CACHE STRING "Default AXI_LIMIT2_MAX_BEATS_BYTES ") |
| 91 | set(AXI_LIMIT2_MEM_TYPE "0x0" CACHE STRING "Default AXI_LIMIT2_MEM_TYPE ") |
| 92 | set(AXI_LIMIT2_MAX_OUTSTANDING_READS "32" CACHE STRING "Default AXI_LIMIT2_MAX_OUTSTANDING_READS ") |
| 93 | set(AXI_LIMIT2_MAX_OUTSTANDING_WRITES "16" CACHE STRING "Default AXI_LIMIT2_MAX_OUTSTANDING_WRITES ") |
| 94 | set(AXI_LIMIT3_MAX_BEATS_BYTES "0x0" CACHE STRING "Default AXI_LIMIT3_MAX_BEATS_BYTES ") |
| 95 | set(AXI_LIMIT3_MEM_TYPE "0x0" CACHE STRING "Default AXI_LIMIT3_MEM_TYPE ") |
| 96 | set(AXI_LIMIT3_MAX_OUTSTANDING_READS "32" CACHE STRING "Default AXI_LIMIT3_MAX_OUTSTANDING_READS ") |
| 97 | set(AXI_LIMIT3_MAX_OUTSTANDING_WRITES "16" CACHE STRING "Default AXI_LIMIT3_MAX_OUTSTANDING_WRITES ") |
| 98 | |
| 99 | |
| 100 | # PMU |
| 101 | if(DRIVER_PMU_AUTOINIT) |
| 102 | set(PMU_AUTOINIT TRUE) |
| 103 | set(INIT_PMCR "0x0" CACHE STRING "Register control b0 = CNT_EN = Enable counters (RW), b1 = EVENT_CNT_RST = Reset event counters (WO), b2 = CYCLE_CNT_RST = Reset cycle counter (WO), b[15:11] = Number of event counters (RO)") |
| 104 | set(INIT_PMCNTENSET "0x0" CACHE STRING "Bit k enables event counter k. k=31 enables the cycle counter. Read value is current status.") |
| 105 | set(INIT_PMCNTENCLR "0x0" CACHE STRING "Bit k disables event counter k. k=31 disables the cycle counter. Reda value is current status.") |
| 106 | set(INIT_PMOVSSET "0x0" CACHE STRING "Overflow detection set. Bit k is for counter k. k=31 is cycle counter.") |
| 107 | set(INIT_PMOVSCLR "0x0" CACHE STRING "Overflow detection clear. Bit k is for counter k. k=31 is cycle counter.") |
| 108 | set(INIT_PMINTSET "0x0" CACHE STRING "Interrupt set. Bit k is for counter k. k=31 is cycle counter.") |
| 109 | set(INIT_PMINTCLR "0x8003" CACHE STRING "Interrupt clear. Bit k is for counter k. k=31 is cycle counter.") |
| 110 | set(INIT_PMCCNTR "0x0" CACHE STRING "Cycle counter, 48 bits value") |
| 111 | set(INIT_PMCCNTR_CFG "0x0" CACHE STRING "b[9:0] Start Event – this event number starts the cycle counter b[25:16] Stop Event – this event number stops the cycle counter") |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 112 | endif() |
| 113 | |
Jonny Svärd | 341a0df | 2020-05-20 17:56:37 +0200 | [diff] [blame^] | 114 | configure_file ( |
| 115 | "${PROJECT_SOURCE_DIR}/src/ethosu_config.h.in" |
| 116 | "${PROJECT_BINARY_DIR}/src/ethosu_config.h" |
| 117 | ) |
| 118 | |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 119 | # |
| 120 | # Print build status |
| 121 | # |
| 122 | |
| 123 | message(STATUS "*******************************************************") |
| 124 | message(STATUS "PROJECT_NAME : ${PROJECT_NAME}") |
| 125 | message(STATUS "CMAKE_SYSTEM_PROCESSOR : ${CMAKE_SYSTEM_PROCESSOR}") |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 126 | message(STATUS "CMSIS_PATH : ${CMSIS_PATH}") |
Kristofer Jonsson | daa0d20 | 2020-05-12 12:23:16 +0200 | [diff] [blame] | 127 | message(STATUS "DRIVER_LOG_SUPPORT : ${DRIVER_LOG_SUPPORT}") |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 128 | message(STATUS "*******************************************************") |