LOLA
synapse_driver.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef CHIP_REVISION
4 #error "Requires CHIP_REVISION"
5 #endif
6 
7 #define ID(x) x
8 #define XSTR(x) #x
9 #define STR(x) XSTR(x)
10 // clang-format off
11 #define CONCAT(w, x, y, z) STR(ID(w)ID(/)ID(x)ID(/)ID(v)ID(y)ID(/)ID(z))
12 #include CONCAT(haldls,vx,CHIP_REVISION,capmem.h)
13 #include CONCAT(haldls,vx,CHIP_REVISION,padi.h)
14 #include CONCAT(haldls,vx,CHIP_REVISION,synapse_driver.h)
15 // clang-format on
16 #undef ID
17 #undef XSTR
18 #undef STR
19 #undef CONCAT
20 
21 #include "halco/common/iter_all.h"
22 #include "halco/common/typed_array.h"
23 #include "haldls/cerealization.h"
24 #include "haldls/vx/common.h"
25 #include "haldls/vx/traits.h"
26 #include "hate/visibility.h"
27 #include "lola/vx/cerealization.h"
28 #include "lola/vx/genpybind.h"
29 #include <boost/hana/adapt_struct.hpp>
30 
31 #if CHIP_REVISION == 2
32 #define GENPYBIND_TAG_LOLA_VX_VY GENPYBIND_TAG_LOLA_VX_V2
33 #define CHIP_REVISION_STR v2
34 #elif CHIP_REVISION == 3
35 #define GENPYBIND_TAG_LOLA_VX_VY GENPYBIND_TAG_LOLA_VX_V3
36 #define CHIP_REVISION_STR v3
37 #else
38 #error "Unknown CHIP_REVISION"
39 #endif
40 
41 namespace lola::vx::CHIP_REVISION_STR GENPYBIND_TAG_LOLA_VX_VY {
42 
46 class GENPYBIND(visible) SynapseDriverBlock
47 {
48 public:
49  typedef std::false_type has_local_data;
50  typedef halco::hicann_dls::vx::CHIP_REVISION_STR::SynapseDriverBlockOnDLS coordinate_type;
51 
53  SynapseDriverBlock() = default;
54 
55  typedef halco::common::typed_array<
56  haldls::vx::CHIP_REVISION_STR::SynapseDriverConfig,
57  halco::hicann_dls::vx::CHIP_REVISION_STR::SynapseDriverOnSynapseDriverBlock>
58  SynapseDrivers GENPYBIND(opaque(false));
59 
64 
68  haldls::vx::CHIP_REVISION_STR::CommonPADIBusConfig padi_bus;
69 
73  haldls::vx::CHIP_REVISION_STR::CommonSTPConfig stp;
74 
75  typedef haldls::vx::CHIP_REVISION_STR::CapMemCell::Value AnalogValue GENPYBIND(visible);
76  typedef haldls::vx::CHIP_REVISION_STR::CapMemCell::DisableRefresh AnalogDisableRefresh
77  GENPYBIND(visible);
78  typedef haldls::vx::CHIP_REVISION_STR::CapMemCell::value_type AnalogValueVariant;
79  typedef halco::common::typed_array<
80  haldls::vx::CHIP_REVISION_STR::CapMemCell::value_type,
81  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemBlockOnHemisphere>
83 
91 
94 
95  bool operator==(SynapseDriverBlock const& other) const SYMBOL_VISIBLE;
96  bool operator!=(SynapseDriverBlock const& other) const SYMBOL_VISIBLE;
97 
98  GENPYBIND(stringstream)
99  friend std::ostream& operator<<(std::ostream& os, SynapseDriverBlock const& config)
100  SYMBOL_VISIBLE;
101 
102 private:
103  friend class haldls::vx::detail::VisitPreorderImpl<SynapseDriverBlock>;
104 };
105 
106 } // namespace lola::vx::vY
107 
108 namespace haldls::vx::detail {
109 
110 template <>
111 struct BackendContainerTrait<lola::vx::CHIP_REVISION_STR::SynapseDriverBlock>
112  : public BackendContainerBase<
113  lola::vx::CHIP_REVISION_STR::SynapseDriverBlock,
114  fisch::vx::word_access_type::Omnibus,
115  fisch::vx::word_access_type::OmnibusChipOverJTAG>
116 {};
117 
118 template <>
119 struct VisitPreorderImpl<lola::vx::CHIP_REVISION_STR::SynapseDriverBlock>
120 {
121  typedef lola::vx::CHIP_REVISION_STR::SynapseDriverBlock container_type;
122 
123  template <typename ContainerT, typename VisitorT>
124  static void call(
125  ContainerT& config,
127  VisitorT&& visitor)
128  {
129  using halco::common::iter_all;
130  using namespace halco::hicann_dls::vx::CHIP_REVISION_STR;
131 
132  visitor(coord, config);
133 
134  for (auto const on_block : iter_all<SynapseDriverOnSynapseDriverBlock>()) {
135  visit_preorder(
136  config.synapse_drivers[on_block], SynapseDriverOnDLS(on_block, coord), visitor);
137  }
138 
139  visit_preorder(config.padi_bus, coord.toCommonPADIBusConfigOnDLS(), visitor);
140  visit_preorder(config.stp, coord.toCommonSTPConfigOnDLS(), visitor);
141 
142  for (auto block : iter_all<CapMemBlockOnHemisphere>()) {
143  CapMemBlockOnDLS block_on_dls(
144  CapMemBlockOnDLS(block.toEnum() + CapMemBlockOnHemisphere::size * coord.toEnum()));
145 
146  haldls::vx::CHIP_REVISION_STR::CapMemCell stp_v_charge_0(config.stp_v_charge_0[block]);
147  visit_preorder(
148  stp_v_charge_0,
149  CapMemCellOnDLS(CapMemCellOnCapMemBlock::stp_v_charge_0, block_on_dls), visitor);
150  if constexpr (!std::is_same<ContainerT, container_type const>::value) {
151  config.stp_v_charge_0[block] = stp_v_charge_0.get_value();
152  }
153 
154  haldls::vx::CHIP_REVISION_STR::CapMemCell stp_v_charge_1(config.stp_v_charge_1[block]);
155  visit_preorder(
156  stp_v_charge_1,
157  CapMemCellOnDLS(CapMemCellOnCapMemBlock::stp_v_charge_1, block_on_dls), visitor);
158  if constexpr (!std::is_same<ContainerT, container_type const>::value) {
159  config.stp_v_charge_1[block] = stp_v_charge_1.get_value();
160  }
161 
162  haldls::vx::CHIP_REVISION_STR::CapMemCell stp_v_recover_0(
163  config.stp_v_recover_0[block]);
164  visit_preorder(
165  stp_v_recover_0,
166  CapMemCellOnDLS(CapMemCellOnCapMemBlock::stp_v_recover_0, block_on_dls), visitor);
167  if constexpr (!std::is_same<ContainerT, container_type const>::value) {
168  config.stp_v_recover_0[block] = stp_v_recover_0.get_value();
169  }
170 
171  haldls::vx::CHIP_REVISION_STR::CapMemCell stp_v_recover_1(
172  config.stp_v_recover_1[block]);
173  visit_preorder(
174  stp_v_recover_1,
175  CapMemCellOnDLS(CapMemCellOnCapMemBlock::stp_v_recover_1, block_on_dls), visitor);
176  if constexpr (!std::is_same<ContainerT, container_type const>::value) {
177  config.stp_v_recover_1[block] = stp_v_recover_1.get_value();
178  }
179 
180  haldls::vx::CHIP_REVISION_STR::CapMemCell stp_i_bias_comparator(
181  config.stp_i_bias_comparator[block]);
182  visit_preorder(
183  stp_i_bias_comparator,
184  CapMemCellOnDLS(CapMemCellOnCapMemBlock::stp_i_bias_comparator, block_on_dls),
185  visitor);
186  if constexpr (!std::is_same<ContainerT, container_type const>::value) {
187  config.stp_i_bias_comparator[block] = stp_i_bias_comparator.get_value();
188  }
189 
190  haldls::vx::CHIP_REVISION_STR::CapMemCell stp_i_ramp(config.stp_i_ramp[block]);
191  visit_preorder(
192  stp_i_ramp, CapMemCellOnDLS(CapMemCellOnCapMemBlock::stp_i_ramp, block_on_dls),
193  visitor);
194  if constexpr (!std::is_same<ContainerT, container_type const>::value) {
195  config.stp_i_ramp[block] = stp_i_ramp.get_value();
196  }
197 
198  haldls::vx::CHIP_REVISION_STR::CapMemCell stp_i_calib(config.stp_i_calib[block]);
199  visit_preorder(
200  stp_i_calib, CapMemCellOnDLS(CapMemCellOnCapMemBlock::stp_i_calib, block_on_dls),
201  visitor);
202  if constexpr (!std::is_same<ContainerT, container_type const>::value) {
203  config.stp_i_calib[block] = stp_i_calib.get_value();
204  }
205  }
206 
207  haldls::vx::CHIP_REVISION_STR::CapMemCell stp_i_bias_readout(config.stp_i_bias_readout);
208  visit_preorder(
209  stp_i_bias_readout,
210  ((coord == SynapseDriverBlockOnDLS::top) ? CapMemCellOnDLS::stp_ibias_readout_top
211  : CapMemCellOnDLS::stp_ibias_readout_bottom),
212  visitor);
213  if constexpr (!std::is_same<ContainerT, container_type const>::value) {
214  config.stp_i_bias_readout = stp_i_bias_readout.get_value();
215  }
216 
217  haldls::vx::CHIP_REVISION_STR::CapMemCell hagen_i_bias_dac(config.hagen_i_bias_dac);
218  visit_preorder(
219  hagen_i_bias_dac,
220  ((coord == SynapseDriverBlockOnDLS::top) ? CapMemCellOnDLS::hagen_ibias_dac_top
221  : CapMemCellOnDLS::hagen_ibias_dac_bottom),
222  visitor);
223  if constexpr (!std::is_same<ContainerT, container_type const>::value) {
224  config.hagen_i_bias_dac = hagen_i_bias_dac.get_value();
225  }
226  }
227 };
228 
229 } // namespace haldls::vx::detail
230 
232  lola::vx::CHIP_REVISION_STR::SynapseDriverBlock,
233  synapse_drivers,
234  padi_bus,
235  stp,
236  stp_v_charge_0,
237  stp_v_charge_1,
238  stp_v_recover_0,
239  stp_v_recover_1,
240  stp_i_bias_comparator,
241  stp_i_ramp,
242  stp_i_calib,
243  stp_i_bias_readout,
244  hagen_i_bias_dac);
245 EXTERN_INSTANTIATE_CEREAL_SERIALIZE_FREE(lola::vx::CHIP_REVISION_STR::SynapseDriverBlock)
Block on synapse drivers and global configuration of one hemisphere.
bool operator==(SynapseDriverBlock const &other) const SYMBOL_VISIBLE
halco::hicann_dls::vx::CHIP_REVISION_STR::SynapseDriverBlockOnDLS coordinate_type
halco::common::typed_array< haldls::vx::CHIP_REVISION_STR::SynapseDriverConfig, halco::hicann_dls::vx::CHIP_REVISION_STR::SynapseDriverOnSynapseDriverBlock > SynapseDrivers
haldls::vx::CHIP_REVISION_STR::CapMemCell::Value AnalogValue
SynapseDriverBlock()=default
Default constructor.
haldls::vx::CHIP_REVISION_STR::CapMemCell::DisableRefresh AnalogDisableRefresh
haldls::vx::CHIP_REVISION_STR::CapMemCell::value_type AnalogValueVariant
haldls::vx::CHIP_REVISION_STR::CommonSTPConfig stp
Digital STP configuration.
SynapseDrivers synapse_drivers
Block of synapse drivers.
haldls::vx::CHIP_REVISION_STR::CommonPADIBusConfig padi_bus
Configuration of PADI-busses.
bool operator!=(SynapseDriverBlock const &other) const SYMBOL_VISIBLE
halco::common::typed_array< haldls::vx::CHIP_REVISION_STR::CapMemCell::value_type, halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemBlockOnHemisphere > AnalogValues
Definition: cadc.h:465
Definition: dac.h:14
static void call(ContainerT &config, lola::vx::CHIP_REVISION_STR::SynapseDriverBlock::coordinate_type const &coord, VisitorT &&visitor)
BOOST_HANA_ADAPT_STRUCT(lola::vx::CHIP_REVISION_STR::SynapseDriverBlock, synapse_drivers, padi_bus, stp, stp_v_charge_0, stp_v_charge_1, stp_v_recover_0, stp_v_recover_1, stp_i_bias_comparator, stp_i_ramp, stp_i_calib, stp_i_bias_readout, hagen_i_bias_dac)
halco::hicann_dls::vx::v2::AtomicNeuronOnDLS coordinate_type
Definition: neuron.h:442