base.cc (4181:6edaeff44647) base.cc (4182:5b2c0d266107)
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

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

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 StaticInstPtr instPtr = NULL;
371
372 //Predecode, ie bundle up an ExtMachInst
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

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

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 StaticInstPtr instPtr = NULL;
371
372 //Predecode, ie bundle up an ExtMachInst
373 unsigned int result =
374 predecode(extMachInst, thread->readPC(), inst, thread->getTC());
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();
375 //If an instruction is ready, decode it
380 //If an instruction is ready, decode it
376 if (result & ExtMIReady)
377 instPtr = StaticInst::decode(extMachInst);
381 if (predecoder.extMachInstReady())
382 instPtr = StaticInst::decode(predecoder.getExtMachInst());
378
379 //If we decoded an instruction and it's microcoded, start pulling
380 //out micro ops
381 if (instPtr && instPtr->isMacroOp()) {
382 curMacroStaticInst = instPtr;
383 curStaticInst = curMacroStaticInst->
384 fetchMicroOp(thread->readMicroPC());
385 } else {

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

441void
442BaseSimpleCPU::advancePC(Fault fault)
443{
444 if (fault != NoFault) {
445 curMacroStaticInst = StaticInst::nullStaticInstPtr;
446 fault->invoke(tc);
447 thread->setMicroPC(0);
448 thread->setNextMicroPC(1);
383
384 //If we decoded an instruction and it's microcoded, start pulling
385 //out micro ops
386 if (instPtr && instPtr->isMacroOp()) {
387 curMacroStaticInst = instPtr;
388 curStaticInst = curMacroStaticInst->
389 fetchMicroOp(thread->readMicroPC());
390 } else {

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