1 |
2 |
acastong |
//InfoPacket.h
|
2 |
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
3 |
|
|
* Version: MPL 1.1
|
4 |
|
|
*
|
5 |
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
6 |
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
7 |
|
|
* the License. You may obtain a copy of the License at
|
8 |
|
|
* http://www.mozilla.org/MPL/
|
9 |
|
|
*
|
10 |
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
11 |
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
12 |
|
|
* for the specific language governing rights and limitations under the
|
13 |
|
|
* License.
|
14 |
|
|
*
|
15 |
|
|
* The Original Code is HyperTransport Tunnel IP Core.
|
16 |
|
|
*
|
17 |
|
|
* The Initial Developer of the Original Code is
|
18 |
|
|
* Ecole Polytechnique de Montreal.
|
19 |
|
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
20 |
|
|
* the Initial Developer. All Rights Reserved.
|
21 |
|
|
*
|
22 |
|
|
* Contributor(s):
|
23 |
|
|
* Ami Castonguay <acastong@grm.polymtl.ca>
|
24 |
|
|
*
|
25 |
|
|
* Alternatively, the contents of this file may be used under the terms
|
26 |
|
|
* of the Polytechnique HyperTransport Tunnel IP Core Source Code License
|
27 |
|
|
* (the "PHTICSCL License", see the file PHTICSCL.txt), in which case the
|
28 |
|
|
* provisions of PHTICSCL License are applicable instead of those
|
29 |
|
|
* above. If you wish to allow use of your version of this file only
|
30 |
|
|
* under the terms of the PHTICSCL License and not to allow others to use
|
31 |
|
|
* your version of this file under the MPL, indicate your decision by
|
32 |
|
|
* deleting the provisions above and replace them with the notice and
|
33 |
|
|
* other provisions required by the PHTICSCL License. If you do not delete
|
34 |
|
|
* the provisions above, a recipient may use your version of this file
|
35 |
|
|
* under either the MPL or the PHTICSCL License."
|
36 |
|
|
*
|
37 |
|
|
* ***** END LICENSE BLOCK ***** */
|
38 |
|
|
|
39 |
|
|
#ifndef InfoPacket_H
|
40 |
|
|
#define InfoPacket_H
|
41 |
|
|
|
42 |
|
|
#ifndef SC_USER_DEFINED_MAX_NUMBER_OF_PROCESSES
|
43 |
|
|
#define SC_USER_DEFINED_MAX_NUMBER_OF_PROCESSES
|
44 |
|
|
#define SC_VC6_MAX_NUMBER_OF_PROCESSES 20
|
45 |
|
|
#endif
|
46 |
|
|
#include <systemc.h>
|
47 |
|
|
|
48 |
|
|
#include "ControlPacket.h"
|
49 |
|
|
#include "../../rtl/systemc/core_synth/ht_type_include.h"
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
///Base class for all info packets
|
53 |
|
|
/**
|
54 |
|
|
An information packet is packet that does not travel through the
|
55 |
|
|
chain but only caries information on a single link.
|
56 |
|
|
*/
|
57 |
|
|
class InfoPacket: public ControlPacket{
|
58 |
|
|
|
59 |
|
|
public:
|
60 |
|
|
|
61 |
|
|
///Default constructor
|
62 |
|
|
/**
|
63 |
|
|
Creates an empty packet with a vector filled with 0.
|
64 |
|
|
*/
|
65 |
|
|
InfoPacket(){}
|
66 |
|
|
|
67 |
|
|
///Constructor with a 32 bit vector
|
68 |
|
|
/**
|
69 |
|
|
@param dWord The least significant 32 bits that represents packet
|
70 |
|
|
*/
|
71 |
|
|
InfoPacket(const sc_bv<32> &dWord) : ControlPacket(dWord){}
|
72 |
|
|
|
73 |
|
|
///Constructor with a 64 bit vector
|
74 |
|
|
/**
|
75 |
|
|
@param qWord The 64 bits that represents packet
|
76 |
|
|
*/
|
77 |
|
|
InfoPacket(const sc_bv<64> &qWord) : ControlPacket(qWord){}
|
78 |
|
|
|
79 |
|
|
///If the packet type is 32 bits
|
80 |
|
|
/**
|
81 |
|
|
@return true If the packet type is 32 bits.
|
82 |
|
|
*/
|
83 |
|
|
virtual bool isDwordPacket() const = 0;
|
84 |
|
|
|
85 |
|
|
///If packet has data associated
|
86 |
|
|
/**
|
87 |
|
|
To know if there is a data packet associated with this control
|
88 |
|
|
packet. No info packet has any data associated.
|
89 |
|
|
|
90 |
|
|
@return false
|
91 |
|
|
*/
|
92 |
|
|
virtual bool hasDataAssociated() const {return false;};
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
///Get the <code>VirtualChannel</code> of the packet
|
96 |
|
|
/**
|
97 |
|
|
To get the virtual channel of this packet
|
98 |
|
|
Packet can travel in different channels depending on their function
|
99 |
|
|
and of their attributes. Since information packets do not travel on
|
100 |
|
|
the chain, they are not part of a virtual channel hence why VC_NONE
|
101 |
|
|
is returned.
|
102 |
|
|
|
103 |
|
|
@return The VirtualChannel VC_NONE
|
104 |
|
|
*/
|
105 |
|
|
virtual VirtualChannel getVirtualChannel() const {return VC_NONE;}
|
106 |
|
|
|
107 |
|
|
///Get the type of this packet
|
108 |
|
|
/**
|
109 |
|
|
InfoPacket objects are always of type INFO
|
110 |
|
|
|
111 |
|
|
@return The INFO PacketType
|
112 |
|
|
*/
|
113 |
|
|
virtual PacketType getPacketType() const {return INFO;}
|
114 |
|
|
|
115 |
|
|
virtual PacketCommand getPacketCommand() const = 0;
|
116 |
|
|
|
117 |
|
|
///If packet part of chain
|
118 |
|
|
/**
|
119 |
|
|
InfoPacket packets are never part of a chain
|
120 |
|
|
|
121 |
|
|
@return false
|
122 |
|
|
*/
|
123 |
|
|
virtual bool isChain() const { return false;}
|
124 |
|
|
|
125 |
|
|
///If packet is a NopPacket
|
126 |
|
|
/**
|
127 |
|
|
@return true if this is a nop packet, false otherwise
|
128 |
|
|
*/
|
129 |
|
|
virtual bool isNopPacket() const = 0;
|
130 |
|
|
|
131 |
|
|
///If packet is a SyncPacket
|
132 |
|
|
/**
|
133 |
|
|
@return true if this is a sync packet, false otherwise
|
134 |
|
|
*/
|
135 |
|
|
virtual bool isSyncPacket() const = 0;
|
136 |
|
|
|
137 |
|
|
///Get the length-1 of the data associated
|
138 |
|
|
/**
|
139 |
|
|
Info packets don't have data associated.
|
140 |
|
|
|
141 |
|
|
@return A 0 length.
|
142 |
|
|
*/
|
143 |
|
|
sc_uint<4> getDataLengthm1() const {return 0; }
|
144 |
|
|
|
145 |
|
|
virtual ControlPacket* getCopy() const = 0;
|
146 |
|
|
|
147 |
|
|
virtual bool getPassPW() const{return false;}
|
148 |
|
|
|
149 |
|
|
};
|
150 |
|
|
|
151 |
|
|
///Nop info packet
|
152 |
|
|
/**
|
153 |
|
|
A NopPacket has two function : as it names says, it is used when there
|
154 |
|
|
is no data to send on the chain since a packet has to be sent at every
|
155 |
|
|
bit time. Secondly, it also carries the count of the buffers that
|
156 |
|
|
become available to establish a flow control. It is a way of making sure
|
157 |
|
|
that buffers never overflow.
|
158 |
|
|
*/
|
159 |
|
|
class NopPacket: public InfoPacket{
|
160 |
|
|
|
161 |
|
|
public:
|
162 |
|
|
|
163 |
|
|
/**
|
164 |
|
|
Constructor for a nop packet
|
165 |
|
|
|
166 |
|
|
@param freeBufResponseCmd The number of command buffers in the response VC that were freed
|
167 |
|
|
@param freeBufResponseData The number of data buffers in the response VC that were freed
|
168 |
|
|
@param freeBufPostedCmd The number of command buffers in the posted VC that were freed
|
169 |
|
|
@param freeBufPostedData The number of data buffers in the posted VC that were freed
|
170 |
|
|
@param freeBufNonPostedCmd The number of command buffers in the non-posted VC that were freed
|
171 |
|
|
@param freeBufNonPostedData The number of data buffers in the non-posted VC that were freed
|
172 |
|
|
@param disCon To disconnect the link
|
173 |
|
|
@param diag Indicates the befinning of a CRC testing phase
|
174 |
|
|
@param isoc If the freed buffers are in isochronous virtual channels
|
175 |
|
|
@param rxNextPacketToAck
|
176 |
|
|
*/
|
177 |
|
|
NopPacket(const sc_uint<2> freeBufResponseCmd = 0,
|
178 |
|
|
const sc_uint<2> freeBufResponseData = 0,
|
179 |
|
|
const sc_uint<2> freeBufPostedCmd = 0,
|
180 |
|
|
const sc_uint<2> freeBufPostedData = 0,
|
181 |
|
|
const sc_uint<2> freeBufNonPostedCmd = 0,
|
182 |
|
|
const sc_uint<2> freeBufNonPostedData = 0,
|
183 |
|
|
const bool disCon = false, bool diag = false,
|
184 |
|
|
const bool isoc = false,
|
185 |
|
|
const sc_bv<8> rxNextPacketToAck = "00000000"){
|
186 |
|
|
|
187 |
|
|
bv[6] = disCon;
|
188 |
|
|
bv.range(9,8) = freeBufPostedCmd;
|
189 |
|
|
bv.range(11,10) = freeBufPostedData;
|
190 |
|
|
bv.range(13,12) = freeBufResponseCmd;
|
191 |
|
|
bv.range(15,14) = freeBufResponseData;
|
192 |
|
|
bv.range(17,16) = freeBufNonPostedCmd;
|
193 |
|
|
bv.range(19,18) = freeBufNonPostedData;
|
194 |
|
|
bv[21] = isoc;
|
195 |
|
|
bv[22] = diag;
|
196 |
|
|
bv.range(31,24) = rxNextPacketToAck;
|
197 |
|
|
}
|
198 |
|
|
|
199 |
|
|
///Constructor with a 32 bit vector
|
200 |
|
|
/**
|
201 |
|
|
@param dWord The least significant 32 bits that represents packet
|
202 |
|
|
*/
|
203 |
|
|
NopPacket(const sc_bv<32> &dWord) : InfoPacket(dWord){}
|
204 |
|
|
|
205 |
|
|
///Constructor with a 64 bit vector
|
206 |
|
|
/**
|
207 |
|
|
@param qWord The 64 bits that represents packet
|
208 |
|
|
*/
|
209 |
|
|
NopPacket(const sc_bv<64> &qWord) : InfoPacket(qWord){}
|
210 |
|
|
|
211 |
|
|
///If packet is a NopPacket
|
212 |
|
|
/**
|
213 |
|
|
@return true
|
214 |
|
|
*/
|
215 |
|
|
bool isNopPacket() const {return true;}
|
216 |
|
|
|
217 |
|
|
///If packet is a SyncPacket
|
218 |
|
|
/**
|
219 |
|
|
@return false
|
220 |
|
|
*/
|
221 |
|
|
bool isSyncPacket() const {return false;}
|
222 |
|
|
|
223 |
|
|
///To get the command of the packet
|
224 |
|
|
/**
|
225 |
|
|
@return NOP
|
226 |
|
|
*/
|
227 |
|
|
virtual PacketCommand getPacketCommand() const{return NOP;}
|
228 |
|
|
|
229 |
|
|
ControlPacket* getCopy() const{
|
230 |
|
|
return new NopPacket(bv);
|
231 |
|
|
}
|
232 |
|
|
|
233 |
|
|
/**
|
234 |
|
|
@return The number of command buffers in the posted VC that were freed
|
235 |
|
|
*/
|
236 |
|
|
sc_uint<2> getFreeBufPostedCmd() const{
|
237 |
|
|
return (sc_bv<2>)bv.range(9,8);
|
238 |
|
|
}
|
239 |
|
|
|
240 |
|
|
/**
|
241 |
|
|
@return The number of data buffers in the posted VC that were freed
|
242 |
|
|
*/
|
243 |
|
|
sc_uint<2> getFreeBufPostedData() const{
|
244 |
|
|
return (sc_bv<2>)bv.range(11,10);
|
245 |
|
|
}
|
246 |
|
|
|
247 |
|
|
/**
|
248 |
|
|
@return The number of command buffers in the response VC that were freed
|
249 |
|
|
*/
|
250 |
|
|
sc_uint<2> freeBufResponseCmd() const{
|
251 |
|
|
return (sc_bv<2>)bv.range(13,12);
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
/**
|
255 |
|
|
@return The number of data buffers in the response VC that were freed
|
256 |
|
|
*/
|
257 |
|
|
sc_uint<2> freeBufResponseData() const{
|
258 |
|
|
return (sc_bv<2>)bv.range(15,14);
|
259 |
|
|
}
|
260 |
|
|
|
261 |
|
|
/**
|
262 |
|
|
@return The number of command buffers in the non-posted VC that were freed
|
263 |
|
|
*/
|
264 |
|
|
sc_uint<2> freeBufNonPostedCmd() const{
|
265 |
|
|
return (sc_bv<2>)bv.range(17,16);
|
266 |
|
|
}
|
267 |
|
|
|
268 |
|
|
/**
|
269 |
|
|
@return The number of data buffers in the non-posted VC that were freed
|
270 |
|
|
*/
|
271 |
|
|
sc_uint<2> freeBufNonPostedData() const{
|
272 |
|
|
return (sc_bv<2>)bv.range(19,18);
|
273 |
|
|
}
|
274 |
|
|
|
275 |
|
|
/**
|
276 |
|
|
@return The ack number of the NOP
|
277 |
|
|
*/
|
278 |
|
|
sc_uint<8> getRxNextPacketToAck(){
|
279 |
|
|
return (sc_bv<8>)bv.range(31,24);
|
280 |
|
|
}
|
281 |
|
|
|
282 |
|
|
///If the packet type is 32 bits
|
283 |
|
|
/**
|
284 |
|
|
@return If the packet type is 32 bits. (always true)
|
285 |
|
|
*/
|
286 |
|
|
virtual bool isDwordPacket() const { return true;}
|
287 |
|
|
};
|
288 |
|
|
|
289 |
|
|
///Sync info packet
|
290 |
|
|
/**
|
291 |
|
|
A SyncPacket is sent on a link to reinitialize the chain
|
292 |
|
|
completely.
|
293 |
|
|
*/
|
294 |
|
|
class SyncPacket: public InfoPacket{
|
295 |
|
|
|
296 |
|
|
public:
|
297 |
|
|
|
298 |
|
|
///Default constructor
|
299 |
|
|
/**
|
300 |
|
|
Constructs a packet with the lowest 32 bits filled with ones
|
301 |
|
|
*/
|
302 |
|
|
SyncPacket(){
|
303 |
|
|
bv = "11111111111111111111111111111111";
|
304 |
|
|
}
|
305 |
|
|
|
306 |
|
|
///Constructor with a 32 bit vector
|
307 |
|
|
/**
|
308 |
|
|
@param dWord The least significant 32 bits that represents packet
|
309 |
|
|
*/
|
310 |
|
|
SyncPacket(const sc_bv<32> &dWord) : InfoPacket(dWord){}
|
311 |
|
|
|
312 |
|
|
///Constructor with a 64 bit vector
|
313 |
|
|
/**
|
314 |
|
|
@param qWord The 64 bits that represents packet
|
315 |
|
|
*/
|
316 |
|
|
SyncPacket(const sc_bv<64> &qWord) : InfoPacket(qWord){}
|
317 |
|
|
|
318 |
|
|
ControlPacket* getCopy() const{
|
319 |
|
|
return new SyncPacket(bv);
|
320 |
|
|
}
|
321 |
|
|
|
322 |
|
|
///To get the command of the packet
|
323 |
|
|
/**
|
324 |
|
|
@return SYNC
|
325 |
|
|
*/
|
326 |
|
|
virtual PacketCommand getPacketCommand() const{return SYNC;}
|
327 |
|
|
|
328 |
|
|
///If packet is a NopPacket
|
329 |
|
|
/**
|
330 |
|
|
@return false
|
331 |
|
|
*/
|
332 |
|
|
bool isNopPacket() const {return false;}
|
333 |
|
|
|
334 |
|
|
///If packet is a SyncPacket
|
335 |
|
|
/**
|
336 |
|
|
@return true
|
337 |
|
|
*/
|
338 |
|
|
bool isSyncPacket() const {return true;}
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
///If the packet type is 32 bits
|
342 |
|
|
/**
|
343 |
|
|
@return true If the packet type is 32 bits. (always true)
|
344 |
|
|
*/
|
345 |
|
|
virtual bool isDwordPacket() const { return true;}
|
346 |
|
|
|
347 |
|
|
};
|
348 |
|
|
|
349 |
|
|
///Extended flow control packet
|
350 |
|
|
/**
|
351 |
|
|
A flow control packet used to manage buffers for VCSets 0-7.
|
352 |
|
|
We do not support VCSets 0-7, but we support the extended flow
|
353 |
|
|
control packet
|
354 |
|
|
*/
|
355 |
|
|
class ExtendedFlowControlPacket: public InfoPacket{
|
356 |
|
|
|
357 |
|
|
public:
|
358 |
|
|
|
359 |
|
|
/**
|
360 |
|
|
Constructor for ExtendedFlowControlPacket
|
361 |
|
|
|
362 |
|
|
@param vcSet defines which vcSet this this packet is ontrolling the buffers of
|
363 |
|
|
@param vcSetFree0 Freed buffer data
|
364 |
|
|
@param rxNextPacketToAck used by the retry protocol
|
365 |
|
|
@param vcSetRsv optional for proprietery use between devices
|
366 |
|
|
*/
|
367 |
|
|
ExtendedFlowControlPacket(const sc_bv<3> &vcSet,
|
368 |
|
|
const sc_bv<8> &vcSetFree0,
|
369 |
|
|
const sc_bv<8> rxNextPacketToAck = "00000000",
|
370 |
|
|
const sc_bv<4> vcSetRsv = "0000"){
|
371 |
|
|
|
372 |
|
|
sc_bv<6> command = "110111";
|
373 |
|
|
bv.range(5,0) = command;
|
374 |
|
|
bv[6] = false;
|
375 |
|
|
bv(10,8) = vcSet;
|
376 |
|
|
bv.range(15,12) = vcSetRsv;
|
377 |
|
|
bv.range(23,16) = vcSetFree0;
|
378 |
|
|
bv.range(31,24) = rxNextPacketToAck;
|
379 |
|
|
|
380 |
|
|
}
|
381 |
|
|
|
382 |
|
|
/**
|
383 |
|
|
Constructor for ExtendedFlowControlPacket
|
384 |
|
|
|
385 |
|
|
@param vcSet defines which vcSet this this packet is ontrolling the buffers of
|
386 |
|
|
@param vcSetFree0 Freed buffer data
|
387 |
|
|
@param vcSetFree1 Freed buffer data
|
388 |
|
|
@param vcSetFree2 Freed buffer data
|
389 |
|
|
@param vcSetFree3 Freed buffer data
|
390 |
|
|
@param rxNextPacketToAck used by the retry protocol
|
391 |
|
|
@param vcSetRsv optional for proprietery use between devices
|
392 |
|
|
*/
|
393 |
|
|
ExtendedFlowControlPacket(const sc_bv<3> &vcSet,
|
394 |
|
|
const sc_bv<8> &vcSetFree0,
|
395 |
|
|
const sc_bv<8> &vcSetFree1,
|
396 |
|
|
const sc_bv<8> &vcSetFree2,
|
397 |
|
|
const sc_bv<8> &vcSetFree3,
|
398 |
|
|
const sc_bv<8> rxNextPacketToAck = "00000000",
|
399 |
|
|
const sc_bv<4> vcSetRsv = "0000"){
|
400 |
|
|
|
401 |
|
|
sc_bv<6> command = "110111";
|
402 |
|
|
bv.range(5,0) = command;
|
403 |
|
|
bv[6] = true;
|
404 |
|
|
bv(10,8) = vcSet;
|
405 |
|
|
bv.range(15,12) = vcSetRsv;
|
406 |
|
|
bv.range(23,16) = vcSetFree0;
|
407 |
|
|
bv.range(31,24) = vcSetFree1;
|
408 |
|
|
bv.range(39,32) = vcSetFree2;
|
409 |
|
|
bv.range(47,40) = vcSetFree3;
|
410 |
|
|
bv.range(63,56) = rxNextPacketToAck;
|
411 |
|
|
|
412 |
|
|
}
|
413 |
|
|
|
414 |
|
|
///Constructor with a 32 bit vector
|
415 |
|
|
/**
|
416 |
|
|
@param dWord The least significant 32 bits that represents packet
|
417 |
|
|
*/
|
418 |
|
|
ExtendedFlowControlPacket(const sc_bv<32> &dWord) : InfoPacket(dWord){}
|
419 |
|
|
|
420 |
|
|
///Constructor with a 64 bit vector
|
421 |
|
|
/**
|
422 |
|
|
@param qWord The 64 bits that represents packet
|
423 |
|
|
*/
|
424 |
|
|
ExtendedFlowControlPacket(const sc_bv<64> &qWord) : InfoPacket(qWord){}
|
425 |
|
|
|
426 |
|
|
ControlPacket* getCopy() const{
|
427 |
|
|
return new ExtendedFlowControlPacket(bv);
|
428 |
|
|
}
|
429 |
|
|
|
430 |
|
|
///To get the command of the packet
|
431 |
|
|
/**
|
432 |
|
|
@return EXTENDED_FLOW
|
433 |
|
|
*/
|
434 |
|
|
virtual PacketCommand getPacketCommand() const{return EXTENDED_FLOW;}
|
435 |
|
|
|
436 |
|
|
///If packet is a NopPacket
|
437 |
|
|
/**
|
438 |
|
|
@return false
|
439 |
|
|
*/
|
440 |
|
|
bool isNopPacket() const {return false;}
|
441 |
|
|
|
442 |
|
|
///If packet is a SyncPacket
|
443 |
|
|
/**
|
444 |
|
|
@return false
|
445 |
|
|
*/
|
446 |
|
|
bool isSyncPacket() const {return true;}
|
447 |
|
|
|
448 |
|
|
|
449 |
|
|
///If the packet type is 32 bits
|
450 |
|
|
/**
|
451 |
|
|
@return If the packet type is 32 bits.
|
452 |
|
|
*/
|
453 |
|
|
virtual bool isDwordPacket() const { return !((bool)((sc_bit)bv[6]));}
|
454 |
|
|
|
455 |
|
|
};
|
456 |
|
|
|
457 |
|
|
#endif
|