sPyNNaker neural_modelling  7.4.2
timing_nearest_pair_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_NEAREST_PAIR_IMPL_H_
20 #define _TIMING_NEAREST_PAIR_IMPL_H_
21 
22 //---------------------------------------
23 // Structures
24 //---------------------------------------
25 typedef struct post_trace_t {
26 } post_trace_t;
27 
28 typedef struct pre_trace_t {
29 } pre_trace_t;
30 
32 #include "timing.h"
34 
35 // Include debug header for log_info etc
36 #include <debug.h>
37 
38 // Include generic plasticity maths functions
40 
41 //---------------------------------------
42 // Timing dependence inline functions
43 //---------------------------------------
47  return (post_trace_t) {};
48 }
49 
50 //---------------------------------------
57  uint32_t time, uint32_t last_time, UNUSED post_trace_t last_trace) {
58  log_debug("\tdelta_time=%u\n", time - last_time);
59 
60  // Return new pre- synaptic event with decayed trace values with energy
61  // for new spike added
62  return (post_trace_t) {};
63 }
64 
65 static inline post_trace_t timing_decay_post(
66  UNUSED uint32_t time, UNUSED uint32_t last_time,
67  UNUSED post_trace_t last_trace) {
68  return (post_trace_t) {};
69 }
70 
71 //---------------------------------------
78  uint32_t time, uint32_t last_time, UNUSED pre_trace_t last_trace) {
79  log_debug("\tdelta_time=%u\n", time - last_time);
80 
81  return (pre_trace_t ) {};
82 }
83 
84 //---------------------------------------
95  uint32_t time, UNUSED pre_trace_t trace, UNUSED uint32_t last_pre_time,
96  UNUSED pre_trace_t last_pre_trace, uint32_t last_post_time,
97  UNUSED post_trace_t last_post_trace, update_state_t previous_state) {
99 
100  // Get time of event relative to last post-synaptic event
101  uint32_t time_since_last_post = time - last_post_time;
102  int32_t decayed_o1 = maths_lut_exponential_decay(
103  time_since_last_post, tau_minus_lookup);
104 
105  log_debug("\t\t\ttime_since_last_post=%u, decayed_o1=%d\n",
106  time_since_last_post, decayed_o1);
107 
108  // Apply depression to state (which is a weight_state)
109  return weight_one_term_apply_depression(previous_state, decayed_o1);
110 }
111 
112 //---------------------------------------
123  uint32_t time, UNUSED post_trace_t trace, uint32_t last_pre_time,
124  UNUSED pre_trace_t last_pre_trace, uint32_t last_post_time,
125  UNUSED post_trace_t last_post_trace, update_state_t previous_state) {
126  extern int16_lut *tau_plus_lookup;
127 
128  // Get time of event relative to last pre-synaptic event
129  uint32_t time_since_last_pre = time - last_pre_time;
130  uint32_t time_since_last_post = time - last_post_time;
131 
132  if (time_since_last_pre > 0) {
133  int32_t decayed_r1 = maths_lut_exponential_decay(
134  time_since_last_pre, tau_plus_lookup);
135 
136  log_debug("\t\t\ttime_since_last_pre=%u, decayed_r1=%d\n",
137  time_since_last_pre, decayed_r1);
138 
139  if (time_since_last_post < time_since_last_pre) {
140  log_debug("\t\t\tSetting trace to zero as not first pre-post pairing");
141  decayed_r1 = 0;
142  }
143 
144  // Apply potentiation to state (which is a weight_state)
145  return weight_one_term_apply_potentiation(previous_state, decayed_r1);
146  } else {
147  return previous_state;
148  }
149 }
150 
151 #endif // _TIMING_NEAREST_PAIR_IMPL_H_
static uint32_t time
Simulation time.
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
Synapses just hold weight.
API for timing rules.
static post_trace_t timing_decay_post(uint32_t time, uint32_t last_time, post_trace_t last_trace)
Evolve the post trace without adding a spike.
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.
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.
int16_t post_trace_t
The type of post-spike traces.
int16_t pre_trace_t
The type of pre-spike traces.
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.