20 #ifndef _NEURON_IMPL_STOC_SIGMA_
21 #define _NEURON_IMPL_STOC_SIGMA_
24 #include <spin1_api.h>
27 #include <stdfix-full-iso.h>
30 #define V_RECORDING_INDEX 0
31 #define EX_INPUT_INDEX 1
32 #define IN_INPUT_INDEX 2
34 #define N_RECORDED_VARS 4
36 #define SPIKE_RECORDING_BITFIELD 0
37 #define N_BITFIELD_VARS 1
45 #define PROB_HALF 0x7FFFFFFF
48 #define MAX_POWER REAL_CONST(5)
50 #define MIN_POWER REAL_CONST(-5)
100 static bool neuron_impl_initialise(uint32_t
n_neurons) {
104 log_error(
"Unable to allocate neuron array - Out of DTCM");
111 static inline uint32_t stoc_sigma_ceil_accum(
UREAL value) {
112 uint32_t bits = bitsuk(value);
113 uint32_t integer = bits >> 16;
114 uint32_t fraction = bits & 0xFFFF;
128 spin1_memcpy(state->
random_seed,
params->random_seed,
sizeof(mars_kiss64_seed_t));
138 spin1_memcpy(
params->random_seed, state->
random_seed,
sizeof(mars_kiss64_seed_t));
141 static void neuron_impl_load_neuron_parameters(
142 address_t address, uint32_t next, uint32_t
n_neurons,
143 address_t save_initial_state) {
146 for (uint32_t i = 0; i <
n_neurons; i++) {
152 if (save_initial_state) {
153 spin1_memcpy(save_initial_state, address,
158 static void neuron_impl_store_neuron_parameters(
159 address_t address, uint32_t next, uint32_t
n_neurons) {
161 for (uint32_t i = 0; i <
n_neurons; i++) {
166 static void neuron_impl_add_inputs(
167 index_t synapse_type_index, index_t neuron_index,
168 input_t weights_this_timestep) {
173 neuron->
inputs[synapse_type_index] += weights_this_timestep;
176 static inline void do_refrac_update(uint32_t timer_count, uint32_t
time,
192 send_spike(timer_count,
time, neuron_index);
195 static inline void do_non_refrac_update(uint32_t timer_count, uint32_t
time,
213 uint32_t prob = muliuk(0xFFFFFFFF, val);
219 uint32_t random = mars_kiss64_seed(neuron->
random_seed);
225 send_spike(timer_count,
time, neuron_index);
229 static void neuron_impl_do_timestep_update(
231 for (uint32_t neuron_index = 0; neuron_index <
n_neurons; neuron_index++) {
237 do_refrac_update(timer_count,
time, neuron_index, neuron);
239 do_non_refrac_update(timer_count,
time, neuron_index, neuron);
246 #if LOG_LEVEL >= LOG_DEBUG
248 log_debug(
"-------------------------------------\n");
249 for (index_t i = 0; i <
n_neurons; i++) {
251 log_debug(
"inputs: %k %k", neuron->
inputs[0], neuron->
inputs[1]);
253 log_debug(
"-------------------------------------\n");
262 if (synapse_type == 0) {
264 }
else if (synapse_type == 1) {
General API of a current source implementation.
Implement all current sources.
static uint32_t time
Simulation time.
maths-util.h - first created 7/10/2013 version 0.1
static UREAL pow_of_2(REAL p)
Calculates 2^p where p is a real number (rather than just an integer). This is still quicker than gen...
#define REAL_CONST(x)
Define a constant of type REAL.
unsigned accum UREAL
Type used for "unsigned real" numbers.
accum REAL
Type used for "real" numbers.
static UREAL ukdivuk(UREAL a, UREAL b)
Divides an unsigned accum by another unsigned accum.
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.
void neuron_impl_print_synapse_parameters(uint32_t n_neurons)
Print the synapse parameters of the neurons.
void neuron_impl_print_inputs(uint32_t n_neurons)
Print the inputs to the neurons.
const char * neuron_impl_get_synapse_type_char(uint32_t synapse_type)
Get the synapse type character for a synapse type.
@ SPIKE_RECORDING_BITFIELD
Spike event recording index.
static neuron_impl_t * neuron_array
Array of neuron states.
uint32_t t_refract
The refractory timer countdown value.
input_t inputs[2]
The inputs to add in the next timestep.
mars_kiss64_seed_t random_seed
The random state.
uint32_t refract_timer
The refractory timer.
REAL alpha
The alpha value of the neuron prob = (2^(-2^(alpha x voltage)))
definition of neuron state
static void neuron_model_initialise(neuron_t *state, neuron_params_t *params, uint32_t n_steps_per_timestep)
initialise the structure from the parameters
static void neuron_model_save_state(neuron_t *state, neuron_params_t *params)
save parameters and state back to SDRAM for reading by host and recovery on restart
REAL alpha
The alpha value of the neuron prob = (2^(-2^(alpha x voltage)))
mars_kiss64_seed_t random_seed
Random seed to use.
UREAL tau_refract
The refractory period of the neuron in milliseconds.
UREAL time_step
The timestep of the neuron being used.
uint32_t refract_init
The initial refractory timer.
definition of neuron parameters
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...
static void neuron_recording_record_int32(uint32_t var_index, uint32_t neuron_index, int32_t value)
stores a recording of an int32_t variable only; this is faster than neuron_recording_record_value for...
static stdp_params params
Configuration parameters.