Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Zane Shelley | 3a02e24 | 2020-05-08 16:25:36 -0500 | [diff] [blame^] | 3 | #include <hei_chip.hpp> |
| 4 | #include <hei_types.hpp> |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 5 | |
| 6 | namespace libhei |
| 7 | { |
| 8 | |
| 9 | /** |
| 10 | * @brief A signature represents an active attention from a single bit on a |
| 11 | * register within a chip. |
| 12 | * |
| 13 | * The isolator will gather a list of all active attentions on a chip and return |
| 14 | * a list of signatures to the user application. The user application should be |
| 15 | * able to determine what actions to take based on these signatures. |
| 16 | */ |
| 17 | class Signature |
| 18 | { |
| 19 | public: // Constructors, destructor, assignment, etc. |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 20 | /** |
| 21 | * @brief Constructor from components. |
| 22 | * @param i_chip The chip containing this register. |
| 23 | * @param i_id The register ID. |
| 24 | * @param i_instance The instance of this register. |
| 25 | * @param i_bit The target bit within this register. |
| 26 | * @param i_attnType The attention type reported by this bit. |
| 27 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 28 | Signature(const Chip& i_chip, RegisterId_t i_id, |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 29 | RegisterInstance_t i_instance, RegisterBit_t i_bit, |
| 30 | AttentionType_t i_attnType) : |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 31 | iv_chip(i_chip), |
| 32 | iv_id(i_id), iv_instance(i_instance), iv_bit(i_bit), |
| 33 | iv_attnType(i_attnType) |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 34 | {} |
| 35 | |
| 36 | /** @brief Destructor. */ |
| 37 | ~Signature() = default; |
| 38 | |
| 39 | /** @brief Copy constructor. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 40 | Signature(const Signature&) = default; |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 41 | |
| 42 | /** @brief Assignment operator. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 43 | Signature& operator=(const Signature&) = default; |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 44 | |
Zane Shelley | 7c8faa1 | 2019-10-28 22:26:28 -0500 | [diff] [blame] | 45 | private: |
| 46 | Chip iv_chip; ///< Chip containing this register. |
| 47 | RegisterId_t iv_id; ///< Register ID. |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 48 | RegisterInstance_t iv_instance; ///< Instance of this register. |
Zane Shelley | 7c8faa1 | 2019-10-28 22:26:28 -0500 | [diff] [blame] | 49 | RegisterBit_t iv_bit; ///< Target bit within this register. |
| 50 | AttentionType_t iv_attnType; ///< Attention type reported by this bit. |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 51 | |
| 52 | public: // Member functions |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 53 | /** @return The chip containing this register. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 54 | const Chip& getChip() const |
| 55 | { |
| 56 | return iv_chip; |
| 57 | } |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 58 | |
| 59 | /** @return The register ID. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 60 | RegisterId_t getId() const |
| 61 | { |
| 62 | return iv_id; |
| 63 | } |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 64 | |
| 65 | /** @return The instance of this register. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 66 | RegisterInstance_t getInstance() const |
| 67 | { |
| 68 | return iv_instance; |
| 69 | } |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 70 | |
| 71 | /** @return The target bit within this register. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 72 | RegisterBit_t getBit() const |
| 73 | { |
| 74 | return iv_bit; |
| 75 | } |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 76 | |
| 77 | /** @return The attention type reported by this bit. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 78 | AttentionType_t getAttnType() const |
| 79 | { |
| 80 | return iv_attnType; |
| 81 | } |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 82 | |
| 83 | public: // Operators |
| 84 | /** @brief Equals operator. */ |
| 85 | bool operator==(const Signature& i_r) const |
| 86 | { |
| 87 | return (getChip() == i_r.getChip() && getId() == i_r.getId() && |
| 88 | getInstance() == i_r.getInstance() && |
| 89 | getBit() == i_r.getBit() && getAttnType() == i_r.getAttnType()); |
| 90 | } |
| 91 | |
| 92 | /** @brief Less than operator. */ |
| 93 | bool operator<(const Signature& i_r) const |
| 94 | { |
| 95 | if (getChip() < i_r.getChip()) |
| 96 | { |
| 97 | return true; |
| 98 | } |
| 99 | else if (getChip() == i_r.getChip()) |
| 100 | { |
| 101 | if (getId() < i_r.getId()) |
| 102 | { |
| 103 | return true; |
| 104 | } |
| 105 | else if (getId() == i_r.getId()) |
| 106 | { |
| 107 | if (getInstance() < i_r.getInstance()) |
| 108 | { |
| 109 | return true; |
| 110 | } |
| 111 | else if (getInstance() == i_r.getInstance()) |
| 112 | { |
| 113 | if (getBit() < i_r.getBit()) |
| 114 | { |
| 115 | return true; |
| 116 | } |
| 117 | else if (getBit() == i_r.getBit()) |
| 118 | { |
| 119 | return (getAttnType() < i_r.getAttnType()); |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | return false; |
| 126 | } |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 127 | }; |
| 128 | |
| 129 | } // end namespace libhei |