22#ifndef INCLUDED_GENERATOR_TYPES_H
23#define INCLUDED_GENERATOR_TYPES_H
31#define UNUSED __attribute__((__unused__))
91 uint32_t pre_index, uint16_t post_index, accum weight, uint16_t delay,
92 unsigned long accum weight_scale);
114 void *generator, uint32_t pre_lo, uint32_t pre_hi,
115 uint32_t post_lo, uint32_t post_hi, uint32_t post_index,
116 uint32_t post_slice_start, uint32_t post_slice_count,
117 unsigned long accum weight_scale, accum timestep_per_delay,
118 param_generator_t weight_generator, param_generator_t delay_generator,
125static inline uint16_t
rescale_delay(accum delay, accum timestep_per_delay) {
126 accum ts_delay = delay * timestep_per_delay;
130 uint16_t delay_int = (uint16_t) ts_delay;
131 if (ts_delay != delay_int) {
132 log_debug(
"Rounded delay %k to %u", delay, delay_int);
142static inline uint16_t
rescale_weight(accum weight,
unsigned long accum weight_scale) {
143 unsigned long accum uweight = 0;
149 unsigned long accum weight_scaled = uweight * weight_scale;
150 unsigned long accum weight_rounded = roundulk(weight_scaled, 32);
151 uint16_t weight_int = (uint16_t) (bitsulk(weight_rounded) >> 32);
152 if (weight_scaled != weight_int) {
153 log_debug(
"Rounded weight %k to %u (scale is %k)",
154 weight_scaled, weight_int, weight_scale);
159#define max(a, b) (a > b? a: b)
void log_debug(const char *message,...)
void *() initialize_connector_func(void **region)
How to initialise the connection generator.
bool() write_synapse_func(void *generator, uint32_t pre_index, uint16_t post_index, accum weight, uint16_t delay, unsigned long accum weight_scale)
How to write a synapse to a matrix.
void *() initialize_matrix_func(void **region, void *synaptic_matrix)
How to initialise the matrix generator.
uint32_t generator_hash_t
The type of values used to indicate the subtype of generator to create. Must match the constants on t...
static uint16_t rescale_weight(accum weight, unsigned long accum weight_scale)
Rescales a weight to account for weight granularity and type-converts it.
void() free_func(void *data)
How to free any data for the generator; all generator types use the same signature of free func.
static uint16_t rescale_delay(accum delay, accum timestep_per_delay)
Rescales a delay to account for timesteps and type-converts it.
bool() generate_connection_func(void *generator, uint32_t pre_lo, uint32_t pre_hi, uint32_t post_lo, uint32_t post_hi, uint32_t post_index, uint32_t post_slice_start, uint32_t post_slice_count, unsigned long accum weight_scale, accum timestep_per_delay, param_generator_t weight_generator, param_generator_t delay_generator, matrix_generator_t matrix_generator)
How to generate connections with a connection generator.
accum() generate_param_func(void *generator)
How to generate values with a parameter generator.
void *() initialize_param_func(void **region)
How to initialise the param generator.
The data for a matrix generator.
Interface for matrix generation.
Interface for parameter generator.
region
spike source array region IDs in human readable form