gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cpu_impl.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, 2016 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) 2006 The Regents of The University of Michigan
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Authors: Kevin Lim
42  * Geoffrey Blake
43  */
44 
45 #ifndef __CPU_CHECKER_CPU_IMPL_HH__
46 #define __CPU_CHECKER_CPU_IMPL_HH__
47 
48 #include <list>
49 #include <string>
50 
51 #include "arch/isa_traits.hh"
52 #include "arch/vtophys.hh"
53 #include "base/refcnt.hh"
54 #include "config/the_isa.hh"
55 #include "cpu/base_dyn_inst.hh"
56 #include "cpu/exetrace.hh"
57 #include "cpu/reg_class.hh"
58 #include "cpu/simple_thread.hh"
59 #include "cpu/static_inst.hh"
60 #include "cpu/thread_context.hh"
61 #include "cpu/checker/cpu.hh"
62 #include "debug/Checker.hh"
63 #include "sim/full_system.hh"
64 #include "sim/sim_object.hh"
65 #include "sim/stats.hh"
66 
67 using namespace std;
68 using namespace TheISA;
69 
70 template <class Impl>
71 void
73 {
74  if (fault != NoFault) {
75  curMacroStaticInst = StaticInst::nullStaticInstPtr;
76  fault->invoke(tc, curStaticInst);
77  thread->decoder.reset();
78  } else {
79  if (curStaticInst) {
80  if (curStaticInst->isLastMicroop())
81  curMacroStaticInst = StaticInst::nullStaticInstPtr;
82  TheISA::PCState pcState = thread->pcState();
83  TheISA::advancePC(pcState, curStaticInst);
84  thread->pcState(pcState);
85  DPRINTF(Checker, "Advancing PC to %s.\n", thread->pcState());
86  }
87  }
88 }
90 
91 template <class Impl>
92 void
94 {
95  DPRINTF(Checker, "IRQ detected at PC: %s with %d insts in buffer\n",
96  thread->pcState(), instList.size());
97  DynInstPtr boundaryInst = NULL;
98  if (!instList.empty()) {
99  // Set the instructions as completed and verify as much as possible.
100  DynInstPtr inst;
101  typename std::list<DynInstPtr>::iterator itr;
102 
103  for (itr = instList.begin(); itr != instList.end(); itr++) {
104  (*itr)->setCompleted();
105  }
106 
107  inst = instList.front();
108  boundaryInst = instList.back();
109  verify(inst); // verify the instructions
110  inst = NULL;
111  }
112  if ((!boundaryInst && curMacroStaticInst &&
113  curStaticInst->isDelayedCommit() &&
114  !curStaticInst->isLastMicroop()) ||
115  (boundaryInst && boundaryInst->isDelayedCommit() &&
116  !boundaryInst->isLastMicroop())) {
117  panic("%lli: Trying to take an interrupt in middle of "
118  "a non-interuptable instruction!", curTick());
119  }
120  boundaryInst = NULL;
121  thread->decoder.reset();
122  curMacroStaticInst = StaticInst::nullStaticInstPtr;
123 }
124 
125 template <class Impl>
126 void
127 Checker<Impl>::verify(const DynInstPtr &completed_inst)
128 {
129  DynInstPtr inst;
130 
131  // Make sure serializing instructions are actually
132  // seen as serializing to commit. instList should be
133  // empty in these cases.
134  if ((completed_inst->isSerializing() ||
135  completed_inst->isSerializeBefore()) &&
136  (!instList.empty() ?
137  (instList.front()->seqNum != completed_inst->seqNum) : 0)) {
138  panic("%lli: Instruction sn:%lli at PC %s is serializing before but is"
139  " entering instList with other instructions\n", curTick(),
140  completed_inst->seqNum, completed_inst->pcState());
141  }
142 
143  // Either check this instruction, or add it to a list of
144  // instructions waiting to be checked. Instructions must be
145  // checked in program order, so if a store has committed yet not
146  // completed, there may be some instructions that are waiting
147  // behind it that have completed and must be checked.
148  if (!instList.empty()) {
149  if (youngestSN < completed_inst->seqNum) {
150  DPRINTF(Checker, "Adding instruction [sn:%lli] PC:%s to list\n",
151  completed_inst->seqNum, completed_inst->pcState());
152  instList.push_back(completed_inst);
153  youngestSN = completed_inst->seqNum;
154  }
155 
156  if (!instList.front()->isCompleted()) {
157  return;
158  } else {
159  inst = instList.front();
160  instList.pop_front();
161  }
162  } else {
163  if (!completed_inst->isCompleted()) {
164  if (youngestSN < completed_inst->seqNum) {
165  DPRINTF(Checker, "Adding instruction [sn:%lli] PC:%s to list\n",
166  completed_inst->seqNum, completed_inst->pcState());
167  instList.push_back(completed_inst);
168  youngestSN = completed_inst->seqNum;
169  }
170  return;
171  } else {
172  if (youngestSN < completed_inst->seqNum) {
173  inst = completed_inst;
174  youngestSN = completed_inst->seqNum;
175  } else {
176  return;
177  }
178  }
179  }
180 
181  // Make sure a serializing instruction is actually seen as
182  // serializing. instList should be empty here
183  if (inst->isSerializeAfter() && !instList.empty()) {
184  panic("%lli: Instruction sn:%lli at PC %s is serializing after but is"
185  " exiting instList with other instructions\n", curTick(),
186  completed_inst->seqNum, completed_inst->pcState());
187  }
188  unverifiedInst = inst;
189  inst = NULL;
190 
191  // Try to check all instructions that are completed, ending if we
192  // run out of instructions to check or if an instruction is not
193  // yet completed.
194  while (1) {
195  DPRINTF(Checker, "Processing instruction [sn:%lli] PC:%s.\n",
196  unverifiedInst->seqNum, unverifiedInst->pcState());
197  unverifiedReq = NULL;
198  unverifiedReq = unverifiedInst->reqToVerify;
199  unverifiedMemData = unverifiedInst->memData;
200  // Make sure results queue is empty
201  while (!result.empty()) {
202  result.pop();
203  }
204  numCycles++;
205 
206  Fault fault = NoFault;
207 
208  // maintain $r0 semantics
209  thread->setIntReg(ZeroReg, 0);
210 #if THE_ISA == ALPHA_ISA
211  thread->setFloatReg(ZeroReg, 0);
212 #endif
213 
214  // Check if any recent PC changes match up with anything we
215  // expect to happen. This is mostly to check if traps or
216  // PC-based events have occurred in both the checker and CPU.
217  if (changedPC) {
218  DPRINTF(Checker, "Changed PC recently to %s\n",
219  thread->pcState());
220  if (willChangePC) {
221  if (newPCState == thread->pcState()) {
222  DPRINTF(Checker, "Changed PC matches expected PC\n");
223  } else {
224  warn("%lli: Changed PC does not match expected PC, "
225  "changed: %s, expected: %s",
226  curTick(), thread->pcState(), newPCState);
228  }
229  willChangePC = false;
230  }
231  changedPC = false;
232  }
233 
234  // Try to fetch the instruction
235  uint64_t fetchOffset = 0;
236  bool fetchDone = false;
237 
238  while (!fetchDone) {
239  Addr fetch_PC = thread->instAddr();
240  fetch_PC = (fetch_PC & PCMask) + fetchOffset;
241 
242  MachInst machInst;
243 
244  // If not in the middle of a macro instruction
245  if (!curMacroStaticInst) {
246  // set up memory request for instruction fetch
247  auto mem_req = std::make_shared<Request>(
248  unverifiedInst->threadNumber, fetch_PC,
249  sizeof(MachInst), 0, masterId, fetch_PC,
250  thread->contextId());
251 
252  mem_req->setVirt(0, fetch_PC, sizeof(MachInst),
253  Request::INST_FETCH, masterId,
254  thread->instAddr());
255 
256  fault = itb->translateFunctional(
257  mem_req, tc, BaseTLB::Execute);
258 
259  if (fault != NoFault) {
260  if (unverifiedInst->getFault() == NoFault) {
261  // In this case the instruction was not a dummy
262  // instruction carrying an ITB fault. In the single
263  // threaded case the ITB should still be able to
264  // translate this instruction; in the SMT case it's
265  // possible that its ITB entry was kicked out.
266  warn("%lli: Instruction PC %s was not found in the "
267  "ITB!", curTick(), thread->pcState());
268  handleError(unverifiedInst);
269 
270  // go to the next instruction
272 
273  // Give up on an ITB fault..
274  unverifiedInst = NULL;
275  return;
276  } else {
277  // The instruction is carrying an ITB fault. Handle
278  // the fault and see if our results match the CPU on
279  // the next tick().
280  fault = unverifiedInst->getFault();
281  break;
282  }
283  } else {
284  PacketPtr pkt = new Packet(mem_req, MemCmd::ReadReq);
285 
286  pkt->dataStatic(&machInst);
287  icachePort->sendFunctional(pkt);
288 
289  delete pkt;
290  }
291  }
292 
293  if (fault == NoFault) {
294  TheISA::PCState pcState = thread->pcState();
295 
296  if (isRomMicroPC(pcState.microPC())) {
297  fetchDone = true;
298  curStaticInst =
299  microcodeRom.fetchMicroop(pcState.microPC(), NULL);
300  } else if (!curMacroStaticInst) {
301  //We're not in the middle of a macro instruction
302  StaticInstPtr instPtr = nullptr;
303 
304  //Predecode, ie bundle up an ExtMachInst
305  //If more fetch data is needed, pass it in.
306  Addr fetchPC = (pcState.instAddr() & PCMask) + fetchOffset;
307  thread->decoder.moreBytes(pcState, fetchPC, machInst);
308 
309  //If an instruction is ready, decode it.
310  //Otherwise, we'll have to fetch beyond the
311  //MachInst at the current pc.
312  if (thread->decoder.instReady()) {
313  fetchDone = true;
314  instPtr = thread->decoder.decode(pcState);
315  thread->pcState(pcState);
316  } else {
317  fetchDone = false;
318  fetchOffset += sizeof(TheISA::MachInst);
319  }
320 
321  //If we decoded an instruction and it's microcoded,
322  //start pulling out micro ops
323  if (instPtr && instPtr->isMacroop()) {
324  curMacroStaticInst = instPtr;
325  curStaticInst =
326  instPtr->fetchMicroop(pcState.microPC());
327  } else {
328  curStaticInst = instPtr;
329  }
330  } else {
331  // Read the next micro op from the macro-op
332  curStaticInst =
333  curMacroStaticInst->fetchMicroop(pcState.microPC());
334  fetchDone = true;
335  }
336  }
337  }
338  // reset decoder on Checker
339  thread->decoder.reset();
340 
341  // Check Checker and CPU get same instruction, and record
342  // any faults the CPU may have had.
343  Fault unverifiedFault;
344  if (fault == NoFault) {
345  unverifiedFault = unverifiedInst->getFault();
346 
347  // Checks that the instruction matches what we expected it to be.
348  // Checks both the machine instruction and the PC.
349  validateInst(unverifiedInst);
350  }
351 
352  // keep an instruction count
353  numInst++;
354 
355 
356  // Either the instruction was a fault and we should process the fault,
357  // or we should just go ahead execute the instruction. This assumes
358  // that the instruction is properly marked as a fault.
359  if (fault == NoFault) {
360  // Execute Checker instruction and trace
361  if (!unverifiedInst->isUnverifiable()) {
362  Trace::InstRecord *traceData = tracer->getInstRecord(curTick(),
363  tc,
364  curStaticInst,
365  pcState(),
366  curMacroStaticInst);
367  fault = curStaticInst->execute(this, traceData);
368  if (traceData) {
369  traceData->dump();
370  delete traceData;
371  }
372  }
373 
374  if (fault == NoFault && unverifiedFault == NoFault) {
375  thread->funcExeInst++;
376  // Checks to make sure instrution results are correct.
377  validateExecution(unverifiedInst);
378 
379  if (curStaticInst->isLoad()) {
380  ++numLoad;
381  }
382  } else if (fault != NoFault && unverifiedFault == NoFault) {
383  panic("%lli: sn: %lli at PC: %s took a fault in checker "
384  "but not in driver CPU\n", curTick(),
385  unverifiedInst->seqNum, unverifiedInst->pcState());
386  } else if (fault == NoFault && unverifiedFault != NoFault) {
387  panic("%lli: sn: %lli at PC: %s took a fault in driver "
388  "CPU but not in checker\n", curTick(),
389  unverifiedInst->seqNum, unverifiedInst->pcState());
390  }
391  }
392 
393  // Take any faults here
394  if (fault != NoFault) {
395  if (FullSystem) {
396  fault->invoke(tc, curStaticInst);
397  willChangePC = true;
398  newPCState = thread->pcState();
399  DPRINTF(Checker, "Fault, PC is now %s\n", newPCState);
400  curMacroStaticInst = StaticInst::nullStaticInstPtr;
401  }
402  } else {
403  advancePC(fault);
404  }
405 
406  if (FullSystem) {
407  // @todo: Determine if these should happen only if the
408  // instruction hasn't faulted. In the SimpleCPU case this may
409  // not be true, but in the O3 case this may be true.
410  Addr oldpc;
411  int count = 0;
412  do {
413  oldpc = thread->instAddr();
414  thread->pcEventQueue.service(oldpc, tc);
415  count++;
416  } while (oldpc != thread->instAddr());
417  if (count > 1) {
418  willChangePC = true;
419  newPCState = thread->pcState();
420  DPRINTF(Checker, "PC Event, PC is now %s\n", newPCState);
421  }
422  }
423 
424  // @todo: Optionally can check all registers. (Or just those
425  // that have been modified).
426  validateState();
427 
428  // Continue verifying instructions if there's another completed
429  // instruction waiting to be verified.
430  if (instList.empty()) {
431  break;
432  } else if (instList.front()->isCompleted()) {
433  unverifiedInst = NULL;
434  unverifiedInst = instList.front();
435  instList.pop_front();
436  } else {
437  break;
438  }
439  }
440  unverifiedInst = NULL;
441 }
442 
443 template <class Impl>
444 void
446 {
447  instList.clear();
448 }
449 
450 template <class Impl>
451 void
453 {
454 }
455 
456 template <class Impl>
457 void
459 {
460  if (inst->instAddr() != thread->instAddr()) {
461  warn("%lli: PCs do not match! Inst: %s, checker: %s",
462  curTick(), inst->pcState(), thread->pcState());
463  if (changedPC) {
464  warn("%lli: Changed PCs recently, may not be an error",
465  curTick());
466  } else {
467  handleError(inst);
468  }
469  }
470 
471  if (curStaticInst != inst->staticInst) {
472  warn("%lli: StaticInstPtrs don't match. (%s, %s).\n", curTick(),
473  curStaticInst->getName(), inst->staticInst->getName());
474  }
475 }
476 
477 template <class Impl>
478 void
480 {
481  InstResult checker_val;
482  InstResult inst_val;
483  int idx = -1;
484  bool result_mismatch = false;
485  bool scalar_mismatch = false;
486  bool vector_mismatch = false;
487 
488  if (inst->isUnverifiable()) {
489  // Unverifiable instructions assume they were executed
490  // properly by the CPU. Grab the result from the
491  // instruction and write it to the register.
492  copyResult(inst, InstResult(0ul, InstResult::ResultType::Scalar), idx);
493  } else if (inst->numDestRegs() > 0 && !result.empty()) {
494  DPRINTF(Checker, "Dest regs %d, number of checker dest regs %d\n",
495  inst->numDestRegs(), result.size());
496  for (int i = 0; i < inst->numDestRegs() && !result.empty(); i++) {
497  checker_val = result.front();
498  result.pop();
499  inst_val = inst->popResult(
501  if (checker_val != inst_val) {
502  result_mismatch = true;
503  idx = i;
504  scalar_mismatch = checker_val.isScalar();
505  vector_mismatch = checker_val.isVector();
506  panic_if(!(scalar_mismatch || vector_mismatch),
507  "Unknown type of result\n");
508  }
509  }
510  } // Checker CPU checks all the saved results in the dyninst passed by
511  // the cpu model being checked against the saved results present in
512  // the static inst executed in the Checker. Sometimes the number
513  // of saved results differs between the dyninst and static inst, but
514  // this is ok and not a bug. May be worthwhile to try and correct this.
515 
516  if (result_mismatch) {
517  if (scalar_mismatch) {
518  warn("%lli: Instruction results (%i) do not match! (Values may"
519  " not actually be integers) Inst: %#x, checker: %#x",
520  curTick(), idx, inst_val.asIntegerNoAssert(),
521  checker_val.asInteger());
522  }
523 
524  // It's useful to verify load values from memory, but in MP
525  // systems the value obtained at execute may be different than
526  // the value obtained at completion. Similarly DMA can
527  // present the same problem on even UP systems. Thus there is
528  // the option to only warn on loads having a result error.
529  // The load/store queue in Detailed CPU can also cause problems
530  // if load/store forwarding is allowed.
531  if (inst->isLoad() && warnOnlyOnLoadError) {
532  copyResult(inst, inst_val, idx);
533  } else {
534  handleError(inst);
535  }
536  }
537 
538  if (inst->nextInstAddr() != thread->nextInstAddr()) {
539  warn("%lli: Instruction next PCs do not match! Inst: %#x, "
540  "checker: %#x",
541  curTick(), inst->nextInstAddr(), thread->nextInstAddr());
542  handleError(inst);
543  }
544 
545  // Checking side effect registers can be difficult if they are not
546  // checked simultaneously with the execution of the instruction.
547  // This is because other valid instructions may have modified
548  // these registers in the meantime, and their values are not
549  // stored within the DynInst.
550  while (!miscRegIdxs.empty()) {
551  int misc_reg_idx = miscRegIdxs.front();
552  miscRegIdxs.pop();
553 
554  if (inst->tcBase()->readMiscRegNoEffect(misc_reg_idx) !=
555  thread->readMiscRegNoEffect(misc_reg_idx)) {
556  warn("%lli: Misc reg idx %i (side effect) does not match! "
557  "Inst: %#x, checker: %#x",
558  curTick(), misc_reg_idx,
559  inst->tcBase()->readMiscRegNoEffect(misc_reg_idx),
560  thread->readMiscRegNoEffect(misc_reg_idx));
561  handleError(inst);
562  }
563  }
564 }
565 
566 
567 // This function is weird, if it is called it means the Checker and
568 // O3 have diverged, so panic is called for now. It may be useful
569 // to resynch states and continue if the divergence is a false positive
570 template <class Impl>
571 void
573 {
574  if (updateThisCycle) {
575  // Change this back to warn if divergences end up being false positives
576  panic("%lli: Instruction PC %#x results didn't match up, copying all "
577  "registers from main CPU", curTick(), unverifiedInst->instAddr());
578 
579  // Terribly convoluted way to make sure O3 model does not implode
580  bool no_squash_from_TC = unverifiedInst->thread->noSquashFromTC;
581  unverifiedInst->thread->noSquashFromTC = true;
582 
583  // Heavy-weight copying of all registers
584  thread->copyArchRegs(unverifiedInst->tcBase());
585  unverifiedInst->thread->noSquashFromTC = no_squash_from_TC;
586 
587  // Set curStaticInst to unverifiedInst->staticInst
588  curStaticInst = unverifiedInst->staticInst;
589  // Also advance the PC. Hopefully no PC-based events happened.
591  updateThisCycle = false;
592  }
593 }
594 
595 template <class Impl>
596 void
598  const InstResult& mismatch_val, int start_idx)
599 {
600  // We've already popped one dest off the queue,
601  // so do the fix-up then start with the next dest reg;
602  if (start_idx >= 0) {
603  const RegId& idx = inst->destRegIdx(start_idx);
604  switch (idx.classValue()) {
605  case IntRegClass:
606  panic_if(!mismatch_val.isScalar(), "Unexpected type of result");
607  thread->setIntReg(idx.index(), mismatch_val.asInteger());
608  break;
609  case FloatRegClass:
610  panic_if(!mismatch_val.isScalar(), "Unexpected type of result");
611  thread->setFloatReg(idx.index(), mismatch_val.asInteger());
612  break;
613  case VecRegClass:
614  panic_if(!mismatch_val.isVector(), "Unexpected type of result");
615  thread->setVecReg(idx, mismatch_val.asVector());
616  break;
617  case VecElemClass:
618  panic_if(!mismatch_val.isVecElem(),
619  "Unexpected type of result");
620  thread->setVecElem(idx, mismatch_val.asVectorElem());
621  break;
622  case CCRegClass:
623  panic_if(!mismatch_val.isScalar(), "Unexpected type of result");
624  thread->setCCReg(idx.index(), mismatch_val.asInteger());
625  break;
626  case MiscRegClass:
627  panic_if(!mismatch_val.isScalar(), "Unexpected type of result");
628  thread->setMiscReg(idx.index(), mismatch_val.asInteger());
629  break;
630  default:
631  panic("Unknown register class: %d", (int)idx.classValue());
632  }
633  }
634  start_idx++;
635  InstResult res;
636  for (int i = start_idx; i < inst->numDestRegs(); i++) {
637  const RegId& idx = inst->destRegIdx(i);
638  res = inst->popResult();
639  switch (idx.classValue()) {
640  case IntRegClass:
641  panic_if(!res.isScalar(), "Unexpected type of result");
642  thread->setIntReg(idx.index(), res.asInteger());
643  break;
644  case FloatRegClass:
645  panic_if(!res.isScalar(), "Unexpected type of result");
646  thread->setFloatReg(idx.index(), res.asInteger());
647  break;
648  case VecRegClass:
649  panic_if(!res.isVector(), "Unexpected type of result");
650  thread->setVecReg(idx, res.asVector());
651  break;
652  case VecElemClass:
653  panic_if(!res.isVecElem(), "Unexpected type of result");
654  thread->setVecElem(idx, res.asVectorElem());
655  break;
656  case CCRegClass:
657  panic_if(!res.isScalar(), "Unexpected type of result");
658  thread->setCCReg(idx.index(), res.asInteger());
659  break;
660  case MiscRegClass:
661  panic_if(res.isValid(), "MiscReg expecting invalid result");
662  // Try to get the proper misc register index for ARM here...
663  thread->setMiscReg(idx.index(), 0);
664  break;
665  // else Register is out of range...
666  default:
667  panic("Unknown register class: %d", (int)idx.classValue());
668  }
669  }
670 }
671 
672 template <class Impl>
673 void
675 {
676  cprintf("Error detected, instruction information:\n");
677  cprintf("PC:%s, nextPC:%#x\n[sn:%lli]\n[tid:%i]\n"
678  "Completed:%i\n",
679  inst->pcState(),
680  inst->nextInstAddr(),
681  inst->seqNum,
682  inst->threadNumber,
683  inst->isCompleted());
684  inst->dump();
686 }
687 
688 template <class Impl>
689 void
691 {
692  int num = 0;
693 
694  InstListIt inst_list_it = --(instList.end());
695 
696  cprintf("Inst list size: %i\n", instList.size());
697 
698  while (inst_list_it != instList.end())
699  {
700  cprintf("Instruction:%i\n",
701  num);
702 
703  cprintf("PC:%s\n[sn:%lli]\n[tid:%i]\n"
704  "Completed:%i\n",
705  (*inst_list_it)->pcState(),
706  (*inst_list_it)->seqNum,
707  (*inst_list_it)->threadNumber,
708  (*inst_list_it)->isCompleted());
709 
710  cprintf("\n");
711 
712  inst_list_it--;
713  ++num;
714  }
715 
716 }
717 
718 #endif//__CPU_CHECKER_CPU_IMPL_HH__
const uint64_t & asInteger() const
Explicit cast-like operations.
Definition: inst_res.hh:168
virtual void dump()=0
count
Definition: misc.hh:705
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
const VecElem & asVectorElem() const
Definition: inst_res.hh:190
#define DPRINTF(x,...)
Definition: trace.hh:229
decltype(nullptr) constexpr NoFault
Definition: types.hh:245
std::list< DynInstPtr >::iterator InstListIt
Definition: cpu.hh:664
Floating-point register.
Definition: reg_class.hh:58
Bitfield< 7 > i
O3CPUImpl ::DynInstPtr DynInstPtr
Definition: cpu.hh:625
void validateInst(const DynInstPtr &inst)
Definition: cpu_impl.hh:458
Control (misc) register.
Definition: reg_class.hh:65
bool isMacroop() const
Definition: static_inst.hh:196
void verify(const DynInstPtr &inst)
Definition: cpu_impl.hh:127
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:136
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:586
void handlePendingInt()
Definition: cpu_impl.hh:93
void copyResult(const DynInstPtr &inst, const InstResult &mismatch_val, int start_idx)
Definition: cpu_impl.hh:597
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
Definition: packet.hh:1040
Templated Checker class.
Definition: cpu.hh:622
uint32_t MachInst
Definition: types.hh:40
Vector Register Native Elem lane.
Definition: reg_class.hh:62
Classes for managing reference counted objects.
Tick curTick()
The current simulated tick.
Definition: core.hh:47
TheISA::PCState pcState() const override
Definition: cpu.hh:441
bool isVector() const
Is this a vector result?.
Definition: inst_res.hh:156
void advancePC(const Fault &fault)
Definition: cpu_impl.hh:72
virtual StaticInstPtr fetchMicroop(MicroPC upc) const
Return the microop that goes with a particular micropc.
Definition: static_inst.cc:100
const RegIndex ZeroReg
Definition: registers.hh:75
Condition-code register.
Definition: reg_class.hh:64
STL list class.
Definition: stl.hh:54
bool isScalar() const
Checks.
Definition: inst_res.hh:154
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void advancePC(PCState &pc, const StaticInstPtr &inst)
Definition: utility.hh:98
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
static bool isRomMicroPC(MicroPC upc)
Definition: types.hh:161
The request was an instruction fetch.
Definition: request.hh:105
const VecRegContainer & asVector() const
Definition: inst_res.hh:184
GenericISA::SimplePCState< MachInst > PCState
Definition: types.hh:43
const RegClass & classValue() const
Class accessor.
Definition: reg_class.hh:206
void takeOverFrom(BaseCPU *oldCPU)
Load the state of a CPU from the previous CPU object, invoked on all new CPUs that are about to be sw...
Definition: cpu_impl.hh:452
void validateExecution(const DynInstPtr &inst)
Definition: cpu_impl.hh:479
void validateState()
Definition: cpu_impl.hh:572
const RegIndex & index() const
Index accessors.
Definition: reg_class.hh:179
bool isVecElem() const
Is this a vector element result?.
Definition: inst_res.hh:158
void switchOut()
Prepare for another CPU to take over execution.
Definition: cpu_impl.hh:445
Defines a dynamic instruction context.
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:79
Integer register.
Definition: reg_class.hh:57
void dumpInsts()
Definition: cpu_impl.hh:690
Vector Register.
Definition: reg_class.hh:60
#define warn(...)
Definition: logging.hh:212
TheISA::MachInst MachInst
Definition: cpu.hh:90
bool isValid() const
Is this a valid result?.
Definition: inst_res.hh:162
static StaticInstPtr nullStaticInstPtr
Pointer to a statically allocated "null" instruction object.
Definition: static_inst.hh:223
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:185
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
void dumpAndExit()
Definition: cpu.cc:389
void handleError()
Definition: cpu.hh:587
void cprintf(const char *format, const Args &...args)
Definition: cprintf.hh:156
ProbePointArg< PacketInfo > Packet
Packet probe point.
Definition: mem.hh:104
const uint64_t & asIntegerNoAssert() const
Cast to integer without checking type.
Definition: inst_res.hh:179

Generated on Fri Feb 28 2020 16:26:59 for gem5 by doxygen 1.8.13