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 | |
| 18 | Register * fir = new HardwareRegister(REG_ADDRESS, REG_WIDTH, |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 19 | CHIP_TYPE, ACCESS_RO); |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 20 | Register * mask = new ConstantRegister(0xffffffff00000000); |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 21 | Register * fir_mask = new AndRegister(fir, mask); |
Zane Shelley | 53efc35 | 2019-10-03 21:46:39 -0500 | [diff] [blame] | 22 | const BitString * bs = fir_mask->getBitString(chip); |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 23 | |
| 24 | The getBitString function (defined by each register) provides access to |
| 25 | the BitString that manages each register's data. In this example bs will |
| 26 | contain the result of fir & mask. |
| 27 | */ |
| 28 | class Register |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 29 | { |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 30 | public: |
Zane Shelley | 65ed96a | 2019-10-14 13:06:11 -0500 | [diff] [blame] | 31 | /** @brief Pure virtual destructor. */ |
| 32 | virtual ~Register() = 0; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 33 | |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 34 | /** |
Zane Shelley | 53efc35 | 2019-10-03 21:46:39 -0500 | [diff] [blame] | 35 | * @brief Provides access to the value of this register. |
| 36 | * @param i_chip Indicates which chip to access for this register. |
| 37 | * @return A BitString containing the value of this register. |
| 38 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 39 | virtual const BitString* getBitString(const Chip& i_chip) const = 0; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 40 | }; |
| 41 | |
Zane Shelley | 65ed96a | 2019-10-14 13:06:11 -0500 | [diff] [blame] | 42 | // Pure virtual destructor must be defined. |
| 43 | inline Register::~Register() {} |
| 44 | |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 45 | } // end namespace libhei |