NEST main@caf0ae8
 
Loading...
Searching...
No Matches
stdp_facetshw_synapse_hom_impl.h
Go to the documentation of this file.
1/*
2 * stdp_facetshw_synapse_hom_impl.h
3 *
4 * This file is part of NEST.
5 *
6 * Copyright (C) 2004 The NEST Initiative
7 *
8 * NEST is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NEST is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef STDP_SYNAPSE_FACETSHW_HOM_IMPL_H
24#define STDP_SYNAPSE_FACETSHW_HOM_IMPL_H
25
27
28// Includes from nestkernel:
30#include "connector_model.h"
31#include "event.h"
32
33namespace nest
34{
35//
36// Implementation of class STDPFACETSHWHomCommonProperties.
37//
38
39template < typename targetidentifierT >
42 , tau_plus_( 20.0 )
43 , tau_minus_( 20.0 )
44 , Wmax_( 100.0 )
45 , no_synapses_( 0 )
46 , synapses_per_driver_( 50 ) // hardware efficiency of 50/256=20%,
47 // which is comparable to Fieres et al. (2008)
48 , driver_readout_time_( 15.0 ) // in ms; measured on hardware
49{
50 lookuptable_0_.resize( 16 );
51 lookuptable_1_.resize( 16 );
52 lookuptable_2_.resize( 16 );
53
54 // intermediate Guetig (mu=0.4)
55 // with r=4 bits and n=36 SSPs, see Pfeil et al. (2012)
56 lookuptable_0_.at( 0 ) = 2;
57 lookuptable_0_.at( 1 ) = 3;
58 lookuptable_0_.at( 2 ) = 4;
59 lookuptable_0_.at( 3 ) = 4;
60 lookuptable_0_.at( 4 ) = 5;
61 lookuptable_0_.at( 5 ) = 6;
62 lookuptable_0_.at( 6 ) = 7;
63 lookuptable_0_.at( 7 ) = 8;
64 lookuptable_0_.at( 8 ) = 9;
65 lookuptable_0_.at( 9 ) = 10;
66 lookuptable_0_.at( 10 ) = 11;
67 lookuptable_0_.at( 11 ) = 12;
68 lookuptable_0_.at( 12 ) = 13;
69 lookuptable_0_.at( 13 ) = 14;
70 lookuptable_0_.at( 14 ) = 14;
71 lookuptable_0_.at( 15 ) = 15;
72
73 lookuptable_1_.at( 0 ) = 0;
74 lookuptable_1_.at( 1 ) = 0;
75 lookuptable_1_.at( 2 ) = 1;
76 lookuptable_1_.at( 3 ) = 2;
77 lookuptable_1_.at( 4 ) = 3;
78 lookuptable_1_.at( 5 ) = 4;
79 lookuptable_1_.at( 6 ) = 5;
80 lookuptable_1_.at( 7 ) = 6;
81 lookuptable_1_.at( 8 ) = 7;
82 lookuptable_1_.at( 9 ) = 8;
83 lookuptable_1_.at( 10 ) = 9;
84 lookuptable_1_.at( 11 ) = 10;
85 lookuptable_1_.at( 12 ) = 10;
86 lookuptable_1_.at( 13 ) = 11;
87 lookuptable_1_.at( 14 ) = 12;
88 lookuptable_1_.at( 15 ) = 13;
89
90 for ( size_t i = 0; i < lookuptable_0_.size(); ++i )
91 {
92 lookuptable_2_.at( i ) = i;
93 }
94
95 configbit_0_.resize( 4 );
96 configbit_1_.resize( 4 );
97
98 // see Friedmann (2013)
99 configbit_0_.at( 0 ) = 0;
100 configbit_0_.at( 1 ) = 0;
101 configbit_0_.at( 2 ) = 1;
102 configbit_0_.at( 3 ) = 0;
103 configbit_1_.at( 0 ) = 0;
104 configbit_1_.at( 1 ) = 1;
105 configbit_1_.at( 2 ) = 0;
106 configbit_1_.at( 3 ) = 0;
107
108 reset_pattern_.resize( 6 );
109 for ( size_t i = 0; i < reset_pattern_.size(); ++i )
110 {
111 reset_pattern_.at( i ) = true;
112 }
113
114 weight_per_lut_entry_ = Wmax_ / ( lookuptable_0_.size() - 1 );
116}
117
118template < typename targetidentifierT >
119void
121{
122 readout_cycle_duration_ = int( ( no_synapses_ - 1.0 ) / synapses_per_driver_ + 1.0 ) * driver_readout_time_;
123}
124
125template < typename targetidentifierT >
126void
128{
130
131 d[ names::tau_plus ] = tau_plus_;
132 d[ names::tau_minus_stdp ] = tau_minus_;
133 d[ names::Wmax ] = Wmax_;
134 d[ names::weight_per_lut_entry ] = weight_per_lut_entry_;
135
136 d[ names::no_synapses ] = no_synapses_;
137 d[ names::synapses_per_driver ] = synapses_per_driver_;
138 d[ names::driver_readout_time ] = driver_readout_time_;
139 d[ names::readout_cycle_duration ] = readout_cycle_duration_;
140
141 d[ names::lookuptable_0 ] = lookuptable_0_;
142 d[ names::lookuptable_1 ] = lookuptable_1_;
143 d[ names::lookuptable_2 ] = lookuptable_2_;
144 d[ names::configbit_0 ] = configbit_0_;
145 d[ names::configbit_1 ] = configbit_1_;
146 d[ names::reset_pattern ] = reset_pattern_;
147}
148
149template < typename targetidentifierT >
150void
152{
154
155 d.update_value( names::tau_plus, tau_plus_ );
156 d.update_value( names::tau_minus_stdp, tau_minus_ );
157 if ( d.update_value( names::Wmax, Wmax_ ) )
158 {
159 weight_per_lut_entry_ = Wmax_ / ( lookuptable_0_.size() - 1 );
160 }
161
162 // TP: they should not be allowed to be changed! But needed for CopyModel ...
163 d.update_value( names::weight_per_lut_entry, weight_per_lut_entry_ );
164 d.update_value( names::readout_cycle_duration, readout_cycle_duration_ );
165 if ( d.update_value( names::no_synapses, no_synapses_ ) )
166 {
167 calc_readout_cycle_duration_();
168 }
169
170 if ( d.update_value( names::synapses_per_driver, synapses_per_driver_ ) )
171 {
172 calc_readout_cycle_duration_();
173 }
174 if ( d.update_value( names::driver_readout_time, driver_readout_time_ ) )
175 {
176 calc_readout_cycle_duration_();
177 }
178
179 if ( d.known( names::lookuptable_0 ) )
180 {
181 d.update_value( names::lookuptable_0, lookuptable_0_ );
182
183 // right size?
184 if ( lookuptable_0_.size() != lookuptable_1_.size() )
185 {
186 throw BadProperty( "Look-up table has not 2^4 entries!" );
187 }
188
189 // are look-up table entries out of bounds?
190 for ( size_t i = 0; i < size_t( lookuptable_0_.size() ); ++i )
191 {
192 if ( lookuptable_0_[ i ] < 0 or lookuptable_0_[ i ] > 15 )
193 {
194 throw BadProperty( "Look-up table entries must be integers in [0,15]" );
195 }
196 }
197 }
198 if ( d.known( names::lookuptable_1 ) )
199 {
200 d.update_value( names::lookuptable_1, lookuptable_1_ );
201
202 // right size?
203 if ( lookuptable_1_.size() != lookuptable_0_.size() )
204 {
205 throw BadProperty( "Look-up table has not 2^4 entries!" );
206 }
207
208 // are look-up table entries out of bounds?
209 for ( size_t i = 0; i < size_t( lookuptable_1_.size() ); ++i )
210 {
211 if ( lookuptable_1_[ i ] < 0 or lookuptable_1_[ i ] > 15 )
212 {
213 throw BadProperty( "Look-up table entries must be integers in [0,15]" );
214 }
215 }
216 }
217 if ( d.known( names::lookuptable_2 ) )
218 {
219 d.update_value( names::lookuptable_2, lookuptable_2_ );
220
221 // right size?
222 if ( lookuptable_2_.size() != lookuptable_0_.size() )
223 {
224 throw BadProperty( "Look-up table has not 2^4 entries!" );
225 }
226
227 // are look-up table entries out of bounds?
228 for ( size_t i = 0; i < size_t( lookuptable_2_.size() ); ++i )
229 {
230 if ( lookuptable_2_[ i ] < 0 or lookuptable_2_[ i ] > 15 )
231 {
232 throw BadProperty( "Look-up table entries must be integers in [0,15]" );
233 }
234 }
235 }
236
237 if ( d.known( names::configbit_0 ) )
238 {
239 d.update_value( names::configbit_0, configbit_0_ );
240
241 // right size?
242 if ( configbit_0_.size() != 4 )
243 {
244 throw BadProperty( "Wrong number of configuration bits (!=4)." );
245 }
246 }
247 if ( d.known( names::configbit_1 ) )
248 {
249 d.update_value( names::configbit_1, configbit_1_ );
250
251 // right size?
252 if ( configbit_1_.size() != 4 )
253 {
254 throw BadProperty( "Wrong number of configuration bits (!=4)." );
255 }
256 }
257 if ( d.known( names::reset_pattern ) )
258 {
259 d.update_value( names::reset_pattern, reset_pattern_ );
260
261 // right size?
262 if ( reset_pattern_.size() != 6 )
263 {
264 throw BadProperty( "Wrong number of reset bits (!=6)." );
265 }
266 }
267}
268
269
270//
271// Implementation of class stdp_facetshw_synapse_hom.
272//
273template < typename targetidentifierT >
275 : weight_( 1.0 )
276 , a_causal_( 0.0 )
277 , a_acausal_( 0.0 )
278 , a_thresh_th_( 21.835 )
279 , a_thresh_tl_( 21.835 ) // exp(-10ms/20ms) * 36SSPs
280 , init_flag_( false )
281 , synapse_id_( 0 )
282 , next_readout_time_( 0.0 )
283 , discrete_weight_( 0 )
284 , t_lastspike_( 0.0 )
285{
286}
287
288template < typename targetidentifierT >
289void
291{
292 // base class properties, different for individual synapse
293 ConnectionBase::get_status( d );
294 d[ names::weight ] = weight_;
295
296 // own properties, different for individual synapse
297 d[ names::a_causal ] = a_causal_;
298 d[ names::a_acausal ] = a_acausal_;
299 d[ names::a_thresh_th ] = a_thresh_th_;
300 d[ names::a_thresh_tl ] = a_thresh_tl_;
301
302 d[ names::init_flag ] = init_flag_;
303 d[ names::synapse_id ] = synapse_id_;
304 d[ names::next_readout_time ] = next_readout_time_;
305 // useful to get conversion before activity, but weight_per_lut_entry_ not
306 // known here
307 // def<unsigned int>(d, "discrete_weight",
308 // entry_to_weight_(weight_to_entry_(weight_,
309 // weight_per_lut_entry_), weight_per_lut_entry_));
310}
311
312template < typename targetidentifierT >
313void
315{
316 // base class properties
317 ConnectionBase::set_status( d, cm );
318 d.update_value( names::weight, weight_ );
319
320 d.update_value( names::a_causal, a_causal_ );
321 d.update_value( names::a_acausal, a_acausal_ );
322 d.update_value( names::a_thresh_th, a_thresh_th_ );
323 d.update_value( names::a_thresh_tl, a_thresh_tl_ );
324
325 d.update_value( names::synapse_id, synapse_id_ );
326
327 // TP: they should not be allowed to be changed! But needed for CopyModel ...
328 d.update_value( names::init_flag, init_flag_ );
329 d.update_value( names::next_readout_time, next_readout_time_ );
330
331 // setting discrete_weight_ does not make sense, is temporary variable
332}
333
334} // of namespace nest
335
336#endif // #ifndef STDP_SYNAPSE_FACETSHW_HOM_IMPL_H
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Exception to be thrown if a status parameter is incomplete or inconsistent.
Definition exceptions.h:680
Class containing the common properties for all connections of a certain type.
Definition common_synapse_properties.h:50
void get_status(Dictionary &d) const
Get all properties and put them into a dictionary.
Definition common_synapse_properties.cpp:47
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties from the values given in dictionary.
Definition common_synapse_properties.cpp:53
Definition connector_model.h:69
void calc_readout_cycle_duration_()
Calculate the readout cycle duration.
Definition stdp_facetshw_synapse_hom_impl.h:120
std::vector< long > configbit_0_
Definition stdp_facetshw_synapse_hom.h:213
std::vector< long > lookuptable_1_
Definition stdp_facetshw_synapse_hom.h:211
std::vector< long > lookuptable_2_
Definition stdp_facetshw_synapse_hom.h:212
double Wmax_
Definition stdp_facetshw_synapse_hom.h:201
double weight_per_lut_entry_
Definition stdp_facetshw_synapse_hom.h:202
std::vector< long > lookuptable_0_
Definition stdp_facetshw_synapse_hom.h:210
std::vector< long > configbit_1_
Definition stdp_facetshw_synapse_hom.h:214
STDPFACETSHWHomCommonProperties()
Default constructor.
Definition stdp_facetshw_synapse_hom_impl.h:40
std::vector< long > reset_pattern_
Definition stdp_facetshw_synapse_hom.h:215
void get_status(Dictionary &d) const
Get all properties and put them into a dictionary.
Definition stdp_facetshw_synapse_hom_impl.h:127
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties from the values given in dictionary.
Definition stdp_facetshw_synapse_hom_impl.h:151
stdp_facetshw_synapse_hom()
Default Constructor.
Definition stdp_facetshw_synapse_hom_impl.h:274
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition stdp_facetshw_synapse_hom_impl.h:290
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition stdp_facetshw_synapse_hom_impl.h:314
const std::string a_thresh_th("a_thresh_th")
const std::string no_synapses("no_synapses")
const std::string lookuptable_0("lookuptable_0")
const std::string reset_pattern("reset_pattern")
const std::string lookuptable_1("lookuptable_1")
const std::string driver_readout_time("driver_readout_time")
const std::string tau_minus_stdp("tau_minus_stdp")
const std::string next_readout_time("next_readout_time")
const std::string a_thresh_tl("a_thresh_tl")
const std::string configbit_0("configbit_0")
const std::string synapse_id("synapse_id")
const std::string synapses_per_driver("synapses_per_driver")
const std::string tau_plus("tau_plus")
const std::string weight("weight")
const std::string configbit_1("configbit_1")
const std::string init_flag("init_flag")
const std::string a_acausal("a_acausal")
const std::string lookuptable_2("lookuptable_2")
const std::string a_causal("a_causal")
const std::string weight_per_lut_entry("weight_per_lut_entry")
const std::string Wmax("Wmax")
const std::string readout_cycle_duration("readout_cycle_duration")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33