Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 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
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
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;
}
103 changes: 0 additions & 103 deletions models/neurons/iaf_psc_delta_neuron.nestml

This file was deleted.

107 changes: 107 additions & 0 deletions models/synapses/stdp_additive_synapse.nestml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# stdp_synapse - Synapse model for spike-timing dependent plasticity
# ##################################################################
#
# XXX: changed this into hard coded multiplicative STDP because SpiNNaker is having difficulty with logk and expk
#
# Description
# +++++++++++
#
# stdp_synapse is a synapse with spike-timing dependent plasticity (as defined in [1]_). Here the weight dependence exponent can be set separately for potentiation and depression. Examples:
#
# =================== ==== =============================
# Multiplicative STDP [2]_ mu_plus = mu_minus = 1
# Additive STDP [3]_ mu_plus = mu_minus = 0
# Guetig STDP [1]_ mu_plus, mu_minus in [0, 1]
# Van Rossum STDP [4]_ mu_plus = 0 mu_minus = 1
# =================== ==== =============================
#
#
# References
# ++++++++++
#
# .. [1] Guetig et al. (2003) Learning Input Correlations through Nonlinear
# Temporally Asymmetric Hebbian Plasticity. Journal of Neuroscience
#
# .. [2] Rubin, J., Lee, D. and Sompolinsky, H. (2001). Equilibrium
# properties of temporally asymmetric Hebbian plasticity, PRL
# 86,364-367
#
# .. [3] Song, S., Miller, K. D. and Abbott, L. F. (2000). Competitive
# Hebbian learning through spike-timing-dependent synaptic
# plasticity,Nature Neuroscience 3:9,919--926
#
# .. [4] van Rossum, M. C. W., Bi, G-Q and Turrigiano, G. G. (2000).
# Stable Hebbian learning from spike timing-dependent
# plasticity, Journal of Neuroscience, 20:23,8812--8821
#
#
# Copyright statement
# +++++++++++++++++++
#
# This file is part of NEST.
#
# Copyright (C) 2004 The NEST Initiative
#
# NEST is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# NEST is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
#
model stdp_synapse:
state:
w real = 1 # Synaptic weight
pre_trace real = 0.
post_trace real = 0.

parameters:
d ms = 1 ms # Synaptic transmission delay
tau_tr_pre ms = 20 ms
tau_tr_post ms = 20 ms
A_POT real = 0.01 # Potentiation factor (LTP)
A_DEP real = 0.0105 # Depression factor (LTD)
eta real = 1. # learning rate
Wmax real = 5.
Wmin real = 0.

equations:
pre_trace' = -pre_trace / tau_tr_pre
post_trace' = -post_trace / tau_tr_post

input:
pre_spikes <- spike
post_spikes <- spike

output:
spike(weight real, delay ms)

onReceive(post_spikes):
post_trace += 1

# potentiate synapse
#w_ real = Wmax * ( w / Wmax + (lambda * ( 1. - ( w / Wmax ) )**mu_plus * pre_trace ))
#w_ real = Wmax * ( w + (lambda * ( 1. - w ) * pre_trace ))
w += eta * A_POT * pre_trace
w = min(Wmax, w)

onReceive(pre_spikes):
pre_trace += 1

# depress synapse
#w_ real = Wmax * ( w / Wmax - ( alpha * lambda * ( w / Wmax )**mu_minus * post_trace ))
#w_ real = Wmax * ( w - ( alpha * lambda * w * post_trace ))
w -= eta * A_DEP * post_trace
w = max(Wmin, w)

# deliver spike to postsynaptic partner
emit_spike(w, d)

update:
integrate_odes()
13 changes: 9 additions & 4 deletions models/synapses/stdp_synapse.nestml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# stdp_synapse - Synapse model for spike-timing dependent plasticity
# ##################################################################
#
# XXX: changed this into hard coded multiplicative STDP because SpiNNaker is having difficulty with logk and expk
#
# Description
# +++++++++++
Expand Down Expand Up @@ -86,15 +87,19 @@ model stdp_synapse:
post_trace += 1

# potentiate synapse
w_ real = Wmax * ( w / Wmax + (lambda * ( 1. - ( w / Wmax ) )**mu_plus * pre_trace ))
w = min(Wmax, w_)
#w_ real = Wmax * ( w / Wmax + (lambda * ( 1. - ( w / Wmax ) )**mu_plus * pre_trace ))
#w_ real = Wmax * ( w + (lambda * ( 1. - w ) * pre_trace ))
w += lambda * pre_trace
w = min(Wmax, w)

onReceive(pre_spikes):
pre_trace += 1

# depress synapse
w_ real = Wmax * ( w / Wmax - ( alpha * lambda * ( w / Wmax )**mu_minus * post_trace ))
w = max(Wmin, w_)
#w_ real = Wmax * ( w / Wmax - ( alpha * lambda * ( w / Wmax )**mu_minus * post_trace ))
#w_ real = Wmax * ( w - ( alpha * lambda * w * post_trace ))
w -= lambda * post_trace
w = max(Wmin, w)

# deliver spike to postsynaptic partner
emit_spike(w, d)
Expand Down
1 change: 1 addition & 0 deletions pynestml/codegeneration/code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def generate_synapses(self, synapses: Sequence[ASTModel]) -> None:
"""
from pynestml.frontend.frontend_configuration import FrontendConfiguration


for synapse in synapses:
self.generate_synapse_code(synapse)
code, message = Messages.get_code_generated(synapse.get_name(), FrontendConfiguration.get_target_path())
Expand Down
Loading
Loading