From dd8975eae5e2fa42f16b521b45080e20e1e45bd3 Mon Sep 17 00:00:00 2001 From: Michael Rogenmoser Date: Tue, 14 Sep 2021 10:46:13 +0200 Subject: [PATCH] Add tcls config to HAL, ensure proper core number is used --- configs/tcls_pulp_ibex.sh | 17 +++++++++++++ include/hal/chips/pulp/pulp.h | 4 +++ include/hal/tcls/tcls.h | 47 +++++++++++++++++++++++++++++++++++ include/pulp.h | 12 +++++++++ kernel/cluster.c | 8 +++--- rules/pulpos/targets/pulp.mk | 4 +++ 6 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 configs/tcls_pulp_ibex.sh create mode 100644 include/hal/tcls/tcls.h diff --git a/configs/tcls_pulp_ibex.sh b/configs/tcls_pulp_ibex.sh new file mode 100644 index 0000000..c525b44 --- /dev/null +++ b/configs/tcls_pulp_ibex.sh @@ -0,0 +1,17 @@ +#!/bin/bash -e + +export PULPRT_TARGET=pulp +export PULPRUN_TARGET=pulp +export USE_IBEX=1 +export ARCHI_TCLS=1 + +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi + +source $scriptDir/common.sh diff --git a/include/hal/chips/pulp/pulp.h b/include/hal/chips/pulp/pulp.h index 5b12fb6..cf6af16 100644 --- a/include/hal/chips/pulp/pulp.h +++ b/include/hal/chips/pulp/pulp.h @@ -40,4 +40,8 @@ #include "hal/udma/spim/udma_spim_v3.h" #include "hal/udma/uart/udma_uart_v1.h" +#ifdef ARCHI_TCLS +#include "hal/tcls/tcls.h" +#endif // ARCHI_TCLS + #endif diff --git a/include/hal/tcls/tcls.h b/include/hal/tcls/tcls.h new file mode 100644 index 0000000..9370716 --- /dev/null +++ b/include/hal/tcls/tcls.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2021 ETH Zurich and University of Bologna + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __HAL_TCLS_H +#define __HAL_TCLS_H + +#include "archi/pulp.h" +#include + +static inline void enable_tcls() { + int * tcls_config; + for (int i = 0; i < 2; i++) { + tcls_config = (int*)(ARCHI_CLUSTER_GLOBAL_ADDR(0) + ARCHI_TCLS_ADDR + 0x4 + i*0x100); + *tcls_config = 1; + } + printf("In TCLS config\n"); +} + +static inline void disable_tcls() { + int * tcls_config; + for (int i = 0; i < 2; i++) { + tcls_config = (int*)(ARCHI_CLUSTER_GLOBAL_ADDR(0) + ARCHI_TCLS_ADDR + 0x4 + i*0x100); + *tcls_config = 0; + } + printf("TCLS disabled\n"); +} + +static inline int check_tcls_enabled() { + int * tcls_config; + tcls_config = (int*)(ARCHI_CLUSTER_GLOBAL_ADDR(0) + ARCHI_TCLS_ADDR + 0x4); + return *tcls_config > 0; +} + +#endif // __HAL_TCLS_H diff --git a/include/pulp.h b/include/pulp.h index c56b2d5..c4500e9 100755 --- a/include/pulp.h +++ b/include/pulp.h @@ -27,6 +27,9 @@ #include #include #include +#ifdef ARCHI_TCLS +#include +#endif // ARCHI_TCLS typedef enum { PI_FREQ_DOMAIN_FC = 0, @@ -66,7 +69,16 @@ void _start(); #define get_cluster_id hal_cluster_id #ifdef ARCHI_CLUSTER_NB_PE +#ifndef ARCHI_TCLS static inline int get_core_num() { return ARCHI_CLUSTER_NB_PE; } +#else // ARCHI_TCLS +static inline int get_core_num() { + if (check_tcls_enabled()) { + return ARCHI_CLUSTER_NB_PE/3; + } + return ARCHI_CLUSTER_NB_PE; +} +#endif // ARCHI_TCLS #endif diff --git a/kernel/cluster.c b/kernel/cluster.c index 872eab9..207ec09 100644 --- a/kernel/cluster.c +++ b/kernel/cluster.c @@ -40,7 +40,7 @@ static void cluster_core_init() { eu_evt_maskSet((1<