HALDLS
correlation.h
Go to the documentation of this file.
1 #pragma once
2 #include "halco/common/geometry.h"
3 #include "halco/common/typed_array.h"
4 #include "halco/hicann-dls/vx/capmem.h"
5 #include "halco/hicann-dls/vx/correlation.h"
6 #include "haldls/vx/genpybind.h"
7 #include "haldls/vx/traits.h"
8 #include "hate/math.h"
9 #include "hate/visibility.h"
10 
11 #ifndef __ppu__
12 #include "haldls/cerealization.h"
13 #include <cereal/cereal.hpp>
14 #endif
15 
17 class Omnibus;
18 class OmnibusChipOverJTAG;
19 } // namespace fisch::vx::word_access_type
20 
22 
26 class GENPYBIND(visible) CommonCorrelationConfig
27 {
28 public:
29  typedef std::true_type is_leaf_node;
30  typedef halco::hicann_dls::vx::CommonCorrelationConfigOnDLS coordinate_type;
31 
36  struct GENPYBIND(inline_base("*")) SenseDelay
37  : public halco::common::detail::
38  RantWrapper<SenseDelay, uint_fast16_t, hate::math::pow(2, 12) - 1, 0>
39  {
40  constexpr explicit SenseDelay(uintmax_t const val = 1) GENPYBIND(implicit_conversion) :
41  rant_t(val)
42  {}
43  };
44 
49  struct GENPYBIND(inline_base("*")) ResetDuration
50  : public halco::common::detail::
51  RantWrapper<ResetDuration, uint_fast16_t, hate::math::pow(2, 12) - 1, 0>
52  {
53  constexpr explicit ResetDuration(uintmax_t const val = 200) GENPYBIND(implicit_conversion) :
54  rant_t(val)
55  {}
56  };
57 
61  struct GENPYBIND(inline_base("*")) ResetFallTime
62  : public halco::common::detail::
63  RantWrapper<ResetFallTime, uint_fast16_t, hate::math::pow(2, 12) - 1, 0>
64  {
65  constexpr explicit ResetFallTime(uintmax_t const val = 5) GENPYBIND(implicit_conversion) :
66  rant_t(val)
67  {}
68  };
69 
71  enum class ResetMode : uint_fast8_t
72  {
73  normal = 0b0,
74  auto_calibrating = 0b1
75  };
76 
78  typedef halco::common::typed_array<
79  halco::hicann_dls::vx::CapMemBlockOnHemisphere,
80  halco::hicann_dls::vx::CapMemBlockOnHemisphere>
81  RampOffsets GENPYBIND(opaque(false));
82 
84  CommonCorrelationConfig() SYMBOL_VISIBLE;
85 
90  GENPYBIND(getter_for(sense_delay))
91  SenseDelay get_sense_delay() const SYMBOL_VISIBLE;
92  GENPYBIND(setter_for(sense_delay))
93  void set_sense_delay(SenseDelay value) SYMBOL_VISIBLE;
94 
99  GENPYBIND(getter_for(reset_duration))
100  ResetDuration get_reset_duration() const SYMBOL_VISIBLE;
101  GENPYBIND(setter_for(reset_duration))
102  void set_reset_duration(ResetDuration value) SYMBOL_VISIBLE;
103 
107  GENPYBIND(getter_for(reset_fall_time))
108  ResetFallTime get_reset_fall_time() const SYMBOL_VISIBLE;
109  GENPYBIND(setter_for(reset_fall_time))
110  void set_reset_fall_time(ResetFallTime value) SYMBOL_VISIBLE;
111 
116  GENPYBIND(getter_for(reset_mode))
117  ResetMode get_reset_mode() const SYMBOL_VISIBLE;
118  GENPYBIND(setter_for(reset_mode))
119  void set_reset_mode(ResetMode value) SYMBOL_VISIBLE;
120 
127  GENPYBIND(getter_for(cadc_v_offset_assignment), return_value_policy(reference))
128  RampOffsets const& get_cadc_v_offset_assignment() const SYMBOL_VISIBLE;
129  GENPYBIND(setter_for(cadc_v_offset_assignment))
130  void set_cadc_v_offset_assignment(RampOffsets const& value) SYMBOL_VISIBLE;
131 
132  bool operator==(CommonCorrelationConfig const& other) const SYMBOL_VISIBLE;
133  bool operator!=(CommonCorrelationConfig const& other) const SYMBOL_VISIBLE;
134 
135  GENPYBIND(stringstream)
136  friend std::ostream& operator<<(std::ostream& os, CommonCorrelationConfig const& config)
137  SYMBOL_VISIBLE;
138 
139  static size_t constexpr config_size_in_words GENPYBIND(hidden) = 4;
140  template <typename AddressT>
141  static std::array<AddressT, config_size_in_words> addresses(coordinate_type const& word)
142  SYMBOL_VISIBLE GENPYBIND(hidden);
143  template <typename WordT>
144  std::array<WordT, config_size_in_words> encode() const SYMBOL_VISIBLE GENPYBIND(hidden);
145  template <typename WordT>
146  void decode(std::array<WordT, config_size_in_words> const& data) SYMBOL_VISIBLE
147  GENPYBIND(hidden);
148 
149 private:
150  friend class cereal::access;
151  template <typename Archive>
152  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE;
153 
154  SenseDelay m_sense_delay;
155  ResetDuration m_reset_duration;
156  ResetFallTime m_reset_fall_time;
157  ResetMode m_reset_mode;
158  RampOffsets m_cadc_v_offset_assignment;
159 };
160 
161 std::ostream& operator<<(std::ostream& os, CommonCorrelationConfig::ResetMode const& config)
162  SYMBOL_VISIBLE;
163 
164 } // namespace haldls::vx
165 
166 namespace haldls::vx::detail {
167 
168 template <>
169 struct BackendContainerTrait<CommonCorrelationConfig>
170  : public BackendContainerBase<
171  haldls::vx::CommonCorrelationConfig,
172  fisch::vx::word_access_type::Omnibus,
173  fisch::vx::word_access_type::OmnibusChipOverJTAG>
174 {};
175 
176 } // namespace haldls::vx::detail
177 
178 #ifndef __ppu__
179 CEREAL_CLASS_VERSION(haldls::vx::CommonCorrelationConfig, 1)
180 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(haldls::vx::CommonCorrelationConfig)
181 #endif
Correlation reset and readout timing configuration container.
Definition: correlation.h:27
halco::hicann_dls::vx::CommonCorrelationConfigOnDLS coordinate_type
Definition: correlation.h:30
#define GENPYBIND_TAG_HALDLS_VX
Definition: genpybind.h:4