53#define N_DMA_BUFFERS 2
114 uint32_t packets_this_time_step;
133 next_buffer->
colour = result->colour;
141 result->n_bytes_to_transfer)) {
155 uint32_t *n_process_spike) {
173 *n_process_spike += 1;
191 *n_process_spike += 1;
221 uint32_t *n_rewires, uint32_t *n_synapse_processes) {
229 bool setup_done =
false;
232 if (current_buffer !=
NULL &&
242 current_buffer->
colour = result.colour;
261 uint32_t dma_buffer_index,
bool plastic_only) {
267 size_t write_size =
buffer->n_bytes_transferred;
268 void *sdram_start_address =
buffer->sdram_writeback_address;
269 void *dtcm_start_address =
buffer->row;
273 buffer->sdram_writeback_address);
279 dtcm_start_address,
DMA_WRITE, write_size)) {
316 for (
uint count = payload; count > 0; count--) {
347 bool write_back =
false;
348 bool plastic_only =
true;
351 for (uint32_t i = n_rewires; i > 0; i--) {
354 plastic_only =
false;
364 bool write_back_now =
false;
367 current_buffer->
row, &write_back_now)) {
369 "Error processing spike 0x%.8x for address 0x%.8x"
373 current_buffer->
row);
384 write_back |= write_back_now;
431 size_t row_max_n_words,
uint mc_packet_callback_priority,
432 uint user_event_priority,
uint incoming_spike_buffer_size,
433 bool clear_input_buffers_of_late_packets_init,
434 uint32_t packets_per_timestep_region) {
437 dma_buffers[i].
row = spin1_malloc(row_max_n_words *
sizeof(uint32_t));
439 log_error(
"Could not initialise DMA buffers with %u words", row_max_n_words);
445 clear_input_buffers_of_late_packets_init;
void log_error(const char *message,...)
static uint32_t key
Base multicast key for sending messages.
Functions for immediate handling of incoming spikes.
static bool in_spikes_get_next_spike(spike_t *spike)
Retrieves a spike from the input spike buffer.
static circular_buffer buffer
Buffer for quickly taking spikes received by a fast interrupt and queueing them for later processing ...
static bool in_spikes_initialize_spike_buffer(uint32_t size)
This function initialises the input spike buffer.
static void in_spikes_clear(void)
clears the input spike buffer.
static uint32_t in_spikes_size(void)
get the size of the input spike buffer
static counter_t in_spikes_get_n_buffer_overflows(void)
Get the number of times that the input spike buffer overflowed.
static bool in_spikes_add_spike(spike_t spike)
Adds a spike to the input spike buffer.
uint32_t n_spikes[2]
Spike buffer counters.
struct synaptic_row * synaptic_row_t
The type of a synaptic row.
uint32_t spike_t
The type of a spike.
Master pop(ulation) table API.
bool population_table_get_next_address(spike_t *spike, pop_table_lookup_result_t *result)
Get the next row data for a previously given spike. If no spike has been given, return False.
bool population_table_get_first_address(spike_t spike, pop_table_lookup_result_t *result)
Get the first row data for the given input spike.
A structure to hold a response to a population table lookup.
bool recording_record(channel_index_t channel, void *data, size_t size_bytes)
void rt_error(uint code,...)
bool simulation_dma_transfer_done_callback_on(uint tag, callback_t callback)
#define N_DMA_BUFFERS
The number of DMA Buffers to use.
static void start_dma_loop(void)
Start the DMA processing loop if not already running.
void user_event_callback(uint unused0, uint unused1)
Called when a user event is received.
static uint32_t spike_processing_count
the number of spikes that were processed (used in provenance generation)
bool spike_processing_initialise(size_t row_max_n_words, uint mc_packet_callback_priority, uint user_event_priority, uint incoming_spike_buffer_size, bool clear_input_buffers_of_late_packets_init, uint32_t packets_per_timestep_region)
Initialise the spike processing system.
static bool setup_synaptic_dma_read(dma_buffer *current_buffer, uint32_t *n_rewires, uint32_t *n_synapse_processes)
Set up a new synaptic DMA read.
static uint32_t dma_n_spikes
The number of spikes to do when the DMA completes.
static void dma_complete_callback(uint unused, uint tag)
Called when a DMA completes.
bool spike_processing_do_rewiring(int number_of_rewires)
Set the number of times spike_processing has to attempt rewiring.
static uint32_t n_successful_rewires
The number of successful rewires.
static uint32_t next_buffer_to_fill
The index of the next buffer to be filled by a DMA.
static uint32_t biggest_fill_size_of_input_buffer
tracker of how full the input buffer got.
static uint32_t buffer_being_read
The index of the buffer currently being filled by a DMA read.
static volatile uint32_t rewires_to_do
Number of outstanding synaptogenic rewires.
static void multicast_packet_received_callback(uint key, uint unused)
Called when a multicast packet is received.
static bool clear_input_buffers_of_late_packets
Whether if we should clear packets from the input buffer at the end of a timer tick.
static dma_buffer dma_buffers[N_DMA_BUFFERS]
The DTCM buffers for the synapse rows.
static volatile bool dma_busy
True if the DMA "loop" is currently running.
static void do_dma_read(spike_t spike, pop_table_lookup_result_t *result)
Perform a DMA read of a synaptic row.
static void multicast_packet_pl_received_callback(uint key, uint payload)
Called when a multicast packet is received.
static uint32_t p_per_ts_region
the region to record the packets per timestep in
void spike_processing_clear_input_buffer(timer_t time)
clears the input buffer of packets
static bool is_something_to_do(spike_t *spike, pop_table_lookup_result_t *result, uint32_t *n_rewire, uint32_t *n_process_spike)
Check if there is anything to do. If not, DMA is not busy.
void spike_processing_store_provenance(struct spike_processing_provenance *prov)
Get provenance data for Spike processing.
spike_processing_dma_tags
DMA tags.
@ DMA_TAG_READ_SYNAPTIC_ROW
Tag of a DMA read of a full synaptic row.
@ DMA_TAG_WRITE_PLASTIC_REGION
Tag of a DMA write of the plastic region of a synaptic row.
static void setup_synaptic_dma_write(uint32_t dma_buffer_index, bool plastic_only)
Set up a DMA write of synaptic data.
static uint32_t dma_complete_count
the number of DMA completes (used in provenance generation)
uint32_t time
The current timer tick value.
static struct @13 p_per_ts_struct
the number of packets received this time step
static uint32_t count_input_buffer_packets_late
How many packets were lost from the input buffer because of late arrival.
static uint32_t dma_n_rewires
The number of rewires to do when the DMA completes.
uint32_t n_spikes_processed
The number of spikes received and processed.
uint32_t n_input_buffer_overflows
A count of the times that the synaptic input circular buffers overflowed.
uint32_t n_rewires
The number of rewires performed.
uint32_t max_filled_input_buffer_size
The maximum size of the input buffer.
uint32_t n_packets_dropped_from_lateness
The number of packets that were cleared at the end of timesteps.
uint32_t n_dmas_complete
The number of DMAs performed.
Provenance for spike processing.
uint spin1_trigger_user_event(uint arg0, uint arg1)
uint spin1_dma_transfer(uint tag, void *system_address, void *tcm_address, uint direction, uint length)
void spin1_dma_flush(void)
uint spin1_int_disable(void)
void spin1_mode_restore(uint value)
void spin1_callback_on(uint event_id, callback_t cback, int priority)
spike_t originating_spike
Key of originating spike.
synaptic_row_t row
Row data.
uint32_t n_bytes_transferred
Number of bytes transferred in the read.
synaptic_row_t sdram_writeback_address
Address in SDRAM to write back plastic region to.
uint32_t colour
Spike colour.
uint32_t colour_mask
Spike colour mask.
implementation for handling the processing of synapse rows.
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.
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
This file contains the main interface for structural plasticity.
bool synaptogenesis_dynamics_rewire(uint32_t time, spike_t *spike, pop_table_lookup_result_t *result)
Trigger the process of synaptic rewiring.
void synaptogenesis_spike_received(uint32_t time, spike_t spike)
Indicates that a spike has been received.
bool synaptogenesis_row_restructure(uint32_t time, synaptic_row_t row)
Perform the actual restructuring of a row.