sPyNNaker neural_modelling 7.1.1
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
synapse_row.h File Reference

implementation for handling the processing of synapse rows. More...

#include <common/neuron-typedefs.h>

Go to the source code of this file.

Data Structures

struct  synapse_row_plastic_part_t
 The type of the plastic-plastic part of the row. More...
 
struct  synapse_row_fixed_part_t
 The type of the fixed part of the row. The fixed-plastic part follows. More...
 

Macros

#define SYNAPSE_WEIGHT_BITS   16
 how many bits the synapse weight will take
 
#define N_SYNAPSE_ROW_HEADER_WORDS   3
 Number of header words per synaptic row.
 

Typedefs

typedef uint16_t control_t
 Define the type of the control data.
 

Functions

static size_t synapse_row_plastic_size (const synaptic_row_t row)
 Get the size of the plastic region.
 
static synapse_row_plastic_data_tsynapse_row_plastic_region (synaptic_row_t row)
 Get the address of the plastic region.
 
static synapse_row_fixed_part_tsynapse_row_fixed_region (synaptic_row_t row)
 Get the address of the non-plastic (or fixed) region.
 
static size_t synapse_row_num_fixed_synapses (const synapse_row_fixed_part_t *fixed)
 Get the number of fixed synapses in the row.
 
static size_t synapse_row_num_plastic_controls (const synapse_row_fixed_part_t *fixed)
 Get the number of plastic controls in the row.
 
static control_tsynapse_row_plastic_controls (synapse_row_fixed_part_t *fixed)
 Get the array of plastic controls in the row.
 
static uint32_t * synapse_row_fixed_weight_controls (synapse_row_fixed_part_t *fixed)
 The array of fixed weights in the row.
 
static index_t synapse_row_sparse_index (uint32_t x, uint32_t synapse_index_mask)
 Get the index.
 
static index_t synapse_row_sparse_type (uint32_t x, uint32_t synapse_index_bits, uint32_t synapse_type_mask)
 Get the type code.
 
static index_t synapse_row_sparse_type_index (uint32_t x, uint32_t synapse_type_index_mask)
 Get the type and index.
 
static index_t synapse_row_sparse_delay (uint32_t x, uint32_t synapse_type_index_bits, uint32_t synapse_delay_mask)
 Get the delay from an encoded synapse descriptor.
 
static weight_t synapse_row_sparse_weight (uint32_t x)
 Get the weight from an encoded synapse descriptor.
 
static input_t synapse_row_convert_weight_to_input (weight_t weight, uint32_t left_shift)
 Converts a weight stored in a synapse row to an input.
 
static index_t synapse_row_get_ring_buffer_index (uint32_t simulation_timestep, uint32_t synapse_type_index, uint32_t neuron_index, uint32_t synapse_type_index_bits, uint32_t synapse_index_bits, uint32_t synapse_delay_mask)
 Get the index of the ring buffer for a given timestep, synapse type and neuron index.
 
static index_t synapse_row_get_ring_buffer_index_time_0 (uint32_t synapse_type_index, uint32_t neuron_index, uint32_t synapse_index_bits)
 Get the index of the ring buffer for time 0, synapse type and neuron index.
 
static index_t synapse_row_get_first_ring_buffer_index (uint32_t simulation_timestep, uint32_t synapse_type_index_bits, int32_t synapse_delay_mask)
 Get the index of the first ring buffer for a given timestep.
 
static index_t synapse_row_get_ring_buffer_index_combined (uint32_t simulation_timestep, uint32_t combined_synapse_neuron_index, uint32_t synapse_type_index_bits, uint32_t synapse_delay_mask)
 Get the index of the ring buffer for a given timestep and combined synapse type and neuron index (as stored in a synapse row)
 

Detailed Description

implementation for handling the processing of synapse rows.

Synapse Row Representation

| Weight | Delay | Synapse Type | Neuron Index |
|-------------------|------------------|-----------------|------------------|
|SYNAPSE_WEIGHT_BITS|SYNAPSE_DELAY_BITS|SYNAPSE_TYPE_BITS|SYNAPSE_INDEX_BITS|
| | | SYNAPSE_TYPE_INDEX_BITS |
#define SYNAPSE_WEIGHT_BITS
how many bits the synapse weight will take
Definition synapse_row.h:95
#define SYNAPSE_TYPE_BITS
Number of bits to encode the synapse type.

The API interface supports:

Data Structure

The data structure layout supported by this API is designed for mixed plastic and fixed synapse rows.

The data structure is treated as an array of 32-bit words. Special meanings are ascribed to the 0th and 1st elements of the array.

We are expecting the original source address in SDRAM to be in row[0]. The number of array elements in the plastic region is held in the upper part of row[1]. A tag to indicate the nature of the synaptic row structure is held in the lower part of row[1].

