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 e0d71fdd3..32417f56e 100644 --- a/hw/snitch_cluster/test/bootdata.cc.tpl +++ b/hw/snitch_cluster/test/bootdata.cc.tpl @@ -14,8 +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['s1_quadrant']['nr_clusters']}, - .s1_quadrant_count = ${cfg['nr_s1_quadrant']}, + .cluster_count = ${cfg['nr_clusters']}, .clint_base = ${hex(cfg['peripherals']['clint']['address'])}}; } // namespace sim diff --git a/target/common/test/tb_lib.hh b/target/common/test/tb_lib.hh index 11c9b4cd3..fe5419f7b 100644 --- a/target/common/test/tb_lib.hh +++ b/target/common/test/tb_lib.hh @@ -126,7 +126,6 @@ struct BootData { uint64_t global_mem_start; uint64_t global_mem_end; uint32_t cluster_count; - uint32_t s1_quadrant_count; uint32_t clint_base; }; extern const BootData BOOTDATA; diff --git a/target/snitch_cluster/cfg/default.hjson b/target/snitch_cluster/cfg/default.hjson index 3c7b176ea..93cb2dbec 100644 --- a/target/snitch_cluster/cfg/default.hjson +++ b/target/snitch_cluster/cfg/default.hjson @@ -4,11 +4,6 @@ // Cluster configuration for a simple testbench system. { - nr_s1_quadrant: 1, - s1_quadrant: { - nr_clusters: 1, - }, - cluster: { boot_addr: 4096, // 0x1000 cluster_base_addr: 268435456, // 0x1000_0000 diff --git a/target/snitch_cluster/cfg/fdiv.hjson b/target/snitch_cluster/cfg/fdiv.hjson index 7ad356dae..c58409ef7 100644 --- a/target/snitch_cluster/cfg/fdiv.hjson +++ b/target/snitch_cluster/cfg/fdiv.hjson @@ -4,11 +4,6 @@ // Cluster configuration for a simple testbench system. { - nr_s1_quadrant: 1, - s1_quadrant: { - nr_clusters: 1, - }, - cluster: { boot_addr: 4096, // 0x1000 cluster_base_addr: 268435456, // 0x1000_0000 diff --git a/target/snitch_cluster/cfg/omega.hjson b/target/snitch_cluster/cfg/omega.hjson index 89cc0c948..65655936a 100644 --- a/target/snitch_cluster/cfg/omega.hjson +++ b/target/snitch_cluster/cfg/omega.hjson @@ -4,11 +4,6 @@ // Cluster configuration for a simple testbench system. { - nr_s1_quadrant: 1, - s1_quadrant: { - nr_clusters: 1, - }, - cluster: { boot_addr: 4096, // 0x1000 cluster_base_addr: 268435456, // 0x1000_0000 diff --git a/target/snitch_cluster/sw/runtime/banshee/src/snrt.h b/target/snitch_cluster/sw/runtime/banshee/src/snrt.h index cf225bbf5..1f510f4e5 100644 --- a/target/snitch_cluster/sw/runtime/banshee/src/snrt.h +++ b/target/snitch_cluster/sw/runtime/banshee/src/snrt.h @@ -7,10 +7,6 @@ #include #include -// Snitch cluster specific -#include "banshee_snitch_cluster_defs.h" -#include "snitch_cluster_memory.h" - // Forward declarations #include "alloc_decls.h" #include "cls_decls.h" @@ -19,6 +15,10 @@ #include "sync_decls.h" #include "team_decls.h" +// Snitch cluster specific +#include "banshee_snitch_cluster_defs.h" +#include "snitch_cluster_memory.h" + // Implementation #include "alloc.h" #include "cls.h" diff --git a/target/snitch_cluster/sw/runtime/common/.gitignore b/target/snitch_cluster/sw/runtime/common/.gitignore index c1bf6c2ff..91b6de1fa 100644 --- a/target/snitch_cluster/sw/runtime/common/.gitignore +++ b/target/snitch_cluster/sw/runtime/common/.gitignore @@ -1,3 +1,3 @@ snitch_cluster_cfg.h snitch_cluster_addrmap.h -snitch_cluster_peripheral.h \ No newline at end of file +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 index 27aaa49d7..433bec208 100644 --- a/target/snitch_cluster/sw/runtime/common/snitch_cluster_defs.h +++ b/target/snitch_cluster/sw/runtime/common/snitch_cluster_defs.h @@ -5,17 +5,3 @@ #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 1 -#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 0x40000 -#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_memory.h b/target/snitch_cluster/sw/runtime/common/snitch_cluster_memory.h index cb30390cc..086eb6050 100644 --- a/target/snitch_cluster/sw/runtime/common/snitch_cluster_memory.h +++ b/target/snitch_cluster/sw/runtime/common/snitch_cluster_memory.h @@ -30,30 +30,34 @@ // snRuntime interface functions //=============================================================== -inline uint32_t __attribute__((const)) snrt_l1_start_addr() { - return CLUSTER_TCDM_START_ADDR; +inline uint32_t cluster_base_offset() { + return snrt_cluster_idx() * SNRT_CLUSTER_OFFSET; } -inline uint32_t __attribute__((const)) snrt_l1_end_addr() { - return CLUSTER_TCDM_END_ADDR; +inline uint32_t snrt_l1_start_addr() { + return CLUSTER_TCDM_BASE_ADDR + cluster_base_offset(); } -inline volatile uint32_t* __attribute__((const)) snrt_cluster_clint_set_ptr() { - return (uint32_t*)CLUSTER_CLINT_SET_ADDR; +inline uint32_t snrt_l1_end_addr() { + return CLUSTER_PERIPH_BASE_ADDR + cluster_base_offset(); } -inline volatile uint32_t* __attribute__((const)) snrt_cluster_clint_clr_ptr() { - return (uint32_t*)CLUSTER_CLINT_CLR_ADDR; +inline volatile uint32_t* snrt_cluster_clint_set_ptr() { + return (uint32_t*)(CLUSTER_CLINT_SET_ADDR + cluster_base_offset()); } -inline uint32_t __attribute__((const)) snrt_cluster_hw_barrier_addr() { - return CLUSTER_HW_BARRIER_ADDR; +inline volatile uint32_t* snrt_cluster_clint_clr_ptr() { + return (uint32_t*)(CLUSTER_CLINT_CLR_ADDR + cluster_base_offset()); } -inline uint32_t __attribute__((const)) snrt_cluster_perf_counters_addr() { - return CLUSTER_PERF_COUNTER_ADDR; +inline uint32_t snrt_cluster_hw_barrier_addr() { + return CLUSTER_HW_BARRIER_ADDR + cluster_base_offset(); } -inline volatile uint32_t* __attribute__((const)) snrt_zero_memory_ptr() { - return (uint32_t*)CLUSTER_ZERO_MEM_START_ADDR; +inline uint32_t snrt_cluster_perf_counters_addr() { + return CLUSTER_PERF_COUNTER_ADDR + cluster_base_offset(); +} + +inline volatile uint32_t* snrt_zero_memory_ptr() { + return (uint32_t*)(CLUSTER_ZERO_MEM_START_ADDR + cluster_base_offset()); } diff --git a/target/snitch_cluster/sw/runtime/rtl/src/snrt.h b/target/snitch_cluster/sw/runtime/rtl/src/snrt.h index 1902c0454..a5a471e63 100644 --- a/target/snitch_cluster/sw/runtime/rtl/src/snrt.h +++ b/target/snitch_cluster/sw/runtime/rtl/src/snrt.h @@ -7,10 +7,6 @@ #include #include -// Snitch cluster specific -#include "snitch_cluster_defs.h" -#include "snitch_cluster_memory.h" - // Forward declarations #include "alloc_decls.h" #include "cls_decls.h" @@ -19,6 +15,10 @@ #include "sync_decls.h" #include "team_decls.h" +// Snitch cluster specific +#include "snitch_cluster_defs.h" +#include "snitch_cluster_memory.h" + // Implementation #include "alloc.h" #include "cls.h"