gem5  v21.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cpu.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012, 2014, 2016, 2017, 2019-2020 ARM Limited
3  * Copyright (c) 2013 Advanced Micro Devices, Inc.
4  * All rights reserved
5  *
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.
14  *
15  * Copyright (c) 2004-2006 The Regents of The University of Michigan
16  * Copyright (c) 2011 Regents of the University of California
17  * All rights reserved.
18  *
19  * Redistribution and use in source and binary forms, with or without
20  * modification, are permitted provided that the following conditions are
21  * met: redistributions of source code must retain the above copyright
22  * notice, this list of conditions and the following disclaimer;
23  * redistributions in binary form must reproduce the above copyright
24  * notice, this list of conditions and the following disclaimer in the
25  * documentation and/or other materials provided with the distribution;
26  * neither the name of the copyright holders nor the names of its
27  * contributors may be used to endorse or promote products derived from
28  * this software without specific prior written permission.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  */
42 
43 #include "cpu/o3/cpu.hh"
44 
45 #include "arch/generic/traits.hh"
46 #include "config/the_isa.hh"
47 #include "cpu/activity.hh"
48 #include "cpu/checker/cpu.hh"
50 #include "cpu/o3/isa_specific.hh"
51 #include "cpu/o3/thread_context.hh"
52 #include "cpu/simple_thread.hh"
53 #include "cpu/thread_context.hh"
54 #include "debug/Activity.hh"
55 #include "debug/Drain.hh"
56 #include "debug/O3CPU.hh"
57 #include "debug/Quiesce.hh"
58 #include "enums/MemoryMode.hh"
59 #include "sim/core.hh"
60 #include "sim/full_system.hh"
61 #include "sim/process.hh"
62 #include "sim/stat_control.hh"
63 #include "sim/system.hh"
64 
65 struct BaseCPUParams;
66 
67 BaseO3CPU::BaseO3CPU(const BaseCPUParams &params)
68  : BaseCPU(params)
69 {
70 }
71 
72 template <class Impl>
73 FullO3CPU<Impl>::FullO3CPU(const DerivO3CPUParams &params)
74  : BaseO3CPU(params),
75  mmu(params.mmu),
76  tickEvent([this]{ tick(); }, "FullO3CPU tick",
77  false, Event::CPU_Tick_Pri),
78  threadExitEvent([this]{ exitThreads(); }, "FullO3CPU exit threads",
79  false, Event::CPU_Exit_Pri),
80 #ifndef NDEBUG
81  instcount(0),
82 #endif
83  removeInstsThisCycle(false),
84  fetch(this, params),
85  decode(this, params),
86  rename(this, params),
87  iew(this, params),
88  commit(this, params),
89 
90  /* It is mandatory that all SMT threads use the same renaming mode as
91  * they are sharing registers and rename */
92  vecMode(RenameMode<TheISA::ISA>::init(params.isa[0])),
93  regFile(params.numPhysIntRegs,
94  params.numPhysFloatRegs,
95  params.numPhysVecRegs,
96  params.numPhysVecPredRegs,
97  params.numPhysCCRegs,
98  vecMode),
99 
100  freeList(name() + ".freelist", &regFile),
101 
102  rob(this, params),
103 
104  scoreboard(name() + ".scoreboard",
105  regFile.totalNumPhysRegs()),
106 
107  isa(numThreads, NULL),
108 
109  timeBuffer(params.backComSize, params.forwardComSize),
110  fetchQueue(params.backComSize, params.forwardComSize),
111  decodeQueue(params.backComSize, params.forwardComSize),
112  renameQueue(params.backComSize, params.forwardComSize),
113  iewQueue(params.backComSize, params.forwardComSize),
114  activityRec(name(), NumStages,
115  params.backComSize + params.forwardComSize,
116  params.activity),
117 
118  globalSeqNum(1),
119  system(params.system),
120  lastRunningCycle(curCycle()),
121  cpuStats(this)
122 {
123  fatal_if(FullSystem && params.numThreads > 1,
124  "SMT is not supported in O3 in full system mode currently.");
125 
126  fatal_if(!FullSystem && params.numThreads < params.workload.size(),
127  "More workload items (%d) than threads (%d) on CPU %s.",
128  params.workload.size(), params.numThreads, name());
129 
130  if (!params.switched_out) {
131  _status = Running;
132  } else {
133  _status = SwitchedOut;
134  }
135 
136  if (params.checker) {
137  BaseCPU *temp_checker = params.checker;
138  checker = dynamic_cast<Checker<Impl> *>(temp_checker);
139  checker->setIcachePort(&this->fetch.getInstPort());
140  checker->setSystem(params.system);
141  } else {
142  checker = NULL;
143  }
144 
145  if (!FullSystem) {
146  thread.resize(numThreads);
147  tids.resize(numThreads);
148  }
149 
150  // The stages also need their CPU pointer setup. However this
151  // must be done at the upper level CPU because they have pointers
152  // to the upper level CPU, and not this FullO3CPU.
153 
154  // Set up Pointers to the activeThreads list for each stage
155  fetch.setActiveThreads(&activeThreads);
156  decode.setActiveThreads(&activeThreads);
157  rename.setActiveThreads(&activeThreads);
158  iew.setActiveThreads(&activeThreads);
159  commit.setActiveThreads(&activeThreads);
160 
161  // Give each of the stages the time buffer they will use.
162  fetch.setTimeBuffer(&timeBuffer);
163  decode.setTimeBuffer(&timeBuffer);
164  rename.setTimeBuffer(&timeBuffer);
165  iew.setTimeBuffer(&timeBuffer);
166  commit.setTimeBuffer(&timeBuffer);
167 
168  // Also setup each of the stages' queues.
169  fetch.setFetchQueue(&fetchQueue);
170  decode.setFetchQueue(&fetchQueue);
171  commit.setFetchQueue(&fetchQueue);
172  decode.setDecodeQueue(&decodeQueue);
173  rename.setDecodeQueue(&decodeQueue);
174  rename.setRenameQueue(&renameQueue);
175  iew.setRenameQueue(&renameQueue);
176  iew.setIEWQueue(&iewQueue);
177  commit.setIEWQueue(&iewQueue);
178  commit.setRenameQueue(&renameQueue);
179 
180  commit.setIEWStage(&iew);
181  rename.setIEWStage(&iew);
182  rename.setCommitStage(&commit);
183 
184  ThreadID active_threads;
185  if (FullSystem) {
186  active_threads = 1;
187  } else {
188  active_threads = params.workload.size();
189 
190  if (active_threads > Impl::MaxThreads) {
191  panic("Workload Size too large. Increase the 'MaxThreads' "
192  "constant in your O3CPU impl. file (e.g. o3/alpha/impl.hh) "
193  "or edit your workload size.");
194  }
195  }
196 
197  //Make Sure That this a Valid Architeture
198  assert(params.numPhysIntRegs >= numThreads * TheISA::NumIntRegs);
199  assert(params.numPhysFloatRegs >= numThreads * TheISA::NumFloatRegs);
200  assert(params.numPhysVecRegs >= numThreads * TheISA::NumVecRegs);
201  assert(params.numPhysVecPredRegs >= numThreads * TheISA::NumVecPredRegs);
202  assert(params.numPhysCCRegs >= numThreads * TheISA::NumCCRegs);
203 
204  rename.setScoreboard(&scoreboard);
205  iew.setScoreboard(&scoreboard);
206 
207  // Setup the rename map for whichever stages need it.
208  for (ThreadID tid = 0; tid < numThreads; tid++) {
209  isa[tid] = dynamic_cast<TheISA::ISA *>(params.isa[tid]);
210  assert(isa[tid]);
211  assert(RenameMode<TheISA::ISA>::equalsInit(isa[tid], isa[0]));
212 
213  // Only Alpha has an FP zero register, so for other ISAs we
214  // use an invalid FP register index to avoid special treatment
215  // of any valid FP reg.
216  RegIndex invalidFPReg = TheISA::NumFloatRegs + 1;
217 
218  commitRenameMap[tid].init(&regFile, TheISA::ZeroReg, invalidFPReg,
219  &freeList, vecMode);
220 
221  renameMap[tid].init(&regFile, TheISA::ZeroReg, invalidFPReg,
222  &freeList, vecMode);
223  }
224 
225  // Initialize rename map to assign physical registers to the
226  // architectural registers for active threads only.
227  for (ThreadID tid = 0; tid < active_threads; tid++) {
228  for (RegIndex ridx = 0; ridx < TheISA::NumIntRegs; ++ridx) {
229  // Note that we can't use the rename() method because we don't
230  // want special treatment for the zero register at this point
231  PhysRegIdPtr phys_reg = freeList.getIntReg();
232  renameMap[tid].setEntry(RegId(IntRegClass, ridx), phys_reg);
233  commitRenameMap[tid].setEntry(RegId(IntRegClass, ridx), phys_reg);
234  }
235 
236  for (RegIndex ridx = 0; ridx < TheISA::NumFloatRegs; ++ridx) {
237  PhysRegIdPtr phys_reg = freeList.getFloatReg();
238  renameMap[tid].setEntry(RegId(FloatRegClass, ridx), phys_reg);
239  commitRenameMap[tid].setEntry(
240  RegId(FloatRegClass, ridx), phys_reg);
241  }
242 
243  /* Here we need two 'interfaces' the 'whole register' and the
244  * 'register element'. At any point only one of them will be
245  * active. */
246  if (vecMode == Enums::Full) {
247  /* Initialize the full-vector interface */
248  for (RegIndex ridx = 0; ridx < TheISA::NumVecRegs; ++ridx) {
249  RegId rid = RegId(VecRegClass, ridx);
250  PhysRegIdPtr phys_reg = freeList.getVecReg();
251  renameMap[tid].setEntry(rid, phys_reg);
252  commitRenameMap[tid].setEntry(rid, phys_reg);
253  }
254  } else {
255  /* Initialize the vector-element interface */
256  for (RegIndex ridx = 0; ridx < TheISA::NumVecRegs; ++ridx) {
257  for (ElemIndex ldx = 0; ldx < TheISA::NumVecElemPerVecReg;
258  ++ldx) {
259  RegId lrid = RegId(VecElemClass, ridx, ldx);
260  PhysRegIdPtr phys_elem = freeList.getVecElem();
261  renameMap[tid].setEntry(lrid, phys_elem);
262  commitRenameMap[tid].setEntry(lrid, phys_elem);
263  }
264  }
265  }
266 
267  for (RegIndex ridx = 0; ridx < TheISA::NumVecPredRegs; ++ridx) {
268  PhysRegIdPtr phys_reg = freeList.getVecPredReg();
269  renameMap[tid].setEntry(RegId(VecPredRegClass, ridx), phys_reg);
270  commitRenameMap[tid].setEntry(
271  RegId(VecPredRegClass, ridx), phys_reg);
272  }
273 
274  for (RegIndex ridx = 0; ridx < TheISA::NumCCRegs; ++ridx) {
275  PhysRegIdPtr phys_reg = freeList.getCCReg();
276  renameMap[tid].setEntry(RegId(CCRegClass, ridx), phys_reg);
277  commitRenameMap[tid].setEntry(RegId(CCRegClass, ridx), phys_reg);
278  }
279  }
280 
281  rename.setRenameMap(renameMap);
282  commit.setRenameMap(commitRenameMap);
283  rename.setFreeList(&freeList);
284 
285  // Setup the ROB for whichever stages need it.
286  commit.setROB(&rob);
287 
288  lastActivatedCycle = 0;
289 
290  DPRINTF(O3CPU, "Creating O3CPU object.\n");
291 
292  // Setup any thread state.
293  this->thread.resize(this->numThreads);
294 
295  for (ThreadID tid = 0; tid < this->numThreads; ++tid) {
296  if (FullSystem) {
297  // SMT is not supported in FS mode yet.
298  assert(this->numThreads == 1);
299  this->thread[tid] = new Thread(this, 0, NULL);
300  } else {
301  if (tid < params.workload.size()) {
302  DPRINTF(O3CPU, "Workload[%i] process is %#x",
303  tid, this->thread[tid]);
304  this->thread[tid] = new typename FullO3CPU<Impl>::Thread(
305  (typename Impl::O3CPU *)(this),
306  tid, params.workload[tid]);
307 
308  //usedTids[tid] = true;
309  //threadMap[tid] = tid;
310  } else {
311  //Allocate Empty thread so M5 can use later
312  //when scheduling threads to CPU
313  Process* dummy_proc = NULL;
314 
315  this->thread[tid] = new typename FullO3CPU<Impl>::Thread(
316  (typename Impl::O3CPU *)(this),
317  tid, dummy_proc);
318  //usedTids[tid] = false;
319  }
320  }
321 
322  ThreadContext *tc;
323 
324  // Setup the TC that will serve as the interface to the threads/CPU.
326 
327  tc = o3_tc;
328 
329  // If we're using a checker, then the TC should be the
330  // CheckerThreadContext.
331  if (params.checker) {
333  o3_tc, this->checker);
334  }
335 
336  o3_tc->cpu = (typename Impl::O3CPU *)(this);
337  assert(o3_tc->cpu);
338  o3_tc->thread = this->thread[tid];
339 
340  // Give the thread the TC.
341  this->thread[tid]->tc = tc;
342 
343  // Add the TC to the CPU's list of TC's.
344  this->threadContexts.push_back(tc);
345  }
346 
347  // FullO3CPU always requires an interrupt controller.
348  if (!params.switched_out && interrupts.empty()) {
349  fatal("FullO3CPU %s has no interrupt controller.\n"
350  "Ensure createInterruptController() is called.\n", name());
351  }
352 
353  for (ThreadID tid = 0; tid < this->numThreads; tid++)
354  this->thread[tid]->setFuncExeInst(0);
355 }
356 
357 template <class Impl>
359 {
360 }
361 
362 template <class Impl>
363 void
365 {
367 
368  ppInstAccessComplete = new ProbePointArg<PacketPtr>(getProbeManager(), "InstAccessComplete");
369  ppDataAccessComplete = new ProbePointArg<std::pair<DynInstPtr, PacketPtr> >(getProbeManager(), "DataAccessComplete");
370 
371  fetch.regProbePoints();
372  rename.regProbePoints();
373  iew.regProbePoints();
374  commit.regProbePoints();
375 }
376 
377 template <class Impl>
380  : Stats::Group(cpu),
381  ADD_STAT(timesIdled, UNIT_COUNT,
382  "Number of times that the entire CPU went into an idle state "
383  "and unscheduled itself"),
384  ADD_STAT(idleCycles, UNIT_CYCLE,
385  "Total number of cycles that the CPU has spent unscheduled due "
386  "to idling"),
388  "Total number of cycles that CPU has spent quiesced or waiting "
389  "for an interrupt"),
390  ADD_STAT(committedInsts, UNIT_COUNT, "Number of Instructions Simulated"),
391  ADD_STAT(committedOps, UNIT_COUNT,
392  "Number of Ops (including micro ops) Simulated"),
393  ADD_STAT(cpi, UNIT_RATE(Stats::Units::Cycle, Stats::Units::Count),
394  "CPI: Cycles Per Instruction"),
395  ADD_STAT(totalCpi, UNIT_RATE(Stats::Units::Cycle, Stats::Units::Count),
396  "CPI: Total CPI of All Threads"),
397  ADD_STAT(ipc, UNIT_RATE(Stats::Units::Count, Stats::Units::Cycle),
398  "IPC: Instructions Per Cycle"),
399  ADD_STAT(totalIpc, UNIT_RATE(Stats::Units::Count, Stats::Units::Cycle),
400  "IPC: Total IPC of All Threads"),
401  ADD_STAT(intRegfileReads, UNIT_COUNT, "Number of integer regfile reads"),
402  ADD_STAT(intRegfileWrites, UNIT_COUNT,
403  "Number of integer regfile writes"),
404  ADD_STAT(fpRegfileReads, UNIT_COUNT, "Number of floating regfile reads"),
405  ADD_STAT(fpRegfileWrites, UNIT_COUNT,
406  "Number of floating regfile writes"),
407  ADD_STAT(vecRegfileReads, UNIT_COUNT, "number of vector regfile reads"),
408  ADD_STAT(vecRegfileWrites, UNIT_COUNT,
409  "number of vector regfile writes"),
410  ADD_STAT(vecPredRegfileReads, UNIT_COUNT,
411  "number of predicate regfile reads"),
412  ADD_STAT(vecPredRegfileWrites, UNIT_COUNT,
413  "number of predicate regfile writes"),
414  ADD_STAT(ccRegfileReads, UNIT_COUNT, "number of cc regfile reads"),
415  ADD_STAT(ccRegfileWrites, UNIT_COUNT, "number of cc regfile writes"),
416  ADD_STAT(miscRegfileReads, UNIT_COUNT, "number of misc regfile reads"),
417  ADD_STAT(miscRegfileWrites, UNIT_COUNT, "number of misc regfile writes")
418 {
419  // Register any of the O3CPU's stats here.
420  timesIdled
421  .prereq(timesIdled);
422 
423  idleCycles
424  .prereq(idleCycles);
425 
428 
429  // Number of Instructions simulated
430  // --------------------------------
431  // Should probably be in Base CPU but need templated
432  // MaxThreads so put in here instead
434  .init(cpu->numThreads)
436 
438  .init(cpu->numThreads)
440 
441  cpi
442  .precision(6);
444 
445  totalCpi
446  .precision(6);
448 
449  ipc
450  .precision(6);
452 
453  totalIpc
454  .precision(6);
456 
459 
462 
465 
468 
471 
474 
477 
480 
483 
486 
489 
492 }
493 
494 template <class Impl>
495 void
497 {
498  DPRINTF(O3CPU, "\n\nFullO3CPU: Ticking main, FullO3CPU.\n");
499  assert(!switchedOut());
500  assert(drainState() != DrainState::Drained);
501 
504 
505 // activity = false;
506 
507  //Tick each of the stages
508  fetch.tick();
509 
510  decode.tick();
511 
512  rename.tick();
513 
514  iew.tick();
515 
516  commit.tick();
517 
518  // Now advance the time buffers
520 
524  iewQueue.advance();
525 
527 
528  if (removeInstsThisCycle) {
530  }
531 
532  if (!tickEvent.scheduled()) {
533  if (_status == SwitchedOut) {
534  DPRINTF(O3CPU, "Switched out!\n");
535  // increment stat
537  } else if (!activityRec.active() || _status == Idle) {
538  DPRINTF(O3CPU, "Idle!\n");
541  } else {
543  DPRINTF(O3CPU, "Scheduling next tick!\n");
544  }
545  }
546 
547  if (!FullSystem)
549 
550  tryDrain();
551 }
552 
553 template <class Impl>
554 void
556 {
557  BaseCPU::init();
558 
559  for (ThreadID tid = 0; tid < numThreads; ++tid) {
560  // Set noSquashFromTC so that the CPU doesn't squash when initially
561  // setting up registers.
562  thread[tid]->noSquashFromTC = true;
563  // Initialise the ThreadContext's memory proxies
564  thread[tid]->initMemProxies(thread[tid]->getTC());
565  }
566 
567  // Clear noSquashFromTC.
568  for (int tid = 0; tid < numThreads; ++tid)
569  thread[tid]->noSquashFromTC = false;
570 
571  commit.setThreads(thread);
572 }
573 
574 template <class Impl>
575 void
577 {
579 
580  fetch.startupStage();
581  decode.startupStage();
582  iew.startupStage();
583  rename.startupStage();
584  commit.startupStage();
585 }
586 
587 template <class Impl>
588 void
590 {
592  std::find(activeThreads.begin(), activeThreads.end(), tid);
593 
594  DPRINTF(O3CPU, "[tid:%i] Calling activate thread.\n", tid);
595  assert(!switchedOut());
596 
597  if (isActive == activeThreads.end()) {
598  DPRINTF(O3CPU, "[tid:%i] Adding to active threads list\n",
599  tid);
600 
601  activeThreads.push_back(tid);
602  }
603 }
604 
605 template <class Impl>
606 void
608 {
609  // hardware transactional memory
610  // shouldn't deactivate thread in the middle of a transaction
611  assert(!commit.executingHtmTransaction(tid));
612 
613  //Remove From Active List, if Active
615  std::find(activeThreads.begin(), activeThreads.end(), tid);
616 
617  DPRINTF(O3CPU, "[tid:%i] Calling deactivate thread.\n", tid);
618  assert(!switchedOut());
619 
620  if (thread_it != activeThreads.end()) {
621  DPRINTF(O3CPU,"[tid:%i] Removing from active threads list\n",
622  tid);
623  activeThreads.erase(thread_it);
624  }
625 
626  fetch.deactivateThread(tid);
627  commit.deactivateThread(tid);
628 }
629 
630 template <class Impl>
631 Counter
633 {
634  Counter total(0);
635 
636  ThreadID size = thread.size();
637  for (ThreadID i = 0; i < size; i++)
638  total += thread[i]->numInst;
639 
640  return total;
641 }
642 
643 template <class Impl>
644 Counter
646 {
647  Counter total(0);
648 
649  ThreadID size = thread.size();
650  for (ThreadID i = 0; i < size; i++)
651  total += thread[i]->numOp;
652 
653  return total;
654 }
655 
656 template <class Impl>
657 void
659 {
660  assert(!switchedOut());
661 
662  // Needs to set each stage to running as well.
663  activateThread(tid);
664 
665  // We don't want to wake the CPU if it is drained. In that case,
666  // we just want to flag the thread as active and schedule the tick
667  // event from drainResume() instead.
669  return;
670 
671  // If we are time 0 or if the last activation time is in the past,
672  // schedule the next tick and wake up the fetch unit
675 
676  // Be sure to signal that there's some activity so the CPU doesn't
677  // deschedule itself.
679  fetch.wakeFromQuiesce();
680 
681  Cycles cycles(curCycle() - lastRunningCycle);
682  // @todo: This is an oddity that is only here to match the stats
683  if (cycles != 0)
684  --cycles;
685  cpuStats.quiesceCycles += cycles;
686 
688 
689  _status = Running;
690 
692  }
693 }
694 
695 template <class Impl>
696 void
698 {
699  DPRINTF(O3CPU,"[tid:%i] Suspending Thread Context.\n", tid);
700  assert(!switchedOut());
701 
702  deactivateThread(tid);
703 
704  // If this was the last thread then unschedule the tick event.
705  if (activeThreads.size() == 0) {
708  _status = Idle;
709  }
710 
711  DPRINTF(Quiesce, "Suspending Context\n");
712 
714 }
715 
716 template <class Impl>
717 void
719 {
720  //For now, this is the same as deallocate
721  DPRINTF(O3CPU,"[tid:%i] Halt Context called. Deallocating\n", tid);
722  assert(!switchedOut());
723 
724  deactivateThread(tid);
725  removeThread(tid);
726 
727  // If this was the last thread then unschedule the tick event.
728  if (activeThreads.size() == 0) {
729  if (tickEvent.scheduled())
730  {
732  }
734  _status = Idle;
735  }
737 }
738 
739 template <class Impl>
740 void
742 {
743  DPRINTF(O3CPU,"[tid:%i] Initializing thread into CPU");
744  // Will change now that the PC and thread state is internal to the CPU
745  // and not in the ThreadContext.
746  ThreadContext *src_tc;
747  if (FullSystem)
748  src_tc = system->threads[tid];
749  else
750  src_tc = tcBase(tid);
751 
752  //Bind Int Regs to Rename Map
753 
754  for (RegId reg_id(IntRegClass, 0); reg_id.index() < TheISA::NumIntRegs;
755  reg_id.index()++) {
756  PhysRegIdPtr phys_reg = freeList.getIntReg();
757  renameMap[tid].setEntry(reg_id, phys_reg);
758  scoreboard.setReg(phys_reg);
759  }
760 
761  //Bind Float Regs to Rename Map
762  for (RegId reg_id(FloatRegClass, 0); reg_id.index() < TheISA::NumFloatRegs;
763  reg_id.index()++) {
764  PhysRegIdPtr phys_reg = freeList.getFloatReg();
765  renameMap[tid].setEntry(reg_id, phys_reg);
766  scoreboard.setReg(phys_reg);
767  }
768 
769  //Bind condition-code Regs to Rename Map
770  for (RegId reg_id(CCRegClass, 0); reg_id.index() < TheISA::NumCCRegs;
771  reg_id.index()++) {
772  PhysRegIdPtr phys_reg = freeList.getCCReg();
773  renameMap[tid].setEntry(reg_id, phys_reg);
774  scoreboard.setReg(phys_reg);
775  }
776 
777  //Copy Thread Data Into RegFile
778  //this->copyFromTC(tid);
779 
780  //Set PC/NPC/NNPC
781  pcState(src_tc->pcState(), tid);
782 
784 
785  activateContext(tid);
786 
787  //Reset ROB/IQ/LSQ Entries
788  commit.rob->resetEntries();
789 }
790 
791 template <class Impl>
792 void
794 {
795  DPRINTF(O3CPU,"[tid:%i] Removing thread context from CPU.\n", tid);
796 
797  // Copy Thread Data From RegFile
798  // If thread is suspended, it might be re-allocated
799  // this->copyToTC(tid);
800 
801 
802  // @todo: 2-27-2008: Fix how we free up rename mappings
803  // here to alleviate the case for double-freeing registers
804  // in SMT workloads.
805 
806  // clear all thread-specific states in each stage of the pipeline
807  // since this thread is going to be completely removed from the CPU
808  commit.clearStates(tid);
809  fetch.clearStates(tid);
810  decode.clearStates(tid);
811  rename.clearStates(tid);
812  iew.clearStates(tid);
813 
814  // Flush out any old data from the time buffers.
815  for (int i = 0; i < timeBuffer.getSize(); ++i) {
820  iewQueue.advance();
821  }
822 
823  // at this step, all instructions in the pipeline should be already
824  // either committed successfully or squashed. All thread-specific
825  // queues in the pipeline must be empty.
826  assert(iew.instQueue.getCount(tid) == 0);
827  assert(iew.ldstQueue.getCount(tid) == 0);
828  assert(commit.rob->isEmpty(tid));
829 
830  // Reset ROB/IQ/LSQ Entries
831 
832  // Commented out for now. This should be possible to do by
833  // telling all the pipeline stages to drain first, and then
834  // checking until the drain completes. Once the pipeline is
835  // drained, call resetEntries(). - 10-09-06 ktlim
836 /*
837  if (activeThreads.size() >= 1) {
838  commit.rob->resetEntries();
839  iew.resetEntries();
840  }
841 */
842 }
843 
844 template <class Impl>
845 void
847 {
848  if (vecMode == Enums::Elem) {
849  for (auto v = 0; v < TheISA::NumVecRegs; v++)
850  for (auto e = 0; e < TheISA::NumVecElemPerVecReg; e++)
852  commitRenameMap[tid].lookup(
853  RegId(VecElemClass, v, e)
854  )
855  );
856  } else if (vecMode == Enums::Full) {
857  for (auto v = 0; v < TheISA::NumVecRegs; v++)
859  commitRenameMap[tid].lookup(
861  )
862  );
863  }
864 }
865 
866 template <class Impl>
867 void
869 {
870  auto pc = this->pcState(tid);
871 
872  // new_mode is the new vector renaming mode
873  auto new_mode = RenameMode<TheISA::ISA>::mode(pc);
874 
875  // We update vecMode only if there has been a change
876  if (new_mode != vecMode) {
877  vecMode = new_mode;
878 
879  renameMap[tid].switchMode(vecMode);
880  commitRenameMap[tid].switchMode(vecMode);
881  renameMap[tid].switchFreeList(freelist);
882  setVectorsAsReady(tid);
883  }
884 }
885 
886 template <class Impl>
887 Fault
889 {
890  // Check if there are any outstanding interrupts
891  return this->interrupts[0]->getInterrupt();
892 }
893 
894 template <class Impl>
895 void
897 {
898  // Check for interrupts here. For now can copy the code that
899  // exists within isa_fullsys_traits.hh. Also assume that thread 0
900  // is the one that handles the interrupts.
901  // @todo: Possibly consolidate the interrupt checking code.
902  // @todo: Allow other threads to handle interrupts.
903 
904  assert(interrupt != NoFault);
905  this->interrupts[0]->updateIntrInfo();
906 
907  DPRINTF(O3CPU, "Interrupt %s being handled\n", interrupt->name());
908  this->trap(interrupt, 0, nullptr);
909 }
910 
911 template <class Impl>
912 void
914  const StaticInstPtr &inst)
915 {
916  // Pass the thread's TC into the invoke method.
917  fault->invoke(this->threadContexts[tid], inst);
918 }
919 
920 template <class Impl>
921 void
923 {
924  thread[tid]->serialize(cp);
925 }
926 
927 template <class Impl>
928 void
930 {
931  thread[tid]->unserialize(cp);
932 }
933 
934 template <class Impl>
937 {
938  // Deschedule any power gating event (if any)
940 
941  // If the CPU isn't doing anything, then return immediately.
942  if (switchedOut())
943  return DrainState::Drained;
944 
945  DPRINTF(Drain, "Draining...\n");
946 
947  // We only need to signal a drain to the commit stage as this
948  // initiates squashing controls the draining. Once the commit
949  // stage commits an instruction where it is safe to stop, it'll
950  // squash the rest of the instructions in the pipeline and force
951  // the fetch stage to stall. The pipeline will be drained once all
952  // in-flight instructions have retired.
953  commit.drain();
954 
955  // Wake the CPU and record activity so everything can drain out if
956  // the CPU was not able to immediately drain.
957  if (!isCpuDrained()) {
958  // If a thread is suspended, wake it up so it can be drained
959  for (auto t : threadContexts) {
960  if (t->status() == ThreadContext::Suspended){
961  DPRINTF(Drain, "Currently suspended so activate %i \n",
962  t->threadId());
963  t->activate();
964  // As the thread is now active, change the power state as well
965  activateContext(t->threadId());
966  }
967  }
968 
969  wakeCPU();
971 
972  DPRINTF(Drain, "CPU not drained\n");
973 
974  return DrainState::Draining;
975  } else {
976  DPRINTF(Drain, "CPU is already drained\n");
977  if (tickEvent.scheduled())
979 
980  // Flush out any old data from the time buffers. In
981  // particular, there might be some data in flight from the
982  // fetch stage that isn't visible in any of the CPU buffers we
983  // test in isCpuDrained().
984  for (int i = 0; i < timeBuffer.getSize(); ++i) {
989  iewQueue.advance();
990  }
991 
993  return DrainState::Drained;
994  }
995 }
996 
997 template <class Impl>
998 bool
1000 {
1002  return false;
1003 
1004  if (tickEvent.scheduled())
1006 
1007  DPRINTF(Drain, "CPU done draining, processing drain event\n");
1008  signalDrainDone();
1009 
1010  return true;
1011 }
1012 
1013 template <class Impl>
1014 void
1016 {
1017  assert(isCpuDrained());
1018  fetch.drainSanityCheck();
1019  decode.drainSanityCheck();
1020  rename.drainSanityCheck();
1021  iew.drainSanityCheck();
1022  commit.drainSanityCheck();
1023 }
1024 
1025 template <class Impl>
1026 bool
1028 {
1029  bool drained(true);
1030 
1031  if (!instList.empty() || !removeList.empty()) {
1032  DPRINTF(Drain, "Main CPU structures not drained.\n");
1033  drained = false;
1034  }
1035 
1036  if (!fetch.isDrained()) {
1037  DPRINTF(Drain, "Fetch not drained.\n");
1038  drained = false;
1039  }
1040 
1041  if (!decode.isDrained()) {
1042  DPRINTF(Drain, "Decode not drained.\n");
1043  drained = false;
1044  }
1045 
1046  if (!rename.isDrained()) {
1047  DPRINTF(Drain, "Rename not drained.\n");
1048  drained = false;
1049  }
1050 
1051  if (!iew.isDrained()) {
1052  DPRINTF(Drain, "IEW not drained.\n");
1053  drained = false;
1054  }
1055 
1056  if (!commit.isDrained()) {
1057  DPRINTF(Drain, "Commit not drained.\n");
1058  drained = false;
1059  }
1060 
1061  return drained;
1062 }
1063 
1064 template <class Impl>
1065 void
1067 {
1068  fetch.drainStall(tid);
1069 }
1070 
1071 template <class Impl>
1072 void
1074 {
1075  if (switchedOut())
1076  return;
1077 
1078  DPRINTF(Drain, "Resuming...\n");
1079  verifyMemoryMode();
1080 
1081  fetch.drainResume();
1082  commit.drainResume();
1083 
1084  _status = Idle;
1085  for (ThreadID i = 0; i < thread.size(); i++) {
1086  if (thread[i]->status() == ThreadContext::Active) {
1087  DPRINTF(Drain, "Activating thread: %i\n", i);
1088  activateThread(i);
1089  _status = Running;
1090  }
1091  }
1092 
1093  assert(!tickEvent.scheduled());
1094  if (_status == Running)
1096 
1097  // Reschedule any power gating event (if any)
1099 }
1100 
1101 template <class Impl>
1102 void
1104 {
1105  DPRINTF(O3CPU, "Switching out\n");
1107 
1108  activityRec.reset();
1109 
1110  _status = SwitchedOut;
1111 
1112  if (checker)
1113  checker->switchOut();
1114 }
1115 
1116 template <class Impl>
1117 void
1119 {
1120  BaseCPU::takeOverFrom(oldCPU);
1121 
1122  fetch.takeOverFrom();
1123  decode.takeOverFrom();
1124  rename.takeOverFrom();
1125  iew.takeOverFrom();
1126  commit.takeOverFrom();
1127 
1128  assert(!tickEvent.scheduled());
1129 
1130  FullO3CPU<Impl> *oldO3CPU = dynamic_cast<FullO3CPU<Impl>*>(oldCPU);
1131  if (oldO3CPU)
1132  globalSeqNum = oldO3CPU->globalSeqNum;
1133 
1135  _status = Idle;
1136 }
1137 
1138 template <class Impl>
1139 void
1141 {
1142  if (!system->isTimingMode()) {
1143  fatal("The O3 CPU requires the memory system to be in "
1144  "'timing' mode.\n");
1145  }
1146 }
1147 
1148 template <class Impl>
1149 RegVal
1151 {
1152  return this->isa[tid]->readMiscRegNoEffect(misc_reg);
1153 }
1154 
1155 template <class Impl>
1156 RegVal
1158 {
1160  return this->isa[tid]->readMiscReg(misc_reg);
1161 }
1162 
1163 template <class Impl>
1164 void
1166 {
1167  this->isa[tid]->setMiscRegNoEffect(misc_reg, val);
1168 }
1169 
1170 template <class Impl>
1171 void
1173 {
1175  this->isa[tid]->setMiscReg(misc_reg, val);
1176 }
1177 
1178 template <class Impl>
1179 RegVal
1181 {
1183  return regFile.readIntReg(phys_reg);
1184 }
1185 
1186 template <class Impl>
1187 RegVal
1189 {
1191  return regFile.readFloatReg(phys_reg);
1192 }
1193 
1194 template <class Impl>
1197 {
1199  return regFile.readVecReg(phys_reg);
1200 }
1201 
1202 template <class Impl>
1205 {
1207  return regFile.getWritableVecReg(phys_reg);
1208 }
1209 
1210 template <class Impl>
1211 const TheISA::VecElem&
1213 {
1215  return regFile.readVecElem(phys_reg);
1216 }
1217 
1218 template <class Impl>
1221 {
1223  return regFile.readVecPredReg(phys_reg);
1224 }
1225 
1226 template <class Impl>
1229 {
1231  return regFile.getWritableVecPredReg(phys_reg);
1232 }
1233 
1234 template <class Impl>
1235 RegVal
1237 {
1239  return regFile.readCCReg(phys_reg);
1240 }
1241 
1242 template <class Impl>
1243 void
1245 {
1247  regFile.setIntReg(phys_reg, val);
1248 }
1249 
1250 template <class Impl>
1251 void
1253 {
1255  regFile.setFloatReg(phys_reg, val);
1256 }
1257 
1258 template <class Impl>
1259 void
1262 {
1264  regFile.setVecReg(phys_reg, val);
1265 }
1266 
1267 template <class Impl>
1268 void
1270 {
1272  regFile.setVecElem(phys_reg, val);
1273 }
1274 
1275 template <class Impl>
1276 void
1279 {
1281  regFile.setVecPredReg(phys_reg, val);
1282 }
1283 
1284 template <class Impl>
1285 void
1287 {
1289  regFile.setCCReg(phys_reg, val);
1290 }
1291 
1292 template <class Impl>
1293 RegVal
1295 {
1297  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1298  RegId(IntRegClass, reg_idx));
1299 
1300  return regFile.readIntReg(phys_reg);
1301 }
1302 
1303 template <class Impl>
1304 RegVal
1306 {
1308  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1309  RegId(FloatRegClass, reg_idx));
1310 
1311  return regFile.readFloatReg(phys_reg);
1312 }
1313 
1314 template <class Impl>
1317 {
1318  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1319  RegId(VecRegClass, reg_idx));
1320  return readVecReg(phys_reg);
1321 }
1322 
1323 template <class Impl>
1326 {
1327  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1328  RegId(VecRegClass, reg_idx));
1329  return getWritableVecReg(phys_reg);
1330 }
1331 
1332 template <class Impl>
1333 const TheISA::VecElem&
1335  const RegIndex& reg_idx, const ElemIndex& ldx, ThreadID tid) const
1336 {
1337  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1338  RegId(VecElemClass, reg_idx, ldx));
1339  return readVecElem(phys_reg);
1340 }
1341 
1342 template <class Impl>
1345 {
1346  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1347  RegId(VecPredRegClass, reg_idx));
1348  return readVecPredReg(phys_reg);
1349 }
1350 
1351 template <class Impl>
1354 {
1355  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1356  RegId(VecPredRegClass, reg_idx));
1357  return getWritableVecPredReg(phys_reg);
1358 }
1359 
1360 template <class Impl>
1361 RegVal
1363 {
1365  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1366  RegId(CCRegClass, reg_idx));
1367 
1368  return regFile.readCCReg(phys_reg);
1369 }
1370 
1371 template <class Impl>
1372 void
1374 {
1376  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1377  RegId(IntRegClass, reg_idx));
1378 
1379  regFile.setIntReg(phys_reg, val);
1380 }
1381 
1382 template <class Impl>
1383 void
1385 {
1387  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1388  RegId(FloatRegClass, reg_idx));
1389 
1390  regFile.setFloatReg(phys_reg, val);
1391 }
1392 
1393 template <class Impl>
1394 void
1396  const TheISA::VecRegContainer& val, ThreadID tid)
1397 {
1398  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1399  RegId(VecRegClass, reg_idx));
1400  setVecReg(phys_reg, val);
1401 }
1402 
1403 template <class Impl>
1404 void
1406  const TheISA::VecElem& val, ThreadID tid)
1407 {
1408  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1409  RegId(VecElemClass, reg_idx, ldx));
1410  setVecElem(phys_reg, val);
1411 }
1412 
1413 template <class Impl>
1414 void
1417 {
1418  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1419  RegId(VecPredRegClass, reg_idx));
1420  setVecPredReg(phys_reg, val);
1421 }
1422 
1423 template <class Impl>
1424 void
1426 {
1428  PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
1429  RegId(CCRegClass, reg_idx));
1430 
1431  regFile.setCCReg(phys_reg, val);
1432 }
1433 
1434 template <class Impl>
1437 {
1438  return commit.pcState(tid);
1439 }
1440 
1441 template <class Impl>
1442 void
1444 {
1445  commit.pcState(val, tid);
1446 }
1447 
1448 template <class Impl>
1449 Addr
1451 {
1452  return commit.instAddr(tid);
1453 }
1454 
1455 template <class Impl>
1456 Addr
1458 {
1459  return commit.nextInstAddr(tid);
1460 }
1461 
1462 template <class Impl>
1463 MicroPC
1465 {
1466  return commit.microPC(tid);
1467 }
1468 
1469 template <class Impl>
1470 void
1472 {
1473  this->thread[tid]->noSquashFromTC = true;
1474  this->commit.generateTCEvent(tid);
1475 }
1476 
1477 template <class Impl>
1478 typename FullO3CPU<Impl>::ListIt
1480 {
1481  instList.push_back(inst);
1482 
1483  return --(instList.end());
1484 }
1485 
1486 template <class Impl>
1487 void
1489 {
1490  // Keep an instruction count.
1491  if (!inst->isMicroop() || inst->isLastMicroop()) {
1492  thread[tid]->numInst++;
1493  thread[tid]->threadStats.numInsts++;
1494  cpuStats.committedInsts[tid]++;
1495 
1496  // Check for instruction-count-based events.
1497  thread[tid]->comInstEventQueue.serviceEvents(thread[tid]->numInst);
1498  }
1499  thread[tid]->numOp++;
1500  thread[tid]->threadStats.numOps++;
1501  cpuStats.committedOps[tid]++;
1502 
1503  probeInstCommit(inst->staticInst, inst->instAddr());
1504 }
1505 
1506 template <class Impl>
1507 void
1509 {
1510  DPRINTF(O3CPU, "Removing committed instruction [tid:%i] PC %s "
1511  "[sn:%lli]\n",
1512  inst->threadNumber, inst->pcState(), inst->seqNum);
1513 
1514  removeInstsThisCycle = true;
1515 
1516  // Remove the front instruction.
1517  removeList.push(inst->getInstListIt());
1518 }
1519 
1520 template <class Impl>
1521 void
1523 {
1524  DPRINTF(O3CPU, "Thread %i: Deleting instructions from instruction"
1525  " list.\n", tid);
1526 
1527  ListIt end_it;
1528 
1529  bool rob_empty = false;
1530 
1531  if (instList.empty()) {
1532  return;
1533  } else if (rob.isEmpty(tid)) {
1534  DPRINTF(O3CPU, "ROB is empty, squashing all insts.\n");
1535  end_it = instList.begin();
1536  rob_empty = true;
1537  } else {
1538  end_it = (rob.readTailInst(tid))->getInstListIt();
1539  DPRINTF(O3CPU, "ROB is not empty, squashing insts not in ROB.\n");
1540  }
1541 
1542  removeInstsThisCycle = true;
1543 
1544  ListIt inst_it = instList.end();
1545 
1546  inst_it--;
1547 
1548  // Walk through the instruction list, removing any instructions
1549  // that were inserted after the given instruction iterator, end_it.
1550  while (inst_it != end_it) {
1551  assert(!instList.empty());
1552 
1553  squashInstIt(inst_it, tid);
1554 
1555  inst_it--;
1556  }
1557 
1558  // If the ROB was empty, then we actually need to remove the first
1559  // instruction as well.
1560  if (rob_empty) {
1561  squashInstIt(inst_it, tid);
1562  }
1563 }
1564 
1565 template <class Impl>
1566 void
1568 {
1569  assert(!instList.empty());
1570 
1571  removeInstsThisCycle = true;
1572 
1573  ListIt inst_iter = instList.end();
1574 
1575  inst_iter--;
1576 
1577  DPRINTF(O3CPU, "Deleting instructions from instruction "
1578  "list that are from [tid:%i] and above [sn:%lli] (end=%lli).\n",
1579  tid, seq_num, (*inst_iter)->seqNum);
1580 
1581  while ((*inst_iter)->seqNum > seq_num) {
1582 
1583  bool break_loop = (inst_iter == instList.begin());
1584 
1585  squashInstIt(inst_iter, tid);
1586 
1587  inst_iter--;
1588 
1589  if (break_loop)
1590  break;
1591  }
1592 }
1593 
1594 template <class Impl>
1595 inline void
1597 {
1598  if ((*instIt)->threadNumber == tid) {
1599  DPRINTF(O3CPU, "Squashing instruction, "
1600  "[tid:%i] [sn:%lli] PC %s\n",
1601  (*instIt)->threadNumber,
1602  (*instIt)->seqNum,
1603  (*instIt)->pcState());
1604 
1605  // Mark it as squashed.
1606  (*instIt)->setSquashed();
1607 
1608  // @todo: Formulate a consistent method for deleting
1609  // instructions from the instruction list
1610  // Remove the instruction from the list.
1611  removeList.push(instIt);
1612  }
1613 }
1614 
1615 template <class Impl>
1616 void
1618 {
1619  while (!removeList.empty()) {
1620  DPRINTF(O3CPU, "Removing instruction, "
1621  "[tid:%i] [sn:%lli] PC %s\n",
1622  (*removeList.front())->threadNumber,
1623  (*removeList.front())->seqNum,
1624  (*removeList.front())->pcState());
1625 
1626  instList.erase(removeList.front());
1627 
1628  removeList.pop();
1629  }
1630 
1631  removeInstsThisCycle = false;
1632 }
1633 /*
1634 template <class Impl>
1635 void
1636 FullO3CPU<Impl>::removeAllInsts()
1637 {
1638  instList.clear();
1639 }
1640 */
1641 template <class Impl>
1642 void
1644 {
1645  int num = 0;
1646 
1647  ListIt inst_list_it = instList.begin();
1648 
1649  cprintf("Dumping Instruction List\n");
1650 
1651  while (inst_list_it != instList.end()) {
1652  cprintf("Instruction:%i\nPC:%#x\n[tid:%i]\n[sn:%lli]\nIssued:%i\n"
1653  "Squashed:%i\n\n",
1654  num, (*inst_list_it)->instAddr(), (*inst_list_it)->threadNumber,
1655  (*inst_list_it)->seqNum, (*inst_list_it)->isIssued(),
1656  (*inst_list_it)->isSquashed());
1657  inst_list_it++;
1658  ++num;
1659  }
1660 }
1661 /*
1662 template <class Impl>
1663 void
1664 FullO3CPU<Impl>::wakeDependents(const DynInstPtr &inst)
1665 {
1666  iew.wakeDependents(inst);
1667 }
1668 */
1669 template <class Impl>
1670 void
1672 {
1673  if (activityRec.active() || tickEvent.scheduled()) {
1674  DPRINTF(Activity, "CPU already running.\n");
1675  return;
1676  }
1677 
1678  DPRINTF(Activity, "Waking up CPU\n");
1679 
1680  Cycles cycles(curCycle() - lastRunningCycle);
1681  // @todo: This is an oddity that is only here to match the stats
1682  if (cycles > 1) {
1683  --cycles;
1684  cpuStats.idleCycles += cycles;
1685  baseStats.numCycles += cycles;
1686  }
1687 
1689 }
1690 
1691 template <class Impl>
1692 void
1694 {
1695  if (this->thread[tid]->status() != ThreadContext::Suspended)
1696  return;
1697 
1698  this->wakeCPU();
1699 
1700  DPRINTF(Quiesce, "Suspended Processor woken\n");
1701  this->threadContexts[tid]->activate();
1702 }
1703 
1704 template <class Impl>
1705 ThreadID
1707 {
1708  for (ThreadID tid = 0; tid < numThreads; tid++) {
1709  if (!tids[tid]) {
1710  tids[tid] = true;
1711  return tid;
1712  }
1713  }
1714 
1715  return InvalidThreadID;
1716 }
1717 
1718 template <class Impl>
1719 void
1721 {
1722  if (activeThreads.size() > 1) {
1723  //DEFAULT TO ROUND ROBIN SCHEME
1724  //e.g. Move highest priority to end of thread list
1725  std::list<ThreadID>::iterator list_begin = activeThreads.begin();
1726 
1727  unsigned high_thread = *list_begin;
1728 
1729  activeThreads.erase(list_begin);
1730 
1731  activeThreads.push_back(high_thread);
1732  }
1733 }
1734 
1735 template <class Impl>
1736 void
1738 {
1739  DPRINTF(O3CPU, "Thread %d is inserted to exitingThreads list\n", tid);
1740 
1741  // the thread trying to exit can't be already halted
1742  assert(tcBase(tid)->status() != ThreadContext::Halted);
1743 
1744  // make sure the thread has not been added to the list yet
1745  assert(exitingThreads.count(tid) == 0);
1746 
1747  // add the thread to exitingThreads list to mark that this thread is
1748  // trying to exit. The boolean value in the pair denotes if a thread is
1749  // ready to exit. The thread is not ready to exit until the corresponding
1750  // exit trap event is processed in the future. Until then, it'll be still
1751  // an active thread that is trying to exit.
1752  exitingThreads.emplace(std::make_pair(tid, false));
1753 }
1754 
1755 template <class Impl>
1756 bool
1758 {
1759  return exitingThreads.count(tid) == 1;
1760 }
1761 
1762 template <class Impl>
1763 void
1765 {
1766  assert(exitingThreads.count(tid) == 1);
1767 
1768  // exit trap event has been processed. Now, the thread is ready to exit
1769  // and be removed from the CPU.
1770  exitingThreads[tid] = true;
1771 
1772  // we schedule a threadExitEvent in the next cycle to properly clean
1773  // up the thread's states in the pipeline. threadExitEvent has lower
1774  // priority than tickEvent, so the cleanup will happen at the very end
1775  // of the next cycle after all pipeline stages complete their operations.
1776  // We want all stages to complete squashing instructions before doing
1777  // the cleanup.
1778  if (!threadExitEvent.scheduled()) {
1780  }
1781 }
1782 
1783 template <class Impl>
1784 void
1786 {
1787  // there must be at least one thread trying to exit
1788  assert(exitingThreads.size() > 0);
1789 
1790  // terminate all threads that are ready to exit
1791  auto it = exitingThreads.begin();
1792  while (it != exitingThreads.end()) {
1793  ThreadID thread_id = it->first;
1794  bool readyToExit = it->second;
1795 
1796  if (readyToExit) {
1797  DPRINTF(O3CPU, "Exiting thread %d\n", thread_id);
1798  haltContext(thread_id);
1799  tcBase(thread_id)->setStatus(ThreadContext::Halted);
1800  it = exitingThreads.erase(it);
1801  } else {
1802  it++;
1803  }
1804  }
1805 }
1806 
1807 template <class Impl>
1808 void
1810  HtmFailureFaultCause cause)
1811 {
1812  const Addr addr = 0x0ul;
1813  const int size = 8;
1814  const Request::Flags flags =
1816 
1817  // O3-specific actions
1818  this->iew.ldstQueue.resetHtmStartsStops(tid);
1819  this->commit.resetHtmStartsStops(tid);
1820 
1821  // notify l1 d-cache (ruby) that core has aborted transaction
1822  RequestPtr req =
1823  std::make_shared<Request>(addr, size, flags, _dataRequestorId);
1824 
1825  req->taskId(taskId());
1826  req->setContext(this->thread[tid]->contextId());
1827  req->setHtmAbortCause(cause);
1828 
1829  assert(req->isHTMAbort());
1830 
1831  PacketPtr abort_pkt = Packet::createRead(req);
1832  uint8_t *memData = new uint8_t[8];
1833  assert(memData);
1834  abort_pkt->dataStatic(memData);
1835  abort_pkt->setHtmTransactional(htm_uid);
1836 
1837  // TODO include correct error handling here
1838  if (!this->iew.ldstQueue.getDataPort().sendTimingReq(abort_pkt)) {
1839  panic("HTM abort signal was not sent to the memory subsystem.");
1840  }
1841 }
1842 
1843 // Forward declaration of FullO3CPU.
1844 template class FullO3CPU<O3CPUImpl>;
FullO3CPU::wakeup
virtual void wakeup(ThreadID tid) override
Definition: cpu.cc:1693
InvalidThreadID
const ThreadID InvalidThreadID
Definition: types.hh:234
PhysRegFile::readVecReg
const TheISA::VecRegContainer & readVecReg(PhysRegIdPtr phys_reg) const
Reads a vector register.
Definition: regfile.hh:200
FullO3CPU::readArchVecElem
const TheISA::VecElem & readArchVecElem(const RegIndex &reg_idx, const ElemIndex &ldx, ThreadID tid) const
Definition: cpu.cc:1334
fatal
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:183
ArmISA::status
Bitfield< 5, 0 > status
Definition: miscregs_types.hh:417
FullO3CPU::takeOverFrom
void takeOverFrom(BaseCPU *oldCPU) override
Takes over from another CPU.
Definition: cpu.cc:1118
Event::scheduled
bool scheduled() const
Determine if the current event is scheduled.
Definition: eventq.hh:462
FullO3CPU::setArchFloatReg
void setArchFloatReg(int reg_idx, RegVal val, ThreadID tid)
Definition: cpu.cc:1384
FullO3CPU
FullO3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time ...
Definition: cpu.hh:91
FullO3CPU::readVecElem
const TheISA::VecElem & readVecElem(PhysRegIdPtr reg_idx) const
Definition: cpu.cc:1212
Scoreboard::setReg
void setReg(PhysRegIdPtr phys_reg)
Sets the register as ready.
Definition: scoreboard.hh:93
FullO3CPU::deactivateThread
void deactivateThread(ThreadID tid)
Remove Thread from Active Threads List.
Definition: cpu.cc:607
FullO3CPU::getInterrupts
Fault getInterrupts()
Returns the Fault for any valid interrupt.
Definition: cpu.cc:888
FullO3CPU::regProbePoints
void regProbePoints() override
Register probe points.
Definition: cpu.cc:364
FullO3CPU::timeBuffer
TimeBuffer< TimeStruct > timeBuffer
The main time buffer to do backwards communication.
Definition: cpu.hh:614
FullO3CPU::rob
CPUPolicy::ROB rob
The re-order buffer.
Definition: cpu.hh:570
FullO3CPU::commitRenameMap
CPUPolicy::RenameMap commitRenameMap[Impl::MaxThreads]
The commit rename map.
Definition: cpu.hh:567
FullO3CPU::rename
CPUPolicy::Rename rename
The dispatch stage.
Definition: cpu.hh:546
FullO3CPU::updateThreadPriority
void updateThreadPriority()
Update The Order In Which We Process Threads.
Definition: cpu.cc:1720
system.hh
FullO3CPU::setVecElem
void setVecElem(PhysRegIdPtr reg_idx, const TheISA::VecElem &val)
Definition: cpu.cc:1269
DrainState::Running
@ Running
Running normally.
Request::HTM_ABORT
@ HTM_ABORT
The request aborts a HTM transaction.
Definition: request.hh:207
EventBase::CPU_Tick_Pri
static const Priority CPU_Tick_Pri
CPU ticks must come after other associated CPU events (such as writebacks).
Definition: eventq.hh:201
ArmISA::VecRegContainer
VecReg::Container VecRegContainer
Definition: registers.hh:63
FullO3CPU::microPC
MicroPC microPC(ThreadID tid)
Reads the commit micro PC of a specific thread.
Definition: cpu.cc:1464
VecElemClass
@ VecElemClass
Vector Register Native Elem lane.
Definition: reg_class.hh:58
FullO3CPU::addThreadToExitingList
void addThreadToExitingList(ThreadID tid)
Insert tid to the list of threads trying to exit.
Definition: cpu.cc:1737
System::isTimingMode
bool isTimingMode() const
Is the system in timing mode?
Definition: system.hh:264
FullO3CPU::setMiscRegNoEffect
void setMiscRegNoEffect(int misc_reg, RegVal val, ThreadID tid)
Sets a miscellaneous register.
Definition: cpu.cc:1165
FullO3CPU::startup
void startup() override
startup() is the final initialization call before simulation.
Definition: cpu.cc:576
FullO3CPU::totalInsts
Counter totalInsts() const override
Count the Total Instructions Committed in the CPU.
Definition: cpu.cc:632
RenameMode::mode
static Enums::VecRegRenameMode mode(const TheISA::PCState &)
Definition: traits.hh:58
BaseCPU::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: base.cc:269
FullO3CPU::setVectorsAsReady
void setVectorsAsReady(ThreadID tid)
Mark vector fields in scoreboard as ready right after switching vector mode, since software may read ...
Definition: cpu.cc:846
FullO3CPU::checker
Checker< Impl > * checker
Pointer to the checker, which can dynamically verify instruction results at run time.
Definition: cpu.hh:670
FullO3CPU::activateThread
void activateThread(ThreadID tid)
Add Thread to Active Threads List.
Definition: cpu.cc:589
RiscvISA::sum
Bitfield< 18 > sum
Definition: registers.hh:634
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
FullO3CPU::serializeThread
void serializeThread(CheckpointOut &cp, ThreadID tid) const override
Serialize a single thread.
Definition: cpu.cc:922
Process
Definition: process.hh:65
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:233
FullO3CPU::exitingThreads
std::unordered_map< ThreadID, bool > exitingThreads
This is a list of threads that are trying to exit.
Definition: cpu.hh:580
FullO3CPU::setArchVecPredReg
void setArchVecPredReg(int reg_idx, const TheISA::VecPredRegContainer &val, ThreadID tid)
Definition: cpu.cc:1415
FullO3CPU::setArchIntReg
void setArchIntReg(int reg_idx, RegVal val, ThreadID tid)
Architectural register accessors.
Definition: cpu.cc:1373
FullO3CPU::nextInstAddr
Addr nextInstAddr(ThreadID tid)
Reads the next PC of a specific thread.
Definition: cpu.cc:1457
Flags< FlagsType >
FullO3CPU::isThreadExiting
bool isThreadExiting(ThreadID tid) const
Is the thread trying to exit?
Definition: cpu.cc:1757
FullO3CPU::switchRenameMode
void switchRenameMode(ThreadID tid, UnifiedFreeList *freelist)
Check if a change in renaming is needed for vector registers.
Definition: cpu.cc:868
FullO3CPU::tickEvent
EventFunctionWrapper tickEvent
The tick event used for scheduling CPU ticks.
Definition: cpu.hh:124
FullO3CPU::setArchCCReg
void setArchCCReg(int reg_idx, RegVal val, ThreadID tid)
Definition: cpu.cc:1425
ProbePointArg
ProbePointArg generates a point for the class of Arg.
Definition: thermal_domain.hh:51
ArmISA::VecPredRegContainer
VecPredReg::Container VecPredRegContainer
Definition: registers.hh:69
FullO3CPU::getWritableVecReg
TheISA::VecRegContainer & getWritableVecReg(PhysRegIdPtr reg_idx)
Read physical vector register for modification.
Definition: cpu.cc:1204
Checker
Templated Checker class.
Definition: cpu.hh:638
FullO3CPU::tcBase
ThreadContext * tcBase(ThreadID tid)
Returns a pointer to a thread context.
Definition: cpu.hh:658
FullO3CPU::drainResume
void drainResume() override
Resumes execution after a drain.
Definition: cpu.cc:1073
FullO3CPU::FullO3CPUStats::idleCycles
Stats::Scalar idleCycles
Stat for total number of cycles the CPU spends descheduled.
Definition: cpu.hh:738
FullO3CPU::removeThread
void removeThread(ThreadID tid)
Remove all of a thread's context from CPU.
Definition: cpu.cc:793
RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:86
FullO3CPU::addInst
ListIt addInst(const DynInstPtr &inst)
Function to add instruction onto the head of the list of the instructions.
Definition: cpu.cc:1479
FullO3CPU::fetchQueue
TimeBuffer< FetchStruct > fetchQueue
The fetch stage's instruction queue.
Definition: cpu.hh:617
EventManager::deschedule
void deschedule(Event &event)
Definition: eventq.hh:1025
BaseCPU::baseStats
BaseCPU::BaseCPUStats baseStats
FullO3CPU::instAddr
Addr instAddr(ThreadID tid)
Reads the commit PC of a specific thread.
Definition: cpu.cc:1450
BaseCPU::deschedulePowerGatingEvent
void deschedulePowerGatingEvent()
Definition: base.cc:448
FullO3CPU::setArchVecReg
void setArchVecReg(int reg_idx, const TheISA::VecRegContainer &val, ThreadID tid)
Definition: cpu.cc:1395
FullSystem
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:204
ActivityRecorder::advance
void advance()
Advances the activity buffer, decrementing the activityCount if active communication just left the ti...
Definition: activity.cc:68
HtmFailureFaultCause
HtmFailureFaultCause
Definition: htm.hh:44
FullO3CPU::cpuStats
FullO3CPU::FullO3CPUStats cpuStats
FullO3CPU::_status
Status _status
Overall CPU status.
Definition: cpu.hh:119
FullO3CPU::removeFrontInst
void removeFrontInst(const DynInstPtr &inst)
Remove an instruction from the front end of the list.
Definition: cpu.cc:1508
RenameMode
Helper structure to get the vector register mode for a given ISA.
Definition: traits.hh:53
FullO3CPU::FullO3CPUStats::committedOps
Stats::Vector committedOps
Stat for the number of committed ops (including micro ops) per thread.
Definition: cpu.hh:746
FullO3CPU::globalSeqNum
InstSeqNum globalSeqNum
The global sequence number counter.
Definition: cpu.hh:664
ActivityRecorder::active
bool active()
Returns if the CPU should be active.
Definition: activity.hh:88
FullO3CPU::FullO3CPUStats::miscRegfileReads
Stats::Scalar miscRegfileReads
Definition: cpu.hh:772
FullO3CPU::squashFromTC
void squashFromTC(ThreadID tid)
Initiates a squash of all in-flight instructions for a given thread.
Definition: cpu.cc:1471
FullO3CPU::switchOut
void switchOut() override
Switches out this CPU.
Definition: cpu.cc:1103
RegId
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:75
BaseCPU::updateCycleCounters
void updateCycleCounters(CPUState state)
base method keeping track of cycle progression
Definition: base.hh:532
FullO3CPU::Idle
@ Idle
Definition: cpu.hh:109
FullO3CPU::cleanUpRemovedInsts
void cleanUpRemovedInsts()
Cleans up all instructions on the remove list.
Definition: cpu.cc:1617
Stats::DataWrap::flags
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
Definition: statistics.hh:339
FullO3CPU::FullO3CPUStats::FullO3CPUStats
FullO3CPUStats(FullO3CPU *cpu)
Definition: cpu.cc:379
DrainState::Drained
@ Drained
Buffers drained, ready for serialization/handover.
PhysRegFile::setCCReg
void setCCReg(PhysRegIdPtr phys_reg, RegVal val)
Sets a condition-code register to the given value.
Definition: regfile.hh:362
FullO3CPU::getWritableArchVecPredReg
TheISA::VecPredRegContainer & getWritableArchVecPredReg(int reg_idx, ThreadID tid)
Definition: cpu.cc:1353
FullO3CPU::commitDrained
void commitDrained(ThreadID tid)
Commit has reached a safe point to drain a thread.
Definition: cpu.cc:1066
FullO3CPU::commit
CPUPolicy::Commit commit
The commit stage.
Definition: cpu.hh:552
FullO3CPU::FullO3CPUStats::committedInsts
Stats::Vector committedInsts
Stat for the number of committed instructions per thread.
Definition: cpu.hh:743
DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:71
FullO3CPU::fetch
CPUPolicy::Fetch fetch
The fetch stage.
Definition: cpu.hh:540
EventBase::CPU_Exit_Pri
static const Priority CPU_Exit_Pri
If we want to exit a thread in a CPU, it comes after CPU_Tick_Pri.
Definition: eventq.hh:208
X86ISA::system
Bitfield< 15 > system
Definition: misc.hh:997
Counter
int64_t Counter
Statistics counter type.
Definition: types.hh:54
FullO3CPU::regFile
PhysRegFile regFile
The register file.
Definition: cpu.hh:558
FullO3CPU::suspendContext
void suspendContext(ThreadID tid) override
Remove Thread from Active Threads List.
Definition: cpu.cc:697
PhysRegFile::readVecElem
const TheISA::VecElem & readVecElem(PhysRegIdPtr phys_reg) const
Reads a vector element.
Definition: regfile.hh:251
FullO3CPU::removeInstsNotInROB
void removeInstsNotInROB(ThreadID tid)
Remove all instructions that are not currently in the ROB.
Definition: cpu.cc:1522
ArmISA::VecElem
uint32_t VecElem
Definition: registers.hh:60
cp
Definition: cprintf.cc:37
FullO3CPU::setCCReg
void setCCReg(PhysRegIdPtr phys_reg, RegVal val)
Definition: cpu.cc:1286
FullO3CPU::FullO3CPUStats::fpRegfileReads
Stats::Scalar fpRegfileReads
Definition: cpu.hh:760
EventManager::schedule
void schedule(Event &event, Tick when)
Definition: eventq.hh:1016
FullO3CPU::setIntReg
void setIntReg(PhysRegIdPtr phys_reg, RegVal val)
Definition: cpu.cc:1244
FullO3CPU< O3CPUImpl >::DynInstPtr
O3CPUImpl ::DynInstPtr DynInstPtr
Definition: cpu.hh:96
FloatRegClass
@ FloatRegClass
Floating-point register.
Definition: reg_class.hh:54
PhysRegFile::setVecPredReg
void setVecPredReg(PhysRegIdPtr phys_reg, const TheISA::VecPredRegContainer &val)
Sets a predicate register to the given value.
Definition: regfile.hh:349
FullO3CPU::ListIt
std::list< DynInstPtr >::iterator ListIt
Definition: cpu.hh:102
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
FullO3CPU::wakeCPU
void wakeCPU()
Wakes the CPU, rescheduling the CPU if it's not already active.
Definition: cpu.cc:1671
Stats::DataWrap::prereq
Derived & prereq(const Stat &prereq)
Set the prerequisite stat and marks this stat to print at the end of simulation.
Definition: statistics.hh:353
FullO3CPU::setArchVecElem
void setArchVecElem(const RegIndex &reg_idx, const ElemIndex &ldx, const TheISA::VecElem &val, ThreadID tid)
Definition: cpu.cc:1405
isa_specific.hh
FullO3CPU::activateContext
void activateContext(ThreadID tid) override
Add Thread to Active Threads List.
Definition: cpu.cc:658
FullO3CPU::verifyMemoryMode
void verifyMemoryMode() const override
Verify that the system is in a memory mode supported by the CPU.
Definition: cpu.cc:1140
FullO3CPU::instList
std::list< DynInstPtr > instList
List of all the instructions in flight.
Definition: cpu.hh:519
FullO3CPU::FullO3CPUStats::fpRegfileWrites
Stats::Scalar fpRegfileWrites
Definition: cpu.hh:761
FullO3CPU::decodeQueue
TimeBuffer< DecodeStruct > decodeQueue
The decode stage's instruction queue.
Definition: cpu.hh:620
PhysRegFile::readIntReg
RegVal readIntReg(PhysRegIdPtr phys_reg) const
Reads an integer register.
Definition: regfile.hh:176
BaseO3CPU
Definition: cpu.hh:78
FullO3CPU::readMiscRegNoEffect
RegVal readMiscRegNoEffect(int misc_reg, ThreadID tid) const
Register accessors.
Definition: cpu.cc:1150
cprintf
void cprintf(const char *format, const Args &...args)
Definition: cprintf.hh:152
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:237
ADD_STAT
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
Definition: group.hh:71
ThreadContext::Halted
@ Halted
Permanently shut down.
Definition: thread_context.hh:116
FullO3CPU::FullO3CPUStats::timesIdled
Stats::Scalar timesIdled
Stat for total number of times the CPU is descheduled.
Definition: cpu.hh:736
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:246
FullO3CPU::Thread
O3ThreadState< Impl > Thread
Definition: cpu.hh:100
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
FullO3CPU::threadExitEvent
EventFunctionWrapper threadExitEvent
The exit event used for terminating all ready-to-exit threads.
Definition: cpu.hh:127
BaseCPU::interrupts
std::vector< BaseInterrupts * > interrupts
Definition: base.hh:232
PhysRegFile::setFloatReg
void setFloatReg(PhysRegIdPtr phys_reg, RegVal val)
Definition: regfile.hh:311
Packet::createRead
static PacketPtr createRead(const RequestPtr &req)
Constructor-like methods that return Packets based on Request objects.
Definition: packet.hh:981
traits.hh
cpu.hh
FullO3CPU::activityRec
ActivityRecorder activityRec
The activity recorder; used to tell if the CPU has any activity remaining or if it can go to idle and...
Definition: cpu.hh:633
FullO3CPU::renameMap
CPUPolicy::RenameMap renameMap[Impl::MaxThreads]
The rename map.
Definition: cpu.hh:564
ArmISA::ZeroReg
const int ZeroReg
Definition: registers.hh:110
BaseCPU::threadContexts
std::vector< ThreadContext * > threadContexts
Definition: base.hh:269
Clocked::curCycle
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
Definition: clocked_object.hh:192
ArmISA::NumVecElemPerVecReg
constexpr unsigned NumVecElemPerVecReg
Definition: registers.hh:58
Clocked::clockEdge
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
Definition: clocked_object.hh:174
FullO3CPU::FullO3CPUStats::vecRegfileWrites
Stats::Scalar vecRegfileWrites
Definition: cpu.hh:764
process.hh
Request::STRICT_ORDER
@ STRICT_ORDER
The request is required to be strictly ordered by CPU models and is non-speculative.
Definition: request.hh:128
CheckerCPU::setIcachePort
void setIcachePort(RequestPort *icache_port)
Definition: cpu.cc:112
FullO3CPU::FullO3CPUStats::miscRegfileWrites
Stats::Scalar miscRegfileWrites
Definition: cpu.hh:773
UnifiedFreeList
FreeList class that simply holds the list of free integer and floating point registers.
Definition: free_list.hh:114
activity.hh
FullO3CPU::FullO3CPU
FullO3CPU(const DerivO3CPUParams &params)
Constructs a CPU with the given parameters.
Definition: cpu.cc:73
FullO3CPU::~FullO3CPU
~FullO3CPU()
Destructor.
Definition: cpu.cc:358
FullO3CPU::freeList
CPUPolicy::FreeList freeList
The free list.
Definition: cpu.hh:561
PhysRegFile::readCCReg
RegVal readCCReg(PhysRegIdPtr phys_reg)
Reads a condition-code register.
Definition: regfile.hh:286
BaseCPU::activateContext
virtual void activateContext(ThreadID thread_num)
Notify the CPU that the indicated context is now active.
Definition: base.cc:484
FullO3CPU::removeInstsThisCycle
bool removeInstsThisCycle
Records if instructions need to be removed this cycle due to being retired or squashed.
Definition: cpu.hh:536
FullO3CPU::FullO3CPUStats::totalCpi
Stats::Formula totalCpi
Stat for the total CPI.
Definition: cpu.hh:750
Packet::setHtmTransactional
void setHtmTransactional(uint64_t val)
Stipulates that this packet/request originates in the CPU executing in transactional mode,...
Definition: packet.cc:537
ArmISA::NumVecPredRegs
const int NumVecPredRegs
Definition: registers.hh:90
FullO3CPU::FullO3CPUStats::vecPredRegfileReads
Stats::Scalar vecPredRegfileReads
Definition: cpu.hh:766
Drainable::signalDrainDone
void signalDrainDone() const
Signal that an object is drained.
Definition: drain.hh:301
FullO3CPU::getFreeTid
ThreadID getFreeTid()
Gets a free thread id.
Definition: cpu.cc:1706
FullO3CPU::readIntReg
RegVal readIntReg(PhysRegIdPtr phys_reg)
Definition: cpu.cc:1180
FullO3CPU::instDone
void instDone(ThreadID tid, const DynInstPtr &inst)
Function to tell the CPU that an instruction has completed.
Definition: cpu.cc:1488
FullO3CPU::removeInstsUntil
void removeInstsUntil(const InstSeqNum &seq_num, ThreadID tid)
Remove all instructions younger than the given sequence number.
Definition: cpu.cc:1567
ArmISA::NumFloatRegs
const int NumFloatRegs
Definition: registers.hh:75
FullO3CPU::setVecReg
void setVecReg(PhysRegIdPtr reg_idx, const TheISA::VecRegContainer &val)
Definition: cpu.cc:1260
BaseCPU::BaseCPUStats::numCycles
Stats::Scalar numCycles
Definition: base.hh:606
VecPredRegClass
@ VecPredRegClass
Definition: reg_class.hh:59
FullO3CPU::FullO3CPUStats::vecRegfileReads
Stats::Scalar vecRegfileReads
Definition: cpu.hh:763
FullO3CPU::SwitchedOut
@ SwitchedOut
Definition: cpu.hh:112
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:37
UNIT_COUNT
#define UNIT_COUNT
Definition: units.hh:49
NoFault
constexpr decltype(nullptr) NoFault
Definition: types.hh:251
FullO3CPU::thread
std::vector< Thread * > thread
Pointers to all of the threads in the CPU.
Definition: cpu.hh:676
ActivityRecorder::reset
void reset()
Clears the time buffer and the activity count.
Definition: activity.cc:122
core.hh
FullO3CPU::readVecReg
const TheISA::VecRegContainer & readVecReg(PhysRegIdPtr reg_idx) const
Definition: cpu.cc:1196
ArmISA::NumIntRegs
const int NumIntRegs
Definition: registers.hh:74
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:148
ThreadContext::setStatus
virtual void setStatus(Status new_status)=0
FullO3CPU::readFloatReg
RegVal readFloatReg(PhysRegIdPtr phys_reg)
Definition: cpu.cc:1188
name
const std::string & name()
Definition: trace.cc:48
Stats::VectorBase::init
Derived & init(size_type size)
Set this vector to have the given size.
Definition: statistics.hh:1028
FullO3CPU::insertThread
void insertThread(ThreadID tid)
Setup CPU to insert a thread's context.
Definition: cpu.cc:741
FullO3CPU::lastActivatedCycle
Tick lastActivatedCycle
The cycle that the CPU was last activated by a new thread.
Definition: cpu.hh:685
FullO3CPU::processInterrupts
void processInterrupts(const Fault &interrupt)
Processes any an interrupt fault.
Definition: cpu.cc:896
IntRegClass
@ IntRegClass
Integer register.
Definition: reg_class.hh:53
FullO3CPU::system
System * system
Pointer to the system.
Definition: cpu.hh:673
FullO3CPU::FullO3CPUStats::intRegfileWrites
Stats::Scalar intRegfileWrites
Definition: cpu.hh:758
FullO3CPU::isCpuDrained
bool isCpuDrained() const
Check if a system is in a drained state.
Definition: cpu.cc:1027
FullO3CPU::FullO3CPUStats::ipc
Stats::Formula ipc
Stat for the IPC per thread.
Definition: cpu.hh:752
FullO3CPU::drainSanityCheck
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: cpu.cc:1015
full_system.hh
CCRegClass
@ CCRegClass
Condition-code register.
Definition: reg_class.hh:60
FullO3CPU::tids
std::vector< ThreadID > tids
Available thread ids in the cpu.
Definition: cpu.hh:691
ArmISA::e
Bitfield< 9 > e
Definition: miscregs_types.hh:61
ThreadContext::pcState
virtual TheISA::PCState pcState() const =0
Drainable::drainState
DrainState drainState() const
Return the current drain state of an object.
Definition: drain.hh:320
BaseCPU::taskId
uint32_t taskId() const
Get cpu task id.
Definition: base.hh:219
FullO3CPU::vecMode
Enums::VecRegRenameMode vecMode
The rename mode of the vector registers.
Definition: cpu.hh:555
X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:80
FullO3CPU::activeThreads
std::list< ThreadID > activeThreads
Active Threads List.
Definition: cpu.hh:573
FullO3CPU::dumpInsts
void dumpInsts()
Debug function to print all instructions on the list.
Definition: cpu.cc:1643
BaseCPU
Definition: base.hh:104
UNIT_RATE
#define UNIT_RATE(T1, T2)
Definition: units.hh:47
FullO3CPU::tryDrain
bool tryDrain()
Check if the pipeline has drained and signal drain done.
Definition: cpu.cc:999
stat_control.hh
FullO3CPU::removeList
std::queue< ListIt > removeList
List of all the instructions that will be removed at the end of this cycle.
Definition: cpu.hh:524
System::threads
Threads threads
Definition: system.hh:304
VecRegClass
@ VecRegClass
Vector Register.
Definition: reg_class.hh:56
ThreadContext::Suspended
@ Suspended
Temporarily inactive.
Definition: thread_context.hh:107
simple_thread.hh
FullO3CPU::readCCReg
RegVal readCCReg(PhysRegIdPtr phys_reg)
Definition: cpu.cc:1236
FullO3CPU::readArchVecReg
const TheISA::VecRegContainer & readArchVecReg(int reg_idx, ThreadID tid) const
Definition: cpu.cc:1316
ArmISA::NumCCRegs
const int NumCCRegs
Definition: registers.hh:76
PseudoInst::quiesceCycles
void quiesceCycles(ThreadContext *tc, uint64_t cycles)
Definition: pseudo_inst.cc:133
FullO3CPU::readArchIntReg
RegVal readArchIntReg(int reg_idx, ThreadID tid)
Definition: cpu.cc:1294
FullO3CPU::scheduleTickEvent
void scheduleTickEvent(Cycles delay)
Schedule tick event, regardless of its current state.
Definition: cpu.hh:130
Stats::DataWrap::precision
Derived & precision(int _precision)
Set the precision and marks this stat to print at the end of simulation.
Definition: statistics.hh:327
MipsISA::PCState
GenericISA::DelaySlotPCState< MachInst > PCState
Definition: types.hh:41
RegIndex
uint16_t RegIndex
Definition: types.hh:52
ArmISA::t
Bitfield< 5 > t
Definition: miscregs_types.hh:67
ActivityRecorder::activity
void activity()
Records that there is activity this cycle.
Definition: activity.cc:52
BaseCPU::schedulePowerGatingEvent
void schedulePowerGatingEvent()
Definition: base.cc:456
Packet::dataStatic
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
Definition: packet.hh:1108
BaseCPU::takeOverFrom
virtual void takeOverFrom(BaseCPU *cpu)
Load the state of a CPU from the previous CPU object, invoked on all new CPUs that are about to be sw...
Definition: base.cc:550
FullO3CPU::FullO3CPUStats::intRegfileReads
Stats::Scalar intRegfileReads
Definition: cpu.hh:757
FullO3CPU::renameQueue
TimeBuffer< RenameStruct > renameQueue
The rename stage's instruction queue.
Definition: cpu.hh:623
PhysRegFile::getWritableVecPredReg
TheISA::VecPredRegContainer & getWritableVecPredReg(PhysRegIdPtr phys_reg)
Definition: regfile.hh:277
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:258
FullO3CPU::getWritableVecPredReg
TheISA::VecPredRegContainer & getWritableVecPredReg(PhysRegIdPtr reg_idx)
Definition: cpu.cc:1228
BaseCPU::switchOut
virtual void switchOut()
Prepare for another CPU to take over execution.
Definition: base.cc:536
BaseCPU::_dataRequestorId
RequestorID _dataRequestorId
data side request id that must be placed in all requests
Definition: base.hh:129
FullO3CPU::squashInstIt
void squashInstIt(const ListIt &instIt, ThreadID tid)
Removes the instruction pointed to by the iterator.
Definition: cpu.cc:1596
FullO3CPU::haltContext
void haltContext(ThreadID tid) override
Remove Thread from Active Threads List && Remove Thread Context from CPU.
Definition: cpu.cc:718
FullO3CPU::htmSendAbortSignal
void htmSendAbortSignal(ThreadID tid, uint64_t htm_uid, HtmFailureFaultCause cause)
Definition: cpu.cc:1809
FullO3CPU::FullO3CPUStats::ccRegfileReads
Stats::Scalar ccRegfileReads
Definition: cpu.hh:769
ElemIndex
uint16_t ElemIndex
Logical vector register elem index type.
Definition: types.hh:55
FullO3CPU::Running
@ Running
Definition: cpu.hh:108
Request::PHYSICAL
@ PHYSICAL
The virtual address is also the physical address.
Definition: request.hh:110
FullO3CPU::FullO3CPUStats::cpi
Stats::Formula cpi
Stat for the CPI per thread.
Definition: cpu.hh:748
BaseCPU::numThreads
ThreadID numThreads
Number of threads we're actually simulating (<= SMT_MAX_THREADS).
Definition: base.hh:378
FullO3CPU::iew
CPUPolicy::IEW iew
The issue/execute/writeback stages.
Definition: cpu.hh:549
O3ThreadContext::thread
O3ThreadState< Impl > * thread
Pointer to the thread state that this TC corrseponds to.
Definition: thread_context.hh:99
FullO3CPU::tick
void tick()
Ticks CPU, calling tick() on each stage, and checking the overall activity to see if the CPU should d...
Definition: cpu.cc:496
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
Clocked::nextCycle
Tick nextCycle() const
Based on the clock of the object, determine the start tick of the first cycle that is at least one cy...
Definition: clocked_object.hh:210
UNIT_CYCLE
#define UNIT_CYCLE
Convenience macros to declare the unit of a stat.
Definition: units.hh:39
ThreadContext::Active
@ Active
Running.
Definition: thread_context.hh:103
FullO3CPU::isa
std::vector< TheISA::ISA * > isa
Definition: cpu.hh:585
CheckerThreadContext
Derived ThreadContext class for use with the Checker.
Definition: thread_context.hh:66
FullO3CPU::init
void init() override
Initialize the CPU.
Definition: cpu.cc:555
thread_context.hh
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:64
BaseCPU::startup
void startup() override
startup() is the final initialization call before simulation.
Definition: base.cc:312
PhysRegId
Physical register ID.
Definition: reg_class.hh:223
Stats
Definition: statistics.cc:53
FullO3CPU::readArchVecPredReg
const TheISA::VecPredRegContainer & readArchVecPredReg(int reg_idx, ThreadID tid) const
Definition: cpu.cc:1344
FullO3CPU::decode
CPUPolicy::Decode decode
The decode stage.
Definition: cpu.hh:543
BaseCPU::regProbePoints
void regProbePoints() override
Register probe points for this object.
Definition: base.cc:337
BaseCPU::CPU_STATE_ON
@ CPU_STATE_ON
Definition: base.hh:523
FullO3CPU::iewQueue
TimeBuffer< IEWStruct > iewQueue
The IEW stage's instruction queue.
Definition: cpu.hh:626
BaseCPU::suspendContext
virtual void suspendContext(ThreadID thread_num)
Notify the CPU that the indicated context is now suspended.
Definition: base.cc:498
RefCountingPtr< StaticInst >
FullO3CPU::pcState
void pcState(const TheISA::PCState &newPCState, ThreadID tid)
Sets the commit PC state of a specific thread.
Definition: cpu.cc:1443
curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:43
BaseO3CPU::BaseO3CPU
BaseO3CPU(const BaseCPUParams &params)
Definition: cpu.cc:67
FullO3CPU::getWritableArchVecReg
TheISA::VecRegContainer & getWritableArchVecReg(int reg_idx, ThreadID tid)
Read architectural vector register for modification.
Definition: cpu.cc:1325
RegId::index
const RegIndex & index() const
Index accessors.
Definition: reg_class.hh:171
BaseCPU::CPU_STATE_SLEEP
@ CPU_STATE_SLEEP
Definition: base.hh:524
TimeBuffer::getSize
unsigned getSize()
Definition: timebuf.hh:241
FullO3CPU::exitThreads
void exitThreads()
Terminate all threads that are ready to exit.
Definition: cpu.cc:1785
ArmISA::NumVecRegs
const int NumVecRegs
Definition: registers.hh:89
FullO3CPU::trap
void trap(const Fault &fault, ThreadID tid, const StaticInstPtr &inst)
Traps to handle given fault.
Definition: cpu.cc:913
FullO3CPU::setMiscReg
void setMiscReg(int misc_reg, RegVal val, ThreadID tid)
Sets a misc.
Definition: cpu.cc:1172
TimeBuffer::advance
void advance()
Definition: timebuf.hh:176
cpu.hh
std::list
STL list class.
Definition: stl.hh:51
FullO3CPU< O3CPUImpl >::O3CPU
O3CPUImpl ::O3CPU O3CPU
Definition: cpu.hh:97
PhysRegFile::getWritableVecReg
TheISA::VecRegContainer & getWritableVecReg(PhysRegIdPtr phys_reg)
Reads a vector register for modification.
Definition: regfile.hh:213
MicroPC
uint16_t MicroPC
Definition: types.hh:150
FullO3CPU::totalOps
Counter totalOps() const override
Count the Total Ops (including micro ops) committed in the CPU.
Definition: cpu.cc:645
FullO3CPU::setFloatReg
void setFloatReg(PhysRegIdPtr phys_reg, RegVal val)
Definition: cpu.cc:1252
FullO3CPU::unscheduleTickEvent
void unscheduleTickEvent()
Unschedule tick event, regardless of its current state.
Definition: cpu.hh:139
BaseCPU::switchedOut
bool switchedOut() const
Determine if the CPU is switched out.
Definition: base.hh:367
PhysRegFile::readVecPredReg
const TheISA::VecPredRegContainer & readVecPredReg(PhysRegIdPtr phys_reg) const
Reads a predicate register.
Definition: regfile.hh:265
fatal_if
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:219
PhysRegFile::readFloatReg
RegVal readFloatReg(PhysRegIdPtr phys_reg) const
Definition: regfile.hh:186
FullO3CPU::scoreboard
Scoreboard scoreboard
Integer Register Scoreboard.
Definition: cpu.hh:583
Stats::total
const FlagsType total
Print the total.
Definition: info.hh:50
CheckpointIn
Definition: serialize.hh:68
PhysRegFile::setIntReg
void setIntReg(PhysRegIdPtr phys_reg, RegVal val)
Sets an integer register to the given value.
Definition: regfile.hh:299
FullO3CPU::readVecPredReg
const TheISA::VecPredRegContainer & readVecPredReg(PhysRegIdPtr reg_idx) const
Definition: cpu.cc:1220
thread_context.hh
FullO3CPU::setVecPredReg
void setVecPredReg(PhysRegIdPtr reg_idx, const TheISA::VecPredRegContainer &val)
Definition: cpu.cc:1277
BaseCPU::probeInstCommit
virtual void probeInstCommit(const StaticInstPtr &inst, Addr pc)
Helper method to trigger PMU probes for a committed instruction.
Definition: base.cc:353
FullO3CPU::drain
DrainState drain() override
Starts draining the CPU's pipeline of all instructions in order to stop all memory accesses.
Definition: cpu.cc:936
FullO3CPU::readArchCCReg
RegVal readArchCCReg(int reg_idx, ThreadID tid)
Definition: cpu.cc:1362
PhysRegFile::setVecElem
void setVecElem(PhysRegIdPtr phys_reg, const TheISA::VecElem val)
Sets a vector register to the given value.
Definition: regfile.hh:336
FullO3CPU::unserializeThread
void unserializeThread(CheckpointIn &cp, ThreadID tid) override
Unserialize one thread.
Definition: cpu.cc:929
ArmISA::v
Bitfield< 28 > v
Definition: miscregs_types.hh:51
FullO3CPU::FullO3CPUStats::totalIpc
Stats::Formula totalIpc
Stat for the total IPC.
Definition: cpu.hh:754
thread_context.hh
FullO3CPU::readMiscReg
RegVal readMiscReg(int misc_reg, ThreadID tid)
Reads a misc.
Definition: cpu.cc:1157
O3ThreadContext::cpu
O3CPU * cpu
Pointer to the CPU.
Definition: thread_context.hh:69
RegVal
uint64_t RegVal
Definition: types.hh:174
FullO3CPU::scheduleThreadExitEvent
void scheduleThreadExitEvent(ThreadID tid)
If a thread is trying to exit and its corresponding trap event has been completed,...
Definition: cpu.cc:1764
PhysRegFile::setVecReg
void setVecReg(PhysRegIdPtr phys_reg, const TheISA::VecRegContainer &val)
Sets a vector register to the given value.
Definition: regfile.hh:324
DrainState::Draining
@ Draining
Draining buffers pending serialization/handover.
FullO3CPU::readArchFloatReg
RegVal readArchFloatReg(int reg_idx, ThreadID tid)
Definition: cpu.cc:1305
FullO3CPU::FullO3CPUStats::vecPredRegfileWrites
Stats::Scalar vecPredRegfileWrites
Definition: cpu.hh:767
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
FullO3CPU::FullO3CPUStats::quiesceCycles
Stats::Scalar quiesceCycles
Stat for total number of cycles the CPU spends descheduled due to a quiesce operation or waiting for ...
Definition: cpu.hh:741
FullO3CPU::FullO3CPUStats::ccRegfileWrites
Stats::Scalar ccRegfileWrites
Definition: cpu.hh:770
FullO3CPU::lastRunningCycle
Cycles lastRunningCycle
The cycle that the CPU was last running, used for statistics.
Definition: cpu.hh:682
O3ThreadContext
Derived ThreadContext class for use with the O3CPU.
Definition: cpu.hh:71

Generated on Tue Mar 23 2021 19:41:18 for gem5 by doxygen 1.8.17