Snitch Clusters
-
void setup_snitchCluster_interruptHandler(void *handler)
Setup the interrupt handler for the cluster cores. All cores in all clusters will jump to the handler when an interrupt is triggered.
- Parameters:
handler – Function pointer to the interrupt handler
-
void *generate_snitchCluster_SPs(uint8_t clusterId, void *sp, uint32_t *stack_size, void **stack_ptr)
Generate the stack pointers for all cores of a given cluster using given stack sizes passed on a per-core basis. The stack pointers are generated compliant to the RISC-V ABI, are aligned to 16-Byte boundaries and are assumed to grow downwards.
- Parameters:
clusterId – ID of the cluster to generate the stack pointers for
sp – The memory address that serves as a base for the stack pointer
stack_size – [in] An array containing the requested stack sizes in Bytes. Must reference an array whose length matches the number of cores in the specified cluster.
stack_ptr – [out] An array to hold the generated stack pointers. Must reference an array whose length matches the number of cores in the specified cluster.
- Returns:
The pointer to the end of available memory after allocating all stacks.
-
void *generate_snitchCluster_SPs_uniform(uint8_t clusterId, void *sp, uint32_t stack_size, void **stack_ptr)
Generate the stack pointers for all cores of a given cluster using the given stack size equal for all cores. The stack pointers are generated compliant to the RISC-V ABI, are aligned to 16-Byte boundaries and are assumed to grow downwards.
- Parameters:
clusterId – ID of the cluster to generate the stack pointers for
sp – The memory address that serves as a base for the stack pointer
stack_size – The stack size per core in the cluster in Bytes.
stack_ptr – [out] An array to hold the generated stack pointers. Must reference an array whose length matches the number of cores in the specified cluster.
- Returns:
The pointer to the end of available memory after allocating all stacks.
-
void offload_snitchCluster(void *function, void *trampoline, void *args, void **stack_ptr, uint8_t clusterId)
Offload a void function pointer to a cluster. The function will be executed on all cores of the cluster. Waits for the cluster to become idle before offloading.
- Parameters:
function – Function pointer to offload
trampoline – Address of the trampoline in the device binary. The trampoline loads the stack pointer, function pointer and argument from the shared data and calls the function.
args – Arguments to pass to the function
stack_ptr – Array containing the stack pointers for the cores. The length must equal the number of cores in the cluster
clusterId – ID of the cluster to offload to
-
void offload_snitchCluster_core(void *function, void *trampoline, void *args, void *stack_ptr, uint8_t clusterId, uint32_t core_id)
Offload a void function pointer to a cluster’s core. The function will be executed on the specified core of the cluster.
- Parameters:
function – Function pointer to offload
trampoline – Address of the trampoline in the device binary. The trampoline loads the stack pointer, function pointer and argument from the shared data and calls the function.
args – Arguments to pass to the function
stack_ptr – Stack pointer for the core
clusterId – ID of the cluster to offload to
core_id – ID of the core to offload to (cores are 0-indexed for each cluster)
-
void set_snitchCluster_reset(uint8_t clusterId, bool enable)
Set Soft Reset on specified cluster.
- Parameters:
clusterId – ID of the cluster to set soft reset for
enable – true to enable soft reset, false to disable
-
void setAll_snitchCluster_reset(bool enable)
Set Soft Reset on all clusters.
- Parameters:
enable – true to enable soft reset, false to disable
-
void set_snitchCluster_clockGating(uint8_t clusterId, bool enable)
Set Clock Gating on specified cluster.
- Parameters:
clusterId – ID of the cluster to set clock gating for
enable – true to enable clock gating, false to disable
-
void setAll_snitchCluster_clockGating(bool enable)
Set Clock Gating on all clusters.
- Parameters:
enable – true to enable clock gating, false to disable
-
int snitchCluster_busy(uint8_t clusterId)
Check if the cluster is busy.
- Parameters:
clusterId – ID of the cluster to check
- Returns:
int Return 1 if the cluster is busy, 0 if it is idle, -1 if the cluster ID is invalid
-
void wait_snitchCluster_busy(uint8_t clusterId)
Blocking wait for the cluster to become idle. The function busy waits until the cluster is ready.
- Todo:
Replace the delay after adding synchronization primitives for the Snitch cores.
Warning
The busy flag is set by the offloaded function itself (
_SET_CLUSTER_BUSY()), not by hardware. Hence the busy flag does not reflect the actual status of the cluster right after an offload. A fixed NOP delay after the flag clears is used as a temporary workaround.- Parameters:
clusterId – ID of the cluster to wait for.
-
uint32_t wait_snitchCluster_return(uint8_t clusterId)
Wait for the cluster to return a value. The return value is written by the last core of the cluster. The function busy waits until the cluster returns a non-zero value.
Warning
The return values must be non-zero, otherwise the function will busy wait forever!
- Parameters:
clusterId – ID of the cluster to wait for.
- Returns:
uint32_t Return value of the cluster.