blob: 91dc9d9a195ed3fe652423e4f541d397a41d3ab0 [file] [log] [blame]
Kristofer Jonsson49bdee82020-04-06 13:21:21 +02001#
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
19cmake_minimum_required(VERSION 3.15.6)
20
21project(ethosu_core_driver VERSION 0.0.1)
22
23#
24# Build options
25#
26
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020027option(DRIVER_PMU_AUTOINIT "Enable PMU boot auto-initialization" OFF)
Kristofer Jonssondaa0d202020-05-12 12:23:16 +020028option(DRIVER_LOG_SUPPORT "Enable logging." OFF)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020029
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020030set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmsis" CACHE PATH "Path to CMSIS.")
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020031
32#
33# Global settings
34#
35
36if(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m0")
37 add_compile_definitions(CPU_CORTEX_M0)
38elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m3")
39 add_compile_definitions(CPU_CORTEX_M3)
40elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m33")
41 add_compile_definitions(CPU_CORTEX_M33)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020042elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m4")
43 add_compile_definitions(CPU_CORTEX_M4)
44elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m55")
45 add_compile_definitions(CPU_CORTEX_M55)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020046elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m7")
47 add_compile_definitions(CPU_CORTEX_M7)
48else()
49 message(FATAL_ERROR "Unsupported compiler ${CMAKE_SYSTEM_PROCESSOR}.")
50endif()
51
52# Enable logging support
Kristofer Jonssondaa0d202020-05-12 12:23:16 +020053if(DRIVER_LOG_SUPPORT)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020054 add_compile_definitions(LOG_ENABLED)
55endif()
56
57# Make include directories available for current- and sub projects
58include_directories(include src)
59include_directories(${CMSIS_PATH}/CMSIS/Core/Include)
60
61#
62# Build libraries
63#
64
65# Build driver library
66add_library(ethosu_core_driver STATIC)
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020067target_include_directories(ethosu_core_driver PUBLIC include)
Jonny Svärd341a0df2020-05-20 17:56:37 +020068target_include_directories(ethosu_core_driver PRIVATE "${PROJECT_BINARY_DIR}/src")
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020069target_sources(ethosu_core_driver PRIVATE src/ethosu_driver.c src/ethosu_device.c src/ethosu_pmu.c)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020070
Jonny Svärd341a0df2020-05-20 17:56:37 +020071# Configurables
72set(NPU_QCONFIG "2" CACHE STRING "Default QCONFIG")
73set(NPU_REGIONCFG_0 "3" CACHE STRING "Default region config 0")
74set(NPU_REGIONCFG_1 "0" CACHE STRING "Default region config 1")
75set(NPU_REGIONCFG_2 "1" CACHE STRING "Default region config 2")
76set(NPU_REGIONCFG_3 "1" CACHE STRING "Default region config 3")
77set(NPU_REGIONCFG_4 "1" CACHE STRING "Default region config 4")
78set(NPU_REGIONCFG_5 "1" CACHE STRING "Default region config 5")
79set(NPU_REGIONCFG_6 "1" CACHE STRING "Default region config 6")
80set(NPU_REGIONCFG_7 "1" CACHE STRING "Default region config 7")
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020081
Jonny Svärd341a0df2020-05-20 17:56:37 +020082set(AXI_LIMIT0_MAX_BEATS_BYTES "0x0" CACHE STRING "Default AXI_LIMIT0_MAX_BEATS_BYTES ")
83set(AXI_LIMIT0_MEM_TYPE "0x0" CACHE STRING "Default AXI_LIMIT0_MEM_TYPE ")
84set(AXI_LIMIT0_MAX_OUTSTANDING_READS "32" CACHE STRING "Default AXI_LIMIT0_MAX_OUTSTANDING_READS ")
85set(AXI_LIMIT0_MAX_OUTSTANDING_WRITES "16" CACHE STRING "Default AXI_LIMIT0_MAX_OUTSTANDING_WRITES ")
86set(AXI_LIMIT1_MAX_BEATS_BYTES "0x0" CACHE STRING "Default AXI_LIMIT1_MAX_BEATS_BYTES ")
87set(AXI_LIMIT1_MEM_TYPE "0x0" CACHE STRING "Default AXI_LIMIT1_MEM_TYPE ")
88set(AXI_LIMIT1_MAX_OUTSTANDING_READS "32" CACHE STRING "Default AXI_LIMIT1_MAX_OUTSTANDING_READS ")
89set(AXI_LIMIT1_MAX_OUTSTANDING_WRITES "16" CACHE STRING "Default AXI_LIMIT1_MAX_OUTSTANDING_WRITES ")
90set(AXI_LIMIT2_MAX_BEATS_BYTES "0x0" CACHE STRING "Default AXI_LIMIT2_MAX_BEATS_BYTES ")
91set(AXI_LIMIT2_MEM_TYPE "0x0" CACHE STRING "Default AXI_LIMIT2_MEM_TYPE ")
92set(AXI_LIMIT2_MAX_OUTSTANDING_READS "32" CACHE STRING "Default AXI_LIMIT2_MAX_OUTSTANDING_READS ")
93set(AXI_LIMIT2_MAX_OUTSTANDING_WRITES "16" CACHE STRING "Default AXI_LIMIT2_MAX_OUTSTANDING_WRITES ")
94set(AXI_LIMIT3_MAX_BEATS_BYTES "0x0" CACHE STRING "Default AXI_LIMIT3_MAX_BEATS_BYTES ")
95set(AXI_LIMIT3_MEM_TYPE "0x0" CACHE STRING "Default AXI_LIMIT3_MEM_TYPE ")
96set(AXI_LIMIT3_MAX_OUTSTANDING_READS "32" CACHE STRING "Default AXI_LIMIT3_MAX_OUTSTANDING_READS ")
97set(AXI_LIMIT3_MAX_OUTSTANDING_WRITES "16" CACHE STRING "Default AXI_LIMIT3_MAX_OUTSTANDING_WRITES ")
98
99
100# PMU
101if(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 Jonsson49bdee82020-04-06 13:21:21 +0200112endif()
113
Jonny Svärd341a0df2020-05-20 17:56:37 +0200114configure_file (
115 "${PROJECT_SOURCE_DIR}/src/ethosu_config.h.in"
116 "${PROJECT_BINARY_DIR}/src/ethosu_config.h"
117)
118
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200119#
120# Print build status
121#
122
123message(STATUS "*******************************************************")
124message(STATUS "PROJECT_NAME : ${PROJECT_NAME}")
125message(STATUS "CMAKE_SYSTEM_PROCESSOR : ${CMAKE_SYSTEM_PROCESSOR}")
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200126message(STATUS "CMSIS_PATH : ${CMSIS_PATH}")
Kristofer Jonssondaa0d202020-05-12 12:23:16 +0200127message(STATUS "DRIVER_LOG_SUPPORT : ${DRIVER_LOG_SUPPORT}")
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200128message(STATUS "*******************************************************")