43d42
< #include <bitset>
44a44
> #include "base/compiler.hh"
65,172c65,66
<
< class MemCmd
< {
< public:
<
< /** List of all commands associated with a packet. */
< enum Command
< {
< InvalidCmd,
< ReadReq,
< WriteReq,
< WriteReqNoAck,
< ReadResp,
< WriteResp,
< Writeback,
< SoftPFReq,
< HardPFReq,
< SoftPFResp,
< HardPFResp,
< InvalidateReq,
< WriteInvalidateReq,
< WriteInvalidateResp,
< UpgradeReq,
< ReadExReq,
< ReadExResp,
< NUM_MEM_CMDS
< };
<
< private:
< /** List of command attributes. */
< enum Attribute
< {
< IsRead,
< IsWrite,
< IsPrefetch,
< IsInvalidate,
< IsRequest,
< IsResponse,
< NeedsResponse,
< IsSWPrefetch,
< IsHWPrefetch,
< IsUpgrade,
< HasData,
< NUM_COMMAND_ATTRIBUTES
< };
<
< /** Structure that defines attributes and other data associated
< * with a Command. */
< struct CommandInfo {
< /** Set of attribute flags. */
< const std::bitset<NUM_COMMAND_ATTRIBUTES> attributes;
< /** Corresponding response for requests; InvalidCmd if no
< * response is applicable. */
< const Command response;
< /** String representation (for printing) */
< const std::string str;
< };
<
< /** Array to map Command enum to associated info. */
< static const CommandInfo commandInfo[];
<
< private:
<
< Command cmd;
<
< bool testCmdAttrib(MemCmd::Attribute attrib) const {
< return commandInfo[cmd].attributes[attrib] != 0;
< }
<
< public:
<
< bool isRead() const { return testCmdAttrib(IsRead); }
< bool isWrite() const { return testCmdAttrib(IsWrite); }
< bool isRequest() const { return testCmdAttrib(IsRequest); }
< bool isResponse() const { return testCmdAttrib(IsResponse); }
< bool needsResponse() const { return testCmdAttrib(NeedsResponse); }
< bool isInvalidate() const { return testCmdAttrib(IsInvalidate); }
< bool hasData() const { return testCmdAttrib(HasData); }
<
< const Command responseCommand() const {
< return commandInfo[cmd].response;
< }
<
< /** Return the string to a cmd given by idx. */
< const std::string &toString() const {
< return commandInfo[cmd].str;
< }
<
< int toInt() const { return (int)cmd; }
<
< MemCmd(Command _cmd)
< : cmd(_cmd)
< { }
<
< MemCmd(int _cmd)
< : cmd((Command)_cmd)
< { }
<
< MemCmd()
< : cmd(InvalidCmd)
< { }
<
< bool operator==(MemCmd c2) { return (cmd == c2.cmd); }
< bool operator!=(MemCmd c2) { return (cmd != c2.cmd); }
<
< friend class Packet;
< };
<
---
> //for now. @todo fix later
> #define NUM_MEM_CMDS (1 << 11)
183,185d76
<
< typedef MemCmd::Command Command;
<
280a172,190
> private:
> /** List of command attributes. */
> // If you add a new CommandAttribute, make sure to increase NUM_MEM_CMDS
> // as well.
> enum CommandAttribute
> {
> IsRead = 1 << 0,
> IsWrite = 1 << 1,
> IsPrefetch = 1 << 2,
> IsInvalidate = 1 << 3,
> IsRequest = 1 << 4,
> IsResponse = 1 << 5,
> NeedsResponse = 1 << 6,
> IsSWPrefetch = 1 << 7,
> IsHWPrefetch = 1 << 8,
> IsUpgrade = 1 << 9,
> HasData = 1 << 10
> };
>
281a192,217
> /** List of all commands associated with a packet. */
> enum Command
> {
> InvalidCmd = 0,
> ReadReq = IsRead | IsRequest | NeedsResponse,
> WriteReq = IsWrite | IsRequest | NeedsResponse | HasData,
> WriteReqNoAck = IsWrite | IsRequest | HasData,
> ReadResp = IsRead | IsResponse | NeedsResponse | HasData,
> WriteResp = IsWrite | IsResponse | NeedsResponse,
> Writeback = IsWrite | IsRequest | HasData,
> SoftPFReq = IsRead | IsRequest | IsSWPrefetch | NeedsResponse,
> HardPFReq = IsRead | IsRequest | IsHWPrefetch | NeedsResponse,
> SoftPFResp = IsRead | IsResponse | IsSWPrefetch
> | NeedsResponse | HasData,
> HardPFResp = IsRead | IsResponse | IsHWPrefetch
> | NeedsResponse | HasData,
> InvalidateReq = IsInvalidate | IsRequest,
> WriteInvalidateReq = IsWrite | IsInvalidate | IsRequest
> | HasData | NeedsResponse,
> WriteInvalidateResp = IsWrite | IsInvalidate | IsRequest
> | NeedsResponse | IsResponse,
> UpgradeReq = IsInvalidate | IsRequest | IsUpgrade,
> ReadExReq = IsRead | IsInvalidate | IsRequest | NeedsResponse,
> ReadExResp = IsRead | IsInvalidate | IsResponse
> | NeedsResponse | HasData
> };
283,285d218
< /** The command field of the packet. */
< MemCmd cmd;
<
288c221
< const std::string &cmdString() const { return cmd.toString(); }
---
> const std::string &cmdString() const;
289a223,225
> /** Reutrn the string to a cmd given by idx. */
> const std::string &cmdIdxToString(Command idx);
>
291c227
< inline int cmdToIndex() const { return cmd.toInt(); }
---
> inline int cmdToIndex() const { return (int) cmd; }
293c229,230
< public:
---
> /** The command field of the packet. */
> Command cmd;
295,301c232,238
< bool isRead() const { return cmd.isRead(); }
< bool isWrite() const { return cmd.isWrite(); }
< bool isRequest() const { return cmd.isRequest(); }
< bool isResponse() const { return cmd.isResponse(); }
< bool needsResponse() const { return cmd.needsResponse(); }
< bool isInvalidate() const { return cmd.isInvalidate(); }
< bool hasData() const { return cmd.hasData(); }
---
> bool isRead() const { return (cmd & IsRead) != 0; }
> bool isWrite() const { return (cmd & IsWrite) != 0; }
> bool isRequest() const { return (cmd & IsRequest) != 0; }
> bool isResponse() const { return (cmd & IsResponse) != 0; }
> bool needsResponse() const { return (cmd & NeedsResponse) != 0; }
> bool isInvalidate() const { return (cmd & IsInvalidate) != 0; }
> bool hasData() const { return (cmd & HasData) != 0; }
335c272
< void cmdOverride(MemCmd newCmd) { cmd = newCmd; }
---
> void cmdOverride(Command newCmd) { cmd = newCmd; }
341c278
< Packet(Request *_req, MemCmd _cmd, short _dest)
---
> Packet(Request *_req, Command _cmd, short _dest)
356c293
< Packet(Request *_req, MemCmd _cmd, short _dest, int _blkSize)
---
> Packet(Request *_req, Command _cmd, short _dest, int _blkSize)
401c338,345
< cmd = cmd.responseCommand();
---
> int icmd = (int)cmd;
> icmd &= ~(IsRequest);
> icmd |= IsResponse;
> if (isRead())
> icmd |= HasData;
> if (isWrite())
> icmd &= ~HasData;
> cmd = (Command)icmd;
405a350,356
>
> void toggleData() {
> int icmd = (int)cmd;
> icmd ^= HasData;
> cmd = (Command)icmd;
> }
>
414c365,372
< cmd = cmd.responseCommand();
---
> int icmd = (int)cmd;
> icmd &= ~(IsRequest);
> icmd |= IsResponse;
> if (isRead())
> icmd |= HasData;
> if (isWrite())
> icmd &= ~HasData;
> cmd = (Command)icmd;