ChimeraTK-DeviceAccess 03.26.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 <string>
10
11namespace ChimeraTK {
12
13 /********************************************************************************************************************/
14
16 public:
24 enum class Access { READ_ONLY = 0, WRITE_ONLY = 1, READ_WRITE = 2, INTERRUPT = 3 };
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;
49 bool operator==(const ChannelInfo& rhs) const;
50 bool operator!=(const ChannelInfo& rhs) const;
51 [[nodiscard]] DataType getRawType() const;
52 };
53
60
65 explicit NumericAddressedRegisterInfo(RegisterPath const& pathName_ = {}, uint32_t nElements_ = 0,
66 uint64_t address_ = 0, uint32_t nBytes_ = 0, uint64_t bar_ = 0, uint32_t width_ = 32,
67 int32_t nFractionalBits_ = 0, bool signedFlag_ = true, Access dataAccess_ = Access::READ_WRITE,
68 Type dataType_ = Type::FIXED_POINT, std::vector<size_t> interruptId_ = {},
69 std::optional<DoubleBufferInfo> doubleBuffer_ = std::nullopt);
70
74 NumericAddressedRegisterInfo(RegisterPath const& pathName_, uint64_t bar_, uint64_t address_, uint32_t nElements_,
75 uint32_t elementPitchBits_, std::vector<ChannelInfo> channelInfo_, Access dataAccess_,
76 std::vector<size_t> interruptId_, std::optional<DoubleBufferInfo> doubleBuffer_ = std::nullopt);
77
79
81
83
85
86 [[nodiscard]] RegisterPath getRegisterName() const override { return pathName; }
87
88 [[nodiscard]] unsigned int getNumberOfElements() const override { return nElements; }
89
90 [[nodiscard]] unsigned int getNumberOfChannels() const override { return channels.size(); }
91
92 [[nodiscard]] const DataDescriptor& getDataDescriptor() const override { return dataDescriptor; }
93
94 [[nodiscard]] bool isReadable() const override {
97 }
98
99 [[nodiscard]] bool isWriteable() const override {
101 }
102
103 [[nodiscard]] AccessModeFlags getSupportedAccessModes() const override {
104 AccessModeFlags flags;
105
108 }
109
110 if(channels.size() == 1 && channels.front().dataType != Type::VOID && channels.front().dataType != Type::ASCII) {
111 flags.add(AccessMode::raw);
112 }
113
114 return flags;
115 }
116
118
119 uint32_t nElements;
122 uint64_t bar;
123 uint64_t address;
126 std::vector<size_t> interruptId;
127 std::optional<DoubleBufferInfo> doubleBuffer;
129 std::vector<ChannelInfo> channels;
130
132
133 bool hidden{false};
134
135 [[nodiscard]] std::unique_ptr<BackendRegisterInfoBase> clone() const override {
136 return std::unique_ptr<BackendRegisterInfoBase>(new NumericAddressedRegisterInfo(*this));
137 }
138
139 [[nodiscard]] std::vector<size_t> getQualifiedAsyncId() const override;
140
142
143 [[nodiscard]] bool isHidden() const override { return hidden; }
144 };
145
146 /********************************************************************************************************************/
147
148 class NumericAddressedRegisterCatalogue : public BackendRegisterCatalogue<NumericAddressedRegisterInfo> {
149 public:
150 [[nodiscard]] NumericAddressedRegisterInfo getBackendRegister(const RegisterPath& registerPathName) const override;
151
152 [[nodiscard]] bool hasRegister(const RegisterPath& registerPathName) const override;
153
154 [[nodiscard]] const std::set<std::vector<size_t>>& getListOfInterrupts() const;
155
156 void addRegister(const NumericAddressedRegisterInfo& registerInfo);
157
158 [[nodiscard]] std::unique_ptr<BackendRegisterCatalogueBase> clone() const override;
159
160 [[nodiscard]] std::shared_ptr<async::DataConsistencyRealm> getDataConsistencyRealm(
161 const std::vector<size_t>& qualifiedAsyncDomainId) const override;
162
164 const std::vector<size_t>& qualifiedAsyncDomainId) const override;
165
166 void addDataConsistencyRealm(const RegisterPath& registerPath, const std::string& realmName);
167
168 protected:
170
175 std::set<std::vector<size_t>> _listOfInterrupts;
176
186 std::map<RegisterPath, std::vector<size_t>> _canonicalInterrupts;
187
191 std::map<RegisterPath, std::string> _dataConsistencyRealms;
192 };
193
194 /********************************************************************************************************************/
195
196} // 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
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.
Class to store a register path name.
@ 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.