HALDLS
pll.h
Go to the documentation of this file.
1 #pragma once
2 #include <array>
3 #include <iosfwd>
4 
5 #include "halco/common/geometry.h"
6 #include "halco/common/typed_array.h"
7 #include "halco/hicann-dls/vx/pll.h"
8 #include "haldls/cerealization.h"
9 #include "haldls/vx/constants.h"
10 #include "haldls/vx/genpybind.h"
11 #include "haldls/vx/traits.h"
12 #include "hate/visibility.h"
13 
14 namespace halco::hicann_dls::vx {
15 class JTAGPLLRegisterOnDLS;
16 class OmnibusChipOverJTAGAddress;
17 } // namespace halco::hicann_dls::vx
18 
19 namespace haldls {
20 namespace vx GENPYBIND_TAG_HALDLS_VX {
21 
27 class GENPYBIND(visible) ADPLL
28 {
29 public:
31  enum class Output
32  {
33  core_0,
34  core_1,
35  dco
36  };
37 
38  typedef halco::hicann_dls::vx::ADPLLOnDLS coordinate_type;
39  typedef std::true_type is_leaf_node;
40 
42  struct GENPYBIND(inline_base("*")) LoopFilterInt
43  : public halco::common::detail::RantWrapper<LoopFilterInt, uint_fast16_t, 31, 1>
44  {
45  constexpr explicit LoopFilterInt(uintmax_t const val = 2) : rant_t(val) {}
46  };
47 
49  struct GENPYBIND(inline_base("*")) LoopFilterProp
50  : public halco::common::detail::RantWrapper<LoopFilterProp, uint_fast16_t, 31, 1>
51  {
52  constexpr explicit LoopFilterProp(uintmax_t const val = 8) : rant_t(val) {}
53  };
54 
59  struct GENPYBIND(inline_base("*")) LoopDivN
60  : public halco::common::detail::RantWrapper<LoopDivN, uint_fast16_t, 31, 1>
61  {
62  constexpr explicit LoopDivN(uintmax_t const val = 10) : rant_t(val) {}
63  };
64 
69  struct GENPYBIND(inline_base("*")) CoreDivM0
70  : public halco::common::detail::RantWrapper<CoreDivM0, uint_fast16_t, 31, 1>
71  {
72  constexpr explicit CoreDivM0(uintmax_t const val = 1) : rant_t(val) {}
73  };
74 
79  struct GENPYBIND(inline_base("*")) CoreDivM1
80  : public halco::common::detail::RantWrapper<CoreDivM1, uint_fast16_t, 31, 1>
81  {
82  constexpr explicit CoreDivM1(uintmax_t const val = 2) : rant_t(val) {}
83  };
84 
89  struct GENPYBIND(inline_base("*")) PreDivP0
90  : public halco::common::detail::RantWrapper<PreDivP0, uint_fast16_t, 4, 2>
91  {
92  constexpr explicit PreDivP0(uintmax_t const val = 2) : rant_t(val) {}
93  };
94 
100  struct GENPYBIND(inline_base("*")) PreDivP1
101  : public halco::common::detail::RantWrapper<PreDivP1, uint_fast16_t, 4, 2>
102  {
103  constexpr explicit PreDivP1(uintmax_t const val = 2) : rant_t(val) {}
104  };
105 
110  struct GENPYBIND(inline_base("*")) PreDivP2
111  : public halco::common::detail::RantWrapper<PreDivP2, uint_fast16_t, 4, 2>
112  {
113  constexpr explicit PreDivP2(uintmax_t const val = 2) : rant_t(val) {}
114  };
115 
117  struct GENPYBIND(inline_base("*")) Tune
118  : public halco::common::detail::RantWrapper<Tune, uint_fast16_t, 4095, 0>
119  {
120  constexpr explicit Tune(uintmax_t const val = 512) : rant_t(val) {}
121  };
122 
124  struct GENPYBIND(inline_base("*")) DcoPowerSwitch
125  : public halco::common::detail::RantWrapper<DcoPowerSwitch, uint_fast16_t, 63, 0>
126  {
127  constexpr explicit DcoPowerSwitch(uintmax_t const val = 63) : rant_t(val) {}
128  };
129 
131  struct GENPYBIND(inline_base("*")) FilterShift
132  : public halco::common::detail::RantWrapper<FilterShift, uint_fast16_t, 3, 0>
133  {
134  constexpr explicit FilterShift(uintmax_t const val = 3) : rant_t(val) {}
135  };
136 
138  ADPLL() SYMBOL_VISIBLE;
139 
140  GENPYBIND(getter_for(loop_filter_int))
141  LoopFilterInt get_loop_filter_int() const SYMBOL_VISIBLE;
142  GENPYBIND(setter_for(loop_filter_int))
143  void set_loop_filter_int(LoopFilterInt value) SYMBOL_VISIBLE;
144 
145  GENPYBIND(getter_for(loop_filter_prop))
146  LoopFilterProp get_loop_filter_prop() const SYMBOL_VISIBLE;
147  GENPYBIND(setter_for(loop_filter_prop))
148  void set_loop_filter_prop(LoopFilterProp value) SYMBOL_VISIBLE;
149 
150  GENPYBIND(getter_for(loop_div_n))
151  LoopDivN get_loop_div_n() const SYMBOL_VISIBLE;
152  GENPYBIND(setter_for(loop_div_n))
153  void set_loop_div_n(LoopDivN value) SYMBOL_VISIBLE;
154 
155  GENPYBIND(getter_for(core_div_m0))
156  CoreDivM0 get_core_div_m0() const SYMBOL_VISIBLE;
157  GENPYBIND(setter_for(core_div_m0))
158  void set_core_div_m0(CoreDivM0 value) SYMBOL_VISIBLE;
159 
160  GENPYBIND(getter_for(core_div_m1))
161  CoreDivM1 get_core_div_m1() const SYMBOL_VISIBLE;
162  GENPYBIND(setter_for(core_div_m1))
163  void set_core_div_m1(CoreDivM1 value) SYMBOL_VISIBLE;
164 
165  GENPYBIND(getter_for(pre_div_p0))
166  PreDivP0 get_pre_div_p0() const SYMBOL_VISIBLE;
167  GENPYBIND(setter_for(pre_div_p0))
168  void set_pre_div_p0(PreDivP0 value) SYMBOL_VISIBLE;
169 
170  GENPYBIND(getter_for(pre_div_p1))
171  PreDivP1 get_pre_div_p1() const SYMBOL_VISIBLE;
172  GENPYBIND(setter_for(pre_div_p1))
173  void set_pre_div_p1(PreDivP1 value) SYMBOL_VISIBLE;
174 
175  GENPYBIND(getter_for(pre_div_p2))
176  PreDivP2 get_pre_div_p2() const SYMBOL_VISIBLE;
177  GENPYBIND(setter_for(pre_div_p2))
178  void set_pre_div_p2(PreDivP2 value) SYMBOL_VISIBLE;
179 
180  GENPYBIND(getter_for(tune))
181  Tune get_tune() const SYMBOL_VISIBLE;
182  GENPYBIND(setter_for(tune))
183  void set_tune(Tune value) SYMBOL_VISIBLE;
184 
185  GENPYBIND(getter_for(dco_power_switch))
186  DcoPowerSwitch get_dco_power_switch() const SYMBOL_VISIBLE;
187  GENPYBIND(setter_for(dco_power_switch))
188  void set_dco_power_switch(DcoPowerSwitch value) SYMBOL_VISIBLE;
189 
194  GENPYBIND(getter_for(open_lock))
195  bool get_open_lock() const SYMBOL_VISIBLE;
196 
201  GENPYBIND(setter_for(open_lock))
202  void set_open_lock(bool value) SYMBOL_VISIBLE;
203 
208  GENPYBIND(getter_for(enforce_lock))
209  bool get_enforce_lock() const SYMBOL_VISIBLE;
210 
215  GENPYBIND(setter_for(enforce_lock))
216  void set_enforce_lock(bool value) SYMBOL_VISIBLE;
217 
222  GENPYBIND(getter_for(pfd_select))
223  bool get_pfd_select() const SYMBOL_VISIBLE;
224 
229  GENPYBIND(setter_for(pfd_select))
230  void set_pfd_select(bool value) SYMBOL_VISIBLE;
231 
236  GENPYBIND(getter_for(lock_window))
237  bool get_lock_window() const SYMBOL_VISIBLE;
238 
243  GENPYBIND(setter_for(lock_window))
244  void set_lock_window(bool value) SYMBOL_VISIBLE;
245 
246  GENPYBIND(getter_for(filter_shift))
247  FilterShift get_filter_shift() const SYMBOL_VISIBLE;
248  GENPYBIND(setter_for(filter_shift))
249  void set_filter_shift(FilterShift value) SYMBOL_VISIBLE;
250 
255  GENPYBIND(getter_for(enable_output_clock))
256  bool get_enable_output_clock() const SYMBOL_VISIBLE;
257 
262  GENPYBIND(setter_for(enable_output_clock))
263  void set_enable_output_clock(bool value) SYMBOL_VISIBLE;
264 
269  GENPYBIND(getter_for(enable))
270  bool get_enable() const SYMBOL_VISIBLE;
271 
276  GENPYBIND(setter_for(enable))
277  void set_enable(bool value) SYMBOL_VISIBLE;
278 
283  GENPYBIND(getter_for(use_external_config))
284  bool get_use_external_config() const SYMBOL_VISIBLE;
285 
290  GENPYBIND(setter_for(use_external_config))
291  void set_use_external_config(bool value) SYMBOL_VISIBLE;
292 
300  double calculate_output_frequency(
301  Output const& output, double const& f_ref = nominal_pll_f_reference) const SYMBOL_VISIBLE;
302 
303  bool operator==(ADPLL const& other) const SYMBOL_VISIBLE;
304  bool operator!=(ADPLL const& other) const SYMBOL_VISIBLE;
305 
306  GENPYBIND(stringstream)
307  friend std::ostream& operator<<(std::ostream& os, ADPLL const& config) SYMBOL_VISIBLE;
308 
309  static size_t constexpr config_size_in_words GENPYBIND(hidden) = 2;
310  template <typename AddressT>
311  static std::array<AddressT, config_size_in_words> addresses(coordinate_type const& coord)
312  SYMBOL_VISIBLE GENPYBIND(hidden);
313  template <typename WordT>
314  std::array<WordT, config_size_in_words> encode() const SYMBOL_VISIBLE GENPYBIND(hidden);
315  template <typename WordT>
316  void decode(std::array<WordT, config_size_in_words> const& data) SYMBOL_VISIBLE
317  GENPYBIND(hidden);
318 
319 private:
320  friend class cereal::access;
321  template <typename Archive>
322  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE;
323 
324  LoopFilterInt m_loop_filter_int;
325  LoopFilterProp m_loop_filter_prop;
326  LoopDivN m_loop_div_n;
327  CoreDivM0 m_core_div_m0;
328  CoreDivM1 m_core_div_m1;
329  PreDivP0 m_pre_div_p0;
330  PreDivP1 m_pre_div_p1;
331  PreDivP2 m_pre_div_p2;
332  Tune m_tune;
333  DcoPowerSwitch m_dco_power_switch;
334  bool m_open_lock;
335  bool m_enforce_lock;
336  bool m_pfd_select;
337  bool m_lock_window;
338  FilterShift m_filter_shift;
339  bool m_enable_output_clock;
340  bool m_enable;
341  bool m_use_external_config;
342 };
343 
344 std::ostream& operator<<(std::ostream&, ADPLL::Output const&) SYMBOL_VISIBLE;
345 
346 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(ADPLL)
347 
348 namespace detail {
349 
356 template <>
357 struct BackendContainerTrait<ADPLL>
358  : public BackendContainerBase<
359  ADPLL,
360  fisch::vx::word_access_type::JTAGPLLRegister,
361  fisch::vx::word_access_type::OmnibusChipOverJTAG>
362 {};
363 
364 } // namespace detail
365 
366 
370 class GENPYBIND(visible) PLLSelfTest
371 {
372 public:
373  typedef halco::hicann_dls::vx::PLLSelfTestOnDLS coordinate_type;
374  typedef std::true_type is_leaf_node;
375 
380  struct GENPYBIND(inline_base("*")) PreScalerP
381  : public halco::common::detail::RantWrapper<PreScalerP, uint_fast16_t, 15, 0>
382  {
383  constexpr explicit PreScalerP(uintmax_t const val = 0) : rant_t(val) {}
384  };
385 
390  struct GENPYBIND(inline_base("*")) CheckRange
391  : public halco::common::detail::RantWrapper<CheckRange, uint_fast16_t, 15, 0>
392  {
393  constexpr explicit CheckRange(uintmax_t const val = 0) : rant_t(val) {}
394  };
395 
400  struct GENPYBIND(inline_base("*")) CheckValue
401  : public halco::common::detail::
402  RantWrapper<CheckValue, uint_fast16_t, 1048575 /*2^20-1*/, 0>
403  {
404  constexpr explicit CheckValue(uintmax_t const val = 0) : rant_t(val) {}
405  };
406 
408  PLLSelfTest() SYMBOL_VISIBLE;
409 
415  GENPYBIND(getter_for(clock_enable))
416  bool get_clock_enable() const SYMBOL_VISIBLE;
417 
423  GENPYBIND(setter_for(clock_enable))
424  void set_clock_enable(bool value) SYMBOL_VISIBLE;
425 
426  GENPYBIND(getter_for(pre_scaler_p))
427  PreScalerP get_pre_scaler_p() const SYMBOL_VISIBLE;
428  GENPYBIND(setter_for(pre_scaler_p))
429  void set_pre_scaler_p(PreScalerP value) SYMBOL_VISIBLE;
430 
435  GENPYBIND(getter_for(select_source))
436  halco::hicann_dls::vx::PLLClockOutputOnDLS get_select_source() const SYMBOL_VISIBLE;
437 
442  GENPYBIND(setter_for(select_source))
443  void set_select_source(halco::hicann_dls::vx::PLLClockOutputOnDLS value) SYMBOL_VISIBLE;
444 
445  GENPYBIND(getter_for(check_range))
446  CheckRange get_check_range() const SYMBOL_VISIBLE;
447  GENPYBIND(setter_for(check_range))
448  void set_check_range(CheckRange value) SYMBOL_VISIBLE;
449 
450  GENPYBIND(getter_for(check_value))
451  CheckValue get_check_value() const SYMBOL_VISIBLE;
452  GENPYBIND(setter_for(check_value))
453  void set_check_value(CheckValue value) SYMBOL_VISIBLE;
454 
455  bool operator==(PLLSelfTest const& other) const SYMBOL_VISIBLE;
456  bool operator!=(PLLSelfTest const& other) const SYMBOL_VISIBLE;
457 
458  GENPYBIND(stringstream)
459  friend std::ostream& operator<<(std::ostream& os, PLLSelfTest const& config) SYMBOL_VISIBLE;
460 
461  static size_t constexpr config_size_in_words GENPYBIND(hidden) = 1;
462  template <typename AddressT>
463  static std::array<AddressT, config_size_in_words> addresses(coordinate_type const& coord)
464  SYMBOL_VISIBLE GENPYBIND(hidden);
465  template <typename WordT>
466  std::array<WordT, config_size_in_words> encode() const SYMBOL_VISIBLE GENPYBIND(hidden);
467  template <typename WordT>
468  void decode(std::array<WordT, config_size_in_words> const& data) SYMBOL_VISIBLE
469  GENPYBIND(hidden);
470 
471 private:
472  friend class cereal::access;
473  template <typename Archive>
474  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE;
475 
476  bool m_clock_enable;
477  PreScalerP m_pre_scaler_p;
478  halco::hicann_dls::vx::PLLClockOutputOnDLS m_select_source;
479  CheckRange m_check_range;
480  CheckValue m_check_value;
481 };
482 
483 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(PLLSelfTest)
484 
485 namespace detail {
486 
487 template <>
488 struct BackendContainerTrait<PLLSelfTest>
489  : public BackendContainerBase<
490  PLLSelfTest,
491  fisch::vx::word_access_type::JTAGPLLRegister,
492  fisch::vx::word_access_type::OmnibusChipOverJTAG>
493 {};
494 
495 } // namespace detail
496 
497 
501 class GENPYBIND(visible) PLLSelfTestStatus
502 {
503 public:
504  typedef halco::hicann_dls::vx::PLLSelfTestStatusOnDLS coordinate_type;
505  typedef std::true_type is_leaf_node;
506 
510  struct GENPYBIND(inline_base("*")) CounterValue
511  : public halco::common::detail::
512  RantWrapper<CounterValue, uint_fast16_t, 1048575 /*2^20-1*/, 0>
513  {
514  constexpr explicit CounterValue(uintmax_t const val = 0) : rant_t(val) {}
515  };
516 
520  PLLSelfTestStatus() SYMBOL_VISIBLE;
521 
526  GENPYBIND(getter_for(success))
527  bool get_success() const SYMBOL_VISIBLE;
528 
535  GENPYBIND(getter_for(finished))
536  bool get_finished() const SYMBOL_VISIBLE;
537 
542  GENPYBIND(getter_for(counter_value))
543  CounterValue get_counter_value() const SYMBOL_VISIBLE;
544 
545  GENPYBIND(stringstream)
546  friend std::ostream& operator<<(std::ostream& os, PLLSelfTestStatus const& config)
547  SYMBOL_VISIBLE;
548 
549  bool operator==(PLLSelfTestStatus const& other) const SYMBOL_VISIBLE;
550  bool operator!=(PLLSelfTestStatus const& other) const SYMBOL_VISIBLE;
551 
552  static size_t constexpr read_config_size_in_words GENPYBIND(hidden) = 1;
553  static size_t constexpr write_config_size_in_words GENPYBIND(hidden) = 0;
554  template <typename AddressT>
555  static std::array<AddressT, read_config_size_in_words> read_addresses(
556  coordinate_type const& coord) SYMBOL_VISIBLE GENPYBIND(hidden);
557  template <typename AddressT>
558  static std::array<AddressT, write_config_size_in_words> write_addresses(
559  coordinate_type const& coord) SYMBOL_VISIBLE GENPYBIND(hidden);
560  template <typename WordT>
561  std::array<WordT, write_config_size_in_words> encode() const SYMBOL_VISIBLE GENPYBIND(hidden);
562  template <typename WordT>
563  void decode(std::array<WordT, read_config_size_in_words> const& data) SYMBOL_VISIBLE
564  GENPYBIND(hidden);
565 
566 private:
567  friend class cereal::access;
568  template <typename Archive>
569  void serialize(Archive& ar, std::uint32_t const version) SYMBOL_VISIBLE;
570 
571  bool m_success;
572  bool m_finished;
573  CounterValue m_counter_value;
574 };
575 
576 EXTERN_INSTANTIATE_CEREAL_SERIALIZE(PLLSelfTestStatus)
577 
578 namespace detail {
579 
580 template <>
581 struct BackendContainerTrait<PLLSelfTestStatus>
582  : public BackendContainerBase<
583  PLLSelfTestStatus,
584  fisch::vx::word_access_type::OmnibusChipOverJTAG>
585 {};
586 
587 } // namespace detail
588 
589 } // namespace vx
590 } // namespace haldls
591 
592 namespace std {
593 
594 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::ADPLL::LoopFilterInt)
595 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::ADPLL::LoopFilterProp)
596 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::ADPLL::LoopDivN)
597 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::ADPLL::CoreDivM0)
598 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::ADPLL::CoreDivM1)
599 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::ADPLL::PreDivP0)
600 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::ADPLL::PreDivP1)
601 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::ADPLL::PreDivP2)
602 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::ADPLL::Tune)
603 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::ADPLL::DcoPowerSwitch)
604 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::ADPLL::FilterShift)
605 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::PLLSelfTest::PreScalerP)
606 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::PLLSelfTest::CheckRange)
607 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::PLLSelfTest::CheckValue)
608 HALCO_GEOMETRY_HASH_CLASS(haldls::vx::PLLSelfTestStatus::CounterValue)
609 
610 } // namespace std
Container for configuration of an ADPLL (All-Digital Phased-Locked-Loop) clock generator.
Definition: pll.h:28
halco::hicann_dls::vx::ADPLLOnDLS coordinate_type
Definition: pll.h:38
Output
Outputs of the ADPLL.
Definition: pll.h:32
std::true_type is_leaf_node
Definition: pll.h:39
#define GENPYBIND_TAG_HALDLS_VX
Definition: genpybind.h:4