Skip to content

Commit c056d90

Browse files
committed
hw: fix MDA multicast Xbar integration
1 parent 1b135a8 commit c056d90

File tree

6 files changed

+28
-20
lines changed

6 files changed

+28
-20
lines changed

hw/snitch/src/snitch.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
281281
dm::dcsr_t dcsr_d, dcsr_q;
282282
logic [31:0] dpc_d, dpc_q;
283283
logic [31:0] dscratch_d, dscratch_q;
284-
284+
285285
logic debug_d, debug_q;
286286
// Multicast mask
287287
logic [31:0] csr_mcast_d, csr_mcast_q;

hw/snitch_cluster/src/snitch_cluster.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ module snitch_cluster
329329
UniqueIds: 1'b0,
330330
AxiAddrWidth: PhysicalAddrWidth,
331331
AxiDataWidth: WideDataWidth,
332-
NoAddrRules: 2,
332+
NoAddrRules: NrWideRules,
333333
NoMulticastRules: 1,
334334
NoMulticastPorts: 2,
335335
default: '0

sw/snRuntime/src/dma.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ inline uint32_t snrt_dma_start_1d_wideptr(uint64_t dst, uint64_t src,
6060
}
6161

6262
/**
63-
* @brief Start an asynchronous multicast 1D DMA transfer with 64-bit wide pointers.
63+
* @brief Start an asynchronous multicast 1D DMA transfer with 64-bit wide
64+
* pointers.
6465
* @param dst The destination address.
6566
* @param src The source address.
6667
* @param size The size of the transfer in bytes.
@@ -119,15 +120,17 @@ inline snrt_dma_txid_t snrt_dma_start_1d(void *dst, const void *src,
119120
}
120121

121122
/**
122-
* @brief Start an asynchronous multicast 1D DMA transfer with native-size pointers.
123+
* @brief Start an asynchronous multicast 1D DMA transfer with native-size
124+
* pointers.
123125
* @param dst The destination pointer.
124126
* @param src The source pointer.
125127
* @param size The size of the transfer in bytes.
126128
* @return The DMA transfer ID.
127129
*/
128130
inline snrt_dma_txid_t snrt_dma_start_1d_mcast(void *dst, const void *src,
129131
size_t size, uint32_t mcast) {
130-
return snrt_dma_start_1d_mcast_wideptr((size_t)dst, (size_t)src, size, mcast);
132+
return snrt_dma_start_1d_mcast_wideptr((size_t)dst, (size_t)src, size,
133+
mcast);
131134
}
132135

133136
/**
@@ -487,10 +490,13 @@ inline snrt_dma_txid_t snrt_dma_load_1d_tile(void *dst, void *src,
487490
* @param mcast Multicast mask applied on the destination address.
488491
*/
489492
inline snrt_dma_txid_t snrt_dma_mcast_load_1d_tile(void *dst, void *src,
490-
size_t tile_idx, size_t tile_size,
491-
uint32_t prec, uint32_t mcast) {
493+
size_t tile_idx,
494+
size_t tile_size,
495+
uint32_t prec,
496+
uint32_t mcast) {
492497
size_t tile_nbytes = tile_size * prec;
493-
return snrt_dma_start_1d_mcast(dst, src + tile_idx * tile_nbytes, tile_nbytes, mcast);
498+
return snrt_dma_start_1d_mcast(dst, src + tile_idx * tile_nbytes,
499+
tile_nbytes, mcast);
494500
}
495501

