1 |
2 |
acastong |
//ControlPacket.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 ControlPacket_H
|
40 |
|
|
#define ControlPacket_H
|
41 |
|
|
|
42 |
|
|
#include "../../rtl/systemc/core_synth/ht_type_include.h"
|
43 |
|
|
|
44 |
|
|
//Forward declarations
|
45 |
|
|
class PacketContainer;
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
/// Base class for all packets
|
49 |
|
|
/**
|
50 |
|
|
Allows to create a packet class from the fisrt dword of a
|
51 |
|
|
Packet. If the packet is doubleDword packet, functions that
|
52 |
|
|
access the first dword of the data can be accessed. The seconde
|
53 |
|
|
dword can be added with the <code>setSecondDword(const sc_bv< 32 > &dWord)</code>
|
54 |
|
|
function to complete the packet. If a function accessing the second
|
55 |
|
|
dword is called before that second dword is available, it should
|
56 |
|
|
make an assertion.
|
57 |
|
|
|
58 |
|
|
@author Ami Castonguay
|
59 |
|
|
*/
|
60 |
|
|
class ControlPacket{
|
61 |
|
|
|
62 |
|
|
///To output the packet on an <code>ostream</code>
|
63 |
|
|
/**
|
64 |
|
|
Called to output the packet to an output stream.
|
65 |
|
|
Displays the internal vector of the packet.
|
66 |
|
|
|
67 |
|
|
@param out The stream to output to
|
68 |
|
|
@param pkt The packet to output
|
69 |
|
|
@return The stream <code>out</code>
|
70 |
|
|
*/
|
71 |
|
|
friend ostream &operator<<(ostream &out,const ControlPacket &pkt);
|
72 |
|
|
|
73 |
|
|
protected:
|
74 |
|
|
|
75 |
|
|
///The actual data of this packet
|
76 |
|
|
sc_bv<64> bv;
|
77 |
|
|
|
78 |
|
|
public:
|
79 |
|
|
|
80 |
|
|
static bool outputExtraInformation;
|
81 |
|
|
|
82 |
|
|
///Default constructor
|
83 |
|
|
/**
|
84 |
|
|
Creates an empty packet with a vector filled with 0.
|
85 |
|
|
*/
|
86 |
|
|
ControlPacket::ControlPacket(){};
|
87 |
|
|
|
88 |
|
|
///Constructor with a 32 bit vector
|
89 |
|
|
/**
|
90 |
|
|
@param dWord The least significant 32 bits that represents packet
|
91 |
|
|
*/
|
92 |
|
|
ControlPacket(const sc_bv<32> &dWord){bv(31,0) = dWord;}
|
93 |
|
|
|
94 |
|
|
///Constructor with a 64 bit vector
|
95 |
|
|
/**
|
96 |
|
|
@param qWord The least significant 32 bits that represents packet
|
97 |
|
|
*/
|
98 |
|
|
ControlPacket(const sc_bv<64> &qWord){bv(63,0) = qWord;}
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
///Creates a packet of the appropriate derived class from 32 bits
|
102 |
|
|
/**
|
103 |
|
|
Creates a packet of the right derived type from the first 32 bits of
|
104 |
|
|
that packet. For easy memory management, the returned packet is encapsulated
|
105 |
|
|
in a <code>PacketContainer</code>. If the command is unknown, the packet returned
|
106 |
|
|
is of type ReservedPacket. If the packet is 64 bits long,
|
107 |
|
|
functions using the last 32 bits will have undefined results until those
|
108 |
|
|
last bits are added through setSecondDword.
|
109 |
|
|
|
110 |
|
|
@param dWord The 32 bits containing the least significant bits of a control packet
|
111 |
|
|
@return A packet inside a PacketContainer created from the 32 bits vector
|
112 |
|
|
*/
|
113 |
|
|
static PacketContainer createPacketFromDword(const sc_bv<32> &dWord);
|
114 |
|
|
|
115 |
|
|
///Creates a packet of the appropriate derived class from 63 bits
|
116 |
|
|
/**
|
117 |
|
|
Creates a packet of the right derived type from the 64 bits of
|
118 |
|
|
that packet. For easy memory management, the returned packet is encapsulated
|
119 |
|
|
in a <code>PacketContainer</code>. If the command is unknown, the packet returned
|
120 |
|
|
is of type ReservedPacket. If the packet is 32 bits long,
|
121 |
|
|
the last 32 bits will simply be ignored.
|
122 |
|
|
|
123 |
|
|
@param qWord The 64 bits containing the bits of the packet. If the packet type
|
124 |
|
|
is 32 bits long, the most significant 32 bits are stored in the invernal
|
125 |
|
|
vector but ignored by functions
|
126 |
|
|
@return A packet inside a PacketContainer created from the 32 bits vector
|
127 |
|
|
*/
|
128 |
|
|
static PacketContainer createPacketFromQuadWord(const sc_bv<64> &qWord);
|
129 |
|
|
|
130 |
|
|
///Complete last 32 bits of a packet
|
131 |
|
|
/**
|
132 |
|
|
To complete a doubleDword packet that was created with the function
|
133 |
|
|
<code>createPacketFromDword(const sc_bv<32> &dWord)</code>.
|
134 |
|
|
|
135 |
|
|
@param dWord The second dword of the packet
|
136 |
|
|
*/
|
137 |
|
|
void setSecondDword(const sc_bv<32> &dWord);
|
138 |
|
|
|
139 |
|
|
///If the packet type is 32 bits
|
140 |
|
|
/**
|
141 |
|
|
To know if the packet type is 32 bits.
|
142 |
|
|
|
143 |
|
|
@return True if the packet is of a type that is 32 bits (dword)
|
144 |
|
|
or false otherwise.
|
145 |
|
|
*/
|
146 |
|
|
virtual bool isDwordPacket() const = 0 ;
|
147 |
|
|
|
148 |
|
|
///To get the command of the packet
|
149 |
|
|
/**
|
150 |
|
|
To get the command of the packet
|
151 |
|
|
The <code>PacketCommand</code> represents the exact function
|
152 |
|
|
of this packet.
|
153 |
|
|
|
154 |
|
|
@return The command of the packet
|
155 |
|
|
*/
|
156 |
|
|
virtual PacketCommand getPacketCommand() const = 0;
|
157 |
|
|
|
158 |
|
|
///To get the command from the 6 bits of command
|
159 |
|
|
/**
|
160 |
|
|
From a 6 bits command vector, returns a PacketCommand type.
|
161 |
|
|
The <code>PacketCommand</code> represents the exact function
|
162 |
|
|
of this packet.
|
163 |
|
|
|
164 |
|
|
@return The command corresponding to the 6 bits command
|
165 |
|
|
*/
|
166 |
|
|
static PacketCommand getPacketCommand(const sc_bv<6> &cmd);
|
167 |
|
|
|
168 |
|
|
///Get the type of packet
|
169 |
|
|
/**
|
170 |
|
|
To get the type of the packet.
|
171 |
|
|
Packet can be categorize in different types depending on their function.
|
172 |
|
|
|
173 |
|
|
@return The type of this packet
|
174 |
|
|
*/
|
175 |
|
|
virtual PacketType getPacketType() const = 0;
|
176 |
|
|
|
177 |
|
|
///Get the type from the command
|
178 |
|
|
/**
|
179 |
|
|
To get the type of a command.
|
180 |
|
|
Packet can be categorize in different types depending on their function.
|
181 |
|
|
This returns the <code>PacketType</code> for the command.
|
182 |
|
|
|
183 |
|
|
@param cmd The command to analyze
|
184 |
|
|
@return The type associated to the command
|
185 |
|
|
*/
|
186 |
|
|
static PacketType getPacketType(const sc_bv<6> &cmd);
|
187 |
|
|
|
188 |
|
|
///Get the <code>VirtualChannel</code> of the packet
|
189 |
|
|
/**
|
190 |
|
|
To get the virtual channel of this packet
|
191 |
|
|
Packet can travel in different channels depending on their function
|
192 |
|
|
and of their attributes.
|
193 |
|
|
|
194 |
|
|
@return The VirtualChannel associated to the command
|
195 |
|
|
*/
|
196 |
|
|
virtual VirtualChannel getVirtualChannel() const = 0 ;
|
197 |
|
|
|
198 |
|
|
///Packet part of chain
|
199 |
|
|
/**
|
200 |
|
|
Some packets are part of chain that can not be interrupted.
|
201 |
|
|
|
202 |
|
|
@return If the packet is part a a chain
|
203 |
|
|
*/
|
204 |
|
|
virtual bool isChain() const = 0;
|
205 |
|
|
|
206 |
|
|
///Packet has data associated
|
207 |
|
|
/**
|
208 |
|
|
To know if there is a data packet associated with this control
|
209 |
|
|
packet
|
210 |
|
|
|
211 |
|
|
@return If the packet has data associated
|
212 |
|
|
*/
|
213 |
|
|
virtual bool hasDataAssociated() const = 0 ;
|
214 |
|
|
|
215 |
|
|
///Get the length-1 of the data associated
|
216 |
|
|
/**
|
217 |
|
|
Gets the number of doublewords of data associated with this ctl packet
|
218 |
|
|
minus 1. So a returned number of 0 represents 1 doubleWord.
|
219 |
|
|
If there is no data associated, the result is undefined.
|
220 |
|
|
The number returned also includes the doubleword mask in a byte write
|
221 |
|
|
|
222 |
|
|
@return Length-1 of data associated with the packet, or undefined
|
223 |
|
|
if the packet has no data associated
|
224 |
|
|
*/
|
225 |
|
|
virtual sc_uint<4> getDataLengthm1() const = 0 ;
|
226 |
|
|
|
227 |
|
|
///Create Address extension doubleWord
|
228 |
|
|
/**
|
229 |
|
|
@param addressExtension The extra 24 bits to add to the standard 40 bits address
|
230 |
|
|
It is illegal to have this all zeros!!!
|
231 |
|
|
@return The 23 bits to prepend to a request to send in the 64 bit format
|
232 |
|
|
*/
|
233 |
|
|
static sc_bv<32> createAddressExtensionDoubleWord(sc_bv<24> &addressExtension);
|
234 |
|
|
|
235 |
|
|
///Get the internal data vector
|
236 |
|
|
inline sc_bv<64> getVector() const {return bv;}
|
237 |
|
|
///Get the internal data vector
|
238 |
|
|
inline operator sc_bv<64>() const {return bv;}
|
239 |
|
|
///Get the least significant 32 bits of the internal data vector
|
240 |
|
|
inline operator sc_bv<32>() const {return bv.range(31,0);}
|
241 |
|
|
|
242 |
|
|
///To check if two packets have identical content
|
243 |
|
|
bool operator== (const ControlPacket &) const;
|
244 |
|
|
|
245 |
|
|
///To check if two packets have different content
|
246 |
|
|
inline bool operator!= (const ControlPacket &test) const {return !(*this == test);}
|
247 |
|
|
|
248 |
|
|
///Get a copy of this object
|
249 |
|
|
/**
|
250 |
|
|
To get a new object which is identical to this packet
|
251 |
|
|
|
252 |
|
|
@return A packet of the same derived type with the same
|
253 |
|
|
internal vector
|
254 |
|
|
*/
|
255 |
|
|
virtual ControlPacket* getCopy() const = 0;
|
256 |
|
|
|
257 |
|
|
/**
|
258 |
|
|
@return If this packet can pass posted writes (increased priority)
|
259 |
|
|
*/
|
260 |
|
|
virtual bool getPassPW() const = 0;
|
261 |
|
|
|
262 |
|
|
///Virtual destructor
|
263 |
|
|
virtual ~ControlPacket(){}
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
};
|
267 |
|
|
|
268 |
|
|
|
269 |
|
|
///To allow this class to be used as a SystemC user data type
|
270 |
|
|
extern
|
271 |
|
|
void sc_trace(sc_trace_file *tf, const ControlPacket& v,
|
272 |
|
|
const sc_string& NAME);
|
273 |
|
|
|
274 |
|
|
|
275 |
|
|
#endif
|