sPyNNaker neural_modelling 7.2.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 o1 and o2 traces
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 o1 and o2 traces
71 int16_t decayed_o1_trace = timing_decay_post(time, last_time, last_trace);
72
73 // Add energy caused by new spike to trace
74 // **NOTE** o2 trace is pre-multiplied by a3_plus
75 int16_t new_o1_trace = decayed_o1_trace + STDP_FIXED_POINT_ONE;
76
77 // Return new pre- synaptic event with decayed trace values with energy
78 // for new spike added
79 return (post_trace_t) new_o1_trace;
80}
81
82//---------------------------------------
89 uint32_t time, uint32_t last_time, pre_trace_t last_trace) {
91 // Get time since last spike
92 uint32_t delta_time = time - last_time;
93
94 // Decay previous r1 and r2 traces
95 int32_t decayed_r1_trace = STDP_FIXED_MUL_16X16(last_trace,
97
98 // Add energy caused by new spike to trace
99 int32_t new_r1_trace = decayed_r1_trace + STDP_FIXED_POINT_ONE;
100
101 log_debug("\tdelta_time=%u, r1=%d\n", delta_time, new_r1_trace);
102
103 // Return new pre-synaptic event with decayed trace values with energy
104 // for new spike added
105 return (pre_trace_t) new_r1_trace;
106}
107
108//---------------------------------------
119 uint32_t time, UNUSED pre_trace_t trace, UNUSED uint32_t last_pre_time,
120 UNUSED pre_trace_t last_pre_trace, uint32_t last_post_time,
121 post_trace_t last_post_trace, update_state_t previous_state) {
123
124 // Get time of event relative to last post-synaptic event
125 uint32_t time_since_last_post = time - last_post_time;
126 int32_t decayed_o1 = STDP_FIXED_MUL_16X16(last_post_trace,
127 maths_lut_exponential_decay(time_since_last_post, tau_minus_lookup));
128
129 log_debug("\t\t\ttime_since_last_post_event=%u, decayed_o1=%d\n",
130 time_since_last_post, decayed_o1);
131
132 // Apply depression to state (which is a weight_state)
133 return weight_one_term_apply_depression(previous_state, decayed_o1);
134}
135
136//---------------------------------------
147 uint32_t time, UNUSED post_trace_t trace, uint32_t last_pre_time,
148 pre_trace_t last_pre_trace, UNUSED uint32_t last_post_time,
149 UNUSED post_trace_t last_post_trace, update_state_t previous_state) {
151
152 // Get time of event relative to last pre-synaptic event
153 uint32_t time_since_last_pre = time - last_pre_time;
154 if (time_since_last_pre > 0) {
155 int32_t decayed_r1 = STDP_FIXED_MUL_16X16(last_pre_trace,
156 maths_lut_exponential_decay(time_since_last_pre, tau_plus_lookup));
157
158 log_debug("\t\t\ttime_since_last_pre_event=%u, decayed_r1=%d\n",
159 time_since_last_pre, decayed_r1);
160
161 // Apply potentiation to state (which is a weight_state)
162 return weight_one_term_apply_potentiation(previous_state, decayed_r1);
163 } else {
164 return previous_state;
165 }
166}
167
168#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.