sPyNNaker neural_modelling 7.1.1
Loading...
Searching...
No Matches
timing_recurrent_dual_fsm_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 _TIMING_RECURRENT_DUAL_FSM_IMPL_H_
20#define _TIMING_RECURRENT_DUAL_FSM_IMPL_H_
21
22//---------------------------------------
23// Typedefines
24//---------------------------------------
26typedef uint16_t post_trace_t;
28typedef uint16_t pre_trace_t;
29
31
32#include "timing.h"
34
35// Include debug header for log_info etc
36#include <debug.h>
37
38// Include generic plasticity maths functions
41
42#include "random_util.h"
43
48
49//---------------------------------------
50// Externals
51//---------------------------------------
54
55//---------------------------------------
56// Timing dependence inline functions
57//---------------------------------------
61 return 0;
62}
63
64//---------------------------------------
71 UNUSED uint32_t time, UNUSED uint32_t last_time,
72 UNUSED post_trace_t last_trace) {
74
75 // Pick random number and use to draw from exponential distribution
76 uint32_t random = mars_kiss_fixed_point();
77 uint16_t window_length = post_exp_dist_lookup[random];
78 log_debug("\t\tResetting post-window: random=%d, window_length=%u",
79 random, window_length);
80
81 // Return window length
82 return window_length;
83}
84
85static inline post_trace_t timing_decay_post(
86 UNUSED uint32_t time, UNUSED uint32_t last_time, post_trace_t last_trace) {
87 return last_trace;
88}
89
90//---------------------------------------
97 UNUSED uint32_t time, UNUSED uint32_t last_time,
98 UNUSED pre_trace_t last_trace) {
100
101 // Pick random number and use to draw from exponential distribution
102 uint32_t random = mars_kiss_fixed_point();
103 uint16_t window_length = pre_exp_dist_lookup[random];
104 log_debug("\t\tResetting pre-window: random=%d, window_length=%u",
105 random, window_length);
106
107 // Return window length
108 return window_length;
109}
110
111//---------------------------------------
122 uint32_t time, UNUSED pre_trace_t trace, UNUSED uint32_t last_pre_time,
123 UNUSED pre_trace_t last_pre_trace, uint32_t last_post_time,
124 post_trace_t last_post_trace, update_state_t previous_state) {
125 // Get time of event relative to last post-synaptic event
126 uint32_t time_since_last_post = time - last_post_time;
127
128 log_debug("\t\t\ttime_since_last_post:%u, post_window_length:%u",
129 time_since_last_post, last_post_trace);
130
131 if (time_since_last_post < last_post_trace) {
132 if (previous_state.accumulator >
134 // If accumulator's not going to hit depression limit,
135 // decrement it
136 previous_state.accumulator--;
137 log_debug("\t\t\t\tDecrementing accumulator=%d",
138 previous_state.accumulator);
139 } else {
140 // Otherwise, reset accumulator and apply depression
141 log_debug("\t\t\t\tApplying depression");
142
143 previous_state.accumulator = 0;
145 previous_state.weight_state, STDP_FIXED_POINT_ONE);
146 }
147 }
148
149 return previous_state;
150}
151
152//---------------------------------------
163 uint32_t time, UNUSED post_trace_t trace, uint32_t last_pre_time,
164 pre_trace_t last_pre_trace, UNUSED uint32_t last_post_time,
165 UNUSED post_trace_t last_post_trace, update_state_t previous_state) {
166 // Get time of event relative to last pre-synaptic event
167 uint32_t time_since_last_pre = time - last_pre_time;
168
169 log_debug("\t\t\ttime_since_last_pre:%u, pre_window_length:%u",
170 time_since_last_pre, last_pre_trace);
171
172 // If spikes don't coincide
173 if (time_since_last_pre > 0) {
174 // If this post-spike has arrived within the last pre window
175 if (time_since_last_pre < last_pre_trace) {
176 if (previous_state.accumulator <
178 // If accumulator's not going to hit potentiation limit,
179 // increment it
180 previous_state.accumulator++;
181 log_debug("\t\t\t\tIncrementing accumulator=%d",
182 previous_state.accumulator);
183 } else {
184 // Otherwise, reset accumulator and apply potentiation
185 log_debug("\t\t\t\tApplying potentiation");
186
187 previous_state.accumulator = 0;
189 previous_state.weight_state, STDP_FIXED_POINT_ONE);
190 }
191 }
192 }
193
194 return previous_state;
195}
196
197#endif // _TIMING_RECURRENT_DUAL_FSM_IMPL_H_
uint32_t time
The current timer tick value.
Definition c_main.c:94
void log_debug(const char *message,...)
uint32_t last_time
The time of the most recently-considered spike.
Support functions for STDP.
Utility function for random number generation.
#define random
Basic definitions for STDP.
#define STDP_FIXED_POINT_ONE
The number 1.0 in the fixed point math used by STDP.
Synapses made of weight and accumulator.
weight_state_t weight_state
The weight staet.
int32_t accumulator
The accumulator (in ARM-friendly format)
API for timing rules.
uint16_t pre_exp_dist_lookup[STDP_FIXED_POINT_ONE]
Lookup table for picking exponentially distributed random value for pre-traces.
uint16_t post_exp_dist_lookup[STDP_FIXED_POINT_ONE]
Lookup table for picking exponentially distributed random value for post-traces.
static post_trace_t timing_add_post_spike(uint32_t time, uint32_t last_time, post_trace_t last_trace)
Add a post spike to the post trace.
static update_state_t timing_apply_pre_spike(uint32_t time, pre_trace_t trace, uint32_t last_pre_time, pre_trace_t last_pre_trace, uint32_t last_post_time, post_trace_t last_post_trace, update_state_t previous_state)
Apply a pre-spike timing rule state update.
static pre_trace_t timing_add_pre_spike(uint32_t time, uint32_t last_time, pre_trace_t last_trace)
Add a pre spike to the pre trace.
static update_state_t timing_apply_post_spike(uint32_t time, post_trace_t trace, uint32_t last_pre_time, pre_trace_t last_pre_trace, uint32_t last_post_time, post_trace_t last_post_trace, update_state_t previous_state)
Apply a post-spike timing rule state update.
uint16_t post_trace_t
The type of post-traces.
plasticity_trace_region_data_t plasticity_trace_region_data
Global plasticity parameter data.
static post_trace_t timing_get_initial_post_trace(void)
Get an initial post-synaptic timing trace.
uint16_t pre_trace_t
The type of pre-traces.
The type of post-spike traces.
The type of pre-spike traces.
int32_t accumulator_potentiation_minus_one
Threshold below which we won't hit potentiation trigger after increment.
int32_t accumulator_depression_plus_one
Threshold above which we won't hit depression trigger after decrement.
Configuration information about plasticity traces.
static weight_state_t weight_one_term_apply_depression(weight_state_t state, int32_t a2_minus)
Apply the depression rule to the weight state.
static weight_state_t weight_one_term_apply_potentiation(weight_state_t state, int32_t a2_plus)
Apply the potentiation rule to the weight state.
API for single-term weight dependence rules.