HALDLS
spi.h
Go to the documentation of this file.
1 #pragma once
2 #include <array>
3 #include <iosfwd>
4 
5 #include "fisch/vx/constants.h"
6 #include "halco/common/geometry.h"
7 #include "halco/common/typed_array.h"
8 #include "halco/hicann-dls/vx/dac.h"
9 #include "halco/hicann-dls/vx/xboard.h"
10 #include "haldls/cerealization.h"
11 #include "haldls/vx/genpybind.h"
12 #include "haldls/vx/traits.h"
13 #include "hate/visibility.h"
14 
15 namespace halco::hicann_dls::vx {
16 class SPIShiftRegisterOnBoard;
17 class SPIDACDataRegisterOnBoard;
18 class SPIDACControlRegisterOnBoard;
19 } // namespace halco::hicann_dls::vx
20 
21 namespace haldls {
22 namespace vx GENPYBIND_TAG_HALDLS_VX {
23 
31 class GENPYBIND(visible) ShiftRegister : public DifferentialWriteTrait
32 {
33 public:
34  typedef halco::hicann_dls::vx::ShiftRegisterOnBoard coordinate_type;
35  typedef std::true_type is_leaf_node;
36 
38  {
39  off,
40  readout_chain_0,
41  readout_chain_1,
42  mux_rfu_0
43  };
44 
46  {
47  off,
48  v_reset,
49  vdd_res_meas,
50  mux_dac_25
51  };
52 
54  {
55  off,
56  i_ref,
57  mux_rfu_1,
58  mux_rfu_2
59  };
60 
62  ShiftRegister() SYMBOL_VISIBLE;
63 
69  GENPYBIND(getter_for(enable_i_ref_board))
70  bool get_enable_i_ref_board() const SYMBOL_VISIBLE;
71 
77  GENPYBIND(setter_for(enable_i_ref_board))
78  void set_enable_i_ref_board(bool value) SYMBOL_VISIBLE;
79 
85  GENPYBIND(getter_for(enable_measure_i_ref))
86  bool get_enable_measure_i_ref() const SYMBOL_VISIBLE;
87 
93  GENPYBIND(setter_for(enable_measure_i_ref))
94  void set_enable_measure_i_ref(bool value) SYMBOL_VISIBLE;
95 
100  GENPYBIND(getter_for(select_analog_readout_mux_1_input))
101  AnalogReadoutMux1Input get_select_analog_readout_mux_1_input() const SYMBOL_VISIBLE;
102 
107  GENPYBIND(setter_for(select_analog_readout_mux_1_input))
108  void set_select_analog_readout_mux_1_input(AnalogReadoutMux1Input value) SYMBOL_VISIBLE;
109 
114  GENPYBIND(getter_for(select_analog_readout_mux_2_input))
115  AnalogReadoutMux2Input get_select_analog_readout_mux_2_input() const SYMBOL_VISIBLE;
116 
121  GENPYBIND(setter_for(select_analog_readout_mux_2_input))
122  void set_select_analog_readout_mux_2_input(AnalogReadoutMux2Input value) SYMBOL_VISIBLE;
123 
128  GENPYBIND(getter_for(select_analog_readout_mux_3_input))
129  AnalogReadoutMux3Input get_select_analog_readout_mux_3_input() const SYMBOL_VISIBLE;
130 
135  GENPYBIND(setter_for(select_analog_readout_mux_3_input))
136  void set_select_analog_readout_mux_3_input(AnalogReadoutMux3Input value) SYMBOL_VISIBLE;
137 
142  GENPYBIND(getter_for(enable_dac_to_readout_0))
143  bool get_enable_dac_to_readout_0() const SYMBOL_VISIBLE;
144 
149  GENPYBIND(setter_for(enable_dac_to_readout_0))
150  void set_enable_dac_to_readout_0(bool value) SYMBOL_VISIBLE;
151 
156  GENPYBIND(getter_for(enable_dac_to_readout_1))
157  bool get_enable_dac_to_readout_1() const SYMBOL_VISIBLE;
158 
163  GENPYBIND(setter_for(enable_dac_to_readout_1))
164  void set_enable_dac_to_readout_1(bool value) SYMBOL_VISIBLE;
165 
171  bool get_enable_led(halco::hicann_dls::vx::LEDOnBoard const& coord) const SYMBOL_VISIBLE;
172 
178  void set_enable_led(halco::hicann_dls::vx::LEDOnBoard const& coord, bool value) SYMBOL_VISIBLE;
179 
186  GENPYBIND(getter_for(enable_adc_power_down))
187  bool get_enable_adc_power_down() const SYMBOL_VISIBLE;
188 
195  GENPYBIND(setter_for(enable_adc_power_down))
196  void set_enable_adc_power_down(bool value) SYMBOL_VISIBLE;
197 
203  GENPYBIND(getter_for(enable_adc_reset))
204  bool get_enable_adc_reset() const SYMBOL_VISIBLE;
205 
211  GENPYBIND(setter_for(enable_adc_reset))
212  void set_enable_adc_reset(bool value) SYMBOL_VISIBLE;
213 
219  bool get_enable_vdd(halco::hicann_dls::vx::VDDOnBoard const& coord) const SYMBOL_VISIBLE;
220 
226  void set_enable_vdd(halco::hicann_dls::vx::VDDOnBoard const& coord, bool value) SYMBOL_VISIBLE;
227 
228  bool operator==(ShiftRegister const& other) const SYMBOL_VISIBLE;
229  bool operator!=(ShiftRegister const& other) const SYMBOL_VISIBLE;
230 
231  GENPYBIND(stringstream)
232  friend std::ostream& operator<<(std::ostream& os, ShiftRegister const& config) SYMBOL_VISIBLE;
233 
234  static size_t constexpr write_config_size_in_words GENPYBIND(hidden) = 1;
235  static size_t constexpr read_config_size_in_words GENPYBIND(hidden) = 0;
236  static std::array<halco::hicann_dls::vx::SPIShiftRegisterOnBoard, write_config_size_in_words>
237  write_addresses(coordinate_type const& coord) SYMBOL_VISIBLE GENPYBIND(hidden);
238  static std::array<halco::hicann_dls::vx::SPIShiftRegisterOnBoard, read_config_size_in_words>
239  read_addresses(coordinate_type const& coord) SYMBOL_VISIBLE GENPYBIND(hidden);
240  std::array<fisch::vx::word_access_type::SPIShiftRegister, write_config_size_in_words> encode()
241  const SYMBOL_VISIBLE GENPYBIND(hidden);
242  void decode(
243  std::array<fisch::vx::word_access_type::SPIShiftRegister, read_config_size_in_words> const&
244  data) SYMBOL_VISIBLE GENPYBIND(hidden);
245 
246 private:
247  friend class cereal::access;
248  template <typename Archive>
249  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE;
250 
251  AnalogReadoutMux1Input m_mux_1;
252  AnalogReadoutMux2Input m_mux_2;
253  AnalogReadoutMux3Input m_mux_3;
254  bool m_enable_i_ref_board;
255  bool m_enable_measure_i_ref;
256  bool m_enable_dac_to_readout_0;
257  bool m_enable_dac_to_readout_1;
258  halco::common::typed_array<bool, halco::hicann_dls::vx::LEDOnBoard> m_enable_led;
259  bool m_enable_adc_power_down;
260  bool m_enable_adc_reset;
261  halco::common::typed_array<bool, halco::hicann_dls::vx::VDDOnBoard> m_enable_vdd;
262 };
263 
264 std::ostream& operator<<(std::ostream& os, ShiftRegister::AnalogReadoutMux1Input const& config)
265  SYMBOL_VISIBLE;
266 std::ostream& operator<<(std::ostream& os, ShiftRegister::AnalogReadoutMux2Input const& config)
267  SYMBOL_VISIBLE;
268 std::ostream& operator<<(std::ostream& os, ShiftRegister::AnalogReadoutMux3Input const& config)
269  SYMBOL_VISIBLE;
270 
272 
273 namespace detail {
274 
275 template <>
277  : public BackendContainerBase<ShiftRegister, fisch::vx::word_access_type::SPIShiftRegister>
278 {};
279 
280 } // namespace detail
281 
282 
286 class GENPYBIND(visible) DACChannel : public DifferentialWriteTrait
287 {
288 public:
289  typedef halco::hicann_dls::vx::DACChannelOnBoard coordinate_type;
290  typedef std::true_type is_leaf_node;
291 
292  struct GENPYBIND(inline_base("*")) Value
293  : public halco::common::detail::
294  RantWrapper<Value, uint_fast32_t, fisch::vx::dac_value_max, fisch::vx::dac_value_min>
295  {
296  constexpr explicit Value(uintmax_t const val = 0) GENPYBIND(implicit_conversion) :
297  rant_t(val)
298  {}
299  };
300 
305  DACChannel(Value const& value = Value()) : m_value(value) {}
306 
311  GENPYBIND(setter_for(value))
312  void set_value(Value value) SYMBOL_VISIBLE;
313 
318  GENPYBIND(getter_for(value))
319  Value get_value() const SYMBOL_VISIBLE;
320 
321  bool operator==(DACChannel const& other) const SYMBOL_VISIBLE;
322  bool operator!=(DACChannel const& other) const SYMBOL_VISIBLE;
323 
324  GENPYBIND(stringstream)
325  friend std::ostream& operator<<(std::ostream& os, DACChannel const& config) SYMBOL_VISIBLE;
326 
327  static size_t constexpr write_config_size_in_words GENPYBIND(hidden) = 1;
328  static size_t constexpr read_config_size_in_words GENPYBIND(hidden) = 0;
329  static std::array<halco::hicann_dls::vx::SPIDACDataRegisterOnBoard, write_config_size_in_words>
330  write_addresses(coordinate_type const& coord) SYMBOL_VISIBLE GENPYBIND(hidden);
331  static std::array<halco::hicann_dls::vx::SPIDACDataRegisterOnBoard, read_config_size_in_words>
332  read_addresses(coordinate_type const& coord) SYMBOL_VISIBLE GENPYBIND(hidden);
333  std::array<fisch::vx::word_access_type::SPIDACDataRegister, write_config_size_in_words> encode()
334  const SYMBOL_VISIBLE GENPYBIND(hidden);
335  void decode(std::array<
336  fisch::vx::word_access_type::SPIDACDataRegister,
337  read_config_size_in_words> const& data) SYMBOL_VISIBLE GENPYBIND(hidden);
338 
339 private:
340  friend class cereal::access;
341  template <typename Archive>
342  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE;
343 
344  Value m_value;
345 };
346 
347 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(DACChannel)
348 
349 namespace detail {
350 
351 template <>
352 struct BackendContainerTrait<DACChannel>
353  : public BackendContainerBase<DACChannel, fisch::vx::word_access_type::SPIDACDataRegister>
354 {};
355 
356 } // namespace detail
357 
358 
362 class GENPYBIND(visible) DACControl : public DifferentialWriteTrait
363 {
364 public:
365  typedef halco::hicann_dls::vx::DACOnBoard coordinate_type;
366  typedef std::true_type is_leaf_node;
367 
369  DACControl() SYMBOL_VISIBLE;
370 
376  void set_enable_channel(halco::hicann_dls::vx::DACChannelOnDAC const& channel, bool value)
377  SYMBOL_VISIBLE;
378 
384  bool get_enable_channel(halco::hicann_dls::vx::DACChannelOnDAC const& channel) const
385  SYMBOL_VISIBLE;
386 
387  bool operator==(DACControl const& other) const SYMBOL_VISIBLE;
388  bool operator!=(DACControl const& other) const SYMBOL_VISIBLE;
389 
390  GENPYBIND(stringstream)
391  friend std::ostream& operator<<(std::ostream& os, DACControl const& config) SYMBOL_VISIBLE;
392 
393  static size_t constexpr write_config_size_in_words GENPYBIND(hidden) = 2;
394  static size_t constexpr read_config_size_in_words GENPYBIND(hidden) = 0;
395  static std::
396  array<halco::hicann_dls::vx::SPIDACControlRegisterOnBoard, write_config_size_in_words>
397  write_addresses(coordinate_type const& coord) SYMBOL_VISIBLE GENPYBIND(hidden);
398  static std::
399  array<halco::hicann_dls::vx::SPIDACControlRegisterOnBoard, read_config_size_in_words>
400  read_addresses(coordinate_type const& coord) SYMBOL_VISIBLE GENPYBIND(hidden);
401  std::array<fisch::vx::word_access_type::SPIDACControlRegister, write_config_size_in_words>
402  encode() const SYMBOL_VISIBLE GENPYBIND(hidden);
403  void decode(std::array<
404  fisch::vx::word_access_type::SPIDACControlRegister,
405  read_config_size_in_words> const& data) SYMBOL_VISIBLE GENPYBIND(hidden);
406 
407 private:
408  friend class cereal::access;
409  template <typename Archive>
410  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE;
411 
412  halco::common::typed_array<bool, halco::hicann_dls::vx::DACChannelOnDAC> m_enable_channel;
413 };
414 
415 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(DACControl)
416 
417 namespace detail {
418 
419 template <>
420 struct BackendContainerTrait<DACControl>
421  : public BackendContainerBase<DACControl, fisch::vx::word_access_type::SPIDACControlRegister>
422 {};
423 
424 } // namespace detail
425 
426 } // namespace vx
427 } // namespace haldls
428 
429 namespace std {
430 
431 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::DACChannel::Value)
432 
433 } // namespace std
#define EXTERN_INSTANTIATE_CEREAL_SERIALIZE(CLASS_NAME)
Definition: cerealization.h:75
Container for individual configuration of the value of a DAC channel of the xBoard DACs.
Definition: spi.h:287
std::true_type is_leaf_node
Definition: spi.h:290
halco::hicann_dls::vx::DACChannelOnBoard coordinate_type
Definition: spi.h:289
Trait signalling derived-from container type support differential write operation.
Definition: traits.h:17
Container for configuration of the 24-bit wide shift register controlling six VDD switches,...
Definition: spi.h:32
halco::hicann_dls::vx::ShiftRegisterOnBoard coordinate_type
Definition: spi.h:34
ShiftRegister() SYMBOL_VISIBLE
Default constructor.
std::true_type is_leaf_node
Definition: spi.h:35
#define GENPYBIND_TAG_HALDLS_VX
Definition: genpybind.h:4
Definition: arq.h:13
Backend container trait base.
Definition: traits.h:77