ChimeraTK-DeviceAccess 03.25.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;
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;
113 uint64_t bar;
114 uint64_t address;
117 std::vector<size_t> interruptId;
118
120 std::vector<ChannelInfo> channels;
121
123
124 bool hidden{false};
125
126 [[nodiscard]] std::unique_ptr<BackendRegisterInfoBase> clone() const override {
127 return std::unique_ptr<BackendRegisterInfoBase>(new NumericAddressedRegisterInfo(*this));
128 }
129
130 [[nodiscard]] std::vector<size_t> getQualifiedAsyncId() const override;
131
133
134 [[nodiscard]] bool isHidden() const override { return hidden; }
135 };
136
137 /********************************************************************************************************************/
138
139 class NumericAddressedRegisterCatalogue : public BackendRegisterCatalogue<NumericAddressedRegisterInfo> {
140 public:
141 [[nodiscard]] NumericAddressedRegisterInfo getBackendRegister(const RegisterPath& registerPathName) const override;
142
143 [[nodiscard]] bool hasRegister(const RegisterPath& registerPathName) const override;
144
145 [[nodiscard]] const std::set<std::vector<size_t>>& getListOfInterrupts() const;
146
147 void addRegister(const NumericAddressedRegisterInfo& registerInfo);
148
149 [[nodiscard]] std::unique_ptr<BackendRegisterCatalogueBase> clone() const override;
150
151 [[nodiscard]] std::shared_ptr<async::DataConsistencyRealm> getDataConsistencyRealm(
152 const std::vector<size_t>& qualifiedAsyncDomainId) const override;
153
155 const std::vector<size_t>& qualifiedAsyncDomainId) const override;
156
157 void addDataConsistencyRealm(const RegisterPath& registerPath, const std::string& realmName);
158
159 protected:
161
166 std::set<std::vector<size_t>> _listOfInterrupts;
167
177 std::map<RegisterPath, std::vector<size_t>> _canonicalInterrupts;
178
182 std::map<RegisterPath, std::string> _dataConsistencyRealms;
183 };
184
185 /********************************************************************************************************************/
186
187} // 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...
DataType getRawType() const
Return raw type matching the given width.
uint32_t width
Number of significant bits in the register.