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 <hei_includes.hpp> |
| 4 | #include <util/hei_bit_string.hpp> |
| 5 | |
Zane Shelley | 871adec | 2019-07-30 11:01:39 -0500 | [diff] [blame] | 6 | namespace libhei |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 7 | { |
| 8 | |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 9 | /** |
Zane Shelley | 65ed96a | 2019-10-14 13:06:11 -0500 | [diff] [blame] | 10 | @brief An abstract class for register objects. |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 11 | |
| 12 | Purpose: Register is an abstract base class for real and virtual registers. |
| 13 | A few examples of these registers are; HardwareRegister, ConstantRegister, |
| 14 | NotRegister, and AndRegister. As a base class of register types, Register |
| 15 | creates a place where these registers can be put together like logical |
| 16 | building blocks. For example, Register makes this possible: |
| 17 | |
Paul Greenwood | dc47e0a | 2019-11-01 16:22:57 -0500 | [diff] [blame] | 18 | Register * mask1 = new ConstantRegister(0xffff000000000000); |
| 19 | Register * mask2 = new ConstantRegister(0xffffffff00000000); |
| 20 | Register * fir_mask = new AndRegister(mask1, mask2); |
Zane Shelley | 53efc35 | 2019-10-03 21:46:39 -0500 | [diff] [blame] | 21 | const BitString * bs = fir_mask->getBitString(chip); |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 22 | |
| 23 | The getBitString function (defined by each register) provides access to |
| 24 | the BitString that manages each register's data. In this example bs will |
Paul Greenwood | dc47e0a | 2019-11-01 16:22:57 -0500 | [diff] [blame] | 25 | contain the result of mask1 & mask2. |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 26 | */ |
| 27 | class Register |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 28 | { |
Zane Shelley | 4de8ff8 | 2020-05-14 15:39:01 -0500 | [diff] [blame] | 29 | public: // Aliases |
| 30 | using Ptr = std::shared_ptr<Register>; |
| 31 | using ConstPtr = std::shared_ptr<const Register>; |
| 32 | |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 33 | public: |
Zane Shelley | 65ed96a | 2019-10-14 13:06:11 -0500 | [diff] [blame] | 34 | /** @brief Pure virtual destructor. */ |
| 35 | virtual ~Register() = 0; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 36 | |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 37 | /** |
Zane Shelley | 53efc35 | 2019-10-03 21:46:39 -0500 | [diff] [blame] | 38 | * @brief Provides access to the value of this register. |
| 39 | * @param i_chip Indicates which chip to access for this register. |
| 40 | * @return A BitString containing the value of this register. |
| 41 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 42 | virtual const BitString* getBitString(const Chip& i_chip) const = 0; |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 43 | |
| 44 | /** @return The size (in bytes) of this register. */ |
| 45 | virtual size_t getSize() const = 0; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 46 | }; |
| 47 | |
Zane Shelley | 65ed96a | 2019-10-14 13:06:11 -0500 | [diff] [blame] | 48 | // Pure virtual destructor must be defined. |
| 49 | inline Register::~Register() {} |
| 50 | |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 51 | } // end namespace libhei |