sPyNNaker neural_modelling 7.3.1
Loading...
Searching...
No Matches
synapse_row.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
88#ifndef _SYNAPSE_ROW_H_
89#define _SYNAPSE_ROW_H_
90
92
94#ifndef SYNAPSE_WEIGHT_BITS
95#define SYNAPSE_WEIGHT_BITS 16
96#endif
97
98#ifdef SYNAPSE_WEIGHTS_SIGNED
100typedef __int_t(SYNAPSE_WEIGHT_BITS) weight_t;
101#else
103typedef __uint_t(SYNAPSE_WEIGHT_BITS) weight_t;
104#endif
106typedef uint16_t control_t;
107
109#define N_SYNAPSE_ROW_HEADER_WORDS 3
110
112typedef struct {
113 size_t size;
114 uint32_t data[];
116
118typedef struct {
119 size_t num_fixed;
120 size_t num_plastic;
121 uint32_t data[];
123
125
129static inline size_t synapse_row_plastic_size(const synaptic_row_t row) {
130 const synapse_row_plastic_part_t *the_row =
131 (const synapse_row_plastic_part_t *) row;
132 return the_row->size;
133}
134
143
148 synaptic_row_t row) {
150 return (synapse_row_fixed_part_t *) &the_row->data[the_row->size];
151}
152
157 const synapse_row_fixed_part_t *fixed) {
158 return fixed->num_fixed;
159}
160
165 const synapse_row_fixed_part_t *fixed) {
166 return fixed->num_plastic;
167}
168
174 return (control_t *) &fixed->data[fixed->num_fixed];
175}
176
180static inline uint32_t *synapse_row_fixed_weight_controls(
182 return fixed->data;
183}
184
185// The following are offset calculations into the ring buffers
191 uint32_t x, uint32_t synapse_index_mask) {
192 return x & synapse_index_mask;
193}
194
202 uint32_t x, uint32_t synapse_index_bits, uint32_t synapse_type_mask) {
204}
205
212 uint32_t x, uint32_t synapse_type_index_mask) {
213 return x & synapse_type_index_mask;
214}
215
223 uint32_t x, uint32_t synapse_type_index_bits, uint32_t synapse_delay_mask) {
225}
226
230static inline weight_t synapse_row_sparse_weight(uint32_t x) {
231 return x >> (32 - SYNAPSE_WEIGHT_BITS);
232}
233
239 weight_t weight, uint32_t left_shift) {
240 union {
241 int_k_t input_type;
242 s1615 output_type;
243 } converter;
244
245 converter.input_type = (int_k_t) (weight) << left_shift;
246
247 return converter.output_type;
248}
249
260 uint32_t simulation_timestep, uint32_t synapse_type_index,
261 uint32_t neuron_index, uint32_t synapse_type_index_bits,
262 uint32_t synapse_index_bits, uint32_t synapse_delay_mask) {
263 return ((simulation_timestep & synapse_delay_mask) << synapse_type_index_bits)
264 | (synapse_type_index << synapse_index_bits)
265 | neuron_index;
266}
267
275 uint32_t synapse_type_index, uint32_t neuron_index,
276 uint32_t synapse_index_bits) {
277 return (synapse_type_index << synapse_index_bits) | neuron_index;
278}
279
286 uint32_t simulation_timestep, uint32_t synapse_type_index_bits,
287 int32_t synapse_delay_mask) {
288 return (simulation_timestep & synapse_delay_mask) << synapse_type_index_bits;
289}
290
299 uint32_t simulation_timestep,
300 uint32_t combined_synapse_neuron_index,
301 uint32_t synapse_type_index_bits, uint32_t synapse_delay_mask) {
302 return ((simulation_timestep & synapse_delay_mask) << synapse_type_index_bits)
303 | combined_synapse_neuron_index;
304}
305
306#endif // SYNAPSE_ROW_H
uint32_t index_t
uint32_t synapse_delay_mask
The mask to get the synaptic delay from a "synapse".
Definition local_only.c:71
uint32_t synapse_type_index_bits
The number of bits used by the synapse type and post-neuron index.
Definition local_only.c:74
uint32_t synapse_index_bits
The number of bits used by just the post-neuron index.
Definition local_only.c:77
Data type definitions for SpiNNaker Neuron-modelling.
struct synaptic_row * synaptic_row_t
The type of a synaptic row.
REAL input_t
The type of an input.
int32_t int_k_t
accum s1615
The format of the plastic data region of a synaptic row.
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.
uint32_t data[]
The data, first the fixed then the plastic.
static size_t synapse_row_num_plastic_controls(const synapse_row_fixed_part_t *fixed)
Get the number of plastic controls in the row.
size_t size
The number of plastic words in data
#define SYNAPSE_WEIGHT_BITS
how many bits the synapse weight will take
Definition synapse_row.h:95
static synapse_row_fixed_part_t * synapse_row_fixed_region(synaptic_row_t row)
Get the address of the non-plastic (or fixed) region.
static control_t * synapse_row_plastic_controls(synapse_row_fixed_part_t *fixed)
Get the array of plastic controls in the row.
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 size_t synapse_row_num_fixed_synapses(const synapse_row_fixed_part_t *fixed)
Get the number of fixed synapses in the row.
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 ...
static index_t synapse_row_sparse_index(uint32_t x, uint32_t synapse_index_mask)
Get the 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 synapse_row_plastic_data_t * synapse_row_plastic_region(synaptic_row_t row)
Get the address of the plastic region.
size_t num_plastic
The number of plastic controls in data
static index_t synapse_row_sparse_type_index(uint32_t x, uint32_t synapse_type_index_mask)
Get the type and index.
static size_t synapse_row_plastic_size(const synaptic_row_t row)
Get the size of the plastic region.
static uint32_t * synapse_row_fixed_weight_controls(synapse_row_fixed_part_t *fixed)
The array of fixed weights in the row.
size_t num_fixed
The number of fixed synapses in data
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 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.
uint16_t control_t
Define the type of the control data.
static weight_t synapse_row_sparse_weight(uint32_t x)
Get the weight from an encoded synapse descriptor.
uint32_t data[]
The plastic words, followed by the fixed part.
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.
The type of the fixed part of the row. The fixed-plastic part follows.
The type of the plastic-plastic part of the row.
uint32_t synapse_index_mask
Mask to pick out the synapse index.
Definition synapses.c:69
uint32_t synapse_type_index_mask
Mask to pick out the synapse type and index.
Definition synapses.c:65
uint32_t synapse_type_mask
Mask to pick out the synapse type.
Definition synapses.c:73