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 | |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 3 | #include <stdio.h> |
Zane Shelley | 52cb1a9 | 2019-08-21 14:38:31 -0500 | [diff] [blame] | 4 | #include <hei_includes.hpp> |
| 5 | #include <util/hei_bit_string.hpp> |
| 6 | |
Zane Shelley | 871adec | 2019-07-30 11:01:39 -0500 | [diff] [blame] | 7 | namespace libhei |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 8 | { |
| 9 | |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 10 | /** |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 11 | @brief Description: The Register class. |
| 12 | |
| 13 | Purpose: Register is an abstract base class for real and virtual registers. |
| 14 | A few examples of these registers are; HardwareRegister, ConstantRegister, |
| 15 | NotRegister, and AndRegister. As a base class of register types, Register |
| 16 | creates a place where these registers can be put together like logical |
| 17 | building blocks. For example, Register makes this possible: |
| 18 | |
| 19 | Register * fir = new HardwareRegister(REG_ADDRESS, REG_WIDTH, |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame^] | 20 | CHIP_TYPE, ACCESS_RO); |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 21 | Register * mask = new ConstantRegister( 0xffffffff00000000 ); |
| 22 | Register * fir_mask = new AndRegister(fir, mask); |
| 23 | const BitString * bs = fir_mask->getBitString(); |
| 24 | |
| 25 | The getBitString function (defined by each register) provides access to |
| 26 | the BitString that manages each register's data. In this example bs will |
| 27 | contain the result of fir & mask. |
| 28 | */ |
| 29 | class Register |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 30 | { |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 31 | public: |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 32 | |
| 33 | /** |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 34 | @brief Default constructor |
| 35 | */ |
| 36 | Register() = default; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 37 | |
| 38 | /** |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 39 | @brief Delete copy, assignment, and move operators. Deleting |
| 40 | copy causes the compiler to delete move. |
| 41 | */ |
| 42 | Register(const Register&) = delete; |
| 43 | Register& operator=(const Register&) = delete; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 44 | |
| 45 | /** |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 46 | @brief Default destructor |
| 47 | */ |
| 48 | virtual ~Register() = default; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 49 | |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 50 | /** |
| 51 | @brief Provides access to the BitString that manages |
| 52 | this register's data. |
| 53 | @return A pointer to a BitString. |
| 54 | */ |
| 55 | virtual const BitString * getBitString() const = 0; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 56 | |
| 57 | }; |
| 58 | |
Paul Greenwood | 701fcc1 | 2019-08-15 19:29:31 -0500 | [diff] [blame] | 59 | }//end namespace libhei |