36#ifndef APPLICATION_NAME_HASH
37#error APPLICATION_NAME_HASH must be defined
41#define __use(x) do { (void) (x); } while (0)
103#define NUMBER_OF_REGIONS_TO_RECORD 1
105#define SPIKE_HISTORY_CHANNEL 0
108#define MIN_BUFFER_SPACE 10
111#define TICKS_BETWEEN_REQUESTS 25
114#define MAX_PACKET_SIZE 272
261#define BITS(value, shift, mask) \
262 (((value) >> (shift)) & (mask))
356#if LOG_LEVEL >= LOG_DEBUG
359 log_debug(
"packet of %d bytes:", length);
361 for (
int i = 0;
i < length;
i++) {
378#if LOG_LEVEL >= LOG_DEBUG
394#if LOG_LEVEL >= LOG_DEBUG
511 log_debug(
"read_pointer = 0x%.8x, write_pointer= = 0x%.8x,"
512 "last_buffer_operation == read = %d, packet length = %d",
539 log_debug(
"Copying first %d bytes to final space of %d",
615 log_debug(
"check before send packet: check_key_in_space=%d, key=0x%08x,"
616 " mask=0x%08x, key_space=%d: %d",
624 log_debug(
"mc packet 16-bit key=%d, payload=%d",
626 while (!spin1_send_mc_packet(key, payload,
WITH_PAYLOAD)) {
630 log_debug(
"mc packet 16-bit key=%d", key);
631 while (!spin1_send_mc_packet(key, 0,
NO_PAYLOAD)) {
675 log_debug(
"check before send packet: %d",
682 log_debug(
"mc packet 32-bit key=0x%08x, payload=0x%08x",
684 while (!spin1_send_mc_packet(key, payload,
WITH_PAYLOAD)) {
688 log_debug(
"mc packet 32-bit key=0x%08x", key);
689 while (!spin1_send_mc_packet(key, 0,
NO_PAYLOAD)) {
709 log_debug(
"recording a EIEIO message with length %u",
734 log_debug(
"eieio_data_process_data_packet");
745 log_debug(
"====================================");
841 log_debug(
"Stopping packet requests - parse_stop_packet_reqs");
851 log_debug(
"Starting packet requests - parse_start_packet_reqs");
868 log_debug(
"received sequenced eieio packet with invalid region ID:"
886 log_debug(
"Updating last sequence seen to %d",
889 log_debug(
"unable to buffer sequenced data packet.");
907 log_debug(
"command: HOST_SEND_SEQUENCED_DATA");
911 log_debug(
"command: STOP_SENDING_REQUESTS");
915 log_debug(
"command: START_SENDING_REQUESTS");
954 log_debug(
"in fetch_and_process_packet");
964 log_debug(
"has_eieio_packet_in_buffer set to %d",
983 log_error(
"Packet from SDRAM at 0x%08x of %u bytes is too big!",
989 log_debug(
"packet with length %d, from address: %08x",
len,
995 log_debug(
"1 - reading packet to %08x from %08x length: %d",
1002 log_debug(
"2 - reading packet to %08x from %08x length: %d",
1010 log_debug(
"1 - reading packet to %08x from %08x length: %d",
1024 log_debug(
"packet time: %d, current time: %d",
1042 log_debug(
"sending request packet with space: %d and seq_no: %d at %u",
1241 log_debug(
"timer_callback, final time: %d, current time: %d,"
1242 "next packet buffer time: %d",
1255 log_debug(
"Last time of stop notification request: %d",
1295 spin1_msg_free(msg);
Definitions for the streaming-over-EIEIO buffering protocol.
buffered_operations
The different buffer operations.
@ BUFFER_OPERATION_READ
The last operation was a read.
@ BUFFER_OPERATION_WRITE
The last operation was a write.
@ STOP_SENDING_REQUESTS
Stop complaining that there is SDRAM free space for buffers.
@ SPINNAKER_REQUEST_BUFFERS
SpiNNaker requesting new buffers for spike source population.
@ SPINNAKER_REQUEST_READ_DATA
Buffers available to be read from a buffered out vertex.
@ HOST_SEND_SEQUENCED_DATA
Buffers being sent from host to SpiNNaker.
@ HOST_DATA_READ
Host confirming data being read form SpiNNaker memory.
@ EVENT_PADDING
Fill in buffer area with padding.
@ START_SENDING_REQUESTS
Start complaining that there is SDRAM free space for buffers.
@ EVENT_STOP_COMMANDS
End of all buffers, stop execution.
uint16_t * eieio_msg_t
pointer to an EIEIO message
#define MAX_SEQUENCE_NO
The maximum sequence number.
@ TIMER
The timer callback is highest priority.
@ DMA
DMA processing is lowest priority.
@ SYSTEM
The system data region ID.
@ PROVENANCE_REGION
Where to record provenance data. (Format: cs_provenance_t)
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.
static uint32_t data[ITEMS_PER_DATA_PACKET]
static void initialise(void)
Sets up the application.
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.
eieio_prefix_types
The EIEIO prefix types.
@ PACKET_CLASS
eieio_header_bitfields::packet_class
@ COUNT
eieio_header_bitfields::count
@ PAYLOAD_IS_TIMESTAMP
eieio_header_bitfields::payload_is_timestamp
@ PACKET_COMMAND
eieio_header_bitfields::packet_command
@ 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
@ KEY_16_BIT
Message is just a key, 16 bits long.
@ KEY_32_BIT
Message is just a key, 32 bits long.
@ KEY_PAYLOAD_32_bIT
Message is a key and a payload, each 32 bits long.
@ KEY_PAYLOAD_16_BIT
Message is a key and a payload, each 16 bits long.
static uint32_t packets_sent
The number of packets sent so far this timestamp.
static uint8_t event_size
The size of an individual event.
interface for recording data into "channels" on the SDRAM in a standard way, and storing buffers to b...
bool recording_initialize(void **recording_data_address, uint32_t *recording_flags)
initialises the recording of data
void recording_finalise(void)
Finishes recording - should only be called if recording_flags is not 0.
bool recording_record(channel_index_t channel, void *data, size_t size_bytes)
records some data into a specific recording channel.
void recording_reset(void)
resets recording to the state just after initialisation
region_ids
The memory regions.
static uint32_t prefix
The prefix to apply.
static uint8_t pkt_last_sequence_seen
Most recently seen message sequence number.
uint8_t sequence
What sequence number we expect.
static uint8_t * write_pointer
Points to next byte to write in buffer_region.
static bool apply_prefix
If a prefix should be applied.
#define BITS(value, shift, mask)
Extract a field from a bitfield value.
static bool initialise_recording(void)
Initialises the recording parts of the model.
#define TICKS_BETWEEN_REQUESTS
the amount of ticks to wait between requests
static bool setup_buffer_region(uint8_t *region_address)
Initialises the buffer region.
static uint32_t tx_offset
The timer offset to use for transmissions.
uint32_t time
The timestamp of this recording event.
static uint32_t simulation_ticks
The time that the simulation is scheduled to stop at.
uint32_t space_before_data_request
The point where we ask for the host to clear up space.
static void print_packet(const eieio_msg_t eieio_msg_ptr)
Dumps a message to IOBUF if debug messages are enabled.
uint8_t data[MAX_PACKET_SIZE]
The content of the packet.
static recorded_packet_t * recorded_packet
Buffer used for recording inbound packets.
uint32_t prefix_type
The type of prefix that is supplied.
uint16_t chip_id
What chip is making the request.
uint8_t region
What region is full.
static bool is_eieio_packet_in_buffer(void)
Whether we have a packet in the buffer.
uint32_t prefix
The prefix to apply.
static uint8_t * end_of_buffer_region
Points to the end of the buffer (to first byte that must not be written)
static uint32_t buffer_region_size
Size of buffer in buffer_region.
static void fetch_and_process_packet(void)
Process a stored packet.
static bool stopped
Whether this app has been asked to stop running.
static void eieio_command_parse_sequenced_data(const eieio_msg_t eieio_msg_ptr, uint16_t length)
Handle the command to store a request for later processing.
static uint32_t space_before_data_request
Threshold at which we ask for buffers to be cleared.
static uint32_t return_tag_dest
The SDP destination for sending messages to host.
uint32_t apply_prefix
Whether to always apply a prefix.
interrupt_priorities
human readable versions of the different priorities and usages.
uint16_t eieio_header_command
The command header.
static void send_buffer_request_pkt(void)
Sends a message saying what our state is.
static eieio_msg_t msg_from_sdram
DTCM buffer holding message copied from buffer_region.
static void record_packet(const eieio_msg_t eieio_msg_ptr, uint32_t length)
Asynchronously record an EIEIO message.
uint32_t key_space
The key space used for packet selection.
static uint8_t * buffer_region
Points to the buffer used to store data being collected to transfer out.
uint32_t buffer_region_size
The size of the buffer region.
uint32_t buffered_in_sdp_port
The SDP port that we buffer messages in on.
static sdp_msg_t sdp_host_req
An SDP message ready to send to host.
static buffered_operations last_buffer_operation
What the last operation done on buffer_region was.
static void process_16_bit_packets(const uint16_t *event_pointer, bool pkt_prefix_upper, uint32_t pkt_count, uint32_t pkt_key_prefix, uint32_t pkt_payload_prefix, bool pkt_has_payload, bool pkt_payload_is_timestamp)
Handle an SDP message containing 16 bit events. The events are converted into SpiNNaker multicast pac...
uint32_t incorrect_keys
Number of bad keys.
uint32_t mask
The mask used for packet selection.
static bool eieio_data_parse_packet(const eieio_msg_t eieio_msg_ptr, uint32_t length)
Parses an EIEIO message.
static bool eieio_commmand_parse_packet(const eieio_msg_t eieio_msg_ptr, uint16_t length)
Handle a command message.
static uint32_t key_space
Pattern of keys that must be matched when check_key_in_space is true.
static bool packet_handler_selector(const eieio_msg_t eieio_msg_ptr, uint16_t length)
Handle an EIEIO message, which can either be a command or an event description message.
static req_packet_sdp_t * req_ptr
Payload part of sdp_host_req.
static void sdp_packet_callback(uint mailbox, uint port)
Handles an incoming SDP message.
static bool check_key_in_space
Whether only packets with keys in the masked key space should be sent.
#define MIN_BUFFER_SPACE
the minimum space required for a buffer to work
uint32_t length
The real length of recorded_packet_t::data.
#define MAX_PACKET_SIZE
the maximum size of a packet excluding header
uint32_t return_tag_dest
The SDP destination for sending messages to host.
static void eieio_command_parse_start_requests(const eieio_msg_t eieio_msg_ptr, uint16_t length)
Handle the command to start parsing requests.
uint8_t processor
What core is making the request.
static uint32_t last_stop_notification_request
DEBUG: time of last stop notification.
static void process_32_bit_packets(const uint16_t *event_pointer, uint32_t pkt_count, uint32_t pkt_key_prefix, uint32_t pkt_payload_prefix, bool pkt_has_payload, bool pkt_payload_is_timestamp)
Handle an SDP message containing 32 bit events. The events are converted into SpiNNaker multicast pac...
static uint32_t buffered_in_sdp_port
The SDP port that we buffer messages in on.
static uint32_t recording_flags
Keeps track of which types of recording should be done to this model.
uint32_t sent_packets
How many MC packets were sent.
static bool read_parameters(struct config *config)
Reads our configuration region.
static uint32_t infinite_run
True if the simulation will "run forever" (until user interrupt).
void c_main(void)
Entry point.
static int msg_from_sdram_length
Length of msg_from_sdram.
uint32_t return_tag_id
The SDP tag for sending messages to host.
static void timer_callback(uint unused0, uint unused1)
The fundamental operation loop for the application.
static void provenance_callback(address_t address)
Writes our provenance data into the provenance region.
uint32_t received_packets
How many EIEIO packets were received.
static bool has_key
Whether a key is present; nothing is sent if no key is present.
static uint16_t calculate_eieio_packet_command_size(const eieio_msg_t eieio_msg_ptr)
What is the size of a command message?
static uint16_t calculate_eieio_packet_size(eieio_msg_t eieio_msg_ptr)
What is the size of a message?
uint32_t space_available
How much space is available.
static uint32_t next_buffer_time
Simulation time associated with message in msg_from_sdram.
static bool add_eieio_packet_to_sdram(const eieio_msg_t eieio_msg_ptr, uint32_t length)
Places a packet into the buffer.
static uint16_t calculate_eieio_packet_event_size(const eieio_msg_t eieio_msg_ptr)
What is the size of an event message?
static uint32_t last_request_tick
Last (sim) time we forced the buffers clear from timer_callback()
static uint32_t last_space
Last value of result of get_sdram_buffer_space_available() in send_buffer_request_pkt()
#define SPIKE_HISTORY_CHANNEL
The recording channel used to track the history of what spikes were sent.
uint32_t has_key
Whether a key is provided.
static bool msg_from_sdram_in_use
Does msg_from_sdram currently contain a message being processed?
static uint8_t return_tag_id
The SDP tag for sending messages to host.
static bool send_packet_reqs
Whether request packets should be sent.
uint32_t incorrect_packets
Number of bad packets (in non-debug mode)
static uint32_t mask
Mask for keys to determine if the key matches the key_space.
static eieio_prefix_types prefix_type
How to apply the prefix.
static void eieio_command_parse_stop_requests(const eieio_msg_t eieio_msg_ptr, uint16_t length)
Handle the command to stop parsing requests.
uint32_t tx_offset
The timer offset to use for transmissions.
static uint32_t time
Current simulation time.
static uint32_t get_sdram_buffer_space_available(void)
Computes how much space is available in the buffer.
static uint8_t * read_pointer
Points to next byte to read in buffer_region.
static void signal_software_error(const eieio_msg_t eieio_msg_ptr, uint16_t length)
Flags up that bad input was received.
static void print_packet_bytes(eieio_msg_t eieio_msg_ptr, uint16_t length)
Dumps a message to IOBUF if debug messages are enabled.
static uint32_t extract_time_from_eieio_msg(const eieio_msg_t eieio_msg_ptr)
Get the time from a message.
static void resume_callback(void)
Reinitialises the application after it was paused.
static ripmcs_provenance_t provenance
The provenance information that we're collecting.
uint32_t late_packets
Number of packets dropped for being late.
uint32_t check_keys
Whether only packets with keys in the masked key space should be sent.
The configuration parameters for the application.
What information is recorded about a packet.
An EIEIO request-for-more-space message.
The provenance data items.
void io_printf(char *stream, char *format,...)
void rt_error(uint code,...)
static struct simulation_provenance * prov
the region ID for storing provenance data from the chip
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...
bool simulation_sdp_callback_on(uint sdp_port, callback_t sdp_callback)
Registers an additional SDP callback on a given SDP port. This is required when using simulation_regi...
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:
void spin1_set_timer_tick_and_phase(uint time, uint phase)
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)