Zane Shelley | 871adec | 2019-07-30 11:01:39 -0500 | [diff] [blame] | 1 | #pragma once |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 2 | |
Zane Shelley | 52cb1a9 | 2019-08-21 14:38:31 -0500 | [diff] [blame] | 3 | #include <register/hei_register.hpp> |
| 4 | |
Zane Shelley | 871adec | 2019-07-30 11:01:39 -0500 | [diff] [blame] | 5 | namespace libhei |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 6 | { |
| 7 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 8 | /** |
| 9 | * @brief An abstract class for all operator registers. |
| 10 | * |
| 11 | * Contains member functions and variables that are required for all child |
| 12 | * classes. |
| 13 | */ |
| 14 | class OperatorRegister : public Register |
| 15 | { |
| 16 | public: |
| 17 | /** @brief Pure virtual destructor. */ |
| 18 | virtual ~OperatorRegister() = 0; |
| 19 | |
| 20 | protected: |
| 21 | /** |
| 22 | * @brief Constructor from components. |
| 23 | * @param i_size Size (in bytes) of this register. |
| 24 | */ |
| 25 | explicit OperatorRegister(size_t i_size) : Register(), iv_result(i_size * 8) |
| 26 | {} |
| 27 | |
| 28 | protected: // Instance variables |
| 29 | /** When getBitString() is called on an operator, the resulting value of the |
| 30 | * operation will be stored in this instance variable. */ |
| 31 | BitStringBuffer iv_result; |
| 32 | |
| 33 | public: |
| 34 | /** @brief Overloaded from parent class. */ |
| 35 | virtual const BitString* getBitString(const Chip& i_chip) const = 0; |
| 36 | |
| 37 | /** @brief Overloaded from parent class. */ |
| 38 | size_t getSize() const |
| 39 | { |
| 40 | return (BitString::getMinBytes(iv_result.getBitLen())); |
| 41 | } |
| 42 | }; |
| 43 | |
| 44 | // Pure virtual destructor must be defined. |
| 45 | inline OperatorRegister::~OperatorRegister() {} |
| 46 | |
| 47 | class NotRegister : public OperatorRegister |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 48 | { |
| 49 | public: |
Zane Shelley | 48aa860 | 2019-12-05 21:41:21 -0600 | [diff] [blame] | 50 | /** |
| 51 | * @brief Constructor from components. |
| 52 | * @param i_arg Target register for operation. |
| 53 | */ |
| 54 | explicit NotRegister(Register& i_arg) : |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 55 | OperatorRegister(i_arg.getSize()), iv_child(&i_arg) |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 56 | {} |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 57 | |
Zane Shelley | 48aa860 | 2019-12-05 21:41:21 -0600 | [diff] [blame] | 58 | /** @brief Default destructor. */ |
| 59 | ~NotRegister() = default; |
| 60 | |
| 61 | /** @brief Default copy constructor. */ |
| 62 | NotRegister(const NotRegister&) = default; |
| 63 | |
| 64 | /** @brief Default assignment operator. */ |
| 65 | NotRegister& operator=(const NotRegister& r) = default; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 66 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 67 | /** @brief Overloaded from parent class. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 68 | const BitString* getBitString(const Chip& i_chip) const |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 69 | { |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 70 | const auto* bs = iv_child->getBitString(i_chip); |
| 71 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 72 | (const_cast<NotRegister*>(this))->iv_result = ~(*bs); |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 73 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 74 | return &iv_result; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 75 | } |
| 76 | |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 77 | /** @brief Comparison operator. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 78 | bool operator==(const NotRegister& r) const |
| 79 | { |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 80 | return iv_child == r.iv_child; |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 81 | } |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 82 | |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 83 | /** @brief Less-than operator. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 84 | bool operator<(const NotRegister& r) const |
| 85 | { |
| 86 | return iv_child < r.iv_child; |
| 87 | } |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 88 | |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 89 | private: |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 90 | Register* iv_child; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 91 | }; |
| 92 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 93 | class LeftShiftRegister : public OperatorRegister |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 94 | { |
| 95 | public: |
Zane Shelley | 48aa860 | 2019-12-05 21:41:21 -0600 | [diff] [blame] | 96 | /** |
| 97 | * @brief Constructor from components. |
| 98 | * @param i_arg Target register for operation. |
| 99 | * @param i_amount The shift value. |
| 100 | */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 101 | LeftShiftRegister(Register& i_arg, uint16_t i_amount) : |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 102 | OperatorRegister(i_arg.getSize()), iv_child(&i_arg), iv_amount(i_amount) |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 103 | {} |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 104 | |
Zane Shelley | 48aa860 | 2019-12-05 21:41:21 -0600 | [diff] [blame] | 105 | /** @brief Default destructor. */ |
| 106 | ~LeftShiftRegister() = default; |
| 107 | |
| 108 | /** @brief Default copy constructor. */ |
| 109 | LeftShiftRegister(const LeftShiftRegister&) = default; |
| 110 | |
| 111 | /** @brief Default assignment operator. */ |
| 112 | LeftShiftRegister& operator=(const LeftShiftRegister& r) = default; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 113 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 114 | /** @brief Overloaded from parent class. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 115 | const BitString* getBitString(const Chip& i_chip) const |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 116 | { |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 117 | const auto* bs = iv_child->getBitString(i_chip); |
| 118 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 119 | (const_cast<LeftShiftRegister*>(this))->iv_result = (*bs) << iv_amount; |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 120 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 121 | return &iv_result; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 122 | } |
| 123 | |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 124 | /** @brief Comparison operator. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 125 | bool operator==(const LeftShiftRegister& r) const |
| 126 | { |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 127 | return (iv_child == r.iv_child) && (iv_amount == r.iv_amount); |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 128 | } |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 129 | |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 130 | /** @brief Less-than operator. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 131 | bool operator<(const LeftShiftRegister& r) const |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 132 | { |
| 133 | if (iv_child == r.iv_child) |
| 134 | return iv_amount < r.iv_amount; |
| 135 | return iv_child < r.iv_child; |
| 136 | } |
| 137 | |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 138 | private: |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 139 | Register* iv_child; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 140 | uint16_t iv_amount; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 141 | }; |
| 142 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 143 | class RightShiftRegister : public OperatorRegister |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 144 | { |
| 145 | public: |
Zane Shelley | 48aa860 | 2019-12-05 21:41:21 -0600 | [diff] [blame] | 146 | /** |
| 147 | * @brief Constructor from components. |
| 148 | * @param i_arg Target register for operation. |
| 149 | * @param i_amount The shift value. |
| 150 | */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 151 | RightShiftRegister(Register& i_arg, uint16_t i_amount) : |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 152 | OperatorRegister(i_arg.getSize()), iv_child(&i_arg), iv_amount(i_amount) |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 153 | {} |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 154 | |
Zane Shelley | 48aa860 | 2019-12-05 21:41:21 -0600 | [diff] [blame] | 155 | /** @brief Default destructor. */ |
| 156 | ~RightShiftRegister() = default; |
| 157 | |
| 158 | /** @brief Default copy constructor. */ |
| 159 | RightShiftRegister(const RightShiftRegister&) = default; |
| 160 | |
| 161 | /** @brief Default assignment operator. */ |
| 162 | RightShiftRegister& operator=(const RightShiftRegister& r) = default; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 163 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 164 | /** @brief Overloaded from parent class. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 165 | const BitString* getBitString(const Chip& i_chip) const |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 166 | { |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 167 | const auto* bs = iv_child->getBitString(i_chip); |
| 168 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 169 | (const_cast<RightShiftRegister*>(this))->iv_result = (*bs) >> iv_amount; |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 170 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 171 | return &iv_result; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 172 | } |
| 173 | |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 174 | /** @brief Comparison operator. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 175 | bool operator==(const RightShiftRegister& r) const |
| 176 | { |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 177 | return (iv_child == r.iv_child) && (iv_amount == r.iv_amount); |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 178 | } |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 179 | |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 180 | /** @brief Less-than operator. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 181 | bool operator<(const RightShiftRegister& r) const |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 182 | { |
| 183 | if (iv_child == r.iv_child) |
| 184 | return iv_amount < r.iv_amount; |
| 185 | return iv_child < r.iv_child; |
| 186 | } |
| 187 | |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 188 | private: |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 189 | Register* iv_child; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 190 | uint16_t iv_amount; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 191 | }; |
| 192 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 193 | class AndRegister : public OperatorRegister |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 194 | { |
| 195 | public: |
Zane Shelley | 48aa860 | 2019-12-05 21:41:21 -0600 | [diff] [blame] | 196 | /** |
| 197 | * @brief Constructor from components. |
| 198 | * @param i_left Target register for operation. |
| 199 | * @param i_right Target register for operation. |
| 200 | */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 201 | AndRegister(Register& i_left, Register& i_right) : |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 202 | OperatorRegister(std::min(i_left.getSize(), i_right.getSize())), |
| 203 | iv_left(&i_left), iv_right(&i_right) |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 204 | {} |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 205 | |
Zane Shelley | 48aa860 | 2019-12-05 21:41:21 -0600 | [diff] [blame] | 206 | /** @brief Default destructor. */ |
| 207 | ~AndRegister() = default; |
| 208 | |
| 209 | /** @brief Default copy constructor. */ |
| 210 | AndRegister(const AndRegister&) = default; |
| 211 | |
| 212 | /** @brief Default assignment operator. */ |
| 213 | AndRegister& operator=(const AndRegister& r) = default; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 214 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 215 | /** @brief Overloaded from parent class. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 216 | const BitString* getBitString(const Chip& i_chip) const |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 217 | { |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 218 | const auto* l_bs = iv_left->getBitString(i_chip); |
| 219 | const auto* r_bs = iv_right->getBitString(i_chip); |
| 220 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 221 | (const_cast<AndRegister*>(this))->iv_result = (*l_bs) & (*r_bs); |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 222 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 223 | return &iv_result; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 224 | } |
| 225 | |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 226 | /** @brief Comparison operator. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 227 | bool operator==(const AndRegister& r) const |
| 228 | { |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 229 | return (iv_left == r.iv_left) && (iv_right == r.iv_right); |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 230 | } |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 231 | |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 232 | /** @brief Less-than operator. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 233 | bool operator<(const AndRegister& r) const |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 234 | { |
| 235 | if (iv_left == r.iv_left) |
| 236 | return iv_right < r.iv_right; |
| 237 | return iv_left < r.iv_left; |
| 238 | } |
| 239 | |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 240 | private: |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 241 | Register* iv_left; |
| 242 | Register* iv_right; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 243 | }; |
| 244 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 245 | class OrRegister : public OperatorRegister |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 246 | { |
| 247 | public: |
Zane Shelley | 48aa860 | 2019-12-05 21:41:21 -0600 | [diff] [blame] | 248 | /** |
| 249 | * @brief Constructor from components. |
| 250 | * @param i_left Target register for operation. |
| 251 | * @param i_right Target register for operation. |
| 252 | */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 253 | OrRegister(Register& i_left, Register& i_right) : |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 254 | OperatorRegister(std::min(i_left.getSize(), i_right.getSize())), |
| 255 | iv_left(&i_left), iv_right(&i_right) |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 256 | {} |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 257 | |
Zane Shelley | 48aa860 | 2019-12-05 21:41:21 -0600 | [diff] [blame] | 258 | /** @brief Default destructor. */ |
| 259 | ~OrRegister() = default; |
| 260 | |
| 261 | /** @brief Default copy constructor. */ |
| 262 | OrRegister(const OrRegister&) = default; |
| 263 | |
| 264 | /** @brief Default assignment operator. */ |
| 265 | OrRegister& operator=(const OrRegister& r) = default; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 266 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 267 | /** @brief Overloaded from parent class. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 268 | const BitString* getBitString(const Chip& i_chip) const |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 269 | { |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 270 | const auto* l_bs = iv_left->getBitString(i_chip); |
| 271 | const auto* r_bs = iv_right->getBitString(i_chip); |
| 272 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 273 | (const_cast<OrRegister*>(this))->iv_result = (*l_bs) | (*r_bs); |
Zane Shelley | d4c0e98 | 2019-12-05 21:27:41 -0600 | [diff] [blame] | 274 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 275 | return &iv_result; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 276 | } |
| 277 | |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 278 | /** @brief Comparison operator. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 279 | bool operator==(const OrRegister& r) const |
| 280 | { |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 281 | return (iv_left == r.iv_left) && (iv_right == r.iv_right); |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 282 | } |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 283 | |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 284 | /** @brief Less-than operator. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 285 | bool operator<(const OrRegister& r) const |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 286 | { |
| 287 | if (iv_left == r.iv_left) |
| 288 | return iv_right < r.iv_right; |
| 289 | return iv_left < r.iv_left; |
| 290 | } |
| 291 | |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 292 | private: |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 293 | Register* iv_left; |
| 294 | Register* iv_right; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 295 | }; |
| 296 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 297 | class ConstantRegister : public OperatorRegister |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 298 | { |
| 299 | public: |
Zane Shelley | 48aa860 | 2019-12-05 21:41:21 -0600 | [diff] [blame] | 300 | /** |
| 301 | * @brief Constructor from components. |
| 302 | * @param i_arg A BitStringBuffer containing the constant value. |
| 303 | */ |
| 304 | explicit ConstantRegister(const BitStringBuffer& i_arg) : |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 305 | OperatorRegister(BitString::getMinBytes(i_arg.getBitLen())) |
| 306 | { |
| 307 | iv_result = i_arg; |
| 308 | } |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 309 | |
Zane Shelley | 48aa860 | 2019-12-05 21:41:21 -0600 | [diff] [blame] | 310 | /** @brief Default destructor. */ |
| 311 | ~ConstantRegister() = default; |
| 312 | |
| 313 | /** @brief Default copy constructor. */ |
| 314 | ConstantRegister(const ConstantRegister&) = default; |
| 315 | |
| 316 | /** @brief Default assignment operator. */ |
| 317 | ConstantRegister& operator=(const ConstantRegister& r) = default; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 318 | |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 319 | /** @brief Overloaded from parent class. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 320 | const BitString* getBitString(const Chip& i_chip) const |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 321 | { |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 322 | return &iv_result; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 323 | } |
| 324 | |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 325 | /** @brief Comparison operator. */ |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 326 | bool operator==(const ConstantRegister& r) const |
| 327 | { |
Zane Shelley | ec06f82 | 2019-12-05 22:23:19 -0600 | [diff] [blame^] | 328 | return iv_result == r.iv_result; |
| 329 | } |
| 330 | |
| 331 | /** @brief Less-than operator. */ |
| 332 | bool operator<(const ConstantRegister& r) const |
| 333 | { |
| 334 | return iv_result < r.iv_result; |
Zane Shelley | caee69f | 2019-12-05 13:42:58 -0600 | [diff] [blame] | 335 | } |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 336 | }; |
| 337 | |
Zane Shelley | 871adec | 2019-07-30 11:01:39 -0500 | [diff] [blame] | 338 | } // end namespace libhei |