0: [ N = <plastic elements> | <tag> ]
1: [ First word of plastic region ]
...
N: [ Last word of plastic region ]
N+1: [ First word of fixed region ]
...
M: [ Last word of fixed region ]
region
spike source array region IDs in human readable form

Fixed and Fixed-Plastic Regions

Within the fixed-region extracted using the above API, fixed[0] contains the number of 32-bit fixed synaptic words, fixed[1] contains the number of 16-bit plastic synapse control words. (The weights for the plastic synapses are assumed to be stored in some learning-rule-specific format in the plastic region)

0: [ F = Num fixed synapses ]
1: [ P = Size of plastic region in HALF-WORDS ]
2: [ First fixed synaptic word ]
...
F+1: [ Last fixed synaptic word ]
F+2: [ 1st plastic synapse control word|2nd plastic control word ]
...
F+1+ceil(P/2): [ Last word of fixed region ]
#define HALF
A REAL 0.5.
Definition maths-util.h:119

Note that P is effectively rounded up to a multiple of two for storage purposes.

Definition in file synapse_row.h.


Data Structure Documentation

◆ synapse_row_plastic_part_t

struct synapse_row_plastic_part_t

The type of the plastic-plastic part of the row.

Definition at line 112 of file synapse_row.h.

Data Fields
size_t size The number of plastic words in data
uint32_t data[] The plastic words, followed by the fixed part.

◆ synapse_row_fixed_part_t

struct synapse_row_fixed_part_t

The type of the fixed part of the row. The fixed-plastic part follows.

Definition at line 118 of file synapse_row.h.

Data Fields
size_t num_fixed The number of fixed synapses in data
size_t num_plastic The number of plastic controls in data
uint32_t data[] The data, first the fixed then the plastic.

Macro Definition Documentation

◆ SYNAPSE_WEIGHT_BITS

#define SYNAPSE_WEIGHT_BITS   16

how many bits the synapse weight will take

Definition at line 95 of file synapse_row.h.

◆ N_SYNAPSE_ROW_HEADER_WORDS

#define N_SYNAPSE_ROW_HEADER_WORDS   3

Number of header words per synaptic row.

Definition at line 109 of file synapse_row.h.

Typedef Documentation

◆ control_t

typedef uint16_t control_t

Define the type of the control data.

Definition at line 106 of file synapse_row.h.

Function Documentation

◆ synapse_row_plastic_size()

static size_t synapse_row_plastic_size ( const synaptic_row_t  row)
inlinestatic

Get the size of the plastic region.

Parameters
[in]rowThe synaptic row
Returns
The size of the plastic region of the row

Definition at line 129 of file synapse_row.h.

◆ synapse_row_plastic_region()

static synapse_row_plastic_data_t * synapse_row_plastic_region ( synaptic_row_t  row)
inlinestatic

Get the address of the plastic region.

Parameters
[in]rowThe synaptic row
Returns
Pointer to the plastic region of the row

Definition at line 138 of file synapse_row.h.

◆ synapse_row_fixed_region()

static synapse_row_fixed_part_t * synapse_row_fixed_region ( synaptic_row_t  row)
inlinestatic

Get the address of the non-plastic (or fixed) region.

Parameters
[in]rowThe synaptic row
Returns
Address of the fixed region of the row

Definition at line 147 of file synapse_row.h.

◆ synapse_row_num_fixed_synapses()

static size_t synapse_row_num_fixed_synapses ( const synapse_row_fixed_part_t fixed)
inlinestatic

Get the number of fixed synapses in the row.

Parameters
[in]fixedThe fixed region of the synaptic row
Returns
Size of the fixed region of the row (in words)

Definition at line 156 of file synapse_row.h.

◆ synapse_row_num_plastic_controls()

static size_t synapse_row_num_plastic_controls ( const synapse_row_fixed_part_t fixed)
inlinestatic

Get the number of plastic controls in the row.

Parameters
[in]fixedThe fixed region of the synaptic row
Returns
Size of the fixed-plastic region of the row (in half words)

Definition at line 164 of file synapse_row.h.

◆ synapse_row_plastic_controls()

static control_t * synapse_row_plastic_controls ( synapse_row_fixed_part_t fixed)
inlinestatic

Get the array of plastic controls in the row.

Parameters
[in]fixedThe fixed region of the synaptic row
Returns
Address of the fixed-plastic region of the row

Definition at line 172 of file synapse_row.h.

◆ synapse_row_fixed_weight_controls()

static uint32_t * synapse_row_fixed_weight_controls ( synapse_row_fixed_part_t fixed)
inlinestatic

The array of fixed weights in the row.

Parameters
[in]fixedThe fixed region of the synaptic row
Returns
Address of the fixed-fixed region of the row

Definition at line 180 of file synapse_row.h.

◆ synapse_row_sparse_index()

static index_t synapse_row_sparse_index ( uint32_t  x,
uint32_t  synapse_index_mask 
)
inlinestatic

Get the index.

