2 * Copyright (c) 2007 MIPS Technologies, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Korey Sewell
34 #include "arch/utility.hh"
35 #include "base/bigint.hh"
36 #include "config/full_system.hh"
37 #include "config/the_isa.hh"
38 #include "cpu/inorder/resources/resource_list.hh"
39 #include "cpu/inorder/cpu.hh"
40 #include "cpu/inorder/first_stage.hh"
41 #include "cpu/inorder/inorder_dyn_inst.hh"
42 #include "cpu/inorder/pipeline_traits.hh"
43 #include "cpu/inorder/resource_pool.hh"
44 #include "cpu/inorder/thread_context.hh"
45 #include "cpu/inorder/thread_state.hh"
46 #include "cpu/activity.hh"
47 #include "cpu/base.hh"
48 #include "cpu/exetrace.hh"
49 #include "cpu/simple_thread.hh"
50 #include "cpu/thread_context.hh"
51 #include "debug/Activity.hh"
52 #include "debug/InOrderCPU.hh"
53 #include "debug/RefCount.hh"
54 #include "debug/SkedCache.hh"
55 #include "mem/translating_port.hh"
56 #include "params/InOrderCPU.hh"
57 #include "sim/process.hh"
58 #include "sim/stat_control.hh"
61 #include "cpu/quiesce_event.hh"
62 #include "sim/system.hh"
65 #if THE_ISA == ALPHA_ISA
66 #include "arch/alpha/osfpal.hh"
70 using namespace TheISA
;
71 using namespace ThePipeline
;
73 InOrderCPU::TickEvent::TickEvent(InOrderCPU
*c
)
74 : Event(CPU_Tick_Pri
), cpu(c
)
79 InOrderCPU::TickEvent::process()
86 InOrderCPU::TickEvent::description()
88 return "InOrderCPU tick event";
91 InOrderCPU::CPUEvent::CPUEvent(InOrderCPU
*_cpu
, CPUEventType e_type
,
92 Fault fault
, ThreadID _tid
, DynInstPtr inst
,
93 CPUEventPri event_pri
)
94 : Event(event_pri
), cpu(_cpu
)
96 setEvent(e_type
, fault
, _tid
, inst
);
100 std::string
InOrderCPU::eventNames
[NumCPUEvents
] =
103 "ActivateNextReadyThread",
109 "SquashFromMemStall",
114 InOrderCPU::CPUEvent::process()
116 switch (cpuEventType
)
119 cpu
->activateThread(tid
);
120 cpu
->resPool
->activateThread(tid
);
123 case ActivateNextReadyThread
:
124 cpu
->activateNextReadyThread();
127 case DeactivateThread
:
128 cpu
->deactivateThread(tid
);
129 cpu
->resPool
->deactivateThread(tid
);
133 cpu
->haltThread(tid
);
134 cpu
->resPool
->deactivateThread(tid
);
138 cpu
->suspendThread(tid
);
139 cpu
->resPool
->suspendThread(tid
);
142 case SquashFromMemStall
:
143 cpu
->squashDueToMemStall(inst
->squashingStage
, inst
->seqNum
, tid
);
144 cpu
->resPool
->squashDueToMemStall(inst
, inst
->squashingStage
,
149 DPRINTF(InOrderCPU
, "Trapping CPU\n");
150 cpu
->trap(fault
, tid
, inst
);
151 cpu
->resPool
->trap(fault
, tid
, inst
);
155 cpu
->syscall(inst
->syscallNum
, tid
);
156 cpu
->resPool
->trap(fault
, tid
, inst
);
160 fatal("Unrecognized Event Type %s", eventNames
[cpuEventType
]);
163 cpu
->cpuEventRemoveList
.push(this);
169 InOrderCPU::CPUEvent::description()
171 return "InOrderCPU event";
175 InOrderCPU::CPUEvent::scheduleEvent(int delay
)
177 assert(!scheduled() || squashed());
178 cpu
->reschedule(this, cpu
->nextCycle(curTick() + cpu
->ticks(delay
)), true);
182 InOrderCPU::CPUEvent::unscheduleEvent()
188 InOrderCPU::InOrderCPU(Params
*params
)
190 cpu_id(params
->cpu_id
),
194 stageWidth(params
->stageWidth
),
196 removeInstsThisCycle(false),
197 activityRec(params
->name
, NumStages
, 10, params
->activity
),
200 system(params
->system
),
201 physmem(system
->physmem
),
202 #endif // FULL_SYSTEM
208 deferRegistration(false/*params->deferRegistration*/),
209 stageTracing(params
->stageTracing
),
213 ThreadID active_threads
;
216 resPool
= new ResourcePool(this, params
);
218 // Resize for Multithreading CPUs
219 thread
.resize(numThreads
);
224 active_threads
= params
->workload
.size();
226 if (active_threads
> MaxThreads
) {
227 panic("Workload Size too large. Increase the 'MaxThreads'"
228 "in your InOrder implementation or "
229 "edit your workload size.");
233 if (active_threads
> 1) {
234 threadModel
= (InOrderCPU::ThreadModel
) params
->threadModel
;
236 if (threadModel
== SMT
) {
237 DPRINTF(InOrderCPU
, "Setting Thread Model to SMT.\n");
238 } else if (threadModel
== SwitchOnCacheMiss
) {
239 DPRINTF(InOrderCPU
, "Setting Thread Model to "
240 "Switch On Cache Miss\n");
244 threadModel
= Single
;
251 // Bind the fetch & data ports from the resource pool.
252 fetchPortIdx
= resPool
->getPortIdx(params
->fetchMemPort
);
253 if (fetchPortIdx
== 0) {
254 fatal("Unable to find port to fetch instructions from.\n");
257 dataPortIdx
= resPool
->getPortIdx(params
->dataMemPort
);
258 if (dataPortIdx
== 0) {
259 fatal("Unable to find port for data.\n");
262 for (ThreadID tid
= 0; tid
< numThreads
; ++tid
) {
264 lastCommittedPC
[tid
].set(0);
267 // SMT is not supported in FS mode yet.
268 assert(numThreads
== 1);
269 thread
[tid
] = new Thread(this, 0);
271 if (tid
< (ThreadID
)params
->workload
.size()) {
272 DPRINTF(InOrderCPU
, "Workload[%i] process is %#x\n",
273 tid
, params
->workload
[tid
]->prog_fname
);
275 new Thread(this, tid
, params
->workload
[tid
]);
277 //Allocate Empty thread so M5 can use later
278 //when scheduling threads to CPU
279 Process
* dummy_proc
= params
->workload
[0];
280 thread
[tid
] = new Thread(this, tid
, dummy_proc
);
283 // Eventually set this with parameters...
287 // Setup the TC that will serve as the interface to the threads/CPU.
288 InOrderThreadContext
*tc
= new InOrderThreadContext
;
290 tc
->thread
= thread
[tid
];
292 // Give the thread the TC.
293 thread
[tid
]->tc
= tc
;
294 thread
[tid
]->setFuncExeInst(0);
295 globalSeqNum
[tid
] = 1;
297 // Add the TC to the CPU's list of TC's.
298 this->threadContexts
.push_back(tc
);
301 // Initialize TimeBuffer Stage Queues
302 for (int stNum
=0; stNum
< NumStages
- 1; stNum
++) {
303 stageQueue
[stNum
] = new StageQueue(NumStages
, NumStages
);
304 stageQueue
[stNum
]->id(stNum
);
308 // Set Up Pipeline Stages
309 for (int stNum
=0; stNum
< NumStages
; stNum
++) {
311 pipelineStage
[stNum
] = new FirstStage(params
, stNum
);
313 pipelineStage
[stNum
] = new PipelineStage(params
, stNum
);
315 pipelineStage
[stNum
]->setCPU(this);
316 pipelineStage
[stNum
]->setActiveThreads(&activeThreads
);
317 pipelineStage
[stNum
]->setTimeBuffer(&timeBuffer
);
319 // Take Care of 1st/Nth stages
321 pipelineStage
[stNum
]->setPrevStageQueue(stageQueue
[stNum
- 1]);
322 if (stNum
< NumStages
- 1)
323 pipelineStage
[stNum
]->setNextStageQueue(stageQueue
[stNum
]);
326 // Initialize thread specific variables
327 for (ThreadID tid
= 0; tid
< numThreads
; tid
++) {
328 archRegDepMap
[tid
].setCPU(this);
330 nonSpecInstActive
[tid
] = false;
331 nonSpecSeqNum
[tid
] = 0;
333 squashSeqNum
[tid
] = MaxAddr
;
334 lastSquashCycle
[tid
] = 0;
336 memset(intRegs
[tid
], 0, sizeof(intRegs
[tid
]));
337 memset(floatRegs
.i
[tid
], 0, sizeof(floatRegs
.i
[tid
]));
340 // Define dummy instructions and resource requests to be used.
341 dummyInst
[tid
] = new InOrderDynInst(this,
347 dummyReq
[tid
] = new ResourceRequest(resPool
->getResource(0));
350 dummyReqInst
= new InOrderDynInst(this, NULL
, 0, 0, 0);
351 dummyReqInst
->setSquashed();
352 dummyReqInst
->resetInstCount();
354 dummyBufferInst
= new InOrderDynInst(this, NULL
, 0, 0, 0);
355 dummyBufferInst
->setSquashed();
356 dummyBufferInst
->resetInstCount();
358 endOfSkedIt
= skedCache
.end();
359 frontEndSked
= createFrontEndSked();
361 lastRunningCycle
= curTick();
363 // Reset CPU to reset state.
365 Fault resetFault
= new ResetFault();
366 resetFault
->invoke(tcBase());
370 // Schedule First Tick Event, CPU will reschedule itself from here on out.
371 scheduleTickEvent(0);
374 InOrderCPU::~InOrderCPU()
378 SkedCacheIt sked_it
= skedCache
.begin();
379 SkedCacheIt sked_end
= skedCache
.end();
381 while (sked_it
!= sked_end
) {
382 delete (*sked_it
).second
;
388 m5::hash_map
<InOrderCPU::SkedID
, ThePipeline::RSkedPtr
> InOrderCPU::skedCache
;
391 InOrderCPU::createFrontEndSked()
393 RSkedPtr res_sked
= new ResourceSked();
395 StageScheduler
F(res_sked
, stage_num
++);
396 StageScheduler
D(res_sked
, stage_num
++);
399 F
.needs(FetchSeq
, FetchSeqUnit::AssignNextPC
);
400 F
.needs(ICache
, FetchUnit::InitiateFetch
);
403 D
.needs(ICache
, FetchUnit::CompleteFetch
);
404 D
.needs(Decode
, DecodeUnit::DecodeInst
);
405 D
.needs(BPred
, BranchPredictor::PredictBranch
);
406 D
.needs(FetchSeq
, FetchSeqUnit::UpdateTargetPC
);
409 DPRINTF(SkedCache
, "Resource Sked created for instruction \"front_end\"\n");
415 InOrderCPU::createBackEndSked(DynInstPtr inst
)
417 RSkedPtr res_sked
= lookupSked(inst
);
418 if (res_sked
!= NULL
) {
419 DPRINTF(SkedCache
, "Found %s in sked cache.\n",
423 res_sked
= new ResourceSked();
426 int stage_num
= ThePipeline::BackEndStartStage
;
427 StageScheduler
X(res_sked
, stage_num
++);
428 StageScheduler
M(res_sked
, stage_num
++);
429 StageScheduler
W(res_sked
, stage_num
++);
431 if (!inst
->staticInst
) {
432 warn_once("Static Instruction Object Not Set. Can't Create"
433 " Back End Schedule");
438 X
.needs(RegManager
, UseDefUnit::MarkDestRegs
);
439 for (int idx
=0; idx
< inst
->numSrcRegs(); idx
++) {
440 if (!idx
|| !inst
->isStore()) {
441 X
.needs(RegManager
, UseDefUnit::ReadSrcReg
, idx
);
445 //@todo: schedule non-spec insts to operate on this cycle
446 // as long as all previous insts are done
447 if ( inst
->isNonSpeculative() ) {
448 // skip execution of non speculative insts until later
449 } else if ( inst
->isMemRef() ) {
450 if ( inst
->isLoad() ) {
451 X
.needs(AGEN
, AGENUnit::GenerateAddr
);
453 } else if (inst
->opClass() == IntMultOp
|| inst
->opClass() == IntDivOp
) {
454 X
.needs(MDU
, MultDivUnit::StartMultDiv
);
456 X
.needs(ExecUnit
, ExecutionUnit::ExecuteInst
);
460 if (!inst
->isNonSpeculative()) {
461 if (inst
->opClass() == IntMultOp
|| inst
->opClass() == IntDivOp
) {
462 M
.needs(MDU
, MultDivUnit::EndMultDiv
);
465 if ( inst
->isLoad() ) {
466 M
.needs(DCache
, CacheUnit::InitiateReadData
);
468 M
.needs(DCache
, CacheUnit::InitSecondSplitRead
);
469 } else if ( inst
->isStore() ) {
470 for (int i
= 1; i
< inst
->numSrcRegs(); i
++ ) {
471 M
.needs(RegManager
, UseDefUnit::ReadSrcReg
, i
);
473 M
.needs(AGEN
, AGENUnit::GenerateAddr
);
474 M
.needs(DCache
, CacheUnit::InitiateWriteData
);
476 M
.needs(DCache
, CacheUnit::InitSecondSplitWrite
);
481 if (!inst
->isNonSpeculative()) {
482 if ( inst
->isLoad() ) {
483 W
.needs(DCache
, CacheUnit::CompleteReadData
);
485 W
.needs(DCache
, CacheUnit::CompleteSecondSplitRead
);
486 } else if ( inst
->isStore() ) {
487 W
.needs(DCache
, CacheUnit::CompleteWriteData
);
489 W
.needs(DCache
, CacheUnit::CompleteSecondSplitWrite
);
492 // Finally, Execute Speculative Data
493 if (inst
->isMemRef()) {
494 if (inst
->isLoad()) {
495 W
.needs(AGEN
, AGENUnit::GenerateAddr
);
496 W
.needs(DCache
, CacheUnit::InitiateReadData
);
498 W
.needs(DCache
, CacheUnit::InitSecondSplitRead
);
499 W
.needs(DCache
, CacheUnit::CompleteReadData
);
501 W
.needs(DCache
, CacheUnit::CompleteSecondSplitRead
);
502 } else if (inst
->isStore()) {
503 if ( inst
->numSrcRegs() >= 2 ) {
504 W
.needs(RegManager
, UseDefUnit::ReadSrcReg
, 1);
506 W
.needs(AGEN
, AGENUnit::GenerateAddr
);
507 W
.needs(DCache
, CacheUnit::InitiateWriteData
);
509 W
.needs(DCache
, CacheUnit::InitSecondSplitWrite
);
510 W
.needs(DCache
, CacheUnit::CompleteWriteData
);
512 W
.needs(DCache
, CacheUnit::CompleteSecondSplitWrite
);
515 W
.needs(ExecUnit
, ExecutionUnit::ExecuteInst
);
519 W
.needs(Grad
, GraduationUnit::GraduateInst
);
521 for (int idx
=0; idx
< inst
->numDestRegs(); idx
++) {
522 W
.needs(RegManager
, UseDefUnit::WriteDestReg
, idx
);
525 if (inst
->isControl())
526 W
.needs(BPred
, BranchPredictor::UpdatePredictor
);
528 // Insert Back Schedule into our cache of
529 // resource schedules
530 addToSkedCache(inst
, res_sked
);
532 DPRINTF(SkedCache
, "Back End Sked Created for instruction: %s (%08p)\n",
533 inst
->instName(), inst
->getMachInst());
540 InOrderCPU::regStats()
542 /* Register the Resource Pool's stats here.*/
545 /* Register for each Pipeline Stage */
546 for (int stage_num
=0; stage_num
< ThePipeline::NumStages
; stage_num
++) {
547 pipelineStage
[stage_num
]->regStats();
550 /* Register any of the InOrderCPU's stats here.*/
552 .name(name() + ".instsPerContextSwitch")
553 .desc("Instructions Committed Per Context Switch")
554 .prereq(instsPerCtxtSwitch
);
557 .name(name() + ".contextSwitches")
558 .desc("Number of context switches");
561 .name(name() + ".comLoads")
562 .desc("Number of Load instructions committed");
565 .name(name() + ".comStores")
566 .desc("Number of Store instructions committed");
569 .name(name() + ".comBranches")
570 .desc("Number of Branches instructions committed");
573 .name(name() + ".comNops")
574 .desc("Number of Nop instructions committed");
577 .name(name() + ".comNonSpec")
578 .desc("Number of Non-Speculative instructions committed");
581 .name(name() + ".comInts")
582 .desc("Number of Integer instructions committed");
585 .name(name() + ".comFloats")
586 .desc("Number of Floating Point instructions committed");
589 .name(name() + ".timesIdled")
590 .desc("Number of times that the entire CPU went into an idle state and"
591 " unscheduled itself")
595 .name(name() + ".idleCycles")
596 .desc("Number of cycles cpu's stages were not processed");
599 .name(name() + ".runCycles")
600 .desc("Number of cycles cpu stages are processed.");
603 .name(name() + ".activity")
604 .desc("Percentage of cycles cpu is active")
606 activity
= (runCycles
/ numCycles
) * 100;
610 .name(name() + ".threadCycles")
611 .desc("Total Number of Cycles A Thread Was Active in CPU (Per-Thread)");
614 .name(name() + ".smtCycles")
615 .desc("Total number of cycles that the CPU was in SMT-mode");
619 .name(name() + ".committedInsts")
620 .desc("Number of Instructions Simulated (Per-Thread)");
624 .name(name() + ".smtCommittedInsts")
625 .desc("Number of SMT Instructions Simulated (Per-Thread)");
628 .name(name() + ".committedInsts_total")
629 .desc("Number of Instructions Simulated (Total)");
632 .name(name() + ".cpi")
633 .desc("CPI: Cycles Per Instruction (Per-Thread)")
635 cpi
= numCycles
/ committedInsts
;
638 .name(name() + ".smt_cpi")
639 .desc("CPI: Total SMT-CPI")
641 smtCpi
= smtCycles
/ smtCommittedInsts
;
644 .name(name() + ".cpi_total")
645 .desc("CPI: Total CPI of All Threads")
647 totalCpi
= numCycles
/ totalCommittedInsts
;
650 .name(name() + ".ipc")
651 .desc("IPC: Instructions Per Cycle (Per-Thread)")
653 ipc
= committedInsts
/ numCycles
;
656 .name(name() + ".smt_ipc")
657 .desc("IPC: Total SMT-IPC")
659 smtIpc
= smtCommittedInsts
/ smtCycles
;
662 .name(name() + ".ipc_total")
663 .desc("IPC: Total IPC of All Threads")
665 totalIpc
= totalCommittedInsts
/ numCycles
;
674 DPRINTF(InOrderCPU
, "\n\nInOrderCPU: Ticking main, InOrderCPU.\n");
678 bool pipes_idle
= true;
680 //Tick each of the stages
681 for (int stNum
=NumStages
- 1; stNum
>= 0 ; stNum
--) {
682 pipelineStage
[stNum
]->tick();
684 pipes_idle
= pipes_idle
&& pipelineStage
[stNum
]->idle
;
692 // Now advance the time buffers one tick
693 timeBuffer
.advance();
694 for (int sqNum
=0; sqNum
< NumStages
- 1; sqNum
++) {
695 stageQueue
[sqNum
]->advance();
697 activityRec
.advance();
699 // Any squashed events, or insts then remove them now
700 cleanUpRemovedEvents();
701 cleanUpRemovedInsts();
703 // Re-schedule CPU for this cycle
704 if (!tickEvent
.scheduled()) {
705 if (_status
== SwitchedOut
) {
707 lastRunningCycle
= curTick();
708 } else if (!activityRec
.active()) {
709 DPRINTF(InOrderCPU
, "sleeping CPU.\n");
710 lastRunningCycle
= curTick();
713 //Tick next_tick = curTick() + cycles(1);
714 //tickEvent.schedule(next_tick);
715 schedule(&tickEvent
, nextCycle(curTick() + 1));
716 DPRINTF(InOrderCPU
, "Scheduled CPU for next tick @ %i.\n",
717 nextCycle(curTick() + 1));
722 updateThreadPriority();
729 if (!deferRegistration
) {
730 registerThreadContexts();
733 // Set inSyscall so that the CPU doesn't squash when initially
734 // setting up registers.
735 for (ThreadID tid
= 0; tid
< numThreads
; ++tid
)
736 thread
[tid
]->inSyscall
= true;
739 for (ThreadID tid
= 0; tid
< numThreads
; tid
++) {
740 ThreadContext
*src_tc
= threadContexts
[tid
];
741 TheISA::initCPU(src_tc
, src_tc
->contextId());
746 for (ThreadID tid
= 0; tid
< numThreads
; ++tid
)
747 thread
[tid
]->inSyscall
= false;
749 // Call Initializiation Routine for Resource Pool
754 InOrderCPU::getPort(const std::string
&if_name
, int idx
)
756 return resPool
->getPort(if_name
, idx
);
761 InOrderCPU::hwrei(ThreadID tid
)
763 panic("hwrei: Unimplemented");
770 InOrderCPU::simPalCheck(int palFunc
, ThreadID tid
)
772 panic("simPalCheck: Unimplemented");
779 InOrderCPU::getInterrupts()
781 // Check if there are any outstanding interrupts
782 return interrupts
->getInterrupt(threadContexts
[0]);
787 InOrderCPU::processInterrupts(Fault interrupt
)
789 // Check for interrupts here. For now can copy the code that
790 // exists within isa_fullsys_traits.hh. Also assume that thread 0
791 // is the one that handles the interrupts.
792 // @todo: Possibly consolidate the interrupt checking code.
793 // @todo: Allow other threads to handle interrupts.
795 assert(interrupt
!= NoFault
);
796 interrupts
->updateIntrInfo(threadContexts
[0]);
798 DPRINTF(InOrderCPU
, "Interrupt %s being handled\n", interrupt
->name());
800 // Note: Context ID ok here? Impl. of FS mode needs to revisit this
801 trap(interrupt
, threadContexts
[0]->contextId(), dummyBufferInst
);
806 InOrderCPU::updateMemPorts()
808 // Update all ThreadContext's memory ports (Functional/Virtual
810 ThreadID size
= thread
.size();
811 for (ThreadID i
= 0; i
< size
; ++i
)
812 thread
[i
]->connectMemPorts(thread
[i
]->getTC());
817 InOrderCPU::trapContext(Fault fault
, ThreadID tid
, DynInstPtr inst
, int delay
)
819 scheduleCpuEvent(Trap
, fault
, tid
, inst
, delay
);
823 InOrderCPU::trap(Fault fault
, ThreadID tid
, DynInstPtr inst
)
825 fault
->invoke(tcBase(tid
), inst
->staticInst
);
829 InOrderCPU::squashFromMemStall(DynInstPtr inst
, ThreadID tid
, int delay
)
831 scheduleCpuEvent(SquashFromMemStall
, NoFault
, tid
, inst
, delay
);
836 InOrderCPU::squashDueToMemStall(int stage_num
, InstSeqNum seq_num
,
839 DPRINTF(InOrderCPU
, "Squashing Pipeline Stages Due to Memory Stall...\n");
841 // Squash all instructions in each stage including
842 // instruction that caused the squash (seq_num - 1)
843 // NOTE: The stage bandwidth needs to be cleared so thats why
844 // the stalling instruction is squashed as well. The stalled
845 // instruction is previously placed in another intermediate buffer
846 // while it's stall is being handled.
847 InstSeqNum squash_seq_num
= seq_num
- 1;
849 for (int stNum
=stage_num
; stNum
>= 0 ; stNum
--) {
850 pipelineStage
[stNum
]->squashDueToMemStall(squash_seq_num
, tid
);
855 InOrderCPU::scheduleCpuEvent(CPUEventType c_event
, Fault fault
,
856 ThreadID tid
, DynInstPtr inst
,
857 unsigned delay
, CPUEventPri event_pri
)
859 CPUEvent
*cpu_event
= new CPUEvent(this, c_event
, fault
, tid
, inst
,
862 Tick sked_tick
= nextCycle(curTick() + ticks(delay
));
864 DPRINTF(InOrderCPU
, "Scheduling CPU Event (%s) for cycle %i, [tid:%i].\n",
865 eventNames
[c_event
], curTick() + delay
, tid
);
866 schedule(cpu_event
, sked_tick
);
868 cpu_event
->process();
869 cpuEventRemoveList
.push(cpu_event
);
872 // Broadcast event to the Resource Pool
873 // Need to reset tid just in case this is a dummy instruction
875 resPool
->scheduleEvent(c_event
, inst
, 0, 0, tid
);
879 InOrderCPU::isThreadActive(ThreadID tid
)
881 list
<ThreadID
>::iterator isActive
=
882 std::find(activeThreads
.begin(), activeThreads
.end(), tid
);
884 return (isActive
!= activeThreads
.end());
888 InOrderCPU::isThreadReady(ThreadID tid
)
890 list
<ThreadID
>::iterator isReady
=
891 std::find(readyThreads
.begin(), readyThreads
.end(), tid
);
893 return (isReady
!= readyThreads
.end());
897 InOrderCPU::isThreadSuspended(ThreadID tid
)
899 list
<ThreadID
>::iterator isSuspended
=
900 std::find(suspendedThreads
.begin(), suspendedThreads
.end(), tid
);
902 return (isSuspended
!= suspendedThreads
.end());
906 InOrderCPU::activateNextReadyThread()
908 if (readyThreads
.size() >= 1) {
909 ThreadID ready_tid
= readyThreads
.front();
911 // Activate in Pipeline
912 activateThread(ready_tid
);
914 // Activate in Resource Pool
915 resPool
->activateThread(ready_tid
);
917 list
<ThreadID
>::iterator ready_it
=
918 std::find(readyThreads
.begin(), readyThreads
.end(), ready_tid
);
919 readyThreads
.erase(ready_it
);
922 "Attempting to activate new thread, but No Ready Threads to"
925 "Unable to switch to next active thread.\n");
930 InOrderCPU::activateThread(ThreadID tid
)
932 if (isThreadSuspended(tid
)) {
934 "Removing [tid:%i] from suspended threads list.\n", tid
);
936 list
<ThreadID
>::iterator susp_it
=
937 std::find(suspendedThreads
.begin(), suspendedThreads
.end(),
939 suspendedThreads
.erase(susp_it
);
942 if (threadModel
== SwitchOnCacheMiss
&&
943 numActiveThreads() == 1) {
945 "Ignoring activation of [tid:%i], since [tid:%i] is "
946 "already running.\n", tid
, activeThreadId());
948 DPRINTF(InOrderCPU
,"Placing [tid:%i] on ready threads list\n",
951 readyThreads
.push_back(tid
);
953 } else if (!isThreadActive(tid
)) {
955 "Adding [tid:%i] to active threads list.\n", tid
);
956 activeThreads
.push_back(tid
);
958 activateThreadInPipeline(tid
);
960 thread
[tid
]->lastActivate
= curTick();
962 tcBase(tid
)->setStatus(ThreadContext::Active
);
971 InOrderCPU::activateThreadInPipeline(ThreadID tid
)
973 for (int stNum
=0; stNum
< NumStages
; stNum
++) {
974 pipelineStage
[stNum
]->activateThread(tid
);
979 InOrderCPU::deactivateContext(ThreadID tid
, int delay
)
981 DPRINTF(InOrderCPU
,"[tid:%i]: Deactivating ...\n", tid
);
983 scheduleCpuEvent(DeactivateThread
, NoFault
, tid
, dummyInst
[tid
], delay
);
985 // Be sure to signal that there's some activity so the CPU doesn't
986 // deschedule itself.
987 activityRec
.activity();
993 InOrderCPU::deactivateThread(ThreadID tid
)
995 DPRINTF(InOrderCPU
, "[tid:%i]: Calling deactivate thread.\n", tid
);
997 if (isThreadActive(tid
)) {
998 DPRINTF(InOrderCPU
,"[tid:%i]: Removing from active threads list\n",
1000 list
<ThreadID
>::iterator thread_it
=
1001 std::find(activeThreads
.begin(), activeThreads
.end(), tid
);
1003 removePipelineStalls(*thread_it
);
1005 activeThreads
.erase(thread_it
);
1007 // Ideally, this should be triggered from the
1008 // suspendContext/Thread functions
1009 tcBase(tid
)->setStatus(ThreadContext::Suspended
);
1012 assert(!isThreadActive(tid
));
1016 InOrderCPU::removePipelineStalls(ThreadID tid
)
1018 DPRINTF(InOrderCPU
,"[tid:%i]: Removing all pipeline stalls\n",
1021 for (int stNum
= 0; stNum
< NumStages
; stNum
++) {
1022 pipelineStage
[stNum
]->removeStalls(tid
);
1028 InOrderCPU::updateThreadPriority()
1030 if (activeThreads
.size() > 1)
1032 //DEFAULT TO ROUND ROBIN SCHEME
1033 //e.g. Move highest priority to end of thread list
1034 list
<ThreadID
>::iterator list_begin
= activeThreads
.begin();
1035 list
<ThreadID
>::iterator list_end
= activeThreads
.end();
1037 unsigned high_thread
= *list_begin
;
1039 activeThreads
.erase(list_begin
);
1041 activeThreads
.push_back(high_thread
);
1046 InOrderCPU::tickThreadStats()
1048 /** Keep track of cycles that each thread is active */
1049 list
<ThreadID
>::iterator thread_it
= activeThreads
.begin();
1050 while (thread_it
!= activeThreads
.end()) {
1051 threadCycles
[*thread_it
]++;
1055 // Keep track of cycles where SMT is active
1056 if (activeThreads
.size() > 1) {
1062 InOrderCPU::activateContext(ThreadID tid
, int delay
)
1064 DPRINTF(InOrderCPU
,"[tid:%i]: Activating ...\n", tid
);
1067 scheduleCpuEvent(ActivateThread
, NoFault
, tid
, dummyInst
[tid
], delay
);
1069 // Be sure to signal that there's some activity so the CPU doesn't
1070 // deschedule itself.
1071 activityRec
.activity();
1077 InOrderCPU::activateNextReadyContext(int delay
)
1079 DPRINTF(InOrderCPU
,"Activating next ready thread\n");
1081 scheduleCpuEvent(ActivateNextReadyThread
, NoFault
, 0/*tid*/, dummyInst
[0],
1082 delay
, ActivateNextReadyThread_Pri
);
1084 // Be sure to signal that there's some activity so the CPU doesn't
1085 // deschedule itself.
1086 activityRec
.activity();
1092 InOrderCPU::haltContext(ThreadID tid
, int delay
)
1094 DPRINTF(InOrderCPU
, "[tid:%i]: Calling Halt Context...\n", tid
);
1096 scheduleCpuEvent(HaltThread
, NoFault
, tid
, dummyInst
[tid
], delay
);
1098 activityRec
.activity();
1102 InOrderCPU::haltThread(ThreadID tid
)
1104 DPRINTF(InOrderCPU
, "[tid:%i]: Placing on Halted Threads List...\n", tid
);
1105 deactivateThread(tid
);
1106 squashThreadInPipeline(tid
);
1107 haltedThreads
.push_back(tid
);
1109 tcBase(tid
)->setStatus(ThreadContext::Halted
);
1111 if (threadModel
== SwitchOnCacheMiss
) {
1112 activateNextReadyContext();
1117 InOrderCPU::suspendContext(ThreadID tid
, int delay
)
1119 scheduleCpuEvent(SuspendThread
, NoFault
, tid
, dummyInst
[tid
], delay
);
1123 InOrderCPU::suspendThread(ThreadID tid
)
1125 DPRINTF(InOrderCPU
, "[tid:%i]: Placing on Suspended Threads List...\n",
1127 deactivateThread(tid
);
1128 suspendedThreads
.push_back(tid
);
1129 thread
[tid
]->lastSuspend
= curTick();
1131 tcBase(tid
)->setStatus(ThreadContext::Suspended
);
1135 InOrderCPU::squashThreadInPipeline(ThreadID tid
)
1137 //Squash all instructions in each stage
1138 for (int stNum
=NumStages
- 1; stNum
>= 0 ; stNum
--) {
1139 pipelineStage
[stNum
]->squash(0 /*seq_num*/, tid
);
1144 InOrderCPU::getPipeStage(int stage_num
)
1146 return pipelineStage
[stage_num
];
1151 InOrderCPU::flattenRegIdx(RegIndex reg_idx
, RegType
®_type
, ThreadID tid
)
1153 if (reg_idx
< FP_Base_DepTag
) {
1155 return isa
[tid
].flattenIntIndex(reg_idx
);
1156 } else if (reg_idx
< Ctrl_Base_DepTag
) {
1157 reg_type
= FloatType
;
1158 reg_idx
-= FP_Base_DepTag
;
1159 return isa
[tid
].flattenFloatIndex(reg_idx
);
1161 reg_type
= MiscType
;
1162 return reg_idx
- TheISA::Ctrl_Base_DepTag
;
1167 InOrderCPU::readIntReg(RegIndex reg_idx
, ThreadID tid
)
1169 DPRINTF(IntRegs
, "[tid:%i]: Reading Int. Reg %i as %x\n",
1170 tid
, reg_idx
, intRegs
[tid
][reg_idx
]);
1172 return intRegs
[tid
][reg_idx
];
1176 InOrderCPU::readFloatReg(RegIndex reg_idx
, ThreadID tid
)
1178 DPRINTF(FloatRegs
, "[tid:%i]: Reading Float Reg %i as %x, %08f\n",
1179 tid
, reg_idx
, floatRegs
.i
[tid
][reg_idx
], floatRegs
.f
[tid
][reg_idx
]);
1181 return floatRegs
.f
[tid
][reg_idx
];
1185 InOrderCPU::readFloatRegBits(RegIndex reg_idx
, ThreadID tid
)
1187 DPRINTF(FloatRegs
, "[tid:%i]: Reading Float Reg %i as %x, %08f\n",
1188 tid
, reg_idx
, floatRegs
.i
[tid
][reg_idx
], floatRegs
.f
[tid
][reg_idx
]);
1190 return floatRegs
.i
[tid
][reg_idx
];
1194 InOrderCPU::setIntReg(RegIndex reg_idx
, uint64_t val
, ThreadID tid
)
1196 if (reg_idx
== TheISA::ZeroReg
) {
1197 DPRINTF(IntRegs
, "[tid:%i]: Ignoring Setting of ISA-ZeroReg "
1198 "(Int. Reg %i) to %x\n", tid
, reg_idx
, val
);
1201 DPRINTF(IntRegs
, "[tid:%i]: Setting Int. Reg %i to %x\n",
1204 intRegs
[tid
][reg_idx
] = val
;
1210 InOrderCPU::setFloatReg(RegIndex reg_idx
, FloatReg val
, ThreadID tid
)
1212 floatRegs
.f
[tid
][reg_idx
] = val
;
1213 DPRINTF(FloatRegs
, "[tid:%i]: Setting Float. Reg %i bits to "
1216 floatRegs
.i
[tid
][reg_idx
],
1217 floatRegs
.f
[tid
][reg_idx
]);
1222 InOrderCPU::setFloatRegBits(RegIndex reg_idx
, FloatRegBits val
, ThreadID tid
)
1224 floatRegs
.i
[tid
][reg_idx
] = val
;
1225 DPRINTF(FloatRegs
, "[tid:%i]: Setting Float. Reg %i bits to "
1228 floatRegs
.i
[tid
][reg_idx
],
1229 floatRegs
.f
[tid
][reg_idx
]);
1233 InOrderCPU::readRegOtherThread(unsigned reg_idx
, ThreadID tid
)
1235 // If Default value is set, then retrieve target thread
1236 if (tid
== InvalidThreadID
) {
1237 tid
= TheISA::getTargetThread(tcBase(tid
));
1240 if (reg_idx
< FP_Base_DepTag
) {
1241 // Integer Register File
1242 return readIntReg(reg_idx
, tid
);
1243 } else if (reg_idx
< Ctrl_Base_DepTag
) {
1244 // Float Register File
1245 reg_idx
-= FP_Base_DepTag
;
1246 return readFloatRegBits(reg_idx
, tid
);
1248 reg_idx
-= Ctrl_Base_DepTag
;
1249 return readMiscReg(reg_idx
, tid
); // Misc. Register File
1253 InOrderCPU::setRegOtherThread(unsigned reg_idx
, const MiscReg
&val
,
1256 // If Default value is set, then retrieve target thread
1257 if (tid
== InvalidThreadID
) {
1258 tid
= TheISA::getTargetThread(tcBase(tid
));
1261 if (reg_idx
< FP_Base_DepTag
) { // Integer Register File
1262 setIntReg(reg_idx
, val
, tid
);
1263 } else if (reg_idx
< Ctrl_Base_DepTag
) { // Float Register File
1264 reg_idx
-= FP_Base_DepTag
;
1265 setFloatRegBits(reg_idx
, val
, tid
);
1267 reg_idx
-= Ctrl_Base_DepTag
;
1268 setMiscReg(reg_idx
, val
, tid
); // Misc. Register File
1273 InOrderCPU::readMiscRegNoEffect(int misc_reg
, ThreadID tid
)
1275 return isa
[tid
].readMiscRegNoEffect(misc_reg
);
1279 InOrderCPU::readMiscReg(int misc_reg
, ThreadID tid
)
1281 DPRINTF(InOrderCPU
, "MiscReg: %i\n", misc_reg
);
1282 DPRINTF(InOrderCPU
, "tid: %i\n", tid
);
1283 DPRINTF(InOrderCPU
, "tcBase: %x\n", tcBase(tid
));
1284 DPRINTF(InOrderCPU
, "isa-tid: %x\n", &isa
[tid
]);
1286 return isa
[tid
].readMiscReg(misc_reg
, tcBase(tid
));
1290 InOrderCPU::setMiscRegNoEffect(int misc_reg
, const MiscReg
&val
, ThreadID tid
)
1292 isa
[tid
].setMiscRegNoEffect(misc_reg
, val
);
1296 InOrderCPU::setMiscReg(int misc_reg
, const MiscReg
&val
, ThreadID tid
)
1298 isa
[tid
].setMiscReg(misc_reg
, val
, tcBase(tid
));
1303 InOrderCPU::addInst(DynInstPtr inst
)
1305 ThreadID tid
= inst
->readTid();
1307 instList
[tid
].push_back(inst
);
1309 return --(instList
[tid
].end());
1313 InOrderCPU::findInst(InstSeqNum seq_num
, ThreadID tid
)
1315 ListIt it
= instList
[tid
].begin();
1316 ListIt end
= instList
[tid
].end();
1319 if ((*it
)->seqNum
== seq_num
)
1321 else if ((*it
)->seqNum
> seq_num
)
1327 return instList
[tid
].end();
1331 InOrderCPU::updateContextSwitchStats()
1333 // Set Average Stat Here, then reset to 0
1334 instsPerCtxtSwitch
= instsPerSwitch
;
1340 InOrderCPU::instDone(DynInstPtr inst
, ThreadID tid
)
1342 // Set the nextPC to be fetched if this is the last instruction
1345 // This contributes to the precise state of the CPU
1346 // which can be used when restoring a thread to the CPU after after any
1347 // type of context switching activity (fork, exception, etc.)
1348 TheISA::PCState comm_pc
= inst
->pcState();
1349 lastCommittedPC
[tid
] = comm_pc
;
1350 TheISA::advancePC(comm_pc
, inst
->staticInst
);
1351 pcState(comm_pc
, tid
);
1353 //@todo: may be unnecessary with new-ISA-specific branch handling code
1354 if (inst
->isControl()) {
1355 thread
[tid
]->lastGradIsBranch
= true;
1356 thread
[tid
]->lastBranchPC
= inst
->pcState();
1357 TheISA::advancePC(thread
[tid
]->lastBranchPC
, inst
->staticInst
);
1359 thread
[tid
]->lastGradIsBranch
= false;
1363 // Finalize Trace Data For Instruction
1364 if (inst
->traceData
) {
1365 //inst->traceData->setCycle(curTick());
1366 inst
->traceData
->setFetchSeq(inst
->seqNum
);
1367 //inst->traceData->setCPSeq(cpu->tcBase(tid)->numInst);
1368 inst
->traceData
->dump();
1369 delete inst
->traceData
;
1370 inst
->traceData
= NULL
;
1373 // Increment active thread's instruction count
1376 // Increment thread-state's instruction count
1377 thread
[tid
]->numInst
++;
1379 // Increment thread-state's instruction stats
1380 thread
[tid
]->numInsts
++;
1382 // Count committed insts per thread stats
1383 committedInsts
[tid
]++;
1385 // Count total insts committed stat
1386 totalCommittedInsts
++;
1388 // Count SMT-committed insts per thread stat
1389 if (numActiveThreads() > 1) {
1390 smtCommittedInsts
[tid
]++;
1393 // Instruction-Mix Stats
1394 if (inst
->isLoad()) {
1396 } else if (inst
->isStore()) {
1398 } else if (inst
->isControl()) {
1400 } else if (inst
->isNop()) {
1402 } else if (inst
->isNonSpeculative()) {
1404 } else if (inst
->isInteger()) {
1406 } else if (inst
->isFloating()) {
1410 // Check for instruction-count-based events.
1411 comInstEventQueue
[tid
]->serviceEvents(thread
[tid
]->numInst
);
1413 // Finally, remove instruction from CPU
1417 // currently unused function, but substitute repetitive code w/this function
1420 InOrderCPU::addToRemoveList(DynInstPtr inst
)
1422 removeInstsThisCycle
= true;
1423 if (!inst
->isRemoveList()) {
1424 DPRINTF(InOrderCPU
, "Pushing instruction [tid:%i] PC %s "
1425 "[sn:%lli] to remove list\n",
1426 inst
->threadNumber
, inst
->pcState(), inst
->seqNum
);
1427 inst
->setRemoveList();
1428 removeList
.push(inst
->getInstListIt());
1430 DPRINTF(InOrderCPU
, "Ignoring instruction removal for [tid:%i] PC %s "
1431 "[sn:%lli], already remove list\n",
1432 inst
->threadNumber
, inst
->pcState(), inst
->seqNum
);
1438 InOrderCPU::removeInst(DynInstPtr inst
)
1440 DPRINTF(InOrderCPU
, "Removing graduated instruction [tid:%i] PC %s "
1442 inst
->threadNumber
, inst
->pcState(), inst
->seqNum
);
1444 removeInstsThisCycle
= true;
1446 // Remove the instruction.
1447 if (!inst
->isRemoveList()) {
1448 DPRINTF(InOrderCPU
, "Pushing instruction [tid:%i] PC %s "
1449 "[sn:%lli] to remove list\n",
1450 inst
->threadNumber
, inst
->pcState(), inst
->seqNum
);
1451 inst
->setRemoveList();
1452 removeList
.push(inst
->getInstListIt());
1454 DPRINTF(InOrderCPU
, "Ignoring instruction removal for [tid:%i] PC %s "
1455 "[sn:%lli], already on remove list\n",
1456 inst
->threadNumber
, inst
->pcState(), inst
->seqNum
);
1462 InOrderCPU::removeInstsUntil(const InstSeqNum
&seq_num
, ThreadID tid
)
1464 //assert(!instList[tid].empty());
1466 removeInstsThisCycle
= true;
1468 ListIt inst_iter
= instList
[tid
].end();
1472 DPRINTF(InOrderCPU
, "Squashing instructions from CPU instruction "
1473 "list that are from [tid:%i] and above [sn:%lli] (end=%lli).\n",
1474 tid
, seq_num
, (*inst_iter
)->seqNum
);
1476 while ((*inst_iter
)->seqNum
> seq_num
) {
1478 bool break_loop
= (inst_iter
== instList
[tid
].begin());
1480 squashInstIt(inst_iter
, tid
);
1491 InOrderCPU::squashInstIt(const ListIt inst_it
, ThreadID tid
)
1493 DynInstPtr inst
= (*inst_it
);
1494 if (inst
->threadNumber
== tid
) {
1495 DPRINTF(InOrderCPU
, "Squashing instruction, "
1496 "[tid:%i] [sn:%lli] PC %s\n",
1501 inst
->setSquashed();
1502 archRegDepMap
[tid
].remove(inst
);
1504 if (!inst
->isRemoveList()) {
1505 DPRINTF(InOrderCPU
, "Pushing instruction [tid:%i] PC %s "
1506 "[sn:%lli] to remove list\n",
1507 inst
->threadNumber
, inst
->pcState(),
1509 inst
->setRemoveList();
1510 removeList
.push(inst_it
);
1512 DPRINTF(InOrderCPU
, "Ignoring instruction removal for [tid:%i]"
1513 " PC %s [sn:%lli], already on remove list\n",
1514 inst
->threadNumber
, inst
->pcState(),
1524 InOrderCPU::cleanUpRemovedInsts()
1526 while (!removeList
.empty()) {
1527 DPRINTF(InOrderCPU
, "Removing instruction, "
1528 "[tid:%i] [sn:%lli] PC %s\n",
1529 (*removeList
.front())->threadNumber
,
1530 (*removeList
.front())->seqNum
,
1531 (*removeList
.front())->pcState());
1533 DynInstPtr inst
= *removeList
.front();
1534 ThreadID tid
= inst
->threadNumber
;
1536 // Remove From Register Dependency Map, If Necessary
1537 // archRegDepMap[tid].remove(inst);
1539 // Clear if Non-Speculative
1540 if (inst
->staticInst
&&
1541 inst
->seqNum
== nonSpecSeqNum
[tid
] &&
1542 nonSpecInstActive
[tid
] == true) {
1543 nonSpecInstActive
[tid
] = false;
1546 inst
->onInstList
= false;
1548 instList
[tid
].erase(removeList
.front());
1553 removeInstsThisCycle
= false;
1557 InOrderCPU::cleanUpRemovedEvents()
1559 while (!cpuEventRemoveList
.empty()) {
1560 Event
*cpu_event
= cpuEventRemoveList
.front();
1561 cpuEventRemoveList
.pop();
1568 InOrderCPU::dumpInsts()
1572 ListIt inst_list_it
= instList
[0].begin();
1574 cprintf("Dumping Instruction List\n");
1576 while (inst_list_it
!= instList
[0].end()) {
1577 cprintf("Instruction:%i\nPC:%s\n[tid:%i]\n[sn:%lli]\nIssued:%i\n"
1579 num
, (*inst_list_it
)->pcState(),
1580 (*inst_list_it
)->threadNumber
,
1581 (*inst_list_it
)->seqNum
, (*inst_list_it
)->isIssued(),
1582 (*inst_list_it
)->isSquashed());
1589 InOrderCPU::wakeCPU()
1591 if (/*activityRec.active() || */tickEvent
.scheduled()) {
1592 DPRINTF(Activity
, "CPU already running.\n");
1596 DPRINTF(Activity
, "Waking up CPU\n");
1598 Tick extra_cycles
= tickToCycles((curTick() - 1) - lastRunningCycle
);
1600 idleCycles
+= extra_cycles
;
1601 for (int stage_num
= 0; stage_num
< NumStages
; stage_num
++) {
1602 pipelineStage
[stage_num
]->idleCycles
+= extra_cycles
;
1605 numCycles
+= extra_cycles
;
1607 schedule(&tickEvent
, nextCycle(curTick()));
1613 InOrderCPU::wakeup()
1615 if (thread
[0]->status() != ThreadContext::Suspended
)
1620 DPRINTF(Quiesce
, "Suspended Processor woken\n");
1621 threadContexts
[0]->activate();
1627 InOrderCPU::syscallContext(Fault fault
, ThreadID tid
, DynInstPtr inst
, int delay
)
1629 scheduleCpuEvent(Syscall
, fault
, tid
, inst
, delay
, Syscall_Pri
);
1633 InOrderCPU::syscall(int64_t callnum
, ThreadID tid
)
1635 DPRINTF(InOrderCPU
, "[tid:%i] Executing syscall().\n\n", tid
);
1637 DPRINTF(Activity
,"Activity: syscall() called.\n");
1639 // Temporarily increase this by one to account for the syscall
1641 ++(this->thread
[tid
]->funcExeInst
);
1643 // Execute the actual syscall.
1644 this->thread
[tid
]->syscall(callnum
);
1646 // Decrease funcExeInst by one as the normal commit will handle
1648 --(this->thread
[tid
]->funcExeInst
);
1650 // Clear Non-Speculative Block Variable
1651 nonSpecInstActive
[tid
] = false;
1656 InOrderCPU::getITBPtr()
1658 CacheUnit
*itb_res
=
1659 dynamic_cast<CacheUnit
*>(resPool
->getResource(fetchPortIdx
));
1660 return itb_res
->tlb();
1665 InOrderCPU::getDTBPtr()
1667 CacheUnit
*dtb_res
=
1668 dynamic_cast<CacheUnit
*>(resPool
->getResource(dataPortIdx
));
1669 return dtb_res
->tlb();
1673 InOrderCPU::read(DynInstPtr inst
, Addr addr
,
1674 uint8_t *data
, unsigned size
, unsigned flags
)
1676 //@TODO: Generalize name "CacheUnit" to "MemUnit" just in case
1677 // you want to run w/out caches?
1678 CacheUnit
*cache_res
=
1679 dynamic_cast<CacheUnit
*>(resPool
->getResource(dataPortIdx
));
1681 return cache_res
->read(inst
, addr
, data
, size
, flags
);
1685 InOrderCPU::write(DynInstPtr inst
, uint8_t *data
, unsigned size
,
1686 Addr addr
, unsigned flags
, uint64_t *write_res
)
1688 //@TODO: Generalize name "CacheUnit" to "MemUnit" just in case
1689 // you want to run w/out caches?
1690 CacheUnit
*cache_res
=
1691 dynamic_cast<CacheUnit
*>(resPool
->getResource(dataPortIdx
));
1692 return cache_res
->write(inst
, data
, size
, addr
, flags
, write_res
);