blob: 4f824db25872faa8a49d1a9e885ad2651b6c26f2 [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/**
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 */
17class Signature
18{
19 public: // Constructors, destructor, assignment, etc.
Zane Shelley93b61ad2019-10-16 20:41:03 -050020 /**
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 Shelleyfe27b652019-10-28 11:33:07 -050028 Signature(const Chip& i_chip, RegisterId_t i_id,
Zane Shelley83da2452019-10-25 15:45:34 -050029 RegisterInstance_t i_instance, RegisterBit_t i_bit,
30 AttentionType_t i_attnType) :
Zane Shelley7f7a42d2019-10-28 13:28:31 -050031 iv_chip(i_chip),
32 iv_id(i_id), iv_instance(i_instance), iv_bit(i_bit),
33 iv_attnType(i_attnType)
Zane Shelley93b61ad2019-10-16 20:41:03 -050034 {}
35
36 /** @brief Destructor. */
37 ~Signature() = default;
38
39 /** @brief Copy constructor. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050040 Signature(const Signature&) = default;
Zane Shelley93b61ad2019-10-16 20:41:03 -050041
42 /** @brief Assignment operator. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050043 Signature& operator=(const Signature&) = default;
Zane Shelley93b61ad2019-10-16 20:41:03 -050044
Zane Shelley7c8faa12019-10-28 22:26:28 -050045 private:
46 Chip iv_chip; ///< Chip containing this register.
47 RegisterId_t iv_id; ///< Register ID.
Zane Shelley93b61ad2019-10-16 20:41:03 -050048 RegisterInstance_t iv_instance; ///< Instance of this register.
Zane Shelley7c8faa12019-10-28 22:26:28 -050049 RegisterBit_t iv_bit; ///< Target bit within this register.
50 AttentionType_t iv_attnType; ///< Attention type reported by this bit.
Zane Shelley93b61ad2019-10-16 20:41:03 -050051
52 public: // Member functions
Zane Shelley93b61ad2019-10-16 20:41:03 -050053 /** @return The chip containing this register. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -050054 const Chip& getChip() const
55 {
56 return iv_chip;
57 }
Zane Shelley93b61ad2019-10-16 20:41:03 -050058
59 /** @return The register ID. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -050060 RegisterId_t getId() const
61 {
62 return iv_id;
63 }
Zane Shelley93b61ad2019-10-16 20:41:03 -050064
65 /** @return The instance of this register. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -050066 RegisterInstance_t getInstance() const
67 {
68 return iv_instance;
69 }
Zane Shelley93b61ad2019-10-16 20:41:03 -050070
71 /** @return The target bit within this register. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -050072 RegisterBit_t getBit() const
73 {
74 return iv_bit;
75 }
Zane Shelley93b61ad2019-10-16 20:41:03 -050076
77 /** @return The attention type reported by this bit. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -050078 AttentionType_t getAttnType() const
79 {
80 return iv_attnType;
81 }
Zane Shelley11b89942019-11-07 11:07:28 -060082
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 Shelley93b61ad2019-10-16 20:41:03 -0500127};
128
129} // end namespace libhei