29#include <common/send_mc.h>
32#define IN_BUFFER_SIZE 256
35#define COUNTER_SATURATION_VALUE 255
79static uint32_t
key = 0;
98static uint32_t
time = UINT32_MAX;
180 uint8_t *
counters, uint32_t num_items) {
181 for (uint32_t i = 0 ; i < num_items ; i++) {
211 log_debug(
"\t key = 0x%08x, incoming key = 0x%08x, incoming mask = 0x%08x,"
212 "incoming key mask = 0x%08x",
230 log_info(
"\t parrot neurons = %u, neuron bit field words = %u,"
231 " num delay stages = %u, num delay slots = %u (pot = %u),"
232 " num delay slots mask = %08x, n delay in a stage = %u",
238 spike_counters = spin1_malloc(num_delay_slots_pot *
sizeof(uint8_t*));
240 log_error(
"failed to allocate memory for array of size %u bytes",
241 num_delay_slots_pot *
sizeof(uint8_t*));
245 for (uint32_t s = 0; s < num_delay_slots_pot; s++) {
249 log_error(
"failed to allocate memory for bitfield of size %u bytes",
259 log_debug(
"read_parameters: completed successfully");
266 log_debug(
"writing other provenance data");
284 log_debug(
"finished other provenance data");
303 data_specification_get_region(
SYSTEM, ds_regions),
320 log_info(
"initialise: completed successfully");
340 for (uint32_t i = payload; i > 0; i--) {
371 uint32_t spike_id =
key_n(s);
377 int32_t colour_diff =
colour - spike_colour;
385 if (time_slot_spike_counters[neuron_id] ==
389 time_slot_spike_counters[neuron_id]++;
391 log_debug(
"Incrementing counter %u = %u\n",
393 time_slot_spike_counters[neuron_id]);
397 log_debug(
"Invalid neuron ID %u", neuron_id);
401 log_debug(
"Invalid spike key 0x%08x", s);
427 uint32_t delay_stage_time_slot =
429 uint8_t *delay_stage_spike_counters =
432 log_debug(
"%u: Checking time slot %u for delay stage %u (delay %u)",
433 local_time, delay_stage_time_slot, d, delay_stage_delay);
439 if (delay_stage_spike_counters[n] == 0) {
448 log_debug(
"Neuron %u sending %u spikes after delay"
449 "stage %u with key %x",
450 n, delay_stage_spike_counters[n], d,
455 if (delay_stage_spike_counters[n] > 1) {
457 "%d: sending packet with key 0x%08x and payload %d",
460 send_spike_mc_payload(
spike_key, delay_stage_spike_counters[n]);
464 }
else if (delay_stage_spike_counters[n] == 1) {
495 log_debug(
"%d: Clearing time slot %d",
time, clearable_slot);
506 log_debug(
"Delay extension finished at time %u, %u received spikes, "
507 "%u processed spikes, %u sent spikes, %u added spikes",
541 log_error(
"Error in initialisation - exiting!");
data_specification_metadata_t * data_specification_get_data_address(void)
bool data_specification_read_header(data_specification_metadata_t *ds_regions)
void log_error(const char *message,...)
void log_debug(const char *message,...)
void log_info(const char *message,...)
static bool initialize(void)
Read the application configuration.
static uint8_t ** spike_counters
The spike counters, as a 2D array.
static uint32_t incoming_mask
Mask for incoming_key to say which messages are for this program.
static uint32_t incoming_neuron_mask
Mask for key (that matches incoming_key/incoming_mask) to extract the neuron ID from it.
static uint32_t num_neurons
Number of neurons supported.
uint32_t n_buffer_overflows
Number of circular buffer overflows (spikes internally dropped)
uint32_t n_packets_processed
Number of spikes transferred via queue.
uint32_t n_packets_dropped_due_to_invalid_key
number of packets dropped due to invalid key
static uint32_t simulation_ticks
Simulation speed.
static uint32_t n_spikes_sent
Number of spikes sent.
static uint32_t n_packets_dropped_due_to_invalid_neuron_value
number of packets dropped due to invalid neuron id
static void spike_process(void)
Processes spikes queued by incoming_spike_callback()
uint32_t n_delays
Number of times we had to back off because the comms hardware was busy.
uint32_t n_packets_dropped_due_to_invalid_neuron_value
number of packets dropped due to invalid neuron value
static uint32_t incoming_key
Key for receiving messages.
static void background_callback(uint local_time, uint timer_count)
Background event callback.
static uint32_t colour_mask
The mask to apply to get the colour from the current timestep or key.
static uint32_t n_in_spikes
Number of input spikes.
static uint32_t n_delays
Number of times we had to back off because the comms hardware was busy.
static uint32_t colour
The colour for the current time step.
static void zero_spike_counters(uint8_t *counters, uint32_t num_items)
Sets an array of counters to zero.
static uint32_t n_processed_spikes
Number of spikes transferred via queue.
static bool clear_input_buffers_of_late_packets
Whether to clear packets each timestep.
uint32_t n_packets_received
Number of input spikes.
static uint32_t num_delay_slots
The total number of delay slots.
static void store_provenance_data(address_t provenance_region)
Writes the provenance data.
static uint32_t key
Base multicast key for sending messages.
static uint32_t num_delay_slots_mask
Mask for converting time into the current delay slot.
#define COUNTER_SATURATION_VALUE
the point where the count has saturated.
uint32_t n_packets_sent
Number of spikes sent.
static uint32_t max_keys
number of possible keys.
static uint32_t n_colour_bits
The number of colour bits (both from source and to send)
static void incoming_spike_callback(uint key, uint payload)
Handles incoming spikes (FIQ)
delay_extension_callback_priorities
values for the priority for each callback
@ TIMER
Call timer at 0 to keep it quick.
@ DMA
DMA is not actually used.
@ BACKGROUND
Background processing.
@ SDP
SDP handling is queued.
@ MC_PACKET
multicast packet reception uses FIQ
@ USER
Call user at 0 as well; will be behind timer.
static uint32_t infinite_run
True if we're running forever.
void c_main(void)
Entry point.
uint32_t n_background_queue_overloads
Background queue overloads.
#define IN_BUFFER_SIZE
the size of the circular queue for packets.
static bool has_key
bool in int form for if there is a key
static uint32_t n_backgrounds_queued
The number of background tasks queued / running.
uint32_t n_packets_lost_due_to_count_saturation
number of packets lost due to count saturation of uint8
static uint32_t n_spikes_added
Number of spikes added to delay processing.
static void user_callback(uint unused0, uint unused1)
User event callback.
static bool spike_processing
Is spike processing happening right now?
static uint32_t timer_period
Used for configuring the timer hardware.
static void timer_callback(uint timer_count, uint unused1)
Main timer callback.
static uint32_t round_to_next_pot(uint32_t v)
Rounds up to the next power of two.
static uint32_t max_backgrounds_queued
The maximum number of background tasks queued.
static uint32_t num_delay_stages
The number of delay stages.
uint32_t max_backgrounds_queued
Maximum backgrounds queued.
uint32_t n_packets_added
Number of spikes added to delay processing.
uint32_t count_input_buffer_packets_late
number of packets dropped due to out of time
static uint32_t time
Simulation time.
static uint32_t n_packets_dropped_due_to_invalid_key
number of packets dropped due to invalid key
static uint32_t n_delay_in_a_stage
The number of delays within a delay stage.
static uint32_t count_input_buffer_packets_late
number of packets late
static index_t key_n(key_t k)
Gets the neuron ID of the incoming spike.
static uint32_t saturation_count
Number of packets dropped due to count saturation.
static uint32_t neuron_bit_field_words
Size of each bitfield in ::neuron_delay_stage_config.
static uint32_t n_background_overloads
The number of times the background couldn't be added.
static bool read_parameters(struct delay_parameters *params)
Read the configuration region.
Structure of the provenance data.
Declarations for delay extensions.
@ DELAY_PARAMS
Delay parameters (see delay_parameters)
Delay configuration, as read from SDRAM where it was placed by DSG or by on-chip generation.
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 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.
static uint32_t local_time
The local time step counter.
Data type definitions for SpiNNaker Neuron-modelling.
uint32_t key_t
The type of a SpiNNaker multicast message key word.
uint32_t spike_t
The type of a spike.
static key_t spike_key(spike_t s)
helper method to retrieve the key from a spike
static int * counters
Accumulators for each motor direction.
uint sark_heap_max(heap_t *heap, uint flag)
void rt_error(uint code,...)
void simulation_handle_pause_resume(resume_callback_t callback)
void simulation_set_provenance_function(prov_callback_t provenance_function, address_t provenance_data_address)
bool simulation_is_finished(void)
void simulation_ready_to_read(void)
void simulation_run(void)
bool simulation_initialise(address_t address, uint32_t expected_application_magic_number, uint32_t *timer_period, uint32_t *simulation_ticks_pointer, uint32_t *infinite_run_pointer, uint32_t *time_pointer, int sdp_packet_callback_priority, int dma_transfer_complete_priority)
uint spin1_trigger_user_event(uint arg0, uint arg1)
uint spin1_schedule_callback(callback_t cback, uint arg0, uint arg1, uint priority)
uint spin1_int_disable(void)
void spin1_mode_restore(uint value)
void spin1_callback_on(uint event_id, callback_t cback, int priority)
static stdp_params params
Configuration parameters.