2 * Copyright (c) 2012 ARM Limited
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
14 * Copyright (c) 2007 MIPS Technologies, Inc.
15 * All rights reserved.
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 * Authors: Korey Sewell
44 #ifndef __CPU_INORDER_CPU_HH__
45 #define __CPU_INORDER_CPU_HH__
53 #include "arch/isa_traits.hh"
54 #include "arch/registers.hh"
55 #include "arch/types.hh"
56 #include "base/statistics.hh"
57 #include "base/types.hh"
58 #include "config/the_isa.hh"
59 #include "cpu/inorder/inorder_dyn_inst.hh"
60 #include "cpu/inorder/pipeline_stage.hh"
61 #include "cpu/inorder/pipeline_traits.hh"
62 #include "cpu/inorder/reg_dep_map.hh"
63 #include "cpu/inorder/thread_state.hh"
64 #include "cpu/o3/dep_graph.hh"
65 #include "cpu/o3/rename_map.hh"
66 #include "cpu/activity.hh"
67 #include "cpu/base.hh"
68 #include "cpu/simple_thread.hh"
69 #include "cpu/timebuf.hh"
70 #include "mem/packet.hh"
71 #include "mem/port.hh"
72 #include "mem/request.hh"
73 #include "sim/eventq.hh"
74 #include "sim/process.hh"
83 class InOrderCPU : public BaseCPU
87 typedef ThePipeline::Params Params;
88 typedef InOrderThreadState Thread;
91 typedef TheISA::IntReg IntReg;
92 typedef TheISA::FloatReg FloatReg;
93 typedef TheISA::FloatRegBits FloatRegBits;
94 typedef TheISA::MiscReg MiscReg;
95 typedef TheISA::RegIndex RegIndex;
98 typedef ThePipeline::DynInstPtr DynInstPtr;
99 typedef std::list<DynInstPtr>::iterator ListIt;
101 //TimeBuffer TypeDefs
102 typedef TimeBuffer<InterStageStruct> StageQueue;
104 friend class Resource;
107 /** Constructs a CPU with the given parameters. */
108 InOrderCPU(Params *params);
112 void verifyMemoryMode() const;
114 /** Return a reference to the data port. */
115 virtual CpuPort &getDataPort() { return dataPort; }
117 /** Return a reference to the instruction port. */
118 virtual CpuPort &getInstPort() { return instPort; }
124 ThreadID asid[ThePipeline::MaxThreads];
126 /** Type of core that this is */
127 std::string coreType;
129 // Only need for SE MODE
136 ThreadModel threadModel;
138 int readCpuId() { return cpu_id; }
140 void setCpuId(int val) { cpu_id = val; }
153 /** Overall CPU status. */
158 * CachePort class for the in-order CPU, interacting with a
159 * specific CacheUnit in the pipeline.
161 class CachePort : public CpuPort
165 /** Pointer to cache unit */
166 CacheUnit *cacheUnit;
169 /** Default constructor. */
170 CachePort(CacheUnit *_cacheUnit, const std::string& name);
174 /** Timing version of receive */
175 bool recvTimingResp(PacketPtr pkt);
177 /** Handles doing a retry of a failed timing request. */
180 /** Ignoring snoops for now. */
181 void recvTimingSnoopReq(PacketPtr pkt) { }
184 /** Define TickEvent for the CPU */
185 class TickEvent : public Event
188 /** Pointer to the CPU. */
192 /** Constructs a tick event. */
193 TickEvent(InOrderCPU *c);
195 /** Processes a tick event, calling tick() on the CPU. */
198 /** Returns the description of the tick event. */
199 const char *description() const;
202 /** The tick event used for scheduling CPU ticks. */
205 /** Schedule tick event, regardless of its current state. */
206 void scheduleTickEvent(Cycles delay)
208 assert(!tickEvent.scheduled() || tickEvent.squashed());
209 reschedule(&tickEvent, clockEdge(delay), true);
212 /** Unschedule tick event, regardless of its current state. */
213 void unscheduleTickEvent()
215 if (tickEvent.scheduled())
220 // List of Events That can be scheduled from
222 // NOTE(1): The Resource Pool also uses this event list
223 // to schedule events broadcast to all resources interfaces
224 // NOTE(2): CPU Events usually need to schedule a corresponding resource
228 ActivateNextReadyThread,
239 static std::string eventNames[NumCPUEvents];
242 InOrderCPU_Pri = Event::CPU_Tick_Pri,
243 Syscall_Pri = Event::CPU_Tick_Pri + 9,
244 ActivateNextReadyThread_Pri = Event::CPU_Tick_Pri + 10
247 /** Define CPU Event */
248 class CPUEvent : public Event
254 CPUEventType cpuEventType;
262 /** Constructs a CPU event. */
263 CPUEvent(InOrderCPU *_cpu, CPUEventType e_type, Fault fault,
264 ThreadID _tid, DynInstPtr inst, CPUEventPri event_pri);
266 /** Set Type of Event To Be Scheduled */
267 void setEvent(CPUEventType e_type, Fault _fault, ThreadID _tid,
271 cpuEventType = e_type;
277 /** Processes a CPU event. */
280 /** Returns the description of the CPU event. */
281 const char *description() const;
283 /** Schedule Event */
284 void scheduleEvent(Cycles delay);
286 /** Unschedule This Event */
287 void unscheduleEvent();
290 /** Schedule a CPU Event */
291 void scheduleCpuEvent(CPUEventType cpu_event, Fault fault, ThreadID tid,
292 DynInstPtr inst, Cycles delay = Cycles(0),
293 CPUEventPri event_pri = InOrderCPU_Pri);
297 /** Width (processing bandwidth) of each stage */
300 /** Interface between the CPU and CPU resources. */
301 ResourcePool *resPool;
303 /** Instruction used to signify that there is no *real* instruction in
305 DynInstPtr dummyInst[ThePipeline::MaxThreads];
306 DynInstPtr dummyBufferInst;
307 DynInstPtr dummyReqInst;
308 DynInstPtr dummyTrapInst[ThePipeline::MaxThreads];
310 /** Used by resources to signify a denied access to a resource. */
311 ResourceRequest *dummyReq[ThePipeline::MaxThreads];
313 /** The Pipeline Stages for the CPU */
314 PipelineStage *pipelineStage[ThePipeline::NumStages];
316 /** Program Counters */
317 TheISA::PCState pc[ThePipeline::MaxThreads];
319 /** Last Committed PC */
320 TheISA::PCState lastCommittedPC[ThePipeline::MaxThreads];
322 /** The Register File for the CPU */
324 FloatReg f[ThePipeline::MaxThreads][TheISA::NumFloatRegs];
325 FloatRegBits i[ThePipeline::MaxThreads][TheISA::NumFloatRegs];
327 TheISA::IntReg intRegs[ThePipeline::MaxThreads][TheISA::NumIntRegs];
330 std::vector<TheISA::ISA *> isa;
332 /** Dependency Tracker for Integer & Floating Point Regs */
333 RegDepMap archRegDepMap[ThePipeline::MaxThreads];
335 /** Register Types Used in Dependency Tracking */
336 enum RegType { IntType, FloatType, MiscType, NumRegTypes};
338 /** Global communication structure */
339 TimeBuffer<TimeStruct> timeBuffer;
341 /** Communication structure that sits in between pipeline stages */
342 StageQueue *stageQueue[ThePipeline::NumStages-1];
344 TheISA::TLB *getITBPtr();
345 TheISA::TLB *getDTBPtr();
347 TheISA::Decoder *getDecoderPtr(unsigned tid);
349 /** Accessor Type for the SkedCache */
350 typedef uint32_t SkedID;
352 /** Cache of Instruction Schedule using the instruction's name as a key */
353 static m5::hash_map<SkedID, ThePipeline::RSkedPtr> skedCache;
355 typedef m5::hash_map<SkedID, ThePipeline::RSkedPtr>::iterator SkedCacheIt;
357 /** Initialized to last iterator in map, signifying a invalid entry
360 SkedCacheIt endOfSkedIt;
362 ThePipeline::RSkedPtr frontEndSked;
363 ThePipeline::RSkedPtr faultSked;
365 /** Add a new instruction schedule to the schedule cache */
366 void addToSkedCache(DynInstPtr inst, ThePipeline::RSkedPtr inst_sked)
368 SkedID sked_id = genSkedID(inst);
369 assert(skedCache.find(sked_id) == skedCache.end());
370 skedCache[sked_id] = inst_sked;
374 /** Find a instruction schedule */
375 ThePipeline::RSkedPtr lookupSked(DynInstPtr inst)
377 SkedID sked_id = genSkedID(inst);
378 SkedCacheIt lookup_it = skedCache.find(sked_id);
380 if (lookup_it != endOfSkedIt) {
381 return (*lookup_it).second;
387 static const uint8_t INST_OPCLASS = 26;
388 static const uint8_t INST_LOAD = 25;
389 static const uint8_t INST_STORE = 24;
390 static const uint8_t INST_CONTROL = 23;
391 static const uint8_t INST_NONSPEC = 22;
392 static const uint8_t INST_DEST_REGS = 18;
393 static const uint8_t INST_SRC_REGS = 14;
394 static const uint8_t INST_SPLIT_DATA = 13;
396 inline SkedID genSkedID(DynInstPtr inst)
399 id = (inst->opClass() << INST_OPCLASS) |
400 (inst->isLoad() << INST_LOAD) |
401 (inst->isStore() << INST_STORE) |
402 (inst->isControl() << INST_CONTROL) |
403 (inst->isNonSpeculative() << INST_NONSPEC) |
404 (inst->numDestRegs() << INST_DEST_REGS) |
405 (inst->numSrcRegs() << INST_SRC_REGS) |
406 (inst->splitInst << INST_SPLIT_DATA);
410 ThePipeline::RSkedPtr createFrontEndSked();
411 ThePipeline::RSkedPtr createFaultSked();
412 ThePipeline::RSkedPtr createBackEndSked(DynInstPtr inst);
414 class StageScheduler {
416 ThePipeline::RSkedPtr rsked;
418 int nextTaskPriority;
421 StageScheduler(ThePipeline::RSkedPtr _rsked, int stage_num)
422 : rsked(_rsked), stageNum(stage_num),
426 void needs(int unit, int request) {
427 rsked->push(new ScheduleEntry(
428 stageNum, nextTaskPriority++, unit, request
432 void needs(int unit, int request, int param) {
433 rsked->push(new ScheduleEntry(
434 stageNum, nextTaskPriority++, unit, request, param
441 /** Data port. Note that it has to appear after the resPool. */
444 /** Instruction port. Note that it has to appear after the resPool. */
449 /** Registers statistics. */
452 /** Ticks CPU, calling tick() on each stage, and checking the overall
453 * activity to see if the CPU should deschedule itself.
457 /** Initialize the CPU */
460 /** HW return from error interrupt. */
461 Fault hwrei(ThreadID tid);
463 bool simPalCheck(int palFunc, ThreadID tid);
465 void checkForInterrupts();
467 /** Returns the Fault for any valid interrupt. */
468 Fault getInterrupts();
470 /** Processes any an interrupt fault. */
471 void processInterrupts(Fault interrupt);
473 /** Halts the CPU. */
474 void halt() { panic("Halt not implemented!\n"); }
476 /** Check if this address is a valid instruction address. */
477 bool validInstAddr(Addr addr) { return true; }
479 /** Check if this address is a valid data address. */
480 bool validDataAddr(Addr addr) { return true; }
482 /** Schedule a syscall on the CPU */
483 void syscallContext(Fault fault, ThreadID tid, DynInstPtr inst,
484 Cycles delay = Cycles(0));
486 /** Executes a syscall.*/
487 void syscall(int64_t callnum, ThreadID tid);
489 /** Schedule a trap on the CPU */
490 void trapContext(Fault fault, ThreadID tid, DynInstPtr inst,
491 Cycles delay = Cycles(0));
493 /** Perform trap to Handle Given Fault */
494 void trap(Fault fault, ThreadID tid, DynInstPtr inst);
496 /** Schedule thread activation on the CPU */
497 void activateContext(ThreadID tid, Cycles delay = Cycles(0));
499 /** Add Thread to Active Threads List. */
500 void activateThread(ThreadID tid);
502 /** Activate Thread In Each Pipeline Stage */
503 void activateThreadInPipeline(ThreadID tid);
505 /** Schedule Thread Activation from Ready List */
506 void activateNextReadyContext(Cycles delay = Cycles(0));
508 /** Add Thread From Ready List to Active Threads List. */
509 void activateNextReadyThread();
511 /** Schedule a thread deactivation on the CPU */
512 void deactivateContext(ThreadID tid, Cycles delay = Cycles(0));
514 /** Remove from Active Thread List */
515 void deactivateThread(ThreadID tid);
517 /** Schedule a thread suspension on the CPU */
518 void suspendContext(ThreadID tid);
520 /** Suspend Thread, Remove from Active Threads List, Add to Suspend List */
521 void suspendThread(ThreadID tid);
523 /** Schedule a thread halt on the CPU */
524 void haltContext(ThreadID tid);
526 /** Halt Thread, Remove from Active Thread List, Place Thread on Halted
529 void haltThread(ThreadID tid);
531 /** squashFromMemStall() - sets up a squash event
532 * squashDueToMemStall() - squashes pipeline
533 * @note: maybe squashContext/squashThread would be better?
535 void squashFromMemStall(DynInstPtr inst, ThreadID tid,
536 Cycles delay = Cycles(0));
537 void squashDueToMemStall(int stage_num, InstSeqNum seq_num, ThreadID tid);
539 void removePipelineStalls(ThreadID tid);
540 void squashThreadInPipeline(ThreadID tid);
541 void squashBehindMemStall(int stage_num, InstSeqNum seq_num, ThreadID tid);
543 PipelineStage* getPipeStage(int stage_num);
548 hack_once("return a bogus context id");
552 /** Update The Order In Which We Process Threads. */
553 void updateThreadPriority();
555 /** Switches a Pipeline Stage to Active. (Unused currently) */
556 void switchToActive(int stage_idx)
557 { /*pipelineStage[stage_idx]->switchToActive();*/ }
559 /** Get the current instruction sequence number, and increment it. */
560 InstSeqNum getAndIncrementInstSeq(ThreadID tid)
561 { return globalSeqNum[tid]++; }
563 /** Get the current instruction sequence number, and increment it. */
564 InstSeqNum nextInstSeqNum(ThreadID tid)
565 { return globalSeqNum[tid]; }
567 /** Increment Instruction Sequence Number */
568 void incrInstSeqNum(ThreadID tid)
569 { globalSeqNum[tid]++; }
571 /** Set Instruction Sequence Number */
572 void setInstSeqNum(ThreadID tid, InstSeqNum seq_num)
574 globalSeqNum[tid] = seq_num;
577 /** Get & Update Next Event Number */
578 InstSeqNum getNextEventNum()
581 return cpuEventNum++;
587 /** Register file accessors */
588 uint64_t readIntReg(RegIndex reg_idx, ThreadID tid);
590 FloatReg readFloatReg(RegIndex reg_idx, ThreadID tid);
592 FloatRegBits readFloatRegBits(RegIndex reg_idx, ThreadID tid);
594 void setIntReg(RegIndex reg_idx, uint64_t val, ThreadID tid);
596 void setFloatReg(RegIndex reg_idx, FloatReg val, ThreadID tid);
598 void setFloatRegBits(RegIndex reg_idx, FloatRegBits val, ThreadID tid);
600 RegType inline getRegType(RegIndex reg_idx)
602 if (reg_idx < TheISA::FP_Base_DepTag)
604 else if (reg_idx < TheISA::Ctrl_Base_DepTag)
610 RegIndex flattenRegIdx(RegIndex reg_idx, RegType ®_type, ThreadID tid);
612 /** Reads a miscellaneous register. */
613 MiscReg readMiscRegNoEffect(int misc_reg, ThreadID tid = 0);
615 /** Reads a misc. register, including any side effects the read
616 * might have as defined by the architecture.
618 MiscReg readMiscReg(int misc_reg, ThreadID tid = 0);
620 /** Sets a miscellaneous register. */
621 void setMiscRegNoEffect(int misc_reg, const MiscReg &val,
624 /** Sets a misc. register, including any side effects the write
625 * might have as defined by the architecture.
627 void setMiscReg(int misc_reg, const MiscReg &val, ThreadID tid = 0);
629 /** Reads a int/fp/misc reg. from another thread depending on ISA-defined
632 uint64_t readRegOtherThread(unsigned misc_reg,
633 ThreadID tid = InvalidThreadID);
635 /** Sets a int/fp/misc reg. from another thread depending on an ISA-defined
638 void setRegOtherThread(unsigned misc_reg, const MiscReg &val,
641 /** Reads the commit PC of a specific thread. */
643 pcState(ThreadID tid)
648 /** Sets the commit PC of a specific thread. */
650 pcState(const TheISA::PCState &newPC, ThreadID tid)
655 Addr instAddr(ThreadID tid) { return pc[tid].instAddr(); }
656 Addr nextInstAddr(ThreadID tid) { return pc[tid].nextInstAddr(); }
657 MicroPC microPC(ThreadID tid) { return pc[tid].microPC(); }
659 /** Function to add instruction onto the head of the list of the
660 * instructions. Used when new instructions are fetched.
662 ListIt addInst(DynInstPtr inst);
664 /** Find instruction on instruction list */
665 ListIt findInst(InstSeqNum seq_num, ThreadID tid);
667 /** Function to tell the CPU that an instruction has completed. */
668 void instDone(DynInstPtr inst, ThreadID tid);
670 /** Add Instructions to the CPU Remove List*/
671 void addToRemoveList(DynInstPtr inst);
673 /** Remove an instruction from CPU */
674 void removeInst(DynInstPtr inst);
676 /** Remove all instructions younger than the given sequence number. */
677 void removeInstsUntil(const InstSeqNum &seq_num,ThreadID tid);
679 /** Removes the instruction pointed to by the iterator. */
680 inline void squashInstIt(const ListIt inst_it, ThreadID tid);
682 /** Cleans up all instructions on the instruction remove list. */
683 void cleanUpRemovedInsts();
685 /** Cleans up all events on the CPU event remove list. */
686 void cleanUpRemovedEvents();
688 /** Debug function to print all instructions on the list. */
691 /** Forwards an instruction read to the appropriate data
692 * resource (indexes into Resource Pool thru "dataPortIdx")
694 Fault read(DynInstPtr inst, Addr addr,
695 uint8_t *data, unsigned size, unsigned flags);
697 /** Forwards an instruction write. to the appropriate data
698 * resource (indexes into Resource Pool thru "dataPortIdx")
700 Fault write(DynInstPtr inst, uint8_t *data, unsigned size,
701 Addr addr, unsigned flags, uint64_t *write_res = NULL);
704 /** Per-Thread List of all the instructions in flight. */
705 std::list<DynInstPtr> instList[ThePipeline::MaxThreads];
707 /** List of all the instructions that will be removed at the end of this
710 std::queue<ListIt> removeList;
712 bool trapPending[ThePipeline::MaxThreads];
714 /** List of all the cpu event requests that will be removed at the end of
717 std::queue<Event*> cpuEventRemoveList;
719 /** Records if instructions need to be removed this cycle due to
720 * being retired or squashed.
722 bool removeInstsThisCycle;
724 /** True if there is non-speculative Inst Active In Pipeline. Lets any
725 * execution unit know, NOT to execute while the instruction is active.
727 bool nonSpecInstActive[ThePipeline::MaxThreads];
729 /** Instruction Seq. Num of current non-speculative instruction. */
730 InstSeqNum nonSpecSeqNum[ThePipeline::MaxThreads];
732 /** Instruction Seq. Num of last instruction squashed in pipeline */
733 InstSeqNum squashSeqNum[ThePipeline::MaxThreads];
735 /** Last Cycle that the CPU squashed instruction end. */
736 Tick lastSquashCycle[ThePipeline::MaxThreads];
738 std::list<ThreadID> fetchPriorityList;
741 /** Active Threads List */
742 std::list<ThreadID> activeThreads;
744 /** Ready Threads List */
745 std::list<ThreadID> readyThreads;
747 /** Suspended Threads List */
748 std::list<ThreadID> suspendedThreads;
750 /** Halted Threads List */
751 std::list<ThreadID> haltedThreads;
753 /** Thread Status Functions */
754 bool isThreadActive(ThreadID tid);
755 bool isThreadReady(ThreadID tid);
756 bool isThreadSuspended(ThreadID tid);
759 /** The activity recorder; used to tell if the CPU has any
760 * activity remaining or if it can go to idle and deschedule
763 ActivityRecorder activityRec;
766 /** Number of Active Threads in the CPU */
767 ThreadID numActiveThreads() { return activeThreads.size(); }
769 /** Thread id of active thread
770 * Only used for SwitchOnCacheMiss model.
771 * Assumes only 1 thread active
773 ThreadID activeThreadId()
775 if (numActiveThreads() > 0)
776 return activeThreads.front();
778 return InvalidThreadID;
782 /** Records that there was time buffer activity this cycle. */
783 void activityThisCycle() { activityRec.activity(); }
785 /** Changes a stage's status to active within the activity recorder. */
786 void activateStage(const int idx)
787 { activityRec.activateStage(idx); }
789 /** Changes a stage's status to inactive within the activity recorder. */
790 void deactivateStage(const int idx)
791 { activityRec.deactivateStage(idx); }
793 /** Wakes the CPU, rescheduling the CPU if it's not already active. */
796 virtual void wakeup();
798 /* LL/SC debug functionality
799 unsigned stCondFails;
801 unsigned readStCondFailures()
802 { return stCondFails; }
804 unsigned setStCondFailures(unsigned st_fails)
805 { return stCondFails = st_fails; }
808 /** Returns a pointer to a thread context. */
809 ThreadContext *tcBase(ThreadID tid = 0)
811 return thread[tid]->getTC();
814 /** Count the Total Instructions Committed in the CPU. */
815 virtual Counter totalInsts() const
819 for (ThreadID tid = 0; tid < (ThreadID)thread.size(); tid++)
820 total += thread[tid]->numInst;
825 /** Count the Total Ops Committed in the CPU. */
826 virtual Counter totalOps() const
830 for (ThreadID tid = 0; tid < (ThreadID)thread.size(); tid++)
831 total += thread[tid]->numOp;
836 /** Pointer to the system. */
839 /** The global sequence number counter. */
840 InstSeqNum globalSeqNum[ThePipeline::MaxThreads];
843 /** The global event number counter. */
844 InstSeqNum cpuEventNum;
846 /** Number of resource requests active in CPU **/
847 unsigned resReqCount;
852 /** Temporary fix for the lock flag, works in the UP case. */
855 /** Counter of how many stages have completed draining */
858 /** Pointers to all of the threads in the CPU. */
859 std::vector<Thread *> thread;
861 /** Per-Stage Instruction Tracing */
864 /** The cycle that the CPU was last running, used for statistics. */
865 Tick lastRunningCycle;
867 void updateContextSwitchStats();
868 unsigned instsPerSwitch;
869 Stats::Average instsPerCtxtSwitch;
870 Stats::Scalar numCtxtSwitches;
872 /** Update Thread , used for statistic purposes*/
873 inline void tickThreadStats();
875 /** Per-Thread Tick */
876 Stats::Vector threadCycles;
879 Stats::Scalar smtCycles;
881 /** Stat for total number of times the CPU is descheduled. */
882 Stats::Scalar timesIdled;
884 /** Stat for total number of cycles the CPU spends descheduled or no
887 Stats::Scalar idleCycles;
889 /** Stat for total number of cycles the CPU is active. */
890 Stats::Scalar runCycles;
892 /** Percentage of cycles a stage was active */
893 Stats::Formula activity;
895 /** Instruction Mix Stats */
896 Stats::Scalar comLoads;
897 Stats::Scalar comStores;
898 Stats::Scalar comBranches;
899 Stats::Scalar comNops;
900 Stats::Scalar comNonSpec;
901 Stats::Scalar comInts;
902 Stats::Scalar comFloats;
904 /** Stat for the number of committed instructions per thread. */
905 Stats::Vector committedInsts;
907 /** Stat for the number of committed ops per thread. */
908 Stats::Vector committedOps;
910 /** Stat for the number of committed instructions per thread. */
911 Stats::Vector smtCommittedInsts;
913 /** Stat for the total number of committed instructions. */
914 Stats::Scalar totalCommittedInsts;
916 /** Stat for the CPI per thread. */
919 /** Stat for the SMT-CPI per thread. */
920 Stats::Formula smtCpi;
922 /** Stat for the total CPI. */
923 Stats::Formula totalCpi;
925 /** Stat for the IPC per thread. */
928 /** Stat for the total IPC. */
929 Stats::Formula smtIpc;
931 /** Stat for the total IPC. */
932 Stats::Formula totalIpc;
935 #endif // __CPU_O3_CPU_HH__