blob: b8206009af74292f1921ddfdaaf3179ca7e69331 [file] [log] [blame]
Zane Shelley93b61ad2019-10-16 20:41:03 -05001#pragma once
2
Zane Shelley3a02e242020-05-08 16:25:36 -05003#include <hei_chip.hpp>
4#include <hei_types.hpp>
Zane Shelley93b61ad2019-10-16 20:41:03 -05005
6namespace libhei
7{
8
9/**
Zane Shelley6722b5b2020-05-12 22:09:04 -050010 * @brief A signature represents an active attention from a single bit position
11 * from an isolation node within a chip.
Zane Shelley93b61ad2019-10-16 20:41:03 -050012 *
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 */
17class Signature
18{
19 public: // Constructors, destructor, assignment, etc.
Zane Shelleydc7baeb2020-06-11 14:28:46 -050020 /** @brief Default constructor. */
21 Signature() = default;
22
Zane Shelley93b61ad2019-10-16 20:41:03 -050023 /**
24 * @brief Constructor from components.
25 * @param i_chip The chip containing this register.
Zane Shelley6722b5b2020-05-12 22:09:04 -050026 * @param i_id The node ID.
Zane Shelley93b61ad2019-10-16 20:41:03 -050027 * @param i_instance The instance of this register.
28 * @param i_bit The target bit within this register.
29 * @param i_attnType The attention type reported by this bit.
30 */
Zane Shelley6722b5b2020-05-12 22:09:04 -050031 Signature(const Chip& i_chip, NodeId_t i_id, Instance_t i_instance,
Zane Shelley13b182b2020-05-07 20:23:45 -050032 BitPosition_t i_bit, AttentionType_t i_attnType) :
Zane Shelley7f7a42d2019-10-28 13:28:31 -050033 iv_chip(i_chip),
34 iv_id(i_id), iv_instance(i_instance), iv_bit(i_bit),
35 iv_attnType(i_attnType)
Zane Shelley93b61ad2019-10-16 20:41:03 -050036 {}
37
38 /** @brief Destructor. */
39 ~Signature() = default;
40
41 /** @brief Copy constructor. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050042 Signature(const Signature&) = default;
Zane Shelley93b61ad2019-10-16 20:41:03 -050043
44 /** @brief Assignment operator. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050045 Signature& operator=(const Signature&) = default;
Zane Shelley93b61ad2019-10-16 20:41:03 -050046
Zane Shelley7c8faa12019-10-28 22:26:28 -050047 private:
Zane Shelley13b182b2020-05-07 20:23:45 -050048 Chip iv_chip; ///< Chip containing this register.
Zane Shelley6722b5b2020-05-12 22:09:04 -050049 NodeId_t iv_id; ///< Node ID.
Zane Shelley13b182b2020-05-07 20:23:45 -050050 Instance_t iv_instance; ///< Instance of this register.
51 BitPosition_t iv_bit; ///< Target bit within this register.
52 AttentionType_t iv_attnType; ///< Attention type reported by this bit.
Zane Shelley93b61ad2019-10-16 20:41:03 -050053
54 public: // Member functions
Zane Shelley93b61ad2019-10-16 20:41:03 -050055 /** @return The chip containing this register. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -050056 const Chip& getChip() const
57 {
58 return iv_chip;
59 }
Zane Shelley93b61ad2019-10-16 20:41:03 -050060
61 /** @return The register ID. */
Zane Shelley6722b5b2020-05-12 22:09:04 -050062 NodeId_t getId() const
Zane Shelley7f7a42d2019-10-28 13:28:31 -050063 {
64 return iv_id;
65 }
Zane Shelley93b61ad2019-10-16 20:41:03 -050066
67 /** @return The instance of this register. */
Zane Shelley13b182b2020-05-07 20:23:45 -050068 Instance_t getInstance() const
Zane Shelley7f7a42d2019-10-28 13:28:31 -050069 {
70 return iv_instance;
71 }
Zane Shelley93b61ad2019-10-16 20:41:03 -050072
73 /** @return The target bit within this register. */
Zane Shelley13b182b2020-05-07 20:23:45 -050074 BitPosition_t getBit() const
Zane Shelley7f7a42d2019-10-28 13:28:31 -050075 {
76 return iv_bit;
77 }
Zane Shelley93b61ad2019-10-16 20:41:03 -050078
79 /** @return The attention type reported by this bit. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -050080 AttentionType_t getAttnType() const
81 {
82 return iv_attnType;
83 }
Zane Shelley11b89942019-11-07 11:07:28 -060084
85 public: // Operators
86 /** @brief Equals operator. */
87 bool operator==(const Signature& i_r) const
88 {
89 return (getChip() == i_r.getChip() && getId() == i_r.getId() &&
90 getInstance() == i_r.getInstance() &&
91 getBit() == i_r.getBit() && getAttnType() == i_r.getAttnType());
92 }
93
94 /** @brief Less than operator. */
95 bool operator<(const Signature& i_r) const
96 {
97 if (getChip() < i_r.getChip())
98 {
99 return true;
100 }
101 else if (getChip() == i_r.getChip())
102 {
103 if (getId() < i_r.getId())
104 {
105 return true;
106 }
107 else if (getId() == i_r.getId())
108 {
109 if (getInstance() < i_r.getInstance())
110 {
111 return true;
112 }
113 else if (getInstance() == i_r.getInstance())
114 {
115 if (getBit() < i_r.getBit())
116 {
117 return true;
118 }
119 else if (getBit() == i_r.getBit())
120 {
121 return (getAttnType() < i_r.getAttnType());
122 }
123 }
124 }
125 }
126
127 return false;
128 }
Zane Shelley93b61ad2019-10-16 20:41:03 -0500129};
130
131} // end namespace libhei