{
_status = Idle;
- ifetch_req = new Request(true);
- ifetch_req->setAsid(0);
- // @todo fix me and get the real cpu iD!!!
- ifetch_req->setCpuNum(0);
- ifetch_req->setSize(sizeof(MachInst));
+ // @todo fix me and get the real cpu id & thread number!!!
+ ifetch_req = new Request();
ifetch_pkt = new Packet(ifetch_req, Packet::ReadReq, Packet::Broadcast);
ifetch_pkt->dataStatic(&inst);
- data_read_req = new Request(true);
- // @todo fix me and get the real cpu iD!!!
- data_read_req->setCpuNum(0);
- data_read_req->setAsid(0);
+ data_read_req = new Request();
data_read_pkt = new Packet(data_read_req, Packet::ReadReq,
Packet::Broadcast);
data_read_pkt->dataStatic(&dataReg);
- data_write_req = new Request(true);
- // @todo fix me and get the real cpu iD!!!
- data_write_req->setCpuNum(0);
- data_write_req->setAsid(0);
+ data_write_req = new Request();
data_write_pkt = new Packet(data_write_req, Packet::WriteReq,
Packet::Broadcast);
}
Fault
AtomicSimpleCPU::read(Addr addr, T &data, unsigned flags)
{
- data_read_req->setVaddr(addr);
- data_read_req->setSize(sizeof(T));
- data_read_req->setFlags(flags);
- data_read_req->setTime(curTick);
+ data_read_req->setVirt(0, addr, sizeof(T), flags, cpuXC->readPC());
if (traceData) {
traceData->setAddr(addr);
Fault
AtomicSimpleCPU::write(T data, Addr addr, unsigned flags, uint64_t *res)
{
- data_write_req->setVaddr(addr);
- data_write_req->setTime(curTick);
- data_write_req->setSize(sizeof(T));
- data_write_req->setFlags(flags);
+ data_write_req->setVirt(0, addr, sizeof(T), flags, cpuXC->readPC());
if (traceData) {
traceData->setAddr(addr);
checkForInterrupts();
- ifetch_req->resetMin();
Fault fault = setupFetchRequest(ifetch_req);
if (fault == NoFault) {
Fault
TimingSimpleCPU::read(Addr addr, T &data, unsigned flags)
{
- Request *data_read_req = new Request(true);
+ // need to fill in CPU & thread IDs here
+ Request *data_read_req = new Request();
- data_read_req->setVaddr(addr);
- data_read_req->setSize(sizeof(T));
- data_read_req->setFlags(flags);
- data_read_req->setTime(curTick);
+ data_read_req->setVirt(0, addr, sizeof(T), flags, cpuXC->readPC());
if (traceData) {
traceData->setAddr(data_read_req->getVaddr());
Fault
TimingSimpleCPU::write(T data, Addr addr, unsigned flags, uint64_t *res)
{
- Request *data_write_req = new Request(true);
- data_write_req->setVaddr(addr);
- data_write_req->setTime(curTick);
- data_write_req->setSize(sizeof(T));
- data_write_req->setFlags(flags);
+ // need to fill in CPU & thread IDs here
+ Request *data_write_req = new Request();
+ data_write_req->setVirt(0, addr, sizeof(T), flags, cpuXC->readPC());
// translate to physical address
Fault fault = cpuXC->translateDataWriteReq(data_write_req);
{
checkForInterrupts();
- Request *ifetch_req = new Request(true);
- ifetch_req->setSize(sizeof(MachInst));
+ // need to fill in CPU & thread IDs here
+ Request *ifetch_req = new Request();
Fault fault = setupFetchRequest(ifetch_req);
ifetch_pkt = new Packet(ifetch_req, Packet::ReadReq, Packet::Broadcast);
* (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;
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();
class Request
{
- //@todo Make Accesor functions, make these private.
- public:
- /** Constructor, needs a bool to signify if it is/isn't Cpu Request. */
- Request(bool isCpu);
-
- /** reset the request to it's initial state so it can be reused.*/
- void resetAll(bool isCpu);
-
- /** reset the request's addrs times, etc, so but not everything to same
- * time. */
- void resetMin();
-
-//First non-cpu request fields
private:
- /** The physical address of the request. */
+ /**
+ * The physical address of the request. Valid only if validPaddr
+ * is set. */
Addr paddr;
- /** Wether or not paddr is valid (has been written yet). */
- bool validPaddr;
- /** The size of the request. */
+ /**
+ * The size of the request. This field must be set when vaddr or
+ * paddr is written via setVirt() or setPhys(), so it is always
+ * valid as long as one of the address fields is valid. */
int size;
- /** Wether or not size is valid (has been written yet). */
- bool validSize;
-
- /** The time this request was started. Used to calculate latencies. */
- Tick time;
- /** Wether or not time is valid (has been written yet). */
- bool validTime;
-
- /** Destination address if this is a block copy. */
- Addr copyDest;
- /** Wether or not copyDest is valid (has been written yet). */
- bool validCopyDest;
/** Flag structure for the request. */
uint32_t flags;
-//Accsesors for non-cpu request fields
- public:
- /** Accesor for paddr. */
- Addr getPaddr();
- /** Accesor for paddr. */
- void setPaddr(Addr _paddr);
-
- /** Accesor for size. */
- int getSize();
- /** Accesor for size. */
- void setSize(int _size);
-
- /** Accesor for time. */
- Tick getTime();
- /** Accesor for time. */
- void setTime(Tick _time);
-
- /** Accesor for copy dest. */
- Addr getCopyDest();
- /** Accesor for copy dest. */
- void setCopyDest(Addr _copyDest);
-
- /** Accesor for flags. */
- uint32_t getFlags();
- /** Accesor for paddr. */
- void setFlags(uint32_t _flags);
-
-//Now cpu-request fields
- private:
- /** Bool to signify if this is a cpuRequest. */
- bool cpuReq;
-
- /** The virtual address of the request. */
- Addr vaddr;
- /** Wether or not the vaddr is valid. */
- bool validVaddr;
+ /**
+ * The time this request was started. Used to calculate
+ * latencies. This field is set to curTick any time paddr or vaddr
+ * is written. */
+ Tick time;
/** The address space ID. */
int asid;
- /** Wether or not the asid is valid. */
- bool validAsid;
+ /** The virtual address of the request. */
+ Addr vaddr;
/** The return value of store conditional. */
uint64_t scResult;
- /** Wether or not the sc result is valid. */
- bool validScResult;
- /** The cpu number for statistics. */
+ /** The cpu number (for statistics, typically). */
int cpuNum;
- /** Wether or not the cpu number is valid. */
- bool validCpuNum;
-
- /** The requesting thread id. */
+ /** The requesting thread id (for statistics, typically). */
int threadNum;
- /** Wether or not the thread id is valid. */
- bool validThreadNum;
/** program counter of initiating access; for tracing/debugging */
Addr pc;
- /** Wether or not the pc is valid. */
+
+ /** Whether or not paddr is valid (has been written yet). */
+ bool validPaddr;
+ /** Whether or not the asid & vaddr are valid. */
+ bool validAsidVaddr;
+ /** Whether or not the sc result is valid. */
+ bool validScResult;
+ /** Whether or not the cpu number & thread ID are valid. */
+ bool validCpuAndThreadNums;
+ /** Whether or not the pc is valid. */
bool validPC;
-//Accessor Functions for cpu request fields
public:
- /** Accesor function to determine if this is a cpu request or not.*/
- bool isCpuRequest();
-
- /** Accesor function for vaddr.*/
- Addr getVaddr();
- /** Accesor function for vaddr.*/
- void setVaddr(Addr _vaddr);
-
- /** Accesor function for asid.*/
- int getAsid();
- /** Accesor function for asid.*/
- void setAsid(int _asid);
-
- /** Accesor function for store conditional return value.*/
- uint64_t getScResult();
- /** Accesor function for store conditional return value.*/
- void setScResult(uint64_t _scResult);
-
- /** Accesor function for cpu number.*/
- int getCpuNum();
- /** Accesor function for cpu number.*/
- void setCpuNum(int _cpuNum);
-
- /** Accesor function for thread number.*/
- int getThreadNum();
- /** Accesor function for thread number.*/
- void setThreadNum(int _threadNum);
-
- /** Accesor function for pc.*/
- Addr getPC();
- /** Accesor function for pc.*/
- void setPC(Addr _pc);
+ /** Minimal constructor. No fields are initialized. */
+ Request()
+ : validPaddr(false), validAsidVaddr(false),
+ validScResult(false), validCpuAndThreadNums(false), validPC(false)
+ {}
+
+ /**
+ * Constructor for physical (e.g. device) requests. Initializes
+ * just physical address, size, flags, and timestamp (to curTick).
+ * These fields are adequate to perform a request. */
+ Request(Addr _paddr, int _size, int _flags)
+ : validCpuAndThreadNums(false)
+ { setPhys(_paddr, _size, _flags); }
+
+ /**
+ * Set up CPU and thread numbers. */
+ void setThreadContext(int _cpuNum, int _threadNum)
+ {
+ cpuNum = _cpuNum;
+ threadNum = _threadNum;
+ validCpuAndThreadNums = true;
+ }
+
+ /**
+ * Set up a physical (e.g. device) request in a previously
+ * allocated Request object. */
+ void setPhys(Addr _paddr, int _size, int _flags)
+ {
+ paddr = _paddr;
+ size = _size;
+ flags = _flags;
+ time = curTick;
+ validPaddr = true;
+ validAsidVaddr = false;
+ validPC = false;
+ validScResult = false;
+ }
+
+ /**
+ * Set up a virtual (e.g., CPU) request in a previously
+ * allocated Request object. */
+ void setVirt(int _asid, Addr _vaddr, int _size, int _flags, Addr _pc)
+ {
+ asid = _asid;
+ vaddr = _vaddr;
+ size = _size;
+ flags = _flags;
+ pc = _pc;
+ time = curTick;
+ validPaddr = false;
+ validAsidVaddr = true;
+ validPC = true;
+ validScResult = false;
+ }
+
+ /** Set just the physical address. This should only be used to
+ * record the result of a translation, and thus the vaddr must be
+ * valid before this method is called. Otherwise, use setPhys()
+ * to guarantee that the size and flags are also set.
+ */
+ void setPaddr(Addr _paddr)
+ {
+ assert(validAsidVaddr);
+ paddr = _paddr;
+ validPaddr = true;
+ }
+
+ /** Accessor for paddr. */
+ Addr getPaddr() { assert(validPaddr); return paddr; }
+
+ /** Accessor for size. */
+ int getSize() { assert(validPaddr || validAsidVaddr); return size; }
+ /** Accessor for time. */
+ Tick getTime() { assert(validPaddr || validAsidVaddr); return time; }
+
+ /** Accessor for flags. */
+ uint32_t getFlags() { assert(validPaddr || validAsidVaddr); return flags; }
+ /** Accessor for paddr. */
+ void setFlags(uint32_t _flags)
+ { assert(validPaddr || validAsidVaddr); flags = _flags; }
+
+ /** Accessor function for vaddr.*/
+ Addr getVaddr() { assert(validAsidVaddr); return vaddr; }
+
+ /** Accessor function for asid.*/
+ int getAsid() { assert(validAsidVaddr); return asid; }
+
+ /** Accessor function for store conditional return value.*/
+ uint64_t getScResult() { assert(validScResult); return scResult; }
+ /** Accessor function for store conditional return value.*/
+ void setScResult(uint64_t _scResult)
+ { scResult = _scResult; validScResult = true; }
+
+ /** Accessor function for cpu number.*/
+ int getCpuNum() { assert(validCpuAndThreadNums); return cpuNum; }
+ /** Accessor function for thread number.*/
+ int getThreadNum() { assert(validCpuAndThreadNums); return threadNum; }
+
+ /** Accessor function for pc.*/
+ Addr getPC() { assert(validPC); return pc; }
friend class Packet;
};