HALDLS
event.h
Go to the documentation of this file.
1 #pragma once
2 #include "fisch/vx/event.h"
3 #include "halco/common/geometry.h"
4 #include "halco/hicann-dls/vx/event.h"
5 #include "halco/hicann-dls/vx/highspeed_link.h"
6 #include "halco/hicann-dls/vx/readout.h"
7 #include "haldls/cerealization.h"
8 #include "haldls/vx/genpybind.h"
9 #include "haldls/vx/neuron.h"
10 #include "haldls/vx/padi.h"
11 #include "haldls/vx/synapse.h"
12 #include "haldls/vx/traits.h"
13 #include "hate/visibility.h"
14 
16 
17 struct GENPYBIND(inline_base("*")) SpikeLabel
18  : public halco::common::detail::BaseType<SpikeLabel, uint16_t>
19 {
20  constexpr explicit SpikeLabel(value_type const value = value_type()) : base_t(value) {}
21 
23  GENPYBIND(getter_for(spl1_address))
24  halco::hicann_dls::vx::SPL1Address get_spl1_address() const SYMBOL_VISIBLE;
25  GENPYBIND(setter_for(spl1_address))
26  void set_spl1_address(halco::hicann_dls::vx::SPL1Address value) SYMBOL_VISIBLE;
27 
29  GENPYBIND(getter_for(neuron_label))
30  halco::hicann_dls::vx::NeuronLabel get_neuron_label() const SYMBOL_VISIBLE;
31  GENPYBIND(setter_for(neuron_label))
32  void set_neuron_label(halco::hicann_dls::vx::NeuronLabel value) SYMBOL_VISIBLE;
33 
35  struct GENPYBIND(inline_base("*")) PADILabel
36  : public halco::common::detail::RantWrapper<PADILabel, uint_fast16_t, 0x3ff, 0>
37  {
38  constexpr explicit PADILabel(uintmax_t const val = 0) GENPYBIND(implicit_conversion) :
39  rant_t(val)
40  {}
41  };
42 
44  GENPYBIND(getter_for(padi_label))
45  PADILabel get_padi_label() const SYMBOL_VISIBLE;
46  GENPYBIND(setter_for(padi_label))
47  void set_padi_label(PADILabel value) SYMBOL_VISIBLE;
48 
50  GENPYBIND(getter_for(neuron_event_output))
51  halco::hicann_dls::vx::NeuronEventOutputOnDLS get_neuron_event_output() const SYMBOL_VISIBLE;
52  GENPYBIND(setter_for(neuron_event_output))
53  void set_neuron_event_output(halco::hicann_dls::vx::NeuronEventOutputOnDLS value)
54  SYMBOL_VISIBLE;
55 
57  GENPYBIND(getter_for(neuron_backend_address_out))
58  NeuronBackendAddressOut get_neuron_backend_address_out() const SYMBOL_VISIBLE;
59  GENPYBIND(setter_for(neuron_backend_address_out))
60  void set_neuron_backend_address_out(NeuronBackendAddressOut value) SYMBOL_VISIBLE;
61 
63  GENPYBIND(getter_for(row_select_address))
64  PADIEvent::RowSelectAddress get_row_select_address() const SYMBOL_VISIBLE;
65  GENPYBIND(setter_for(row_select_address))
66  void set_row_select_address(PADIEvent::RowSelectAddress) SYMBOL_VISIBLE;
67 
69  GENPYBIND(getter_for(synapse_label))
70  SynapseLabelValue get_synapse_label() const SYMBOL_VISIBLE;
71  GENPYBIND(setter_for(synapse_label))
72  void set_synapse_label(SynapseLabelValue value) SYMBOL_VISIBLE;
73 };
74 
75 #define SpikePackToChip(Num) \
76  class GENPYBIND(visible) SpikePack##Num##ToChip \
77  { \
78  public: \
79  typedef halco::hicann_dls::vx::SpikePack##Num##ToChipOnDLS coordinate_type; \
80  typedef std::true_type is_leaf_node; \
81  \
82  typedef std::array<SpikeLabel, Num> labels_type; \
83  \ \
85  SpikePack##Num##ToChip() SYMBOL_VISIBLE; \
86  \ \
91  explicit SpikePack##Num##ToChip(labels_type const& labels) SYMBOL_VISIBLE; \
92  \ \
97  GENPYBIND(getter_for(labels)) \
98  labels_type get_labels() const SYMBOL_VISIBLE; \
99  \ \
104  GENPYBIND(setter_for(labels)) \
105  void set_labels(labels_type const& value) SYMBOL_VISIBLE; \
106  \
107  bool operator==(SpikePack##Num##ToChip const& other) const SYMBOL_VISIBLE; \
108  bool operator!=(SpikePack##Num##ToChip const& other) const SYMBOL_VISIBLE; \
109  \
110  GENPYBIND(stringstream) \
111  friend std::ostream& operator<<(std::ostream& os, SpikePack##Num##ToChip const& config) \
112  SYMBOL_VISIBLE; \
113  \
114  constexpr static size_t GENPYBIND(hidden) write_config_size_in_words = 1; \
115  constexpr static size_t GENPYBIND(hidden) read_config_size_in_words = 0; \
116  static std:: \
117  array<halco::hicann_dls::vx::SpikePack##Num##ToChipOnDLS, write_config_size_in_words> \
118  write_addresses(coordinate_type const& word) SYMBOL_VISIBLE GENPYBIND(hidden); \
119  static std:: \
120  array<halco::hicann_dls::vx::SpikePack##Num##ToChipOnDLS, read_config_size_in_words> \
121  read_addresses(coordinate_type const& word) SYMBOL_VISIBLE GENPYBIND(hidden); \
122  std:: \
123  array<fisch::vx::word_access_type::SpikePack##Num##ToChip, write_config_size_in_words> \
124  encode() const SYMBOL_VISIBLE GENPYBIND(hidden); \
125  void decode(std::array< \
126  fisch::vx::word_access_type::SpikePack##Num##ToChip, \
127  read_config_size_in_words> const& data) SYMBOL_VISIBLE GENPYBIND(hidden); \
128  \
129  private: \
130  friend class cereal::access; \
131  template <class Archive> \
132  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE; \
133  \
134  labels_type m_impl; \
135  }; \
136  \
137  EXTERN_INSTANTIATE_CEREAL_SERIALIZE(SpikePack##Num##ToChip) \
138  \
139  namespace detail { \
140  \
141  template <> \
142  struct BackendContainerTrait<SpikePack##Num##ToChip> \
143  : public BackendContainerBase< \
144  SpikePack##Num##ToChip, \
145  fisch::vx::word_access_type::SpikePack##Num##ToChip> \
146  {}; \
147  \
148  } // namespace detail
149 
150 // clang-format off
151 SpikePackToChip(1)
152 SpikePackToChip(2)
153 SpikePackToChip(3)
154 // clang-format on
155 
156 #undef SpikePackToChip
157 
158 
159 typedef fisch::vx::FPGATime FPGATime GENPYBIND(visible);
160 typedef fisch::vx::ChipTime ChipTime GENPYBIND(visible);
161 
162 namespace detail {
163  struct SpikeFromChipChecker;
164 }
165 
170 class GENPYBIND(visible) SpikeFromChip
171 {
172 public:
174  SpikeFromChip() = default;
175 
182  SpikeFromChip(SpikeLabel const& label, FPGATime const& fpga_time, ChipTime const& chip_time) :
183  label(label), fpga_time(fpga_time), chip_time(chip_time)
184  {}
185 
190  SpikeFromChip(fisch::vx::SpikeFromChip const& data) :
191  label(data.label), fpga_time(data.fpga_time), chip_time(data.chip_time)
192  {}
193 
197  SpikeLabel label;
198 
202  FPGATime fpga_time;
203 
207  ChipTime chip_time;
208 
209  bool operator==(SpikeFromChip const& other) const SYMBOL_VISIBLE;
210  bool operator!=(SpikeFromChip const& other) const SYMBOL_VISIBLE;
211 
212  GENPYBIND(stringstream)
213  friend std::ostream& operator<<(std::ostream& os, SpikeFromChip const& spike) SYMBOL_VISIBLE;
214 
215 private:
216  friend class cereal::access;
217  template <typename Archive>
218  void serialize(Archive& ar, std::uint32_t const version);
219 
220 public:
221  friend struct detail::SpikeFromChipChecker;
222  // packing of structs and pods seems different
223  struct __attribute__((packed)) GENPYBIND(hidden) SpikeFromChipDType
224  {
225  uint16_t label;
226  uint64_t fpga_time;
227  uint64_t chip_time;
228  };
229 };
230 
231 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(SpikeFromChip)
232 
233 namespace detail {
234 
235 struct SpikeFromChipChecker {
236  static_assert(sizeof(SpikeFromChip::SpikeFromChipDType::label) == sizeof(SpikeFromChip::label));
237  static_assert(
238  sizeof(SpikeFromChip::SpikeFromChipDType::fpga_time) == sizeof(SpikeFromChip::fpga_time));
239  static_assert(
240  sizeof(SpikeFromChip::SpikeFromChipDType::chip_time) == sizeof(SpikeFromChip::chip_time));
241  static_assert(sizeof(SpikeFromChip::SpikeFromChipDType) == sizeof(SpikeFromChip));
242  static_assert(
243  offsetof(SpikeFromChip::SpikeFromChipDType, label) == offsetof(SpikeFromChip, label));
244  static_assert(
245  offsetof(SpikeFromChip::SpikeFromChipDType, fpga_time) ==
246  offsetof(SpikeFromChip, fpga_time));
247  static_assert(
248  offsetof(SpikeFromChip::SpikeFromChipDType, chip_time) ==
249  offsetof(SpikeFromChip, chip_time));
250 };
251 
252 } // namespace detail
253 
254 
255 namespace detail {
256 struct MADCSampleFromChipChecker;
257 }
258 
263 class GENPYBIND(visible) MADCSampleFromChip
264 {
265 public:
267  struct GENPYBIND(inline_base("*")) Value
268  : public halco::common::detail::RantWrapper<Value, uint16_t, 0x3ff, 0>
269  {
270  constexpr explicit Value(uintmax_t const val = 0) : rant_t(val) {}
271  };
272 
274  typedef halco::hicann_dls::vx::SourceMultiplexerOnReadoutSourceSelection Channel
275  GENPYBIND(opaque(false));
276 
278  MADCSampleFromChip() = default;
279 
287  MADCSampleFromChip(
288  Value const& value,
289  Channel const& channel,
290  FPGATime const& fpga_time,
291  ChipTime const& chip_time) :
292  value(value), channel(channel), fpga_time(fpga_time), chip_time(chip_time)
293  {}
294 
299  MADCSampleFromChip(fisch::vx::MADCSampleFromChip const& data) :
300  value(data.value),
301  channel(data.channel),
302  fpga_time(data.fpga_time),
303  chip_time(data.chip_time)
304  {}
305 
309  Value value;
310 
314  Channel channel;
315 
319  FPGATime fpga_time;
320 
324  ChipTime chip_time;
325 
326  bool operator==(MADCSampleFromChip const& other) const SYMBOL_VISIBLE;
327  bool operator!=(MADCSampleFromChip const& other) const SYMBOL_VISIBLE;
328 
329  GENPYBIND(stringstream)
330  friend std::ostream& operator<<(std::ostream& os, MADCSampleFromChip const& sample)
331  SYMBOL_VISIBLE;
332 
333 private:
334  friend class cereal::access;
335  template <typename Archive>
336  void serialize(Archive& ar, std::uint32_t const version);
337 
338 public:
339  friend struct detail::MADCSampleFromChipChecker;
340  // packing of structs and pods seems different
341  struct __attribute__((packed)) GENPYBIND(hidden) MADCSampleFromChipDType
342  {
343  uint16_t value;
344  uint8_t channel;
345  uint64_t fpga_time;
346  uint64_t chip_time;
347  };
348 };
349 
350 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(MADCSampleFromChip)
351 
352 namespace detail {
353 
354 struct MADCSampleFromChipChecker
355 {
356  static_assert(
357  sizeof(MADCSampleFromChip::MADCSampleFromChipDType::value) ==
358  sizeof(MADCSampleFromChip::value));
359  static_assert(
360  sizeof(MADCSampleFromChip::MADCSampleFromChipDType::channel) ==
361  sizeof(MADCSampleFromChip::channel));
362  static_assert(
363  sizeof(MADCSampleFromChip::MADCSampleFromChipDType::fpga_time) ==
364  sizeof(MADCSampleFromChip::fpga_time));
365  static_assert(
366  sizeof(MADCSampleFromChip::MADCSampleFromChipDType::chip_time) ==
367  sizeof(MADCSampleFromChip::chip_time));
368  static_assert(
369  sizeof(MADCSampleFromChip::MADCSampleFromChipDType) == sizeof(MADCSampleFromChip));
370  static_assert(
371  offsetof(MADCSampleFromChip::MADCSampleFromChipDType, value) ==
372  offsetof(MADCSampleFromChip, value));
373  static_assert(
374  offsetof(MADCSampleFromChip::MADCSampleFromChipDType, channel) ==
375  offsetof(MADCSampleFromChip, channel));
376  static_assert(
377  offsetof(MADCSampleFromChip::MADCSampleFromChipDType, fpga_time) ==
378  offsetof(MADCSampleFromChip, fpga_time));
379  static_assert(
380  offsetof(MADCSampleFromChip::MADCSampleFromChipDType, chip_time) ==
381  offsetof(MADCSampleFromChip, chip_time));
382 };
383 
384 } // namespace detail
385 
386 
390 class GENPYBIND(visible) HighspeedLinkNotification
391 {
392 public:
394  HighspeedLinkNotification() = default;
395 
400  HighspeedLinkNotification(fisch::vx::HighspeedLinkNotification const& data) SYMBOL_VISIBLE;
401 
406  GENPYBIND(getter_for(phy))
407  halco::hicann_dls::vx::PhyStatusOnFPGA get_phy() const SYMBOL_VISIBLE;
408 
413  GENPYBIND(setter_for(phy))
414  void set_phy(halco::hicann_dls::vx::PhyStatusOnFPGA value) SYMBOL_VISIBLE;
415 
420  GENPYBIND(getter_for(link_up))
421  bool get_link_up() const SYMBOL_VISIBLE;
422 
427  GENPYBIND(setter_for(link_up))
428  void set_link_up(bool value) SYMBOL_VISIBLE;
429 
434  GENPYBIND(getter_for(decode_error))
435  bool get_decode_error() const SYMBOL_VISIBLE;
436 
441  GENPYBIND(setter_for(decode_error))
442  void set_decode_error(bool value) SYMBOL_VISIBLE;
443 
448  GENPYBIND(getter_for(crc_error))
449  bool get_crc_error() const SYMBOL_VISIBLE;
450 
455  GENPYBIND(setter_for(crc_error))
456  void set_crc_error(bool value) SYMBOL_VISIBLE;
457 
462  GENPYBIND(getter_for(crc_recover))
463  bool get_crc_recover() const SYMBOL_VISIBLE;
464 
469  GENPYBIND(setter_for(crc_recover))
470  void set_crc_recover(bool value) SYMBOL_VISIBLE;
471 
476  GENPYBIND(getter_for(check_error))
477  bool get_check_error() const SYMBOL_VISIBLE;
478 
483  GENPYBIND(setter_for(check_error))
484  void set_check_error(bool value) SYMBOL_VISIBLE;
485 
490  GENPYBIND(getter_for(fpga_time))
491  FPGATime get_fpga_time() const SYMBOL_VISIBLE;
492 
497  GENPYBIND(setter_for(fpga_time))
498  void set_fpga_time(FPGATime value) SYMBOL_VISIBLE;
499 
500  bool operator==(HighspeedLinkNotification const& other) const SYMBOL_VISIBLE;
501  bool operator!=(HighspeedLinkNotification const& other) const SYMBOL_VISIBLE;
502 
503  GENPYBIND(stringstream)
504  friend std::ostream& operator<<(std::ostream& os, HighspeedLinkNotification const& sample)
505  SYMBOL_VISIBLE;
506 
507 private:
508  friend class cereal::access;
509  template <typename Archive>
510  void serialize(Archive& ar, std::uint32_t const version);
511 
512  halco::hicann_dls::vx::PhyStatusOnFPGA m_phy{};
513  bool m_link_up{false};
514  bool m_decode_error{false};
515  bool m_crc_error{false};
516  bool m_crc_recover{false};
517  bool m_check_error{false};
518  FPGATime m_fpga_time{};
519 };
520 
521 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(HighspeedLinkNotification)
522 
523 } // namespace haldls::vx
524 
525 namespace std {
526 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::SpikeLabel)
527 } // namespace std
#define GENPYBIND_TAG_HALDLS_VX
Definition: genpybind.h:4