sPyNNaker neural_modelling 7.1.1
Loading...
Searching...
No Matches
synapse_structure_weight_state_accumulator_window_impl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 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
19#ifndef _SYNAPSE_STRUCTURE_WEIGHT_STATE_ACCUMULATOR_WINDOW_H_
20#define _SYNAPSE_STRUCTURE_WEIGHT_STATE_ACCUMULATOR_WINDOW_H_
21
24typedef struct plastic_synapse_t {
25 unsigned int weight : 16;
26 int accumulator : 4;
27 unsigned int state : 2;
28 unsigned int window_length : 10;
30
33typedef struct update_state_t {
35
36 int32_t accumulator;
37 int32_t state;
38
39 uint32_t window_length;
41
44
45#include "synapse_structure.h"
46
52 plastic_synapse_t synaptic_word, index_t synapse_type) {
53 // Create update state, using weight dependance to initialise the weight
54 // state and copying other parameters from the synaptic word into 32-bit
55 // form
56 update_state_t update_state;
57 update_state.weight_state =
58 weight_get_initial(synaptic_word.weight, synapse_type);
59 update_state.accumulator = (int32_t) synaptic_word.accumulator;
60 update_state.state = (uint32_t) synaptic_word.state;
61 update_state.window_length = (uint32_t) synaptic_word.window_length;
62 return update_state;
63}
64
65//---------------------------------------
70 update_state_t state) {
71 // Get weight from state
72 weight_t weight = weight_get_final(state.weight_state);
73
74 // Build this into synaptic word along with updated accumulator and state
75 return (final_state_t) {
76 .weight = weight,
77 .accumulator = (int) state.accumulator,
78 .state = (unsigned int) state.state,
79 .window_length = (unsigned int)state.window_length
80 };
81}
82
83//---------------------------------------
88 final_state_t final_state) {
89 return final_state.weight;
90}
91
92//---------------------------------------
97 final_state_t final_state) {
98 return final_state;
99}
100
101//---------------------------------------
106 weight_t weight) {
107 return (plastic_synapse_t) {
108 .weight = weight,
109 .accumulator = 0,
110 .state = 0,
111 .window_length = 0
112 };
113}
114
115//---------------------------------------
119static inline weight_t synapse_structure_get_weight(
120 plastic_synapse_t synaptic_word) {
121 return synaptic_word.weight;
122}
123
124static inline void synapse_structure_decay_weight(
125 update_state_t *state, uint32_t decay) {
126 weight_decay(&(state->weight_state), decay);
127}
128
129static inline accum synapse_structure_get_update_weight(update_state_t state) {
130 return weight_get_update(state.weight_state);
131}
132
133#endif // _SYNAPSE_STRUCTURE_WEIGHT_STATE_ACCUMULATOR_WINDOW_H_
uint32_t index_t
#define decay(x, d)
This is a type-generic decay "function".
Definition decay.h:118
API for synaptic state.
plastic_synapse_t final_state_t
Final states are actually directly what is stored.
static plastic_synapse_t synapse_structure_get_final_synaptic_word(final_state_t final_state)
Get the final plastic synapse data from the final state.
weight_state_t weight_state
The weight staet.
static plastic_synapse_t synapse_structure_create_synapse(weight_t weight)
Create the initial plastic synapse data.
static update_state_t synapse_structure_get_update_state(plastic_synapse_t synaptic_word, index_t synapse_type)
Get the update state from the synapse structure.
static weight_t synapse_structure_get_final_weight(final_state_t final_state)
Get the final weight from the final state.
int32_t accumulator
The accumulator (in ARM-friendly format)
static final_state_t synapse_structure_get_final_state(update_state_t state)
Get the final state from the update state.
static weight_t synapse_structure_get_weight(plastic_synapse_t synaptic_word)
Get the current synaptic weight from the plastic synapse data.
Plastic synapse contains normal 16-bit weight and an accumulator.
static weight_t weight_get_final(weight_state_t new_state)
Gets the final weight.
static weight_state_t weight_get_initial(weight_t weight, index_t synapse_type)
Gets the initial weight state.
static void weight_decay(weight_state_t *state, int32_t decay)
Decay the weight inside the state by multiplication.
static accum weight_get_update(weight_state_t state)
Get the weight inside during update in STDP fixed point format.
The current state data for the rule.