2 * Copyright (c) 2012-2013 ARM Limited
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated
12 * unmodified and in its entirety in all distributions of the software,
13 * modified or unmodified, in source code or in binary form.
15 * Copyright (c) 2007 MIPS Technologies, Inc.
16 * All rights reserved.
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 * Authors: Korey Sewell
45 #ifndef __CPU_INORDER_CPU_HH__
46 #define __CPU_INORDER_CPU_HH__
54 #include "arch/isa_traits.hh"
55 #include "arch/registers.hh"
56 #include "arch/types.hh"
57 #include "base/statistics.hh"
58 #include "base/types.hh"
59 #include "config/the_isa.hh"
60 #include "cpu/inorder/inorder_dyn_inst.hh"
61 #include "cpu/inorder/pipeline_stage.hh"
62 #include "cpu/inorder/pipeline_traits.hh"
63 #include "cpu/inorder/reg_dep_map.hh"
64 #include "cpu/inorder/thread_state.hh"
65 #include "cpu/o3/dep_graph.hh"
66 #include "cpu/o3/rename_map.hh"
67 #include "cpu/activity.hh"
68 #include "cpu/base.hh"
69 #include "cpu/reg_class.hh"
70 #include "cpu/simple_thread.hh"
71 #include "cpu/timebuf.hh"
72 #include "mem/packet.hh"
73 #include "mem/port.hh"
74 #include "mem/request.hh"
75 #include "sim/eventq.hh"
76 #include "sim/process.hh"
85 class InOrderCPU : public BaseCPU
89 typedef ThePipeline::Params Params;
90 typedef InOrderThreadState Thread;
93 typedef TheISA::IntReg IntReg;
94 typedef TheISA::FloatReg FloatReg;
95 typedef TheISA::FloatRegBits FloatRegBits;
96 typedef TheISA::MiscReg MiscReg;
97 typedef TheISA::RegIndex RegIndex;
100 typedef ThePipeline::DynInstPtr DynInstPtr;
101 typedef std::list<DynInstPtr>::iterator ListIt;
103 //TimeBuffer TypeDefs
104 typedef TimeBuffer<InterStageStruct> StageQueue;
106 friend class Resource;
109 /** Constructs a CPU with the given parameters. */
110 InOrderCPU(Params *params);
114 void verifyMemoryMode() const;
116 /** Return a reference to the data port. */
117 virtual MasterPort &getDataPort() { return dataPort; }
119 /** Return a reference to the instruction port. */
120 virtual MasterPort &getInstPort() { return instPort; }
126 ThreadID asid[ThePipeline::MaxThreads];
128 /** Type of core that this is */
129 std::string coreType;
131 // Only need for SE MODE
138 ThreadModel threadModel;
140 int readCpuId() { return cpu_id; }
142 void setCpuId(int val) { cpu_id = val; }
155 /** Overall CPU status. */
160 * CachePort class for the in-order CPU, interacting with a
161 * specific CacheUnit in the pipeline.
163 class CachePort : public MasterPort
167 /** Pointer to cache unit */
168 CacheUnit *cacheUnit;
171 /** Default constructor. */
172 CachePort(CacheUnit *_cacheUnit, const std::string& name);
176 /** Timing version of receive */
177 bool recvTimingResp(PacketPtr pkt);
179 /** Handles doing a retry of a failed timing request. */
182 /** Ignoring snoops for now. */
183 void recvTimingSnoopReq(PacketPtr pkt) { }
186 /** Define TickEvent for the CPU */
187 class TickEvent : public Event
190 /** Pointer to the CPU. */
194 /** Constructs a tick event. */
195 TickEvent(InOrderCPU *c);
197 /** Processes a tick event, calling tick() on the CPU. */
200 /** Returns the description of the tick event. */
201 const char *description() const;
204 /** The tick event used for scheduling CPU ticks. */
207 /** Schedule tick event, regardless of its current state. */
208 void scheduleTickEvent(Cycles delay)
210 assert(!tickEvent.scheduled() || tickEvent.squashed());
211 reschedule(&tickEvent, clockEdge(delay), true);
214 /** Unschedule tick event, regardless of its current state. */
215 void unscheduleTickEvent()
217 if (tickEvent.scheduled())
222 // List of Events That can be scheduled from
224 // NOTE(1): The Resource Pool also uses this event list
225 // to schedule events broadcast to all resources interfaces
226 // NOTE(2): CPU Events usually need to schedule a corresponding resource
230 ActivateNextReadyThread,
241 static std::string eventNames[NumCPUEvents];
244 InOrderCPU_Pri = Event::CPU_Tick_Pri,
245 Syscall_Pri = Event::CPU_Tick_Pri + 9,
246 ActivateNextReadyThread_Pri = Event::CPU_Tick_Pri + 10
249 /** Define CPU Event */
250 class CPUEvent : public Event
256 CPUEventType cpuEventType;
264 /** Constructs a CPU event. */
265 CPUEvent(InOrderCPU *_cpu, CPUEventType e_type, Fault fault,
266 ThreadID _tid, DynInstPtr inst, CPUEventPri event_pri);
268 /** Set Type of Event To Be Scheduled */
269 void setEvent(CPUEventType e_type, Fault _fault, ThreadID _tid,
273 cpuEventType = e_type;
279 /** Processes a CPU event. */
282 /** Returns the description of the CPU event. */
283 const char *description() const;
285 /** Schedule Event */
286 void scheduleEvent(Cycles delay);
288 /** Unschedule This Event */
289 void unscheduleEvent();
292 /** Schedule a CPU Event */
293 void scheduleCpuEvent(CPUEventType cpu_event, Fault fault, ThreadID tid,
294 DynInstPtr inst, Cycles delay = Cycles(0),
295 CPUEventPri event_pri = InOrderCPU_Pri);
299 /** Width (processing bandwidth) of each stage */
302 /** Interface between the CPU and CPU resources. */
303 ResourcePool *resPool;
305 /** Instruction used to signify that there is no *real* instruction in
307 DynInstPtr dummyInst[ThePipeline::MaxThreads];
308 DynInstPtr dummyBufferInst;
309 DynInstPtr dummyReqInst;
310 DynInstPtr dummyTrapInst[ThePipeline::MaxThreads];
312 /** Used by resources to signify a denied access to a resource. */
313 ResourceRequest *dummyReq[ThePipeline::MaxThreads];
315 /** The Pipeline Stages for the CPU */
316 PipelineStage *pipelineStage[ThePipeline::NumStages];
318 /** Program Counters */
319 TheISA::PCState pc[ThePipeline::MaxThreads];
321 /** Last Committed PC */
322 TheISA::PCState lastCommittedPC[ThePipeline::MaxThreads];
324 /** The Register File for the CPU */
326 FloatReg f[ThePipeline::MaxThreads][TheISA::NumFloatRegs];
327 FloatRegBits i[ThePipeline::MaxThreads][TheISA::NumFloatRegs];
329 TheISA::IntReg intRegs[ThePipeline::MaxThreads][TheISA::NumIntRegs];
332 std::vector<TheISA::ISA *> isa;
334 /** Dependency Tracker for Integer & Floating Point Regs */
335 RegDepMap archRegDepMap[ThePipeline::MaxThreads];
337 /** Register Types Used in Dependency Tracking */
338 enum RegType { IntType, FloatType, MiscType, NumRegTypes};
340 /** Global communication structure */
341 TimeBuffer<TimeStruct> timeBuffer;
343 /** Communication structure that sits in between pipeline stages */
344 StageQueue *stageQueue[ThePipeline::NumStages-1];
346 TheISA::TLB *getITBPtr();
347 TheISA::TLB *getDTBPtr();
349 TheISA::Decoder *getDecoderPtr(unsigned tid);
351 /** Accessor Type for the SkedCache */
352 typedef uint32_t SkedID;
354 /** Cache of Instruction Schedule using the instruction's name as a key */
355 static m5::hash_map<SkedID, ThePipeline::RSkedPtr> skedCache;
357 typedef m5::hash_map<SkedID, ThePipeline::RSkedPtr>::iterator SkedCacheIt;
359 /** Initialized to last iterator in map, signifying a invalid entry
362 SkedCacheIt endOfSkedIt;
364 ThePipeline::RSkedPtr frontEndSked;
365 ThePipeline::RSkedPtr faultSked;
367 /** Add a new instruction schedule to the schedule cache */
368 void addToSkedCache(DynInstPtr inst, ThePipeline::RSkedPtr inst_sked)
370 SkedID sked_id = genSkedID(inst);
371 assert(skedCache.find(sked_id) == skedCache.end());
372 skedCache[sked_id] = inst_sked;
376 /** Find a instruction schedule */
377 ThePipeline::RSkedPtr lookupSked(DynInstPtr inst)
379 SkedID sked_id = genSkedID(inst);
380 SkedCacheIt lookup_it = skedCache.find(sked_id);
382 if (lookup_it != endOfSkedIt) {
383 return (*lookup_it).second;
389 static const uint8_t INST_OPCLASS = 26;
390 static const uint8_t INST_LOAD = 25;
391 static const uint8_t INST_STORE = 24;
392 static const uint8_t INST_CONTROL = 23;
393 static const uint8_t INST_NONSPEC = 22;
394 static const uint8_t INST_DEST_REGS = 18;
395 static const uint8_t INST_SRC_REGS = 14;
396 static const uint8_t INST_SPLIT_DATA = 13;
398 inline SkedID genSkedID(DynInstPtr inst)
401 id = (inst->opClass() << INST_OPCLASS) |
402 (inst->isLoad() << INST_LOAD) |
403 (inst->isStore() << INST_STORE) |
404 (inst->isControl() << INST_CONTROL) |
405 (inst->isNonSpeculative() << INST_NONSPEC) |
406 (inst->numDestRegs() << INST_DEST_REGS) |
407 (inst->numSrcRegs() << INST_SRC_REGS) |
408 (inst->splitInst << INST_SPLIT_DATA);
412 ThePipeline::RSkedPtr createFrontEndSked();
413 ThePipeline::RSkedPtr createFaultSked();
414 ThePipeline::RSkedPtr createBackEndSked(DynInstPtr inst);
416 class StageScheduler {
418 ThePipeline::RSkedPtr rsked;
420 int nextTaskPriority;
423 StageScheduler(ThePipeline::RSkedPtr _rsked, int stage_num)
424 : rsked(_rsked), stageNum(stage_num),
428 void needs(int unit, int request) {
429 rsked->push(new ScheduleEntry(
430 stageNum, nextTaskPriority++, unit, request
434 void needs(int unit, int request, int param) {
435 rsked->push(new ScheduleEntry(
436 stageNum, nextTaskPriority++, unit, request, param
443 /** Data port. Note that it has to appear after the resPool. */
446 /** Instruction port. Note that it has to appear after the resPool. */
451 /** Registers statistics. */
454 /** Ticks CPU, calling tick() on each stage, and checking the overall
455 * activity to see if the CPU should deschedule itself.
459 /** Initialize the CPU */
462 /** HW return from error interrupt. */
463 Fault hwrei(ThreadID tid);
465 bool simPalCheck(int palFunc, ThreadID tid);
467 void checkForInterrupts();
469 /** Returns the Fault for any valid interrupt. */
470 Fault getInterrupts();
472 /** Processes any an interrupt fault. */
473 void processInterrupts(Fault interrupt);
475 /** Halts the CPU. */
476 void halt() { panic("Halt not implemented!\n"); }
478 /** Check if this address is a valid instruction address. */
479 bool validInstAddr(Addr addr) { return true; }
481 /** Check if this address is a valid data address. */
482 bool validDataAddr(Addr addr) { return true; }
484 /** Schedule a syscall on the CPU */
485 void syscallContext(Fault fault, ThreadID tid, DynInstPtr inst,
486 Cycles delay = Cycles(0));
488 /** Executes a syscall.*/
489 void syscall(int64_t callnum, ThreadID tid);
491 /** Schedule a trap on the CPU */
492 void trapContext(Fault fault, ThreadID tid, DynInstPtr inst,
493 Cycles delay = Cycles(0));
495 /** Perform trap to Handle Given Fault */
496 void trap(Fault fault, ThreadID tid, DynInstPtr inst);
498 /** Schedule thread activation on the CPU */
499 void activateContext(ThreadID tid, Cycles delay = Cycles(0));
501 /** Add Thread to Active Threads List. */
502 void activateThread(ThreadID tid);
504 /** Activate Thread In Each Pipeline Stage */
505 void activateThreadInPipeline(ThreadID tid);
507 /** Schedule Thread Activation from Ready List */
508 void activateNextReadyContext(Cycles delay = Cycles(0));
510 /** Add Thread From Ready List to Active Threads List. */
511 void activateNextReadyThread();
513 /** Schedule a thread deactivation on the CPU */
514 void deactivateContext(ThreadID tid, Cycles delay = Cycles(0));
516 /** Remove from Active Thread List */
517 void deactivateThread(ThreadID tid);
519 /** Schedule a thread suspension on the CPU */
520 void suspendContext(ThreadID tid);
522 /** Suspend Thread, Remove from Active Threads List, Add to Suspend List */
523 void suspendThread(ThreadID tid);
525 /** Schedule a thread halt on the CPU */
526 void haltContext(ThreadID tid);
528 /** Halt Thread, Remove from Active Thread List, Place Thread on Halted
531 void haltThread(ThreadID tid);
533 /** squashFromMemStall() - sets up a squash event
534 * squashDueToMemStall() - squashes pipeline
535 * @note: maybe squashContext/squashThread would be better?
537 void squashFromMemStall(DynInstPtr inst, ThreadID tid,
538 Cycles delay = Cycles(0));
539 void squashDueToMemStall(int stage_num, InstSeqNum seq_num, ThreadID tid);
541 void removePipelineStalls(ThreadID tid);
542 void squashThreadInPipeline(ThreadID tid);
543 void squashBehindMemStall(int stage_num, InstSeqNum seq_num, ThreadID tid);
545 PipelineStage* getPipeStage(int stage_num);
550 hack_once("return a bogus context id");
554 /** Update The Order In Which We Process Threads. */
555 void updateThreadPriority();
557 /** Switches a Pipeline Stage to Active. (Unused currently) */
558 void switchToActive(int stage_idx)
559 { /*pipelineStage[stage_idx]->switchToActive();*/ }
561 /** Get the current instruction sequence number, and increment it. */
562 InstSeqNum getAndIncrementInstSeq(ThreadID tid)
563 { return globalSeqNum[tid]++; }
565 /** Get the current instruction sequence number, and increment it. */
566 InstSeqNum nextInstSeqNum(ThreadID tid)
567 { return globalSeqNum[tid]; }
569 /** Increment Instruction Sequence Number */
570 void incrInstSeqNum(ThreadID tid)
571 { globalSeqNum[tid]++; }
573 /** Set Instruction Sequence Number */
574 void setInstSeqNum(ThreadID tid, InstSeqNum seq_num)
576 globalSeqNum[tid] = seq_num;
579 /** Get & Update Next Event Number */
580 InstSeqNum getNextEventNum()
583 return cpuEventNum++;
589 /** Register file accessors */
590 uint64_t readIntReg(RegIndex reg_idx, ThreadID tid);
592 FloatReg readFloatReg(RegIndex reg_idx, ThreadID tid);
594 FloatRegBits readFloatRegBits(RegIndex reg_idx, ThreadID tid);
596 void setIntReg(RegIndex reg_idx, uint64_t val, ThreadID tid);
598 void setFloatReg(RegIndex reg_idx, FloatReg val, ThreadID tid);
600 void setFloatRegBits(RegIndex reg_idx, FloatRegBits val, ThreadID tid);
602 RegType inline getRegType(RegIndex reg_idx)
604 switch (regIdxToClass(reg_idx)) {
615 panic("register %d out of range\n", reg_idx);
619 RegIndex flattenRegIdx(RegIndex reg_idx, RegType ®_type, ThreadID tid);
621 /** Reads a miscellaneous register. */
622 MiscReg readMiscRegNoEffect(int misc_reg, ThreadID tid = 0);
624 /** Reads a misc. register, including any side effects the read
625 * might have as defined by the architecture.
627 MiscReg readMiscReg(int misc_reg, ThreadID tid = 0);
629 /** Sets a miscellaneous register. */
630 void setMiscRegNoEffect(int misc_reg, const MiscReg &val,
633 /** Sets a misc. register, including any side effects the write
634 * might have as defined by the architecture.
636 void setMiscReg(int misc_reg, const MiscReg &val, ThreadID tid = 0);
638 /** Reads a int/fp/misc reg. from another thread depending on ISA-defined
641 uint64_t readRegOtherThread(unsigned misc_reg,
642 ThreadID tid = InvalidThreadID);
644 /** Sets a int/fp/misc reg. from another thread depending on an ISA-defined
647 void setRegOtherThread(unsigned misc_reg, const MiscReg &val,
650 /** Reads the commit PC of a specific thread. */
652 pcState(ThreadID tid)
657 /** Sets the commit PC of a specific thread. */
659 pcState(const TheISA::PCState &newPC, ThreadID tid)
664 Addr instAddr(ThreadID tid) { return pc[tid].instAddr(); }
665 Addr nextInstAddr(ThreadID tid) { return pc[tid].nextInstAddr(); }
666 MicroPC microPC(ThreadID tid) { return pc[tid].microPC(); }
668 /** Function to add instruction onto the head of the list of the
669 * instructions. Used when new instructions are fetched.
671 ListIt addInst(DynInstPtr inst);
673 /** Find instruction on instruction list */
674 ListIt findInst(InstSeqNum seq_num, ThreadID tid);
676 /** Function to tell the CPU that an instruction has completed. */
677 void instDone(DynInstPtr inst, ThreadID tid);
679 /** Add Instructions to the CPU Remove List*/
680 void addToRemoveList(DynInstPtr inst);
682 /** Remove an instruction from CPU */
683 void removeInst(DynInstPtr inst);
685 /** Remove all instructions younger than the given sequence number. */
686 void removeInstsUntil(const InstSeqNum &seq_num,ThreadID tid);
688 /** Removes the instruction pointed to by the iterator. */
689 inline void squashInstIt(const ListIt inst_it, ThreadID tid);
691 /** Cleans up all instructions on the instruction remove list. */
692 void cleanUpRemovedInsts();
694 /** Cleans up all events on the CPU event remove list. */
695 void cleanUpRemovedEvents();
697 /** Debug function to print all instructions on the list. */
700 /** Forwards an instruction read to the appropriate data
701 * resource (indexes into Resource Pool thru "dataPortIdx")
703 Fault read(DynInstPtr inst, Addr addr,
704 uint8_t *data, unsigned size, unsigned flags);
706 /** Forwards an instruction write. to the appropriate data
707 * resource (indexes into Resource Pool thru "dataPortIdx")
709 Fault write(DynInstPtr inst, uint8_t *data, unsigned size,
710 Addr addr, unsigned flags, uint64_t *write_res = NULL);
713 /** Per-Thread List of all the instructions in flight. */
714 std::list<DynInstPtr> instList[ThePipeline::MaxThreads];
716 /** List of all the instructions that will be removed at the end of this
719 std::queue<ListIt> removeList;
721 bool trapPending[ThePipeline::MaxThreads];
723 /** List of all the cpu event requests that will be removed at the end of
726 std::queue<Event*> cpuEventRemoveList;
728 /** Records if instructions need to be removed this cycle due to
729 * being retired or squashed.
731 bool removeInstsThisCycle;
733 /** True if there is non-speculative Inst Active In Pipeline. Lets any
734 * execution unit know, NOT to execute while the instruction is active.
736 bool nonSpecInstActive[ThePipeline::MaxThreads];
738 /** Instruction Seq. Num of current non-speculative instruction. */
739 InstSeqNum nonSpecSeqNum[ThePipeline::MaxThreads];
741 /** Instruction Seq. Num of last instruction squashed in pipeline */
742 InstSeqNum squashSeqNum[ThePipeline::MaxThreads];
744 /** Last Cycle that the CPU squashed instruction end. */
745 Tick lastSquashCycle[ThePipeline::MaxThreads];
747 std::list<ThreadID> fetchPriorityList;
750 /** Active Threads List */
751 std::list<ThreadID> activeThreads;
753 /** Ready Threads List */
754 std::list<ThreadID> readyThreads;
756 /** Suspended Threads List */
757 std::list<ThreadID> suspendedThreads;
759 /** Halted Threads List */
760 std::list<ThreadID> haltedThreads;
762 /** Thread Status Functions */
763 bool isThreadActive(ThreadID tid);
764 bool isThreadReady(ThreadID tid);
765 bool isThreadSuspended(ThreadID tid);
768 /** The activity recorder; used to tell if the CPU has any
769 * activity remaining or if it can go to idle and deschedule
772 ActivityRecorder activityRec;
775 /** Number of Active Threads in the CPU */
776 ThreadID numActiveThreads() { return activeThreads.size(); }
778 /** Thread id of active thread
779 * Only used for SwitchOnCacheMiss model.
780 * Assumes only 1 thread active
782 ThreadID activeThreadId()
784 if (numActiveThreads() > 0)
785 return activeThreads.front();
787 return InvalidThreadID;
791 /** Records that there was time buffer activity this cycle. */
792 void activityThisCycle() { activityRec.activity(); }
794 /** Changes a stage's status to active within the activity recorder. */
795 void activateStage(const int idx)
796 { activityRec.activateStage(idx); }
798 /** Changes a stage's status to inactive within the activity recorder. */
799 void deactivateStage(const int idx)
800 { activityRec.deactivateStage(idx); }
802 /** Wakes the CPU, rescheduling the CPU if it's not already active. */
805 virtual void wakeup();
807 /* LL/SC debug functionality
808 unsigned stCondFails;
810 unsigned readStCondFailures()
811 { return stCondFails; }
813 unsigned setStCondFailures(unsigned st_fails)
814 { return stCondFails = st_fails; }
817 /** Returns a pointer to a thread context. */
818 ThreadContext *tcBase(ThreadID tid = 0)
820 return thread[tid]->getTC();
823 /** Count the Total Instructions Committed in the CPU. */
824 virtual Counter totalInsts() const
828 for (ThreadID tid = 0; tid < (ThreadID)thread.size(); tid++)
829 total += thread[tid]->numInst;
834 /** Count the Total Ops Committed in the CPU. */
835 virtual Counter totalOps() const
839 for (ThreadID tid = 0; tid < (ThreadID)thread.size(); tid++)
840 total += thread[tid]->numOp;
845 /** Pointer to the system. */
848 /** The global sequence number counter. */
849 InstSeqNum globalSeqNum[ThePipeline::MaxThreads];
852 /** The global event number counter. */
853 InstSeqNum cpuEventNum;
855 /** Number of resource requests active in CPU **/
856 unsigned resReqCount;
861 /** Temporary fix for the lock flag, works in the UP case. */
864 /** Counter of how many stages have completed draining */
867 /** Pointers to all of the threads in the CPU. */
868 std::vector<Thread *> thread;
870 /** Per-Stage Instruction Tracing */
873 /** The cycle that the CPU was last running, used for statistics. */
874 Tick lastRunningCycle;
876 void updateContextSwitchStats();
877 unsigned instsPerSwitch;
878 Stats::Average instsPerCtxtSwitch;
879 Stats::Scalar numCtxtSwitches;
881 /** Update Thread , used for statistic purposes*/
882 inline void tickThreadStats();
884 /** Per-Thread Tick */
885 Stats::Vector threadCycles;
888 Stats::Scalar smtCycles;
890 /** Stat for total number of times the CPU is descheduled. */
891 Stats::Scalar timesIdled;
893 /** Stat for total number of cycles the CPU spends descheduled or no
896 Stats::Scalar idleCycles;
898 /** Stat for total number of cycles the CPU is active. */
899 Stats::Scalar runCycles;
901 /** Percentage of cycles a stage was active */
902 Stats::Formula activity;
904 /** Instruction Mix Stats */
905 Stats::Scalar comLoads;
906 Stats::Scalar comStores;
907 Stats::Scalar comBranches;
908 Stats::Scalar comNops;
909 Stats::Scalar comNonSpec;
910 Stats::Scalar comInts;
911 Stats::Scalar comFloats;
913 /** Stat for the number of committed instructions per thread. */
914 Stats::Vector committedInsts;
916 /** Stat for the number of committed ops per thread. */
917 Stats::Vector committedOps;
919 /** Stat for the number of committed instructions per thread. */
920 Stats::Vector smtCommittedInsts;
922 /** Stat for the total number of committed instructions. */
923 Stats::Scalar totalCommittedInsts;
925 /** Stat for the CPI per thread. */
928 /** Stat for the SMT-CPI per thread. */
929 Stats::Formula smtCpi;
931 /** Stat for the total CPI. */
932 Stats::Formula totalCpi;
934 /** Stat for the IPC per thread. */
937 /** Stat for the total IPC. */
938 Stats::Formula smtIpc;
940 /** Stat for the total IPC. */
941 Stats::Formula totalIpc;
944 #endif // __CPU_O3_CPU_HH__