Merge ktlim@zizzer:/bk/newmem

into  zamp.eecs.umich.edu:/z/ktlim2/clean/newmem

--HG--
extra : convert_revision : d6bb87586cf7ee63ca32e36944c3755fae0b55d0
This commit is contained in:
Kevin Lim 2006-11-06 13:27:57 -05:00
commit 2506c15620
4 changed files with 45 additions and 19 deletions

View file

@ -259,6 +259,26 @@ BaseCPU::regStats()
#endif #endif
} }
Tick
BaseCPU::nextCycle()
{
Tick next_tick = curTick + clock - 1;
next_tick -= (next_tick % clock);
return next_tick;
}
Tick
BaseCPU::nextCycle(Tick begin_tick)
{
Tick next_tick = begin_tick;
while (next_tick < curTick)
next_tick += clock;
next_tick -= (next_tick % clock);
assert(next_tick >= curTick);
return next_tick;
}
void void
BaseCPU::registerThreadContexts() BaseCPU::registerThreadContexts()

View file

@ -73,6 +73,20 @@ class BaseCPU : public MemObject
inline Tick cycles(int numCycles) const { return clock * numCycles; } inline Tick cycles(int numCycles) const { return clock * numCycles; }
inline Tick curCycle() const { return curTick / clock; } inline Tick curCycle() const { return curTick / clock; }
/** The next cycle the CPU should be scheduled, given a cache
* access or quiesce event returning on this cycle. This function
* may return curTick if the CPU should run on the current cycle.
*/
Tick nextCycle();
/** The next cycle the CPU should be scheduled, given a cache
* access or quiesce event returning on the given Tick. This
* function may return curTick if the CPU should run on the
* current cycle.
* @param begin_tick The tick that the event is completing on.
*/
Tick nextCycle(Tick begin_tick);
#if FULL_SYSTEM #if FULL_SYSTEM
protected: protected:
uint64_t interrupts[TheISA::NumInterruptLevels]; uint64_t interrupts[TheISA::NumInterruptLevels];

View file

@ -180,9 +180,7 @@ AtomicSimpleCPU::resume()
changeState(SimObject::Running); changeState(SimObject::Running);
if (thread->status() == ThreadContext::Active) { if (thread->status() == ThreadContext::Active) {
if (!tickEvent.scheduled()) { if (!tickEvent.scheduled()) {
Tick nextTick = curTick + cycles(1) - 1; tickEvent.schedule(nextCycle());
nextTick -= (nextTick % (cycles(1)));
tickEvent.schedule(nextTick);
} }
} }
} }
@ -211,9 +209,7 @@ AtomicSimpleCPU::takeOverFrom(BaseCPU *oldCPU)
ThreadContext *tc = threadContexts[i]; ThreadContext *tc = threadContexts[i];
if (tc->status() == ThreadContext::Active && _status != Running) { if (tc->status() == ThreadContext::Active && _status != Running) {
_status = Running; _status = Running;
Tick nextTick = curTick + cycles(1) - 1; tickEvent.schedule(nextCycle());
nextTick -= (nextTick % (cycles(1)));
tickEvent.schedule(nextTick);
break; break;
} }
} }
@ -231,9 +227,7 @@ AtomicSimpleCPU::activateContext(int thread_num, int delay)
notIdleFraction++; notIdleFraction++;
//Make sure ticks are still on multiples of cycles //Make sure ticks are still on multiples of cycles
Tick nextTick = curTick + cycles(delay + 1) - 1; tickEvent.schedule(nextCycle(curTick + cycles(delay)));
nextTick -= (nextTick % (cycles(1)));
tickEvent.schedule(nextTick);
_status = Running; _status = Running;
} }

View file

@ -532,14 +532,13 @@ TimingSimpleCPU::IcachePort::recvTiming(PacketPtr pkt)
{ {
if (pkt->isResponse()) { if (pkt->isResponse()) {
// delay processing of returned data until next CPU clock edge // delay processing of returned data until next CPU clock edge
Tick time = pkt->req->getTime(); Tick mem_time = pkt->req->getTime();
while (time < curTick) Tick next_tick = cpu->nextCycle(mem_time);
time += lat;
if (time == curTick) if (next_tick == curTick)
cpu->completeIfetch(pkt); cpu->completeIfetch(pkt);
else else
tickEvent.schedule(pkt, time); tickEvent.schedule(pkt, next_tick);
return true; return true;
} }
@ -610,14 +609,13 @@ TimingSimpleCPU::DcachePort::recvTiming(PacketPtr pkt)
{ {
if (pkt->isResponse()) { if (pkt->isResponse()) {
// delay processing of returned data until next CPU clock edge // delay processing of returned data until next CPU clock edge
Tick time = pkt->req->getTime(); Tick mem_time = pkt->req->getTime();
while (time < curTick) Tick next_tick = cpu->nextCycle(mem_time);
time += lat;
if (time == curTick) if (next_tick == curTick)
cpu->completeDataAccess(pkt); cpu->completeDataAccess(pkt);
else else
tickEvent.schedule(pkt, time); tickEvent.schedule(pkt, next_tick);
return true; return true;
} }