LOLA
neuron.h
Go to the documentation of this file.
1 #pragma once
2 #include "haldls/vx/v2/capmem.h"
3 #include "haldls/vx/v2/neuron.h"
4 #include "hate/visibility.h"
6 #include "lola/vx/v2/synapse.h"
7 
9 
13 class GENPYBIND(visible) AtomicNeuron
14 {
15 public:
16  typedef haldls::vx::v2::CapMemCell::Value AnalogValue GENPYBIND(visible);
17  typedef haldls::vx::v2::CapMemCell::DisableRefresh AnalogDisableRefresh GENPYBIND(visible);
18  typedef haldls::vx::v2::CapMemCell::value_type AnalogValueVariant;
19 
20  struct GENPYBIND(visible) SynapticInput
21  {
22  SynapticInput() SYMBOL_VISIBLE;
23 
27  bool enable;
28 
31  AnalogValueVariant i_bias_tau;
32 
37  AnalogValueVariant i_drop_input;
38 
43  AnalogValueVariant i_shift_reference;
44 
46  AnalogValueVariant i_bias_gm;
47 
49  bool enable_small_capacitor;
50 
52  bool enable_high_resistance;
53 
54  bool operator==(SynapticInput const& other) const SYMBOL_VISIBLE;
55  bool operator!=(SynapticInput const& other) const SYMBOL_VISIBLE;
56 
57  GENPYBIND(stringstream)
58  friend std::ostream& operator<<(std::ostream& os, SynapticInput const& config)
59  SYMBOL_VISIBLE;
60  };
61 
62  struct GENPYBIND(visible) Leak
63  {
64  Leak() SYMBOL_VISIBLE;
65 
68 
69  /*
70  * Bias current of OTA during leak.
71  * High values result in a shorter membrane time constant.
72  */
74 
76  bool enable_degeneration;
77 
79  bool enable_division;
80 
82  bool enable_multiplication;
83 
84  bool operator==(Leak const& other) const SYMBOL_VISIBLE;
85  bool operator!=(Leak const& other) const SYMBOL_VISIBLE;
86 
87  GENPYBIND(stringstream)
88  friend std::ostream& operator<<(std::ostream& os, Leak const& config) SYMBOL_VISIBLE;
89  };
90 
91  struct GENPYBIND(visible) Reset
92  {
93  Reset() SYMBOL_VISIBLE;
94 
97 
98  /*
99  * Bias current of OTA during reset.
100  * High values result in higher reset conductance.
101  */
103 
105  bool enable_degeneration;
106 
108  bool enable_division;
109 
111  bool enable_multiplication;
112 
113  bool operator==(Reset const& other) const SYMBOL_VISIBLE;
114  bool operator!=(Reset const& other) const SYMBOL_VISIBLE;
115 
116  GENPYBIND(stringstream)
117  friend std::ostream& operator<<(std::ostream& os, Reset const& config) SYMBOL_VISIBLE;
118  };
119 
120  struct GENPYBIND(visible) Threshold
121  {
122  Threshold() SYMBOL_VISIBLE;
123 
125  bool enable;
126 
128  AnalogValueVariant v_threshold;
129 
130  bool operator==(Threshold const& other) const SYMBOL_VISIBLE;
131  bool operator!=(Threshold const& other) const SYMBOL_VISIBLE;
132 
133  GENPYBIND(stringstream)
134  friend std::ostream& operator<<(std::ostream& os, Threshold const& config) SYMBOL_VISIBLE;
135  };
136 
141  struct GENPYBIND(visible) Multicompartment
142  {
143  Multicompartment() SYMBOL_VISIBLE;
144 
146  bool connect_soma;
147 
149  bool connect_soma_right;
150 
152  bool connect_right;
153 
155  bool connect_vertical;
156 
158  bool enable_conductance;
159 
161  bool enable_conductance_division;
162 
164  bool enable_conductance_multiplication;
165 
167  AnalogValueVariant i_bias_nmda;
168 
169  bool operator==(Multicompartment const& other) const SYMBOL_VISIBLE;
170  bool operator!=(Multicompartment const& other) const SYMBOL_VISIBLE;
171 
172  GENPYBIND(stringstream)
173  friend std::ostream& operator<<(std::ostream& os, Multicompartment const& config)
174  SYMBOL_VISIBLE;
175  };
176 
177  struct GENPYBIND(visible) ConstantCurrent
178  {
179  ConstantCurrent() SYMBOL_VISIBLE;
180 
182  bool enable;
183 
186 
188  enum class Type
189  {
190  source,
191  sink
192  } type;
193 
194  bool operator==(ConstantCurrent const& other) const SYMBOL_VISIBLE;
195  bool operator!=(ConstantCurrent const& other) const SYMBOL_VISIBLE;
196 
197  GENPYBIND(stringstream)
198  friend std::ostream& operator<<(std::ostream& os, ConstantCurrent const& config)
199  SYMBOL_VISIBLE;
200  };
201 
202  struct GENPYBIND(visible) MembraneCapacitance
203  {
204  typedef haldls::vx::v2::NeuronConfig::MembraneCapacitorSize CapacitorSize
205  GENPYBIND(visible);
206 
207  MembraneCapacitance() SYMBOL_VISIBLE;
208 
210  CapacitorSize capacitance;
211 
212  bool operator==(MembraneCapacitance const& other) const SYMBOL_VISIBLE;
213  bool operator!=(MembraneCapacitance const& other) const SYMBOL_VISIBLE;
214 
215  GENPYBIND(stringstream)
216  friend std::ostream& operator<<(std::ostream& os, MembraneCapacitance const& config)
217  SYMBOL_VISIBLE;
218  };
219 
220  struct GENPYBIND(visible) Adaptation
221  {
222  Adaptation() SYMBOL_VISIBLE;
223 
225  bool enable;
226 
231  bool enable_pulse;
232 
234  bool invert_a;
235 
237  bool invert_b;
238 
241 
243  AnalogValueVariant i_bias_tau;
244 
247 
250 
253 
254  bool operator==(Adaptation const& other) const SYMBOL_VISIBLE;
255  bool operator!=(Adaptation const& other) const SYMBOL_VISIBLE;
256 
257  GENPYBIND(stringstream)
258  friend std::ostream& operator<<(std::ostream& os, Adaptation const& config) SYMBOL_VISIBLE;
259  };
260 
261  struct GENPYBIND(visible) Exponential
262  {
264  bool enable;
265 
268 
271 
272  Exponential() SYMBOL_VISIBLE;
273 
274  bool operator==(Exponential const& other) const SYMBOL_VISIBLE;
275  bool operator!=(Exponential const& other) const SYMBOL_VISIBLE;
276 
277  GENPYBIND(stringstream)
278  friend std::ostream& operator<<(std::ostream& os, Exponential const& config) SYMBOL_VISIBLE;
279  };
280 
281  struct GENPYBIND(visible) EventRouting
282  {
283  EventRouting() SYMBOL_VISIBLE;
284 
285  typedef haldls::vx::v2::NeuronBackendConfig::AddressOut Address GENPYBIND(visible);
286 
293  enum class AnalogOutputMode
294  {
295  off,
296  normal,
297  strong
298  } analog_output;
299 
302 
305 
308 
311 
317 
319  AnalogOutputMode analog_output,
320  bool enable_digital,
321  bool enable_bypass_excitatory,
322  bool enable_bypass_inhibitory,
323  Address address,
324  bool enable_post_overwrite) SYMBOL_VISIBLE;
325 
326  static const EventRouting disabled SYMBOL_VISIBLE;
327  static const EventRouting enabled SYMBOL_VISIBLE;
328  static const EventRouting bypass_exc SYMBOL_VISIBLE;
329  static const EventRouting bypass_inh SYMBOL_VISIBLE;
330 
331  bool operator==(EventRouting const& other) const SYMBOL_VISIBLE;
332  bool operator!=(EventRouting const& other) const SYMBOL_VISIBLE;
333 
334  GENPYBIND(stringstream)
335  friend std::ostream& operator<<(std::ostream& os, EventRouting const& config)
336  SYMBOL_VISIBLE;
337  };
338 
339  struct GENPYBIND(visible) Readout
340  {
341  typedef haldls::vx::v2::NeuronConfig::ReadoutSource Source GENPYBIND(visible);
342 
349 
352 
358 
374  Source source;
375 
376  Readout() SYMBOL_VISIBLE;
377 
378  bool operator==(Readout const& other) const SYMBOL_VISIBLE;
379  bool operator!=(Readout const& other) const SYMBOL_VISIBLE;
380 
381  GENPYBIND(stringstream)
382  friend std::ostream& operator<<(std::ostream& os, Readout const& config) SYMBOL_VISIBLE;
383  };
384 
385  struct GENPYBIND(visible) RefractoryPeriod
386  {
387  typedef haldls::vx::v2::NeuronBackendConfig::InputClock InputClock GENPYBIND(visible);
388  typedef haldls::vx::v2::NeuronBackendConfig::ResetHoldoff ResetHoldoff GENPYBIND(visible);
389  typedef haldls::vx::v2::NeuronBackendConfig::RefractoryTime RefractoryTime
390  GENPYBIND(visible);
391 
397 
407 
414 
419 
420  RefractoryPeriod() SYMBOL_VISIBLE;
421 
422  bool operator==(RefractoryPeriod const& other) const SYMBOL_VISIBLE;
423  bool operator!=(RefractoryPeriod const& other) const SYMBOL_VISIBLE;
424 
425  GENPYBIND(stringstream)
426  friend std::ostream& operator<<(std::ostream& os, RefractoryPeriod const& config)
427  SYMBOL_VISIBLE;
428  };
429 
430  struct GENPYBIND(visible) Bayesian
431  {
432  Bayesian() SYMBOL_VISIBLE;
433 
434  bool enable;
435  bool connect_fire_vertical;
436  bool connect_fire_to_right;
437  bool connect_fire_from_right;
438 
444  bool enable_master;
445  bool enable_slave;
446  bool enable_0;
447  bool enable_1;
448 
449  bool operator==(Bayesian const& other) const SYMBOL_VISIBLE;
450  bool operator!=(Bayesian const& other) const SYMBOL_VISIBLE;
451 
452  GENPYBIND(stringstream)
453  friend std::ostream& operator<<(std::ostream& os, Bayesian const& config) SYMBOL_VISIBLE;
454  };
455 
456 
457  typedef halco::hicann_dls::vx::v2::AtomicNeuronOnDLS coordinate_type;
458  typedef std::false_type has_local_data;
459 
460  AtomicNeuron() SYMBOL_VISIBLE;
461 
476 
478  explicit operator haldls::vx::v2::NeuronConfig() const SYMBOL_VISIBLE;
479  GENPYBIND_MANUAL({
480  parent.def("asNeuronConfig", [](GENPYBIND_PARENT_TYPE const& self) {
481  return static_cast<haldls::vx::v2::NeuronConfig>(self);
482  });
483  })
484 
485  void set_from(haldls::vx::v2::NeuronConfig const& neuron_config) SYMBOL_VISIBLE;
486 
488  explicit operator haldls::vx::v2::NeuronBackendConfig() const SYMBOL_VISIBLE;
489  GENPYBIND_MANUAL({
490  parent.def("asNeuronBackendConfig", [](GENPYBIND_PARENT_TYPE const& self) {
491  return static_cast<haldls::vx::v2::NeuronBackendConfig>(self);
492  });
493  })
494 
495  void set_from(haldls::vx::v2::NeuronBackendConfig const& neuron_backend_config) SYMBOL_VISIBLE;
496 
497  bool operator==(AtomicNeuron const& other) const SYMBOL_VISIBLE;
498  bool operator!=(AtomicNeuron const& other) const SYMBOL_VISIBLE;
499 
500  GENPYBIND(stringstream)
501  friend std::ostream& operator<<(std::ostream& os, AtomicNeuron const& config) SYMBOL_VISIBLE;
502 
503 private:
504  friend class haldls::vx::detail::VisitPreorderImpl<AtomicNeuron>;
505 };
506 
507 
511 class GENPYBIND(visible) NeuronBlock
512 {
513 public:
514  typedef haldls::vx::v2::CapMemCell::Value AnalogValue GENPYBIND(visible);
515  typedef haldls::vx::v2::CapMemCell::DisableRefresh AnalogDisableRefresh GENPYBIND(visible);
516  typedef haldls::vx::v2::CapMemCell::value_type AnalogValueVariant;
517 
518  typedef halco::hicann_dls::vx::v2::NeuronBlockOnDLS coordinate_type;
519  typedef std::false_type has_local_data;
520 
521  NeuronBlock() = default;
522 
523  typedef halco::common::
524  typed_heap_array<AtomicNeuron, halco::hicann_dls::vx::v2::AtomicNeuronOnDLS>
525  AtomicNeurons GENPYBIND(opaque(false));
529  AtomicNeurons atomic_neurons{};
530 
531  typedef halco::common::typed_array<
532  haldls::vx::v2::CommonNeuronBackendConfig,
533  halco::hicann_dls::vx::v2::CommonNeuronBackendConfigOnDLS>
534  Backends GENPYBIND(opaque(false));
535 
539  Backends backends{};
540 
541  typedef halco::common::typed_array<
543  halco::hicann_dls::vx::v2::ColumnCurrentRowOnDLS>
544  CurrentRows GENPYBIND(opaque(false));
545 
549  CurrentRows current_rows{};
550 
551  typedef halco::common::
552  typed_array<AnalogValueVariant, halco::hicann_dls::vx::v2::CapMemBlockOnDLS>
553  AnalogValues;
557  AnalogValues v_bias_casc_n{
558  AnalogValue{250}, AnalogValue{250}, AnalogValue{250}, AnalogValue{250}};
559 
563  AnalogValues i_bias_readout_amp{
564  AnalogValue{110}, AnalogValue{110}, AnalogValue{110}, AnalogValue{110}};
565 
569  AnalogValues i_bias_leak_source_follower{
570  AnalogValue{100}, AnalogValue{100}, AnalogValue{100}, AnalogValue{100}};
571 
575  AnalogValues i_bias_threshold_comparator{
576  AnalogValue{200}, AnalogValue{200}, AnalogValue{200}, AnalogValue{200}};
577 
578  bool operator==(NeuronBlock const& other) const SYMBOL_VISIBLE;
579  bool operator!=(NeuronBlock const& other) const SYMBOL_VISIBLE;
580 
581  GENPYBIND(stringstream)
582  friend std::ostream& operator<<(std::ostream& os, NeuronBlock const& config) SYMBOL_VISIBLE;
583 
584  // TODO (Issue 3622): Manual wrapping is necessary due to genpybind forgetting full
585  // qualification
586  GENPYBIND_MANUAL({
587  auto av = parent->py::template class_<::lola::vx::v2::NeuronBlock::AnalogValues>(
588  parent, "AnalogValues");
589  av.def(
590  "fill", &::lola::vx::v2::NeuronBlock::AnalogValues::fill, "", parent->py::arg("val"));
591  {
592  typedef ::lola::vx::v2::NeuronBlock::AnalogValues::reference (
593  ::lola::vx::v2::NeuronBlock::AnalogValues::*genpybind_at_type)(
594  const ::lola::vx::v2::NeuronBlock::AnalogValues::key_type&);
595  av.def(
596  "at", (genpybind_at_type) & ::lola::vx::v2::NeuronBlock::AnalogValues::at, "",
597  parent->py::arg("key"));
598  }
599  {
600  typedef ::lola::vx::v2::NeuronBlock::AnalogValues::const_reference (
601  ::lola::vx::v2::NeuronBlock::AnalogValues::*genpybind_at_type)(
602  const ::lola::vx::v2::NeuronBlock::AnalogValues::key_type&) const;
603  av.def(
604  "at", (genpybind_at_type) & ::lola::vx::v2::NeuronBlock::AnalogValues::at, "",
605  parent->py::arg("key"));
606  }
607  {
608  typedef ::lola::vx::v2::NeuronBlock::AnalogValues::reference (
609  ::lola::vx::v2::NeuronBlock::AnalogValues::*genpybind_front_type)();
610  av.def(
611  "front", (genpybind_front_type) & ::lola::vx::v2::NeuronBlock::AnalogValues::front,
612  "");
613  }
614  {
615  typedef ::lola::vx::v2::NeuronBlock::AnalogValues::const_reference (
616  ::lola::vx::v2::NeuronBlock::AnalogValues::*genpybind_front_type)() const;
617  av.def(
618  "front", (genpybind_front_type) & ::lola::vx::v2::NeuronBlock::AnalogValues::front,
619  "");
620  }
621  {
622  typedef ::lola::vx::v2::NeuronBlock::AnalogValues::reference (
623  ::lola::vx::v2::NeuronBlock::AnalogValues::*genpybind_back_type)();
624  av.def(
625  "back", (genpybind_back_type) & ::lola::vx::v2::NeuronBlock::AnalogValues::back,
626  "");
627  }
628  {
629  typedef ::lola::vx::v2::NeuronBlock::AnalogValues::const_reference (
630  ::lola::vx::v2::NeuronBlock::AnalogValues::*genpybind_back_type)() const;
631  av.def(
632  "back", (genpybind_back_type) & ::lola::vx::v2::NeuronBlock::AnalogValues::back,
633  "");
634  }
635  av.def(
636  "__getitem__", &::lola::vx::v2::NeuronBlock::AnalogValues::get, "",
637  parent->py::arg("key"), parent->py::return_value_policy::reference);
638  av.def(
639  "__setitem__", &::lola::vx::v2::NeuronBlock::AnalogValues::set, "",
640  parent->py::arg("key"), parent->py::arg("value"));
641  av.def(
642  "__iter__",
643  [av](::lola::vx::v2::NeuronBlock::AnalogValues& self) {
644  return pybind11::make_iterator(self);
645  },
646  parent->py::template keep_alive<0, 1>());
647 
648  av.def("to_numpy", [](::lola::vx::v2::NeuronBlock::AnalogValues const& self) {
649  return ::halco::common::detail::to_numpy(self);
650  });
651  av.def(
652  "from_numpy",
653  [](::lola::vx::v2::NeuronBlock::AnalogValues& self, pybind11::array const& array) {
654  ::halco::common::detail::from_numpy(self, array);
655  });
656  av.def(parent->py::template init<const ::lola::vx::v2::NeuronBlock::AnalogValues&>(), "");
657  av.def(parent->py::template init<>(), "");
658  av.def_property_readonly(
659  "size", parent->py::cpp_function(&::lola::vx::v2::NeuronBlock::AnalogValues::size));
660  av.def_property_readonly(
661  "max_size",
662  parent->py::cpp_function(&::lola::vx::v2::NeuronBlock::AnalogValues::max_size));
663  av.def_property_readonly(
664  "empty", parent->py::cpp_function(&::lola::vx::v2::NeuronBlock::AnalogValues::empty));
665  })
666 private:
667  friend class haldls::vx::detail::VisitPreorderImpl<NeuronBlock>;
668 };
669 
670 } // namespace lola::vx::v2
671 
672 #include "lola/vx/v2/neuron.tcc"
Configuration of digital and analog parameters for a single-denmem neuron.
Definition: neuron.h:14
haldls::vx::v2::CapMemCell::Value AnalogValue
Definition: neuron.h:16
haldls::vx::v2::CapMemCell::DisableRefresh AnalogDisableRefresh
Definition: neuron.h:17
halco::hicann_dls::vx::v2::AtomicNeuronOnDLS coordinate_type
Definition: neuron.h:457
haldls::vx::v2::CapMemCell::value_type AnalogValueVariant
Definition: neuron.h:18
std::false_type has_local_data
Definition: neuron.h:458
#define GENPYBIND_TAG_LOLA_VX_V2
Definition: genpybind.h:5
Definition: cadc.h:465
lola::vx::ColumnCurrentRow ColumnCurrentRow
Definition: synapse.h:8
class lola::vx::v2::AtomicNeuron set_from(haldls::vx::v2::NeuronConfig const &neuron_config) SYMBOL_VISIBLE
haldls::vx::v2::NeuronBackendConfig::AddressOut Address
Definition: neuron.h:270
Definition: neuron.h:48
Multicompartment configuration of connectivity to adjacent neurons.
Definition: neuron.h:127
Definition: neuron.h:77
bool operator==(ConstantCurrent const &other) const SYMBOL_VISIBLE
Type
Sink/source offset current on membrane.
Definition: neuron.h:189
static const EventRouting enabled SYMBOL_VISIBLE
Definition: neuron.h:327
Address address
Lower 8 bit of address sent on event output.
Definition: neuron.h:310
bool enable_bypass_inhibitory
Enable inhibitory bypass circuit.
Definition: neuron.h:307
bool operator!=(EventRouting const &other) const SYMBOL_VISIBLE
EventRouting(AnalogOutputMode analog_output, bool enable_digital, bool enable_bypass_excitatory, bool enable_bypass_inhibitory, Address address, bool enable_post_overwrite) SYMBOL_VISIBLE
bool enable_bypass_excitatory
Enable excitatory bypass circuit.
Definition: neuron.h:304
static const EventRouting bypass_exc SYMBOL_VISIBLE
Definition: neuron.h:328
bool operator==(EventRouting const &other) const SYMBOL_VISIBLE
AnalogOutputMode
Analog output (off/normal/strong) settings.
Definition: neuron.h:294
static const EventRouting bypass_inh SYMBOL_VISIBLE
Definition: neuron.h:329
bool enable_digital
Enable sending a spike packet out of the digital backend.
Definition: neuron.h:301
haldls::vx::v2::NeuronBackendConfig::AddressOut Address
Definition: neuron.h:285
bool enable_post_overwrite
Enable usage of external post pulses reaching the synapses exclusively.
Definition: neuron.h:316
bool enable
Enable exponential term.
Definition: neuron.h:264
AnalogValueVariant v_exp
Threshold voltage for the exponential term.
Definition: neuron.h:267
haldls::vx::v2::NeuronConfig::MembraneCapacitorSize CapacitorSize
Definition: neuron.h:205
Multicompartment configuration of connectivity to adjacent neurons.
Definition: neuron.h:142
bool enable_buffered_access
Connect the readout amplifier's output to the shared readout lines.
Definition: neuron.h:348
haldls::vx::v2::NeuronConfig::ReadoutSource Source
Definition: neuron.h:341
bool enable_amplifier
Enable readout amplifier.
Definition: neuron.h:351
bool enable_unbuffered_access
Enable direct, unbuffered access.
Definition: neuron.h:357
haldls::vx::v2::NeuronBackendConfig::InputClock InputClock
Definition: neuron.h:387
RefractoryTime refractory_time
Counter value to control refractory time.
Definition: neuron.h:413
InputClock input_clock
Select between the two input clocks specified in the common neuron backend.
Definition: neuron.h:396
bool enable_pause
Enable gating of synaptic inputs and exponential term during reset periods.
Definition: neuron.h:418
haldls::vx::v2::NeuronBackendConfig::ResetHoldoff ResetHoldoff
Definition: neuron.h:388
haldls::vx::v2::NeuronBackendConfig::RefractoryTime RefractoryTime
Definition: neuron.h:390
ResetHoldoff reset_holdoff
Release the reset potential before the refractory time ends.
Definition: neuron.h:406
bool operator!=(AtomicNeuron const &other) const SYMBOL_VISIBLE
bool operator==(AtomicNeuron const &other) const SYMBOL_VISIBLE
SynapticInput inhibitory_input
Definition: neuron.h:448
Threshold threshold
Definition: neuron.h:451
Reset reset
Definition: neuron.h:450
MembraneCapacitance membrane_capacitance
Definition: neuron.h:454
friend std::ostream & operator<<(std::ostream &os, AtomicNeuron const &config) SYMBOL_VISIBLE
Leak leak
Definition: neuron.h:449
ConstantCurrent constant_current
Definition: neuron.h:453
EventRouting event_routing
Definition: neuron.h:457
haldls::vx::v2::CapMemCell::DisableRefresh AnalogDisableRefresh
Definition: neuron.h:2
Readout readout
Definition: neuron.h:458
halco::hicann_dls::vx::v2::AtomicNeuronOnDLS coordinate_type
Definition: neuron.h:442
Multicompartment multicompartment
Definition: neuron.h:452
std::false_type has_local_data
Definition: neuron.h:443
haldls::vx::v2::CapMemCell::Value AnalogValue
Definition: neuron.h:1
SynapticInput excitatory_input
Definition: neuron.h:447
RefractoryPeriod refractory_period
Definition: neuron.h:459
haldls::vx::v2::CapMemCell::value_type AnalogValueVariant
Definition: neuron.h:3
Adaptation adaptation
Definition: neuron.h:455
Bayesian bayesian
Definition: neuron.h:460
Exponential exponential
Definition: neuron.h:456
AtomicNeuron() SYMBOL_VISIBLE