45 const uint32_t last_pre_time,
const pre_trace_t last_pre_trace,
46 const pre_trace_t new_pre_trace,
const uint32_t delay_dendritic,
50 const uint32_t delayed_last_pre_time = last_pre_time + delay_axonal;
53 const uint32_t window_begin_time =
54 (delayed_last_pre_time >= delay_dendritic)
55 ? (delayed_last_pre_time - delay_dendritic) : 0;
56 const uint32_t delayed_pre_time =
time + delay_axonal;
57 const uint32_t window_end_time =
58 (delayed_pre_time >= delay_dendritic)
59 ? (delayed_pre_time - delay_dendritic) : 0;
63 log_debug(
"\tPerforming deferred synapse update at time:%u",
time);
64 log_debug(
"\t\tbegin_time:%u, end_time:%u - prev_time:%u (valid %u), num_events:%u",
65 window_begin_time, window_end_time, post_window.
prev_time,
68#if LOG_LEVEL >= LOG_DEBUG
71 window_end_time, delay_dendritic);
76 const uint32_t delayed_post_time = *post_window.
next_time + delay_dendritic;
78 log_debug(
"\t\tApplying post-synaptic event at delayed time:%u, pre:%u\n",
79 delayed_post_time, delayed_last_pre_time);
83 delayed_post_time, *post_window.
next_trace, delayed_last_pre_time,
93 const uint32_t delayed_last_post = post_window.
prev_time + delay_dendritic;
94 log_debug(
"\t\tApplying pre-synaptic event at time:%u last post time:%u\n",
95 delayed_pre_time, delayed_last_post);
97 delayed_pre_time, new_pre_trace, delayed_last_pre_time, last_pre_trace,
98 delayed_last_post, post_window.
prev_trace, current_state);
107 uint32_t *ring_buffer_to_input_buffer_left_shifts) {
110 ring_buffer_to_input_buffer_left_shifts)) {
128 uint32_t *ring_buffer_to_input_buffer_left_shifts) {
129 __use(plastic_region_data);
131 __use(ring_buffer_to_input_buffer_left_shifts);
133#if LOG_LEVEL >= LOG_DEBUG
140 log_debug(
"Plastic region %u synapses\n", plastic_synapse);
143 for (uint32_t i = 0; i < plastic_synapse; i++) {
145 uint32_t control_word = *control_words++;
151 *plastic_words++, synapse_type);
156 log_debug(
"%08x [%3d: (w: %5u (=", control_word, i, weight);
158 weight, ring_buffer_to_input_buffer_left_shifts[synapse_type]);
159 log_debug(
"nA) d: %2u, n = %3u)] - {%08x %08x}\n",
177 return (x >> synapse_delay_index_type_bits) & SYNAPSE_AXONAL_DELAY_MASK;
183 uint32_t time,
index_t neuron_index) {
184 log_debug(
"Adding post-synaptic event to trace at time:%u",
time);
197 uint32_t control_word, uint32_t last_pre_time,
pre_trace_t last_pre_trace,
208 uint32_t post_delay = s.delay_dendritic;
213 time - colour_delay, last_pre_time, last_pre_trace, new_pre_trace,
214 post_delay, s.delay_axonal, current_state,
218 if (s.delay_axonal + s.delay_dendritic > colour_delay) {
220 synapse_dynamics_stdp_update_ring_buffers(
ring_buffers, s, weight);
231 weight_t *
ring_buffers, uint32_t time, uint32_t colour_delay,
246 log_debug(
"Adding pre-synaptic event to trace at time:%u",
time);
252 for (; n_plastic_synapses > 0; n_plastic_synapses--) {
254 uint32_t control_word = *control_words++;
256 plastic_words[0] = process_plastic_synapse(
257 control_word, last_pre_time, last_pre_trace,
259 colour_delay, plastic_words[0]);
267 uint32_t
id,
synaptic_row_t row, weight_t *weight, uint16_t *delay,
268 uint32_t *offset, uint32_t *synapse_type) {
277 for (
size_t plastic_synapse = n_plastic_synapses; plastic_synapse > 0;
283 uint32_t control_word = *control_words++;
285 *offset = n_plastic_synapses - plastic_synapse;
307 plastic_words[offset] = plastic_words[plastic_synapse - 1];
310 control_words[offset] = control_words[plastic_synapse - 1];
311 control_words[plastic_synapse - 1] = 0;
319 weight_t weight, uint32_t delay, uint32_t type) {
330 plastic_words[plastic_synapse] = new_weight;
333 control_words[plastic_synapse] = new_control;
static weight_t * ring_buffers
The ring buffers to be used in the simulation.
uint32_t time
The current timer tick value.
void log_debug(const char *message,...)
uint32_t synapse_delay_mask
The mask to get the synaptic delay from a "synapse".
uint32_t synapse_type_index_bits
The number of bits used by the synapse type and post-neuron index.
uint32_t synapse_index_bits
The number of bits used by just the post-neuron index.
struct synaptic_row * synaptic_row_t
The type of a synaptic row.
static uint32_t n_neurons
The number of neurons on the core.
static uint32_t n_synapse_types
The number of synapse types.
static post_event_history_t * post_events_init_buffers(uint32_t n_neurons)
Initialise an array of post-synaptic event histories.
static void print_event_history(const post_event_history_t *events)
Print a post-synaptic event history.
static post_event_window_t post_events_next(post_event_window_t window)
Advance a post-synaptic event window to the next event.
static void post_events_add(uint32_t time, post_event_history_t *events, post_trace_t trace)
Add a post-synaptic event to the history.
static post_event_window_t post_events_get_window_delayed(const post_event_history_t *events, uint32_t begin_time, uint32_t end_time)
Get the post-synaptic event window.
static void print_delayed_window_events(const post_event_history_t *post_event_history, uint32_t begin_time, uint32_t end_time, uint32_t delay_dendritic)
Print the post-synaptic event history.
uint32_t num_events
The number of events.
post_trace_t prev_trace
The previous post-synaptic event trace.
const uint32_t * next_time
The next post-synaptic event time.
uint32_t prev_time
The previous post-synaptic event time.
const post_trace_t * next_trace
The next post-synaptic event trace.
uint32_t prev_time_valid
Whether the previous post-synaptic event is valid (based on time)
Post event window description.
uint32_t count_minus_one
Number of events stored (minus one)
uint32_t times[MAX_POST_SYNAPTIC_EVENTS]
Event times.
post_trace_t traces[MAX_POST_SYNAPTIC_EVENTS]
Event traces.
Trace history of post-synaptic events.
plastic_synapse_t synapses[]
The per-synapse information.
pre_event_history_t history
The pre-event history.
The format of the plastic data region of a synaptic row.
STDP core implementation.
uint32_t backprop_delay
The back-propagation delay, in basic simulation timesteps.
static control_t control_conversion(uint32_t id, uint32_t delay, uint32_t type)
packing all of the information into the required plastic control word
static stdp_params params
Configuration parameters.
pre_trace_t prev_trace
The event trace.
static post_event_history_t * post_event_history
The history data of post-events.
static uint32_t num_plastic_pre_synaptic_events
Count of pre-synaptic events relevant to plastic processing.
uint32_t prev_time
The event time.
The type of history data of pre-events.
bool synapse_dynamics_initialise(address_t address, uint32_t n_neurons, uint32_t n_synapse_types, uint32_t *ring_buffer_to_input_buffer_left_shifts)
Initialise the synapse dynamics.
void synapse_dynamics_process_post_synaptic_event(uint32_t time, index_t neuron_index)
Inform the synapses that the neuron fired.
bool synapse_dynamics_find_neuron(uint32_t id, synaptic_row_t row, weight_t *weight, uint16_t *delay, uint32_t *offset, uint32_t *synapse_type)
Search the synaptic row for the the connection with the specified post-synaptic ID.
static final_state_t plasticity_update_synapse(const uint32_t time, const uint32_t last_pre_time, const pre_trace_t last_pre_trace, const pre_trace_t new_pre_trace, const uint32_t delay_dendritic, const uint32_t delay_axonal, update_state_t current_state, const post_event_history_t *post_event_history)
Synapse update loop core.
static index_t sparse_axonal_delay(uint32_t x)
Get the axonal delay.
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_add_neuron(uint32_t id, synaptic_row_t row, weight_t weight, uint32_t delay, uint32_t type)
Add an entry in the synaptic row.
bool synapse_dynamics_remove_neuron(uint32_t offset, synaptic_row_t row)
Remove the entry at the specified offset in the synaptic row.
uint32_t skipped_synapses
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 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 control_t * synapse_row_plastic_controls(synapse_row_fixed_part_t *fixed)
Get the array of plastic controls in the row.
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 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.
size_t num_plastic
The number of plastic controls in data
uint16_t control_t
Define the type of the control data.
The type of the fixed part of the row. The fixed-plastic part follows.
static plastic_synapse_t synapse_structure_get_final_synaptic_word(final_state_t final_state)
Get the final plastic synapse data from the final state.
static plastic_synapse_t synapse_structure_create_synapse(weight_t weight)
Create the initial plastic synapse data.
static update_state_t synapse_structure_get_update_state(plastic_synapse_t synaptic_word, index_t synapse_type)
Get the update state from the synapse structure.
static weight_t synapse_structure_get_final_weight(final_state_t final_state)
Get the final weight from the final state.
static final_state_t synapse_structure_get_final_state(update_state_t state)
Get the final state from the update state.
static weight_t synapse_structure_get_weight(plastic_synapse_t synaptic_word)
Get the current synaptic weight from the plastic synapse data.
Plastic synapse contains normal 16-bit weight and an accumulator.
uint32_t synapse_index_mask
Mask to pick out the synapse index.
uint32_t synapse_type_mask
Mask to pick out the synapse type.
static void synapses_print_weight(weight_t weight, uint32_t left_shift)
Print the weight of a synapse.
static post_trace_t timing_add_post_spike(uint32_t time, uint32_t last_time, post_trace_t last_trace)
Add a post spike to the post trace.
static update_state_t timing_apply_pre_spike(uint32_t time, pre_trace_t trace, uint32_t last_pre_time, pre_trace_t last_pre_trace, uint32_t last_post_time, post_trace_t last_post_trace, update_state_t previous_state)
Apply a pre-spike timing rule state update.
static pre_trace_t timing_add_pre_spike(uint32_t time, uint32_t last_time, pre_trace_t last_trace)
Add a pre spike to the pre trace.
static update_state_t timing_apply_post_spike(uint32_t time, post_trace_t trace, uint32_t last_pre_time, pre_trace_t last_pre_trace, uint32_t last_post_time, post_trace_t last_post_trace, update_state_t previous_state)
Apply a post-spike timing rule state update.
The type of post-spike traces.
The type of pre-spike traces.