Snitch Clusters
-
void (*_trampoline_function[NUM_CLUSTER_CORES])(void*) = {NULL}
Persistent trampoline function pointers for each cluster core.
Each entry holds the function to be called by the trampoline on the corresponding core.
-
void *_trampoline_args[NUM_CLUSTER_CORES] = {NULL}
Persistent argument storage for each cluster core’s trampoline function.
Each entry holds the
void*argument passed to the trampoline on the corresponding core.
-
void *_trampoline_stack[NUM_CLUSTER_CORES] = {NULL}
Persistent stack pointer storage for each cluster core’s trampoline context.
Each entry holds the stack pointer to be loaded by the trampoline on the corresponding core.
-
static void *_generate_trampoline(uint32_t hartID, void (*function)(void*), void *args, void *stack)
Generate a trampoline function for the cluster core. The trampoline function will set up the stack pointer and call the function.
- Parameters:
hartID – hart ID of the core to offload to
function – Function pointer to offload
args – Arguments to pass to the function
stack – Stack pointer for core
- Returns:
A pointer to the persistent trampoline function
-
static uint32_t _get_hart_id(uint32_t clusterId, uint32_t core_id)
Get the hart ID of a core within a cluster.
- Parameters:
clusterId – ID of the cluster
core_id – ID of the core
- Returns:
uint32_t Hart ID of the core
-
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 a given cluster using given stack sizes passed on a per-core bases. The stack pointers are generated compliant to the RISCV-ABI and are aligned to 16-Byte boundaries and 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 a given cluster using the given stack size equal for all cores. The stack pointers are generated compliant to the RISCV-ABI and are aligned to 16-Byte boundaries and 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_core(void *function, 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
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 offload_snitchCluster(void *function, 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.
- Parameters:
function – Function pointer to offload
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
-
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:
Fix the bootrom after adding synchornization primitives for the Snitch cores.
Warning
In the current Snitch bootrom implementation each cores clears the busy flag as soon as is returned. Hence the busy flag does not reflect the actual status of the cluster.
- 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 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.
-
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
-
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
-
static int snitchcluster_open(chi_device_t *dev)
-
static int snitchcluster_close(chi_device_t *dev)
-
static ssize_t snitchcluster_read(chi_device_t *dev, void *buf, uint32_t len, chi_device_callback_t cb)