29#ifdef PROFILER_ENABLED
30#include "profile_tags.h"
101#if LOG_LEVEL >= LOG_DEBUG
115 log_debug(
"Synaptic row, at address %08x, Num plastic words:%u",
117 if (synaptic_row ==
NULL) {
120#if LOG_LEVEL >= LOG_DEBUG
129 "Fixed region %u fixed synapses (%u plastic control words):\n",
132 for (uint32_t i = 0; i < n_fixed_synapses; i++) {
133 uint32_t synapse = fixed_synapses[i];
167#if LOG_LEVEL >= LOG_DEBUG
170 for (uint32_t n = 0; n <
n_neurons; n++) {
173 for (uint32_t d = 0; d < n_delay_bits; d++) {
184 for (uint32_t d = 0; d < n_delay_bits; d++) {
208 uint32_t colour_delay) {
217 uint32_t sat_flag = 0xFFFF0000;
218 uint32_t sat_value = 0xFFFF;
220 for (; fixed_synapse > 0; fixed_synapse--) {
223 uint32_t synaptic_word = *synaptic_words++;
236 uint32_t ring_buffer_index = (synaptic_word + masked_time) &
ring_buffer_mask;
240 uint32_t accumulation =
ring_buffers[ring_buffer_index] + weight;
243 uint32_t sat_test = accumulation & sat_flag;
245 accumulation = sat_value;
258 uint32_t n_synapse_types;
259 uint32_t log_n_neurons;
260 uint32_t log_n_synapse_types;
261 uint32_t log_max_delay;
262 uint32_t drop_late_packets;
263 uint32_t incoming_spike_buffer_size;
264 uint32_t ring_buffer_shifts[];
270 uint32_t *n_neurons_out, uint32_t *n_synapse_types_out,
271 weight_t **ring_buffers_out,
272 uint32_t **ring_buffer_to_input_buffer_left_shifts,
273 bool* clear_input_buffers_of_late_packets_init,
274 uint32_t *incoming_spike_buffer_size) {
276 *clear_input_buffers_of_late_packets_init =
params->drop_late_packets;
277 *incoming_spike_buffer_size =
params->incoming_spike_buffer_size;
283 uint32_t log_n_neurons =
params->log_n_neurons;
284 uint32_t log_n_synapse_types =
params->log_n_synapse_types;
285 uint32_t log_max_delay =
params->log_max_delay;
291 log_error(
"Not enough memory to allocate ring buffer");
299 *ring_buffer_to_input_buffer_left_shifts =
314 uint32_t n_ring_buffer_bits =
321 log_error(
"Could not allocate %u entries for ring buffers; Biggest space %u",
330 log_info(
"Ready to process synapses for %u neurons with %u synapse types",
337 uint32_t synapse_index = 0;
341 uint32_t neuron_index = 0;
352 uint32_t time, uint32_t spike_colour, uint32_t
colour_mask,
364 int32_t colour_diff = time_colour - spike_colour;
387 profiler_write_entry_disable_fiq(
393 profiler_write_entry_disable_fiq(
uint32_t time
The current timer tick value.
void log_error(const char *message,...)
void log_debug(const char *message,...)
void log_info(const char *message,...)
static uint32_t colour_mask
The mask to apply to get the colour from the current timestep or key.
struct synaptic_row * synaptic_row_t
The type of a synaptic row.
const char * neuron_get_synapse_type_char(uint32_t synapse_type)
Get the synapse type description character.
void io_printf(char *stream, char *format,...)
uint sark_heap_max(heap_t *heap, uint flag)
void spin1_memcpy(void *dst, void const *src, uint len)
API for synapse dynamics.
The format of the plastic data region of a synaptic row.
static stdp_params params
Configuration parameters.
uint32_t synapse_dynamics_get_plastic_pre_synaptic_events(void)
Get the counters for plastic pre synaptic events based on (if the model was compiled with SYNAPSE_BEN...
void synapse_dynamics_print_plastic_synapses(synapse_row_plastic_data_t *plastic_region_data, synapse_row_fixed_part_t *fixed_region, uint32_t *ring_buffer_to_input_buffer_left_shifts)
Print the synapse dynamics.
bool synapse_dynamics_process_plastic_synapses(synapse_row_plastic_data_t *plastic_region_address, synapse_row_fixed_part_t *fixed_region, weight_t *ring_buffers, uint32_t time, uint32_t colour_delay, bool *write_back)
Process the dynamics of the synapses.
static index_t synapse_row_get_first_ring_buffer_index(uint32_t simulation_timestep, uint32_t synapse_type_index_bits, int32_t synapse_delay_mask)
Get the index of the first ring buffer for a given timestep.
static size_t synapse_row_num_plastic_controls(const synapse_row_fixed_part_t *fixed)
Get the number of plastic controls in the row.
static synapse_row_fixed_part_t * synapse_row_fixed_region(synaptic_row_t row)
Get the address of the non-plastic (or fixed) region.
static index_t synapse_row_sparse_type(uint32_t x, uint32_t synapse_index_bits, uint32_t synapse_type_mask)
Get the type code.
static size_t synapse_row_num_fixed_synapses(const synapse_row_fixed_part_t *fixed)
Get the number of fixed synapses in the row.
static index_t synapse_row_sparse_index(uint32_t x, uint32_t synapse_index_mask)
Get the index.
static index_t synapse_row_sparse_delay(uint32_t x, uint32_t synapse_type_index_bits, uint32_t synapse_delay_mask)
Get the delay from an encoded synapse descriptor.
static synapse_row_plastic_data_t * synapse_row_plastic_region(synaptic_row_t row)
Get the address of the plastic region.
static size_t synapse_row_plastic_size(const synaptic_row_t row)
Get the size of the plastic region.
static uint32_t * synapse_row_fixed_weight_controls(synapse_row_fixed_part_t *fixed)
The array of fixed weights in the row.
static index_t synapse_row_get_ring_buffer_index(uint32_t simulation_timestep, uint32_t synapse_type_index, uint32_t neuron_index, uint32_t synapse_type_index_bits, uint32_t synapse_index_bits, uint32_t synapse_delay_mask)
Get the index of the ring buffer for a given timestep, synapse type and neuron index.
static weight_t synapse_row_sparse_weight(uint32_t x)
Get the weight from an encoded synapse descriptor.
The type of the fixed part of the row. The fixed-plastic part follows.
uint32_t max_late_spike
The maximum lateness of a spike.
void synapses_flush_ring_buffers(timer_t time)
Reset the ring buffers to 0 at the given time.
static const char * get_type_char(uint32_t synapse_type)
get the synapse type character
static bool process_fixed_synapses(synapse_row_fixed_part_t *fixed_region, uint32_t time, uint32_t colour_delay)
The "inner loop" of the neural simulation.
uint32_t synapse_delay_mask
Mask to pick out the delay.
uint32_t synapse_type_index_bits
Number of bits needed for the synapse type and index.
static uint32_t n_neurons_peak
Number of neurons.
static void print_synaptic_row(synaptic_row_t synaptic_row)
Print a synaptic row.
static uint32_t n_neurons
The number of neurons.
uint32_t synapse_index_bits
Number of bits in the synapse index.
uint32_t synapse_index_mask
Mask to pick out the synapse index.
uint32_t synapses_saturation_count
Count of the number of times the ring buffers have saturated.
void synapses_resume(timer_t time)
Resume processing of synapses after a pause.
static uint32_t ring_buffer_size
Ring buffer size.
static weight_t * ring_buffers
Ring buffers to handle delays between synapses and neurons.
uint32_t synapses_get_pre_synaptic_events(void)
returns the counters for plastic and fixed pre synaptic events based on (if the model was compiled wi...
uint32_t synapse_delay_bits
Number of bits in the delay.
bool synapses_initialise(address_t synapse_params_address, uint32_t *n_neurons_out, uint32_t *n_synapse_types_out, weight_t **ring_buffers_out, uint32_t **ring_buffer_to_input_buffer_left_shifts, bool *clear_input_buffers_of_late_packets_init, uint32_t *incoming_spike_buffer_size)
Initialise the synapse processing.
static void print_ring_buffers(uint32_t time)
Print the contents of the ring buffers.
uint32_t synapse_type_index_mask
Mask to pick out the synapse type and index.
static uint32_t synapse_delay_mask_shifted
The mask of the delay shifted into position i.e. pre-shift.
uint32_t late_spikes
Count of the spikes that are received late.
static uint32_t ring_buffer_mask
Ring buffer mask.
uint32_t num_fixed_pre_synaptic_events
if using profiler import profiler tags
bool synapses_process_synaptic_row(uint32_t time, uint32_t spike_colour, uint32_t colour_mask, synaptic_row_t row, bool *write_back)
process a synaptic row
static uint32_t * ring_buffer_to_input_left_shifts
Amount to left shift the ring buffer by to make it an input.
static uint32_t n_synapse_types
The number of synapse types.
uint32_t synapse_type_bits
Number of bits in the synapse type.
uint32_t skipped_synapses
uint32_t synapse_type_mask
Mask to pick out the synapse type.
The layout of the synapse parameters region.
static void synapses_print_weight(weight_t weight, uint32_t left_shift)
Print the weight of a synapse.