HALDLS
neuron.h
Go to the documentation of this file.
1 #pragma once
2 #include "halco/hicann-dls/vx/v3/coordinates.h"
3 #include "halco/hicann-dls/vx/v3/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::v3::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::v3::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  // set exc. synaptic input from CUBA to COBA mode.
142  GENPYBIND(getter_for(enable_synaptic_input_excitatory_coba_mode))
143  bool get_enable_synaptic_input_excitatory_coba_mode() const SYMBOL_VISIBLE;
144  GENPYBIND(setter_for(enable_synaptic_input_excitatory_coba_mode))
145  void set_enable_synaptic_input_excitatory_coba_mode(bool value) SYMBOL_VISIBLE;
146 
147  // set inh. synaptic input from CUBA to COBA mode.
148  GENPYBIND(getter_for(enable_synaptic_input_inhibitory_coba_mode))
149  bool get_enable_synaptic_input_inhibitory_coba_mode() const SYMBOL_VISIBLE;
150  GENPYBIND(setter_for(enable_synaptic_input_inhibitory_coba_mode))
151  void set_enable_synaptic_input_inhibitory_coba_mode(bool value) SYMBOL_VISIBLE;
152 
153  // enable small capacitance mode at excitatory synaptic input:
154  // This disconnects the capacitor from the synaptic input line and leaves
155  // only the parasitic capacitance of the line.
156  GENPYBIND(getter_for(enable_synaptic_input_excitatory_small_capacitance))
157  bool get_enable_synaptic_input_excitatory_small_capacitance() const SYMBOL_VISIBLE;
158  GENPYBIND(setter_for(enable_synaptic_input_excitatory_small_capacitance))
159  void set_enable_synaptic_input_excitatory_small_capacitance(bool value) SYMBOL_VISIBLE;
160 
161  // enable small capacitance mode at inhibitory synaptic input:
162  // This disconnects the capacitor from the synaptic input line and leaves
163  // only the parasitic capacitance of the line.
164  GENPYBIND(getter_for(enable_synaptic_input_inhibitory_small_capacitance))
165  bool get_enable_synaptic_input_inhibitory_small_capacitance() const SYMBOL_VISIBLE;
166  GENPYBIND(setter_for(enable_synaptic_input_inhibitory_small_capacitance))
167  void set_enable_synaptic_input_inhibitory_small_capacitance(bool value) SYMBOL_VISIBLE;
168 
169  // enable high resistance mode for excitatory synaptic input
170  GENPYBIND(getter_for(enable_synaptic_input_excitatory_high_resistance))
171  bool get_enable_synaptic_input_excitatory_high_resistance() const SYMBOL_VISIBLE;
172  GENPYBIND(setter_for(enable_synaptic_input_excitatory_high_resistance))
173  void set_enable_synaptic_input_excitatory_high_resistance(bool value) SYMBOL_VISIBLE;
174 
175  // enable high resistance mode for inhibitory synaptic input
176  GENPYBIND(getter_for(enable_synaptic_input_inhibitory_high_resistance))
177  bool get_enable_synaptic_input_inhibitory_high_resistance() const SYMBOL_VISIBLE;
178  GENPYBIND(setter_for(enable_synaptic_input_inhibitory_high_resistance))
179  void set_enable_synaptic_input_inhibitory_high_resistance(bool value) SYMBOL_VISIBLE;
180 
181  // enable exc. bypass circuit
182  GENPYBIND(getter_for(enable_bypass_excitatory))
183  bool get_enable_bypass_excitatory() const SYMBOL_VISIBLE;
184  GENPYBIND(setter_for(enable_bypass_excitatory))
185  void set_enable_bypass_excitatory(bool value) SYMBOL_VISIBLE;
186 
187  // enable inh. bypass circuit
188  GENPYBIND(getter_for(enable_bypass_inhibitory))
189  bool get_enable_bypass_inhibitory() const SYMBOL_VISIBLE;
190  GENPYBIND(setter_for(enable_bypass_inhibitory))
191  void set_enable_bypass_inhibitory(bool value) SYMBOL_VISIBLE;
192 
193  // enable membrane offset current (can also be used for stimulus/step current)
194  GENPYBIND(getter_for(enable_membrane_offset))
195  bool get_enable_membrane_offset() const SYMBOL_VISIBLE;
196  GENPYBIND(setter_for(enable_membrane_offset))
197  void set_enable_membrane_offset(bool value) SYMBOL_VISIBLE;
198 
199  // invert membrane offset current
200  GENPYBIND(getter_for(invert_membrane_offset))
201  bool get_invert_membrane_offset() const SYMBOL_VISIBLE;
202  GENPYBIND(setter_for(invert_membrane_offset))
203  void set_invert_membrane_offset(bool value) SYMBOL_VISIBLE;
204 
205  // configure membrane size
206  GENPYBIND(getter_for(membrane_capacitor_size))
207  MembraneCapacitorSize get_membrane_capacitor_size() const SYMBOL_VISIBLE;
208  GENPYBIND(setter_for(membrane_capacitor_size))
209  void set_membrane_capacitor_size(MembraneCapacitorSize value) SYMBOL_VISIBLE;
210 
211  // flip the sign of a (sub-threshold adaptation)
212  GENPYBIND(getter_for(invert_adaptation_a))
213  bool get_invert_adaptation_a() const SYMBOL_VISIBLE;
214  GENPYBIND(setter_for(invert_adaptation_a))
215  void set_invert_adaptation_a(bool value) SYMBOL_VISIBLE;
216 
217  // flip the sign of b (spike-triggered adaptation)
218  GENPYBIND(getter_for(invert_adaptation_b))
219  bool get_invert_adaptation_b() const SYMBOL_VISIBLE;
220  GENPYBIND(setter_for(invert_adaptation_b))
221  void set_invert_adaptation_b(bool value) SYMBOL_VISIBLE;
222 
223  // enable adaptation
224  GENPYBIND(getter_for(enable_adaptation))
225  bool get_enable_adaptation() const SYMBOL_VISIBLE;
226  GENPYBIND(setter_for(enable_adaptation))
227  void set_enable_adaptation(bool value) SYMBOL_VISIBLE;
228 
229  // enable exponential term
230  GENPYBIND(getter_for(enable_exponential))
231  bool get_enable_exponential() const SYMBOL_VISIBLE;
232  GENPYBIND(setter_for(enable_exponential))
233  void set_enable_exponential(bool value) SYMBOL_VISIBLE;
234 
235  // enable direct, unbuffered access to membrane
236  GENPYBIND(getter_for(enable_unbuffered_access))
237  bool get_enable_unbuffered_access() const SYMBOL_VISIBLE;
238  GENPYBIND(setter_for(enable_unbuffered_access))
239  void set_enable_unbuffered_access(bool value) SYMBOL_VISIBLE;
240 
241  // enable readout amplifier
242  GENPYBIND(getter_for(enable_readout_amplifier))
243  bool get_enable_readout_amplifier() const SYMBOL_VISIBLE;
244  GENPYBIND(setter_for(enable_readout_amplifier))
245  void set_enable_readout_amplifier(bool value) SYMBOL_VISIBLE;
246 
247  // select readout source
248  GENPYBIND(getter_for(readout_source))
249  ReadoutSource get_readout_source() const SYMBOL_VISIBLE;
250  GENPYBIND(setter_for(readout_source))
251  void set_readout_source(ReadoutSource value) SYMBOL_VISIBLE;
252 
253  // enable readout
254  GENPYBIND(getter_for(enable_readout))
255  bool get_enable_readout() const SYMBOL_VISIBLE;
256  GENPYBIND(setter_for(enable_readout))
257  void set_enable_readout(bool value) SYMBOL_VISIBLE;
258 
259  // enable source degeneration of leak/reset OTA in reset mode
260  GENPYBIND(getter_for(enable_reset_degeneration))
261  bool get_enable_reset_degeneration() const SYMBOL_VISIBLE;
262  GENPYBIND(setter_for(enable_reset_degeneration))
263  void set_enable_reset_degeneration(bool value) SYMBOL_VISIBLE;
264 
265  // enable division (8x) of conductance in reset mode
266  GENPYBIND(getter_for(enable_reset_division))
267  bool get_enable_reset_division() const SYMBOL_VISIBLE;
268  GENPYBIND(setter_for(enable_reset_division))
269  void set_enable_reset_division(bool value) SYMBOL_VISIBLE;
270 
271  // enable multiplication (8x) of conductance in reset mode
272  GENPYBIND(getter_for(enable_reset_multiplication))
273  bool get_enable_reset_multiplication() const SYMBOL_VISIBLE;
274  GENPYBIND(setter_for(enable_reset_multiplication))
275  void set_enable_reset_multiplication(bool value) SYMBOL_VISIBLE;
276 
277  // enable source degeneration of leak/reset OTA in leak mode
278  GENPYBIND(getter_for(enable_leak_degeneration))
279  bool get_enable_leak_degeneration() const SYMBOL_VISIBLE;
280  GENPYBIND(setter_for(enable_leak_degeneration))
281  void set_enable_leak_degeneration(bool value) SYMBOL_VISIBLE;
282 
283  // enable division (8x) of conductance in leak mode
284  GENPYBIND(getter_for(enable_leak_division))
285  bool get_enable_leak_division() const SYMBOL_VISIBLE;
286  GENPYBIND(setter_for(enable_leak_division))
287  void set_enable_leak_division(bool value) SYMBOL_VISIBLE;
288 
289  // enable multiplication (8x) of conductance in leak mode
290  GENPYBIND(getter_for(enable_leak_multiplication))
291  bool get_enable_leak_multiplication() const SYMBOL_VISIBLE;
292  GENPYBIND(setter_for(enable_leak_multiplication))
293  void set_enable_leak_multiplication(bool value) SYMBOL_VISIBLE;
294 
295  // enable gating of synaptic inputs and exponential term during reset periods
296  GENPYBIND(getter_for(enable_pause))
297  bool get_enable_pause() const SYMBOL_VISIBLE;
298  GENPYBIND(setter_for(enable_pause))
299  void set_enable_pause(bool value) SYMBOL_VISIBLE;
300 
301  bool operator==(NeuronConfig const& other) const SYMBOL_VISIBLE;
302  bool operator!=(NeuronConfig const& other) const SYMBOL_VISIBLE;
303 
304  static size_t constexpr config_size_in_words GENPYBIND(hidden) = 6;
305  template <typename AddressT>
306  static std::array<AddressT, config_size_in_words> addresses(coordinate_type const& neuron)
307  SYMBOL_VISIBLE GENPYBIND(hidden);
308  template <typename WordT>
309  std::array<WordT, config_size_in_words> encode() const SYMBOL_VISIBLE GENPYBIND(hidden);
310  template <typename WordT>
311  void decode(std::array<WordT, config_size_in_words> const& data) SYMBOL_VISIBLE
312  GENPYBIND(hidden);
313 
314  GENPYBIND(stringstream)
315  friend std::ostream& operator<<(std::ostream& os, NeuronConfig const& config) SYMBOL_VISIBLE;
316 
317 private:
318  friend class cereal::access;
319  template <class Archive>
320  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE;
321 
322  bool m_en_comp_cond_div;
323  bool m_en_comp_cond_mul;
324  bool m_connect_soma;
325  bool m_connect_membrane_right;
326  bool m_en_comp_cond;
327  bool m_connect_bottom;
328  bool m_connect_somata;
329  bool m_en_fire;
330  bool m_en_strong_fire;
331  bool m_en_thresh_comp;
332  bool m_en_synin_inh;
333  bool m_en_synin_exc;
334  bool m_en_synin_inh_coba;
335  bool m_en_synin_exc_coba;
336  bool m_en_synin_exc_small_cap;
337  bool m_en_synin_inh_small_cap;
338  bool m_en_synin_exc_high_res;
339  bool m_en_synin_inh_high_res;
340  bool m_en_byp_inh;
341  bool m_en_byp_exc;
342  bool m_en_mem_off;
343  bool m_invert_current;
344  MembraneCapacitorSize m_mem_cap_size;
345  bool m_invert_adapt_a;
346  bool m_invert_adapt_b;
347  bool m_en_adapt;
348  bool m_en_exp;
349  bool m_en_unbuf_access;
350  bool m_en_readout_amp;
351  ReadoutSource m_readout_select;
352  bool m_en_readout;
353  bool m_en_reset_deg;
354  bool m_en_reset_div;
355  bool m_en_reset_mul;
356  bool m_en_leak_deg;
357  bool m_en_leak_div;
358  bool m_en_leak_mul;
359  bool m_en_pause;
360 };
361 
362 std::ostream& operator<<(std::ostream&, NeuronConfig::ReadoutSource const&) SYMBOL_VISIBLE;
363 
369 class GENPYBIND(visible) NeuronResetQuad
370 {
371 public:
372  typedef halco::hicann_dls::vx::v3::NeuronResetQuadOnDLS coordinate_type;
373  typedef std::true_type is_leaf_node;
374 
376  NeuronResetQuad() SYMBOL_VISIBLE;
377 
378  bool operator==(NeuronResetQuad const& other) const SYMBOL_VISIBLE;
379  bool operator!=(NeuronResetQuad const& other) const SYMBOL_VISIBLE;
380 
381  static size_t constexpr write_config_size_in_words GENPYBIND(hidden) = 1;
382  static size_t constexpr read_config_size_in_words GENPYBIND(hidden) = 0;
383  template <typename AddressT>
384  static std::array<AddressT, read_config_size_in_words> read_addresses(
385  coordinate_type const& neuron) SYMBOL_VISIBLE GENPYBIND(hidden);
386  template <typename AddressT>
387  static std::array<AddressT, write_config_size_in_words> write_addresses(
388  coordinate_type const& neuron) SYMBOL_VISIBLE GENPYBIND(hidden);
389  template <typename WordT>
390  std::array<WordT, write_config_size_in_words> encode() const SYMBOL_VISIBLE GENPYBIND(hidden);
391  template <typename WordT>
392  void decode(std::array<WordT, read_config_size_in_words> const& data) SYMBOL_VISIBLE
393  GENPYBIND(hidden);
394 
395  GENPYBIND(stringstream)
396  friend std::ostream& operator<<(std::ostream& os, NeuronResetQuad const& config) SYMBOL_VISIBLE;
397 
398 private:
399  friend class cereal::access;
400  template <class Archive>
401  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE;
402 };
403 
404 } // namespace haldls::vx::v3
405 
406 namespace haldls::vx::detail {
407 
408 template <>
409 struct BackendContainerTrait<v3::NeuronConfig>
410  : public BackendContainerBase<
411  v3::NeuronConfig,
412  fisch::vx::word_access_type::Omnibus,
413  fisch::vx::word_access_type::OmnibusChipOverJTAG>
414 {};
415 
416 template <>
417 struct BackendContainerTrait<v3::NeuronResetQuad>
418  : public BackendContainerBase<
419  v3::NeuronResetQuad,
420  fisch::vx::word_access_type::Omnibus,
421  fisch::vx::word_access_type::OmnibusChipOverJTAG>
422 {};
423 
424 } // namespace haldls::vx::detail
425 
426 #ifndef __ppu__
427 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(haldls::vx::v3::NeuronConfig)
428 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(haldls::vx::v3::NeuronResetQuad)
429 #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
halco::hicann_dls::vx::v3::NeuronConfigOnDLS coordinate_type
Definition: neuron.h:38
ReadoutSource
Source of readout output.
Definition: neuron.h:47
std::true_type is_leaf_node
Definition: neuron.h:39
#define GENPYBIND_TAG_HALDLS_VX_V3
Definition: genpybind.h:6
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