blob: 3723a588e954c0a6229a383811610e63481eb9a7 [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.
Zane Shelley8deb0902019-10-14 15:52:27 -050019 /**
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 */
Zane Shelley83da2452019-10-25 15:45:34 -050027 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)
Zane Shelley8deb0902019-10-14 15:52:27 -050032 {}
33
34 /** @brief Destructor. */
35 ~ScomRegister() = default;
36
Zane Shelley2f341bf2019-10-16 11:19:36 -050037 private:
Zane Shelley2f341bf2019-10-16 11:19:36 -050038 // This is needed to allow the flyweights to use the copy constructor, but
39 // not allow it to be used in general.
40 friend class Flyweight<ScomRegister>;
41
Zane Shelley8deb0902019-10-14 15:52:27 -050042 /**
43 * @brief Copy constructor.
44 *
Zane Shelley2f341bf2019-10-16 11:19:36 -050045 * Needed by Flyweight class, but should not be allowed in general.
Zane Shelley8deb0902019-10-14 15:52:27 -050046 */
Zane Shelleyfe27b652019-10-28 11:33:07 -050047 ScomRegister(const ScomRegister&) = default;
Zane Shelley8deb0902019-10-14 15:52:27 -050048
49 /**
50 * @brief Explicitly disables assignment operator.
51 *
52 * This is redundant since the compilier will implicitly delete this because
53 * of the constant instance variables, but helps communicate it is not
54 * allowed.
55 */
Zane Shelleyfe27b652019-10-28 11:33:07 -050056 ScomRegister& operator=(const ScomRegister&) = delete;
Zane Shelley8deb0902019-10-14 15:52:27 -050057
58 public: // Accessor functions
Zane Shelley8deb0902019-10-14 15:52:27 -050059 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -050060 RegisterType_t getRegisterType() const
61 {
62 return REG_TYPE_SCOM;
63 }
Zane Shelley8deb0902019-10-14 15:52:27 -050064
65 /** Function overloaded from parent HardwareRegister class. */
66 RegisterAddress_t getAddress() const
67 {
Zane Shelley83da2452019-10-25 15:45:34 -050068 return static_cast<RegisterAddress_t>(iv_address);
Zane Shelley8deb0902019-10-14 15:52:27 -050069 }
70
71 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -050072 size_t getSize() const
73 {
74 return 8;
75 }
Zane Shelley8deb0902019-10-14 15:52:27 -050076
Zane Shelley8deb0902019-10-14 15:52:27 -050077 private: // Instance variables
Zane Shelley8deb0902019-10-14 15:52:27 -050078 /** This register's address. */
79 const uint32_t iv_address;
80
81}; // end class ScomRegister
82
83/**
84 * @brief A Power Systems Indirect SCOM register.
85 *
86 * Address width: 8 bytes
87 * Register width: 2* bytes (see note below)
88 * Bit order: Ascending (0-63 left to right)
89 *
90 * IMPORTANT NOTE:
91 * Technically, only two bytes of data are actually used. However, the bit
92 * definition of these registers put the two bytes at the end of the returned
93 * value (bit 48-63). Therefore, this class will be made to look like the
94 * width is 8 bytes in order to make the bit indexing work in the returned
95 * BitString.
96 */
97class IdScomRegister : public HardwareRegister
98{
99 public: // Constructor, destructors, assignment, etc.
Zane Shelley8deb0902019-10-14 15:52:27 -0500100 /**
101 * @brief Constructor from components.
102 * @param i_chipType Type of chip associated with this register.
103 * @param i_id Unique ID for this register.
104 * @param i_instance Instance of this register
105 * @param i_accessLevel Hardware access level for this register.
106 * @param i_address An 8-byte address for this Indirect SCOM register.
107 */
Zane Shelley83da2452019-10-25 15:45:34 -0500108 IdScomRegister(ChipType_t i_chipType, RegisterId_t i_id,
109 RegisterInstance_t i_instance,
110 RegisterAccessLevel_t i_accessLevel, uint64_t i_address) :
111 HardwareRegister(i_chipType, i_id, i_instance, i_accessLevel),
112 iv_address(i_address)
Zane Shelley8deb0902019-10-14 15:52:27 -0500113 {}
114
115 /** @brief Destructor. */
116 ~IdScomRegister() = default;
117
Zane Shelley2f341bf2019-10-16 11:19:36 -0500118 private:
Zane Shelley2f341bf2019-10-16 11:19:36 -0500119 // This is needed to allow the flyweights to use the copy constructor, but
120 // not allow it to be used in general.
121 friend class Flyweight<IdScomRegister>;
122
Zane Shelley8deb0902019-10-14 15:52:27 -0500123 /**
124 * @brief Copy constructor.
125 *
Zane Shelley2f341bf2019-10-16 11:19:36 -0500126 * Needed by Flyweight class, but should not be allowed in general.
Zane Shelley8deb0902019-10-14 15:52:27 -0500127 */
Zane Shelleyfe27b652019-10-28 11:33:07 -0500128 IdScomRegister(const IdScomRegister&) = default;
Zane Shelley8deb0902019-10-14 15:52:27 -0500129
130 /**
131 * @brief Explicitly disables assignment operator.
132 *
133 * This is redundant since the compilier will implicitly delete this because
134 * of the constant instance variables, but helps communicate it is not
135 * allowed.
136 */
Zane Shelleyfe27b652019-10-28 11:33:07 -0500137 IdScomRegister& operator=(const IdScomRegister&) = delete;
Zane Shelley8deb0902019-10-14 15:52:27 -0500138
139 public: // Accessor functions
Zane Shelley8deb0902019-10-14 15:52:27 -0500140 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -0500141 RegisterType_t getRegisterType() const
142 {
143 return REG_TYPE_ID_SCOM;
144 }
Zane Shelley8deb0902019-10-14 15:52:27 -0500145
146 /** Function overloaded from parent HardwareRegister class. */
147 RegisterAddress_t getAddress() const
148 {
Zane Shelley83da2452019-10-25 15:45:34 -0500149 return static_cast<RegisterAddress_t>(iv_address);
Zane Shelley8deb0902019-10-14 15:52:27 -0500150 }
151
152 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -0500153 size_t getSize() const
154 {
155 return 8; // See note in class documentation.
156 }
Zane Shelley8deb0902019-10-14 15:52:27 -0500157
Zane Shelley8deb0902019-10-14 15:52:27 -0500158 private: // Instance variables
Zane Shelley8deb0902019-10-14 15:52:27 -0500159 /** This register's address. */
160 const uint64_t iv_address;
161
162}; // end class IdScomRegister
163
164} // end namespace libhei