-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSoCINDefines.h
318 lines (241 loc) · 9.73 KB
/
SoCINDefines.h
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/*
--------------------------------------------------------------------------------
PROJECT: SoCIN_Simulator
MODULE : No modules - only data structures
FILE : SoCINDefines.h
--------------------------------------------------------------------------------
DESCRIPTION: Data structures of transmission
Data type
--------------------------------------------------------------------------------
AUTHORS: Laboratory of Embedded and Distributed Systems (LEDS - UNIVALI)
CONTACT: Prof. Cesar Zeferino ([email protected])
-------------------------------- Reviews ---------------------------------------
| Date - Version - Author | Description
--------------------------------------------------------------------------------
| 04/09/2016 - 1.0 - Eduardo Alves da Silva | Initial implementation
--------------------------------------------------------------------------------
*/
#ifndef __SOCINDEFINES_H__
#define __SOCINDEFINES_H__
#include <systemc>
#include "Parameters/Parameters.h"
using namespace sc_core;
using namespace sc_dt;
/////////////////////////////////////////////////////////////////////////
/// Parameterizable data representation (unsigned)
/////////////////////////////////////////////////////////////////////////
class UIntVar : public sc_unsigned {
public:
////////// Constructors //////////
UIntVar() : sc_unsigned(FLIT_WIDTH) {} // Default
UIntVar(int v, int width)
: sc_unsigned( width )
{ *this = v; }
// Follow SystemC specs
UIntVar( const UIntVar& v )
: sc_unsigned( FLIT_WIDTH )
{ *this = v; }
UIntVar( const sc_unsigned& v )
: sc_unsigned( FLIT_WIDTH )
{ *this = v; }
UIntVar( const sc_signed& v )
: sc_unsigned( FLIT_WIDTH )
{ *this = v; }
UIntVar( const char* v )
: sc_unsigned( FLIT_WIDTH )
{ *this = v; }
UIntVar( int64 v )
: sc_unsigned( FLIT_WIDTH )
{ *this = v; }
UIntVar( uint64 v )
: sc_unsigned( FLIT_WIDTH )
{ *this = v; }
UIntVar( long v )
: sc_unsigned( FLIT_WIDTH )
{ *this = v; }
UIntVar( unsigned long v )
: sc_unsigned( FLIT_WIDTH )
{ *this = v; }
UIntVar( int v )
: sc_unsigned( FLIT_WIDTH )
{ *this = v; }
UIntVar( unsigned int v )
: sc_unsigned( FLIT_WIDTH )
{ *this = v; }
UIntVar( double v )
: sc_unsigned( FLIT_WIDTH )
{ *this = v; }
UIntVar( const sc_bv_base& v )
: sc_unsigned( FLIT_WIDTH )
{ *this = v; }
UIntVar( const sc_lv_base& v )
: sc_unsigned( FLIT_WIDTH )
{ *this = v; }
////////// Assignment operators //////////
UIntVar& operator = ( const UIntVar& v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( const sc_unsigned& v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( const sc_signed& v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( const char* v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( int64 v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( uint64 v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( long v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( unsigned long v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( int v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( unsigned int v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( double v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( const sc_bv_base& v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( const sc_lv_base& v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( const sc_int_base& v )
{ sc_unsigned::operator = ( v ); return *this; }
UIntVar& operator = ( const sc_uint_base& v )
{ sc_unsigned::operator = ( v ); return *this; }
~UIntVar() {}
};
/////////////////////////////////////////////////////////////////////////
/// Parameterizable data representation (signed)
/////////////////////////////////////////////////////////////////////////
class IntVar : public sc_signed {
public:
////////// Constructors //////////
IntVar() : sc_signed(FLIT_WIDTH) {} // Default
IntVar(int v, int width)
: sc_signed( width )
{ *this = v; }
// Follow SystemC specs
IntVar( const IntVar& v )
: sc_signed( FLIT_WIDTH )
{ *this = v; }
IntVar( const sc_unsigned& v )
: sc_signed( FLIT_WIDTH )
{ *this = v; }
IntVar( const sc_signed& v )
: sc_signed( FLIT_WIDTH )
{ *this = v; }
IntVar( const char* v )
: sc_signed( FLIT_WIDTH )
{ *this = v; }
IntVar( int64 v )
: sc_signed( FLIT_WIDTH )
{ *this = v; }
IntVar( uint64 v )
: sc_signed( FLIT_WIDTH )
{ *this = v; }
IntVar( long v )
: sc_signed( FLIT_WIDTH )
{ *this = v; }
IntVar( unsigned long v )
: sc_signed( FLIT_WIDTH )
{ *this = v; }
IntVar( int v )
: sc_signed( FLIT_WIDTH )
{ *this = v; }
IntVar( unsigned int v )
: sc_signed( FLIT_WIDTH )
{ *this = v; }
IntVar( double v )
: sc_signed( FLIT_WIDTH )
{ *this = v; }
IntVar( const sc_bv_base& v )
: sc_signed( FLIT_WIDTH )
{ *this = v; }
IntVar( const sc_lv_base& v )
: sc_signed( FLIT_WIDTH )
{ *this = v; }
////////// Assignment operators //////////
IntVar& operator = ( const IntVar& v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( const sc_unsigned& v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( const sc_signed& v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( const char* v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( int64 v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( uint64 v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( long v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( unsigned long v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( int v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( unsigned int v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( double v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( const sc_bv_base& v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( const sc_lv_base& v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( const sc_int_base& v )
{ sc_signed::operator = ( v ); return *this; }
IntVar& operator = ( const sc_uint_base& v )
{ sc_signed::operator = ( v ); return *this; }
~IntVar() {}
};
/////////////////////////////////////////////////////////////////////////
/// END of Parameterizable data representation
/////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
/// Packet structure
/////////////////////////////////////////////////////////////////////////
struct Packet {
unsigned long int packetId; // Packet identifier in the network - exclusive by packet
unsigned short payloadLength; // Number of payload flits
float requiredBW; // Required bandwidth for the packet
unsigned long int deadline; // Defined deadline for the packet
unsigned long int packetCreationCycle; // Packet cycle generation
unsigned short hops; // Number of hops of this packet in the network
};
/////////////////////////////////////////////////////////////////////////
/// END of Packet structure
/////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
/// Data type used in the communication channels
/////////////////////////////////////////////////////////////////////////
class Flit {
public:
UIntVar data; // Real data
Packet* packet_ptr; // Pointer to packet of this flit
// Constructors
Flit() : data(0), packet_ptr(NULL) {} // Default
Flit(UIntVar value, Packet* packet) : data(value), packet_ptr(packet) {} // Auxiliar
Flit(const Flit& f) { this->data = f.data; this->packet_ptr = f.packet_ptr;} // Copy
Flit(Flit& f) { this->data = f.data; this->packet_ptr = f.packet_ptr;} // Copy
Flit(int data) { this->data = data; this->packet_ptr = NULL;}
Flit& operator= (const Flit& flit)
{ this->data = flit.data; this->packet_ptr = flit.packet_ptr; return *this;}
Flit& operator = (int data)
{ this->data = data; this->packet_ptr = NULL; return *this;}
bool operator== (const Flit& flit) const
{ return ( this->data == flit.data && this->packet_ptr == flit.packet_ptr ); }
virtual ~Flit() {}
friend std::ostream& operator<<(std::ostream& os, const Flit& flit)
{
os << "{" << "Data:" << flit.data.to_string(SC_HEX_US) << ","
<< "Packet_ID:" << flit.packet_ptr << "}";
return os;
}
friend void sc_trace(::sc_core::sc_trace_file* tf, const Flit& flit, const std::string& nm)
{ sc_trace( tf, flit.data, nm ); }
};
/////////////////////////////////////////////////////////////////////////
/// END of Data type used in the communication channels
/////////////////////////////////////////////////////////////////////////
#endif // __SOCINDEFINES_H__