* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Ron Dreslinski
+ * Steve Reinhardt
+ * Ali Saidi
*/
/**
#include "mem/request.hh"
#include "arch/isa_traits.hh"
#include "sim/root.hh"
+#include <list>
struct Packet;
typedef Packet* PacketPtr;
typedef uint8_t* PacketDataPtr;
+typedef std::list<PacketPtr> PacketList;
+
+//Coherence Flags
+#define NACKED_LINE 1 << 0
+#define SATISFIED 1 << 1
+#define SHARED_LINE 1 << 2
+
+//For statistics we need max number of commands, hard code it at
+//20 for now. @todo fix later
+#define NUM_MEM_CMDS 1 << 9
/**
* A Packet is used to encapsulate a transfer between two objects in
* (unlike * addr, size, and src). */
short dest;
- /** Is the 'addr' field valid? */
- bool addrValid;
- /** Is the 'size' field valid? */
- bool sizeValid;
+ /** Are the 'addr' and 'size' fields valid? */
+ bool addrSizeValid;
/** Is the 'src' field valid? */
bool srcValid;
public:
+ /** Used to calculate latencies for each packet.*/
+ Tick time;
+
/** The special destination address indicating that the packet
* should be routed based on its address. */
static const short Broadcast = -1;
IsRequest = 1 << 4,
IsResponse = 1 << 5,
NeedsResponse = 1 << 6,
+ IsSWPrefetch = 1 << 7,
+ IsHWPrefetch = 1 << 8
};
public:
WriteReq = IsWrite | IsRequest | NeedsResponse,
WriteReqNoAck = IsWrite | IsRequest,
ReadResp = IsRead | IsResponse,
- WriteResp = IsWrite | IsResponse
+ WriteResp = IsWrite | IsResponse,
+ Writeback = IsWrite | IsRequest,
+ SoftPFReq = IsRead | IsRequest | IsSWPrefetch | NeedsResponse,
+ HardPFReq = IsRead | IsRequest | IsHWPrefetch | NeedsResponse,
+ SoftPFResp = IsRead | IsRequest | IsSWPrefetch | IsResponse,
+ HardPFResp = IsRead | IsRequest | IsHWPrefetch | IsResponse,
+ InvalidateReq = IsInvalidate | IsRequest,
+ WriteInvalidateReq = IsWrite | IsInvalidate | IsRequest,
+ UpgradeReq = IsInvalidate | NeedsResponse
};
/** Return the string name of the cmd field (for debugging and
* tracing). */
const std::string &cmdString() const;
+ /** Reutrn the string to a cmd given by idx. */
+ const std::string &cmdIdxToString(Command idx);
+
+ /** Return the index of this command. */
+ inline int cmdToIndex() const { return (int) cmd; }
+
/** The command field of the packet. */
Command cmd;
bool isRead() { return (cmd & IsRead) != 0; }
+ bool isWrite() { return (cmd & IsWrite) != 0; }
bool isRequest() { return (cmd & IsRequest) != 0; }
bool isResponse() { return (cmd & IsResponse) != 0; }
bool needsResponse() { return (cmd & NeedsResponse) != 0; }
+ bool isInvalidate() { return (cmd * IsInvalidate) != 0; }
+
+ bool isCacheFill() { assert("Unimplemented yet\n" && 0); }
+ bool isNoAllocate() { assert("Unimplemented yet\n" && 0); }
/** Possible results of a packet's request. */
enum Result
{
Success,
BadAddress,
+ Nacked,
Unknown
};
short getDest() const { return dest; }
void setDest(short _dest) { dest = _dest; }
- Addr getAddr() const { assert(addrValid); return addr; }
- void setAddr(Addr _addr) { addr = _addr; addrValid = true; }
-
- int getSize() const { assert(sizeValid); return size; }
- void setSize(int _size) { size = _size; sizeValid = true; }
+ Addr getAddr() const { assert(addrSizeValid); return addr; }
+ int getSize() const { assert(addrSizeValid); return size; }
/** Constructor. Note that a Request object must be constructed
* first, but the Requests's physical address and size fields
Packet(Request *_req, Command _cmd, short _dest)
: data(NULL), staticData(false), dynamicData(false), arrayData(false),
addr(_req->paddr), size(_req->size), dest(_dest),
- addrValid(_req->validPaddr), sizeValid(_req->validSize),
+ addrSizeValid(_req->validPaddr),
srcValid(false),
req(_req), coherence(NULL), senderState(NULL), cmd(_cmd),
result(Unknown)
* multiple transactions. */
void reinitFromRequest() {
assert(req->validPaddr);
- setAddr(req->paddr);
- assert(req->validSize);
- setSize(req->size);
+ addr = req->paddr;
+ size = req->size;
+ addrSizeValid = true;
result = Unknown;
if (dynamicData) {
deleteData();
srcValid = false;
}
+ /** Take a request packet that has been returned as NACKED and modify it so
+ * that it can be sent out again. Only packets that need a response can be
+ * NACKED, so verify that that is true. */
+ void reinitNacked() {
+ assert(needsResponse() && result == Nacked);
+ dest = Broadcast;
+ result = Unknown;
+ }
+
+
/** Set the data pointer to the following value that should not be freed. */
template <typename T>
void dataStatic(T *p);