More changes toward making simpleCpu use new port interface.

cpu/simple/cpu.cc:
    Initialize the ports, also add Request and Packet instead of MemReq.  Initial work at ICache read in place.
cpu/simple/cpu.hh:
    Need to call the completion handler when we see a recieve.

--HG--
extra : convert_revision : a52caee6f0ceb5d9ee1e5acca63a202f5ea71359
This commit is contained in:
Ron Dreslinski 2006-01-31 15:00:09 -05:00
parent 6c7fdb1be7
commit 0d74f27313
2 changed files with 31 additions and 21 deletions

View file

@ -115,7 +115,7 @@ SimpleCPU::CacheCompletionEvent::description()
SimpleCPU::SimpleCPU(Params *p) SimpleCPU::SimpleCPU(Params *p)
: BaseCPU(p), tickEvent(this, p->width), xc(NULL), : BaseCPU(p), tickEvent(this, p->width), xc(NULL),
cacheCompletionEvent(this) cacheCompletionEvent(this), dcache_port(this), icache_port(this)
{ {
_status = Idle; _status = Idle;
#if FULL_SYSTEM #if FULL_SYSTEM
@ -130,10 +130,12 @@ SimpleCPU::SimpleCPU(Params *p)
icacheInterface = p->icache_interface; icacheInterface = p->icache_interface;
dcacheInterface = p->dcache_interface; dcacheInterface = p->dcache_interface;
memReq = new MemReq(); req = new CpuRequest();
memReq->xc = xc; pkt = new Packet();
memReq->asid = 0;
memReq->data = new uint8_t[64]; req->asid = 0;
pkt->req = req;
pkt->data = new uint8_t[64];
numInst = 0; numInst = 0;
startNumInst = 0; startNumInst = 0;
@ -704,16 +706,20 @@ SimpleCPU::tick()
#define IFETCH_FLAGS(pc) 0 #define IFETCH_FLAGS(pc) 0
#endif #endif
memReq->cmd = Read; pkt->cmd = Read;
memReq->reset(xc->regs.pc & ~3, sizeof(uint32_t), req->paddr = xc->regs.pc & ~3;
IFETCH_FLAGS(xc->regs.pc)); pkt->size = sizeof(uint32_t);
/* memReq->reset(xc->regs.pc & ~3, sizeof(uint32_t),
IFETCH_FLAGS(xc->regs.pc));
*/
//NEED NEW TRANSLATION HERE
fault = xc->translateInstReq(memReq); fault = xc->translateInstReq(memReq);
if (fault == No_Fault) if (fault == No_Fault)
fault = xc->mem->read(memReq, inst); fault = xc->mem->read(memReq, inst);
if (icacheInterface && fault == No_Fault) { /* if (icacheInterface && fault == No_Fault) {
memReq->completionEvent = NULL; memReq->completionEvent = NULL;
memReq->time = curTick; memReq->time = curTick;
@ -723,7 +729,7 @@ SimpleCPU::tick()
// Ugly hack to get an event scheduled *only* if the access is // Ugly hack to get an event scheduled *only* if the access is
// a miss. We really should add first-class support for this // a miss. We really should add first-class support for this
// at some point. // at some point.
if (result != MA_HIT && icacheInterface->doEvents()) { if (result != MA_HIT && icacheInterface->doEvents()) {
memReq->completionEvent = &cacheCompletionEvent; memReq->completionEvent = &cacheCompletionEvent;
lastIcacheStall = curTick; lastIcacheStall = curTick;
unscheduleTickEvent(); unscheduleTickEvent();
@ -731,6 +737,16 @@ SimpleCPU::tick()
return; return;
} }
} }
*/
bool success = icache_port.sendTiming(pkt);
if (!success)
{
//Need to wait for retry
lastIcacheStall = curTick;
unscheduleTickEvent();
_status = IcacheMissStall;
return;
}
} }
// If we've got a valid instruction (i.e., no fault on instruction // If we've got a valid instruction (i.e., no fault on instruction

View file

@ -80,13 +80,13 @@ class SimpleCPU : public BaseCPU
protected: protected:
virtual bool recvTiming(Packet &pkt) virtual bool recvTiming(Packet &pkt)
{ return cpu->recvTiming(pkt); } { return cpu->processCacheCompletion(pkt); }
virtual Tick recvAtomic(Packet &pkt) virtual Tick recvAtomic(Packet &pkt)
{ return cpu->recvAtomic(pkt); } { return cpu->processCacheCompletion(pkt); }
virtual void recvFunctional(Packet &pkt) virtual void recvFunctional(Packet &pkt)
{ cpu->recvFunctional(pkt); } { cpu->processCacheCompletion(pkt); }
virtual void recvStatusChange(Status status) virtual void recvStatusChange(Status status)
{ cpu->recvStatusChange(status); } { cpu->recvStatusChange(status); }
@ -192,17 +192,11 @@ class SimpleCPU : public BaseCPU
bool interval_stats; bool interval_stats;
#endif #endif
// L1 instruction cache
MemInterface *icacheInterface;
// L1 data cache
MemInterface *dcacheInterface;
// current instruction // current instruction
MachInst inst; MachInst inst;
// Refcounted pointer to the one memory request. CpuRequest *req;
MemReqPtr memReq; Packet *pkt;
// Pointer to the sampler that is telling us to switchover. // Pointer to the sampler that is telling us to switchover.
// Used to signal the completion of the pipe drain and schedule // Used to signal the completion of the pipe drain and schedule