sPyNNaker neural_modelling  7.4.2
Macros | Typedefs | Functions
generator_types.h File Reference

General types associated with generators. More...

#include <common-typedefs.h>
#include <spin1_api.h>
#include "param_generator.h"
#include "matrix_generator.h"

Go to the source code of this file.

Macros

#define max(a, b)   (a > b? a: b)
 

Typedefs

typedef uint32_t generator_hash_t
 The type of values used to indicate the subtype of generator to create. Must match the constants on the Python side of the code.
 
typedef void *() initialize_param_func(void **region)
 How to initialise the param generator. More...
 
typedef void *() initialize_connector_func(void **region)
 How to initialise the connection generator. More...
 
typedef void *() initialize_matrix_func(void **region, void *synaptic_matrix)
 How to initialise the matrix generator. More...
 
typedef void() free_func(void *data)
 How to free any data for the generator; all generator types use the same signature of free func. More...
 
typedef accum() generate_param_func(void *generator)
 How to generate values with a parameter generator. More...
 
typedef 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. More...
 
typedef 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. More...
 

Functions

static uint16_t rescale_delay (accum delay, accum timestep_per_delay)
 Rescales a delay to account for timesteps and type-converts it. More...
 
static uint16_t rescale_weight (accum weight, unsigned long accum weight_scale)
 Rescales a weight to account for weight granularity and type-converts it. More...
 

Detailed Description

General types associated with generators.

Note that generators are really classes... except this is C so we have to cheat.

Definition in file generator_types.h.

Typedef Documentation

◆ initialize_param_func

typedef void*() initialize_param_func(void **region)

How to initialise the param generator.

Parameters
[in,out]regionRegion to read parameters from. Should be updated to position just after parameters after calling.
Returns
A data item to be passed in to other functions later on

Definition at line 46 of file generator_types.h.

◆ initialize_connector_func

typedef void*() initialize_connector_func(void **region)

How to initialise the connection generator.

Parameters
[in,out]regionRegion to read parameters from. Should be updated to position just after parameters after calling.
Returns
A data item to be passed in to other functions later on

Definition at line 54 of file generator_types.h.

◆ initialize_matrix_func

typedef void*() initialize_matrix_func(void **region, void *synaptic_matrix)

How to initialise the matrix generator.

Parameters
[in,out]regionRegion to read parameters from. Should be updated to position just after parameters after calling.
[in]synaptic_matrixThe address of the base of the synaptic matrix
Returns
A data item to be passed in to other functions later on

Definition at line 63 of file generator_types.h.

◆ free_func

typedef void() free_func(void *data)

How to free any data for the generator; all generator types use the same signature of free func.

Parameters
[in]dataThe data to free

Definition at line 70 of file generator_types.h.

◆ generate_param_func

typedef accum() generate_param_func(void *generator)

How to generate values with a parameter generator.

Parameters
[in]generatorThe generator to use to generate values
Returns
The value generated

Definition at line 77 of file generator_types.h.

◆ write_synapse_func

typedef 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.

Parameters
[in]generatorThe generator data
[in]pre_indexThe index of the pre-neuron relative to the start of the matrix
[in]post_indexThe index of the post-neuron on this core
[in]weightThe weight of the synapse in raw numbers
[in]delayThe delay of the synapse in time steps
[in]weight_scaleThe scaling to apply to the weight if needed
Returns
: Whether the synapse was added or not

Definition at line 90 of file generator_types.h.

◆ generate_connection_func

typedef 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.

Parameters
[in]generatorThe generator to use to generate connections
[in]pre_slice_startThe start of the slice of the pre-population being generated
[in]pre_slice_countThe number of neurons in the slice of the pre-population being generated
[in]pre_neuron_indexThe index of the neuron in the pre-population being generated
[in]post_slice_startThe start of the slice of the post-population being generated
[in]post_slice_countThe number of neurons in the slice of the post-population being generated
[in]max_row_lengthThe maximum number of connections to generate
[in,out]indicesAn array into which the core-relative post-indices should be placed. This will be initialised to be max_row_length in size
Returns
Whether connections have been generated successfully

Definition at line 113 of file generator_types.h.

Function Documentation

◆ rescale_delay()

static uint16_t rescale_delay ( accum  delay,
accum  timestep_per_delay 
)
inlinestatic

Rescales a delay to account for timesteps and type-converts it.

Parameters
[in]delaythe delay to rescale
[in]timestep_per_delayThe timestep unit
Returns
the rescaled delay

Definition at line 125 of file generator_types.h.

◆ rescale_weight()

static uint16_t rescale_weight ( accum  weight,
unsigned long accum  weight_scale 
)
inlinestatic

Rescales a weight to account for weight granularity and type-converts it.

Parameters
[in]weightthe weight to rescale
[in]weight_scaleThe weight scaling factor
Returns
the rescaled weight

Definition at line 142 of file generator_types.h.