sPyNNaker neural_modelling 7.3.1
Loading...
Searching...
No Matches
synapse_dynamics_static_impl.c
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
24#include "synapse_dynamics.h"
25#include <neuron/synapses.h>
26#include <debug.h>
27#include <utils.h>
28
30 UNUSED address_t address, UNUSED uint32_t n_neurons,
31 UNUSED uint32_t n_synapse_types,
32 UNUSED uint32_t *ring_buffer_to_input_buffer_left_shifts) {
33 return true;
34}
35
36//---------------------------------------
38 UNUSED uint32_t time, UNUSED index_t neuron_index) {
39}
40
41//---------------------------------------
43 UNUSED synapse_row_plastic_data_t *plastic_region_data,
44 UNUSED synapse_row_fixed_part_t *fixed_region,
45 UNUSED weight_t *ring_buffer, UNUSED uint32_t time,
46 UNUSED uint32_t colour_delay, bool *write_back) {
47 log_error("There should be no plastic synapses!");
48 *write_back = false;
49 return false;
50}
51
53 UNUSED synapse_row_plastic_data_t *plastic_region_data,
54 UNUSED synapse_row_fixed_part_t *fixed_region,
55 UNUSED uint32_t *ring_buffer_to_input_left_shifts) {
56}
57
59 return 0;
60}
61
63 return 0;
64}
65
67 uint32_t id, synaptic_row_t row, weight_t *weight, uint16_t *delay,
68 uint32_t *offset, uint32_t *synapse_type) {
70 int32_t fixed_synapse = synapse_row_num_fixed_synapses(fixed_region);
71 uint32_t *synaptic_words = synapse_row_fixed_weight_controls(fixed_region);
72
73 // Loop through plastic synapses
74 for (; fixed_synapse > 0; fixed_synapse--) {
75
76 // Get next control word (auto incrementing)
77 // Check if index is the one I'm looking for
78 uint32_t synaptic_word = *synaptic_words++;
79 if (synapse_row_sparse_index(synaptic_word, synapse_index_mask) == id) {
80 *offset = synapse_row_num_fixed_synapses(fixed_region) -
81 fixed_synapse;
82 *weight = synapse_row_sparse_weight(synaptic_word);
83 *delay = synapse_row_sparse_delay(synaptic_word,
85 *synapse_type = synapse_row_sparse_type(
87 return true;
88 }
89 }
90
91 return false;
92}
93
96 int32_t fixed_synapse = synapse_row_num_fixed_synapses(fixed_region);
97 uint32_t *synaptic_words = synapse_row_fixed_weight_controls(fixed_region);
98
99 // Delete control word at offset (contains weight)
100 synaptic_words[offset] = synaptic_words[fixed_synapse - 1];
101
102 // Decrement FF
103 fixed_region->num_fixed--;
104 return true;
105}
106
108static inline uint32_t _fixed_synapse_convert(
109 uint32_t id, weight_t weight, uint32_t delay, uint32_t type) {
110 uint32_t new_synapse = weight << (32 - SYNAPSE_WEIGHT_BITS);
111 new_synapse |= ((delay & ((1 << synapse_delay_bits) - 1)) <<
113 new_synapse |= ((type & ((1 << synapse_type_bits) - 1)) <<
115 new_synapse |= (id & ((1 << synapse_type_index_bits) - 1));
116 return new_synapse;
117}
118
120 uint32_t id, synaptic_row_t row, weight_t weight,
121 uint32_t delay, uint32_t type) {
123 int32_t fixed_synapse = synapse_row_num_fixed_synapses(fixed_region);
124 uint32_t *synaptic_words = synapse_row_fixed_weight_controls(fixed_region);
125 uint32_t new_synapse = _fixed_synapse_convert(id, weight, delay, type);
126
127 // Add control word at offset
128 synaptic_words[fixed_synapse] = new_synapse;
129
130 // Increment FF
131 fixed_region->num_fixed++;
132 return true;
133}
134
uint32_t index_t
uint32_t * address_t
void log_error(const char *message,...)
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
struct synaptic_row * synaptic_row_t
The type of a synaptic row.
static uint32_t n_neurons
The number of neurons on the core.
Definition neuron.c:45
static uint32_t * ring_buffer_to_input_left_shifts
Amount to left shift the ring buffer by to make it an input.
Definition neuron.c:57
static uint32_t n_synapse_types
The number of synapse types.
Definition neuron.c:51
API for synapse dynamics.
The format of the plastic data region of a synaptic row.
uint32_t synapse_dynamics_get_plastic_pre_synaptic_events(void)
Get the counters for plastic pre synaptic events based on (if the model was compiled with SYNAPSE_BEN...
bool synapse_dynamics_initialise(address_t address, uint32_t n_neurons, uint32_t n_synapse_types, uint32_t *ring_buffer_to_input_buffer_left_shifts)
Initialise the synapse dynamics.
void synapse_dynamics_process_post_synaptic_event(uint32_t time, index_t neuron_index)
Inform the synapses that the neuron fired.
uint32_t synapse_dynamics_get_plastic_saturation_count(void)
Get the number of ring buffer saturation events due to adding plastic weights.
bool synapse_dynamics_find_neuron(uint32_t id, synaptic_row_t row, weight_t *weight, uint16_t *delay, uint32_t *offset, uint32_t *synapse_type)
Search the synaptic row for the the connection with the specified post-synaptic ID.
bool synapse_dynamics_process_plastic_synapses(synapse_row_plastic_data_t *plastic_region_data, synapse_row_fixed_part_t *fixed_region, weight_t *ring_buffer, uint32_t time, uint32_t colour_delay, bool *write_back)
Process the dynamics of the synapses.
bool synapse_dynamics_add_neuron(uint32_t id, synaptic_row_t row, weight_t weight, uint32_t delay, uint32_t type)
Add an entry in the synaptic row.
uint32_t synapse_dynamics_n_connections_in_row(synapse_row_fixed_part_t *fixed)
Get the number of connections in the given row.
void synapse_dynamics_print_plastic_synapses(synapse_row_plastic_data_t *plastic_region_data, synapse_row_fixed_part_t *fixed_region, uint32_t *ring_buffer_to_input_left_shifts)
Print the synapse dynamics.
bool synapse_dynamics_remove_neuron(uint32_t offset, synaptic_row_t row)
Remove the entry at the specified offset in the synaptic row.
#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 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_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 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 weight_t synapse_row_sparse_weight(uint32_t x)
Get the weight from an encoded synapse descriptor.
The type of the fixed part of the row. The fixed-plastic part follows.
uint32_t synapse_index_mask
Mask to pick out the synapse index.
Definition synapses.c:69
uint32_t synapse_delay_bits
Number of bits in the delay.
Definition synapses.c:75
uint32_t synapse_type_bits
Number of bits in the synapse type.
Definition synapses.c:71
uint32_t synapse_type_mask
Mask to pick out the synapse type.
Definition synapses.c:73
Operations on synapses.