HALDLS
background.h
Go to the documentation of this file.
1 #pragma once
2 #include <array>
3 #include <iosfwd>
4 
5 #include "halco/common/geometry.h"
6 #include "halco/hicann-dls/vx/background.h"
7 #include "halco/hicann-dls/vx/event.h"
8 
9 #include "haldls/cerealization.h"
10 #include "haldls/vx/genpybind.h"
11 #include "haldls/vx/traits.h"
12 #include "hate/math.h"
13 #include "hate/visibility.h"
14 
15 #ifndef __ppu__
16 #include "hxcomm/vx/target.h"
17 #endif
18 
19 namespace fisch::vx {
20 class OmnibusChipOverJTAG;
21 class Omnibus;
22 } // namespace fisch::vx
23 
24 namespace haldls {
25 namespace vx GENPYBIND_TAG_HALDLS_VX {
26 
35 class GENPYBIND(visible) BackgroundSpikeSource
36 {
37 public:
38  typedef halco::hicann_dls::vx::BackgroundSpikeSourceOnDLS 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::hardware, hxcomm::vx::Target::simulation};
43 #endif
44 
49  struct GENPYBIND(inline_base("*")) Period
50  : public halco::common::detail::
51  RantWrapper<Period, uint_fast32_t, hate::math::pow(2, 16) - 1, 0>
52  {
53  constexpr explicit Period(uintmax_t const val = 0)
54  GENPYBIND(implicit_conversion) : rant_t(val)
55  {}
56  };
57 
64  struct GENPYBIND(inline_base("*")) Rate
65  : public halco::common::detail::
66  RantWrapper<Rate, uint_fast16_t, hate::math::pow(2, 8) - 1, 0>
67  {
68  constexpr explicit Rate(uintmax_t const val = 0)
69  GENPYBIND(implicit_conversion) : rant_t(val)
70  {}
71  };
72 
77  struct GENPYBIND(inline_base("*")) Seed
78  : public halco::common::detail::
79  RantWrapper<Seed, uint_fast64_t, hate::math::pow(2, 32) - 1, 0>
80  {
81  constexpr explicit Seed(uintmax_t const val = 0)
82  GENPYBIND(implicit_conversion) : rant_t(val)
83  {}
84  };
85 
92  struct GENPYBIND(inline_base("*")) Mask
93  : public halco::common::detail::
94  RantWrapper<Mask, uint_fast16_t, hate::math::pow(2, 8) - 1, 0>
95  {
96  constexpr explicit Mask(uintmax_t const val = 0)
97  GENPYBIND(implicit_conversion) : rant_t(val)
98  {}
99  };
100 
102  BackgroundSpikeSource() SYMBOL_VISIBLE;
103 
111  GENPYBIND(getter_for(enable))
112  bool get_enable() const SYMBOL_VISIBLE;
113 
121  GENPYBIND(setter_for(enable))
122  void set_enable(bool value) SYMBOL_VISIBLE;
123 
131  GENPYBIND(getter_for(enable_random))
132  bool get_enable_random() const SYMBOL_VISIBLE;
133 
141  GENPYBIND(setter_for(enable_random))
142  void set_enable_random(bool value) SYMBOL_VISIBLE;
143 
149  GENPYBIND(getter_for(period))
150  Period get_period() const SYMBOL_VISIBLE;
151 
157  GENPYBIND(setter_for(period))
158  void set_period(Period const& value) SYMBOL_VISIBLE;
159 
165  GENPYBIND(getter_for(rate))
166  Rate get_rate() const SYMBOL_VISIBLE;
167 
173  GENPYBIND(setter_for(rate))
174  void set_rate(Rate const& value) SYMBOL_VISIBLE;
175 
181  GENPYBIND(getter_for(seed))
182  Seed get_seed() const SYMBOL_VISIBLE;
183 
189  GENPYBIND(setter_for(seed))
190  void set_seed(Seed const& value) SYMBOL_VISIBLE;
191 
197  GENPYBIND(getter_for(mask))
198  Mask get_mask() const SYMBOL_VISIBLE;
199 
205  GENPYBIND(setter_for(mask))
206  void set_mask(Mask const& value) SYMBOL_VISIBLE;
207 
214  GENPYBIND(getter_for(neuron_label))
215  halco::hicann_dls::vx::NeuronLabel get_neuron_label() const SYMBOL_VISIBLE;
216 
223  GENPYBIND(setter_for(neuron_label))
224  void set_neuron_label(halco::hicann_dls::vx::NeuronLabel const& value) SYMBOL_VISIBLE;
225 
226  bool operator==(BackgroundSpikeSource const& other) const SYMBOL_VISIBLE;
227  bool operator!=(BackgroundSpikeSource const& other) const SYMBOL_VISIBLE;
228 
229  static size_t constexpr config_size_in_words GENPYBIND(hidden) = 3;
230  template <typename AddressT>
231  static std::array<AddressT, config_size_in_words> addresses(coordinate_type const& neuron)
232  SYMBOL_VISIBLE GENPYBIND(hidden);
233  template <typename WordT>
234  std::array<WordT, config_size_in_words> encode() const SYMBOL_VISIBLE GENPYBIND(hidden);
235  template <typename WordT>
236  void decode(std::array<WordT, config_size_in_words> const& data) SYMBOL_VISIBLE
237  GENPYBIND(hidden);
238 
239  GENPYBIND(stringstream)
240  friend std::ostream& operator<<(std::ostream& os, BackgroundSpikeSource const& config)
241  SYMBOL_VISIBLE;
242 
243 private:
244  friend class cereal::access;
245  template <class Archive>
246  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE;
247 
248  bool m_enable;
249  bool m_enable_random;
250  Period m_period;
251  Rate m_rate;
252  Seed m_seed;
253  Mask m_mask;
254  halco::hicann_dls::vx::NeuronLabel m_neuron_label;
255 };
256 
257 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(BackgroundSpikeSource)
258 
259 namespace detail {
260 
261 template <>
262 struct BackendContainerTrait<BackgroundSpikeSource>
263  : public BackendContainerBase<
264  BackgroundSpikeSource,
265  fisch::vx::word_access_type::Omnibus,
266  fisch::vx::word_access_type::OmnibusChipOverJTAG>
267 {};
268 
269 } // namespace detail
270 
271 } // namespace vx
272 } // namespace haldls
Background spike source on chip.
Definition: background.h:36
halco::hicann_dls::vx::BackgroundSpikeSourceOnDLS coordinate_type
Definition: background.h:38
#define GENPYBIND_TAG_HALDLS_VX
Definition: genpybind.h:4