LOLA
cadc.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/cadc.h"
12 #include "haldls/vx/common.h"
13 #include "haldls/vx/synapse.h"
14 #include "haldls/vx/traits.h"
15 #include "hate/visibility.h"
16 #include "lola/vx/cerealization.h"
17 #include "lola/vx/genpybind.h"
18 #include "lola/vx/synapse.h"
19 #include <boost/hana/adapt_struct.hpp>
20 
21 #define ID(x) x
22 #define XSTR(x) #x
23 #define STR(x) XSTR(x)
24 // clang-format off
25 #define CONCAT(w, x, y, z) STR(ID(w)ID(/)ID(x)ID(/)ID(v)ID(y)ID(/)ID(z))
26 #include CONCAT(haldls,vx,CHIP_REVISION,capmem.h)
27 #include CONCAT(haldls,vx,CHIP_REVISION,correlation.h)
28 // clang-format on
29 #undef ID
30 #undef XSTR
31 #undef STR
32 #undef CONCAT
33 
34 #if CHIP_REVISION == 2
35 #define GENPYBIND_TAG_LOLA_VX_VY GENPYBIND_TAG_LOLA_VX_V2
36 #define CHIP_REVISION_STR v2
37 #elif CHIP_REVISION == 3
38 #define GENPYBIND_TAG_LOLA_VX_VY GENPYBIND_TAG_LOLA_VX_V3
39 #define CHIP_REVISION_STR v3
40 #else
41 #error "Unknown CHIP_REVISION"
42 #endif
43 
44 namespace lola::vx::CHIP_REVISION_STR GENPYBIND_TAG_LOLA_VX_VY {
45 #undef GENPYBIND_TAG_LOLA_VX_VY
46 
47 #if defined(__GENPYBIND__) or defined(__GENPYBIND_GENERATED__)
48 #include <pybind11/numpy.h>
49 #endif
50 
54 class GENPYBIND(visible) CADCReadoutChain
55 {
56 public:
57  typedef std::false_type has_local_data;
58  typedef halco::hicann_dls::vx::CADCOnDLS coordinate_type;
59 
63  class GENPYBIND(visible) Channel
64  {
65  public:
66  typedef haldls::vx::CADCChannelConfig::Offset Offset GENPYBIND(visible);
67 
72  Offset offset{};
73 
78  bool enable_connect_correlation{false};
83  bool enable_connect_debug{false};
88  bool enable_connect_neuron{false};
89 
90  Channel() = default;
91 
92  bool operator==(Channel const& other) const SYMBOL_VISIBLE;
93  bool operator!=(Channel const& other) const SYMBOL_VISIBLE;
94 
95  GENPYBIND(stringstream)
96  friend std::ostream& operator<<(std::ostream& os, Channel const& config) SYMBOL_VISIBLE;
97  };
98 
102  typedef halco::common::typed_array<Channel, halco::hicann_dls::vx::CADCChannelColumnOnSynram>
103  ChannelArray GENPYBIND(opaque);
104 
105  typedef halco::common::typed_array<
106  haldls::vx::CHIP_REVISION_STR::CapMemCell::value_type,
107  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemBlockOnHemisphere>
109 
113  class GENPYBIND(visible) Ramp
114  {
115  public:
116  typedef haldls::vx::CADCConfig::ResetWait ResetWait GENPYBIND(visible);
117  typedef haldls::vx::CADCConfig::DeadTime DeadTime GENPYBIND(visible);
118  typedef haldls::vx::CHIP_REVISION_STR::CapMemCell::Value AnalogValue GENPYBIND(visible);
119  typedef haldls::vx::CHIP_REVISION_STR::CapMemCell::DisableRefresh AnalogDisableRefresh
120  GENPYBIND(visible);
121 
122  typedef haldls::vx::CHIP_REVISION_STR::CommonCorrelationConfig::RampOffsets OffsetAssignment
123  GENPYBIND(visible);
124 
128  bool enable{false};
129 
135  ResetWait reset_wait{};
140  DeadTime dead_time{};
141 
147  OffsetAssignment v_offset_assignment{
148  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemBlockOnHemisphere(0),
149  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemBlockOnHemisphere(1)};
161  CADCReadoutChain::AnalogValues i_bias_comparator{};
165  CADCReadoutChain::AnalogValues i_bias_vreset_buffer{};
170 
171  Ramp() = default;
172 
173  bool operator==(Ramp const& other) const SYMBOL_VISIBLE;
174  bool operator!=(Ramp const& other) const SYMBOL_VISIBLE;
175 
176  GENPYBIND(stringstream)
177  friend std::ostream& operator<<(std::ostream& os, Ramp const& config) SYMBOL_VISIBLE;
178  };
179 
184  struct GENPYBIND(visible) Correlation
185  {
186  typedef haldls::vx::CHIP_REVISION_STR::CommonCorrelationConfig::SenseDelay SenseDelay
187  GENPYBIND(visible);
188  typedef haldls::vx::CHIP_REVISION_STR::CommonCorrelationConfig::ResetDuration ResetDuration
189  GENPYBIND(visible);
190  typedef haldls::vx::CHIP_REVISION_STR::CommonCorrelationConfig::ResetFallTime ResetFallTime
191  GENPYBIND(visible);
192  typedef haldls::vx::CHIP_REVISION_STR::CommonCorrelationConfig::ResetMode ResetMode
193  GENPYBIND(visible);
194  typedef haldls::vx::CHIP_REVISION_STR::CapMemCell::Value AnalogValue GENPYBIND(visible);
195  typedef haldls::vx::CHIP_REVISION_STR::CapMemCell::DisableRefresh AnalogDisableRefresh
196  GENPYBIND(visible);
197 
204  SenseDelay sense_delay{};
210  ResetDuration reset_duration{};
216  ResetFallTime reset_fall_time{};
217 
235  ResetMode reset_mode{ResetMode::normal};
236 
254 
255  Correlation() = default;
256 
257  bool operator==(Correlation const& other) const SYMBOL_VISIBLE;
258  bool operator!=(Correlation const& other) const SYMBOL_VISIBLE;
259 
260  GENPYBIND(stringstream)
261  friend std::ostream& operator<<(std::ostream& os, Correlation const& config) SYMBOL_VISIBLE;
262  };
263 
267  Ramp ramp{};
271  ChannelArray channels_causal{};
275  ChannelArray channels_acausal{};
280  Correlation correlation{};
281 
282  CADCReadoutChain() = default;
283 
284  bool operator==(CADCReadoutChain const& other) const SYMBOL_VISIBLE;
285  bool operator!=(CADCReadoutChain const& other) const SYMBOL_VISIBLE;
286 
287  GENPYBIND(stringstream)
288  friend std::ostream& operator<<(std::ostream& os, CADCReadoutChain const& config)
289  SYMBOL_VISIBLE;
290 
291  // TODO (Issue 3622): Manual wrapping is necessary due to genpybind forgetting full
292  // qualification
293  GENPYBIND_MANUAL({
294  auto av = parent->py::template class_<
295  ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues>(parent, "AnalogValues");
296  av.def(
297  "fill", &::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::fill, "",
298  parent->py::arg("val"));
299  {
300  typedef ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::reference (
301  ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::*genpybind_at_type)(
302  const ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::key_type&);
303  av.def(
304  "at",
305  (genpybind_at_type) &
306  ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::at,
307  "", parent->py::arg("key"));
308  }
309  {
310  typedef ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::const_reference (
311  ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::*genpybind_at_type)(
312  const ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::key_type&)
313  const;
314  av.def(
315  "at",
316  (genpybind_at_type) &
317  ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::at,
318  "", parent->py::arg("key"));
319  }
320  {
321  typedef ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::reference (
322  ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::*
323  genpybind_front_type)();
324  av.def(
325  "front",
326  (genpybind_front_type) &
327  ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::front,
328  "");
329  }
330  {
331  typedef ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::const_reference (
332  ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::*
333  genpybind_front_type)() const;
334  av.def(
335  "front",
336  (genpybind_front_type) &
337  ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::front,
338  "");
339  }
340  {
341  typedef ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::reference (
342  ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::*
343  genpybind_back_type)();
344  av.def(
345  "back",
346  (genpybind_back_type) &
347  ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::back,
348  "");
349  }
350  {
351  typedef ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::const_reference (
352  ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::*
353  genpybind_back_type)() const;
354  av.def(
355  "back",
356  (genpybind_back_type) &
357  ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::back,
358  "");
359  }
360  av.def(
361  "__getitem__", &::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::get, "",
362  parent->py::arg("key"), parent->py::return_value_policy::reference);
363  av.def(
364  "__setitem__", &::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::set, "",
365  parent->py::arg("key"), parent->py::arg("value"));
366  av.def(
367  "__iter__",
368  [av](::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues& self) {
369  return pybind11::make_iterator(self);
370  },
371  parent->py::template keep_alive<0, 1>());
372 
373  av.def(
374  "to_numpy",
375  [](::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues const& self) {
376  return ::halco::common::detail::to_numpy(self);
377  });
378  av.def(
379  "from_numpy",
380  [](::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues& self,
381  pybind11::array const& array) { ::halco::common::detail::from_numpy(self, array); });
382  av.def(
383  parent->py::template init<
384  const ::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues&>(),
385  "");
386  av.def(parent->py::template init<>(), "");
387  av.def_property_readonly(
388  "size", parent->py::cpp_function(
389  &::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::size));
390  av.def_property_readonly(
391  "max_size",
392  parent->py::cpp_function(
393  &::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::max_size));
394  av.def_property_readonly(
395  "empty", parent->py::cpp_function(
396  &::lola::vx::CHIP_REVISION_STR::CADCReadoutChain::AnalogValues::empty));
397  })
398 private:
399  friend class haldls::vx::detail::VisitPreorderImpl<CADCReadoutChain>;
400 };
401 
402 
403 class GENPYBIND(visible) CADCSampleRow
404 {
405 public:
406  typedef std::false_type has_local_data;
407  typedef halco::hicann_dls::vx::CADCSampleRowOnDLS coordinate_type;
408 
409  typedef haldls::vx::CADCSampleQuad::Value Value GENPYBIND(visible);
410 
411  typedef halco::common::typed_heap_array<Value, halco::hicann_dls::vx::SynapseOnSynapseRow>
412  _samples_type GENPYBIND(opaque);
413 
415  CADCSampleRow() SYMBOL_VISIBLE;
416 
419 
421  _samples_type acausal;
422 
423  bool operator==(CADCSampleRow const& other) const SYMBOL_VISIBLE;
424  bool operator!=(CADCSampleRow const& other) const SYMBOL_VISIBLE;
425 
426  GENPYBIND(stringstream)
427  friend std::ostream& operator<<(std::ostream& os, CADCSampleRow const& row) SYMBOL_VISIBLE;
428 
429 private:
430  friend class haldls::vx::detail::VisitPreorderImpl<CADCSampleRow>;
431 };
432 
433 
434 class GENPYBIND(visible) CADCSamples
435 {
436 public:
437  typedef std::false_type has_local_data;
438  typedef halco::hicann_dls::vx::CADCSamplesOnDLS coordinate_type;
439 
440  typedef haldls::vx::CADCSampleQuad::Value Value GENPYBIND(visible);
441 
442  typedef halco::common::typed_heap_array<
443  halco::common::typed_array<Value, halco::hicann_dls::vx::SynapseOnSynapseRow>,
444  halco::hicann_dls::vx::SynramOnDLS>
445  _samples_type GENPYBIND(opaque);
446 
448  CADCSamples() SYMBOL_VISIBLE;
449 
451  _samples_type acausal;
452 
453  bool operator==(CADCSamples const& other) const SYMBOL_VISIBLE;
454  bool operator!=(CADCSamples const& other) const SYMBOL_VISIBLE;
455 
456  GENPYBIND(stringstream)
457  friend std::ostream& operator<<(std::ostream& os, CADCSamples const& row) SYMBOL_VISIBLE;
458 
459 private:
460  friend class haldls::vx::detail::VisitPreorderImpl<CADCSamples>;
461 };
462 
463 } // namespace lola::vx
464 
465 namespace haldls::vx::detail {
466 
467 template <>
468 struct BackendContainerTrait<lola::vx::CHIP_REVISION_STR::CADCSampleRow>
469  : public BackendContainerBase<
470  lola::vx::CHIP_REVISION_STR::CADCSampleRow,
471  fisch::vx::word_access_type::Omnibus>
472 {};
473 
474 template <>
475 struct BackendContainerTrait<lola::vx::CHIP_REVISION_STR::CADCSamples>
476  : public BackendContainerBase<
477  lola::vx::CHIP_REVISION_STR::CADCSamples,
478  fisch::vx::word_access_type::Omnibus>
479 {};
480 
481 template <>
482 struct BackendContainerTrait<lola::vx::CHIP_REVISION_STR::CADCReadoutChain>
483  : public BackendContainerBase<
484  lola::vx::CHIP_REVISION_STR::CADCReadoutChain,
485  fisch::vx::word_access_type::Omnibus,
486  fisch::vx::word_access_type::OmnibusChipOverJTAG>
487 {};
488 
489 template <>
491 {
492  template <typename ContainerT, typename VisitorT>
493  static void call(
494  ContainerT& config,
496  VisitorT&& visitor)
497  {
498  using halco::common::iter_all;
499  using namespace halco::hicann_dls::vx;
500 
501  visitor(coord, config);
502 
503  haldls::vx::CADCConfig cadc_config;
504  cadc_config.set_enable(config.ramp.enable);
505  cadc_config.set_reset_wait(config.ramp.reset_wait);
506  cadc_config.set_dead_time(config.ramp.dead_time);
507  auto const cadc_coord = coord.toCADCConfigOnDLS();
508  visit_preorder(cadc_config, cadc_coord, visitor);
509 
510  if constexpr (!std::is_same<
511  ContainerT, lola::vx::CHIP_REVISION_STR::CADCReadoutChain const>::value) {
512  config.ramp.enable = cadc_config.get_enable();
513  config.ramp.reset_wait = cadc_config.get_reset_wait();
514  config.ramp.dead_time = cadc_config.get_dead_time();
515  }
516 
517  for (auto const block : iter_all<CapMemBlockOnHemisphere>()) {
518  haldls::vx::CHIP_REVISION_STR::CapMemCell cell_v_offset(config.ramp.v_offset[block]);
519  haldls::vx::CHIP_REVISION_STR::CapMemCell cell_i_slope(config.ramp.i_slope[block]);
520  haldls::vx::CHIP_REVISION_STR::CapMemCell cell_i_bias_comp(
521  config.ramp.i_bias_comparator[block]);
522  haldls::vx::CHIP_REVISION_STR::CapMemCell cell_i_bias_vreset_buf(
523  config.ramp.i_bias_vreset_buffer[block]);
524  haldls::vx::CHIP_REVISION_STR::CapMemCell cell_v_bias_buf(
525  config.ramp.v_bias_buffer[block]);
526  haldls::vx::CHIP_REVISION_STR::CapMemCell cell_i_bias_ramp(
527  config.correlation.i_bias_ramp[block]);
528  haldls::vx::CHIP_REVISION_STR::CapMemCell cell_i_bias_store(
529  config.correlation.i_bias_store[block]);
530  haldls::vx::CHIP_REVISION_STR::CapMemCell cell_i_bias_corout(
531  config.correlation.i_bias_corout[block]);
532 
533  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemBlockOnDLS capmem_block(
534  block.toEnum() +
535  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemBlockOnHemisphere::size *
536  coord.toEnum());
537  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnDLS cell_v_offset_coord(
538  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnCapMemBlock::
539  cadc_v_ramp_offset,
540  capmem_block);
541  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnDLS cell_i_slope_coord(
542  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnCapMemBlock::
543  cadc_i_ramp_slope,
544  capmem_block);
545  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnDLS cell_i_bias_comp_coord(
546  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnCapMemBlock::cadc_i_bias_comp,
547  capmem_block);
548  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnDLS cell_i_bias_vreset_buf_coord(
549  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnCapMemBlock::
550  cadc_i_bias_vreset_buf,
551  capmem_block);
552  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnDLS cell_v_bias_buf_coord(
553  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnCapMemBlock::
554  cadc_v_bias_ramp_buf,
555  capmem_block);
556  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnDLS cell_i_bias_ramp_coord(
557  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnCapMemBlock::syn_i_bias_ramp,
558  capmem_block);
559  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnDLS cell_i_bias_store_coord(
560  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnCapMemBlock::syn_i_bias_store,
561  capmem_block);
562  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnDLS cell_i_bias_corout_coord(
563  halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemCellOnCapMemBlock::
564  syn_i_bias_corout,
565  capmem_block);
566  visit_preorder(cell_v_offset, cell_v_offset_coord, visitor);
567  visit_preorder(cell_i_slope, cell_i_slope_coord, visitor);
568  visit_preorder(cell_i_bias_comp, cell_i_bias_comp_coord, visitor);
569  visit_preorder(cell_i_bias_vreset_buf, cell_i_bias_vreset_buf_coord, visitor);
570  visit_preorder(cell_v_bias_buf, cell_v_bias_buf_coord, visitor);
571  visit_preorder(cell_i_bias_ramp, cell_i_bias_ramp_coord, visitor);
572  visit_preorder(cell_i_bias_store, cell_i_bias_store_coord, visitor);
573  visit_preorder(cell_i_bias_corout, cell_i_bias_corout_coord, visitor);
574 
575  if constexpr (!std::is_same<
576  ContainerT,
578  config.ramp.v_offset[block] = cell_v_offset.get_value();
579  config.ramp.i_slope[block] = cell_i_slope.get_value();
580  config.ramp.i_bias_comparator[block] = cell_i_bias_comp.get_value();
581  config.ramp.i_bias_vreset_buffer[block] = cell_i_bias_vreset_buf.get_value();
582  config.ramp.v_bias_buffer[block] = cell_v_bias_buf.get_value();
583  config.correlation.i_bias_ramp[block] = cell_i_bias_ramp.get_value();
584  config.correlation.i_bias_store[block] = cell_i_bias_store.get_value();
585  config.correlation.i_bias_corout[block] = cell_i_bias_corout.get_value();
586  }
587  }
588 
589  for (auto const column : iter_all<CADCChannelColumnOnSynram>()) {
590  haldls::vx::CADCChannelConfig channel_config;
591  channel_config.set_offset(config.channels_causal[column].offset);
592 
593  CADCChannelConfigOnDLS channel_coord(
594  CADCChannelConfigOnSynram(column, CADCChannelType::causal), coord.toSynramOnDLS());
595  visit_preorder(channel_config, channel_coord, visitor);
596 
597  if constexpr (!std::is_same<
598  ContainerT,
600  config.channels_causal[column].offset = channel_config.get_offset();
601  }
602  }
603 
604  for (auto const column : iter_all<CADCChannelColumnOnSynram>()) {
605  haldls::vx::CADCChannelConfig channel_config;
606  channel_config.set_offset(config.channels_acausal[column].offset);
607 
608  CADCChannelConfigOnDLS channel_coord(
609  CADCChannelConfigOnSynram(column, CADCChannelType::acausal), coord.toSynramOnDLS());
610  visit_preorder(channel_config, channel_coord, visitor);
611 
612  if constexpr (!std::is_same<
613  ContainerT,
615  config.channels_acausal[column].offset = channel_config.get_offset();
616  }
617  }
618 
619  lola::vx::ColumnCorrelationRow column_correlation_row;
620  for (auto const synapse : iter_all<SynapseOnSynapseRow>()) {
621  auto const column = synapse.toCADCChannelColumnOnSynram();
622 
623  auto& sw = column_correlation_row.values[synapse];
624  sw.set_enable_internal_causal(
625  config.channels_causal[column].enable_connect_correlation);
626  sw.set_enable_internal_acausal(
627  config.channels_acausal[column].enable_connect_correlation);
628  sw.set_enable_debug_causal(config.channels_causal[column].enable_connect_debug);
629  sw.set_enable_debug_acausal(config.channels_acausal[column].enable_connect_debug);
630  sw.set_enable_cadc_neuron_readout_causal(
631  config.channels_causal[column].enable_connect_neuron);
632  sw.set_enable_cadc_neuron_readout_acausal(
633  config.channels_acausal[column].enable_connect_neuron);
634  }
635 
636  auto const column_correlation_row_coord = coord.toColumnCorrelationRowOnDLS();
637  visit_preorder(column_correlation_row, column_correlation_row_coord, visitor);
638 
639  if constexpr (!std::is_same<
640  ContainerT, lola::vx::CHIP_REVISION_STR::CADCReadoutChain const>::value) {
641  for (auto const synapse : iter_all<SynapseOnSynapseRow>()) {
642  auto const column = synapse.toCADCChannelColumnOnSynram();
643 
644  auto const& sw = column_correlation_row.values[synapse];
645  config.channels_causal[column].enable_connect_correlation =
646  sw.get_enable_internal_causal();
647  config.channels_acausal[column].enable_connect_correlation =
648  sw.get_enable_internal_acausal();
649  config.channels_causal[column].enable_connect_debug = sw.get_enable_debug_causal();
650  config.channels_acausal[column].enable_connect_debug =
651  sw.get_enable_debug_acausal();
652  config.channels_causal[column].enable_connect_neuron =
653  sw.get_enable_cadc_neuron_readout_causal();
654  config.channels_acausal[column].enable_connect_neuron =
655  sw.get_enable_cadc_neuron_readout_acausal();
656  }
657  }
658 
659  haldls::vx::CHIP_REVISION_STR::CommonCorrelationConfig correlation_config;
660  correlation_config.set_sense_delay(config.correlation.sense_delay);
661  correlation_config.set_reset_duration(config.correlation.reset_duration);
662  correlation_config.set_reset_fall_time(config.correlation.reset_fall_time);
663  correlation_config.set_reset_mode(config.correlation.reset_mode);
664  correlation_config.set_cadc_v_offset_assignment(config.ramp.v_offset_assignment);
665  auto const correlation_coord = coord.toCommonCorrelationConfigOnDLS();
666  visit_preorder(correlation_config, correlation_coord, visitor);
667 
668  if constexpr (!std::is_same<
669  ContainerT, lola::vx::CHIP_REVISION_STR::CADCReadoutChain const>::value) {
670  config.correlation.sense_delay = correlation_config.get_sense_delay();
671  config.correlation.reset_duration = correlation_config.get_reset_duration();
672  config.correlation.reset_fall_time = correlation_config.get_reset_fall_time();
673  config.correlation.reset_mode = correlation_config.get_reset_mode();
674  config.ramp.v_offset_assignment = correlation_config.get_cadc_v_offset_assignment();
675  }
676  }
677 };
678 
679 template <>
680 struct VisitPreorderImpl<lola::vx::CHIP_REVISION_STR::CADCSampleRow>
681 {
682  template <typename ContainerT, typename VisitorT>
683  static void call(
684  ContainerT& config,
686  VisitorT&& visitor)
687  {
688  using halco::common::iter_all;
689  using namespace halco::hicann_dls::vx;
690 
691  visitor(coord, config);
692 
693  // only do something on read
694  if constexpr (!std::is_same<
695  ContainerT, lola::vx::CHIP_REVISION_STR::CADCSampleRow const>::value) {
696  // trigger ADC sampling by reading one quad of causal channels
697  CADCSampleQuad quad_config_trigger;
698  CADCSampleQuadOnDLS quad_coord_trigger(
699  CADCSampleQuadOnSynram(
700  SynapseQuadOnSynram(
701  SynapseQuadColumnOnDLS(SynapseQuadColumnOnDLS::min),
702  coord.toSynapseRowOnSynram()),
703  CADCChannelType::causal, CADCReadoutType::trigger_read),
704  coord.toSynramOnDLS());
705  visit_preorder(quad_config_trigger, quad_coord_trigger, visitor);
706 
707  // Use results of triggered read: write into result array
708  for (auto const entry : iter_all<EntryOnQuad>()) {
709  SynapseOnSynapseRow syn_on_row(entry, SynapseQuadColumnOnDLS(0));
710  config.causal[syn_on_row] = quad_config_trigger.get_sample(entry);
711  }
712 
713  // buffered read of remaining causal channel quads:
714  // This reads back the results that were acquired during the last
715  // triggered measurement, which was just done above.
716  for (size_t i = SynapseQuadColumnOnDLS::min + 1; i <= SynapseQuadColumnOnDLS::max;
717  ++i) {
718  auto quad_column = SynapseQuadColumnOnDLS(i);
719 
720  CADCSampleQuadOnDLS quad_coord(
721  CADCSampleQuadOnSynram(
722  SynapseQuadOnSynram(quad_column, coord.toSynapseRowOnSynram()),
723  CADCChannelType::causal, CADCReadoutType::buffered),
724  coord.toSynramOnDLS());
725  CADCSampleQuad quad_config;
726  visit_preorder(quad_config, quad_coord, visitor);
727  for (auto const syn : iter_all<EntryOnQuad>()) {
728  SynapseOnSynapseRow syn_on_row(syn, quad_column);
729  config.causal[syn_on_row] = quad_config.get_sample(syn);
730  }
731  }
732 
733  // buffered read of acausal channel quads
734  for (auto quad_column : iter_all<SynapseQuadColumnOnDLS>()) {
735  CADCSampleQuadOnDLS quad_coord(
736  CADCSampleQuadOnSynram(
737  SynapseQuadOnSynram(quad_column, coord.toSynapseRowOnSynram()),
738  CADCChannelType::acausal, CADCReadoutType::buffered),
739  coord.toSynramOnDLS());
740  CADCSampleQuad quad_config;
741  visit_preorder(quad_config, quad_coord, visitor);
742  for (auto const syn : iter_all<EntryOnQuad>()) {
743  SynapseOnSynapseRow syn_on_row(syn, quad_column);
744  config.acausal[syn_on_row] = quad_config.get_sample(syn);
745  }
746  }
747  }
748  }
749 };
750 
751 template <>
752 struct VisitPreorderImpl<lola::vx::CHIP_REVISION_STR::CADCSamples>
753 {
754  template <typename ContainerT, typename VisitorT>
755  static void call(
756  ContainerT& config,
758  VisitorT&& visitor)
759  {
760  using halco::common::iter_all;
761  using namespace halco::hicann_dls::vx;
762 
763  visitor(coord, config);
764 
765  // only do something on read
766  if constexpr (!std::is_same<
767  ContainerT, lola::vx::CHIP_REVISION_STR::CADCSamples const>::value) {
768  auto const trigger = [&](auto& values, auto const& loc) {
769  CADCSampleQuad quad_config_trigger;
770  CADCSampleQuadOnDLS quad_coord_trigger_top(
771  CADCSampleQuadOnSynram(
772  SynapseQuadOnSynram(
773  SynapseQuadColumnOnDLS(SynapseQuadColumnOnDLS::min),
774  SynapseRowOnSynram()),
775  CADCChannelType::causal, CADCReadoutType::trigger_read),
776  loc);
777  visit_preorder(quad_config_trigger, quad_coord_trigger_top, visitor);
778 
779  for (auto const syn : iter_all<EntryOnQuad>()) {
780  SynapseOnSynapseRow syn_on_row(
781  syn, SynapseQuadColumnOnDLS(SynapseQuadColumnOnDLS::min));
782  values[loc][syn_on_row] = quad_config_trigger.get_sample(syn);
783  }
784  };
785 
786  // trigger ADC sampling in top synram by reading one quad of causal channels
787  // immediately trigger ADC sampling in bottom synram as well
788  trigger(config.causal, SynramOnDLS::top);
789  trigger(config.causal, SynramOnDLS::bottom);
790 
791  auto const buffered = [&](auto& values, auto const& type, auto const& loc) {
792  for (auto quad_column : iter_all<SynapseQuadColumnOnDLS>()) {
793  // Skip causal quad 0 (handled above as triggered read)
794  if (type == CADCChannelType::causal &&
795  quad_column == SynapseQuadColumnOnDLS::min)
796  continue;
797 
798  CADCSampleQuadOnDLS quad_coord(
799  CADCSampleQuadOnSynram(
800  SynapseQuadOnSynram(quad_column, SynapseRowOnSynram()), type,
801  CADCReadoutType::buffered),
802  loc);
803  CADCSampleQuad quad_config;
804  visit_preorder(quad_config, quad_coord, visitor);
805  for (auto const syn : iter_all<EntryOnQuad>()) {
806  SynapseOnSynapseRow syn_on_row(syn, quad_column);
807  values[loc][syn_on_row] = quad_config.get_sample(syn);
808  }
809  }
810  };
811 
812  // buffered reads of remaining quads
813  buffered(config.causal, CADCChannelType::causal, SynramOnDLS::top);
814  buffered(config.acausal, CADCChannelType::acausal, SynramOnDLS::top);
815  buffered(config.causal, CADCChannelType::causal, SynramOnDLS::bottom);
816  buffered(config.acausal, CADCChannelType::acausal, SynramOnDLS::bottom);
817  }
818  }
819 };
820 
821 } // namespace haldls::vx::detail
822 
825  ramp,
826  channels_causal,
827  channels_acausal,
828  correlation);
830  lola::vx::CHIP_REVISION_STR::CADCReadoutChain::Channel,
831  offset,
832  enable_connect_correlation,
833  enable_connect_debug,
834  enable_connect_neuron);
836  lola::vx::CHIP_REVISION_STR::CADCReadoutChain::Ramp,
837  enable,
838  reset_wait,
839  dead_time,
840  v_offset_assignment,
841  v_offset,
842  i_slope,
843  i_bias_comparator,
844  i_bias_vreset_buffer,
845  v_bias_buffer);
847  lola::vx::CHIP_REVISION_STR::CADCReadoutChain::Correlation,
848  sense_delay,
849  reset_duration,
850  reset_fall_time,
851  reset_mode,
852  i_bias_ramp,
853  i_bias_store,
854  i_bias_corout);
855 BOOST_HANA_ADAPT_STRUCT(lola::vx::CHIP_REVISION_STR::CADCSampleRow, causal, acausal);
856 BOOST_HANA_ADAPT_STRUCT(lola::vx::CHIP_REVISION_STR::CADCSamples, causal, acausal);
857 EXTERN_INSTANTIATE_CEREAL_SERIALIZE_FREE(lola::vx::CHIP_REVISION_STR::CADCReadoutChain)
858 EXTERN_INSTANTIATE_CEREAL_SERIALIZE_FREE(lola::vx::CHIP_REVISION_STR::CADCSampleRow)
859 EXTERN_INSTANTIATE_CEREAL_SERIALIZE_FREE(lola::vx::CHIP_REVISION_STR::CADCSamples)
BOOST_HANA_ADAPT_STRUCT(lola::vx::CHIP_REVISION_STR::CADCReadoutChain, ramp, channels_causal, channels_acausal, correlation)
halco::hicann_dls::vx::CADCSampleRowOnDLS coordinate_type
Definition: cadc.h:407
haldls::vx::CADCSampleQuad::Value Value
Definition: cadc.h:409
CADCSampleRow() SYMBOL_VISIBLE
Default constructor.
halco::common::typed_heap_array< Value, halco::hicann_dls::vx::SynapseOnSynapseRow > _samples_type
Definition: cadc.h:412
std::false_type has_local_data
Definition: cadc.h:406
haldls::vx::CADCSampleQuad::Value Value
Definition: cadc.h:440
CADCSamples() SYMBOL_VISIBLE
Default constructor.
halco::hicann_dls::vx::CADCSamplesOnDLS coordinate_type
Definition: cadc.h:438
halco::common::typed_heap_array< halco::common::typed_array< Value, halco::hicann_dls::vx::SynapseOnSynapseRow >, halco::hicann_dls::vx::SynramOnDLS > _samples_type
Definition: cadc.h:445
std::false_type has_local_data
Definition: cadc.h:437
Configuration of each CADC channel.
Definition: cadc.h:64
haldls::vx::CADCChannelConfig::Offset Offset
Definition: cadc.h:66
bool operator!=(Channel const &other) const SYMBOL_VISIBLE
bool operator==(Channel const &other) const SYMBOL_VISIBLE
CADC ramp generation settings.
Definition: cadc.h:114
haldls::vx::CHIP_REVISION_STR::CapMemCell::Value AnalogValue
Definition: cadc.h:118
bool operator!=(Ramp const &other) const SYMBOL_VISIBLE
bool operator==(Ramp const &other) const SYMBOL_VISIBLE
haldls::vx::CHIP_REVISION_STR::CommonCorrelationConfig::RampOffsets OffsetAssignment
Definition: cadc.h:123
haldls::vx::CADCConfig::DeadTime DeadTime
Definition: cadc.h:117
haldls::vx::CADCConfig::ResetWait ResetWait
Definition: cadc.h:116
haldls::vx::CHIP_REVISION_STR::CapMemCell::DisableRefresh AnalogDisableRefresh
Definition: cadc.h:120
Configuration container for CADC and correlation/neuron-readout related settings.
Definition: cadc.h:55
bool operator==(CADCReadoutChain 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:108
halco::common::typed_array< Channel, halco::hicann_dls::vx::CADCChannelColumnOnSynram > ChannelArray
Configuration of each CADC channel.
Definition: cadc.h:103
halco::hicann_dls::vx::CADCOnDLS coordinate_type
Definition: cadc.h:58
bool operator!=(CADCReadoutChain const &other) const SYMBOL_VISIBLE
class GENPYBIND_TAG_LOLA_VX_VY::CADCReadoutChain CADCReadoutChain
Definition: cadc.h:465
Definition: dac.h:14
Synapses' correlation settings, affecting correlation reset, measurement and readout,...
Definition: cadc.h:185
haldls::vx::CHIP_REVISION_STR::CommonCorrelationConfig::ResetFallTime ResetFallTime
Definition: cadc.h:191
haldls::vx::CHIP_REVISION_STR::CapMemCell::Value AnalogValue
Definition: cadc.h:194
haldls::vx::CHIP_REVISION_STR::CommonCorrelationConfig::ResetDuration ResetDuration
Definition: cadc.h:189
haldls::vx::CHIP_REVISION_STR::CapMemCell::DisableRefresh AnalogDisableRefresh
Definition: cadc.h:196
haldls::vx::CHIP_REVISION_STR::CommonCorrelationConfig::SenseDelay SenseDelay
Definition: cadc.h:187
bool operator!=(Correlation const &other) const SYMBOL_VISIBLE
bool operator==(Correlation const &other) const SYMBOL_VISIBLE
haldls::vx::CHIP_REVISION_STR::CommonCorrelationConfig::ResetMode ResetMode
Definition: cadc.h:193
static void call(ContainerT &config, lola::vx::CHIP_REVISION_STR::CADCReadoutChain::coordinate_type const &coord, VisitorT &&visitor)
Definition: cadc.h:493
static void call(ContainerT &config, lola::vx::CHIP_REVISION_STR::CADCSampleRow::coordinate_type const &coord, VisitorT &&visitor)
Definition: cadc.h:683
static void call(ContainerT &config, lola::vx::CHIP_REVISION_STR::CADCSamples::coordinate_type const &coord, VisitorT &&visitor)
Definition: cadc.h:755
halco::hicann_dls::vx::v2::AtomicNeuronOnDLS coordinate_type
Definition: neuron.h:442