19#ifndef _NEURON_IMPL_EXTERNAL_DEVICES_H_
20#define _NEURON_IMPL_EXTERNAL_DEVICES_H_
104static inline uint _int_bits(
int value) {
105 typedef union _int_bits_union {
110 _int_bits_union converter;
111 converter.int_value = value;
112 return converter.uint_value;
119static inline uint _get_payload(
enum send_type type, accum value) {
122 return _int_bits((
int) value);
126 return _int_bits(bitsk(value));
128 return bitsuk((
unsigned accum) value);
130 return _int_bits(bitslr((
long fract) value));
132 return bitsulr((
long unsigned fract) value);
134 log_error(
"Unknown enum value %u", value);
150 log_error(
"Unable to allocate neuron array - Out of DTCM");
158 log_error(
"Unable to allocate packet firing array - Out of DTCM");
166 log_error(
"Unable to allocate synapse parameters array"
181 input_t weights_this_timestep) {
185 parameters, weights_this_timestep);
192 return (size + (
sizeof(uint32_t) - 1)) /
sizeof(uint32_t);
196static void neuron_impl_load_neuron_parameters(
205 log_error(
"bad number of steps per timestep: 0");
209 for (uint32_t i = 0; i <
n_neurons; i++) {
219 for (uint32_t i = 0; i <
n_neurons; i++) {
226 if (save_initial_state) {
227 spin1_memcpy(save_initial_state, address, next *
sizeof(uint32_t));
230#if LOG_LEVEL >= LOG_DEBUG
258 UNUSED uint32_t timer_count, UNUSED uint32_t time, uint32_t
n_neurons) {
260 for (uint32_t neuron_index = 0; neuron_index <
n_neurons; neuron_index++) {
271 bool will_fire =
false;
292 total_exc += exc_input_values[i];
295 total_inh += inh_input_values[i];
315 0, current_offset, this_neuron);
318 will_fire = _test_will_fire(the_packet_firing);
323 accum value_to_send = result;
324 if (result > the_packet_firing->
max_value) {
325 value_to_send = the_packet_firing->
max_value;
327 if (result < the_packet_firing->min_value) {
328 value_to_send = the_packet_firing->
min_value;
331 uint payload = _get_payload(
332 the_packet_firing->
type,
335 send_spike_mc_payload(the_packet_firing->
key, payload);
337 send_spike_mc(the_packet_firing->
key);
350 #if LOG_LEVEL >= LOG_DEBUG
367 for (uint32_t i = 0; i <
n_neurons; i++) {
368 neuron_model_save_state(&
neuron_array[i], &neuron_params[i]);
377 for (uint32_t i = 0; i <
n_neurons; i++) {
383#if LOG_LEVEL >= LOG_DEBUG
393 empty = empty && (0 == bitsk(
405 if (bitsk(input) != 0) {
uint32_t time
The current timer tick value.
General API of a current source implementation.
static REAL current_source_get_offset(uint32_t time, uint32_t neuron_index)
Calculate the current offset from all injected current sources.
Implement all current sources.
void log_error(const char *message,...)
void log_debug(const char *message,...)
void log_info(const char *message,...)
accum REAL
Type used for "real" numbers.
REAL state_t
The type of a state variable.
REAL input_t
The type of an input.
static uint32_t n_neurons
The number of neurons on the core.
General API of a neuron implementation.
bitfield_recording_indices
Indices for recording of bitfields.
@ PACKET_RECORDING_BITFIELD
Spike event recording index.
@ N_BITFIELD_VARS
Number of recorded bitfields.
uint32_t value_as_payload
void neuron_impl_print_synapse_parameters(uint32_t n_neurons)
Print the synapse parameters of the neurons.
static neuron_t * neuron_array
Array of neuron states.
uint32_t key
The key to send to update the value.
const char * neuron_impl_get_synapse_type_char(uint32_t synapse_type)
Get the synapse type character for a synapse type.
static void neuron_impl_do_timestep_update(uint32_t timer_count, uint32_t time, uint32_t n_neurons)
Do the timestep update for the particular implementation.
word_recording_indices
Indices for recording of words.
@ GSYN_INH_RECORDING_INDEX
Gsyn_inh (excitatory synaptic conductance/current) recording index.
@ GSYN_EXC_RECORDING_INDEX
Gsyn_exc (excitatory synaptic conductance/current) recording index.
@ N_RECORDED_VARS
Number of recorded word-sized state variables.
@ V_RECORDING_INDEX
V (somatic potential) recording index.
static uint32_t n_words_needed(size_t size)
The number of words required to hold an object of given size.
send_type
What sort of message payload should we send?
@ SEND_TYPE_ACCUM
Message payload is an accum
@ SEND_TYPE_UFRACT
Message payload is an unsigned fract
@ SEND_TYPE_INT
Message payload is an int32_t
@ SEND_TYPE_UACCUM
Message payload is an unsigned accum
@ SEND_TYPE_UINT
Message payload is an uint32_t
@ SEND_TYPE_FRACT
Message payload is a fract
static void neuron_impl_add_inputs(index_t synapse_type_index, index_t neuron_index, input_t weights_this_timestep)
Add inputs to the neuron.
static packet_firing_data_t * packet_firing_array
Threshold states array.
uint32_t timesteps_between_sending
The time between sending the value.
void neuron_impl_print_inputs(uint32_t n_neurons)
Print the inputs to the neurons.
static bool neuron_impl_initialise(uint32_t n_neurons)
Initialise the particular implementation of the data.
static uint n_steps_per_timestep
The number of steps to run per timestep.
uint32_t time_until_next_send
The time until the next sending of the value (initially 0)
static synapse_types_t * synapse_types_array
The synapse shaping parameters.
static void neuron_impl_store_neuron_parameters(address_t address, uint32_t next, uint32_t n_neurons)
Stores neuron parameters back into SDRAM.
enum send_type type
Send type.
The definition of the threshold.
static void neuron_model_print_state_variables(const neuron_t *neuron)
printout of state variables i.e. those values that might change
static state_t neuron_model_get_membrane_voltage(const neuron_t *neuron)
get the neuron membrane voltage for a given neuron parameter set
static state_t neuron_model_state_update(uint16_t num_excitatory_inputs, const input_t *exc_input, uint16_t num_inhibitory_inputs, const input_t *inh_input, input_t external_bias, REAL current_offset, neuron_t *restrict neuron)
primary function called in timer loop after synaptic updates
static void neuron_model_print_parameters(const neuron_t *neuron)
printout of parameters i.e. those values that don't change
Leaky Integrate and Fire neuron type.
definition of neuron parameters
definition for LIF neuron state
Recording of the state of a neuron (spiking, voltage, etc.)
static void neuron_recording_record_accum(uint32_t var_index, uint32_t neuron_index, accum value)
stores a recording of an accum variable only; this is faster than neuron_recording_record_value for t...
static void neuron_recording_record_bit(uint32_t var_index, uint32_t neuron_index)
stores a recording of a set bit; this is the only way to set a bit in a bitfield; neuron_recording_re...
void rt_error(uint code,...)
void spin1_memcpy(void *dst, void const *src, uint len)
static stdp_params params
Configuration parameters.
static void synapse_types_save_state(synapse_types_t *state, synapse_types_params_t *params)
save parameters and state back to SDRAM for reading by host and recovery on restart
static const char * synapse_types_get_type_char(index_t synapse_type_index)
returns a human readable character for the type of synapse.
static input_t * synapse_types_get_excitatory_input(input_t *excitatory_response, synapse_types_t *parameters)
extracts the excitatory input buffers from the buffers available for a given neuron ID
static void synapse_types_initialise(synapse_types_t *state, synapse_types_params_t *params, uint32_t n_steps_per_time_step)
initialise the structure from the parameters
static void synapse_types_add_neuron_input(index_t synapse_type_index, synapse_types_t *parameters, input_t input)
adds the inputs for a give timer period to a given neuron that is being simulated by this model
static void synapse_types_print_input(synapse_types_t *parameters)
prints the input for a neuron ID given the available inputs currently only executed when the models a...
static void synapse_types_print_parameters(synapse_types_t *parameters)
prints the parameters of the synapse type
static void synapse_types_shape_input(synapse_types_t *parameters)
decays the stuff thats sitting in the input buffers as these have not yet been processed and applied ...
static input_t * synapse_types_get_inhibitory_input(input_t *inhibitory_response, synapse_types_t *parameters)
extracts the inhibitory input buffers from the buffers available for a given neuron ID
implementation of synapse_types.h for Exponential shaping
Delta synapses support just a single excitatory and inhibitory input each.
The layout of the synapse parameters region.