LOLA
dac.h
Go to the documentation of this file.
1 #pragma once
2 #include "halco/common/iter_all.h"
3 #include "halco/common/typed_array.h"
4 #include "halco/hicann-dls/vx/dac.h"
5 #include "haldls/cerealization.h"
6 #include "haldls/vx/common.h"
7 #include "haldls/vx/spi.h"
8 #include "haldls/vx/traits.h"
9 #include "hate/visibility.h"
10 #include "lola/vx/cerealization.h"
11 #include "lola/vx/genpybind.h"
12 #include <boost/hana/adapt_struct.hpp>
13 
15 
19 class GENPYBIND(visible) DACChannelBlock
20 {
21 public:
22  typedef halco::hicann_dls::vx::DACChannelBlockOnBoard coordinate_type;
23  typedef std::false_type has_local_data;
24 
25  typedef haldls::vx::DACChannel::Value Value GENPYBIND(visible);
26 
28  DACChannelBlock() SYMBOL_VISIBLE;
29 
30  typedef halco::common::typed_array<Value, halco::hicann_dls::vx::DACChannelOnBoard> _value_type
31  GENPYBIND(opaque);
32 
34  _value_type value;
35 
39  static const SYMBOL_VISIBLE GENPYBIND(visible) DACChannelBlock default_ldo_1;
40 
44  static const SYMBOL_VISIBLE GENPYBIND(visible) DACChannelBlock default_ldo_2;
45 
52  void set_voltage(halco::hicann_dls::vx::DACChannelOnBoard coord, double voltage) SYMBOL_VISIBLE;
53 
60  double get_voltage(halco::hicann_dls::vx::DACChannelOnBoard coord) const SYMBOL_VISIBLE;
61 
62  bool operator==(DACChannelBlock const& other) const SYMBOL_VISIBLE;
63  bool operator!=(DACChannelBlock const& other) const SYMBOL_VISIBLE;
64 
65  GENPYBIND(stringstream)
66  friend std::ostream& operator<<(std::ostream& os, DACChannelBlock const& block) SYMBOL_VISIBLE;
67 
68 private:
69  friend struct haldls::vx::detail::VisitPreorderImpl<lola::vx::DACChannelBlock>;
70 };
71 
72 
76 class GENPYBIND(visible) DACControlBlock
77 {
78 public:
79  typedef halco::hicann_dls::vx::DACControlBlockOnBoard coordinate_type;
80  typedef std::false_type has_local_data;
81 
83  DACControlBlock() SYMBOL_VISIBLE;
84 
85  typedef halco::common::typed_array<bool, halco::hicann_dls::vx::DACChannelOnBoard> _enable_type
86  GENPYBIND(opaque);
87 
89  _enable_type enable;
90 
91  bool operator==(DACControlBlock const& other) const SYMBOL_VISIBLE;
92  bool operator!=(DACControlBlock const& other) const SYMBOL_VISIBLE;
93 
94  GENPYBIND(stringstream)
95  friend std::ostream& operator<<(std::ostream& os, DACControlBlock const& block) SYMBOL_VISIBLE;
96 
97 private:
98  friend struct haldls::vx::detail::VisitPreorderImpl<lola::vx::DACControlBlock>;
99 };
100 
101 } // namespace lola::vx
102 
103 namespace haldls::vx::detail {
104 
105 template <>
106 struct BackendContainerTrait<lola::vx::DACChannelBlock>
107  : public BackendContainerBase<
108  lola::vx::DACChannelBlock,
109  fisch::vx::word_access_type::SPIDACDataRegister>
110 {};
111 
112 template <>
113 struct BackendContainerTrait<lola::vx::DACControlBlock>
114  : public BackendContainerBase<
115  lola::vx::DACControlBlock,
116  fisch::vx::word_access_type::SPIDACControlRegister>
117 {};
118 
119 template <>
120 struct VisitPreorderImpl<lola::vx::DACChannelBlock>
121 {
122  template <typename ContainerT, typename VisitorT>
123  static void call(
124  ContainerT& config,
126  VisitorT&& visitor)
127  {
128  using halco::common::iter_all;
129  using namespace halco::hicann_dls::vx;
130 
131  visitor(coord, config);
132 
133  for (auto ch : iter_all<DACChannelOnBoard>()) {
134  DACChannel channel(config.value[ch]);
135  visit_preorder(channel, ch, visitor);
136  }
137  }
138 };
139 
140 template <>
141 struct VisitPreorderImpl<lola::vx::DACControlBlock>
142 {
143  template <typename ContainerT, typename VisitorT>
144  static void call(
145  ContainerT& config,
147  VisitorT&& visitor)
148  {
149  using halco::common::iter_all;
150  using namespace halco::hicann_dls::vx;
151 
152  visitor(coord, config);
153 
154  for (auto dac : iter_all<DACOnBoard>()) {
155  DACControl control;
156  for (auto ch : iter_all<DACChannelOnDAC>()) {
157  control.set_enable_channel(ch, config.enable[DACChannelOnBoard(ch, dac)]);
158  }
159  visit_preorder(control, dac, visitor);
160  }
161  }
162 };
163 
164 } // namespace haldls::vx::detail
165 
168 
169 EXTERN_INSTANTIATE_CEREAL_SERIALIZE_FREE(lola::vx::DACChannelBlock)
170 EXTERN_INSTANTIATE_CEREAL_SERIALIZE_FREE(lola::vx::DACControlBlock)
Container for configuration of all DAC channels on the xBoard.
Definition: dac.h:20
halco::common::typed_array< Value, halco::hicann_dls::vx::DACChannelOnBoard > _value_type
Definition: dac.h:31
haldls::vx::DACChannel::Value Value
Definition: dac.h:25
halco::hicann_dls::vx::DACChannelBlockOnBoard coordinate_type
Definition: dac.h:22
std::false_type has_local_data
Definition: dac.h:23
DACChannelBlock() SYMBOL_VISIBLE
Default constructor.
Container for configuration of all DAC channel enable values on the xBoard.
Definition: dac.h:77
DACControlBlock() SYMBOL_VISIBLE
Default constructor.
halco::common::typed_array< bool, halco::hicann_dls::vx::DACChannelOnBoard > _enable_type
Definition: dac.h:86
std::false_type has_local_data
Definition: dac.h:80
halco::hicann_dls::vx::DACControlBlockOnBoard coordinate_type
Definition: dac.h:79
BOOST_HANA_ADAPT_STRUCT(lola::vx::DACChannelBlock, value)
#define GENPYBIND_TAG_LOLA_VX
Definition: genpybind.h:4
Definition: cadc.h:465
lola::vx::DACControlBlock DACControlBlock
Definition: dac.h:8
lola::vx::DACChannelBlock DACChannelBlock
Definition: dac.h:7
Definition: dac.h:14
Definition: dac.h:14
static void call(ContainerT &config, lola::vx::DACChannelBlock::coordinate_type const &coord, VisitorT &&visitor)
Definition: dac.h:123
static void call(ContainerT &config, lola::vx::DACControlBlock::coordinate_type const &coord, VisitorT &&visitor)
Definition: dac.h:144