Skip to content

Commit

Permalink
Improve snrt to calculate the correct cluster index (#273)
Browse files Browse the repository at this point in the history
* improve_snrt

* Bug Fix

* Bug Fix
  • Loading branch information
IveanEx committed Aug 26, 2024
1 parent 05df4d9 commit c8ccfad
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sw/snRuntime/src/team.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ inline uint32_t __attribute__((const)) snrt_global_compute_core_idx() {

inline uint32_t __attribute__((const)) snrt_cluster_idx() {
// return snrt_global_core_idx() / snrt_cluster_core_num();
return (snrt_cluster_base_addrl() & 0xfc0000) >> 18;
return (snrt_cluster_base_addrl() & 0xfc0000) >> CLUSTER_ADDRWIDTH;
}

inline uint32_t __attribute__((const)) snrt_cluster_core_idx() {
Expand Down
2 changes: 1 addition & 1 deletion target/snitch_cluster/cfg/default.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name: "snitch_cluster",
boot_addr: 4096, // 0x1000
cluster_base_addr: 268435456, // 0x1000_0000
cluster_base_offset: 0, // 0x0
cluster_base_offset: 262144, // 256KB
cluster_base_hartid: 0,
addr_width: 48,
data_width: 64,
Expand Down
2 changes: 1 addition & 1 deletion target/snitch_cluster/cfg/snax-alu.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name: "snax_alu_cluster",
boot_addr: 4096, // 0x1000
cluster_base_addr: 268435456, // 0x1000_0000
cluster_base_offset: 0, // 0x0
cluster_base_offset: 262144, // 256KB
cluster_base_hartid: 0,
addr_width: 48,
data_width: 64,
Expand Down
2 changes: 1 addition & 1 deletion target/snitch_cluster/cfg/snax-hypercorex.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name: "snax_hypercorex_cluster",
boot_addr: 4096, // 0x1000
cluster_base_addr: 268435456, // 0x1000_0000
cluster_base_offset: 0, // 0x0
cluster_base_offset: 262144, // 256KB
cluster_base_hartid: 0,
addr_width: 48,
data_width: 64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name: "snax_KUL_xdma_cluster",
boot_addr: 4096, // 0x1000
cluster_base_addr: 268435456, // 0x1000_0000
cluster_base_offset: 0, // 0x0
cluster_base_offset: 262144, // 256KB
cluster_base_hartid: 0,
addr_width: 48,
data_width: 64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name: "snax_KUL_cluster",
boot_addr: 4096, // 0x1000
cluster_base_addr: 268435456, // 0x1000_0000
cluster_base_offset: 0, // 0x0
cluster_base_offset: 262144, // 256KB
cluster_base_hartid: 0,
addr_width: 48,
data_width: 64,
Expand Down
2 changes: 1 addition & 1 deletion target/snitch_cluster/cfg/snax-mac-mult.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name: "snax_mac_mult_cluster",
boot_addr: 4096, // 0x1000
cluster_base_addr: 268435456, // 0x1000_0000
cluster_base_offset: 0, // 0x0
cluster_base_offset: 262144, // 256KB
cluster_base_hartid: 0,
addr_width: 48,
data_width: 64,
Expand Down
2 changes: 1 addition & 1 deletion target/snitch_cluster/cfg/snax-mac.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name: "snax_mac_cluster",
boot_addr: 4096, // 0x1000
cluster_base_addr: 268435456, // 0x1000_0000
cluster_base_offset: 0, // 0x0
cluster_base_offset: 262144, // 256KB
cluster_base_hartid: 0,
addr_width: 48,
data_width: 64,
Expand Down
2 changes: 1 addition & 1 deletion target/snitch_cluster/cfg/snax-streamer-gemm-add-c.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
name: "snax_streamer_gemm_add_c_cluster",
boot_addr: 4096, // 0x1000
cluster_base_addr: 268435456, // 0x1000_0000
cluster_base_offset: 0, // 0x0
cluster_base_offset: 262144, // 256KB
cluster_base_hartid: 0,
addr_width: 48,
data_width: 64,
Expand Down
2 changes: 1 addition & 1 deletion target/snitch_cluster/cfg/snax-streamer-gemm.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name: "snax_streamer_gemm_cluster",
boot_addr: 4096, // 0x1000
cluster_base_addr: 268435456, // 0x1000_0000
cluster_base_offset: 0, // 0x0
cluster_base_offset: 262144, // 256KB
cluster_base_hartid: 0,
addr_width: 48,
data_width: 64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0



#define CLUSTER_TCDM_BASE_ADDR ${hex(cfg['cluster']['cluster_base_addr'])}
#define CLUSTER_PERIPH_BASE_ADDR (CLUSTER_TCDM_BASE_ADDR + ${hex(cfg['cluster']['tcdm']['size'] * 1024)})
#define CLUSTER_TCDM_SIZE ${hex(cfg['cluster']['tcdm']['size'] * 1024)}
#define CLUSTER_SIZE ${hex(cfg['cluster']['cluster_base_offset'])}
<%
import math
cluster_addrwidth = int(math.log2(cfg['cluster']['cluster_base_offset']))
%>
#define CLUSTER_ADDRWIDTH ${cluster_addrwidth}
#define CLUSTER_PERIPH_BASE_ADDR (CLUSTER_TCDM_BASE_ADDR + CLUSTER_TCDM_SIZE)
#define CLUSTER_ZERO_MEM_START_ADDR (CLUSTER_PERIPH_BASE_ADDR + ${hex(cfg['cluster']['cluster_periph_size'] * 1024)})
#define CLUSTER_ZERO_MEM_END_ADDR (CLUSTER_ZERO_MEM_START_ADDR + ${hex(cfg['cluster']['zero_mem_size'] * 1024)})
#define CLINT_BASE_ADDR ${hex(cfg['peripherals']['clint']['address'])}

0 comments on commit c8ccfad

Please sign in to comment.