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