From df6c73848063b6ba23b49efaa2d261aca434590a Mon Sep 17 00:00:00 2001 From: Tim Fischer Date: Tue, 2 Jul 2024 17:39:17 +0200 Subject: [PATCH] cfg: Merge config + put the `nr_clusters` parameter in the top-level --- docs/schema/snitch_cluster.schema.json | 5 ----- docs/schema/snitch_cluster_tb.schema.json | 5 +++++ hw/snitch_cluster/test/bootdata.cc.tpl | 2 +- target/snitch_cluster/sw.mk | 3 +-- .../sw/runtime/common/.gitignore | 1 - .../runtime/common/snitch_cluster_cfg.h.tpl | 14 ++++++++++++- .../sw/runtime/common/snitch_cluster_defs.h | 7 +++++++ .../runtime/common/snitch_cluster_defs.h.tpl | 21 ------------------- 8 files changed, 27 insertions(+), 31 deletions(-) create mode 100644 target/snitch_cluster/sw/runtime/common/snitch_cluster_defs.h delete mode 100644 target/snitch_cluster/sw/runtime/common/snitch_cluster_defs.h.tpl diff --git a/docs/schema/snitch_cluster.schema.json b/docs/schema/snitch_cluster.schema.json index 8b364d180..f9d5831ca 100644 --- a/docs/schema/snitch_cluster.schema.json +++ b/docs/schema/snitch_cluster.schema.json @@ -14,11 +14,6 @@ "description": "Optional name for the generated wrapper.", "default": "snitch_cluster" }, - "nr_clusters": { - "type": "number", - "description": "Number of clusters. Only relevant for the SW runtime.", - "default": 1 - }, "boot_addr": { "type": "number", "description": "Address from which all harts of the cluster start to boot. The default setting is `0x8000_0000`.", diff --git a/docs/schema/snitch_cluster_tb.schema.json b/docs/schema/snitch_cluster_tb.schema.json index 4fe0cf435..36fd1036a 100644 --- a/docs/schema/snitch_cluster_tb.schema.json +++ b/docs/schema/snitch_cluster_tb.schema.json @@ -11,6 +11,11 @@ "cluster": { "$ref": "http://pulp-platform.org/snitch_cluster/snitch_cluster.schema.json" }, + "nr_clusters": { + "type": "number", + "description": "Number of clusters. Relevant for the SW runtime.", + "default": 1 + }, "dram": { "title": "DRAM", "type": "object", diff --git a/hw/snitch_cluster/test/bootdata.cc.tpl b/hw/snitch_cluster/test/bootdata.cc.tpl index 140f03dcb..32417f56e 100644 --- a/hw/snitch_cluster/test/bootdata.cc.tpl +++ b/hw/snitch_cluster/test/bootdata.cc.tpl @@ -14,7 +14,7 @@ const BootData BOOTDATA = {.boot_addr = ${hex(cfg['cluster']['boot_addr'])}, .tcdm_offset = ${hex(cfg['cluster']['cluster_base_offset'])}, .global_mem_start = ${hex(cfg['dram']['address'])}, .global_mem_end = ${hex(cfg['dram']['address'] + cfg['dram']['length'])}, - .cluster_count = ${cfg['cluster']['nr_clusters']}, + .cluster_count = ${cfg['nr_clusters']}, .clint_base = ${hex(cfg['peripherals']['clint']['address'])}}; } // namespace sim diff --git a/target/snitch_cluster/sw.mk b/target/snitch_cluster/sw.mk index 47d06249e..ca8246124 100644 --- a/target/snitch_cluster/sw.mk +++ b/target/snitch_cluster/sw.mk @@ -18,8 +18,7 @@ clean: clean-sw #################### CLUSTER_GEN_HEADERS = snitch_cluster_cfg.h \ - snitch_cluster_addrmap.h \ - snitch_cluster_defs.h + snitch_cluster_addrmap.h REGGEN_HEADERS = snitch_cluster_peripheral.h diff --git a/target/snitch_cluster/sw/runtime/common/.gitignore b/target/snitch_cluster/sw/runtime/common/.gitignore index 5d08b3b7f..91b6de1fa 100644 --- a/target/snitch_cluster/sw/runtime/common/.gitignore +++ b/target/snitch_cluster/sw/runtime/common/.gitignore @@ -1,4 +1,3 @@ snitch_cluster_cfg.h -snitch_cluster_defs.h snitch_cluster_addrmap.h snitch_cluster_peripheral.h diff --git a/target/snitch_cluster/sw/runtime/common/snitch_cluster_cfg.h.tpl b/target/snitch_cluster/sw/runtime/common/snitch_cluster_cfg.h.tpl index d230062e4..e434e6c88 100644 --- a/target/snitch_cluster/sw/runtime/common/snitch_cluster_cfg.h.tpl +++ b/target/snitch_cluster/sw/runtime/common/snitch_cluster_cfg.h.tpl @@ -3,4 +3,16 @@ // SPDX-License-Identifier: Apache-2.0 #define CFG_CLUSTER_NR_CORES ${cfg['cluster']['nr_cores']} -#define CFG_CLUSTER_BASE_HARTID ${cfg['cluster']['cluster_base_hartid']} \ No newline at end of file +#define CFG_CLUSTER_BASE_HARTID ${cfg['cluster']['cluster_base_hartid']} +#define SNRT_BASE_HARTID CFG_CLUSTER_BASE_HARTID +#define SNRT_CLUSTER_CORE_NUM CFG_CLUSTER_NR_CORES +#define SNRT_CLUSTER_NUM ${cfg['nr_clusters']} +#define SNRT_CLUSTER_DM_CORE_NUM 1 +#define SNRT_TCDM_START_ADDR CLUSTER_TCDM_BASE_ADDR +#define SNRT_TCDM_SIZE (CLUSTER_PERIPH_BASE_ADDR - CLUSTER_TCDM_BASE_ADDR) +#define SNRT_CLUSTER_OFFSET ${cfg['cluster']['cluster_base_offset']} +#define SNRT_CLUSTER_HW_BARRIER_ADDR \ + (CLUSTER_PERIPH_BASE_ADDR + SNITCH_CLUSTER_PERIPHERAL_HW_BARRIER_REG_OFFSET) + +// Software configuration +#define SNRT_LOG2_STACK_SIZE 10 diff --git a/target/snitch_cluster/sw/runtime/common/snitch_cluster_defs.h b/target/snitch_cluster/sw/runtime/common/snitch_cluster_defs.h new file mode 100644 index 000000000..433bec208 --- /dev/null +++ b/target/snitch_cluster/sw/runtime/common/snitch_cluster_defs.h @@ -0,0 +1,7 @@ +// Copyright 2023 ETH Zurich and University of Bologna. +// Licensed under the Apache License, Version 2.0, see LICENSE for details. +// SPDX-License-Identifier: Apache-2.0 + +#include "snitch_cluster_addrmap.h" +#include "snitch_cluster_cfg.h" +#include "snitch_cluster_peripheral.h" diff --git a/target/snitch_cluster/sw/runtime/common/snitch_cluster_defs.h.tpl b/target/snitch_cluster/sw/runtime/common/snitch_cluster_defs.h.tpl deleted file mode 100644 index db765ae9c..000000000 --- a/target/snitch_cluster/sw/runtime/common/snitch_cluster_defs.h.tpl +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2023 ETH Zurich and University of Bologna. -// Licensed under the Apache License, Version 2.0, see LICENSE for details. -// SPDX-License-Identifier: Apache-2.0 - -#include "snitch_cluster_addrmap.h" -#include "snitch_cluster_cfg.h" -#include "snitch_cluster_peripheral.h" - -// Hardware parameters -#define SNRT_BASE_HARTID CFG_CLUSTER_BASE_HARTID -#define SNRT_CLUSTER_CORE_NUM CFG_CLUSTER_NR_CORES -#define SNRT_CLUSTER_NUM ${cfg['cluster']['nr_clusters']} -#define SNRT_CLUSTER_DM_CORE_NUM 1 -#define SNRT_TCDM_START_ADDR CLUSTER_TCDM_BASE_ADDR -#define SNRT_TCDM_SIZE (CLUSTER_PERIPH_BASE_ADDR - CLUSTER_TCDM_BASE_ADDR) -#define SNRT_CLUSTER_OFFSET ${cfg['cluster']['cluster_base_offset']} -#define SNRT_CLUSTER_HW_BARRIER_ADDR \ - (CLUSTER_PERIPH_BASE_ADDR + SNITCH_CLUSTER_PERIPHERAL_HW_BARRIER_REG_OFFSET) - -// Software configuration -#define SNRT_LOG2_STACK_SIZE 10