sPyNNaker neural_modelling 7.4.2
Loading...
Searching...
No Matches
timing_pair_impl.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
19#ifndef _TIMING_PAIR_IMPL_H_
20#define _TIMING_PAIR_IMPL_H_
21
22//---------------------------------------
23// Typedefines
24//---------------------------------------
26typedef int16_t post_trace_t;
28typedef int16_t pre_trace_t;
29
31#include "timing.h"
33
34// Include debug header for log_info etc
35#include <debug.h>
36
37// Include generic plasticity maths functions
40
41//---------------------------------------
42// Timing dependence inline functions
43//---------------------------------------
47 return 0;
48}
49
50static inline post_trace_t timing_decay_post(
51 uint32_t time, uint32_t last_time, post_trace_t last_trace) {
53 // Get time since last spike
54 uint32_t delta_time = time - last_time;
55
56 // Decay previous trace
57 return (post_trace_t) STDP_FIXED_MUL_16X16(last_trace,
59}
60
61//---------------------------------------
68 uint32_t time, uint32_t last_time, post_trace_t last_trace) {
69
70 // Decay previous trace
71 int16_t decayed_trace = timing_decay_post(time, last_time, last_trace);
72
73 // Add energy caused by new spike to trace
74 int16_t new_trace = decayed_trace + STDP_FIXED_POINT_ONE;
75
76 // Return new pre- synaptic event with decayed trace values with energy
77 // for new spike added
78 return (post_trace_t) new_trace;
79}
80
81//---------------------------------------
88 uint32_t time, uint32_t last_time, pre_trace_t last_trace) {
90 // Get time since last spike
91 uint32_t delta_time = time - last_time;
92
93 // Decay previous trace
94 int32_t decayed_trace = STDP_FIXED_MUL_16X16(last_trace,
96
97 // Add energy caused by new spike to trace
98 int32_t new_trace = decayed_trace + STDP_FIXED_POINT_ONE;
99
100 log_debug("\tdelta_time=%u, trace=%d\n", delta_time, new_trace);
101
102 // Return new pre-synaptic event with decayed trace values with energy
103 // for new spike added
104 return (pre_trace_t) new_trace;
105}
106
107//---------------------------------------
118 uint32_t time, UNUSED pre_trace_t trace, UNUSED uint32_t last_pre_time,
119 UNUSED pre_trace_t last_pre_trace, uint32_t last_post_time,
120 post_trace_t last_post_trace, update_state_t previous_state) {
122
123 // Get time of event relative to last post-synaptic event
124 uint32_t time_since_last_post = time - last_post_time;
125 int32_t decayed_trace = STDP_FIXED_MUL_16X16(last_post_trace,
126 maths_lut_exponential_decay(time_since_last_post, tau_minus_lookup));
127
128 log_debug("\t\t\ttime_since_last_post_event=%u, decayed_trace=%d\n",
129 time_since_last_post, decayed_trace);
130
131 // Apply depression to state (which is a weight_state)
132 return weight_one_term_apply_depression(previous_state, decayed_trace);
133}
134
135//---------------------------------------
146 uint32_t time, UNUSED post_trace_t trace, uint32_t last_pre_time,
147 pre_trace_t last_pre_trace, UNUSED uint32_t last_post_time,
148 UNUSED post_trace_t last_post_trace, update_state_t previous_state) {
150
151 // Get time of event relative to last pre-synaptic event
152 uint32_t time_since_last_pre = time - last_pre_time;
153 if (time_since_last_pre > 0) {
154 int32_t decayed_trace = STDP_FIXED_MUL_16X16(last_pre_trace,
155 maths_lut_exponential_decay(time_since_last_pre, tau_plus_lookup));
156
157 log_debug("\t\t\ttime_since_last_pre_event=%u, decayed_trace=%d\n",
158 time_since_last_pre, decayed_trace);
159
160 // Apply potentiation to state (which is a weight_state)
161 return weight_one_term_apply_potentiation(previous_state, decayed_trace);
162 } else {
163 return previous_state;
164 }
165}
166
167#endif // _TIMING_PAIR_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.
static int32_t maths_lut_exponential_decay(uint32_t time, const int16_lut *lut)
Get value from lookup table.
Definition maths.h:79
Lookup Table of 16-bit integers.
Definition maths.h:44
Basic definitions for STDP.
#define STDP_FIXED_POINT_ONE
The number 1.0 in the fixed point math used by STDP.
#define STDP_FIXED_MUL_16X16(a, b)
Multiply two STDP fixed point numbers.
Synapses just hold weight.
API for timing rules.
int16_lut * tau_minus_lookup
Lookup table for τ- exponential decay.
int16_lut * tau_plus_lookup
Lookup table for τ+ exponential decay.
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.
int16_t post_trace_t
The type of post-spike traces.
int16_t pre_trace_t
The type of pre-spike traces.
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.
static post_trace_t timing_get_initial_post_trace(void)
Get an initial post-synaptic timing trace.
The type of post-spike traces.
The type of pre-spike 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.