packet.cc (2632:1bb2f91485ea) | packet.cc (2641:6d9d837e2032) |
---|---|
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; --- 20 unchanged lines hidden (view full) --- 29/** 30 * @file 31 * Definition of the Packet Class, a packet is a transaction occuring 32 * between a single level of the memory heirarchy (ie L1->L2). 33 */ 34#include "base/misc.hh" 35#include "mem/packet.hh" 36 | 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; --- 20 unchanged lines hidden (view full) --- 29/** 30 * @file 31 * Definition of the Packet Class, a packet is a transaction occuring 32 * between a single level of the memory heirarchy (ie L1->L2). 33 */ 34#include "base/misc.hh" 35#include "mem/packet.hh" 36 |
37static const std::string ReadReqString("ReadReq"); 38static const std::string WriteReqString("WriteReq"); 39static const std::string WriteReqNoAckString("WriteReqNoAck"); 40static const std::string ReadRespString("ReadResp"); 41static const std::string WriteRespString("WriteResp"); 42static const std::string OtherCmdString("<other>"); |
|
37 | 43 |
44const std::string & 45Packet::cmdString() const 46{ 47 switch (cmd) { 48 case ReadReq: return ReadReqString; 49 case WriteReq: return WriteReqString; 50 case WriteReqNoAck: return WriteReqNoAckString; 51 case ReadResp: return ReadRespString; 52 case WriteResp: return WriteRespString; 53 default: return OtherCmdString; 54 } 55} 56 |
|
38/** delete the data pointed to in the data pointer. Ok to call to matter how 39 * data was allocted. */ 40void | 57/** delete the data pointed to in the data pointer. Ok to call to matter how 58 * data was allocted. */ 59void |
41Packet::deleteData() { | 60Packet::deleteData() 61{ |
42 assert(staticData || dynamicData); 43 if (staticData) 44 return; 45 46 if (arrayData) 47 delete [] data; 48 else 49 delete data; 50} 51 52/** If there isn't data in the packet, allocate some. */ 53void | 62 assert(staticData || dynamicData); 63 if (staticData) 64 return; 65 66 if (arrayData) 67 delete [] data; 68 else 69 delete data; 70} 71 72/** If there isn't data in the packet, allocate some. */ 73void |
54Packet::allocate() { | 74Packet::allocate() 75{ |
55 if (data) 56 return; 57 assert(!staticData); 58 dynamicData = true; 59 arrayData = true; | 76 if (data) 77 return; 78 assert(!staticData); 79 dynamicData = true; 80 arrayData = true; |
60 data = new uint8_t[size]; | 81 data = new uint8_t[getSize()]; |
61} 62 63/** Do the packet modify the same addresses. */ 64bool | 82} 83 84/** Do the packet modify the same addresses. */ 85bool |
65Packet::intersect(Packet *p) { 66 Addr s1 = addr; 67 Addr e1 = addr + size; 68 Addr s2 = p->addr; 69 Addr e2 = p->addr + p->size; | 86Packet::intersect(Packet *p) 87{ 88 Addr s1 = getAddr(); 89 Addr e1 = getAddr() + getSize(); 90 Addr s2 = p->getAddr(); 91 Addr e2 = p->getAddr() + p->getSize(); |
70 71 if (s1 >= s2 && s1 < e2) 72 return true; 73 if (e1 >= s2 && e1 < e2) 74 return true; 75 return false; 76} 77 78/** Minimally reset a packet so something like simple cpu can reuse it. */ 79void | 92 93 if (s1 >= s2 && s1 < e2) 94 return true; 95 if (e1 >= s2 && e1 < e2) 96 return true; 97 return false; 98} 99 100/** Minimally reset a packet so something like simple cpu can reuse it. */ 101void |
80Packet::reset() { | 102Packet::reset() 103{ |
81 result = Unknown; 82 if (dynamicData) { 83 deleteData(); 84 dynamicData = false; 85 arrayData = false; 86 time = curTick; 87 } 88} 89 90 | 104 result = Unknown; 105 if (dynamicData) { 106 deleteData(); 107 dynamicData = false; 108 arrayData = false; 109 time = curTick; 110 } 111} 112 113 |
91 92 93bool fixPacket(Packet *func, Packet *timing) 94{ panic("Need to implement!"); } | 114bool 115fixPacket(Packet *func, Packet *timing) 116{ 117 panic("Need to implement!"); 118} |