blob: bebfb26b37e2040ab2387515df04d0732b37ed7a [file] [log] [blame]
Zane Shelley8deb0902019-10-14 15:52:27 -05001#pragma once
2
3#include <register/hei_hardware_register.hpp>
Zane Shelley2f341bf2019-10-16 11:19:36 -05004#include <util/hei_flyweight.hpp>
Zane Shelley8deb0902019-10-14 15:52:27 -05005
6namespace libhei
7{
8
9/**
10 * @brief A Power Systems SCOM register.
11 *
12 * Address width: 4 bytes
13 * Register width: 8 bytes
14 * Bit order: Ascending (0-63 left to right)
15 */
16class ScomRegister : public HardwareRegister
17{
18 public: // Constructor, destructors, assignment, etc.
19
20 /**
21 * @brief Constructor from components.
22 * @param i_chipType Type of chip associated with this register.
23 * @param i_id Unique ID for this register.
24 * @param i_instance Instance of this register
25 * @param i_accessLevel Hardware access level for this register.
26 * @param i_address A 4-byte address for this SCOM register.
27 */
28 ScomRegister( ChipType_t i_chipType, RegisterId_t i_id,
29 RegisterInstance_t i_instance,
30 RegisterAccessLevel_t i_accessLevel, uint32_t i_address ) :
31 HardwareRegister( i_chipType, i_id, i_instance, i_accessLevel ),
32 iv_address( i_address )
33 {}
34
35 /** @brief Destructor. */
36 ~ScomRegister() = default;
37
Zane Shelley2f341bf2019-10-16 11:19:36 -050038 private:
39
40 // This is needed to allow the flyweights to use the copy constructor, but
41 // not allow it to be used in general.
42 friend class Flyweight<ScomRegister>;
43
Zane Shelley8deb0902019-10-14 15:52:27 -050044 /**
45 * @brief Copy constructor.
46 *
Zane Shelley2f341bf2019-10-16 11:19:36 -050047 * Needed by Flyweight class, but should not be allowed in general.
Zane Shelley8deb0902019-10-14 15:52:27 -050048 */
49 ScomRegister( const ScomRegister & ) = default;
50
51 /**
52 * @brief Explicitly disables assignment operator.
53 *
54 * This is redundant since the compilier will implicitly delete this because
55 * of the constant instance variables, but helps communicate it is not
56 * allowed.
57 */
58 ScomRegister & operator=( const ScomRegister & ) = delete;
59
60 public: // Accessor functions
61
62 /** Function overloaded from parent HardwareRegister class. */
63 RegisterType_t getRegisterType() const { return REG_TYPE_SCOM; }
64
65 /** Function overloaded from parent HardwareRegister class. */
66 RegisterAddress_t getAddress() const
67 {
68 return static_cast<RegisterAddress_t>( iv_address );
69 }
70
71 /** Function overloaded from parent HardwareRegister class. */
72 size_t getSize() const { return 8; }
73
74 public: // Operators
75
76 /** @brief Equals operator. */
77 bool operator==( const ScomRegister & i_r ) const
78 {
79 // Comparing address and chip type should be sufficient.
80 return ( getAddress() == i_r.getAddress() ) &&
81 ( getChipType() == i_r.getChipType() );
82 }
83
84 /** @brief Less than operator. */
85 bool operator<( const ScomRegister & i_r ) const
86 {
87 // Comparing address and chip type should be sufficient.
88 return ( getAddress() < i_r.getAddress() ) ||
89 ( ( getAddress() == i_r.getAddress() ) &&
90 ( getChipType() < i_r.getChipType() ) );
91 }
92
93 private: // Instance variables
94
95 /** This register's address. */
96 const uint32_t iv_address;
97
98}; // end class ScomRegister
99
100/**
101 * @brief A Power Systems Indirect SCOM register.
102 *
103 * Address width: 8 bytes
104 * Register width: 2* bytes (see note below)
105 * Bit order: Ascending (0-63 left to right)
106 *
107 * IMPORTANT NOTE:
108 * Technically, only two bytes of data are actually used. However, the bit
109 * definition of these registers put the two bytes at the end of the returned
110 * value (bit 48-63). Therefore, this class will be made to look like the
111 * width is 8 bytes in order to make the bit indexing work in the returned
112 * BitString.
113 */
114class IdScomRegister : public HardwareRegister
115{
116 public: // Constructor, destructors, assignment, etc.
117
118 /**
119 * @brief Constructor from components.
120 * @param i_chipType Type of chip associated with this register.
121 * @param i_id Unique ID for this register.
122 * @param i_instance Instance of this register
123 * @param i_accessLevel Hardware access level for this register.
124 * @param i_address An 8-byte address for this Indirect SCOM register.
125 */
126 IdScomRegister( ChipType_t i_chipType, RegisterId_t i_id,
127 RegisterInstance_t i_instance,
128 RegisterAccessLevel_t i_accessLevel, uint64_t i_address ) :
129 HardwareRegister( i_chipType, i_id, i_instance, i_accessLevel ),
130 iv_address( i_address )
131 {}
132
133 /** @brief Destructor. */
134 ~IdScomRegister() = default;
135
Zane Shelley2f341bf2019-10-16 11:19:36 -0500136 private:
137
138 // This is needed to allow the flyweights to use the copy constructor, but
139 // not allow it to be used in general.
140 friend class Flyweight<IdScomRegister>;
141
Zane Shelley8deb0902019-10-14 15:52:27 -0500142 /**
143 * @brief Copy constructor.
144 *
Zane Shelley2f341bf2019-10-16 11:19:36 -0500145 * Needed by Flyweight class, but should not be allowed in general.
Zane Shelley8deb0902019-10-14 15:52:27 -0500146 */
147 IdScomRegister( const IdScomRegister & ) = default;
148
149 /**
150 * @brief Explicitly disables assignment operator.
151 *
152 * This is redundant since the compilier will implicitly delete this because
153 * of the constant instance variables, but helps communicate it is not
154 * allowed.
155 */
156 IdScomRegister & operator=( const IdScomRegister & ) = delete;
157
158 public: // Accessor functions
159
160 /** Function overloaded from parent HardwareRegister class. */
161 RegisterType_t getRegisterType() const { return REG_TYPE_ID_SCOM; }
162
163 /** Function overloaded from parent HardwareRegister class. */
164 RegisterAddress_t getAddress() const
165 {
166 return static_cast<RegisterAddress_t>( iv_address );
167 }
168
169 /** Function overloaded from parent HardwareRegister class. */
170 size_t getSize() const { return 8; } // See note in class documentation.
171
172 public: // Operators
173
174 /** @brief Equals operator. */
175 bool operator==( const IdScomRegister & i_r ) const
176 {
177 // Comparing address and chip type should be sufficient.
178 return ( getAddress() == i_r.getAddress() ) &&
179 ( getChipType() == i_r.getChipType() );
180 }
181
182 /** @brief Less than operator. */
183 bool operator<( const IdScomRegister & i_r ) const
184 {
185 // Comparing address and chip type should be sufficient.
186 return ( getAddress() < i_r.getAddress() ) ||
187 ( ( getAddress() == i_r.getAddress() ) &&
188 ( getChipType() < i_r.getChipType() ) );
189 }
190
191 private: // Instance variables
192
193 /** This register's address. */
194 const uint64_t iv_address;
195
196}; // end class IdScomRegister
197
198} // end namespace libhei
199