ChimeraTK-DeviceAccess 03.31.00
Loading...
Searching...
No Matches
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 <limits>
10#include <string>
11
12namespace ChimeraTK {
13
14 /********************************************************************************************************************/
15
17 public:
25 enum class Access { READ_ONLY = 0, WRITE_ONLY = 1, READ_WRITE = 2, INTERRUPT = 3 };
26
37 enum class Type { VOID = 0, FIXED_POINT = 1, IEEE754 = 2, ASCII = 3 };
38
44 /* Unfortunately, register is a reserved keyword so we use regPath.
45 * And since this is used as a std::optional, which has a value() method would make "value" a weird name
46 */
47 struct SelectedBy {
49 int64_t val;
50 };
51
56 struct ChannelInfo {
57 uint32_t bitOffset;
59 uint32_t width;
63 std::optional<SelectedBy> selectedBy{std::nullopt};
64 bool operator==(const ChannelInfo& rhs) const;
65 bool operator!=(const ChannelInfo& rhs) const;
66 [[nodiscard]] DataType getRawType() const;
67 };
68
75
80 explicit NumericAddressedRegisterInfo(RegisterPath const& pathName_ = {}, uint32_t nElements_ = 0,
81 uint64_t address_ = 0, uint32_t nBytes_ = 0, uint64_t bar_ = 0, uint32_t width_ = 32,
82 int32_t nFractionalBits_ = 0, bool signedFlag_ = true, Access dataAccess_ = Access::READ_WRITE,
83 Type dataType_ = Type::FIXED_POINT, std::vector<size_t> interruptId_ = {},
84 std::optional<DoubleBufferInfo> doubleBuffer_ = std::nullopt, bool isBitRange_ = false);
85
89 NumericAddressedRegisterInfo(RegisterPath const& pathName_, uint64_t bar_, uint64_t address_, uint32_t nElements_,
90 uint32_t elementPitchBits_, std::vector<ChannelInfo> channelInfo_, Access dataAccess_,
91 std::vector<size_t> interruptId_, std::optional<DoubleBufferInfo> doubleBuffer_ = std::nullopt);
92
94
96
98
100
101 [[nodiscard]] RegisterPath getRegisterName() const override { return pathName; }
102
103 [[nodiscard]] unsigned int getNumberOfElements() const override { return nElements; }
104
105 [[nodiscard]] unsigned int getNumberOfChannels() const override { return channels.size(); }
106
107 [[nodiscard]] const DataDescriptor& getDataDescriptor() const override { return dataDescriptor; }
108
109 [[nodiscard]] bool isReadable() const override {
112 }
113
114 [[nodiscard]] bool isWriteable() const override {
116 }
117
118 [[nodiscard]] AccessModeFlags getSupportedAccessModes() const override {
119 AccessModeFlags flags;
120
123 }
124
125 if(channels.size() == 1 && channels.front().dataType != Type::VOID && channels.front().dataType != Type::ASCII) {
126 flags.add(AccessMode::raw);
127 }
128
129 return flags;
130 }
131
133
134 uint32_t nElements;
137 uint64_t bar;
138 uint64_t address;
141 std::vector<size_t> interruptId;
142 std::optional<DoubleBufferInfo> doubleBuffer;
143 bool isBitRange; // A (sub) bit range of a bit field.
144
146 std::vector<ChannelInfo> channels;
147
149
150 bool hidden{false};
151
152 [[nodiscard]] std::unique_ptr<BackendRegisterInfoBase> clone() const override {
153 return std::unique_ptr<BackendRegisterInfoBase>(new NumericAddressedRegisterInfo(*this));
154 }
155
156 [[nodiscard]] std::vector<size_t> getQualifiedAsyncId() const override;
157
159
160 [[nodiscard]] bool isHidden() const override { return hidden; }
161
162 std::string description;
163
164 std::string engineeringUnit;
165
167 [[nodiscard]] std::string getUnit() const override { return engineeringUnit; }
168
170 [[nodiscard]] std::string getDescription() const override { return description; }
171 };
172
173 /********************************************************************************************************************/
174
175 class NumericAddressedRegisterCatalogue : public BackendRegisterCatalogue<NumericAddressedRegisterInfo> {
176 public:
177 [[nodiscard]] NumericAddressedRegisterInfo getBackendRegister(const RegisterPath& registerPathName) const override;
178
179 [[nodiscard]] bool hasRegister(const RegisterPath& registerPathName) const override;
180
181 [[nodiscard]] const std::set<std::vector<size_t>>& getListOfInterrupts() const;
182
183 void addRegister(const NumericAddressedRegisterInfo& registerInfo);
184
185 [[nodiscard]] std::unique_ptr<BackendRegisterCatalogueBase> clone() const override;
186
187 [[nodiscard]] std::shared_ptr<async::DataConsistencyRealm> getDataConsistencyRealm(
188 const std::vector<size_t>& qualifiedAsyncDomainId) const override;
189
191 const std::vector<size_t>& qualifiedAsyncDomainId) const override;
192
193 void addDataConsistencyRealm(const RegisterPath& registerPath, const std::string& realmName);
194
195 protected:
197
202 std::set<std::vector<size_t>> _listOfInterrupts;
203
213 std::map<RegisterPath, std::vector<size_t>> _canonicalInterrupts;
214
218 std::map<RegisterPath, std::string> _dataConsistencyRealms;
219 };
220
221 /********************************************************************************************************************/
222
223} // namespace ChimeraTK
Set of AccessMode flags with additional functionality for an easier handling.
Definition AccessMode.h:48
void add(AccessMode flag)
Add the given flag to the set.
Definition AccessMode.cc:62
Interface for backends to the register catalogue.
DeviceBackend-independent register description.
Class describing the actual payload data format of a register in an abstract manner.
A class to describe which of the supported data types is used.
void addDataConsistencyRealm(const RegisterPath &registerPath, const std::string &realmName)
const std::set< std::vector< size_t > > & getListOfInterrupts() const
bool hasRegister(const RegisterPath &registerPathName) const override
Check if register with the given path name exists.
void addRegister(const NumericAddressedRegisterInfo &registerInfo)
void fillFromThis(NumericAddressedRegisterCatalogue *target) const
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...
std::set< std::vector< size_t > > _listOfInterrupts
set of interrupt IDs.
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...
std::unique_ptr< BackendRegisterCatalogueBase > clone() const override
Create deep copy of the catalogue.
std::shared_ptr< async::DataConsistencyRealm > getDataConsistencyRealm(const std::vector< size_t > &qualifiedAsyncDomainId) const override
Return DataConsistencyRealm for the given qualified AsyncDomainId.
RegisterPath getDataConsistencyKeyRegisterPath(const std::vector< size_t > &qualifiedAsyncDomainId) const override
Return RegisterPath for the register containing the DataConsistencyKey value for the given qualified ...
std::map< RegisterPath, std::string > _dataConsistencyRealms
Map of data consistency key register paths to realm names.
uint32_t nElements
Number of elements in register.
std::vector< ChannelInfo > channels
Define per-channel information (bit interpretation etc.), 1D/scalars have exactly one entry.
unsigned int getNumberOfChannels() const override
Return number of channels in register.
NumericAddressedRegisterInfo(const NumericAddressedRegisterInfo &)=default
bool isReadable() const override
Return whether the register is readable.
Access
Enum describing the access mode of the register:
AccessModeFlags getSupportedAccessModes() const override
Return all supported AccessModes for this register.
uint64_t bar
Upper part of the address (name originally from PCIe, meaning now generalised)
const DataDescriptor & getDataDescriptor() const override
Return description of the actual payload data for this register.
uint32_t elementPitchBits
Distance in bits (!) between two elements (of the same channel)
std::unique_ptr< BackendRegisterInfoBase > clone() const override
Create copy of the object.
bool operator==(const ChimeraTK::NumericAddressedRegisterInfo &rhs) const
std::string getDescription() const override
Return the description of the register.
bool operator!=(const ChimeraTK::NumericAddressedRegisterInfo &rhs) const
bool isHidden() const override
Returns whether the register is "hidden", meaning it won't be listed when iterating the catalogue.
std::vector< size_t > getQualifiedAsyncId() const override
Return the fully qualified async::SubDomain ID.
uint64_t address
Lower part of the address relative to BAR, in bytes.
Access registerAccess
Data access direction: Read, write, read and write or interrupt.
RegisterPath getRegisterName() const override
Return full path name of the register (including modules)
NumericAddressedRegisterInfo & operator=(const NumericAddressedRegisterInfo &other)=default
bool isWriteable() const override
Return whether the register is writeable.
unsigned int getNumberOfElements() const override
Return number of elements per channel.
std::string getUnit() const override
Return the engineering unit of the register.
Class to store a register path name.
This header collects some conversion routines which should be useful both for ApplicationCore Python ...
@ wait_for_new_data
Make any read blocking until new data has arrived since the last read.
@ raw
Raw access: disable any possible conversion from the original hardware data type into the given UserT...
uint32_t width
Number of significant bits in the register.
Per-channel information that contains a pair of register and value determining a condition under whic...
RegisterPath regPath
Path of register that determines if a Channel/Register is considered active.
int64_t val
Value of that register that determines if that Channel/Register is active.