packet.hh (2812:8e5feae75615) | packet.hh (2813:89d9196456ac) |
---|---|
1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 38 unchanged lines hidden (view full) --- 47typedef Packet* PacketPtr; 48typedef uint8_t* PacketDataPtr; 49typedef std::list<PacketPtr> PacketList; 50 51//Coherence Flags 52#define NACKED_LINE 1 << 0 53#define SATISFIED 1 << 1 54#define SHARED_LINE 1 << 2 | 1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 38 unchanged lines hidden (view full) --- 47typedef Packet* PacketPtr; 48typedef uint8_t* PacketDataPtr; 49typedef std::list<PacketPtr> PacketList; 50 51//Coherence Flags 52#define NACKED_LINE 1 << 0 53#define SATISFIED 1 << 1 54#define SHARED_LINE 1 << 2 |
55#define CACHE_LINE_FILL 1 << 3 56#define COMPRESSED 1 << 4 57#define NO_ALLOCATE 1 << 5 |
|
55 56//For statistics we need max number of commands, hard code it at 57//20 for now. @todo fix later 58#define NUM_MEM_CMDS 1 << 9 59 60/** 61 * A Packet is used to encapsulate a transfer between two objects in 62 * the memory system (e.g., the L1 and L2 cache). (In contrast, a 63 * single Request travels all the way from the requester to the 64 * ultimate destination and back, possibly being conveyed by several 65 * different Packets along the way.) 66 */ 67class Packet 68{ | 58 59//For statistics we need max number of commands, hard code it at 60//20 for now. @todo fix later 61#define NUM_MEM_CMDS 1 << 9 62 63/** 64 * A Packet is used to encapsulate a transfer between two objects in 65 * the memory system (e.g., the L1 and L2 cache). (In contrast, a 66 * single Request travels all the way from the requester to the 67 * ultimate destination and back, possibly being conveyed by several 68 * different Packets along the way.) 69 */ 70class Packet 71{ |
72 public: 73 /** Temporary FLAGS field until cache gets working, this should be in coherence/sender state. */ 74 uint64_t flags; 75 |
|
69 private: 70 /** A pointer to the data being transfered. It can be differnt 71 * sizes at each level of the heirarchy so it belongs in the 72 * packet, not request. This may or may not be populated when a 73 * responder recieves the packet. If not populated it memory 74 * should be allocated. 75 */ 76 PacketDataPtr data; --- 11 unchanged lines hidden (view full) --- 88 89 /** The address of the request. This address could be virtual or 90 * physical, depending on the system configuration. */ 91 Addr addr; 92 93 /** The size of the request or transfer. */ 94 int size; 95 | 76 private: 77 /** A pointer to the data being transfered. It can be differnt 78 * sizes at each level of the heirarchy so it belongs in the 79 * packet, not request. This may or may not be populated when a 80 * responder recieves the packet. If not populated it memory 81 * should be allocated. 82 */ 83 PacketDataPtr data; --- 11 unchanged lines hidden (view full) --- 95 96 /** The address of the request. This address could be virtual or 97 * physical, depending on the system configuration. */ 98 Addr addr; 99 100 /** The size of the request or transfer. */ 101 int size; 102 |
103 /** The offset within the block that represents the data. */ 104 int offset; 105 |
|
96 /** Device address (e.g., bus ID) of the source of the 97 * transaction. The source is not responsible for setting this 98 * field; it is set implicitly by the interconnect when the 99 * packet * is first sent. */ 100 short src; 101 102 /** Device address (e.g., bus ID) of the destination of the 103 * transaction. The special value Broadcast indicates that the 104 * packet should be routed based on its address. This field is 105 * initialized in the constructor and is thus always valid 106 * (unlike * addr, size, and src). */ 107 short dest; 108 109 /** Are the 'addr' and 'size' fields valid? */ 110 bool addrSizeValid; 111 /** Is the 'src' field valid? */ 112 bool srcValid; | 106 /** Device address (e.g., bus ID) of the source of the 107 * transaction. The source is not responsible for setting this 108 * field; it is set implicitly by the interconnect when the 109 * packet * is first sent. */ 110 short src; 111 112 /** Device address (e.g., bus ID) of the destination of the 113 * transaction. The special value Broadcast indicates that the 114 * packet should be routed based on its address. This field is 115 * initialized in the constructor and is thus always valid 116 * (unlike * addr, size, and src). */ 117 short dest; 118 119 /** Are the 'addr' and 'size' fields valid? */ 120 bool addrSizeValid; 121 /** Is the 'src' field valid? */ 122 bool srcValid; |
123 /** Is the offset valid. */ 124 bool offsetValid; |
|
113 | 125 |
126 |
|
114 public: 115 116 /** Used to calculate latencies for each packet.*/ 117 Tick time; 118 119 /** The special destination address indicating that the packet 120 * should be routed based on its address. */ 121 static const short Broadcast = -1; --- 44 unchanged lines hidden (view full) --- 166 IsSWPrefetch = 1 << 7, 167 IsHWPrefetch = 1 << 8 168 }; 169 170 public: 171 /** List of all commands associated with a packet. */ 172 enum Command 173 { | 127 public: 128 129 /** Used to calculate latencies for each packet.*/ 130 Tick time; 131 132 /** The special destination address indicating that the packet 133 * should be routed based on its address. */ 134 static const short Broadcast = -1; --- 44 unchanged lines hidden (view full) --- 179 IsSWPrefetch = 1 << 7, 180 IsHWPrefetch = 1 << 8 181 }; 182 183 public: 184 /** List of all commands associated with a packet. */ 185 enum Command 186 { |
187 InvalidCmd = 0, |
|
174 ReadReq = IsRead | IsRequest | NeedsResponse, 175 WriteReq = IsWrite | IsRequest | NeedsResponse, 176 WriteReqNoAck = IsWrite | IsRequest, 177 ReadResp = IsRead | IsResponse, 178 WriteResp = IsWrite | IsResponse, 179 Writeback = IsWrite | IsRequest, 180 SoftPFReq = IsRead | IsRequest | IsSWPrefetch | NeedsResponse, 181 HardPFReq = IsRead | IsRequest | IsHWPrefetch | NeedsResponse, 182 SoftPFResp = IsRead | IsRequest | IsSWPrefetch | IsResponse, 183 HardPFResp = IsRead | IsRequest | IsHWPrefetch | IsResponse, 184 InvalidateReq = IsInvalidate | IsRequest, 185 WriteInvalidateReq = IsWrite | IsInvalidate | IsRequest, | 188 ReadReq = IsRead | IsRequest | NeedsResponse, 189 WriteReq = IsWrite | IsRequest | NeedsResponse, 190 WriteReqNoAck = IsWrite | IsRequest, 191 ReadResp = IsRead | IsResponse, 192 WriteResp = IsWrite | IsResponse, 193 Writeback = IsWrite | IsRequest, 194 SoftPFReq = IsRead | IsRequest | IsSWPrefetch | NeedsResponse, 195 HardPFReq = IsRead | IsRequest | IsHWPrefetch | NeedsResponse, 196 SoftPFResp = IsRead | IsRequest | IsSWPrefetch | IsResponse, 197 HardPFResp = IsRead | IsRequest | IsHWPrefetch | IsResponse, 198 InvalidateReq = IsInvalidate | IsRequest, 199 WriteInvalidateReq = IsWrite | IsInvalidate | IsRequest, |
186 UpgradeReq = IsInvalidate | NeedsResponse | 200 UpgradeReq = IsInvalidate | NeedsResponse, 201 UpgradeResp = IsInvalidate | IsResponse, 202 ReadExReq = IsRead | IsInvalidate | NeedsResponse, 203 ReadExResp = IsRead | IsInvalidate | IsResponse |
187 }; 188 189 /** Return the string name of the cmd field (for debugging and 190 * tracing). */ 191 const std::string &cmdString() const; 192 193 /** Reutrn the string to a cmd given by idx. */ 194 const std::string &cmdIdxToString(Command idx); --- 6 unchanged lines hidden (view full) --- 201 202 bool isRead() { return (cmd & IsRead) != 0; } 203 bool isWrite() { return (cmd & IsWrite) != 0; } 204 bool isRequest() { return (cmd & IsRequest) != 0; } 205 bool isResponse() { return (cmd & IsResponse) != 0; } 206 bool needsResponse() { return (cmd & NeedsResponse) != 0; } 207 bool isInvalidate() { return (cmd * IsInvalidate) != 0; } 208 | 204 }; 205 206 /** Return the string name of the cmd field (for debugging and 207 * tracing). */ 208 const std::string &cmdString() const; 209 210 /** Reutrn the string to a cmd given by idx. */ 211 const std::string &cmdIdxToString(Command idx); --- 6 unchanged lines hidden (view full) --- 218 219 bool isRead() { return (cmd & IsRead) != 0; } 220 bool isWrite() { return (cmd & IsWrite) != 0; } 221 bool isRequest() { return (cmd & IsRequest) != 0; } 222 bool isResponse() { return (cmd & IsResponse) != 0; } 223 bool needsResponse() { return (cmd & NeedsResponse) != 0; } 224 bool isInvalidate() { return (cmd * IsInvalidate) != 0; } 225 |
209 bool isCacheFill() { assert("Unimplemented yet\n" && 0); } 210 bool isNoAllocate() { assert("Unimplemented yet\n" && 0); } | 226 bool isCacheFill() { return (flags & CACHE_LINE_FILL) != 0; } 227 bool isNoAllocate() { return (flags & NO_ALLOCATE) != 0; } |
211 212 /** Possible results of a packet's request. */ 213 enum Result 214 { 215 Success, 216 BadAddress, 217 Nacked, 218 Unknown --- 8 unchanged lines hidden (view full) --- 227 228 /** Accessor function that returns the destination index of 229 the packet. */ 230 short getDest() const { return dest; } 231 void setDest(short _dest) { dest = _dest; } 232 233 Addr getAddr() const { assert(addrSizeValid); return addr; } 234 int getSize() const { assert(addrSizeValid); return size; } | 228 229 /** Possible results of a packet's request. */ 230 enum Result 231 { 232 Success, 233 BadAddress, 234 Nacked, 235 Unknown --- 8 unchanged lines hidden (view full) --- 244 245 /** Accessor function that returns the destination index of 246 the packet. */ 247 short getDest() const { return dest; } 248 void setDest(short _dest) { dest = _dest; } 249 250 Addr getAddr() const { assert(addrSizeValid); return addr; } 251 int getSize() const { assert(addrSizeValid); return size; } |
252 int getOffset() const { assert(offsetValid); return offset; } |
|
235 | 253 |
254 void addrOverride(Addr newAddr) { assert(addrSizeValid); addr = newAddr; } 255 void cmdOverride(Command newCmd) { cmd = newCmd; } 256 |
|
236 /** Constructor. Note that a Request object must be constructed 237 * first, but the Requests's physical address and size fields 238 * need not be valid. The command and destination addresses 239 * must be supplied. */ 240 Packet(Request *_req, Command _cmd, short _dest) 241 : data(NULL), staticData(false), dynamicData(false), arrayData(false), 242 addr(_req->paddr), size(_req->size), dest(_dest), 243 addrSizeValid(_req->validPaddr), | 257 /** Constructor. Note that a Request object must be constructed 258 * first, but the Requests's physical address and size fields 259 * need not be valid. The command and destination addresses 260 * must be supplied. */ 261 Packet(Request *_req, Command _cmd, short _dest) 262 : data(NULL), staticData(false), dynamicData(false), arrayData(false), 263 addr(_req->paddr), size(_req->size), dest(_dest), 264 addrSizeValid(_req->validPaddr), |
244 srcValid(false), | 265 srcValid(false), offsetValid(false), |
245 req(_req), coherence(NULL), senderState(NULL), cmd(_cmd), 246 result(Unknown) 247 { | 266 req(_req), coherence(NULL), senderState(NULL), cmd(_cmd), 267 result(Unknown) 268 { |
269 flags = 0; |
|
248 } 249 | 270 } 271 |
272 /** Alternate constructor if you are trying to create a packet with 273 * a request that is for a whole block, not the address from the req. 274 * this allows for overriding the size/addr of the req.*/ 275 Packet(Request *_req, Command _cmd, short _dest, int _blkSize) 276 : data(NULL), staticData(false), dynamicData(false), arrayData(false), 277 addr(_req->paddr & ~(_blkSize - 1)), size(_blkSize), 278 offset(_req->paddr & (_blkSize - 1)), dest(_dest), 279 addrSizeValid(_req->validPaddr), srcValid(false), offsetValid(true), 280 req(_req), coherence(NULL), senderState(NULL), cmd(_cmd), 281 result(Unknown) 282 { 283 flags = 0; 284 } 285 |
|
250 /** Destructor. */ 251 ~Packet() 252 { deleteData(); } 253 254 /** Reinitialize packet address and size from the associated 255 * Request object, and reset other fields that may have been 256 * modified by a previous transaction. Typically called when a 257 * statically allocated Request/Packet pair is reused for --- 78 unchanged lines hidden --- | 286 /** Destructor. */ 287 ~Packet() 288 { deleteData(); } 289 290 /** Reinitialize packet address and size from the associated 291 * Request object, and reset other fields that may have been 292 * modified by a previous transaction. Typically called when a 293 * statically allocated Request/Packet pair is reused for --- 78 unchanged lines hidden --- |