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 | /** |
Zane Shelley | 6722b5b | 2020-05-12 22:09:04 -0500 | [diff] [blame] | 10 | * @brief A signature represents an active attention from a single bit position |
| 11 | * from an isolation node within a chip. |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 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 | 8453353 | 2020-06-11 15:20:50 -0500 | [diff] [blame] | 20 | /** |
| 21 | * @brief Default contructor. |
| 22 | * |
| 23 | * In general the default constructor should not be used, but it is needed |
| 24 | * for some STL functions. |
| 25 | */ |
Zane Shelley | dc7baeb | 2020-06-11 14:28:46 -0500 | [diff] [blame] | 26 | Signature() = default; |
| 27 | |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 28 | /** |
| 29 | * @brief Constructor from components. |
| 30 | * @param i_chip The chip containing this register. |
Zane Shelley | 6722b5b | 2020-05-12 22:09:04 -0500 | [diff] [blame] | 31 | * @param i_id The node ID. |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 32 | * @param i_instance The instance of this register. |
| 33 | * @param i_bit The target bit within this register. |
| 34 | * @param i_attnType The attention type reported by this bit. |
| 35 | */ |
Zane Shelley | 6722b5b | 2020-05-12 22:09:04 -0500 | [diff] [blame] | 36 | Signature(const Chip& i_chip, NodeId_t i_id, Instance_t i_instance, |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 37 | BitPosition_t i_bit, AttentionType_t i_attnType) : |
Patrick Williams | 8db65db | 2024-08-16 15:22:30 -0400 | [diff] [blame^] | 38 | iv_chip(i_chip), iv_id(i_id), iv_instance(i_instance), iv_bit(i_bit), |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 39 | iv_attnType(i_attnType) |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 40 | {} |
| 41 | |
| 42 | /** @brief Destructor. */ |
| 43 | ~Signature() = default; |
| 44 | |
| 45 | /** @brief Copy constructor. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 46 | Signature(const Signature&) = default; |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 47 | |
| 48 | /** @brief Assignment operator. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 49 | Signature& operator=(const Signature&) = default; |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 50 | |
Zane Shelley | 7c8faa1 | 2019-10-28 22:26:28 -0500 | [diff] [blame] | 51 | private: |
Zane Shelley | 5a78fa8 | 2022-09-16 16:49:58 -0500 | [diff] [blame] | 52 | Chip iv_chip; ///< Chip containing this register. |
Patrick Williams | 2f7537d | 2023-05-10 07:51:39 -0500 | [diff] [blame] | 53 | NodeId_t iv_id = 0; ///< Node ID. |
Zane Shelley | 5a78fa8 | 2022-09-16 16:49:58 -0500 | [diff] [blame] | 54 | Instance_t iv_instance = 0; ///< Instance of this register. |
Patrick Williams | 2f7537d | 2023-05-10 07:51:39 -0500 | [diff] [blame] | 55 | BitPosition_t iv_bit = 0; ///< Target bit within this register. |
Zane Shelley | 5a78fa8 | 2022-09-16 16:49:58 -0500 | [diff] [blame] | 56 | |
| 57 | /** Attention type reported by this bit. */ |
Zane Shelley | b7005ca | 2023-03-24 15:23:59 -0500 | [diff] [blame] | 58 | AttentionType_t iv_attnType = ATTN_TYPE_CHIP_CS; |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 59 | |
| 60 | public: // Member functions |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 61 | /** @return The chip containing this register. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 62 | const Chip& getChip() const |
| 63 | { |
| 64 | return iv_chip; |
| 65 | } |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 66 | |
Zane Shelley | d280cca | 2020-11-13 17:08:24 -0600 | [diff] [blame] | 67 | /** @return The node ID. */ |
Zane Shelley | 6722b5b | 2020-05-12 22:09:04 -0500 | [diff] [blame] | 68 | NodeId_t getId() const |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 69 | { |
| 70 | return iv_id; |
| 71 | } |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 72 | |
| 73 | /** @return The instance of this register. */ |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 74 | Instance_t getInstance() const |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 75 | { |
| 76 | return iv_instance; |
| 77 | } |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 78 | |
| 79 | /** @return The target bit within this register. */ |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 80 | BitPosition_t getBit() const |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 81 | { |
| 82 | return iv_bit; |
| 83 | } |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 84 | |
| 85 | /** @return The attention type reported by this bit. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 86 | AttentionType_t getAttnType() const |
| 87 | { |
| 88 | return iv_attnType; |
| 89 | } |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 90 | |
Zane Shelley | d280cca | 2020-11-13 17:08:24 -0600 | [diff] [blame] | 91 | /** @return A 32-bit integer containing the node ID, instance, and bit. This |
| 92 | * should be helpful for consistent logging and tracing. */ |
| 93 | uint32_t toUint32() const |
| 94 | { |
| 95 | return getId() << 16 | getInstance() << 8 | getBit(); |
| 96 | } |
| 97 | |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 98 | public: // Operators |
| 99 | /** @brief Equals operator. */ |
| 100 | bool operator==(const Signature& i_r) const |
| 101 | { |
| 102 | return (getChip() == i_r.getChip() && getId() == i_r.getId() && |
| 103 | getInstance() == i_r.getInstance() && |
| 104 | getBit() == i_r.getBit() && getAttnType() == i_r.getAttnType()); |
| 105 | } |
| 106 | |
| 107 | /** @brief Less than operator. */ |
| 108 | bool operator<(const Signature& i_r) const |
| 109 | { |
| 110 | if (getChip() < i_r.getChip()) |
| 111 | { |
| 112 | return true; |
| 113 | } |
| 114 | else if (getChip() == i_r.getChip()) |
| 115 | { |
| 116 | if (getId() < i_r.getId()) |
| 117 | { |
| 118 | return true; |
| 119 | } |
| 120 | else if (getId() == i_r.getId()) |
| 121 | { |
| 122 | if (getInstance() < i_r.getInstance()) |
| 123 | { |
| 124 | return true; |
| 125 | } |
| 126 | else if (getInstance() == i_r.getInstance()) |
| 127 | { |
| 128 | if (getBit() < i_r.getBit()) |
| 129 | { |
| 130 | return true; |
| 131 | } |
| 132 | else if (getBit() == i_r.getBit()) |
| 133 | { |
| 134 | return (getAttnType() < i_r.getAttnType()); |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | return false; |
| 141 | } |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 142 | }; |
| 143 | |
| 144 | } // end namespace libhei |