Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
73291c4
fix SpiNNaker code generator
clinssen Apr 25, 2025
26562c1
fix SpiNNaker code generator
clinssen Apr 27, 2025
04ba0fb
fix SpiNNaker code generator
clinssen Apr 27, 2025
d5edd93
fix SpiNNaker code generator
clinssen Apr 27, 2025
8794fa6
fix templates to add onCondition block code rendering and emit_spike(…
clinssen May 13, 2025
d215299
add generated code for onReceive blocks
clinssen May 13, 2025
8bfcab5
fix templates to add onCondition block code rendering and emit_spike(…
clinssen May 15, 2025
8e9b7d5
remove make clean step from the build
clinssen May 15, 2025
75b44b7
updated documentation about SpiNNaker code generator
clinssen May 15, 2025
2fa9a2c
clean up SpiNNaker template
clinssen May 15, 2025
562e305
Merge remote-tracking branch 'upstream/master' into fix_spinnaker_cod…
clinssen May 27, 2025
f13aba4
update spinnaker builder with new APLX filename
clinssen Jun 2, 2025
f2ff683
workaround for SpiNNaker core mapping
clinssen Jun 3, 2025
ea9d095
Merge remote-tracking branch 'upstream/master' into fix_spinnaker_cod…
clinssen Jun 3, 2025
8a91413
clean up SpiNNaker apptainer definition file
clinssen Jun 3, 2025
19eaf9e
spinnaker stdp support
mottenmann99 Jun 12, 2025
8bcee6f
Merge remote-tracking branch 'upstream/master' into stdp_support
mottenmann99 Jun 12, 2025
b5bb5d4
added stdp specific test
mottenmann99 Jun 12, 2025
3d1e1eb
Merge remote-tracking branch 'mottenmann99/stdp_support' into fix_spi…
clinssen Jun 12, 2025
8de52ab
fix spinnaker stdp synapse code generation
clinssen Jun 12, 2025
7b7e3aa
changed synapse jinja template temporary
mottenmann99 Jun 19, 2025
ee0a626
fix SpiNNaker synapse code generation
clinssen Jun 19, 2025
266d751
Merge remote-tracking branch 'clinssen/spinnaker_stdp' into stdp_support
mottenmann99 Jun 19, 2025
4a58ed0
empty variable printed fix
mottenmann99 Jul 3, 2025
735a171
allow empty blocks in synapse model
clinssen Jul 3, 2025
f0b6db4
fix printing of the pow() function
clinssen Jul 3, 2025
c0517f1
added stdp to test file
mottenmann99 Jul 10, 2025
429bc6a
Merge remote-tracking branch 'upstream/master' into stdp_support
clinssen Jul 10, 2025
7707906
changes in synapse python jinja files
mottenmann99 Jul 15, 2025
313fc7d
Merge remote-tracking branch 'mottenmann99/stdp_support' into stdp_su…
clinssen Jul 15, 2025
25a8377
Temporary using sPyNNaker weight and timing dependance for STDP
mottenmann99 Jul 28, 2025
05ca21e
change time and weight dependencies within neuron makefile for testin…
mottenmann99 Jul 29, 2025
59ab646
Merge remote-tracking branch 'upstream/master' into stdp_support
clinssen Jul 29, 2025
f09b965
enable projection
clinssen Jul 29, 2025
d6760d4
Merge remote-tracking branch 'mottenmann99/stdp_support' into stdp_su…
clinssen Jul 29, 2025
4826560
clean up weight and timing dependence
clinssen Jul 29, 2025
43842f0
STDP updates
clinssen Aug 1, 2025
82c5de1
STDP updates
clinssen Aug 6, 2025
34ceab7
STDP support
clinssen Aug 6, 2025
f1a1e9c
STDP support
clinssen Aug 6, 2025
8464086
STDP support
clinssen Aug 12, 2025
50ddb1d
STDP support
clinssen Aug 14, 2025
18965bf
STDP support
clinssen Aug 14, 2025
f19510a
STDP updates: conversion between synapse_state_t and synapse_word_t
clinssen Aug 15, 2025
37149ea
STDP support
clinssen Aug 19, 2025
dba1f93
STDP support
clinssen Aug 19, 2025
3ddacb8
STDP support
clinssen Aug 20, 2025
e7ffc59
STDP support
clinssen Aug 20, 2025
bb499a5
STDP support -- all state and parameters in Q15.16; parameters have t…
clinssen Aug 25, 2025
f5145b3
STDP support
clinssen Aug 25, 2025
4ee8874
getting the right parameter values inside synapse but new state isn't…
clinssen Aug 26, 2025
7dd665a
before post trace processing
clinssen Aug 29, 2025
633da77
STDP support: main synapse integration loop like NEST
clinssen Aug 30, 2025
715279b
STDP support: post trace working
clinssen Sep 1, 2025
882a143
STDP support: variable integration timestep in synapse analytic solver
clinssen Sep 2, 2025
5dd0f57
first working STDP window
clinssen Sep 4, 2025
7292442
add PSP test script
clinssen Oct 23, 2025
867c6d2
add PSP test script
clinssen Oct 23, 2025
32d7eb9
fix STDP PSP test
clinssen Oct 31, 2025
d401daa
add min/max to STDP synapse weight
clinssen Nov 2, 2025
aee7eec
add distribution test
clinssen Nov 2, 2025
b117025
add STDP additive synapse
clinssen Nov 2, 2025
35d9a22
spinnaker stdp
Nov 2, 2025
e1822d3
spinnaker stdp
Nov 2, 2025
6c56798
spinnaker stdp
clinssen Nov 3, 2025
31f16f5
issue with no PSPs in stdp_distribution test
clinssen Nov 7, 2025
94cca39
fix synapse PSP test
clinssen Nov 10, 2025
3dff39e
fixed post ports for different neuron model; still issue with incorre…
clinssen Nov 11, 2025
5e81f4e
fix neuron with static synapse code generation
clinssen Nov 25, 2025
4f20045
synapse work-in-progress to remove genmatrix
clinssen Nov 26, 2025
9525754
improved getting of numerical initial values
Nov 27, 2025
25c24f5
fix neuron code generation
clinssen Nov 27, 2025
a4c76c5
fix neuron code generation
clinssen Nov 27, 2025
a701448
add test for ignore_and_fire_neuron on SpiNNaker
clinssen Dec 1, 2025
1790434
Merge remote-tracking branch 'upstream/master' into stdp_support
clinssen Jan 29, 2026
9f9d7e2
update tests to new API for spinnaker code generation
clinssen Jan 29, 2026
4ce0e97
Merge remote-tracking branch 'upstream/master' into stdp_support
Jan 29, 2026
0e89594
Merge remote-tracking branch 'clinssen/stdp_support' into stdp_support
Jan 29, 2026
4737d2b
right-hand side of the STDP window
clinssen Feb 6, 2026
5d2421d
fixed/float conversion of state works but neuron needs ignore port
clinssen Feb 7, 2026
fb47075
fixed STDP window
clinssen Feb 7, 2026
dccd7fa
fix STDP synapse on SpiNNaker (except for factor of 2)
clinssen Feb 9, 2026
eb4e32a
STDP synapse on SpiNNaker
clinssen Feb 11, 2026
720b41b
first steps for pre-transformer
Feb 12, 2026
be2a34b
post transformer cleanup
Feb 12, 2026
b30cec1
Merge branch 'post-transformer-cleanup' into stdp_support
Feb 13, 2026
1fdb348
post transformer cleanup
Feb 15, 2026
ee5b084
Merge branch 'post-transformer-cleanup' into stdp_support
Feb 15, 2026
c5170b0
clean up
Feb 15, 2026
18bbe30
post transformer cleanup
Feb 15, 2026
a106709
post transformer cleanup
Feb 15, 2026
90aade6
Merge branch 'post-transformer-cleanup' into stdp_support
Feb 15, 2026
9b682eb
post transformer cleanup
Feb 15, 2026
eebd95e
Merge branch 'post-transformer-cleanup' into stdp_support
Feb 15, 2026
d7c69f2
STDP synapse on SpiNNaker
Feb 17, 2026
cd2b183
Merge remote-tracking branch 'upstream/master' into stdp_support
Feb 17, 2026
b316a7b
changes to transformers
Feb 19, 2026
7074867
change NESTML units printing to include a space
Feb 19, 2026
7b0c37b
Merge remote-tracking branch 'clinssen/units_printer' into stdp_support
Feb 19, 2026
2252989
Merge remote-tracking branch 'upstream/master' into post-transformer-…
Feb 25, 2026
d101073
use metadata to store transformer results rather than setting propert…
Feb 28, 2026
59e5ab2
use metadata to store transformer results rather than setting propert…
Feb 28, 2026
293bb19
Merge remote-tracking branch 'clinssen/post-transformer-cleanup' into…
Mar 1, 2026
160e8ea
use metadata to store transformer results rather than setting propert…
Mar 1, 2026
7f5312f
Merge remote-tracking branch 'upstream/master' into post-transformer-…
Mar 2, 2026
22e4607
Merge remote-tracking branch 'clinssen/post-transformer-cleanup' into…
Mar 2, 2026
267ae7a
post transformer cleanup
Mar 2, 2026
684a9c6
post transformer cleanup
Mar 2, 2026
ba821e7
Merge remote-tracking branch 'clinssen/post-transformer-cleanup' into…
Mar 2, 2026
23dd23d
post transformer cleanup
Mar 2, 2026
b229d88
Merge remote-tracking branch 'upstream/master' into post-transformer-…
Mar 3, 2026
9e2e327
post transformer cleanup: remove _is_post_port ad-hoc property
Mar 3, 2026
d73c5d7
Merge remote-tracking branch 'upstream/main' into post-transformer-cl…
Mar 13, 2026
e45f69a
Merge remote-tracking branch 'upstream/main' into post-transformer-cl…
Mar 19, 2026
67981ad
Merge remote-tracking branch 'clinssen/post-transformer-cleanup' into…
Mar 19, 2026
bccb68d
add docstring about metadata
Mar 19, 2026
d58cffa
Merge remote-tracking branch 'clinssen/post-transformer-cleanup' into…
Mar 19, 2026
fb7670a
make metadata a required parameter; require transformers to work on l…
Mar 20, 2026
0e62a2e
synapse code generation for SpiNNaker
Mar 20, 2026
aee36e5
Merge remote-tracking branch 'clinssen/post-transformer-cleanup' into…
Mar 20, 2026
e5ba2a2
make metadata a required parameter
Mar 20, 2026
831e049
Merge remote-tracking branch 'clinssen/post-transformer-cleanup' into…
Mar 20, 2026
b6ba09b
synapse code generation for SpiNNaker: work in progress on the synaps…
Mar 21, 2026
bdd8c52
Merge remote-tracking branch 'upstream/main' into stdp_support
Mar 23, 2026
8514c87
synapse code generation for SpiNNaker: work in progress on the synaps…
Mar 23, 2026
1f0727a
synapse code generation for SpiNNaker: work in progress on the synaps…
Mar 23, 2026
942fcd3
synapse post transformer wip ??
Apr 3, 2026
e43d610
Merge remote-tracking branch 'upstream/main' into stdp_support
Apr 6, 2026
e435893
add SpiNNaker STDP support
clinssen Apr 6, 2026
5d5c579
fix and add test for synapse post transformer
Apr 6, 2026
dae7dd0
add SpiNNaker STDP support
clinssen Apr 6, 2026
2b23473
refactor ODE-toolbox-transformer from code generator
Apr 8, 2026
56f59bf
Merge remote-tracking branch 'upstream/main' into ode-tb-transformer
Apr 8, 2026
321b35d
wip
clinssen Apr 8, 2026
724db8d
Merge remote-tracking branch 'upstream/main' into stdp_support
clinssen Apr 8, 2026
67d7b95
Merge remote-tracking branch 'clinssen/ode-tb-transformer' into stdp_…
clinssen Apr 8, 2026
3e0609d
refactor ODE-toolbox-transformer from code generator
Apr 8, 2026
018996d
refactor ODE-toolbox-transformer from code generator
Apr 9, 2026
12c1796
refactor ODE-toolbox-transformer from code generator
Apr 9, 2026
6aa636e
refactor ODE-toolbox-transformer from code generator
Apr 9, 2026
3c0283f
refactor ODE-toolbox-transformer from code generator
Apr 9, 2026
21e5497
refactor ODE-toolbox-transformer from code generator
Apr 9, 2026
755800b
refactor ODE-toolbox-transformer from code generator
Apr 9, 2026
4eb8936
refactor ODE-toolbox-transformer from code generator
Apr 9, 2026
ab77b00
Merge remote-tracking branch 'clinssen/ode-tb-transformer' into stdp_…
Apr 9, 2026
d754ed7
refactor ODE-toolbox-transformer from code generator
Apr 9, 2026
c4b2c06
Merge remote-tracking branch 'clinssen/ode-tb-transformer' into stdp_…
Apr 9, 2026
946811e
separate ODE-toolbox neuron header processing
clinssen Apr 9, 2026
79f10e9
Merge remote-tracking branch 'clinssen/stdp_support' into stdp_support
clinssen Apr 9, 2026
ad11cfc
add SpiNNaker STDP support
Apr 9, 2026
1f66077
add SpiNNaker STDP support
Apr 9, 2026
10cb0dd
Merge remote-tracking branch 'clinssen/stdp_support' into stdp_support
Apr 9, 2026
7e740eb
add SpiNNaker STDP support
clinssen Apr 9, 2026
fc0d721
add SpiNNaker STDP support
Apr 9, 2026
3d8d0d6
Merge remote-tracking branch 'clinssen/stdp_support' into stdp_support
Apr 9, 2026
8197e18
synapse-pre-transformer basically working
Apr 10, 2026
36acb93
Merge remote-tracking branch 'upstream/main' into stdp_support
Apr 14, 2026
0177317
fix SpiNNaker bug with ordering of variables
clinssen Apr 14, 2026
66aa8aa
add SpiNNaker STDP support
clinssen Apr 17, 2026
44e80e5
test_spinnaker_stdp_psp.py passes
clinssen Apr 18, 2026
156d8fa
fix iaf_psc_exp test
clinssen Apr 28, 2026
cc36bd0
add spinnaker stdp support
clinssen Jun 25, 2026
0e452e2
Merge remote-tracking branch 'upstream/main' into stdp_support
Jun 25, 2026
f162f38
fix n_header_words bug
clinssen Jun 29, 2026
9ab160b
add spinnaker stdp support
clinssen Jul 6, 2026
cd4b3da
Merge remote-tracking branch 'upstream/main' into stdp_support
clinssen Jul 6, 2026
b968ac2
fix pre trace to header transformer
clinssen Jul 6, 2026
b7b817c
split SynapsePreNeuronTransformer into pre and post headers
Jul 7, 2026
30eda58
add support for post history trace buffers
Jul 8, 2026
b7c0fe2
Merge remote-tracking branch 'clinssen/stdp_support' into stdp_support
clinssen Jul 8, 2026
820411c
add support for post history trace buffers
Jul 8, 2026
8034c50
fixes after turning off post transformer
clinssen Jul 8, 2026
0f55ae3
fix namespace issue
clinssen Jul 8, 2026
7e511e2
fix writeback for synapse weights
clinssen Jul 9, 2026
ea00bef
Merge remote-tracking branch 'upstream/main' into stdp_support
clinssen Jul 14, 2026
36d3319
add spinnaker-target
clinssen Jul 18, 2026
7f8ae24
working post history buffer
clinssen Jul 19, 2026
055185d
working post history buffer
clinssen Jul 19, 2026
bf8931c
add manual installation instructions to docs
Jul 20, 2026
0dc3a0f
Merge remote-tracking branch 'clinssen/stdp_support' into stdp_support
Jul 20, 2026
35db5b1
Merge remote-tracking branch 'upstream/main' into stdp_support
Jul 20, 2026
453173e
Merge remote-tracking branch 'upstream/main' into stdp_support
Jul 22, 2026
7aa6624
fixes after merge
clinssen Jul 22, 2026
2d804d0
fixes after merge
clinssen Jul 22, 2026
9e19c3b
clean up ignore_and_fire test
clinssen Jul 22, 2026
6464d8d
fix whitespace
clinssen Jul 23, 2026
bdd6eaa
fix STDP synapse test
clinssen Jul 25, 2026
97ec196
add spinnaker stdp support
Jul 26, 2026
1185bf0
Merge remote-tracking branch 'clinssen/stdp_support' into stdp_support
Jul 26, 2026
488d846
add spinnaker stdp support
Jul 26, 2026
cd73da8
update weight types
Aug 18, 2026
33f9268
updates for latest SpiNNaker development version
clinssen Aug 18, 2026
0cc0f70
add spinnaker stdp support
clinssen Aug 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
nestml_python_target*
spinnaker-target*
spinnaker-install*
*_BACKUP_*
*_BASE_*
*_LOCAL_*
*_REMOTE_*
*.orig
*.save
.settings/
target/
.idea/
Expand Down
115 changes: 109 additions & 6 deletions doc/running/running_spinnaker.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
SpiNNaker target
----------------

*NESTML features supported:* :doc:`neurons </nestml_language/neurons_in_nestml>`
*NESTML features supported:* :doc:`neurons </nestml_language/neurons_in_nestml>`, :doc:`synapses </nestml_language/synapses_in_nestml>`

.. warning::

SpiNNaker support is in an early stage of development. Expect missing features and bugs. If you want to use or contribute to this target, please reach out to the developers via GitHub or the NEST-users mailing list.

Introduction
~~~~~~~~~~~~

SpiNNaker [FB20]_ was first publicly mentioned in 1998. It is a neuromorphic architecture based on ARM microprocessors connected into a network. The project emerged from the research question of efficiently integrating associative memory in Very Large Scale Integration (VLSI) architectures. After some research, it was clear that the architecture would come down to a neuromorphic architecture. Earlier implementations mainly focused on analog implementations of neurons and synapses combined with digital communication, However, Furber's previous involvement with ARM and asynchronous digital circuits led to a design based on ARM microprocessors implementing the model and network details in software. As mentioned in the introduction to neuromorphic computing, handling many communication messages is a challenge. Following the biological example is hard to achieve, as to be generally applicable would mean building a physical connection between each neuron, which apart from spatial problems also hinders scalability. This was previously solved by using a bus system with, compared to biological spikes, short digital messages encoding a unique address of the source neuron as the spike. Because of the short pulse, spikes generated simultaneously can be serialized without breaking the concepts found in nature. This protocol is called Address Event Representation (AER [Mah92]_). Each spike is a broadcast message on the bus, where
each neuron determines if it should receive the spike through the address of the source neuron [Mah92]_.
SpiNNaker [FB20]_ was first publicly mentioned in 1998. It is a neuromorphic architecture based on ARM microprocessors connected into a network. The project emerged from the research question of efficiently integrating associative memory in Very Large Scale Integration (VLSI) architectures. After some research, it was clear that the architecture would come down to a neuromorphic architecture. Earlier implementations mainly focused on analog implementations of neurons and synapses combined with digital communication, However, Furber's previous involvement with ARM and asynchronous digital circuits led to a design based on ARM microprocessors implementing the model and network details in software. As mentioned in the introduction to neuromorphic computing, handling many communication messages is a challenge. Following the biological example is hard to achieve, as to be generally applicable would mean building a physical connection between each neuron, which apart from spatial problems also hinders scalability. This was previously solved by using a bus system with, compared to biological spikes, short digital messages encoding a unique address of the source neuron as the spike. Because of the short pulse, spikes generated simultaneously can be serialized without breaking the concepts found in nature. This protocol is called Address Event Representation (AER [Mah92]_). Each spike is a broadcast message on the bus, where each neuron determines if it should receive the spike through the address of the source neuron [Mah92]_.

As this solution uses a single bus, the scalability of the system is dependent on the bus throughput. This let the team around SpiNNaker to switch from a bus system to a packet-switched network, where packets can be routed to specified targets. Instead of being bound to the fixed specification of bus throughput, this now also allows scaling the network capacity by adding more routers. They call this Multicast Packet-Switched AER. With this architecture, they were able to achieve a system with 1 million processors called SpiNNaker1M. All information about SpiNNaker presented in this chapter comes from the book "SpiNNaker: A Spiking Neural Network Architecture" [FB20]_.

Expand All @@ -21,9 +24,46 @@ Generating code

.. code-block:: bash

apptainer build spinnaker-apptainer.sif spinnaker-apptainer.def
apptainer build spinnaker-apptainer.sif spinnaker-apptainer.def
apptainer overlay create --size 4096 spinnaker-overlay.img

Note that for now, the sPyNNaker codebase needs to be manually edited to remove the checks in ``/home/spinnaker/source/sPyNNaker/neural_modelling/makefiles/synapse_only/synapse_build.mk`` on lines 99-104 (see https://github.com/SpiNNakerManchester/sPyNNaker/pull/1679):

.. code-block::

diff --git a/neural_modelling/makefiles/synapse_only/synapse_build.mk b/neural_modelling/makefiles/synapse_only/synapse_build.mk
index b6bfaffa29..004250ecff 100644
--- a/neural_modelling/makefiles/synapse_only/synapse_build.mk
+++ b/neural_modelling/makefiles/synapse_only/synapse_build.mk
@@ -96,12 +96,6 @@ else
ifneq ($(SYNAPSE_DYNAMICS), $(SYNAPSE_DYNAMICS_STATIC))
STDP_ENABLED = 1

- ifndef TIMING_DEPENDENCE_H
- $(error TIMING_DEPENDENCE_H is not set which is required when SYNAPSE_DYNAMICS ($(SYNAPSE_DYNAMICS_C)) != $(SYNAPSE_DYNAMICS_STATIC))
- endif
- ifndef WEIGHT_DEPENDENCE_H
- $(error WEIGHT_DEPENDENCE_H is not set which is required when SYNAPSE_DYNAMICS ($(SYNAPSE_DYNAMICS_C)) != $(SYNAPSE_DYNAMICS_STATIC))
- endif
endif
endif

@@ -205,8 +199,10 @@ endif

#STDP Build rules If and only if STDP used
ifeq ($(STDP_ENABLED), 1)
- STDP_INCLUDES:= -include $(WEIGHT_DEPENDENCE_H) -include $(TIMING_DEPENDENCE_H)
- STDP_COMPILE = $(CC) -DLOG_LEVEL=$(PLASTIC_DEBUG) $(CFLAGS) -DSTDP_ENABLED=$(STDP_ENABLED) -DSYNGEN_ENABLED=$(SYNGEN_ENABLED) $(STDP_INCLUDES)

+ #STDP_INCLUDES:= -include $(WEIGHT_DEPENDENCE_H) -include $(TIMING_DEPENDENCE_H)
+ #STDP_INCLUDES:= -include $(WEIGHT_DEPENDENCE_H) -include $(TIMING_DEPENDENCE_H)
+ #STDP_COMPILE = $(CC) -DLOG_LEVEL=$(PLASTIC_DEBUG) $(CFLAGS) -DSTDP_ENABLED=$(STDP_ENABLED) -DSYNGEN_ENABLED=$(SYNGEN_ENABLED) $(STDP_INC
LUDES)
+ STDP_COMPILE = $(CC) -DLOG_LEVEL=$(PLASTIC_DEBUG) $(CFLAGS) -DSTDP_ENABLED=$(STDP_ENABLED) -DSYNGEN_ENABLED=$(SYNGEN_ENABLED)

$(SYNAPSE_DYNAMICS_O): $(SYNAPSE_DYNAMICS_C)
# SYNAPSE_DYNAMICS_O stdp

3. Run the Apptainer image:

.. code-block:: bash
Expand Down Expand Up @@ -61,6 +101,22 @@ Generating code

PYTHONPATH=$HOME/nestml/spinnaker-install python3 -m pytest -s --pdb ./tests/spinnaker_tests/test_spinnaker_iaf_psc_exp.py

Optionally, create a little helper script to run the test anew (replace ``USERNAME`` with your username):

.. code-block:: bash

#!/bin/bash

cd $HOME/nestml

mv -v /users/USERNAME/nestml/spinnaker-target /users/USERNAME/nestml/spinnaker-target-$(date +%Y-%m-%d_%H-%M-%S.%N | cut -b1-23)
mv -v /users/USERNAME/nestml/spinnaker-install /users/USERNAME/nestml/spinnaker-install-$(date +%Y-%m-%d_%H-%M-%S.%N | cut -b1-23)

# need to create this directory first, otherwise it gets ignored in the PYTHONPATH!
mkdir /users/USERNAME/nestml/spinnaker-install

PATH=$PATH:/users/USERNAME/.local/bin PYTHONPATH=/users/USERNAME/nestml/spinnaker-install:$PYTHONPATH python3 -m pytest -o log_cli=true -o log_cli_level="DEBUG" -s --pdb /home/nestml/tests/spinnaker_tests/test_spinnaker_iaf_psc_exp.py


Data types
^^^^^^^^^^
Expand All @@ -69,6 +125,53 @@ Data types
- The NESTML data type ``integer`` will be rendered as ``int32_t``.


Code generation for synapses
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Synaptic and neuronal models should ideally be formulated independently of each other, so that each neuron can be combined with each synapse for maximum flexibility. When a synaptic plasticity rule (such as STDP) is formulated as a computational model, the plasticity rule is often expressed as a function of the timing of pre- and postsynaptic spikes, which are used in the dynamics of the weight update for that particular rule. Note that as each neuron is typically connected to hundreds or thousands of other neurons via synapses on its axon, each of those synapses will observe the same presynaptic spike times, and store and numerically integrate them in exactly the same way, causing a very large redundancy in memory and computation.

To prevent this redundancy, these values should only be stored and computed once. To achieve this, during code generation, state variables that depend only on presynaptic spike timing are automatically identified and moved from the NESTML synapse model into a header section in the synaptic row by the toolchain. In the generated code, at the points where the respective variables are used by the synapse (for instance, where they are used in calculating the change in synaptic strength), the variable references are replaced by function calls into the necessary memory space (more precisely, the header words at the start of each row). All parameters that are only used by these presynaptic dynamics (for instance, time constants) are also moved to reduce the memory requirements for the synapse. Detecting and moving the state, parameters, and dynamics (ODEs) from synapse to neuron is carried out fully autonomously. We refer to this feature as the "co-generation" of neuron and synapse. It enables flexibility and separation of concerns in the model formalisations without compromising on performance.

When NESTML is invoked to generate code for plastic synapses, the (neuron, synapse) pairs can be specified as a list of two-element dictionaries of the form :code:`{"neuron": "neuron_model_name", "synapse": "synapse_model_name"}`. Additionally, if the synapse requires it, specify the ``"post_ports"`` entry to connect the postsynaptic spiking input port on the synapse with the postsynaptic neuron. For example:

.. code-block:: python

generate_target(...,
codegen_opts={...,
"neuron_synapse_pairs": [{"neuron": "iaf_psc_exp_neuron",
"synapse": "stdp_synapse"
"post_ports": ["post_spikes"]}]})


Use cases/examples
~~~~~~~~~~~~~~~~~~

Ignore-and-fire neuron
^^^^^^^^^^^^^^^^^^^^^^

...


STDP synapse
^^^^^^^^^^^^

Additive STDP model.

.. figure:: https://raw.githubusercontent.com/nest/nestml/master/doc/running/running_spinnaker_figs/stdp_window.png
:alt: Comparison between STDP window functions based on SpiNNaker simulation (orange crosses) and hand-coded Python "ground truth" simulation.


Troubleshooting
~~~~~~~~~~~~~~~

The build process and simulation produce many log messages, so it can be hard to find the reason for a failing build.

::
/home/dev/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /users/.../nestml/spinnaker-install/c_models/build/iaf_psc_exp_neuron_nestml_impl/iaf_psc_exp_neuron_nestml_impl.elf section `RO_DATA' will not fit in region `ITCM'

This error means that the compiled code does not fit into the ITCM memory. Typically this is due to too many logging statements; try commenting out logging statements.


Further reading
~~~~~~~~~~~~~~~

Expand All @@ -78,6 +181,6 @@ Levin Schmidt, "Extension of the NEST Modelling Language to the SpiNNaker Archit
References
~~~~~~~~~~

.. [Mah92] M. Mahowald. VLSI analogs of neuronal visual processing: a synthesis of form and function. 1992
.. [Mah92] M. Mahowald. VLSI analogs of neuronal visual processing: a synthesis of form and function. California Institute of Technology, 1992

.. [FB20] S. Furber and P. Bogdan. SpiNNaker: A Spiking Neural Network Architecture. Boston-Delft: now publishers, 2020
.. [FB20] S. Furber and P. Bogdan. SpiNNaker: A Spiking Neural Network Architecture. Emerald Publishing Limited, 2020
104 changes: 104 additions & 0 deletions extras/q15.16_to_string.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>

/**
* @brief Converts a 32-bit Q15.16 fixed-point number to a decimal string.
*
* This function extracts the sign, integer, and fractional parts of the Q15.16
* number without using floating-point arithmetic. It then constructs a string
* representation.
*
* @param q_num The 32-bit Q15.16 fixed-point number.
* @param buffer A character buffer to store the resulting string.
* @param buffer_size The size of the buffer.
*/
void q15_16_to_string(int32_t q_num, char *buffer, size_t buffer_size) {
if (buffer == NULL || buffer_size == 0) {
return;
}

// Determine the sign and work with the absolute value for calculations.
// The sign bit is the MSB (bit 31)
int is_negative = (q_num < 0);
if (is_negative) {
q_num = -q_num;
}

// Extract the integer part by right-shifting by 16 bits.
// The integer part occupies bits 16 to 30 (15 bits)
int32_t integer_part = q_num >> 16;

// Extract the fractional part by masking the lower 16 bits.
// The fractional part occupies bits 0 to 15 (16 bits)
int32_t fractional_part = q_num & 0xFFFF;

// To convert the fractional part to a decimal string without floats, we
// treat it as a fraction of 2^16 (65536).
// For example, if the fractional part is 32768, the value is 32768/65536 = 0.5.
// To get a decimal string with, say, 5 digits, we multiply by 10^5 and
// then divide by 65536, using a 64-bit integer to avoid overflow.
// The fractional part will be (fractional_part * 100000) / 65536.
int64_t decimal_fraction = ((int64_t)fractional_part * 100000 + 32768) >> 16;
// We add 32768 (0.5 * 65536) for rounding before the bit shift, which is
// equivalent to division. This is a common fixed-point rounding technique.

// Start printing the string.
char *ptr = buffer;
if (is_negative) {
*ptr++ = '-';
}

// Print the integer part.
ptr += snprintf(ptr, buffer_size - (ptr - buffer), "%d.", integer_part);

// Print the fractional part with leading zeros to maintain precision.
snprintf(ptr, buffer_size - (ptr - buffer), "%05lld", (long long)decimal_fraction);
}

/**
* @brief Main function to demonstrate the conversion.
*/
int main() {
// Test cases for various Q15.16 numbers
// 1. A positive number: 10.5
// 10 << 16 = 655360
// 0.5 * 2^16 = 0.5 * 65536 = 32768 = 0x8000
// 10.5 = (10 << 16) + 32768 = 688128 = 0xA8000
int32_t q_positive = 688128;

// 2. A negative number: -2.75
// 2 << 16 = 131072
// 0.75 * 2^16 = 0.75 * 65536 = 49152 = 0xC000
// -2.75 = - (131072 + 49152) = -180224 = -0x2C000
int32_t q_negative = -180224;

// 3. A small number: 0.001
// 0.001 * 2^16 = 0.001 * 65536 = 65.536 -> round to 66
int32_t q_small = 66;

// 4. A large number: 30000.12345
// 30000 << 16 = 1966080000
// 0.12345 * 2^16 = 8090.88 -> round to 8091 = 0x1F9B
// 1966080000 + 8091 = 1966088091 = 0x75231F9B
int32_t q_large = 1966088091;

// Buffer to hold the resulting strings
char result_buffer[50];

// Convert and print each number
q15_16_to_string(q_positive, result_buffer, sizeof(result_buffer));
printf("Q15.16 value 0x%X -> %s\n", q_positive, result_buffer);

q15_16_to_string(q_negative, result_buffer, sizeof(result_buffer));
printf("Q15.16 value 0x%X -> %s\n", q_negative, result_buffer);

q15_16_to_string(q_small, result_buffer, sizeof(result_buffer));
printf("Q15.16 value 0x%X -> %s\n", q_small, result_buffer);

q15_16_to_string(q_large, result_buffer, sizeof(result_buffer));
printf("Q15.16 value 0x%X -> %s\n", q_large, result_buffer);

return 0;
}
Loading