LOLA
synapse_block.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 #include "halco/common/iter_all.h"
8 #include "halco/common/typed_array.h"
9 #include "halco/common/typed_heap_array.h"
10 #include "haldls/cerealization.h"
11 #include "haldls/vx/common.h"
12 #include "haldls/vx/traits.h"
13 #include "hate/visibility.h"
14 #include "lola/vx/cerealization.h"
15 #include "lola/vx/genpybind.h"
16 #include <boost/hana/adapt_struct.hpp>
17 
18 #define ID(x) x
19 #define XSTR(x) #x
20 #define STR(x) XSTR(x)
21 // clang-format off
22 #define CONCAT(w, x, y, z) STR(ID(w)ID(/)ID(x)ID(/)ID(v)ID(y)ID(/)ID(z))
23 #include CONCAT(haldls,vx,CHIP_REVISION,capmem.h)
24 #include CONCAT(lola,vx,CHIP_REVISION,synapse.h)
25 // clang-format on
26 #undef ID
27 #undef XSTR
28 #undef STR
29 #undef CONCAT
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 struct GENPYBIND(visible) SynapseBlock
47 {
48 public:
49  typedef std::false_type has_local_data;
50  typedef halco::hicann_dls::vx::CHIP_REVISION_STR::SynapseBlockOnDLS coordinate_type;
51 
52  typedef haldls::vx::CHIP_REVISION_STR::CapMemCell::Value AnalogValue GENPYBIND(visible);
53  typedef haldls::vx::CHIP_REVISION_STR::CapMemCell::DisableRefresh AnalogDisableRefresh
54  GENPYBIND(visible);
55  typedef haldls::vx::CHIP_REVISION_STR::CapMemCell::value_type AnalogValueVariant;
56  typedef SynapseMatrix Matrix GENPYBIND(visible);
57 
59  SynapseBlock() = default;
60 
63 
64  typedef halco::common::typed_array<
65  haldls::vx::CHIP_REVISION_STR::CapMemCell::value_type,
66  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemBlockOnHemisphere>
68 
70  AnalogValues i_bias_dac{AnalogValue{1022}, AnalogValue{1022}};
71 
72  bool operator==(SynapseBlock const& other) const SYMBOL_VISIBLE;
73  bool operator!=(SynapseBlock const& other) const SYMBOL_VISIBLE;
74 
75  GENPYBIND(stringstream)
76  friend std::ostream& operator<<(std::ostream& os, SynapseBlock const& config) SYMBOL_VISIBLE;
77 
78 private:
79  friend struct haldls::vx::detail::VisitPreorderImpl<SynapseBlock>;
80 };
81 
82 } // namespace lola::vx::vY
83 
84 namespace haldls::vx::detail {
85 
86 template <>
87 struct BackendContainerTrait<lola::vx::CHIP_REVISION_STR::SynapseBlock>
88  : public BackendContainerBase<
89  lola::vx::CHIP_REVISION_STR::SynapseBlock,
90  fisch::vx::word_access_type::Omnibus,
91  fisch::vx::word_access_type::OmnibusChipOverJTAG>
92 {};
93 
94 template <>
95 struct VisitPreorderImpl<lola::vx::CHIP_REVISION_STR::SynapseBlock>
96 {
97  typedef lola::vx::CHIP_REVISION_STR::SynapseBlock container_type;
98 
99  template <typename ContainerT, typename VisitorT>
100  static void call(
101  ContainerT& config,
102  typename container_type::coordinate_type const& coord,
103  VisitorT&& visitor)
104  {
105  using halco::common::iter_all;
106  using namespace halco::hicann_dls::vx::CHIP_REVISION_STR;
107 
108  visitor(coord, config);
109 
110  visit_preorder(config.matrix, coord.toSynramOnDLS(), visitor);
111 
112  for (auto block : iter_all<CapMemBlockOnHemisphere>()) {
113  CapMemBlockOnDLS block_on_dls(
114  CapMemBlockOnDLS(block.toEnum() + CapMemBlockOnHemisphere::size * coord.toEnum()));
115  haldls::vx::CHIP_REVISION_STR::CapMemCell i_bias_dac(config.i_bias_dac[block]);
116  visit_preorder(
117  i_bias_dac, CapMemCellOnDLS(CapMemCellOnCapMemBlock::syn_i_bias_dac, block_on_dls),
118  visitor);
119  if constexpr (!std::is_same<ContainerT, container_type const>::value) {
120  config.i_bias_dac[block] = i_bias_dac.get_value();
121  }
122  }
123  }
124 };
125 
126 } // namespace haldls::vx::detail
127 
128 BOOST_HANA_ADAPT_STRUCT(lola::vx::CHIP_REVISION_STR::SynapseBlock, matrix, i_bias_dac);
129 
130 EXTERN_INSTANTIATE_CEREAL_SERIALIZE_FREE(lola::vx::CHIP_REVISION_STR::SynapseBlock)
Definition: cadc.h:465
lola::vx::SynapseMatrix SynapseMatrix
Definition: synapse.h:16
Definition: dac.h:14
Synapses of one hemisphere in conjunction with hemisphere-global configuration.
Definition: synapse_block.h:47
haldls::vx::CHIP_REVISION_STR::CapMemCell::value_type AnalogValueVariant
Definition: synapse_block.h:55
bool operator==(SynapseBlock const &other) const SYMBOL_VISIBLE
SynapseBlock()=default
Default constructor.
bool operator!=(SynapseBlock const &other) const SYMBOL_VISIBLE
haldls::vx::CHIP_REVISION_STR::CapMemCell::DisableRefresh AnalogDisableRefresh
Definition: synapse_block.h:54
halco::common::typed_array< haldls::vx::CHIP_REVISION_STR::CapMemCell::value_type, halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemBlockOnHemisphere > AnalogValues
Definition: synapse_block.h:67
halco::hicann_dls::vx::CHIP_REVISION_STR::SynapseBlockOnDLS coordinate_type
Definition: synapse_block.h:50
haldls::vx::CHIP_REVISION_STR::CapMemCell::Value AnalogValue
Definition: synapse_block.h:52
static void call(ContainerT &config, typename container_type::coordinate_type const &coord, VisitorT &&visitor)
BOOST_HANA_ADAPT_STRUCT(lola::vx::CHIP_REVISION_STR::SynapseBlock, matrix, i_bias_dac)
halco::hicann_dls::vx::v2::AtomicNeuronOnDLS coordinate_type
Definition: neuron.h:442