HALDLS
synapse_driver.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/synapse_driver.h"
7 #include "haldls/vx/genpybind.h"
10 #include "haldls/vx/traits.h"
11 #include "hate/visibility.h"
12 
13 #ifndef __ppu__
14 #include "haldls/cerealization.h"
15 #include "hxcomm/vx/target.h"
16 #endif
17 
18 namespace fisch::vx {
19 class OmnibusChipOverJTAG;
20 class Omnibus;
21 } // namespace fisch::vx
22 
23 namespace haldls {
24 namespace vx GENPYBIND_TAG_HALDLS_VX {
25 
26 // TODO: Switch to CRTP pattern when https://github.com/kljohann/genpybind/issues/28 is solved
28 {
29 public:
30  typedef halco::hicann_dls::vx::SynapseDriverSRAMTimingConfigOnDLS coordinate_type;
31 #ifndef __ppu__
32  constexpr static auto unsupported_read_targets GENPYBIND(hidden) = {
33  hxcomm::vx::Target::simulation, hxcomm::vx::Target::hardware};
34 #endif
35 
36  bool operator==(SynapseDriverSRAMTimingConfig const& other) const SYMBOL_VISIBLE;
37  bool operator!=(SynapseDriverSRAMTimingConfig const& other) const SYMBOL_VISIBLE;
38 
39  GENPYBIND(stringstream)
40  friend std::ostream& operator<<(std::ostream& os, SynapseDriverSRAMTimingConfig const& config)
41  SYMBOL_VISIBLE;
42 
43  template <typename AddressT>
44  std::array<AddressT, config_size_in_words> addresses(coordinate_type const& word) const
45  SYMBOL_VISIBLE GENPYBIND(hidden);
46 
47 private:
48  friend class cereal::access;
49  template <typename Archive>
50  void serialize(Archive& ar, std::uint32_t);
51 };
52 
53 #ifndef __ppu__
55 #endif
56 
57 namespace detail {
58 
59 template <>
61  : public BackendContainerBase<
62  SynapseDriverSRAMTimingConfig,
63  fisch::vx::word_access_type::Omnibus,
64  fisch::vx::word_access_type::OmnibusChipOverJTAG>
65 {};
66 
67 } // namespace detail
68 
69 class GENPYBIND(visible) SynapseDriverConfig : public DifferentialWriteTrait
70 {
71 public:
72  typedef halco::hicann_dls::vx::SynapseDriverOnDLS coordinate_type;
73  typedef std::true_type is_leaf_node;
74 #ifndef __ppu__
75  constexpr static auto unsupported_read_targets GENPYBIND(hidden) = {
76  hxcomm::vx::Target::simulation};
77 #endif
78 
79  struct GENPYBIND(inline_base("*")) Utilization
80  : public halco::common::detail::RantWrapper<Utilization, uint_fast8_t, 15, 0>
81  {
82  constexpr explicit Utilization(uintmax_t const val = 0) GENPYBIND(implicit_conversion) :
83  rant_t(val)
84  {}
85  };
86 
87  struct GENPYBIND(inline_base("*")) Offset
88  : public halco::common::detail::RantWrapper<Offset, uint_fast8_t, 15, 0>
89  {
90  constexpr explicit Offset(uintmax_t const val = 0) GENPYBIND(implicit_conversion) :
91  rant_t(val)
92  {}
93  };
94 
95  struct GENPYBIND(inline_base("*")) Recovery
96  : public halco::common::detail::RantWrapper<Recovery, uint_fast8_t, 15, 0>
97  {
98  constexpr explicit Recovery(uintmax_t const val = 0) GENPYBIND(implicit_conversion) :
99  rant_t(val)
100  {}
101  };
102 
103  struct GENPYBIND(inline_base("*")) HagenDACOffset
104  : public halco::common::detail::RantWrapper<HagenDACOffset, uint_fast8_t, 63, 0>
105  {
106  constexpr explicit HagenDACOffset(uintmax_t const val = 0) GENPYBIND(implicit_conversion) :
107  rant_t(val)
108  {}
109  };
110 
111  struct GENPYBIND(inline_base("*")) TargetVoltages
112  : public halco::common::detail::RantWrapper<TargetVoltages, uint_fast8_t, 1, 0>
113  {
114  constexpr explicit TargetVoltages(uintmax_t const val = 0) GENPYBIND(implicit_conversion) :
115  rant_t(val)
116  {}
117  };
118 
119  struct GENPYBIND(inline_base("*")) RowAddressCompareMask
120  : public halco::common::detail::RantWrapper<RowAddressCompareMask, uint_fast8_t, 31, 0>
121  {
122  constexpr explicit RowAddressCompareMask(uintmax_t const val = 0b11111)
123  GENPYBIND(implicit_conversion) :
124  rant_t(val)
125  {}
126  };
127 
128  enum class GENPYBIND(visible) RowMode
129  {
130  disabled,
131  excitatory,
132  inhibitory,
133  excitatory_and_inhibitory
134  };
135 
136  SynapseDriverConfig() SYMBOL_VISIBLE;
137 
138  // accessors
139 
141  GENPYBIND(getter_for(enable_receiver))
142  bool get_enable_receiver() const SYMBOL_VISIBLE;
143  GENPYBIND(setter_for(enable_receiver))
144  void set_enable_receiver(bool const value) SYMBOL_VISIBLE;
145 
154  GENPYBIND(getter_for(row_address_compare_mask))
155  RowAddressCompareMask get_row_address_compare_mask() const SYMBOL_VISIBLE;
156  GENPYBIND(setter_for(row_address_compare_mask))
157  void set_row_address_compare_mask(RowAddressCompareMask const value) SYMBOL_VISIBLE;
158 
163  GENPYBIND(getter_for(enable_address_out))
164  bool get_enable_address_out() const SYMBOL_VISIBLE;
165  GENPYBIND(setter_for(enable_address_out))
166  void set_enable_address_out(bool const value) SYMBOL_VISIBLE;
167 
169  GENPYBIND(getter_for(utilization))
170  Utilization get_utilization() const SYMBOL_VISIBLE;
171  GENPYBIND(setter_for(utilization))
172  void set_utilization(Utilization const value) SYMBOL_VISIBLE;
173 
175  GENPYBIND(getter_for(offset))
176  Offset get_offset() const SYMBOL_VISIBLE;
177  GENPYBIND(setter_for(offset))
178  void set_offset(Offset const value) SYMBOL_VISIBLE;
179 
181  GENPYBIND(getter_for(enable_hagen_dac))
182  bool get_enable_hagen_dac() const SYMBOL_VISIBLE;
183  GENPYBIND(setter_for(enable_hagen_dac))
184  void set_enable_hagen_dac(bool value) SYMBOL_VISIBLE;
185 
187  GENPYBIND(getter_for(recovery))
188  Recovery get_recovery() const SYMBOL_VISIBLE;
189  GENPYBIND(setter_for(recovery))
190  void set_recovery(Recovery const value) SYMBOL_VISIBLE;
191 
193  GENPYBIND(getter_for(row_mode_bottom))
194  RowMode get_row_mode_bottom() const SYMBOL_VISIBLE;
195  GENPYBIND(setter_for(row_mode_bottom))
196  void set_row_mode_bottom(RowMode value) SYMBOL_VISIBLE;
197 
199  GENPYBIND(getter_for(row_mode_top))
200  RowMode get_row_mode_top() const SYMBOL_VISIBLE;
201  GENPYBIND(setter_for(row_mode_top))
202  void set_row_mode_top(RowMode value) SYMBOL_VISIBLE;
203 
209  GENPYBIND(getter_for(hagen_dac_offset))
210  HagenDACOffset get_hagen_dac_offset() const SYMBOL_VISIBLE;
211  GENPYBIND(setter_for(hagen_dac_offset))
212  void set_hagen_dac_offset(HagenDACOffset value) SYMBOL_VISIBLE;
213 
223  GENPYBIND(getter_for(select_target_voltages))
224  TargetVoltages get_select_target_voltages() const SYMBOL_VISIBLE;
225  GENPYBIND(setter_for(select_target_voltages))
226  void set_select_target_voltages(TargetVoltages const value) SYMBOL_VISIBLE;
227 
236  GENPYBIND(getter_for(enable_readout))
237  bool get_enable_readout() const SYMBOL_VISIBLE;
238  GENPYBIND(setter_for(enable_readout))
239  void set_enable_readout(bool const value) SYMBOL_VISIBLE;
240 
242  GENPYBIND(getter_for(enable_renewing))
243  bool get_enable_renewing() const SYMBOL_VISIBLE;
244  GENPYBIND(setter_for(enable_renewing))
245  void set_enable_renewing(bool const value) SYMBOL_VISIBLE;
246 
254  GENPYBIND(getter_for(enable_hagen_modulation))
255  bool get_enable_hagen_modulation() const SYMBOL_VISIBLE;
256  GENPYBIND(setter_for(enable_hagen_modulation))
257  void set_enable_hagen_modulation(bool const value) SYMBOL_VISIBLE;
258 
260  GENPYBIND(getter_for(enable_stp))
261  bool get_enable_stp() const SYMBOL_VISIBLE;
262  GENPYBIND(setter_for(enable_stp))
263  void set_enable_stp(bool const value) SYMBOL_VISIBLE;
264 
266  GENPYBIND(getter_for(enable_charge_sharing))
267  bool get_enable_charge_sharing() const SYMBOL_VISIBLE;
268  GENPYBIND(setter_for(enable_charge_sharing))
269  void set_enable_charge_sharing(bool const value) SYMBOL_VISIBLE;
270 
272  GENPYBIND(getter_for(enable_recovery))
273  bool get_enable_recovery() const SYMBOL_VISIBLE;
274  GENPYBIND(setter_for(enable_recovery))
275  void set_enable_recovery(bool const value) SYMBOL_VISIBLE;
276 
277  bool operator==(SynapseDriverConfig const& other) const SYMBOL_VISIBLE;
278  bool operator!=(SynapseDriverConfig const& other) const SYMBOL_VISIBLE;
279 
280  static size_t constexpr config_size_in_words GENPYBIND(hidden) = 3;
281  template <typename AddressT>
282  static std::array<AddressT, config_size_in_words> addresses(
283  coordinate_type const& synapse_driver) SYMBOL_VISIBLE GENPYBIND(hidden);
284  template <typename WordT>
285  std::array<WordT, config_size_in_words> encode() const SYMBOL_VISIBLE GENPYBIND(hidden);
286  template <typename WordT>
287  void decode(std::array<WordT, config_size_in_words> const& data) SYMBOL_VISIBLE
288  GENPYBIND(hidden);
289 
290  GENPYBIND(stringstream)
291  friend std::ostream& operator<<(std::ostream& os, SynapseDriverConfig const& config)
292  SYMBOL_VISIBLE;
293 
294 private:
295  friend class cereal::access;
296  template <class Archive>
297  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE;
298 
299  struct SynapseDriverConfigBitfield;
300 
301  SynapseDriverConfigBitfield to_bitfield() const;
302  void from_bitfield(SynapseDriverConfigBitfield const& bitfield);
303 
304  bool m_en_receiver;
305  RowAddressCompareMask m_row_address_compare_mask;
306  bool m_en_address_out;
307  Utilization m_utilization;
308  Offset m_offset;
309  bool m_en_hagen_dac;
310  Recovery m_recovery;
311  RowMode m_row_mode_bottom;
312  RowMode m_row_mode_top;
313  HagenDACOffset m_hagen_dac_offset;
314  TargetVoltages m_select_target_voltages;
315  bool m_en_readout;
316  bool m_en_renewing;
317  bool m_en_hagen_modulation;
318  bool m_en_stp;
319  bool m_en_charge_sharing;
320  bool m_en_recovery;
321 };
322 
323 std::ostream& operator<<(std::ostream& os, SynapseDriverConfig::RowMode const& mode) SYMBOL_VISIBLE;
324 
325 #ifndef __ppu__
326 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(haldls::vx::SynapseDriverConfig)
327 #endif
328 
329 namespace detail {
330 
331 template <>
332 struct BackendContainerTrait<SynapseDriverConfig>
333  : public BackendContainerBase<
334  SynapseDriverConfig,
335  fisch::vx::word_access_type::Omnibus,
336  fisch::vx::word_access_type::OmnibusChipOverJTAG>
337 {};
338 
339 } // namespace detail
340 
341 } // namespace vx
342 } // namespace haldls
#define EXTERN_INSTANTIATE_CEREAL_SERIALIZE(CLASS_NAME)
Definition: cerealization.h:75
Trait signalling derived-from container type support differential write operation.
Definition: traits.h:17
halco::hicann_dls::vx::SynapseDriverOnDLS coordinate_type
bool operator!=(SynapseDriverSRAMTimingConfig const &other) const SYMBOL_VISIBLE
halco::hicann_dls::vx::SynapseDriverSRAMTimingConfigOnDLS coordinate_type
bool operator==(SynapseDriverSRAMTimingConfig const &other) const SYMBOL_VISIBLE
Configuration of full-custom SRAM timing.
#define GENPYBIND_TAG_HALDLS_VX
Definition: genpybind.h:4
Backend container trait base.
Definition: traits.h:77