496502
/**

sw/snRuntime/src/start.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static inline void snrt_init_bss() {
5757
if (snrt_is_dm_core()) {
5858
size_t size = (size_t)(&__bss_end) - (size_t)(&__bss_start);
5959
snrt_dma_start_1d_wideptr((uint64_t)(&__bss_start),
60-
(uint64_t)(snrt_zero_memory_ptr()), size);
60+
(uint64_t)(snrt_zero_memory_ptr()), size);
6161
snrt_dma_wait_all();
6262
}
6363
snrt_cluster_hw_barrier();
@@ -66,9 +66,9 @@ static inline void snrt_init_bss() {
6666
#endif
6767

6868
#ifdef SNRT_WAKE_UP
69-
static inline void snrt_wake_up(){
70-
if(snrt_cluster_idx() == 0 && snrt_cluster_core_idx() == 0){
71-
snrt_wake_all((1 << snrt_cluster_core_num()) - 1 );
69+
static inline void snrt_wake_up() {
70+
if (snrt_cluster_idx() == 0 && snrt_cluster_core_idx() == 0) {
71+
snrt_wake_all((1 << snrt_cluster_core_num()) - 1);
7272
} else {
7373
snrt_int_clr_mcip();
7474
}
@@ -117,7 +117,7 @@ extern void snrt_exit(int exit_code);
117117

118118
void snrt_main() {
119119
int exit_code = 0;
120-
if (snrt_cluster_core_idx() == 0 && snrt_cluster_idx() == 0){
120+
if (snrt_cluster_core_idx() == 0 && snrt_cluster_idx() == 0) {
121121
snrt_int_clr_mcip();
122122
}
123123

sw/snRuntime/src/sync.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,24 @@ inline void snrt_mutex_release(volatile uint32_t *pmtx) {
7575
// Barrier functions
7676
//================================================================================
7777

78-
inline void snrt_wake_all(uint32_t core_mask){
78+
inline void snrt_wake_all(uint32_t core_mask) {
7979
#ifdef SUPPORTS_MULTICAST
8080
// Multicast cluster interrupt to every other cluster's core
8181
// Note: we need to address another cluster's address space
8282
// because the cluster XBAR has not been extended to support
8383
// multicast yet. We address the second cluster, if we are the
8484
// first cluster, and the second otherwise.
85-
uintptr_t addr = (uintptr_t)snrt_cluster_clint_set_ptr() - SNRT_CLUSTER_OFFSET * snrt_cluster_idx();
85+
uintptr_t addr = (uintptr_t)snrt_cluster_clint_set_ptr() -
86+
SNRT_CLUSTER_OFFSET * snrt_cluster_idx();
8687
if (snrt_cluster_idx() == 0) addr += SNRT_CLUSTER_OFFSET;
8788
snrt_enable_multicast(BCAST_MASK_ALL);
8889
*((uint32_t *)addr) = core_mask;
8990
snrt_disable_multicast();
9091
#else
91-
for (int i = 0; i < snrt_cluster_num(); i++){
92-
if (snrt_cluster_idx() != i){
93-
void* ptr = snrt_remote_l1_ptr(snrt_cluster_clint_set_ptr(), snrt_cluster_idx(), i);
92+
for (int i = 0; i < snrt_cluster_num(); i++) {
93+
if (snrt_cluster_idx() != i) {
94+
void *ptr = snrt_remote_l1_ptr(snrt_cluster_clint_set_ptr(),
95+
snrt_cluster_idx(), i);
9496
*((uint32_t *)ptr) = core_mask;
9597
}
9698
}
@@ -147,7 +149,6 @@ inline void snrt_global_barrier() {
147149
// Synchronize all DM cores in software
148150
if (snrt_is_dm_core()) {
149151
snrt_inter_cluster_barrier();
150-
151152
}
152153
// Synchronize cores in a cluster with the HW barrier
153154
snrt_cluster_hw_barrier();

target/snitch_cluster/sw/runtime/rtl/src/snitch_cluster_start.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
#pragma once
66

7-
#define SNRT_INIT_TLS
87
#define SNRT_INIT_BSS
8+
#define SNRT_WAKE_UP
9+
#define SNRT_INIT_TLS
910
#define SNRT_INIT_CLS
1011
#define SNRT_INIT_LIBS
1112
#define SNRT_CRT0_PRE_BARRIER

0 commit comments

Comments
 (0)