ChimeraTK-DeviceAccess  03.18.00
NumericAddressedRegisterCatalogue.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 #pragma once
4 
7 
8 #include <cstdint>
9 #include <string>
10 
11 namespace ChimeraTK {
12 
13  /********************************************************************************************************************/
14 
16  public:
25 
36  enum class Type { VOID = 0, FIXED_POINT = 1, IEEE754 = 2, ASCII = 3 };
37 
42  struct ChannelInfo {
43  uint32_t bitOffset;
45  uint32_t width;
46  int32_t nFractionalBits;
47  bool signedFlag;
48  bool operator==(const ChannelInfo& rhs) const;
49  bool operator!=(const ChannelInfo& rhs) const;
50  [[nodiscard]] DataType getRawType() const;
51  };
52 
57  explicit NumericAddressedRegisterInfo(RegisterPath const& pathName_ = {}, uint32_t nElements_ = 0,
58  uint64_t address_ = 0, uint32_t nBytes_ = 0, uint64_t bar_ = 0, uint32_t width_ = 32,
59  int32_t nFractionalBits_ = 0, bool signedFlag_ = true, Access dataAccess_ = Access::READ_WRITE,
60  Type dataType_ = Type::FIXED_POINT, std::vector<size_t> interruptId_ = {});
61 
65  NumericAddressedRegisterInfo(RegisterPath const& pathName_, uint64_t bar_, uint64_t address_, uint32_t nElements_,
66  uint32_t elementPitchBits_, std::vector<ChannelInfo> channelInfo_, Access dataAccess_,
67  std::vector<size_t> interruptId_);
68 
70 
72 
74 
76 
77  [[nodiscard]] RegisterPath getRegisterName() const override { return pathName; }
78 
79  [[nodiscard]] unsigned int getNumberOfElements() const override { return nElements; }
80 
81  [[nodiscard]] unsigned int getNumberOfChannels() const override { return channels.size(); }
82 
83  [[nodiscard]] const DataDescriptor& getDataDescriptor() const override { return dataDescriptor; }
84 
85  [[nodiscard]] bool isReadable() const override {
88  }
89 
90  [[nodiscard]] bool isWriteable() const override {
92  }
93 
94  [[nodiscard]] AccessModeFlags getSupportedAccessModes() const override {
95  AccessModeFlags flags;
96 
99  }
100 
101  if(channels.size() == 1 && channels.front().dataType != Type::VOID && channels.front().dataType != Type::ASCII) {
102  flags.add(AccessMode::raw);
103  }
104 
105  return flags;
106  }
107 
109 
110  uint32_t nElements;
111  uint32_t elementPitchBits;
113  uint64_t bar;
114  uint64_t address;
117  std::vector<size_t> interruptId;
118 
120  std::vector<ChannelInfo> channels;
121 
123 
124  [[nodiscard]] std::unique_ptr<BackendRegisterInfoBase> clone() const override {
125  return std::unique_ptr<BackendRegisterInfoBase>(new NumericAddressedRegisterInfo(*this));
126  }
127 
128  [[nodiscard]] std::vector<size_t> getQualifiedAsyncId() const override;
129 
130  private:
131  void computeDataDescriptor();
132  };
133 
134  /********************************************************************************************************************/
135 
136  class NumericAddressedRegisterCatalogue : public BackendRegisterCatalogue<NumericAddressedRegisterInfo> {
137  public:
138  [[nodiscard]] NumericAddressedRegisterInfo getBackendRegister(const RegisterPath& registerPathName) const override;
139 
140  [[nodiscard]] bool hasRegister(const RegisterPath& registerPathName) const override;
141 
142  [[nodiscard]] const std::set<std::vector<size_t>>& getListOfInterrupts() const;
143 
144  void addRegister(const NumericAddressedRegisterInfo& registerInfo);
145  [[nodiscard]] std::unique_ptr<BackendRegisterCatalogueBase> clone() const override;
146 
147  protected:
152  std::set<std::vector<size_t>> _listOfInterrupts;
153 
163  std::map<RegisterPath, std::vector<size_t>> _canonicalInterrupts;
164  };
165 
166  /********************************************************************************************************************/
167 
168 } // namespace ChimeraTK
ChimeraTK::NumericAddressedRegisterInfo::ChannelInfo::operator!=
bool operator!=(const ChannelInfo &rhs) const
Definition: NumericAddressedRegisterCatalogue.cc:202
ChimeraTK::NumericAddressedRegisterInfo::interruptId
std::vector< size_t > interruptId
Definition: NumericAddressedRegisterCatalogue.h:117
ChimeraTK::NumericAddressedRegisterInfo::address
uint64_t address
Lower part of the address relative to BAR, in bytes.
Definition: NumericAddressedRegisterCatalogue.h:114
ChimeraTK::NumericAddressedRegisterCatalogue::addRegister
void addRegister(const NumericAddressedRegisterInfo &registerInfo)
Definition: NumericAddressedRegisterCatalogue.cc:269
ChimeraTK::NumericAddressedRegisterInfo::Type::ASCII
@ ASCII
ChimeraTK::AccessMode::raw
@ raw
Raw access: disable any possible conversion from the original hardware data type into the given UserT...
ChimeraTK::NumericAddressedRegisterInfo::ChannelInfo::nFractionalBits
int32_t nFractionalBits
Number of fractional bits.
Definition: NumericAddressedRegisterCatalogue.h:46
ChimeraTK::NumericAddressedRegisterInfo::ChannelInfo::width
uint32_t width
Number of significant bits in the register.
Definition: NumericAddressedRegisterCatalogue.h:45
ChimeraTK::NumericAddressedRegisterInfo::getNumberOfElements
unsigned int getNumberOfElements() const override
Return number of elements per channel.
Definition: NumericAddressedRegisterCatalogue.h:79
ChimeraTK::NumericAddressedRegisterCatalogue::getBackendRegister
NumericAddressedRegisterInfo getBackendRegister(const RegisterPath &registerPathName) const override
Note: Override this function if backend has "hidden" registers which are not added to the map and hen...
Definition: NumericAddressedRegisterCatalogue.cc:209
ChimeraTK::NumericAddressedRegisterInfo::nElements
uint32_t nElements
Number of elements in register.
Definition: NumericAddressedRegisterCatalogue.h:110
ChimeraTK::NumericAddressedRegisterInfo::operator==
bool operator==(const ChimeraTK::NumericAddressedRegisterInfo &rhs) const
Definition: NumericAddressedRegisterCatalogue.cc:166
ChimeraTK::NumericAddressedRegisterInfo
Definition: NumericAddressedRegisterCatalogue.h:15
BackendRegisterCatalogue.h
ChimeraTK::AccessModeFlags::add
void add(AccessMode flag)
Add the given flag to the set.
Definition: AccessMode.cc:62
ChimeraTK::NumericAddressedRegisterInfo::Type::VOID
@ VOID
ChimeraTK::NumericAddressedRegisterInfo::Type::IEEE754
@ IEEE754
ChimeraTK::NumericAddressedRegisterInfo::Access::INTERRUPT
@ INTERRUPT
ChimeraTK::BackendRegisterCatalogue
Interface for backends to the register catalogue.
Definition: BackendRegisterCatalogue.h:70
ChimeraTK::DataDescriptor
Class describing the actual payload data format of a register in an abstract manner.
Definition: DataDescriptor.h:19
ChimeraTK::NumericAddressedRegisterInfo::ChannelInfo::dataType
Type dataType
Data type (fixpoint, floating point)
Definition: NumericAddressedRegisterCatalogue.h:44
ChimeraTK::NumericAddressedRegisterInfo::ChannelInfo::signedFlag
bool signedFlag
Signed/Unsigned flag.
Definition: NumericAddressedRegisterCatalogue.h:47
ChimeraTK::NumericAddressedRegisterInfo::getDataDescriptor
const DataDescriptor & getDataDescriptor() const override
Return desciption of the actual payload data for this register.
Definition: NumericAddressedRegisterCatalogue.h:83
ChimeraTK::NumericAddressedRegisterCatalogue::getListOfInterrupts
const std::set< std::vector< size_t > > & getListOfInterrupts() const
Definition: NumericAddressedRegisterCatalogue.cc:263
ChimeraTK::NumericAddressedRegisterInfo::pathName
RegisterPath pathName
Definition: NumericAddressedRegisterCatalogue.h:108
ChimeraTK::AccessMode::wait_for_new_data
@ wait_for_new_data
Make any read blocking until new data has arrived since the last read.
ChimeraTK::NumericAddressedRegisterInfo::ChannelInfo::bitOffset
uint32_t bitOffset
Offset in bits w.r.t.
Definition: NumericAddressedRegisterCatalogue.h:43
ChimeraTK::NumericAddressedRegisterInfo::getRegisterName
RegisterPath getRegisterName() const override
Return full path name of the register (including modules)
Definition: NumericAddressedRegisterCatalogue.h:77
ChimeraTK::NumericAddressedRegisterInfo::bar
uint64_t bar
Upper part of the address (name originally from PCIe, meaning now generalised)
Definition: NumericAddressedRegisterCatalogue.h:113
ChimeraTK::NumericAddressedRegisterCatalogue::clone
std::unique_ptr< BackendRegisterCatalogueBase > clone() const override
Create deep copy of the catalogue.
Definition: NumericAddressedRegisterCatalogue.cc:286
ChimeraTK::NumericAddressedRegisterInfo::Type::FIXED_POINT
@ FIXED_POINT
ChimeraTK::NumericAddressedRegisterInfo::dataDescriptor
DataDescriptor dataDescriptor
Definition: NumericAddressedRegisterCatalogue.h:122
ChimeraTK::DataType
A class to describe which of the supported data types is used.
Definition: SupportedUserTypes.h:599
ChimeraTK::NumericAddressedRegisterInfo::Access::READ_ONLY
@ READ_ONLY
ChimeraTK::NumericAddressedRegisterInfo::operator=
NumericAddressedRegisterInfo & operator=(const NumericAddressedRegisterInfo &other)=default
ChimeraTK::NumericAddressedRegisterInfo::channels
std::vector< ChannelInfo > channels
Define per-channel information (bit interpretation etc.), 1D/scalars have exactly one entry.
Definition: NumericAddressedRegisterCatalogue.h:120
ChimeraTK::NumericAddressedRegisterInfo::getNumberOfChannels
unsigned int getNumberOfChannels() const override
Return number of channels in register.
Definition: NumericAddressedRegisterCatalogue.h:81
ChimeraTK::NumericAddressedRegisterInfo::isWriteable
bool isWriteable() const override
Return whether the register is writeable.
Definition: NumericAddressedRegisterCatalogue.h:90
ChimeraTK::NumericAddressedRegisterInfo::Type
Type
Enum descibing the data interpretation:
Definition: NumericAddressedRegisterCatalogue.h:36
ChimeraTK::NumericAddressedRegisterInfo::elementPitchBits
uint32_t elementPitchBits
Distance in bits (!) between two elements (of the same channel)
Definition: NumericAddressedRegisterCatalogue.h:111
ChimeraTK::NumericAddressedRegisterInfo::ChannelInfo
Per-channel information.
Definition: NumericAddressedRegisterCatalogue.h:42
ChimeraTK::NumericAddressedRegisterInfo::ChannelInfo::operator==
bool operator==(const ChannelInfo &rhs) const
Definition: NumericAddressedRegisterCatalogue.cc:187
ChimeraTK::NumericAddressedRegisterInfo::Access
Access
Enum describing the access mode of the register:
Definition: NumericAddressedRegisterCatalogue.h:24
ChimeraTK::NumericAddressedRegisterInfo::getQualifiedAsyncId
std::vector< size_t > getQualifiedAsyncId() const override
Return the fully qualified async::SubDomain ID.
Definition: NumericAddressedRegisterCatalogue.cc:181
ChimeraTK::RegisterPath
Class to store a register path name.
Definition: RegisterPath.h:16
ChimeraTK::NumericAddressedRegisterInfo::NumericAddressedRegisterInfo
NumericAddressedRegisterInfo(RegisterPath const &pathName_={}, uint32_t nElements_=0, uint64_t address_=0, uint32_t nBytes_=0, uint64_t bar_=0, uint32_t width_=32, int32_t nFractionalBits_=0, bool signedFlag_=true, Access dataAccess_=Access::READ_WRITE, Type dataType_=Type::FIXED_POINT, std::vector< size_t > interruptId_={})
Constructor to set all data members for scalar/1D registers.
Definition: NumericAddressedRegisterCatalogue.cc:18
ChimeraTK::NumericAddressedRegisterInfo::Access::WRITE_ONLY
@ WRITE_ONLY
ChimeraTK::NumericAddressedRegisterCatalogue
Definition: NumericAddressedRegisterCatalogue.h:136
ChimeraTK::NumericAddressedRegisterInfo::registerAccess
Access registerAccess
Data access direction: Read, write, read and write or interrupt.
Definition: NumericAddressedRegisterCatalogue.h:116
ChimeraTK::NumericAddressedRegisterInfo::Access::READ_WRITE
@ READ_WRITE
ChimeraTK::AccessModeFlags
Set of AccessMode flags with additional functionality for an easier handling.
Definition: AccessMode.h:48
BackendRegisterInfoBase.h
ChimeraTK::NumericAddressedRegisterCatalogue::hasRegister
bool hasRegister(const RegisterPath &registerPathName) const override
Check if register with the given path name exists.
Definition: NumericAddressedRegisterCatalogue.cc:250
ChimeraTK::NumericAddressedRegisterInfo::isReadable
bool isReadable() const override
Return whether the register is readable.
Definition: NumericAddressedRegisterCatalogue.h:85
ChimeraTK::NumericAddressedRegisterInfo::operator!=
bool operator!=(const ChimeraTK::NumericAddressedRegisterInfo &rhs) const
Definition: NumericAddressedRegisterCatalogue.cc:175
ChimeraTK::NumericAddressedRegisterInfo::getSupportedAccessModes
AccessModeFlags getSupportedAccessModes() const override
Return all supported AccessModes for this register.
Definition: NumericAddressedRegisterCatalogue.h:94
ChimeraTK
Definition: DummyBackend.h:16
ChimeraTK::BackendRegisterInfoBase
DeviceBackend-independent register description.
Definition: BackendRegisterInfoBase.h:16
ChimeraTK::NumericAddressedRegisterCatalogue::_canonicalInterrupts
std::map< RegisterPath, std::vector< size_t > > _canonicalInterrupts
A canonical interrupt path consists of an exclamation mark, followed by a numeric interrupt and a col...
Definition: NumericAddressedRegisterCatalogue.h:163
ChimeraTK::NumericAddressedRegisterCatalogue::_listOfInterrupts
std::set< std::vector< size_t > > _listOfInterrupts
set of interrupt IDs.
Definition: NumericAddressedRegisterCatalogue.h:152
ChimeraTK::NumericAddressedRegisterInfo::clone
std::unique_ptr< BackendRegisterInfoBase > clone() const override
Create copy of the object.
Definition: NumericAddressedRegisterCatalogue.h:124
ChimeraTK::NumericAddressedRegisterInfo::ChannelInfo::getRawType
DataType getRawType() const
Return raw type matching the given width.
Definition: NumericAddressedRegisterCatalogue.cc:194