105 CONFIGURATION_REGION,
171#define FLAG_IS_SET(flags, bit) (((flags) & (bit)) != 0)
174#define CLAMP8(value) ((value) & 0xFF)
177#define CLAMP16(value) ((value) & 0xFFFF)
180#define HAVE_PAYLOAD(pkt_type) FLAG_IS_SET(pkt_type, 0x1)
183#define HAVE_WIDE_LOAD(pkt_type) FLAG_IS_SET(pkt_type, 0x2)
186#define BUFFER_CAPACITY 256
190 if (!
config->n_translation_entries) {
195 uint32_t imax =
config->n_translation_entries;
197 while (imin < imax) {
198 uint32_t imid = (imax + imin) >> 1;
200 if ((key & entry.mask) == entry.key) {
203 }
else if (entry.key < key) {
215static inline uint32_t translated_key(uint32_t key) {
220 return key &
config->received_key_mask;
226 uint32_t shifted_key = key & ~entry.
mask;
227 if (
config->translated_key_right_shift) {
228 shifted_key = shifted_key >>
config->translated_key_right_shift;
230 return shifted_key + entry.lo_atom;
239static inline void write_word(
void *base, uint32_t index, uint32_t value) {
240 uint16_t *ary = base;
241 uint32_t idx = index * 2;
243 ary[idx] =
CLAMP16(value >> 16);
250static inline void write_short(
void *base, uint32_t index, uint32_t value) {
251 uint16_t *ary = base;
271 (
config->packets_per_timestamp == 0) ||
356 key >>
config->key_right_shift);
382 log_debug(
"Processing key %x, payload %x", key, payload);
388 key >>
config->key_right_shift);
393 payload >>
config->payload_right_shift);
432 key = translated_key(key);
436 key = translated_key(key);
476 log_debug(
"Received key %x, payload %x", key, payload);
499 log_error(
"Could not allocate space for config!");
511 log_info(
"payload_apply_prefix: %d",
config->payload_apply_prefix);
516 log_info(
"packets_per_timestamp: %d",
config->packets_per_timestamp);
517 log_info(
"n_translation_entries: %d",
config->n_translation_entries);
520 log_info(
"key = 0x%08x, mask = 0x%08x, lo_atom = 0x%08x",
567 switch (
config->packet_type) {
598 if (
config->payload_timestamp &&
config->payload_apply_prefix
600 log_error(
"Timestamp can either be included as payload prefix or as"
601 "payload to each key, not both");
604 if (
config->payload_timestamp && !
config->payload_apply_prefix
606 log_error(
"Timestamp can either be included as payload prefix or as"
607 "payload to each key, but current configuration does not"
608 "specify either of these");
632 if (
config->payload_apply_prefix) {
639 if (!
config->payload_timestamp) {
646 if (!
config->payload_timestamp) {
673 log_error(
"Error in initialisation - exiting!");
687 spin1_set_timer_tick(timer_period);
static bool initialize(void)
Initialises the program.
circular_buffer circular_buffer_initialize(uint32_t size)
@ PROVENANCE_REGION
Where to record provenance data. (Format: cs_provenance_t)
@ SYSTEM_REGION
Where simulation system information is stored.
Data type definitions for SpiNNaker Neuron-modelling.
uint32_t * address_t
A generic pointer to a word.
Data Specification region access API.
data_specification_metadata_t * data_specification_get_data_address(void)
Gets the location of the data for this core using the user0 entry of the SARK VCPU structure.
bool data_specification_read_header(data_specification_metadata_t *ds_regions)
Reads the header from the address given and checks if the parameters are of the correct values.
static void * data_specification_get_region(uint32_t region, data_specification_metadata_t *ds_regions)
Gets the address of a region.
SpiNNaker debug header file.
void log_error(const char *message,...)
This function logs errors. Errors usually indicate a serious fault in the program,...
void log_debug(const char *message,...)
This function logs debugging messages. This level of message is normally not printed except when the ...
void log_info(const char *message,...)
This function logs informational messages. This is the lowest level of message normally printed.
EIEIO message header description.
@ PAYLOAD_IS_TIMESTAMP
eieio_header_bitfields::payload_is_timestamp
@ PACKET_TYPE
eieio_header_bitfields::packet_type
@ APPLY_PAYLOAD_PREFIX
eieio_header_bitfields::apply_payload_prefix
@ APPLY_PREFIX
eieio_header_bitfields::apply_prefix
@ PREFIX_UPPER
eieio_header_bitfields::prefix_upper
static sdp_msg_t g_event_message
The SDP message that we will send.
uint32_t sdp_dest
SDP destination to use when sending.
key_translation_entry translation_table[]
Translation table.
static uint32_t buffer_index
Index into our buffer in sdp_msg_aer_data.
uint32_t n_translation_entries
The number of entries in the translation table.
uint32_t payload_prefix
Payload prefix data (for the receiver)
uint32_t received_key_mask
Mask to apply to non-translated keys.
static uint32_t simulation_ticks
When we will run until.
#define HAVE_WIDE_LOAD(pkt_type)
Does the packet type include a double-width payload?
static uint16_t * sdp_msg_aer_data
Pointer to outbound message data. Might only be half-word aligned!
static uint8_t sdp_msg_aer_header_len
The length of the header, in bytes.
uint32_t payload_apply_prefix
D bit.
#define HAVE_PAYLOAD(pkt_type)
Does the packet type include a payload?
#define CLAMP16(value)
How to use just the low 16 bits of an integer value.
static lpg_provenance_data_t provenance_data
The provenance information that we are collecting.
#define BUFFER_CAPACITY
The size of the circular buffers.
uint32_t key_right_shift
Right payload shift (for the sender)
static bool configure_sdp_msg(void)
Sets up the AER EIEIO data message.
static circular_buffer without_payload_buffer
Circular buffer of incoming multicast packets that lack payloads.
static uint8_t get_event_count(void)
Get how many events there are waiting to be sent.
uint32_t translated_key_right_shift
Shift to apply to received and translated keys.
static void record_provenance_data(address_t provenance_region_address)
Store provenance data elements into SDRAM.
static uint16_t * sdp_msg_aer_payload_prefix
The location of the payload prefix in the message. NULL if no prefix.
static bool processing_events
Whether we are processing events (or discarding them).
packet_types
EIEIO packet types.
static uint16_t * sdp_msg_aer_header
The location of the EIEIO header in the message.
static bool read_parameters(struct lpg_config *sdram_config)
Copies the application configuration from DSG SDRAM to DTCM.
static void flush_events(void)
Send buffered events to host via SDP AER message and clear internal buffers.
static void process_incoming_event(uint key)
Processes an incoming multicast packet without payload.
static uint32_t infinite_run
TRUE if we're running without bound. FALSE if we're only running for a limited period of time.
void c_main(void)
Entry point.
static void timer_callback(uint unused0, uint unused1)
Periodic timer callback.
uint32_t payload_timestamp
T bit.
uint32_t sdp_tag
SDP tag to use when sending.
@ TIMER
Timer interrupt is lowest priority.
@ DMA
DMA complete interrupt is low priority.
@ SDP
SDP interrupt is highest priority.
@ MC_PACKET
Multicast packet interrupt uses FIQ (super high prio)
@ USER
Interrupt for enqueued list of received packets.
static void process_incoming_event_payload(uint key, uint payload)
Processes an incoming multicast packet with payload.
uint32_t payload_right_shift
Right payload shift (for the sender)
static circular_buffer with_payload_buffer
Circular buffer of incoming multicast packets that have payloads.
uint32_t number_of_overflows_no_payload
Count of overflows when no payload was sent.
static void write_short(void *base, uint32_t index, uint32_t value)
Simple mirror of write_word() for true 16 bit values.
static bool find_translation_entry(uint32_t key, uint32_t *index)
find a key translation entry
uint32_t number_of_sent_messages
Number of messages sent to host.
static struct lpg_config * config
The configuration data of the application.
static uint32_t packets_sent
The number of packets sent so far this timestamp.
static void incoming_event_payload_callback(uint key, uint payload)
FIQ handler for incoming packets with payload.
static void flush_events_if_full(void)
Flush events to the outside world if our internal buffers are now full.
uint32_t packet_type
F bit (for the receiver)
uint32_t prefix
Prefix data.
uint32_t number_of_gathered_events
Number of events gathered and recorded.
uint32_t packets_per_timestamp
Maximum number of packets to send per timestep, or 0 for "send them all".
static uint16_t eieio_constant_header
Part of the generic EIEIO header that is constant.
static void write_word(void *base, uint32_t index, uint32_t value)
Because WHY OH WHY would you use aligned memory? At least with this we don't get data aborts.
static uint32_t time
Current simulation time.
uint32_t number_of_overflows_with_payload
Count of overflows when a payload was sent.
static void incoming_event_process_callback(uint unused0, uint unused1)
Handler for processing incoming packets that have been locally queued.
static uint8_t event_size
The size of an individual event.
uint32_t apply_prefix
P bit.
uint32_t prefix_type
Type bits.
static void incoming_event_callback(uint key, uint unused)
FIQ handler for incoming packets without payload.
#define CLAMP8(value)
How to use just the low 8 bits of an integer value.
Definitions of each element in the configuration.
uint32_t prefix_type
The type of prefix that is supplied.
uint32_t prefix
The prefix to apply.
uint32_t apply_prefix
Whether to always apply a prefix.
uint32_t mask
The mask used for packet selection.
The configuration parameters for the application.
void rt_error(uint code,...)
Simulation Functions Header File.
void simulation_handle_pause_resume(resume_callback_t callback)
cleans up the house keeping, falls into a sync state and handles the resetting up of states as requir...
void simulation_set_provenance_function(prov_callback_t provenance_function, address_t provenance_data_address)
Set an additional callback function to store extra provenance data.
bool simulation_is_finished(void)
determine if the simulation is finished. Will also pause the simulation for resynchronisation if requ...
void simulation_ready_to_read(void)
Indicates that all data has been written and the core is going idle, so any data can now be read.
void simulation_run(void)
Starts the simulation running, returning when it is complete,.
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)
initialises the simulation interface which involves:
uint spin1_trigger_user_event(uint arg0, uint arg1)
void spin1_memcpy(void *dst, void const *src, uint len)
uint spin1_get_chip_id(void)
uint spin1_get_core_id(void)
void spin1_callback_on(uint event_id, callback_t cback, int priority)