-
Notifications
You must be signed in to change notification settings - Fork 17
/
event.hh
179 lines (156 loc) · 4.34 KB
/
event.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
* SPDX-License-Identifier: BSD-3-Clause-Clear
*
* Copyright (c) 2015 ARM Limited
* All rights reserved
* Created on: 22 Jan 2016
* Author: Matteo Andreozzi
*/
#ifndef __AMBA_TRAFFIC_PROFILE_EVENT_HH__
#define __AMBA_TRAFFIC_PROFILE_EVENT_HH__
#include <functional>
#include <iostream>
using namespace std;
namespace TrafficProfiles {
/*!
*\brief AMBA Traffic Profile Event
*
* An ATP Event can be triggered by a Profile and
* is propagated by the ATP Manager to all other
* Profiles subscribed to it
*/
class Event {
private:
//! Event configuration string separator
static const string separator;
public:
/*! ATP Event Categories by which
* Events are grouped
*/
enum Category {
NO_CATEGORY = 0,
PROFILE = 1,
FIFO_LEVEL = 2,
SEND_STATUS = 3,
PACKET = 4,
CLOCK = 5,
N_CATEGORIES = 6
};
/*!
* Event Type
* NONE: an empty event
* ACTIVATION: a profile is active for the first time
* TERMINATION : a profile has issued all its transactions
* FIFO_EMPTY : a profile FIFO has become empty
* FIFO_FULL : a profile FIFO has become full
* FIFO_NOT_EMPTY : a FIFO becomes non empty after being empty
* FIFO_NOT_FULL : a FIFO becomes non full after being full
* PROFILE_LOCKED : a profile is unable to send data
* PROFILE_UNLOCKED: a profile is able to send data after being unable
* PACKET_REQUEST_RETRY: a rejected request is due to be retried
* TICK: special clock event, triggers TPM tick
*/
const enum Type {
NONE = 0,
ACTIVATION = 1,
TERMINATION = 2,
FIFO_EMPTY = 3,
FIFO_FULL = 4,
FIFO_NOT_EMPTY = 5,
FIFO_NOT_FULL = 6,
PROFILE_LOCKED = 7,
PROFILE_UNLOCKED = 8,
PACKET_REQUEST_RETRY = 9,
TICK = 10,
N_EVENTS = 11
} type;
/*!
* Action Type
* AWAITED = event waited for
* TRIGGERED = event occurred
*/
const enum Action {
AWAITED = 0,
TRIGGERED = 1
} action;
/*!
* Event type to category map
*/
static const Category category[];
/*!
* Event type to string name map
*/
static const string text[];
/*!
* Event category to allow concurrency flag map
*/
static const bool allowConcurrency[];
/*!
* Unique ID
*/
const uint64_t id;
/*!
* Event time
*/
const uint64_t time;
public:
/*!
* Parses a string into Event Type and Profile name
*\param t returned Event Type
*\param profile returned Profile name
*\param in input string
*\return true if both type and id are successfully
* parsed, false otherwise
*/
static bool parse(Type&, string&, const string&);
/*!
* Event Constructor
*\param ty the type of the Event
*\param a the Event action
*\param eId this event ID
*\param t Event time
*/
Event(const Type, const Action, const uint64_t, const uint64_t);
//! Default destructor
virtual ~Event();
/*!
* Equality operator
*\param ev1 the first Event to be compared
*\param ev2 the second Event to be compared
*\return true if the events compare equal
*/
inline friend bool operator==(const Event& ev1, const Event& ev2) {
return (ev1.type == ev2.type && ev1.id == ev2.id);
}
/*!
* Inequality operator
*\param ev1 the first Event to be compared
*\param ev2 the second Event to be compared
*\return true if the events compare equal
*/
inline friend bool operator!=(const Event& ev1, const Event& ev2) {
return (ev1.type != ev2.type || ev1.id != ev2.id);
}
/*!
* Ostream operator
*\param os the ostream where to output the event
*\param ev the event to be output to ostream
*\return reference to the modified ostream
*/
friend ostream& operator<<(ostream& os, const Event& ev);
};
} /* namespace TrafficProfiles */
//! the C++ standard template library namespace
namespace std {
/*!\brief ATP Event Hash function
*
* Computes the hash value of an ATP event
*/
template<>
struct hash<TrafficProfiles::Event> {
size_t operator()(const TrafficProfiles::Event& object) const {
return hash<uint64_t>()((object.type + 1) * object.id);
}
};
}
#endif /* __AMBA_TRAFFIC_PROFILE_EVENT_HH__ */