HALDLS
neuron.h
Go to the documentation of this file.
1 #pragma once
2 #include "halco/hicann-dls/vx/v2/coordinates.h"
3 #include "halco/hicann-dls/vx/v2/neuron.h"
4 #include "haldls/vx/genpybind.h"
5 #include "haldls/vx/neuron.h"
6 
7 #ifndef __ppu__
8 #include "haldls/cerealization.h"
9 #endif
10 
11 namespace fisch::vx {
12 class OmnibusChipOverJTAG;
13 class Omnibus;
14 } // namespace fisch::vx
15 
16 namespace haldls::vx {
17 NEURON_EXTERN_TEMPLATE(halco::hicann_dls::vx::v2::Coordinates)
18 } // namespace haldls::vx
19 
21 
23 using NeuronBackendConfig GENPYBIND(opaque) =
25 using NeuronReset GENPYBIND(visible) = haldls::vx::NeuronReset;
26 using BlockPostPulse GENPYBIND(visible) = haldls::vx::BlockPostPulse;
31 
32 /*
33  * Container for configuration of (digital) neuron parameters.
34  */
35 class GENPYBIND(visible) NeuronConfig : public DifferentialWriteTrait
36 {
37 public:
38  typedef halco::hicann_dls::vx::v2::NeuronConfigOnDLS coordinate_type;
39  typedef std::true_type is_leaf_node;
40 #ifndef __ppu__
41  constexpr static auto unsupported_read_targets GENPYBIND(hidden) = {
42  hxcomm::vx::Target::simulation};
43 #endif
44 
46  enum class ReadoutSource : uint_fast8_t
47  {
48  membrane = 0b00,
49  exc_synin = 0b01,
50  inh_synin = 0b10,
51  adaptation = 0b11
52  };
53 
55  struct GENPYBIND(inline_base("*")) MembraneCapacitorSize
56  : public halco::common::detail::RantWrapper<MembraneCapacitorSize, uint_fast8_t, 63, 0>
57  {
58  constexpr explicit MembraneCapacitorSize(uintmax_t const val = 0)
59  GENPYBIND(implicit_conversion) :
60  rant_t(val)
61  {}
62  };
63 
65  NeuronConfig() SYMBOL_VISIBLE;
66 
67  // accessors
68 
69  // divide inter-compartment conductance bias by 4
70  GENPYBIND(getter_for(enable_divide_multicomp_conductance_bias))
71  bool get_enable_divide_multicomp_conductance_bias() const SYMBOL_VISIBLE;
72  GENPYBIND(setter_for(enable_divide_multicomp_conductance_bias))
73  void set_enable_divide_multicomp_conductance_bias(bool value) SYMBOL_VISIBLE;
74 
75  // multiply inter-compartment conductance bias by 4
76  GENPYBIND(getter_for(enable_multiply_multicomp_conductance_bias))
77  bool get_enable_multiply_multicomp_conductance_bias() const SYMBOL_VISIBLE;
78  GENPYBIND(setter_for(enable_multiply_multicomp_conductance_bias))
79  void set_enable_multiply_multicomp_conductance_bias(bool value) SYMBOL_VISIBLE;
80 
81  // connect local membrane to soma
82  GENPYBIND(getter_for(connect_soma))
83  bool get_connect_soma() const SYMBOL_VISIBLE;
84  GENPYBIND(setter_for(connect_soma))
85  void set_connect_soma(bool value) SYMBOL_VISIBLE;
86 
87  // connect local membrane to membrane on right
88  GENPYBIND(getter_for(connect_membrane_right))
89  bool get_connect_membrane_right() const SYMBOL_VISIBLE;
90  GENPYBIND(setter_for(connect_membrane_right))
91  void set_connect_membrane_right(bool value) SYMBOL_VISIBLE;
92 
93  // enable inter-compartment conductance
94  GENPYBIND(getter_for(enable_multicomp_conductance))
95  bool get_enable_multicomp_conductance() const SYMBOL_VISIBLE;
96  GENPYBIND(setter_for(enable_multicomp_conductance))
97  void set_enable_multicomp_conductance(bool value) SYMBOL_VISIBLE;
98 
99  // connect local membrane to bottom membrane
100  GENPYBIND(getter_for(connect_bottom))
101  bool get_connect_bottom() const SYMBOL_VISIBLE;
102  GENPYBIND(setter_for(connect_bottom))
103  void set_connect_bottom(bool value) SYMBOL_VISIBLE;
104 
105  // connect soma to soma on the right
106  GENPYBIND(getter_for(connect_soma_right))
107  bool get_connect_soma_right() const SYMBOL_VISIBLE;
108  GENPYBIND(setter_for(connect_soma_right))
109  void set_connect_soma_right(bool value) SYMBOL_VISIBLE;
110 
111  // enable fire output of neuron (also gates bypass circuits)
112  GENPYBIND(getter_for(enable_fire))
113  bool get_enable_fire() const SYMBOL_VISIBLE;
114  GENPYBIND(setter_for(enable_fire))
115  void set_enable_fire(bool value) SYMBOL_VISIBLE;
116 
117  // increase the strength of the neuron's fire pulse
118  GENPYBIND(getter_for(enable_strong_fire))
119  bool get_enable_strong_fire() const SYMBOL_VISIBLE;
120  GENPYBIND(setter_for(enable_strong_fire))
121  void set_enable_strong_fire(bool value) SYMBOL_VISIBLE;
122 
123  // enable threshold comparator
124  GENPYBIND(getter_for(enable_threshold_comparator))
125  bool get_enable_threshold_comparator() const SYMBOL_VISIBLE;
126  GENPYBIND(setter_for(enable_threshold_comparator))
127  void set_enable_threshold_comparator(bool value) SYMBOL_VISIBLE;
128 
129  // enable exc. synaptic input
130  GENPYBIND(getter_for(enable_synaptic_input_excitatory))
131  bool get_enable_synaptic_input_excitatory() const SYMBOL_VISIBLE;
132  GENPYBIND(setter_for(enable_synaptic_input_excitatory))
133  void set_enable_synaptic_input_excitatory(bool value) SYMBOL_VISIBLE;
134 
135  // enable inh. synaptic input
136  GENPYBIND(getter_for(enable_synaptic_input_inhibitory))
137  bool get_enable_synaptic_input_inhibitory() const SYMBOL_VISIBLE;
138  GENPYBIND(setter_for(enable_synaptic_input_inhibitory))
139  void set_enable_synaptic_input_inhibitory(bool value) SYMBOL_VISIBLE;
140 
141  // enable small capacitor at excitatory synaptic input
142  GENPYBIND(getter_for(enable_synaptic_input_excitatory_small_capacitor))
143  bool get_enable_synaptic_input_excitatory_small_capacitor() const SYMBOL_VISIBLE;
144  GENPYBIND(setter_for(enable_synaptic_input_excitatory_small_capacitor))
145  void set_enable_synaptic_input_excitatory_small_capacitor(bool value) SYMBOL_VISIBLE;
146 
147  // enable small capacitor at inhibitory synaptic input
148  GENPYBIND(getter_for(enable_synaptic_input_inhibitory_small_capacitor))
149  bool get_enable_synaptic_input_inhibitory_small_capacitor() const SYMBOL_VISIBLE;
150  GENPYBIND(setter_for(enable_synaptic_input_inhibitory_small_capacitor))
151  void set_enable_synaptic_input_inhibitory_small_capacitor(bool value) SYMBOL_VISIBLE;
152 
153  // enable high resistance mode for excitatory synaptic input
154  GENPYBIND(getter_for(enable_synaptic_input_excitatory_high_resistance))
155  bool get_enable_synaptic_input_excitatory_high_resistance() const SYMBOL_VISIBLE;
156  GENPYBIND(setter_for(enable_synaptic_input_excitatory_high_resistance))
157  void set_enable_synaptic_input_excitatory_high_resistance(bool value) SYMBOL_VISIBLE;
158 
159  // enable high resistance mode for inhibitory synaptic input
160  GENPYBIND(getter_for(enable_synaptic_input_inhibitory_high_resistance))
161  bool get_enable_synaptic_input_inhibitory_high_resistance() const SYMBOL_VISIBLE;
162  GENPYBIND(setter_for(enable_synaptic_input_inhibitory_high_resistance))
163  void set_enable_synaptic_input_inhibitory_high_resistance(bool value) SYMBOL_VISIBLE;
164 
165  // enable exc. bypass circuit
166  GENPYBIND(getter_for(enable_bypass_excitatory))
167  bool get_enable_bypass_excitatory() const SYMBOL_VISIBLE;
168  GENPYBIND(setter_for(enable_bypass_excitatory))
169  void set_enable_bypass_excitatory(bool value) SYMBOL_VISIBLE;
170 
171  // enable inh. bypass circuit
172  GENPYBIND(getter_for(enable_bypass_inhibitory))
173  bool get_enable_bypass_inhibitory() const SYMBOL_VISIBLE;
174  GENPYBIND(setter_for(enable_bypass_inhibitory))
175  void set_enable_bypass_inhibitory(bool value) SYMBOL_VISIBLE;
176 
177  // enable membrane offset current (can also be used for stimulus/step current)
178  GENPYBIND(getter_for(enable_membrane_offset))
179  bool get_enable_membrane_offset() const SYMBOL_VISIBLE;
180  GENPYBIND(setter_for(enable_membrane_offset))
181  void set_enable_membrane_offset(bool value) SYMBOL_VISIBLE;
182 
183  // invert membrane offset current
184  GENPYBIND(getter_for(invert_membrane_offset))
185  bool get_invert_membrane_offset() const SYMBOL_VISIBLE;
186  GENPYBIND(setter_for(invert_membrane_offset))
187  void set_invert_membrane_offset(bool value) SYMBOL_VISIBLE;
188 
189  // configure membrane size
190  GENPYBIND(getter_for(membrane_capacitor_size))
191  MembraneCapacitorSize get_membrane_capacitor_size() const SYMBOL_VISIBLE;
192  GENPYBIND(setter_for(membrane_capacitor_size))
193  void set_membrane_capacitor_size(MembraneCapacitorSize value) SYMBOL_VISIBLE;
194 
195  // flip the sign of a (sub-threshold adaptation)
196  GENPYBIND(getter_for(invert_adaptation_a))
197  bool get_invert_adaptation_a() const SYMBOL_VISIBLE;
198  GENPYBIND(setter_for(invert_adaptation_a))
199  void set_invert_adaptation_a(bool value) SYMBOL_VISIBLE;
200 
201  // flip the sign of b (spike-triggered adaptation)
202  GENPYBIND(getter_for(invert_adaptation_b))
203  bool get_invert_adaptation_b() const SYMBOL_VISIBLE;
204  GENPYBIND(setter_for(invert_adaptation_b))
205  void set_invert_adaptation_b(bool value) SYMBOL_VISIBLE;
206 
207  // enable adaptation
208  GENPYBIND(getter_for(enable_adaptation))
209  bool get_enable_adaptation() const SYMBOL_VISIBLE;
210  GENPYBIND(setter_for(enable_adaptation))
211  void set_enable_adaptation(bool value) SYMBOL_VISIBLE;
212 
213  // enable exponential term
214  GENPYBIND(getter_for(enable_exponential))
215  bool get_enable_exponential() const SYMBOL_VISIBLE;
216  GENPYBIND(setter_for(enable_exponential))
217  void set_enable_exponential(bool value) SYMBOL_VISIBLE;
218 
219  // enable direct, unbuffered access to membrane
220  GENPYBIND(getter_for(enable_unbuffered_access))
221  bool get_enable_unbuffered_access() const SYMBOL_VISIBLE;
222  GENPYBIND(setter_for(enable_unbuffered_access))
223  void set_enable_unbuffered_access(bool value) SYMBOL_VISIBLE;
224 
225  // enable readout amplifier
226  GENPYBIND(getter_for(enable_readout_amplifier))
227  bool get_enable_readout_amplifier() const SYMBOL_VISIBLE;
228  GENPYBIND(setter_for(enable_readout_amplifier))
229  void set_enable_readout_amplifier(bool value) SYMBOL_VISIBLE;
230 
231  // select readout source
232  GENPYBIND(getter_for(readout_source))
233  ReadoutSource get_readout_source() const SYMBOL_VISIBLE;
234  GENPYBIND(setter_for(readout_source))
235  void set_readout_source(ReadoutSource value) SYMBOL_VISIBLE;
236 
237  // enable readout
238  GENPYBIND(getter_for(enable_readout))
239  bool get_enable_readout() const SYMBOL_VISIBLE;
240  GENPYBIND(setter_for(enable_readout))
241  void set_enable_readout(bool value) SYMBOL_VISIBLE;
242 
243  // enable source degeneration of leak/reset OTA in reset mode
244  GENPYBIND(getter_for(enable_reset_degeneration))
245  bool get_enable_reset_degeneration() const SYMBOL_VISIBLE;
246  GENPYBIND(setter_for(enable_reset_degeneration))
247  void set_enable_reset_degeneration(bool value) SYMBOL_VISIBLE;
248 
249  // enable division (8x) of conductance in reset mode
250  GENPYBIND(getter_for(enable_reset_division))
251  bool get_enable_reset_division() const SYMBOL_VISIBLE;
252  GENPYBIND(setter_for(enable_reset_division))
253  void set_enable_reset_division(bool value) SYMBOL_VISIBLE;
254 
255  // enable multiplication (8x) of conductance in reset mode
256  GENPYBIND(getter_for(enable_reset_multiplication))
257  bool get_enable_reset_multiplication() const SYMBOL_VISIBLE;
258  GENPYBIND(setter_for(enable_reset_multiplication))
259  void set_enable_reset_multiplication(bool value) SYMBOL_VISIBLE;
260 
261  // enable source degeneration of leak/reset OTA in leak mode
262  GENPYBIND(getter_for(enable_leak_degeneration))
263  bool get_enable_leak_degeneration() const SYMBOL_VISIBLE;
264  GENPYBIND(setter_for(enable_leak_degeneration))
265  void set_enable_leak_degeneration(bool value) SYMBOL_VISIBLE;
266 
267  // enable division (8x) of conductance in leak mode
268  GENPYBIND(getter_for(enable_leak_division))
269  bool get_enable_leak_division() const SYMBOL_VISIBLE;
270  GENPYBIND(setter_for(enable_leak_division))
271  void set_enable_leak_division(bool value) SYMBOL_VISIBLE;
272 
273  // enable multiplication (8x) of conductance in leak mode
274  GENPYBIND(getter_for(enable_leak_multiplication))
275  bool get_enable_leak_multiplication() const SYMBOL_VISIBLE;
276  GENPYBIND(setter_for(enable_leak_multiplication))
277  void set_enable_leak_multiplication(bool value) SYMBOL_VISIBLE;
278 
279  // enable gating of synaptic inputs and exponential term during reset periods
280  GENPYBIND(getter_for(enable_pause))
281  bool get_enable_pause() const SYMBOL_VISIBLE;
282  GENPYBIND(setter_for(enable_pause))
283  void set_enable_pause(bool value) SYMBOL_VISIBLE;
284 
285  bool operator==(NeuronConfig const& other) const SYMBOL_VISIBLE;
286  bool operator!=(NeuronConfig const& other) const SYMBOL_VISIBLE;
287 
288  static size_t constexpr config_size_in_words GENPYBIND(hidden) = 6;
289  template <typename AddressT>
290  static std::array<AddressT, config_size_in_words> addresses(coordinate_type const& neuron)
291  SYMBOL_VISIBLE GENPYBIND(hidden);
292  template <typename WordT>
293  std::array<WordT, config_size_in_words> encode() const SYMBOL_VISIBLE GENPYBIND(hidden);
294  template <typename WordT>
295  void decode(std::array<WordT, config_size_in_words> const& data) SYMBOL_VISIBLE
296  GENPYBIND(hidden);
297 
298  GENPYBIND(stringstream)
299  friend std::ostream& operator<<(std::ostream& os, NeuronConfig const& config) SYMBOL_VISIBLE;
300 
301 private:
302  friend class cereal::access;
303  template <class Archive>
304  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE;
305 
306  bool m_en_comp_cond_div;
307  bool m_en_comp_cond_mul;
308  bool m_connect_soma;
309  bool m_connect_membrane_right;
310  bool m_en_comp_cond;
311  bool m_connect_bottom;
312  bool m_connect_somata;
313  bool m_en_fire;
314  bool m_en_strong_fire;
315  bool m_en_thresh_comp;
316  bool m_en_synin_inh;
317  bool m_en_synin_exc;
318  bool m_en_synin_exc_small_cap;
319  bool m_en_synin_inh_small_cap;
320  bool m_en_synin_exc_high_res;
321  bool m_en_synin_inh_high_res;
322  bool m_en_byp_inh;
323  bool m_en_byp_exc;
324  bool m_en_mem_off;
325  bool m_invert_current;
326  MembraneCapacitorSize m_mem_cap_size;
327  bool m_invert_adapt_a;
328  bool m_invert_adapt_b;
329  bool m_en_adapt;
330  bool m_en_exp;
331  bool m_en_unbuf_access;
332  bool m_en_readout_amp;
333  ReadoutSource m_readout_select;
334  bool m_en_readout;
335  bool m_en_reset_deg;
336  bool m_en_reset_div;
337  bool m_en_reset_mul;
338  bool m_en_leak_deg;
339  bool m_en_leak_div;
340  bool m_en_leak_mul;
341  bool m_en_pause;
342 };
343 
344 std::ostream& operator<<(std::ostream&, NeuronConfig::ReadoutSource const&) SYMBOL_VISIBLE;
345 
351 class GENPYBIND(visible) NeuronResetQuad
352 {
353 public:
354  typedef halco::hicann_dls::vx::v2::NeuronResetQuadOnDLS coordinate_type;
355  typedef std::true_type is_leaf_node;
356 
358  NeuronResetQuad() SYMBOL_VISIBLE;
359 
360  bool operator==(NeuronResetQuad const& other) const SYMBOL_VISIBLE;
361  bool operator!=(NeuronResetQuad const& other) const SYMBOL_VISIBLE;
362 
363  static size_t constexpr write_config_size_in_words GENPYBIND(hidden) = 1;
364  static size_t constexpr read_config_size_in_words GENPYBIND(hidden) = 0;
365  template <typename AddressT>
366  static std::array<AddressT, read_config_size_in_words> read_addresses(
367  coordinate_type const& neuron) SYMBOL_VISIBLE GENPYBIND(hidden);
368  template <typename AddressT>
369  static std::array<AddressT, write_config_size_in_words> write_addresses(
370  coordinate_type const& neuron) SYMBOL_VISIBLE GENPYBIND(hidden);
371  template <typename WordT>
372  std::array<WordT, write_config_size_in_words> encode() const SYMBOL_VISIBLE GENPYBIND(hidden);
373  template <typename WordT>
374  void decode(std::array<WordT, read_config_size_in_words> const& data) SYMBOL_VISIBLE
375  GENPYBIND(hidden);
376 
377  GENPYBIND(stringstream)
378  friend std::ostream& operator<<(std::ostream& os, NeuronResetQuad const& config) SYMBOL_VISIBLE;
379 
380 private:
381  friend class cereal::access;
382  template <class Archive>
383  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE;
384 };
385 
386 } // namespace haldls::vx::v2
387 
388 namespace haldls::vx::detail {
389 
390 template <>
391 struct BackendContainerTrait<v2::NeuronConfig>
392  : public BackendContainerBase<
393  v2::NeuronConfig,
394  fisch::vx::word_access_type::Omnibus,
395  fisch::vx::word_access_type::OmnibusChipOverJTAG>
396 {};
397 
398 template <>
399 struct BackendContainerTrait<v2::NeuronResetQuad>
400  : public BackendContainerBase<
401  v2::NeuronResetQuad,
402  fisch::vx::word_access_type::Omnibus,
403  fisch::vx::word_access_type::OmnibusChipOverJTAG>
404 {};
405 
406 } // namespace haldls::vx::detail
407 
408 #ifndef __ppu__
409 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(haldls::vx::v2::NeuronConfig)
410 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(haldls::vx::v2::NeuronResetQuad)
411 #endif
Container to send post pulses to one half of the neurons (left/right).
Definition: neuron.h:549
Read/write access to common neuron parameters.
Definition: neuron.h:31
Trait signalling derived-from container type support differential write operation.
Definition: traits.h:17
Read/write access to the NeuronBackend container.
Definition: neuron.h:231
Container to trigger reset of a single neuron.
Definition: neuron.h:491
Container to read the spike counter of a single neuron.
Definition: neuron.h:604
Container to reset the spike counter of a single neuron.
Definition: neuron.h:689
ReadoutSource
Source of readout output.
Definition: neuron.h:47
std::true_type is_leaf_node
Definition: neuron.h:39
halco::hicann_dls::vx::v2::NeuronConfigOnDLS coordinate_type
Definition: neuron.h:38
#define GENPYBIND_TAG_HALDLS_VX_V2
Definition: genpybind.h:5
haldls::vx::SpikeCounterReset SpikeCounterReset
Definition: neuron.h:28
haldls::vx::NeuronBackendSRAMTimingConfig NeuronBackendSRAMTimingConfig
Definition: neuron.h:29
haldls::vx::SpikeCounterRead SpikeCounterRead
Definition: neuron.h:27
haldls::vx::NeuronReset NeuronReset
Definition: neuron.h:25
haldls::vx::BlockPostPulse BlockPostPulse
Definition: neuron.h:26
haldls::vx::NeuronSRAMTimingConfig NeuronSRAMTimingConfig
Definition: neuron.h:30
haldls::vx::CommonNeuronBackendConfig CommonNeuronBackendConfig
Definition: neuron.h:22
#define NEURON_EXTERN_TEMPLATE(Coordinates)
Definition: neuron.h:828