base.cc (4216:c01745179a1f) base.cc (4240:cde9d7751cce)
1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 56 unchanged lines hidden (view full) ---

65#else // !FULL_SYSTEM
66#include "mem/mem_object.hh"
67#endif // FULL_SYSTEM
68
69using namespace std;
70using namespace TheISA;
71
72BaseSimpleCPU::BaseSimpleCPU(Params *p)
1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 56 unchanged lines hidden (view full) ---

65#else // !FULL_SYSTEM
66#include "mem/mem_object.hh"
67#endif // FULL_SYSTEM
68
69using namespace std;
70using namespace TheISA;
71
72BaseSimpleCPU::BaseSimpleCPU(Params *p)
73 : BaseCPU(p), thread(NULL)
73 : BaseCPU(p), thread(NULL), predecoder(NULL)
74{
75#if FULL_SYSTEM
76 thread = new SimpleThread(this, 0, p->system, p->itb, p->dtb);
77#else
78 thread = new SimpleThread(this, /* thread_num */ 0, p->process,
79 /* asid */ 0);
80#endif // !FULL_SYSTEM
81

--- 280 unchanged lines hidden (view full) ---

362
363 // check for instruction-count-based events
364 comInstEventQueue[0]->serviceEvents(numInst);
365
366 // decode the instruction
367 inst = gtoh(inst);
368 //If we're not in the middle of a macro instruction
369 if (!curMacroStaticInst) {
74{
75#if FULL_SYSTEM
76 thread = new SimpleThread(this, 0, p->system, p->itb, p->dtb);
77#else
78 thread = new SimpleThread(this, /* thread_num */ 0, p->process,
79 /* asid */ 0);
80#endif // !FULL_SYSTEM
81

--- 280 unchanged lines hidden (view full) ---

362
363 // check for instruction-count-based events
364 comInstEventQueue[0]->serviceEvents(numInst);
365
366 // decode the instruction
367 inst = gtoh(inst);
368 //If we're not in the middle of a macro instruction
369 if (!curMacroStaticInst) {
370#if THE_ISA == ALPHA_ISA
371 StaticInstPtr instPtr = StaticInst::decode(makeExtMI(inst, thread->readPC()));
372#elif THE_ISA == SPARC_ISA
373 StaticInstPtr instPtr = StaticInst::decode(makeExtMI(inst, thread->getTC()));
374#elif THE_ISA == X86_ISA
375 StaticInstPtr instPtr = StaticInst::decode(makeExtMI(inst, thread->getTC()));
376#elif THE_ISA == MIPS_ISA
377 //Mips doesn't do anything in it's MakeExtMI function right now,
378 //so it won't be called.
379 StaticInstPtr instPtr = StaticInst::decode(inst);
380#endif
381 if (instPtr->isMacroOp()) {
370 StaticInstPtr instPtr = NULL;
371
372 //Predecode, ie bundle up an ExtMachInst
373 //This should go away once the constructor can be set up properly
374 predecoder.setTC(thread->getTC());
375 //If more fetch data is needed, pass it in.
376 if(predecoder.needMoreBytes())
377 predecoder.moreBytes(thread->readPC(), 0, inst);
378 else
379 predecoder.process();
380 //If an instruction is ready, decode it
381 if (predecoder.extMachInstReady())
382 instPtr = StaticInst::decode(predecoder.getExtMachInst());
383
384 //If we decoded an instruction and it's microcoded, start pulling
385 //out micro ops
386 if (instPtr && instPtr->isMacroOp()) {
382 curMacroStaticInst = instPtr;
383 curStaticInst = curMacroStaticInst->
384 fetchMicroOp(thread->readMicroPC());
385 } else {
386 curStaticInst = instPtr;
387 }
388 } else {
389 //Read the next micro op from the macro op
390 curStaticInst = curMacroStaticInst->
391 fetchMicroOp(thread->readMicroPC());
392 }
393
387 curMacroStaticInst = instPtr;
388 curStaticInst = curMacroStaticInst->
389 fetchMicroOp(thread->readMicroPC());
390 } else {
391 curStaticInst = instPtr;
392 }
393 } else {
394 //Read the next micro op from the macro op
395 curStaticInst = curMacroStaticInst->
396 fetchMicroOp(thread->readMicroPC());
397 }
398
399 //If we decoded an instruction this "tick", record information about it.
400 if(curStaticInst)
401 {
402 traceData = Trace::getInstRecord(curTick, tc, curStaticInst,
403 thread->readPC());
394
404
395 traceData = Trace::getInstRecord(curTick, tc, curStaticInst,
396 thread->readPC());
405 DPRINTF(Decode,"Decode: Decoded %s instruction: 0x%x\n",
406 curStaticInst->getName(), curStaticInst->machInst);
397
407
398 DPRINTF(Decode,"Decode: Decoded %s instruction (opcode: 0x%x): 0x%x\n",
399 curStaticInst->getName(), curStaticInst->getOpcode(),
400 curStaticInst->machInst);
401
402#if FULL_SYSTEM
408#if FULL_SYSTEM
403 thread->setInst(inst);
409 thread->setInst(inst);
404#endif // FULL_SYSTEM
410#endif // FULL_SYSTEM
411 }
405}
406
407void
408BaseSimpleCPU::postExecute()
409{
410#if FULL_SYSTEM
411 if (thread->profile) {
412 bool usermode = TheISA::inUserMode(tc);

--- 26 unchanged lines hidden (view full) ---

439void
440BaseSimpleCPU::advancePC(Fault fault)
441{
442 if (fault != NoFault) {
443 curMacroStaticInst = StaticInst::nullStaticInstPtr;
444 fault->invoke(tc);
445 thread->setMicroPC(0);
446 thread->setNextMicroPC(1);
412}
413
414void
415BaseSimpleCPU::postExecute()
416{
417#if FULL_SYSTEM
418 if (thread->profile) {
419 bool usermode = TheISA::inUserMode(tc);

--- 26 unchanged lines hidden (view full) ---

446void
447BaseSimpleCPU::advancePC(Fault fault)
448{
449 if (fault != NoFault) {
450 curMacroStaticInst = StaticInst::nullStaticInstPtr;
451 fault->invoke(tc);
452 thread->setMicroPC(0);
453 thread->setNextMicroPC(1);
447 } else {
454 } else if (predecoder.needMoreBytes()) {
448 //If we're at the last micro op for this instruction
455 //If we're at the last micro op for this instruction
449 if (curStaticInst->isLastMicroOp()) {
456 if (curStaticInst && curStaticInst->isLastMicroOp()) {
450 //We should be working with a macro op
451 assert(curMacroStaticInst);
452 //Close out this macro op, and clean up the
453 //microcode state
454 curMacroStaticInst = StaticInst::nullStaticInstPtr;
455 thread->setMicroPC(0);
456 thread->setNextMicroPC(1);
457 }
458 //If we're still in a macro op
459 if (curMacroStaticInst) {
460 //Advance the micro pc
461 thread->setMicroPC(thread->readNextMicroPC());
462 //Advance the "next" micro pc. Note that there are no delay
463 //slots, and micro ops are "word" addressed.
464 thread->setNextMicroPC(thread->readNextMicroPC() + 1);
465 } else {
466 // go to the next instruction
467 thread->setPC(thread->readNextPC());
457 //We should be working with a macro op
458 assert(curMacroStaticInst);
459 //Close out this macro op, and clean up the
460 //microcode state
461 curMacroStaticInst = StaticInst::nullStaticInstPtr;
462 thread->setMicroPC(0);
463 thread->setNextMicroPC(1);
464 }
465 //If we're still in a macro op
466 if (curMacroStaticInst) {
467 //Advance the micro pc
468 thread->setMicroPC(thread->readNextMicroPC());
469 //Advance the "next" micro pc. Note that there are no delay
470 //slots, and micro ops are "word" addressed.
471 thread->setNextMicroPC(thread->readNextMicroPC() + 1);
472 } else {
473 // go to the next instruction
474 thread->setPC(thread->readNextPC());
468#if ISA_HAS_DELAY_SLOT
469 thread->setNextPC(thread->readNextNPC());
470 thread->setNextNPC(thread->readNextNPC() + sizeof(MachInst));
471 assert(thread->readNextPC() != thread->readNextNPC());
475 thread->setNextPC(thread->readNextNPC());
476 thread->setNextNPC(thread->readNextNPC() + sizeof(MachInst));
477 assert(thread->readNextPC() != thread->readNextNPC());
472#else
473 thread->setNextPC(thread->readNextPC() + sizeof(MachInst));
474#endif
475 }
476 }
477
478#if FULL_SYSTEM
479 Addr oldpc;
480 do {
481 oldpc = thread->readPC();
482 system->pcEventQueue.service(tc);
483 } while (oldpc != thread->readPC());
484#endif
485}
486
478 }
479 }
480
481#if FULL_SYSTEM
482 Addr oldpc;
483 do {
484 oldpc = thread->readPC();
485 system->pcEventQueue.service(tc);
486 } while (oldpc != thread->readPC());
487#endif
488}
489