blob: 2cec1418abfffdcd392e4ce644b1faa39dedccd2 [file] [log] [blame]
Isabella Gottardi118f73e2021-09-16 17:54:35 +01001/*
Richard Burtonf32a86a2022-11-15 11:46:11 +00002 * SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
Isabella Gottardi118f73e2021-09-16 17:54:35 +01003 * 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 */
Isabella Gottardiee4920b2022-02-25 14:29:32 +000017
Isabella Gottardi118f73e2021-09-16 17:54:35 +010018#ifndef ETHOS_U_NPU_MEM_CONFIG_H
19#define ETHOS_U_NPU_MEM_CONFIG_H
20
21#define ETHOS_U_NPU_MEMORY_MODE_SRAM_ONLY 0
22#define ETHOS_U_NPU_MEMORY_MODE_SHARED_SRAM 1
23#define ETHOS_U_NPU_MEMORY_MODE_DEDICATED_SRAM 2
24
25#define ETHOS_U_MEM_BYTE_ALIGNMENT 16
26
27#ifndef ETHOS_U_NPU_MEMORY_MODE
28 #define ETHOS_U_NPU_MEMORY_MODE ETHOS_U_MEMORY_MODE_SHARED_SRAM
29#endif /* ETHOS_U_NPU_MEMORY_MODE */
30
31#if (ETHOS_U_NPU_MEMORY_MODE==ETHOS_U_NPU_MEMORY_MODE_DEDICATED_SRAM)
Isabella Gottardiee4920b2022-02-25 14:29:32 +000032 #ifndef ETHOS_U_NPU_CACHE_SIZE
33 #define ETHOS_U_CACHE_BUF_SZ (393216U) /* See vela doc for reference */
34 #else
35 #define ETHOS_U_CACHE_BUF_SZ ETHOS_U_NPU_CACHE_SIZE
36 #endif /* ETHOS_U_NPU_CACHE_SIZE */
Isabella Gottardi118f73e2021-09-16 17:54:35 +010037#else
38 #define ETHOS_U_CACHE_BUF_SZ (0U)
39#endif /* CACHE_BUF_SZ */
40
41/**
42 * Activation buffer aka tensor arena section name
43 * We have to place the tensor arena in different region based on the memory config.
44 **/
45#if (ETHOS_U_NPU_MEMORY_MODE==ETHOS_U_NPU_MEMORY_MODE_SHARED_SRAM)
46 #define ACTIVATION_BUF_SECTION section(".bss.NoInit.activation_buf_sram")
47 #define ACTIVATION_BUF_SECTION_NAME ("SRAM")
48#elif (ETHOS_U_NPU_MEMORY_MODE==ETHOS_U_NPU_MEMORY_MODE_SRAM_ONLY)
49 #define ACTIVATION_BUF_SECTION section(".bss.NoInit.activation_buf_sram")
50 #define ACTIVATION_BUF_SECTION_NAME ("SRAM")
51#elif (ETHOS_U_NPU_MEMORY_MODE==ETHOS_U_NPU_MEMORY_MODE_DEDICATED_SRAM)
52 #define ACTIVATION_BUF_SECTION section("activation_buf_dram")
53 #define CACHE_BUF_SECTION section(".bss.NoInit.ethos_u_cache")
54 #define ACTIVATION_BUF_SECTION_NAME ("DDR/DRAM")
55 #define CACHE_BUF_ATTRIBUTE __attribute__((aligned(ETHOS_U_MEM_BYTE_ALIGNMENT), CACHE_BUF_SECTION))
56#endif
57
Isabella Gottardiee4920b2022-02-25 14:29:32 +000058#endif /* ETHOS_U_NPU_MEM_CONFIG_H */