Debian Codegraph @

brian2/devices/cpp_standalone/templates/spikegenerator.cpp

raw
1 {# USES_VARIABLES { _spikespace, neuron_index, _timebins, _period_bins, _lastindex, t_in_timesteps, N } #}
2 {% extends 'common_group.cpp' %}
3 {% block maincode %}
4
5 const int32_t _the_period = {{_period_bins}};
6 int32_t _timebin = {{t_in_timesteps}};
7 const int32_t _n_spikes = 0;
8
9 if (_the_period > 0) {
10 _timebin %= _the_period;
11 // If there is a periodicity in the SpikeGenerator, we need to reset the
12 // lastindex when the period has passed
13 if ({{_lastindex}} > 0 && {{_timebins}}[{{_lastindex}} - 1] >= _timebin)
14 {{_lastindex}} = 0;
15 }
16
17 int32_t _cpp_numspikes = 0;
18
19 for(size_t _idx={{_lastindex}}; _idx < _num_timebins; _idx++)
20 {
21 if ({{_timebins}}[_idx] > _timebin)
22 break;
23
24 {{_spikespace}}[_cpp_numspikes++] = {{neuron_index}}[_idx];
25 }
26
27 {{_spikespace}}[N] = _cpp_numspikes;
28
29 {{_lastindex}} += _cpp_numspikes;
30
31
32 {% endblock %}