blob: 47a685212aa196362a7363351cb5c75413c67273 [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.
Zane Shelley7667b712020-05-11 20:45:40 -050021 * @param i_id Unique ID for this register.
22 * @param i_instance Instance of this register
23 * @param i_flags Attribute flags for this register.
24 * @param i_address A 4-byte address for this SCOM register.
Zane Shelley8deb0902019-10-14 15:52:27 -050025 */
Zane Shelley5ec88102020-05-11 21:08:25 -050026 ScomRegister(RegisterId_t i_id, Instance_t i_instance,
27 RegisterAttributeFlags_t i_flags, uint32_t i_address) :
28 HardwareRegister(i_id, i_instance, i_flags),
Zane Shelley83da2452019-10-25 15:45:34 -050029 iv_address(i_address)
Zane Shelley8deb0902019-10-14 15:52:27 -050030 {}
31
32 /** @brief Destructor. */
33 ~ScomRegister() = default;
34
Zane Shelley2f341bf2019-10-16 11:19:36 -050035 private:
Zane Shelley2f341bf2019-10-16 11:19:36 -050036 // This is needed to allow the flyweights to use the copy constructor, but
37 // not allow it to be used in general.
38 friend class Flyweight<ScomRegister>;
39
Zane Shelley8deb0902019-10-14 15:52:27 -050040 /**
41 * @brief Copy constructor.
42 *
Zane Shelley2f341bf2019-10-16 11:19:36 -050043 * Needed by Flyweight class, but should not be allowed in general.
Zane Shelley8deb0902019-10-14 15:52:27 -050044 */
Zane Shelleyfe27b652019-10-28 11:33:07 -050045 ScomRegister(const ScomRegister&) = default;
Zane Shelley8deb0902019-10-14 15:52:27 -050046
47 /**
48 * @brief Explicitly disables assignment operator.
49 *
50 * This is redundant since the compilier will implicitly delete this because
51 * of the constant instance variables, but helps communicate it is not
52 * allowed.
53 */
Zane Shelleyfe27b652019-10-28 11:33:07 -050054 ScomRegister& operator=(const ScomRegister&) = delete;
Zane Shelley8deb0902019-10-14 15:52:27 -050055
56 public: // Accessor functions
Zane Shelley8deb0902019-10-14 15:52:27 -050057 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley5ec88102020-05-11 21:08:25 -050058 RegisterType_t getType() const
Zane Shelley7f7a42d2019-10-28 13:28:31 -050059 {
60 return REG_TYPE_SCOM;
61 }
Zane Shelley8deb0902019-10-14 15:52:27 -050062
63 /** Function overloaded from parent HardwareRegister class. */
64 RegisterAddress_t getAddress() const
65 {
Zane Shelley83da2452019-10-25 15:45:34 -050066 return static_cast<RegisterAddress_t>(iv_address);
Zane Shelley8deb0902019-10-14 15:52:27 -050067 }
68
69 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -050070 size_t getSize() const
71 {
72 return 8;
73 }
Zane Shelley8deb0902019-10-14 15:52:27 -050074
Zane Shelley8deb0902019-10-14 15:52:27 -050075 private: // Instance variables
Zane Shelley8deb0902019-10-14 15:52:27 -050076 /** This register's address. */
77 const uint32_t iv_address;
78
79}; // end class ScomRegister
80
81/**
82 * @brief A Power Systems Indirect SCOM register.
83 *
84 * Address width: 8 bytes
85 * Register width: 2* bytes (see note below)
86 * Bit order: Ascending (0-63 left to right)
87 *
88 * IMPORTANT NOTE:
89 * Technically, only two bytes of data are actually used. However, the bit
90 * definition of these registers put the two bytes at the end of the returned
91 * value (bit 48-63). Therefore, this class will be made to look like the
92 * width is 8 bytes in order to make the bit indexing work in the returned
93 * BitString.
94 */
95class IdScomRegister : public HardwareRegister
96{
97 public: // Constructor, destructors, assignment, etc.
Zane Shelley8deb0902019-10-14 15:52:27 -050098 /**
99 * @brief Constructor from components.
Zane Shelley7667b712020-05-11 20:45:40 -0500100 * @param i_id Unique ID for this register.
101 * @param i_instance Instance of this register
102 * @param i_flags Attribute flags for this register.
103 * @param i_address An 8-byte address for this Indirect SCOM register.
Zane Shelley8deb0902019-10-14 15:52:27 -0500104 */
Zane Shelley5ec88102020-05-11 21:08:25 -0500105 IdScomRegister(RegisterId_t i_id, Instance_t i_instance,
106 RegisterAttributeFlags_t i_flags, uint64_t i_address) :
107 HardwareRegister(i_id, i_instance, i_flags),
Zane Shelley83da2452019-10-25 15:45:34 -0500108 iv_address(i_address)
Zane Shelley8deb0902019-10-14 15:52:27 -0500109 {}
110
111 /** @brief Destructor. */
112 ~IdScomRegister() = default;
113
Zane Shelley2f341bf2019-10-16 11:19:36 -0500114 private:
Zane Shelley2f341bf2019-10-16 11:19:36 -0500115 // This is needed to allow the flyweights to use the copy constructor, but
116 // not allow it to be used in general.
117 friend class Flyweight<IdScomRegister>;
118
Zane Shelley8deb0902019-10-14 15:52:27 -0500119 /**
120 * @brief Copy constructor.
121 *
Zane Shelley2f341bf2019-10-16 11:19:36 -0500122 * Needed by Flyweight class, but should not be allowed in general.
Zane Shelley8deb0902019-10-14 15:52:27 -0500123 */
Zane Shelleyfe27b652019-10-28 11:33:07 -0500124 IdScomRegister(const IdScomRegister&) = default;
Zane Shelley8deb0902019-10-14 15:52:27 -0500125
126 /**
127 * @brief Explicitly disables assignment operator.
128 *
129 * This is redundant since the compilier will implicitly delete this because
130 * of the constant instance variables, but helps communicate it is not
131 * allowed.
132 */
Zane Shelleyfe27b652019-10-28 11:33:07 -0500133 IdScomRegister& operator=(const IdScomRegister&) = delete;
Zane Shelley8deb0902019-10-14 15:52:27 -0500134
135 public: // Accessor functions
Zane Shelley8deb0902019-10-14 15:52:27 -0500136 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley5ec88102020-05-11 21:08:25 -0500137 RegisterType_t getType() const
Zane Shelley7f7a42d2019-10-28 13:28:31 -0500138 {
139 return REG_TYPE_ID_SCOM;
140 }
Zane Shelley8deb0902019-10-14 15:52:27 -0500141
142 /** Function overloaded from parent HardwareRegister class. */
143 RegisterAddress_t getAddress() const
144 {
Zane Shelley83da2452019-10-25 15:45:34 -0500145 return static_cast<RegisterAddress_t>(iv_address);
Zane Shelley8deb0902019-10-14 15:52:27 -0500146 }
147
148 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -0500149 size_t getSize() const
150 {
151 return 8; // See note in class documentation.
152 }
Zane Shelley8deb0902019-10-14 15:52:27 -0500153
Zane Shelley8deb0902019-10-14 15:52:27 -0500154 private: // Instance variables
Zane Shelley8deb0902019-10-14 15:52:27 -0500155 /** This register's address. */
156 const uint64_t iv_address;
157
158}; // end class IdScomRegister
159
160} // end namespace libhei