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