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