Parameters
[in]xThe value to decode
[in]synapse_index_maskMask for the synapse index (depends on type)
Returns
the index

Definition at line 190 of file synapse_row.h.

◆ synapse_row_sparse_type()

static index_t synapse_row_sparse_type ( uint32_t  x,
uint32_t  synapse_index_bits,
uint32_t  synapse_type_mask 
)
inlinestatic

Get the type code.

Parameters
[in]xThe value to decode
[in]synapse_index_bitsNumber of bits for the synapse index (depends on type)
[in]synapse_type_maskMask for the synapse type (depends on type)
Returns
the type code

Definition at line 201 of file synapse_row.h.

◆ synapse_row_sparse_type_index()

static index_t synapse_row_sparse_type_index ( uint32_t  x,
uint32_t  synapse_type_index_mask 
)
inlinestatic

Get the type and index.

Parameters
[in]xThe value to decode
[in]synapse_type_index_maskMask for the synapse type and index (depends on type)
Returns
the type and index (packed in the low bits of a word)

Definition at line 211 of file synapse_row.h.

◆ synapse_row_sparse_delay()

static index_t synapse_row_sparse_delay ( uint32_t  x,
uint32_t  synapse_type_index_bits,
uint32_t  synapse_delay_mask 
)
inlinestatic

Get the delay from an encoded synapse descriptor.

Parameters
[in]xThe value to decode
[in]synapse_type_index_bitsNumber of bits for the synapse type and index (depends on type)
[in]synapse_delay_maskThe mask for selecting the bits of the delay
Returns
the delay

Definition at line 222 of file synapse_row.h.

◆ synapse_row_sparse_weight()

static weight_t synapse_row_sparse_weight ( uint32_t  x)
inlinestatic

Get the weight from an encoded synapse descriptor.

Parameters
[in]xThe value to decode
Returns
the weight

Definition at line 230 of file synapse_row.h.

◆ synapse_row_convert_weight_to_input()

static input_t synapse_row_convert_weight_to_input ( weight_t  weight,
uint32_t  left_shift 
)
inlinestatic

Converts a weight stored in a synapse row to an input.

Parameters
[in]weightthe weight to convert in synapse-row form
[in]left_shiftthe shift to use when decoding
Returns
the actual input weight for the model

Definition at line 238 of file synapse_row.h.

◆ synapse_row_get_ring_buffer_index()

static index_t synapse_row_get_ring_buffer_index ( uint32_t  simulation_timestep,
uint32_t  synapse_type_index,
uint32_t  neuron_index,
uint32_t  synapse_type_index_bits,
uint32_t  synapse_index_bits,
uint32_t  synapse_delay_mask 
)
inlinestatic

Get the index of the ring buffer for a given timestep, synapse type and neuron index.

Parameters
[in]simulation_timestepThe timestep
[in]synapse_type_indexThe synapse type index
[in]neuron_indexThe neuron index
[in]synapse_type_index_bitsNumber of bits for type and index
[in]synapse_index_bitsNumber of bits for index
[in]synapse_delay_maskMask for delay
Returns
Index into the ring buffer

Definition at line 259 of file synapse_row.h.

◆ synapse_row_get_ring_buffer_index_time_0()

static index_t synapse_row_get_ring_buffer_index_time_0 ( uint32_t  synapse_type_index,
uint32_t  neuron_index,
uint32_t  synapse_index_bits 
)
inlinestatic

Get the index of the ring buffer for time 0, synapse type and neuron index.

Parameters
[in]synapse_type_indexThe synapse type index
[in]neuron_indexThe neuron index
[in]synapse_index_bitsNumber of bits for index
Returns
Index into the ring buffer

Definition at line 274 of file synapse_row.h.

◆ synapse_row_get_first_ring_buffer_index()

static index_t synapse_row_get_first_ring_buffer_index ( uint32_t  simulation_timestep,
uint32_t  synapse_type_index_bits,
int32_t  synapse_delay_mask 
)
inlinestatic

Get the index of the first ring buffer for a given timestep.

Parameters
[in]simulation_timestepThe timestep
[in]synapse_type_index_bitsNumber of bits for type and index
[in]synapse_delay_maskMask for delay
Returns
Index into the ring buffer

Definition at line 285 of file synapse_row.h.

◆ synapse_row_get_ring_buffer_index_combined()

static index_t synapse_row_get_ring_buffer_index_combined ( uint32_t  simulation_timestep,
uint32_t  combined_synapse_neuron_index,
uint32_t  synapse_type_index_bits,
uint32_t  synapse_delay_mask 
)
inlinestatic

Get the index of the ring buffer for a given timestep and combined synapse type and neuron index (as stored in a synapse row)

Parameters
[in]simulation_timestepThe timestep
[in]combined_synapse_neuron_index
[in]synapse_type_index_bitsNumber of bits for type and index
[in]synapse_delay_maskMask for delay
Returns
Index into the ring buffer

Definition at line 298 of file synapse_row.h.