161c161
< drainCount(0),
---
> switchCount(0),
466c466
< DPRINTF(O3CPU,"[tid:%i] Initializing thread data");
---
> DPRINTF(O3CPU,"[tid:%i] Initializing thread into CPU");
469d468
< #if 0
473c472
< ThreadContext *src_tc = thread[tid];
---
> ThreadContext *src_tc = tcBase(tid);
493c492
< this->copyFromTC(tid);
---
> //this->copyFromTC(tid);
495,497c494,499
< //Set PC/NPC
< regFile.pc[tid] = src_tc->readPC();
< regFile.npc[tid] = src_tc->readNextPC();
---
> //Set PC/NPC/NNPC
> setPC(src_tc->readPC(), tid);
> setNextPC(src_tc->readNextPC(), tid);
> #if THE_ISA != ALPHA_ISA
> setNextNPC(src_tc->readNextNPC(), tid);
> #endif
506d507
< #endif
513,515c514,520
< DPRINTF(O3CPU,"[tid:%i] Removing thread data");
< #if 0
< //Unbind Int Regs from Rename Map
---
> DPRINTF(O3CPU,"[tid:%i] Removing thread from CPU.");
>
> // Copy Thread Data From RegFile
> // If thread is suspended, it might be re-allocated
> //this->copyToTC(tid);
>
> // Unbind Int Regs from Rename Map
523c528
< //Unbind Float Regs from Rename Map
---
> // Unbind Float Regs from Rename Map
531,539c536
< //Copy Thread Data From RegFile
< /* Fix Me:
< * Do we really need to do this if we are removing a thread
< * in the sense that it's finished (exiting)? If the thread is just
< * being suspended we might...
< */
< // this->copyToTC(tid);
<
< //Squash Throughout Pipeline
---
> // Squash Throughout Pipeline
546c543
< //Reset ROB/IQ/LSQ Entries
---
> // Reset ROB/IQ/LSQ Entries
551d547
< #endif
659c655
< DPRINTF(O3CPU,"[tid: %i]: Suspended ...\n", tid);
---
> DPRINTF(O3CPU,"[tid: %i]: Suspending Thread Context.\n", tid);
679,680c675,676
< DPRINTF(O3CPU,"[tid:%i]: Deallocating ...", tid);
< /*
---
> DPRINTF(O3CPU,"[tid:%i]: Deallocating Thread Context", tid);
>
682,683c678,679
< list<unsigned>::iterator isActive = find(
< activeThreads.begin(), activeThreads.end(), tid);
---
> list<unsigned>::iterator thread_it =
> find(activeThreads.begin(), activeThreads.end(), tid);
685c681
< if (isActive != activeThreads.end()) {
---
> if (thread_it != activeThreads.end()) {
688c684
< activeThreads.erase(isActive);
---
> activeThreads.erase(thread_it);
692d687
< */
699c694
< DPRINTF(O3CPU,"[tid:%i]: Halted ...", tid);
---
> DPRINTF(O3CPU,"[tid:%i]: Halting Thread Context", tid);
716,717c711,712
< bool
< FullO3CPU<Impl>::drain(Event *drain_event)
---
> void
> FullO3CPU<Impl>::switchOut(Sampler *_sampler)
719,725c714,720
< drainCount = 0;
< drainEvent = drain_event;
< fetch.drain();
< decode.drain();
< rename.drain();
< iew.drain();
< commit.drain();
---
> sampler = _sampler;
> switchCount = 0;
> fetch.switchOut();
> decode.switchOut();
> rename.switchOut();
> iew.switchOut();
> commit.switchOut();
731,732d725
<
< return false;
737c730
< FullO3CPU<Impl>::resume()
---
> FullO3CPU<Impl>::signalSwitched()
739,745c732,739
< if (_status == SwitchedOut)
< return;
< fetch.resume();
< decode.resume();
< rename.resume();
< iew.resume();
< commit.resume();
---
> if (++switchCount == NumStages) {
> fetch.doSwitchOut();
> rename.doSwitchOut();
> commit.doSwitchOut();
> instList.clear();
> while (!removeList.empty()) {
> removeList.pop();
> }
747,750c741,744
< if (!tickEvent.scheduled())
< tickEvent.schedule(curTick);
< _status = Running;
< }
---
> #if USE_CHECKER
> if (checker)
> checker->switchOut(sampler);
> #endif
752,756d745
< template <class Impl>
< void
< FullO3CPU<Impl>::signalDrained()
< {
< if (++drainCount == NumStages) {
759,760c748,749
< _status = Drained;
< drainEvent->process();
---
> sampler->signalSwitched();
> _status = SwitchedOut;
762c751
< assert(drainCount <= 5);
---
> assert(switchCount <= 5);
767,785d755
< FullO3CPU<Impl>::switchOut()
< {
< fetch.switchOut();
< rename.switchOut();
< commit.switchOut();
< instList.clear();
< while (!removeList.empty()) {
< removeList.pop();
< }
<
< _status = SwitchedOut;
< #if USE_CHECKER
< if (checker)
< checker->switchOut();
< #endif
< }
<
< template <class Impl>
< void